solid-ui 2.4.27-dc50c4e2 → 2.4.27-ddcbbf49

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, oldMsgMaker, errMsg, privateKey, pubKey, sig, _errMsg;
2658
+ var sts, now, timestamp, dateStamp, chatDocument, message, me, msg, oldMsgMaker, errMsg, privateKey, sig, _errMsg;
2659
2659
  return _regenerator["default"].wrap(function _callee2$(_context2) {
2660
2660
  while (1) switch (_context2.prev = _context2.next) {
2661
2661
  case 0:
@@ -2682,7 +2682,6 @@ var ChatChannel = /*#__PURE__*/function () {
2682
2682
  if (deleteIt) {
2683
2683
  // we need to add a specific signature, else anyone can delete a msg ?
2684
2684
  sts.push($rdf.st(message, ns.schema('dateDeleted'), dateStamp, chatDocument));
2685
- // msg.dateDeleted = dateStamp
2686
2685
  }
2687
2686
  _context2.next = 20;
2688
2687
  break;
@@ -2703,46 +2702,40 @@ var ChatChannel = /*#__PURE__*/function () {
2703
2702
  sts.push($rdf.st(message, ns.dct('created'), dateStamp, chatDocument));
2704
2703
  msg.created = dateStamp.value;
2705
2704
  if (!me) {
2706
- _context2.next = 36;
2705
+ _context2.next = 35;
2707
2706
  break;
2708
2707
  }
2709
2708
  sts.push($rdf.st(message, ns.foaf('maker'), me, chatDocument));
2710
2709
  msg.maker = me.uri;
2711
2710
  // privateKey the cached private key of me, cached in store
2712
2711
  _context2.next = 32;
2713
- return (0, _keys.getPrivateKey)(me.uri);
2712
+ return (0, _keys.getPrivateKey)(me);
2714
2713
  case 32:
2715
2714
  privateKey = _context2.sent;
2716
- // const privateKey0 = 'a11bc5d2eee6cdb3b37f5473a712cad905ccfb13fb2ccdbf1be0a1ac4fdc7d2a'
2717
- // const pubKey0 = '023a9da707bee1302f66083c9d95673ff969b41607a66f52686fa774d64ceb87'
2718
- pubKey = (0, _keys.getPublicKey)(me.uri);
2715
+ // me.uri)
2719
2716
  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;
2717
+ sts.push($rdf.st(message, $rdf.sym("".concat(_signature.SEC, "proofValue")), $rdf.lit(sig), chatDocument));
2718
+ case 35:
2719
+ _context2.prev = 35;
2720
+ _context2.next = 38;
2728
2721
  return _solidLogic.store.updater.update([], sts);
2729
- case 39:
2730
- _context2.next = 47;
2722
+ case 38:
2723
+ _context2.next = 46;
2731
2724
  break;
2732
- case 41:
2733
- _context2.prev = 41;
2734
- _context2.t0 = _context2["catch"](36);
2725
+ case 40:
2726
+ _context2.prev = 40;
2727
+ _context2.t0 = _context2["catch"](35);
2735
2728
  _errMsg = 'Error saving chat message: ' + _context2.t0;
2736
2729
  debug.warn(_errMsg);
2737
2730
  alert(_errMsg);
2738
2731
  throw new Error(_errMsg);
2739
- case 47:
2732
+ case 46:
2740
2733
  return _context2.abrupt("return", message);
2741
- case 48:
2734
+ case 47:
2742
2735
  case "end":
2743
2736
  return _context2.stop();
2744
2737
  }
2745
- }, _callee2, null, [[36, 41]]);
2738
+ }, _callee2, null, [[35, 40]]);
2746
2739
  })();
2747
2740
  });
2748
2741
  function updateMessage(_x2) {
@@ -4040,9 +4033,11 @@ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/r
4040
4033
  var debug = _interopRequireWildcard(__webpack_require__(/*! ../debug */ "./lib/debug.js"));
4041
4034
  var _secp256k = __webpack_require__(/*! @noble/curves/secp256k1 */ "./node_modules/@noble/curves/secp256k1.js");
4042
4035
  var _utils = __webpack_require__(/*! @noble/hashes/utils */ "./node_modules/@noble/hashes/utils.js");
4043
- var _signature = __webpack_require__(/*! ./signature */ "./lib/chat/signature.js");
4036
+ var ns = _interopRequireWildcard(__webpack_require__(/*! ../ns */ "./lib/ns.js"));
4044
4037
  var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
4045
4038
  var $rdf = _interopRequireWildcard(__webpack_require__(/*! rdflib */ "./node_modules/rdflib/esm/index.js"));
4039
+ var _accessData = __webpack_require__(/*! ../utils/keyHelpers/accessData */ "./lib/utils/keyHelpers/accessData.js");
4040
+ var _acl = __webpack_require__(/*! ../utils/keyHelpers/acl */ "./lib/utils/keyHelpers/acl.js");
4046
4041
  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); }
4047
4042
  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; }
4048
4043
  function generatePrivateKey() {
@@ -4051,140 +4046,209 @@ function generatePrivateKey() {
4051
4046
  function generatePublicKey(privateKey) {
4052
4047
  return (0, _utils.bytesToHex)(_secp256k.schnorr.getPublicKey(privateKey));
4053
4048
  }
4054
- function getPublicKey(webId) {
4055
- var publicKey = publicKeyExists(webId);
4056
- return publicKey;
4057
- }
4058
- function publicKeyExists(webId) {
4059
- // find publickey
4060
- var url = new URL(webId);
4061
- url.hash = '';
4062
- /* debug.warn('Alain publicKeyExists')
4063
- debug.warn(webId)
4064
- debug.warn(url.href) */
4065
- _solidLogic.store.fetcher.load(url.href);
4066
- var publicKey = _solidLogic.store.any(_solidLogic.store.sym(webId), _solidLogic.store.sym(_signature.CERT + 'PublicKey'));
4067
- return publicKey === null || publicKey === void 0 ? void 0 : publicKey.value; // as NamedNode
4068
- }
4069
-
4070
- var privKeyUrl = function privKeyUrl(webId) {
4071
- var url = new URL(webId);
4072
- var privateKeyUrl = url.protocol + '//' + url.host + '/profile/privateKey.ttl';
4073
- return privateKeyUrl;
4074
- };
4075
- function privateKeyExists(_x) {
4076
- return _privateKeyExists.apply(this, arguments);
4049
+
4050
+ /**
4051
+ * getPublicKey
4052
+ * used for displaying messages in chat, therefore does not
4053
+ * create a new key if not found
4054
+ * @param webId
4055
+ * @returns string | undefined
4056
+ */
4057
+ function getPublicKey(_x) {
4058
+ return _getPublicKey.apply(this, arguments);
4077
4059
  }
4078
- function _privateKeyExists() {
4079
- _privateKeyExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
4080
- var privateKeyUrl, privateKey, _err$response, data, contentType, response;
4081
- return _regenerator["default"].wrap(function _callee$(_context) {
4082
- while (1) switch (_context.prev = _context.next) {
4060
+ function _getPublicKey() {
4061
+ _getPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
4062
+ var publicKeyDoc, key;
4063
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
4064
+ while (1) switch (_context2.prev = _context2.next) {
4083
4065
  case 0:
4084
- /* const url = new URL(webId)
4085
- const privateKeyUrl = url.protocol + '//' + url.host + '/profile/privateKey.ttl' */
4086
- privateKeyUrl = privKeyUrl(webId);
4087
- /* debug.warn('Alain privateKeyExists')
4088
- debug.warn(webId)
4089
- debug.warn(privateKeyUrl) */
4090
- _context.prev = 1;
4091
- _solidLogic.store.fetcher.load(privateKeyUrl);
4092
- privateKey = _solidLogic.store.any(_solidLogic.store.sym(webId), _solidLogic.store.sym(_signature.CERT + 'PrivateKey'));
4093
- return _context.abrupt("return", privateKey === null || privateKey === void 0 ? void 0 : privateKey.value);
4094
- case 7:
4095
- _context.prev = 7;
4096
- _context.t0 = _context["catch"](1);
4097
- if (!((_context.t0 === null || _context.t0 === void 0 ? void 0 : (_err$response = _context.t0.response) === null || _err$response === void 0 ? void 0 : _err$response.status) === 404)) {
4098
- _context.next = 24;
4099
- break;
4100
- }
4101
- _context.prev = 10;
4102
- // create privateKey resource
4103
- data = '';
4104
- contentType = 'text/ttl';
4105
- _context.next = 15;
4106
- return _solidLogic.store.fetcher.webOperation('PUT', privateKeyUrl, {
4107
- data: data,
4108
- contentType: contentType
4109
- });
4066
+ _context2.next = 2;
4067
+ return _solidLogic.store.fetcher.load(webId);
4068
+ case 2:
4069
+ _context2.next = 4;
4070
+ return (0, _accessData.pubKeyUrl)(webId);
4071
+ case 4:
4072
+ publicKeyDoc = _context2.sent;
4073
+ _context2.prev = 5;
4074
+ _context2.next = 8;
4075
+ return _solidLogic.store.fetcher.load(publicKeyDoc);
4076
+ case 8:
4077
+ // url.href)
4078
+ key = _solidLogic.store.any(webId, ns.solid('publicKey'));
4079
+ return _context2.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
4080
+ case 12:
4081
+ _context2.prev = 12;
4082
+ _context2.t0 = _context2["catch"](5);
4083
+ return _context2.abrupt("return", undefined);
4110
4084
  case 15:
4111
- response = _context.sent;
4112
- _context.next = 22;
4113
- break;
4114
- case 18:
4115
- _context.prev = 18;
4116
- _context.t1 = _context["catch"](10);
4117
- debug.log('createIfNotExists doc FAILED: ' + privateKeyUrl + ': ' + _context.t1);
4118
- throw _context.t1;
4119
- case 22:
4120
- delete _solidLogic.store.fetcher.requested[privateKeyUrl]; // delete cached 404 error
4121
- return _context.abrupt("return", undefined);
4122
- case 24:
4123
- debug.log('createIfNotExists doc FAILED: ' + privateKeyUrl + ': ' + _context.t0);
4124
- throw _context.t0;
4125
- case 26:
4126
4085
  case "end":
4127
- return _context.stop();
4086
+ return _context2.stop();
4128
4087
  }
4129
- }, _callee, null, [[1, 7], [10, 18]]);
4088
+ }, _callee2, null, [[5, 12]]);
4130
4089
  }));
4131
- return _privateKeyExists.apply(this, arguments);
4090
+ return _getPublicKey.apply(this, arguments);
4132
4091
  }
