@enbox/auth 0.4.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.
- package/dist/esm/auth-manager.js +244 -121
- package/dist/esm/auth-manager.js.map +1 -1
- package/dist/esm/connect/import.js +131 -0
- package/dist/esm/connect/import.js.map +1 -0
- package/dist/esm/connect/lifecycle.js +235 -0
- package/dist/esm/connect/lifecycle.js.map +1 -0
- package/dist/esm/connect/local.js +91 -0
- package/dist/esm/connect/local.js.map +1 -0
- package/dist/esm/{flows/session-restore.js → connect/restore.js} +39 -50
- package/dist/esm/connect/restore.js.map +1 -0
- package/dist/esm/{flows/wallet-connect.js → connect/wallet.js} +33 -39
- package/dist/esm/connect/wallet.js.map +1 -0
- package/dist/esm/{flows/dwn-discovery.js → discovery.js} +98 -83
- package/dist/esm/discovery.js.map +1 -0
- package/dist/esm/index.js +7 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/password-provider.js +319 -0
- package/dist/esm/password-provider.js.map +1 -0
- package/dist/esm/{flows/dwn-registration.js → registration.js} +50 -4
- package/dist/esm/registration.js.map +1 -0
- package/dist/esm/types.js +11 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/wallet-connect-client.js +188 -0
- package/dist/esm/wallet-connect-client.js.map +1 -0
- package/dist/types/auth-manager.d.ts +86 -7
- package/dist/types/auth-manager.d.ts.map +1 -1
- package/dist/types/connect/import.d.ts +25 -0
- package/dist/types/connect/import.d.ts.map +1 -0
- package/dist/types/connect/lifecycle.d.ts +152 -0
- package/dist/types/connect/lifecycle.d.ts.map +1 -0
- package/dist/types/connect/local.d.ts +18 -0
- package/dist/types/connect/local.d.ts.map +1 -0
- package/dist/types/connect/restore.d.ts +18 -0
- package/dist/types/connect/restore.d.ts.map +1 -0
- package/dist/types/{flows/wallet-connect.d.ts → connect/wallet.d.ts} +7 -16
- package/dist/types/connect/wallet.d.ts.map +1 -0
- package/dist/types/{flows/dwn-discovery.d.ts → discovery.d.ts} +43 -56
- package/dist/types/discovery.d.ts.map +1 -0
- package/dist/types/index.d.ts +8 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/password-provider.d.ts +194 -0
- package/dist/types/password-provider.d.ts.map +1 -0
- package/dist/types/{flows/dwn-registration.d.ts → registration.d.ts} +21 -2
- package/dist/types/registration.d.ts.map +1 -0
- package/dist/types/types.d.ts +92 -4
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/wallet-connect-client.d.ts +89 -0
- package/dist/types/wallet-connect-client.d.ts.map +1 -0
- package/package.json +15 -12
- package/src/auth-manager.ts +279 -145
- package/src/connect/import.ts +148 -0
- package/src/connect/lifecycle.ts +321 -0
- package/src/connect/local.ts +101 -0
- package/src/connect/restore.ts +117 -0
- package/src/{flows/wallet-connect.ts → connect/wallet.ts} +42 -58
- package/src/{flows/dwn-discovery.ts → discovery.ts} +103 -82
- package/src/index.ts +14 -4
- package/src/password-provider.ts +383 -0
- package/src/{flows/dwn-registration.ts → registration.ts} +61 -6
- package/src/types.ts +100 -4
- package/src/wallet-connect-client.ts +278 -0
- package/dist/esm/flows/dwn-discovery.js.map +0 -1
- package/dist/esm/flows/dwn-registration.js.map +0 -1
- package/dist/esm/flows/import-identity.js +0 -175
- package/dist/esm/flows/import-identity.js.map +0 -1
- package/dist/esm/flows/local-connect.js +0 -141
- package/dist/esm/flows/local-connect.js.map +0 -1
- package/dist/esm/flows/session-restore.js.map +0 -1
- package/dist/esm/flows/wallet-connect.js.map +0 -1
- package/dist/esm/vault/vault-manager.js +0 -95
- package/dist/esm/vault/vault-manager.js.map +0 -1
- package/dist/types/flows/dwn-discovery.d.ts.map +0 -1
- package/dist/types/flows/dwn-registration.d.ts.map +0 -1
- package/dist/types/flows/import-identity.d.ts +0 -35
- package/dist/types/flows/import-identity.d.ts.map +0 -1
- package/dist/types/flows/local-connect.d.ts +0 -29
- package/dist/types/flows/local-connect.d.ts.map +0 -1
- package/dist/types/flows/session-restore.d.ts +0 -27
- package/dist/types/flows/session-restore.d.ts.map +0 -1
- package/dist/types/flows/wallet-connect.d.ts.map +0 -1
- package/dist/types/vault/vault-manager.d.ts +0 -57
- package/dist/types/vault/vault-manager.d.ts.map +0 -1
- package/src/flows/import-identity.ts +0 -217
- package/src/flows/local-connect.ts +0 -171
- package/src/flows/session-restore.ts +0 -142
- package/src/vault/vault-manager.ts +0 -89
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Wallet connect (
|
|
2
|
+
* Wallet connect (Enbox Connect relay) flow.
|
|
3
3
|
*
|
|
4
|
-
* Connects to an external wallet via the
|
|
4
|
+
* Connects to an external wallet via the Enbox Connect relay protocol,
|
|
5
5
|
* importing a delegated DID with permission grants.
|
|
6
6
|
* This replaces the "Mode B/C" paths in Enbox.connect().
|
|
7
7
|
* @module
|
|
@@ -27,11 +27,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
27
27
|
return t;
|
|
28
28
|
};
|
|
29
29
|
import { Convert } from '@enbox/common';
|
|
30
|
-
import {
|
|
30
|
+
import { registerWithDwnEndpoints } from '../registration.js';
|
|
31
|
+
import { WalletConnect } from '../wallet-connect-client.js';
|
|
32
|
+
import { DEFAULT_DWN_ENDPOINTS, STORAGE_KEYS } from '../types.js';
|
|
31
33
|
import { DwnInterface, DwnPermissionGrant } from '@enbox/agent';
|
|
32
|
-
import {
|
|
33
|
-
import { registerWithDwnEndpoints } from './dwn-registration.js';
|
|
34
|
-
import { STORAGE_KEYS } from '../types.js';
|
|
34
|
+
import { ensureVaultReady, finalizeSession, resolvePassword, startSyncIfEnabled } from './lifecycle.js';
|
|
35
35
|
/**
|
|
36
36
|
* Process connected grants by storing them in the local DWN as the owner.
|
|
37
37
|
*
|
|
@@ -87,12 +87,21 @@ export function walletConnect(ctx, options) {
|
|
|
87
87
|
throw new Error('[@enbox/auth] Sync must be enabled when using wallet connect. ' +
|
|
88
88
|
'Remove sync: "off" or set an interval like "15s".');
|
|
89
89
|
}
|
|
90
|
-
//
|
|
90
|
+
// Ensure the agent is initialized and started before the relay flow.
|
|
91
|
+
const isFirstLaunch = yield userAgent.firstLaunch();
|
|
92
|
+
const password = yield resolvePassword(ctx, undefined, isFirstLaunch);
|
|
93
|
+
yield ensureVaultReady({
|
|
94
|
+
userAgent,
|
|
95
|
+
emitter,
|
|
96
|
+
password,
|
|
97
|
+
isFirstLaunch,
|
|
98
|
+
});
|
|
99
|
+
// Run the Enbox Connect relay flow.
|
|
91
100
|
// permissionRequests are already agent-level ConnectPermissionRequest objects.
|
|
92
101
|
const result = yield WalletConnect.initClient({
|
|
93
102
|
displayName: options.displayName,
|
|
94
103
|
connectServerUrl: options.connectServerUrl,
|
|
95
|
-
walletUri: (_b = options.walletUri) !== null && _b !== void 0 ? _b : '
|
|
104
|
+
walletUri: (_b = options.walletUri) !== null && _b !== void 0 ? _b : 'enbox://connect',
|
|
96
105
|
permissionRequests: options.permissionRequests,
|
|
97
106
|
onWalletUriReady: options.onWalletUriReady,
|
|
98
107
|
validatePin: options.validatePin,
|
|
@@ -123,12 +132,13 @@ export function walletConnect(ctx, options) {
|
|
|
123
132
|
});
|
|
124
133
|
// Register with DWN endpoints (if registration options are provided).
|
|
125
134
|
if (ctx.registration) {
|
|
126
|
-
const dwnEndpoints = (_c = ctx.defaultDwnEndpoints) !== null && _c !== void 0 ? _c :
|
|
135
|
+
const dwnEndpoints = (_c = ctx.defaultDwnEndpoints) !== null && _c !== void 0 ? _c : DEFAULT_DWN_ENDPOINTS;
|
|
127
136
|
yield registerWithDwnEndpoints({
|
|
128
137
|
userAgent: userAgent,
|
|
129
138
|
dwnEndpoints,
|
|
130
139
|
agentDid: userAgent.agentDid.uri,
|
|
131
140
|
connectedDid,
|
|
141
|
+
storage: storage,
|
|
132
142
|
}, ctx.registration);
|
|
133
143
|
}
|
|
134
144
|
// Register sync for the connected identity.
|
|
@@ -161,39 +171,23 @@ export function walletConnect(ctx, options) {
|
|
|
161
171
|
const message = error instanceof Error ? error.message : String(error);
|
|
162
172
|
throw new Error(`[@enbox/auth] Wallet connect failed: ${message}`);
|
|
163
173
|
}
|
|
164
|
-
// Start sync.
|
|
165
|
-
const syncMode = sync === undefined ? 'live' : 'poll';
|
|
166
|
-
const syncInterval = sync !== null && sync !== void 0 ? sync : (syncMode === 'live' ? '5m' : '2m');
|
|
167
|
-
userAgent.sync.startSync({ mode: syncMode, interval: syncInterval })
|
|
168
|
-
.catch((err) => {
|
|
169
|
-
console.error('[@enbox/auth] Sync failed:', err);
|
|
170
|
-
});
|
|
171
174
|
const delegateDid = delegatePortableDid.uri;
|
|
172
|
-
//
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
connectedDid: identity.metadata.connectedDid,
|
|
181
|
-
};
|
|
182
|
-
const session = new AuthSession({
|
|
183
|
-
agent: userAgent,
|
|
184
|
-
did: connectedDid,
|
|
175
|
+
// Start sync.
|
|
176
|
+
startSyncIfEnabled(userAgent, sync);
|
|
177
|
+
// Persist session info, build AuthSession, and emit lifecycle events.
|
|
178
|
+
return finalizeSession({
|
|
179
|
+
userAgent,
|
|
180
|
+
emitter,
|
|
181
|
+
storage,
|
|
182
|
+
connectedDid,
|
|
185
183
|
delegateDid,
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
did: session.did,
|
|
192
|
-
delegateDid,
|
|
193
|
-
identity: identityInfo,
|
|
184
|
+
identityName: identity.metadata.name,
|
|
185
|
+
identityConnectedDid: identity.metadata.connectedDid,
|
|
186
|
+
extraStorageKeys: {
|
|
187
|
+
[STORAGE_KEYS.DELEGATE_DID]: delegateDid,
|
|
188
|
+
[STORAGE_KEYS.CONNECTED_DID]: connectedDid,
|
|
194
189
|
},
|
|
195
190
|
});
|
|
196
|
-
return session;
|
|
197
191
|
});
|
|
198
192
|
}
|
|
199
|
-
//# sourceMappingURL=wallet
|
|
193
|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EAAsE;QACtE,OAAO,eAAe,CAAC;YACrB,SAAS;YACT,OAAO;YACP,OAAO;YACP,YAAY;YACZ,WAAW;YACX,YAAY,EAAW,QAAQ,CAAC,QAAQ,CAAC,IAAI;YAC7C,oBAAoB,EAAG,QAAQ,CAAC,QAAQ,CAAC,YAAY;YACrD,gBAAgB,EAAO;gBACrB,CAAC,YAAY,CAAC,YAAY,CAAC,EAAI,WAAW;gBAC1C,CAAC,YAAY,CAAC,aAAa,CAAC,EAAG,YAAY;aAC5C;SACF,CAAC,CAAC;IACL,CAAC;CAAA"}
|
|
@@ -7,26 +7,21 @@
|
|
|
7
7
|
*
|
|
8
8
|
* ## Discovery channels (browser, highest to lowest priority)
|
|
9
9
|
*
|
|
10
|
-
* 1. **URL fragment payload** — A `dwn://
|
|
10
|
+
* 1. **URL fragment payload** — A `dwn://connect` redirect just landed
|
|
11
11
|
* on the page with the endpoint in `#`. Highest priority because it's
|
|
12
12
|
* fresh and explicit.
|
|
13
13
|
* 2. **Persisted endpoint** (localStorage) — A previously discovered
|
|
14
14
|
* endpoint restored and re-validated via `GET /info`.
|
|
15
|
-
* 3. **Agent-level discovery** (transparent, runs on every `sendRequest`)
|
|
16
|
-
* — `~/.enbox/dwn.json` discovery file (Node/Bun only; skipped in
|
|
17
|
-
* browsers) and sequential port probing on `127.0.0.1:{3000,55500–55509}`.
|
|
18
|
-
* This channel works even if the browser-specific functions here
|
|
19
|
-
* return `false`.
|
|
20
15
|
*
|
|
21
16
|
* ## Discovery channels (CLI / native, all transparent)
|
|
22
17
|
*
|
|
23
|
-
* In Node/Bun environments,
|
|
18
|
+
* In Node/Bun environments, the agent's `LocalDwnDiscovery` reads the
|
|
19
|
+
* `~/.enbox/dwn.json` discovery file automatically inside
|
|
24
20
|
* `AgentDwnApi.getLocalDwnEndpoint()`. The browser-specific functions
|
|
25
21
|
* in this module (`checkUrlForDwnDiscoveryPayload`, `requestLocalDwnDiscovery`)
|
|
26
|
-
* are not needed
|
|
27
|
-
* on its own.
|
|
22
|
+
* are not needed in those environments.
|
|
28
23
|
*
|
|
29
|
-
* @see https://github.com/enboxorg/enbox/issues/
|
|
24
|
+
* @see https://github.com/enboxorg/enbox/issues/677
|
|
30
25
|
* @module
|
|
31
26
|
*/
|
|
32
27
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
@@ -38,13 +33,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
38
33
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
39
34
|
});
|
|
40
35
|
};
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
36
|
+
import { EnboxRpcClient } from '@enbox/dwn-clients';
|
|
37
|
+
import { buildDwnConnectUrl, localDwnServerName, normalizeBaseUrl, readDwnDiscoveryPayloadFromUrl } from '@enbox/agent';
|
|
38
|
+
import { STORAGE_KEYS } from './types.js';
|
|
43
39
|
/**
|
|
44
40
|
* Check the current page URL for a `DwnDiscoveryPayload` in the fragment.
|
|
45
41
|
*
|
|
46
42
|
* This is called once at the start of a connection flow to detect whether
|
|
47
|
-
* the user was just redirected back from a `dwn://
|
|
43
|
+
* the user was just redirected back from a `dwn://connect` handler. If a
|
|
48
44
|
* valid payload is found, the endpoint is persisted and the fragment is
|
|
49
45
|
* cleared to prevent double-reads.
|
|
50
46
|
*
|
|
@@ -67,6 +63,80 @@ export function checkUrlForDwnDiscoveryPayload() {
|
|
|
67
63
|
}
|
|
68
64
|
return payload.endpoint;
|
|
69
65
|
}
|
|
66
|
+
// ─── Standalone (pre-agent) discovery ───────────────────────────
|
|
67
|
+
/**
|
|
68
|
+
* Validate a local DWN endpoint by calling `GET /info` and checking
|
|
69
|
+
* that the server identifies itself as `@enbox/dwn-server`.
|
|
70
|
+
*
|
|
71
|
+
* This function has **zero** agent or vault dependencies — it only uses
|
|
72
|
+
* the network. It is safe to call before the agent exists.
|
|
73
|
+
*
|
|
74
|
+
* @param endpoint - The candidate endpoint URL.
|
|
75
|
+
* @returns The normalised endpoint if valid, `undefined` otherwise.
|
|
76
|
+
*/
|
|
77
|
+
function validateEndpointStandalone(endpoint) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
const normalized = normalizeBaseUrl(endpoint);
|
|
80
|
+
try {
|
|
81
|
+
const rpc = new EnboxRpcClient();
|
|
82
|
+
const serverInfo = yield rpc.getServerInfo(normalized);
|
|
83
|
+
if (serverInfo.server === localDwnServerName) {
|
|
84
|
+
return normalized;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (_a) {
|
|
88
|
+
// Server not reachable or not ours.
|
|
89
|
+
}
|
|
90
|
+
return undefined;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Run local DWN discovery **before the agent exists**.
|
|
95
|
+
*
|
|
96
|
+
* This is the standalone counterpart of {@link applyLocalDwnDiscovery} and
|
|
97
|
+
* is designed to be called in `AuthManager.create()`, before
|
|
98
|
+
* `EnboxUserAgent.create()`, so the agent creation can decide whether to
|
|
99
|
+
* spin up an in-process DWN or operate in remote mode.
|
|
100
|
+
*
|
|
101
|
+
* Discovery channels (highest → lowest priority):
|
|
102
|
+
* 1. **URL fragment payload** — A `dwn://connect` redirect just landed.
|
|
103
|
+
* 2. **Persisted endpoint** (localStorage) — A previously discovered
|
|
104
|
+
* endpoint, re-validated via `GET /info`.
|
|
105
|
+
*
|
|
106
|
+
* When a valid endpoint is found it is persisted to storage. When a
|
|
107
|
+
* previously-persisted endpoint is stale, it is removed.
|
|
108
|
+
*
|
|
109
|
+
* @param storage - The auth storage adapter (for reading/writing the
|
|
110
|
+
* cached endpoint).
|
|
111
|
+
* @returns The validated endpoint URL, or `undefined` if no local DWN
|
|
112
|
+
* server is available.
|
|
113
|
+
*/
|
|
114
|
+
export function discoverLocalDwn(storage) {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
// Channel 1: Fresh redirect payload in the URL fragment.
|
|
117
|
+
const freshEndpoint = checkUrlForDwnDiscoveryPayload();
|
|
118
|
+
if (freshEndpoint) {
|
|
119
|
+
const validated = yield validateEndpointStandalone(freshEndpoint);
|
|
120
|
+
if (validated) {
|
|
121
|
+
yield persistLocalDwnEndpoint(storage, validated);
|
|
122
|
+
return validated;
|
|
123
|
+
}
|
|
124
|
+
// Payload was in the URL but the server is unreachable — fall through.
|
|
125
|
+
}
|
|
126
|
+
// Channel 2: Persisted endpoint from a previous session.
|
|
127
|
+
const cached = yield storage.get(STORAGE_KEYS.LOCAL_DWN_ENDPOINT);
|
|
128
|
+
if (cached) {
|
|
129
|
+
const validated = yield validateEndpointStandalone(cached);
|
|
130
|
+
if (validated) {
|
|
131
|
+
return validated;
|
|
132
|
+
}
|
|
133
|
+
// Stale — server no longer running.
|
|
134
|
+
yield clearLocalDwnEndpoint(storage);
|
|
135
|
+
}
|
|
136
|
+
return undefined;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
// ─── Storage helpers ────────────────────────────────────────────
|
|
70
140
|
/**
|
|
71
141
|
* Persist a discovered local DWN endpoint in auth storage.
|
|
72
142
|
*
|
|
@@ -121,25 +191,18 @@ export function restoreLocalDwnEndpoint(agent, storage) {
|
|
|
121
191
|
* Run the full local DWN discovery sequence for a browser connection flow.
|
|
122
192
|
*
|
|
123
193
|
* This function handles the **receiving** side of local DWN discovery in
|
|
124
|
-
* the browser. It does NOT trigger the `dwn://
|
|
194
|
+
* the browser. It does NOT trigger the `dwn://connect` redirect — use
|
|
125
195
|
* {@link requestLocalDwnDiscovery} for that.
|
|
126
196
|
*
|
|
127
197
|
* The discovery channels, from highest to lowest priority:
|
|
128
198
|
*
|
|
129
|
-
* 1. **URL fragment payload** — A `dwn://
|
|
199
|
+
* 1. **URL fragment payload** — A `dwn://connect` redirect just landed on
|
|
130
200
|
* this page with the DWN endpoint in `#`. This is the highest-priority
|
|
131
201
|
* signal because it's fresh and explicit.
|
|
132
202
|
*
|
|
133
203
|
* 2. **Persisted endpoint** (localStorage) — A previously discovered
|
|
134
204
|
* endpoint is restored and re-validated via `GET /info`.
|
|
135
205
|
*
|
|
136
|
-
* 3. **Agent-level discovery** (transparent) — Even if this function
|
|
137
|
-
* returns `false`, the agent's `LocalDwnDiscovery` will independently
|
|
138
|
-
* try the discovery file (`~/.enbox/dwn.json`) and port probing on
|
|
139
|
-
* every `sendRequest()` call. Those channels are not available in
|
|
140
|
-
* browsers (no filesystem access, CORS may block probes), but they
|
|
141
|
-
* work transparently in Node/Bun CLI environments.
|
|
142
|
-
*
|
|
143
206
|
* When an `emitter` is provided, this function emits:
|
|
144
207
|
* - `'local-dwn-available'` with the endpoint when discovery succeeds.
|
|
145
208
|
* - `'local-dwn-unavailable'` when no local DWN could be reached.
|
|
@@ -176,36 +239,30 @@ export function applyLocalDwnDiscovery(agent, storage, emitter) {
|
|
|
176
239
|
return restored;
|
|
177
240
|
});
|
|
178
241
|
}
|
|
179
|
-
// ─── dwn://
|
|
242
|
+
// ─── dwn://connect trigger ──────────────────────────────────────
|
|
180
243
|
/**
|
|
181
|
-
* Initiate the `dwn://
|
|
244
|
+
* Initiate the `dwn://connect` flow by opening the connect URL.
|
|
182
245
|
*
|
|
183
|
-
* This asks the operating system to route `dwn://
|
|
246
|
+
* This asks the operating system to route `dwn://connect?callback=<url>`
|
|
184
247
|
* to the registered handler (electrobun-dwn), which will redirect the
|
|
185
248
|
* user's browser back to `callbackUrl` with the local DWN endpoint
|
|
186
249
|
* encoded in the URL fragment.
|
|
187
250
|
*
|
|
188
|
-
* **
|
|
189
|
-
*
|
|
190
|
-
* will silently fail or show an OS-level error dialog.
|
|
191
|
-
* {@link probeLocalDwn} first to check if a local DWN is already
|
|
192
|
-
* reachable via port probing — if it is, you can skip the register flow
|
|
193
|
-
* entirely and call {@link applyLocalDwnDiscovery} instead.
|
|
251
|
+
* **Note:** There is no reliable cross-browser API to detect whether a
|
|
252
|
+
* `dwn://` handler is installed. If no handler is registered, this call
|
|
253
|
+
* will silently fail or show an OS-level error dialog.
|
|
194
254
|
*
|
|
195
255
|
* @param callbackUrl - The URL to redirect back to. Defaults to the
|
|
196
256
|
* current page URL (without its fragment) if running in a browser.
|
|
197
|
-
* @returns `true` if the
|
|
257
|
+
* @returns `true` if the connect URL was opened, `false` if no
|
|
198
258
|
* callback URL could be determined (e.g. no `globalThis.location`).
|
|
199
259
|
*
|
|
200
260
|
* @example
|
|
201
261
|
* ```ts
|
|
202
|
-
* //
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
* requestLocalDwnDiscovery();
|
|
207
|
-
* // The page will reload with the endpoint in the URL fragment.
|
|
208
|
-
* }
|
|
262
|
+
* // Trigger the dwn://connect flow to discover a local DWN.
|
|
263
|
+
* requestLocalDwnDiscovery();
|
|
264
|
+
* // The page will reload with the endpoint in the URL fragment.
|
|
265
|
+
* // On the next connect/restore, applyLocalDwnDiscovery() reads it.
|
|
209
266
|
* ```
|
|
210
267
|
*/
|
|
211
268
|
export function requestLocalDwnDiscovery(callbackUrl) {
|
|
@@ -213,7 +270,7 @@ export function requestLocalDwnDiscovery(callbackUrl) {
|
|
|
213
270
|
if (!resolvedCallback) {
|
|
214
271
|
return false;
|
|
215
272
|
}
|
|
216
|
-
const registerUrl =
|
|
273
|
+
const registerUrl = buildDwnConnectUrl(resolvedCallback);
|
|
217
274
|
// Open the dwn:// URL. Use window.open() rather than location.href
|
|
218
275
|
// assignment to avoid navigating away from the current page if the
|
|
219
276
|
// OS handler isn't installed.
|
|
@@ -228,48 +285,6 @@ export function requestLocalDwnDiscovery(callbackUrl) {
|
|
|
228
285
|
}
|
|
229
286
|
return false;
|
|
230
287
|
}
|
|
231
|
-
/**
|
|
232
|
-
* Probe whether a local DWN server is reachable via direct HTTP fetch.
|
|
233
|
-
*
|
|
234
|
-
* Attempts `GET http://127.0.0.1:{port}/info` on the well-known port
|
|
235
|
-
* candidates and returns the endpoint URL of the first server that
|
|
236
|
-
* responds with a valid `@enbox/dwn-server` identity.
|
|
237
|
-
*
|
|
238
|
-
* This is useful in browsers to check if a local DWN is available
|
|
239
|
-
* *before* triggering the `dwn://register` redirect flow — if the
|
|
240
|
-
* server is already reachable (CORS permitting), the redirect is
|
|
241
|
-
* unnecessary.
|
|
242
|
-
*
|
|
243
|
-
* @returns The local DWN endpoint URL, or `undefined` if no server
|
|
244
|
-
* was found. Returns `undefined` (rather than throwing) on CORS
|
|
245
|
-
* errors or network failures.
|
|
246
|
-
*/
|
|
247
|
-
export function probeLocalDwn() {
|
|
248
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
249
|
-
// Import port candidates from @enbox/agent. Using a dynamic import
|
|
250
|
-
// here keeps the function self-contained and avoids circular deps.
|
|
251
|
-
const { localDwnPortCandidates, localDwnHostCandidates } = yield import('@enbox/agent');
|
|
252
|
-
for (const port of localDwnPortCandidates) {
|
|
253
|
-
for (const host of localDwnHostCandidates) {
|
|
254
|
-
const endpoint = `http://${host}:${port}`;
|
|
255
|
-
try {
|
|
256
|
-
const response = yield fetch(`${endpoint}/info`, { signal: AbortSignal.timeout(2000) });
|
|
257
|
-
if (!response.ok) {
|
|
258
|
-
continue;
|
|
259
|
-
}
|
|
260
|
-
const serverInfo = yield response.json();
|
|
261
|
-
if ((serverInfo === null || serverInfo === void 0 ? void 0 : serverInfo.server) === '@enbox/dwn-server') {
|
|
262
|
-
return endpoint;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
catch (_a) {
|
|
266
|
-
// Network error, CORS block, or timeout — try next candidate.
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
return undefined;
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
288
|
// ─── Internal helpers ───────────────────────────────────────────
|
|
274
289
|
/** Return the current page URL without the fragment, or `undefined`. */
|
|
275
290
|
function currentPageUrl() {
|
|
@@ -278,4 +293,4 @@ function currentPageUrl() {
|
|
|
278
293
|
}
|
|
279
294
|
return globalThis.location.href.split('#')[0];
|
|
280
295
|
}
|
|
281
|
-
//# sourceMappingURL=
|
|
296
|
+
//# sourceMappingURL=discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../../src/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;;;;;;;;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAKxH,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,8BAA8B;IAC5C,IAAI,OAAO,UAAU,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;QAC/C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAG,8BAA8B,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACzE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,kEAAkE;IAClE,qDAAqD;IACrD,IAAI,OAAO,UAAU,CAAC,OAAO,KAAK,WAAW,IAAI,UAAU,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;QACjF,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACxD,UAAU,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,OAAO,CAAC,QAAQ,CAAC;AAC1B,CAAC;AAED,mEAAmE;AAEnE;;;;;;;;;GASG;AACH,SAAe,0BAA0B,CAAC,QAAgB;;QACxD,MAAM,UAAU,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAC9C,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E;AACxE,SAAS,cAAc;IACrB,IAAI,OAAO,UAAU,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;QAC/C,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAChD,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -36,15 +36,19 @@
|
|
|
36
36
|
// Core classes
|
|
37
37
|
export { AuthManager } from './auth-manager.js';
|
|
38
38
|
export { AuthSession } from './identity-session.js';
|
|
39
|
-
export { VaultManager } from './vault/vault-manager.js';
|
|
40
39
|
export { AuthEventEmitter } from './events.js';
|
|
40
|
+
// Password providers
|
|
41
|
+
export { PasswordProvider } from './password-provider.js';
|
|
41
42
|
// Re-export agent classes so consumers can construct custom agents/vaults
|
|
42
43
|
// without a direct @enbox/agent dependency.
|
|
43
44
|
export { EnboxUserAgent, HdIdentityVault } from '@enbox/agent';
|
|
44
45
|
// Wallet-connect helpers
|
|
45
|
-
export { processConnectedGrants } from './
|
|
46
|
+
export { processConnectedGrants } from './connect/wallet.js';
|
|
47
|
+
export { WalletConnect } from './wallet-connect-client.js';
|
|
48
|
+
// Registration token storage helpers
|
|
49
|
+
export { loadTokensFromStorage, saveTokensToStorage } from './registration.js';
|
|
46
50
|
// Local DWN discovery (browser dwn:// protocol integration)
|
|
47
|
-
export { applyLocalDwnDiscovery, checkUrlForDwnDiscoveryPayload, clearLocalDwnEndpoint,
|
|
51
|
+
export { applyLocalDwnDiscovery, checkUrlForDwnDiscoveryPayload, clearLocalDwnEndpoint, discoverLocalDwn, persistLocalDwnEndpoint, requestLocalDwnDiscovery, restoreLocalDwnEndpoint, } from './discovery.js';
|
|
48
52
|
// Storage adapters
|
|
49
53
|
export { BrowserStorage, LevelStorage, MemoryStorage, createDefaultStorage } from './storage/storage.js';
|
|
50
54
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;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,yBAAyB;AACzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,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"}
|