solid-ui 2.4.27-17005e61 → 2.4.27-18070a02
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 +530 -509
- 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/chatLogic.js +16 -17
- package/lib/chat/chatLogic.js.map +1 -1
- package/lib/chat/keys.d.ts.map +1 -1
- package/lib/chat/keys.js +38 -121
- package/lib/chat/keys.js.map +1 -1
- package/lib/chat/message.js +1 -1
- package/lib/chat/message.js.map +1 -1
- package/lib/chat/signature.d.ts +0 -2
- package/lib/chat/signature.d.ts.map +1 -1
- package/lib/chat/signature.js +23 -20
- package/lib/chat/signature.js.map +1 -1
- package/lib/utils/keyHelpers/accessData.d.ts +10 -0
- package/lib/utils/keyHelpers/accessData.d.ts.map +1 -0
- package/lib/utils/{cryptoKeyHelpers.js → keyHelpers/accessData.js} +30 -39
- package/lib/utils/keyHelpers/accessData.js.map +1 -0
- package/lib/utils/keyHelpers/acl.d.ts +20 -0
- package/lib/utils/keyHelpers/acl.d.ts.map +1 -0
- package/lib/utils/keyHelpers/acl.js +101 -0
- package/lib/utils/keyHelpers/acl.js.map +1 -0
- package/lib/versionInfo.js +2 -2
- package/lib/versionInfo.js.map +1 -1
- package/package.json +1 -1
- package/lib/utils/cryptoKeyHelpers.d.ts +0 -6
- package/lib/utils/cryptoKeyHelpers.d.ts.map +0 -1
- package/lib/utils/cryptoKeyHelpers.js.map +0 -1
package/dist/solid-ui.js
CHANGED
|
@@ -2655,7 +2655,7 @@ var ChatChannel = /*#__PURE__*/function () {
|
|
|
2655
2655
|
var oldMsg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
2656
2656
|
var deleteIt = arguments.length > 2 ? arguments[2] : undefined;
|
|
2657
2657
|
return /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
2658
|
-
var sts, now, timestamp, dateStamp, chatDocument, message, me, msg, oldMsgMaker, errMsg, privateKey,
|
|
2658
|
+
var sts, now, timestamp, dateStamp, chatDocument, message, me, msg, oldMsgMaker, errMsg, privateKey, sig, _errMsg;
|
|
2659
2659
|
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
2660
2660
|
while (1) switch (_context2.prev = _context2.next) {
|
|
2661
2661
|
case 0:
|
|
@@ -2703,7 +2703,7 @@ var ChatChannel = /*#__PURE__*/function () {
|
|
|
2703
2703
|
sts.push($rdf.st(message, ns.dct('created'), dateStamp, chatDocument));
|
|
2704
2704
|
msg.created = dateStamp.value;
|
|
2705
2705
|
if (!me) {
|
|
2706
|
-
_context2.next =
|
|
2706
|
+
_context2.next = 35;
|
|
2707
2707
|
break;
|
|
2708
2708
|
}
|
|
2709
2709
|
sts.push($rdf.st(message, ns.foaf('maker'), me, chatDocument));
|
|
@@ -2715,35 +2715,34 @@ var ChatChannel = /*#__PURE__*/function () {
|
|
|
2715
2715
|
privateKey = _context2.sent;
|
|
2716
2716
|
// me.uri)
|
|
2717
2717
|
// const privateKey0 = 'a11bc5d2eee6cdb3b37f5473a712cad905ccfb13fb2ccdbf1be0a1ac4fdc7d2a'
|
|
2718
|
-
// const pubKey0 = '023a9da707bee1302f66083c9d95673ff969b41607a66f52686fa774d64ceb87'
|
|
2719
|
-
pubKey =
|
|
2720
|
-
|
|
2721
|
-
/* const verify = verifySignature(sig, msg, pubKey) // alain to remove
|
|
2718
|
+
sig = (0, _signature.signMsg)(msg, privateKey); // const pubKey0 = '023a9da707bee1302f66083c9d95673ff969b41607a66f52686fa774d64ceb87'
|
|
2719
|
+
/* const pubKey = await getPublicKey(me)
|
|
2720
|
+
const verify = verifySignature(sig, msg, pubKey) // alain to remove
|
|
2722
2721
|
debug.warn('sig ' + sig)
|
|
2723
2722
|
debug.warn('verifySign ' + verify)
|
|
2724
2723
|
debug.warn(msg) */
|
|
2725
2724
|
sts.push($rdf.st(message, $rdf.sym("".concat(_signature.SEC, "Proof")), $rdf.lit(sig), chatDocument));
|
|
2726
|
-
case
|
|
2727
|
-
_context2.prev =
|
|
2728
|
-
_context2.next =
|
|
2725
|
+
case 35:
|
|
2726
|
+
_context2.prev = 35;
|
|
2727
|
+
_context2.next = 38;
|
|
2729
2728
|
return _solidLogic.store.updater.update([], sts);
|
|
2730
|
-
case
|
|
2731
|
-
_context2.next =
|
|
2729
|
+
case 38:
|
|
2730
|
+
_context2.next = 46;
|
|
2732
2731
|
break;
|
|
2733
|
-
case
|
|
2734
|
-
_context2.prev =
|
|
2735
|
-
_context2.t0 = _context2["catch"](
|
|
2732
|
+
case 40:
|
|
2733
|
+
_context2.prev = 40;
|
|
2734
|
+
_context2.t0 = _context2["catch"](35);
|
|
2736
2735
|
_errMsg = 'Error saving chat message: ' + _context2.t0;
|
|
2737
2736
|
debug.warn(_errMsg);
|
|
2738
2737
|
alert(_errMsg);
|
|
2739
2738
|
throw new Error(_errMsg);
|
|
2740
|
-
case
|
|
2739
|
+
case 46:
|
|
2741
2740
|
return _context2.abrupt("return", message);
|
|
2742
|
-
case
|
|
2741
|
+
case 47:
|
|
2743
2742
|
case "end":
|
|
2744
2743
|
return _context2.stop();
|
|
2745
2744
|
}
|
|
2746
|
-
}, _callee2, null, [[
|
|
2745
|
+
}, _callee2, null, [[35, 40]]);
|
|
2747
2746
|
})();
|
|
2748
2747
|
});
|
|
2749
2748
|
function updateMessage(_x2) {
|
|
@@ -4044,7 +4043,8 @@ var _utils = __webpack_require__(/*! @noble/hashes/utils */ "./node_modules/@nob
|
|
|
4044
4043
|
var _signature = __webpack_require__(/*! ./signature */ "./lib/chat/signature.js");
|
|
4045
4044
|
var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
|
|
4046
4045
|
var $rdf = _interopRequireWildcard(__webpack_require__(/*! rdflib */ "./node_modules/rdflib/esm/index.js"));
|
|
4047
|
-
var
|
|
4046
|
+
var _accessData = __webpack_require__(/*! ../utils/keyHelpers/accessData */ "./lib/utils/keyHelpers/accessData.js");
|
|
4047
|
+
var _acl = __webpack_require__(/*! ../utils/keyHelpers/acl */ "./lib/utils/keyHelpers/acl.js");
|
|
4048
4048
|
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); }
|
|
4049
4049
|
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; }
|
|
4050
4050
|
function generatePrivateKey() {
|
|
@@ -4066,7 +4066,7 @@ function _getPublicKey() {
|
|
|
4066
4066
|
return _solidLogic.store.fetcher.load(webId);
|
|
4067
4067
|
case 2:
|
|
4068
4068
|
_context.next = 4;
|
|
4069
|
-
return (0,
|
|
4069
|
+
return (0, _accessData.pubKeyUrl)(webId);
|
|
4070
4070
|
case 4:
|
|
4071
4071
|
publicKeyDoc = _context.sent;
|
|
4072
4072
|
_context.prev = 5;
|
|
@@ -4092,9 +4092,9 @@ function getPrivateKey(_x2) {
|
|
|
4092
4092
|
return _getPrivateKey.apply(this, arguments);
|
|
4093
4093
|
}
|
|
4094
4094
|
/**
|
|
4095
|
-
*
|
|
4096
|
-
*
|
|
4097
|
-
*
|
|
4095
|
+
* delete acl if keydoc exists
|
|
4096
|
+
* create/edit keyDoc
|
|
4097
|
+
* set keyDoc acl
|
|
4098
4098
|
*/
|
|
4099
4099
|
function _getPrivateKey() {
|
|
4100
4100
|
_getPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
|
|
@@ -4106,19 +4106,19 @@ function _getPrivateKey() {
|
|
|
4106
4106
|
return _solidLogic.store.fetcher.load(webId);
|
|
4107
4107
|
case 2:
|
|
4108
4108
|
_context2.next = 4;
|
|
4109
|
-
return (0,
|
|
4109
|
+
return (0, _accessData.pubKeyUrl)(webId);
|
|
4110
4110
|
case 4:
|
|
4111
4111
|
publicKeyDoc = _context2.sent;
|
|
4112
4112
|
_context2.next = 7;
|
|
4113
|
-
return (0,
|
|
4113
|
+
return (0, _accessData.privKeyUrl)(webId);
|
|
4114
4114
|
case 7:
|
|
4115
4115
|
privateKeyDoc = _context2.sent;
|
|
4116
4116
|
_context2.next = 10;
|
|
4117
|
-
return (0,
|
|
4117
|
+
return (0, _accessData.getExistingPublicKey)(webId, publicKeyDoc);
|
|
4118
4118
|
case 10:
|
|
4119
4119
|
publicKey = _context2.sent;
|
|
4120
4120
|
_context2.next = 13;
|
|
4121
|
-
return (0,
|
|
4121
|
+
return (0, _accessData.getExistingPrivateKey)(webId, privateKeyDoc);
|
|
4122
4122
|
case 13:
|
|
4123
4123
|
privateKey = _context2.sent;
|
|
4124
4124
|
// is publicKey valid ?
|
|
@@ -4162,7 +4162,7 @@ function _getPrivateKey() {
|
|
|
4162
4162
|
case 31:
|
|
4163
4163
|
keyContainer = privateKeyDoc.substring(0, privateKeyDoc.lastIndexOf('/') + 1);
|
|
4164
4164
|
_context2.next = 34;
|
|
4165
|
-
return setAcl(keyContainer, keyContainerAclBody(webId.uri));
|
|
4165
|
+
return (0, _acl.setAcl)(keyContainer, (0, _acl.keyContainerAclBody)(webId.uri));
|
|
4166
4166
|
case 34:
|
|
4167
4167
|
return _context2.abrupt("return", privateKey);
|
|
4168
4168
|
case 35:
|
|
@@ -4173,151 +4173,67 @@ function _getPrivateKey() {
|
|
|
4173
4173
|
}));
|
|
4174
4174
|
return _getPrivateKey.apply(this, arguments);
|
|
4175
4175
|
}
|
|
4176
|
-
|
|
4177
|
-
var aclBody = "\n@prefix : <#>.\n@prefix acl: <http://www.w3.org/ns/auth/acl#>.\n@prefix foaf: <http://xmlns.com/foaf/0.1/>.\n@prefix key: <./>.\n\n:ReadWrite\n a acl:Authorization;\n acl:accessTo key:;\n acl:default key:;\n acl:agent <".concat(me, ">;\n acl:mode acl:Read, acl:Write.\n");
|
|
4178
|
-
return aclBody;
|
|
4179
|
-
};
|
|
4180
|
-
|
|
4181
|
-
/**
|
|
4182
|
-
* Read only ACL
|
|
4183
|
-
* @param keyDoc
|
|
4184
|
-
* @param me
|
|
4185
|
-
* @returns aclBody
|
|
4186
|
-
*/
|
|
4187
|
-
var keyAclBody = function keyAclBody(keyDoc, me) {
|
|
4188
|
-
var keyAgent = 'acl:agentClass foaf:Agent'; // publicKey
|
|
4189
|
-
if (me !== null && me !== void 0 && me.length) keyAgent = "acl:agent <".concat(me, ">"); // privateKey
|
|
4190
|
-
var 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");
|
|
4191
|
-
return aclBody;
|
|
4192
|
-
};
|
|
4193
|
-
|
|
4194
|
-
/**
|
|
4195
|
-
* set ACL
|
|
4196
|
-
* @param keyDoc
|
|
4197
|
-
* @param aclBody
|
|
4198
|
-
*/
|
|
4199
|
-
function setAcl(_x3, _x4) {
|
|
4200
|
-
return _setAcl.apply(this, arguments);
|
|
4201
|
-
}
|
|
4202
|
-
/**
|
|
4203
|
-
* delete acl if keydoc exists
|
|
4204
|
-
* create/edit keyDoc
|
|
4205
|
-
* set keyDoc acl
|
|
4206
|
-
*/
|
|
4207
|
-
function _setAcl() {
|
|
4208
|
-
_setAcl = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(keyDoc, aclBody) {
|
|
4209
|
-
var keyAclDoc, response, aclResponse;
|
|
4210
|
-
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
4211
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
4212
|
-
case 0:
|
|
4213
|
-
_context3.next = 2;
|
|
4214
|
-
return _solidLogic.store.fetcher.load(keyDoc);
|
|
4215
|
-
case 2:
|
|
4216
|
-
// FIXME: check the Why value on this quad:
|
|
4217
|
-
debug.log(_solidLogic.store.statementsMatching(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl')));
|
|
4218
|
-
keyAclDoc = _solidLogic.store.any(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl'));
|
|
4219
|
-
if (keyAclDoc) {
|
|
4220
|
-
_context3.next = 6;
|
|
4221
|
-
break;
|
|
4222
|
-
}
|
|
4223
|
-
throw new Error('Key ACL doc not found!');
|
|
4224
|
-
case 6:
|
|
4225
|
-
_context3.prev = 6;
|
|
4226
|
-
_context3.next = 9;
|
|
4227
|
-
return _solidLogic.store.fetcher.webOperation('DELETE', keyAclDoc.value);
|
|
4228
|
-
case 9:
|
|
4229
|
-
response = _context3.sent;
|
|
4230
|
-
// this may fail if webId is not an owner
|
|
4231
|
-
debug.log('delete ' + keyAclDoc.value + ' ' + response.status); // should test 404 and 2xx
|
|
4232
|
-
_context3.next = 18;
|
|
4233
|
-
break;
|
|
4234
|
-
case 13:
|
|
4235
|
-
_context3.prev = 13;
|
|
4236
|
-
_context3.t0 = _context3["catch"](6);
|
|
4237
|
-
if (!(_context3.t0.response.status !== 404)) {
|
|
4238
|
-
_context3.next = 17;
|
|
4239
|
-
break;
|
|
4240
|
-
}
|
|
4241
|
-
throw new Error(_context3.t0);
|
|
4242
|
-
case 17:
|
|
4243
|
-
debug.log('delete ' + keyAclDoc.value + ' ' + _context3.t0.response.status); // should test 404 and 2xx
|
|
4244
|
-
case 18:
|
|
4245
|
-
_context3.next = 20;
|
|
4246
|
-
return _solidLogic.store.fetcher.webOperation('PUT', keyAclDoc.value, {
|
|
4247
|
-
data: aclBody,
|
|
4248
|
-
contentType: 'text/turtle'
|
|
4249
|
-
});
|
|
4250
|
-
case 20:
|
|
4251
|
-
aclResponse = _context3.sent;
|
|
4252
|
-
case 21:
|
|
4253
|
-
case "end":
|
|
4254
|
-
return _context3.stop();
|
|
4255
|
-
}
|
|
4256
|
-
}, _callee3, null, [[6, 13]]);
|
|
4257
|
-
}));
|
|
4258
|
-
return _setAcl.apply(this, arguments);
|
|
4259
|
-
}
|
|
4260
|
-
function saveKey(_x5, _x6, _x7) {
|
|
4176
|
+
function saveKey(_x3, _x4, _x5) {
|
|
4261
4177
|
return _saveKey.apply(this, arguments);
|
|
4262
4178
|
}
|
|
4263
4179
|
function _saveKey() {
|
|
4264
4180
|
_saveKey = (0, _asyncToGenerator2["default"])(function (keyDoc, del, add) {
|
|
4265
4181
|
var me = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
|
|
4266
|
-
return /*#__PURE__*/_regenerator["default"].mark(function
|
|
4182
|
+
return /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
4267
4183
|
var keyAclDoc, response, aclBody;
|
|
4268
|
-
return _regenerator["default"].wrap(function
|
|
4269
|
-
while (1) switch (
|
|
4184
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
4185
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
4270
4186
|
case 0:
|
|
4271
|
-
|
|
4187
|
+
_context3.next = 2;
|
|
4272
4188
|
return _solidLogic.store.fetcher.load(keyDoc);
|
|
4273
4189
|
case 2:
|
|
4274
|
-
|
|
4190
|
+
_context3.prev = 2;
|
|
4275
4191
|
// get keyAcldoc
|
|
4276
4192
|
keyAclDoc = _solidLogic.store.any(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl'));
|
|
4277
4193
|
if (!keyAclDoc) {
|
|
4278
|
-
|
|
4194
|
+
_context3.next = 17;
|
|
4279
4195
|
break;
|
|
4280
4196
|
}
|
|
4281
|
-
|
|
4282
|
-
|
|
4197
|
+
_context3.prev = 5;
|
|
4198
|
+
_context3.next = 8;
|
|
4283
4199
|
return _solidLogic.store.fetcher.webOperation('DELETE', keyAclDoc.value);
|
|
4284
4200
|
case 8:
|
|
4285
|
-
response =
|
|
4201
|
+
response = _context3.sent;
|
|
4286
4202
|
// this may fail if webId is not an owner
|
|
4287
4203
|
debug.log('delete ' + keyAclDoc.value + ' ' + response.status); // should test 404 and 2xx
|
|
4288
|
-
|
|
4204
|
+
_context3.next = 17;
|
|
4289
4205
|
break;
|
|
4290
4206
|
case 12:
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
if (!(
|
|
4294
|
-
|
|
4207
|
+
_context3.prev = 12;
|
|
4208
|
+
_context3.t0 = _context3["catch"](5);
|
|
4209
|
+
if (!(_context3.t0.response.status !== 404)) {
|
|
4210
|
+
_context3.next = 16;
|
|
4295
4211
|
break;
|
|
4296
4212
|
}
|
|
4297
|
-
throw new Error(
|
|
4213
|
+
throw new Error(_context3.t0);
|
|
4298
4214
|
case 16:
|
|
4299
|
-
debug.log('delete ' + keyAclDoc.value + ' ' +
|
|
4215
|
+
debug.log('delete ' + keyAclDoc.value + ' ' + _context3.t0.response.status); // should test 404 and 2xx
|
|
4300
4216
|
case 17:
|
|
4301
|
-
|
|
4217
|
+
_context3.next = 19;
|
|
4302
4218
|
return _solidLogic.store.updater.updateMany(del, add);
|
|
4303
4219
|
case 19:
|
|
4304
4220
|
// or a promise store.updater.update ?
|
|
4305
4221
|
// create READ only ACL
|
|
4306
|
-
aclBody = keyAclBody(keyDoc, me);
|
|
4307
|
-
|
|
4308
|
-
return setAcl(keyDoc, aclBody);
|
|
4222
|
+
aclBody = (0, _acl.keyAclBody)(keyDoc, me);
|
|
4223
|
+
_context3.next = 22;
|
|
4224
|
+
return (0, _acl.setAcl)(keyDoc, aclBody);
|
|
4309
4225
|
case 22:
|
|
4310
|
-
|
|
4226
|
+
_context3.next = 27;
|
|
4311
4227
|
break;
|
|
4312
4228
|
case 24:
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
throw new Error(
|
|
4229
|
+
_context3.prev = 24;
|
|
4230
|
+
_context3.t1 = _context3["catch"](2);
|
|
4231
|
+
throw new Error(_context3.t1);
|
|
4316
4232
|
case 27:
|
|
4317
4233
|
case "end":
|
|
4318
|
-
return
|
|
4234
|
+
return _context3.stop();
|
|
4319
4235
|
}
|
|
4320
|
-
},
|
|
4236
|
+
}, _callee3, null, [[2, 24], [5, 12]]);
|
|
4321
4237
|
})();
|
|
4322
4238
|
});
|
|
4323
4239
|
return _saveKey.apply(this, arguments);
|
|
@@ -4469,7 +4385,7 @@ function renderMessageRow(channelObject, message, fresh, options, userContext) {
|
|
|
4469
4385
|
|
|
4470
4386
|
// signed message, get public key and check signature
|
|
4471
4387
|
else {
|
|
4472
|
-
(0, _keys.getPublicKey)(creator
|
|
4388
|
+
(0, _keys.getPublicKey)(creator).then(function (publicKey) {
|
|
4473
4389
|
debug.log(creator.uri + '\n' + msg.created + '\n' + msg.id + '\n' + publicKey);
|
|
4474
4390
|
if (!publicKey) {
|
|
4475
4391
|
// TODO try to recreate the publicKey
|
|
@@ -5276,13 +5192,11 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
5276
5192
|
value: true
|
|
5277
5193
|
}));
|
|
5278
5194
|
exports.SEC = exports.CERT = void 0;
|
|
5279
|
-
exports.finishMsg = finishMsg;
|
|
5280
5195
|
exports.getBlankMsg = getBlankMsg;
|
|
5281
5196
|
exports.getMsgHash = getMsgHash;
|
|
5282
5197
|
exports.serializeMsg = serializeMsg;
|
|
5283
5198
|
exports.signMsg = signMsg;
|
|
5284
5199
|
exports.utf8Encoder = exports.utf8Decoder = void 0;
|
|
5285
|
-
exports.validateMsg = validateMsg;
|
|
5286
5200
|
exports.verifySignature = verifySignature;
|
|
5287
5201
|
var _secp256k = __webpack_require__(/*! @noble/curves/secp256k1 */ "./node_modules/@noble/curves/secp256k1.js");
|
|
5288
5202
|
var _utils = __webpack_require__(/*! @noble/hashes/utils */ "./node_modules/@noble/hashes/utils.js");
|
|
@@ -5328,19 +5242,22 @@ function getBlankMsg() {
|
|
|
5328
5242
|
id: '',
|
|
5329
5243
|
created: '',
|
|
5330
5244
|
dateDeleted: '',
|
|
5245
|
+
// TODO to remove if not used
|
|
5331
5246
|
content: '',
|
|
5332
5247
|
maker: '',
|
|
5333
|
-
sig: ''
|
|
5248
|
+
sig: '' // TODO to remove if not used
|
|
5334
5249
|
};
|
|
5335
5250
|
}
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
message.
|
|
5341
|
-
message.
|
|
5342
|
-
|
|
5343
|
-
|
|
5251
|
+
|
|
5252
|
+
/* export function finishMsg (t: MsgTemplate, privateKey: string): Message {
|
|
5253
|
+
// to update to chat message triples
|
|
5254
|
+
const message = t as Message
|
|
5255
|
+
// message.pubkey = getPublicKey(privateKey)
|
|
5256
|
+
message.id = getMsgHash(message)
|
|
5257
|
+
message.sig = signMsg(message, privateKey)
|
|
5258
|
+
return message
|
|
5259
|
+
} */
|
|
5260
|
+
|
|
5344
5261
|
function serializeMsg(msg) {
|
|
5345
5262
|
// to update to chat messages triples
|
|
5346
5263
|
/* if (!validateMsg(msg))
|
|
@@ -5352,27 +5269,29 @@ function getMsgHash(message) {
|
|
|
5352
5269
|
var msgHash = (0, _sha.sha256)(utf8Encoder.encode(serializeMsg(message)));
|
|
5353
5270
|
return (0, _utils.bytesToHex)(msgHash);
|
|
5354
5271
|
}
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
function validateMsg(message) {
|
|
5359
|
-
|
|
5272
|
+
|
|
5273
|
+
// const isRecord = (obj: unknown): obj is Record<string, unknown> => obj instanceof Object
|
|
5274
|
+
|
|
5275
|
+
/* export function validateMsg<T> (message: T): message is T & UnsignedMsg {
|
|
5276
|
+
if (!isRecord(message)) return false
|
|
5360
5277
|
if (typeof message.kind !== 'number') return false
|
|
5361
5278
|
if (typeof message.content !== 'string') return false
|
|
5362
5279
|
if (typeof message.created_at !== 'number') return false
|
|
5363
5280
|
if (typeof message.pubkey !== 'string') return false
|
|
5364
5281
|
if (!message.pubkey.match(/^[a-f0-9]{64}$/)) return false
|
|
5365
|
-
|
|
5282
|
+
|
|
5283
|
+
if (!Array.isArray(message.tags)) return false
|
|
5366
5284
|
for (let i = 0; i < message.tags.length; i++) {
|
|
5367
5285
|
let tag = message.tags[i]
|
|
5368
5286
|
if (!Array.isArray(tag)) return false
|
|
5369
5287
|
for (let j = 0; j < tag.length; j++) {
|
|
5370
5288
|
if (typeof tag[j] === 'object') return false
|
|
5371
5289
|
}
|
|
5372
|
-
}
|
|
5290
|
+
}
|
|
5291
|
+
|
|
5292
|
+
return true
|
|
5293
|
+
} */
|
|
5373
5294
|
|
|
5374
|
-
return true;
|
|
5375
|
-
}
|
|
5376
5295
|
function verifySignature(sig, message, pubKey) {
|
|
5377
5296
|
return _secp256k.schnorr.verify(sig, getMsgHash(message), pubKey);
|
|
5378
5297
|
}
|
|
@@ -12583,379 +12502,134 @@ function isLight(x) {
|
|
|
12583
12502
|
|
|
12584
12503
|
/***/ }),
|
|
12585
12504
|
|
|
12586
|
-
/***/ "./lib/utils/
|
|
12587
|
-
|
|
12588
|
-
!*** ./lib/utils/
|
|
12589
|
-
|
|
12505
|
+
/***/ "./lib/utils/headerFooterHelpers.js":
|
|
12506
|
+
/*!******************************************!*\
|
|
12507
|
+
!*** ./lib/utils/headerFooterHelpers.js ***!
|
|
12508
|
+
\******************************************/
|
|
12590
12509
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
12591
12510
|
|
|
12592
12511
|
"use strict";
|
|
12593
12512
|
|
|
12594
12513
|
|
|
12595
12514
|
var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");
|
|
12596
|
-
var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
|
|
12597
12515
|
Object.defineProperty(exports, "__esModule", ({
|
|
12598
12516
|
value: true
|
|
12599
12517
|
}));
|
|
12600
|
-
exports.
|
|
12601
|
-
exports.
|
|
12602
|
-
exports.
|
|
12603
|
-
exports.
|
|
12518
|
+
exports.getName = getName;
|
|
12519
|
+
exports.getPod = getPod;
|
|
12520
|
+
exports.getPodOwner = getPodOwner;
|
|
12521
|
+
exports.throttle = throttle;
|
|
12604
12522
|
var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
|
|
12605
12523
|
var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
|
|
12606
|
-
var
|
|
12607
|
-
var
|
|
12608
|
-
|
|
12609
|
-
|
|
12610
|
-
|
|
12611
|
-
|
|
12612
|
-
|
|
12613
|
-
|
|
12614
|
-
|
|
12615
|
-
|
|
12524
|
+
var _rdflib = __webpack_require__(/*! rdflib */ "./node_modules/rdflib/esm/index.js");
|
|
12525
|
+
var _ = __webpack_require__(/*! .. */ "./lib/index.js");
|
|
12526
|
+
/*
|
|
12527
|
+
Copied from mashlib/src/global/metadata.ts
|
|
12528
|
+
*/
|
|
12529
|
+
|
|
12530
|
+
/**
|
|
12531
|
+
* @ignore exporting this only for the unit test
|
|
12532
|
+
*/
|
|
12533
|
+
function getPod() {
|
|
12534
|
+
// @@ TODO: This is given that mashlib runs on NSS - might need to change when we want it to run on other Pod servers
|
|
12535
|
+
return (0, _rdflib.sym)(document.location.origin).site();
|
|
12536
|
+
}
|
|
12537
|
+
/**
|
|
12538
|
+
*/
|
|
12539
|
+
function getPodOwner(_x, _x2) {
|
|
12540
|
+
return _getPodOwner.apply(this, arguments);
|
|
12541
|
+
}
|
|
12542
|
+
/**
|
|
12543
|
+
* @ignore exporting this only for the unit test
|
|
12544
|
+
*/
|
|
12545
|
+
function _getPodOwner() {
|
|
12546
|
+
_getPodOwner = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(pod, store) {
|
|
12547
|
+
var response, containerTurtle, podOwner, guess;
|
|
12616
12548
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
12617
12549
|
while (1) switch (_context.prev = _context.next) {
|
|
12618
12550
|
case 0:
|
|
12619
|
-
|
|
12620
|
-
|
|
12621
|
-
|
|
12622
|
-
case 3:
|
|
12623
|
-
storages = _solidLogic.store.each(webId, ns.space('storage'), null, webId.doc());
|
|
12624
|
-
if (storages !== null && storages !== void 0 && storages.length) {
|
|
12625
|
-
_context.next = 19;
|
|
12551
|
+
_context.prev = 0;
|
|
12552
|
+
if (store.any(pod, null, _.ns.ldp('Container'), pod)) {
|
|
12553
|
+
_context.next = 7;
|
|
12626
12554
|
break;
|
|
12627
12555
|
}
|
|
12628
|
-
|
|
12629
|
-
|
|
12630
|
-
|
|
12631
|
-
|
|
12632
|
-
|
|
12556
|
+
_context.next = 4;
|
|
12557
|
+
return store.fetcher.webOperation('GET', pod.uri, store.fetcher.initFetchOptions(pod.uri, {
|
|
12558
|
+
headers: {
|
|
12559
|
+
accept: 'text/turtle'
|
|
12560
|
+
}
|
|
12561
|
+
}));
|
|
12562
|
+
case 4:
|
|
12563
|
+
response = _context.sent;
|
|
12564
|
+
containerTurtle = response.responseText;
|
|
12565
|
+
(0, _rdflib.parse)(containerTurtle, store, pod.uri, 'text/turtle');
|
|
12566
|
+
case 7:
|
|
12567
|
+
_context.next = 13;
|
|
12568
|
+
break;
|
|
12569
|
+
case 9:
|
|
12570
|
+
_context.prev = 9;
|
|
12571
|
+
_context.t0 = _context["catch"](0);
|
|
12572
|
+
console.error('Error loading pod ' + pod + ': ' + _context.t0);
|
|
12573
|
+
return _context.abrupt("return", null);
|
|
12574
|
+
case 13:
|
|
12575
|
+
if (store.holds(pod, _.ns.rdf('type'), _.ns.space('Storage'), pod)) {
|
|
12576
|
+
_context.next = 16;
|
|
12633
12577
|
break;
|
|
12634
12578
|
}
|
|
12635
|
-
|
|
12636
|
-
|
|
12637
|
-
|
|
12638
|
-
|
|
12639
|
-
|
|
12640
|
-
|
|
12641
|
-
if (!((_res$headers$get = res.headers.get('link')) !== null && _res$headers$get !== void 0 && _res$headers$get.includes(ns.space('Storage').value))) {
|
|
12642
|
-
_context.next = 14;
|
|
12579
|
+
console.warn('Pod ' + pod + ' does not declare itself as a space:Storage');
|
|
12580
|
+
return _context.abrupt("return", null);
|
|
12581
|
+
case 16:
|
|
12582
|
+
podOwner = store.any(pod, _.ns.solid('owner'), null, pod) || store.any(null, _.ns.space('storage'), pod, pod);
|
|
12583
|
+
if (!podOwner) {
|
|
12584
|
+
_context.next = 31;
|
|
12643
12585
|
break;
|
|
12644
12586
|
}
|
|
12645
|
-
|
|
12646
|
-
case 14:
|
|
12647
|
-
if (!path) debug.warn("Current user storage not found for\n".concat(webId));
|
|
12648
|
-
_context.next = 6;
|
|
12649
|
-
break;
|
|
12650
|
-
case 17:
|
|
12587
|
+
_context.prev = 18;
|
|
12651
12588
|
_context.next = 21;
|
|
12652
|
-
|
|
12653
|
-
case 19:
|
|
12654
|
-
// give preference to storage in webId root
|
|
12655
|
-
podRoot = storages.find(function (storage) {
|
|
12656
|
-
return webIdURL.origin === new URL(storage.value).origin;
|
|
12657
|
-
});
|
|
12658
|
-
if (!podRoot) podRoot = storages[0];
|
|
12589
|
+
return store.fetcher.load(podOwner.doc());
|
|
12659
12590
|
case 21:
|
|
12660
|
-
|
|
12661
|
-
|
|
12591
|
+
_context.next = 27;
|
|
12592
|
+
break;
|
|
12593
|
+
case 23:
|
|
12594
|
+
_context.prev = 23;
|
|
12595
|
+
_context.t1 = _context["catch"](18);
|
|
12596
|
+
console.warn('Unable to load profile of pod owner ' + podOwner);
|
|
12597
|
+
return _context.abrupt("return", null);
|
|
12598
|
+
case 27:
|
|
12599
|
+
if (!store.holds(podOwner, _.ns.space('storage'), pod, podOwner.doc())) {
|
|
12600
|
+
console.warn("Pod owner ".concat(podOwner, " does NOT list pod ").concat(pod, " as their storage"));
|
|
12601
|
+
}
|
|
12602
|
+
return _context.abrupt("return", podOwner);
|
|
12603
|
+
case 31:
|
|
12604
|
+
// pod owner not declared in pod
|
|
12605
|
+
// @@ TODO: This is given the structure that NSS provides
|
|
12606
|
+
// This is a massive guess. For old pods which don't have owner link
|
|
12607
|
+
guess = (0, _rdflib.sym)("".concat(pod.uri, "profile/card#me"));
|
|
12608
|
+
_context.prev = 32;
|
|
12609
|
+
_context.next = 35;
|
|
12610
|
+
return store.fetcher.load(guess);
|
|
12611
|
+
case 35:
|
|
12612
|
+
_context.next = 41;
|
|
12613
|
+
break;
|
|
12614
|
+
case 37:
|
|
12615
|
+
_context.prev = 37;
|
|
12616
|
+
_context.t2 = _context["catch"](32);
|
|
12617
|
+
console.error('Ooops. Guessed wrong pod owner webid {$guess} : can\'t load it.');
|
|
12618
|
+
return _context.abrupt("return", null);
|
|
12619
|
+
case 41:
|
|
12620
|
+
if (!store.holds(guess, _.ns.space('storage'), pod, guess.doc())) {
|
|
12621
|
+
_context.next = 44;
|
|
12622
|
+
break;
|
|
12623
|
+
}
|
|
12624
|
+
console.warn('Using guessed pod owner webid but it links back.');
|
|
12625
|
+
return _context.abrupt("return", guess);
|
|
12626
|
+
case 44:
|
|
12627
|
+
return _context.abrupt("return", null);
|
|
12628
|
+
case 45:
|
|
12662
12629
|
case "end":
|
|
12663
12630
|
return _context.stop();
|
|
12664
12631
|
}
|
|
12665
|
-
}, _callee);
|
|
12666
|
-
}));
|
|
12667
|
-
return function getPodRoot(_x) {
|
|
12668
|
-
return _ref.apply(this, arguments);
|
|
12669
|
-
};
|
|
12670
|
-
}();
|
|
12671
|
-
var pubKeyUrl = /*#__PURE__*/function () {
|
|
12672
|
-
var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
|
|
12673
|
-
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
12674
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
12675
|
-
case 0:
|
|
12676
|
-
_context2.prev = 0;
|
|
12677
|
-
_context2.next = 3;
|
|
12678
|
-
return getPodRoot(webId);
|
|
12679
|
-
case 3:
|
|
12680
|
-
_context2.t0 = _context2.sent;
|
|
12681
|
-
return _context2.abrupt("return", _context2.t0 + 'profile/keys/publicKey.ttl');
|
|
12682
|
-
case 7:
|
|
12683
|
-
_context2.prev = 7;
|
|
12684
|
-
_context2.t1 = _context2["catch"](0);
|
|
12685
|
-
throw new Error(_context2.t1);
|
|
12686
|
-
case 10:
|
|
12687
|
-
case "end":
|
|
12688
|
-
return _context2.stop();
|
|
12689
|
-
}
|
|
12690
|
-
}, _callee2, null, [[0, 7]]);
|
|
12691
|
-
}));
|
|
12692
|
-
return function pubKeyUrl(_x2) {
|
|
12693
|
-
return _ref2.apply(this, arguments);
|
|
12694
|
-
};
|
|
12695
|
-
}();
|
|
12696
|
-
exports.pubKeyUrl = pubKeyUrl;
|
|
12697
|
-
function publicKeyExists(_x3) {
|
|
12698
|
-
return _publicKeyExists.apply(this, arguments);
|
|
12699
|
-
}
|
|
12700
|
-
function _publicKeyExists() {
|
|
12701
|
-
_publicKeyExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(webId) {
|
|
12702
|
-
var publicKeyUrl;
|
|
12703
|
-
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
12704
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
12705
|
-
case 0:
|
|
12706
|
-
_context4.next = 2;
|
|
12707
|
-
return pubKeyUrl(webId);
|
|
12708
|
-
case 2:
|
|
12709
|
-
publicKeyUrl = _context4.sent;
|
|
12710
|
-
_context4.next = 5;
|
|
12711
|
-
return keyExists(webId, publicKeyUrl, 'PublicKey');
|
|
12712
|
-
case 5:
|
|
12713
|
-
return _context4.abrupt("return", _context4.sent);
|
|
12714
|
-
case 6:
|
|
12715
|
-
case "end":
|
|
12716
|
-
return _context4.stop();
|
|
12717
|
-
}
|
|
12718
|
-
}, _callee4);
|
|
12719
|
-
}));
|
|
12720
|
-
return _publicKeyExists.apply(this, arguments);
|
|
12721
|
-
}
|
|
12722
|
-
var privKeyUrl = /*#__PURE__*/function () {
|
|
12723
|
-
var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId) {
|
|
12724
|
-
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
12725
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
12726
|
-
case 0:
|
|
12727
|
-
_context3.prev = 0;
|
|
12728
|
-
_context3.next = 3;
|
|
12729
|
-
return getPodRoot(webId);
|
|
12730
|
-
case 3:
|
|
12731
|
-
_context3.t0 = _context3.sent;
|
|
12732
|
-
return _context3.abrupt("return", _context3.t0 + 'profile/keys/privateKey.ttl');
|
|
12733
|
-
case 7:
|
|
12734
|
-
_context3.prev = 7;
|
|
12735
|
-
_context3.t1 = _context3["catch"](0);
|
|
12736
|
-
throw new Error(_context3.t1);
|
|
12737
|
-
case 10:
|
|
12738
|
-
case "end":
|
|
12739
|
-
return _context3.stop();
|
|
12740
|
-
}
|
|
12741
|
-
}, _callee3, null, [[0, 7]]);
|
|
12742
|
-
}));
|
|
12743
|
-
return function privKeyUrl(_x4) {
|
|
12744
|
-
return _ref3.apply(this, arguments);
|
|
12745
|
-
};
|
|
12746
|
-
}();
|
|
12747
|
-
exports.privKeyUrl = privKeyUrl;
|
|
12748
|
-
function privateKeyExists(_x5) {
|
|
12749
|
-
return _privateKeyExists.apply(this, arguments);
|
|
12750
|
-
}
|
|
12751
|
-
function _privateKeyExists() {
|
|
12752
|
-
_privateKeyExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(webId) {
|
|
12753
|
-
var privateKeyUrl;
|
|
12754
|
-
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
12755
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
12756
|
-
case 0:
|
|
12757
|
-
_context5.next = 2;
|
|
12758
|
-
return privKeyUrl(webId);
|
|
12759
|
-
case 2:
|
|
12760
|
-
privateKeyUrl = _context5.sent;
|
|
12761
|
-
_context5.next = 5;
|
|
12762
|
-
return keyExists(webId, privateKeyUrl, 'PrivateKey');
|
|
12763
|
-
case 5:
|
|
12764
|
-
return _context5.abrupt("return", _context5.sent);
|
|
12765
|
-
case 6:
|
|
12766
|
-
case "end":
|
|
12767
|
-
return _context5.stop();
|
|
12768
|
-
}
|
|
12769
|
-
}, _callee5);
|
|
12770
|
-
}));
|
|
12771
|
-
return _privateKeyExists.apply(this, arguments);
|
|
12772
|
-
}
|
|
12773
|
-
function keyExists(_x6, _x7, _x8) {
|
|
12774
|
-
return _keyExists.apply(this, arguments);
|
|
12775
|
-
}
|
|
12776
|
-
function _keyExists() {
|
|
12777
|
-
_keyExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(webId, keyUrl, keyType) {
|
|
12778
|
-
var key, _err$response, data, contentType, response;
|
|
12779
|
-
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
12780
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
12781
|
-
case 0:
|
|
12782
|
-
_context6.prev = 0;
|
|
12783
|
-
_context6.next = 3;
|
|
12784
|
-
return _solidLogic.store.fetcher.load(keyUrl);
|
|
12785
|
-
case 3:
|
|
12786
|
-
key = _solidLogic.store.any(webId, _solidLogic.store.sym(_signature.CERT + keyType));
|
|
12787
|
-
return _context6.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
|
|
12788
|
-
case 7:
|
|
12789
|
-
_context6.prev = 7;
|
|
12790
|
-
_context6.t0 = _context6["catch"](0);
|
|
12791
|
-
if (!((_context6.t0 === null || _context6.t0 === void 0 ? void 0 : (_err$response = _context6.t0.response) === null || _err$response === void 0 ? void 0 : _err$response.status) === 404)) {
|
|
12792
|
-
_context6.next = 24;
|
|
12793
|
-
break;
|
|
12794
|
-
}
|
|
12795
|
-
_context6.prev = 10;
|
|
12796
|
-
// create privateKey resource
|
|
12797
|
-
data = '';
|
|
12798
|
-
contentType = 'text/turtle';
|
|
12799
|
-
_context6.next = 15;
|
|
12800
|
-
return _solidLogic.store.fetcher.webOperation('PUT', keyUrl, {
|
|
12801
|
-
data: data,
|
|
12802
|
-
contentType: contentType
|
|
12803
|
-
});
|
|
12804
|
-
case 15:
|
|
12805
|
-
response = _context6.sent;
|
|
12806
|
-
_context6.next = 22;
|
|
12807
|
-
break;
|
|
12808
|
-
case 18:
|
|
12809
|
-
_context6.prev = 18;
|
|
12810
|
-
_context6.t1 = _context6["catch"](10);
|
|
12811
|
-
debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context6.t1);
|
|
12812
|
-
throw _context6.t1;
|
|
12813
|
-
case 22:
|
|
12814
|
-
delete _solidLogic.store.fetcher.requested[keyUrl]; // delete cached 404 error
|
|
12815
|
-
return _context6.abrupt("return", undefined);
|
|
12816
|
-
case 24:
|
|
12817
|
-
debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context6.t0);
|
|
12818
|
-
throw _context6.t0;
|
|
12819
|
-
case 26:
|
|
12820
|
-
case "end":
|
|
12821
|
-
return _context6.stop();
|
|
12822
|
-
}
|
|
12823
|
-
}, _callee6, null, [[0, 7], [10, 18]]);
|
|
12824
|
-
}));
|
|
12825
|
-
return _keyExists.apply(this, arguments);
|
|
12826
|
-
}
|
|
12827
|
-
//# sourceMappingURL=cryptoKeyHelpers.js.map
|
|
12828
|
-
|
|
12829
|
-
/***/ }),
|
|
12830
|
-
|
|
12831
|
-
/***/ "./lib/utils/headerFooterHelpers.js":
|
|
12832
|
-
/*!******************************************!*\
|
|
12833
|
-
!*** ./lib/utils/headerFooterHelpers.js ***!
|
|
12834
|
-
\******************************************/
|
|
12835
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
12836
|
-
|
|
12837
|
-
"use strict";
|
|
12838
|
-
|
|
12839
|
-
|
|
12840
|
-
var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");
|
|
12841
|
-
Object.defineProperty(exports, "__esModule", ({
|
|
12842
|
-
value: true
|
|
12843
|
-
}));
|
|
12844
|
-
exports.getName = getName;
|
|
12845
|
-
exports.getPod = getPod;
|
|
12846
|
-
exports.getPodOwner = getPodOwner;
|
|
12847
|
-
exports.throttle = throttle;
|
|
12848
|
-
var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
|
|
12849
|
-
var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
|
|
12850
|
-
var _rdflib = __webpack_require__(/*! rdflib */ "./node_modules/rdflib/esm/index.js");
|
|
12851
|
-
var _ = __webpack_require__(/*! .. */ "./lib/index.js");
|
|
12852
|
-
/*
|
|
12853
|
-
Copied from mashlib/src/global/metadata.ts
|
|
12854
|
-
*/
|
|
12855
|
-
|
|
12856
|
-
/**
|
|
12857
|
-
* @ignore exporting this only for the unit test
|
|
12858
|
-
*/
|
|
12859
|
-
function getPod() {
|
|
12860
|
-
// @@ TODO: This is given that mashlib runs on NSS - might need to change when we want it to run on other Pod servers
|
|
12861
|
-
return (0, _rdflib.sym)(document.location.origin).site();
|
|
12862
|
-
}
|
|
12863
|
-
/**
|
|
12864
|
-
*/
|
|
12865
|
-
function getPodOwner(_x, _x2) {
|
|
12866
|
-
return _getPodOwner.apply(this, arguments);
|
|
12867
|
-
}
|
|
12868
|
-
/**
|
|
12869
|
-
* @ignore exporting this only for the unit test
|
|
12870
|
-
*/
|
|
12871
|
-
function _getPodOwner() {
|
|
12872
|
-
_getPodOwner = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(pod, store) {
|
|
12873
|
-
var response, containerTurtle, podOwner, guess;
|
|
12874
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
12875
|
-
while (1) switch (_context.prev = _context.next) {
|
|
12876
|
-
case 0:
|
|
12877
|
-
_context.prev = 0;
|
|
12878
|
-
if (store.any(pod, null, _.ns.ldp('Container'), pod)) {
|
|
12879
|
-
_context.next = 7;
|
|
12880
|
-
break;
|
|
12881
|
-
}
|
|
12882
|
-
_context.next = 4;
|
|
12883
|
-
return store.fetcher.webOperation('GET', pod.uri, store.fetcher.initFetchOptions(pod.uri, {
|
|
12884
|
-
headers: {
|
|
12885
|
-
accept: 'text/turtle'
|
|
12886
|
-
}
|
|
12887
|
-
}));
|
|
12888
|
-
case 4:
|
|
12889
|
-
response = _context.sent;
|
|
12890
|
-
containerTurtle = response.responseText;
|
|
12891
|
-
(0, _rdflib.parse)(containerTurtle, store, pod.uri, 'text/turtle');
|
|
12892
|
-
case 7:
|
|
12893
|
-
_context.next = 13;
|
|
12894
|
-
break;
|
|
12895
|
-
case 9:
|
|
12896
|
-
_context.prev = 9;
|
|
12897
|
-
_context.t0 = _context["catch"](0);
|
|
12898
|
-
console.error('Error loading pod ' + pod + ': ' + _context.t0);
|
|
12899
|
-
return _context.abrupt("return", null);
|
|
12900
|
-
case 13:
|
|
12901
|
-
if (store.holds(pod, _.ns.rdf('type'), _.ns.space('Storage'), pod)) {
|
|
12902
|
-
_context.next = 16;
|
|
12903
|
-
break;
|
|
12904
|
-
}
|
|
12905
|
-
console.warn('Pod ' + pod + ' does not declare itself as a space:Storage');
|
|
12906
|
-
return _context.abrupt("return", null);
|
|
12907
|
-
case 16:
|
|
12908
|
-
podOwner = store.any(pod, _.ns.solid('owner'), null, pod) || store.any(null, _.ns.space('storage'), pod, pod);
|
|
12909
|
-
if (!podOwner) {
|
|
12910
|
-
_context.next = 31;
|
|
12911
|
-
break;
|
|
12912
|
-
}
|
|
12913
|
-
_context.prev = 18;
|
|
12914
|
-
_context.next = 21;
|
|
12915
|
-
return store.fetcher.load(podOwner.doc());
|
|
12916
|
-
case 21:
|
|
12917
|
-
_context.next = 27;
|
|
12918
|
-
break;
|
|
12919
|
-
case 23:
|
|
12920
|
-
_context.prev = 23;
|
|
12921
|
-
_context.t1 = _context["catch"](18);
|
|
12922
|
-
console.warn('Unable to load profile of pod owner ' + podOwner);
|
|
12923
|
-
return _context.abrupt("return", null);
|
|
12924
|
-
case 27:
|
|
12925
|
-
if (!store.holds(podOwner, _.ns.space('storage'), pod, podOwner.doc())) {
|
|
12926
|
-
console.warn("Pod owner ".concat(podOwner, " does NOT list pod ").concat(pod, " as their storage"));
|
|
12927
|
-
}
|
|
12928
|
-
return _context.abrupt("return", podOwner);
|
|
12929
|
-
case 31:
|
|
12930
|
-
// pod owner not declared in pod
|
|
12931
|
-
// @@ TODO: This is given the structure that NSS provides
|
|
12932
|
-
// This is a massive guess. For old pods which don't have owner link
|
|
12933
|
-
guess = (0, _rdflib.sym)("".concat(pod.uri, "profile/card#me"));
|
|
12934
|
-
_context.prev = 32;
|
|
12935
|
-
_context.next = 35;
|
|
12936
|
-
return store.fetcher.load(guess);
|
|
12937
|
-
case 35:
|
|
12938
|
-
_context.next = 41;
|
|
12939
|
-
break;
|
|
12940
|
-
case 37:
|
|
12941
|
-
_context.prev = 37;
|
|
12942
|
-
_context.t2 = _context["catch"](32);
|
|
12943
|
-
console.error('Ooops. Guessed wrong pod owner webid {$guess} : can\'t load it.');
|
|
12944
|
-
return _context.abrupt("return", null);
|
|
12945
|
-
case 41:
|
|
12946
|
-
if (!store.holds(guess, _.ns.space('storage'), pod, guess.doc())) {
|
|
12947
|
-
_context.next = 44;
|
|
12948
|
-
break;
|
|
12949
|
-
}
|
|
12950
|
-
console.warn('Using guessed pod owner webid but it links back.');
|
|
12951
|
-
return _context.abrupt("return", guess);
|
|
12952
|
-
case 44:
|
|
12953
|
-
return _context.abrupt("return", null);
|
|
12954
|
-
case 45:
|
|
12955
|
-
case "end":
|
|
12956
|
-
return _context.stop();
|
|
12957
|
-
}
|
|
12958
|
-
}, _callee, null, [[0, 9], [18, 23], [32, 37]]);
|
|
12632
|
+
}, _callee, null, [[0, 9], [18, 23], [32, 37]]);
|
|
12959
12633
|
}));
|
|
12960
12634
|
return _getPodOwner.apply(this, arguments);
|
|
12961
12635
|
}
|
|
@@ -13546,6 +13220,353 @@ function predParentOf(node) {
|
|
|
13546
13220
|
|
|
13547
13221
|
/***/ }),
|
|
13548
13222
|
|
|
13223
|
+
/***/ "./lib/utils/keyHelpers/accessData.js":
|
|
13224
|
+
/*!********************************************!*\
|
|
13225
|
+
!*** ./lib/utils/keyHelpers/accessData.js ***!
|
|
13226
|
+
\********************************************/
|
|
13227
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
13228
|
+
|
|
13229
|
+
"use strict";
|
|
13230
|
+
|
|
13231
|
+
|
|
13232
|
+
var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");
|
|
13233
|
+
var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
|
|
13234
|
+
Object.defineProperty(exports, "__esModule", ({
|
|
13235
|
+
value: true
|
|
13236
|
+
}));
|
|
13237
|
+
exports.getExistingPrivateKey = getExistingPrivateKey;
|
|
13238
|
+
exports.getExistingPublicKey = getExistingPublicKey;
|
|
13239
|
+
exports.getKeyIfExists = getKeyIfExists;
|
|
13240
|
+
exports.pubKeyUrl = exports.privKeyUrl = exports.getPodRoot = void 0;
|
|
13241
|
+
var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
|
|
13242
|
+
var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
|
|
13243
|
+
var debug = _interopRequireWildcard(__webpack_require__(/*! ../../debug */ "./lib/debug.js"));
|
|
13244
|
+
var _signature = __webpack_require__(/*! ../../chat/signature */ "./lib/chat/signature.js");
|
|
13245
|
+
var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
|
|
13246
|
+
var ns = _interopRequireWildcard(__webpack_require__(/*! ../../ns */ "./lib/ns.js"));
|
|
13247
|
+
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); }
|
|
13248
|
+
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
|
+
var getPodRoot = /*#__PURE__*/function () {
|
|
13250
|
+
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
|
|
13251
|
+
var _podRoot;
|
|
13252
|
+
var webIdURL, storages, podRoot, path, _res$headers$get, res;
|
|
13253
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
13254
|
+
while (1) switch (_context.prev = _context.next) {
|
|
13255
|
+
case 0:
|
|
13256
|
+
webIdURL = new URL(webId.uri); // find storages in webId document
|
|
13257
|
+
_context.next = 3;
|
|
13258
|
+
return _solidLogic.store.fetcher.load(webId.uri);
|
|
13259
|
+
case 3:
|
|
13260
|
+
storages = _solidLogic.store.each(webId, ns.space('storage'), null, webId.doc());
|
|
13261
|
+
if (storages !== null && storages !== void 0 && storages.length) {
|
|
13262
|
+
_context.next = 19;
|
|
13263
|
+
break;
|
|
13264
|
+
}
|
|
13265
|
+
// find storage recursively in webId URL
|
|
13266
|
+
path = webIdURL.pathname;
|
|
13267
|
+
case 6:
|
|
13268
|
+
if (!path.length) {
|
|
13269
|
+
_context.next = 17;
|
|
13270
|
+
break;
|
|
13271
|
+
}
|
|
13272
|
+
path = path.substring(0, path.lastIndexOf('/'));
|
|
13273
|
+
podRoot = _solidLogic.store.sym(webIdURL.origin + path + '/');
|
|
13274
|
+
_context.next = 11;
|
|
13275
|
+
return _solidLogic.store.fetcher.webOperation('HEAD', podRoot.uri);
|
|
13276
|
+
case 11:
|
|
13277
|
+
res = _context.sent;
|
|
13278
|
+
if (!((_res$headers$get = res.headers.get('link')) !== null && _res$headers$get !== void 0 && _res$headers$get.includes(ns.space('Storage').value))) {
|
|
13279
|
+
_context.next = 14;
|
|
13280
|
+
break;
|
|
13281
|
+
}
|
|
13282
|
+
return _context.abrupt("break", 17);
|
|
13283
|
+
case 14:
|
|
13284
|
+
if (!path) debug.warn("Current user storage not found for\n".concat(webId));
|
|
13285
|
+
_context.next = 6;
|
|
13286
|
+
break;
|
|
13287
|
+
case 17:
|
|
13288
|
+
_context.next = 21;
|
|
13289
|
+
break;
|
|
13290
|
+
case 19:
|
|
13291
|
+
// give preference to storage in webId root
|
|
13292
|
+
podRoot = storages.find(function (storage) {
|
|
13293
|
+
return webIdURL.origin === new URL(storage.value).origin;
|
|
13294
|
+
});
|
|
13295
|
+
if (!podRoot) podRoot = storages[0];
|
|
13296
|
+
case 21:
|
|
13297
|
+
return _context.abrupt("return", (_podRoot = podRoot) === null || _podRoot === void 0 ? void 0 : _podRoot.value);
|
|
13298
|
+
case 22:
|
|
13299
|
+
case "end":
|
|
13300
|
+
return _context.stop();
|
|
13301
|
+
}
|
|
13302
|
+
}, _callee);
|
|
13303
|
+
}));
|
|
13304
|
+
return function getPodRoot(_x) {
|
|
13305
|
+
return _ref.apply(this, arguments);
|
|
13306
|
+
};
|
|
13307
|
+
}();
|
|
13308
|
+
exports.getPodRoot = getPodRoot;
|
|
13309
|
+
var pubKeyUrl = /*#__PURE__*/function () {
|
|
13310
|
+
var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
|
|
13311
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
13312
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
13313
|
+
case 0:
|
|
13314
|
+
_context2.prev = 0;
|
|
13315
|
+
_context2.next = 3;
|
|
13316
|
+
return getPodRoot(webId);
|
|
13317
|
+
case 3:
|
|
13318
|
+
_context2.t0 = _context2.sent;
|
|
13319
|
+
return _context2.abrupt("return", _context2.t0 + 'profile/keys/publicKey.ttl');
|
|
13320
|
+
case 7:
|
|
13321
|
+
_context2.prev = 7;
|
|
13322
|
+
_context2.t1 = _context2["catch"](0);
|
|
13323
|
+
throw new Error(_context2.t1);
|
|
13324
|
+
case 10:
|
|
13325
|
+
case "end":
|
|
13326
|
+
return _context2.stop();
|
|
13327
|
+
}
|
|
13328
|
+
}, _callee2, null, [[0, 7]]);
|
|
13329
|
+
}));
|
|
13330
|
+
return function pubKeyUrl(_x2) {
|
|
13331
|
+
return _ref2.apply(this, arguments);
|
|
13332
|
+
};
|
|
13333
|
+
}();
|
|
13334
|
+
exports.pubKeyUrl = pubKeyUrl;
|
|
13335
|
+
function getExistingPublicKey(_x3, _x4) {
|
|
13336
|
+
return _getExistingPublicKey.apply(this, arguments);
|
|
13337
|
+
}
|
|
13338
|
+
function _getExistingPublicKey() {
|
|
13339
|
+
_getExistingPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(webId, publicKeyUrl) {
|
|
13340
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
13341
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
13342
|
+
case 0:
|
|
13343
|
+
_context4.next = 2;
|
|
13344
|
+
return getKeyIfExists(webId, publicKeyUrl, 'PublicKey');
|
|
13345
|
+
case 2:
|
|
13346
|
+
return _context4.abrupt("return", _context4.sent);
|
|
13347
|
+
case 3:
|
|
13348
|
+
case "end":
|
|
13349
|
+
return _context4.stop();
|
|
13350
|
+
}
|
|
13351
|
+
}, _callee4);
|
|
13352
|
+
}));
|
|
13353
|
+
return _getExistingPublicKey.apply(this, arguments);
|
|
13354
|
+
}
|
|
13355
|
+
var privKeyUrl = /*#__PURE__*/function () {
|
|
13356
|
+
var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId) {
|
|
13357
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
13358
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
13359
|
+
case 0:
|
|
13360
|
+
_context3.prev = 0;
|
|
13361
|
+
_context3.next = 3;
|
|
13362
|
+
return getPodRoot(webId);
|
|
13363
|
+
case 3:
|
|
13364
|
+
_context3.t0 = _context3.sent;
|
|
13365
|
+
return _context3.abrupt("return", _context3.t0 + 'profile/keys/privateKey.ttl');
|
|
13366
|
+
case 7:
|
|
13367
|
+
_context3.prev = 7;
|
|
13368
|
+
_context3.t1 = _context3["catch"](0);
|
|
13369
|
+
throw new Error(_context3.t1);
|
|
13370
|
+
case 10:
|
|
13371
|
+
case "end":
|
|
13372
|
+
return _context3.stop();
|
|
13373
|
+
}
|
|
13374
|
+
}, _callee3, null, [[0, 7]]);
|
|
13375
|
+
}));
|
|
13376
|
+
return function privKeyUrl(_x5) {
|
|
13377
|
+
return _ref3.apply(this, arguments);
|
|
13378
|
+
};
|
|
13379
|
+
}();
|
|
13380
|
+
exports.privKeyUrl = privKeyUrl;
|
|
13381
|
+
function getExistingPrivateKey(_x6, _x7) {
|
|
13382
|
+
return _getExistingPrivateKey.apply(this, arguments);
|
|
13383
|
+
}
|
|
13384
|
+
function _getExistingPrivateKey() {
|
|
13385
|
+
_getExistingPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(webId, privateKeyUrl) {
|
|
13386
|
+
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
13387
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
13388
|
+
case 0:
|
|
13389
|
+
_context5.next = 2;
|
|
13390
|
+
return getKeyIfExists(webId, privateKeyUrl, 'PrivateKey');
|
|
13391
|
+
case 2:
|
|
13392
|
+
return _context5.abrupt("return", _context5.sent);
|
|
13393
|
+
case 3:
|
|
13394
|
+
case "end":
|
|
13395
|
+
return _context5.stop();
|
|
13396
|
+
}
|
|
13397
|
+
}, _callee5);
|
|
13398
|
+
}));
|
|
13399
|
+
return _getExistingPrivateKey.apply(this, arguments);
|
|
13400
|
+
}
|
|
13401
|
+
function getKeyIfExists(_x8, _x9, _x10) {
|
|
13402
|
+
return _getKeyIfExists.apply(this, arguments);
|
|
13403
|
+
}
|
|
13404
|
+
function _getKeyIfExists() {
|
|
13405
|
+
_getKeyIfExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(webId, keyUrl, keyType) {
|
|
13406
|
+
var key, _err$response, data, contentType, response;
|
|
13407
|
+
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
13408
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
13409
|
+
case 0:
|
|
13410
|
+
_context6.prev = 0;
|
|
13411
|
+
_context6.next = 3;
|
|
13412
|
+
return _solidLogic.store.fetcher.load(keyUrl);
|
|
13413
|
+
case 3:
|
|
13414
|
+
key = _solidLogic.store.any(webId, _solidLogic.store.sym(_signature.CERT + keyType));
|
|
13415
|
+
return _context6.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
|
|
13416
|
+
case 7:
|
|
13417
|
+
_context6.prev = 7;
|
|
13418
|
+
_context6.t0 = _context6["catch"](0);
|
|
13419
|
+
if (!((_context6.t0 === null || _context6.t0 === void 0 ? void 0 : (_err$response = _context6.t0.response) === null || _err$response === void 0 ? void 0 : _err$response.status) === 404)) {
|
|
13420
|
+
_context6.next = 24;
|
|
13421
|
+
break;
|
|
13422
|
+
}
|
|
13423
|
+
_context6.prev = 10;
|
|
13424
|
+
// create resource
|
|
13425
|
+
data = '';
|
|
13426
|
+
contentType = 'text/turtle';
|
|
13427
|
+
_context6.next = 15;
|
|
13428
|
+
return _solidLogic.store.fetcher.webOperation('PUT', keyUrl, {
|
|
13429
|
+
data: data,
|
|
13430
|
+
contentType: contentType
|
|
13431
|
+
});
|
|
13432
|
+
case 15:
|
|
13433
|
+
response = _context6.sent;
|
|
13434
|
+
_context6.next = 22;
|
|
13435
|
+
break;
|
|
13436
|
+
case 18:
|
|
13437
|
+
_context6.prev = 18;
|
|
13438
|
+
_context6.t1 = _context6["catch"](10);
|
|
13439
|
+
debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context6.t1);
|
|
13440
|
+
throw _context6.t1;
|
|
13441
|
+
case 22:
|
|
13442
|
+
delete _solidLogic.store.fetcher.requested[keyUrl]; // delete cached 404 error
|
|
13443
|
+
return _context6.abrupt("return", undefined);
|
|
13444
|
+
case 24:
|
|
13445
|
+
debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context6.t0);
|
|
13446
|
+
throw _context6.t0;
|
|
13447
|
+
case 26:
|
|
13448
|
+
case "end":
|
|
13449
|
+
return _context6.stop();
|
|
13450
|
+
}
|
|
13451
|
+
}, _callee6, null, [[0, 7], [10, 18]]);
|
|
13452
|
+
}));
|
|
13453
|
+
return _getKeyIfExists.apply(this, arguments);
|
|
13454
|
+
}
|
|
13455
|
+
//# sourceMappingURL=accessData.js.map
|
|
13456
|
+
|
|
13457
|
+
/***/ }),
|
|
13458
|
+
|
|
13459
|
+
/***/ "./lib/utils/keyHelpers/acl.js":
|
|
13460
|
+
/*!*************************************!*\
|
|
13461
|
+
!*** ./lib/utils/keyHelpers/acl.js ***!
|
|
13462
|
+
\*************************************/
|
|
13463
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
13464
|
+
|
|
13465
|
+
"use strict";
|
|
13466
|
+
|
|
13467
|
+
|
|
13468
|
+
var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");
|
|
13469
|
+
var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
|
|
13470
|
+
Object.defineProperty(exports, "__esModule", ({
|
|
13471
|
+
value: true
|
|
13472
|
+
}));
|
|
13473
|
+
exports.keyContainerAclBody = exports.keyAclBody = void 0;
|
|
13474
|
+
exports.setAcl = setAcl;
|
|
13475
|
+
var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
|
|
13476
|
+
var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
|
|
13477
|
+
var debug = _interopRequireWildcard(__webpack_require__(/*! ../../debug */ "./lib/debug.js"));
|
|
13478
|
+
var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
|
|
13479
|
+
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); }
|
|
13480
|
+
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; }
|
|
13481
|
+
/**
|
|
13482
|
+
* set ACL
|
|
13483
|
+
* @param keyDoc
|
|
13484
|
+
* @param aclBody
|
|
13485
|
+
*/
|
|
13486
|
+
function setAcl(_x, _x2) {
|
|
13487
|
+
return _setAcl.apply(this, arguments);
|
|
13488
|
+
}
|
|
13489
|
+
/**
|
|
13490
|
+
* key container ACL
|
|
13491
|
+
* @param me
|
|
13492
|
+
* @returns aclBody
|
|
13493
|
+
*/
|
|
13494
|
+
function _setAcl() {
|
|
13495
|
+
_setAcl = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(keyDoc, aclBody) {
|
|
13496
|
+
var keyAclDoc, response, aclResponse;
|
|
13497
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
13498
|
+
while (1) switch (_context.prev = _context.next) {
|
|
13499
|
+
case 0:
|
|
13500
|
+
_context.next = 2;
|
|
13501
|
+
return _solidLogic.store.fetcher.load(keyDoc);
|
|
13502
|
+
case 2:
|
|
13503
|
+
// FIXME: check the Why value on this quad:
|
|
13504
|
+
debug.log(_solidLogic.store.statementsMatching(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl')));
|
|
13505
|
+
keyAclDoc = _solidLogic.store.any(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl'));
|
|
13506
|
+
if (keyAclDoc) {
|
|
13507
|
+
_context.next = 6;
|
|
13508
|
+
break;
|
|
13509
|
+
}
|
|
13510
|
+
throw new Error('Key ACL doc not found!');
|
|
13511
|
+
case 6:
|
|
13512
|
+
_context.prev = 6;
|
|
13513
|
+
_context.next = 9;
|
|
13514
|
+
return _solidLogic.store.fetcher.webOperation('DELETE', keyAclDoc.value);
|
|
13515
|
+
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;
|
|
13520
|
+
break;
|
|
13521
|
+
case 13:
|
|
13522
|
+
_context.prev = 13;
|
|
13523
|
+
_context.t0 = _context["catch"](6);
|
|
13524
|
+
if (!(_context.t0.response.status !== 404)) {
|
|
13525
|
+
_context.next = 17;
|
|
13526
|
+
break;
|
|
13527
|
+
}
|
|
13528
|
+
throw new Error(_context.t0);
|
|
13529
|
+
case 17:
|
|
13530
|
+
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:
|
|
13540
|
+
case "end":
|
|
13541
|
+
return _context.stop();
|
|
13542
|
+
}
|
|
13543
|
+
}, _callee, null, [[6, 13]]);
|
|
13544
|
+
}));
|
|
13545
|
+
return _setAcl.apply(this, arguments);
|
|
13546
|
+
}
|
|
13547
|
+
var keyContainerAclBody = function keyContainerAclBody(me) {
|
|
13548
|
+
var aclBody = "\n@prefix : <#>.\n@prefix acl: <http://www.w3.org/ns/auth/acl#>.\n@prefix foaf: <http://xmlns.com/foaf/0.1/>.\n@prefix key: <./>.\n\n:ReadWrite\n a acl:Authorization;\n acl:accessTo key:;\n acl:default key:;\n acl:agent <".concat(me, ">;\n acl:mode acl:Read, acl:Write.\n");
|
|
13549
|
+
return aclBody;
|
|
13550
|
+
};
|
|
13551
|
+
|
|
13552
|
+
/**
|
|
13553
|
+
* Read only ACL
|
|
13554
|
+
* @param keyDoc
|
|
13555
|
+
* @param me
|
|
13556
|
+
* @returns aclBody
|
|
13557
|
+
*/
|
|
13558
|
+
exports.keyContainerAclBody = keyContainerAclBody;
|
|
13559
|
+
var keyAclBody = function keyAclBody(keyDoc, me) {
|
|
13560
|
+
var keyAgent = 'acl:agentClass foaf:Agent'; // publicKey
|
|
13561
|
+
if (me !== null && me !== void 0 && me.length) keyAgent = "acl:agent <".concat(me, ">"); // privateKey
|
|
13562
|
+
var 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");
|
|
13563
|
+
return aclBody;
|
|
13564
|
+
};
|
|
13565
|
+
exports.keyAclBody = keyAclBody;
|
|
13566
|
+
//# sourceMappingURL=acl.js.map
|
|
13567
|
+
|
|
13568
|
+
/***/ }),
|
|
13569
|
+
|
|
13549
13570
|
/***/ "./lib/utils/label.js":
|
|
13550
13571
|
/*!****************************!*\
|
|
13551
13572
|
!*** ./lib/utils/label.js ***!
|
|
@@ -13674,8 +13695,8 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
13674
13695
|
}));
|
|
13675
13696
|
exports.versionInfo = void 0;
|
|
13676
13697
|
var versionInfo = {
|
|
13677
|
-
buildTime: '2023-05-
|
|
13678
|
-
commit: '
|
|
13698
|
+
buildTime: '2023-05-10T18:37:24Z',
|
|
13699
|
+
commit: '18070a02fa8159a2b83d9503ee400f8e046bf1f6',
|
|
13679
13700
|
npmInfo: {
|
|
13680
13701
|
'solid-ui': '2.4.27',
|
|
13681
13702
|
npm: '8.19.4',
|