solid-ui 2.4.27-fd0d1bf4 → 2.4.27-fd5a7172

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() {
@@ -4052,263 +4053,205 @@ function generatePrivateKey() {
4052
4053
  function generatePublicKey(privateKey) {
4053
4054
  return (0, _utils.bytesToHex)(_secp256k.schnorr.getPublicKey(privateKey));
4054
4055
  }
4056
+
4057
+ /**
4058
+ * getPublicKey
4059
+ * used for displaying messages in chat, therefore does not
4060
+ * create a new key if not found
4061
+ * @param webId
4062
+ * @returns string | undefined
4063
+ */
4055
4064
  function getPublicKey(_x) {
4056
4065
  return _getPublicKey.apply(this, arguments);
4057
4066
  }
4058
4067
  function _getPublicKey() {
4059
- _getPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
4068
+ _getPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
4060
4069
  var publicKeyDoc, key;
4061
- return _regenerator["default"].wrap(function _callee$(_context) {
4062
- while (1) switch (_context.prev = _context.next) {
4070
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
4071
+ while (1) switch (_context2.prev = _context2.next) {
4063
4072
  case 0:
4064
- _context.next = 2;
4073
+ _context2.next = 2;
4065
4074
  return _solidLogic.store.fetcher.load(webId);
4066
4075
  case 2:
4067
- publicKeyDoc = (0, _cryptoKeyHelpers.pubKeyUrl)(webId);
4068
- _context.prev = 3;
4069
- _context.next = 6;
4076
+ _context2.next = 4;
4077
+ return (0, _accessData.pubKeyUrl)(webId);
4078
+ case 4:
4079
+ publicKeyDoc = _context2.sent;
4080
+ _context2.prev = 5;
4081
+ _context2.next = 8;
4070
4082
  return _solidLogic.store.fetcher.load(publicKeyDoc);
4071
- case 6:
4083
+ case 8:
4072
4084
  // url.href)
4073
- key = _solidLogic.store.any(_solidLogic.store.sym(webId), _solidLogic.store.sym(_signature.CERT + 'PublicKey'));
4074
- return _context.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
4075
- case 10:
4076
- _context.prev = 10;
4077
- _context.t0 = _context["catch"](3);
4078
- return _context.abrupt("return", undefined);
4079
- case 13:
4085
+ key = _solidLogic.store.any(webId, _solidLogic.store.sym(_signature.CERT + 'PublicKey'));
4086
+ return _context2.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
4087
+ case 12:
4088
+ _context2.prev = 12;
4089
+ _context2.t0 = _context2["catch"](5);
4090
+ return _context2.abrupt("return", undefined);
4091
+ case 15:
4080
4092
  case "end":
4081
- return _context.stop();
4093
+ return _context2.stop();
4082
4094
  }
4083
- }, _callee, null, [[3, 10]]);
4095
+ }, _callee2, null, [[5, 12]]);
4084
4096
  }));
4085
4097
  return _getPublicKey.apply(this, arguments);
4086
4098
  }
4087
4099
  function getPrivateKey(_x2) {
4088
4100
  return _getPrivateKey.apply(this, arguments);
4089
4101
  }
4090
- /**
4091
- * key container ACL
4092
- * @param me
4093
- * @returns aclBody
4094
- */
4095
4102
  function _getPrivateKey() {
4096
- _getPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
4103
+ _getPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId) {
4097
4104
  var publicKeyDoc, privateKeyDoc, publicKey, privateKey, validPublicKey, del, add, newPublicKey, keyContainer;
4098
- return _regenerator["default"].wrap(function _callee2$(_context2) {
4099
- while (1) switch (_context2.prev = _context2.next) {
4105
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
4106
+ while (1) switch (_context3.prev = _context3.next) {
4100
4107
  case 0:
4101
- _context2.next = 2;
4108
+ _context3.next = 2;
4102
4109
  return _solidLogic.store.fetcher.load(webId);
4103
4110
  case 2:
4104
- // find keys url's
4105
- publicKeyDoc = (0, _cryptoKeyHelpers.pubKeyUrl)(webId);
4106
- privateKeyDoc = (0, _cryptoKeyHelpers.privKeyUrl)(webId); // find key pair
4107
- _context2.next = 6;
4108
- return (0, _cryptoKeyHelpers.publicKeyExists)(webId);
4109
- case 6:
4110
- publicKey = _context2.sent;
4111
- _context2.next = 9;
4112
- return (0, _cryptoKeyHelpers.privateKeyExists)(webId);
4113
- case 9:
4114
- privateKey = _context2.sent;
4111
+ _context3.next = 4;
4112
+ return (0, _accessData.pubKeyUrl)(webId);
4113
+ case 4:
4114
+ publicKeyDoc = _context3.sent;
4115
+ _context3.next = 7;
4116
+ return (0, _accessData.privKeyUrl)(webId);
4117
+ case 7:
4118
+ privateKeyDoc = _context3.sent;
4119
+ _context3.next = 10;
4120
+ return (0, _accessData.getExistingPublicKey)(webId, publicKeyDoc);
4121
+ case 10:
4122
+ publicKey = _context3.sent;
4123
+ _context3.next = 13;
4124
+ return (0, _accessData.getExistingPrivateKey)(webId, privateKeyDoc);
4125
+ case 13:
4126
+ privateKey = _context3.sent;
4115
4127
  // is publicKey valid ?
4116
4128
  validPublicKey = true;
4117
4129
  if (privateKey && publicKey !== generatePublicKey(privateKey)) {
4118
- if (confirm('This is strange the publicKey is not valid for\n' + webId + '\'shall we repair keeping the private key ?')) validPublicKey = false;
4130
+ 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;
4119
4131
  }
4120
4132
 
4121
4133
  // create key pair or repair publicKey
4122
4134
  if (!(!privateKey || !publicKey || !validPublicKey)) {
4123
- _context2.next = 30;
4135
+ _context3.next = 34;
4124
4136
  break;
4125
4137
  }
4126
4138
  del = [];
4127
- add = []; // if (privateKey) del.push($rdf.st($rdf.sym(webId), $rdf.sym(CERT + 'PrivateKey'), $rdf.lit(privateKey), $rdf.sym(privateKeyDoc)))
4139
+ add = []; // if (privateKey) del.push($rdf.st(webId, store.sym(CERT + 'PrivateKey'), $rdf.lit(privateKey), store.sym(privateKeyDoc)))
4128
4140
  if (privateKey) {
4129
- _context2.next = 20;
4141
+ _context3.next = 24;
4130
4142
  break;
4131
4143
  }
4132
4144
  // add = []
4133
4145
  privateKey = generatePrivateKey();
4134
- add = [$rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'PrivateKey'), $rdf.literal(privateKey), $rdf.sym(privateKeyDoc))];
4135
- _context2.next = 20;
4136
- return saveKey(privateKeyDoc, [], add, webId);
4137
- case 20:
4146
+ add = [$rdf.st(webId, _solidLogic.store.sym(_signature.CERT + 'PrivateKey'), $rdf.literal(privateKey), _solidLogic.store.sym(privateKeyDoc))];
4147
+ _context3.next = 24;
4148
+ return saveKey(privateKeyDoc, [], add, webId.uri);
4149
+ case 24:
4138
4150
  if (!(!publicKey || !validPublicKey)) {
4139
- _context2.next = 27;
4151
+ _context3.next = 31;
4140
4152
  break;
4141
4153
  }
4142
4154
  del = [];
4143
4155
  // delete invalid public key
4144
4156
  if (publicKey) {
4145
- del = [$rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'PublicKey'), $rdf.lit(publicKey), $rdf.sym(publicKeyDoc))];
4157
+ del = [$rdf.st(webId, _solidLogic.store.sym(_signature.CERT + 'PublicKey'), $rdf.lit(publicKey), _solidLogic.store.sym(publicKeyDoc))];
4146
4158
  debug.log(del);
4147
4159
  }
4148
4160
  // update new valid key
4149
4161
  newPublicKey = generatePublicKey(privateKey);
4150
- add = [$rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'PublicKey'), $rdf.literal(newPublicKey), $rdf.sym(publicKeyDoc))];
4151
- _context2.next = 27;
4162
+ add = [$rdf.st(webId, _solidLogic.store.sym(_signature.CERT + 'PublicKey'), $rdf.literal(newPublicKey), _solidLogic.store.sym(publicKeyDoc))];
4163
+ _context3.next = 31;
4152
4164
  return saveKey(publicKeyDoc, del, add);
