@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,30 @@
|
|
|
1
|
+
export type * from './types/agent.js';
|
|
2
|
+
export * from './types/dwn.js';
|
|
3
|
+
export type * from './types/identity.js';
|
|
4
|
+
export type * from './types/identity-vault.js';
|
|
5
|
+
export type * from './types/key-manager.js';
|
|
6
|
+
export type * from './types/permissions.js';
|
|
7
|
+
export type * from './types/sync.js';
|
|
8
|
+
export type * from './types/vc.js';
|
|
9
|
+
export * from './agent-did-resolver-cache.js';
|
|
10
|
+
export * from './bearer-identity.js';
|
|
11
|
+
export * from './crypto-api.js';
|
|
12
|
+
export * from './did-api.js';
|
|
13
|
+
export * from './dwn-api.js';
|
|
14
|
+
export * from './dwn-registrar.js';
|
|
15
|
+
export * from './hd-identity-vault.js';
|
|
16
|
+
export * from './identity-api.js';
|
|
17
|
+
export * from './local-key-manager.js';
|
|
18
|
+
export * from './permissions-api.js';
|
|
19
|
+
export * from './rpc-client.js';
|
|
20
|
+
export * from './store-data.js';
|
|
21
|
+
export * from './store-did.js';
|
|
22
|
+
export * from './store-identity.js';
|
|
23
|
+
export * from './store-key.js';
|
|
24
|
+
export * from './sync-api.js';
|
|
25
|
+
export * from './sync-engine-level.js';
|
|
26
|
+
export * from './test-harness.js';
|
|
27
|
+
export * from './utils.js';
|
|
28
|
+
export * from './connect.js';
|
|
29
|
+
export * from './oidc.js';
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,kBAAkB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,mBAAmB,qBAAqB,CAAC;AACzC,mBAAmB,2BAA2B,CAAC;AAC/C,mBAAmB,wBAAwB,CAAC;AAC5C,mBAAmB,wBAAwB,CAAC;AAC5C,mBAAmB,iBAAiB,CAAC;AACrC,mBAAmB,eAAe,CAAC;AAEnC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC;AACvC,cAAe,mBAAmB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import type { Jwk, AesGcmParams, KeyIdentifier, KmsSignParams, KmsDigestParams, KmsVerifyParams, KmsExportKeyParams, KmsGetKeyUriParams, KmsImportKeyParams, KmsGenerateKeyParams, KmsGetPublicKeyParams } from '@enbox/crypto';
|
|
2
|
+
import type { AgentDataStore } from './store-data.js';
|
|
3
|
+
import type { Web5PlatformAgent } from './types/agent.js';
|
|
4
|
+
import type { AgentKeyManager } from './types/key-manager.js';
|
|
5
|
+
import type { InferType } from './prototyping/common/type-utils.js';
|
|
6
|
+
import type { KmsCipherParams, KmsUnwrapKeyParams, KmsWrapKeyParams } from './prototyping/crypto/types/params-kms.js';
|
|
7
|
+
type SupportedKeyGeneratorAlgorithm = 'Ed25519' | 'secp256k1' | 'ES256K' | 'secp256r1' | 'ES256' | 'A128GCM' | 'A192GCM' | 'A256GCM' | 'A128KW' | 'A192KW' | 'A256KW';
|
|
8
|
+
/**
|
|
9
|
+
* The `LocalKmsParams` interface specifies the parameters for initializing an instance of
|
|
10
|
+
* {@link LocalKeyManager}. It allows the optional inclusion of a {@link AgentDataStore} instance
|
|
11
|
+
* for key management. If not provided, a default {@link InMemoryKeyStore} instance will be used for
|
|
12
|
+
* storing keys. Note that the {@link InMemoryKeyStore} is not persistent and will be cleared when
|
|
13
|
+
* the application exits.
|
|
14
|
+
*/
|
|
15
|
+
export type LocalKmsParams = {
|
|
16
|
+
agent?: Web5PlatformAgent;
|
|
17
|
+
/**
|
|
18
|
+
* An optional property to specify a custom {@link AgentDataStore} instance for key management. If
|
|
19
|
+
* not provided, {@link LocalKeyManager} uses a default {@link InMemoryKeyStore} instance. This
|
|
20
|
+
* store is responsible for managing cryptographic keys, allowing them to be retrieved, stored,
|
|
21
|
+
* and managed during cryptographic operations.
|
|
22
|
+
*/
|
|
23
|
+
keyStore?: AgentDataStore<Jwk>;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The `LocalKmsGenerateKeyParams` interface defines the algorithm-specific parameters that
|
|
27
|
+
* should be passed into the {@link LocalKeyManager.generateKey | `LocalKeyManager.generateKey()`}
|
|
28
|
+
* method when generating a key in the local KMS.
|
|
29
|
+
*/
|
|
30
|
+
export interface LocalKmsGenerateKeyParams extends KmsGenerateKeyParams {
|
|
31
|
+
/**
|
|
32
|
+
* A string defining the type of key to generate.
|
|
33
|
+
*/
|
|
34
|
+
algorithm: InferType<SupportedKeyGeneratorAlgorithm>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The `LocalKmsUnwrapKeyParams` interface defines the algorithm-specific parameters that
|
|
38
|
+
* should be passed into the {@link LocalKeyManager.wrapKey} method when wrapping a key using a
|
|
39
|
+
* key stored in the local KMS to encrypt the key material.
|
|
40
|
+
*/
|
|
41
|
+
export interface LocalKmsUnwrapKeyParams extends KmsUnwrapKeyParams {
|
|
42
|
+
/**
|
|
43
|
+
* A string defining the type of wrapped key. The value must be one of the following:
|
|
44
|
+
* - `"A128GCM"`: AES GCM using a 128-bit key.
|
|
45
|
+
* - `"A192GCM"`: AES GCM using a 192-bit key.
|
|
46
|
+
* - `"A256GCM"`: AES GCM using a 256-bit key.
|
|
47
|
+
* - `"A128KW"`: AES Key Wrap using a 128-bit key.
|
|
48
|
+
* - `"A192KW"`: AES Key Wrap using a 192-bit key.
|
|
49
|
+
* - `"A256KW"`: AES Key Wrap using a 256-bit key.
|
|
50
|
+
*/
|
|
51
|
+
wrappedKeyAlgorithm: 'A128GCM' | 'A192GCM' | 'A256GCM' | 'A128KW' | 'A192KW' | 'A256KW';
|
|
52
|
+
}
|
|
53
|
+
export declare class LocalKeyManager implements AgentKeyManager {
|
|
54
|
+
/**
|
|
55
|
+
* Holds the instance of a `Web5PlatformAgent` that represents the current execution context for
|
|
56
|
+
* the `LocalKeyManager`. This agent is used to interact with other Web5 agent components. It's
|
|
57
|
+
* vital to ensure this instance is set to correctly contextualize operations within the broader
|
|
58
|
+
* Web5 Agent framework.
|
|
59
|
+
*/
|
|
60
|
+
private _agent?;
|
|
61
|
+
/**
|
|
62
|
+
* A private map that stores instances of cryptographic algorithm implementations. Each key in
|
|
63
|
+
* this map is an `AlgorithmConstructor`, and its corresponding value is an instance of a class
|
|
64
|
+
* that implements a specific cryptographic algorithm. This map is used to cache and reuse
|
|
65
|
+
* instances for performance optimization, ensuring that each algorithm is instantiated only once.
|
|
66
|
+
*/
|
|
67
|
+
private _algorithmInstances;
|
|
68
|
+
/**
|
|
69
|
+
* The `_keyStore` private variable in `LocalKeyManager` is a {@link AgentDataStore} instance used
|
|
70
|
+
* for storing and managing cryptographic keys. It allows the `LocalKeyManager` class to save,
|
|
71
|
+
* retrieve, and handle keys efficiently within the local Key Management System (KMS) context.
|
|
72
|
+
* This variable can be configured to use different storage backends, like in-memory storage or
|
|
73
|
+
* persistent storage, providing flexibility in key management according to the application's
|
|
74
|
+
* requirements.
|
|
75
|
+
*/
|
|
76
|
+
private _keyStore;
|
|
77
|
+
constructor({ agent, keyStore }?: LocalKmsParams);
|
|
78
|
+
/**
|
|
79
|
+
* Retrieves the `Web5PlatformAgent` execution context.
|
|
80
|
+
*
|
|
81
|
+
* @returns The `Web5PlatformAgent` instance that represents the current execution context.
|
|
82
|
+
* @throws Will throw an error if the `agent` instance property is undefined.
|
|
83
|
+
*/
|
|
84
|
+
get agent(): Web5PlatformAgent;
|
|
85
|
+
set agent(agent: Web5PlatformAgent);
|
|
86
|
+
decrypt({ keyUri, ...params }: KmsCipherParams & AesGcmParams): Promise<Uint8Array>;
|
|
87
|
+
digest(_params: KmsDigestParams): Promise<Uint8Array>;
|
|
88
|
+
encrypt({ keyUri, ...params }: KmsCipherParams & AesGcmParams): Promise<Uint8Array>;
|
|
89
|
+
/**
|
|
90
|
+
* Exports a private key identified by the provided key URI from the local KMS.
|
|
91
|
+
*
|
|
92
|
+
* @remarks
|
|
93
|
+
* This method retrieves the key from the key store and returns it. It is primarily used
|
|
94
|
+
* for extracting keys for backup or transfer purposes.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```ts
|
|
98
|
+
* const keyManager = new LocalKeyManager();
|
|
99
|
+
* const keyUri = await keyManager.generateKey({ algorithm: 'Ed25519' });
|
|
100
|
+
* const privateKey = await keyManager.exportKey({ keyUri });
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* @param params - Parameters for exporting the key.
|
|
104
|
+
* @param params.keyUri - The key URI identifying the key to export.
|
|
105
|
+
*
|
|
106
|
+
* @returns A Promise resolving to the JWK representation of the exported key.
|
|
107
|
+
*/
|
|
108
|
+
exportKey({ keyUri }: KmsExportKeyParams): Promise<Jwk>;
|
|
109
|
+
/**
|
|
110
|
+
* Generates a new cryptographic key in the local KMS with the specified algorithm and returns a
|
|
111
|
+
* unique key URI which can be used to reference the key in subsequent operations.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* const keyManager = new LocalKeyManager();
|
|
116
|
+
* const keyUri = await keyManager.generateKey({ algorithm: 'Ed25519' });
|
|
117
|
+
* console.log(keyUri); // Outputs the key URI
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* @param params - The parameters for key generation.
|
|
121
|
+
* @param params.algorithm - The algorithm to use for key generation, defined in `SupportedAlgorithm`.
|
|
122
|
+
*
|
|
123
|
+
* @returns A Promise that resolves to the key URI, a unique identifier for the generated key.
|
|
124
|
+
*/
|
|
125
|
+
generateKey({ algorithm: algorithmIdentifier }: LocalKmsGenerateKeyParams): Promise<KeyIdentifier>;
|
|
126
|
+
/**
|
|
127
|
+
* Computes the Key URI for a given public JWK (JSON Web Key).
|
|
128
|
+
*
|
|
129
|
+
* @remarks
|
|
130
|
+
* This method generates a {@link https://datatracker.ietf.org/doc/html/rfc3986 | URI}
|
|
131
|
+
* (Uniform Resource Identifier) for the given JWK, which uniquely identifies the key across all
|
|
132
|
+
* `CryptoApi` implementations. The key URI is constructed by appending the
|
|
133
|
+
* {@link https://datatracker.ietf.org/doc/html/rfc7638 | JWK thumbprint} to the prefix
|
|
134
|
+
* `urn:jwk:`. The JWK thumbprint is deterministically computed from the JWK and is consistent
|
|
135
|
+
* regardless of property order or optional property inclusion in the JWK. This ensures that the
|
|
136
|
+
* same key material represented as a JWK will always yield the same thumbprint, and therefore,
|
|
137
|
+
* the same key URI.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* const keyManager = new LocalKeyManager();
|
|
142
|
+
* const keyUri = await keyManager.generateKey({ algorithm: 'Ed25519' });
|
|
143
|
+
* const publicKey = await keyManager.getPublicKey({ keyUri });
|
|
144
|
+
* const keyUriFromPublicKey = await keyManager.getKeyUri({ key: publicKey });
|
|
145
|
+
* console.log(keyUri === keyUriFromPublicKey); // Outputs `true`
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* @param params - The parameters for getting the key URI.
|
|
149
|
+
* @param params.key - The JWK for which to compute the key URI.
|
|
150
|
+
*
|
|
151
|
+
* @returns A Promise that resolves to the key URI as a string.
|
|
152
|
+
*/
|
|
153
|
+
getKeyUri({ key }: KmsGetKeyUriParams): Promise<KeyIdentifier>;
|
|
154
|
+
/**
|
|
155
|
+
* Retrieves the public key associated with a previously generated private key, identified by
|
|
156
|
+
* the provided key URI.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```ts
|
|
160
|
+
* const keyManager = new LocalKeyManager();
|
|
161
|
+
* const keyUri = await keyManager.generateKey({ algorithm: 'Ed25519' });
|
|
162
|
+
* const publicKey = await keyManager.getPublicKey({ keyUri });
|
|
163
|
+
* ```
|
|
164
|
+
*
|
|
165
|
+
* @param params - The parameters for retrieving the public key.
|
|
166
|
+
* @param params.keyUri - The key URI of the private key to retrieve the public key for.
|
|
167
|
+
*
|
|
168
|
+
* @returns A Promise that resolves to the public key in JWK format.
|
|
169
|
+
*/
|
|
170
|
+
getPublicKey({ keyUri }: KmsGetPublicKeyParams): Promise<Jwk>;
|
|
171
|
+
/**
|
|
172
|
+
* Imports a private key into the local KMS.
|
|
173
|
+
*
|
|
174
|
+
* @remarks
|
|
175
|
+
* This method stores the provided JWK in the key store, making it available for subsequent
|
|
176
|
+
* cryptographic operations. It is particularly useful for initializing the KMS with pre-existing
|
|
177
|
+
* keys or for restoring keys from backups.
|
|
178
|
+
*
|
|
179
|
+
* Note that, if defined, the `kid` (key ID) property of the JWK is used as the key URI for the
|
|
180
|
+
* imported key. If the `kid` property is not provided, the key URI is computed from the JWK
|
|
181
|
+
* thumbprint of the key.
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```ts
|
|
185
|
+
* const keyManager = new LocalKeyManager();
|
|
186
|
+
* const privateKey = { ... } // A private key in JWK format
|
|
187
|
+
* const keyUri = await keyManager.importKey({ key: privateKey });
|
|
188
|
+
* ```
|
|
189
|
+
*
|
|
190
|
+
* @param params - Parameters for importing the key.
|
|
191
|
+
* @param params.key - The private key to import to in JWK format.
|
|
192
|
+
*
|
|
193
|
+
* @returns A Promise resolving to the key URI, uniquely identifying the imported key.
|
|
194
|
+
*/
|
|
195
|
+
importKey({ key }: KmsImportKeyParams): Promise<KeyIdentifier>;
|
|
196
|
+
/**
|
|
197
|
+
* Signs the provided data using the private key identified by the provided key URI.
|
|
198
|
+
*
|
|
199
|
+
* @remarks
|
|
200
|
+
* This method uses the signature algorithm determined by the `alg` and/or `crv` properties of the
|
|
201
|
+
* private key identified by the provided key URI to sign the provided data. The signature can
|
|
202
|
+
* later be verified by parties with access to the corresponding public key, ensuring that the
|
|
203
|
+
* data has not been tampered with and was indeed signed by the holder of the private key.
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```ts
|
|
207
|
+
* const keyManager = new LocalKeyManager();
|
|
208
|
+
* const keyUri = await keyManager.generateKey({ algorithm: 'Ed25519' });
|
|
209
|
+
* const data = new TextEncoder().encode('Message to sign');
|
|
210
|
+
* const signature = await keyManager.sign({ keyUri, data });
|
|
211
|
+
* ```
|
|
212
|
+
*
|
|
213
|
+
* @param params - The parameters for the signing operation.
|
|
214
|
+
* @param params.keyUri - The key URI of the private key to use for signing.
|
|
215
|
+
* @param params.data - The data to sign.
|
|
216
|
+
*
|
|
217
|
+
* @returns A Promise resolving to the digital signature as a `Uint8Array`.
|
|
218
|
+
*/
|
|
219
|
+
sign({ keyUri, data }: KmsSignParams): Promise<Uint8Array>;
|
|
220
|
+
unwrapKey({ wrappedKeyBytes, wrappedKeyAlgorithm, decryptionKeyUri }: LocalKmsUnwrapKeyParams): Promise<Jwk>;
|
|
221
|
+
/**
|
|
222
|
+
* Verifies a digital signature associated the provided data using the provided key.
|
|
223
|
+
*
|
|
224
|
+
* @remarks
|
|
225
|
+
* This method uses the signature algorithm determined by the `alg` and/or `crv` properties of the
|
|
226
|
+
* provided key to check the validity of a digital signature against the original data. It
|
|
227
|
+
* confirms whether the signature was created by the holder of the corresponding private key and
|
|
228
|
+
* that the data has not been tampered with.
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* ```ts
|
|
232
|
+
* const keyManager = new LocalKeyManager();
|
|
233
|
+
* const keyUri = await keyManager.generateKey({ algorithm: 'Ed25519' });
|
|
234
|
+
* const data = new TextEncoder().encode('Message to sign');
|
|
235
|
+
* const signature = await keyManager.sign({ keyUri, data });
|
|
236
|
+
* const isSignatureValid = await keyManager.verify({ keyUri, data, signature });
|
|
237
|
+
* ```
|
|
238
|
+
*
|
|
239
|
+
* @param params - The parameters for the verification operation.
|
|
240
|
+
* @param params.key - The key to use for verification.
|
|
241
|
+
* @param params.signature - The signature to verify.
|
|
242
|
+
* @param params.data - The data to verify.
|
|
243
|
+
*
|
|
244
|
+
* @returns A Promise resolving to a boolean indicating whether the signature is valid.
|
|
245
|
+
*/
|
|
246
|
+
verify({ key, signature, data }: KmsVerifyParams): Promise<boolean>;
|
|
247
|
+
wrapKey({ unwrappedKey, encryptionKeyUri }: KmsWrapKeyParams): Promise<Uint8Array>;
|
|
248
|
+
deleteKey({ keyUri }: {
|
|
249
|
+
keyUri: KeyIdentifier;
|
|
250
|
+
}): Promise<void>;
|
|
251
|
+
/**
|
|
252
|
+
* Retrieves an algorithm implementation instance based on the provided algorithm name.
|
|
253
|
+
*
|
|
254
|
+
* @remarks
|
|
255
|
+
* This method checks if the requested algorithm is supported and returns a cached instance
|
|
256
|
+
* if available. If an instance does not exist, it creates and caches a new one. This approach
|
|
257
|
+
* optimizes performance by reusing algorithm instances across cryptographic operations.
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```ts
|
|
261
|
+
* const signer = this.getAlgorithm({ algorithm: 'Ed25519' });
|
|
262
|
+
* ```
|
|
263
|
+
*
|
|
264
|
+
* @param params - The parameters for retrieving the algorithm implementation.
|
|
265
|
+
* @param params.algorithm - The name of the algorithm to retrieve.
|
|
266
|
+
*
|
|
267
|
+
* @returns An instance of the requested algorithm implementation.
|
|
268
|
+
*
|
|
269
|
+
* @throws Error if the requested algorithm is not supported.
|
|
270
|
+
*/
|
|
271
|
+
private getAlgorithm;
|
|
272
|
+
/**
|
|
273
|
+
* Determines the algorithm name based on the key's properties.
|
|
274
|
+
*
|
|
275
|
+
* @remarks
|
|
276
|
+
* This method facilitates the identification of the correct algorithm for cryptographic
|
|
277
|
+
* operations based on the `alg` or `crv` properties of a {@link Jwk | JWK}.
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* ```ts
|
|
281
|
+
* const publicKey = { ... }; // Public key in JWK format
|
|
282
|
+
* const algorithm = this.getAlgorithmName({ key: publicKey });
|
|
283
|
+
* ```
|
|
284
|
+
*
|
|
285
|
+
* @param params - The parameters for determining the algorithm name.
|
|
286
|
+
* @param params.key - A JWK containing the `alg` or `crv` properties.
|
|
287
|
+
*
|
|
288
|
+
* @returns The algorithm name associated with the key.
|
|
289
|
+
*
|
|
290
|
+
* @throws Error if the algorithm name cannot be determined from the provided input.
|
|
291
|
+
*/
|
|
292
|
+
private getAlgorithmName;
|
|
293
|
+
/**
|
|
294
|
+
* Retrieves a private key from the key store based on the provided key URI.
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* ```ts
|
|
298
|
+
* const privateKey = this.getPrivateKey({ keyUri: 'urn:jwk:...' });
|
|
299
|
+
* ```
|
|
300
|
+
*
|
|
301
|
+
* @param params - Parameters for retrieving the private key.
|
|
302
|
+
* @param params.keyUri - The key URI identifying the private key to retrieve.
|
|
303
|
+
*
|
|
304
|
+
* @returns A Promise resolving to the JWK representation of the private key.
|
|
305
|
+
*
|
|
306
|
+
* @throws Error if the key is not found in the key store.
|
|
307
|
+
*/
|
|
308
|
+
private getPrivateKey;
|
|
309
|
+
}
|
|
310
|
+
export {};
|
|
311
|
+
//# sourceMappingURL=local-key-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-key-manager.d.ts","sourceRoot":"","sources":["../../src/local-key-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,GAAG,EAKH,YAAY,EAGZ,aAAa,EACb,aAAa,EACb,eAAe,EACf,eAAe,EAEf,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EAEtB,MAAM,eAAe,CAAC;AAavB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAEpE,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,E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KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAU3E;;;;;;;;;;;;;;;;;;;OAmBG;IACH,OAAO,CAAC,YAAY;IAmBpB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,OAAO,CAAC,gBAAgB;IAqBxB;;;;;;;;;;;;;;OAcG;YACW,aAAa;CAY5B"}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { RequireOnly } from '@enbox/common';
|
|
2
|
+
import type { ConnectPermissionRequest } from './connect.js';
|
|
3
|
+
import { DidDocument, PortableDid, type BearerDid } from '@enbox/dids';
|
|
4
|
+
import { DwnDataEncodedRecordsWriteMessage, DwnPermissionScope } from './types/dwn.js';
|
|
5
|
+
import type { Web5Agent } from './types/agent.js';
|
|
6
|
+
/**
|
|
7
|
+
* Sent to an OIDC server to authorize a client. Allows clients
|
|
8
|
+
* to securely send authorization request parameters directly to
|
|
9
|
+
* the server via POST. This avoids exposing sensitive data in URLs
|
|
10
|
+
* and ensures the server validates the request before user interaction.
|
|
11
|
+
*
|
|
12
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc9126.html | OAuth 2.0 Pushed Authorization Requests}
|
|
13
|
+
*/
|
|
14
|
+
export type PushedAuthRequest = {
|
|
15
|
+
/** The JWT which contains the {@link Web5ConnectAuthRequest} */
|
|
16
|
+
request: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Sent back by OIDC server in response to {@link PushedAuthRequest}
|
|
20
|
+
* The server generates a TTL and a unique request_uri. The request_uri can be shared
|
|
21
|
+
* with the Provider using a link or a QR code along with additional params
|
|
22
|
+
* to access the url and decrypt the payload.
|
|
23
|
+
*/
|
|
24
|
+
export type PushedAuthResponse = {
|
|
25
|
+
request_uri: string;
|
|
26
|
+
expires_in: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Used in decentralized apps. The SIOPv2 Auth Request is created by a client relying party (RP)
|
|
30
|
+
* often a web service or an app who wants to obtain information from a provider
|
|
31
|
+
* The contents of this are inserted into a JWT inside of the {@link PushedAuthRequest}.
|
|
32
|
+
* @see {@link https://github.com/TBD54566975/known-customer-credential | TBD OIDC Documentation for SIOPv2 }
|
|
33
|
+
*/
|
|
34
|
+
export type SIOPv2AuthRequest = {
|
|
35
|
+
/** The DID of the client (RP) */
|
|
36
|
+
client_id: string;
|
|
37
|
+
/** The scope of the access request (e.g., `openid profile`). */
|
|
38
|
+
scope: string;
|
|
39
|
+
/** The type of response desired (e.g. `id_token`) */
|
|
40
|
+
response_type: string;
|
|
41
|
+
/** the URL to which the Identity Provider will post the Authorization Response */
|
|
42
|
+
redirect_uri: string;
|
|
43
|
+
/** The URI to which the SIOPv2 Authorization Response will be sent (Tim's note: not used with encrypted request JWT)*/
|
|
44
|
+
response_uri?: string;
|
|
45
|
+
/**
|
|
46
|
+
* An opaque value used to maintain state between the request and the callback.
|
|
47
|
+
* Recommended for security to prevent CSRF attacks.
|
|
48
|
+
*/
|
|
49
|
+
state: string;
|
|
50
|
+
/**
|
|
51
|
+
* A string value used to associate a client session with an ID token to mitigate replay attacks.
|
|
52
|
+
* Recommended when requesting ID tokens.
|
|
53
|
+
*/
|
|
54
|
+
nonce: string;
|
|
55
|
+
/**
|
|
56
|
+
* The PKCE code challenge.
|
|
57
|
+
* Required if `code_challenge_method` is used. Enhances security for public clients (e.g., single-page apps,
|
|
58
|
+
* mobile apps) by requiring an additional verification step during token exchange.
|
|
59
|
+
*/
|
|
60
|
+
code_challenge?: string;
|
|
61
|
+
/** The method used for the PKCE challenge (typically `S256`). Must be present if `code_challenge` is included. */
|
|
62
|
+
code_challenge_method?: 'S256';
|
|
63
|
+
/**
|
|
64
|
+
* An ID token previously issued to the client, passed as a hint about the end-user’s current or past authenticated
|
|
65
|
+
* session with the client. Can streamline user experience if already logged in.
|
|
66
|
+
*/
|
|
67
|
+
id_token_hint?: string;
|
|
68
|
+
/** A hint to the authorization server about the login identifier the user might use. Useful for pre-filling login information. */
|
|
69
|
+
login_hint?: string;
|
|
70
|
+
/** Requested Authentication Context Class Reference values. Specifies the authentication context requirements. */
|
|
71
|
+
acr_values?: string;
|
|
72
|
+
/** When using a PAR for secure cross device flows we use a "form_post" rather than a "direct_post" */
|
|
73
|
+
response_mode: 'direct_post';
|
|
74
|
+
/** Used by PFI to request VCs as input to IDV process. If present, `response_type: "vp_token""` MUST also be present */
|
|
75
|
+
presentation_definition?: any;
|
|
76
|
+
/** A JSON object containing the Verifier metadata values (Tim's note: from TBD KCC Repo) */
|
|
77
|
+
client_metadata?: {
|
|
78
|
+
/** Array of strings, each a DID method supported for the subject of ID Token */
|
|
79
|
+
subject_syntax_types_supported: string[];
|
|
80
|
+
/** Human-readable string name of the client to be presented to the end-user during authorization */
|
|
81
|
+
client_name?: string;
|
|
82
|
+
/** URI of a web page providing information about the client */
|
|
83
|
+
client_uri?: string;
|
|
84
|
+
/** URI of an image logo for the client */
|
|
85
|
+
logo_uri?: string;
|
|
86
|
+
/** Array of strings representing ways to contact people responsible for this client, typically email addresses */
|
|
87
|
+
contacts?: string[];
|
|
88
|
+
/** URI that points to a terms of service document for the client */
|
|
89
|
+
tos_uri?: string;
|
|
90
|
+
/** URI that points to a privacy policy document */
|
|
91
|
+
policy_uri?: string;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* An auth request that is compatible with both Web5 Connect and (hopefully, WIP) OIDC SIOPv2
|
|
96
|
+
* The contents of this are inserted into a JWT inside of the {@link PushedAuthRequest}.
|
|
97
|
+
*/
|
|
98
|
+
export type Web5ConnectAuthRequest = {
|
|
99
|
+
/** The user friendly name of the client/app to be displayed when prompting end-user with permission requests. */
|
|
100
|
+
displayName: string;
|
|
101
|
+
/** PermissionGrants that are to be sent to the provider */
|
|
102
|
+
permissionRequests: ConnectPermissionRequest[];
|
|
103
|
+
} & SIOPv2AuthRequest;
|
|
104
|
+
/** The fields for an OIDC SIOPv2 Auth Repsonse */
|
|
105
|
+
export type SIOPv2AuthResponse = {
|
|
106
|
+
/** Issuer MUST match the value of sub (Applicant's DID) */
|
|
107
|
+
iss: string;
|
|
108
|
+
/** Subject Identifier. A locally unique and never reassigned identifier
|
|
109
|
+
* within the Issuer for the End-User, which is intended to be consumed
|
|
110
|
+
* by the Client. */
|
|
111
|
+
sub: string;
|
|
112
|
+
/** Audience(s) that this ID Token is intended for. It MUST contain the
|
|
113
|
+
* OAuth 2.0 client_id of the Relying Party as an audience value. */
|
|
114
|
+
aud: string;
|
|
115
|
+
/** Time at which the JWT was issued. */
|
|
116
|
+
iat: number;
|
|
117
|
+
/** Expiration time on or after which the ID Token MUST NOT be accepted
|
|
118
|
+
* for processing. */
|
|
119
|
+
exp: number;
|
|
120
|
+
/** Time when the End-User authentication occurred. */
|
|
121
|
+
auth_time?: number;
|
|
122
|
+
/** b64url encoded nonce used to associate a Client session with an ID Token, and to
|
|
123
|
+
* mitigate replay attacks. */
|
|
124
|
+
nonce?: string;
|
|
125
|
+
/** Custom claims. */
|
|
126
|
+
[key: string]: any;
|
|
127
|
+
};
|
|
128
|
+
/** An auth response that is compatible with both Web5 Connect and (hopefully, WIP) OIDC SIOPv2 */
|
|
129
|
+
export type Web5ConnectAuthResponse = {
|
|
130
|
+
delegateGrants: DwnDataEncodedRecordsWriteMessage[];
|
|
131
|
+
delegatePortableDid: PortableDid;
|
|
132
|
+
} & SIOPv2AuthResponse;
|
|
133
|
+
/** Represents the different OIDC endpoint types.
|
|
134
|
+
* 1. `pushedAuthorizationRequest`: client sends {@link PushedAuthRequest} receives {@link PushedAuthResponse}
|
|
135
|
+
* 2. `authorize`: provider gets the {@link Web5ConnectAuthRequest} JWT that was stored by the PAR
|
|
136
|
+
* 3. `callback`: provider sends {@link Web5ConnectAuthResponse} to this endpoint
|
|
137
|
+
* 4. `token`: client gets {@link Web5ConnectAuthResponse} from this endpoint
|
|
138
|
+
*/
|
|
139
|
+
type OidcEndpoint = 'pushedAuthorizationRequest' | 'authorize' | 'callback' | 'token';
|
|
140
|
+
/**
|
|
141
|
+
* Gets the correct OIDC endpoint out of the {@link OidcEndpoint} options provided.
|
|
142
|
+
* Handles a trailing slash on baseURL
|
|
143
|
+
*
|
|
144
|
+
* @param {Object} options the options object
|
|
145
|
+
* @param {string} options.baseURL for example `http://foo.com/connect/
|
|
146
|
+
* @param {OidcEndpoint} options.endpoint the OIDC endpoint desired
|
|
147
|
+
* @param {string} options.authParam this is the unique id which must be provided when getting the `authorize` endpoint
|
|
148
|
+
* @param {string} options.tokenParam this is the random state as b64url which must be provided with the `token` endpoint
|
|
149
|
+
*/
|
|
150
|
+
declare function buildOidcUrl({ baseURL, endpoint, authParam, tokenParam, }: {
|
|
151
|
+
baseURL: string;
|
|
152
|
+
endpoint: OidcEndpoint;
|
|
153
|
+
authParam?: string;
|
|
154
|
+
tokenParam?: string;
|
|
155
|
+
}): string;
|
|
156
|
+
/**
|
|
157
|
+
* Generates a cryptographically random "code challenge" in
|
|
158
|
+
* accordance with the RFC 7636 PKCE specification.
|
|
159
|
+
*
|
|
160
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc7636#section-4.2 | RFC 7636 }
|
|
161
|
+
*/
|
|
162
|
+
declare function generateCodeChallenge(): Promise<{
|
|
163
|
+
codeChallengeBytes: Uint8Array;
|
|
164
|
+
codeChallengeBase64Url: string;
|
|
165
|
+
}>;
|
|
166
|
+
/** Client creates the {@link Web5ConnectAuthRequest} */
|
|
167
|
+
declare function createAuthRequest(options: RequireOnly<Web5ConnectAuthRequest, 'client_id' | 'scope' | 'redirect_uri' | 'permissionRequests' | 'displayName'>): Promise<Web5ConnectAuthRequest>;
|
|
168
|
+
/** Encrypts the auth request with the key which will be passed through QR code */
|
|
169
|
+
declare function encryptAuthRequest({ jwt, encryptionKey, }: {
|
|
170
|
+
jwt: string;
|
|
171
|
+
encryptionKey: Uint8Array;
|
|
172
|
+
}): Promise<string>;
|
|
173
|
+
/** Create a response object compatible with Web5 Connect and OIDC SIOPv2 */
|
|
174
|
+
declare function createResponseObject(options: RequireOnly<Web5ConnectAuthResponse, 'iss' | 'sub' | 'aud' | 'delegateGrants' | 'delegatePortableDid'>): Promise<Web5ConnectAuthResponse>;
|
|
175
|
+
/** sign an object and transform it into a jwt using a did */
|
|
176
|
+
declare function signJwt({ did, data, }: {
|
|
177
|
+
did: BearerDid;
|
|
178
|
+
data: Record<string, unknown>;
|
|
179
|
+
}): Promise<string>;
|
|
180
|
+
/** Take the decrypted JWT and verify it was signed by its public DID. Return parsed object. */
|
|
181
|
+
declare function verifyJwt({ jwt }: {
|
|
182
|
+
jwt: string;
|
|
183
|
+
}): Promise<object>;
|
|
184
|
+
/** Take the encrypted JWE, decrypt using the code challenge and return a JWT string which will need to be verified */
|
|
185
|
+
declare function decryptAuthRequest({ jwe, encryption_key, }: {
|
|
186
|
+
jwe: string;
|
|
187
|
+
encryption_key: string;
|
|
188
|
+
}): string;
|
|
189
|
+
/**
|
|
190
|
+
* The client uses to decrypt the jwe obtained from the auth server which contains
|
|
191
|
+
* the {@link Web5ConnectAuthResponse} that was sent by the provider to the auth server.
|
|
192
|
+
*
|
|
193
|
+
* @async
|
|
194
|
+
* @param {BearerDid} clientDid - The did that was initially used by the client for ECDH at connect init.
|
|
195
|
+
* @param {string} jwe - The encrypted data as a jwe.
|
|
196
|
+
* @param {string} pin - The pin that was obtained from the user.
|
|
197
|
+
*/
|
|
198
|
+
declare function decryptAuthResponse(clientDid: BearerDid, jwe: string, pin: string): Promise<string>;
|
|
199
|
+
/** Derives a shared ECDH private key in order to encrypt the {@link Web5ConnectAuthResponse} */
|
|
200
|
+
declare function deriveSharedKey(privateKeyDid: BearerDid, publicKeyDid: DidDocument): Promise<Uint8Array>;
|
|
201
|
+
/**
|
|
202
|
+
* Encrypts the auth response jwt. Requires a randomPin is added to the AAD of the
|
|
203
|
+
* encryption algorithm in order to prevent man in the middle and eavesdropping attacks.
|
|
204
|
+
* The keyid of the delegate did is used to pass the public key to the client in order
|
|
205
|
+
* for the client to derive the shared ECDH private key.
|
|
206
|
+
*/
|
|
207
|
+
declare function encryptAuthResponse({ jwt, encryptionKey, delegateDidKeyId, randomPin, }: {
|
|
208
|
+
jwt: string;
|
|
209
|
+
encryptionKey: Uint8Array;
|
|
210
|
+
delegateDidKeyId: string;
|
|
211
|
+
randomPin: string;
|
|
212
|
+
}): string;
|
|
213
|
+
/**
|
|
214
|
+
* Creates the permission grants that assign to the selectedDid the level of
|
|
215
|
+
* permissions that the web app requested in the {@link Web5ConnectAuthRequest}
|
|
216
|
+
*/
|
|
217
|
+
declare function createPermissionGrants(selectedDid: string, delegateBearerDid: BearerDid, agent: Web5Agent, scopes: DwnPermissionScope[]): Promise<(import("@enbox/dwn-sdk-js").RecordsWriteMessage & {
|
|
218
|
+
encodedData: string;
|
|
219
|
+
})[]>;
|
|
220
|
+
/**
|
|
221
|
+
* Creates a delegate did which the web app will use as its future indentity.
|
|
222
|
+
* Assigns to that DID the level of permissions that the web app requested in
|
|
223
|
+
* the {@link Web5ConnectAuthRequest}. Encrypts via ECDH key that the web app
|
|
224
|
+
* will have access to because the web app has the public key which it provided
|
|
225
|
+
* in the {@link Web5ConnectAuthRequest}. Then sends the ciphertext of this
|
|
226
|
+
* {@link Web5ConnectAuthResponse} to the callback endpoint. Which the
|
|
227
|
+
* web app will need to retrieve from the token endpoint and decrypt with the pin to access.
|
|
228
|
+
*/
|
|
229
|
+
declare function submitAuthResponse(selectedDid: string, authRequest: Web5ConnectAuthRequest, randomPin: string, agent: Web5Agent): Promise<void>;
|
|
230
|
+
export declare const Oidc: {
|
|
231
|
+
createAuthRequest: typeof createAuthRequest;
|
|
232
|
+
encryptAuthRequest: typeof encryptAuthRequest;
|
|
233
|
+
getAuthRequest: (request_uri: string, encryption_key: string) => Promise<Web5ConnectAuthRequest>;
|
|
234
|
+
decryptAuthRequest: typeof decryptAuthRequest;
|
|
235
|
+
createPermissionGrants: typeof createPermissionGrants;
|
|
236
|
+
createResponseObject: typeof createResponseObject;
|
|
237
|
+
encryptAuthResponse: typeof encryptAuthResponse;
|
|
238
|
+
decryptAuthResponse: typeof decryptAuthResponse;
|
|
239
|
+
deriveSharedKey: typeof deriveSharedKey;
|
|
240
|
+
signJwt: typeof signJwt;
|
|
241
|
+
verifyJwt: typeof verifyJwt;
|
|
242
|
+
buildOidcUrl: typeof buildOidcUrl;
|
|
243
|
+
generateCodeChallenge: typeof generateCodeChallenge;
|
|
244
|
+
submitAuthResponse: typeof submitAuthResponse;
|
|
245
|
+
};
|
|
246
|
+
export {};
|
|
247
|
+
//# sourceMappingURL=oidc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oidc.d.ts","sourceRoot":"","sources":["../../src/oidc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,WAAW,EAAE,MAAM,eAAe,CAAC;AAY7D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAU,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,EAAE,iCAAiC,EAAgB,kBAAkB,EAAyB,MAAM,gBAAgB,CAAC;AAE5H,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAIlD;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,iCAAiC;IACjC,SAAS,EAAE,MAAM,CAAC;IAElB,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;IAEd,qDAAqD;IACrD,aAAa,EAAE,MAAM,CAAC;IAEtB,kFAAkF;IAClF,YAAY,EAAE,MAAM,CAAC;IAErB,uHAAuH;IACvH,YAAY,CAA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eAAO,MAAM,IAAI;;;kCApb0B,MAAM,kBAAkB,MAAM;;;;;;;;;;;;CAmcxE,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Web5Agent } from './types/agent.js';
|
|
2
|
+
import { DwnInterface } from './types/dwn.js';
|
|
3
|
+
import { CreateGrantParams, CreateRequestParams, CreateRevocationParams, FetchPermissionRequestParams, FetchPermissionsParams, GetPermissionParams, IsGrantRevokedParams, PermissionGrantEntry, PermissionRequestEntry, PermissionRevocationEntry, PermissionsApi } from './types/permissions.js';
|
|
4
|
+
export declare class AgentPermissionsApi implements PermissionsApi {
|
|
5
|
+
/** cache for fetching a permission {@link PermissionGrant}, keyed by a specific MessageType and protocol */
|
|
6
|
+
private _cachedPermissions;
|
|
7
|
+
private _agent?;
|
|
8
|
+
get agent(): Web5Agent;
|
|
9
|
+
set agent(agent: Web5Agent);
|
|
10
|
+
constructor({ agent }?: {
|
|
11
|
+
agent?: Web5Agent;
|
|
12
|
+
});
|
|
13
|
+
getPermissionForRequest({ connectedDid, delegateDid, delegate, messageType, protocol, cached }: GetPermissionParams): Promise<PermissionGrantEntry>;
|
|
14
|
+
fetchGrants({ author, target, grantee, grantor, protocol, remote }: FetchPermissionsParams): Promise<PermissionGrantEntry[]>;
|
|
15
|
+
fetchRequests({ author, target, protocol, remote }: FetchPermissionRequestParams): Promise<PermissionRequestEntry[]>;
|
|
16
|
+
isGrantRevoked({ author, target, grantRecordId, remote }: IsGrantRevokedParams): Promise<boolean>;
|
|
17
|
+
createGrant(params: CreateGrantParams): Promise<PermissionGrantEntry>;
|
|
18
|
+
createRequest(params: CreateRequestParams): Promise<PermissionRequestEntry>;
|
|
19
|
+
createRevocation(params: CreateRevocationParams): Promise<PermissionRevocationEntry>;
|
|
20
|
+
clear(): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Matches the appropriate grant from an array of grants based on the provided parameters.
|
|
23
|
+
*
|
|
24
|
+
* @param delegated if true, only delegated grants are turned, if false all grants are returned including delegated ones.
|
|
25
|
+
*/
|
|
26
|
+
static matchGrantFromArray<T extends DwnInterface>(grantor: string, grantee: string, messageParams: {
|
|
27
|
+
messageType: T;
|
|
28
|
+
protocol?: string;
|
|
29
|
+
protocolPath?: string;
|
|
30
|
+
contextId?: string;
|
|
31
|
+
}, grants: PermissionGrantEntry[], delegated?: boolean): Promise<PermissionGrantEntry | undefined>;
|
|
32
|
+
private static matchScopeFromGrant;
|
|
33
|
+
private static isUnrestrictedProtocolScope;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=permissions-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions-api.d.ts","sourceRoot":"","sources":["../../src/permissions-api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAqC,YAAY,EAAwL,MAAM,gBAAgB,CAAC;AAEvQ,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGlS,qBAAa,mBAAoB,YAAW,cAAc;IAExD,4GAA4G;IAC5G,OAAO,CAAC,kBAAkB,CAA4E;IAEtG,OAAO,CAAC,MAAM,CAAC,CAAY;IAE3B,IAAI,KAAK,IAAI,SAAS,CAKrB;IAED,IAAI,KAAK,CAAC,KAAK,EAAC,SAAS,EAExB;gBAEW,EAAE,KAAK,EAAE,GAAE;QAAE,KAAK,CAAC,EAAE,SAAS,CAAA;KAAO;IAI3C,uBAAuB,CAAC,EAC5B,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,MAAc,EACf,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAiChD,WAAW,CAAC,EAChB,MAAM,EACN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