4133
4092
  function getPrivateKey(_x2) {
4134
4093
  return _getPrivateKey.apply(this, arguments);
4135
4094
  }
4136
4095
  function _getPrivateKey() {
4137
- _getPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
4138
- var url, privateKeyUrl, publicKey, privateKey, del, add;
4139
- return _regenerator["default"].wrap(function _callee2$(_context2) {
4140
- while (1) switch (_context2.prev = _context2.next) {
4096
+ _getPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId) {
4097
+ var publicKeyDoc, privateKeyDoc, publicKey, privateKey, validPublicKey, del, add, newPublicKey, keyContainer;
4098
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
4099
+ while (1) switch (_context3.prev = _context3.next) {
4141
4100
  case 0:
4142
- url = new URL(webId);
4143
- url.hash = '';
4144
- /* const privateKeyUrl = url.protocol + '//' + url.host + '/profile/privateKey.ttl' */
4145
- privateKeyUrl = privKeyUrl(webId); // find publickey
4146
- publicKey = publicKeyExists(webId); // debug.warn('publicKey ' + publicKey)
4147
- // find privateKey
4148
- _context2.next = 6;
4149
- return privateKeyExists(webId);
4150
- case 6:
4151
- privateKey = _context2.sent;
4152
- // debug.warn('privateKey ' + privateKey)
4153
- if (privateKey && publicKey !== generatePublicKey(privateKey)) debug.warn('publicKey is not valid');
4154
-
4155
- // simulate new key pair
4156
- /* const newPrivateKey = generatePrivateKey()
4157
- const newPublicKey = generatePublicKey(newPrivateKey)
4158
- debug.log('newPrivateKey ' + newPrivateKey)
4159
- debug.log('newPublicKey ' + newPublicKey) */
4160
-
4161
- // create key pair
4162
- if (!(!privateKey || !publicKey)) {
4163
- _context2.next = 19;
4101
+ _context3.next = 2;
4102
+ return _solidLogic.store.fetcher.load(webId);
4103
+ case 2:
4104
+ _context3.next = 4;
4105
+ return (0, _accessData.pubKeyUrl)(webId);
4106
+ case 4:
4107
+ publicKeyDoc = _context3.sent;
4108
+ _context3.next = 7;
4109
+ return (0, _accessData.privKeyUrl)(webId);
4110
+ case 7:
4111
+ privateKeyDoc = _context3.sent;
4112
+ _context3.next = 10;
4113
+ return (0, _accessData.getExistingPublicKey)(webId, publicKeyDoc);
4114
+ case 10:
4115
+ publicKey = _context3.sent;
4116
+ _context3.next = 13;
4117
+ return (0, _accessData.getExistingPrivateKey)(webId, privateKeyDoc);
4118
+ case 13:
4119
+ privateKey = _context3.sent;
4120
+ // is publicKey valid ?
4121
+ validPublicKey = true;
4122
+ if (privateKey && publicKey !== generatePublicKey(privateKey)) {
4123
+ if (confirm('This is strange the publicKey is not valid for\n' + (webId === null || webId === void 0 ? void 0 : webId.uri) + '\'shall we repair keeping the private key ?')) validPublicKey = false;
4124
+ }
4125
+
4126
+ // create key pair or repair publicKey
4127
+ if (!(!privateKey || !publicKey || !validPublicKey)) {
4128
+ _context3.next = 34;
4164
4129
  break;
4165
4130
  }
4166
4131
  del = [];
4167
4132
  add = [];
4168
- if (privateKey) del.push($rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'PrivateKey'), $rdf.lit(privateKey), $rdf.sym(privateKeyUrl)));
4169
- if (publicKey) del.push($rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'PublicKey'), $rdf.lit(publicKey), $rdf.sym(url.href)));
4133
+ if (privateKey) {
4134
+ _context3.next = 24;
4135
+ break;
4136
+ }
4137
+ // add = []
4170
4138
  privateKey = generatePrivateKey();
4171
- publicKey = generatePublicKey(privateKey);
4172
- /* debug.log('newPrivateKey-1 ' + privateKey)
4173
- debug.log('newPublicKey-1 ' + publicKey) */
4174
- add.push($rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'PrivateKey'), $rdf.literal(privateKey), $rdf.sym(privateKeyUrl)));
4175
- add.push($rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'PublicKey'), $rdf.literal(publicKey), $rdf.sym(url.href)));
4176
- _context2.next = 19;
4177
- return _solidLogic.store.updater.updateMany(del, add);
4178
- case 19:
4179
- return _context2.abrupt("return", privateKey);
4180
- case 20:
4139
+ add = [$rdf.st(webId, ns.solid('privateKey'), $rdf.literal(privateKey), _solidLogic.store.sym(privateKeyDoc))];
4140
+ _context3.next = 24;
4141
+ return saveKey(privateKeyDoc, [], add, webId.uri);
4142
+ case 24:
4143
+ if (!(!publicKey || !validPublicKey)) {
4144
+ _context3.next = 31;
4145
+ break;
4146
+ }
4147
+ del = [];
4148
+ // delete invalid public key
4149
+ if (publicKey) {
4150
+ del = [$rdf.st(webId, ns.solid('publicKey'), $rdf.lit(publicKey), _solidLogic.store.sym(publicKeyDoc))];
4151
+ debug.log(del);
4152
+ }
4153
+ // update new valid key
4154
+ newPublicKey = generatePublicKey(privateKey);
4155
+ add = [$rdf.st(webId, ns.solid('publicKey'), $rdf.literal(newPublicKey), _solidLogic.store.sym(publicKeyDoc))];
4156
+ _context3.next = 31;
4157
+ return saveKey(publicKeyDoc, del, add);
4158
+ case 31:
4159
+ keyContainer = privateKeyDoc.substring(0, privateKeyDoc.lastIndexOf('/') + 1);
4160
+ _context3.next = 34;
4161
+ return (0, _acl.setAcl)(keyContainer, (0, _acl.keyContainerAclBody)(webId.uri));
4162
+ case 34:
4163
+ return _context3.abrupt("return", privateKey);
4164
+ case 35:
4181
4165
  case "end":
4182
- return _context2.stop();
4166
+ return _context3.stop();
4183
4167
  }
4184
- }, _callee2);
4168
+ }, _callee3);
4185
4169
  }));
4186
4170
  return _getPrivateKey.apply(this, arguments);
4187
4171
  }
