@icp-sdk/auth 7.1.0 → 8.0.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.
|
@@ -53,6 +53,29 @@ export interface AuthClientCreateOptions {
|
|
|
53
53
|
* @example "toolbar=0,location=0,menubar=0,width=500,height=500,left=100,top=100"
|
|
54
54
|
*/
|
|
55
55
|
windowOpenerFeatures?: string;
|
|
56
|
+
/**
|
|
57
|
+
* How the client communicates with the identity provider.
|
|
58
|
+
*
|
|
59
|
+
* - `'window'` (default) — the identity provider opens in a separate browser
|
|
60
|
+
* tab or window (a popup when {@link windowOpenerFeatures} is set) and
|
|
61
|
+
* communicates over the ICRC-29 `postMessage` transport.
|
|
62
|
+
* - `'redirect'` — the current page navigates to the identity provider over
|
|
63
|
+
* the ICRC-167 URL transport, which returns to this same page. The callback
|
|
64
|
+
* URL is the current page's URL (`location.origin + location.pathname`), so
|
|
65
|
+
* that page must be on an origin you control and declared in that origin's
|
|
66
|
+
* `/.well-known/ii-auth-callbacks` allow-list. Use it for full-page sign-in
|
|
67
|
+
* that shouldn't need a user gesture to open a window (e.g. redirecting on a
|
|
68
|
+
* restricted route), or native apps handing off via universal links.
|
|
69
|
+
*
|
|
70
|
+
* With `'redirect'` the page unloads on each step and the flow re-runs on the
|
|
71
|
+
* return load, so call `signIn` / `requestAttributes` directly on the page's
|
|
72
|
+
* load (not deferred behind, say, a click handler): a fresh visit starts the
|
|
73
|
+
* flow and the identity provider's return replays it to completion. Give each
|
|
74
|
+
* flow its own route so its persisted state stays isolated.
|
|
75
|
+
* @default 'window'
|
|
76
|
+
* @see https://github.com/dfinity/wg-identity-authentication/blob/main/topics/icrc_167_browser_url_transport.md
|
|
77
|
+
*/
|
|
78
|
+
transport?: 'window' | 'redirect';
|
|
56
79
|
/**
|
|
57
80
|
* OpenID provider for one-click sign-in. When set, the identity provider
|
|
58
81
|
* URL includes an `openid` search param so the user authenticates via
|
|
@@ -132,24 +155,62 @@ export declare class AuthClient {
|
|
|
132
155
|
/**
|
|
133
156
|
* Requests signed identity attributes from the identity provider.
|
|
134
157
|
*
|
|
135
|
-
* The `nonce`
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
158
|
+
* The `nonce` is a callback that produces the 32-byte nonce (typically
|
|
159
|
+
* fetched from the RP canister), returning a promise resolving to it. It is a
|
|
160
|
+
* callback rather than a value so the redirect flow can journal the nonce and
|
|
161
|
+
* reuse the exact same bytes when the flow replays on the return load,
|
|
162
|
+
* instead of fetching a fresh single-use nonce that the signer never signed
|
|
163
|
+
* against.
|
|
164
|
+
*
|
|
165
|
+
* In 'window' mode the callback lets the identity provider window open while the
|
|
166
|
+
* nonce is still resolving, avoiding a perceived delay before the user sees
|
|
167
|
+
* the prompt; auto-close of the signer transport channel is temporarily
|
|
168
|
+
* disabled while awaiting so the window cannot be closed out from under the
|
|
169
|
+
* pending flow.
|
|
141
170
|
*
|
|
142
171
|
* @param params - Request parameters.
|
|
143
172
|
* @param params.keys - Attribute keys to request (e.g. `['email', 'name']`).
|
|
144
|
-
* @param params.nonce - 32-byte nonce issued by the RP canister,
|
|
145
|
-
* resolving to
|
|
173
|
+
* @param params.nonce - Produces the 32-byte nonce issued by the RP canister,
|
|
174
|
+
* as a promise resolving to it.
|
|
146
175
|
* @returns Signed attribute data and signature.
|
|
147
176
|
* @throws When the identity provider returns an error or an invalid response.
|
|
148
177
|
*/
|
|
149
178
|
requestAttributes(params: {
|
|
150
179
|
keys: string[];
|
|
151
|
-
nonce:
|
|
180
|
+
nonce: () => Promise<Uint8Array>;
|
|
152
181
|
}): Promise<SignedAttributes>;
|
|
182
|
+
/**
|
|
183
|
+
* Runs and journals a piece of your own async work so its result stays stable
|
|
184
|
+
* across the `'redirect'` flow.
|
|
185
|
+
*
|
|
186
|
+
* In `'redirect'` mode the page unloads on each step and `signIn` /
|
|
187
|
+
* `requestAttributes` re-run on the return load, so a value you compute on the
|
|
188
|
+
* first visit (from `location`, a fetch, `crypto`, …) would otherwise be
|
|
189
|
+
* recomputed — and may differ — on the return. Wrap it in `memoize`: it runs
|
|
190
|
+
* `produce` once on the first visit, journals the result, and replays that
|
|
191
|
+
* result on the return load instead of re-running. Use it for a value the
|
|
192
|
+
* post-flow code depends on, e.g. the URL to navigate to once sign-in
|
|
193
|
+
* completes:
|
|
194
|
+
*
|
|
195
|
+
* ```ts
|
|
196
|
+
* const next = await authClient.memoize(
|
|
197
|
+
* () => new URLSearchParams(location.search).get('next') ?? '/',
|
|
198
|
+
* );
|
|
199
|
+
* await authClient.signIn();
|
|
200
|
+
* location.assign(next); // the value captured before the redirect
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* Call `memoize` in a stable order relative to `signIn` / `requestAttributes`
|
|
204
|
+
* across loads (same order every load — branch only on values recovered from
|
|
205
|
+
* earlier results), and keep the result JSON-serializable, since the journal
|
|
206
|
+
* is JSON.
|
|
207
|
+
*
|
|
208
|
+
* In `'window'` mode there is no redirect, so this simply runs `produce` and
|
|
209
|
+
* returns its result without persisting anything.
|
|
210
|
+
* @param produce - Produces the value to journal on the first load.
|
|
211
|
+
* @returns The produced value, or the journaled value on a replay load.
|
|
212
|
+
*/
|
|
213
|
+
memoize<T>(produce: () => T | Promise<T>): Promise<T>;
|
|
153
214
|
/**
|
|
154
215
|
* Clears the stored session and resets the client to an anonymous state.
|
|
155
216
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnonymousIdentity } from '@icp-sdk/core/agent';
|
|
2
2
|
import { DelegationChain, DelegationIdentity, ECDSAKeyIdentity, Ed25519KeyIdentity, isDelegationValid, PartialDelegationIdentity, } from '@icp-sdk/core/identity';
|
|
3
3
|
import { Signer } from '@icp-sdk/signer';
|
|
4
|
-
import { PostMessageTransport } from '@icp-sdk/signer/web';
|
|
4
|
+
import { PostMessageTransport, UrlTransport } from '@icp-sdk/signer/web';
|
|
5
5
|
import { IdleManager } from './idle-manager.js';
|
|
6
6
|
import { IdbStorage, KEY_STORAGE_DELEGATION, KEY_STORAGE_KEY, KEY_VECTOR, LocalStorage, } from './storage.js';
|
|
7
7
|
const NANOSECONDS_PER_SECOND = BigInt(1_000_000_000);
|
|
@@ -14,6 +14,10 @@ const ED25519_KEY_LABEL = 'Ed25519';
|
|
|
14
14
|
// localStorage key used to cache the delegation expiration so that
|
|
15
15
|
// isAuthenticated() can answer synchronously without hitting IndexedDB.
|
|
16
16
|
const KEY_STORAGE_EXPIRATION = 'ic-delegation_expiration';
|
|
17
|
+
// Storage key prefix for a redirect flow's session key, held only while the
|
|
18
|
+
// flow is in progress (keyed by a per-flow id) and removed once the delegation
|
|
19
|
+
// is persisted. See AuthClient.#acquireSessionKey.
|
|
20
|
+
const PENDING_KEY_PREFIX = 'ic-auth-pending-key:';
|
|
17
21
|
export const OPENID_PROVIDER_URLS = {
|
|
18
22
|
google: 'https://accounts.google.com',
|
|
19
23
|
apple: 'https://appleid.apple.com',
|
|
@@ -35,6 +39,9 @@ export class AuthClient {
|
|
|
35
39
|
#chain = null;
|
|
36
40
|
#storage;
|
|
37
41
|
#signer;
|
|
42
|
+
// Set only in redirect mode, so the redirect-specific paths (nonce/key
|
|
43
|
+
// journaling) can reach `memoize`. Undefined in the default 'window' mode.
|
|
44
|
+
#urlTransport;
|
|
38
45
|
#options;
|
|
39
46
|
#initPromise = null;
|
|
40
47
|
idleManager;
|
|
@@ -45,10 +52,19 @@ export class AuthClient {
|
|
|
45
52
|
if (options.openIdProvider) {
|
|
46
53
|
identityProviderUrl.searchParams.set('openid', OPENID_PROVIDER_URLS[options.openIdProvider]);
|
|
47
54
|
}
|
|
48
|
-
const transport =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
const transport = options.transport === 'redirect'
|
|
56
|
+
? new UrlTransport({
|
|
57
|
+
url: identityProviderUrl.toString(),
|
|
58
|
+
// The callback is this page: a fresh visit starts the flow and the
|
|
59
|
+
// provider's return lands back here to replay it. Drop any query
|
|
60
|
+
// and fragment so it stays stable across the redirect.
|
|
61
|
+
callbackUrl: `${globalThis.location.origin}${globalThis.location.pathname}`,
|
|
62
|
+
})
|
|
63
|
+
: new PostMessageTransport({
|
|
64
|
+
url: identityProviderUrl.toString(),
|
|
65
|
+
windowOpenerFeatures: options.windowOpenerFeatures,
|
|
66
|
+
});
|
|
67
|
+
this.#urlTransport = transport instanceof UrlTransport ? transport : undefined;
|
|
52
68
|
this.#signer = new Signer({
|
|
53
69
|
transport,
|
|
54
70
|
derivationOrigin: options.derivationOrigin?.toString(),
|
|
@@ -95,8 +111,10 @@ export class AuthClient {
|
|
|
95
111
|
async signIn(options) {
|
|
96
112
|
await this.#signer.openChannel();
|
|
97
113
|
const maxTimeToLive = options?.maxTimeToLive ?? DEFAULT_MAX_TIME_TO_LIVE;
|
|
98
|
-
|
|
99
|
-
const key
|
|
114
|
+
const keyType = this.#options.keyType ?? ECDSA_KEY_LABEL;
|
|
115
|
+
const { key, pendingKeySlot } = this.#urlTransport
|
|
116
|
+
? await this.#ensureSessionKeyForRedirectFlow(this.#urlTransport, keyType)
|
|
117
|
+
: { key: await this.#ensureSessionKeyForWindowFlow(keyType) };
|
|
100
118
|
const delegationChain = await this.#signer.requestDelegation({
|
|
101
119
|
publicKey: key.getPublicKey(),
|
|
102
120
|
targets: options?.targets,
|
|
@@ -118,27 +136,70 @@ export class AuthClient {
|
|
|
118
136
|
// Persist so the session survives page reloads.
|
|
119
137
|
await persistChain(this.#storage, this.#chain);
|
|
120
138
|
await persistKey(this.#storage, key);
|
|
139
|
+
// The flow is complete: the delegation is bound to this key and stored, so
|
|
140
|
+
// the per-flow pending copy is no longer needed.
|
|
141
|
+
if (pendingKeySlot !== undefined) {
|
|
142
|
+
await this.#storage.remove(pendingKeySlot);
|
|
143
|
+
}
|
|
121
144
|
return this.#identity;
|
|
122
145
|
}
|
|
146
|
+
// Window flow: sign-in completes in a single load, so a fresh session key per
|
|
147
|
+
// sign-in is enough (or the caller-provided identity), with nothing to
|
|
148
|
+
// persist for a later load.
|
|
149
|
+
async #ensureSessionKeyForWindowFlow(keyType) {
|
|
150
|
+
return this.#options.identity ?? (await generateKey(keyType));
|
|
151
|
+
}
|
|
152
|
+
// Redirect flow: `signIn` runs twice — once on the load that navigates to the
|
|
153
|
+
// identity provider, and again on the return load that replays the delegation
|
|
154
|
+
// minted for the FIRST load's key. Both runs must therefore use the same key.
|
|
155
|
+
// A per-flow key id is journaled via the transport (stable across the
|
|
156
|
+
// redirect) and the key is kept in storage under that id, so the return load
|
|
157
|
+
// restores the same key rather than generating a fresh one that would not
|
|
158
|
+
// match the replayed delegation. A caller-provided identity is already stable
|
|
159
|
+
// across the redirect, so it is used as-is with nothing persisted.
|
|
160
|
+
async #ensureSessionKeyForRedirectFlow(transport, keyType) {
|
|
161
|
+
if (this.#options.identity !== undefined) {
|
|
162
|
+
return { key: this.#options.identity };
|
|
163
|
+
}
|
|
164
|
+
const keyId = await transport.memoize(() => globalThis.crypto.randomUUID());
|
|
165
|
+
const pendingKeySlot = `${PENDING_KEY_PREFIX}${keyId}`;
|
|
166
|
+
const restored = await restoreKeyAt(this.#storage, pendingKeySlot);
|
|
167
|
+
if (restored) {
|
|
168
|
+
return { key: restored, pendingKeySlot };
|
|
169
|
+
}
|
|
170
|
+
const key = await generateKey(keyType);
|
|
171
|
+
await this.#storage.set(pendingKeySlot, serializeKey(key));
|
|
172
|
+
return { key, pendingKeySlot };
|
|
173
|
+
}
|
|
123
174
|
/**
|
|
124
175
|
* Requests signed identity attributes from the identity provider.
|
|
125
176
|
*
|
|
126
|
-
* The `nonce`
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
177
|
+
* The `nonce` is a callback that produces the 32-byte nonce (typically
|
|
178
|
+
* fetched from the RP canister), returning a promise resolving to it. It is a
|
|
179
|
+
* callback rather than a value so the redirect flow can journal the nonce and
|
|
180
|
+
* reuse the exact same bytes when the flow replays on the return load,
|
|
181
|
+
* instead of fetching a fresh single-use nonce that the signer never signed
|
|
182
|
+
* against.
|
|
183
|
+
*
|
|
184
|
+
* In 'window' mode the callback lets the identity provider window open while the
|
|
185
|
+
* nonce is still resolving, avoiding a perceived delay before the user sees
|
|
186
|
+
* the prompt; auto-close of the signer transport channel is temporarily
|
|
187
|
+
* disabled while awaiting so the window cannot be closed out from under the
|
|
188
|
+
* pending flow.
|
|
132
189
|
*
|
|
133
190
|
* @param params - Request parameters.
|
|
134
191
|
* @param params.keys - Attribute keys to request (e.g. `['email', 'name']`).
|
|
135
|
-
* @param params.nonce - 32-byte nonce issued by the RP canister,
|
|
136
|
-
* resolving to
|
|
192
|
+
* @param params.nonce - Produces the 32-byte nonce issued by the RP canister,
|
|
193
|
+
* as a promise resolving to it.
|
|
137
194
|
* @returns Signed attribute data and signature.
|
|
138
195
|
* @throws When the identity provider returns an error or an invalid response.
|
|
139
196
|
*/
|
|
140
197
|
async requestAttributes(params) {
|
|
141
|
-
|
|
198
|
+
// In redirect mode the nonce is journaled (base64, since the journal is
|
|
199
|
+
// JSON) so the replay on the return load signs against the same bytes.
|
|
200
|
+
const nonceBytes = this.#urlTransport
|
|
201
|
+
? fromBase64(await this.#urlTransport.memoize(async () => toBase64(await params.nonce())))
|
|
202
|
+
: await this.#resolveNonce(params.nonce);
|
|
142
203
|
const response = await this.#signer.sendRequest({
|
|
143
204
|
jsonrpc: '2.0',
|
|
144
205
|
id: globalThis.crypto.randomUUID(),
|
|
@@ -162,6 +223,43 @@ export class AuthClient {
|
|
|
162
223
|
throw new Error('Invalid response: data or signature is not valid base64', { cause });
|
|
163
224
|
}
|
|
164
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* Runs and journals a piece of your own async work so its result stays stable
|
|
228
|
+
* across the `'redirect'` flow.
|
|
229
|
+
*
|
|
230
|
+
* In `'redirect'` mode the page unloads on each step and `signIn` /
|
|
231
|
+
* `requestAttributes` re-run on the return load, so a value you compute on the
|
|
232
|
+
* first visit (from `location`, a fetch, `crypto`, …) would otherwise be
|
|
233
|
+
* recomputed — and may differ — on the return. Wrap it in `memoize`: it runs
|
|
234
|
+
* `produce` once on the first visit, journals the result, and replays that
|
|
235
|
+
* result on the return load instead of re-running. Use it for a value the
|
|
236
|
+
* post-flow code depends on, e.g. the URL to navigate to once sign-in
|
|
237
|
+
* completes:
|
|
238
|
+
*
|
|
239
|
+
* ```ts
|
|
240
|
+
* const next = await authClient.memoize(
|
|
241
|
+
* () => new URLSearchParams(location.search).get('next') ?? '/',
|
|
242
|
+
* );
|
|
243
|
+
* await authClient.signIn();
|
|
244
|
+
* location.assign(next); // the value captured before the redirect
|
|
245
|
+
* ```
|
|
246
|
+
*
|
|
247
|
+
* Call `memoize` in a stable order relative to `signIn` / `requestAttributes`
|
|
248
|
+
* across loads (same order every load — branch only on values recovered from
|
|
249
|
+
* earlier results), and keep the result JSON-serializable, since the journal
|
|
250
|
+
* is JSON.
|
|
251
|
+
*
|
|
252
|
+
* In `'window'` mode there is no redirect, so this simply runs `produce` and
|
|
253
|
+
* returns its result without persisting anything.
|
|
254
|
+
* @param produce - Produces the value to journal on the first load.
|
|
255
|
+
* @returns The produced value, or the journaled value on a replay load.
|
|
256
|
+
*/
|
|
257
|
+
async memoize(produce) {
|
|
258
|
+
if (this.#urlTransport) {
|
|
259
|
+
return this.#urlTransport.memoize(produce);
|
|
260
|
+
}
|
|
261
|
+
return produce();
|
|
262
|
+
}
|
|
165
263
|
/**
|
|
166
264
|
* Clears the stored session and resets the client to an anonymous state.
|
|
167
265
|
*
|
|
@@ -181,21 +279,19 @@ export class AuthClient {
|
|
|
181
279
|
}
|
|
182
280
|
}
|
|
183
281
|
}
|
|
184
|
-
//
|
|
185
|
-
//
|
|
282
|
+
// Popup-mode nonce resolution. Start the fetch, then open the transport
|
|
283
|
+
// channel so the identity provider window is visible while we wait, and
|
|
186
284
|
// suspend auto-close so it can't fire mid-await (e.g. due to a close
|
|
187
285
|
// scheduled by a prior request on the same signer). The original auto-close
|
|
188
286
|
// setting is restored before sendRequest, so the next response resumes
|
|
189
287
|
// normal close behaviour.
|
|
190
288
|
async #resolveNonce(nonce) {
|
|
191
|
-
|
|
192
|
-
return nonce;
|
|
193
|
-
}
|
|
289
|
+
const value = nonce();
|
|
194
290
|
await this.#signer.openChannel();
|
|
195
291
|
const previousAutoClose = this.#signer.autoCloseTransportChannel;
|
|
196
292
|
this.#signer.autoCloseTransportChannel = false;
|
|
197
293
|
try {
|
|
198
|
-
return await
|
|
294
|
+
return await value;
|
|
199
295
|
}
|
|
200
296
|
finally {
|
|
201
297
|
this.#signer.autoCloseTransportChannel = previousAutoClose;
|
|
@@ -315,6 +411,28 @@ async function restoreKey(storage, keyType) {
|
|
|
315
411
|
return null;
|
|
316
412
|
}
|
|
317
413
|
}
|
|
414
|
+
/**
|
|
415
|
+
* Loads a session key from a specific storage slot, deserializing by stored
|
|
416
|
+
* shape (`CryptoKeyPair` → ECDSA, JSON string → Ed25519). Unlike
|
|
417
|
+
* {@link restoreKey} it does not migrate from localStorage — it reads only the
|
|
418
|
+
* given slot, as used for a redirect flow's per-flow pending key.
|
|
419
|
+
* @param storage - The storage backend.
|
|
420
|
+
* @param storageKey - The slot to read.
|
|
421
|
+
*/
|
|
422
|
+
async function restoreKeyAt(storage, storageKey) {
|
|
423
|
+
const stored = await storage.get(storageKey);
|
|
424
|
+
if (!stored)
|
|
425
|
+
return null;
|
|
426
|
+
try {
|
|
427
|
+
if (typeof stored === 'object') {
|
|
428
|
+
return await ECDSAKeyIdentity.fromKeyPair(stored);
|
|
429
|
+
}
|
|
430
|
+
return Ed25519KeyIdentity.fromJSON(stored);
|
|
431
|
+
}
|
|
432
|
+
catch {
|
|
433
|
+
return null;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
318
436
|
/**
|
|
319
437
|
* Converts a key into a format suitable for storage.
|
|
320
438
|
* @param key - The key to serialize.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-client.js","sour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AC,GAAG,CACb,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,QAAQ,IAAI,GAAG,EAAuD,CAC1F,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icp-sdk/auth",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"author": "DFINITY Stiftung <sdk@dfinity.org>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "Authentication library for Internet Computer web apps",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@icp-sdk/core": "^5"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@icp-sdk/signer": "^5.
|
|
57
|
+
"@icp-sdk/signer": "^5.5.0",
|
|
58
58
|
"idb": "^7.1.1"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from '@icp-sdk/core/identity';
|
|
11
11
|
import type { Principal } from '@icp-sdk/core/principal';
|
|
12
12
|
import { Signer } from '@icp-sdk/signer';
|
|
13
|
-
import { PostMessageTransport } from '@icp-sdk/signer/web';
|
|
13
|
+
import { PostMessageTransport, UrlTransport } from '@icp-sdk/signer/web';
|
|
14
14
|
import { IdleManager, type IdleManagerOptions } from './idle-manager.js';
|
|
15
15
|
import {
|
|
16
16
|
type AuthClientStorage,
|
|
@@ -37,6 +37,11 @@ type BaseKeyType = typeof ECDSA_KEY_LABEL | typeof ED25519_KEY_LABEL;
|
|
|
37
37
|
// isAuthenticated() can answer synchronously without hitting IndexedDB.
|
|
38
38
|
const KEY_STORAGE_EXPIRATION = 'ic-delegation_expiration';
|
|
39
39
|
|
|
40
|
+
// Storage key prefix for a redirect flow's session key, held only while the
|
|
41
|
+
// flow is in progress (keyed by a per-flow id) and removed once the delegation
|
|
42
|
+
// is persisted. See AuthClient.#acquireSessionKey.
|
|
43
|
+
const PENDING_KEY_PREFIX = 'ic-auth-pending-key:';
|
|
44
|
+
|
|
40
45
|
export type OpenIdProvider = 'google' | 'apple' | 'microsoft';
|
|
41
46
|
|
|
42
47
|
export const OPENID_PROVIDER_URLS = {
|
|
@@ -94,6 +99,30 @@ export interface AuthClientCreateOptions {
|
|
|
94
99
|
*/
|
|
95
100
|
windowOpenerFeatures?: string;
|
|
96
101
|
|
|
102
|
+
/**
|
|
103
|
+
* How the client communicates with the identity provider.
|
|
104
|
+
*
|
|
105
|
+
* - `'window'` (default) — the identity provider opens in a separate browser
|
|
106
|
+
* tab or window (a popup when {@link windowOpenerFeatures} is set) and
|
|
107
|
+
* communicates over the ICRC-29 `postMessage` transport.
|
|
108
|
+
* - `'redirect'` — the current page navigates to the identity provider over
|
|
109
|
+
* the ICRC-167 URL transport, which returns to this same page. The callback
|
|
110
|
+
* URL is the current page's URL (`location.origin + location.pathname`), so
|
|
111
|
+
* that page must be on an origin you control and declared in that origin's
|
|
112
|
+
* `/.well-known/ii-auth-callbacks` allow-list. Use it for full-page sign-in
|
|
113
|
+
* that shouldn't need a user gesture to open a window (e.g. redirecting on a
|
|
114
|
+
* restricted route), or native apps handing off via universal links.
|
|
115
|
+
*
|
|
116
|
+
* With `'redirect'` the page unloads on each step and the flow re-runs on the
|
|
117
|
+
* return load, so call `signIn` / `requestAttributes` directly on the page's
|
|
118
|
+
* load (not deferred behind, say, a click handler): a fresh visit starts the
|
|
119
|
+
* flow and the identity provider's return replays it to completion. Give each
|
|
120
|
+
* flow its own route so its persisted state stays isolated.
|
|
121
|
+
* @default 'window'
|
|
122
|
+
* @see https://github.com/dfinity/wg-identity-authentication/blob/main/topics/icrc_167_browser_url_transport.md
|
|
123
|
+
*/
|
|
124
|
+
transport?: 'window' | 'redirect';
|
|
125
|
+
|
|
97
126
|
/**
|
|
98
127
|
* OpenID provider for one-click sign-in. When set, the identity provider
|
|
99
128
|
* URL includes an `openid` search param so the user authenticates via
|
|
@@ -152,6 +181,9 @@ export class AuthClient {
|
|
|
152
181
|
#chain: DelegationChain | null = null;
|
|
153
182
|
#storage: AuthClientStorage;
|
|
154
183
|
#signer: Signer;
|
|
184
|
+
// Set only in redirect mode, so the redirect-specific paths (nonce/key
|
|
185
|
+
// journaling) can reach `memoize`. Undefined in the default 'window' mode.
|
|
186
|
+
#urlTransport: UrlTransport | undefined;
|
|
155
187
|
#options: AuthClientCreateOptions;
|
|
156
188
|
#initPromise: Promise<void> | null = null;
|
|
157
189
|
idleManager: IdleManager | undefined;
|
|
@@ -167,10 +199,20 @@ export class AuthClient {
|
|
|
167
199
|
identityProviderUrl.searchParams.set('openid', OPENID_PROVIDER_URLS[options.openIdProvider]);
|
|
168
200
|
}
|
|
169
201
|
|
|
170
|
-
const transport =
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
202
|
+
const transport =
|
|
203
|
+
options.transport === 'redirect'
|
|
204
|
+
? new UrlTransport({
|
|
205
|
+
url: identityProviderUrl.toString(),
|
|
206
|
+
// The callback is this page: a fresh visit starts the flow and the
|
|
207
|
+
// provider's return lands back here to replay it. Drop any query
|
|
208
|
+
// and fragment so it stays stable across the redirect.
|
|
209
|
+
callbackUrl: `${globalThis.location.origin}${globalThis.location.pathname}`,
|
|
210
|
+
})
|
|
211
|
+
: new PostMessageTransport({
|
|
212
|
+
url: identityProviderUrl.toString(),
|
|
213
|
+
windowOpenerFeatures: options.windowOpenerFeatures,
|
|
214
|
+
});
|
|
215
|
+
this.#urlTransport = transport instanceof UrlTransport ? transport : undefined;
|
|
174
216
|
|
|
175
217
|
this.#signer = new Signer({
|
|
176
218
|
transport,
|
|
@@ -223,10 +265,11 @@ export class AuthClient {
|
|
|
223
265
|
await this.#signer.openChannel();
|
|
224
266
|
|
|
225
267
|
const maxTimeToLive = options?.maxTimeToLive ?? DEFAULT_MAX_TIME_TO_LIVE;
|
|
268
|
+
const keyType = this.#options.keyType ?? ECDSA_KEY_LABEL;
|
|
226
269
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
270
|
+
const { key, pendingKeySlot } = this.#urlTransport
|
|
271
|
+
? await this.#ensureSessionKeyForRedirectFlow(this.#urlTransport, keyType)
|
|
272
|
+
: { key: await this.#ensureSessionKeyForWindowFlow(keyType) };
|
|
230
273
|
|
|
231
274
|
const delegationChain = await this.#signer.requestDelegation({
|
|
232
275
|
publicKey: key.getPublicKey(),
|
|
@@ -253,31 +296,85 @@ export class AuthClient {
|
|
|
253
296
|
await persistChain(this.#storage, this.#chain);
|
|
254
297
|
await persistKey(this.#storage, key);
|
|
255
298
|
|
|
299
|
+
// The flow is complete: the delegation is bound to this key and stored, so
|
|
300
|
+
// the per-flow pending copy is no longer needed.
|
|
301
|
+
if (pendingKeySlot !== undefined) {
|
|
302
|
+
await this.#storage.remove(pendingKeySlot);
|
|
303
|
+
}
|
|
304
|
+
|
|
256
305
|
return this.#identity;
|
|
257
306
|
}
|
|
258
307
|
|
|
308
|
+
// Window flow: sign-in completes in a single load, so a fresh session key per
|
|
309
|
+
// sign-in is enough (or the caller-provided identity), with nothing to
|
|
310
|
+
// persist for a later load.
|
|
311
|
+
async #ensureSessionKeyForWindowFlow(
|
|
312
|
+
keyType: BaseKeyType,
|
|
313
|
+
): Promise<SignIdentity | PartialIdentity> {
|
|
314
|
+
return this.#options.identity ?? (await generateKey(keyType));
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// Redirect flow: `signIn` runs twice — once on the load that navigates to the
|
|
318
|
+
// identity provider, and again on the return load that replays the delegation
|
|
319
|
+
// minted for the FIRST load's key. Both runs must therefore use the same key.
|
|
320
|
+
// A per-flow key id is journaled via the transport (stable across the
|
|
321
|
+
// redirect) and the key is kept in storage under that id, so the return load
|
|
322
|
+
// restores the same key rather than generating a fresh one that would not
|
|
323
|
+
// match the replayed delegation. A caller-provided identity is already stable
|
|
324
|
+
// across the redirect, so it is used as-is with nothing persisted.
|
|
325
|
+
async #ensureSessionKeyForRedirectFlow(
|
|
326
|
+
transport: UrlTransport,
|
|
327
|
+
keyType: BaseKeyType,
|
|
328
|
+
): Promise<{ key: SignIdentity | PartialIdentity; pendingKeySlot?: string }> {
|
|
329
|
+
if (this.#options.identity !== undefined) {
|
|
330
|
+
return { key: this.#options.identity };
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const keyId = await transport.memoize(() => globalThis.crypto.randomUUID());
|
|
334
|
+
const pendingKeySlot = `${PENDING_KEY_PREFIX}${keyId}`;
|
|
335
|
+
|
|
336
|
+
const restored = await restoreKeyAt(this.#storage, pendingKeySlot);
|
|
337
|
+
if (restored) {
|
|
338
|
+
return { key: restored, pendingKeySlot };
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
const key = await generateKey(keyType);
|
|
342
|
+
await this.#storage.set(pendingKeySlot, serializeKey(key));
|
|
343
|
+
return { key, pendingKeySlot };
|
|
344
|
+
}
|
|
345
|
+
|
|
259
346
|
/**
|
|
260
347
|
* Requests signed identity attributes from the identity provider.
|
|
261
348
|
*
|
|
262
|
-
* The `nonce`
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
349
|
+
* The `nonce` is a callback that produces the 32-byte nonce (typically
|
|
350
|
+
* fetched from the RP canister), returning a promise resolving to it. It is a
|
|
351
|
+
* callback rather than a value so the redirect flow can journal the nonce and
|
|
352
|
+
* reuse the exact same bytes when the flow replays on the return load,
|
|
353
|
+
* instead of fetching a fresh single-use nonce that the signer never signed
|
|
354
|
+
* against.
|
|
355
|
+
*
|
|
356
|
+
* In 'window' mode the callback lets the identity provider window open while the
|
|
357
|
+
* nonce is still resolving, avoiding a perceived delay before the user sees
|
|
358
|
+
* the prompt; auto-close of the signer transport channel is temporarily
|
|
359
|
+
* disabled while awaiting so the window cannot be closed out from under the
|
|
360
|
+
* pending flow.
|
|
268
361
|
*
|
|
269
362
|
* @param params - Request parameters.
|
|
270
363
|
* @param params.keys - Attribute keys to request (e.g. `['email', 'name']`).
|
|
271
|
-
* @param params.nonce - 32-byte nonce issued by the RP canister,
|
|
272
|
-
* resolving to
|
|
364
|
+
* @param params.nonce - Produces the 32-byte nonce issued by the RP canister,
|
|
365
|
+
* as a promise resolving to it.
|
|
273
366
|
* @returns Signed attribute data and signature.
|
|
274
367
|
* @throws When the identity provider returns an error or an invalid response.
|
|
275
368
|
*/
|
|
276
369
|
async requestAttributes(params: {
|
|
277
370
|
keys: string[];
|
|
278
|
-
nonce:
|
|
371
|
+
nonce: () => Promise<Uint8Array>;
|
|
279
372
|
}): Promise<SignedAttributes> {
|
|
280
|
-
|
|
373
|
+
// In redirect mode the nonce is journaled (base64, since the journal is
|
|
374
|
+
// JSON) so the replay on the return load signs against the same bytes.
|
|
375
|
+
const nonceBytes = this.#urlTransport
|
|
376
|
+
? fromBase64(await this.#urlTransport.memoize(async () => toBase64(await params.nonce())))
|
|
377
|
+
: await this.#resolveNonce(params.nonce);
|
|
281
378
|
|
|
282
379
|
const response = await this.#signer.sendRequest({
|
|
283
380
|
jsonrpc: '2.0',
|
|
@@ -305,6 +402,44 @@ export class AuthClient {
|
|
|
305
402
|
}
|
|
306
403
|
}
|
|
307
404
|
|
|
405
|
+
/**
|
|
406
|
+
* Runs and journals a piece of your own async work so its result stays stable
|
|
407
|
+
* across the `'redirect'` flow.
|
|
408
|
+
*
|
|
409
|
+
* In `'redirect'` mode the page unloads on each step and `signIn` /
|
|
410
|
+
* `requestAttributes` re-run on the return load, so a value you compute on the
|
|
411
|
+
* first visit (from `location`, a fetch, `crypto`, …) would otherwise be
|
|
412
|
+
* recomputed — and may differ — on the return. Wrap it in `memoize`: it runs
|
|
413
|
+
* `produce` once on the first visit, journals the result, and replays that
|
|
414
|
+
* result on the return load instead of re-running. Use it for a value the
|
|
415
|
+
* post-flow code depends on, e.g. the URL to navigate to once sign-in
|
|
416
|
+
* completes:
|
|
417
|
+
*
|
|
418
|
+
* ```ts
|
|
419
|
+
* const next = await authClient.memoize(
|
|
420
|
+
* () => new URLSearchParams(location.search).get('next') ?? '/',
|
|
421
|
+
* );
|
|
422
|
+
* await authClient.signIn();
|
|
423
|
+
* location.assign(next); // the value captured before the redirect
|
|
424
|
+
* ```
|
|
425
|
+
*
|
|
426
|
+
* Call `memoize` in a stable order relative to `signIn` / `requestAttributes`
|
|
427
|
+
* across loads (same order every load — branch only on values recovered from
|
|
428
|
+
* earlier results), and keep the result JSON-serializable, since the journal
|
|
429
|
+
* is JSON.
|
|
430
|
+
*
|
|
431
|
+
* In `'window'` mode there is no redirect, so this simply runs `produce` and
|
|
432
|
+
* returns its result without persisting anything.
|
|
433
|
+
* @param produce - Produces the value to journal on the first load.
|
|
434
|
+
* @returns The produced value, or the journaled value on a replay load.
|
|
435
|
+
*/
|
|
436
|
+
async memoize<T>(produce: () => T | Promise<T>): Promise<T> {
|
|
437
|
+
if (this.#urlTransport) {
|
|
438
|
+
return this.#urlTransport.memoize(produce);
|
|
439
|
+
}
|
|
440
|
+
return produce();
|
|
441
|
+
}
|
|
442
|
+
|
|
308
443
|
/**
|
|
309
444
|
* Clears the stored session and resets the client to an anonymous state.
|
|
310
445
|
*
|
|
@@ -326,22 +461,19 @@ export class AuthClient {
|
|
|
326
461
|
}
|
|
327
462
|
}
|
|
328
463
|
|
|
329
|
-
//
|
|
330
|
-
//
|
|
464
|
+
// Popup-mode nonce resolution. Start the fetch, then open the transport
|
|
465
|
+
// channel so the identity provider window is visible while we wait, and
|
|
331
466
|
// suspend auto-close so it can't fire mid-await (e.g. due to a close
|
|
332
467
|
// scheduled by a prior request on the same signer). The original auto-close
|
|
333
468
|
// setting is restored before sendRequest, so the next response resumes
|
|
334
469
|
// normal close behaviour.
|
|
335
|
-
async #resolveNonce(nonce:
|
|
336
|
-
|
|
337
|
-
return nonce;
|
|
338
|
-
}
|
|
339
|
-
|
|
470
|
+
async #resolveNonce(nonce: () => Promise<Uint8Array>): Promise<Uint8Array> {
|
|
471
|
+
const value = nonce();
|
|
340
472
|
await this.#signer.openChannel();
|
|
341
473
|
const previousAutoClose = this.#signer.autoCloseTransportChannel;
|
|
342
474
|
this.#signer.autoCloseTransportChannel = false;
|
|
343
475
|
try {
|
|
344
|
-
return await
|
|
476
|
+
return await value;
|
|
345
477
|
} finally {
|
|
346
478
|
this.#signer.autoCloseTransportChannel = previousAutoClose;
|
|
347
479
|
}
|
|
@@ -475,6 +607,31 @@ async function restoreKey(
|
|
|
475
607
|
}
|
|
476
608
|
}
|
|
477
609
|
|
|
610
|
+
/**
|
|
611
|
+
* Loads a session key from a specific storage slot, deserializing by stored
|
|
612
|
+
* shape (`CryptoKeyPair` → ECDSA, JSON string → Ed25519). Unlike
|
|
613
|
+
* {@link restoreKey} it does not migrate from localStorage — it reads only the
|
|
614
|
+
* given slot, as used for a redirect flow's per-flow pending key.
|
|
615
|
+
* @param storage - The storage backend.
|
|
616
|
+
* @param storageKey - The slot to read.
|
|
617
|
+
*/
|
|
618
|
+
async function restoreKeyAt(
|
|
619
|
+
storage: AuthClientStorage,
|
|
620
|
+
storageKey: string,
|
|
621
|
+
): Promise<SignIdentity | PartialIdentity | null> {
|
|
622
|
+
const stored = await storage.get(storageKey);
|
|
623
|
+
if (!stored) return null;
|
|
624
|
+
|
|
625
|
+
try {
|
|
626
|
+
if (typeof stored === 'object') {
|
|
627
|
+
return await ECDSAKeyIdentity.fromKeyPair(stored);
|
|
628
|
+
}
|
|
629
|
+
return Ed25519KeyIdentity.fromJSON(stored);
|
|
630
|
+
} catch {
|
|
631
|
+
return null;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
|
|
478
635
|
/**
|
|
479
636
|
* Converts a key into a format suitable for storage.
|
|
480
637
|
* @param key - The key to serialize.
|