@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,34 @@
|
|
|
1
|
+
import type { Web5PlatformAgent } from './types/agent.js';
|
|
2
|
+
import type { IdentityMetadata } from './types/identity.js';
|
|
3
|
+
import type { AgentDataStore, DataStoreDeleteParams, DataStoreGetParams, DataStoreListParams, DataStoreSetParams } from './store-data.js';
|
|
4
|
+
import { DwnDataStore, InMemoryDataStore } from './store-data.js';
|
|
5
|
+
export declare function isIdentityMetadata(obj: unknown): obj is IdentityMetadata;
|
|
6
|
+
export declare class DwnIdentityStore extends DwnDataStore<IdentityMetadata> implements AgentDataStore<IdentityMetadata> {
|
|
7
|
+
protected name: string;
|
|
8
|
+
protected _recordProtocolDefinition: import("./types/dwn.js").DwnProtocolDefinition;
|
|
9
|
+
/**
|
|
10
|
+
* Properties to use when writing and querying Identity records with the DWN store.
|
|
11
|
+
*/
|
|
12
|
+
protected _recordProperties: {
|
|
13
|
+
dataFormat: string;
|
|
14
|
+
protocol: string;
|
|
15
|
+
protocolPath: string;
|
|
16
|
+
schema: string | undefined;
|
|
17
|
+
};
|
|
18
|
+
delete(params: DataStoreDeleteParams): Promise<boolean>;
|
|
19
|
+
get(params: DataStoreGetParams): Promise<IdentityMetadata | undefined>;
|
|
20
|
+
set(params: DataStoreSetParams<IdentityMetadata>): Promise<void>;
|
|
21
|
+
list(params: DataStoreListParams): Promise<IdentityMetadata[]>;
|
|
22
|
+
protected getAllRecords({ agent, tenantDid }: {
|
|
23
|
+
agent: Web5PlatformAgent;
|
|
24
|
+
tenantDid: string;
|
|
25
|
+
}): Promise<IdentityMetadata[]>;
|
|
26
|
+
}
|
|
27
|
+
export declare class InMemoryIdentityStore extends InMemoryDataStore<IdentityMetadata> implements AgentDataStore<IdentityMetadata> {
|
|
28
|
+
protected name: string;
|
|
29
|
+
delete(params: DataStoreDeleteParams): Promise<boolean>;
|
|
30
|
+
get(params: DataStoreGetParams): Promise<IdentityMetadata | undefined>;
|
|
31
|
+
list(params: DataStoreListParams): Promise<IdentityMetadata[]>;
|
|
32
|
+
set(params: DataStoreSetParams<IdentityMetadata>): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=store-identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store-identity.d.ts","sourceRoot":"","sources":["../../src/store-identity.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAA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AC;IAItE,IAAI,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAI9D,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAG9E"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Jwk } from '@enbox/crypto';
|
|
2
|
+
import type { Web5PlatformAgent } from './types/agent.js';
|
|
3
|
+
import { AgentDataStore, DataStoreDeleteParams, DataStoreGetParams, DataStoreListParams, DataStoreSetParams, DwnDataStore, InMemoryDataStore } from './store-data.js';
|
|
4
|
+
export declare class DwnKeyStore extends DwnDataStore<Jwk> implements AgentDataStore<Jwk> {
|
|
5
|
+
protected name: string;
|
|
6
|
+
protected _recordProtocolDefinition: import("./types/dwn.js").DwnProtocolDefinition;
|
|
7
|
+
/**
|
|
8
|
+
* Properties to use when writing and querying Private Key records with the DWN store.
|
|
9
|
+
*/
|
|
10
|
+
protected _recordProperties: {
|
|
11
|
+
dataFormat: string;
|
|
12
|
+
protocol: string;
|
|
13
|
+
protocolPath: string;
|
|
14
|
+
schema: string | undefined;
|
|
15
|
+
};
|
|
16
|
+
delete(params: DataStoreDeleteParams): Promise<boolean>;
|
|
17
|
+
get(params: DataStoreGetParams): Promise<Jwk | undefined>;
|
|
18
|
+
set(params: DataStoreSetParams<Jwk>): Promise<void>;
|
|
19
|
+
list(params: DataStoreListParams): Promise<Jwk[]>;
|
|
20
|
+
protected getAllRecords({ agent, tenantDid }: {
|
|
21
|
+
agent: Web5PlatformAgent;
|
|
22
|
+
tenantDid: string;
|
|
23
|
+
}): Promise<Jwk[]>;
|
|
24
|
+
}
|
|
25
|
+
export declare class InMemoryKeyStore extends InMemoryDataStore<Jwk> implements AgentDataStore<Jwk> {
|
|
26
|
+
protected name: string;
|
|
27
|
+
delete(params: DataStoreDeleteParams): Promise<boolean>;
|
|
28
|
+
get(params: DataStoreGetParams): Promise<Jwk | undefined>;
|
|
29
|
+
list(params: DataStoreListParams): Promise<Jwk[]>;
|
|
30
|
+
set(params: DataStoreSetParams<Jwk>): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=store-key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store-key.d.ts","sourceRoot":"","sources":["../../src/store-key.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAKzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAK1D,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEtK,qBAAa,WAAY,SAAQ,YAAY,CAAC,GAAG,CAAE,YAAW,cAAc,CAAC,GAAG,CAAC;IAC/E,SAAS,CAAC,IAAI,SAAiB;IAE/B,SAAS,CAAC,yBAAyB,iDAAyB;IAE5D;;OAEG;IACH,SAAS,CAAC,iBAAiB;;;;;MAKzB;IAEW,MAAM,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,OAAO,CAAC;IAIvD,GAAG,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC;IAIzD,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAInD,IAAI,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;cAI9C,aAAa,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE;QAClD,KAAK,EAAE,iBAAiB,CAAC;QACzB,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;CAqCnB;AAED,qBAAa,gBAAiB,SAAQ,iBAAiB,CAAC,GAAG,CAAE,YAAW,cAAc,CAAC,GAAG,CAAC;IACzF,SAAS,CAAC,IAAI,SAAsB;IAEvB,MAAM,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,OAAO,CAAC;IAIvD,GAAG,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC;IAIzD,IAAI,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAIjD,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAGjE"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { SyncEngine, SyncIdentityOptions } from './types/sync.js';
|
|
2
|
+
import type { Web5PlatformAgent } from './types/agent.js';
|
|
3
|
+
export type SyncApiParams = {
|
|
4
|
+
agent?: Web5PlatformAgent;
|
|
5
|
+
syncEngine: SyncEngine;
|
|
6
|
+
};
|
|
7
|
+
export declare class AgentSyncApi implements SyncEngine {
|
|
8
|
+
/**
|
|
9
|
+
* Holds the instance of a `Web5PlatformAgent` that represents the current execution context for
|
|
10
|
+
* the `AgentSyncApi`. This agent is used to interact with other Web5 agent components. It's vital
|
|
11
|
+
* to ensure this instance is set to correctly contextualize operations within the broader Web5
|
|
12
|
+
* Agent framework.
|
|
13
|
+
*/
|
|
14
|
+
private _agent?;
|
|
15
|
+
private _syncEngine;
|
|
16
|
+
constructor({ agent, syncEngine }: SyncApiParams);
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves the `Web5PlatformAgent` execution context.
|
|
19
|
+
*
|
|
20
|
+
* @returns The `Web5PlatformAgent` instance that represents the current execution context.
|
|
21
|
+
* @throws Will throw an error if the `agent` instance property is undefined.
|
|
22
|
+
*/
|
|
23
|
+
get agent(): Web5PlatformAgent;
|
|
24
|
+
set agent(agent: Web5PlatformAgent);
|
|
25
|
+
registerIdentity(params: {
|
|
26
|
+
did: string;
|
|
27
|
+
options?: SyncIdentityOptions;
|
|
28
|
+
}): Promise<void>;
|
|
29
|
+
unregisterIdentity(did: string): Promise<void>;
|
|
30
|
+
getIdentityOptions(did: string): Promise<SyncIdentityOptions | undefined>;
|
|
31
|
+
updateIdentityOptions(params: {
|
|
32
|
+
did: string;
|
|
33
|
+
options: SyncIdentityOptions;
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
sync(direction?: 'push' | 'pull'): Promise<void>;
|
|
36
|
+
startSync(params: {
|
|
37
|
+
interval: string;
|
|
38
|
+
}): Promise<void>;
|
|
39
|
+
stopSync(timeout?: number): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=sync-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-api.d.ts","sourceRoot":"","sources":["../../src/sync-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,UAAU,EAAE,UAAU,CAAC;CACxB,CAAA;AAED,qBAAa,YAAa,YAAW,UAAU;IAC7C;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,CAAoB;IAEnC,OAAO,CAAC,WAAW,CAAa;gBAEpB,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,aAAa;IAKhD;;;;;OAKG;IACH,IAAI,KAAK,IAAI,iBAAiB,CAM7B;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,iBAAiB,EAGjC;IAEY,gBAAgB,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,mBAAmB,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvF,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC;IAIzE,qBAAqB,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,mBAAmB,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjG,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhD,SAAS,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGjD"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import type { AbstractLevel } from 'abstract-level';
|
|
3
|
+
import type { SyncEngine, SyncIdentityOptions } from './types/sync.js';
|
|
4
|
+
import type { Web5PlatformAgent } from './types/agent.js';
|
|
5
|
+
export type SyncEngineLevelParams = {
|
|
6
|
+
agent?: Web5PlatformAgent;
|
|
7
|
+
dataPath?: string;
|
|
8
|
+
db?: AbstractLevel<string | Buffer | Uint8Array>;
|
|
9
|
+
};
|
|
10
|
+
export declare class SyncEngineLevel implements SyncEngine {
|
|
11
|
+
/**
|
|
12
|
+
* Holds the instance of a `Web5PlatformAgent` that represents the current execution context for
|
|
13
|
+
* the `SyncEngineLevel`. This agent is used to interact with other Web5 agent components. It's
|
|
14
|
+
* vital to ensure this instance is set to correctly contextualize operations within the broader
|
|
15
|
+
* Web5 Agent framework.
|
|
16
|
+
*/
|
|
17
|
+
private _agent?;
|
|
18
|
+
/**
|
|
19
|
+
* An instance of the `AgentPermissionsApi` that is used to interact with permissions grants used during sync
|
|
20
|
+
*/
|
|
21
|
+
private _permissionsApi;
|
|
22
|
+
private _db;
|
|
23
|
+
private _syncIntervalId?;
|
|
24
|
+
private _syncLock;
|
|
25
|
+
private _ulidFactory;
|
|
26
|
+
constructor({ agent, dataPath, db }: SyncEngineLevelParams);
|
|
27
|
+
/**
|
|
28
|
+
* Retrieves the `Web5PlatformAgent` execution context.
|
|
29
|
+
*
|
|
30
|
+
* @returns The `Web5PlatformAgent` instance that represents the current execution context.
|
|
31
|
+
* @throws Will throw an error if the `agent` instance property is undefined.
|
|
32
|
+
*/
|
|
33
|
+
get agent(): Web5PlatformAgent;
|
|
34
|
+
set agent(agent: Web5PlatformAgent);
|
|
35
|
+
clear(): Promise<void>;
|
|
36
|
+
close(): Promise<void>;
|
|
37
|
+
private pull;
|
|
38
|
+
private push;
|
|
39
|
+
registerIdentity({ did, options }: {
|
|
40
|
+
did: string;
|
|
41
|
+
options?: SyncIdentityOptions;
|
|
42
|
+
}): Promise<void>;
|
|
43
|
+
unregisterIdentity(did: string): Promise<void>;
|
|
44
|
+
getIdentityOptions(did: string): Promise<SyncIdentityOptions | undefined>;
|
|
45
|
+
updateIdentityOptions({ did, options }: {
|
|
46
|
+
did: string;
|
|
47
|
+
options: SyncIdentityOptions;
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
sync(direction?: 'push' | 'pull'): Promise<void>;
|
|
50
|
+
startSync({ interval }: {
|
|
51
|
+
interval: string;
|
|
52
|
+
}): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* stopSync currently awaits the completion of the current sync operation before stopping the sync interval.
|
|
55
|
+
* TODO: implement a signal to gracefully stop sync immediately https://github.com/TBD54566975/web5-js/issues/890
|
|
56
|
+
*/
|
|
57
|
+
stopSync(timeout?: number): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* 202: message was successfully written to the remote DWN
|
|
60
|
+
* 204: an initial write message was written without any data, cannot yet be read until a subsequent message is written with data
|
|
61
|
+
* 409: message was already present on the remote DWN
|
|
62
|
+
* RecordsDelete and the status code is 404: the initial write message was not found or the message was already deleted
|
|
63
|
+
*/
|
|
64
|
+
private static syncMessageReplyIsSuccessful;
|
|
65
|
+
private enqueueOperations;
|
|
66
|
+
private static generateSyncMessageParamsKey;
|
|
67
|
+
private static parseSyncMessageParamsKey;
|
|
68
|
+
private getDwnEventLog;
|
|
69
|
+
private getDwnMessage;
|
|
70
|
+
private getSyncPeerState;
|
|
71
|
+
private getCursor;
|
|
72
|
+
private setCursor;
|
|
73
|
+
/**
|
|
74
|
+
* The message store is used to prevent "echoes" that occur during a sync pull operation.
|
|
75
|
+
* After a message is confirmed to already be synchronized on the local DWN, its CID is added
|
|
76
|
+
* to the message store to ensure that any subsequent pull attempts are skipped.
|
|
77
|
+
*/
|
|
78
|
+
private messageExists;
|
|
79
|
+
private addMessage;
|
|
80
|
+
private getMessageStore;
|
|
81
|
+
private getCursorStore;
|
|
82
|
+
private getPushQueue;
|
|
83
|
+
private getPullQueue;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=sync-engine-level.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-engine-level.d.ts","sourceRoot":"","sources":["../../src/sync-engine-level.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAA0B,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAkB5E,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,KAAK,EAAa,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAOrE,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,EAAE,CAAC,EAAE,aAAa,CAAC,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC,CAAC;CAClD,CAAA;AAwBD,qBAAa,eAAgB,YAAW,UAAU;IAChD;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,CAAoB;IAEnC;;OAEG;IACH,OAAO,CAA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AAC,4BAA4B;YAe7B,iBAAiB;IA6C/B,OAAO,CAAC,MAAM,CAAC,4BAA4B;IAW3C,OAAO,CAAC,MAAM,CAAC,yBAAyB;YAU1B,cAAc;YAwEd,aAAa;YAsDb,gBAAgB;YA6ChB,SAAS;YAoBT,SAAS;IAOvB;;;;OAIG;YACW,aAAa;YAeb,UAAU;IAMxB,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,YAAY;CAGrB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import type { KeyValueStore } from '@enbox/common';
|
|
3
|
+
import type { AbstractLevel } from 'abstract-level';
|
|
4
|
+
import { DataStoreLevel, Dwn, EventLogLevel, MessageStoreLevel, ResumableTaskStoreLevel } from '@enbox/dwn-sdk-js';
|
|
5
|
+
import { DidResolverCache } from '@enbox/dids';
|
|
6
|
+
import type { Web5PlatformAgent } from './types/agent.js';
|
|
7
|
+
import { BearerIdentity } from './bearer-identity.js';
|
|
8
|
+
import { LocalKeyManager } from './local-key-manager.js';
|
|
9
|
+
import { DwnDidStore } from './store-did.js';
|
|
10
|
+
import { DwnKeyStore } from './store-key.js';
|
|
11
|
+
import { DwnIdentityStore } from './store-identity.js';
|
|
12
|
+
type PlatformAgentTestHarnessParams = {
|
|
13
|
+
agent: Web5PlatformAgent<LocalKeyManager>;
|
|
14
|
+
agentStores: 'dwn' | 'memory';
|
|
15
|
+
didResolverCache: DidResolverCache;
|
|
16
|
+
dwn: Dwn;
|
|
17
|
+
dwnDataStore: DataStoreLevel;
|
|
18
|
+
dwnEventLog: EventLogLevel;
|
|
19
|
+
dwnMessageStore: MessageStoreLevel;
|
|
20
|
+
dwnResumableTaskStore: ResumableTaskStoreLevel;
|
|
21
|
+
syncStore: AbstractLevel<string | Buffer | Uint8Array>;
|
|
22
|
+
vaultStore: KeyValueStore<string, string>;
|
|
23
|
+
dwnStores: {
|
|
24
|
+
keyStore: DwnKeyStore;
|
|
25
|
+
identityStore: DwnIdentityStore;
|
|
26
|
+
didStore: DwnDidStore;
|
|
27
|
+
clear: () => void;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export declare class PlatformAgentTestHarness {
|
|
31
|
+
agent: Web5PlatformAgent<LocalKeyManager>;
|
|
32
|
+
agentStores: 'dwn' | 'memory';
|
|
33
|
+
didResolverCache: DidResolverCache;
|
|
34
|
+
dwn: Dwn;
|
|
35
|
+
dwnDataStore: DataStoreLevel;
|
|
36
|
+
dwnEventLog: EventLogLevel;
|
|
37
|
+
dwnMessageStore: MessageStoreLevel;
|
|
38
|
+
dwnResumableTaskStore: ResumableTaskStoreLevel;
|
|
39
|
+
syncStore: AbstractLevel<string | Buffer | Uint8Array>;
|
|
40
|
+
vaultStore: KeyValueStore<string, string>;
|
|
41
|
+
/**
|
|
42
|
+
* Custom DWN Stores for `keyStore`, `identityStore` and `didStore`.
|
|
43
|
+
* This allows us to clear the store cache between tests
|
|
44
|
+
*/
|
|
45
|
+
dwnStores: {
|
|
46
|
+
keyStore: DwnKeyStore;
|
|
47
|
+
identityStore: DwnIdentityStore;
|
|
48
|
+
didStore: DwnDidStore;
|
|
49
|
+
/** clears the protocol initialization caches */
|
|
50
|
+
clear: () => void;
|
|
51
|
+
};
|
|
52
|
+
constructor(params: PlatformAgentTestHarnessParams);
|
|
53
|
+
clearStorage(): Promise<void>;
|
|
54
|
+
closeStorage(): Promise<void>;
|
|
55
|
+
createAgentDid(): Promise<void>;
|
|
56
|
+
createIdentity({ name, testDwnUrls }: {
|
|
57
|
+
name: string;
|
|
58
|
+
testDwnUrls: string[];
|
|
59
|
+
}): Promise<BearerIdentity>;
|
|
60
|
+
static setup({ agentClass, agentStores, testDataLocation }: {
|
|
61
|
+
agentClass: new (params: any) => Web5PlatformAgent<LocalKeyManager>;
|
|
62
|
+
agentStores?: 'dwn' | 'memory';
|
|
63
|
+
testDataLocation?: string;
|
|
64
|
+
}): Promise<PlatformAgentTestHarness>;
|
|
65
|
+
private static useDiskStores;
|
|
66
|
+
private static useMemoryStores;
|
|
67
|
+
}
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=test-harness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-harness.d.ts","sourceRoot":"","sources":["../../src/test-harness.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAIpD,OAAO,EAAE,cAAc,EAAE,GAAG,EAAsB,aAAa,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AACvI,OAAO,EAAuC,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAS1D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAoB,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAoB,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAyB,MAAM,qBAAqB,CAAC;AAI9E,KAAK,8BAA8B,GAAG;IACpC,KAAK,EAAE,iBAAiB,CAAC,eAAe,CAAC,CAAA;IAEzC,WAAW,EAAE,KAAK,GAAG,QAAQ,CAAC;IAC9B,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,GAAG,EAAE,GAAG,CAAC;IACT,YAAY,EAAE,cAAc,CAAC;IAC7B,WAAW,EAAE,aAAa,CAAC;IAC3B,eAAe,EAAE,iBAAiB,CAAC;IACnC,qBAAqB,EAAE,uBAAuB,CAAC;IAC/C,SAAS,EAAE,aAAa,CAAC,MAAM,GAAG,MAAM,GAAG,UAA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E,WAAW,EAAE,gBAAgB,EAAE,EAAE;QACrE,UAAU,EAAE,KAAK,MAAM,EAAE,GAAG,KAAK,iBAAiB,CAAC,eAAe,CAAC,CAAA;QACnE,WAAW,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;QAC/B,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,GAAG,OAAO,CAAC,wBAAwB,CAAC;IA8FvC,OAAO,CAAC,MAAM,CAAC,aAAa;IAqC5B,OAAO,CAAC,MAAM,CAAC,eAAe;CAsB/B"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import type { BearerDid } from '@enbox/dids';
|
|
2
|
+
import type { Web5Rpc } from '../rpc-client.js';
|
|
3
|
+
import type { AgentDwnApi } from '../dwn-api.js';
|
|
4
|
+
import type { AgentSyncApi } from '../sync-api.js';
|
|
5
|
+
import type { AgentCryptoApi } from '../crypto-api.js';
|
|
6
|
+
import type { AgentKeyManager } from './key-manager.js';
|
|
7
|
+
import type { IdentityVault } from './identity-vault.js';
|
|
8
|
+
import type { AgentIdentityApi } from '../identity-api.js';
|
|
9
|
+
import type { AgentPermissionsApi } from '../permissions-api.js';
|
|
10
|
+
import type { ProcessVcRequest, SendVcRequest, VcResponse } from './vc.js';
|
|
11
|
+
import type { AgentDidApi, DidInterface, DidRequest, DidResponse } from '../did-api.js';
|
|
12
|
+
import type { DwnInterface, DwnResponse, ProcessDwnRequest, SendDwnRequest } from './dwn.js';
|
|
13
|
+
/**
|
|
14
|
+
* Defines the structure for response status in the context of an Agent's interaction within the
|
|
15
|
+
* Web5 framework.
|
|
16
|
+
*
|
|
17
|
+
* This type is utilized to convey the success or failure of an operation performed by the Agent,
|
|
18
|
+
* providing feedback that can be programmatically interpreted and acted upon.
|
|
19
|
+
*
|
|
20
|
+
* This standardized response structure ensures a consistent interface for handling operation
|
|
21
|
+
* outcomes, enabling clear communication of success or error states along with actionable insights
|
|
22
|
+
* when necessary.
|
|
23
|
+
*/
|
|
24
|
+
export type ResponseStatus = {
|
|
25
|
+
/**
|
|
26
|
+
* A boolean value indicating the overall success (`true`) or failure (`false`) of the operation.
|
|
27
|
+
* - `true`: Indicates that the operation was successful without errors.
|
|
28
|
+
* - `false`: Indicates that the operation failed, with the error details provided in the `status`
|
|
29
|
+
* object.
|
|
30
|
+
*/
|
|
31
|
+
ok: boolean;
|
|
32
|
+
status: {
|
|
33
|
+
/**
|
|
34
|
+
* A numerical code representing the specific outcome of the operation.
|
|
35
|
+
*
|
|
36
|
+
* This can be aligned with standard HTTP status codes for web-based operations or custom codes
|
|
37
|
+
* for specific business logic.
|
|
38
|
+
*/
|
|
39
|
+
code: number;
|
|
40
|
+
/**
|
|
41
|
+
* A descriptive message corresponding to the status code that provides additional information
|
|
42
|
+
* about the operation's result.
|
|
43
|
+
*
|
|
44
|
+
* This message is particularly useful for logging, debugging, or displaying contextual messages
|
|
45
|
+
* to the end-user, offering insights into why an operation succeeded or failed.
|
|
46
|
+
*/
|
|
47
|
+
message: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Defines the interface for a Web5 Agent, encapsulating the core functionality all implementations
|
|
52
|
+
* must include.
|
|
53
|
+
*
|
|
54
|
+
* The Agent is responsible for handling decentralized identifier (DID) requests, decentralized web
|
|
55
|
+
* node (DWN) requests, and verifiable credential (VC) requests.
|
|
56
|
+
*
|
|
57
|
+
* The `AgentDid` property represents the Web5 Agent's own DID, while the various process and send
|
|
58
|
+
* methods enable the Agent to handle and initiate requests pertaining to DIDs, DWNs, and VCs.
|
|
59
|
+
*/
|
|
60
|
+
export interface Web5Agent {
|
|
61
|
+
/**
|
|
62
|
+
* The Decentralized Identifier (DID) of this Web5 Agent.
|
|
63
|
+
*/
|
|
64
|
+
agentDid: BearerDid;
|
|
65
|
+
/**
|
|
66
|
+
* Processes a DID request, handling it internally within the agent and returning a DID response,
|
|
67
|
+
* typically involving operations like DID creation or resolution.
|
|
68
|
+
*/
|
|
69
|
+
processDidRequest<T extends DidInterface>(request: DidRequest<T>): Promise<DidResponse<T>>;
|
|
70
|
+
/**
|
|
71
|
+
* Sends a DID request to another entity or service, expecting a DID response, often used for
|
|
72
|
+
* interactions involving DIDs occurring over a network or between different agents.
|
|
73
|
+
*/
|
|
74
|
+
sendDidRequest<T extends DidInterface>(request: DidRequest<T>): Promise<DidResponse<T>>;
|
|
75
|
+
/**
|
|
76
|
+
* Processes a request related to a Decentralized Web Node (DWN) and returns a corresponding
|
|
77
|
+
* response.
|
|
78
|
+
*/
|
|
79
|
+
processDwnRequest<T extends DwnInterface>(request: ProcessDwnRequest<T>): Promise<DwnResponse<T>>;
|
|
80
|
+
/**
|
|
81
|
+
* Sends a request to a Decentralized Web Node (DWN) and awaits a response, often used for
|
|
82
|
+
* interactions involving DWNs occurring over a network or between different agents.
|
|
83
|
+
*/
|
|
84
|
+
sendDwnRequest<T extends DwnInterface>(request: SendDwnRequest<T>): Promise<DwnResponse<T>>;
|
|
85
|
+
/**
|
|
86
|
+
* Processes a request for handling Verifiable Credentials (VCs), such as issuing or verifying
|
|
87
|
+
* them, and returns a response indicating the outcome.
|
|
88
|
+
*/
|
|
89
|
+
processVcRequest(request: ProcessVcRequest): Promise<VcResponse>;
|
|
90
|
+
/**
|
|
91
|
+
* Sends a request to issue, verify, or manage Verifiable Credentials (VCs), expecting a response
|
|
92
|
+
* that indicates the result of the operation. This method is often used for interactions
|
|
93
|
+
* involving VCs occurring over a network or between different agents.
|
|
94
|
+
*/
|
|
95
|
+
sendVcRequest(request: SendVcRequest): Promise<VcResponse>;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Represents a Web5 Platform Agent, an extended and more feature-rich implementation of a
|
|
99
|
+
* {@link Web5Agent}.
|
|
100
|
+
*
|
|
101
|
+
* This Agent integrates a comprehensive set of APIs and functionalities, including cryptographic
|
|
102
|
+
* operations, DID management, DWN interaction, identity handling, and data synchronization.
|
|
103
|
+
*
|
|
104
|
+
* The platform agent provides a higher-level abstraction over the core Web5Agent functionalities,
|
|
105
|
+
* facilitating a robust platform for developing Web5 applications. It includes lifecycle management
|
|
106
|
+
* methods like initialization and startup, alongside a suite of specialized APIs and utilities.
|
|
107
|
+
*
|
|
108
|
+
* @typeParam TKeyManager - The type of Key Manager used to manage cryptographic keys.
|
|
109
|
+
*/
|
|
110
|
+
export interface Web5PlatformAgent<TKeyManager extends AgentKeyManager = AgentKeyManager> extends Web5Agent {
|
|
111
|
+
/**
|
|
112
|
+
* The cryptography API, essential for performing various cryptographic operations such
|
|
113
|
+
* as encryption, decryption, signing, and verification, ensuring secure data handling and
|
|
114
|
+
* communication within the Web5 Platform.
|
|
115
|
+
*/
|
|
116
|
+
crypto: AgentCryptoApi;
|
|
117
|
+
/**
|
|
118
|
+
* The DID API, responsible for managing all DID-related functionalities, enabling the agent to
|
|
119
|
+
* create, resolve, update, and manage DIDs.
|
|
120
|
+
*/
|
|
121
|
+
did: AgentDidApi<TKeyManager>;
|
|
122
|
+
/**
|
|
123
|
+
* The DWN API, enabling the Agent to interact with Decentralized Web Nodes (DWNs) and handle
|
|
124
|
+
* requests from Web5 applications.
|
|
125
|
+
*/
|
|
126
|
+
dwn: AgentDwnApi;
|
|
127
|
+
/**
|
|
128
|
+
* The identity management API, handling identity-related operations and allowing the agent to
|
|
129
|
+
* manage Web5 identities, supporting operations like identity creation and update.
|
|
130
|
+
*/
|
|
131
|
+
identity: AgentIdentityApi<TKeyManager>;
|
|
132
|
+
/**
|
|
133
|
+
* The Key Manager instance, central to the agent's cryptographic operations, managing key
|
|
134
|
+
* generation, storage, retrieval, and usage, ensuring secure cryptographic practices.
|
|
135
|
+
*/
|
|
136
|
+
keyManager: TKeyManager;
|
|
137
|
+
/**
|
|
138
|
+
* The Permissions API, handling permission operations such as request, create, revocation, fetching and verifying revocation status.
|
|
139
|
+
*/
|
|
140
|
+
permissions: AgentPermissionsApi;
|
|
141
|
+
/**
|
|
142
|
+
* The RPC (Remote Procedure Call) client interface, facilitating communication with other Web5
|
|
143
|
+
* Agents and services.
|
|
144
|
+
*/
|
|
145
|
+
rpc: Web5Rpc;
|
|
146
|
+
/**
|
|
147
|
+
* The synchronization API, responsible for managing the consistency and real-time update of the
|
|
148
|
+
* agent's data with the state of the distributed network.
|
|
149
|
+
*/
|
|
150
|
+
sync: AgentSyncApi;
|
|
151
|
+
/**
|
|
152
|
+
* An instance of {@link IdentityVault}, providing secure storage and management of a Web5 Agent's
|
|
153
|
+
* DID and cryptographic keys.
|
|
154
|
+
*/
|
|
155
|
+
vault: IdentityVault;
|
|
156
|
+
/**
|
|
157
|
+
* Determines if it's the first time the Agent is being launched, typically used for initialization
|
|
158
|
+
* checks or first-time setup routines.
|
|
159
|
+
*/
|
|
160
|
+
firstLaunch(): Promise<boolean>;
|
|
161
|
+
/**
|
|
162
|
+
* Initializes the agent with essential parameters (e.g., a passphrase) and prepares it for
|
|
163
|
+
* processing Web5 requests.
|
|
164
|
+
*/
|
|
165
|
+
initialize(params: unknown): Promise<unknown>;
|
|
166
|
+
/**
|
|
167
|
+
* Starts the agent with the provided parameters, typically following initialization, to begin
|
|
168
|
+
* normal operation and readiness to process requests.
|
|
169
|
+
*/
|
|
170
|
+
start(params: unknown): Promise<unknown>;
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../src/types/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,C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cAAc,CAAC,CAAC,SAAS,YAAY,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAE5F;;;OAGG;IACH,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IAEhE;;;;OAIG;IACH,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAC5D;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,iBAAiB,CAAC,WAAW,SAAS,eAAe,GAAG,eAAe,CAAE,SAAQ,SAAS;IACzG;;;;OAIG;IACH,MAAM,EAAE,cAAc,CAAC;IAEvB;;;OAGG;IACH,GAAG,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;IAE9B;;;OAGG;IACH,GAAG,EAAE,WAAW,CAAC;IAEjB;;;OAGG;IACH,QAAQ,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAExC;;;OAGG;IACH,UAAU,EAAE,WAAW,CAAC;IAExB;;OAEG;IACH,WAAW,EAAE,mBAAmB,CAAC;IAEjC;;;OAGG;IACH,GAAG,EAAE,OAAO,CAAC;IAEb;;;OAGG;IACH,IAAI,EAAE,YAAY,CAAC;IAEnB;;;OAGG;IACH,KAAK,EAAE,aAAa,CAAC;IAErB;;;OAGG;IACH,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAEhC;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE9C;;;OAGG;IACH,KAAK,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1C"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import type { DidService } from '@enbox/dids';
|
|
2
|
+
import type { Readable, RequireOnly } from '@enbox/common';
|
|
3
|
+
import type { RecordsReadReply, RecordsQueryReply, RecordsReadMessage, RecordsReadOptions, GenericMessageReply, ProtocolsQueryReply, RecordsQueryMessage, RecordsQueryOptions, RecordsWriteMessage, RecordsWriteOptions, RecordsDeleteMessage, RecordsDeleteOptions, ProtocolsQueryMessage, ProtocolsQueryOptions, ProtocolsConfigureMessage, ProtocolsConfigureOptions, RecordsSubscribeMessage, RecordsSubscribeOptions, RecordsSubscribeReply, MessageSubscriptionHandler, RecordSubscriptionHandler, MessagesQueryMessage, MessagesReadMessage, MessagesSubscribeMessage, MessagesQueryOptions, MessagesReadOptions, MessagesSubscribeOptions, MessagesQueryReply, MessagesReadReply, MessagesSubscribeReply } from '@enbox/dwn-sdk-js';
|
|
4
|
+
import { RecordsRead, RecordsQuery, RecordsWrite, RecordsDelete, ProtocolsQuery, ProtocolsConfigure, RecordsSubscribe, MessagesQuery, MessagesRead, MessagesSubscribe } from '@enbox/dwn-sdk-js';
|
|
5
|
+
/**
|
|
6
|
+
* Represents a Decentralized Web Node (DWN) service in a DID Document.
|
|
7
|
+
*
|
|
8
|
+
* A DWN DID service is a specialized type of DID service with the `type` set to
|
|
9
|
+
* `DecentralizedWebNode`. It includes specific properties `enc` and `sig` that are used to identify
|
|
10
|
+
* the public keys that can be used to interact with the DID Subject. The values of these properties
|
|
11
|
+
* are strings or arrays of strings containing one or more verification method `id` values present in
|
|
12
|
+
* the same DID document. If the `enc` and/or `sig` properties are an array of strings, an entity
|
|
13
|
+
* interacting with the DID subject is expected to use the verification methods in the order they
|
|
14
|
+
* are listed.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const service: DwnDidService = {
|
|
19
|
+
* id: 'did:example:123#dwn',
|
|
20
|
+
* type: 'DecentralizedWebNode',
|
|
21
|
+
* serviceEndpoint: 'https://enbox-production.up.railway.app',
|
|
22
|
+
* enc: 'did:example:123#key-1',
|
|
23
|
+
* sig: 'did:example:123#key-2'
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @see {@link https://identity.foundation/decentralized-web-node/spec/ | DIF Decentralized Web Node (DWN) Specification}
|
|
28
|
+
*/
|
|
29
|
+
export interface DwnDidService extends DidService {
|
|
30
|
+
/**
|
|
31
|
+
* One or more verification method `id` values that can be used to encrypt information
|
|
32
|
+
* intended for the DID subject.
|
|
33
|
+
*/
|
|
34
|
+
enc?: string | string[];
|
|
35
|
+
/**
|
|
36
|
+
* One or more verification method `id` values that will be used by the DID subject to sign data
|
|
37
|
+
* or by another entity to verify signatures created by the DID subject.
|
|
38
|
+
*/
|
|
39
|
+
sig: string | string[];
|
|
40
|
+
}
|
|
41
|
+
export declare enum DwnInterface {
|
|
42
|
+
MessagesQuery = "MessagesQuery",
|
|
43
|
+
MessagesRead = "MessagesRead",
|
|
44
|
+
MessagesSubscribe = "MessagesSubscribe",
|
|
45
|
+
ProtocolsConfigure = "ProtocolsConfigure",
|
|
46
|
+
ProtocolsQuery = "ProtocolsQuery",
|
|
47
|
+
RecordsDelete = "RecordsDelete",
|
|
48
|
+
RecordsQuery = "RecordsQuery",
|
|
49
|
+
RecordsRead = "RecordsRead",
|
|
50
|
+
RecordsSubscribe = "RecordsSubscribe",
|
|
51
|
+
RecordsWrite = "RecordsWrite"
|
|
52
|
+
}
|
|
53
|
+
export type DwnRecordsInterfaces = DwnInterface.RecordsDelete | DwnInterface.RecordsQuery | DwnInterface.RecordsRead | DwnInterface.RecordsSubscribe | DwnInterface.RecordsWrite;
|
|
54
|
+
export type DwnMessageInterfaces = DwnInterface.MessagesQuery | DwnInterface.MessagesRead | DwnInterface.MessagesSubscribe;
|
|
55
|
+
export type DwnProtocolInterfaces = DwnInterface.ProtocolsConfigure | DwnInterface.ProtocolsQuery;
|
|
56
|
+
export interface DwnMessage {
|
|
57
|
+
[DwnInterface.MessagesQuery]: MessagesQueryMessage;
|
|
58
|
+
[DwnInterface.MessagesRead]: MessagesReadMessage;
|
|
59
|
+
[DwnInterface.MessagesSubscribe]: MessagesSubscribeMessage;
|
|
60
|
+
[DwnInterface.ProtocolsConfigure]: ProtocolsConfigureMessage;
|
|
61
|
+
[DwnInterface.ProtocolsQuery]: ProtocolsQueryMessage;
|
|
62
|
+
[DwnInterface.RecordsDelete]: RecordsDeleteMessage;
|
|
63
|
+
[DwnInterface.RecordsQuery]: RecordsQueryMessage;
|
|
64
|
+
[DwnInterface.RecordsRead]: RecordsReadMessage;
|
|
65
|
+
[DwnInterface.RecordsSubscribe]: RecordsSubscribeMessage;
|
|
66
|
+
[DwnInterface.RecordsWrite]: RecordsWriteMessage;
|
|
67
|
+
}
|
|
68
|
+
export interface DwnMessageDescriptor {
|
|
69
|
+
[DwnInterface.MessagesQuery]: MessagesQueryMessage['descriptor'];
|
|
70
|
+
[DwnInterface.MessagesRead]: MessagesReadMessage['descriptor'];
|
|
71
|
+
[DwnInterface.MessagesSubscribe]: MessagesSubscribeMessage['descriptor'];
|
|
72
|
+
[DwnInterface.ProtocolsConfigure]: ProtocolsConfigureMessage['descriptor'];
|
|
73
|
+
[DwnInterface.ProtocolsQuery]: ProtocolsQueryMessage['descriptor'];
|
|
74
|
+
[DwnInterface.RecordsDelete]: RecordsDeleteMessage['descriptor'];
|
|
75
|
+
[DwnInterface.RecordsQuery]: RecordsQueryMessage['descriptor'];
|
|
76
|
+
[DwnInterface.RecordsRead]: RecordsReadMessage['descriptor'];
|
|
77
|
+
[DwnInterface.RecordsSubscribe]: RecordsSubscribeMessage['descriptor'];
|
|
78
|
+
[DwnInterface.RecordsWrite]: RecordsWriteMessage['descriptor'];
|
|
79
|
+
}
|
|
80
|
+
export interface DwnMessageParams {
|
|
81
|
+
[DwnInterface.MessagesQuery]: RequireOnly<MessagesQueryOptions, 'filters'>;
|
|
82
|
+
[DwnInterface.MessagesRead]: RequireOnly<MessagesReadOptions, 'messageCid'>;
|
|
83
|
+
[DwnInterface.MessagesSubscribe]: Partial<MessagesSubscribeOptions>;
|
|
84
|
+
[DwnInterface.ProtocolsConfigure]: RequireOnly<ProtocolsConfigureOptions, 'definition'>;
|
|
85
|
+
[DwnInterface.ProtocolsQuery]: ProtocolsQueryOptions;
|
|
86
|
+
[DwnInterface.RecordsDelete]: RequireOnly<RecordsDeleteOptions, 'recordId'>;
|
|
87
|
+
[DwnInterface.RecordsQuery]: RecordsQueryOptions;
|
|
88
|
+
[DwnInterface.RecordsRead]: RecordsReadOptions;
|
|
89
|
+
[DwnInterface.RecordsSubscribe]: RecordsSubscribeOptions;
|
|
90
|
+
[DwnInterface.RecordsWrite]: RecordsWriteOptions;
|
|
91
|
+
}
|
|
92
|
+
export interface DwnMessageReply {
|
|
93
|
+
[DwnInterface.MessagesQuery]: MessagesQueryReply;
|
|
94
|
+
[DwnInterface.MessagesRead]: MessagesReadReply;
|
|
95
|
+
[DwnInterface.MessagesSubscribe]: MessagesSubscribeReply;
|
|
96
|
+
[DwnInterface.ProtocolsConfigure]: GenericMessageReply;
|
|
97
|
+
[DwnInterface.ProtocolsQuery]: ProtocolsQueryReply;
|
|
98
|
+
[DwnInterface.RecordsDelete]: GenericMessageReply;
|
|
99
|
+
[DwnInterface.RecordsQuery]: RecordsQueryReply;
|
|
100
|
+
[DwnInterface.RecordsRead]: RecordsReadReply;
|
|
101
|
+
[DwnInterface.RecordsSubscribe]: RecordsSubscribeReply;
|
|
102
|
+
[DwnInterface.RecordsWrite]: GenericMessageReply;
|
|
103
|
+
}
|
|
104
|
+
export interface MessageHandler {
|
|
105
|
+
[DwnInterface.MessagesSubscribe]: MessageSubscriptionHandler;
|
|
106
|
+
[DwnInterface.RecordsSubscribe]: RecordSubscriptionHandler;
|
|
107
|
+
[DwnInterface.MessagesQuery]: undefined;
|
|
108
|
+
[DwnInterface.MessagesRead]: undefined;
|
|
109
|
+
[DwnInterface.ProtocolsConfigure]: undefined;
|
|
110
|
+
[DwnInterface.ProtocolsQuery]: undefined;
|
|
111
|
+
[DwnInterface.RecordsDelete]: undefined;
|
|
112
|
+
[DwnInterface.RecordsQuery]: undefined;
|
|
113
|
+
[DwnInterface.RecordsRead]: undefined;
|
|
114
|
+
[DwnInterface.RecordsWrite]: undefined;
|
|
115
|
+
}
|
|
116
|
+
export type DwnRequest<T extends DwnInterface> = {
|
|
117
|
+
author: string;
|
|
118
|
+
target: string;
|
|
119
|
+
messageType: T;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Defines the structure for response status, including a status code and detail message.
|
|
123
|
+
*/
|
|
124
|
+
export type DwnResponseStatus = {
|
|
125
|
+
/** Encapsulates the outcome of an operation, providing both a numeric status code and a descriptive message. */
|
|
126
|
+
status: {
|
|
127
|
+
/** Numeric status code representing the outcome of the operation. */
|
|
128
|
+
code: number;
|
|
129
|
+
/** Descriptive detail about the status or error. */
|
|
130
|
+
detail: string;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
export type ProcessDwnRequest<T extends DwnInterface> = DwnRequest<T> & {
|
|
134
|
+
dataStream?: Blob | ReadableStream | Readable;
|
|
135
|
+
rawMessage?: DwnMessage[T];
|
|
136
|
+
messageParams?: DwnMessageParams[T];
|
|
137
|
+
store?: boolean;
|
|
138
|
+
signAsOwner?: boolean;
|
|
139
|
+
signAsOwnerDelegate?: boolean;
|
|
140
|
+
granteeDid?: string;
|
|
141
|
+
subscriptionHandler?: MessageHandler[T];
|
|
142
|
+
};
|
|
143
|
+
export type SendDwnRequest<T extends DwnInterface> = DwnRequest<T> & (ProcessDwnRequest<T> | {
|
|
144
|
+
messageCid: string;
|
|
145
|
+
});
|
|
146
|
+
export type DwnResponse<T extends DwnInterface> = {
|
|
147
|
+
message?: DwnMessage[T];
|
|
148
|
+
messageCid: string;
|
|
149
|
+
reply: DwnMessageReply[T];
|
|
150
|
+
};
|
|
151
|
+
export interface DwnMessageConstructor<T extends DwnInterface> {
|
|
152
|
+
new (): DwnMessageInstance[T];
|
|
153
|
+
create(params: DwnMessageParams[T]): Promise<DwnMessageInstance[T]>;
|
|
154
|
+
parse(rawMessage: DwnMessage[T]): Promise<DwnMessageInstance[T]>;
|
|
155
|
+
}
|
|
156
|
+
export declare const dwnMessageConstructors: {
|
|
157
|
+
[T in DwnInterface]: DwnMessageConstructor<T>;
|
|
158
|
+
};
|
|
159
|
+
export type DwnMessageConstructors = typeof dwnMessageConstructors;
|
|
160
|
+
export interface DwnMessageInstance {
|
|
161
|
+
[DwnInterface.MessagesQuery]: MessagesQuery;
|
|
162
|
+
[DwnInterface.MessagesRead]: MessagesRead;
|
|
163
|
+
[DwnInterface.MessagesSubscribe]: MessagesSubscribe;
|
|
164
|
+
[DwnInterface.ProtocolsConfigure]: ProtocolsConfigure;
|
|
165
|
+
[DwnInterface.ProtocolsQuery]: ProtocolsQuery;
|
|
166
|
+
[DwnInterface.RecordsDelete]: RecordsDelete;
|
|
167
|
+
[DwnInterface.RecordsQuery]: RecordsQuery;
|
|
168
|
+
[DwnInterface.RecordsRead]: RecordsRead;
|
|
169
|
+
[DwnInterface.RecordsSubscribe]: RecordsSubscribe;
|
|
170
|
+
[DwnInterface.RecordsWrite]: RecordsWrite;
|
|
171
|
+
}
|
|
172
|
+
export type DwnMessageWithData<T extends DwnInterface> = {
|
|
173
|
+
message: DwnMessage[T];
|
|
174
|
+
dataStream?: Readable;
|
|
175
|
+
};
|
|
176
|
+
export { DwnConstant, Signer as DwnSigner, DateSort as DwnDateSort, DataEncodedRecordsWriteMessage as DwnDataEncodedRecordsWriteMessage, PublicJwk as DwnPublicKeyJwk, // TODO: Remove once DWN SDK switches to Jwk from @enbox/crypto
|
|
177
|
+
PaginationCursor as DwnPaginationCursor, MessageSubscriptionHandler as DwnMessageSubscriptionHandler, RecordSubscriptionHandler as DwnRecordSubscriptionHandler, MessageSubscription as DwnMessageSubscription, MessagesPermissionScope as DwnMessagesPermissionScope, EncryptionAlgorithm as DwnEncryptionAlgorithm, KeyDerivationScheme as DwnKeyDerivationScheme, PermissionGrant as DwnPermissionGrant, PermissionGrantData as DwnPermissionGrantData, PermissionRequest as DwnPermissionRequest, PermissionRequestData as DwnPermissionRequestData, PermissionsProtocol as DwnPermissionsProtocol, ProtocolDefinition as DwnProtocolDefinition, ProtocolPermissionScope as DwnProtocolPermissionScope, RecordsPermissionScope as DwnRecordsPermissionScope, PermissionConditions as DwnPermissionConditions, PermissionScope as DwnPermissionScope, } from '@enbox/dwn-sdk-js';
|
|
178
|
+
//# sourceMappingURL=dwn.d.ts.map
|