solid-ui 2.4.28-21f105c8 → 2.4.28-44bfba6e

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
@@ -4127,32 +4127,39 @@ function _infiniteMessageArea() {
4127
4127
  date = extremity.messageTable.date; // day in mssecs
4128
4128
  // Are we at the top of a thread?
4129
4129
  if (!(backwards && earliest.limit && date <= earliest.limit)) {
4130
- _context4.next = 4;
4130
+ _context4.next = 7;
4131
4131
  break;
4132
4132
  }
4133
+ if (liveMessageTable) {
4134
+ _context4.next = 6;
4135
+ break;
4136
+ }
4137
+ _context4.next = 6;
4138
+ return appendCurrentMessages();
4139
+ case 6:
4133
4140
  return _context4.abrupt("return", true);
4134
- case 4:
4141
+ case 7:
4135
4142
  debug.log(' insertPreviousMessages: loadPrevious given date ' + date);
4136
- _context4.next = 7;
4143
+ _context4.next = 10;
4137
4144
  return dateFolder.loadPrevious(date, backwards);
4138
- case 7:
4145
+ case 10:
4139
4146
  date = _context4.sent;
4140
4147
  // backwards
4141
4148
  debug.log(' insertPreviousMessages: loadPrevious returns date ' + date);
4142
4149
  debug.log("insertPreviousMessages: from ".concat(backwards ? 'backwards' : 'forwards', " loadPrevious: ").concat(date));
4143
4150
  if (!(!date && !backwards && !liveMessageTable)) {
4144
- _context4.next = 13;
4151
+ _context4.next = 16;
4145
4152
  break;
4146
4153
  }
4147
- _context4.next = 13;
4154
+ _context4.next = 16;
4148
4155
  return appendCurrentMessages();
4149
- case 13:
4156
+ case 16:
4150
4157
  if (date) {
4151
- _context4.next = 15;
4158
+ _context4.next = 18;
4152
4159
  break;
4153
4160
  }
4154
4161
  return _context4.abrupt("return", true);
4155
- case 15:
4162
+ case 18:
4156
4163
  // done
4157
4164
  live = false;
4158
4165
  if (!backwards) {
@@ -4160,9 +4167,9 @@ function _infiniteMessageArea() {
4160
4167
  doc = dateFolder.leafDocumentFromDate(date);
4161
4168
  live = doc.sameTerm(todayDoc); // Is this todays?
4162
4169
  }
4163
- _context4.next = 19;
4170
+ _context4.next = 22;
4164
4171
  return createMessageTable(date, live);
4165
- case 19:
4172
+ case 22:
4166
4173
  newMessageTable = _context4.sent;
4167
4174
  extremity.messageTable = newMessageTable; // move pointer to earliest
4168
4175
  if (backwards ? newestFirst : !newestFirst) {
@@ -4173,7 +4180,7 @@ function _infiniteMessageArea() {
4173
4180
  div.insertBefore(newMessageTable, div.firstChild);
4174
4181
  }
4175
4182
  return _context4.abrupt("return", live);
4176
- case 23:
4183
+ case 26:
4177
4184
  case "end":
4178
4185
  return _context4.stop();
4179
4186
  }
@@ -4408,10 +4415,13 @@ var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_m
4408
4415
  Object.defineProperty(exports, "__esModule", ({
4409
4416
  value: true
4410
4417
  }));
4418
+ exports.createAndSaveKeyPairs = createAndSaveKeyPairs;
4419
+ exports.generateAndStorePublicKey = generateAndStorePublicKey;
4411
4420
  exports.generatePrivateKey = generatePrivateKey;
4412
4421
  exports.generatePublicKey = generatePublicKey;
4413
4422
  exports.getPrivateKey = getPrivateKey;
4414
4423
  exports.getPublicKey = getPublicKey;
4424
+ exports.validPublicKey = validPublicKey;
4415
4425
  var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
4416
4426
  var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
4417
4427
  var debug = _interopRequireWildcard(__webpack_require__(/*! ../debug */ "./lib/debug.js"));
@@ -4447,109 +4457,150 @@ function _getPublicKey() {
4447
4457
  return _regenerator["default"].wrap(function _callee2$(_context2) {
4448
4458
  while (1) switch (_context2.prev = _context2.next) {
4449
4459
  case 0:
4450
- _context2.next = 2;
4460
+ _context2.prev = 0;
4461
+ _context2.next = 3;
4451
4462
  return _solidLogic.store.fetcher.load(webId);
4452
- case 2:
4453
- _context2.next = 4;
4463
+ case 3:
4464
+ _context2.next = 5;
4454
4465
  return (0, _accessData.pubKeyUrl)(webId);
4455
- case 4:
4466
+ case 5:
4456
4467
  publicKeyDoc = _context2.sent;
4457
- _context2.prev = 5;
4458
- _context2.next = 8;
4468
+ _context2.prev = 6;
4469
+ _context2.next = 9;
4459
4470
  return _solidLogic.store.fetcher.load(publicKeyDoc);
4460
- case 8:
4471
+ case 9:
4461
4472
  // url.href)
4462
4473
  key = _solidLogic.store.any(webId, ns.solid('publicKey'));
4463
4474
  return _context2.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
4464
- case 12:
4465
- _context2.prev = 12;
4466
- _context2.t0 = _context2["catch"](5);
4475
+ case 13:
4476
+ _context2.prev = 13;
4477
+ _context2.t0 = _context2["catch"](6);
4478
+ debug.error(_context2.t0);
4467
4479
  return _context2.abrupt("return", undefined);
4468
- 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:
4469
4489
  case "end":
4470
4490
  return _context2.stop();
4471
4491
  }
4472
- }, _callee2, null, [[5, 12]]);
4492
+ }, _callee2, null, [[0, 19], [6, 13]]);
4473
4493
  }));