4172
+ var deleteKeyAcl = /*#__PURE__*/function () {
4173
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(keyDoc) {
4174
+ var keyAclDoc, response;
4175
+ return _regenerator["default"].wrap(function _callee$(_context) {
4176
+ while (1) switch (_context.prev = _context.next) {
4177
+ case 0:
4178
+ _context.next = 2;
4179
+ return _solidLogic.store.fetcher.load(keyDoc);
4180
+ case 2:
4181
+ keyAclDoc = _solidLogic.store.any(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl'));
4182
+ if (!keyAclDoc) {
4183
+ _context.next = 16;
4184
+ break;
4185
+ }
4186
+ _context.prev = 4;
4187
+ _context.next = 7;
4188
+ return _solidLogic.store.fetcher.webOperation('DELETE', keyAclDoc.value);
4189
+ case 7:
4190
+ response = _context.sent;
4191
+ // this may fail if webId is not an owner
4192
+ debug.log('delete ' + keyAclDoc.value + ' ' + response.status); // should test 404 and 2xx
4193
+ _context.next = 16;
4194
+ break;
4195
+ case 11:
4196
+ _context.prev = 11;
4197
+ _context.t0 = _context["catch"](4);
4198
+ if (!(_context.t0.response.status !== 404)) {
4199
+ _context.next = 15;
4200
+ break;
4201
+ }
4202
+ throw new Error(_context.t0);
4203
+ case 15:
4204
+ debug.log('delete ' + keyAclDoc.value + ' ' + _context.t0.response.status); // should test 404 and 2xx
4205
+ case 16:
4206
+ case "end":
4207
+ return _context.stop();
4208
+ }
4209
+ }, _callee, null, [[4, 11]]);
4210
+ }));
4211
+ return function deleteKeyAcl(_x3) {
4212
+ return _ref.apply(this, arguments);
4213
+ };
4214
+ }();
4215
+
4216
+ /**
4217
+ * delete acl if keydoc exists
4218
+ * create/edit keyDoc
4219
+ * set keyDoc acl
4220
+ */
4221
+ function saveKey(_x4, _x5, _x6) {
4222
+ return _saveKey.apply(this, arguments);
4223
+ }
4224
+ function _saveKey() {
4225
+ _saveKey = (0, _asyncToGenerator2["default"])(function (keyDoc, del, add) {
4226
+ var me = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
4227
+ return /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
4228
+ var aclBody;
4229
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
4230
+ while (1) switch (_context4.prev = _context4.next) {
4231
+ case 0:
4232
+ _context4.next = 2;
4233
+ return deleteKeyAcl(keyDoc);
4234
+ case 2:
4235
+ _context4.next = 4;
4236
+ return _solidLogic.store.updater.updateMany(del, add);
4237
+ case 4:
4238
+ // or a promise store.updater.update ?
4239
+ // create READ only ACL
4240
+ aclBody = (0, _acl.keyAclBody)(keyDoc, me);
4241
+ _context4.next = 7;
4242
+ return (0, _acl.setAcl)(keyDoc, aclBody);
4243
+ case 7:
4244
+ case "end":
4245
+ return _context4.stop();
4246
+ }
4247
+ }, _callee4);
4248
+ })();
4249
+ });
4250
+ return _saveKey.apply(this, arguments);
4251
+ }
4188
4252
  //# sourceMappingURL=keys.js.map
4189
4253
 
4190
4254
  /***/ }),
@@ -4237,7 +4301,11 @@ var messageBodyStyle = style.messageBodyStyle;
4237
4301
  var label = utils.label;
4238
4302
 
4239
4303
  /**
4304
+ * elementForImageURI
4240
4305
  * HTML component for an image
4306
+ * @param imageUri
4307
+ * @param options { inlineImageHeightEms }
4308
+ * @returns HTMLAnchorElement For Image
4241
4309
  */
