solid-ui 2.4.27-dc50c4e2 → 2.4.27-e6d67dd8
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 +351 -117
- package/dist/solid-ui.js.map +1 -1
- package/dist/solid-ui.min.js +1 -1
- package/dist/solid-ui.min.js.map +1 -1
- package/lib/chat/keys.d.ts +1 -1
- package/lib/chat/keys.d.ts.map +1 -1
- package/lib/chat/keys.js +171 -99
- package/lib/chat/keys.js.map +1 -1
- package/lib/chat/message.js +22 -15
- package/lib/chat/message.js.map +1 -1
- package/lib/utils/cryptoKeyHelpers.d.ts +5 -0
- package/lib/utils/cryptoKeyHelpers.d.ts.map +1 -0
- package/lib/utils/cryptoKeyHelpers.js +145 -0
- package/lib/utils/cryptoKeyHelpers.js.map +1 -0
- package/lib/versionInfo.js +2 -2
- package/lib/versionInfo.js.map +1 -1
- package/package.json +1 -1
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() {
|
|
@@ -4051,133 +4052,102 @@ function generatePrivateKey() {
|
|
|
4051
4052
|
function generatePublicKey(privateKey) {
|
|
4052
4053
|
return (0, _utils.bytesToHex)(_secp256k.schnorr.getPublicKey(privateKey));
|
|
4053
4054
|
}
|
|
4054
|
-
function getPublicKey(
|
|
4055
|
-
|
|
4056
|
-
return publicKey;
|
|
4055
|
+
function getPublicKey(_x) {
|
|
4056
|
+
return _getPublicKey.apply(this, arguments);
|
|
4057
4057
|
}
|
|
4058
|
-
function
|
|
4059
|
-
|
|
4060
|
-
|
|
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);
|
|
4077
|
-
}
|
|
4078
|
-
function _privateKeyExists() {
|
|
4079
|
-
_privateKeyExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
|
|
4080
|
-
var privateKeyUrl, privateKey, _err$response, data, contentType, response;
|
|
4058
|
+
function _getPublicKey() {
|
|
4059
|
+
_getPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
|
|
4060
|
+
var publicKeyDoc, key;
|
|
4081
4061
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
4082
4062
|
while (1) switch (_context.prev = _context.next) {
|
|
4083
4063
|
case 0:
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
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
|
-
}
|
|
4064
|
+
_context.next = 2;
|
|
4065
|
+
return _solidLogic.store.fetcher.load(webId);
|
|
4066
|
+
case 2:
|
|
4067
|
+
publicKeyDoc = (0, _cryptoKeyHelpers.pubKeyUrl)(webId);
|
|
4068
|
+
_context.prev = 3;
|
|
4069
|
+
_context.next = 6;
|
|
4070
|
+
return _solidLogic.store.fetcher.load(publicKeyDoc);
|
|
4071
|
+
case 6:
|
|
4072
|
+
// url.href)
|
|
4073
|
+
key = _solidLogic.store.any(_solidLogic.store.sym(webId), _solidLogic.store.sym(_signature.CERT + 'PublicKey'));
|
|
4074
|
+
return _context.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
|
|
4075
|
+
case 10:
|
|
4101
4076
|
_context.prev = 10;
|
|
4102
|
-
|
|
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
|
|
4077
|
+
_context.t0 = _context["catch"](3);
|
|
4121
4078
|
return _context.abrupt("return", undefined);
|
|
4122
|
-
case
|
|
4123
|
-
debug.log('createIfNotExists doc FAILED: ' + privateKeyUrl + ': ' + _context.t0);
|
|
4124
|
-
throw _context.t0;
|
|
4125
|
-
case 26:
|
|
4079
|
+
case 13:
|
|
4126
4080
|
case "end":
|
|
4127
4081
|
return _context.stop();
|
|
4128
4082
|
}
|
|
4129
|
-
}, _callee, null, [[
|
|
4083
|
+
}, _callee, null, [[3, 10]]);
|
|
4130
4084
|
}));
|
|
4131
|
-
return
|
|
4085
|
+
return _getPublicKey.apply(this, arguments);
|
|
4132
4086
|
}
|
|
4133
4087
|
function getPrivateKey(_x2) {
|
|
4134
4088
|
return _getPrivateKey.apply(this, arguments);
|
|
4135
4089
|
}
|
|
4136
4090
|
function _getPrivateKey() {
|
|
4137
4091
|
_getPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
|
|
4138
|
-
var
|
|
4092
|
+
var publicKeyDoc, privateKeyDoc, publicKey, privateKey, validPublicKey, del, add, newPublicKey;
|
|
4139
4093
|
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
4140
4094
|
while (1) switch (_context2.prev = _context2.next) {
|
|
4141
4095
|
case 0:
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
// find
|
|
4096
|
+
_context2.next = 2;
|
|
4097
|
+
return _solidLogic.store.fetcher.load(webId);
|
|
4098
|
+
case 2:
|
|
4099
|
+
// find keys url's
|
|
4100
|
+
publicKeyDoc = (0, _cryptoKeyHelpers.pubKeyUrl)(webId);
|
|
4101
|
+
privateKeyDoc = (0, _cryptoKeyHelpers.privKeyUrl)(webId); // find key pair
|
|
4148
4102
|
_context2.next = 6;
|
|
4149
|
-
return
|
|
4103
|
+
return (0, _cryptoKeyHelpers.publicKeyExists)(webId);
|
|
4150
4104
|
case 6:
|
|
4105
|
+
publicKey = _context2.sent;
|
|
4106
|
+
_context2.next = 9;
|
|
4107
|
+
return (0, _cryptoKeyHelpers.privateKeyExists)(webId);
|
|
4108
|
+
case 9:
|
|
4151
4109
|
privateKey = _context2.sent;
|
|
4152
|
-
//
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
// create key pair
|
|
4162
|
-
if (!(!privateKey || !publicKey)) {
|
|
4163
|
-
_context2.next = 19;
|
|
4110
|
+
// is publicKey valid ?
|
|
4111
|
+
validPublicKey = true;
|
|
4112
|
+
if (privateKey && publicKey !== generatePublicKey(privateKey)) {
|
|
4113
|
+
if (confirm('This is strange the publicKey is not valid for\n' + webId + '\'shall we repair keeping the private key ?')) validPublicKey = false;
|
|
4114
|
+
}
|
|
4115
|
+
|
|
4116
|
+
// create key pair or repair publicKey
|
|
4117
|
+
if (!(!privateKey || !publicKey || !validPublicKey)) {
|
|
4118
|
+
_context2.next = 27;
|
|
4164
4119
|
break;
|
|
4165
4120
|
}
|
|
4166
4121
|
del = [];
|
|
4167
|
-
add = [];
|
|
4168
|
-
if (privateKey)
|
|
4169
|
-
|
|
4122
|
+
add = []; // if (privateKey) del.push($rdf.st($rdf.sym(webId), $rdf.sym(CERT + 'PrivateKey'), $rdf.lit(privateKey), $rdf.sym(privateKeyDoc)))
|
|
4123
|
+
if (privateKey) {
|
|
4124
|
+
_context2.next = 20;
|
|
4125
|
+
break;
|
|
4126
|
+
}
|
|
4127
|
+
// add = []
|
|
4170
4128
|
privateKey = generatePrivateKey();
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
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;
|
|
4177
|
-
return _solidLogic.store.updater.updateMany(del, add);
|
|
4178
|
-
case 19:
|
|
4179
|
-
return _context2.abrupt("return", privateKey);
|
|
4129
|
+
add = [$rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'PrivateKey'), $rdf.literal(privateKey), $rdf.sym(privateKeyDoc))];
|
|
4130
|
+
_context2.next = 20;
|
|
4131
|
+
return saveKey(privateKeyDoc, [], add, webId);
|
|
4180
4132
|
case 20:
|
|
4133
|
+
if (!(!publicKey || !validPublicKey)) {
|
|
4134
|
+
_context2.next = 27;
|
|
4135
|
+
break;
|
|
4136
|
+
}
|
|
4137
|
+
del = [];
|
|
4138
|
+
// delete invalid public key
|
|
4139
|
+
if (publicKey) {
|
|
4140
|
+
del = [$rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'PublicKey'), $rdf.lit(publicKey), $rdf.sym(publicKeyDoc))];
|
|
4141
|
+
debug.log(del);
|
|
4142
|
+
}
|
|
4143
|
+
// update new valid key
|
|
4144
|
+
newPublicKey = generatePublicKey(privateKey);
|
|
4145
|
+
add = [$rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'PublicKey'), $rdf.literal(newPublicKey), $rdf.sym(publicKeyDoc))];
|
|
4146
|
+
_context2.next = 27;
|
|
4147
|
+
return saveKey(publicKeyDoc, del, add);
|
|
4148
|
+
case 27:
|
|
4149
|
+
return _context2.abrupt("return", privateKey);
|
|
4150
|
+
case 28:
|
|
4181
4151
|
case "end":
|
|
4182
4152
|
return _context2.stop();
|
|
4183
4153
|
}
|
|
@@ -4185,6 +4155,108 @@ function _getPrivateKey() {
|
|
|
4185
4155
|
}));
|
|
4186
4156
|
return _getPrivateKey.apply(this, arguments);
|
|
4187
4157
|
}
|
|
4158
|
+
function setAcl(_x3) {
|
|
4159
|
+
return _setAcl.apply(this, arguments);
|
|
4160
|
+
}
|
|
4161
|
+
function _setAcl() {
|
|
4162
|
+
_setAcl = (0, _asyncToGenerator2["default"])(function (keyDoc) {
|
|
4163
|
+
var me = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
4164
|
+
return /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
4165
|
+
var keyAclDoc, keyAgent, aclBody, aclResponse;
|
|
4166
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
4167
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
4168
|
+
case 0:
|
|
4169
|
+
_context3.next = 2;
|
|
4170
|
+
return _solidLogic.store.fetcher.load(keyDoc);
|
|
4171
|
+
case 2:
|
|
4172
|
+
// FIXME: check the Why value on this quad:
|
|
4173
|
+
keyAclDoc = _solidLogic.store.any($rdf.sym(keyDoc), $rdf.sym('http://www.iana.org/assignments/link-relations/acl'));
|
|
4174
|
+
if (keyAclDoc) {
|
|
4175
|
+
_context3.next = 5;
|
|
4176
|
+
break;
|
|
4177
|
+
}
|
|
4178
|
+
throw new Error('Key ACL doc not found!');
|
|
4179
|
+
case 5:
|
|
4180
|
+
keyAgent = 'acl:agentClass foaf:agent';
|
|
4181
|
+
if (me !== null && me !== void 0 && me.length) keyAgent = "acl:agent <".concat(me, ">");
|
|
4182
|
+
aclBody = "\n@prefix foaf: <http://xmlns.com/foaf/0.1/>.\n@prefix acl: <http://www.w3.org/ns/auth/acl#>.\n<#Read>\n a acl:Authorization;\n ".concat(keyAgent, ";\n acl:accessTo <").concat(keyDoc.split('/').pop(), ">;\n acl:mode acl:Read.\n");
|
|
4183
|
+
_context3.next = 10;
|
|
4184
|
+
return _solidLogic.store.fetcher.webOperation('PUT', keyAclDoc.value, {
|
|
4185
|
+
data: aclBody,
|
|
4186
|
+
contentType: 'text/turtle'
|
|
4187
|
+
});
|
|
4188
|
+
case 10:
|
|
4189
|
+
aclResponse = _context3.sent;
|
|
4190
|
+
case 11:
|
|
4191
|
+
case "end":
|
|
4192
|
+
return _context3.stop();
|
|
4193
|
+
}
|
|
4194
|
+
}, _callee3);
|
|
4195
|
+
})();
|
|
4196
|
+
});
|
|
4197
|
+
return _setAcl.apply(this, arguments);
|
|
4198
|
+
}
|
|
4199
|
+
function saveKey(_x4, _x5, _x6) {
|
|
4200
|
+
return _saveKey.apply(this, arguments);
|
|
4201
|
+
}
|
|
4202
|
+
function _saveKey() {
|
|
4203
|
+
_saveKey = (0, _asyncToGenerator2["default"])(function (keyDoc, del, add) {
|
|
4204
|
+
var me = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
|
|
4205
|
+
return /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
|
|
4206
|
+
var keyAclDoc, response;
|
|
4207
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
4208
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
4209
|
+
case 0:
|
|
4210
|
+
_context4.prev = 0;
|
|
4211
|
+
// get keyAcldoc
|
|
4212
|
+
keyAclDoc = _solidLogic.store.any($rdf.sym(keyDoc), $rdf.sym('http://www.iana.org/assignments/link-relations/acl'));
|
|
4213
|
+
if (keyAclDoc) {
|
|
4214
|
+
_context4.next = 4;
|
|
4215
|
+
break;
|
|
4216
|
+
}
|
|
4217
|
+
throw new Error("".concat(keyDoc, " ACL doc not found!"));
|
|
4218
|
+
case 4:
|
|
4219
|
+
_context4.prev = 4;
|
|
4220
|
+
_context4.next = 7;
|
|
4221
|
+
return _solidLogic.store.fetcher.webOperation('DELETE', keyAclDoc.value);
|
|
4222
|
+
case 7:
|
|
4223
|
+
response = _context4.sent;
|
|
4224
|
+
// this may fail if webId is not an owner
|
|
4225
|
+
debug.log('delete ' + keyAclDoc.value + ' ' + response.status); // should test 404 and 2xx
|
|
4226
|
+
_context4.next = 16;
|
|
4227
|
+
break;
|
|
4228
|
+
case 11:
|
|
4229
|
+
_context4.prev = 11;
|
|
4230
|
+
_context4.t0 = _context4["catch"](4);
|
|
4231
|
+
if (!(_context4.t0.response.status !== 404)) {
|
|
4232
|
+
_context4.next = 15;
|
|
4233
|
+
break;
|
|
4234
|
+
}
|
|
4235
|
+
throw new Error(_context4.t0);
|
|
4236
|
+
case 15:
|
|
4237
|
+
debug.log('delete ' + keyAclDoc.value + ' ' + _context4.t0.response.status); // should test 404 and 2xx
|
|
4238
|
+
case 16:
|
|
4239
|
+
_context4.next = 18;
|
|
4240
|
+
return _solidLogic.store.updater.updateMany(del, add);
|
|
4241
|
+
case 18:
|
|
4242
|
+
_context4.next = 20;
|
|
4243
|
+
return setAcl(keyDoc, me);
|
|
4244
|
+
case 20:
|
|
4245
|
+
_context4.next = 25;
|
|
4246
|
+
break;
|
|
4247
|
+
case 22:
|
|
4248
|
+
_context4.prev = 22;
|
|
4249
|
+
_context4.t1 = _context4["catch"](0);
|
|
4250
|
+
throw new Error(_context4.t1);
|
|
4251
|
+
case 25:
|
|
4252
|
+
case "end":
|
|
4253
|
+
return _context4.stop();
|
|
4254
|
+
}
|
|
4255
|
+
}, _callee4, null, [[0, 22], [4, 11]]);
|
|
4256
|
+
})();
|
|
4257
|
+
});
|
|
4258
|
+
return _saveKey.apply(this, arguments);
|
|
4259
|
+
}
|
|
4188
4260
|
//# sourceMappingURL=keys.js.map
|
|
4189
4261
|
|
|
4190
4262
|
/***/ }),
|
|
@@ -4314,30 +4386,37 @@ function renderMessageRow(channelObject, message, fresh, options, userContext) {
|
|
|
4314
4386
|
var date = _solidLogic.store.any(message, ns.dct('created'));
|
|
4315
4387
|
var latestVersion = (0, _chatLogic.mostRecentVersion)(message);
|
|
4316
4388
|
var latestVersionCreator = _solidLogic.store.any(latestVersion, ns.foaf('maker'));
|
|
4389
|
+
|
|
4317
4390
|
// use latest content if same owner, else use original
|
|
4318
|
-
var msgId = creator === latestVersionCreator ? latestVersion : message;
|
|
4391
|
+
var msgId = creator.uri === latestVersionCreator.uri ? latestVersion : message;
|
|
4319
4392
|
var content = _solidLogic.store.any(msgId, ns.sioc('content'));
|
|
4320
4393
|
var signature = _solidLogic.store.any(msgId, $rdf.sym("".concat(_signature.SEC, "Proof")));
|
|
4321
|
-
debug.log('alain ' + (signature === null || signature === void 0 ? void 0 : signature.value));
|
|
4322
4394
|
|
|
4323
|
-
//
|
|
4395
|
+
// set message object
|
|
4324
4396
|
var msg = (0, _signature.getBlankMsg)();
|
|
4325
4397
|
msg.id = msgId.uri;
|
|
4326
4398
|
msg.created = _solidLogic.store.any(msgId, ns.dct('created')).value;
|
|
4327
4399
|
msg.content = content.value;
|
|
4328
4400
|
msg.maker = creator.uri;
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4401
|
+
|
|
4402
|
+
// unsigned message
|
|
4403
|
+
if (!(signature !== null && signature !== void 0 && signature.value)) debug.warn(msgId.uri + ' is unsigned'); // TODO replace with UI (colored message ?)
|
|
4404
|
+
|
|
4405
|
+
// signed message, get public key and check signature
|
|
4406
|
+
else {
|
|
4407
|
+
(0, _keys.getPublicKey)(creator.uri).then(function (publicKey) {
|
|
4408
|
+
debug.log(creator.uri + '\n' + msg.created + '\n' + msg.id + '\n' + publicKey);
|
|
4409
|
+
if (!publicKey) {
|
|
4410
|
+
// TODO try to recreate the publicKey
|
|
4411
|
+
// if(me.uri === creator.uri) await getPrivateKey(creator.uri)
|
|
4412
|
+
debug.warn('message is signed but ' + creator.uri + ' is missing publicKey');
|
|
4413
|
+
}
|
|
4414
|
+
// check that publicKey is a valid hex string
|
|
4415
|
+
var regex = /[0-9A-Fa-f]{6}/g;
|
|
4416
|
+
if (!(publicKey !== null && publicKey !== void 0 && publicKey.match(regex))) debug.warn('invalid publicKey hex string\n' + creator.uri + '\n' + publicKey);
|
|
4417
|
+
// verify signature
|
|
4418
|
+
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);
|
|
4419
|
+
});
|
|
4341
4420
|
}
|
|
4342
4421
|
var originalMessage = (0, _chatLogic.originalVersion)(message);
|
|
4343
4422
|
var edited = !message.sameTerm(originalMessage);
|
|
@@ -12439,6 +12518,161 @@ function isLight(x) {
|
|
|
12439
12518
|
|
|
12440
12519
|
/***/ }),
|
|
12441
12520
|
|
|
12521
|
+
/***/ "./lib/utils/cryptoKeyHelpers.js":
|
|
12522
|
+
/*!***************************************!*\
|
|
12523
|
+
!*** ./lib/utils/cryptoKeyHelpers.js ***!
|
|
12524
|
+
\***************************************/
|
|
12525
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
12526
|
+
|
|
12527
|
+
"use strict";
|
|
12528
|
+
|
|
12529
|
+
|
|
12530
|
+
var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");
|
|
12531
|
+
var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
|
|
12532
|
+
Object.defineProperty(exports, "__esModule", ({
|
|
12533
|
+
value: true
|
|
12534
|
+
}));
|
|
12535
|
+
exports.privKeyUrl = void 0;
|
|
12536
|
+
exports.privateKeyExists = privateKeyExists;
|
|
12537
|
+
exports.pubKeyUrl = void 0;
|
|
12538
|
+
exports.publicKeyExists = publicKeyExists;
|
|
12539
|
+
var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
|
|
12540
|
+
var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
|
|
12541
|
+
var debug = _interopRequireWildcard(__webpack_require__(/*! ../debug */ "./lib/debug.js"));
|
|
12542
|
+
var _signature = __webpack_require__(/*! ../chat/signature */ "./lib/chat/signature.js");
|
|
12543
|
+
var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
|
|
12544
|
+
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); }
|
|
12545
|
+
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; }
|
|
12546
|
+
var pubKeyUrl = function pubKeyUrl(webId) {
|
|
12547
|
+
var url = new URL(webId);
|
|
12548
|
+
// find storage in webId
|
|
12549
|
+
var storage = _solidLogic.store.each(_solidLogic.store.sym(webId), _solidLogic.store.sym('http://www.w3.org/ns/pim/space#storage'));
|
|
12550
|
+
var pod = storage.length === 1 ? storage : storage.find(function (node) {
|
|
12551
|
+
return url.origin === new URL(node.value).origin;
|
|
12552
|
+
});
|
|
12553
|
+
var podUrl = Array.isArray(pod) ? pod[0] : pod;
|
|
12554
|
+
if (!(podUrl !== null && podUrl !== void 0 && podUrl.value)) throw Error('No space:storage in ' + webId);
|
|
12555
|
+
var publicKeyUrl = podUrl.value + 'profile/keys/publicKey.ttl';
|
|
12556
|
+
return publicKeyUrl;
|
|
12557
|
+
};
|
|
12558
|
+
exports.pubKeyUrl = pubKeyUrl;
|
|
12559
|
+
function publicKeyExists(_x) {
|
|
12560
|
+
return _publicKeyExists.apply(this, arguments);
|
|
12561
|
+
}
|
|
12562
|
+
function _publicKeyExists() {
|
|
12563
|
+
_publicKeyExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
|
|
12564
|
+
var publicKeyUrl;
|
|
12565
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
12566
|
+
while (1) switch (_context.prev = _context.next) {
|
|
12567
|
+
case 0:
|
|
12568
|
+
// find publickey
|
|
12569
|
+
publicKeyUrl = pubKeyUrl(webId);
|
|
12570
|
+
_context.next = 3;
|
|
12571
|
+
return keyExists(webId, publicKeyUrl, 'PublicKey');
|
|
12572
|
+
case 3:
|
|
12573
|
+
return _context.abrupt("return", _context.sent);
|
|
12574
|
+
case 4:
|
|
12575
|
+
case "end":
|
|
12576
|
+
return _context.stop();
|
|
12577
|
+
}
|
|
12578
|
+
}, _callee);
|
|
12579
|
+
}));
|
|
12580
|
+
return _publicKeyExists.apply(this, arguments);
|
|
12581
|
+
}
|
|
12582
|
+
var privKeyUrl = function privKeyUrl(webId) {
|
|
12583
|
+
var url = new URL(webId);
|
|
12584
|
+
// find storage in webId
|
|
12585
|
+
var storage = _solidLogic.store.each(_solidLogic.store.sym(webId), _solidLogic.store.sym('http://www.w3.org/ns/pim/space#storage'));
|
|
12586
|
+
var pod = storage.length === 1 ? storage : storage.find(function (node) {
|
|
12587
|
+
return url.origin === new URL(node.value).origin;
|
|
12588
|
+
});
|
|
12589
|
+
var podUrl = Array.isArray(pod) ? pod[0] : pod;
|
|
12590
|
+
if (!(podUrl !== null && podUrl !== void 0 && podUrl.value)) throw Error('Expected space:storage in ' + webId);
|
|
12591
|
+
var privateKeyUrl = (podUrl === null || podUrl === void 0 ? void 0 : podUrl.value) + 'profile/keys/privateKey.ttl';
|
|
12592
|
+
return privateKeyUrl;
|
|
12593
|
+
};
|
|
12594
|
+
exports.privKeyUrl = privKeyUrl;
|
|
12595
|
+
function privateKeyExists(_x2) {
|
|
12596
|
+
return _privateKeyExists.apply(this, arguments);
|
|
12597
|
+
}
|
|
12598
|
+
function _privateKeyExists() {
|
|
12599
|
+
_privateKeyExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
|
|
12600
|
+
var privateKeyUrl;
|
|
12601
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
12602
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
12603
|
+
case 0:
|
|
12604
|
+
// find privateKey
|
|
12605
|
+
privateKeyUrl = privKeyUrl(webId);
|
|
12606
|
+
_context2.next = 3;
|
|
12607
|
+
return keyExists(webId, privateKeyUrl, 'PrivateKey');
|
|
12608
|
+
case 3:
|
|
12609
|
+
return _context2.abrupt("return", _context2.sent);
|
|
12610
|
+
case 4:
|
|
12611
|
+
case "end":
|
|
12612
|
+
return _context2.stop();
|
|
12613
|
+
}
|
|
12614
|
+
}, _callee2);
|
|
12615
|
+
}));
|
|
12616
|
+
return _privateKeyExists.apply(this, arguments);
|
|
12617
|
+
}
|
|
12618
|
+
function keyExists(_x3, _x4, _x5) {
|
|
12619
|
+
return _keyExists.apply(this, arguments);
|
|
12620
|
+
}
|
|
12621
|
+
function _keyExists() {
|
|
12622
|
+
_keyExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId, keyUrl, keyType) {
|
|
12623
|
+
var key, _err$response, data, contentType, response;
|
|
12624
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
12625
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
12626
|
+
case 0:
|
|
12627
|
+
_context3.prev = 0;
|
|
12628
|
+
_context3.next = 3;
|
|
12629
|
+
return _solidLogic.store.fetcher.load(keyUrl);
|
|
12630
|
+
case 3:
|
|
12631
|
+
key = _solidLogic.store.any(_solidLogic.store.sym(webId), _solidLogic.store.sym(_signature.CERT + keyType));
|
|
12632
|
+
return _context3.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
|
|
12633
|
+
case 7:
|
|
12634
|
+
_context3.prev = 7;
|
|
12635
|
+
_context3.t0 = _context3["catch"](0);
|
|
12636
|
+
if (!((_context3.t0 === null || _context3.t0 === void 0 ? void 0 : (_err$response = _context3.t0.response) === null || _err$response === void 0 ? void 0 : _err$response.status) === 404)) {
|
|
12637
|
+
_context3.next = 24;
|
|
12638
|
+
break;
|
|
12639
|
+
}
|
|
12640
|
+
_context3.prev = 10;
|
|
12641
|
+
// create privateKey resource
|
|
12642
|
+
data = '';
|
|
12643
|
+
contentType = 'text/turtle';
|
|
12644
|
+
_context3.next = 15;
|
|
12645
|
+
return _solidLogic.store.fetcher.webOperation('PUT', keyUrl, {
|
|
12646
|
+
data: data,
|
|
12647
|
+
contentType: contentType
|
|
12648
|
+
});
|
|
12649
|
+
case 15:
|
|
12650
|
+
response = _context3.sent;
|
|
12651
|
+
_context3.next = 22;
|
|
12652
|
+
break;
|
|
12653
|
+
case 18:
|
|
12654
|
+
_context3.prev = 18;
|
|
12655
|
+
_context3.t1 = _context3["catch"](10);
|
|
12656
|
+
debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context3.t1);
|
|
12657
|
+
throw _context3.t1;
|
|
12658
|
+
case 22:
|
|
12659
|
+
delete _solidLogic.store.fetcher.requested[keyUrl]; // delete cached 404 error
|
|
12660
|
+
return _context3.abrupt("return", undefined);
|
|
12661
|
+
case 24:
|
|
12662
|
+
debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context3.t0);
|
|
12663
|
+
throw _context3.t0;
|
|
12664
|
+
case 26:
|
|
12665
|
+
case "end":
|
|
12666
|
+
return _context3.stop();
|
|
12667
|
+
}
|
|
12668
|
+
}, _callee3, null, [[0, 7], [10, 18]]);
|
|
12669
|
+
}));
|
|
12670
|
+
return _keyExists.apply(this, arguments);
|
|
12671
|
+
}
|
|
12672
|
+
//# sourceMappingURL=cryptoKeyHelpers.js.map
|
|
12673
|
+
|
|
12674
|
+
/***/ }),
|
|
12675
|
+
|
|
12442
12676
|
/***/ "./lib/utils/headerFooterHelpers.js":
|
|
12443
12677
|
/*!******************************************!*\
|
|
12444
12678
|
!*** ./lib/utils/headerFooterHelpers.js ***!
|
|
@@ -13285,8 +13519,8 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
13285
13519
|
}));
|
|
13286
13520
|
exports.versionInfo = void 0;
|
|
13287
13521
|
var versionInfo = {
|
|
13288
|
-
buildTime: '2023-04-
|
|
13289
|
-
commit: '
|
|
13522
|
+
buildTime: '2023-04-29T23:09:27Z',
|
|
13523
|
+
commit: 'e6d67dd8caf3c8261ced536258b78723fd07f0a8',
|
|
13290
13524
|
npmInfo: {
|
|
13291
13525
|
'solid-ui': '2.4.27',
|
|
13292
13526
|
npm: '8.19.4',
|