4474
4494
  return _getPublicKey.apply(this, arguments);
4475
4495
  }
4476
- function getPrivateKey(_x2) {
4477
- 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;
4478
4501
  }
4479
- function _getPrivateKey() {
4480
- _getPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId) {
4481
- var publicKeyDoc, privateKeyDoc, publicKey, privateKey, validPublicKey, del, add, newPublicKey, keyContainer;
4502
+ function generateAndStorePublicKey(_x2, _x3, _x4, _x5) {
4503
+ return _generateAndStorePublicKey.apply(this, arguments);
4504
+ }
4505
+ function _generateAndStorePublicKey() {
4506
+ _generateAndStorePublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId, privateKey, publicKey, publicKeyDoc) {
4507
+ var del, newPublicKey, add;
4482
4508
  return _regenerator["default"].wrap(function _callee3$(_context3) {
4483
4509
  while (1) switch (_context3.prev = _context3.next) {
4484
4510
  case 0:
4485
- _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 _generateAndStorePublicKey.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 generateAndStorePublicKey(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;
4486
4560
  return _solidLogic.store.fetcher.load(webId);
4487
4561
  case 2:
4488
- _context3.next = 4;
4562
+ _context5.next = 4;
4489
4563
  return (0, _accessData.pubKeyUrl)(webId);
4490
4564
  case 4:
4491
- publicKeyDoc = _context3.sent;
4492
- _context3.next = 7;
4565
+ publicKeyDoc = _context5.sent;
4566
+ _context5.next = 7;
4493
4567
  return (0, _accessData.privKeyUrl)(webId);
4494
4568
  case 7:
4495
- privateKeyDoc = _context3.sent;
4496
- _context3.next = 10;
4569
+ privateKeyDoc = _context5.sent;
4570
+ _context5.next = 10;
4497
4571
  return (0, _accessData.getExistingPublicKey)(webId, publicKeyDoc);
4498
4572
  case 10:
4499
- publicKey = _context3.sent;
4500
- _context3.next = 13;
4573
+ publicKey = _context5.sent;
4574
+ _context5.next = 13;
4501
4575
  return (0, _accessData.getExistingPrivateKey)(webId, privateKeyDoc);
4502
4576
  case 13:
4503
- privateKey = _context3.sent;
4504
- // is publicKey valid ?
4505
- validPublicKey = true;
4506
- if (privateKey && publicKey !== generatePublicKey(privateKey)) {
4507
- 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;
4508
- }
4509
-
4510
- // create key pair or repair publicKey
4511
- if (!(!privateKey || !publicKey || !validPublicKey)) {
4512
- _context3.next = 34;
4513
- break;
4514
- }
4515
- del = [];
4516
- add = [];
4577
+ privateKey = _context5.sent;
4517
4578
  if (privateKey) {
4518
- _context3.next = 24;
4579
+ _context5.next = 18;
4519
4580
  break;
4520
4581
  }
4521
- // add = []
4522
- privateKey = generatePrivateKey();
4523
- add = [$rdf.st(webId, ns.solid('privateKey'), $rdf.literal(privateKey), _solidLogic.store.sym(privateKeyDoc))];
4524
- _context3.next = 24;
4525
- return saveKey(privateKeyDoc, [], add, webId.uri);
4526
- case 24:
4527
- if (!(!publicKey || !validPublicKey)) {
4528
- _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;
4529
4589
  break;
4530
4590
  }
4531
- del = [];
4532
- // delete invalid public key
4533
- if (publicKey) {
4534
- del = [$rdf.st(webId, ns.solid('publicKey'), $rdf.lit(publicKey), _solidLogic.store.sym(publicKeyDoc))];
4535
- debug.log(del);
4536
- }
4537
- // update new valid key
4538
- newPublicKey = generatePublicKey(privateKey);
4539
- add = [$rdf.st(webId, ns.solid('publicKey'), $rdf.literal(newPublicKey), _solidLogic.store.sym(publicKeyDoc))];
4540
- _context3.next = 31;
4541
- return saveKey(publicKeyDoc, del, add);
4542
- case 31:
4591
+ _context5.next = 21;
4592
+ return generateAndStorePublicKey(webId, privateKey, publicKey, publicKeyDoc);
4593
+ case 21:
4543
4594
  keyContainer = privateKeyDoc.substring(0, privateKeyDoc.lastIndexOf('/') + 1);
4544
- _context3.next = 34;
4595
+ _context5.next = 24;
4545
4596
  return (0, _acl.setAcl)(keyContainer, (0, _acl.keyContainerAclBody)(webId.uri));
4546
- case 34:
4547
- return _context3.abrupt("return", privateKey);
4548
- case 35:
4597
+ case 24:
4598
+ return _context5.abrupt("return", privateKey);
4599
+ case 25:
4549
4600
  case "end":
4550
- return _context3.stop();
4601
+ return _context5.stop();
4551
4602
  }
4552
- }, _callee3);
4603
+ }, _callee5);
4553
4604
  }));
