solid-ui 2.4.27-beea007f → 2.4.27-c0cda1b3

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,7 +2703,7 @@ 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));
@@ -2715,35 +2715,34 @@ var ChatChannel = /*#__PURE__*/function () {
2715
2715
  privateKey = _context2.sent;
2716
2716
  // me.uri)
2717
2717
  // const privateKey0 = 'a11bc5d2eee6cdb3b37f5473a712cad905ccfb13fb2ccdbf1be0a1ac4fdc7d2a'
2718
- // const pubKey0 = '023a9da707bee1302f66083c9d95673ff969b41607a66f52686fa774d64ceb87'
2719
- pubKey = (0, _keys.getPublicKey)(me.uri);
2720
- sig = (0, _signature.signMsg)(msg, privateKey);
2721
- /* 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
2722
2721
  debug.warn('sig ' + sig)
2723
2722
  debug.warn('verifySign ' + verify)
2724
2723
  debug.warn(msg) */
2725
2724
  sts.push($rdf.st(message, $rdf.sym("".concat(_signature.SEC, "Proof")), $rdf.lit(sig), chatDocument));
2726
- case 36:
2727
- _context2.prev = 36;
2728
- _context2.next = 39;
2725
+ case 35:
2726
+ _context2.prev = 35;
2727
+ _context2.next = 38;
2729
2728
  return _solidLogic.store.updater.update([], sts);
2730
- case 39:
2731
- _context2.next = 47;
2729
+ case 38:
2730
+ _context2.next = 46;
2732
2731
  break;
2733
- case 41:
2734
- _context2.prev = 41;
2735
- _context2.t0 = _context2["catch"](36);
2732
+ case 40:
2733
+ _context2.prev = 40;
2734
+ _context2.t0 = _context2["catch"](35);
2736
2735
  _errMsg = 'Error saving chat message: ' + _context2.t0;
2737
2736
  debug.warn(_errMsg);
2738
2737
  alert(_errMsg);
2739
2738
  throw new Error(_errMsg);
2740
- case 47:
2739
+ case 46:
2741
2740
  return _context2.abrupt("return", message);
2742
- case 48:
2741
+ case 47:
2743
2742
  case "end":
2744
2743
  return _context2.stop();
2745
2744
  }
2746
- }, _callee2, null, [[36, 41]]);
2745
+ }, _callee2, null, [[35, 40]]);
2747
2746
  })();
2748
2747
  });
