solid-ui 2.4.28-df3d9431 → 2.4.28-e581c53c

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
@@ -4415,13 +4415,10 @@ var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_m
4415
4415
  Object.defineProperty(exports, "__esModule", ({
4416
4416
  value: true
4417
4417
  }));
4418
- exports.createAndSaveKeyPairs = createAndSaveKeyPairs;
4419
- exports.generateAndStoreNewPublicKey = generateAndStoreNewPublicKey;
4420
4418
  exports.generatePrivateKey = generatePrivateKey;
4421
4419
  exports.generatePublicKey = generatePublicKey;
4422
4420
  exports.getPrivateKey = getPrivateKey;
4423
4421
  exports.getPublicKey = getPublicKey;
4424
- exports.validPublicKey = validPublicKey;
4425
4422
  var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
4426
4423
  var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
4427
4424
  var debug = _interopRequireWildcard(__webpack_require__(/*! ../debug */ "./lib/debug.js"));
@@ -4457,150 +4454,109 @@ function _getPublicKey() {
4457
4454
  return _regenerator["default"].wrap(function _callee2$(_context2) {
4458
4455
  while (1) switch (_context2.prev = _context2.next) {
4459
4456
  case 0:
4460
- _context2.prev = 0;
4461
- _context2.next = 3;
4457
+ _context2.next = 2;
4462
4458
  return _solidLogic.store.fetcher.load(webId);
4463
- case 3:
4464
- _context2.next = 5;
4459
+ case 2:
4460
+ _context2.next = 4;
4465
4461
  return (0, _accessData.pubKeyUrl)(webId);
4466
- case 5:
4462
+ case 4:
4467
4463
  publicKeyDoc = _context2.sent;
4468
- _context2.prev = 6;
4469
- _context2.next = 9;
4464
+ _context2.prev = 5;
4465
+ _context2.next = 8;
4470
4466
  return _solidLogic.store.fetcher.load(publicKeyDoc);
4471
- case 9:
4467
+ case 8:
4472
4468
  // url.href)
4473
4469
  key = _solidLogic.store.any(webId, ns.solid('publicKey'));
4474
4470
  return _context2.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
4475
- case 13:
4476
- _context2.prev = 13;
4477
- _context2.t0 = _context2["catch"](6);
4478
- debug.error(_context2.t0);
4479
- return _context2.abrupt("return", undefined);
4480
- case 17:
4481
- _context2.next = 23;
4482
- break;
4483
- case 19:
4484
- _context2.prev = 19;
4485
- _context2.t1 = _context2["catch"](0);
4486
- debug.error(_context2.t1);
4471
+ case 12:
4472
+ _context2.prev = 12;
4473
+ _context2.t0 = _context2["catch"](5);
4487
4474
  return _context2.abrupt("return", undefined);
4488
- case 23:
4475
+ case 15:
4489
4476
  case "end":
4490
4477
  return _context2.stop();
4491
4478
  }
4492
- }, _callee2, null, [[0, 19], [6, 13]]);
4479
+ }, _callee2, null, [[5, 12]]);
4493
4480
  }));
4494
4481
  return _getPublicKey.apply(this, arguments);
4495
4482
  }
