@atproto/lex-space 0.0.0-stage → 0.0.1
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/LICENSE.txt +7 -0
- package/README.md +463 -2
- package/dist/actions.d.ts +17 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +20 -0
- package/dist/actions.js.map +1 -0
- package/dist/atproto-did-resolver.d.ts +3 -0
- package/dist/atproto-did-resolver.d.ts.map +1 -0
- package/dist/atproto-did-resolver.js +2 -0
- package/dist/atproto-did-resolver.js.map +1 -0
- package/dist/client-attestation-provider.d.ts +57 -0
- package/dist/client-attestation-provider.d.ts.map +1 -0
- package/dist/client-attestation-provider.js +51 -0
- package/dist/client-attestation-provider.js.map +1 -0
- package/dist/delegation-token-provider.d.ts +25 -0
- package/dist/delegation-token-provider.d.ts.map +1 -0
- package/dist/delegation-token-provider.js +28 -0
- package/dist/delegation-token-provider.js.map +1 -0
- package/dist/errors.d.ts +27 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +27 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/lexicons/com/atproto/managedspace/policy.d.ts +3 -0
- package/dist/lexicons/com/atproto/managedspace/policy.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/managedspace/policy.defs.d.ts +78 -0
- package/dist/lexicons/com/atproto/managedspace/policy.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/managedspace/policy.defs.js +23 -0
- package/dist/lexicons/com/atproto/managedspace/policy.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/managedspace/policy.js +6 -0
- package/dist/lexicons/com/atproto/managedspace/policy.js.map +1 -0
- package/dist/lexicons/com/atproto/managedspace.d.ts +2 -0
- package/dist/lexicons/com/atproto/managedspace.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/managedspace.js +5 -0
- package/dist/lexicons/com/atproto/managedspace.js.map +1 -0
- package/dist/lexicons/com/atproto/memberspace/defs.d.ts +2 -0
- package/dist/lexicons/com/atproto/memberspace/defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/memberspace/defs.defs.d.ts +14 -0
- package/dist/lexicons/com/atproto/memberspace/defs.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/memberspace/defs.defs.js +9 -0
- package/dist/lexicons/com/atproto/memberspace/defs.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/memberspace/defs.js +5 -0
- package/dist/lexicons/com/atproto/memberspace/defs.js.map +1 -0
- package/dist/lexicons/com/atproto/memberspace/listMembers.d.ts +3 -0
- package/dist/lexicons/com/atproto/memberspace/listMembers.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/memberspace/listMembers.defs.d.ts +35 -0
- package/dist/lexicons/com/atproto/memberspace/listMembers.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/memberspace/listMembers.defs.js +15 -0
- package/dist/lexicons/com/atproto/memberspace/listMembers.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/memberspace/listMembers.js +6 -0
- package/dist/lexicons/com/atproto/memberspace/listMembers.js.map +1 -0
- package/dist/lexicons/com/atproto/memberspace/policy.d.ts +3 -0
- package/dist/lexicons/com/atproto/memberspace/policy.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/memberspace/policy.defs.d.ts +120 -0
- package/dist/lexicons/com/atproto/memberspace/policy.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/memberspace/policy.defs.js +23 -0
- package/dist/lexicons/com/atproto/memberspace/policy.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/memberspace/policy.js +6 -0
- package/dist/lexicons/com/atproto/memberspace/policy.js.map +1 -0
- package/dist/lexicons/com/atproto/memberspace/putMembers.d.ts +3 -0
- package/dist/lexicons/com/atproto/memberspace/putMembers.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/memberspace/putMembers.defs.d.ts +30 -0
- package/dist/lexicons/com/atproto/memberspace/putMembers.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/memberspace/putMembers.defs.js +16 -0
- package/dist/lexicons/com/atproto/memberspace/putMembers.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/memberspace/putMembers.js +6 -0
- package/dist/lexicons/com/atproto/memberspace/putMembers.js.map +1 -0
- package/dist/lexicons/com/atproto/memberspace/removeMembers.d.ts +3 -0
- package/dist/lexicons/com/atproto/memberspace/removeMembers.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/memberspace/removeMembers.defs.d.ts +33 -0
- package/dist/lexicons/com/atproto/memberspace/removeMembers.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/memberspace/removeMembers.defs.js +15 -0
- package/dist/lexicons/com/atproto/memberspace/removeMembers.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/memberspace/removeMembers.js +6 -0
- package/dist/lexicons/com/atproto/memberspace/removeMembers.js.map +1 -0
- package/dist/lexicons/com/atproto/memberspace.d.ts +6 -0
- package/dist/lexicons/com/atproto/memberspace.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/memberspace.js +9 -0
- package/dist/lexicons/com/atproto/memberspace.js.map +1 -0
- package/dist/lexicons/com/atproto/personalspace/policy.d.ts +3 -0
- package/dist/lexicons/com/atproto/personalspace/policy.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/personalspace/policy.defs.d.ts +50 -0
- package/dist/lexicons/com/atproto/personalspace/policy.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/personalspace/policy.defs.js +23 -0
- package/dist/lexicons/com/atproto/personalspace/policy.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/personalspace/policy.js +6 -0
- package/dist/lexicons/com/atproto/personalspace/policy.js.map +1 -0
- package/dist/lexicons/com/atproto/personalspace.d.ts +2 -0
- package/dist/lexicons/com/atproto/personalspace.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/personalspace.js +5 -0
- package/dist/lexicons/com/atproto/personalspace.js.map +1 -0
- package/dist/lexicons/com/atproto/space/applyWrites.d.ts +3 -0
- package/dist/lexicons/com/atproto/space/applyWrites.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/applyWrites.defs.d.ts +97 -0
- package/dist/lexicons/com/atproto/space/applyWrites.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/applyWrites.defs.js +30 -0
- package/dist/lexicons/com/atproto/space/applyWrites.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/applyWrites.js +6 -0
- package/dist/lexicons/com/atproto/space/applyWrites.js.map +1 -0
- package/dist/lexicons/com/atproto/space/authorizeSpaceSync.d.ts +3 -0
- package/dist/lexicons/com/atproto/space/authorizeSpaceSync.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/authorizeSpaceSync.defs.d.ts +59 -0
- package/dist/lexicons/com/atproto/space/authorizeSpaceSync.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/authorizeSpaceSync.defs.js +17 -0
- package/dist/lexicons/com/atproto/space/authorizeSpaceSync.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/authorizeSpaceSync.js +6 -0
- package/dist/lexicons/com/atproto/space/authorizeSpaceSync.js.map +1 -0
- package/dist/lexicons/com/atproto/space/clearRecords.d.ts +3 -0
- package/dist/lexicons/com/atproto/space/clearRecords.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/clearRecords.defs.d.ts +33 -0
- package/dist/lexicons/com/atproto/space/clearRecords.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/clearRecords.defs.js +15 -0
- package/dist/lexicons/com/atproto/space/clearRecords.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/clearRecords.js +6 -0
- package/dist/lexicons/com/atproto/space/clearRecords.js.map +1 -0
- package/dist/lexicons/com/atproto/space/createRecord.d.ts +3 -0
- package/dist/lexicons/com/atproto/space/createRecord.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/createRecord.defs.d.ts +69 -0
- package/dist/lexicons/com/atproto/space/createRecord.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/createRecord.defs.js +15 -0
- package/dist/lexicons/com/atproto/space/createRecord.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/createRecord.js +6 -0
- package/dist/lexicons/com/atproto/space/createRecord.js.map +1 -0
- package/dist/lexicons/com/atproto/space/createSpace.d.ts +3 -0
- package/dist/lexicons/com/atproto/space/createSpace.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/createSpace.defs.d.ts +46 -0
- package/dist/lexicons/com/atproto/space/createSpace.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/createSpace.defs.js +18 -0
- package/dist/lexicons/com/atproto/space/createSpace.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/createSpace.js +6 -0
- package/dist/lexicons/com/atproto/space/createSpace.js.map +1 -0
- package/dist/lexicons/com/atproto/space/defs.d.ts +2 -0
- package/dist/lexicons/com/atproto/space/defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/defs.defs.d.ts +60 -0
- package/dist/lexicons/com/atproto/space/defs.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/defs.defs.js +16 -0
- package/dist/lexicons/com/atproto/space/defs.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/defs.js +5 -0
- package/dist/lexicons/com/atproto/space/defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/deleteRecord.d.ts +3 -0
- package/dist/lexicons/com/atproto/space/deleteRecord.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/deleteRecord.defs.d.ts +45 -0
- package/dist/lexicons/com/atproto/space/deleteRecord.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/deleteRecord.defs.js +15 -0
- package/dist/lexicons/com/atproto/space/deleteRecord.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/deleteRecord.js +6 -0
- package/dist/lexicons/com/atproto/space/deleteRecord.js.map +1 -0
- package/dist/lexicons/com/atproto/space/deleteSpace.d.ts +3 -0
- package/dist/lexicons/com/atproto/space/deleteSpace.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/deleteSpace.defs.d.ts +27 -0
- package/dist/lexicons/com/atproto/space/deleteSpace.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/deleteSpace.defs.js +15 -0
- package/dist/lexicons/com/atproto/space/deleteSpace.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/deleteSpace.js +6 -0
- package/dist/lexicons/com/atproto/space/deleteSpace.js.map +1 -0
- package/dist/lexicons/com/atproto/space/getBlob.d.ts +3 -0
- package/dist/lexicons/com/atproto/space/getBlob.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/getBlob.defs.d.ts +36 -0
- package/dist/lexicons/com/atproto/space/getBlob.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/getBlob.defs.js +14 -0
- package/dist/lexicons/com/atproto/space/getBlob.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/getBlob.js +6 -0
- package/dist/lexicons/com/atproto/space/getBlob.js.map +1 -0
- package/dist/lexicons/com/atproto/space/getDelegationToken.d.ts +3 -0
- package/dist/lexicons/com/atproto/space/getDelegationToken.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/getDelegationToken.defs.d.ts +28 -0
- package/dist/lexicons/com/atproto/space/getDelegationToken.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/getDelegationToken.defs.js +14 -0
- package/dist/lexicons/com/atproto/space/getDelegationToken.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/getDelegationToken.js +6 -0
- package/dist/lexicons/com/atproto/space/getDelegationToken.js.map +1 -0
- package/dist/lexicons/com/atproto/space/getLatestCommit.d.ts +3 -0
- package/dist/lexicons/com/atproto/space/getLatestCommit.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/getLatestCommit.defs.d.ts +35 -0
- package/dist/lexicons/com/atproto/space/getLatestCommit.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/getLatestCommit.defs.js +15 -0
- package/dist/lexicons/com/atproto/space/getLatestCommit.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/getLatestCommit.js +6 -0
- package/dist/lexicons/com/atproto/space/getLatestCommit.js.map +1 -0
- package/dist/lexicons/com/atproto/space/getRecord.d.ts +3 -0
- package/dist/lexicons/com/atproto/space/getRecord.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/getRecord.defs.d.ts +58 -0
- package/dist/lexicons/com/atproto/space/getRecord.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/getRecord.defs.js +14 -0
- package/dist/lexicons/com/atproto/space/getRecord.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/getRecord.js +6 -0
- package/dist/lexicons/com/atproto/space/getRecord.js.map +1 -0
- package/dist/lexicons/com/atproto/space/getRepo.d.ts +3 -0
- package/dist/lexicons/com/atproto/space/getRepo.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/getRepo.defs.d.ts +30 -0
- package/dist/lexicons/com/atproto/space/getRepo.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/getRepo.defs.js +14 -0
- package/dist/lexicons/com/atproto/space/getRepo.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/getRepo.js +6 -0
- package/dist/lexicons/com/atproto/space/getRepo.js.map +1 -0
- package/dist/lexicons/com/atproto/space/getSpace.d.ts +3 -0
- package/dist/lexicons/com/atproto/space/getSpace.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/getSpace.defs.d.ts +37 -0
- package/dist/lexicons/com/atproto/space/getSpace.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/getSpace.defs.js +17 -0
- package/dist/lexicons/com/atproto/space/getSpace.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/getSpace.js +6 -0
- package/dist/lexicons/com/atproto/space/getSpace.js.map +1 -0
- package/dist/lexicons/com/atproto/space/getSpaceCredential.d.ts +3 -0
- package/dist/lexicons/com/atproto/space/getSpaceCredential.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/getSpaceCredential.defs.d.ts +53 -0
- package/dist/lexicons/com/atproto/space/getSpaceCredential.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/getSpaceCredential.defs.js +17 -0
- package/dist/lexicons/com/atproto/space/getSpaceCredential.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/getSpaceCredential.js +6 -0
- package/dist/lexicons/com/atproto/space/getSpaceCredential.js.map +1 -0
- package/dist/lexicons/com/atproto/space/listBlobs.d.ts +3 -0
- package/dist/lexicons/com/atproto/space/listBlobs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/listBlobs.defs.d.ts +44 -0
- package/dist/lexicons/com/atproto/space/listBlobs.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/listBlobs.defs.js +14 -0
- package/dist/lexicons/com/atproto/space/listBlobs.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/listBlobs.js +6 -0
- package/dist/lexicons/com/atproto/space/listBlobs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/listRecords.d.ts +3 -0
- package/dist/lexicons/com/atproto/space/listRecords.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/listRecords.defs.d.ts +58 -0
- package/dist/lexicons/com/atproto/space/listRecords.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/listRecords.defs.js +16 -0
- package/dist/lexicons/com/atproto/space/listRecords.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/listRecords.js +6 -0
- package/dist/lexicons/com/atproto/space/listRecords.js.map +1 -0
- package/dist/lexicons/com/atproto/space/listRepoOps.d.ts +3 -0
- package/dist/lexicons/com/atproto/space/listRepoOps.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/listRepoOps.defs.d.ts +74 -0
- package/dist/lexicons/com/atproto/space/listRepoOps.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/listRepoOps.defs.js +18 -0
- package/dist/lexicons/com/atproto/space/listRepoOps.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/listRepoOps.js +6 -0
- package/dist/lexicons/com/atproto/space/listRepoOps.js.map +1 -0
- package/dist/lexicons/com/atproto/space/listSpaces.d.ts +3 -0
- package/dist/lexicons/com/atproto/space/listSpaces.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/listSpaces.defs.d.ts +59 -0
- package/dist/lexicons/com/atproto/space/listSpaces.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/listSpaces.defs.js +16 -0
- package/dist/lexicons/com/atproto/space/listSpaces.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/listSpaces.js +6 -0
- package/dist/lexicons/com/atproto/space/listSpaces.js.map +1 -0
- package/dist/lexicons/com/atproto/space/listWriters.d.ts +3 -0
- package/dist/lexicons/com/atproto/space/listWriters.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/listWriters.defs.d.ts +35 -0
- package/dist/lexicons/com/atproto/space/listWriters.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/listWriters.defs.js +15 -0
- package/dist/lexicons/com/atproto/space/listWriters.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/listWriters.js +6 -0
- package/dist/lexicons/com/atproto/space/listWriters.js.map +1 -0
- package/dist/lexicons/com/atproto/space/putRecord.d.ts +3 -0
- package/dist/lexicons/com/atproto/space/putRecord.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/putRecord.defs.d.ts +69 -0
- package/dist/lexicons/com/atproto/space/putRecord.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/putRecord.defs.js +15 -0
- package/dist/lexicons/com/atproto/space/putRecord.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/putRecord.js +6 -0
- package/dist/lexicons/com/atproto/space/putRecord.js.map +1 -0
- package/dist/lexicons/com/atproto/space/registerNotify.d.ts +3 -0
- package/dist/lexicons/com/atproto/space/registerNotify.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/registerNotify.defs.d.ts +37 -0
- package/dist/lexicons/com/atproto/space/registerNotify.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/registerNotify.defs.js +23 -0
- package/dist/lexicons/com/atproto/space/registerNotify.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/registerNotify.js +6 -0
- package/dist/lexicons/com/atproto/space/registerNotify.js.map +1 -0
- package/dist/lexicons/com/atproto/space/removeWriter.d.ts +3 -0
- package/dist/lexicons/com/atproto/space/removeWriter.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/removeWriter.defs.d.ts +33 -0
- package/dist/lexicons/com/atproto/space/removeWriter.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/removeWriter.defs.js +15 -0
- package/dist/lexicons/com/atproto/space/removeWriter.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/removeWriter.js +6 -0
- package/dist/lexicons/com/atproto/space/removeWriter.js.map +1 -0
- package/dist/lexicons/com/atproto/space/unregisterNotify.d.ts +3 -0
- package/dist/lexicons/com/atproto/space/unregisterNotify.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/unregisterNotify.defs.d.ts +29 -0
- package/dist/lexicons/com/atproto/space/unregisterNotify.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/unregisterNotify.defs.js +20 -0
- package/dist/lexicons/com/atproto/space/unregisterNotify.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/unregisterNotify.js +6 -0
- package/dist/lexicons/com/atproto/space/unregisterNotify.js.map +1 -0
- package/dist/lexicons/com/atproto/space/updateSpace.d.ts +3 -0
- package/dist/lexicons/com/atproto/space/updateSpace.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/updateSpace.defs.d.ts +32 -0
- package/dist/lexicons/com/atproto/space/updateSpace.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space/updateSpace.defs.js +18 -0
- package/dist/lexicons/com/atproto/space/updateSpace.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/space/updateSpace.js +6 -0
- package/dist/lexicons/com/atproto/space/updateSpace.js.map +1 -0
- package/dist/lexicons/com/atproto/space.d.ts +23 -0
- package/dist/lexicons/com/atproto/space.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/space.js +26 -0
- package/dist/lexicons/com/atproto/space.js.map +1 -0
- package/dist/lexicons/com/atproto.d.ts +5 -0
- package/dist/lexicons/com/atproto.d.ts.map +1 -0
- package/dist/lexicons/com/atproto.js +8 -0
- package/dist/lexicons/com/atproto.js.map +1 -0
- package/dist/lexicons/com.d.ts +2 -0
- package/dist/lexicons/com.d.ts.map +1 -0
- package/dist/lexicons/com.js +5 -0
- package/dist/lexicons/com.js.map +1 -0
- package/dist/lexicons/index.d.ts +2 -0
- package/dist/lexicons/index.d.ts.map +1 -0
- package/dist/lexicons/index.js +5 -0
- package/dist/lexicons/index.js.map +1 -0
- package/dist/policies/baseline.d.ts +7 -0
- package/dist/policies/baseline.d.ts.map +1 -0
- package/dist/policies/baseline.js +10 -0
- package/dist/policies/baseline.js.map +1 -0
- package/dist/policies/index.d.ts +6 -0
- package/dist/policies/index.d.ts.map +1 -0
- package/dist/policies/index.js +6 -0
- package/dist/policies/index.js.map +1 -0
- package/dist/policies/managedspace.d.ts +12 -0
- package/dist/policies/managedspace.d.ts.map +1 -0
- package/dist/policies/managedspace.js +12 -0
- package/dist/policies/managedspace.js.map +1 -0
- package/dist/policies/memberspace.d.ts +31 -0
- package/dist/policies/memberspace.d.ts.map +1 -0
- package/dist/policies/memberspace.js +48 -0
- package/dist/policies/memberspace.js.map +1 -0
- package/dist/policies/personalspace.d.ts +11 -0
- package/dist/policies/personalspace.d.ts.map +1 -0
- package/dist/policies/personalspace.js +11 -0
- package/dist/policies/personalspace.js.map +1 -0
- package/dist/policies/space-policy-manager.d.ts +73 -0
- package/dist/policies/space-policy-manager.d.ts.map +1 -0
- package/dist/policies/space-policy-manager.js +81 -0
- package/dist/policies/space-policy-manager.js.map +1 -0
- package/dist/space-client.d.ts +254 -0
- package/dist/space-client.d.ts.map +1 -0
- package/dist/space-client.js +301 -0
- package/dist/space-client.js.map +1 -0
- package/dist/space-collection.d.ts +11 -0
- package/dist/space-collection.d.ts.map +1 -0
- package/dist/space-collection.js +2 -0
- package/dist/space-collection.js.map +1 -0
- package/dist/space-credential-provider.d.ts +68 -0
- package/dist/space-credential-provider.d.ts.map +1 -0
- package/dist/space-credential-provider.js +68 -0
- package/dist/space-credential-provider.js.map +1 -0
- package/dist/space-credential.d.ts +35 -0
- package/dist/space-credential.d.ts.map +1 -0
- package/dist/space-credential.js +64 -0
- package/dist/space-credential.js.map +1 -0
- package/dist/space-manager.d.ts +102 -0
- package/dist/space-manager.d.ts.map +1 -0
- package/dist/space-manager.js +121 -0
- package/dist/space-manager.js.map +1 -0
- package/dist/space-reader.d.ts +400 -0
- package/dist/space-reader.d.ts.map +1 -0
- package/dist/space-reader.js +573 -0
- package/dist/space-reader.js.map +1 -0
- package/dist/write-operation-builder.d.ts +22 -0
- package/dist/write-operation-builder.d.ts.map +1 -0
- package/dist/write-operation-builder.js +37 -0
- package/dist/write-operation-builder.js.map +1 -0
- package/package.json +64 -3
|
@@ -0,0 +1,573 @@
|
|
|
1
|
+
import { formatDidVerificationMethod } from '@atproto/crypto';
|
|
2
|
+
import { extractKemKey, extractPdsUrl } from '@atproto/did';
|
|
3
|
+
import { cidForLex } from '@atproto/lex-cbor';
|
|
4
|
+
import { XrpcAuthenticationError, XrpcResponseError, buildAgent, xrpc, } from '@atproto/lex-client';
|
|
5
|
+
import { checkCid, isCidForBytes, parseCid, } from '@atproto/lex-data';
|
|
6
|
+
import { getMain, } from '@atproto/lex-schema';
|
|
7
|
+
import { COMMIT_MAC_PROFILE, RECORD_MAC_PROFILE, RepoCommit, SpaceMacError, SpaceRepoVerificationError, encapsulate, formatMacRequest, formatRecordPath, verifyCommit, verifyRecord, verifyRepoStar, } from '@atproto/space';
|
|
8
|
+
import { SpaceRef, } from '@atproto/syntax';
|
|
9
|
+
import { createDidResolver } from '@atproto-labs/did-resolver';
|
|
10
|
+
import { RepoGapError } from './errors.js';
|
|
11
|
+
import { repoRemoved, repoWrite, } from './lexicons/com/atproto/space/defs.js';
|
|
12
|
+
import getBlob from './lexicons/com/atproto/space/getBlob.js';
|
|
13
|
+
import getLatestCommit from './lexicons/com/atproto/space/getLatestCommit.js';
|
|
14
|
+
import getRecord from './lexicons/com/atproto/space/getRecord.js';
|
|
15
|
+
import getRepo from './lexicons/com/atproto/space/getRepo.js';
|
|
16
|
+
import listBlobs from './lexicons/com/atproto/space/listBlobs.js';
|
|
17
|
+
import listRecords, {} from './lexicons/com/atproto/space/listRecords.js';
|
|
18
|
+
import listRepoOps from './lexicons/com/atproto/space/listRepoOps.js';
|
|
19
|
+
import listWriters from './lexicons/com/atproto/space/listWriters.js';
|
|
20
|
+
import { SpaceCredentialProviderCache, buildSpaceCredentialProvider, } from './space-credential-provider.js';
|
|
21
|
+
export { SpaceRef };
|
|
22
|
+
/**
|
|
23
|
+
* Reads a space of the type described by `schema`, with a space credential
|
|
24
|
+
* obtained in exchange for delegation tokens (see
|
|
25
|
+
* {@link DelegationTokenProvider}). Use it to sync a space without acting for a
|
|
26
|
+
* specific user, e.g. in a sync service; see `SpaceClient` to act for a user.
|
|
27
|
+
*
|
|
28
|
+
* Requests are sent to the PDS of the account whose repo they target, or to
|
|
29
|
+
* the space host (the authority's PDS) when they target no repo. Records,
|
|
30
|
+
* commits, repos and blobs are verified against the MAC, or CID, their host
|
|
31
|
+
* provided.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const reader = SpaceReader.openSpace(com.example.forum, spaceUri, {
|
|
36
|
+
* delegationTokenProvider: async (space) => requestDelegationToken(space),
|
|
37
|
+
* })
|
|
38
|
+
*
|
|
39
|
+
* for await (const record of reader.allRecords()) {
|
|
40
|
+
* console.log(record.repo, record.collection, record.rkey, record.record)
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export class SpaceReader {
|
|
45
|
+
#resolver;
|
|
46
|
+
#fetch;
|
|
47
|
+
#credentialProvider;
|
|
48
|
+
/**
|
|
49
|
+
* Reads a space, identified by its URI or by its authority and key.
|
|
50
|
+
*
|
|
51
|
+
* @throws {TypeError} if the space is not of the type described by `schema`
|
|
52
|
+
*/
|
|
53
|
+
static openSpace(schema, space, options) {
|
|
54
|
+
const ref = typeof space === 'string'
|
|
55
|
+
? SpaceRef.parse(space)
|
|
56
|
+
: space instanceof SpaceRef
|
|
57
|
+
? space
|
|
58
|
+
: schema.spaceRefFor(space.authority, space.skey);
|
|
59
|
+
return new SpaceReader(schema, ref, options);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* @throws {TypeError} if the space is not of the type described by `schema`
|
|
63
|
+
*/
|
|
64
|
+
constructor(
|
|
65
|
+
/** The space type, e.g. to restrict the collections read and written. */
|
|
66
|
+
schema, ref, { fetch = globalThis.fetch, didResolver = createDidResolver({ fetch }), clientAttestationProvider = undefined, delegationTokenProvider = undefined, notifyRegistrationProvider = undefined, credentialProvider = buildSpaceCredentialProvider({
|
|
67
|
+
didResolver,
|
|
68
|
+
fetch,
|
|
69
|
+
clientAttestationProvider,
|
|
70
|
+
delegationTokenProvider,
|
|
71
|
+
notifyRegistrationProvider,
|
|
72
|
+
}), } = {}) {
|
|
73
|
+
this.schema = schema;
|
|
74
|
+
this.ref = ref;
|
|
75
|
+
if (ref.spaceType !== schema.nsid) {
|
|
76
|
+
throw new TypeError(`${ref} is not a ${schema.nsid} space`);
|
|
77
|
+
}
|
|
78
|
+
this.uri = ref.toString();
|
|
79
|
+
this.#resolver = didResolver;
|
|
80
|
+
this.#fetch = fetch;
|
|
81
|
+
this.#credentialProvider =
|
|
82
|
+
SpaceCredentialProviderCache.for(credentialProvider);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Lists the accounts holding a repo in the space (its writer set), as known
|
|
86
|
+
* to the space host.
|
|
87
|
+
*/
|
|
88
|
+
async listWriters({ limit, cursor, ...options } = {}) {
|
|
89
|
+
return this.authorityXrpc(listWriters, {
|
|
90
|
+
...options,
|
|
91
|
+
params: { space: this.uri, limit, cursor },
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Iterates over the writer set of the space, at the latest update to each
|
|
96
|
+
* repo, in ascending `spaceRev` order. A repo removed from the writer set is
|
|
97
|
+
* listed as `repoRemoved`, and is not part of the space. A repo updated while
|
|
98
|
+
* iterating may be yielded again, in which case its last entry is current.
|
|
99
|
+
*
|
|
100
|
+
* The highest `spaceRev` yielded can be used as `cursor` to only list the
|
|
101
|
+
* repos updated since. Removals may be forgotten by the space host after 72
|
|
102
|
+
* hours, so with an older cursor, list the whole writer set instead, and drop
|
|
103
|
+
* the repos missing from it.
|
|
104
|
+
*/
|
|
105
|
+
async *writers(options = {}) {
|
|
106
|
+
let { cursor } = options;
|
|
107
|
+
do {
|
|
108
|
+
const { body } = await this.listWriters({ ...options, cursor });
|
|
109
|
+
for (const entry of body.repos) {
|
|
110
|
+
// Entries of a kind unknown to this version are skipped.
|
|
111
|
+
if (repoWrite.$isTypeOf(entry) || repoRemoved.$isTypeOf(entry)) {
|
|
112
|
+
yield entry;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// Guard against a server returning the same cursor
|
|
116
|
+
if (body.cursor === cursor)
|
|
117
|
+
return;
|
|
118
|
+
cursor = body.cursor;
|
|
119
|
+
} while (cursor);
|
|
120
|
+
}
|
|
121
|
+
async listRecords({ repo, collection, limit, cursor, excludeValues, ...options }) {
|
|
122
|
+
return this.repoXrpc(repo, listRecords, {
|
|
123
|
+
...options,
|
|
124
|
+
params: {
|
|
125
|
+
space: this.uri,
|
|
126
|
+
repo,
|
|
127
|
+
collection,
|
|
128
|
+
limit,
|
|
129
|
+
cursor,
|
|
130
|
+
excludeValues,
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Iterates over the records of a repo.
|
|
136
|
+
*
|
|
137
|
+
* @note Listed records are not covered by a MAC; see {@link getRepo} for a
|
|
138
|
+
* verified copy of a repo.
|
|
139
|
+
*/
|
|
140
|
+
async *records(options) {
|
|
141
|
+
let { cursor } = options;
|
|
142
|
+
do {
|
|
143
|
+
const { body } = await this.listRecords({ ...options, cursor });
|
|
144
|
+
yield* body.records;
|
|
145
|
+
if (body.cursor === cursor)
|
|
146
|
+
return;
|
|
147
|
+
cursor = body.cursor;
|
|
148
|
+
} while (cursor);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Gets a record, verified against the MAC its host computed for the
|
|
152
|
+
* request.
|
|
153
|
+
*
|
|
154
|
+
* @throws {SpaceRepoVerificationError} if the record fails verification
|
|
155
|
+
*/
|
|
156
|
+
async getRecord(collection, rkey, { repo, ...options }) {
|
|
157
|
+
const params = { space: this.uri, repo, collection, rkey };
|
|
158
|
+
const uri = `${this.uri}/${repo}/${collection}/${rkey}`;
|
|
159
|
+
return this.#verified(`Record ${uri} failed verification`, async (kem) => {
|
|
160
|
+
const { response, mac } = await this.#withMac(repo, getRecord, RECORD_MAC_PROFILE, { ...options, params }, kem);
|
|
161
|
+
await verifyRecord(response.body, { ...mac, uri });
|
|
162
|
+
return response;
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Gets the current commit of a repo, verified against the MAC its host
|
|
167
|
+
* computed for the request.
|
|
168
|
+
*
|
|
169
|
+
* @throws {SpaceRepoVerificationError} if the commit fails verification
|
|
170
|
+
*/
|
|
171
|
+
async getLatestCommit({ repo, ...options }) {
|
|
172
|
+
const params = { space: this.uri, repo };
|
|
173
|
+
return this.#verified(`Repo ${repo} commit failed verification`, async (kem) => {
|
|
174
|
+
const { response, mac } = await this.#withMac(repo, getLatestCommit, COMMIT_MAC_PROFILE, { ...options, params }, kem);
|
|
175
|
+
verifyCommit(response.body.commit, { ...params, ...mac });
|
|
176
|
+
return response;
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Gets a repo in full. Its commit is verified against the MAC its host
|
|
181
|
+
* computed for the request, and its records against its commit as they are
|
|
182
|
+
* read: all of them must be read before trusting any.
|
|
183
|
+
*
|
|
184
|
+
* @note The returned repo must be disposed of, or its records read.
|
|
185
|
+
* @throws {SpaceRepoVerificationError} if the repo fails verification
|
|
186
|
+
*/
|
|
187
|
+
async getRepo({ repo, ...options }) {
|
|
188
|
+
const params = { space: this.uri, repo };
|
|
189
|
+
return this.#verified(`Repo ${repo} failed verification`, async (kem) => {
|
|
190
|
+
const { response, mac } = await this.#withMac(repo, getRepo, COMMIT_MAC_PROFILE, { ...options, params }, kem);
|
|
191
|
+
// @TODO Stream the archive, once lex-client can stream response bodies
|
|
192
|
+
return verifyRepoStar([response.body], { ...params, ...mac });
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Lists a page of a repo's operation log. The repo's current commit, included
|
|
197
|
+
* with every page, is verified against the MAC its host computed for the
|
|
198
|
+
* request.
|
|
199
|
+
*
|
|
200
|
+
* @see {@link syncRepo} to apply the operations to a known state.
|
|
201
|
+
* @throws {SpaceRepoVerificationError} if the commit fails verification
|
|
202
|
+
*/
|
|
203
|
+
async listRepoOps({ repo, since, cursor, limit, excludeValues, ...options }) {
|
|
204
|
+
const params = {
|
|
205
|
+
space: this.uri,
|
|
206
|
+
repo,
|
|
207
|
+
since,
|
|
208
|
+
cursor,
|
|
209
|
+
limit,
|
|
210
|
+
excludeValues,
|
|
211
|
+
};
|
|
212
|
+
return this.#verified(`Repo ${repo} commit failed verification`, async (kem) => {
|
|
213
|
+
const { response, mac } = await this.#withMac(repo, listRepoOps, COMMIT_MAC_PROFILE, { ...options, params }, kem);
|
|
214
|
+
verifyCommit(response.body.commit, { space: this.uri, repo, ...mac });
|
|
215
|
+
return response;
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Brings a known state of a repo up to date, from its operation log. Every
|
|
220
|
+
* operation is checked against the state (using `lookup` for the CIDs of the
|
|
221
|
+
* records it touches), and the resulting state against the repo's commit.
|
|
222
|
+
*
|
|
223
|
+
* @throws {RepoGapError} if the operation log cannot be applied to `head`
|
|
224
|
+
* @throws {SpaceRepoVerificationError} if the repo fails verification
|
|
225
|
+
*/
|
|
226
|
+
async syncRepo({ repo, head, lookup, signal, }) {
|
|
227
|
+
const repoCommit = RepoCommit.fromState(head.state);
|
|
228
|
+
const changes = new Map();
|
|
229
|
+
let commit;
|
|
230
|
+
let cursor;
|
|
231
|
+
let rev = head.rev;
|
|
232
|
+
do {
|
|
233
|
+
const { body } = await this.listRepoOps({
|
|
234
|
+
repo,
|
|
235
|
+
since: head.rev,
|
|
236
|
+
cursor,
|
|
237
|
+
signal,
|
|
238
|
+
});
|
|
239
|
+
for (const op of body.ops) {
|
|
240
|
+
// Operations sharing a revision were applied atomically.
|
|
241
|
+
if (op.rev <= head.rev || op.rev < rev) {
|
|
242
|
+
throw new RepoGapError(`Repo ${repo} operations are out of order`);
|
|
243
|
+
}
|
|
244
|
+
rev = op.rev;
|
|
245
|
+
const path = formatRecordPath(op.collection, op.rkey);
|
|
246
|
+
const change = changes.get(path);
|
|
247
|
+
const current = change
|
|
248
|
+
? change.cid
|
|
249
|
+
: ((await lookup(op.collection, op.rkey)) ?? null);
|
|
250
|
+
const prev = op.prev ? parseCid(op.prev) : null;
|
|
251
|
+
if (!cidEquals(prev, current)) {
|
|
252
|
+
throw new RepoGapError(`Repo ${repo} diverged at ${path}`);
|
|
253
|
+
}
|
|
254
|
+
const cid = op.cid ? parseCid(op.cid) : null;
|
|
255
|
+
if (op.value && !(cid && (await cidForLex(op.value)).equals(cid))) {
|
|
256
|
+
throw new SpaceRepoVerificationError(`Record ${path} failed verification`);
|
|
257
|
+
}
|
|
258
|
+
repoCommit.applyOp({
|
|
259
|
+
collection: op.collection,
|
|
260
|
+
rkey: op.rkey,
|
|
261
|
+
cid,
|
|
262
|
+
prev,
|
|
263
|
+
});
|
|
264
|
+
changes.set(path, {
|
|
265
|
+
collection: op.collection,
|
|
266
|
+
rkey: op.rkey,
|
|
267
|
+
cid,
|
|
268
|
+
prev: change ? change.prev : prev,
|
|
269
|
+
record: op.value,
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
// Every page carries the repo's current commit. The last page's is checked
|
|
273
|
+
// against the state once all the operations are applied.
|
|
274
|
+
commit = body.commit;
|
|
275
|
+
cursor = body.cursor;
|
|
276
|
+
} while (cursor);
|
|
277
|
+
if (!repoCommit.matches(commit)) {
|
|
278
|
+
throw new RepoGapError(`Repo ${repo} diverged from its commit`);
|
|
279
|
+
}
|
|
280
|
+
// A value is only listed with the last operation on its record.
|
|
281
|
+
for (const change of changes.values()) {
|
|
282
|
+
if (change.cid && !change.record) {
|
|
283
|
+
const { collection, rkey } = change;
|
|
284
|
+
const { body } = await this.getRecord(collection, rkey, {
|
|
285
|
+
repo,
|
|
286
|
+
signal,
|
|
287
|
+
});
|
|
288
|
+
if (!parseCid(body.cid).equals(change.cid)) {
|
|
289
|
+
throw new RepoGapError(`Repo ${repo} changed while syncing`);
|
|
290
|
+
}
|
|
291
|
+
change.record = body.value;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return {
|
|
295
|
+
commit,
|
|
296
|
+
head: { rev: commit.rev, state: repoCommit.setHash.state() },
|
|
297
|
+
// A record created then deleted since `head` did not change.
|
|
298
|
+
changes: [...changes.values()].filter((c) => c.cid || c.prev),
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Gets a repo in full, and the state needed to {@link syncRepo} it later.
|
|
303
|
+
*
|
|
304
|
+
* @throws {SpaceRepoVerificationError} if the repo fails verification
|
|
305
|
+
*/
|
|
306
|
+
async getRepoSnapshot({ repo, signal, }) {
|
|
307
|
+
const { commit, records } = await this.getRepo({ repo, signal });
|
|
308
|
+
const collected = [];
|
|
309
|
+
for await (const record of records)
|
|
310
|
+
collected.push(record);
|
|
311
|
+
const state = RepoCommit.fromRecords(collected).setHash.state();
|
|
312
|
+
return { commit, head: { rev: commit.rev, state }, records: collected };
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Brings a repo up to date: incrementally from its known state (`head` and
|
|
316
|
+
* `lookup`), and in full when there is none (e.g. on the first pull), or
|
|
317
|
+
* when the incremental sync fails. A repo its host does not have is pulled
|
|
318
|
+
* as an empty repo.
|
|
319
|
+
*/
|
|
320
|
+
async pullRepo({ repo, head, lookup, signal, }) {
|
|
321
|
+
if (head) {
|
|
322
|
+
try {
|
|
323
|
+
const changes = await this.syncRepo({ repo, head, lookup, signal });
|
|
324
|
+
return { type: 'changes', ...changes };
|
|
325
|
+
}
|
|
326
|
+
catch (err) {
|
|
327
|
+
if (isRepoNotFound(err))
|
|
328
|
+
return { type: 'empty' };
|
|
329
|
+
if (!(err instanceof RepoGapError) &&
|
|
330
|
+
!(err instanceof SpaceRepoVerificationError)) {
|
|
331
|
+
throw err;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
let snapshot;
|
|
336
|
+
try {
|
|
337
|
+
snapshot = await this.getRepoSnapshot({ repo, signal });
|
|
338
|
+
}
|
|
339
|
+
catch (err) {
|
|
340
|
+
if (isRepoNotFound(err))
|
|
341
|
+
return { type: 'empty' };
|
|
342
|
+
throw err;
|
|
343
|
+
}
|
|
344
|
+
if (head && snapshot.commit.rev < head.rev) {
|
|
345
|
+
throw new RepoGapError(`Repo ${repo} is older than its known state`);
|
|
346
|
+
}
|
|
347
|
+
return { type: 'snapshot', ...snapshot };
|
|
348
|
+
}
|
|
349
|
+
async *allRecords({ collections, validateRequest, concurrency = 4, signal, } = {}) {
|
|
350
|
+
const schemas = collections?.map(getMain);
|
|
351
|
+
if (schemas && validateRequest !== false) {
|
|
352
|
+
for (const { $type } of schemas)
|
|
353
|
+
this.assertCollection($type);
|
|
354
|
+
}
|
|
355
|
+
// A repo listed again was updated while listing: its last entry is current.
|
|
356
|
+
const writers = new Map();
|
|
357
|
+
for await (const entry of this.writers({ signal })) {
|
|
358
|
+
writers.set(entry.repo, entry);
|
|
359
|
+
}
|
|
360
|
+
const queue = [...writers.values()]
|
|
361
|
+
.filter((entry) => repoWrite.$isTypeOf(entry))
|
|
362
|
+
.map((entry) => entry.repo);
|
|
363
|
+
while (queue.length) {
|
|
364
|
+
const batch = queue.splice(0, concurrency);
|
|
365
|
+
const snapshots = await Promise.all(batch.map((repo) => this.getRepoSnapshot({ repo, signal }).catch((err) => {
|
|
366
|
+
if (err instanceof XrpcResponseError) {
|
|
367
|
+
switch (err.error) {
|
|
368
|
+
// Errors meaning that a member's repo holds no readable data.
|
|
369
|
+
case 'RepoNotFound':
|
|
370
|
+
case 'RepoTakendown':
|
|
371
|
+
case 'RepoSuspended':
|
|
372
|
+
case 'RepoDeactivated':
|
|
373
|
+
return undefined;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
throw err;
|
|
377
|
+
})));
|
|
378
|
+
for (const [i, snapshot] of snapshots.entries()) {
|
|
379
|
+
for (const record of snapshot?.records ?? []) {
|
|
380
|
+
const item = { ...record, repo: batch[i] };
|
|
381
|
+
if (!schemas) {
|
|
382
|
+
yield this.isCollection(record.collection)
|
|
383
|
+
? { ...item, valid: true }
|
|
384
|
+
: { ...item, valid: false };
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
const schema = schemas.find((s) => s.$type === record.collection);
|
|
388
|
+
if (!schema)
|
|
389
|
+
continue;
|
|
390
|
+
const result = schema.safeValidate(record.record);
|
|
391
|
+
yield result.success
|
|
392
|
+
? { ...item, valid: true, record: result.value }
|
|
393
|
+
: { ...item, valid: false };
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
/** Whether `collection` is one of the collections declared by the space type. */
|
|
399
|
+
isCollection(collection) {
|
|
400
|
+
return this.schema.collections.includes(collection);
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* @throws {TypeError} if `collection` is not one of the collections declared
|
|
404
|
+
* by the space type
|
|
405
|
+
*/
|
|
406
|
+
assertCollection(collection) {
|
|
407
|
+
if (!this.isCollection(collection)) {
|
|
408
|
+
throw new TypeError(`${collection} is not a collection of ${this.schema.nsid} spaces`);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Gets a blob, verified against its CID.
|
|
413
|
+
*
|
|
414
|
+
* @throws {SpaceRepoVerificationError} if the blob fails verification
|
|
415
|
+
*/
|
|
416
|
+
async getBlob({ repo, cid: cidInput, ...options }) {
|
|
417
|
+
const cid = typeof cidInput === 'string' ? parseCid(cidInput) : cidInput;
|
|
418
|
+
if (!checkCid(cid, { flavor: 'raw' })) {
|
|
419
|
+
throw new TypeError(`${cid} is not a raw CID`);
|
|
420
|
+
}
|
|
421
|
+
// @TODO Stream the blob, once lex-client can stream response bodies
|
|
422
|
+
const response = await this.repoXrpc(repo, getBlob, {
|
|
423
|
+
...options,
|
|
424
|
+
params: { space: this.uri, repo, cid: cid.toString() },
|
|
425
|
+
});
|
|
426
|
+
if (!(await isCidForBytes(cid, response.body))) {
|
|
427
|
+
throw new SpaceRepoVerificationError(`Blob ${cid} failed verification`);
|
|
428
|
+
}
|
|
429
|
+
return response;
|
|
430
|
+
}
|
|
431
|
+
/** Lists the CIDs of the blobs referenced by a repo's records. */
|
|
432
|
+
async listBlobs({ repo, cursor, limit, ...options }) {
|
|
433
|
+
return this.repoXrpc(repo, listBlobs, {
|
|
434
|
+
...options,
|
|
435
|
+
params: { space: this.uri, repo, cursor, limit },
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Makes a request to the space host (the authority's PDS), with the space
|
|
440
|
+
* credential presented to the space authority.
|
|
441
|
+
*/
|
|
442
|
+
async authorityXrpc(ns, options) {
|
|
443
|
+
return this.credentialXrpc(this.ref.spaceDid, ns, options);
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Makes a request to the host (PDS) of a repo in the space, with the space
|
|
447
|
+
* credential presented to the repo's account.
|
|
448
|
+
*/
|
|
449
|
+
async repoXrpc(repo, ns, options) {
|
|
450
|
+
return this.credentialXrpc(repo, ns, options);
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Makes a request with the space credential, presented to `audience` (whose
|
|
454
|
+
* PDS receives the request).
|
|
455
|
+
*/
|
|
456
|
+
async credentialXrpc(audience, ns, options) {
|
|
457
|
+
const agent = await this.buildCredentialXrpcAgent(audience, options);
|
|
458
|
+
try {
|
|
459
|
+
return await xrpc(agent, ns, options);
|
|
460
|
+
}
|
|
461
|
+
catch (err) {
|
|
462
|
+
if (!('renew' in options && options.renew) &&
|
|
463
|
+
!options.signal?.aborted &&
|
|
464
|
+
err instanceof XrpcAuthenticationError) {
|
|
465
|
+
// Retry with a new credential
|
|
466
|
+
const agent = await this.buildCredentialXrpcAgent(audience, {
|
|
467
|
+
signal: options.signal,
|
|
468
|
+
renew: true,
|
|
469
|
+
});
|
|
470
|
+
return xrpc(agent, ns, options);
|
|
471
|
+
}
|
|
472
|
+
throw err;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
async buildCredentialXrpcAgent(audience, { signal, renew } = {}) {
|
|
476
|
+
// Did resolution first, to avoid unnecessary credential requests if the
|
|
477
|
+
// audience's PDS cannot be resolved.
|
|
478
|
+
const service = await this.#resolver
|
|
479
|
+
.resolve(audience, { signal, noCache: renew })
|
|
480
|
+
.then(extractPdsUrl);
|
|
481
|
+
signal?.throwIfAborted?.();
|
|
482
|
+
const credential = await this.authorize({ signal, renew });
|
|
483
|
+
signal?.throwIfAborted?.();
|
|
484
|
+
const headers = await credential.headers(audience);
|
|
485
|
+
return buildAgent({ service, headers, fetch: this.#fetch });
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Obtains the space credential (or a new one, with `renew`). The credential
|
|
489
|
+
* is otherwise obtained on first use: call this to check, early, that the
|
|
490
|
+
* space grants access.
|
|
491
|
+
*
|
|
492
|
+
* @throws {XrpcResponseError} if the credential cannot be obtained, e.g.
|
|
493
|
+
* `SpaceNotFound` (not granted access), `AppNotAuthorized` or `SpaceDeleted`
|
|
494
|
+
*/
|
|
495
|
+
async authorize(options) {
|
|
496
|
+
return this.#credentialProvider.getCredential(this.ref, options);
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Makes a request to a member's PDS asking for a MAC (with `Accept-Signature`),
|
|
500
|
+
* using a new key share (derived from the member's `#atproto_kem` key) for
|
|
501
|
+
* every attempt, retries included. Returns what the response's MAC is
|
|
502
|
+
* verified with.
|
|
503
|
+
*/
|
|
504
|
+
async #withMac(repo, ns, profile, options, refreshKemKey) {
|
|
505
|
+
const kemKey = await this.#resolveKemKey(repo, options.signal, refreshKemKey);
|
|
506
|
+
const { headers: headersInit } = options;
|
|
507
|
+
let encapsulation;
|
|
508
|
+
const response = await this.repoXrpc(repo, ns, {
|
|
509
|
+
...options,
|
|
510
|
+
// The encapsulated key can only be used once, even on retries, so we
|
|
511
|
+
// generate a new one for each request.
|
|
512
|
+
headers: async () => {
|
|
513
|
+
options.signal?.throwIfAborted?.();
|
|
514
|
+
const headers = new Headers(typeof headersInit === 'function' ? await headersInit() : headersInit);
|
|
515
|
+
options.signal?.throwIfAborted?.();
|
|
516
|
+
encapsulation = await encapsulate(kemKey);
|
|
517
|
+
options.signal?.throwIfAborted?.();
|
|
518
|
+
headers.set('accept-signature', formatMacRequest(profile, encapsulation.keyShare));
|
|
519
|
+
return headers;
|
|
520
|
+
},
|
|
521
|
+
});
|
|
522
|
+
// A missing MAC fails verification, like an invalid one.
|
|
523
|
+
return { response, mac: { ...encapsulation, headers: response.headers } };
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Resolves the `#atproto_kem` key of a repo's account. A DID document without
|
|
527
|
+
* one is resolved again, as the key may have been added since it was cached.
|
|
528
|
+
*/
|
|
529
|
+
async #resolveKemKey(repo, signal, noCache) {
|
|
530
|
+
const didDocument = await this.#resolver.resolve(repo, { signal, noCache });
|
|
531
|
+
try {
|
|
532
|
+
return formatDidVerificationMethod(extractKemKey(didDocument));
|
|
533
|
+
}
|
|
534
|
+
catch (err) {
|
|
535
|
+
if (noCache)
|
|
536
|
+
throw err;
|
|
537
|
+
return this.#resolveKemKey(repo, signal, true);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Retries a verification once, with the author's KEM key re-resolved, as it
|
|
542
|
+
* may have been rotated since it was cached.
|
|
543
|
+
*
|
|
544
|
+
* @throws {SpaceRepoVerificationError} if both attempts fail verification
|
|
545
|
+
*/
|
|
546
|
+
async #verified(message, attempt) {
|
|
547
|
+
try {
|
|
548
|
+
return await attempt(false);
|
|
549
|
+
}
|
|
550
|
+
catch (err) {
|
|
551
|
+
if (!isVerificationError(err))
|
|
552
|
+
throw err;
|
|
553
|
+
}
|
|
554
|
+
try {
|
|
555
|
+
return await attempt(true);
|
|
556
|
+
}
|
|
557
|
+
catch (err) {
|
|
558
|
+
if (!isVerificationError(err))
|
|
559
|
+
throw err;
|
|
560
|
+
throw new SpaceRepoVerificationError(message, { cause: err });
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
function isRepoNotFound(err) {
|
|
565
|
+
return err instanceof XrpcResponseError && err.error === 'RepoNotFound';
|
|
566
|
+
}
|
|
567
|
+
function isVerificationError(err) {
|
|
568
|
+
return (err instanceof SpaceMacError || err instanceof SpaceRepoVerificationError);
|
|
569
|
+
}
|
|
570
|
+
function cidEquals(a, b) {
|
|
571
|
+
return a === null || b === null ? a === b : a.equals(b);
|
|
572
|
+
}
|
|
573
|
+
//# sourceMappingURL=space-reader.js.map
|