@pod-os/core 0.12.1-39cd89f.0 → 0.12.1-3a9df69.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 CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  lit,
9
9
  namedNode,
10
10
  st
11
- } from "./chunk-GBIS3SJI.js";
11
+ } from "./chunk-7VQUARYZ.js";
12
12
  import {
13
13
  __commonJS,
14
14
  __export,
@@ -281,7 +281,7 @@ var require_events = __commonJS({
281
281
  }
282
282
  return this;
283
283
  };
284
- function _listeners(target5, type5, unwrap3) {
284
+ function _listeners(target5, type5, unwrap) {
285
285
  var events3 = target5._events;
286
286
  if (events3 === void 0)
287
287
  return [];
@@ -289,8 +289,8 @@ var require_events = __commonJS({
289
289
  if (evlistener === void 0)
290
290
  return [];
291
291
  if (typeof evlistener === "function")
292
- return unwrap3 ? [evlistener.listener || evlistener] : [evlistener];
293
- return unwrap3 ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
292
+ return unwrap ? [evlistener.listener || evlistener] : [evlistener];
293
+ return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
294
294
  }
295
295
  EventEmitter2.prototype.listeners = function listeners(type5) {
296
296
  return _listeners(this, type5, true);
@@ -10191,22 +10191,24 @@ var JWTClaimValidationFailed = class extends JOSEError {
10191
10191
  static get code() {
10192
10192
  return "ERR_JWT_CLAIM_VALIDATION_FAILED";
10193
10193
  }
10194
- constructor(message4, claim2 = "unspecified", reason2 = "unspecified") {
10194
+ constructor(message4, payload4, claim2 = "unspecified", reason2 = "unspecified") {
10195
10195
  super(message4);
10196
10196
  this.code = "ERR_JWT_CLAIM_VALIDATION_FAILED";
10197
10197
  this.claim = claim2;
10198
10198
  this.reason = reason2;
10199
+ this.payload = payload4;
10199
10200
  }
10200
10201
  };
10201
10202
  var JWTExpired = class extends JOSEError {
10202
10203
  static get code() {
10203
10204
  return "ERR_JWT_EXPIRED";
10204
10205
  }
10205
- constructor(message4, claim2 = "unspecified", reason2 = "unspecified") {
10206
+ constructor(message4, payload4, claim2 = "unspecified", reason2 = "unspecified") {
10206
10207
  super(message4);
10207
10208
  this.code = "ERR_JWT_EXPIRED";
10208
10209
  this.claim = claim2;
10209
10210
  this.reason = reason2;
10211
+ this.payload = payload4;
10210
10212
  }
10211
10213
  };
10212
10214
  var JOSEAlgNotAllowed = class extends JOSEError {
@@ -10295,9 +10297,6 @@ var JWSSignatureVerificationFailed = class extends JOSEError {
10295
10297
  }
10296
10298
  };
10297
10299
 
10298
- // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/runtime/random.js
10299
- var random_default = webcrypto_default.getRandomValues.bind(webcrypto_default);
10300
-
10301
10300
  // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/lib/crypto_key.js
10302
10301
  function unusable(name7, prop = "algorithm.name") {
10303
10302
  return new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name7}`);
@@ -10394,6 +10393,7 @@ function checkSigCryptoKey(key3, alg, ...usages) {
10394
10393
 
10395
10394
  // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/lib/invalid_key_input.js
10396
10395
  function message(msg, actual2, ...types2) {
10396
+ types2 = types2.filter(Boolean);
10397
10397
  if (types2.length > 2) {
10398
10398
  const last3 = types2.pop();
10399
10399
  msg += `one of type ${types2.join(", ")}, or ${last3}.`;
@@ -10422,7 +10422,10 @@ function withAlg(alg, actual2, ...types2) {
10422
10422
 
10423
10423
  // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/runtime/is_key_like.js
10424
10424
  var is_key_like_default = (key3) => {
10425
- return isCryptoKey(key3);
10425
+ if (isCryptoKey(key3)) {
10426
+ return true;
10427
+ }
10428
+ return key3?.[Symbol.toStringTag] === "KeyObject";
10426
10429
  };
10427
10430
  var types = ["CryptoKey"];
10428
10431
 
@@ -10478,6 +10481,20 @@ var check_key_length_default = (alg, key3) => {
10478
10481
  }
10479
10482
  };
10480
10483
 
10484
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/lib/is_jwk.js
10485
+ function isJWK(key3) {
10486
+ return isObject(key3) && typeof key3.kty === "string";
10487
+ }
10488
+ function isPrivateJWK(key3) {
10489
+ return key3.kty !== "oct" && typeof key3.d === "string";
10490
+ }
10491
+ function isPublicJWK(key3) {
10492
+ return key3.kty !== "oct" && typeof key3.d === "undefined";
10493
+ }
10494
+ function isSecretJWK(key3) {
10495
+ return isJWK(key3) && key3.kty === "oct" && typeof key3.k === "string";
10496
+ }
10497
+
10481
10498
  // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/runtime/jwk_to_key.js
10482
10499
  function subtleMapping(jwk) {
10483
10500
  let algorithm3;
@@ -10578,6 +10595,72 @@ var parse = async (jwk) => {
10578
10595
  };
10579
10596
  var jwk_to_key_default = parse;
10580
10597
 
10598
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/runtime/normalize_key.js
10599
+ var exportKeyValue = (k) => decode(k);
10600
+ var privCache;
10601
+ var pubCache;
10602
+ var isKeyObject = (key3) => {
10603
+ return key3?.[Symbol.toStringTag] === "KeyObject";
10604
+ };
10605
+ var importAndCache = async (cache, key3, jwk, alg, freeze = false) => {
10606
+ let cached = cache.get(key3);
10607
+ if (cached?.[alg]) {
10608
+ return cached[alg];
10609
+ }
10610
+ const cryptoKey = await jwk_to_key_default({ ...jwk, alg });
10611
+ if (freeze)
10612
+ Object.freeze(key3);
10613
+ if (!cached) {
10614
+ cache.set(key3, { [alg]: cryptoKey });
10615
+ } else {
10616
+ cached[alg] = cryptoKey;
10617
+ }
10618
+ return cryptoKey;
10619
+ };
10620
+ var normalizePublicKey = (key3, alg) => {
10621
+ if (isKeyObject(key3)) {
10622
+ let jwk = key3.export({ format: "jwk" });
10623
+ delete jwk.d;
10624
+ delete jwk.dp;
10625
+ delete jwk.dq;
10626
+ delete jwk.p;
10627
+ delete jwk.q;
10628
+ delete jwk.qi;
10629
+ if (jwk.k) {
10630
+ return exportKeyValue(jwk.k);
10631
+ }
10632
+ pubCache || (pubCache = /* @__PURE__ */ new WeakMap());
10633
+ return importAndCache(pubCache, key3, jwk, alg);
10634
+ }
10635
+ if (isJWK(key3)) {
10636
+ if (key3.k)
10637
+ return decode(key3.k);
10638
+ pubCache || (pubCache = /* @__PURE__ */ new WeakMap());
10639
+ const cryptoKey = importAndCache(pubCache, key3, key3, alg, true);
10640
+ return cryptoKey;
10641
+ }
10642
+ return key3;
10643
+ };
10644
+ var normalizePrivateKey = (key3, alg) => {
10645
+ if (isKeyObject(key3)) {
10646
+ let jwk = key3.export({ format: "jwk" });
10647
+ if (jwk.k) {
10648
+ return exportKeyValue(jwk.k);
10649
+ }
10650
+ privCache || (privCache = /* @__PURE__ */ new WeakMap());
10651
+ return importAndCache(privCache, key3, jwk, alg);
10652
+ }
10653
+ if (isJWK(key3)) {
10654
+ if (key3.k)
10655
+ return decode(key3.k);
10656
+ privCache || (privCache = /* @__PURE__ */ new WeakMap());
10657
+ const cryptoKey = importAndCache(privCache, key3, key3, alg, true);
10658
+ return cryptoKey;
10659
+ }
10660
+ return key3;
10661
+ };
10662
+ var normalize_key_default = { normalizePublicKey, normalizePrivateKey };
10663
+
10581
10664
  // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/key/import.js
10582
10665
  async function importJWK(jwk, alg) {
10583
10666
  if (!isObject(jwk)) {
@@ -10603,45 +10686,76 @@ async function importJWK(jwk, alg) {
10603
10686
  }
10604
10687
 
10605
10688
  // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/lib/check_key_type.js
10606
- var symmetricTypeCheck = (alg, key3) => {
10689
+ var tag = (key3) => key3?.[Symbol.toStringTag];
10690
+ var jwkMatchesOp = (alg, key3, usage2) => {
10691
+ if (key3.use !== void 0 && key3.use !== "sig") {
10692
+ throw new TypeError("Invalid key for this operation, when present its use must be sig");
10693
+ }
10694
+ if (key3.key_ops !== void 0 && key3.key_ops.includes?.(usage2) !== true) {
10695
+ throw new TypeError(`Invalid key for this operation, when present its key_ops must include ${usage2}`);
10696
+ }
10697
+ if (key3.alg !== void 0 && key3.alg !== alg) {
10698
+ throw new TypeError(`Invalid key for this operation, when present its alg must be ${alg}`);
10699
+ }
10700
+ return true;
10701
+ };
10702
+ var symmetricTypeCheck = (alg, key3, usage2, allowJwk) => {
10607
10703
  if (key3 instanceof Uint8Array)
10608
10704
  return;
10705
+ if (allowJwk && isJWK(key3)) {
10706
+ if (isSecretJWK(key3) && jwkMatchesOp(alg, key3, usage2))
10707
+ return;
10708
+ throw new TypeError(`JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present`);
10709
+ }
10609
10710
  if (!is_key_like_default(key3)) {
10610
- throw new TypeError(withAlg(alg, key3, ...types, "Uint8Array"));
10711
+ throw new TypeError(withAlg(alg, key3, ...types, "Uint8Array", allowJwk ? "JSON Web Key" : null));
10611
10712
  }
10612
10713
  if (key3.type !== "secret") {
10613
- throw new TypeError(`${types.join(" or ")} instances for symmetric algorithms must be of type "secret"`);
10714
+ throw new TypeError(`${tag(key3)} instances for symmetric algorithms must be of type "secret"`);
10614
10715
  }
10615
10716
  };
10616
- var asymmetricTypeCheck = (alg, key3, usage2) => {
10717
+ var asymmetricTypeCheck = (alg, key3, usage2, allowJwk) => {
10718
+ if (allowJwk && isJWK(key3)) {
10719
+ switch (usage2) {
10720
+ case "sign":
10721
+ if (isPrivateJWK(key3) && jwkMatchesOp(alg, key3, usage2))
10722
+ return;
10723
+ throw new TypeError(`JSON Web Key for this operation be a private JWK`);
10724
+ case "verify":
10725
+ if (isPublicJWK(key3) && jwkMatchesOp(alg, key3, usage2))
10726
+ return;
10727
+ throw new TypeError(`JSON Web Key for this operation be a public JWK`);
10728
+ }
10729
+ }
10617
10730
  if (!is_key_like_default(key3)) {
10618
- throw new TypeError(withAlg(alg, key3, ...types));
10731
+ throw new TypeError(withAlg(alg, key3, ...types, allowJwk ? "JSON Web Key" : null));
10619
10732
  }
10620
10733
  if (key3.type === "secret") {
10621
- throw new TypeError(`${types.join(" or ")} instances for asymmetric algorithms must not be of type "secret"`);
10734
+ throw new TypeError(`${tag(key3)} instances for asymmetric algorithms must not be of type "secret"`);
10622
10735
  }
10623
10736
  if (usage2 === "sign" && key3.type === "public") {
10624
- throw new TypeError(`${types.join(" or ")} instances for asymmetric algorithm signing must be of type "private"`);
10737
+ throw new TypeError(`${tag(key3)} instances for asymmetric algorithm signing must be of type "private"`);
10625
10738
  }
10626
10739
  if (usage2 === "decrypt" && key3.type === "public") {
10627
- throw new TypeError(`${types.join(" or ")} instances for asymmetric algorithm decryption must be of type "private"`);
10740
+ throw new TypeError(`${tag(key3)} instances for asymmetric algorithm decryption must be of type "private"`);
10628
10741
  }
10629
10742
  if (key3.algorithm && usage2 === "verify" && key3.type === "private") {
10630
- throw new TypeError(`${types.join(" or ")} instances for asymmetric algorithm verifying must be of type "public"`);
10743
+ throw new TypeError(`${tag(key3)} instances for asymmetric algorithm verifying must be of type "public"`);
10631
10744
  }
10632
10745
  if (key3.algorithm && usage2 === "encrypt" && key3.type === "private") {
10633
- throw new TypeError(`${types.join(" or ")} instances for asymmetric algorithm encryption must be of type "public"`);
10746
+ throw new TypeError(`${tag(key3)} instances for asymmetric algorithm encryption must be of type "public"`);
10634
10747
  }
10635
10748
  };
10636
- var checkKeyType = (alg, key3, usage2) => {
10749
+ function checkKeyType(allowJwk, alg, key3, usage2) {
10637
10750
  const symmetric = alg.startsWith("HS") || alg === "dir" || alg.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(alg);
10638
10751
  if (symmetric) {
10639
- symmetricTypeCheck(alg, key3);
10752
+ symmetricTypeCheck(alg, key3, usage2, allowJwk);
10640
10753
  } else {
10641
- asymmetricTypeCheck(alg, key3, usage2);
10754
+ asymmetricTypeCheck(alg, key3, usage2, allowJwk);
10642
10755
  }
10643
- };
10644
- var check_key_type_default = checkKeyType;
10756
+ }
10757
+ var check_key_type_default = checkKeyType.bind(void 0, false);
10758
+ var checkKeyTypeWithJwk = checkKeyType.bind(void 0, true);
10645
10759
 
10646
10760
  // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/lib/validate_crit.js
10647
10761
  function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
@@ -10711,9 +10825,6 @@ async function exportJWK(key3) {
10711
10825
  return key_to_jwk_default(key3);
10712
10826
  }
10713
10827
 
10714
- // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/jwe/flattened/encrypt.js
10715
- var unprotected = Symbol();
10716
-
10717
10828
  // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/runtime/subtle_dsa.js
10718
10829
  function subtleDsa(alg, algorithm3) {
10719
10830
  const hash2 = `SHA-${alg.slice(-3)}`;
@@ -10742,7 +10853,13 @@ function subtleDsa(alg, algorithm3) {
10742
10853
  }
10743
10854
 
10744
10855
  // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/runtime/get_sign_verify_key.js
10745
- function getCryptoKey(alg, key3, usage2) {
10856
+ async function getCryptoKey(alg, key3, usage2) {
10857
+ if (usage2 === "sign") {
10858
+ key3 = await normalize_key_default.normalizePrivateKey(key3, alg);
10859
+ }
10860
+ if (usage2 === "verify") {
10861
+ key3 = await normalize_key_default.normalizePublicKey(key3, alg);
10862
+ }
10746
10863
  if (isCryptoKey(key3)) {
10747
10864
  checkSigCryptoKey(key3, alg, usage2);
10748
10865
  return key3;
@@ -10753,7 +10870,7 @@ function getCryptoKey(alg, key3, usage2) {
10753
10870
  }
10754
10871
  return webcrypto_default.subtle.importKey("raw", key3, { hash: `SHA-${alg.slice(-3)}`, name: "HMAC" }, false, [usage2]);
10755
10872
  }
10756
- throw new TypeError(invalid_key_input_default(key3, ...types, "Uint8Array"));
10873
+ throw new TypeError(invalid_key_input_default(key3, ...types, "Uint8Array", "JSON Web Key"));
10757
10874
  }
10758
10875
 
10759
10876
  // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/runtime/verify.js
@@ -10832,8 +10949,13 @@ async function flattenedVerify(jws2, key3, options) {
10832
10949
  if (typeof key3 === "function") {
10833
10950
  key3 = await key3(parsedProt, jws2);
10834
10951
  resolvedKey = true;
10952
+ checkKeyTypeWithJwk(alg, key3, "verify");
10953
+ if (isJWK(key3)) {
10954
+ key3 = await importJWK(key3, alg);
10955
+ }
10956
+ } else {
10957
+ checkKeyTypeWithJwk(alg, key3, "verify");
10835
10958
  }
10836
- check_key_type_default(alg, key3, "verify");
10837
10959
  const data2 = concat(encoder.encode(jws2.protected ?? ""), encoder.encode("."), typeof jws2.payload === "string" ? encoder.encode(jws2.payload) : jws2.payload);
10838
10960
  let signature2;
10839
10961
  try {
@@ -10962,10 +11084,6 @@ var checkAudiencePresence = (audPayload, audOption) => {
10962
11084
  return false;
10963
11085
  };
10964
11086
  var jwt_claims_set_default = (protectedHeader, encodedPayload, options = {}) => {
10965
- const { typ } = options;
10966
- if (typ && (typeof protectedHeader.typ !== "string" || normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ))) {
10967
- throw new JWTClaimValidationFailed('unexpected "typ" JWT header value', "typ", "check_failed");
10968
- }
10969
11087
  let payload4;
10970
11088
  try {
10971
11089
  payload4 = JSON.parse(decoder.decode(encodedPayload));
@@ -10974,6 +11092,10 @@ var jwt_claims_set_default = (protectedHeader, encodedPayload, options = {}) =>
10974
11092
  if (!isObject(payload4)) {
10975
11093
  throw new JWTInvalid("JWT Claims Set must be a top-level JSON object");
10976
11094
  }
11095
+ const { typ } = options;
11096
+ if (typ && (typeof protectedHeader.typ !== "string" || normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ))) {
11097
+ throw new JWTClaimValidationFailed('unexpected "typ" JWT header value', payload4, "typ", "check_failed");
11098
+ }
10977
11099
  const { requiredClaims = [], issuer: issuer2, subject: subject5, audience: audience5, maxTokenAge } = options;
10978
11100
  const presenceCheck = [...requiredClaims];
10979
11101
  if (maxTokenAge !== void 0)
@@ -10986,17 +11108,17 @@ var jwt_claims_set_default = (protectedHeader, encodedPayload, options = {}) =>
10986
11108
  presenceCheck.push("iss");
10987
11109
  for (const claim2 of new Set(presenceCheck.reverse())) {
10988
11110
  if (!(claim2 in payload4)) {
10989
- throw new JWTClaimValidationFailed(`missing required "${claim2}" claim`, claim2, "missing");
11111
+ throw new JWTClaimValidationFailed(`missing required "${claim2}" claim`, payload4, claim2, "missing");
10990
11112
  }
10991
11113
  }
10992
11114
  if (issuer2 && !(Array.isArray(issuer2) ? issuer2 : [issuer2]).includes(payload4.iss)) {
10993
- throw new JWTClaimValidationFailed('unexpected "iss" claim value', "iss", "check_failed");
11115
+ throw new JWTClaimValidationFailed('unexpected "iss" claim value', payload4, "iss", "check_failed");
10994
11116
  }
10995
11117
  if (subject5 && payload4.sub !== subject5) {
10996
- throw new JWTClaimValidationFailed('unexpected "sub" claim value', "sub", "check_failed");
11118
+ throw new JWTClaimValidationFailed('unexpected "sub" claim value', payload4, "sub", "check_failed");
10997
11119
  }
10998
11120
  if (audience5 && !checkAudiencePresence(payload4.aud, typeof audience5 === "string" ? [audience5] : audience5)) {
10999
- throw new JWTClaimValidationFailed('unexpected "aud" claim value', "aud", "check_failed");
11121
+ throw new JWTClaimValidationFailed('unexpected "aud" claim value', payload4, "aud", "check_failed");
11000
11122
  }
11001
11123
  let tolerance;
11002
11124
  switch (typeof options.clockTolerance) {
@@ -11015,32 +11137,32 @@ var jwt_claims_set_default = (protectedHeader, encodedPayload, options = {}) =>
11015
11137
  const { currentDate } = options;
11016
11138
  const now = epoch_default(currentDate || /* @__PURE__ */ new Date());
11017
11139
  if ((payload4.iat !== void 0 || maxTokenAge) && typeof payload4.iat !== "number") {
11018
- throw new JWTClaimValidationFailed('"iat" claim must be a number', "iat", "invalid");
11140
+ throw new JWTClaimValidationFailed('"iat" claim must be a number', payload4, "iat", "invalid");
11019
11141
  }
11020
11142
  if (payload4.nbf !== void 0) {
11021
11143
  if (typeof payload4.nbf !== "number") {
11022
- throw new JWTClaimValidationFailed('"nbf" claim must be a number', "nbf", "invalid");
11144
+ throw new JWTClaimValidationFailed('"nbf" claim must be a number', payload4, "nbf", "invalid");
11023
11145
  }
11024
11146
  if (payload4.nbf > now + tolerance) {
11025
- throw new JWTClaimValidationFailed('"nbf" claim timestamp check failed', "nbf", "check_failed");
11147
+ throw new JWTClaimValidationFailed('"nbf" claim timestamp check failed', payload4, "nbf", "check_failed");
11026
11148
  }
11027
11149
  }
11028
11150
  if (payload4.exp !== void 0) {
11029
11151
  if (typeof payload4.exp !== "number") {
11030
- throw new JWTClaimValidationFailed('"exp" claim must be a number', "exp", "invalid");
11152
+ throw new JWTClaimValidationFailed('"exp" claim must be a number', payload4, "exp", "invalid");
11031
11153
  }
11032
11154
  if (payload4.exp <= now - tolerance) {
11033
- throw new JWTExpired('"exp" claim timestamp check failed', "exp", "check_failed");
11155
+ throw new JWTExpired('"exp" claim timestamp check failed', payload4, "exp", "check_failed");
11034
11156
  }
11035
11157
  }
11036
11158
  if (maxTokenAge) {
11037
11159
  const age2 = now - payload4.iat;
11038
11160
  const max2 = typeof maxTokenAge === "number" ? maxTokenAge : secs_default(maxTokenAge);
11039
11161
  if (age2 - tolerance > max2) {
11040
- throw new JWTExpired('"iat" claim timestamp check failed (too far in the past)', "iat", "check_failed");
11162
+ throw new JWTExpired('"iat" claim timestamp check failed (too far in the past)', payload4, "iat", "check_failed");
11041
11163
  }
11042
11164
  if (age2 < 0 - tolerance) {
11043
- throw new JWTClaimValidationFailed('"iat" claim timestamp check failed (it should be in the past)', "iat", "check_failed");
11165
+ throw new JWTClaimValidationFailed('"iat" claim timestamp check failed (it should be in the past)', payload4, "iat", "check_failed");
11044
11166
  }
11045
11167
  }
11046
11168
  return payload4;
@@ -11114,7 +11236,7 @@ var FlattenedSign = class {
11114
11236
  if (typeof alg !== "string" || !alg) {
11115
11237
  throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
11116
11238
  }
11117
- check_key_type_default(alg, key3, "sign");
11239
+ checkKeyTypeWithJwk(alg, key3, "sign");
11118
11240
  let payload4 = this._payload;
11119
11241
  if (b64) {
11120
11242
  payload4 = encoder.encode(encode(payload4));
@@ -11403,9 +11525,22 @@ function isCloudflareWorkers() {
11403
11525
  var USER_AGENT;
11404
11526
  if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) {
11405
11527
  const NAME = "jose";
11406
- const VERSION = "v5.3.0";
11528
+ const VERSION = "v5.9.3";
11407
11529
  USER_AGENT = `${NAME}/${VERSION}`;
11408
11530
  }
11531
+ var jwksCache = Symbol();
11532
+ function isFreshJwksCache(input2, cacheMaxAge) {
11533
+ if (typeof input2 !== "object" || input2 === null) {
11534
+ return false;
11535
+ }
11536
+ if (!("uat" in input2) || typeof input2.uat !== "number" || Date.now() - input2.uat >= cacheMaxAge) {
11537
+ return false;
11538
+ }
11539
+ if (!("jwks" in input2) || !isObject(input2.jwks) || !Array.isArray(input2.jwks.keys) || !Array.prototype.every.call(input2.jwks.keys, isObject)) {
11540
+ return false;
11541
+ }
11542
+ return true;
11543
+ }
11409
11544
  var RemoteJWKSet = class {
11410
11545
  constructor(url7, options) {
11411
11546
  if (!(url7 instanceof URL)) {
@@ -11416,6 +11551,13 @@ var RemoteJWKSet = class {
11416
11551
  this._timeoutDuration = typeof options?.timeoutDuration === "number" ? options?.timeoutDuration : 5e3;
11417
11552
  this._cooldownDuration = typeof options?.cooldownDuration === "number" ? options?.cooldownDuration : 3e4;
11418
11553
  this._cacheMaxAge = typeof options?.cacheMaxAge === "number" ? options?.cacheMaxAge : 6e5;
11554
+ if (options?.[jwksCache] !== void 0) {
11555
+ this._cache = options?.[jwksCache];
11556
+ if (isFreshJwksCache(options?.[jwksCache], this._cacheMaxAge)) {
11557
+ this._jwksTimestamp = this._cache.uat;
11558
+ this._local = createLocalJWKSet(this._cache.jwks);
11559
+ }
11560
+ }
11419
11561
  }
11420
11562
  coolingDown() {
11421
11563
  return typeof this._jwksTimestamp === "number" ? Date.now() < this._jwksTimestamp + this._cooldownDuration : false;
@@ -11450,6 +11592,10 @@ var RemoteJWKSet = class {
11450
11592
  }
11451
11593
  this._pendingFetch || (this._pendingFetch = fetch_jwks_default(this._url, this._timeoutDuration, this._options).then((json) => {
11452
11594
  this._local = createLocalJWKSet(json);
11595
+ if (this._cache) {
11596
+ this._cache.uat = Date.now();
11597
+ this._cache.jwks = json;
11598
+ }
11453
11599
  this._jwksTimestamp = Date.now();
11454
11600
  this._pendingFetch = void 0;
11455
11601
  }).catch((err) => {
@@ -11598,7 +11744,17 @@ async function generateKeyPair2(alg, options) {
11598
11744
  return generateKeyPair(alg, options);
11599
11745
  }
11600
11746
 
11601
- // ../node_modules/uuid/dist/esm-browser/rng.js
11747
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/uuid/dist/esm-browser/stringify.js
11748
+ var byteToHex = [];
11749
+ for (i = 0; i < 256; ++i) {
11750
+ byteToHex.push((i + 256).toString(16).slice(1));
11751
+ }
11752
+ var i;
11753
+ function unsafeStringify(arr, offset3 = 0) {
11754
+ return (byteToHex[arr[offset3 + 0]] + byteToHex[arr[offset3 + 1]] + byteToHex[arr[offset3 + 2]] + byteToHex[arr[offset3 + 3]] + "-" + byteToHex[arr[offset3 + 4]] + byteToHex[arr[offset3 + 5]] + "-" + byteToHex[arr[offset3 + 6]] + byteToHex[arr[offset3 + 7]] + "-" + byteToHex[arr[offset3 + 8]] + byteToHex[arr[offset3 + 9]] + "-" + byteToHex[arr[offset3 + 10]] + byteToHex[arr[offset3 + 11]] + byteToHex[arr[offset3 + 12]] + byteToHex[arr[offset3 + 13]] + byteToHex[arr[offset3 + 14]] + byteToHex[arr[offset3 + 15]]).toLowerCase();
11755
+ }
11756
+
11757
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/uuid/dist/esm-browser/rng.js
11602
11758
  var getRandomValues;
11603
11759
  var rnds8 = new Uint8Array(16);
11604
11760
  function rng() {
@@ -11611,33 +11767,24 @@ function rng() {
11611
11767
  return getRandomValues(rnds8);
11612
11768
  }
11613
11769
 
11614
- // ../node_modules/uuid/dist/esm-browser/stringify.js
11615
- var byteToHex = [];
11616
- for (let i = 0; i < 256; ++i) {
11617
- byteToHex.push((i + 256).toString(16).slice(1));
11618
- }
11619
- function unsafeStringify(arr, offset3 = 0) {
11620
- return byteToHex[arr[offset3 + 0]] + byteToHex[arr[offset3 + 1]] + byteToHex[arr[offset3 + 2]] + byteToHex[arr[offset3 + 3]] + "-" + byteToHex[arr[offset3 + 4]] + byteToHex[arr[offset3 + 5]] + "-" + byteToHex[arr[offset3 + 6]] + byteToHex[arr[offset3 + 7]] + "-" + byteToHex[arr[offset3 + 8]] + byteToHex[arr[offset3 + 9]] + "-" + byteToHex[arr[offset3 + 10]] + byteToHex[arr[offset3 + 11]] + byteToHex[arr[offset3 + 12]] + byteToHex[arr[offset3 + 13]] + byteToHex[arr[offset3 + 14]] + byteToHex[arr[offset3 + 15]];
11621
- }
11622
-
11623
- // ../node_modules/uuid/dist/esm-browser/native.js
11770
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/uuid/dist/esm-browser/native.js
11624
11771
  var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
11625
11772
  var native_default = {
11626
11773
  randomUUID
11627
11774
  };
11628
11775
 
11629
- // ../node_modules/uuid/dist/esm-browser/v4.js
11776
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/uuid/dist/esm-browser/v4.js
11630
11777
  function v4(options, buf, offset3) {
11631
11778
  if (native_default.randomUUID && !buf && !options) {
11632
11779
  return native_default.randomUUID();
11633
11780
  }
11634
11781
  options = options || {};
11635
- const rnds = options.random || (options.rng || rng)();
11782
+ var rnds = options.random || (options.rng || rng)();
11636
11783
  rnds[6] = rnds[6] & 15 | 64;
11637
11784
  rnds[8] = rnds[8] & 63 | 128;
11638
11785
  if (buf) {
11639
11786
  offset3 = offset3 || 0;
11640
- for (let i = 0; i < 16; ++i) {
11787
+ for (var i = 0; i < 16; ++i) {
11641
11788
  buf[offset3 + i] = rnds[i];
11642
11789
  }
11643
11790
  return buf;
@@ -11703,6 +11850,7 @@ var AggregateHandler = class {
11703
11850
  };
11704
11851
  async function getWebidFromTokenPayload(idToken, jwksIri, issuerIri, clientId) {
11705
11852
  let payload4;
11853
+ let clientIdInPayload;
11706
11854
  try {
11707
11855
  const { payload: verifiedPayload } = await jwtVerify(idToken, createRemoteJWKSet(new URL(jwksIri)), {
11708
11856
  issuer: issuerIri,
@@ -11712,15 +11860,24 @@ async function getWebidFromTokenPayload(idToken, jwksIri, issuerIri, clientId) {
11712
11860
  } catch (e) {
11713
11861
  throw new Error(`Token verification failed: ${e.stack}`);
11714
11862
  }
11863
+ if (typeof payload4.azp === "string") {
11864
+ clientIdInPayload = payload4.azp;
11865
+ }
11715
11866
  if (typeof payload4.webid === "string") {
11716
- return payload4.webid;
11867
+ return {
11868
+ webId: payload4.webid,
11869
+ clientId: clientIdInPayload
11870
+ };
11717
11871
  }
11718
11872
  if (typeof payload4.sub !== "string") {
11719
11873
  throw new Error(`The token ${JSON.stringify(payload4)} is invalid: it has no 'webid' claim and no 'sub' claim.`);
11720
11874
  }
11721
11875
  try {
11722
11876
  new URL(payload4.sub);
11723
- return payload4.sub;
11877
+ return {
11878
+ webId: payload4.sub,
11879
+ clientId: clientIdInPayload
11880
+ };
11724
11881
  } catch (e) {
11725
11882
  throw new Error(`The token has no 'webid' claim, and its 'sub' claim of [${payload4.sub}] is invalid as a URL - error [${e}].`);
11726
11883
  }
@@ -12045,6 +12202,26 @@ async function loadOidcContextFromStorage(sessionId, storageUtility, configFetch
12045
12202
  throw new Error(`Failed to retrieve OIDC context from storage associated with session [${sessionId}]: ${e}`);
12046
12203
  }
12047
12204
  }
12205
+ async function saveSessionInfoToStorage(storageUtility, sessionId, webId, clientId, isLoggedIn2, refreshToken, secure, dpopKey) {
12206
+ if (refreshToken !== void 0) {
12207
+ await storageUtility.setForUser(sessionId, { refreshToken }, { secure });
12208
+ }
12209
+ if (webId !== void 0) {
12210
+ await storageUtility.setForUser(sessionId, { webId }, { secure });
12211
+ }
12212
+ if (clientId !== void 0) {
12213
+ await storageUtility.setForUser(sessionId, { clientId }, { secure });
12214
+ }
12215
+ if (isLoggedIn2 !== void 0) {
12216
+ await storageUtility.setForUser(sessionId, { isLoggedIn: isLoggedIn2 }, { secure });
12217
+ }
12218
+ if (dpopKey !== void 0) {
12219
+ await storageUtility.setForUser(sessionId, {
12220
+ publicKey: JSON.stringify(dpopKey.publicKey),
12221
+ privateKey: JSON.stringify(await exportJWK(dpopKey.privateKey))
12222
+ }, { secure });
12223
+ }
12224
+ }
12048
12225
  var StorageUtility = class {
12049
12226
  constructor(secureStorage, insecureStorage) {
12050
12227
  this.secureStorage = secureStorage;
@@ -12288,6 +12465,55 @@ async function buildAuthenticatedFetch(accessToken, options) {
12288
12465
  };
12289
12466
  }
12290
12467
 
12468
+ // ../node_modules/@inrupt/solid-client-authn-browser/node_modules/uuid/dist/esm-browser/stringify.js
12469
+ var byteToHex2 = [];
12470
+ for (i = 0; i < 256; ++i) {
12471
+ byteToHex2.push((i + 256).toString(16).slice(1));
12472
+ }
12473
+ var i;
12474
+ function unsafeStringify2(arr, offset3 = 0) {
12475
+ return (byteToHex2[arr[offset3 + 0]] + byteToHex2[arr[offset3 + 1]] + byteToHex2[arr[offset3 + 2]] + byteToHex2[arr[offset3 + 3]] + "-" + byteToHex2[arr[offset3 + 4]] + byteToHex2[arr[offset3 + 5]] + "-" + byteToHex2[arr[offset3 + 6]] + byteToHex2[arr[offset3 + 7]] + "-" + byteToHex2[arr[offset3 + 8]] + byteToHex2[arr[offset3 + 9]] + "-" + byteToHex2[arr[offset3 + 10]] + byteToHex2[arr[offset3 + 11]] + byteToHex2[arr[offset3 + 12]] + byteToHex2[arr[offset3 + 13]] + byteToHex2[arr[offset3 + 14]] + byteToHex2[arr[offset3 + 15]]).toLowerCase();
12476
+ }
12477
+
12478
+ // ../node_modules/@inrupt/solid-client-authn-browser/node_modules/uuid/dist/esm-browser/rng.js
12479
+ var getRandomValues2;
12480
+ var rnds82 = new Uint8Array(16);
12481
+ function rng2() {
12482
+ if (!getRandomValues2) {
12483
+ getRandomValues2 = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
12484
+ if (!getRandomValues2) {
12485
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
12486
+ }
12487
+ }
12488
+ return getRandomValues2(rnds82);
12489
+ }
12490
+
12491
+ // ../node_modules/@inrupt/solid-client-authn-browser/node_modules/uuid/dist/esm-browser/native.js
12492
+ var randomUUID2 = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
12493
+ var native_default2 = {
12494
+ randomUUID: randomUUID2
12495
+ };
12496
+
12497
+ // ../node_modules/@inrupt/solid-client-authn-browser/node_modules/uuid/dist/esm-browser/v4.js
12498
+ function v42(options, buf, offset3) {
12499
+ if (native_default2.randomUUID && !buf && !options) {
12500
+ return native_default2.randomUUID();
12501
+ }
12502
+ options = options || {};
12503
+ var rnds = options.random || (options.rng || rng2)();
12504
+ rnds[6] = rnds[6] & 15 | 64;
12505
+ rnds[8] = rnds[8] & 63 | 128;
12506
+ if (buf) {
12507
+ offset3 = offset3 || 0;
12508
+ for (var i = 0; i < 16; ++i) {
12509
+ buf[offset3 + i] = rnds[i];
12510
+ }
12511
+ return buf;
12512
+ }
12513
+ return unsafeStringify2(rnds);
12514
+ }
12515
+ var v4_default2 = v42;
12516
+
12291
12517
  // ../node_modules/@inrupt/solid-client-authn-browser/dist/index.mjs
12292
12518
  var import_events = __toESM(require_events(), 1);
12293
12519
 
@@ -12440,12 +12666,13 @@ async function getTokens(issuer2, client, data2, dpop) {
12440
12666
  const rawTokenResponse = await fetch(issuer2.tokenEndpoint, tokenRequestInit);
12441
12667
  const jsonTokenResponse = await rawTokenResponse.json();
12442
12668
  const tokenResponse = validateTokenEndpointResponse(jsonTokenResponse, dpop);
12443
- const webId = await getWebidFromTokenPayload(tokenResponse.id_token, issuer2.jwksUri, issuer2.issuer, client.clientId);
12669
+ const { webId, clientId } = await getWebidFromTokenPayload(tokenResponse.id_token, issuer2.jwksUri, issuer2.issuer, client.clientId);
12444
12670
  return {
12445
12671
  accessToken: tokenResponse.access_token,
12446
12672
  idToken: tokenResponse.id_token,
12447
12673
  refreshToken: hasRefreshToken(tokenResponse) ? tokenResponse.refresh_token : void 0,
12448
12674
  webId,
12675
+ clientId,
12449
12676
  dpopKey,
12450
12677
  expiresIn: tokenResponse.expires_in
12451
12678
  };
@@ -12499,7 +12726,7 @@ async function refresh(refreshToken, issuer2, client, dpopKey) {
12499
12726
  throw new Error(`The token endpoint of issuer ${issuer2.issuer} returned a malformed response.`);
12500
12727
  }
12501
12728
  const validatedResponse = validateTokenEndpointResponse(response6, dpopKey !== void 0);
12502
- const webId = await getWebidFromTokenPayload(validatedResponse.id_token, issuer2.jwksUri, issuer2.issuer, client.clientId);
12729
+ const { webId } = await getWebidFromTokenPayload(validatedResponse.id_token, issuer2.jwksUri, issuer2.issuer, client.clientId);
12503
12730
  return {
12504
12731
  accessToken: validatedResponse.access_token,
12505
12732
  idToken: validatedResponse.id_token,
@@ -12589,7 +12816,8 @@ var ClientAuthentication2 = class extends ClientAuthentication {
12589
12816
  isLoggedIn: redirectInfo.isLoggedIn,
12590
12817
  webId: redirectInfo.webId,
12591
12818
  sessionId: redirectInfo.sessionId,
12592
- expirationDate: redirectInfo.expirationDate
12819
+ expirationDate: redirectInfo.expirationDate,
12820
+ clientAppId: redirectInfo.clientAppId
12593
12821
  };
12594
12822
  } catch (err) {
12595
12823
  await this.cleanUrlAfterRedirect(url7);
@@ -12963,10 +13191,7 @@ var AuthCodeRedirectHandler = class {
12963
13191
  eventEmitter,
12964
13192
  expiresIn: tokens.expiresIn
12965
13193
  });
12966
- await this.storageUtility.setForUser(storedSessionId, {
12967
- webId: tokens.webId,
12968
- isLoggedIn: "true"
12969
- }, { secure: true });
13194
+ await saveSessionInfoToStorage(this.storageUtility, storedSessionId, tokens.webId, tokens.clientId, "true", void 0, true);
12970
13195
  const sessionInfo = await this.sessionInfoManager.get(storedSessionId);
12971
13196
  if (!sessionInfo) {
12972
13197
  throw new Error(`Could not retrieve session: [${storedSessionId}].`);
@@ -13103,9 +13328,6 @@ var TokenRefresher = class {
13103
13328
  const tokenSet = await refresh(refreshToken, oidcContext.issuerConfig, clientInfo, dpopKey);
13104
13329
  if (tokenSet.refreshToken !== void 0) {
13105
13330
  eventEmitter === null || eventEmitter === void 0 ? void 0 : eventEmitter.emit(EVENTS.NEW_REFRESH_TOKEN, tokenSet.refreshToken);
13106
- await this.storageUtility.setForUser(sessionId, {
13107
- refreshToken: tokenSet.refreshToken
13108
- });
13109
13331
  }
13110
13332
  return tokenSet;
13111
13333
  }
@@ -13241,11 +13463,12 @@ var Session = class {
13241
13463
  this.info = {
13242
13464
  sessionId: sessionOptions.sessionInfo.sessionId,
13243
13465
  isLoggedIn: false,
13244
- webId: sessionOptions.sessionInfo.webId
13466
+ webId: sessionOptions.sessionInfo.webId,
13467
+ clientAppId: sessionOptions.sessionInfo.clientAppId
13245
13468
  };
13246
13469
  } else {
13247
13470
  this.info = {
13248
- sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : v4_default(),
13471
+ sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : v4_default2(),
13249
13472
  isLoggedIn: false
13250
13473
  };
13251
13474
  }
@@ -13257,6 +13480,7 @@ var Session = class {
13257
13480
  this.info.isLoggedIn = sessionInfo.isLoggedIn;
13258
13481
  this.info.webId = sessionInfo.webId;
13259
13482
  this.info.sessionId = sessionInfo.sessionId;
13483
+ this.info.clientAppId = sessionInfo.clientAppId;
13260
13484
  this.info.expirationDate = sessionInfo.expirationDate;
13261
13485
  this.events.on(EVENTS.SESSION_EXTENDED, (expiresIn) => {
13262
13486
  this.info.expirationDate = Date.now() + expiresIn * 1e3;
@@ -13376,7 +13600,7 @@ var FileFetcher = class {
13376
13600
 
13377
13601
  // src/modules/contacts.ts
13378
13602
  async function loadContactsModule(store) {
13379
- const module2 = await import("./dist-TVYD2Q5S.js");
13603
+ const module2 = await import("./dist-F3EUFQHU.js");
13380
13604
  return new module2.default({
13381
13605
  store: store.graph,
13382
13606
  fetcher: store.fetcher,
@@ -13891,7 +14115,7 @@ var provider = "http://www.w3.org/ns/activitystreams#provider";
13891
14115
  var replies = "http://www.w3.org/ns/activitystreams#replies";
13892
14116
  var result = "http://www.w3.org/ns/activitystreams#result";
13893
14117
  var audience = "http://www.w3.org/ns/activitystreams#audience";
13894
- var tag = "http://www.w3.org/ns/activitystreams#tag";
14118
+ var tag2 = "http://www.w3.org/ns/activitystreams#tag";
13895
14119
  var tags = "http://www.w3.org/ns/activitystreams#tags";
13896
14120
  var target = "http://www.w3.org/ns/activitystreams#target";
13897
14121
  var origin2 = "http://www.w3.org/ns/activitystreams#origin";
@@ -14009,7 +14233,7 @@ var asImport = /* @__PURE__ */ Object.freeze({
14009
14233
  replies,
14010
14234
  result,
14011
14235
  audience,
14012
- tag,
14236
+ tag: tag2,
14013
14237
  tags,
14014
14238
  target,
14015
14239
  origin: origin2,
@@ -18460,7 +18684,7 @@ var Patient = "http://hl7.org/fhir/Patient";
18460
18684
  var _identified = "http://hl7.org/fhir/_identified";
18461
18685
  var ExplanationOfBenefitAdjudication = "http://hl7.org/fhir/ExplanationOfBenefitAdjudication";
18462
18686
  var _Subscription = "http://hl7.org/fhir/_Subscription";
18463
- var tag2 = "http://hl7.org/fhir/tag";
18687
+ var tag3 = "http://hl7.org/fhir/tag";
18464
18688
  var _performed = "http://hl7.org/fhir/_performed";
18465
18689
  var _formOf = "http://hl7.org/fhir/_formOf";
18466
18690
  var DeviceDefinitionPackagingComponentPackagingPackaging = "http://hl7.org/fhir/DeviceDefinitionPackagingComponentPackagingPackaging";
@@ -22693,7 +22917,7 @@ var fhirImport = /* @__PURE__ */ Object.freeze({
22693
22917
  _identified,
22694
22918
  ExplanationOfBenefitAdjudication,
22695
22919
  _Subscription,
22696
- tag: tag2,
22920
+ tag: tag3,
22697
22921
  _performed,
22698
22922
  _formOf,
22699
22923
  DeviceDefinitionPackagingComponentPackagingPackaging,