solid-ui 2.4.27-7184a38a → 2.4.27-77f914e3

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:
@@ -2703,46 +2703,46 @@ var ChatChannel = /*#__PURE__*/function () {
2703
2703
  sts.push($rdf.st(message, ns.dct('created'), dateStamp, chatDocument));
2704
2704
  msg.created = dateStamp.value;
2705
2705
  if (!me) {
2706
- _context2.next = 36;
2706
+ _context2.next = 35;
2707
2707
  break;
2708
2708
  }
2709
2709
  sts.push($rdf.st(message, ns.foaf('maker'), me, chatDocument));
2710
2710
  msg.maker = me.uri;
2711
2711
  // privateKey the cached private key of me, cached in store
2712
2712
  _context2.next = 32;
2713
- return (0, _keys.getPrivateKey)(me.uri);
2713
+ return (0, _keys.getPrivateKey)(me);
2714
2714
  case 32:
2715
2715
  privateKey = _context2.sent;
2716
+ // me.uri)
2716
2717
  // 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
2718
+ sig = (0, _signature.signMsg)(msg, privateKey); // const pubKey0 = '023a9da707bee1302f66083c9d95673ff969b41607a66f52686fa774d64ceb87'
2719
+ /* const pubKey = await getPublicKey(me)
2720
+ const verify = verifySignature(sig, msg, pubKey) // alain to remove
2721
2721
  debug.warn('sig ' + sig)
2722
2722
  debug.warn('verifySign ' + verify)
2723
2723
  debug.warn(msg) */
2724
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;
2725
+ case 35:
2726
+ _context2.prev = 35;
2727
+ _context2.next = 38;
2728
2728
  return _solidLogic.store.updater.update([], sts);
2729
- case 39:
2730
- _context2.next = 47;
2729
+ case 38:
2730
+ _context2.next = 46;
2731
2731
  break;
2732
- case 41:
2733
- _context2.prev = 41;
2734
- _context2.t0 = _context2["catch"](36);
2732
+ case 40:
2733
+ _context2.prev = 40;
2734
+ _context2.t0 = _context2["catch"](35);
2735
2735
  _errMsg = 'Error saving chat message: ' + _context2.t0;
2736
2736
  debug.warn(_errMsg);
2737
2737
  alert(_errMsg);
2738
2738
  throw new Error(_errMsg);
2739
- case 47:
2739
+ case 46:
2740
2740
  return _context2.abrupt("return", message);
2741
- case 48:
2741
+ case 47:
2742
2742
  case "end":
2743
2743
  return _context2.stop();
2744
2744
  }
2745
- }, _callee2, null, [[36, 41]]);
2745
+ }, _callee2, null, [[35, 40]]);
2746
2746
  })();
2747
2747
  });
2748
2748
  function updateMessage(_x2) {
@@ -4043,7 +4043,8 @@ var _utils = __webpack_require__(/*! @noble/hashes/utils */ "./node_modules/@nob
4043
4043
  var _signature = __webpack_require__(/*! ./signature */ "./lib/chat/signature.js");
4044
4044
  var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
4045
4045
  var $rdf = _interopRequireWildcard(__webpack_require__(/*! rdflib */ "./node_modules/rdflib/esm/index.js"));
4046
- var _cryptoKeyHelpers = __webpack_require__(/*! ../utils/cryptoKeyHelpers */ "./lib/utils/cryptoKeyHelpers.js");
4046
+ var _accessData = __webpack_require__(/*! ../utils/keyHelpers/accessData */ "./lib/utils/keyHelpers/accessData.js");
4047
+ var _acl = __webpack_require__(/*! ../utils/keyHelpers/acl */ "./lib/utils/keyHelpers/acl.js");
4047
4048
  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); }
4048
4049
  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; }
4049
4050
  function generatePrivateKey() {
@@ -4064,29 +4065,37 @@ function _getPublicKey() {
4064
4065
  _context.next = 2;
4065
4066
  return _solidLogic.store.fetcher.load(webId);
4066
4067
  case 2:
4067
- publicKeyDoc = (0, _cryptoKeyHelpers.pubKeyUrl)(webId);
4068
- _context.prev = 3;
4069
- _context.next = 6;
4068
+ _context.next = 4;
4069
+ return (0, _accessData.pubKeyUrl)(webId);
4070
+ case 4:
4071
+ publicKeyDoc = _context.sent;
4072
+ _context.prev = 5;
4073
+ _context.next = 8;
4070
4074
  return _solidLogic.store.fetcher.load(publicKeyDoc);
4071
- case 6:
4075
+ case 8:
4072
4076
  // url.href)
4073
- key = _solidLogic.store.any(_solidLogic.store.sym(webId), _solidLogic.store.sym(_signature.CERT + 'PublicKey'));
4077
+ key = _solidLogic.store.any(webId, _solidLogic.store.sym(_signature.CERT + 'PublicKey'));
4074
4078
  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);
4079
+ case 12:
4080
+ _context.prev = 12;
4081
+ _context.t0 = _context["catch"](5);
4078
4082
  return _context.abrupt("return", undefined);
4079
- case 13:
4083
+ case 15:
4080
4084
  case "end":
4081
4085
  return _context.stop();
4082
4086
  }
