solid-ui 2.4.28-a414b470 → 2.4.28-df3d9431

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,10 +4415,13 @@ 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;
4418
4420
  exports.generatePrivateKey = generatePrivateKey;
4419
4421
  exports.generatePublicKey = generatePublicKey;
4420
4422
  exports.getPrivateKey = getPrivateKey;
4421
4423
  exports.getPublicKey = getPublicKey;
4424
+ exports.validPublicKey = validPublicKey;
4422
4425
  var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
4423
4426
  var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
4424
4427
  var debug = _interopRequireWildcard(__webpack_require__(/*! ../debug */ "./lib/debug.js"));
@@ -4454,109 +4457,150 @@ function _getPublicKey() {
4454
4457
  return _regenerator["default"].wrap(function _callee2$(_context2) {
4455
4458
  while (1) switch (_context2.prev = _context2.next) {
4456
4459
  case 0:
4457
- _context2.next = 2;
4460
+ _context2.prev = 0;
4461
+ _context2.next = 3;
4458
4462
  return _solidLogic.store.fetcher.load(webId);
4459
- case 2:
4460
- _context2.next = 4;
4463
+ case 3:
4464
+ _context2.next = 5;
4461
4465
  return (0, _accessData.pubKeyUrl)(webId);
4462
- case 4:
4466
+ case 5:
4463
4467
  publicKeyDoc = _context2.sent;
4464
- _context2.prev = 5;
4465
- _context2.next = 8;
4468
+ _context2.prev = 6;
4469
+ _context2.next = 9;
4466
4470
  return _solidLogic.store.fetcher.load(publicKeyDoc);
4467
- case 8:
4471
+ case 9:
4468
4472
  // url.href)
4469
4473
  key = _solidLogic.store.any(webId, ns.solid('publicKey'));
4470
4474
  return _context2.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
4471
- case 12:
4472
- _context2.prev = 12;
4473
- _context2.t0 = _context2["catch"](5);
4475
+ case 13:
4476
+ _context2.prev = 13;
4477
+ _context2.t0 = _context2["catch"](6);
4478
+ debug.error(_context2.t0);
4474
4479
  return _context2.abrupt("return", undefined);
4475
- case 15:
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);
4487
+ return _context2.abrupt("return", undefined);
4488
+ case 23:
4476
4489
  case "end":
4477
4490
  return _context2.stop();
4478
4491
  }
4479
- }, _callee2, null, [[5, 12]]);
4492
+ }, _callee2, null, [[0, 19], [6, 13]]);
4480
4493
  }));
4481
4494
  return _getPublicKey.apply(this, arguments);
4482
4495
  }
4483
- function getPrivateKey(_x2) {
4484
- return _getPrivateKey.apply(this, arguments);
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;
4485
4501
  }
