solid-ui 2.4.28-6587e612 → 2.4.28-6a319caf

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
@@ -4861,7 +4861,7 @@ function _renderMessageRow() {
4861
4861
  thread = _solidLogic.store.any(null, ns.sioc('has_member'), message);
4862
4862
  }
4863
4863
  // get signature
4864
- signature = _solidLogic.store.any(msgId, $rdf.sym("".concat(_signature.SEC, "proofValue"))); // set message object
4864
+ signature = _solidLogic.store.any(msgId, $rdf.sym("".concat(_signature.SEC, "proofValue"))); // set proof message object
4865
4865
  msg = (0, _signature.getBlankMsg)();
4866
4866
  msg.id = msgId.uri;
4867
4867
  msg.created = _solidLogic.store.any(msgId, ns.dct('created')).value;
@@ -5953,96 +5953,27 @@ exports.verifySignature = verifySignature;
5953
5953
  var _secp256k = __webpack_require__(/*! @noble/curves/secp256k1 */ "./node_modules/@noble/curves/secp256k1.js");
5954
5954
  var _utils = __webpack_require__(/*! @noble/hashes/utils */ "./node_modules/@noble/hashes/utils.js");
5955
5955
  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
5956
  var utf8Decoder = new TextDecoder('utf-8');
5960
5957
  exports.utf8Decoder = utf8Decoder;
5961
5958
  var utf8Encoder = new TextEncoder();
5962
5959
  exports.utf8Encoder = utf8Encoder;
5963
5960
  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
5961
  exports.SEC = SEC;
5991
5962
  function getBlankMsg() {
5992
5963
  return {
5993
5964
  id: '',
5994
5965
  created: '',
5995
- dateDeleted: '',
5996
- // TODO to remove if not used
5997
5966
  content: '',
5998
- maker: '',
5999
- sig: '' // TODO to remove if not used
5967
+ maker: ''
6000
5968
  };
6001
5969
  }
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
5970
  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
5971
  return JSON.stringify(msg);
6018
5972
  }
6019
5973
  function getMsgHash(message) {
6020
5974
  var msgHash = (0, _sha.sha256)(utf8Encoder.encode(serializeMsg(message)));
6021
5975
  return (0, _utils.bytesToHex)(msgHash);
6022
5976
  }
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
5977
  function verifySignature(sig, message, pubKey) {
6047
5978
  return _secp256k.schnorr.verify(sig, getMsgHash(message), pubKey);
6048
5979
  }
@@ -14032,176 +13963,96 @@ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/r
14032
13963
  var debug = _interopRequireWildcard(__webpack_require__(/*! ../../debug */ "./lib/debug.js"));
14033
13964
  var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
14034
13965
  var ns = _interopRequireWildcard(__webpack_require__(/*! ../../ns */ "./lib/ns.js"));
13966
+ var _otherHelpers = __webpack_require__(/*! ./otherHelpers */ "./lib/utils/keyHelpers/otherHelpers.js");
14035
13967
  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
13968
  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
13969
+ var pubKeyUrl = function pubKeyUrl(webId) {
13970
+ var url;
13971
+ try {
13972
+ var root = (0, _otherHelpers.getRootIfPreferencesExist)(webId);
13973
+ url = "".concat(root, "/profile/keys/publicKey.ttl");
13974
+ } catch (err) {
13975
+ debug.error(err);
14057
13976
  }
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
- }();
13977
+ return url;
13978
+ };
14088
13979
  exports.pubKeyUrl = pubKeyUrl;
14089
- function getExistingPublicKey(_x2, _x3) {
13980
+ var privKeyUrl = function privKeyUrl(webId) {
13981
+ var url;
13982
+ try {
13983
+ var root = (0, _otherHelpers.getRootIfPreferencesExist)(webId);
13984
+ url = "".concat(root, "/keys/privateKey.ttl");
13985
+ } catch (err) {
13986
+ debug.error(err);
13987
+ }
13988
+ return url;
13989
+ };
13990
+ exports.privKeyUrl = privKeyUrl;
13991
+ function getExistingPublicKey(_x, _x2) {
14090
13992
  return _getExistingPublicKey.apply(this, arguments);
14091
13993
  }
14092
13994
  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) {
13995
+ _getExistingPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId, publicKeyUrl) {
13996
+ return _regenerator["default"].wrap(function _callee$(_context) {
13997
+ while (1) switch (_context.prev = _context.next) {
14096
13998
  case 0:
14097
- _context3.next = 2;
13999
+ _context.next = 2;
14098
14000
  return getKeyIfExists(webId, publicKeyUrl, 'publicKey');
14099
14001
  case 2:
14100
- return _context3.abrupt("return", _context3.sent);
14002
+ return _context.abrupt("return", _context.sent);
14101
14003
  case 3:
14102
14004
  case "end":
14103
- return _context3.stop();
14005
+ return _context.stop();
14104
14006
  }
14105
- }, _callee3);
14007
+ }, _callee);
14106
14008
  }));
14107
14009
  return _getExistingPublicKey.apply(this, arguments);
