@pod-os/core 0.12.1-7d2693a.0 → 0.12.1-b3f906d.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/index.js +405 -539
- package/lib/index.js +428 -562
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -41,22 +41,22 @@ var require_events = __commonJS({
|
|
|
41
41
|
var NumberIsNaN = Number.isNaN || function NumberIsNaN2(value6) {
|
|
42
42
|
return value6 !== value6;
|
|
43
43
|
};
|
|
44
|
-
function
|
|
45
|
-
|
|
44
|
+
function EventEmitter3() {
|
|
45
|
+
EventEmitter3.init.call(this);
|
|
46
46
|
}
|
|
47
|
-
module2.exports =
|
|
47
|
+
module2.exports = EventEmitter3;
|
|
48
48
|
module2.exports.once = once;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
EventEmitter3.EventEmitter = EventEmitter3;
|
|
50
|
+
EventEmitter3.prototype._events = void 0;
|
|
51
|
+
EventEmitter3.prototype._eventsCount = 0;
|
|
52
|
+
EventEmitter3.prototype._maxListeners = void 0;
|
|
53
53
|
var defaultMaxListeners = 10;
|
|
54
54
|
function checkListener(listener) {
|
|
55
55
|
if (typeof listener !== "function") {
|
|
56
56
|
throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
Object.defineProperty(
|
|
59
|
+
Object.defineProperty(EventEmitter3, "defaultMaxListeners", {
|
|
60
60
|
enumerable: true,
|
|
61
61
|
get: function() {
|
|
62
62
|
return defaultMaxListeners;
|
|
@@ -68,14 +68,14 @@ var require_events = __commonJS({
|
|
|
68
68
|
defaultMaxListeners = arg2;
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
|
-
|
|
71
|
+
EventEmitter3.init = function() {
|
|
72
72
|
if (this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) {
|
|
73
73
|
this._events = /* @__PURE__ */ Object.create(null);
|
|
74
74
|
this._eventsCount = 0;
|
|
75
75
|
}
|
|
76
76
|
this._maxListeners = this._maxListeners || void 0;
|
|
77
77
|
};
|
|
78
|
-
|
|
78
|
+
EventEmitter3.prototype.setMaxListeners = function setMaxListeners(n2) {
|
|
79
79
|
if (typeof n2 !== "number" || n2 < 0 || NumberIsNaN(n2)) {
|
|
80
80
|
throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n2 + ".");
|
|
81
81
|
}
|
|
@@ -84,13 +84,13 @@ var require_events = __commonJS({
|
|
|
84
84
|
};
|
|
85
85
|
function _getMaxListeners(that) {
|
|
86
86
|
if (that._maxListeners === void 0)
|
|
87
|
-
return
|
|
87
|
+
return EventEmitter3.defaultMaxListeners;
|
|
88
88
|
return that._maxListeners;
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
EventEmitter3.prototype.getMaxListeners = function getMaxListeners() {
|
|
91
91
|
return _getMaxListeners(this);
|
|
92
92
|
};
|
|
93
|
-
|
|
93
|
+
EventEmitter3.prototype.emit = function emit(type5) {
|
|
94
94
|
var args = [];
|
|
95
95
|
for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
|
|
96
96
|
var doError = type5 === "error";
|
|
@@ -167,11 +167,11 @@ var require_events = __commonJS({
|
|
|
167
167
|
}
|
|
168
168
|
return target5;
|
|
169
169
|
}
|
|
170
|
-
|
|
170
|
+
EventEmitter3.prototype.addListener = function addListener(type5, listener) {
|
|
171
171
|
return _addListener(this, type5, listener, false);
|
|
172
172
|
};
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
EventEmitter3.prototype.on = EventEmitter3.prototype.addListener;
|
|
174
|
+
EventEmitter3.prototype.prependListener = function prependListener(type5, listener) {
|
|
175
175
|
return _addListener(this, type5, listener, true);
|
|
176
176
|
};
|
|
177
177
|
function onceWrapper() {
|
|
@@ -190,17 +190,17 @@ var require_events = __commonJS({
|
|
|
190
190
|
state2.wrapFn = wrapped;
|
|
191
191
|
return wrapped;
|
|
192
192
|
}
|
|
193
|
-
|
|
193
|
+
EventEmitter3.prototype.once = function once2(type5, listener) {
|
|
194
194
|
checkListener(listener);
|
|
195
195
|
this.on(type5, _onceWrap(this, type5, listener));
|
|
196
196
|
return this;
|
|
197
197
|
};
|
|
198
|
-
|
|
198
|
+
EventEmitter3.prototype.prependOnceListener = function prependOnceListener(type5, listener) {
|
|
199
199
|
checkListener(listener);
|
|
200
200
|
this.prependListener(type5, _onceWrap(this, type5, listener));
|
|
201
201
|
return this;
|
|
202
202
|
};
|
|
203
|
-
|
|
203
|
+
EventEmitter3.prototype.removeListener = function removeListener(type5, listener) {
|
|
204
204
|
var list, events3, position4, i, originalListener;
|
|
205
205
|
checkListener(listener);
|
|
206
206
|
events3 = this._events;
|
|
@@ -240,8 +240,8 @@ var require_events = __commonJS({
|
|
|
240
240
|
}
|
|
241
241
|
return this;
|
|
242
242
|
};
|
|
243
|
-
|
|
244
|
-
|
|
243
|
+
EventEmitter3.prototype.off = EventEmitter3.prototype.removeListener;
|
|
244
|
+
EventEmitter3.prototype.removeAllListeners = function removeAllListeners(type5) {
|
|
245
245
|
var listeners, events3, i;
|
|
246
246
|
events3 = this._events;
|
|
247
247
|
if (events3 === void 0)
|
|
@@ -292,20 +292,20 @@ var require_events = __commonJS({
|
|
|
292
292
|
return unwrap3 ? [evlistener.listener || evlistener] : [evlistener];
|
|
293
293
|
return unwrap3 ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
|
|
294
294
|
}
|
|
295
|
-
|
|
295
|
+
EventEmitter3.prototype.listeners = function listeners(type5) {
|
|
296
296
|
return _listeners(this, type5, true);
|
|
297
297
|
};
|
|
298
|
-
|
|
298
|
+
EventEmitter3.prototype.rawListeners = function rawListeners(type5) {
|
|
299
299
|
return _listeners(this, type5, false);
|
|
300
300
|
};
|
|
301
|
-
|
|
301
|
+
EventEmitter3.listenerCount = function(emitter, type5) {
|
|
302
302
|
if (typeof emitter.listenerCount === "function") {
|
|
303
303
|
return emitter.listenerCount(type5);
|
|
304
304
|
} else {
|
|
305
305
|
return listenerCount.call(emitter, type5);
|
|
306
306
|
}
|
|
307
307
|
};
|
|
308
|
-
|
|
308
|
+
EventEmitter3.prototype.listenerCount = listenerCount;
|
|
309
309
|
function listenerCount(type5) {
|
|
310
310
|
var events3 = this._events;
|
|
311
311
|
if (events3 !== void 0) {
|
|
@@ -318,7 +318,7 @@ var require_events = __commonJS({
|
|
|
318
318
|
}
|
|
319
319
|
return 0;
|
|
320
320
|
}
|
|
321
|
-
|
|
321
|
+
EventEmitter3.prototype.eventNames = function eventNames() {
|
|
322
322
|
return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
|
|
323
323
|
};
|
|
324
324
|
function arrayClone(arr, n2) {
|
|
@@ -6741,20 +6741,20 @@ var require_lunr = __commonJS({
|
|
|
6741
6741
|
if (obj === null || obj === void 0) {
|
|
6742
6742
|
return obj;
|
|
6743
6743
|
}
|
|
6744
|
-
var
|
|
6744
|
+
var clone = /* @__PURE__ */ Object.create(null), keys = Object.keys(obj);
|
|
6745
6745
|
for (var i = 0; i < keys.length; i++) {
|
|
6746
6746
|
var key3 = keys[i], val = obj[key3];
|
|
6747
6747
|
if (Array.isArray(val)) {
|
|
6748
|
-
|
|
6748
|
+
clone[key3] = val.slice();
|
|
6749
6749
|
continue;
|
|
6750
6750
|
}
|
|
6751
6751
|
if (typeof val === "string" || typeof val === "number" || typeof val === "boolean") {
|
|
6752
|
-
|
|
6752
|
+
clone[key3] = val;
|
|
6753
6753
|
continue;
|
|
6754
6754
|
}
|
|
6755
6755
|
throw new TypeError("clone is not deep and does not support nested objects");
|
|
6756
6756
|
}
|
|
6757
|
-
return
|
|
6757
|
+
return clone;
|
|
6758
6758
|
};
|
|
6759
6759
|
lunr2.FieldRef = function(docRef, fieldName, stringValue) {
|
|
6760
6760
|
this.docRef = docRef;
|
|
@@ -10119,11 +10119,18 @@ function tap(observerOrNext, error4, complete2) {
|
|
|
10119
10119
|
}) : identity;
|
|
10120
10120
|
}
|
|
10121
10121
|
|
|
10122
|
-
// ../node_modules/@inrupt/solid-client-authn-core/
|
|
10122
|
+
// ../node_modules/@inrupt/solid-client-authn-core/dist/index.mjs
|
|
10123
|
+
var import_events = __toESM(require_events(), 1);
|
|
10124
|
+
|
|
10125
|
+
// ../node_modules/@inrupt/universal-fetch/dist/index-browser.mjs
|
|
10126
|
+
var indexBrowser = globalThis.fetch;
|
|
10127
|
+
var { fetch: fetch2, Response, Request, Headers } = globalThis;
|
|
10128
|
+
|
|
10129
|
+
// ../node_modules/jose/dist/browser/runtime/webcrypto.js
|
|
10123
10130
|
var webcrypto_default = crypto;
|
|
10124
10131
|
var isCryptoKey = (key3) => key3 instanceof CryptoKey;
|
|
10125
10132
|
|
|
10126
|
-
// ../node_modules
|
|
10133
|
+
// ../node_modules/jose/dist/browser/lib/buffer_utils.js
|
|
10127
10134
|
var encoder = new TextEncoder();
|
|
10128
10135
|
var decoder = new TextDecoder();
|
|
10129
10136
|
var MAX_INT32 = 2 ** 32;
|
|
@@ -10131,14 +10138,14 @@ function concat(...buffers) {
|
|
|
10131
10138
|
const size4 = buffers.reduce((acc, { length: length2 }) => acc + length2, 0);
|
|
10132
10139
|
const buf = new Uint8Array(size4);
|
|
10133
10140
|
let i = 0;
|
|
10134
|
-
|
|
10141
|
+
buffers.forEach((buffer) => {
|
|
10135
10142
|
buf.set(buffer, i);
|
|
10136
10143
|
i += buffer.length;
|
|
10137
|
-
}
|
|
10144
|
+
});
|
|
10138
10145
|
return buf;
|
|
10139
10146
|
}
|
|
10140
10147
|
|
|
10141
|
-
// ../node_modules
|
|
10148
|
+
// ../node_modules/jose/dist/browser/runtime/base64url.js
|
|
10142
10149
|
var encodeBase64 = (input2) => {
|
|
10143
10150
|
let unencoded = input2;
|
|
10144
10151
|
if (typeof unencoded === "string") {
|
|
@@ -10170,21 +10177,22 @@ var decode = (input2) => {
|
|
|
10170
10177
|
encoded = encoded.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
|
|
10171
10178
|
try {
|
|
10172
10179
|
return decodeBase64(encoded);
|
|
10173
|
-
} catch {
|
|
10180
|
+
} catch (_a) {
|
|
10174
10181
|
throw new TypeError("The input to be decoded is not correctly encoded.");
|
|
10175
10182
|
}
|
|
10176
10183
|
};
|
|
10177
10184
|
|
|
10178
|
-
// ../node_modules
|
|
10185
|
+
// ../node_modules/jose/dist/browser/util/errors.js
|
|
10179
10186
|
var JOSEError = class extends Error {
|
|
10180
10187
|
static get code() {
|
|
10181
10188
|
return "ERR_JOSE_GENERIC";
|
|
10182
10189
|
}
|
|
10183
10190
|
constructor(message4) {
|
|
10191
|
+
var _a;
|
|
10184
10192
|
super(message4);
|
|
10185
10193
|
this.code = "ERR_JOSE_GENERIC";
|
|
10186
10194
|
this.name = this.constructor.name;
|
|
10187
|
-
Error.captureStackTrace
|
|
10195
|
+
(_a = Error.captureStackTrace) === null || _a === void 0 ? void 0 : _a.call(Error, this, this.constructor);
|
|
10188
10196
|
}
|
|
10189
10197
|
};
|
|
10190
10198
|
var JWTClaimValidationFailed = class extends JOSEError {
|
|
@@ -10245,45 +10253,6 @@ var JWTInvalid = class extends JOSEError {
|
|
|
10245
10253
|
return "ERR_JWT_INVALID";
|
|
10246
10254
|
}
|
|
10247
10255
|
};
|
|
10248
|
-
var JWKSInvalid = class extends JOSEError {
|
|
10249
|
-
constructor() {
|
|
10250
|
-
super(...arguments);
|
|
10251
|
-
this.code = "ERR_JWKS_INVALID";
|
|
10252
|
-
}
|
|
10253
|
-
static get code() {
|
|
10254
|
-
return "ERR_JWKS_INVALID";
|
|
10255
|
-
}
|
|
10256
|
-
};
|
|
10257
|
-
var JWKSNoMatchingKey = class extends JOSEError {
|
|
10258
|
-
constructor() {
|
|
10259
|
-
super(...arguments);
|
|
10260
|
-
this.code = "ERR_JWKS_NO_MATCHING_KEY";
|
|
10261
|
-
this.message = "no applicable key found in the JSON Web Key Set";
|
|
10262
|
-
}
|
|
10263
|
-
static get code() {
|
|
10264
|
-
return "ERR_JWKS_NO_MATCHING_KEY";
|
|
10265
|
-
}
|
|
10266
|
-
};
|
|
10267
|
-
var JWKSMultipleMatchingKeys = class extends JOSEError {
|
|
10268
|
-
constructor() {
|
|
10269
|
-
super(...arguments);
|
|
10270
|
-
this.code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
|
|
10271
|
-
this.message = "multiple matching keys found in the JSON Web Key Set";
|
|
10272
|
-
}
|
|
10273
|
-
static get code() {
|
|
10274
|
-
return "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
|
|
10275
|
-
}
|
|
10276
|
-
};
|
|
10277
|
-
var JWKSTimeout = class extends JOSEError {
|
|
10278
|
-
constructor() {
|
|
10279
|
-
super(...arguments);
|
|
10280
|
-
this.code = "ERR_JWKS_TIMEOUT";
|
|
10281
|
-
this.message = "request timed out";
|
|
10282
|
-
}
|
|
10283
|
-
static get code() {
|
|
10284
|
-
return "ERR_JWKS_TIMEOUT";
|
|
10285
|
-
}
|
|
10286
|
-
};
|
|
10287
10256
|
var JWSSignatureVerificationFailed = class extends JOSEError {
|
|
10288
10257
|
constructor() {
|
|
10289
10258
|
super(...arguments);
|
|
@@ -10295,10 +10264,10 @@ var JWSSignatureVerificationFailed = class extends JOSEError {
|
|
|
10295
10264
|
}
|
|
10296
10265
|
};
|
|
10297
10266
|
|
|
10298
|
-
// ../node_modules
|
|
10267
|
+
// ../node_modules/jose/dist/browser/runtime/random.js
|
|
10299
10268
|
var random_default = webcrypto_default.getRandomValues.bind(webcrypto_default);
|
|
10300
10269
|
|
|
10301
|
-
// ../node_modules
|
|
10270
|
+
// ../node_modules/jose/dist/browser/lib/crypto_key.js
|
|
10302
10271
|
function unusable(name7, prop = "algorithm.name") {
|
|
10303
10272
|
return new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name7}`);
|
|
10304
10273
|
}
|
|
@@ -10392,7 +10361,7 @@ function checkSigCryptoKey(key3, alg, ...usages) {
|
|
|
10392
10361
|
checkUsage(key3, usages);
|
|
10393
10362
|
}
|
|
10394
10363
|
|
|
10395
|
-
// ../node_modules
|
|
10364
|
+
// ../node_modules/jose/dist/browser/lib/invalid_key_input.js
|
|
10396
10365
|
function message(msg, actual2, ...types2) {
|
|
10397
10366
|
if (types2.length > 2) {
|
|
10398
10367
|
const last3 = types2.pop();
|
|
@@ -10407,7 +10376,7 @@ function message(msg, actual2, ...types2) {
|
|
|
10407
10376
|
} else if (typeof actual2 === "function" && actual2.name) {
|
|
10408
10377
|
msg += ` Received function ${actual2.name}`;
|
|
10409
10378
|
} else if (typeof actual2 === "object" && actual2 != null) {
|
|
10410
|
-
if (actual2.constructor
|
|
10379
|
+
if (actual2.constructor && actual2.constructor.name) {
|
|
10411
10380
|
msg += ` Received an instance of ${actual2.constructor.name}`;
|
|
10412
10381
|
}
|
|
10413
10382
|
}
|
|
@@ -10420,13 +10389,13 @@ function withAlg(alg, actual2, ...types2) {
|
|
|
10420
10389
|
return message(`Key for the ${alg} algorithm must be `, actual2, ...types2);
|
|
10421
10390
|
}
|
|
10422
10391
|
|
|
10423
|
-
// ../node_modules
|
|
10392
|
+
// ../node_modules/jose/dist/browser/runtime/is_key_like.js
|
|
10424
10393
|
var is_key_like_default = (key3) => {
|
|
10425
10394
|
return isCryptoKey(key3);
|
|
10426
10395
|
};
|
|
10427
10396
|
var types = ["CryptoKey"];
|
|
10428
10397
|
|
|
10429
|
-
// ../node_modules
|
|
10398
|
+
// ../node_modules/jose/dist/browser/lib/is_disjoint.js
|
|
10430
10399
|
var isDisjoint = (...headers) => {
|
|
10431
10400
|
const sources = headers.filter(Boolean);
|
|
10432
10401
|
if (sources.length === 0 || sources.length === 1) {
|
|
@@ -10450,7 +10419,7 @@ var isDisjoint = (...headers) => {
|
|
|
10450
10419
|
};
|
|
10451
10420
|
var is_disjoint_default = isDisjoint;
|
|
10452
10421
|
|
|
10453
|
-
// ../node_modules
|
|
10422
|
+
// ../node_modules/jose/dist/browser/lib/is_object.js
|
|
10454
10423
|
function isObjectLike(value6) {
|
|
10455
10424
|
return typeof value6 === "object" && value6 !== null;
|
|
10456
10425
|
}
|
|
@@ -10468,7 +10437,7 @@ function isObject(input2) {
|
|
|
10468
10437
|
return Object.getPrototypeOf(input2) === proto;
|
|
10469
10438
|
}
|
|
10470
10439
|
|
|
10471
|
-
// ../node_modules
|
|
10440
|
+
// ../node_modules/jose/dist/browser/runtime/check_key_length.js
|
|
10472
10441
|
var check_key_length_default = (alg, key3) => {
|
|
10473
10442
|
if (alg.startsWith("RS") || alg.startsWith("PS")) {
|
|
10474
10443
|
const { modulusLength } = key3.algorithm;
|
|
@@ -10478,11 +10447,49 @@ var check_key_length_default = (alg, key3) => {
|
|
|
10478
10447
|
}
|
|
10479
10448
|
};
|
|
10480
10449
|
|
|
10481
|
-
// ../node_modules
|
|
10450
|
+
// ../node_modules/jose/dist/browser/runtime/jwk_to_key.js
|
|
10482
10451
|
function subtleMapping(jwk) {
|
|
10483
10452
|
let algorithm3;
|
|
10484
10453
|
let keyUsages;
|
|
10485
10454
|
switch (jwk.kty) {
|
|
10455
|
+
case "oct": {
|
|
10456
|
+
switch (jwk.alg) {
|
|
10457
|
+
case "HS256":
|
|
10458
|
+
case "HS384":
|
|
10459
|
+
case "HS512":
|
|
10460
|
+
algorithm3 = { name: "HMAC", hash: `SHA-${jwk.alg.slice(-3)}` };
|
|
10461
|
+
keyUsages = ["sign", "verify"];
|
|
10462
|
+
break;
|
|
10463
|
+
case "A128CBC-HS256":
|
|
10464
|
+
case "A192CBC-HS384":
|
|
10465
|
+
case "A256CBC-HS512":
|
|
10466
|
+
throw new JOSENotSupported(`${jwk.alg} keys cannot be imported as CryptoKey instances`);
|
|
10467
|
+
case "A128GCM":
|
|
10468
|
+
case "A192GCM":
|
|
10469
|
+
case "A256GCM":
|
|
10470
|
+
case "A128GCMKW":
|
|
10471
|
+
case "A192GCMKW":
|
|
10472
|
+
case "A256GCMKW":
|
|
10473
|
+
algorithm3 = { name: "AES-GCM" };
|
|
10474
|
+
keyUsages = ["encrypt", "decrypt"];
|
|
10475
|
+
break;
|
|
10476
|
+
case "A128KW":
|
|
10477
|
+
case "A192KW":
|
|
10478
|
+
case "A256KW":
|
|
10479
|
+
algorithm3 = { name: "AES-KW" };
|
|
10480
|
+
keyUsages = ["wrapKey", "unwrapKey"];
|
|
10481
|
+
break;
|
|
10482
|
+
case "PBES2-HS256+A128KW":
|
|
10483
|
+
case "PBES2-HS384+A192KW":
|
|
10484
|
+
case "PBES2-HS512+A256KW":
|
|
10485
|
+
algorithm3 = { name: "PBKDF2" };
|
|
10486
|
+
keyUsages = ["deriveBits"];
|
|
10487
|
+
break;
|
|
10488
|
+
default:
|
|
10489
|
+
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
10490
|
+
}
|
|
10491
|
+
break;
|
|
10492
|
+
}
|
|
10486
10493
|
case "RSA": {
|
|
10487
10494
|
switch (jwk.alg) {
|
|
10488
10495
|
case "PS256":
|
|
@@ -10562,15 +10569,19 @@ function subtleMapping(jwk) {
|
|
|
10562
10569
|
return { algorithm: algorithm3, keyUsages };
|
|
10563
10570
|
}
|
|
10564
10571
|
var parse = async (jwk) => {
|
|
10572
|
+
var _a, _b;
|
|
10565
10573
|
if (!jwk.alg) {
|
|
10566
10574
|
throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
|
|
10567
10575
|
}
|
|
10568
10576
|
const { algorithm: algorithm3, keyUsages } = subtleMapping(jwk);
|
|
10569
10577
|
const rest3 = [
|
|
10570
10578
|
algorithm3,
|
|
10571
|
-
jwk.ext
|
|
10572
|
-
jwk.key_ops
|
|
10579
|
+
(_a = jwk.ext) !== null && _a !== void 0 ? _a : false,
|
|
10580
|
+
(_b = jwk.key_ops) !== null && _b !== void 0 ? _b : keyUsages
|
|
10573
10581
|
];
|
|
10582
|
+
if (algorithm3.name === "PBKDF2") {
|
|
10583
|
+
return webcrypto_default.subtle.importKey("raw", decode(jwk.k), ...rest3);
|
|
10584
|
+
}
|
|
10574
10585
|
const keyData = { ...jwk };
|
|
10575
10586
|
delete keyData.alg;
|
|
10576
10587
|
delete keyData.use;
|
|
@@ -10578,8 +10589,9 @@ var parse = async (jwk) => {
|
|
|
10578
10589
|
};
|
|
10579
10590
|
var jwk_to_key_default = parse;
|
|
10580
10591
|
|
|
10581
|
-
// ../node_modules
|
|
10582
|
-
async function importJWK(jwk, alg) {
|
|
10592
|
+
// ../node_modules/jose/dist/browser/key/import.js
|
|
10593
|
+
async function importJWK(jwk, alg, octAsKeyObject) {
|
|
10594
|
+
var _a;
|
|
10583
10595
|
if (!isObject(jwk)) {
|
|
10584
10596
|
throw new TypeError("JWK must be an object");
|
|
10585
10597
|
}
|
|
@@ -10589,6 +10601,10 @@ async function importJWK(jwk, alg) {
|
|
|
10589
10601
|
if (typeof jwk.k !== "string" || !jwk.k) {
|
|
10590
10602
|
throw new TypeError('missing "k" (Key Value) Parameter value');
|
|
10591
10603
|
}
|
|
10604
|
+
octAsKeyObject !== null && octAsKeyObject !== void 0 ? octAsKeyObject : octAsKeyObject = jwk.ext !== true;
|
|
10605
|
+
if (octAsKeyObject) {
|
|
10606
|
+
return jwk_to_key_default({ ...jwk, alg, ext: (_a = jwk.ext) !== null && _a !== void 0 ? _a : false });
|
|
10607
|
+
}
|
|
10592
10608
|
return decode(jwk.k);
|
|
10593
10609
|
case "RSA":
|
|
10594
10610
|
if (jwk.oth !== void 0) {
|
|
@@ -10602,7 +10618,7 @@ async function importJWK(jwk, alg) {
|
|
|
10602
10618
|
}
|
|
10603
10619
|
}
|
|
10604
10620
|
|
|
10605
|
-
// ../node_modules
|
|
10621
|
+
// ../node_modules/jose/dist/browser/lib/check_key_type.js
|
|
10606
10622
|
var symmetricTypeCheck = (alg, key3) => {
|
|
10607
10623
|
if (key3 instanceof Uint8Array)
|
|
10608
10624
|
return;
|
|
@@ -10643,9 +10659,9 @@ var checkKeyType = (alg, key3, usage2) => {
|
|
|
10643
10659
|
};
|
|
10644
10660
|
var check_key_type_default = checkKeyType;
|
|
10645
10661
|
|
|
10646
|
-
// ../node_modules
|
|
10662
|
+
// ../node_modules/jose/dist/browser/lib/validate_crit.js
|
|
10647
10663
|
function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
|
|
10648
|
-
if (joseHeader.crit !== void 0 && protectedHeader
|
|
10664
|
+
if (joseHeader.crit !== void 0 && protectedHeader.crit === void 0) {
|
|
10649
10665
|
throw new Err('"crit" (Critical) Header Parameter MUST be integrity protected');
|
|
10650
10666
|
}
|
|
10651
10667
|
if (!protectedHeader || protectedHeader.crit === void 0) {
|
|
@@ -10666,8 +10682,7 @@ function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader,
|
|
|
10666
10682
|
}
|
|
10667
10683
|
if (joseHeader[parameter2] === void 0) {
|
|
10668
10684
|
throw new Err(`Extension Header Parameter "${parameter2}" is missing`);
|
|
10669
|
-
}
|
|
10670
|
-
if (recognized.get(parameter2) && protectedHeader[parameter2] === void 0) {
|
|
10685
|
+
} else if (recognized.get(parameter2) && protectedHeader[parameter2] === void 0) {
|
|
10671
10686
|
throw new Err(`Extension Header Parameter "${parameter2}" MUST be integrity protected`);
|
|
10672
10687
|
}
|
|
10673
10688
|
}
|
|
@@ -10675,7 +10690,7 @@ function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader,
|
|
|
10675
10690
|
}
|
|
10676
10691
|
var validate_crit_default = validateCrit;
|
|
10677
10692
|
|
|
10678
|
-
// ../node_modules
|
|
10693
|
+
// ../node_modules/jose/dist/browser/lib/validate_algorithms.js
|
|
10679
10694
|
var validateAlgorithms = (option5, algorithms) => {
|
|
10680
10695
|
if (algorithms !== void 0 && (!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== "string"))) {
|
|
10681
10696
|
throw new TypeError(`"${option5}" option must be an array of strings`);
|
|
@@ -10687,7 +10702,7 @@ var validateAlgorithms = (option5, algorithms) => {
|
|
|
10687
10702
|
};
|
|
10688
10703
|
var validate_algorithms_default = validateAlgorithms;
|
|
10689
10704
|
|
|
10690
|
-
// ../node_modules
|
|
10705
|
+
// ../node_modules/jose/dist/browser/runtime/key_to_jwk.js
|
|
10691
10706
|
var keyToJWK = async (key3) => {
|
|
10692
10707
|
if (key3 instanceof Uint8Array) {
|
|
10693
10708
|
return {
|
|
@@ -10706,15 +10721,15 @@ var keyToJWK = async (key3) => {
|
|
|
10706
10721
|
};
|
|
10707
10722
|
var key_to_jwk_default = keyToJWK;
|
|
10708
10723
|
|
|
10709
|
-
// ../node_modules
|
|
10724
|
+
// ../node_modules/jose/dist/browser/key/export.js
|
|
10710
10725
|
async function exportJWK(key3) {
|
|
10711
10726
|
return key_to_jwk_default(key3);
|
|
10712
10727
|
}
|
|
10713
10728
|
|
|
10714
|
-
// ../node_modules
|
|
10729
|
+
// ../node_modules/jose/dist/browser/jwe/flattened/encrypt.js
|
|
10715
10730
|
var unprotected = Symbol();
|
|
10716
10731
|
|
|
10717
|
-
// ../node_modules
|
|
10732
|
+
// ../node_modules/jose/dist/browser/runtime/subtle_dsa.js
|
|
10718
10733
|
function subtleDsa(alg, algorithm3) {
|
|
10719
10734
|
const hash2 = `SHA-${alg.slice(-3)}`;
|
|
10720
10735
|
switch (alg) {
|
|
@@ -10741,7 +10756,7 @@ function subtleDsa(alg, algorithm3) {
|
|
|
10741
10756
|
}
|
|
10742
10757
|
}
|
|
10743
10758
|
|
|
10744
|
-
// ../node_modules
|
|
10759
|
+
// ../node_modules/jose/dist/browser/runtime/get_sign_verify_key.js
|
|
10745
10760
|
function getCryptoKey(alg, key3, usage2) {
|
|
10746
10761
|
if (isCryptoKey(key3)) {
|
|
10747
10762
|
checkSigCryptoKey(key3, alg, usage2);
|
|
@@ -10756,21 +10771,22 @@ function getCryptoKey(alg, key3, usage2) {
|
|
|
10756
10771
|
throw new TypeError(invalid_key_input_default(key3, ...types, "Uint8Array"));
|
|
10757
10772
|
}
|
|
10758
10773
|
|
|
10759
|
-
// ../node_modules
|
|
10774
|
+
// ../node_modules/jose/dist/browser/runtime/verify.js
|
|
10760
10775
|
var verify = async (alg, key3, signature2, data2) => {
|
|
10761
10776
|
const cryptoKey = await getCryptoKey(alg, key3, "verify");
|
|
10762
10777
|
check_key_length_default(alg, cryptoKey);
|
|
10763
10778
|
const algorithm3 = subtleDsa(alg, cryptoKey.algorithm);
|
|
10764
10779
|
try {
|
|
10765
10780
|
return await webcrypto_default.subtle.verify(algorithm3, cryptoKey, signature2, data2);
|
|
10766
|
-
} catch {
|
|
10781
|
+
} catch (_a) {
|
|
10767
10782
|
return false;
|
|
10768
10783
|
}
|
|
10769
10784
|
};
|
|
10770
10785
|
var verify_default = verify;
|
|
10771
10786
|
|
|
10772
|
-
// ../node_modules
|
|
10787
|
+
// ../node_modules/jose/dist/browser/jws/flattened/verify.js
|
|
10773
10788
|
async function flattenedVerify(jws2, key3, options) {
|
|
10789
|
+
var _a;
|
|
10774
10790
|
if (!isObject(jws2)) {
|
|
10775
10791
|
throw new JWSInvalid("Flattened JWS must be an object");
|
|
10776
10792
|
}
|
|
@@ -10794,7 +10810,7 @@ async function flattenedVerify(jws2, key3, options) {
|
|
|
10794
10810
|
try {
|
|
10795
10811
|
const protectedHeader = decode(jws2.protected);
|
|
10796
10812
|
parsedProt = JSON.parse(decoder.decode(protectedHeader));
|
|
10797
|
-
} catch {
|
|
10813
|
+
} catch (_b) {
|
|
10798
10814
|
throw new JWSInvalid("JWS Protected Header is invalid");
|
|
10799
10815
|
}
|
|
10800
10816
|
}
|
|
@@ -10805,7 +10821,7 @@ async function flattenedVerify(jws2, key3, options) {
|
|
|
10805
10821
|
...parsedProt,
|
|
10806
10822
|
...jws2.header
|
|
10807
10823
|
};
|
|
10808
|
-
const extensions = validate_crit_default(JWSInvalid, /* @__PURE__ */ new Map([["b64", true]]), options
|
|
10824
|
+
const extensions = validate_crit_default(JWSInvalid, /* @__PURE__ */ new Map([["b64", true]]), options === null || options === void 0 ? void 0 : options.crit, parsedProt, joseHeader);
|
|
10809
10825
|
let b64 = true;
|
|
10810
10826
|
if (extensions.has("b64")) {
|
|
10811
10827
|
b64 = parsedProt.b64;
|
|
@@ -10819,7 +10835,7 @@ async function flattenedVerify(jws2, key3, options) {
|
|
|
10819
10835
|
}
|
|
10820
10836
|
const algorithms = options && validate_algorithms_default("algorithms", options.algorithms);
|
|
10821
10837
|
if (algorithms && !algorithms.has(alg)) {
|
|
10822
|
-
throw new JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter
|
|
10838
|
+
throw new JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter not allowed');
|
|
10823
10839
|
}
|
|
10824
10840
|
if (b64) {
|
|
10825
10841
|
if (typeof jws2.payload !== "string") {
|
|
@@ -10834,11 +10850,11 @@ async function flattenedVerify(jws2, key3, options) {
|
|
|
10834
10850
|
resolvedKey = true;
|
|
10835
10851
|
}
|
|
10836
10852
|
check_key_type_default(alg, key3, "verify");
|
|
10837
|
-
const data2 = concat(encoder.encode(jws2.protected
|
|
10853
|
+
const data2 = concat(encoder.encode((_a = jws2.protected) !== null && _a !== void 0 ? _a : ""), encoder.encode("."), typeof jws2.payload === "string" ? encoder.encode(jws2.payload) : jws2.payload);
|
|
10838
10854
|
let signature2;
|
|
10839
10855
|
try {
|
|
10840
10856
|
signature2 = decode(jws2.signature);
|
|
10841
|
-
} catch {
|
|
10857
|
+
} catch (_c) {
|
|
10842
10858
|
throw new JWSInvalid("Failed to base64url decode the signature");
|
|
10843
10859
|
}
|
|
10844
10860
|
const verified2 = await verify_default(alg, key3, signature2, data2);
|
|
@@ -10849,7 +10865,7 @@ async function flattenedVerify(jws2, key3, options) {
|
|
|
10849
10865
|
if (b64) {
|
|
10850
10866
|
try {
|
|
10851
10867
|
payload4 = decode(jws2.payload);
|
|
10852
|
-
} catch {
|
|
10868
|
+
} catch (_d) {
|
|
10853
10869
|
throw new JWSInvalid("Failed to base64url decode the payload");
|
|
10854
10870
|
}
|
|
10855
10871
|
} else if (typeof jws2.payload === "string") {
|
|
@@ -10870,7 +10886,7 @@ async function flattenedVerify(jws2, key3, options) {
|
|
|
10870
10886
|
return result5;
|
|
10871
10887
|
}
|
|
10872
10888
|
|
|
10873
|
-
// ../node_modules
|
|
10889
|
+
// ../node_modules/jose/dist/browser/jws/compact/verify.js
|
|
10874
10890
|
async function compactVerify(jws2, key3, options) {
|
|
10875
10891
|
if (jws2 instanceof Uint8Array) {
|
|
10876
10892
|
jws2 = decoder.decode(jws2);
|
|
@@ -10890,67 +10906,56 @@ async function compactVerify(jws2, key3, options) {
|
|
|
10890
10906
|
return result5;
|
|
10891
10907
|
}
|
|
10892
10908
|
|
|
10893
|
-
// ../node_modules
|
|
10909
|
+
// ../node_modules/jose/dist/browser/lib/epoch.js
|
|
10894
10910
|
var epoch_default = (date5) => Math.floor(date5.getTime() / 1e3);
|
|
10895
10911
|
|
|
10896
|
-
// ../node_modules
|
|
10912
|
+
// ../node_modules/jose/dist/browser/lib/secs.js
|
|
10897
10913
|
var minute = 60;
|
|
10898
10914
|
var hour = minute * 60;
|
|
10899
10915
|
var day = hour * 24;
|
|
10900
10916
|
var week = day * 7;
|
|
10901
10917
|
var year = day * 365.25;
|
|
10902
|
-
var REGEX = /^(
|
|
10918
|
+
var REGEX = /^(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i;
|
|
10903
10919
|
var secs_default = (str) => {
|
|
10904
10920
|
const matched = REGEX.exec(str);
|
|
10905
|
-
if (!matched
|
|
10921
|
+
if (!matched) {
|
|
10906
10922
|
throw new TypeError("Invalid time period format");
|
|
10907
10923
|
}
|
|
10908
|
-
const value6 = parseFloat(matched[
|
|
10909
|
-
const unit2 = matched[
|
|
10910
|
-
let numericDate;
|
|
10924
|
+
const value6 = parseFloat(matched[1]);
|
|
10925
|
+
const unit2 = matched[2].toLowerCase();
|
|
10911
10926
|
switch (unit2) {
|
|
10912
10927
|
case "sec":
|
|
10913
10928
|
case "secs":
|
|
10914
10929
|
case "second":
|
|
10915
10930
|
case "seconds":
|
|
10916
10931
|
case "s":
|
|
10917
|
-
|
|
10918
|
-
break;
|
|
10932
|
+
return Math.round(value6);
|
|
10919
10933
|
case "minute":
|
|
10920
10934
|
case "minutes":
|
|
10921
10935
|
case "min":
|
|
10922
10936
|
case "mins":
|
|
10923
10937
|
case "m":
|
|
10924
|
-
|
|
10925
|
-
break;
|
|
10938
|
+
return Math.round(value6 * minute);
|
|
10926
10939
|
case "hour":
|
|
10927
10940
|
case "hours":
|
|
10928
10941
|
case "hr":
|
|
10929
10942
|
case "hrs":
|
|
10930
10943
|
case "h":
|
|
10931
|
-
|
|
10932
|
-
break;
|
|
10944
|
+
return Math.round(value6 * hour);
|
|
10933
10945
|
case "day":
|
|
10934
10946
|
case "days":
|
|
10935
10947
|
case "d":
|
|
10936
|
-
|
|
10937
|
-
break;
|
|
10948
|
+
return Math.round(value6 * day);
|
|
10938
10949
|
case "week":
|
|
10939
10950
|
case "weeks":
|
|
10940
10951
|
case "w":
|
|
10941
|
-
|
|
10942
|
-
break;
|
|
10952
|
+
return Math.round(value6 * week);
|
|
10943
10953
|
default:
|
|
10944
|
-
|
|
10945
|
-
break;
|
|
10946
|
-
}
|
|
10947
|
-
if (matched[1] === "-" || matched[4] === "ago") {
|
|
10948
|
-
return -numericDate;
|
|
10954
|
+
return Math.round(value6 * year);
|
|
10949
10955
|
}
|
|
10950
|
-
return numericDate;
|
|
10951
10956
|
};
|
|
10952
10957
|
|
|
10953
|
-
// ../node_modules
|
|
10958
|
+
// ../node_modules/jose/dist/browser/lib/jwt_claims_set.js
|
|
10954
10959
|
var normalizeTyp = (value6) => value6.toLowerCase().replace(/^application\//, "");
|
|
10955
10960
|
var checkAudiencePresence = (audPayload, audOption) => {
|
|
10956
10961
|
if (typeof audPayload === "string") {
|
|
@@ -10969,22 +10974,21 @@ var jwt_claims_set_default = (protectedHeader, encodedPayload, options = {}) =>
|
|
|
10969
10974
|
let payload4;
|
|
10970
10975
|
try {
|
|
10971
10976
|
payload4 = JSON.parse(decoder.decode(encodedPayload));
|
|
10972
|
-
} catch {
|
|
10977
|
+
} catch (_a) {
|
|
10973
10978
|
}
|
|
10974
10979
|
if (!isObject(payload4)) {
|
|
10975
10980
|
throw new JWTInvalid("JWT Claims Set must be a top-level JSON object");
|
|
10976
10981
|
}
|
|
10977
10982
|
const { requiredClaims = [], issuer: issuer2, subject: subject5, audience: audience5, maxTokenAge } = options;
|
|
10978
|
-
const presenceCheck = [...requiredClaims];
|
|
10979
10983
|
if (maxTokenAge !== void 0)
|
|
10980
|
-
|
|
10984
|
+
requiredClaims.push("iat");
|
|
10981
10985
|
if (audience5 !== void 0)
|
|
10982
|
-
|
|
10986
|
+
requiredClaims.push("aud");
|
|
10983
10987
|
if (subject5 !== void 0)
|
|
10984
|
-
|
|
10988
|
+
requiredClaims.push("sub");
|
|
10985
10989
|
if (issuer2 !== void 0)
|
|
10986
|
-
|
|
10987
|
-
for (const claim2 of new Set(
|
|
10990
|
+
requiredClaims.push("iss");
|
|
10991
|
+
for (const claim2 of new Set(requiredClaims.reverse())) {
|
|
10988
10992
|
if (!(claim2 in payload4)) {
|
|
10989
10993
|
throw new JWTClaimValidationFailed(`missing required "${claim2}" claim`, claim2, "missing");
|
|
10990
10994
|
}
|
|
@@ -11046,10 +11050,11 @@ var jwt_claims_set_default = (protectedHeader, encodedPayload, options = {}) =>
|
|
|
11046
11050
|
return payload4;
|
|
11047
11051
|
};
|
|
11048
11052
|
|
|
11049
|
-
// ../node_modules
|
|
11053
|
+
// ../node_modules/jose/dist/browser/jwt/verify.js
|
|
11050
11054
|
async function jwtVerify(jwt, key3, options) {
|
|
11055
|
+
var _a;
|
|
11051
11056
|
const verified2 = await compactVerify(jwt, key3, options);
|
|
11052
|
-
if (verified2.protectedHeader.crit
|
|
11057
|
+
if (((_a = verified2.protectedHeader.crit) === null || _a === void 0 ? void 0 : _a.includes("b64")) && verified2.protectedHeader.b64 === false) {
|
|
11053
11058
|
throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
|
|
11054
11059
|
}
|
|
11055
11060
|
const payload4 = jwt_claims_set_default(verified2.protectedHeader, verified2.payload, options);
|
|
@@ -11060,7 +11065,7 @@ async function jwtVerify(jwt, key3, options) {
|
|
|
11060
11065
|
return result5;
|
|
11061
11066
|
}
|
|
11062
11067
|
|
|
11063
|
-
// ../node_modules
|
|
11068
|
+
// ../node_modules/jose/dist/browser/runtime/sign.js
|
|
11064
11069
|
var sign = async (alg, key3, data2) => {
|
|
11065
11070
|
const cryptoKey = await getCryptoKey(alg, key3, "sign");
|
|
11066
11071
|
check_key_length_default(alg, cryptoKey);
|
|
@@ -11069,7 +11074,7 @@ var sign = async (alg, key3, data2) => {
|
|
|
11069
11074
|
};
|
|
11070
11075
|
var sign_default = sign;
|
|
11071
11076
|
|
|
11072
|
-
// ../node_modules
|
|
11077
|
+
// ../node_modules/jose/dist/browser/jws/flattened/sign.js
|
|
11073
11078
|
var FlattenedSign = class {
|
|
11074
11079
|
constructor(payload4) {
|
|
11075
11080
|
if (!(payload4 instanceof Uint8Array)) {
|
|
@@ -11102,7 +11107,7 @@ var FlattenedSign = class {
|
|
|
11102
11107
|
...this._protectedHeader,
|
|
11103
11108
|
...this._unprotectedHeader
|
|
11104
11109
|
};
|
|
11105
|
-
const extensions = validate_crit_default(JWSInvalid, /* @__PURE__ */ new Map([["b64", true]]), options
|
|
11110
|
+
const extensions = validate_crit_default(JWSInvalid, /* @__PURE__ */ new Map([["b64", true]]), options === null || options === void 0 ? void 0 : options.crit, this._protectedHeader, joseHeader);
|
|
11106
11111
|
let b64 = true;
|
|
11107
11112
|
if (extensions.has("b64")) {
|
|
11108
11113
|
b64 = this._protectedHeader.b64;
|
|
@@ -11144,7 +11149,7 @@ var FlattenedSign = class {
|
|
|
11144
11149
|
}
|
|
11145
11150
|
};
|
|
11146
11151
|
|
|
11147
|
-
// ../node_modules
|
|
11152
|
+
// ../node_modules/jose/dist/browser/jws/compact/sign.js
|
|
11148
11153
|
var CompactSign = class {
|
|
11149
11154
|
constructor(payload4) {
|
|
11150
11155
|
this._flattened = new FlattenedSign(payload4);
|
|
@@ -11162,15 +11167,9 @@ var CompactSign = class {
|
|
|
11162
11167
|
}
|
|
11163
11168
|
};
|
|
11164
11169
|
|
|
11165
|
-
// ../node_modules
|
|
11166
|
-
function validateInput(label4, input2) {
|
|
11167
|
-
if (!Number.isFinite(input2)) {
|
|
11168
|
-
throw new TypeError(`Invalid ${label4} input`);
|
|
11169
|
-
}
|
|
11170
|
-
return input2;
|
|
11171
|
-
}
|
|
11170
|
+
// ../node_modules/jose/dist/browser/jwt/produce.js
|
|
11172
11171
|
var ProduceJWT = class {
|
|
11173
|
-
constructor(payload4
|
|
11172
|
+
constructor(payload4) {
|
|
11174
11173
|
if (!isObject(payload4)) {
|
|
11175
11174
|
throw new TypeError("JWT Claims Set MUST be an object");
|
|
11176
11175
|
}
|
|
@@ -11194,9 +11193,7 @@ var ProduceJWT = class {
|
|
|
11194
11193
|
}
|
|
11195
11194
|
setNotBefore(input2) {
|
|
11196
11195
|
if (typeof input2 === "number") {
|
|
11197
|
-
this._payload = { ...this._payload, nbf:
|
|
11198
|
-
} else if (input2 instanceof Date) {
|
|
11199
|
-
this._payload = { ...this._payload, nbf: validateInput("setNotBefore", epoch_default(input2)) };
|
|
11196
|
+
this._payload = { ...this._payload, nbf: input2 };
|
|
11200
11197
|
} else {
|
|
11201
11198
|
this._payload = { ...this._payload, nbf: epoch_default(/* @__PURE__ */ new Date()) + secs_default(input2) };
|
|
11202
11199
|
}
|
|
@@ -11204,9 +11201,7 @@ var ProduceJWT = class {
|
|
|
11204
11201
|
}
|
|
11205
11202
|
setExpirationTime(input2) {
|
|
11206
11203
|
if (typeof input2 === "number") {
|
|
11207
|
-
this._payload = { ...this._payload, exp:
|
|
11208
|
-
} else if (input2 instanceof Date) {
|
|
11209
|
-
this._payload = { ...this._payload, exp: validateInput("setExpirationTime", epoch_default(input2)) };
|
|
11204
|
+
this._payload = { ...this._payload, exp: input2 };
|
|
11210
11205
|
} else {
|
|
11211
11206
|
this._payload = { ...this._payload, exp: epoch_default(/* @__PURE__ */ new Date()) + secs_default(input2) };
|
|
11212
11207
|
}
|
|
@@ -11215,294 +11210,41 @@ var ProduceJWT = class {
|
|
|
11215
11210
|
setIssuedAt(input2) {
|
|
11216
11211
|
if (typeof input2 === "undefined") {
|
|
11217
11212
|
this._payload = { ...this._payload, iat: epoch_default(/* @__PURE__ */ new Date()) };
|
|
11218
|
-
} else if (input2 instanceof Date) {
|
|
11219
|
-
this._payload = { ...this._payload, iat: validateInput("setIssuedAt", epoch_default(input2)) };
|
|
11220
|
-
} else if (typeof input2 === "string") {
|
|
11221
|
-
this._payload = {
|
|
11222
|
-
...this._payload,
|
|
11223
|
-
iat: validateInput("setIssuedAt", epoch_default(/* @__PURE__ */ new Date()) + secs_default(input2))
|
|
11224
|
-
};
|
|
11225
11213
|
} else {
|
|
11226
|
-
this._payload = { ...this._payload, iat:
|
|
11214
|
+
this._payload = { ...this._payload, iat: input2 };
|
|
11227
11215
|
}
|
|
11228
11216
|
return this;
|
|
11229
11217
|
}
|
|
11230
11218
|
};
|
|
11231
11219
|
|
|
11232
|
-
// ../node_modules
|
|
11220
|
+
// ../node_modules/jose/dist/browser/jwt/sign.js
|
|
11233
11221
|
var SignJWT = class extends ProduceJWT {
|
|
11234
11222
|
setProtectedHeader(protectedHeader) {
|
|
11235
11223
|
this._protectedHeader = protectedHeader;
|
|
11236
11224
|
return this;
|
|
11237
11225
|
}
|
|
11238
11226
|
async sign(key3, options) {
|
|
11227
|
+
var _a;
|
|
11239
11228
|
const sig = new CompactSign(encoder.encode(JSON.stringify(this._payload)));
|
|
11240
11229
|
sig.setProtectedHeader(this._protectedHeader);
|
|
11241
|
-
if (Array.isArray(this._protectedHeader
|
|
11230
|
+
if (Array.isArray((_a = this._protectedHeader) === null || _a === void 0 ? void 0 : _a.crit) && this._protectedHeader.crit.includes("b64") && this._protectedHeader.b64 === false) {
|
|
11242
11231
|
throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
|
|
11243
11232
|
}
|
|
11244
11233
|
return sig.sign(key3, options);
|
|
11245
11234
|
}
|
|
11246
11235
|
};
|
|
11247
11236
|
|
|
11248
|
-
// ../node_modules
|
|
11249
|
-
function getKtyFromAlg(alg) {
|
|
11250
|
-
switch (typeof alg === "string" && alg.slice(0, 2)) {
|
|
11251
|
-
case "RS":
|
|
11252
|
-
case "PS":
|
|
11253
|
-
return "RSA";
|
|
11254
|
-
case "ES":
|
|
11255
|
-
return "EC";
|
|
11256
|
-
case "Ed":
|
|
11257
|
-
return "OKP";
|
|
11258
|
-
default:
|
|
11259
|
-
throw new JOSENotSupported('Unsupported "alg" value for a JSON Web Key Set');
|
|
11260
|
-
}
|
|
11261
|
-
}
|
|
11262
|
-
function isJWKSLike(jwks) {
|
|
11263
|
-
return jwks && typeof jwks === "object" && Array.isArray(jwks.keys) && jwks.keys.every(isJWKLike);
|
|
11264
|
-
}
|
|
11265
|
-
function isJWKLike(key3) {
|
|
11266
|
-
return isObject(key3);
|
|
11267
|
-
}
|
|
11268
|
-
function clone(obj) {
|
|
11269
|
-
if (typeof structuredClone === "function") {
|
|
11270
|
-
return structuredClone(obj);
|
|
11271
|
-
}
|
|
11272
|
-
return JSON.parse(JSON.stringify(obj));
|
|
11273
|
-
}
|
|
11274
|
-
var LocalJWKSet = class {
|
|
11275
|
-
constructor(jwks) {
|
|
11276
|
-
this._cached = /* @__PURE__ */ new WeakMap();
|
|
11277
|
-
if (!isJWKSLike(jwks)) {
|
|
11278
|
-
throw new JWKSInvalid("JSON Web Key Set malformed");
|
|
11279
|
-
}
|
|
11280
|
-
this._jwks = clone(jwks);
|
|
11281
|
-
}
|
|
11282
|
-
async getKey(protectedHeader, token) {
|
|
11283
|
-
const { alg, kid } = { ...protectedHeader, ...token?.header };
|
|
11284
|
-
const kty = getKtyFromAlg(alg);
|
|
11285
|
-
const candidates = this._jwks.keys.filter((jwk2) => {
|
|
11286
|
-
let candidate4 = kty === jwk2.kty;
|
|
11287
|
-
if (candidate4 && typeof kid === "string") {
|
|
11288
|
-
candidate4 = kid === jwk2.kid;
|
|
11289
|
-
}
|
|
11290
|
-
if (candidate4 && typeof jwk2.alg === "string") {
|
|
11291
|
-
candidate4 = alg === jwk2.alg;
|
|
11292
|
-
}
|
|
11293
|
-
if (candidate4 && typeof jwk2.use === "string") {
|
|
11294
|
-
candidate4 = jwk2.use === "sig";
|
|
11295
|
-
}
|
|
11296
|
-
if (candidate4 && Array.isArray(jwk2.key_ops)) {
|
|
11297
|
-
candidate4 = jwk2.key_ops.includes("verify");
|
|
11298
|
-
}
|
|
11299
|
-
if (candidate4 && alg === "EdDSA") {
|
|
11300
|
-
candidate4 = jwk2.crv === "Ed25519" || jwk2.crv === "Ed448";
|
|
11301
|
-
}
|
|
11302
|
-
if (candidate4) {
|
|
11303
|
-
switch (alg) {
|
|
11304
|
-
case "ES256":
|
|
11305
|
-
candidate4 = jwk2.crv === "P-256";
|
|
11306
|
-
break;
|
|
11307
|
-
case "ES256K":
|
|
11308
|
-
candidate4 = jwk2.crv === "secp256k1";
|
|
11309
|
-
break;
|
|
11310
|
-
case "ES384":
|
|
11311
|
-
candidate4 = jwk2.crv === "P-384";
|
|
11312
|
-
break;
|
|
11313
|
-
case "ES512":
|
|
11314
|
-
candidate4 = jwk2.crv === "P-521";
|
|
11315
|
-
break;
|
|
11316
|
-
}
|
|
11317
|
-
}
|
|
11318
|
-
return candidate4;
|
|
11319
|
-
});
|
|
11320
|
-
const { 0: jwk, length: length2 } = candidates;
|
|
11321
|
-
if (length2 === 0) {
|
|
11322
|
-
throw new JWKSNoMatchingKey();
|
|
11323
|
-
}
|
|
11324
|
-
if (length2 !== 1) {
|
|
11325
|
-
const error4 = new JWKSMultipleMatchingKeys();
|
|
11326
|
-
const { _cached } = this;
|
|
11327
|
-
error4[Symbol.asyncIterator] = async function* () {
|
|
11328
|
-
for (const jwk2 of candidates) {
|
|
11329
|
-
try {
|
|
11330
|
-
yield await importWithAlgCache(_cached, jwk2, alg);
|
|
11331
|
-
} catch {
|
|
11332
|
-
}
|
|
11333
|
-
}
|
|
11334
|
-
};
|
|
11335
|
-
throw error4;
|
|
11336
|
-
}
|
|
11337
|
-
return importWithAlgCache(this._cached, jwk, alg);
|
|
11338
|
-
}
|
|
11339
|
-
};
|
|
11340
|
-
async function importWithAlgCache(cache, jwk, alg) {
|
|
11341
|
-
const cached = cache.get(jwk) || cache.set(jwk, {}).get(jwk);
|
|
11342
|
-
if (cached[alg] === void 0) {
|
|
11343
|
-
const key3 = await importJWK({ ...jwk, ext: true }, alg);
|
|
11344
|
-
if (key3 instanceof Uint8Array || key3.type !== "public") {
|
|
11345
|
-
throw new JWKSInvalid("JSON Web Key Set members must be public keys");
|
|
11346
|
-
}
|
|
11347
|
-
cached[alg] = key3;
|
|
11348
|
-
}
|
|
11349
|
-
return cached[alg];
|
|
11350
|
-
}
|
|
11351
|
-
function createLocalJWKSet(jwks) {
|
|
11352
|
-
const set = new LocalJWKSet(jwks);
|
|
11353
|
-
const localJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);
|
|
11354
|
-
Object.defineProperties(localJWKSet, {
|
|
11355
|
-
jwks: {
|
|
11356
|
-
value: () => clone(set._jwks),
|
|
11357
|
-
enumerable: true,
|
|
11358
|
-
configurable: false,
|
|
11359
|
-
writable: false
|
|
11360
|
-
}
|
|
11361
|
-
});
|
|
11362
|
-
return localJWKSet;
|
|
11363
|
-
}
|
|
11364
|
-
|
|
11365
|
-
// ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/runtime/fetch_jwks.js
|
|
11366
|
-
var fetchJwks = async (url7, timeout2, options) => {
|
|
11367
|
-
let controller2;
|
|
11368
|
-
let id4;
|
|
11369
|
-
let timedOut = false;
|
|
11370
|
-
if (typeof AbortController === "function") {
|
|
11371
|
-
controller2 = new AbortController();
|
|
11372
|
-
id4 = setTimeout(() => {
|
|
11373
|
-
timedOut = true;
|
|
11374
|
-
controller2.abort();
|
|
11375
|
-
}, timeout2);
|
|
11376
|
-
}
|
|
11377
|
-
const response6 = await fetch(url7.href, {
|
|
11378
|
-
signal: controller2 ? controller2.signal : void 0,
|
|
11379
|
-
redirect: "manual",
|
|
11380
|
-
headers: options.headers
|
|
11381
|
-
}).catch((err) => {
|
|
11382
|
-
if (timedOut)
|
|
11383
|
-
throw new JWKSTimeout();
|
|
11384
|
-
throw err;
|
|
11385
|
-
});
|
|
11386
|
-
if (id4 !== void 0)
|
|
11387
|
-
clearTimeout(id4);
|
|
11388
|
-
if (response6.status !== 200) {
|
|
11389
|
-
throw new JOSEError("Expected 200 OK from the JSON Web Key Set HTTP response");
|
|
11390
|
-
}
|
|
11391
|
-
try {
|
|
11392
|
-
return await response6.json();
|
|
11393
|
-
} catch {
|
|
11394
|
-
throw new JOSEError("Failed to parse the JSON Web Key Set HTTP response as JSON");
|
|
11395
|
-
}
|
|
11396
|
-
};
|
|
11397
|
-
var fetch_jwks_default = fetchJwks;
|
|
11398
|
-
|
|
11399
|
-
// ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/jwks/remote.js
|
|
11400
|
-
function isCloudflareWorkers() {
|
|
11401
|
-
return typeof WebSocketPair !== "undefined" || typeof navigator !== "undefined" && navigator.userAgent === "Cloudflare-Workers" || typeof EdgeRuntime !== "undefined" && EdgeRuntime === "vercel";
|
|
11402
|
-
}
|
|
11403
|
-
var USER_AGENT;
|
|
11404
|
-
if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) {
|
|
11405
|
-
const NAME = "jose";
|
|
11406
|
-
const VERSION = "v5.3.0";
|
|
11407
|
-
USER_AGENT = `${NAME}/${VERSION}`;
|
|
11408
|
-
}
|
|
11409
|
-
var RemoteJWKSet = class {
|
|
11410
|
-
constructor(url7, options) {
|
|
11411
|
-
if (!(url7 instanceof URL)) {
|
|
11412
|
-
throw new TypeError("url must be an instance of URL");
|
|
11413
|
-
}
|
|
11414
|
-
this._url = new URL(url7.href);
|
|
11415
|
-
this._options = { agent: options?.agent, headers: options?.headers };
|
|
11416
|
-
this._timeoutDuration = typeof options?.timeoutDuration === "number" ? options?.timeoutDuration : 5e3;
|
|
11417
|
-
this._cooldownDuration = typeof options?.cooldownDuration === "number" ? options?.cooldownDuration : 3e4;
|
|
11418
|
-
this._cacheMaxAge = typeof options?.cacheMaxAge === "number" ? options?.cacheMaxAge : 6e5;
|
|
11419
|
-
}
|
|
11420
|
-
coolingDown() {
|
|
11421
|
-
return typeof this._jwksTimestamp === "number" ? Date.now() < this._jwksTimestamp + this._cooldownDuration : false;
|
|
11422
|
-
}
|
|
11423
|
-
fresh() {
|
|
11424
|
-
return typeof this._jwksTimestamp === "number" ? Date.now() < this._jwksTimestamp + this._cacheMaxAge : false;
|
|
11425
|
-
}
|
|
11426
|
-
async getKey(protectedHeader, token) {
|
|
11427
|
-
if (!this._local || !this.fresh()) {
|
|
11428
|
-
await this.reload();
|
|
11429
|
-
}
|
|
11430
|
-
try {
|
|
11431
|
-
return await this._local(protectedHeader, token);
|
|
11432
|
-
} catch (err) {
|
|
11433
|
-
if (err instanceof JWKSNoMatchingKey) {
|
|
11434
|
-
if (this.coolingDown() === false) {
|
|
11435
|
-
await this.reload();
|
|
11436
|
-
return this._local(protectedHeader, token);
|
|
11437
|
-
}
|
|
11438
|
-
}
|
|
11439
|
-
throw err;
|
|
11440
|
-
}
|
|
11441
|
-
}
|
|
11442
|
-
async reload() {
|
|
11443
|
-
if (this._pendingFetch && isCloudflareWorkers()) {
|
|
11444
|
-
this._pendingFetch = void 0;
|
|
11445
|
-
}
|
|
11446
|
-
const headers = new Headers(this._options.headers);
|
|
11447
|
-
if (USER_AGENT && !headers.has("User-Agent")) {
|
|
11448
|
-
headers.set("User-Agent", USER_AGENT);
|
|
11449
|
-
this._options.headers = Object.fromEntries(headers.entries());
|
|
11450
|
-
}
|
|
11451
|
-
this._pendingFetch || (this._pendingFetch = fetch_jwks_default(this._url, this._timeoutDuration, this._options).then((json) => {
|
|
11452
|
-
this._local = createLocalJWKSet(json);
|
|
11453
|
-
this._jwksTimestamp = Date.now();
|
|
11454
|
-
this._pendingFetch = void 0;
|
|
11455
|
-
}).catch((err) => {
|
|
11456
|
-
this._pendingFetch = void 0;
|
|
11457
|
-
throw err;
|
|
11458
|
-
}));
|
|
11459
|
-
await this._pendingFetch;
|
|
11460
|
-
}
|
|
11461
|
-
};
|
|
11462
|
-
function createRemoteJWKSet(url7, options) {
|
|
11463
|
-
const set = new RemoteJWKSet(url7, options);
|
|
11464
|
-
const remoteJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);
|
|
11465
|
-
Object.defineProperties(remoteJWKSet, {
|
|
11466
|
-
coolingDown: {
|
|
11467
|
-
get: () => set.coolingDown(),
|
|
11468
|
-
enumerable: true,
|
|
11469
|
-
configurable: false
|
|
11470
|
-
},
|
|
11471
|
-
fresh: {
|
|
11472
|
-
get: () => set.fresh(),
|
|
11473
|
-
enumerable: true,
|
|
11474
|
-
configurable: false
|
|
11475
|
-
},
|
|
11476
|
-
reload: {
|
|
11477
|
-
value: () => set.reload(),
|
|
11478
|
-
enumerable: true,
|
|
11479
|
-
configurable: false,
|
|
11480
|
-
writable: false
|
|
11481
|
-
},
|
|
11482
|
-
reloading: {
|
|
11483
|
-
get: () => !!set._pendingFetch,
|
|
11484
|
-
enumerable: true,
|
|
11485
|
-
configurable: false
|
|
11486
|
-
},
|
|
11487
|
-
jwks: {
|
|
11488
|
-
value: () => set._local?.jwks(),
|
|
11489
|
-
enumerable: true,
|
|
11490
|
-
configurable: false,
|
|
11491
|
-
writable: false
|
|
11492
|
-
}
|
|
11493
|
-
});
|
|
11494
|
-
return remoteJWKSet;
|
|
11495
|
-
}
|
|
11496
|
-
|
|
11497
|
-
// ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/runtime/generate.js
|
|
11237
|
+
// ../node_modules/jose/dist/browser/runtime/generate.js
|
|
11498
11238
|
function getModulusLengthOption(options) {
|
|
11499
|
-
|
|
11239
|
+
var _a;
|
|
11240
|
+
const modulusLength = (_a = options === null || options === void 0 ? void 0 : options.modulusLength) !== null && _a !== void 0 ? _a : 2048;
|
|
11500
11241
|
if (typeof modulusLength !== "number" || modulusLength < 2048) {
|
|
11501
11242
|
throw new JOSENotSupported("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");
|
|
11502
11243
|
}
|
|
11503
11244
|
return modulusLength;
|
|
11504
11245
|
}
|
|
11505
11246
|
async function generateKeyPair(alg, options) {
|
|
11247
|
+
var _a, _b, _c;
|
|
11506
11248
|
let algorithm3;
|
|
11507
11249
|
let keyUsages;
|
|
11508
11250
|
switch (alg) {
|
|
@@ -11552,9 +11294,9 @@ async function generateKeyPair(alg, options) {
|
|
|
11552
11294
|
algorithm3 = { name: "ECDSA", namedCurve: "P-521" };
|
|
11553
11295
|
keyUsages = ["sign", "verify"];
|
|
11554
11296
|
break;
|
|
11555
|
-
case "EdDSA":
|
|
11297
|
+
case "EdDSA":
|
|
11556
11298
|
keyUsages = ["sign", "verify"];
|
|
11557
|
-
const crv = options
|
|
11299
|
+
const crv = (_a = options === null || options === void 0 ? void 0 : options.crv) !== null && _a !== void 0 ? _a : "Ed25519";
|
|
11558
11300
|
switch (crv) {
|
|
11559
11301
|
case "Ed25519":
|
|
11560
11302
|
case "Ed448":
|
|
@@ -11564,23 +11306,22 @@ async function generateKeyPair(alg, options) {
|
|
|
11564
11306
|
throw new JOSENotSupported("Invalid or unsupported crv option provided");
|
|
11565
11307
|
}
|
|
11566
11308
|
break;
|
|
11567
|
-
}
|
|
11568
11309
|
case "ECDH-ES":
|
|
11569
11310
|
case "ECDH-ES+A128KW":
|
|
11570
11311
|
case "ECDH-ES+A192KW":
|
|
11571
11312
|
case "ECDH-ES+A256KW": {
|
|
11572
11313
|
keyUsages = ["deriveKey", "deriveBits"];
|
|
11573
|
-
const
|
|
11574
|
-
switch (
|
|
11314
|
+
const crv2 = (_b = options === null || options === void 0 ? void 0 : options.crv) !== null && _b !== void 0 ? _b : "P-256";
|
|
11315
|
+
switch (crv2) {
|
|
11575
11316
|
case "P-256":
|
|
11576
11317
|
case "P-384":
|
|
11577
11318
|
case "P-521": {
|
|
11578
|
-
algorithm3 = { name: "ECDH", namedCurve:
|
|
11319
|
+
algorithm3 = { name: "ECDH", namedCurve: crv2 };
|
|
11579
11320
|
break;
|
|
11580
11321
|
}
|
|
11581
11322
|
case "X25519":
|
|
11582
11323
|
case "X448":
|
|
11583
|
-
algorithm3 = { name:
|
|
11324
|
+
algorithm3 = { name: crv2 };
|
|
11584
11325
|
break;
|
|
11585
11326
|
default:
|
|
11586
11327
|
throw new JOSENotSupported("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, X25519, and X448");
|
|
@@ -11590,10 +11331,10 @@ async function generateKeyPair(alg, options) {
|
|
|
11590
11331
|
default:
|
|
11591
11332
|
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
11592
11333
|
}
|
|
11593
|
-
return webcrypto_default.subtle.generateKey(algorithm3, options
|
|
11334
|
+
return webcrypto_default.subtle.generateKey(algorithm3, (_c = options === null || options === void 0 ? void 0 : options.extractable) !== null && _c !== void 0 ? _c : false, keyUsages);
|
|
11594
11335
|
}
|
|
11595
11336
|
|
|
11596
|
-
// ../node_modules
|
|
11337
|
+
// ../node_modules/jose/dist/browser/key/generate_key_pair.js
|
|
11597
11338
|
async function generateKeyPair2(alg, options) {
|
|
11598
11339
|
return generateKeyPair(alg, options);
|
|
11599
11340
|
}
|
|
@@ -11665,6 +11406,17 @@ var SCOPE_OPENID = "openid";
|
|
|
11665
11406
|
var SCOPE_OFFLINE = "offline_access";
|
|
11666
11407
|
var SCOPE_WEBID = "webid";
|
|
11667
11408
|
var DEFAULT_SCOPES = [SCOPE_OPENID, SCOPE_OFFLINE, SCOPE_WEBID].join(" ");
|
|
11409
|
+
var buildProxyHandler = (toExclude, errorMessage) => ({
|
|
11410
|
+
// This proxy is only a temporary measure until Session no longer extends
|
|
11411
|
+
// SessionEventEmitter, and the proxying is no longer necessary.
|
|
11412
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11413
|
+
get(target5, prop, receiver2) {
|
|
11414
|
+
if (!Object.getOwnPropertyNames(import_events.EventEmitter).includes(prop) && Object.getOwnPropertyNames(toExclude).includes(prop)) {
|
|
11415
|
+
throw new Error(`${errorMessage}: [${prop}] is not supported`);
|
|
11416
|
+
}
|
|
11417
|
+
return Reflect.get(target5, prop, receiver2);
|
|
11418
|
+
}
|
|
11419
|
+
});
|
|
11668
11420
|
var AggregateHandler = class {
|
|
11669
11421
|
constructor(handleables) {
|
|
11670
11422
|
this.handleables = handleables;
|
|
@@ -11701,10 +11453,24 @@ var AggregateHandler = class {
|
|
|
11701
11453
|
}).join(", ")}`);
|
|
11702
11454
|
}
|
|
11703
11455
|
};
|
|
11456
|
+
async function fetchJwks(jwksIri, issuerIri) {
|
|
11457
|
+
const jwksResponse = await fetch2.call(globalThis, jwksIri);
|
|
11458
|
+
if (jwksResponse.status !== 200) {
|
|
11459
|
+
throw new Error(`Could not fetch JWKS for [${issuerIri}] at [${jwksIri}]: ${jwksResponse.status} ${jwksResponse.statusText}`);
|
|
11460
|
+
}
|
|
11461
|
+
let jwk;
|
|
11462
|
+
try {
|
|
11463
|
+
jwk = (await jwksResponse.json()).keys[0];
|
|
11464
|
+
} catch (e) {
|
|
11465
|
+
throw new Error(`Malformed JWKS for [${issuerIri}] at [${jwksIri}]: ${e.message}`);
|
|
11466
|
+
}
|
|
11467
|
+
return jwk;
|
|
11468
|
+
}
|
|
11704
11469
|
async function getWebidFromTokenPayload(idToken, jwksIri, issuerIri, clientId) {
|
|
11470
|
+
const jwk = await fetchJwks(jwksIri, issuerIri);
|
|
11705
11471
|
let payload4;
|
|
11706
11472
|
try {
|
|
11707
|
-
const { payload: verifiedPayload } = await jwtVerify(idToken,
|
|
11473
|
+
const { payload: verifiedPayload } = await jwtVerify(idToken, await importJWK(jwk), {
|
|
11708
11474
|
issuer: issuerIri,
|
|
11709
11475
|
audience: clientId
|
|
11710
11476
|
});
|
|
@@ -11744,29 +11510,17 @@ function removeOpenIdParams(redirectUrl) {
|
|
|
11744
11510
|
cleanedUpUrl.searchParams.delete("iss");
|
|
11745
11511
|
return cleanedUpUrl;
|
|
11746
11512
|
}
|
|
11747
|
-
function booleanWithFallback(value6, fallback) {
|
|
11748
|
-
if (typeof value6 === "boolean") {
|
|
11749
|
-
return Boolean(value6);
|
|
11750
|
-
}
|
|
11751
|
-
return Boolean(fallback);
|
|
11752
|
-
}
|
|
11753
11513
|
var AuthorizationCodeWithPkceOidcHandlerBase = class {
|
|
11754
11514
|
constructor(storageUtility, redirector) {
|
|
11755
11515
|
this.storageUtility = storageUtility;
|
|
11756
11516
|
this.redirector = redirector;
|
|
11757
|
-
this.parametersGuard = (oidcLoginOptions) => {
|
|
11758
|
-
return oidcLoginOptions.issuerConfiguration.grantTypesSupported !== void 0 && oidcLoginOptions.issuerConfiguration.grantTypesSupported.indexOf("authorization_code") > -1 && oidcLoginOptions.redirectUrl !== void 0;
|
|
11759
|
-
};
|
|
11760
11517
|
this.storageUtility = storageUtility;
|
|
11761
11518
|
this.redirector = redirector;
|
|
11762
11519
|
}
|
|
11763
11520
|
async canHandle(oidcLoginOptions) {
|
|
11764
|
-
return
|
|
11521
|
+
return !!(oidcLoginOptions.issuerConfiguration.grantTypesSupported && oidcLoginOptions.issuerConfiguration.grantTypesSupported.indexOf("authorization_code") > -1);
|
|
11765
11522
|
}
|
|
11766
11523
|
async handleRedirect({ oidcLoginOptions, state: state2, codeVerifier, targetUrl: targetUrl3 }) {
|
|
11767
|
-
if (!this.parametersGuard(oidcLoginOptions)) {
|
|
11768
|
-
throw new Error("The authorization code grant requires a redirectUrl.");
|
|
11769
|
-
}
|
|
11770
11524
|
await Promise.all([
|
|
11771
11525
|
// We use the OAuth 'state' value (which should be crypto-random) as
|
|
11772
11526
|
// the key in our storage to store our actual SessionID. We do this
|
|
@@ -11777,6 +11531,7 @@ var AuthorizationCodeWithPkceOidcHandlerBase = class {
|
|
|
11777
11531
|
// that session ID can be any developer-specified value, and therefore
|
|
11778
11532
|
// may not be appropriate (since the OAuth 'state' value should really
|
|
11779
11533
|
// be an unguessable crypto-random value).
|
|
11534
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
11780
11535
|
this.storageUtility.setForUser(state2, {
|
|
11781
11536
|
sessionId: oidcLoginOptions.sessionId
|
|
11782
11537
|
}),
|
|
@@ -11785,12 +11540,12 @@ var AuthorizationCodeWithPkceOidcHandlerBase = class {
|
|
|
11785
11540
|
// our session ID is unnecessary, but it provides a slightly cleaner
|
|
11786
11541
|
// separation of concerns.
|
|
11787
11542
|
this.storageUtility.setForUser(oidcLoginOptions.sessionId, {
|
|
11543
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
11788
11544
|
codeVerifier,
|
|
11789
11545
|
issuer: oidcLoginOptions.issuer.toString(),
|
|
11790
11546
|
// The redirect URL is read after redirect, so it must be stored now.
|
|
11791
11547
|
redirectUrl: oidcLoginOptions.redirectUrl,
|
|
11792
|
-
dpop:
|
|
11793
|
-
keepAlive: booleanWithFallback(oidcLoginOptions.keepAlive, true).toString()
|
|
11548
|
+
dpop: oidcLoginOptions.dpop ? "true" : "false"
|
|
11794
11549
|
})
|
|
11795
11550
|
]);
|
|
11796
11551
|
this.redirector.redirect(targetUrl3, {
|
|
@@ -11852,7 +11607,7 @@ function getUnauthenticatedSession() {
|
|
|
11852
11607
|
return {
|
|
11853
11608
|
isLoggedIn: false,
|
|
11854
11609
|
sessionId: v4_default(),
|
|
11855
|
-
fetch: (...args) =>
|
|
11610
|
+
fetch: (...args) => fetch2.call(globalThis, ...args)
|
|
11856
11611
|
};
|
|
11857
11612
|
}
|
|
11858
11613
|
async function clear(sessionId, storage2) {
|
|
@@ -11946,51 +11701,48 @@ function determineSigningAlg(supported, preferred2) {
|
|
|
11946
11701
|
return supported.includes(signingAlg);
|
|
11947
11702
|
})) !== null && _a !== void 0 ? _a : null;
|
|
11948
11703
|
}
|
|
11949
|
-
function
|
|
11950
|
-
|
|
11951
|
-
|
|
11952
|
-
|
|
11953
|
-
|
|
11954
|
-
|
|
11955
|
-
|
|
11956
|
-
return
|
|
11704
|
+
function determineClientType(options, issuerConfig) {
|
|
11705
|
+
if (options.clientId !== void 0 && !isValidUrl(options.clientId)) {
|
|
11706
|
+
return "static";
|
|
11707
|
+
}
|
|
11708
|
+
if (issuerConfig.scopesSupported.includes("webid") && options.clientId !== void 0 && isValidUrl(options.clientId)) {
|
|
11709
|
+
return "solid-oidc";
|
|
11710
|
+
}
|
|
11711
|
+
return "dynamic";
|
|
11957
11712
|
}
|
|
11958
11713
|
async function handleRegistration(options, issuerConfig, storageUtility, clientRegistrar) {
|
|
11959
|
-
|
|
11960
|
-
if (
|
|
11961
|
-
clientInfo = {
|
|
11962
|
-
clientId: options.clientId,
|
|
11963
|
-
clientName: options.clientName,
|
|
11964
|
-
clientType: "solid-oidc"
|
|
11965
|
-
};
|
|
11966
|
-
} else if (isStaticClient(options)) {
|
|
11967
|
-
clientInfo = {
|
|
11968
|
-
clientId: options.clientId,
|
|
11969
|
-
clientSecret: options.clientSecret,
|
|
11970
|
-
clientName: options.clientName,
|
|
11971
|
-
clientType: "static"
|
|
11972
|
-
};
|
|
11973
|
-
} else {
|
|
11714
|
+
const clientType = determineClientType(options, issuerConfig);
|
|
11715
|
+
if (clientType === "dynamic") {
|
|
11974
11716
|
return clientRegistrar.getClient({
|
|
11975
11717
|
sessionId: options.sessionId,
|
|
11976
11718
|
clientName: options.clientName,
|
|
11977
11719
|
redirectUrl: options.redirectUrl
|
|
11978
11720
|
}, issuerConfig);
|
|
11979
11721
|
}
|
|
11980
|
-
|
|
11981
|
-
|
|
11982
|
-
|
|
11983
|
-
|
|
11984
|
-
|
|
11985
|
-
|
|
11722
|
+
await storageUtility.setForUser(options.sessionId, {
|
|
11723
|
+
// If the client is either static or solid-oidc compliant, its client ID cannot be undefined.
|
|
11724
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
11725
|
+
clientId: options.clientId
|
|
11726
|
+
});
|
|
11727
|
+
if (options.clientSecret) {
|
|
11728
|
+
await storageUtility.setForUser(options.sessionId, {
|
|
11729
|
+
clientSecret: options.clientSecret
|
|
11730
|
+
});
|
|
11986
11731
|
}
|
|
11987
|
-
if (
|
|
11988
|
-
|
|
11732
|
+
if (options.clientName) {
|
|
11733
|
+
await storageUtility.setForUser(options.sessionId, {
|
|
11734
|
+
clientName: options.clientName
|
|
11735
|
+
});
|
|
11989
11736
|
}
|
|
11990
|
-
|
|
11991
|
-
|
|
11737
|
+
return {
|
|
11738
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
11739
|
+
clientId: options.clientId,
|
|
11740
|
+
clientSecret: options.clientSecret,
|
|
11741
|
+
clientName: options.clientName,
|
|
11742
|
+
clientType
|
|
11743
|
+
};
|
|
11992
11744
|
}
|
|
11993
|
-
var
|
|
11745
|
+
var globalFetch = (request2, init) => fetch2.call(globalThis, request2, init);
|
|
11994
11746
|
var ClientAuthentication = class {
|
|
11995
11747
|
constructor(loginHandler, redirectHandler, logoutHandler, sessionInfoManager, issuerConfigFetcher) {
|
|
11996
11748
|
this.loginHandler = loginHandler;
|
|
@@ -11998,13 +11750,13 @@ var ClientAuthentication = class {
|
|
|
11998
11750
|
this.logoutHandler = logoutHandler;
|
|
11999
11751
|
this.sessionInfoManager = sessionInfoManager;
|
|
12000
11752
|
this.issuerConfigFetcher = issuerConfigFetcher;
|
|
12001
|
-
this.fetch =
|
|
11753
|
+
this.fetch = globalFetch;
|
|
12002
11754
|
this.logout = async (sessionId, options) => {
|
|
12003
11755
|
await this.logoutHandler.handle(sessionId, (options === null || options === void 0 ? void 0 : options.logoutType) === "idp" ? {
|
|
12004
11756
|
...options,
|
|
12005
11757
|
toLogoutUrl: this.boundLogout
|
|
12006
11758
|
} : options);
|
|
12007
|
-
this.fetch =
|
|
11759
|
+
this.fetch = globalFetch;
|
|
12008
11760
|
delete this.boundLogout;
|
|
12009
11761
|
};
|
|
12010
11762
|
this.getSessionInfo = async (sessionId) => {
|
|
@@ -12022,14 +11774,13 @@ var ClientAuthentication = class {
|
|
|
12022
11774
|
};
|
|
12023
11775
|
async function loadOidcContextFromStorage(sessionId, storageUtility, configFetcher) {
|
|
12024
11776
|
try {
|
|
12025
|
-
const [issuerIri, codeVerifier, storedRedirectIri, dpop
|
|
11777
|
+
const [issuerIri, codeVerifier, storedRedirectIri, dpop] = await Promise.all([
|
|
12026
11778
|
storageUtility.getForUser(sessionId, "issuer", {
|
|
12027
11779
|
errorIfNull: true
|
|
12028
11780
|
}),
|
|
12029
11781
|
storageUtility.getForUser(sessionId, "codeVerifier"),
|
|
12030
11782
|
storageUtility.getForUser(sessionId, "redirectUrl"),
|
|
12031
|
-
storageUtility.getForUser(sessionId, "dpop", { errorIfNull: true })
|
|
12032
|
-
storageUtility.getForUser(sessionId, "keepAlive")
|
|
11783
|
+
storageUtility.getForUser(sessionId, "dpop", { errorIfNull: true })
|
|
12033
11784
|
]);
|
|
12034
11785
|
await storageUtility.deleteForUser(sessionId, "codeVerifier");
|
|
12035
11786
|
const issuerConfig = await configFetcher.fetchConfig(issuerIri);
|
|
@@ -12037,9 +11788,7 @@ async function loadOidcContextFromStorage(sessionId, storageUtility, configFetch
|
|
|
12037
11788
|
codeVerifier,
|
|
12038
11789
|
redirectUrl: storedRedirectIri,
|
|
12039
11790
|
issuerConfig,
|
|
12040
|
-
dpop: dpop === "true"
|
|
12041
|
-
// Default keepAlive to true if not found in storage.
|
|
12042
|
-
keepAlive: typeof keepAlive === "string" ? keepAlive === "true" : true
|
|
11791
|
+
dpop: dpop === "true"
|
|
12043
11792
|
};
|
|
12044
11793
|
} catch (e) {
|
|
12045
11794
|
throw new Error(`Failed to retrieve OIDC context from storage associated with session [${sessionId}]: ${e}`);
|
|
@@ -12196,8 +11945,8 @@ async function buildAuthenticatedHeaders(targetUrl3, authToken, dpopKey, default
|
|
|
12196
11945
|
headers
|
|
12197
11946
|
};
|
|
12198
11947
|
}
|
|
12199
|
-
async function makeAuthenticatedRequest(accessToken, url7, defaultRequestInit, dpopKey) {
|
|
12200
|
-
return
|
|
11948
|
+
async function makeAuthenticatedRequest(unauthFetch, accessToken, url7, defaultRequestInit, dpopKey) {
|
|
11949
|
+
return unauthFetch(url7, await buildAuthenticatedHeaders(url7.toString(), accessToken, dpopKey, defaultRequestInit));
|
|
12201
11950
|
}
|
|
12202
11951
|
async function refreshAccessToken(refreshOptions, dpopKey, eventEmitter) {
|
|
12203
11952
|
var _a;
|
|
@@ -12221,7 +11970,7 @@ var computeRefreshDelay = (expiresIn) => {
|
|
|
12221
11970
|
}
|
|
12222
11971
|
return DEFAULT_EXPIRATION_TIME_SECONDS;
|
|
12223
11972
|
};
|
|
12224
|
-
async function buildAuthenticatedFetch(accessToken, options) {
|
|
11973
|
+
async function buildAuthenticatedFetch(unauthFetch, accessToken, options) {
|
|
12225
11974
|
var _a;
|
|
12226
11975
|
let currentAccessToken = accessToken;
|
|
12227
11976
|
let latestTimeout;
|
|
@@ -12269,7 +12018,7 @@ async function buildAuthenticatedFetch(accessToken, options) {
|
|
|
12269
12018
|
options.eventEmitter.emit(EVENTS.TIMEOUT_SET, expirationTimeout);
|
|
12270
12019
|
}
|
|
12271
12020
|
return async (url7, requestInit) => {
|
|
12272
|
-
let response6 = await makeAuthenticatedRequest(currentAccessToken, url7, requestInit, options === null || options === void 0 ? void 0 : options.dpopKey);
|
|
12021
|
+
let response6 = await makeAuthenticatedRequest(unauthFetch, currentAccessToken, url7, requestInit, options === null || options === void 0 ? void 0 : options.dpopKey);
|
|
12273
12022
|
const failedButNotExpectedAuthError = !response6.ok && !isExpectedAuthError(response6.status);
|
|
12274
12023
|
if (response6.ok || failedButNotExpectedAuthError) {
|
|
12275
12024
|
return response6;
|
|
@@ -12277,6 +12026,7 @@ async function buildAuthenticatedFetch(accessToken, options) {
|
|
|
12277
12026
|
const hasBeenRedirected = response6.url !== url7;
|
|
12278
12027
|
if (hasBeenRedirected && (options === null || options === void 0 ? void 0 : options.dpopKey) !== void 0) {
|
|
12279
12028
|
response6 = await makeAuthenticatedRequest(
|
|
12029
|
+
unauthFetch,
|
|
12280
12030
|
currentAccessToken,
|
|
12281
12031
|
// Replace the original target IRI (`url`) by the redirection target
|
|
12282
12032
|
response6.url,
|
|
@@ -12289,7 +12039,7 @@ async function buildAuthenticatedFetch(accessToken, options) {
|
|
|
12289
12039
|
}
|
|
12290
12040
|
|
|
12291
12041
|
// ../node_modules/@inrupt/solid-client-authn-browser/dist/index.mjs
|
|
12292
|
-
var
|
|
12042
|
+
var import_events2 = __toESM(require_events(), 1);
|
|
12293
12043
|
|
|
12294
12044
|
// ../node_modules/@inrupt/oidc-client-ext/dist/index.es.js
|
|
12295
12045
|
var import_oidc_client = __toESM(require_oidc_client_min());
|
|
@@ -12437,7 +12187,7 @@ async function getTokens(issuer2, client, data2, dpop) {
|
|
|
12437
12187
|
headers,
|
|
12438
12188
|
body: new URLSearchParams(requestBody).toString()
|
|
12439
12189
|
};
|
|
12440
|
-
const rawTokenResponse = await
|
|
12190
|
+
const rawTokenResponse = await fetch2(issuer2.tokenEndpoint, tokenRequestInit);
|
|
12441
12191
|
const jsonTokenResponse = await rawTokenResponse.json();
|
|
12442
12192
|
const tokenResponse = validateTokenEndpointResponse(jsonTokenResponse, dpop);
|
|
12443
12193
|
const webId = await getWebidFromTokenPayload(tokenResponse.id_token, issuer2.jwksUri, issuer2.issuer, client.clientId);
|
|
@@ -12450,6 +12200,66 @@ async function getTokens(issuer2, client, data2, dpop) {
|
|
|
12450
12200
|
expiresIn: tokenResponse.expires_in
|
|
12451
12201
|
};
|
|
12452
12202
|
}
|
|
12203
|
+
async function getBearerToken(redirectUrl) {
|
|
12204
|
+
let signinResponse;
|
|
12205
|
+
try {
|
|
12206
|
+
const client = new import_oidc_client.OidcClient({
|
|
12207
|
+
// TODO: We should look at the various interfaces being used for storage,
|
|
12208
|
+
// i.e. between oidc-client-js (WebStorageStoreState), localStorage
|
|
12209
|
+
// (which has an interface Storage), and our own proprietary interface
|
|
12210
|
+
// IStorage - i.e. we should really just be using the browser Web Storage
|
|
12211
|
+
// API, e.g. "stateStore: window.localStorage,".
|
|
12212
|
+
// We are instantiating a new instance here, so the only value we need to
|
|
12213
|
+
// explicitly provide is the response mode (default otherwise will look
|
|
12214
|
+
// for a hash '#' fragment!).
|
|
12215
|
+
// eslint-disable-next-line camelcase
|
|
12216
|
+
response_mode: "query",
|
|
12217
|
+
// The userinfo endpoint on NSS fails, so disable this for now
|
|
12218
|
+
// Note that in Solid, information should be retrieved from the
|
|
12219
|
+
// profile referenced by the WebId.
|
|
12220
|
+
// TODO: Note that this is heavy-handed, and that this userinfo check
|
|
12221
|
+
// verifies that the `sub` claim in the id token you get along with the
|
|
12222
|
+
// access token matches the sub claim associated with the access token at
|
|
12223
|
+
// the userinfo endpoint.
|
|
12224
|
+
// That is a useful check, and in the future it should be only disabled
|
|
12225
|
+
// against NSS, and not in general.
|
|
12226
|
+
// Issue tracker: https://github.com/solid/node-solid-server/issues/1490
|
|
12227
|
+
loadUserInfo: false
|
|
12228
|
+
});
|
|
12229
|
+
signinResponse = await client.processSigninResponse(redirectUrl);
|
|
12230
|
+
if (client.settings.metadata === void 0) {
|
|
12231
|
+
throw new Error("Cannot retrieve issuer metadata from client information in storage.");
|
|
12232
|
+
}
|
|
12233
|
+
if (client.settings.metadata.jwks_uri === void 0) {
|
|
12234
|
+
throw new Error("Missing some issuer metadata from client information in storage: 'jwks_uri' is undefined");
|
|
12235
|
+
}
|
|
12236
|
+
if (client.settings.metadata.issuer === void 0) {
|
|
12237
|
+
throw new Error("Missing some issuer metadata from client information in storage: 'issuer' is undefined");
|
|
12238
|
+
}
|
|
12239
|
+
if (client.settings.client_id === void 0) {
|
|
12240
|
+
throw new Error("Missing some client information in storage: 'client_id' is undefined");
|
|
12241
|
+
}
|
|
12242
|
+
const webId = await getWebidFromTokenPayload(signinResponse.id_token, client.settings.metadata.jwks_uri, client.settings.metadata.issuer, client.settings.client_id);
|
|
12243
|
+
return {
|
|
12244
|
+
accessToken: signinResponse.access_token,
|
|
12245
|
+
idToken: signinResponse.id_token,
|
|
12246
|
+
webId,
|
|
12247
|
+
// Although not a field in the TypeScript response interface, the refresh
|
|
12248
|
+
// token (which can optionally come back with the access token (if, as per
|
|
12249
|
+
// the OAuth2 spec, we requested one using the scope of 'offline_access')
|
|
12250
|
+
// will be included in the signin response object.
|
|
12251
|
+
// eslint-disable-next-line camelcase
|
|
12252
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
12253
|
+
// @ts-ignore
|
|
12254
|
+
refreshToken: signinResponse.refresh_token
|
|
12255
|
+
};
|
|
12256
|
+
} catch (err) {
|
|
12257
|
+
throw new Error(`Problem handling Auth Code Grant (Flow) redirect - URL [${redirectUrl}]: ${err}`);
|
|
12258
|
+
}
|
|
12259
|
+
}
|
|
12260
|
+
async function getDpopToken(issuer2, client, data2) {
|
|
12261
|
+
return getTokens(issuer2, client, data2, true);
|
|
12262
|
+
}
|
|
12453
12263
|
var isValidUrl2 = (url7) => {
|
|
12454
12264
|
try {
|
|
12455
12265
|
new URL(url7);
|
|
@@ -12483,7 +12293,7 @@ async function refresh(refreshToken, issuer2, client, dpopKey) {
|
|
|
12483
12293
|
} else if (isValidUrl2(client.clientId)) {
|
|
12484
12294
|
requestBody.client_id = client.clientId;
|
|
12485
12295
|
}
|
|
12486
|
-
const rawResponse = await
|
|
12296
|
+
const rawResponse = await fetch2(issuer2.tokenEndpoint, {
|
|
12487
12297
|
method: "POST",
|
|
12488
12298
|
body: new URLSearchParams(requestBody).toString(),
|
|
12489
12299
|
headers: {
|
|
@@ -12581,7 +12391,7 @@ var ClientAuthentication2 = class extends ClientAuthentication {
|
|
|
12581
12391
|
};
|
|
12582
12392
|
this.handleIncomingRedirect = async (url7, eventEmitter) => {
|
|
12583
12393
|
try {
|
|
12584
|
-
const redirectInfo = await this.redirectHandler.handle(url7, eventEmitter
|
|
12394
|
+
const redirectInfo = await this.redirectHandler.handle(url7, eventEmitter);
|
|
12585
12395
|
this.fetch = redirectInfo.fetch.bind(window);
|
|
12586
12396
|
this.boundLogout = redirectInfo.getLogoutUrl;
|
|
12587
12397
|
await this.cleanUrlAfterRedirect(url7);
|
|
@@ -12660,7 +12470,8 @@ var AuthorizationCodeWithPkceOidcHandler = class extends AuthorizationCodeWithPk
|
|
|
12660
12470
|
authority: oidcLoginOptions.issuer.toString(),
|
|
12661
12471
|
client_id: oidcLoginOptions.client.clientId,
|
|
12662
12472
|
client_secret: oidcLoginOptions.client.clientSecret,
|
|
12663
|
-
redirect_uri: oidcLoginOptions.redirectUrl,
|
|
12473
|
+
redirect_uri: oidcLoginOptions.redirectUrl.toString(),
|
|
12474
|
+
post_logout_redirect_uri: oidcLoginOptions.redirectUrl.toString(),
|
|
12664
12475
|
response_type: "code",
|
|
12665
12476
|
scope: DEFAULT_SCOPES,
|
|
12666
12477
|
filterProtocolClaims: true,
|
|
@@ -12806,7 +12617,7 @@ var IssuerConfigFetcher = class _IssuerConfigFetcher {
|
|
|
12806
12617
|
// includes the full issuer path. See https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig.
|
|
12807
12618
|
issuer2.endsWith("/") ? issuer2 : `${issuer2}/`
|
|
12808
12619
|
).href;
|
|
12809
|
-
const issuerConfigRequestBody = await
|
|
12620
|
+
const issuerConfigRequestBody = await fetch2.call(globalThis, openIdConfigUrl);
|
|
12810
12621
|
try {
|
|
12811
12622
|
issuerConfig = processConfig(await issuerConfigRequestBody.json());
|
|
12812
12623
|
} catch (err) {
|
|
@@ -12897,6 +12708,7 @@ var FallbackRedirectHandler = class {
|
|
|
12897
12708
|
return getUnauthenticatedSession();
|
|
12898
12709
|
}
|
|
12899
12710
|
};
|
|
12711
|
+
var globalFetch2 = (...args) => fetch2.call(globalThis, ...args);
|
|
12900
12712
|
var AuthCodeRedirectHandler = class {
|
|
12901
12713
|
constructor(storageUtility, sessionInfoManager, issuerConfigFetcher, clientRegistrar, tokerRefresher) {
|
|
12902
12714
|
this.storageUtility = storageUtility;
|
|
@@ -12939,16 +12751,21 @@ var AuthCodeRedirectHandler = class {
|
|
|
12939
12751
|
throw new Error(`The redirect URL for session ${storedSessionId} is missing from storage.`);
|
|
12940
12752
|
}
|
|
12941
12753
|
const client = await this.clientRegistrar.getClient({ sessionId: storedSessionId }, issuerConfig);
|
|
12754
|
+
let tokens;
|
|
12942
12755
|
const tokenCreatedAt = Date.now();
|
|
12943
|
-
|
|
12944
|
-
|
|
12945
|
-
|
|
12946
|
-
|
|
12947
|
-
|
|
12948
|
-
|
|
12949
|
-
|
|
12950
|
-
|
|
12951
|
-
|
|
12756
|
+
if (isDpop) {
|
|
12757
|
+
tokens = await getDpopToken(issuerConfig, client, {
|
|
12758
|
+
grantType: "authorization_code",
|
|
12759
|
+
// We rely on our 'canHandle' function checking that the OAuth 'code'
|
|
12760
|
+
// parameter is present in our query string.
|
|
12761
|
+
code: url7.searchParams.get("code"),
|
|
12762
|
+
codeVerifier,
|
|
12763
|
+
redirectUrl: storedRedirectIri
|
|
12764
|
+
});
|
|
12765
|
+
window.localStorage.removeItem(`oidc.${oauthState}`);
|
|
12766
|
+
} else {
|
|
12767
|
+
tokens = await getBearerToken(url7.toString());
|
|
12768
|
+
}
|
|
12952
12769
|
let refreshOptions;
|
|
12953
12770
|
if (tokens.refreshToken !== void 0) {
|
|
12954
12771
|
refreshOptions = {
|
|
@@ -12957,7 +12774,7 @@ var AuthCodeRedirectHandler = class {
|
|
|
12957
12774
|
tokenRefresher: this.tokerRefresher
|
|
12958
12775
|
};
|
|
12959
12776
|
}
|
|
12960
|
-
const authFetch = await buildAuthenticatedFetch(tokens.accessToken, {
|
|
12777
|
+
const authFetch = await buildAuthenticatedFetch(globalFetch2, tokens.accessToken, {
|
|
12961
12778
|
dpopKey: tokens.dpopKey,
|
|
12962
12779
|
refreshOptions,
|
|
12963
12780
|
eventEmitter,
|
|
@@ -13017,34 +12834,33 @@ var ClientRegistrar = class {
|
|
|
13017
12834
|
this.storageUtility = storageUtility;
|
|
13018
12835
|
}
|
|
13019
12836
|
async getClient(options, issuerConfig) {
|
|
13020
|
-
const [
|
|
12837
|
+
const [
|
|
12838
|
+
storedClientId,
|
|
12839
|
+
storedClientSecret
|
|
12840
|
+
// storedClientName,
|
|
12841
|
+
] = await Promise.all([
|
|
13021
12842
|
this.storageUtility.getForUser(options.sessionId, "clientId", {
|
|
13022
12843
|
secure: false
|
|
13023
12844
|
}),
|
|
13024
12845
|
this.storageUtility.getForUser(options.sessionId, "clientSecret", {
|
|
13025
12846
|
secure: false
|
|
13026
|
-
}),
|
|
13027
|
-
this.storageUtility.getForUser(options.sessionId, "clientName", {
|
|
13028
|
-
secure: false
|
|
13029
|
-
}),
|
|
13030
|
-
this.storageUtility.getForUser(options.sessionId, "clientType", {
|
|
13031
|
-
secure: false
|
|
13032
12847
|
})
|
|
12848
|
+
// this.storageUtility.getForUser(options.sessionId, "clientName", {
|
|
12849
|
+
// // FIXME: figure out how to persist secure storage at reload
|
|
12850
|
+
// secure: false,
|
|
12851
|
+
// }),
|
|
13033
12852
|
]);
|
|
13034
|
-
if (storedClientId
|
|
12853
|
+
if (storedClientId) {
|
|
13035
12854
|
return {
|
|
13036
12855
|
clientId: storedClientId,
|
|
13037
12856
|
clientSecret: storedClientSecret,
|
|
13038
|
-
|
|
13039
|
-
// Note: static clients are not applicable in a browser context.
|
|
13040
|
-
clientType: storedClientType
|
|
12857
|
+
clientType: "dynamic"
|
|
13041
12858
|
};
|
|
13042
12859
|
}
|
|
13043
12860
|
try {
|
|
13044
12861
|
const registeredClient = await registerClient(options, issuerConfig);
|
|
13045
12862
|
const infoToSave = {
|
|
13046
|
-
clientId: registeredClient.clientId
|
|
13047
|
-
clientType: "dynamic"
|
|
12863
|
+
clientId: registeredClient.clientId
|
|
13048
12864
|
};
|
|
13049
12865
|
if (registeredClient.clientSecret) {
|
|
13050
12866
|
infoToSave.clientSecret = registeredClient.clientSecret;
|
|
@@ -13153,7 +12969,7 @@ async function silentlyAuthenticate(sessionId, clientAuthn, session4) {
|
|
|
13153
12969
|
function isLoggedIn(sessionInfo) {
|
|
13154
12970
|
return !!(sessionInfo === null || sessionInfo === void 0 ? void 0 : sessionInfo.isLoggedIn);
|
|
13155
12971
|
}
|
|
13156
|
-
var Session = class {
|
|
12972
|
+
var Session = class _Session extends import_events2.default {
|
|
13157
12973
|
/**
|
|
13158
12974
|
* Session object constructor. Typically called as follows:
|
|
13159
12975
|
*
|
|
@@ -13170,6 +12986,7 @@ var Session = class {
|
|
|
13170
12986
|
*
|
|
13171
12987
|
*/
|
|
13172
12988
|
constructor(sessionOptions = {}, sessionId = void 0) {
|
|
12989
|
+
super();
|
|
13173
12990
|
this.tokenRequestInProgress = false;
|
|
13174
12991
|
this.login = async (options) => {
|
|
13175
12992
|
var _a;
|
|
@@ -13226,7 +13043,7 @@ var Session = class {
|
|
|
13226
13043
|
this.tokenRequestInProgress = false;
|
|
13227
13044
|
return sessionInfo;
|
|
13228
13045
|
};
|
|
13229
|
-
this.events = new
|
|
13046
|
+
this.events = new Proxy(this, buildProxyHandler(_Session.prototype, "events only implements ISessionEventListener"));
|
|
13230
13047
|
if (sessionOptions.clientAuthentication) {
|
|
13231
13048
|
this.clientAuthentication = sessionOptions.clientAuthentication;
|
|
13232
13049
|
} else if (sessionOptions.secureStorage && sessionOptions.insecureStorage) {
|
|
@@ -13253,6 +13070,58 @@ var Session = class {
|
|
|
13253
13070
|
this.events.on(EVENTS.SESSION_EXPIRED, () => this.internalLogout(false));
|
|
13254
13071
|
this.events.on(EVENTS.ERROR, () => this.internalLogout(false));
|
|
13255
13072
|
}
|
|
13073
|
+
/**
|
|
13074
|
+
* Register a callback function to be called when a user completes login.
|
|
13075
|
+
*
|
|
13076
|
+
* The callback is called when {@link handleIncomingRedirect} completes successfully.
|
|
13077
|
+
*
|
|
13078
|
+
* @param callback The function called when a user completes login.
|
|
13079
|
+
* @deprecated Prefer session.events.on(EVENTS.LOGIN, callback)
|
|
13080
|
+
*/
|
|
13081
|
+
onLogin(callback) {
|
|
13082
|
+
this.events.on(EVENTS.LOGIN, callback);
|
|
13083
|
+
}
|
|
13084
|
+
/**
|
|
13085
|
+
* Register a callback function to be called when a user logs out:
|
|
13086
|
+
*
|
|
13087
|
+
* @param callback The function called when a user completes logout.
|
|
13088
|
+
* @deprecated Prefer session.events.on(EVENTS.LOGOUT, callback)
|
|
13089
|
+
*/
|
|
13090
|
+
onLogout(callback) {
|
|
13091
|
+
this.events.on(EVENTS.LOGOUT, callback);
|
|
13092
|
+
}
|
|
13093
|
+
/**
|
|
13094
|
+
* Register a callback function to be called when a user logs out:
|
|
13095
|
+
*
|
|
13096
|
+
* @param callback The function called when an error occurs.
|
|
13097
|
+
* @since 1.11.0
|
|
13098
|
+
* @deprecated Prefer session.events.on(EVENTS.ERROR, callback)
|
|
13099
|
+
*/
|
|
13100
|
+
onError(callback) {
|
|
13101
|
+
this.events.on(EVENTS.ERROR, callback);
|
|
13102
|
+
}
|
|
13103
|
+
/**
|
|
13104
|
+
* Register a callback function to be called when a session is restored.
|
|
13105
|
+
*
|
|
13106
|
+
* Note: the callback will be called with the saved value of the 'current URL'
|
|
13107
|
+
* at the time the session was restored.
|
|
13108
|
+
*
|
|
13109
|
+
* @param callback The function called when a user's already logged-in session is restored, e.g., after a silent authentication is completed after a page refresh.
|
|
13110
|
+
* @deprecated Prefer session.events.on(EVENTS.SESSION_RESTORED, callback)
|
|
13111
|
+
*/
|
|
13112
|
+
onSessionRestore(callback) {
|
|
13113
|
+
this.events.on(EVENTS.SESSION_RESTORED, callback);
|
|
13114
|
+
}
|
|
13115
|
+
/**
|
|
13116
|
+
* Register a callback that runs when the session expires and can no longer
|
|
13117
|
+
* make authenticated requests, but following a user logout.
|
|
13118
|
+
* @param callback The function that runs on session expiration.
|
|
13119
|
+
* @since 1.11.0
|
|
13120
|
+
* @deprecated Prefer session.events.on(EVENTS.SESSION_EXPIRED, callback)
|
|
13121
|
+
*/
|
|
13122
|
+
onSessionExpiration(callback) {
|
|
13123
|
+
this.events.on(EVENTS.SESSION_EXPIRED, callback);
|
|
13124
|
+
}
|
|
13256
13125
|
setSessionInfo(sessionInfo) {
|
|
13257
13126
|
this.info.isLoggedIn = sessionInfo.isLoggedIn;
|
|
13258
13127
|
this.info.webId = sessionInfo.webId;
|
|
@@ -13303,19 +13172,16 @@ var BrowserSession = class {
|
|
|
13303
13172
|
* @deprecated use observeSession instead
|
|
13304
13173
|
*/
|
|
13305
13174
|
trackSession(callback) {
|
|
13306
|
-
this.session.
|
|
13307
|
-
this.session.
|
|
13308
|
-
this.session.
|
|
13309
|
-
EVENTS.SESSION_RESTORED,
|
|
13310
|
-
() => callback(this.session.info)
|
|
13311
|
-
);
|
|
13175
|
+
this.session.on(EVENTS.LOGIN, () => callback(this.session.info));
|
|
13176
|
+
this.session.on(EVENTS.LOGOUT, () => callback(this.session.info));
|
|
13177
|
+
this.session.on(EVENTS.SESSION_RESTORED, () => callback(this.session.info));
|
|
13312
13178
|
callback(this.session.info);
|
|
13313
13179
|
}
|
|
13314
13180
|
observeSession() {
|
|
13315
13181
|
return this.sessionInfo$;
|
|
13316
13182
|
}
|
|
13317
13183
|
onSessionRestore(callback) {
|
|
13318
|
-
this.session.
|
|
13184
|
+
this.session.on(EVENTS.SESSION_RESTORED, callback);
|
|
13319
13185
|
}
|
|
13320
13186
|
};
|
|
13321
13187
|
|
|
@@ -23297,7 +23163,7 @@ var Document3 = "http://www.w3.org/2007/ont/link#Document";
|
|
|
23297
23163
|
var Mailbox = "http://www.w3.org/2007/ont/link#Mailbox";
|
|
23298
23164
|
var ProtocolEvent = "http://www.w3.org/2007/ont/link#ProtocolEvent";
|
|
23299
23165
|
var RDFDocument = "http://www.w3.org/2007/ont/link#RDFDocument";
|
|
23300
|
-
var
|
|
23166
|
+
var Response2 = "http://www.w3.org/2007/ont/link#Response";
|
|
23301
23167
|
var Session3 = "http://www.w3.org/2007/ont/link#Session";
|
|
23302
23168
|
var isMentionedIn = "http://www.w3.org/2007/ont/link#isMentionedIn";
|
|
23303
23169
|
var mentionsClass = "http://www.w3.org/2007/ont/link#mentionsClass";
|
|
@@ -23317,7 +23183,7 @@ var linkImport = /* @__PURE__ */ Object.freeze({
|
|
|
23317
23183
|
Mailbox,
|
|
23318
23184
|
ProtocolEvent,
|
|
23319
23185
|
RDFDocument,
|
|
23320
|
-
Response,
|
|
23186
|
+
Response: Response2,
|
|
23321
23187
|
Session: Session3,
|
|
23322
23188
|
isMentionedIn,
|
|
23323
23189
|
mentionsClass,
|
|
@@ -33583,7 +33449,7 @@ var Document4 = "http://www.w3.org/2007/ont/link#Document";
|
|
|
33583
33449
|
var Mailbox2 = "http://www.w3.org/2007/ont/link#Mailbox";
|
|
33584
33450
|
var ProtocolEvent2 = "http://www.w3.org/2007/ont/link#ProtocolEvent";
|
|
33585
33451
|
var RDFDocument2 = "http://www.w3.org/2007/ont/link#RDFDocument";
|
|
33586
|
-
var
|
|
33452
|
+
var Response3 = "http://www.w3.org/2007/ont/link#Response";
|
|
33587
33453
|
var Session4 = "http://www.w3.org/2007/ont/link#Session";
|
|
33588
33454
|
var isMentionedIn2 = "http://www.w3.org/2007/ont/link#isMentionedIn";
|
|
33589
33455
|
var mentionsClass2 = "http://www.w3.org/2007/ont/link#mentionsClass";
|
|
@@ -33603,7 +33469,7 @@ var tabImport = /* @__PURE__ */ Object.freeze({
|
|
|
33603
33469
|
Mailbox: Mailbox2,
|
|
33604
33470
|
ProtocolEvent: ProtocolEvent2,
|
|
33605
33471
|
RDFDocument: RDFDocument2,
|
|
33606
|
-
Response:
|
|
33472
|
+
Response: Response3,
|
|
33607
33473
|
Session: Session4,
|
|
33608
33474
|
isMentionedIn: isMentionedIn2,
|
|
33609
33475
|
mentionsClass: mentionsClass2,
|
|
@@ -33625,7 +33491,7 @@ var Document5 = "http://www.w3.org/2007/ont/link#Document";
|
|
|
33625
33491
|
var Mailbox3 = "http://www.w3.org/2007/ont/link#Mailbox";
|
|
33626
33492
|
var ProtocolEvent3 = "http://www.w3.org/2007/ont/link#ProtocolEvent";
|
|
33627
33493
|
var RDFDocument3 = "http://www.w3.org/2007/ont/link#RDFDocument";
|
|
33628
|
-
var
|
|
33494
|
+
var Response4 = "http://www.w3.org/2007/ont/link#Response";
|
|
33629
33495
|
var Session5 = "http://www.w3.org/2007/ont/link#Session";
|
|
33630
33496
|
var isMentionedIn3 = "http://www.w3.org/2007/ont/link#isMentionedIn";
|
|
33631
33497
|
var mentionsClass3 = "http://www.w3.org/2007/ont/link#mentionsClass";
|
|
@@ -33645,7 +33511,7 @@ var tabontImport = /* @__PURE__ */ Object.freeze({
|
|
|
33645
33511
|
Mailbox: Mailbox3,
|
|
33646
33512
|
ProtocolEvent: ProtocolEvent3,
|
|
33647
33513
|
RDFDocument: RDFDocument3,
|
|
33648
|
-
Response:
|
|
33514
|
+
Response: Response4,
|
|
33649
33515
|
Session: Session5,
|
|
33650
33516
|
isMentionedIn: isMentionedIn3,
|
|
33651
33517
|
mentionsClass: mentionsClass3,
|