4486
- function _getPrivateKey() {
4487
- _getPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId) {
4488
- var publicKeyDoc, privateKeyDoc, publicKey, privateKey, validPublicKey, del, add, newPublicKey, keyContainer;
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;
4489
4508
  return _regenerator["default"].wrap(function _callee3$(_context3) {
4490
4509
  while (1) switch (_context3.prev = _context3.next) {
4491
4510
  case 0:
4492
- _context3.next = 2;
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) {
4551
+ return _getPrivateKey.apply(this, arguments);
4552
+ }
4553
+ 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) {
4558
+ case 0:
4559
+ _context5.next = 2;
4493
4560
  return _solidLogic.store.fetcher.load(webId);
4494
4561
  case 2:
4495
- _context3.next = 4;
4562
+ _context5.next = 4;
4496
4563
  return (0, _accessData.pubKeyUrl)(webId);
4497
4564
  case 4:
4498
- publicKeyDoc = _context3.sent;
4499
- _context3.next = 7;
4565
+ publicKeyDoc = _context5.sent;
4566
+ _context5.next = 7;
4500
4567
  return (0, _accessData.privKeyUrl)(webId);
4501
4568
  case 7:
4502
- privateKeyDoc = _context3.sent;
4503
- _context3.next = 10;
4569
+ privateKeyDoc = _context5.sent;
4570
+ _context5.next = 10;
4504
4571
  return (0, _accessData.getExistingPublicKey)(webId, publicKeyDoc);
4505
4572
  case 10:
4506
- publicKey = _context3.sent;
4507
- _context3.next = 13;
4573
+ publicKey = _context5.sent;
4574
+ _context5.next = 13;
4508
4575
  return (0, _accessData.getExistingPrivateKey)(webId, privateKeyDoc);
4509
4576
  case 13:
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 = [];
4577
+ privateKey = _context5.sent;
4524
4578
  if (privateKey) {
4525
- _context3.next = 24;
4579
+ _context5.next = 18;
4526
4580
  break;
4527
4581
  }
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;
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;
4536
4589
  break;
4537
4590
  }
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:
4591
+ _context5.next = 21;
4592
+ return generateAndStoreNewPublicKey(webId, privateKey, publicKey, publicKeyDoc);
4593
+ case 21:
4550
4594
  keyContainer = privateKeyDoc.substring(0, privateKeyDoc.lastIndexOf('/') + 1);
4551
- _context3.next = 34;
4595
+ _context5.next = 24;
4552
4596
  return (0, _acl.setAcl)(keyContainer, (0, _acl.keyContainerAclBody)(webId.uri));
4553
- case 34:
4554
- return _context3.abrupt("return", privateKey);
4555
- case 35:
4597
+ case 24:
4598
+ return _context5.abrupt("return", privateKey);
4599
+ case 25:
4556
4600
  case "end":
4557
- return _context3.stop();
4601
+ return _context5.stop();
4558
4602
  }
4559
- }, _callee3);
4603
+ }, _callee5);
4560
4604
  }));
4561
4605
  return _getPrivateKey.apply(this, arguments);
4562
4606
  }
@@ -4599,7 +4643,7 @@ var deleteKeyAcl = /*#__PURE__*/function () {
4599
4643
  }
4600
4644
  }, _callee, null, [[4, 11]]);
4601
4645
  }));
4602
- return function deleteKeyAcl(_x3) {
4646
+ return function deleteKeyAcl(_x11) {
4603
4647
  return _ref.apply(this, arguments);
4604
4648
  };
4605
4649
  }();