4242
4310
  function elementForImageURI(imageUri, options) {
4243
4311
  var img = dom.createElement('img');
@@ -4267,21 +4335,27 @@ var anchor = function anchor(text, term) {
4267
4335
  a.textContent = text;
4268
4336
  return a;
4269
4337
  };
4270
- function nick(person) {
4338
+ function nickname(person) {
4271
4339
  var s = _solidLogic.store.any(person, ns.foaf('nick'));
4272
4340
  if (s) return '' + s.value;
4273
4341
  return '' + label(person);
4274
4342
  }
4275
4343
 
4276
4344
  /**
4345
+ * creatorAndDate
4277
4346
  * Displays creator and date for a chat message
4278
4347
  * inside the `td1` element
4348
+ * @param td1
4349
+ * @param creator
4350
+ * @param date
4351
+ * @param message
4352
+ * @returns HTMLAnchorElement For Image
4279
4353
  */
4280
4354
  function creatorAndDate(td1, creator, date, message) {
4281
- var nickAnchor = td1.appendChild(anchor(nick(creator), creator));
4355
+ var nickAnchor = td1.appendChild(anchor(nickname(creator), creator));
4282
4356
  if (creator.uri) {
4283
4357
  _solidLogic.store.fetcher.nowOrWhenFetched(creator.doc(), undefined, function (_ok, _body) {
4284
- nickAnchor.textContent = nick(creator);
4358
+ nickAnchor.textContent = nickname(creator);
4285
4359
  });
4286
4360
  }
4287
4361
  td1.appendChild(dom.createElement('br'));
@@ -4289,14 +4363,20 @@ function creatorAndDate(td1, creator, date, message) {
4289
4363
  }
4290
4364
 
4291
4365
  /**
4366
+ * creatorAndDateHorizontal
4292
4367
  * Horizontally displays creator and date for a chat message
4293
4368
  * inside the `td1` element
4369
+ * @param td1
4370
+ * @param creator
4371
+ * @param date
4372
+ * @param message
4373
+ * @returns HTMLAnchorElement For Image
4294
4374
  */
4295
4375
  function creatorAndDateHorizontal(td1, creator, date, message) {
4296
4376
  var nickAnchor = td1.appendChild(anchor(label(creator), creator));
4297
4377
  if (creator.uri) {
4298
4378
  _solidLogic.store.fetcher.nowOrWhenFetched(creator.doc(), undefined, function (_ok, _body) {
4299
- nickAnchor.textContent = nick(creator);
4379
+ nickAnchor.textContent = nickname(creator);
4300
4380
  });
4301
4381
  }
4302
4382
  var dateBit = td1.appendChild(anchor(date, message));
@@ -4306,44 +4386,61 @@ function creatorAndDateHorizontal(td1, creator, date, message) {
4306
4386
  }
4307
4387
 
4308
4388
  /**
4389
+ * renderMessageRow
4309
4390
  * Renders a chat message, read-only mode
4391
+ * @param channelObject
4392
+ * @param message
4393
+ * @param fresh
4394
+ * @param options
4395
+ * @param userContext
4396
+ * @returns Message Row HTML Table Element
4310
4397
  */
4311
4398
  function renderMessageRow(channelObject, message, fresh, options, userContext) {
4399
+ var unsignedMessage = false;
4312
4400
  var colorizeByAuthor = options.colorizeByAuthor === '1' || options.colorizeByAuthor === true;
4313
4401
  var creator = _solidLogic.store.any(message, ns.foaf('maker'));
4314
4402
  var date = _solidLogic.store.any(message, ns.dct('created'));
4315
4403
  var latestVersion = (0, _chatLogic.mostRecentVersion)(message);
4316
4404
  var latestVersionCreator = _solidLogic.store.any(latestVersion, ns.foaf('maker'));
4405
+
4317
4406
  // use latest content if same owner, else use original
4318
- var msgId = creator === latestVersionCreator ? latestVersion : message;
4407
+ var msgId = creator.uri === latestVersionCreator.uri ? latestVersion : message;
4319
4408
  var content = _solidLogic.store.any(msgId, ns.sioc('content'));
4320
- var signature = _solidLogic.store.any(msgId, $rdf.sym("".concat(_signature.SEC, "Proof")));
4321
- debug.log('alain ' + (signature === null || signature === void 0 ? void 0 : signature.value));
4409
+ var signature = _solidLogic.store.any(msgId, $rdf.sym("".concat(_signature.SEC, "proofValue")));
4322
4410
 
4323
- // verify signature
4411
+ // set message object
4324
4412
  var msg = (0, _signature.getBlankMsg)();
4325
4413
  msg.id = msgId.uri;
4326
4414
  msg.created = _solidLogic.store.any(msgId, ns.dct('created')).value;
4327
4415
  msg.content = content.value;
4328
4416
  msg.maker = creator.uri;
4329
- try {
4330
- // pubKey could be store in a cache for all makers
4331
- var pubKey = (0, _keys.getPublicKey)(creator.uri);
4332
- /* const pubKey0 = '023a9da707bee1302f66083c9d95673ff969b41607a66f52686fa774d64ceb87'
4333
- debug.warn('publicKeys\n' + pubKey0 + '\n' + pubKey)
4334
- const privKey0 = getPrivateKey(creator.uri) // alain to remove
4335
- // unsigned messages should be signaled as unsecured
4336
- debug.warn(msg)
4337
- debug.warn(signature?.value) */
4338
- if (signature !== null && signature !== void 0 && signature.value && !(0, _signature.verifySignature)(signature.value, msg, pubKey)) throw new Error('invalid signature');
4339
- } catch (err) {
4340
- debug.log(err);
4417
+
4418
+ // unsigned message
4419
+ if (!(signature !== null && signature !== void 0 && signature.value)) {
4420
+ unsignedMessage = true;
4421
+ debug.warn(msgId.uri + ' is unsigned'); // TODO replace with UI (colored message ?)
4422
+ } else {
4423
+ // signed message, get public key and check signature
4424
+ (0, _keys.getPublicKey)(creator).then(function (publicKey) {
4425
+ debug.log(creator.uri + '\n' + msg.created + '\n' + msg.id + '\n' + publicKey);
4426
+ if (!publicKey) {
4427
+ // TODO try to recreate the publicKey
4428
+ // if(me.uri === creator.uri) await getPrivateKey(creator)
4429
+ debug.warn('message is signed but ' + creator.uri + ' is missing publicKey');
4430
+ }
4431
+ // check that publicKey is a valid hex string
4432
+ var regex = /[0-9A-Fa-f]{6}/g;
4433
+ if (!(publicKey !== null && publicKey !== void 0 && publicKey.match(regex))) debug.warn('invalid publicKey hex string\n' + creator.uri + '\n' + publicKey);
4434
+ // verify signature
4435
+ 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);
4436
+ });
4341
4437
  }
4342
4438
  var originalMessage = (0, _chatLogic.originalVersion)(message);
4343
4439
  var edited = !message.sameTerm(originalMessage);
4344
4440
  var sortDate = _solidLogic.store.the(originalMessage, ns.dct('created'), null, originalMessage.doc()); // In message
4345
4441
 
4346
4442
  var messageRow = dom.createElement('tr');
4443
+ if (unsignedMessage) messageRow.setAttribute('style', 'background-color: red');
4347
4444
  messageRow.AJAR_date = sortDate.value;
4348
4445
  messageRow.AJAR_subject = message;
4349
4446
  var td1 = dom.createElement('td');
@@ -4432,7 +4529,8 @@ function renderMessageRow(channelObject, message, fresh, options, userContext) {
4432
4529
  toolsTD.appendChild(tools);
4433
4530
  });
4434
4531
  return messageRow;
4435
- }
4532
+ } // END OF RENDERMESSAGE
4533
+
4436
4534
  function switchToEditor(messageRow, message, channelObject, userContext) {
4437
4535
  var messageTable = messageRow.parentNode;
4438
4536
  var editRow = renderMessageEditor(channelObject, messageTable, userContext, channelObject.options, (0, _chatLogic.mostRecentVersion)(message));
@@ -4477,8 +4575,6 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
4477
4575
  while (1) switch (_context7.prev = _context7.next) {
4478
4576
  case 0:
4479
4577
  sendComplete = function _sendComplete(message, _text2) {
4480
- // const dateStamp = store.any(message, ns.dct('created'), null, message.doc())
4481
- // const content = $rdf.literal(text2)
4482
4578
  (0, _infinite.insertMessageIntoTable)(channelObject, messageTable, message, false, options, userContext); // not green
4483
4579
 
4484
4580
  if (originalMessage) {
@@ -5131,14 +5227,12 @@ function messageToolbar(message, messageRow, userContext, channelObject) {
5131
5227
  Object.defineProperty(exports, "__esModule", ({
5132
5228
  value: true
5133
5229
  }));
5134
- exports.SEC = exports.CERT = void 0;
5135
- exports.finishMsg = finishMsg;
5230
+ exports.SEC = void 0;
5136
5231
  exports.getBlankMsg = getBlankMsg;
5137
5232
  exports.getMsgHash = getMsgHash;
5138
5233
  exports.serializeMsg = serializeMsg;
5139
5234
  exports.signMsg = signMsg;
5140
5235
  exports.utf8Encoder = exports.utf8Decoder = void 0;
5141
- exports.validateMsg = validateMsg;
5142
5236
  exports.verifySignature = verifySignature;
5143
5237
  var _secp256k = __webpack_require__(/*! @noble/curves/secp256k1 */ "./node_modules/@noble/curves/secp256k1.js");
5144
5238
  var _utils = __webpack_require__(/*! @noble/hashes/utils */ "./node_modules/@noble/hashes/utils.js");
@@ -5151,8 +5245,7 @@ exports.utf8Decoder = utf8Decoder;
5151
5245
  var utf8Encoder = new TextEncoder();
5152
5246
  exports.utf8Encoder = utf8Encoder;
5153
5247
  var SEC = 'https://w3id.org/security#'; // Proof, VerificationMethod
5154
- exports.SEC = SEC;
5155
- var CERT = 'http://www.w3.org/ns/auth/cert#'; // PrivateKey, PublicKey
5248
+ // export const CERT = 'http://www.w3.org/ns/auth/cert#' // PrivateKey, PublicKey, key
5156
5249
 
5157
5250
  /* eslint-disable no-unused-vars */
5158
5251
  /* export enum Kind {
@@ -5178,25 +5271,28 @@ var CERT = 'http://www.w3.org/ns/auth/cert#'; // PrivateKey, PublicKey
5178
5271
  ProfileBadge = 30009,
5179
5272
  Article = 30023
5180
5273
  } */
5181
- exports.CERT = CERT;
5274
+ exports.SEC = SEC;
5182
5275
  function getBlankMsg() {
5183
5276
  return {
5184
5277
  id: '',
5185
5278
  created: '',
5186
5279
  dateDeleted: '',
5280
+ // TODO to remove if not used
5187
5281
  content: '',
5188
5282
  maker: '',
5189
- sig: ''
5283
+ sig: '' // TODO to remove if not used
5190
5284
  };
5191
5285
  }
5192
- function finishMsg(t, privateKey) {
5193
- // to update to chat message triples
5194
- var message = t;
5195
- // message.pubkey = getPublicKey(privateKey)
5196
- message.id = getMsgHash(message);
5197
- message.sig = signMsg(message, privateKey);
5198
- return message;
5199
- }
5286
+
5287
+ /* export function finishMsg (t: MsgTemplate, privateKey: string): Message {
5288
+ // to update to chat message triples
5289
+ const message = t as Message
5290
+ // message.pubkey = getPublicKey(privateKey)
5291
+ message.id = getMsgHash(message)
5292
+ message.sig = signMsg(message, privateKey)
5293
+ return message
5294
+ } */
5295
+
5200
5296
  function serializeMsg(msg) {
5201
5297
  // to update to chat messages triples
5202
5298
  /* if (!validateMsg(msg))
@@ -5208,27 +5304,29 @@ function getMsgHash(message) {
5208
5304
  var msgHash = (0, _sha.sha256)(utf8Encoder.encode(serializeMsg(message)));
5209
5305
  return (0, _utils.bytesToHex)(msgHash);
5210
5306
  }
5211
- var isRecord = function isRecord(obj) {
5212
- return obj instanceof Object;
5213
- };
5214
- function validateMsg(message) {
5215
- /* if (!isRecord(message)) return false
5307
+
5308
+ // const isRecord = (obj: unknown): obj is Record<string, unknown> => obj instanceof Object
5309
+
5310
+ /* export function validateMsg<T> (message: T): message is T & UnsignedMsg {
5311
+ if (!isRecord(message)) return false
5216
5312
  if (typeof message.kind !== 'number') return false
5217
5313
  if (typeof message.content !== 'string') return false
5218
5314
  if (typeof message.created_at !== 'number') return false
5219
5315
  if (typeof message.pubkey !== 'string') return false
5220
5316
  if (!message.pubkey.match(/^[a-f0-9]{64}$/)) return false
5221
- if (!Array.isArray(message.tags)) return false
5317
+
5318
+ if (!Array.isArray(message.tags)) return false
5222
5319
  for (let i = 0; i < message.tags.length; i++) {
5223
5320
  let tag = message.tags[i]
5224
5321
  if (!Array.isArray(tag)) return false
5225
5322
  for (let j = 0; j < tag.length; j++) {
5226
5323
  if (typeof tag[j] === 'object') return false
5227
5324
  }
5228
- } */
5325
+ }
5326
+
5327
+ return true
5328
+ } */
5229
5329
 
5230
- return true;
5231
- }
5232
5330
  function verifySignature(sig, message, pubKey) {
5233
5331
  return _secp256k.schnorr.verify(sig, getMsgHash(message), pubKey);
5234
5332
  }
@@ -13157,6 +13255,351 @@ function predParentOf(node) {
13157
13255
 
13158
13256
  /***/ }),
13159
13257
 
13258
+ /***/ "./lib/utils/keyHelpers/accessData.js":
13259
+ /*!********************************************!*\
13260
+ !*** ./lib/utils/keyHelpers/accessData.js ***!
13261
+ \********************************************/
13262
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
13263
+
13264
+ "use strict";
13265
+
13266
+
13267
+ var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");
13268
+ var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
13269
+ Object.defineProperty(exports, "__esModule", ({
13270
+ value: true
13271
+ }));
13272
+ exports.getExistingPrivateKey = getExistingPrivateKey;
13273
+ exports.getExistingPublicKey = getExistingPublicKey;
13274
+ exports.getKeyIfExists = getKeyIfExists;
13275
+ exports.pubKeyUrl = exports.privKeyUrl = exports.getPodRoot = void 0;
13276
+ var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
13277
+ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
13278
+ var debug = _interopRequireWildcard(__webpack_require__(/*! ../../debug */ "./lib/debug.js"));
13279
+ var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
13280
+ var ns = _interopRequireWildcard(__webpack_require__(/*! ../../ns */ "./lib/ns.js"));
13281
+ 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); }
13282
+ 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; }
13283
+ var getPodRoot = /*#__PURE__*/function () {
13284
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
13285
+ var webIdURL, storages, podRoot, path, _res$headers$get, res;
13286
+ return _regenerator["default"].wrap(function _callee$(_context) {
13287
+ while (1) switch (_context.prev = _context.next) {
13288
+ case 0:
13289
+ webIdURL = new URL(webId.uri); // find storages in webId document
13290
+ _context.next = 3;
13291
+ return _solidLogic.store.fetcher.load(webId.uri);
13292
+ case 3:
13293
+ storages = _solidLogic.store.each(webId, ns.space('storage'), null, webId.doc());
13294
+ if (storages !== null && storages !== void 0 && storages.length) {
13295
+ _context.next = 19;
13296
+ break;
13297
+ }
13298
+ // find storage recursively in webId URL
13299
+ path = webIdURL.pathname;
13300
+ case 6:
13301
+ if (!path.length) {
13302
+ _context.next = 17;
13303
+ break;
13304
+ }
13305
+ path = path.substring(0, path.lastIndexOf('/'));
13306
+ podRoot = _solidLogic.store.sym(webIdURL.origin + path + '/');
13307
+ _context.next = 11;
13308
+ return _solidLogic.store.fetcher.webOperation('HEAD', podRoot.uri);
13309
+ case 11:
13310
+ res = _context.sent;
13311
+ if (!((_res$headers$get = res.headers.get('link')) !== null && _res$headers$get !== void 0 && _res$headers$get.includes(ns.space('Storage').value))) {
13312
+ _context.next = 14;
13313
+ break;
13314
+ }
13315
+ return _context.abrupt("break", 17);
13316
+ case 14:
13317
+ if (!path) debug.warn("Current user storage not found for\n".concat(webId));
13318
+ _context.next = 6;
13319
+ break;
13320
+ case 17:
13321
+ _context.next = 21;
13322
+ break;
13323
+ case 19:
13324
+ // give preference to storage in webId root
13325
+ podRoot = storages.find(function (storage) {
13326
+ return webIdURL.origin === new URL(storage.value).origin;
13327
+ });
13328
+ if (!podRoot) podRoot = storages[0];
13329
+ case 21:
13330
+ return _context.abrupt("return", podRoot);
13331
+ case 22:
13332
+ case "end":
13333
+ return _context.stop();
13334
+ }
13335
+ }, _callee);
13336
+ }));
13337
+ return function getPodRoot(_x) {
13338
+ return _ref.apply(this, arguments);
13339
+ };
13340
+ }();
13341
+ exports.getPodRoot = getPodRoot;
13342
+ var pubKeyUrl = /*#__PURE__*/function () {
13343
+ var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
13344
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
13345
+ while (1) switch (_context2.prev = _context2.next) {
13346
+ case 0:
13347
+ _context2.prev = 0;
13348
+ _context2.next = 3;
13349
+ return getPodRoot(webId);
13350
+ case 3:
13351
+ _context2.t0 = _context2.sent.value;
13352
+ return _context2.abrupt("return", _context2.t0 + 'profile/keys/publicKey.ttl');
13353
+ case 7:
13354
+ _context2.prev = 7;
13355
+ _context2.t1 = _context2["catch"](0);
13356
+ throw new Error(_context2.t1);
13357
+ case 10:
13358
+ case "end":
13359
+ return _context2.stop();
13360
+ }
13361
+ }, _callee2, null, [[0, 7]]);
13362
+ }));
13363
+ return function pubKeyUrl(_x2) {
13364
+ return _ref2.apply(this, arguments);
13365
+ };
13366
+ }();
13367
+ exports.pubKeyUrl = pubKeyUrl;
13368
+ function getExistingPublicKey(_x3, _x4) {
13369
+ return _getExistingPublicKey.apply(this, arguments);
13370
+ }
13371
+ function _getExistingPublicKey() {
13372
+ _getExistingPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(webId, publicKeyUrl) {
13373
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
13374
+ while (1) switch (_context4.prev = _context4.next) {
13375
+ case 0:
13376
+ _context4.next = 2;
13377
+ return getKeyIfExists(webId, publicKeyUrl, 'publicKey');
13378
+ case 2:
13379
+ return _context4.abrupt("return", _context4.sent);
13380
+ case 3:
13381
+ case "end":
13382
+ return _context4.stop();
13383
+ }
13384
+ }, _callee4);
13385
+ }));
13386
+ return _getExistingPublicKey.apply(this, arguments);
13387
+ }
13388
+ var privKeyUrl = /*#__PURE__*/function () {
13389
+ var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId) {
13390
+ var _store$any, _settings;
13391
+ var settings, _settings2, podRoot;
13392
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
13393
+ while (1) switch (_context3.prev = _context3.next) {
13394
+ case 0:
13395
+ settings = (_store$any = _solidLogic.store.any(webId, ns.space('preferencesFile'), null, webId.doc())) === null || _store$any === void 0 ? void 0 : _store$any.value;
13396
+ settings = (_settings = settings) === null || _settings === void 0 ? void 0 : _settings.split('/').slice(0, -1).join('/');
13397
+ _context3.prev = 2;
13398
+ _context3.next = 5;
13399
+ return getPodRoot(webId);
13400
+ case 5:
13401
+ podRoot = _context3.sent;
13402
+ if ((_settings2 = settings) !== null && _settings2 !== void 0 && _settings2.startsWith(podRoot.value)) {
13403
+ _context3.next = 8;
13404
+ break;
13405
+ }
13406
+ throw new Error("/settings/ is expected to be in ".concat(podRoot.value));
13407
+ case 8:
13408
+ return _context3.abrupt("return", "".concat(settings, "/keys/privateKey.ttl"));
13409
+ case 11:
13410
+ _context3.prev = 11;
13411
+ _context3.t0 = _context3["catch"](2);
13412
+ throw new Error(_context3.t0);
13413
+ case 14:
13414
+ case "end":
13415
+ return _context3.stop();
13416
+ }
13417
+ }, _callee3, null, [[2, 11]]);
13418
+ }));
13419
+ return function privKeyUrl(_x5) {
13420
+ return _ref3.apply(this, arguments);
13421
+ };
13422
+ }();
13423
+ exports.privKeyUrl = privKeyUrl;
13424
+ function getExistingPrivateKey(_x6, _x7) {
13425
+ return _getExistingPrivateKey.apply(this, arguments);
13426
+ }
13427
+ function _getExistingPrivateKey() {
13428
+ _getExistingPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(webId, privateKeyUrl) {
13429
+ return _regenerator["default"].wrap(function _callee5$(_context5) {
13430
+ while (1) switch (_context5.prev = _context5.next) {
13431
+ case 0:
13432
+ _context5.next = 2;
13433
+ return getKeyIfExists(webId, privateKeyUrl, 'privateKey');
13434
+ case 2:
13435
+ return _context5.abrupt("return", _context5.sent);
13436
+ case 3:
13437
+ case "end":
13438
+ return _context5.stop();
13439
+ }
13440
+ }, _callee5);
13441
+ }));
13442
+ return _getExistingPrivateKey.apply(this, arguments);
13443
+ }
13444
+ function getKeyIfExists(_x8, _x9, _x10) {
13445
+ return _getKeyIfExists.apply(this, arguments);
13446
+ }
13447
+ function _getKeyIfExists() {
13448
+ _getKeyIfExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(webId, keyUrl, keyType) {
13449
+ var key;
13450
+ return _regenerator["default"].wrap(function _callee6$(_context6) {
13451
+ while (1) switch (_context6.prev = _context6.next) {
13452
+ case 0:
13453
+ _context6.prev = 0;
13454
+ _context6.next = 3;
13455
+ return _solidLogic.store.fetcher.load(keyUrl);
13456
+ case 3:
13457
+ key = _solidLogic.store.any(webId, ns.solid(keyType)); // store.sym(CERT + keyType))
13458
+ return _context6.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
13459
+ case 7:
13460
+ _context6.prev = 7;
13461
+ _context6.t0 = _context6["catch"](0);
13462
+ if (!(_context6.t0.response.status === 404)) {
13463
+ _context6.next = 24;
13464
+ break;
13465
+ }
13466
+ debug.log('createIfNotExists: doc does NOT exist, will create... ' + keyUrl);
13467
+ _context6.prev = 11;
13468
+ _context6.next = 14;
13469
+ return _solidLogic.store.fetcher.webOperation('PUT', keyUrl, {
13470
+ data: '',
13471
+ contentType: 'text/turtle'
13472
+ });
13473
+ case 14:
13474
+ _context6.next = 20;
13475
+ break;
13476
+ case 16:
13477
+ _context6.prev = 16;
13478
+ _context6.t1 = _context6["catch"](11);
13479
+ debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context6.t1);
13480
+ throw _context6.t1;
13481
+ case 20:
13482
+ delete _solidLogic.store.fetcher.requested[keyUrl]; // delete cached 404 error
13483
+ // debug.log('createIfNotExists doc created ok ' + doc)
13484
+ return _context6.abrupt("return", undefined);
13485
+ case 24:
13486
+ debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context6.t0);
13487
+ throw _context6.t0;
13488
+ case 26:
13489
+ case "end":
13490
+ return _context6.stop();
13491
+ }
13492
+ }, _callee6, null, [[0, 7], [11, 16]]);
13493
+ }));
13494
+ return _getKeyIfExists.apply(this, arguments);
13495
+ }
13496
+ //# sourceMappingURL=accessData.js.map
13497
+
13498
+ /***/ }),
13499
+
13500
+ /***/ "./lib/utils/keyHelpers/acl.js":
13501
+ /*!*************************************!*\
13502
+ !*** ./lib/utils/keyHelpers/acl.js ***!
13503
+ \*************************************/
13504
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
13505
+
13506
+ "use strict";
13507
+
13508
+
13509
+ var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");
13510
+ var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
13511
+ Object.defineProperty(exports, "__esModule", ({
13512
+ value: true
13513
+ }));
13514
+ exports.keyContainerAclBody = exports.keyAclBody = void 0;
13515
+ exports.setAcl = setAcl;
13516
+ var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
13517
+ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
13518
+ var debug = _interopRequireWildcard(__webpack_require__(/*! ../../debug */ "./lib/debug.js"));
13519
+ var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
13520
+ 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); }
13521
+ 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; }
13522
+ /**
13523
+ * set ACL
13524
+ * @param keyDoc
13525
+ * @param aclBody
13526
+ */
13527
+ function setAcl(_x, _x2) {
13528
+ return _setAcl.apply(this, arguments);
13529
+ }
13530
+ /**
13531
+ * key container ACL
13532
+ * @param me
13533
+ * @returns aclBody
13534
+ */
13535
+ function _setAcl() {
13536
+ _setAcl = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(keyDoc, aclBody) {
13537
+ var keyAclDoc, _err$response;
13538
+ return _regenerator["default"].wrap(function _callee$(_context) {
13539
+ while (1) switch (_context.prev = _context.next) {
13540
+ case 0:
13541
+ _context.next = 2;
13542
+ return _solidLogic.store.fetcher.load(keyDoc);
13543
+ case 2:
13544
+ // FIXME: check the Why value on this quad:
13545
+ debug.log(_solidLogic.store.statementsMatching(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl')));
13546
+ keyAclDoc = _solidLogic.store.any(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl'));
13547
+ if (keyAclDoc) {
13548
+ _context.next = 6;
13549
+ break;
13550
+ }
13551
+ throw new Error('Key ACL doc not found!');
13552
+ case 6:
13553
+ _context.prev = 6;
13554
+ _context.next = 9;
13555
+ return _solidLogic.store.fetcher.webOperation('PUT', keyAclDoc.value, {
13556
+ data: aclBody,
13557
+ contentType: 'text/turtle'
13558
+ });
13559
+ case 9:
13560
+ _context.next = 16;
13561
+ break;
13562
+ case 11:
13563
+ _context.prev = 11;
13564
+ _context.t0 = _context["catch"](6);
13565
+ if (!((_context.t0 === null || _context.t0 === void 0 ? void 0 : (_err$response = _context.t0.response) === null || _err$response === void 0 ? void 0 : _err$response.status) !== 404)) {
13566
+ _context.next = 15;
13567
+ break;
13568
+ }
13569
+ throw new Error(_context.t0);
13570
+ case 15:
13571
+ debug.log('delete ' + keyAclDoc.value + ' ' + _context.t0.response.status); // should test 404 and 2xx
13572
+ case 16:
13573
+ case "end":
13574
+ return _context.stop();
13575
+ }
13576
+ }, _callee, null, [[6, 11]]);
13577
+ }));
13578
+ return _setAcl.apply(this, arguments);
13579
+ }
13580
+ var keyContainerAclBody = function keyContainerAclBody(me) {
13581
+ 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:default key:;\n acl:agent <".concat(me, ">;\n acl:mode acl:Read, acl:Write.\n");
13582
+ return aclBody;
13583
+ };
13584
+
13585
+ /**
13586
+ * Read only ACL
13587
+ * @param keyDoc
13588
+ * @param me
13589
+ * @returns aclBody
13590
+ */
13591
+ exports.keyContainerAclBody = keyContainerAclBody;
13592
+ var keyAclBody = function keyAclBody(keyDoc, me) {
13593
+ var keyAgent = 'acl:agentClass foaf:Agent'; // publicKey
13594
+ if (me !== null && me !== void 0 && me.length) keyAgent = "acl:agent <".concat(me, ">"); // privateKey
13595
+ 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.\n");
13596
+ return aclBody;
13597
+ };
13598
+ exports.keyAclBody = keyAclBody;
13599
+ //# sourceMappingURL=acl.js.map
13600
+
13601
+ /***/ }),
13602
+
13160
13603
  /***/ "./lib/utils/label.js":