4496
- function validPublicKey(webId, publicKey, privateKey) {
4497
- if (privateKey && publicKey !== generatePublicKey(privateKey)) {
4498
- 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 ?')) return false;
4499
- }
4500
- return true;
4501
- }
4502
- function generateAndStoreNewPublicKey(_x2, _x3, _x4, _x5) {
4503
- return _generateAndStoreNewPublicKey.apply(this, arguments);
4504
- }
4505
- function _generateAndStoreNewPublicKey() {
4506
- _generateAndStoreNewPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId, privateKey, publicKey, publicKeyDoc) {
4507
- var del, newPublicKey, add;
4508
- return _regenerator["default"].wrap(function _callee3$(_context3) {
4509
- while (1) switch (_context3.prev = _context3.next) {
4510
- case 0:
4511
- del = [$rdf.st(webId, ns.solid('publicKey'), $rdf.lit(publicKey || ''), _solidLogic.store.sym(publicKeyDoc))];
4512
- newPublicKey = generatePublicKey(privateKey);
4513
- add = [$rdf.st(webId, ns.solid('publicKey'), $rdf.literal(newPublicKey), _solidLogic.store.sym(publicKeyDoc))];
4514
- _context3.next = 5;
4515
- return saveKeyAndHandleAcl(publicKeyDoc, del, add);
4516
- case 5:
4517
- case "end":
4518
- return _context3.stop();
4519
- }
4520
- }, _callee3);
4521
- }));
4522
- return _generateAndStoreNewPublicKey.apply(this, arguments);
4523
- }
4524
- function createAndSaveKeyPairs(_x6, _x7, _x8, _x9) {
4525
- return _createAndSaveKeyPairs.apply(this, arguments);
4526
- }
4527
- function _createAndSaveKeyPairs() {
4528
- _createAndSaveKeyPairs = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(webId, publicKey, privateKeyDoc, publicKeyDoc) {
4529
- var privateKey, add;
4530
- return _regenerator["default"].wrap(function _callee4$(_context4) {
4531
- while (1) switch (_context4.prev = _context4.next) {
4532
- case 0:
4533
- privateKey = generatePrivateKey();
4534
- add = [$rdf.st(webId, ns.solid('privateKey'), $rdf.literal(privateKey), _solidLogic.store.sym(privateKeyDoc))];
4535
- _context4.next = 4;
4536
- return saveKeyAndHandleAcl(privateKeyDoc, [], add, webId.uri);
4537
- case 4:
4538
- _context4.next = 6;
4539
- return generateAndStoreNewPublicKey(webId, privateKey, publicKey, publicKeyDoc);
4540
- case 6:
4541
- return _context4.abrupt("return", privateKey);
4542
- case 7:
4543
- case "end":
4544
- return _context4.stop();
4545
- }
4546
- }, _callee4);
4547
- }));
4548
- return _createAndSaveKeyPairs.apply(this, arguments);
4549
- }
4550
- function getPrivateKey(_x10) {
4483
+ function getPrivateKey(_x2) {
4551
4484
  return _getPrivateKey.apply(this, arguments);
4552
4485
  }
4553
4486
  function _getPrivateKey() {
4554
- _getPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(webId) {
4555
- var publicKeyDoc, privateKeyDoc, publicKey, privateKey, keyContainer;
4556
- return _regenerator["default"].wrap(function _callee5$(_context5) {
4557
- while (1) switch (_context5.prev = _context5.next) {
4487
+ _getPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId) {
4488
+ var publicKeyDoc, privateKeyDoc, publicKey, privateKey, validPublicKey, del, add, newPublicKey, keyContainer;
4489
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
4490
+ while (1) switch (_context3.prev = _context3.next) {
4558
4491
  case 0:
4559
- _context5.next = 2;
4492
+ _context3.next = 2;
4560
4493
  return _solidLogic.store.fetcher.load(webId);
4561
4494
  case 2:
4562
- _context5.next = 4;
4495
+ _context3.next = 4;
4563
4496
  return (0, _accessData.pubKeyUrl)(webId);
4564
4497
  case 4:
4565
- publicKeyDoc = _context5.sent;
4566
- _context5.next = 7;
4498
+ publicKeyDoc = _context3.sent;
4499
+ _context3.next = 7;
4567
4500
  return (0, _accessData.privKeyUrl)(webId);
4568
4501
  case 7:
4569
- privateKeyDoc = _context5.sent;
4570
- _context5.next = 10;
4502
+ privateKeyDoc = _context3.sent;
4503
+ _context3.next = 10;
4571
4504
  return (0, _accessData.getExistingPublicKey)(webId, publicKeyDoc);
4572
4505
  case 10:
4573
- publicKey = _context5.sent;
4574
- _context5.next = 13;
4506
+ publicKey = _context3.sent;
4507
+ _context3.next = 13;
4575
4508
  return (0, _accessData.getExistingPrivateKey)(webId, privateKeyDoc);
4576
4509
  case 13:
4577
- privateKey = _context5.sent;
4510
+ privateKey = _context3.sent;
4511
+ // is publicKey valid ?
4512
+ validPublicKey = true;
4513
+ if (privateKey && publicKey !== generatePublicKey(privateKey)) {
4514
+ 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;
4515
+ }
4516
+
4517
+ // create key pair or repair publicKey
4518
+ if (!(!privateKey || !publicKey || !validPublicKey)) {
4519
+ _context3.next = 34;
4520
+ break;
4521
+ }
4522
+ del = [];
4523
+ add = [];
4578
4524
  if (privateKey) {
4579
- _context5.next = 18;
4525
+ _context3.next = 24;
4580
4526
  break;
4581
4527
  }
4582
- _context5.next = 17;
4583
- return createAndSaveKeyPairs(webId, publicKey, privateKeyDoc, publicKeyDoc);
4584
- case 17:
4585
- privateKey = _context5.sent;
4586
- case 18:
4587
- if (validPublicKey(webId, publicKey, privateKey)) {
4588
- _context5.next = 21;
4528
+ // add = []
4529
+ privateKey = generatePrivateKey();
4530
+ add = [$rdf.st(webId, ns.solid('privateKey'), $rdf.literal(privateKey), _solidLogic.store.sym(privateKeyDoc))];
4531
+ _context3.next = 24;
4532
+ return saveKey(privateKeyDoc, [], add, webId.uri);
4533
+ case 24:
4534
+ if (!(!publicKey || !validPublicKey)) {
4535
+ _context3.next = 31;
4589
4536
  break;
4590
4537
  }
4591
- _context5.next = 21;
4592
- return generateAndStoreNewPublicKey(webId, privateKey, publicKey, publicKeyDoc);
4593
- case 21:
4538
+ del = [];
4539
+ // delete invalid public key
4540
+ if (publicKey) {
4541
+ del = [$rdf.st(webId, ns.solid('publicKey'), $rdf.lit(publicKey), _solidLogic.store.sym(publicKeyDoc))];
4542
+ debug.log(del);
4543
+ }
4544
+ // update new valid key
4545
+ newPublicKey = generatePublicKey(privateKey);
4546
+ add = [$rdf.st(webId, ns.solid('publicKey'), $rdf.literal(newPublicKey), _solidLogic.store.sym(publicKeyDoc))];
4547
+ _context3.next = 31;
4548
+ return saveKey(publicKeyDoc, del, add);
4549
+ case 31:
4594
4550
  keyContainer = privateKeyDoc.substring(0, privateKeyDoc.lastIndexOf('/') + 1);
4595
- _context5.next = 24;
4551
+ _context3.next = 34;
4596
4552
  return (0, _acl.setAcl)(keyContainer, (0, _acl.keyContainerAclBody)(webId.uri));
4597
- case 24:
4598
- return _context5.abrupt("return", privateKey);
4599
- case 25:
4553
+ case 34:
4554
+ return _context3.abrupt("return", privateKey);
4555
+ case 35:
4600
4556
  case "end":
4601
- return _context5.stop();
4557
+ return _context3.stop();
4602
4558
  }
4603
- }, _callee5);
4559
+ }, _callee3);
4604
4560
  }));
