@weaveprotocol/core 0.1.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/README.md +1106 -0
- package/dist/elements/auth-styles.d.ts +18 -0
- package/dist/elements/auth-styles.d.ts.map +1 -0
- package/dist/elements/auth-styles.js +150 -0
- package/dist/elements/auth-styles.js.map +1 -0
- package/dist/elements/dom.d.ts +28 -0
- package/dist/elements/dom.d.ts.map +1 -0
- package/dist/elements/dom.js +74 -0
- package/dist/elements/dom.js.map +1 -0
- package/dist/elements/index.d.ts +13 -0
- package/dist/elements/index.d.ts.map +1 -0
- package/dist/elements/index.js +11 -0
- package/dist/elements/index.js.map +1 -0
- package/dist/elements/weave-auth.d.ts +52 -0
- package/dist/elements/weave-auth.d.ts.map +1 -0
- package/dist/elements/weave-auth.js +427 -0
- package/dist/elements/weave-auth.js.map +1 -0
- package/dist/identity/account-store.d.ts +113 -0
- package/dist/identity/account-store.d.ts.map +1 -0
- package/dist/identity/account-store.js +305 -0
- package/dist/identity/account-store.js.map +1 -0
- package/dist/identity/account-vault.d.ts +199 -0
- package/dist/identity/account-vault.d.ts.map +1 -0
- package/dist/identity/account-vault.js +251 -0
- package/dist/identity/account-vault.js.map +1 -0
- package/dist/identity/agent-note.d.ts +19 -0
- package/dist/identity/agent-note.d.ts.map +1 -0
- package/dist/identity/agent-note.js +29 -0
- package/dist/identity/agent-note.js.map +1 -0
- package/dist/identity/crypto-p256.d.ts +7 -0
- package/dist/identity/crypto-p256.d.ts.map +1 -0
- package/dist/identity/crypto-p256.js +84 -0
- package/dist/identity/crypto-p256.js.map +1 -0
- package/dist/identity/device-key.d.ts +60 -0
- package/dist/identity/device-key.d.ts.map +1 -0
- package/dist/identity/device-key.js +103 -0
- package/dist/identity/device-key.js.map +1 -0
- package/dist/identity/did.d.ts +22 -0
- package/dist/identity/did.d.ts.map +1 -0
- package/dist/identity/did.js +37 -0
- package/dist/identity/did.js.map +1 -0
- package/dist/identity/folder-account.d.ts +65 -0
- package/dist/identity/folder-account.d.ts.map +1 -0
- package/dist/identity/folder-account.js +115 -0
- package/dist/identity/folder-account.js.map +1 -0
- package/dist/identity/identity-manager.d.ts +36 -0
- package/dist/identity/identity-manager.d.ts.map +1 -0
- package/dist/identity/identity-manager.js +115 -0
- package/dist/identity/identity-manager.js.map +1 -0
- package/dist/identity/index.d.ts +10 -0
- package/dist/identity/index.d.ts.map +1 -0
- package/dist/identity/index.js +10 -0
- package/dist/identity/index.js.map +1 -0
- package/dist/identity/keys.d.ts +24 -0
- package/dist/identity/keys.d.ts.map +1 -0
- package/dist/identity/keys.js +38 -0
- package/dist/identity/keys.js.map +1 -0
- package/dist/identity/pairing.d.ts +83 -0
- package/dist/identity/pairing.d.ts.map +1 -0
- package/dist/identity/pairing.js +120 -0
- package/dist/identity/pairing.js.map +1 -0
- package/dist/identity/passkey-diagnostics.d.ts +54 -0
- package/dist/identity/passkey-diagnostics.d.ts.map +1 -0
- package/dist/identity/passkey-diagnostics.js +178 -0
- package/dist/identity/passkey-diagnostics.js.map +1 -0
- package/dist/identity/recovery-code.d.ts +50 -0
- package/dist/identity/recovery-code.d.ts.map +1 -0
- package/dist/identity/recovery-code.js +116 -0
- package/dist/identity/recovery-code.js.map +1 -0
- package/dist/identity/root-signer.d.ts +59 -0
- package/dist/identity/root-signer.d.ts.map +1 -0
- package/dist/identity/root-signer.js +44 -0
- package/dist/identity/root-signer.js.map +1 -0
- package/dist/identity/ucan.d.ts +164 -0
- package/dist/identity/ucan.d.ts.map +1 -0
- package/dist/identity/ucan.js +273 -0
- package/dist/identity/ucan.js.map +1 -0
- package/dist/identity/webauthn.d.ts +87 -0
- package/dist/identity/webauthn.d.ts.map +1 -0
- package/dist/identity/webauthn.js +155 -0
- package/dist/identity/webauthn.js.map +1 -0
- package/dist/index.d.ts +116 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +85 -0
- package/dist/index.js.map +1 -0
- package/dist/network/index.d.ts +17 -0
- package/dist/network/index.d.ts.map +1 -0
- package/dist/network/index.js +10 -0
- package/dist/network/index.js.map +1 -0
- package/dist/network/introductions.d.ts +85 -0
- package/dist/network/introductions.d.ts.map +1 -0
- package/dist/network/introductions.js +94 -0
- package/dist/network/introductions.js.map +1 -0
- package/dist/network/local-transport.d.ts +22 -0
- package/dist/network/local-transport.d.ts.map +1 -0
- package/dist/network/local-transport.js +55 -0
- package/dist/network/local-transport.js.map +1 -0
- package/dist/network/mesh.d.ts +31 -0
- package/dist/network/mesh.d.ts.map +1 -0
- package/dist/network/mesh.js +332 -0
- package/dist/network/mesh.js.map +1 -0
- package/dist/network/multi-signaling.d.ts +29 -0
- package/dist/network/multi-signaling.d.ts.map +1 -0
- package/dist/network/multi-signaling.js +125 -0
- package/dist/network/multi-signaling.js.map +1 -0
- package/dist/network/network-manager.d.ts +37 -0
- package/dist/network/network-manager.d.ts.map +1 -0
- package/dist/network/network-manager.js +64 -0
- package/dist/network/network-manager.js.map +1 -0
- package/dist/network/peer-auth.d.ts +98 -0
- package/dist/network/peer-auth.d.ts.map +1 -0
- package/dist/network/peer-auth.js +86 -0
- package/dist/network/peer-auth.js.map +1 -0
- package/dist/network/rtc-transport.d.ts +18 -0
- package/dist/network/rtc-transport.d.ts.map +1 -0
- package/dist/network/rtc-transport.js +149 -0
- package/dist/network/rtc-transport.js.map +1 -0
- package/dist/network/signaling.d.ts +40 -0
- package/dist/network/signaling.d.ts.map +1 -0
- package/dist/network/signaling.js +124 -0
- package/dist/network/signaling.js.map +1 -0
- package/dist/network/transport.d.ts +50 -0
- package/dist/network/transport.d.ts.map +1 -0
- package/dist/network/transport.js +13 -0
- package/dist/network/transport.js.map +1 -0
- package/dist/network/ws-transport.d.ts +42 -0
- package/dist/network/ws-transport.d.ts.map +1 -0
- package/dist/network/ws-transport.js +194 -0
- package/dist/network/ws-transport.js.map +1 -0
- package/dist/node/actions.d.ts +62 -0
- package/dist/node/actions.d.ts.map +1 -0
- package/dist/node/actions.js +500 -0
- package/dist/node/actions.js.map +1 -0
- package/dist/node/carrier.d.ts +85 -0
- package/dist/node/carrier.d.ts.map +1 -0
- package/dist/node/carrier.js +192 -0
- package/dist/node/carrier.js.map +1 -0
- package/dist/node/copy.d.ts +38 -0
- package/dist/node/copy.d.ts.map +1 -0
- package/dist/node/copy.js +53 -0
- package/dist/node/copy.js.map +1 -0
- package/dist/node/index.d.ts +16 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +11 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/node.d.ts +12 -0
- package/dist/node/node.d.ts.map +1 -0
- package/dist/node/node.js +872 -0
- package/dist/node/node.js.map +1 -0
- package/dist/node/space-runtime.d.ts +144 -0
- package/dist/node/space-runtime.d.ts.map +1 -0
- package/dist/node/space-runtime.js +1221 -0
- package/dist/node/space-runtime.js.map +1 -0
- package/dist/node/stores.d.ts +45 -0
- package/dist/node/stores.d.ts.map +1 -0
- package/dist/node/stores.js +31 -0
- package/dist/node/stores.js.map +1 -0
- package/dist/node/types.d.ts +508 -0
- package/dist/node/types.d.ts.map +1 -0
- package/dist/node/types.js +2 -0
- package/dist/node/types.js.map +1 -0
- package/dist/privacy/index.d.ts +4 -0
- package/dist/privacy/index.d.ts.map +1 -0
- package/dist/privacy/index.js +4 -0
- package/dist/privacy/index.js.map +1 -0
- package/dist/privacy/key-distribution.d.ts +42 -0
- package/dist/privacy/key-distribution.d.ts.map +1 -0
- package/dist/privacy/key-distribution.js +50 -0
- package/dist/privacy/key-distribution.js.map +1 -0
- package/dist/privacy/privacy-guard.d.ts +24 -0
- package/dist/privacy/privacy-guard.d.ts.map +1 -0
- package/dist/privacy/privacy-guard.js +87 -0
- package/dist/privacy/privacy-guard.js.map +1 -0
- package/dist/privacy/space-encryption.d.ts +48 -0
- package/dist/privacy/space-encryption.d.ts.map +1 -0
- package/dist/privacy/space-encryption.js +61 -0
- package/dist/privacy/space-encryption.js.map +1 -0
- package/dist/query/engine.d.ts +27 -0
- package/dist/query/engine.d.ts.map +1 -0
- package/dist/query/engine.js +84 -0
- package/dist/query/engine.js.map +1 -0
- package/dist/query/filter.d.ts +15 -0
- package/dist/query/filter.d.ts.map +1 -0
- package/dist/query/filter.js +207 -0
- package/dist/query/filter.js.map +1 -0
- package/dist/query/types.d.ts +144 -0
- package/dist/query/types.d.ts.map +1 -0
- package/dist/query/types.js +22 -0
- package/dist/query/types.js.map +1 -0
- package/dist/react/context.d.ts +81 -0
- package/dist/react/context.d.ts.map +1 -0
- package/dist/react/context.js +95 -0
- package/dist/react/context.js.map +1 -0
- package/dist/react/index.d.ts +40 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +36 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/use-live.d.ts +16 -0
- package/dist/react/use-live.d.ts.map +1 -0
- package/dist/react/use-live.js +55 -0
- package/dist/react/use-live.js.map +1 -0
- package/dist/react/use-query.d.ts +17 -0
- package/dist/react/use-query.d.ts.map +1 -0
- package/dist/react/use-query.js +23 -0
- package/dist/react/use-query.js.map +1 -0
- package/dist/react/use-space.d.ts +29 -0
- package/dist/react/use-space.d.ts.map +1 -0
- package/dist/react/use-space.js +48 -0
- package/dist/react/use-space.js.map +1 -0
- package/dist/react/use-spaces.d.ts +19 -0
- package/dist/react/use-spaces.d.ts.map +1 -0
- package/dist/react/use-spaces.js +55 -0
- package/dist/react/use-spaces.js.map +1 -0
- package/dist/react/use-weave-auth.d.ts +10 -0
- package/dist/react/use-weave-auth.d.ts.map +1 -0
- package/dist/react/use-weave-auth.js +15 -0
- package/dist/react/use-weave-auth.js.map +1 -0
- package/dist/react/weave-auth.d.ts +17 -0
- package/dist/react/weave-auth.d.ts.map +1 -0
- package/dist/react/weave-auth.js +38 -0
- package/dist/react/weave-auth.js.map +1 -0
- package/dist/records/describe.d.ts +38 -0
- package/dist/records/describe.d.ts.map +1 -0
- package/dist/records/describe.js +101 -0
- package/dist/records/describe.js.map +1 -0
- package/dist/records/links.d.ts +14 -0
- package/dist/records/links.d.ts.map +1 -0
- package/dist/records/links.js +25 -0
- package/dist/records/links.js.map +1 -0
- package/dist/records/rules.d.ts +59 -0
- package/dist/records/rules.d.ts.map +1 -0
- package/dist/records/rules.js +118 -0
- package/dist/records/rules.js.map +1 -0
- package/dist/records/version.d.ts +54 -0
- package/dist/records/version.d.ts.map +1 -0
- package/dist/records/version.js +70 -0
- package/dist/records/version.js.map +1 -0
- package/dist/schema/collection-def.d.ts +96 -0
- package/dist/schema/collection-def.d.ts.map +1 -0
- package/dist/schema/collection-def.js +272 -0
- package/dist/schema/collection-def.js.map +1 -0
- package/dist/schema/expression.d.ts +69 -0
- package/dist/schema/expression.d.ts.map +1 -0
- package/dist/schema/expression.js +92 -0
- package/dist/schema/expression.js.map +1 -0
- package/dist/schema/index.d.ts +4 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +4 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/schema-engine.d.ts +42 -0
- package/dist/schema/schema-engine.d.ts.map +1 -0
- package/dist/schema/schema-engine.js +36 -0
- package/dist/schema/schema-engine.js.map +1 -0
- package/dist/schema/signer.d.ts +27 -0
- package/dist/schema/signer.d.ts.map +1 -0
- package/dist/schema/signer.js +36 -0
- package/dist/schema/signer.js.map +1 -0
- package/dist/schemas/apps.d.ts +88 -0
- package/dist/schemas/apps.d.ts.map +1 -0
- package/dist/schemas/apps.js +168 -0
- package/dist/schemas/apps.js.map +1 -0
- package/dist/schemas/index.d.ts +410 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +208 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/screens.d.ts +67 -0
- package/dist/schemas/screens.d.ts.map +1 -0
- package/dist/schemas/screens.js +242 -0
- package/dist/schemas/screens.js.map +1 -0
- package/dist/session/agent-link.d.ts +79 -0
- package/dist/session/agent-link.d.ts.map +1 -0
- package/dist/session/agent-link.js +251 -0
- package/dist/session/agent-link.js.map +1 -0
- package/dist/session/auth.d.ts +233 -0
- package/dist/session/auth.d.ts.map +1 -0
- package/dist/session/auth.js +783 -0
- package/dist/session/auth.js.map +1 -0
- package/dist/session/connect.d.ts +211 -0
- package/dist/session/connect.d.ts.map +1 -0
- package/dist/session/connect.js +355 -0
- package/dist/session/connect.js.map +1 -0
- package/dist/session/connection.d.ts +70 -0
- package/dist/session/connection.d.ts.map +1 -0
- package/dist/session/connection.js +120 -0
- package/dist/session/connection.js.map +1 -0
- package/dist/session/credentials.d.ts +44 -0
- package/dist/session/credentials.d.ts.map +1 -0
- package/dist/session/credentials.js +60 -0
- package/dist/session/credentials.js.map +1 -0
- package/dist/session/index.d.ts +25 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +18 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/pairing.d.ts +59 -0
- package/dist/session/pairing.d.ts.map +1 -0
- package/dist/session/pairing.js +144 -0
- package/dist/session/pairing.js.map +1 -0
- package/dist/session/places.d.ts +62 -0
- package/dist/session/places.d.ts.map +1 -0
- package/dist/session/places.js +101 -0
- package/dist/session/places.js.map +1 -0
- package/dist/session/stay-signed-in.d.ts +37 -0
- package/dist/session/stay-signed-in.d.ts.map +1 -0
- package/dist/session/stay-signed-in.js +124 -0
- package/dist/session/stay-signed-in.js.map +1 -0
- package/dist/space/account-registry.d.ts +64 -0
- package/dist/space/account-registry.d.ts.map +1 -0
- package/dist/space/account-registry.js +66 -0
- package/dist/space/account-registry.js.map +1 -0
- package/dist/space/index.d.ts +3 -0
- package/dist/space/index.d.ts.map +1 -0
- package/dist/space/index.js +3 -0
- package/dist/space/index.js.map +1 -0
- package/dist/space/pass.d.ts +63 -0
- package/dist/space/pass.d.ts.map +1 -0
- package/dist/space/pass.js +54 -0
- package/dist/space/pass.js.map +1 -0
- package/dist/space/presets.d.ts +31 -0
- package/dist/space/presets.d.ts.map +1 -0
- package/dist/space/presets.js +24 -0
- package/dist/space/presets.js.map +1 -0
- package/dist/space/roles.d.ts +186 -0
- package/dist/space/roles.d.ts.map +1 -0
- package/dist/space/roles.js +500 -0
- package/dist/space/roles.js.map +1 -0
- package/dist/space/space-access.d.ts +80 -0
- package/dist/space/space-access.d.ts.map +1 -0
- package/dist/space/space-access.js +135 -0
- package/dist/space/space-access.js.map +1 -0
- package/dist/space/space-manager.d.ts +87 -0
- package/dist/space/space-manager.d.ts.map +1 -0
- package/dist/space/space-manager.js +187 -0
- package/dist/space/space-manager.js.map +1 -0
- package/dist/storage/directory-access.d.ts +78 -0
- package/dist/storage/directory-access.d.ts.map +1 -0
- package/dist/storage/directory-access.js +164 -0
- package/dist/storage/directory-access.js.map +1 -0
- package/dist/storage/encrypted-adapter.d.ts +49 -0
- package/dist/storage/encrypted-adapter.d.ts.map +1 -0
- package/dist/storage/encrypted-adapter.js +106 -0
- package/dist/storage/encrypted-adapter.js.map +1 -0
- package/dist/storage/folder-adapter.d.ts +105 -0
- package/dist/storage/folder-adapter.d.ts.map +1 -0
- package/dist/storage/folder-adapter.js +280 -0
- package/dist/storage/folder-adapter.js.map +1 -0
- package/dist/storage/folder-reconcile.d.ts +53 -0
- package/dist/storage/folder-reconcile.d.ts.map +1 -0
- package/dist/storage/folder-reconcile.js +65 -0
- package/dist/storage/folder-reconcile.js.map +1 -0
- package/dist/storage/index.d.ts +10 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +9 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/indexeddb-adapter.d.ts +12 -0
- package/dist/storage/indexeddb-adapter.d.ts.map +1 -0
- package/dist/storage/indexeddb-adapter.js +190 -0
- package/dist/storage/indexeddb-adapter.js.map +1 -0
- package/dist/storage/mst.d.ts +121 -0
- package/dist/storage/mst.d.ts.map +1 -0
- package/dist/storage/mst.js +402 -0
- package/dist/storage/mst.js.map +1 -0
- package/dist/storage/storage-provider.d.ts +85 -0
- package/dist/storage/storage-provider.d.ts.map +1 -0
- package/dist/storage/storage-provider.js +220 -0
- package/dist/storage/storage-provider.js.map +1 -0
- package/dist/sync/anti-entropy.d.ts +49 -0
- package/dist/sync/anti-entropy.d.ts.map +1 -0
- package/dist/sync/anti-entropy.js +62 -0
- package/dist/sync/anti-entropy.js.map +1 -0
- package/dist/sync/index.d.ts +4 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +4 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/sync-engine.d.ts +71 -0
- package/dist/sync/sync-engine.d.ts.map +1 -0
- package/dist/sync/sync-engine.js +309 -0
- package/dist/sync/sync-engine.js.map +1 -0
- package/dist/sync/sync-messages.d.ts +75 -0
- package/dist/sync/sync-messages.d.ts.map +1 -0
- package/dist/sync/sync-messages.js +12 -0
- package/dist/sync/sync-messages.js.map +1 -0
- package/dist/types.d.ts +243 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/encoding.d.ts +63 -0
- package/dist/utils/encoding.d.ts.map +1 -0
- package/dist/utils/encoding.js +130 -0
- package/dist/utils/encoding.js.map +1 -0
- package/dist/utils/errors.d.ts +43 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +28 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/events.d.ts +19 -0
- package/dist/utils/events.d.ts.map +1 -0
- package/dist/utils/events.js +27 -0
- package/dist/utils/events.js.map +1 -0
- package/dist/utils/hash.d.ts +23 -0
- package/dist/utils/hash.d.ts.map +1 -0
- package/dist/utils/hash.js +49 -0
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +9 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/validation/capability-gate.d.ts +50 -0
- package/dist/validation/capability-gate.d.ts.map +1 -0
- package/dist/validation/capability-gate.js +71 -0
- package/dist/validation/capability-gate.js.map +1 -0
- package/dist/validation/crypto-gate.d.ts +16 -0
- package/dist/validation/crypto-gate.d.ts.map +1 -0
- package/dist/validation/crypto-gate.js +37 -0
- package/dist/validation/crypto-gate.js.map +1 -0
- package/dist/validation/index.d.ts +6 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +6 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/stateful-gate.d.ts +15 -0
- package/dist/validation/stateful-gate.d.ts.map +1 -0
- package/dist/validation/stateful-gate.js +50 -0
- package/dist/validation/stateful-gate.js.map +1 -0
- package/dist/validation/structural-gate.d.ts +18 -0
- package/dist/validation/structural-gate.d.ts.map +1 -0
- package/dist/validation/structural-gate.js +54 -0
- package/dist/validation/structural-gate.js.map +1 -0
- package/dist/validation/validation-engine.d.ts +28 -0
- package/dist/validation/validation-engine.d.ts.map +1 -0
- package/dist/validation/validation-engine.js +38 -0
- package/dist/validation/validation-engine.js.map +1 -0
- package/package.json +107 -0
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module node/types
|
|
3
|
+
* The shape of a node: everything an app, a CLI, a daemon or an agent needs to
|
|
4
|
+
* work with spaces, as plain data in and plain data out.
|
|
5
|
+
*
|
|
6
|
+
* Everything a method returns is JSON-serialisable on purpose. The same calls
|
|
7
|
+
* are exposed as actions to a command line, an MCP server and WebMCP, and a
|
|
8
|
+
* value that cannot cross a wire would have to be reshaped at each of them.
|
|
9
|
+
*/
|
|
10
|
+
import type { BodyOf, Query, ResultOf } from '../query/types.js';
|
|
11
|
+
import type { CollectionRules } from '../records/rules.js';
|
|
12
|
+
import type { CollectionDef, CryptoProvider, Link, SpaceRole, SpaceVisibility, StandardJSONSchemaV1 } from '../types.js';
|
|
13
|
+
import type { LinkDeclaration } from '../records/links.js';
|
|
14
|
+
import type { RootSigner } from '../identity/root-signer.js';
|
|
15
|
+
import type { Capability, UCANToken } from '../identity/ucan.js';
|
|
16
|
+
import type { PeerTransport } from '../network/transport.js';
|
|
17
|
+
import type { ServerAuth } from '../network/peer-auth.js';
|
|
18
|
+
import type { StoreFactory } from './stores.js';
|
|
19
|
+
import type { JsonSchema, SchemaIssue } from '../schema/collection-def.js';
|
|
20
|
+
export interface NodeNetworkConfig {
|
|
21
|
+
/** Relays for WebRTC, browsers only. Each space meets in the room named after its id. */
|
|
22
|
+
readonly relays?: ReadonlyArray<string>;
|
|
23
|
+
/** Always-on nodes to hold a socket to, `ws(s)://host/peer`. The space id is appended. */
|
|
24
|
+
readonly nodes?: ReadonlyArray<string>;
|
|
25
|
+
readonly iceServers?: ReadonlyArray<RTCIceServer>;
|
|
26
|
+
/**
|
|
27
|
+
* Extra transports per space — how a node serving sockets, or a test, plugs
|
|
28
|
+
* in. Given the space and this node's session DID, which is its identity on
|
|
29
|
+
* the wire.
|
|
30
|
+
*/
|
|
31
|
+
readonly transports?: (spaceId: string, sessionDid: string) => ReadonlyArray<PeerTransport>;
|
|
32
|
+
}
|
|
33
|
+
export interface NodeConfig {
|
|
34
|
+
/** Who this node acts for. The root key only ever signs session delegations. */
|
|
35
|
+
readonly signer: RootSigner;
|
|
36
|
+
/**
|
|
37
|
+
* The account's vault key bytes (`deriveVaultKeyBytes(seed)`). With it, the node keeps the account's space list in the
|
|
38
|
+
* account registry space: spaces joined on any device or node of the account
|
|
39
|
+
* are joined here too, and leaving one leaves it everywhere. Without it,
|
|
40
|
+
* spaces are this node's alone.
|
|
41
|
+
*/
|
|
42
|
+
readonly accountKey?: Uint8Array;
|
|
43
|
+
/** Where the registry and each space's store live */
|
|
44
|
+
readonly stores: StoreFactory;
|
|
45
|
+
readonly provider?: CryptoProvider;
|
|
46
|
+
/**
|
|
47
|
+
* Collections this node knows the shape of, for when a space does not
|
|
48
|
+
* describe them itself. Records are checked against them when written here
|
|
49
|
+
* and flagged (`conforms`) when read. Nothing is refused on arrival for its
|
|
50
|
+
* shape: sync accepts whatever is signed and authorized, so nodes with
|
|
51
|
+
* different schemas still converge.
|
|
52
|
+
*/
|
|
53
|
+
readonly collections?: ReadonlyArray<CollectionDef>;
|
|
54
|
+
/** Omit to stay offline */
|
|
55
|
+
readonly network?: NodeNetworkConfig;
|
|
56
|
+
/** How long each session delegation lasts. Renewed before it runs out. Default 3600. */
|
|
57
|
+
readonly sessionTtlSeconds?: number;
|
|
58
|
+
/**
|
|
59
|
+
* The key this node signs with, when it must be one the signer already
|
|
60
|
+
* knows — an app given a delegation by an account home, which named the
|
|
61
|
+
* app's key. By default the node makes a fresh one each time it starts.
|
|
62
|
+
*/
|
|
63
|
+
readonly sessionKey?: CryptoKeyPair;
|
|
64
|
+
/** How often to look for writes another process made to a folder store. 0 disables. Default 2000. */
|
|
65
|
+
readonly watchIntervalMs?: number;
|
|
66
|
+
}
|
|
67
|
+
/** A space, as the node describes it. Never carries the key. */
|
|
68
|
+
export interface SpaceSummary {
|
|
69
|
+
readonly id: string;
|
|
70
|
+
readonly name: string;
|
|
71
|
+
readonly visibility: SpaceVisibility;
|
|
72
|
+
/** The account that made it */
|
|
73
|
+
readonly creator: string;
|
|
74
|
+
readonly createdAt: string;
|
|
75
|
+
/** Whether this node can read the space: always for public ones, only with the key for private */
|
|
76
|
+
readonly readable: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Whether this node's account holds a role here, and so may write — as far
|
|
79
|
+
* as this node last heard. A view-only invite, or being removed, means it
|
|
80
|
+
* follows the space and reads.
|
|
81
|
+
*/
|
|
82
|
+
readonly writable: boolean;
|
|
83
|
+
/** The role this account holds here, by name — null when it holds none */
|
|
84
|
+
readonly role: string | null;
|
|
85
|
+
/** Whether an invite is waiting to be used — its record has not reached this device yet */
|
|
86
|
+
readonly joining: boolean;
|
|
87
|
+
}
|
|
88
|
+
export interface NewSpace {
|
|
89
|
+
readonly name: string;
|
|
90
|
+
/** `private` encrypts every body with the space key */
|
|
91
|
+
readonly visibility: SpaceVisibility;
|
|
92
|
+
/**
|
|
93
|
+
* The roles it starts with. Default: the creator alone, holding everything.
|
|
94
|
+
* `rolePresets` has some to start from — or write your own.
|
|
95
|
+
*/
|
|
96
|
+
readonly roles?: ReadonlyArray<SpaceRole>;
|
|
97
|
+
/** Which of them the creator holds. Default: the highest-ranked. */
|
|
98
|
+
readonly creatorRole?: string;
|
|
99
|
+
}
|
|
100
|
+
export interface InvitePreview {
|
|
101
|
+
readonly space: Pick<SpaceSummary, 'id' | 'name' | 'visibility' | 'creator' | 'createdAt'>;
|
|
102
|
+
readonly invitedBy: string;
|
|
103
|
+
/** Whether the invite carries the key to a private space */
|
|
104
|
+
readonly carriesKey: boolean;
|
|
105
|
+
/** Whether the invite lets you join with a role — false for a view-only one */
|
|
106
|
+
readonly carriesWrite: boolean;
|
|
107
|
+
/** The role it is for, as the link says. The space's own invite record is what counts. */
|
|
108
|
+
readonly role: string | null;
|
|
109
|
+
}
|
|
110
|
+
export interface InviteOptions {
|
|
111
|
+
/**
|
|
112
|
+
* The role whoever uses it will hold. Default: the lowest role below your
|
|
113
|
+
* own — or, when there is none, a view-only invite.
|
|
114
|
+
*/
|
|
115
|
+
readonly role?: string;
|
|
116
|
+
/** False for a view-only invite: the key to read a private space, and no role */
|
|
117
|
+
readonly write?: boolean;
|
|
118
|
+
}
|
|
119
|
+
/** Who holds what in a space, now */
|
|
120
|
+
export interface SpaceAccess {
|
|
121
|
+
/** Highest rank first */
|
|
122
|
+
readonly roles: ReadonlyArray<SpaceRole>;
|
|
123
|
+
readonly members: ReadonlyArray<{
|
|
124
|
+
readonly did: string;
|
|
125
|
+
readonly role: string;
|
|
126
|
+
}>;
|
|
127
|
+
/** Open and closed invites, by their public key */
|
|
128
|
+
readonly invites: ReadonlyArray<{
|
|
129
|
+
readonly key: string;
|
|
130
|
+
readonly role: string;
|
|
131
|
+
readonly open: boolean;
|
|
132
|
+
}>;
|
|
133
|
+
/** This account's own role — null when it holds none */
|
|
134
|
+
readonly role: SpaceRole | null;
|
|
135
|
+
/** The latest access changes held — what a record written now names as `seen` */
|
|
136
|
+
readonly heads: ReadonlyArray<string>;
|
|
137
|
+
}
|
|
138
|
+
/** A record, opened and checked — its current version, unless listed as history */
|
|
139
|
+
export interface NodeRecord<T = unknown> {
|
|
140
|
+
/** The record's identity. Stays the same across edits; links point here. */
|
|
141
|
+
readonly key: string;
|
|
142
|
+
/** This version's id — a content hash, different for every edit */
|
|
143
|
+
readonly version: string;
|
|
144
|
+
/** 0 for the first version, one more for each edit */
|
|
145
|
+
readonly seq: number;
|
|
146
|
+
readonly space: string;
|
|
147
|
+
readonly collection: string;
|
|
148
|
+
/** The key that signed this version — usually a session key */
|
|
149
|
+
readonly author: string;
|
|
150
|
+
/** The identity that key was acting for, when its delegation checks out */
|
|
151
|
+
readonly root: string | null;
|
|
152
|
+
/** The identity that created the record, when its first version is held */
|
|
153
|
+
readonly createdBy: string | null;
|
|
154
|
+
/** When the record was created, as its creator's clock said — for display; it decides nothing */
|
|
155
|
+
readonly createdAt: string;
|
|
156
|
+
/** When this version was written, likewise for display only */
|
|
157
|
+
readonly updatedAt: string;
|
|
158
|
+
/** The content, or null when it is encrypted and this node has no key */
|
|
159
|
+
readonly body: T | null;
|
|
160
|
+
/** What this record points at — empty when it points at nothing, or cannot be opened */
|
|
161
|
+
readonly links: ReadonlyArray<Link>;
|
|
162
|
+
readonly encrypted: boolean;
|
|
163
|
+
/** Signature, delegation and shape all check out */
|
|
164
|
+
readonly verified: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Present, and true, when an agent wrote this version for `root`: the note
|
|
167
|
+
* it was signed under says so (`AGENT_FACT`). The account's word, signed —
|
|
168
|
+
* not something the agent can leave out.
|
|
169
|
+
*/
|
|
170
|
+
readonly viaAgent?: true;
|
|
171
|
+
readonly reason?: string;
|
|
172
|
+
/** Present, and true, when this version deletes the record (listed only with `includeDeleted`) */
|
|
173
|
+
readonly deleted?: true;
|
|
174
|
+
/**
|
|
175
|
+
* Whether the body fits its collection's schema — the one the space
|
|
176
|
+
* describes, else one this node was given. Null when there is none, or the
|
|
177
|
+
* body could not be opened. A record that does not fit is still kept and
|
|
178
|
+
* synced: whether it fits can depend on which definition a peer has seen yet,
|
|
179
|
+
* and rejecting it would leave peers that disagree forever.
|
|
180
|
+
*/
|
|
181
|
+
readonly conforms: boolean | null;
|
|
182
|
+
readonly issues?: ReadonlyArray<SchemaIssue>;
|
|
183
|
+
}
|
|
184
|
+
/** A collection as a space describes it, and how many records it holds */
|
|
185
|
+
export interface NodeCollection {
|
|
186
|
+
readonly name: string;
|
|
187
|
+
readonly title?: string;
|
|
188
|
+
readonly description?: string;
|
|
189
|
+
/** Null when records exist but the space has no definition for them */
|
|
190
|
+
readonly schema: JsonSchema | null;
|
|
191
|
+
readonly version: number | null;
|
|
192
|
+
/** Whether edits keep old versions: `all` for an audit trail, `latest` (the default) for current state only */
|
|
193
|
+
readonly history: 'latest' | 'all';
|
|
194
|
+
/** The link roles its records carry, and what each may point at — how the space's things connect */
|
|
195
|
+
readonly links: Readonly<Record<string, LinkDeclaration>>;
|
|
196
|
+
/** The identity that first defined it — it, and anyone who can manage the space, may change it */
|
|
197
|
+
readonly definedBy: string | null;
|
|
198
|
+
/** The permissions its rules name — a role holds each as `<collection>/<permission>` */
|
|
199
|
+
readonly permissions: ReadonlyArray<string>;
|
|
200
|
+
/** Who may create, edit and delete, what must be unique — for records created from now on */
|
|
201
|
+
readonly rules: CollectionRules;
|
|
202
|
+
/** A screen for its records, when its definer gave one: one HTML document, run sealed */
|
|
203
|
+
readonly screen?: string;
|
|
204
|
+
readonly records: number;
|
|
205
|
+
}
|
|
206
|
+
export interface DefineCollection {
|
|
207
|
+
readonly name: string;
|
|
208
|
+
readonly title?: string;
|
|
209
|
+
readonly description?: string;
|
|
210
|
+
/**
|
|
211
|
+
* A record body's shape: JSON Schema in the supported subset, or a
|
|
212
|
+
* validator that can describe itself as JSON Schema — a Zod object, say
|
|
213
|
+
* (Standard JSON Schema). Either way, JSON Schema is what gets stored.
|
|
214
|
+
*/
|
|
215
|
+
readonly schema: JsonSchema | StandardJSONSchemaV1;
|
|
216
|
+
/** Default: one past the current version, or 1 */
|
|
217
|
+
readonly version?: number;
|
|
218
|
+
/** Keep every version of every record in it (`all`), or only the current one (`latest`, the default) */
|
|
219
|
+
readonly history?: 'latest' | 'all';
|
|
220
|
+
/** The link roles its records may carry, and what each may point at */
|
|
221
|
+
readonly links?: Readonly<Record<string, LinkDeclaration>>;
|
|
222
|
+
/** The permissions its rules may name, like `moderate` */
|
|
223
|
+
readonly permissions?: ReadonlyArray<string>;
|
|
224
|
+
/** Who may create, edit and delete, what must be unique, which fields are fixed */
|
|
225
|
+
readonly rules?: CollectionRules;
|
|
226
|
+
/** A screen for its records — one HTML document an app may run in a sealed frame (`StoredCollection.screen`) */
|
|
227
|
+
readonly screen?: string;
|
|
228
|
+
}
|
|
229
|
+
export interface NodeCollections {
|
|
230
|
+
/** What a space holds: every defined collection, and every collection with records */
|
|
231
|
+
list(spaceId: string): Promise<ReadonlyArray<NodeCollection>>;
|
|
232
|
+
/** Publishes a definition into the space, as a signed record that syncs like any other */
|
|
233
|
+
define(spaceId: string, definition: DefineCollection): Promise<NodeCollection>;
|
|
234
|
+
/**
|
|
235
|
+
* Takes a definition out of the space. Refused while the collection still
|
|
236
|
+
* has records; the same people who may change a definition may remove it.
|
|
237
|
+
*/
|
|
238
|
+
delete(spaceId: string, name: string): Promise<void>;
|
|
239
|
+
}
|
|
240
|
+
export interface ListOptions {
|
|
241
|
+
/** Only this collection. Default: every collection except the protocol's own `sys.*` */
|
|
242
|
+
readonly collection?: string;
|
|
243
|
+
/** Newest first when set; oldest first by default */
|
|
244
|
+
readonly newestFirst?: boolean;
|
|
245
|
+
readonly limit?: number;
|
|
246
|
+
/** Also return deleted records, marked `deleted` */
|
|
247
|
+
readonly includeDeleted?: boolean;
|
|
248
|
+
}
|
|
249
|
+
export type ConnectionState = 'offline' | 'connecting' | 'connected' | 'error';
|
|
250
|
+
export interface SpaceStatus {
|
|
251
|
+
readonly space: string;
|
|
252
|
+
readonly connection: ConnectionState;
|
|
253
|
+
/** Peers currently connected in this space */
|
|
254
|
+
readonly peers: ReadonlyArray<string>;
|
|
255
|
+
/** Of `peers`, this account's own other devices and apps — the ones following the account registry too */
|
|
256
|
+
readonly own: ReadonlyArray<string>;
|
|
257
|
+
/** Of `peers`, carriers the account uses: nodes that keep its spaces online without reading them */
|
|
258
|
+
readonly carriers: ReadonlyArray<string>;
|
|
259
|
+
/** Root of this space's Merkle tree — equal on two nodes means identical data */
|
|
260
|
+
readonly root: string | null;
|
|
261
|
+
/** Records peers sent that failed validation */
|
|
262
|
+
readonly rejected: number;
|
|
263
|
+
}
|
|
264
|
+
export type NodeEvent =
|
|
265
|
+
/** Records were added, changed or deleted, locally or by sync */
|
|
266
|
+
{
|
|
267
|
+
readonly type: 'records';
|
|
268
|
+
readonly space: string;
|
|
269
|
+
}
|
|
270
|
+
/** Connection or peers changed */
|
|
271
|
+
| {
|
|
272
|
+
readonly type: 'status';
|
|
273
|
+
readonly space: string;
|
|
274
|
+
}
|
|
275
|
+
/** The registry changed: a space was created, joined or left */
|
|
276
|
+
| {
|
|
277
|
+
readonly type: 'spaces';
|
|
278
|
+
}
|
|
279
|
+
/** The account's profile may have changed, here or on another device */
|
|
280
|
+
| {
|
|
281
|
+
readonly type: 'account';
|
|
282
|
+
} | {
|
|
283
|
+
readonly type: 'rejected';
|
|
284
|
+
readonly space: string;
|
|
285
|
+
readonly peer: string;
|
|
286
|
+
readonly reason: string;
|
|
287
|
+
}
|
|
288
|
+
/** The note this node writes under was revoked in a space — an app disconnected from its account home, say */
|
|
289
|
+
| {
|
|
290
|
+
readonly type: 'revoked';
|
|
291
|
+
readonly space: string;
|
|
292
|
+
};
|
|
293
|
+
/** Who someone is in a space: the name they gave there, by their identity */
|
|
294
|
+
export interface SpaceProfile {
|
|
295
|
+
/** Their identity — what `root` and `createdBy` on a record name */
|
|
296
|
+
readonly did: string;
|
|
297
|
+
readonly name: string;
|
|
298
|
+
readonly updatedAt: string;
|
|
299
|
+
}
|
|
300
|
+
export interface NodeSpaces {
|
|
301
|
+
list(): Promise<ReadonlyArray<SpaceSummary>>;
|
|
302
|
+
get(spaceId: string): Promise<SpaceSummary | null>;
|
|
303
|
+
create(params: NewSpace): Promise<SpaceSummary>;
|
|
304
|
+
/**
|
|
305
|
+
* An invite string. For a private space it carries the key, and unless it is
|
|
306
|
+
* view-only, the secret of an invite opened for a role — so treat it as a
|
|
307
|
+
* secret. It is shown once: nothing keeps it. Closing the invite (`closeInvite`)
|
|
308
|
+
* stops it working.
|
|
309
|
+
*/
|
|
310
|
+
invite(spaceId: string, options?: InviteOptions): Promise<string>;
|
|
311
|
+
preview(invite: string): InvitePreview;
|
|
312
|
+
join(invite: string): Promise<SpaceSummary>;
|
|
313
|
+
/**
|
|
314
|
+
* Forgets a space on this node, with its key. Other members keep theirs.
|
|
315
|
+
* Your role stays too — to give it up, `setMember` yourself to null first.
|
|
316
|
+
*/
|
|
317
|
+
leave(spaceId: string): Promise<void>;
|
|
318
|
+
/** Roles, members and invites, as the space's access history says now */
|
|
319
|
+
access(spaceId: string): Promise<SpaceAccess>;
|
|
320
|
+
/** Gives someone a role, changes it, or with null takes it away. You may change people ranked below you, and yourself to null. */
|
|
321
|
+
setMember(spaceId: string, did: string, role: string | null): Promise<void>;
|
|
322
|
+
/** Adds or changes a role ranked below yours */
|
|
323
|
+
putRole(spaceId: string, role: SpaceRole): Promise<void>;
|
|
324
|
+
/** Removes a role ranked below yours; whoever held it holds nothing */
|
|
325
|
+
removeRole(spaceId: string, name: string): Promise<void>;
|
|
326
|
+
/** Closes an invite — by the link itself, or by its key from `access().invites`. Who joined with it before stays. */
|
|
327
|
+
closeInvite(spaceId: string, keyOrLink: string): Promise<void>;
|
|
328
|
+
/**
|
|
329
|
+
* Revokes a note this account signed — an app's, say. Nothing written under
|
|
330
|
+
* it counts from then on, except what this node had already seen.
|
|
331
|
+
*/
|
|
332
|
+
revoke(spaceId: string, token: string): Promise<void>;
|
|
333
|
+
/** Starts syncing a space. Reading or writing opens it anyway; this is for nodes that serve. */
|
|
334
|
+
open(spaceId: string): Promise<void>;
|
|
335
|
+
/** Stops syncing a space until it is next used */
|
|
336
|
+
close(spaceId: string): Promise<void>;
|
|
337
|
+
status(spaceId: string): Promise<SpaceStatus>;
|
|
338
|
+
/**
|
|
339
|
+
* What a node serving this space uses to check a connecting peer is who it
|
|
340
|
+
* says — and, in a private space, may read it — and to sign its welcome.
|
|
341
|
+
* Needs no key of the space's. Null for a space this node does not hold.
|
|
342
|
+
*/
|
|
343
|
+
authenticator(spaceId: string): Promise<ServerAuth | null>;
|
|
344
|
+
/**
|
|
345
|
+
* The name each person gave in this space, by identity. Your own is
|
|
346
|
+
* published for you, from the account's name, into every space you can
|
|
347
|
+
* write in — and kept up to date when you rename. Only you can change yours.
|
|
348
|
+
*/
|
|
349
|
+
profiles(spaceId: string): Promise<ReadonlyArray<SpaceProfile>>;
|
|
350
|
+
}
|
|
351
|
+
export interface NodeRecords {
|
|
352
|
+
/** Current versions, oldest record first; deleted records only with `includeDeleted` */
|
|
353
|
+
list<T = unknown>(spaceId: string, options?: ListOptions): Promise<ReadonlyArray<NodeRecord<T>>>;
|
|
354
|
+
/** A record's current version, or null when there is none or it was deleted */
|
|
355
|
+
get<T = unknown>(spaceId: string, key: string): Promise<NodeRecord<T> | null>;
|
|
356
|
+
/**
|
|
357
|
+
* Creates a record. Its key is random unless given — a chosen key suits a
|
|
358
|
+
* record there is one of by nature. Writing a key that was deleted brings it back.
|
|
359
|
+
*/
|
|
360
|
+
put<T = unknown>(spaceId: string, collection: string, body: T, options?: {
|
|
361
|
+
key?: string;
|
|
362
|
+
links?: ReadonlyArray<Link>;
|
|
363
|
+
}): Promise<NodeRecord<T>>;
|
|
364
|
+
/** The same, given the collection's definition: the body is checked against its type as you write it */
|
|
365
|
+
put<C extends {
|
|
366
|
+
readonly name: string;
|
|
367
|
+
}>(spaceId: string, collection: C, body: BodyOf<C>, options?: {
|
|
368
|
+
key?: string;
|
|
369
|
+
links?: ReadonlyArray<Link>;
|
|
370
|
+
}): Promise<NodeRecord<BodyOf<C>>>;
|
|
371
|
+
/** Writes the record's next version. Same key; `seq` one higher. Links carry over unless given. */
|
|
372
|
+
update<T = unknown>(spaceId: string, key: string, body: T, options?: {
|
|
373
|
+
links?: ReadonlyArray<Link>;
|
|
374
|
+
}): Promise<NodeRecord<T>>;
|
|
375
|
+
/** The records whose current version points at this one — optionally in one role, or one collection */
|
|
376
|
+
linked<T = unknown>(spaceId: string, key: string, options?: {
|
|
377
|
+
rel?: string;
|
|
378
|
+
collection?: string;
|
|
379
|
+
}): Promise<ReadonlyArray<NodeRecord<T>>>;
|
|
380
|
+
/**
|
|
381
|
+
* Deletes a record everywhere, by writing a version marked deleted that syncs
|
|
382
|
+
* like any other. Anyone who may write in the space may delete in it.
|
|
383
|
+
*/
|
|
384
|
+
delete(spaceId: string, key: string): Promise<void>;
|
|
385
|
+
/**
|
|
386
|
+
* The versions of a record this node keeps, newest first: the current one,
|
|
387
|
+
* the first one, and — in a collection with `history: 'all'` — every other.
|
|
388
|
+
*/
|
|
389
|
+
history<T = unknown>(spaceId: string, key: string): Promise<ReadonlyArray<NodeRecord<T>>>;
|
|
390
|
+
/**
|
|
391
|
+
* Whether this account may `create` in a collection (`target` = its name),
|
|
392
|
+
* or `edit` / `delete` a record (`target` = its key) — by the collection's
|
|
393
|
+
* rules and the space's. For hiding a button rather than showing an error.
|
|
394
|
+
*/
|
|
395
|
+
can(spaceId: string, action: 'create' | 'edit' | 'delete', target: string): Promise<boolean>;
|
|
396
|
+
/**
|
|
397
|
+
* Records matching a query — filtered, sorted, paged, with linked records
|
|
398
|
+
* pulled in. The query is plain data. Name a collection by its definition
|
|
399
|
+
* (or a `Typed` name) instead of a string, and the records — and what each
|
|
400
|
+
* `include` finds — come back typed. Only records this device can read are
|
|
401
|
+
* returned.
|
|
402
|
+
* @throws When the query is malformed, saying what to fix
|
|
403
|
+
*/
|
|
404
|
+
query<const Q extends Query>(spaceId: string, query: Q): Promise<ResultOf<Q>>;
|
|
405
|
+
/**
|
|
406
|
+
* Runs a query now and again whenever the space's records change, calling
|
|
407
|
+
* back with each result. Returns a function that stops it.
|
|
408
|
+
*/
|
|
409
|
+
watch<const Q extends Query>(spaceId: string, query: Q, onResult: (result: ResultOf<Q>) => void, onError?: (error: Error) => void): () => void;
|
|
410
|
+
}
|
|
411
|
+
export interface DelegateParams {
|
|
412
|
+
/** The key being given permission — an agent's, a guest's */
|
|
413
|
+
readonly audience: string;
|
|
414
|
+
/** Must be no broader than the node's own */
|
|
415
|
+
readonly capabilities: ReadonlyArray<Capability>;
|
|
416
|
+
/** Unix seconds; capped at the node's own delegation. Default: the same. */
|
|
417
|
+
readonly expiration?: number;
|
|
418
|
+
}
|
|
419
|
+
export interface Delegated {
|
|
420
|
+
readonly token: UCANToken;
|
|
421
|
+
/** The chain above it, root first, for anyone verifying it */
|
|
422
|
+
readonly proofs: ReadonlyArray<string>;
|
|
423
|
+
}
|
|
424
|
+
export interface AccountProfileView {
|
|
425
|
+
readonly name: string;
|
|
426
|
+
/** When it was set, on whichever device set it */
|
|
427
|
+
readonly updatedAt: string;
|
|
428
|
+
}
|
|
429
|
+
/** A carrier the account uses, as the account registry lists it */
|
|
430
|
+
export interface CarrierSummary {
|
|
431
|
+
/** The carry space shared with it */
|
|
432
|
+
readonly space: string;
|
|
433
|
+
/** Its key, as peers see it */
|
|
434
|
+
readonly did: string;
|
|
435
|
+
readonly name: string;
|
|
436
|
+
readonly since: string;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Carriers: nodes that keep the account's spaces online without being able to
|
|
440
|
+
* read them — a browser extension, say (`space/pass.ts`). Needs the account key.
|
|
441
|
+
*/
|
|
442
|
+
export interface NodeCarriers {
|
|
443
|
+
list(): Promise<ReadonlyArray<CarrierSummary>>;
|
|
444
|
+
/**
|
|
445
|
+
* Starts using a carrier: makes a carry space for it, puts a pass for every
|
|
446
|
+
* space of the account in it, and lists it in the account registry so every
|
|
447
|
+
* device keeps those passes current.
|
|
448
|
+
* @returns The carry space, and the view-only invite the carrier joins it with
|
|
449
|
+
*/
|
|
450
|
+
add(carrier: {
|
|
451
|
+
readonly did: string;
|
|
452
|
+
readonly name: string;
|
|
453
|
+
}): Promise<{
|
|
454
|
+
readonly space: string;
|
|
455
|
+
readonly invite: string;
|
|
456
|
+
}>;
|
|
457
|
+
/**
|
|
458
|
+
* Stops using a carrier: takes its passes away and tells it to forget what it
|
|
459
|
+
* held. What it already downloaded, it keeps — encrypted, as it always was.
|
|
460
|
+
*/
|
|
461
|
+
remove(space: string): Promise<void>;
|
|
462
|
+
}
|
|
463
|
+
export interface NodeAccount {
|
|
464
|
+
/** The account's profile as its devices last set it. Null without an account key, or before any is set. */
|
|
465
|
+
profile(): Promise<AccountProfileView | null>;
|
|
466
|
+
/** Renames the account on every device and app that opens it. Needs an account key. */
|
|
467
|
+
setName(name: string): Promise<AccountProfileView>;
|
|
468
|
+
/**
|
|
469
|
+
* Revokes a note this account signed in the account registry, so a
|
|
470
|
+
* whole-account app can no longer add spaces or rename it. Needs an account key.
|
|
471
|
+
*/
|
|
472
|
+
revoke(token: string): Promise<void>;
|
|
473
|
+
}
|
|
474
|
+
export interface P2PNode {
|
|
475
|
+
/** The identity this node acts for */
|
|
476
|
+
readonly did: string;
|
|
477
|
+
/** The session key that signs and connects; stable for the node's lifetime */
|
|
478
|
+
readonly sessionDid: string;
|
|
479
|
+
readonly spaces: NodeSpaces;
|
|
480
|
+
readonly records: NodeRecords;
|
|
481
|
+
readonly collections: NodeCollections;
|
|
482
|
+
/** The account itself — its name, synced through the account registry */
|
|
483
|
+
readonly account: NodeAccount;
|
|
484
|
+
/** Nodes that keep the account's spaces online without reading them */
|
|
485
|
+
readonly carriers: NodeCarriers;
|
|
486
|
+
/** The delegation the session key currently writes under (root → session) */
|
|
487
|
+
delegation(): UCANToken;
|
|
488
|
+
/** Passes a narrower delegation from the session key on to another key */
|
|
489
|
+
delegate(params: DelegateParams): Promise<Delegated>;
|
|
490
|
+
/**
|
|
491
|
+
* The same node, acting as an agent: what it writes is signed by the
|
|
492
|
+
* agent's key under the agent's note (one carrying `AGENT_FACT`), so it
|
|
493
|
+
* shows as "via agent" everywhere. It reads and writes only the spaces that
|
|
494
|
+
* note names, and refuses everything that needs a person — defining
|
|
495
|
+
* collections, roles, invites, joining or leaving, the account itself.
|
|
496
|
+
* Closing it leaves this node running.
|
|
497
|
+
*
|
|
498
|
+
* @param agent.note The agent's note from the account home (`Grant.token` of an agent grant)
|
|
499
|
+
* @throws When the note is not an agent's, has run out, or is not made out to `keys`
|
|
500
|
+
*/
|
|
501
|
+
asAgent(agent: {
|
|
502
|
+
readonly keys: CryptoKeyPair;
|
|
503
|
+
readonly note: string;
|
|
504
|
+
}): Promise<P2PNode>;
|
|
505
|
+
subscribe(listener: (event: NodeEvent) => void): () => void;
|
|
506
|
+
close(): Promise<void>;
|
|
507
|
+
}
|
|
508
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/node/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACzH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,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AG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,OAAO;IACtB,sCAAsC;IACtC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,8EAA8E;IAC9E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,eAAe,CAAC;IACtC,yEAAyE;IACzE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAChC,6EAA6E;IAC7E,UAAU,IAAI,SAAS,CAAC;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IACrD;;;;;;;;;;OAUG;IACH,OAAO,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1F,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAC5D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/node/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/privacy/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/privacy/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a space key that has been wrapped for a specific recipient.
|
|
3
|
+
*/
|
|
4
|
+
export interface WrappedKey {
|
|
5
|
+
readonly recipientDid: string;
|
|
6
|
+
readonly ephemeralPublicKey: string;
|
|
7
|
+
readonly wrappedKeyData: string;
|
|
8
|
+
readonly algorithm: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A member's public key for key wrapping.
|
|
12
|
+
*/
|
|
13
|
+
export interface MemberPublicKey {
|
|
14
|
+
readonly did: string;
|
|
15
|
+
readonly publicKey: CryptoKey;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Wraps a space key using ECDH + AES-KW.
|
|
19
|
+
*
|
|
20
|
+
* @param {CryptoKey} spaceKey - The space key to wrap.
|
|
21
|
+
* @param {CryptoKey} recipientPublicKey - The recipient's public ECDH key.
|
|
22
|
+
* @param {string} recipientDid - The DID of the recipient.
|
|
23
|
+
* @returns {Promise<WrappedKey>} A promise resolving to the wrapped key.
|
|
24
|
+
*/
|
|
25
|
+
export declare function wrapSpaceKey(spaceKey: CryptoKey, recipientPublicKey: CryptoKey, recipientDid: string): Promise<WrappedKey>;
|
|
26
|
+
/**
|
|
27
|
+
* Unwraps a wrapped space key using ECDH + AES-KW.
|
|
28
|
+
*
|
|
29
|
+
* @param {WrappedKey} wrapped - The wrapped key to unwrap.
|
|
30
|
+
* @param {CryptoKey} recipientPrivateKey - The recipient's private ECDH key.
|
|
31
|
+
* @returns {Promise<CryptoKey>} A promise resolving to the unwrapped space key.
|
|
32
|
+
*/
|
|
33
|
+
export declare function unwrapSpaceKey(wrapped: WrappedKey, recipientPrivateKey: CryptoKey): Promise<CryptoKey>;
|
|
34
|
+
/**
|
|
35
|
+
* Wraps a space key for multiple members.
|
|
36
|
+
*
|
|
37
|
+
* @param {CryptoKey} spaceKey - The space key to wrap.
|
|
38
|
+
* @param {ReadonlyArray<MemberPublicKey>} memberPublicKeys - An array of member public keys.
|
|
39
|
+
* @returns {Promise<ReadonlyArray<WrappedKey>>} A promise resolving to an array of wrapped keys.
|
|
40
|
+
*/
|
|
41
|
+
export declare function distributeSpaceKey(spaceKey: CryptoKey, memberPublicKeys: ReadonlyArray<MemberPublicKey>): Promise<ReadonlyArray<WrappedKey>>;
|
|
42
|
+
//# sourceMappingURL=key-distribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-distribution.d.ts","sourceRoot":"","sources":["../../src/privacy/key-distribution.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CAC/B;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,SAAS,EACnB,kBAAkB,EAAE,SAAS,EAC7B,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,UAAU,CAAC,CAoCrB;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,UAAU,EACnB,mBAAmB,EAAE,SAAS,GAC7B,OAAO,CAAC,SAAS,CAAC,CAmCpB;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,SAAS,EACnB,gBAAgB,EAAE,aAAa,CAAC,eAAe,CAAC,GAC/C,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAMpC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { base64UrlEncode, base64UrlDecode } from '../utils/encoding.js';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a space key using ECDH + AES-KW.
|
|
4
|
+
*
|
|
5
|
+
* @param {CryptoKey} spaceKey - The space key to wrap.
|
|
6
|
+
* @param {CryptoKey} recipientPublicKey - The recipient's public ECDH key.
|
|
7
|
+
* @param {string} recipientDid - The DID of the recipient.
|
|
8
|
+
* @returns {Promise<WrappedKey>} A promise resolving to the wrapped key.
|
|
9
|
+
*/
|
|
10
|
+
export async function wrapSpaceKey(spaceKey, recipientPublicKey, recipientDid) {
|
|
11
|
+
const ephemeralPair = await globalThis.crypto.subtle.generateKey({ name: 'ECDH', namedCurve: 'P-256' }, true, ['deriveBits']);
|
|
12
|
+
const sharedSecret = await globalThis.crypto.subtle.deriveBits({ name: 'ECDH', public: recipientPublicKey }, ephemeralPair.privateKey, 256);
|
|
13
|
+
const kek = await globalThis.crypto.subtle.importKey('raw', sharedSecret, { name: 'AES-KW' }, false, ['wrapKey']);
|
|
14
|
+
const wrappedKeyBuffer = await globalThis.crypto.subtle.wrapKey('raw', spaceKey, kek, { name: 'AES-KW' });
|
|
15
|
+
const ephemeralRaw = await globalThis.crypto.subtle.exportKey('raw', ephemeralPair.publicKey);
|
|
16
|
+
return Object.freeze({
|
|
17
|
+
recipientDid,
|
|
18
|
+
ephemeralPublicKey: base64UrlEncode(new Uint8Array(ephemeralRaw)),
|
|
19
|
+
wrappedKeyData: base64UrlEncode(new Uint8Array(wrappedKeyBuffer)),
|
|
20
|
+
algorithm: 'ECDH-AES-KW'
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Unwraps a wrapped space key using ECDH + AES-KW.
|
|
25
|
+
*
|
|
26
|
+
* @param {WrappedKey} wrapped - The wrapped key to unwrap.
|
|
27
|
+
* @param {CryptoKey} recipientPrivateKey - The recipient's private ECDH key.
|
|
28
|
+
* @returns {Promise<CryptoKey>} A promise resolving to the unwrapped space key.
|
|
29
|
+
*/
|
|
30
|
+
export async function unwrapSpaceKey(wrapped, recipientPrivateKey) {
|
|
31
|
+
const ephemeralRaw = base64UrlDecode(wrapped.ephemeralPublicKey);
|
|
32
|
+
const ephemeralPublicKey = await globalThis.crypto.subtle.importKey('raw', ephemeralRaw, { name: 'ECDH', namedCurve: 'P-256' }, true, []);
|
|
33
|
+
const sharedSecret = await globalThis.crypto.subtle.deriveBits({ name: 'ECDH', public: ephemeralPublicKey }, recipientPrivateKey, 256);
|
|
34
|
+
const kek = await globalThis.crypto.subtle.importKey('raw', sharedSecret, { name: 'AES-KW' }, false, ['unwrapKey']);
|
|
35
|
+
const wrappedKeyData = base64UrlDecode(wrapped.wrappedKeyData);
|
|
36
|
+
return globalThis.crypto.subtle.unwrapKey('raw', wrappedKeyData, kek, { name: 'AES-KW' }, { name: 'AES-GCM', length: 256 }, true, ['encrypt', 'decrypt']);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Wraps a space key for multiple members.
|
|
40
|
+
*
|
|
41
|
+
* @param {CryptoKey} spaceKey - The space key to wrap.
|
|
42
|
+
* @param {ReadonlyArray<MemberPublicKey>} memberPublicKeys - An array of member public keys.
|
|
43
|
+
* @returns {Promise<ReadonlyArray<WrappedKey>>} A promise resolving to an array of wrapped keys.
|
|
44
|
+
*/
|
|
45
|
+
export async function distributeSpaceKey(spaceKey, memberPublicKeys) {
|
|
46
|
+
const promises = memberPublicKeys.map(member => wrapSpaceKey(spaceKey, member.publicKey, member.did));
|
|
47
|
+
const wrappedKeys = await Promise.all(promises);
|
|
48
|
+
return Object.freeze([...wrappedKeys]);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=key-distribution.js.map
|