solid-ui 2.4.27-77f914e3 → 2.4.27-7aaee063

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/README.md CHANGED
@@ -70,7 +70,8 @@ When you want to test the component within a solid-pane, you can use the [develo
70
70
 
71
71
  ## Adding Tests
72
72
 
73
- Need to point to Unit test Readme.
73
+ The following document gives guidance on how to add and perform testing in solid-ui.
74
+ [Testing in solid-ui](https://github.com/SolidOS/solid-ui/blob/18070a02fa8159a2b83d9503ee400f8e046bf1f6/test/unit/README.md)
74
75
 
75
76
  ## Further documentation
76
77
 
package/dist/solid-ui.js CHANGED
@@ -4053,74 +4053,77 @@ function generatePrivateKey() {
4053
4053
  function generatePublicKey(privateKey) {
4054
4054
  return (0, _utils.bytesToHex)(_secp256k.schnorr.getPublicKey(privateKey));
4055
4055
  }
4056
+
4057
+ /**
4058
+ * getPublicKey
4059
+ * used for displaying messages in chat, therefore does not
4060
+ * create a new key if not found
4061
+ * @param webId
4062
+ * @returns string | undefined
4063
+ */
4056
4064
  function getPublicKey(_x) {
4057
4065
  return _getPublicKey.apply(this, arguments);
4058
4066
  }
4059
4067
  function _getPublicKey() {
4060
- _getPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
4068
+ _getPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
4061
4069
  var publicKeyDoc, key;
4062
- return _regenerator["default"].wrap(function _callee$(_context) {
4063
- while (1) switch (_context.prev = _context.next) {
4070
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
4071
+ while (1) switch (_context2.prev = _context2.next) {
4064
4072
  case 0:
4065
- _context.next = 2;
4073
+ _context2.next = 2;
4066
4074
  return _solidLogic.store.fetcher.load(webId);
4067
4075
  case 2:
4068
- _context.next = 4;
4076
+ _context2.next = 4;
4069
4077
  return (0, _accessData.pubKeyUrl)(webId);
4070
4078
  case 4:
4071
- publicKeyDoc = _context.sent;
4072
- _context.prev = 5;
4073
- _context.next = 8;
4079
+ publicKeyDoc = _context2.sent;
4080
+ _context2.prev = 5;
4081
+ _context2.next = 8;
4074
4082
  return _solidLogic.store.fetcher.load(publicKeyDoc);
4075
4083
  case 8:
4076
4084
  // url.href)
4077
4085
  key = _solidLogic.store.any(webId, _solidLogic.store.sym(_signature.CERT + 'PublicKey'));
4078
- return _context.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
4086
+ return _context2.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
4079
4087
  case 12:
4080
- _context.prev = 12;
4081
- _context.t0 = _context["catch"](5);
4082
- return _context.abrupt("return", undefined);
4088
+ _context2.prev = 12;
4089
+ _context2.t0 = _context2["catch"](5);
4090
+ return _context2.abrupt("return", undefined);
4083
4091
  case 15:
4084
4092
  case "end":
4085
- return _context.stop();
4093
+ return _context2.stop();
4086
4094
  }
4087
- }, _callee, null, [[5, 12]]);
4095
+ }, _callee2, null, [[5, 12]]);
4088
4096
  }));
4089
4097
  return _getPublicKey.apply(this, arguments);
4090
4098
  }
4091
4099
  function getPrivateKey(_x2) {
4092
4100
  return _getPrivateKey.apply(this, arguments);
4093
4101
  }