4554
4605
  return _getPrivateKey.apply(this, arguments);
4555
4606
  }
@@ -4592,7 +4643,7 @@ var deleteKeyAcl = /*#__PURE__*/function () {
4592
4643
  }
4593
4644
  }, _callee, null, [[4, 11]]);
4594
4645
  }));
4595
- return function deleteKeyAcl(_x3) {
4646
+ return function deleteKeyAcl(_x11) {
4596
4647
  return _ref.apply(this, arguments);
4597
4648
  };
4598
4649
  }();
@@ -4602,36 +4653,36 @@ var deleteKeyAcl = /*#__PURE__*/function () {
4602
4653
  * create/edit keyDoc
4603
4654
  * set keyDoc acl
4604
4655
  */
4605
- function saveKey(_x4, _x5, _x6) {
4606
- return _saveKey.apply(this, arguments);
4656
+ function saveKeyAndHandleAcl(_x12, _x13, _x14) {
4657
+ return _saveKeyAndHandleAcl.apply(this, arguments);
4607
4658
  }
4608
- function _saveKey() {
4609
- _saveKey = (0, _asyncToGenerator2["default"])(function (keyDoc, del, add) {
4659
+ function _saveKeyAndHandleAcl() {
4660
+ _saveKeyAndHandleAcl = (0, _asyncToGenerator2["default"])(function (keyDoc, del, add) {
4610
4661
  var me = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
4611
- return /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
4662
+ return /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
4612
4663
  var aclBody;
4613
- return _regenerator["default"].wrap(function _callee4$(_context4) {
4614
- while (1) switch (_context4.prev = _context4.next) {
4664
+ return _regenerator["default"].wrap(function _callee6$(_context6) {
4665
+ while (1) switch (_context6.prev = _context6.next) {
4615
4666
  case 0:
4616
- _context4.next = 2;
4667
+ _context6.next = 2;
4617
4668
  return deleteKeyAcl(keyDoc);
4618
4669
  case 2:
4619
- _context4.next = 4;
4670
+ _context6.next = 4;
4620
4671
  return _solidLogic.store.updater.updateMany(del, add);
4621
4672
  case 4:
4622
4673
  // or a promise store.updater.update ?
4623
4674
  // create READ only ACL
4624
4675
  aclBody = (0, _acl.keyAclBody)(keyDoc, me);
4625
- _context4.next = 7;
4676
+ _context6.next = 7;
4626
4677
  return (0, _acl.setAcl)(keyDoc, aclBody);
4627
4678
  case 7:
4628
4679
  case "end":
4629
- return _context4.stop();
4680
+ return _context6.stop();
4630
4681
  }
4631
- }, _callee4);
4682
+ }, _callee6);
4632
4683
  })();
4633
4684
  });
4634
- return _saveKey.apply(this, arguments);
4685
+ return _saveKeyAndHandleAcl.apply(this, arguments);
4635
4686
  }
4636
4687
  //# sourceMappingURL=keys.js.map
4637
4688
 
@@ -4848,13 +4899,13 @@ function _renderMessageRow() {
4848
4899
  if (straightReplies.length > 1) {
4849
4900
  debug.log('renderMessageRow: found normal replies: ', straightReplies);
4850
4901
  }
4851
- debug.log('@@@@ alain thread');
4852
- // debug.log(replies)
4853
- // debug.log(thread)
4854
- thread = _solidLogic.store.any(msgId, ns.sioc('has_reply')); // if (!thread)
4855
- debug.log(thread);
4902
+ debug.log('@@@@ is thread');
4903
+ if (!thread) {
4904
+ // thread = store.any(message, ns.sioc('has_reply'))
4905
+ thread = _solidLogic.store.any(null, ns.sioc('has_member'), message);
4906
+ }
4856
4907
  // get signature
4857
- signature = _solidLogic.store.any(msgId, $rdf.sym("".concat(_signature.SEC, "proofValue"))); // set message object
4908
+ signature = _solidLogic.store.any(msgId, $rdf.sym("".concat(_signature.SEC, "proofValue"))); // set proof message object
4858
4909
  msg = (0, _signature.getBlankMsg)();
4859
4910
  msg.id = msgId.uri;
4860
4911
  msg.created = _solidLogic.store.any(msgId, ns.dct('created')).value;
@@ -4880,9 +4931,9 @@ function _renderMessageRow() {
4880
4931
  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);
4881
4932
  });
4882
4933
  }
4883
- _context10.next = 39;
4934
+ _context10.next = 38;
4884
4935
  return (0, _chatLogic.originalVersion)(message);
4885
- case 39:
4936
+ case 38:
4886
4937
  originalMessage = _context10.sent;
4887
4938
  edited = !message.sameTerm(originalMessage); // @@ load it first @@ Or display the new data at the old date.
4888
4939
  // @@@ kludge!
@@ -4939,9 +4990,9 @@ function _renderMessageRow() {
4939
4990
  bgcolor = colorizeByAuthor ? pad.lightColorHash(creator) : getBgColor(fresh);
4940
4991
  para.setAttribute('style', messageBodyStyle + 'background-color: ' + bgcolor + ';');
4941
4992
  }
4942
- _context10.next = 60;
4993
+ _context10.next = 59;
4943
4994
  return (0, _messageTools.sentimentStripLinked)(message, message.doc());
4944
- case 60:
4995
+ case 59:
4945
4996
  strip = _context10.sent;
4946
4997
  if (strip.children.length) {
4947
4998
  td2.appendChild(dom.createElement('br'));
@@ -5006,7 +5057,7 @@ function _renderMessageRow() {
5006
5057
  }));
5007
5058
  }
