solid-ui 2.4.27-f3d1fd8f → 2.4.27-f7a2eabe
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/solid-ui.js +554 -268
- 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 +2 -1
- package/lib/chat/chatLogic.js.map +1 -1
- package/lib/chat/keys.d.ts +2 -1
- package/lib/chat/keys.d.ts.map +1 -1
- package/lib/chat/keys.js +231 -116
- package/lib/chat/keys.js.map +1 -1
- package/lib/chat/message.js +21 -28
- package/lib/chat/message.js.map +1 -1
- package/lib/utils/cryptoKeyHelpers.d.ts +6 -0
- package/lib/utils/cryptoKeyHelpers.d.ts.map +1 -0
- package/lib/utils/cryptoKeyHelpers.js +235 -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
|
@@ -2710,9 +2710,10 @@ var ChatChannel = /*#__PURE__*/function () {
|
|
|
2710
2710
|
msg.maker = me.uri;
|
|
2711
2711
|
// privateKey the cached private key of me, cached in store
|
|
2712
2712
|
_context2.next = 32;
|
|
2713
|
-
return (0, _keys.getPrivateKey)(me
|
|
2713
|
+
return (0, _keys.getPrivateKey)(me);
|
|
2714
2714
|
case 32:
|
|
2715
2715
|
privateKey = _context2.sent;
|
|
2716
|
+
// me.uri)
|
|
2716
2717
|
// const privateKey0 = 'a11bc5d2eee6cdb3b37f5473a712cad905ccfb13fb2ccdbf1be0a1ac4fdc7d2a'
|
|
2717
2718
|
// const pubKey0 = '023a9da707bee1302f66083c9d95673ff969b41607a66f52686fa774d64ceb87'
|
|
2718
2719
|
pubKey = (0, _keys.getPublicKey)(me.uri);
|
|
@@ -4043,6 +4044,7 @@ var _utils = __webpack_require__(/*! @noble/hashes/utils */ "./node_modules/@nob
|
|
|
4043
4044
|
var _signature = __webpack_require__(/*! ./signature */ "./lib/chat/signature.js");
|
|
4044
4045
|
var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
|
|
4045
4046
|
var $rdf = _interopRequireWildcard(__webpack_require__(/*! rdflib */ "./node_modules/rdflib/esm/index.js"));
|
|
4047
|
+
var _cryptoKeyHelpers = __webpack_require__(/*! ../utils/cryptoKeyHelpers */ "./lib/utils/cryptoKeyHelpers.js");
|
|
4046
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); }
|
|
4047
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; }
|
|
4048
4050
|
function generatePrivateKey() {
|
|
@@ -4051,160 +4053,274 @@ function generatePrivateKey() {
|
|
|
4051
4053
|
function generatePublicKey(privateKey) {
|
|
4052
4054
|
return (0, _utils.bytesToHex)(_secp256k.schnorr.getPublicKey(privateKey));
|
|
4053
4055
|
}
|
|
4054
|
-
function getPublicKey(
|
|
4055
|
-
|
|
4056
|
-
return publicKey;
|
|
4056
|
+
function getPublicKey(_x) {
|
|
4057
|
+
return _getPublicKey.apply(this, arguments);
|
|
4057
4058
|
}
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
return publicKeyUrl;
|
|
4062
|
-
};
|
|
4063
|
-
function publicKeyExists(_x) {
|
|
4064
|
-
return _publicKeyExists.apply(this, arguments);
|
|
4065
|
-
}
|
|
4066
|
-
function _publicKeyExists() {
|
|
4067
|
-
_publicKeyExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
|
|
4068
|
-
var publicKey;
|
|
4059
|
+
function _getPublicKey() {
|
|
4060
|
+
_getPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
|
|
4061
|
+
var publicKeyDoc, key;
|
|
4069
4062
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
4070
4063
|
while (1) switch (_context.prev = _context.next) {
|
|
4071
4064
|
case 0:
|
|
4072
4065
|
_context.next = 2;
|
|
4073
|
-
return _solidLogic.store.fetcher.load(
|
|
4066
|
+
return _solidLogic.store.fetcher.load(webId);
|
|
4074
4067
|
case 2:
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
return _context.abrupt("return", publicKey === null || publicKey === void 0 ? void 0 : publicKey.value);
|
|
4068
|
+
_context.next = 4;
|
|
4069
|
+
return (0, _cryptoKeyHelpers.pubKeyUrl)(webId);
|
|
4078
4070
|
case 4:
|
|
4071
|
+
publicKeyDoc = _context.sent;
|
|
4072
|
+
_context.prev = 5;
|
|
4073
|
+
_context.next = 8;
|
|
4074
|
+
return _solidLogic.store.fetcher.load(publicKeyDoc);
|
|
4075
|
+
case 8:
|
|
4076
|
+
// url.href)
|
|
4077
|
+
key = _solidLogic.store.any(webId, _solidLogic.store.sym(_signature.CERT + 'PublicKey'));
|
|
4078
|
+
return _context.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
|
|
4079
|
+
case 12:
|
|
4080
|
+
_context.prev = 12;
|
|
4081
|
+
_context.t0 = _context["catch"](5);
|
|
4082
|
+
return _context.abrupt("return", undefined);
|
|
4083
|
+
case 15:
|
|
4079
4084
|
case "end":
|
|
4080
4085
|
return _context.stop();
|
|
4081
4086
|
}
|
|
4082
|
-
}, _callee);
|
|
4087
|
+
}, _callee, null, [[5, 12]]);
|
|
4083
4088
|
}));
|
|
4084
|
-
return
|
|
4089
|
+
return _getPublicKey.apply(this, arguments);
|
|
4085
4090
|
}
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
var privateKeyUrl = url.origin + '/profile/keys/privateKey.ttl';
|
|
4089
|
-
return privateKeyUrl;
|
|
4090
|
-
};
|
|
4091
|
-
function privateKeyExists(_x2) {
|
|
4092
|
-
return _privateKeyExists.apply(this, arguments);
|
|
4091
|
+
function getPrivateKey(_x2) {
|
|
4092
|
+
return _getPrivateKey.apply(this, arguments);
|
|
4093
4093
|
}
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4094
|
+
/**
|
|
4095
|
+
* key container ACL
|
|
4096
|
+
* @param me
|
|
4097
|
+
* @returns aclBody
|
|
4098
|
+
*/
|
|
4099
|
+
function _getPrivateKey() {
|
|
4100
|
+
_getPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
|
|
4101
|
+
var publicKeyDoc, privateKeyDoc, publicKey, privateKey, validPublicKey, del, add, newPublicKey, keyContainer;
|
|
4097
4102
|
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
4098
4103
|
while (1) switch (_context2.prev = _context2.next) {
|
|
4099
4104
|
case 0:
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
/* debug.warn('Alain privateKeyExists')
|
|
4104
|
-
debug.warn(webId)
|
|
4105
|
-
debug.warn(privateKeyUrl) */
|
|
4106
|
-
_context2.prev = 1;
|
|
4105
|
+
_context2.next = 2;
|
|
4106
|
+
return _solidLogic.store.fetcher.load(webId);
|
|
4107
|
+
case 2:
|
|
4107
4108
|
_context2.next = 4;
|
|
4108
|
-
return
|
|
4109
|
+
return (0, _cryptoKeyHelpers.pubKeyUrl)(webId);
|
|
4109
4110
|
case 4:
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4111
|
+
publicKeyDoc = _context2.sent;
|
|
4112
|
+
_context2.next = 7;
|
|
4113
|
+
return (0, _cryptoKeyHelpers.privKeyUrl)(webId);
|
|
4114
|
+
case 7:
|
|
4115
|
+
privateKeyDoc = _context2.sent;
|
|
4116
|
+
_context2.next = 10;
|
|
4117
|
+
return (0, _cryptoKeyHelpers.publicKeyExists)(webId);
|
|
4118
|
+
case 10:
|
|
4119
|
+
publicKey = _context2.sent;
|
|
4120
|
+
_context2.next = 13;
|
|
4121
|
+
return (0, _cryptoKeyHelpers.privateKeyExists)(webId);
|
|
4122
|
+
case 13:
|
|
4123
|
+
privateKey = _context2.sent;
|
|
4124
|
+
// is publicKey valid ?
|
|
4125
|
+
validPublicKey = true;
|
|
4126
|
+
if (privateKey && publicKey !== generatePublicKey(privateKey)) {
|
|
4127
|
+
if (confirm('This is strange the publicKey is not valid for\n' + webId + '\'shall we repair keeping the private key ?')) validPublicKey = false;
|
|
4128
|
+
}
|
|
4129
|
+
|
|
4130
|
+
// create key pair or repair publicKey
|
|
4131
|
+
if (!(!privateKey || !publicKey || !validPublicKey)) {
|
|
4132
|
+
_context2.next = 34;
|
|
4117
4133
|
break;
|
|
4118
4134
|
}
|
|
4119
|
-
|
|
4120
|
-
//
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4135
|
+
del = [];
|
|
4136
|
+
add = []; // if (privateKey) del.push($rdf.st(webId, store.sym(CERT + 'PrivateKey'), $rdf.lit(privateKey), store.sym(privateKeyDoc)))
|
|
4137
|
+
if (privateKey) {
|
|
4138
|
+
_context2.next = 24;
|
|
4139
|
+
break;
|
|
4140
|
+
}
|
|
4141
|
+
// add = []
|
|
4142
|
+
privateKey = generatePrivateKey();
|
|
4143
|
+
add = [$rdf.st(webId, _solidLogic.store.sym(_signature.CERT + 'PrivateKey'), $rdf.literal(privateKey), _solidLogic.store.sym(privateKeyDoc))];
|
|
4144
|
+
_context2.next = 24;
|
|
4145
|
+
return saveKey(privateKeyDoc, [], add, webId.uri);
|
|
4146
|
+
case 24:
|
|
4147
|
+
if (!(!publicKey || !validPublicKey)) {
|
|
4148
|
+
_context2.next = 31;
|
|
4149
|
+
break;
|
|
4150
|
+
}
|
|
4151
|
+
del = [];
|
|
4152
|
+
// delete invalid public key
|
|
4153
|
+
if (publicKey) {
|
|
4154
|
+
del = [$rdf.st(webId, _solidLogic.store.sym(_signature.CERT + 'PublicKey'), $rdf.lit(publicKey), _solidLogic.store.sym(publicKeyDoc))];
|
|
4155
|
+
debug.log(del);
|
|
4156
|
+
}
|
|
4157
|
+
// update new valid key
|
|
4158
|
+
newPublicKey = generatePublicKey(privateKey);
|
|
4159
|
+
add = [$rdf.st(webId, _solidLogic.store.sym(_signature.CERT + 'PublicKey'), $rdf.literal(newPublicKey), _solidLogic.store.sym(publicKeyDoc))];
|
|
4160
|
+
_context2.next = 31;
|
|
4161
|
+
return saveKey(publicKeyDoc, del, add);
|
|
4162
|
+
case 31:
|
|
4163
|
+
keyContainer = privateKeyDoc.substring(0, privateKeyDoc.lastIndexOf('/') + 1);
|
|
4164
|
+
_context2.next = 34;
|
|
4165
|
+
return setAcl(keyContainer, keyContainerAclBody(webId.uri));
|
|
4166
|
+
case 34:
|
|
4167
|
+
return _context2.abrupt("return", privateKey);
|
|
4168
|
+
case 35:
|
|
4144
4169
|
case "end":
|
|
4145
4170
|
return _context2.stop();
|
|
4146
4171
|
}
|
|
4147
|
-
}, _callee2
|
|
4172
|
+
}, _callee2);
|
|
4148
4173
|
}));
|
|
4149
|
-
return _privateKeyExists.apply(this, arguments);
|
|
4150
|
-
}
|
|
4151
|
-
function getPrivateKey(_x3) {
|
|
4152
4174
|
return _getPrivateKey.apply(this, arguments);
|
|
4153
4175
|
}
|
|
4154
|
-
function
|
|
4155
|
-
|
|
4156
|
-
|
|
4176
|
+
var keyContainerAclBody = function keyContainerAclBody(me) {
|
|
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;
|
|
4157
4210
|
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
4158
4211
|
while (1) switch (_context3.prev = _context3.next) {
|
|
4159
4212
|
case 0:
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
publicKey = _context3.sent;
|
|
4169
|
-
_context3.next = 7;
|
|
4170
|
-
return privateKeyExists(webId);
|
|
4171
|
-
case 7:
|
|
4172
|
-
privateKey = _context3.sent;
|
|
4173
|
-
// debug.warn('privateKey ' + privateKey)
|
|
4174
|
-
if (privateKey && publicKey !== generatePublicKey(privateKey)) debug.warn('publicKey is not valid');
|
|
4175
|
-
|
|
4176
|
-
// simulate new key pair
|
|
4177
|
-
/* const newPrivateKey = generatePrivateKey()
|
|
4178
|
-
const newPublicKey = generatePublicKey(newPrivateKey)
|
|
4179
|
-
debug.log('newPrivateKey ' + newPrivateKey)
|
|
4180
|
-
debug.log('newPublicKey ' + newPublicKey) */
|
|
4181
|
-
|
|
4182
|
-
// create key pair
|
|
4183
|
-
if (!(!privateKey || !publicKey)) {
|
|
4184
|
-
_context3.next = 20;
|
|
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;
|
|
4185
4221
|
break;
|
|
4186
4222
|
}
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
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:
|
|
4197
4245
|
_context3.next = 20;
|
|
4198
|
-
return _solidLogic.store.
|
|
4246
|
+
return _solidLogic.store.fetcher.webOperation('PUT', keyAclDoc.value, {
|
|
4247
|
+
data: aclBody,
|
|
4248
|
+
contentType: 'text/turtle'
|
|
4249
|
+
});
|
|
4199
4250
|
case 20:
|
|
4200
|
-
|
|
4251
|
+
aclResponse = _context3.sent;
|
|
4201
4252
|
case 21:
|
|
4202
4253
|
case "end":
|
|
4203
4254
|
return _context3.stop();
|
|
4204
4255
|
}
|
|
4205
|
-
}, _callee3);
|
|
4256
|
+
}, _callee3, null, [[6, 13]]);
|
|
4206
4257
|
}));
|
|
4207
|
-
return
|
|
4258
|
+
return _setAcl.apply(this, arguments);
|
|
4259
|
+
}
|
|
4260
|
+
function saveKey(_x5, _x6, _x7) {
|
|
4261
|
+
return _saveKey.apply(this, arguments);
|
|
4262
|
+
}
|
|
4263
|
+
function _saveKey() {
|
|
4264
|
+
_saveKey = (0, _asyncToGenerator2["default"])(function (keyDoc, del, add) {
|
|
4265
|
+
var me = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
|
|
4266
|
+
return /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
|
|
4267
|
+
var keyAclDoc, response, aclBody;
|
|
4268
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
4269
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
4270
|
+
case 0:
|
|
4271
|
+
_context4.next = 2;
|
|
4272
|
+
return _solidLogic.store.fetcher.load(keyDoc);
|
|
4273
|
+
case 2:
|
|
4274
|
+
_context4.prev = 2;
|
|
4275
|
+
// get keyAcldoc
|
|
4276
|
+
keyAclDoc = _solidLogic.store.any(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl'));
|
|
4277
|
+
if (!keyAclDoc) {
|
|
4278
|
+
_context4.next = 17;
|
|
4279
|
+
break;
|
|
4280
|
+
}
|
|
4281
|
+
_context4.prev = 5;
|
|
4282
|
+
_context4.next = 8;
|
|
4283
|
+
return _solidLogic.store.fetcher.webOperation('DELETE', keyAclDoc.value);
|
|
4284
|
+
case 8:
|
|
4285
|
+
response = _context4.sent;
|
|
4286
|
+
// this may fail if webId is not an owner
|
|
4287
|
+
debug.log('delete ' + keyAclDoc.value + ' ' + response.status); // should test 404 and 2xx
|
|
4288
|
+
_context4.next = 17;
|
|
4289
|
+
break;
|
|
4290
|
+
case 12:
|
|
4291
|
+
_context4.prev = 12;
|
|
4292
|
+
_context4.t0 = _context4["catch"](5);
|
|
4293
|
+
if (!(_context4.t0.response.status !== 404)) {
|
|
4294
|
+
_context4.next = 16;
|
|
4295
|
+
break;
|
|
4296
|
+
}
|
|
4297
|
+
throw new Error(_context4.t0);
|
|
4298
|
+
case 16:
|
|
4299
|
+
debug.log('delete ' + keyAclDoc.value + ' ' + _context4.t0.response.status); // should test 404 and 2xx
|
|
4300
|
+
case 17:
|
|
4301
|
+
_context4.next = 19;
|
|
4302
|
+
return _solidLogic.store.updater.updateMany(del, add);
|
|
4303
|
+
case 19:
|
|
4304
|
+
// or a promise store.updater.update ?
|
|
4305
|
+
// create READ only ACL
|
|
4306
|
+
aclBody = keyAclBody(keyDoc, me);
|
|
4307
|
+
_context4.next = 22;
|
|
4308
|
+
return setAcl(keyDoc, aclBody);
|
|
4309
|
+
case 22:
|
|
4310
|
+
_context4.next = 27;
|
|
4311
|
+
break;
|
|
4312
|
+
case 24:
|
|
4313
|
+
_context4.prev = 24;
|
|
4314
|
+
_context4.t1 = _context4["catch"](2);
|
|
4315
|
+
throw new Error(_context4.t1);
|
|
4316
|
+
case 27:
|
|
4317
|
+
case "end":
|
|
4318
|
+
return _context4.stop();
|
|
4319
|
+
}
|
|
4320
|
+
}, _callee4, null, [[2, 24], [5, 12]]);
|
|
4321
|
+
})();
|
|
4322
|
+
});
|
|
4323
|
+
return _saveKey.apply(this, arguments);
|
|
4208
4324
|
}
|
|
4209
4325
|
//# sourceMappingURL=keys.js.map
|
|
4210
4326
|
|
|
@@ -4335,44 +4451,37 @@ function renderMessageRow(channelObject, message, fresh, options, userContext) {
|
|
|
4335
4451
|
var date = _solidLogic.store.any(message, ns.dct('created'));
|
|
4336
4452
|
var latestVersion = (0, _chatLogic.mostRecentVersion)(message);
|
|
4337
4453
|
var latestVersionCreator = _solidLogic.store.any(latestVersion, ns.foaf('maker'));
|
|
4454
|
+
|
|
4338
4455
|
// use latest content if same owner, else use original
|
|
4339
4456
|
var msgId = creator.uri === latestVersionCreator.uri ? latestVersion : message;
|
|
4340
4457
|
var content = _solidLogic.store.any(msgId, ns.sioc('content'));
|
|
4341
4458
|
var signature = _solidLogic.store.any(msgId, $rdf.sym("".concat(_signature.SEC, "Proof")));
|
|
4342
|
-
debug.log('alain ' + (signature === null || signature === void 0 ? void 0 : signature.value));
|
|
4343
4459
|
|
|
4344
|
-
//
|
|
4460
|
+
// set message object
|
|
4345
4461
|
var msg = (0, _signature.getBlankMsg)();
|
|
4346
4462
|
msg.id = msgId.uri;
|
|
4347
4463
|
msg.created = _solidLogic.store.any(msgId, ns.dct('created')).value;
|
|
4348
4464
|
msg.content = content.value;
|
|
4349
4465
|
msg.maker = creator.uri;
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
const privKey0 = getPrivateKey(creator.uri) // alain to remove
|
|
4370
|
-
// unsigned messages should be signaled as unsecured
|
|
4371
|
-
debug.warn(msg)
|
|
4372
|
-
debug.warn(signature?.value) */
|
|
4373
|
-
if (signature !== null && signature !== void 0 && signature.value && !(0, _signature.verifySignature)(signature.value, msg, pubKey)) throw new Error('invalid signature');
|
|
4374
|
-
} catch (err) {
|
|
4375
|
-
debug.log(err);
|
|
4466
|
+
|
|
4467
|
+
// unsigned message
|
|
4468
|
+
if (!(signature !== null && signature !== void 0 && signature.value)) debug.warn(msgId.uri + ' is unsigned'); // TODO replace with UI (colored message ?)
|
|
4469
|
+
|
|
4470
|
+
// signed message, get public key and check signature
|
|
4471
|
+
else {
|
|
4472
|
+
(0, _keys.getPublicKey)(creator.uri).then(function (publicKey) {
|
|
4473
|
+
debug.log(creator.uri + '\n' + msg.created + '\n' + msg.id + '\n' + publicKey);
|
|
4474
|
+
if (!publicKey) {
|
|
4475
|
+
// TODO try to recreate the publicKey
|
|
4476
|
+
// if(me.uri === creator.uri) await getPrivateKey(creator)
|
|
4477
|
+
debug.warn('message is signed but ' + creator.uri + ' is missing publicKey');
|
|
4478
|
+
}
|
|
4479
|
+
// check that publicKey is a valid hex string
|
|
4480
|
+
var regex = /[0-9A-Fa-f]{6}/g;
|
|
4481
|
+
if (!(publicKey !== null && publicKey !== void 0 && publicKey.match(regex))) debug.warn('invalid publicKey hex string\n' + creator.uri + '\n' + publicKey);
|
|
4482
|
+
// verify signature
|
|
4483
|
+
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);
|
|
4484
|
+
});
|
|
4376
4485
|
}
|
|
4377
4486
|
var originalMessage = (0, _chatLogic.originalVersion)(message);
|
|
4378
4487
|
var edited = !message.sameTerm(originalMessage);
|
|
@@ -12474,6 +12583,251 @@ function isLight(x) {
|
|
|
12474
12583
|
|
|
12475
12584
|
/***/ }),
|
|
12476
12585
|
|
|
12586
|
+
/***/ "./lib/utils/cryptoKeyHelpers.js":
|
|
12587
|
+
/*!***************************************!*\
|
|
12588
|
+
!*** ./lib/utils/cryptoKeyHelpers.js ***!
|
|
12589
|
+
\***************************************/
|
|
12590
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
12591
|
+
|
|
12592
|
+
"use strict";
|
|
12593
|
+
|
|
12594
|
+
|
|
12595
|
+
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
|
+
Object.defineProperty(exports, "__esModule", ({
|
|
12598
|
+
value: true
|
|
12599
|
+
}));
|
|
12600
|
+
exports.privKeyUrl = void 0;
|
|
12601
|
+
exports.privateKeyExists = privateKeyExists;
|
|
12602
|
+
exports.pubKeyUrl = void 0;
|
|
12603
|
+
exports.publicKeyExists = publicKeyExists;
|
|
12604
|
+
var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
|
|
12605
|
+
var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
|
|
12606
|
+
var debug = _interopRequireWildcard(__webpack_require__(/*! ../debug */ "./lib/debug.js"));
|
|
12607
|
+
var _signature = __webpack_require__(/*! ../chat/signature */ "./lib/chat/signature.js");
|
|
12608
|
+
var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
|
|
12609
|
+
var ns = _interopRequireWildcard(__webpack_require__(/*! ../ns */ "./lib/ns.js"));
|
|
12610
|
+
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); }
|
|
12611
|
+
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; }
|
|
12612
|
+
var getPodRoot = /*#__PURE__*/function () {
|
|
12613
|
+
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
|
|
12614
|
+
var _podRoot;
|
|
12615
|
+
var webIdURL, storages, podRoot, path, _res$headers$get, res;
|
|
12616
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
12617
|
+
while (1) switch (_context.prev = _context.next) {
|
|
12618
|
+
case 0:
|
|
12619
|
+
webIdURL = new URL(webId.uri); // find storages in webId document
|
|
12620
|
+
_context.next = 3;
|
|
12621
|
+
return _solidLogic.store.fetcher.load(webId.uri);
|
|
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;
|
|
12626
|
+
break;
|
|
12627
|
+
}
|
|
12628
|
+
// find storage recursively in webId URL
|
|
12629
|
+
path = webIdURL.pathname;
|
|
12630
|
+
case 6:
|
|
12631
|
+
if (!path.length) {
|
|
12632
|
+
_context.next = 17;
|
|
12633
|
+
break;
|
|
12634
|
+
}
|
|
12635
|
+
path = path.substring(0, path.lastIndexOf('/'));
|
|
12636
|
+
podRoot = _solidLogic.store.sym(webIdURL.origin + path + '/');
|
|
12637
|
+
_context.next = 11;
|
|
12638
|
+
return _solidLogic.store.fetcher.webOperation('HEAD', podRoot.uri);
|
|
12639
|
+
case 11:
|
|
12640
|
+
res = _context.sent;
|
|
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;
|
|
12643
|
+
break;
|
|
12644
|
+
}
|
|
12645
|
+
return _context.abrupt("break", 17);
|
|
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:
|
|
12651
|
+
_context.next = 21;
|
|
12652
|
+
break;
|
|
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];
|
|
12659
|
+
case 21:
|
|
12660
|
+
return _context.abrupt("return", (_podRoot = podRoot) === null || _podRoot === void 0 ? void 0 : _podRoot.value);
|
|
12661
|
+
case 22:
|
|
12662
|
+
case "end":
|
|
12663
|
+
return _context.stop();
|
|
12664
|
+
}
|
|
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
|
+
|
|
12477
12831
|
/***/ "./lib/utils/headerFooterHelpers.js":
|
|
12478
12832
|
/*!******************************************!*\
|
|
12479
12833
|
!*** ./lib/utils/headerFooterHelpers.js ***!
|
|
@@ -13320,8 +13674,8 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
13320
13674
|
}));
|
|
13321
13675
|
exports.versionInfo = void 0;
|
|
13322
13676
|
var versionInfo = {
|
|
13323
|
-
buildTime: '2023-
|
|
13324
|
-
commit: '
|
|
13677
|
+
buildTime: '2023-05-05T21:31:54Z',
|
|
13678
|
+
commit: 'f7a2eabe0c0ad3ff6898451fb2c40a36802b4abc',
|
|
13325
13679
|
npmInfo: {
|
|
13326
13680
|
'solid-ui': '2.4.27',
|
|
13327
13681
|
npm: '8.19.4',
|
|
@@ -62007,14 +62361,17 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
62007
62361
|
/* harmony export */ "createRemoteJWKSet": () => (/* binding */ createRemoteJWKSet)
|
|
62008
62362
|
/* harmony export */ });
|
|
62009
62363
|
/* harmony import */ var _runtime_fetch_jwks_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../runtime/fetch_jwks.js */ "./node_modules/jose/dist/browser/runtime/fetch_jwks.js");
|
|
62010
|
-
/* harmony import */ var
|
|
62011
|
-
/* harmony import */ var
|
|
62012
|
-
/* harmony import */ var _local_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./local.js */ "./node_modules/jose/dist/browser/jwks/local.js");
|
|
62013
|
-
|
|
62364
|
+
/* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
|
|
62365
|
+
/* harmony import */ var _local_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./local.js */ "./node_modules/jose/dist/browser/jwks/local.js");
|
|
62014
62366
|
|
|
62015
62367
|
|
|
62016
62368
|
|
|
62017
|
-
|
|
62369
|
+
function isCloudflareWorkers() {
|
|
62370
|
+
return (typeof WebSocketPair !== 'undefined' ||
|
|
62371
|
+
(typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers') ||
|
|
62372
|
+
(typeof EdgeRuntime !== 'undefined' && EdgeRuntime === 'vercel'));
|
|
62373
|
+
}
|
|
62374
|
+
class RemoteJWKSet extends _local_js__WEBPACK_IMPORTED_MODULE_2__.LocalJWKSet {
|
|
62018
62375
|
constructor(url, options) {
|
|
62019
62376
|
super({ keys: [] });
|
|
62020
62377
|
this._jwks = undefined;
|
|
@@ -62047,7 +62404,7 @@ class RemoteJWKSet extends _local_js__WEBPACK_IMPORTED_MODULE_3__.LocalJWKSet {
|
|
|
62047
62404
|
return await super.getKey(protectedHeader, token);
|
|
62048
62405
|
}
|
|
62049
62406
|
catch (err) {
|
|
62050
|
-
if (err instanceof
|
|
62407
|
+
if (err instanceof _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JWKSNoMatchingKey) {
|
|
62051
62408
|
if (this.coolingDown() === false) {
|
|
62052
62409
|
await this.reload();
|
|
62053
62410
|
return super.getKey(protectedHeader, token);
|
|
@@ -62057,13 +62414,13 @@ class RemoteJWKSet extends _local_js__WEBPACK_IMPORTED_MODULE_3__.LocalJWKSet {
|
|
|
62057
62414
|
}
|
|
62058
62415
|
}
|
|
62059
62416
|
async reload() {
|
|
62060
|
-
if (this._pendingFetch &&
|
|
62417
|
+
if (this._pendingFetch && isCloudflareWorkers()) {
|
|
62061
62418
|
this._pendingFetch = undefined;
|
|
62062
62419
|
}
|
|
62063
62420
|
this._pendingFetch || (this._pendingFetch = (0,_runtime_fetch_jwks_js__WEBPACK_IMPORTED_MODULE_0__["default"])(this._url, this._timeoutDuration, this._options)
|
|
62064
62421
|
.then((json) => {
|
|
62065
|
-
if (!(0,
|
|
62066
|
-
throw new
|
|
62422
|
+
if (!(0,_local_js__WEBPACK_IMPORTED_MODULE_2__.isJWKSLike)(json)) {
|
|
62423
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JWKSInvalid('JSON Web Key Set malformed');
|
|
62067
62424
|
}
|
|
62068
62425
|
this._jwks = { keys: json.keys };
|
|
62069
62426
|
this._jwksTimestamp = Date.now();
|
|
@@ -63251,8 +63608,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
63251
63608
|
/* harmony export */ "checkEncCryptoKey": () => (/* binding */ checkEncCryptoKey),
|
|
63252
63609
|
/* harmony export */ "checkSigCryptoKey": () => (/* binding */ checkSigCryptoKey)
|
|
63253
63610
|
/* harmony export */ });
|
|
63254
|
-
/* harmony import */ var _runtime_env_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../runtime/env.js */ "./node_modules/jose/dist/browser/runtime/env.js");
|
|
63255
|
-
|
|
63256
63611
|
function unusable(name, prop = 'algorithm.name') {
|
|
63257
63612
|
return new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
|
|
63258
63613
|
}
|
|
@@ -63327,11 +63682,6 @@ function checkSigCryptoKey(key, alg, ...usages) {
|
|
|
63327
63682
|
}
|
|
63328
63683
|
case 'EdDSA': {
|
|
63329
63684
|
if (key.algorithm.name !== 'Ed25519' && key.algorithm.name !== 'Ed448') {
|
|
63330
|
-
if ((0,_runtime_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)()) {
|
|
63331
|
-
if (isAlgorithm(key.algorithm, 'NODE-ED25519'))
|
|
63332
|
-
break;
|
|
63333
|
-
throw unusable('Ed25519, Ed448, or NODE-ED25519');
|
|
63334
|
-
}
|
|
63335
63685
|
throw unusable('Ed25519 or Ed448');
|
|
63336
63686
|
}
|
|
63337
63687
|
break;
|
|
@@ -64162,14 +64512,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
64162
64512
|
/* harmony export */ "toPKCS8": () => (/* binding */ toPKCS8),
|
|
64163
64513
|
/* harmony export */ "toSPKI": () => (/* binding */ toSPKI)
|
|
64164
64514
|
/* harmony export */ });
|
|
64165
|
-
/* harmony import */ var
|
|
64166
|
-
/* harmony import */ var
|
|
64167
|
-
/* harmony import */ var
|
|
64168
|
-
/* harmony import */ var
|
|
64169
|
-
/* harmony import */ var
|
|
64170
|
-
/* harmony import */ var
|
|
64171
|
-
/* harmony import */ var _is_key_like_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./is_key_like.js */ "./node_modules/jose/dist/browser/runtime/is_key_like.js");
|
|
64172
|
-
|
|
64515
|
+
/* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webcrypto.js */ "./node_modules/jose/dist/browser/runtime/webcrypto.js");
|
|
64516
|
+
/* harmony import */ var _lib_invalid_key_input_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../lib/invalid_key_input.js */ "./node_modules/jose/dist/browser/lib/invalid_key_input.js");
|
|
64517
|
+
/* harmony import */ var _base64url_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base64url.js */ "./node_modules/jose/dist/browser/runtime/base64url.js");
|
|
64518
|
+
/* harmony import */ var _lib_format_pem_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../lib/format_pem.js */ "./node_modules/jose/dist/browser/lib/format_pem.js");
|
|
64519
|
+
/* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
|
|
64520
|
+
/* harmony import */ var _is_key_like_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./is_key_like.js */ "./node_modules/jose/dist/browser/runtime/is_key_like.js");
|
|
64173
64521
|
|
|
64174
64522
|
|
|
64175
64523
|
|
|
@@ -64177,8 +64525,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
64177
64525
|
|
|
64178
64526
|
|
|
64179
64527
|
const genericExport = async (keyType, keyFormat, key) => {
|
|
64180
|
-
if (!(0,
|
|
64181
|
-
throw new TypeError((0,
|
|
64528
|
+
if (!(0,_webcrypto_js__WEBPACK_IMPORTED_MODULE_0__.isCryptoKey)(key)) {
|
|
64529
|
+
throw new TypeError((0,_lib_invalid_key_input_js__WEBPACK_IMPORTED_MODULE_1__["default"])(key, ..._is_key_like_js__WEBPACK_IMPORTED_MODULE_5__.types));
|
|
64182
64530
|
}
|
|
64183
64531
|
if (!key.extractable) {
|
|
64184
64532
|
throw new TypeError('CryptoKey is not extractable');
|
|
@@ -64186,7 +64534,7 @@ const genericExport = async (keyType, keyFormat, key) => {
|
|
|
64186
64534
|
if (key.type !== keyType) {
|
|
64187
64535
|
throw new TypeError(`key is not a ${keyType} key`);
|
|
64188
64536
|
}
|
|
64189
|
-
return (0,
|
|
64537
|
+
return (0,_lib_format_pem_js__WEBPACK_IMPORTED_MODULE_3__["default"])((0,_base64url_js__WEBPACK_IMPORTED_MODULE_2__.encodeBase64)(new Uint8Array(await _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__["default"].subtle.exportKey(keyFormat, key))), `${keyType.toUpperCase()} KEY`);
|
|
64190
64538
|
};
|
|
64191
64539
|
const toSPKI = (key) => {
|
|
64192
64540
|
return genericExport('public', 'spki', key);
|
|
@@ -64224,11 +64572,11 @@ const getNamedCurve = (keyData) => {
|
|
|
64224
64572
|
case findOid(keyData, [0x2b, 0x65, 0x71]):
|
|
64225
64573
|
return 'Ed448';
|
|
64226
64574
|
default:
|
|
64227
|
-
throw new
|
|
64575
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_4__.JOSENotSupported('Invalid or unsupported EC Key Curve or OKP Key Sub Type');
|
|
64228
64576
|
}
|
|
64229
64577
|
};
|
|
64230
64578
|
const genericImport = async (replace, keyFormat, pem, alg, options) => {
|
|
64231
|
-
var _a
|
|
64579
|
+
var _a;
|
|
64232
64580
|
let algorithm;
|
|
64233
64581
|
let keyUsages;
|
|
64234
64582
|
const keyData = new Uint8Array(atob(pem.replace(replace, ''))
|
|
@@ -64284,20 +64632,9 @@ const genericImport = async (replace, keyFormat, pem, alg, options) => {
|
|
|
64284
64632
|
keyUsages = isPublic ? ['verify'] : ['sign'];
|
|
64285
64633
|
break;
|
|
64286
64634
|
default:
|
|
64287
|
-
throw new
|
|
64288
|
-
}
|
|
64289
|
-
try {
|
|
64290
|
-
return await _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.importKey(keyFormat, keyData, algorithm, (_a = options === null || options === void 0 ? void 0 : options.extractable) !== null && _a !== void 0 ? _a : false, keyUsages);
|
|
64291
|
-
}
|
|
64292
|
-
catch (err) {
|
|
64293
|
-
if (algorithm.name === 'Ed25519' &&
|
|
64294
|
-
(err === null || err === void 0 ? void 0 : err.name) === 'NotSupportedError' &&
|
|
64295
|
-
(0,_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)()) {
|
|
64296
|
-
algorithm = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
|
|
64297
|
-
return await _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.importKey(keyFormat, keyData, algorithm, (_b = options === null || options === void 0 ? void 0 : options.extractable) !== null && _b !== void 0 ? _b : false, keyUsages);
|
|
64298
|
-
}
|
|
64299
|
-
throw err;
|
|
64635
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_4__.JOSENotSupported('Invalid or unsupported "alg" (Algorithm) value');
|
|
64300
64636
|
}
|
|
64637
|
+
return _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__["default"].subtle.importKey(keyFormat, keyData, algorithm, (_a = options === null || options === void 0 ? void 0 : options.extractable) !== null && _a !== void 0 ? _a : false, keyUsages);
|
|
64301
64638
|
};
|
|
64302
64639
|
const fromPKCS8 = (pem, alg, options) => {
|
|
64303
64640
|
return genericImport(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g, 'pkcs8', pem, alg, options);
|
|
@@ -64366,12 +64703,12 @@ function parseElement(bytes) {
|
|
|
64366
64703
|
}
|
|
64367
64704
|
function spkiFromX509(buf) {
|
|
64368
64705
|
const tbsCertificate = getElement(getElement(parseElement(buf).contents)[0].contents);
|
|
64369
|
-
return (0,
|
|
64706
|
+
return (0,_base64url_js__WEBPACK_IMPORTED_MODULE_2__.encodeBase64)(tbsCertificate[tbsCertificate[0].raw[0] === 0xa0 ? 6 : 5].raw);
|
|
64370
64707
|
}
|
|
64371
64708
|
function getSPKI(x509) {
|
|
64372
64709
|
const pem = x509.replace(/(?:-----(?:BEGIN|END) CERTIFICATE-----|\s)/g, '');
|
|
64373
|
-
const raw = (0,
|
|
64374
|
-
return (0,
|
|
64710
|
+
const raw = (0,_base64url_js__WEBPACK_IMPORTED_MODULE_2__.decodeBase64)(pem);
|
|
64711
|
+
return (0,_lib_format_pem_js__WEBPACK_IMPORTED_MODULE_3__["default"])(spkiFromX509(raw), 'PUBLIC KEY');
|
|
64375
64712
|
}
|
|
64376
64713
|
const fromX509 = (pem, alg, options) => {
|
|
64377
64714
|
let spki;
|
|
@@ -64799,26 +65136,6 @@ const encrypt = async (enc, plaintext, cek, iv, aad) => {
|
|
|
64799
65136
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (encrypt);
|
|
64800
65137
|
|
|
64801
65138
|
|
|
64802
|
-
/***/ }),
|
|
64803
|
-
|
|
64804
|
-
/***/ "./node_modules/jose/dist/browser/runtime/env.js":
|
|
64805
|
-
/*!*******************************************************!*\
|
|
64806
|
-
!*** ./node_modules/jose/dist/browser/runtime/env.js ***!
|
|
64807
|
-
\*******************************************************/
|
|
64808
|
-
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
64809
|
-
|
|
64810
|
-
"use strict";
|
|
64811
|
-
__webpack_require__.r(__webpack_exports__);
|
|
64812
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
64813
|
-
/* harmony export */ "isCloudflareWorkers": () => (/* binding */ isCloudflareWorkers)
|
|
64814
|
-
/* harmony export */ });
|
|
64815
|
-
function isCloudflareWorkers() {
|
|
64816
|
-
return (typeof WebSocketPair !== 'undefined' ||
|
|
64817
|
-
(typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers') ||
|
|
64818
|
-
(typeof EdgeRuntime !== 'undefined' && EdgeRuntime === 'vercel'));
|
|
64819
|
-
}
|
|
64820
|
-
|
|
64821
|
-
|
|
64822
65139
|
/***/ }),
|
|
64823
65140
|
|
|
64824
65141
|
/***/ "./node_modules/jose/dist/browser/runtime/fetch_jwks.js":
|
|
@@ -64883,11 +65200,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
64883
65200
|
/* harmony export */ "generateKeyPair": () => (/* binding */ generateKeyPair),
|
|
64884
65201
|
/* harmony export */ "generateSecret": () => (/* binding */ generateSecret)
|
|
64885
65202
|
/* harmony export */ });
|
|
64886
|
-
/* harmony import */ var
|
|
64887
|
-
/* harmony import */ var
|
|
64888
|
-
/* harmony import */ var
|
|
64889
|
-
/* harmony import */ var _random_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./random.js */ "./node_modules/jose/dist/browser/runtime/random.js");
|
|
64890
|
-
|
|
65203
|
+
/* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webcrypto.js */ "./node_modules/jose/dist/browser/runtime/webcrypto.js");
|
|
65204
|
+
/* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
|
|
65205
|
+
/* harmony import */ var _random_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./random.js */ "./node_modules/jose/dist/browser/runtime/random.js");
|
|
64891
65206
|
|
|
64892
65207
|
|
|
64893
65208
|
|
|
@@ -64908,7 +65223,7 @@ async function generateSecret(alg, options) {
|
|
|
64908
65223
|
case 'A192CBC-HS384':
|
|
64909
65224
|
case 'A256CBC-HS512':
|
|
64910
65225
|
length = parseInt(alg.slice(-3), 10);
|
|
64911
|
-
return (0,
|
|
65226
|
+
return (0,_random_js__WEBPACK_IMPORTED_MODULE_2__["default"])(new Uint8Array(length >> 3));
|
|
64912
65227
|
case 'A128KW':
|
|
64913
65228
|
case 'A192KW':
|
|
64914
65229
|
case 'A256KW':
|
|
@@ -64927,20 +65242,20 @@ async function generateSecret(alg, options) {
|
|
|
64927
65242
|
keyUsages = ['encrypt', 'decrypt'];
|
|
64928
65243
|
break;
|
|
64929
65244
|
default:
|
|
64930
|
-
throw new
|
|
65245
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
64931
65246
|
}
|
|
64932
|
-
return
|
|
65247
|
+
return _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__["default"].subtle.generateKey(algorithm, (_a = options === null || options === void 0 ? void 0 : options.extractable) !== null && _a !== void 0 ? _a : false, keyUsages);
|
|
64933
65248
|
}
|
|
64934
65249
|
function getModulusLengthOption(options) {
|
|
64935
65250
|
var _a;
|
|
64936
65251
|
const modulusLength = (_a = options === null || options === void 0 ? void 0 : options.modulusLength) !== null && _a !== void 0 ? _a : 2048;
|
|
64937
65252
|
if (typeof modulusLength !== 'number' || modulusLength < 2048) {
|
|
64938
|
-
throw new
|
|
65253
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used');
|
|
64939
65254
|
}
|
|
64940
65255
|
return modulusLength;
|
|
64941
65256
|
}
|
|
64942
65257
|
async function generateKeyPair(alg, options) {
|
|
64943
|
-
var _a, _b, _c
|
|
65258
|
+
var _a, _b, _c;
|
|
64944
65259
|
let algorithm;
|
|
64945
65260
|
let keyUsages;
|
|
64946
65261
|
switch (alg) {
|
|
@@ -64999,7 +65314,7 @@ async function generateKeyPair(alg, options) {
|
|
|
64999
65314
|
algorithm = { name: crv };
|
|
65000
65315
|
break;
|
|
65001
65316
|
default:
|
|
65002
|
-
throw new
|
|
65317
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported crv option provided');
|
|
65003
65318
|
}
|
|
65004
65319
|
break;
|
|
65005
65320
|
case 'ECDH-ES':
|
|
@@ -65020,25 +65335,14 @@ async function generateKeyPair(alg, options) {
|
|
|
65020
65335
|
algorithm = { name: crv };
|
|
65021
65336
|
break;
|
|
65022
65337
|
default:
|
|
65023
|
-
throw new
|
|
65338
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, X25519, and X448');
|
|
65024
65339
|
}
|
|
65025
65340
|
break;
|
|
65026
65341
|
}
|
|
65027
65342
|
default:
|
|
65028
|
-
throw new
|
|
65029
|
-
}
|
|
65030
|
-
try {
|
|
65031
|
-
return (await _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.generateKey(algorithm, (_c = options === null || options === void 0 ? void 0 : options.extractable) !== null && _c !== void 0 ? _c : false, keyUsages));
|
|
65032
|
-
}
|
|
65033
|
-
catch (err) {
|
|
65034
|
-
if (algorithm.name === 'Ed25519' &&
|
|
65035
|
-
(err === null || err === void 0 ? void 0 : err.name) === 'NotSupportedError' &&
|
|
65036
|
-
(0,_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)()) {
|
|
65037
|
-
algorithm = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
|
|
65038
|
-
return (await _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.generateKey(algorithm, (_d = options === null || options === void 0 ? void 0 : options.extractable) !== null && _d !== void 0 ? _d : false, keyUsages));
|
|
65039
|
-
}
|
|
65040
|
-
throw err;
|
|
65343
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
65041
65344
|
}
|
|
65345
|
+
return (_webcrypto_js__WEBPACK_IMPORTED_MODULE_0__["default"].subtle.generateKey(algorithm, (_c = options === null || options === void 0 ? void 0 : options.extractable) !== null && _c !== void 0 ? _c : false, keyUsages));
|
|
65042
65346
|
}
|
|
65043
65347
|
|
|
65044
65348
|
|
|
@@ -65113,11 +65417,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
65113
65417
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
65114
65418
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
65115
65419
|
/* harmony export */ });
|
|
65116
|
-
/* harmony import */ var
|
|
65117
|
-
/* harmony import */ var
|
|
65118
|
-
/* harmony import */ var
|
|
65119
|
-
/* harmony import */ var _base64url_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./base64url.js */ "./node_modules/jose/dist/browser/runtime/base64url.js");
|
|
65120
|
-
|
|
65420
|
+
/* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webcrypto.js */ "./node_modules/jose/dist/browser/runtime/webcrypto.js");
|
|
65421
|
+
/* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
|
|
65422
|
+
/* harmony import */ var _base64url_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base64url.js */ "./node_modules/jose/dist/browser/runtime/base64url.js");
|
|
65121
65423
|
|
|
65122
65424
|
|
|
65123
65425
|
|
|
@@ -65136,7 +65438,7 @@ function subtleMapping(jwk) {
|
|
|
65136
65438
|
case 'A128CBC-HS256':
|
|
65137
65439
|
case 'A192CBC-HS384':
|
|
65138
65440
|
case 'A256CBC-HS512':
|
|
65139
|
-
throw new
|
|
65441
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported(`${jwk.alg} keys cannot be imported as CryptoKey instances`);
|
|
65140
65442
|
case 'A128GCM':
|
|
65141
65443
|
case 'A192GCM':
|
|
65142
65444
|
case 'A256GCM':
|
|
@@ -65159,7 +65461,7 @@ function subtleMapping(jwk) {
|
|
|
65159
65461
|
keyUsages = ['deriveBits'];
|
|
65160
65462
|
break;
|
|
65161
65463
|
default:
|
|
65162
|
-
throw new
|
|
65464
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
65163
65465
|
}
|
|
65164
65466
|
break;
|
|
65165
65467
|
}
|
|
@@ -65188,7 +65490,7 @@ function subtleMapping(jwk) {
|
|
|
65188
65490
|
keyUsages = jwk.d ? ['decrypt', 'unwrapKey'] : ['encrypt', 'wrapKey'];
|
|
65189
65491
|
break;
|
|
65190
65492
|
default:
|
|
65191
|
-
throw new
|
|
65493
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
65192
65494
|
}
|
|
65193
65495
|
break;
|
|
65194
65496
|
}
|
|
@@ -65214,7 +65516,7 @@ function subtleMapping(jwk) {
|
|
|
65214
65516
|
keyUsages = jwk.d ? ['deriveBits'] : [];
|
|
65215
65517
|
break;
|
|
65216
65518
|
default:
|
|
65217
|
-
throw new
|
|
65519
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
65218
65520
|
}
|
|
65219
65521
|
break;
|
|
65220
65522
|
}
|
|
@@ -65232,12 +65534,12 @@ function subtleMapping(jwk) {
|
|
|
65232
65534
|
keyUsages = jwk.d ? ['deriveBits'] : [];
|
|
65233
65535
|
break;
|
|
65234
65536
|
default:
|
|
65235
|
-
throw new
|
|
65537
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
65236
65538
|
}
|
|
65237
65539
|
break;
|
|
65238
65540
|
}
|
|
65239
65541
|
default:
|
|
65240
|
-
throw new
|
|
65542
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
|
|
65241
65543
|
}
|
|
65242
65544
|
return { algorithm, keyUsages };
|
|
65243
65545
|
}
|
|
@@ -65253,23 +65555,12 @@ const parse = async (jwk) => {
|
|
|
65253
65555
|
(_b = jwk.key_ops) !== null && _b !== void 0 ? _b : keyUsages,
|
|
65254
65556
|
];
|
|
65255
65557
|
if (algorithm.name === 'PBKDF2') {
|
|
65256
|
-
return
|
|
65558
|
+
return _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__["default"].subtle.importKey('raw', (0,_base64url_js__WEBPACK_IMPORTED_MODULE_2__.decode)(jwk.k), ...rest);
|
|
65257
65559
|
}
|
|
65258
65560
|
const keyData = { ...jwk };
|
|
65259
65561
|
delete keyData.alg;
|
|
65260
65562
|
delete keyData.use;
|
|
65261
|
-
|
|
65262
|
-
return await _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.importKey('jwk', keyData, ...rest);
|
|
65263
|
-
}
|
|
65264
|
-
catch (err) {
|
|
65265
|
-
if (algorithm.name === 'Ed25519' &&
|
|
65266
|
-
(err === null || err === void 0 ? void 0 : err.name) === 'NotSupportedError' &&
|
|
65267
|
-
(0,_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)()) {
|
|
65268
|
-
rest[0] = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
|
|
65269
|
-
return await _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.importKey('jwk', keyData, ...rest);
|
|
65270
|
-
}
|
|
65271
|
-
throw err;
|
|
65272
|
-
}
|
|
65563
|
+
return _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__["default"].subtle.importKey('jwk', keyData, ...rest);
|
|
65273
65564
|
};
|
|
65274
65565
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (parse);
|
|
65275
65566
|
|
|
@@ -65511,9 +65802,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
65511
65802
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
65512
65803
|
/* harmony export */ "default": () => (/* binding */ subtleDsa)
|
|
65513
65804
|
/* harmony export */ });
|
|
65514
|
-
/* harmony import */ var
|
|
65515
|
-
/* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
|
|
65516
|
-
|
|
65805
|
+
/* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
|
|
65517
65806
|
|
|
65518
65807
|
function subtleDsa(alg, algorithm) {
|
|
65519
65808
|
const hash = `SHA-${alg.slice(-3)}`;
|
|
@@ -65535,12 +65824,9 @@ function subtleDsa(alg, algorithm) {
|
|
|
65535
65824
|
case 'ES512':
|
|
65536
65825
|
return { hash, name: 'ECDSA', namedCurve: algorithm.namedCurve };
|
|
65537
65826
|
case 'EdDSA':
|
|
65538
|
-
if ((0,_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)() && algorithm.name === 'NODE-ED25519') {
|
|
65539
|
-
return { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
|
|
65540
|
-
}
|
|
65541
65827
|
return { name: algorithm.name };
|
|
65542
65828
|
default:
|
|
65543
|
-
throw new
|
|
65829
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_0__.JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
|
|
65544
65830
|
}
|
|
65545
65831
|
}
|
|
65546
65832
|
|