@pod-os/core 0.12.1-b3f906d.0 → 0.12.1-d90fec2.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/lib/index.js CHANGED
@@ -60,22 +60,22 @@ var PodOS = (() => {
60
60
  var NumberIsNaN = Number.isNaN || function NumberIsNaN2(value6) {
61
61
  return value6 !== value6;
62
62
  };
63
- function EventEmitter3() {
64
- EventEmitter3.init.call(this);
63
+ function EventEmitter2() {
64
+ EventEmitter2.init.call(this);
65
65
  }
66
- module3.exports = EventEmitter3;
66
+ module3.exports = EventEmitter2;
67
67
  module3.exports.once = once;
68
- EventEmitter3.EventEmitter = EventEmitter3;
69
- EventEmitter3.prototype._events = void 0;
70
- EventEmitter3.prototype._eventsCount = 0;
71
- EventEmitter3.prototype._maxListeners = void 0;
68
+ EventEmitter2.EventEmitter = EventEmitter2;
69
+ EventEmitter2.prototype._events = void 0;
70
+ EventEmitter2.prototype._eventsCount = 0;
71
+ EventEmitter2.prototype._maxListeners = void 0;
72
72
  var defaultMaxListeners = 10;
73
73
  function checkListener(listener) {
74
74
  if (typeof listener !== "function") {
75
75
  throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
76
76
  }
77
77
  }
78
- Object.defineProperty(EventEmitter3, "defaultMaxListeners", {
78
+ Object.defineProperty(EventEmitter2, "defaultMaxListeners", {
79
79
  enumerable: true,
80
80
  get: function() {
81
81
  return defaultMaxListeners;
@@ -87,14 +87,14 @@ var PodOS = (() => {
87
87
  defaultMaxListeners = arg2;
88
88
  }
89
89
  });
90
- EventEmitter3.init = function() {
90
+ EventEmitter2.init = function() {
91
91
  if (this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) {
92
92
  this._events = /* @__PURE__ */ Object.create(null);
93
93
  this._eventsCount = 0;
94
94
  }
95
95
  this._maxListeners = this._maxListeners || void 0;
96
96
  };
97
- EventEmitter3.prototype.setMaxListeners = function setMaxListeners(n2) {
97
+ EventEmitter2.prototype.setMaxListeners = function setMaxListeners(n2) {
98
98
  if (typeof n2 !== "number" || n2 < 0 || NumberIsNaN(n2)) {
99
99
  throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n2 + ".");
100
100
  }
@@ -103,13 +103,13 @@ var PodOS = (() => {
103
103
  };
104
104
  function _getMaxListeners(that) {
105
105
  if (that._maxListeners === void 0)
106
- return EventEmitter3.defaultMaxListeners;
106
+ return EventEmitter2.defaultMaxListeners;
107
107
  return that._maxListeners;
108
108
  }
109
- EventEmitter3.prototype.getMaxListeners = function getMaxListeners() {
109
+ EventEmitter2.prototype.getMaxListeners = function getMaxListeners() {
110
110
  return _getMaxListeners(this);
111
111
  };
112
- EventEmitter3.prototype.emit = function emit(type5) {
112
+ EventEmitter2.prototype.emit = function emit(type5) {
113
113
  var args = [];
114
114
  for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
115
115
  var doError = type5 === "error";
@@ -186,11 +186,11 @@ var PodOS = (() => {
186
186
  }
187
187
  return target5;
188
188
  }
189
- EventEmitter3.prototype.addListener = function addListener(type5, listener) {
189
+ EventEmitter2.prototype.addListener = function addListener(type5, listener) {
190
190
  return _addListener(this, type5, listener, false);
191
191
  };
192
- EventEmitter3.prototype.on = EventEmitter3.prototype.addListener;
193
- EventEmitter3.prototype.prependListener = function prependListener(type5, listener) {
192
+ EventEmitter2.prototype.on = EventEmitter2.prototype.addListener;
193
+ EventEmitter2.prototype.prependListener = function prependListener(type5, listener) {
194
194
  return _addListener(this, type5, listener, true);
195
195
  };
196
196
  function onceWrapper() {
@@ -209,17 +209,17 @@ var PodOS = (() => {
209
209
  state2.wrapFn = wrapped;
210
210
  return wrapped;
211
211
  }
212
- EventEmitter3.prototype.once = function once2(type5, listener) {
212
+ EventEmitter2.prototype.once = function once2(type5, listener) {
213
213
  checkListener(listener);
214
214
  this.on(type5, _onceWrap(this, type5, listener));
215
215
  return this;
216
216
  };
217
- EventEmitter3.prototype.prependOnceListener = function prependOnceListener(type5, listener) {
217
+ EventEmitter2.prototype.prependOnceListener = function prependOnceListener(type5, listener) {
218
218
  checkListener(listener);
219
219
  this.prependListener(type5, _onceWrap(this, type5, listener));
220
220
  return this;
221
221
  };
222
- EventEmitter3.prototype.removeListener = function removeListener(type5, listener) {
222
+ EventEmitter2.prototype.removeListener = function removeListener(type5, listener) {
223
223
  var list, events3, position4, i, originalListener;
224
224
  checkListener(listener);
225
225
  events3 = this._events;
@@ -259,8 +259,8 @@ var PodOS = (() => {
259
259
  }
260
260
  return this;
261
261
  };
262
- EventEmitter3.prototype.off = EventEmitter3.prototype.removeListener;
263
- EventEmitter3.prototype.removeAllListeners = function removeAllListeners(type5) {
262
+ EventEmitter2.prototype.off = EventEmitter2.prototype.removeListener;
263
+ EventEmitter2.prototype.removeAllListeners = function removeAllListeners(type5) {
264
264
  var listeners, events3, i;
265
265
  events3 = this._events;
266
266
  if (events3 === void 0)
@@ -300,7 +300,7 @@ var PodOS = (() => {
300
300
  }
301
301
  return this;
302
302
  };
303
- function _listeners(target5, type5, unwrap3) {
303
+ function _listeners(target5, type5, unwrap) {
304
304
  var events3 = target5._events;
305
305
  if (events3 === void 0)
306
306
  return [];
@@ -308,23 +308,23 @@ var PodOS = (() => {
308
308
  if (evlistener === void 0)
309
309
  return [];
310
310
  if (typeof evlistener === "function")
311
- return unwrap3 ? [evlistener.listener || evlistener] : [evlistener];
312
- return unwrap3 ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
311
+ return unwrap ? [evlistener.listener || evlistener] : [evlistener];
312
+ return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
313
313
  }
314
- EventEmitter3.prototype.listeners = function listeners(type5) {
314
+ EventEmitter2.prototype.listeners = function listeners(type5) {
315
315
  return _listeners(this, type5, true);
316
316
  };
317
- EventEmitter3.prototype.rawListeners = function rawListeners(type5) {
317
+ EventEmitter2.prototype.rawListeners = function rawListeners(type5) {
318
318
  return _listeners(this, type5, false);
319
319
  };
320
- EventEmitter3.listenerCount = function(emitter, type5) {
320
+ EventEmitter2.listenerCount = function(emitter, type5) {
321
321
  if (typeof emitter.listenerCount === "function") {
322
322
  return emitter.listenerCount(type5);
323
323
  } else {
324
324
  return listenerCount.call(emitter, type5);
325
325
  }
326
326
  };
327
- EventEmitter3.prototype.listenerCount = listenerCount;
327
+ EventEmitter2.prototype.listenerCount = listenerCount;
328
328
  function listenerCount(type5) {
329
329
  var events3 = this._events;
330
330
  if (events3 !== void 0) {
@@ -337,7 +337,7 @@ var PodOS = (() => {
337
337
  }
338
338
  return 0;
339
339
  }
340
- EventEmitter3.prototype.eventNames = function eventNames() {
340
+ EventEmitter2.prototype.eventNames = function eventNames() {
341
341
  return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
342
342
  };
343
343
  function arrayClone(arr, n2) {
@@ -7770,7 +7770,7 @@ var PodOS = (() => {
7770
7770
  return t3[e2] = r2;
7771
7771
  };
7772
7772
  }
7773
- function wrap3(t2, e2, r2, n3) {
7773
+ function wrap(t2, e2, r2, n3) {
7774
7774
  var i2 = e2 && e2.prototype instanceof Generator ? e2 : Generator, a2 = Object.create(i2.prototype), c2 = new Context(n3 || []);
7775
7775
  return o(a2, "_invoke", {
7776
7776
  value: makeInvokeMethod(t2, r2, c2)
@@ -7789,7 +7789,7 @@ var PodOS = (() => {
7789
7789
  };
7790
7790
  }
7791
7791
  }
7792
- e.wrap = wrap3;
7792
+ e.wrap = wrap;
7793
7793
  var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {};
7794
7794
  function Generator() {
7795
7795
  }
@@ -7935,7 +7935,7 @@ var PodOS = (() => {
7935
7935
  return this;
7936
7936
  }), e.AsyncIterator = AsyncIterator, e.async = function(t2, r2, n3, o2, i2) {
7937
7937
  void 0 === i2 && (i2 = Promise);
7938
- var a2 = new AsyncIterator(wrap3(t2, r2, n3, o2), i2);
7938
+ var a2 = new AsyncIterator(wrap(t2, r2, n3, o2), i2);
7939
7939
  return e.isGeneratorFunction(r2) ? a2 : a2.next().then(function(t3) {
7940
7940
  return t3.done ? t3.value : a2.next();
7941
7941
  });
@@ -10088,6 +10088,8 @@ var PodOS = (() => {
10088
10088
  return buf.push("<?", node2.target, " ", node2.data, "?>");
10089
10089
  case ENTITY_REFERENCE_NODE:
10090
10090
  return buf.push("&", node2.nodeName, ";");
10091
+ //case ENTITY_NODE:
10092
+ //case NOTATION_NODE:
10091
10093
  default:
10092
10094
  buf.push("??", node2.nodeName);
10093
10095
  }
@@ -10098,6 +10100,11 @@ var PodOS = (() => {
10098
10100
  case ELEMENT_NODE:
10099
10101
  node22 = node2.cloneNode(false);
10100
10102
  node22.ownerDocument = doc;
10103
+ //var attrs = node2.attributes;
10104
+ //var len = attrs.length;
10105
+ //for(var i=0;i<len;i++){
10106
+ //node2.setAttributeNodeNS(importNode(doc,attrs.item(i),deep));
10107
+ //}
10101
10108
  case DOCUMENT_FRAGMENT_NODE:
10102
10109
  break;
10103
10110
  case ATTRIBUTE_NODE:
@@ -12500,6 +12507,7 @@ var PodOS = (() => {
12500
12507
  }
12501
12508
  end2++;
12502
12509
  break;
12510
+ // end elment
12503
12511
  case "?":
12504
12512
  locator && position4(tagStart);
12505
12513
  end2 = parseInstruction(source8, tagStart, domBuilder);
@@ -12635,6 +12643,7 @@ var PodOS = (() => {
12635
12643
  case S_ATTR_SPACE:
12636
12644
  el.closed = true;
12637
12645
  break;
12646
+ //case S_EQ:
12638
12647
  default:
12639
12648
  throw new Error("attribute invalid close char('/')");
12640
12649
  }
@@ -12653,7 +12662,9 @@ var PodOS = (() => {
12653
12662
  case S_TAG_SPACE:
12654
12663
  case S_TAG_CLOSE:
12655
12664
  break;
12665
+ //normal
12656
12666
  case S_ATTR_NOQUOT_VALUE:
12667
+ //Compatible state
12657
12668
  case S_ATTR:
12658
12669
  value6 = source8.slice(start2, p);
12659
12670
  if (value6.slice(-1) === "/") {
@@ -12678,6 +12689,7 @@ var PodOS = (() => {
12678
12689
  throw new Error("attribute value missed!!");
12679
12690
  }
12680
12691
  return p;
12692
+ /*xml space '\x20' | #x9 | #xD | #xA; */
12681
12693
  case "\x80":
12682
12694
  c = " ";
12683
12695
  default:
@@ -12701,6 +12713,9 @@ var PodOS = (() => {
12701
12713
  }
12702
12714
  } else {
12703
12715
  switch (s) {
12716
+ //case S_TAG:void();break;
12717
+ //case S_ATTR:void();break;
12718
+ //case S_ATTR_NOQUOT_VALUE:void();break;
12704
12719
  case S_ATTR_SPACE:
12705
12720
  var tagName = el.tagName;
12706
12721
  if (!NAMESPACE.isHTML(currentNSMap[""]) || !attrName.match(/^(?:disabled|checked|selected)$/i)) {
@@ -13562,7 +13577,7 @@ var PodOS = (() => {
13562
13577
  }
13563
13578
  return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
13564
13579
  }
13565
- function decode4(input2) {
13580
+ function decode3(input2) {
13566
13581
  var output2 = [], inputLength = input2.length, out, i = 0, n2 = initialN, bias = initialBias, basic, j, index2, oldi, w, k, digit, t, baseMinusT;
13567
13582
  basic = input2.lastIndexOf(delimiter);
13568
13583
  if (basic < 0) {
@@ -13666,7 +13681,7 @@ var PodOS = (() => {
13666
13681
  }
13667
13682
  function toUnicode(input2) {
13668
13683
  return mapDomain(input2, function(string2) {
13669
- return regexPunycode.test(string2) ? decode4(string2.slice(4).toLowerCase()) : string2;
13684
+ return regexPunycode.test(string2) ? decode3(string2.slice(4).toLowerCase()) : string2;
13670
13685
  });
13671
13686
  }
13672
13687
  function toASCII(input2) {
@@ -13692,7 +13707,7 @@ var PodOS = (() => {
13692
13707
  "decode": ucs2decode,
13693
13708
  "encode": ucs2encode
13694
13709
  },
13695
- "decode": decode4,
13710
+ "decode": decode3,
13696
13711
  "encode": encode3,
13697
13712
  "toASCII": toASCII,
13698
13713
  "toUnicode": toUnicode
@@ -14716,14 +14731,14 @@ var PodOS = (() => {
14716
14731
  var protoTag = obj instanceof Object ? "" : "null prototype";
14717
14732
  var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? "Object" : "";
14718
14733
  var constructorTag = isPlainObject || typeof obj.constructor !== "function" ? "" : obj.constructor.name ? obj.constructor.name + " " : "";
14719
- var tag3 = constructorTag + (stringTag || protoTag ? "[" + $join.call($concat.call([], stringTag || [], protoTag || []), ": ") + "] " : "");
14734
+ var tag4 = constructorTag + (stringTag || protoTag ? "[" + $join.call($concat.call([], stringTag || [], protoTag || []), ": ") + "] " : "");
14720
14735
  if (ys.length === 0) {
14721
- return tag3 + "{}";
14736
+ return tag4 + "{}";
14722
14737
  }
14723
14738
  if (indent) {
14724
- return tag3 + "{" + indentedJoin(ys, indent) + "}";
14739
+ return tag4 + "{" + indentedJoin(ys, indent) + "}";
14725
14740
  }
14726
- return tag3 + "{ " + $join.call(ys, ", ") + " }";
14741
+ return tag4 + "{ " + $join.call(ys, ", ") + " }";
14727
14742
  }
14728
14743
  return String(obj);
14729
14744
  };
@@ -15236,7 +15251,7 @@ var PodOS = (() => {
15236
15251
  return acc;
15237
15252
  }, target5);
15238
15253
  };
15239
- var decode4 = function(str, decoder2, charset) {
15254
+ var decode3 = function(str, decoder2, charset) {
15240
15255
  var strWithoutPlus = str.replace(/\+/g, " ");
15241
15256
  if (charset === "iso-8859-1") {
15242
15257
  return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
@@ -15339,7 +15354,7 @@ var PodOS = (() => {
15339
15354
  assign,
15340
15355
  combine,
15341
15356
  compact,
15342
- decode: decode4,
15357
+ decode: decode3,
15343
15358
  encode: encode3,
15344
15359
  isBuffer,
15345
15360
  isRegExp,
@@ -15655,6 +15670,7 @@ var PodOS = (() => {
15655
15670
  parameterLimit: 1e3,
15656
15671
  parseArrays: true,
15657
15672
  plainObjects: false,
15673
+ strictDepth: false,
15658
15674
  strictNullHandling: false
15659
15675
  };
15660
15676
  var interpretNumericEntities = function(str) {
@@ -15673,6 +15689,7 @@ var PodOS = (() => {
15673
15689
  var parseValues = function parseQueryStringValues(str, options) {
15674
15690
  var obj = { __proto__: null };
15675
15691
  var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, "") : str;
15692
+ cleanStr = cleanStr.replace(/%5B/gi, "[").replace(/%5D/gi, "]");
15676
15693
  var limit3 = options.parameterLimit === Infinity ? void 0 : options.parameterLimit;
15677
15694
  var parts = cleanStr.split(options.delimiter, limit3);
15678
15695
  var skipIndex = -1;
@@ -15732,7 +15749,7 @@ var PodOS = (() => {
15732
15749
  var obj;
15733
15750
  var root = chain2[i];
15734
15751
  if (root === "[]" && options.parseArrays) {
15735
- obj = options.allowEmptyArrays && leaf === "" ? [] : [].concat(leaf);
15752
+ obj = options.allowEmptyArrays && (leaf === "" || options.strictNullHandling && leaf === null) ? [] : [].concat(leaf);
15736
15753
  } else {
15737
15754
  obj = options.plainObjects ? /* @__PURE__ */ Object.create(null) : {};
15738
15755
  var cleanRoot = root.charAt(0) === "[" && root.charAt(root.length - 1) === "]" ? root.slice(1, -1) : root;
@@ -15780,6 +15797,9 @@ var PodOS = (() => {
15780
15797
  keys.push(segment[1]);
15781
15798
  }
15782
15799
  if (segment) {
15800
+ if (options.strictDepth === true) {
15801
+ throw new RangeError("Input depth exceeded depth option of " + options.depth + " and strictDepth is true");
15802
+ }
15783
15803
  keys.push("[" + key3.slice(segment.index) + "]");
15784
15804
  }
15785
15805
  return parseObject(keys, val, options, valuesParsed);
@@ -15826,6 +15846,7 @@ var PodOS = (() => {
15826
15846
  parameterLimit: typeof opts.parameterLimit === "number" ? opts.parameterLimit : defaults.parameterLimit,
15827
15847
  parseArrays: opts.parseArrays !== false,
15828
15848
  plainObjects: typeof opts.plainObjects === "boolean" ? opts.plainObjects : defaults.plainObjects,
15849
+ strictDepth: typeof opts.strictDepth === "boolean" ? !!opts.strictDepth : defaults.strictDepth,
15829
15850
  strictNullHandling: typeof opts.strictNullHandling === "boolean" ? opts.strictNullHandling : defaults.strictNullHandling
15830
15851
  };
15831
15852
  };
@@ -21859,7 +21880,7 @@ var PodOS = (() => {
21859
21880
  throw new Error("Can't serialize object of type " + st3.object.termType + " into XML");
21860
21881
  }
21861
21882
  }
21862
- var tag3 = type5 ? qname(type5) : "rdf:Description";
21883
+ var tag4 = type5 ? qname(type5) : "rdf:Description";
21863
21884
  var attrs = "";
21864
21885
  if (subject5.termType === "BlankNode") {
21865
21886
  if (!stats.incoming[subject5] || stats.incoming[subject5].length !== 1) {
@@ -21868,7 +21889,7 @@ var PodOS = (() => {
21868
21889
  } else {
21869
21890
  attrs = ' rdf:about="' + relURI(subject5) + '"';
21870
21891
  }
21871
- return ["<" + tag3 + attrs + ">"].concat([results]).concat(["</" + tag3 + ">"]);
21892
+ return ["<" + tag4 + attrs + ">"].concat([results]).concat(["</" + tag4 + ">"]);
21872
21893
  }
21873
21894
  var subjectXMLTree = subjectXMLTreeMethod.bind(this);
21874
21895
  function collectionXMLTree(subject5, stats) {
@@ -23777,6 +23798,7 @@ var PodOS = (() => {
23777
23798
  return new BlankNode(term3.value);
23778
23799
  case CollectionTermType:
23779
23800
  return term3;
23801
+ // non-RDF/JS type, should just need to cast
23780
23802
  case DefaultGraphTermType:
23781
23803
  return new DefaultGraph();
23782
23804
  case EmptyTermType:
@@ -23898,6 +23920,7 @@ var PodOS = (() => {
23898
23920
  break;
23899
23921
  case "Literal":
23900
23922
  case "BlankNode":
23923
+ // @ts-ignore Collections can appear here
23901
23924
  case "Collection":
23902
23925
  this.add(target5, st3.predicate, st3.object.copy(this));
23903
23926
  }
@@ -24629,7 +24652,7 @@ var PodOS = (() => {
24629
24652
  return utftext;
24630
24653
  },
24631
24654
  // public method for url decoding
24632
- decode: function decode3(utftext) {
24655
+ decode: function decode2(utftext) {
24633
24656
  var string2 = "";
24634
24657
  var i = 0;
24635
24658
  while (i < utftext.length) {
@@ -28992,15 +29015,15 @@ var PodOS = (() => {
28992
29015
  }
28993
29016
  return resolved;
28994
29017
  }
28995
- _cacheResolvedContext({ key: key3, resolved, tag: tag3 }) {
29018
+ _cacheResolvedContext({ key: key3, resolved, tag: tag4 }) {
28996
29019
  this.perOpCache.set(key3, resolved);
28997
- if (tag3 !== void 0) {
29020
+ if (tag4 !== void 0) {
28998
29021
  let tagMap = this.sharedCache.get(key3);
28999
29022
  if (!tagMap) {
29000
29023
  tagMap = /* @__PURE__ */ new Map();
29001
29024
  this.sharedCache.set(key3, tagMap);
29002
29025
  }
29003
- tagMap.set(tag3, resolved);
29026
+ tagMap.set(tag4, resolved);
29004
29027
  }
29005
29028
  return resolved;
29006
29029
  }
@@ -34734,6 +34757,7 @@ var PodOS = (() => {
34734
34757
  }
34735
34758
  break;
34736
34759
  }
34760
+ // Fall through in case the type is an IRI
34737
34761
  case "<":
34738
34762
  if (match = this._unescapedIri.exec(input2))
34739
34763
  type5 = "IRI", value6 = match[1];
@@ -34799,6 +34823,7 @@ var PodOS = (() => {
34799
34823
  matchLength = 1;
34800
34824
  break;
34801
34825
  }
34826
+ // Fall through to numerical case (could be a decimal dot)
34802
34827
  case "0":
34803
34828
  case "1":
34804
34829
  case "2":
@@ -35346,19 +35371,23 @@ var PodOS = (() => {
35346
35371
  // ### `_readInTopContext` reads a token when in the top context
35347
35372
  _readInTopContext(token) {
35348
35373
  switch (token.type) {
35374
+ // If an EOF token arrives in the top context, signal that we're done
35349
35375
  case "eof":
35350
35376
  if (this._graph !== null)
35351
35377
  return this._error("Unclosed graph", token);
35352
35378
  delete this._prefixes._;
35353
35379
  return this._callback(null, null, this._prefixes);
35380
+ // It could be a prefix declaration
35354
35381
  case "PREFIX":
35355
35382
  this._sparqlStyle = true;
35356
35383
  case "@prefix":
35357
35384
  return this._readPrefix;
35385
+ // It could be a base declaration
35358
35386
  case "BASE":
35359
35387
  this._sparqlStyle = true;
35360
35388
  case "@base":
35361
35389
  return this._readBaseIRI;
35390
+ // It could be a graph
35362
35391
  case "{":
35363
35392
  if (this._supportsNamedGraphs) {
35364
35393
  this._graph = "";
@@ -35368,6 +35397,7 @@ var PodOS = (() => {
35368
35397
  case "GRAPH":
35369
35398
  if (this._supportsNamedGraphs)
35370
35399
  return this._readNamedGraphLabel;
35400
+ // Otherwise, the next token must be a subject
35371
35401
  default:
35372
35402
  return this._readSubject(token);
35373
35403
  }
@@ -35376,6 +35406,7 @@ var PodOS = (() => {
35376
35406
  _readEntity(token, quantifier) {
35377
35407
  let value6;
35378
35408
  switch (token.type) {
35409
+ // Read a relative or absolute IRI
35379
35410
  case "IRI":
35380
35411
  case "typeIRI":
35381
35412
  const iri = this._resolveIRI(token.value);
@@ -35383,6 +35414,7 @@ var PodOS = (() => {
35383
35414
  return this._error("Invalid IRI", token);
35384
35415
  value6 = this._namedNode(iri);
35385
35416
  break;
35417
+ // Read a prefixed name
35386
35418
  case "type":
35387
35419
  case "prefixed":
35388
35420
  const prefix2 = this._prefixes[token.prefix];
@@ -35390,12 +35422,15 @@ var PodOS = (() => {
35390
35422
  return this._error(`Undefined prefix "${token.prefix}:"`, token);
35391
35423
  value6 = this._namedNode(prefix2 + token.value);
35392
35424
  break;
35425
+ // Read a blank node
35393
35426
  case "blank":
35394
35427
  value6 = this._blankNode(this._prefixes[token.prefix] + token.value);
35395
35428
  break;
35429
+ // Read a variable
35396
35430
  case "var":
35397
35431
  value6 = this._variable(token.value.substr(1));
35398
35432
  break;
35433
+ // Everything else is not an entity
35399
35434
  default:
35400
35435
  return this._error(`Expected entity but got ${token.type}`, token);
35401
35436
  }
@@ -35699,6 +35734,7 @@ var PodOS = (() => {
35699
35734
  _completeLiteral(token) {
35700
35735
  let literal5 = this._literal(this._literalValue);
35701
35736
  switch (token.type) {
35737
+ // Create a datatyped literal
35702
35738
  case "type":
35703
35739
  case "typeIRI":
35704
35740
  const datatype = this._readEntity(token);
@@ -35706,6 +35742,7 @@ var PodOS = (() => {
35706
35742
  literal5 = this._literal(this._literalValue, datatype);
35707
35743
  token = null;
35708
35744
  break;
35745
+ // Create a language-tagged string
35709
35746
  case "langcode":
35710
35747
  literal5 = this._literal(this._literalValue, token.value);
35711
35748
  token = null;
@@ -35747,23 +35784,28 @@ var PodOS = (() => {
35747
35784
  let next3, graph4 = this._graph;
35748
35785
  const subject5 = this._subject, inversePredicate = this._inversePredicate;
35749
35786
  switch (token.type) {
35787
+ // A closing brace ends a graph
35750
35788
  case "}":
35751
35789
  if (this._graph === null)
35752
35790
  return this._error("Unexpected graph closing", token);
35753
35791
  if (this._n3Mode)
35754
35792
  return this._readFormulaTail(token);
35755
35793
  this._graph = null;
35794
+ // A dot just ends the statement, without sharing anything with the next
35756
35795
  case ".":
35757
35796
  this._subject = null;
35758
35797
  next3 = this._contextStack.length ? this._readSubject : this._readInTopContext;
35759
35798
  if (inversePredicate) this._inversePredicate = false;
35760
35799
  break;
35800
+ // Semicolon means the subject is shared; predicate and object are different
35761
35801
  case ";":
35762
35802
  next3 = this._readPredicate;
35763
35803
  break;
35804
+ // Comma means both the subject and predicate are shared; the object is different
35764
35805
  case ",":
35765
35806
  next3 = this._readObject;
35766
35807
  break;
35808
+ // {| means that the current triple is annotated with predicate-object pairs.
35767
35809
  case "{|":
35768
35810
  if (!this._supportsRDFStar)
35769
35811
  return this._error("Unexpected RDF* syntax", token);
@@ -35771,6 +35813,7 @@ var PodOS = (() => {
35771
35813
  this._subject = this._quad(subject5, predicate2, object6, this.DEFAULTGRAPH);
35772
35814
  next3 = this._readPredicate;
35773
35815
  break;
35816
+ // |} means that the current quoted triple in annotation syntax is finalized.
35774
35817
  case "|}":
35775
35818
  if (this._subject.termType !== "Quad")
35776
35819
  return this._error("Unexpected asserted triple closing", token);
@@ -35797,9 +35840,11 @@ var PodOS = (() => {
35797
35840
  _readBlankNodePunctuation(token) {
35798
35841
  let next3;
35799
35842
  switch (token.type) {
35843
+ // Semicolon means the subject is shared; predicate and object are different
35800
35844
  case ";":
35801
35845
  next3 = this._readPredicate;
35802
35846
  break;
35847
+ // Comma means both the subject and predicate are shared; the object is different
35803
35848
  case ",":
35804
35849
  next3 = this._readObject;
35805
35850
  break;
@@ -35922,10 +35967,13 @@ var PodOS = (() => {
35922
35967
  // ### `_readPath` reads a potential path
35923
35968
  _readPath(token) {
35924
35969
  switch (token.type) {
35970
+ // Forward path
35925
35971
  case "!":
35926
35972
  return this._readForwardPath;
35973
+ // Backward path
35927
35974
  case "^":
35928
35975
  return this._readBackwardPath;
35976
+ // Not a path; resume reading where we left off
35929
35977
  default:
35930
35978
  const stack = this._contextStack, parent4 = stack.length && stack[stack.length - 1];
35931
35979
  if (parent4 && parent4.type === "item") {
@@ -36031,12 +36079,16 @@ var PodOS = (() => {
36031
36079
  if (!iri.length)
36032
36080
  return this._base;
36033
36081
  switch (iri[0]) {
36082
+ // Resolve relative fragment IRIs against the base IRI
36034
36083
  case "#":
36035
36084
  return this._base + iri;
36085
+ // Resolve relative query string IRIs by replacing the query string
36036
36086
  case "?":
36037
36087
  return this._base.replace(/(?:\?.*)?$/, iri);
36088
+ // Resolve root-relative IRIs at the root of the base IRI
36038
36089
  case "/":
36039
36090
  return (iri[1] === "/" ? this._baseScheme : this._baseRoot) + this._removeDotSegments(iri);
36091
+ // Resolve all other IRIs at the base IRI's path
36040
36092
  default:
36041
36093
  return /^[^/:]*:/.test(iri) ? null : this._removeDotSegments(this._basePath + iri);
36042
36094
  }
@@ -36049,6 +36101,7 @@ var PodOS = (() => {
36049
36101
  let result5 = "", i = -1, pathStart = -1, segmentStart = 0, next3 = "/";
36050
36102
  while (i < length2) {
36051
36103
  switch (next3) {
36104
+ // The path starts with the first slash after the authority
36052
36105
  case ":":
36053
36106
  if (pathStart < 0) {
36054
36107
  if (iri[++i] === "/" && iri[++i] === "/")
@@ -36056,22 +36109,27 @@ var PodOS = (() => {
36056
36109
  i = pathStart;
36057
36110
  }
36058
36111
  break;
36112
+ // Don't modify a query string or fragment
36059
36113
  case "?":
36060
36114
  case "#":
36061
36115
  i = length2;
36062
36116
  break;
36117
+ // Handle '/.' or '/..' path segments
36063
36118
  case "/":
36064
36119
  if (iri[i + 1] === ".") {
36065
36120
  next3 = iri[++i + 1];
36066
36121
  switch (next3) {
36122
+ // Remove a '/.' segment
36067
36123
  case "/":
36068
36124
  result5 += iri.substring(segmentStart, i - 1);
36069
36125
  segmentStart = i + 1;
36070
36126
  break;
36127
+ // Remove a trailing '/.' segment
36071
36128
  case void 0:
36072
36129
  case "?":
36073
36130
  case "#":
36074
36131
  return result5 + iri.substring(segmentStart, i) + iri.substr(i + 1);
36132
+ // Remove a '/..' segment
36075
36133
  case ".":
36076
36134
  next3 = iri[++i + 1];
36077
36135
  if (next3 === void 0 || next3 === "/" || next3 === "?" || next3 === "#") {
@@ -37954,7 +38012,7 @@ var PodOS = (() => {
37954
38012
  };
37955
38013
  if (support2.formData) {
37956
38014
  this.formData = function() {
37957
- return this.text().then(decode4);
38015
+ return this.text().then(decode3);
37958
38016
  };
37959
38017
  }
37960
38018
  this.json = function() {
@@ -37967,10 +38025,10 @@ var PodOS = (() => {
37967
38025
  var upcased = method5.toUpperCase();
37968
38026
  return methods.indexOf(upcased) > -1 ? upcased : method5;
37969
38027
  }
37970
- function Request2(input2, options) {
38028
+ function Request(input2, options) {
37971
38029
  options = options || {};
37972
38030
  var body = options.body;
37973
- if (input2 instanceof Request2) {
38031
+ if (input2 instanceof Request) {
37974
38032
  if (input2.bodyUsed) {
37975
38033
  throw new TypeError("Already read");
37976
38034
  }
@@ -38002,10 +38060,10 @@ var PodOS = (() => {
38002
38060
  }
38003
38061
  this._initBody(body);
38004
38062
  }
38005
- Request2.prototype.clone = function() {
38006
- return new Request2(this, { body: this._bodyInit });
38063
+ Request.prototype.clone = function() {
38064
+ return new Request(this, { body: this._bodyInit });
38007
38065
  };
38008
- function decode4(body) {
38066
+ function decode3(body) {
38009
38067
  var form2 = new FormData();
38010
38068
  body.trim().split("&").forEach(function(bytes) {
38011
38069
  if (bytes) {
@@ -38030,8 +38088,8 @@ var PodOS = (() => {
38030
38088
  });
38031
38089
  return headers;
38032
38090
  }
38033
- Body.call(Request2.prototype);
38034
- function Response5(bodyInit, options) {
38091
+ Body.call(Request.prototype);
38092
+ function Response4(bodyInit, options) {
38035
38093
  if (!options) {
38036
38094
  options = {};
38037
38095
  }
@@ -38043,26 +38101,26 @@ var PodOS = (() => {
38043
38101
  this.url = options.url || "";
38044
38102
  this._initBody(bodyInit);
38045
38103
  }
38046
- Body.call(Response5.prototype);
38047
- Response5.prototype.clone = function() {
38048
- return new Response5(this._bodyInit, {
38104
+ Body.call(Response4.prototype);
38105
+ Response4.prototype.clone = function() {
38106
+ return new Response4(this._bodyInit, {
38049
38107
  status: this.status,
38050
38108
  statusText: this.statusText,
38051
38109
  headers: new Headers3(this.headers),
38052
38110
  url: this.url
38053
38111
  });
38054
38112
  };
38055
- Response5.error = function() {
38056
- var response6 = new Response5(null, { status: 0, statusText: "" });
38113
+ Response4.error = function() {
38114
+ var response6 = new Response4(null, { status: 0, statusText: "" });
38057
38115
  response6.type = "error";
38058
38116
  return response6;
38059
38117
  };
38060
38118
  var redirectStatuses = [301, 302, 303, 307, 308];
38061
- Response5.redirect = function(url7, status9) {
38119
+ Response4.redirect = function(url7, status9) {
38062
38120
  if (redirectStatuses.indexOf(status9) === -1) {
38063
38121
  throw new RangeError("Invalid status code");
38064
38122
  }
38065
- return new Response5(null, { status: status9, headers: { location: url7 } });
38123
+ return new Response4(null, { status: status9, headers: { location: url7 } });
38066
38124
  };
38067
38125
  exports2.DOMException = self2.DOMException;
38068
38126
  try {
@@ -38077,9 +38135,9 @@ var PodOS = (() => {
38077
38135
  exports2.DOMException.prototype = Object.create(Error.prototype);
38078
38136
  exports2.DOMException.prototype.constructor = exports2.DOMException;
38079
38137
  }
38080
- function fetch3(input2, init) {
38138
+ function fetch2(input2, init) {
38081
38139
  return new Promise(function(resolve, reject2) {
38082
- var request2 = new Request2(input2, init);
38140
+ var request2 = new Request(input2, init);
38083
38141
  if (request2.signal && request2.signal.aborted) {
38084
38142
  return reject2(new exports2.DOMException("Aborted", "AbortError"));
38085
38143
  }
@@ -38095,7 +38153,7 @@ var PodOS = (() => {
38095
38153
  };
38096
38154
  options.url = "responseURL" in xhr ? xhr.responseURL : options.headers.get("X-Request-URL");
38097
38155
  var body = "response" in xhr ? xhr.response : xhr.responseText;
38098
- resolve(new Response5(body, options));
38156
+ resolve(new Response4(body, options));
38099
38157
  };
38100
38158
  xhr.onerror = function() {
38101
38159
  reject2(new TypeError("Network request failed"));
@@ -38129,17 +38187,17 @@ var PodOS = (() => {
38129
38187
  xhr.send(typeof request2._bodyInit === "undefined" ? null : request2._bodyInit);
38130
38188
  });
38131
38189
  }
38132
- fetch3.polyfill = true;
38190
+ fetch2.polyfill = true;
38133
38191
  if (!self2.fetch) {
38134
- self2.fetch = fetch3;
38192
+ self2.fetch = fetch2;
38135
38193
  self2.Headers = Headers3;
38136
- self2.Request = Request2;
38137
- self2.Response = Response5;
38194
+ self2.Request = Request;
38195
+ self2.Response = Response4;
38138
38196
  }
38139
38197
  exports2.Headers = Headers3;
38140
- exports2.Request = Request2;
38141
- exports2.Response = Response5;
38142
- exports2.fetch = fetch3;
38198
+ exports2.Request = Request;
38199
+ exports2.Response = Response4;
38200
+ exports2.fetch = fetch2;
38143
38201
  Object.defineProperty(exports2, "__esModule", { value: true });
38144
38202
  return exports2;
38145
38203
  }({});
@@ -40959,6 +41017,7 @@ var PodOS = (() => {
40959
41017
  case "text/n3":
40960
41018
  case "text/turtle":
40961
41019
  case "application/x-turtle":
41020
+ // Legacy
40962
41021
  case "application/n3":
40963
41022
  documentString = sz.statementsToN3(data2);
40964
41023
  break;
@@ -41150,14 +41209,11 @@ var PodOS = (() => {
41150
41209
  });
41151
41210
 
41152
41211
  // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/namespaces.js
41153
- var rdf3, vcard, solid, pim, dc;
41212
+ var vcard, dc;
41154
41213
  var init_namespaces = __esm({
41155
41214
  "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/namespaces.js"() {
41156
41215
  init_esm();
41157
- rdf3 = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
41158
41216
  vcard = Namespace("http://www.w3.org/2006/vcard/ns#");
41159
- solid = Namespace("http://www.w3.org/ns/solid/terms#");
41160
- pim = Namespace("http://www.w3.org/ns/pim/space#");
41161
41217
  dc = Namespace("http://purl.org/dc/elements/1.1/");
41162
41218
  }
41163
41219
  });
@@ -41504,25 +41560,32 @@ var PodOS = (() => {
41504
41560
  }
41505
41561
  });
41506
41562
 
41507
- // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/generate-id.js
41563
+ // ../node_modules/@solid-data-modules/rdflib-utils/dist/identifier/generate-id.js
41508
41564
  function generateId() {
41509
41565
  return uid.rnd(6);
41510
41566
  }
41511
41567
  var import_short_unique_id, uid;
41512
41568
  var init_generate_id = __esm({
41513
- "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/generate-id.js"() {
41569
+ "../node_modules/@solid-data-modules/rdflib-utils/dist/identifier/generate-id.js"() {
41514
41570
  import_short_unique_id = __toESM(require_short_unique_id(), 1);
41515
41571
  uid = new import_short_unique_id.default({ length: 10 });
41516
41572
  }
41517
41573
  });
41518
41574
 
41575
+ // ../node_modules/@solid-data-modules/rdflib-utils/dist/identifier/index.js
41576
+ var init_identifier = __esm({
41577
+ "../node_modules/@solid-data-modules/rdflib-utils/dist/identifier/index.js"() {
41578
+ init_generate_id();
41579
+ }
41580
+ });
41581
+
41519
41582
  // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/queries/AddressBookQuery.js
41520
41583
  var AddressBookQuery;
41521
41584
  var init_AddressBookQuery = __esm({
41522
41585
  "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/queries/AddressBookQuery.js"() {
41523
41586
  init_esm();
41524
41587
  init_namespaces();
41525
- init_generate_id();
41588
+ init_identifier();
41526
41589
  AddressBookQuery = class {
41527
41590
  constructor(store, addressBookNode) {
41528
41591
  this.store = store;
@@ -41640,11 +41703,37 @@ var PodOS = (() => {
41640
41703
  }
41641
41704
  });
41642
41705
 
41706
+ // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/queries/GroupQuery.js
41707
+ var GroupQuery;
41708
+ var init_GroupQuery = __esm({
41709
+ "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/queries/GroupQuery.js"() {
41710
+ init_esm();
41711
+ init_namespaces();
41712
+ GroupQuery = class {
41713
+ constructor(store, groupNode) {
41714
+ this.store = store;
41715
+ this.groupNode = groupNode;
41716
+ this.groupDoc = groupNode.doc();
41717
+ }
41718
+ queryName() {
41719
+ return this.store.anyValue(this.groupNode, vcard("fn"), void 0, this.groupDoc) ?? "";
41720
+ }
41721
+ queryMembers() {
41722
+ return this.store.each(this.groupNode, vcard("hasMember"), null, this.groupDoc).filter((it) => isNamedNode(it)).map((node2) => ({
41723
+ uri: node2.value,
41724
+ name: this.store.anyValue(node2, vcard("fn"), null, this.groupDoc) ?? ""
41725
+ }));
41726
+ }
41727
+ };
41728
+ }
41729
+ });
41730
+
41643
41731
  // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/queries/index.js
41644
41732
  var init_queries = __esm({
41645
41733
  "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/queries/index.js"() {
41646
41734
  init_AddressBookQuery();
41647
41735
  init_ContactQuery();
41736
+ init_GroupQuery();
41648
41737
  }
41649
41738
  });
41650
41739
 
@@ -41664,14 +41753,251 @@ var PodOS = (() => {
41664
41753
  uri: uri6,
41665
41754
  deletions: [],
41666
41755
  insertions,
41667
- filesToCreate: [{ uri: nameEmailIndexUri }, { uri: groupIndexUri }]
41756
+ filesToCreate: [{ url: nameEmailIndexUri }, { url: groupIndexUri }]
41668
41757
  };
41669
41758
  }
41670
41759
  var init_createAddressBook = __esm({
41671
41760
  "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/createAddressBook.js"() {
41672
41761
  init_esm();
41673
41762
  init_namespaces();
41674
- init_generate_id();
41763
+ init_identifier();
41764
+ }
41765
+ });
41766
+
41767
+ // ../node_modules/@solid-data-modules/rdflib-utils/dist/web-operations/executeUpdate.js
41768
+ async function executeUpdate(fetcher3, updater, operation3) {
41769
+ await updater.updateMany(operation3.deletions, operation3.insertions);
41770
+ operation3.filesToCreate.map((file2) => {
41771
+ createEmptyTurtleFile(fetcher3, file2.url);
41772
+ });
41773
+ }
41774
+ function createEmptyTurtleFile(fetcher3, url7) {
41775
+ return fetcher3.webOperation("PUT", url7, {
41776
+ contentType: "text/turtle"
41777
+ });
41778
+ }
41779
+ var init_executeUpdate = __esm({
41780
+ "../node_modules/@solid-data-modules/rdflib-utils/dist/web-operations/executeUpdate.js"() {
41781
+ }
41782
+ });
41783
+
41784
+ // ../node_modules/@solid-data-modules/rdflib-utils/dist/web-operations/fetchNode.js
41785
+ async function fetchNode(fetcher3, node2) {
41786
+ if (node2) {
41787
+ await fetcher3.load(node2.value);
41788
+ }
41789
+ }
41790
+ var init_fetchNode = __esm({
41791
+ "../node_modules/@solid-data-modules/rdflib-utils/dist/web-operations/fetchNode.js"() {
41792
+ }
41793
+ });
41794
+
41795
+ // ../node_modules/@solid-data-modules/rdflib-utils/dist/web-operations/index.js
41796
+ var init_web_operations = __esm({
41797
+ "../node_modules/@solid-data-modules/rdflib-utils/dist/web-operations/index.js"() {
41798
+ init_executeUpdate();
41799
+ init_fetchNode();
41800
+ }
41801
+ });
41802
+
41803
+ // ../node_modules/@solid-data-modules/rdflib-utils/dist/namespaces/index.js
41804
+ var rdf3, solid, pim, ldp;
41805
+ var init_namespaces2 = __esm({
41806
+ "../node_modules/@solid-data-modules/rdflib-utils/dist/namespaces/index.js"() {
41807
+ init_esm();
41808
+ rdf3 = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
41809
+ solid = Namespace("http://www.w3.org/ns/solid/terms#");
41810
+ pim = Namespace("http://www.w3.org/ns/pim/space#");
41811
+ ldp = Namespace("http://www.w3.org/ns/ldp#");
41812
+ }
41813
+ });
41814
+
41815
+ // ../node_modules/@solid-data-modules/rdflib-utils/dist/queries/PreferencesQuery.js
41816
+ var PreferencesQuery;
41817
+ var init_PreferencesQuery = __esm({
41818
+ "../node_modules/@solid-data-modules/rdflib-utils/dist/queries/PreferencesQuery.js"() {
41819
+ init_esm();
41820
+ init_namespaces2();
41821
+ PreferencesQuery = class {
41822
+ constructor(store, webIdNode, preferencesDoc) {
41823
+ this.store = store;
41824
+ this.webIdNode = webIdNode;
41825
+ this.preferencesDoc = preferencesDoc;
41826
+ }
41827
+ /**
41828
+ * Look up the private type index. Returns null if none is found or if the predicated does not link to a proper named node
41829
+ */
41830
+ queryPrivateTypeIndex() {
41831
+ const node2 = this.store.any(this.webIdNode, solid("privateTypeIndex"), null, this.preferencesDoc);
41832
+ if (isNamedNode(node2)) {
41833
+ return node2;
41834
+ }
41835
+ return null;
41836
+ }
41837
+ };
41838
+ }
41839
+ });
41840
+
41841
+ // ../node_modules/@solid-data-modules/rdflib-utils/dist/queries/ProfileQuery.js
41842
+ var ProfileQuery;
41843
+ var init_ProfileQuery = __esm({
41844
+ "../node_modules/@solid-data-modules/rdflib-utils/dist/queries/ProfileQuery.js"() {
41845
+ init_esm();
41846
+ init_namespaces2();
41847
+ ProfileQuery = class {
41848
+ constructor(webIdNode, store) {
41849
+ this.webIdNode = webIdNode;
41850
+ this.store = store;
41851
+ }
41852
+ /**
41853
+ * Look up the public type index. Returns null if none is found or if the predicated does not link to a proper named node
41854
+ */
41855
+ queryPublicTypeIndex() {
41856
+ const predicate2 = solid("publicTypeIndex");
41857
+ return this.queryNamedNode(predicate2);
41858
+ }
41859
+ /**
41860
+ * Look up the preferences file. Returns null if none is found or if the predicated does not link to a proper named node
41861
+ */
41862
+ queryPreferencesFile() {
41863
+ const predicate2 = pim("preferencesFile");
41864
+ return this.queryNamedNode(predicate2);
41865
+ }
41866
+ queryNamedNode(predicate2) {
41867
+ const node2 = this.store.any(this.webIdNode, predicate2, null, this.webIdNode.doc());
41868
+ if (isNamedNode(node2)) {
41869
+ return node2;
41870
+ }
41871
+ return null;
41872
+ }
41873
+ };
41874
+ }
41875
+ });
41876
+
41877
+ // ../node_modules/@solid-data-modules/rdflib-utils/dist/queries/TypeIndexQuery.js
41878
+ var TypeIndexQuery;
41879
+ var init_TypeIndexQuery = __esm({
41880
+ "../node_modules/@solid-data-modules/rdflib-utils/dist/queries/TypeIndexQuery.js"() {
41881
+ init_esm();
41882
+ init_namespaces2();
41883
+ TypeIndexQuery = class {
41884
+ constructor(store, typeIndexDoc) {
41885
+ this.store = store;
41886
+ this.typeIndexDoc = typeIndexDoc;
41887
+ }
41888
+ /**
41889
+ * Look up the instances in the type registration for the given RDF class
41890
+ * @param type - The RDF class to look up
41891
+ * @returns A list of the URIs of the found instances
41892
+ */
41893
+ queryInstancesForClass(type5) {
41894
+ const registrations = this.store.each(null, solid("forClass"), type5, this.typeIndexDoc);
41895
+ return registrations.flatMap((registration) => {
41896
+ if (!isNamedNode(registration))
41897
+ return [];
41898
+ return this.getInstanceValues(registration);
41899
+ });
41900
+ }
41901
+ getInstanceValues(registration) {
41902
+ return this.store.each(registration, solid("instance"), null, this.typeIndexDoc).map((it) => it.value);
41903
+ }
41904
+ };
41905
+ }
41906
+ });
41907
+
41908
+ // ../node_modules/@solid-data-modules/rdflib-utils/dist/queries/index.js
41909
+ var init_queries2 = __esm({
41910
+ "../node_modules/@solid-data-modules/rdflib-utils/dist/queries/index.js"() {
41911
+ init_PreferencesQuery();
41912
+ init_ProfileQuery();
41913
+ init_TypeIndexQuery();
41914
+ }
41915
+ });
41916
+
41917
+ // ../node_modules/@solid-data-modules/rdflib-utils/dist/module/ModuleSupport.js
41918
+ var ModuleSupport;
41919
+ var init_ModuleSupport = __esm({
41920
+ "../node_modules/@solid-data-modules/rdflib-utils/dist/module/ModuleSupport.js"() {
41921
+ init_esm();
41922
+ init_dist();
41923
+ init_namespaces2();
41924
+ ModuleSupport = class {
41925
+ constructor(config2) {
41926
+ this.store = config2.store;
41927
+ this.fetcher = config2.fetcher;
41928
+ this.updater = config2.updater;
41929
+ }
41930
+ /**
41931
+ * Nullsafe fetching of a node
41932
+ * @param node - A node to fetch, or null to do nothing at all
41933
+ */
41934
+ async fetchNode(node2) {
41935
+ return fetchNode(this.fetcher, node2);
41936
+ }
41937
+ /**
41938
+ * Fetch all the given nodes in parallel
41939
+ * @param nodes
41940
+ */
41941
+ async fetchAll(nodes) {
41942
+ return Promise.all(nodes.map((it) => this.fetchNode(it)));
41943
+ }
41944
+ /**
41945
+ * Checks whether the resource identified by the given URL is a LDP container
41946
+ * @param storageUrl - The URL to check
41947
+ * @returns true if it is a container, false otherwise
41948
+ */
41949
+ async isContainer(storageUrl) {
41950
+ const storageNode = namedNode2(storageUrl);
41951
+ await this.fetcher.load(storageNode.value);
41952
+ return this.store.holds(storageNode, rdf3("type"), ldp("Container"), storageNode.doc());
41953
+ }
41954
+ };
41955
+ }
41956
+ });
41957
+
41958
+ // ../node_modules/@solid-data-modules/rdflib-utils/dist/module/index.js
41959
+ var init_module = __esm({
41960
+ "../node_modules/@solid-data-modules/rdflib-utils/dist/module/index.js"() {
41961
+ init_ModuleSupport();
41962
+ }
41963
+ });
41964
+
41965
+ // ../node_modules/@solid-data-modules/rdflib-utils/dist/update-operations/addInstanceToTypeIndex.js
41966
+ function addInstanceToTypeIndex(typeIndexDoc, instanceUri, type5) {
41967
+ const registrationNode = namedNode2(`${typeIndexDoc.value}#${generateId()}`);
41968
+ return {
41969
+ deletions: [],
41970
+ filesToCreate: [],
41971
+ insertions: [
41972
+ st2(registrationNode, rdf3("type"), solid("TypeRegistration"), typeIndexDoc),
41973
+ st2(registrationNode, solid("forClass"), type5, typeIndexDoc),
41974
+ st2(registrationNode, solid("instance"), namedNode2(instanceUri), typeIndexDoc)
41975
+ ]
41976
+ };
41977
+ }
41978
+ var init_addInstanceToTypeIndex = __esm({
41979
+ "../node_modules/@solid-data-modules/rdflib-utils/dist/update-operations/addInstanceToTypeIndex.js"() {
41980
+ init_esm();
41981
+ init_identifier();
41982
+ init_namespaces2();
41983
+ }
41984
+ });
41985
+
41986
+ // ../node_modules/@solid-data-modules/rdflib-utils/dist/update-operations/index.js
41987
+ var init_update_operations = __esm({
41988
+ "../node_modules/@solid-data-modules/rdflib-utils/dist/update-operations/index.js"() {
41989
+ init_addInstanceToTypeIndex();
41990
+ }
41991
+ });
41992
+
41993
+ // ../node_modules/@solid-data-modules/rdflib-utils/dist/index.js
41994
+ var init_dist = __esm({
41995
+ "../node_modules/@solid-data-modules/rdflib-utils/dist/index.js"() {
41996
+ init_web_operations();
41997
+ init_queries2();
41998
+ init_module();
41999
+ init_update_operations();
42000
+ init_namespaces2();
41675
42001
  }
41676
42002
  });
41677
42003
 
@@ -41707,42 +42033,7 @@ var PodOS = (() => {
41707
42033
  "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/createNewContact.js"() {
41708
42034
  init_esm();
41709
42035
  init_namespaces();
41710
- }
41711
- });
41712
-
41713
- // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/index.js
41714
- var init_update_operations = __esm({
41715
- "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/index.js"() {
41716
- init_createAddressBook();
41717
- init_createNewContact();
41718
- }
41719
- });
41720
-
41721
- // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/web-operations/executeUpdate.js
41722
- async function executeUpdate(fetcher3, updater, operation3) {
41723
- await updater.updateMany(operation3.deletions, operation3.insertions);
41724
- operation3.filesToCreate.map((file2) => {
41725
- createEmptyTurtleFile(fetcher3, file2.uri);
41726
- });
41727
- }
41728
- function createEmptyTurtleFile(fetcher3, uri6) {
41729
- return fetcher3.webOperation("PUT", uri6, {
41730
- contentType: "text/turtle"
41731
- });
41732
- }
41733
- var init_executeUpdate = __esm({
41734
- "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/web-operations/executeUpdate.js"() {
41735
- }
41736
- });
41737
-
41738
- // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/web-operations/fetchNode.js
41739
- async function fetchNode(fetcher3, node2) {
41740
- if (node2) {
41741
- await fetcher3.load(node2.value);
41742
- }
41743
- }
41744
- var init_fetchNode = __esm({
41745
- "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/web-operations/fetchNode.js"() {
42036
+ init_dist();
41746
42037
  }
41747
42038
  });
41748
42039
 
@@ -41770,31 +42061,7 @@ var PodOS = (() => {
41770
42061
  "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/createNewGroup.js"() {
41771
42062
  init_esm();
41772
42063
  init_namespaces();
41773
- }
41774
- });
41775
-
41776
- // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/queries/GroupQuery.js
41777
- var GroupQuery;
41778
- var init_GroupQuery = __esm({
41779
- "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/queries/GroupQuery.js"() {
41780
- init_esm();
41781
- init_namespaces();
41782
- GroupQuery = class {
41783
- constructor(store, groupNode) {
41784
- this.store = store;
41785
- this.groupNode = groupNode;
41786
- this.groupDoc = groupNode.doc();
41787
- }
41788
- queryName() {
41789
- return this.store.anyValue(this.groupNode, vcard("fn"), void 0, this.groupDoc) ?? "";
41790
- }
41791
- queryMembers() {
41792
- return this.store.each(this.groupNode, vcard("hasMember"), null, this.groupDoc).filter((it) => isNamedNode(it)).map((node2) => ({
41793
- uri: node2.value,
41794
- name: this.store.anyValue(node2, vcard("fn"), null, this.groupDoc) ?? ""
41795
- }));
41796
- }
41797
- };
42064
+ init_dist();
41798
42065
  }
41799
42066
  });
41800
42067
 
@@ -41802,7 +42069,6 @@ var PodOS = (() => {
41802
42069
  function addContactToGroup(contactQuery, groupQuery) {
41803
42070
  const name7 = contactQuery.queryName();
41804
42071
  return {
41805
- uri: "",
41806
42072
  insertions: [
41807
42073
  st2(groupQuery.groupNode, vcard("hasMember"), contactQuery.contactNode, groupQuery.groupNode.doc()),
41808
42074
  st2(contactQuery.contactNode, vcard("fn"), lit2(name7), groupQuery.groupNode.doc())
@@ -41818,27 +42084,25 @@ var PodOS = (() => {
41818
42084
  }
41819
42085
  });
41820
42086
 
41821
- // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/removeContactFromGroup.js
41822
- function removeContactFromGroup(contactQuery, groupQuery) {
41823
- const contactUri = contactQuery.contactNode.uri;
41824
- const member9 = groupQuery.queryMembers().find((it) => it.uri === contactUri);
41825
- if (!member9) {
41826
- throw new Error("member not found in group");
41827
- }
42087
+ // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/addNewEmailAddress.js
42088
+ function addNewEmailAddress(contactNode, emailAddress) {
42089
+ const id6 = generateId();
42090
+ const uri6 = `${contactNode.doc().uri}#${id6}`;
41828
42091
  return {
41829
- uri: "",
41830
- insertions: [],
41831
- deletions: [
41832
- st2(groupQuery.groupNode, vcard("hasMember"), contactQuery.contactNode, groupQuery.groupNode.doc()),
41833
- st2(contactQuery.contactNode, vcard("fn"), lit2(member9.name), groupQuery.groupNode.doc())
42092
+ uri: uri6,
42093
+ insertions: [
42094
+ st2(contactNode, vcard("hasEmail"), namedNode2(uri6), contactNode.doc()),
42095
+ st2(namedNode2(uri6), vcard("value"), namedNode2("mailto:" + emailAddress), contactNode.doc())
41834
42096
  ],
42097
+ deletions: [],
41835
42098
  filesToCreate: []
41836
42099
  };
41837
42100
  }
41838
- var init_removeContactFromGroup = __esm({
41839
- "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/removeContactFromGroup.js"() {
42101
+ var init_addNewEmailAddress = __esm({
42102
+ "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/addNewEmailAddress.js"() {
41840
42103
  init_esm();
41841
42104
  init_namespaces();
42105
+ init_identifier();
41842
42106
  }
41843
42107
  });
41844
42108
 
@@ -41859,48 +42123,29 @@ var PodOS = (() => {
41859
42123
  var init_addNewPhoneNumber = __esm({
41860
42124
  "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/addNewPhoneNumber.js"() {
41861
42125
  init_esm();
41862
- init_generate_id();
41863
42126
  init_namespaces();
42127
+ init_identifier();
41864
42128
  }
41865
42129
  });
41866
42130
 
41867
- // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/addNewEmailAddress.js
41868
- function addNewEmailAddress(contactNode, emailAddress) {
41869
- const id6 = generateId();
41870
- const uri6 = `${contactNode.doc().uri}#${id6}`;
41871
- return {
41872
- uri: uri6,
41873
- insertions: [
41874
- st2(contactNode, vcard("hasEmail"), namedNode2(uri6), contactNode.doc()),
41875
- st2(namedNode2(uri6), vcard("value"), namedNode2("mailto:" + emailAddress), contactNode.doc())
41876
- ],
41877
- deletions: [],
41878
- filesToCreate: []
41879
- };
41880
- }
41881
- var init_addNewEmailAddress = __esm({
41882
- "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/addNewEmailAddress.js"() {
41883
- init_esm();
41884
- init_generate_id();
41885
- init_namespaces();
42131
+ // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/removeContactFromGroup.js
42132
+ function removeContactFromGroup(contactQuery, groupQuery) {
42133
+ const contactUri = contactQuery.contactNode.uri;
42134
+ const member9 = groupQuery.queryMembers().find((it) => it.uri === contactUri);
42135
+ if (!member9) {
42136
+ throw new Error("member not found in group");
41886
42137
  }
41887
- });
41888
-
41889
- // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/removePhoneNumber.js
41890
- function removePhoneNumber(contactNode, phoneNode, store) {
41891
- const phoneStatements = store.statementsMatching(phoneNode, null, null, phoneNode.doc());
41892
42138
  return {
41893
- uri: "",
41894
42139
  insertions: [],
41895
42140
  deletions: [
41896
- ...phoneStatements,
41897
- st2(contactNode, vcard("hasTelephone"), phoneNode, contactNode.doc())
42141
+ st2(groupQuery.groupNode, vcard("hasMember"), contactQuery.contactNode, groupQuery.groupNode.doc()),
42142
+ st2(contactQuery.contactNode, vcard("fn"), lit2(member9.name), groupQuery.groupNode.doc())
41898
42143
  ],
41899
42144
  filesToCreate: []
41900
42145
  };
41901
42146
  }
41902
- var init_removePhoneNumber = __esm({
41903
- "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/removePhoneNumber.js"() {
42147
+ var init_removeContactFromGroup = __esm({
42148
+ "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/removeContactFromGroup.js"() {
41904
42149
  init_esm();
41905
42150
  init_namespaces();
41906
42151
  }
@@ -41910,7 +42155,6 @@ var PodOS = (() => {
41910
42155
  function removeEmailAddress(contactNode, emailNode, store) {
41911
42156
  const emailStatements = store.statementsMatching(emailNode, null, null, emailNode.doc());
41912
42157
  return {
41913
- uri: "",
41914
42158
  insertions: [],
41915
42159
  deletions: [
41916
42160
  ...emailStatements,
@@ -41926,82 +42170,22 @@ var PodOS = (() => {
41926
42170
  }
41927
42171
  });
41928
42172
 
41929
- // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/queries/ProfileQuery.js
41930
- var ProfileQuery;
41931
- var init_ProfileQuery = __esm({
41932
- "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/queries/ProfileQuery.js"() {
41933
- init_esm();
41934
- init_namespaces();
41935
- ProfileQuery = class {
41936
- constructor(webIdNode, store) {
41937
- this.webIdNode = webIdNode;
41938
- this.store = store;
41939
- }
41940
- queryPublicTypeIndex() {
41941
- const predicate2 = solid("publicTypeIndex");
41942
- return this.queryNamedNode(predicate2);
41943
- }
41944
- queryPreferencesFile() {
41945
- const predicate2 = pim("preferencesFile");
41946
- return this.queryNamedNode(predicate2);
41947
- }
41948
- queryNamedNode(predicate2) {
41949
- const node2 = this.store.any(this.webIdNode, predicate2, null, this.webIdNode.doc());
41950
- if (isNamedNode(node2)) {
41951
- return node2;
41952
- }
41953
- return null;
41954
- }
41955
- };
41956
- }
41957
- });
41958
-
41959
- // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/queries/TypeIndexQuery.js
41960
- var TypeIndexQuery;
41961
- var init_TypeIndexQuery = __esm({
41962
- "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/queries/TypeIndexQuery.js"() {
41963
- init_esm();
41964
- init_namespaces();
41965
- TypeIndexQuery = class {
41966
- constructor(store, typeIndexDoc) {
41967
- this.store = store;
41968
- this.typeIndexDoc = typeIndexDoc;
41969
- }
41970
- queryAddressBookInstances() {
41971
- const addressBookRegistrations = this.store.each(null, solid("forClass"), vcard("AddressBook"), this.typeIndexDoc);
41972
- return addressBookRegistrations.flatMap((registration) => {
41973
- if (!isNamedNode(registration))
41974
- return [];
41975
- return this.getInstanceValues(registration);
41976
- });
41977
- }
41978
- getInstanceValues(registration) {
41979
- return this.store.each(registration, solid("instance"), null, this.typeIndexDoc).map((it) => it.value);
41980
- }
41981
- };
41982
- }
41983
- });
41984
-
41985
- // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/queries/PreferencesQuery.js
41986
- var PreferencesQuery;
41987
- var init_PreferencesQuery = __esm({
41988
- "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/queries/PreferencesQuery.js"() {
42173
+ // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/removePhoneNumber.js
42174
+ function removePhoneNumber(contactNode, phoneNode, store) {
42175
+ const phoneStatements = store.statementsMatching(phoneNode, null, null, phoneNode.doc());
42176
+ return {
42177
+ insertions: [],
42178
+ deletions: [
42179
+ ...phoneStatements,
42180
+ st2(contactNode, vcard("hasTelephone"), phoneNode, contactNode.doc())
42181
+ ],
42182
+ filesToCreate: []
42183
+ };
42184
+ }
42185
+ var init_removePhoneNumber = __esm({
42186
+ "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/removePhoneNumber.js"() {
41989
42187
  init_esm();
41990
42188
  init_namespaces();
41991
- PreferencesQuery = class {
41992
- constructor(store, webIdNode, preferencesDoc) {
41993
- this.store = store;
41994
- this.webIdNode = webIdNode;
41995
- this.preferencesDoc = preferencesDoc;
41996
- }
41997
- queryPrivateTypeIndex() {
41998
- const node2 = this.store.any(this.webIdNode, solid("privateTypeIndex"), null, this.preferencesDoc);
41999
- if (isNamedNode(node2)) {
42000
- return node2;
42001
- }
42002
- return null;
42003
- }
42004
- };
42005
42189
  }
42006
42190
  });
42007
42191
 
@@ -42010,7 +42194,6 @@ var PodOS = (() => {
42010
42194
  const deletions = store.statementsMatching(contactNode, vcard("fn"), null, null);
42011
42195
  const insertions = deletions.map((it) => st2(it.subject, it.predicate, lit2(newName), it.graph));
42012
42196
  return {
42013
- uri: "",
42014
42197
  insertions,
42015
42198
  deletions,
42016
42199
  filesToCreate: []
@@ -42023,25 +42206,23 @@ var PodOS = (() => {
42023
42206
  }
42024
42207
  });
42025
42208
 
42026
- // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/addAddressBookToTypeIndex.js
42027
- function addAddressBookToTypeIndex(typeIndexDoc, addressBookUri) {
42028
- const registrationNode = namedNode2(`${typeIndexDoc.value}#${generateId()}`);
42209
+ // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/updateEmailAddress.js
42210
+ function updateEmailAddress(emailAddressNode, newEmailAddress, store) {
42211
+ const oldValue = store.any(emailAddressNode, vcard("value"));
42212
+ const deletions = oldValue ? [st2(emailAddressNode, vcard("value"), oldValue, emailAddressNode.doc())] : [];
42213
+ const insertions = [
42214
+ st2(emailAddressNode, vcard("value"), namedNode2("mailto:" + newEmailAddress), emailAddressNode.doc())
42215
+ ];
42029
42216
  return {
42030
- deletions: [],
42031
- filesToCreate: [],
42032
- insertions: [
42033
- st2(registrationNode, rdf3("type"), solid("TypeRegistration"), typeIndexDoc),
42034
- st2(registrationNode, solid("forClass"), vcard("AddressBook"), typeIndexDoc),
42035
- st2(registrationNode, solid("instance"), namedNode2(addressBookUri), typeIndexDoc)
42036
- ],
42037
- uri: ""
42217
+ insertions,
42218
+ deletions,
42219
+ filesToCreate: []
42038
42220
  };
42039
42221
  }
42040
- var init_addAddressBookToTypeIndex = __esm({
42041
- "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/addAddressBookToTypeIndex.js"() {
42222
+ var init_updateEmailAddress = __esm({
42223
+ "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/updateEmailAddress.js"() {
42042
42224
  init_esm();
42043
42225
  init_namespaces();
42044
- init_generate_id();
42045
42226
  }
42046
42227
  });
42047
42228
 
@@ -42053,7 +42234,6 @@ var PodOS = (() => {
42053
42234
  st2(phoneNumberNode, vcard("value"), namedNode2("tel:" + newPhoneNumber), phoneNumberNode.doc())
42054
42235
  ];
42055
42236
  return {
42056
- uri: "",
42057
42237
  insertions,
42058
42238
  deletions,
42059
42239
  filesToCreate: []
@@ -42066,69 +42246,49 @@ var PodOS = (() => {
42066
42246
  }
42067
42247
  });
42068
42248
 
42069
- // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/updateEmailAddress.js
42070
- function updateEmailAddress(emailAddressNode, newEmailAddress, store) {
42071
- const oldValue = store.any(emailAddressNode, vcard("value"));
42072
- const deletions = oldValue ? [st2(emailAddressNode, vcard("value"), oldValue, emailAddressNode.doc())] : [];
42073
- const insertions = [
42074
- st2(emailAddressNode, vcard("value"), namedNode2("mailto:" + newEmailAddress), emailAddressNode.doc())
42075
- ];
42076
- return {
42077
- uri: "",
42078
- insertions,
42079
- deletions,
42080
- filesToCreate: []
42081
- };
42082
- }
42083
- var init_updateEmailAddress = __esm({
42084
- "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/updateEmailAddress.js"() {
42085
- init_esm();
42086
- init_namespaces();
42249
+ // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/index.js
42250
+ var init_update_operations2 = __esm({
42251
+ "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/index.js"() {
42252
+ init_createAddressBook();
42253
+ init_createNewContact();
42254
+ init_createNewGroup();
42255
+ init_addContactToGroup();
42256
+ init_addNewEmailAddress();
42257
+ init_addNewPhoneNumber();
42258
+ init_removeContactFromGroup();
42259
+ init_removeEmailAddress();
42260
+ init_removePhoneNumber();
42261
+ init_renameContact();
42262
+ init_updateEmailAddress();
42263
+ init_updatePhoneNumber();
42087
42264
  }
42088
42265
  });
42089
42266
 
42090
42267
  // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/ContactsModuleRdfLib.js
42091
- var ContactsModuleRdfLib;
42268
+ var VCARD_ADDRESS_BOOK, ContactsModuleRdfLib;
42092
42269
  var init_ContactsModuleRdfLib = __esm({
42093
42270
  "../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/ContactsModuleRdfLib.js"() {
42094
42271
  init_esm();
42095
42272
  init_queries();
42096
- init_update_operations();
42097
- init_executeUpdate();
42098
- init_fetchNode();
42099
- init_createNewGroup();
42100
- init_GroupQuery();
42101
- init_addContactToGroup();
42102
- init_removeContactFromGroup();
42103
- init_addNewPhoneNumber();
42104
- init_addNewEmailAddress();
42105
- init_removePhoneNumber();
42106
- init_removeEmailAddress();
42107
- init_ProfileQuery();
42108
- init_TypeIndexQuery();
42109
- init_PreferencesQuery();
42110
- init_renameContact();
42111
- init_addAddressBookToTypeIndex();
42112
- init_updatePhoneNumber();
42113
- init_updateEmailAddress();
42273
+ init_update_operations2();
42274
+ init_dist();
42275
+ init_namespaces();
42276
+ VCARD_ADDRESS_BOOK = vcard("AddressBook");
42114
42277
  ContactsModuleRdfLib = class {
42115
42278
  constructor(config2) {
42279
+ this.support = new ModuleSupport(config2);
42116
42280
  this.store = config2.store;
42117
42281
  this.fetcher = config2.fetcher;
42118
42282
  this.updater = config2.updater;
42119
42283
  }
42120
42284
  async readAddressBook(uri6) {
42121
42285
  const addressBookNode = namedNode2(uri6);
42122
- await this.fetchNode(addressBookNode);
42286
+ await this.support.fetchNode(addressBookNode);
42123
42287
  const query4 = new AddressBookQuery(this.store, addressBookNode);
42124
42288
  const title9 = query4.queryTitle();
42125
42289
  const nameEmailIndex = query4.queryNameEmailIndex();
42126
42290
  const groupIndex = query4.queryGroupIndex();
42127
- await Promise.allSettled([
42128
- this.fetchNode(nameEmailIndex),
42129
- this.fetchNode(groupIndex)
42130
- ]);
42131
- await this.fetchAll([nameEmailIndex, groupIndex]);
42291
+ await this.support.fetchAll([nameEmailIndex, groupIndex]);
42132
42292
  const contacts = query4.queryContacts();
42133
42293
  const groups = query4.queryGroups();
42134
42294
  return {
@@ -42138,12 +42298,6 @@ var PodOS = (() => {
42138
42298
  groups
42139
42299
  };
42140
42300
  }
42141
- async fetchNode(node2) {
42142
- return fetchNode(this.fetcher, node2);
42143
- }
42144
- async fetchAll(nodes) {
42145
- return Promise.all(nodes.map((it) => this.fetchNode(it)));
42146
- }
42147
42301
  async createAddressBook({ containerUri, name: name7, ownerWebId }) {
42148
42302
  const operation3 = createAddressBook(containerUri, name7);
42149
42303
  await executeUpdate(this.fetcher, this.updater, operation3);
@@ -42154,14 +42308,14 @@ var PodOS = (() => {
42154
42308
  }
42155
42309
  async updatePrivateTypeIndex(ownerWebId, addressBookUri) {
42156
42310
  const profileNode = namedNode2(ownerWebId);
42157
- await this.fetchNode(profileNode);
42311
+ await this.support.fetchNode(profileNode);
42158
42312
  const profileQuery = new ProfileQuery(profileNode, this.store);
42159
42313
  const preferencesFile2 = profileQuery.queryPreferencesFile();
42160
42314
  const privateTypeIndex2 = await this.fetchPrivateTypeIndex(profileNode, preferencesFile2);
42161
42315
  if (!privateTypeIndex2) {
42162
42316
  throw new Error(`Private type not found for WebID ${ownerWebId}.`);
42163
42317
  }
42164
- const operation3 = addAddressBookToTypeIndex(privateTypeIndex2, addressBookUri);
42318
+ const operation3 = addInstanceToTypeIndex(privateTypeIndex2, addressBookUri, VCARD_ADDRESS_BOOK);
42165
42319
  await executeUpdate(this.fetcher, this.updater, operation3);
42166
42320
  }
42167
42321
  async createNewContact({ addressBookUri, contact: contact4, groupUris }) {
@@ -42171,7 +42325,7 @@ var PodOS = (() => {
42171
42325
  }
42172
42326
  async executeAddContactToGroups(groupUris, contactQuery) {
42173
42327
  const groupNodes = (groupUris ?? []).map((it) => namedNode2(it));
42174
- await this.fetchAll(groupNodes);
42328
+ await this.support.fetchAll(groupNodes);
42175
42329
  const groupUpdates = groupNodes.map((groupNode) => {
42176
42330
  const groupQuery = new GroupQuery(this.store, groupNode);
42177
42331
  const operation3 = addContactToGroup(contactQuery, groupQuery);
@@ -42181,14 +42335,14 @@ var PodOS = (() => {
42181
42335
  }
42182
42336
  async executeCreateNewContact(addressBookUri, contact4) {
42183
42337
  const addressBookNode = namedNode2(addressBookUri);
42184
- await this.fetchNode(addressBookNode);
42338
+ await this.support.fetchNode(addressBookNode);
42185
42339
  const operation3 = createNewContact(new AddressBookQuery(this.store, addressBookNode), contact4);
42186
42340
  await executeUpdate(this.fetcher, this.updater, operation3);
42187
42341
  return new ContactQuery(this.store, namedNode2(operation3.uri));
42188
42342
  }
42189
42343
  async readContact(uri6) {
42190
42344
  const contactNode = namedNode2(uri6);
42191
- await this.fetchNode(contactNode);
42345
+ await this.support.fetchNode(contactNode);
42192
42346
  const query4 = new ContactQuery(this.store, contactNode);
42193
42347
  const name7 = query4.queryName();
42194
42348
  const emails = query4.queryEmails();
@@ -42202,7 +42356,7 @@ var PodOS = (() => {
42202
42356
  }
42203
42357
  async createNewGroup({ addressBookUri, groupName }) {
42204
42358
  const addressBookNode = namedNode2(addressBookUri);
42205
- await this.fetchNode(addressBookNode);
42359
+ await this.support.fetchNode(addressBookNode);
42206
42360
  const query4 = new AddressBookQuery(this.store, addressBookNode);
42207
42361
  const operation3 = createNewGroup(query4, groupName);
42208
42362
  await executeUpdate(this.fetcher, this.updater, operation3);
@@ -42210,7 +42364,7 @@ var PodOS = (() => {
42210
42364
  }
42211
42365
  async readGroup(uri6) {
42212
42366
  const groupNode = namedNode2(uri6);
42213
- await this.fetchNode(groupNode);
42367
+ await this.support.fetchNode(groupNode);
42214
42368
  const query4 = new GroupQuery(this.store, groupNode);
42215
42369
  const name7 = query4.queryName();
42216
42370
  const members4 = query4.queryMembers();
@@ -42223,7 +42377,7 @@ var PodOS = (() => {
42223
42377
  async addContactToGroup({ contactUri, groupUri }) {
42224
42378
  const contactNode = namedNode2(contactUri);
42225
42379
  const groupNode = namedNode2(groupUri);
42226
- await this.fetchNode(contactNode);
42380
+ await this.support.fetchNode(contactNode);
42227
42381
  const contactQuery = new ContactQuery(this.store, contactNode);
42228
42382
  const groupQuery = new GroupQuery(this.store, groupNode);
42229
42383
  const operation3 = addContactToGroup(contactQuery, groupQuery);
@@ -42232,7 +42386,7 @@ var PodOS = (() => {
42232
42386
  async removeContactFromGroup({ contactUri, groupUri }) {
42233
42387
  const contactNode = namedNode2(contactUri);
42234
42388
  const groupNode = namedNode2(groupUri);
42235
- await this.fetchNode(groupNode);
42389
+ await this.support.fetchNode(groupNode);
42236
42390
  const contactQuery = new ContactQuery(this.store, contactNode);
42237
42391
  const groupQuery = new GroupQuery(this.store, groupNode);
42238
42392
  const operation3 = removeContactFromGroup(contactQuery, groupQuery);
@@ -42253,32 +42407,32 @@ var PodOS = (() => {
42253
42407
  async removePhoneNumber({ contactUri, phoneNumberUri }) {
42254
42408
  const contactNode = namedNode2(contactUri);
42255
42409
  const phoneNumberNode = namedNode2(phoneNumberUri);
42256
- await this.fetchNode(phoneNumberNode);
42410
+ await this.support.fetchNode(phoneNumberNode);
42257
42411
  const operation3 = removePhoneNumber(contactNode, phoneNumberNode, this.store);
42258
42412
  await executeUpdate(this.fetcher, this.updater, operation3);
42259
42413
  }
42260
42414
  async removeEmailAddress({ contactUri, emailAddressUri }) {
42261
42415
  const contactNode = namedNode2(contactUri);
42262
42416
  const emailAddressNode = namedNode2(emailAddressUri);
42263
- await this.fetchNode(emailAddressNode);
42417
+ await this.support.fetchNode(emailAddressNode);
42264
42418
  const operation3 = removeEmailAddress(contactNode, emailAddressNode, this.store);
42265
42419
  await executeUpdate(this.fetcher, this.updater, operation3);
42266
42420
  }
42267
42421
  async updatePhoneNumber({ phoneNumberUri, newPhoneNumber }) {
42268
42422
  const phoneNumberNode = namedNode2(phoneNumberUri);
42269
- await this.fetchNode(phoneNumberNode);
42423
+ await this.support.fetchNode(phoneNumberNode);
42270
42424
  const operation3 = updatePhoneNumber(phoneNumberNode, newPhoneNumber, this.store);
42271
42425
  await executeUpdate(this.fetcher, this.updater, operation3);
42272
42426
  }
42273
42427
  async updateEmailAddress({ emailAddressUri, newEmailAddress }) {
42274
42428
  const emailAddressNode = namedNode2(emailAddressUri);
42275
- await this.fetchNode(emailAddressNode);
42429
+ await this.support.fetchNode(emailAddressNode);
42276
42430
  const operation3 = updateEmailAddress(emailAddressNode, newEmailAddress, this.store);
42277
42431
  await executeUpdate(this.fetcher, this.updater, operation3);
42278
42432
  }
42279
42433
  async listAddressBooks(webId) {
42280
42434
  const profileNode = namedNode2(webId);
42281
- await this.fetchNode(profileNode);
42435
+ await this.support.fetchNode(profileNode);
42282
42436
  const profileQuery = new ProfileQuery(profileNode, this.store);
42283
42437
  const publicTypeIndexNode = profileQuery.queryPublicTypeIndex();
42284
42438
  const preferencesFile2 = profileQuery.queryPreferencesFile();
@@ -42298,20 +42452,20 @@ var PodOS = (() => {
42298
42452
  if (!publicTypeIndexNode) {
42299
42453
  return [];
42300
42454
  }
42301
- await this.fetchNode(publicTypeIndexNode);
42302
- return new TypeIndexQuery(this.store, publicTypeIndexNode).queryAddressBookInstances();
42455
+ await this.support.fetchNode(publicTypeIndexNode);
42456
+ return new TypeIndexQuery(this.store, publicTypeIndexNode).queryInstancesForClass(VCARD_ADDRESS_BOOK);
42303
42457
  }
42304
42458
  async fetchPrivateTypeIndex(profileNode, preferencesFile2) {
42305
42459
  if (!preferencesFile2) {
42306
42460
  return null;
42307
42461
  }
42308
- await this.fetchNode(preferencesFile2);
42462
+ await this.support.fetchNode(preferencesFile2);
42309
42463
  const preferencesQuery = new PreferencesQuery(this.store, profileNode, preferencesFile2);
42310
42464
  return preferencesQuery.queryPrivateTypeIndex();
42311
42465
  }
42312
42466
  async renameContact({ contactUri, newName }) {
42313
42467
  const contactNode = namedNode2(contactUri);
42314
- await this.fetchNode(contactNode);
42468
+ await this.support.fetchNode(contactNode);
42315
42469
  const operation3 = renameContact(this.store, contactNode, newName);
42316
42470
  await executeUpdate(this.fetcher, this.updater, operation3);
42317
42471
  }
@@ -42325,7 +42479,7 @@ var PodOS = (() => {
42325
42479
  default: () => dist_default
42326
42480
  });
42327
42481
  var dist_default;
42328
- var init_dist = __esm({
42482
+ var init_dist2 = __esm({
42329
42483
  "../node_modules/@solid-data-modules/contacts-rdflib/dist/index.js"() {
42330
42484
  init_ContactsModuleRdfLib();
42331
42485
  dist_default = ContactsModuleRdfLib;
@@ -42369,20 +42523,20 @@ var PodOS = (() => {
42369
42523
  if (obj === null || obj === void 0) {
42370
42524
  return obj;
42371
42525
  }
42372
- var clone = /* @__PURE__ */ Object.create(null), keys = Object.keys(obj);
42526
+ var clone2 = /* @__PURE__ */ Object.create(null), keys = Object.keys(obj);
42373
42527
  for (var i = 0; i < keys.length; i++) {
42374
42528
  var key3 = keys[i], val = obj[key3];
42375
42529
  if (Array.isArray(val)) {
42376
- clone[key3] = val.slice();
42530
+ clone2[key3] = val.slice();
42377
42531
  continue;
42378
42532
  }
42379
42533
  if (typeof val === "string" || typeof val === "number" || typeof val === "boolean") {
42380
- clone[key3] = val;
42534
+ clone2[key3] = val;
42381
42535
  continue;
42382
42536
  }
42383
42537
  throw new TypeError("clone is not deep and does not support nested objects");
42384
42538
  }
42385
- return clone;
42539
+ return clone2;
42386
42540
  };
42387
42541
  lunr2.FieldRef = function(docRef, fieldName, stringValue) {
42388
42542
  this.docRef = docRef;
@@ -45763,18 +45917,11 @@ var PodOS = (() => {
45763
45917
  }) : identity;
45764
45918
  }
45765
45919
 
45766
- // ../node_modules/@inrupt/solid-client-authn-core/dist/index.mjs
45767
- var import_events = __toESM(require_events(), 1);
45768
-
45769
- // ../node_modules/@inrupt/universal-fetch/dist/index-browser.mjs
45770
- var indexBrowser = globalThis.fetch;
45771
- var { fetch: fetch2, Response, Request, Headers } = globalThis;
45772
-
45773
- // ../node_modules/jose/dist/browser/runtime/webcrypto.js
45920
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/runtime/webcrypto.js
45774
45921
  var webcrypto_default = crypto;
45775
45922
  var isCryptoKey = (key3) => key3 instanceof CryptoKey;
45776
45923
 
45777
- // ../node_modules/jose/dist/browser/lib/buffer_utils.js
45924
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/lib/buffer_utils.js
45778
45925
  var encoder = new TextEncoder();
45779
45926
  var decoder = new TextDecoder();
45780
45927
  var MAX_INT32 = 2 ** 32;
@@ -45782,14 +45929,14 @@ var PodOS = (() => {
45782
45929
  const size4 = buffers.reduce((acc, { length: length2 }) => acc + length2, 0);
45783
45930
  const buf = new Uint8Array(size4);
45784
45931
  let i = 0;
45785
- buffers.forEach((buffer) => {
45932
+ for (const buffer of buffers) {
45786
45933
  buf.set(buffer, i);
45787
45934
  i += buffer.length;
45788
- });
45935
+ }
45789
45936
  return buf;
45790
45937
  }
45791
45938
 
45792
- // ../node_modules/jose/dist/browser/runtime/base64url.js
45939
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/runtime/base64url.js
45793
45940
  var encodeBase64 = (input2) => {
45794
45941
  let unencoded = input2;
45795
45942
  if (typeof unencoded === "string") {
@@ -45821,44 +45968,45 @@ var PodOS = (() => {
45821
45968
  encoded = encoded.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
45822
45969
  try {
45823
45970
  return decodeBase64(encoded);
45824
- } catch (_a) {
45971
+ } catch {
45825
45972
  throw new TypeError("The input to be decoded is not correctly encoded.");
45826
45973
  }
45827
45974
  };
45828
45975
 
45829
- // ../node_modules/jose/dist/browser/util/errors.js
45976
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/util/errors.js
45830
45977
  var JOSEError = class extends Error {
45831
45978
  static get code() {
45832
45979
  return "ERR_JOSE_GENERIC";
45833
45980
  }
45834
45981
  constructor(message4) {
45835
- var _a;
45836
45982
  super(message4);
45837
45983
  this.code = "ERR_JOSE_GENERIC";
45838
45984
  this.name = this.constructor.name;
45839
- (_a = Error.captureStackTrace) === null || _a === void 0 ? void 0 : _a.call(Error, this, this.constructor);
45985
+ Error.captureStackTrace?.(this, this.constructor);
45840
45986
  }
45841
45987
  };
45842
45988
  var JWTClaimValidationFailed = class extends JOSEError {
45843
45989
  static get code() {
45844
45990
  return "ERR_JWT_CLAIM_VALIDATION_FAILED";
45845
45991
  }
45846
- constructor(message4, claim2 = "unspecified", reason2 = "unspecified") {
45992
+ constructor(message4, payload4, claim2 = "unspecified", reason2 = "unspecified") {
45847
45993
  super(message4);
45848
45994
  this.code = "ERR_JWT_CLAIM_VALIDATION_FAILED";
45849
45995
  this.claim = claim2;
45850
45996
  this.reason = reason2;
45997
+ this.payload = payload4;
45851
45998
  }
45852
45999
  };
45853
46000
  var JWTExpired = class extends JOSEError {
45854
46001
  static get code() {
45855
46002
  return "ERR_JWT_EXPIRED";
45856
46003
  }
45857
- constructor(message4, claim2 = "unspecified", reason2 = "unspecified") {
46004
+ constructor(message4, payload4, claim2 = "unspecified", reason2 = "unspecified") {
45858
46005
  super(message4);
45859
46006
  this.code = "ERR_JWT_EXPIRED";
45860
46007
  this.claim = claim2;
45861
46008
  this.reason = reason2;
46009
+ this.payload = payload4;
45862
46010
  }
45863
46011
  };
45864
46012
  var JOSEAlgNotAllowed = class extends JOSEError {
@@ -45897,6 +46045,45 @@ var PodOS = (() => {
45897
46045
  return "ERR_JWT_INVALID";
45898
46046
  }
45899
46047
  };
46048
+ var JWKSInvalid = class extends JOSEError {
46049
+ constructor() {
46050
+ super(...arguments);
46051
+ this.code = "ERR_JWKS_INVALID";
46052
+ }
46053
+ static get code() {
46054
+ return "ERR_JWKS_INVALID";
46055
+ }
46056
+ };
46057
+ var JWKSNoMatchingKey = class extends JOSEError {
46058
+ constructor() {
46059
+ super(...arguments);
46060
+ this.code = "ERR_JWKS_NO_MATCHING_KEY";
46061
+ this.message = "no applicable key found in the JSON Web Key Set";
46062
+ }
46063
+ static get code() {
46064
+ return "ERR_JWKS_NO_MATCHING_KEY";
46065
+ }
46066
+ };
46067
+ var JWKSMultipleMatchingKeys = class extends JOSEError {
46068
+ constructor() {
46069
+ super(...arguments);
46070
+ this.code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
46071
+ this.message = "multiple matching keys found in the JSON Web Key Set";
46072
+ }
46073
+ static get code() {
46074
+ return "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
46075
+ }
46076
+ };
46077
+ var JWKSTimeout = class extends JOSEError {
46078
+ constructor() {
46079
+ super(...arguments);
46080
+ this.code = "ERR_JWKS_TIMEOUT";
46081
+ this.message = "request timed out";
46082
+ }
46083
+ static get code() {
46084
+ return "ERR_JWKS_TIMEOUT";
46085
+ }
46086
+ };
45900
46087
  var JWSSignatureVerificationFailed = class extends JOSEError {
45901
46088
  constructor() {
45902
46089
  super(...arguments);
@@ -45908,10 +46095,7 @@ var PodOS = (() => {
45908
46095
  }
45909
46096
  };
45910
46097
 
45911
- // ../node_modules/jose/dist/browser/runtime/random.js
45912
- var random_default = webcrypto_default.getRandomValues.bind(webcrypto_default);
45913
-
45914
- // ../node_modules/jose/dist/browser/lib/crypto_key.js
46098
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/lib/crypto_key.js
45915
46099
  function unusable(name7, prop = "algorithm.name") {
45916
46100
  return new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name7}`);
45917
46101
  }
@@ -46005,8 +46189,9 @@ var PodOS = (() => {
46005
46189
  checkUsage(key3, usages);
46006
46190
  }
46007
46191
 
46008
- // ../node_modules/jose/dist/browser/lib/invalid_key_input.js
46192
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/lib/invalid_key_input.js
46009
46193
  function message(msg2, actual2, ...types2) {
46194
+ types2 = types2.filter(Boolean);
46010
46195
  if (types2.length > 2) {
46011
46196
  const last3 = types2.pop();
46012
46197
  msg2 += `one of type ${types2.join(", ")}, or ${last3}.`;
@@ -46020,7 +46205,7 @@ var PodOS = (() => {
46020
46205
  } else if (typeof actual2 === "function" && actual2.name) {
46021
46206
  msg2 += ` Received function ${actual2.name}`;
46022
46207
  } else if (typeof actual2 === "object" && actual2 != null) {
46023
- if (actual2.constructor && actual2.constructor.name) {
46208
+ if (actual2.constructor?.name) {
46024
46209
  msg2 += ` Received an instance of ${actual2.constructor.name}`;
46025
46210
  }
46026
46211
  }
@@ -46033,13 +46218,16 @@ var PodOS = (() => {
46033
46218
  return message(`Key for the ${alg} algorithm must be `, actual2, ...types2);
46034
46219
  }
46035
46220
 
46036
- // ../node_modules/jose/dist/browser/runtime/is_key_like.js
46221
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/runtime/is_key_like.js
46037
46222
  var is_key_like_default = (key3) => {
46038
- return isCryptoKey(key3);
46223
+ if (isCryptoKey(key3)) {
46224
+ return true;
46225
+ }
46226
+ return key3?.[Symbol.toStringTag] === "KeyObject";
46039
46227
  };
46040
46228
  var types = ["CryptoKey"];
46041
46229
 
46042
- // ../node_modules/jose/dist/browser/lib/is_disjoint.js
46230
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/lib/is_disjoint.js
46043
46231
  var isDisjoint = (...headers) => {
46044
46232
  const sources = headers.filter(Boolean);
46045
46233
  if (sources.length === 0 || sources.length === 1) {
@@ -46063,7 +46251,7 @@ var PodOS = (() => {
46063
46251
  };
46064
46252
  var is_disjoint_default = isDisjoint;
46065
46253
 
46066
- // ../node_modules/jose/dist/browser/lib/is_object.js
46254
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/lib/is_object.js
46067
46255
  function isObjectLike(value6) {
46068
46256
  return typeof value6 === "object" && value6 !== null;
46069
46257
  }
@@ -46081,7 +46269,7 @@ var PodOS = (() => {
46081
46269
  return Object.getPrototypeOf(input2) === proto;
46082
46270
  }
46083
46271
 
46084
- // ../node_modules/jose/dist/browser/runtime/check_key_length.js
46272
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/runtime/check_key_length.js
46085
46273
  var check_key_length_default = (alg, key3) => {
46086
46274
  if (alg.startsWith("RS") || alg.startsWith("PS")) {
46087
46275
  const { modulusLength } = key3.algorithm;
@@ -46091,49 +46279,25 @@ var PodOS = (() => {
46091
46279
  }
46092
46280
  };
46093
46281
 
46094
- // ../node_modules/jose/dist/browser/runtime/jwk_to_key.js
46282
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/lib/is_jwk.js
46283
+ function isJWK(key3) {
46284
+ return isObject(key3) && typeof key3.kty === "string";
46285
+ }
46286
+ function isPrivateJWK(key3) {
46287
+ return key3.kty !== "oct" && typeof key3.d === "string";
46288
+ }
46289
+ function isPublicJWK(key3) {
46290
+ return key3.kty !== "oct" && typeof key3.d === "undefined";
46291
+ }
46292
+ function isSecretJWK(key3) {
46293
+ return isJWK(key3) && key3.kty === "oct" && typeof key3.k === "string";
46294
+ }
46295
+
46296
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/runtime/jwk_to_key.js
46095
46297
  function subtleMapping(jwk) {
46096
46298
  let algorithm3;
46097
46299
  let keyUsages;
46098
46300
  switch (jwk.kty) {
46099
- case "oct": {
46100
- switch (jwk.alg) {
46101
- case "HS256":
46102
- case "HS384":
46103
- case "HS512":
46104
- algorithm3 = { name: "HMAC", hash: `SHA-${jwk.alg.slice(-3)}` };
46105
- keyUsages = ["sign", "verify"];
46106
- break;
46107
- case "A128CBC-HS256":
46108
- case "A192CBC-HS384":
46109
- case "A256CBC-HS512":
46110
- throw new JOSENotSupported(`${jwk.alg} keys cannot be imported as CryptoKey instances`);
46111
- case "A128GCM":
46112
- case "A192GCM":
46113
- case "A256GCM":
46114
- case "A128GCMKW":
46115
- case "A192GCMKW":
46116
- case "A256GCMKW":
46117
- algorithm3 = { name: "AES-GCM" };
46118
- keyUsages = ["encrypt", "decrypt"];
46119
- break;
46120
- case "A128KW":
46121
- case "A192KW":
46122
- case "A256KW":
46123
- algorithm3 = { name: "AES-KW" };
46124
- keyUsages = ["wrapKey", "unwrapKey"];
46125
- break;
46126
- case "PBES2-HS256+A128KW":
46127
- case "PBES2-HS384+A192KW":
46128
- case "PBES2-HS512+A256KW":
46129
- algorithm3 = { name: "PBKDF2" };
46130
- keyUsages = ["deriveBits"];
46131
- break;
46132
- default:
46133
- throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
46134
- }
46135
- break;
46136
- }
46137
46301
  case "RSA": {
46138
46302
  switch (jwk.alg) {
46139
46303
  case "PS256":
@@ -46213,19 +46377,15 @@ var PodOS = (() => {
46213
46377
  return { algorithm: algorithm3, keyUsages };
46214
46378
  }
46215
46379
  var parse = async (jwk) => {
46216
- var _a, _b;
46217
46380
  if (!jwk.alg) {
46218
46381
  throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
46219
46382
  }
46220
46383
  const { algorithm: algorithm3, keyUsages } = subtleMapping(jwk);
46221
46384
  const rest3 = [
46222
46385
  algorithm3,
46223
- (_a = jwk.ext) !== null && _a !== void 0 ? _a : false,
46224
- (_b = jwk.key_ops) !== null && _b !== void 0 ? _b : keyUsages
46386
+ jwk.ext ?? false,
46387
+ jwk.key_ops ?? keyUsages
46225
46388
  ];
46226
- if (algorithm3.name === "PBKDF2") {
46227
- return webcrypto_default.subtle.importKey("raw", decode(jwk.k), ...rest3);
46228
- }
46229
46389
  const keyData = { ...jwk };
46230
46390
  delete keyData.alg;
46231
46391
  delete keyData.use;
@@ -46233,9 +46393,74 @@ var PodOS = (() => {
46233
46393
  };
46234
46394
  var jwk_to_key_default = parse;
46235
46395
 
46236
- // ../node_modules/jose/dist/browser/key/import.js
46237
- async function importJWK(jwk, alg, octAsKeyObject) {
46238
- var _a;
46396
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/runtime/normalize_key.js
46397
+ var exportKeyValue = (k) => decode(k);
46398
+ var privCache;
46399
+ var pubCache;
46400
+ var isKeyObject = (key3) => {
46401
+ return key3?.[Symbol.toStringTag] === "KeyObject";
46402
+ };
46403
+ var importAndCache = async (cache, key3, jwk, alg, freeze = false) => {
46404
+ let cached = cache.get(key3);
46405
+ if (cached?.[alg]) {
46406
+ return cached[alg];
46407
+ }
46408
+ const cryptoKey = await jwk_to_key_default({ ...jwk, alg });
46409
+ if (freeze)
46410
+ Object.freeze(key3);
46411
+ if (!cached) {
46412
+ cache.set(key3, { [alg]: cryptoKey });
46413
+ } else {
46414
+ cached[alg] = cryptoKey;
46415
+ }
46416
+ return cryptoKey;
46417
+ };
46418
+ var normalizePublicKey = (key3, alg) => {
46419
+ if (isKeyObject(key3)) {
46420
+ let jwk = key3.export({ format: "jwk" });
46421
+ delete jwk.d;
46422
+ delete jwk.dp;
46423
+ delete jwk.dq;
46424
+ delete jwk.p;
46425
+ delete jwk.q;
46426
+ delete jwk.qi;
46427
+ if (jwk.k) {
46428
+ return exportKeyValue(jwk.k);
46429
+ }
46430
+ pubCache || (pubCache = /* @__PURE__ */ new WeakMap());
46431
+ return importAndCache(pubCache, key3, jwk, alg);
46432
+ }
46433
+ if (isJWK(key3)) {
46434
+ if (key3.k)
46435
+ return decode(key3.k);
46436
+ pubCache || (pubCache = /* @__PURE__ */ new WeakMap());
46437
+ const cryptoKey = importAndCache(pubCache, key3, key3, alg, true);
46438
+ return cryptoKey;
46439
+ }
46440
+ return key3;
46441
+ };
46442
+ var normalizePrivateKey = (key3, alg) => {
46443
+ if (isKeyObject(key3)) {
46444
+ let jwk = key3.export({ format: "jwk" });
46445
+ if (jwk.k) {
46446
+ return exportKeyValue(jwk.k);
46447
+ }
46448
+ privCache || (privCache = /* @__PURE__ */ new WeakMap());
46449
+ return importAndCache(privCache, key3, jwk, alg);
46450
+ }
46451
+ if (isJWK(key3)) {
46452
+ if (key3.k)
46453
+ return decode(key3.k);
46454
+ privCache || (privCache = /* @__PURE__ */ new WeakMap());
46455
+ const cryptoKey = importAndCache(privCache, key3, key3, alg, true);
46456
+ return cryptoKey;
46457
+ }
46458
+ return key3;
46459
+ };
46460
+ var normalize_key_default = { normalizePublicKey, normalizePrivateKey };
46461
+
46462
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/key/import.js
46463
+ async function importJWK(jwk, alg) {
46239
46464
  if (!isObject(jwk)) {
46240
46465
  throw new TypeError("JWK must be an object");
46241
46466
  }
@@ -46245,10 +46470,6 @@ var PodOS = (() => {
46245
46470
  if (typeof jwk.k !== "string" || !jwk.k) {
46246
46471
  throw new TypeError('missing "k" (Key Value) Parameter value');
46247
46472
  }
46248
- octAsKeyObject !== null && octAsKeyObject !== void 0 ? octAsKeyObject : octAsKeyObject = jwk.ext !== true;
46249
- if (octAsKeyObject) {
46250
- return jwk_to_key_default({ ...jwk, alg, ext: (_a = jwk.ext) !== null && _a !== void 0 ? _a : false });
46251
- }
46252
46473
  return decode(jwk.k);
46253
46474
  case "RSA":
46254
46475
  if (jwk.oth !== void 0) {
@@ -46262,50 +46483,81 @@ var PodOS = (() => {
46262
46483
  }
46263
46484
  }
46264
46485
 
46265
- // ../node_modules/jose/dist/browser/lib/check_key_type.js
46266
- var symmetricTypeCheck = (alg, key3) => {
46486
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/lib/check_key_type.js
46487
+ var tag = (key3) => key3?.[Symbol.toStringTag];
46488
+ var jwkMatchesOp = (alg, key3, usage2) => {
46489
+ if (key3.use !== void 0 && key3.use !== "sig") {
46490
+ throw new TypeError("Invalid key for this operation, when present its use must be sig");
46491
+ }
46492
+ if (key3.key_ops !== void 0 && key3.key_ops.includes?.(usage2) !== true) {
46493
+ throw new TypeError(`Invalid key for this operation, when present its key_ops must include ${usage2}`);
46494
+ }
46495
+ if (key3.alg !== void 0 && key3.alg !== alg) {
46496
+ throw new TypeError(`Invalid key for this operation, when present its alg must be ${alg}`);
46497
+ }
46498
+ return true;
46499
+ };
46500
+ var symmetricTypeCheck = (alg, key3, usage2, allowJwk) => {
46267
46501
  if (key3 instanceof Uint8Array)
46268
46502
  return;
46503
+ if (allowJwk && isJWK(key3)) {
46504
+ if (isSecretJWK(key3) && jwkMatchesOp(alg, key3, usage2))
46505
+ return;
46506
+ 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`);
46507
+ }
46269
46508
  if (!is_key_like_default(key3)) {
46270
- throw new TypeError(withAlg(alg, key3, ...types, "Uint8Array"));
46509
+ throw new TypeError(withAlg(alg, key3, ...types, "Uint8Array", allowJwk ? "JSON Web Key" : null));
46271
46510
  }
46272
46511
  if (key3.type !== "secret") {
46273
- throw new TypeError(`${types.join(" or ")} instances for symmetric algorithms must be of type "secret"`);
46512
+ throw new TypeError(`${tag(key3)} instances for symmetric algorithms must be of type "secret"`);
46274
46513
  }
46275
46514
  };
46276
- var asymmetricTypeCheck = (alg, key3, usage2) => {
46515
+ var asymmetricTypeCheck = (alg, key3, usage2, allowJwk) => {
46516
+ if (allowJwk && isJWK(key3)) {
46517
+ switch (usage2) {
46518
+ case "sign":
46519
+ if (isPrivateJWK(key3) && jwkMatchesOp(alg, key3, usage2))
46520
+ return;
46521
+ throw new TypeError(`JSON Web Key for this operation be a private JWK`);
46522
+ case "verify":
46523
+ if (isPublicJWK(key3) && jwkMatchesOp(alg, key3, usage2))
46524
+ return;
46525
+ throw new TypeError(`JSON Web Key for this operation be a public JWK`);
46526
+ }
46527
+ }
46277
46528
  if (!is_key_like_default(key3)) {
46278
- throw new TypeError(withAlg(alg, key3, ...types));
46529
+ throw new TypeError(withAlg(alg, key3, ...types, allowJwk ? "JSON Web Key" : null));
46279
46530
  }
46280
46531
  if (key3.type === "secret") {
46281
- throw new TypeError(`${types.join(" or ")} instances for asymmetric algorithms must not be of type "secret"`);
46532
+ throw new TypeError(`${tag(key3)} instances for asymmetric algorithms must not be of type "secret"`);
46282
46533
  }
46283
46534
  if (usage2 === "sign" && key3.type === "public") {
46284
- throw new TypeError(`${types.join(" or ")} instances for asymmetric algorithm signing must be of type "private"`);
46535
+ throw new TypeError(`${tag(key3)} instances for asymmetric algorithm signing must be of type "private"`);
46285
46536
  }
46286
46537
  if (usage2 === "decrypt" && key3.type === "public") {
46287
- throw new TypeError(`${types.join(" or ")} instances for asymmetric algorithm decryption must be of type "private"`);
46538
+ throw new TypeError(`${tag(key3)} instances for asymmetric algorithm decryption must be of type "private"`);
46288
46539
  }
46289
46540
  if (key3.algorithm && usage2 === "verify" && key3.type === "private") {
46290
- throw new TypeError(`${types.join(" or ")} instances for asymmetric algorithm verifying must be of type "public"`);
46541
+ throw new TypeError(`${tag(key3)} instances for asymmetric algorithm verifying must be of type "public"`);
46291
46542
  }
46292
46543
  if (key3.algorithm && usage2 === "encrypt" && key3.type === "private") {
46293
- throw new TypeError(`${types.join(" or ")} instances for asymmetric algorithm encryption must be of type "public"`);
46544
+ throw new TypeError(`${tag(key3)} instances for asymmetric algorithm encryption must be of type "public"`);
46294
46545
  }
46295
46546
  };
46296
- var checkKeyType = (alg, key3, usage2) => {
46547
+ function checkKeyType(allowJwk, alg, key3, usage2) {
46297
46548
  const symmetric = alg.startsWith("HS") || alg === "dir" || alg.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(alg);
46298
46549
  if (symmetric) {
46299
- symmetricTypeCheck(alg, key3);
46550
+ symmetricTypeCheck(alg, key3, usage2, allowJwk);
46300
46551
  } else {
46301
- asymmetricTypeCheck(alg, key3, usage2);
46552
+ asymmetricTypeCheck(alg, key3, usage2, allowJwk);
46302
46553
  }
46303
- };
46304
- var check_key_type_default = checkKeyType;
46554
+ }
46555
+ var check_key_type_default = checkKeyType.bind(void 0, false);
46556
+ var checkKeyTypeWithJwk = checkKeyType.bind(void 0, true);
46305
46557
 
46306
- // ../node_modules/jose/dist/browser/lib/validate_crit.js
46558
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/lib/validate_crit.js
46307
46559
  function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
46308
- if (joseHeader.crit !== void 0 && protectedHeader.crit === void 0) {
46560
+ if (joseHeader.crit !== void 0 && protectedHeader?.crit === void 0) {
46309
46561
  throw new Err('"crit" (Critical) Header Parameter MUST be integrity protected');
46310
46562
  }
46311
46563
  if (!protectedHeader || protectedHeader.crit === void 0) {
@@ -46326,7 +46578,8 @@ var PodOS = (() => {
46326
46578
  }
46327
46579
  if (joseHeader[parameter2] === void 0) {
46328
46580
  throw new Err(`Extension Header Parameter "${parameter2}" is missing`);
46329
- } else if (recognized.get(parameter2) && protectedHeader[parameter2] === void 0) {
46581
+ }
46582
+ if (recognized.get(parameter2) && protectedHeader[parameter2] === void 0) {
46330
46583
  throw new Err(`Extension Header Parameter "${parameter2}" MUST be integrity protected`);
46331
46584
  }
46332
46585
  }
@@ -46334,7 +46587,7 @@ var PodOS = (() => {
46334
46587
  }
46335
46588
  var validate_crit_default = validateCrit;
46336
46589
 
46337
- // ../node_modules/jose/dist/browser/lib/validate_algorithms.js
46590
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/lib/validate_algorithms.js
46338
46591
  var validateAlgorithms = (option5, algorithms) => {
46339
46592
  if (algorithms !== void 0 && (!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== "string"))) {
46340
46593
  throw new TypeError(`"${option5}" option must be an array of strings`);
@@ -46346,7 +46599,7 @@ var PodOS = (() => {
46346
46599
  };
46347
46600
  var validate_algorithms_default = validateAlgorithms;
46348
46601
 
46349
- // ../node_modules/jose/dist/browser/runtime/key_to_jwk.js
46602
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/runtime/key_to_jwk.js
46350
46603
  var keyToJWK = async (key3) => {
46351
46604
  if (key3 instanceof Uint8Array) {
46352
46605
  return {
@@ -46365,15 +46618,12 @@ var PodOS = (() => {
46365
46618
  };
46366
46619
  var key_to_jwk_default = keyToJWK;
46367
46620
 
46368
- // ../node_modules/jose/dist/browser/key/export.js
46621
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/key/export.js
46369
46622
  async function exportJWK(key3) {
46370
46623
  return key_to_jwk_default(key3);
46371
46624
  }
46372
46625
 
46373
- // ../node_modules/jose/dist/browser/jwe/flattened/encrypt.js
46374
- var unprotected = Symbol();
46375
-
46376
- // ../node_modules/jose/dist/browser/runtime/subtle_dsa.js
46626
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/runtime/subtle_dsa.js
46377
46627
  function subtleDsa(alg, algorithm3) {
46378
46628
  const hash2 = `SHA-${alg.slice(-3)}`;
46379
46629
  switch (alg) {
@@ -46400,8 +46650,14 @@ var PodOS = (() => {
46400
46650
  }
46401
46651
  }
46402
46652
 
46403
- // ../node_modules/jose/dist/browser/runtime/get_sign_verify_key.js
46404
- function getCryptoKey(alg, key3, usage2) {
46653
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/runtime/get_sign_verify_key.js
46654
+ async function getCryptoKey(alg, key3, usage2) {
46655
+ if (usage2 === "sign") {
46656
+ key3 = await normalize_key_default.normalizePrivateKey(key3, alg);
46657
+ }
46658
+ if (usage2 === "verify") {
46659
+ key3 = await normalize_key_default.normalizePublicKey(key3, alg);
46660
+ }
46405
46661
  if (isCryptoKey(key3)) {
46406
46662
  checkSigCryptoKey(key3, alg, usage2);
46407
46663
  return key3;
@@ -46412,25 +46668,24 @@ var PodOS = (() => {
46412
46668
  }
46413
46669
  return webcrypto_default.subtle.importKey("raw", key3, { hash: `SHA-${alg.slice(-3)}`, name: "HMAC" }, false, [usage2]);
46414
46670
  }
46415
- throw new TypeError(invalid_key_input_default(key3, ...types, "Uint8Array"));
46671
+ throw new TypeError(invalid_key_input_default(key3, ...types, "Uint8Array", "JSON Web Key"));
46416
46672
  }
46417
46673
 
46418
- // ../node_modules/jose/dist/browser/runtime/verify.js
46674
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/runtime/verify.js
46419
46675
  var verify = async (alg, key3, signature2, data2) => {
46420
46676
  const cryptoKey = await getCryptoKey(alg, key3, "verify");
46421
46677
  check_key_length_default(alg, cryptoKey);
46422
46678
  const algorithm3 = subtleDsa(alg, cryptoKey.algorithm);
46423
46679
  try {
46424
46680
  return await webcrypto_default.subtle.verify(algorithm3, cryptoKey, signature2, data2);
46425
- } catch (_a) {
46681
+ } catch {
46426
46682
  return false;
46427
46683
  }
46428
46684
  };
46429
46685
  var verify_default = verify;
46430
46686
 
46431
- // ../node_modules/jose/dist/browser/jws/flattened/verify.js
46687
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/jws/flattened/verify.js
46432
46688
  async function flattenedVerify(jws2, key3, options) {
46433
- var _a;
46434
46689
  if (!isObject(jws2)) {
46435
46690
  throw new JWSInvalid("Flattened JWS must be an object");
46436
46691
  }
@@ -46454,7 +46709,7 @@ var PodOS = (() => {
46454
46709
  try {
46455
46710
  const protectedHeader = decode(jws2.protected);
46456
46711
  parsedProt = JSON.parse(decoder.decode(protectedHeader));
46457
- } catch (_b) {
46712
+ } catch {
46458
46713
  throw new JWSInvalid("JWS Protected Header is invalid");
46459
46714
  }
46460
46715
  }
@@ -46465,7 +46720,7 @@ var PodOS = (() => {
46465
46720
  ...parsedProt,
46466
46721
  ...jws2.header
46467
46722
  };
46468
- const extensions = validate_crit_default(JWSInvalid, /* @__PURE__ */ new Map([["b64", true]]), options === null || options === void 0 ? void 0 : options.crit, parsedProt, joseHeader);
46723
+ const extensions = validate_crit_default(JWSInvalid, /* @__PURE__ */ new Map([["b64", true]]), options?.crit, parsedProt, joseHeader);
46469
46724
  let b64 = true;
46470
46725
  if (extensions.has("b64")) {
46471
46726
  b64 = parsedProt.b64;
@@ -46479,7 +46734,7 @@ var PodOS = (() => {
46479
46734
  }
46480
46735
  const algorithms = options && validate_algorithms_default("algorithms", options.algorithms);
46481
46736
  if (algorithms && !algorithms.has(alg)) {
46482
- throw new JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter not allowed');
46737
+ throw new JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter value not allowed');
46483
46738
  }
46484
46739
  if (b64) {
46485
46740
  if (typeof jws2.payload !== "string") {
@@ -46492,13 +46747,18 @@ var PodOS = (() => {
46492
46747
  if (typeof key3 === "function") {
46493
46748
  key3 = await key3(parsedProt, jws2);
46494
46749
  resolvedKey = true;
46750
+ checkKeyTypeWithJwk(alg, key3, "verify");
46751
+ if (isJWK(key3)) {
46752
+ key3 = await importJWK(key3, alg);
46753
+ }
46754
+ } else {
46755
+ checkKeyTypeWithJwk(alg, key3, "verify");
46495
46756
  }
46496
- check_key_type_default(alg, key3, "verify");
46497
- 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);
46757
+ const data2 = concat(encoder.encode(jws2.protected ?? ""), encoder.encode("."), typeof jws2.payload === "string" ? encoder.encode(jws2.payload) : jws2.payload);
46498
46758
  let signature2;
46499
46759
  try {
46500
46760
  signature2 = decode(jws2.signature);
46501
- } catch (_c) {
46761
+ } catch {
46502
46762
  throw new JWSInvalid("Failed to base64url decode the signature");
46503
46763
  }
46504
46764
  const verified2 = await verify_default(alg, key3, signature2, data2);
@@ -46509,7 +46769,7 @@ var PodOS = (() => {
46509
46769
  if (b64) {
46510
46770
  try {
46511
46771
  payload4 = decode(jws2.payload);
46512
- } catch (_d) {
46772
+ } catch {
46513
46773
  throw new JWSInvalid("Failed to base64url decode the payload");
46514
46774
  }
46515
46775
  } else if (typeof jws2.payload === "string") {
@@ -46530,7 +46790,7 @@ var PodOS = (() => {
46530
46790
  return result5;
46531
46791
  }
46532
46792
 
46533
- // ../node_modules/jose/dist/browser/jws/compact/verify.js
46793
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/jws/compact/verify.js
46534
46794
  async function compactVerify(jws2, key3, options) {
46535
46795
  if (jws2 instanceof Uint8Array) {
46536
46796
  jws2 = decoder.decode(jws2);
@@ -46550,56 +46810,67 @@ var PodOS = (() => {
46550
46810
  return result5;
46551
46811
  }
46552
46812
 
46553
- // ../node_modules/jose/dist/browser/lib/epoch.js
46813
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/lib/epoch.js
46554
46814
  var epoch_default = (date5) => Math.floor(date5.getTime() / 1e3);
46555
46815
 
46556
- // ../node_modules/jose/dist/browser/lib/secs.js
46816
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/lib/secs.js
46557
46817
  var minute = 60;
46558
46818
  var hour = minute * 60;
46559
46819
  var day = hour * 24;
46560
46820
  var week = day * 7;
46561
46821
  var year = day * 365.25;
46562
- var REGEX = /^(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i;
46822
+ var REGEX = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;
46563
46823
  var secs_default = (str) => {
46564
46824
  const matched = REGEX.exec(str);
46565
- if (!matched) {
46825
+ if (!matched || matched[4] && matched[1]) {
46566
46826
  throw new TypeError("Invalid time period format");
46567
46827
  }
46568
- const value6 = parseFloat(matched[1]);
46569
- const unit2 = matched[2].toLowerCase();
46828
+ const value6 = parseFloat(matched[2]);
46829
+ const unit2 = matched[3].toLowerCase();
46830
+ let numericDate;
46570
46831
  switch (unit2) {
46571
46832
  case "sec":
46572
46833
  case "secs":
46573
46834
  case "second":
46574
46835
  case "seconds":
46575
46836
  case "s":
46576
- return Math.round(value6);
46837
+ numericDate = Math.round(value6);
46838
+ break;
46577
46839
  case "minute":
46578
46840
  case "minutes":
46579
46841
  case "min":
46580
46842
  case "mins":
46581
46843
  case "m":
46582
- return Math.round(value6 * minute);
46844
+ numericDate = Math.round(value6 * minute);
46845
+ break;
46583
46846
  case "hour":
46584
46847
  case "hours":
46585
46848
  case "hr":
46586
46849
  case "hrs":
46587
46850
  case "h":
46588
- return Math.round(value6 * hour);
46851
+ numericDate = Math.round(value6 * hour);
46852
+ break;
46589
46853
  case "day":
46590
46854
  case "days":
46591
46855
  case "d":
46592
- return Math.round(value6 * day);
46856
+ numericDate = Math.round(value6 * day);
46857
+ break;
46593
46858
  case "week":
46594
46859
  case "weeks":
46595
46860
  case "w":
46596
- return Math.round(value6 * week);
46861
+ numericDate = Math.round(value6 * week);
46862
+ break;
46597
46863
  default:
46598
- return Math.round(value6 * year);
46864
+ numericDate = Math.round(value6 * year);
46865
+ break;
46599
46866
  }
46867
+ if (matched[1] === "-" || matched[4] === "ago") {
46868
+ return -numericDate;
46869
+ }
46870
+ return numericDate;
46600
46871
  };
46601
46872
 
46602
- // ../node_modules/jose/dist/browser/lib/jwt_claims_set.js
46873
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/lib/jwt_claims_set.js
46603
46874
  var normalizeTyp = (value6) => value6.toLowerCase().replace(/^application\//, "");
46604
46875
  var checkAudiencePresence = (audPayload, audOption) => {
46605
46876
  if (typeof audPayload === "string") {
@@ -46611,40 +46882,41 @@ var PodOS = (() => {
46611
46882
  return false;
46612
46883
  };
46613
46884
  var jwt_claims_set_default = (protectedHeader, encodedPayload, options = {}) => {
46614
- const { typ } = options;
46615
- if (typ && (typeof protectedHeader.typ !== "string" || normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ))) {
46616
- throw new JWTClaimValidationFailed('unexpected "typ" JWT header value', "typ", "check_failed");
46617
- }
46618
46885
  let payload4;
46619
46886
  try {
46620
46887
  payload4 = JSON.parse(decoder.decode(encodedPayload));
46621
- } catch (_a) {
46888
+ } catch {
46622
46889
  }
46623
46890
  if (!isObject(payload4)) {
46624
46891
  throw new JWTInvalid("JWT Claims Set must be a top-level JSON object");
46625
46892
  }
46893
+ const { typ } = options;
46894
+ if (typ && (typeof protectedHeader.typ !== "string" || normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ))) {
46895
+ throw new JWTClaimValidationFailed('unexpected "typ" JWT header value', payload4, "typ", "check_failed");
46896
+ }
46626
46897
  const { requiredClaims = [], issuer: issuer2, subject: subject5, audience: audience5, maxTokenAge } = options;
46898
+ const presenceCheck = [...requiredClaims];
46627
46899
  if (maxTokenAge !== void 0)
46628
- requiredClaims.push("iat");
46900
+ presenceCheck.push("iat");
46629
46901
  if (audience5 !== void 0)
46630
- requiredClaims.push("aud");
46902
+ presenceCheck.push("aud");
46631
46903
  if (subject5 !== void 0)
46632
- requiredClaims.push("sub");
46904
+ presenceCheck.push("sub");
46633
46905
  if (issuer2 !== void 0)
46634
- requiredClaims.push("iss");
46635
- for (const claim2 of new Set(requiredClaims.reverse())) {
46906
+ presenceCheck.push("iss");
46907
+ for (const claim2 of new Set(presenceCheck.reverse())) {
46636
46908
  if (!(claim2 in payload4)) {
46637
- throw new JWTClaimValidationFailed(`missing required "${claim2}" claim`, claim2, "missing");
46909
+ throw new JWTClaimValidationFailed(`missing required "${claim2}" claim`, payload4, claim2, "missing");
46638
46910
  }
46639
46911
  }
46640
46912
  if (issuer2 && !(Array.isArray(issuer2) ? issuer2 : [issuer2]).includes(payload4.iss)) {
46641
- throw new JWTClaimValidationFailed('unexpected "iss" claim value', "iss", "check_failed");
46913
+ throw new JWTClaimValidationFailed('unexpected "iss" claim value', payload4, "iss", "check_failed");
46642
46914
  }
46643
46915
  if (subject5 && payload4.sub !== subject5) {
46644
- throw new JWTClaimValidationFailed('unexpected "sub" claim value', "sub", "check_failed");
46916
+ throw new JWTClaimValidationFailed('unexpected "sub" claim value', payload4, "sub", "check_failed");
46645
46917
  }
46646
46918
  if (audience5 && !checkAudiencePresence(payload4.aud, typeof audience5 === "string" ? [audience5] : audience5)) {
46647
- throw new JWTClaimValidationFailed('unexpected "aud" claim value', "aud", "check_failed");
46919
+ throw new JWTClaimValidationFailed('unexpected "aud" claim value', payload4, "aud", "check_failed");
46648
46920
  }
46649
46921
  let tolerance;
46650
46922
  switch (typeof options.clockTolerance) {
@@ -46663,42 +46935,41 @@ var PodOS = (() => {
46663
46935
  const { currentDate } = options;
46664
46936
  const now = epoch_default(currentDate || /* @__PURE__ */ new Date());
46665
46937
  if ((payload4.iat !== void 0 || maxTokenAge) && typeof payload4.iat !== "number") {
46666
- throw new JWTClaimValidationFailed('"iat" claim must be a number', "iat", "invalid");
46938
+ throw new JWTClaimValidationFailed('"iat" claim must be a number', payload4, "iat", "invalid");
46667
46939
  }
46668
46940
  if (payload4.nbf !== void 0) {
46669
46941
  if (typeof payload4.nbf !== "number") {
46670
- throw new JWTClaimValidationFailed('"nbf" claim must be a number', "nbf", "invalid");
46942
+ throw new JWTClaimValidationFailed('"nbf" claim must be a number', payload4, "nbf", "invalid");
46671
46943
  }
46672
46944
  if (payload4.nbf > now + tolerance) {
46673
- throw new JWTClaimValidationFailed('"nbf" claim timestamp check failed', "nbf", "check_failed");
46945
+ throw new JWTClaimValidationFailed('"nbf" claim timestamp check failed', payload4, "nbf", "check_failed");
46674
46946
  }
46675
46947
  }
46676
46948
  if (payload4.exp !== void 0) {
46677
46949
  if (typeof payload4.exp !== "number") {
46678
- throw new JWTClaimValidationFailed('"exp" claim must be a number', "exp", "invalid");
46950
+ throw new JWTClaimValidationFailed('"exp" claim must be a number', payload4, "exp", "invalid");
46679
46951
  }
46680
46952
  if (payload4.exp <= now - tolerance) {
46681
- throw new JWTExpired('"exp" claim timestamp check failed', "exp", "check_failed");
46953
+ throw new JWTExpired('"exp" claim timestamp check failed', payload4, "exp", "check_failed");
46682
46954
  }
46683
46955
  }
46684
46956
  if (maxTokenAge) {
46685
46957
  const age2 = now - payload4.iat;
46686
46958
  const max2 = typeof maxTokenAge === "number" ? maxTokenAge : secs_default(maxTokenAge);
46687
46959
  if (age2 - tolerance > max2) {
46688
- throw new JWTExpired('"iat" claim timestamp check failed (too far in the past)', "iat", "check_failed");
46960
+ throw new JWTExpired('"iat" claim timestamp check failed (too far in the past)', payload4, "iat", "check_failed");
46689
46961
  }
46690
46962
  if (age2 < 0 - tolerance) {
46691
- throw new JWTClaimValidationFailed('"iat" claim timestamp check failed (it should be in the past)', "iat", "check_failed");
46963
+ throw new JWTClaimValidationFailed('"iat" claim timestamp check failed (it should be in the past)', payload4, "iat", "check_failed");
46692
46964
  }
46693
46965
  }
46694
46966
  return payload4;
46695
46967
  };
46696
46968
 
46697
- // ../node_modules/jose/dist/browser/jwt/verify.js
46969
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/jwt/verify.js
46698
46970
  async function jwtVerify(jwt, key3, options) {
46699
- var _a;
46700
46971
  const verified2 = await compactVerify(jwt, key3, options);
46701
- if (((_a = verified2.protectedHeader.crit) === null || _a === void 0 ? void 0 : _a.includes("b64")) && verified2.protectedHeader.b64 === false) {
46972
+ if (verified2.protectedHeader.crit?.includes("b64") && verified2.protectedHeader.b64 === false) {
46702
46973
  throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
46703
46974
  }
46704
46975
  const payload4 = jwt_claims_set_default(verified2.protectedHeader, verified2.payload, options);
@@ -46709,7 +46980,7 @@ var PodOS = (() => {
46709
46980
  return result5;
46710
46981
  }
46711
46982
 
46712
- // ../node_modules/jose/dist/browser/runtime/sign.js
46983
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/runtime/sign.js
46713
46984
  var sign = async (alg, key3, data2) => {
46714
46985
  const cryptoKey = await getCryptoKey(alg, key3, "sign");
46715
46986
  check_key_length_default(alg, cryptoKey);
@@ -46718,7 +46989,7 @@ var PodOS = (() => {
46718
46989
  };
46719
46990
  var sign_default = sign;
46720
46991
 
46721
- // ../node_modules/jose/dist/browser/jws/flattened/sign.js
46992
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/jws/flattened/sign.js
46722
46993
  var FlattenedSign = class {
46723
46994
  constructor(payload4) {
46724
46995
  if (!(payload4 instanceof Uint8Array)) {
@@ -46751,7 +47022,7 @@ var PodOS = (() => {
46751
47022
  ...this._protectedHeader,
46752
47023
  ...this._unprotectedHeader
46753
47024
  };
46754
- const extensions = validate_crit_default(JWSInvalid, /* @__PURE__ */ new Map([["b64", true]]), options === null || options === void 0 ? void 0 : options.crit, this._protectedHeader, joseHeader);
47025
+ const extensions = validate_crit_default(JWSInvalid, /* @__PURE__ */ new Map([["b64", true]]), options?.crit, this._protectedHeader, joseHeader);
46755
47026
  let b64 = true;
46756
47027
  if (extensions.has("b64")) {
46757
47028
  b64 = this._protectedHeader.b64;
@@ -46763,7 +47034,7 @@ var PodOS = (() => {
46763
47034
  if (typeof alg !== "string" || !alg) {
46764
47035
  throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
46765
47036
  }
46766
- check_key_type_default(alg, key3, "sign");
47037
+ checkKeyTypeWithJwk(alg, key3, "sign");
46767
47038
  let payload4 = this._payload;
46768
47039
  if (b64) {
46769
47040
  payload4 = encoder.encode(encode(payload4));
@@ -46793,7 +47064,7 @@ var PodOS = (() => {
46793
47064
  }
46794
47065
  };
46795
47066
 
46796
- // ../node_modules/jose/dist/browser/jws/compact/sign.js
47067
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/jws/compact/sign.js
46797
47068
  var CompactSign = class {
46798
47069
  constructor(payload4) {
46799
47070
  this._flattened = new FlattenedSign(payload4);
@@ -46811,9 +47082,15 @@ var PodOS = (() => {
46811
47082
  }
46812
47083
  };
46813
47084
 
46814
- // ../node_modules/jose/dist/browser/jwt/produce.js
47085
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/jwt/produce.js
47086
+ function validateInput(label4, input2) {
47087
+ if (!Number.isFinite(input2)) {
47088
+ throw new TypeError(`Invalid ${label4} input`);
47089
+ }
47090
+ return input2;
47091
+ }
46815
47092
  var ProduceJWT = class {
46816
- constructor(payload4) {
47093
+ constructor(payload4 = {}) {
46817
47094
  if (!isObject(payload4)) {
46818
47095
  throw new TypeError("JWT Claims Set MUST be an object");
46819
47096
  }
@@ -46837,7 +47114,9 @@ var PodOS = (() => {
46837
47114
  }
46838
47115
  setNotBefore(input2) {
46839
47116
  if (typeof input2 === "number") {
46840
- this._payload = { ...this._payload, nbf: input2 };
47117
+ this._payload = { ...this._payload, nbf: validateInput("setNotBefore", input2) };
47118
+ } else if (input2 instanceof Date) {
47119
+ this._payload = { ...this._payload, nbf: validateInput("setNotBefore", epoch_default(input2)) };
46841
47120
  } else {
46842
47121
  this._payload = { ...this._payload, nbf: epoch_default(/* @__PURE__ */ new Date()) + secs_default(input2) };
46843
47122
  }
@@ -46845,7 +47124,9 @@ var PodOS = (() => {
46845
47124
  }
46846
47125
  setExpirationTime(input2) {
46847
47126
  if (typeof input2 === "number") {
46848
- this._payload = { ...this._payload, exp: input2 };
47127
+ this._payload = { ...this._payload, exp: validateInput("setExpirationTime", input2) };
47128
+ } else if (input2 instanceof Date) {
47129
+ this._payload = { ...this._payload, exp: validateInput("setExpirationTime", epoch_default(input2)) };
46849
47130
  } else {
46850
47131
  this._payload = { ...this._payload, exp: epoch_default(/* @__PURE__ */ new Date()) + secs_default(input2) };
46851
47132
  }
@@ -46854,41 +47135,318 @@ var PodOS = (() => {
46854
47135
  setIssuedAt(input2) {
46855
47136
  if (typeof input2 === "undefined") {
46856
47137
  this._payload = { ...this._payload, iat: epoch_default(/* @__PURE__ */ new Date()) };
47138
+ } else if (input2 instanceof Date) {
47139
+ this._payload = { ...this._payload, iat: validateInput("setIssuedAt", epoch_default(input2)) };
47140
+ } else if (typeof input2 === "string") {
47141
+ this._payload = {
47142
+ ...this._payload,
47143
+ iat: validateInput("setIssuedAt", epoch_default(/* @__PURE__ */ new Date()) + secs_default(input2))
47144
+ };
46857
47145
  } else {
46858
- this._payload = { ...this._payload, iat: input2 };
47146
+ this._payload = { ...this._payload, iat: validateInput("setIssuedAt", input2) };
46859
47147
  }
46860
47148
  return this;
46861
47149
  }
46862
47150
  };
46863
47151
 
46864
- // ../node_modules/jose/dist/browser/jwt/sign.js
47152
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/jwt/sign.js
46865
47153
  var SignJWT = class extends ProduceJWT {
46866
47154
  setProtectedHeader(protectedHeader) {
46867
47155
  this._protectedHeader = protectedHeader;
46868
47156
  return this;
46869
47157
  }
46870
47158
  async sign(key3, options) {
46871
- var _a;
46872
47159
  const sig = new CompactSign(encoder.encode(JSON.stringify(this._payload)));
46873
47160
  sig.setProtectedHeader(this._protectedHeader);
46874
- if (Array.isArray((_a = this._protectedHeader) === null || _a === void 0 ? void 0 : _a.crit) && this._protectedHeader.crit.includes("b64") && this._protectedHeader.b64 === false) {
47161
+ if (Array.isArray(this._protectedHeader?.crit) && this._protectedHeader.crit.includes("b64") && this._protectedHeader.b64 === false) {
46875
47162
  throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
46876
47163
  }
46877
47164
  return sig.sign(key3, options);
46878
47165
  }
46879
47166
  };
46880
47167
 
46881
- // ../node_modules/jose/dist/browser/runtime/generate.js
47168
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/jwks/local.js
47169
+ function getKtyFromAlg(alg) {
47170
+ switch (typeof alg === "string" && alg.slice(0, 2)) {
47171
+ case "RS":
47172
+ case "PS":
47173
+ return "RSA";
47174
+ case "ES":
47175
+ return "EC";
47176
+ case "Ed":
47177
+ return "OKP";
47178
+ default:
47179
+ throw new JOSENotSupported('Unsupported "alg" value for a JSON Web Key Set');
47180
+ }
47181
+ }
47182
+ function isJWKSLike(jwks) {
47183
+ return jwks && typeof jwks === "object" && Array.isArray(jwks.keys) && jwks.keys.every(isJWKLike);
47184
+ }
47185
+ function isJWKLike(key3) {
47186
+ return isObject(key3);
47187
+ }
47188
+ function clone(obj) {
47189
+ if (typeof structuredClone === "function") {
47190
+ return structuredClone(obj);
47191
+ }
47192
+ return JSON.parse(JSON.stringify(obj));
47193
+ }
47194
+ var LocalJWKSet = class {
47195
+ constructor(jwks) {
47196
+ this._cached = /* @__PURE__ */ new WeakMap();
47197
+ if (!isJWKSLike(jwks)) {
47198
+ throw new JWKSInvalid("JSON Web Key Set malformed");
47199
+ }
47200
+ this._jwks = clone(jwks);
47201
+ }
47202
+ async getKey(protectedHeader, token) {
47203
+ const { alg, kid } = { ...protectedHeader, ...token?.header };
47204
+ const kty = getKtyFromAlg(alg);
47205
+ const candidates = this._jwks.keys.filter((jwk2) => {
47206
+ let candidate4 = kty === jwk2.kty;
47207
+ if (candidate4 && typeof kid === "string") {
47208
+ candidate4 = kid === jwk2.kid;
47209
+ }
47210
+ if (candidate4 && typeof jwk2.alg === "string") {
47211
+ candidate4 = alg === jwk2.alg;
47212
+ }
47213
+ if (candidate4 && typeof jwk2.use === "string") {
47214
+ candidate4 = jwk2.use === "sig";
47215
+ }
47216
+ if (candidate4 && Array.isArray(jwk2.key_ops)) {
47217
+ candidate4 = jwk2.key_ops.includes("verify");
47218
+ }
47219
+ if (candidate4 && alg === "EdDSA") {
47220
+ candidate4 = jwk2.crv === "Ed25519" || jwk2.crv === "Ed448";
47221
+ }
47222
+ if (candidate4) {
47223
+ switch (alg) {
47224
+ case "ES256":
47225
+ candidate4 = jwk2.crv === "P-256";
47226
+ break;
47227
+ case "ES256K":
47228
+ candidate4 = jwk2.crv === "secp256k1";
47229
+ break;
47230
+ case "ES384":
47231
+ candidate4 = jwk2.crv === "P-384";
47232
+ break;
47233
+ case "ES512":
47234
+ candidate4 = jwk2.crv === "P-521";
47235
+ break;
47236
+ }
47237
+ }
47238
+ return candidate4;
47239
+ });
47240
+ const { 0: jwk, length: length2 } = candidates;
47241
+ if (length2 === 0) {
47242
+ throw new JWKSNoMatchingKey();
47243
+ }
47244
+ if (length2 !== 1) {
47245
+ const error5 = new JWKSMultipleMatchingKeys();
47246
+ const { _cached } = this;
47247
+ error5[Symbol.asyncIterator] = async function* () {
47248
+ for (const jwk2 of candidates) {
47249
+ try {
47250
+ yield await importWithAlgCache(_cached, jwk2, alg);
47251
+ } catch {
47252
+ }
47253
+ }
47254
+ };
47255
+ throw error5;
47256
+ }
47257
+ return importWithAlgCache(this._cached, jwk, alg);
47258
+ }
47259
+ };
47260
+ async function importWithAlgCache(cache, jwk, alg) {
47261
+ const cached = cache.get(jwk) || cache.set(jwk, {}).get(jwk);
47262
+ if (cached[alg] === void 0) {
47263
+ const key3 = await importJWK({ ...jwk, ext: true }, alg);
47264
+ if (key3 instanceof Uint8Array || key3.type !== "public") {
47265
+ throw new JWKSInvalid("JSON Web Key Set members must be public keys");
47266
+ }
47267
+ cached[alg] = key3;
47268
+ }
47269
+ return cached[alg];
47270
+ }
47271
+ function createLocalJWKSet(jwks) {
47272
+ const set = new LocalJWKSet(jwks);
47273
+ const localJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);
47274
+ Object.defineProperties(localJWKSet, {
47275
+ jwks: {
47276
+ value: () => clone(set._jwks),
47277
+ enumerable: true,
47278
+ configurable: false,
47279
+ writable: false
47280
+ }
47281
+ });
47282
+ return localJWKSet;
47283
+ }
47284
+
47285
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/runtime/fetch_jwks.js
47286
+ var fetchJwks = async (url7, timeout2, options) => {
47287
+ let controller2;
47288
+ let id6;
47289
+ let timedOut = false;
47290
+ if (typeof AbortController === "function") {
47291
+ controller2 = new AbortController();
47292
+ id6 = setTimeout(() => {
47293
+ timedOut = true;
47294
+ controller2.abort();
47295
+ }, timeout2);
47296
+ }
47297
+ const response6 = await fetch(url7.href, {
47298
+ signal: controller2 ? controller2.signal : void 0,
47299
+ redirect: "manual",
47300
+ headers: options.headers
47301
+ }).catch((err) => {
47302
+ if (timedOut)
47303
+ throw new JWKSTimeout();
47304
+ throw err;
47305
+ });
47306
+ if (id6 !== void 0)
47307
+ clearTimeout(id6);
47308
+ if (response6.status !== 200) {
47309
+ throw new JOSEError("Expected 200 OK from the JSON Web Key Set HTTP response");
47310
+ }
47311
+ try {
47312
+ return await response6.json();
47313
+ } catch {
47314
+ throw new JOSEError("Failed to parse the JSON Web Key Set HTTP response as JSON");
47315
+ }
47316
+ };
47317
+ var fetch_jwks_default = fetchJwks;
47318
+
47319
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/jwks/remote.js
47320
+ function isCloudflareWorkers() {
47321
+ return typeof WebSocketPair !== "undefined" || typeof navigator !== "undefined" && navigator.userAgent === "Cloudflare-Workers" || typeof EdgeRuntime !== "undefined" && EdgeRuntime === "vercel";
47322
+ }
47323
+ var USER_AGENT;
47324
+ if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) {
47325
+ const NAME = "jose";
47326
+ const VERSION = "v5.9.3";
47327
+ USER_AGENT = `${NAME}/${VERSION}`;
47328
+ }
47329
+ var jwksCache = Symbol();
47330
+ function isFreshJwksCache(input2, cacheMaxAge) {
47331
+ if (typeof input2 !== "object" || input2 === null) {
47332
+ return false;
47333
+ }
47334
+ if (!("uat" in input2) || typeof input2.uat !== "number" || Date.now() - input2.uat >= cacheMaxAge) {
47335
+ return false;
47336
+ }
47337
+ if (!("jwks" in input2) || !isObject(input2.jwks) || !Array.isArray(input2.jwks.keys) || !Array.prototype.every.call(input2.jwks.keys, isObject)) {
47338
+ return false;
47339
+ }
47340
+ return true;
47341
+ }
47342
+ var RemoteJWKSet = class {
47343
+ constructor(url7, options) {
47344
+ if (!(url7 instanceof URL)) {
47345
+ throw new TypeError("url must be an instance of URL");
47346
+ }
47347
+ this._url = new URL(url7.href);
47348
+ this._options = { agent: options?.agent, headers: options?.headers };
47349
+ this._timeoutDuration = typeof options?.timeoutDuration === "number" ? options?.timeoutDuration : 5e3;
47350
+ this._cooldownDuration = typeof options?.cooldownDuration === "number" ? options?.cooldownDuration : 3e4;
47351
+ this._cacheMaxAge = typeof options?.cacheMaxAge === "number" ? options?.cacheMaxAge : 6e5;
47352
+ if (options?.[jwksCache] !== void 0) {
47353
+ this._cache = options?.[jwksCache];
47354
+ if (isFreshJwksCache(options?.[jwksCache], this._cacheMaxAge)) {
47355
+ this._jwksTimestamp = this._cache.uat;
47356
+ this._local = createLocalJWKSet(this._cache.jwks);
47357
+ }
47358
+ }
47359
+ }
47360
+ coolingDown() {
47361
+ return typeof this._jwksTimestamp === "number" ? Date.now() < this._jwksTimestamp + this._cooldownDuration : false;
47362
+ }
47363
+ fresh() {
47364
+ return typeof this._jwksTimestamp === "number" ? Date.now() < this._jwksTimestamp + this._cacheMaxAge : false;
47365
+ }
47366
+ async getKey(protectedHeader, token) {
47367
+ if (!this._local || !this.fresh()) {
47368
+ await this.reload();
47369
+ }
47370
+ try {
47371
+ return await this._local(protectedHeader, token);
47372
+ } catch (err) {
47373
+ if (err instanceof JWKSNoMatchingKey) {
47374
+ if (this.coolingDown() === false) {
47375
+ await this.reload();
47376
+ return this._local(protectedHeader, token);
47377
+ }
47378
+ }
47379
+ throw err;
47380
+ }
47381
+ }
47382
+ async reload() {
47383
+ if (this._pendingFetch && isCloudflareWorkers()) {
47384
+ this._pendingFetch = void 0;
47385
+ }
47386
+ const headers = new Headers(this._options.headers);
47387
+ if (USER_AGENT && !headers.has("User-Agent")) {
47388
+ headers.set("User-Agent", USER_AGENT);
47389
+ this._options.headers = Object.fromEntries(headers.entries());
47390
+ }
47391
+ this._pendingFetch || (this._pendingFetch = fetch_jwks_default(this._url, this._timeoutDuration, this._options).then((json) => {
47392
+ this._local = createLocalJWKSet(json);
47393
+ if (this._cache) {
47394
+ this._cache.uat = Date.now();
47395
+ this._cache.jwks = json;
47396
+ }
47397
+ this._jwksTimestamp = Date.now();
47398
+ this._pendingFetch = void 0;
47399
+ }).catch((err) => {
47400
+ this._pendingFetch = void 0;
47401
+ throw err;
47402
+ }));
47403
+ await this._pendingFetch;
47404
+ }
47405
+ };
47406
+ function createRemoteJWKSet(url7, options) {
47407
+ const set = new RemoteJWKSet(url7, options);
47408
+ const remoteJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);
47409
+ Object.defineProperties(remoteJWKSet, {
47410
+ coolingDown: {
47411
+ get: () => set.coolingDown(),
47412
+ enumerable: true,
47413
+ configurable: false
47414
+ },
47415
+ fresh: {
47416
+ get: () => set.fresh(),
47417
+ enumerable: true,
47418
+ configurable: false
47419
+ },
47420
+ reload: {
47421
+ value: () => set.reload(),
47422
+ enumerable: true,
47423
+ configurable: false,
47424
+ writable: false
47425
+ },
47426
+ reloading: {
47427
+ get: () => !!set._pendingFetch,
47428
+ enumerable: true,
47429
+ configurable: false
47430
+ },
47431
+ jwks: {
47432
+ value: () => set._local?.jwks(),
47433
+ enumerable: true,
47434
+ configurable: false,
47435
+ writable: false
47436
+ }
47437
+ });
47438
+ return remoteJWKSet;
47439
+ }
47440
+
47441
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/runtime/generate.js
46882
47442
  function getModulusLengthOption(options) {
46883
- var _a;
46884
- const modulusLength = (_a = options === null || options === void 0 ? void 0 : options.modulusLength) !== null && _a !== void 0 ? _a : 2048;
47443
+ const modulusLength = options?.modulusLength ?? 2048;
46885
47444
  if (typeof modulusLength !== "number" || modulusLength < 2048) {
46886
47445
  throw new JOSENotSupported("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");
46887
47446
  }
46888
47447
  return modulusLength;
46889
47448
  }
46890
47449
  async function generateKeyPair(alg, options) {
46891
- var _a, _b, _c;
46892
47450
  let algorithm3;
46893
47451
  let keyUsages;
46894
47452
  switch (alg) {
@@ -46938,9 +47496,9 @@ var PodOS = (() => {
46938
47496
  algorithm3 = { name: "ECDSA", namedCurve: "P-521" };
46939
47497
  keyUsages = ["sign", "verify"];
46940
47498
  break;
46941
- case "EdDSA":
47499
+ case "EdDSA": {
46942
47500
  keyUsages = ["sign", "verify"];
46943
- const crv = (_a = options === null || options === void 0 ? void 0 : options.crv) !== null && _a !== void 0 ? _a : "Ed25519";
47501
+ const crv = options?.crv ?? "Ed25519";
46944
47502
  switch (crv) {
46945
47503
  case "Ed25519":
46946
47504
  case "Ed448":
@@ -46950,22 +47508,23 @@ var PodOS = (() => {
46950
47508
  throw new JOSENotSupported("Invalid or unsupported crv option provided");
46951
47509
  }
46952
47510
  break;
47511
+ }
46953
47512
  case "ECDH-ES":
46954
47513
  case "ECDH-ES+A128KW":
46955
47514
  case "ECDH-ES+A192KW":
46956
47515
  case "ECDH-ES+A256KW": {
46957
47516
  keyUsages = ["deriveKey", "deriveBits"];
46958
- const crv2 = (_b = options === null || options === void 0 ? void 0 : options.crv) !== null && _b !== void 0 ? _b : "P-256";
46959
- switch (crv2) {
47517
+ const crv = options?.crv ?? "P-256";
47518
+ switch (crv) {
46960
47519
  case "P-256":
46961
47520
  case "P-384":
46962
47521
  case "P-521": {
46963
- algorithm3 = { name: "ECDH", namedCurve: crv2 };
47522
+ algorithm3 = { name: "ECDH", namedCurve: crv };
46964
47523
  break;
46965
47524
  }
46966
47525
  case "X25519":
46967
47526
  case "X448":
46968
- algorithm3 = { name: crv2 };
47527
+ algorithm3 = { name: crv };
46969
47528
  break;
46970
47529
  default:
46971
47530
  throw new JOSENotSupported("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, X25519, and X448");
@@ -46975,15 +47534,25 @@ var PodOS = (() => {
46975
47534
  default:
46976
47535
  throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
46977
47536
  }
46978
- return webcrypto_default.subtle.generateKey(algorithm3, (_c = options === null || options === void 0 ? void 0 : options.extractable) !== null && _c !== void 0 ? _c : false, keyUsages);
47537
+ return webcrypto_default.subtle.generateKey(algorithm3, options?.extractable ?? false, keyUsages);
46979
47538
  }
46980
47539
 
46981
- // ../node_modules/jose/dist/browser/key/generate_key_pair.js
47540
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/key/generate_key_pair.js
46982
47541
  async function generateKeyPair2(alg, options) {
46983
47542
  return generateKeyPair(alg, options);
46984
47543
  }
46985
47544
 
46986
- // ../node_modules/uuid/dist/esm-browser/rng.js
47545
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/uuid/dist/esm-browser/stringify.js
47546
+ var byteToHex = [];
47547
+ for (i = 0; i < 256; ++i) {
47548
+ byteToHex.push((i + 256).toString(16).slice(1));
47549
+ }
47550
+ var i;
47551
+ function unsafeStringify(arr, offset3 = 0) {
47552
+ 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();
47553
+ }
47554
+
47555
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/uuid/dist/esm-browser/rng.js
46987
47556
  var getRandomValues;
46988
47557
  var rnds8 = new Uint8Array(16);
46989
47558
  function rng() {
@@ -46996,33 +47565,24 @@ var PodOS = (() => {
46996
47565
  return getRandomValues(rnds8);
46997
47566
  }
46998
47567
 
46999
- // ../node_modules/uuid/dist/esm-browser/stringify.js
47000
- var byteToHex = [];
47001
- for (let i = 0; i < 256; ++i) {
47002
- byteToHex.push((i + 256).toString(16).slice(1));
47003
- }
47004
- function unsafeStringify(arr, offset3 = 0) {
47005
- 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]];
47006
- }
47007
-
47008
- // ../node_modules/uuid/dist/esm-browser/native.js
47568
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/uuid/dist/esm-browser/native.js
47009
47569
  var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
47010
47570
  var native_default = {
47011
47571
  randomUUID
47012
47572
  };
47013
47573
 
47014
- // ../node_modules/uuid/dist/esm-browser/v4.js
47574
+ // ../node_modules/@inrupt/solid-client-authn-core/node_modules/uuid/dist/esm-browser/v4.js
47015
47575
  function v4(options, buf, offset3) {
47016
47576
  if (native_default.randomUUID && !buf && !options) {
47017
47577
  return native_default.randomUUID();
47018
47578
  }
47019
47579
  options = options || {};
47020
- const rnds = options.random || (options.rng || rng)();
47580
+ var rnds = options.random || (options.rng || rng)();
47021
47581
  rnds[6] = rnds[6] & 15 | 64;
47022
47582
  rnds[8] = rnds[8] & 63 | 128;
47023
47583
  if (buf) {
47024
47584
  offset3 = offset3 || 0;
47025
- for (let i = 0; i < 16; ++i) {
47585
+ for (var i = 0; i < 16; ++i) {
47026
47586
  buf[offset3 + i] = rnds[i];
47027
47587
  }
47028
47588
  return buf;
@@ -47050,17 +47610,6 @@ var PodOS = (() => {
47050
47610
  var SCOPE_OFFLINE = "offline_access";
47051
47611
  var SCOPE_WEBID = "webid";
47052
47612
  var DEFAULT_SCOPES = [SCOPE_OPENID, SCOPE_OFFLINE, SCOPE_WEBID].join(" ");
47053
- var buildProxyHandler = (toExclude, errorMessage) => ({
47054
- // This proxy is only a temporary measure until Session no longer extends
47055
- // SessionEventEmitter, and the proxying is no longer necessary.
47056
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
47057
- get(target5, prop, receiver2) {
47058
- if (!Object.getOwnPropertyNames(import_events.EventEmitter).includes(prop) && Object.getOwnPropertyNames(toExclude).includes(prop)) {
47059
- throw new Error(`${errorMessage}: [${prop}] is not supported`);
47060
- }
47061
- return Reflect.get(target5, prop, receiver2);
47062
- }
47063
- });
47064
47613
  var AggregateHandler = class {
47065
47614
  constructor(handleables) {
47066
47615
  this.handleables = handleables;
@@ -47097,24 +47646,11 @@ var PodOS = (() => {
47097
47646
  }).join(", ")}`);
47098
47647
  }
47099
47648
  };
47100
- async function fetchJwks(jwksIri, issuerIri) {
47101
- const jwksResponse = await fetch2.call(globalThis, jwksIri);
47102
- if (jwksResponse.status !== 200) {
47103
- throw new Error(`Could not fetch JWKS for [${issuerIri}] at [${jwksIri}]: ${jwksResponse.status} ${jwksResponse.statusText}`);
47104
- }
47105
- let jwk;
47106
- try {
47107
- jwk = (await jwksResponse.json()).keys[0];
47108
- } catch (e) {
47109
- throw new Error(`Malformed JWKS for [${issuerIri}] at [${jwksIri}]: ${e.message}`);
47110
- }
47111
- return jwk;
47112
- }
47113
47649
  async function getWebidFromTokenPayload(idToken, jwksIri, issuerIri, clientId) {
47114
- const jwk = await fetchJwks(jwksIri, issuerIri);
47115
47650
  let payload4;
47651
+ let clientIdInPayload;
47116
47652
  try {
47117
- const { payload: verifiedPayload } = await jwtVerify(idToken, await importJWK(jwk), {
47653
+ const { payload: verifiedPayload } = await jwtVerify(idToken, createRemoteJWKSet(new URL(jwksIri)), {
47118
47654
  issuer: issuerIri,
47119
47655
  audience: clientId
47120
47656
  });
@@ -47122,15 +47658,24 @@ var PodOS = (() => {
47122
47658
  } catch (e) {
47123
47659
  throw new Error(`Token verification failed: ${e.stack}`);
47124
47660
  }
47661
+ if (typeof payload4.azp === "string") {
47662
+ clientIdInPayload = payload4.azp;
47663
+ }
47125
47664
  if (typeof payload4.webid === "string") {
47126
- return payload4.webid;
47665
+ return {
47666
+ webId: payload4.webid,
47667
+ clientId: clientIdInPayload
47668
+ };
47127
47669
  }
47128
47670
  if (typeof payload4.sub !== "string") {
47129
47671
  throw new Error(`The token ${JSON.stringify(payload4)} is invalid: it has no 'webid' claim and no 'sub' claim.`);
47130
47672
  }
47131
47673
  try {
47132
47674
  new URL(payload4.sub);
47133
- return payload4.sub;
47675
+ return {
47676
+ webId: payload4.sub,
47677
+ clientId: clientIdInPayload
47678
+ };
47134
47679
  } catch (e) {
47135
47680
  throw new Error(`The token has no 'webid' claim, and its 'sub' claim of [${payload4.sub}] is invalid as a URL - error [${e}].`);
47136
47681
  }
@@ -47154,17 +47699,29 @@ var PodOS = (() => {
47154
47699
  cleanedUpUrl.searchParams.delete("iss");
47155
47700
  return cleanedUpUrl;
47156
47701
  }
47702
+ function booleanWithFallback(value6, fallback) {
47703
+ if (typeof value6 === "boolean") {
47704
+ return Boolean(value6);
47705
+ }
47706
+ return Boolean(fallback);
47707
+ }
47157
47708
  var AuthorizationCodeWithPkceOidcHandlerBase = class {
47158
47709
  constructor(storageUtility, redirector) {
47159
47710
  this.storageUtility = storageUtility;
47160
47711
  this.redirector = redirector;
47712
+ this.parametersGuard = (oidcLoginOptions) => {
47713
+ return oidcLoginOptions.issuerConfiguration.grantTypesSupported !== void 0 && oidcLoginOptions.issuerConfiguration.grantTypesSupported.indexOf("authorization_code") > -1 && oidcLoginOptions.redirectUrl !== void 0;
47714
+ };
47161
47715
  this.storageUtility = storageUtility;
47162
47716
  this.redirector = redirector;
47163
47717
  }
47164
47718
  async canHandle(oidcLoginOptions) {
47165
- return !!(oidcLoginOptions.issuerConfiguration.grantTypesSupported && oidcLoginOptions.issuerConfiguration.grantTypesSupported.indexOf("authorization_code") > -1);
47719
+ return this.parametersGuard(oidcLoginOptions);
47166
47720
  }
47167
47721
  async handleRedirect({ oidcLoginOptions, state: state2, codeVerifier, targetUrl: targetUrl3 }) {
47722
+ if (!this.parametersGuard(oidcLoginOptions)) {
47723
+ throw new Error("The authorization code grant requires a redirectUrl.");
47724
+ }
47168
47725
  await Promise.all([
47169
47726
  // We use the OAuth 'state' value (which should be crypto-random) as
47170
47727
  // the key in our storage to store our actual SessionID. We do this
@@ -47175,7 +47732,6 @@ var PodOS = (() => {
47175
47732
  // that session ID can be any developer-specified value, and therefore
47176
47733
  // may not be appropriate (since the OAuth 'state' value should really
47177
47734
  // be an unguessable crypto-random value).
47178
- // eslint-disable-next-line no-underscore-dangle
47179
47735
  this.storageUtility.setForUser(state2, {
47180
47736
  sessionId: oidcLoginOptions.sessionId
47181
47737
  }),
@@ -47184,12 +47740,12 @@ var PodOS = (() => {
47184
47740
  // our session ID is unnecessary, but it provides a slightly cleaner
47185
47741
  // separation of concerns.
47186
47742
  this.storageUtility.setForUser(oidcLoginOptions.sessionId, {
47187
- // eslint-disable-next-line no-underscore-dangle
47188
47743
  codeVerifier,
47189
47744
  issuer: oidcLoginOptions.issuer.toString(),
47190
47745
  // The redirect URL is read after redirect, so it must be stored now.
47191
47746
  redirectUrl: oidcLoginOptions.redirectUrl,
47192
- dpop: oidcLoginOptions.dpop ? "true" : "false"
47747
+ dpop: Boolean(oidcLoginOptions.dpop).toString(),
47748
+ keepAlive: booleanWithFallback(oidcLoginOptions.keepAlive, true).toString()
47193
47749
  })
47194
47750
  ]);
47195
47751
  this.redirector.redirect(targetUrl3, {
@@ -47251,7 +47807,7 @@ var PodOS = (() => {
47251
47807
  return {
47252
47808
  isLoggedIn: false,
47253
47809
  sessionId: v4_default(),
47254
- fetch: (...args) => fetch2.call(globalThis, ...args)
47810
+ fetch: (...args) => fetch(...args)
47255
47811
  };
47256
47812
  }
47257
47813
  async function clear(sessionId, storage2) {
@@ -47345,48 +47901,51 @@ var PodOS = (() => {
47345
47901
  return supported.includes(signingAlg);
47346
47902
  })) !== null && _a !== void 0 ? _a : null;
47347
47903
  }
47348
- function determineClientType(options, issuerConfig) {
47349
- if (options.clientId !== void 0 && !isValidUrl(options.clientId)) {
47350
- return "static";
47351
- }
47352
- if (issuerConfig.scopesSupported.includes("webid") && options.clientId !== void 0 && isValidUrl(options.clientId)) {
47353
- return "solid-oidc";
47354
- }
47355
- return "dynamic";
47904
+ function isStaticClient(options) {
47905
+ return options.clientId !== void 0 && !isValidUrl(options.clientId);
47906
+ }
47907
+ function isSolidOidcClient(options, issuerConfig) {
47908
+ return issuerConfig.scopesSupported.includes("webid") && options.clientId !== void 0 && isValidUrl(options.clientId);
47909
+ }
47910
+ function isKnownClientType(clientType) {
47911
+ return typeof clientType === "string" && ["dynamic", "static", "solid-oidc"].includes(clientType);
47356
47912
  }
47357
47913
  async function handleRegistration(options, issuerConfig, storageUtility, clientRegistrar) {
47358
- const clientType = determineClientType(options, issuerConfig);
47359
- if (clientType === "dynamic") {
47914
+ let clientInfo;
47915
+ if (isSolidOidcClient(options, issuerConfig)) {
47916
+ clientInfo = {
47917
+ clientId: options.clientId,
47918
+ clientName: options.clientName,
47919
+ clientType: "solid-oidc"
47920
+ };
47921
+ } else if (isStaticClient(options)) {
47922
+ clientInfo = {
47923
+ clientId: options.clientId,
47924
+ clientSecret: options.clientSecret,
47925
+ clientName: options.clientName,
47926
+ clientType: "static"
47927
+ };
47928
+ } else {
47360
47929
  return clientRegistrar.getClient({
47361
47930
  sessionId: options.sessionId,
47362
47931
  clientName: options.clientName,
47363
47932
  redirectUrl: options.redirectUrl
47364
47933
  }, issuerConfig);
47365
47934
  }
47366
- await storageUtility.setForUser(options.sessionId, {
47367
- // If the client is either static or solid-oidc compliant, its client ID cannot be undefined.
47368
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
47369
- clientId: options.clientId
47370
- });
47371
- if (options.clientSecret) {
47372
- await storageUtility.setForUser(options.sessionId, {
47373
- clientSecret: options.clientSecret
47374
- });
47935
+ const infoToSave = {
47936
+ clientId: clientInfo.clientId,
47937
+ clientType: clientInfo.clientType
47938
+ };
47939
+ if (clientInfo.clientType === "static") {
47940
+ infoToSave.clientSecret = clientInfo.clientSecret;
47375
47941
  }
47376
- if (options.clientName) {
47377
- await storageUtility.setForUser(options.sessionId, {
47378
- clientName: options.clientName
47379
- });
47942
+ if (clientInfo.clientName) {
47943
+ infoToSave.clientName = clientInfo.clientName;
47380
47944
  }
47381
- return {
47382
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
47383
- clientId: options.clientId,
47384
- clientSecret: options.clientSecret,
47385
- clientName: options.clientName,
47386
- clientType
47387
- };
47945
+ await storageUtility.setForUser(options.sessionId, infoToSave);
47946
+ return clientInfo;
47388
47947
  }
47389
- var globalFetch = (request2, init) => fetch2.call(globalThis, request2, init);
47948
+ var boundFetch = (request2, init) => fetch(request2, init);
47390
47949
  var ClientAuthentication = class {
47391
47950
  constructor(loginHandler, redirectHandler, logoutHandler, sessionInfoManager, issuerConfigFetcher) {
47392
47951
  this.loginHandler = loginHandler;
@@ -47394,13 +47953,13 @@ var PodOS = (() => {
47394
47953
  this.logoutHandler = logoutHandler;
47395
47954
  this.sessionInfoManager = sessionInfoManager;
47396
47955
  this.issuerConfigFetcher = issuerConfigFetcher;
47397
- this.fetch = globalFetch;
47956
+ this.fetch = boundFetch;
47398
47957
  this.logout = async (sessionId, options) => {
47399
47958
  await this.logoutHandler.handle(sessionId, (options === null || options === void 0 ? void 0 : options.logoutType) === "idp" ? {
47400
47959
  ...options,
47401
47960
  toLogoutUrl: this.boundLogout
47402
47961
  } : options);
47403
- this.fetch = globalFetch;
47962
+ this.fetch = boundFetch;
47404
47963
  delete this.boundLogout;
47405
47964
  };
47406
47965
  this.getSessionInfo = async (sessionId) => {
@@ -47418,13 +47977,14 @@ var PodOS = (() => {
47418
47977
  };
47419
47978
  async function loadOidcContextFromStorage(sessionId, storageUtility, configFetcher) {
47420
47979
  try {
47421
- const [issuerIri, codeVerifier, storedRedirectIri, dpop] = await Promise.all([
47980
+ const [issuerIri, codeVerifier, storedRedirectIri, dpop, keepAlive] = await Promise.all([
47422
47981
  storageUtility.getForUser(sessionId, "issuer", {
47423
47982
  errorIfNull: true
47424
47983
  }),
47425
47984
  storageUtility.getForUser(sessionId, "codeVerifier"),
47426
47985
  storageUtility.getForUser(sessionId, "redirectUrl"),
47427
- storageUtility.getForUser(sessionId, "dpop", { errorIfNull: true })
47986
+ storageUtility.getForUser(sessionId, "dpop", { errorIfNull: true }),
47987
+ storageUtility.getForUser(sessionId, "keepAlive")
47428
47988
  ]);
47429
47989
  await storageUtility.deleteForUser(sessionId, "codeVerifier");
47430
47990
  const issuerConfig = await configFetcher.fetchConfig(issuerIri);
@@ -47432,12 +47992,34 @@ var PodOS = (() => {
47432
47992
  codeVerifier,
47433
47993
  redirectUrl: storedRedirectIri,
47434
47994
  issuerConfig,
47435
- dpop: dpop === "true"
47995
+ dpop: dpop === "true",
47996
+ // Default keepAlive to true if not found in storage.
47997
+ keepAlive: typeof keepAlive === "string" ? keepAlive === "true" : true
47436
47998
  };
47437
47999
  } catch (e) {
47438
48000
  throw new Error(`Failed to retrieve OIDC context from storage associated with session [${sessionId}]: ${e}`);
47439
48001
  }
47440
48002
  }
48003
+ async function saveSessionInfoToStorage(storageUtility, sessionId, webId, clientId, isLoggedIn2, refreshToken, secure, dpopKey) {
48004
+ if (refreshToken !== void 0) {
48005
+ await storageUtility.setForUser(sessionId, { refreshToken }, { secure });
48006
+ }
48007
+ if (webId !== void 0) {
48008
+ await storageUtility.setForUser(sessionId, { webId }, { secure });
48009
+ }
48010
+ if (clientId !== void 0) {
48011
+ await storageUtility.setForUser(sessionId, { clientId }, { secure });
48012
+ }
48013
+ if (isLoggedIn2 !== void 0) {
48014
+ await storageUtility.setForUser(sessionId, { isLoggedIn: isLoggedIn2 }, { secure });
48015
+ }
48016
+ if (dpopKey !== void 0) {
48017
+ await storageUtility.setForUser(sessionId, {
48018
+ publicKey: JSON.stringify(dpopKey.publicKey),
48019
+ privateKey: JSON.stringify(await exportJWK(dpopKey.privateKey))
48020
+ }, { secure });
48021
+ }
48022
+ }
47441
48023
  var StorageUtility = class {
47442
48024
  constructor(secureStorage, insecureStorage) {
47443
48025
  this.secureStorage = secureStorage;
@@ -47589,8 +48171,8 @@ var PodOS = (() => {
47589
48171
  headers
47590
48172
  };
47591
48173
  }
47592
- async function makeAuthenticatedRequest(unauthFetch, accessToken, url7, defaultRequestInit, dpopKey) {
47593
- return unauthFetch(url7, await buildAuthenticatedHeaders(url7.toString(), accessToken, dpopKey, defaultRequestInit));
48174
+ async function makeAuthenticatedRequest(accessToken, url7, defaultRequestInit, dpopKey) {
48175
+ return fetch(url7, await buildAuthenticatedHeaders(url7.toString(), accessToken, dpopKey, defaultRequestInit));
47594
48176
  }
47595
48177
  async function refreshAccessToken(refreshOptions, dpopKey, eventEmitter) {
47596
48178
  var _a;
@@ -47614,7 +48196,7 @@ var PodOS = (() => {
47614
48196
  }
47615
48197
  return DEFAULT_EXPIRATION_TIME_SECONDS;
47616
48198
  };
47617
- async function buildAuthenticatedFetch(unauthFetch, accessToken, options) {
48199
+ async function buildAuthenticatedFetch(accessToken, options) {
47618
48200
  var _a;
47619
48201
  let currentAccessToken = accessToken;
47620
48202
  let latestTimeout;
@@ -47662,7 +48244,7 @@ var PodOS = (() => {
47662
48244
  options.eventEmitter.emit(EVENTS.TIMEOUT_SET, expirationTimeout);
47663
48245
  }
47664
48246
  return async (url7, requestInit) => {
47665
- let response6 = await makeAuthenticatedRequest(unauthFetch, currentAccessToken, url7, requestInit, options === null || options === void 0 ? void 0 : options.dpopKey);
48247
+ let response6 = await makeAuthenticatedRequest(currentAccessToken, url7, requestInit, options === null || options === void 0 ? void 0 : options.dpopKey);
47666
48248
  const failedButNotExpectedAuthError = !response6.ok && !isExpectedAuthError(response6.status);
47667
48249
  if (response6.ok || failedButNotExpectedAuthError) {
47668
48250
  return response6;
@@ -47670,7 +48252,6 @@ var PodOS = (() => {
47670
48252
  const hasBeenRedirected = response6.url !== url7;
47671
48253
  if (hasBeenRedirected && (options === null || options === void 0 ? void 0 : options.dpopKey) !== void 0) {
47672
48254
  response6 = await makeAuthenticatedRequest(
47673
- unauthFetch,
47674
48255
  currentAccessToken,
47675
48256
  // Replace the original target IRI (`url`) by the redirection target
47676
48257
  response6.url,
@@ -47682,8 +48263,57 @@ var PodOS = (() => {
47682
48263
  };
47683
48264
  }
47684
48265
 
48266
+ // ../node_modules/@inrupt/solid-client-authn-browser/node_modules/uuid/dist/esm-browser/stringify.js
48267
+ var byteToHex2 = [];
48268
+ for (i = 0; i < 256; ++i) {
48269
+ byteToHex2.push((i + 256).toString(16).slice(1));
48270
+ }
48271
+ var i;
48272
+ function unsafeStringify2(arr, offset3 = 0) {
48273
+ 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();
48274
+ }
48275
+
48276
+ // ../node_modules/@inrupt/solid-client-authn-browser/node_modules/uuid/dist/esm-browser/rng.js
48277
+ var getRandomValues2;
48278
+ var rnds82 = new Uint8Array(16);
48279
+ function rng2() {
48280
+ if (!getRandomValues2) {
48281
+ getRandomValues2 = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
48282
+ if (!getRandomValues2) {
48283
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
48284
+ }
48285
+ }
48286
+ return getRandomValues2(rnds82);
48287
+ }
48288
+
48289
+ // ../node_modules/@inrupt/solid-client-authn-browser/node_modules/uuid/dist/esm-browser/native.js
48290
+ var randomUUID2 = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
48291
+ var native_default2 = {
48292
+ randomUUID: randomUUID2
48293
+ };
48294
+
48295
+ // ../node_modules/@inrupt/solid-client-authn-browser/node_modules/uuid/dist/esm-browser/v4.js
48296
+ function v42(options, buf, offset3) {
48297
+ if (native_default2.randomUUID && !buf && !options) {
48298
+ return native_default2.randomUUID();
48299
+ }
48300
+ options = options || {};
48301
+ var rnds = options.random || (options.rng || rng2)();
48302
+ rnds[6] = rnds[6] & 15 | 64;
48303
+ rnds[8] = rnds[8] & 63 | 128;
48304
+ if (buf) {
48305
+ offset3 = offset3 || 0;
48306
+ for (var i = 0; i < 16; ++i) {
48307
+ buf[offset3 + i] = rnds[i];
48308
+ }
48309
+ return buf;
48310
+ }
48311
+ return unsafeStringify2(rnds);
48312
+ }
48313
+ var v4_default2 = v42;
48314
+
47685
48315
  // ../node_modules/@inrupt/solid-client-authn-browser/dist/index.mjs
47686
- var import_events2 = __toESM(require_events(), 1);
48316
+ var import_events = __toESM(require_events(), 1);
47687
48317
 
47688
48318
  // ../node_modules/@inrupt/oidc-client-ext/dist/index.es.js
47689
48319
  var import_oidc_client = __toESM(require_oidc_client_min());
@@ -47831,79 +48461,20 @@ var PodOS = (() => {
47831
48461
  headers,
47832
48462
  body: new URLSearchParams(requestBody).toString()
47833
48463
  };
47834
- const rawTokenResponse = await fetch2(issuer2.tokenEndpoint, tokenRequestInit);
48464
+ const rawTokenResponse = await fetch(issuer2.tokenEndpoint, tokenRequestInit);
47835
48465
  const jsonTokenResponse = await rawTokenResponse.json();
47836
48466
  const tokenResponse = validateTokenEndpointResponse(jsonTokenResponse, dpop);
47837
- const webId = await getWebidFromTokenPayload(tokenResponse.id_token, issuer2.jwksUri, issuer2.issuer, client.clientId);
48467
+ const { webId, clientId } = await getWebidFromTokenPayload(tokenResponse.id_token, issuer2.jwksUri, issuer2.issuer, client.clientId);
47838
48468
  return {
47839
48469
  accessToken: tokenResponse.access_token,
47840
48470
  idToken: tokenResponse.id_token,
47841
48471
  refreshToken: hasRefreshToken(tokenResponse) ? tokenResponse.refresh_token : void 0,
47842
48472
  webId,
48473
+ clientId,
47843
48474
  dpopKey,
47844
48475
  expiresIn: tokenResponse.expires_in
47845
48476
  };
47846
48477
  }
47847
- async function getBearerToken(redirectUrl) {
47848
- let signinResponse;
47849
- try {
47850
- const client = new import_oidc_client.OidcClient({
47851
- // TODO: We should look at the various interfaces being used for storage,
47852
- // i.e. between oidc-client-js (WebStorageStoreState), localStorage
47853
- // (which has an interface Storage), and our own proprietary interface
47854
- // IStorage - i.e. we should really just be using the browser Web Storage
47855
- // API, e.g. "stateStore: window.localStorage,".
47856
- // We are instantiating a new instance here, so the only value we need to
47857
- // explicitly provide is the response mode (default otherwise will look
47858
- // for a hash '#' fragment!).
47859
- // eslint-disable-next-line camelcase
47860
- response_mode: "query",
47861
- // The userinfo endpoint on NSS fails, so disable this for now
47862
- // Note that in Solid, information should be retrieved from the
47863
- // profile referenced by the WebId.
47864
- // TODO: Note that this is heavy-handed, and that this userinfo check
47865
- // verifies that the `sub` claim in the id token you get along with the
47866
- // access token matches the sub claim associated with the access token at
47867
- // the userinfo endpoint.
47868
- // That is a useful check, and in the future it should be only disabled
47869
- // against NSS, and not in general.
47870
- // Issue tracker: https://github.com/solid/node-solid-server/issues/1490
47871
- loadUserInfo: false
47872
- });
47873
- signinResponse = await client.processSigninResponse(redirectUrl);
47874
- if (client.settings.metadata === void 0) {
47875
- throw new Error("Cannot retrieve issuer metadata from client information in storage.");
47876
- }
47877
- if (client.settings.metadata.jwks_uri === void 0) {
47878
- throw new Error("Missing some issuer metadata from client information in storage: 'jwks_uri' is undefined");
47879
- }
47880
- if (client.settings.metadata.issuer === void 0) {
47881
- throw new Error("Missing some issuer metadata from client information in storage: 'issuer' is undefined");
47882
- }
47883
- if (client.settings.client_id === void 0) {
47884
- throw new Error("Missing some client information in storage: 'client_id' is undefined");
47885
- }
47886
- const webId = await getWebidFromTokenPayload(signinResponse.id_token, client.settings.metadata.jwks_uri, client.settings.metadata.issuer, client.settings.client_id);
47887
- return {
47888
- accessToken: signinResponse.access_token,
47889
- idToken: signinResponse.id_token,
47890
- webId,
47891
- // Although not a field in the TypeScript response interface, the refresh
47892
- // token (which can optionally come back with the access token (if, as per
47893
- // the OAuth2 spec, we requested one using the scope of 'offline_access')
47894
- // will be included in the signin response object.
47895
- // eslint-disable-next-line camelcase
47896
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
47897
- // @ts-ignore
47898
- refreshToken: signinResponse.refresh_token
47899
- };
47900
- } catch (err) {
47901
- throw new Error(`Problem handling Auth Code Grant (Flow) redirect - URL [${redirectUrl}]: ${err}`);
47902
- }
47903
- }
47904
- async function getDpopToken(issuer2, client, data2) {
47905
- return getTokens(issuer2, client, data2, true);
47906
- }
47907
48478
  var isValidUrl2 = (url7) => {
47908
48479
  try {
47909
48480
  new URL(url7);
@@ -47937,7 +48508,7 @@ var PodOS = (() => {
47937
48508
  } else if (isValidUrl2(client.clientId)) {
47938
48509
  requestBody.client_id = client.clientId;
47939
48510
  }
47940
- const rawResponse = await fetch2(issuer2.tokenEndpoint, {
48511
+ const rawResponse = await fetch(issuer2.tokenEndpoint, {
47941
48512
  method: "POST",
47942
48513
  body: new URLSearchParams(requestBody).toString(),
47943
48514
  headers: {
@@ -47953,7 +48524,7 @@ var PodOS = (() => {
47953
48524
  throw new Error(`The token endpoint of issuer ${issuer2.issuer} returned a malformed response.`);
47954
48525
  }
47955
48526
  const validatedResponse = validateTokenEndpointResponse(response6, dpopKey !== void 0);
47956
- const webId = await getWebidFromTokenPayload(validatedResponse.id_token, issuer2.jwksUri, issuer2.issuer, client.clientId);
48527
+ const { webId } = await getWebidFromTokenPayload(validatedResponse.id_token, issuer2.jwksUri, issuer2.issuer, client.clientId);
47957
48528
  return {
47958
48529
  accessToken: validatedResponse.access_token,
47959
48530
  idToken: validatedResponse.id_token,
@@ -48035,7 +48606,7 @@ var PodOS = (() => {
48035
48606
  };
48036
48607
  this.handleIncomingRedirect = async (url7, eventEmitter) => {
48037
48608
  try {
48038
- const redirectInfo = await this.redirectHandler.handle(url7, eventEmitter);
48609
+ const redirectInfo = await this.redirectHandler.handle(url7, eventEmitter, void 0);
48039
48610
  this.fetch = redirectInfo.fetch.bind(window);
48040
48611
  this.boundLogout = redirectInfo.getLogoutUrl;
48041
48612
  await this.cleanUrlAfterRedirect(url7);
@@ -48043,7 +48614,8 @@ var PodOS = (() => {
48043
48614
  isLoggedIn: redirectInfo.isLoggedIn,
48044
48615
  webId: redirectInfo.webId,
48045
48616
  sessionId: redirectInfo.sessionId,
48046
- expirationDate: redirectInfo.expirationDate
48617
+ expirationDate: redirectInfo.expirationDate,
48618
+ clientAppId: redirectInfo.clientAppId
48047
48619
  };
48048
48620
  } catch (err) {
48049
48621
  await this.cleanUrlAfterRedirect(url7);
@@ -48114,8 +48686,7 @@ var PodOS = (() => {
48114
48686
  authority: oidcLoginOptions.issuer.toString(),
48115
48687
  client_id: oidcLoginOptions.client.clientId,
48116
48688
  client_secret: oidcLoginOptions.client.clientSecret,
48117
- redirect_uri: oidcLoginOptions.redirectUrl.toString(),
48118
- post_logout_redirect_uri: oidcLoginOptions.redirectUrl.toString(),
48689
+ redirect_uri: oidcLoginOptions.redirectUrl,
48119
48690
  response_type: "code",
48120
48691
  scope: DEFAULT_SCOPES,
48121
48692
  filterProtocolClaims: true,
@@ -48261,7 +48832,7 @@ var PodOS = (() => {
48261
48832
  // includes the full issuer path. See https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig.
48262
48833
  issuer2.endsWith("/") ? issuer2 : `${issuer2}/`
48263
48834
  ).href;
48264
- const issuerConfigRequestBody = await fetch2.call(globalThis, openIdConfigUrl);
48835
+ const issuerConfigRequestBody = await fetch(openIdConfigUrl);
48265
48836
  try {
48266
48837
  issuerConfig = processConfig(await issuerConfigRequestBody.json());
48267
48838
  } catch (err) {
@@ -48352,7 +48923,6 @@ var PodOS = (() => {
48352
48923
  return getUnauthenticatedSession();
48353
48924
  }
48354
48925
  };
48355
- var globalFetch2 = (...args) => fetch2.call(globalThis, ...args);
48356
48926
  var AuthCodeRedirectHandler = class {
48357
48927
  constructor(storageUtility, sessionInfoManager, issuerConfigFetcher, clientRegistrar, tokerRefresher) {
48358
48928
  this.storageUtility = storageUtility;
@@ -48395,21 +48965,16 @@ var PodOS = (() => {
48395
48965
  throw new Error(`The redirect URL for session ${storedSessionId} is missing from storage.`);
48396
48966
  }
48397
48967
  const client = await this.clientRegistrar.getClient({ sessionId: storedSessionId }, issuerConfig);
48398
- let tokens;
48399
48968
  const tokenCreatedAt = Date.now();
48400
- if (isDpop) {
48401
- tokens = await getDpopToken(issuerConfig, client, {
48402
- grantType: "authorization_code",
48403
- // We rely on our 'canHandle' function checking that the OAuth 'code'
48404
- // parameter is present in our query string.
48405
- code: url7.searchParams.get("code"),
48406
- codeVerifier,
48407
- redirectUrl: storedRedirectIri
48408
- });
48409
- window.localStorage.removeItem(`oidc.${oauthState}`);
48410
- } else {
48411
- tokens = await getBearerToken(url7.toString());
48412
- }
48969
+ const tokens = await getTokens(issuerConfig, client, {
48970
+ grantType: "authorization_code",
48971
+ // We rely on our 'canHandle' function checking that the OAuth 'code'
48972
+ // parameter is present in our query string.
48973
+ code: url7.searchParams.get("code"),
48974
+ codeVerifier,
48975
+ redirectUrl: storedRedirectIri
48976
+ }, isDpop);
48977
+ window.localStorage.removeItem(`oidc.${oauthState}`);
48413
48978
  let refreshOptions;
48414
48979
  if (tokens.refreshToken !== void 0) {
48415
48980
  refreshOptions = {
@@ -48418,16 +48983,13 @@ var PodOS = (() => {
48418
48983
  tokenRefresher: this.tokerRefresher
48419
48984
  };
48420
48985
  }
48421
- const authFetch = await buildAuthenticatedFetch(globalFetch2, tokens.accessToken, {
48986
+ const authFetch = await buildAuthenticatedFetch(tokens.accessToken, {
48422
48987
  dpopKey: tokens.dpopKey,
48423
48988
  refreshOptions,
48424
48989
  eventEmitter,
48425
48990
  expiresIn: tokens.expiresIn
48426
48991
  });
48427
- await this.storageUtility.setForUser(storedSessionId, {
48428
- webId: tokens.webId,
48429
- isLoggedIn: "true"
48430
- }, { secure: true });
48992
+ await saveSessionInfoToStorage(this.storageUtility, storedSessionId, tokens.webId, tokens.clientId, "true", void 0, true);
48431
48993
  const sessionInfo = await this.sessionInfoManager.get(storedSessionId);
48432
48994
  if (!sessionInfo) {
48433
48995
  throw new Error(`Could not retrieve session: [${storedSessionId}].`);
@@ -48478,33 +49040,34 @@ var PodOS = (() => {
48478
49040
  this.storageUtility = storageUtility;
48479
49041
  }
48480
49042
  async getClient(options, issuerConfig) {
48481
- const [
48482
- storedClientId,
48483
- storedClientSecret
48484
- // storedClientName,
48485
- ] = await Promise.all([
49043
+ const [storedClientId, storedClientSecret, storedClientName, storedClientType] = await Promise.all([
48486
49044
  this.storageUtility.getForUser(options.sessionId, "clientId", {
48487
49045
  secure: false
48488
49046
  }),
48489
49047
  this.storageUtility.getForUser(options.sessionId, "clientSecret", {
48490
49048
  secure: false
49049
+ }),
49050
+ this.storageUtility.getForUser(options.sessionId, "clientName", {
49051
+ secure: false
49052
+ }),
49053
+ this.storageUtility.getForUser(options.sessionId, "clientType", {
49054
+ secure: false
48491
49055
  })
48492
- // this.storageUtility.getForUser(options.sessionId, "clientName", {
48493
- // // FIXME: figure out how to persist secure storage at reload
48494
- // secure: false,
48495
- // }),
48496
49056
  ]);
48497
- if (storedClientId) {
49057
+ if (storedClientId && isKnownClientType(storedClientType)) {
48498
49058
  return {
48499
49059
  clientId: storedClientId,
48500
49060
  clientSecret: storedClientSecret,
48501
- clientType: "dynamic"
49061
+ clientName: storedClientName,
49062
+ // Note: static clients are not applicable in a browser context.
49063
+ clientType: storedClientType
48502
49064
  };
48503
49065
  }
48504
49066
  try {
48505
49067
  const registeredClient = await registerClient(options, issuerConfig);
48506
49068
  const infoToSave = {
48507
- clientId: registeredClient.clientId
49069
+ clientId: registeredClient.clientId,
49070
+ clientType: "dynamic"
48508
49071
  };
48509
49072
  if (registeredClient.clientSecret) {
48510
49073
  infoToSave.clientSecret = registeredClient.clientSecret;
@@ -48563,9 +49126,6 @@ var PodOS = (() => {
48563
49126
  const tokenSet = await refresh(refreshToken, oidcContext.issuerConfig, clientInfo, dpopKey);
48564
49127
  if (tokenSet.refreshToken !== void 0) {
48565
49128
  eventEmitter === null || eventEmitter === void 0 ? void 0 : eventEmitter.emit(EVENTS.NEW_REFRESH_TOKEN, tokenSet.refreshToken);
48566
- await this.storageUtility.setForUser(sessionId, {
48567
- refreshToken: tokenSet.refreshToken
48568
- });
48569
49129
  }
48570
49130
  return tokenSet;
48571
49131
  }
@@ -48613,7 +49173,7 @@ var PodOS = (() => {
48613
49173
  function isLoggedIn(sessionInfo) {
48614
49174
  return !!(sessionInfo === null || sessionInfo === void 0 ? void 0 : sessionInfo.isLoggedIn);
48615
49175
  }
48616
- var Session = class _Session extends import_events2.default {
49176
+ var Session = class {
48617
49177
  /**
48618
49178
  * Session object constructor. Typically called as follows:
48619
49179
  *
@@ -48630,7 +49190,6 @@ var PodOS = (() => {
48630
49190
  *
48631
49191
  */
48632
49192
  constructor(sessionOptions = {}, sessionId = void 0) {
48633
- super();
48634
49193
  this.tokenRequestInProgress = false;
48635
49194
  this.login = async (options) => {
48636
49195
  var _a;
@@ -48687,7 +49246,7 @@ var PodOS = (() => {
48687
49246
  this.tokenRequestInProgress = false;
48688
49247
  return sessionInfo;
48689
49248
  };
48690
- this.events = new Proxy(this, buildProxyHandler(_Session.prototype, "events only implements ISessionEventListener"));
49249
+ this.events = new import_events.default();
48691
49250
  if (sessionOptions.clientAuthentication) {
48692
49251
  this.clientAuthentication = sessionOptions.clientAuthentication;
48693
49252
  } else if (sessionOptions.secureStorage && sessionOptions.insecureStorage) {
@@ -48702,11 +49261,12 @@ var PodOS = (() => {
48702
49261
  this.info = {
48703
49262
  sessionId: sessionOptions.sessionInfo.sessionId,
48704
49263
  isLoggedIn: false,
48705
- webId: sessionOptions.sessionInfo.webId
49264
+ webId: sessionOptions.sessionInfo.webId,
49265
+ clientAppId: sessionOptions.sessionInfo.clientAppId
48706
49266
  };
48707
49267
  } else {
48708
49268
  this.info = {
48709
- sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : v4_default(),
49269
+ sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : v4_default2(),
48710
49270
  isLoggedIn: false
48711
49271
  };
48712
49272
  }
@@ -48714,62 +49274,11 @@ var PodOS = (() => {
48714
49274
  this.events.on(EVENTS.SESSION_EXPIRED, () => this.internalLogout(false));
48715
49275
  this.events.on(EVENTS.ERROR, () => this.internalLogout(false));
48716
49276
  }
48717
- /**
48718
- * Register a callback function to be called when a user completes login.
48719
- *
48720
- * The callback is called when {@link handleIncomingRedirect} completes successfully.
48721
- *
48722
- * @param callback The function called when a user completes login.
48723
- * @deprecated Prefer session.events.on(EVENTS.LOGIN, callback)
48724
- */
48725
- onLogin(callback) {
48726
- this.events.on(EVENTS.LOGIN, callback);
48727
- }
48728
- /**
48729
- * Register a callback function to be called when a user logs out:
48730
- *
48731
- * @param callback The function called when a user completes logout.
48732
- * @deprecated Prefer session.events.on(EVENTS.LOGOUT, callback)
48733
- */
48734
- onLogout(callback) {
48735
- this.events.on(EVENTS.LOGOUT, callback);
48736
- }
48737
- /**
48738
- * Register a callback function to be called when a user logs out:
48739
- *
48740
- * @param callback The function called when an error occurs.
48741
- * @since 1.11.0
48742
- * @deprecated Prefer session.events.on(EVENTS.ERROR, callback)
48743
- */
48744
- onError(callback) {
48745
- this.events.on(EVENTS.ERROR, callback);
48746
- }
48747
- /**
48748
- * Register a callback function to be called when a session is restored.
48749
- *
48750
- * Note: the callback will be called with the saved value of the 'current URL'
48751
- * at the time the session was restored.
48752
- *
48753
- * @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.
48754
- * @deprecated Prefer session.events.on(EVENTS.SESSION_RESTORED, callback)
48755
- */
48756
- onSessionRestore(callback) {
48757
- this.events.on(EVENTS.SESSION_RESTORED, callback);
48758
- }
48759
- /**
48760
- * Register a callback that runs when the session expires and can no longer
48761
- * make authenticated requests, but following a user logout.
48762
- * @param callback The function that runs on session expiration.
48763
- * @since 1.11.0
48764
- * @deprecated Prefer session.events.on(EVENTS.SESSION_EXPIRED, callback)
48765
- */
48766
- onSessionExpiration(callback) {
48767
- this.events.on(EVENTS.SESSION_EXPIRED, callback);
48768
- }
48769
49277
  setSessionInfo(sessionInfo) {
48770
49278
  this.info.isLoggedIn = sessionInfo.isLoggedIn;
48771
49279
  this.info.webId = sessionInfo.webId;
48772
49280
  this.info.sessionId = sessionInfo.sessionId;
49281
+ this.info.clientAppId = sessionInfo.clientAppId;
48773
49282
  this.info.expirationDate = sessionInfo.expirationDate;
48774
49283
  this.events.on(EVENTS.SESSION_EXTENDED, (expiresIn) => {
48775
49284
  this.info.expirationDate = Date.now() + expiresIn * 1e3;
@@ -48816,16 +49325,19 @@ var PodOS = (() => {
48816
49325
  * @deprecated use observeSession instead
48817
49326
  */
48818
49327
  trackSession(callback) {
48819
- this.session.on(EVENTS.LOGIN, () => callback(this.session.info));
48820
- this.session.on(EVENTS.LOGOUT, () => callback(this.session.info));
48821
- this.session.on(EVENTS.SESSION_RESTORED, () => callback(this.session.info));
49328
+ this.session.events.on(EVENTS.LOGIN, () => callback(this.session.info));
49329
+ this.session.events.on(EVENTS.LOGOUT, () => callback(this.session.info));
49330
+ this.session.events.on(
49331
+ EVENTS.SESSION_RESTORED,
49332
+ () => callback(this.session.info)
49333
+ );
48822
49334
  callback(this.session.info);
48823
49335
  }
48824
49336
  observeSession() {
48825
49337
  return this.sessionInfo$;
48826
49338
  }
48827
49339
  onSessionRestore(callback) {
48828
- this.session.on(EVENTS.SESSION_RESTORED, callback);
49340
+ this.session.events.on(EVENTS.SESSION_RESTORED, callback);
48829
49341
  }
48830
49342
  };
48831
49343
 
@@ -48886,7 +49398,7 @@ var PodOS = (() => {
48886
49398
 
48887
49399
  // src/modules/contacts.ts
48888
49400
  async function loadContactsModule(store) {
48889
- const module3 = await Promise.resolve().then(() => (init_dist(), dist_exports));
49401
+ const module3 = await Promise.resolve().then(() => (init_dist2(), dist_exports));
48890
49402
  return new module3.default({
48891
49403
  store: store.graph,
48892
49404
  fetcher: store.fetcher,
@@ -49306,7 +49818,7 @@ var PodOS = (() => {
49306
49818
  foaf: () => foaf,
49307
49819
  http: () => http,
49308
49820
  hydra: () => hydra,
49309
- ldp: () => ldp,
49821
+ ldp: () => ldp2,
49310
49822
  link: () => link3,
49311
49823
  log: () => log2,
49312
49824
  meeting: () => meeting,
@@ -49413,7 +49925,7 @@ var PodOS = (() => {
49413
49925
  var replies = "http://www.w3.org/ns/activitystreams#replies";
49414
49926
  var result = "http://www.w3.org/ns/activitystreams#result";
49415
49927
  var audience = "http://www.w3.org/ns/activitystreams#audience";
49416
- var tag = "http://www.w3.org/ns/activitystreams#tag";
49928
+ var tag2 = "http://www.w3.org/ns/activitystreams#tag";
49417
49929
  var tags = "http://www.w3.org/ns/activitystreams#tags";
49418
49930
  var target = "http://www.w3.org/ns/activitystreams#target";
49419
49931
  var origin2 = "http://www.w3.org/ns/activitystreams#origin";
@@ -49531,7 +50043,7 @@ var PodOS = (() => {
49531
50043
  replies,
49532
50044
  result,
49533
50045
  audience,
49534
- tag,
50046
+ tag: tag2,
49535
50047
  tags,
49536
50048
  target,
49537
50049
  origin: origin2,
@@ -53982,7 +54494,7 @@ var PodOS = (() => {
53982
54494
  var _identified = "http://hl7.org/fhir/_identified";
53983
54495
  var ExplanationOfBenefitAdjudication = "http://hl7.org/fhir/ExplanationOfBenefitAdjudication";
53984
54496
  var _Subscription = "http://hl7.org/fhir/_Subscription";
53985
- var tag2 = "http://hl7.org/fhir/tag";
54497
+ var tag3 = "http://hl7.org/fhir/tag";
53986
54498
  var _performed = "http://hl7.org/fhir/_performed";
53987
54499
  var _formOf = "http://hl7.org/fhir/_formOf";
53988
54500
  var DeviceDefinitionPackagingComponentPackagingPackaging = "http://hl7.org/fhir/DeviceDefinitionPackagingComponentPackagingPackaging";
@@ -58215,7 +58727,7 @@ var PodOS = (() => {
58215
58727
  _identified,
58216
58728
  ExplanationOfBenefitAdjudication,
58217
58729
  _Subscription,
58218
- tag: tag2,
58730
+ tag: tag3,
58219
58731
  _performed,
58220
58732
  _formOf,
58221
58733
  DeviceDefinitionPackagingComponentPackagingPackaging,
@@ -58819,7 +59331,7 @@ var PodOS = (() => {
58819
59331
  var Mailbox = "http://www.w3.org/2007/ont/link#Mailbox";
58820
59332
  var ProtocolEvent = "http://www.w3.org/2007/ont/link#ProtocolEvent";
58821
59333
  var RDFDocument = "http://www.w3.org/2007/ont/link#RDFDocument";
58822
- var Response2 = "http://www.w3.org/2007/ont/link#Response";
59334
+ var Response = "http://www.w3.org/2007/ont/link#Response";
58823
59335
  var Session3 = "http://www.w3.org/2007/ont/link#Session";
58824
59336
  var isMentionedIn = "http://www.w3.org/2007/ont/link#isMentionedIn";
58825
59337
  var mentionsClass = "http://www.w3.org/2007/ont/link#mentionsClass";
@@ -58839,7 +59351,7 @@ var PodOS = (() => {
58839
59351
  Mailbox,
58840
59352
  ProtocolEvent,
58841
59353
  RDFDocument,
58842
- Response: Response2,
59354
+ Response,
58843
59355
  Session: Session3,
58844
59356
  isMentionedIn,
58845
59357
  mentionsClass,
@@ -69105,7 +69617,7 @@ var PodOS = (() => {
69105
69617
  var Mailbox2 = "http://www.w3.org/2007/ont/link#Mailbox";
69106
69618
  var ProtocolEvent2 = "http://www.w3.org/2007/ont/link#ProtocolEvent";
69107
69619
  var RDFDocument2 = "http://www.w3.org/2007/ont/link#RDFDocument";
69108
- var Response3 = "http://www.w3.org/2007/ont/link#Response";
69620
+ var Response2 = "http://www.w3.org/2007/ont/link#Response";
69109
69621
  var Session4 = "http://www.w3.org/2007/ont/link#Session";
69110
69622
  var isMentionedIn2 = "http://www.w3.org/2007/ont/link#isMentionedIn";
69111
69623
  var mentionsClass2 = "http://www.w3.org/2007/ont/link#mentionsClass";
@@ -69125,7 +69637,7 @@ var PodOS = (() => {
69125
69637
  Mailbox: Mailbox2,
69126
69638
  ProtocolEvent: ProtocolEvent2,
69127
69639
  RDFDocument: RDFDocument2,
69128
- Response: Response3,
69640
+ Response: Response2,
69129
69641
  Session: Session4,
69130
69642
  isMentionedIn: isMentionedIn2,
69131
69643
  mentionsClass: mentionsClass2,
@@ -69147,7 +69659,7 @@ var PodOS = (() => {
69147
69659
  var Mailbox3 = "http://www.w3.org/2007/ont/link#Mailbox";
69148
69660
  var ProtocolEvent3 = "http://www.w3.org/2007/ont/link#ProtocolEvent";
69149
69661
  var RDFDocument3 = "http://www.w3.org/2007/ont/link#RDFDocument";
69150
- var Response4 = "http://www.w3.org/2007/ont/link#Response";
69662
+ var Response3 = "http://www.w3.org/2007/ont/link#Response";
69151
69663
  var Session5 = "http://www.w3.org/2007/ont/link#Session";
69152
69664
  var isMentionedIn3 = "http://www.w3.org/2007/ont/link#isMentionedIn";
69153
69665
  var mentionsClass3 = "http://www.w3.org/2007/ont/link#mentionsClass";
@@ -69167,7 +69679,7 @@ var PodOS = (() => {
69167
69679
  Mailbox: Mailbox3,
69168
69680
  ProtocolEvent: ProtocolEvent3,
69169
69681
  RDFDocument: RDFDocument3,
69170
- Response: Response4,
69682
+ Response: Response3,
69171
69683
  Session: Session5,
69172
69684
  isMentionedIn: isMentionedIn3,
69173
69685
  mentionsClass: mentionsClass3,
@@ -69555,7 +70067,7 @@ var PodOS = (() => {
69555
70067
  var foaf = foafImport;
69556
70068
  var http = httpImport;
69557
70069
  var hydra = hydraImport;
69558
- var ldp = ldpImport;
70070
+ var ldp2 = ldpImport;
69559
70071
  var link3 = linkImport;
69560
70072
  var log2 = logImport;
69561
70073
  var meeting = meetingImport;