@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,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module session/agent-link
|
|
3
|
+
* Connecting an agent on a computer — Claude Code, Claude Desktop, Cursor —
|
|
4
|
+
* with one command the person copies from an app.
|
|
5
|
+
*
|
|
6
|
+
* The app shows `weave connect wv_…`. The code is a random secret, made for
|
|
7
|
+
* this one connection. Both sides work out a meeting room and a key from it,
|
|
8
|
+
* meet on a relay, and talk over the ordinary peer connection:
|
|
9
|
+
*
|
|
10
|
+
* 1. The terminal says who it is: its own key, made on that computer and never
|
|
11
|
+
* sent anywhere, and a name for the person to recognise ("Agent on
|
|
12
|
+
* leifs-macbook").
|
|
13
|
+
* 2. The app shows that and waits for a click, which opens the account home.
|
|
14
|
+
* The person allows it there, and the home signs an agent's note for that
|
|
15
|
+
* key — the same note an app gets, saying "agent".
|
|
16
|
+
* 3. The app hands the note back. The terminal keeps it, and from then on runs
|
|
17
|
+
* a node of its own: the app's tab can close.
|
|
18
|
+
*
|
|
19
|
+
* Everything said is sealed with the key from the code, so the relay — which
|
|
20
|
+
* introduces the two sides and could put itself between them — learns nothing
|
|
21
|
+
* and can change nothing. It is the phone pairing's arrangement
|
|
22
|
+
* (`identity/pairing.ts`), with a secret made for the purpose instead of the
|
|
23
|
+
* seed. The code is pasted, not typed, so it can be long enough that recording
|
|
24
|
+
* the traffic and guessing it later gets nowhere; it works once, and only while
|
|
25
|
+
* the app is showing it.
|
|
26
|
+
*/
|
|
27
|
+
import { createNetworkManager } from '../network/network-manager.js';
|
|
28
|
+
import { createMesh } from '../network/mesh.js';
|
|
29
|
+
import { createP256Provider } from '../identity/crypto-p256.js';
|
|
30
|
+
import { publicKeyToDid, P256_MULTICODEC } from '../identity/did.js';
|
|
31
|
+
import { verifyUCAN, parseUCAN } from '../identity/ucan.js';
|
|
32
|
+
import { isAgentNote } from '../identity/agent-note.js';
|
|
33
|
+
import { sealPairingPayload, openPairingPayload } from '../identity/pairing.js';
|
|
34
|
+
import { base64UrlDecode, base64UrlEncode, concatBytes, utf8Decode, utf8Encode } from '../utils/encoding.js';
|
|
35
|
+
import { cidFromBytes } from '../utils/hash.js';
|
|
36
|
+
const CODE_PREFIX = 'wv_';
|
|
37
|
+
const SECRET_BYTES = 16;
|
|
38
|
+
const ROOM_PREFIX = utf8Encode('weave-agent-link-room-v1');
|
|
39
|
+
const KEY_INFO = utf8Encode('weave-agent-link-key-v1');
|
|
40
|
+
/** Messages on the link, each sealed */
|
|
41
|
+
const ASK = 'agent-link:ask';
|
|
42
|
+
const HEARD = 'agent-link:heard';
|
|
43
|
+
const ANSWER = 'agent-link:answer';
|
|
44
|
+
const DONE = 'agent-link:done';
|
|
45
|
+
/** Longest name an agent may give itself */
|
|
46
|
+
const MAX_NAME = 80;
|
|
47
|
+
// ─── The code ────────────────────────────────────────────────────────
|
|
48
|
+
/** A new code: `wv_` and 128 random bits */
|
|
49
|
+
export function newAgentCode() {
|
|
50
|
+
return CODE_PREFIX + base64UrlEncode(globalThis.crypto.getRandomValues(new Uint8Array(SECRET_BYTES)));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The secret in a code, for anything a person might paste — surrounding
|
|
54
|
+
* spaces, quotes, the whole command.
|
|
55
|
+
* @throws When there is no code in it
|
|
56
|
+
*/
|
|
57
|
+
export function readAgentCode(input) {
|
|
58
|
+
const match = /wv_([A-Za-z0-9_-]{22})(?![A-Za-z0-9_-])/.exec(input);
|
|
59
|
+
const secret = match ? base64UrlDecode(match[1]) : null;
|
|
60
|
+
if (!secret || secret.length !== SECRET_BYTES) {
|
|
61
|
+
throw new Error('That is not a connect code. Copy the whole command from “Connect an agent” in the app.');
|
|
62
|
+
}
|
|
63
|
+
return secret;
|
|
64
|
+
}
|
|
65
|
+
async function linkRoom(secret) {
|
|
66
|
+
return encodeURIComponent(await cidFromBytes(concatBytes(ROOM_PREFIX, secret)));
|
|
67
|
+
}
|
|
68
|
+
async function linkKey(secret) {
|
|
69
|
+
const material = await globalThis.crypto.subtle.importKey('raw', secret, { name: 'HKDF' }, false, ['deriveKey']);
|
|
70
|
+
return globalThis.crypto.subtle.deriveKey({ name: 'HKDF', hash: 'SHA-256', salt: new Uint8Array(0), info: KEY_INFO }, material, { name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']);
|
|
71
|
+
}
|
|
72
|
+
async function seal(value, key) {
|
|
73
|
+
return Array.from(await sealPairingPayload(utf8Encode(JSON.stringify(value)), key));
|
|
74
|
+
}
|
|
75
|
+
/** What a sealed message says, or null when it wasn't sealed with this code */
|
|
76
|
+
async function unseal(message, key) {
|
|
77
|
+
if (!Array.isArray(message.payload))
|
|
78
|
+
return null;
|
|
79
|
+
try {
|
|
80
|
+
return JSON.parse(utf8Decode(await openPairingPayload(new Uint8Array(message.payload), key)));
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function meet(network, room, did) {
|
|
87
|
+
if (network.transport)
|
|
88
|
+
return createNetworkManager({ did, createTransport: () => network.transport(did) });
|
|
89
|
+
return createMesh({ relays: network.relays, did, introductions: false }).join(room);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Starts offering a connection to an agent on a computer. Keep it running
|
|
93
|
+
* while the code is on screen; the first terminal that shows up with the code
|
|
94
|
+
* is the one asked about, and nobody after it.
|
|
95
|
+
*/
|
|
96
|
+
export async function offerAgentLink(network, onStage) {
|
|
97
|
+
if (network.relays.length === 0 && !network.transport)
|
|
98
|
+
throw new Error('Connecting an agent needs a relay, and none is configured.');
|
|
99
|
+
const code = newAgentCode();
|
|
100
|
+
const secret = readAgentCode(code);
|
|
101
|
+
const key = await linkKey(secret);
|
|
102
|
+
// A name for this end of the link, and nothing more: it signs nothing.
|
|
103
|
+
const provider = createP256Provider();
|
|
104
|
+
const did = publicKeyToDid(await provider.exportPublicKey((await provider.generateKeyPair()).publicKey), P256_MULTICODEC);
|
|
105
|
+
const net = meet(network, await linkRoom(secret), did);
|
|
106
|
+
let asked = null;
|
|
107
|
+
let over = false;
|
|
108
|
+
const finish = (stage) => {
|
|
109
|
+
if (over)
|
|
110
|
+
return;
|
|
111
|
+
over = true;
|
|
112
|
+
onStage(stage);
|
|
113
|
+
globalThis.setTimeout(() => net.disconnect(), 500);
|
|
114
|
+
};
|
|
115
|
+
net.on('message', (message) => {
|
|
116
|
+
if (over)
|
|
117
|
+
return;
|
|
118
|
+
void (async () => {
|
|
119
|
+
if (message.type === ASK && !asked) {
|
|
120
|
+
const said = await unseal(message, key);
|
|
121
|
+
// Not sealed with this code: someone else in the room. Ignored.
|
|
122
|
+
if (!said || typeof said.did !== 'string' || !said.did.startsWith('did:key:'))
|
|
123
|
+
return;
|
|
124
|
+
const name = typeof said.name === 'string' && said.name.trim() ? said.name.trim().slice(0, MAX_NAME) : 'An agent';
|
|
125
|
+
const agent = { did: said.did, name };
|
|
126
|
+
asked = { peer: message.from, agent };
|
|
127
|
+
// So the terminal knows the code was right, and the person is deciding.
|
|
128
|
+
net.send(message.from, { type: HEARD, from: did, payload: await seal({ heard: true }, key) });
|
|
129
|
+
onStage({
|
|
130
|
+
kind: 'asking',
|
|
131
|
+
agent,
|
|
132
|
+
allow: async (grant) => {
|
|
133
|
+
if (parseUCAN(grant.token).payload.aud !== agent.did)
|
|
134
|
+
throw new Error('That note is for a different key.');
|
|
135
|
+
net.send(asked.peer, { type: ANSWER, from: did, payload: await seal({ grant }, key) });
|
|
136
|
+
},
|
|
137
|
+
deny: (reason = 'The person said no.') => {
|
|
138
|
+
void seal({ denied: reason }, key).then((payload) => {
|
|
139
|
+
net.send(asked.peer, { type: ANSWER, from: did, payload });
|
|
140
|
+
finish({ kind: 'failed', reason: 'You said no. Make a new code to try again.' });
|
|
141
|
+
});
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
else if (message.type === DONE && asked && message.from === asked.peer) {
|
|
146
|
+
if (await unseal(message, key))
|
|
147
|
+
finish({ kind: 'connected', agent: asked.agent });
|
|
148
|
+
}
|
|
149
|
+
})();
|
|
150
|
+
});
|
|
151
|
+
onStage({ kind: 'waiting' });
|
|
152
|
+
await net.connect();
|
|
153
|
+
return {
|
|
154
|
+
code,
|
|
155
|
+
stop: () => {
|
|
156
|
+
over = true;
|
|
157
|
+
net.disconnect();
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
// ─── The terminal's side ─────────────────────────────────────────────
|
|
162
|
+
/**
|
|
163
|
+
* Checks a grant the way the terminal must: a valid agent's note, from the
|
|
164
|
+
* account it names, made out to this key.
|
|
165
|
+
* @throws When it does not check out
|
|
166
|
+
*/
|
|
167
|
+
export async function checkAgentGrant(grant, audience) {
|
|
168
|
+
if (!grant || grant.v !== 1 || typeof grant.token !== 'string' || typeof grant.did !== 'string') {
|
|
169
|
+
throw new Error('The app sent something that is not a grant.');
|
|
170
|
+
}
|
|
171
|
+
const verified = await verifyUCAN(grant.token, createP256Provider());
|
|
172
|
+
if (!verified.valid)
|
|
173
|
+
throw new Error(`The note does not check out: ${verified.reason ?? 'invalid'}`);
|
|
174
|
+
const { payload } = parseUCAN(grant.token);
|
|
175
|
+
if (payload.aud !== audience)
|
|
176
|
+
throw new Error('The note was made out to a different key.');
|
|
177
|
+
if (payload.iss !== grant.did)
|
|
178
|
+
throw new Error('The note was not signed by the account it names.');
|
|
179
|
+
if (!isAgentNote(grant.token))
|
|
180
|
+
throw new Error('The note is not an agent\'s. Update your account home.');
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Connects this terminal as an agent, with the code from the app.
|
|
184
|
+
*
|
|
185
|
+
* @param params.did This agent's key — the note will be made out to it
|
|
186
|
+
* @param params.name What the person sees, e.g. "Agent on leifs-macbook"
|
|
187
|
+
* @param params.onWaiting Told once the app has heard, and the person is deciding
|
|
188
|
+
* @returns The grant, checked
|
|
189
|
+
* @throws When the code is wrong or stale, the person says no, or nothing answers in time
|
|
190
|
+
*/
|
|
191
|
+
export async function acceptAgentLink(params) {
|
|
192
|
+
const secret = readAgentCode(params.code);
|
|
193
|
+
const key = await linkKey(secret);
|
|
194
|
+
const net = meet(params.network, await linkRoom(secret), params.did);
|
|
195
|
+
return new Promise((resolve, reject) => {
|
|
196
|
+
let settled = false;
|
|
197
|
+
let timer;
|
|
198
|
+
const wait = (ms, reason) => {
|
|
199
|
+
clearTimeout(timer);
|
|
200
|
+
timer = setTimeout(() => finish(() => reject(new Error(reason))), ms);
|
|
201
|
+
};
|
|
202
|
+
const finish = (done) => {
|
|
203
|
+
if (settled)
|
|
204
|
+
return;
|
|
205
|
+
settled = true;
|
|
206
|
+
clearTimeout(timer);
|
|
207
|
+
// A moment for the last message to leave.
|
|
208
|
+
setTimeout(() => net.disconnect(), 500);
|
|
209
|
+
done();
|
|
210
|
+
};
|
|
211
|
+
net.on('peer-connected', (peer) => {
|
|
212
|
+
void seal({ did: params.did, name: params.name.slice(0, MAX_NAME) }, key).then((payload) => {
|
|
213
|
+
net.send(peer.did, { type: ASK, from: params.did, payload });
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
let heard = false;
|
|
217
|
+
net.on('message', (message) => {
|
|
218
|
+
void (async () => {
|
|
219
|
+
if (settled)
|
|
220
|
+
return;
|
|
221
|
+
// Once the app has the question, the person gets longer to answer it.
|
|
222
|
+
if (message.type === HEARD && !heard && (await unseal(message, key))) {
|
|
223
|
+
heard = true;
|
|
224
|
+
params.onWaiting?.();
|
|
225
|
+
wait(params.decideTimeoutMs ?? 10 * 60_000, 'Nobody answered in the app. Make a new code and try again.');
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
if (message.type !== ANSWER)
|
|
229
|
+
return;
|
|
230
|
+
const answer = await unseal(message, key);
|
|
231
|
+
if (!answer)
|
|
232
|
+
return;
|
|
233
|
+
if (typeof answer.denied === 'string') {
|
|
234
|
+
finish(() => reject(new Error(answer.denied)));
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
try {
|
|
238
|
+
await checkAgentGrant(answer.grant, params.did);
|
|
239
|
+
net.send(message.from, { type: DONE, from: params.did, payload: await seal({ ok: true }, key) });
|
|
240
|
+
finish(() => resolve(answer.grant));
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
finish(() => reject(error instanceof Error ? error : new Error(String(error))));
|
|
244
|
+
}
|
|
245
|
+
})();
|
|
246
|
+
});
|
|
247
|
+
wait(params.findTimeoutMs ?? 60_000, 'The app did not answer. Check the “Connect an agent” window is still open, or make a new code there.');
|
|
248
|
+
net.connect().catch(() => finish(() => reject(new Error('Could not reach the relay.'))));
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=agent-link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-link.js","sourceRoot":"","sources":["../../src/session/agent-link.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,oBAAoB,EAAuB,MAAM,+BAA+B,CAAC;AAC1F,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,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AAC;oBACtC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;oBAC/C,OAAO;gBACT,CAAC;gBACD,IAAI,CAAC;oBACH,MAAM,eAAe,CAAC,MAAM,CAAC,KAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;oBACjD,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;oBACjG,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAM,CAAC,CAAC,CAAC;gBACvC,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBAClF,CAAC;YACH,CAAC,CAAC,EAAE,CAAC;QACP,CAAC,CAAC,CAAC;QAEH,IAAI,CACF,MAAM,CAAC,aAAa,IAAI,MAAM,EAC9B,sGAAsG,CACvG,CAAC;QACF,GAAG,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3F,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import type { AccountStore, AccountSummary } from '../identity/account-store.js';
|
|
2
|
+
import { type AccountVault, type DeviceWrap } from '../identity/account-vault.js';
|
|
3
|
+
import type { PairingTicket } from '../identity/pairing.js';
|
|
4
|
+
import type { StoreFactory } from '../node/stores.js';
|
|
5
|
+
import type { NodeNetworkConfig, P2PNode } from '../node/types.js';
|
|
6
|
+
import { type ProtocolErrorCode } from '../utils/errors.js';
|
|
7
|
+
import { type Place, type PodContents } from './places.js';
|
|
8
|
+
import { type KeyValueStore, type StaySignedIn } from './stay-signed-in.js';
|
|
9
|
+
import { type CarryGrant, type ConnectRequest, type Grant } from './connect.js';
|
|
10
|
+
import { type PairingOffer, type PairingStage } from './pairing.js';
|
|
11
|
+
export interface WeaveAuthConfig {
|
|
12
|
+
/** What passkey prompts call this app. Default "Weave". */
|
|
13
|
+
readonly appName?: string;
|
|
14
|
+
/** Relays and always-on nodes the signed-in node connects to. Omit to stay offline. */
|
|
15
|
+
readonly network?: NodeNetworkConfig;
|
|
16
|
+
/** The site passkeys belong to. Default: this page's hostname. */
|
|
17
|
+
readonly rpId?: string;
|
|
18
|
+
/** Where small choices are remembered — which account, stay signed in. Default `localStorage`. */
|
|
19
|
+
readonly storage?: KeyValueStore | null;
|
|
20
|
+
/** Namespaces those choices, so two apps on one origin keep their own. Default "weave". */
|
|
21
|
+
readonly storageKey?: string;
|
|
22
|
+
/** The page a phone-pairing QR opens. Default: this page. */
|
|
23
|
+
readonly pairingLink?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Accounts kept in this browser, and their data. Defaults to IndexedDB;
|
|
26
|
+
* swap both for tests or for a host with no IndexedDB.
|
|
27
|
+
*/
|
|
28
|
+
readonly browser?: {
|
|
29
|
+
readonly accounts: () => Promise<AccountStore>;
|
|
30
|
+
readonly stores: (account: AccountSummary) => StoreFactory;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Which screen the flow is on.
|
|
35
|
+
*
|
|
36
|
+
* `where` — where should your data live (a pod, or this browser); asked once.
|
|
37
|
+
* `welcome` — the place holds no accounts: new here, or not?
|
|
38
|
+
* `signIn` — choose an account and unlock it.
|
|
39
|
+
* `create` — name a new account; then, with `freshCode` set, save its password.
|
|
40
|
+
* `pair` — opened from a phone-pairing QR code.
|
|
41
|
+
* `ready` — signed in; `session` is set.
|
|
42
|
+
*/
|
|
43
|
+
export type AuthStage = 'starting' | 'where' | 'welcome' | 'signIn' | 'create' | 'pair' | 'ready';
|
|
44
|
+
/** A failure, in the shape a screen needs to explain it */
|
|
45
|
+
export interface AuthError {
|
|
46
|
+
readonly message: string;
|
|
47
|
+
/** What the person can do about it, when that is known */
|
|
48
|
+
readonly hint?: string;
|
|
49
|
+
readonly code?: ProtocolErrorCode;
|
|
50
|
+
}
|
|
51
|
+
/** Which ways into an account exist on this site */
|
|
52
|
+
export interface AccountEntry {
|
|
53
|
+
readonly summary: AccountSummary;
|
|
54
|
+
readonly vault: AccountVault;
|
|
55
|
+
/**
|
|
56
|
+
* Passkey shortcuts this device can actually use. A wrap names a key in this
|
|
57
|
+
* site's storage, so one made on another site — or before storage was
|
|
58
|
+
* cleared — is listed by the vault but unopenable here.
|
|
59
|
+
*/
|
|
60
|
+
readonly shortcuts: ReadonlyArray<DeviceWrap>;
|
|
61
|
+
/** Whether a short password was set here */
|
|
62
|
+
readonly hasPassword: boolean;
|
|
63
|
+
}
|
|
64
|
+
/** An open account: who it is, and the node doing its work */
|
|
65
|
+
export interface WeaveSession {
|
|
66
|
+
readonly account: AccountSummary;
|
|
67
|
+
/** The account's identity */
|
|
68
|
+
readonly did: string;
|
|
69
|
+
/** The session key's DID — what peers see */
|
|
70
|
+
readonly sessionDid: string;
|
|
71
|
+
readonly node: P2PNode;
|
|
72
|
+
}
|
|
73
|
+
/** What the last move into a pod did */
|
|
74
|
+
export interface MovedToPod {
|
|
75
|
+
/** The pod already held this account, and the two copies were combined */
|
|
76
|
+
readonly merged: boolean;
|
|
77
|
+
readonly spacesAdded: number;
|
|
78
|
+
readonly recordsAdded: number;
|
|
79
|
+
/** The old pod's name, or null when the old place was this browser */
|
|
80
|
+
readonly from: string | null;
|
|
81
|
+
}
|
|
82
|
+
/** An app this account gave access to, as the home remembers it */
|
|
83
|
+
export interface Connection {
|
|
84
|
+
/** Where the app lives — as the browser reported it, not as the app named itself */
|
|
85
|
+
readonly origin: string;
|
|
86
|
+
/** What the app called itself */
|
|
87
|
+
readonly name: string | null;
|
|
88
|
+
/** The app's key */
|
|
89
|
+
readonly audience: string;
|
|
90
|
+
/** `carry` for a carrier, which holds passes and no keys */
|
|
91
|
+
readonly access: 'read' | 'write' | 'carry';
|
|
92
|
+
/** `account` when the app was given the whole account, not chosen spaces */
|
|
93
|
+
readonly scope: 'spaces' | 'account';
|
|
94
|
+
/** A carrier's carry space — what disconnecting takes away */
|
|
95
|
+
readonly carrySpace?: string;
|
|
96
|
+
readonly spaces: ReadonlyArray<{
|
|
97
|
+
readonly id: string;
|
|
98
|
+
readonly name: string;
|
|
99
|
+
}>;
|
|
100
|
+
readonly grantedAt: string;
|
|
101
|
+
/** Unix seconds */
|
|
102
|
+
readonly expiresAt: number;
|
|
103
|
+
/** The note the app writes under — what disconnecting revokes */
|
|
104
|
+
readonly token?: string;
|
|
105
|
+
/** Present, and true, for an agent connected through the app at `origin` — its own key, kept apart from the app's own connection */
|
|
106
|
+
readonly agent?: true;
|
|
107
|
+
}
|
|
108
|
+
/** What the person chose on the approval screen */
|
|
109
|
+
export interface GrantChoice {
|
|
110
|
+
readonly origin: string;
|
|
111
|
+
readonly request: ConnectRequest;
|
|
112
|
+
/** Existing spaces to give the app */
|
|
113
|
+
readonly spaceIds: ReadonlyArray<string>;
|
|
114
|
+
/** How long the note lasts, overriding what the request asked for. Default: the request's `days`, or 7. */
|
|
115
|
+
readonly days?: number;
|
|
116
|
+
}
|
|
117
|
+
export interface AuthState {
|
|
118
|
+
readonly stage: AuthStage;
|
|
119
|
+
/** Where accounts are being read from */
|
|
120
|
+
readonly place: Place | null;
|
|
121
|
+
readonly accounts: ReadonlyArray<AccountSummary>;
|
|
122
|
+
readonly selectedId: string | null;
|
|
123
|
+
/** Ways into the selected account */
|
|
124
|
+
readonly entry: AccountEntry | null;
|
|
125
|
+
readonly session: WeaveSession | null;
|
|
126
|
+
/** A new account's password, shown once until `codeSaved()` */
|
|
127
|
+
readonly freshCode: string | null;
|
|
128
|
+
/** Something is in progress; buttons should wait */
|
|
129
|
+
readonly busy: boolean;
|
|
130
|
+
readonly error: AuthError | null;
|
|
131
|
+
/** Whether this browser can open a pod at all */
|
|
132
|
+
readonly folderAvailable: boolean;
|
|
133
|
+
/** The phone-pairing link this page was opened with */
|
|
134
|
+
readonly pairing: PairingTicket | null;
|
|
135
|
+
readonly pairingStage: PairingStage | null;
|
|
136
|
+
/** A pod picked while signed in, waiting on what should happen to the data */
|
|
137
|
+
readonly podChoice: {
|
|
138
|
+
readonly pod: Place;
|
|
139
|
+
readonly contents: PodContents;
|
|
140
|
+
readonly from: Place;
|
|
141
|
+
} | null;
|
|
142
|
+
readonly moved: MovedToPod | null;
|
|
143
|
+
}
|
|
144
|
+
export interface WeaveAuth {
|
|
145
|
+
getState(): AuthState;
|
|
146
|
+
/** Called after every change. Returns a function that stops it. */
|
|
147
|
+
subscribe(listener: (state: AuthState) => void): () => void;
|
|
148
|
+
/** Looks for accounts and resumes a kept sign-in. Safe to call more than once. */
|
|
149
|
+
start(): Promise<void>;
|
|
150
|
+
/** Opens a pod. Needs a click. Signed in, it asks what should happen to the data first (`podChoice`). */
|
|
151
|
+
choosePod(): Promise<void>;
|
|
152
|
+
/** Keeps accounts in this browser, and stops using a pod if one was open */
|
|
153
|
+
useBrowser(): Promise<void>;
|
|
154
|
+
/** Back to the where-should-your-data-live question */
|
|
155
|
+
changeStorage(): void;
|
|
156
|
+
select(accountId: string): Promise<void>;
|
|
157
|
+
signInWithCode(code: string): Promise<void>;
|
|
158
|
+
signInWithPassword(password: string): Promise<void>;
|
|
159
|
+
signInWithPasskey(): Promise<void>;
|
|
160
|
+
startCreating(): void;
|
|
161
|
+
showSignIn(): void;
|
|
162
|
+
createAccount(name: string): Promise<void>;
|
|
163
|
+
/** The new password has been saved; carry on in */
|
|
164
|
+
codeSaved(): void;
|
|
165
|
+
acceptPairing(): Promise<void>;
|
|
166
|
+
dismissPairing(): void;
|
|
167
|
+
clearError(): void;
|
|
168
|
+
rename(name: string): Promise<boolean>;
|
|
169
|
+
addPasskey(): Promise<boolean>;
|
|
170
|
+
removeShortcut(kind: 'passkey' | 'passphrase'): Promise<boolean>;
|
|
171
|
+
confirmPod(how: 'combine' | 'switch'): Promise<void>;
|
|
172
|
+
cancelPod(): void;
|
|
173
|
+
/** Removes the copy this browser kept after a move into a pod */
|
|
174
|
+
forgetBrowserCopy(): Promise<void>;
|
|
175
|
+
dismissMoved(): void;
|
|
176
|
+
/** The account password, for handing back to a password manager. Null when signed out. */
|
|
177
|
+
accountPassword(): string | null;
|
|
178
|
+
/** Starts offering this account to a phone */
|
|
179
|
+
offerToPhone(onStage: (stage: PairingStage) => void): Promise<PairingOffer>;
|
|
180
|
+
/**
|
|
181
|
+
* Gives an app access, as the account home: makes any spaces it asked for,
|
|
182
|
+
* signs a note from the account to the app's key for these spaces, and
|
|
183
|
+
* remembers the app as connected. The seed signs here and goes nowhere.
|
|
184
|
+
*/
|
|
185
|
+
grant(choice: GrantChoice): Promise<Omit<Grant, 'home'>>;
|
|
186
|
+
/**
|
|
187
|
+
* Starts using a carrier, as the account home: makes its carry space, fills
|
|
188
|
+
* it with a pass for every space, and remembers it as connected. The
|
|
189
|
+
* carrier gets no key that reads or writes a space.
|
|
190
|
+
*/
|
|
191
|
+
grantCarry(choice: {
|
|
192
|
+
readonly origin: string;
|
|
193
|
+
readonly request: ConnectRequest;
|
|
194
|
+
}): Promise<Omit<CarryGrant, 'home'>>;
|
|
195
|
+
/** Apps this account is connected to from this home, newest first */
|
|
196
|
+
connections(): ReadonlyArray<Connection>;
|
|
197
|
+
/**
|
|
198
|
+
* Other accounts in this place that `origin` is connected to from this home.
|
|
199
|
+
* One browser extension carries one account, so connecting it here moves it
|
|
200
|
+
* off theirs — worth saying before it happens.
|
|
201
|
+
*/
|
|
202
|
+
connectedElsewhere(origin: string): ReadonlyArray<{
|
|
203
|
+
readonly id: string;
|
|
204
|
+
readonly name: string;
|
|
205
|
+
}>;
|
|
206
|
+
/**
|
|
207
|
+
* Disconnects an app: revokes its note in every space it could write in —
|
|
208
|
+
* and, for a whole-account app, in the account registry — so nothing it
|
|
209
|
+
* writes from now on counts, and forgets it. What this home had
|
|
210
|
+
* seen it write stays. What it could already read, it keeps — reading is
|
|
211
|
+
* holding a space's key, and that is not taken back.
|
|
212
|
+
*
|
|
213
|
+
* Disconnecting an app disconnects the agents connected through it too.
|
|
214
|
+
* `{ agent: true }` disconnects only those agents; `{ audience }` only the
|
|
215
|
+
* one with that key.
|
|
216
|
+
*/
|
|
217
|
+
disconnect(origin: string, options?: {
|
|
218
|
+
readonly agent?: boolean;
|
|
219
|
+
readonly audience?: string;
|
|
220
|
+
}): Promise<void>;
|
|
221
|
+
readonly staySignedIn: {
|
|
222
|
+
choice(): StaySignedIn;
|
|
223
|
+
setChoice(choice: StaySignedIn): Promise<void>;
|
|
224
|
+
until(): Date | null;
|
|
225
|
+
};
|
|
226
|
+
signOut(): Promise<void>;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Creates the sign-in flow for this page.
|
|
230
|
+
* @param config Where to connect once signed in, and what to call the app
|
|
231
|
+
*/
|
|
232
|
+
export declare function createWeaveAuth(config?: WeaveAuthConfig): WeaveAuth;
|
|
233
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/session/auth.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEjF,OAAO,EAQL,KAAK,YAAY,EACjB,KAAK,UAAU,EAChB,MAAM,8BAA8B,CAAC;AAItC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,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