4605
4561
  return _getPrivateKey.apply(this, arguments);
4606
4562
  }
@@ -4643,7 +4599,7 @@ var deleteKeyAcl = /*#__PURE__*/function () {
4643
4599
  }
4644
4600
  }, _callee, null, [[4, 11]]);
4645
4601
  }));
4646
- return function deleteKeyAcl(_x11) {
4602
+ return function deleteKeyAcl(_x3) {
4647
4603
  return _ref.apply(this, arguments);
4648
4604
  };
4649
4605
  }();
@@ -4653,36 +4609,36 @@ var deleteKeyAcl = /*#__PURE__*/function () {
4653
4609
  * create/edit keyDoc
4654
4610
  * set keyDoc acl
4655
4611
  */
4656
- function saveKeyAndHandleAcl(_x12, _x13, _x14) {
4657
- return _saveKeyAndHandleAcl.apply(this, arguments);
4612
+ function saveKey(_x4, _x5, _x6) {
4613
+ return _saveKey.apply(this, arguments);
4658
4614
  }
4659
- function _saveKeyAndHandleAcl() {
4660
- _saveKeyAndHandleAcl = (0, _asyncToGenerator2["default"])(function (keyDoc, del, add) {
4615
+ function _saveKey() {
4616
+ _saveKey = (0, _asyncToGenerator2["default"])(function (keyDoc, del, add) {
4661
4617
  var me = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
4662
- return /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
4618
+ return /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
4663
4619
  var aclBody;
4664
- return _regenerator["default"].wrap(function _callee6$(_context6) {
4665
- while (1) switch (_context6.prev = _context6.next) {
4620
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
4621
+ while (1) switch (_context4.prev = _context4.next) {
4666
4622
  case 0:
4667
- _context6.next = 2;
4623
+ _context4.next = 2;
4668
4624
  return deleteKeyAcl(keyDoc);
4669
4625
  case 2:
4670
- _context6.next = 4;
4626
+ _context4.next = 4;
4671
4627
  return _solidLogic.store.updater.updateMany(del, add);
4672
4628
  case 4:
4673
4629
  // or a promise store.updater.update ?
4674
4630
  // create READ only ACL
4675
4631
  aclBody = (0, _acl.keyAclBody)(keyDoc, me);
4676
- _context6.next = 7;
4632
+ _context4.next = 7;
4677
4633
  return (0, _acl.setAcl)(keyDoc, aclBody);
4678
4634
  case 7:
4679
4635
  case "end":
4680
- return _context6.stop();
4636
+ return _context4.stop();
4681
4637
  }
4682
- }, _callee6);
4638
+ }, _callee4);
4683
4639
  })();
4684
4640
  });
4685
- return _saveKeyAndHandleAcl.apply(this, arguments);
4641
+ return _saveKey.apply(this, arguments);
4686
4642
  }
4687
4643
  //# sourceMappingURL=keys.js.map
4688
4644
 
@@ -4841,20 +4797,23 @@ function renderMessageRow(_x, _x2, _x3, _x4, _x5) {
4841
4797
  } // END OF RENDERMESSAGE
4842
4798
  function _renderMessageRow() {
4843
4799
  _renderMessageRow = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(channelObject, message, fresh, options, userContext) {
4844
- var colorizeByAuthor, creator, date, latestVersion, latestVersionCreator, msgId, content, versions, replies, thread, straightReplies, _iterator2, _step2, reply, signature, msg, messageRow, publicKey, regex, validSignature, validPublicKeyHexString, originalMessage, edited, sortDate, td1, img, bothDates, td2, text, isURI, para, isImage, _img, anc, bgcolor, getBgColor, strip, td3, toolsButton;
4800
+ var unsignedMessage, colorizeByAuthor, creator, date, latestVersion, latestVersionCreator, msgId, content, versions, replies, thread, straightReplies, _iterator2, _step2, reply, signature, msg, originalMessage, edited, sortDate, messageRow, td1, img, bothDates, td2, text, isURI, para, isImage, _img, anc, bgcolor, getBgColor, strip, td3, toolsButton;
4845
4801
  return _regenerator["default"].wrap(function _callee9$(_context10) {
4846
4802
  while (1) switch (_context10.prev = _context10.next) {
4847
4803
  case 0:
4848
4804
  getBgColor = function _getBgColor(fresh) {
4849
4805
  return fresh ? '#e8ffe8' : 'white';
4850
4806
  };
4851
- colorizeByAuthor = options.colorizeByAuthor === '1' || options.colorizeByAuthor === true;
4807
+ unsignedMessage = false;
4808
+ colorizeByAuthor = options.colorizeByAuthor === '1' || options.colorizeByAuthor === true; // const id = store.any(latestVersion, ns.sioc('id'))
4809
+ // const replies = store.each(latestVersion, ns.sioc('has_reply'))
4852
4810
  creator = _solidLogic.store.any(message, ns.foaf('maker'));
4853
4811
  date = _solidLogic.store.any(message, ns.dct('created'));
4854
- _context10.next = 6;
4812
+ _context10.next = 7;
4855
4813
  return (0, _chatLogic.mostRecentVersion)(message);
4856
- case 6:
4814
+ case 7:
4857
4815
  latestVersion = _context10.sent;
4816
+ debug.log('@@@@ alain mostRecentVersion');
4858
4817
  debug.log(message);
4859
4818
  debug.log(latestVersion);
4860
4819
  latestVersionCreator = _solidLogic.store.any(latestVersion, ns.foaf('maker')); // use latest content if same owner, else use original
@@ -4864,9 +4823,9 @@ function _renderMessageRow() {
4864
4823
  debug.log(latestVersionCreator);
4865
4824
  msgId = creator.uri === (latestVersionCreator === null || latestVersionCreator === void 0 ? void 0 : latestVersionCreator.uri) ? latestVersion : message;
4866
4825
  content = _solidLogic.store.any(msgId, ns.sioc('content'));
4867
- _context10.next = 17;
4826
+ _context10.next = 19;
4868
4827
  return (0, _chatLogic.allVersions)(msgId);
4869
- case 17:
4828
+ case 19:
4870
4829
  versions = _context10.sent;
4871
4830
  if (versions.length > 1) {
4872
4831
  debug.log('renderMessageRow versions: ', versions.join(', '));
@@ -4908,38 +4867,35 @@ function _renderMessageRow() {
4908
4867
  msg.created = _solidLogic.store.any(msgId, ns.dct('created')).value;
4909
4868
  msg.content = content.value;
4910
4869
  msg.maker = creator.uri;
4911
- messageRow = dom.createElement('tr'); // verify signature
4912
- if (signature !== null && signature !== void 0 && signature.value) {
4913
- _context10.next = 38;
4914
- break;
4915
- }
4916
- // unsigned message
4917
- messageRow.setAttribute('style', style.textInputBackgroundColorHighlight);
4918
- _context10.next = 48;
4919
- break;
4920
- case 38:
4921
- _context10.next = 40;
4922
- return (0, _keys.getPublicKey)(creator);
4923
- case 40:
4924
- publicKey = _context10.sent;
4925
- debug.log(creator.uri + '\n' + msg.created + '\n' + msg.id + '\n' + publicKey);
4926
- if (!publicKey) {
4927
- debug.warn('message is signed but ' + creator.uri + ' is missing publicKey');
4870
+
4871
+ // verify signature
4872
+ if (!(signature !== null && signature !== void 0 && signature.value)) {
4873
+ // unsigned message
4874
+ unsignedMessage = true;
4875
+ debug.warn(msgId.uri + ' is unsigned'); // TODO replace with UI (colored message ?)
4876
+ } else {
4877
+ // signed message, get public key and check signature
4878
+ (0, _keys.getPublicKey)(creator).then(function (publicKey) {
4879
+ debug.log(creator.uri + '\n' + msg.created + '\n' + msg.id + '\n' + publicKey);
4880
+ if (!publicKey) {
4881
+ debug.warn('message is signed but ' + creator.uri + ' is missing publicKey');
4882
+ }
4883
+ // check that publicKey is a valid hex string
4884
+ var regex = /[0-9A-Fa-f]{6}/g;
4885
+ if (!(publicKey !== null && publicKey !== void 0 && publicKey.match(regex))) debug.warn('invalid publicKey hex string\n' + creator.uri + '\n' + publicKey);
4886
+ // verify signature
4887
+ else if (signature !== null && signature !== void 0 && signature.value && !(0, _signature.verifySignature)(signature === null || signature === void 0 ? void 0 : signature.value, msg, publicKey)) debug.warn('invalid signature\n' + msg.id);
4888
+ });
4928
4889
  }
4929
- // check that publicKey is a valid hex string
4930
- regex = /[0-9A-Fa-f]{6}/g;
4931
- validSignature = (0, _signature.verifySignature)(signature === null || signature === void 0 ? void 0 : signature.value, msg, publicKey);
4932
- validPublicKeyHexString = publicKey === null || publicKey === void 0 ? void 0 : publicKey.match(regex);
4933
- if (!validPublicKeyHexString) debug.warn('invalid publicKey hex string\n' + creator.uri + '\n' + publicKey);else if (signature !== null && signature !== void 0 && signature.value && !validSignature) debug.warn('invalid signature\n' + msg.id);
4934
- if (!validSignature || !validPublicKeyHexString) messageRow.setAttribute('style', style.textInputBackgroundColorError);
4935
- case 48:
4936
- _context10.next = 50;
4890
+ _context10.next = 38;
4937
4891
  return (0, _chatLogic.originalVersion)(message);
4938
- case 50:
4892
+ case 38:
4939
4893
  originalMessage = _context10.sent;
4940
4894
  edited = !message.sameTerm(originalMessage); // @@ load it first @@ Or display the new data at the old date.
4941
4895
  // @@@ kludge!
4942
4896
  sortDate = _solidLogic.store.the(originalMessage, ns.dct('created'), null, originalMessage.doc()) || _solidLogic.store.the(message, ns.dct('created'), null, message.doc()); // In message
4897
+ messageRow = dom.createElement('tr');
4898
+ if (unsignedMessage) messageRow.setAttribute('style', 'background-color: red');
4943
4899
  messageRow.AJAR_date = sortDate.value;
4944
4900
  messageRow.AJAR_subject = message;
4945
4901
  td1 = dom.createElement('td');
@@ -4990,9 +4946,9 @@ function _renderMessageRow() {
4990
4946
  bgcolor = colorizeByAuthor ? pad.lightColorHash(creator) : getBgColor(fresh);
4991
4947
  para.setAttribute('style', messageBodyStyle + 'background-color: ' + bgcolor + ';');
4992
4948
  }
4993
- _context10.next = 69;
4949
+ _context10.next = 59;
4994
4950
  return (0, _messageTools.sentimentStripLinked)(message, message.doc());
4995
- case 69:
4951
+ case 59:
4996
4952
  strip = _context10.sent;
4997
4953
  if (strip.children.length) {
4998
4954
  td2.appendChild(dom.createElement('br'));
@@ -5057,7 +5013,7 @@ function _renderMessageRow() {
5057
5013
  }));
5058
5014
  }
5059
5015
  return _context10.abrupt("return", messageRow);
5060
- case 78:
5016
+ case 68:
5061
5017
  case "end":
5062
5018
  return _context10.stop();
5063
5019
  }
@@ -5997,27 +5953,96 @@ exports.verifySignature = verifySignature;
5997
5953
  var _secp256k = __webpack_require__(/*! @noble/curves/secp256k1 */ "./node_modules/@noble/curves/secp256k1.js");
5998
5954
  var _utils = __webpack_require__(/*! @noble/hashes/utils */ "./node_modules/@noble/hashes/utils.js");
5999
5955
  var _sha = __webpack_require__(/*! @noble/hashes/sha256 */ "./node_modules/@noble/hashes/sha256.js");
5956
+ // import {utf8Encoder} from './utils'
5957
+ // import { getPublicKey } from './keys'
5958
+
6000
5959
  var utf8Decoder = new TextDecoder('utf-8');
6001
5960
  exports.utf8Decoder = utf8Decoder;
6002
5961
  var utf8Encoder = new TextEncoder();
6003
5962
  exports.utf8Encoder = utf8Encoder;
6004
5963
  var SEC = 'https://w3id.org/security#'; // Proof, VerificationMethod
5964
+ // export const CERT = 'http://www.w3.org/ns/auth/cert#' // PrivateKey, PublicKey, key
5965
+
5966
+ /* eslint-disable no-unused-vars */
5967
+ /* export enum Kind {
5968
+ Metadata = 0,
5969
+ Text = 1,
5970
+ RecommendRelay = 2,
5971
+ Contacts = 3,
5972
+ EncryptedDirectMessage = 4,
5973
+ EventDeletion = 5,
5974
+ Reaction = 7,
5975
+ BadgeAward = 8,
5976
+ ChannelCreation = 40,
5977
+ ChannelMetadata = 41,
5978
+ ChannelMessage = 42,
5979
+ ChannelHideMessage = 43,
5980
+ ChannelMuteUser = 44,
5981
+ Report = 1984,
5982
+ ZapRequest = 9734,
5983
+ Zap = 9735,
5984
+ RelayList = 10002,
5985
+ ClientAuth = 22242,
5986
+ BadgeDefinition = 30008,
5987
+ ProfileBadge = 30009,
5988
+ Article = 30023
5989
+ } */
6005
5990
  exports.SEC = SEC;
6006
5991
  function getBlankMsg() {
6007
5992
  return {
6008
5993
  id: '',
6009
5994
  created: '',
5995
+ dateDeleted: '',
5996
+ // TODO to remove if not used
6010
5997
  content: '',
6011
- maker: ''
5998
+ maker: '',
5999
+ sig: '' // TODO to remove if not used
6012
6000
  };
6013
6001
  }
6002
+
6003
+ /* export function finishMsg (t: MsgTemplate, privateKey: string): Message {
6004
+ // to update to chat message triples
6005
+ const message = t as Message
6006
+ // message.pubkey = getPublicKey(privateKey)
6007
+ message.id = getMsgHash(message)
6008
+ message.sig = signMsg(message, privateKey)
6009
+ return message
6010
+ } */
6011
+
6014
6012
  function serializeMsg(msg) {
6013
+ // to update to chat messages triples
6014
+ /* if (!validateMsg(msg))
6015
+ throw new Error("can't serialize message with wrong or missing properties") */
6016
+
6015
6017
  return JSON.stringify(msg);
6016
6018
  }
6017
6019
  function getMsgHash(message) {
6018
6020
  var msgHash = (0, _sha.sha256)(utf8Encoder.encode(serializeMsg(message)));
6019
6021
  return (0, _utils.bytesToHex)(msgHash);
6020
6022
  }
6023
+
6024
+ // const isRecord = (obj: unknown): obj is Record<string, unknown> => obj instanceof Object
6025
+
6026
+ /* export function validateMsg<T> (message: T): message is T & UnsignedMsg {
6027
+ if (!isRecord(message)) return false
6028
+ if (typeof message.kind !== 'number') return false
6029
+ if (typeof message.content !== 'string') return false
6030
+ if (typeof message.created_at !== 'number') return false
6031
+ if (typeof message.pubkey !== 'string') return false
6032
+ if (!message.pubkey.match(/^[a-f0-9]{64}$/)) return false
6033
+
6034
+ if (!Array.isArray(message.tags)) return false
6035
+ for (let i = 0; i < message.tags.length; i++) {
6036
+ let tag = message.tags[i]
6037
+ if (!Array.isArray(tag)) return false
6038
+ for (let j = 0; j < tag.length; j++) {
6039
+ if (typeof tag[j] === 'object') return false
6040
+ }
6041
+ }
6042
+
6043
+ return true
6044
+ } */
6045
+
6021
6046
  function verifySignature(sig, message, pubKey) {
6022
6047
  return _secp256k.schnorr.verify(sig, getMsgHash(message), pubKey);
6023
6048
  }
@@ -11069,8 +11094,6 @@ var style = {
11069
11094
  formFieldNameBoxStyle: "padding: 0.3em; vertical-align: middle; width:".concat(formFieldNameBoxWidth, ";"),
11070
11095
  textInputBackgroundColor: '#eef',
11071
11096
  textInputBackgroundColorUneditable: '#fff',
11072
- textInputBackgroundColorError: 'background-color: #fee;',
11073
- textInputBackgroundColorHighlight: 'background-color: #fdeadc;',
11074
11097
  textInputColor: '#000',
11075
11098
  textInputColorPending: '#888',
11076
11099
  multilineTextInputStyle: 'font-size:100%; white-space: pre-wrap; background-color: #eef;' + ' border: 0.07em solid gray; padding: 1em 0.5em; margin: 1em 1em;',
@@ -14009,96 +14032,176 @@ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/r
14009
14032
  var debug = _interopRequireWildcard(__webpack_require__(/*! ../../debug */ "./lib/debug.js"));
14010
14033
  var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
14011
14034
  var ns = _interopRequireWildcard(__webpack_require__(/*! ../../ns */ "./lib/ns.js"));
14012
- var _otherHelpers = __webpack_require__(/*! ./otherHelpers */ "./lib/utils/keyHelpers/otherHelpers.js");
14013
14035
  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); }
14014
14036
  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; }
14015
- var pubKeyUrl = function pubKeyUrl(webId) {
14016
- var url;
14017
- try {
14018
- var root = (0, _otherHelpers.getRootIfPreferencesExist)(webId);
14019
- url = "".concat(root, "/profile/keys/publicKey.ttl");
14020
- } catch (err) {
14021
- debug.error(err);
14037
+ /* export const getPodRoot = async (webId: NamedNode) => {
14038
+ const webIdURL = new URL(webId.uri)
14039
+ // find storages in webId document
14040
+ await store.fetcher.load(webId.uri)
14041
+ const storages = store.each(webId, ns.space('storage'), null, webId.doc())
14042
+ var podRoot: NamedNode | undefined
14043
+ if (!storages?.length) {
14044
+ // find storage recursively in webId URL
14045
+ let path = webIdURL.pathname
14046
+ while (path.length) {
14047
+ path = path.substring(0, path.lastIndexOf('/'))
14048
+ podRoot = store.sym(webIdURL.origin + path + '/')
14049
+ const res = await store.fetcher.webOperation('HEAD', podRoot.uri)
14050
+ if (res.headers.get('link')?.includes(ns.space('Storage').value)) break
14051
+ if (!path) debug.warn(`Current user storage not found for\n${webId}`)
14052
+ }
14053
+ } else {
14054
+ // give preference to storage in webId root
14055
+ podRoot = storages.find((storage) => webIdURL.origin === new URL(storage.value).origin) as NamedNode
14056
+ if (!podRoot) podRoot = storages[0] as NamedNode
14022
14057
  }
14023
- return url;
14024
- };
14058
+
14059
+ return podRoot as NamedNode
14060
+ } */
14061
+
14062
+ var pubKeyUrl = /*#__PURE__*/function () {
14063
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
14064
+ var _store$any, _parentSettings;
14065
+ var parentSettings;
14066
+ return _regenerator["default"].wrap(function _callee$(_context) {
14067
+ while (1) switch (_context.prev = _context.next) {
14068
+ case 0:
14069
+ parentSettings = (_store$any = _solidLogic.store.any(webId, ns.space('preferencesFile'), null, webId.doc())) === null || _store$any === void 0 ? void 0 : _store$any.value;
14070
+ parentSettings = (_parentSettings = parentSettings) === null || _parentSettings === void 0 ? void 0 : _parentSettings.split('/').slice(0, -2).join('/');
14071
+ if (parentSettings) {
14072
+ _context.next = 4;
14073
+ break;
14074
+ }
14075
+ throw new Error("prefererencesFile is expected to exist in ".concat(webId.doc));
14076
+ case 4:
14077
+ return _context.abrupt("return", "".concat(parentSettings, "/profile/keys/publicKey.ttl"));
14078
+ case 5:
14079
+ case "end":
14080
+ return _context.stop();
14081
+ }
14082
+ }, _callee);
14083
+ }));
14084
+ return function pubKeyUrl(_x) {
14085
+ return _ref.apply(this, arguments);
14086
+ };
14087
+ }();
14025
14088
  exports.pubKeyUrl = pubKeyUrl;
14026
- var privKeyUrl = function privKeyUrl(webId) {
14027
- var url;
14028
- try {
14029
- var root = (0, _otherHelpers.getRootIfPreferencesExist)(webId);
14030
- url = "".concat(root, "/keys/privateKey.ttl");
14031
- } catch (err) {
14032
- debug.error(err);
14033
- }
14034
- return url;
14035
- };
14036
- exports.privKeyUrl = privKeyUrl;
14037
- function getExistingPublicKey(_x, _x2) {
14089
+ function getExistingPublicKey(_x2, _x3) {
14038
14090
  return _getExistingPublicKey.apply(this, arguments);
14039
14091
  }
14040
14092
  function _getExistingPublicKey() {
14041
- _getExistingPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId, publicKeyUrl) {
14042
- return _regenerator["default"].wrap(function _callee$(_context) {
14043
- while (1) switch (_context.prev = _context.next) {
14093
+ _getExistingPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId, publicKeyUrl) {
14094
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
14095
+ while (1) switch (_context3.prev = _context3.next) {
14044
14096
  case 0:
14045
- _context.next = 2;
14097
+ _context3.next = 2;
14046
14098
  return getKeyIfExists(webId, publicKeyUrl, 'publicKey');
14047
14099
  case 2:
14048
- return _context.abrupt("return", _context.sent);
14100
+ return _context3.abrupt("return", _context3.sent);
14049
14101
  case 3:
14050
14102
  case "end":
14051
- return _context.stop();
14103
+ return _context3.stop();
14052
14104
  }
14053
- }, _callee);
14105
+ }, _callee3);
14054
14106
  }));
14055
14107
  return _getExistingPublicKey.apply(this, arguments);
14056
14108
  }
14057
- function getExistingPrivateKey(_x3, _x4) {
14109
+ var privKeyUrl = /*#__PURE__*/function () {
14110
+ var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
14111
+ var _store$any2, _settings;
14112
+ var settings;
14113
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
14114
+ while (1) switch (_context2.prev = _context2.next) {
14115
+ case 0:
14116
+ settings = (_store$any2 = _solidLogic.store.any(webId, ns.space('preferencesFile'), null, webId.doc())) === null || _store$any2 === void 0 ? void 0 : _store$any2.value;
14117
+ settings = (_settings = settings) === null || _settings === void 0 ? void 0 : _settings.split('/').slice(0, -1).join('/');
14118
+ if (settings) {
14119
+ _context2.next = 4;
14120
+ break;
14121
+ }
14122
+ throw new Error("prefererencesFile is expected to exist in ".concat(webId.doc));
14123
+ case 4:
14124
+ return _context2.abrupt("return", "".concat(settings, "/keys/privateKey.ttl"));
14125
+ case 5:
14126
+ case "end":
14127
+ return _context2.stop();
14128
+ }
14129
+ }, _callee2);
14130
+ }));
14131
+ return function privKeyUrl(_x4) {
14132
+ return _ref2.apply(this, arguments);
14133
+ };
14134
+ }();
14135
+ exports.privKeyUrl = privKeyUrl;
14136
+ function getExistingPrivateKey(_x5, _x6) {
14058
14137
  return _getExistingPrivateKey.apply(this, arguments);
14059
14138
  }
