solid-ui 2.4.27-6c8461c9 → 2.4.27-7184a38a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/solid-ui.js CHANGED
@@ -2655,7 +2655,7 @@ var ChatChannel = /*#__PURE__*/function () {
2655
2655
  var oldMsg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
2656
2656
  var deleteIt = arguments.length > 2 ? arguments[2] : undefined;
2657
2657
  return /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
2658
- var sts, now, timestamp, dateStamp, chatDocument, message, me, msg, privateKey, errMsg;
2658
+ var sts, now, timestamp, dateStamp, chatDocument, message, me, msg, oldMsgMaker, errMsg, privateKey, pubKey, sig, _errMsg;
2659
2659
  return _regenerator["default"].wrap(function _callee2$(_context2) {
2660
2660
  while (1) switch (_context2.prev = _context2.next) {
2661
2661
  case 0:
@@ -2666,57 +2666,83 @@ var ChatChannel = /*#__PURE__*/function () {
2666
2666
  chatDocument = oldMsg ? oldMsg.doc() : _this.dateFolder.leafDocumentFromDate(now);
2667
2667
  message = _solidLogic.store.sym(chatDocument.uri + '#' + 'Msg' + timestamp); // const content = store.literal(text)
2668
2668
  me = _solidLogic.authn.currentUser(); // If already logged on
2669
- msg = _signature.getBlankMsg;
2670
- msg.id = message;
2671
- if (oldMsg) {
2672
- // edit message replaces old one
2673
- sts.push($rdf.st(mostRecentVersion(oldMsg), ns.dct('isReplacedBy'), message, chatDocument));
2674
- // do we need to rebuild oldMsg signaturen ?
2675
- if (deleteIt) {
2676
- sts.push($rdf.st(message, ns.schema('dateDeleted'), dateStamp, chatDocument));
2677
- msg.dateDeleted = dateStamp;
2678
- }
2679
- } else {
2680
- // link new message to channel
2681
- sts.push($rdf.st(_this.channel, ns.wf('message'), message, chatDocument));
2669
+ msg = (0, _signature.getBlankMsg)();
2670
+ msg.id = message.uri;
2671
+ if (!oldMsg) {
2672
+ _context2.next = 22;
2673
+ break;
2674
+ }
2675
+ // edit message replaces old one
2676
+ oldMsgMaker = _solidLogic.store.any(oldMsg, ns.foaf('maker')); // may not be needed here, but needed on READ
2677
+ if (!(oldMsgMaker.uri === me.uri)) {
2678
+ _context2.next = 16;
2679
+ break;
2680
+ }
2681
+ sts.push($rdf.st(mostRecentVersion(oldMsg), ns.dct('isReplacedBy'), message, chatDocument));
2682
+ if (deleteIt) {
2683
+ // we need to add a specific signature, else anyone can delete a msg ?
2684
+ sts.push($rdf.st(message, ns.schema('dateDeleted'), dateStamp, chatDocument));
2685
+ // msg.dateDeleted = dateStamp
2682
2686
  }
2687
+ _context2.next = 20;
2688
+ break;
2689
+ case 16:
2690
+ errMsg = 'Error you cannot delete/edit a message from someone else : \n' + oldMsgMaker.uri;
2691
+ debug.warn(errMsg);
2692
+ alert(errMsg);
2693
+ throw new Error(errMsg);
2694
+ case 20:
2695
+ _context2.next = 23;
2696
+ break;
2697
+ case 22:
2698
+ // link new message to channel
2699
+ sts.push($rdf.st(_this.channel, ns.wf('message'), message, chatDocument));
2700
+ case 23:
2683
2701
  sts.push($rdf.st(message, ns.sioc('content'), _solidLogic.store.literal(text), chatDocument));
2684
2702
  msg.content = text;
2685
2703
  sts.push($rdf.st(message, ns.dct('created'), dateStamp, chatDocument));
2686
- msg.created = dateStamp;
2704
+ msg.created = dateStamp.value;
2687
2705
  if (!me) {
2688
- _context2.next = 21;
2706
+ _context2.next = 36;
2689
2707
  break;
2690
2708
  }
2691
2709
  sts.push($rdf.st(message, ns.foaf('maker'), me, chatDocument));
2692
- msg.maker = me;
2693
- // privateKey the cached private key of me, cache should be deleted after a certain time
2694
- _context2.next = 19;
2695
- return (0, _keys.getPrivateKey)(me);
2696
- case 19:
2710
+ msg.maker = me.uri;
2711
+ // privateKey the cached private key of me, cached in store
2712
+ _context2.next = 32;
2713
+ return (0, _keys.getPrivateKey)(me.uri);
2714
+ case 32:
2697
2715
  privateKey = _context2.sent;
2698
- sts.push($rdf.st(message, $rdf.sym("".concat(_signature.SEC, "Proof")), $rdf.sym((0, _signature.signMsg)(msg, privateKey), chatDocument)));
2699
- case 21:
2700
- _context2.prev = 21;
2701
- _context2.next = 24;
2716
+ // const privateKey0 = 'a11bc5d2eee6cdb3b37f5473a712cad905ccfb13fb2ccdbf1be0a1ac4fdc7d2a'
2717
+ // const pubKey0 = '023a9da707bee1302f66083c9d95673ff969b41607a66f52686fa774d64ceb87'
2718
+ pubKey = (0, _keys.getPublicKey)(me.uri);
2719
+ sig = (0, _signature.signMsg)(msg, privateKey);
2720
+ /* const verify = verifySignature(sig, msg, pubKey) // alain to remove
2721
+ debug.warn('sig ' + sig)
2722
+ debug.warn('verifySign ' + verify)
2723
+ debug.warn(msg) */
2724
+ sts.push($rdf.st(message, $rdf.sym("".concat(_signature.SEC, "Proof")), $rdf.lit(sig), chatDocument));
2725
+ case 36:
2726
+ _context2.prev = 36;
2727
+ _context2.next = 39;
2702
2728
  return _solidLogic.store.updater.update([], sts);
2703
- case 24:
2704
- _context2.next = 32;
2729
+ case 39:
2730
+ _context2.next = 47;
2705
2731
  break;
2706
- case 26:
2707
- _context2.prev = 26;
2708
- _context2.t0 = _context2["catch"](21);
2709
- errMsg = 'Error saving chat message: ' + _context2.t0;
2710
- debug.warn(errMsg);
2711
- alert(errMsg);
2712
- throw new Error(errMsg);
2713
- case 32:
2732
+ case 41:
2733
+ _context2.prev = 41;
2734
+ _context2.t0 = _context2["catch"](36);
2735
+ _errMsg = 'Error saving chat message: ' + _context2.t0;
2736
+ debug.warn(_errMsg);
2737
+ alert(_errMsg);
2738
+ throw new Error(_errMsg);
2739
+ case 47:
2714
2740
  return _context2.abrupt("return", message);
2715
- case 33:
2741
+ case 48:
2716
2742
  case "end":
2717
2743
  return _context2.stop();
2718
2744
  }
2719
- }, _callee2, null, [[21, 26]]);
2745
+ }, _callee2, null, [[36, 41]]);
2720
2746
  })();
2721
2747
  });
2722
2748
  function updateMessage(_x2) {
@@ -4011,82 +4037,239 @@ exports.getPrivateKey = getPrivateKey;
4011
4037
  exports.getPublicKey = getPublicKey;
4012
4038
  var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
4013
4039
  var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
4040
+ var debug = _interopRequireWildcard(__webpack_require__(/*! ../debug */ "./lib/debug.js"));
4014
4041
  var _secp256k = __webpack_require__(/*! @noble/curves/secp256k1 */ "./node_modules/@noble/curves/secp256k1.js");
4015
4042
  var _utils = __webpack_require__(/*! @noble/hashes/utils */ "./node_modules/@noble/hashes/utils.js");
4016
4043
  var _signature = __webpack_require__(/*! ./signature */ "./lib/chat/signature.js");
4017
4044
  var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
4018
4045
  var $rdf = _interopRequireWildcard(__webpack_require__(/*! rdflib */ "./node_modules/rdflib/esm/index.js"));
4046
+ var _cryptoKeyHelpers = __webpack_require__(/*! ../utils/cryptoKeyHelpers */ "./lib/utils/cryptoKeyHelpers.js");
4019
4047
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
4020
4048
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
4021
- // should have webcrypto.getRandomValues defined
4022
-
4023
4049
  function generatePrivateKey() {
4024
4050
  return (0, _utils.bytesToHex)(_secp256k.schnorr.utils.randomPrivateKey());
4025
4051
  }
4026
4052
  function generatePublicKey(privateKey) {
4027
4053
  return (0, _utils.bytesToHex)(_secp256k.schnorr.getPublicKey(privateKey));
4028
4054
  }
4029
- function getPublicKey(webId) {
4030
- // find publickey
4031
- /* const url = new URL(webId)
4032
- url.hash = ''
4033
- store.fetcher.load(url.href)
4034
- let publicKey = store.any(store.sym(webId), store.sym(CERT +'publicKey')) */
4035
- var publicKey = publicKeyExists(webId);
4036
- return publicKey === null || publicKey === void 0 ? void 0 : publicKey.uri;
4037
- }
4038
- function publicKeyExists(webId) {
4039
- // find publickey
4040
- var url = new URL(webId);
4041
- url.hash = '';
4042
- _solidLogic.store.fetcher.load(url.href);
4043
- var publicKey = _solidLogic.store.any(_solidLogic.store.sym(webId), _solidLogic.store.sym(_signature.CERT + 'publicKey'));
4044
- return publicKey;
4055
+ function getPublicKey(_x) {
4056
+ return _getPublicKey.apply(this, arguments);
4045
4057
  }
4046
- function privateKeyExists(webId) {
4047
- var url = new URL(webId);
4048
- var privateKeyUrl = url.hostname + '/profile/privateKey.ttl';
4049
- _solidLogic.store.fetcher.load(privateKeyUrl);
4050
- var privateKey = _solidLogic.store.any(_solidLogic.store.sym(webId), _solidLogic.store.sym(_signature.CERT + 'privateKey'));
4051
- return privateKey;
4058
+ function _getPublicKey() {
4059
+ _getPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
4060
+ var publicKeyDoc, key;
4061
+ return _regenerator["default"].wrap(function _callee$(_context) {
4062
+ while (1) switch (_context.prev = _context.next) {
4063
+ case 0:
4064
+ _context.next = 2;
4065
+ return _solidLogic.store.fetcher.load(webId);
4066
+ case 2:
4067
+ publicKeyDoc = (0, _cryptoKeyHelpers.pubKeyUrl)(webId);
4068
+ _context.prev = 3;
4069
+ _context.next = 6;
4070
+ return _solidLogic.store.fetcher.load(publicKeyDoc);
4071
+ case 6:
4072
+ // url.href)
4073
+ key = _solidLogic.store.any(_solidLogic.store.sym(webId), _solidLogic.store.sym(_signature.CERT + 'PublicKey'));
4074
+ return _context.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
4075
+ case 10:
4076
+ _context.prev = 10;
4077
+ _context.t0 = _context["catch"](3);
4078
+ return _context.abrupt("return", undefined);
4079
+ case 13:
4080
+ case "end":
4081
+ return _context.stop();
4082
+ }
4083
+ }, _callee, null, [[3, 10]]);
4084
+ }));
4085
+ return _getPublicKey.apply(this, arguments);
4052
4086
  }
4053
- function getPrivateKey(_x) {
4087
+ function getPrivateKey(_x2) {
4054
4088
  return _getPrivateKey.apply(this, arguments);
4055
4089
  }
4056
4090
  function _getPrivateKey() {
4057
- _getPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
4058
- var url, privateKeyUrl, publicKey, privateKey, del, add;
4059
- return _regenerator["default"].wrap(function _callee$(_context) {
4060
- while (1) switch (_context.prev = _context.next) {
4091
+ _getPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
4092
+ var publicKeyDoc, privateKeyDoc, publicKey, privateKey, validPublicKey, del, add, newPublicKey, keyContainer;
4093
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
4094
+ while (1) switch (_context2.prev = _context2.next) {
4061
4095
  case 0:
4062
- url = new URL(webId);
4063
- privateKeyUrl = url.hostname + '/profile/privateKey.ttl'; // find publickey
4064
- publicKey = publicKeyExists(webId); // find privateKey
4065
- privateKey = privateKeyExists(webId); // create key pair
4066
- if (!(!privateKey || !publicKey)) {
4067
- _context.next = 15;
4096
+ _context2.next = 2;
4097
+ return _solidLogic.store.fetcher.load(webId);
4098
+ case 2:
4099
+ // find keys url's
4100
+ publicKeyDoc = (0, _cryptoKeyHelpers.pubKeyUrl)(webId);
4101
+ privateKeyDoc = (0, _cryptoKeyHelpers.privKeyUrl)(webId); // find key pair
4102
+ _context2.next = 6;
4103
+ return (0, _cryptoKeyHelpers.publicKeyExists)(webId);
4104
+ case 6:
4105
+ publicKey = _context2.sent;
4106
+ _context2.next = 9;
4107
+ return (0, _cryptoKeyHelpers.privateKeyExists)(webId);
4108
+ case 9:
4109
+ privateKey = _context2.sent;
4110
+ // is publicKey valid ?
4111
+ validPublicKey = true;
4112
+ if (privateKey && publicKey !== generatePublicKey(privateKey)) {
4113
+ if (confirm('This is strange the publicKey is not valid for\n' + webId + '\'shall we repair keeping the private key ?')) validPublicKey = false;
4114
+ }
4115
+
4116
+ // create key pair or repair publicKey
4117
+ if (!(!privateKey || !publicKey || !validPublicKey)) {
4118
+ _context2.next = 30;
4068
4119
  break;
4069
4120
  }
4070
4121
  del = [];
4071
- add = [];
4072
- if (privateKey) del.push($rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'privateKey'), privateKey, $rdf.sym(privateKeyUrl)));
4073
- if (publicKey) del.push($rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'publicKey'), publicKey, $rdf.sym(url.href)));
4074
- privateKey = _solidLogic.store.sym(generatePrivateKey());
4075
- publicKey = _solidLogic.store.sym(generatePublicKey(privateKey.uri));
4076
- add.push($rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'privateKey'), $rdf.literal(privateKey.uri), $rdf.sym(privateKeyUrl)));
4077
- add.push($rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'publicKey'), $rdf.literal(publicKey.uri), $rdf.sym(url.href)));
4078
- _context.next = 15;
4079
- return _solidLogic.store.updater.updateMany(del, add);
4080
- case 15:
4081
- return _context.abrupt("return", privateKey.uri);
4082
- case 16:
4122
+ add = []; // if (privateKey) del.push($rdf.st($rdf.sym(webId), $rdf.sym(CERT + 'PrivateKey'), $rdf.lit(privateKey), $rdf.sym(privateKeyDoc)))
4123
+ if (privateKey) {
4124
+ _context2.next = 20;
4125
+ break;
4126
+ }
4127
+ // add = []
4128
+ privateKey = generatePrivateKey();
4129
+ add = [$rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'PrivateKey'), $rdf.literal(privateKey), $rdf.sym(privateKeyDoc))];
4130
+ _context2.next = 20;
4131
+ return saveKey(privateKeyDoc, [], add, webId);
4132
+ case 20:
4133
+ if (!(!publicKey || !validPublicKey)) {
4134
+ _context2.next = 27;
4135
+ break;
4136
+ }
4137
+ del = [];
4138
+ // delete invalid public key
4139
+ if (publicKey) {
4140
+ del = [$rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'PublicKey'), $rdf.lit(publicKey), $rdf.sym(publicKeyDoc))];
4141
+ debug.log(del);
4142
+ }
4143
+ // update new valid key
4144
+ newPublicKey = generatePublicKey(privateKey);
4145
+ add = [$rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'PublicKey'), $rdf.literal(newPublicKey), $rdf.sym(publicKeyDoc))];
4146
+ _context2.next = 27;
4147
+ return saveKey(publicKeyDoc, del, add);
4148
+ case 27:
4149
+ keyContainer = privateKeyDoc.substring(0, privateKeyDoc.lastIndexOf('/') + 1);
4150
+ _context2.next = 30;
4151
+ return setAcl(keyContainer, keyContainerAclBody(webId));
4152
+ case 30:
4153
+ return _context2.abrupt("return", privateKey);
4154
+ case 31:
4083
4155
  case "end":
4084
- return _context.stop();
4156
+ return _context2.stop();
4085
4157
  }
4086
- }, _callee);
4158
+ }, _callee2);
4087
4159
  }));
4088
4160
  return _getPrivateKey.apply(this, arguments);
4089
4161
  }
4162
+ var keyContainerAclBody = function keyContainerAclBody(me) {
4163
+ var aclBody = "\n@prefix : <#>.\n@prefix acl: <http://www.w3.org/ns/auth/acl#>.\n@prefix foaf: <http://xmlns.com/foaf/0.1/>.\n@prefix key: <./>.\n\n:ReadWrite\n a acl:Authorization;\n acl:accessTo key:;\n acl:agent <".concat(me, ">;\n acl:mode acl:Read, acl:Write.\n:Read\n a acl:Authorization;\n acl:accessTo key:;\n acl:default key:;\n acl:agentClass foaf:Agent;\n acl:mode acl:Read.\n");
4164
+ return aclBody;
4165
+ };
4166
+ var keyAclBody = function keyAclBody(keyDoc, me) {
4167
+ var keyAgent = 'acl:agentClass foaf:Agent'; // publicKey
4168
+ if (me !== null && me !== void 0 && me.length) keyAgent = "acl:agent <".concat(me, ">"); // privateKey
4169
+ var aclBody = "\n@prefix foaf: <http://xmlns.com/foaf/0.1/>.\n@prefix acl: <http://www.w3.org/ns/auth/acl#>.\n<#Read>\n a acl:Authorization;\n ".concat(keyAgent, ";\n acl:accessTo <").concat(keyDoc.split('/').pop(), ">;\n acl:mode acl:Read, acl:Control. # NSS issue: missing acl link header with READ only\n");
4170
+ return aclBody;
4171
+ };
4172
+ function setAcl(_x3, _x4) {
4173
+ return _setAcl.apply(this, arguments);
4174
+ }
4175
+ function _setAcl() {
4176
+ _setAcl = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(keyDoc, aclBody) {
4177
+ var keyAclDoc, aclResponse;
4178
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
4179
+ while (1) switch (_context3.prev = _context3.next) {
4180
+ case 0:
4181
+ _context3.next = 2;
4182
+ return _solidLogic.store.fetcher.load(keyDoc);
4183
+ case 2:
4184
+ // FIXME: check the Why value on this quad:
4185
+ keyAclDoc = _solidLogic.store.any($rdf.sym(keyDoc), $rdf.sym('http://www.iana.org/assignments/link-relations/acl'));
4186
+ if (keyAclDoc) {
4187
+ _context3.next = 5;
4188
+ break;
4189
+ }
4190
+ throw new Error('Key ACL doc not found!');
4191
+ case 5:
4192
+ _context3.next = 7;
4193
+ return _solidLogic.store.fetcher.webOperation('PUT', keyAclDoc.value, {
4194
+ data: aclBody,
4195
+ contentType: 'text/turtle'
4196
+ });
4197
+ case 7:
4198
+ aclResponse = _context3.sent;
4199
+ case 8:
4200
+ case "end":
4201
+ return _context3.stop();
4202
+ }
4203
+ }, _callee3);
4204
+ }));
4205
+ return _setAcl.apply(this, arguments);
4206
+ }
4207
+ function saveKey(_x5, _x6, _x7) {
4208
+ return _saveKey.apply(this, arguments);
4209
+ }
4210
+ function _saveKey() {
4211
+ _saveKey = (0, _asyncToGenerator2["default"])(function (keyDoc, del, add) {
4212
+ var me = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
4213
+ return /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
4214
+ var keyAclDoc, response, aclBody;
4215
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
4216
+ while (1) switch (_context4.prev = _context4.next) {
4217
+ case 0:
4218
+ _context4.next = 2;
4219
+ return _solidLogic.store.updater.updateMany(del, add);
4220
+ case 2:
4221
+ _context4.next = 4;
4222
+ return _solidLogic.store.fetcher.load(keyDoc);
4223
+ case 4:
4224
+ _context4.prev = 4;
4225
+ // get keyAcldoc
4226
+ keyAclDoc = _solidLogic.store.any($rdf.sym(keyDoc), $rdf.sym('http://www.iana.org/assignments/link-relations/acl'));
4227
+ if (keyAclDoc) {
4228
+ _context4.next = 8;
4229
+ break;
4230
+ }
4231
+ throw new Error("".concat(keyDoc, " ACL doc not found!"));
4232
+ case 8:
4233
+ _context4.prev = 8;
4234
+ _context4.next = 11;
4235
+ return _solidLogic.store.fetcher.webOperation('DELETE', keyAclDoc.value);
4236
+ case 11:
4237
+ response = _context4.sent;
4238
+ // this may fail if webId is not an owner
4239
+ debug.log('delete ' + keyAclDoc.value + ' ' + response.status); // should test 404 and 2xx
4240
+ _context4.next = 20;
4241
+ break;
4242
+ case 15:
4243
+ _context4.prev = 15;
4244
+ _context4.t0 = _context4["catch"](8);
4245
+ if (!(_context4.t0.response.status !== 404)) {
4246
+ _context4.next = 19;
4247
+ break;
4248
+ }
4249
+ throw new Error(_context4.t0);
4250
+ case 19:
4251
+ debug.log('delete ' + keyAclDoc.value + ' ' + _context4.t0.response.status); // should test 404 and 2xx
4252
+ case 20:
4253
+ // create READ only ACL
4254
+ aclBody = keyAclBody(keyDoc, me);
4255
+ _context4.next = 23;
4256
+ return setAcl(keyDoc, aclBody);
4257
+ case 23:
4258
+ _context4.next = 28;
4259
+ break;
4260
+ case 25:
4261
+ _context4.prev = 25;
4262
+ _context4.t1 = _context4["catch"](4);
4263
+ throw new Error(_context4.t1);
4264
+ case 28:
4265
+ case "end":
4266
+ return _context4.stop();
4267
+ }
4268
+ }, _callee4, null, [[4, 25], [8, 15]]);
4269
+ })();
4270
+ });
4271
+ return _saveKey.apply(this, arguments);
4272
+ }
4090
4273
  //# sourceMappingURL=keys.js.map