@@ -4609,36 +4653,36 @@ var deleteKeyAcl = /*#__PURE__*/function () {
4609
4653
  * create/edit keyDoc
4610
4654
  * set keyDoc acl
4611
4655
  */
4612
- function saveKey(_x4, _x5, _x6) {
4613
- return _saveKey.apply(this, arguments);
4656
+ function saveKeyAndHandleAcl(_x12, _x13, _x14) {
4657
+ return _saveKeyAndHandleAcl.apply(this, arguments);
4614
4658
  }
4615
- function _saveKey() {
4616
- _saveKey = (0, _asyncToGenerator2["default"])(function (keyDoc, del, add) {
4659
+ function _saveKeyAndHandleAcl() {
4660
+ _saveKeyAndHandleAcl = (0, _asyncToGenerator2["default"])(function (keyDoc, del, add) {
4617
4661
  var me = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
4618
- return /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
4662
+ return /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
4619
4663
  var aclBody;
4620
- return _regenerator["default"].wrap(function _callee4$(_context4) {
4621
- while (1) switch (_context4.prev = _context4.next) {
4664
+ return _regenerator["default"].wrap(function _callee6$(_context6) {
4665
+ while (1) switch (_context6.prev = _context6.next) {
4622
4666
  case 0:
4623
- _context4.next = 2;
4667
+ _context6.next = 2;
4624
4668
  return deleteKeyAcl(keyDoc);
4625
4669
  case 2:
4626
- _context4.next = 4;
4670
+ _context6.next = 4;
4627
4671
  return _solidLogic.store.updater.updateMany(del, add);
4628
4672
  case 4:
4629
4673
  // or a promise store.updater.update ?
4630
4674
  // create READ only ACL
4631
4675
  aclBody = (0, _acl.keyAclBody)(keyDoc, me);
4632
- _context4.next = 7;
4676
+ _context6.next = 7;
4633
4677
  return (0, _acl.setAcl)(keyDoc, aclBody);
4634
4678
  case 7:
4635
4679
  case "end":
4636
- return _context4.stop();
4680
+ return _context6.stop();
4637
4681
  }
4638
- }, _callee4);
4682
+ }, _callee6);
4639
4683
  })();
4640
4684
  });
4641
- return _saveKey.apply(this, arguments);
4685
+ return _saveKeyAndHandleAcl.apply(this, arguments);
4642
4686
  }
4643
4687
  //# sourceMappingURL=keys.js.map
4644
4688
 
@@ -4797,23 +4841,20 @@ function renderMessageRow(_x, _x2, _x3, _x4, _x5) {
4797
4841
  } // END OF RENDERMESSAGE
4798
4842
  function _renderMessageRow() {
4799
4843
  _renderMessageRow = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(channelObject, message, fresh, options, userContext) {
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;
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;
4801
4845
  return _regenerator["default"].wrap(function _callee9$(_context10) {
4802
4846
  while (1) switch (_context10.prev = _context10.next) {
4803
4847
  case 0:
4804
4848
  getBgColor = function _getBgColor(fresh) {
4805
4849
  return fresh ? '#e8ffe8' : 'white';
4806
4850
  };
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'))
4851
+ colorizeByAuthor = options.colorizeByAuthor === '1' || options.colorizeByAuthor === true;
4810
4852
  creator = _solidLogic.store.any(message, ns.foaf('maker'));
4811
4853
  date = _solidLogic.store.any(message, ns.dct('created'));
4812
- _context10.next = 7;
4854
+ _context10.next = 6;
4813
4855
  return (0, _chatLogic.mostRecentVersion)(message);
4814
- case 7:
4856
+ case 6:
4815
4857
  latestVersion = _context10.sent;
4816
- debug.log('@@@@ alain mostRecentVersion');
4817
4858
  debug.log(message);
4818
4859
  debug.log(latestVersion);
4819
4860
  latestVersionCreator = _solidLogic.store.any(latestVersion, ns.foaf('maker')); // use latest content if same owner, else use original
@@ -4823,9 +4864,9 @@ function _renderMessageRow() {
4823
4864
  debug.log(latestVersionCreator);
4824
4865
  msgId = creator.uri === (latestVersionCreator === null || latestVersionCreator === void 0 ? void 0 : latestVersionCreator.uri) ? latestVersion : message;
4825
4866
  content = _solidLogic.store.any(msgId, ns.sioc('content'));
4826
- _context10.next = 19;
4867
+ _context10.next = 17;
4827
4868
  return (0, _chatLogic.allVersions)(msgId);
4828
- case 19:
4869
+ case 17:
4829
4870
  versions = _context10.sent;
4830
4871
  if (versions.length > 1) {
4831
4872
  debug.log('renderMessageRow versions: ', versions.join(', '));
@@ -4867,35 +4908,38 @@ function _renderMessageRow() {
4867
4908
  msg.created = _solidLogic.store.any(msgId, ns.dct('created')).value;
4868
4909
  msg.content = content.value;
4869
4910
  msg.maker = creator.uri;
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
- });
4911
+ messageRow = dom.createElement('tr'); // verify signature
4912
+ if (signature !== null && signature !== void 0 && signature.value) {
4913
+ _context10.next = 38;
4914
+ break;
4889
4915
  }
4890
- _context10.next = 38;
4891
- return (0, _chatLogic.originalVersion)(message);
4916
+ // unsigned message
4917
+ messageRow.setAttribute('style', style.textInputBackgroundColorHighlight);
4918
+ _context10.next = 48;
4919
+ break;
4892
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');
4928
+ }
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;
4937
+ return (0, _chatLogic.originalVersion)(message);
4938
+ case 50:
4893
4939
  originalMessage = _context10.sent;
4894
4940
  edited = !message.sameTerm(originalMessage); // @@ load it first @@ Or display the new data at the old date.
4895
4941
  // @@@ kludge!
4896
4942
  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');
4899
4943
  messageRow.AJAR_date = sortDate.value;
4900
4944
  messageRow.AJAR_subject = message;
4901
4945
  td1 = dom.createElement('td');
@@ -4946,9 +4990,9 @@ function _renderMessageRow() {
4946
4990
  bgcolor = colorizeByAuthor ? pad.lightColorHash(creator) : getBgColor(fresh);
4947
4991
  para.setAttribute('style', messageBodyStyle + 'background-color: ' + bgcolor + ';');
4948
4992
  }
4949
- _context10.next = 59;
4993
+ _context10.next = 69;
4950
4994
  return (0, _messageTools.sentimentStripLinked)(message, message.doc());
4951
- case 59:
4995
+ case 69:
4952
4996
  strip = _context10.sent;
4953
4997
  if (strip.children.length) {
4954
4998
  td2.appendChild(dom.createElement('br'));
@@ -5013,7 +5057,7 @@ function _renderMessageRow() {
5013
5057
  }));
5014
5058
  }
5015
5059
  return _context10.abrupt("return", messageRow);
5016
- case 68:
5060
+ case 78:
5017
5061
  case "end":
5018
5062
  return _context10.stop();
5019
5063
  }
@@ -5953,96 +5997,27 @@ exports.verifySignature = verifySignature;
5953
5997
  var _secp256k = __webpack_require__(/*! @noble/curves/secp256k1 */ "./node_modules/@noble/curves/secp256k1.js");
5954
5998
  var _utils = __webpack_require__(/*! @noble/hashes/utils */ "./node_modules/@noble/hashes/utils.js");
5955
5999
  var _sha = __webpack_require__(/*! @noble/hashes/sha256 */ "./node_modules/@noble/hashes/sha256.js");
5956
- // import {utf8Encoder} from './utils'
5957
- // import { getPublicKey } from './keys'
5958
-
5959
6000
  var utf8Decoder = new TextDecoder('utf-8');
5960
6001
  exports.utf8Decoder = utf8Decoder;
5961
6002
  var utf8Encoder = new TextEncoder();
5962
6003
  exports.utf8Encoder = utf8Encoder;
5963
6004
  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
- } */
5990
6005
  exports.SEC = SEC;
5991
6006
  function getBlankMsg() {
5992
6007
  return {
5993
6008
  id: '',
5994
6009
  created: '',
5995
- dateDeleted: '',
5996
- // TODO to remove if not used
5997
6010
  content: '',
5998
- maker: '',
5999
- sig: '' // TODO to remove if not used
6011
+ maker: ''
6000
6012
  };
6001
6013
  }
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
-
6012
6014
  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
-
6017
6015
  return JSON.stringify(msg);
6018
6016
  }
6019
6017
  function getMsgHash(message) {
6020
6018
  var msgHash = (0, _sha.sha256)(utf8Encoder.encode(serializeMsg(message)));
6021
6019
  return (0, _utils.bytesToHex)(msgHash);
6022
6020
  }
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
-
6046
6021
  function verifySignature(sig, message, pubKey) {
6047
6022
  return _secp256k.schnorr.verify(sig, getMsgHash(message), pubKey);
6048
6023
  }
@@ -11094,6 +11069,8 @@ var style = {
11094
11069
  formFieldNameBoxStyle: "padding: 0.3em; vertical-align: middle; width:".concat(formFieldNameBoxWidth, ";"),
11095
11070
  textInputBackgroundColor: '#eef',
11096
11071
  textInputBackgroundColorUneditable: '#fff',
11072
+ textInputBackgroundColorError: 'background-color: #fee;',
11073
+ textInputBackgroundColorHighlight: 'background-color: #fdeadc;',
11097
11074
  textInputColor: '#000',
11098
11075
  textInputColorPending: '#888',
11099
11076
  multilineTextInputStyle: 'font-size:100%; white-space: pre-wrap; background-color: #eef;' + ' border: 0.07em solid gray; padding: 1em 0.5em; margin: 1em 1em;',
@@ -14032,176 +14009,96 @@ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/r
14032
14009
  var debug = _interopRequireWildcard(__webpack_require__(/*! ../../debug */ "./lib/debug.js"));
14033
14010
  var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
14034
14011
  var ns = _interopRequireWildcard(__webpack_require__(/*! ../../ns */ "./lib/ns.js"));
14012
+ var _otherHelpers = __webpack_require__(/*! ./otherHelpers */ "./lib/utils/keyHelpers/otherHelpers.js");
14035
14013
  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); }
14036
14014
  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; }
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
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);
14057
14022
  }
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
- }();
14023
+ return url;
14024
+ };
14088
14025
  exports.pubKeyUrl = pubKeyUrl;