14060
14139
  function _getExistingPrivateKey() {
14061
- _getExistingPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId, privateKeyUrl) {
14062
- return _regenerator["default"].wrap(function _callee2$(_context2) {
14063
- while (1) switch (_context2.prev = _context2.next) {
14140
+ _getExistingPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(webId, privateKeyUrl) {
14141
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
14142
+ while (1) switch (_context4.prev = _context4.next) {
14064
14143
  case 0:
14065
- _context2.next = 2;
14144
+ _context4.next = 2;
14066
14145
  return getKeyIfExists(webId, privateKeyUrl, 'privateKey');
14067
14146
  case 2:
14068
- return _context2.abrupt("return", _context2.sent);
14147
+ return _context4.abrupt("return", _context4.sent);
14069
14148
  case 3:
14070
14149
  case "end":
14071
- return _context2.stop();
14150
+ return _context4.stop();
14072
14151
  }
14073
- }, _callee2);
14152
+ }, _callee4);
14074
14153
  }));
14075
14154
  return _getExistingPrivateKey.apply(this, arguments);
14076
14155
  }
14077
- function getKeyIfExists(_x5, _x6, _x7) {
14156
+ function getKeyIfExists(_x7, _x8, _x9) {
14078
14157
  return _getKeyIfExists.apply(this, arguments);
14079
14158
  }
14080
14159
  function _getKeyIfExists() {
14081
- _getKeyIfExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId, keyUrl, keyType) {
14160
+ _getKeyIfExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(webId, keyUrl, keyType) {
14082
14161
  var key;
14083
- return _regenerator["default"].wrap(function _callee3$(_context3) {
14084
- while (1) switch (_context3.prev = _context3.next) {
14162
+ return _regenerator["default"].wrap(function _callee5$(_context5) {
14163
+ while (1) switch (_context5.prev = _context5.next) {
14085
14164
  case 0:
14086
- _context3.prev = 0;
14087
- _context3.next = 3;
14165
+ _context5.prev = 0;
14166
+ _context5.next = 3;
14088
14167
  return _solidLogic.store.fetcher.load(keyUrl);
14089
14168
  case 3:
14090
14169
  key = _solidLogic.store.any(webId, ns.solid(keyType)); // store.sym(CERT + keyType))
14091
- return _context3.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
14170
+ return _context5.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
14092
14171
  case 7:
14093
- _context3.prev = 7;
14094
- _context3.t0 = _context3["catch"](0);
14095
- debug.error('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context3.t0);
14096
- return _context3.abrupt("return", undefined);
14097
- case 11:
14172
+ _context5.prev = 7;
14173
+ _context5.t0 = _context5["catch"](0);
14174
+ if (!(_context5.t0.response.status === 404)) {
14175
+ _context5.next = 24;
14176
+ break;
14177
+ }
14178
+ debug.log('createIfNotExists: doc does NOT exist, will create... ' + keyUrl);
14179
+ _context5.prev = 11;
14180
+ _context5.next = 14;
14181
+ return _solidLogic.store.fetcher.webOperation('PUT', keyUrl, {
14182
+ data: '',
14183
+ contentType: 'text/turtle'
14184
+ });
14185
+ case 14:
14186
+ _context5.next = 20;
14187
+ break;
14188
+ case 16:
14189
+ _context5.prev = 16;
14190
+ _context5.t1 = _context5["catch"](11);
14191
+ debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context5.t1);
14192
+ throw _context5.t1;
14193
+ case 20:
14194
+ delete _solidLogic.store.fetcher.requested[keyUrl]; // delete cached 404 error
14195
+ // debug.log('createIfNotExists doc created ok ' + doc)
14196
+ return _context5.abrupt("return", undefined);
14197
+ case 24:
14198
+ debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context5.t0);
14199
+ throw _context5.t0;
14200
+ case 26:
14098
14201
  case "end":
14099
- return _context3.stop();
14202
+ return _context5.stop();
14100
14203
  }
14101
- }, _callee3, null, [[0, 7]]);
14204
+ }, _callee5, null, [[0, 7], [11, 16]]);
14102
14205
  }));
