···11import { AtpAgent, ComAtprotoIdentitySignPlcOperation } from "@atproto/api";
22-import { P256Keypair, Secp256k1Keypair } from "@atproto/crypto";
22+import { Secp256k1Keypair } from "@atproto/crypto";
33import * as ui8 from "uint8arrays";
44import { loginAgentOrCredentials } from "./util.js";
55···2323 /** An agent logged into the labeler account. You must provide either `password` or `agent`. */
2424 agent?: AtpAgent;
25252626- /** You may choose to provide your own signing key to use for the labeler. */
2626+ /**
2727+ * You may choose to provide your own hex-encoded secp256k1 signing key to use for the labeler.
2828+ * Leave this empty to generate a new keypair.
2929+ */
2730 privateKey?: string | Uint8Array;
2828- /** The algorithm of the provided private key. */
2929- privateKeyAlgorithm?: "secp256k1" | "secp256r1";
3031 /** Whether to overwrite the existing label signing key if one is already set. */
3132 overwriteExistingKey?: boolean;
3233}
···5354 await agent.login({ identifier: options.did, password: options.password });
5455 }
55565656- let keypair: Secp256k1Keypair | P256Keypair;
5757- if (options.privateKey) {
5858- if (options.privateKeyAlgorithm === "secp256r1") {
5959- keypair = await P256Keypair.import(options.privateKey);
6060- } else if (options.privateKeyAlgorithm === "secp256k1") {
6161- keypair = await Secp256k1Keypair.import(options.privateKey);
6262- } else {
6363- throw new Error("Invalid private key algorithm.");
6464- }
6565- } else {
6666- keypair = await Secp256k1Keypair.create({ exportable: true });
6767- }
5757+ const keypair = options.privateKey
5858+ ? await Secp256k1Keypair.import(options.privateKey)
5959+ : await Secp256k1Keypair.create({ exportable: true });
68606961 const keyDid = keypair.did();
7062