4083
- }, _callee, null, [[3, 10]]);
4087
+ }, _callee, null, [[5, 12]]);
4084
4088
  }));
4085
4089
  return _getPublicKey.apply(this, arguments);
4086
4090
  }
4087
4091
  function getPrivateKey(_x2) {
4088
4092
  return _getPrivateKey.apply(this, arguments);
4089
4093
  }
4094
+ /**
4095
+ * delete acl if keydoc exists
4096
+ * create/edit keyDoc
4097
+ * set keyDoc acl
4098
+ */
4090
4099
  function _getPrivateKey() {
4091
4100
  _getPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
4092
4101
  var publicKeyDoc, privateKeyDoc, publicKey, privateKey, validPublicKey, del, add, newPublicKey, keyContainer;
@@ -4096,62 +4105,67 @@ function _getPrivateKey() {
4096
4105
  _context2.next = 2;
4097
4106
  return _solidLogic.store.fetcher.load(webId);
4098
4107
  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:
4108
+ _context2.next = 4;
4109
+ return (0, _accessData.pubKeyUrl)(webId);
4110
+ case 4:
4111
+ publicKeyDoc = _context2.sent;
4112
+ _context2.next = 7;
4113
+ return (0, _accessData.privKeyUrl)(webId);
4114
+ case 7:
4115
+ privateKeyDoc = _context2.sent;
4116
+ _context2.next = 10;
4117
+ return (0, _accessData.getExistingPublicKey)(webId, publicKeyDoc);
4118
+ case 10:
4105
4119
  publicKey = _context2.sent;
4106
- _context2.next = 9;
4107
- return (0, _cryptoKeyHelpers.privateKeyExists)(webId);
4108
- case 9:
4120
+ _context2.next = 13;
4121
+ return (0, _accessData.getExistingPrivateKey)(webId, privateKeyDoc);
4122
+ case 13:
4109
4123
  privateKey = _context2.sent;
4110
4124
  // is publicKey valid ?
4111
4125
  validPublicKey = true;
4112
4126
  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;
4127
+ 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;
4114
4128
  }
4115
4129
 
4116
4130
  // create key pair or repair publicKey
4117
4131
  if (!(!privateKey || !publicKey || !validPublicKey)) {
4118
- _context2.next = 30;
4132
+ _context2.next = 34;
4119
4133
  break;
4120
4134
  }
4121
4135
  del = [];
4122
- add = []; // if (privateKey) del.push($rdf.st($rdf.sym(webId), $rdf.sym(CERT + 'PrivateKey'), $rdf.lit(privateKey), $rdf.sym(privateKeyDoc)))
4136
+ add = []; // if (privateKey) del.push($rdf.st(webId, store.sym(CERT + 'PrivateKey'), $rdf.lit(privateKey), store.sym(privateKeyDoc)))
4123
4137
  if (privateKey) {
4124
- _context2.next = 20;
4138
+ _context2.next = 24;
4125
4139
  break;
4126
4140
  }
4127
4141
  // add = []
4128
4142
  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:
4143
+ add = [$rdf.st(webId, _solidLogic.store.sym(_signature.CERT + 'PrivateKey'), $rdf.literal(privateKey), _solidLogic.store.sym(privateKeyDoc))];
4144
+ _context2.next = 24;
4145
+ return saveKey(privateKeyDoc, [], add, webId.uri);
4146
+ case 24:
4133
4147
  if (!(!publicKey || !validPublicKey)) {
4134
- _context2.next = 27;
4148
+ _context2.next = 31;
4135
4149
  break;
4136
4150
  }
4137
4151
  del = [];
4138
4152
  // delete invalid public key
4139
4153
  if (publicKey) {
4140
- del = [$rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'PublicKey'), $rdf.lit(publicKey), $rdf.sym(publicKeyDoc))];
4154
+ del = [$rdf.st(webId, _solidLogic.store.sym(_signature.CERT + 'PublicKey'), $rdf.lit(publicKey), _solidLogic.store.sym(publicKeyDoc))];
4141
4155
  debug.log(del);
4142
4156
  }
