solid-ui 2.4.27-7184a38a → 2.4.27-75062170

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,35 +4053,46 @@ 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
  }
@@ -4088,184 +4100,158 @@ function getPrivateKey(_x2) {
4088
4100
  return _getPrivateKey.apply(this, arguments);
4089
4101
  }
4090
4102
  function _getPrivateKey() {
4091
- _getPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
4103
+ _getPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId) {
4092
4104
  var publicKeyDoc, privateKeyDoc, publicKey, privateKey, validPublicKey, del, add, newPublicKey, keyContainer;
4093
- return _regenerator["default"].wrap(function _callee2$(_context2) {
4094
- while (1) switch (_context2.prev = _context2.next) {
4105
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
4106
+ while (1) switch (_context3.prev = _context3.next) {
4095
4107
  case 0:
4096
- _context2.next = 2;
4108
+ _context3.next = 2;
4097
4109
  return _solidLogic.store.fetcher.load(webId);
4098
4110
  case 2:
4099
- // find keys url's
4100
- publicKeyDoc = (0, _cryptoKeyHelpers.pubKeyUrl)(webId);
4101
- privateKeyDoc = (0, _cryptoKeyHelpers.privKeyUrl)(webId); // find key pair
4102
- _context2.next = 6;
4103
- return (0, _cryptoKeyHelpers.publicKeyExists)(webId);
4104
- case 6:
4105
- publicKey = _context2.sent;
4106
- _context2.next = 9;
4107
- return (0, _cryptoKeyHelpers.privateKeyExists)(webId);
4108
- case 9:
4109
- privateKey = _context2.sent;
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;
4110
4127
  // is publicKey valid ?
4111
4128
  validPublicKey = true;
4112
4129
  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;
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;
4114
4131
  }
4115
4132
 
4116
4133
  // create key pair or repair publicKey
4117
4134
  if (!(!privateKey || !publicKey || !validPublicKey)) {
4118
- _context2.next = 30;
4135
+ _context3.next = 34;
4119
4136
  break;
4120
4137
  }
4121
4138
  del = [];
4122
- 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)))
4123
4140
  if (privateKey) {
4124
- _context2.next = 20;
4141
+ _context3.next = 24;
4125
4142
  break;
4126
4143
  }
4127
4144
  // add = []
4128
4145
  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:
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:
4133
4150
  if (!(!publicKey || !validPublicKey)) {
4134
- _context2.next = 27;
4151
+ _context3.next = 31;
4135
4152
  break;
4136
4153
  }
4137
4154
  del = [];
4138
4155
  // delete invalid public key
4139
4156
  if (publicKey) {
4140
- 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))];
4141
4158
  debug.log(del);
4142
4159
  }
4143
4160
  // update new valid key
4144
4161
  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;
4162
+ add = [$rdf.st(webId, _solidLogic.store.sym(_signature.CERT + 'PublicKey'), $rdf.literal(newPublicKey), _solidLogic.store.sym(publicKeyDoc))];
4163
+ _context3.next = 31;
4147
4164
  return saveKey(publicKeyDoc, del, add);
4148
- case 27:
4149
- keyContainer = privateKeyDoc.substring(0, privateKeyDoc.lastIndexOf('/') + 1);
4150
- _context2.next = 30;
4151
- return setAcl(keyContainer, keyContainerAclBody(webId));
4152
- case 30:
4153
- return _context2.abrupt("return", privateKey);
4154
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:
4155
4172
  case "end":
4156
- return _context2.stop();
4173
+ return _context3.stop();
4157
4174
  }
4158
- }, _callee2);
4175
+ }, _callee3);
4159
4176
  }));
4160
4177
  return _getPrivateKey.apply(this, arguments);