4091
4274
 
4092
4275
  /***/ }),
@@ -4215,21 +4398,39 @@ function renderMessageRow(channelObject, message, fresh, options, userContext) {
4215
4398
  var creator = _solidLogic.store.any(message, ns.foaf('maker'));
4216
4399
  var date = _solidLogic.store.any(message, ns.dct('created'));
4217
4400
  var latestVersion = (0, _chatLogic.mostRecentVersion)(message);
4218
- var content = _solidLogic.store.any(latestVersion, ns.sioc('content'));
4219
- var signature = _solidLogic.store.any(message, $rdf.sym("".concat(_signature.SEC, "Proof")));
4401
+ var latestVersionCreator = _solidLogic.store.any(latestVersion, ns.foaf('maker'));
4220
4402
 
4221
- // verify signature
4403
+ // use latest content if same owner, else use original
4404
+ var msgId = creator.uri === latestVersionCreator.uri ? latestVersion : message;
4405
+ var content = _solidLogic.store.any(msgId, ns.sioc('content'));
4406
+ var signature = _solidLogic.store.any(msgId, $rdf.sym("".concat(_signature.SEC, "Proof")));
4407
+
4408
+ // set message object
4222
4409
  var msg = (0, _signature.getBlankMsg)();
4223
- msg.id = message;
4224
- msg.created = date;
4225
- // this is not correct.
4226
- // If the message has been edited/deleted we must verify the latest message and may be the intermediate ones
4227
- msg.content = content;
4228
- msg.maker = creator;
4229
-
4230
- // pubKey could be store in a cache for all makers
4231
- var pubKey = (0, _keys.getPublicKey)(creator); // alain no
4232
- if (!(0, _signature.verifySignature)(signature, msg, pubKey)) throw new Error();
4410
+ msg.id = msgId.uri;
4411
+ msg.created = _solidLogic.store.any(msgId, ns.dct('created')).value;
4412
+ msg.content = content.value;
4413
+ msg.maker = creator.uri;
4414
+
4415
+ // unsigned message
4416
+ if (!(signature !== null && signature !== void 0 && signature.value)) debug.warn(msgId.uri + ' is unsigned'); // TODO replace with UI (colored message ?)
4417
+
4418
+ // signed message, get public key and check signature
4419
+ else {
4420
+ (0, _keys.getPublicKey)(creator.uri).then(function (publicKey) {
4421
+ debug.log(creator.uri + '\n' + msg.created + '\n' + msg.id + '\n' + publicKey);
4422
+ if (!publicKey) {
4423
+ // TODO try to recreate the publicKey
4424
+ // if(me.uri === creator.uri) await getPrivateKey(creator.uri)
4425
+ debug.warn('message is signed but ' + creator.uri + ' is missing publicKey');
4426
+ }
4427
+ // check that publicKey is a valid hex string
4428
+ var regex = /[0-9A-Fa-f]{6}/g;
4429
+ if (!(publicKey !== null && publicKey !== void 0 && publicKey.match(regex))) debug.warn('invalid publicKey hex string\n' + creator.uri + '\n' + publicKey);
4430
+ // verify signature
4431
+ else if (signature !== null && signature !== void 0 && signature.value && !(0, _signature.verifySignature)(signature === null || signature === void 0 ? void 0 : signature.value, msg, publicKey)) debug.warn('invalid signature\n' + msg.id);
4432
+ });
4433
+ }
4233
4434
  var originalMessage = (0, _chatLogic.originalVersion)(message);
4234
4435
  var edited = !message.sameTerm(originalMessage);
4235
4436
  var sortDate = _solidLogic.store.the(originalMessage, ns.dct('created'), null, originalMessage.doc()); // In message
@@ -5032,8 +5233,8 @@ exports.utf8Encoder = exports.utf8Decoder = void 0;
5032
5233
  exports.validateMsg = validateMsg;
5033
5234
  exports.verifySignature = verifySignature;
5034
5235
  var _secp256k = __webpack_require__(/*! @noble/curves/secp256k1 */ "./node_modules/@noble/curves/secp256k1.js");
5035
- var _sha = __webpack_require__(/*! @noble/hashes/sha256 */ "./node_modules/@noble/hashes/sha256.js");
5036
5236
  var _utils = __webpack_require__(/*! @noble/hashes/utils */ "./node_modules/@noble/hashes/utils.js");
5237
+ var _sha = __webpack_require__(/*! @noble/hashes/sha256 */ "./node_modules/@noble/hashes/sha256.js");
5037
5238
  // import {utf8Encoder} from './utils'
5038
5239
  // import { getPublicKey } from './keys'
5039
5240
 
@@ -5043,7 +5244,7 @@ var utf8Encoder = new TextEncoder();
5043
5244
  exports.utf8Encoder = utf8Encoder;
5044
5245
  var SEC = 'https://w3id.org/security#'; // Proof, VerificationMethod
5045
5246
  exports.SEC = SEC;
5046
- var CERT = 'http://www.w3.org/ns/auth/cert#'; // PrivatKey, PublicKey
5247
+ var CERT = 'http://www.w3.org/ns/auth/cert#'; // PrivateKey, PublicKey
5047
5248
 
5048
5249
  /* eslint-disable no-unused-vars */
5049
5250
  /* export enum Kind {
@@ -12330,6 +12531,173 @@ function isLight(x) {
12330
12531
 
12331
12532
  /***/ }),
12332
12533
 
12534
+ /***/ "./lib/utils/cryptoKeyHelpers.js":
12535
+ /*!***************************************!*\
12536
+ !*** ./lib/utils/cryptoKeyHelpers.js ***!
12537
+ \***************************************/
12538
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
12539
+
12540
+ "use strict";
12541
+
12542
+
12543
+ var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");
12544
+ var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
12545
+ Object.defineProperty(exports, "__esModule", ({
12546
+ value: true
12547
+ }));
12548
+ exports.privKeyUrl = void 0;
12549
+ exports.privateKeyExists = privateKeyExists;
12550
+ exports.pubKeyUrl = void 0;
12551
+ exports.publicKeyExists = publicKeyExists;
12552
+ var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
12553
+ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
12554
+ var debug = _interopRequireWildcard(__webpack_require__(/*! ../debug */ "./lib/debug.js"));
12555
+ var _signature = __webpack_require__(/*! ../chat/signature */ "./lib/chat/signature.js");
12556
+ var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
12557
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12558
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
12559
+ // find podRoot from space:storage for subdomain/suffix podServers
12560
+ /* export const podRoot = (webId: string) => {
12561
+ await store.fetcher.load(webId)
12562
+ const url = new URL(webId)
12563
+ // find storage in webId
12564
+ const storage = store.each(store.sym(webId), store.sym('http://www.w3.org/ns/pim/space#storage'))
12565
+ const pod = storage.length === 1 ? storage : storage.find(node => url.origin === new URL(node.value).origin)
12566
+ const podRoot = Array.isArray(pod) ? pod[0] : pod
12567
+ if (!podRoot?.value) throw Error('No space:storage in ' + webId)
12568
+ return podRoot.value
12569
+ } */
12570
+
12571
+ var pubKeyUrl = function pubKeyUrl(webId) {
12572
+ var url = new URL(webId);
12573
+ // find storage in webId
12574
+ var storage = _solidLogic.store.each(_solidLogic.store.sym(webId), _solidLogic.store.sym('http://www.w3.org/ns/pim/space#storage'));
12575
+ var pod = storage.length === 1 ? storage : storage.find(function (node) {
12576
+ return url.origin === new URL(node.value).origin;
12577
+ });
12578
+ var podUrl = Array.isArray(pod) ? pod[0] : pod;
12579
+ if (!(podUrl !== null && podUrl !== void 0 && podUrl.value)) throw Error('No space:storage in ' + webId);
12580
+ var publicKeyUrl = (podUrl === null || podUrl === void 0 ? void 0 : podUrl.value) + 'profile/keys/publicKey.ttl';
12581
+ return publicKeyUrl;
12582
+ };
12583
+ exports.pubKeyUrl = pubKeyUrl;
12584
+ function publicKeyExists(_x) {
12585
+ return _publicKeyExists.apply(this, arguments);
12586
+ }
12587
+ function _publicKeyExists() {
12588
+ _publicKeyExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
12589
+ var publicKeyUrl;
12590
+ return _regenerator["default"].wrap(function _callee$(_context) {
12591
+ while (1) switch (_context.prev = _context.next) {
12592
+ case 0:
12593
+ // find publickey
12594
+ publicKeyUrl = pubKeyUrl(webId);
12595
+ _context.next = 3;
12596
+ return keyExists(webId, publicKeyUrl, 'PublicKey');
12597
+ case 3:
12598
+ return _context.abrupt("return", _context.sent);
12599
+ case 4:
12600
+ case "end":
12601
+ return _context.stop();
12602
+ }
12603
+ }, _callee);
12604
+ }));
12605
+ return _publicKeyExists.apply(this, arguments);
12606
+ }
12607
+ var privKeyUrl = function privKeyUrl(webId) {
12608
+ var url = new URL(webId);
12609
+ // find storage in webId
12610
+ var storage = _solidLogic.store.each(_solidLogic.store.sym(webId), _solidLogic.store.sym('http://www.w3.org/ns/pim/space#storage'));
12611
+ var pod = storage.length === 1 ? storage : storage.find(function (node) {
12612
+ return url.origin === new URL(node.value).origin;
12613
+ });
12614
+ var podUrl = Array.isArray(pod) ? pod[0] : pod;
12615
+ if (!(podUrl !== null && podUrl !== void 0 && podUrl.value)) throw Error('Expected space:storage in ' + webId);
12616
+ var privateKeyUrl = (podUrl === null || podUrl === void 0 ? void 0 : podUrl.value) + 'profile/keys/privateKey.ttl';
12617
+ return privateKeyUrl;
12618
+ };
12619
+ exports.privKeyUrl = privKeyUrl;
12620
+ function privateKeyExists(_x2) {
12621
+ return _privateKeyExists.apply(this, arguments);
12622
+ }
12623
+ function _privateKeyExists() {
12624
+ _privateKeyExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
12625
+ var privateKeyUrl;
12626
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
12627
+ while (1) switch (_context2.prev = _context2.next) {
12628
+ case 0:
12629
+ // find privateKey
12630
+ privateKeyUrl = privKeyUrl(webId);
12631
+ _context2.next = 3;
12632
+ return keyExists(webId, privateKeyUrl, 'PrivateKey');
12633
+ case 3:
12634
+ return _context2.abrupt("return", _context2.sent);
12635
+ case 4:
12636
+ case "end":
12637
+ return _context2.stop();
12638
+ }
12639
+ }, _callee2);
12640
+ }));
12641
+ return _privateKeyExists.apply(this, arguments);
12642
+ }
12643
+ function keyExists(_x3, _x4, _x5) {
12644
+ return _keyExists.apply(this, arguments);
12645
+ }
12646
+ function _keyExists() {
12647
+ _keyExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId, keyUrl, keyType) {
12648
+ var key, _err$response, data, contentType, response;
12649
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
12650
+ while (1) switch (_context3.prev = _context3.next) {
12651
+ case 0:
12652
+ _context3.prev = 0;
12653
+ _context3.next = 3;
12654
+ return _solidLogic.store.fetcher.load(keyUrl);
12655
+ case 3:
12656
+ key = _solidLogic.store.any(_solidLogic.store.sym(webId), _solidLogic.store.sym(_signature.CERT + keyType));
12657
+ return _context3.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
12658
+ case 7:
12659
+ _context3.prev = 7;
12660
+ _context3.t0 = _context3["catch"](0);
12661
+ if (!((_context3.t0 === null || _context3.t0 === void 0 ? void 0 : (_err$response = _context3.t0.response) === null || _err$response === void 0 ? void 0 : _err$response.status) === 404)) {
12662
+ _context3.next = 24;
12663
+ break;
12664
+ }
12665
+ _context3.prev = 10;
12666
+ // create privateKey resource
12667
+ data = '';
12668
+ contentType = 'text/turtle';
12669
+ _context3.next = 15;
12670
+ return _solidLogic.store.fetcher.webOperation('PUT', keyUrl, {
12671
+ data: data,
12672
+ contentType: contentType
12673
+ });
12674
+ case 15:
12675
+ response = _context3.sent;
12676
+ _context3.next = 22;
12677
+ break;
12678
+ case 18:
12679
+ _context3.prev = 18;
12680
+ _context3.t1 = _context3["catch"](10);
12681
+ debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context3.t1);
12682
+ throw _context3.t1;
12683
+ case 22:
12684
+ delete _solidLogic.store.fetcher.requested[keyUrl]; // delete cached 404 error
12685
+ return _context3.abrupt("return", undefined);
12686
+ case 24:
12687
+ debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context3.t0);
12688
+ throw _context3.t0;
12689
+ case 26:
12690
+ case "end":
12691
+ return _context3.stop();
12692
+ }
12693
+ }, _callee3, null, [[0, 7], [10, 18]]);
12694
+ }));
12695
+ return _keyExists.apply(this, arguments);
12696
+ }
12697
+ //# sourceMappingURL=cryptoKeyHelpers.js.map
12698
+
12699
+ /***/ }),
12700
+
12333
12701
  /***/ "./lib/utils/headerFooterHelpers.js":
12334
12702
  /*!******************************************!*\
12335
12703
  !*** ./lib/utils/headerFooterHelpers.js ***!
@@ -13176,8 +13544,8 @@ Object.defineProperty(exports, "__esModule", ({
13176
13544
  }));
13177
13545
  exports.versionInfo = void 0;
13178
13546
  var versionInfo = {
13179
- buildTime: '2023-04-18T15:43:25Z',
13180
- commit: '6c8461c90348c12751456ce058874760f5b987aa',
13547
+ buildTime: '2023-04-30T22:04:08Z',
13548
+ commit: '7184a38ab5fc3b8a1be713169d0ef99666aad8a7',
13181
13549
  npmInfo: {
13182
13550
  'solid-ui': '2.4.27',
13183
13551
  npm: '8.19.4',
@@ -25340,6 +25708,8 @@ __webpack_require__.r(__webpack_exports__);
25340
25708
  /* harmony import */ var _inrupt_oidc_client__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @inrupt/oidc-client */ "./node_modules/@inrupt/oidc-client/lib/oidc-client.min.js");
25341
25709
  /* harmony import */ var _inrupt_oidc_client__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_inrupt_oidc_client__WEBPACK_IMPORTED_MODULE_0__);
25342
25710
  /* harmony import */ var _inrupt_solid_client_authn_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @inrupt/solid-client-authn-core */ "./node_modules/@inrupt/solid-client-authn-core/dist/index.mjs");
25711
+ /* harmony import */ var _inrupt_universal_fetch__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @inrupt/universal-fetch */ "./node_modules/@inrupt/universal-fetch/dist/index-browser.mjs");
25712
+
25343
25713
 
25344
25714
 
25345
25715
 
@@ -25493,7 +25863,7 @@ async function getTokens(issuer, client, data, dpop) {
25493
25863
  headers,
25494
25864
  body: new URLSearchParams(requestBody).toString(),
25495
25865
  };
25496
- const rawTokenResponse = await await fetch(issuer.tokenEndpoint, tokenRequestInit);
25866
+ const rawTokenResponse = await (0,_inrupt_universal_fetch__WEBPACK_IMPORTED_MODULE_2__.fetch)(issuer.tokenEndpoint, tokenRequestInit);
25497
25867
  const jsonTokenResponse = (await rawTokenResponse.json());
25498
25868
  const tokenResponse = validateTokenEndpointResponse(jsonTokenResponse, dpop);
25499
25869
  const webId = await (0,_inrupt_solid_client_authn_core__WEBPACK_IMPORTED_MODULE_1__.getWebidFromTokenPayload)(tokenResponse.id_token, issuer.jwksUri, issuer.issuer, client.clientId);
