@enbox/auth 0.5.0 → 0.6.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.
Files changed (81) hide show
  1. package/dist/esm/auth-manager.js +94 -167
  2. package/dist/esm/auth-manager.js.map +1 -1
  3. package/dist/esm/connect/import.js +131 -0
  4. package/dist/esm/connect/import.js.map +1 -0
  5. package/dist/esm/connect/lifecycle.js +235 -0
  6. package/dist/esm/connect/lifecycle.js.map +1 -0
  7. package/dist/esm/connect/local.js +91 -0
  8. package/dist/esm/connect/local.js.map +1 -0
  9. package/dist/esm/{flows/session-restore.js → connect/restore.js} +34 -56
  10. package/dist/esm/connect/restore.js.map +1 -0
  11. package/dist/esm/{flows/wallet-connect.js → connect/wallet.js} +28 -35
  12. package/dist/esm/connect/wallet.js.map +1 -0
  13. package/dist/esm/{flows/dwn-discovery.js → discovery.js} +2 -2
  14. package/dist/esm/discovery.js.map +1 -0
  15. package/dist/esm/index.js +4 -4
  16. package/dist/esm/index.js.map +1 -1
  17. package/dist/esm/{flows/dwn-registration.js → registration.js} +2 -2
  18. package/dist/esm/registration.js.map +1 -0
  19. package/dist/esm/types.js +2 -0
  20. package/dist/esm/types.js.map +1 -1
  21. package/dist/esm/wallet-connect-client.js +188 -0
  22. package/dist/esm/wallet-connect-client.js.map +1 -0
  23. package/dist/types/auth-manager.d.ts +20 -6
  24. package/dist/types/auth-manager.d.ts.map +1 -1
  25. package/dist/types/connect/import.d.ts +25 -0
  26. package/dist/types/connect/import.d.ts.map +1 -0
  27. package/dist/types/connect/lifecycle.d.ts +152 -0
  28. package/dist/types/connect/lifecycle.d.ts.map +1 -0
  29. package/dist/types/connect/local.d.ts +18 -0
  30. package/dist/types/connect/local.d.ts.map +1 -0
  31. package/dist/types/connect/restore.d.ts +18 -0
  32. package/dist/types/connect/restore.d.ts.map +1 -0
  33. package/dist/types/{flows/wallet-connect.d.ts → connect/wallet.d.ts} +5 -14
  34. package/dist/types/connect/wallet.d.ts.map +1 -0
  35. package/dist/types/{flows/dwn-discovery.d.ts → discovery.d.ts} +3 -3
  36. package/dist/types/discovery.d.ts.map +1 -0
  37. package/dist/types/index.d.ts +5 -4
  38. package/dist/types/index.d.ts.map +1 -1
  39. package/dist/types/{flows/dwn-registration.d.ts → registration.d.ts} +2 -2
  40. package/dist/types/registration.d.ts.map +1 -0
  41. package/dist/types/types.d.ts +6 -3
  42. package/dist/types/types.d.ts.map +1 -1
  43. package/dist/types/wallet-connect-client.d.ts +89 -0
  44. package/dist/types/wallet-connect-client.d.ts.map +1 -0
  45. package/package.json +9 -5
  46. package/src/auth-manager.ts +94 -188
  47. package/src/connect/import.ts +148 -0
  48. package/src/connect/lifecycle.ts +321 -0
  49. package/src/connect/local.ts +101 -0
  50. package/src/connect/restore.ts +117 -0
  51. package/src/{flows/wallet-connect.ts → connect/wallet.ts} +37 -54
  52. package/src/{flows/dwn-discovery.ts → discovery.ts} +4 -3
  53. package/src/index.ts +5 -4
  54. package/src/{flows/dwn-registration.ts → registration.ts} +2 -2
  55. package/src/types.ts +7 -3
  56. package/src/wallet-connect-client.ts +278 -0
  57. package/dist/esm/flows/dwn-discovery.js.map +0 -1
  58. package/dist/esm/flows/dwn-registration.js.map +0 -1
  59. package/dist/esm/flows/import-identity.js +0 -177
  60. package/dist/esm/flows/import-identity.js.map +0 -1
  61. package/dist/esm/flows/local-connect.js +0 -158
  62. package/dist/esm/flows/local-connect.js.map +0 -1
  63. package/dist/esm/flows/session-restore.js.map +0 -1
  64. package/dist/esm/flows/wallet-connect.js.map +0 -1
  65. package/dist/esm/vault/vault-manager.js +0 -95
  66. package/dist/esm/vault/vault-manager.js.map +0 -1
  67. package/dist/types/flows/dwn-discovery.d.ts.map +0 -1
  68. package/dist/types/flows/dwn-registration.d.ts.map +0 -1
  69. package/dist/types/flows/import-identity.d.ts +0 -35
  70. package/dist/types/flows/import-identity.d.ts.map +0 -1
  71. package/dist/types/flows/local-connect.d.ts +0 -31
  72. package/dist/types/flows/local-connect.d.ts.map +0 -1
  73. package/dist/types/flows/session-restore.d.ts +0 -29
  74. package/dist/types/flows/session-restore.d.ts.map +0 -1
  75. package/dist/types/flows/wallet-connect.d.ts.map +0 -1
  76. package/dist/types/vault/vault-manager.d.ts +0 -57
  77. package/dist/types/vault/vault-manager.d.ts.map +0 -1
  78. package/src/flows/import-identity.ts +0 -219
  79. package/src/flows/local-connect.ts +0 -192
  80. package/src/flows/session-restore.ts +0 -155
  81. package/src/vault/vault-manager.ts +0 -89