5008
5059
  return _context10.abrupt("return", messageRow);
5009
- case 69:
5060
+ case 68:
5010
5061
  case "end":
5011
5062
  return _context10.stop();
5012
5063
  }
@@ -5946,96 +5997,27 @@ exports.verifySignature = verifySignature;
5946
5997
  var _secp256k = __webpack_require__(/*! @noble/curves/secp256k1 */ "./node_modules/@noble/curves/secp256k1.js");
5947
5998
  var _utils = __webpack_require__(/*! @noble/hashes/utils */ "./node_modules/@noble/hashes/utils.js");
5948
5999
  var _sha = __webpack_require__(/*! @noble/hashes/sha256 */ "./node_modules/@noble/hashes/sha256.js");
5949
- // import {utf8Encoder} from './utils'
5950
- // import { getPublicKey } from './keys'
5951
-
5952
6000
  var utf8Decoder = new TextDecoder('utf-8');
5953
6001
  exports.utf8Decoder = utf8Decoder;
5954
6002
  var utf8Encoder = new TextEncoder();
5955
6003
  exports.utf8Encoder = utf8Encoder;
5956
6004
  var SEC = 'https://w3id.org/security#'; // Proof, VerificationMethod
5957
- // export const CERT = 'http://www.w3.org/ns/auth/cert#' // PrivateKey, PublicKey, key
5958
-
5959
- /* eslint-disable no-unused-vars */
5960
- /* export enum Kind {
5961
- Metadata = 0,
5962
- Text = 1,
5963
- RecommendRelay = 2,
5964
- Contacts = 3,
5965
- EncryptedDirectMessage = 4,
5966
- EventDeletion = 5,
5967
- Reaction = 7,
5968
- BadgeAward = 8,
5969
- ChannelCreation = 40,
5970
- ChannelMetadata = 41,
5971
- ChannelMessage = 42,
5972
- ChannelHideMessage = 43,
5973
- ChannelMuteUser = 44,
5974
- Report = 1984,
5975
- ZapRequest = 9734,
5976
- Zap = 9735,
5977
- RelayList = 10002,
5978
- ClientAuth = 22242,
5979
- BadgeDefinition = 30008,
5980
- ProfileBadge = 30009,
5981
- Article = 30023
5982
- } */
5983
6005
  exports.SEC = SEC;