2749
2748
  function updateMessage(_x2) {
@@ -4044,7 +4043,8 @@ var _utils = __webpack_require__(/*! @noble/hashes/utils */ "./node_modules/@nob
4044
4043
  var _signature = __webpack_require__(/*! ./signature */ "./lib/chat/signature.js");
4045
4044
  var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
4046
4045
  var $rdf = _interopRequireWildcard(__webpack_require__(/*! rdflib */ "./node_modules/rdflib/esm/index.js"));
4047
- 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");
4048
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); }
4049
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; }
4050
4050
  function generatePrivateKey() {
@@ -4053,6 +4053,14 @@ function generatePrivateKey() {
4053
4053
  function generatePublicKey(privateKey) {
4054
4054
  return (0, _utils.bytesToHex)(_secp256k.schnorr.getPublicKey(privateKey));
4055
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
+ */
4056
4064
  function getPublicKey(_x) {
4057
4065
  return _getPublicKey.apply(this, arguments);
4058
4066
  }
@@ -4066,7 +4074,7 @@ function _getPublicKey() {
4066
4074
  return _solidLogic.store.fetcher.load(webId);
4067
4075
  case 2:
4068
4076
  _context.next = 4;
4069
- return (0, _cryptoKeyHelpers.pubKeyUrl)(webId);
4077
+ return (0, _accessData.pubKeyUrl)(webId);
4070
4078
  case 4:
4071
4079
  publicKeyDoc = _context.sent;
4072
4080
  _context.prev = 5;
@@ -4092,9 +4100,9 @@ function getPrivateKey(_x2) {
4092
4100
  return _getPrivateKey.apply(this, arguments);
4093
4101
  }
4094
4102
  /**
4095
- * key container ACL
4096
- * @param me
4097
- * @returns aclBody
4103
+ * delete acl if keydoc exists
4104
+ * create/edit keyDoc
4105
+ * set keyDoc acl
4098
4106
  */
4099
4107
  function _getPrivateKey() {
4100
4108
  _getPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
@@ -4106,25 +4114,25 @@ function _getPrivateKey() {
4106
4114
  return _solidLogic.store.fetcher.load(webId);
4107
4115
  case 2:
4108
4116
  _context2.next = 4;
4109
- return (0, _cryptoKeyHelpers.pubKeyUrl)(webId);
4117
+ return (0, _accessData.pubKeyUrl)(webId);
4110
4118
  case 4:
4111
4119
  publicKeyDoc = _context2.sent;
4112
4120
  _context2.next = 7;
4113
- return (0, _cryptoKeyHelpers.privKeyUrl)(webId);
4121
+ return (0, _accessData.privKeyUrl)(webId);
4114
4122
  case 7:
4115
4123
  privateKeyDoc = _context2.sent;
4116
4124
  _context2.next = 10;
4117
- return (0, _cryptoKeyHelpers.publicKeyExists)(webId);
4125
+ return (0, _accessData.getExistingPublicKey)(webId, publicKeyDoc);
4118
4126
  case 10:
4119
4127
  publicKey = _context2.sent;
4120
4128
  _context2.next = 13;
4121
- return (0, _cryptoKeyHelpers.privateKeyExists)(webId);
4129
+ return (0, _accessData.getExistingPrivateKey)(webId, privateKeyDoc);
4122
4130
  case 13:
4123
4131
  privateKey = _context2.sent;
4124
4132
  // is publicKey valid ?
4125
4133
  validPublicKey = true;
4126
4134
  if (privateKey && publicKey !== generatePublicKey(privateKey)) {
4127
- if (confirm('This is strange the publicKey is not valid for\n' + webId + '\'shall we repair keeping the private key ?')) validPublicKey = false;
4135
+ 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;
4128
4136
  }
4129
4137
 
4130
4138
  // create key pair or repair publicKey
@@ -4162,7 +4170,7 @@ function _getPrivateKey() {
4162
4170
  case 31:
4163
4171
  keyContainer = privateKeyDoc.substring(0, privateKeyDoc.lastIndexOf('/') + 1);
4164
4172
  _context2.next = 34;
4165
- return setAcl(keyContainer, keyContainerAclBody(webId.uri));
4173
+ return (0, _acl.setAcl)(keyContainer, (0, _acl.keyContainerAclBody)(webId.uri));
4166
4174
  case 34:
4167
4175
  return _context2.abrupt("return", privateKey);
4168
4176
  case 35:
@@ -4173,151 +4181,67 @@ function _getPrivateKey() {
4173
4181
  }));
4174
4182
  return _getPrivateKey.apply(this, arguments);
4175
4183
  }
4176
- var keyContainerAclBody = function keyContainerAclBody(me) {
4177
- 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");
4178
- return aclBody;
4179
- };
4180
-
4181
- /**
4182
- * Read only ACL
4183
- * @param keyDoc
4184
- * @param me
4185
- * @returns aclBody
4186
- */
4187
- var keyAclBody = function keyAclBody(keyDoc, me) {
4188
- var keyAgent = 'acl:agentClass foaf:Agent'; // publicKey
4189
- if (me !== null && me !== void 0 && me.length) keyAgent = "acl:agent <".concat(me, ">"); // privateKey
4190
- 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");
4191
- return aclBody;
4192
- };
4193
-
4194
- /**
4195
- * set ACL
4196
- * @param keyDoc
4197
- * @param aclBody
4198
- */
4199
- function setAcl(_x3, _x4) {
4200
- return _setAcl.apply(this, arguments);
4201
- }
4202
- /**
4203
- * delete acl if keydoc exists
4204
- * create/edit keyDoc
4205
- * set keyDoc acl
4206
- */
4207
- function _setAcl() {
4208
- _setAcl = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(keyDoc, aclBody) {
4209
- var keyAclDoc, response, aclResponse;
4210
- return _regenerator["default"].wrap(function _callee3$(_context3) {
4211
- while (1) switch (_context3.prev = _context3.next) {
4212
- case 0:
4213
- _context3.next = 2;
4214
- return _solidLogic.store.fetcher.load(keyDoc);
4215
- case 2:
4216
- // FIXME: check the Why value on this quad:
4217
- debug.log(_solidLogic.store.statementsMatching(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl')));
4218
- keyAclDoc = _solidLogic.store.any(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl'));
4219
- if (keyAclDoc) {
4220
- _context3.next = 6;
4221
- break;
4222
- }
4223
- throw new Error('Key ACL doc not found!');
4224
- case 6:
4225
- _context3.prev = 6;
4226
- _context3.next = 9;
4227
- return _solidLogic.store.fetcher.webOperation('DELETE', keyAclDoc.value);
4228
- case 9:
4229
- response = _context3.sent;
4230
- // this may fail if webId is not an owner
4231
- debug.log('delete ' + keyAclDoc.value + ' ' + response.status); // should test 404 and 2xx
4232
- _context3.next = 18;
4233
- break;
4234
- case 13:
4235
- _context3.prev = 13;
4236
- _context3.t0 = _context3["catch"](6);
4237
- if (!(_context3.t0.response.status !== 404)) {
4238
- _context3.next = 17;
4239
- break;
4240
- }
4241
- throw new Error(_context3.t0);
4242
- case 17:
4243
- debug.log('delete ' + keyAclDoc.value + ' ' + _context3.t0.response.status); // should test 404 and 2xx
4244
- case 18:
4245
- _context3.next = 20;
4246
- return _solidLogic.store.fetcher.webOperation('PUT', keyAclDoc.value, {
4247
- data: aclBody,
4248
- contentType: 'text/turtle'
4249
- });
4250
- case 20:
4251
- aclResponse = _context3.sent;
4252
- case 21:
4253
- case "end":
4254
- return _context3.stop();
4255
- }
4256
- }, _callee3, null, [[6, 13]]);
4257
- }));
4258
- return _setAcl.apply(this, arguments);
4259
- }
4260
- function saveKey(_x5, _x6, _x7) {
4184
+ function saveKey(_x3, _x4, _x5) {
4261
4185
  return _saveKey.apply(this, arguments);
4262
4186
  }
4263
4187
  function _saveKey() {
4264
4188
  _saveKey = (0, _asyncToGenerator2["default"])(function (keyDoc, del, add) {
4265
4189
  var me = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
4266
- return /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
4190
+ return /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
4267
4191
  var keyAclDoc, response, aclBody;
4268
- return _regenerator["default"].wrap(function _callee4$(_context4) {
4269
- while (1) switch (_context4.prev = _context4.next) {
4192
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
4193
+ while (1) switch (_context3.prev = _context3.next) {
4270
4194
  case 0:
4271
- _context4.next = 2;
4195
+ _context3.next = 2;
4272
4196
  return _solidLogic.store.fetcher.load(keyDoc);
4273
4197
  case 2:
4274
- _context4.prev = 2;
4198
+ _context3.prev = 2;
4275
4199
  // get keyAcldoc
4276
4200
  keyAclDoc = _solidLogic.store.any(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl'));
4277
4201
  if (!keyAclDoc) {
4278
- _context4.next = 17;
4202
+ _context3.next = 17;
4279
4203
  break;
4280
4204
  }
4281
- _context4.prev = 5;
4282
- _context4.next = 8;
4205
+ _context3.prev = 5;
4206
+ _context3.next = 8;
4283
4207
  return _solidLogic.store.fetcher.webOperation('DELETE', keyAclDoc.value);
4284
4208
  case 8:
4285
- response = _context4.sent;
4209
+ response = _context3.sent;
4286
4210
  // this may fail if webId is not an owner
4287
4211
  debug.log('delete ' + keyAclDoc.value + ' ' + response.status); // should test 404 and 2xx
4288
- _context4.next = 17;
4212
+ _context3.next = 17;
4289
4213
  break;
4290
4214
  case 12:
4291
- _context4.prev = 12;
4292
- _context4.t0 = _context4["catch"](5);
4293
- if (!(_context4.t0.response.status !== 404)) {
4294
- _context4.next = 16;
4215
+ _context3.prev = 12;
4216
+ _context3.t0 = _context3["catch"](5);
4217
+ if (!(_context3.t0.response.status !== 404)) {
4218
+ _context3.next = 16;
4295
4219
  break;
4296
4220
  }
4297
- throw new Error(_context4.t0);
4221
+ throw new Error(_context3.t0);
4298
4222
  case 16:
4299
- debug.log('delete ' + keyAclDoc.value + ' ' + _context4.t0.response.status); // should test 404 and 2xx
4223
+ debug.log('delete ' + keyAclDoc.value + ' ' + _context3.t0.response.status); // should test 404 and 2xx
4300
4224
  case 17:
4301
- _context4.next = 19;
4225
+ _context3.next = 19;
4302
4226
  return _solidLogic.store.updater.updateMany(del, add);
4303
4227
  case 19:
4304
4228
  // or a promise store.updater.update ?
4305
4229
  // create READ only ACL
4306
- aclBody = keyAclBody(keyDoc, me);
4307
- _context4.next = 22;
4308
- return setAcl(keyDoc, aclBody);
4230
+ aclBody = (0, _acl.keyAclBody)(keyDoc, me);
4231
+ _context3.next = 22;
4232
+ return (0, _acl.setAcl)(keyDoc, aclBody);
4309
4233
  case 22:
4310
- _context4.next = 27;
4234
+ _context3.next = 27;
4311
4235
  break;
4312
4236
  case 24:
4313
- _context4.prev = 24;
4314
- _context4.t1 = _context4["catch"](2);
4315
- throw new Error(_context4.t1);
4237
+ _context3.prev = 24;
4238
+ _context3.t1 = _context3["catch"](2);
4239
+ throw new Error(_context3.t1);
4316
4240
  case 27:
4317
4241
  case "end":
4318
- return _context4.stop();
4242
+ return _context3.stop();
4319
4243
  }
4320
- }, _callee4, null, [[2, 24], [5, 12]]);
4244
+ }, _callee3, null, [[2, 24], [5, 12]]);
4321
4245
  })();
4322
4246
  });
4323
4247
  return _saveKey.apply(this, arguments);
@@ -4469,7 +4393,7 @@ function renderMessageRow(channelObject, message, fresh, options, userContext) {
4469
4393
 
4470
4394
  // signed message, get public key and check signature
4471
4395
  else {
4472
- (0, _keys.getPublicKey)(creator.uri).then(function (publicKey) {
4396
+ (0, _keys.getPublicKey)(creator).then(function (publicKey) {
4473
4397
  debug.log(creator.uri + '\n' + msg.created + '\n' + msg.id + '\n' + publicKey);
4474
4398
  if (!publicKey) {
4475
4399
  // TODO try to recreate the publicKey
@@ -5276,13 +5200,11 @@ Object.defineProperty(exports, "__esModule", ({
5276
5200
  value: true
5277
5201
  }));
5278
5202
  exports.SEC = exports.CERT = void 0;
5279
- exports.finishMsg = finishMsg;
5280
5203
  exports.getBlankMsg = getBlankMsg;
5281
5204
  exports.getMsgHash = getMsgHash;
5282
5205
  exports.serializeMsg = serializeMsg;
5283
5206
  exports.signMsg = signMsg;
5284
5207
  exports.utf8Encoder = exports.utf8Decoder = void 0;
5285
- exports.validateMsg = validateMsg;
5286
5208
  exports.verifySignature = verifySignature;
5287
5209
  var _secp256k = __webpack_require__(/*! @noble/curves/secp256k1 */ "./node_modules/@noble/curves/secp256k1.js");
5288
5210
  var _utils = __webpack_require__(/*! @noble/hashes/utils */ "./node_modules/@noble/hashes/utils.js");
@@ -5328,19 +5250,22 @@ function getBlankMsg() {
5328
5250
  id: '',
5329
5251
  created: '',
5330
5252
  dateDeleted: '',
5253
+ // TODO to remove if not used
5331
5254
  content: '',
5332
5255
  maker: '',
5333
- sig: ''
5256
+ sig: '' // TODO to remove if not used
5334
5257
  };
5335
5258
  }
5336
- function finishMsg(t, privateKey) {
5337
- // to update to chat message triples
5338
- var message = t;
5339
- // message.pubkey = getPublicKey(privateKey)
5340
- message.id = getMsgHash(message);
5341
- message.sig = signMsg(message, privateKey);
5342
- return message;
5343
- }
5259
+
5260
+ /* export function finishMsg (t: MsgTemplate, privateKey: string): Message {
5261
+ // to update to chat message triples
5262
+ const message = t as Message
5263
+ // message.pubkey = getPublicKey(privateKey)
5264
+ message.id = getMsgHash(message)
5265
+ message.sig = signMsg(message, privateKey)
5266
+ return message
5267
+ } */
5268
+
5344
5269
  function serializeMsg(msg) {
5345
5270
  // to update to chat messages triples
5346
5271
  /* if (!validateMsg(msg))
@@ -5352,27 +5277,29 @@ function getMsgHash(message) {
5352
5277
  var msgHash = (0, _sha.sha256)(utf8Encoder.encode(serializeMsg(message)));
5353
5278
  return (0, _utils.bytesToHex)(msgHash);
5354
5279
  }
5355
- var isRecord = function isRecord(obj) {
5356
- return obj instanceof Object;
5357
- };
5358
- function validateMsg(message) {
5359
- /* if (!isRecord(message)) return false
5280
+
5281
+ // const isRecord = (obj: unknown): obj is Record<string, unknown> => obj instanceof Object
5282
+
5283
+ /* export function validateMsg<T> (message: T): message is T & UnsignedMsg {
5284
+ if (!isRecord(message)) return false
5360
5285
  if (typeof message.kind !== 'number') return false
5361
5286
  if (typeof message.content !== 'string') return false
5362
5287
  if (typeof message.created_at !== 'number') return false
5363
5288
  if (typeof message.pubkey !== 'string') return false
5364
5289
  if (!message.pubkey.match(/^[a-f0-9]{64}$/)) return false
5365
- if (!Array.isArray(message.tags)) return false
5290
+
5291
+ if (!Array.isArray(message.tags)) return false
5366
5292
  for (let i = 0; i < message.tags.length; i++) {
5367
5293
  let tag = message.tags[i]
5368
5294
  if (!Array.isArray(tag)) return false
5369
5295
  for (let j = 0; j < tag.length; j++) {
5370
5296
  if (typeof tag[j] === 'object') return false
5371
5297
  }
5372
- } */
5298
+ }
5299
+
5300
+ return true
5301
+ } */
5373
5302
 
5374
- return true;
5375
- }
5376
5303
  function verifySignature(sig, message, pubKey) {
5377
5304
  return _secp256k.schnorr.verify(sig, getMsgHash(message), pubKey);
5378
5305
  }
@@ -12583,251 +12510,6 @@ function isLight(x) {
12583
12510
 
12584
12511
  /***/ }),
12585
12512
 
12586
- /***/ "./lib/utils/cryptoKeyHelpers.js":
12587
- /*!***************************************!*\
12588
- !*** ./lib/utils/cryptoKeyHelpers.js ***!
12589
- \***************************************/
12590
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
12591
-
12592
- "use strict";
12593
-
12594
-
12595
- var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");
12596
- var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
12597
- Object.defineProperty(exports, "__esModule", ({
12598
- value: true
12599
- }));
12600
- exports.privKeyUrl = void 0;
12601
- exports.privateKeyExists = privateKeyExists;
12602
- exports.pubKeyUrl = void 0;
12603
- exports.publicKeyExists = publicKeyExists;
12604
- var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
12605
- var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
12606
- var debug = _interopRequireWildcard(__webpack_require__(/*! ../debug */ "./lib/debug.js"));
12607
- var _signature = __webpack_require__(/*! ../chat/signature */ "./lib/chat/signature.js");
12608
- var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
12609
- var ns = _interopRequireWildcard(__webpack_require__(/*! ../ns */ "./lib/ns.js"));
12610
- 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); }
12611
- 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; }
12612
- var getPodRoot = /*#__PURE__*/function () {
12613
- var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
12614
- var _podRoot;
12615
- var webIdURL, storages, podRoot, path, _res$headers$get, res;
12616
- return _regenerator["default"].wrap(function _callee$(_context) {
12617
- while (1) switch (_context.prev = _context.next) {
12618
- case 0:
12619
- webIdURL = new URL(webId.uri); // find storages in webId document
12620
- _context.next = 3;
12621
- return _solidLogic.store.fetcher.load(webId.uri);
12622
- case 3:
12623
- storages = _solidLogic.store.each(webId, ns.space('storage'), null, webId.doc());
12624
- if (storages !== null && storages !== void 0 && storages.length) {
12625
- _context.next = 19;
12626
- break;
12627
- }
12628
- // find storage recursively in webId URL
12629
- path = webIdURL.pathname;
12630
- case 6:
12631
- if (!path.length) {
12632
- _context.next = 17;
12633
- break;
12634
- }
12635
- path = path.substring(0, path.lastIndexOf('/'));
12636
- podRoot = _solidLogic.store.sym(webIdURL.origin + path + '/');
12637
- _context.next = 11;
12638
- return _solidLogic.store.fetcher.webOperation('HEAD', podRoot.uri);
12639
- case 11:
12640
- res = _context.sent;
12641
- if (!((_res$headers$get = res.headers.get('link')) !== null && _res$headers$get !== void 0 && _res$headers$get.includes(ns.space('Storage').value))) {
12642
- _context.next = 14;
12643
- break;
12644
- }
12645
- return _context.abrupt("break", 17);
12646
- case 14:
12647
- if (!path) debug.warn("Current user storage not found for\n".concat(webId));
12648
- _context.next = 6;
12649
- break;
12650
- case 17:
12651
- _context.next = 21;
12652
- break;
12653
- case 19:
12654
- // give preference to storage in webId root
12655
- podRoot = storages.find(function (storage) {
12656
- return webIdURL.origin === new URL(storage.value).origin;
12657
- });
12658
- if (!podRoot) podRoot = storages[0];
12659
- case 21:
12660
- return _context.abrupt("return", (_podRoot = podRoot) === null || _podRoot === void 0 ? void 0 : _podRoot.value);
12661
- case 22:
12662
- case "end":
12663
- return _context.stop();
12664
- }
12665
- }, _callee);
12666
- }));
12667
- return function getPodRoot(_x) {
12668
- return _ref.apply(this, arguments);
12669
- };
12670
- }();
12671
- var pubKeyUrl = /*#__PURE__*/function () {
12672
- var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
12673
- return _regenerator["default"].wrap(function _callee2$(_context2) {
12674
- while (1) switch (_context2.prev = _context2.next) {
12675
- case 0:
12676
- _context2.prev = 0;
12677
- _context2.next = 3;
12678
- return getPodRoot(webId);
12679
- case 3:
12680
- _context2.t0 = _context2.sent;
12681
- return _context2.abrupt("return", _context2.t0 + 'profile/keys/publicKey.ttl');
12682
- case 7:
12683
- _context2.prev = 7;
12684
- _context2.t1 = _context2["catch"](0);
12685
- throw new Error(_context2.t1);
12686
- case 10:
12687
- case "end":
12688
- return _context2.stop();
12689
- }
12690
- }, _callee2, null, [[0, 7]]);
12691
- }));
12692
- return function pubKeyUrl(_x2) {
12693
- return _ref2.apply(this, arguments);
12694
- };
12695
- }();
12696
- exports.pubKeyUrl = pubKeyUrl;
12697
- function publicKeyExists(_x3) {
12698
- return _publicKeyExists.apply(this, arguments);
12699
- }
12700
- function _publicKeyExists() {
12701
- _publicKeyExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(webId) {
12702
- var publicKeyUrl;
12703
- return _regenerator["default"].wrap(function _callee4$(_context4) {
12704
- while (1) switch (_context4.prev = _context4.next) {
12705
- case 0:
12706
- _context4.next = 2;
12707
- return pubKeyUrl(webId);
12708
- case 2:
12709
- publicKeyUrl = _context4.sent;
12710
- _context4.next = 5;
12711
- return keyExists(webId, publicKeyUrl, 'PublicKey');
12712
- case 5:
12713
- return _context4.abrupt("return", _context4.sent);
12714
- case 6:
12715
- case "end":
12716
- return _context4.stop();
12717
- }
12718
- }, _callee4);
12719
- }));
12720
- return _publicKeyExists.apply(this, arguments);
12721
- }
12722
- var privKeyUrl = /*#__PURE__*/function () {
12723
- var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId) {
12724
- return _regenerator["default"].wrap(function _callee3$(_context3) {
12725
- while (1) switch (_context3.prev = _context3.next) {
12726
- case 0:
12727
- _context3.prev = 0;
12728
- _context3.next = 3;
12729
- return getPodRoot(webId);
12730
- case 3:
12731
- _context3.t0 = _context3.sent;
12732
- return _context3.abrupt("return", _context3.t0 + 'profile/keys/privateKey.ttl');
12733
- case 7:
12734
- _context3.prev = 7;
12735
- _context3.t1 = _context3["catch"](0);
12736
- throw new Error(_context3.t1);
12737
- case 10:
12738
- case "end":
12739
- return _context3.stop();
12740
- }
12741
- }, _callee3, null, [[0, 7]]);
12742
- }));
12743
- return function privKeyUrl(_x4) {
12744
- return _ref3.apply(this, arguments);
12745
- };
12746
- }();
12747
- exports.privKeyUrl = privKeyUrl;
12748
- function privateKeyExists(_x5) {
12749
- return _privateKeyExists.apply(this, arguments);
12750
- }
12751
- function _privateKeyExists() {
12752
- _privateKeyExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(webId) {
12753
- var privateKeyUrl;
12754
- return _regenerator["default"].wrap(function _callee5$(_context5) {
12755
- while (1) switch (_context5.prev = _context5.next) {
12756
- case 0:
12757
- _context5.next = 2;
12758
- return privKeyUrl(webId);
12759
- case 2:
12760
- privateKeyUrl = _context5.sent;
12761
- _context5.next = 5;
12762
- return keyExists(webId, privateKeyUrl, 'PrivateKey');
12763
- case 5:
12764
- return _context5.abrupt("return", _context5.sent);
12765
- case 6:
12766
- case "end":
12767
- return _context5.stop();
12768
- }
12769
- }, _callee5);
12770
- }));
12771
- return _privateKeyExists.apply(this, arguments);
12772
- }
12773
- function keyExists(_x6, _x7, _x8) {
12774
- return _keyExists.apply(this, arguments);
12775
- }
12776
- function _keyExists() {
12777
- _keyExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(webId, keyUrl, keyType) {
12778
- var key, _err$response, data, contentType, response;
12779
- return _regenerator["default"].wrap(function _callee6$(_context6) {
12780
- while (1) switch (_context6.prev = _context6.next) {
12781
- case 0:
12782
- _context6.prev = 0;
12783
- _context6.next = 3;
12784
- return _solidLogic.store.fetcher.load(keyUrl);
12785
- case 3:
12786
- key = _solidLogic.store.any(webId, _solidLogic.store.sym(_signature.CERT + keyType));
12787
- return _context6.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
12788
- case 7:
12789
- _context6.prev = 7;
12790
- _context6.t0 = _context6["catch"](0);
12791
- 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)) {
12792
- _context6.next = 24;
12793
- break;
12794
- }
12795
- _context6.prev = 10;
12796
- // create privateKey resource
12797
- data = '';
12798
- contentType = 'text/turtle';
12799
- _context6.next = 15;
12800
- return _solidLogic.store.fetcher.webOperation('PUT', keyUrl, {
12801
- data: data,
12802
- contentType: contentType
12803
- });
12804
- case 15:
12805
- response = _context6.sent;
12806
- _context6.next = 22;
12807
- break;
12808
- case 18:
12809
- _context6.prev = 18;
12810
- _context6.t1 = _context6["catch"](10);
12811
- debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context6.t1);
12812
- throw _context6.t1;
12813
- case 22:
12814
- delete _solidLogic.store.fetcher.requested[keyUrl]; // delete cached 404 error
12815
- return _context6.abrupt("return", undefined);
12816
- case 24:
12817
- debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context6.t0);
12818
- throw _context6.t0;
12819
- case 26:
12820
- case "end":
12821
- return _context6.stop();
12822
- }
12823
- }, _callee6, null, [[0, 7], [10, 18]]);
12824
- }));
12825
- return _keyExists.apply(this, arguments);
12826
- }
12827
- //# sourceMappingURL=cryptoKeyHelpers.js.map
12828
-
12829
- /***/ }),
12830
-
12831
12513
  /***/ "./lib/utils/headerFooterHelpers.js":
