@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,330 @@
|
|
|
1
|
+
import type { KeyValueStore } from '@enbox/common';
|
|
2
|
+
import type { AbstractLevel } from 'abstract-level';
|
|
3
|
+
|
|
4
|
+
import { Level } from 'level';
|
|
5
|
+
import { LevelStore, MemoryStore } from '@enbox/common';
|
|
6
|
+
import { DataStoreLevel, Dwn, EventEmitterStream, EventLogLevel, MessageStoreLevel, ResumableTaskStoreLevel } from '@enbox/dwn-sdk-js';
|
|
7
|
+
import { DidDht, DidJwk, DidResolutionResult, DidResolverCache } from '@enbox/dids';
|
|
8
|
+
|
|
9
|
+
import type { Web5PlatformAgent } from './types/agent.js';
|
|
10
|
+
|
|
11
|
+
import { AgentDidApi } from './did-api.js';
|
|
12
|
+
import { AgentDidResolverCache } from './agent-did-resolver-cache.js';
|
|
13
|
+
import { AgentDwnApi } from './dwn-api.js';
|
|
14
|
+
import { AgentSyncApi } from './sync-api.js';
|
|
15
|
+
import { Web5RpcClient } from './rpc-client.js';
|
|
16
|
+
import { AgentCryptoApi } from './crypto-api.js';
|
|
17
|
+
import { AgentIdentityApi } from './identity-api.js';
|
|
18
|
+
import { BearerIdentity } from './bearer-identity.js';
|
|
19
|
+
import { HdIdentityVault } from './hd-identity-vault.js';
|
|
20
|
+
import { LocalKeyManager } from './local-key-manager.js';
|
|
21
|
+
import { SyncEngineLevel } from './sync-engine-level.js';
|
|
22
|
+
import { DwnDidStore, InMemoryDidStore } from './store-did.js';
|
|
23
|
+
import { DwnKeyStore, InMemoryKeyStore } from './store-key.js';
|
|
24
|
+
import { DwnIdentityStore, InMemoryIdentityStore } from './store-identity.js';
|
|
25
|
+
import { DidResolverCacheMemory } from './prototyping/dids/resolver-cache-memory.js';
|
|
26
|
+
import { AgentPermissionsApi } from './permissions-api.js';
|
|
27
|
+
|
|
28
|
+
type PlatformAgentTestHarnessParams = {
|
|
29
|
+
agent: Web5PlatformAgent<LocalKeyManager>
|
|
30
|
+
|
|
31
|
+
agentStores: 'dwn' | 'memory';
|
|
32
|
+
didResolverCache: DidResolverCache;
|
|
33
|
+
dwn: Dwn;
|
|
34
|
+
dwnDataStore: DataStoreLevel;
|
|
35
|
+
dwnEventLog: EventLogLevel;
|
|
36
|
+
dwnMessageStore: MessageStoreLevel;
|
|
37
|
+
dwnResumableTaskStore: ResumableTaskStoreLevel;
|
|
38
|
+
syncStore: AbstractLevel<string | Buffer | Uint8Array>;
|
|
39
|
+
vaultStore: KeyValueStore<string, string>;
|
|
40
|
+
dwnStores: {
|
|
41
|
+
keyStore: DwnKeyStore;
|
|
42
|
+
identityStore: DwnIdentityStore;
|
|
43
|
+
didStore: DwnDidStore;
|
|
44
|
+
clear: () => void;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class PlatformAgentTestHarness {
|
|
49
|
+
public agent: Web5PlatformAgent<LocalKeyManager>;
|
|
50
|
+
|
|
51
|
+
public agentStores: 'dwn' | 'memory';
|
|
52
|
+
public didResolverCache: DidResolverCache;
|
|
53
|
+
public dwn: Dwn;
|
|
54
|
+
public dwnDataStore: DataStoreLevel;
|
|
55
|
+
public dwnEventLog: EventLogLevel;
|
|
56
|
+
public dwnMessageStore: MessageStoreLevel;
|
|
57
|
+
public dwnResumableTaskStore: ResumableTaskStoreLevel;
|
|
58
|
+
public syncStore: AbstractLevel<string | Buffer | Uint8Array>;
|
|
59
|
+
public vaultStore: KeyValueStore<string, string>;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Custom DWN Stores for `keyStore`, `identityStore` and `didStore`.
|
|
63
|
+
* This allows us to clear the store cache between tests
|
|
64
|
+
*/
|
|
65
|
+
public dwnStores: {
|
|
66
|
+
keyStore: DwnKeyStore;
|
|
67
|
+
identityStore: DwnIdentityStore;
|
|
68
|
+
didStore: DwnDidStore;
|
|
69
|
+
/** clears the protocol initialization caches */
|
|
70
|
+
clear: () => void;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
constructor(params: PlatformAgentTestHarnessParams) {
|
|
74
|
+
this.agent = params.agent;
|
|
75
|
+
this.agentStores = params.agentStores;
|
|
76
|
+
this.didResolverCache = params.didResolverCache;
|
|
77
|
+
this.dwn = params.dwn;
|
|
78
|
+
this.dwnDataStore = params.dwnDataStore;
|
|
79
|
+
this.dwnEventLog = params.dwnEventLog;
|
|
80
|
+
this.dwnMessageStore = params.dwnMessageStore;
|
|
81
|
+
this.syncStore = params.syncStore;
|
|
82
|
+
this.vaultStore = params.vaultStore;
|
|
83
|
+
this.dwnResumableTaskStore = params.dwnResumableTaskStore;
|
|
84
|
+
this.dwnStores = params.dwnStores;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
public async clearStorage(): Promise<void> {
|
|
88
|
+
// first stop any ongoing sync operations
|
|
89
|
+
await this.agent.sync.stopSync();
|
|
90
|
+
|
|
91
|
+
// @ts-expect-error since normally this property shouldn't be set to undefined.
|
|
92
|
+
this.agent.agentDid = undefined;
|
|
93
|
+
await this.didResolverCache.clear();
|
|
94
|
+
await this.dwnDataStore.clear();
|
|
95
|
+
await this.dwnEventLog.clear();
|
|
96
|
+
await this.dwnMessageStore.clear();
|
|
97
|
+
await this.dwnResumableTaskStore.clear();
|
|
98
|
+
await this.syncStore.clear();
|
|
99
|
+
await this.vaultStore.clear();
|
|
100
|
+
await this.agent.permissions.clear();
|
|
101
|
+
this.dwnStores.clear();
|
|
102
|
+
|
|
103
|
+
// Reset the indexes and caches for the Agent's DWN data stores.
|
|
104
|
+
// if (this.agentStores === 'dwn') {
|
|
105
|
+
// const { didApi, identityApi } = PlatformAgentTestHarness.useDiskStores({ testDataLocation: '__TESTDATA__', agent: this.agent });
|
|
106
|
+
// this.agent.crypto = cryptoApi;
|
|
107
|
+
// this.agent.did = didApi;
|
|
108
|
+
// this.agent.identity = identityApi;
|
|
109
|
+
// }
|
|
110
|
+
|
|
111
|
+
// Easiest way to start with fresh in-memory stores is to re-instantiate Agent components.
|
|
112
|
+
if (this.agentStores === 'memory') {
|
|
113
|
+
const { didApi, identityApi, permissionsApi, keyManager } = PlatformAgentTestHarness.useMemoryStores({ agent: this.agent });
|
|
114
|
+
this.agent.did = didApi;
|
|
115
|
+
this.agent.identity = identityApi;
|
|
116
|
+
this.agent.keyManager = keyManager;
|
|
117
|
+
this.agent.permissions = permissionsApi;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
public async closeStorage(): Promise<void> {
|
|
122
|
+
await this.didResolverCache.close();
|
|
123
|
+
await this.dwnDataStore.close();
|
|
124
|
+
await this.dwnEventLog.close();
|
|
125
|
+
await this.dwnMessageStore.close();
|
|
126
|
+
await this.dwnResumableTaskStore.close();
|
|
127
|
+
await this.syncStore.close();
|
|
128
|
+
await this.vaultStore.close();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public async createAgentDid(): Promise<void> {
|
|
132
|
+
// Create a DID for the Agent.
|
|
133
|
+
this.agent.agentDid = await DidJwk.create({
|
|
134
|
+
options: { algorithm: 'Ed25519' }
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
public async createIdentity({ name, testDwnUrls }: {
|
|
139
|
+
name: string;
|
|
140
|
+
testDwnUrls: string[];
|
|
141
|
+
}): Promise<BearerIdentity> {
|
|
142
|
+
const bearerIdentity = await this.agent.identity.create({
|
|
143
|
+
didMethod : 'dht',
|
|
144
|
+
didOptions : {
|
|
145
|
+
services: [
|
|
146
|
+
{
|
|
147
|
+
id : 'dwn',
|
|
148
|
+
type : 'DecentralizedWebNode',
|
|
149
|
+
serviceEndpoint : testDwnUrls,
|
|
150
|
+
enc : '#enc',
|
|
151
|
+
sig : '#sig',
|
|
152
|
+
}
|
|
153
|
+
],
|
|
154
|
+
verificationMethods: [
|
|
155
|
+
{
|
|
156
|
+
algorithm : 'Ed25519',
|
|
157
|
+
id : 'sig',
|
|
158
|
+
purposes : ['assertionMethod', 'authentication']
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
algorithm : 'secp256k1',
|
|
162
|
+
id : 'enc',
|
|
163
|
+
purposes : ['keyAgreement']
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
},
|
|
167
|
+
metadata: { name }
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
return bearerIdentity;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
public static async setup({ agentClass, agentStores, testDataLocation }: {
|
|
174
|
+
agentClass: new (params: any) => Web5PlatformAgent<LocalKeyManager>
|
|
175
|
+
agentStores?: 'dwn' | 'memory';
|
|
176
|
+
testDataLocation?: string;
|
|
177
|
+
}): Promise<PlatformAgentTestHarness> {
|
|
178
|
+
agentStores ??= 'memory';
|
|
179
|
+
testDataLocation ??= '__TESTDATA__';
|
|
180
|
+
|
|
181
|
+
const testDataPath = (path: string) => `${testDataLocation}/${path}`;
|
|
182
|
+
|
|
183
|
+
// Instantiate Agent's Crypto API.
|
|
184
|
+
const cryptoApi = new AgentCryptoApi();
|
|
185
|
+
|
|
186
|
+
// Instantiate Agent's RPC Client.
|
|
187
|
+
const rpcClient = new Web5RpcClient();
|
|
188
|
+
|
|
189
|
+
const dwnStores = {
|
|
190
|
+
keyStore : new DwnKeyStore(),
|
|
191
|
+
identityStore : new DwnIdentityStore(),
|
|
192
|
+
didStore : new DwnDidStore(),
|
|
193
|
+
clear : ():void => {
|
|
194
|
+
dwnStores.keyStore['_protocolInitializedCache']?.clear();
|
|
195
|
+
dwnStores.identityStore['_protocolInitializedCache']?.clear();
|
|
196
|
+
dwnStores.didStore['_protocolInitializedCache']?.clear();
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const {
|
|
201
|
+
agentVault,
|
|
202
|
+
didApi,
|
|
203
|
+
identityApi,
|
|
204
|
+
keyManager,
|
|
205
|
+
didResolverCache,
|
|
206
|
+
vaultStore,
|
|
207
|
+
permissionsApi
|
|
208
|
+
} = (agentStores === 'memory')
|
|
209
|
+
? PlatformAgentTestHarness.useMemoryStores()
|
|
210
|
+
: PlatformAgentTestHarness.useDiskStores({ testDataLocation, stores: dwnStores });
|
|
211
|
+
|
|
212
|
+
// Instantiate custom stores to use with DWN instance.
|
|
213
|
+
// Note: There is no in-memory store for DWN, so we always use LevelDB-based disk stores.
|
|
214
|
+
const dwnDataStore = new DataStoreLevel({ blockstoreLocation: testDataPath('DWN_DATASTORE') });
|
|
215
|
+
const dwnEventLog = new EventLogLevel({ location: testDataPath('DWN_EVENTLOG') });
|
|
216
|
+
const dwnEventStream = new EventEmitterStream();
|
|
217
|
+
const dwnResumableTaskStore = new ResumableTaskStoreLevel({ location: testDataPath('DWN_RESUMABLETASKSTORE') });
|
|
218
|
+
|
|
219
|
+
const dwnMessageStore = new MessageStoreLevel({
|
|
220
|
+
blockstoreLocation : testDataPath('DWN_MESSAGESTORE'),
|
|
221
|
+
indexLocation : testDataPath('DWN_MESSAGEINDEX')
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
// Instantiate DWN instance using the custom stores.
|
|
225
|
+
const dwn = await AgentDwnApi.createDwn({
|
|
226
|
+
dataPath : testDataLocation,
|
|
227
|
+
dataStore : dwnDataStore,
|
|
228
|
+
didResolver : didApi,
|
|
229
|
+
eventLog : dwnEventLog,
|
|
230
|
+
eventStream : dwnEventStream,
|
|
231
|
+
messageStore : dwnMessageStore,
|
|
232
|
+
resumableTaskStore : dwnResumableTaskStore
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
// Instantiate Agent's DWN API using the custom DWN instance.
|
|
236
|
+
const dwnApi = new AgentDwnApi({ dwn });
|
|
237
|
+
|
|
238
|
+
// Instantiate Agent's Sync API using a custom LevelDB-backed store.
|
|
239
|
+
const syncStore = new Level(testDataPath('SYNC_STORE'));
|
|
240
|
+
const syncEngine = new SyncEngineLevel({ db: syncStore });
|
|
241
|
+
const syncApi = new AgentSyncApi({ syncEngine });
|
|
242
|
+
|
|
243
|
+
// Create Web5PlatformAgent instance
|
|
244
|
+
const agent = new agentClass({
|
|
245
|
+
agentVault,
|
|
246
|
+
cryptoApi,
|
|
247
|
+
didApi,
|
|
248
|
+
dwnApi,
|
|
249
|
+
identityApi,
|
|
250
|
+
keyManager,
|
|
251
|
+
permissionsApi,
|
|
252
|
+
rpcClient,
|
|
253
|
+
syncApi,
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
return new PlatformAgentTestHarness({
|
|
257
|
+
agent,
|
|
258
|
+
agentStores,
|
|
259
|
+
didResolverCache,
|
|
260
|
+
dwn,
|
|
261
|
+
dwnDataStore,
|
|
262
|
+
dwnEventLog,
|
|
263
|
+
dwnMessageStore,
|
|
264
|
+
dwnResumableTaskStore,
|
|
265
|
+
dwnStores,
|
|
266
|
+
syncStore,
|
|
267
|
+
vaultStore
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
private static useDiskStores({ agent, testDataLocation, stores }: {
|
|
272
|
+
agent?: Web5PlatformAgent;
|
|
273
|
+
stores: {
|
|
274
|
+
keyStore: DwnKeyStore;
|
|
275
|
+
identityStore: DwnIdentityStore;
|
|
276
|
+
didStore: DwnDidStore;
|
|
277
|
+
}
|
|
278
|
+
testDataLocation: string;
|
|
279
|
+
}) {
|
|
280
|
+
const testDataPath = (path: string) => `${testDataLocation}/${path}`;
|
|
281
|
+
|
|
282
|
+
const vaultStore = new LevelStore<string, string>({ location: testDataPath('VAULT_STORE') });
|
|
283
|
+
const agentVault = new HdIdentityVault({ keyDerivationWorkFactor: 1, store: vaultStore });
|
|
284
|
+
|
|
285
|
+
const { didStore, identityStore, keyStore } = stores;
|
|
286
|
+
|
|
287
|
+
// Setup DID Resolver Cache
|
|
288
|
+
const didResolverCache = new AgentDidResolverCache({
|
|
289
|
+
location: testDataPath('DID_RESOLVERCACHE')
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
const didApi = new AgentDidApi({
|
|
293
|
+
agent : agent,
|
|
294
|
+
didMethods : [DidDht, DidJwk],
|
|
295
|
+
resolverCache : didResolverCache,
|
|
296
|
+
store : didStore
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
const identityApi = new AgentIdentityApi({ agent, store: identityStore });
|
|
300
|
+
|
|
301
|
+
const keyManager = new LocalKeyManager({ agent, keyStore: keyStore });
|
|
302
|
+
|
|
303
|
+
const permissionsApi = new AgentPermissionsApi({ agent });
|
|
304
|
+
|
|
305
|
+
return { agentVault, didApi, didResolverCache, identityApi, keyManager, permissionsApi, vaultStore };
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
private static useMemoryStores({ agent }: { agent?: Web5PlatformAgent<LocalKeyManager> } = {}) {
|
|
309
|
+
const vaultStore = new MemoryStore<string, string>();
|
|
310
|
+
const agentVault = new HdIdentityVault({ keyDerivationWorkFactor: 1, store: vaultStore });
|
|
311
|
+
|
|
312
|
+
// Setup DID Resolver Cache
|
|
313
|
+
const didResolverCache = new DidResolverCacheMemory();
|
|
314
|
+
|
|
315
|
+
const didApi = new AgentDidApi({
|
|
316
|
+
agent : agent,
|
|
317
|
+
didMethods : [DidDht, DidJwk],
|
|
318
|
+
resolverCache : didResolverCache,
|
|
319
|
+
store : new InMemoryDidStore()
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
const keyManager = new LocalKeyManager({ agent, keyStore: new InMemoryKeyStore() });
|
|
323
|
+
|
|
324
|
+
const identityApi = new AgentIdentityApi<LocalKeyManager>({ agent, store: new InMemoryIdentityStore() });
|
|
325
|
+
|
|
326
|
+
const permissionsApi = new AgentPermissionsApi({ agent });
|
|
327
|
+
|
|
328
|
+
return { agentVault, didApi, didResolverCache, identityApi, keyManager, permissionsApi, vaultStore };
|
|
329
|
+
}
|
|
330
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import type { BearerDid } from '@enbox/dids';
|
|
2
|
+
|
|
3
|
+
import type { Web5Rpc } from '../rpc-client.js';
|
|
4
|
+
import type { AgentDwnApi } from '../dwn-api.js';
|
|
5
|
+
import type { AgentSyncApi } from '../sync-api.js';
|
|
6
|
+
import type { AgentCryptoApi } from '../crypto-api.js';
|
|
7
|
+
import type { AgentKeyManager } from './key-manager.js';
|
|
8
|
+
import type { IdentityVault } from './identity-vault.js';
|
|
9
|
+
import type { AgentIdentityApi } from '../identity-api.js';
|
|
10
|
+
import type { AgentPermissionsApi } from '../permissions-api.js';
|
|
11
|
+
import type { ProcessVcRequest, SendVcRequest, VcResponse } from './vc.js';
|
|
12
|
+
import type { AgentDidApi, DidInterface, DidRequest, DidResponse } from '../did-api.js';
|
|
13
|
+
import type { DwnInterface, DwnResponse, ProcessDwnRequest, SendDwnRequest } from './dwn.js';
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Defines the structure for response status in the context of an Agent's interaction within the
|
|
18
|
+
* Web5 framework.
|
|
19
|
+
*
|
|
20
|
+
* This type is utilized to convey the success or failure of an operation performed by the Agent,
|
|
21
|
+
* providing feedback that can be programmatically interpreted and acted upon.
|
|
22
|
+
*
|
|
23
|
+
* This standardized response structure ensures a consistent interface for handling operation
|
|
24
|
+
* outcomes, enabling clear communication of success or error states along with actionable insights
|
|
25
|
+
* when necessary.
|
|
26
|
+
*/
|
|
27
|
+
export type ResponseStatus = {
|
|
28
|
+
/**
|
|
29
|
+
* A boolean value indicating the overall success (`true`) or failure (`false`) of the operation.
|
|
30
|
+
* - `true`: Indicates that the operation was successful without errors.
|
|
31
|
+
* - `false`: Indicates that the operation failed, with the error details provided in the `status`
|
|
32
|
+
* object.
|
|
33
|
+
*/
|
|
34
|
+
ok: boolean;
|
|
35
|
+
|
|
36
|
+
status: {
|
|
37
|
+
/**
|
|
38
|
+
* A numerical code representing the specific outcome of the operation.
|
|
39
|
+
*
|
|
40
|
+
* This can be aligned with standard HTTP status codes for web-based operations or custom codes
|
|
41
|
+
* for specific business logic.
|
|
42
|
+
*/
|
|
43
|
+
code: number;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A descriptive message corresponding to the status code that provides additional information
|
|
47
|
+
* about the operation's result.
|
|
48
|
+
*
|
|
49
|
+
* This message is particularly useful for logging, debugging, or displaying contextual messages
|
|
50
|
+
* to the end-user, offering insights into why an operation succeeded or failed.
|
|
51
|
+
*/
|
|
52
|
+
message: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Defines the interface for a Web5 Agent, encapsulating the core functionality all implementations
|
|
58
|
+
* must include.
|
|
59
|
+
*
|
|
60
|
+
* The Agent is responsible for handling decentralized identifier (DID) requests, decentralized web
|
|
61
|
+
* node (DWN) requests, and verifiable credential (VC) requests.
|
|
62
|
+
*
|
|
63
|
+
* The `AgentDid` property represents the Web5 Agent's own DID, while the various process and send
|
|
64
|
+
* methods enable the Agent to handle and initiate requests pertaining to DIDs, DWNs, and VCs.
|
|
65
|
+
*/
|
|
66
|
+
export interface Web5Agent {
|
|
67
|
+
/**
|
|
68
|
+
* The Decentralized Identifier (DID) of this Web5 Agent.
|
|
69
|
+
*/
|
|
70
|
+
agentDid: BearerDid;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Processes a DID request, handling it internally within the agent and returning a DID response,
|
|
74
|
+
* typically involving operations like DID creation or resolution.
|
|
75
|
+
*/
|
|
76
|
+
processDidRequest<T extends DidInterface>(request: DidRequest<T>): Promise<DidResponse<T>>
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Sends a DID request to another entity or service, expecting a DID response, often used for
|
|
80
|
+
* interactions involving DIDs occurring over a network or between different agents.
|
|
81
|
+
*/
|
|
82
|
+
sendDidRequest<T extends DidInterface>(request: DidRequest<T>): Promise<DidResponse<T>>;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Processes a request related to a Decentralized Web Node (DWN) and returns a corresponding
|
|
86
|
+
* response.
|
|
87
|
+
*/
|
|
88
|
+
processDwnRequest<T extends DwnInterface>(request: ProcessDwnRequest<T>): Promise<DwnResponse<T>>
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Sends a request to a Decentralized Web Node (DWN) and awaits a response, often used for
|
|
92
|
+
* interactions involving DWNs occurring over a network or between different agents.
|
|
93
|
+
*/
|
|
94
|
+
sendDwnRequest<T extends DwnInterface>(request: SendDwnRequest<T>): Promise<DwnResponse<T>>;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Processes a request for handling Verifiable Credentials (VCs), such as issuing or verifying
|
|
98
|
+
* them, and returns a response indicating the outcome.
|
|
99
|
+
*/
|
|
100
|
+
processVcRequest(request: ProcessVcRequest): Promise<VcResponse>
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Sends a request to issue, verify, or manage Verifiable Credentials (VCs), expecting a response
|
|
104
|
+
* that indicates the result of the operation. This method is often used for interactions
|
|
105
|
+
* involving VCs occurring over a network or between different agents.
|
|
106
|
+
*/
|
|
107
|
+
sendVcRequest(request: SendVcRequest): Promise<VcResponse>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Represents a Web5 Platform Agent, an extended and more feature-rich implementation of a
|
|
112
|
+
* {@link Web5Agent}.
|
|
113
|
+
*
|
|
114
|
+
* This Agent integrates a comprehensive set of APIs and functionalities, including cryptographic
|
|
115
|
+
* operations, DID management, DWN interaction, identity handling, and data synchronization.
|
|
116
|
+
*
|
|
117
|
+
* The platform agent provides a higher-level abstraction over the core Web5Agent functionalities,
|
|
118
|
+
* facilitating a robust platform for developing Web5 applications. It includes lifecycle management
|
|
119
|
+
* methods like initialization and startup, alongside a suite of specialized APIs and utilities.
|
|
120
|
+
*
|
|
121
|
+
* @typeParam TKeyManager - The type of Key Manager used to manage cryptographic keys.
|
|
122
|
+
*/
|
|
123
|
+
export interface Web5PlatformAgent<TKeyManager extends AgentKeyManager = AgentKeyManager> extends Web5Agent {
|
|
124
|
+
/**
|
|
125
|
+
* The cryptography API, essential for performing various cryptographic operations such
|
|
126
|
+
* as encryption, decryption, signing, and verification, ensuring secure data handling and
|
|
127
|
+
* communication within the Web5 Platform.
|
|
128
|
+
*/
|
|
129
|
+
crypto: AgentCryptoApi;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The DID API, responsible for managing all DID-related functionalities, enabling the agent to
|
|
133
|
+
* create, resolve, update, and manage DIDs.
|
|
134
|
+
*/
|
|
135
|
+
did: AgentDidApi<TKeyManager>;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* The DWN API, enabling the Agent to interact with Decentralized Web Nodes (DWNs) and handle
|
|
139
|
+
* requests from Web5 applications.
|
|
140
|
+
*/
|
|
141
|
+
dwn: AgentDwnApi;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The identity management API, handling identity-related operations and allowing the agent to
|
|
145
|
+
* manage Web5 identities, supporting operations like identity creation and update.
|
|
146
|
+
*/
|
|
147
|
+
identity: AgentIdentityApi<TKeyManager>;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* The Key Manager instance, central to the agent's cryptographic operations, managing key
|
|
151
|
+
* generation, storage, retrieval, and usage, ensuring secure cryptographic practices.
|
|
152
|
+
*/
|
|
153
|
+
keyManager: TKeyManager;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* The Permissions API, handling permission operations such as request, create, revocation, fetching and verifying revocation status.
|
|
157
|
+
*/
|
|
158
|
+
permissions: AgentPermissionsApi;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The RPC (Remote Procedure Call) client interface, facilitating communication with other Web5
|
|
162
|
+
* Agents and services.
|
|
163
|
+
*/
|
|
164
|
+
rpc: Web5Rpc;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The synchronization API, responsible for managing the consistency and real-time update of the
|
|
168
|
+
* agent's data with the state of the distributed network.
|
|
169
|
+
*/
|
|
170
|
+
sync: AgentSyncApi;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* An instance of {@link IdentityVault}, providing secure storage and management of a Web5 Agent's
|
|
174
|
+
* DID and cryptographic keys.
|
|
175
|
+
*/
|
|
176
|
+
vault: IdentityVault;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Determines if it's the first time the Agent is being launched, typically used for initialization
|
|
180
|
+
* checks or first-time setup routines.
|
|
181
|
+
*/
|
|
182
|
+
firstLaunch(): Promise<boolean>;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Initializes the agent with essential parameters (e.g., a passphrase) and prepares it for
|
|
186
|
+
* processing Web5 requests.
|
|
187
|
+
*/
|
|
188
|
+
initialize(params: unknown): Promise<unknown>;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Starts the agent with the provided parameters, typically following initialization, to begin
|
|
192
|
+
* normal operation and readiness to process requests.
|
|
193
|
+
*/
|
|
194
|
+
start(params: unknown): Promise<unknown>;
|
|
195
|
+
}
|