5984
6006
  function getBlankMsg() {
5985
6007
  return {
5986
6008
  id: '',
5987
6009
  created: '',
5988
- dateDeleted: '',
5989
- // TODO to remove if not used
5990
6010
  content: '',
5991
- maker: '',
5992
- sig: '' // TODO to remove if not used
6011
+ maker: ''
5993
6012
  };
5994
6013
  }
5995
-
5996
- /* export function finishMsg (t: MsgTemplate, privateKey: string): Message {
5997
- // to update to chat message triples
5998
- const message = t as Message
5999
- // message.pubkey = getPublicKey(privateKey)
6000
- message.id = getMsgHash(message)
6001
- message.sig = signMsg(message, privateKey)
6002
- return message
6003
- } */
6004
-
6005
6014
  function serializeMsg(msg) {
6006
- // to update to chat messages triples
6007
- /* if (!validateMsg(msg))
6008
- throw new Error("can't serialize message with wrong or missing properties") */
6009
-
6010
6015
  return JSON.stringify(msg);
6011
6016
  }
6012
6017
  function getMsgHash(message) {
6013
6018
  var msgHash = (0, _sha.sha256)(utf8Encoder.encode(serializeMsg(message)));
6014
6019
  return (0, _utils.bytesToHex)(msgHash);
6015
6020
  }
6016
-
6017
- // const isRecord = (obj: unknown): obj is Record<string, unknown> => obj instanceof Object
6018
-
6019
- /* export function validateMsg<T> (message: T): message is T & UnsignedMsg {
6020
- if (!isRecord(message)) return false
6021
- if (typeof message.kind !== 'number') return false
6022
- if (typeof message.content !== 'string') return false
6023
- if (typeof message.created_at !== 'number') return false
6024
- if (typeof message.pubkey !== 'string') return false
6025
- if (!message.pubkey.match(/^[a-f0-9]{64}$/)) return false
6026
-
6027
- if (!Array.isArray(message.tags)) return false
6028
- for (let i = 0; i < message.tags.length; i++) {
6029
- let tag = message.tags[i]
6030
- if (!Array.isArray(tag)) return false
6031
- for (let j = 0; j < tag.length; j++) {
6032
- if (typeof tag[j] === 'object') return false
6033
- }
6034
- }
6035
-
6036
- return true
6037
- } */
6038
-
6039
6021
  function verifySignature(sig, message, pubKey) {
6040
6022
  return _secp256k.schnorr.verify(sig, getMsgHash(message), pubKey);
6041
6023
  }
@@ -14025,176 +14007,96 @@ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/r
14025
14007
  var debug = _interopRequireWildcard(__webpack_require__(/*! ../../debug */ "./lib/debug.js"));
14026
14008
  var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
14027
14009
  var ns = _interopRequireWildcard(__webpack_require__(/*! ../../ns */ "./lib/ns.js"));
14010
+ var _otherHelpers = __webpack_require__(/*! ./otherHelpers */ "./lib/utils/keyHelpers/otherHelpers.js");
14028
14011
  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); }
