solid-ui 2.4.27-20175fe3 → 2.4.27-2910a831

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
@@ -4043,6 +4043,7 @@ var _utils = __webpack_require__(/*! @noble/hashes/utils */ "./node_modules/@nob
4043
4043
  var _signature = __webpack_require__(/*! ./signature */ "./lib/chat/signature.js");
4044
4044
  var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
4045
4045
  var $rdf = _interopRequireWildcard(__webpack_require__(/*! rdflib */ "./node_modules/rdflib/esm/index.js"));
4046
+ var _cryptoKeyHelpers = __webpack_require__(/*! ../utils/cryptoKeyHelpers */ "./lib/utils/cryptoKeyHelpers.js");
4046
4047
  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); }
4047
4048
  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; }
4048
4049
  function generatePrivateKey() {
@@ -4052,103 +4053,31 @@ function generatePublicKey(privateKey) {
4052
4053
  return (0, _utils.bytesToHex)(_secp256k.schnorr.getPublicKey(privateKey));
4053
4054
  }
4054
4055
  function getPublicKey(webId) {
4055
- var publicKey = publicKeyExists(webId);
4056
+ var publicKey = (0, _cryptoKeyHelpers.publicKeyExists)(webId);
4056
4057
  return publicKey;
4057
4058
  }
4058
- function publicKeyExists(webId) {
4059
- // find publickey
4060
- var url = new URL(webId);
4061
- url.hash = '';
4062
- /* debug.warn('Alain publicKeyExists')
4063
- debug.warn(webId)
4064
- debug.warn(url.href) */
4065
- _solidLogic.store.fetcher.load(url.href);
4066
- var publicKey = _solidLogic.store.any(_solidLogic.store.sym(webId), _solidLogic.store.sym(_signature.CERT + 'PublicKey'));
4067
- return publicKey === null || publicKey === void 0 ? void 0 : publicKey.value; // as NamedNode
4068
- }
4069
-
4070
- var privKeyUrl = function privKeyUrl(webId) {
4071
- var url = new URL(webId);
4072
- var privateKeyUrl = url.protocol + '//' + url.host + '/profile/privateKey.ttl';
4073
- return privateKeyUrl;
4074
- };
4075
- function privateKeyExists(_x) {
4076
- return _privateKeyExists.apply(this, arguments);
4059
+ function getPrivateKey(_x) {
4060
+ return _getPrivateKey.apply(this, arguments);
4077
4061
  }
4078
- function _privateKeyExists() {
4079
- _privateKeyExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
4080
- var privateKeyUrl, privateKey, _err$response, data, contentType, response;
4062
+ function _getPrivateKey() {
4063
+ _getPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
4064
+ var publicKeyUrl, privateKeyUrl, publicKey, privateKey, del, add;
4081
4065
  return _regenerator["default"].wrap(function _callee$(_context) {
4082
4066
  while (1) switch (_context.prev = _context.next) {
4083
4067
  case 0:
4084
4068
  /* const url = new URL(webId)
4085
- const privateKeyUrl = url.protocol + '//' + url.host + '/profile/privateKey.ttl' */
4086
- privateKeyUrl = privKeyUrl(webId);
4087
- /* debug.warn('Alain privateKeyExists')
4088
- debug.warn(webId)
4089
- debug.warn(privateKeyUrl) */
4090
- _context.prev = 1;
4091
- _solidLogic.store.fetcher.load(privateKeyUrl);
4092
- privateKey = _solidLogic.store.any(_solidLogic.store.sym(webId), _solidLogic.store.sym(_signature.CERT + 'PrivateKey'));
4093
- return _context.abrupt("return", privateKey === null || privateKey === void 0 ? void 0 : privateKey.value);
4094
- case 7:
4095
- _context.prev = 7;
4096
- _context.t0 = _context["catch"](1);
4097
- if (!((_context.t0 === null || _context.t0 === void 0 ? void 0 : (_err$response = _context.t0.response) === null || _err$response === void 0 ? void 0 : _err$response.status) === 404)) {
4098
- _context.next = 24;
4099
- break;
4100
- }
4101
- _context.prev = 10;
4102
- // create privateKey resource
4103
- data = '';
4104
- contentType = 'text/ttl';
4105
- _context.next = 15;
4106
- return _solidLogic.store.fetcher.webOperation('PUT', privateKeyUrl, {
4107
- data: data,
4108
- contentType: contentType
4109
- });
4110
- case 15:
4111
- response = _context.sent;
4112
- _context.next = 22;
4113
- break;
4114
- case 18:
4115
- _context.prev = 18;
4116
- _context.t1 = _context["catch"](10);
4117
- debug.log('createIfNotExists doc FAILED: ' + privateKeyUrl + ': ' + _context.t1);
4118
- throw _context.t1;
4119
- case 22:
4120
- delete _solidLogic.store.fetcher.requested[privateKeyUrl]; // delete cached 404 error
4121
- return _context.abrupt("return", undefined);
4122
- case 24:
4123
- debug.log('createIfNotExists doc FAILED: ' + privateKeyUrl + ': ' + _context.t0);
4124
- throw _context.t0;
4125
- case 26:
4126
- case "end":
4127
- return _context.stop();
4128
- }
4129
- }, _callee, null, [[1, 7], [10, 18]]);
4130
- }));
4131
- return _privateKeyExists.apply(this, arguments);
4132
- }
4133
- function getPrivateKey(_x2) {
4134
- return _getPrivateKey.apply(this, arguments);
4135
- }
4136
- function _getPrivateKey() {
4137
- _getPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
4138
- var url, privateKeyUrl, publicKey, privateKey, del, add;
4139
- return _regenerator["default"].wrap(function _callee2$(_context2) {
4140
- while (1) switch (_context2.prev = _context2.next) {
4141
- case 0:
4142
- url = new URL(webId);
4143
- url.hash = '';
4069
+ url.hash = '' */
4144
4070
  /* const privateKeyUrl = url.protocol + '//' + url.host + '/profile/privateKey.ttl' */
4145
- privateKeyUrl = privKeyUrl(webId); // find publickey
4146
- publicKey = publicKeyExists(webId); // debug.warn('publicKey ' + publicKey)
4147
- // find privateKey
4148
- _context2.next = 6;
4149
- return privateKeyExists(webId);
4150
- case 6:
4151
- privateKey = _context2.sent;
4071
+ publicKeyUrl = (0, _cryptoKeyHelpers.pubKeyUrl)(webId);
4072
+ privateKeyUrl = (0, _cryptoKeyHelpers.privKeyUrl)(webId); // find publickey
4073
+ _context.next = 4;
4074
+ return (0, _cryptoKeyHelpers.publicKeyExists)(webId);
4075
+ case 4:
4076
+ publicKey = _context.sent;
4077
+ _context.next = 7;
4078
+ return (0, _cryptoKeyHelpers.privateKeyExists)(webId);
4079
+ case 7:
4080
+ privateKey = _context.sent;
4152
4081
  // debug.warn('privateKey ' + privateKey)
4153
4082
  if (privateKey && publicKey !== generatePublicKey(privateKey)) debug.warn('publicKey is not valid');
4154
4083
 
@@ -4160,28 +4089,28 @@ function _getPrivateKey() {
4160
4089
 
4161
4090
  // create key pair
4162
4091
  if (!(!privateKey || !publicKey)) {
4163
- _context2.next = 19;
4092
+ _context.next = 20;
4164
4093
  break;
4165
4094
  }
4166
4095
  del = [];
4167
4096
  add = [];
4168
4097
  if (privateKey) del.push($rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'PrivateKey'), $rdf.lit(privateKey), $rdf.sym(privateKeyUrl)));
4169
- if (publicKey) del.push($rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'PublicKey'), $rdf.lit(publicKey), $rdf.sym(url.href)));
4098
+ if (publicKey) del.push($rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'PublicKey'), $rdf.lit(publicKey), $rdf.sym(publicKeyUrl)));
4170
4099
  privateKey = generatePrivateKey();
