solid-ui 2.4.28-6a319caf → 2.4.28-7b1c0b2d

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.generateAndStorePublicKey = generateAndStorePublicKey;
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 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;
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 _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;
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 generateAndStorePublicKey(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
 
@@ -14324,8 +14368,8 @@ Object.defineProperty(exports, "__esModule", ({
14324
14368
  }));
14325
14369
  exports.versionInfo = void 0;
14326
14370
  var versionInfo = {
14327
- buildTime: '2023-06-03T23:48:25Z',
14328
- commit: '6a319caf69ef4ecc171a5adcb375dea108d002c2',
14371
+ buildTime: '2023-06-06T08:34:10Z',
14372
+ commit: '7b1c0b2d7ab8de07add05b789f87dfdbeb68b960',
14329
14373
  npmInfo: {
14330
14374
  'solid-ui': '2.4.28',
14331
14375
  npm: '8.19.4',