14029
14012
  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; }
14030
- /* export const getPodRoot = async (webId: NamedNode) => {
14031
- const webIdURL = new URL(webId.uri)
14032
- // find storages in webId document
14033
- await store.fetcher.load(webId.uri)
14034
- const storages = store.each(webId, ns.space('storage'), null, webId.doc())
14035
- var podRoot: NamedNode | undefined
14036
- if (!storages?.length) {
14037
- // find storage recursively in webId URL
14038
- let path = webIdURL.pathname
14039
- while (path.length) {
14040
- path = path.substring(0, path.lastIndexOf('/'))
14041
- podRoot = store.sym(webIdURL.origin + path + '/')
14042
- const res = await store.fetcher.webOperation('HEAD', podRoot.uri)
14043
- if (res.headers.get('link')?.includes(ns.space('Storage').value)) break
14044
- if (!path) debug.warn(`Current user storage not found for\n${webId}`)
14045
- }
14046
- } else {
14047
- // give preference to storage in webId root
14048
- podRoot = storages.find((storage) => webIdURL.origin === new URL(storage.value).origin) as NamedNode
14049
- if (!podRoot) podRoot = storages[0] as NamedNode
14013
+ var pubKeyUrl = function pubKeyUrl(webId) {
14014
+ var url;
14015
+ try {
14016
+ var root = (0, _otherHelpers.getRootIfPreferencesExist)(webId);
14017
+ url = "".concat(root, "/profile/keys/publicKey.ttl");
14018
+ } catch (err) {
14019
+ debug.error(err);
14050
14020
  }
14051
-
14052
- return podRoot as NamedNode
14053
- } */
14054
-
14055
- var pubKeyUrl = /*#__PURE__*/function () {
14056
- var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
14057
- var _store$any, _parentSettings;
14058
- var parentSettings;
14059
- return _regenerator["default"].wrap(function _callee$(_context) {
14060
- while (1) switch (_context.prev = _context.next) {
14061
- case 0:
14062
- parentSettings = (_store$any = _solidLogic.store.any(webId, ns.space('preferencesFile'), null, webId.doc())) === null || _store$any === void 0 ? void 0 : _store$any.value;
14063
- parentSettings = (_parentSettings = parentSettings) === null || _parentSettings === void 0 ? void 0 : _parentSettings.split('/').slice(0, -2).join('/');
14064
- if (parentSettings) {
14065
- _context.next = 4;
14066
- break;
14067
- }
14068
- throw new Error("prefererencesFile is expected to exist in ".concat(webId.doc));
14069
- case 4:
14070
- return _context.abrupt("return", "".concat(parentSettings, "/profile/keys/publicKey.ttl"));
14071
- case 5:
14072
- case "end":
14073
- return _context.stop();
14074
- }
14075
- }, _callee);
14076
- }));
14077
- return function pubKeyUrl(_x) {
14078
- return _ref.apply(this, arguments);
14079
- };
14080
- }();
14021
+ return url;
14022
+ };
14081
14023
  exports.pubKeyUrl = pubKeyUrl;
14082
- function getExistingPublicKey(_x2, _x3) {
14024
+ var privKeyUrl = function privKeyUrl(webId) {
14025
+ var url;
14026
+ try {
14027
+ var root = (0, _otherHelpers.getRootIfPreferencesExist)(webId);
14028
+ url = "".concat(root, "/keys/privateKey.ttl");
14029
+ } catch (err) {
14030
+ debug.error(err);
14031
+ }
14032
+ return url;
14033
+ };
14034
+ exports.privKeyUrl = privKeyUrl;
14035
+ function getExistingPublicKey(_x, _x2) {
14083
14036
  return _getExistingPublicKey.apply(this, arguments);
14084
14037
  }
14085
14038
  function _getExistingPublicKey() {
14086
- _getExistingPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId, publicKeyUrl) {
14087
- return _regenerator["default"].wrap(function _callee3$(_context3) {
14088
- while (1) switch (_context3.prev = _context3.next) {
14039
+ _getExistingPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId, publicKeyUrl) {
14040
+ return _regenerator["default"].wrap(function _callee$(_context) {
14041
+ while (1) switch (_context.prev = _context.next) {
14089
14042
  case 0:
14090
- _context3.next = 2;
14043
+ _context.next = 2;
14091
14044
  return getKeyIfExists(webId, publicKeyUrl, 'publicKey');
14092
14045
  case 2:
14093
- return _context3.abrupt("return", _context3.sent);
14046
+ return _context.abrupt("return", _context.sent);
14094
14047
  case 3:
14095
14048
  case "end":
14096
- return _context3.stop();
14049
+ return _context.stop();
14097
14050
  }
14098
- }, _callee3);
14051
+ }, _callee);
14099
14052
  }));