14103
14206
  return _getKeyIfExists.apply(this, arguments);
14104
14207
  }
@@ -14209,39 +14312,6 @@ exports.keyAclBody = keyAclBody;
14209
14312
 
14210
14313
  /***/ }),
14211
14314
 
14212
- /***/ "./lib/utils/keyHelpers/otherHelpers.js":
14213
- /*!**********************************************!*\
14214
- !*** ./lib/utils/keyHelpers/otherHelpers.js ***!
14215
- \**********************************************/
14216
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
14217
-
14218
- "use strict";
14219
-
14220
-
14221
- var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
14222
- Object.defineProperty(exports, "__esModule", ({
14223
- value: true
14224
- }));
14225
- exports.getRootIfPreferencesExist = void 0;
14226
- var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
14227
- var ns = _interopRequireWildcard(__webpack_require__(/*! ../../ns */ "./lib/ns.js"));
14228
- 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); }
14229
- 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; }
14230
- // Will rename this file later. We will probably be using solid-logic anyway
14231
- // moved it out so I can mock
14232
-
14233
- var getRootIfPreferencesExist = function getRootIfPreferencesExist(webId) {
14234
- var _store$any, _root;
14235
- var root = (_store$any = _solidLogic.store.any(webId, ns.space('preferencesFile'), null, webId.doc())) === null || _store$any === void 0 ? void 0 : _store$any.value;
14236
- root = (_root = root) === null || _root === void 0 ? void 0 : _root.split('/').slice(0, -2).join('/');
14237
- if (!root) throw new Error("prefererencesFile is expected to exist in ".concat(webId));
14238
- return root;
14239
- };
14240
- exports.getRootIfPreferencesExist = getRootIfPreferencesExist;
14241
- //# sourceMappingURL=otherHelpers.js.map
14242
-
14243
- /***/ }),
14244
-
14245
14315
  /***/ "./lib/utils/label.js":
14246
14316
  /*!****************************!*\
14247
14317
  !*** ./lib/utils/label.js ***!
@@ -14370,8 +14440,8 @@ Object.defineProperty(exports, "__esModule", ({
14370
14440
  }));
14371
14441
  exports.versionInfo = void 0;
14372
14442
  var versionInfo = {
14373
- buildTime: '2023-06-06T09:58:11Z',
14374
- commit: 'df3d943175afe78b5cfa7f13804ee7ff66055067',
14443
+ buildTime: '2023-06-20T22:08:42Z',
14444
+ commit: 'e581c53c2db1fb41eb0f46072e3abe522816d159',
14375
14445
  npmInfo: {
14376
14446
  'solid-ui': '2.4.28',
14377
14447
  npm: '8.19.4',