4161
4178
  }
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) {
4179
+ var deleteKeyAcl = /*#__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) {
4180
4184
  case 0:
4181
- _context3.next = 2;
4185
+ _context.next = 2;
4182
4186
  return _solidLogic.store.fetcher.load(keyDoc);
4183
4187
  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
+ 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;
4188
4191
  break;
4189
4192
  }
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
- });
4193
+ _context.prev = 4;
4194
+ _context.next = 7;
4195
+ return _solidLogic.store.fetcher.webOperation('DELETE', keyAclDoc.value);
4197
4196
  case 7:
4198
- aclResponse = _context3.sent;
4199
- case 8:
4197
+ response = _context.sent;
4198
+ // this may fail if webId is not an owner
4199
+ debug.log('delete ' + keyAclDoc.value + ' ' + response.status); // should test 404 and 2xx
4200
+ _context.next = 16;
4201
+ break;
4202
+ case 11:
4203
+ _context.prev = 11;
4204
+ _context.t0 = _context["catch"](4);
4205
+ if (!(_context.t0.response.status !== 404)) {
4206
+ _context.next = 15;
4207
+ break;
4208
+ }
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:
4200
4213
  case "end":
4201
- return _context3.stop();
4214
+ return _context.stop();
4202
4215
  }
4203
- }, _callee3);
4216
+ }, _callee, null, [[4, 11]]);
4204
4217
  }));
4205
- return _setAcl.apply(this, arguments);
4206
- }
4207
- function saveKey(_x5, _x6, _x7) {
4218
+ return function deleteKeyAcl(_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) {
4208
4229
  return _saveKey.apply(this, arguments);
4209
4230
  }
4210
4231
  function _saveKey() {
4211
4232
  _saveKey = (0, _asyncToGenerator2["default"])(function (keyDoc, del, add) {
4212
4233
  var me = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
4213
4234
  return /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
4214
- var keyAclDoc, response, aclBody;
4235
+ var aclBody;
4215
4236
  return _regenerator["default"].wrap(function _callee4$(_context4) {
4216
4237
  while (1) switch (_context4.prev = _context4.next) {
4217
4238
  case 0:
4218
4239
  _context4.next = 2;
4219
- return _solidLogic.store.updater.updateMany(del, add);
4240
+ return deleteKeyAcl(keyDoc);
4220
4241
  case 2:
4221
4242
  _context4.next = 4;
4222
- return _solidLogic.store.fetcher.load(keyDoc);
4243
+ return _solidLogic.store.updater.updateMany(del, add);
4223
4244
  case 4:
4224
- _context4.prev = 4;
4225
- // get keyAcldoc
4226
- keyAclDoc = _solidLogic.store.any($rdf.sym(keyDoc), $rdf.sym('http://www.iana.org/assignments/link-relations/acl'));
4227
- if (keyAclDoc) {
4228
- _context4.next = 8;
4229
- break;
4230
- }
4231
- throw new Error("".concat(keyDoc, " ACL doc not found!"));
4232
- case 8:
4233
- _context4.prev = 8;
4234
- _context4.next = 11;
4235
- return _solidLogic.store.fetcher.webOperation('DELETE', keyAclDoc.value);
4236
- case 11:
4237
- response = _context4.sent;
4238
- // this may fail if webId is not an owner
4239
- debug.log('delete ' + keyAclDoc.value + ' ' + response.status); // should test 404 and 2xx
4240
- _context4.next = 20;
4241
- break;
4242
- case 15:
4243
- _context4.prev = 15;
4244
- _context4.t0 = _context4["catch"](8);
4245
- if (!(_context4.t0.response.status !== 404)) {
4246
- _context4.next = 19;
4247
- break;
4248
- }
4249
- throw new Error(_context4.t0);
4250
- case 19:
4251
- debug.log('delete ' + keyAclDoc.value + ' ' + _context4.t0.response.status); // should test 404 and 2xx
4252
- case 20:
4245
+ // or a promise store.updater.update ?
4253
4246
  // create READ only ACL
4254
- aclBody = keyAclBody(keyDoc, me);
4255
- _context4.next = 23;
4256
- return setAcl(keyDoc, aclBody);
4257
- case 23:
4258
- _context4.next = 28;
4259
- break;
4260
- case 25:
4261
- _context4.prev = 25;
4262
- _context4.t1 = _context4["catch"](4);
4263
- throw new Error(_context4.t1);
4264
- case 28:
4247
+ aclBody = (0, _acl.keyAclBody)(keyDoc, me);
4248
+ _context4.next = 7;
4249
+ return (0, _acl.setAcl)(keyDoc, aclBody);
4250
+ case 7:
4265
4251
  case "end":
4266
4252
  return _context4.stop();
4267
4253
  }
4268
- }, _callee4, null, [[4, 25], [8, 15]]);
4254
+ }, _callee4);
4269
4255
  })();
4270
4256
  });
4271
4257
  return _saveKey.apply(this, arguments);
@@ -4417,11 +4403,11 @@ function renderMessageRow(channelObject, message, fresh, options, userContext) {
4417
4403
 
4418
4404
  // signed message, get public key and check signature
4419
4405
  else {
4420
- (0, _keys.getPublicKey)(creator.uri).then(function (publicKey) {
4406
+ (0, _keys.getPublicKey)(creator).then(function (publicKey) {
4421
4407
  debug.log(creator.uri + '\n' + msg.created + '\n' + msg.id + '\n' + publicKey);
4422
4408
  if (!publicKey) {
4423
4409
  // TODO try to recreate the publicKey
4424
- // if(me.uri === creator.uri) await getPrivateKey(creator.uri)
4410
+ // if(me.uri === creator.uri) await getPrivateKey(creator)
4425
4411
  debug.warn('message is signed but ' + creator.uri + ' is missing publicKey');
4426
4412
  }
4427
4413
  // check that publicKey is a valid hex string
@@ -5224,13 +5210,11 @@ Object.defineProperty(exports, "__esModule", ({
5224
5210
  value: true
5225
5211
  }));
5226
5212
  exports.SEC = exports.CERT = void 0;
5227
- exports.finishMsg = finishMsg;
5228
5213
  exports.getBlankMsg = getBlankMsg;
5229
5214
  exports.getMsgHash = getMsgHash;
5230
5215
  exports.serializeMsg = serializeMsg;
5231
5216
  exports.signMsg = signMsg;
5232
5217
  exports.utf8Encoder = exports.utf8Decoder = void 0;
5233
- exports.validateMsg = validateMsg;
5234
5218
  exports.verifySignature = verifySignature;
5235
5219
  var _secp256k = __webpack_require__(/*! @noble/curves/secp256k1 */ "./node_modules/@noble/curves/secp256k1.js");