14100
14053
  return _getExistingPublicKey.apply(this, arguments);
14101
14054
  }
14102
- var privKeyUrl = /*#__PURE__*/function () {
14103
- var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
14104
- var _store$any2, _settings;
14105
- var settings;
14106
- return _regenerator["default"].wrap(function _callee2$(_context2) {
14107
- while (1) switch (_context2.prev = _context2.next) {
14108
- case 0:
14109
- settings = (_store$any2 = _solidLogic.store.any(webId, ns.space('preferencesFile'), null, webId.doc())) === null || _store$any2 === void 0 ? void 0 : _store$any2.value;
14110
- settings = (_settings = settings) === null || _settings === void 0 ? void 0 : _settings.split('/').slice(0, -1).join('/');
14111
- if (settings) {
14112
- _context2.next = 4;
14113
- break;
14114
- }
14115
- throw new Error("prefererencesFile is expected to exist in ".concat(webId.doc));
14116
- case 4:
14117
- return _context2.abrupt("return", "".concat(settings, "/keys/privateKey.ttl"));
14118
- case 5:
14119
- case "end":
14120
- return _context2.stop();
14121
- }
14122
- }, _callee2);
14123
- }));
14124
- return function privKeyUrl(_x4) {
14125
- return _ref2.apply(this, arguments);
14126
- };
14127
- }();
14128
- exports.privKeyUrl = privKeyUrl;
14129
- function getExistingPrivateKey(_x5, _x6) {
14055
+ function getExistingPrivateKey(_x3, _x4) {
14130
14056
  return _getExistingPrivateKey.apply(this, arguments);
14131
14057
  }
14132
14058
  function _getExistingPrivateKey() {
14133
- _getExistingPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(webId, privateKeyUrl) {
14134
- return _regenerator["default"].wrap(function _callee4$(_context4) {
14135
- while (1) switch (_context4.prev = _context4.next) {
14059
+ _getExistingPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId, privateKeyUrl) {
14060
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
14061
+ while (1) switch (_context2.prev = _context2.next) {
14136
14062
  case 0:
14137
- _context4.next = 2;
14063
+ _context2.next = 2;
14138
14064
  return getKeyIfExists(webId, privateKeyUrl, 'privateKey');
14139
14065
  case 2:
14140
- return _context4.abrupt("return", _context4.sent);
14066
+ return _context2.abrupt("return", _context2.sent);
14141
14067
  case 3:
14142
14068
  case "end":
14143
- return _context4.stop();
14069
+ return _context2.stop();
14144
14070
  }
14145
- }, _callee4);
14071
+ }, _callee2);
14146
14072
  }));
14147
14073
  return _getExistingPrivateKey.apply(this, arguments);
14148
14074
  }