@@ -20,7 +20,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
20
20
  });
21
21
  };
22
22
  import { DwnRegistrar } from '@enbox/dwn-clients';
23
- import { STORAGE_KEYS } from '../types.js';
23
+ import { STORAGE_KEYS } from './types.js';
24
24
  /**
25
25
  * Register the agent and connected DIDs with the configured DWN endpoints.
26
26
  *
@@ -165,4 +165,4 @@ export function saveTokensToStorage(storage, tokens) {
165
165
  yield storage.set(STORAGE_KEYS.REGISTRATION_TOKENS, JSON.stringify(tokens));
166
166
  });
167
167
  }
168
- //# sourceMappingURL=dwn-registration.js.map
168
+ //# sourceMappingURL=registration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registration.js","sourceRoot":"","sources":["../../src/registration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;;;;;;;;;;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA6B1C;;;;;;;;;;;GAWG;AACH,MAAM,UAAgB,wBAAwB,CAC5C,GAAwB,EACxB,YAAiC;;;QAEjC,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC;QAEzE,wEAAwE;QACxE,8EAA8E;QAC9E,IAAI,UAAU,GAA0C,EAAE,CAAC;QAE3D,IAAI,YAAY,CAAC,aAAa,IAAI,OAAO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CAAC;YACxB,YAAY,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;CAAA;AAED,qEAAqE;AAErE;;;;;;;GAOG;AACH,MAAM,UAAgB,qBAAqB,CACzC,OAAuB;;QAEvB,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;YAChE,IAAI,CAAC,GAAG,EAAE,CAAC;gBAAC,OAAO,EAAE,CAAC;YAAC,CAAC;YACxB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAA0C,CAAC;QAClE,CAAC;QAAC,WAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;CAAA;AAED;;;GAGG;AACH,MAAM,UAAgB,mBAAmB,CACvC,OAAuB,EACvB,MAA6C;;QAE7C,MAAM,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,mBAAmB,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9E,CAAC;CAAA"}
package/dist/esm/types.js CHANGED
@@ -5,6 +5,8 @@
5
5
  // ─── Internal helpers ────────────────────────────────────────────
6
6
  /** The insecure default password used when none is provided. */
7
7
  export const INSECURE_DEFAULT_PASSWORD = 'insecure-static-phrase';