5236
5220
  var _utils = __webpack_require__(/*! @noble/hashes/utils */ "./node_modules/@noble/hashes/utils.js");
@@ -5276,19 +5260,22 @@ function getBlankMsg() {
5276
5260
  id: '',
5277
5261
  created: '',
5278
5262
  dateDeleted: '',
5263
+ // TODO to remove if not used
5279
5264
  content: '',
5280
5265
  maker: '',
5281
- sig: ''
5266
+ sig: '' // TODO to remove if not used
5282
5267
  };
5283
5268
  }
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
- }
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
+
5292
5279
  function serializeMsg(msg) {
5293
5280
  // to update to chat messages triples
5294
5281
  /* if (!validateMsg(msg))
@@ -5300,27 +5287,29 @@ function getMsgHash(message) {
5300
5287
  var msgHash = (0, _sha.sha256)(utf8Encoder.encode(serializeMsg(message)));
5301
5288
  return (0, _utils.bytesToHex)(msgHash);
5302
5289
  }
5303
- var isRecord = function isRecord(obj) {
5304
- return obj instanceof Object;
5305
- };
5306
- function validateMsg(message) {
5307
- /* 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
5308
5295
  if (typeof message.kind !== 'number') return false
5309
5296
  if (typeof message.content !== 'string') return false
5310
5297
  if (typeof message.created_at !== 'number') return false
5311
5298
  if (typeof message.pubkey !== 'string') return false
5312
5299
  if (!message.pubkey.match(/^[a-f0-9]{64}$/)) return false
5313
- if (!Array.isArray(message.tags)) return false
5300
+
5301
+ if (!Array.isArray(message.tags)) return false
5314
5302
  for (let i = 0; i < message.tags.length; i++) {
5315
5303
  let tag = message.tags[i]
5316
5304
  if (!Array.isArray(tag)) return false
5317
5305
  for (let j = 0; j < tag.length; j++) {
5318
5306
  if (typeof tag[j] === 'object') return false
5319
5307
  }
5320
- } */
5308
+ }
5309
+
5310
+ return true
5311
+ } */
5321
5312
 
5322
- return true;
5323
- }
5324
5313
  function verifySignature(sig, message, pubKey) {
5325
5314
  return _secp256k.schnorr.verify(sig, getMsgHash(message), pubKey);
5326
5315
  }
@@ -12531,173 +12520,6 @@ function isLight(x) {
12531
12520
 
12532
12521
  /***/ }),
12533
12522
 
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
12523
  /***/ "./lib/utils/headerFooterHelpers.js":
12702
12524
  /*!******************************************!*\
12703
12525
  !*** ./lib/utils/headerFooterHelpers.js ***!
@@ -13416,6 +13238,344 @@ function predParentOf(node) {
13416
13238
 
13417
13239
  /***/ }),