13161
13604
  /*!****************************!*\
13162
13605
  !*** ./lib/utils/label.js ***!
@@ -13285,8 +13728,8 @@ Object.defineProperty(exports, "__esModule", ({
13285
13728
  }));
13286
13729
  exports.versionInfo = void 0;
13287
13730
  var versionInfo = {
13288
- buildTime: '2023-04-21T21:20:49Z',
13289
- commit: 'dc50c4e2addac6176cf97d2ef510c5f33531df21',
13731
+ buildTime: '2023-05-25T09:41:42Z',
13732
+ commit: 'ddcbbf49a287dc4333053f0089d79aa41b1157c4',
13290
13733
  npmInfo: {
13291
13734
  'solid-ui': '2.4.27',
13292
13735
  npm: '8.19.4',
@@ -61972,14 +62415,17 @@ __webpack_require__.r(__webpack_exports__);
61972
62415
  /* harmony export */ "createRemoteJWKSet": () => (/* binding */ createRemoteJWKSet)
61973
62416
  /* harmony export */ });
61974
62417
  /* 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");
61975
- /* harmony import */ var _runtime_env_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../runtime/env.js */ "./node_modules/jose/dist/browser/runtime/env.js");
61976
- /* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
61977
- /* harmony import */ var _local_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./local.js */ "./node_modules/jose/dist/browser/jwks/local.js");
61978
-
62418
+ /* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
62419
+ /* harmony import */ var _local_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./local.js */ "./node_modules/jose/dist/browser/jwks/local.js");
61979
62420
 
