@getcirrus/space-conformance 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base-D8a-ZK57.d.ts +249 -0
- package/dist/base-D8a-ZK57.d.ts.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +373 -0
- package/dist/cli.js.map +1 -0
- package/dist/coverage-DhJZu8P8.js +1914 -0
- package/dist/coverage-DhJZu8P8.js.map +1 -0
- package/dist/full-D4ufJLcw.js +409 -0
- package/dist/full-D4ufJLcw.js.map +1 -0
- package/dist/full.d.ts +59 -0
- package/dist/full.d.ts.map +1 -0
- package/dist/full.js +4 -0
- package/dist/index.d.ts +178 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +114 -0
- package/dist/index.js.map +1 -0
- package/dist/operator-BErXCDow.js +923 -0
- package/dist/operator-BErXCDow.js.map +1 -0
- package/lexicons/MANIFEST.json +7 -0
- package/lexicons/simplespace/addMember.json +37 -0
- package/lexicons/simplespace/checkUserAccess.json +43 -0
- package/lexicons/simplespace/createSpace.json +74 -0
- package/lexicons/simplespace/defs.json +47 -0
- package/lexicons/simplespace/deleteSpace.json +32 -0
- package/lexicons/simplespace/getSpace.json +53 -0
- package/lexicons/simplespace/listMembers.json +65 -0
- package/lexicons/simplespace/removeMember.json +37 -0
- package/lexicons/simplespace/updateSpace.json +57 -0
- package/lexicons/space/applyWrites.json +163 -0
- package/lexicons/space/createRecord.json +79 -0
- package/lexicons/space/defs.json +38 -0
- package/lexicons/space/deleteRecord.json +51 -0
- package/lexicons/space/getBlob.json +54 -0
- package/lexicons/space/getDelegationToken.json +34 -0
- package/lexicons/space/getLatestCommit.json +57 -0
- package/lexicons/space/getRecord.json +76 -0
- package/lexicons/space/getRepo.json +41 -0
- package/lexicons/space/getSpaceCredential.json +67 -0
- package/lexicons/space/listBlobs.json +59 -0
- package/lexicons/space/listRecords.json +108 -0
- package/lexicons/space/listRepoOps.json +111 -0
- package/lexicons/space/listRepos.json +75 -0
- package/lexicons/space/listSpaces.json +65 -0
- package/lexicons/space/notifySpaceDeleted.json +24 -0
- package/lexicons/space/notifyWrite.json +38 -0
- package/lexicons/space/putRecord.json +75 -0
- package/lexicons/space/registerNotify.json +49 -0
- package/lexicons/space/unregisterNotify.json +29 -0
- package/package.json +53 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverage-DhJZu8P8.js","names":["logs: string[]","ctx: CheckContext","results: CheckResult[]","checkCtx: CheckContext","id","lines: string[]","lexicons: LexiconDoc[]","space_applyWrites","space_createRecord","space_defs","space_deleteRecord","space_getBlob","space_getDelegationToken","space_getLatestCommit","space_getRecord","space_getRepo","space_getSpaceCredential","space_listBlobs","space_listRecords","space_listRepoOps","space_listRepos","space_listSpaces","space_notifySpaceDeleted","space_notifyWrite","space_putRecord","space_registerNotify","space_unregisterNotify","simplespace_addMember","simplespace_checkUserAccess","simplespace_createSpace","simplespace_defs","simplespace_deleteSpace","simplespace_getSpace","simplespace_listMembers","simplespace_removeMember","simplespace_updateSpace","requirements: CoverageRequirement[]","dangling: CoverageReport[\"danglingCitations\"]"],"sources":["../src/runner.ts","../lexicons/space/applyWrites.json","../lexicons/space/createRecord.json","../lexicons/space/defs.json","../lexicons/space/deleteRecord.json","../lexicons/space/getBlob.json","../lexicons/space/getDelegationToken.json","../lexicons/space/getLatestCommit.json","../lexicons/space/getRecord.json","../lexicons/space/getRepo.json","../lexicons/space/getSpaceCredential.json","../lexicons/space/listBlobs.json","../lexicons/space/listRecords.json","../lexicons/space/listRepoOps.json","../lexicons/space/listRepos.json","../lexicons/space/listSpaces.json","../lexicons/space/notifySpaceDeleted.json","../lexicons/space/notifyWrite.json","../lexicons/space/putRecord.json","../lexicons/space/registerNotify.json","../lexicons/space/unregisterNotify.json","../lexicons/simplespace/addMember.json","../lexicons/simplespace/checkUserAccess.json","../lexicons/simplespace/createSpace.json","../lexicons/simplespace/defs.json","../lexicons/simplespace/deleteSpace.json","../lexicons/simplespace/getSpace.json","../lexicons/simplespace/listMembers.json","../lexicons/simplespace/removeMember.json","../lexicons/simplespace/updateSpace.json","../src/lexicons.ts","../src/coverage.ts"],"sourcesContent":["/**\n * The core runner: executes a filtered catalog against one target and\n * produces a report. Transport- and environment-agnostic — the vitest\n * adapter, the CLI and the web checker all call this.\n */\n\nimport type { Check, CheckContext, CheckResult, Target } from \"./model.js\";\nimport type { FilteredCatalog } from \"./registry.js\";\n\nexport interface RunReport {\n\tsuite: { name: string; version: string };\n\t/** The alpha build the suite's verifiers are pinned to. */\n\talphaBuild: string;\n\ttarget: Target;\n\tstartedAt: string;\n\tfinishedAt: string;\n\tresults: CheckResult[];\n\tlogs: string[];\n\tsummary: {\n\t\tpass: number;\n\t\tfail: number;\n\t\tmustFail: number;\n\t\t/**\n\t\t * must-tier checks that errored (threw or timed out). A CI gate must\n\t\t * treat these as failures too: an unreachable or hung target errors\n\t\t * its checks rather than failing them, and must not exit 0.\n\t\t */\n\t\tmustError: number;\n\t\tskipped: number;\n\t\terror: number;\n\t};\n}\n\nexport interface RunOptions {\n\tcatalog: FilteredCatalog;\n\tcontext: Omit<CheckContext, \"state\" | \"log\">;\n\tsuiteVersion: string;\n\talphaBuild: string;\n\t/** Per-check timeout; a hung target must not hang the run. */\n\tcheckTimeoutMs?: number;\n\t/**\n\t * Called with each result as it is determined, in run order — so a UI\n\t * can render progress live instead of waiting for the whole report.\n\t * Skipped results are delivered too (at the end). A throwing callback\n\t * is contained: it must not be able to abort the run.\n\t */\n\tonResult?: (result: CheckResult) => void;\n}\n\nexport async function runChecks(options: RunOptions): Promise<RunReport> {\n\tconst logs: string[] = [];\n\tconst state = new Map<string, unknown>();\n\tconst ctx: CheckContext = {\n\t\t...options.context,\n\t\tstate,\n\t\tlog: (message) => logs.push(message),\n\t};\n\tconst timeoutMs = options.checkTimeoutMs ?? 30_000;\n\tconst startedAt = new Date().toISOString();\n\tconst results: CheckResult[] = [];\n\tconst emit = (result: CheckResult) => {\n\t\tresults.push(result);\n\t\ttry {\n\t\t\toptions.onResult?.(result);\n\t\t} catch {\n\t\t\t// The callback is an observer; its bugs must not abort the run.\n\t\t}\n\t};\n\n\t// Sequential on purpose: checks share probe state, and hammering a\n\t// live target in parallel makes failures racy and reports unreadable.\n\tfor (const check of options.catalog.runnable) {\n\t\tconst began = Date.now();\n\t\t// A per-check abort so a timed-out check's in-flight requests are\n\t\t// cancelled rather than continuing to fetch and mutate shared state\n\t\t// alongside the next check (the sequential invariant above).\n\t\tconst controller = new AbortController();\n\t\tconst checkCtx: CheckContext = {\n\t\t\t...ctx,\n\t\t\tfetch: (input, init) =>\n\t\t\t\tctx.fetch(input, {\n\t\t\t\t\t...init,\n\t\t\t\t\tsignal: init?.signal ?? controller.signal,\n\t\t\t\t}),\n\t\t};\n\t\ttry {\n\t\t\tconst outcome = await withTimeout(\n\t\t\t\tcheck.run(checkCtx),\n\t\t\t\ttimeoutMs,\n\t\t\t\tcheck.id,\n\t\t\t\tcontroller,\n\t\t\t);\n\t\t\temit({\n\t\t\t\tid: check.id,\n\t\t\t\ttier: check.tier,\n\t\t\t\tstatus: outcome.status,\n\t\t\t\tdetail: outcome.detail,\n\t\t\t\tcitations: check.citations,\n\t\t\t\t...(outcome.evidence !== undefined\n\t\t\t\t\t? { evidence: outcome.evidence }\n\t\t\t\t\t: {}),\n\t\t\t\tdurationMs: Date.now() - began,\n\t\t\t});\n\t\t} catch (err) {\n\t\t\t// A thrown error means the CHECK broke (or the target hung) —\n\t\t\t// reported distinctly from a failing target so suite bugs don't\n\t\t\t// masquerade as non-conformance.\n\t\t\temit({\n\t\t\t\tid: check.id,\n\t\t\t\ttier: check.tier,\n\t\t\t\tstatus: \"error\",\n\t\t\t\tdetail: err instanceof Error ? err.message : String(err),\n\t\t\t\tcitations: check.citations,\n\t\t\t\tdurationMs: Date.now() - began,\n\t\t\t});\n\t\t}\n\t}\n\n\tfor (const { check, reason } of options.catalog.skipped) {\n\t\temit({\n\t\t\tid: check.id,\n\t\t\ttier: check.tier,\n\t\t\tstatus: \"skipped\",\n\t\t\tdetail: reason,\n\t\t\tcitations: check.citations,\n\t\t});\n\t}\n\n\tconst summary = {\n\t\tpass: results.filter((r) => r.status === \"pass\").length,\n\t\tfail: results.filter((r) => r.status === \"fail\").length,\n\t\tmustFail: results.filter((r) => r.status === \"fail\" && r.tier === \"must\")\n\t\t\t.length,\n\t\tmustError: results.filter((r) => r.status === \"error\" && r.tier === \"must\")\n\t\t\t.length,\n\t\tskipped: results.filter((r) => r.status === \"skipped\").length,\n\t\terror: results.filter((r) => r.status === \"error\").length,\n\t};\n\n\treturn {\n\t\tsuite: {\n\t\t\tname: \"@getcirrus/space-conformance\",\n\t\t\tversion: options.suiteVersion,\n\t\t},\n\t\talphaBuild: options.alphaBuild,\n\t\ttarget: options.context.target,\n\t\tstartedAt,\n\t\tfinishedAt: new Date().toISOString(),\n\t\tresults,\n\t\tlogs,\n\t\tsummary,\n\t};\n}\n\nfunction withTimeout<T>(\n\tpromise: Promise<T>,\n\tms: number,\n\tid: string,\n\tcontroller: AbortController,\n): Promise<T> {\n\treturn new Promise<T>((resolve, reject) => {\n\t\tconst timer = setTimeout(() => {\n\t\t\t// Abort the check's in-flight requests so it stops touching shared\n\t\t\t// state before the next check begins.\n\t\t\tcontroller.abort();\n\t\t\treject(new Error(`check ${id} timed out after ${ms}ms`));\n\t\t}, ms);\n\t\tpromise.then(\n\t\t\t(value) => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\tresolve(value);\n\t\t\t},\n\t\t\t(err) => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\treject(err);\n\t\t\t},\n\t\t);\n\t});\n}\n\n/** Render a compact human-readable summary of a report. */\nexport function renderReport(report: RunReport): string {\n\tconst lines: string[] = [];\n\tconst icon = { pass: \"✓\", fail: \"✗\", skipped: \"-\", error: \"!\" } as const;\n\tlines.push(\n\t\t`# ${report.suite.name}@${report.suite.version} vs ${report.target.implementation ?? report.target.origin}`,\n\t);\n\tlines.push(`alpha build: ${report.alphaBuild}`);\n\tfor (const result of report.results) {\n\t\tlines.push(\n\t\t\t`${icon[result.status]} [${result.tier}] ${result.id} — ${result.detail}`,\n\t\t);\n\t}\n\tconst s = report.summary;\n\tlines.push(\n\t\t`${s.pass} pass, ${s.fail} fail (${s.mustFail} must), ${s.skipped} skipped, ${s.error} errored`,\n\t);\n\treturn lines.join(\"\\n\");\n}\n","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","/**\n * Vendored lexicon access. Regenerated by the vendor step of the weekly\n * sync whenever lexicons/ changes — imports are explicit so bundlers\n * carry the documents without filesystem access at runtime.\n */\n\nimport space_applyWrites from \"../lexicons/space/applyWrites.json\" with { type: \"json\" };\nimport space_createRecord from \"../lexicons/space/createRecord.json\" with { type: \"json\" };\nimport space_defs from \"../lexicons/space/defs.json\" with { type: \"json\" };\nimport space_deleteRecord from \"../lexicons/space/deleteRecord.json\" with { type: \"json\" };\nimport space_getBlob from \"../lexicons/space/getBlob.json\" with { type: \"json\" };\nimport space_getDelegationToken from \"../lexicons/space/getDelegationToken.json\" with { type: \"json\" };\nimport space_getLatestCommit from \"../lexicons/space/getLatestCommit.json\" with { type: \"json\" };\nimport space_getRecord from \"../lexicons/space/getRecord.json\" with { type: \"json\" };\nimport space_getRepo from \"../lexicons/space/getRepo.json\" with { type: \"json\" };\nimport space_getSpaceCredential from \"../lexicons/space/getSpaceCredential.json\" with { type: \"json\" };\nimport space_listBlobs from \"../lexicons/space/listBlobs.json\" with { type: \"json\" };\nimport space_listRecords from \"../lexicons/space/listRecords.json\" with { type: \"json\" };\nimport space_listRepoOps from \"../lexicons/space/listRepoOps.json\" with { type: \"json\" };\nimport space_listRepos from \"../lexicons/space/listRepos.json\" with { type: \"json\" };\nimport space_listSpaces from \"../lexicons/space/listSpaces.json\" with { type: \"json\" };\nimport space_notifySpaceDeleted from \"../lexicons/space/notifySpaceDeleted.json\" with { type: \"json\" };\nimport space_notifyWrite from \"../lexicons/space/notifyWrite.json\" with { type: \"json\" };\nimport space_putRecord from \"../lexicons/space/putRecord.json\" with { type: \"json\" };\nimport space_registerNotify from \"../lexicons/space/registerNotify.json\" with { type: \"json\" };\nimport space_unregisterNotify from \"../lexicons/space/unregisterNotify.json\" with { type: \"json\" };\nimport simplespace_addMember from \"../lexicons/simplespace/addMember.json\" with { type: \"json\" };\nimport simplespace_checkUserAccess from \"../lexicons/simplespace/checkUserAccess.json\" with { type: \"json\" };\nimport simplespace_createSpace from \"../lexicons/simplespace/createSpace.json\" with { type: \"json\" };\nimport simplespace_defs from \"../lexicons/simplespace/defs.json\" with { type: \"json\" };\nimport simplespace_deleteSpace from \"../lexicons/simplespace/deleteSpace.json\" with { type: \"json\" };\nimport simplespace_getSpace from \"../lexicons/simplespace/getSpace.json\" with { type: \"json\" };\nimport simplespace_listMembers from \"../lexicons/simplespace/listMembers.json\" with { type: \"json\" };\nimport simplespace_removeMember from \"../lexicons/simplespace/removeMember.json\" with { type: \"json\" };\nimport simplespace_updateSpace from \"../lexicons/simplespace/updateSpace.json\" with { type: \"json\" };\n\nexport interface LexiconDoc {\n\tlexicon: number;\n\tid: string;\n\tdefs: Record<string, unknown>;\n}\n\nexport const lexicons: LexiconDoc[] = [\n\tspace_applyWrites as LexiconDoc,\n\tspace_createRecord as LexiconDoc,\n\tspace_defs as LexiconDoc,\n\tspace_deleteRecord as LexiconDoc,\n\tspace_getBlob as LexiconDoc,\n\tspace_getDelegationToken as LexiconDoc,\n\tspace_getLatestCommit as LexiconDoc,\n\tspace_getRecord as LexiconDoc,\n\tspace_getRepo as LexiconDoc,\n\tspace_getSpaceCredential as LexiconDoc,\n\tspace_listBlobs as LexiconDoc,\n\tspace_listRecords as LexiconDoc,\n\tspace_listRepoOps as LexiconDoc,\n\tspace_listRepos as LexiconDoc,\n\tspace_listSpaces as LexiconDoc,\n\tspace_notifySpaceDeleted as LexiconDoc,\n\tspace_notifyWrite as LexiconDoc,\n\tspace_putRecord as LexiconDoc,\n\tspace_registerNotify as LexiconDoc,\n\tspace_unregisterNotify as LexiconDoc,\n\tsimplespace_addMember as LexiconDoc,\n\tsimplespace_checkUserAccess as LexiconDoc,\n\tsimplespace_createSpace as LexiconDoc,\n\tsimplespace_defs as LexiconDoc,\n\tsimplespace_deleteSpace as LexiconDoc,\n\tsimplespace_getSpace as LexiconDoc,\n\tsimplespace_listMembers as LexiconDoc,\n\tsimplespace_removeMember as LexiconDoc,\n\tsimplespace_updateSpace as LexiconDoc,\n];\n","/**\n * Coverage is computed, not remembered.\n *\n * The vendored lexicons define what a conforming implementation exposes:\n * every method, and every error it declares. Each of those wants at least\n * one `must` check citing it. When the weekly sync re-vendors a changed\n * lexicon, new methods and error names surface here as gaps the moment\n * they land — no human has to notice that an endpoint grew.\n */\n\nimport type { Check } from \"./model.js\";\nimport { lexicons, type LexiconDoc } from \"./lexicons.js\";\n\nexport interface CoverageRequirement {\n\t/** `<nsid>` for the method itself, `<nsid>@error:<Name>` for an error. */\n\tref: string;\n\tkind: \"method\" | \"error\";\n}\n\nexport interface CoverageReport {\n\trequirements: CoverageRequirement[];\n\tcovered: Array<{ ref: string; by: string[] }>;\n\tgaps: CoverageRequirement[];\n\t/** Lexicon citations on checks that match no requirement (typo guard). */\n\tdanglingCitations: Array<{ checkId: string; ref: string }>;\n}\n\n/** Extract the coverage requirements from the vendored lexicons. */\nexport function coverageRequirements(\n\tdocs: LexiconDoc[] = lexicons,\n): CoverageRequirement[] {\n\tconst requirements: CoverageRequirement[] = [];\n\tfor (const doc of docs) {\n\t\tconst main = doc.defs.main as\n\t\t\t| { type?: string; errors?: Array<{ name: string }> }\n\t\t\t| undefined;\n\t\tif (!main || (main.type !== \"query\" && main.type !== \"procedure\")) {\n\t\t\tcontinue;\n\t\t}\n\t\trequirements.push({ ref: doc.id, kind: \"method\" });\n\t\tfor (const error of main.errors ?? []) {\n\t\t\trequirements.push({\n\t\t\t\tref: `${doc.id}@error:${error.name}`,\n\t\t\t\tkind: \"error\",\n\t\t\t});\n\t\t}\n\t}\n\treturn requirements;\n}\n\n/**\n * A citation covers a requirement when it names the method (which covers\n * the method requirement) or the exact `@error:` form. A citation with a\n * `#def` fragment covers its method.\n */\nfunction citationRefs(check: Check): string[] {\n\treturn check.citations\n\t\t.filter((c) => c.source === \"lexicon\")\n\t\t.map((c) => c.ref);\n}\n\nexport function coverageReport(\n\tcatalog: Check[],\n\tdocs: LexiconDoc[] = lexicons,\n): CoverageReport {\n\tconst requirements = coverageRequirements(docs);\n\tconst known = new Set(requirements.map((r) => r.ref));\n\tconst methodIds = new Set(\n\t\trequirements.filter((r) => r.kind === \"method\").map((r) => r.ref),\n\t);\n\t// Every vendored lexicon id, so a citation to a non-method document\n\t// (e.g. `com.atproto.space.defs`, the signed-commit shape) is\n\t// recognised as real rather than flagged as a typo.\n\tconst knownDocIds = new Set(docs.map((d) => d.id));\n\n\tconst coveredBy = new Map<string, string[]>();\n\tconst dangling: CoverageReport[\"danglingCitations\"] = [];\n\tconst credit = (ref: string, checkId: string) =>\n\t\tcoveredBy.set(ref, [...(coveredBy.get(ref) ?? []), checkId]);\n\n\tfor (const check of catalog) {\n\t\tif (check.tier !== \"must\") continue;\n\t\tfor (const ref of citationRefs(check)) {\n\t\t\tconst methodRef = ref.split(\"@\")[0]!.split(\"#\")[0]!;\n\n\t\t\t// An `@error:` citation covers ONLY the exact error requirement.\n\t\t\t// It must never fall back to crediting the method: doing so would\n\t\t\t// silently absorb an error-name typo (or an upstream rename) and\n\t\t\t// falsely mark the method covered — defeating the typo guard this\n\t\t\t// report exists to provide.\n\t\t\tif (ref.includes(\"@error:\")) {\n\t\t\t\tif (known.has(ref)) {\n\t\t\t\t\tcredit(ref, check.id);\n\t\t\t\t} else {\n\t\t\t\t\tdangling.push({ checkId: check.id, ref });\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// A method (or `#def`) citation.\n\t\t\tif (methodIds.has(methodRef)) {\n\t\t\t\tcredit(methodRef, check.id);\n\t\t\t} else if (!knownDocIds.has(methodRef)) {\n\t\t\t\t// Names no vendored document at all — a typo.\n\t\t\t\tdangling.push({ checkId: check.id, ref });\n\t\t\t}\n\t\t\t// else: a `#def` reference to a real non-method document (e.g.\n\t\t\t// defs) — valid, contributes no method coverage, not dangling.\n\t\t}\n\t}\n\n\tconst gaps = requirements.filter((r) => !coveredBy.has(r.ref));\n\treturn {\n\t\trequirements,\n\t\tcovered: Array.from(coveredBy, ([ref, by]) => ({ ref, by })),\n\t\tgaps,\n\t\tdanglingCitations: dangling,\n\t};\n}\n"],"mappings":";AAiDA,eAAsB,UAAU,SAAyC;CACxE,MAAMA,OAAiB,EAAE;CACzB,MAAM,wBAAQ,IAAI,KAAsB;CACxC,MAAMC,MAAoB;EACzB,GAAG,QAAQ;EACX;EACA,MAAM,YAAY,KAAK,KAAK,QAAQ;EACpC;CACD,MAAM,YAAY,QAAQ,kBAAkB;CAC5C,MAAM,6BAAY,IAAI,MAAM,EAAC,aAAa;CAC1C,MAAMC,UAAyB,EAAE;CACjC,MAAM,QAAQ,WAAwB;AACrC,UAAQ,KAAK,OAAO;AACpB,MAAI;AACH,WAAQ,WAAW,OAAO;UACnB;;AAOT,MAAK,MAAM,SAAS,QAAQ,QAAQ,UAAU;EAC7C,MAAM,QAAQ,KAAK,KAAK;EAIxB,MAAM,aAAa,IAAI,iBAAiB;EACxC,MAAMC,WAAyB;GAC9B,GAAG;GACH,QAAQ,OAAO,SACd,IAAI,MAAM,OAAO;IAChB,GAAG;IACH,QAAQ,MAAM,UAAU,WAAW;IACnC,CAAC;GACH;AACD,MAAI;GACH,MAAM,UAAU,MAAM,YACrB,MAAM,IAAI,SAAS,EACnB,WACA,MAAM,IACN,WACA;AACD,QAAK;IACJ,IAAI,MAAM;IACV,MAAM,MAAM;IACZ,QAAQ,QAAQ;IAChB,QAAQ,QAAQ;IAChB,WAAW,MAAM;IACjB,GAAI,QAAQ,aAAa,SACtB,EAAE,UAAU,QAAQ,UAAU,GAC9B,EAAE;IACL,YA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C,MAAMC,WAAgD,EAAE;CACxD,MAAM,UAAU,KAAa,YAC5B,UAAU,IAAI,KAAK,CAAC,GAAI,UAAU,IAAI,IAAI,IAAI,EAAE,EAAG,QAAQ,CAAC;AAE7D,MAAK,MAAM,SAAS,SAAS;AAC5B,MAAI,MAAM,SAAS,OAAQ;AAC3B,OAAK,MAAM,OAAO,aAAa,MAAM,EAAE;GACtC,MAAM,YAAY,IAAI,MAAM,IAAI,CAAC,GAAI,MAAM,IAAI,CAAC;AAOhD,OAAI,IAAI,SAAS,UAAU,EAAE;AAC5B,QAAI,MAAM,IAAI,IAAI,CACjB,QAAO,KAAK,MAAM,GAAG;QAErB,UAAS,KAAK;KAAE,SAAS,MAAM;KAAI;KAAK,CAAC;AAE1C;;AAID,OAAI,UAAU,IAAI,UAAU,CAC3B,QAAO,WAAW,MAAM,GAAG;YACjB,CAAC,YAAY,IAAI,UAAU,CAErC,UAAS,KAAK;IAAE,SAAS,MAAM;IAAI;IAAK,CAAC;;;CAO5C,MAAM,OAAO,aAAa,QAAQ,MAAM,CAAC,UAAU,IAAI,EAAE,IAAI,CAAC;AAC9D,QAAO;EACN;EACA,SAAS,MAAM,KAAK,YAAY,CAAC,KAAK,SAAS;GAAE;GAAK;GAAI,EAAE;EAC5D;EACA,mBAAmB;EACnB"}
|
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
import { S as pass, a as note, c as operatorCreateRecord, d as createDpopProofJwt, f as baseChecks, g as xrpcPost, h as xrpcGet, i as deleteProbeSpace, n as createProbeSpace, p as asOperator, r as credentialGet, s as operatorChecks, t as POST, u as createDpopKey, v as buildCatalog, x as fail, y as defineCheck } from "./operator-BErXCDow.js";
|
|
2
|
+
import { LtHash, createSpaceToken, spaceHostAud } from "@atproto/space";
|
|
3
|
+
import { fromBase64 } from "@atproto/lex-data";
|
|
4
|
+
import { Secp256k1Keypair } from "@atproto/crypto";
|
|
5
|
+
|
|
6
|
+
//#region src/full/helpers.ts
|
|
7
|
+
/**
|
|
8
|
+
* Crypto-bound helpers for the identity checks: minting delegation tokens
|
|
9
|
+
* as harness-held reader/writer identities, and exchanging them for
|
|
10
|
+
* credentials — built on `@atproto/space`'s token primitives.
|
|
11
|
+
*
|
|
12
|
+
* Note on using the reference lib to mint: these helpers generate tokens
|
|
13
|
+
* with the same library the target is expected to interoperate with. That
|
|
14
|
+
* is deliberate — the point of a credential check is that the *target's*
|
|
15
|
+
* verification accepts a correctly-formed token, and "correctly formed" is
|
|
16
|
+
* defined by the reference lib every implementation must interop with.
|
|
17
|
+
*
|
|
18
|
+
* Everything an operator session can do without foreign identities —
|
|
19
|
+
* probe spaces, record writes, the self credential flow — lives in the
|
|
20
|
+
* browser-safe `../checks/operator.js` and is re-exported here so the
|
|
21
|
+
* full entry keeps its historical surface.
|
|
22
|
+
*/
|
|
23
|
+
/** Adapt a harness identity to the `Keypair` surface token minting uses. */
|
|
24
|
+
function keypairFor(identity) {
|
|
25
|
+
return {
|
|
26
|
+
jwtAlg: identity.jwtAlg,
|
|
27
|
+
sign: (bytes) => identity.sign(bytes),
|
|
28
|
+
did: () => identity.did
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** Mint a delegation token for `identity` against `space`. */
|
|
32
|
+
async function mintDelegation(ctx, identity, space, audOverride) {
|
|
33
|
+
return createSpaceToken("delegation", {
|
|
34
|
+
iss: identity.did,
|
|
35
|
+
sub: space,
|
|
36
|
+
aud: audOverride ?? spaceHostAud(ctx.target.did)
|
|
37
|
+
}, keypairFor(identity));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The full obtain flow: mint a delegation token as `identity`, exchange it
|
|
41
|
+
* at the target for a credential bound to a fresh DPoP key. Returns the
|
|
42
|
+
* raw XrpcResult alongside the credential so callers can assert on refusals.
|
|
43
|
+
*/
|
|
44
|
+
async function obtainCredential(ctx, identity, space, opts = {}) {
|
|
45
|
+
if (!ctx.identities) throw new Error("obtainCredential needs an identity provider");
|
|
46
|
+
const dpopKey = await ctx.identities.dpopKey();
|
|
47
|
+
const delegation = await mintDelegation(ctx, identity, space, opts.audOverride);
|
|
48
|
+
const proof = await createDpopProofJwt(dpopKey, {
|
|
49
|
+
htm: "POST",
|
|
50
|
+
htu: `${ctx.target.origin}/xrpc/com.atproto.space.getSpaceCredential`
|
|
51
|
+
});
|
|
52
|
+
const result = await xrpcPost(ctx, "com.atproto.space.getSpaceCredential", {
|
|
53
|
+
space,
|
|
54
|
+
...opts.clientAttestation ? { clientAttestation: opts.clientAttestation } : {}
|
|
55
|
+
}, {
|
|
56
|
+
Authorization: `Bearer ${delegation}`,
|
|
57
|
+
DPoP: proof
|
|
58
|
+
});
|
|
59
|
+
if (result.status === 200) return {
|
|
60
|
+
result,
|
|
61
|
+
credential: {
|
|
62
|
+
credential: result.json.credential,
|
|
63
|
+
dpopKey
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
return { result };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/full/checks.ts
|
|
71
|
+
/**
|
|
72
|
+
* The crypto-bound check catalog: the checks that genuinely need the
|
|
73
|
+
* alpha libs or harness-held foreign identities, and nothing else — every
|
|
74
|
+
* check an operator session can run with plain fetch + WebCrypto lives in
|
|
75
|
+
* `../checks/operator.js` instead, browser included.
|
|
76
|
+
*
|
|
77
|
+
* What keeps a check here:
|
|
78
|
+
* - `identities`: the harness plays a reader/member who is not the
|
|
79
|
+
* operator, minting delegation tokens the target must verify by
|
|
80
|
+
* resolving the reader's DID — only an in-process fixture with an
|
|
81
|
+
* injected resolver can arrange that.
|
|
82
|
+
* - `LtHash`: folding the oplog needs the lattice set-hash from
|
|
83
|
+
* `@atproto/space`, whose bundle pulls node-only dependencies.
|
|
84
|
+
*/
|
|
85
|
+
const credentialRoundTrip = defineCheck({
|
|
86
|
+
id: "credential.round-trip",
|
|
87
|
+
title: "A member exchanges a delegation token for a credential and reads",
|
|
88
|
+
tier: "must",
|
|
89
|
+
citations: [{
|
|
90
|
+
source: "lexicon",
|
|
91
|
+
ref: "com.atproto.space.getSpaceCredential"
|
|
92
|
+
}, {
|
|
93
|
+
source: "lexicon",
|
|
94
|
+
ref: "com.atproto.space.getRecord"
|
|
95
|
+
}],
|
|
96
|
+
needs: ["operator", "identities"],
|
|
97
|
+
destructive: true,
|
|
98
|
+
async run(ctx) {
|
|
99
|
+
const reader = await ctx.identities.identity("reader");
|
|
100
|
+
const space = await createProbeSpace(ctx);
|
|
101
|
+
try {
|
|
102
|
+
await operatorCreateRecord(ctx, space.uri, POST, "shared", note("visible"));
|
|
103
|
+
await xrpcPost(asOperator(ctx), "com.atproto.simplespace.addMember", {
|
|
104
|
+
space: space.uri,
|
|
105
|
+
did: reader.did
|
|
106
|
+
});
|
|
107
|
+
const { result, credential } = await obtainCredential(ctx, reader, space.uri);
|
|
108
|
+
if (!credential) return fail(`getSpaceCredential ${result.status} ${result.error ?? ""}`, result.json);
|
|
109
|
+
const read = await credentialGet(ctx, credential, "com.atproto.space.getRecord", {
|
|
110
|
+
space: space.uri,
|
|
111
|
+
repo: ctx.target.did,
|
|
112
|
+
collection: POST,
|
|
113
|
+
rkey: "shared"
|
|
114
|
+
});
|
|
115
|
+
return read.status === 200 ? pass("credential read the space") : fail(`credential read failed: ${read.status} ${read.error ?? ""}`, read.json);
|
|
116
|
+
} finally {
|
|
117
|
+
await deleteProbeSpace(ctx, space.uri);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
const credentialCrossSpace = defineCheck({
|
|
122
|
+
id: "credential.cross-space-refused",
|
|
123
|
+
title: "A credential for one space cannot read another",
|
|
124
|
+
tier: "must",
|
|
125
|
+
citations: [{
|
|
126
|
+
source: "lexicon",
|
|
127
|
+
ref: "com.atproto.space.getRecord"
|
|
128
|
+
}],
|
|
129
|
+
needs: ["operator", "identities"],
|
|
130
|
+
destructive: true,
|
|
131
|
+
async run(ctx) {
|
|
132
|
+
const reader = await ctx.identities.identity("reader");
|
|
133
|
+
const publicPolicy = { $type: "com.atproto.simplespace.defs#publicPolicy" };
|
|
134
|
+
const spaceA = await createProbeSpace(ctx, publicPolicy);
|
|
135
|
+
const spaceB = await createProbeSpace(ctx, publicPolicy);
|
|
136
|
+
try {
|
|
137
|
+
await operatorCreateRecord(ctx, spaceB.uri, POST, "secret", note("b"));
|
|
138
|
+
const { credential } = await obtainCredential(ctx, reader, spaceA.uri);
|
|
139
|
+
if (!credential) return fail("could not obtain a credential for space A");
|
|
140
|
+
const cross = await credentialGet(ctx, credential, "com.atproto.space.getRecord", {
|
|
141
|
+
space: spaceB.uri,
|
|
142
|
+
repo: ctx.target.did,
|
|
143
|
+
collection: POST,
|
|
144
|
+
rkey: "secret"
|
|
145
|
+
});
|
|
146
|
+
return cross.status === 200 ? fail("space-A credential read space B", cross.json) : pass(`cross-space read refused with ${cross.status} ${cross.error ?? ""}`);
|
|
147
|
+
} finally {
|
|
148
|
+
await deleteProbeSpace(ctx, spaceA.uri);
|
|
149
|
+
await deleteProbeSpace(ctx, spaceB.uri);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
const delegationReplay = defineCheck({
|
|
154
|
+
id: "delegation.replay-refused",
|
|
155
|
+
title: "A delegation token cannot be used twice",
|
|
156
|
+
tier: "must",
|
|
157
|
+
citations: [{
|
|
158
|
+
source: "lexicon",
|
|
159
|
+
ref: "com.atproto.space.getSpaceCredential@error:InvalidDelegationToken"
|
|
160
|
+
}],
|
|
161
|
+
needs: ["operator", "identities"],
|
|
162
|
+
destructive: true,
|
|
163
|
+
async run(ctx) {
|
|
164
|
+
const reader = await ctx.identities.identity("reader");
|
|
165
|
+
const space = await createProbeSpace(ctx, { $type: "com.atproto.simplespace.defs#publicPolicy" });
|
|
166
|
+
try {
|
|
167
|
+
const { createDpopProof, createSpaceToken: createSpaceToken$1, spaceHostAud: spaceHostAud$1 } = await import("@atproto/space");
|
|
168
|
+
const delegation = await createSpaceToken$1("delegation", {
|
|
169
|
+
iss: reader.did,
|
|
170
|
+
sub: space.uri,
|
|
171
|
+
aud: spaceHostAud$1(ctx.target.did)
|
|
172
|
+
}, {
|
|
173
|
+
jwtAlg: reader.jwtAlg,
|
|
174
|
+
sign: (b) => reader.sign(b)
|
|
175
|
+
});
|
|
176
|
+
const exchange = async () => {
|
|
177
|
+
const proof = await createDpopProof(await ctx.identities.dpopKey(), {
|
|
178
|
+
htm: "POST",
|
|
179
|
+
htu: `${ctx.target.origin}/xrpc/com.atproto.space.getSpaceCredential`
|
|
180
|
+
});
|
|
181
|
+
return xrpcPost(ctx, "com.atproto.space.getSpaceCredential", { space: space.uri }, {
|
|
182
|
+
Authorization: `Bearer ${delegation}`,
|
|
183
|
+
DPoP: proof
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
const first = await exchange();
|
|
187
|
+
if (first.status !== 200) return fail(`first exchange failed (${first.status}); cannot test replay`, first.json);
|
|
188
|
+
const second = await exchange();
|
|
189
|
+
return second.status === 200 ? fail("a replayed delegation token was accepted") : pass(`replay refused with ${second.status} ${second.error ?? ""}`);
|
|
190
|
+
} finally {
|
|
191
|
+
await deleteProbeSpace(ctx, space.uri);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
const delegationWrongAud = defineCheck({
|
|
196
|
+
id: "delegation.wrong-audience-refused",
|
|
197
|
+
title: "A delegation token addressed to another host is refused",
|
|
198
|
+
tier: "must",
|
|
199
|
+
citations: [{
|
|
200
|
+
source: "lexicon",
|
|
201
|
+
ref: "com.atproto.space.getSpaceCredential@error:InvalidDelegationToken"
|
|
202
|
+
}],
|
|
203
|
+
needs: ["operator", "identities"],
|
|
204
|
+
destructive: true,
|
|
205
|
+
async run(ctx) {
|
|
206
|
+
const reader = await ctx.identities.identity("reader");
|
|
207
|
+
const space = await createProbeSpace(ctx, { $type: "com.atproto.simplespace.defs#publicPolicy" });
|
|
208
|
+
try {
|
|
209
|
+
const control = await obtainCredential(ctx, reader, space.uri);
|
|
210
|
+
if (!control.credential) return fail(`correct-aud control failed (${control.result.status} ${control.result.error ?? ""}); cannot attribute the wrong-aud refusal`, control.result.json);
|
|
211
|
+
const { result } = await obtainCredential(ctx, reader, space.uri, { audOverride: "did:web:someone-else.example#atproto_space_host" });
|
|
212
|
+
if (result.status === 200) return fail("a token with the wrong audience was accepted");
|
|
213
|
+
return result.error === "InvalidDelegationToken" ? pass("wrong-aud token refused with InvalidDelegationToken") : pass(`wrong-aud token refused (${result.status} ${result.error ?? ""}); InvalidDelegationToken preferred`);
|
|
214
|
+
} finally {
|
|
215
|
+
await deleteProbeSpace(ctx, space.uri);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
const syncOplogFolds = defineCheck({
|
|
220
|
+
id: "sync.oplog-folds-to-commit",
|
|
221
|
+
title: "Folding the oplog reproduces the commit set-hash",
|
|
222
|
+
tier: "must",
|
|
223
|
+
citations: [{
|
|
224
|
+
source: "lexicon",
|
|
225
|
+
ref: "com.atproto.space.listRepoOps"
|
|
226
|
+
}, {
|
|
227
|
+
source: "lexicon",
|
|
228
|
+
ref: "com.atproto.space.defs"
|
|
229
|
+
}],
|
|
230
|
+
needs: ["operator"],
|
|
231
|
+
destructive: true,
|
|
232
|
+
async run(ctx) {
|
|
233
|
+
const space = await createProbeSpace(ctx);
|
|
234
|
+
try {
|
|
235
|
+
await operatorCreateRecord(ctx, space.uri, POST, "a", note("1"));
|
|
236
|
+
await operatorCreateRecord(ctx, space.uri, POST, "b", note("2"));
|
|
237
|
+
const res = await xrpcGet(asOperator(ctx), "com.atproto.space.listRepoOps", {
|
|
238
|
+
space: space.uri,
|
|
239
|
+
repo: ctx.target.did
|
|
240
|
+
});
|
|
241
|
+
if (res.status !== 200) return fail(`listRepoOps ${res.status} ${res.error ?? ""}`, res.json);
|
|
242
|
+
const body = res.json;
|
|
243
|
+
if (!body.commit) return fail("listRepoOps reached the head but returned no commit");
|
|
244
|
+
const setHash = new LtHash();
|
|
245
|
+
for (const op of body.ops) {
|
|
246
|
+
if (op.prev) setHash.remove(`${op.collection}/${op.rkey}/${op.prev}`);
|
|
247
|
+
if (op.cid) setHash.add(`${op.collection}/${op.rkey}/${op.cid}`);
|
|
248
|
+
}
|
|
249
|
+
const folded = setHash.digest();
|
|
250
|
+
const claimed = fromBase64(body.commit.hash.$bytes);
|
|
251
|
+
return folded.length === claimed.length && folded.every((byte, i) => byte === claimed[i]) ? pass("folded oplog matches the commit hash") : fail("folded oplog does not match the commit hash");
|
|
252
|
+
} finally {
|
|
253
|
+
await deleteProbeSpace(ctx, space.uri);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
const hostMemberGate = defineCheck({
|
|
258
|
+
id: "host.member-list-gates",
|
|
259
|
+
title: "member-list policy refuses a non-member and admits a member",
|
|
260
|
+
tier: "must",
|
|
261
|
+
citations: [{
|
|
262
|
+
source: "lexicon",
|
|
263
|
+
ref: "com.atproto.space.getSpaceCredential@error:UserNotAuthorized"
|
|
264
|
+
}, {
|
|
265
|
+
source: "lexicon",
|
|
266
|
+
ref: "com.atproto.simplespace.addMember"
|
|
267
|
+
}],
|
|
268
|
+
needs: ["operator", "identities"],
|
|
269
|
+
destructive: true,
|
|
270
|
+
async run(ctx) {
|
|
271
|
+
const reader = await ctx.identities.identity("reader");
|
|
272
|
+
const space = await createProbeSpace(ctx);
|
|
273
|
+
try {
|
|
274
|
+
const before = await obtainCredential(ctx, reader, space.uri);
|
|
275
|
+
if (before.credential) return fail("a non-member obtained a credential under member-list policy");
|
|
276
|
+
await xrpcPost(asOperator(ctx), "com.atproto.simplespace.addMember", {
|
|
277
|
+
space: space.uri,
|
|
278
|
+
did: reader.did
|
|
279
|
+
});
|
|
280
|
+
const after = await obtainCredential(ctx, reader, space.uri);
|
|
281
|
+
return after.credential ? pass(`non-member refused (${before.result.error ?? before.result.status}), member admitted`) : fail(`a member was refused: ${after.result.status} ${after.result.error ?? ""}`);
|
|
282
|
+
} finally {
|
|
283
|
+
await deleteProbeSpace(ctx, space.uri);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
const hostDeleteTombstone = defineCheck({
|
|
288
|
+
id: "host.delete-space-tombstone",
|
|
289
|
+
title: "After deleteSpace, getSpaceCredential answers SpaceDeleted",
|
|
290
|
+
tier: "must",
|
|
291
|
+
citations: [{
|
|
292
|
+
source: "lexicon",
|
|
293
|
+
ref: "com.atproto.simplespace.deleteSpace"
|
|
294
|
+
}, {
|
|
295
|
+
source: "lexicon",
|
|
296
|
+
ref: "com.atproto.space.getSpaceCredential@error:SpaceDeleted"
|
|
297
|
+
}],
|
|
298
|
+
needs: ["operator", "identities"],
|
|
299
|
+
destructive: true,
|
|
300
|
+
async run(ctx) {
|
|
301
|
+
const reader = await ctx.identities.identity("reader");
|
|
302
|
+
const space = await createProbeSpace(ctx, { $type: "com.atproto.simplespace.defs#publicPolicy" });
|
|
303
|
+
const before = await obtainCredential(ctx, reader, space.uri);
|
|
304
|
+
if (!before.credential) {
|
|
305
|
+
await deleteProbeSpace(ctx, space.uri);
|
|
306
|
+
return fail(`could not obtain a credential before deletion (${before.result.status} ${before.result.error ?? ""}); cannot test the tombstone`, before.result.json);
|
|
307
|
+
}
|
|
308
|
+
const del = await xrpcPost(asOperator(ctx), "com.atproto.simplespace.deleteSpace", { space: space.uri });
|
|
309
|
+
if (del.status !== 200) return fail(`deleteSpace failed (${del.status} ${del.error ?? ""})`, del.json);
|
|
310
|
+
const { result } = await obtainCredential(ctx, reader, space.uri);
|
|
311
|
+
if (result.status === 200) return fail("a deleted space still issued a credential");
|
|
312
|
+
return result.error === "SpaceDeleted" ? pass("getSpaceCredential answered SpaceDeleted") : fail(`deleted space refused with ${result.error} (${result.status}), expected SpaceDeleted`, result.json);
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
/** The crypto-bound catalog: identity checks plus the LtHash fold. */
|
|
316
|
+
const cryptoChecks = [
|
|
317
|
+
credentialRoundTrip,
|
|
318
|
+
credentialCrossSpace,
|
|
319
|
+
delegationReplay,
|
|
320
|
+
delegationWrongAud,
|
|
321
|
+
syncOplogFolds,
|
|
322
|
+
hostMemberGate,
|
|
323
|
+
hostDeleteTombstone
|
|
324
|
+
];
|
|
325
|
+
|
|
326
|
+
//#endregion
|
|
327
|
+
//#region src/identity.ts
|
|
328
|
+
/**
|
|
329
|
+
* Harness identities and DPoP keys.
|
|
330
|
+
*
|
|
331
|
+
* Multi-party checks need the harness to play a reader, a writer and a
|
|
332
|
+
* syncer — parties that aren't the target's operator. Each only needs a
|
|
333
|
+
* DID with a resolvable key the target can verify against, so the provider
|
|
334
|
+
* mints keypairs and the harness signs as those parties.
|
|
335
|
+
*
|
|
336
|
+
* Two facts the caller must arrange (they can't be solved in-library):
|
|
337
|
+
* the target has to be able to *resolve* each identity's DID to its key.
|
|
338
|
+
* In an in-process fixture the caller wires the target's key resolver to
|
|
339
|
+
* this provider's `didKey(role)`; against a live target the identities
|
|
340
|
+
* must be published (did:web under the checker's origin, or did:plc on a
|
|
341
|
+
* reachable directory). The provider is resolution-agnostic — it only
|
|
342
|
+
* holds keys and signs.
|
|
343
|
+
*/
|
|
344
|
+
/**
|
|
345
|
+
* An identity provider backed by secp256k1 keypairs. Identities are keyed
|
|
346
|
+
* by role label and reused within a run, so "reader" is stable across the
|
|
347
|
+
* checks that mint and then present its tokens.
|
|
348
|
+
*
|
|
349
|
+
* `didAt` lets the caller give each identity a resolvable DID (e.g.
|
|
350
|
+
* `did:web:checker.test:actors:reader`); when omitted, the identity's DID
|
|
351
|
+
* is its own `did:key`, which only works against a target whose resolver
|
|
352
|
+
* this provider is wired into.
|
|
353
|
+
*/
|
|
354
|
+
var KeypairIdentityProvider = class {
|
|
355
|
+
cache = /* @__PURE__ */ new Map();
|
|
356
|
+
constructor(didAt) {
|
|
357
|
+
this.didAt = didAt;
|
|
358
|
+
}
|
|
359
|
+
identity(role) {
|
|
360
|
+
let existing = this.cache.get(role);
|
|
361
|
+
if (!existing) {
|
|
362
|
+
existing = this.mint(role);
|
|
363
|
+
this.cache.set(role, existing);
|
|
364
|
+
}
|
|
365
|
+
return existing;
|
|
366
|
+
}
|
|
367
|
+
async mint(role) {
|
|
368
|
+
const keypair = await Secp256k1Keypair.create({ exportable: true });
|
|
369
|
+
const didKey = keypair.did();
|
|
370
|
+
return {
|
|
371
|
+
did: this.didAt ? this.didAt(role, didKey) : didKey,
|
|
372
|
+
didKey,
|
|
373
|
+
jwtAlg: keypair.jwtAlg,
|
|
374
|
+
sign: (bytes) => keypair.sign(bytes)
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
dpopKey() {
|
|
378
|
+
return createDpopKey();
|
|
379
|
+
}
|
|
380
|
+
/** All minted identities so far, for resolver wiring in fixtures. */
|
|
381
|
+
minted() {
|
|
382
|
+
return Promise.all(this.cache.values());
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
//#endregion
|
|
387
|
+
//#region src/full.ts
|
|
388
|
+
/**
|
|
389
|
+
* The full check catalog and the identity provider.
|
|
390
|
+
*
|
|
391
|
+
* This entry imports `@atproto/space`, so it pulls the alpha crypto libs
|
|
392
|
+
* and their (node-ish) transitive graph. Import it from the CLI and the
|
|
393
|
+
* vitest adapter — anywhere WebCrypto and the alpha libs run — but never
|
|
394
|
+
* from a browser bundle. The browser adapter imports the base catalog from
|
|
395
|
+
* the package root instead.
|
|
396
|
+
*/
|
|
397
|
+
/**
|
|
398
|
+
* The complete catalog: the browser-safe base and operator checks plus
|
|
399
|
+
* the crypto-bound ones only this entry can run.
|
|
400
|
+
*/
|
|
401
|
+
const fullCatalog = buildCatalog([
|
|
402
|
+
...baseChecks,
|
|
403
|
+
...operatorChecks,
|
|
404
|
+
...cryptoChecks
|
|
405
|
+
]);
|
|
406
|
+
|
|
407
|
+
//#endregion
|
|
408
|
+
export { obtainCredential as a, mintDelegation as i, KeypairIdentityProvider as n, cryptoChecks as r, fullCatalog as t };
|
|
409
|
+
//# sourceMappingURL=full-D4ufJLcw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"full-D4ufJLcw.js","names":["createSpaceToken","spaceHostAud","cryptoChecks: Check[]","didAt?: (role: string, didKey: string) => string"],"sources":["../src/full/helpers.ts","../src/full/checks.ts","../src/identity.ts","../src/full.ts"],"sourcesContent":["/**\n * Crypto-bound helpers for the identity checks: minting delegation tokens\n * as harness-held reader/writer identities, and exchanging them for\n * credentials — built on `@atproto/space`'s token primitives.\n *\n * Note on using the reference lib to mint: these helpers generate tokens\n * with the same library the target is expected to interoperate with. That\n * is deliberate — the point of a credential check is that the *target's*\n * verification accepts a correctly-formed token, and \"correctly formed\" is\n * defined by the reference lib every implementation must interop with.\n *\n * Everything an operator session can do without foreign identities —\n * probe spaces, record writes, the self credential flow — lives in the\n * browser-safe `../checks/operator.js` and is re-exported here so the\n * full entry keeps its historical surface.\n */\n\nimport { createSpaceToken, spaceHostAud } from \"@atproto/space\";\nimport type { CheckContext, HarnessIdentity } from \"../model.js\";\nimport { createDpopProofJwt } from \"../dpop.js\";\nimport { xrpcPost, type XrpcResult } from \"../http.js\";\nimport type { Credential } from \"../checks/operator.js\";\n\nexport {\n\tcreateProbeSpace,\n\tdeleteProbeSpace,\n\toperatorCreateRecord,\n\tobtainCredentialViaDelegation,\n\tcredentialGet,\n} from \"../checks/operator.js\";\nexport type { Credential, ProbeSpace } from \"../checks/operator.js\";\n\n/** Adapt a harness identity to the `Keypair` surface token minting uses. */\nfunction keypairFor(identity: HarnessIdentity) {\n\treturn {\n\t\tjwtAlg: identity.jwtAlg,\n\t\tsign: (bytes: Uint8Array) => identity.sign(bytes),\n\t\tdid: () => identity.did,\n\t} as never;\n}\n\n/** Mint a delegation token for `identity` against `space`. */\nexport async function mintDelegation(\n\tctx: CheckContext,\n\tidentity: HarnessIdentity,\n\tspace: string,\n\taudOverride?: string,\n): Promise<string> {\n\treturn createSpaceToken(\n\t\t\"delegation\",\n\t\t{\n\t\t\tiss: identity.did,\n\t\t\tsub: space,\n\t\t\taud: audOverride ?? spaceHostAud(ctx.target.did),\n\t\t},\n\t\tkeypairFor(identity),\n\t);\n}\n\n/**\n * The full obtain flow: mint a delegation token as `identity`, exchange it\n * at the target for a credential bound to a fresh DPoP key. Returns the\n * raw XrpcResult alongside the credential so callers can assert on refusals.\n */\nexport async function obtainCredential(\n\tctx: CheckContext,\n\tidentity: HarnessIdentity,\n\tspace: string,\n\topts: { audOverride?: string; clientAttestation?: string } = {},\n): Promise<{ result: XrpcResult; credential?: Credential }> {\n\tif (!ctx.identities)\n\t\tthrow new Error(\"obtainCredential needs an identity provider\");\n\tconst dpopKey = await ctx.identities.dpopKey();\n\tconst delegation = await mintDelegation(\n\t\tctx,\n\t\tidentity,\n\t\tspace,\n\t\topts.audOverride,\n\t);\n\tconst proof = await createDpopProofJwt(dpopKey, {\n\t\thtm: \"POST\",\n\t\thtu: `${ctx.target.origin}/xrpc/com.atproto.space.getSpaceCredential`,\n\t});\n\tconst result = await xrpcPost(\n\t\tctx,\n\t\t\"com.atproto.space.getSpaceCredential\",\n\t\t{\n\t\t\tspace,\n\t\t\t...(opts.clientAttestation\n\t\t\t\t? { clientAttestation: opts.clientAttestation }\n\t\t\t\t: {}),\n\t\t},\n\t\t{ Authorization: `Bearer ${delegation}`, DPoP: proof },\n\t);\n\tif (result.status === 200) {\n\t\tconst credential = (result.json as { credential: string }).credential;\n\t\treturn { result, credential: { credential, dpopKey } };\n\t}\n\treturn { result };\n}\n","/**\n * The crypto-bound check catalog: the checks that genuinely need the\n * alpha libs or harness-held foreign identities, and nothing else — every\n * check an operator session can run with plain fetch + WebCrypto lives in\n * `../checks/operator.js` instead, browser included.\n *\n * What keeps a check here:\n * - `identities`: the harness plays a reader/member who is not the\n * operator, minting delegation tokens the target must verify by\n * resolving the reader's DID — only an in-process fixture with an\n * injected resolver can arrange that.\n * - `LtHash`: folding the oplog needs the lattice set-hash from\n * `@atproto/space`, whose bundle pulls node-only dependencies.\n */\n\nimport { LtHash } from \"@atproto/space\";\nimport { fromBase64 } from \"@atproto/lex-data\";\nimport { defineCheck } from \"../registry.js\";\nimport { asOperator, xrpcGet, xrpcPost } from \"../http.js\";\nimport { fail, pass, type Check } from \"../model.js\";\nimport {\n\tcreateProbeSpace,\n\tcredentialGet,\n\tdeleteProbeSpace,\n\tobtainCredential,\n\toperatorCreateRecord,\n} from \"./helpers.js\";\nimport { POST, note } from \"../checks/operator.js\";\n\n// --- credential / delegation (foreign identities) ----------------------\n\nconst credentialRoundTrip = defineCheck({\n\tid: \"credential.round-trip\",\n\ttitle: \"A member exchanges a delegation token for a credential and reads\",\n\ttier: \"must\",\n\tcitations: [\n\t\t{ source: \"lexicon\", ref: \"com.atproto.space.getSpaceCredential\" },\n\t\t{ source: \"lexicon\", ref: \"com.atproto.space.getRecord\" },\n\t],\n\tneeds: [\"operator\", \"identities\"],\n\tdestructive: true,\n\tasync run(ctx) {\n\t\tconst reader = await ctx.identities!.identity(\"reader\");\n\t\tconst space = await createProbeSpace(ctx);\n\t\ttry {\n\t\t\tawait operatorCreateRecord(\n\t\t\t\tctx,\n\t\t\t\tspace.uri,\n\t\t\t\tPOST,\n\t\t\t\t\"shared\",\n\t\t\t\tnote(\"visible\"),\n\t\t\t);\n\t\t\t// member-list policy: authorize the reader first.\n\t\t\tawait xrpcPost(asOperator(ctx), \"com.atproto.simplespace.addMember\", {\n\t\t\t\tspace: space.uri,\n\t\t\t\tdid: reader.did,\n\t\t\t});\n\t\t\tconst { result, credential } = await obtainCredential(\n\t\t\t\tctx,\n\t\t\t\treader,\n\t\t\t\tspace.uri,\n\t\t\t);\n\t\t\tif (!credential) {\n\t\t\t\treturn fail(\n\t\t\t\t\t`getSpaceCredential ${result.status} ${result.error ?? \"\"}`,\n\t\t\t\t\tresult.json,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst read = await credentialGet(\n\t\t\t\tctx,\n\t\t\t\tcredential,\n\t\t\t\t\"com.atproto.space.getRecord\",\n\t\t\t\t{\n\t\t\t\t\tspace: space.uri,\n\t\t\t\t\trepo: ctx.target.did,\n\t\t\t\t\tcollection: POST,\n\t\t\t\t\trkey: \"shared\",\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn read.status === 200\n\t\t\t\t? pass(\"credential read the space\")\n\t\t\t\t: fail(\n\t\t\t\t\t\t`credential read failed: ${read.status} ${read.error ?? \"\"}`,\n\t\t\t\t\t\tread.json,\n\t\t\t\t\t);\n\t\t} finally {\n\t\t\tawait deleteProbeSpace(ctx, space.uri);\n\t\t}\n\t},\n});\n\nconst credentialCrossSpace = defineCheck({\n\tid: \"credential.cross-space-refused\",\n\ttitle: \"A credential for one space cannot read another\",\n\ttier: \"must\",\n\tcitations: [{ source: \"lexicon\", ref: \"com.atproto.space.getRecord\" }],\n\tneeds: [\"operator\", \"identities\"],\n\tdestructive: true,\n\tasync run(ctx) {\n\t\tconst reader = await ctx.identities!.identity(\"reader\");\n\t\tconst publicPolicy = {\n\t\t\t$type: \"com.atproto.simplespace.defs#publicPolicy\",\n\t\t};\n\t\tconst spaceA = await createProbeSpace(ctx, publicPolicy);\n\t\tconst spaceB = await createProbeSpace(ctx, publicPolicy);\n\t\ttry {\n\t\t\tawait operatorCreateRecord(ctx, spaceB.uri, POST, \"secret\", note(\"b\"));\n\t\t\tconst { credential } = await obtainCredential(ctx, reader, spaceA.uri);\n\t\t\tif (!credential) return fail(\"could not obtain a credential for space A\");\n\t\t\tconst cross = await credentialGet(\n\t\t\t\tctx,\n\t\t\t\tcredential,\n\t\t\t\t\"com.atproto.space.getRecord\",\n\t\t\t\t{\n\t\t\t\t\tspace: spaceB.uri,\n\t\t\t\t\trepo: ctx.target.did,\n\t\t\t\t\tcollection: POST,\n\t\t\t\t\trkey: \"secret\",\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn cross.status === 200\n\t\t\t\t? fail(\"space-A credential read space B\", cross.json)\n\t\t\t\t: pass(\n\t\t\t\t\t\t`cross-space read refused with ${cross.status} ${cross.error ?? \"\"}`,\n\t\t\t\t\t);\n\t\t} finally {\n\t\t\tawait deleteProbeSpace(ctx, spaceA.uri);\n\t\t\tawait deleteProbeSpace(ctx, spaceB.uri);\n\t\t}\n\t},\n});\n\nconst delegationReplay = defineCheck({\n\tid: \"delegation.replay-refused\",\n\ttitle: \"A delegation token cannot be used twice\",\n\ttier: \"must\",\n\tcitations: [\n\t\t{\n\t\t\tsource: \"lexicon\",\n\t\t\tref: \"com.atproto.space.getSpaceCredential@error:InvalidDelegationToken\",\n\t\t},\n\t],\n\tneeds: [\"operator\", \"identities\"],\n\tdestructive: true,\n\tasync run(ctx) {\n\t\tconst reader = await ctx.identities!.identity(\"reader\");\n\t\tconst space = await createProbeSpace(ctx, {\n\t\t\t$type: \"com.atproto.simplespace.defs#publicPolicy\",\n\t\t});\n\t\ttry {\n\t\t\t// Reuse one delegation token twice by minting it once. obtainCredential\n\t\t\t// mints a fresh token each call, so drive the exchange directly.\n\t\t\tconst { createDpopProof, createSpaceToken, spaceHostAud } =\n\t\t\t\tawait import(\"@atproto/space\");\n\t\t\tconst delegation = await createSpaceToken(\n\t\t\t\t\"delegation\",\n\t\t\t\t{\n\t\t\t\t\tiss: reader.did,\n\t\t\t\t\tsub: space.uri,\n\t\t\t\t\taud: spaceHostAud(ctx.target.did),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tjwtAlg: reader.jwtAlg,\n\t\t\t\t\tsign: (b: Uint8Array) => reader.sign(b),\n\t\t\t\t} as never,\n\t\t\t);\n\t\t\tconst exchange = async () => {\n\t\t\t\tconst dpopKey = await ctx.identities!.dpopKey();\n\t\t\t\tconst proof = await createDpopProof(dpopKey as never, {\n\t\t\t\t\thtm: \"POST\",\n\t\t\t\t\thtu: `${ctx.target.origin}/xrpc/com.atproto.space.getSpaceCredential`,\n\t\t\t\t});\n\t\t\t\treturn xrpcPost(\n\t\t\t\t\tctx,\n\t\t\t\t\t\"com.atproto.space.getSpaceCredential\",\n\t\t\t\t\t{ space: space.uri },\n\t\t\t\t\t{ Authorization: `Bearer ${delegation}`, DPoP: proof },\n\t\t\t\t);\n\t\t\t};\n\t\t\tconst first = await exchange();\n\t\t\tif (first.status !== 200) {\n\t\t\t\treturn fail(\n\t\t\t\t\t`first exchange failed (${first.status}); cannot test replay`,\n\t\t\t\t\tfirst.json,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst second = await exchange();\n\t\t\treturn second.status === 200\n\t\t\t\t? fail(\"a replayed delegation token was accepted\")\n\t\t\t\t: pass(`replay refused with ${second.status} ${second.error ?? \"\"}`);\n\t\t} finally {\n\t\t\tawait deleteProbeSpace(ctx, space.uri);\n\t\t}\n\t},\n});\n\nconst delegationWrongAud = defineCheck({\n\tid: \"delegation.wrong-audience-refused\",\n\ttitle: \"A delegation token addressed to another host is refused\",\n\ttier: \"must\",\n\tcitations: [\n\t\t{\n\t\t\tsource: \"lexicon\",\n\t\t\tref: \"com.atproto.space.getSpaceCredential@error:InvalidDelegationToken\",\n\t\t},\n\t],\n\tneeds: [\"operator\", \"identities\"],\n\tdestructive: true,\n\tasync run(ctx) {\n\t\tconst reader = await ctx.identities!.identity(\"reader\");\n\t\tconst space = await createProbeSpace(ctx, {\n\t\t\t$type: \"com.atproto.simplespace.defs#publicPolicy\",\n\t\t});\n\t\ttry {\n\t\t\t// Positive control: with the correct audience the same reader is\n\t\t\t// admitted (public policy), so a refusal below is attributable to\n\t\t\t// the audience and not to, say, an unresolvable reader DID.\n\t\t\tconst control = await obtainCredential(ctx, reader, space.uri);\n\t\t\tif (!control.credential) {\n\t\t\t\treturn fail(\n\t\t\t\t\t`correct-aud control failed (${control.result.status} ${control.result.error ?? \"\"}); cannot attribute the wrong-aud refusal`,\n\t\t\t\t\tcontrol.result.json,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { result } = await obtainCredential(ctx, reader, space.uri, {\n\t\t\t\taudOverride: \"did:web:someone-else.example#atproto_space_host\",\n\t\t\t});\n\t\t\tif (result.status === 200) {\n\t\t\t\treturn fail(\"a token with the wrong audience was accepted\");\n\t\t\t}\n\t\t\treturn result.error === \"InvalidDelegationToken\"\n\t\t\t\t? pass(\"wrong-aud token refused with InvalidDelegationToken\")\n\t\t\t\t: pass(\n\t\t\t\t\t\t`wrong-aud token refused (${result.status} ${result.error ?? \"\"}); InvalidDelegationToken preferred`,\n\t\t\t\t\t);\n\t\t} finally {\n\t\t\tawait deleteProbeSpace(ctx, space.uri);\n\t\t}\n\t},\n});\n\n// --- sync --------------------------------------------------------------\n\nconst syncOplogFolds = defineCheck({\n\tid: \"sync.oplog-folds-to-commit\",\n\t// \"set-hash\", not \"signed\": this check verifies the host's ops fold to the\n\t// commit hash the host serves — an internal-consistency property (catching\n\t// oplog/commit divergence, e.g. compaction bugs). It does not verify the\n\t// commit *signature*; no check does yet, and claiming so would overstate.\n\ttitle: \"Folding the oplog reproduces the commit set-hash\",\n\ttier: \"must\",\n\tcitations: [\n\t\t{ source: \"lexicon\", ref: \"com.atproto.space.listRepoOps\" },\n\t\t{ source: \"lexicon\", ref: \"com.atproto.space.defs\" },\n\t],\n\tneeds: [\"operator\"],\n\tdestructive: true,\n\tasync run(ctx) {\n\t\tconst space = await createProbeSpace(ctx);\n\t\ttry {\n\t\t\tawait operatorCreateRecord(ctx, space.uri, POST, \"a\", note(\"1\"));\n\t\t\tawait operatorCreateRecord(ctx, space.uri, POST, \"b\", note(\"2\"));\n\t\t\tconst res = await xrpcGet(\n\t\t\t\tasOperator(ctx),\n\t\t\t\t\"com.atproto.space.listRepoOps\",\n\t\t\t\t{ space: space.uri, repo: ctx.target.did },\n\t\t\t);\n\t\t\tif (res.status !== 200) {\n\t\t\t\treturn fail(`listRepoOps ${res.status} ${res.error ?? \"\"}`, res.json);\n\t\t\t}\n\t\t\tconst body = res.json as {\n\t\t\t\tops: Array<{\n\t\t\t\t\tcollection: string;\n\t\t\t\t\trkey: string;\n\t\t\t\t\tcid: string | null;\n\t\t\t\t\tprev: string | null;\n\t\t\t\t}>;\n\t\t\t\tcommit?: { hash: { $bytes: string } };\n\t\t\t};\n\t\t\tif (!body.commit) {\n\t\t\t\treturn fail(\"listRepoOps reached the head but returned no commit\");\n\t\t\t}\n\t\t\tconst setHash = new LtHash();\n\t\t\tfor (const op of body.ops) {\n\t\t\t\tif (op.prev) setHash.remove(`${op.collection}/${op.rkey}/${op.prev}`);\n\t\t\t\tif (op.cid) setHash.add(`${op.collection}/${op.rkey}/${op.cid}`);\n\t\t\t}\n\t\t\tconst folded = setHash.digest();\n\t\t\tconst claimed = fromBase64(body.commit.hash.$bytes);\n\t\t\tconst equal =\n\t\t\t\tfolded.length === claimed.length &&\n\t\t\t\tfolded.every((byte, i) => byte === claimed[i]);\n\t\t\treturn equal\n\t\t\t\t? pass(\"folded oplog matches the commit hash\")\n\t\t\t\t: fail(\"folded oplog does not match the commit hash\");\n\t\t} finally {\n\t\t\tawait deleteProbeSpace(ctx, space.uri);\n\t\t}\n\t},\n});\n\n// --- host role ---------------------------------------------------------\n\nconst hostMemberGate = defineCheck({\n\tid: \"host.member-list-gates\",\n\ttitle: \"member-list policy refuses a non-member and admits a member\",\n\ttier: \"must\",\n\tcitations: [\n\t\t{\n\t\t\tsource: \"lexicon\",\n\t\t\tref: \"com.atproto.space.getSpaceCredential@error:UserNotAuthorized\",\n\t\t},\n\t\t{ source: \"lexicon\", ref: \"com.atproto.simplespace.addMember\" },\n\t],\n\tneeds: [\"operator\", \"identities\"],\n\tdestructive: true,\n\tasync run(ctx) {\n\t\tconst reader = await ctx.identities!.identity(\"reader\");\n\t\tconst space = await createProbeSpace(ctx);\n\t\ttry {\n\t\t\tconst before = await obtainCredential(ctx, reader, space.uri);\n\t\t\tif (before.credential) {\n\t\t\t\treturn fail(\n\t\t\t\t\t\"a non-member obtained a credential under member-list policy\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait xrpcPost(asOperator(ctx), \"com.atproto.simplespace.addMember\", {\n\t\t\t\tspace: space.uri,\n\t\t\t\tdid: reader.did,\n\t\t\t});\n\t\t\tconst after = await obtainCredential(ctx, reader, space.uri);\n\t\t\treturn after.credential\n\t\t\t\t? pass(\n\t\t\t\t\t\t`non-member refused (${before.result.error ?? before.result.status}), member admitted`,\n\t\t\t\t\t)\n\t\t\t\t: fail(\n\t\t\t\t\t\t`a member was refused: ${after.result.status} ${after.result.error ?? \"\"}`,\n\t\t\t\t\t);\n\t\t} finally {\n\t\t\tawait deleteProbeSpace(ctx, space.uri);\n\t\t}\n\t},\n});\n\nconst hostDeleteTombstone = defineCheck({\n\tid: \"host.delete-space-tombstone\",\n\ttitle: \"After deleteSpace, getSpaceCredential answers SpaceDeleted\",\n\ttier: \"must\",\n\tcitations: [\n\t\t{ source: \"lexicon\", ref: \"com.atproto.simplespace.deleteSpace\" },\n\t\t{\n\t\t\tsource: \"lexicon\",\n\t\t\tref: \"com.atproto.space.getSpaceCredential@error:SpaceDeleted\",\n\t\t},\n\t],\n\tneeds: [\"operator\", \"identities\"],\n\tdestructive: true,\n\tasync run(ctx) {\n\t\tconst reader = await ctx.identities!.identity(\"reader\");\n\t\tconst space = await createProbeSpace(ctx, {\n\t\t\t$type: \"com.atproto.simplespace.defs#publicPolicy\",\n\t\t});\n\t\t// Positive control: before deletion the reader can obtain a\n\t\t// credential. Without it, a target that simply can't resolve the\n\t\t// reader (so credentials always fail) would pass the tombstone check\n\t\t// without the deletion ever being exercised.\n\t\tconst before = await obtainCredential(ctx, reader, space.uri);\n\t\tif (!before.credential) {\n\t\t\tawait deleteProbeSpace(ctx, space.uri);\n\t\t\treturn fail(\n\t\t\t\t`could not obtain a credential before deletion (${before.result.status} ${before.result.error ?? \"\"}); cannot test the tombstone`,\n\t\t\t\tbefore.result.json,\n\t\t\t);\n\t\t}\n\t\tconst del = await xrpcPost(\n\t\t\tasOperator(ctx),\n\t\t\t\"com.atproto.simplespace.deleteSpace\",\n\t\t\t{ space: space.uri },\n\t\t);\n\t\tif (del.status !== 200) {\n\t\t\treturn fail(\n\t\t\t\t`deleteSpace failed (${del.status} ${del.error ?? \"\"})`,\n\t\t\t\tdel.json,\n\t\t\t);\n\t\t}\n\t\tconst { result } = await obtainCredential(ctx, reader, space.uri);\n\t\tif (result.status === 200)\n\t\t\treturn fail(\"a deleted space still issued a credential\");\n\t\t// The proposal specifies SpaceDeleted as the durable tombstone signal\n\t\t// so a syncer that missed the notification learns to drop its copy.\n\t\treturn result.error === \"SpaceDeleted\"\n\t\t\t? pass(\"getSpaceCredential answered SpaceDeleted\")\n\t\t\t: fail(\n\t\t\t\t\t`deleted space refused with ${result.error} (${result.status}), expected SpaceDeleted`,\n\t\t\t\t\tresult.json,\n\t\t\t\t);\n\t},\n});\n\n/** The crypto-bound catalog: identity checks plus the LtHash fold. */\nexport const cryptoChecks: Check[] = [\n\tcredentialRoundTrip,\n\tcredentialCrossSpace,\n\tdelegationReplay,\n\tdelegationWrongAud,\n\tsyncOplogFolds,\n\thostMemberGate,\n\thostDeleteTombstone,\n];\n","/**\n * Harness identities and DPoP keys.\n *\n * Multi-party checks need the harness to play a reader, a writer and a\n * syncer — parties that aren't the target's operator. Each only needs a\n * DID with a resolvable key the target can verify against, so the provider\n * mints keypairs and the harness signs as those parties.\n *\n * Two facts the caller must arrange (they can't be solved in-library):\n * the target has to be able to *resolve* each identity's DID to its key.\n * In an in-process fixture the caller wires the target's key resolver to\n * this provider's `didKey(role)`; against a live target the identities\n * must be published (did:web under the checker's origin, or did:plc on a\n * reachable directory). The provider is resolution-agnostic — it only\n * holds keys and signs.\n */\n\nimport { Secp256k1Keypair } from \"@atproto/crypto\";\nimport type { DpopKey, HarnessIdentity, IdentityProvider } from \"./model.js\";\nimport { createDpopKey } from \"./dpop.js\";\n\n// DPoP keys are WebCrypto and browser-safe, so they live in ./dpop.ts;\n// re-exported here because the full entry has always offered them.\nexport { createDpopKey } from \"./dpop.js\";\n\nexport interface HarnessIdentityWithKey extends HarnessIdentity {\n\t/** The did:key form of the identity's signing key, for resolver wiring. */\n\tdidKey: string;\n}\n\n/**\n * An identity provider backed by secp256k1 keypairs. Identities are keyed\n * by role label and reused within a run, so \"reader\" is stable across the\n * checks that mint and then present its tokens.\n *\n * `didAt` lets the caller give each identity a resolvable DID (e.g.\n * `did:web:checker.test:actors:reader`); when omitted, the identity's DID\n * is its own `did:key`, which only works against a target whose resolver\n * this provider is wired into.\n */\nexport class KeypairIdentityProvider implements IdentityProvider {\n\tprivate cache = new Map<string, Promise<HarnessIdentityWithKey>>();\n\n\tconstructor(\n\t\tprivate readonly didAt?: (role: string, didKey: string) => string,\n\t) {}\n\n\tidentity(role: string): Promise<HarnessIdentityWithKey> {\n\t\tlet existing = this.cache.get(role);\n\t\tif (!existing) {\n\t\t\texisting = this.mint(role);\n\t\t\tthis.cache.set(role, existing);\n\t\t}\n\t\treturn existing;\n\t}\n\n\tprivate async mint(role: string): Promise<HarnessIdentityWithKey> {\n\t\tconst keypair = await Secp256k1Keypair.create({ exportable: true });\n\t\tconst didKey = keypair.did();\n\t\tconst did = this.didAt ? this.didAt(role, didKey) : didKey;\n\t\treturn {\n\t\t\tdid,\n\t\t\tdidKey,\n\t\t\tjwtAlg: keypair.jwtAlg,\n\t\t\tsign: (bytes) => keypair.sign(bytes),\n\t\t};\n\t}\n\n\tdpopKey(): Promise<DpopKey> {\n\t\treturn createDpopKey();\n\t}\n\n\t/** All minted identities so far, for resolver wiring in fixtures. */\n\tminted(): Promise<HarnessIdentityWithKey[]> {\n\t\treturn Promise.all(this.cache.values());\n\t}\n}\n","/**\n * The full check catalog and the identity provider.\n *\n * This entry imports `@atproto/space`, so it pulls the alpha crypto libs\n * and their (node-ish) transitive graph. Import it from the CLI and the\n * vitest adapter — anywhere WebCrypto and the alpha libs run — but never\n * from a browser bundle. The browser adapter imports the base catalog from\n * the package root instead.\n */\n\nimport { buildCatalog } from \"./registry.js\";\nimport { baseChecks } from \"./checks/base.js\";\nimport { operatorChecks } from \"./checks/operator.js\";\nimport { cryptoChecks } from \"./full/checks.js\";\n\nexport { KeypairIdentityProvider, createDpopKey } from \"./identity.js\";\nexport type { HarnessIdentityWithKey } from \"./identity.js\";\n\nexport {\n\tcreateProbeSpace,\n\tdeleteProbeSpace,\n\tobtainCredential,\n\tobtainCredentialViaDelegation,\n\tcredentialGet,\n\tmintDelegation,\n\toperatorCreateRecord,\n} from \"./full/helpers.js\";\nexport type { Credential, ProbeSpace } from \"./full/helpers.js\";\n\nexport { cryptoChecks } from \"./full/checks.js\";\nexport { operatorChecks } from \"./checks/operator.js\";\nexport { baseChecks } from \"./checks/base.js\";\n\n/**\n * The complete catalog: the browser-safe base and operator checks plus\n * the crypto-bound ones only this entry can run.\n */\nexport const fullCatalog = buildCatalog([\n\t...baseChecks,\n\t...operatorChecks,\n\t...cryptoChecks,\n]);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAiCA,SAAS,WAAW,UAA2B;AAC9C,QAAO;EACN,QAAQ,SAAS;EACjB,OAAO,UAAsB,SAAS,KAAK,MAAM;EACjD,WAAW,SAAS;EACpB;;;AAIF,eAAsB,eACrB,KACA,UACA,OACA,aACkB;AAClB,QAAO,iBACN,cACA;EACC,KAAK,SAAS;EACd,KAAK;EACL,KAAK,eAAe,aAAa,IAAI,OAAO,IAAI;EAChD,EACD,WAAW,SAAS,CACpB;;;;;;;AAQF,eAAsB,iBACrB,KACA,UACA,OACA,OAA6D,EAAE,EACJ;AAC3D,KAAI,CAAC,IAAI,WACR,OAAM,IAAI,MAAM,8CAA8C;CAC/D,MAAM,UAAU,MAAM,IAAI,WAAW,SAAS;CAC9C,MAAM,aAAa,MAAM,eACxB,KACA,UACA,OACA,KAAK,YACL;CACD,MAAM,QAAQ,MAAM,mBAAmB,SAAS;EAC/C,KAAK;EACL,KAAK,GAAG,IAAI,OAAO,OAAO;EAC1B,CAAC;CACF,MAAM,SAAS,MAAM,SACpB,KACA,wCACA;EACC;EACA,GAAI,KAAK,oBACN,EAAE,mBAAmB,KAAK,mBAAmB,GAC7C,EAAE;EACL,EACD;EAAE,eAAe,UAAU;EAAc,MAAM;EAA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vB,SAA4C;AAC3C,SAAO,QAAQ,IAAI,KAAK,MAAM,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;ACrCzC,MAAa,cAAc,aAAa;CACvC,GAAG;CACH,GAAG;CACH,GAAG;CACH,CAAC"}
|
package/dist/full.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { E as IdentityProvider, T as HarnessIdentity, a as credentialGet, c as operatorChecks, h as createDpopKey, i as createProbeSpace, l as operatorCreateRecord, n as Credential, o as deleteProbeSpace, r as ProbeSpace, s as obtainCredentialViaDelegation, t as baseChecks, u as XrpcResult, v as Check, w as DpopKey, y as CheckContext } from "./base-D8a-ZK57.js";
|
|
2
|
+
|
|
3
|
+
//#region src/identity.d.ts
|
|
4
|
+
|
|
5
|
+
interface HarnessIdentityWithKey extends HarnessIdentity {
|
|
6
|
+
/** The did:key form of the identity's signing key, for resolver wiring. */
|
|
7
|
+
didKey: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* An identity provider backed by secp256k1 keypairs. Identities are keyed
|
|
11
|
+
* by role label and reused within a run, so "reader" is stable across the
|
|
12
|
+
* checks that mint and then present its tokens.
|
|
13
|
+
*
|
|
14
|
+
* `didAt` lets the caller give each identity a resolvable DID (e.g.
|
|
15
|
+
* `did:web:checker.test:actors:reader`); when omitted, the identity's DID
|
|
16
|
+
* is its own `did:key`, which only works against a target whose resolver
|
|
17
|
+
* this provider is wired into.
|
|
18
|
+
*/
|
|
19
|
+
declare class KeypairIdentityProvider implements IdentityProvider {
|
|
20
|
+
private readonly didAt?;
|
|
21
|
+
private cache;
|
|
22
|
+
constructor(didAt?: ((role: string, didKey: string) => string) | undefined);
|
|
23
|
+
identity(role: string): Promise<HarnessIdentityWithKey>;
|
|
24
|
+
private mint;
|
|
25
|
+
dpopKey(): Promise<DpopKey>;
|
|
26
|
+
/** All minted identities so far, for resolver wiring in fixtures. */
|
|
27
|
+
minted(): Promise<HarnessIdentityWithKey[]>;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/full/helpers.d.ts
|
|
31
|
+
|
|
32
|
+
/** Mint a delegation token for `identity` against `space`. */
|
|
33
|
+
declare function mintDelegation(ctx: CheckContext, identity: HarnessIdentity, space: string, audOverride?: string): Promise<string>;
|
|
34
|
+
/**
|
|
35
|
+
* The full obtain flow: mint a delegation token as `identity`, exchange it
|
|
36
|
+
* at the target for a credential bound to a fresh DPoP key. Returns the
|
|
37
|
+
* raw XrpcResult alongside the credential so callers can assert on refusals.
|
|
38
|
+
*/
|
|
39
|
+
declare function obtainCredential(ctx: CheckContext, identity: HarnessIdentity, space: string, opts?: {
|
|
40
|
+
audOverride?: string;
|
|
41
|
+
clientAttestation?: string;
|
|
42
|
+
}): Promise<{
|
|
43
|
+
result: XrpcResult;
|
|
44
|
+
credential?: Credential;
|
|
45
|
+
}>;
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/full/checks.d.ts
|
|
48
|
+
/** The crypto-bound catalog: identity checks plus the LtHash fold. */
|
|
49
|
+
declare const cryptoChecks: Check[];
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/full.d.ts
|
|
52
|
+
/**
|
|
53
|
+
* The complete catalog: the browser-safe base and operator checks plus
|
|
54
|
+
* the crypto-bound ones only this entry can run.
|
|
55
|
+
*/
|
|
56
|
+
declare const fullCatalog: Check[];
|
|
57
|
+
//#endregion
|
|
58
|
+
export { type Credential, type HarnessIdentityWithKey, KeypairIdentityProvider, type ProbeSpace, baseChecks, createDpopKey, createProbeSpace, credentialGet, cryptoChecks, deleteProbeSpace, fullCatalog, mintDelegation, obtainCredential, obtainCredentialViaDelegation, operatorChecks, operatorCreateRecord };
|
|
59
|
+
//# sourceMappingURL=full.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"full.d.ts","names":[],"sources":["../src/identity.ts","../src/full/helpers.ts","../src/full/checks.ts","../src/full.ts"],"sourcesContent":[],"mappings":";;;;AC4CW,UDnBM,sBAAA,SAA+B,eCmBrC,CAAA;EAGR;EAAO,MAAA,EAAA,MAAA;AAiBV;;;;;;;;;;ACgVA;cFxWa,uBAAA,YAAmC;;;EGHnC,WAAA,CAAA,KAAW,CAItB,EAAA,CAAA,CAAA,IAAA,EAAA,MAJsB,EAAA,MAAA,EAAA,MAAA,EAAA,GAAA,MAAA,CAAA,GAAA,SAAA;0BHUC,QAAQ;;aAqBrB,QAAQ;;YAKT,QAAQ;;;;;ACTnB;AACM,iBAvBgB,cAAA,CAuBhB,GAAA,EAtBA,YAsBA,EAAA,QAAA,EArBK,eAqBL,EAAA,KAAA,EAAA,MAAA,EAAA,WAAA,CAAA,EAAA,MAAA,CAAA,EAlBH,OAkBG,CAAA,MAAA,CAAA;;;;;;iBADgB,gBAAA,MAChB,wBACK,oCC8UX;;;AAAA,CAAA,CAAA,ED3UG,OC2UU,CAAA;UD3UQ;eAAyB;;;;;AA3BxB,cCsWT,YDtWuB,ECsWT,KDtWS,EAAA;;;AAApC;;;;AAKU,cEVG,WFUH,EENR,KAAA,EFMQ"}
|
package/dist/full.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { c as operatorCreateRecord, f as baseChecks, i as deleteProbeSpace, n as createProbeSpace, o as obtainCredentialViaDelegation, r as credentialGet, s as operatorChecks, u as createDpopKey } from "./operator-BErXCDow.js";
|
|
2
|
+
import { a as obtainCredential, i as mintDelegation, n as KeypairIdentityProvider, r as cryptoChecks, t as fullCatalog } from "./full-D4ufJLcw.js";
|
|
3
|
+
|
|
4
|
+
export { KeypairIdentityProvider, baseChecks, createDpopKey, createProbeSpace, credentialGet, cryptoChecks, deleteProbeSpace, fullCatalog, mintDelegation, obtainCredential, obtainCredentialViaDelegation, operatorChecks, operatorCreateRecord };
|