13418
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 webIdURL, storages, podRoot, path, _res$headers$get, res;
13270
+ return _regenerator["default"].wrap(function _callee$(_context) {
13271
+ while (1) switch (_context.prev = _context.next) {
13272
+ case 0:
13273
+ webIdURL = new URL(webId.uri); // find storages in webId document
13274
+ _context.next = 3;
13275
+ return _solidLogic.store.fetcher.load(webId.uri);
13276
+ case 3:
13277
+ storages = _solidLogic.store.each(webId, ns.space('storage'), null, webId.doc());
13278
+ if (storages !== null && storages !== void 0 && storages.length) {
13279
+ _context.next = 19;
13280
+ break;
13281
+ }
13282
+ // find storage recursively in webId URL
13283
+ path = webIdURL.pathname;
13284
+ case 6:
13285
+ if (!path.length) {
13286
+ _context.next = 17;
13287
+ break;
13288
+ }
13289
+ path = path.substring(0, path.lastIndexOf('/'));
13290
+ podRoot = _solidLogic.store.sym(webIdURL.origin + path + '/');
13291
+ _context.next = 11;
13292
+ return _solidLogic.store.fetcher.webOperation('HEAD', podRoot.uri);
13293
+ case 11:
13294
+ res = _context.sent;
13295
+ if (!((_res$headers$get = res.headers.get('link')) !== null && _res$headers$get !== void 0 && _res$headers$get.includes(ns.space('Storage').value))) {
13296
+ _context.next = 14;
13297
+ break;
13298
+ }
13299
+ return _context.abrupt("break", 17);
13300
+ case 14:
13301
+ if (!path) debug.warn("Current user storage not found for\n".concat(webId));
13302
+ _context.next = 6;
13303
+ break;
13304
+ case 17:
13305
+ _context.next = 21;
13306
+ break;
13307
+ case 19:
13308
+ // give preference to storage in webId root
13309
+ podRoot = storages.find(function (storage) {
13310
+ return webIdURL.origin === new URL(storage.value).origin;
13311
+ });
13312
+ if (!podRoot) podRoot = storages[0];
13313
+ case 21:
13314
+ return _context.abrupt("return", podRoot);
13315
+ case 22:
13316
+ case "end":
13317
+ return _context.stop();
13318
+ }
13319
+ }, _callee);
13320
+ }));
13321
+ return function getPodRoot(_x) {
13322
+ return _ref.apply(this, arguments);
13323
+ };
13324
+ }();
13325
+ exports.getPodRoot = getPodRoot;
13326
+ var pubKeyUrl = /*#__PURE__*/function () {
13327
+ var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
13328
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
13329
+ while (1) switch (_context2.prev = _context2.next) {
13330
+ case 0:
13331
+ _context2.prev = 0;
13332
+ _context2.next = 3;
13333
+ return getPodRoot(webId);
13334
+ case 3:
13335
+ _context2.t0 = _context2.sent.value;
13336
+ return _context2.abrupt("return", _context2.t0 + 'profile/keys/publicKey.ttl');
13337
+ case 7:
13338
+ _context2.prev = 7;
13339
+ _context2.t1 = _context2["catch"](0);
13340
+ throw new Error(_context2.t1);
13341
+ case 10:
13342
+ case "end":
13343
+ return _context2.stop();
13344
+ }
13345
+ }, _callee2, null, [[0, 7]]);
13346
+ }));
13347
+ return function pubKeyUrl(_x2) {
13348
+ return _ref2.apply(this, arguments);
13349
+ };
13350
+ }();
13351
+ exports.pubKeyUrl = pubKeyUrl;
13352
+ function getExistingPublicKey(_x3, _x4) {
13353
+ return _getExistingPublicKey.apply(this, arguments);
13354
+ }
13355
+ function _getExistingPublicKey() {
13356
+ _getExistingPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(webId, publicKeyUrl) {
13357
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
13358
+ while (1) switch (_context4.prev = _context4.next) {
13359
+ case 0:
13360
+ _context4.next = 2;
13361
+ return getKeyIfExists(webId, publicKeyUrl, 'PublicKey');
13362
+ case 2:
13363
+ return _context4.abrupt("return", _context4.sent);
13364
+ case 3:
13365
+ case "end":
13366
+ return _context4.stop();
13367
+ }
13368
+ }, _callee4);
13369
+ }));
13370
+ return _getExistingPublicKey.apply(this, arguments);
13371
+ }
13372
+ var privKeyUrl = /*#__PURE__*/function () {
13373
+ var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId) {
13374
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
13375
+ while (1) switch (_context3.prev = _context3.next) {
13376
+ case 0:
13377
+ _context3.prev = 0;
13378
+ _context3.next = 3;
13379
+ return getPodRoot(webId);
13380
+ case 3:
13381
+ _context3.t0 = _context3.sent.value;
13382
+ return _context3.abrupt("return", _context3.t0 + 'profile/keys/privateKey.ttl');
13383
+ case 7:
13384
+ _context3.prev = 7;
13385
+ _context3.t1 = _context3["catch"](0);
13386
+ throw new Error(_context3.t1);
13387
+ case 10:
13388
+ case "end":
13389
+ return _context3.stop();
13390
+ }
13391
+ }, _callee3, null, [[0, 7]]);
13392
+ }));
13393
+ return function privKeyUrl(_x5) {
13394
+ return _ref3.apply(this, arguments);
13395
+ };
13396
+ }();
13397
+ exports.privKeyUrl = privKeyUrl;
13398
+ function getExistingPrivateKey(_x6, _x7) {
13399
+ return _getExistingPrivateKey.apply(this, arguments);
13400
+ }
13401
+ function _getExistingPrivateKey() {
13402
+ _getExistingPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(webId, privateKeyUrl) {
13403
+ return _regenerator["default"].wrap(function _callee5$(_context5) {
13404
+ while (1) switch (_context5.prev = _context5.next) {
13405
+ case 0:
13406
+ _context5.next = 2;
13407
+ return getKeyIfExists(webId, privateKeyUrl, 'PrivateKey');
13408
+ case 2:
13409
+ return _context5.abrupt("return", _context5.sent);
13410
+ case 3:
13411
+ case "end":
13412
+ return _context5.stop();
13413
+ }
13414
+ }, _callee5);
13415
+ }));
13416
+ return _getExistingPrivateKey.apply(this, arguments);
13417
+ }
13418
+ function getKeyIfExists(_x8, _x9, _x10) {
13419
+ return _getKeyIfExists.apply(this, arguments);
13420
+ }
13421
+ function _getKeyIfExists() {
13422
+ _getKeyIfExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(webId, keyUrl, keyType) {
13423
+ var key, _err$response, data, contentType, response;
13424
+ return _regenerator["default"].wrap(function _callee6$(_context6) {
13425
+ while (1) switch (_context6.prev = _context6.next) {
13426
+ case 0:
13427
+ _context6.prev = 0;
13428
+ _context6.next = 3;
13429
+ return _solidLogic.store.fetcher.load(keyUrl);
13430
+ case 3:
13431
+ key = _solidLogic.store.any(webId, _solidLogic.store.sym(_signature.CERT + keyType));
13432
+ return _context6.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
13433
+ case 7:
13434
+ _context6.prev = 7;
13435
+ _context6.t0 = _context6["catch"](0);
13436
+ 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)) {
13437
+ _context6.next = 24;
13438
+ break;
13439
+ }
13440
+ _context6.prev = 10;
13441
+ // create resource
13442
+ data = '';
13443
+ contentType = 'text/turtle';
13444
+ _context6.next = 15;
13445
+ return _solidLogic.store.fetcher.webOperation('PUT', keyUrl, {
13446
+ data: data,
13447
+ contentType: contentType
13448
+ });
13449
+ case 15:
13450
+ response = _context6.sent;
13451
+ _context6.next = 22;
13452
+ break;
13453
+ case 18:
13454
+ _context6.prev = 18;
13455
+ _context6.t1 = _context6["catch"](10);
13456
+ debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context6.t1);
13457
+ throw _context6.t1;
13458
+ case 22:
13459
+ delete _solidLogic.store.fetcher.requested[keyUrl]; // delete cached 404 error
13460
+ return _context6.abrupt("return", undefined);
13461
+ case 24:
13462
+ debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context6.t0);
13463
+ throw _context6.t0;
13464
+ case 26:
13465
+ case "end":
13466
+ return _context6.stop();
13467
+ }
13468
+ }, _callee6, null, [[0, 7], [10, 18]]);
13469
+ }));
13470
+ return _getKeyIfExists.apply(this, arguments);
13471
+ }
13472
+ //# sourceMappingURL=accessData.js.map
13473
+
13474
+ /***/ }),
13475
+
13476
+ /***/ "./lib/utils/keyHelpers/acl.js":
13477
+ /*!*************************************!*\
13478
+ !*** ./lib/utils/keyHelpers/acl.js ***!
13479
+ \*************************************/
13480
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
13481
+
13482
+ "use strict";
13483
+
13484
+
13485
+ var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");
13486
+ var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
13487
+ Object.defineProperty(exports, "__esModule", ({
13488
+ value: true
13489
+ }));
13490
+ exports.keyContainerAclBody = exports.keyAclBody = void 0;
13491
+ exports.setAcl = setAcl;
13492
+ var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
13493
+ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
13494
+ var debug = _interopRequireWildcard(__webpack_require__(/*! ../../debug */ "./lib/debug.js"));
13495
+ var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
13496
+ 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); }
13497
+ 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; }
13498
+ /**
13499
+ * set ACL
13500
+ * @param keyDoc
13501
+ * @param aclBody
13502
+ */
13503
+ function setAcl(_x, _x2) {
13504
+ return _setAcl.apply(this, arguments);
13505
+ }
13506
+ /**
13507
+ * key container ACL
13508
+ * @param me
13509
+ * @returns aclBody
13510
+ */
13511
+ function _setAcl() {
13512
+ _setAcl = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(keyDoc, aclBody) {
13513
+ var keyAclDoc, _err$response;
13514
+ return _regenerator["default"].wrap(function _callee$(_context) {
13515
+ while (1) switch (_context.prev = _context.next) {
13516
+ case 0:
13517
+ _context.next = 2;
13518
+ return _solidLogic.store.fetcher.load(keyDoc);
13519
+ case 2:
13520
+ // FIXME: check the Why value on this quad:
13521
+ debug.log(_solidLogic.store.statementsMatching(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl')));
13522
+ keyAclDoc = _solidLogic.store.any(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl'));
13523
+ if (keyAclDoc) {
13524
+ _context.next = 6;
13525
+ break;
13526
+ }
13527
+ throw new Error('Key ACL doc not found!');
13528
+ case 6:
13529
+ _context.prev = 6;
13530
+ _context.next = 9;
13531
+ return _solidLogic.store.fetcher.webOperation('PUT', keyAclDoc.value, {
13532
+ data: aclBody,
13533
+ contentType: 'text/turtle'
13534
+ });
13535
+ case 9:
13536
+ _context.next = 16;
13537
+ break;
13538
+ case 11:
13539
+ _context.prev = 11;
13540
+ _context.t0 = _context["catch"](6);
13541
+ 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)) {
13542
+ _context.next = 15;
13543
+ break;
13544
+ }
13545
+ throw new Error(_context.t0);
13546
+ case 15:
13547
+ debug.log('delete ' + keyAclDoc.value + ' ' + _context.t0.response.status); // should test 404 and 2xx
13548
+ case 16:
13549
+ case "end":
13550
+ return _context.stop();
13551
+ }
13552
+ }, _callee, null, [[6, 11]]);
13553
+ }));
13554
+ return _setAcl.apply(this, arguments);
13555
+ }
13556
+ var keyContainerAclBody = function keyContainerAclBody(me) {
13557
+ 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");
13558
+ return aclBody;
13559
+ };
13560
+
13561
+ /**
13562
+ * Read only ACL
13563
+ * @param keyDoc
13564
+ * @param me
13565
+ * @returns aclBody
13566
+ */
13567
+ exports.keyContainerAclBody = keyContainerAclBody;
13568
+ var keyAclBody = function keyAclBody(keyDoc, me) {
13569
+ var keyAgent = 'acl:agentClass foaf:Agent'; // publicKey
13570
+ if (me !== null && me !== void 0 && me.length) keyAgent = "acl:agent <".concat(me, ">"); // privateKey
13571
+ 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");
13572
+ return aclBody;
13573
+ };
13574
+ exports.keyAclBody = keyAclBody;
13575
+ //# sourceMappingURL=acl.js.map
13576
+
13577
+ /***/ }),
13578
+
13419
13579
  /***/ "./lib/utils/label.js":
13420
13580
  /*!****************************!*\
13421
13581
  !*** ./lib/utils/label.js ***!
@@ -13544,8 +13704,8 @@ Object.defineProperty(exports, "__esModule", ({
13544
13704
  }));
13545
13705
  exports.versionInfo = void 0;
13546
13706
  var versionInfo = {
13547
- buildTime: '2023-04-30T22:04:08Z',
13548
- commit: '7184a38ab5fc3b8a1be713169d0ef99666aad8a7',
13707
+ buildTime: '2023-05-18T16:22:51Z',
13708
+ commit: '75062170392eec4bb1af60f905cf115adc5e2daf',
13549
13709
  npmInfo: {
13550
13710
  'solid-ui': '2.4.27',
13551
13711
  npm: '8.19.4',