4171
4100
  publicKey = generatePublicKey(privateKey);
4172
4101
  /* debug.log('newPrivateKey-1 ' + privateKey)
4173
4102
  debug.log('newPublicKey-1 ' + publicKey) */
4174
4103
  add.push($rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'PrivateKey'), $rdf.literal(privateKey), $rdf.sym(privateKeyUrl)));
4175
- add.push($rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'PublicKey'), $rdf.literal(publicKey), $rdf.sym(url.href)));
4176
- _context2.next = 19;
4104
+ add.push($rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'PublicKey'), $rdf.literal(publicKey), $rdf.sym(publicKeyUrl)));
4105
+ _context.next = 20;
4177
4106
  return _solidLogic.store.updater.updateMany(del, add);
4178
- case 19:
4179
- return _context2.abrupt("return", privateKey);
4180
4107
  case 20:
4108
+ return _context.abrupt("return", privateKey);
4109
+ case 21:
4181
4110
  case "end":
4182
- return _context2.stop();
4111
+ return _context.stop();
4183
4112
  }
4184
- }, _callee2);
4113
+ }, _callee);
4185
4114
  }));
4186
4115
  return _getPrivateKey.apply(this, arguments);
4187
4116
  }
@@ -4315,7 +4244,7 @@ function renderMessageRow(channelObject, message, fresh, options, userContext) {
4315
4244
  var latestVersion = (0, _chatLogic.mostRecentVersion)(message);
4316
4245
  var latestVersionCreator = _solidLogic.store.any(latestVersion, ns.foaf('maker'));
4317
4246
  // use latest content if same owner, else use original
4318
- var msgId = creator === latestVersionCreator ? latestVersion : message;
4247
+ var msgId = creator.uri === latestVersionCreator.uri ? latestVersion : message;
4319
4248
  var content = _solidLogic.store.any(msgId, ns.sioc('content'));
4320
4249
  var signature = _solidLogic.store.any(msgId, $rdf.sym("".concat(_signature.SEC, "Proof")));
4321
4250
  debug.log('alain ' + (signature === null || signature === void 0 ? void 0 : signature.value));
@@ -4326,9 +4255,23 @@ function renderMessageRow(channelObject, message, fresh, options, userContext) {
4326
4255
  msg.created = _solidLogic.store.any(msgId, ns.dct('created')).value;
4327
4256
  msg.content = content.value;
4328
4257
  msg.maker = creator.uri;
4258
+ try {
4259
+ var publicKey = function publicKey(webId) {
4260
+ var pubKey;
4261
+ (0, _keys.getPublicKey)(webId).then(function (publicKey) {
4262
+ debug.log('alain publicKey ' + publicKey);
4263
+ pubKey = publicKey;
4264
+ });
4265
+ return pubKey;
4266
+ };
4267
+ var pubKey = publicKey(creator.uri); // await getPublicKey(creator.uri)
4268
+ debug.log('alain pubKey ' + pubKey);
4269
+ debug.log(creator.uri);
4270
+ } catch (err) {
4271
+ debug.warn(err);
4272
+ }
4329
4273
  try {
4330
4274
  // pubKey could be store in a cache for all makers
4331
- var pubKey = (0, _keys.getPublicKey)(creator.uri);
4332
4275
  /* const pubKey0 = '023a9da707bee1302f66083c9d95673ff969b41607a66f52686fa774d64ceb87'
4333
4276
  debug.warn('publicKeys\n' + pubKey0 + '\n' + pubKey)
4334
4277
  const privKey0 = getPrivateKey(creator.uri) // alain to remove
@@ -12439,6 +12382,130 @@ function isLight(x) {
12439
12382
 
12440
12383
  /***/ }),
12441
12384
 
12385
+ /***/ "./lib/utils/cryptoKeyHelpers.js":
12386
+ /*!***************************************!*\
12387
+ !*** ./lib/utils/cryptoKeyHelpers.js ***!
12388
+ \***************************************/
12389
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
12390
+
12391
+ "use strict";
12392
+
12393
+
12394
+ var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");
12395
+ var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
12396
+ Object.defineProperty(exports, "__esModule", ({
12397
+ value: true
12398
+ }));
12399
+ exports.privKeyUrl = void 0;
12400
+ exports.privateKeyExists = privateKeyExists;
12401
+ exports.pubKeyUrl = void 0;
12402
+ exports.publicKeyExists = publicKeyExists;
12403
+ var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
12404
+ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
12405
+ var debug = _interopRequireWildcard(__webpack_require__(/*! ../debug */ "./lib/debug.js"));
12406
+ var _signature = __webpack_require__(/*! ../chat/signature */ "./lib/chat/signature.js");
12407
+ var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
12408
+ 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); }
12409
+ 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; }
12410
+ var pubKeyUrl = function pubKeyUrl(webId) {
12411
+ var url = new URL(webId);
12412
+ var publicKeyUrl = url.origin + '/profile/keys/publicKey.ttl';
12413
+ return publicKeyUrl;
12414
+ };
12415
+ exports.pubKeyUrl = pubKeyUrl;
12416
+ function publicKeyExists(_x) {
12417
+ return _publicKeyExists.apply(this, arguments);
12418
+ }
12419
+ function _publicKeyExists() {
12420
+ _publicKeyExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
12421
+ var publicKey;
12422
+ return _regenerator["default"].wrap(function _callee$(_context) {
12423
+ while (1) switch (_context.prev = _context.next) {
12424
+ case 0:
12425
+ _context.next = 2;
12426
+ return _solidLogic.store.fetcher.load(pubKeyUrl(webId));
12427
+ case 2:
12428
+ // url.href)
12429
+ publicKey = _solidLogic.store.any(_solidLogic.store.sym(webId), _solidLogic.store.sym(_signature.CERT + 'PublicKey'));
12430
+ return _context.abrupt("return", publicKey === null || publicKey === void 0 ? void 0 : publicKey.value);
12431
+ case 4:
12432
+ case "end":
12433
+ return _context.stop();
12434
+ }
12435
+ }, _callee);
12436
+ }));
12437
+ return _publicKeyExists.apply(this, arguments);
12438
+ }
12439
+ var privKeyUrl = function privKeyUrl(webId) {
12440
+ var url = new URL(webId);
12441
+ var privateKeyUrl = url.origin + '/profile/keys/privateKey.ttl';
12442
+ return privateKeyUrl;
12443
+ };
12444
+ exports.privKeyUrl = privKeyUrl;
12445
+ function privateKeyExists(_x2) {
12446
+ return _privateKeyExists.apply(this, arguments);
12447
+ }
12448
+ function _privateKeyExists() {
12449
+ _privateKeyExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
12450
+ var privateKeyUrl, privateKey, _err$response, data, contentType, response;
12451
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
12452
+ while (1) switch (_context2.prev = _context2.next) {
12453
+ case 0:
12454
+ /* const url = new URL(webId)
12455
+ const privateKeyUrl = url.protocol + '//' + url.host + '/profile/privateKey.ttl' */
12456
+ privateKeyUrl = privKeyUrl(webId);
12457
+ /* debug.warn('Alain privateKeyExists')
12458
+ debug.warn(webId)
12459
+ debug.warn(privateKeyUrl) */
12460
+ _context2.prev = 1;
12461
+ _context2.next = 4;
12462
+ return _solidLogic.store.fetcher.load(privateKeyUrl);
12463
+ case 4:
12464
+ privateKey = _solidLogic.store.any(_solidLogic.store.sym(webId), _solidLogic.store.sym(_signature.CERT + 'PrivateKey'));
12465
+ return _context2.abrupt("return", privateKey === null || privateKey === void 0 ? void 0 : privateKey.value);
12466
+ case 8:
12467
+ _context2.prev = 8;
12468
+ _context2.t0 = _context2["catch"](1);
12469
+ if (!((_context2.t0 === null || _context2.t0 === void 0 ? void 0 : (_err$response = _context2.t0.response) === null || _err$response === void 0 ? void 0 : _err$response.status) === 404)) {
12470
+ _context2.next = 25;
12471
+ break;
12472
+ }
12473
+ _context2.prev = 11;
12474
+ // create privateKey resource
12475
+ data = '';
12476
+ contentType = 'text/ttl';
12477
+ _context2.next = 16;
12478
+ return _solidLogic.store.fetcher.webOperation('PUT', privateKeyUrl, {
12479
+ data: data,
12480
+ contentType: contentType
12481
+ });
12482
+ case 16:
12483
+ response = _context2.sent;
12484
+ _context2.next = 23;
12485
+ break;
12486
+ case 19:
12487
+ _context2.prev = 19;
12488
+ _context2.t1 = _context2["catch"](11);
12489
+ debug.log('createIfNotExists doc FAILED: ' + privateKeyUrl + ': ' + _context2.t1);
12490
+ throw _context2.t1;
12491
+ case 23:
12492
+ delete _solidLogic.store.fetcher.requested[privateKeyUrl]; // delete cached 404 error
12493
+ return _context2.abrupt("return", undefined);
12494
+ case 25:
12495
+ debug.log('createIfNotExists doc FAILED: ' + privateKeyUrl + ': ' + _context2.t0);
12496
+ throw _context2.t0;
12497
+ case 27:
12498
+ case "end":
12499
+ return _context2.stop();
12500
+ }
12501
+ }, _callee2, null, [[1, 8], [11, 19]]);
12502
+ }));
12503
+ return _privateKeyExists.apply(this, arguments);
12504
+ }
12505
+ //# sourceMappingURL=cryptoKeyHelpers.js.map
12506
+
12507
+ /***/ }),
12508
+
12442
12509
  /***/ "./lib/utils/headerFooterHelpers.js":
12443
12510
  /*!******************************************!*\
12444
12511
  !*** ./lib/utils/headerFooterHelpers.js ***!
@@ -13285,8 +13352,8 @@ Object.defineProperty(exports, "__esModule", ({
13285
13352
  }));
13286
13353
  exports.versionInfo = void 0;
13287
13354
  var versionInfo = {
13288
- buildTime: '2023-04-21T21:20:00Z',
13289
- commit: '20175fe34b116218e9d7838365c079aa30ed7459',
13355
+ buildTime: '2023-04-26T07:56:28Z',
13356
+ commit: '2910a8313b68d08927570a93f57617b8573226d4',
13290
13357
  npmInfo: {
13291
13358
  'solid-ui': '2.4.27',
13292
13359
  npm: '8.19.4',