4094
- /**
4095
- * delete acl if keydoc exists
4096
- * create/edit keyDoc
4097
- * set keyDoc acl
4098
- */
4099
4102
  function _getPrivateKey() {
4100
- _getPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
4103
+ _getPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId) {
4101
4104
  var publicKeyDoc, privateKeyDoc, publicKey, privateKey, validPublicKey, del, add, newPublicKey, keyContainer;
4102
- return _regenerator["default"].wrap(function _callee2$(_context2) {
4103
- while (1) switch (_context2.prev = _context2.next) {
4105
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
4106
+ while (1) switch (_context3.prev = _context3.next) {
4104
4107
  case 0:
4105
- _context2.next = 2;
4108
+ _context3.next = 2;
4106
4109
  return _solidLogic.store.fetcher.load(webId);
4107
4110
  case 2:
4108
- _context2.next = 4;
4111
+ _context3.next = 4;
4109
4112
  return (0, _accessData.pubKeyUrl)(webId);
4110
4113
  case 4:
4111
- publicKeyDoc = _context2.sent;
4112
- _context2.next = 7;
4114
+ publicKeyDoc = _context3.sent;
4115
+ _context3.next = 7;
4113
4116
  return (0, _accessData.privKeyUrl)(webId);
4114
4117
  case 7:
4115
- privateKeyDoc = _context2.sent;
4116
- _context2.next = 10;
4118
+ privateKeyDoc = _context3.sent;
4119
+ _context3.next = 10;
4117
4120
  return (0, _accessData.getExistingPublicKey)(webId, publicKeyDoc);
4118
4121
  case 10:
4119
- publicKey = _context2.sent;
4120
- _context2.next = 13;
4122
+ publicKey = _context3.sent;
4123
+ _context3.next = 13;
4121
4124
  return (0, _accessData.getExistingPrivateKey)(webId, privateKeyDoc);
4122
4125
  case 13:
4123
- privateKey = _context2.sent;
4126
+ privateKey = _context3.sent;
4124
4127
  // is publicKey valid ?
4125
4128
  validPublicKey = true;
4126
4129
  if (privateKey && publicKey !== generatePublicKey(privateKey)) {
@@ -4129,23 +4132,23 @@ function _getPrivateKey() {
4129
4132
 
4130
4133
  // create key pair or repair publicKey
4131
4134
  if (!(!privateKey || !publicKey || !validPublicKey)) {
4132
- _context2.next = 34;
4135
+ _context3.next = 34;
4133
4136
  break;
4134
4137
  }
4135
4138
  del = [];
4136
4139
  add = []; // if (privateKey) del.push($rdf.st(webId, store.sym(CERT + 'PrivateKey'), $rdf.lit(privateKey), store.sym(privateKeyDoc)))
4137
4140
  if (privateKey) {
4138
- _context2.next = 24;
4141
+ _context3.next = 24;
4139
4142
  break;
4140
4143
  }
4141
4144
  // add = []
4142
4145
  privateKey = generatePrivateKey();
4143
4146
  add = [$rdf.st(webId, _solidLogic.store.sym(_signature.CERT + 'PrivateKey'), $rdf.literal(privateKey), _solidLogic.store.sym(privateKeyDoc))];
4144
- _context2.next = 24;
4147
+ _context3.next = 24;
4145
4148
  return saveKey(privateKeyDoc, [], add, webId.uri);
4146
4149
  case 24:
4147
4150
  if (!(!publicKey || !validPublicKey)) {
4148
- _context2.next = 31;
4151
+ _context3.next = 31;
4149
4152
  break;
4150
4153
  }
4151
4154
  del = [];
@@ -4157,83 +4160,98 @@ function _getPrivateKey() {
4157
4160
  // update new valid key
4158
4161
  newPublicKey = generatePublicKey(privateKey);
4159
4162
  add = [$rdf.st(webId, _solidLogic.store.sym(_signature.CERT + 'PublicKey'), $rdf.literal(newPublicKey), _solidLogic.store.sym(publicKeyDoc))];
4160
- _context2.next = 31;
4163
+ _context3.next = 31;
4161
4164
  return saveKey(publicKeyDoc, del, add);
4162
4165
  case 31:
4163
4166
  keyContainer = privateKeyDoc.substring(0, privateKeyDoc.lastIndexOf('/') + 1);
4164
- _context2.next = 34;
4167
+ _context3.next = 34;
4165
4168
  return (0, _acl.setAcl)(keyContainer, (0, _acl.keyContainerAclBody)(webId.uri));
4166
4169
  case 34:
4167
- return _context2.abrupt("return", privateKey);
4170
+ return _context3.abrupt("return", privateKey);
4168
4171
  case 35:
4169
4172
  case "end":
4170
- return _context2.stop();
4173
+ return _context3.stop();
4171
4174
  }
4172
- }, _callee2);
4175
+ }, _callee3);
4173
4176
  }));
4174
4177
  return _getPrivateKey.apply(this, arguments);
4175
4178
  }
