Something went wrong. Try again.
quick script i threw together to make a signing op and ig ill post it as my first string lolol
Something went wrong. Try again.
1.8 kB · 52 lines · Created 10mo ago
TypeScript
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152import {P256PrivateKey, parsePrivateMultikey} from 'npm:@atcute/crypto';import * as CBOR from 'npm:@atcute/cbor';import {fromBase16, toBase64Url} from 'npm:@atcute/multibase';
// use ur own private keyconst PRIVKEY = "<YOUR KEY HERE>";
// shamelessly stolen from pds mooverconst 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 operationconst 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`)