4153
- case 27:
4154
- keyContainer = privateKeyDoc.substring(0, privateKeyDoc.lastIndexOf('/') + 1);
4155
- _context2.next = 30;
4156
- return setAcl(keyContainer, keyContainerAclBody(webId));
4157
- case 30:
4158
- return _context2.abrupt("return", privateKey);
4159
4165
  case 31:
4166
+ keyContainer = privateKeyDoc.substring(0, privateKeyDoc.lastIndexOf('/') + 1);
4167
+ _context3.next = 34;
4168
+ return (0, _acl.setAcl)(keyContainer, (0, _acl.keyContainerAclBody)(webId.uri));
4169
+ case 34:
4170
+ return _context3.abrupt("return", privateKey);
4171
+ case 35:
4160
4172
  case "end":
4161
- return _context2.stop();
4173
+ return _context3.stop();
4162
4174
  }
4163
- }, _callee2);
4175
+ }, _callee3);
4164
4176
  }));
4165
4177
  return _getPrivateKey.apply(this, arguments);
4166
4178
  }
4167
- var keyContainerAclBody = function keyContainerAclBody(me) {
4168
- 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");
4169
- return aclBody;
4170
- };
4171
-
4172
- /**
4173
- * Read only ACL
4174
- * @param keyDoc
4175
- * @param me
4176
- * @returns aclBody
4177
- */
4178
- var keyAclBody = function keyAclBody(keyDoc, me) {
4179
- var keyAgent = 'acl:agentClass foaf:Agent'; // publicKey
4180
- if (me !== null && me !== void 0 && me.length) keyAgent = "acl:agent <".concat(me, ">"); // privateKey
4181
- 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");
4182
- return aclBody;
4183
- };
4184
-
4185
- /**
4186
- * set ACL
4187
- * @param keyDoc
4188
- * @param aclBody
4189
- */
4190
- function setAcl(_x3, _x4) {
4191
- return _setAcl.apply(this, arguments);
4192
- }
4193
- /**
4194
- * delete acl if keydoc exists
4195
- * create/edit keyDoc
4196
- * set keyDoc acl
4197
- */
4198
- function _setAcl() {
4199
- _setAcl = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(keyDoc, aclBody) {
4200
- var keyAclDoc, response, aclResponse;
4201
- return _regenerator["default"].wrap(function _callee3$(_context3) {
4202
- while (1) switch (_context3.prev = _context3.next) {
4179
+ var deleteKey = /*#__PURE__*/function () {
4180
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(keyDoc) {
4181
+ var keyAclDoc, response;
4182
+ return _regenerator["default"].wrap(function _callee$(_context) {
4183
+ while (1) switch (_context.prev = _context.next) {
4203
4184
  case 0:
4204
- _context3.next = 2;
4185
+ _context.next = 2;
4205
4186
  return _solidLogic.store.fetcher.load(keyDoc);
4206
4187
  case 2:
4207
- // FIXME: check the Why value on this quad:
4208
- debug.log(_solidLogic.store.statementsMatching($rdf.sym(keyDoc), $rdf.sym('http://www.iana.org/assignments/link-relations/acl')));
4209
- keyAclDoc = _solidLogic.store.any($rdf.sym(keyDoc), $rdf.sym('http://www.iana.org/assignments/link-relations/acl'));
4210
- if (keyAclDoc) {
4211
- _context3.next = 6;
4188
+ keyAclDoc = _solidLogic.store.any(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl'));
4189
+ if (!keyAclDoc) {
4190
+ _context.next = 16;
4212
4191
  break;
4213
4192
  }
4214
- throw new Error('Key ACL doc not found!');
4215
- case 6:
4216
- _context3.prev = 6;
4217
- _context3.next = 9;
4193
+ _context.prev = 4;
4194
+ _context.next = 7;
4218
4195
  return _solidLogic.store.fetcher.webOperation('DELETE', keyAclDoc.value);
4219
- case 9:
4220
- response = _context3.sent;
4196
+ case 7:
4197
+ response = _context.sent;
4221
4198
  // this may fail if webId is not an owner
4222
4199
  debug.log('delete ' + keyAclDoc.value + ' ' + response.status); // should test 404 and 2xx
4223
- _context3.next = 18;
4200
+ _context.next = 16;
4224
4201
  break;
4225
- case 13:
4226
- _context3.prev = 13;
4227
- _context3.t0 = _context3["catch"](6);
4228
- if (!(_context3.t0.response.status !== 404)) {
4229
- _context3.next = 17;
4202
+ case 11:
4203
+ _context.prev = 11;
4204
+ _context.t0 = _context["catch"](4);
4205
+ if (!(_context.t0.response.status !== 404)) {
4206
+ _context.next = 15;
4230
4207
  break;
4231
4208
  }
4232
- throw new Error(_context3.t0);
4233
- case 17:
4234
- debug.log('delete ' + keyAclDoc.value + ' ' + _context3.t0.response.status); // should test 404 and 2xx
4235
- case 18:
4236
- _context3.next = 20;
4237
- return _solidLogic.store.fetcher.webOperation('PUT', keyAclDoc.value, {
4238
- data: aclBody,
4239
- contentType: 'text/turtle'
4240
- });
4241
- case 20:
4242
- aclResponse = _context3.sent;
4243
- case 21:
4209
+ throw new Error(_context.t0);
4210
+ case 15:
4211
+ debug.log('delete ' + keyAclDoc.value + ' ' + _context.t0.response.status); // should test 404 and 2xx
4212
+ case 16:
4244
4213
  case "end":
4245
- return _context3.stop();
4214
+ return _context.stop();
4246
4215
  }
4247
- }, _callee3, null, [[6, 13]]);
4216
+ }, _callee, null, [[4, 11]]);
4248
4217
  }));
4249
- return _setAcl.apply(this, arguments);
4250
- }
4251
- function saveKey(_x5, _x6, _x7) {
4218
+ return function deleteKey(_x3) {
4219
+ return _ref.apply(this, arguments);
4220
+ };
4221
+ }();
4222
+
4223
+ /**
4224
+ * delete acl if keydoc exists
4225
+ * create/edit keyDoc
4226
+ * set keyDoc acl
4227
+ */
4228
+ function saveKey(_x4, _x5, _x6) {
4252
4229
  return _saveKey.apply(this, arguments);
4253
4230
  }
4254
4231
  function _saveKey() {
4255
4232
  _saveKey = (0, _asyncToGenerator2["default"])(function (keyDoc, del, add) {
4256
4233
  var me = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
4257
4234
  return /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
4258
- var keyAclDoc, response, aclBody;
4235
+ var aclBody;
4259
4236
  return _regenerator["default"].wrap(function _callee4$(_context4) {
4260
4237
  while (1) switch (_context4.prev = _context4.next) {
4261
4238
  case 0:
4262
4239
  _context4.next = 2;
4263
- return _solidLogic.store.fetcher.load(keyDoc);
4240
+ return deleteKey(keyDoc);
4264
4241
  case 2:
4265
- _context4.prev = 2;
4266
- // get keyAcldoc
4267
- keyAclDoc = _solidLogic.store.any($rdf.sym(keyDoc), $rdf.sym('http://www.iana.org/assignments/link-relations/acl'));
4268
- if (!keyAclDoc) {
4269
- _context4.next = 17;
4270
- break;
4271
- }
4272
- _context4.prev = 5;
4273
- _context4.next = 8;
4274
- return _solidLogic.store.fetcher.webOperation('DELETE', keyAclDoc.value);
4275
- case 8:
4276
- response = _context4.sent;
4277
- // this may fail if webId is not an owner
4278
- debug.log('delete ' + keyAclDoc.value + ' ' + response.status); // should test 404 and 2xx
4279
- _context4.next = 17;
4280
- break;
4281
- case 12:
4282
- _context4.prev = 12;
4283
- _context4.t0 = _context4["catch"](5);
4284
- if (!(_context4.t0.response.status !== 404)) {
4285
- _context4.next = 16;
4286
- break;
4287
- }
4288
- throw new Error(_context4.t0);
4289
- case 16:
4290
- debug.log('delete ' + keyAclDoc.value + ' ' + _context4.t0.response.status); // should test 404 and 2xx
4291
- case 17:
4292
- _context4.next = 19;
4242
+ _context4.next = 4;
4293
4243
  return _solidLogic.store.updater.updateMany(del, add);
4294
- case 19:
4244
+ case 4:
4295
4245
  // or a promise store.updater.update ?
4296
4246
  // create READ only ACL
4297
- aclBody = keyAclBody(keyDoc, me);
4298
- _context4.next = 22;
4299
- return setAcl(keyDoc, aclBody);
4300
- case 22:
4301
- _context4.next = 27;
4302
- break;
4303
- case 24:
4304
- _context4.prev = 24;
4305
- _context4.t1 = _context4["catch"](2);
4306
- throw new Error(_context4.t1);
4307
- case 27:
4247
+ aclBody = (0, _acl.keyAclBody)(keyDoc, me);
4248
+ _context4.next = 7;
4249
+ return (0, _acl.setAcl)(keyDoc, aclBody);
4250
+ case 7:
4308
4251
  case "end":
4309
4252
  return _context4.stop();
4310
4253
  }
4311
- }, _callee4, null, [[2, 24], [5, 12]]);
4254
+ }, _callee4);
4312
4255
  })();
4313
4256
  });
4314
4257
  return _saveKey.apply(this, arguments);
@@ -4460,11 +4403,11 @@ function renderMessageRow(channelObject, message, fresh, options, userContext) {
4460
4403
 
4461
4404
  // signed message, get public key and check signature
4462
4405
  else {
4463
- (0, _keys.getPublicKey)(creator.uri).then(function (publicKey) {
4406
+ (0, _keys.getPublicKey)(creator).then(function (publicKey) {
4464
4407
  debug.log(creator.uri + '\n' + msg.created + '\n' + msg.id + '\n' + publicKey);
4465
4408
  if (!publicKey) {
4466
4409
  // TODO try to recreate the publicKey
4467
- // if(me.uri === creator.uri) await getPrivateKey(creator.uri)
4410
+ // if(me.uri === creator.uri) await getPrivateKey(creator)
4468
4411
  debug.warn('message is signed but ' + creator.uri + ' is missing publicKey');
4469
4412
  }
4470
4413
  // check that publicKey is a valid hex string
@@ -5267,13 +5210,11 @@ Object.defineProperty(exports, "__esModule", ({
5267
5210
  value: true
5268
5211
  }));
5269
5212
  exports.SEC = exports.CERT = void 0;
5270
- exports.finishMsg = finishMsg;
5271
5213
  exports.getBlankMsg = getBlankMsg;
5272
5214
  exports.getMsgHash = getMsgHash;
5273
5215
  exports.serializeMsg = serializeMsg;
5274
5216
  exports.signMsg = signMsg;
5275
5217
  exports.utf8Encoder = exports.utf8Decoder = void 0;
5276
- exports.validateMsg = validateMsg;
5277
5218
  exports.verifySignature = verifySignature;
5278
5219
  var _secp256k = __webpack_require__(/*! @noble/curves/secp256k1 */ "./node_modules/@noble/curves/secp256k1.js");
5279
5220
  var _utils = __webpack_require__(/*! @noble/hashes/utils */ "./node_modules/@noble/hashes/utils.js");
@@ -5319,19 +5260,22 @@ function getBlankMsg() {
5319
5260
  id: '',
5320
5261
  created: '',
5321
5262
  dateDeleted: '',
5263
+ // TODO to remove if not used
5322
5264
  content: '',
5323
5265
  maker: '',
5324
- sig: ''
5266
+ sig: '' // TODO to remove if not used
5325
5267
  };
5326
5268
  }
5327
- function finishMsg(t, privateKey) {
5328
- // to update to chat message triples
5329
- var message = t;
5330
- // message.pubkey = getPublicKey(privateKey)
5331
- message.id = getMsgHash(message);
5332
- message.sig = signMsg(message, privateKey);
5333
- return message;
5334
- }
5269
+
5270
+ /* export function finishMsg (t: MsgTemplate, privateKey: string): Message {
5271
+ // to update to chat message triples
5272
+ const message = t as Message
5273
+ // message.pubkey = getPublicKey(privateKey)
5274
+ message.id = getMsgHash(message)
5275
+ message.sig = signMsg(message, privateKey)
5276
+ return message
5277
+ } */
5278
+
5335
5279
  function serializeMsg(msg) {
5336
5280
  // to update to chat messages triples
5337
5281
  /* if (!validateMsg(msg))
@@ -5343,27 +5287,29 @@ function getMsgHash(message) {
5343
5287
  var msgHash = (0, _sha.sha256)(utf8Encoder.encode(serializeMsg(message)));
5344
5288
  return (0, _utils.bytesToHex)(msgHash);
5345
5289
  }
5346
- var isRecord = function isRecord(obj) {
5347
- return obj instanceof Object;
5348
- };
5349
- function validateMsg(message) {
5350
- /* if (!isRecord(message)) return false
5290
+
5291
+ // const isRecord = (obj: unknown): obj is Record<string, unknown> => obj instanceof Object
5292
+
5293
+ /* export function validateMsg<T> (message: T): message is T & UnsignedMsg {
5294
+ if (!isRecord(message)) return false
5351
5295
  if (typeof message.kind !== 'number') return false
5352
5296
  if (typeof message.content !== 'string') return false
5353
5297
  if (typeof message.created_at !== 'number') return false
5354
5298
  if (typeof message.pubkey !== 'string') return false
5355
5299
  if (!message.pubkey.match(/^[a-f0-9]{64}$/)) return false
5356
- if (!Array.isArray(message.tags)) return false
5300
+
5301
+ if (!Array.isArray(message.tags)) return false
5357
5302
  for (let i = 0; i < message.tags.length; i++) {
5358
5303
  let tag = message.tags[i]
5359
5304
  if (!Array.isArray(tag)) return false
5360
5305
  for (let j = 0; j < tag.length; j++) {
5361
5306
  if (typeof tag[j] === 'object') return false
5362
5307
  }
5363
- } */
5308
+ }
5309
+
5310
+ return true
5311
+ } */
5364
5312
 
5365
- return true;
5366
- }
5367
5313
  function verifySignature(sig, message, pubKey) {
5368
5314
  return _secp256k.schnorr.verify(sig, getMsgHash(message), pubKey);
5369
5315
  }
@@ -12574,173 +12520,6 @@ function isLight(x) {
12574
12520
 
12575
12521
  /***/ }),
12576
12522
 
12577
- /***/ "./lib/utils/cryptoKeyHelpers.js":
12578
- /*!***************************************!*\
12579
- !*** ./lib/utils/cryptoKeyHelpers.js ***!
12580
- \***************************************/
12581
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
12582
-
12583
- "use strict";
12584
-
12585
-
12586
- var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");
12587
- var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
12588
- Object.defineProperty(exports, "__esModule", ({
12589
- value: true
12590
- }));
12591
- exports.privKeyUrl = void 0;
12592
- exports.privateKeyExists = privateKeyExists;
12593
- exports.pubKeyUrl = void 0;
12594
- exports.publicKeyExists = publicKeyExists;
12595
- var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
12596
- var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
12597
- var debug = _interopRequireWildcard(__webpack_require__(/*! ../debug */ "./lib/debug.js"));
12598
- var _signature = __webpack_require__(/*! ../chat/signature */ "./lib/chat/signature.js");
12599
- var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
12600
- 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); }
12601
- 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; }
12602
- // find podRoot from space:storage for subdomain/suffix podServers
12603
- /* export const podRoot = (webId: string) => {
12604
- await store.fetcher.load(webId)
12605
- const url = new URL(webId)
12606
- // find storage in webId
12607
- const storage = store.each(store.sym(webId), store.sym('http://www.w3.org/ns/pim/space#storage'))
12608
- const pod = storage.length === 1 ? storage : storage.find(node => url.origin === new URL(node.value).origin)
12609
- const podRoot = Array.isArray(pod) ? pod[0] : pod
12610
- if (!podRoot?.value) throw Error('No space:storage in ' + webId)
12611
- return podRoot.value
12612
- } */
12613
-
12614
- var pubKeyUrl = function pubKeyUrl(webId) {
12615
- var url = new URL(webId);
12616
- // find storage in webId
12617
- var storage = _solidLogic.store.each(_solidLogic.store.sym(webId), _solidLogic.store.sym('http://www.w3.org/ns/pim/space#storage'));
12618
- var pod = storage.length === 1 ? storage : storage.find(function (node) {
12619
- return url.origin === new URL(node.value).origin;
12620
- });
12621
- var podUrl = Array.isArray(pod) ? pod[0] : pod;
12622
- if (!(podUrl !== null && podUrl !== void 0 && podUrl.value)) throw Error('No space:storage in ' + webId);
12623
- var publicKeyUrl = (podUrl === null || podUrl === void 0 ? void 0 : podUrl.value) + 'profile/keys/publicKey.ttl';
12624
- return publicKeyUrl;
12625
- };
12626
- exports.pubKeyUrl = pubKeyUrl;
12627
- function publicKeyExists(_x) {
12628
- return _publicKeyExists.apply(this, arguments);
12629
- }
12630
- function _publicKeyExists() {
12631
- _publicKeyExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
12632
- var publicKeyUrl;
12633
- return _regenerator["default"].wrap(function _callee$(_context) {
12634
- while (1) switch (_context.prev = _context.next) {
12635
- case 0:
12636
- // find publickey
12637
- publicKeyUrl = pubKeyUrl(webId);
12638
- _context.next = 3;
12639
- return keyExists(webId, publicKeyUrl, 'PublicKey');
12640
- case 3:
12641
- return _context.abrupt("return", _context.sent);
12642
- case 4:
12643
- case "end":
12644
- return _context.stop();
12645
- }
12646
- }, _callee);
12647
- }));
12648
- return _publicKeyExists.apply(this, arguments);
12649
- }
12650
- var privKeyUrl = function privKeyUrl(webId) {
12651
- var url = new URL(webId);
12652
- // find storage in webId
12653
- var storage = _solidLogic.store.each(_solidLogic.store.sym(webId), _solidLogic.store.sym('http://www.w3.org/ns/pim/space#storage'));
12654
- var pod = storage.length === 1 ? storage : storage.find(function (node) {
12655
- return url.origin === new URL(node.value).origin;
12656
- });
12657
- var podUrl = Array.isArray(pod) ? pod[0] : pod;
12658
- if (!(podUrl !== null && podUrl !== void 0 && podUrl.value)) throw Error('Expected space:storage in ' + webId);
12659
- var privateKeyUrl = (podUrl === null || podUrl === void 0 ? void 0 : podUrl.value) + 'profile/keys/privateKey.ttl';
12660
- return privateKeyUrl;
12661
- };
12662
- exports.privKeyUrl = privKeyUrl;
12663
- function privateKeyExists(_x2) {
12664
- return _privateKeyExists.apply(this, arguments);
12665
- }
12666
- function _privateKeyExists() {
12667
- _privateKeyExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
12668
- var privateKeyUrl;
12669
- return _regenerator["default"].wrap(function _callee2$(_context2) {
12670
- while (1) switch (_context2.prev = _context2.next) {
12671
- case 0:
12672
- // find privateKey
12673
- privateKeyUrl = privKeyUrl(webId);
12674
- _context2.next = 3;
12675
- return keyExists(webId, privateKeyUrl, 'PrivateKey');
12676
- case 3:
12677
- return _context2.abrupt("return", _context2.sent);
12678
- case 4:
12679
- case "end":
12680
- return _context2.stop();
12681
- }
12682
- }, _callee2);
12683
- }));
12684
- return _privateKeyExists.apply(this, arguments);
12685
- }
12686
- function keyExists(_x3, _x4, _x5) {
12687
- return _keyExists.apply(this, arguments);
12688
- }
12689
- function _keyExists() {
12690
- _keyExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId, keyUrl, keyType) {
12691
- var key, _err$response, data, contentType, response;
12692
- return _regenerator["default"].wrap(function _callee3$(_context3) {
12693
- while (1) switch (_context3.prev = _context3.next) {
12694
- case 0:
12695
- _context3.prev = 0;
12696
- _context3.next = 3;
12697
- return _solidLogic.store.fetcher.load(keyUrl);
12698
- case 3:
12699
- key = _solidLogic.store.any(_solidLogic.store.sym(webId), _solidLogic.store.sym(_signature.CERT + keyType));
12700
- return _context3.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
12701
- case 7:
12702
- _context3.prev = 7;
12703
- _context3.t0 = _context3["catch"](0);
12704
- 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)) {
12705
- _context3.next = 24;
12706
- break;
12707
- }
12708
- _context3.prev = 10;
12709
- // create privateKey resource
12710
- data = '';
12711
- contentType = 'text/turtle';
12712
- _context3.next = 15;
12713
- return _solidLogic.store.fetcher.webOperation('PUT', keyUrl, {
12714
- data: data,
12715
- contentType: contentType
12716
- });
12717
- case 15:
12718
- response = _context3.sent;
12719
- _context3.next = 22;
12720
- break;
12721
- case 18:
12722
- _context3.prev = 18;
12723
- _context3.t1 = _context3["catch"](10);
12724
- debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context3.t1);
12725
- throw _context3.t1;
12726
- case 22:
12727
- delete _solidLogic.store.fetcher.requested[keyUrl]; // delete cached 404 error
12728
- return _context3.abrupt("return", undefined);
12729
- case 24:
12730
- debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context3.t0);
12731
- throw _context3.t0;
12732
- case 26:
12733
- case "end":
12734
- return _context3.stop();
12735
- }
12736
- }, _callee3, null, [[0, 7], [10, 18]]);
12737
- }));
12738
- return _keyExists.apply(this, arguments);
12739
- }
12740
- //# sourceMappingURL=cryptoKeyHelpers.js.map
12741
-
12742
- /***/ }),
12743
-
12744
12523
  /***/ "./lib/utils/headerFooterHelpers.js":