4143
4157
  // update new valid key
4144
4158
  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;
4159
+ add = [$rdf.st(webId, _solidLogic.store.sym(_signature.CERT + 'PublicKey'), $rdf.literal(newPublicKey), _solidLogic.store.sym(publicKeyDoc))];
4160
+ _context2.next = 31;
4147
4161
  return saveKey(publicKeyDoc, del, add);
4148
- case 27:
4162
+ case 31:
4149
4163
  keyContainer = privateKeyDoc.substring(0, privateKeyDoc.lastIndexOf('/') + 1);
4150
- _context2.next = 30;
4151
- return setAcl(keyContainer, keyContainerAclBody(webId));
4152
- case 30:
4164
+ _context2.next = 34;
4165
+ return (0, _acl.setAcl)(keyContainer, (0, _acl.keyContainerAclBody)(webId.uri));
4166
+ case 34:
4153
4167
  return _context2.abrupt("return", privateKey);
4154
- case 31:
4168
+ case 35:
4155
4169
  case "end":
4156
4170
  return _context2.stop();
4157
4171
  }
@@ -4159,113 +4173,67 @@ function _getPrivateKey() {
4159
4173
  }));
4160
4174
  return _getPrivateKey.apply(this, arguments);
4161
4175
  }
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) {
4176
+ function saveKey(_x3, _x4, _x5) {
4208
4177
  return _saveKey.apply(this, arguments);
4209
4178
  }
4210
4179
  function _saveKey() {
4211
4180
  _saveKey = (0, _asyncToGenerator2["default"])(function (keyDoc, del, add) {
4212
4181
  var me = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
4213
- return /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
4182
+ return /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
4214
4183
  var keyAclDoc, response, aclBody;
4215
- return _regenerator["default"].wrap(function _callee4$(_context4) {
4216
- while (1) switch (_context4.prev = _context4.next) {
4184
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
4185
+ while (1) switch (_context3.prev = _context3.next) {
4217
4186
  case 0:
4218
- _context4.next = 2;
4219
- return _solidLogic.store.updater.updateMany(del, add);
4220
- case 2:
4221
- _context4.next = 4;
4187
+ _context3.next = 2;
4222
4188
  return _solidLogic.store.fetcher.load(keyDoc);
4223
- case 4:
4224
- _context4.prev = 4;
4189
+ case 2:
4190
+ _context3.prev = 2;
4225
4191
  // 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;
4192
+ keyAclDoc = _solidLogic.store.any(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl'));
4193
+ if (!keyAclDoc) {
4194
+ _context3.next = 17;
4229
4195
  break;
4230
4196
  }
4231
- throw new Error("".concat(keyDoc, " ACL doc not found!"));
4232
- case 8:
4233
- _context4.prev = 8;
4234
- _context4.next = 11;
4197
+ _context3.prev = 5;
4198
+ _context3.next = 8;
4235
4199
  return _solidLogic.store.fetcher.webOperation('DELETE', keyAclDoc.value);
4236
- case 11:
4237
- response = _context4.sent;
4200
+ case 8:
4201
+ response = _context3.sent;
4238
4202
  // this may fail if webId is not an owner
4239
4203
  debug.log('delete ' + keyAclDoc.value + ' ' + response.status); // should test 404 and 2xx
4240
- _context4.next = 20;
4204
+ _context3.next = 17;
4241
4205
  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;
4206
+ case 12:
4207
+ _context3.prev = 12;
4208
+ _context3.t0 = _context3["catch"](5);
4209
+ if (!(_context3.t0.response.status !== 404)) {
4210
+ _context3.next = 16;
4247
4211
  break;
4248
4212
  }
4249
- throw new Error(_context4.t0);
4213
+ throw new Error(_context3.t0);
4214
+ case 16:
4215
+ debug.log('delete ' + keyAclDoc.value + ' ' + _context3.t0.response.status); // should test 404 and 2xx
4216
+ case 17:
4217
+ _context3.next = 19;
4218
+ return _solidLogic.store.updater.updateMany(del, add);
4250
4219
  case 19:
4251
- debug.log('delete ' + keyAclDoc.value + ' ' + _context4.t0.response.status); // should test 404 and 2xx
4252
- case 20:
4220
+ // or a promise store.updater.update ?
4253
4221
  // 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;
4222
+ aclBody = (0, _acl.keyAclBody)(keyDoc, me);
4223
+ _context3.next = 22;
4224
+ return (0, _acl.setAcl)(keyDoc, aclBody);
4225
+ case 22:
4226
+ _context3.next = 27;
4259
4227
  break;
4260
- case 25:
4261
- _context4.prev = 25;
4262
- _context4.t1 = _context4["catch"](4);
4263
- throw new Error(_context4.t1);
4264
- case 28:
4228
+ case 24:
4229
+ _context3.prev = 24;
4230
+ _context3.t1 = _context3["catch"](2);
4231
+ throw new Error(_context3.t1);
4232
+ case 27:
4265
4233
  case "end":
4266
- return _context4.stop();
4234
+ return _context3.stop();
4267
4235
  }
4268
- }, _callee4, null, [[4, 25], [8, 15]]);
4236
+ }, _callee3, null, [[2, 24], [5, 12]]);
4269
4237
  })();
4270
4238
  });
