@enbox/agent 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +2215 -0
- package/dist/browser.js.map +7 -0
- package/dist/browser.mjs +2215 -0
- package/dist/browser.mjs.map +7 -0
- package/dist/cjs/index.js +8530 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/agent-did-resolver-cache.js +87 -0
- package/dist/esm/agent-did-resolver-cache.js.map +1 -0
- package/dist/esm/bearer-identity.js +41 -0
- package/dist/esm/bearer-identity.js.map +1 -0
- package/dist/esm/connect.js +191 -0
- package/dist/esm/connect.js.map +1 -0
- package/dist/esm/crypto-api.js +346 -0
- package/dist/esm/crypto-api.js.map +1 -0
- package/dist/esm/did-api.js +278 -0
- package/dist/esm/did-api.js.map +1 -0
- package/dist/esm/dwn-api.js +336 -0
- package/dist/esm/dwn-api.js.map +1 -0
- package/dist/esm/dwn-registrar.js +120 -0
- package/dist/esm/dwn-registrar.js.map +1 -0
- package/dist/esm/hd-identity-vault.js +729 -0
- package/dist/esm/hd-identity-vault.js.map +1 -0
- package/dist/esm/identity-api.js +262 -0
- package/dist/esm/identity-api.js.map +1 -0
- package/dist/esm/index.js +23 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/local-key-manager.js +498 -0
- package/dist/esm/local-key-manager.js.map +1 -0
- package/dist/esm/oidc.js +507 -0
- package/dist/esm/oidc.js.map +1 -0
- package/dist/esm/permissions-api.js +322 -0
- package/dist/esm/permissions-api.js.map +1 -0
- package/dist/esm/prototyping/clients/dwn-rpc-types.js +2 -0
- package/dist/esm/prototyping/clients/dwn-rpc-types.js.map +1 -0
- package/dist/esm/prototyping/clients/dwn-server-info-cache-memory.js +74 -0
- package/dist/esm/prototyping/clients/dwn-server-info-cache-memory.js.map +1 -0
- package/dist/esm/prototyping/clients/http-dwn-rpc-client.js +105 -0
- package/dist/esm/prototyping/clients/http-dwn-rpc-client.js.map +1 -0
- package/dist/esm/prototyping/clients/json-rpc-socket.js +150 -0
- package/dist/esm/prototyping/clients/json-rpc-socket.js.map +1 -0
- package/dist/esm/prototyping/clients/json-rpc.js +58 -0
- package/dist/esm/prototyping/clients/json-rpc.js.map +1 -0
- package/dist/esm/prototyping/clients/server-info-types.js +2 -0
- package/dist/esm/prototyping/clients/server-info-types.js.map +1 -0
- package/dist/esm/prototyping/clients/web-socket-clients.js +90 -0
- package/dist/esm/prototyping/clients/web-socket-clients.js.map +1 -0
- package/dist/esm/prototyping/common/object.js +14 -0
- package/dist/esm/prototyping/common/object.js.map +1 -0
- package/dist/esm/prototyping/common/type-utils.js +2 -0
- package/dist/esm/prototyping/common/type-utils.js.map +1 -0
- package/dist/esm/prototyping/crypto/algorithms/aes-gcm.js +147 -0
- package/dist/esm/prototyping/crypto/algorithms/aes-gcm.js.map +1 -0
- package/dist/esm/prototyping/crypto/algorithms/aes-kw.js +137 -0
- package/dist/esm/prototyping/crypto/algorithms/aes-kw.js.map +1 -0
- package/dist/esm/prototyping/crypto/algorithms/ecdsa.js +307 -0
- package/dist/esm/prototyping/crypto/algorithms/ecdsa.js.map +1 -0
- package/dist/esm/prototyping/crypto/algorithms/eddsa.js +264 -0
- package/dist/esm/prototyping/crypto/algorithms/eddsa.js.map +1 -0
- package/dist/esm/prototyping/crypto/algorithms/hkdf.js +39 -0
- package/dist/esm/prototyping/crypto/algorithms/hkdf.js.map +1 -0
- package/dist/esm/prototyping/crypto/algorithms/pbkdf2.js +41 -0
- package/dist/esm/prototyping/crypto/algorithms/pbkdf2.js.map +1 -0
- package/dist/esm/prototyping/crypto/crypto-error.js +41 -0
- package/dist/esm/prototyping/crypto/crypto-error.js.map +1 -0
- package/dist/esm/prototyping/crypto/dsa.js +236 -0
- package/dist/esm/prototyping/crypto/dsa.js.map +1 -0
- package/dist/esm/prototyping/crypto/jose/jwe-compact.js +130 -0
- package/dist/esm/prototyping/crypto/jose/jwe-compact.js.map +1 -0
- package/dist/esm/prototyping/crypto/jose/jwe-flattened.js +294 -0
- package/dist/esm/prototyping/crypto/jose/jwe-flattened.js.map +1 -0
- package/dist/esm/prototyping/crypto/jose/jwe.js +308 -0
- package/dist/esm/prototyping/crypto/jose/jwe.js.map +1 -0
- package/dist/esm/prototyping/crypto/primitives/aes-gcm.js +352 -0
- package/dist/esm/prototyping/crypto/primitives/aes-gcm.js.map +1 -0
- package/dist/esm/prototyping/crypto/primitives/aes-kw.js +247 -0
- package/dist/esm/prototyping/crypto/primitives/aes-kw.js.map +1 -0
- package/dist/esm/prototyping/crypto/primitives/hkdf.js +80 -0
- package/dist/esm/prototyping/crypto/primitives/hkdf.js.map +1 -0
- package/dist/esm/prototyping/crypto/primitives/pbkdf2.js +85 -0
- package/dist/esm/prototyping/crypto/primitives/pbkdf2.js.map +1 -0
- package/dist/esm/prototyping/crypto/types/cipher.js +2 -0
- package/dist/esm/prototyping/crypto/types/cipher.js.map +1 -0
- package/dist/esm/prototyping/crypto/types/crypto-api.js +2 -0
- package/dist/esm/prototyping/crypto/types/crypto-api.js.map +1 -0
- package/dist/esm/prototyping/crypto/types/key-converter.js +2 -0
- package/dist/esm/prototyping/crypto/types/key-converter.js.map +1 -0
- package/dist/esm/prototyping/crypto/types/key-deriver.js +2 -0
- package/dist/esm/prototyping/crypto/types/key-deriver.js.map +1 -0
- package/dist/esm/prototyping/crypto/types/key-io.js +2 -0
- package/dist/esm/prototyping/crypto/types/key-io.js.map +1 -0
- package/dist/esm/prototyping/crypto/types/key-manager.js +2 -0
- package/dist/esm/prototyping/crypto/types/key-manager.js.map +1 -0
- package/dist/esm/prototyping/crypto/types/key-wrapper.js +2 -0
- package/dist/esm/prototyping/crypto/types/key-wrapper.js.map +1 -0
- package/dist/esm/prototyping/crypto/types/params-direct.js +2 -0
- package/dist/esm/prototyping/crypto/types/params-direct.js.map +1 -0
- package/dist/esm/prototyping/crypto/types/params-kms.js +2 -0
- package/dist/esm/prototyping/crypto/types/params-kms.js.map +1 -0
- package/dist/esm/prototyping/crypto/utils.js +19 -0
- package/dist/esm/prototyping/crypto/utils.js.map +1 -0
- package/dist/esm/prototyping/dids/resolver-cache-memory.js +77 -0
- package/dist/esm/prototyping/dids/resolver-cache-memory.js.map +1 -0
- package/dist/esm/prototyping/dids/utils.js +9 -0
- package/dist/esm/prototyping/dids/utils.js.map +1 -0
- package/dist/esm/rpc-client.js +123 -0
- package/dist/esm/rpc-client.js.map +1 -0
- package/dist/esm/store-data-protocols.js +38 -0
- package/dist/esm/store-data-protocols.js.map +1 -0
- package/dist/esm/store-data.js +320 -0
- package/dist/esm/store-data.js.map +1 -0
- package/dist/esm/store-did.js +136 -0
- package/dist/esm/store-did.js.map +1 -0
- package/dist/esm/store-identity.js +140 -0
- package/dist/esm/store-identity.js.map +1 -0
- package/dist/esm/store-key.js +136 -0
- package/dist/esm/store-key.js.map +1 -0
- package/dist/esm/sync-api.js +61 -0
- package/dist/esm/sync-api.js.map +1 -0
- package/dist/esm/sync-engine-level.js +618 -0
- package/dist/esm/sync-engine-level.js.map +1 -0
- package/dist/esm/test-harness.js +239 -0
- package/dist/esm/test-harness.js.map +1 -0
- package/dist/esm/types/agent.js +2 -0
- package/dist/esm/types/agent.js.map +1 -0
- package/dist/esm/types/dwn.js +31 -0
- package/dist/esm/types/dwn.js.map +1 -0
- package/dist/esm/types/identity-vault.js +2 -0
- package/dist/esm/types/identity-vault.js.map +1 -0
- package/dist/esm/types/identity.js +2 -0
- package/dist/esm/types/identity.js.map +1 -0
- package/dist/esm/types/key-manager.js +2 -0
- package/dist/esm/types/key-manager.js.map +1 -0
- package/dist/esm/types/permissions.js +2 -0
- package/dist/esm/types/permissions.js.map +1 -0
- package/dist/esm/types/sync.js +2 -0
- package/dist/esm/types/sync.js.map +1 -0
- package/dist/esm/types/vc.js +5 -0
- package/dist/esm/types/vc.js.map +1 -0
- package/dist/esm/utils-internal.js +147 -0
- package/dist/esm/utils-internal.js.map +1 -0
- package/dist/esm/utils.js +161 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/types/agent-did-resolver-cache.d.ts +30 -0
- package/dist/types/agent-did-resolver-cache.d.ts.map +1 -0
- package/dist/types/bearer-identity.d.ts +31 -0
- package/dist/types/bearer-identity.d.ts.map +1 -0
- package/dist/types/connect.d.ts +88 -0
- package/dist/types/connect.d.ts.map +1 -0
- package/dist/types/crypto-api.d.ts +286 -0
- package/dist/types/crypto-api.d.ts.map +1 -0
- package/dist/types/did-api.d.ts +119 -0
- package/dist/types/did-api.d.ts.map +1 -0
- package/dist/types/dwn-api.d.ts +66 -0
- package/dist/types/dwn-api.d.ts.map +1 -0
- package/dist/types/dwn-registrar.d.ts +29 -0
- package/dist/types/dwn-registrar.d.ts.map +1 -0
- package/dist/types/hd-identity-vault.d.ts +306 -0
- package/dist/types/hd-identity-vault.d.ts.map +1 -0
- package/dist/types/identity-api.d.ts +107 -0
- package/dist/types/identity-api.d.ts.map +1 -0
- package/dist/types/index.d.ts +30 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/local-key-manager.d.ts +311 -0
- package/dist/types/local-key-manager.d.ts.map +1 -0
- package/dist/types/oidc.d.ts +247 -0
- package/dist/types/oidc.d.ts.map +1 -0
- package/dist/types/permissions-api.d.ts +35 -0
- package/dist/types/permissions-api.d.ts.map +1 -0
- package/dist/types/prototyping/clients/dwn-rpc-types.d.ts +45 -0
- package/dist/types/prototyping/clients/dwn-rpc-types.d.ts.map +1 -0
- package/dist/types/prototyping/clients/dwn-server-info-cache-memory.d.ts +57 -0
- package/dist/types/prototyping/clients/dwn-server-info-cache-memory.d.ts.map +1 -0
- package/dist/types/prototyping/clients/http-dwn-rpc-client.d.ts +13 -0
- package/dist/types/prototyping/clients/http-dwn-rpc-client.d.ts.map +1 -0
- package/dist/types/prototyping/clients/json-rpc-socket.d.ts +43 -0
- package/dist/types/prototyping/clients/json-rpc-socket.d.ts.map +1 -0
- package/dist/types/prototyping/clients/json-rpc.d.ts +49 -0
- package/dist/types/prototyping/clients/json-rpc.d.ts.map +1 -0
- package/dist/types/prototyping/clients/server-info-types.d.ts +20 -0
- package/dist/types/prototyping/clients/server-info-types.d.ts.map +1 -0
- package/dist/types/prototyping/clients/web-socket-clients.d.ts +10 -0
- package/dist/types/prototyping/clients/web-socket-clients.d.ts.map +1 -0
- package/dist/types/prototyping/common/object.d.ts +2 -0
- package/dist/types/prototyping/common/object.d.ts.map +1 -0
- package/dist/types/prototyping/common/type-utils.d.ts +7 -0
- package/dist/types/prototyping/common/type-utils.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/algorithms/aes-gcm.d.ts +151 -0
- package/dist/types/prototyping/crypto/algorithms/aes-gcm.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/algorithms/aes-kw.d.ts +109 -0
- package/dist/types/prototyping/crypto/algorithms/aes-kw.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/algorithms/ecdsa.d.ts +160 -0
- package/dist/types/prototyping/crypto/algorithms/ecdsa.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/algorithms/eddsa.d.ts +157 -0
- package/dist/types/prototyping/crypto/algorithms/eddsa.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/algorithms/hkdf.d.ts +21 -0
- package/dist/types/prototyping/crypto/algorithms/hkdf.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/algorithms/pbkdf2.d.ts +21 -0
- package/dist/types/prototyping/crypto/algorithms/pbkdf2.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/crypto-error.d.ts +29 -0
- package/dist/types/prototyping/crypto/crypto-error.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/dsa.d.ts +169 -0
- package/dist/types/prototyping/crypto/dsa.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/jose/jwe-compact.d.ts +135 -0
- package/dist/types/prototyping/crypto/jose/jwe-compact.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/jose/jwe-flattened.d.ts +134 -0
- package/dist/types/prototyping/crypto/jose/jwe-flattened.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/jose/jwe.d.ts +378 -0
- package/dist/types/prototyping/crypto/jose/jwe.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/primitives/aes-gcm.d.ts +245 -0
- package/dist/types/prototyping/crypto/primitives/aes-gcm.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/primitives/aes-kw.d.ts +103 -0
- package/dist/types/prototyping/crypto/primitives/aes-kw.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/primitives/hkdf.d.ts +90 -0
- package/dist/types/prototyping/crypto/primitives/hkdf.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/primitives/pbkdf2.d.ts +84 -0
- package/dist/types/prototyping/crypto/primitives/pbkdf2.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/types/cipher.d.ts +14 -0
- package/dist/types/prototyping/crypto/types/cipher.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/types/crypto-api.d.ts +35 -0
- package/dist/types/prototyping/crypto/types/crypto-api.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/types/key-converter.d.ts +49 -0
- package/dist/types/prototyping/crypto/types/key-converter.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/types/key-deriver.d.ts +50 -0
- package/dist/types/prototyping/crypto/types/key-deriver.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/types/key-io.d.ts +49 -0
- package/dist/types/prototyping/crypto/types/key-io.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/types/key-manager.d.ts +69 -0
- package/dist/types/prototyping/crypto/types/key-manager.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/types/key-wrapper.d.ts +14 -0
- package/dist/types/prototyping/crypto/types/key-wrapper.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/types/params-direct.d.ts +75 -0
- package/dist/types/prototyping/crypto/types/params-direct.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/types/params-kms.d.ts +63 -0
- package/dist/types/prototyping/crypto/types/params-kms.d.ts.map +1 -0
- package/dist/types/prototyping/crypto/utils.d.ts +7 -0
- package/dist/types/prototyping/crypto/utils.d.ts.map +1 -0
- package/dist/types/prototyping/dids/resolver-cache-memory.d.ts +57 -0
- package/dist/types/prototyping/dids/resolver-cache-memory.d.ts.map +1 -0
- package/dist/types/prototyping/dids/utils.d.ts +3 -0
- package/dist/types/prototyping/dids/utils.d.ts.map +1 -0
- package/dist/types/rpc-client.d.ts +51 -0
- package/dist/types/rpc-client.d.ts.map +1 -0
- package/dist/types/store-data-protocols.d.ts +4 -0
- package/dist/types/store-data-protocols.d.ts.map +1 -0
- package/dist/types/store-data.d.ts +95 -0
- package/dist/types/store-data.d.ts.map +1 -0
- package/dist/types/store-did.d.ts +33 -0
- package/dist/types/store-did.d.ts.map +1 -0
- package/dist/types/store-identity.d.ts +34 -0
- package/dist/types/store-identity.d.ts.map +1 -0
- package/dist/types/store-key.d.ts +32 -0
- package/dist/types/store-key.d.ts.map +1 -0
- package/dist/types/sync-api.d.ts +41 -0
- package/dist/types/sync-api.d.ts.map +1 -0
- package/dist/types/sync-engine-level.d.ts +85 -0
- package/dist/types/sync-engine-level.d.ts.map +1 -0
- package/dist/types/test-harness.d.ts +69 -0
- package/dist/types/test-harness.d.ts.map +1 -0
- package/dist/types/types/agent.d.ts +172 -0
- package/dist/types/types/agent.d.ts.map +1 -0
- package/dist/types/types/dwn.d.ts +178 -0
- package/dist/types/types/dwn.d.ts.map +1 -0
- package/dist/types/types/identity-vault.d.ts +129 -0
- package/dist/types/types/identity-vault.d.ts.map +1 -0
- package/dist/types/types/identity.d.ts +16 -0
- package/dist/types/types/identity.d.ts.map +1 -0
- package/dist/types/types/key-manager.d.ts +9 -0
- package/dist/types/types/key-manager.d.ts.map +1 -0
- package/dist/types/types/permissions.d.ts +98 -0
- package/dist/types/types/permissions.d.ts.map +1 -0
- package/dist/types/types/sync.d.ts +66 -0
- package/dist/types/types/sync.d.ts.map +1 -0
- package/dist/types/types/vc.d.ts +7 -0
- package/dist/types/types/vc.d.ts.map +1 -0
- package/dist/types/utils-internal.d.ts +50 -0
- package/dist/types/utils-internal.d.ts.map +1 -0
- package/dist/types/utils.d.ts +37 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/package.json +112 -0
- package/src/agent-did-resolver-cache.ts +95 -0
- package/src/bearer-identity.ts +42 -0
- package/src/connect.ts +296 -0
- package/src/crypto-api.ts +593 -0
- package/src/did-api.ts +429 -0
- package/src/dwn-api.ts +462 -0
- package/src/dwn-registrar.ts +127 -0
- package/src/hd-identity-vault.ts +853 -0
- package/src/identity-api.ts +324 -0
- package/src/index.ts +30 -0
- package/src/local-key-manager.ts +672 -0
- package/src/oidc.ts +857 -0
- package/src/permissions-api.ts +408 -0
- package/src/prototyping/clients/dwn-rpc-types.ts +55 -0
- package/src/prototyping/clients/dwn-server-info-cache-memory.ts +79 -0
- package/src/prototyping/clients/http-dwn-rpc-client.ts +110 -0
- package/src/prototyping/clients/json-rpc-socket.ts +169 -0
- package/src/prototyping/clients/json-rpc.ts +113 -0
- package/src/prototyping/clients/server-info-types.ts +21 -0
- package/src/prototyping/clients/web-socket-clients.ts +100 -0
- package/src/prototyping/common/object.ts +15 -0
- package/src/prototyping/common/type-utils.ts +6 -0
- package/src/prototyping/crypto/algorithms/aes-gcm.ts +211 -0
- package/src/prototyping/crypto/algorithms/aes-kw.ts +164 -0
- package/src/prototyping/crypto/algorithms/ecdsa.ts +365 -0
- package/src/prototyping/crypto/algorithms/eddsa.ts +310 -0
- package/src/prototyping/crypto/algorithms/hkdf.ts +40 -0
- package/src/prototyping/crypto/algorithms/pbkdf2.ts +44 -0
- package/src/prototyping/crypto/crypto-error.ts +45 -0
- package/src/prototyping/crypto/dsa.ts +367 -0
- package/src/prototyping/crypto/jose/jwe-compact.ts +225 -0
- package/src/prototyping/crypto/jose/jwe-flattened.ts +459 -0
- package/src/prototyping/crypto/jose/jwe.ts +653 -0
- package/src/prototyping/crypto/primitives/aes-gcm.ts +374 -0
- package/src/prototyping/crypto/primitives/aes-kw.ts +271 -0
- package/src/prototyping/crypto/primitives/hkdf.ts +121 -0
- package/src/prototyping/crypto/primitives/pbkdf2.ts +116 -0
- package/src/prototyping/crypto/types/cipher.ts +17 -0
- package/src/prototyping/crypto/types/crypto-api.ts +78 -0
- package/src/prototyping/crypto/types/key-converter.ts +53 -0
- package/src/prototyping/crypto/types/key-deriver.ts +56 -0
- package/src/prototyping/crypto/types/key-io.ts +51 -0
- package/src/prototyping/crypto/types/key-manager.ts +83 -0
- package/src/prototyping/crypto/types/key-wrapper.ts +17 -0
- package/src/prototyping/crypto/types/params-direct.ts +95 -0
- package/src/prototyping/crypto/types/params-kms.ts +76 -0
- package/src/prototyping/crypto/utils.ts +41 -0
- package/src/prototyping/dids/resolver-cache-memory.ts +83 -0
- package/src/prototyping/dids/utils.ts +10 -0
- package/src/rpc-client.ts +162 -0
- package/src/store-data-protocols.ts +40 -0
- package/src/store-data.ts +400 -0
- package/src/store-did.ts +105 -0
- package/src/store-identity.ts +109 -0
- package/src/store-key.ts +104 -0
- package/src/sync-api.ts +71 -0
- package/src/sync-engine-level.ts +714 -0
- package/src/test-harness.ts +330 -0
- package/src/types/agent.ts +195 -0
- package/src/types/dwn.ts +278 -0
- package/src/types/identity-vault.ts +137 -0
- package/src/types/identity.ts +18 -0
- package/src/types/key-manager.ts +15 -0
- package/src/types/permissions.ts +115 -0
- package/src/types/sync.ts +58 -0
- package/src/types/vc.ts +7 -0
- package/src/utils-internal.ts +157 -0
- package/src/utils.ts +181 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { DidDocument, DidMetadata, PortableDid, DidMethodApi, DidDhtCreateOptions, DidJwkCreateOptions, DidResolutionResult, DidResolutionOptions, DidVerificationMethod, DidResolverCache } from '@enbox/dids';
|
|
2
|
+
import { BearerDid, UniversalResolver } from '@enbox/dids';
|
|
3
|
+
import type { AgentDataStore } from './store-data.js';
|
|
4
|
+
import type { AgentKeyManager } from './types/key-manager.js';
|
|
5
|
+
import type { ResponseStatus, Web5PlatformAgent } from './types/agent.js';
|
|
6
|
+
export declare enum DidInterface {
|
|
7
|
+
Create = "Create",
|
|
8
|
+
Resolve = "Resolve"
|
|
9
|
+
}
|
|
10
|
+
export interface DidMessageParams {
|
|
11
|
+
[DidInterface.Create]: DidCreateParams;
|
|
12
|
+
[DidInterface.Resolve]: DidResolveParams;
|
|
13
|
+
}
|
|
14
|
+
export interface DidMessageResult {
|
|
15
|
+
[DidInterface.Create]: DidCreateResult;
|
|
16
|
+
[DidInterface.Resolve]: DidResolveResult;
|
|
17
|
+
}
|
|
18
|
+
export type DidCreateResult = {
|
|
19
|
+
uri: string;
|
|
20
|
+
document: DidDocument;
|
|
21
|
+
metadata: DidMetadata;
|
|
22
|
+
};
|
|
23
|
+
export type DidResolveResult = DidResolutionResult;
|
|
24
|
+
export type DidRequest<T extends DidInterface> = {
|
|
25
|
+
messageType: T;
|
|
26
|
+
messageParams: DidMessageParams[T];
|
|
27
|
+
};
|
|
28
|
+
export type DidResolveParams = {
|
|
29
|
+
didUri: string;
|
|
30
|
+
options?: DidResolutionOptions;
|
|
31
|
+
};
|
|
32
|
+
export type DidResponse<T extends DidInterface> = ResponseStatus & {
|
|
33
|
+
result?: DidMessageResult[T];
|
|
34
|
+
};
|
|
35
|
+
export interface DidCreateParams<TKeyManager = AgentKeyManager, TMethod extends keyof DidMethodCreateOptions<TKeyManager> = keyof DidMethodCreateOptions<TKeyManager>> {
|
|
36
|
+
method: TMethod;
|
|
37
|
+
options?: DidMethodCreateOptions<TKeyManager>[TMethod];
|
|
38
|
+
store?: boolean;
|
|
39
|
+
tenant?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface DidMethodCreateOptions<TKeyManager> {
|
|
42
|
+
dht: DidDhtCreateOptions<TKeyManager>;
|
|
43
|
+
jwk: DidJwkCreateOptions<TKeyManager>;
|
|
44
|
+
}
|
|
45
|
+
export interface DidApiParams {
|
|
46
|
+
didMethods: DidMethodApi[];
|
|
47
|
+
agent?: Web5PlatformAgent;
|
|
48
|
+
/**
|
|
49
|
+
* An optional `DidResolverCache` instance used for caching resolved DID documents.
|
|
50
|
+
*
|
|
51
|
+
* Providing a cache implementation can significantly enhance resolution performance by avoiding
|
|
52
|
+
* redundant resolutions for previously resolved DIDs. If omitted, the default is an instance of `AgentDidResolverCache`.
|
|
53
|
+
*
|
|
54
|
+
* `AgentDidResolverCache` keeps a stale copy of the Agent's managed Identity DIDs and only refreshes upon a successful resolution.
|
|
55
|
+
* This allows for quick and offline access to the internal DIDs used by the agent.
|
|
56
|
+
*/
|
|
57
|
+
resolverCache?: DidResolverCache;
|
|
58
|
+
store?: AgentDataStore<PortableDid>;
|
|
59
|
+
}
|
|
60
|
+
export declare function isDidRequest<T extends DidInterface>(didRequest: DidRequest<DidInterface>, messageType: T): didRequest is DidRequest<T>;
|
|
61
|
+
/**
|
|
62
|
+
* This API is used to manage and interact with DIDs within the Web5 Agent framework.
|
|
63
|
+
*
|
|
64
|
+
* If a DWN Data Store is used, the DID information is stored under DID's own tenant by default.
|
|
65
|
+
* If a tenant property is passed, that tenant will be used to store the DID information.
|
|
66
|
+
*/
|
|
67
|
+
export declare class AgentDidApi<TKeyManager extends AgentKeyManager = AgentKeyManager> extends UniversalResolver {
|
|
68
|
+
/**
|
|
69
|
+
* Holds the instance of a `Web5PlatformAgent` that represents the current execution context for
|
|
70
|
+
* the `AgentDidApi`. This agent is used to interact with other Web5 agent components. It's vital
|
|
71
|
+
* to ensure this instance is set to correctly contextualize operations within the broader Web5
|
|
72
|
+
* Agent framework.
|
|
73
|
+
*/
|
|
74
|
+
private _agent?;
|
|
75
|
+
private _didMethods;
|
|
76
|
+
private _store;
|
|
77
|
+
constructor({ agent, didMethods, resolverCache, store }: DidApiParams);
|
|
78
|
+
/**
|
|
79
|
+
* Retrieves the `Web5PlatformAgent` execution context.
|
|
80
|
+
*
|
|
81
|
+
* @returns The `Web5PlatformAgent` instance that represents the current execution context.
|
|
82
|
+
* @throws Will throw an error if the `agent` instance property is undefined.
|
|
83
|
+
*/
|
|
84
|
+
get agent(): Web5PlatformAgent;
|
|
85
|
+
set agent(agent: Web5PlatformAgent);
|
|
86
|
+
create({ method, tenant, options, store }: DidCreateParams<TKeyManager>): Promise<BearerDid>;
|
|
87
|
+
export({ didUri, tenant }: {
|
|
88
|
+
didUri: string;
|
|
89
|
+
tenant?: string;
|
|
90
|
+
}): Promise<PortableDid>;
|
|
91
|
+
get({ didUri, tenant }: {
|
|
92
|
+
didUri: string;
|
|
93
|
+
tenant?: string;
|
|
94
|
+
}): Promise<BearerDid | undefined>;
|
|
95
|
+
getSigningMethod({ didUri, methodId }: {
|
|
96
|
+
didUri: string;
|
|
97
|
+
methodId?: string;
|
|
98
|
+
}): Promise<DidVerificationMethod>;
|
|
99
|
+
update({ tenant, portableDid, publish }: {
|
|
100
|
+
tenant?: string;
|
|
101
|
+
portableDid: PortableDid;
|
|
102
|
+
publish?: boolean;
|
|
103
|
+
}): Promise<BearerDid>;
|
|
104
|
+
import({ portableDid, tenant }: {
|
|
105
|
+
portableDid: PortableDid;
|
|
106
|
+
tenant?: string;
|
|
107
|
+
}): Promise<BearerDid>;
|
|
108
|
+
delete({ didUri, tenant, deleteKey }: {
|
|
109
|
+
didUri: string;
|
|
110
|
+
tenant?: string;
|
|
111
|
+
deleteKey?: boolean;
|
|
112
|
+
}): Promise<void>;
|
|
113
|
+
deleteKeys({ portableDid }: {
|
|
114
|
+
portableDid: PortableDid;
|
|
115
|
+
}): Promise<void>;
|
|
116
|
+
processRequest<T extends DidInterface>(request: DidRequest<T>): Promise<DidResponse<T>>;
|
|
117
|
+
private getMethod;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=did-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"did-api.d.ts","sourceRoot":"","sources":["../../src/did-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,m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U,CAAC,EAAE,WAAW,EAAE,EAAE;QACvC,WAAW,EAAE,WAAW,CAAC;KAC1B,GAAG,OAAO,CAAC,IAAI,CAAC;IAWJ,cAAc,CAAC,CAAC,SAAS,YAAY,EAChD,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAuC1B,OAAO,CAAC,SAAS;CASlB"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Dwn, DwnConfig, GenericMessage } from '@enbox/dwn-sdk-js';
|
|
2
|
+
import type { Web5PlatformAgent } from './types/agent.js';
|
|
3
|
+
import type { DwnMessage, DwnMessagesPermissionScope, DwnPermissionScope, DwnRecordsInterfaces, DwnRecordsPermissionScope, DwnResponse, ProcessDwnRequest, SendDwnRequest } from './types/dwn.js';
|
|
4
|
+
import { DwnInterface } from './types/dwn.js';
|
|
5
|
+
export type DwnMessageWithBlob<T extends DwnInterface> = {
|
|
6
|
+
message: DwnMessage[T];
|
|
7
|
+
data?: Blob;
|
|
8
|
+
};
|
|
9
|
+
export type DwnApiParams = {
|
|
10
|
+
agent?: Web5PlatformAgent;
|
|
11
|
+
dwn: Dwn;
|
|
12
|
+
};
|
|
13
|
+
export interface DwnApiCreateDwnParams extends Partial<DwnConfig> {
|
|
14
|
+
dataPath?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function isDwnRequest<T extends DwnInterface>(dwnRequest: ProcessDwnRequest<DwnInterface>, messageType: T): dwnRequest is ProcessDwnRequest<T>;
|
|
17
|
+
export declare function isDwnMessage<T extends DwnInterface>(messageType: T, message: GenericMessage): message is DwnMessage[T];
|
|
18
|
+
export declare function isRecordsType(messageType: DwnInterface): messageType is DwnRecordsInterfaces;
|
|
19
|
+
export declare function isRecordPermissionScope(scope: DwnPermissionScope): scope is DwnRecordsPermissionScope;
|
|
20
|
+
export declare function isMessagesPermissionScope(scope: DwnPermissionScope): scope is DwnMessagesPermissionScope;
|
|
21
|
+
export declare class AgentDwnApi {
|
|
22
|
+
/**
|
|
23
|
+
* Holds the instance of a `Web5PlatformAgent` that represents the current execution context for
|
|
24
|
+
* the `AgentDwnApi`. This agent is used to interact with other Web5 agent components. It's vital
|
|
25
|
+
* to ensure this instance is set to correctly contextualize operations within the broader Web5
|
|
26
|
+
* Agent framework.
|
|
27
|
+
*/
|
|
28
|
+
private _agent?;
|
|
29
|
+
/**
|
|
30
|
+
* The DWN instance to use for this API.
|
|
31
|
+
*/
|
|
32
|
+
private _dwn;
|
|
33
|
+
constructor({ agent, dwn }: DwnApiParams);
|
|
34
|
+
/**
|
|
35
|
+
* Retrieves the `Web5PlatformAgent` execution context.
|
|
36
|
+
*
|
|
37
|
+
* @returns The `Web5PlatformAgent` instance that represents the current execution context.
|
|
38
|
+
* @throws Will throw an error if the `agent` instance property is undefined.
|
|
39
|
+
*/
|
|
40
|
+
get agent(): Web5PlatformAgent;
|
|
41
|
+
set agent(agent: Web5PlatformAgent);
|
|
42
|
+
/**
|
|
43
|
+
* Public getter for the DWN instance used by this API.
|
|
44
|
+
*
|
|
45
|
+
* Notes:
|
|
46
|
+
* - This getter is public to allow advanced developers to access the DWN instance directly.
|
|
47
|
+
* However, it is recommended to use the `processRequest` method to interact with the DWN
|
|
48
|
+
* instance to ensure that the DWN message is constructed correctly.
|
|
49
|
+
* - The getter is named `node` to avoid confusion with the `dwn` property of the
|
|
50
|
+
* `Web5PlatformAgent`. In other words, so that a developer can call `agent.dwn.node` to access
|
|
51
|
+
* the DWN instance and not `agent.dwn.dwn`.
|
|
52
|
+
*/
|
|
53
|
+
get node(): Dwn;
|
|
54
|
+
static createDwn({ dataPath, dataStore, didResolver, eventLog, eventStream, messageStore, tenantGate, resumableTaskStore }: DwnApiCreateDwnParams): Promise<Dwn>;
|
|
55
|
+
processRequest<T extends DwnInterface>(request: ProcessDwnRequest<T>): Promise<DwnResponse<T>>;
|
|
56
|
+
sendRequest<T extends DwnInterface>(request: SendDwnRequest<T>): Promise<DwnResponse<T>>;
|
|
57
|
+
private sendDwnRpcRequest;
|
|
58
|
+
private constructDwnMessage;
|
|
59
|
+
private hasGrantParams;
|
|
60
|
+
private getSigner;
|
|
61
|
+
/**
|
|
62
|
+
* FURTHER REFACTORING NEEDED BELOW THIS LINE
|
|
63
|
+
*/
|
|
64
|
+
private getDwnMessage;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=dwn-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dwn-api.d.ts","sourceRoot":"","sources":["../../src/dwn-api.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,GAAG,EACH,SAAS,EAKT,cAAc,EAIf,MAAM,mBAAmB,CAAC;AAM3B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EACV,UAAU,EAIV,0BAA0B,EAE1B,kBAAkB,EAClB,oBAAoB,EACpB,yBAAyB,EACzB,WAAW,EAGX,iBAAiB,EACjB,cAAc,EACf,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,YAAY,EAA0B,MAAM,gBAAgB,CAAC;AAGtE,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,YAAY,IAAI;IACvD,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACvB,IAAI,CAAC,EAAE,IAAI,CAAC;CACb,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,GAAG,EAAE,GAAG,CAAC;CACV,CAAA;AAED,MAAM,WAAW,qBAAsB,SAAQ,OAAO,CAAC,SAAS,CAAC;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,YAAY,CAAC,CAAC,SAAS,YAAY,EACjD,UAAU,EAAE,iBAAiB,CAAC,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC,GAC1D,UAAU,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAE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YAEW,aAAa;CAgC5B"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A client for registering tenants with a DWN.
|
|
3
|
+
*/
|
|
4
|
+
export declare class DwnRegistrar {
|
|
5
|
+
/**
|
|
6
|
+
* Registers a new tenant with the given DWN.
|
|
7
|
+
* NOTE: Assumes the user has already accepted the terms of service.
|
|
8
|
+
* NOTE: Currently the DWN Server from `dwn-server` does not require user signature.
|
|
9
|
+
* TODO: bring in types from `dwn-server`.
|
|
10
|
+
*/
|
|
11
|
+
static registerTenant(dwnEndpoint: string, did: string): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Computes the SHA-256 hash of the given array of strings.
|
|
14
|
+
*/
|
|
15
|
+
static hashAsHexString(input: string): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Finds a response nonce that qualifies the difficulty requirement for the given proof-of-work challenge and request data.
|
|
18
|
+
*/
|
|
19
|
+
static findQualifiedResponseNonce(input: {
|
|
20
|
+
maximumAllowedHashValue: string;
|
|
21
|
+
challengeNonce: string;
|
|
22
|
+
requestData: string;
|
|
23
|
+
}): Promise<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Generates 32 random bytes expressed as a HEX string.
|
|
26
|
+
*/
|
|
27
|
+
static generateNonce(): Promise<string>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=dwn-registrar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dwn-registrar.d.ts","sourceRoot":"","sources":["../../src/dwn-registrar.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,qBAAa,YAAY;IACvB;;;;;OAKG;WACiB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA6DnF;;OAEG;WACiB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAMnE;;OAEG;WACiB,0BAA0B,CAAC,KAAK,EAAE;QACpD,uBAAuB,EAAE,MAAM,CAAC;QAChC,cAAc,EAAE,MAAM,CAAC;QACvB,WAAW,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO,CAAC,MAAM,CAAC;IA2BnB;;OAEG;WACiB,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;CAKrD"}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { BearerDid } from '@enbox/dids';
|
|
2
|
+
import type { IdentityVaultBackup, IdentityVaultStatus, IdentityVaultParams, IdentityVault } from './types/identity-vault.js';
|
|
3
|
+
import { AgentCryptoApi } from './crypto-api.js';
|
|
4
|
+
/**
|
|
5
|
+
* Extended initialization parameters for HdIdentityVault, including an optional recovery phrase
|
|
6
|
+
* that can be used to derive keys to encrypt the vault and generate a DID.
|
|
7
|
+
*/
|
|
8
|
+
export type HdIdentityVaultInitializeParams = {
|
|
9
|
+
/**
|
|
10
|
+
* The password used to secure the vault.
|
|
11
|
+
*
|
|
12
|
+
* The password selected should be strong and securely managed to prevent unauthorized access.
|
|
13
|
+
*/
|
|
14
|
+
password: string;
|
|
15
|
+
/**
|
|
16
|
+
* An optional recovery phrase used to derive the cryptographic keys for the vault.
|
|
17
|
+
*
|
|
18
|
+
* Providing a recovery phrase can be used to recover the vault's content or establish a
|
|
19
|
+
* deterministic key generation scheme. If not provided, a new recovery phrase will be generated
|
|
20
|
+
* during the initialization process.
|
|
21
|
+
*/
|
|
22
|
+
recoveryPhrase?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Optional dwnEndpoints to register didService endpoints during HdIdentityVault initialization
|
|
25
|
+
*
|
|
26
|
+
* The dwnEndpoints are used to register a DWN endpoint during DidDht.create(). This allows the
|
|
27
|
+
* agent to properly recover connectedDids from DWN. Also, this pattern can be used on the server
|
|
28
|
+
* side in place of the agentDid-->connectedDids pattern.
|
|
29
|
+
*/
|
|
30
|
+
dwnEndpoints?: string[];
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The `HdIdentityVault` class provides secure storage and management of identity data.
|
|
34
|
+
*
|
|
35
|
+
* The `HdIdentityVault` class implements the `IdentityVault` interface, providing secure storage
|
|
36
|
+
* and management of identity data with an added layer of security using Hierarchical Deterministic
|
|
37
|
+
* (HD) key derivation based on the SLIP-0010 standard for Ed25519 keys. It enhances identity
|
|
38
|
+
* protection by generating and securing the identity using a derived HD key, allowing for the
|
|
39
|
+
* deterministic regeneration of keys from a recovery phrase.
|
|
40
|
+
*
|
|
41
|
+
* The vault is capable of:
|
|
42
|
+
* - Secure initialization with a password and an optional recovery phrase, employing HD key
|
|
43
|
+
* derivation.
|
|
44
|
+
* - Encrypting the identity data using a derived content encryption key (CEK) which is securely
|
|
45
|
+
* encrypted and stored, accessible only by the correct password.
|
|
46
|
+
* - Securely backing up and restoring the vault’s contents, including the HD-derived keys and
|
|
47
|
+
* associated DID.
|
|
48
|
+
* - Locking and unlocking the vault, which encrypts and decrypts the CEK for secure access to the
|
|
49
|
+
* vault's contents.
|
|
50
|
+
* - Managing the DID associated with the identity, providing a secure identity layer for
|
|
51
|
+
* applications.
|
|
52
|
+
*
|
|
53
|
+
* Usage involves initializing the vault with a secure password (and optionally a recovery phrase),
|
|
54
|
+
* which then allows for the secure storage, backup, and retrieval of the identity data.
|
|
55
|
+
*
|
|
56
|
+
* Note: Ensure the password is strong and securely managed, as it is crucial for the security of the
|
|
57
|
+
* vault's encrypted contents.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const vault = new HdIdentityVault();
|
|
62
|
+
* await vault.initialize({ password: 'secure-unique-phrase', recoveryPhrase: 'twelve words ...' });
|
|
63
|
+
* const backup = await vault.backup();
|
|
64
|
+
* await vault.restore({ backup, password: 'secure-unique-phrase' });
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare class HdIdentityVault implements IdentityVault<{
|
|
68
|
+
InitializeResult: string;
|
|
69
|
+
}> {
|
|
70
|
+
/** Provides cryptographic functions needed for secure storage and management of the vault. */
|
|
71
|
+
crypto: AgentCryptoApi;
|
|
72
|
+
/** Determines the computational intensity of the key derivation process. */
|
|
73
|
+
private _keyDerivationWorkFactor;
|
|
74
|
+
/** The underlying key-value store for the vault's encrypted content. */
|
|
75
|
+
private _store;
|
|
76
|
+
/** The cryptographic key used to encrypt and decrypt the vault's content securely. */
|
|
77
|
+
private _contentEncryptionKey;
|
|
78
|
+
/**
|
|
79
|
+
* Constructs an instance of `HdIdentityVault`, initializing the key derivation factor and data
|
|
80
|
+
* store. It sets the default key derivation work factor and initializes the internal data store,
|
|
81
|
+
* either with the provided store or a default in-memory store. It also establishes the initial
|
|
82
|
+
* status of the vault as uninitialized and locked.
|
|
83
|
+
*
|
|
84
|
+
* @param params - Optional parameters when constructing a vault instance.
|
|
85
|
+
* @param params.keyDerivationWorkFactor - Optionally set the computational effort for key derivation.
|
|
86
|
+
* @param params.store - Optionally specify a custom key-value store for vault data.
|
|
87
|
+
*/
|
|
88
|
+
constructor({ keyDerivationWorkFactor, store }?: IdentityVaultParams);
|
|
89
|
+
/**
|
|
90
|
+
* Creates a backup of the vault's current state, including the encrypted DID and content
|
|
91
|
+
* encryption key, and returns it as an `IdentityVaultBackup` object. The backup includes a
|
|
92
|
+
* Base64Url-encoded string representing the vault's encrypted data, encapsulating the
|
|
93
|
+
* {@link PortableDid}, the content encryption key, and the vault's status.
|
|
94
|
+
*
|
|
95
|
+
* This method ensures that the vault is initialized and unlocked before proceeding with the
|
|
96
|
+
* backup operation.
|
|
97
|
+
*
|
|
98
|
+
* @throws Error if the vault is not initialized or is locked, preventing the backup.
|
|
99
|
+
* @returns A promise that resolves to the `IdentityVaultBackup` object containing the vault's
|
|
100
|
+
* encrypted backup data.
|
|
101
|
+
*/
|
|
102
|
+
backup(): Promise<IdentityVaultBackup>;
|
|
103
|
+
/**
|
|
104
|
+
* Changes the password used to secure the vault.
|
|
105
|
+
*
|
|
106
|
+
* This method decrypts the existing content encryption key (CEK) with the old password, then
|
|
107
|
+
* re-encrypts it with the new password, updating the vault's stored encrypted CEK. It ensures
|
|
108
|
+
* that the vault is initialized and unlocks the vault if the password is successfully changed.
|
|
109
|
+
*
|
|
110
|
+
* @param params - Parameters required for changing the vault password.
|
|
111
|
+
* @param params.oldPassword - The current password used to unlock the vault.
|
|
112
|
+
* @param params.newPassword - The new password to replace the existing one.
|
|
113
|
+
* @throws Error if the vault is not initialized or the old password is incorrect.
|
|
114
|
+
* @returns A promise that resolves when the password change is complete.
|
|
115
|
+
*/
|
|
116
|
+
changePassword({ oldPassword, newPassword }: {
|
|
117
|
+
oldPassword: string;
|
|
118
|
+
newPassword: string;
|
|
119
|
+
}): Promise<void>;
|
|
120
|
+
/**
|
|
121
|
+
* Retrieves the DID (Decentralized Identifier) associated with the vault.
|
|
122
|
+
*
|
|
123
|
+
* This method ensures the vault is initialized and unlocked before decrypting and returning the
|
|
124
|
+
* DID. The DID is stored encrypted and is decrypted using the vault's content encryption key.
|
|
125
|
+
*
|
|
126
|
+
* @throws Error if the vault is not initialized, is locked, or the DID cannot be decrypted.
|
|
127
|
+
* @returns A promise that resolves with a {@link BearerDid}.
|
|
128
|
+
*/
|
|
129
|
+
getDid(): Promise<BearerDid>;
|
|
130
|
+
/**
|
|
131
|
+
* Fetches the current status of the `HdIdentityVault`, providing details on whether it's
|
|
132
|
+
* initialized and the timestamps of the last backup and restore operations.
|
|
133
|
+
*
|
|
134
|
+
* @returns A promise that resolves with the current status of the `HdIdentityVault`, detailing
|
|
135
|
+
* its initialization, lock state, and the timestamps of the last backup and restore.
|
|
136
|
+
*/
|
|
137
|
+
getStatus(): Promise<IdentityVaultStatus>;
|
|
138
|
+
/**
|
|
139
|
+
* Initializes the `HdIdentityVault` with a password and an optional recovery phrase.
|
|
140
|
+
*
|
|
141
|
+
* If a recovery phrase is not provided, a new one is generated. This process sets up the vault,
|
|
142
|
+
* deriving the necessary cryptographic keys and preparing the vault for use. It ensures the vault
|
|
143
|
+
* is ready to securely store and manage identity data.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```ts
|
|
147
|
+
* const identityVault = new HdIdentityVault();
|
|
148
|
+
* const recoveryPhrase = await identityVault.initialize({
|
|
149
|
+
* password: 'your-secure-phrase'
|
|
150
|
+
* });
|
|
151
|
+
* console.log('Vault initialized. Recovery phrase:', recoveryPhrase);
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* @param params - The initialization parameters.
|
|
155
|
+
* @param params.password - The password used to secure the vault.
|
|
156
|
+
* @param params.recoveryPhrase - An optional 12-word recovery phrase for key derivation. If
|
|
157
|
+
* omitted, a new recovery is generated.
|
|
158
|
+
* @returns A promise that resolves with the recovery phrase used during the initialization, which
|
|
159
|
+
* should be securely stored by the user.
|
|
160
|
+
*/
|
|
161
|
+
initialize({ password, recoveryPhrase, dwnEndpoints }: HdIdentityVaultInitializeParams): Promise<string>;
|
|
162
|
+
/**
|
|
163
|
+
* Determines whether the vault has been initialized.
|
|
164
|
+
*
|
|
165
|
+
* This method checks the vault's current status to determine if it has been
|
|
166
|
+
* initialized. Initialization is a prerequisite for most operations on the vault,
|
|
167
|
+
* ensuring that it is ready for use.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```ts
|
|
171
|
+
* const isInitialized = await identityVault.isInitialized();
|
|
172
|
+
* console.log('Is the vault initialized?', isInitialized);
|
|
173
|
+
* ```
|
|
174
|
+
*
|
|
175
|
+
* @returns A promise that resolves to `true` if the vault has been initialized, otherwise `false`.
|
|
176
|
+
*/
|
|
177
|
+
isInitialized(): Promise<boolean>;
|
|
178
|
+
/**
|
|
179
|
+
* Checks if the vault is currently locked.
|
|
180
|
+
*
|
|
181
|
+
* This method assesses the vault's current state to determine if it is locked.
|
|
182
|
+
* A locked vault restricts access to its contents, requiring the correct password
|
|
183
|
+
* to unlock and access the stored identity data. The vault must be unlocked to
|
|
184
|
+
* perform operations that access or modify its contents.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```ts
|
|
188
|
+
* const isLocked = await identityVault.isLocked();
|
|
189
|
+
* console.log('Is the vault locked?', isLocked);
|
|
190
|
+
* ```
|
|
191
|
+
*
|
|
192
|
+
* @returns `true` if the vault is locked, otherwise `false`.
|
|
193
|
+
*/
|
|
194
|
+
isLocked(): boolean;
|
|
195
|
+
/**
|
|
196
|
+
* Locks the `HdIdentityVault`, securing its contents by clearing the in-memory encryption key.
|
|
197
|
+
*
|
|
198
|
+
* This method ensures that the vault's sensitive data cannot be accessed without unlocking the
|
|
199
|
+
* vault again with the correct password. It's an essential security feature for safeguarding
|
|
200
|
+
* the vault's contents against unauthorized access.
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```ts
|
|
204
|
+
* const identityVault = new HdIdentityVault();
|
|
205
|
+
* await identityVault.lock();
|
|
206
|
+
* console.log('Vault is now locked.');
|
|
207
|
+
* ```
|
|
208
|
+
* @throws An error if the identity vault has not been initialized.
|
|
209
|
+
* @returns A promise that resolves when the vault is successfully locked.
|
|
210
|
+
*/
|
|
211
|
+
lock(): Promise<void>;
|
|
212
|
+
/**
|
|
213
|
+
* Restores the vault's data from a backup object, decrypting and reinitializing the vault's
|
|
214
|
+
* content with the provided backup data.
|
|
215
|
+
*
|
|
216
|
+
* This operation is crucial for data recovery scenarios, allowing users to regain access to their
|
|
217
|
+
* encrypted data using a previously saved backup and their password.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```ts
|
|
221
|
+
* const identityVault = new HdIdentityVault();
|
|
222
|
+
* await identityVault.initialize({ password: 'your-secure-phrase' });
|
|
223
|
+
* // Create a backup of the vault's contents.
|
|
224
|
+
* const backup = await identityVault.backup();
|
|
225
|
+
* // Restore the vault with the same password.
|
|
226
|
+
* await identityVault.restore({ backup: backup, password: 'your-secure-phrase' });
|
|
227
|
+
* console.log('Vault restored successfully.');
|
|
228
|
+
* ```
|
|
229
|
+
*
|
|
230
|
+
* @param params - The parameters required for the restore operation.
|
|
231
|
+
* @param params.backup - The backup object containing the encrypted vault data.
|
|
232
|
+
* @param params.password - The password used to encrypt the backup, necessary for decryption.
|
|
233
|
+
* @returns A promise that resolves when the vault has been successfully restored.
|
|
234
|
+
* @throws An error if the backup object is invalid or if the password is incorrect.
|
|
235
|
+
*/
|
|
236
|
+
restore({ backup, password }: {
|
|
237
|
+
backup: IdentityVaultBackup;
|
|
238
|
+
password: string;
|
|
239
|
+
}): Promise<void>;
|
|
240
|
+
/**
|
|
241
|
+
* Unlocks the vault by decrypting the stored content encryption key (CEK) using the provided
|
|
242
|
+
* password.
|
|
243
|
+
*
|
|
244
|
+
* This method is essential for accessing the vault's encrypted contents, enabling the decryption
|
|
245
|
+
* of stored data and the execution of further operations requiring the vault to be unlocked.
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* ```ts
|
|
249
|
+
* const identityVault = new HdIdentityVault();
|
|
250
|
+
* await identityVault.initialize({ password: 'your-initial-phrase' });
|
|
251
|
+
* // Unlock the vault with the correct password before accessing its contents
|
|
252
|
+
* await identityVault.unlock({ password: 'your-initial-phrase' });
|
|
253
|
+
* console.log('Vault unlocked successfully.');
|
|
254
|
+
* ```
|
|
255
|
+
*
|
|
256
|
+
*
|
|
257
|
+
* @param params - The parameters required for the unlock operation.
|
|
258
|
+
* @param params.password - The password used to encrypt the vault's CEK, necessary for
|
|
259
|
+
* decryption.
|
|
260
|
+
* @returns A promise that resolves when the vault has been successfully unlocked.
|
|
261
|
+
* @throws An error if the vault has not been initialized or if the provided password is
|
|
262
|
+
* incorrect.
|
|
263
|
+
*/
|
|
264
|
+
unlock({ password }: {
|
|
265
|
+
password: string;
|
|
266
|
+
}): Promise<void>;
|
|
267
|
+
/**
|
|
268
|
+
* Retrieves the Decentralized Identifier (DID) associated with the identity vault from the vault
|
|
269
|
+
* store.
|
|
270
|
+
*
|
|
271
|
+
* This DID is encrypted in compact JWE format and needs to be decrypted after the vault is
|
|
272
|
+
* unlocked. The method is intended to be used internally within the HdIdentityVault class to access
|
|
273
|
+
* the encrypted PortableDid.
|
|
274
|
+
*
|
|
275
|
+
* @returns A promise that resolves to the encrypted DID stored in the vault as a compact JWE.
|
|
276
|
+
* @throws Will throw an error if the DID cannot be retrieved from the vault.
|
|
277
|
+
*/
|
|
278
|
+
private getStoredDid;
|
|
279
|
+
/**
|
|
280
|
+
* Retrieves the encrypted Content Encryption Key (CEK) from the vault's storage.
|
|
281
|
+
*
|
|
282
|
+
* This CEK is used for encrypting and decrypting the vault's contents. It is stored as a
|
|
283
|
+
* compact JWE and should be decrypted with the user's password to be used for further
|
|
284
|
+
* cryptographic operations.
|
|
285
|
+
*
|
|
286
|
+
* @returns A promise that resolves to the stored CEK as a string in compact JWE format.
|
|
287
|
+
* @throws Will throw an error if the CEK cannot be retrieved, indicating potential issues with
|
|
288
|
+
* the vault's integrity or state.
|
|
289
|
+
*/
|
|
290
|
+
private getStoredContentEncryptionKey;
|
|
291
|
+
/**
|
|
292
|
+
* Updates the status of the `HdIdentityVault`, reflecting changes in its initialization, lock
|
|
293
|
+
* state, and the timestamps of the last backup and restore operations.
|
|
294
|
+
*
|
|
295
|
+
* This method directly manipulates the internal state stored in the vault's key-value store.
|
|
296
|
+
*
|
|
297
|
+
* @param params - The status properties to be updated.
|
|
298
|
+
* @param params.initialized - Updates the initialization state of the vault.
|
|
299
|
+
* @param params.lastBackup - Updates the timestamp of the last successful backup.
|
|
300
|
+
* @param params.lastRestore - Updates the timestamp of the last successful restore.
|
|
301
|
+
* @returns A promise that resolves to a boolean indicating successful status update.
|
|
302
|
+
* @throws Will throw an error if the status cannot be updated in the key-value store.
|
|
303
|
+
*/
|
|
304
|
+
private setStatus;
|
|
305
|
+
}
|
|
306
|
+
//# sourceMappingURL=hd-identity-vault.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hd-identity-vault.d.ts","sourceRoot":"","sources":["../../src/hd-identity-vault.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,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QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,EAChE,+BAA+B,GAC9B,OAAO,CAAC,MAAM,CAAC;IAqNlB;;;;;;;;;;;;;;OAcG;IACU,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC;IAI9C;;;;;;;;;;;;;;;OAeG;IACI,QAAQ,IAAI,OAAO;IAI1B;;;;;;;;;;;;;;;OAeG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAWlC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACU,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE;QACzC,MAAM,EAAE,mBAAmB,CAAC;QAC5B,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,IAAI,CAAC;IAoDjB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACU,MAAM,CAAC,EAAE,QAAQ,EAAE,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAyBtE;;;;;;;;;;OAUG;YACW,YAAY;IAe1B;;;;;;;;;;OAUG;YACW,6BAA6B;IAe3C;;;;;;;;;;;;OAYG;YACW,SAAS;CAcxB"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { RequireOnly } from '@enbox/common';
|
|
2
|
+
import type { AgentDataStore } from './store-data.js';
|
|
3
|
+
import type { Web5PlatformAgent } from './types/agent.js';
|
|
4
|
+
import type { DidMethodCreateOptions } from './did-api.js';
|
|
5
|
+
import type { AgentKeyManager } from './types/key-manager.js';
|
|
6
|
+
import type { IdentityMetadata, PortableIdentity } from './types/identity.js';
|
|
7
|
+
import { BearerIdentity } from './bearer-identity.js';
|
|
8
|
+
export interface IdentityApiParams<TKeyManager extends AgentKeyManager> {
|
|
9
|
+
agent?: Web5PlatformAgent<TKeyManager>;
|
|
10
|
+
store?: AgentDataStore<IdentityMetadata>;
|
|
11
|
+
}
|
|
12
|
+
export interface IdentityCreateParams<TKeyManager = AgentKeyManager, TMethod extends keyof DidMethodCreateOptions<TKeyManager> = keyof DidMethodCreateOptions<TKeyManager>> {
|
|
13
|
+
metadata: RequireOnly<IdentityMetadata, 'name'>;
|
|
14
|
+
didMethod?: TMethod;
|
|
15
|
+
didOptions?: DidMethodCreateOptions<TKeyManager>[TMethod];
|
|
16
|
+
store?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function isPortableIdentity(obj: unknown): obj is PortableIdentity;
|
|
19
|
+
/**
|
|
20
|
+
* This API is used to manage and interact with Identities within the Web5 Agent framework.
|
|
21
|
+
* An Identity is a DID that is associated with metadata that describes the Identity.
|
|
22
|
+
* Metadata includes A name(label), and whether or not the Identity is connected (delegated to act on the behalf of another DID).
|
|
23
|
+
*
|
|
24
|
+
* A KeyManager is used to manage the cryptographic keys associated with the Identities.
|
|
25
|
+
*
|
|
26
|
+
* The `DidApi` is used internally to create, store, and manage DIDs.
|
|
27
|
+
* When a DWN Data Store is used, the Identity and DID information are stored under the Agent DID's tenant.
|
|
28
|
+
*/
|
|
29
|
+
export declare class AgentIdentityApi<TKeyManager extends AgentKeyManager = AgentKeyManager> {
|
|
30
|
+
/**
|
|
31
|
+
* Holds the instance of a `Web5PlatformAgent` that represents the current execution context for
|
|
32
|
+
* the `AgentIdentityApi`. This agent is used to interact with other Web5 agent components. It's
|
|
33
|
+
* vital to ensure this instance is set to correctly contextualize operations within the broader
|
|
34
|
+
* Web5 Agent framework.
|
|
35
|
+
*/
|
|
36
|
+
private _agent?;
|
|
37
|
+
private _store;
|
|
38
|
+
constructor({ agent, store }?: IdentityApiParams<TKeyManager>);
|
|
39
|
+
/**
|
|
40
|
+
* Retrieves the `Web5PlatformAgent` execution context.
|
|
41
|
+
*
|
|
42
|
+
* @returns The `Web5PlatformAgent` instance that represents the current execution context.
|
|
43
|
+
* @throws Will throw an error if the `agent` instance property is undefined.
|
|
44
|
+
*/
|
|
45
|
+
get agent(): Web5PlatformAgent<TKeyManager>;
|
|
46
|
+
set agent(agent: Web5PlatformAgent<TKeyManager>);
|
|
47
|
+
get tenant(): string;
|
|
48
|
+
create({ metadata, didMethod, didOptions, store }: IdentityCreateParams<TKeyManager>): Promise<BearerIdentity>;
|
|
49
|
+
export({ didUri }: {
|
|
50
|
+
didUri: string;
|
|
51
|
+
}): Promise<PortableIdentity>;
|
|
52
|
+
get({ didUri }: {
|
|
53
|
+
didUri: string;
|
|
54
|
+
}): Promise<BearerIdentity | undefined>;
|
|
55
|
+
import({ portableIdentity }: {
|
|
56
|
+
portableIdentity: PortableIdentity;
|
|
57
|
+
}): Promise<BearerIdentity>;
|
|
58
|
+
list({ tenant }?: {
|
|
59
|
+
tenant?: string;
|
|
60
|
+
}): Promise<BearerIdentity[]>;
|
|
61
|
+
delete({ didUri }: {
|
|
62
|
+
didUri: string;
|
|
63
|
+
}): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Returns the DWN endpoints for the given DID.
|
|
66
|
+
*
|
|
67
|
+
* @param didUri - The DID URI to get the DWN endpoints for.
|
|
68
|
+
* @returns An array of DWN endpoints.
|
|
69
|
+
* @throws An error if the DID is not found, or no DWN service exists.
|
|
70
|
+
*/
|
|
71
|
+
getDwnEndpoints({ didUri }: {
|
|
72
|
+
didUri: string;
|
|
73
|
+
}): Promise<string[]>;
|
|
74
|
+
/**
|
|
75
|
+
* Sets the DWN endpoints for the given DID.
|
|
76
|
+
*
|
|
77
|
+
* @param didUri - The DID URI to set the DWN endpoints for.
|
|
78
|
+
* @param endpoints - The array of DWN endpoints to set.
|
|
79
|
+
* @throws An error if the DID is not found, or if an update cannot be performed.
|
|
80
|
+
*/
|
|
81
|
+
setDwnEndpoints({ didUri, endpoints }: {
|
|
82
|
+
didUri: string;
|
|
83
|
+
endpoints: string[];
|
|
84
|
+
}): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Updates the Identity's metadata name field.
|
|
87
|
+
*
|
|
88
|
+
* @param didUri - The DID URI of the Identity to update.
|
|
89
|
+
* @param name - The new name to set for the Identity.
|
|
90
|
+
*
|
|
91
|
+
* @throws An error if the Identity is not found, name is not provided, or no changes are detected.
|
|
92
|
+
*/
|
|
93
|
+
setMetadataName({ didUri, name }: {
|
|
94
|
+
didUri: string;
|
|
95
|
+
name: string;
|
|
96
|
+
}): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Returns the connected Identity, if one is available.
|
|
99
|
+
*
|
|
100
|
+
* Accepts optional `connectedDid` parameter to filter the a specific connected identity,
|
|
101
|
+
* if none is provided the first connected identity is returned.
|
|
102
|
+
*/
|
|
103
|
+
connectedIdentity({ connectedDid }?: {
|
|
104
|
+
connectedDid?: string;
|
|
105
|
+
}): Promise<BearerIdentity | undefined>;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=identity-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-api.d.ts","sourceRoot":"","sources":["../../src/identity-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE9E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAMtD,MAAM,WAAW,iBAAiB,CAAC,WAAW,SAAS,eAAe;IACpE,KAAK,CAAC,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAEvC,KAAK,CAAC,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,oBAAoB,CACnC,WAAW,GAAG,eAAe,E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