14149
- function getKeyIfExists(_x7, _x8, _x9) {
14075
+ function getKeyIfExists(_x5, _x6, _x7) {
14150
14076
  return _getKeyIfExists.apply(this, arguments);
14151
14077
  }
14152
14078
  function _getKeyIfExists() {
14153
- _getKeyIfExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(webId, keyUrl, keyType) {
14079
+ _getKeyIfExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId, keyUrl, keyType) {
14154
14080
  var key;
14155
- return _regenerator["default"].wrap(function _callee5$(_context5) {
14156
- while (1) switch (_context5.prev = _context5.next) {
14081
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
14082
+ while (1) switch (_context3.prev = _context3.next) {
14157
14083
  case 0:
14158
- _context5.prev = 0;
14159
- _context5.next = 3;
14084
+ _context3.prev = 0;
14085
+ _context3.next = 3;
14160
14086
  return _solidLogic.store.fetcher.load(keyUrl);
14161
14087
  case 3:
14162
14088
  key = _solidLogic.store.any(webId, ns.solid(keyType)); // store.sym(CERT + keyType))
14163
- return _context5.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
14089
+ return _context3.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
14164
14090
  case 7:
14165
- _context5.prev = 7;
14166
- _context5.t0 = _context5["catch"](0);
14167
- if (!(_context5.t0.response.status === 404)) {
14168
- _context5.next = 24;
14169
- break;
14170
- }
14171
- debug.log('createIfNotExists: doc does NOT exist, will create... ' + keyUrl);
14172
- _context5.prev = 11;
14173
- _context5.next = 14;
14174
- return _solidLogic.store.fetcher.webOperation('PUT', keyUrl, {
14175
- data: '',
14176
- contentType: 'text/turtle'
14177
- });
14178
- case 14:
14179
- _context5.next = 20;
14180
- break;
14181
- case 16:
14182
- _context5.prev = 16;
14183
- _context5.t1 = _context5["catch"](11);
14184
- debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context5.t1);
14185
- throw _context5.t1;
14186
- case 20:
14187
- delete _solidLogic.store.fetcher.requested[keyUrl]; // delete cached 404 error
14188
- // debug.log('createIfNotExists doc created ok ' + doc)
14189
- return _context5.abrupt("return", undefined);
14190
- case 24:
14191
- debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context5.t0);
14192
- throw _context5.t0;
14193
- case 26:
14091
+ _context3.prev = 7;
14092
+ _context3.t0 = _context3["catch"](0);
14093
+ debug.error('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context3.t0);
14094
+ return _context3.abrupt("return", undefined);
14095
+ case 11:
14194
14096
  case "end":
14195
- return _context5.stop();
14097
+ return _context3.stop();
14196
14098
  }
14197
- }, _callee5, null, [[0, 7], [11, 16]]);
14099
+ }, _callee3, null, [[0, 7]]);
14198
14100
  }));
14199
14101
  return _getKeyIfExists.apply(this, arguments);
14200
14102
  }
@@ -14305,6 +14207,39 @@ exports.keyAclBody = keyAclBody;
14305
14207
 
14306
14208
  /***/ }),
14307
14209
 
14210
+ /***/ "./lib/utils/keyHelpers/otherHelpers.js":
14211
+ /*!**********************************************!*\
14212
+ !*** ./lib/utils/keyHelpers/otherHelpers.js ***!
14213
+ \**********************************************/
14214
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
14215
+
14216
+ "use strict";
14217
+
14218
+
14219
+ var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
14220
+ Object.defineProperty(exports, "__esModule", ({
14221
+ value: true
14222
+ }));
14223
+ exports.getRootIfPreferencesExist = void 0;
14224
+ var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
14225
+ var ns = _interopRequireWildcard(__webpack_require__(/*! ../../ns */ "./lib/ns.js"));
14226
+ 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); }
14227
+ 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; }
14228
+ // Will rename this file later. We will probably be using solid-logic anyway
14229
+ // moved it out so I can mock
14230
+
14231
+ var getRootIfPreferencesExist = function getRootIfPreferencesExist(webId) {
14232
+ var _store$any, _root;
14233
+ var root = (_store$any = _solidLogic.store.any(webId, ns.space('preferencesFile'), null, webId.doc())) === null || _store$any === void 0 ? void 0 : _store$any.value;
14234
+ root = (_root = root) === null || _root === void 0 ? void 0 : _root.split('/').slice(0, -2).join('/');
14235
+ if (!root) throw new Error("prefererencesFile is expected to exist in ".concat(webId));
14236
+ return root;
14237
+ };
14238
+ exports.getRootIfPreferencesExist = getRootIfPreferencesExist;
14239
+ //# sourceMappingURL=otherHelpers.js.map
14240
+
14241
+ /***/ }),
14242
+
14308
14243
  /***/ "./lib/utils/label.js":
14309
14244
  /*!****************************!*\
14310
14245
  !*** ./lib/utils/label.js ***!
@@ -14433,8 +14368,8 @@ Object.defineProperty(exports, "__esModule", ({
14433
14368
  }));
14434
14369
  exports.versionInfo = void 0;
14435
14370
  var versionInfo = {
14436
- buildTime: '2023-05-29T17:22:09Z',
14437
- commit: '21f105c85cf152232421970c17d78f5c8cfa3d20',
14371
+ buildTime: '2023-06-06T08:34:20Z',
14372
+ commit: '44bfba6e5d833499af54ef66004e9ada0cd53220',
14438
14373
  npmInfo: {
14439
14374
  'solid-ui': '2.4.28',
14440
14375
  npm: '8.19.4',