14089
- function getExistingPublicKey(_x2, _x3) {
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) {
14090
14038
  return _getExistingPublicKey.apply(this, arguments);
14091
14039
  }
14092
14040
  function _getExistingPublicKey() {
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) {
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) {
14096
14044
  case 0:
14097
- _context3.next = 2;
14045
+ _context.next = 2;
14098
14046
  return getKeyIfExists(webId, publicKeyUrl, 'publicKey');
14099
14047
  case 2:
14100
- return _context3.abrupt("return", _context3.sent);
14048
+ return _context.abrupt("return", _context.sent);
14101
14049
  case 3:
14102
14050
  case "end":
14103
- return _context3.stop();
14051
+ return _context.stop();
14104
14052
  }
14105
- }, _callee3);
14053
+ }, _callee);
14106
14054
  }));
14107
14055
  return _getExistingPublicKey.apply(this, arguments);
14108
14056
  }
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) {
14057
+ function getExistingPrivateKey(_x3, _x4) {
14137
14058
  return _getExistingPrivateKey.apply(this, arguments);
14138
14059
  }
14139
14060
  function _getExistingPrivateKey() {
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) {
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) {
14143
14064
  case 0:
14144
- _context4.next = 2;
14065
+ _context2.next = 2;
14145
14066
  return getKeyIfExists(webId, privateKeyUrl, 'privateKey');
14146
14067
  case 2:
14147
- return _context4.abrupt("return", _context4.sent);
14068
+ return _context2.abrupt("return", _context2.sent);
14148
14069
  case 3:
14149
14070
  case "end":
14150
- return _context4.stop();
14071
+ return _context2.stop();
14151
14072
  }
14152
- }, _callee4);
14073
+ }, _callee2);
14153
14074
  }));
