this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Validate labeler signing key

futurGH 0f309eb7 7ddc1b65

+13 -1
+13 -1
src/LabelerServer.ts
··· 23 23 } from "./util/types.js"; 24 24 import { excludeNullish, frameToBytes } from "./util/util.js"; 25 25 26 + const INVALID_SIGNING_KEY_ERROR = `Make sure to provide a private signing key, not a public key. 27 + 28 + If you don't have a key, generate and set one using the \`npx @skyware/labeler setup\` command or the \`import { plcSetupLabeler } from "@skyware/labeler/scripts"\` function. 29 + For more information, see https://skyware.js.org/guides/labeler/introduction/getting-started/`; 30 + 26 31 /** 27 32 * Options for the {@link LabelerServer} class. 28 33 */ ··· 74 79 */ 75 80 constructor(options: LabelerOptions) { 76 81 this.did = options.did as At.DID; 82 + this.auth = options.auth ?? ((did) => did === this.did); 83 + 84 + if (options.signingKey.startsWith("did:key:")) { 85 + throw new Error(INVALID_SIGNING_KEY_ERROR); 86 + } 77 87 this.#signingKey = ui8FromString(options.signingKey, "hex"); 78 - this.auth = options.auth ?? ((did) => did === this.did); 88 + if (this.#signingKey.byteLength !== 32) { 89 + throw new Error(INVALID_SIGNING_KEY_ERROR); 90 + } 79 91 80 92 this.db = new Database(options.dbPath ?? "labels.db"); 81 93 this.db.pragma("journal_mode = WAL");