12745
12524
  /*!******************************************!*\
12746
12525
  !*** ./lib/utils/headerFooterHelpers.js ***!
@@ -13459,6 +13238,345 @@ function predParentOf(node) {
13459
13238
 
13460
13239
  /***/ }),
13461
13240
 
13241
+ /***/ "./lib/utils/keyHelpers/accessData.js":
13242
+ /*!********************************************!*\
13243
+ !*** ./lib/utils/keyHelpers/accessData.js ***!
13244
+ \********************************************/
13245
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
13246
+
13247
+ "use strict";
13248
+
13249
+
13250
+ var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");
13251
+ var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
13252
+ Object.defineProperty(exports, "__esModule", ({
13253
+ value: true
13254
+ }));
13255
+ exports.getExistingPrivateKey = getExistingPrivateKey;
13256
+ exports.getExistingPublicKey = getExistingPublicKey;
13257
+ exports.getKeyIfExists = getKeyIfExists;
13258
+ exports.pubKeyUrl = exports.privKeyUrl = exports.getPodRoot = void 0;
13259
+ var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
13260
+ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
13261
+ var debug = _interopRequireWildcard(__webpack_require__(/*! ../../debug */ "./lib/debug.js"));
13262
+ var _signature = __webpack_require__(/*! ../../chat/signature */ "./lib/chat/signature.js");
13263
+ var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
13264
+ var ns = _interopRequireWildcard(__webpack_require__(/*! ../../ns */ "./lib/ns.js"));
13265
+ 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); }
13266
+ 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; }
13267
+ var getPodRoot = /*#__PURE__*/function () {
13268
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
13269
+ var _podRoot;
13270
+ var webIdURL, storages, podRoot, path, _res$headers$get, res;
13271
+ return _regenerator["default"].wrap(function _callee$(_context) {
13272
+ while (1) switch (_context.prev = _context.next) {
13273
+ case 0:
13274
+ webIdURL = new URL(webId.uri); // find storages in webId document
13275
+ _context.next = 3;
13276
+ return _solidLogic.store.fetcher.load(webId.uri);
13277
+ case 3:
13278
+ storages = _solidLogic.store.each(webId, ns.space('storage'), null, webId.doc());
13279
+ if (storages !== null && storages !== void 0 && storages.length) {
13280
+ _context.next = 19;
13281
+ break;
13282
+ }
13283
+ // find storage recursively in webId URL
13284
+ path = webIdURL.pathname;
13285
+ case 6:
13286
+ if (!path.length) {
13287
+ _context.next = 17;
13288
+ break;
13289
+ }
13290
+ path = path.substring(0, path.lastIndexOf('/'));
13291
+ podRoot = _solidLogic.store.sym(webIdURL.origin + path + '/');
13292
+ _context.next = 11;
13293
+ return _solidLogic.store.fetcher.webOperation('HEAD', podRoot.uri);
13294
+ case 11:
13295
+ res = _context.sent;
13296
+ if (!((_res$headers$get = res.headers.get('link')) !== null && _res$headers$get !== void 0 && _res$headers$get.includes(ns.space('Storage').value))) {
13297
+ _context.next = 14;
13298
+ break;
13299
+ }
13300
+ return _context.abrupt("break", 17);
13301
+ case 14:
13302
+ if (!path) debug.warn("Current user storage not found for\n".concat(webId));
13303
+ _context.next = 6;
13304
+ break;
13305
+ case 17:
13306
+ _context.next = 21;
13307
+ break;
13308
+ case 19:
13309
+ // give preference to storage in webId root
13310
+ podRoot = storages.find(function (storage) {
13311
+ return webIdURL.origin === new URL(storage.value).origin;
13312
+ });
13313
+ if (!podRoot) podRoot = storages[0];
13314
+ case 21:
13315
+ return _context.abrupt("return", (_podRoot = podRoot) === null || _podRoot === void 0 ? void 0 : _podRoot.value);
13316
+ case 22:
13317
+ case "end":
13318
+ return _context.stop();
13319
+ }
13320
+ }, _callee);
13321
+ }));
13322
+ return function getPodRoot(_x) {
13323
+ return _ref.apply(this, arguments);
13324
+ };
13325
+ }();
13326
+ exports.getPodRoot = getPodRoot;
13327
+ var pubKeyUrl = /*#__PURE__*/function () {
13328
+ var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
13329
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
13330
+ while (1) switch (_context2.prev = _context2.next) {
13331
+ case 0:
13332
+ _context2.prev = 0;
13333
+ _context2.next = 3;
13334
+ return getPodRoot(webId);
13335
+ case 3:
13336
+ _context2.t0 = _context2.sent;
13337
+ return _context2.abrupt("return", _context2.t0 + 'profile/keys/publicKey.ttl');
13338
+ case 7:
13339
+ _context2.prev = 7;
13340
+ _context2.t1 = _context2["catch"](0);
13341
+ throw new Error(_context2.t1);
13342
+ case 10:
13343
+ case "end":
13344
+ return _context2.stop();
13345
+ }
13346
+ }, _callee2, null, [[0, 7]]);
13347
+ }));
13348
+ return function pubKeyUrl(_x2) {
13349
+ return _ref2.apply(this, arguments);
13350
+ };
13351
+ }();
13352
+ exports.pubKeyUrl = pubKeyUrl;
13353
+ function getExistingPublicKey(_x3, _x4) {
13354
+ return _getExistingPublicKey.apply(this, arguments);
13355
+ }
13356
+ function _getExistingPublicKey() {
13357
+ _getExistingPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(webId, publicKeyUrl) {
13358
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
13359
+ while (1) switch (_context4.prev = _context4.next) {
13360
+ case 0:
13361
+ _context4.next = 2;
13362
+ return getKeyIfExists(webId, publicKeyUrl, 'PublicKey');
13363
+ case 2:
13364
+ return _context4.abrupt("return", _context4.sent);
13365
+ case 3:
13366
+ case "end":
13367
+ return _context4.stop();
13368
+ }
13369
+ }, _callee4);
13370
+ }));
13371
+ return _getExistingPublicKey.apply(this, arguments);
13372
+ }
13373
+ var privKeyUrl = /*#__PURE__*/function () {
13374
+ var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId) {
13375
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
13376
+ while (1) switch (_context3.prev = _context3.next) {
13377
+ case 0:
13378
+ _context3.prev = 0;
13379
+ _context3.next = 3;
13380
+ return getPodRoot(webId);
13381
+ case 3:
13382
+ _context3.t0 = _context3.sent;
13383
+ return _context3.abrupt("return", _context3.t0 + 'profile/keys/privateKey.ttl');
13384
+ case 7:
13385
+ _context3.prev = 7;
13386
+ _context3.t1 = _context3["catch"](0);
13387
+ throw new Error(_context3.t1);
13388
+ case 10:
13389
+ case "end":
13390
+ return _context3.stop();
13391
+ }
13392
+ }, _callee3, null, [[0, 7]]);
13393
+ }));
13394
+ return function privKeyUrl(_x5) {
13395
+ return _ref3.apply(this, arguments);
13396
+ };
13397
+ }();
13398
+ exports.privKeyUrl = privKeyUrl;
13399
+ function getExistingPrivateKey(_x6, _x7) {
13400
+ return _getExistingPrivateKey.apply(this, arguments);
13401
+ }
13402
+ function _getExistingPrivateKey() {
13403
+ _getExistingPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(webId, privateKeyUrl) {
13404
+ return _regenerator["default"].wrap(function _callee5$(_context5) {
13405
+ while (1) switch (_context5.prev = _context5.next) {
13406
+ case 0:
13407
+ _context5.next = 2;
13408
+ return getKeyIfExists(webId, privateKeyUrl, 'PrivateKey');
13409
+ case 2:
13410
+ return _context5.abrupt("return", _context5.sent);
13411
+ case 3:
13412
+ case "end":
13413
+ return _context5.stop();
13414
+ }
13415
+ }, _callee5);
13416
+ }));
13417
+ return _getExistingPrivateKey.apply(this, arguments);
13418
+ }
13419
+ function getKeyIfExists(_x8, _x9, _x10) {
13420
+ return _getKeyIfExists.apply(this, arguments);
13421
+ }
13422
+ function _getKeyIfExists() {
13423
+ _getKeyIfExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(webId, keyUrl, keyType) {
13424
+ var key, _err$response, data, contentType, response;
13425
+ return _regenerator["default"].wrap(function _callee6$(_context6) {
13426
+ while (1) switch (_context6.prev = _context6.next) {
13427
+ case 0:
13428
+ _context6.prev = 0;
13429
+ _context6.next = 3;
13430
+ return _solidLogic.store.fetcher.load(keyUrl);
13431
+ case 3:
13432
+ key = _solidLogic.store.any(webId, _solidLogic.store.sym(_signature.CERT + keyType));
13433
+ return _context6.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
13434
+ case 7:
13435
+ _context6.prev = 7;
13436
+ _context6.t0 = _context6["catch"](0);
13437
+ 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)) {
13438
+ _context6.next = 24;
13439
+ break;
13440
+ }
13441
+ _context6.prev = 10;
13442
+ // create resource
13443
+ data = '';
13444
+ contentType = 'text/turtle';
13445
+ _context6.next = 15;
13446
+ return _solidLogic.store.fetcher.webOperation('PUT', keyUrl, {
13447
+ data: data,
13448
+ contentType: contentType
13449
+ });
13450
+ case 15:
13451
+ response = _context6.sent;
13452
+ _context6.next = 22;
13453
+ break;
13454
+ case 18:
13455
+ _context6.prev = 18;
13456
+ _context6.t1 = _context6["catch"](10);
13457
+ debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context6.t1);
13458
+ throw _context6.t1;
13459
+ case 22:
13460
+ delete _solidLogic.store.fetcher.requested[keyUrl]; // delete cached 404 error
13461
+ return _context6.abrupt("return", undefined);
13462
+ case 24:
13463
+ debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context6.t0);
13464
+ throw _context6.t0;
13465
+ case 26:
13466
+ case "end":
13467
+ return _context6.stop();
13468
+ }
13469
+ }, _callee6, null, [[0, 7], [10, 18]]);
13470
+ }));
13471
+ return _getKeyIfExists.apply(this, arguments);
13472
+ }
13473
+ //# sourceMappingURL=accessData.js.map
13474
+
13475
+ /***/ }),
13476
+
13477
+ /***/ "./lib/utils/keyHelpers/acl.js":
13478
+ /*!*************************************!*\
13479
+ !*** ./lib/utils/keyHelpers/acl.js ***!
13480
+ \*************************************/
13481
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
13482
+
13483
+ "use strict";
13484
+
13485
+
13486
+ var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");
13487
+ var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
13488
+ Object.defineProperty(exports, "__esModule", ({
13489
+ value: true
13490
+ }));
13491
+ exports.keyContainerAclBody = exports.keyAclBody = void 0;
13492
+ exports.setAcl = setAcl;
13493
+ var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
13494
+ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
13495
+ var debug = _interopRequireWildcard(__webpack_require__(/*! ../../debug */ "./lib/debug.js"));
13496
+ var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
13497
+ 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); }
13498
+ 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; }
13499
+ /**
13500
+ * set ACL
13501
+ * @param keyDoc
13502
+ * @param aclBody
13503
+ */
13504
+ function setAcl(_x, _x2) {
13505
+ return _setAcl.apply(this, arguments);
13506
+ }
13507
+ /**
13508
+ * key container ACL
13509
+ * @param me
13510
+ * @returns aclBody
13511
+ */
13512
+ function _setAcl() {
13513
+ _setAcl = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(keyDoc, aclBody) {
13514
+ var keyAclDoc, _err$response;
13515
+ return _regenerator["default"].wrap(function _callee$(_context) {
13516
+ while (1) switch (_context.prev = _context.next) {
13517
+ case 0:
13518
+ _context.next = 2;
13519
+ return _solidLogic.store.fetcher.load(keyDoc);
13520
+ case 2:
13521
+ // FIXME: check the Why value on this quad:
13522
+ debug.log(_solidLogic.store.statementsMatching(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl')));
13523
+ keyAclDoc = _solidLogic.store.any(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl'));
13524
+ if (keyAclDoc) {
13525
+ _context.next = 6;
13526
+ break;
13527
+ }
13528
+ throw new Error('Key ACL doc not found!');
13529
+ case 6:
13530
+ _context.prev = 6;
13531
+ _context.next = 9;
13532
+ return _solidLogic.store.fetcher.webOperation('PUT', keyAclDoc.value, {
13533
+ data: aclBody,
13534
+ contentType: 'text/turtle'
13535
+ });
13536
+ case 9:
13537
+ _context.next = 16;
13538
+ break;
13539
+ case 11:
13540
+ _context.prev = 11;
13541
+ _context.t0 = _context["catch"](6);
13542
+ 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)) {
13543
+ _context.next = 15;
13544
+ break;
13545
+ }
13546
+ throw new Error(_context.t0);
13547
+ case 15:
13548
+ debug.log('delete ' + keyAclDoc.value + ' ' + _context.t0.response.status); // should test 404 and 2xx
13549
+ case 16:
13550
+ case "end":
13551
+ return _context.stop();
13552
+ }
13553
+ }, _callee, null, [[6, 11]]);
13554
+ }));
13555
+ return _setAcl.apply(this, arguments);
13556
+ }
13557
+ var keyContainerAclBody = function keyContainerAclBody(me) {
13558
+ 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");
13559
+ return aclBody;
13560
+ };
13561
+
13562
+ /**
13563
+ * Read only ACL
13564
+ * @param keyDoc
13565
+ * @param me
13566
+ * @returns aclBody
13567
+ */
13568
+ exports.keyContainerAclBody = keyContainerAclBody;
13569
+ var keyAclBody = function keyAclBody(keyDoc, me) {
13570
+ var keyAgent = 'acl:agentClass foaf:Agent'; // publicKey
13571
+ if (me !== null && me !== void 0 && me.length) keyAgent = "acl:agent <".concat(me, ">"); // privateKey
13572
+ 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");
13573
+ return aclBody;
13574
+ };
13575
+ exports.keyAclBody = keyAclBody;
13576
+ //# sourceMappingURL=acl.js.map
13577
+
13578
+ /***/ }),
13579
+
13462
13580
  /***/ "./lib/utils/label.js":