8
+ /** Default DWN endpoints for new identities when none are configured. */
9
+ export const DEFAULT_DWN_ENDPOINTS = ['https://enbox-dwn.fly.dev'];
8
10
  /**
9
11
  * Storage keys used by the auth manager for session persistence.
10
12
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA0cH,oEAAoE;AAEpE,gEAAgE;AAChE,MAAM,CAAC,MAAM,yBAAyB,GAAG,wBAAwB,CAAC;AAElE;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,oDAAoD;IACpD,oBAAoB,EAAE,gCAAgC;IAEtD,+CAA+C;IAC/C,eAAe,EAAE,2BAA2B;IAE5C,4DAA4D;IAC5D,YAAY,EAAE,wBAAwB;IAEtC,yDAAyD;IACzD,aAAa,EAAE,yBAAyB;IAExC;;;;;;OAMG;IACH,kBAAkB,EAAE,6BAA6B;IAEjD;;;;;;OAMG;IACH,mBAAmB,EAAE,+BAA+B;CAC5C,CAAC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA2cH,oEAAoE;AAEpE,gEAAgE;AAChE,MAAM,CAAC,MAAM,yBAAyB,GAAG,wBAAwB,CAAC;AAElE,yEAAyE;AACzE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,2BAA2B,CAAC,CAAC;AAEnE;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,oDAAoD;IACpD,oBAAoB,EAAE,gCAAgC;IAEtD,+CAA+C;IAC/C,eAAe,EAAE,2BAA2B;IAE5C,4DAA4D;IAC5D,YAAY,EAAE,wBAAwB;IAEtC,yDAAyD;IACzD,aAAa,EAAE,yBAAyB;IAExC;;;;;;OAMG;IACH,kBAAkB,EAAE,6BAA6B;IAEjD;;;;;;OAMG;IACH,mBAAmB,EAAE,+BAA+B;CAC5C,CAAC"}
@@ -0,0 +1,188 @@
1
+ /**
2
+ * WalletConnect client — initiates the relay-mediated connect flow.
3
+ *
4
+ * Moved from `@enbox/agent/src/connect.ts` because `initClient` has zero
5
+ * coupling to agent internals (no vault, no key store, no DWN processing,
6
+ * no sync). Its only consumer is `auth/src/connect/wallet.ts`.
7
+ *
8
+ * The server-side counterpart (`EnboxConnectProtocol`) correctly stays in
9
+ * `@enbox/agent` because it uses `agent.processDwnRequest()`,
10
+ * `agent.sendDwnRequest()`, and `AgentPermissionsApi`.
11
+ *
12
+ * @module
13
+ */
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ import { CryptoUtils } from '@enbox/crypto';
24
+ import { DidJwk } from '@enbox/dids';
25
+ import { Convert, logger } from '@enbox/common';
26
+ import { DwnInterfaceName, DwnMethodName } from '@enbox/dwn-sdk-js';
27
+ import { EnboxConnectProtocol, pollWithTtl } from '@enbox/agent';
28
+ /**
29
+ * Initiates the wallet connect process. Used when a client wants to obtain
30
+ * a did from a provider.
31
+ */
32
+ function initClient(_a) {
33
+ return __awaiter(this, arguments, void 0, function* ({ displayName, connectServerUrl, walletUri, permissionRequests, onWalletUriReady, validatePin, }) {
34
+ // ephemeral client did for ECDH, signing, verification
35
+ const clientDid = yield DidJwk.create();
36
+ // TODO: properly implement PKCE. this implementation is lacking server side validations and more.
37
+ // https://github.com/enboxorg/enbox/issues/829
38
+ // Derive the code challenge based on the code verifier
39
+ // const { codeChallengeBytes, codeChallengeBase64Url } =
40
+ // await Oidc.generateCodeChallenge();
41
+ const encryptionKey = CryptoUtils.randomBytes(32);
42
+ // Build callback URL for the connect request.
43
+ const callbackEndpoint = EnboxConnectProtocol.buildConnectUrl({
44
+ baseURL: connectServerUrl,
45
+ endpoint: 'callback',
46
+ });
47
+ // Build the connect request.
48
+ const request = yield EnboxConnectProtocol.createConnectRequest({
49
+ clientDid: clientDid.uri,
50
+ callbackUrl: callbackEndpoint,
51
+ permissionRequests: permissionRequests,
52
+ appName: displayName,
53
+ });
54
+ // Sign the request as a JWT.
55
+ const requestJwt = yield EnboxConnectProtocol.signJwt({
56
+ did: clientDid,
57
+ data: request,
58
+ });
59
+ if (!requestJwt) {
60
+ throw new Error('Unable to sign requestObject');
61
+ }
62
+ // Encrypt the request JWT with the symmetric key.
63
+ const requestObjectJwe = yield EnboxConnectProtocol.encryptRequest({
64
+ jwt: requestJwt,
65
+ encryptionKey,
66
+ });
67
+ const pushedAuthorizationRequestEndpoint = EnboxConnectProtocol.buildConnectUrl({
68
+ baseURL: connectServerUrl,
69
+ endpoint: 'pushedAuthorizationRequest',
70
+ });
71
+ const parResponse = yield fetch(pushedAuthorizationRequestEndpoint, {
72
+ body: JSON.stringify({ request: requestObjectJwe }),
73
+ method: 'POST',
74
+ headers: {
75
+ 'Content-Type': 'application/json',
76
+ },
77
+ signal: AbortSignal.timeout(30000),
78
+ });
79
+ if (!parResponse.ok) {
80
+ throw new Error(`${parResponse.status}: ${parResponse.statusText}`);
81
+ }
82
+ const parData = yield parResponse.json();
83
+ // a deeplink to a compatible wallet. if the wallet scans this link it should receive
84
+ // a route to its Connect provider flow and the params of where to fetch the auth request.
85
+ logger.log(`Wallet URI: ${walletUri}`);
86
+ const generatedWalletUri = new URL(walletUri);
87
+ generatedWalletUri.searchParams.set('request_uri', parData.request_uri);
88
+ generatedWalletUri.searchParams.set('encryption_key', Convert.uint8Array(encryptionKey).toBase64Url());
89
+ // call user's callback so they can send the URI to the wallet as they see fit
90
+ onWalletUriReady(generatedWalletUri.toString());
91
+ const tokenUrl = EnboxConnectProtocol.buildConnectUrl({
92
+ baseURL: connectServerUrl,
93
+ endpoint: 'token',
94
+ tokenParam: request.state,
95
+ });
96
+ // subscribe to receiving a response from the wallet with default TTL. receive ciphertext of {@link EnboxConnectResponse}
97
+ const authResponse = yield pollWithTtl(() => fetch(tokenUrl, { signal: AbortSignal.timeout(30000) }));
98
+ if (authResponse) {
99
+ const jwe = yield (authResponse === null || authResponse === void 0 ? void 0 : authResponse.text());
100
+ // Get the PIN from the user and use it as AAD to decrypt.
101
+ const pin = yield validatePin();
102
+ const jwt = yield EnboxConnectProtocol.decryptResponse(clientDid, jwe, pin);
103
+ const verifiedResponse = (yield EnboxConnectProtocol.verifyJwt({
104
+ jwt,
105
+ }));
106
+ return {
107
+ delegateGrants: verifiedResponse.delegateGrants,
108
+ delegatePortableDid: verifiedResponse.delegatePortableDid,
109
+ connectedDid: verifiedResponse.providerDid,
110
+ };
111
+ }
112
+ });
113
+ }
114
+ /**
115
+ * Creates a set of Dwn Permission Scopes to request for a given protocol.
116
+ *
117
+ * If no permissions are provided, the default is to request all relevant record permissions (write, read, delete, query, subscribe).
118
+ * 'configure' is not included by default, as this gives the application a lot of control over the protocol.
119
+ */
120
+ function createPermissionRequestForProtocol({ definition, permissions }) {
121
+ const requests = [];
122
+ // Add the ability to query for the specific protocol
123
+ requests.push({
124
+ protocol: definition.protocol,
125
+ interface: DwnInterfaceName.Protocols,
126
+ method: DwnMethodName.Query,
127
+ });
128
+ // A Messages.Read grant is a unified scope that covers MessagesRead, MessagesSync, and MessagesSubscribe.
129
+ // This single grant enables sync and real-time subscriptions for the protocol.
130
+ requests.push({
131
+ protocol: definition.protocol,
132
+ interface: DwnInterfaceName.Messages,
133
+ method: DwnMethodName.Read,
134
+ });
135
+ // We also request any additional permissions the user has requested for this protocol
136
+ for (const permission of permissions) {
137
+ switch (permission) {
138
+ case 'write':
139
+ requests.push({
140
+ protocol: definition.protocol,
141
+ interface: DwnInterfaceName.Records,
142
+ method: DwnMethodName.Write,
143
+ });
144
+ break;
145
+ case 'read':
146
+ requests.push({
147
+ protocol: definition.protocol,
148
+ interface: DwnInterfaceName.Records,
149
+ method: DwnMethodName.Read,
150
+ });
151
+ break;
152
+ case 'delete':
153
+ requests.push({
154
+ protocol: definition.protocol,
155
+ interface: DwnInterfaceName.Records,
156
+ method: DwnMethodName.Delete,
157
+ });
158
+ break;
159
+ case 'query':
160
+ requests.push({
161
+ protocol: definition.protocol,
162
+ interface: DwnInterfaceName.Records,
163
+ method: DwnMethodName.Query,
164
+ });
165
+ break;
166
+ case 'subscribe':
167
+ requests.push({
168
+ protocol: definition.protocol,
169
+ interface: DwnInterfaceName.Records,
170
+ method: DwnMethodName.Subscribe,
171
+ });
172
+ break;
173
+ case 'configure':
174
+ requests.push({
175
+ protocol: definition.protocol,
176
+ interface: DwnInterfaceName.Protocols,
177
+ method: DwnMethodName.Configure,
178
+ });
179
+ break;
180
+ }
181
+ }
182
+ return {
183
+ protocolDefinition: definition,
184
+ permissionScopes: requests,
185
+ };
186
+ }
187
+ export const WalletConnect = { initClient, createPermissionRequestForProtocol };
188
+ //# sourceMappingURL=wallet-connect-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet-connect-client.js","sourceRoot":"","sources":["../../src/wallet-connect-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;;;;;;;;;;AAKH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AA+DjE;;;GAGG;AACH,SAAe,UAAU;yDAAC,EACxB,WAAW,EACX,gBAAgB,EAChB,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,GACgB;QAK3B,uDAAuD;QACvD,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC;QAExC,kGAAkG;QAClG,+CAA+C;QAC/C,uDAAuD;QACvD,yDAAyD;QACzD,wCAAwC;QACxC,MAAM,aAAa,GAAG,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAElD,8CAA8C;QAC9C,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,eAAe,CAAC;YAC5D,OAAO,EAAI,gBAAgB;YAC3B,QAAQ,EAAG,UAAU;SACtB,CAAC,CAAC;QAEH,6BAA6B;QAC7B,MAAM,OAAO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H,MAAM;YACR,KAAK,OAAO;gBACV,QAAQ,CAAC,IAAI,CAAC;oBACZ,QAAQ,EAAI,UAAU,CAAC,QAAQ;oBAC/B,SAAS,EAAG,gBAAgB,CAAC,OAAO;oBACpC,MAAM,EAAM,aAAa,CAAC,KAAK;iBAChC,CAAC,CAAC;gBACH,MAAM;YACR,KAAK,WAAW;gBACd,QAAQ,CAAC,IAAI,CAAC;oBACZ,QAAQ,EAAI,UAAU,CAAC,QAAQ;oBAC/B,SAAS,EAAG,gBAAgB,CAAC,OAAO;oBACpC,MAAM,EAAM,aAAa,CAAC,SAAS;iBACpC,CAAC,CAAC;gBACH,MAAM;YACR,KAAK,WAAW;gBACd,QAAQ,CAAC,IAAI,CAAC;oBACZ,QAAQ,EAAI,UAAU,CAAC,QAAQ;oBAC/B,SAAS,EAAG,gBAAgB,CAAC,SAAS;oBACtC,MAAM,EAAM,aAAa,CAAC,SAAS;iBACpC,CAAC,CAAC;gBACH,MAAM;QACV,CAAC;IACH,CAAC;IAED,OAAO;QACL,kBAAkB,EAAG,UAAU;QAC/B,gBAAgB,EAAK,QAAQ;KAC9B,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,UAAU,EAAE,kCAAkC,EAAE,CAAC"}
@@ -5,11 +5,10 @@
5
5
  * multi-identity-aware auth system that works in both browser and CLI environments.