14154
14075
  return _getExistingPrivateKey.apply(this, arguments);
14155
14076
  }
14156
- function getKeyIfExists(_x7, _x8, _x9) {
14077
+ function getKeyIfExists(_x5, _x6, _x7) {
14157
14078
  return _getKeyIfExists.apply(this, arguments);
14158
14079
  }
14159
14080
  function _getKeyIfExists() {
14160
- _getKeyIfExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(webId, keyUrl, keyType) {
14081
+ _getKeyIfExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId, keyUrl, keyType) {
14161
14082
  var key;
14162
- return _regenerator["default"].wrap(function _callee5$(_context5) {
14163
- while (1) switch (_context5.prev = _context5.next) {
14083
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
14084
+ while (1) switch (_context3.prev = _context3.next) {
14164
14085
  case 0:
14165
- _context5.prev = 0;
14166
- _context5.next = 3;
14086
+ _context3.prev = 0;
14087
+ _context3.next = 3;
14167
14088
  return _solidLogic.store.fetcher.load(keyUrl);
14168
14089
  case 3:
14169
14090
  key = _solidLogic.store.any(webId, ns.solid(keyType)); // store.sym(CERT + keyType))
14170
- return _context5.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
14091
+ return _context3.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
14171
14092
  case 7:
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:
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:
14201
14098
  case "end":
14202
- return _context5.stop();
14099
+ return _context3.stop();
14203
14100
  }
14204
- }, _callee5, null, [[0, 7], [11, 16]]);
14101
+ }, _callee3, null, [[0, 7]]);
14205
14102
  }));
14206
14103
  return _getKeyIfExists.apply(this, arguments);
14207
14104
  }
@@ -14312,6 +14209,39 @@ exports.keyAclBody = keyAclBody;
14312
14209
 
14313
14210
  /***/ }),
14314
14211
 
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
+
14315
14245
  /***/ "./lib/utils/label.js":
14316
14246
  /*!****************************!*\
14317
14247
  !*** ./lib/utils/label.js ***!
@@ -14440,8 +14370,8 @@ Object.defineProperty(exports, "__esModule", ({
14440
14370
  }));
14441
14371
  exports.versionInfo = void 0;
14442
14372
  var versionInfo = {
14443
- buildTime: '2023-05-31T16:12:20Z',
14444
- commit: 'a414b470667e6a4fec9865625b7724e091f58482',
14373
+ buildTime: '2023-06-06T09:58:11Z',
14374
+ commit: 'df3d943175afe78b5cfa7f13804ee7ff66055067',
14445
14375
  npmInfo: {
14446
14376
  'solid-ui': '2.4.28',
14447
14377
  npm: '8.19.4',