61980
62421
 
61981
62422
 
61982
- class RemoteJWKSet extends _local_js__WEBPACK_IMPORTED_MODULE_3__.LocalJWKSet {
62423
+ function isCloudflareWorkers() {
62424
+ return (typeof WebSocketPair !== 'undefined' ||
62425
+ (typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers') ||
62426
+ (typeof EdgeRuntime !== 'undefined' && EdgeRuntime === 'vercel'));
62427
+ }
62428
+ class RemoteJWKSet extends _local_js__WEBPACK_IMPORTED_MODULE_2__.LocalJWKSet {
61983
62429
  constructor(url, options) {
61984
62430
  super({ keys: [] });
61985
62431
  this._jwks = undefined;
@@ -62012,7 +62458,7 @@ class RemoteJWKSet extends _local_js__WEBPACK_IMPORTED_MODULE_3__.LocalJWKSet {
62012
62458
  return await super.getKey(protectedHeader, token);
62013
62459
  }
62014
62460
  catch (err) {
62015
- if (err instanceof _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JWKSNoMatchingKey) {
62461
+ if (err instanceof _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JWKSNoMatchingKey) {
62016
62462
  if (this.coolingDown() === false) {
62017
62463
  await this.reload();
62018
62464
  return super.getKey(protectedHeader, token);
@@ -62022,13 +62468,13 @@ class RemoteJWKSet extends _local_js__WEBPACK_IMPORTED_MODULE_3__.LocalJWKSet {
62022
62468
  }
62023
62469
  }
62024
62470
  async reload() {
62025
- if (this._pendingFetch && (0,_runtime_env_js__WEBPACK_IMPORTED_MODULE_1__.isCloudflareWorkers)()) {
62471
+ if (this._pendingFetch && isCloudflareWorkers()) {
62026
62472
  this._pendingFetch = undefined;
62027
62473
  }
62028
62474
  this._pendingFetch || (this._pendingFetch = (0,_runtime_fetch_jwks_js__WEBPACK_IMPORTED_MODULE_0__["default"])(this._url, this._timeoutDuration, this._options)
62029
62475
  .then((json) => {
62030
- if (!(0,_local_js__WEBPACK_IMPORTED_MODULE_3__.isJWKSLike)(json)) {
62031
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JWKSInvalid('JSON Web Key Set malformed');
62476
+ if (!(0,_local_js__WEBPACK_IMPORTED_MODULE_2__.isJWKSLike)(json)) {
62477
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JWKSInvalid('JSON Web Key Set malformed');
62032
62478
  }
62033
62479
  this._jwks = { keys: json.keys };
62034
62480
  this._jwksTimestamp = Date.now();
@@ -63216,8 +63662,6 @@ __webpack_require__.r(__webpack_exports__);
63216
63662
  /* harmony export */ "checkEncCryptoKey": () => (/* binding */ checkEncCryptoKey),
63217
63663
  /* harmony export */ "checkSigCryptoKey": () => (/* binding */ checkSigCryptoKey)
63218
63664
  /* harmony export */ });
63219
- /* harmony import */ var _runtime_env_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../runtime/env.js */ "./node_modules/jose/dist/browser/runtime/env.js");
63220
-
63221
63665
  function unusable(name, prop = 'algorithm.name') {
63222
63666
  return new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
63223
63667
  }
@@ -63292,11 +63736,6 @@ function checkSigCryptoKey(key, alg, ...usages) {
63292
63736
  }
63293
63737
  case 'EdDSA': {
63294
63738
  if (key.algorithm.name !== 'Ed25519' && key.algorithm.name !== 'Ed448') {
63295
- if ((0,_runtime_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)()) {
63296
- if (isAlgorithm(key.algorithm, 'NODE-ED25519'))
63297
- break;
63298
- throw unusable('Ed25519, Ed448, or NODE-ED25519');
63299
- }
63300
63739
  throw unusable('Ed25519 or Ed448');
63301
63740
  }
63302
63741
  break;
@@ -64127,14 +64566,12 @@ __webpack_require__.r(__webpack_exports__);
64127
64566
  /* harmony export */ "toPKCS8": () => (/* binding */ toPKCS8),
64128
64567
  /* harmony export */ "toSPKI": () => (/* binding */ toSPKI)
64129
64568
  /* harmony export */ });
64130
- /* harmony import */ var _env_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./env.js */ "./node_modules/jose/dist/browser/runtime/env.js");
64131
- /* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webcrypto.js */ "./node_modules/jose/dist/browser/runtime/webcrypto.js");
64132
- /* 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");
64133
- /* harmony import */ var _base64url_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./base64url.js */ "./node_modules/jose/dist/browser/runtime/base64url.js");
64134
- /* 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");
64135
- /* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
64136
- /* 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");
64137
-
64569
+ /* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webcrypto.js */ "./node_modules/jose/dist/browser/runtime/webcrypto.js");
64570
+ /* 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");
64571
+ /* harmony import */ var _base64url_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base64url.js */ "./node_modules/jose/dist/browser/runtime/base64url.js");
64572
+ /* 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");
64573
+ /* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
64574
+ /* 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");
64138
64575
 
64139
64576
 
64140
64577
 
@@ -64142,8 +64579,8 @@ __webpack_require__.r(__webpack_exports__);
64142
64579
 
64143
64580
 
64144
64581
  const genericExport = async (keyType, keyFormat, key) => {
64145
- if (!(0,_webcrypto_js__WEBPACK_IMPORTED_MODULE_1__.isCryptoKey)(key)) {
64146
- throw new TypeError((0,_lib_invalid_key_input_js__WEBPACK_IMPORTED_MODULE_2__["default"])(key, ..._is_key_like_js__WEBPACK_IMPORTED_MODULE_6__.types));
64582
+ if (!(0,_webcrypto_js__WEBPACK_IMPORTED_MODULE_0__.isCryptoKey)(key)) {
64583
+ throw new TypeError((0,_lib_invalid_key_input_js__WEBPACK_IMPORTED_MODULE_1__["default"])(key, ..._is_key_like_js__WEBPACK_IMPORTED_MODULE_5__.types));
64147
64584
  }
64148
64585
  if (!key.extractable) {
64149
64586
  throw new TypeError('CryptoKey is not extractable');
@@ -64151,7 +64588,7 @@ const genericExport = async (keyType, keyFormat, key) => {
64151
64588
  if (key.type !== keyType) {
64152
64589
  throw new TypeError(`key is not a ${keyType} key`);
64153
64590
  }
64154
- 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`);
64591
+ 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`);
64155
64592
  };
64156
64593
  const toSPKI = (key) => {
64157
64594
  return genericExport('public', 'spki', key);
@@ -64189,11 +64626,11 @@ const getNamedCurve = (keyData) => {
64189
64626
  case findOid(keyData, [0x2b, 0x65, 0x71]):
64190
64627
  return 'Ed448';
64191
64628
  default:
64192
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_5__.JOSENotSupported('Invalid or unsupported EC Key Curve or OKP Key Sub Type');
64629
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_4__.JOSENotSupported('Invalid or unsupported EC Key Curve or OKP Key Sub Type');
64193
64630
  }
64194
64631
  };
64195
64632
  const genericImport = async (replace, keyFormat, pem, alg, options) => {
64196
- var _a, _b;
64633
+ var _a;
64197
64634
  let algorithm;
64198
64635
  let keyUsages;
64199
64636
  const keyData = new Uint8Array(atob(pem.replace(replace, ''))
@@ -64249,20 +64686,9 @@ const genericImport = async (replace, keyFormat, pem, alg, options) => {
64249
64686
  keyUsages = isPublic ? ['verify'] : ['sign'];
64250
64687
  break;
64251
64688
  default:
64252
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_5__.JOSENotSupported('Invalid or unsupported "alg" (Algorithm) value');
64253
- }
64254
- try {
64255
- 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);
64256
- }
64257
- catch (err) {
64258
- if (algorithm.name === 'Ed25519' &&
64259
- (err === null || err === void 0 ? void 0 : err.name) === 'NotSupportedError' &&
64260
- (0,_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)()) {
64261
- algorithm = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
64262
- 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);
64263
- }
64264
- throw err;
64689
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_4__.JOSENotSupported('Invalid or unsupported "alg" (Algorithm) value');
64265
64690
  }
64691
+ 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);
64266
64692
  };
64267
64693
  const fromPKCS8 = (pem, alg, options) => {
64268
64694
  return genericImport(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g, 'pkcs8', pem, alg, options);
@@ -64331,12 +64757,12 @@ function parseElement(bytes) {
64331
64757
  }
64332
64758
  function spkiFromX509(buf) {
64333
64759
  const tbsCertificate = getElement(getElement(parseElement(buf).contents)[0].contents);
64334
- return (0,_base64url_js__WEBPACK_IMPORTED_MODULE_3__.encodeBase64)(tbsCertificate[tbsCertificate[0].raw[0] === 0xa0 ? 6 : 5].raw);
64760
+ return (0,_base64url_js__WEBPACK_IMPORTED_MODULE_2__.encodeBase64)(tbsCertificate[tbsCertificate[0].raw[0] === 0xa0 ? 6 : 5].raw);
64335
64761
  }
64336
64762
  function getSPKI(x509) {
64337
64763
  const pem = x509.replace(/(?:-----(?:BEGIN|END) CERTIFICATE-----|\s)/g, '');
64338
- const raw = (0,_base64url_js__WEBPACK_IMPORTED_MODULE_3__.decodeBase64)(pem);
64339
- return (0,_lib_format_pem_js__WEBPACK_IMPORTED_MODULE_4__["default"])(spkiFromX509(raw), 'PUBLIC KEY');
64764
+ const raw = (0,_base64url_js__WEBPACK_IMPORTED_MODULE_2__.decodeBase64)(pem);
64765
+ return (0,_lib_format_pem_js__WEBPACK_IMPORTED_MODULE_3__["default"])(spkiFromX509(raw), 'PUBLIC KEY');
64340
64766
  }
64341
64767
  const fromX509 = (pem, alg, options) => {
64342
64768
  let spki;
@@ -64764,26 +65190,6 @@ const encrypt = async (enc, plaintext, cek, iv, aad) => {
64764
65190
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (encrypt);
64765
65191
 
64766
65192
 
64767
- /***/ }),
64768
-
64769
- /***/ "./node_modules/jose/dist/browser/runtime/env.js":
64770
- /*!*******************************************************!*\
64771
- !*** ./node_modules/jose/dist/browser/runtime/env.js ***!
64772
- \*******************************************************/
64773
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
64774
-
64775
- "use strict";
64776
- __webpack_require__.r(__webpack_exports__);
64777
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
64778
- /* harmony export */ "isCloudflareWorkers": () => (/* binding */ isCloudflareWorkers)
64779
- /* harmony export */ });
64780
- function isCloudflareWorkers() {
64781
- return (typeof WebSocketPair !== 'undefined' ||
64782
- (typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers') ||
64783
- (typeof EdgeRuntime !== 'undefined' && EdgeRuntime === 'vercel'));
64784
- }
64785
-
64786
-
64787
65193
  /***/ }),
