@minca/core 0.1.15 → 0.1.17
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 +10 -10
- package/dist/elements/auth-styles.d.ts +1 -1
- package/dist/elements/auth-styles.d.ts.map +1 -1
- package/dist/elements/auth-styles.js +35 -9
- package/dist/elements/auth-styles.js.map +1 -1
- package/dist/elements/minca-auth.d.ts.map +1 -1
- package/dist/elements/minca-auth.js +169 -72
- package/dist/elements/minca-auth.js.map +1 -1
- package/dist/identity/abilities.d.ts +2 -0
- package/dist/identity/abilities.d.ts.map +1 -1
- package/dist/identity/abilities.js +2 -0
- package/dist/identity/abilities.js.map +1 -1
- package/dist/identity/account-vault.d.ts +15 -71
- package/dist/identity/account-vault.d.ts.map +1 -1
- package/dist/identity/account-vault.js +45 -104
- package/dist/identity/account-vault.js.map +1 -1
- package/dist/identity/channel.d.ts +3 -9
- package/dist/identity/channel.d.ts.map +1 -1
- package/dist/identity/channel.js +42 -42
- package/dist/identity/channel.js.map +1 -1
- package/dist/identity/contact-key.d.ts +14 -29
- package/dist/identity/contact-key.d.ts.map +1 -1
- package/dist/identity/contact-key.js +31 -51
- package/dist/identity/contact-key.js.map +1 -1
- package/dist/identity/crypto-p256.d.ts.map +1 -1
- package/dist/identity/crypto-p256.js +39 -53
- package/dist/identity/crypto-p256.js.map +1 -1
- package/dist/identity/hpke.d.ts.map +1 -1
- package/dist/identity/hpke.js +19 -19
- package/dist/identity/hpke.js.map +1 -1
- package/dist/identity/identity-manager.d.ts.map +1 -1
- package/dist/identity/identity-manager.js +1 -2
- package/dist/identity/identity-manager.js.map +1 -1
- package/dist/identity/policy.d.ts.map +1 -1
- package/dist/identity/policy.js +35 -61
- package/dist/identity/policy.js.map +1 -1
- package/dist/identity/recovery-code.d.ts +2 -8
- package/dist/identity/recovery-code.d.ts.map +1 -1
- package/dist/identity/recovery-code.js +4 -11
- package/dist/identity/recovery-code.js.map +1 -1
- package/dist/identity/root-signer.d.ts +1 -6
- package/dist/identity/root-signer.d.ts.map +1 -1
- package/dist/identity/root-signer.js +12 -15
- package/dist/identity/root-signer.js.map +1 -1
- package/dist/identity/ucan.d.ts.map +1 -1
- package/dist/identity/ucan.js +48 -39
- package/dist/identity/ucan.js.map +1 -1
- package/dist/identity/webauthn.d.ts +6 -11
- package/dist/identity/webauthn.d.ts.map +1 -1
- package/dist/identity/webauthn.js +18 -30
- package/dist/identity/webauthn.js.map +1 -1
- package/dist/inbox/inbox.d.ts.map +1 -1
- package/dist/inbox/inbox.js +40 -30
- package/dist/inbox/inbox.js.map +1 -1
- package/dist/inbox/index.d.ts +2 -0
- package/dist/inbox/index.d.ts.map +1 -1
- package/dist/inbox/index.js +1 -0
- package/dist/inbox/index.js.map +1 -1
- package/dist/inbox/names.d.ts +54 -0
- package/dist/inbox/names.d.ts.map +1 -0
- package/dist/inbox/names.js +299 -0
- package/dist/inbox/names.js.map +1 -0
- package/dist/index.d.ts +3 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -12
- package/dist/index.js.map +1 -1
- package/dist/network/mesh.d.ts +7 -20
- package/dist/network/mesh.d.ts.map +1 -1
- package/dist/network/mesh.js +267 -245
- package/dist/network/mesh.js.map +1 -1
- package/dist/network/relay-link.d.ts +31 -0
- package/dist/network/relay-link.d.ts.map +1 -0
- package/dist/network/relay-link.js +62 -0
- package/dist/network/relay-link.js.map +1 -0
- package/dist/network/relay-minca.d.ts.map +1 -1
- package/dist/network/relay-minca.js +11 -49
- package/dist/network/relay-minca.js.map +1 -1
- package/dist/network/relay-nostr.d.ts.map +1 -1
- package/dist/network/relay-nostr.js +23 -63
- package/dist/network/relay-nostr.js.map +1 -1
- package/dist/network/relay-socket.d.ts +1 -1
- package/dist/network/relay-socket.d.ts.map +1 -1
- package/dist/network/relay-socket.js +3 -1
- package/dist/network/relay-socket.js.map +1 -1
- package/dist/network/ws-transport.d.ts.map +1 -1
- package/dist/network/ws-transport.js +3 -0
- package/dist/network/ws-transport.js.map +1 -1
- package/dist/node/actions.d.ts +2 -0
- package/dist/node/actions.d.ts.map +1 -1
- package/dist/node/actions.js +89 -58
- package/dist/node/actions.js.map +1 -1
- package/dist/node/api.d.ts +7 -0
- package/dist/node/api.d.ts.map +1 -1
- package/dist/node/api.js +7 -0
- package/dist/node/api.js.map +1 -1
- package/dist/node/carrier.d.ts +5 -0
- package/dist/node/carrier.d.ts.map +1 -1
- package/dist/node/carrier.js +94 -73
- package/dist/node/carrier.js.map +1 -1
- package/dist/node/copy.d.ts +8 -7
- package/dist/node/copy.d.ts.map +1 -1
- package/dist/node/copy.js +54 -56
- package/dist/node/copy.js.map +1 -1
- package/dist/node/host.d.ts +39 -65
- package/dist/node/host.d.ts.map +1 -1
- package/dist/node/host.js +362 -379
- package/dist/node/host.js.map +1 -1
- package/dist/node/index.d.ts +2 -2
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/dist/node/node-carriers.d.ts +35 -0
- package/dist/node/node-carriers.d.ts.map +1 -0
- package/dist/node/node-carriers.js +567 -0
- package/dist/node/node-carriers.js.map +1 -0
- package/dist/node/node-contacts.d.ts +11 -0
- package/dist/node/node-contacts.d.ts.map +1 -0
- package/dist/node/node-contacts.js +808 -0
- package/dist/node/node-contacts.js.map +1 -0
- package/dist/node/node-context.d.ts +76 -0
- package/dist/node/node-context.d.ts.map +1 -0
- package/dist/node/node-context.js +54 -0
- package/dist/node/node-context.js.map +1 -0
- package/dist/node/node-hosting.d.ts +20 -0
- package/dist/node/node-hosting.d.ts.map +1 -0
- package/dist/node/node-hosting.js +456 -0
- package/dist/node/node-hosting.js.map +1 -0
- package/dist/node/node-records.d.ts +18 -0
- package/dist/node/node-records.d.ts.map +1 -0
- package/dist/node/node-records.js +262 -0
- package/dist/node/node-records.js.map +1 -0
- package/dist/node/node.d.ts.map +1 -1
- package/dist/node/node.js +199 -1990
- package/dist/node/node.js.map +1 -1
- package/dist/node/remote.d.ts +5 -6
- package/dist/node/remote.d.ts.map +1 -1
- package/dist/node/remote.js +272 -260
- package/dist/node/remote.js.map +1 -1
- package/dist/node/space-catalog.d.ts +40 -0
- package/dist/node/space-catalog.d.ts.map +1 -0
- package/dist/node/space-catalog.js +158 -0
- package/dist/node/space-catalog.js.map +1 -0
- package/dist/node/space-checks.d.ts +25 -0
- package/dist/node/space-checks.d.ts.map +1 -0
- package/dist/node/space-checks.js +343 -0
- package/dist/node/space-checks.js.map +1 -0
- package/dist/node/space-history.d.ts +37 -0
- package/dist/node/space-history.d.ts.map +1 -0
- package/dist/node/space-history.js +350 -0
- package/dist/node/space-history.js.map +1 -0
- package/dist/node/space-holding.d.ts +53 -0
- package/dist/node/space-holding.d.ts.map +1 -0
- package/dist/node/space-holding.js +339 -0
- package/dist/node/space-holding.js.map +1 -0
- package/dist/node/space-index.d.ts +41 -0
- package/dist/node/space-index.d.ts.map +1 -0
- package/dist/node/space-index.js +217 -0
- package/dist/node/space-index.js.map +1 -0
- package/dist/node/space-keys.d.ts +34 -0
- package/dist/node/space-keys.d.ts.map +1 -0
- package/dist/node/space-keys.js +309 -0
- package/dist/node/space-keys.js.map +1 -0
- package/dist/node/space-lines.d.ts +33 -0
- package/dist/node/space-lines.d.ts.map +1 -0
- package/dist/node/space-lines.js +145 -0
- package/dist/node/space-lines.js.map +1 -0
- package/dist/node/space-membership.d.ts +69 -0
- package/dist/node/space-membership.d.ts.map +1 -0
- package/dist/node/space-membership.js +242 -0
- package/dist/node/space-membership.js.map +1 -0
- package/dist/node/space-mirrors.d.ts +43 -0
- package/dist/node/space-mirrors.d.ts.map +1 -0
- package/dist/node/space-mirrors.js +125 -0
- package/dist/node/space-mirrors.js.map +1 -0
- package/dist/node/space-peers.d.ts +104 -0
- package/dist/node/space-peers.d.ts.map +1 -0
- package/dist/node/space-peers.js +629 -0
- package/dist/node/space-peers.js.map +1 -0
- package/dist/node/space-profiles.d.ts +18 -0
- package/dist/node/space-profiles.d.ts.map +1 -0
- package/dist/node/space-profiles.js +105 -0
- package/dist/node/space-profiles.js.map +1 -0
- package/dist/node/space-rules.d.ts +29 -0
- package/dist/node/space-rules.d.ts.map +1 -0
- package/dist/node/space-rules.js +144 -0
- package/dist/node/space-rules.js.map +1 -0
- package/dist/node/space-runtime.d.ts +107 -140
- package/dist/node/space-runtime.d.ts.map +1 -1
- package/dist/node/space-runtime.js +331 -3985
- package/dist/node/space-runtime.js.map +1 -1
- package/dist/node/space-standing.d.ts +20 -0
- package/dist/node/space-standing.d.ts.map +1 -0
- package/dist/node/space-standing.js +317 -0
- package/dist/node/space-standing.js.map +1 -0
- package/dist/node/space-versions.d.ts +104 -0
- package/dist/node/space-versions.d.ts.map +1 -0
- package/dist/node/space-versions.js +153 -0
- package/dist/node/space-versions.js.map +1 -0
- package/dist/node/space-warrants.d.ts +25 -0
- package/dist/node/space-warrants.d.ts.map +1 -0
- package/dist/node/space-warrants.js +214 -0
- package/dist/node/space-warrants.js.map +1 -0
- package/dist/node/space-writing.d.ts +74 -0
- package/dist/node/space-writing.d.ts.map +1 -0
- package/dist/node/space-writing.js +442 -0
- package/dist/node/space-writing.js.map +1 -0
- package/dist/node/stores.d.ts +19 -50
- package/dist/node/stores.d.ts.map +1 -1
- package/dist/node/stores.js +14 -33
- package/dist/node/stores.js.map +1 -1
- package/dist/node/types.d.ts +243 -306
- package/dist/node/types.d.ts.map +1 -1
- package/dist/node/usage.d.ts +2 -24
- package/dist/node/usage.d.ts.map +1 -1
- package/dist/node/usage.js +118 -102
- package/dist/node/usage.js.map +1 -1
- package/dist/node/watch-notifications.d.ts.map +1 -1
- package/dist/node/watch-notifications.js +32 -29
- package/dist/node/watch-notifications.js.map +1 -1
- package/dist/node/worker.d.ts +5 -6
- package/dist/node/worker.d.ts.map +1 -1
- package/dist/node/worker.js +80 -72
- package/dist/node/worker.js.map +1 -1
- package/dist/node/writer-keys.d.ts +5 -6
- package/dist/node/writer-keys.d.ts.map +1 -1
- package/dist/node/writer-keys.js +66 -57
- package/dist/node/writer-keys.js.map +1 -1
- package/dist/node/writers.d.ts +12 -19
- package/dist/node/writers.d.ts.map +1 -1
- package/dist/node/writers.js +7 -15
- package/dist/node/writers.js.map +1 -1
- package/dist/privacy/direct.d.ts.map +1 -1
- package/dist/privacy/direct.js +31 -27
- package/dist/privacy/direct.js.map +1 -1
- package/dist/privacy/space-encryption.d.ts.map +1 -1
- package/dist/privacy/space-encryption.js +5 -9
- package/dist/privacy/space-encryption.js.map +1 -1
- package/dist/query/computed.d.ts.map +1 -1
- package/dist/query/computed.js +78 -77
- package/dist/query/computed.js.map +1 -1
- package/dist/query/engine.d.ts +3 -4
- package/dist/query/engine.d.ts.map +1 -1
- package/dist/query/engine.js +93 -86
- package/dist/query/engine.js.map +1 -1
- package/dist/query/filter.d.ts +8 -10
- package/dist/query/filter.d.ts.map +1 -1
- package/dist/query/filter.js +144 -161
- package/dist/query/filter.js.map +1 -1
- package/dist/records/cel-types.d.ts.map +1 -1
- package/dist/records/cel-types.js +13 -27
- package/dist/records/cel-types.js.map +1 -1
- package/dist/records/cel.d.ts.map +1 -1
- package/dist/records/cel.js +177 -242
- package/dist/records/cel.js.map +1 -1
- package/dist/records/rules.d.ts.map +1 -1
- package/dist/records/rules.js +46 -50
- package/dist/records/rules.js.map +1 -1
- package/dist/records/topics.d.ts.map +1 -1
- package/dist/records/topics.js +18 -22
- package/dist/records/topics.js.map +1 -1
- package/dist/schemas/automations.d.ts +8 -15
- package/dist/schemas/automations.d.ts.map +1 -1
- package/dist/schemas/automations.js +203 -165
- package/dist/schemas/automations.js.map +1 -1
- package/dist/schemas/blueprints.d.ts.map +1 -1
- package/dist/schemas/blueprints.js +14 -13
- package/dist/schemas/blueprints.js.map +1 -1
- package/dist/schemas/connectors.d.ts.map +1 -1
- package/dist/schemas/connectors.js +16 -11
- package/dist/schemas/connectors.js.map +1 -1
- package/dist/schemas/contacts.d.ts +57 -0
- package/dist/schemas/contacts.d.ts.map +1 -1
- package/dist/schemas/contacts.js +32 -0
- package/dist/schemas/contacts.js.map +1 -1
- package/dist/schemas/cron.d.ts.map +1 -1
- package/dist/schemas/cron.js +27 -28
- package/dist/schemas/cron.js.map +1 -1
- package/dist/schemas/defined.d.ts +6 -0
- package/dist/schemas/defined.d.ts.map +1 -0
- package/dist/schemas/defined.js +7 -0
- package/dist/schemas/defined.js.map +1 -0
- package/dist/schemas/guides.d.ts +3 -1
- package/dist/schemas/guides.d.ts.map +1 -1
- package/dist/schemas/guides.js +13 -12
- package/dist/schemas/guides.js.map +1 -1
- package/dist/schemas/index.d.ts +2 -2
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +18 -14
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/library/social.d.ts +258 -0
- package/dist/schemas/library/social.d.ts.map +1 -1
- package/dist/schemas/library/social.js +28 -1
- package/dist/schemas/library/social.js.map +1 -1
- package/dist/session/account-hint.d.ts.map +1 -1
- package/dist/session/account-hint.js +8 -5
- package/dist/session/account-hint.js.map +1 -1
- package/dist/session/auth.d.ts +36 -2
- package/dist/session/auth.d.ts.map +1 -1
- package/dist/session/auth.js +95 -2
- package/dist/session/auth.js.map +1 -1
- package/dist/session/connect.d.ts +1 -0
- package/dist/session/connect.d.ts.map +1 -1
- package/dist/session/connect.js +3 -1
- package/dist/session/connect.js.map +1 -1
- package/dist/session/credentials.d.ts +8 -26
- package/dist/session/credentials.d.ts.map +1 -1
- package/dist/session/credentials.js +14 -32
- package/dist/session/credentials.js.map +1 -1
- package/dist/session/hosting.d.ts.map +1 -1
- package/dist/session/hosting.js +8 -2
- package/dist/session/hosting.js.map +1 -1
- package/dist/session/index.d.ts +1 -0
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +1 -0
- package/dist/session/index.js.map +1 -1
- package/dist/session/pairing.d.ts.map +1 -1
- package/dist/session/pairing.js +92 -88
- package/dist/session/pairing.js.map +1 -1
- package/dist/session/password-strength.d.ts.map +1 -1
- package/dist/session/password-strength.js +37 -37
- package/dist/session/password-strength.js.map +1 -1
- package/dist/session/places.d.ts.map +1 -1
- package/dist/session/places.js +18 -13
- package/dist/session/places.js.map +1 -1
- package/dist/session/popup.d.ts +13 -0
- package/dist/session/popup.d.ts.map +1 -0
- package/dist/session/popup.js +23 -0
- package/dist/session/popup.js.map +1 -0
- package/dist/space/constitution.d.ts.map +1 -1
- package/dist/space/constitution.js +22 -29
- package/dist/space/constitution.js.map +1 -1
- package/dist/space/grants.d.ts.map +1 -1
- package/dist/space/grants.js +37 -39
- package/dist/space/grants.js.map +1 -1
- package/dist/space/invite-link.d.ts.map +1 -1
- package/dist/space/invite-link.js +33 -33
- package/dist/space/invite-link.js.map +1 -1
- package/dist/space/own-automations.d.ts +13 -24
- package/dist/space/own-automations.d.ts.map +1 -1
- package/dist/space/own-automations.js +47 -37
- package/dist/space/own-automations.js.map +1 -1
- package/dist/space/presets.d.ts +2 -2
- package/dist/space/presets.d.ts.map +1 -1
- package/dist/space/presets.js +3 -2
- package/dist/space/presets.js.map +1 -1
- package/dist/space/roles.d.ts +56 -80
- package/dist/space/roles.d.ts.map +1 -1
- package/dist/space/roles.js +448 -441
- package/dist/space/roles.js.map +1 -1
- package/dist/space/space-access.d.ts +3 -4
- package/dist/space/space-access.d.ts.map +1 -1
- package/dist/space/space-access.js +3 -8
- package/dist/space/space-access.js.map +1 -1
- package/dist/storage/blob/directory.d.ts.map +1 -1
- package/dist/storage/blob/directory.js +39 -32
- package/dist/storage/blob/directory.js.map +1 -1
- package/dist/storage/blob/s3.d.ts.map +1 -1
- package/dist/storage/blob/s3.js +21 -19
- package/dist/storage/blob/s3.js.map +1 -1
- package/dist/storage/blob-store.d.ts +0 -9
- package/dist/storage/blob-store.d.ts.map +1 -1
- package/dist/storage/directory-access.d.ts +8 -32
- package/dist/storage/directory-access.d.ts.map +1 -1
- package/dist/storage/directory-access.js +11 -36
- package/dist/storage/directory-access.js.map +1 -1
- package/dist/storage/encrypted-adapter.d.ts +12 -32
- package/dist/storage/encrypted-adapter.d.ts.map +1 -1
- package/dist/storage/encrypted-adapter.js +31 -54
- package/dist/storage/encrypted-adapter.js.map +1 -1
- package/dist/storage/folder-adapter.d.ts +12 -26
- package/dist/storage/folder-adapter.d.ts.map +1 -1
- package/dist/storage/folder-adapter.js +37 -54
- package/dist/storage/folder-adapter.js.map +1 -1
- package/dist/storage/folder-reconcile.d.ts +12 -26
- package/dist/storage/folder-reconcile.d.ts.map +1 -1
- package/dist/storage/folder-reconcile.js +39 -48
- package/dist/storage/folder-reconcile.js.map +1 -1
- package/dist/storage/indexeddb-adapter.d.ts +2 -6
- package/dist/storage/indexeddb-adapter.d.ts.map +1 -1
- package/dist/storage/indexeddb-adapter.js +60 -114
- package/dist/storage/indexeddb-adapter.js.map +1 -1
- package/dist/storage/mirror.d.ts +0 -29
- package/dist/storage/mirror.d.ts.map +1 -1
- package/dist/storage/mirror.js +153 -110
- package/dist/storage/mirror.js.map +1 -1
- package/dist/storage/segment.d.ts.map +1 -1
- package/dist/storage/segment.js +3 -7
- package/dist/storage/segment.js.map +1 -1
- package/dist/storage/storage-provider.d.ts +6 -11
- package/dist/storage/storage-provider.d.ts.map +1 -1
- package/dist/storage/storage-provider.js +112 -116
- package/dist/storage/storage-provider.js.map +1 -1
- package/dist/sync/sync-engine.d.ts +10 -44
- package/dist/sync/sync-engine.d.ts.map +1 -1
- package/dist/sync/sync-engine.js +245 -247
- package/dist/sync/sync-engine.js.map +1 -1
- package/dist/sync/sync-messages.d.ts +1 -1
- package/dist/sync/sync-messages.d.ts.map +1 -1
- package/dist/sync/sync-messages.js +1 -1
- package/dist/sync/sync-messages.js.map +1 -1
- package/dist/utils/guards.d.ts +1 -0
- package/dist/utils/guards.d.ts.map +1 -1
- package/dist/utils/guards.js +1 -0
- package/dist/utils/guards.js.map +1 -1
- package/dist/utils/hmac.d.ts +5 -0
- package/dist/utils/hmac.d.ts.map +1 -0
- package/dist/utils/hmac.js +20 -0
- package/dist/utils/hmac.js.map +1 -0
- package/dist/utils/map.d.ts +10 -0
- package/dist/utils/map.d.ts.map +1 -0
- package/dist/utils/map.js +30 -0
- package/dist/utils/map.js.map +1 -0
- package/dist/utils/serial.d.ts +2 -0
- package/dist/utils/serial.d.ts.map +1 -1
- package/dist/utils/serial.js +9 -0
- package/dist/utils/serial.js.map +1 -1
- package/dist/validation/capability-gate.d.ts +7 -15
- package/dist/validation/capability-gate.d.ts.map +1 -1
- package/dist/validation/capability-gate.js +32 -36
- package/dist/validation/capability-gate.js.map +1 -1
- package/dist/validation/crypto-gate.d.ts.map +1 -1
- package/dist/validation/crypto-gate.js +12 -21
- package/dist/validation/crypto-gate.js.map +1 -1
- package/docs/README.md +1 -0
- package/docs/actions.md +32 -25
- package/docs/agents.md +28 -16
- package/docs/automations.md +1 -1
- package/docs/blueprints-and-guides.md +37 -5
- package/docs/building-an-app.md +7 -4
- package/docs/collections.md +3 -3
- package/docs/contacts.md +34 -1
- package/docs/contracts.md +1 -1
- package/docs/direct-messages.md +6 -2
- package/docs/inbox.md +5 -11
- package/docs/node.md +54 -22
- package/docs/records-and-queries.md +1 -1
- package/docs/sign-in.md +54 -26
- package/docs/spaces.md +9 -8
- package/docs/standard-library.md +37 -14
- package/docs/storage.md +5 -6
- package/docs/usernames.md +161 -0
- package/docs/warrants.md +1 -1
- package/package.json +1 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abilities.js","sourceRoot":"","sources":["../../src/identity/abilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAqC,MAAM,WAAW,CAAC;AAG1G,oBAAoB;AACpB,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAC;AAC/B,+BAA+B;AAC/B,MAAM,CAAC,MAAM,eAAe,GAAG,SAAS,CAAC;AACzC,MAAM,CAAC,MAAM,aAAa,GA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vC,IAAI,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAClE,IAAI,GAAG,KAAK,GAAG;QAAE,OAAO,EAAE,CAAC;IAC3B,MAAM,MAAM,GAAe,EAAE,CAAC;IAC9B,KAAK,MAAM,SAAS,IAAI,GAAG,EAAE,CAAC;QAC5B,wDAAwD;QACxD,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,YAAY;YAAE,OAAO,EAAE,CAAC;QACvF,MAAM,KAAK,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;QACrC,IAAI,CAAC,KAAK;YAAE,OAAO,EAAE,CAAC;QACtB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IACD,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC;IAChC,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACrF,CAAC"}
|
|
@@ -4,13 +4,7 @@
|
|
|
4
4
|
* it, one per way of unlocking (a device key gated by a passkey, or a
|
|
5
5
|
* passphrase). The recovery code needs no wrap: it is the seed.
|
|
6
6
|
*/
|
|
7
|
-
/**
|
|
8
|
-
* PBKDF2 rounds for a passphrase wrap.
|
|
9
|
-
*
|
|
10
|
-
* Tuned to roughly a quarter-second in a browser, on the reasoning that this
|
|
11
|
-
* runs once per unlock and the thing it guards is an identity rather than a
|
|
12
|
-
* session.
|
|
13
|
-
*/
|
|
7
|
+
/** PBKDF2 rounds for a passphrase wrap: about a quarter-second in a browser, once per unlock */
|
|
14
8
|
export declare const PASSPHRASE_ITERATIONS = 600000;
|
|
15
9
|
/** Fields every wrap carries, whatever unlocks it */
|
|
16
10
|
interface WrapBase {
|
|
@@ -22,23 +16,10 @@ interface WrapBase {
|
|
|
22
16
|
/** base64url of the envelope around the seed (spec 01 §9.1) */
|
|
23
17
|
readonly sealed: string;
|
|
24
18
|
}
|
|
25
|
-
/**
|
|
26
|
-
* A seed wrapped under a key held on one device.
|
|
27
|
-
*
|
|
28
|
-
* The key is not derived from the passkey — a passkey only yields key material
|
|
29
|
-
* through the PRF extension, which several widely used providers do not
|
|
30
|
-
* implement. It is a random key in this origin's storage, and the passkey in
|
|
31
|
-
* front of it is a user-verification gate rather than the source of the
|
|
32
|
-
* secret. See {@link module:device-key} for what that does and does not
|
|
33
|
-
* protect against.
|
|
34
|
-
*/
|
|
19
|
+
/** A seed wrapped under a random key in one origin's storage, gated by a passkey ({@link module:device-key}) */
|
|
35
20
|
export interface DeviceWrap extends WrapBase {
|
|
36
21
|
readonly kind: 'device';
|
|
37
|
-
/**
|
|
38
|
-
* The origin this belongs to. The key it names lives in that origin's
|
|
39
|
-
* storage, so a wrap from another app is not merely likely to fail — it is
|
|
40
|
-
* unreachable from here.
|
|
41
|
-
*/
|
|
22
|
+
/** The origin whose storage holds its key; no other origin can open it */
|
|
42
23
|
readonly rpId: string;
|
|
43
24
|
/** Which local key opens it. Missing from this device means unopenable here. */
|
|
44
25
|
readonly deviceKeyId: string;
|
|
@@ -64,18 +45,9 @@ export interface AccountVault {
|
|
|
64
45
|
readonly createdAt: string;
|
|
65
46
|
readonly wraps: ReadonlyArray<SeedWrap>;
|
|
66
47
|
}
|
|
67
|
-
/**
|
|
68
|
-
* Whether parsed JSON is a vault. Loose on purpose: the version and a list of
|
|
69
|
-
* wraps; each wrap is checked when something tries to open it.
|
|
70
|
-
*/
|
|
48
|
+
/** Whether parsed JSON is a vault. Loose on purpose: each wrap is checked when opened. */
|
|
71
49
|
export declare function isAccountVault(value: unknown): value is AccountVault;
|
|
72
|
-
/**
|
|
73
|
-
* Wraps a seed under this device's key.
|
|
74
|
-
*
|
|
75
|
-
* The key is random and lives in this origin's storage; the passkey recorded
|
|
76
|
-
* alongside is the gate in front of it, not the source of it. See
|
|
77
|
-
* {@link module:device-key}.
|
|
78
|
-
*/
|
|
50
|
+
/** Wraps a seed under this device's key; the passkey recorded beside it is a gate, not the key's source */
|
|
79
51
|
export declare function wrapSeedWithDeviceKey(seed: Uint8Array, deviceKey: {
|
|
80
52
|
id: string;
|
|
81
53
|
key: CryptoKey;
|
|
@@ -93,55 +65,27 @@ export declare function unwrapSeedWithDeviceKey(wrap: DeviceWrap, deviceKey: Cry
|
|
|
93
65
|
/** Wraps a seed under a passphrase — the portable way back in. */
|
|
94
66
|
export declare function wrapSeedWithPassphrase(seed: Uint8Array, passphrase: string, label?: string): Promise<PassphraseWrap>;
|
|
95
67
|
/**
|
|
96
|
-
* Opens a passphrase wrap. Its
|
|
97
|
-
*
|
|
98
|
-
* {@link PASSPHRASE_ITERATIONS} are refused before any are run.
|
|
68
|
+
* Opens a passphrase wrap. Its salt and rounds are bound into the envelope, so
|
|
69
|
+
* an edited wrap does not open; too few or too many rounds are refused before any run.
|
|
99
70
|
* @param did The vault's DID: the seed inside must derive it
|
|
100
71
|
*/
|
|
101
72
|
export declare function unwrapSeedWithPassphrase(wrap: PassphraseWrap, passphrase: string, did: string): Promise<Uint8Array>;
|
|
102
73
|
/**
|
|
103
|
-
* The
|
|
104
|
-
*
|
|
105
|
-
* extractable, so a page can use it without being able to leak it.
|
|
106
|
-
*
|
|
107
|
-
* Derived from the seed under its own label, beside the account key, so an
|
|
108
|
-
* app given the account key derives nothing that opens local storage.
|
|
74
|
+
* The local key: seals this account's data on this device, never leaves it,
|
|
75
|
+
* and isn't extractable. Its own label, so the account key derives nothing that opens it.
|
|
109
76
|
*/
|
|
110
77
|
export declare function deriveLocalKey(seed: Uint8Array): Promise<CryptoKey>;
|
|
111
|
-
/**
|
|
112
|
-
* The **account key**, 32 bytes: the root of the member keys and of the
|
|
113
|
-
* account's own spaces (the registry, the contacts). What an app given the
|
|
114
|
-
* whole account receives, and a node that follows the registry is given.
|
|
115
|
-
*/
|
|
78
|
+
/** The account key, 32 bytes: the root of member keys and the account's own spaces */
|
|
116
79
|
export declare function deriveAccountKey(seed: Uint8Array): Promise<Uint8Array>;
|
|
117
|
-
/**
|
|
118
|
-
* The device wraps this origin could actually attempt.
|
|
119
|
-
*
|
|
120
|
-
* The key a wrap names lives in the storage of the origin that made it, so one
|
|
121
|
-
* from another app is not merely likely to fail — it is unreachable from here.
|
|
122
|
-
*/
|
|
80
|
+
/** The device wraps this origin can attempt: only its own storage holds their keys */
|
|
123
81
|
export declare function deviceWrapsFor(vault: AccountVault, rpId: string): ReadonlyArray<DeviceWrap>;
|
|
124
|
-
/**
|
|
125
|
-
* What the CLI labels the passphrase it unlocks with unattended. Kept apart
|
|
126
|
-
* from the account's password, so changing one does not remove the other.
|
|
127
|
-
*/
|
|
82
|
+
/** The label of the passphrase the CLI unlocks with unattended, apart from the account's own */
|
|
128
83
|
export declare const CLI_PASSPHRASE_LABEL = "CLI passphrase";
|
|
129
|
-
/**
|
|
130
|
-
* Adds a wrap, replacing any earlier one for the same passkey.
|
|
131
|
-
*
|
|
132
|
-
* Re-registering on an origin should leave one usable wrap rather than a pile of
|
|
133
|
-
* stale ones, and a wrap whose credential is gone is only clutter.
|
|
134
|
-
*/
|
|
84
|
+
/** Adds a wrap, replacing an earlier device wrap for the same origin */
|
|
135
85
|
export declare function withWrap(vault: AccountVault, wrap: SeedWrap): AccountVault;
|
|
136
86
|
/**
|
|
137
|
-
* Assembles a fresh locked account.
|
|
138
|
-
*
|
|
139
|
-
* Pure — it neither generates the seed nor touches the disk, so a caller stays
|
|
140
|
-
* in charge of both the entropy and when it lands.
|
|
141
|
-
*
|
|
142
|
-
* @param params.wraps Shortcuts for getting in. May be empty: the account code
|
|
143
|
-
* is the seed written out, so it opens the account with nothing stored —
|
|
144
|
-
* which is exactly what a brand new account has.
|
|
87
|
+
* Assembles a fresh locked account; generates nothing and writes nothing.
|
|
88
|
+
* @param params.wraps May be empty: the recovery code is the seed, and opens it with nothing stored
|
|
145
89
|
*/
|
|
146
90
|
export declare function createVault(params: {
|
|
147
91
|
did: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-vault.d.ts","sourceRoot":"","sources":["../../src/identity/account-vault.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH
|
|
1
|
+
{"version":3,"file":"account-vault.d.ts","sourceRoot":"","sources":["../../src/identity/account-vault.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH,gGAAgG;AAChG,eAAO,MAAM,qBAAqB,SAAU,CAAC;AAS7C,qDAAqD;AACrD,UAAU,QAAQ;IAChB,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,gHAAgH;AAChH,MAAM,WAAW,UAAW,SAAQ,QAAQ;IAC1C,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,gFAAgF;IAChF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,mDAAmD;IACnD,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,4EAA4E;IAC5E,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,wCAAwC;AACxC,MAAM,WAAW,cAAe,SAAQ,QAAQ;IAC9C,QAAQ,CAAC,IAAI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AwB,CAC5C,IAAI,EAAE,cAAc,EACpB,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,UAAU,CAAC,CAMrB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAEnE;AAED,sFAAsF;AACtF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAEtE;AAED,sFAAsF;AACtF,wBAAgB,cAAc,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,aAAa,CAAC,UAAU,CAAC,CAE3F;AAED,gGAAgG;AAChG,eAAO,MAAM,oBAAoB,mBAAmB,CAAC;AAErD,wEAAwE;AACxE,wBAAgB,QAAQ,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,GAAG,YAAY,CAI1E;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,YAAY,CAQf"}
|
|
@@ -12,13 +12,7 @@ import { openEnvelope, sealEnvelope } from './envelope.js';
|
|
|
12
12
|
import { createIdentityManager } from './identity-manager.js';
|
|
13
13
|
import { RECOVERY_SEED_BYTES } from './recovery-code.js';
|
|
14
14
|
const SALT_BYTES = 16;
|
|
15
|
-
/**
|
|
16
|
-
* PBKDF2 rounds for a passphrase wrap.
|
|
17
|
-
*
|
|
18
|
-
* Tuned to roughly a quarter-second in a browser, on the reasoning that this
|
|
19
|
-
* runs once per unlock and the thing it guards is an identity rather than a
|
|
20
|
-
* session.
|
|
21
|
-
*/
|
|
15
|
+
/** PBKDF2 rounds for a passphrase wrap: about a quarter-second in a browser, once per unlock */
|
|
22
16
|
export const PASSPHRASE_ITERATIONS = 600_000;
|
|
23
17
|
/** More rounds than this are refused: a vault file edited to a huge count would hang the page */
|
|
24
18
|
const MAX_ITERATIONS = 10_000_000;
|
|
@@ -26,64 +20,11 @@ const LOCAL_KEY_INFO = utf8Encode('minca/local-key/v1');
|
|
|
26
20
|
const ACCOUNT_KEY_INFO = utf8Encode('minca/account-key/v1');
|
|
27
21
|
/** The envelope label of a wrap; bound to `{ did, id, kind }`, and a passphrase wrap's `salt` and `iterations` */
|
|
28
22
|
const WRAP_LABEL = 'minca/vault-wrap/v1';
|
|
29
|
-
/**
|
|
30
|
-
* Whether parsed JSON is a vault. Loose on purpose: the version and a list of
|
|
31
|
-
* wraps; each wrap is checked when something tries to open it.
|
|
32
|
-
*/
|
|
23
|
+
/** Whether parsed JSON is a vault. Loose on purpose: each wrap is checked when opened. */
|
|
33
24
|
export function isAccountVault(value) {
|
|
34
25
|
return isRecord(value) && value.version === 1 && Array.isArray(value.wraps);
|
|
35
26
|
}
|
|
36
|
-
/**
|
|
37
|
-
function randomBytes(length) {
|
|
38
|
-
return globalThis.crypto.getRandomValues(new Uint8Array(length));
|
|
39
|
-
}
|
|
40
|
-
/** A short opaque id for a wrap. */
|
|
41
|
-
function wrapId() {
|
|
42
|
-
return base64UrlEncode(randomBytes(8));
|
|
43
|
-
}
|
|
44
|
-
/** The DID a seed derives */
|
|
45
|
-
async function didOfSeed(seed) {
|
|
46
|
-
return (await createIdentityManager().fromSeed(seed)).did;
|
|
47
|
-
}
|
|
48
|
-
/** What a wrap's envelope is bound to: whose seed, which wrap, and how it opens */
|
|
49
|
-
function wrapBound(did, wrap) {
|
|
50
|
-
return wrap.kind === 'passphrase'
|
|
51
|
-
? { did, id: wrap.id, kind: wrap.kind, salt: wrap.salt ?? '', iterations: wrap.iterations ?? 0 }
|
|
52
|
-
: { did, id: wrap.id, kind: wrap.kind };
|
|
53
|
-
}
|
|
54
|
-
const unlockFailed = () => protocolError('VAULT_UNLOCK_FAILED', 'That did not unlock the folder.', 'Check the passphrase, or use your recovery code instead.');
|
|
55
|
-
/**
|
|
56
|
-
* Opens a wrap, and checks what is inside is the seed of `did`: a wrap copied
|
|
57
|
-
* in from another account's vault, or edited, is refused.
|
|
58
|
-
*/
|
|
59
|
-
async function open(wrap, key, did) {
|
|
60
|
-
let seed = null;
|
|
61
|
-
try {
|
|
62
|
-
seed = await openEnvelope(key, WRAP_LABEL, wrapBound(did, wrap), base64UrlDecode(wrap.sealed));
|
|
63
|
-
}
|
|
64
|
-
catch {
|
|
65
|
-
seed = null;
|
|
66
|
-
}
|
|
67
|
-
// AES-GCM authenticates, so a failure is the wrong key, account or wrap rather than corruption.
|
|
68
|
-
if (!seed || seed.length !== RECOVERY_SEED_BYTES || (await didOfSeed(seed)) !== did)
|
|
69
|
-
throw unlockFailed();
|
|
70
|
-
return seed;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Stretches a passphrase into the key that wraps a seed.
|
|
74
|
-
* @param iterations PBKDF2 rounds, read from the wrap so old ones stay openable
|
|
75
|
-
*/
|
|
76
|
-
async function passphraseWrappingKey(passphrase, salt, iterations) {
|
|
77
|
-
const material = await globalThis.crypto.subtle.importKey('raw', bufferSource(utf8Encode(passphrase.normalize('NFKC'))), { name: 'PBKDF2' }, false, ['deriveKey']);
|
|
78
|
-
return globalThis.crypto.subtle.deriveKey({ name: 'PBKDF2', hash: 'SHA-256', salt: bufferSource(salt), iterations }, material, { name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Wraps a seed under this device's key.
|
|
82
|
-
*
|
|
83
|
-
* The key is random and lives in this origin's storage; the passkey recorded
|
|
84
|
-
* alongside is the gate in front of it, not the source of it. See
|
|
85
|
-
* {@link module:device-key}.
|
|
86
|
-
*/
|
|
27
|
+
/** Wraps a seed under this device's key; the passkey recorded beside it is a gate, not the key's source */
|
|
87
28
|
export async function wrapSeedWithDeviceKey(seed, deviceKey, meta) {
|
|
88
29
|
const id = wrapId();
|
|
89
30
|
const bound = wrapBound(await didOfSeed(seed), { id, kind: 'device' });
|
|
@@ -122,9 +63,8 @@ export async function wrapSeedWithPassphrase(seed, passphrase, label = 'Passphra
|
|
|
122
63
|
return { ...unsealed, sealed: base64UrlEncode(await sealEnvelope(key, WRAP_LABEL, bound, seed)) };
|
|
123
64
|
}
|
|
124
65
|
/**
|
|
125
|
-
* Opens a passphrase wrap. Its
|
|
126
|
-
*
|
|
127
|
-
* {@link PASSPHRASE_ITERATIONS} are refused before any are run.
|
|
66
|
+
* Opens a passphrase wrap. Its salt and rounds are bound into the envelope, so
|
|
67
|
+
* an edited wrap does not open; too few or too many rounds are refused before any run.
|
|
128
68
|
* @param did The vault's DID: the seed inside must derive it
|
|
129
69
|
*/
|
|
130
70
|
export async function unwrapSeedWithPassphrase(wrap, passphrase, did) {
|
|
@@ -135,59 +75,30 @@ export async function unwrapSeedWithPassphrase(wrap, passphrase, did) {
|
|
|
135
75
|
return open(wrap, key, did);
|
|
136
76
|
}
|
|
137
77
|
/**
|
|
138
|
-
* The
|
|
139
|
-
*
|
|
140
|
-
* extractable, so a page can use it without being able to leak it.
|
|
141
|
-
*
|
|
142
|
-
* Derived from the seed under its own label, beside the account key, so an
|
|
143
|
-
* app given the account key derives nothing that opens local storage.
|
|
78
|
+
* The local key: seals this account's data on this device, never leaves it,
|
|
79
|
+
* and isn't extractable. Its own label, so the account key derives nothing that opens it.
|
|
144
80
|
*/
|
|
145
|
-
export
|
|
81
|
+
export function deriveLocalKey(seed) {
|
|
146
82
|
return hkdfAesKey(seed, LOCAL_KEY_INFO);
|
|
147
83
|
}
|
|
148
|
-
/**
|
|
149
|
-
|
|
150
|
-
* account's own spaces (the registry, the contacts). What an app given the
|
|
151
|
-
* whole account receives, and a node that follows the registry is given.
|
|
152
|
-
*/
|
|
153
|
-
export async function deriveAccountKey(seed) {
|
|
84
|
+
/** The account key, 32 bytes: the root of member keys and the account's own spaces */
|
|
85
|
+
export function deriveAccountKey(seed) {
|
|
154
86
|
return hkdf(seed, ACCOUNT_KEY_INFO, 32);
|
|
155
87
|
}
|
|
156
|
-
/**
|
|
157
|
-
* The device wraps this origin could actually attempt.
|
|
158
|
-
*
|
|
159
|
-
* The key a wrap names lives in the storage of the origin that made it, so one
|
|
160
|
-
* from another app is not merely likely to fail — it is unreachable from here.
|
|
161
|
-
*/
|
|
88
|
+
/** The device wraps this origin can attempt: only its own storage holds their keys */
|
|
162
89
|
export function deviceWrapsFor(vault, rpId) {
|
|
163
90
|
return vault.wraps.filter((wrap) => wrap.kind === 'device' && wrap.rpId === rpId);
|
|
164
91
|
}
|
|
165
|
-
/**
|
|
166
|
-
* What the CLI labels the passphrase it unlocks with unattended. Kept apart
|
|
167
|
-
* from the account's password, so changing one does not remove the other.
|
|
168
|
-
*/
|
|
92
|
+
/** The label of the passphrase the CLI unlocks with unattended, apart from the account's own */
|
|
169
93
|
export const CLI_PASSPHRASE_LABEL = 'CLI passphrase';
|
|
170
|
-
/**
|
|
171
|
-
* Adds a wrap, replacing any earlier one for the same passkey.
|
|
172
|
-
*
|
|
173
|
-
* Re-registering on an origin should leave one usable wrap rather than a pile of
|
|
174
|
-
* stale ones, and a wrap whose credential is gone is only clutter.
|
|
175
|
-
*/
|
|
94
|
+
/** Adds a wrap, replacing an earlier device wrap for the same origin */
|
|
176
95
|
export function withWrap(vault, wrap) {
|
|
177
|
-
// One device wrap per origin: re-adding the shortcut should replace it, not
|
|
178
|
-
// leave an older one pointing at a key nobody will use again.
|
|
179
96
|
const superseded = (existing) => existing.kind === 'device' && wrap.kind === 'device' && existing.rpId === wrap.rpId;
|
|
180
97
|
return { ...vault, wraps: [...vault.wraps.filter((existing) => !superseded(existing)), wrap] };
|
|
181
98
|
}
|
|
182
99
|
/**
|
|
183
|
-
* Assembles a fresh locked account.
|
|
184
|
-
*
|
|
185
|
-
* Pure — it neither generates the seed nor touches the disk, so a caller stays
|
|
186
|
-
* in charge of both the entropy and when it lands.
|
|
187
|
-
*
|
|
188
|
-
* @param params.wraps Shortcuts for getting in. May be empty: the account code
|
|
189
|
-
* is the seed written out, so it opens the account with nothing stored —
|
|
190
|
-
* which is exactly what a brand new account has.
|
|
100
|
+
* Assembles a fresh locked account; generates nothing and writes nothing.
|
|
101
|
+
* @param params.wraps May be empty: the recovery code is the seed, and opens it with nothing stored
|
|
191
102
|
*/
|
|
192
103
|
export function createVault(params) {
|
|
193
104
|
return {
|
|
@@ -198,4 +109,34 @@ export function createVault(params) {
|
|
|
198
109
|
wraps: params.wraps,
|
|
199
110
|
};
|
|
200
111
|
}
|
|
112
|
+
const randomBytes = (length) => globalThis.crypto.getRandomValues(new Uint8Array(length));
|
|
113
|
+
const wrapId = () => base64UrlEncode(randomBytes(8));
|
|
114
|
+
const didOfSeed = async (seed) => (await createIdentityManager().fromSeed(seed)).did;
|
|
115
|
+
/** What a wrap's envelope is bound to: whose seed, which wrap, and how it opens */
|
|
116
|
+
function wrapBound(did, wrap) {
|
|
117
|
+
return wrap.kind === 'passphrase'
|
|
118
|
+
? { did, id: wrap.id, kind: wrap.kind, salt: wrap.salt ?? '', iterations: wrap.iterations ?? 0 }
|
|
119
|
+
: { did, id: wrap.id, kind: wrap.kind };
|
|
120
|
+
}
|
|
121
|
+
const unlockFailed = () => protocolError('VAULT_UNLOCK_FAILED', 'That did not unlock the folder.', 'Check the passphrase, or use your recovery code instead.');
|
|
122
|
+
/** Opens a wrap, refusing one whose seed doesn't derive `did`: copied from another vault, or edited */
|
|
123
|
+
async function open(wrap, key, did) {
|
|
124
|
+
const seed = await openSealed(wrap, key, did);
|
|
125
|
+
if (!seed || seed.length !== RECOVERY_SEED_BYTES || (await didOfSeed(seed)) !== did)
|
|
126
|
+
throw unlockFailed();
|
|
127
|
+
return seed;
|
|
128
|
+
}
|
|
129
|
+
async function openSealed(wrap, key, did) {
|
|
130
|
+
try {
|
|
131
|
+
return await openEnvelope(key, WRAP_LABEL, wrapBound(did, wrap), base64UrlDecode(wrap.sealed));
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/** Stretches a passphrase into the key that wraps a seed; `iterations` come from the wrap */
|
|
138
|
+
async function passphraseWrappingKey(passphrase, salt, iterations) {
|
|
139
|
+
const material = await globalThis.crypto.subtle.importKey('raw', bufferSource(utf8Encode(passphrase.normalize('NFKC'))), { name: 'PBKDF2' }, false, ['deriveKey']);
|
|
140
|
+
return globalThis.crypto.subtle.deriveKey({ name: 'PBKDF2', hash: 'SHA-256', salt: bufferSource(salt), iterations }, material, { name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']);
|
|
141
|
+
}
|
|
201
142
|
//# sourceMappingURL=account-vault.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-vault.js","sourceRoot":"","sources":["../../src/identity/account-vault.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAc,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB
|
|
1
|
+
{"version":3,"file":"account-vault.js","sourceRoot":"","sources":["../../src/identity/account-vault.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,aAAa,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CAAC,CAAC,EACtD,EAAE,IAAI,EAAE,QAAQ,EAAE,EAClB,KAAK,EACL,CAAC,WAAW,CAAC,CACd,CAAC;IACF,OAAO,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CACvC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,EACzE,QAAQ,EACR,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,EAChC,KAAK,EACL,CAAC,SAAS,EAAE,SAAS,CAAC,CACvB,CAAC;AACJ,CAAC"}
|
|
@@ -26,10 +26,7 @@ export declare const PAIRING_CHANNEL: ChannelKind;
|
|
|
26
26
|
export declare const CODE_CHANNEL: ChannelKind;
|
|
27
27
|
/** Which side: the one that made the secret and shows it, or the one that joins with it */
|
|
28
28
|
export type ChannelSide = 'offer' | 'join';
|
|
29
|
-
/**
|
|
30
|
-
* The room both sides meet in: a hash of the secret, so only someone who has
|
|
31
|
-
* the secret can find it, and a relay sees a new name every time.
|
|
32
|
-
*/
|
|
29
|
+
/** The room both sides meet in: a hash of the secret, so only its holders find it */
|
|
33
30
|
export declare function channelRoom(kind: ChannelKind, secret: Uint8Array): Promise<string>;
|
|
34
31
|
/** An ephemeral ECDH key for one exchange, and its public point */
|
|
35
32
|
export declare function channelKeyPair(): Promise<{
|
|
@@ -50,11 +47,8 @@ export interface Channel {
|
|
|
50
47
|
}
|
|
51
48
|
/**
|
|
52
49
|
* The channel, from this side's private key, both public points and the secret.
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* channel; the shared point goes in too, so a recording opens nothing to
|
|
56
|
-
* someone who learns the secret later; both points go into the labels, so a
|
|
57
|
-
* message sealed for one exchange opens in no other.
|
|
50
|
+
* The secret and the shared point both go into the keys, so neither alone
|
|
51
|
+
* opens a recording; both points go into the labels, binding it to this exchange.
|
|
58
52
|
*/
|
|
59
53
|
export declare function deriveChannel(params: {
|
|
60
54
|
readonly kind: ChannelKind;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../src/identity/channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../src/identity/channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAeH,0FAA0F;AAC1F,MAAM,WAAW,WAAW;IAC1B,mDAAmD;IACnD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,4DAA4D;AAC5D,eAAO,MAAM,eAAe,EAAE,WAI5B,CAAC;AAEH,gGAAgG;AAChG,eAAO,MAAM,YAAY,EAAE,WAIzB,CAAC;AAEH,2FAA2F;AAC3F,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;AAE3C,qFAAqF;AACrF,wBAAsB,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAExF;AAED,mEAAmE;AACnE,wBAAsB,cAAc,IAAI,OAAO,CAAC;IAC9C,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;CAC5B,CAAC,CAID;AAED;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,+DAA+D;IAC/D,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3D,uGAAuG;IACvG,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IAChE,uGAAuG;IACvG,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAC5D;AAID;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE;IAC1C,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,gCAAgC;IAChC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,+BAA+B;IAC/B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;CAC5B,GAAG,OAAO,CAAC,OAAO,CAAC,CAoCnB"}
|
package/dist/identity/channel.js
CHANGED
|
@@ -21,6 +21,7 @@ import { openEnvelope, sealEnvelope } from './envelope.js';
|
|
|
21
21
|
const POINT_BYTES = 65;
|
|
22
22
|
/** Sealed messages longer than this are not tried */
|
|
23
23
|
const MAX_SEALED = 1_000_000;
|
|
24
|
+
const ECDH = { name: 'ECDH', namedCurve: 'P-256' };
|
|
24
25
|
/** Handing an account to a phone (`identity/pairing.ts`) */
|
|
25
26
|
export const PAIRING_CHANNEL = Object.freeze({
|
|
26
27
|
room: 'minca/pairing-room/v1',
|
|
@@ -33,53 +34,45 @@ export const CODE_CHANNEL = Object.freeze({
|
|
|
33
34
|
key: 'minca/code-key/v1',
|
|
34
35
|
message: 'minca/code/v1',
|
|
35
36
|
});
|
|
36
|
-
/**
|
|
37
|
-
* The room both sides meet in: a hash of the secret, so only someone who has
|
|
38
|
-
* the secret can find it, and a relay sees a new name every time.
|
|
39
|
-
*/
|
|
37
|
+
/** The room both sides meet in: a hash of the secret, so only its holders find it */
|
|
40
38
|
export async function channelRoom(kind, secret) {
|
|
41
39
|
return cidFromBytes(concatBytes(utf8Encode(kind.room), secret));
|
|
42
40
|
}
|
|
43
41
|
/** An ephemeral ECDH key for one exchange, and its public point */
|
|
44
42
|
export async function channelKeyPair() {
|
|
45
|
-
const pair = await globalThis.crypto.subtle.generateKey(
|
|
46
|
-
'deriveBits',
|
|
47
|
-
]);
|
|
43
|
+
const pair = await globalThis.crypto.subtle.generateKey(ECDH, false, ['deriveBits']);
|
|
48
44
|
const point = new Uint8Array(await globalThis.crypto.subtle.exportKey('raw', pair.publicKey));
|
|
49
45
|
return { privateKey: pair.privateKey, point };
|
|
50
46
|
}
|
|
51
47
|
const notAKey = () => protocolError('PAIRING_TICKET_UNREADABLE', 'That device sent a key that is not one.');
|
|
52
48
|
/**
|
|
53
49
|
* The channel, from this side's private key, both public points and the secret.
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* channel; the shared point goes in too, so a recording opens nothing to
|
|
57
|
-
* someone who learns the secret later; both points go into the labels, so a
|
|
58
|
-
* message sealed for one exchange opens in no other.
|
|
50
|
+
* The secret and the shared point both go into the keys, so neither alone
|
|
51
|
+
* opens a recording; both points go into the labels, binding it to this exchange.
|
|
59
52
|
*/
|
|
60
53
|
export async function deriveChannel(params) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
throw notAKey();
|
|
64
|
-
}
|
|
65
|
-
let shared;
|
|
66
|
-
try {
|
|
67
|
-
const peer = await globalThis.crypto.subtle.importKey('raw', bufferSource(params.side === 'offer' ? params.join : params.offer), { name: 'ECDH', namedCurve: 'P-256' }, false, []);
|
|
68
|
-
shared = new Uint8Array(await globalThis.crypto.subtle.deriveBits({ name: 'ECDH', public: peer }, params.privateKey, 256));
|
|
69
|
-
}
|
|
70
|
-
catch {
|
|
54
|
+
const { kind, side, offer, join } = params;
|
|
55
|
+
if (!isPoint(offer) || !isPoint(join))
|
|
71
56
|
throw notAKey();
|
|
72
|
-
|
|
73
|
-
const { kind } = params;
|
|
57
|
+
const shared = await sharedPoint(params.privateKey, side === 'offer' ? join : offer);
|
|
74
58
|
const ikm = concatBytes(params.secret, shared);
|
|
75
|
-
const transcript = `|${base64UrlEncode(
|
|
76
|
-
const other =
|
|
77
|
-
const sendKey = await hkdfAesKey(ikm, utf8Encode(`${kind.key}|${
|
|
59
|
+
const transcript = `|${base64UrlEncode(offer)}|${base64UrlEncode(join)}`;
|
|
60
|
+
const other = side === 'offer' ? 'join' : 'offer';
|
|
61
|
+
const sendKey = await hkdfAesKey(ikm, utf8Encode(`${kind.key}|${side}${transcript}`));
|
|
78
62
|
const receiveKey = await hkdfAesKey(ikm, utf8Encode(`${kind.key}|${other}${transcript}`));
|
|
79
63
|
let sent = 0;
|
|
80
64
|
let received = 0;
|
|
81
65
|
// One open at a time, so two messages arriving together are each tried at the count they should have.
|
|
82
66
|
let opening = Promise.resolve();
|
|
67
|
+
async function openNext(type, sealed) {
|
|
68
|
+
const bytes = decodeSealed(sealed);
|
|
69
|
+
if (!bytes)
|
|
70
|
+
return null;
|
|
71
|
+
const plain = await openEnvelope(receiveKey, kind.message, { type, seq: received }, bytes);
|
|
72
|
+
if (plain)
|
|
73
|
+
received += 1;
|
|
74
|
+
return plain;
|
|
75
|
+
}
|
|
83
76
|
return Object.freeze({
|
|
84
77
|
async seal(type, plaintext) {
|
|
85
78
|
const seq = sent;
|
|
@@ -87,25 +80,32 @@ export async function deriveChannel(params) {
|
|
|
87
80
|
return base64UrlEncode(await sealEnvelope(sendKey, kind.message, { type, seq }, plaintext));
|
|
88
81
|
},
|
|
89
82
|
open(type, sealed) {
|
|
90
|
-
const result = opening.then(
|
|
91
|
-
if (typeof sealed !== 'string' || sealed.length > MAX_SEALED)
|
|
92
|
-
return null;
|
|
93
|
-
let bytes;
|
|
94
|
-
try {
|
|
95
|
-
bytes = base64UrlDecode(sealed);
|
|
96
|
-
}
|
|
97
|
-
catch {
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
const plain = await openEnvelope(receiveKey, kind.message, { type, seq: received }, bytes);
|
|
101
|
-
if (plain)
|
|
102
|
-
received += 1;
|
|
103
|
-
return plain;
|
|
104
|
-
});
|
|
83
|
+
const result = opening.then(() => openNext(type, sealed));
|
|
105
84
|
opening = result;
|
|
106
85
|
return result;
|
|
107
86
|
},
|
|
108
87
|
derive: (label, length) => hkdf(ikm, utf8Encode(label + transcript), length),
|
|
109
88
|
});
|
|
110
89
|
}
|
|
90
|
+
const isPoint = (point) => point.length === POINT_BYTES && point[0] === 0x04;
|
|
91
|
+
/** The ECDH shared x coordinate with the other side's point */
|
|
92
|
+
async function sharedPoint(privateKey, theirs) {
|
|
93
|
+
try {
|
|
94
|
+
const peer = await globalThis.crypto.subtle.importKey('raw', bufferSource(theirs), ECDH, false, []);
|
|
95
|
+
return new Uint8Array(await globalThis.crypto.subtle.deriveBits({ name: 'ECDH', public: peer }, privateKey, 256));
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
throw notAKey();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function decodeSealed(sealed) {
|
|
102
|
+
if (typeof sealed !== 'string' || sealed.length > MAX_SEALED)
|
|
103
|
+
return null;
|
|
104
|
+
try {
|
|
105
|
+
return base64UrlDecode(sealed);
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
111
|
//# sourceMappingURL=channel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.js","sourceRoot":"","sources":["../../src/identity/channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACjG,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAA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