6
6
  * @module
7
7
  */
8
+ import type { HdIdentityVault, PortableIdentity } from '@enbox/agent';
9
+ import type { AuthEvent, AuthEventHandler, AuthManagerOptions, AuthState, DisconnectOptions, HeadlessConnectOptions, IdentityInfo, ImportFromPhraseOptions, ImportFromPortableOptions, LocalConnectOptions, RestoreSessionOptions, ShutdownOptions, WalletConnectOptions } from './types.js';
8
10
  import { EnboxUserAgent } from '@enbox/agent';
9
- import type { PortableIdentity } from '@enbox/agent';
10
11
  import { AuthSession } from './identity-session.js';
11
- import { VaultManager } from './vault/vault-manager.js';
12
- import type { AuthEvent, AuthEventHandler, AuthManagerOptions, AuthState, DisconnectOptions, HeadlessConnectOptions, IdentityInfo, ImportFromPhraseOptions, ImportFromPortableOptions, LocalConnectOptions, RestoreSessionOptions, ShutdownOptions, WalletConnectOptions } from './types.js';
13
12
  /**
14
13
  * The primary entry point for authentication and identity management.
15
14
  *
@@ -47,7 +46,6 @@ export declare class AuthManager {
47
46
  private _userAgent;
48
47
  private _emitter;
49
48
  private _storage;
50
- private _vault;
51
49
  private _session;
52
50
  private _state;
53
51
  private _isConnecting;
@@ -223,8 +221,8 @@ export declare class AuthManager {
223
221
  * to another device.
224
222
  */
