@enbox/auth 0.6.0 → 0.6.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/esm/auth-manager.js +147 -5
- package/dist/esm/auth-manager.js.map +1 -1
- package/dist/esm/connect/lifecycle.js +145 -2
- package/dist/esm/connect/lifecycle.js.map +1 -1
- package/dist/esm/connect/local.js +19 -5
- package/dist/esm/connect/local.js.map +1 -1
- package/dist/esm/connect/restore.js +22 -8
- package/dist/esm/connect/restore.js.map +1 -1
- package/dist/esm/connect/wallet.js +24 -137
- package/dist/esm/connect/wallet.js.map +1 -1
- package/dist/esm/index.js +9 -15
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/permissions.js +41 -0
- package/dist/esm/permissions.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/wallet-connect-client.js.map +1 -1
- package/dist/types/auth-manager.d.ts +70 -6
- package/dist/types/auth-manager.d.ts.map +1 -1
- package/dist/types/connect/lifecycle.d.ts +49 -2
- package/dist/types/connect/lifecycle.d.ts.map +1 -1
- package/dist/types/connect/local.d.ts +6 -1
- package/dist/types/connect/local.d.ts.map +1 -1
- package/dist/types/connect/restore.d.ts.map +1 -1
- package/dist/types/connect/wallet.d.ts +1 -15
- package/dist/types/connect/wallet.d.ts.map +1 -1
- package/dist/types/index.d.ts +10 -16
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/permissions.d.ts +18 -0
- package/dist/types/permissions.d.ts.map +1 -0
- package/dist/types/types.d.ts +148 -1
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/wallet-connect-client.d.ts +1 -4
- package/dist/types/wallet-connect-client.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/auth-manager.ts +167 -6
- package/src/connect/lifecycle.ts +170 -4
- package/src/connect/local.ts +20 -5
- package/src/connect/restore.ts +25 -9
- package/src/connect/wallet.ts +26 -146
- package/src/index.ts +16 -16
- package/src/permissions.ts +48 -0
- package/src/types.ts +164 -1
- package/src/wallet-connect-client.ts +1 -4
|
@@ -15,62 +15,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
15
15
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
16
16
|
});
|
|
17
17
|
};
|
|
18
|
-
|
|
19
|
-
var t = {};
|
|
20
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
21
|
-
t[p] = s[p];
|
|
22
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
23
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
24
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
25
|
-
t[p[i]] = s[p[i]];
|
|
26
|
-
}
|
|
27
|
-
return t;
|
|
28
|
-
};
|
|
29
|
-
import { Convert } from '@enbox/common';
|
|
18
|
+
import { DEFAULT_DWN_ENDPOINTS } from '../types.js';
|
|
30
19
|
import { registerWithDwnEndpoints } from '../registration.js';
|
|
31
20
|
import { WalletConnect } from '../wallet-connect-client.js';
|
|
32
|
-
import {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Process connected grants by storing them in the local DWN as the owner.
|
|
37
|
-
*
|
|
38
|
-
* This is the agent-level equivalent of `Enbox.processConnectedGrants()`.
|
|
39
|
-
* It stores each grant, signed as owner, and returns the deduplicated
|
|
40
|
-
* list of protocol URIs represented by the grants.
|
|
41
|
-
*
|
|
42
|
-
* @internal
|
|
43
|
-
*/
|
|
44
|
-
export function processConnectedGrants(params) {
|
|
45
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
const { agent, delegateDid, grants } = params;
|
|
47
|
-
const connectedProtocols = new Set();
|
|
48
|
-
for (const grantMessage of grants) {
|
|
49
|
-
const grant = DwnPermissionGrant.parse(grantMessage);
|
|
50
|
-
// Store the grant as the owner of the DWN so the delegateDid
|
|
51
|
-
// can use it when impersonating the connectedDid.
|
|
52
|
-
const { encodedData } = grantMessage, rawMessage = __rest(grantMessage, ["encodedData"]);
|
|
53
|
-
const dataStream = new Blob([Convert.base64Url(encodedData).toUint8Array()]);
|
|
54
|
-
const { reply } = yield agent.processDwnRequest({
|
|
55
|
-
store: true,
|
|
56
|
-
author: delegateDid,
|
|
57
|
-
target: delegateDid,
|
|
58
|
-
messageType: DwnInterface.RecordsWrite,
|
|
59
|
-
signAsOwner: true,
|
|
60
|
-
rawMessage,
|
|
61
|
-
dataStream,
|
|
62
|
-
});
|
|
63
|
-
if (reply.status.code !== 202) {
|
|
64
|
-
throw new Error(`[@enbox/auth] Failed to process connected grant: ${reply.status.detail}`);
|
|
65
|
-
}
|
|
66
|
-
const protocol = grant.scope.protocol;
|
|
67
|
-
if (protocol) {
|
|
68
|
-
connectedProtocols.add(protocol);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return [...connectedProtocols];
|
|
72
|
-
});
|
|
73
|
-
}
|
|
21
|
+
import { ensureVaultReady, finalizeDelegateSession, importDelegateAndSetupSync, resolvePassword } from './lifecycle.js';
|
|
22
|
+
// Re-export for backward compatibility — processConnectedGrants moved to lifecycle.ts.
|
|
23
|
+
export { processConnectedGrants } from './lifecycle.js';
|
|
74
24
|
/**
|
|
75
25
|
* Execute the wallet connect flow.
|
|
76
26
|
*
|
|
@@ -90,14 +40,8 @@ export function walletConnect(ctx, options) {
|
|
|
90
40
|
// Ensure the agent is initialized and started before the relay flow.
|
|
91
41
|
const isFirstLaunch = yield userAgent.firstLaunch();
|
|
92
42
|
const password = yield resolvePassword(ctx, undefined, isFirstLaunch);
|
|
93
|
-
yield ensureVaultReady({
|
|
94
|
-
userAgent,
|
|
95
|
-
emitter,
|
|
96
|
-
password,
|
|
97
|
-
isFirstLaunch,
|
|
98
|
-
});
|
|
43
|
+
yield ensureVaultReady({ userAgent, emitter, password, isFirstLaunch });
|
|
99
44
|
// Run the Enbox Connect relay flow.
|
|
100
|
-
// permissionRequests are already agent-level ConnectPermissionRequest objects.
|
|
101
45
|
const result = yield WalletConnect.initClient({
|
|
102
46
|
displayName: options.displayName,
|
|
103
47
|
connectServerUrl: options.connectServerUrl,
|
|
@@ -109,84 +53,27 @@ export function walletConnect(ctx, options) {
|
|
|
109
53
|
if (!result) {
|
|
110
54
|
throw new Error('[@enbox/auth] Wallet connect flow was cancelled or returned no result.');
|
|
111
55
|
}
|
|
56
|
+
// Import delegate DID, process grants, and set up sync.
|
|
112
57
|
const { delegatePortableDid, connectedDid, delegateGrants } = result;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
});
|
|
127
|
-
// Process the connected grants using agent primitives.
|
|
128
|
-
const connectedProtocols = yield processConnectedGrants({
|
|
129
|
-
agent: userAgent,
|
|
130
|
-
delegateDid: delegatePortableDid.uri,
|
|
131
|
-
grants: delegateGrants,
|
|
132
|
-
});
|
|
133
|
-
// Register with DWN endpoints (if registration options are provided).
|
|
134
|
-
if (ctx.registration) {
|
|
135
|
-
const dwnEndpoints = (_c = ctx.defaultDwnEndpoints) !== null && _c !== void 0 ? _c : DEFAULT_DWN_ENDPOINTS;
|
|
136
|
-
yield registerWithDwnEndpoints({
|
|
137
|
-
userAgent: userAgent,
|
|
138
|
-
dwnEndpoints,
|
|
139
|
-
agentDid: userAgent.agentDid.uri,
|
|
140
|
-
connectedDid,
|
|
141
|
-
storage: storage,
|
|
142
|
-
}, ctx.registration);
|
|
143
|
-
}
|
|
144
|
-
// Register sync for the connected identity.
|
|
145
|
-
yield userAgent.sync.registerIdentity({
|
|
146
|
-
did: connectedDid,
|
|
147
|
-
options: {
|
|
148
|
-
delegateDid: delegatePortableDid.uri,
|
|
149
|
-
protocols: connectedProtocols,
|
|
150
|
-
},
|
|
151
|
-
});
|
|
152
|
-
// Pull down existing messages from the connected DID's DWN.
|
|
153
|
-
yield userAgent.sync.sync('pull');
|
|
154
|
-
}
|
|
155
|
-
catch (error) {
|
|
156
|
-
// Clean up on failure.
|
|
157
|
-
if (identity) {
|
|
158
|
-
try {
|
|
159
|
-
yield userAgent.did.delete({
|
|
160
|
-
didUri: identity.did.uri,
|
|
161
|
-
tenant: identity.metadata.tenant,
|
|
162
|
-
deleteKey: true,
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
catch ( /* best effort */_d) { /* best effort */ }
|
|
166
|
-
try {
|
|
167
|
-
yield userAgent.identity.delete({ didUri: identity.did.uri });
|
|
168
|
-
}
|
|
169
|
-
catch ( /* best effort */_e) { /* best effort */ }
|
|
170
|
-
}
|
|
171
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
172
|
-
throw new Error(`[@enbox/auth] Wallet connect failed: ${message}`);
|
|
58
|
+
const identity = yield importDelegateAndSetupSync({
|
|
59
|
+
userAgent, delegatePortableDid, connectedDid, delegateGrants,
|
|
60
|
+
flowName: 'Wallet connect',
|
|
61
|
+
});
|
|
62
|
+
// Register with DWN endpoints (if registration options are provided).
|
|
63
|
+
if (ctx.registration) {
|
|
64
|
+
const dwnEndpoints = (_c = ctx.defaultDwnEndpoints) !== null && _c !== void 0 ? _c : DEFAULT_DWN_ENDPOINTS;
|
|
65
|
+
yield registerWithDwnEndpoints({
|
|
66
|
+
userAgent,
|
|
67
|
+
dwnEndpoints,
|
|
68
|
+
agentDid: userAgent.agentDid.uri,
|
|
69
|
+
connectedDid,
|
|
70
|
+
storage,
|
|
71
|
+
}, ctx.registration);
|
|
173
72
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
return finalizeSession({
|
|
179
|
-
userAgent,
|
|
180
|
-
emitter,
|
|
181
|
-
storage,
|
|
182
|
-
connectedDid,
|
|
183
|
-
delegateDid,
|
|
184
|
-
identityName: identity.metadata.name,
|
|
185
|
-
identityConnectedDid: identity.metadata.connectedDid,
|
|
186
|
-
extraStorageKeys: {
|
|
187
|
-
[STORAGE_KEYS.DELEGATE_DID]: delegateDid,
|
|
188
|
-
[STORAGE_KEYS.CONNECTED_DID]: connectedDid,
|
|
189
|
-
},
|
|
73
|
+
// Finalize session.
|
|
74
|
+
return finalizeDelegateSession({
|
|
75
|
+
userAgent, emitter, storage, identity,
|
|
76
|
+
connectedDid, delegateDid: delegatePortableDid.uri, sync,
|
|
190
77
|
});
|
|
191
78
|
});
|
|
192
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../../src/connect/wallet.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../../src/connect/wallet.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;;;;;;;;;;AAMH,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAExH,uFAAuF;AACvF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,UAAgB,aAAa,CACjC,GAAgB,EAChB,OAA6B;;;QAE7B,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC;QAC5C,MAAM,IAAI,GAAG,MAAA,OAAO,CAAC,IAAI,mCAAI,GAAG,CAAC,WAAW,CAAC;QAE7C,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CACb,gEAAgE;gBAChE,mDAAmD,CACp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AAY,CACjB,CAAC;QACJ,CAAC;QAED,oBAAoB;QACpB,OAAO,uBAAuB,CAAC;YAC7B,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ;YACrC,YAAY,EAAE,WAAW,EAAE,mBAAmB,CAAC,GAAG,EAAE,IAAI;SACzD,CAAC,CAAC;IACL,CAAC;CAAA"}
|
package/dist/esm/index.js
CHANGED
|
@@ -5,30 +5,23 @@
|
|
|
5
5
|
* in both browser and CLI environments. Depends only on `@enbox/agent`
|
|
6
6
|
* and can be used standalone or consumed by `@enbox/api`.
|
|
7
7
|
*
|
|
8
|
-
* @example Standalone auth
|
|
8
|
+
* @example Standalone auth (wallet app)
|
|
9
9
|
* ```ts
|
|
10
10
|
* import { AuthManager } from '@enbox/auth';
|
|
11
11
|
*
|
|
12
12
|
* const auth = await AuthManager.create({ sync: '15s' });
|
|
13
|
-
* const session = await auth.
|
|
14
|
-
*
|
|
15
|
-
* // session.agent — the authenticated Enbox agent
|
|
16
|
-
* // session.did — the connected DID URI
|
|
13
|
+
* const session = await auth.connectLocal({ password: userPin });
|
|
17
14
|
* ```
|
|
18
15
|
*
|
|
19
|
-
* @example
|
|
16
|
+
* @example Dapp with browser connect handler
|
|
20
17
|
* ```ts
|
|
21
18
|
* import { AuthManager } from '@enbox/auth';
|
|
22
|
-
* import {
|
|
23
|
-
*
|
|
24
|
-
* const auth = await AuthManager.create({ sync: '15s' });
|
|
25
|
-
* const session = await auth.connect();
|
|
19
|
+
* import { BrowserConnectHandler } from '@enbox/browser';
|
|
26
20
|
*
|
|
27
|
-
* const
|
|
28
|
-
*
|
|
29
|
-
* connectedDid: session.did,
|
|
30
|
-
* delegateDid: session.delegateDid,
|
|
21
|
+
* const auth = await AuthManager.create({
|
|
22
|
+
* connectHandler: BrowserConnectHandler(),
|
|
31
23
|
* });
|
|
24
|
+
* const session = await auth.connect({ protocols: [NotesProtocol] });
|
|
32
25
|
* ```
|
|
33
26
|
*
|
|
34
27
|
* @packageDocumentation
|
|
@@ -42,8 +35,9 @@ export { PasswordProvider } from './password-provider.js';
|
|
|
42
35
|
// Re-export agent classes so consumers can construct custom agents/vaults
|
|
43
36
|
// without a direct @enbox/agent dependency.
|
|
44
37
|
export { EnboxUserAgent, HdIdentityVault } from '@enbox/agent';
|
|
45
|
-
//
|
|
38
|
+
// Connect helpers
|
|
46
39
|
export { processConnectedGrants } from './connect/wallet.js';
|
|
40
|
+
export { normalizeProtocolRequests } from './permissions.js';
|
|
47
41
|
export { WalletConnect } from './wallet-connect-client.js';
|
|
48
42
|
// Registration token storage helpers
|
|
49
43
|
export { loadTokensFromStorage, saveTokensToStorage } from './registration.js';
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,qBAAqB;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,0EAA0E;AAC1E,4CAA4C;AAC5C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/D,kBAAkB;AAClB,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,qCAAqC;AACrC,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE/E,4DAA4D;AAC5D,OAAO,EACL,sBAAsB,EACtB,8BAA8B,EAC9B,qBAAqB,EACrB,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AAExB,mBAAmB;AACnB,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Permission request normalization utilities.
|
|
3
|
+
*
|
|
4
|
+
* Converts simplified `ProtocolRequest` entries (just a protocol definition
|
|
5
|
+
* or `{ definition, permissions }`) into agent-level `ConnectPermissionRequest`
|
|
6
|
+
* objects used by connect handlers.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
import { DEFAULT_PERMISSIONS } from './types.js';
|
|
12
|
+
import { WalletConnect } from './wallet-connect-client.js';
|
|
13
|
+
/**
|
|
14
|
+
* Normalize simplified `ProtocolRequest[]` into agent-level
|
|
15
|
+
* `ConnectPermissionRequest[]`.
|
|
16
|
+
*/
|
|
17
|
+
export function normalizeProtocolRequests(protocols) {
|
|
18
|
+
if (!protocols || protocols.length === 0) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
return protocols.map((entry) => {
|
|
22
|
+
let definition;
|
|
23
|
+
let permissions;
|
|
24
|
+
if ('protocol' in entry && 'types' in entry && 'structure' in entry) {
|
|
25
|
+
// Bare protocol definition — use default permissions.
|
|
26
|
+
definition = entry;
|
|
27
|
+
permissions = [...DEFAULT_PERMISSIONS];
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
// Object with explicit permissions.
|
|
31
|
+
const explicit = entry;
|
|
32
|
+
definition = explicit.definition;
|
|
33
|
+
permissions = explicit.permissions;
|
|
34
|
+
}
|
|
35
|
+
return WalletConnect.createPermissionRequestForProtocol({
|
|
36
|
+
definition,
|
|
37
|
+
permissions: permissions,
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=permissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../src/permissions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CACvC,SAAwC;IAExC,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAAC,OAAO,EAAE,CAAC;IAAC,CAAC;IAExD,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC7B,IAAI,UAAiC,CAAC;QACtC,IAAI,WAAqB,CAAC;QAE1B,IAAI,UAAU,IAAI,KAAK,IAAI,OAAO,IAAI,KAAK,IAAI,WAAW,IAAI,KAAK,EAAE,CAAC;YACpE,sDAAsD;YACtD,UAAU,GAAG,KAA8B,CAAC;YAC5C,WAAW,GAAG,CAAC,GAAG,mBAAmB,CAAC,CAAC;QACzC,CAAC;aAAM,CAAC;YACN,oCAAoC;YACpC,MAAM,QAAQ,GAAG,KAAqE,CAAC;YACvF,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;YACjC,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC;QACrC,CAAC;QAED,OAAO,aAAa,CAAC,kCAAkC,CAAC;YACtD,UAAU;YACV,WAAW,EAAE,WAAoG;SAClH,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/esm/types.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* @module @enbox/auth
|
|
3
3
|
* Public types for the authentication and identity management SDK.
|
|
4
4
|
*/
|
|
5
|
+
/** Default permissions granted when only a protocol definition is provided. */
|
|
6
|
+
export const DEFAULT_PERMISSIONS = ['read', 'write', 'query', 'subscribe'];
|
|
5
7
|
// ─── Internal helpers ────────────────────────────────────────────
|
|
6
8
|
/** The insecure default password used when none is provided. */
|
|
7
9
|
export const INSECURE_DEFAULT_PASSWORD = 'insecure-static-phrase';
|
package/dist/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAqaH,+EAA+E;AAC/E,MAAM,CAAC,MAAM,mBAAmB,GAAiB,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;AAwMzF,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"}
|
|
@@ -1 +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,EAA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AAQ;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"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module
|
|
7
7
|
*/
|
|
8
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';
|
|
9
|
+
import type { AuthEvent, AuthEventHandler, AuthManagerOptions, AuthState, ConnectOptions, DisconnectOptions, HeadlessConnectOptions, IdentityInfo, ImportFromPhraseOptions, ImportFromPortableOptions, LocalConnectOptions, RestoreSessionOptions, ShutdownOptions, WalletConnectOptions } from './types.js';
|
|
10
10
|
import { EnboxUserAgent } from '@enbox/agent';
|
|
11
11
|
import { AuthSession } from './identity-session.js';
|
|
12
12
|
/**
|
|
@@ -55,6 +55,7 @@ export declare class AuthManager {
|
|
|
55
55
|
private _defaultSync?;
|
|
56
56
|
private _defaultDwnEndpoints?;
|
|
57
57
|
private _registration?;
|
|
58
|
+
private _connectHandler?;
|
|
58
59
|
/**
|
|
59
60
|
* The local DWN server endpoint discovered during `create()`, if any.
|
|
60
61
|
* `undefined` means no local server was found. This is set before any
|
|
@@ -75,16 +76,60 @@ export declare class AuthManager {
|
|
|
75
76
|
*/
|
|
76
77
|
static create(options?: AuthManagerOptions): Promise<AuthManager>;
|
|
77
78
|
/**
|
|
78
|
-
*
|
|
79
|
+
* Connect to a wallet or create a local session.
|
|
79
80
|
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
81
|
+
* This is the primary entry point for dapps. It routes to the
|
|
82
|
+
* appropriate flow based on the options:
|
|
82
83
|
*
|
|
83
|
-
*
|
|
84
|
+
* **Handler-based connect** (dapps): Delegates credential acquisition
|
|
85
|
+
* to a {@link ConnectHandler}. Triggered when `protocols` or
|
|
86
|
+
* `connectHandler` is provided.
|
|
87
|
+
*
|
|
88
|
+
* **Local connect** (wallets / CLI): Creates or unlocks a local vault.
|
|
89
|
+
* Triggered when `password`, `createIdentity`, or `recoveryPhrase`
|
|
90
|
+
* is provided.
|
|
91
|
+
*
|
|
92
|
+
* In both cases, `connect()` first attempts to restore a previous
|
|
93
|
+
* session. If a valid session exists, it is returned immediately
|
|
94
|
+
* without any user interaction.
|
|
95
|
+
*
|
|
96
|
+
* @example Dapp (browser)
|
|
97
|
+
* ```ts
|
|
98
|
+
* import { BrowserConnectHandler } from '@enbox/browser';
|
|
99
|
+
*
|
|
100
|
+
* const auth = await AuthManager.create({
|
|
101
|
+
* connectHandler: BrowserConnectHandler(),
|
|
102
|
+
* });
|
|
103
|
+
* const session = await auth.connect({
|
|
104
|
+
* protocols: [NotesProtocol],
|
|
105
|
+
* });
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* @example Wallet / CLI
|
|
109
|
+
* ```ts
|
|
110
|
+
* const session = await auth.connect({
|
|
111
|
+
* password: userPin,
|
|
112
|
+
* createIdentity: true,
|
|
113
|
+
* });
|
|
114
|
+
* ```
|
|
115
|
+
*
|
|
116
|
+
* @param options - Connection options. The shape determines the flow.
|
|
117
|
+
* @returns An active AuthSession.
|
|
118
|
+
* @throws If a connection attempt is already in progress.
|
|
119
|
+
* @throws If handler-based connect is attempted without a handler.
|
|
120
|
+
*/
|
|
121
|
+
connect(options?: ConnectOptions): Promise<AuthSession>;
|
|
122
|
+
/**
|
|
123
|
+
* Create or reconnect a local identity (explicit local connect).
|
|
124
|
+
*
|
|
125
|
+
* Use this when you explicitly want the local vault flow, bypassing
|
|
126
|
+
* auto-detection. This is the preferred method for wallet apps.
|
|
127
|
+
*
|
|
128
|
+
* @param options - Local connect options.
|
|
84
129
|
* @returns An active AuthSession.
|
|
85
130
|
* @throws If a connection attempt is already in progress.
|
|
86
131
|
*/
|
|
87
|
-
|
|
132
|
+
connectLocal(options?: LocalConnectOptions): Promise<AuthSession>;
|
|
88
133
|
/**
|
|
89
134
|
* Connect to an external wallet via the Enbox Connect relay protocol.
|
|
90
135
|
*
|
|
@@ -249,6 +294,25 @@ export declare class AuthManager {
|
|
|
249
294
|
* before any event listeners are attached.
|
|
250
295
|
*/
|
|
251
296
|
get localDwnEndpoint(): string | undefined;
|
|
297
|
+
/**
|
|
298
|
+
* Determine whether the given options indicate a local connect flow.
|
|
299
|
+
*
|
|
300
|
+
* Local connect is indicated by the presence of `password`,
|
|
301
|
+
* `createIdentity`, or `recoveryPhrase` — signals that the caller
|
|
302
|
+
* is managing its own vault/identity lifecycle. In non-browser
|
|
303
|
+
* environments, local connect is the fallback.
|
|
304
|
+
*/
|
|
305
|
+
private _isLocalConnect;
|
|
306
|
+
/**
|
|
307
|
+
* Run a handler-based (delegated) connect flow.
|
|
308
|
+
*
|
|
309
|
+
* 1. Initialize the vault (agent-only, no identity).
|
|
310
|
+
* 2. Normalize protocol permission requests.
|
|
311
|
+
* 3. Delegate to the connect handler for credential acquisition.
|
|
312
|
+
* 4. Import the delegate DID, process grants, set up sync.
|
|
313
|
+
* 5. Finalize and return the AuthSession.
|
|
314
|
+
*/
|
|
315
|
+
private _handlerConnect;
|
|
252
316
|
/**
|
|
253
317
|
* Build a `FlowContext` from the manager's current state.
|
|
254
318
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-manager.d.ts","sourceRoot":"","sources":["../../src/auth-manager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAkB,eAAe,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAItF,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,
|
|
1
|
+
{"version":3,"file":"auth-manager.d.ts","sourceRoot":"","sources":["../../src/auth-manager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAkB,eAAe,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAItF,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,EAET,cAAc,EACd,iBAAiB,EAEjB,sBAAsB,EACtB,YAAY,EACZ,uBAAuB,EACvB,yBAAyB,EACzB,mBAAmB,EAEnB,qBAAqB,EACrB,eAAe,EAGf,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAWpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,UAAU,CAAiB;IACnC,OAAO,CAAC,QAAQ,CAAmB;IACnC,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,QAAQ,CAA0B;IAC1C,OAAO,CAAC,MAAM,CAA8B;IAC5C,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D7B;;;;;;OAMG;IACH,OAAO,CAAC,YAAY;IAapB;;;;;;OAMG;YACW,YAAY;IAc1B,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,iBAAiB;CAQ1B"}
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
* @module
|
|
14
14
|
* @internal
|
|
15
15
|
*/
|
|
16
|
-
import type {
|
|
16
|
+
import type { PortableDid } from '@enbox/dids';
|
|
17
|
+
import type { BearerIdentity, DwnDataEncodedRecordsWriteMessage, EnboxUserAgent } from '@enbox/agent';
|
|
17
18
|
import type { AuthEventEmitter } from '../events.js';
|
|
18
19
|
import type { PasswordProvider } from '../password-provider.js';
|
|
19
20
|
import type { RegistrationOptions, StorageAdapter, SyncOption } from '../types.js';
|
|
@@ -118,6 +119,52 @@ export declare function resolveIdentityDids(identity: BearerIdentity, storedDele
|
|
|
118
119
|
connectedDid: string;
|
|
119
120
|
delegateDid: string | undefined;
|
|
120
121
|
};
|
|
122
|
+
/**
|
|
123
|
+
* Process connected grants by storing them in the local DWN as the owner.
|
|
124
|
+
*
|
|
125
|
+
* This is the agent-level equivalent of `Enbox.processConnectedGrants()`.
|
|
126
|
+
* It stores each grant, signed as owner, and returns the deduplicated
|
|
127
|
+
* list of protocol URIs represented by the grants.
|
|
128
|
+
*
|
|
129
|
+
* @internal
|
|
130
|
+
*/
|
|
131
|
+
export declare function processConnectedGrants(params: {
|
|
132
|
+
agent: EnboxUserAgent;
|
|
133
|
+
delegateDid: string;
|
|
134
|
+
grants: DwnDataEncodedRecordsWriteMessage[];
|
|
135
|
+
}): Promise<string[]>;
|
|
136
|
+
/**
|
|
137
|
+
* Import a delegated DID, process its grants, register sync, and pull.
|
|
138
|
+
*
|
|
139
|
+
* This is the shared post-connect lifecycle used by both the DWeb Connect
|
|
140
|
+
* and relay WalletConnect flows. On failure, the imported identity is
|
|
141
|
+
* cleaned up before re-throwing.
|
|
142
|
+
*
|
|
143
|
+
* @internal
|
|
144
|
+
*/
|
|
145
|
+
export declare function importDelegateAndSetupSync(params: {
|
|
146
|
+
userAgent: EnboxUserAgent;
|
|
147
|
+
delegatePortableDid: PortableDid;
|
|
148
|
+
connectedDid: string;
|
|
149
|
+
delegateGrants: DwnDataEncodedRecordsWriteMessage[];
|
|
150
|
+
flowName: string;
|
|
151
|
+
}): Promise<BearerIdentity>;
|
|
152
|
+
/**
|
|
153
|
+
* Build an `AuthSession` for a delegated connect flow (DWeb Connect or
|
|
154
|
+
* relay WalletConnect). Starts sync and persists delegate/connected DID
|
|
155
|
+
* markers.
|
|
156
|
+
*
|
|
157
|
+
* @internal
|
|
158
|
+
*/
|
|
159
|
+
export declare function finalizeDelegateSession(params: {
|
|
160
|
+
userAgent: EnboxUserAgent;
|
|
161
|
+
emitter: AuthEventEmitter;
|
|
162
|
+
storage: StorageAdapter;
|
|
163
|
+
identity: BearerIdentity;
|
|
164
|
+
connectedDid: string;
|
|
165
|
+
delegateDid: string;
|
|
166
|
+
sync: SyncOption | undefined;
|
|
167
|
+
}): Promise<AuthSession>;
|
|
121
168
|
/**
|
|
122
169
|
* Persist session markers, build an `AuthSession`, and emit lifecycle events.
|
|
123
170
|
*
|
|
@@ -144,7 +191,7 @@ export declare function finalizeSession(params: {
|
|
|
144
191
|
connectedDid: string;
|
|
145
192
|
delegateDid?: string;
|
|
146
193
|
recoveryPhrase?: string;
|
|
147
|
-
identityName
|
|
194
|
+
identityName?: string;
|
|
148
195
|
identityConnectedDid?: string;
|
|
149
196
|
emitIdentityAdded?: boolean;
|
|
150
197
|
extraStorageKeys?: Record<string, string>;
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../src/connect/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zB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;CAC9B,GAAG,OAAO,CAAC,WAAW,CAAC,CAkBvB;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,CAAC,EAAE,MAAM,CAAC;IACtB,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,CAiDvB"}
|
|
@@ -11,8 +11,13 @@ import type { LocalConnectOptions } from '../types.js';
|
|
|
11
11
|
/**
|
|
12
12
|
* Execute the local connect flow.
|
|
13
13
|
*
|
|
14
|
-
* - On first launch: initializes the vault
|
|
14
|
+
* - On first launch: initializes the vault. Identity creation is opt-in via
|
|
15
|
+
* `options.createIdentity: true`.
|
|
15
16
|
* - On subsequent launches: unlocks the vault and reconnects to the existing identity.
|
|
17
|
+
*
|
|
18
|
+
* When no identities exist and `createIdentity` is not `true`, the session
|
|
19
|
+
* is returned with the **agent DID** as the connected DID. This allows apps to
|
|
20
|
+
* manage identity creation separately from vault setup.
|
|
16
21
|
*/
|
|
17
22
|
export declare function localConnect(ctx: FlowContext, options?: LocalConnectOptions): Promise<AuthSession>;
|
|
18
23
|
//# sourceMappingURL=local.d.ts.map
|
|
@@ -1 +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
|
|
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;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,WAAW,EAChB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,WAAW,CAAC,CAoFtB"}
|
|
@@ -1 +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,
|
|
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,CA2GlC"}
|
|
@@ -6,24 +6,10 @@
|
|
|
6
6
|
* This replaces the "Mode B/C" paths in Enbox.connect().
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
|
-
import type { DwnDataEncodedRecordsWriteMessage, EnboxUserAgent } from '@enbox/agent';
|
|
10
9
|
import type { AuthSession } from '../identity-session.js';
|
|
11
10
|
import type { FlowContext } from './lifecycle.js';
|
|
12
11
|
import type { WalletConnectOptions } from '../types.js';
|
|
13
|
-
|
|
14
|
-
* Process connected grants by storing them in the local DWN as the owner.
|
|
15
|
-
*
|
|
16
|
-
* This is the agent-level equivalent of `Enbox.processConnectedGrants()`.
|
|
17
|
-
* It stores each grant, signed as owner, and returns the deduplicated
|
|
18
|
-
* list of protocol URIs represented by the grants.
|
|
19
|
-
*
|
|
20
|
-
* @internal
|
|
21
|
-
*/
|
|
22
|
-
export declare function processConnectedGrants(params: {
|
|
23
|
-
agent: EnboxUserAgent;
|
|
24
|
-
delegateDid: string;
|
|
25
|
-
grants: DwnDataEncodedRecordsWriteMessage[];
|
|
26
|
-
}): Promise<string[]>;
|
|
12
|
+
export { processConnectedGrants } from './lifecycle.js';
|
|
27
13
|
/**
|
|
28
14
|
* Execute the wallet connect flow.
|
|
29
15
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../src/connect/wallet.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../src/connect/wallet.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,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;AAQxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAExD;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,WAAW,CAAC,CAyDtB"}
|