@tidecloak/js 0.13.14 → 0.13.15

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.
@@ -0,0 +1,481 @@
1
+ // @ts-nocheck
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _DPoPStoreManager_instances, _DPoPStoreManager_dbName, _DPoPStoreManager_db, _DPoPStoreManager_useMemoryFallback, _DPoPStoreManager_memoryStore, _DPoPStoreManager_issuer, _DPoPStoreManager_clientId, _DPoPStoreManager_strictStorage, _DPoPStoreManager_openDatabase, _DPoPSignatureProvider_instances, _DPoPSignatureProvider_alg, _DPoPSignatureProvider_store, _DPoPSignatureProvider_serverAllowedAlgorithms, _DPoPSignatureProvider_resourceNonces, _DPoPSignatureProvider_generateKeyPair, _DPoPSignatureProvider_sign;
14
+ /** @enum {string} */
15
+ export const BrowserSignatureAlgs = {
16
+ ES256: 'ES256',
17
+ ES384: 'ES384',
18
+ ES512: 'ES512',
19
+ EdDSA: 'EdDSA'
20
+ };
21
+ const DB_VERSION = 1;
22
+ const STORE_NAME = 'main';
23
+ const STATE_KEY = 'dpopState';
24
+ /** @type {Record<string, EcKeyGenParams | AlgorithmIdentifier>} */
25
+ const KEY_GEN_PARAMS = {
26
+ ES256: { name: 'ECDSA', namedCurve: 'P-256' },
27
+ ES384: { name: 'ECDSA', namedCurve: 'P-384' },
28
+ ES512: { name: 'ECDSA', namedCurve: 'P-521' },
29
+ EdDSA: { name: 'Ed25519' }
30
+ };
31
+ /** @type {Record<string, EcdsaParams | AlgorithmIdentifier>} */
32
+ const SIGN_PARAMS = {
33
+ ES256: { name: 'ECDSA', hash: 'SHA-256' },
34
+ ES384: { name: 'ECDSA', hash: 'SHA-384' },
35
+ ES512: { name: 'ECDSA', hash: 'SHA-512' },
36
+ EdDSA: { name: 'Ed25519' }
37
+ };
38
+ /** Fallback order when EdDSA is unsupported */
39
+ const ECDSA_FALLBACK_ORDER = [
40
+ BrowserSignatureAlgs.ES256,
41
+ BrowserSignatureAlgs.ES384,
42
+ BrowserSignatureAlgs.ES512
43
+ ];
44
+ /**
45
+ * Creates a safe database name from issuer and clientId.
46
+ * Uses SHA-256 hash of both issuer and clientId to avoid special characters
47
+ * and prevent injection attacks via malicious clientId values.
48
+ * @param {string} issuer - The authorization server issuer URL
49
+ * @param {string} clientId - The OIDC client identifier
50
+ * @returns {Promise<string>} A sanitized database name
51
+ */
52
+ async function createDbName(issuer, clientId) {
53
+ const encoder = new TextEncoder();
54
+ // Hash issuer
55
+ const issuerData = encoder.encode(issuer);
56
+ const issuerHashBuffer = await crypto.subtle.digest('SHA-256', issuerData);
57
+ const issuerHashArray = new Uint8Array(issuerHashBuffer);
58
+ const issuerHash = Array.from(issuerHashArray.slice(0, 8))
59
+ .map(b => b.toString(16).padStart(2, '0'))
60
+ .join('');
61
+ // Hash clientId to prevent special character issues and injection
62
+ const clientData = encoder.encode(clientId);
63
+ const clientHashBuffer = await crypto.subtle.digest('SHA-256', clientData);
64
+ const clientHashArray = new Uint8Array(clientHashBuffer);
65
+ const clientHash = Array.from(clientHashArray.slice(0, 8))
66
+ .map(b => b.toString(16).padStart(2, '0'))
67
+ .join('');
68
+ return `dpop:${issuerHash}:${clientHash}`;
69
+ }
70
+ /**
71
+ * Manages persistent storage of DPoP key pairs and nonces in IndexedDB.
72
+ * Falls back to in-memory storage when IndexedDB is unavailable.
73
+ *
74
+ * Database is named using a hash of the issuer URL + clientId to ensure
75
+ * isolation between different authorization servers.
76
+ *
77
+ * @see https://datatracker.ietf.org/doc/html/rfc9449
78
+ */
79
+ class DPoPStoreManager {
80
+ /**
81
+ * @param {string} issuer - The authorization server issuer URL
82
+ * @param {string} clientId - The OIDC client identifier
83
+ * @param {boolean} [strictStorage=false] - If true, throws error when IndexedDB is unavailable instead of falling back to memory
84
+ */
85
+ constructor(issuer, clientId, strictStorage = false) {
86
+ _DPoPStoreManager_instances.add(this);
87
+ /** @type {string} */
88
+ _DPoPStoreManager_dbName.set(this, ''
89
+ /** @type {IDBDatabase | null} */
90
+ );
91
+ /** @type {IDBDatabase | null} */
92
+ _DPoPStoreManager_db.set(this, null
93
+ /** @type {boolean} */
94
+ );
95
+ /** @type {boolean} */
96
+ _DPoPStoreManager_useMemoryFallback.set(this, false
97
+ /** @type {DPoPState | undefined} */
98
+ );
99
+ /** @type {DPoPState | undefined} */
100
+ _DPoPStoreManager_memoryStore.set(this, undefined
101
+ /** @type {string} */
102
+ );
103
+ /** @type {string} */
104
+ _DPoPStoreManager_issuer.set(this, void 0);
105
+ /** @type {string} */
106
+ _DPoPStoreManager_clientId.set(this, void 0);
107
+ /** @type {boolean} */
108
+ _DPoPStoreManager_strictStorage.set(this, void 0);
109
+ __classPrivateFieldSet(this, _DPoPStoreManager_issuer, issuer, "f");
110
+ __classPrivateFieldSet(this, _DPoPStoreManager_clientId, clientId, "f");
111
+ __classPrivateFieldSet(this, _DPoPStoreManager_strictStorage, strictStorage, "f");
112
+ }
113
+ /**
114
+ * Initialize the store manager. Must be called before other operations.
115
+ * @returns {Promise<DPoPStoreManager>}
116
+ */
117
+ async init() {
118
+ if (__classPrivateFieldGet(this, _DPoPStoreManager_db, "f") || __classPrivateFieldGet(this, _DPoPStoreManager_useMemoryFallback, "f")) {
119
+ return this; // Already initialized
120
+ }
121
+ try {
122
+ __classPrivateFieldSet(this, _DPoPStoreManager_dbName, await createDbName(__classPrivateFieldGet(this, _DPoPStoreManager_issuer, "f"), __classPrivateFieldGet(this, _DPoPStoreManager_clientId, "f")), "f");
123
+ __classPrivateFieldSet(this, _DPoPStoreManager_db, await __classPrivateFieldGet(this, _DPoPStoreManager_instances, "m", _DPoPStoreManager_openDatabase).call(this), "f");
124
+ }
125
+ catch (error) {
126
+ if (__classPrivateFieldGet(this, _DPoPStoreManager_strictStorage, "f")) {
127
+ throw new Error('DPoP requires IndexedDB for secure key storage, but it is unavailable.', { cause: error });
128
+ }
129
+ console.warn('[KEYCLOAK] IndexedDB unavailable, falling back to in-memory storage:', error);
130
+ __classPrivateFieldSet(this, _DPoPStoreManager_useMemoryFallback, true, "f");
131
+ }
132
+ return this;
133
+ }
134
+ /**
135
+ * Retrieve the stored key pair and nonce.
136
+ * @returns {Promise<DPoPState | undefined>}
137
+ */
138
+ async get() {
139
+ if (__classPrivateFieldGet(this, _DPoPStoreManager_useMemoryFallback, "f")) {
140
+ return __classPrivateFieldGet(this, _DPoPStoreManager_memoryStore, "f");
141
+ }
142
+ if (!__classPrivateFieldGet(this, _DPoPStoreManager_db, "f")) {
143
+ throw new Error('DPoPStoreManager not initialized. Call init() first.');
144
+ }
145
+ return new Promise((resolve, reject) => {
146
+ const transaction = /** @type {IDBDatabase} */ (__classPrivateFieldGet(this, _DPoPStoreManager_db, "f")).transaction(STORE_NAME, 'readonly');
147
+ const store = transaction.objectStore(STORE_NAME);
148
+ const request = store.get(STATE_KEY);
149
+ request.onerror = () => {
150
+ reject(request.error);
151
+ };
152
+ request.onsuccess = () => {
153
+ resolve(request.result);
154
+ };
155
+ });
156
+ }
157
+ /**
158
+ * Store or overwrite the key pair and optional nonce.
159
+ * @param {DPoPState} state - The state to store
160
+ * @returns {Promise<void>}
161
+ */
162
+ async set(state) {
163
+ if (__classPrivateFieldGet(this, _DPoPStoreManager_useMemoryFallback, "f")) {
164
+ __classPrivateFieldSet(this, _DPoPStoreManager_memoryStore, state, "f");
165
+ return;
166
+ }
167
+ if (!__classPrivateFieldGet(this, _DPoPStoreManager_db, "f")) {
168
+ throw new Error('DPoPStoreManager not initialized. Call init() first.');
169
+ }
170
+ return new Promise((resolve, reject) => {
171
+ const transaction = /** @type {IDBDatabase} */ (__classPrivateFieldGet(this, _DPoPStoreManager_db, "f")).transaction(STORE_NAME, 'readwrite');
172
+ const store = transaction.objectStore(STORE_NAME);
173
+ const request = store.put(state, STATE_KEY);
174
+ request.onerror = () => {
175
+ reject(request.error);
176
+ };
177
+ request.onsuccess = () => {
178
+ resolve();
179
+ };
180
+ });
181
+ }
182
+ /**
183
+ * Delete all stored data. Called on logout.
184
+ * @returns {Promise<void>}
185
+ */
186
+ async flush() {
187
+ if (__classPrivateFieldGet(this, _DPoPStoreManager_useMemoryFallback, "f")) {
188
+ __classPrivateFieldSet(this, _DPoPStoreManager_memoryStore, undefined, "f");
189
+ return;
190
+ }
191
+ if (!__classPrivateFieldGet(this, _DPoPStoreManager_db, "f")) {
192
+ throw new Error('DPoPStoreManager not initialized. Call init() first.');
193
+ }
194
+ return new Promise((resolve, reject) => {
195
+ const transaction = /** @type {IDBDatabase} */ (__classPrivateFieldGet(this, _DPoPStoreManager_db, "f")).transaction(STORE_NAME, 'readwrite');
196
+ const store = transaction.objectStore(STORE_NAME);
197
+ const request = store.delete(STATE_KEY);
198
+ request.onerror = () => {
199
+ reject(request.error);
200
+ };
201
+ request.onsuccess = () => {
202
+ resolve();
203
+ };
204
+ });
205
+ }
206
+ /**
207
+ * Update only the nonce while preserving existing keys.
208
+ * Convenience method for handling DPoP-Nonce header responses.
209
+ * @param {string} nonce - The new nonce from the authorization server
210
+ * @returns {Promise<void>}
211
+ * @throws {Error} If nonce fails validation
212
+ */
213
+ async updateNonce(nonce) {
214
+ // Validate nonce to prevent DoS and injection attacks
215
+ const MAX_NONCE_LENGTH = 512;
216
+ // RFC 9449 doesn't specify format, but nonces should be printable ASCII for HTTP headers
217
+ const VALID_NONCE_PATTERN = /^[\x21-\x7E]+$/;
218
+ if (typeof nonce !== 'string' || nonce.length === 0) {
219
+ throw new Error('DPoP nonce must be a non-empty string');
220
+ }
221
+ if (nonce.length > MAX_NONCE_LENGTH) {
222
+ throw new Error(`DPoP nonce exceeds maximum length of ${MAX_NONCE_LENGTH} characters`);
223
+ }
224
+ if (!VALID_NONCE_PATTERN.test(nonce)) {
225
+ throw new Error('DPoP nonce contains invalid characters');
226
+ }
227
+ const state = await this.get();
228
+ if (state) {
229
+ state.nonce = nonce;
230
+ await this.set(state);
231
+ }
232
+ }
233
+ /**
234
+ * Close the database connection.
235
+ */
236
+ close() {
237
+ if (__classPrivateFieldGet(this, _DPoPStoreManager_db, "f")) {
238
+ __classPrivateFieldGet(this, _DPoPStoreManager_db, "f").close();
239
+ __classPrivateFieldSet(this, _DPoPStoreManager_db, null, "f");
240
+ }
241
+ }
242
+ }
243
+ _DPoPStoreManager_dbName = new WeakMap(), _DPoPStoreManager_db = new WeakMap(), _DPoPStoreManager_useMemoryFallback = new WeakMap(), _DPoPStoreManager_memoryStore = new WeakMap(), _DPoPStoreManager_issuer = new WeakMap(), _DPoPStoreManager_clientId = new WeakMap(), _DPoPStoreManager_strictStorage = new WeakMap(), _DPoPStoreManager_instances = new WeakSet(), _DPoPStoreManager_openDatabase = function _DPoPStoreManager_openDatabase() {
244
+ return new Promise((resolve, reject) => {
245
+ if (typeof indexedDB === 'undefined') {
246
+ reject(new Error('IndexedDB is not available'));
247
+ return;
248
+ }
249
+ const request = indexedDB.open(__classPrivateFieldGet(this, _DPoPStoreManager_dbName, "f"), DB_VERSION);
250
+ request.onerror = () => {
251
+ reject(request.error);
252
+ };
253
+ request.onsuccess = () => {
254
+ resolve(request.result);
255
+ };
256
+ request.onupgradeneeded = (event) => {
257
+ /** @type {IDBDatabase} */
258
+ const db = /** @type {IDBOpenDBRequest} */ (event.target).result;
259
+ const oldVersion = event.oldVersion;
260
+ // Version 0 -> 1: Initial schema creation
261
+ if (oldVersion < 1) {
262
+ db.createObjectStore(STORE_NAME);
263
+ }
264
+ // Future migrations:
265
+ // if (oldVersion < 2) {
266
+ // // Example: Add an index to the store
267
+ // const store = event.target.transaction.objectStore(STORE_NAME)
268
+ // store.createIndex('indexName', 'keyPath')
269
+ // }
270
+ };
271
+ });
272
+ };
273
+ export class DPoPSignatureProvider {
274
+ /**
275
+ * @param {DPoPSignatureProviderOptions} options
276
+ */
277
+ constructor(options) {
278
+ _DPoPSignatureProvider_instances.add(this);
279
+ /**@type {BrowserSignatureAlgs} */
280
+ _DPoPSignatureProvider_alg.set(this, void 0);
281
+ /**@type {DPoPStoreManager} */
282
+ _DPoPSignatureProvider_store.set(this, void 0);
283
+ /** @type {string[]} */
284
+ _DPoPSignatureProvider_serverAllowedAlgorithms.set(this, void 0);
285
+ /** @type {Map<string, string>} Resource server nonces keyed by origin */
286
+ _DPoPSignatureProvider_resourceNonces.set(this, new Map());
287
+ const { issuerUrl, clientId, serverSupportedAlgorithms, requestedAlgorithm, strictStorage = false } = options;
288
+ // Check for Web Crypto API availability
289
+ if (typeof crypto === 'undefined' || !crypto.subtle) {
290
+ throw new Error('DPoP requires Web Crypto API (crypto.subtle) which is not available in this environment.');
291
+ }
292
+ // Validate required options
293
+ if (!issuerUrl) {
294
+ throw new Error('DPoP requires issuerUrl');
295
+ }
296
+ if (!clientId) {
297
+ throw new Error('DPoP requires clientId');
298
+ }
299
+ if (!serverSupportedAlgorithms || !Array.isArray(serverSupportedAlgorithms)) {
300
+ throw new Error('DPoP requires serverSupportedAlgorithms array');
301
+ }
302
+ __classPrivateFieldSet(this, _DPoPSignatureProvider_serverAllowedAlgorithms, serverSupportedAlgorithms, "f");
303
+ let chosenAlgorithm = BrowserSignatureAlgs.ES256; // default value (due to high availability in browsers)
304
+ if (requestedAlgorithm !== undefined) {
305
+ // Check to see if requestedAlgorithm is supported by the server
306
+ if (!__classPrivateFieldGet(this, _DPoPSignatureProvider_serverAllowedAlgorithms, "f").includes(requestedAlgorithm)) {
307
+ throw new Error(`Requested algorithm '${requestedAlgorithm}' is not supported by the server. Server supports: ${__classPrivateFieldGet(this, _DPoPSignatureProvider_serverAllowedAlgorithms, "f").join(', ')}`);
308
+ }
309
+ chosenAlgorithm = requestedAlgorithm;
310
+ }
311
+ __classPrivateFieldSet(this, _DPoPSignatureProvider_alg, chosenAlgorithm, "f");
312
+ __classPrivateFieldSet(this, _DPoPSignatureProvider_store, new DPoPStoreManager(issuerUrl.toString(), clientId, strictStorage), "f");
313
+ }
314
+ async init() {
315
+ await __classPrivateFieldGet(this, _DPoPSignatureProvider_store, "f").init();
316
+ // Check for existing keys or generate new ones
317
+ let state = await __classPrivateFieldGet(this, _DPoPSignatureProvider_store, "f").get();
318
+ if (!state) {
319
+ const keys = await __classPrivateFieldGet(this, _DPoPSignatureProvider_instances, "m", _DPoPSignatureProvider_generateKeyPair).call(this);
320
+ state = { keys };
321
+ await __classPrivateFieldGet(this, _DPoPSignatureProvider_store, "f").set(state);
322
+ }
323
+ }
324
+ /**
325
+ * Clear all stored DPoP state (keys and nonce) for this client. Called on logout.
326
+ * Only affects the keys for this specific issuer+clientId combination.
327
+ * @returns {Promise<void>}
328
+ */
329
+ async flush() {
330
+ await __classPrivateFieldGet(this, _DPoPSignatureProvider_store, "f").flush();
331
+ }
332
+ /**
333
+ * Get the stored authorization server nonce.
334
+ * @returns {Promise<string | undefined>}
335
+ */
336
+ async getAuthServerNonce() {
337
+ const state = await __classPrivateFieldGet(this, _DPoPSignatureProvider_store, "f").get();
338
+ return state === null || state === void 0 ? void 0 : state.nonce;
339
+ }
340
+ /**
341
+ * Update the authorization server nonce. Called after receiving DPoP-Nonce header.
342
+ * @param {string} nonce
343
+ * @returns {Promise<void>}
344
+ */
345
+ async updateAuthServerNonce(nonce) {
346
+ await __classPrivateFieldGet(this, _DPoPSignatureProvider_store, "f").updateNonce(nonce);
347
+ }
348
+ /**
349
+ * Get the stored resource server nonce for a given origin.
350
+ * @param {string} origin - The resource server origin (e.g., "https://api.example.com")
351
+ * @returns {string | undefined} The stored nonce, or undefined if none exists
352
+ */
353
+ getResourceServerNonce(origin) {
354
+ return __classPrivateFieldGet(this, _DPoPSignatureProvider_resourceNonces, "f").get(origin);
355
+ }
356
+ /**
357
+ * Update the resource server nonce for a given origin. Called after receiving DPoP-Nonce header.
358
+ * Silently ignores invalid nonces to prevent DoS attacks.
359
+ * @param {string} origin - The resource server origin
360
+ * @param {string} nonce - The nonce from the DPoP-Nonce response header
361
+ */
362
+ updateResourceServerNonce(origin, nonce) {
363
+ // Validate nonce to prevent DoS and injection attacks
364
+ const MAX_NONCE_LENGTH = 512;
365
+ const VALID_NONCE_PATTERN = /^[\x21-\x7E]+$/;
366
+ if (typeof nonce !== 'string' || nonce.length === 0)
367
+ return;
368
+ if (nonce.length > MAX_NONCE_LENGTH)
369
+ return;
370
+ if (!VALID_NONCE_PATTERN.test(nonce))
371
+ return;
372
+ __classPrivateFieldGet(this, _DPoPSignatureProvider_resourceNonces, "f").set(origin, nonce);
373
+ }
374
+ /**
375
+ * @param {string} url
376
+ * @param {string} httpMethod
377
+ * @param {string} [accessToken] Access token if calling resource server
378
+ * @param {string} [nonce] Server-provided nonce
379
+ * @returns {Promise<string>}
380
+ */
381
+ async generateDPoPProof(url, httpMethod, accessToken, nonce) {
382
+ const payload = {
383
+ jti: crypto.randomUUID(),
384
+ htm: httpMethod,
385
+ htu: (() => {
386
+ const urlObj = new URL(url);
387
+ return urlObj.origin + urlObj.pathname;
388
+ })(),
389
+ iat: Math.floor(Date.now() / 1000), // TODO - Get server time here instead of local time
390
+ ...(accessToken !== undefined && {
391
+ ath: base64UrlEncodeBuffer(await sha256Digest(accessToken))
392
+ }),
393
+ ...(nonce !== undefined && { nonce })
394
+ };
395
+ const state = await __classPrivateFieldGet(this, _DPoPSignatureProvider_store, "f").get();
396
+ if (state === undefined)
397
+ throw new Error('DPoP not initialized');
398
+ const exportedJwk = await crypto.subtle.exportKey("jwk", state.keys.publicKey);
399
+ const header = {
400
+ alg: __classPrivateFieldGet(this, _DPoPSignatureProvider_alg, "f"),
401
+ typ: "dpop+jwt",
402
+ // Note: `y` is undefined for EdDSA/OKP keys (RFC 8037) but present for EC keys.
403
+ // JSON.stringify omits undefined values, so this produces valid JWKs for both.
404
+ jwk: {
405
+ crv: exportedJwk.crv,
406
+ kty: exportedJwk.kty,
407
+ x: exportedJwk.x,
408
+ y: exportedJwk.y
409
+ }
410
+ };
411
+ const te = new TextEncoder();
412
+ const unsignedToken = `${base64UrlEncodeBuffer(te.encode(JSON.stringify(header)))}.${base64UrlEncodeBuffer(te.encode(JSON.stringify(payload)))}`;
413
+ const signature = await __classPrivateFieldGet(this, _DPoPSignatureProvider_instances, "m", _DPoPSignatureProvider_sign).call(this, te.encode(unsignedToken), state.keys.privateKey);
414
+ return `${unsignedToken}.${base64UrlEncodeBuffer(signature)}`;
415
+ }
416
+ }
417
+ _DPoPSignatureProvider_alg = new WeakMap(), _DPoPSignatureProvider_store = new WeakMap(), _DPoPSignatureProvider_serverAllowedAlgorithms = new WeakMap(), _DPoPSignatureProvider_resourceNonces = new WeakMap(), _DPoPSignatureProvider_instances = new WeakSet(), _DPoPSignatureProvider_generateKeyPair =
418
+ /**
419
+ * @returns {Promise<CryptoKeyPair>}
420
+ */
421
+ async function _DPoPSignatureProvider_generateKeyPair() {
422
+ const params = KEY_GEN_PARAMS[__classPrivateFieldGet(this, _DPoPSignatureProvider_alg, "f")];
423
+ if (!params) {
424
+ throw new Error(`Unknown signature algorithm: ${__classPrivateFieldGet(this, _DPoPSignatureProvider_alg, "f")}`);
425
+ }
426
+ try {
427
+ return /** @type {CryptoKeyPair} */ (await crypto.subtle.generateKey(params, false, ['sign']));
428
+ }
429
+ catch (ex) {
430
+ if (!(ex instanceof DOMException && ex.name === 'NotSupportedError')) {
431
+ throw ex;
432
+ }
433
+ // Only EdDSA needs fallback; ECDSA is universally supported
434
+ if (__classPrivateFieldGet(this, _DPoPSignatureProvider_alg, "f") !== BrowserSignatureAlgs.EdDSA) {
435
+ throw ex;
436
+ }
437
+ // Find the next available algorithm that both the browser and server support
438
+ const fallback = ECDSA_FALLBACK_ORDER.find(alg => __classPrivateFieldGet(this, _DPoPSignatureProvider_serverAllowedAlgorithms, "f").includes(alg));
439
+ if (!fallback) {
440
+ throw new Error('No supported algorithm available in this browser');
441
+ }
442
+ __classPrivateFieldSet(this, _DPoPSignatureProvider_alg, fallback, "f");
443
+ return __classPrivateFieldGet(this, _DPoPSignatureProvider_instances, "m", _DPoPSignatureProvider_generateKeyPair).call(this);
444
+ }
445
+ }, _DPoPSignatureProvider_sign =
446
+ /**
447
+ * @param {Uint8Array<ArrayBuffer>} msg
448
+ * @param {CryptoKey} key
449
+ * @returns {Promise<ArrayBuffer>}
450
+ */
451
+ async function _DPoPSignatureProvider_sign(msg, key) {
452
+ const params = SIGN_PARAMS[__classPrivateFieldGet(this, _DPoPSignatureProvider_alg, "f")];
453
+ if (!params) {
454
+ throw new Error(`Unknown signature algorithm: ${__classPrivateFieldGet(this, _DPoPSignatureProvider_alg, "f")}`);
455
+ }
456
+ return await crypto.subtle.sign(params, key, msg);
457
+ };
458
+ /**
459
+ * @param {string} message
460
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest#basic_example
461
+ */
462
+ async function sha256Digest(message) {
463
+ const encoder = new TextEncoder();
464
+ const data = encoder.encode(message);
465
+ if (typeof crypto === 'undefined' || typeof crypto.subtle === 'undefined') {
466
+ throw new Error('Web Crypto API is not available.');
467
+ }
468
+ return await crypto.subtle.digest('SHA-256', data);
469
+ }
470
+ /**
471
+ * @param {ArrayBuffer | Uint8Array} buffer
472
+ */
473
+ function base64UrlEncodeBuffer(buffer) {
474
+ const bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
475
+ const binary = String.fromCharCode(...bytes);
476
+ return btoa(binary)
477
+ .replaceAll('+', '-')
478
+ .replaceAll('/', '_')
479
+ .replaceAll('=', '');
480
+ }
481
+ //# sourceMappingURL=tidecloak-dpop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tidecloak-dpop.js","sourceRoot":"","sources":["../../../lib/tidecloak-dpop.js"],"names":[],"mappings":"AAAA,cAAc;;;;;;;;;;;;;AAEd,qBAAqB;AACrB,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;CACf,CAAA;AAED,MAAM,UAAU,GAAG,CAAC,CAAA;AACpB,MAAM,UAAU,GAAG,MAAM,CAAA;AACzB,MAAM,SAAS,GAAG,WAAW,CAAA;AAE7B,mEAAmE;AACnE,MAAM,cAAc,GAAG;IACrB,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE;IAC7C,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE;IAC7C,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE;IAC7C,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;CAC3B,CAAA;AAED,gEAAgE;AAChE,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;IACzC,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;IACzC,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;IACzC,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;CAC3B,CAAA;AAED,+CAA+C;AAC/C,MAAM,oBAAoB,GAAG;IAC3B,oBAAoB,CAAC,KAAK;IAC1B,oBAAoB,CAAC,KAAK;IAC1B,oBAAo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