225
223
  exportIdentity(didUri: string): Promise<PortableIdentity>;
226
- /** Access the vault manager for lock/unlock/backup operations. */
227
- get vault(): VaultManager;
224
+ /** Access the underlying identity vault for lock/unlock/backup operations. */
225
+ get vault(): HdIdentityVault;
228
226
  /**
229
227
  * Subscribe to an auth lifecycle event.
230
228
  *
@@ -251,6 +249,22 @@ export declare class AuthManager {
251
249
  * before any event listeners are attached.
252
250
  */
253
251
  get localDwnEndpoint(): string | undefined;
252
+ /**
253
+ * Build a `FlowContext` from the manager's current state.
254
+ *
255
+ * Replaces the 5 manual inline context constructions that were
256
+ * previously duplicated across `connect()`, `walletConnect()`,
257
+ * `importFromPhrase()`, `importFromPortable()`, and `restoreSession()`.
258
+ */
259
+ private _flowContext;
260
+ /**
261
+ * Template for connection flows that follow the guard → try/finally → setState pattern.
262
+ *
263
+ * Consolidates the duplicated concurrency guard, `_isConnecting` flag management,
264
+ * session assignment, and state transition across `connect()`, `walletConnect()`,
265
+ * `importFromPhrase()`, and `importFromPortable()`.
266
+ */
267
+ private _withConnect;
254
268
  private _setState;
255
269
  private _guardConcurrency;
256
270
  }