4271
4239
  return _saveKey.apply(this, arguments);
@@ -4417,11 +4385,11 @@ function renderMessageRow(channelObject, message, fresh, options, userContext) {
4417
4385
 
4418
4386
  // signed message, get public key and check signature
4419
4387
  else {
4420
- (0, _keys.getPublicKey)(creator.uri).then(function (publicKey) {
4388
+ (0, _keys.getPublicKey)(creator).then(function (publicKey) {
4421
4389
  debug.log(creator.uri + '\n' + msg.created + '\n' + msg.id + '\n' + publicKey);
4422
4390
  if (!publicKey) {
4423
4391
  // TODO try to recreate the publicKey
4424
- // if(me.uri === creator.uri) await getPrivateKey(creator.uri)
4392
+ // if(me.uri === creator.uri) await getPrivateKey(creator)
4425
4393
  debug.warn('message is signed but ' + creator.uri + ' is missing publicKey');
4426
4394
  }
4427
4395
  // check that publicKey is a valid hex string
@@ -5224,13 +5192,11 @@ Object.defineProperty(exports, "__esModule", ({
5224
5192
  value: true
5225
5193
  }));
5226
5194
  exports.SEC = exports.CERT = void 0;
5227
- exports.finishMsg = finishMsg;
5228
5195
  exports.getBlankMsg = getBlankMsg;
5229
5196
  exports.getMsgHash = getMsgHash;
5230
5197
  exports.serializeMsg = serializeMsg;
5231
5198
  exports.signMsg = signMsg;
5232
5199
  exports.utf8Encoder = exports.utf8Decoder = void 0;
5233
- exports.validateMsg = validateMsg;
5234
5200
  exports.verifySignature = verifySignature;
5235
5201
  var _secp256k = __webpack_require__(/*! @noble/curves/secp256k1 */ "./node_modules/@noble/curves/secp256k1.js");
5236
5202
  var _utils = __webpack_require__(/*! @noble/hashes/utils */ "./node_modules/@noble/hashes/utils.js");
@@ -5276,19 +5242,22 @@ function getBlankMsg() {
5276
5242
  id: '',
5277
5243
  created: '',
5278
5244
  dateDeleted: '',
5245
+ // TODO to remove if not used
5279
5246
  content: '',
5280
5247
  maker: '',
5281
- sig: ''
5248
+ sig: '' // TODO to remove if not used
5282
5249
  };
5283
5250
  }
5284
- function finishMsg(t, privateKey) {
5285
- // to update to chat message triples
5286
- var message = t;
5287
- // message.pubkey = getPublicKey(privateKey)
5288
- message.id = getMsgHash(message);
5289
- message.sig = signMsg(message, privateKey);
5290
- return message;
5291
- }
5251
+
5252
+ /* export function finishMsg (t: MsgTemplate, privateKey: string): Message {
5253
+ // to update to chat message triples
5254
+ const message = t as Message
5255
+ // message.pubkey = getPublicKey(privateKey)
5256
+ message.id = getMsgHash(message)
5257
+ message.sig = signMsg(message, privateKey)
5258
+ return message
5259
+ } */
5260
+
5292
5261
  function serializeMsg(msg) {
5293
5262
  // to update to chat messages triples
5294
5263
  /* if (!validateMsg(msg))
@@ -5300,27 +5269,29 @@ function getMsgHash(message) {
5300
5269
  var msgHash = (0, _sha.sha256)(utf8Encoder.encode(serializeMsg(message)));
5301
5270
  return (0, _utils.bytesToHex)(msgHash);
5302
5271
  }
5303
- var isRecord = function isRecord(obj) {
5304
- return obj instanceof Object;
5305
- };
5306
- function validateMsg(message) {
5307
- /* if (!isRecord(message)) return false
5272
+
5273
+ // const isRecord = (obj: unknown): obj is Record<string, unknown> => obj instanceof Object
5274
+
5275
+ /* export function validateMsg<T> (message: T): message is T & UnsignedMsg {
5276
+ if (!isRecord(message)) return false
5308
5277
  if (typeof message.kind !== 'number') return false
5309
5278
  if (typeof message.content !== 'string') return false
5310
5279
  if (typeof message.created_at !== 'number') return false
5311
5280
  if (typeof message.pubkey !== 'string') return false
5312
5281
  if (!message.pubkey.match(/^[a-f0-9]{64}$/)) return false
5313
- if (!Array.isArray(message.tags)) return false
5282
+
5283
+ if (!Array.isArray(message.tags)) return false
5314
5284
  for (let i = 0; i < message.tags.length; i++) {
5315
5285
  let tag = message.tags[i]
5316
5286
  if (!Array.isArray(tag)) return false
5317
5287
  for (let j = 0; j < tag.length; j++) {
5318
5288
  if (typeof tag[j] === 'object') return false
5319
5289
  }
5320
- } */
5290
+ }
5291
+
5292
+ return true
5293
+ } */
5321
5294
 
5322
- return true;
5323
- }
5324
5295
  function verifySignature(sig, message, pubKey) {
5325
5296
  return _secp256k.schnorr.verify(sig, getMsgHash(message), pubKey);
5326
5297
  }
@@ -12531,173 +12502,6 @@ function isLight(x) {
12531
12502
 
12532
12503
  /***/ }),
12533
12504
 
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
-
12701
12505
  /***/ "./lib/utils/headerFooterHelpers.js":
12702
12506
  /*!******************************************!*\
12703
12507
  !*** ./lib/utils/headerFooterHelpers.js ***!
@@ -13416,6 +13220,353 @@ function predParentOf(node) {
13416
13220
 
13417
13221
  /***/ }),