12832
12514
  /*!******************************************!*\
12833
12515
  !*** ./lib/utils/headerFooterHelpers.js ***!
@@ -13546,6 +13228,353 @@ function predParentOf(node) {
13546
13228
 
13547
13229
  /***/ }),
13548
13230
 
13231
+ /***/ "./lib/utils/keyHelpers/accessData.js":
13232
+ /*!********************************************!*\
13233
+ !*** ./lib/utils/keyHelpers/accessData.js ***!
13234
+ \********************************************/
13235
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
13236
+
13237
+ "use strict";
13238
+
13239
+
13240
+ var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");
13241
+ var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
13242
+ Object.defineProperty(exports, "__esModule", ({
13243
+ value: true
13244
+ }));
13245
+ exports.getExistingPrivateKey = getExistingPrivateKey;
13246
+ exports.getExistingPublicKey = getExistingPublicKey;
13247
+ exports.getKeyIfExists = getKeyIfExists;
13248
+ exports.pubKeyUrl = exports.privKeyUrl = exports.getPodRoot = void 0;
13249
+ var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
13250
+ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
13251
+ var debug = _interopRequireWildcard(__webpack_require__(/*! ../../debug */ "./lib/debug.js"));
13252
+ var _signature = __webpack_require__(/*! ../../chat/signature */ "./lib/chat/signature.js");
13253
+ var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
13254
+ var ns = _interopRequireWildcard(__webpack_require__(/*! ../../ns */ "./lib/ns.js"));
13255
+ 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); }
13256
+ 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; }
13257
+ var getPodRoot = /*#__PURE__*/function () {
13258
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
13259
+ var _podRoot;
13260
+ var webIdURL, storages, podRoot, path, _res$headers$get, res;
13261
+ return _regenerator["default"].wrap(function _callee$(_context) {
13262
+ while (1) switch (_context.prev = _context.next) {
13263
+ case 0:
13264
+ webIdURL = new URL(webId.uri); // find storages in webId document
13265
+ _context.next = 3;
13266
+ return _solidLogic.store.fetcher.load(webId.uri);
13267
+ case 3:
13268
+ storages = _solidLogic.store.each(webId, ns.space('storage'), null, webId.doc());
13269
+ if (storages !== null && storages !== void 0 && storages.length) {
13270
+ _context.next = 19;
13271
+ break;
13272
+ }
13273
+ // find storage recursively in webId URL
13274
+ path = webIdURL.pathname;
13275
+ case 6:
13276
+ if (!path.length) {
13277
+ _context.next = 17;
13278
+ break;
13279
+ }
13280
+ path = path.substring(0, path.lastIndexOf('/'));
13281
+ podRoot = _solidLogic.store.sym(webIdURL.origin + path + '/');
13282
+ _context.next = 11;
13283
+ return _solidLogic.store.fetcher.webOperation('HEAD', podRoot.uri);
13284
+ case 11:
13285
+ res = _context.sent;
13286
+ if (!((_res$headers$get = res.headers.get('link')) !== null && _res$headers$get !== void 0 && _res$headers$get.includes(ns.space('Storage').value))) {
13287
+ _context.next = 14;
13288
+ break;
13289
+ }
13290
+ return _context.abrupt("break", 17);
13291
+ case 14:
13292
+ if (!path) debug.warn("Current user storage not found for\n".concat(webId));
13293
+ _context.next = 6;
13294
+ break;
13295
+ case 17:
13296
+ _context.next = 21;
13297
+ break;
13298
+ case 19:
13299
+ // give preference to storage in webId root
13300
+ podRoot = storages.find(function (storage) {
13301
+ return webIdURL.origin === new URL(storage.value).origin;
13302
+ });
13303
+ if (!podRoot) podRoot = storages[0];
13304
+ case 21:
13305
+ return _context.abrupt("return", (_podRoot = podRoot) === null || _podRoot === void 0 ? void 0 : _podRoot.value);
13306
+ case 22:
13307
+ case "end":
13308
+ return _context.stop();
13309
+ }
13310
+ }, _callee);
13311
+ }));
13312
+ return function getPodRoot(_x) {
13313
+ return _ref.apply(this, arguments);
13314
+ };
13315
+ }();
13316
+ exports.getPodRoot = getPodRoot;
13317
+ var pubKeyUrl = /*#__PURE__*/function () {
13318
+ var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
13319
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
13320
+ while (1) switch (_context2.prev = _context2.next) {
13321
+ case 0:
13322
+ _context2.prev = 0;
13323
+ _context2.next = 3;
13324
+ return getPodRoot(webId);
13325
+ case 3:
13326
+ _context2.t0 = _context2.sent;
13327
+ return _context2.abrupt("return", _context2.t0 + 'profile/keys/publicKey.ttl');
13328
+ case 7:
13329
+ _context2.prev = 7;
13330
+ _context2.t1 = _context2["catch"](0);
13331
+ throw new Error(_context2.t1);
13332
+ case 10:
13333
+ case "end":
13334
+ return _context2.stop();
13335
+ }
13336
+ }, _callee2, null, [[0, 7]]);
13337
+ }));
13338
+ return function pubKeyUrl(_x2) {
13339
+ return _ref2.apply(this, arguments);
13340
+ };
13341
+ }();
13342
+ exports.pubKeyUrl = pubKeyUrl;
13343
+ function getExistingPublicKey(_x3, _x4) {
13344
+ return _getExistingPublicKey.apply(this, arguments);
13345
+ }
13346
+ function _getExistingPublicKey() {
13347
+ _getExistingPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(webId, publicKeyUrl) {
13348
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
13349
+ while (1) switch (_context4.prev = _context4.next) {
13350
+ case 0:
13351
+ _context4.next = 2;
13352
+ return getKeyIfExists(webId, publicKeyUrl, 'PublicKey');
13353
+ case 2:
13354
+ return _context4.abrupt("return", _context4.sent);
13355
+ case 3:
13356
+ case "end":
13357
+ return _context4.stop();
13358
+ }
13359
+ }, _callee4);
13360
+ }));
13361
+ return _getExistingPublicKey.apply(this, arguments);
13362
+ }
13363
+ var privKeyUrl = /*#__PURE__*/function () {
13364
+ var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId) {
13365
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
13366
+ while (1) switch (_context3.prev = _context3.next) {
13367
+ case 0:
13368
+ _context3.prev = 0;
13369
+ _context3.next = 3;
13370
+ return getPodRoot(webId);
13371
+ case 3:
13372
+ _context3.t0 = _context3.sent;
13373
+ return _context3.abrupt("return", _context3.t0 + 'profile/keys/privateKey.ttl');
13374
+ case 7:
13375
+ _context3.prev = 7;
13376
+ _context3.t1 = _context3["catch"](0);
13377
+ throw new Error(_context3.t1);
13378
+ case 10:
13379
+ case "end":
13380
+ return _context3.stop();
13381
+ }
13382
+ }, _callee3, null, [[0, 7]]);
13383
+ }));
13384
+ return function privKeyUrl(_x5) {
13385
+ return _ref3.apply(this, arguments);
13386
+ };
13387
+ }();
13388
+ exports.privKeyUrl = privKeyUrl;
13389
+ function getExistingPrivateKey(_x6, _x7) {
13390
+ return _getExistingPrivateKey.apply(this, arguments);
13391
+ }
13392
+ function _getExistingPrivateKey() {
13393
+ _getExistingPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(webId, privateKeyUrl) {
13394
+ return _regenerator["default"].wrap(function _callee5$(_context5) {
13395
+ while (1) switch (_context5.prev = _context5.next) {
13396
+ case 0:
13397
+ _context5.next = 2;
13398
+ return getKeyIfExists(webId, privateKeyUrl, 'PrivateKey');
13399
+ case 2:
13400
+ return _context5.abrupt("return", _context5.sent);
13401
+ case 3:
13402
+ case "end":
13403
+ return _context5.stop();
13404
+ }
13405
+ }, _callee5);
13406
+ }));
13407
+ return _getExistingPrivateKey.apply(this, arguments);
13408
+ }
13409
+ function getKeyIfExists(_x8, _x9, _x10) {
13410
+ return _getKeyIfExists.apply(this, arguments);
13411
+ }
13412
+ function _getKeyIfExists() {
13413
+ _getKeyIfExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(webId, keyUrl, keyType) {
13414
+ var key, _err$response, data, contentType, response;
13415
+ return _regenerator["default"].wrap(function _callee6$(_context6) {
13416
+ while (1) switch (_context6.prev = _context6.next) {
13417
+ case 0:
13418
+ _context6.prev = 0;
13419
+ _context6.next = 3;
13420
+ return _solidLogic.store.fetcher.load(keyUrl);
13421
+ case 3:
13422
+ key = _solidLogic.store.any(webId, _solidLogic.store.sym(_signature.CERT + keyType));
13423
+ return _context6.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
13424
+ case 7:
13425
+ _context6.prev = 7;
13426
+ _context6.t0 = _context6["catch"](0);
13427
+ 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)) {
13428
+ _context6.next = 24;
13429
+ break;
13430
+ }
13431
+ _context6.prev = 10;
13432
+ // create resource
13433
+ data = '';
13434
+ contentType = 'text/turtle';
13435
+ _context6.next = 15;
13436
+ return _solidLogic.store.fetcher.webOperation('PUT', keyUrl, {
13437
+ data: data,
13438
+ contentType: contentType
13439
+ });
13440
+ case 15:
13441
+ response = _context6.sent;
13442
+ _context6.next = 22;
13443
+ break;
13444
+ case 18:
13445
+ _context6.prev = 18;
13446
+ _context6.t1 = _context6["catch"](10);
13447
+ debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context6.t1);
13448
+ throw _context6.t1;
13449
+ case 22:
13450
+ delete _solidLogic.store.fetcher.requested[keyUrl]; // delete cached 404 error
13451
+ return _context6.abrupt("return", undefined);
13452
+ case 24:
13453
+ debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context6.t0);
13454
+ throw _context6.t0;
13455
+ case 26:
13456
+ case "end":
13457
+ return _context6.stop();
13458
+ }
13459
+ }, _callee6, null, [[0, 7], [10, 18]]);
13460
+ }));
13461
+ return _getKeyIfExists.apply(this, arguments);
13462
+ }
13463
+ //# sourceMappingURL=accessData.js.map
13464
+
13465
+ /***/ }),
13466
+
13467
+ /***/ "./lib/utils/keyHelpers/acl.js":
13468
+ /*!*************************************!*\
13469
+ !*** ./lib/utils/keyHelpers/acl.js ***!
13470
+ \*************************************/
13471
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
13472
+
13473
+ "use strict";
13474
+
13475
+
13476
+ var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");
13477
+ var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
13478
+ Object.defineProperty(exports, "__esModule", ({
13479
+ value: true
13480
+ }));
13481
+ exports.keyContainerAclBody = exports.keyAclBody = void 0;
13482
+ exports.setAcl = setAcl;
13483
+ var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
13484
+ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
13485
+ var debug = _interopRequireWildcard(__webpack_require__(/*! ../../debug */ "./lib/debug.js"));
13486
+ var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
13487
+ 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); }
13488
+ 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; }
13489
+ /**
13490
+ * set ACL
13491
+ * @param keyDoc
13492
+ * @param aclBody
13493
+ */
13494
+ function setAcl(_x, _x2) {
13495
+ return _setAcl.apply(this, arguments);
13496
+ }
13497
+ /**
13498
+ * key container ACL
13499
+ * @param me
13500
+ * @returns aclBody
13501
+ */
13502
+ function _setAcl() {
13503
+ _setAcl = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(keyDoc, aclBody) {
13504
+ var keyAclDoc, response, aclResponse;
13505
+ return _regenerator["default"].wrap(function _callee$(_context) {
13506
+ while (1) switch (_context.prev = _context.next) {
13507
+ case 0:
13508
+ _context.next = 2;
13509
+ return _solidLogic.store.fetcher.load(keyDoc);
13510
+ case 2:
13511
+ // FIXME: check the Why value on this quad:
13512
+ debug.log(_solidLogic.store.statementsMatching(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl')));
13513
+ keyAclDoc = _solidLogic.store.any(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl'));
13514
+ if (keyAclDoc) {
13515
+ _context.next = 6;
13516
+ break;
13517
+ }
13518
+ throw new Error('Key ACL doc not found!');
13519
+ case 6:
13520
+ _context.prev = 6;
13521
+ _context.next = 9;
13522
+ return _solidLogic.store.fetcher.webOperation('DELETE', keyAclDoc.value);
13523
+ case 9:
13524
+ response = _context.sent;
13525
+ // this may fail if webId is not an owner
13526
+ debug.log('delete ' + keyAclDoc.value + ' ' + response.status); // should test 404 and 2xx
13527
+ _context.next = 18;
13528
+ break;
13529
+ case 13:
13530
+ _context.prev = 13;
13531
+ _context.t0 = _context["catch"](6);
13532
+ if (!(_context.t0.response.status !== 404)) {
13533
+ _context.next = 17;
13534
+ break;
13535
+ }
13536
+ throw new Error(_context.t0);
13537
+ case 17:
13538
+ debug.log('delete ' + keyAclDoc.value + ' ' + _context.t0.response.status); // should test 404 and 2xx
13539
+ case 18:
13540
+ _context.next = 20;
13541
+ return _solidLogic.store.fetcher.webOperation('PUT', keyAclDoc.value, {
13542
+ data: aclBody,
13543
+ contentType: 'text/turtle'
13544
+ });
13545
+ case 20:
13546
+ aclResponse = _context.sent;
13547
+ case 21:
13548
+ case "end":
13549
+ return _context.stop();
13550
+ }
13551
+ }, _callee, null, [[6, 13]]);
13552
+ }));
13553
+ return _setAcl.apply(this, arguments);
13554
+ }
13555
+ var keyContainerAclBody = function keyContainerAclBody(me) {
13556
+ 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");
13557
+ return aclBody;
13558
+ };
13559
+
13560
+ /**
13561
+ * Read only ACL
13562
+ * @param keyDoc
13563
+ * @param me
13564
+ * @returns aclBody
13565
+ */
13566
+ exports.keyContainerAclBody = keyContainerAclBody;
13567
+ var keyAclBody = function keyAclBody(keyDoc, me) {
13568
+ var keyAgent = 'acl:agentClass foaf:Agent'; // publicKey
13569
+ if (me !== null && me !== void 0 && me.length) keyAgent = "acl:agent <".concat(me, ">"); // privateKey
13570
+ 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");
13571
+ return aclBody;
13572
+ };
13573
+ exports.keyAclBody = keyAclBody;
13574
+ //# sourceMappingURL=acl.js.map
13575
+
13576
+ /***/ }),
13577
+
13549
13578
  /***/ "./lib/utils/label.js":