64788
65194
 
64789
65195
  /***/ "./node_modules/jose/dist/browser/runtime/fetch_jwks.js":
@@ -64848,11 +65254,9 @@ __webpack_require__.r(__webpack_exports__);
64848
65254
  /* harmony export */ "generateKeyPair": () => (/* binding */ generateKeyPair),
64849
65255
  /* harmony export */ "generateSecret": () => (/* binding */ generateSecret)
64850
65256
  /* harmony export */ });
64851
- /* harmony import */ var _env_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./env.js */ "./node_modules/jose/dist/browser/runtime/env.js");
64852
- /* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webcrypto.js */ "./node_modules/jose/dist/browser/runtime/webcrypto.js");
64853
- /* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
64854
- /* harmony import */ var _random_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./random.js */ "./node_modules/jose/dist/browser/runtime/random.js");
64855
-
65257
+ /* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webcrypto.js */ "./node_modules/jose/dist/browser/runtime/webcrypto.js");
65258
+ /* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
65259
+ /* harmony import */ var _random_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./random.js */ "./node_modules/jose/dist/browser/runtime/random.js");
64856
65260
 
64857
65261
 
64858
65262
 
@@ -64873,7 +65277,7 @@ async function generateSecret(alg, options) {
64873
65277
  case 'A192CBC-HS384':
64874
65278
  case 'A256CBC-HS512':
64875
65279
  length = parseInt(alg.slice(-3), 10);
64876
- return (0,_random_js__WEBPACK_IMPORTED_MODULE_3__["default"])(new Uint8Array(length >> 3));
65280
+ return (0,_random_js__WEBPACK_IMPORTED_MODULE_2__["default"])(new Uint8Array(length >> 3));
64877
65281
  case 'A128KW':
64878
65282
  case 'A192KW':
64879
65283
  case 'A256KW':
@@ -64892,20 +65296,20 @@ async function generateSecret(alg, options) {
64892
65296
  keyUsages = ['encrypt', 'decrypt'];
64893
65297
  break;
64894
65298
  default:
64895
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
65299
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
64896
65300
  }
64897
- 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);
65301
+ 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);
64898
65302
  }