13418
13222
 
13223
+ /***/ "./lib/utils/keyHelpers/accessData.js":
13224
+ /*!********************************************!*\
13225
+ !*** ./lib/utils/keyHelpers/accessData.js ***!
13226
+ \********************************************/
13227
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
13228
+
13229
+ "use strict";
13230
+
13231
+
13232
+ var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");
13233
+ var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
13234
+ Object.defineProperty(exports, "__esModule", ({
13235
+ value: true
13236
+ }));
13237
+ exports.getExistingPrivateKey = getExistingPrivateKey;
13238
+ exports.getExistingPublicKey = getExistingPublicKey;
13239
+ exports.getKeyIfExists = getKeyIfExists;
13240
+ exports.pubKeyUrl = exports.privKeyUrl = exports.getPodRoot = void 0;
13241
+ var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
13242
+ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
13243
+ var debug = _interopRequireWildcard(__webpack_require__(/*! ../../debug */ "./lib/debug.js"));
13244
+ var _signature = __webpack_require__(/*! ../../chat/signature */ "./lib/chat/signature.js");
13245
+ var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
13246
+ var ns = _interopRequireWildcard(__webpack_require__(/*! ../../ns */ "./lib/ns.js"));
13247
+ 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); }
13248
+ 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; }
13249
+ var getPodRoot = /*#__PURE__*/function () {
13250
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
13251
+ var _podRoot;
13252
+ var webIdURL, storages, podRoot, path, _res$headers$get, res;
13253
+ return _regenerator["default"].wrap(function _callee$(_context) {
13254
+ while (1) switch (_context.prev = _context.next) {
13255
+ case 0:
13256
+ webIdURL = new URL(webId.uri); // find storages in webId document
13257
+ _context.next = 3;
13258
+ return _solidLogic.store.fetcher.load(webId.uri);
13259
+ case 3:
13260
+ storages = _solidLogic.store.each(webId, ns.space('storage'), null, webId.doc());
13261
+ if (storages !== null && storages !== void 0 && storages.length) {
13262
+ _context.next = 19;
13263
+ break;
13264
+ }
13265
+ // find storage recursively in webId URL
13266
+ path = webIdURL.pathname;
13267
+ case 6:
13268
+ if (!path.length) {
13269
+ _context.next = 17;
13270
+ break;
13271
+ }
13272
+ path = path.substring(0, path.lastIndexOf('/'));
13273
+ podRoot = _solidLogic.store.sym(webIdURL.origin + path + '/');
13274
+ _context.next = 11;
13275
+ return _solidLogic.store.fetcher.webOperation('HEAD', podRoot.uri);
13276
+ case 11:
13277
+ res = _context.sent;
13278
+ if (!((_res$headers$get = res.headers.get('link')) !== null && _res$headers$get !== void 0 && _res$headers$get.includes(ns.space('Storage').value))) {
13279
+ _context.next = 14;
13280
+ break;
13281
+ }
13282
+ return _context.abrupt("break", 17);
13283
+ case 14:
13284
+ if (!path) debug.warn("Current user storage not found for\n".concat(webId));
13285
+ _context.next = 6;
13286
+ break;
13287
+ case 17:
13288
+ _context.next = 21;
13289
+ break;
13290
+ case 19:
13291
+ // give preference to storage in webId root
13292
+ podRoot = storages.find(function (storage) {
13293
+ return webIdURL.origin === new URL(storage.value).origin;
13294
+ });
13295
+ if (!podRoot) podRoot = storages[0];
13296
+ case 21:
13297
+ return _context.abrupt("return", (_podRoot = podRoot) === null || _podRoot === void 0 ? void 0 : _podRoot.value);
13298
+ case 22:
13299
+ case "end":
13300
+ return _context.stop();
13301
+ }
13302
+ }, _callee);
13303
+ }));
13304
+ return function getPodRoot(_x) {
13305
+ return _ref.apply(this, arguments);
13306
+ };
13307
+ }();
13308
+ exports.getPodRoot = getPodRoot;
13309
+ var pubKeyUrl = /*#__PURE__*/function () {
13310
+ var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
13311
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
13312
+ while (1) switch (_context2.prev = _context2.next) {
13313
+ case 0:
13314
+ _context2.prev = 0;
13315
+ _context2.next = 3;
13316
+ return getPodRoot(webId);
13317
+ case 3:
13318
+ _context2.t0 = _context2.sent;
13319
+ return _context2.abrupt("return", _context2.t0 + 'profile/keys/publicKey.ttl');
13320
+ case 7:
13321
+ _context2.prev = 7;
13322
+ _context2.t1 = _context2["catch"](0);
13323
+ throw new Error(_context2.t1);
13324
+ case 10:
13325
+ case "end":
13326
+ return _context2.stop();
13327
+ }
13328
+ }, _callee2, null, [[0, 7]]);
13329
+ }));
13330
+ return function pubKeyUrl(_x2) {
13331
+ return _ref2.apply(this, arguments);
13332
+ };
13333
+ }();
13334
+ exports.pubKeyUrl = pubKeyUrl;
13335
+ function getExistingPublicKey(_x3, _x4) {
13336
+ return _getExistingPublicKey.apply(this, arguments);
13337
+ }
13338
+ function _getExistingPublicKey() {
13339
+ _getExistingPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(webId, publicKeyUrl) {
13340
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
13341
+ while (1) switch (_context4.prev = _context4.next) {
13342
+ case 0:
13343
+ _context4.next = 2;
13344
+ return getKeyIfExists(webId, publicKeyUrl, 'PublicKey');
13345
+ case 2:
13346
+ return _context4.abrupt("return", _context4.sent);
13347
+ case 3:
13348
+ case "end":
13349
+ return _context4.stop();
13350
+ }
13351
+ }, _callee4);
13352
+ }));
13353
+ return _getExistingPublicKey.apply(this, arguments);
13354
+ }
13355
+ var privKeyUrl = /*#__PURE__*/function () {
13356
+ var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId) {
13357
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
13358
+ while (1) switch (_context3.prev = _context3.next) {
13359
+ case 0:
13360
+ _context3.prev = 0;
13361
+ _context3.next = 3;
13362
+ return getPodRoot(webId);
13363
+ case 3:
13364
+ _context3.t0 = _context3.sent;
13365
+ return _context3.abrupt("return", _context3.t0 + 'profile/keys/privateKey.ttl');
13366
+ case 7:
13367
+ _context3.prev = 7;
13368
+ _context3.t1 = _context3["catch"](0);
13369
+ throw new Error(_context3.t1);
13370
+ case 10:
13371
+ case "end":
13372
+ return _context3.stop();
13373
+ }
13374
+ }, _callee3, null, [[0, 7]]);
13375
+ }));
13376
+ return function privKeyUrl(_x5) {
13377
+ return _ref3.apply(this, arguments);
13378
+ };
13379
+ }();
13380
+ exports.privKeyUrl = privKeyUrl;
13381
+ function getExistingPrivateKey(_x6, _x7) {
13382
+ return _getExistingPrivateKey.apply(this, arguments);
13383
+ }
13384
+ function _getExistingPrivateKey() {
13385
+ _getExistingPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(webId, privateKeyUrl) {
13386
+ return _regenerator["default"].wrap(function _callee5$(_context5) {
13387
+ while (1) switch (_context5.prev = _context5.next) {
13388
+ case 0:
13389
+ _context5.next = 2;
13390
+ return getKeyIfExists(webId, privateKeyUrl, 'PrivateKey');
13391
+ case 2:
13392
+ return _context5.abrupt("return", _context5.sent);
13393
+ case 3:
13394
+ case "end":
13395
+ return _context5.stop();
13396
+ }
13397
+ }, _callee5);
13398
+ }));
13399
+ return _getExistingPrivateKey.apply(this, arguments);
13400
+ }
13401
+ function getKeyIfExists(_x8, _x9, _x10) {
13402
+ return _getKeyIfExists.apply(this, arguments);
13403
+ }
13404
+ function _getKeyIfExists() {
13405
+ _getKeyIfExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(webId, keyUrl, keyType) {
13406
+ var key, _err$response, data, contentType, response;
13407
+ return _regenerator["default"].wrap(function _callee6$(_context6) {
13408
+ while (1) switch (_context6.prev = _context6.next) {
13409
+ case 0:
13410
+ _context6.prev = 0;
13411
+ _context6.next = 3;
13412
+ return _solidLogic.store.fetcher.load(keyUrl);
13413
+ case 3:
13414
+ key = _solidLogic.store.any(webId, _solidLogic.store.sym(_signature.CERT + keyType));
13415
+ return _context6.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
13416
+ case 7:
13417
+ _context6.prev = 7;
13418
+ _context6.t0 = _context6["catch"](0);
13419
+ if (!((_context6.t0 === null || _context6.t0 === void 0 ? void 0 : (_err$response = _context6.t0.response) === null || _err$response === void 0 ? void 0 : _err$response.status) === 404)) {
13420
+ _context6.next = 24;
13421
+ break;
13422
+ }
13423
+ _context6.prev = 10;
13424
+ // create resource
13425
+ data = '';
13426
+ contentType = 'text/turtle';
13427
+ _context6.next = 15;
13428
+ return _solidLogic.store.fetcher.webOperation('PUT', keyUrl, {
13429
+ data: data,
13430
+ contentType: contentType
13431
+ });
13432
+ case 15:
13433
+ response = _context6.sent;
13434
+ _context6.next = 22;
13435
+ break;
13436
+ case 18:
13437
+ _context6.prev = 18;
13438
+ _context6.t1 = _context6["catch"](10);
13439
+ debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context6.t1);
13440
+ throw _context6.t1;
13441
+ case 22:
13442
+ delete _solidLogic.store.fetcher.requested[keyUrl]; // delete cached 404 error
13443
+ return _context6.abrupt("return", undefined);
13444
+ case 24:
13445
+ debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context6.t0);
13446
+ throw _context6.t0;
13447
+ case 26:
13448
+ case "end":
13449
+ return _context6.stop();
13450
+ }
13451
+ }, _callee6, null, [[0, 7], [10, 18]]);
13452
+ }));
13453
+ return _getKeyIfExists.apply(this, arguments);
13454
+ }
13455
+ //# sourceMappingURL=accessData.js.map
13456
+
13457
+ /***/ }),
13458
+
13459
+ /***/ "./lib/utils/keyHelpers/acl.js":
13460
+ /*!*************************************!*\
13461
+ !*** ./lib/utils/keyHelpers/acl.js ***!
13462
+ \*************************************/
13463
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
13464
+
13465
+ "use strict";
13466
+
13467
+
13468
+ var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");
13469
+ var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
13470
+ Object.defineProperty(exports, "__esModule", ({
13471
+ value: true
13472
+ }));
13473
+ exports.keyContainerAclBody = exports.keyAclBody = void 0;
13474
+ exports.setAcl = setAcl;
13475
+ var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
13476
+ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
13477
+ var debug = _interopRequireWildcard(__webpack_require__(/*! ../../debug */ "./lib/debug.js"));
13478
+ var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
13479
+ 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); }
13480
+ 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; }
13481
+ /**
13482
+ * set ACL
13483
+ * @param keyDoc
13484
+ * @param aclBody
13485
+ */
13486
+ function setAcl(_x, _x2) {
13487
+ return _setAcl.apply(this, arguments);
13488
+ }
13489
+ /**
13490
+ * key container ACL
13491
+ * @param me
13492
+ * @returns aclBody
13493
+ */
13494
+ function _setAcl() {
13495
+ _setAcl = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(keyDoc, aclBody) {
13496
+ var keyAclDoc, response, aclResponse;
13497
+ return _regenerator["default"].wrap(function _callee$(_context) {
13498
+ while (1) switch (_context.prev = _context.next) {
13499
+ case 0:
13500
+ _context.next = 2;
13501
+ return _solidLogic.store.fetcher.load(keyDoc);
13502
+ case 2:
13503
+ // FIXME: check the Why value on this quad:
13504
+ debug.log(_solidLogic.store.statementsMatching(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl')));
13505
+ keyAclDoc = _solidLogic.store.any(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl'));
13506
+ if (keyAclDoc) {
13507
+ _context.next = 6;
13508
+ break;
13509
+ }
13510
+ throw new Error('Key ACL doc not found!');
13511
+ case 6:
13512
+ _context.prev = 6;
13513
+ _context.next = 9;
13514
+ return _solidLogic.store.fetcher.webOperation('DELETE', keyAclDoc.value);
13515
+ case 9:
13516
+ response = _context.sent;
13517
+ // this may fail if webId is not an owner
13518
+ debug.log('delete ' + keyAclDoc.value + ' ' + response.status); // should test 404 and 2xx
13519
+ _context.next = 18;
13520
+ break;
13521
+ case 13:
13522
+ _context.prev = 13;
13523
+ _context.t0 = _context["catch"](6);
13524
+ if (!(_context.t0.response.status !== 404)) {
13525
+ _context.next = 17;
13526
+ break;
13527
+ }
13528
+ throw new Error(_context.t0);
13529
+ case 17:
13530
+ debug.log('delete ' + keyAclDoc.value + ' ' + _context.t0.response.status); // should test 404 and 2xx
13531
+ case 18:
13532
+ _context.next = 20;
13533
+ return _solidLogic.store.fetcher.webOperation('PUT', keyAclDoc.value, {
13534
+ data: aclBody,
13535
+ contentType: 'text/turtle'
13536
+ });
13537
+ case 20:
13538
+ aclResponse = _context.sent;
13539
+ case 21:
13540
+ case "end":
13541
+ return _context.stop();
13542
+ }
13543
+ }, _callee, null, [[6, 13]]);
13544
+ }));
13545
+ return _setAcl.apply(this, arguments);
13546
+ }
13547
+ var keyContainerAclBody = function keyContainerAclBody(me) {
13548
+ 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");
13549
+ return aclBody;
13550
+ };
13551
+
13552
+ /**
13553
+ * Read only ACL
13554
+ * @param keyDoc
13555
+ * @param me
13556
+ * @returns aclBody
13557
+ */
13558
+ exports.keyContainerAclBody = keyContainerAclBody;
13559
+ var keyAclBody = function keyAclBody(keyDoc, me) {
13560
+ var keyAgent = 'acl:agentClass foaf:Agent'; // publicKey
13561
+ if (me !== null && me !== void 0 && me.length) keyAgent = "acl:agent <".concat(me, ">"); // privateKey
13562
+ 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");
13563
+ return aclBody;
13564
+ };
13565
+ exports.keyAclBody = keyAclBody;
13566
+ //# sourceMappingURL=acl.js.map
13567
+
13568
+ /***/ }),
13569
+
13419
13570
  /***/ "./lib/utils/label.js":