13550
13579
  /*!****************************!*\
13551
13580
  !*** ./lib/utils/label.js ***!
@@ -13674,8 +13703,8 @@ Object.defineProperty(exports, "__esModule", ({
13674
13703
  }));
13675
13704
  exports.versionInfo = void 0;
13676
13705
  var versionInfo = {
13677
- buildTime: '2023-05-06T06:21:01Z',
13678
- commit: 'beea007ff69c8a17227ed08d9a5bb664122f29eb',
13706
+ buildTime: '2023-05-10T20:39:20Z',
13707
+ commit: 'c0cda1b3873b1ece193952d9713a8c8cab353b72',
13679
13708
  npmInfo: {
13680
13709
  'solid-ui': '2.4.27',
13681
13710
  npm: '8.19.4',
@@ -66491,22 +66520,7 @@ module.exports = JSON.parse('{"application/1d-interleaved-parityfec":{"source":"
66491
66520
  /******/
66492
66521
  /******/ /* webpack/runtime/publicPath */
66493
66522
  /******/ (() => {
66494
- /******/ var scriptUrl;
66495
- /******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
66496
- /******/ var document = __webpack_require__.g.document;
66497
- /******/ if (!scriptUrl && document) {
66498
- /******/ if (document.currentScript)
66499
- /******/ scriptUrl = document.currentScript.src;
66500
- /******/ if (!scriptUrl) {
66501
- /******/ var scripts = document.getElementsByTagName("script");
66502
- /******/ if(scripts.length) scriptUrl = scripts[scripts.length - 1].src
66503
- /******/ }
66504
- /******/ }
66505
- /******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
66506
- /******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
66507
- /******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
66508
- /******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
66509
- /******/ __webpack_require__.p = scriptUrl;
66523
+ /******/ __webpack_require__.p = "";
66510
66524
  /******/ })();
66511
66525
  /******/
66512
66526
  /******/ /* webpack/runtime/jsonp chunk loading */