@@ -25577,7 +25947,7 @@ async function refresh(refreshToken, issuer, client, dpopKey) {
25577
25947
  else if (isValidUrl(client.clientId)) {
25578
25948
  requestBody.client_id = client.clientId;
25579
25949
  }
25580
- const rawResponse = await fetch(issuer.tokenEndpoint, {
25950
+ const rawResponse = await (0,_inrupt_universal_fetch__WEBPACK_IMPORTED_MODULE_2__.fetch)(issuer.tokenEndpoint, {
25581
25951
  method: "POST",
25582
25952
  body: new URLSearchParams(requestBody).toString(),
25583
25953
  headers: {
@@ -25692,8 +26062,9 @@ e.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,c=u>>1,h=-7,l=r?i-1:0,f=
25692
26062
 
25693
26063
  Object.defineProperty(exports, "__esModule", ({ value: true }));
25694
26064
  const solid_client_authn_core_1 = __webpack_require__(/*! @inrupt/solid-client-authn-core */ "./node_modules/@inrupt/solid-client-authn-core/dist/index.js");
26065
+ const universal_fetch_1 = __webpack_require__(/*! @inrupt/universal-fetch */ "./node_modules/@inrupt/universal-fetch/dist/index-browser.js");
25695
26066
  const oidc_client_ext_1 = __webpack_require__(/*! @inrupt/oidc-client-ext */ "./node_modules/@inrupt/oidc-client-ext/dist/index.es.js");
25696
- const globalFetch = (request, init) => window.fetch(request, init);
26067
+ const globalFetch = (request, init) => (0, universal_fetch_1.fetch)(request, init);
25697
26068
  class ClientAuthentication {
25698
26069
  constructor(loginHandler, redirectHandler, logoutHandler, sessionInfoManager, issuerConfigFetcher) {
25699
26070
  this.loginHandler = loginHandler;
@@ -26187,6 +26558,7 @@ exports["default"] = ClientRegistrar;
26187
26558
  Object.defineProperty(exports, "__esModule", ({ value: true }));
26188
26559
  exports.WELL_KNOWN_OPENID_CONFIG = void 0;
26189
26560
  const solid_client_authn_core_1 = __webpack_require__(/*! @inrupt/solid-client-authn-core */ "./node_modules/@inrupt/solid-client-authn-core/dist/index.js");
26561
+ const universal_fetch_1 = __webpack_require__(/*! @inrupt/universal-fetch */ "./node_modules/@inrupt/universal-fetch/dist/index-browser.js");
26190
26562
  exports.WELL_KNOWN_OPENID_CONFIG = ".well-known/openid-configuration";
26191
26563
  const issuerConfigKeyMap = {
26192
26564
  issuer: {
@@ -26293,7 +26665,7 @@ class IssuerConfigFetcher {
26293
26665
  async fetchConfig(issuer) {
26294
26666
  let issuerConfig;
26295
26667
  const openIdConfigUrl = new URL(exports.WELL_KNOWN_OPENID_CONFIG, issuer.endsWith("/") ? issuer : `${issuer}/`).href;
26296
- const issuerConfigRequestBody = await window.fetch(openIdConfigUrl);
26668
+ const issuerConfigRequestBody = await (0, universal_fetch_1.fetch)(openIdConfigUrl);
26297
26669
  try {
26298
26670
  issuerConfig = processConfig(await issuerConfigRequestBody.json());
26299
26671
  }
@@ -26396,6 +26768,7 @@ exports["default"] = Redirector;
26396
26768
 
26397
26769
  Object.defineProperty(exports, "__esModule", ({ value: true }));
26398
26770
  exports.AuthCodeRedirectHandler = void 0;
26771
+ const universal_fetch_1 = __webpack_require__(/*! @inrupt/universal-fetch */ "./node_modules/@inrupt/universal-fetch/dist/index-browser.js");
26399
26772
  const solid_client_authn_core_1 = __webpack_require__(/*! @inrupt/solid-client-authn-core */ "./node_modules/@inrupt/solid-client-authn-core/dist/index.js");
26400
26773
  const oidc_client_ext_1 = __webpack_require__(/*! @inrupt/oidc-client-ext */ "./node_modules/@inrupt/oidc-client-ext/dist/index.es.js");
26401
26774
  class AuthCodeRedirectHandler {
@@ -26459,7 +26832,7 @@ class AuthCodeRedirectHandler {
26459
26832
  tokenRefresher: this.tokerRefresher,
26460
26833
  };
26461
26834
  }
26462
- const authFetch = await (0, solid_client_authn_core_1.buildAuthenticatedFetch)(fetch, tokens.accessToken, {
26835
+ const authFetch = await (0, solid_client_authn_core_1.buildAuthenticatedFetch)(universal_fetch_1.fetch, tokens.accessToken, {
26463
26836
  dpopKey: tokens.dpopKey,
26464
26837
  refreshOptions,
26465
26838
  eventEmitter,
@@ -26697,11 +27070,12 @@ exports.SessionInfoManager = exports.clear = exports.getUnauthenticatedSession =
26697
27070
  const solid_client_authn_core_1 = __webpack_require__(/*! @inrupt/solid-client-authn-core */ "./node_modules/@inrupt/solid-client-authn-core/dist/index.js");
26698
27071
  const uuid_1 = __webpack_require__(/*! uuid */ "./node_modules/@inrupt/solid-client-authn-browser/node_modules/uuid/dist/commonjs-browser/index.js");
26699
27072
  const oidc_client_ext_1 = __webpack_require__(/*! @inrupt/oidc-client-ext */ "./node_modules/@inrupt/oidc-client-ext/dist/index.es.js");
27073
+ const universal_fetch_1 = __webpack_require__(/*! @inrupt/universal-fetch */ "./node_modules/@inrupt/universal-fetch/dist/index-browser.js");
26700
27074
  function getUnauthenticatedSession() {
26701
27075
  return {
26702
27076
  isLoggedIn: false,
26703
27077
  sessionId: (0, uuid_1.v4)(),
26704
- fetch,
27078
+ fetch: universal_fetch_1.fetch,
26705
27079
  };
26706
27080
  }
26707
27081
  exports.getUnauthenticatedSession = getUnauthenticatedSession;
@@ -27854,513 +28228,513 @@ exports["default"] = _default;
27854
28228
 
27855
28229
 
27856
28230
  var events = __webpack_require__(/*! events */ "./node_modules/events/events.js");
27857
- var crossFetch = __webpack_require__(/*! cross-fetch */ "./node_modules/cross-fetch/dist/browser-ponyfill.js");
28231
+ var universalFetch = __webpack_require__(/*! @inrupt/universal-fetch */ "./node_modules/@inrupt/universal-fetch/dist/index-browser.js");
27858
28232
  var jose = __webpack_require__(/*! jose */ "./node_modules/jose/dist/browser/index.js");
27859
28233
  var uuid = __webpack_require__(/*! uuid */ "./node_modules/@inrupt/solid-client-authn-core/node_modules/uuid/dist/commonjs-browser/index.js");
27860
28234
 
27861
- const SOLID_CLIENT_AUTHN_KEY_PREFIX = "solidClientAuthn:";
27862
- const PREFERRED_SIGNING_ALG = ["ES256", "RS256"];
27863
- const EVENTS = {
27864
- ERROR: "error",
27865
- LOGIN: "login",
27866
- LOGOUT: "logout",
27867
- NEW_REFRESH_TOKEN: "newRefreshToken",
27868
- SESSION_EXPIRED: "sessionExpired",
27869
- SESSION_EXTENDED: "sessionExtended",
27870
- SESSION_RESTORED: "sessionRestore",
27871
- TIMEOUT_SET: "timeoutSet",
27872
- };
27873
- const REFRESH_BEFORE_EXPIRATION_SECONDS = 5;
27874
- const SCOPE_OPENID = "openid";
27875
- const SCOPE_OFFLINE = "offline_access";
27876
- const SCOPE_WEBID = "webid";
28235
+ const SOLID_CLIENT_AUTHN_KEY_PREFIX = "solidClientAuthn:";
28236
+ const PREFERRED_SIGNING_ALG = ["ES256", "RS256"];
28237
+ const EVENTS = {
28238
+ ERROR: "error",
28239
+ LOGIN: "login",
28240
+ LOGOUT: "logout",
28241
+ NEW_REFRESH_TOKEN: "newRefreshToken",
28242
+ SESSION_EXPIRED: "sessionExpired",
28243
+ SESSION_EXTENDED: "sessionExtended",
28244
+ SESSION_RESTORED: "sessionRestore",
28245
+ TIMEOUT_SET: "timeoutSet",
28246
+ };
28247
+ const REFRESH_BEFORE_EXPIRATION_SECONDS = 5;
28248
+ const SCOPE_OPENID = "openid";
28249
+ const SCOPE_OFFLINE = "offline_access";
28250
+ const SCOPE_WEBID = "webid";
27877
28251
  const DEFAULT_SCOPES = [SCOPE_OPENID, SCOPE_OFFLINE, SCOPE_WEBID].join(" ");
27878
28252
 
27879
- const buildProxyHandler = (toExclude, errorMessage) => ({
27880
- get(target, prop, receiver) {
27881
- if (!Object.getOwnPropertyNames(events.EventEmitter).includes(prop) &&
27882
- Object.getOwnPropertyNames(toExclude).includes(prop)) {
27883
- throw new Error(`${errorMessage}: [${prop}] is not supported`);
27884
- }
27885
- return Reflect.get(target, prop, receiver);
27886
- },
28253
+ const buildProxyHandler = (toExclude, errorMessage) => ({
28254
+ get(target, prop, receiver) {
28255
+ if (!Object.getOwnPropertyNames(events.EventEmitter).includes(prop) &&
28256
+ Object.getOwnPropertyNames(toExclude).includes(prop)) {
28257
+ throw new Error(`${errorMessage}: [${prop}] is not supported`);
28258
+ }
28259
+ return Reflect.get(target, prop, receiver);
28260
+ },
27887
28261
  });
27888
28262
 
27889
- class AggregateHandler {
27890
- constructor(handleables) {
27891
- this.handleables = handleables;
27892
- }
27893
- async getProperHandler(params) {
27894
- const canHandleList = await Promise.all(this.handleables.map((handleable) => handleable.canHandle(...params)));
27895
- for (let i = 0; i < canHandleList.length; i += 1) {
27896
- if (canHandleList[i]) {
27897
- return this.handleables[i];
27898
- }
27899
- }
27900
- return null;
27901
- }
27902
- async canHandle(...params) {
27903
- return (await this.getProperHandler(params)) !== null;
27904
- }
27905
- async handle(...params) {
27906
- const handler = await this.getProperHandler(params);
27907
- if (handler) {
27908
- return handler.handle(...params);
27909
- }
27910
- throw new Error(`[${this.constructor.name}] cannot find a suitable handler for: ${params
27911
- .map((param) => {
27912
- try {
27913
- return JSON.stringify(param);
27914
- }
27915
- catch (err) {
27916
- return param.toString();
27917
- }
27918
- })
27919
- .join(", ")}`);
27920
- }
28263
+ class AggregateHandler {
28264
+ constructor(handleables) {
28265
+ this.handleables = handleables;
28266
+ }
28267
+ async getProperHandler(params) {
28268
+ const canHandleList = await Promise.all(this.handleables.map((handleable) => handleable.canHandle(...params)));
28269
+ for (let i = 0; i < canHandleList.length; i += 1) {
28270
+ if (canHandleList[i]) {
28271
+ return this.handleables[i];
28272
+ }
28273
+ }
28274
+ return null;
28275
+ }
28276
+ async canHandle(...params) {
28277
+ return (await this.getProperHandler(params)) !== null;
28278
+ }
28279
+ async handle(...params) {
28280
+ const handler = await this.getProperHandler(params);
28281
+ if (handler) {
28282
+ return handler.handle(...params);
28283
+ }
28284
+ throw new Error(`[${this.constructor.name}] cannot find a suitable handler for: ${params
28285
+ .map((param) => {
28286
+ try {
28287
+ return JSON.stringify(param);
28288
+ }
28289
+ catch (err) {
28290
+ return param.toString();
28291
+ }
28292
+ })
28293
+ .join(", ")}`);
28294
+ }
27921
28295
  }
27922
28296
 
27923
- async function fetchJwks(jwksIri, issuerIri) {
27924
- const jwksResponse = await crossFetch.fetch(jwksIri);
27925
- if (jwksResponse.status !== 200) {
27926
- throw new Error(`Could not fetch JWKS for [${issuerIri}] at [${jwksIri}]: ${jwksResponse.status} ${jwksResponse.statusText}`);
27927
- }
27928
- let jwk;
27929
- try {
27930
- jwk = (await jwksResponse.json()).keys[0];
27931
- }
27932
- catch (e) {
27933
- throw new Error(`Malformed JWKS for [${issuerIri}] at [${jwksIri}]: ${e.message}`);
27934
- }
27935
- return jwk;
27936
- }
27937
- async function getWebidFromTokenPayload(idToken, jwksIri, issuerIri, clientId) {
27938
- const jwk = await fetchJwks(jwksIri, issuerIri);
27939
- let payload;
27940
- try {
27941
- const { payload: verifiedPayload } = await jose.jwtVerify(idToken, await jose.importJWK(jwk), {
27942
- issuer: issuerIri,
27943
- audience: clientId,
27944
- });
27945
- payload = verifiedPayload;
27946
- }
27947
- catch (e) {
27948
- throw new Error(`Token verification failed: ${e.stack}`);
27949
- }
27950
- if (typeof payload.webid === "string") {
27951
- return payload.webid;
27952
- }
27953
- if (typeof payload.sub !== "string") {
27954
- throw new Error(`The token ${JSON.stringify(payload)} is invalid: it has no 'webid' claim and no 'sub' claim.`);
27955
- }
27956
- try {
27957
- new URL(payload.sub);
27958
- return payload.sub;
27959
- }
27960
- catch (e) {
27961
- throw new Error(`The token has no 'webid' claim, and its 'sub' claim of [${payload.sub}] is invalid as a URL - error [${e}].`);
27962
- }
28297
+ async function fetchJwks(jwksIri, issuerIri) {
28298
+ const jwksResponse = await universalFetch.fetch(jwksIri);
28299
+ if (jwksResponse.status !== 200) {
28300
+ throw new Error(`Could not fetch JWKS for [${issuerIri}] at [${jwksIri}]: ${jwksResponse.status} ${jwksResponse.statusText}`);
28301
+ }
28302
+ let jwk;
28303
+ try {
28304
+ jwk = (await jwksResponse.json()).keys[0];
28305
+ }
28306
+ catch (e) {
28307
+ throw new Error(`Malformed JWKS for [${issuerIri}] at [${jwksIri}]: ${e.message}`);
28308
+ }
28309
+ return jwk;
28310
+ }
28311
+ async function getWebidFromTokenPayload(idToken, jwksIri, issuerIri, clientId) {
28312
+ const jwk = await fetchJwks(jwksIri, issuerIri);
28313
+ let payload;
28314
+ try {
28315
+ const { payload: verifiedPayload } = await jose.jwtVerify(idToken, await jose.importJWK(jwk), {
28316
+ issuer: issuerIri,
28317
+ audience: clientId,
28318
+ });
28319
+ payload = verifiedPayload;
28320
+ }
28321
+ catch (e) {
28322
+ throw new Error(`Token verification failed: ${e.stack}`);
28323
+ }
28324
+ if (typeof payload.webid === "string") {
28325
+ return payload.webid;
28326
+ }
28327
+ if (typeof payload.sub !== "string") {
28328
+ throw new Error(`The token ${JSON.stringify(payload)} is invalid: it has no 'webid' claim and no 'sub' claim.`);
28329
+ }
28330
+ try {
28331
+ new URL(payload.sub);
28332
+ return payload.sub;
28333
+ }
28334
+ catch (e) {
28335
+ throw new Error(`The token has no 'webid' claim, and its 'sub' claim of [${payload.sub}] is invalid as a URL - error [${e}].`);
28336
+ }
27963
28337
  }
27964
28338
 
27965
- function isValidRedirectUrl(redirectUrl) {
27966
- try {
27967
- const urlObject = new URL(redirectUrl);
27968
- return urlObject.hash === "";
27969
- }
27970
- catch (e) {
27971
- return false;
27972
- }
28339
+ function isValidRedirectUrl(redirectUrl) {
28340
+ try {
28341
+ const urlObject = new URL(redirectUrl);
28342
+ return urlObject.hash === "";
28343
+ }
28344
+ catch (e) {
28345
+ return false;
28346
+ }
27973
28347
  }
27974
28348
 
27975
- function isSupportedTokenType(token) {
27976
- return typeof token === "string" && ["DPoP", "Bearer"].includes(token);
28349
+ function isSupportedTokenType(token) {
28350
+ return typeof token === "string" && ["DPoP", "Bearer"].includes(token);
27977
28351
  }
27978
28352
 
27979
28353
  const USER_SESSION_PREFIX = "solidClientAuthenticationUser";
27980
28354
 
27981
- function isValidUrl(url) {
27982
- try {
27983
- new URL(url);
27984
- return true;
27985
- }
27986
- catch (_a) {
27987
- return false;
27988
- }
27989
- }
27990
- function determineSigningAlg(supported, preferred) {
27991
- var _a;
27992
- return ((_a = preferred.find((signingAlg) => {
27993
- return supported.includes(signingAlg);
27994
- })) !== null && _a !== void 0 ? _a : null);
27995
- }
27996
- function determineClientType(options, issuerConfig) {
27997
- if (options.clientId !== undefined && !isValidUrl(options.clientId)) {
27998
- return "static";
27999
- }
28000
- if (issuerConfig.scopesSupported.includes("webid") &&
28001
- options.clientId !== undefined &&
28002
- isValidUrl(options.clientId)) {
28003
- return "solid-oidc";
28004
- }
28005
- return "dynamic";
28006
- }
28007
- async function handleRegistration(options, issuerConfig, storageUtility, clientRegistrar) {
28008
- const clientType = determineClientType(options, issuerConfig);
28009
- if (clientType === "dynamic") {
28010
- return clientRegistrar.getClient({
28011
- sessionId: options.sessionId,
28012
- clientName: options.clientName,
28013
- redirectUrl: options.redirectUrl,
28014
- }, issuerConfig);
28015
- }
28016
- await storageUtility.setForUser(options.sessionId, {
28017
- clientId: options.clientId,
28018
- });
28019
- if (options.clientSecret) {
28020
- await storageUtility.setForUser(options.sessionId, {
28021
- clientSecret: options.clientSecret,
28022
- });
28023
- }
28024
- if (options.clientName) {
28025
- await storageUtility.setForUser(options.sessionId, {
28026
- clientName: options.clientName,
28027
- });
28028
- }
28029
- return {
28030
- clientId: options.clientId,
28031
- clientSecret: options.clientSecret,
28032
- clientName: options.clientName,
28033
- clientType,
28034
- };
28355
+ function isValidUrl(url) {
28356
+ try {
28357
+ new URL(url);
28358
+ return true;
28359
+ }
28360
+ catch (_a) {
28361
+ return false;
28362
+ }
28363
+ }
28364
+ function determineSigningAlg(supported, preferred) {
28365
+ var _a;
28366
+ return ((_a = preferred.find((signingAlg) => {
28367
+ return supported.includes(signingAlg);
28368
+ })) !== null && _a !== void 0 ? _a : null);
28369
+ }
28370
+ function determineClientType(options, issuerConfig) {
28371
+ if (options.clientId !== undefined && !isValidUrl(options.clientId)) {
28372
+ return "static";
28373
+ }
28374
+ if (issuerConfig.scopesSupported.includes("webid") &&
28375
+ options.clientId !== undefined &&
28376
+ isValidUrl(options.clientId)) {
28377
+ return "solid-oidc";
28378
+ }
28379
+ return "dynamic";
28380
+ }
28381
+ async function handleRegistration(options, issuerConfig, storageUtility, clientRegistrar) {
28382
+ const clientType = determineClientType(options, issuerConfig);
28383
+ if (clientType === "dynamic") {
28384
+ return clientRegistrar.getClient({
28385
+ sessionId: options.sessionId,
28386
+ clientName: options.clientName,
28387
+ redirectUrl: options.redirectUrl,
28388
+ }, issuerConfig);
28389
+ }
28390
+ await storageUtility.setForUser(options.sessionId, {
28391
+ clientId: options.clientId,
28392
+ });
28393
+ if (options.clientSecret) {
28394
+ await storageUtility.setForUser(options.sessionId, {
28395
+ clientSecret: options.clientSecret,
28396
+ });
28397
+ }
28398
+ if (options.clientName) {
28399
+ await storageUtility.setForUser(options.sessionId, {
28400
+ clientName: options.clientName,
28401
+ });
28402
+ }
28403
+ return {
28404
+ clientId: options.clientId,
28405
+ clientSecret: options.clientSecret,
28406
+ clientName: options.clientName,
28407
+ clientType,
28408
+ };
28035
28409
  }
28036
28410
 
28037
- async function getSessionIdFromOauthState(storageUtility, oauthState) {
28038
- return storageUtility.getForUser(oauthState, "sessionId");
28039
- }
28040
- async function loadOidcContextFromStorage(sessionId, storageUtility, configFetcher) {
28041
- try {
28042
- const [issuerIri, codeVerifier, storedRedirectIri, dpop] = await Promise.all([
28043
- storageUtility.getForUser(sessionId, "issuer", {
28044
- errorIfNull: true,
28045
- }),
28046
- storageUtility.getForUser(sessionId, "codeVerifier"),
28047
- storageUtility.getForUser(sessionId, "redirectUrl"),
28048
- storageUtility.getForUser(sessionId, "dpop", { errorIfNull: true }),
28049
- ]);
28050
- await storageUtility.deleteForUser(sessionId, "codeVerifier");
28051
- const issuerConfig = await configFetcher.fetchConfig(issuerIri);
28052
- return {
28053
- codeVerifier,
28054
- redirectUrl: storedRedirectIri,
28055
- issuerConfig,
28056
- dpop: dpop === "true",
28057
- };
28058
- }
28059
- catch (e) {
28060
- throw new Error(`Failed to retrieve OIDC context from storage associated with session [${sessionId}]: ${e}`);
28061
- }
28062
- }
28063
- async function saveSessionInfoToStorage(storageUtility, sessionId, webId, isLoggedIn, refreshToken, secure, dpopKey) {
28064
- if (refreshToken !== undefined) {
28065
- await storageUtility.setForUser(sessionId, { refreshToken }, { secure });
28066
- }
28067
- if (webId !== undefined) {
28068
- await storageUtility.setForUser(sessionId, { webId }, { secure });
28069
- }
28070
- if (isLoggedIn !== undefined) {
28071
- await storageUtility.setForUser(sessionId, { isLoggedIn }, { secure });
28072
- }
28073
- if (dpopKey !== undefined) {
28074
- await storageUtility.setForUser(sessionId, {
28075
- publicKey: JSON.stringify(dpopKey.publicKey),
28076
- privateKey: JSON.stringify(await jose.exportJWK(dpopKey.privateKey)),
28077
- }, { secure });
28078
- }
28079
- }
28080
- class StorageUtility {
28081
- constructor(secureStorage, insecureStorage) {
28082
- this.secureStorage = secureStorage;
28083
- this.insecureStorage = insecureStorage;
28084
- }
28085
- getKey(userId) {
28086
- return `solidClientAuthenticationUser:${userId}`;
28087
- }
28088
- async getUserData(userId, secure) {
28089
- const stored = await (secure
28090
- ? this.secureStorage
28091
- : this.insecureStorage).get(this.getKey(userId));
28092
- if (stored === undefined) {
28093
- return {};
28094
- }
28095
- try {
28096
- return JSON.parse(stored);
28097
- }
28098
- catch (err) {
28099
- throw new Error(`Data for user [${userId}] in [${secure ? "secure" : "unsecure"}] storage is corrupted - expected valid JSON, but got: ${stored}`);
28100
- }
28101
- }
28102
- async setUserData(userId, data, secure) {
28103
- await (secure ? this.secureStorage : this.insecureStorage).set(this.getKey(userId), JSON.stringify(data));
28104
- }
28105
- async get(key, options) {
28106
- const value = await ((options === null || options === void 0 ? void 0 : options.secure)
28107
- ? this.secureStorage
28108
- : this.insecureStorage).get(key);
28109
- if (value === undefined && (options === null || options === void 0 ? void 0 : options.errorIfNull)) {
28110
- throw new Error(`[${key}] is not stored`);
28111
- }
28112
- return value;
28113
- }
28114
- async set(key, value, options) {
28115
- return ((options === null || options === void 0 ? void 0 : options.secure) ? this.secureStorage : this.insecureStorage).set(key, value);
28116
- }
28117
- async delete(key, options) {
28118
- return ((options === null || options === void 0 ? void 0 : options.secure) ? this.secureStorage : this.insecureStorage).delete(key);
28119
- }
28120
- async getForUser(userId, key, options) {
28121
- const userData = await this.getUserData(userId, options === null || options === void 0 ? void 0 : options.secure);
28122
- let value;
28123
- if (!userData || !userData[key]) {
28124
- value = undefined;
28125
- }
28126
- value = userData[key];
28127
- if (value === undefined && (options === null || options === void 0 ? void 0 : options.errorIfNull)) {
28128
- throw new Error(`Field [${key}] for user [${userId}] is not stored`);
28129
- }
28130
- return value || undefined;
28131
- }
28132
- async setForUser(userId, values, options) {
28133
- let userData;
28134
- try {
28135
- userData = await this.getUserData(userId, options === null || options === void 0 ? void 0 : options.secure);
28136
- }
28137
- catch (_a) {
28138
- userData = {};
28139
- }
28140
- await this.setUserData(userId, { ...userData, ...values }, options === null || options === void 0 ? void 0 : options.secure);
28141
- }
28142
- async deleteForUser(userId, key, options) {
28143
- const userData = await this.getUserData(userId, options === null || options === void 0 ? void 0 : options.secure);
28144
- delete userData[key];
28145
- await this.setUserData(userId, userData, options === null || options === void 0 ? void 0 : options.secure);
28146
- }
28147
- async deleteAllUserData(userId, options) {
28148
- await ((options === null || options === void 0 ? void 0 : options.secure) ? this.secureStorage : this.insecureStorage).delete(this.getKey(userId));
28149
- }
28411
+ async function getSessionIdFromOauthState(storageUtility, oauthState) {
28412
+ return storageUtility.getForUser(oauthState, "sessionId");
28413
+ }
28414
+ async function loadOidcContextFromStorage(sessionId, storageUtility, configFetcher) {
28415
+ try {
28416
+ const [issuerIri, codeVerifier, storedRedirectIri, dpop] = await Promise.all([
28417
+ storageUtility.getForUser(sessionId, "issuer", {
28418
+ errorIfNull: true,
28419
+ }),
28420
+ storageUtility.getForUser(sessionId, "codeVerifier"),
28421
+ storageUtility.getForUser(sessionId, "redirectUrl"),
28422
+ storageUtility.getForUser(sessionId, "dpop", { errorIfNull: true }),
28423
+ ]);
28424
+ await storageUtility.deleteForUser(sessionId, "codeVerifier");
28425
+ const issuerConfig = await configFetcher.fetchConfig(issuerIri);
28426
+ return {
28427
+ codeVerifier,
28428
+ redirectUrl: storedRedirectIri,
28429
+ issuerConfig,
28430
+ dpop: dpop === "true",
28431
+ };
28432
+ }
28433
+ catch (e) {
28434
+ throw new Error(`Failed to retrieve OIDC context from storage associated with session [${sessionId}]: ${e}`);
28435
+ }
28436
+ }
28437
+ async function saveSessionInfoToStorage(storageUtility, sessionId, webId, isLoggedIn, refreshToken, secure, dpopKey) {
28438
+ if (refreshToken !== undefined) {
28439
+ await storageUtility.setForUser(sessionId, { refreshToken }, { secure });
28440
+ }
28441
+ if (webId !== undefined) {
28442
+ await storageUtility.setForUser(sessionId, { webId }, { secure });
28443
+ }
28444
+ if (isLoggedIn !== undefined) {
28445
+ await storageUtility.setForUser(sessionId, { isLoggedIn }, { secure });
28446
+ }
28447
+ if (dpopKey !== undefined) {
28448
+ await storageUtility.setForUser(sessionId, {
28449
+ publicKey: JSON.stringify(dpopKey.publicKey),
28450
+ privateKey: JSON.stringify(await jose.exportJWK(dpopKey.privateKey)),
28451
+ }, { secure });
28452
+ }
28453
+ }
28454
+ class StorageUtility {
28455
+ constructor(secureStorage, insecureStorage) {
28456
+ this.secureStorage = secureStorage;
28457
+ this.insecureStorage = insecureStorage;
28458
+ }
28459
+ getKey(userId) {
28460
+ return `solidClientAuthenticationUser:${userId}`;
28461
+ }
28462
+ async getUserData(userId, secure) {
28463
+ const stored = await (secure
28464
+ ? this.secureStorage
28465
+ : this.insecureStorage).get(this.getKey(userId));
28466
+ if (stored === undefined) {
28467
+ return {};
28468
+ }
28469
+ try {
28470
+ return JSON.parse(stored);
28471
+ }
28472
+ catch (err) {
28473
+ throw new Error(`Data for user [${userId}] in [${secure ? "secure" : "unsecure"}] storage is corrupted - expected valid JSON, but got: ${stored}`);
28474
+ }
28475
+ }
28476
+ async setUserData(userId, data, secure) {
28477
+ await (secure ? this.secureStorage : this.insecureStorage).set(this.getKey(userId), JSON.stringify(data));
28478
+ }
28479
+ async get(key, options) {
28480
+ const value = await ((options === null || options === void 0 ? void 0 : options.secure)
28481
+ ? this.secureStorage
28482
+ : this.insecureStorage).get(key);
28483
+ if (value === undefined && (options === null || options === void 0 ? void 0 : options.errorIfNull)) {
28484
+ throw new Error(`[${key}] is not stored`);
28485
+ }
28486
+ return value;
28487
+ }
28488
+ async set(key, value, options) {
28489
+ return ((options === null || options === void 0 ? void 0 : options.secure) ? this.secureStorage : this.insecureStorage).set(key, value);
28490
+ }
28491
+ async delete(key, options) {
28492
+ return ((options === null || options === void 0 ? void 0 : options.secure) ? this.secureStorage : this.insecureStorage).delete(key);
28493
+ }
28494
+ async getForUser(userId, key, options) {
28495
+ const userData = await this.getUserData(userId, options === null || options === void 0 ? void 0 : options.secure);
28496
+ let value;
28497
+ if (!userData || !userData[key]) {
28498
+ value = undefined;
28499
+ }
28500
+ value = userData[key];
28501
+ if (value === undefined && (options === null || options === void 0 ? void 0 : options.errorIfNull)) {
28502
+ throw new Error(`Field [${key}] for user [${userId}] is not stored`);
28503
+ }
28504
+ return value || undefined;
28505
+ }
28506
+ async setForUser(userId, values, options) {
28507
+ let userData;
28508
+ try {
28509
+ userData = await this.getUserData(userId, options === null || options === void 0 ? void 0 : options.secure);
28510
+ }
28511
+ catch (_a) {
28512
+ userData = {};
28513
+ }
28514
+ await this.setUserData(userId, { ...userData, ...values }, options === null || options === void 0 ? void 0 : options.secure);
28515
+ }
28516
+ async deleteForUser(userId, key, options) {
28517
+ const userData = await this.getUserData(userId, options === null || options === void 0 ? void 0 : options.secure);
28518
+ delete userData[key];
28519
+ await this.setUserData(userId, userData, options === null || options === void 0 ? void 0 : options.secure);
28520
+ }
28521
+ async deleteAllUserData(userId, options) {
28522
+ await ((options === null || options === void 0 ? void 0 : options.secure) ? this.secureStorage : this.insecureStorage).delete(this.getKey(userId));
28523
+ }
28150
28524
  }
28151
28525
 
28152
- class InMemoryStorage {
28153
- constructor() {
28154
- this.map = {};
28155
- }
28156
- async get(key) {
28157
- return this.map[key] || undefined;
28158
- }
28159
- async set(key, value) {
28160
- this.map[key] = value;
28161
- }
28162
- async delete(key) {
28163
- delete this.map[key];
28164
- }
28526
+ class InMemoryStorage {
28527
+ constructor() {
28528
+ this.map = {};
28529
+ }
28530
+ async get(key) {
28531
+ return this.map[key] || undefined;
28532
+ }
28533
+ async set(key, value) {
28534
+ this.map[key] = value;
28535
+ }
28536
+ async delete(key) {
28537
+ delete this.map[key];
28538
+ }
28165
28539
  }
28166
28540
 
28167
- class ConfigurationError extends Error {
28168
- constructor(message) {
28169
- super(message);
28170
- }
28541
+ class ConfigurationError extends Error {
28542
+ constructor(message) {
28543
+ super(message);
28544
+ }
28171
28545
  }
28172
28546
 
28173
- class NotImplementedError extends Error {
28174
- constructor(methodName) {
28175
- super(`[${methodName}] is not implemented`);
28176
- }
28547
+ class NotImplementedError extends Error {
28548
+ constructor(methodName) {
28549
+ super(`[${methodName}] is not implemented`);
28550
+ }
28177
28551
  }
28178
28552
 
28179
- class InvalidResponseError extends Error {
28180
- constructor(missingFields) {
28181
- super(`Invalid response from OIDC provider: missing fields ${missingFields}`);
28182
- this.missingFields = missingFields;
28183
- }
28553
+ class InvalidResponseError extends Error {
28554
+ constructor(missingFields) {
28555
+ super(`Invalid response from OIDC provider: missing fields ${missingFields}`);
28556
+ this.missingFields = missingFields;
28557
+ }
28184
28558
  }
28185
28559
 
28186
- class OidcProviderError extends Error {
28187
- constructor(message, error, errorDescription) {
28188
- super(message);
28189
- this.error = error;
28190
- this.errorDescription = errorDescription;
28191
- }
28560
+ class OidcProviderError extends Error {
28561
+ constructor(message, error, errorDescription) {
28562
+ super(message);
28563
+ this.error = error;
28564
+ this.errorDescription = errorDescription;
28565
+ }
28192
28566
  }
28193
28567
 
28194
- function normalizeHTU(audience) {
28195
- const audienceUrl = new URL(audience);
28196
- return new URL(audienceUrl.pathname, audienceUrl.origin).toString();
28197
- }
28198
- async function createDpopHeader(audience, method, dpopKey) {
28199
- return new jose.SignJWT({
28200
- htu: normalizeHTU(audience),
28201
- htm: method.toUpperCase(),
28202
- jti: uuid.v4(),
28203
- })
28204
- .setProtectedHeader({
28205
- alg: PREFERRED_SIGNING_ALG[0],
28206
- jwk: dpopKey.publicKey,
28207
- typ: "dpop+jwt",
28208
- })
28209
- .setIssuedAt()
28210
- .sign(dpopKey.privateKey, {});
28211
- }
28212
- async function generateDpopKeyPair() {
28213
- const { privateKey, publicKey } = await jose.generateKeyPair(PREFERRED_SIGNING_ALG[0]);
28214
- const dpopKeyPair = {
28215
- privateKey,
28216
- publicKey: await jose.exportJWK(publicKey),
28217
- };
28218
- [dpopKeyPair.publicKey.alg] = PREFERRED_SIGNING_ALG;
28219
- return dpopKeyPair;
28568
+ function normalizeHTU(audience) {
28569
+ const audienceUrl = new URL(audience);
28570
+ return new URL(audienceUrl.pathname, audienceUrl.origin).toString();
28571
+ }
28572
+ async function createDpopHeader(audience, method, dpopKey) {
28573
+ return new jose.SignJWT({
28574
+ htu: normalizeHTU(audience),
28575
+ htm: method.toUpperCase(),
28576
+ jti: uuid.v4(),
28577
+ })
28578
+ .setProtectedHeader({
28579
+ alg: PREFERRED_SIGNING_ALG[0],
28580
+ jwk: dpopKey.publicKey,
28581
+ typ: "dpop+jwt",
28582
+ })
28583
+ .setIssuedAt()
28584
+ .sign(dpopKey.privateKey, {});
28585
+ }
28586
+ async function generateDpopKeyPair() {
28587
+ const { privateKey, publicKey } = await jose.generateKeyPair(PREFERRED_SIGNING_ALG[0]);
28588
+ const dpopKeyPair = {
28589
+ privateKey,
28590
+ publicKey: await jose.exportJWK(publicKey),
28591
+ };
28592
+ [dpopKeyPair.publicKey.alg] = PREFERRED_SIGNING_ALG;
28593
+ return dpopKeyPair;
28220
28594
  }
28221
28595
 
28222
- const DEFAULT_EXPIRATION_TIME_SECONDS = 600;
28223
- function isExpectedAuthError(statusCode) {
28224
- return [401, 403].includes(statusCode);
28225
- }
28226
- async function buildDpopFetchOptions(targetUrl, authToken, dpopKey, defaultOptions) {
28227
- var _a;
28228
- const headers = new crossFetch.Headers(defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.headers);
28229
- headers.set("Authorization", `DPoP ${authToken}`);
28230
- headers.set("DPoP", await createDpopHeader(targetUrl, (_a = defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.method) !== null && _a !== void 0 ? _a : "get", dpopKey));
28231
- return {
28232
- ...defaultOptions,
28233
- headers,
28234
- };
28235
- }
28236
- async function buildAuthenticatedHeaders(targetUrl, authToken, dpopKey, defaultOptions) {
28237
- if (dpopKey !== undefined) {
28238
- return buildDpopFetchOptions(targetUrl, authToken, dpopKey, defaultOptions);
28239
- }
28240
- const headers = new crossFetch.Headers(defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.headers);
28241
- headers.set("Authorization", `Bearer ${authToken}`);
28242
- return {
28243
- ...defaultOptions,
28244
- headers,
28245
- };
28246
- }
28247
- async function makeAuthenticatedRequest(unauthFetch, accessToken, url, defaultRequestInit, dpopKey) {
28248
- return unauthFetch(url, await buildAuthenticatedHeaders(url.toString(), accessToken, dpopKey, defaultRequestInit));
28249
- }
28250
- async function refreshAccessToken(refreshOptions, dpopKey, eventEmitter) {
28251
- var _a;
28252
- const tokenSet = await refreshOptions.tokenRefresher.refresh(refreshOptions.sessionId, refreshOptions.refreshToken, dpopKey);
28253
- eventEmitter === null || eventEmitter === void 0 ? void 0 : eventEmitter.emit(EVENTS.SESSION_EXTENDED, (_a = tokenSet.expiresIn) !== null && _a !== void 0 ? _a : DEFAULT_EXPIRATION_TIME_SECONDS);
28254
- if (typeof tokenSet.refreshToken === "string") {
28255
- eventEmitter === null || eventEmitter === void 0 ? void 0 : eventEmitter.emit(EVENTS.NEW_REFRESH_TOKEN, tokenSet.refreshToken);
28256
- }
28257
- return {
28258
- accessToken: tokenSet.accessToken,
28259
- refreshToken: tokenSet.refreshToken,
28260
- expiresIn: tokenSet.expiresIn,
28261
- };
28262
- }
28263
- const computeRefreshDelay = (expiresIn) => {
28264
- if (expiresIn !== undefined) {
28265
- return expiresIn - REFRESH_BEFORE_EXPIRATION_SECONDS > 0
28266
- ?
28267
- expiresIn - REFRESH_BEFORE_EXPIRATION_SECONDS
28268
- : expiresIn;
28269
- }
28270
- return DEFAULT_EXPIRATION_TIME_SECONDS;
28271
- };
28272
- async function buildAuthenticatedFetch(unauthFetch, accessToken, options) {
28273
- var _a;
28274
- let currentAccessToken = accessToken;
28275
- let latestTimeout;
28276
- const currentRefreshOptions = options === null || options === void 0 ? void 0 : options.refreshOptions;
28277
- if (currentRefreshOptions !== undefined) {
28278
- const proactivelyRefreshToken = async () => {
28279
- var _a, _b, _c, _d;
28280
- try {
28281
- const { accessToken: refreshedAccessToken, refreshToken, expiresIn, } = await refreshAccessToken(currentRefreshOptions, options.dpopKey, options.eventEmitter);
28282
- currentAccessToken = refreshedAccessToken;
28283
- if (refreshToken !== undefined) {
28284
- currentRefreshOptions.refreshToken = refreshToken;
28285
- }
28286
- clearTimeout(latestTimeout);
28287
- latestTimeout = setTimeout(proactivelyRefreshToken, computeRefreshDelay(expiresIn) * 1000);
28288
- (_a = options.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit(EVENTS.TIMEOUT_SET, latestTimeout);
28289
- }
28290
- catch (e) {
28291
- if (e instanceof OidcProviderError) {
28292
- (_b = options === null || options === void 0 ? void 0 : options.eventEmitter) === null || _b === void 0 ? void 0 : _b.emit(EVENTS.ERROR, e.error, e.errorDescription);
28293
- (_c = options === null || options === void 0 ? void 0 : options.eventEmitter) === null || _c === void 0 ? void 0 : _c.emit(EVENTS.SESSION_EXPIRED);
28294
- }
28295
- if (e instanceof InvalidResponseError &&
28296
- e.missingFields.includes("access_token")) {
28297
- (_d = options === null || options === void 0 ? void 0 : options.eventEmitter) === null || _d === void 0 ? void 0 : _d.emit(EVENTS.SESSION_EXPIRED);
28298
- }
28299
- }
28300
- };
28301
- latestTimeout = setTimeout(proactivelyRefreshToken, computeRefreshDelay(options.expiresIn) * 1000);
28302
- (_a = options.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit(EVENTS.TIMEOUT_SET, latestTimeout);
28303
- }
28304
- else if (options !== undefined && options.eventEmitter !== undefined) {
28305
- const expirationTimeout = setTimeout(() => {
28306
- options.eventEmitter.emit(EVENTS.SESSION_EXPIRED);
28307
- }, computeRefreshDelay(options.expiresIn) * 1000);
28308
- options.eventEmitter.emit(EVENTS.TIMEOUT_SET, expirationTimeout);
28309
- }
28310
- return async (url, requestInit) => {
28311
- let response = await makeAuthenticatedRequest(unauthFetch, currentAccessToken, url, requestInit, options === null || options === void 0 ? void 0 : options.dpopKey);
28312
- const failedButNotExpectedAuthError = !response.ok && !isExpectedAuthError(response.status);
28313
- if (response.ok || failedButNotExpectedAuthError) {
28314
- return response;
28315
- }
28316
- const hasBeenRedirected = response.url !== url;
28317
- if (hasBeenRedirected && (options === null || options === void 0 ? void 0 : options.dpopKey) !== undefined) {
28318
- response = await makeAuthenticatedRequest(unauthFetch, currentAccessToken, response.url, requestInit, options.dpopKey);
28319
- }
28320
- return response;
28321
- };
28596
+ const DEFAULT_EXPIRATION_TIME_SECONDS = 600;
28597
+ function isExpectedAuthError(statusCode) {
28598
+ return [401, 403].includes(statusCode);
28599
+ }
28600
+ async function buildDpopFetchOptions(targetUrl, authToken, dpopKey, defaultOptions) {
28601
+ var _a;
28602
+ const headers = new universalFetch.Headers(defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.headers);
28603
+ headers.set("Authorization", `DPoP ${authToken}`);
28604
+ headers.set("DPoP", await createDpopHeader(targetUrl, (_a = defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.method) !== null && _a !== void 0 ? _a : "get", dpopKey));
28605
+ return {
28606
+ ...defaultOptions,
28607
+ headers,
28608
+ };
28609
+ }
28610
+ async function buildAuthenticatedHeaders(targetUrl, authToken, dpopKey, defaultOptions) {
28611
+ if (dpopKey !== undefined) {
28612
+ return buildDpopFetchOptions(targetUrl, authToken, dpopKey, defaultOptions);
28613
+ }
28614
+ const headers = new universalFetch.Headers(defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.headers);
28615
+ headers.set("Authorization", `Bearer ${authToken}`);
28616
+ return {
28617
+ ...defaultOptions,
28618
+ headers,
28619
+ };
28620
+ }
28621
+ async function makeAuthenticatedRequest(unauthFetch, accessToken, url, defaultRequestInit, dpopKey) {
28622
+ return unauthFetch(url, await buildAuthenticatedHeaders(url.toString(), accessToken, dpopKey, defaultRequestInit));
28623
+ }
28624
+ async function refreshAccessToken(refreshOptions, dpopKey, eventEmitter) {
28625
+ var _a;
28626
+ const tokenSet = await refreshOptions.tokenRefresher.refresh(refreshOptions.sessionId, refreshOptions.refreshToken, dpopKey);
28627
+ eventEmitter === null || eventEmitter === void 0 ? void 0 : eventEmitter.emit(EVENTS.SESSION_EXTENDED, (_a = tokenSet.expiresIn) !== null && _a !== void 0 ? _a : DEFAULT_EXPIRATION_TIME_SECONDS);
28628
+ if (typeof tokenSet.refreshToken === "string") {
28629
+ eventEmitter === null || eventEmitter === void 0 ? void 0 : eventEmitter.emit(EVENTS.NEW_REFRESH_TOKEN, tokenSet.refreshToken);
28630
+ }
28631
+ return {
28632
+ accessToken: tokenSet.accessToken,
28633
+ refreshToken: tokenSet.refreshToken,
28634
+ expiresIn: tokenSet.expiresIn,
28635
+ };
28636
+ }
28637
+ const computeRefreshDelay = (expiresIn) => {
28638
+ if (expiresIn !== undefined) {
28639
+ return expiresIn - REFRESH_BEFORE_EXPIRATION_SECONDS > 0
28640
+ ?
28641
+ expiresIn - REFRESH_BEFORE_EXPIRATION_SECONDS
28642
+ : expiresIn;
28643
+ }
28644
+ return DEFAULT_EXPIRATION_TIME_SECONDS;
28645
+ };
28646
+ async function buildAuthenticatedFetch(unauthFetch, accessToken, options) {
28647
+ var _a;
28648
+ let currentAccessToken = accessToken;
28649
+ let latestTimeout;
28650
+ const currentRefreshOptions = options === null || options === void 0 ? void 0 : options.refreshOptions;
28651
+ if (currentRefreshOptions !== undefined) {
28652
+ const proactivelyRefreshToken = async () => {
28653
+ var _a, _b, _c, _d;
28654
+ try {
28655
+ const { accessToken: refreshedAccessToken, refreshToken, expiresIn, } = await refreshAccessToken(currentRefreshOptions, options.dpopKey, options.eventEmitter);
28656
+ currentAccessToken = refreshedAccessToken;
28657
+ if (refreshToken !== undefined) {
28658
+ currentRefreshOptions.refreshToken = refreshToken;
28659
+ }
28660
+ clearTimeout(latestTimeout);
28661
+ latestTimeout = setTimeout(proactivelyRefreshToken, computeRefreshDelay(expiresIn) * 1000);
28662
+ (_a = options.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit(EVENTS.TIMEOUT_SET, latestTimeout);
28663
+ }
28664
+ catch (e) {
28665
+ if (e instanceof OidcProviderError) {
28666
+ (_b = options === null || options === void 0 ? void 0 : options.eventEmitter) === null || _b === void 0 ? void 0 : _b.emit(EVENTS.ERROR, e.error, e.errorDescription);
28667
+ (_c = options === null || options === void 0 ? void 0 : options.eventEmitter) === null || _c === void 0 ? void 0 : _c.emit(EVENTS.SESSION_EXPIRED);
28668
+ }
28669
+ if (e instanceof InvalidResponseError &&
28670
+ e.missingFields.includes("access_token")) {
28671
+ (_d = options === null || options === void 0 ? void 0 : options.eventEmitter) === null || _d === void 0 ? void 0 : _d.emit(EVENTS.SESSION_EXPIRED);
28672
+ }
28673
+ }
28674
+ };
28675
+ latestTimeout = setTimeout(proactivelyRefreshToken, computeRefreshDelay(options.expiresIn) * 1000);
28676
+ (_a = options.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit(EVENTS.TIMEOUT_SET, latestTimeout);
28677
+ }
28678
+ else if (options !== undefined && options.eventEmitter !== undefined) {
28679
+ const expirationTimeout = setTimeout(() => {
28680
+ options.eventEmitter.emit(EVENTS.SESSION_EXPIRED);
28681
+ }, computeRefreshDelay(options.expiresIn) * 1000);
28682
+ options.eventEmitter.emit(EVENTS.TIMEOUT_SET, expirationTimeout);
28683
+ }
28684
+ return async (url, requestInit) => {
28685
+ let response = await makeAuthenticatedRequest(unauthFetch, currentAccessToken, url, requestInit, options === null || options === void 0 ? void 0 : options.dpopKey);
28686
+ const failedButNotExpectedAuthError = !response.ok && !isExpectedAuthError(response.status);
28687
+ if (response.ok || failedButNotExpectedAuthError) {
28688
+ return response;
28689
+ }
28690
+ const hasBeenRedirected = response.url !== url;
28691
+ if (hasBeenRedirected && (options === null || options === void 0 ? void 0 : options.dpopKey) !== undefined) {
28692
+ response = await makeAuthenticatedRequest(unauthFetch, currentAccessToken, response.url, requestInit, options.dpopKey);
28693
+ }
28694
+ return response;
28695
+ };
28322
28696
  }
28323
28697
 
28324
- const StorageUtilityGetResponse = "getResponse";
28325
- const StorageUtilityMock = {
28326
- get: async (key, options) => StorageUtilityGetResponse,
28327
- set: async (key, value) => {
28328
- },
28329
- delete: async (key) => {
28330
- },
28331
- getForUser: async (userId, key, options) => StorageUtilityGetResponse,
28332
- setForUser: async (userId, values, options) => {
28333
- },
28334
- deleteForUser: async (userId, key, options) => {
28335
- },
28336
- deleteAllUserData: async (userId, options) => {
28337
- },
28338
- };
28339
- const mockStorage = (stored) => {
28340
- const store = stored;
28341
- return {
28342
- get: async (key) => {
28343
- if (store[key] === undefined) {
28344
- return undefined;
28345
- }
28346
- if (typeof store[key] === "string") {
28347
- return store[key];
28348
- }
28349
- return JSON.stringify(store[key]);
28350
- },
28351
- set: async (key, value) => {
28352
- store[key] = value;
28353
- },
28354
- delete: async (key) => {
28355
- delete store[key];
28356
- },
28357
- };
28358
- };
28359
- const mockStorageUtility = (stored, isSecure = false) => {
28360
- if (isSecure) {
28361
- return new StorageUtility(mockStorage(stored), mockStorage({}));
28362
- }
28363
- return new StorageUtility(mockStorage({}), mockStorage(stored));
28698
+ const StorageUtilityGetResponse = "getResponse";
28699
+ const StorageUtilityMock = {
28700
+ get: async (key, options) => StorageUtilityGetResponse,
28701
+ set: async (key, value) => {
28702
+ },
28703
+ delete: async (key) => {
28704
+ },
28705
+ getForUser: async (userId, key, options) => StorageUtilityGetResponse,
28706
+ setForUser: async (userId, values, options) => {
28707
+ },
28708
+ deleteForUser: async (userId, key, options) => {
28709
+ },
28710
+ deleteAllUserData: async (userId, options) => {
28711
+ },
28712
+ };
28713
+ const mockStorage = (stored) => {
28714
+ const store = stored;
28715
+ return {
28716
+ get: async (key) => {
28717
+ if (store[key] === undefined) {
28718
+ return undefined;
28719
+ }
28720
+ if (typeof store[key] === "string") {
28721
+ return store[key];
28722
+ }
28723
+ return JSON.stringify(store[key]);
28724
+ },
28725
+ set: async (key, value) => {
28726
+ store[key] = value;
28727
+ },
28728
+ delete: async (key) => {
28729
+ delete store[key];
28730
+ },
28731
+ };
28732
+ };
28733
+ const mockStorageUtility = (stored, isSecure = false) => {
28734
+ if (isSecure) {
28735
+ return new StorageUtility(mockStorage(stored), mockStorage({}));
28736
+ }
28737
+ return new StorageUtility(mockStorage({}), mockStorage(stored));
28364
28738
  };
28365
28739
 
28366
28740
  exports.AggregateHandler = AggregateHandler;
@@ -29584,6 +29958,29 @@ function validate(uuid) {
29584
29958
 
29585
29959
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (validate);
29586
29960
 
29961
+ /***/ }),
29962
+
29963
+ /***/ "./node_modules/@inrupt/universal-fetch/dist/index-browser.js":
29964
+ /*!********************************************************************!*\
29965
+ !*** ./node_modules/@inrupt/universal-fetch/dist/index-browser.js ***!
29966
+ \********************************************************************/
29967
+ /***/ ((__unused_webpack_module, exports) => {
29968
+
29969
+ "use strict";
29970
+
29971
+
29972
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
29973
+
29974
+ var indexBrowser = globalThis.fetch;
29975
+ const { fetch, Response, Request, Headers } = globalThis;
29976
+
29977
+ exports.Headers = Headers;
29978
+ exports.Request = Request;
29979
+ exports.Response = Response;
29980
+ exports["default"] = indexBrowser;
29981
+ exports.fetch = fetch;
29982
+
29983
+
29587
29984
  /***/ }),
29588
29985
 
29589
29986
  /***/ "./node_modules/@noble/curves/_shortw_utils.js":
@@ -60228,518 +60625,541 @@ __webpack_require__.r(__webpack_exports__);
60228
60625
  /* harmony export */ "saveSessionInfoToStorage": () => (/* binding */ saveSessionInfoToStorage)
60229
60626
  /* harmony export */ });
60230
60627
  /* harmony import */ var events__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! events */ "./node_modules/events/events.js");
60231
- /* harmony import */ var cross_fetch__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! cross-fetch */ "./node_modules/cross-fetch/dist/browser-ponyfill.js");
60232
- /* harmony import */ var jose__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! jose */ "./node_modules/jose/dist/browser/index.js");
60628
+ /* harmony import */ var _inrupt_universal_fetch__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @inrupt/universal-fetch */ "./node_modules/@inrupt/universal-fetch/dist/index-browser.mjs");
60629
+ /* harmony import */ var jose__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! jose */ "./node_modules/jose/dist/browser/index.js");
60233
60630
  /* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uuid */ "./node_modules/@inrupt/solid-client-authn-core/node_modules/uuid/dist/esm-browser/v4.js");
60234
60631
 
60235
60632
 
60236
60633
 
60237
60634
 
60238
60635
 
60239
- const SOLID_CLIENT_AUTHN_KEY_PREFIX = "solidClientAuthn:";
60240
- const PREFERRED_SIGNING_ALG = ["ES256", "RS256"];
60241
- const EVENTS = {
60242
- ERROR: "error",
60243
- LOGIN: "login",
60244
- LOGOUT: "logout",
60245
- NEW_REFRESH_TOKEN: "newRefreshToken",
60246
- SESSION_EXPIRED: "sessionExpired",
60247
- SESSION_EXTENDED: "sessionExtended",
60248
- SESSION_RESTORED: "sessionRestore",
60249
- TIMEOUT_SET: "timeoutSet",
60250
- };
60251
- const REFRESH_BEFORE_EXPIRATION_SECONDS = 5;
60252
- const SCOPE_OPENID = "openid";
60253
- const SCOPE_OFFLINE = "offline_access";
60254
- const SCOPE_WEBID = "webid";
60636
+ const SOLID_CLIENT_AUTHN_KEY_PREFIX = "solidClientAuthn:";
60637
+ const PREFERRED_SIGNING_ALG = ["ES256", "RS256"];
60638
+ const EVENTS = {
60639
+ ERROR: "error",
60640
+ LOGIN: "login",
60641
+ LOGOUT: "logout",
60642
+ NEW_REFRESH_TOKEN: "newRefreshToken",
60643
+ SESSION_EXPIRED: "sessionExpired",
60644
+ SESSION_EXTENDED: "sessionExtended",
60645
+ SESSION_RESTORED: "sessionRestore",
60646
+ TIMEOUT_SET: "timeoutSet",
60647
+ };
60648
+ const REFRESH_BEFORE_EXPIRATION_SECONDS = 5;
60649
+ const SCOPE_OPENID = "openid";
60650
+ const SCOPE_OFFLINE = "offline_access";
60651
+ const SCOPE_WEBID = "webid";
60255
60652
  const DEFAULT_SCOPES = [SCOPE_OPENID, SCOPE_OFFLINE, SCOPE_WEBID].join(" ");
60256
60653
 
60257
- const buildProxyHandler = (toExclude, errorMessage) => ({
60258
- get(target, prop, receiver) {
60259
- if (!Object.getOwnPropertyNames(events__WEBPACK_IMPORTED_MODULE_0__.EventEmitter).includes(prop) &&
60260
- Object.getOwnPropertyNames(toExclude).includes(prop)) {
60261
- throw new Error(`${errorMessage}: [${prop}] is not supported`);
60262
- }
60263
- return Reflect.get(target, prop, receiver);
60264
- },
60654
+ const buildProxyHandler = (toExclude, errorMessage) => ({
60655
+ get(target, prop, receiver) {
60656
+ if (!Object.getOwnPropertyNames(events__WEBPACK_IMPORTED_MODULE_0__.EventEmitter).includes(prop) &&
60657
+ Object.getOwnPropertyNames(toExclude).includes(prop)) {
60658
+ throw new Error(`${errorMessage}: [${prop}] is not supported`);
60659
+ }
60660
+ return Reflect.get(target, prop, receiver);
60661
+ },
60265
60662
  });
60266
60663
 
60267
- class AggregateHandler {
60268
- constructor(handleables) {
60269
- this.handleables = handleables;
60270
- }
60271
- async getProperHandler(params) {
60272
- const canHandleList = await Promise.all(this.handleables.map((handleable) => handleable.canHandle(...params)));
60273
- for (let i = 0; i < canHandleList.length; i += 1) {
60274
- if (canHandleList[i]) {
60275
- return this.handleables[i];
60276
- }
60277
- }
60278
- return null;
60279
- }
60280
- async canHandle(...params) {
60281
- return (await this.getProperHandler(params)) !== null;
60282
- }
60283
- async handle(...params) {
60284
- const handler = await this.getProperHandler(params);
60285
- if (handler) {
60286
- return handler.handle(...params);
60287
- }
60288
- throw new Error(`[${this.constructor.name}] cannot find a suitable handler for: ${params
60289
- .map((param) => {
60290
- try {
60291
- return JSON.stringify(param);
60292
- }
60293
- catch (err) {
60294
- return param.toString();
60295
- }
60296
- })
60297
- .join(", ")}`);
60298
- }
60664
+ class AggregateHandler {
60665
+ constructor(handleables) {
60666
+ this.handleables = handleables;
60667
+ }
60668
+ async getProperHandler(params) {
60669
+ const canHandleList = await Promise.all(this.handleables.map((handleable) => handleable.canHandle(...params)));
60670
+ for (let i = 0; i < canHandleList.length; i += 1) {
60671
+ if (canHandleList[i]) {
60672
+ return this.handleables[i];
60673
+ }
60674
+ }
60675
+ return null;
60676
+ }
60677
+ async canHandle(...params) {
60678
+ return (await this.getProperHandler(params)) !== null;
60679
+ }
60680
+ async handle(...params) {
60681
+ const handler = await this.getProperHandler(params);
60682
+ if (handler) {
60683
+ return handler.handle(...params);
60684
+ }
60685
+ throw new Error(`[${this.constructor.name}] cannot find a suitable handler for: ${params
60686
+ .map((param) => {
60687
+ try {
60688
+ return JSON.stringify(param);
60689
+ }
60690
+ catch (err) {
60691
+ return param.toString();
60692
+ }
60693
+ })
60694
+ .join(", ")}`);
60695
+ }
60299
60696
  }
60300
60697
 
60301
- async function fetchJwks(jwksIri, issuerIri) {
60302
- const jwksResponse = await (0,cross_fetch__WEBPACK_IMPORTED_MODULE_1__.fetch)(jwksIri);
60303
- if (jwksResponse.status !== 200) {
60304
- throw new Error(`Could not fetch JWKS for [${issuerIri}] at [${jwksIri}]: ${jwksResponse.status} ${jwksResponse.statusText}`);
60305
- }
60306
- let jwk;
60307
- try {
60308
- jwk = (await jwksResponse.json()).keys[0];
60309
- }
60310
- catch (e) {
60311
- throw new Error(`Malformed JWKS for [${issuerIri}] at [${jwksIri}]: ${e.message}`);
60312
- }
60313
- return jwk;
60314
- }
60315
- async function getWebidFromTokenPayload(idToken, jwksIri, issuerIri, clientId) {
60316
- const jwk = await fetchJwks(jwksIri, issuerIri);
60317
- let payload;
60318
- try {
60319
- const { payload: verifiedPayload } = await (0,jose__WEBPACK_IMPORTED_MODULE_2__.jwtVerify)(idToken, await (0,jose__WEBPACK_IMPORTED_MODULE_2__.importJWK)(jwk), {
60320
- issuer: issuerIri,
60321
- audience: clientId,
60322
- });
60323
- payload = verifiedPayload;
60324
- }
60325
- catch (e) {
60326
- throw new Error(`Token verification failed: ${e.stack}`);
60327
- }
60328
- if (typeof payload.webid === "string") {
60329
- return payload.webid;
60330
- }
60331
- if (typeof payload.sub !== "string") {
60332
- throw new Error(`The token ${JSON.stringify(payload)} is invalid: it has no 'webid' claim and no 'sub' claim.`);
60333
- }
60334
- try {
60335
- new URL(payload.sub);
60336
- return payload.sub;
60337
- }
60338
- catch (e) {
60339
- throw new Error(`The token has no 'webid' claim, and its 'sub' claim of [${payload.sub}] is invalid as a URL - error [${e}].`);
60340
- }
60698
+ async function fetchJwks(jwksIri, issuerIri) {
60699
+ const jwksResponse = await (0,_inrupt_universal_fetch__WEBPACK_IMPORTED_MODULE_2__.fetch)(jwksIri);
60700
+ if (jwksResponse.status !== 200) {
60701
+ throw new Error(`Could not fetch JWKS for [${issuerIri}] at [${jwksIri}]: ${jwksResponse.status} ${jwksResponse.statusText}`);
60702
+ }
60703
+ let jwk;
60704
+ try {
60705
+ jwk = (await jwksResponse.json()).keys[0];
60706
+ }
60707
+ catch (e) {
60708
+ throw new Error(`Malformed JWKS for [${issuerIri}] at [${jwksIri}]: ${e.message}`);
60709
+ }
60710
+ return jwk;
60711
+ }
60712
+ async function getWebidFromTokenPayload(idToken, jwksIri, issuerIri, clientId) {
60713
+ const jwk = await fetchJwks(jwksIri, issuerIri);
60714
+ let payload;
60715
+ try {
60716
+ const { payload: verifiedPayload } = await (0,jose__WEBPACK_IMPORTED_MODULE_1__.jwtVerify)(idToken, await (0,jose__WEBPACK_IMPORTED_MODULE_1__.importJWK)(jwk), {
60717
+ issuer: issuerIri,
60718
+ audience: clientId,
60719
+ });
60720
+ payload = verifiedPayload;
60721
+ }
60722
+ catch (e) {
60723
+ throw new Error(`Token verification failed: ${e.stack}`);
60724
+ }
60725
+ if (typeof payload.webid === "string") {
60726
+ return payload.webid;
60727
+ }
60728
+ if (typeof payload.sub !== "string") {
60729
+ throw new Error(`The token ${JSON.stringify(payload)} is invalid: it has no 'webid' claim and no 'sub' claim.`);
60730
+ }
60731
+ try {
60732
+ new URL(payload.sub);
60733
+ return payload.sub;
60734
+ }
60735
+ catch (e) {
60736
+ throw new Error(`The token has no 'webid' claim, and its 'sub' claim of [${payload.sub}] is invalid as a URL - error [${e}].`);
60737
+ }
60341
60738
  }
60342
60739
 
60343
- function isValidRedirectUrl(redirectUrl) {
60344
- try {
60345
- const urlObject = new URL(redirectUrl);
60346
- return urlObject.hash === "";
60347
- }
60348
- catch (e) {
60349
- return false;
60350
- }
60740
+ function isValidRedirectUrl(redirectUrl) {
60741
+ try {
60742
+ const urlObject = new URL(redirectUrl);
60743
+ return urlObject.hash === "";
60744
+ }
60745
+ catch (e) {
60746
+ return false;
60747
+ }
60351
60748
  }
60352
60749
 
60353
- function isSupportedTokenType(token) {
60354
- return typeof token === "string" && ["DPoP", "Bearer"].includes(token);
60750
+ function isSupportedTokenType(token) {
60751
+ return typeof token === "string" && ["DPoP", "Bearer"].includes(token);
60355
60752
  }
60356
60753
 
60357
60754
  const USER_SESSION_PREFIX = "solidClientAuthenticationUser";
60358
60755
 
60359
- function isValidUrl(url) {
60360
- try {
60361
- new URL(url);
60362
- return true;
60363
- }
60364
- catch (_a) {
60365
- return false;
60366
- }
60367
- }
60368
- function determineSigningAlg(supported, preferred) {
60369
- var _a;
60370
- return ((_a = preferred.find((signingAlg) => {
60371
- return supported.includes(signingAlg);
60372
- })) !== null && _a !== void 0 ? _a : null);
60373
- }
60374
- function determineClientType(options, issuerConfig) {
60375
- if (options.clientId !== undefined && !isValidUrl(options.clientId)) {
60376
- return "static";
60377
- }
60378
- if (issuerConfig.scopesSupported.includes("webid") &&
60379
- options.clientId !== undefined &&
60380
- isValidUrl(options.clientId)) {
60381
- return "solid-oidc";
60382
- }
60383
- return "dynamic";
60384
- }
60385
- async function handleRegistration(options, issuerConfig, storageUtility, clientRegistrar) {
60386
- const clientType = determineClientType(options, issuerConfig);
60387
- if (clientType === "dynamic") {
60388
- return clientRegistrar.getClient({
60389
- sessionId: options.sessionId,
60390
- clientName: options.clientName,
60391
- redirectUrl: options.redirectUrl,
60392
- }, issuerConfig);
60393
- }
60394
- await storageUtility.setForUser(options.sessionId, {
60395
- clientId: options.clientId,
60396
- });
60397
- if (options.clientSecret) {
60398
- await storageUtility.setForUser(options.sessionId, {
60399
- clientSecret: options.clientSecret,
60400
- });
60401
- }
60402
- if (options.clientName) {
60403
- await storageUtility.setForUser(options.sessionId, {
60404
- clientName: options.clientName,
60405
- });
60406
- }
60407
- return {
60408
- clientId: options.clientId,
60409
- clientSecret: options.clientSecret,
60410
- clientName: options.clientName,
60411
- clientType,
60412
- };
60756
+ function isValidUrl(url) {
60757
+ try {
60758
+ new URL(url);
60759
+ return true;
60760
+ }
60761
+ catch (_a) {
60762
+ return false;
60763
+ }
60764
+ }
60765
+ function determineSigningAlg(supported, preferred) {
60766
+ var _a;
60767
+ return ((_a = preferred.find((signingAlg) => {
60768
+ return supported.includes(signingAlg);
60769
+ })) !== null && _a !== void 0 ? _a : null);
60770
+ }
60771
+ function determineClientType(options, issuerConfig) {
60772
+ if (options.clientId !== undefined && !isValidUrl(options.clientId)) {
60773
+ return "static";
60774
+ }
60775
+ if (issuerConfig.scopesSupported.includes("webid") &&
60776
+ options.clientId !== undefined &&
60777
+ isValidUrl(options.clientId)) {
60778
+ return "solid-oidc";
60779
+ }
60780
+ return "dynamic";
60781
+ }
60782
+ async function handleRegistration(options, issuerConfig, storageUtility, clientRegistrar) {
60783
+ const clientType = determineClientType(options, issuerConfig);
60784
+ if (clientType === "dynamic") {
60785
+ return clientRegistrar.getClient({
60786
+ sessionId: options.sessionId,
60787
+ clientName: options.clientName,
60788
+ redirectUrl: options.redirectUrl,
60789
+ }, issuerConfig);
60790
+ }
60791
+ await storageUtility.setForUser(options.sessionId, {
60792
+ clientId: options.clientId,
60793
+ });
60794
+ if (options.clientSecret) {
60795
+ await storageUtility.setForUser(options.sessionId, {
60796
+ clientSecret: options.clientSecret,
60797
+ });
60798
+ }
60799
+ if (options.clientName) {
60800
+ await storageUtility.setForUser(options.sessionId, {
60801
+ clientName: options.clientName,
60802
+ });
60803
+ }
60804
+ return {
60805
+ clientId: options.clientId,
60806
+ clientSecret: options.clientSecret,
60807
+ clientName: options.clientName,
60808
+ clientType,
60809
+ };
60413
60810
  }
60414
60811
 
60415
- async function getSessionIdFromOauthState(storageUtility, oauthState) {
60416
- return storageUtility.getForUser(oauthState, "sessionId");
60417
- }
60418
- async function loadOidcContextFromStorage(sessionId, storageUtility, configFetcher) {
60419
- try {
60420
- const [issuerIri, codeVerifier, storedRedirectIri, dpop] = await Promise.all([
60421
- storageUtility.getForUser(sessionId, "issuer", {
60422
- errorIfNull: true,
60423
- }),
60424
- storageUtility.getForUser(sessionId, "codeVerifier"),
60425
- storageUtility.getForUser(sessionId, "redirectUrl"),
60426
- storageUtility.getForUser(sessionId, "dpop", { errorIfNull: true }),
60427
- ]);
60428
- await storageUtility.deleteForUser(sessionId, "codeVerifier");
60429
- const issuerConfig = await configFetcher.fetchConfig(issuerIri);
60430
- return {
60431
- codeVerifier,
60432
- redirectUrl: storedRedirectIri,
60433
- issuerConfig,
60434
- dpop: dpop === "true",
60435
- };
60436
- }
60437
- catch (e) {
60438
- throw new Error(`Failed to retrieve OIDC context from storage associated with session [${sessionId}]: ${e}`);
60439
- }
60440
- }
60441
- async function saveSessionInfoToStorage(storageUtility, sessionId, webId, isLoggedIn, refreshToken, secure, dpopKey) {
60442
- if (refreshToken !== undefined) {
60443
- await storageUtility.setForUser(sessionId, { refreshToken }, { secure });
60444
- }
60445
- if (webId !== undefined) {
60446
- await storageUtility.setForUser(sessionId, { webId }, { secure });
60447
- }
60448
- if (isLoggedIn !== undefined) {
60449
- await storageUtility.setForUser(sessionId, { isLoggedIn }, { secure });
60450
- }
60451
- if (dpopKey !== undefined) {
60452
- await storageUtility.setForUser(sessionId, {
60453
- publicKey: JSON.stringify(dpopKey.publicKey),
60454
- privateKey: JSON.stringify(await (0,jose__WEBPACK_IMPORTED_MODULE_2__.exportJWK)(dpopKey.privateKey)),
60455
- }, { secure });
60456
- }
60457
- }
60458
- class StorageUtility {
60459
- constructor(secureStorage, insecureStorage) {
60460
- this.secureStorage = secureStorage;
60461
- this.insecureStorage = insecureStorage;
60462
- }
60463
- getKey(userId) {
60464
- return `solidClientAuthenticationUser:${userId}`;
60465
- }
60466
- async getUserData(userId, secure) {
60467
- const stored = await (secure
60468
- ? this.secureStorage
60469
- : this.insecureStorage).get(this.getKey(userId));
60470
- if (stored === undefined) {
60471
- return {};
60472
- }
60473
- try {
60474
- return JSON.parse(stored);
60475
- }
60476
- catch (err) {
60477
- throw new Error(`Data for user [${userId}] in [${secure ? "secure" : "unsecure"}] storage is corrupted - expected valid JSON, but got: ${stored}`);
60478
- }
60479
- }
60480
- async setUserData(userId, data, secure) {
60481
- await (secure ? this.secureStorage : this.insecureStorage).set(this.getKey(userId), JSON.stringify(data));
60482
- }
60483
- async get(key, options) {
60484
- const value = await ((options === null || options === void 0 ? void 0 : options.secure)
60485
- ? this.secureStorage
60486
- : this.insecureStorage).get(key);
60487
- if (value === undefined && (options === null || options === void 0 ? void 0 : options.errorIfNull)) {
60488
- throw new Error(`[${key}] is not stored`);
60489
- }
60490
- return value;
60491
- }
60492
- async set(key, value, options) {
60493
- return ((options === null || options === void 0 ? void 0 : options.secure) ? this.secureStorage : this.insecureStorage).set(key, value);
60494
- }
60495
- async delete(key, options) {
60496
- return ((options === null || options === void 0 ? void 0 : options.secure) ? this.secureStorage : this.insecureStorage).delete(key);
60497
- }
60498
- async getForUser(userId, key, options) {
60499
- const userData = await this.getUserData(userId, options === null || options === void 0 ? void 0 : options.secure);
60500
- let value;
60501
- if (!userData || !userData[key]) {
60502
- value = undefined;
60503
- }
60504
- value = userData[key];
60505
- if (value === undefined && (options === null || options === void 0 ? void 0 : options.errorIfNull)) {
60506
- throw new Error(`Field [${key}] for user [${userId}] is not stored`);
60507
- }
60508
- return value || undefined;
60509
- }
60510
- async setForUser(userId, values, options) {
60511
- let userData;
60512
- try {
60513
- userData = await this.getUserData(userId, options === null || options === void 0 ? void 0 : options.secure);
60514
- }
60515
- catch (_a) {
60516
- userData = {};
60517
- }
60518
- await this.setUserData(userId, { ...userData, ...values }, options === null || options === void 0 ? void 0 : options.secure);
60519
- }
60520
- async deleteForUser(userId, key, options) {
60521
- const userData = await this.getUserData(userId, options === null || options === void 0 ? void 0 : options.secure);
60522
- delete userData[key];
60523
- await this.setUserData(userId, userData, options === null || options === void 0 ? void 0 : options.secure);
60524
- }
60525
- async deleteAllUserData(userId, options) {
60526
- await ((options === null || options === void 0 ? void 0 : options.secure) ? this.secureStorage : this.insecureStorage).delete(this.getKey(userId));
60527
- }
60812
+ async function getSessionIdFromOauthState(storageUtility, oauthState) {
60813
+ return storageUtility.getForUser(oauthState, "sessionId");
60814
+ }
60815
+ async function loadOidcContextFromStorage(sessionId, storageUtility, configFetcher) {
60816
+ try {
60817
+ const [issuerIri, codeVerifier, storedRedirectIri, dpop] = await Promise.all([
60818
+ storageUtility.getForUser(sessionId, "issuer", {
60819
+ errorIfNull: true,
60820
+ }),
60821
+ storageUtility.getForUser(sessionId, "codeVerifier"),
60822
+ storageUtility.getForUser(sessionId, "redirectUrl"),
60823
+ storageUtility.getForUser(sessionId, "dpop", { errorIfNull: true }),
60824
+ ]);
60825
+ await storageUtility.deleteForUser(sessionId, "codeVerifier");
60826
+ const issuerConfig = await configFetcher.fetchConfig(issuerIri);
60827
+ return {
60828
+ codeVerifier,
60829
+ redirectUrl: storedRedirectIri,
60830
+ issuerConfig,
60831
+ dpop: dpop === "true",
60832
+ };
60833
+ }
60834
+ catch (e) {
60835
+ throw new Error(`Failed to retrieve OIDC context from storage associated with session [${sessionId}]: ${e}`);
60836
+ }
60837
+ }
60838
+ async function saveSessionInfoToStorage(storageUtility, sessionId, webId, isLoggedIn, refreshToken, secure, dpopKey) {
60839
+ if (refreshToken !== undefined) {
60840
+ await storageUtility.setForUser(sessionId, { refreshToken }, { secure });
60841
+ }
60842
+ if (webId !== undefined) {
60843
+ await storageUtility.setForUser(sessionId, { webId }, { secure });
60844
+ }
60845
+ if (isLoggedIn !== undefined) {
60846
+ await storageUtility.setForUser(sessionId, { isLoggedIn }, { secure });
60847
+ }
60848
+ if (dpopKey !== undefined) {
60849
+ await storageUtility.setForUser(sessionId, {
60850
+ publicKey: JSON.stringify(dpopKey.publicKey),
60851
+ privateKey: JSON.stringify(await (0,jose__WEBPACK_IMPORTED_MODULE_1__.exportJWK)(dpopKey.privateKey)),
60852
+ }, { secure });
60853
+ }
60854
+ }
60855
+ class StorageUtility {
60856
+ constructor(secureStorage, insecureStorage) {
60857
+ this.secureStorage = secureStorage;
60858
+ this.insecureStorage = insecureStorage;
60859
+ }
60860
+ getKey(userId) {
60861
+ return `solidClientAuthenticationUser:${userId}`;
60862
+ }
60863
+ async getUserData(userId, secure) {
60864
+ const stored = await (secure
60865
+ ? this.secureStorage
60866
+ : this.insecureStorage).get(this.getKey(userId));
60867
+ if (stored === undefined) {
60868
+ return {};
60869
+ }
60870
+ try {
60871
+ return JSON.parse(stored);
60872
+ }
60873
+ catch (err) {
60874
+ throw new Error(`Data for user [${userId}] in [${secure ? "secure" : "unsecure"}] storage is corrupted - expected valid JSON, but got: ${stored}`);
60875
+ }
60876
+ }
60877
+ async setUserData(userId, data, secure) {
60878
+ await (secure ? this.secureStorage : this.insecureStorage).set(this.getKey(userId), JSON.stringify(data));
60879
+ }
60880
+ async get(key, options) {
60881
+ const value = await ((options === null || options === void 0 ? void 0 : options.secure)
60882
+ ? this.secureStorage
60883
+ : this.insecureStorage).get(key);
60884
+ if (value === undefined && (options === null || options === void 0 ? void 0 : options.errorIfNull)) {
60885
+ throw new Error(`[${key}] is not stored`);
60886
+ }
60887
+ return value;
60888
+ }
60889
+ async set(key, value, options) {
60890
+ return ((options === null || options === void 0 ? void 0 : options.secure) ? this.secureStorage : this.insecureStorage).set(key, value);
60891
+ }
60892
+ async delete(key, options) {
60893
+ return ((options === null || options === void 0 ? void 0 : options.secure) ? this.secureStorage : this.insecureStorage).delete(key);
60894
+ }
60895
+ async getForUser(userId, key, options) {
60896
+ const userData = await this.getUserData(userId, options === null || options === void 0 ? void 0 : options.secure);
60897
+ let value;
60898
+ if (!userData || !userData[key]) {
60899
+ value = undefined;
60900
+ }
60901
+ value = userData[key];
60902
+ if (value === undefined && (options === null || options === void 0 ? void 0 : options.errorIfNull)) {
60903
+ throw new Error(`Field [${key}] for user [${userId}] is not stored`);
60904
+ }
60905
+ return value || undefined;
60906
+ }
60907
+ async setForUser(userId, values, options) {
60908
+ let userData;
60909
+ try {
60910
+ userData = await this.getUserData(userId, options === null || options === void 0 ? void 0 : options.secure);
60911
+ }
60912
+ catch (_a) {
60913
+ userData = {};
60914
+ }
60915
+ await this.setUserData(userId, { ...userData, ...values }, options === null || options === void 0 ? void 0 : options.secure);
60916
+ }
60917
+ async deleteForUser(userId, key, options) {
60918
+ const userData = await this.getUserData(userId, options === null || options === void 0 ? void 0 : options.secure);
60919
+ delete userData[key];
60920
+ await this.setUserData(userId, userData, options === null || options === void 0 ? void 0 : options.secure);
60921
+ }
60922
+ async deleteAllUserData(userId, options) {
60923
+ await ((options === null || options === void 0 ? void 0 : options.secure) ? this.secureStorage : this.insecureStorage).delete(this.getKey(userId));
60924
+ }
60528
60925
  }
60529
60926
 
60530
- class InMemoryStorage {
60531
- constructor() {
60532
- this.map = {};
60533
- }
60534
- async get(key) {
60535
- return this.map[key] || undefined;
60536
- }
60537
- async set(key, value) {
60538
- this.map[key] = value;
60539
- }
60540
- async delete(key) {
60541
- delete this.map[key];
60542
- }
60927
+ class InMemoryStorage {
60928
+ constructor() {
60929
+ this.map = {};
60930
+ }
60931
+ async get(key) {
60932
+ return this.map[key] || undefined;
60933
+ }
60934
+ async set(key, value) {
60935
+ this.map[key] = value;
60936
+ }
60937
+ async delete(key) {
60938
+ delete this.map[key];
60939
+ }
60543
60940
  }
60544
60941
 
60545
- class ConfigurationError extends Error {
60546
- constructor(message) {
60547
- super(message);
60548
- }
60942
+ class ConfigurationError extends Error {
60943
+ constructor(message) {
60944
+ super(message);
60945
+ }
60549
60946
  }
60550
60947
 
60551
- class NotImplementedError extends Error {
60552
- constructor(methodName) {
60553
- super(`[${methodName}] is not implemented`);
60554
- }
60948
+ class NotImplementedError extends Error {
60949
+ constructor(methodName) {
60950
+ super(`[${methodName}] is not implemented`);
60951
+ }
60555
60952
  }
60556
60953
 
60557
- class InvalidResponseError extends Error {
60558
- constructor(missingFields) {
60559
- super(`Invalid response from OIDC provider: missing fields ${missingFields}`);
60560
- this.missingFields = missingFields;
60561
- }
60954
+ class InvalidResponseError extends Error {
60955
+ constructor(missingFields) {
60956
+ super(`Invalid response from OIDC provider: missing fields ${missingFields}`);
60957
+ this.missingFields = missingFields;
60958
+ }
60562
60959
  }
60563
60960
 
60564
- class OidcProviderError extends Error {
60565
- constructor(message, error, errorDescription) {
60566
- super(message);
60567
- this.error = error;
60568
- this.errorDescription = errorDescription;
60569
- }
60961
+ class OidcProviderError extends Error {
60962
+ constructor(message, error, errorDescription) {
60963
+ super(message);
60964
+ this.error = error;
60965
+ this.errorDescription = errorDescription;
60966
+ }
60570
60967
  }
60571
60968
 
60572
- function normalizeHTU(audience) {
60573
- const audienceUrl = new URL(audience);
60574
- return new URL(audienceUrl.pathname, audienceUrl.origin).toString();
60575
- }
60576
- async function createDpopHeader(audience, method, dpopKey) {
60577
- return new jose__WEBPACK_IMPORTED_MODULE_2__.SignJWT({
60578
- htu: normalizeHTU(audience),
60579
- htm: method.toUpperCase(),
60580
- jti: (0,uuid__WEBPACK_IMPORTED_MODULE_3__["default"])(),
60581
- })
60582
- .setProtectedHeader({
60583
- alg: PREFERRED_SIGNING_ALG[0],
60584
- jwk: dpopKey.publicKey,
60585
- typ: "dpop+jwt",
60586
- })
60587
- .setIssuedAt()
60588
- .sign(dpopKey.privateKey, {});
60589
- }
60590
- async function generateDpopKeyPair() {
60591
- const { privateKey, publicKey } = await (0,jose__WEBPACK_IMPORTED_MODULE_2__.generateKeyPair)(PREFERRED_SIGNING_ALG[0]);
60592
- const dpopKeyPair = {
60593
- privateKey,
60594
- publicKey: await (0,jose__WEBPACK_IMPORTED_MODULE_2__.exportJWK)(publicKey),
60595
- };
60596
- [dpopKeyPair.publicKey.alg] = PREFERRED_SIGNING_ALG;
60597
- return dpopKeyPair;
60969
+ function normalizeHTU(audience) {
60970
+ const audienceUrl = new URL(audience);
60971
+ return new URL(audienceUrl.pathname, audienceUrl.origin).toString();
60972
+ }
60973
+ async function createDpopHeader(audience, method, dpopKey) {
60974
+ return new jose__WEBPACK_IMPORTED_MODULE_1__.SignJWT({
60975
+ htu: normalizeHTU(audience),
60976
+ htm: method.toUpperCase(),
60977
+ jti: (0,uuid__WEBPACK_IMPORTED_MODULE_3__["default"])(),
60978
+ })
60979
+ .setProtectedHeader({
60980
+ alg: PREFERRED_SIGNING_ALG[0],
60981
+ jwk: dpopKey.publicKey,
60982
+ typ: "dpop+jwt",
60983
+ })
60984
+ .setIssuedAt()
60985
+ .sign(dpopKey.privateKey, {});
60986
+ }
60987
+ async function generateDpopKeyPair() {
60988
+ const { privateKey, publicKey } = await (0,jose__WEBPACK_IMPORTED_MODULE_1__.generateKeyPair)(PREFERRED_SIGNING_ALG[0]);
60989
+ const dpopKeyPair = {
60990
+ privateKey,
60991
+ publicKey: await (0,jose__WEBPACK_IMPORTED_MODULE_1__.exportJWK)(publicKey),
60992
+ };
60993
+ [dpopKeyPair.publicKey.alg] = PREFERRED_SIGNING_ALG;
60994
+ return dpopKeyPair;
60598
60995
  }
60599
60996
 
60600
- const DEFAULT_EXPIRATION_TIME_SECONDS = 600;
60601
- function isExpectedAuthError(statusCode) {
60602
- return [401, 403].includes(statusCode);
60603
- }
60604
- async function buildDpopFetchOptions(targetUrl, authToken, dpopKey, defaultOptions) {
60605
- var _a;
60606
- const headers = new cross_fetch__WEBPACK_IMPORTED_MODULE_1__.Headers(defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.headers);
60607
- headers.set("Authorization", `DPoP ${authToken}`);
60608
- headers.set("DPoP", await createDpopHeader(targetUrl, (_a = defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.method) !== null && _a !== void 0 ? _a : "get", dpopKey));
60609
- return {
60610
- ...defaultOptions,
60611
- headers,
60612
- };
60613
- }
60614
- async function buildAuthenticatedHeaders(targetUrl, authToken, dpopKey, defaultOptions) {
60615
- if (dpopKey !== undefined) {
60616
- return buildDpopFetchOptions(targetUrl, authToken, dpopKey, defaultOptions);
60617
- }
60618
- const headers = new cross_fetch__WEBPACK_IMPORTED_MODULE_1__.Headers(defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.headers);
60619
- headers.set("Authorization", `Bearer ${authToken}`);
60620
- return {
60621
- ...defaultOptions,
60622
- headers,
60623
- };
60624
- }
60625
- async function makeAuthenticatedRequest(unauthFetch, accessToken, url, defaultRequestInit, dpopKey) {
60626
- return unauthFetch(url, await buildAuthenticatedHeaders(url.toString(), accessToken, dpopKey, defaultRequestInit));
60627
- }
60628
- async function refreshAccessToken(refreshOptions, dpopKey, eventEmitter) {
60629
- var _a;
60630
- const tokenSet = await refreshOptions.tokenRefresher.refresh(refreshOptions.sessionId, refreshOptions.refreshToken, dpopKey);
60631
- eventEmitter === null || eventEmitter === void 0 ? void 0 : eventEmitter.emit(EVENTS.SESSION_EXTENDED, (_a = tokenSet.expiresIn) !== null && _a !== void 0 ? _a : DEFAULT_EXPIRATION_TIME_SECONDS);
60632
- if (typeof tokenSet.refreshToken === "string") {
60633
- eventEmitter === null || eventEmitter === void 0 ? void 0 : eventEmitter.emit(EVENTS.NEW_REFRESH_TOKEN, tokenSet.refreshToken);
60634
- }
60635
- return {
60636
- accessToken: tokenSet.accessToken,
60637
- refreshToken: tokenSet.refreshToken,
60638
- expiresIn: tokenSet.expiresIn,
60639
- };
60640
- }
60641
- const computeRefreshDelay = (expiresIn) => {
60642
- if (expiresIn !== undefined) {
60643
- return expiresIn - REFRESH_BEFORE_EXPIRATION_SECONDS > 0
60644
- ?
60645
- expiresIn - REFRESH_BEFORE_EXPIRATION_SECONDS
60646
- : expiresIn;
60647
- }
60648
- return DEFAULT_EXPIRATION_TIME_SECONDS;
60649
- };
60650
- async function buildAuthenticatedFetch(unauthFetch, accessToken, options) {
60651
- var _a;
60652
- let currentAccessToken = accessToken;
60653
- let latestTimeout;
60654
- const currentRefreshOptions = options === null || options === void 0 ? void 0 : options.refreshOptions;
60655
- if (currentRefreshOptions !== undefined) {
60656
- const proactivelyRefreshToken = async () => {
60657
- var _a, _b, _c, _d;
60658
- try {
60659
- const { accessToken: refreshedAccessToken, refreshToken, expiresIn, } = await refreshAccessToken(currentRefreshOptions, options.dpopKey, options.eventEmitter);
60660
- currentAccessToken = refreshedAccessToken;
60661
- if (refreshToken !== undefined) {
60662
- currentRefreshOptions.refreshToken = refreshToken;
60663
- }
60664
- clearTimeout(latestTimeout);
60665
- latestTimeout = setTimeout(proactivelyRefreshToken, computeRefreshDelay(expiresIn) * 1000);
60666
- (_a = options.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit(EVENTS.TIMEOUT_SET, latestTimeout);
60667
- }
60668
- catch (e) {
60669
- if (e instanceof OidcProviderError) {
60670
- (_b = options === null || options === void 0 ? void 0 : options.eventEmitter) === null || _b === void 0 ? void 0 : _b.emit(EVENTS.ERROR, e.error, e.errorDescription);
60671
- (_c = options === null || options === void 0 ? void 0 : options.eventEmitter) === null || _c === void 0 ? void 0 : _c.emit(EVENTS.SESSION_EXPIRED);
60672
- }
60673
- if (e instanceof InvalidResponseError &&
60674
- e.missingFields.includes("access_token")) {
60675
- (_d = options === null || options === void 0 ? void 0 : options.eventEmitter) === null || _d === void 0 ? void 0 : _d.emit(EVENTS.SESSION_EXPIRED);
60676
- }
60677
- }
60678
- };
60679
- latestTimeout = setTimeout(proactivelyRefreshToken, computeRefreshDelay(options.expiresIn) * 1000);
60680
- (_a = options.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit(EVENTS.TIMEOUT_SET, latestTimeout);
60681
- }
60682
- else if (options !== undefined && options.eventEmitter !== undefined) {
60683
- const expirationTimeout = setTimeout(() => {
60684
- options.eventEmitter.emit(EVENTS.SESSION_EXPIRED);
60685
- }, computeRefreshDelay(options.expiresIn) * 1000);
60686
- options.eventEmitter.emit(EVENTS.TIMEOUT_SET, expirationTimeout);
60687
- }
60688
- return async (url, requestInit) => {
60689
- let response = await makeAuthenticatedRequest(unauthFetch, currentAccessToken, url, requestInit, options === null || options === void 0 ? void 0 : options.dpopKey);
60690
- const failedButNotExpectedAuthError = !response.ok && !isExpectedAuthError(response.status);
60691
- if (response.ok || failedButNotExpectedAuthError) {
60692
- return response;
60693
- }
60694
- const hasBeenRedirected = response.url !== url;
60695
- if (hasBeenRedirected && (options === null || options === void 0 ? void 0 : options.dpopKey) !== undefined) {
60696
- response = await makeAuthenticatedRequest(unauthFetch, currentAccessToken, response.url, requestInit, options.dpopKey);
60697
- }
60698
- return response;
60699
- };
60997
+ const DEFAULT_EXPIRATION_TIME_SECONDS = 600;
60998
+ function isExpectedAuthError(statusCode) {
60999
+ return [401, 403].includes(statusCode);
61000
+ }
61001
+ async function buildDpopFetchOptions(targetUrl, authToken, dpopKey, defaultOptions) {
61002
+ var _a;
61003
+ const headers = new _inrupt_universal_fetch__WEBPACK_IMPORTED_MODULE_2__.Headers(defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.headers);
61004
+ headers.set("Authorization", `DPoP ${authToken}`);
61005
+ headers.set("DPoP", await createDpopHeader(targetUrl, (_a = defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.method) !== null && _a !== void 0 ? _a : "get", dpopKey));
61006
+ return {
61007
+ ...defaultOptions,
61008
+ headers,
61009
+ };
61010
+ }
61011
+ async function buildAuthenticatedHeaders(targetUrl, authToken, dpopKey, defaultOptions) {
61012
+ if (dpopKey !== undefined) {
61013
+ return buildDpopFetchOptions(targetUrl, authToken, dpopKey, defaultOptions);
61014
+ }
61015
+ const headers = new _inrupt_universal_fetch__WEBPACK_IMPORTED_MODULE_2__.Headers(defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.headers);
61016
+ headers.set("Authorization", `Bearer ${authToken}`);
61017
+ return {
61018
+ ...defaultOptions,
61019
+ headers,
61020
+ };
61021
+ }
61022
+ async function makeAuthenticatedRequest(unauthFetch, accessToken, url, defaultRequestInit, dpopKey) {
61023
+ return unauthFetch(url, await buildAuthenticatedHeaders(url.toString(), accessToken, dpopKey, defaultRequestInit));
61024
+ }
61025
+ async function refreshAccessToken(refreshOptions, dpopKey, eventEmitter) {
61026
+ var _a;
61027
+ const tokenSet = await refreshOptions.tokenRefresher.refresh(refreshOptions.sessionId, refreshOptions.refreshToken, dpopKey);
61028
+ eventEmitter === null || eventEmitter === void 0 ? void 0 : eventEmitter.emit(EVENTS.SESSION_EXTENDED, (_a = tokenSet.expiresIn) !== null && _a !== void 0 ? _a : DEFAULT_EXPIRATION_TIME_SECONDS);
61029
+ if (typeof tokenSet.refreshToken === "string") {
61030
+ eventEmitter === null || eventEmitter === void 0 ? void 0 : eventEmitter.emit(EVENTS.NEW_REFRESH_TOKEN, tokenSet.refreshToken);
61031
+ }
61032
+ return {
61033
+ accessToken: tokenSet.accessToken,
61034
+ refreshToken: tokenSet.refreshToken,
61035
+ expiresIn: tokenSet.expiresIn,
61036
+ };
61037
+ }
61038
+ const computeRefreshDelay = (expiresIn) => {
61039
+ if (expiresIn !== undefined) {
61040
+ return expiresIn - REFRESH_BEFORE_EXPIRATION_SECONDS > 0
61041
+ ?
61042
+ expiresIn - REFRESH_BEFORE_EXPIRATION_SECONDS
61043
+ : expiresIn;
61044
+ }
61045
+ return DEFAULT_EXPIRATION_TIME_SECONDS;
61046
+ };
61047
+ async function buildAuthenticatedFetch(unauthFetch, accessToken, options) {
61048
+ var _a;
61049
+ let currentAccessToken = accessToken;
61050
+ let latestTimeout;
61051
+ const currentRefreshOptions = options === null || options === void 0 ? void 0 : options.refreshOptions;
61052
+ if (currentRefreshOptions !== undefined) {
61053
+ const proactivelyRefreshToken = async () => {
61054
+ var _a, _b, _c, _d;
61055
+ try {
61056
+ const { accessToken: refreshedAccessToken, refreshToken, expiresIn, } = await refreshAccessToken(currentRefreshOptions, options.dpopKey, options.eventEmitter);
61057
+ currentAccessToken = refreshedAccessToken;
61058
+ if (refreshToken !== undefined) {
61059
+ currentRefreshOptions.refreshToken = refreshToken;
61060
+ }
61061
+ clearTimeout(latestTimeout);
61062
+ latestTimeout = setTimeout(proactivelyRefreshToken, computeRefreshDelay(expiresIn) * 1000);
61063
+ (_a = options.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit(EVENTS.TIMEOUT_SET, latestTimeout);
61064
+ }
61065
+ catch (e) {
61066
+ if (e instanceof OidcProviderError) {
61067
+ (_b = options === null || options === void 0 ? void 0 : options.eventEmitter) === null || _b === void 0 ? void 0 : _b.emit(EVENTS.ERROR, e.error, e.errorDescription);
61068
+ (_c = options === null || options === void 0 ? void 0 : options.eventEmitter) === null || _c === void 0 ? void 0 : _c.emit(EVENTS.SESSION_EXPIRED);
61069
+ }
61070
+ if (e instanceof InvalidResponseError &&
61071
+ e.missingFields.includes("access_token")) {
61072
+ (_d = options === null || options === void 0 ? void 0 : options.eventEmitter) === null || _d === void 0 ? void 0 : _d.emit(EVENTS.SESSION_EXPIRED);
61073
+ }
61074
+ }
61075
+ };
61076
+ latestTimeout = setTimeout(proactivelyRefreshToken, computeRefreshDelay(options.expiresIn) * 1000);
61077
+ (_a = options.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit(EVENTS.TIMEOUT_SET, latestTimeout);
61078
+ }
61079
+ else if (options !== undefined && options.eventEmitter !== undefined) {
61080
+ const expirationTimeout = setTimeout(() => {
61081
+ options.eventEmitter.emit(EVENTS.SESSION_EXPIRED);
61082
+ }, computeRefreshDelay(options.expiresIn) * 1000);
61083
+ options.eventEmitter.emit(EVENTS.TIMEOUT_SET, expirationTimeout);
61084
+ }
61085
+ return async (url, requestInit) => {
61086
+ let response = await makeAuthenticatedRequest(unauthFetch, currentAccessToken, url, requestInit, options === null || options === void 0 ? void 0 : options.dpopKey);
61087
+ const failedButNotExpectedAuthError = !response.ok && !isExpectedAuthError(response.status);
61088
+ if (response.ok || failedButNotExpectedAuthError) {
61089
+ return response;
61090
+ }
61091
+ const hasBeenRedirected = response.url !== url;
61092
+ if (hasBeenRedirected && (options === null || options === void 0 ? void 0 : options.dpopKey) !== undefined) {
61093
+ response = await makeAuthenticatedRequest(unauthFetch, currentAccessToken, response.url, requestInit, options.dpopKey);
61094
+ }
61095
+ return response;
61096
+ };
60700
61097
  }
60701
61098
 
60702
- const StorageUtilityGetResponse = "getResponse";
60703
- const StorageUtilityMock = {
60704
- get: async (key, options) => StorageUtilityGetResponse,
60705
- set: async (key, value) => {
60706
- },
60707
- delete: async (key) => {
60708
- },
60709
- getForUser: async (userId, key, options) => StorageUtilityGetResponse,
60710
- setForUser: async (userId, values, options) => {
60711
- },
60712
- deleteForUser: async (userId, key, options) => {
60713
- },
60714
- deleteAllUserData: async (userId, options) => {
60715
- },
60716
- };
60717
- const mockStorage = (stored) => {
60718
- const store = stored;
60719
- return {
60720
- get: async (key) => {
60721
- if (store[key] === undefined) {
60722
- return undefined;
60723
- }
60724
- if (typeof store[key] === "string") {
60725
- return store[key];
60726
- }
60727
- return JSON.stringify(store[key]);
60728
- },
60729
- set: async (key, value) => {
60730
- store[key] = value;
60731
- },
60732
- delete: async (key) => {
60733
- delete store[key];
60734
- },
60735
- };
60736
- };
60737
- const mockStorageUtility = (stored, isSecure = false) => {
60738
- if (isSecure) {
60739
- return new StorageUtility(mockStorage(stored), mockStorage({}));
60740
- }
60741
- return new StorageUtility(mockStorage({}), mockStorage(stored));
61099
+ const StorageUtilityGetResponse = "getResponse";
61100
+ const StorageUtilityMock = {
61101
+ get: async (key, options) => StorageUtilityGetResponse,
61102
+ set: async (key, value) => {
61103
+ },
61104
+ delete: async (key) => {
61105
+ },
61106
+ getForUser: async (userId, key, options) => StorageUtilityGetResponse,
61107
+ setForUser: async (userId, values, options) => {
61108
+ },
61109
+ deleteForUser: async (userId, key, options) => {
61110
+ },
61111
+ deleteAllUserData: async (userId, options) => {
61112
+ },
60742
61113
  };
61114
+ const mockStorage = (stored) => {
61115
+ const store = stored;
61116
+ return {
61117
+ get: async (key) => {
61118
+ if (store[key] === undefined) {
61119
+ return undefined;
61120
+ }
61121
+ if (typeof store[key] === "string") {
61122
+ return store[key];
61123
+ }
61124
+ return JSON.stringify(store[key]);
61125
+ },
61126
+ set: async (key, value) => {
61127
+ store[key] = value;
61128
+ },
61129
+ delete: async (key) => {
61130
+ delete store[key];
61131
+ },
61132
+ };
61133
+ };
61134
+ const mockStorageUtility = (stored, isSecure = false) => {
61135
+ if (isSecure) {
61136
+ return new StorageUtility(mockStorage(stored), mockStorage({}));
61137
+ }
61138
+ return new StorageUtility(mockStorage({}), mockStorage(stored));
61139
+ };
61140
+
61141
+
61142
+
61143
+
61144
+ /***/ }),
61145
+
61146
+ /***/ "./node_modules/@inrupt/universal-fetch/dist/index-browser.mjs":
61147
+ /*!*********************************************************************!*\
61148
+ !*** ./node_modules/@inrupt/universal-fetch/dist/index-browser.mjs ***!
61149
+ \*********************************************************************/
61150
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
61151
+
61152
+ "use strict";
61153
+ __webpack_require__.r(__webpack_exports__);
61154
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
61155
+ /* harmony export */ "Headers": () => (/* binding */ Headers),
61156
+ /* harmony export */ "Request": () => (/* binding */ Request),
61157
+ /* harmony export */ "Response": () => (/* binding */ Response),
61158
+ /* harmony export */ "default": () => (/* binding */ indexBrowser),
61159
+ /* harmony export */ "fetch": () => (/* binding */ fetch)
61160
+ /* harmony export */ });
61161
+ var indexBrowser = globalThis.fetch;
61162
+ const { fetch, Response, Request, Headers } = globalThis;
60743
61163
 
60744
61164
 
60745
61165
 
@@ -61811,14 +62231,17 @@ __webpack_require__.r(__webpack_exports__);
61811
62231
  /* harmony export */ "createRemoteJWKSet": () => (/* binding */ createRemoteJWKSet)
61812
62232
  /* harmony export */ });
61813
62233
  /* harmony import */ var _runtime_fetch_jwks_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../runtime/fetch_jwks.js */ "./node_modules/jose/dist/browser/runtime/fetch_jwks.js");
61814
- /* harmony import */ var _runtime_env_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../runtime/env.js */ "./node_modules/jose/dist/browser/runtime/env.js");
61815
- /* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
61816
- /* harmony import */ var _local_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./local.js */ "./node_modules/jose/dist/browser/jwks/local.js");
61817
-
62234
+ /* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
62235
+ /* harmony import */ var _local_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./local.js */ "./node_modules/jose/dist/browser/jwks/local.js");
61818
62236
 
61819
62237
 
61820
62238
 
61821
- class RemoteJWKSet extends _local_js__WEBPACK_IMPORTED_MODULE_3__.LocalJWKSet {
62239
+ function isCloudflareWorkers() {
62240
+ return (typeof WebSocketPair !== 'undefined' ||
62241
+ (typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers') ||
62242
+ (typeof EdgeRuntime !== 'undefined' && EdgeRuntime === 'vercel'));
62243
+ }
62244
+ class RemoteJWKSet extends _local_js__WEBPACK_IMPORTED_MODULE_2__.LocalJWKSet {
61822
62245
  constructor(url, options) {
61823
62246
  super({ keys: [] });
61824
62247
  this._jwks = undefined;
@@ -61851,7 +62274,7 @@ class RemoteJWKSet extends _local_js__WEBPACK_IMPORTED_MODULE_3__.LocalJWKSet {
61851
62274
  return await super.getKey(protectedHeader, token);
61852
62275
  }
61853
62276
  catch (err) {
61854
- if (err instanceof _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JWKSNoMatchingKey) {
62277
+ if (err instanceof _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JWKSNoMatchingKey) {
61855
62278
  if (this.coolingDown() === false) {
61856
62279
  await this.reload();
61857
62280
  return super.getKey(protectedHeader, token);
@@ -61861,13 +62284,13 @@ class RemoteJWKSet extends _local_js__WEBPACK_IMPORTED_MODULE_3__.LocalJWKSet {
61861
62284
  }
61862
62285
  }
61863
62286
  async reload() {
61864
- if (this._pendingFetch && (0,_runtime_env_js__WEBPACK_IMPORTED_MODULE_1__.isCloudflareWorkers)()) {
62287
+ if (this._pendingFetch && isCloudflareWorkers()) {
61865
62288
  this._pendingFetch = undefined;
61866
62289
  }
61867
62290
  this._pendingFetch || (this._pendingFetch = (0,_runtime_fetch_jwks_js__WEBPACK_IMPORTED_MODULE_0__["default"])(this._url, this._timeoutDuration, this._options)
61868
62291
  .then((json) => {
61869
- if (!(0,_local_js__WEBPACK_IMPORTED_MODULE_3__.isJWKSLike)(json)) {
61870
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JWKSInvalid('JSON Web Key Set malformed');
62292
+ if (!(0,_local_js__WEBPACK_IMPORTED_MODULE_2__.isJWKSLike)(json)) {
62293
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JWKSInvalid('JSON Web Key Set malformed');
61871
62294
  }
61872
62295
  this._jwks = { keys: json.keys };
61873
62296
  this._jwksTimestamp = Date.now();
@@ -63055,8 +63478,6 @@ __webpack_require__.r(__webpack_exports__);
63055
63478
  /* harmony export */ "checkEncCryptoKey": () => (/* binding */ checkEncCryptoKey),
63056
63479
  /* harmony export */ "checkSigCryptoKey": () => (/* binding */ checkSigCryptoKey)
63057
63480
  /* harmony export */ });
63058
- /* harmony import */ var _runtime_env_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../runtime/env.js */ "./node_modules/jose/dist/browser/runtime/env.js");
63059
-
63060
63481
  function unusable(name, prop = 'algorithm.name') {
63061
63482
  return new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
63062
63483
  }
@@ -63131,11 +63552,6 @@ function checkSigCryptoKey(key, alg, ...usages) {
63131
63552
  }
63132
63553
  case 'EdDSA': {
63133
63554
  if (key.algorithm.name !== 'Ed25519' && key.algorithm.name !== 'Ed448') {
63134
- if ((0,_runtime_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)()) {
63135
- if (isAlgorithm(key.algorithm, 'NODE-ED25519'))
63136
- break;
63137
- throw unusable('Ed25519, Ed448, or NODE-ED25519');
63138
- }
63139
63555
  throw unusable('Ed25519 or Ed448');
63140
63556
  }
63141
63557
  break;
@@ -63966,14 +64382,12 @@ __webpack_require__.r(__webpack_exports__);
63966
64382
  /* harmony export */ "toPKCS8": () => (/* binding */ toPKCS8),
63967
64383
  /* harmony export */ "toSPKI": () => (/* binding */ toSPKI)
63968
64384
  /* harmony export */ });
63969
- /* harmony import */ var _env_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./env.js */ "./node_modules/jose/dist/browser/runtime/env.js");
63970
- /* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webcrypto.js */ "./node_modules/jose/dist/browser/runtime/webcrypto.js");
63971
- /* harmony import */ var _lib_invalid_key_input_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../lib/invalid_key_input.js */ "./node_modules/jose/dist/browser/lib/invalid_key_input.js");
63972
- /* harmony import */ var _base64url_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./base64url.js */ "./node_modules/jose/dist/browser/runtime/base64url.js");
63973
- /* harmony import */ var _lib_format_pem_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../lib/format_pem.js */ "./node_modules/jose/dist/browser/lib/format_pem.js");
63974
- /* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
63975
- /* harmony import */ var _is_key_like_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./is_key_like.js */ "./node_modules/jose/dist/browser/runtime/is_key_like.js");
63976
-
64385
+ /* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webcrypto.js */ "./node_modules/jose/dist/browser/runtime/webcrypto.js");
64386
+ /* harmony import */ var _lib_invalid_key_input_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../lib/invalid_key_input.js */ "./node_modules/jose/dist/browser/lib/invalid_key_input.js");
64387
+ /* harmony import */ var _base64url_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base64url.js */ "./node_modules/jose/dist/browser/runtime/base64url.js");
64388
+ /* harmony import */ var _lib_format_pem_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../lib/format_pem.js */ "./node_modules/jose/dist/browser/lib/format_pem.js");
64389
+ /* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
64390
+ /* harmony import */ var _is_key_like_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./is_key_like.js */ "./node_modules/jose/dist/browser/runtime/is_key_like.js");
63977
64391
 
63978
64392
 
63979
64393
 
@@ -63981,8 +64395,8 @@ __webpack_require__.r(__webpack_exports__);
63981
64395
 
63982
64396
 
63983
64397
  const genericExport = async (keyType, keyFormat, key) => {
63984
- if (!(0,_webcrypto_js__WEBPACK_IMPORTED_MODULE_1__.isCryptoKey)(key)) {
63985
- throw new TypeError((0,_lib_invalid_key_input_js__WEBPACK_IMPORTED_MODULE_2__["default"])(key, ..._is_key_like_js__WEBPACK_IMPORTED_MODULE_6__.types));
64398
+ if (!(0,_webcrypto_js__WEBPACK_IMPORTED_MODULE_0__.isCryptoKey)(key)) {
64399
+ throw new TypeError((0,_lib_invalid_key_input_js__WEBPACK_IMPORTED_MODULE_1__["default"])(key, ..._is_key_like_js__WEBPACK_IMPORTED_MODULE_5__.types));
63986
64400
  }
63987
64401
  if (!key.extractable) {
63988
64402
  throw new TypeError('CryptoKey is not extractable');
@@ -63990,7 +64404,7 @@ const genericExport = async (keyType, keyFormat, key) => {
63990
64404
  if (key.type !== keyType) {
63991
64405
  throw new TypeError(`key is not a ${keyType} key`);
63992
64406
  }
63993
- return (0,_lib_format_pem_js__WEBPACK_IMPORTED_MODULE_4__["default"])((0,_base64url_js__WEBPACK_IMPORTED_MODULE_3__.encodeBase64)(new Uint8Array(await _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.exportKey(keyFormat, key))), `${keyType.toUpperCase()} KEY`);
64407
+ return (0,_lib_format_pem_js__WEBPACK_IMPORTED_MODULE_3__["default"])((0,_base64url_js__WEBPACK_IMPORTED_MODULE_2__.encodeBase64)(new Uint8Array(await _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__["default"].subtle.exportKey(keyFormat, key))), `${keyType.toUpperCase()} KEY`);
63994
64408
  };
63995
64409
  const toSPKI = (key) => {
63996
64410
  return genericExport('public', 'spki', key);
@@ -64028,11 +64442,11 @@ const getNamedCurve = (keyData) => {
64028
64442
  case findOid(keyData, [0x2b, 0x65, 0x71]):
64029
64443
  return 'Ed448';
64030
64444
  default:
64031
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_5__.JOSENotSupported('Invalid or unsupported EC Key Curve or OKP Key Sub Type');
64445
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_4__.JOSENotSupported('Invalid or unsupported EC Key Curve or OKP Key Sub Type');
64032
64446
  }
64033
64447
  };
64034
64448
  const genericImport = async (replace, keyFormat, pem, alg, options) => {
64035
- var _a, _b;
64449
+ var _a;
64036
64450
  let algorithm;
64037
64451
  let keyUsages;
64038
64452
  const keyData = new Uint8Array(atob(pem.replace(replace, ''))
@@ -64088,20 +64502,9 @@ const genericImport = async (replace, keyFormat, pem, alg, options) => {
64088
64502
  keyUsages = isPublic ? ['verify'] : ['sign'];
64089
64503
  break;
64090
64504
  default:
64091
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_5__.JOSENotSupported('Invalid or unsupported "alg" (Algorithm) value');
64092
- }
64093
- try {
64094
- return await _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.importKey(keyFormat, keyData, algorithm, (_a = options === null || options === void 0 ? void 0 : options.extractable) !== null && _a !== void 0 ? _a : false, keyUsages);
64095
- }
64096
- catch (err) {
64097
- if (algorithm.name === 'Ed25519' &&
64098
- (err === null || err === void 0 ? void 0 : err.name) === 'NotSupportedError' &&
64099
- (0,_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)()) {
64100
- algorithm = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
64101
- return await _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.importKey(keyFormat, keyData, algorithm, (_b = options === null || options === void 0 ? void 0 : options.extractable) !== null && _b !== void 0 ? _b : false, keyUsages);
64102
- }
64103
- throw err;
64505
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_4__.JOSENotSupported('Invalid or unsupported "alg" (Algorithm) value');
64104
64506
  }
64507
+ return _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__["default"].subtle.importKey(keyFormat, keyData, algorithm, (_a = options === null || options === void 0 ? void 0 : options.extractable) !== null && _a !== void 0 ? _a : false, keyUsages);
64105
64508
  };
64106
64509
  const fromPKCS8 = (pem, alg, options) => {
64107
64510
  return genericImport(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g, 'pkcs8', pem, alg, options);
@@ -64170,12 +64573,12 @@ function parseElement(bytes) {
64170
64573
  }
64171
64574
  function spkiFromX509(buf) {
64172
64575
  const tbsCertificate = getElement(getElement(parseElement(buf).contents)[0].contents);
64173
- return (0,_base64url_js__WEBPACK_IMPORTED_MODULE_3__.encodeBase64)(tbsCertificate[tbsCertificate[0].raw[0] === 0xa0 ? 6 : 5].raw);
64576
+ return (0,_base64url_js__WEBPACK_IMPORTED_MODULE_2__.encodeBase64)(tbsCertificate[tbsCertificate[0].raw[0] === 0xa0 ? 6 : 5].raw);
64174
64577
  }
64175
64578
  function getSPKI(x509) {
64176
64579
  const pem = x509.replace(/(?:-----(?:BEGIN|END) CERTIFICATE-----|\s)/g, '');
64177
- const raw = (0,_base64url_js__WEBPACK_IMPORTED_MODULE_3__.decodeBase64)(pem);
64178
- return (0,_lib_format_pem_js__WEBPACK_IMPORTED_MODULE_4__["default"])(spkiFromX509(raw), 'PUBLIC KEY');
64580
+ const raw = (0,_base64url_js__WEBPACK_IMPORTED_MODULE_2__.decodeBase64)(pem);
64581
+ return (0,_lib_format_pem_js__WEBPACK_IMPORTED_MODULE_3__["default"])(spkiFromX509(raw), 'PUBLIC KEY');
64179
64582
  }
64180
64583
  const fromX509 = (pem, alg, options) => {
64181
64584
  let spki;
@@ -64603,26 +65006,6 @@ const encrypt = async (enc, plaintext, cek, iv, aad) => {
64603
65006
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (encrypt);
64604
65007
 
64605
65008
 
64606
- /***/ }),
64607
-
64608
- /***/ "./node_modules/jose/dist/browser/runtime/env.js":
64609
- /*!*******************************************************!*\
64610
- !*** ./node_modules/jose/dist/browser/runtime/env.js ***!
64611
- \*******************************************************/
64612
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
64613
-
64614
- "use strict";
64615
- __webpack_require__.r(__webpack_exports__);
64616
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
64617
- /* harmony export */ "isCloudflareWorkers": () => (/* binding */ isCloudflareWorkers)
64618
- /* harmony export */ });
64619
- function isCloudflareWorkers() {
64620
- return (typeof WebSocketPair !== 'undefined' ||
64621
- (typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers') ||
64622
- (typeof EdgeRuntime !== 'undefined' && EdgeRuntime === 'vercel'));
64623
- }
64624
-
64625
-
64626
65009
  /***/ }),
64627
65010
 
64628
65011
  /***/ "./node_modules/jose/dist/browser/runtime/fetch_jwks.js":
@@ -64687,11 +65070,9 @@ __webpack_require__.r(__webpack_exports__);
64687
65070
  /* harmony export */ "generateKeyPair": () => (/* binding */ generateKeyPair),
64688
65071
  /* harmony export */ "generateSecret": () => (/* binding */ generateSecret)
64689
65072
  /* harmony export */ });
64690
- /* harmony import */ var _env_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./env.js */ "./node_modules/jose/dist/browser/runtime/env.js");
64691
- /* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webcrypto.js */ "./node_modules/jose/dist/browser/runtime/webcrypto.js");
64692
- /* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
64693
- /* harmony import */ var _random_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./random.js */ "./node_modules/jose/dist/browser/runtime/random.js");
64694
-
65073
+ /* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webcrypto.js */ "./node_modules/jose/dist/browser/runtime/webcrypto.js");
65074
+ /* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
65075
+ /* harmony import */ var _random_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./random.js */ "./node_modules/jose/dist/browser/runtime/random.js");
64695
65076
 
64696
65077
 
64697
65078
 
@@ -64712,7 +65093,7 @@ async function generateSecret(alg, options) {
64712
65093
  case 'A192CBC-HS384':
64713
65094
  case 'A256CBC-HS512':
64714
65095
  length = parseInt(alg.slice(-3), 10);
64715
- return (0,_random_js__WEBPACK_IMPORTED_MODULE_3__["default"])(new Uint8Array(length >> 3));
65096
+ return (0,_random_js__WEBPACK_IMPORTED_MODULE_2__["default"])(new Uint8Array(length >> 3));
64716
65097
  case 'A128KW':
64717
65098
  case 'A192KW':
64718
65099
  case 'A256KW':
@@ -64731,20 +65112,20 @@ async function generateSecret(alg, options) {
64731
65112
  keyUsages = ['encrypt', 'decrypt'];
64732
65113
  break;
64733
65114
  default:
64734
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
65115
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
64735
65116
  }
64736
- return _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.generateKey(algorithm, (_a = options === null || options === void 0 ? void 0 : options.extractable) !== null && _a !== void 0 ? _a : false, keyUsages);
65117
+ return _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__["default"].subtle.generateKey(algorithm, (_a = options === null || options === void 0 ? void 0 : options.extractable) !== null && _a !== void 0 ? _a : false, keyUsages);
64737
65118
  }
64738
65119
  function getModulusLengthOption(options) {
64739
65120
  var _a;
64740
65121
  const modulusLength = (_a = options === null || options === void 0 ? void 0 : options.modulusLength) !== null && _a !== void 0 ? _a : 2048;
64741
65122
  if (typeof modulusLength !== 'number' || modulusLength < 2048) {
64742
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported('Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used');
65123
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used');
64743
65124
  }
64744
65125
  return modulusLength;
64745
65126
  }
64746
65127
  async function generateKeyPair(alg, options) {
64747
- var _a, _b, _c, _d;
65128
+ var _a, _b, _c;
64748
65129
  let algorithm;
64749
65130
  let keyUsages;
64750
65131
  switch (alg) {
@@ -64803,7 +65184,7 @@ async function generateKeyPair(alg, options) {
64803
65184
  algorithm = { name: crv };
64804
65185
  break;
64805
65186
  default:
64806
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported('Invalid or unsupported crv option provided');
65187
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported crv option provided');
64807
65188
  }
64808
65189
  break;
64809
65190
  case 'ECDH-ES':
@@ -64824,25 +65205,14 @@ async function generateKeyPair(alg, options) {
64824
65205
  algorithm = { name: crv };
64825
65206
  break;
64826
65207
  default:
64827
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported('Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, X25519, and X448');
65208
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, X25519, and X448');
64828
65209
  }
64829
65210
  break;
64830
65211
  }
64831
65212
  default:
64832
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
64833
- }
64834
- try {
64835
- return (await _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.generateKey(algorithm, (_c = options === null || options === void 0 ? void 0 : options.extractable) !== null && _c !== void 0 ? _c : false, keyUsages));
64836
- }
64837
- catch (err) {
64838
- if (algorithm.name === 'Ed25519' &&
64839
- (err === null || err === void 0 ? void 0 : err.name) === 'NotSupportedError' &&
64840
- (0,_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)()) {
64841
- algorithm = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
64842
- return (await _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.generateKey(algorithm, (_d = options === null || options === void 0 ? void 0 : options.extractable) !== null && _d !== void 0 ? _d : false, keyUsages));
64843
- }
64844
- throw err;
65213
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
64845
65214
  }
65215
+ return (_webcrypto_js__WEBPACK_IMPORTED_MODULE_0__["default"].subtle.generateKey(algorithm, (_c = options === null || options === void 0 ? void 0 : options.extractable) !== null && _c !== void 0 ? _c : false, keyUsages));
64846
65216
  }
64847
65217
 
64848
65218
 
@@ -64917,11 +65287,9 @@ __webpack_require__.r(__webpack_exports__);
64917
65287
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
64918
65288
  /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
64919
65289
  /* harmony export */ });
64920
- /* harmony import */ var _env_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./env.js */ "./node_modules/jose/dist/browser/runtime/env.js");
64921
- /* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webcrypto.js */ "./node_modules/jose/dist/browser/runtime/webcrypto.js");
64922
- /* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
64923
- /* harmony import */ var _base64url_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./base64url.js */ "./node_modules/jose/dist/browser/runtime/base64url.js");
64924
-
65290
+ /* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webcrypto.js */ "./node_modules/jose/dist/browser/runtime/webcrypto.js");
65291
+ /* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
65292
+ /* harmony import */ var _base64url_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base64url.js */ "./node_modules/jose/dist/browser/runtime/base64url.js");
64925
65293
 
64926
65294
 
64927
65295
 
@@ -64940,7 +65308,7 @@ function subtleMapping(jwk) {
64940
65308
  case 'A128CBC-HS256':
64941
65309
  case 'A192CBC-HS384':
64942
65310
  case 'A256CBC-HS512':
64943
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported(`${jwk.alg} keys cannot be imported as CryptoKey instances`);
65311
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported(`${jwk.alg} keys cannot be imported as CryptoKey instances`);
64944
65312
  case 'A128GCM':
64945
65313
  case 'A192GCM':
64946
65314
  case 'A256GCM':
@@ -64963,7 +65331,7 @@ function subtleMapping(jwk) {
64963
65331
  keyUsages = ['deriveBits'];
64964
65332
  break;
64965
65333
  default:
64966
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
65334
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
64967
65335
  }
64968
65336
  break;
64969
65337
  }
@@ -64992,7 +65360,7 @@ function subtleMapping(jwk) {
64992
65360
  keyUsages = jwk.d ? ['decrypt', 'unwrapKey'] : ['encrypt', 'wrapKey'];
64993
65361
  break;
64994
65362
  default:
64995
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
65363
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
64996
65364
  }
64997
65365
  break;
64998
65366
  }
@@ -65018,7 +65386,7 @@ function subtleMapping(jwk) {
65018
65386
  keyUsages = jwk.d ? ['deriveBits'] : [];
65019
65387
  break;
65020
65388
  default:
65021
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
65389
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
65022
65390
  }
65023
65391
  break;
65024
65392
  }
@@ -65036,12 +65404,12 @@ function subtleMapping(jwk) {
65036
65404
  keyUsages = jwk.d ? ['deriveBits'] : [];
65037
65405
  break;
65038
65406
  default:
65039
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
65407
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
65040
65408
  }
65041
65409
  break;
65042
65410
  }
65043
65411
  default:
65044
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
65412
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
65045
65413
  }
65046
65414
  return { algorithm, keyUsages };
65047
65415
  }
@@ -65057,23 +65425,12 @@ const parse = async (jwk) => {
65057
65425
  (_b = jwk.key_ops) !== null && _b !== void 0 ? _b : keyUsages,
65058
65426
  ];
65059
65427
  if (algorithm.name === 'PBKDF2') {
65060
- return _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.importKey('raw', (0,_base64url_js__WEBPACK_IMPORTED_MODULE_3__.decode)(jwk.k), ...rest);
65428
+ return _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__["default"].subtle.importKey('raw', (0,_base64url_js__WEBPACK_IMPORTED_MODULE_2__.decode)(jwk.k), ...rest);
65061
65429
  }
65062
65430
  const keyData = { ...jwk };
65063
65431
  delete keyData.alg;
65064
65432
  delete keyData.use;
65065
- try {
65066
- return await _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.importKey('jwk', keyData, ...rest);
65067
- }
65068
- catch (err) {
65069
- if (algorithm.name === 'Ed25519' &&
65070
- (err === null || err === void 0 ? void 0 : err.name) === 'NotSupportedError' &&
65071
- (0,_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)()) {
65072
- rest[0] = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
65073
- return await _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.importKey('jwk', keyData, ...rest);
65074
- }
65075
- throw err;
65076
- }
65433
+ return _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__["default"].subtle.importKey('jwk', keyData, ...rest);
65077
65434
  };
65078
65435
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (parse);
65079
65436
 
@@ -65315,9 +65672,7 @@ __webpack_require__.r(__webpack_exports__);
65315
65672
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
65316
65673
  /* harmony export */ "default": () => (/* binding */ subtleDsa)
65317
65674
  /* harmony export */ });
65318
- /* harmony import */ var _env_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./env.js */ "./node_modules/jose/dist/browser/runtime/env.js");
65319
- /* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
65320
-
65675
+ /* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
65321
65676
 
65322
65677
  function subtleDsa(alg, algorithm) {
65323
65678
  const hash = `SHA-${alg.slice(-3)}`;
@@ -65339,12 +65694,9 @@ function subtleDsa(alg, algorithm) {
65339
65694
  case 'ES512':
65340
65695
  return { hash, name: 'ECDSA', namedCurve: algorithm.namedCurve };
65341
65696
  case 'EdDSA':
65342
- if ((0,_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)() && algorithm.name === 'NODE-ED25519') {
65343
- return { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
65344
- }
65345
65697
  return { name: algorithm.name };
65346
65698
  default:
65347
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
65699
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_0__.JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
65348
65700
  }
65349
65701
  }
65350
65702