@enbox/agent 0.2.1 → 0.3.0
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.mjs +9 -9
- package/dist/browser.mjs.map +4 -4
- package/dist/esm/agent-did-resolver-cache.js.map +1 -1
- package/dist/esm/anonymous-dwn-api.js +1 -1
- package/dist/esm/bearer-identity.js +1 -1
- package/dist/esm/connect.js +3 -3
- package/dist/esm/connect.js.map +1 -1
- package/dist/esm/did-api.js +3 -3
- package/dist/esm/did-api.js.map +1 -1
- package/dist/esm/dwn-api.js +150 -10
- package/dist/esm/dwn-api.js.map +1 -1
- package/dist/esm/dwn-discovery-file.js +244 -0
- package/dist/esm/dwn-discovery-file.js.map +1 -0
- package/dist/esm/dwn-discovery-payload.js +253 -0
- package/dist/esm/dwn-discovery-payload.js.map +1 -0
- package/dist/esm/dwn-encryption.js.map +1 -1
- package/dist/esm/dwn-key-delivery.js +6 -5
- package/dist/esm/dwn-key-delivery.js.map +1 -1
- package/dist/esm/dwn-protocol-cache.js +6 -7
- package/dist/esm/dwn-protocol-cache.js.map +1 -1
- package/dist/esm/dwn-record-upgrade.js.map +1 -1
- package/dist/esm/{web5-user-agent.js → enbox-user-agent.js} +18 -9
- package/dist/esm/enbox-user-agent.js.map +1 -0
- package/dist/esm/identity-api.js +4 -5
- package/dist/esm/identity-api.js.map +1 -1
- package/dist/esm/index.js +4 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/local-dwn.js +197 -0
- package/dist/esm/local-dwn.js.map +1 -0
- package/dist/esm/local-key-manager.js +2 -2
- package/dist/esm/local-key-manager.js.map +1 -1
- package/dist/esm/oidc.js +11 -11
- package/dist/esm/oidc.js.map +1 -1
- package/dist/esm/permissions-api.js.map +1 -1
- package/dist/esm/store-data.js.map +1 -1
- package/dist/esm/sync-api.js +2 -2
- package/dist/esm/sync-api.js.map +1 -1
- package/dist/esm/sync-engine-level.js +3 -4
- package/dist/esm/sync-engine-level.js.map +1 -1
- package/dist/esm/test-harness.js +5 -4
- package/dist/esm/test-harness.js.map +1 -1
- package/dist/esm/utils-internal.js +2 -2
- package/dist/types/agent-did-resolver-cache.d.ts +7 -7
- package/dist/types/agent-did-resolver-cache.d.ts.map +1 -1
- package/dist/types/anonymous-dwn-api.d.ts +3 -3
- package/dist/types/anonymous-dwn-api.d.ts.map +1 -1
- package/dist/types/bearer-identity.d.ts +1 -1
- package/dist/types/connect.d.ts +8 -8
- package/dist/types/connect.d.ts.map +1 -1
- package/dist/types/did-api.d.ts +12 -11
- package/dist/types/did-api.d.ts.map +1 -1
- package/dist/types/dwn-api.d.ts +58 -11
- package/dist/types/dwn-api.d.ts.map +1 -1
- package/dist/types/dwn-discovery-file.d.ts +122 -0
- package/dist/types/dwn-discovery-file.d.ts.map +1 -0
- package/dist/types/dwn-discovery-payload.d.ts +105 -0
- package/dist/types/dwn-discovery-payload.d.ts.map +1 -0
- package/dist/types/dwn-encryption.d.ts +8 -8
- package/dist/types/dwn-encryption.d.ts.map +1 -1
- package/dist/types/dwn-key-delivery.d.ts +9 -7
- package/dist/types/dwn-key-delivery.d.ts.map +1 -1
- package/dist/types/dwn-protocol-cache.d.ts +6 -5
- package/dist/types/dwn-protocol-cache.d.ts.map +1 -1
- package/dist/types/dwn-record-upgrade.d.ts +2 -2
- package/dist/types/dwn-record-upgrade.d.ts.map +1 -1
- package/dist/types/{web5-user-agent.d.ts → enbox-user-agent.d.ts} +21 -13
- package/dist/types/enbox-user-agent.d.ts.map +1 -0
- package/dist/types/identity-api.d.ts +10 -10
- package/dist/types/identity-api.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/local-dwn.d.ts +121 -0
- package/dist/types/local-dwn.d.ts.map +1 -0
- package/dist/types/local-key-manager.d.ts +9 -9
- package/dist/types/local-key-manager.d.ts.map +1 -1
- package/dist/types/oidc.d.ts +23 -19
- package/dist/types/oidc.d.ts.map +1 -1
- package/dist/types/permissions-api.d.ts +4 -4
- package/dist/types/permissions-api.d.ts.map +1 -1
- package/dist/types/store-data.d.ts +3 -3
- package/dist/types/store-data.d.ts.map +1 -1
- package/dist/types/store-did.d.ts +2 -2
- package/dist/types/store-did.d.ts.map +1 -1
- package/dist/types/store-identity.d.ts +2 -2
- package/dist/types/store-identity.d.ts.map +1 -1
- package/dist/types/store-key.d.ts +2 -2
- package/dist/types/store-key.d.ts.map +1 -1
- package/dist/types/sync-api.d.ts +9 -9
- package/dist/types/sync-api.d.ts.map +1 -1
- package/dist/types/sync-engine-level.d.ts +9 -9
- package/dist/types/sync-engine-level.d.ts.map +1 -1
- package/dist/types/sync-messages.d.ts +5 -5
- package/dist/types/sync-messages.d.ts.map +1 -1
- package/dist/types/test-harness.d.ts +4 -4
- package/dist/types/test-harness.d.ts.map +1 -1
- package/dist/types/types/agent.d.ts +24 -19
- package/dist/types/types/agent.d.ts.map +1 -1
- package/dist/types/types/identity.d.ts +1 -1
- package/dist/types/types/key-manager.d.ts +2 -2
- package/dist/types/types/key-manager.d.ts.map +1 -1
- package/dist/types/types/sync.d.ts +2 -2
- package/dist/types/types/sync.d.ts.map +1 -1
- package/dist/types/utils-internal.d.ts +4 -4
- package/dist/types/utils-internal.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/agent-did-resolver-cache.ts +8 -8
- package/src/anonymous-dwn-api.ts +4 -4
- package/src/bearer-identity.ts +1 -1
- package/src/connect.ts +12 -12
- package/src/did-api.ts +13 -11
- package/src/dwn-api.ts +196 -16
- package/src/dwn-discovery-file.ts +305 -0
- package/src/dwn-discovery-payload.ts +308 -0
- package/src/dwn-encryption.ts +8 -8
- package/src/dwn-key-delivery.ts +11 -8
- package/src/dwn-protocol-cache.ts +9 -8
- package/src/dwn-record-upgrade.ts +2 -2
- package/src/{web5-user-agent.ts → enbox-user-agent.ts} +39 -19
- package/src/identity-api.ts +12 -13
- package/src/index.ts +4 -1
- package/src/local-dwn.ts +207 -0
- package/src/local-key-manager.ts +10 -10
- package/src/oidc.ts +40 -30
- package/src/permissions-api.ts +5 -5
- package/src/store-data.ts +7 -7
- package/src/store-did.ts +2 -2
- package/src/store-identity.ts +2 -2
- package/src/store-key.ts +2 -2
- package/src/sync-api.ts +10 -10
- package/src/sync-engine-level.ts +13 -14
- package/src/sync-messages.ts +5 -5
- package/src/test-harness.ts +11 -10
- package/src/types/agent.ts +31 -20
- package/src/types/identity.ts +1 -1
- package/src/types/key-manager.ts +2 -2
- package/src/types/sync.ts +2 -2
- package/src/utils-internal.ts +4 -4
- package/dist/esm/web5-user-agent.js.map +0 -1
- package/dist/types/web5-user-agent.d.ts.map +0 -1
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
|
-
import type { DidUrlDereferencer } from '@enbox/dids';
|
|
10
9
|
import type { PublicKeyJwk } from '@enbox/crypto';
|
|
11
10
|
import type { TtlCache } from '@enbox/common';
|
|
12
11
|
import type { ProtocolDefinition } from '@enbox/dwn-sdk-js';
|
|
13
12
|
import type { DwnInterface, DwnMessage, DwnMessageReply, DwnSigner, MessageHandler } from './types/dwn.js';
|
|
13
|
+
/** Callback to resolve DWN endpoint URLs for a target DID (with local discovery). */
|
|
14
|
+
type GetDwnEndpointUrlsFn = (targetDid: string) => Promise<string[]>;
|
|
14
15
|
/** Callback to obtain a DWN signer for a given DID. */
|
|
15
16
|
type GetSignerFn = (author: string) => Promise<DwnSigner>;
|
|
16
17
|
/** Callback to send a raw DWN request to a remote endpoint. */
|
|
@@ -44,13 +45,13 @@ export declare function getProtocolDefinition(tenantDid: string, protocolUri: st
|
|
|
44
45
|
*
|
|
45
46
|
* @param targetDid - The remote DWN owner
|
|
46
47
|
* @param protocolUri - The protocol URI to look up
|
|
47
|
-
* @param
|
|
48
|
+
* @param getDwnEndpointUrls - Callback to resolve DWN endpoint URLs (with local discovery)
|
|
48
49
|
* @param sendDwnRpcRequest - Callback to send the RPC query
|
|
49
50
|
* @param cache - The shared protocol definition cache
|
|
50
51
|
* @returns The protocol definition
|
|
51
52
|
* @throws If the protocol cannot be fetched
|
|
52
53
|
*/
|
|
53
|
-
export declare function fetchRemoteProtocolDefinition(targetDid: string, protocolUri: string,
|
|
54
|
+
export declare function fetchRemoteProtocolDefinition(targetDid: string, protocolUri: string, getDwnEndpointUrls: GetDwnEndpointUrlsFn, sendDwnRpcRequest: SendDwnRpcRequestFn, cache: TtlCache<string, ProtocolDefinition>): Promise<ProtocolDefinition>;
|
|
54
55
|
/**
|
|
55
56
|
* Extracts the `derivedPublicKey` from an existing `ProtocolContext`-encrypted
|
|
56
57
|
* record in a context on a remote DWN.
|
|
@@ -62,13 +63,13 @@ export declare function fetchRemoteProtocolDefinition(targetDid: string, protoco
|
|
|
62
63
|
* @param protocolUri - The protocol URI to search
|
|
63
64
|
* @param rootContextId - The root context ID
|
|
64
65
|
* @param requesterDid - The DID of the requester (used for signing the query)
|
|
65
|
-
* @param
|
|
66
|
+
* @param getDwnEndpointUrls - Callback to resolve DWN endpoint URLs (with local discovery)
|
|
66
67
|
* @param getSigner - Callback to obtain the signer for `requesterDid`
|
|
67
68
|
* @param sendDwnRpcRequest - Callback to send the RPC query
|
|
68
69
|
* @returns The rootKeyId and derivedPublicKey, or `undefined` if no
|
|
69
70
|
* `ProtocolContext` record exists yet
|
|
70
71
|
*/
|
|
71
|
-
export declare function extractDerivedPublicKey(targetDid: string, protocolUri: string, rootContextId: string, requesterDid: string,
|
|
72
|
+
export declare function extractDerivedPublicKey(targetDid: string, protocolUri: string, rootContextId: string, requesterDid: string, getDwnEndpointUrls: GetDwnEndpointUrlsFn, getSigner: GetSignerFn, sendDwnRpcRequest: SendDwnRpcRequestFn): Promise<{
|
|
72
73
|
rootKeyId: string;
|
|
73
74
|
derivedPublicKey: PublicKeyJwk;
|
|
74
75
|
} | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dwn-protocol-cache.d.ts","sourceRoot":"","sources":["../../src/dwn-protocol-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"dwn-protocol-cache.d.ts","sourceRoot":"","sources":["../../src/dwn-protocol-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EACV,kBAAkB,EAGnB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,eAAe,EACf,SAAS,EACT,cAAc,EACf,MAAM,gBAAgB,CAAC;AAUxB,qFAAqF;AACrF,KAAK,oBAAoB,GAAG,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AAErE,uDAAuD;AACvD,KAAK,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;AAE1D,+DAA+D;AAC/D,KAAK,mBAAmB,GAAG,CAAC,CAAC,SAAS,YAAY,EAAE,MAAM,EAAE;IAC1D,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACvB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,mBAAmB,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;CACzC,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AAElC,qEAAqE;AACrE,UAAU,OAAO;IACf,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CACnF;AAMD;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CACzC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,WAAW,EACtB,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAC1C,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CA0BzC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,6BAA6B,CACjD,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,kBAAkB,EAAE,oBAAoB,EACxC,iBAAiB,EAAE,mBAAmB,EACtC,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAC1C,OAAO,CAAC,kBAAkB,CAAC,CA2B7B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,uBAAuB,CAC3C,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,kBAAkB,EAAE,oBAAoB,EACxC,SAAS,EAAE,WAAW,EACtB,iBAAiB,EAAE,mBAAmB,GACrC,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,YAAY,CAAA;CAAE,GAAG,SAAS,CAAC,CAyC5E"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { KeyIdentifier } from '@enbox/crypto';
|
|
2
2
|
import type { Dwn, RecordsWriteMessage } from '@enbox/dwn-sdk-js';
|
|
3
3
|
import type { DwnSigner } from './types/dwn.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { EnboxPlatformAgent } from './types/agent.js';
|
|
5
5
|
/**
|
|
6
6
|
* Reactively upgrades an externally-authored root record that has only
|
|
7
7
|
* ProtocolPath encryption by appending a ProtocolContext recipient entry.
|
|
@@ -23,7 +23,7 @@ import type { Web5PlatformAgent } from './types/agent.js';
|
|
|
23
23
|
* @param getSigner - Function to get a DWN signer
|
|
24
24
|
* @param contextKeyCache - Cache for context key info
|
|
25
25
|
*/
|
|
26
|
-
export declare function upgradeExternalRootRecord(agent:
|
|
26
|
+
export declare function upgradeExternalRootRecord(agent: EnboxPlatformAgent, tenantDid: string, recordsWrite: RecordsWriteMessage, dwn: Dwn, getSigner: (author: string) => Promise<DwnSigner>, contextKeyCache: {
|
|
27
27
|
set(key: string, value: {
|
|
28
28
|
keyId: string;
|
|
29
29
|
keyUri: KeyIdentifier;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dwn-record-upgrade.d.ts","sourceRoot":"","sources":["../../src/dwn-record-upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EACV,GAAG,EAIH,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"dwn-record-upgrade.d.ts","sourceRoot":"","sources":["../../src/dwn-record-upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EACV,GAAG,EAIH,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAY3D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,kBAAkB,EACzB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,mBAAmB,EACjC,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,CAAC,EACjD,eAAe,EAAE;IAAE,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,aAAa,CAAC;QAAC,qBAAqB,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,IAAI,CAAA;CAAE,GAC5H,OAAO,CAAC,IAAI,CAAC,CAmHf"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { AgentKeyManager } from './types/key-manager.js';
|
|
2
2
|
import type { BearerDid } from '@enbox/dids';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
3
|
+
import type { EnboxPlatformAgent } from './types/agent.js';
|
|
4
|
+
import type { EnboxRpc } from '@enbox/dwn-clients';
|
|
5
|
+
import type { LocalDwnStrategy } from './local-dwn.js';
|
|
5
6
|
import type { DidInterface, DidRequest, DidResponse } from './did-api.js';
|
|
6
7
|
import type { DwnInterface, DwnResponse, ProcessDwnRequest, SendDwnRequest } from './types/dwn.js';
|
|
7
8
|
import type { ProcessVcRequest, SendVcRequest, VcResponse } from './types/vc.js';
|
|
@@ -14,7 +15,7 @@ import { AgentSyncApi } from './sync-api.js';
|
|
|
14
15
|
import { HdIdentityVault } from './hd-identity-vault.js';
|
|
15
16
|
import { LocalKeyManager } from './local-key-manager.js';
|
|
16
17
|
/**
|
|
17
|
-
* Initialization parameters for {@link
|
|
18
|
+
* Initialization parameters for {@link EnboxUserAgent}, including an optional recovery phrase that
|
|
18
19
|
* can be used to derive keys to encrypt the vault and generate a DID.
|
|
19
20
|
*/
|
|
20
21
|
export type AgentInitializeParams = {
|
|
@@ -33,10 +34,10 @@ export type AgentInitializeParams = {
|
|
|
33
34
|
*/
|
|
34
35
|
recoveryPhrase?: string;
|
|
35
36
|
/**
|
|
36
|
-
* Optional dwnEndpoints to register didService endpoints during
|
|
37
|
+
* Optional dwnEndpoints to register didService endpoints during EnboxUserAgent initialization
|
|
37
38
|
*
|
|
38
39
|
* The dwnEndpoints are used to register DWN endpoints against the agent DID created during
|
|
39
|
-
*
|
|
40
|
+
* EnboxUserAgent.initialize() => DidDht.create(). This allows the
|
|
40
41
|
* agent to properly recover connectedDids from DWN. Also, this pattern can be used on the server
|
|
41
42
|
* side in place of the agentDid-->connectedDids pattern.
|
|
42
43
|
*/
|
|
@@ -49,7 +50,7 @@ export type AgentStartParams = {
|
|
|
49
50
|
password: string;
|
|
50
51
|
};
|
|
51
52
|
export type AgentParams<TKeyManager extends AgentKeyManager = LocalKeyManager> = {
|
|
52
|
-
/** Optional. The Decentralized Identifier (DID) representing this
|
|
53
|
+
/** Optional. The Decentralized Identifier (DID) representing this Enbox User Agent. */
|
|
53
54
|
agentDid?: BearerDid;
|
|
54
55
|
/** Encrypted vault used for managing the Agent's DID and associated keys. */
|
|
55
56
|
agentVault: HdIdentityVault;
|
|
@@ -67,19 +68,22 @@ export type AgentParams<TKeyManager extends AgentKeyManager = LocalKeyManager> =
|
|
|
67
68
|
keyManager: TKeyManager;
|
|
68
69
|
/** Facilitates fetching, requesting, creating, revoking and validating revocation status of permissions */
|
|
69
70
|
permissionsApi: AgentPermissionsApi;
|
|
70
|
-
/** Remote procedure call (RPC) client used to communicate with other
|
|
71
|
-
rpcClient:
|
|
71
|
+
/** Remote procedure call (RPC) client used to communicate with other Enbox services. */
|
|
72
|
+
rpcClient: EnboxRpc;
|
|
72
73
|
/** Facilitates data synchronization of DWN records between nodes. */
|
|
73
74
|
syncApi: AgentSyncApi;
|
|
74
75
|
};
|
|
75
|
-
export
|
|
76
|
+
export type CreateUserAgentParams = Partial<AgentParams> & {
|
|
77
|
+
localDwnStrategy?: LocalDwnStrategy;
|
|
78
|
+
};
|
|
79
|
+
export declare class EnboxUserAgent<TKeyManager extends AgentKeyManager = LocalKeyManager> implements EnboxPlatformAgent<TKeyManager> {
|
|
76
80
|
crypto: AgentCryptoApi;
|
|
77
81
|
did: AgentDidApi<TKeyManager>;
|
|
78
82
|
dwn: AgentDwnApi;
|
|
79
83
|
identity: AgentIdentityApi<TKeyManager>;
|
|
80
84
|
keyManager: TKeyManager;
|
|
81
85
|
permissions: AgentPermissionsApi;
|
|
82
|
-
rpc:
|
|
86
|
+
rpc: EnboxRpc;
|
|
83
87
|
sync: AgentSyncApi;
|
|
84
88
|
vault: HdIdentityVault;
|
|
85
89
|
private _agentDid?;
|
|
@@ -89,14 +93,14 @@ export declare class Web5UserAgent<TKeyManager extends AgentKeyManager = LocalKe
|
|
|
89
93
|
/**
|
|
90
94
|
* If any of the required agent components are not provided, instantiate default implementations.
|
|
91
95
|
*/
|
|
92
|
-
static create({ dataPath, agentDid, agentVault, cryptoApi, didApi, dwnApi, identityApi, keyManager, permissionsApi, rpcClient, syncApi }?:
|
|
96
|
+
static create({ dataPath, localDwnStrategy, agentDid, agentVault, cryptoApi, didApi, dwnApi, identityApi, keyManager, permissionsApi, rpcClient, syncApi }?: CreateUserAgentParams): Promise<EnboxUserAgent>;
|
|
93
97
|
firstLaunch(): Promise<boolean>;
|
|
94
98
|
/**
|
|
95
99
|
* Initializes the User Agent with a password, and optionally a recovery phrase.
|
|
96
100
|
*
|
|
97
101
|
* This method is typically called once, the first time the Agent is launched, and is responsible
|
|
98
102
|
* for setting up the agent's operational environment, cryptographic key material, and readiness
|
|
99
|
-
* for processing
|
|
103
|
+
* for processing requests.
|
|
100
104
|
*
|
|
101
105
|
* The password is used to secure the Agent vault, and the recovery phrase is used to derive the
|
|
102
106
|
* cryptographic keys for the vault. If a recovery phrase is not provided, a new recovery phrase
|
|
@@ -111,4 +115,8 @@ export declare class Web5UserAgent<TKeyManager extends AgentKeyManager = LocalKe
|
|
|
111
115
|
sendVcRequest(_request: SendVcRequest): Promise<VcResponse>;
|
|
112
116
|
start({ password }: AgentInitializeParams): Promise<void>;
|
|
113
117
|
}
|
|
114
|
-
|
|
118
|
+
/** @deprecated Use {@link EnboxUserAgent} instead. Will be removed in a future version. */
|
|
119
|
+
export declare const Web5UserAgent: typeof EnboxUserAgent;
|
|
120
|
+
/** @deprecated Use {@link EnboxUserAgent} instead. Will be removed in a future version. */
|
|
121
|
+
export type Web5UserA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CAAC,CAAC,CAAC,GACzB,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAIb,aAAa,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC;IAI3D,KAAK,CAAC,EAAE,QAAQ,EAAE,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;CASvE;AAMD,2FAA2F;AAC3F,eAAO,MAAM,aAAa,uBAAiB,CAAC;AAE5C,2FAA2F;AAC3F,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC"}
|
|
@@ -2,11 +2,11 @@ import type { RequireOnly } from '@enbox/common';
|
|
|
2
2
|
import type { AgentDataStore } from './store-data.js';
|
|
3
3
|
import type { AgentKeyManager } from './types/key-manager.js';
|
|
4
4
|
import type { DidMethodCreateOptions } from './did-api.js';
|
|
5
|
-
import type {
|
|
5
|
+
import type { EnboxPlatformAgent } from './types/agent.js';
|
|
6
6
|
import type { IdentityMetadata, PortableIdentity } from './types/identity.js';
|
|
7
7
|
import { BearerIdentity } from './bearer-identity.js';
|
|
8
8
|
export interface IdentityApiParams<TKeyManager extends AgentKeyManager> {
|
|
9
|
-
agent?:
|
|
9
|
+
agent?: EnboxPlatformAgent<TKeyManager>;
|
|
10
10
|
store?: AgentDataStore<IdentityMetadata>;
|
|
11
11
|
}
|
|
12
12
|
export interface IdentityCreateParams<TKeyManager = AgentKeyManager, TMethod extends keyof DidMethodCreateOptions<TKeyManager> = keyof DidMethodCreateOptions<TKeyManager>> {
|
|
@@ -17,7 +17,7 @@ export interface IdentityCreateParams<TKeyManager = AgentKeyManager, TMethod ext
|
|
|
17
17
|
}
|
|
18
18
|
export declare function isPortableIdentity(obj: unknown): obj is PortableIdentity;
|
|
19
19
|
/**
|
|
20
|
-
* This API is used to manage and interact with Identities within the
|
|
20
|
+
* This API is used to manage and interact with Identities within the Enbox Agent framework.
|
|
21
21
|
* An Identity is a DID that is associated with metadata that describes the Identity.
|
|
22
22
|
* Metadata includes A name(label), and whether or not the Identity is connected (delegated to act on the behalf of another DID).
|
|
23
23
|
*
|
|
@@ -28,22 +28,22 @@ export declare function isPortableIdentity(obj: unknown): obj is PortableIdentit
|
|
|
28
28
|
*/
|
|
29
29
|
export declare class AgentIdentityApi<TKeyManager extends AgentKeyManager = AgentKeyManager> {
|
|
30
30
|
/**
|
|
31
|
-
* Holds the instance of a `
|
|
32
|
-
* the `AgentIdentityApi`. This agent is used to interact with other
|
|
31
|
+
* Holds the instance of a `EnboxPlatformAgent` that represents the current execution context for
|
|
32
|
+
* the `AgentIdentityApi`. This agent is used to interact with other Enbox agent components. It's
|
|
33
33
|
* vital to ensure this instance is set to correctly contextualize operations within the broader
|
|
34
|
-
*
|
|
34
|
+
* Enbox Agent framework.
|
|
35
35
|
*/
|
|
36
36
|
private _agent?;
|
|
37
37
|
private _store;
|
|
38
38
|
constructor({ agent, store }?: IdentityApiParams<TKeyManager>);
|
|
39
39
|
/**
|
|
40
|
-
* Retrieves the `
|
|
40
|
+
* Retrieves the `EnboxPlatformAgent` execution context.
|
|
41
41
|
*
|
|
42
|
-
* @returns The `
|
|
42
|
+
* @returns The `EnboxPlatformAgent` instance that represents the current execution context.
|
|
43
43
|
* @throws Will throw an error if the `agent` instance property is undefined.
|
|
44
44
|
*/
|
|
45
|
-
get agent():
|
|
46
|
-
set agent(agent:
|
|
45
|
+
get agent(): EnboxPlatformAgent<TKeyManager>;
|
|
46
|
+
set agent(agent: EnboxPlatformAgent<TKeyManager>);
|
|
47
47
|
get tenant(): string;
|
|
48
48
|
create({ metadata, didMethod, didOptions, store }: IdentityCreateParams<TKeyManager>): Promise<BearerIdentity>;
|
|
49
49
|
export({ didUri }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity-api.d.ts","sourceRoot":"","sources":["../../src/identity-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,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AAE,MAAM,CAAC;KAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAI1E;;;;;;OAMG;IACU,eAAe,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAgC3G;;;;;;;OAOG;IACU,eAAe,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAyB/F;;;;;OAKG;IACU,iBAAiB,CAAC,EAAE,YAAY,EAAE,GAAC;QAAE,YAAY,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;CAYrH"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export * from './bearer-identity.js';
|
|
|
12
12
|
export * from './crypto-api.js';
|
|
13
13
|
export * from './did-api.js';
|
|
14
14
|
export * from './dwn-api.js';
|
|
15
|
+
export * from './dwn-discovery-file.js';
|
|
16
|
+
export * from './dwn-discovery-payload.js';
|
|
15
17
|
export * from './dwn-encryption.js';
|
|
16
18
|
export * from './dwn-key-delivery.js';
|
|
17
19
|
export * from './dwn-record-upgrade.js';
|
|
@@ -19,6 +21,7 @@ export * from './dwn-type-guards.js';
|
|
|
19
21
|
export * from './protocol-utils.js';
|
|
20
22
|
export * from './hd-identity-vault.js';
|
|
21
23
|
export * from './identity-api.js';
|
|
24
|
+
export * from './local-dwn.js';
|
|
22
25
|
export * from './local-key-manager.js';
|
|
23
26
|
export * from './permissions-api.js';
|
|
24
27
|
export * from './store-data.js';
|
|
@@ -31,5 +34,5 @@ export * from './test-harness.js';
|
|
|
31
34
|
export * from './utils.js';
|
|
32
35
|
export * from './connect.js';
|
|
33
36
|
export * from './oidc.js';
|
|
34
|
-
export * from './
|
|
37
|
+
export * from './enbox-user-agent.js';
|
|
35
38
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,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,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,
|
|
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,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,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,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local DWN discovery — discovers a running `@enbox/dwn-server` instance
|
|
3
|
+
* so the agent can route traffic to it.
|
|
4
|
+
*
|
|
5
|
+
* Discovery channels (tried in order):
|
|
6
|
+
* 1. **In-memory cache** — serves a recent positive or negative result.
|
|
7
|
+
* 2. **Discovery file** (`~/.enbox/dwn.json`) — written by `electrobun-dwn`
|
|
8
|
+
* on startup. Fast filesystem read, no network. Available for CLI and
|
|
9
|
+
* native apps; skipped in browsers.
|
|
10
|
+
* 3. **Port probing** (fallback) — sequential HTTP `GET /info` on well-known
|
|
11
|
+
* localhost ports. Works everywhere but is slower.
|
|
12
|
+
*
|
|
13
|
+
* @see https://github.com/enboxorg/enbox/issues/585
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
import type { EnboxRpc } from '@enbox/dwn-clients';
|
|
17
|
+
import type { DwnDiscoveryFile } from './dwn-discovery-file.js';
|
|
18
|
+
/**
|
|
19
|
+
* Well-known ports the local DWN desktop app may bind to.
|
|
20
|
+
*
|
|
21
|
+
* Per the DWN Transport Spec, clients probe ports `55500` through `55509`
|
|
22
|
+
* (inclusive). Port `3000` is included as a development convenience.
|
|
23
|
+
*
|
|
24
|
+
* @see https://identity.foundation/dwn-transport/#port-probing
|
|
25
|
+
*/
|
|
26
|
+
export declare const localDwnPortCandidates: readonly [3000, 55500, 55501, 55502, 55503, 55504, 55505, 55506, 55507, 55508, 55509];
|
|
27
|
+
/**
|
|
28
|
+
* Hosts probed when discovering a local DWN server.
|
|
29
|
+
*
|
|
30
|
+
* Per the DWN Transport Spec, clients MUST use `127.0.0.1` rather than
|
|
31
|
+
* `localhost` to avoid DNS resolution ambiguity.
|
|
32
|
+
*
|
|
33
|
+
* @see https://identity.foundation/dwn-transport/#port-probing
|
|
34
|
+
*/
|
|
35
|
+
export declare const localDwnHostCandidates: readonly ["127.0.0.1"];
|
|
36
|
+
/**
|
|
37
|
+
* Controls how the agent discovers and routes to a local DWN server.
|
|
38
|
+
*
|
|
39
|
+
* - `'off'` — (default) skip local discovery entirely.
|
|
40
|
+
* - `'prefer'` — probe localhost first; fall back to DID-document endpoints.
|
|
41
|
+
* - `'only'` — require a local server; throw if none is found.
|
|
42
|
+
*/
|
|
43
|
+
export type LocalDwnStrategy = 'prefer' | 'only' | 'off';
|
|
44
|
+
/** The `server` field returned by `GET /info` on `@enbox/dwn-server`. */
|
|
45
|
+
export declare const localDwnServerName = "@enbox/dwn-server";
|
|
46
|
+
/** Strips a trailing slash from a URL so endpoint comparisons are consistent. */
|
|
47
|
+
export declare function normalizeBaseUrl(url: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* Discovers a running local DWN server.
|
|
50
|
+
*
|
|
51
|
+
* Results are cached for {@link _cacheTtlMs} milliseconds (default 10 s) to
|
|
52
|
+
* avoid repeated I/O on hot paths such as sync.
|
|
53
|
+
*
|
|
54
|
+
* @example Discovery with file-based channel
|
|
55
|
+
* ```ts
|
|
56
|
+
* import { DwnDiscoveryFile } from './dwn-discovery-file.js';
|
|
57
|
+
*
|
|
58
|
+
* const discoveryFile = new DwnDiscoveryFile();
|
|
59
|
+
* const discovery = new LocalDwnDiscovery(rpcClient, 10_000, discoveryFile);
|
|
60
|
+
* const endpoint = await discovery.getEndpoint();
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @example Browser: inject cached endpoint from `dwn://register` redirect
|
|
64
|
+
* ```ts
|
|
65
|
+
* const discovery = new LocalDwnDiscovery(rpcClient);
|
|
66
|
+
* discovery.setCachedEndpoint('http://127.0.0.1:55557');
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare class LocalDwnDiscovery {
|
|
70
|
+
private _rpcClient;
|
|
71
|
+
private _cacheTtlMs;
|
|
72
|
+
private _discoveryFile?;
|
|
73
|
+
private _cachedEndpoint?;
|
|
74
|
+
private _cacheExpiry;
|
|
75
|
+
constructor(_rpcClient: EnboxRpc, _cacheTtlMs?: number, _discoveryFile?: DwnDiscoveryFile | undefined);
|
|
76
|
+
/**
|
|
77
|
+
* Returns the base URL of a local DWN server, or `undefined` if none
|
|
78
|
+
* is discoverable.
|
|
79
|
+
*
|
|
80
|
+
* The discovery order is:
|
|
81
|
+
* 1. In-memory cache (if not expired).
|
|
82
|
+
* 2. `~/.enbox/dwn.json` discovery file (if a {@link DwnDiscoveryFile}
|
|
83
|
+
* was provided). The endpoint from the file is validated via
|
|
84
|
+
* `GET /info` to ensure the server is still running.
|
|
85
|
+
* 3. Sequential port probing on well-known localhost ports (fallback).
|
|
86
|
+
*/
|
|
87
|
+
getEndpoint(): Promise<string | undefined>;
|
|
88
|
+
/**
|
|
89
|
+
* Inject a cached endpoint (e.g. from a `dwn://register` browser redirect
|
|
90
|
+
* or from `localStorage`). The endpoint is validated via `GET /info` before
|
|
91
|
+
* caching.
|
|
92
|
+
*
|
|
93
|
+
* @returns `true` if the endpoint was validated and cached, `false` otherwise.
|
|
94
|
+
*/
|
|
95
|
+
setCachedEndpoint(endpoint: string): Promise<boolean>;
|
|
96
|
+
/**
|
|
97
|
+
* Clear the in-memory cache, forcing the next {@link getEndpoint} call
|
|
98
|
+
* to perform a fresh discovery.
|
|
99
|
+
*/
|
|
100
|
+
clearCache(): void;
|
|
101
|
+
/**
|
|
102
|
+
* Try the `~/.enbox/dwn.json` discovery file. Returns the endpoint if
|
|
103
|
+
* the file exists, is valid, and the endpoint passes `GET /info`
|
|
104
|
+
* validation. Returns `undefined` otherwise.
|
|
105
|
+
*/
|
|
106
|
+
private _tryDiscoveryFile;
|
|
107
|
+
/**
|
|
108
|
+
* Sequential HTTP probe on well-known localhost port candidates.
|
|
109
|
+
* Returns the first endpoint whose `GET /info` response identifies
|
|
110
|
+
* as `@enbox/dwn-server`, or `undefined` if none is found.
|
|
111
|
+
*/
|
|
112
|
+
private _probePortCandidates;
|
|
113
|
+
/**
|
|
114
|
+
* Call `GET /info` on the endpoint and check that
|
|
115
|
+
* `serverInfo.server === '@enbox/dwn-server'`.
|
|
116
|
+
*/
|
|
117
|
+
private _validateEndpoint;
|
|
118
|
+
/** Update the in-memory cache entry. */
|
|
119
|
+
private _setCacheEntry;
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=local-dwn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-dwn.d.ts","sourceRoot":"","sources":["../../src/local-dwn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;A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icKeyParams, KmsImportKeyParams, KmsSignParams, KmsUriUnwrapKeyParams, KmsUriWrapKeyParams, KmsVerifyParams, PublicKeyJwk } from '@enbox/crypto';
|
|
2
2
|
import type { AgentDataStore } from './store-data.js';
|
|
3
3
|
import type { AgentKeyManager } from './types/key-manager.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { EnboxPlatformAgent } from './types/agent.js';
|
|
5
5
|
type SupportedKeyGeneratorAlgorithm = 'Ed25519' | 'secp256k1' | 'ES256K' | 'secp256r1' | 'ES256' | 'X25519' | 'A128GCM' | 'A192GCM' | 'A256GCM' | 'A128KW' | 'A192KW' | 'A256KW';
|
|
6
6
|
/**
|
|
7
7
|
* The `LocalKmsParams` interface specifies the parameters for initializing an instance of
|
|
@@ -11,7 +11,7 @@ type SupportedKeyGeneratorAlgorithm = 'Ed25519' | 'secp256k1' | 'ES256K' | 'secp
|
|
|
11
11
|
* the application exits.
|
|
12
12
|
*/
|
|
13
13
|
export type LocalKmsParams = {
|
|
14
|
-
agent?:
|
|
14
|
+
agent?: EnboxPlatformAgent;
|
|
15
15
|
/**
|
|
16
16
|
* An optional property to specify a custom {@link AgentDataStore} instance for key management. If
|
|
17
17
|
* not provided, {@link LocalKeyManager} uses a default {@link InMemoryKeyStore} instance. This
|
|
@@ -50,10 +50,10 @@ export interface LocalKmsUnwrapKeyParams extends KmsUriUnwrapKeyParams {
|
|
|
50
50
|
}
|
|
51
51
|
export declare class LocalKeyManager implements AgentKeyManager {
|
|
52
52
|
/**
|
|
53
|
-
* Holds the instance of a `
|
|
54
|
-
* the `LocalKeyManager`. This agent is used to interact with other
|
|
53
|
+
* Holds the instance of a `EnboxPlatformAgent` that represents the current execution context for
|
|
54
|
+
* the `LocalKeyManager`. This agent is used to interact with other Enbox agent components. It's
|
|
55
55
|
* vital to ensure this instance is set to correctly contextualize operations within the broader
|
|
56
|
-
*
|
|
56
|
+
* Enbox Agent framework.
|
|
57
57
|
*/
|
|
58
58
|
private _agent?;
|
|
59
59
|
/**
|
|
@@ -74,13 +74,13 @@ export declare class LocalKeyManager implements AgentKeyManager {
|
|
|
74
74
|
private _keyStore;
|
|
75
75
|
constructor({ agent, keyStore }?: LocalKmsParams);
|
|
76
76
|
/**
|
|
77
|
-
* Retrieves the `
|
|
77
|
+
* Retrieves the `EnboxPlatformAgent` execution context.
|
|
78
78
|
*
|
|
79
|
-
* @returns The `
|
|
79
|
+
* @returns The `EnboxPlatformAgent` instance that represents the current execution context.
|
|
80
80
|
* @throws Will throw an error if the `agent` instance property is undefined.
|
|
81
81
|
*/
|
|
82
|
-
get agent():
|
|
83
|
-
set agent(agent:
|
|
82
|
+
get agent(): EnboxPlatformAgent;
|
|
83
|
+
set agent(agent: EnboxPlatformAgent);
|
|
84
84
|
decrypt({ keyUri, ...params }: KmsCipherParams & AesGcmParams): Promise<Uint8Array>;
|
|
85
85
|
digest(_params: KmsDigestParams): Promise<Uint8Array>;
|
|
86
86
|
encrypt({ keyUri, ...params }: KmsCipherParams & AesGcmParams): Promise<Uint8Array>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-key-manager.d.ts","sourceRoot":"","sources":["../../src/local-key-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAMZ,GAAG,EAEH,aAAa,EAEb,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,eAAe,EACf,YAAY,EAKG,MAAM,eAAe,CAAC;AAqBvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"local-key-manager.d.ts","sourceRoot":"","sources":["../../src/local-key-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAA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,6 @@
|
|
|
1
1
|
import type { ConnectPermissionRequest } from './connect.js';
|
|
2
|
+
import type { EnboxAgent } from './types/agent.js';
|
|
2
3
|
import type { RequireOnly } from '@enbox/common';
|
|
3
|
-
import type { Web5Agent } from './types/agent.js';
|
|
4
4
|
import type { DidDocument, PortableDid } from '@enbox/dids';
|
|
5
5
|
import type { DwnDataEncodedRecordsWriteMessage, DwnPermissionScope } from './types/dwn.js';
|
|
6
6
|
import { type BearerDid } from '@enbox/dids';
|
|
@@ -13,7 +13,7 @@ import { type BearerDid } from '@enbox/dids';
|
|
|
13
13
|
* @see {@link https://www.rfc-editor.org/rfc/rfc9126.html | OAuth 2.0 Pushed Authorization Requests}
|
|
14
14
|
*/
|
|
15
15
|
export type PushedAuthRequest = {
|
|
16
|
-
/** The JWT which contains the {@link
|
|
16
|
+
/** The JWT which contains the {@link EnboxConnectAuthRequest} */
|
|
17
17
|
request: string;
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
@@ -96,7 +96,7 @@ export type SIOPv2AuthRequest = {
|
|
|
96
96
|
* An auth request that is compatible with both Web5 Connect and (hopefully, WIP) OIDC SIOPv2
|
|
97
97
|
* The contents of this are inserted into a JWT inside of the {@link PushedAuthRequest}.
|
|
98
98
|
*/
|
|
99
|
-
export type
|
|
99
|
+
export type EnboxConnectAuthRequest = {
|
|
100
100
|
/** The user friendly name of the client/app to be displayed when prompting end-user with permission requests. */
|
|
101
101
|
displayName: string;
|
|
102
102
|
/** PermissionGrants that are to be sent to the provider */
|
|
@@ -127,15 +127,15 @@ export type SIOPv2AuthResponse = {
|
|
|
127
127
|
[key: string]: any;
|
|
128
128
|
};
|
|
129
129
|
/** An auth response that is compatible with both Web5 Connect and (hopefully, WIP) OIDC SIOPv2 */
|
|
130
|
-
export type
|
|
130
|
+
export type EnboxConnectAuthResponse = {
|
|
131
131
|
delegateGrants: DwnDataEncodedRecordsWriteMessage[];
|
|
132
132
|
delegatePortableDid: PortableDid;
|
|
133
133
|
} & SIOPv2AuthResponse;
|
|
134
134
|
/** Represents the different OIDC endpoint types.
|
|
135
135
|
* 1. `pushedAuthorizationRequest`: client sends {@link PushedAuthRequest} receives {@link PushedAuthResponse}
|
|
136
|
-
* 2. `authorize`: provider gets the {@link
|
|
137
|
-
* 3. `callback`: provider sends {@link
|
|
138
|
-
* 4. `token`: client gets {@link
|
|
136
|
+
* 2. `authorize`: provider gets the {@link EnboxConnectAuthRequest} JWT that was stored by the PAR
|
|
137
|
+
* 3. `callback`: provider sends {@link EnboxConnectAuthResponse} to this endpoint
|
|
138
|
+
* 4. `token`: client gets {@link EnboxConnectAuthResponse} from this endpoint
|
|
139
139
|
*/
|
|
140
140
|
type OidcEndpoint = 'pushedAuthorizationRequest' | 'authorize' | 'callback' | 'token';
|
|
141
141
|
/**
|
|
@@ -164,15 +164,15 @@ declare function generateCodeChallenge(): Promise<{
|
|
|
164
164
|
codeChallengeBytes: Uint8Array;
|
|
165
165
|
codeChallengeBase64Url: string;
|
|
166
166
|
}>;
|
|
167
|
-
/** Client creates the {@link
|
|
168
|
-
declare function createAuthRequest(options: RequireOnly<
|
|
167
|
+
/** Client creates the {@link EnboxConnectAuthRequest} */
|
|
168
|
+
declare function createAuthRequest(options: RequireOnly<EnboxConnectAuthRequest, 'client_id' | 'scope' | 'redirect_uri' | 'permissionRequests' | 'displayName'>): Promise<EnboxConnectAuthRequest>;
|
|
169
169
|
/** Encrypts the auth request with the key which will be passed through QR code */
|
|
170
170
|
declare function encryptAuthRequest({ jwt, encryptionKey, }: {
|
|
171
171
|
jwt: string;
|
|
172
172
|
encryptionKey: Uint8Array;
|
|
173
173
|
}): Promise<string>;
|
|
174
174
|
/** Create a response object compatible with Web5 Connect and OIDC SIOPv2 */
|
|
175
|
-
declare function createResponseObject(options: RequireOnly<
|
|
175
|
+
declare function createResponseObject(options: RequireOnly<EnboxConnectAuthResponse, 'iss' | 'sub' | 'aud' | 'delegateGrants' | 'delegatePortableDid'>): Promise<EnboxConnectAuthResponse>;
|
|
176
176
|
/** sign an object and transform it into a jwt using a did */
|
|
177
177
|
declare function signJwt({ did, data, }: {
|
|
178
178
|
did: BearerDid;
|
|
@@ -189,7 +189,7 @@ declare function decryptAuthRequest({ jwe, encryption_key, }: {
|
|
|
189
189
|
}): Promise<string>;
|
|
190
190
|
/**
|
|
191
191
|
* The client uses to decrypt the jwe obtained from the auth server which contains
|
|
192
|
-
* the {@link
|
|
192
|
+
* the {@link EnboxConnectAuthResponse} that was sent by the provider to the auth server.
|
|
193
193
|
*
|
|
194
194
|
* @async
|
|
195
195
|
* @param {BearerDid} clientDid - The did that was initially used by the client for ECDH at connect init.
|
|
@@ -197,7 +197,7 @@ declare function decryptAuthRequest({ jwe, encryption_key, }: {
|
|
|
197
197
|
* @param {string} pin - The pin that was obtained from the user.
|
|
198
198
|
*/
|
|
199
199
|
declare function decryptAuthResponse(clientDid: BearerDid, jwe: string, pin: string): Promise<string>;
|
|
200
|
-
/** Derives a shared ECDH private key in order to encrypt the {@link
|
|
200
|
+
/** Derives a shared ECDH private key in order to encrypt the {@link EnboxConnectAuthResponse} */
|
|
201
201
|
declare function deriveSharedKey(privateKeyDid: BearerDid, publicKeyDid: DidDocument): Promise<Uint8Array>;
|
|
202
202
|
/**
|
|
203
203
|
* Encrypts the auth response jwt. Requires a randomPin is added to the AAD of the
|
|
@@ -213,23 +213,23 @@ declare function encryptAuthResponse({ jwt, encryptionKey, delegateDidKeyId, ran
|
|
|
213
213
|
}): Promise<string>;
|
|
214
214
|
/**
|
|
215
215
|
* Creates the permission grants that assign to the selectedDid the level of
|
|
216
|
-
* permissions that the web app requested in the {@link
|
|
216
|
+
* permissions that the web app requested in the {@link EnboxConnectAuthRequest}
|
|
217
217
|
*/
|
|
218
|
-
declare function createPermissionGrants(selectedDid: string, delegateBearerDid: BearerDid, agent:
|
|
218
|
+
declare function createPermissionGrants(selectedDid: string, delegateBearerDid: BearerDid, agent: EnboxAgent, scopes: DwnPermissionScope[]): Promise<DwnDataEncodedRecordsWriteMessage[]>;
|
|
219
219
|
/**
|
|
220
220
|
* Creates a delegate did which the web app will use as its future indentity.
|
|
221
221
|
* Assigns to that DID the level of permissions that the web app requested in
|
|
222
|
-
* the {@link
|
|
222
|
+
* the {@link EnboxConnectAuthRequest}. Encrypts via ECDH key that the web app
|
|
223
223
|
* will have access to because the web app has the public key which it provided
|
|
224
|
-
* in the {@link
|
|
225
|
-
* {@link
|
|
224
|
+
* in the {@link EnboxConnectAuthRequest}. Then sends the ciphertext of this
|
|
225
|
+
* {@link EnboxConnectAuthResponse} to the callback endpoint. Which the
|
|
226
226
|
* web app will need to retrieve from the token endpoint and decrypt with the pin to access.
|
|
227
227
|
*/
|
|
228
|
-
declare function submitAuthResponse(selectedDid: string, authRequest:
|
|
228
|
+
declare function submitAuthResponse(selectedDid: string, authRequest: EnboxConnectAuthRequest, randomPin: string, agent: EnboxAgent): Promise<void>;
|
|
229
229
|
export declare const Oidc: {
|
|
230
230
|
createAuthRequest: typeof createAuthRequest;
|
|
231
231
|
encryptAuthRequest: typeof encryptAuthRequest;
|
|
232
|
-
getAuthRequest: (request_uri: string, encryption_key: string) => Promise<
|
|
232
|
+
getAuthRequest: (request_uri: string, encryption_key: string) => Promise<EnboxConnectAuthRequest>;
|
|
233
233
|
decryptAuthRequest: typeof decryptAuthRequest;
|
|
234
234
|
createPermissionGrants: typeof createPermissionGrants;
|
|
235
235
|
createResponseObject: typeof createResponseObject;
|
|
@@ -242,5 +242,9 @@ export declare const Oidc: {
|
|
|
242
242
|
generateCodeChallenge: typeof generateCodeChallenge;
|
|
243
243
|
submitAuthResponse: typeof submitAuthResponse;
|
|
244
244
|
};
|
|
245
|
+
/** @deprecated Use {@link EnboxConnectAuthRequest} instead. */
|
|
246
|
+
export type Web5ConnectAuthRequest = EnboxConnectAuthRequest;
|
|
247
|
+
/** @deprecated Use {@link EnboxConnectAuthResponse} instead. */
|
|
248
|
+
export type Web5ConnectAuthResponse = EnboxConnectAuthResponse;
|
|
245
249
|
export {};
|
|
246
250
|
//# sourceMappingURL=oidc.d.ts.map
|