4176
- function saveKey(_x3, _x4, _x5) {
4179
+ var deleteKeyAcl = /*#__PURE__*/function () {
4180
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(keyDoc) {
4181
+ var keyAclDoc, response;
4182
+ return _regenerator["default"].wrap(function _callee$(_context) {
4183
+ while (1) switch (_context.prev = _context.next) {
4184
+ case 0:
4185
+ _context.next = 2;
4186
+ return _solidLogic.store.fetcher.load(keyDoc);
4187
+ case 2:
4188
+ keyAclDoc = _solidLogic.store.any(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl'));
4189
+ if (!keyAclDoc) {
4190
+ _context.next = 16;
4191
+ break;
4192
+ }
4193
+ _context.prev = 4;
4194
+ _context.next = 7;
4195
+ return _solidLogic.store.fetcher.webOperation('DELETE', keyAclDoc.value);
4196
+ case 7:
4197
+ response = _context.sent;
4198
+ // this may fail if webId is not an owner
4199
+ debug.log('delete ' + keyAclDoc.value + ' ' + response.status); // should test 404 and 2xx
4200
+ _context.next = 16;
4201
+ break;
4202
+ case 11:
4203
+ _context.prev = 11;
4204
+ _context.t0 = _context["catch"](4);
4205
+ if (!(_context.t0.response.status !== 404)) {
4206
+ _context.next = 15;
4207
+ break;
4208
+ }
4209
+ throw new Error(_context.t0);
4210
+ case 15:
4211
+ debug.log('delete ' + keyAclDoc.value + ' ' + _context.t0.response.status); // should test 404 and 2xx
4212
+ case 16:
4213
+ case "end":
4214
+ return _context.stop();
4215
+ }
4216
+ }, _callee, null, [[4, 11]]);
4217
+ }));
4218
+ return function deleteKeyAcl(_x3) {
4219
+ return _ref.apply(this, arguments);
4220
+ };
4221
+ }();
4222
+
4223
+ /**
4224
+ * delete acl if keydoc exists
4225
+ * create/edit keyDoc
4226
+ * set keyDoc acl
4227
+ */
4228
+ function saveKey(_x4, _x5, _x6) {
4177
4229
  return _saveKey.apply(this, arguments);
4178
4230
  }
4179
4231
  function _saveKey() {
4180
4232
  _saveKey = (0, _asyncToGenerator2["default"])(function (keyDoc, del, add) {
4181
4233
  var me = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
4182
- return /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
4183
- var keyAclDoc, response, aclBody;
4184
- return _regenerator["default"].wrap(function _callee3$(_context3) {
4185
- while (1) switch (_context3.prev = _context3.next) {
4234
+ return /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
4235
+ var aclBody;
4236
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
4237
+ while (1) switch (_context4.prev = _context4.next) {
4186
4238
  case 0:
4187
- _context3.next = 2;
4188
- return _solidLogic.store.fetcher.load(keyDoc);
4239
+ _context4.next = 2;
4240
+ return deleteKeyAcl(keyDoc);
4189
4241
  case 2:
4190
- _context3.prev = 2;
4191
- // get keyAcldoc
4192
- keyAclDoc = _solidLogic.store.any(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl'));
4193
- if (!keyAclDoc) {
4194
- _context3.next = 17;
4195
- break;
4196
- }
4197
- _context3.prev = 5;
4198
- _context3.next = 8;
4199
- return _solidLogic.store.fetcher.webOperation('DELETE', keyAclDoc.value);
4200
- case 8:
4201
- response = _context3.sent;
4202
- // this may fail if webId is not an owner
4203
- debug.log('delete ' + keyAclDoc.value + ' ' + response.status); // should test 404 and 2xx
4204
- _context3.next = 17;
4205
- break;
4206
- case 12:
4207
- _context3.prev = 12;
4208
- _context3.t0 = _context3["catch"](5);
4209
- if (!(_context3.t0.response.status !== 404)) {
4210
- _context3.next = 16;
4211
- break;
4212
- }
4213
- throw new Error(_context3.t0);
4214
- case 16:
4215
- debug.log('delete ' + keyAclDoc.value + ' ' + _context3.t0.response.status); // should test 404 and 2xx
4216
- case 17:
4217
- _context3.next = 19;
4242
+ _context4.next = 4;
4218
4243
  return _solidLogic.store.updater.updateMany(del, add);
4219
- case 19:
4244
+ case 4:
4220
4245
  // or a promise store.updater.update ?
4221
4246
  // create READ only ACL
4222
4247
  aclBody = (0, _acl.keyAclBody)(keyDoc, me);
4223
- _context3.next = 22;
4248
+ _context4.next = 7;
4224
4249
  return (0, _acl.setAcl)(keyDoc, aclBody);
4225
- case 22:
4226
- _context3.next = 27;
4227
- break;
4228
- case 24:
4229
- _context3.prev = 24;
4230
- _context3.t1 = _context3["catch"](2);
4231
- throw new Error(_context3.t1);
4232
- case 27:
4250
+ case 7:
4233
4251
  case "end":
4234
- return _context3.stop();
4252
+ return _context4.stop();
4235
4253
  }
4236
- }, _callee3, null, [[2, 24], [5, 12]]);
4254
+ }, _callee4);
4237
4255
  })();
4238
4256
  });
4239
4257
  return _saveKey.apply(this, arguments);
@@ -13248,7 +13266,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
13248
13266
  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; }
