solid-ui 2.4.27-6c8461c9 → 2.4.27-77f914e3
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 +1700 -1212
- 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 +62 -36
- package/lib/chat/chatLogic.js.map +1 -1
- package/lib/chat/keys.d.ts +3 -2
- package/lib/chat/keys.d.ts.map +1 -1
- package/lib/chat/keys.js +174 -49
- package/lib/chat/keys.js.map +1 -1
- package/lib/chat/message.js +30 -12
- 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 +25 -22
- 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/keyHelpers/accessData.js +226 -0
- 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/chat/crypto.d.ts +0 -1
- package/lib/chat/crypto.d.ts.map +0 -1
- package/lib/chat/crypto.js +0 -257
- package/lib/chat/crypto.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, 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:
|
|
@@ -2666,57 +2666,83 @@ var ChatChannel = /*#__PURE__*/function () {
|
|
|
2666
2666
|
chatDocument = oldMsg ? oldMsg.doc() : _this.dateFolder.leafDocumentFromDate(now);
|
|
2667
2667
|
message = _solidLogic.store.sym(chatDocument.uri + '#' + 'Msg' + timestamp); // const content = store.literal(text)
|
|
2668
2668
|
me = _solidLogic.authn.currentUser(); // If already logged on
|
|
2669
|
-
msg = _signature.getBlankMsg;
|
|
2670
|
-
msg.id = message;
|
|
2671
|
-
if (oldMsg) {
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
// link new message to channel
|
|
2681
|
-
sts.push($rdf.st(_this.channel, ns.wf('message'), message, chatDocument));
|
|
2669
|
+
msg = (0, _signature.getBlankMsg)();
|
|
2670
|
+
msg.id = message.uri;
|
|
2671
|
+
if (!oldMsg) {
|
|
2672
|
+
_context2.next = 22;
|
|
2673
|
+
break;
|
|
2674
|
+
}
|
|
2675
|
+
// edit message replaces old one
|
|
2676
|
+
oldMsgMaker = _solidLogic.store.any(oldMsg, ns.foaf('maker')); // may not be needed here, but needed on READ
|
|
2677
|
+
if (!(oldMsgMaker.uri === me.uri)) {
|
|
2678
|
+
_context2.next = 16;
|
|
2679
|
+
break;
|
|
2682
2680
|
}
|
|
2681
|
+
sts.push($rdf.st(mostRecentVersion(oldMsg), ns.dct('isReplacedBy'), message, chatDocument));
|
|
2682
|
+
if (deleteIt) {
|
|
2683
|
+
// we need to add a specific signature, else anyone can delete a msg ?
|
|
2684
|
+
sts.push($rdf.st(message, ns.schema('dateDeleted'), dateStamp, chatDocument));
|
|
2685
|
+
// msg.dateDeleted = dateStamp
|
|
2686
|
+
}
|
|
2687
|
+
_context2.next = 20;
|
|
2688
|
+
break;
|
|
2689
|
+
case 16:
|
|
2690
|
+
errMsg = 'Error you cannot delete/edit a message from someone else : \n' + oldMsgMaker.uri;
|
|
2691
|
+
debug.warn(errMsg);
|
|
2692
|
+
alert(errMsg);
|
|
2693
|
+
throw new Error(errMsg);
|
|
2694
|
+
case 20:
|
|
2695
|
+
_context2.next = 23;
|
|
2696
|
+
break;
|
|
2697
|
+
case 22:
|
|
2698
|
+
// link new message to channel
|
|
2699
|
+
sts.push($rdf.st(_this.channel, ns.wf('message'), message, chatDocument));
|
|
2700
|
+
case 23:
|
|
2683
2701
|
sts.push($rdf.st(message, ns.sioc('content'), _solidLogic.store.literal(text), chatDocument));
|
|
2684
2702
|
msg.content = text;
|
|
2685
2703
|
sts.push($rdf.st(message, ns.dct('created'), dateStamp, chatDocument));
|
|
2686
|
-
msg.created = dateStamp;
|
|
2704
|
+
msg.created = dateStamp.value;
|
|
2687
2705
|
if (!me) {
|
|
2688
|
-
_context2.next =
|
|
2706
|
+
_context2.next = 35;
|
|
2689
2707
|
break;
|
|
2690
2708
|
}
|
|
2691
2709
|
sts.push($rdf.st(message, ns.foaf('maker'), me, chatDocument));
|
|
2692
|
-
msg.maker = me;
|
|
2693
|
-
// privateKey the cached private key of me,
|
|
2694
|
-
_context2.next =
|
|
2710
|
+
msg.maker = me.uri;
|
|
2711
|
+
// privateKey the cached private key of me, cached in store
|
|
2712
|
+
_context2.next = 32;
|
|
2695
2713
|
return (0, _keys.getPrivateKey)(me);
|
|
2696
|
-
case
|
|
2714
|
+
case 32:
|
|
2697
2715
|
privateKey = _context2.sent;
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2716
|
+
// me.uri)
|
|
2717
|
+
// const privateKey0 = 'a11bc5d2eee6cdb3b37f5473a712cad905ccfb13fb2ccdbf1be0a1ac4fdc7d2a'
|
|
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
|
|
2721
|
+
debug.warn('sig ' + sig)
|
|
2722
|
+
debug.warn('verifySign ' + verify)
|
|
2723
|
+
debug.warn(msg) */
|
|
2724
|
+
sts.push($rdf.st(message, $rdf.sym("".concat(_signature.SEC, "Proof")), $rdf.lit(sig), chatDocument));
|
|
2725
|
+
case 35:
|
|
2726
|
+
_context2.prev = 35;
|
|
2727
|
+
_context2.next = 38;
|
|
2702
2728
|
return _solidLogic.store.updater.update([], sts);
|
|
2703
|
-
case
|
|
2704
|
-
_context2.next =
|
|
2729
|
+
case 38:
|
|
2730
|
+
_context2.next = 46;
|
|
2705
2731
|
break;
|
|
2706
|
-
case
|
|
2707
|
-
_context2.prev =
|
|
2708
|
-
_context2.t0 = _context2["catch"](
|
|
2709
|
-
|
|
2710
|
-
debug.warn(
|
|
2711
|
-
alert(
|
|
2712
|
-
throw new Error(
|
|
2713
|
-
case
|
|
2732
|
+
case 40:
|
|
2733
|
+
_context2.prev = 40;
|
|
2734
|
+
_context2.t0 = _context2["catch"](35);
|
|
2735
|
+
_errMsg = 'Error saving chat message: ' + _context2.t0;
|
|
2736
|
+
debug.warn(_errMsg);
|
|
2737
|
+
alert(_errMsg);
|
|
2738
|
+
throw new Error(_errMsg);
|
|
2739
|
+
case 46:
|
|
2714
2740
|
return _context2.abrupt("return", message);
|
|
2715
|
-
case
|
|
2741
|
+
case 47:
|
|
2716
2742
|
case "end":
|
|
2717
2743
|
return _context2.stop();
|
|
2718
2744
|
}
|
|
2719
|
-
}, _callee2, null, [[
|
|
2745
|
+
}, _callee2, null, [[35, 40]]);
|
|
2720
2746
|
})();
|
|
2721
2747
|
});
|
|
2722
2748
|
function updateMessage(_x2) {
|
|
@@ -4011,82 +4037,207 @@ exports.getPrivateKey = getPrivateKey;
|
|
|
4011
4037
|
exports.getPublicKey = getPublicKey;
|
|
4012
4038
|
var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
|
|
4013
4039
|
var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
|
|
4040
|
+
var debug = _interopRequireWildcard(__webpack_require__(/*! ../debug */ "./lib/debug.js"));
|
|
4014
4041
|
var _secp256k = __webpack_require__(/*! @noble/curves/secp256k1 */ "./node_modules/@noble/curves/secp256k1.js");
|
|
4015
4042
|
var _utils = __webpack_require__(/*! @noble/hashes/utils */ "./node_modules/@noble/hashes/utils.js");
|
|
4016
4043
|
var _signature = __webpack_require__(/*! ./signature */ "./lib/chat/signature.js");
|
|
4017
4044
|
var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
|
|
4018
4045
|
var $rdf = _interopRequireWildcard(__webpack_require__(/*! rdflib */ "./node_modules/rdflib/esm/index.js"));
|
|
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");
|
|
4019
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); }
|
|
4020
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; }
|
|
4021
|
-
// should have webcrypto.getRandomValues defined
|
|
4022
|
-
|
|
4023
4050
|
function generatePrivateKey() {
|
|
4024
4051
|
return (0, _utils.bytesToHex)(_secp256k.schnorr.utils.randomPrivateKey());
|
|
4025
4052
|
}
|
|
4026
4053
|
function generatePublicKey(privateKey) {
|
|
4027
4054
|
return (0, _utils.bytesToHex)(_secp256k.schnorr.getPublicKey(privateKey));
|
|
4028
4055
|
}
|
|
4029
|
-
function getPublicKey(
|
|
4030
|
-
|
|
4031
|
-
/* const url = new URL(webId)
|
|
4032
|
-
url.hash = ''
|
|
4033
|
-
store.fetcher.load(url.href)
|
|
4034
|
-
let publicKey = store.any(store.sym(webId), store.sym(CERT +'publicKey')) */
|
|
4035
|
-
var publicKey = publicKeyExists(webId);
|
|
4036
|
-
return publicKey === null || publicKey === void 0 ? void 0 : publicKey.uri;
|
|
4037
|
-
}
|
|
4038
|
-
function publicKeyExists(webId) {
|
|
4039
|
-
// find publickey
|
|
4040
|
-
var url = new URL(webId);
|
|
4041
|
-
url.hash = '';
|
|
4042
|
-
_solidLogic.store.fetcher.load(url.href);
|
|
4043
|
-
var publicKey = _solidLogic.store.any(_solidLogic.store.sym(webId), _solidLogic.store.sym(_signature.CERT + 'publicKey'));
|
|
4044
|
-
return publicKey;
|
|
4045
|
-
}
|
|
4046
|
-
function privateKeyExists(webId) {
|
|
4047
|
-
var url = new URL(webId);
|
|
4048
|
-
var privateKeyUrl = url.hostname + '/profile/privateKey.ttl';
|
|
4049
|
-
_solidLogic.store.fetcher.load(privateKeyUrl);
|
|
4050
|
-
var privateKey = _solidLogic.store.any(_solidLogic.store.sym(webId), _solidLogic.store.sym(_signature.CERT + 'privateKey'));
|
|
4051
|
-
return privateKey;
|
|
4052
|
-
}
|
|
4053
|
-
function getPrivateKey(_x) {
|
|
4054
|
-
return _getPrivateKey.apply(this, arguments);
|
|
4056
|
+
function getPublicKey(_x) {
|
|
4057
|
+
return _getPublicKey.apply(this, arguments);
|
|
4055
4058
|
}
|
|
4056
|
-
function
|
|
4057
|
-
|
|
4058
|
-
var
|
|
4059
|
+
function _getPublicKey() {
|
|
4060
|
+
_getPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
|
|
4061
|
+
var publicKeyDoc, key;
|
|
4059
4062
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
4060
4063
|
while (1) switch (_context.prev = _context.next) {
|
|
4061
4064
|
case 0:
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4065
|
+
_context.next = 2;
|
|
4066
|
+
return _solidLogic.store.fetcher.load(webId);
|
|
4067
|
+
case 2:
|
|
4068
|
+
_context.next = 4;
|
|
4069
|
+
return (0, _accessData.pubKeyUrl)(webId);
|
|
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:
|
|
4084
|
+
case "end":
|
|
4085
|
+
return _context.stop();
|
|
4086
|
+
}
|
|
4087
|
+
}, _callee, null, [[5, 12]]);
|
|
4088
|
+
}));
|
|
4089
|
+
return _getPublicKey.apply(this, arguments);
|
|
4090
|
+
}
|
|
4091
|
+
function getPrivateKey(_x2) {
|
|
4092
|
+
return _getPrivateKey.apply(this, arguments);
|
|
4093
|
+
}
|
|
4094
|
+
/**
|
|
4095
|
+
* delete acl if keydoc exists
|
|
4096
|
+
* create/edit keyDoc
|
|
4097
|
+
* set keyDoc acl
|
|
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;
|
|
4102
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
4103
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
4104
|
+
case 0:
|
|
4105
|
+
_context2.next = 2;
|
|
4106
|
+
return _solidLogic.store.fetcher.load(webId);
|
|
4107
|
+
case 2:
|
|
4108
|
+
_context2.next = 4;
|
|
4109
|
+
return (0, _accessData.pubKeyUrl)(webId);
|
|
4110
|
+
case 4:
|
|
4111
|
+
publicKeyDoc = _context2.sent;
|
|
4112
|
+
_context2.next = 7;
|
|
4113
|
+
return (0, _accessData.privKeyUrl)(webId);
|
|
4114
|
+
case 7:
|
|
4115
|
+
privateKeyDoc = _context2.sent;
|
|
4116
|
+
_context2.next = 10;
|
|
4117
|
+
return (0, _accessData.getExistingPublicKey)(webId, publicKeyDoc);
|
|
4118
|
+
case 10:
|
|
4119
|
+
publicKey = _context2.sent;
|
|
4120
|
+
_context2.next = 13;
|
|
4121
|
+
return (0, _accessData.getExistingPrivateKey)(webId, privateKeyDoc);
|
|
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 === null || webId === void 0 ? void 0 : webId.uri) + '\'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;
|
|
4068
4133
|
break;
|
|
4069
4134
|
}
|
|
4070
4135
|
del = [];
|
|
4071
|
-
add = [];
|
|
4072
|
-
if (privateKey)
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
add
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
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 (0, _acl.setAcl)(keyContainer, (0, _acl.keyContainerAclBody)(webId.uri));
|
|
4166
|
+
case 34:
|
|
4167
|
+
return _context2.abrupt("return", privateKey);
|
|
4168
|
+
case 35:
|
|
4083
4169
|
case "end":
|
|
4084
|
-
return
|
|
4170
|
+
return _context2.stop();
|
|
4085
4171
|
}
|
|
4086
|
-
},
|
|
4172
|
+
}, _callee2);
|
|
4087
4173
|
}));
|
|
4088
4174
|
return _getPrivateKey.apply(this, arguments);
|
|
4089
4175
|
}
|
|
4176
|
+
function saveKey(_x3, _x4, _x5) {
|
|
4177
|
+
return _saveKey.apply(this, arguments);
|
|
4178
|
+
}
|
|
4179
|
+
function _saveKey() {
|
|
4180
|
+
_saveKey = (0, _asyncToGenerator2["default"])(function (keyDoc, del, add) {
|
|
4181
|
+
var me = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
|
|
4182
|
+
return /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
4183
|
+
var keyAclDoc, response, aclBody;
|
|
4184
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
4185
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
4186
|
+
case 0:
|
|
4187
|
+
_context3.next = 2;
|
|
4188
|
+
return _solidLogic.store.fetcher.load(keyDoc);
|
|
4189
|
+
case 2:
|
|
4190
|
+
_context3.prev = 2;
|
|
4191
|
+
// get keyAcldoc
|
|
4192
|
+
keyAclDoc = _solidLogic.store.any(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl'));
|
|
4193
|
+
if (!keyAclDoc) {
|
|
4194
|
+
_context3.next = 17;
|
|
4195
|
+
break;
|
|
4196
|
+
}
|
|
4197
|
+
_context3.prev = 5;
|
|
4198
|
+
_context3.next = 8;
|
|
4199
|
+
return _solidLogic.store.fetcher.webOperation('DELETE', keyAclDoc.value);
|
|
4200
|
+
case 8:
|
|
4201
|
+
response = _context3.sent;
|
|
4202
|
+
// this may fail if webId is not an owner
|
|
4203
|
+
debug.log('delete ' + keyAclDoc.value + ' ' + response.status); // should test 404 and 2xx
|
|
4204
|
+
_context3.next = 17;
|
|
4205
|
+
break;
|
|
4206
|
+
case 12:
|
|
4207
|
+
_context3.prev = 12;
|
|
4208
|
+
_context3.t0 = _context3["catch"](5);
|
|
4209
|
+
if (!(_context3.t0.response.status !== 404)) {
|
|
4210
|
+
_context3.next = 16;
|
|
4211
|
+
break;
|
|
4212
|
+
}
|
|
4213
|
+
throw new Error(_context3.t0);
|
|
4214
|
+
case 16:
|
|
4215
|
+
debug.log('delete ' + keyAclDoc.value + ' ' + _context3.t0.response.status); // should test 404 and 2xx
|
|
4216
|
+
case 17:
|
|
4217
|
+
_context3.next = 19;
|
|
4218
|
+
return _solidLogic.store.updater.updateMany(del, add);
|
|
4219
|
+
case 19:
|
|
4220
|
+
// or a promise store.updater.update ?
|
|
4221
|
+
// create READ only ACL
|
|
4222
|
+
aclBody = (0, _acl.keyAclBody)(keyDoc, me);
|
|
4223
|
+
_context3.next = 22;
|
|
4224
|
+
return (0, _acl.setAcl)(keyDoc, aclBody);
|
|
4225
|
+
case 22:
|
|
4226
|
+
_context3.next = 27;
|
|
4227
|
+
break;
|
|
4228
|
+
case 24:
|
|
4229
|
+
_context3.prev = 24;
|
|
4230
|
+
_context3.t1 = _context3["catch"](2);
|
|
4231
|
+
throw new Error(_context3.t1);
|
|
4232
|
+
case 27:
|
|
4233
|
+
case "end":
|
|
4234
|
+
return _context3.stop();
|
|
4235
|
+
}
|
|
4236
|
+
}, _callee3, null, [[2, 24], [5, 12]]);
|
|
4237
|
+
})();
|
|
4238
|
+
});
|
|
4239
|
+
return _saveKey.apply(this, arguments);
|
|
4240
|
+
}
|
|
4090
4241
|
//# sourceMappingURL=keys.js.map
|
|
4091
4242
|
|
|
4092
4243
|
/***/ }),
|
|
@@ -4215,21 +4366,39 @@ function renderMessageRow(channelObject, message, fresh, options, userContext) {
|
|
|
4215
4366
|
var creator = _solidLogic.store.any(message, ns.foaf('maker'));
|
|
4216
4367
|
var date = _solidLogic.store.any(message, ns.dct('created'));
|
|
4217
4368
|
var latestVersion = (0, _chatLogic.mostRecentVersion)(message);
|
|
4218
|
-
var
|
|
4219
|
-
|
|
4369
|
+
var latestVersionCreator = _solidLogic.store.any(latestVersion, ns.foaf('maker'));
|
|
4370
|
+
|
|
4371
|
+
// use latest content if same owner, else use original
|
|
4372
|
+
var msgId = creator.uri === latestVersionCreator.uri ? latestVersion : message;
|
|
4373
|
+
var content = _solidLogic.store.any(msgId, ns.sioc('content'));
|
|
4374
|
+
var signature = _solidLogic.store.any(msgId, $rdf.sym("".concat(_signature.SEC, "Proof")));
|
|
4220
4375
|
|
|
4221
|
-
//
|
|
4376
|
+
// set message object
|
|
4222
4377
|
var msg = (0, _signature.getBlankMsg)();
|
|
4223
|
-
msg.id =
|
|
4224
|
-
msg.created =
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4378
|
+
msg.id = msgId.uri;
|
|
4379
|
+
msg.created = _solidLogic.store.any(msgId, ns.dct('created')).value;
|
|
4380
|
+
msg.content = content.value;
|
|
4381
|
+
msg.maker = creator.uri;
|
|
4382
|
+
|
|
4383
|
+
// unsigned message
|
|
4384
|
+
if (!(signature !== null && signature !== void 0 && signature.value)) debug.warn(msgId.uri + ' is unsigned'); // TODO replace with UI (colored message ?)
|
|
4385
|
+
|
|
4386
|
+
// signed message, get public key and check signature
|
|
4387
|
+
else {
|
|
4388
|
+
(0, _keys.getPublicKey)(creator).then(function (publicKey) {
|
|
4389
|
+
debug.log(creator.uri + '\n' + msg.created + '\n' + msg.id + '\n' + publicKey);
|
|
4390
|
+
if (!publicKey) {
|
|
4391
|
+
// TODO try to recreate the publicKey
|
|
4392
|
+
// if(me.uri === creator.uri) await getPrivateKey(creator)
|
|
4393
|
+
debug.warn('message is signed but ' + creator.uri + ' is missing publicKey');
|
|
4394
|
+
}
|
|
4395
|
+
// check that publicKey is a valid hex string
|
|
4396
|
+
var regex = /[0-9A-Fa-f]{6}/g;
|
|
4397
|
+
if (!(publicKey !== null && publicKey !== void 0 && publicKey.match(regex))) debug.warn('invalid publicKey hex string\n' + creator.uri + '\n' + publicKey);
|
|
4398
|
+
// verify signature
|
|
4399
|
+
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);
|
|
4400
|
+
});
|
|
4401
|
+
}
|
|
4233
4402
|
var originalMessage = (0, _chatLogic.originalVersion)(message);
|
|
4234
4403
|
var edited = !message.sameTerm(originalMessage);
|
|
4235
4404
|
var sortDate = _solidLogic.store.the(originalMessage, ns.dct('created'), null, originalMessage.doc()); // In message
|
|
@@ -5023,17 +5192,15 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
5023
5192
|
value: true
|
|
5024
5193
|
}));
|
|
5025
5194
|
exports.SEC = exports.CERT = void 0;
|
|
5026
|
-
exports.finishMsg = finishMsg;
|
|
5027
5195
|
exports.getBlankMsg = getBlankMsg;
|
|
5028
5196
|
exports.getMsgHash = getMsgHash;
|
|
5029
5197
|
exports.serializeMsg = serializeMsg;
|
|
5030
5198
|
exports.signMsg = signMsg;
|
|
5031
5199
|
exports.utf8Encoder = exports.utf8Decoder = void 0;
|
|
5032
|
-
exports.validateMsg = validateMsg;
|
|
5033
5200
|
exports.verifySignature = verifySignature;
|
|
5034
5201
|
var _secp256k = __webpack_require__(/*! @noble/curves/secp256k1 */ "./node_modules/@noble/curves/secp256k1.js");
|
|
5035
|
-
var _sha = __webpack_require__(/*! @noble/hashes/sha256 */ "./node_modules/@noble/hashes/sha256.js");
|
|
5036
5202
|
var _utils = __webpack_require__(/*! @noble/hashes/utils */ "./node_modules/@noble/hashes/utils.js");
|
|
5203
|
+
var _sha = __webpack_require__(/*! @noble/hashes/sha256 */ "./node_modules/@noble/hashes/sha256.js");
|
|
5037
5204
|
// import {utf8Encoder} from './utils'
|
|
5038
5205
|
// import { getPublicKey } from './keys'
|
|
5039
5206
|
|
|
@@ -5043,7 +5210,7 @@ var utf8Encoder = new TextEncoder();
|
|
|
5043
5210
|
exports.utf8Encoder = utf8Encoder;
|
|
5044
5211
|
var SEC = 'https://w3id.org/security#'; // Proof, VerificationMethod
|
|
5045
5212
|
exports.SEC = SEC;
|
|
5046
|
-
var CERT = 'http://www.w3.org/ns/auth/cert#'; //
|
|
5213
|
+
var CERT = 'http://www.w3.org/ns/auth/cert#'; // PrivateKey, PublicKey
|
|
5047
5214
|
|
|
5048
5215
|
/* eslint-disable no-unused-vars */
|
|
5049
5216
|
/* export enum Kind {
|
|
@@ -5075,19 +5242,22 @@ function getBlankMsg() {
|
|
|
5075
5242
|
id: '',
|
|
5076
5243
|
created: '',
|
|
5077
5244
|
dateDeleted: '',
|
|
5245
|
+
// TODO to remove if not used
|
|
5078
5246
|
content: '',
|
|
5079
5247
|
maker: '',
|
|
5080
|
-
sig: ''
|
|
5248
|
+
sig: '' // TODO to remove if not used
|
|
5081
5249
|
};
|
|
5082
5250
|
}
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
message.
|
|
5088
|
-
message.
|
|
5089
|
-
|
|
5090
|
-
|
|
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
|
+
|
|
5091
5261
|
function serializeMsg(msg) {
|
|
5092
5262
|
// to update to chat messages triples
|
|
5093
5263
|
/* if (!validateMsg(msg))
|
|
@@ -5099,27 +5269,29 @@ function getMsgHash(message) {
|
|
|
5099
5269
|
var msgHash = (0, _sha.sha256)(utf8Encoder.encode(serializeMsg(message)));
|
|
5100
5270
|
return (0, _utils.bytesToHex)(msgHash);
|
|
5101
5271
|
}
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
function validateMsg(message) {
|
|
5106
|
-
|
|
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
|
|
5107
5277
|
if (typeof message.kind !== 'number') return false
|
|
5108
5278
|
if (typeof message.content !== 'string') return false
|
|
5109
5279
|
if (typeof message.created_at !== 'number') return false
|
|
5110
5280
|
if (typeof message.pubkey !== 'string') return false
|
|
5111
5281
|
if (!message.pubkey.match(/^[a-f0-9]{64}$/)) return false
|
|
5112
|
-
|
|
5282
|
+
|
|
5283
|
+
if (!Array.isArray(message.tags)) return false
|
|
5113
5284
|
for (let i = 0; i < message.tags.length; i++) {
|
|
5114
5285
|
let tag = message.tags[i]
|
|
5115
5286
|
if (!Array.isArray(tag)) return false
|
|
5116
5287
|
for (let j = 0; j < tag.length; j++) {
|
|
5117
5288
|
if (typeof tag[j] === 'object') return false
|
|
5118
5289
|
}
|
|
5119
|
-
}
|
|
5290
|
+
}
|
|
5291
|
+
|
|
5292
|
+
return true
|
|
5293
|
+
} */
|
|
5120
5294
|
|
|
5121
|
-
return true;
|
|
5122
|
-
}
|
|
5123
5295
|
function verifySignature(sig, message, pubKey) {
|
|
5124
5296
|
return _secp256k.schnorr.verify(sig, getMsgHash(message), pubKey);
|
|
5125
5297
|
}
|
|
@@ -13048,6 +13220,353 @@ function predParentOf(node) {
|
|
|
13048
13220
|
|
|
13049
13221
|
/***/ }),
|
|
13050
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
|
+
|
|
13051
13570
|
/***/ "./lib/utils/label.js":
|
|
13052
13571
|
/*!****************************!*\
|
|
13053
13572
|
!*** ./lib/utils/label.js ***!
|
|
@@ -13176,8 +13695,8 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
13176
13695
|
}));
|
|
13177
13696
|
exports.versionInfo = void 0;
|
|
13178
13697
|
var versionInfo = {
|
|
13179
|
-
buildTime: '2023-
|
|
13180
|
-
commit: '
|
|
13698
|
+
buildTime: '2023-05-10T18:38:16Z',
|
|
13699
|
+
commit: '77f914e3e4b885876fd4618e7374fd020da07cd1',
|
|
13181
13700
|
npmInfo: {
|
|
13182
13701
|
'solid-ui': '2.4.27',
|
|
13183
13702
|
npm: '8.19.4',
|
|
@@ -25340,6 +25859,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
25340
25859
|
/* harmony import */ var _inrupt_oidc_client__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @inrupt/oidc-client */ "./node_modules/@inrupt/oidc-client/lib/oidc-client.min.js");
|
|
25341
25860
|
/* harmony import */ var _inrupt_oidc_client__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_inrupt_oidc_client__WEBPACK_IMPORTED_MODULE_0__);
|
|
25342
25861
|
/* harmony import */ var _inrupt_solid_client_authn_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @inrupt/solid-client-authn-core */ "./node_modules/@inrupt/solid-client-authn-core/dist/index.mjs");
|
|
25862
|
+
/* harmony import */ var _inrupt_universal_fetch__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @inrupt/universal-fetch */ "./node_modules/@inrupt/universal-fetch/dist/index-browser.mjs");
|
|
25863
|
+
|
|
25343
25864
|
|
|
25344
25865
|
|
|
25345
25866
|
|
|
@@ -25493,7 +26014,7 @@ async function getTokens(issuer, client, data, dpop) {
|
|
|
25493
26014
|
headers,
|
|
25494
26015
|
body: new URLSearchParams(requestBody).toString(),
|
|
25495
26016
|
};
|
|
25496
|
-
const rawTokenResponse = await
|
|
26017
|
+
const rawTokenResponse = await (0,_inrupt_universal_fetch__WEBPACK_IMPORTED_MODULE_2__.fetch)(issuer.tokenEndpoint, tokenRequestInit);
|
|
25497
26018
|
const jsonTokenResponse = (await rawTokenResponse.json());
|
|
25498
26019
|
const tokenResponse = validateTokenEndpointResponse(jsonTokenResponse, dpop);
|
|
25499
26020
|
const webId = await (0,_inrupt_solid_client_authn_core__WEBPACK_IMPORTED_MODULE_1__.getWebidFromTokenPayload)(tokenResponse.id_token, issuer.jwksUri, issuer.issuer, client.clientId);
|
|
@@ -25577,7 +26098,7 @@ async function refresh(refreshToken, issuer, client, dpopKey) {
|
|
|
25577
26098
|
else if (isValidUrl(client.clientId)) {
|
|
25578
26099
|
requestBody.client_id = client.clientId;
|
|
25579
26100
|
}
|
|
25580
|
-
const rawResponse = await fetch(issuer.tokenEndpoint, {
|
|
26101
|
+
const rawResponse = await (0,_inrupt_universal_fetch__WEBPACK_IMPORTED_MODULE_2__.fetch)(issuer.tokenEndpoint, {
|
|
25581
26102
|
method: "POST",
|
|
25582
26103
|
body: new URLSearchParams(requestBody).toString(),
|
|
25583
26104
|
headers: {
|
|
@@ -25692,8 +26213,9 @@ e.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,c=u>>1,h=-7,l=r?i-1:0,f=
|
|
|
25692
26213
|
|
|
25693
26214
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
25694
26215
|
const solid_client_authn_core_1 = __webpack_require__(/*! @inrupt/solid-client-authn-core */ "./node_modules/@inrupt/solid-client-authn-core/dist/index.js");
|
|
26216
|
+
const universal_fetch_1 = __webpack_require__(/*! @inrupt/universal-fetch */ "./node_modules/@inrupt/universal-fetch/dist/index-browser.js");
|
|
25695
26217
|
const oidc_client_ext_1 = __webpack_require__(/*! @inrupt/oidc-client-ext */ "./node_modules/@inrupt/oidc-client-ext/dist/index.es.js");
|
|
25696
|
-
const globalFetch = (request, init) =>
|
|
26218
|
+
const globalFetch = (request, init) => (0, universal_fetch_1.fetch)(request, init);
|
|
25697
26219
|
class ClientAuthentication {
|
|
25698
26220
|
constructor(loginHandler, redirectHandler, logoutHandler, sessionInfoManager, issuerConfigFetcher) {
|
|
25699
26221
|
this.loginHandler = loginHandler;
|
|
@@ -26187,6 +26709,7 @@ exports["default"] = ClientRegistrar;
|
|
|
26187
26709
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
26188
26710
|
exports.WELL_KNOWN_OPENID_CONFIG = void 0;
|
|
26189
26711
|
const solid_client_authn_core_1 = __webpack_require__(/*! @inrupt/solid-client-authn-core */ "./node_modules/@inrupt/solid-client-authn-core/dist/index.js");
|
|
26712
|
+
const universal_fetch_1 = __webpack_require__(/*! @inrupt/universal-fetch */ "./node_modules/@inrupt/universal-fetch/dist/index-browser.js");
|
|
26190
26713
|
exports.WELL_KNOWN_OPENID_CONFIG = ".well-known/openid-configuration";
|
|
26191
26714
|
const issuerConfigKeyMap = {
|
|
26192
26715
|
issuer: {
|
|
@@ -26293,7 +26816,7 @@ class IssuerConfigFetcher {
|
|
|
26293
26816
|
async fetchConfig(issuer) {
|
|
26294
26817
|
let issuerConfig;
|
|
26295
26818
|
const openIdConfigUrl = new URL(exports.WELL_KNOWN_OPENID_CONFIG, issuer.endsWith("/") ? issuer : `${issuer}/`).href;
|
|
26296
|
-
const issuerConfigRequestBody = await
|
|
26819
|
+
const issuerConfigRequestBody = await (0, universal_fetch_1.fetch)(openIdConfigUrl);
|
|
26297
26820
|
try {
|
|
26298
26821
|
issuerConfig = processConfig(await issuerConfigRequestBody.json());
|
|
26299
26822
|
}
|
|
@@ -26396,6 +26919,7 @@ exports["default"] = Redirector;
|
|
|
26396
26919
|
|
|
26397
26920
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
26398
26921
|
exports.AuthCodeRedirectHandler = void 0;
|
|
26922
|
+
const universal_fetch_1 = __webpack_require__(/*! @inrupt/universal-fetch */ "./node_modules/@inrupt/universal-fetch/dist/index-browser.js");
|
|
26399
26923
|
const solid_client_authn_core_1 = __webpack_require__(/*! @inrupt/solid-client-authn-core */ "./node_modules/@inrupt/solid-client-authn-core/dist/index.js");
|
|
26400
26924
|
const oidc_client_ext_1 = __webpack_require__(/*! @inrupt/oidc-client-ext */ "./node_modules/@inrupt/oidc-client-ext/dist/index.es.js");
|
|
26401
26925
|
class AuthCodeRedirectHandler {
|
|
@@ -26459,7 +26983,7 @@ class AuthCodeRedirectHandler {
|
|
|
26459
26983
|
tokenRefresher: this.tokerRefresher,
|
|
26460
26984
|
};
|
|
26461
26985
|
}
|
|
26462
|
-
const authFetch = await (0, solid_client_authn_core_1.buildAuthenticatedFetch)(fetch, tokens.accessToken, {
|
|
26986
|
+
const authFetch = await (0, solid_client_authn_core_1.buildAuthenticatedFetch)(universal_fetch_1.fetch, tokens.accessToken, {
|
|
26463
26987
|
dpopKey: tokens.dpopKey,
|
|
26464
26988
|
refreshOptions,
|
|
26465
26989
|
eventEmitter,
|
|
@@ -26697,11 +27221,12 @@ exports.SessionInfoManager = exports.clear = exports.getUnauthenticatedSession =
|
|
|
26697
27221
|
const solid_client_authn_core_1 = __webpack_require__(/*! @inrupt/solid-client-authn-core */ "./node_modules/@inrupt/solid-client-authn-core/dist/index.js");
|
|
26698
27222
|
const uuid_1 = __webpack_require__(/*! uuid */ "./node_modules/@inrupt/solid-client-authn-browser/node_modules/uuid/dist/commonjs-browser/index.js");
|
|
26699
27223
|
const oidc_client_ext_1 = __webpack_require__(/*! @inrupt/oidc-client-ext */ "./node_modules/@inrupt/oidc-client-ext/dist/index.es.js");
|
|
27224
|
+
const universal_fetch_1 = __webpack_require__(/*! @inrupt/universal-fetch */ "./node_modules/@inrupt/universal-fetch/dist/index-browser.js");
|
|
26700
27225
|
function getUnauthenticatedSession() {
|
|
26701
27226
|
return {
|
|
26702
27227
|
isLoggedIn: false,
|
|
26703
27228
|
sessionId: (0, uuid_1.v4)(),
|
|
26704
|
-
fetch,
|
|
27229
|
+
fetch: universal_fetch_1.fetch,
|
|
26705
27230
|
};
|
|
26706
27231
|
}
|
|
26707
27232
|
exports.getUnauthenticatedSession = getUnauthenticatedSession;
|
|
@@ -27854,513 +28379,513 @@ exports["default"] = _default;
|
|
|
27854
28379
|
|
|
27855
28380
|
|
|
27856
28381
|
var events = __webpack_require__(/*! events */ "./node_modules/events/events.js");
|
|
27857
|
-
var
|
|
28382
|
+
var universalFetch = __webpack_require__(/*! @inrupt/universal-fetch */ "./node_modules/@inrupt/universal-fetch/dist/index-browser.js");
|
|
27858
28383
|
var jose = __webpack_require__(/*! jose */ "./node_modules/jose/dist/browser/index.js");
|
|
27859
28384
|
var uuid = __webpack_require__(/*! uuid */ "./node_modules/@inrupt/solid-client-authn-core/node_modules/uuid/dist/commonjs-browser/index.js");
|
|
27860
28385
|
|
|
27861
|
-
const SOLID_CLIENT_AUTHN_KEY_PREFIX = "solidClientAuthn:";
|
|
27862
|
-
const PREFERRED_SIGNING_ALG = ["ES256", "RS256"];
|
|
27863
|
-
const EVENTS = {
|
|
27864
|
-
ERROR: "error",
|
|
27865
|
-
LOGIN: "login",
|
|
27866
|
-
LOGOUT: "logout",
|
|
27867
|
-
NEW_REFRESH_TOKEN: "newRefreshToken",
|
|
27868
|
-
SESSION_EXPIRED: "sessionExpired",
|
|
27869
|
-
SESSION_EXTENDED: "sessionExtended",
|
|
27870
|
-
SESSION_RESTORED: "sessionRestore",
|
|
27871
|
-
TIMEOUT_SET: "timeoutSet",
|
|
27872
|
-
};
|
|
27873
|
-
const REFRESH_BEFORE_EXPIRATION_SECONDS = 5;
|
|
27874
|
-
const SCOPE_OPENID = "openid";
|
|
27875
|
-
const SCOPE_OFFLINE = "offline_access";
|
|
27876
|
-
const SCOPE_WEBID = "webid";
|
|
28386
|
+
const SOLID_CLIENT_AUTHN_KEY_PREFIX = "solidClientAuthn:";
|
|
28387
|
+
const PREFERRED_SIGNING_ALG = ["ES256", "RS256"];
|
|
28388
|
+
const EVENTS = {
|
|
28389
|
+
ERROR: "error",
|
|
28390
|
+
LOGIN: "login",
|
|
28391
|
+
LOGOUT: "logout",
|
|
28392
|
+
NEW_REFRESH_TOKEN: "newRefreshToken",
|
|
28393
|
+
SESSION_EXPIRED: "sessionExpired",
|
|
28394
|
+
SESSION_EXTENDED: "sessionExtended",
|
|
28395
|
+
SESSION_RESTORED: "sessionRestore",
|
|
28396
|
+
TIMEOUT_SET: "timeoutSet",
|
|
28397
|
+
};
|
|
28398
|
+
const REFRESH_BEFORE_EXPIRATION_SECONDS = 5;
|
|
28399
|
+
const SCOPE_OPENID = "openid";
|
|
28400
|
+
const SCOPE_OFFLINE = "offline_access";
|
|
28401
|
+
const SCOPE_WEBID = "webid";
|
|
27877
28402
|
const DEFAULT_SCOPES = [SCOPE_OPENID, SCOPE_OFFLINE, SCOPE_WEBID].join(" ");
|
|
27878
28403
|
|
|
27879
|
-
const buildProxyHandler = (toExclude, errorMessage) => ({
|
|
27880
|
-
get(target, prop, receiver) {
|
|
27881
|
-
if (!Object.getOwnPropertyNames(events.EventEmitter).includes(prop) &&
|
|
27882
|
-
Object.getOwnPropertyNames(toExclude).includes(prop)) {
|
|
27883
|
-
throw new Error(`${errorMessage}: [${prop}] is not supported`);
|
|
27884
|
-
}
|
|
27885
|
-
return Reflect.get(target, prop, receiver);
|
|
27886
|
-
},
|
|
28404
|
+
const buildProxyHandler = (toExclude, errorMessage) => ({
|
|
28405
|
+
get(target, prop, receiver) {
|
|
28406
|
+
if (!Object.getOwnPropertyNames(events.EventEmitter).includes(prop) &&
|
|
28407
|
+
Object.getOwnPropertyNames(toExclude).includes(prop)) {
|
|
28408
|
+
throw new Error(`${errorMessage}: [${prop}] is not supported`);
|
|
28409
|
+
}
|
|
28410
|
+
return Reflect.get(target, prop, receiver);
|
|
28411
|
+
},
|
|
27887
28412
|
});
|
|
27888
28413
|
|
|
27889
|
-
class AggregateHandler {
|
|
27890
|
-
constructor(handleables) {
|
|
27891
|
-
this.handleables = handleables;
|
|
27892
|
-
}
|
|
27893
|
-
async getProperHandler(params) {
|
|
27894
|
-
const canHandleList = await Promise.all(this.handleables.map((handleable) => handleable.canHandle(...params)));
|
|
27895
|
-
for (let i = 0; i < canHandleList.length; i += 1) {
|
|
27896
|
-
if (canHandleList[i]) {
|
|
27897
|
-
return this.handleables[i];
|
|
27898
|
-
}
|
|
27899
|
-
}
|
|
27900
|
-
return null;
|
|
27901
|
-
}
|
|
27902
|
-
async canHandle(...params) {
|
|
27903
|
-
return (await this.getProperHandler(params)) !== null;
|
|
27904
|
-
}
|
|
27905
|
-
async handle(...params) {
|
|
27906
|
-
const handler = await this.getProperHandler(params);
|
|
27907
|
-
if (handler) {
|
|
27908
|
-
return handler.handle(...params);
|
|
27909
|
-
}
|
|
27910
|
-
throw new Error(`[${this.constructor.name}] cannot find a suitable handler for: ${params
|
|
27911
|
-
.map((param) => {
|
|
27912
|
-
try {
|
|
27913
|
-
return JSON.stringify(param);
|
|
27914
|
-
}
|
|
27915
|
-
catch (err) {
|
|
27916
|
-
return param.toString();
|
|
27917
|
-
}
|
|
27918
|
-
})
|
|
27919
|
-
.join(", ")}`);
|
|
27920
|
-
}
|
|
28414
|
+
class AggregateHandler {
|
|
28415
|
+
constructor(handleables) {
|
|
28416
|
+
this.handleables = handleables;
|
|
28417
|
+
}
|
|
28418
|
+
async getProperHandler(params) {
|
|
28419
|
+
const canHandleList = await Promise.all(this.handleables.map((handleable) => handleable.canHandle(...params)));
|
|
28420
|
+
for (let i = 0; i < canHandleList.length; i += 1) {
|
|
28421
|
+
if (canHandleList[i]) {
|
|
28422
|
+
return this.handleables[i];
|
|
28423
|
+
}
|
|
28424
|
+
}
|
|
28425
|
+
return null;
|
|
28426
|
+
}
|
|
28427
|
+
async canHandle(...params) {
|
|
28428
|
+
return (await this.getProperHandler(params)) !== null;
|
|
28429
|
+
}
|
|
28430
|
+
async handle(...params) {
|
|
28431
|
+
const handler = await this.getProperHandler(params);
|
|
28432
|
+
if (handler) {
|
|
28433
|
+
return handler.handle(...params);
|
|
28434
|
+
}
|
|
28435
|
+
throw new Error(`[${this.constructor.name}] cannot find a suitable handler for: ${params
|
|
28436
|
+
.map((param) => {
|
|
28437
|
+
try {
|
|
28438
|
+
return JSON.stringify(param);
|
|
28439
|
+
}
|
|
28440
|
+
catch (err) {
|
|
28441
|
+
return param.toString();
|
|
28442
|
+
}
|
|
28443
|
+
})
|
|
28444
|
+
.join(", ")}`);
|
|
28445
|
+
}
|
|
27921
28446
|
}
|
|
27922
28447
|
|
|
27923
|
-
async function fetchJwks(jwksIri, issuerIri) {
|
|
27924
|
-
const jwksResponse = await
|
|
27925
|
-
if (jwksResponse.status !== 200) {
|
|
27926
|
-
throw new Error(`Could not fetch JWKS for [${issuerIri}] at [${jwksIri}]: ${jwksResponse.status} ${jwksResponse.statusText}`);
|
|
27927
|
-
}
|
|
27928
|
-
let jwk;
|
|
27929
|
-
try {
|
|
27930
|
-
jwk = (await jwksResponse.json()).keys[0];
|
|
27931
|
-
}
|
|
27932
|
-
catch (e) {
|
|
27933
|
-
throw new Error(`Malformed JWKS for [${issuerIri}] at [${jwksIri}]: ${e.message}`);
|
|
27934
|
-
}
|
|
27935
|
-
return jwk;
|
|
27936
|
-
}
|
|
27937
|
-
async function getWebidFromTokenPayload(idToken, jwksIri, issuerIri, clientId) {
|
|
27938
|
-
const jwk = await fetchJwks(jwksIri, issuerIri);
|
|
27939
|
-
let payload;
|
|
27940
|
-
try {
|
|
27941
|
-
const { payload: verifiedPayload } = await jose.jwtVerify(idToken, await jose.importJWK(jwk), {
|
|
27942
|
-
issuer: issuerIri,
|
|
27943
|
-
audience: clientId,
|
|
27944
|
-
});
|
|
27945
|
-
payload = verifiedPayload;
|
|
27946
|
-
}
|
|
27947
|
-
catch (e) {
|
|
27948
|
-
throw new Error(`Token verification failed: ${e.stack}`);
|
|
27949
|
-
}
|
|
27950
|
-
if (typeof payload.webid === "string") {
|
|
27951
|
-
return payload.webid;
|
|
27952
|
-
}
|
|
27953
|
-
if (typeof payload.sub !== "string") {
|
|
27954
|
-
throw new Error(`The token ${JSON.stringify(payload)} is invalid: it has no 'webid' claim and no 'sub' claim.`);
|
|
27955
|
-
}
|
|
27956
|
-
try {
|
|
27957
|
-
new URL(payload.sub);
|
|
27958
|
-
return payload.sub;
|
|
27959
|
-
}
|
|
27960
|
-
catch (e) {
|
|
27961
|
-
throw new Error(`The token has no 'webid' claim, and its 'sub' claim of [${payload.sub}] is invalid as a URL - error [${e}].`);
|
|
27962
|
-
}
|
|
28448
|
+
async function fetchJwks(jwksIri, issuerIri) {
|
|
28449
|
+
const jwksResponse = await universalFetch.fetch(jwksIri);
|
|
28450
|
+
if (jwksResponse.status !== 200) {
|
|
28451
|
+
throw new Error(`Could not fetch JWKS for [${issuerIri}] at [${jwksIri}]: ${jwksResponse.status} ${jwksResponse.statusText}`);
|
|
28452
|
+
}
|
|
28453
|
+
let jwk;
|
|
28454
|
+
try {
|
|
28455
|
+
jwk = (await jwksResponse.json()).keys[0];
|
|
28456
|
+
}
|
|
28457
|
+
catch (e) {
|
|
28458
|
+
throw new Error(`Malformed JWKS for [${issuerIri}] at [${jwksIri}]: ${e.message}`);
|
|
28459
|
+
}
|
|
28460
|
+
return jwk;
|
|
28461
|
+
}
|
|
28462
|
+
async function getWebidFromTokenPayload(idToken, jwksIri, issuerIri, clientId) {
|
|
28463
|
+
const jwk = await fetchJwks(jwksIri, issuerIri);
|
|
28464
|
+
let payload;
|
|
28465
|
+
try {
|
|
28466
|
+
const { payload: verifiedPayload } = await jose.jwtVerify(idToken, await jose.importJWK(jwk), {
|
|
28467
|
+
issuer: issuerIri,
|
|
28468
|
+
audience: clientId,
|
|
28469
|
+
});
|
|
28470
|
+
payload = verifiedPayload;
|
|
28471
|
+
}
|
|
28472
|
+
catch (e) {
|
|
28473
|
+
throw new Error(`Token verification failed: ${e.stack}`);
|
|
28474
|
+
}
|
|
28475
|
+
if (typeof payload.webid === "string") {
|
|
28476
|
+
return payload.webid;
|
|
28477
|
+
}
|
|
28478
|
+
if (typeof payload.sub !== "string") {
|
|
28479
|
+
throw new Error(`The token ${JSON.stringify(payload)} is invalid: it has no 'webid' claim and no 'sub' claim.`);
|
|
28480
|
+
}
|
|
28481
|
+
try {
|
|
28482
|
+
new URL(payload.sub);
|
|
28483
|
+
return payload.sub;
|
|
28484
|
+
}
|
|
28485
|
+
catch (e) {
|
|
28486
|
+
throw new Error(`The token has no 'webid' claim, and its 'sub' claim of [${payload.sub}] is invalid as a URL - error [${e}].`);
|
|
28487
|
+
}
|
|
27963
28488
|
}
|
|
27964
28489
|
|
|
27965
|
-
function isValidRedirectUrl(redirectUrl) {
|
|
27966
|
-
try {
|
|
27967
|
-
const urlObject = new URL(redirectUrl);
|
|
27968
|
-
return urlObject.hash === "";
|
|
27969
|
-
}
|
|
27970
|
-
catch (e) {
|
|
27971
|
-
return false;
|
|
27972
|
-
}
|
|
28490
|
+
function isValidRedirectUrl(redirectUrl) {
|
|
28491
|
+
try {
|
|
28492
|
+
const urlObject = new URL(redirectUrl);
|
|
28493
|
+
return urlObject.hash === "";
|
|
28494
|
+
}
|
|
28495
|
+
catch (e) {
|
|
28496
|
+
return false;
|
|
28497
|
+
}
|
|
27973
28498
|
}
|
|
27974
28499
|
|
|
27975
|
-
function isSupportedTokenType(token) {
|
|
27976
|
-
return typeof token === "string" && ["DPoP", "Bearer"].includes(token);
|
|
28500
|
+
function isSupportedTokenType(token) {
|
|
28501
|
+
return typeof token === "string" && ["DPoP", "Bearer"].includes(token);
|
|
27977
28502
|
}
|
|
27978
28503
|
|
|
27979
28504
|
const USER_SESSION_PREFIX = "solidClientAuthenticationUser";
|
|
27980
28505
|
|
|
27981
|
-
function isValidUrl(url) {
|
|
27982
|
-
try {
|
|
27983
|
-
new URL(url);
|
|
27984
|
-
return true;
|
|
27985
|
-
}
|
|
27986
|
-
catch (_a) {
|
|
27987
|
-
return false;
|
|
27988
|
-
}
|
|
27989
|
-
}
|
|
27990
|
-
function determineSigningAlg(supported, preferred) {
|
|
27991
|
-
var _a;
|
|
27992
|
-
return ((_a = preferred.find((signingAlg) => {
|
|
27993
|
-
return supported.includes(signingAlg);
|
|
27994
|
-
})) !== null && _a !== void 0 ? _a : null);
|
|
27995
|
-
}
|
|
27996
|
-
function determineClientType(options, issuerConfig) {
|
|
27997
|
-
if (options.clientId !== undefined && !isValidUrl(options.clientId)) {
|
|
27998
|
-
return "static";
|
|
27999
|
-
}
|
|
28000
|
-
if (issuerConfig.scopesSupported.includes("webid") &&
|
|
28001
|
-
options.clientId !== undefined &&
|
|
28002
|
-
isValidUrl(options.clientId)) {
|
|
28003
|
-
return "solid-oidc";
|
|
28004
|
-
}
|
|
28005
|
-
return "dynamic";
|
|
28006
|
-
}
|
|
28007
|
-
async function handleRegistration(options, issuerConfig, storageUtility, clientRegistrar) {
|
|
28008
|
-
const clientType = determineClientType(options, issuerConfig);
|
|
28009
|
-
if (clientType === "dynamic") {
|
|
28010
|
-
return clientRegistrar.getClient({
|
|
28011
|
-
sessionId: options.sessionId,
|
|
28012
|
-
clientName: options.clientName,
|
|
28013
|
-
redirectUrl: options.redirectUrl,
|
|
28014
|
-
}, issuerConfig);
|
|
28015
|
-
}
|
|
28016
|
-
await storageUtility.setForUser(options.sessionId, {
|
|
28017
|
-
clientId: options.clientId,
|
|
28018
|
-
});
|
|
28019
|
-
if (options.clientSecret) {
|
|
28020
|
-
await storageUtility.setForUser(options.sessionId, {
|
|
28021
|
-
clientSecret: options.clientSecret,
|
|
28022
|
-
});
|
|
28023
|
-
}
|
|
28024
|
-
if (options.clientName) {
|
|
28025
|
-
await storageUtility.setForUser(options.sessionId, {
|
|
28026
|
-
clientName: options.clientName,
|
|
28027
|
-
});
|
|
28028
|
-
}
|
|
28029
|
-
return {
|
|
28030
|
-
clientId: options.clientId,
|
|
28031
|
-
clientSecret: options.clientSecret,
|
|
28032
|
-
clientName: options.clientName,
|
|
28033
|
-
clientType,
|
|
28034
|
-
};
|
|
28506
|
+
function isValidUrl(url) {
|
|
28507
|
+
try {
|
|
28508
|
+
new URL(url);
|
|
28509
|
+
return true;
|
|
28510
|
+
}
|
|
28511
|
+
catch (_a) {
|
|
28512
|
+
return false;
|
|
28513
|
+
}
|
|
28514
|
+
}
|
|
28515
|
+
function determineSigningAlg(supported, preferred) {
|
|
28516
|
+
var _a;
|
|
28517
|
+
return ((_a = preferred.find((signingAlg) => {
|
|
28518
|
+
return supported.includes(signingAlg);
|
|
28519
|
+
})) !== null && _a !== void 0 ? _a : null);
|
|
28520
|
+
}
|
|
28521
|
+
function determineClientType(options, issuerConfig) {
|
|
28522
|
+
if (options.clientId !== undefined && !isValidUrl(options.clientId)) {
|
|
28523
|
+
return "static";
|
|
28524
|
+
}
|
|
28525
|
+
if (issuerConfig.scopesSupported.includes("webid") &&
|
|
28526
|
+
options.clientId !== undefined &&
|
|
28527
|
+
isValidUrl(options.clientId)) {
|
|
28528
|
+
return "solid-oidc";
|
|
28529
|
+
}
|
|
28530
|
+
return "dynamic";
|
|
28531
|
+
}
|
|
28532
|
+
async function handleRegistration(options, issuerConfig, storageUtility, clientRegistrar) {
|
|
28533
|
+
const clientType = determineClientType(options, issuerConfig);
|
|
28534
|
+
if (clientType === "dynamic") {
|
|
28535
|
+
return clientRegistrar.getClient({
|
|
28536
|
+
sessionId: options.sessionId,
|
|
28537
|
+
clientName: options.clientName,
|
|
28538
|
+
redirectUrl: options.redirectUrl,
|
|
28539
|
+
}, issuerConfig);
|
|
28540
|
+
}
|
|
28541
|
+
await storageUtility.setForUser(options.sessionId, {
|
|
28542
|
+
clientId: options.clientId,
|
|
28543
|
+
});
|
|
28544
|
+
if (options.clientSecret) {
|
|
28545
|
+
await storageUtility.setForUser(options.sessionId, {
|
|
28546
|
+
clientSecret: options.clientSecret,
|
|
28547
|
+
});
|
|
28548
|
+
}
|
|
28549
|
+
if (options.clientName) {
|
|
28550
|
+
await storageUtility.setForUser(options.sessionId, {
|
|
28551
|
+
clientName: options.clientName,
|
|
28552
|
+
});
|
|
28553
|
+
}
|
|
28554
|
+
return {
|
|
28555
|
+
clientId: options.clientId,
|
|
28556
|
+
clientSecret: options.clientSecret,
|
|
28557
|
+
clientName: options.clientName,
|
|
28558
|
+
clientType,
|
|
28559
|
+
};
|
|
28035
28560
|
}
|
|
28036
28561
|
|
|
28037
|
-
async function getSessionIdFromOauthState(storageUtility, oauthState) {
|
|
28038
|
-
return storageUtility.getForUser(oauthState, "sessionId");
|
|
28039
|
-
}
|
|
28040
|
-
async function loadOidcContextFromStorage(sessionId, storageUtility, configFetcher) {
|
|
28041
|
-
try {
|
|
28042
|
-
const [issuerIri, codeVerifier, storedRedirectIri, dpop] = await Promise.all([
|
|
28043
|
-
storageUtility.getForUser(sessionId, "issuer", {
|
|
28044
|
-
errorIfNull: true,
|
|
28045
|
-
}),
|
|
28046
|
-
storageUtility.getForUser(sessionId, "codeVerifier"),
|
|
28047
|
-
storageUtility.getForUser(sessionId, "redirectUrl"),
|
|
28048
|
-
storageUtility.getForUser(sessionId, "dpop", { errorIfNull: true }),
|
|
28049
|
-
]);
|
|
28050
|
-
await storageUtility.deleteForUser(sessionId, "codeVerifier");
|
|
28051
|
-
const issuerConfig = await configFetcher.fetchConfig(issuerIri);
|
|
28052
|
-
return {
|
|
28053
|
-
codeVerifier,
|
|
28054
|
-
redirectUrl: storedRedirectIri,
|
|
28055
|
-
issuerConfig,
|
|
28056
|
-
dpop: dpop === "true",
|
|
28057
|
-
};
|
|
28058
|
-
}
|
|
28059
|
-
catch (e) {
|
|
28060
|
-
throw new Error(`Failed to retrieve OIDC context from storage associated with session [${sessionId}]: ${e}`);
|
|
28061
|
-
}
|
|
28062
|
-
}
|
|
28063
|
-
async function saveSessionInfoToStorage(storageUtility, sessionId, webId, isLoggedIn, refreshToken, secure, dpopKey) {
|
|
28064
|
-
if (refreshToken !== undefined) {
|
|
28065
|
-
await storageUtility.setForUser(sessionId, { refreshToken }, { secure });
|
|
28066
|
-
}
|
|
28067
|
-
if (webId !== undefined) {
|
|
28068
|
-
await storageUtility.setForUser(sessionId, { webId }, { secure });
|
|
28069
|
-
}
|
|
28070
|
-
if (isLoggedIn !== undefined) {
|
|
28071
|
-
await storageUtility.setForUser(sessionId, { isLoggedIn }, { secure });
|
|
28072
|
-
}
|
|
28073
|
-
if (dpopKey !== undefined) {
|
|
28074
|
-
await storageUtility.setForUser(sessionId, {
|
|
28075
|
-
publicKey: JSON.stringify(dpopKey.publicKey),
|
|
28076
|
-
privateKey: JSON.stringify(await jose.exportJWK(dpopKey.privateKey)),
|
|
28077
|
-
}, { secure });
|
|
28078
|
-
}
|
|
28079
|
-
}
|
|
28080
|
-
class StorageUtility {
|
|
28081
|
-
constructor(secureStorage, insecureStorage) {
|
|
28082
|
-
this.secureStorage = secureStorage;
|
|
28083
|
-
this.insecureStorage = insecureStorage;
|
|
28084
|
-
}
|
|
28085
|
-
getKey(userId) {
|
|
28086
|
-
return `solidClientAuthenticationUser:${userId}`;
|
|
28087
|
-
}
|
|
28088
|
-
async getUserData(userId, secure) {
|
|
28089
|
-
const stored = await (secure
|
|
28090
|
-
? this.secureStorage
|
|
28091
|
-
: this.insecureStorage).get(this.getKey(userId));
|
|
28092
|
-
if (stored === undefined) {
|
|
28093
|
-
return {};
|
|
28094
|
-
}
|
|
28095
|
-
try {
|
|
28096
|
-
return JSON.parse(stored);
|
|
28097
|
-
}
|
|
28098
|
-
catch (err) {
|
|
28099
|
-
throw new Error(`Data for user [${userId}] in [${secure ? "secure" : "unsecure"}] storage is corrupted - expected valid JSON, but got: ${stored}`);
|
|
28100
|
-
}
|
|
28101
|
-
}
|
|
28102
|
-
async setUserData(userId, data, secure) {
|
|
28103
|
-
await (secure ? this.secureStorage : this.insecureStorage).set(this.getKey(userId), JSON.stringify(data));
|
|
28104
|
-
}
|
|
28105
|
-
async get(key, options) {
|
|
28106
|
-
const value = await ((options === null || options === void 0 ? void 0 : options.secure)
|
|
28107
|
-
? this.secureStorage
|
|
28108
|
-
: this.insecureStorage).get(key);
|
|
28109
|
-
if (value === undefined && (options === null || options === void 0 ? void 0 : options.errorIfNull)) {
|
|
28110
|
-
throw new Error(`[${key}] is not stored`);
|
|
28111
|
-
}
|
|
28112
|
-
return value;
|
|
28113
|
-
}
|
|
28114
|
-
async set(key, value, options) {
|
|
28115
|
-
return ((options === null || options === void 0 ? void 0 : options.secure) ? this.secureStorage : this.insecureStorage).set(key, value);
|
|
28116
|
-
}
|
|
28117
|
-
async delete(key, options) {
|
|
28118
|
-
return ((options === null || options === void 0 ? void 0 : options.secure) ? this.secureStorage : this.insecureStorage).delete(key);
|
|
28119
|
-
}
|
|
28120
|
-
async getForUser(userId, key, options) {
|
|
28121
|
-
const userData = await this.getUserData(userId, options === null || options === void 0 ? void 0 : options.secure);
|
|
28122
|
-
let value;
|
|
28123
|
-
if (!userData || !userData[key]) {
|
|
28124
|
-
value = undefined;
|
|
28125
|
-
}
|
|
28126
|
-
value = userData[key];
|
|
28127
|
-
if (value === undefined && (options === null || options === void 0 ? void 0 : options.errorIfNull)) {
|
|
28128
|
-
throw new Error(`Field [${key}] for user [${userId}] is not stored`);
|
|
28129
|
-
}
|
|
28130
|
-
return value || undefined;
|
|
28131
|
-
}
|
|
28132
|
-
async setForUser(userId, values, options) {
|
|
28133
|
-
let userData;
|
|
28134
|
-
try {
|
|
28135
|
-
userData = await this.getUserData(userId, options === null || options === void 0 ? void 0 : options.secure);
|
|
28136
|
-
}
|
|
28137
|
-
catch (_a) {
|
|
28138
|
-
userData = {};
|
|
28139
|
-
}
|
|
28140
|
-
await this.setUserData(userId, { ...userData, ...values }, options === null || options === void 0 ? void 0 : options.secure);
|
|
28141
|
-
}
|
|
28142
|
-
async deleteForUser(userId, key, options) {
|
|
28143
|
-
const userData = await this.getUserData(userId, options === null || options === void 0 ? void 0 : options.secure);
|
|
28144
|
-
delete userData[key];
|
|
28145
|
-
await this.setUserData(userId, userData, options === null || options === void 0 ? void 0 : options.secure);
|
|
28146
|
-
}
|
|
28147
|
-
async deleteAllUserData(userId, options) {
|
|
28148
|
-
await ((options === null || options === void 0 ? void 0 : options.secure) ? this.secureStorage : this.insecureStorage).delete(this.getKey(userId));
|
|
28149
|
-
}
|
|
28562
|
+
async function getSessionIdFromOauthState(storageUtility, oauthState) {
|
|
28563
|
+
return storageUtility.getForUser(oauthState, "sessionId");
|
|
28564
|
+
}
|
|
28565
|
+
async function loadOidcContextFromStorage(sessionId, storageUtility, configFetcher) {
|
|
28566
|
+
try {
|
|
28567
|
+
const [issuerIri, codeVerifier, storedRedirectIri, dpop] = await Promise.all([
|
|
28568
|
+
storageUtility.getForUser(sessionId, "issuer", {
|
|
28569
|
+
errorIfNull: true,
|
|
28570
|
+
}),
|
|
28571
|
+
storageUtility.getForUser(sessionId, "codeVerifier"),
|
|
28572
|
+
storageUtility.getForUser(sessionId, "redirectUrl"),
|
|
28573
|
+
storageUtility.getForUser(sessionId, "dpop", { errorIfNull: true }),
|
|
28574
|
+
]);
|
|
28575
|
+
await storageUtility.deleteForUser(sessionId, "codeVerifier");
|
|
28576
|
+
const issuerConfig = await configFetcher.fetchConfig(issuerIri);
|
|
28577
|
+
return {
|
|
28578
|
+
codeVerifier,
|
|
28579
|
+
redirectUrl: storedRedirectIri,
|
|
28580
|
+
issuerConfig,
|
|
28581
|
+
dpop: dpop === "true",
|
|
28582
|
+
};
|
|
28583
|
+
}
|
|
28584
|
+
catch (e) {
|
|
28585
|
+
throw new Error(`Failed to retrieve OIDC context from storage associated with session [${sessionId}]: ${e}`);
|
|
28586
|
+
}
|
|
28587
|
+
}
|
|
28588
|
+
async function saveSessionInfoToStorage(storageUtility, sessionId, webId, isLoggedIn, refreshToken, secure, dpopKey) {
|
|
28589
|
+
if (refreshToken !== undefined) {
|
|
28590
|
+
await storageUtility.setForUser(sessionId, { refreshToken }, { secure });
|
|
28591
|
+
}
|
|
28592
|
+
if (webId !== undefined) {
|
|
28593
|
+
await storageUtility.setForUser(sessionId, { webId }, { secure });
|
|
28594
|
+
}
|
|
28595
|
+
if (isLoggedIn !== undefined) {
|
|
28596
|
+
await storageUtility.setForUser(sessionId, { isLoggedIn }, { secure });
|
|
28597
|
+
}
|
|
28598
|
+
if (dpopKey !== undefined) {
|
|
28599
|
+
await storageUtility.setForUser(sessionId, {
|
|
28600
|
+
publicKey: JSON.stringify(dpopKey.publicKey),
|
|
28601
|
+
privateKey: JSON.stringify(await jose.exportJWK(dpopKey.privateKey)),
|
|
28602
|
+
}, { secure });
|
|
28603
|
+
}
|
|
28604
|
+
}
|
|
28605
|
+
class StorageUtility {
|
|
28606
|
+
constructor(secureStorage, insecureStorage) {
|
|
28607
|
+
this.secureStorage = secureStorage;
|
|
28608
|
+
this.insecureStorage = insecureStorage;
|
|
28609
|
+
}
|
|
28610
|
+
getKey(userId) {
|
|
28611
|
+
return `solidClientAuthenticationUser:${userId}`;
|
|
28612
|
+
}
|
|
28613
|
+
async getUserData(userId, secure) {
|
|
28614
|
+
const stored = await (secure
|
|
28615
|
+
? this.secureStorage
|
|
28616
|
+
: this.insecureStorage).get(this.getKey(userId));
|
|
28617
|
+
if (stored === undefined) {
|
|
28618
|
+
return {};
|
|
28619
|
+
}
|
|
28620
|
+
try {
|
|
28621
|
+
return JSON.parse(stored);
|
|
28622
|
+
}
|
|
28623
|
+
catch (err) {
|
|
28624
|
+
throw new Error(`Data for user [${userId}] in [${secure ? "secure" : "unsecure"}] storage is corrupted - expected valid JSON, but got: ${stored}`);
|
|
28625
|
+
}
|
|
28626
|
+
}
|
|
28627
|
+
async setUserData(userId, data, secure) {
|
|
28628
|
+
await (secure ? this.secureStorage : this.insecureStorage).set(this.getKey(userId), JSON.stringify(data));
|
|
28629
|
+
}
|
|
28630
|
+
async get(key, options) {
|
|
28631
|
+
const value = await ((options === null || options === void 0 ? void 0 : options.secure)
|
|
28632
|
+
? this.secureStorage
|
|
28633
|
+
: this.insecureStorage).get(key);
|
|
28634
|
+
if (value === undefined && (options === null || options === void 0 ? void 0 : options.errorIfNull)) {
|
|
28635
|
+
throw new Error(`[${key}] is not stored`);
|
|
28636
|
+
}
|
|
28637
|
+
return value;
|
|
28638
|
+
}
|
|
28639
|
+
async set(key, value, options) {
|
|
28640
|
+
return ((options === null || options === void 0 ? void 0 : options.secure) ? this.secureStorage : this.insecureStorage).set(key, value);
|
|
28641
|
+
}
|
|
28642
|
+
async delete(key, options) {
|
|
28643
|
+
return ((options === null || options === void 0 ? void 0 : options.secure) ? this.secureStorage : this.insecureStorage).delete(key);
|
|
28644
|
+
}
|
|
28645
|
+
async getForUser(userId, key, options) {
|
|
28646
|
+
const userData = await this.getUserData(userId, options === null || options === void 0 ? void 0 : options.secure);
|
|
28647
|
+
let value;
|
|
28648
|
+
if (!userData || !userData[key]) {
|
|
28649
|
+
value = undefined;
|
|
28650
|
+
}
|
|
28651
|
+
value = userData[key];
|
|
28652
|
+
if (value === undefined && (options === null || options === void 0 ? void 0 : options.errorIfNull)) {
|
|
28653
|
+
throw new Error(`Field [${key}] for user [${userId}] is not stored`);
|
|
28654
|
+
}
|
|
28655
|
+
return value || undefined;
|
|
28656
|
+
}
|
|
28657
|
+
async setForUser(userId, values, options) {
|
|
28658
|
+
let userData;
|
|
28659
|
+
try {
|
|
28660
|
+
userData = await this.getUserData(userId, options === null || options === void 0 ? void 0 : options.secure);
|
|
28661
|
+
}
|
|
28662
|
+
catch (_a) {
|
|
28663
|
+
userData = {};
|
|
28664
|
+
}
|
|
28665
|
+
await this.setUserData(userId, { ...userData, ...values }, options === null || options === void 0 ? void 0 : options.secure);
|
|
28666
|
+
}
|
|
28667
|
+
async deleteForUser(userId, key, options) {
|
|
28668
|
+
const userData = await this.getUserData(userId, options === null || options === void 0 ? void 0 : options.secure);
|
|
28669
|
+
delete userData[key];
|
|
28670
|
+
await this.setUserData(userId, userData, options === null || options === void 0 ? void 0 : options.secure);
|
|
28671
|
+
}
|
|
28672
|
+
async deleteAllUserData(userId, options) {
|
|
28673
|
+
await ((options === null || options === void 0 ? void 0 : options.secure) ? this.secureStorage : this.insecureStorage).delete(this.getKey(userId));
|
|
28674
|
+
}
|
|
28150
28675
|
}
|
|
28151
28676
|
|
|
28152
|
-
class InMemoryStorage {
|
|
28153
|
-
constructor() {
|
|
28154
|
-
this.map = {};
|
|
28155
|
-
}
|
|
28156
|
-
async get(key) {
|
|
28157
|
-
return this.map[key] || undefined;
|
|
28158
|
-
}
|
|
28159
|
-
async set(key, value) {
|
|
28160
|
-
this.map[key] = value;
|
|
28161
|
-
}
|
|
28162
|
-
async delete(key) {
|
|
28163
|
-
delete this.map[key];
|
|
28164
|
-
}
|
|
28677
|
+
class InMemoryStorage {
|
|
28678
|
+
constructor() {
|
|
28679
|
+
this.map = {};
|
|
28680
|
+
}
|
|
28681
|
+
async get(key) {
|
|
28682
|
+
return this.map[key] || undefined;
|
|
28683
|
+
}
|
|
28684
|
+
async set(key, value) {
|
|
28685
|
+
this.map[key] = value;
|
|
28686
|
+
}
|
|
28687
|
+
async delete(key) {
|
|
28688
|
+
delete this.map[key];
|
|
28689
|
+
}
|
|
28165
28690
|
}
|
|
28166
28691
|
|
|
28167
|
-
class ConfigurationError extends Error {
|
|
28168
|
-
constructor(message) {
|
|
28169
|
-
super(message);
|
|
28170
|
-
}
|
|
28692
|
+
class ConfigurationError extends Error {
|
|
28693
|
+
constructor(message) {
|
|
28694
|
+
super(message);
|
|
28695
|
+
}
|
|
28171
28696
|
}
|
|
28172
28697
|
|
|
28173
|
-
class NotImplementedError extends Error {
|
|
28174
|
-
constructor(methodName) {
|
|
28175
|
-
super(`[${methodName}] is not implemented`);
|
|
28176
|
-
}
|
|
28698
|
+
class NotImplementedError extends Error {
|
|
28699
|
+
constructor(methodName) {
|
|
28700
|
+
super(`[${methodName}] is not implemented`);
|
|
28701
|
+
}
|
|
28177
28702
|
}
|
|
28178
28703
|
|
|
28179
|
-
class InvalidResponseError extends Error {
|
|
28180
|
-
constructor(missingFields) {
|
|
28181
|
-
super(`Invalid response from OIDC provider: missing fields ${missingFields}`);
|
|
28182
|
-
this.missingFields = missingFields;
|
|
28183
|
-
}
|
|
28704
|
+
class InvalidResponseError extends Error {
|
|
28705
|
+
constructor(missingFields) {
|
|
28706
|
+
super(`Invalid response from OIDC provider: missing fields ${missingFields}`);
|
|
28707
|
+
this.missingFields = missingFields;
|
|
28708
|
+
}
|
|
28184
28709
|
}
|
|
28185
28710
|
|
|
28186
|
-
class OidcProviderError extends Error {
|
|
28187
|
-
constructor(message, error, errorDescription) {
|
|
28188
|
-
super(message);
|
|
28189
|
-
this.error = error;
|
|
28190
|
-
this.errorDescription = errorDescription;
|
|
28191
|
-
}
|
|
28711
|
+
class OidcProviderError extends Error {
|
|
28712
|
+
constructor(message, error, errorDescription) {
|
|
28713
|
+
super(message);
|
|
28714
|
+
this.error = error;
|
|
28715
|
+
this.errorDescription = errorDescription;
|
|
28716
|
+
}
|
|
28192
28717
|
}
|
|
28193
28718
|
|
|
28194
|
-
function normalizeHTU(audience) {
|
|
28195
|
-
const audienceUrl = new URL(audience);
|
|
28196
|
-
return new URL(audienceUrl.pathname, audienceUrl.origin).toString();
|
|
28197
|
-
}
|
|
28198
|
-
async function createDpopHeader(audience, method, dpopKey) {
|
|
28199
|
-
return new jose.SignJWT({
|
|
28200
|
-
htu: normalizeHTU(audience),
|
|
28201
|
-
htm: method.toUpperCase(),
|
|
28202
|
-
jti: uuid.v4(),
|
|
28203
|
-
})
|
|
28204
|
-
.setProtectedHeader({
|
|
28205
|
-
alg: PREFERRED_SIGNING_ALG[0],
|
|
28206
|
-
jwk: dpopKey.publicKey,
|
|
28207
|
-
typ: "dpop+jwt",
|
|
28208
|
-
})
|
|
28209
|
-
.setIssuedAt()
|
|
28210
|
-
.sign(dpopKey.privateKey, {});
|
|
28211
|
-
}
|
|
28212
|
-
async function generateDpopKeyPair() {
|
|
28213
|
-
const { privateKey, publicKey } = await jose.generateKeyPair(PREFERRED_SIGNING_ALG[0]);
|
|
28214
|
-
const dpopKeyPair = {
|
|
28215
|
-
privateKey,
|
|
28216
|
-
publicKey: await jose.exportJWK(publicKey),
|
|
28217
|
-
};
|
|
28218
|
-
[dpopKeyPair.publicKey.alg] = PREFERRED_SIGNING_ALG;
|
|
28219
|
-
return dpopKeyPair;
|
|
28719
|
+
function normalizeHTU(audience) {
|
|
28720
|
+
const audienceUrl = new URL(audience);
|
|
28721
|
+
return new URL(audienceUrl.pathname, audienceUrl.origin).toString();
|
|
28722
|
+
}
|
|
28723
|
+
async function createDpopHeader(audience, method, dpopKey) {
|
|
28724
|
+
return new jose.SignJWT({
|
|
28725
|
+
htu: normalizeHTU(audience),
|
|
28726
|
+
htm: method.toUpperCase(),
|
|
28727
|
+
jti: uuid.v4(),
|
|
28728
|
+
})
|
|
28729
|
+
.setProtectedHeader({
|
|
28730
|
+
alg: PREFERRED_SIGNING_ALG[0],
|
|
28731
|
+
jwk: dpopKey.publicKey,
|
|
28732
|
+
typ: "dpop+jwt",
|
|
28733
|
+
})
|
|
28734
|
+
.setIssuedAt()
|
|
28735
|
+
.sign(dpopKey.privateKey, {});
|
|
28736
|
+
}
|
|
28737
|
+
async function generateDpopKeyPair() {
|
|
28738
|
+
const { privateKey, publicKey } = await jose.generateKeyPair(PREFERRED_SIGNING_ALG[0]);
|
|
28739
|
+
const dpopKeyPair = {
|
|
28740
|
+
privateKey,
|
|
28741
|
+
publicKey: await jose.exportJWK(publicKey),
|
|
28742
|
+
};
|
|
28743
|
+
[dpopKeyPair.publicKey.alg] = PREFERRED_SIGNING_ALG;
|
|
28744
|
+
return dpopKeyPair;
|
|
28220
28745
|
}
|
|
28221
28746
|
|
|
28222
|
-
const DEFAULT_EXPIRATION_TIME_SECONDS = 600;
|
|
28223
|
-
function isExpectedAuthError(statusCode) {
|
|
28224
|
-
return [401, 403].includes(statusCode);
|
|
28225
|
-
}
|
|
28226
|
-
async function buildDpopFetchOptions(targetUrl, authToken, dpopKey, defaultOptions) {
|
|
28227
|
-
var _a;
|
|
28228
|
-
const headers = new
|
|
28229
|
-
headers.set("Authorization", `DPoP ${authToken}`);
|
|
28230
|
-
headers.set("DPoP", await createDpopHeader(targetUrl, (_a = defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.method) !== null && _a !== void 0 ? _a : "get", dpopKey));
|
|
28231
|
-
return {
|
|
28232
|
-
...defaultOptions,
|
|
28233
|
-
headers,
|
|
28234
|
-
};
|
|
28235
|
-
}
|
|
28236
|
-
async function buildAuthenticatedHeaders(targetUrl, authToken, dpopKey, defaultOptions) {
|
|
28237
|
-
if (dpopKey !== undefined) {
|
|
28238
|
-
return buildDpopFetchOptions(targetUrl, authToken, dpopKey, defaultOptions);
|
|
28239
|
-
}
|
|
28240
|
-
const headers = new
|
|
28241
|
-
headers.set("Authorization", `Bearer ${authToken}`);
|
|
28242
|
-
return {
|
|
28243
|
-
...defaultOptions,
|
|
28244
|
-
headers,
|
|
28245
|
-
};
|
|
28246
|
-
}
|
|
28247
|
-
async function makeAuthenticatedRequest(unauthFetch, accessToken, url, defaultRequestInit, dpopKey) {
|
|
28248
|
-
return unauthFetch(url, await buildAuthenticatedHeaders(url.toString(), accessToken, dpopKey, defaultRequestInit));
|
|
28249
|
-
}
|
|
28250
|
-
async function refreshAccessToken(refreshOptions, dpopKey, eventEmitter) {
|
|
28251
|
-
var _a;
|
|
28252
|
-
const tokenSet = await refreshOptions.tokenRefresher.refresh(refreshOptions.sessionId, refreshOptions.refreshToken, dpopKey);
|
|
28253
|
-
eventEmitter === null || eventEmitter === void 0 ? void 0 : eventEmitter.emit(EVENTS.SESSION_EXTENDED, (_a = tokenSet.expiresIn) !== null && _a !== void 0 ? _a : DEFAULT_EXPIRATION_TIME_SECONDS);
|
|
28254
|
-
if (typeof tokenSet.refreshToken === "string") {
|
|
28255
|
-
eventEmitter === null || eventEmitter === void 0 ? void 0 : eventEmitter.emit(EVENTS.NEW_REFRESH_TOKEN, tokenSet.refreshToken);
|
|
28256
|
-
}
|
|
28257
|
-
return {
|
|
28258
|
-
accessToken: tokenSet.accessToken,
|
|
28259
|
-
refreshToken: tokenSet.refreshToken,
|
|
28260
|
-
expiresIn: tokenSet.expiresIn,
|
|
28261
|
-
};
|
|
28262
|
-
}
|
|
28263
|
-
const computeRefreshDelay = (expiresIn) => {
|
|
28264
|
-
if (expiresIn !== undefined) {
|
|
28265
|
-
return expiresIn - REFRESH_BEFORE_EXPIRATION_SECONDS > 0
|
|
28266
|
-
?
|
|
28267
|
-
expiresIn - REFRESH_BEFORE_EXPIRATION_SECONDS
|
|
28268
|
-
: expiresIn;
|
|
28269
|
-
}
|
|
28270
|
-
return DEFAULT_EXPIRATION_TIME_SECONDS;
|
|
28271
|
-
};
|
|
28272
|
-
async function buildAuthenticatedFetch(unauthFetch, accessToken, options) {
|
|
28273
|
-
var _a;
|
|
28274
|
-
let currentAccessToken = accessToken;
|
|
28275
|
-
let latestTimeout;
|
|
28276
|
-
const currentRefreshOptions = options === null || options === void 0 ? void 0 : options.refreshOptions;
|
|
28277
|
-
if (currentRefreshOptions !== undefined) {
|
|
28278
|
-
const proactivelyRefreshToken = async () => {
|
|
28279
|
-
var _a, _b, _c, _d;
|
|
28280
|
-
try {
|
|
28281
|
-
const { accessToken: refreshedAccessToken, refreshToken, expiresIn, } = await refreshAccessToken(currentRefreshOptions, options.dpopKey, options.eventEmitter);
|
|
28282
|
-
currentAccessToken = refreshedAccessToken;
|
|
28283
|
-
if (refreshToken !== undefined) {
|
|
28284
|
-
currentRefreshOptions.refreshToken = refreshToken;
|
|
28285
|
-
}
|
|
28286
|
-
clearTimeout(latestTimeout);
|
|
28287
|
-
latestTimeout = setTimeout(proactivelyRefreshToken, computeRefreshDelay(expiresIn) * 1000);
|
|
28288
|
-
(_a = options.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit(EVENTS.TIMEOUT_SET, latestTimeout);
|
|
28289
|
-
}
|
|
28290
|
-
catch (e) {
|
|
28291
|
-
if (e instanceof OidcProviderError) {
|
|
28292
|
-
(_b = options === null || options === void 0 ? void 0 : options.eventEmitter) === null || _b === void 0 ? void 0 : _b.emit(EVENTS.ERROR, e.error, e.errorDescription);
|
|
28293
|
-
(_c = options === null || options === void 0 ? void 0 : options.eventEmitter) === null || _c === void 0 ? void 0 : _c.emit(EVENTS.SESSION_EXPIRED);
|
|
28294
|
-
}
|
|
28295
|
-
if (e instanceof InvalidResponseError &&
|
|
28296
|
-
e.missingFields.includes("access_token")) {
|
|
28297
|
-
(_d = options === null || options === void 0 ? void 0 : options.eventEmitter) === null || _d === void 0 ? void 0 : _d.emit(EVENTS.SESSION_EXPIRED);
|
|
28298
|
-
}
|
|
28299
|
-
}
|
|
28300
|
-
};
|
|
28301
|
-
latestTimeout = setTimeout(proactivelyRefreshToken, computeRefreshDelay(options.expiresIn) * 1000);
|
|
28302
|
-
(_a = options.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit(EVENTS.TIMEOUT_SET, latestTimeout);
|
|
28303
|
-
}
|
|
28304
|
-
else if (options !== undefined && options.eventEmitter !== undefined) {
|
|
28305
|
-
const expirationTimeout = setTimeout(() => {
|
|
28306
|
-
options.eventEmitter.emit(EVENTS.SESSION_EXPIRED);
|
|
28307
|
-
}, computeRefreshDelay(options.expiresIn) * 1000);
|
|
28308
|
-
options.eventEmitter.emit(EVENTS.TIMEOUT_SET, expirationTimeout);
|
|
28309
|
-
}
|
|
28310
|
-
return async (url, requestInit) => {
|
|
28311
|
-
let response = await makeAuthenticatedRequest(unauthFetch, currentAccessToken, url, requestInit, options === null || options === void 0 ? void 0 : options.dpopKey);
|
|
28312
|
-
const failedButNotExpectedAuthError = !response.ok && !isExpectedAuthError(response.status);
|
|
28313
|
-
if (response.ok || failedButNotExpectedAuthError) {
|
|
28314
|
-
return response;
|
|
28315
|
-
}
|
|
28316
|
-
const hasBeenRedirected = response.url !== url;
|
|
28317
|
-
if (hasBeenRedirected && (options === null || options === void 0 ? void 0 : options.dpopKey) !== undefined) {
|
|
28318
|
-
response = await makeAuthenticatedRequest(unauthFetch, currentAccessToken, response.url, requestInit, options.dpopKey);
|
|
28319
|
-
}
|
|
28320
|
-
return response;
|
|
28321
|
-
};
|
|
28747
|
+
const DEFAULT_EXPIRATION_TIME_SECONDS = 600;
|
|
28748
|
+
function isExpectedAuthError(statusCode) {
|
|
28749
|
+
return [401, 403].includes(statusCode);
|
|
28750
|
+
}
|
|
28751
|
+
async function buildDpopFetchOptions(targetUrl, authToken, dpopKey, defaultOptions) {
|
|
28752
|
+
var _a;
|
|
28753
|
+
const headers = new universalFetch.Headers(defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.headers);
|
|
28754
|
+
headers.set("Authorization", `DPoP ${authToken}`);
|
|
28755
|
+
headers.set("DPoP", await createDpopHeader(targetUrl, (_a = defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.method) !== null && _a !== void 0 ? _a : "get", dpopKey));
|
|
28756
|
+
return {
|
|
28757
|
+
...defaultOptions,
|
|
28758
|
+
headers,
|
|
28759
|
+
};
|
|
28760
|
+
}
|
|
28761
|
+
async function buildAuthenticatedHeaders(targetUrl, authToken, dpopKey, defaultOptions) {
|
|
28762
|
+
if (dpopKey !== undefined) {
|
|
28763
|
+
return buildDpopFetchOptions(targetUrl, authToken, dpopKey, defaultOptions);
|
|
28764
|
+
}
|
|
28765
|
+
const headers = new universalFetch.Headers(defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.headers);
|
|
28766
|
+
headers.set("Authorization", `Bearer ${authToken}`);
|
|
28767
|
+
return {
|
|
28768
|
+
...defaultOptions,
|
|
28769
|
+
headers,
|
|
28770
|
+
};
|
|
28771
|
+
}
|
|
28772
|
+
async function makeAuthenticatedRequest(unauthFetch, accessToken, url, defaultRequestInit, dpopKey) {
|
|
28773
|
+
return unauthFetch(url, await buildAuthenticatedHeaders(url.toString(), accessToken, dpopKey, defaultRequestInit));
|
|
28774
|
+
}
|
|
28775
|
+
async function refreshAccessToken(refreshOptions, dpopKey, eventEmitter) {
|
|
28776
|
+
var _a;
|
|
28777
|
+
const tokenSet = await refreshOptions.tokenRefresher.refresh(refreshOptions.sessionId, refreshOptions.refreshToken, dpopKey);
|
|
28778
|
+
eventEmitter === null || eventEmitter === void 0 ? void 0 : eventEmitter.emit(EVENTS.SESSION_EXTENDED, (_a = tokenSet.expiresIn) !== null && _a !== void 0 ? _a : DEFAULT_EXPIRATION_TIME_SECONDS);
|
|
28779
|
+
if (typeof tokenSet.refreshToken === "string") {
|
|
28780
|
+
eventEmitter === null || eventEmitter === void 0 ? void 0 : eventEmitter.emit(EVENTS.NEW_REFRESH_TOKEN, tokenSet.refreshToken);
|
|
28781
|
+
}
|
|
28782
|
+
return {
|
|
28783
|
+
accessToken: tokenSet.accessToken,
|
|
28784
|
+
refreshToken: tokenSet.refreshToken,
|
|
28785
|
+
expiresIn: tokenSet.expiresIn,
|
|
28786
|
+
};
|
|
28787
|
+
}
|
|
28788
|
+
const computeRefreshDelay = (expiresIn) => {
|
|
28789
|
+
if (expiresIn !== undefined) {
|
|
28790
|
+
return expiresIn - REFRESH_BEFORE_EXPIRATION_SECONDS > 0
|
|
28791
|
+
?
|
|
28792
|
+
expiresIn - REFRESH_BEFORE_EXPIRATION_SECONDS
|
|
28793
|
+
: expiresIn;
|
|
28794
|
+
}
|
|
28795
|
+
return DEFAULT_EXPIRATION_TIME_SECONDS;
|
|
28796
|
+
};
|
|
28797
|
+
async function buildAuthenticatedFetch(unauthFetch, accessToken, options) {
|
|
28798
|
+
var _a;
|
|
28799
|
+
let currentAccessToken = accessToken;
|
|
28800
|
+
let latestTimeout;
|
|
28801
|
+
const currentRefreshOptions = options === null || options === void 0 ? void 0 : options.refreshOptions;
|
|
28802
|
+
if (currentRefreshOptions !== undefined) {
|
|
28803
|
+
const proactivelyRefreshToken = async () => {
|
|
28804
|
+
var _a, _b, _c, _d;
|
|
28805
|
+
try {
|
|
28806
|
+
const { accessToken: refreshedAccessToken, refreshToken, expiresIn, } = await refreshAccessToken(currentRefreshOptions, options.dpopKey, options.eventEmitter);
|
|
28807
|
+
currentAccessToken = refreshedAccessToken;
|
|
28808
|
+
if (refreshToken !== undefined) {
|
|
28809
|
+
currentRefreshOptions.refreshToken = refreshToken;
|
|
28810
|
+
}
|
|
28811
|
+
clearTimeout(latestTimeout);
|
|
28812
|
+
latestTimeout = setTimeout(proactivelyRefreshToken, computeRefreshDelay(expiresIn) * 1000);
|
|
28813
|
+
(_a = options.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit(EVENTS.TIMEOUT_SET, latestTimeout);
|
|
28814
|
+
}
|
|
28815
|
+
catch (e) {
|
|
28816
|
+
if (e instanceof OidcProviderError) {
|
|
28817
|
+
(_b = options === null || options === void 0 ? void 0 : options.eventEmitter) === null || _b === void 0 ? void 0 : _b.emit(EVENTS.ERROR, e.error, e.errorDescription);
|
|
28818
|
+
(_c = options === null || options === void 0 ? void 0 : options.eventEmitter) === null || _c === void 0 ? void 0 : _c.emit(EVENTS.SESSION_EXPIRED);
|
|
28819
|
+
}
|
|
28820
|
+
if (e instanceof InvalidResponseError &&
|
|
28821
|
+
e.missingFields.includes("access_token")) {
|
|
28822
|
+
(_d = options === null || options === void 0 ? void 0 : options.eventEmitter) === null || _d === void 0 ? void 0 : _d.emit(EVENTS.SESSION_EXPIRED);
|
|
28823
|
+
}
|
|
28824
|
+
}
|
|
28825
|
+
};
|
|
28826
|
+
latestTimeout = setTimeout(proactivelyRefreshToken, computeRefreshDelay(options.expiresIn) * 1000);
|
|
28827
|
+
(_a = options.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit(EVENTS.TIMEOUT_SET, latestTimeout);
|
|
28828
|
+
}
|
|
28829
|
+
else if (options !== undefined && options.eventEmitter !== undefined) {
|
|
28830
|
+
const expirationTimeout = setTimeout(() => {
|
|
28831
|
+
options.eventEmitter.emit(EVENTS.SESSION_EXPIRED);
|
|
28832
|
+
}, computeRefreshDelay(options.expiresIn) * 1000);
|
|
28833
|
+
options.eventEmitter.emit(EVENTS.TIMEOUT_SET, expirationTimeout);
|
|
28834
|
+
}
|
|
28835
|
+
return async (url, requestInit) => {
|
|
28836
|
+
let response = await makeAuthenticatedRequest(unauthFetch, currentAccessToken, url, requestInit, options === null || options === void 0 ? void 0 : options.dpopKey);
|
|
28837
|
+
const failedButNotExpectedAuthError = !response.ok && !isExpectedAuthError(response.status);
|
|
28838
|
+
if (response.ok || failedButNotExpectedAuthError) {
|
|
28839
|
+
return response;
|
|
28840
|
+
}
|
|
28841
|
+
const hasBeenRedirected = response.url !== url;
|
|
28842
|
+
if (hasBeenRedirected && (options === null || options === void 0 ? void 0 : options.dpopKey) !== undefined) {
|
|
28843
|
+
response = await makeAuthenticatedRequest(unauthFetch, currentAccessToken, response.url, requestInit, options.dpopKey);
|
|
28844
|
+
}
|
|
28845
|
+
return response;
|
|
28846
|
+
};
|
|
28322
28847
|
}
|
|
28323
28848
|
|
|
28324
|
-
const StorageUtilityGetResponse = "getResponse";
|
|
28325
|
-
const StorageUtilityMock = {
|
|
28326
|
-
get: async (key, options) => StorageUtilityGetResponse,
|
|
28327
|
-
set: async (key, value) => {
|
|
28328
|
-
},
|
|
28329
|
-
delete: async (key) => {
|
|
28330
|
-
},
|
|
28331
|
-
getForUser: async (userId, key, options) => StorageUtilityGetResponse,
|
|
28332
|
-
setForUser: async (userId, values, options) => {
|
|
28333
|
-
},
|
|
28334
|
-
deleteForUser: async (userId, key, options) => {
|
|
28335
|
-
},
|
|
28336
|
-
deleteAllUserData: async (userId, options) => {
|
|
28337
|
-
},
|
|
28338
|
-
};
|
|
28339
|
-
const mockStorage = (stored) => {
|
|
28340
|
-
const store = stored;
|
|
28341
|
-
return {
|
|
28342
|
-
get: async (key) => {
|
|
28343
|
-
if (store[key] === undefined) {
|
|
28344
|
-
return undefined;
|
|
28345
|
-
}
|
|
28346
|
-
if (typeof store[key] === "string") {
|
|
28347
|
-
return store[key];
|
|
28348
|
-
}
|
|
28349
|
-
return JSON.stringify(store[key]);
|
|
28350
|
-
},
|
|
28351
|
-
set: async (key, value) => {
|
|
28352
|
-
store[key] = value;
|
|
28353
|
-
},
|
|
28354
|
-
delete: async (key) => {
|
|
28355
|
-
delete store[key];
|
|
28356
|
-
},
|
|
28357
|
-
};
|
|
28358
|
-
};
|
|
28359
|
-
const mockStorageUtility = (stored, isSecure = false) => {
|
|
28360
|
-
if (isSecure) {
|
|
28361
|
-
return new StorageUtility(mockStorage(stored), mockStorage({}));
|
|
28362
|
-
}
|
|
28363
|
-
return new StorageUtility(mockStorage({}), mockStorage(stored));
|
|
28849
|
+
const StorageUtilityGetResponse = "getResponse";
|
|
28850
|
+
const StorageUtilityMock = {
|
|
28851
|
+
get: async (key, options) => StorageUtilityGetResponse,
|
|
28852
|
+
set: async (key, value) => {
|
|
28853
|
+
},
|
|
28854
|
+
delete: async (key) => {
|
|
28855
|
+
},
|
|
28856
|
+
getForUser: async (userId, key, options) => StorageUtilityGetResponse,
|
|
28857
|
+
setForUser: async (userId, values, options) => {
|
|
28858
|
+
},
|
|
28859
|
+
deleteForUser: async (userId, key, options) => {
|
|
28860
|
+
},
|
|
28861
|
+
deleteAllUserData: async (userId, options) => {
|
|
28862
|
+
},
|
|
28863
|
+
};
|
|
28864
|
+
const mockStorage = (stored) => {
|
|
28865
|
+
const store = stored;
|
|
28866
|
+
return {
|
|
28867
|
+
get: async (key) => {
|
|
28868
|
+
if (store[key] === undefined) {
|
|
28869
|
+
return undefined;
|
|
28870
|
+
}
|
|
28871
|
+
if (typeof store[key] === "string") {
|
|
28872
|
+
return store[key];
|
|
28873
|
+
}
|
|
28874
|
+
return JSON.stringify(store[key]);
|
|
28875
|
+
},
|
|
28876
|
+
set: async (key, value) => {
|
|
28877
|
+
store[key] = value;
|
|
28878
|
+
},
|
|
28879
|
+
delete: async (key) => {
|
|
28880
|
+
delete store[key];
|
|
28881
|
+
},
|
|
28882
|
+
};
|
|
28883
|
+
};
|
|
28884
|
+
const mockStorageUtility = (stored, isSecure = false) => {
|
|
28885
|
+
if (isSecure) {
|
|
28886
|
+
return new StorageUtility(mockStorage(stored), mockStorage({}));
|
|
28887
|
+
}
|
|
28888
|
+
return new StorageUtility(mockStorage({}), mockStorage(stored));
|
|
28364
28889
|
};
|
|
28365
28890
|
|
|
28366
28891
|
exports.AggregateHandler = AggregateHandler;
|
|
@@ -29584,6 +30109,29 @@ function validate(uuid) {
|
|
|
29584
30109
|
|
|
29585
30110
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (validate);
|
|
29586
30111
|
|
|
30112
|
+
/***/ }),
|
|
30113
|
+
|
|
30114
|
+
/***/ "./node_modules/@inrupt/universal-fetch/dist/index-browser.js":
|
|
30115
|
+
/*!********************************************************************!*\
|
|
30116
|
+
!*** ./node_modules/@inrupt/universal-fetch/dist/index-browser.js ***!
|
|
30117
|
+
\********************************************************************/
|
|
30118
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
30119
|
+
|
|
30120
|
+
"use strict";
|
|
30121
|
+
|
|
30122
|
+
|
|
30123
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
30124
|
+
|
|
30125
|
+
var indexBrowser = globalThis.fetch;
|
|
30126
|
+
const { fetch, Response, Request, Headers } = globalThis;
|
|
30127
|
+
|
|
30128
|
+
exports.Headers = Headers;
|
|
30129
|
+
exports.Request = Request;
|
|
30130
|
+
exports.Response = Response;
|
|
30131
|
+
exports["default"] = indexBrowser;
|
|
30132
|
+
exports.fetch = fetch;
|
|
30133
|
+
|
|
30134
|
+
|
|
29587
30135
|
/***/ }),
|
|
29588
30136
|
|
|
29589
30137
|
/***/ "./node_modules/@noble/curves/_shortw_utils.js":
|
|
@@ -60228,522 +60776,545 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
60228
60776
|
/* harmony export */ "saveSessionInfoToStorage": () => (/* binding */ saveSessionInfoToStorage)
|
|
60229
60777
|
/* harmony export */ });
|
|
60230
60778
|
/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! events */ "./node_modules/events/events.js");
|
|
60231
|
-
/* harmony import */ var
|
|
60232
|
-
/* harmony import */ var
|
|
60779
|
+
/* harmony import */ var _inrupt_universal_fetch__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @inrupt/universal-fetch */ "./node_modules/@inrupt/universal-fetch/dist/index-browser.mjs");
|
|
60780
|
+
/* harmony import */ var jose__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! jose */ "./node_modules/jose/dist/browser/index.js");
|
|
60233
60781
|
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uuid */ "./node_modules/@inrupt/solid-client-authn-core/node_modules/uuid/dist/esm-browser/v4.js");
|
|
60234
60782
|
|
|
60235
60783
|
|
|
60236
60784
|
|
|
60237
60785
|
|
|
60238
60786
|
|
|
60239
|
-
const SOLID_CLIENT_AUTHN_KEY_PREFIX = "solidClientAuthn:";
|
|
60240
|
-
const PREFERRED_SIGNING_ALG = ["ES256", "RS256"];
|
|
60241
|
-
const EVENTS = {
|
|
60242
|
-
ERROR: "error",
|
|
60243
|
-
LOGIN: "login",
|
|
60244
|
-
LOGOUT: "logout",
|
|
60245
|
-
NEW_REFRESH_TOKEN: "newRefreshToken",
|
|
60246
|
-
SESSION_EXPIRED: "sessionExpired",
|
|
60247
|
-
SESSION_EXTENDED: "sessionExtended",
|
|
60248
|
-
SESSION_RESTORED: "sessionRestore",
|
|
60249
|
-
TIMEOUT_SET: "timeoutSet",
|
|
60250
|
-
};
|
|
60251
|
-
const REFRESH_BEFORE_EXPIRATION_SECONDS = 5;
|
|
60252
|
-
const SCOPE_OPENID = "openid";
|
|
60253
|
-
const SCOPE_OFFLINE = "offline_access";
|
|
60254
|
-
const SCOPE_WEBID = "webid";
|
|
60787
|
+
const SOLID_CLIENT_AUTHN_KEY_PREFIX = "solidClientAuthn:";
|
|
60788
|
+
const PREFERRED_SIGNING_ALG = ["ES256", "RS256"];
|
|
60789
|
+
const EVENTS = {
|
|
60790
|
+
ERROR: "error",
|
|
60791
|
+
LOGIN: "login",
|
|
60792
|
+
LOGOUT: "logout",
|
|
60793
|
+
NEW_REFRESH_TOKEN: "newRefreshToken",
|
|
60794
|
+
SESSION_EXPIRED: "sessionExpired",
|
|
60795
|
+
SESSION_EXTENDED: "sessionExtended",
|
|
60796
|
+
SESSION_RESTORED: "sessionRestore",
|
|
60797
|
+
TIMEOUT_SET: "timeoutSet",
|
|
60798
|
+
};
|
|
60799
|
+
const REFRESH_BEFORE_EXPIRATION_SECONDS = 5;
|
|
60800
|
+
const SCOPE_OPENID = "openid";
|
|
60801
|
+
const SCOPE_OFFLINE = "offline_access";
|
|
60802
|
+
const SCOPE_WEBID = "webid";
|
|
60255
60803
|
const DEFAULT_SCOPES = [SCOPE_OPENID, SCOPE_OFFLINE, SCOPE_WEBID].join(" ");
|
|
60256
60804
|
|
|
60257
|
-
const buildProxyHandler = (toExclude, errorMessage) => ({
|
|
60258
|
-
get(target, prop, receiver) {
|
|
60259
|
-
if (!Object.getOwnPropertyNames(events__WEBPACK_IMPORTED_MODULE_0__.EventEmitter).includes(prop) &&
|
|
60260
|
-
Object.getOwnPropertyNames(toExclude).includes(prop)) {
|
|
60261
|
-
throw new Error(`${errorMessage}: [${prop}] is not supported`);
|
|
60262
|
-
}
|
|
60263
|
-
return Reflect.get(target, prop, receiver);
|
|
60264
|
-
},
|
|
60805
|
+
const buildProxyHandler = (toExclude, errorMessage) => ({
|
|
60806
|
+
get(target, prop, receiver) {
|
|
60807
|
+
if (!Object.getOwnPropertyNames(events__WEBPACK_IMPORTED_MODULE_0__.EventEmitter).includes(prop) &&
|
|
60808
|
+
Object.getOwnPropertyNames(toExclude).includes(prop)) {
|
|
60809
|
+
throw new Error(`${errorMessage}: [${prop}] is not supported`);
|
|
60810
|
+
}
|
|
60811
|
+
return Reflect.get(target, prop, receiver);
|
|
60812
|
+
},
|
|
60265
60813
|
});
|
|
60266
60814
|
|
|
60267
|
-
class AggregateHandler {
|
|
60268
|
-
constructor(handleables) {
|
|
60269
|
-
this.handleables = handleables;
|
|
60270
|
-
}
|
|
60271
|
-
async getProperHandler(params) {
|
|
60272
|
-
const canHandleList = await Promise.all(this.handleables.map((handleable) => handleable.canHandle(...params)));
|
|
60273
|
-
for (let i = 0; i < canHandleList.length; i += 1) {
|
|
60274
|
-
if (canHandleList[i]) {
|
|
60275
|
-
return this.handleables[i];
|
|
60276
|
-
}
|
|
60277
|
-
}
|
|
60278
|
-
return null;
|
|
60279
|
-
}
|
|
60280
|
-
async canHandle(...params) {
|
|
60281
|
-
return (await this.getProperHandler(params)) !== null;
|
|
60282
|
-
}
|
|
60283
|
-
async handle(...params) {
|
|
60284
|
-
const handler = await this.getProperHandler(params);
|
|
60285
|
-
if (handler) {
|
|
60286
|
-
return handler.handle(...params);
|
|
60287
|
-
}
|
|
60288
|
-
throw new Error(`[${this.constructor.name}] cannot find a suitable handler for: ${params
|
|
60289
|
-
.map((param) => {
|
|
60290
|
-
try {
|
|
60291
|
-
return JSON.stringify(param);
|
|
60292
|
-
}
|
|
60293
|
-
catch (err) {
|
|
60294
|
-
return param.toString();
|
|
60295
|
-
}
|
|
60296
|
-
})
|
|
60297
|
-
.join(", ")}`);
|
|
60298
|
-
}
|
|
60815
|
+
class AggregateHandler {
|
|
60816
|
+
constructor(handleables) {
|
|
60817
|
+
this.handleables = handleables;
|
|
60818
|
+
}
|
|
60819
|
+
async getProperHandler(params) {
|
|
60820
|
+
const canHandleList = await Promise.all(this.handleables.map((handleable) => handleable.canHandle(...params)));
|
|
60821
|
+
for (let i = 0; i < canHandleList.length; i += 1) {
|
|
60822
|
+
if (canHandleList[i]) {
|
|
60823
|
+
return this.handleables[i];
|
|
60824
|
+
}
|
|
60825
|
+
}
|
|
60826
|
+
return null;
|
|
60827
|
+
}
|
|
60828
|
+
async canHandle(...params) {
|
|
60829
|
+
return (await this.getProperHandler(params)) !== null;
|
|
60830
|
+
}
|
|
60831
|
+
async handle(...params) {
|
|
60832
|
+
const handler = await this.getProperHandler(params);
|
|
60833
|
+
if (handler) {
|
|
60834
|
+
return handler.handle(...params);
|
|
60835
|
+
}
|
|
60836
|
+
throw new Error(`[${this.constructor.name}] cannot find a suitable handler for: ${params
|
|
60837
|
+
.map((param) => {
|
|
60838
|
+
try {
|
|
60839
|
+
return JSON.stringify(param);
|
|
60840
|
+
}
|
|
60841
|
+
catch (err) {
|
|
60842
|
+
return param.toString();
|
|
60843
|
+
}
|
|
60844
|
+
})
|
|
60845
|
+
.join(", ")}`);
|
|
60846
|
+
}
|
|
60299
60847
|
}
|
|
60300
60848
|
|
|
60301
|
-
async function fetchJwks(jwksIri, issuerIri) {
|
|
60302
|
-
const jwksResponse = await (0,
|
|
60303
|
-
if (jwksResponse.status !== 200) {
|
|
60304
|
-
throw new Error(`Could not fetch JWKS for [${issuerIri}] at [${jwksIri}]: ${jwksResponse.status} ${jwksResponse.statusText}`);
|
|
60305
|
-
}
|
|
60306
|
-
let jwk;
|
|
60307
|
-
try {
|
|
60308
|
-
jwk = (await jwksResponse.json()).keys[0];
|
|
60309
|
-
}
|
|
60310
|
-
catch (e) {
|
|
60311
|
-
throw new Error(`Malformed JWKS for [${issuerIri}] at [${jwksIri}]: ${e.message}`);
|
|
60312
|
-
}
|
|
60313
|
-
return jwk;
|
|
60314
|
-
}
|
|
60315
|
-
async function getWebidFromTokenPayload(idToken, jwksIri, issuerIri, clientId) {
|
|
60316
|
-
const jwk = await fetchJwks(jwksIri, issuerIri);
|
|
60317
|
-
let payload;
|
|
60318
|
-
try {
|
|
60319
|
-
const { payload: verifiedPayload } = await (0,
|
|
60320
|
-
issuer: issuerIri,
|
|
60321
|
-
audience: clientId,
|
|
60322
|
-
});
|
|
60323
|
-
payload = verifiedPayload;
|
|
60324
|
-
}
|
|
60325
|
-
catch (e) {
|
|
60326
|
-
throw new Error(`Token verification failed: ${e.stack}`);
|
|
60327
|
-
}
|
|
60328
|
-
if (typeof payload.webid === "string") {
|
|
60329
|
-
return payload.webid;
|
|
60330
|
-
}
|
|
60331
|
-
if (typeof payload.sub !== "string") {
|
|
60332
|
-
throw new Error(`The token ${JSON.stringify(payload)} is invalid: it has no 'webid' claim and no 'sub' claim.`);
|
|
60333
|
-
}
|
|
60334
|
-
try {
|
|
60335
|
-
new URL(payload.sub);
|
|
60336
|
-
return payload.sub;
|
|
60337
|
-
}
|
|
60338
|
-
catch (e) {
|
|
60339
|
-
throw new Error(`The token has no 'webid' claim, and its 'sub' claim of [${payload.sub}] is invalid as a URL - error [${e}].`);
|
|
60340
|
-
}
|
|
60849
|
+
async function fetchJwks(jwksIri, issuerIri) {
|
|
60850
|
+
const jwksResponse = await (0,_inrupt_universal_fetch__WEBPACK_IMPORTED_MODULE_2__.fetch)(jwksIri);
|
|
60851
|
+
if (jwksResponse.status !== 200) {
|
|
60852
|
+
throw new Error(`Could not fetch JWKS for [${issuerIri}] at [${jwksIri}]: ${jwksResponse.status} ${jwksResponse.statusText}`);
|
|
60853
|
+
}
|
|
60854
|
+
let jwk;
|
|
60855
|
+
try {
|
|
60856
|
+
jwk = (await jwksResponse.json()).keys[0];
|
|
60857
|
+
}
|
|
60858
|
+
catch (e) {
|
|
60859
|
+
throw new Error(`Malformed JWKS for [${issuerIri}] at [${jwksIri}]: ${e.message}`);
|
|
60860
|
+
}
|
|
60861
|
+
return jwk;
|
|
60862
|
+
}
|
|
60863
|
+
async function getWebidFromTokenPayload(idToken, jwksIri, issuerIri, clientId) {
|
|
60864
|
+
const jwk = await fetchJwks(jwksIri, issuerIri);
|
|
60865
|
+
let payload;
|
|
60866
|
+
try {
|
|
60867
|
+
const { payload: verifiedPayload } = await (0,jose__WEBPACK_IMPORTED_MODULE_1__.jwtVerify)(idToken, await (0,jose__WEBPACK_IMPORTED_MODULE_1__.importJWK)(jwk), {
|
|
60868
|
+
issuer: issuerIri,
|
|
60869
|
+
audience: clientId,
|
|
60870
|
+
});
|
|
60871
|
+
payload = verifiedPayload;
|
|
60872
|
+
}
|
|
60873
|
+
catch (e) {
|
|
60874
|
+
throw new Error(`Token verification failed: ${e.stack}`);
|
|
60875
|
+
}
|
|
60876
|
+
if (typeof payload.webid === "string") {
|
|
60877
|
+
return payload.webid;
|
|
60878
|
+
}
|
|
60879
|
+
if (typeof payload.sub !== "string") {
|
|
60880
|
+
throw new Error(`The token ${JSON.stringify(payload)} is invalid: it has no 'webid' claim and no 'sub' claim.`);
|
|
60881
|
+
}
|
|
60882
|
+
try {
|
|
60883
|
+
new URL(payload.sub);
|
|
60884
|
+
return payload.sub;
|
|
60885
|
+
}
|
|
60886
|
+
catch (e) {
|
|
60887
|
+
throw new Error(`The token has no 'webid' claim, and its 'sub' claim of [${payload.sub}] is invalid as a URL - error [${e}].`);
|
|
60888
|
+
}
|
|
60341
60889
|
}
|
|
60342
60890
|
|
|
60343
|
-
function isValidRedirectUrl(redirectUrl) {
|
|
60344
|
-
try {
|
|
60345
|
-
const urlObject = new URL(redirectUrl);
|
|
60346
|
-
return urlObject.hash === "";
|
|
60347
|
-
}
|
|
60348
|
-
catch (e) {
|
|
60349
|
-
return false;
|
|
60350
|
-
}
|
|
60891
|
+
function isValidRedirectUrl(redirectUrl) {
|
|
60892
|
+
try {
|
|
60893
|
+
const urlObject = new URL(redirectUrl);
|
|
60894
|
+
return urlObject.hash === "";
|
|
60895
|
+
}
|
|
60896
|
+
catch (e) {
|
|
60897
|
+
return false;
|
|
60898
|
+
}
|
|
60351
60899
|
}
|
|
60352
60900
|
|
|
60353
|
-
function isSupportedTokenType(token) {
|
|
60354
|
-
return typeof token === "string" && ["DPoP", "Bearer"].includes(token);
|
|
60901
|
+
function isSupportedTokenType(token) {
|
|
60902
|
+
return typeof token === "string" && ["DPoP", "Bearer"].includes(token);
|
|
60355
60903
|
}
|
|
60356
60904
|
|
|
60357
60905
|
const USER_SESSION_PREFIX = "solidClientAuthenticationUser";
|
|
60358
60906
|
|
|
60359
|
-
function isValidUrl(url) {
|
|
60360
|
-
try {
|
|
60361
|
-
new URL(url);
|
|
60362
|
-
return true;
|
|
60363
|
-
}
|
|
60364
|
-
catch (_a) {
|
|
60365
|
-
return false;
|
|
60366
|
-
}
|
|
60367
|
-
}
|
|
60368
|
-
function determineSigningAlg(supported, preferred) {
|
|
60369
|
-
var _a;
|
|
60370
|
-
return ((_a = preferred.find((signingAlg) => {
|
|
60371
|
-
return supported.includes(signingAlg);
|
|
60372
|
-
})) !== null && _a !== void 0 ? _a : null);
|
|
60373
|
-
}
|
|
60374
|
-
function determineClientType(options, issuerConfig) {
|
|
60375
|
-
if (options.clientId !== undefined && !isValidUrl(options.clientId)) {
|
|
60376
|
-
return "static";
|
|
60377
|
-
}
|
|
60378
|
-
if (issuerConfig.scopesSupported.includes("webid") &&
|
|
60379
|
-
options.clientId !== undefined &&
|
|
60380
|
-
isValidUrl(options.clientId)) {
|
|
60381
|
-
return "solid-oidc";
|
|
60382
|
-
}
|
|
60383
|
-
return "dynamic";
|
|
60384
|
-
}
|
|
60385
|
-
async function handleRegistration(options, issuerConfig, storageUtility, clientRegistrar) {
|
|
60386
|
-
const clientType = determineClientType(options, issuerConfig);
|
|
60387
|
-
if (clientType === "dynamic") {
|
|
60388
|
-
return clientRegistrar.getClient({
|
|
60389
|
-
sessionId: options.sessionId,
|
|
60390
|
-
clientName: options.clientName,
|
|
60391
|
-
redirectUrl: options.redirectUrl,
|
|
60392
|
-
}, issuerConfig);
|
|
60393
|
-
}
|
|
60394
|
-
await storageUtility.setForUser(options.sessionId, {
|
|
60395
|
-
clientId: options.clientId,
|
|
60396
|
-
});
|
|
60397
|
-
if (options.clientSecret) {
|
|
60398
|
-
await storageUtility.setForUser(options.sessionId, {
|
|
60399
|
-
clientSecret: options.clientSecret,
|
|
60400
|
-
});
|
|
60401
|
-
}
|
|
60402
|
-
if (options.clientName) {
|
|
60403
|
-
await storageUtility.setForUser(options.sessionId, {
|
|
60404
|
-
clientName: options.clientName,
|
|
60405
|
-
});
|
|
60406
|
-
}
|
|
60407
|
-
return {
|
|
60408
|
-
clientId: options.clientId,
|
|
60409
|
-
clientSecret: options.clientSecret,
|
|
60410
|
-
clientName: options.clientName,
|
|
60411
|
-
clientType,
|
|
60412
|
-
};
|
|
60907
|
+
function isValidUrl(url) {
|
|
60908
|
+
try {
|
|
60909
|
+
new URL(url);
|
|
60910
|
+
return true;
|
|
60911
|
+
}
|
|
60912
|
+
catch (_a) {
|
|
60913
|
+
return false;
|
|
60914
|
+
}
|
|
60915
|
+
}
|
|
60916
|
+
function determineSigningAlg(supported, preferred) {
|
|
60917
|
+
var _a;
|
|
60918
|
+
return ((_a = preferred.find((signingAlg) => {
|
|
60919
|
+
return supported.includes(signingAlg);
|
|
60920
|
+
})) !== null && _a !== void 0 ? _a : null);
|
|
60921
|
+
}
|
|
60922
|
+
function determineClientType(options, issuerConfig) {
|
|
60923
|
+
if (options.clientId !== undefined && !isValidUrl(options.clientId)) {
|
|
60924
|
+
return "static";
|
|
60925
|
+
}
|
|
60926
|
+
if (issuerConfig.scopesSupported.includes("webid") &&
|
|
60927
|
+
options.clientId !== undefined &&
|
|
60928
|
+
isValidUrl(options.clientId)) {
|
|
60929
|
+
return "solid-oidc";
|
|
60930
|
+
}
|
|
60931
|
+
return "dynamic";
|
|
60932
|
+
}
|
|
60933
|
+
async function handleRegistration(options, issuerConfig, storageUtility, clientRegistrar) {
|
|
60934
|
+
const clientType = determineClientType(options, issuerConfig);
|
|
60935
|
+
if (clientType === "dynamic") {
|
|
60936
|
+
return clientRegistrar.getClient({
|
|
60937
|
+
sessionId: options.sessionId,
|
|
60938
|
+
clientName: options.clientName,
|
|
60939
|
+
redirectUrl: options.redirectUrl,
|
|
60940
|
+
}, issuerConfig);
|
|
60941
|
+
}
|
|
60942
|
+
await storageUtility.setForUser(options.sessionId, {
|
|
60943
|
+
clientId: options.clientId,
|
|
60944
|
+
});
|
|
60945
|
+
if (options.clientSecret) {
|
|
60946
|
+
await storageUtility.setForUser(options.sessionId, {
|
|
60947
|
+
clientSecret: options.clientSecret,
|
|
60948
|
+
});
|
|
60949
|
+
}
|
|
60950
|
+
if (options.clientName) {
|
|
60951
|
+
await storageUtility.setForUser(options.sessionId, {
|
|
60952
|
+
clientName: options.clientName,
|
|
60953
|
+
});
|
|
60954
|
+
}
|
|
60955
|
+
return {
|
|
60956
|
+
clientId: options.clientId,
|
|
60957
|
+
clientSecret: options.clientSecret,
|
|
60958
|
+
clientName: options.clientName,
|
|
60959
|
+
clientType,
|
|
60960
|
+
};
|
|
60413
60961
|
}
|
|
60414
60962
|
|
|
60415
|
-
async function getSessionIdFromOauthState(storageUtility, oauthState) {
|
|
60416
|
-
return storageUtility.getForUser(oauthState, "sessionId");
|
|
60417
|
-
}
|
|
60418
|
-
async function loadOidcContextFromStorage(sessionId, storageUtility, configFetcher) {
|
|
60419
|
-
try {
|
|
60420
|
-
const [issuerIri, codeVerifier, storedRedirectIri, dpop] = await Promise.all([
|
|
60421
|
-
storageUtility.getForUser(sessionId, "issuer", {
|
|
60422
|
-
errorIfNull: true,
|
|
60423
|
-
}),
|
|
60424
|
-
storageUtility.getForUser(sessionId, "codeVerifier"),
|
|
60425
|
-
storageUtility.getForUser(sessionId, "redirectUrl"),
|
|
60426
|
-
storageUtility.getForUser(sessionId, "dpop", { errorIfNull: true }),
|
|
60427
|
-
]);
|
|
60428
|
-
await storageUtility.deleteForUser(sessionId, "codeVerifier");
|
|
60429
|
-
const issuerConfig = await configFetcher.fetchConfig(issuerIri);
|
|
60430
|
-
return {
|
|
60431
|
-
codeVerifier,
|
|
60432
|
-
redirectUrl: storedRedirectIri,
|
|
60433
|
-
issuerConfig,
|
|
60434
|
-
dpop: dpop === "true",
|
|
60435
|
-
};
|
|
60436
|
-
}
|
|
60437
|
-
catch (e) {
|
|
60438
|
-
throw new Error(`Failed to retrieve OIDC context from storage associated with session [${sessionId}]: ${e}`);
|
|
60439
|
-
}
|
|
60440
|
-
}
|
|
60441
|
-
async function saveSessionInfoToStorage(storageUtility, sessionId, webId, isLoggedIn, refreshToken, secure, dpopKey) {
|
|
60442
|
-
if (refreshToken !== undefined) {
|
|
60443
|
-
await storageUtility.setForUser(sessionId, { refreshToken }, { secure });
|
|
60444
|
-
}
|
|
60445
|
-
if (webId !== undefined) {
|
|
60446
|
-
await storageUtility.setForUser(sessionId, { webId }, { secure });
|
|
60447
|
-
}
|
|
60448
|
-
if (isLoggedIn !== undefined) {
|
|
60449
|
-
await storageUtility.setForUser(sessionId, { isLoggedIn }, { secure });
|
|
60450
|
-
}
|
|
60451
|
-
if (dpopKey !== undefined) {
|
|
60452
|
-
await storageUtility.setForUser(sessionId, {
|
|
60453
|
-
publicKey: JSON.stringify(dpopKey.publicKey),
|
|
60454
|
-
privateKey: JSON.stringify(await (0,
|
|
60455
|
-
}, { secure });
|
|
60456
|
-
}
|
|
60457
|
-
}
|
|
60458
|
-
class StorageUtility {
|
|
60459
|
-
constructor(secureStorage, insecureStorage) {
|
|
60460
|
-
this.secureStorage = secureStorage;
|
|
60461
|
-
this.insecureStorage = insecureStorage;
|
|
60462
|
-
}
|
|
60463
|
-
getKey(userId) {
|
|
60464
|
-
return `solidClientAuthenticationUser:${userId}`;
|
|
60465
|
-
}
|
|
60466
|
-
async getUserData(userId, secure) {
|
|
60467
|
-
const stored = await (secure
|
|
60468
|
-
? this.secureStorage
|
|
60469
|
-
: this.insecureStorage).get(this.getKey(userId));
|
|
60470
|
-
if (stored === undefined) {
|
|
60471
|
-
return {};
|
|
60472
|
-
}
|
|
60473
|
-
try {
|
|
60474
|
-
return JSON.parse(stored);
|
|
60475
|
-
}
|
|
60476
|
-
catch (err) {
|
|
60477
|
-
throw new Error(`Data for user [${userId}] in [${secure ? "secure" : "unsecure"}] storage is corrupted - expected valid JSON, but got: ${stored}`);
|
|
60478
|
-
}
|
|
60479
|
-
}
|
|
60480
|
-
async setUserData(userId, data, secure) {
|
|
60481
|
-
await (secure ? this.secureStorage : this.insecureStorage).set(this.getKey(userId), JSON.stringify(data));
|
|
60482
|
-
}
|
|
60483
|
-
async get(key, options) {
|
|
60484
|
-
const value = await ((options === null || options === void 0 ? void 0 : options.secure)
|
|
60485
|
-
? this.secureStorage
|
|
60486
|
-
: this.insecureStorage).get(key);
|
|
60487
|
-
if (value === undefined && (options === null || options === void 0 ? void 0 : options.errorIfNull)) {
|
|
60488
|
-
throw new Error(`[${key}] is not stored`);
|
|
60489
|
-
}
|
|
60490
|
-
return value;
|
|
60491
|
-
}
|
|
60492
|
-
async set(key, value, options) {
|
|
60493
|
-
return ((options === null || options === void 0 ? void 0 : options.secure) ? this.secureStorage : this.insecureStorage).set(key, value);
|
|
60494
|
-
}
|
|
60495
|
-
async delete(key, options) {
|
|
60496
|
-
return ((options === null || options === void 0 ? void 0 : options.secure) ? this.secureStorage : this.insecureStorage).delete(key);
|
|
60497
|
-
}
|
|
60498
|
-
async getForUser(userId, key, options) {
|
|
60499
|
-
const userData = await this.getUserData(userId, options === null || options === void 0 ? void 0 : options.secure);
|
|
60500
|
-
let value;
|
|
60501
|
-
if (!userData || !userData[key]) {
|
|
60502
|
-
value = undefined;
|
|
60503
|
-
}
|
|
60504
|
-
value = userData[key];
|
|
60505
|
-
if (value === undefined && (options === null || options === void 0 ? void 0 : options.errorIfNull)) {
|
|
60506
|
-
throw new Error(`Field [${key}] for user [${userId}] is not stored`);
|
|
60507
|
-
}
|
|
60508
|
-
return value || undefined;
|
|
60509
|
-
}
|
|
60510
|
-
async setForUser(userId, values, options) {
|
|
60511
|
-
let userData;
|
|
60512
|
-
try {
|
|
60513
|
-
userData = await this.getUserData(userId, options === null || options === void 0 ? void 0 : options.secure);
|
|
60514
|
-
}
|
|
60515
|
-
catch (_a) {
|
|
60516
|
-
userData = {};
|
|
60517
|
-
}
|
|
60518
|
-
await this.setUserData(userId, { ...userData, ...values }, options === null || options === void 0 ? void 0 : options.secure);
|
|
60519
|
-
}
|
|
60520
|
-
async deleteForUser(userId, key, options) {
|
|
60521
|
-
const userData = await this.getUserData(userId, options === null || options === void 0 ? void 0 : options.secure);
|
|
60522
|
-
delete userData[key];
|
|
60523
|
-
await this.setUserData(userId, userData, options === null || options === void 0 ? void 0 : options.secure);
|
|
60524
|
-
}
|
|
60525
|
-
async deleteAllUserData(userId, options) {
|
|
60526
|
-
await ((options === null || options === void 0 ? void 0 : options.secure) ? this.secureStorage : this.insecureStorage).delete(this.getKey(userId));
|
|
60527
|
-
}
|
|
60963
|
+
async function getSessionIdFromOauthState(storageUtility, oauthState) {
|
|
60964
|
+
return storageUtility.getForUser(oauthState, "sessionId");
|
|
60965
|
+
}
|
|
60966
|
+
async function loadOidcContextFromStorage(sessionId, storageUtility, configFetcher) {
|
|
60967
|
+
try {
|
|
60968
|
+
const [issuerIri, codeVerifier, storedRedirectIri, dpop] = await Promise.all([
|
|
60969
|
+
storageUtility.getForUser(sessionId, "issuer", {
|
|
60970
|
+
errorIfNull: true,
|
|
60971
|
+
}),
|
|
60972
|
+
storageUtility.getForUser(sessionId, "codeVerifier"),
|
|
60973
|
+
storageUtility.getForUser(sessionId, "redirectUrl"),
|
|
60974
|
+
storageUtility.getForUser(sessionId, "dpop", { errorIfNull: true }),
|
|
60975
|
+
]);
|
|
60976
|
+
await storageUtility.deleteForUser(sessionId, "codeVerifier");
|
|
60977
|
+
const issuerConfig = await configFetcher.fetchConfig(issuerIri);
|
|
60978
|
+
return {
|
|
60979
|
+
codeVerifier,
|
|
60980
|
+
redirectUrl: storedRedirectIri,
|
|
60981
|
+
issuerConfig,
|
|
60982
|
+
dpop: dpop === "true",
|
|
60983
|
+
};
|
|
60984
|
+
}
|
|
60985
|
+
catch (e) {
|
|
60986
|
+
throw new Error(`Failed to retrieve OIDC context from storage associated with session [${sessionId}]: ${e}`);
|
|
60987
|
+
}
|
|
60988
|
+
}
|
|
60989
|
+
async function saveSessionInfoToStorage(storageUtility, sessionId, webId, isLoggedIn, refreshToken, secure, dpopKey) {
|
|
60990
|
+
if (refreshToken !== undefined) {
|
|
60991
|
+
await storageUtility.setForUser(sessionId, { refreshToken }, { secure });
|
|
60992
|
+
}
|
|
60993
|
+
if (webId !== undefined) {
|
|
60994
|
+
await storageUtility.setForUser(sessionId, { webId }, { secure });
|
|
60995
|
+
}
|
|
60996
|
+
if (isLoggedIn !== undefined) {
|
|
60997
|
+
await storageUtility.setForUser(sessionId, { isLoggedIn }, { secure });
|
|
60998
|
+
}
|
|
60999
|
+
if (dpopKey !== undefined) {
|
|
61000
|
+
await storageUtility.setForUser(sessionId, {
|
|
61001
|
+
publicKey: JSON.stringify(dpopKey.publicKey),
|
|
61002
|
+
privateKey: JSON.stringify(await (0,jose__WEBPACK_IMPORTED_MODULE_1__.exportJWK)(dpopKey.privateKey)),
|
|
61003
|
+
}, { secure });
|
|
61004
|
+
}
|
|
61005
|
+
}
|
|
61006
|
+
class StorageUtility {
|
|
61007
|
+
constructor(secureStorage, insecureStorage) {
|
|
61008
|
+
this.secureStorage = secureStorage;
|
|
61009
|
+
this.insecureStorage = insecureStorage;
|
|
61010
|
+
}
|
|
61011
|
+
getKey(userId) {
|
|
61012
|
+
return `solidClientAuthenticationUser:${userId}`;
|
|
61013
|
+
}
|
|
61014
|
+
async getUserData(userId, secure) {
|
|
61015
|
+
const stored = await (secure
|
|
61016
|
+
? this.secureStorage
|
|
61017
|
+
: this.insecureStorage).get(this.getKey(userId));
|
|
61018
|
+
if (stored === undefined) {
|
|
61019
|
+
return {};
|
|
61020
|
+
}
|
|
61021
|
+
try {
|
|
61022
|
+
return JSON.parse(stored);
|
|
61023
|
+
}
|
|
61024
|
+
catch (err) {
|
|
61025
|
+
throw new Error(`Data for user [${userId}] in [${secure ? "secure" : "unsecure"}] storage is corrupted - expected valid JSON, but got: ${stored}`);
|
|
61026
|
+
}
|
|
61027
|
+
}
|
|
61028
|
+
async setUserData(userId, data, secure) {
|
|
61029
|
+
await (secure ? this.secureStorage : this.insecureStorage).set(this.getKey(userId), JSON.stringify(data));
|
|
61030
|
+
}
|
|
61031
|
+
async get(key, options) {
|
|
61032
|
+
const value = await ((options === null || options === void 0 ? void 0 : options.secure)
|
|
61033
|
+
? this.secureStorage
|
|
61034
|
+
: this.insecureStorage).get(key);
|
|
61035
|
+
if (value === undefined && (options === null || options === void 0 ? void 0 : options.errorIfNull)) {
|
|
61036
|
+
throw new Error(`[${key}] is not stored`);
|
|
61037
|
+
}
|
|
61038
|
+
return value;
|
|
61039
|
+
}
|
|
61040
|
+
async set(key, value, options) {
|
|
61041
|
+
return ((options === null || options === void 0 ? void 0 : options.secure) ? this.secureStorage : this.insecureStorage).set(key, value);
|
|
61042
|
+
}
|
|
61043
|
+
async delete(key, options) {
|
|
61044
|
+
return ((options === null || options === void 0 ? void 0 : options.secure) ? this.secureStorage : this.insecureStorage).delete(key);
|
|
61045
|
+
}
|
|
61046
|
+
async getForUser(userId, key, options) {
|
|
61047
|
+
const userData = await this.getUserData(userId, options === null || options === void 0 ? void 0 : options.secure);
|
|
61048
|
+
let value;
|
|
61049
|
+
if (!userData || !userData[key]) {
|
|
61050
|
+
value = undefined;
|
|
61051
|
+
}
|
|
61052
|
+
value = userData[key];
|
|
61053
|
+
if (value === undefined && (options === null || options === void 0 ? void 0 : options.errorIfNull)) {
|
|
61054
|
+
throw new Error(`Field [${key}] for user [${userId}] is not stored`);
|
|
61055
|
+
}
|
|
61056
|
+
return value || undefined;
|
|
61057
|
+
}
|
|
61058
|
+
async setForUser(userId, values, options) {
|
|
61059
|
+
let userData;
|
|
61060
|
+
try {
|
|
61061
|
+
userData = await this.getUserData(userId, options === null || options === void 0 ? void 0 : options.secure);
|
|
61062
|
+
}
|
|
61063
|
+
catch (_a) {
|
|
61064
|
+
userData = {};
|
|
61065
|
+
}
|
|
61066
|
+
await this.setUserData(userId, { ...userData, ...values }, options === null || options === void 0 ? void 0 : options.secure);
|
|
61067
|
+
}
|
|
61068
|
+
async deleteForUser(userId, key, options) {
|
|
61069
|
+
const userData = await this.getUserData(userId, options === null || options === void 0 ? void 0 : options.secure);
|
|
61070
|
+
delete userData[key];
|
|
61071
|
+
await this.setUserData(userId, userData, options === null || options === void 0 ? void 0 : options.secure);
|
|
61072
|
+
}
|
|
61073
|
+
async deleteAllUserData(userId, options) {
|
|
61074
|
+
await ((options === null || options === void 0 ? void 0 : options.secure) ? this.secureStorage : this.insecureStorage).delete(this.getKey(userId));
|
|
61075
|
+
}
|
|
60528
61076
|
}
|
|
60529
61077
|
|
|
60530
|
-
class InMemoryStorage {
|
|
60531
|
-
constructor() {
|
|
60532
|
-
this.map = {};
|
|
60533
|
-
}
|
|
60534
|
-
async get(key) {
|
|
60535
|
-
return this.map[key] || undefined;
|
|
60536
|
-
}
|
|
60537
|
-
async set(key, value) {
|
|
60538
|
-
this.map[key] = value;
|
|
60539
|
-
}
|
|
60540
|
-
async delete(key) {
|
|
60541
|
-
delete this.map[key];
|
|
60542
|
-
}
|
|
61078
|
+
class InMemoryStorage {
|
|
61079
|
+
constructor() {
|
|
61080
|
+
this.map = {};
|
|
61081
|
+
}
|
|
61082
|
+
async get(key) {
|
|
61083
|
+
return this.map[key] || undefined;
|
|
61084
|
+
}
|
|
61085
|
+
async set(key, value) {
|
|
61086
|
+
this.map[key] = value;
|
|
61087
|
+
}
|
|
61088
|
+
async delete(key) {
|
|
61089
|
+
delete this.map[key];
|
|
61090
|
+
}
|
|
60543
61091
|
}
|
|
60544
61092
|
|
|
60545
|
-
class ConfigurationError extends Error {
|
|
60546
|
-
constructor(message) {
|
|
60547
|
-
super(message);
|
|
60548
|
-
}
|
|
61093
|
+
class ConfigurationError extends Error {
|
|
61094
|
+
constructor(message) {
|
|
61095
|
+
super(message);
|
|
61096
|
+
}
|
|
60549
61097
|
}
|
|
60550
61098
|
|
|
60551
|
-
class NotImplementedError extends Error {
|
|
60552
|
-
constructor(methodName) {
|
|
60553
|
-
super(`[${methodName}] is not implemented`);
|
|
60554
|
-
}
|
|
61099
|
+
class NotImplementedError extends Error {
|
|
61100
|
+
constructor(methodName) {
|
|
61101
|
+
super(`[${methodName}] is not implemented`);
|
|
61102
|
+
}
|
|
60555
61103
|
}
|
|
60556
61104
|
|
|
60557
|
-
class InvalidResponseError extends Error {
|
|
60558
|
-
constructor(missingFields) {
|
|
60559
|
-
super(`Invalid response from OIDC provider: missing fields ${missingFields}`);
|
|
60560
|
-
this.missingFields = missingFields;
|
|
60561
|
-
}
|
|
61105
|
+
class InvalidResponseError extends Error {
|
|
61106
|
+
constructor(missingFields) {
|
|
61107
|
+
super(`Invalid response from OIDC provider: missing fields ${missingFields}`);
|
|
61108
|
+
this.missingFields = missingFields;
|
|
61109
|
+
}
|
|
60562
61110
|
}
|
|
60563
61111
|
|
|
60564
|
-
class OidcProviderError extends Error {
|
|
60565
|
-
constructor(message, error, errorDescription) {
|
|
60566
|
-
super(message);
|
|
60567
|
-
this.error = error;
|
|
60568
|
-
this.errorDescription = errorDescription;
|
|
60569
|
-
}
|
|
61112
|
+
class OidcProviderError extends Error {
|
|
61113
|
+
constructor(message, error, errorDescription) {
|
|
61114
|
+
super(message);
|
|
61115
|
+
this.error = error;
|
|
61116
|
+
this.errorDescription = errorDescription;
|
|
61117
|
+
}
|
|
60570
61118
|
}
|
|
60571
61119
|
|
|
60572
|
-
function normalizeHTU(audience) {
|
|
60573
|
-
const audienceUrl = new URL(audience);
|
|
60574
|
-
return new URL(audienceUrl.pathname, audienceUrl.origin).toString();
|
|
60575
|
-
}
|
|
60576
|
-
async function createDpopHeader(audience, method, dpopKey) {
|
|
60577
|
-
return new
|
|
60578
|
-
htu: normalizeHTU(audience),
|
|
60579
|
-
htm: method.toUpperCase(),
|
|
60580
|
-
jti: (0,uuid__WEBPACK_IMPORTED_MODULE_3__["default"])(),
|
|
60581
|
-
})
|
|
60582
|
-
.setProtectedHeader({
|
|
60583
|
-
alg: PREFERRED_SIGNING_ALG[0],
|
|
60584
|
-
jwk: dpopKey.publicKey,
|
|
60585
|
-
typ: "dpop+jwt",
|
|
60586
|
-
})
|
|
60587
|
-
.setIssuedAt()
|
|
60588
|
-
.sign(dpopKey.privateKey, {});
|
|
60589
|
-
}
|
|
60590
|
-
async function generateDpopKeyPair() {
|
|
60591
|
-
const { privateKey, publicKey } = await (0,
|
|
60592
|
-
const dpopKeyPair = {
|
|
60593
|
-
privateKey,
|
|
60594
|
-
publicKey: await (0,
|
|
60595
|
-
};
|
|
60596
|
-
[dpopKeyPair.publicKey.alg] = PREFERRED_SIGNING_ALG;
|
|
60597
|
-
return dpopKeyPair;
|
|
61120
|
+
function normalizeHTU(audience) {
|
|
61121
|
+
const audienceUrl = new URL(audience);
|
|
61122
|
+
return new URL(audienceUrl.pathname, audienceUrl.origin).toString();
|
|
61123
|
+
}
|
|
61124
|
+
async function createDpopHeader(audience, method, dpopKey) {
|
|
61125
|
+
return new jose__WEBPACK_IMPORTED_MODULE_1__.SignJWT({
|
|
61126
|
+
htu: normalizeHTU(audience),
|
|
61127
|
+
htm: method.toUpperCase(),
|
|
61128
|
+
jti: (0,uuid__WEBPACK_IMPORTED_MODULE_3__["default"])(),
|
|
61129
|
+
})
|
|
61130
|
+
.setProtectedHeader({
|
|
61131
|
+
alg: PREFERRED_SIGNING_ALG[0],
|
|
61132
|
+
jwk: dpopKey.publicKey,
|
|
61133
|
+
typ: "dpop+jwt",
|
|
61134
|
+
})
|
|
61135
|
+
.setIssuedAt()
|
|
61136
|
+
.sign(dpopKey.privateKey, {});
|
|
61137
|
+
}
|
|
61138
|
+
async function generateDpopKeyPair() {
|
|
61139
|
+
const { privateKey, publicKey } = await (0,jose__WEBPACK_IMPORTED_MODULE_1__.generateKeyPair)(PREFERRED_SIGNING_ALG[0]);
|
|
61140
|
+
const dpopKeyPair = {
|
|
61141
|
+
privateKey,
|
|
61142
|
+
publicKey: await (0,jose__WEBPACK_IMPORTED_MODULE_1__.exportJWK)(publicKey),
|
|
61143
|
+
};
|
|
61144
|
+
[dpopKeyPair.publicKey.alg] = PREFERRED_SIGNING_ALG;
|
|
61145
|
+
return dpopKeyPair;
|
|
60598
61146
|
}
|
|
60599
61147
|
|
|
60600
|
-
const DEFAULT_EXPIRATION_TIME_SECONDS = 600;
|
|
60601
|
-
function isExpectedAuthError(statusCode) {
|
|
60602
|
-
return [401, 403].includes(statusCode);
|
|
60603
|
-
}
|
|
60604
|
-
async function buildDpopFetchOptions(targetUrl, authToken, dpopKey, defaultOptions) {
|
|
60605
|
-
var _a;
|
|
60606
|
-
const headers = new
|
|
60607
|
-
headers.set("Authorization", `DPoP ${authToken}`);
|
|
60608
|
-
headers.set("DPoP", await createDpopHeader(targetUrl, (_a = defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.method) !== null && _a !== void 0 ? _a : "get", dpopKey));
|
|
60609
|
-
return {
|
|
60610
|
-
...defaultOptions,
|
|
60611
|
-
headers,
|
|
60612
|
-
};
|
|
60613
|
-
}
|
|
60614
|
-
async function buildAuthenticatedHeaders(targetUrl, authToken, dpopKey, defaultOptions) {
|
|
60615
|
-
if (dpopKey !== undefined) {
|
|
60616
|
-
return buildDpopFetchOptions(targetUrl, authToken, dpopKey, defaultOptions);
|
|
60617
|
-
}
|
|
60618
|
-
const headers = new
|
|
60619
|
-
headers.set("Authorization", `Bearer ${authToken}`);
|
|
60620
|
-
return {
|
|
60621
|
-
...defaultOptions,
|
|
60622
|
-
headers,
|
|
60623
|
-
};
|
|
60624
|
-
}
|
|
60625
|
-
async function makeAuthenticatedRequest(unauthFetch, accessToken, url, defaultRequestInit, dpopKey) {
|
|
60626
|
-
return unauthFetch(url, await buildAuthenticatedHeaders(url.toString(), accessToken, dpopKey, defaultRequestInit));
|
|
60627
|
-
}
|
|
60628
|
-
async function refreshAccessToken(refreshOptions, dpopKey, eventEmitter) {
|
|
60629
|
-
var _a;
|
|
60630
|
-
const tokenSet = await refreshOptions.tokenRefresher.refresh(refreshOptions.sessionId, refreshOptions.refreshToken, dpopKey);
|
|
60631
|
-
eventEmitter === null || eventEmitter === void 0 ? void 0 : eventEmitter.emit(EVENTS.SESSION_EXTENDED, (_a = tokenSet.expiresIn) !== null && _a !== void 0 ? _a : DEFAULT_EXPIRATION_TIME_SECONDS);
|
|
60632
|
-
if (typeof tokenSet.refreshToken === "string") {
|
|
60633
|
-
eventEmitter === null || eventEmitter === void 0 ? void 0 : eventEmitter.emit(EVENTS.NEW_REFRESH_TOKEN, tokenSet.refreshToken);
|
|
60634
|
-
}
|
|
60635
|
-
return {
|
|
60636
|
-
accessToken: tokenSet.accessToken,
|
|
60637
|
-
refreshToken: tokenSet.refreshToken,
|
|
60638
|
-
expiresIn: tokenSet.expiresIn,
|
|
60639
|
-
};
|
|
60640
|
-
}
|
|
60641
|
-
const computeRefreshDelay = (expiresIn) => {
|
|
60642
|
-
if (expiresIn !== undefined) {
|
|
60643
|
-
return expiresIn - REFRESH_BEFORE_EXPIRATION_SECONDS > 0
|
|
60644
|
-
?
|
|
60645
|
-
expiresIn - REFRESH_BEFORE_EXPIRATION_SECONDS
|
|
60646
|
-
: expiresIn;
|
|
60647
|
-
}
|
|
60648
|
-
return DEFAULT_EXPIRATION_TIME_SECONDS;
|
|
60649
|
-
};
|
|
60650
|
-
async function buildAuthenticatedFetch(unauthFetch, accessToken, options) {
|
|
60651
|
-
var _a;
|
|
60652
|
-
let currentAccessToken = accessToken;
|
|
60653
|
-
let latestTimeout;
|
|
60654
|
-
const currentRefreshOptions = options === null || options === void 0 ? void 0 : options.refreshOptions;
|
|
60655
|
-
if (currentRefreshOptions !== undefined) {
|
|
60656
|
-
const proactivelyRefreshToken = async () => {
|
|
60657
|
-
var _a, _b, _c, _d;
|
|
60658
|
-
try {
|
|
60659
|
-
const { accessToken: refreshedAccessToken, refreshToken, expiresIn, } = await refreshAccessToken(currentRefreshOptions, options.dpopKey, options.eventEmitter);
|
|
60660
|
-
currentAccessToken = refreshedAccessToken;
|
|
60661
|
-
if (refreshToken !== undefined) {
|
|
60662
|
-
currentRefreshOptions.refreshToken = refreshToken;
|
|
60663
|
-
}
|
|
60664
|
-
clearTimeout(latestTimeout);
|
|
60665
|
-
latestTimeout = setTimeout(proactivelyRefreshToken, computeRefreshDelay(expiresIn) * 1000);
|
|
60666
|
-
(_a = options.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit(EVENTS.TIMEOUT_SET, latestTimeout);
|
|
60667
|
-
}
|
|
60668
|
-
catch (e) {
|
|
60669
|
-
if (e instanceof OidcProviderError) {
|
|
60670
|
-
(_b = options === null || options === void 0 ? void 0 : options.eventEmitter) === null || _b === void 0 ? void 0 : _b.emit(EVENTS.ERROR, e.error, e.errorDescription);
|
|
60671
|
-
(_c = options === null || options === void 0 ? void 0 : options.eventEmitter) === null || _c === void 0 ? void 0 : _c.emit(EVENTS.SESSION_EXPIRED);
|
|
60672
|
-
}
|
|
60673
|
-
if (e instanceof InvalidResponseError &&
|
|
60674
|
-
e.missingFields.includes("access_token")) {
|
|
60675
|
-
(_d = options === null || options === void 0 ? void 0 : options.eventEmitter) === null || _d === void 0 ? void 0 : _d.emit(EVENTS.SESSION_EXPIRED);
|
|
60676
|
-
}
|
|
60677
|
-
}
|
|
60678
|
-
};
|
|
60679
|
-
latestTimeout = setTimeout(proactivelyRefreshToken, computeRefreshDelay(options.expiresIn) * 1000);
|
|
60680
|
-
(_a = options.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit(EVENTS.TIMEOUT_SET, latestTimeout);
|
|
60681
|
-
}
|
|
60682
|
-
else if (options !== undefined && options.eventEmitter !== undefined) {
|
|
60683
|
-
const expirationTimeout = setTimeout(() => {
|
|
60684
|
-
options.eventEmitter.emit(EVENTS.SESSION_EXPIRED);
|
|
60685
|
-
}, computeRefreshDelay(options.expiresIn) * 1000);
|
|
60686
|
-
options.eventEmitter.emit(EVENTS.TIMEOUT_SET, expirationTimeout);
|
|
60687
|
-
}
|
|
60688
|
-
return async (url, requestInit) => {
|
|
60689
|
-
let response = await makeAuthenticatedRequest(unauthFetch, currentAccessToken, url, requestInit, options === null || options === void 0 ? void 0 : options.dpopKey);
|
|
60690
|
-
const failedButNotExpectedAuthError = !response.ok && !isExpectedAuthError(response.status);
|
|
60691
|
-
if (response.ok || failedButNotExpectedAuthError) {
|
|
60692
|
-
return response;
|
|
60693
|
-
}
|
|
60694
|
-
const hasBeenRedirected = response.url !== url;
|
|
60695
|
-
if (hasBeenRedirected && (options === null || options === void 0 ? void 0 : options.dpopKey) !== undefined) {
|
|
60696
|
-
response = await makeAuthenticatedRequest(unauthFetch, currentAccessToken, response.url, requestInit, options.dpopKey);
|
|
60697
|
-
}
|
|
60698
|
-
return response;
|
|
60699
|
-
};
|
|
61148
|
+
const DEFAULT_EXPIRATION_TIME_SECONDS = 600;
|
|
61149
|
+
function isExpectedAuthError(statusCode) {
|
|
61150
|
+
return [401, 403].includes(statusCode);
|
|
61151
|
+
}
|
|
61152
|
+
async function buildDpopFetchOptions(targetUrl, authToken, dpopKey, defaultOptions) {
|
|
61153
|
+
var _a;
|
|
61154
|
+
const headers = new _inrupt_universal_fetch__WEBPACK_IMPORTED_MODULE_2__.Headers(defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.headers);
|
|
61155
|
+
headers.set("Authorization", `DPoP ${authToken}`);
|
|
61156
|
+
headers.set("DPoP", await createDpopHeader(targetUrl, (_a = defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.method) !== null && _a !== void 0 ? _a : "get", dpopKey));
|
|
61157
|
+
return {
|
|
61158
|
+
...defaultOptions,
|
|
61159
|
+
headers,
|
|
61160
|
+
};
|
|
61161
|
+
}
|
|
61162
|
+
async function buildAuthenticatedHeaders(targetUrl, authToken, dpopKey, defaultOptions) {
|
|
61163
|
+
if (dpopKey !== undefined) {
|
|
61164
|
+
return buildDpopFetchOptions(targetUrl, authToken, dpopKey, defaultOptions);
|
|
61165
|
+
}
|
|
61166
|
+
const headers = new _inrupt_universal_fetch__WEBPACK_IMPORTED_MODULE_2__.Headers(defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.headers);
|
|
61167
|
+
headers.set("Authorization", `Bearer ${authToken}`);
|
|
61168
|
+
return {
|
|
61169
|
+
...defaultOptions,
|
|
61170
|
+
headers,
|
|
61171
|
+
};
|
|
61172
|
+
}
|
|
61173
|
+
async function makeAuthenticatedRequest(unauthFetch, accessToken, url, defaultRequestInit, dpopKey) {
|
|
61174
|
+
return unauthFetch(url, await buildAuthenticatedHeaders(url.toString(), accessToken, dpopKey, defaultRequestInit));
|
|
61175
|
+
}
|
|
61176
|
+
async function refreshAccessToken(refreshOptions, dpopKey, eventEmitter) {
|
|
61177
|
+
var _a;
|
|
61178
|
+
const tokenSet = await refreshOptions.tokenRefresher.refresh(refreshOptions.sessionId, refreshOptions.refreshToken, dpopKey);
|
|
61179
|
+
eventEmitter === null || eventEmitter === void 0 ? void 0 : eventEmitter.emit(EVENTS.SESSION_EXTENDED, (_a = tokenSet.expiresIn) !== null && _a !== void 0 ? _a : DEFAULT_EXPIRATION_TIME_SECONDS);
|
|
61180
|
+
if (typeof tokenSet.refreshToken === "string") {
|
|
61181
|
+
eventEmitter === null || eventEmitter === void 0 ? void 0 : eventEmitter.emit(EVENTS.NEW_REFRESH_TOKEN, tokenSet.refreshToken);
|
|
61182
|
+
}
|
|
61183
|
+
return {
|
|
61184
|
+
accessToken: tokenSet.accessToken,
|
|
61185
|
+
refreshToken: tokenSet.refreshToken,
|
|
61186
|
+
expiresIn: tokenSet.expiresIn,
|
|
61187
|
+
};
|
|
61188
|
+
}
|
|
61189
|
+
const computeRefreshDelay = (expiresIn) => {
|
|
61190
|
+
if (expiresIn !== undefined) {
|
|
61191
|
+
return expiresIn - REFRESH_BEFORE_EXPIRATION_SECONDS > 0
|
|
61192
|
+
?
|
|
61193
|
+
expiresIn - REFRESH_BEFORE_EXPIRATION_SECONDS
|
|
61194
|
+
: expiresIn;
|
|
61195
|
+
}
|
|
61196
|
+
return DEFAULT_EXPIRATION_TIME_SECONDS;
|
|
61197
|
+
};
|
|
61198
|
+
async function buildAuthenticatedFetch(unauthFetch, accessToken, options) {
|
|
61199
|
+
var _a;
|
|
61200
|
+
let currentAccessToken = accessToken;
|
|
61201
|
+
let latestTimeout;
|
|
61202
|
+
const currentRefreshOptions = options === null || options === void 0 ? void 0 : options.refreshOptions;
|
|
61203
|
+
if (currentRefreshOptions !== undefined) {
|
|
61204
|
+
const proactivelyRefreshToken = async () => {
|
|
61205
|
+
var _a, _b, _c, _d;
|
|
61206
|
+
try {
|
|
61207
|
+
const { accessToken: refreshedAccessToken, refreshToken, expiresIn, } = await refreshAccessToken(currentRefreshOptions, options.dpopKey, options.eventEmitter);
|
|
61208
|
+
currentAccessToken = refreshedAccessToken;
|
|
61209
|
+
if (refreshToken !== undefined) {
|
|
61210
|
+
currentRefreshOptions.refreshToken = refreshToken;
|
|
61211
|
+
}
|
|
61212
|
+
clearTimeout(latestTimeout);
|
|
61213
|
+
latestTimeout = setTimeout(proactivelyRefreshToken, computeRefreshDelay(expiresIn) * 1000);
|
|
61214
|
+
(_a = options.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit(EVENTS.TIMEOUT_SET, latestTimeout);
|
|
61215
|
+
}
|
|
61216
|
+
catch (e) {
|
|
61217
|
+
if (e instanceof OidcProviderError) {
|
|
61218
|
+
(_b = options === null || options === void 0 ? void 0 : options.eventEmitter) === null || _b === void 0 ? void 0 : _b.emit(EVENTS.ERROR, e.error, e.errorDescription);
|
|
61219
|
+
(_c = options === null || options === void 0 ? void 0 : options.eventEmitter) === null || _c === void 0 ? void 0 : _c.emit(EVENTS.SESSION_EXPIRED);
|
|
61220
|
+
}
|
|
61221
|
+
if (e instanceof InvalidResponseError &&
|
|
61222
|
+
e.missingFields.includes("access_token")) {
|
|
61223
|
+
(_d = options === null || options === void 0 ? void 0 : options.eventEmitter) === null || _d === void 0 ? void 0 : _d.emit(EVENTS.SESSION_EXPIRED);
|
|
61224
|
+
}
|
|
61225
|
+
}
|
|
61226
|
+
};
|
|
61227
|
+
latestTimeout = setTimeout(proactivelyRefreshToken, computeRefreshDelay(options.expiresIn) * 1000);
|
|
61228
|
+
(_a = options.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit(EVENTS.TIMEOUT_SET, latestTimeout);
|
|
61229
|
+
}
|
|
61230
|
+
else if (options !== undefined && options.eventEmitter !== undefined) {
|
|
61231
|
+
const expirationTimeout = setTimeout(() => {
|
|
61232
|
+
options.eventEmitter.emit(EVENTS.SESSION_EXPIRED);
|
|
61233
|
+
}, computeRefreshDelay(options.expiresIn) * 1000);
|
|
61234
|
+
options.eventEmitter.emit(EVENTS.TIMEOUT_SET, expirationTimeout);
|
|
61235
|
+
}
|
|
61236
|
+
return async (url, requestInit) => {
|
|
61237
|
+
let response = await makeAuthenticatedRequest(unauthFetch, currentAccessToken, url, requestInit, options === null || options === void 0 ? void 0 : options.dpopKey);
|
|
61238
|
+
const failedButNotExpectedAuthError = !response.ok && !isExpectedAuthError(response.status);
|
|
61239
|
+
if (response.ok || failedButNotExpectedAuthError) {
|
|
61240
|
+
return response;
|
|
61241
|
+
}
|
|
61242
|
+
const hasBeenRedirected = response.url !== url;
|
|
61243
|
+
if (hasBeenRedirected && (options === null || options === void 0 ? void 0 : options.dpopKey) !== undefined) {
|
|
61244
|
+
response = await makeAuthenticatedRequest(unauthFetch, currentAccessToken, response.url, requestInit, options.dpopKey);
|
|
61245
|
+
}
|
|
61246
|
+
return response;
|
|
61247
|
+
};
|
|
60700
61248
|
}
|
|
60701
61249
|
|
|
60702
|
-
const StorageUtilityGetResponse = "getResponse";
|
|
60703
|
-
const StorageUtilityMock = {
|
|
60704
|
-
get: async (key, options) => StorageUtilityGetResponse,
|
|
60705
|
-
set: async (key, value) => {
|
|
60706
|
-
},
|
|
60707
|
-
delete: async (key) => {
|
|
60708
|
-
},
|
|
60709
|
-
getForUser: async (userId, key, options) => StorageUtilityGetResponse,
|
|
60710
|
-
setForUser: async (userId, values, options) => {
|
|
60711
|
-
},
|
|
60712
|
-
deleteForUser: async (userId, key, options) => {
|
|
60713
|
-
},
|
|
60714
|
-
deleteAllUserData: async (userId, options) => {
|
|
60715
|
-
},
|
|
60716
|
-
};
|
|
60717
|
-
const mockStorage = (stored) => {
|
|
60718
|
-
const store = stored;
|
|
60719
|
-
return {
|
|
60720
|
-
get: async (key) => {
|
|
60721
|
-
if (store[key] === undefined) {
|
|
60722
|
-
return undefined;
|
|
60723
|
-
}
|
|
60724
|
-
if (typeof store[key] === "string") {
|
|
60725
|
-
return store[key];
|
|
60726
|
-
}
|
|
60727
|
-
return JSON.stringify(store[key]);
|
|
60728
|
-
},
|
|
60729
|
-
set: async (key, value) => {
|
|
60730
|
-
store[key] = value;
|
|
60731
|
-
},
|
|
60732
|
-
delete: async (key) => {
|
|
60733
|
-
delete store[key];
|
|
60734
|
-
},
|
|
60735
|
-
};
|
|
60736
|
-
};
|
|
60737
|
-
const mockStorageUtility = (stored, isSecure = false) => {
|
|
60738
|
-
if (isSecure) {
|
|
60739
|
-
return new StorageUtility(mockStorage(stored), mockStorage({}));
|
|
60740
|
-
}
|
|
60741
|
-
return new StorageUtility(mockStorage({}), mockStorage(stored));
|
|
61250
|
+
const StorageUtilityGetResponse = "getResponse";
|
|
61251
|
+
const StorageUtilityMock = {
|
|
61252
|
+
get: async (key, options) => StorageUtilityGetResponse,
|
|
61253
|
+
set: async (key, value) => {
|
|
61254
|
+
},
|
|
61255
|
+
delete: async (key) => {
|
|
61256
|
+
},
|
|
61257
|
+
getForUser: async (userId, key, options) => StorageUtilityGetResponse,
|
|
61258
|
+
setForUser: async (userId, values, options) => {
|
|
61259
|
+
},
|
|
61260
|
+
deleteForUser: async (userId, key, options) => {
|
|
61261
|
+
},
|
|
61262
|
+
deleteAllUserData: async (userId, options) => {
|
|
61263
|
+
},
|
|
61264
|
+
};
|
|
61265
|
+
const mockStorage = (stored) => {
|
|
61266
|
+
const store = stored;
|
|
61267
|
+
return {
|
|
61268
|
+
get: async (key) => {
|
|
61269
|
+
if (store[key] === undefined) {
|
|
61270
|
+
return undefined;
|
|
61271
|
+
}
|
|
61272
|
+
if (typeof store[key] === "string") {
|
|
61273
|
+
return store[key];
|
|
61274
|
+
}
|
|
61275
|
+
return JSON.stringify(store[key]);
|
|
61276
|
+
},
|
|
61277
|
+
set: async (key, value) => {
|
|
61278
|
+
store[key] = value;
|
|
61279
|
+
},
|
|
61280
|
+
delete: async (key) => {
|
|
61281
|
+
delete store[key];
|
|
61282
|
+
},
|
|
61283
|
+
};
|
|
61284
|
+
};
|
|
61285
|
+
const mockStorageUtility = (stored, isSecure = false) => {
|
|
61286
|
+
if (isSecure) {
|
|
61287
|
+
return new StorageUtility(mockStorage(stored), mockStorage({}));
|
|
61288
|
+
}
|
|
61289
|
+
return new StorageUtility(mockStorage({}), mockStorage(stored));
|
|
60742
61290
|
};
|
|
60743
61291
|
|
|
60744
61292
|
|
|
60745
61293
|
|
|
60746
61294
|
|
|
61295
|
+
/***/ }),
|
|
61296
|
+
|
|
61297
|
+
/***/ "./node_modules/@inrupt/universal-fetch/dist/index-browser.mjs":
|
|
61298
|
+
/*!*********************************************************************!*\
|
|
61299
|
+
!*** ./node_modules/@inrupt/universal-fetch/dist/index-browser.mjs ***!
|
|
61300
|
+
\*********************************************************************/
|
|
61301
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
61302
|
+
|
|
61303
|
+
"use strict";
|
|
61304
|
+
__webpack_require__.r(__webpack_exports__);
|
|
61305
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
61306
|
+
/* harmony export */ "Headers": () => (/* binding */ Headers),
|
|
61307
|
+
/* harmony export */ "Request": () => (/* binding */ Request),
|
|
61308
|
+
/* harmony export */ "Response": () => (/* binding */ Response),
|
|
61309
|
+
/* harmony export */ "default": () => (/* binding */ indexBrowser),
|
|
61310
|
+
/* harmony export */ "fetch": () => (/* binding */ fetch)
|
|
61311
|
+
/* harmony export */ });
|
|
61312
|
+
var indexBrowser = globalThis.fetch;
|
|
61313
|
+
const { fetch, Response, Request, Headers } = globalThis;
|
|
61314
|
+
|
|
61315
|
+
|
|
61316
|
+
|
|
61317
|
+
|
|
60747
61318
|
/***/ }),
|
|
60748
61319
|
|
|
60749
61320
|
/***/ "./node_modules/jose/dist/browser/index.js":
|
|
@@ -61811,14 +62382,17 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
61811
62382
|
/* harmony export */ "createRemoteJWKSet": () => (/* binding */ createRemoteJWKSet)
|
|
61812
62383
|
/* harmony export */ });
|
|
61813
62384
|
/* 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");
|
|
61814
|
-
/* harmony import */ var
|
|
61815
|
-
/* harmony import */ var
|
|
61816
|
-
/* harmony import */ var _local_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./local.js */ "./node_modules/jose/dist/browser/jwks/local.js");
|
|
61817
|
-
|
|
62385
|
+
/* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
|
|
62386
|
+
/* harmony import */ var _local_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./local.js */ "./node_modules/jose/dist/browser/jwks/local.js");
|
|
61818
62387
|
|
|
61819
62388
|
|
|
61820
62389
|
|
|
61821
|
-
|
|
62390
|
+
function isCloudflareWorkers() {
|
|
62391
|
+
return (typeof WebSocketPair !== 'undefined' ||
|
|
62392
|
+
(typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers') ||
|
|
62393
|
+
(typeof EdgeRuntime !== 'undefined' && EdgeRuntime === 'vercel'));
|
|
62394
|
+
}
|
|
62395
|
+
class RemoteJWKSet extends _local_js__WEBPACK_IMPORTED_MODULE_2__.LocalJWKSet {
|
|
61822
62396
|
constructor(url, options) {
|
|
61823
62397
|
super({ keys: [] });
|
|
61824
62398
|
this._jwks = undefined;
|
|
@@ -61851,7 +62425,7 @@ class RemoteJWKSet extends _local_js__WEBPACK_IMPORTED_MODULE_3__.LocalJWKSet {
|
|
|
61851
62425
|
return await super.getKey(protectedHeader, token);
|
|
61852
62426
|
}
|
|
61853
62427
|
catch (err) {
|
|
61854
|
-
if (err instanceof
|
|
62428
|
+
if (err instanceof _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JWKSNoMatchingKey) {
|
|
61855
62429
|
if (this.coolingDown() === false) {
|
|
61856
62430
|
await this.reload();
|
|
61857
62431
|
return super.getKey(protectedHeader, token);
|
|
@@ -61861,13 +62435,13 @@ class RemoteJWKSet extends _local_js__WEBPACK_IMPORTED_MODULE_3__.LocalJWKSet {
|
|
|
61861
62435
|
}
|
|
61862
62436
|
}
|
|
61863
62437
|
async reload() {
|
|
61864
|
-
if (this._pendingFetch &&
|
|
62438
|
+
if (this._pendingFetch && isCloudflareWorkers()) {
|
|
61865
62439
|
this._pendingFetch = undefined;
|
|
61866
62440
|
}
|
|
61867
62441
|
this._pendingFetch || (this._pendingFetch = (0,_runtime_fetch_jwks_js__WEBPACK_IMPORTED_MODULE_0__["default"])(this._url, this._timeoutDuration, this._options)
|
|
61868
62442
|
.then((json) => {
|
|
61869
|
-
if (!(0,
|
|
61870
|
-
throw new
|
|
62443
|
+
if (!(0,_local_js__WEBPACK_IMPORTED_MODULE_2__.isJWKSLike)(json)) {
|
|
62444
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JWKSInvalid('JSON Web Key Set malformed');
|
|
61871
62445
|
}
|
|
61872
62446
|
this._jwks = { keys: json.keys };
|
|
61873
62447
|
this._jwksTimestamp = Date.now();
|
|
@@ -63055,8 +63629,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
63055
63629
|
/* harmony export */ "checkEncCryptoKey": () => (/* binding */ checkEncCryptoKey),
|
|
63056
63630
|
/* harmony export */ "checkSigCryptoKey": () => (/* binding */ checkSigCryptoKey)
|
|
63057
63631
|
/* harmony export */ });
|
|
63058
|
-
/* harmony import */ var _runtime_env_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../runtime/env.js */ "./node_modules/jose/dist/browser/runtime/env.js");
|
|
63059
|
-
|
|
63060
63632
|
function unusable(name, prop = 'algorithm.name') {
|
|
63061
63633
|
return new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
|
|
63062
63634
|
}
|
|
@@ -63131,11 +63703,6 @@ function checkSigCryptoKey(key, alg, ...usages) {
|
|
|
63131
63703
|
}
|
|
63132
63704
|
case 'EdDSA': {
|
|
63133
63705
|
if (key.algorithm.name !== 'Ed25519' && key.algorithm.name !== 'Ed448') {
|
|
63134
|
-
if ((0,_runtime_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)()) {
|
|
63135
|
-
if (isAlgorithm(key.algorithm, 'NODE-ED25519'))
|
|
63136
|
-
break;
|
|
63137
|
-
throw unusable('Ed25519, Ed448, or NODE-ED25519');
|
|
63138
|
-
}
|
|
63139
63706
|
throw unusable('Ed25519 or Ed448');
|
|
63140
63707
|
}
|
|
63141
63708
|
break;
|
|
@@ -63966,14 +64533,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
63966
64533
|
/* harmony export */ "toPKCS8": () => (/* binding */ toPKCS8),
|
|
63967
64534
|
/* harmony export */ "toSPKI": () => (/* binding */ toSPKI)
|
|
63968
64535
|
/* harmony export */ });
|
|
63969
|
-
/* harmony import */ var
|
|
63970
|
-
/* harmony import */ var
|
|
63971
|
-
/* harmony import */ var
|
|
63972
|
-
/* harmony import */ var
|
|
63973
|
-
/* harmony import */ var
|
|
63974
|
-
/* harmony import */ var
|
|
63975
|
-
/* 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");
|
|
63976
|
-
|
|
64536
|
+
/* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webcrypto.js */ "./node_modules/jose/dist/browser/runtime/webcrypto.js");
|
|
64537
|
+
/* 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");
|
|
64538
|
+
/* harmony import */ var _base64url_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base64url.js */ "./node_modules/jose/dist/browser/runtime/base64url.js");
|
|
64539
|
+
/* 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");
|
|
64540
|
+
/* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
|
|
64541
|
+
/* 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");
|
|
63977
64542
|
|
|
63978
64543
|
|
|
63979
64544
|
|
|
@@ -63981,8 +64546,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
63981
64546
|
|
|
63982
64547
|
|
|
63983
64548
|
const genericExport = async (keyType, keyFormat, key) => {
|
|
63984
|
-
if (!(0,
|
|
63985
|
-
throw new TypeError((0,
|
|
64549
|
+
if (!(0,_webcrypto_js__WEBPACK_IMPORTED_MODULE_0__.isCryptoKey)(key)) {
|
|
64550
|
+
throw new TypeError((0,_lib_invalid_key_input_js__WEBPACK_IMPORTED_MODULE_1__["default"])(key, ..._is_key_like_js__WEBPACK_IMPORTED_MODULE_5__.types));
|
|
63986
64551
|
}
|
|
63987
64552
|
if (!key.extractable) {
|
|
63988
64553
|
throw new TypeError('CryptoKey is not extractable');
|
|
@@ -63990,7 +64555,7 @@ const genericExport = async (keyType, keyFormat, key) => {
|
|
|
63990
64555
|
if (key.type !== keyType) {
|
|
63991
64556
|
throw new TypeError(`key is not a ${keyType} key`);
|
|
63992
64557
|
}
|
|
63993
|
-
return (0,
|
|
64558
|
+
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`);
|
|
63994
64559
|
};
|
|
63995
64560
|
const toSPKI = (key) => {
|
|
63996
64561
|
return genericExport('public', 'spki', key);
|
|
@@ -64028,11 +64593,11 @@ const getNamedCurve = (keyData) => {
|
|
|
64028
64593
|
case findOid(keyData, [0x2b, 0x65, 0x71]):
|
|
64029
64594
|
return 'Ed448';
|
|
64030
64595
|
default:
|
|
64031
|
-
throw new
|
|
64596
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_4__.JOSENotSupported('Invalid or unsupported EC Key Curve or OKP Key Sub Type');
|
|
64032
64597
|
}
|
|
64033
64598
|
};
|
|
64034
64599
|
const genericImport = async (replace, keyFormat, pem, alg, options) => {
|
|
64035
|
-
var _a
|
|
64600
|
+
var _a;
|
|
64036
64601
|
let algorithm;
|
|
64037
64602
|
let keyUsages;
|
|
64038
64603
|
const keyData = new Uint8Array(atob(pem.replace(replace, ''))
|
|
@@ -64088,20 +64653,9 @@ const genericImport = async (replace, keyFormat, pem, alg, options) => {
|
|
|
64088
64653
|
keyUsages = isPublic ? ['verify'] : ['sign'];
|
|
64089
64654
|
break;
|
|
64090
64655
|
default:
|
|
64091
|
-
throw new
|
|
64092
|
-
}
|
|
64093
|
-
try {
|
|
64094
|
-
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);
|
|
64095
|
-
}
|
|
64096
|
-
catch (err) {
|
|
64097
|
-
if (algorithm.name === 'Ed25519' &&
|
|
64098
|
-
(err === null || err === void 0 ? void 0 : err.name) === 'NotSupportedError' &&
|
|
64099
|
-
(0,_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)()) {
|
|
64100
|
-
algorithm = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
|
|
64101
|
-
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);
|
|
64102
|
-
}
|
|
64103
|
-
throw err;
|
|
64656
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_4__.JOSENotSupported('Invalid or unsupported "alg" (Algorithm) value');
|
|
64104
64657
|
}
|
|
64658
|
+
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);
|
|
64105
64659
|
};
|
|
64106
64660
|
const fromPKCS8 = (pem, alg, options) => {
|
|
64107
64661
|
return genericImport(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g, 'pkcs8', pem, alg, options);
|
|
@@ -64170,12 +64724,12 @@ function parseElement(bytes) {
|
|
|
64170
64724
|
}
|
|
64171
64725
|
function spkiFromX509(buf) {
|
|
64172
64726
|
const tbsCertificate = getElement(getElement(parseElement(buf).contents)[0].contents);
|
|
64173
|
-
return (0,
|
|
64727
|
+
return (0,_base64url_js__WEBPACK_IMPORTED_MODULE_2__.encodeBase64)(tbsCertificate[tbsCertificate[0].raw[0] === 0xa0 ? 6 : 5].raw);
|
|
64174
64728
|
}
|
|
64175
64729
|
function getSPKI(x509) {
|
|
64176
64730
|
const pem = x509.replace(/(?:-----(?:BEGIN|END) CERTIFICATE-----|\s)/g, '');
|
|
64177
|
-
const raw = (0,
|
|
64178
|
-
return (0,
|
|
64731
|
+
const raw = (0,_base64url_js__WEBPACK_IMPORTED_MODULE_2__.decodeBase64)(pem);
|
|
64732
|
+
return (0,_lib_format_pem_js__WEBPACK_IMPORTED_MODULE_3__["default"])(spkiFromX509(raw), 'PUBLIC KEY');
|
|
64179
64733
|
}
|
|
64180
64734
|
const fromX509 = (pem, alg, options) => {
|
|
64181
64735
|
let spki;
|
|
@@ -64603,26 +65157,6 @@ const encrypt = async (enc, plaintext, cek, iv, aad) => {
|
|
|
64603
65157
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (encrypt);
|
|
64604
65158
|
|
|
64605
65159
|
|
|
64606
|
-
/***/ }),
|
|
64607
|
-
|
|
64608
|
-
/***/ "./node_modules/jose/dist/browser/runtime/env.js":
|
|
64609
|
-
/*!*******************************************************!*\
|
|
64610
|
-
!*** ./node_modules/jose/dist/browser/runtime/env.js ***!
|
|
64611
|
-
\*******************************************************/
|
|
64612
|
-
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
64613
|
-
|
|
64614
|
-
"use strict";
|
|
64615
|
-
__webpack_require__.r(__webpack_exports__);
|
|
64616
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
64617
|
-
/* harmony export */ "isCloudflareWorkers": () => (/* binding */ isCloudflareWorkers)
|
|
64618
|
-
/* harmony export */ });
|
|
64619
|
-
function isCloudflareWorkers() {
|
|
64620
|
-
return (typeof WebSocketPair !== 'undefined' ||
|
|
64621
|
-
(typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers') ||
|
|
64622
|
-
(typeof EdgeRuntime !== 'undefined' && EdgeRuntime === 'vercel'));
|
|
64623
|
-
}
|
|
64624
|
-
|
|
64625
|
-
|
|
64626
65160
|
/***/ }),
|
|
64627
65161
|
|
|
64628
65162
|
/***/ "./node_modules/jose/dist/browser/runtime/fetch_jwks.js":
|
|
@@ -64687,11 +65221,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
64687
65221
|
/* harmony export */ "generateKeyPair": () => (/* binding */ generateKeyPair),
|
|
64688
65222
|
/* harmony export */ "generateSecret": () => (/* binding */ generateSecret)
|
|
64689
65223
|
/* harmony export */ });
|
|
64690
|
-
/* harmony import */ var
|
|
64691
|
-
/* harmony import */ var
|
|
64692
|
-
/* harmony import */ var
|
|
64693
|
-
/* harmony import */ var _random_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./random.js */ "./node_modules/jose/dist/browser/runtime/random.js");
|
|
64694
|
-
|
|
65224
|
+
/* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webcrypto.js */ "./node_modules/jose/dist/browser/runtime/webcrypto.js");
|
|
65225
|
+
/* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
|
|
65226
|
+
/* harmony import */ var _random_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./random.js */ "./node_modules/jose/dist/browser/runtime/random.js");
|
|
64695
65227
|
|
|
64696
65228
|
|
|
64697
65229
|
|
|
@@ -64712,7 +65244,7 @@ async function generateSecret(alg, options) {
|
|
|
64712
65244
|
case 'A192CBC-HS384':
|
|
64713
65245
|
case 'A256CBC-HS512':
|
|
64714
65246
|
length = parseInt(alg.slice(-3), 10);
|
|
64715
|
-
return (0,
|
|
65247
|
+
return (0,_random_js__WEBPACK_IMPORTED_MODULE_2__["default"])(new Uint8Array(length >> 3));
|
|
64716
65248
|
case 'A128KW':
|
|
64717
65249
|
case 'A192KW':
|
|
64718
65250
|
case 'A256KW':
|
|
@@ -64731,20 +65263,20 @@ async function generateSecret(alg, options) {
|
|
|
64731
65263
|
keyUsages = ['encrypt', 'decrypt'];
|
|
64732
65264
|
break;
|
|
64733
65265
|
default:
|
|
64734
|
-
throw new
|
|
65266
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
64735
65267
|
}
|
|
64736
|
-
return
|
|
65268
|
+
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);
|
|
64737
65269
|
}
|
|
64738
65270
|
function getModulusLengthOption(options) {
|
|
64739
65271
|
var _a;
|
|
64740
65272
|
const modulusLength = (_a = options === null || options === void 0 ? void 0 : options.modulusLength) !== null && _a !== void 0 ? _a : 2048;
|
|
64741
65273
|
if (typeof modulusLength !== 'number' || modulusLength < 2048) {
|
|
64742
|
-
throw new
|
|
65274
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used');
|
|
64743
65275
|
}
|
|
64744
65276
|
return modulusLength;
|
|
64745
65277
|
}
|
|
64746
65278
|
async function generateKeyPair(alg, options) {
|
|
64747
|
-
var _a, _b, _c
|
|
65279
|
+
var _a, _b, _c;
|
|
64748
65280
|
let algorithm;
|
|
64749
65281
|
let keyUsages;
|
|
64750
65282
|
switch (alg) {
|
|
@@ -64803,7 +65335,7 @@ async function generateKeyPair(alg, options) {
|
|
|
64803
65335
|
algorithm = { name: crv };
|
|
64804
65336
|
break;
|
|
64805
65337
|
default:
|
|
64806
|
-
throw new
|
|
65338
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported crv option provided');
|
|
64807
65339
|
}
|
|
64808
65340
|
break;
|
|
64809
65341
|
case 'ECDH-ES':
|
|
@@ -64824,25 +65356,14 @@ async function generateKeyPair(alg, options) {
|
|
|
64824
65356
|
algorithm = { name: crv };
|
|
64825
65357
|
break;
|
|
64826
65358
|
default:
|
|
64827
|
-
throw new
|
|
65359
|
+
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');
|
|
64828
65360
|
}
|
|
64829
65361
|
break;
|
|
64830
65362
|
}
|
|
64831
65363
|
default:
|
|
64832
|
-
throw new
|
|
64833
|
-
}
|
|
64834
|
-
try {
|
|
64835
|
-
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));
|
|
64836
|
-
}
|
|
64837
|
-
catch (err) {
|
|
64838
|
-
if (algorithm.name === 'Ed25519' &&
|
|
64839
|
-
(err === null || err === void 0 ? void 0 : err.name) === 'NotSupportedError' &&
|
|
64840
|
-
(0,_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)()) {
|
|
64841
|
-
algorithm = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
|
|
64842
|
-
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));
|
|
64843
|
-
}
|
|
64844
|
-
throw err;
|
|
65364
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
64845
65365
|
}
|
|
65366
|
+
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));
|
|
64846
65367
|
}
|
|
64847
65368
|
|
|
64848
65369
|
|
|
@@ -64917,11 +65438,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
64917
65438
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
64918
65439
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
64919
65440
|
/* harmony export */ });
|
|
64920
|
-
/* harmony import */ var
|
|
64921
|
-
/* harmony import */ var
|
|
64922
|
-
/* harmony import */ var
|
|
64923
|
-
/* harmony import */ var _base64url_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./base64url.js */ "./node_modules/jose/dist/browser/runtime/base64url.js");
|
|
64924
|
-
|
|
65441
|
+
/* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webcrypto.js */ "./node_modules/jose/dist/browser/runtime/webcrypto.js");
|
|
65442
|
+
/* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
|
|
65443
|
+
/* harmony import */ var _base64url_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base64url.js */ "./node_modules/jose/dist/browser/runtime/base64url.js");
|
|
64925
65444
|
|
|
64926
65445
|
|
|
64927
65446
|
|
|
@@ -64940,7 +65459,7 @@ function subtleMapping(jwk) {
|
|
|
64940
65459
|
case 'A128CBC-HS256':
|
|
64941
65460
|
case 'A192CBC-HS384':
|
|
64942
65461
|
case 'A256CBC-HS512':
|
|
64943
|
-
throw new
|
|
65462
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported(`${jwk.alg} keys cannot be imported as CryptoKey instances`);
|
|
64944
65463
|
case 'A128GCM':
|
|
64945
65464
|
case 'A192GCM':
|
|
64946
65465
|
case 'A256GCM':
|
|
@@ -64963,7 +65482,7 @@ function subtleMapping(jwk) {
|
|
|
64963
65482
|
keyUsages = ['deriveBits'];
|
|
64964
65483
|
break;
|
|
64965
65484
|
default:
|
|
64966
|
-
throw new
|
|
65485
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
64967
65486
|
}
|
|
64968
65487
|
break;
|
|
64969
65488
|
}
|
|
@@ -64992,7 +65511,7 @@ function subtleMapping(jwk) {
|
|
|
64992
65511
|
keyUsages = jwk.d ? ['decrypt', 'unwrapKey'] : ['encrypt', 'wrapKey'];
|
|
64993
65512
|
break;
|
|
64994
65513
|
default:
|
|
64995
|
-
throw new
|
|
65514
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
64996
65515
|
}
|
|
64997
65516
|
break;
|
|
64998
65517
|
}
|
|
@@ -65018,7 +65537,7 @@ function subtleMapping(jwk) {
|
|
|
65018
65537
|
keyUsages = jwk.d ? ['deriveBits'] : [];
|
|
65019
65538
|
break;
|
|
65020
65539
|
default:
|
|
65021
|
-
throw new
|
|
65540
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
65022
65541
|
}
|
|
65023
65542
|
break;
|
|
65024
65543
|
}
|
|
@@ -65036,12 +65555,12 @@ function subtleMapping(jwk) {
|
|
|
65036
65555
|
keyUsages = jwk.d ? ['deriveBits'] : [];
|
|
65037
65556
|
break;
|
|
65038
65557
|
default:
|
|
65039
|
-
throw new
|
|
65558
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
65040
65559
|
}
|
|
65041
65560
|
break;
|
|
65042
65561
|
}
|
|
65043
65562
|
default:
|
|
65044
|
-
throw new
|
|
65563
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
|
|
65045
65564
|
}
|
|
65046
65565
|
return { algorithm, keyUsages };
|
|
65047
65566
|
}
|
|
@@ -65057,23 +65576,12 @@ const parse = async (jwk) => {
|
|
|
65057
65576
|
(_b = jwk.key_ops) !== null && _b !== void 0 ? _b : keyUsages,
|
|
65058
65577
|
];
|
|
65059
65578
|
if (algorithm.name === 'PBKDF2') {
|
|
65060
|
-
return
|
|
65579
|
+
return _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__["default"].subtle.importKey('raw', (0,_base64url_js__WEBPACK_IMPORTED_MODULE_2__.decode)(jwk.k), ...rest);
|
|
65061
65580
|
}
|
|
65062
65581
|
const keyData = { ...jwk };
|
|
65063
65582
|
delete keyData.alg;
|
|
65064
65583
|
delete keyData.use;
|
|
65065
|
-
|
|
65066
|
-
return await _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.importKey('jwk', keyData, ...rest);
|
|
65067
|
-
}
|
|
65068
|
-
catch (err) {
|
|
65069
|
-
if (algorithm.name === 'Ed25519' &&
|
|
65070
|
-
(err === null || err === void 0 ? void 0 : err.name) === 'NotSupportedError' &&
|
|
65071
|
-
(0,_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)()) {
|
|
65072
|
-
rest[0] = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
|
|
65073
|
-
return await _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.importKey('jwk', keyData, ...rest);
|
|
65074
|
-
}
|
|
65075
|
-
throw err;
|
|
65076
|
-
}
|
|
65584
|
+
return _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__["default"].subtle.importKey('jwk', keyData, ...rest);
|
|
65077
65585
|
};
|
|
65078
65586
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (parse);
|
|
65079
65587
|
|
|
@@ -65315,9 +65823,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
65315
65823
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
65316
65824
|
/* harmony export */ "default": () => (/* binding */ subtleDsa)
|
|
65317
65825
|
/* harmony export */ });
|
|
65318
|
-
/* harmony import */ var
|
|
65319
|
-
/* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
|
|
65320
|
-
|
|
65826
|
+
/* harmony import */ var _util_errors_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../util/errors.js */ "./node_modules/jose/dist/browser/util/errors.js");
|
|
65321
65827
|
|
|
65322
65828
|
function subtleDsa(alg, algorithm) {
|
|
65323
65829
|
const hash = `SHA-${alg.slice(-3)}`;
|
|
@@ -65339,12 +65845,9 @@ function subtleDsa(alg, algorithm) {
|
|
|
65339
65845
|
case 'ES512':
|
|
65340
65846
|
return { hash, name: 'ECDSA', namedCurve: algorithm.namedCurve };
|
|
65341
65847
|
case 'EdDSA':
|
|
65342
|
-
if ((0,_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)() && algorithm.name === 'NODE-ED25519') {
|
|
65343
|
-
return { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
|
|
65344
|
-
}
|
|
65345
65848
|
return { name: algorithm.name };
|
|
65346
65849
|
default:
|
|
65347
|
-
throw new
|
|
65850
|
+
throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_0__.JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
|
|
65348
65851
|
}
|
|
65349
65852
|
}
|
|
65350
65853
|
|
|
@@ -66009,22 +66512,7 @@ module.exports = JSON.parse('{"application/1d-interleaved-parityfec":{"source":"
|
|
|
66009
66512
|
/******/
|
|
66010
66513
|
/******/ /* webpack/runtime/publicPath */
|
|
66011
66514
|
/******/ (() => {
|
|
66012
|
-
/******/
|
|
66013
|
-
/******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
|
|
66014
|
-
/******/ var document = __webpack_require__.g.document;
|
|
66015
|
-
/******/ if (!scriptUrl && document) {
|
|
66016
|
-
/******/ if (document.currentScript)
|
|
66017
|
-
/******/ scriptUrl = document.currentScript.src;
|
|
66018
|
-
/******/ if (!scriptUrl) {
|
|
66019
|
-
/******/ var scripts = document.getElementsByTagName("script");
|
|
66020
|
-
/******/ if(scripts.length) scriptUrl = scripts[scripts.length - 1].src
|
|
66021
|
-
/******/ }
|
|
66022
|
-
/******/ }
|
|
66023
|
-
/******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
|
|
66024
|
-
/******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
|
|
66025
|
-
/******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
|
|
66026
|
-
/******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
|
|
66027
|
-
/******/ __webpack_require__.p = scriptUrl;
|
|
66515
|
+
/******/ __webpack_require__.p = "";
|
|
66028
66516
|
/******/ })();
|
|
66029
66517
|
/******/
|
|
66030
66518
|
/******/ /* webpack/runtime/jsonp chunk loading */
|