import {P256PrivateKey, parsePrivateMultikey} from 'npm:@atcute/crypto'; import * as CBOR from 'npm:@atcute/cbor'; import {fromBase16, toBase64Url} from 'npm:@atcute/multibase'; // use ur own private key const PRIVKEY = ""; // shamelessly stolen from pds moover const HEX_REGEX = /^[0-9a-f]+$/i; const MULTIKEY_REGEX = /^z[a-km-zA-HJ-NP-Z1-9]+$/; const KEYPAIR = HEX_REGEX.test(PRIVKEY) ? (await P256PrivateKey.importRaw(fromBase16(PRIVKEY))) : ( MULTIKEY_REGEX.test(PRIVKEY) ? (await P256PrivateKey.importRaw(parsePrivateMultikey(PRIVKEY).privateKeyBytes)) : (() => {throw "could not parse key; shits malformed lol"})() ); const OP = { type: "plc_operation", // make sure to replace prev with your previous op cid (plc.directory/did/log/audit, latest op) prev: "bafyreicolpsmfigl72pqrfyiiyaqawhqe5d3waa3bhvk37hbevxfwtyvoe", // get this data from your current doc + whatever else you want to include. ex: rotationKeys: [ "did:key:zDnaeQm8B5eH4c6aJ5ZAbWMNCsRerrjnZZVau1dKucaosW2S4", "did:key:zQ3shfC9s6jzyvt8155tUwSRG55sGzynT1uLWsnmFrE4bTMFM", ], verificationMethods: { atproto: "did:key:zQ3sham9NEsqzb7RPQ18YgoFT9rTHUd7UVEhH2usxwtb39398", }, alsoKnownAs: ["at://vielle.dev", "at://afterlifepro.neocities.org"], services: { atproto_pds: { type: "AtprotoPersonalDataServer", endpoint: "https://katproto.girlonthemoon.xyz", }, self: { type: "PersonalWebbedSite", endpoint: "https://vielle.dev", }, }, }; // sign the operation const OPBYTES = CBOR.encode(OP) const SIGBYTES = await KEYPAIR.sign(OPBYTES) const SIG = toBase64Url(SIGBYTES) const SIGNEDOP = {...OP, sig: SIG} console.log(JSON.stringify(SIGNEDOP)) // final step: post this to plc.directory/did (better to use pds via `goat account plc submit file_with_signed_op.json`)