13249
13267
  var getPodRoot = /*#__PURE__*/function () {
13250
13268
  var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
13251
- var _podRoot;
13252
13269
  var webIdURL, storages, podRoot, path, _res$headers$get, res;
13253
13270
  return _regenerator["default"].wrap(function _callee$(_context) {
13254
13271
  while (1) switch (_context.prev = _context.next) {
@@ -13294,7 +13311,7 @@ var getPodRoot = /*#__PURE__*/function () {
13294
13311
  });
13295
13312
  if (!podRoot) podRoot = storages[0];
13296
13313
  case 21:
13297
- return _context.abrupt("return", (_podRoot = podRoot) === null || _podRoot === void 0 ? void 0 : _podRoot.value);
13314
+ return _context.abrupt("return", podRoot);
13298
13315
  case 22:
13299
13316
  case "end":
13300
13317
  return _context.stop();
@@ -13315,7 +13332,7 @@ var pubKeyUrl = /*#__PURE__*/function () {
13315
13332
  _context2.next = 3;
13316
13333
  return getPodRoot(webId);
13317
13334
  case 3:
13318
- _context2.t0 = _context2.sent;
13335
+ _context2.t0 = _context2.sent.value;
13319
13336
  return _context2.abrupt("return", _context2.t0 + 'profile/keys/publicKey.ttl');
13320
13337
  case 7:
13321
13338
  _context2.prev = 7;
@@ -13361,7 +13378,7 @@ var privKeyUrl = /*#__PURE__*/function () {
13361
13378
  _context3.next = 3;
13362
13379
  return getPodRoot(webId);
13363
13380
  case 3:
13364
- _context3.t0 = _context3.sent;
13381
+ _context3.t0 = _context3.sent.value;
13365
13382
  return _context3.abrupt("return", _context3.t0 + 'profile/keys/privateKey.ttl');
13366
13383
  case 7:
13367
13384
  _context3.prev = 7;
@@ -13493,7 +13510,7 @@ function setAcl(_x, _x2) {
13493
13510
  */
13494
13511
  function _setAcl() {
13495
13512
  _setAcl = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(keyDoc, aclBody) {
13496
- var keyAclDoc, response, aclResponse;
13513
+ var keyAclDoc, _err$response;
13497
13514
  return _regenerator["default"].wrap(function _callee$(_context) {
13498
13515
  while (1) switch (_context.prev = _context.next) {
13499
13516
  case 0:
@@ -13511,36 +13528,28 @@ function _setAcl() {
13511
13528
  case 6:
13512
13529
  _context.prev = 6;
13513
13530
  _context.next = 9;
13514
- return _solidLogic.store.fetcher.webOperation('DELETE', keyAclDoc.value);
13531
+ return _solidLogic.store.fetcher.webOperation('PUT', keyAclDoc.value, {
13532
+ data: aclBody,
13533
+ contentType: 'text/turtle'
13534
+ });
13515
13535
  case 9:
13516
- response = _context.sent;
13517
- // this may fail if webId is not an owner
13518
- debug.log('delete ' + keyAclDoc.value + ' ' + response.status); // should test 404 and 2xx
13519
- _context.next = 18;
13536
+ _context.next = 16;
13520
13537
  break;
13521
- case 13:
13522
- _context.prev = 13;
13538
+ case 11:
13539
+ _context.prev = 11;
13523
13540
  _context.t0 = _context["catch"](6);
13524
- if (!(_context.t0.response.status !== 404)) {
13525
- _context.next = 17;
13541
+ 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)) {
13542
+ _context.next = 15;
13526
13543
  break;
13527
13544
  }
13528
13545
  throw new Error(_context.t0);
13529
- case 17:
13546
+ case 15:
13530
13547
  debug.log('delete ' + keyAclDoc.value + ' ' + _context.t0.response.status); // should test 404 and 2xx
13531
- case 18:
13532
- _context.next = 20;
13533
- return _solidLogic.store.fetcher.webOperation('PUT', keyAclDoc.value, {
13534
- data: aclBody,
13535
- contentType: 'text/turtle'
13536
- });
13537
- case 20:
13538
- aclResponse = _context.sent;
13539
- case 21:
13548
+ case 16:
13540
13549
  case "end":
13541
13550
  return _context.stop();
13542
13551
  }
13543
- }, _callee, null, [[6, 13]]);
13552
+ }, _callee, null, [[6, 11]]);
13544
13553
  }));
13545
13554
  return _setAcl.apply(this, arguments);
13546
13555
  }
@@ -13695,8 +13704,8 @@ Object.defineProperty(exports, "__esModule", ({
13695
13704
  }));
13696
13705
  exports.versionInfo = void 0;
13697
13706
  var versionInfo = {
13698
- buildTime: '2023-05-10T18:38:16Z',
13699
- commit: '77f914e3e4b885876fd4618e7374fd020da07cd1',
13707
+ buildTime: '2023-05-18T16:22:59Z',
13708
+ commit: '7aaee06326ec9cca058b0e98e82eb40b151555fc',
13700
13709
  npmInfo: {
13701
13710
  'solid-ui': '2.4.27',
13702
13711
  npm: '8.19.4',