14108
14010
  }
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) {
14011
+ function getExistingPrivateKey(_x3, _x4) {
14137
14012
  return _getExistingPrivateKey.apply(this, arguments);
14138
14013
  }
14139
14014
  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) {
14015
+ _getExistingPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId, privateKeyUrl) {
14016
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
14017
+ while (1) switch (_context2.prev = _context2.next) {
14143
14018
  case 0:
14144
- _context4.next = 2;
14019
+ _context2.next = 2;
14145
14020
  return getKeyIfExists(webId, privateKeyUrl, 'privateKey');
14146
14021
  case 2:
14147
- return _context4.abrupt("return", _context4.sent);
14022
+ return _context2.abrupt("return", _context2.sent);
14148
14023
  case 3:
14149
14024
  case "end":
14150
- return _context4.stop();
14025
+ return _context2.stop();
14151
14026
  }
14152
- }, _callee4);
14027
+ }, _callee2);
14153
14028
  }));
14154
14029
  return _getExistingPrivateKey.apply(this, arguments);
14155
14030
  }
14156
- function getKeyIfExists(_x7, _x8, _x9) {
14031
+ function getKeyIfExists(_x5, _x6, _x7) {
14157
14032
  return _getKeyIfExists.apply(this, arguments);
14158
14033
  }
14159
14034
  function _getKeyIfExists() {
14160
- _getKeyIfExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(webId, keyUrl, keyType) {
14035
+ _getKeyIfExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId, keyUrl, keyType) {
14161
14036
  var key;
14162
- return _regenerator["default"].wrap(function _callee5$(_context5) {
14163
- while (1) switch (_context5.prev = _context5.next) {
14037
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
14038
+ while (1) switch (_context3.prev = _context3.next) {
14164
14039
  case 0:
14165
- _context5.prev = 0;
14166
- _context5.next = 3;
14040
+ _context3.prev = 0;
14041
+ _context3.next = 3;
14167
14042
  return _solidLogic.store.fetcher.load(keyUrl);
14168
14043
  case 3:
14169
14044
  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);
14045
+ return _context3.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
14171
14046
  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:
14047
+ _context3.prev = 7;
14048
+ _context3.t0 = _context3["catch"](0);
14049
+ debug.error('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context3.t0);
14050
+ return _context3.abrupt("return", undefined);
14051
+ case 11:
14201
14052
  case "end":
14202
- return _context5.stop();
14053
+ return _context3.stop();
14203
14054
  }
14204
- }, _callee5, null, [[0, 7], [11, 16]]);
14055
+ }, _callee3, null, [[0, 7]]);
14205
14056
  }));
14206
14057
  return _getKeyIfExists.apply(this, arguments);
14207
14058
  }
@@ -14312,6 +14163,39 @@ exports.keyAclBody = keyAclBody;
14312
14163
 
14313
14164
  /***/ }),
14314
14165
 
14166
+ /***/ "./lib/utils/keyHelpers/otherHelpers.js":
14167
+ /*!**********************************************!*\
14168
+ !*** ./lib/utils/keyHelpers/otherHelpers.js ***!
14169
+ \**********************************************/
14170
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
14171
+
14172
+ "use strict";
14173
+
14174
+
14175
+ var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
14176
+ Object.defineProperty(exports, "__esModule", ({
14177
+ value: true
14178
+ }));
14179
+ exports.getRootIfPreferencesExist = void 0;
14180
+ var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
14181
+ var ns = _interopRequireWildcard(__webpack_require__(/*! ../../ns */ "./lib/ns.js"));
14182
+ 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); }
14183
+ 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; }
14184
+ // Will rename this file later. We will probably be using solid-logic anyway
14185
+ // moved it out so I can mock
14186
+
14187
+ var getRootIfPreferencesExist = function getRootIfPreferencesExist(webId) {
14188
+ var _store$any, _root;
14189
+ var root = (_store$any = _solidLogic.store.any(webId, ns.space('preferencesFile'), null, webId.doc())) === null || _store$any === void 0 ? void 0 : _store$any.value;
14190
+ root = (_root = root) === null || _root === void 0 ? void 0 : _root.split('/').slice(0, -2).join('/');
14191
+ if (!root) throw new Error("prefererencesFile is expected to exist in ".concat(webId));
14192
+ return root;
14193
+ };
14194
+ exports.getRootIfPreferencesExist = getRootIfPreferencesExist;
14195
+ //# sourceMappingURL=otherHelpers.js.map
14196
+
14197
+ /***/ }),
14198
+
14315
14199
  /***/ "./lib/utils/label.js":
14316
14200
  /*!****************************!*\
14317
14201
  !*** ./lib/utils/label.js ***!
@@ -14440,8 +14324,8 @@ Object.defineProperty(exports, "__esModule", ({
14440
14324
  }));
14441
14325
  exports.versionInfo = void 0;
14442
14326
  var versionInfo = {
14443
- buildTime: '2023-05-30T18:12:14Z',
14444
- commit: '6587e6129e43789b8f329708faa3fac5a97779da',
14327
+ buildTime: '2023-06-03T23:48:25Z',
14328
+ commit: '6a319caf69ef4ecc171a5adcb375dea108d002c2',
14445
14329
  npmInfo: {
14446
14330
  'solid-ui': '2.4.28',
14447
14331
  npm: '8.19.4',