Something went wrong. Try again.
A decentralized music tracking and discovery platform built on AT Protocol ๐ต rocksky.app
spotify atproto lastfm musicbrainz scrobbling listenbrainz
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041import { isValidHandle } from "@atproto/syntax";import { env } from "./env";import { logger } from "logger";import { ctx } from "context";import chalk from "chalk";import { c } from "theme";
export async function getDidAndHandle(): Promise<[string, string]> { let handle = env.ROCKSKY_HANDLE || env.ROCKSKY_IDENTIFIER; let did = env.ROCKSKY_HANDLE || env.ROCKSKY_IDENTIFIER;
if (!handle) { console.error( `โ No AT Proto handle or DID provided, please provide one in the environment variables ${chalk.bold("ROCKSKY_HANDLE")} or ${chalk.bold("ROCKSKY_IDENTIFIER")}`, ); process.exit(1); }
if (!env.ROCKSKY_PASSWORD) { console.error( `โ No app password provided, please provide one in the environment variable ${chalk.bold("ROCKSKY_PASSWORD")}\nYou can create one at ${c.link("https://bsky.app/settings/app-passwords")}`, ); process.exit(1); }
if (handle.startsWith("did:plc:") || handle.startsWith("did:web:")) { handle = await ctx.resolver.resolveDidToHandle(handle); }
if (!isValidHandle(handle)) { logger.error`โ Invalid handle: ${handle}`; process.exit(1); }
if (!did.startsWith("did:plc:") && !did.startsWith("did:web:")) { did = await ctx.baseIdResolver.handle.resolve(did); }
return [did, handle];}