13463
13581
  /*!****************************!*\
13464
13582
  !*** ./lib/utils/label.js ***!
@@ -13587,8 +13705,8 @@ Object.defineProperty(exports, "__esModule", ({
13587
13705
  }));
13588
13706
  exports.versionInfo = void 0;
13589
13707
  var versionInfo = {
13590
- buildTime: '2023-05-01T20:03:38Z',
13591
- commit: 'fd0d1bf4759c488f6aca406446337baf12f009f3',
13708
+ buildTime: '2023-05-17T23:36:37Z',
13709
+ commit: 'fd5a7172c8e5cef746d9812d555a274590b70866',
13592
13710
  npmInfo: {
13593
13711
  'solid-ui': '2.4.27',
13594
13712
  npm: '8.19.4',
@@ -66404,22 +66522,7 @@ module.exports = JSON.parse('{"application/1d-interleaved-parityfec":{"source":"
66404
66522
  /******/
66405
66523
  /******/ /* webpack/runtime/publicPath */
66406
66524
  /******/ (() => {
66407
- /******/ var scriptUrl;
66408
- /******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
66409
- /******/ var document = __webpack_require__.g.document;
66410
- /******/ if (!scriptUrl && document) {
66411
- /******/ if (document.currentScript)
66412
- /******/ scriptUrl = document.currentScript.src;
66413
- /******/ if (!scriptUrl) {
66414
- /******/ var scripts = document.getElementsByTagName("script");
66415
- /******/ if(scripts.length) scriptUrl = scripts[scripts.length - 1].src
66416
- /******/ }
66417
- /******/ }
66418
- /******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
66419
- /******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
66420
- /******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
66421
- /******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
66422
- /******/ __webpack_require__.p = scriptUrl;
66525
+ /******/ __webpack_require__.p = "";
66423
66526
  /******/ })();
66424
66527
  /******/
66425
66528
  /******/ /* webpack/runtime/jsonp chunk loading */