Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415// The client's signing key, for confidential-client authentication (public// mode only). In loopback development there is nowhere to serve a JWKS from,// so no key is used.import { chmodSync, existsSync, readFileSync, writeFileSync } from "node:fs"import { JoseKey } from "@atproto/oauth-client-node"
export async function loadOrCreateKey(path) { if (existsSync(path)) { return JoseKey.fromImportable(JSON.parse(readFileSync(path, "utf8"))) } const key = await JoseKey.generate(["ES256"], "pi-collab-1") writeFileSync(path, JSON.stringify(key.privateJwk, null, 2), { mode: 0o600 }) chmodSync(path, 0o600) return key}