13420
13571
  /*!****************************!*\
13421
13572
  !*** ./lib/utils/label.js ***!
@@ -13544,8 +13695,8 @@ Object.defineProperty(exports, "__esModule", ({
13544
13695
  }));
13545
13696
  exports.versionInfo = void 0;
13546
13697
  var versionInfo = {
13547
- buildTime: '2023-04-30T22:04:08Z',
13548
- commit: '7184a38ab5fc3b8a1be713169d0ef99666aad8a7',
13698
+ buildTime: '2023-05-10T18:38:16Z',
13699
+ commit: '77f914e3e4b885876fd4618e7374fd020da07cd1',
13549
13700
  npmInfo: {
13550
13701
  'solid-ui': '2.4.27',
13551
13702
  npm: '8.19.4',
@@ -66361,22 +66512,7 @@ module.exports = JSON.parse('{"application/1d-interleaved-parityfec":{"source":"
66361
66512
  /******/
66362
66513
  /******/ /* webpack/runtime/publicPath */
66363
66514
  /******/ (() => {
66364
- /******/ var scriptUrl;
66365
- /******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
66366
- /******/ var document = __webpack_require__.g.document;
66367
- /******/ if (!scriptUrl && document) {
66368
- /******/ if (document.currentScript)
66369
- /******/ scriptUrl = document.currentScript.src;
66370
- /******/ if (!scriptUrl) {
66371
- /******/ var scripts = document.getElementsByTagName("script");
66372
- /******/ if(scripts.length) scriptUrl = scripts[scripts.length - 1].src
66373
- /******/ }
66374
- /******/ }
66375
- /******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
66376
- /******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
66377
- /******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
66378
- /******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
66379
- /******/ __webpack_require__.p = scriptUrl;
66515
+ /******/ __webpack_require__.p = "";
66380
66516
  /******/ })();
66381
66517
  /******/
66382
66518
  /******/ /* webpack/runtime/jsonp chunk loading */