64899
65303
  function getModulusLengthOption(options) {
64900
65304
  var _a;
64901
65305
  const modulusLength = (_a = options === null || options === void 0 ? void 0 : options.modulusLength) !== null && _a !== void 0 ? _a : 2048;
64902
65306
  if (typeof modulusLength !== 'number' || modulusLength < 2048) {
64903
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported('Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used');
65307
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used');
64904
65308
  }
64905
65309
  return modulusLength;
64906
65310
  }
64907
65311
  async function generateKeyPair(alg, options) {
64908
- var _a, _b, _c, _d;
65312
+ var _a, _b, _c;
64909
65313
  let algorithm;
64910
65314
  let keyUsages;
64911
65315
  switch (alg) {
@@ -64964,7 +65368,7 @@ async function generateKeyPair(alg, options) {
64964
65368
  algorithm = { name: crv };
64965
65369
  break;
64966
65370
  default:
64967
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported('Invalid or unsupported crv option provided');
65371
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported crv option provided');
64968
65372
  }
64969
65373
  break;
64970
65374
  case 'ECDH-ES':
@@ -64985,25 +65389,14 @@ async function generateKeyPair(alg, options) {
64985
65389
  algorithm = { name: crv };
64986
65390
  break;
64987
65391
  default:
64988
- 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');
65392
+ 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');
64989
65393
  }
64990
65394
  break;
64991
65395
  }
64992
65396
  default:
64993
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
64994
- }
64995
- try {
64996
- 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));
64997
- }
64998
- catch (err) {
64999
- if (algorithm.name === 'Ed25519' &&
65000
- (err === null || err === void 0 ? void 0 : err.name) === 'NotSupportedError' &&
65001
- (0,_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)()) {
65002
- algorithm = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
65003
- 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));
65004
- }
65005
- throw err;
65397
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
65006
65398
  }
65399
+ 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));
65007
65400
  }
65008
65401
 
65009
65402
 
@@ -65078,11 +65471,9 @@ __webpack_require__.r(__webpack_exports__);
65078
65471
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
65079
65472
  /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
65080
65473
  /* harmony export */ });
65081
- /* harmony import */ var _env_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./env.js */ "./node_modules/jose/dist/browser/runtime/env.js");
65082
- /* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webcrypto.js */ "./node_modules/jose/dist/browser/runtime/webcrypto.js");
65083
- /* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
65084
- /* harmony import */ var _base64url_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./base64url.js */ "./node_modules/jose/dist/browser/runtime/base64url.js");
65085
-
65474
+ /* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webcrypto.js */ "./node_modules/jose/dist/browser/runtime/webcrypto.js");
65475
+ /* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
65476
+ /* harmony import */ var _base64url_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base64url.js */ "./node_modules/jose/dist/browser/runtime/base64url.js");
65086
65477
 
65087
65478
 
65088
65479
 
@@ -65101,7 +65492,7 @@ function subtleMapping(jwk) {
65101
65492
  case 'A128CBC-HS256':
65102
65493
  case 'A192CBC-HS384':
65103
65494
  case 'A256CBC-HS512':
65104
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported(`${jwk.alg} keys cannot be imported as CryptoKey instances`);
65495
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported(`${jwk.alg} keys cannot be imported as CryptoKey instances`);
65105
65496
  case 'A128GCM':
65106
65497
  case 'A192GCM':
65107
65498
  case 'A256GCM':
@@ -65124,7 +65515,7 @@ function subtleMapping(jwk) {
65124
65515
  keyUsages = ['deriveBits'];
65125
65516
  break;
65126
65517
  default:
65127
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
65518
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
65128
65519
  }
65129
65520
  break;
65130
65521
  }
@@ -65153,7 +65544,7 @@ function subtleMapping(jwk) {
65153
65544
  keyUsages = jwk.d ? ['decrypt', 'unwrapKey'] : ['encrypt', 'wrapKey'];
65154
65545
  break;
65155
65546
  default:
65156
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
65547
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
65157
65548
  }
65158
65549
  break;
65159
65550
  }
@@ -65179,7 +65570,7 @@ function subtleMapping(jwk) {
65179
65570
  keyUsages = jwk.d ? ['deriveBits'] : [];
65180
65571
  break;
65181
65572
  default:
65182
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
65573
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
65183
65574
  }
65184
65575
  break;
65185
65576
  }
@@ -65197,12 +65588,12 @@ function subtleMapping(jwk) {
65197
65588
  keyUsages = jwk.d ? ['deriveBits'] : [];
65198
65589
  break;
65199
65590
  default:
65200
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
65591
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
65201
65592
  }
65202
65593
  break;
65203
65594
  }
65204
65595
  default:
65205
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
65596
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
65206
65597
  }
65207
65598
  return { algorithm, keyUsages };
65208
65599
  }
@@ -65218,23 +65609,12 @@ const parse = async (jwk) => {
65218
65609
  (_b = jwk.key_ops) !== null && _b !== void 0 ? _b : keyUsages,
65219
65610
  ];
65220
65611
  if (algorithm.name === 'PBKDF2') {
65221
- return _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.importKey('raw', (0,_base64url_js__WEBPACK_IMPORTED_MODULE_3__.decode)(jwk.k), ...rest);
65612
+ return _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__["default"].subtle.importKey('raw', (0,_base64url_js__WEBPACK_IMPORTED_MODULE_2__.decode)(jwk.k), ...rest);
65222
65613
  }
65223
65614
  const keyData = { ...jwk };
65224
65615
  delete keyData.alg;
65225
65616
  delete keyData.use;
65226
- try {
65227
- return await _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.importKey('jwk', keyData, ...rest);
65228
- }
65229
- catch (err) {
65230
- if (algorithm.name === 'Ed25519' &&
65231
- (err === null || err === void 0 ? void 0 : err.name) === 'NotSupportedError' &&
65232
- (0,_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)()) {
65233
- rest[0] = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
65234
- return await _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.importKey('jwk', keyData, ...rest);
65235
- }
65236
- throw err;
65237
- }
65617
+ return _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__["default"].subtle.importKey('jwk', keyData, ...rest);
65238
65618
  };
65239
65619
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (parse);
65240
65620
 
@@ -65476,9 +65856,7 @@ __webpack_require__.r(__webpack_exports__);
65476
65856
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
65477
65857
  /* harmony export */ "default": () => (/* binding */ subtleDsa)
65478
65858
  /* harmony export */ });
65479
- /* harmony import */ var _env_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./env.js */ "./node_modules/jose/dist/browser/runtime/env.js");
65480
- /* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
65481
-
65859
+ /* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
65482
65860
 
65483
65861
  function subtleDsa(alg, algorithm) {
65484
65862
  const hash = `SHA-${alg.slice(-3)}`;
@@ -65500,12 +65878,9 @@ function subtleDsa(alg, algorithm) {
65500
65878
  case 'ES512':
65501
65879
  return { hash, name: 'ECDSA', namedCurve: algorithm.namedCurve };
65502
65880
  case 'EdDSA':
65503
- if ((0,_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)() && algorithm.name === 'NODE-ED25519') {
65504
- return { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
65505
- }
65506
65881
  return { name: algorithm.name };
65507
65882
  default:
65508
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
65883
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_0__.JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
65509
65884
  }
65510
65885
  }
65511
65886
 
@@ -66170,22 +66545,7 @@ module.exports = JSON.parse('{"application/1d-interleaved-parityfec":{"source":"
66170
66545
  /******/
66171
66546
  /******/ /* webpack/runtime/publicPath */
66172
66547
  /******/ (() => {
66173
- /******/ var scriptUrl;
66174
- /******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
66175
- /******/ var document = __webpack_require__.g.document;
66176
- /******/ if (!scriptUrl && document) {
66177
- /******/ if (document.currentScript)
66178
- /******/ scriptUrl = document.currentScript.src;
66179
- /******/ if (!scriptUrl) {
66180
- /******/ var scripts = document.getElementsByTagName("script");
66181
- /******/ if(scripts.length) scriptUrl = scripts[scripts.length - 1].src
66182
- /******/ }
66183
- /******/ }
66184
- /******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
66185
- /******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
66186
- /******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
66187
- /******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
66188
- /******/ __webpack_require__.p = scriptUrl;
66548
+ /******/ __webpack_require__.p = "";
66189
66549
  /******/ })();
66190
66550
  /******/
66191
66551
  /******/ /* webpack/runtime/jsonp chunk loading */