@@ -1 +1 @@
1
- {"version":3,"file":"auth-manager.d.ts","sourceRoot":"","sources":["../../src/auth-manager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAkB,gBAAgB,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,CAAC,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAsD5D;;;;;OAKG;IACG,cAAc,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAS/C;;;;;OAKG;IACG,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAuD1D;;;;;;OAMG;IACG,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA4BnD;;;;;OAKG;IACG,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAM/D,8EAA8E;IAC9E,IAAI,KAAK,IAAI,eAAe,CAE3B;IAID;;;;;;OAMG;IACH,EAAE,CAAC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI;IAM3E,8BAA8B;IAC9B,IAAI,KAAK,IAAI,SAAS,CAErB;IAED,wCAAwC;IACxC,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED,6CAA6C;IAC7C,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,mDAAmD;IACnD,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,0DAA0D;IAC1D,IAAI,KAAK,IAAI,cAAc,CAE1B;IAED;;;;;;OAMG;IACH,IAAI,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAEzC;IAID;;;;;;OAMG;IACH,OAAO,CAAC,YAAY;IAapB;;;;;;OAMG;YACW,YAAY;IAc1B,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,iBAAiB;CAQ1B"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Identity import flows.
3
+ *
4
+ * - Import from BIP-39 recovery phrase (re-derive vault + identity).
5
+ * - Import from PortableIdentity JSON.
6
+ * @module
7
+ */
8
+ import type { AuthSession } from '../identity-session.js';
9
+ import type { FlowContext } from './lifecycle.js';
10
+ import type { ImportFromPhraseOptions, ImportFromPortableOptions } from '../types.js';
11
+ /**
12
+ * Import (or recover) an identity from a BIP-39 recovery phrase.
13
+ *
14
+ * This re-initializes the vault with the given phrase and password,
15
+ * recovering the agent DID and all derived keys.
16
+ */
17
+ export declare function importFromPhrase(ctx: FlowContext, options: ImportFromPhraseOptions): Promise<AuthSession>;
18
+ /**
19
+ * Import an identity from a PortableIdentity JSON object.
20
+ *
21
+ * The portable identity contains the DID's private keys and metadata,
22
+ * allowing it to be used on this device.
23
+ */
24
+ export declare function importFromPortable(ctx: FlowContext, options: ImportFromPortableOptions): Promise<AuthSession>;
25
+ //# sourceMappingURL=import.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../../src/connect/import.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAMtF;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,WAAW,CAAC,CAiEtB;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,WAAW,CAAC,CA8CtB"}
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Shared helpers for connect flows.
3
+ *
4
+ * Consolidates duplicated logic across `local-connect`, `session-restore`,
5
+ * `wallet-connect`, and `import-identity` flows:
6
+ *
7
+ * - Password resolution chain
8
+ * - Vault init/start lifecycle
9
+ * - Sync mode/interval calculation and startup
10
+ * - `connectedDid` / `delegateDid` derivation from identity metadata
11
+ * - Session finalization (storage persistence + AuthSession construction + events)
12
+ *
13
+ * @module
14
+ * @internal
15
+ */
16
+ import type { BearerIdentity, EnboxUserAgent } from '@enbox/agent';
17
+ import type { AuthEventEmitter } from '../events.js';
18
+ import type { PasswordProvider } from '../password-provider.js';
19
+ import type { RegistrationOptions, StorageAdapter, SyncOption } from '../types.js';
20
+ import { AuthSession } from '../identity-session.js';
21
+ /**
22
+ * Unified context passed from `AuthManager` to every connect flow.
23
+ *
24
+ * Replaces the per-flow `LocalConnectContext`, `SessionRestoreContext`,
25
+ * `WalletConnectContext`, and `ImportContext` interfaces. All fields are
26
+ * optional beyond the core triple (`userAgent`, `emitter`, `storage`) so
27
+ * flows only consume what they need.
28
+ *
29
+ * @internal
30
+ */
31
+ export interface FlowContext {
32
+ userAgent: EnboxUserAgent;
33
+ emitter: AuthEventEmitter;
34
+ storage: StorageAdapter;
35
+ defaultPassword?: string;
36
+ passwordProvider?: PasswordProvider;
37
+ defaultSync?: SyncOption;
38
+ defaultDwnEndpoints?: string[];
39
+ registration?: RegistrationOptions;
40
+ }
41
+ /**
42
+ * Resolve a password through the standard chain:
43
+ * explicit option → manager default → provider → insecure fallback.
44
+ *
45
+ * Emits a console warning when the insecure default is used.
46
+ *
47
+ * @param ctx - The flow context (provides `defaultPassword` and `passwordProvider`).
48
+ * @param explicit - An explicit password from the caller (highest priority).
49
+ * @param isFirstLaunch - Whether the vault has never been initialized.
50
+ * @returns The resolved password string.
51
+ *
52
+ * @internal
53
+ */
54
+ export declare function resolvePassword(ctx: Pick<FlowContext, 'defaultPassword' | 'passwordProvider'>, explicit: string | undefined, isFirstLaunch: boolean): Promise<string>;
55
+ /**
56
+ * Initialize (on first launch) and start the agent, then emit `vault-unlocked`.
57
+ *
58
+ * This consolidates the 5 copies of:
59
+ * ```ts
60
+ * if (isFirstLaunch) { await userAgent.initialize({ password, ... }); }
61
+ * await userAgent.start({ password });
62
+ * emitter.emit('vault-unlocked', {});
63
+ * ```
64
+ *
65
+ * @returns The recovery phrase if the vault was just initialized, otherwise `undefined`.
66
+ *
67
+ * @internal
68
+ */
69
+ export declare function ensureVaultReady(params: {
70
+ userAgent: EnboxUserAgent;
71
+ emitter: AuthEventEmitter;
72
+ password: string;
73
+ isFirstLaunch: boolean;
74
+ recoveryPhrase?: string;
75
+ dwnEndpoints?: string[];
76
+ }): Promise<string | undefined>;
77
+ /**
78
+ * Start DWN synchronisation if `sync` is not `'off'`.
79
+ *
80
+ * Consolidates 6 copies of:
81
+ * ```ts
82
+ * const syncMode = sync === undefined ? 'live' : 'poll';
83
+ * const syncInterval = sync ?? (syncMode === 'live' ? '5m' : '2m');
84
+ * userAgent.sync.startSync({ mode: syncMode, interval: syncInterval })
85
+ * .catch((err) => console.error('[@enbox/auth] Sync failed:', err));
86
+ * ```
87
+ *
88
+ * @internal
89
+ */
90
+ export declare function startSyncIfEnabled(userAgent: EnboxUserAgent, sync: SyncOption | undefined): void;
91
+ /**
92
+ * Create a new `did:dht` identity with Ed25519 signing and X25519
93
+ * encryption keys, and a DWN service endpoint.
94
+ *
95
+ * This consolidates the identical identity creation block that was
96
+ * duplicated in `localConnect` and `importFromPhrase`.
97
+ *
98
+ * @internal
99
+ */
100
+ export declare function createDefaultIdentity(userAgent: EnboxUserAgent, dwnEndpoints?: string[], name?: string): Promise<BearerIdentity>;
101
+ /**
102
+ * Derive `connectedDid` and `delegateDid` from identity metadata.
103
+ *
104
+ * For a **local** identity: `connectedDid` is the identity's own DID URI
105
+ * and `delegateDid` is `undefined`.
106
+ *
107
+ * For a **wallet-connected** identity: `connectedDid` is the external wallet
108
+ * DID, and `delegateDid` is the local identity's DID URI.
109
+ *
110
+ * @param identity - The bearer identity to extract DIDs from.
111
+ * @param storedDelegateDid - Optional fallback delegate DID from storage,
112
+ * used by session-restore when the identity metadata doesn't include a
113
+ * `connectedDid` but a delegate DID was persisted in a prior session.
114
+ *
115
+ * @internal
116
+ */
117
+ export declare function resolveIdentityDids(identity: BearerIdentity, storedDelegateDid?: string): {
118
+ connectedDid: string;
119
+ delegateDid: string | undefined;
120
+ };
121
+ /**
122
+ * Persist session markers, build an `AuthSession`, and emit lifecycle events.
123
+ *
124
+ * Consolidates 5 copies of:
125
+ * ```ts
126
+ * await storage.set(STORAGE_KEYS.PREVIOUSLY_CONNECTED, 'true');
127
+ * await storage.set(STORAGE_KEYS.ACTIVE_IDENTITY, connectedDid);
128
+ * const session = new AuthSession({ ... });
129
+ * emitter.emit('identity-added', { identity: identityInfo });
130
+ * emitter.emit('session-start', { session: { ... } });
131
+ * ```
132
+ *
133
+ * @param params.emitIdentityAdded - Whether to emit `identity-added`. Defaults to `true`.
134
+ * Set to `false` for session-restore (identity was already added in the original flow).
135
+ * @param params.extraStorageKeys - Additional key-value pairs to persist (e.g. delegate/connected DIDs
136
+ * for wallet-connect flows).
137
+ *
138
+ * @internal
139
+ */
140
+ export declare function finalizeSession(params: {
141
+ userAgent: EnboxUserAgent;
142
+ emitter: AuthEventEmitter;
143
+ storage: StorageAdapter;
144
+ connectedDid: string;
145
+ delegateDid?: string;
146
+ recoveryPhrase?: string;
147
+ identityName: string;
148
+ identityConnectedDid?: string;
149
+ emitIdentityAdded?: boolean;
150
+ extraStorageKeys?: Record<string, string>;
151
+ }): Promise<AuthSession>;
152
+ //# sourceMappingURL=lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../src/connect/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAgB,mBAAmB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEjG,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAKrD;;;;;;;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iBAAiB,CAAC,EAAE,MAAM,GACzB;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,CAMA;AAID;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE;IAC5C,SAAS,EAAE,cAAc,CAAC;IAC1B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,OAAO,EAAE,cAAc,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3C,GAAG,OAAO,CAAC,WAAW,CAAC,CA+CvB"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Local DID connect flow.
3
+ *
4
+ * Creates or reconnects a local identity with vault-protected keys.
5
+ * This replaces the "Mode D/E" paths in Enbox.connect().
6
+ * @module
7
+ */
8
+ import type { AuthSession } from '../identity-session.js';
9
+ import type { FlowContext } from './lifecycle.js';
10
+ import type { LocalConnectOptions } from '../types.js';
11
+ /**
12
+ * Execute the local connect flow.
13
+ *
14
+ * - On first launch: initializes the vault, creates a new DID, returns recovery phrase.
15
+ * - On subsequent launches: unlocks the vault and reconnects to the existing identity.
16
+ */
17
+ export declare function localConnect(ctx: FlowContext, options?: LocalConnectOptions): Promise<AuthSession>;
18
+ //# sourceMappingURL=local.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../../src/connect/local.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAOvD;;;;;GAKG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,WAAW,EAChB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,WAAW,CAAC,CA0EtB"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Session restore flow.
3
+ *
4
+ * Restores a previously established session from persisted storage,
5
+ * replacing the "previouslyConnected" pattern in apps.
6
+ * @module
7
+ */
8
+ import type { AuthSession } from '../identity-session.js';
9
+ import type { FlowContext } from './lifecycle.js';
10
+ import type { RestoreSessionOptions } from '../types.js';
11
+ /**
12
+ * Attempt to restore a previous session.
13
+ *
14
+ * Returns `undefined` if no previous session exists.
15
+ * Returns an `AuthSession` if the session was successfully restored.
16
+ */
17
+ export declare function restoreSession(ctx: FlowContext, options?: RestoreSessionOptions): Promise<AuthSession | undefined>;
18
+ //# sourceMappingURL=restore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restore.d.ts","sourceRoot":"","sources":["../../../src/connect/restore.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAMzD;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,WAAW,EAChB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CA2FlC"}
@@ -7,18 +7,9 @@
7
7
  * @module
8
8
  */
9
9
  import type { DwnDataEncodedRecordsWriteMessage, EnboxUserAgent } from '@enbox/agent';
10
- import type { AuthEventEmitter } from '../events.js';
11
- import { AuthSession } from '../identity-session.js';
12
- import type { RegistrationOptions, StorageAdapter, SyncOption, WalletConnectOptions } from '../types.js';
13
- /** @internal */
14
- export interface WalletConnectContext {
15
- userAgent: EnboxUserAgent;
16
- emitter: AuthEventEmitter;
17
- storage: StorageAdapter;
18
- defaultSync?: SyncOption;
19
- defaultDwnEndpoints?: string[];
20
- registration?: RegistrationOptions;
21
- }
10
+ import type { AuthSession } from '../identity-session.js';
11
+ import type { FlowContext } from './lifecycle.js';
12
+ import type { WalletConnectOptions } from '../types.js';
22
13
  /**
23
14
  * Process connected grants by storing them in the local DWN as the owner.
24
15
  *
@@ -40,5 +31,5 @@ export declare function processConnectedGrants(params: {
40
31
  * 2. Imports the delegate DID and processes grants.
41
32
  * 3. Sets up sync and returns an AuthSession.
42
33
  */
43
- export declare function walletConnect(ctx: WalletConnectContext, options: WalletConnectOptions): Promise<AuthSession>;
44
- //# sourceMappingURL=wallet-connect.d.ts.map
34
+ export declare function walletConnect(ctx: FlowContext, options: WalletConnectOptions): Promise<AuthSession>;
35
+ //# sourceMappingURL=wallet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../src/connect/wallet.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,iCAAiC,EAAyD,cAAc,EAAE,MAAM,cAAc,CAAC;AAE7I,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AASxD;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAAC,MAAM,EAAE;IACnD,KAAK,EAAE,cAAc,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,iCAAiC,EAAE,CAAC;CAC7C,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAmCpB;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,WAAW,CAAC,CA8HtB"}
@@ -25,8 +25,8 @@
25
25
  * @module
26
26
  */
27
27
  import type { EnboxUserAgent } from '@enbox/agent';
28
- import type { AuthEventEmitter } from '../events.js';
29
- import type { StorageAdapter } from '../types.js';
28
+ import type { AuthEventEmitter } from './events.js';
29
+ import type { StorageAdapter } from './types.js';
30
30
  /**
31
31
  * Check the current page URL for a `DwnDiscoveryPayload` in the fragment.
32
32
  *
@@ -141,4 +141,4 @@ export declare function applyLocalDwnDiscovery(agent: EnboxUserAgent, storage: S
141
141
  * ```
142
142
  */
143
143
  export declare function requestLocalDwnDiscovery(callbackUrl?: string): boolean;
144
- //# sourceMappingURL=dwn-discovery.d.ts.map
144
+ //# sourceMappingURL=discovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAKnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAIjD;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,IAAI,MAAM,GAAG,SAAS,CAkBnE;AA4BD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAwB7B;AAID;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,OAAO,CAAC,CAclB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,OAAO,CAAC,CA2BlB;AAID;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAuBtE"}
@@ -35,14 +35,15 @@
35
35
  */
36
36
  export { AuthManager } from './auth-manager.js';
37
37
  export { AuthSession } from './identity-session.js';
38
- export { VaultManager } from './vault/vault-manager.js';
39
38
  export { AuthEventEmitter } from './events.js';
40
39
  export { PasswordProvider } from './password-provider.js';
41
40
  export type { PasswordContext } from './password-provider.js';
42
41
  export { EnboxUserAgent, HdIdentityVault } from '@enbox/agent';
43
- export { processConnectedGrants } from './flows/wallet-connect.js';
44
- export { loadTokensFromStorage, saveTokensToStorage } from './flows/dwn-registration.js';
45
- export { applyLocalDwnDiscovery, checkUrlForDwnDiscoveryPayload, clearLocalDwnEndpoint, discoverLocalDwn, persistLocalDwnEndpoint, requestLocalDwnDiscovery, restoreLocalDwnEndpoint, } from './flows/dwn-discovery.js';
42
+ export { processConnectedGrants } from './connect/wallet.js';
43
+ export { WalletConnect } from './wallet-connect-client.js';
44
+ export type { Permission, ProtocolPermissionOptions, WalletConnectClientOptions } from './wallet-connect-client.js';
45
+ export { loadTokensFromStorage, saveTokensToStorage } from './registration.js';
46
+ export { applyLocalDwnDiscovery, checkUrlForDwnDiscoveryPayload, clearLocalDwnEndpoint, discoverLocalDwn, persistLocalDwnEndpoint, requestLocalDwnDiscovery, restoreLocalDwnEndpoint, } from './discovery.js';
46
47
  export { BrowserStorage, LevelStorage, MemoryStorage, createDefaultStorage } from './storage/storage.js';
47
48
  export type { AuthEvent, AuthEventHandler, AuthEventMap, AuthManagerOptions, AuthSessionInfo, AuthState, ConnectPermissionRequest, DisconnectOptions, HeadlessConnectOptions, IdentityInfo, IdentityVaultBackup, ImportFromPhraseOptions, ImportFromPortableOptions, LocalConnectOptions, LocalDwnStrategy, PortableIdentity, ProviderAuthParams, ProviderAuthResult, RegistrationOptions, RegistrationTokenData, RestoreSessionOptions, ShutdownOptions, StorageAdapter, SyncOption, WalletConnectOptions, } from './types.js';
48
49
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAI9D,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAGnE,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAGzF,OAAO,EACL,sBAAsB,EACtB,8BAA8B,EAC9B,qBAAqB,EACrB,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAA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