@muze-nl/metro-oidc 0.5.5 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +590 -431
- package/dist/browser.js.map +4 -4
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +4 -4
- package/package.json +3 -4
package/dist/browser.js
CHANGED
|
@@ -147,9 +147,9 @@
|
|
|
147
147
|
return new Client(...deepClone(options));
|
|
148
148
|
}
|
|
149
149
|
function getRequestParams(req, current) {
|
|
150
|
-
let
|
|
151
|
-
if (!
|
|
152
|
-
|
|
150
|
+
let params = current || {};
|
|
151
|
+
if (!params.url && current.url) {
|
|
152
|
+
params.url = current.url;
|
|
153
153
|
}
|
|
154
154
|
for (let prop of [
|
|
155
155
|
"method",
|
|
@@ -175,27 +175,27 @@
|
|
|
175
175
|
value = value[Symbol.metroSource];
|
|
176
176
|
}
|
|
177
177
|
if (typeof value == "function") {
|
|
178
|
-
|
|
178
|
+
params[prop] = value(params[prop], params);
|
|
179
179
|
} else {
|
|
180
180
|
if (prop == "url") {
|
|
181
|
-
|
|
181
|
+
params.url = url(params.url, value);
|
|
182
182
|
} else if (prop == "headers") {
|
|
183
|
-
|
|
183
|
+
params.headers = new Headers(current.headers);
|
|
184
184
|
if (!(value instanceof Headers)) {
|
|
185
185
|
value = new Headers(req.headers);
|
|
186
186
|
}
|
|
187
187
|
for (let [key, val] of value.entries()) {
|
|
188
|
-
|
|
188
|
+
params.headers.set(key, val);
|
|
189
189
|
}
|
|
190
190
|
} else {
|
|
191
|
-
|
|
191
|
+
params[prop] = value;
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
if (req instanceof Request && req.data) {
|
|
196
|
-
|
|
196
|
+
params.body = req.data;
|
|
197
197
|
}
|
|
198
|
-
return
|
|
198
|
+
return params;
|
|
199
199
|
}
|
|
200
200
|
function request(...options) {
|
|
201
201
|
let requestParams = {
|
|
@@ -259,9 +259,9 @@
|
|
|
259
259
|
});
|
|
260
260
|
}
|
|
261
261
|
function getResponseParams(res, current) {
|
|
262
|
-
let
|
|
263
|
-
if (!
|
|
264
|
-
|
|
262
|
+
let params = current || {};
|
|
263
|
+
if (!params.url && current.url) {
|
|
264
|
+
params.url = current.url;
|
|
265
265
|
}
|
|
266
266
|
for (let prop of ["status", "statusText", "headers", "body", "url", "type", "redirected"]) {
|
|
267
267
|
let value = res[prop];
|
|
@@ -272,19 +272,19 @@
|
|
|
272
272
|
value = value[Symbol.metroSource];
|
|
273
273
|
}
|
|
274
274
|
if (typeof value == "function") {
|
|
275
|
-
|
|
275
|
+
params[prop] = value(params[prop], params);
|
|
276
276
|
} else {
|
|
277
277
|
if (prop == "url") {
|
|
278
|
-
|
|
278
|
+
params.url = new URL(value, params.url || "https://localhost/");
|
|
279
279
|
} else {
|
|
280
|
-
|
|
280
|
+
params[prop] = value;
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
if (res instanceof Response && res.data) {
|
|
285
|
-
|
|
285
|
+
params.body = res.data;
|
|
286
286
|
}
|
|
287
|
-
return
|
|
287
|
+
return params;
|
|
288
288
|
}
|
|
289
289
|
function response(...options) {
|
|
290
290
|
let responseParams = {};
|
|
@@ -343,12 +343,12 @@
|
|
|
343
343
|
}
|
|
344
344
|
});
|
|
345
345
|
}
|
|
346
|
-
function appendSearchParams(url2,
|
|
347
|
-
if (typeof
|
|
348
|
-
|
|
346
|
+
function appendSearchParams(url2, params) {
|
|
347
|
+
if (typeof params == "function") {
|
|
348
|
+
params(url2.searchParams, url2);
|
|
349
349
|
} else {
|
|
350
|
-
|
|
351
|
-
|
|
350
|
+
params = new URLSearchParams(params);
|
|
351
|
+
params.forEach((value, key) => {
|
|
352
352
|
url2.searchParams.append(key, value);
|
|
353
353
|
});
|
|
354
354
|
}
|
|
@@ -467,31 +467,31 @@
|
|
|
467
467
|
});
|
|
468
468
|
}
|
|
469
469
|
function formdata(...options) {
|
|
470
|
-
var
|
|
470
|
+
var params = new FormData();
|
|
471
471
|
for (let option of options) {
|
|
472
472
|
if (option instanceof HTMLFormElement) {
|
|
473
473
|
option = new FormData(option);
|
|
474
474
|
}
|
|
475
475
|
if (option instanceof FormData) {
|
|
476
476
|
for (let entry of option.entries()) {
|
|
477
|
-
|
|
477
|
+
params.append(entry[0], entry[1]);
|
|
478
478
|
}
|
|
479
479
|
} else if (option && typeof option == "object") {
|
|
480
480
|
for (let entry of Object.entries(option)) {
|
|
481
481
|
if (Array.isArray(entry[1])) {
|
|
482
482
|
for (let value of entry[1]) {
|
|
483
|
-
|
|
483
|
+
params.append(entry[0], value);
|
|
484
484
|
}
|
|
485
485
|
} else {
|
|
486
|
-
|
|
486
|
+
params.append(entry[0], entry[1]);
|
|
487
487
|
}
|
|
488
488
|
}
|
|
489
489
|
} else {
|
|
490
490
|
throw new metroError("metro.formdata: unknown option type " + metroURL + "formdata/unknown-option-value/", option);
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
|
-
Object.freeze(
|
|
494
|
-
return new Proxy(
|
|
493
|
+
Object.freeze(params);
|
|
494
|
+
return new Proxy(params, {
|
|
495
495
|
get(target, prop) {
|
|
496
496
|
let result;
|
|
497
497
|
switch (prop) {
|
|
@@ -737,8 +737,28 @@
|
|
|
737
737
|
}
|
|
738
738
|
var everything_default = metro;
|
|
739
739
|
|
|
740
|
-
// node_modules/@muze-nl/metro-oauth2/
|
|
740
|
+
// node_modules/@muze-nl/metro-oauth2/src/oauth2.mjs
|
|
741
|
+
var oauth2_exports = {};
|
|
742
|
+
__export(oauth2_exports, {
|
|
743
|
+
base64url_encode: () => base64url_encode,
|
|
744
|
+
createState: () => createState,
|
|
745
|
+
default: () => oauth2mw,
|
|
746
|
+
generateCodeChallenge: () => generateCodeChallenge,
|
|
747
|
+
generateCodeVerifier: () => generateCodeVerifier,
|
|
748
|
+
getExpires: () => getExpires,
|
|
749
|
+
isAuthorized: () => isAuthorized,
|
|
750
|
+
isExpired: () => isExpired,
|
|
751
|
+
isRedirected: () => isRedirected
|
|
752
|
+
});
|
|
753
|
+
|
|
754
|
+
// node_modules/@muze-nl/assert/src/assert.mjs
|
|
741
755
|
globalThis.assertEnabled = false;
|
|
756
|
+
function enable() {
|
|
757
|
+
globalThis.assertEnabled = true;
|
|
758
|
+
}
|
|
759
|
+
function disable() {
|
|
760
|
+
globalThis.assertEnabled = false;
|
|
761
|
+
}
|
|
742
762
|
function assert(source, test) {
|
|
743
763
|
if (globalThis.assertEnabled) {
|
|
744
764
|
let problems = fails(source, test);
|
|
@@ -768,6 +788,51 @@
|
|
|
768
788
|
}
|
|
769
789
|
};
|
|
770
790
|
}
|
|
791
|
+
function Recommended(pattern) {
|
|
792
|
+
return function _Recommended(data, root, path) {
|
|
793
|
+
if (data == null || typeof data == "undefined") {
|
|
794
|
+
warn("data does not contain recommended value", data, pattern, path);
|
|
795
|
+
return false;
|
|
796
|
+
} else {
|
|
797
|
+
return fails(data, pattern, root, path);
|
|
798
|
+
}
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
function oneOf(...patterns) {
|
|
802
|
+
return function _oneOf(data, root, path) {
|
|
803
|
+
for (let pattern of patterns) {
|
|
804
|
+
if (!fails(data, pattern, root, path)) {
|
|
805
|
+
return false;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
return error("data does not match oneOf patterns", data, patterns, path);
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
function anyOf(...patterns) {
|
|
812
|
+
return function _anyOf(data, root, path) {
|
|
813
|
+
if (!Array.isArray(data)) {
|
|
814
|
+
return error("data is not an array", data, "anyOf", path);
|
|
815
|
+
}
|
|
816
|
+
for (let value of data) {
|
|
817
|
+
if (oneOf(...patterns)(value)) {
|
|
818
|
+
return error("data does not match anyOf patterns", value, patterns, path);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
return false;
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
function allOf(...patterns) {
|
|
825
|
+
return function _allOf(data, root, path) {
|
|
826
|
+
let problems = [];
|
|
827
|
+
for (let pattern of patterns) {
|
|
828
|
+
problems = problems.concat(fails(data, pattern, root, path));
|
|
829
|
+
}
|
|
830
|
+
problems = problems.filter(Boolean);
|
|
831
|
+
if (problems.length) {
|
|
832
|
+
return error("data does not match all given patterns", data, patterns, path, problems);
|
|
833
|
+
}
|
|
834
|
+
};
|
|
835
|
+
}
|
|
771
836
|
function validURL(data, root, path) {
|
|
772
837
|
try {
|
|
773
838
|
if (data instanceof URL) {
|
|
@@ -783,6 +848,25 @@
|
|
|
783
848
|
return error("data is not a valid url", data, "validURL", path);
|
|
784
849
|
}
|
|
785
850
|
}
|
|
851
|
+
function validEmail(data, root, path) {
|
|
852
|
+
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(data)) {
|
|
853
|
+
return error("data is not a valid email", data, "validEmail", path);
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
function instanceOf(constructor) {
|
|
857
|
+
return function _instanceOf(data, root, path) {
|
|
858
|
+
if (!(data instanceof constructor)) {
|
|
859
|
+
return error("data is not an instanceof pattern", data, constructor, path);
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
function not(pattern) {
|
|
864
|
+
return function _not(data, root, path) {
|
|
865
|
+
if (!fails(data, pattern, root, path)) {
|
|
866
|
+
return error("data matches pattern, when required not to", data, pattern, path);
|
|
867
|
+
}
|
|
868
|
+
};
|
|
869
|
+
}
|
|
786
870
|
function fails(data, pattern, root, path = "") {
|
|
787
871
|
if (!root) {
|
|
788
872
|
root = data;
|
|
@@ -885,6 +969,27 @@
|
|
|
885
969
|
}
|
|
886
970
|
return result;
|
|
887
971
|
}
|
|
972
|
+
function warn(message, data, pattern, path) {
|
|
973
|
+
console.warn("\u{1F170}\uFE0F Assert: " + path, message, pattern, data);
|
|
974
|
+
}
|
|
975
|
+
globalThis.assert = {
|
|
976
|
+
warn,
|
|
977
|
+
error,
|
|
978
|
+
assert,
|
|
979
|
+
enable,
|
|
980
|
+
disable,
|
|
981
|
+
Required,
|
|
982
|
+
Recommended,
|
|
983
|
+
Optional,
|
|
984
|
+
oneOf,
|
|
985
|
+
anyOf,
|
|
986
|
+
allOf,
|
|
987
|
+
validURL,
|
|
988
|
+
validEmail,
|
|
989
|
+
instanceOf,
|
|
990
|
+
not,
|
|
991
|
+
fails
|
|
992
|
+
};
|
|
888
993
|
|
|
889
994
|
// node_modules/@muze-nl/metro-oauth2/src/tokenstore.mjs
|
|
890
995
|
function tokenStore(site) {
|
|
@@ -939,9 +1044,9 @@
|
|
|
939
1044
|
}
|
|
940
1045
|
};
|
|
941
1046
|
assert(options, {});
|
|
942
|
-
const
|
|
1047
|
+
const oauth22 = Object.assign({}, defaultOptions.oauth2_configuration, options?.oauth2_configuration);
|
|
943
1048
|
options = Object.assign({}, defaultOptions, options);
|
|
944
|
-
options.oauth2_configuration =
|
|
1049
|
+
options.oauth2_configuration = oauth22;
|
|
945
1050
|
const store = tokenStore(options.site);
|
|
946
1051
|
if (!options.tokens) {
|
|
947
1052
|
options.tokens = store.tokens;
|
|
@@ -958,12 +1063,12 @@
|
|
|
958
1063
|
redirect_uri: Required(validURL)
|
|
959
1064
|
}
|
|
960
1065
|
});
|
|
961
|
-
for (let option in
|
|
1066
|
+
for (let option in oauth22) {
|
|
962
1067
|
switch (option) {
|
|
963
1068
|
case "access_token":
|
|
964
1069
|
case "authorization_code":
|
|
965
1070
|
case "refresh_token":
|
|
966
|
-
options.tokens.set(option,
|
|
1071
|
+
options.tokens.set(option, oauth22[option]);
|
|
967
1072
|
break;
|
|
968
1073
|
}
|
|
969
1074
|
}
|
|
@@ -1035,20 +1140,20 @@
|
|
|
1035
1140
|
function getTokensFromLocation() {
|
|
1036
1141
|
if (typeof window !== "undefined" && window?.location) {
|
|
1037
1142
|
let url2 = url(window.location);
|
|
1038
|
-
let code, state,
|
|
1143
|
+
let code, state, params;
|
|
1039
1144
|
if (url2.searchParams.has("code")) {
|
|
1040
|
-
|
|
1145
|
+
params = url2.searchParams;
|
|
1041
1146
|
url2 = url2.with({ search: "" });
|
|
1042
1147
|
history.pushState({}, "", url2.href);
|
|
1043
1148
|
} else if (url2.hash) {
|
|
1044
1149
|
let query = url2.hash.substr(1);
|
|
1045
|
-
|
|
1150
|
+
params = new URLSearchParams("?" + query);
|
|
1046
1151
|
url2 = url2.with({ hash: "" });
|
|
1047
1152
|
history.pushState({}, "", url2.href);
|
|
1048
1153
|
}
|
|
1049
|
-
if (
|
|
1050
|
-
code =
|
|
1051
|
-
state =
|
|
1154
|
+
if (params) {
|
|
1155
|
+
code = params.get("code");
|
|
1156
|
+
state = params.get("state");
|
|
1052
1157
|
let storedState = options.state.get("metro/state");
|
|
1053
1158
|
if (!state || state !== storedState) {
|
|
1054
1159
|
return;
|
|
@@ -1060,7 +1165,7 @@
|
|
|
1060
1165
|
}
|
|
1061
1166
|
}
|
|
1062
1167
|
async function fetchAccessToken() {
|
|
1063
|
-
if (
|
|
1168
|
+
if (oauth22.grant_type === "authorization_code" && !options.tokens.has("authorization_code")) {
|
|
1064
1169
|
let authReqURL = await getAuthorizationCodeURL();
|
|
1065
1170
|
if (!options.authorize_callback || typeof options.authorize_callback !== "function") {
|
|
1066
1171
|
throw metroError("oauth2mw: oauth2 with grant_type:authorization_code requires a callback function in client options.authorize_callback");
|
|
@@ -1076,7 +1181,7 @@
|
|
|
1076
1181
|
let response2 = await options.client.post(tokenReq);
|
|
1077
1182
|
if (!response2.ok) {
|
|
1078
1183
|
let msg = await response2.text();
|
|
1079
|
-
throw metroError("OAuth2mw: fetch access_token: " + response2.status + ": " + response2.statusText, { cause: tokenReq });
|
|
1184
|
+
throw metroError("OAuth2mw: fetch access_token: " + response2.status + ": " + response2.statusText + " (" + msg + ")", { cause: tokenReq });
|
|
1080
1185
|
}
|
|
1081
1186
|
let data = await response2.json();
|
|
1082
1187
|
options.tokens.set("access_token", {
|
|
@@ -1118,11 +1223,11 @@
|
|
|
1118
1223
|
return data;
|
|
1119
1224
|
}
|
|
1120
1225
|
async function getAuthorizationCodeURL() {
|
|
1121
|
-
if (!
|
|
1226
|
+
if (!oauth22.authorization_endpoint) {
|
|
1122
1227
|
throw metroError("oauth2mw: Missing options.oauth2_configuration.authorization_endpoint");
|
|
1123
1228
|
}
|
|
1124
|
-
let url2 = url(
|
|
1125
|
-
assert(
|
|
1229
|
+
let url2 = url(oauth22.authorization_endpoint, { hash: "" });
|
|
1230
|
+
assert(oauth22, {
|
|
1126
1231
|
client_id: /.+/,
|
|
1127
1232
|
redirect_uri: /.+/,
|
|
1128
1233
|
scope: /.*/
|
|
@@ -1130,73 +1235,72 @@
|
|
|
1130
1235
|
let search = {
|
|
1131
1236
|
response_type: "code",
|
|
1132
1237
|
// implicit flow uses 'token' here, but is not considered safe, so not supported
|
|
1133
|
-
client_id:
|
|
1134
|
-
redirect_uri:
|
|
1135
|
-
state:
|
|
1238
|
+
client_id: oauth22.client_id,
|
|
1239
|
+
redirect_uri: oauth22.redirect_uri,
|
|
1240
|
+
state: oauth22.state || createState(40)
|
|
1136
1241
|
// OAuth2.1 RFC says optional, but its a good idea to always add/check it
|
|
1137
1242
|
};
|
|
1138
|
-
if (
|
|
1139
|
-
search.response_type =
|
|
1243
|
+
if (oauth22.response_type) {
|
|
1244
|
+
search.response_type = oauth22.response_type;
|
|
1140
1245
|
}
|
|
1141
|
-
if (
|
|
1142
|
-
search.response_mode =
|
|
1246
|
+
if (oauth22.response_mode) {
|
|
1247
|
+
search.response_mode = oauth22.response_mode;
|
|
1143
1248
|
}
|
|
1144
1249
|
options.state.set(search.state);
|
|
1145
|
-
if (
|
|
1146
|
-
search.client_secret =
|
|
1250
|
+
if (oauth22.client_secret) {
|
|
1251
|
+
search.client_secret = oauth22.client_secret;
|
|
1147
1252
|
}
|
|
1148
|
-
if (
|
|
1149
|
-
options.tokens.set("code_verifier",
|
|
1150
|
-
search.code_challenge = await generateCodeChallenge(
|
|
1253
|
+
if (oauth22.code_verifier) {
|
|
1254
|
+
options.tokens.set("code_verifier", oauth22.code_verifier);
|
|
1255
|
+
search.code_challenge = await generateCodeChallenge(oauth22.code_verifier);
|
|
1151
1256
|
search.code_challenge_method = "S256";
|
|
1152
1257
|
}
|
|
1153
|
-
if (
|
|
1154
|
-
search.scope =
|
|
1258
|
+
if (oauth22.scope) {
|
|
1259
|
+
search.scope = oauth22.scope;
|
|
1155
1260
|
}
|
|
1156
|
-
if (
|
|
1157
|
-
search.prompt =
|
|
1261
|
+
if (oauth22.prompt) {
|
|
1262
|
+
search.prompt = oauth22.prompt;
|
|
1158
1263
|
}
|
|
1159
1264
|
return url(url2, { search });
|
|
1160
1265
|
}
|
|
1161
1266
|
function getAccessTokenRequest(grant_type = null) {
|
|
1162
|
-
assert(
|
|
1267
|
+
assert(oauth22, {
|
|
1163
1268
|
client_id: /.+/,
|
|
1164
1269
|
redirect_uri: /.+/
|
|
1165
1270
|
});
|
|
1166
|
-
if (!
|
|
1271
|
+
if (!oauth22.token_endpoint) {
|
|
1167
1272
|
throw metroError("oauth2mw: Missing options.endpoints.token url");
|
|
1168
1273
|
}
|
|
1169
|
-
let url2 = url(
|
|
1170
|
-
let
|
|
1171
|
-
grant_type: grant_type ||
|
|
1172
|
-
client_id:
|
|
1274
|
+
let url2 = url(oauth22.token_endpoint, { hash: "" });
|
|
1275
|
+
let params = {
|
|
1276
|
+
grant_type: grant_type || oauth22.grant_type,
|
|
1277
|
+
client_id: oauth22.client_id
|
|
1173
1278
|
};
|
|
1174
|
-
if (
|
|
1175
|
-
|
|
1279
|
+
if (oauth22.client_secret) {
|
|
1280
|
+
params.client_secret = oauth22.client_secret;
|
|
1176
1281
|
}
|
|
1177
|
-
if (
|
|
1178
|
-
|
|
1282
|
+
if (oauth22.scope) {
|
|
1283
|
+
params.scope = oauth22.scope;
|
|
1179
1284
|
}
|
|
1180
|
-
switch (
|
|
1285
|
+
switch (params.grant_type) {
|
|
1181
1286
|
case "authorization_code":
|
|
1182
|
-
|
|
1183
|
-
|
|
1287
|
+
params.redirect_uri = oauth22.redirect_uri;
|
|
1288
|
+
params.code = options.tokens.get("authorization_code");
|
|
1184
1289
|
const code_verifier = options.tokens.get("code_verifier");
|
|
1185
1290
|
if (code_verifier) {
|
|
1186
|
-
|
|
1291
|
+
params.code_verifier = code_verifier;
|
|
1187
1292
|
}
|
|
1188
1293
|
break;
|
|
1189
1294
|
case "client_credentials":
|
|
1190
1295
|
break;
|
|
1191
1296
|
case "refresh_token":
|
|
1192
|
-
|
|
1193
|
-
params2.refresh_token = refreshToken.value;
|
|
1297
|
+
params.refresh_token = options.tokens.get("refresh_token");
|
|
1194
1298
|
break;
|
|
1195
1299
|
default:
|
|
1196
1300
|
throw new Error("Unknown grant_type: ".oauth2.grant_type);
|
|
1197
1301
|
break;
|
|
1198
1302
|
}
|
|
1199
|
-
return request(url2, { method: "POST", body: new URLSearchParams(
|
|
1303
|
+
return request(url2, { method: "POST", body: new URLSearchParams(params) });
|
|
1200
1304
|
}
|
|
1201
1305
|
}
|
|
1202
1306
|
function isExpired(token) {
|
|
@@ -1248,7 +1352,7 @@
|
|
|
1248
1352
|
if (!url2.searchParams.has("code")) {
|
|
1249
1353
|
if (url2.hash) {
|
|
1250
1354
|
let query = url2.hash.substr(1);
|
|
1251
|
-
params = new URLSearchParams("?" + query);
|
|
1355
|
+
const params = new URLSearchParams("?" + query);
|
|
1252
1356
|
if (params.has("code")) {
|
|
1253
1357
|
return true;
|
|
1254
1358
|
}
|
|
@@ -1257,6 +1361,277 @@
|
|
|
1257
1361
|
}
|
|
1258
1362
|
return true;
|
|
1259
1363
|
}
|
|
1364
|
+
function isAuthorized(tokens) {
|
|
1365
|
+
if (typeof tokens == "string") {
|
|
1366
|
+
tokens = tokenStore(tokens).tokens;
|
|
1367
|
+
}
|
|
1368
|
+
let accessToken = tokens.get("access_token");
|
|
1369
|
+
if (accessToken && !isExpired(accessToken)) {
|
|
1370
|
+
return true;
|
|
1371
|
+
}
|
|
1372
|
+
let refreshToken = tokens.get("refresh_token");
|
|
1373
|
+
if (refreshToken) {
|
|
1374
|
+
return true;
|
|
1375
|
+
}
|
|
1376
|
+
return false;
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
// node_modules/@muze-nl/metro-oauth2/src/oauth2.mockserver.mjs
|
|
1380
|
+
var oauth2_mockserver_exports = {};
|
|
1381
|
+
__export(oauth2_mockserver_exports, {
|
|
1382
|
+
default: () => oauth2mockserver
|
|
1383
|
+
});
|
|
1384
|
+
var baseResponse = {
|
|
1385
|
+
status: 200,
|
|
1386
|
+
statusText: "OK",
|
|
1387
|
+
headers: {
|
|
1388
|
+
"Content-Type": "application/json"
|
|
1389
|
+
}
|
|
1390
|
+
};
|
|
1391
|
+
var badRequest = (error3) => {
|
|
1392
|
+
return {
|
|
1393
|
+
status: 400,
|
|
1394
|
+
statusText: "Bad Request",
|
|
1395
|
+
headers: {
|
|
1396
|
+
"Content-Type": "application/json"
|
|
1397
|
+
},
|
|
1398
|
+
body: JSON.stringify({
|
|
1399
|
+
error: "invalid_request",
|
|
1400
|
+
error_description: error3
|
|
1401
|
+
})
|
|
1402
|
+
};
|
|
1403
|
+
};
|
|
1404
|
+
var error2;
|
|
1405
|
+
var pkce = {};
|
|
1406
|
+
function oauth2mockserver(options = {}) {
|
|
1407
|
+
const defaultOptions = {
|
|
1408
|
+
"PKCE": false,
|
|
1409
|
+
"DPoP": false
|
|
1410
|
+
};
|
|
1411
|
+
options = Object.assign({}, defaultOptions, options);
|
|
1412
|
+
return async (req, next) => {
|
|
1413
|
+
let url2 = everything_default.url(req.url);
|
|
1414
|
+
switch (url2.pathname) {
|
|
1415
|
+
case "/authorize/":
|
|
1416
|
+
if (error2 = fails(url2.searchParams, {
|
|
1417
|
+
response_type: "code",
|
|
1418
|
+
client_id: "mockClientId",
|
|
1419
|
+
state: Optional(/.*/)
|
|
1420
|
+
})) {
|
|
1421
|
+
return everything_default.response(badRequest(error2));
|
|
1422
|
+
}
|
|
1423
|
+
if (url2.searchParams.has("code_challenge")) {
|
|
1424
|
+
if (!url2.searchParams.has("code_challenge_method")) {
|
|
1425
|
+
return everything_default.response(badRequest("missing code_challenge_method"));
|
|
1426
|
+
}
|
|
1427
|
+
pkce.code_challenge = url2.searchParams.get("code_challenge");
|
|
1428
|
+
pkce.code_challenge_method = url2.searchParams.get("code_challenge_method");
|
|
1429
|
+
}
|
|
1430
|
+
return everything_default.response(baseResponse, {
|
|
1431
|
+
body: JSON.stringify({
|
|
1432
|
+
code: "mockAuthorizeToken",
|
|
1433
|
+
state: url2.searchParams.get("state")
|
|
1434
|
+
})
|
|
1435
|
+
});
|
|
1436
|
+
break;
|
|
1437
|
+
case "/token/":
|
|
1438
|
+
if (req.data instanceof URLSearchParams) {
|
|
1439
|
+
let body = {};
|
|
1440
|
+
req.data.forEach((value, key) => body[key] = value);
|
|
1441
|
+
req = req.with({ body });
|
|
1442
|
+
}
|
|
1443
|
+
if (error2 = fails(req, {
|
|
1444
|
+
method: "POST",
|
|
1445
|
+
data: {
|
|
1446
|
+
grant_type: oneOf("refresh_token", "authorization_code")
|
|
1447
|
+
}
|
|
1448
|
+
})) {
|
|
1449
|
+
return everything_default.response(badRequest(error2));
|
|
1450
|
+
}
|
|
1451
|
+
switch (req.data.grant_type) {
|
|
1452
|
+
case "refresh_token":
|
|
1453
|
+
if (error2 = fails(req.data, oneOf({
|
|
1454
|
+
refresh_token: "mockRefreshToken",
|
|
1455
|
+
client_id: "mockClientId",
|
|
1456
|
+
client_secret: "mockClientSecret"
|
|
1457
|
+
}, {
|
|
1458
|
+
refresh_token: "mockRefreshToken",
|
|
1459
|
+
client_id: "mockClientId",
|
|
1460
|
+
code_verifier: /.+/
|
|
1461
|
+
}))) {
|
|
1462
|
+
return everything_default.response(badRequest(error2));
|
|
1463
|
+
}
|
|
1464
|
+
break;
|
|
1465
|
+
case "access_token":
|
|
1466
|
+
if (error2 = fails(req.data, oneOf({
|
|
1467
|
+
client_id: "mockClientId",
|
|
1468
|
+
client_secret: "mockClientSecret"
|
|
1469
|
+
}, {
|
|
1470
|
+
client_id: "mockClientId",
|
|
1471
|
+
code_challenge: /.*/,
|
|
1472
|
+
//FIXME: check that this matches code_verifier
|
|
1473
|
+
code_challenge_method: "S256"
|
|
1474
|
+
}))) {
|
|
1475
|
+
return everything_default.response(badRequest(error2));
|
|
1476
|
+
}
|
|
1477
|
+
break;
|
|
1478
|
+
}
|
|
1479
|
+
return everything_default.response(baseResponse, {
|
|
1480
|
+
body: JSON.stringify({
|
|
1481
|
+
access_token: "mockAccessToken",
|
|
1482
|
+
token_type: "mockExample",
|
|
1483
|
+
expires_in: 3600,
|
|
1484
|
+
refresh_token: "mockRefreshToken",
|
|
1485
|
+
example_parameter: "mockExampleValue"
|
|
1486
|
+
})
|
|
1487
|
+
});
|
|
1488
|
+
break;
|
|
1489
|
+
case "/protected/":
|
|
1490
|
+
let auth = req.headers.get("Authorization");
|
|
1491
|
+
let [type, token] = auth ? auth.split(" ") : [];
|
|
1492
|
+
if (!token || token !== "mockAccessToken") {
|
|
1493
|
+
return everything_default.response({
|
|
1494
|
+
status: 401,
|
|
1495
|
+
statusText: "Forbidden",
|
|
1496
|
+
body: "401 Forbidden"
|
|
1497
|
+
});
|
|
1498
|
+
}
|
|
1499
|
+
return everything_default.response(baseResponse, {
|
|
1500
|
+
body: JSON.stringify({
|
|
1501
|
+
result: "Success"
|
|
1502
|
+
})
|
|
1503
|
+
});
|
|
1504
|
+
break;
|
|
1505
|
+
case "/public/":
|
|
1506
|
+
return everything_default.response(baseResponse, {
|
|
1507
|
+
body: JSON.stringify({
|
|
1508
|
+
result: "Success"
|
|
1509
|
+
})
|
|
1510
|
+
});
|
|
1511
|
+
break;
|
|
1512
|
+
default:
|
|
1513
|
+
return everything_default.response({
|
|
1514
|
+
status: 404,
|
|
1515
|
+
statusText: "not found",
|
|
1516
|
+
body: "404 Not Found " + url2
|
|
1517
|
+
});
|
|
1518
|
+
break;
|
|
1519
|
+
}
|
|
1520
|
+
};
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
// node_modules/@muze-nl/metro-oauth2/src/oauth2.discovery.mjs
|
|
1524
|
+
var oauth2_discovery_exports = {};
|
|
1525
|
+
__export(oauth2_discovery_exports, {
|
|
1526
|
+
default: () => makeClient
|
|
1527
|
+
});
|
|
1528
|
+
var validAlgorithms = [
|
|
1529
|
+
"HS256",
|
|
1530
|
+
"HS384",
|
|
1531
|
+
"HS512",
|
|
1532
|
+
"RS256",
|
|
1533
|
+
"RS384",
|
|
1534
|
+
"RS512",
|
|
1535
|
+
"ES256",
|
|
1536
|
+
"ES384",
|
|
1537
|
+
"ES512"
|
|
1538
|
+
];
|
|
1539
|
+
var validAuthMethods = [
|
|
1540
|
+
"client_secret_post",
|
|
1541
|
+
"client_secret_base",
|
|
1542
|
+
"client_secret_jwt",
|
|
1543
|
+
"private_key_jwt"
|
|
1544
|
+
];
|
|
1545
|
+
var oauth_authorization_server_metadata = {
|
|
1546
|
+
issuer: Required(validURL),
|
|
1547
|
+
authorization_endpoint: Required(validURL),
|
|
1548
|
+
token_endpoint: Required(validURL),
|
|
1549
|
+
jwks_uri: Optional(validURL),
|
|
1550
|
+
registration_endpoint: Optional(validURL),
|
|
1551
|
+
scopes_supported: Recommended([]),
|
|
1552
|
+
response_types_supported: Required(anyOf("code", "token")),
|
|
1553
|
+
response_modes_supported: Optional([]),
|
|
1554
|
+
grant_types_supported: Optional([]),
|
|
1555
|
+
token_endpoint_auth_methods_supported: Optional([]),
|
|
1556
|
+
token_endpoint_auth_signing_alg_values_supported: Optional([]),
|
|
1557
|
+
service_documentation: Optional(validURL),
|
|
1558
|
+
ui_locales_supported: Optional([]),
|
|
1559
|
+
op_policy_uri: Optional(validURL),
|
|
1560
|
+
op_tos_uri: Optional(validURL),
|
|
1561
|
+
revocation_endpoint: Optional(validURL),
|
|
1562
|
+
revocation_endpoint_auth_methods_supported: Optional(validAuthMethods),
|
|
1563
|
+
revocation_endpoint_auth_signing_alg_values_supported: Optional(validAlgorithms),
|
|
1564
|
+
introspection_endpoint: Optional(validURL),
|
|
1565
|
+
introspection_endpoint_auth_methods_supported: Optional(validAuthMethods),
|
|
1566
|
+
introspection_endpoint_auth_signing_alg_values_supported: Optional(validAlgorithms),
|
|
1567
|
+
code_challendge_methods_supported: Optional([])
|
|
1568
|
+
};
|
|
1569
|
+
function makeClient(options = {}) {
|
|
1570
|
+
const defaultOptions = {
|
|
1571
|
+
client: everything_default.client()
|
|
1572
|
+
};
|
|
1573
|
+
options = Object.assign({}, defaultOptions, options);
|
|
1574
|
+
assert(options, {
|
|
1575
|
+
issuer: Required(validURL)
|
|
1576
|
+
});
|
|
1577
|
+
const oauth_authorization_server_configuration = fetchWellknownOauthAuthorizationServer(options.issuer);
|
|
1578
|
+
return options.client.with(options.issuer);
|
|
1579
|
+
}
|
|
1580
|
+
async function fetchWellknownOauthAuthorizationServer(issuer, client2) {
|
|
1581
|
+
let res = client2.get(everything_default.url(issuer, ".wellknown/oauth_authorization_server"));
|
|
1582
|
+
if (res.ok) {
|
|
1583
|
+
assert(res.headers.get("Content-Type"), /application\/json.*/);
|
|
1584
|
+
let configuration = await res.json();
|
|
1585
|
+
assert(configuration, oauth_authorization_server_metadata);
|
|
1586
|
+
return configuration;
|
|
1587
|
+
}
|
|
1588
|
+
throw everything_default.metroError("metro.oidcmw: Error while fetching " + issuer + ".wellknown/oauth_authorization_server", res);
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
// node_modules/@muze-nl/metro-oauth2/src/oauth2.popup.mjs
|
|
1592
|
+
function handleRedirect(origin = null) {
|
|
1593
|
+
let success = false;
|
|
1594
|
+
origin = origin || window.location.origin;
|
|
1595
|
+
let params = new URLSearchParams(window.location.search);
|
|
1596
|
+
if (!params.has("code") && window.location.hash) {
|
|
1597
|
+
let query = window.location.hash.substr(1);
|
|
1598
|
+
params = new URLSearchParams("?" + query);
|
|
1599
|
+
}
|
|
1600
|
+
let parent = window.parent !== window ? window.parent : window.opener;
|
|
1601
|
+
if (!parent) {
|
|
1602
|
+
console.error("No parent window found, cannot post authorization code (or error)");
|
|
1603
|
+
} else {
|
|
1604
|
+
if (params.has("code")) {
|
|
1605
|
+
parent.postMessage({
|
|
1606
|
+
authorization_code: params.get("code")
|
|
1607
|
+
}, origin);
|
|
1608
|
+
success = true;
|
|
1609
|
+
} else if (params.has("error")) {
|
|
1610
|
+
parent.postMessage({
|
|
1611
|
+
error: params.get("error")
|
|
1612
|
+
}, origin);
|
|
1613
|
+
} else {
|
|
1614
|
+
parent.postMessage({
|
|
1615
|
+
error: "Could not find an authorization_code"
|
|
1616
|
+
}, origin);
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
return success;
|
|
1620
|
+
}
|
|
1621
|
+
function authorizePopup(authorizationCodeURL) {
|
|
1622
|
+
return new Promise((resolve, reject) => {
|
|
1623
|
+
addEventListener("message", (event) => {
|
|
1624
|
+
if (event.data.authorization_code) {
|
|
1625
|
+
resolve(event.data.authorization_code);
|
|
1626
|
+
} else if (event.data.error) {
|
|
1627
|
+
reject(event.data.error);
|
|
1628
|
+
} else {
|
|
1629
|
+
reject("Unknown authorization error");
|
|
1630
|
+
}
|
|
1631
|
+
}, { once: true });
|
|
1632
|
+
window.open(authorizationCodeURL);
|
|
1633
|
+
});
|
|
1634
|
+
}
|
|
1260
1635
|
|
|
1261
1636
|
// node_modules/@muze-nl/metro-oauth2/src/keysstore.mjs
|
|
1262
1637
|
function keysStore() {
|
|
@@ -1349,35 +1724,44 @@
|
|
|
1349
1724
|
const signature = b64u(await crypto.subtle.sign(subtleAlgorithm(key), key, buf(input)));
|
|
1350
1725
|
return `${input}.${signature}`;
|
|
1351
1726
|
}
|
|
1352
|
-
var
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
input
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1727
|
+
var encodeBase64Url;
|
|
1728
|
+
if (Uint8Array.prototype.toBase64) {
|
|
1729
|
+
encodeBase64Url = (input) => {
|
|
1730
|
+
if (input instanceof ArrayBuffer) {
|
|
1731
|
+
input = new Uint8Array(input);
|
|
1732
|
+
}
|
|
1733
|
+
return input.toBase64({ alphabet: "base64url", omitPadding: true });
|
|
1734
|
+
};
|
|
1735
|
+
} else {
|
|
1736
|
+
const CHUNK_SIZE = 32768;
|
|
1737
|
+
encodeBase64Url = (input) => {
|
|
1738
|
+
if (input instanceof ArrayBuffer) {
|
|
1739
|
+
input = new Uint8Array(input);
|
|
1740
|
+
}
|
|
1741
|
+
const arr = [];
|
|
1742
|
+
for (let i = 0; i < input.byteLength; i += CHUNK_SIZE) {
|
|
1743
|
+
arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));
|
|
1744
|
+
}
|
|
1745
|
+
return btoa(arr.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
1746
|
+
};
|
|
1362
1747
|
}
|
|
1363
1748
|
function b64u(input) {
|
|
1364
1749
|
return encodeBase64Url(input);
|
|
1365
1750
|
}
|
|
1366
|
-
function randomBytes() {
|
|
1367
|
-
return b64u(crypto.getRandomValues(new Uint8Array(32)));
|
|
1368
|
-
}
|
|
1369
1751
|
var UnsupportedOperationError = class extends Error {
|
|
1370
1752
|
constructor(message) {
|
|
1371
|
-
|
|
1753
|
+
var _a;
|
|
1754
|
+
super(message !== null && message !== void 0 ? message : "operation not supported");
|
|
1372
1755
|
this.name = this.constructor.name;
|
|
1373
|
-
Error.captureStackTrace
|
|
1756
|
+
(_a = Error.captureStackTrace) === null || _a === void 0 ? void 0 : _a.call(Error, this, this.constructor);
|
|
1374
1757
|
}
|
|
1375
1758
|
};
|
|
1376
1759
|
var OperationProcessingError = class extends Error {
|
|
1377
1760
|
constructor(message) {
|
|
1761
|
+
var _a;
|
|
1378
1762
|
super(message);
|
|
1379
1763
|
this.name = this.constructor.name;
|
|
1380
|
-
Error.captureStackTrace
|
|
1764
|
+
(_a = Error.captureStackTrace) === null || _a === void 0 ? void 0 : _a.call(Error, this, this.constructor);
|
|
1381
1765
|
}
|
|
1382
1766
|
};
|
|
1383
1767
|
function psAlg(key) {
|
|
@@ -1413,7 +1797,7 @@
|
|
|
1413
1797
|
case "ECDSA":
|
|
1414
1798
|
return esAlg(key);
|
|
1415
1799
|
case "Ed25519":
|
|
1416
|
-
return "
|
|
1800
|
+
return "Ed25519";
|
|
1417
1801
|
default:
|
|
1418
1802
|
throw new UnsupportedOperationError("unsupported CryptoKey algorithm name");
|
|
1419
1803
|
}
|
|
@@ -1430,9 +1814,9 @@
|
|
|
1430
1814
|
function epochTime() {
|
|
1431
1815
|
return Math.floor(Date.now() / 1e3);
|
|
1432
1816
|
}
|
|
1433
|
-
async function
|
|
1434
|
-
const privateKey = keypair
|
|
1435
|
-
const publicKey = keypair
|
|
1817
|
+
async function generateProof(keypair, htu, htm, nonce, accessToken, additional) {
|
|
1818
|
+
const privateKey = keypair === null || keypair === void 0 ? void 0 : keypair.privateKey;
|
|
1819
|
+
const publicKey = keypair === null || keypair === void 0 ? void 0 : keypair.publicKey;
|
|
1436
1820
|
if (!isPrivateKey(privateKey)) {
|
|
1437
1821
|
throw new TypeError('"keypair.privateKey" must be a private CryptoKey');
|
|
1438
1822
|
}
|
|
@@ -1461,21 +1845,21 @@
|
|
|
1461
1845
|
alg: determineJWSAlgorithm(privateKey),
|
|
1462
1846
|
typ: "dpop+jwt",
|
|
1463
1847
|
jwk: await publicJwk(publicKey)
|
|
1464
|
-
}, {
|
|
1465
|
-
...additional,
|
|
1848
|
+
}, Object.assign(Object.assign({}, additional), {
|
|
1466
1849
|
iat: epochTime(),
|
|
1467
|
-
jti:
|
|
1850
|
+
jti: crypto.randomUUID(),
|
|
1468
1851
|
htm,
|
|
1469
1852
|
nonce,
|
|
1470
1853
|
htu,
|
|
1471
1854
|
ath: accessToken ? b64u(await crypto.subtle.digest("SHA-256", buf(accessToken))) : void 0
|
|
1472
|
-
}, privateKey);
|
|
1855
|
+
}), privateKey);
|
|
1473
1856
|
}
|
|
1474
1857
|
async function publicJwk(key) {
|
|
1475
1858
|
const { kty, e, n, x, y, crv } = await crypto.subtle.exportKey("jwk", key);
|
|
1476
1859
|
return { kty, crv, e, n, x, y };
|
|
1477
1860
|
}
|
|
1478
1861
|
async function generateKeyPair(alg, options) {
|
|
1862
|
+
var _a;
|
|
1479
1863
|
let algorithm;
|
|
1480
1864
|
if (typeof alg !== "string" || alg.length === 0) {
|
|
1481
1865
|
throw new TypeError('"alg" must be a non-empty string');
|
|
@@ -1485,7 +1869,7 @@
|
|
|
1485
1869
|
algorithm = {
|
|
1486
1870
|
name: "RSA-PSS",
|
|
1487
1871
|
hash: "SHA-256",
|
|
1488
|
-
modulusLength:
|
|
1872
|
+
modulusLength: 2048,
|
|
1489
1873
|
publicExponent: new Uint8Array([1, 0, 1])
|
|
1490
1874
|
};
|
|
1491
1875
|
break;
|
|
@@ -1493,20 +1877,20 @@
|
|
|
1493
1877
|
algorithm = {
|
|
1494
1878
|
name: "RSASSA-PKCS1-v1_5",
|
|
1495
1879
|
hash: "SHA-256",
|
|
1496
|
-
modulusLength:
|
|
1880
|
+
modulusLength: 2048,
|
|
1497
1881
|
publicExponent: new Uint8Array([1, 0, 1])
|
|
1498
1882
|
};
|
|
1499
1883
|
break;
|
|
1500
1884
|
case "ES256":
|
|
1501
1885
|
algorithm = { name: "ECDSA", namedCurve: "P-256" };
|
|
1502
1886
|
break;
|
|
1503
|
-
case "
|
|
1887
|
+
case "Ed25519":
|
|
1504
1888
|
algorithm = { name: "Ed25519" };
|
|
1505
1889
|
break;
|
|
1506
1890
|
default:
|
|
1507
1891
|
throw new UnsupportedOperationError();
|
|
1508
1892
|
}
|
|
1509
|
-
return crypto.subtle.generateKey(algorithm, options
|
|
1893
|
+
return crypto.subtle.generateKey(algorithm, (_a = options === null || options === void 0 ? void 0 : options.extractable) !== null && _a !== void 0 ? _a : false, ["sign", "verify"]);
|
|
1510
1894
|
}
|
|
1511
1895
|
|
|
1512
1896
|
// node_modules/@muze-nl/metro-oauth2/src/oauth2.dpop.mjs
|
|
@@ -1528,14 +1912,14 @@
|
|
|
1528
1912
|
}
|
|
1529
1913
|
const url2 = everything_default.url(req.url);
|
|
1530
1914
|
if (req.url.startsWith(options.authorization_endpoint)) {
|
|
1531
|
-
let
|
|
1532
|
-
if (
|
|
1533
|
-
|
|
1915
|
+
let params = req.body;
|
|
1916
|
+
if (params instanceof URLSearchParams || params instanceof FormData) {
|
|
1917
|
+
params.set("dpop_jkt", keyInfo.keyPair.publicKey);
|
|
1534
1918
|
} else {
|
|
1535
|
-
|
|
1919
|
+
params.dpop_jkt = keyInfo.keyPair.publicKey;
|
|
1536
1920
|
}
|
|
1537
1921
|
} else if (req.url.startsWith(options.token_endpoint)) {
|
|
1538
|
-
const dpopHeader = await
|
|
1922
|
+
const dpopHeader = await generateProof(keyInfo.keyPair, req.url, req.method);
|
|
1539
1923
|
req = req.with({
|
|
1540
1924
|
headers: {
|
|
1541
1925
|
"DPoP": dpopHeader
|
|
@@ -1544,7 +1928,7 @@
|
|
|
1544
1928
|
} else if (req.headers.has("Authorization")) {
|
|
1545
1929
|
const nonce = localStorage.getItem(url2.host + ":nonce") || void 0;
|
|
1546
1930
|
const accessToken = req.headers.get("Authorization").split(" ")[1];
|
|
1547
|
-
const dpopHeader = await
|
|
1931
|
+
const dpopHeader = await generateProof(keyInfo.keyPair, req.url, req.method, nonce, accessToken);
|
|
1548
1932
|
req = req.with({
|
|
1549
1933
|
headers: {
|
|
1550
1934
|
"Authorization": "DPoP " + accessToken,
|
|
@@ -1560,258 +1944,33 @@
|
|
|
1560
1944
|
};
|
|
1561
1945
|
}
|
|
1562
1946
|
|
|
1563
|
-
// node_modules/@muze-nl/
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
throw new Error("Assertions failed", {
|
|
1577
|
-
cause: { problems, source }
|
|
1578
|
-
});
|
|
1579
|
-
}
|
|
1580
|
-
}
|
|
1581
|
-
}
|
|
1582
|
-
function Optional2(pattern) {
|
|
1583
|
-
return function _Optional(data, root, path) {
|
|
1584
|
-
if (typeof data != "undefined" && data != null && typeof pattern != "undefined") {
|
|
1585
|
-
return fails2(data, pattern, root, path);
|
|
1586
|
-
}
|
|
1587
|
-
};
|
|
1588
|
-
}
|
|
1589
|
-
function Required2(pattern) {
|
|
1590
|
-
return function _Required(data, root, path) {
|
|
1591
|
-
if (data == null || typeof data == "undefined") {
|
|
1592
|
-
return error2("data is required", data, pattern || "any value", path);
|
|
1593
|
-
} else if (typeof pattern != "undefined") {
|
|
1594
|
-
return fails2(data, pattern, root, path);
|
|
1595
|
-
} else {
|
|
1596
|
-
return false;
|
|
1597
|
-
}
|
|
1598
|
-
};
|
|
1599
|
-
}
|
|
1600
|
-
function Recommended(pattern) {
|
|
1601
|
-
return function _Recommended(data, root, path) {
|
|
1602
|
-
if (data == null || typeof data == "undefined") {
|
|
1603
|
-
warn("data does not contain recommended value", data, pattern, path);
|
|
1604
|
-
return false;
|
|
1605
|
-
} else {
|
|
1606
|
-
return fails2(data, pattern, root, path);
|
|
1607
|
-
}
|
|
1608
|
-
};
|
|
1609
|
-
}
|
|
1610
|
-
function oneOf(...patterns) {
|
|
1611
|
-
return function _oneOf(data, root, path) {
|
|
1612
|
-
for (let pattern of patterns) {
|
|
1613
|
-
if (!fails2(data, pattern, root, path)) {
|
|
1614
|
-
return false;
|
|
1615
|
-
}
|
|
1616
|
-
}
|
|
1617
|
-
return error2("data does not match oneOf patterns", data, patterns, path);
|
|
1618
|
-
};
|
|
1619
|
-
}
|
|
1620
|
-
function anyOf(...patterns) {
|
|
1621
|
-
return function _anyOf(data, root, path) {
|
|
1622
|
-
if (!Array.isArray(data)) {
|
|
1623
|
-
return error2("data is not an array", data, "anyOf", path);
|
|
1624
|
-
}
|
|
1625
|
-
for (let value of data) {
|
|
1626
|
-
if (oneOf(...patterns)(value)) {
|
|
1627
|
-
return error2("data does not match anyOf patterns", value, patterns, path);
|
|
1628
|
-
}
|
|
1629
|
-
}
|
|
1630
|
-
return false;
|
|
1631
|
-
};
|
|
1632
|
-
}
|
|
1633
|
-
function allOf(...patterns) {
|
|
1634
|
-
return function _allOf(data, root, path) {
|
|
1635
|
-
let problems = [];
|
|
1636
|
-
for (let pattern of patterns) {
|
|
1637
|
-
problems = problems.concat(fails2(data, pattern, root, path));
|
|
1638
|
-
}
|
|
1639
|
-
problems = problems.filter(Boolean);
|
|
1640
|
-
if (problems.length) {
|
|
1641
|
-
return error2("data does not match all given patterns", data, patterns, path, problems);
|
|
1642
|
-
}
|
|
1643
|
-
};
|
|
1644
|
-
}
|
|
1645
|
-
function validURL2(data, root, path) {
|
|
1646
|
-
try {
|
|
1647
|
-
if (data instanceof URL) {
|
|
1648
|
-
data = data.href;
|
|
1649
|
-
}
|
|
1650
|
-
let url2 = new URL(data);
|
|
1651
|
-
if (url2.href != data) {
|
|
1652
|
-
if (!(url2.href + "/" == data || url2.href == data + "/")) {
|
|
1653
|
-
return error2("data is not a valid url", data, "validURL", path);
|
|
1654
|
-
}
|
|
1655
|
-
}
|
|
1656
|
-
} catch (e) {
|
|
1657
|
-
return error2("data is not a valid url", data, "validURL", path);
|
|
1658
|
-
}
|
|
1659
|
-
}
|
|
1660
|
-
function validEmail(data, root, path) {
|
|
1661
|
-
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(data)) {
|
|
1662
|
-
return error2("data is not a valid email", data, "validEmail", path);
|
|
1663
|
-
}
|
|
1664
|
-
}
|
|
1665
|
-
function instanceOf(constructor) {
|
|
1666
|
-
return function _instanceOf(data, root, path) {
|
|
1667
|
-
if (!(data instanceof constructor)) {
|
|
1668
|
-
return error2("data is not an instanceof pattern", data, constructor, path);
|
|
1669
|
-
}
|
|
1670
|
-
};
|
|
1671
|
-
}
|
|
1672
|
-
function not(pattern) {
|
|
1673
|
-
return function _not(data, root, path) {
|
|
1674
|
-
if (!fails2(data, pattern, root, path)) {
|
|
1675
|
-
return error2("data matches pattern, when required not to", data, pattern, path);
|
|
1676
|
-
}
|
|
1677
|
-
};
|
|
1678
|
-
}
|
|
1679
|
-
function fails2(data, pattern, root, path = "") {
|
|
1680
|
-
if (!root) {
|
|
1681
|
-
root = data;
|
|
1682
|
-
}
|
|
1683
|
-
let problems = [];
|
|
1684
|
-
if (pattern === Boolean) {
|
|
1685
|
-
if (typeof data != "boolean" && !(data instanceof Boolean)) {
|
|
1686
|
-
problems.push(error2("data is not a boolean", data, pattern, path));
|
|
1687
|
-
}
|
|
1688
|
-
} else if (pattern === Number) {
|
|
1689
|
-
if (typeof data != "number" && !(data instanceof Number)) {
|
|
1690
|
-
problems.push(error2("data is not a number", data, pattern, path));
|
|
1691
|
-
}
|
|
1692
|
-
} else if (pattern === String) {
|
|
1693
|
-
if (typeof data != "string" && !(data instanceof String)) {
|
|
1694
|
-
problems.push(error2("data is not a string", data, pattern, path));
|
|
1695
|
-
}
|
|
1696
|
-
if (data == "") {
|
|
1697
|
-
problems.push(error2("data is an empty string, which is not allowed", data, pattern, path));
|
|
1698
|
-
}
|
|
1699
|
-
} else if (pattern instanceof RegExp) {
|
|
1700
|
-
if (Array.isArray(data)) {
|
|
1701
|
-
let index = data.findIndex((element, index2) => fails2(element, pattern, root, path + "[" + index2 + "]"));
|
|
1702
|
-
if (index > -1) {
|
|
1703
|
-
problems.push(error2("data[" + index + "] does not match pattern", data[index], pattern, path + "[" + index + "]"));
|
|
1704
|
-
}
|
|
1705
|
-
} else if (typeof data == "undefined") {
|
|
1706
|
-
problems.push(error2("data is undefined, should match pattern", data, pattern, path));
|
|
1707
|
-
} else if (!pattern.test(data)) {
|
|
1708
|
-
problems.push(error2("data does not match pattern", data, pattern, path));
|
|
1709
|
-
}
|
|
1710
|
-
} else if (pattern instanceof Function) {
|
|
1711
|
-
let problem = pattern(data, root, path);
|
|
1712
|
-
if (problem) {
|
|
1713
|
-
if (Array.isArray(problem)) {
|
|
1714
|
-
problems = problems.concat(problem);
|
|
1715
|
-
} else {
|
|
1716
|
-
problems.push(problem);
|
|
1717
|
-
}
|
|
1718
|
-
}
|
|
1719
|
-
} else if (Array.isArray(pattern)) {
|
|
1720
|
-
if (!Array.isArray(data)) {
|
|
1721
|
-
problems.push(error2("data is not an array", data, [], path));
|
|
1722
|
-
}
|
|
1723
|
-
for (let p of pattern) {
|
|
1724
|
-
for (let index of data.keys()) {
|
|
1725
|
-
let problem = fails2(data[index], p, root, path + "[" + index + "]");
|
|
1726
|
-
if (Array.isArray(problem)) {
|
|
1727
|
-
problems = problems.concat(problem);
|
|
1728
|
-
} else if (problem) {
|
|
1729
|
-
problems.push(problem);
|
|
1730
|
-
}
|
|
1731
|
-
}
|
|
1732
|
-
}
|
|
1733
|
-
} else if (pattern && typeof pattern == "object") {
|
|
1734
|
-
if (Array.isArray(data)) {
|
|
1735
|
-
let index = data.findIndex((element, index2) => fails2(element, pattern, root, path + "[" + index2 + "]"));
|
|
1736
|
-
if (index > -1) {
|
|
1737
|
-
problems.push(error2("data[" + index + "] does not match pattern", data[index], pattern, path + "[" + index + "]"));
|
|
1738
|
-
}
|
|
1739
|
-
} else if (!data || typeof data != "object") {
|
|
1740
|
-
problems.push(error2("data is not an object, pattern is", data, pattern, path));
|
|
1741
|
-
} else {
|
|
1742
|
-
if (data instanceof URLSearchParams) {
|
|
1743
|
-
data = Object.fromEntries(data);
|
|
1744
|
-
}
|
|
1745
|
-
if (pattern instanceof Function) {
|
|
1746
|
-
let result = fails2(data, pattern, root, path);
|
|
1747
|
-
if (result) {
|
|
1748
|
-
problems = problems.concat(result);
|
|
1749
|
-
}
|
|
1750
|
-
} else {
|
|
1751
|
-
for (const [patternKey, subpattern] of Object.entries(pattern)) {
|
|
1752
|
-
let result = fails2(data[patternKey], subpattern, root, path + "." + patternKey);
|
|
1753
|
-
if (result) {
|
|
1754
|
-
problems = problems.concat(result);
|
|
1755
|
-
}
|
|
1756
|
-
}
|
|
1757
|
-
}
|
|
1758
|
-
}
|
|
1759
|
-
} else {
|
|
1760
|
-
if (pattern != data) {
|
|
1761
|
-
problems.push(error2("data and pattern are not equal", data, pattern, path));
|
|
1762
|
-
}
|
|
1763
|
-
}
|
|
1764
|
-
if (problems.length) {
|
|
1765
|
-
return problems;
|
|
1766
|
-
}
|
|
1767
|
-
return false;
|
|
1768
|
-
}
|
|
1769
|
-
function error2(message, found, expected, path, problems) {
|
|
1770
|
-
let result = {
|
|
1771
|
-
path,
|
|
1772
|
-
message,
|
|
1773
|
-
found,
|
|
1774
|
-
expected
|
|
1775
|
-
};
|
|
1776
|
-
if (problems) {
|
|
1777
|
-
result.problems = problems;
|
|
1778
|
-
}
|
|
1779
|
-
return result;
|
|
1780
|
-
}
|
|
1781
|
-
function warn(message, data, pattern, path) {
|
|
1782
|
-
console.warn("\u{1F170}\uFE0F Assert: " + path, message, pattern, data);
|
|
1947
|
+
// node_modules/@muze-nl/metro-oauth2/src/browser.mjs
|
|
1948
|
+
var oauth2 = Object.assign({}, oauth2_exports, {
|
|
1949
|
+
oauth2mw,
|
|
1950
|
+
mockserver: oauth2_mockserver_exports,
|
|
1951
|
+
discover: oauth2_discovery_exports,
|
|
1952
|
+
tokenstore: tokenStore,
|
|
1953
|
+
dpopmw,
|
|
1954
|
+
keysstore: keysStore,
|
|
1955
|
+
authorizePopup,
|
|
1956
|
+
popupHandleRedirect: handleRedirect
|
|
1957
|
+
});
|
|
1958
|
+
if (!globalThis.metro.oauth2) {
|
|
1959
|
+
globalThis.metro.oauth2 = oauth2;
|
|
1783
1960
|
}
|
|
1784
|
-
globalThis.assert = {
|
|
1785
|
-
warn,
|
|
1786
|
-
error: error2,
|
|
1787
|
-
assert: assert2,
|
|
1788
|
-
enable,
|
|
1789
|
-
disable,
|
|
1790
|
-
Required: Required2,
|
|
1791
|
-
Recommended,
|
|
1792
|
-
Optional: Optional2,
|
|
1793
|
-
oneOf,
|
|
1794
|
-
anyOf,
|
|
1795
|
-
allOf,
|
|
1796
|
-
validURL: validURL2,
|
|
1797
|
-
validEmail,
|
|
1798
|
-
instanceOf,
|
|
1799
|
-
not,
|
|
1800
|
-
fails: fails2
|
|
1801
|
-
};
|
|
1802
1961
|
|
|
1803
1962
|
// src/oidc.util.mjs
|
|
1804
1963
|
var MustHave = (...options) => (value, root) => {
|
|
1805
1964
|
if (options.filter((o) => root.hasOwnKey(o)).length > 0) {
|
|
1806
1965
|
return false;
|
|
1807
1966
|
}
|
|
1808
|
-
return
|
|
1967
|
+
return error("root data must have all of", root, options);
|
|
1809
1968
|
};
|
|
1810
1969
|
var MustInclude = (...options) => (value) => {
|
|
1811
1970
|
if (Array.isArray(value) && options.filter((o) => !value.includes(o)).length == 0) {
|
|
1812
1971
|
return false;
|
|
1813
1972
|
} else {
|
|
1814
|
-
return
|
|
1973
|
+
return error("data must be an array which includes", value, options);
|
|
1815
1974
|
}
|
|
1816
1975
|
};
|
|
1817
1976
|
var validJWA = [
|
|
@@ -1825,7 +1984,7 @@
|
|
|
1825
1984
|
"ES384",
|
|
1826
1985
|
"ES512"
|
|
1827
1986
|
];
|
|
1828
|
-
var
|
|
1987
|
+
var validAuthMethods2 = [
|
|
1829
1988
|
"client_secret_post",
|
|
1830
1989
|
"client_secret_basic",
|
|
1831
1990
|
"client_secret_jwt",
|
|
@@ -1834,9 +1993,9 @@
|
|
|
1834
1993
|
|
|
1835
1994
|
// src/oidc.discovery.mjs
|
|
1836
1995
|
async function oidcDiscovery(options = {}) {
|
|
1837
|
-
|
|
1838
|
-
client:
|
|
1839
|
-
issuer:
|
|
1996
|
+
assert(options, {
|
|
1997
|
+
client: Optional(instanceOf(everything_default.client().constructor)),
|
|
1998
|
+
issuer: Required(validURL)
|
|
1840
1999
|
});
|
|
1841
2000
|
const defaultOptions = {
|
|
1842
2001
|
client: everything_default.client().with(throwermw()).with(jsonmw()),
|
|
@@ -1848,42 +2007,42 @@
|
|
|
1848
2007
|
return TestSucceeded;
|
|
1849
2008
|
}
|
|
1850
2009
|
const openid_provider_metadata = {
|
|
1851
|
-
issuer:
|
|
1852
|
-
authorization_endpoint:
|
|
1853
|
-
token_endpoint:
|
|
1854
|
-
userinfo_endpoint: Recommended(
|
|
2010
|
+
issuer: Required(allOf(options.issuer, MustUseHTTPS)),
|
|
2011
|
+
authorization_endpoint: Required(validURL),
|
|
2012
|
+
token_endpoint: Required(validURL),
|
|
2013
|
+
userinfo_endpoint: Recommended(validURL),
|
|
1855
2014
|
// todo: test for https protocol
|
|
1856
|
-
jwks_uri:
|
|
1857
|
-
registration_endpoint: options.requireDynamicRegistration ?
|
|
2015
|
+
jwks_uri: Required(validURL),
|
|
2016
|
+
registration_endpoint: options.requireDynamicRegistration ? Required(validURL) : Recommended(validURL),
|
|
1858
2017
|
scopes_supported: Recommended(MustInclude("openid")),
|
|
1859
|
-
response_types_supported: options.requireDynamicRegistration ?
|
|
1860
|
-
response_modes_supported:
|
|
1861
|
-
grant_types_supported: options.requireDynamicRegistration ?
|
|
1862
|
-
acr_values_supported:
|
|
1863
|
-
subject_types_supported:
|
|
1864
|
-
id_token_signing_alg_values_supported:
|
|
1865
|
-
id_token_encryption_alg_values_supported:
|
|
1866
|
-
id_token_encryption_enc_values_supported:
|
|
1867
|
-
userinfo_signing_alg_values_supported:
|
|
1868
|
-
userinfo_encryption_alg_values_supported:
|
|
1869
|
-
userinfo_encryption_enc_values_supported:
|
|
1870
|
-
request_object_signing_alg_values_supported:
|
|
2018
|
+
response_types_supported: options.requireDynamicRegistration ? Required(MustInclude("code", "id_token", "id_token token")) : Required([]),
|
|
2019
|
+
response_modes_supported: Optional([]),
|
|
2020
|
+
grant_types_supported: options.requireDynamicRegistration ? Optional(MustInclude("authorization_code")) : Optional([]),
|
|
2021
|
+
acr_values_supported: Optional([]),
|
|
2022
|
+
subject_types_supported: Required([]),
|
|
2023
|
+
id_token_signing_alg_values_supported: Required(MustInclude("RS256")),
|
|
2024
|
+
id_token_encryption_alg_values_supported: Optional([]),
|
|
2025
|
+
id_token_encryption_enc_values_supported: Optional([]),
|
|
2026
|
+
userinfo_signing_alg_values_supported: Optional([]),
|
|
2027
|
+
userinfo_encryption_alg_values_supported: Optional([]),
|
|
2028
|
+
userinfo_encryption_enc_values_supported: Optional([]),
|
|
2029
|
+
request_object_signing_alg_values_supported: Optional(MustInclude("RS256")),
|
|
1871
2030
|
// not testing for 'none'
|
|
1872
|
-
request_object_encryption_alg_values_supported:
|
|
1873
|
-
request_object_encryption_enc_values_supported:
|
|
1874
|
-
token_endpoint_auth_methods_supported:
|
|
1875
|
-
token_endpoint_auth_signing_alg_values_supported:
|
|
1876
|
-
display_values_supported:
|
|
1877
|
-
claim_types_supported:
|
|
2031
|
+
request_object_encryption_alg_values_supported: Optional([]),
|
|
2032
|
+
request_object_encryption_enc_values_supported: Optional([]),
|
|
2033
|
+
token_endpoint_auth_methods_supported: Optional(anyOf(...validAuthMethods2)),
|
|
2034
|
+
token_endpoint_auth_signing_alg_values_supported: Optional(MustInclude("RS256"), not(MustInclude("none"))),
|
|
2035
|
+
display_values_supported: Optional(anyOf("page", "popup", "touch", "wap")),
|
|
2036
|
+
claim_types_supported: Optional(anyOf("normal", "aggregated", "distributed")),
|
|
1878
2037
|
claims_supported: Recommended([]),
|
|
1879
|
-
service_documentation:
|
|
1880
|
-
claims_locales_supported:
|
|
1881
|
-
ui_locales_supported:
|
|
1882
|
-
claims_parameter_supported:
|
|
1883
|
-
request_parameter_supported:
|
|
1884
|
-
request_uri_parameter_supported:
|
|
1885
|
-
op_policy_uri:
|
|
1886
|
-
op_tos_uri:
|
|
2038
|
+
service_documentation: Optional(validURL),
|
|
2039
|
+
claims_locales_supported: Optional([]),
|
|
2040
|
+
ui_locales_supported: Optional([]),
|
|
2041
|
+
claims_parameter_supported: Optional(Boolean),
|
|
2042
|
+
request_parameter_supported: Optional(Boolean),
|
|
2043
|
+
request_uri_parameter_supported: Optional(Boolean),
|
|
2044
|
+
op_policy_uri: Optional(validURL),
|
|
2045
|
+
op_tos_uri: Optional(validURL)
|
|
1887
2046
|
};
|
|
1888
2047
|
const configURL = everything_default.url(options.issuer, ".well-known/openid-configuration");
|
|
1889
2048
|
const response2 = await options.client.get(
|
|
@@ -1892,49 +2051,49 @@
|
|
|
1892
2051
|
configURL
|
|
1893
2052
|
);
|
|
1894
2053
|
const openid_config = response2.data;
|
|
1895
|
-
|
|
1896
|
-
|
|
2054
|
+
assert(openid_config, openid_provider_metadata);
|
|
2055
|
+
assert(openid_config.issuer, options.issuer);
|
|
1897
2056
|
return openid_config;
|
|
1898
2057
|
}
|
|
1899
2058
|
|
|
1900
2059
|
// src/oidc.register.mjs
|
|
1901
2060
|
async function register(options) {
|
|
1902
2061
|
const openid_client_metadata = {
|
|
1903
|
-
redirect_uris:
|
|
1904
|
-
response_types:
|
|
1905
|
-
grant_types:
|
|
2062
|
+
redirect_uris: Required([validURL]),
|
|
2063
|
+
response_types: Optional([]),
|
|
2064
|
+
grant_types: Optional(anyOf("authorization_code", "refresh_token")),
|
|
1906
2065
|
//TODO: match response_types with grant_types
|
|
1907
|
-
application_type:
|
|
1908
|
-
contacts:
|
|
1909
|
-
client_name:
|
|
1910
|
-
logo_uri:
|
|
1911
|
-
client_uri:
|
|
1912
|
-
policy_uri:
|
|
1913
|
-
tos_uri:
|
|
1914
|
-
jwks_uri:
|
|
1915
|
-
jwks:
|
|
1916
|
-
sector_identifier_uri:
|
|
1917
|
-
subject_type:
|
|
1918
|
-
id_token_signed_response_alg:
|
|
1919
|
-
id_token_encrypted_response_alg:
|
|
1920
|
-
id_token_encrypted_response_enc:
|
|
1921
|
-
userinfo_signed_response_alg:
|
|
1922
|
-
userinfo_encrypted_response_alg:
|
|
1923
|
-
userinfo_encrypted_response_enc:
|
|
1924
|
-
request_object_signing_alg:
|
|
1925
|
-
request_object_encryption_alg:
|
|
1926
|
-
request_object_encryption_enc:
|
|
1927
|
-
token_endpoint_auth_method:
|
|
1928
|
-
token_endpoint_auth_signing_alg:
|
|
1929
|
-
default_max_age:
|
|
1930
|
-
require_auth_time:
|
|
1931
|
-
default_acr_values:
|
|
1932
|
-
initiate_login_uri:
|
|
1933
|
-
request_uris:
|
|
2066
|
+
application_type: Optional(oneOf("native", "web")),
|
|
2067
|
+
contacts: Optional([validEmail]),
|
|
2068
|
+
client_name: Optional(String),
|
|
2069
|
+
logo_uri: Optional(validURL),
|
|
2070
|
+
client_uri: Optional(validURL),
|
|
2071
|
+
policy_uri: Optional(validURL),
|
|
2072
|
+
tos_uri: Optional(validURL),
|
|
2073
|
+
jwks_uri: Optional(validURL, not(MustHave("jwks"))),
|
|
2074
|
+
jwks: Optional(validURL, not(MustHave("jwks_uri"))),
|
|
2075
|
+
sector_identifier_uri: Optional(validURL),
|
|
2076
|
+
subject_type: Optional(String),
|
|
2077
|
+
id_token_signed_response_alg: Optional(oneOf(...validJWA)),
|
|
2078
|
+
id_token_encrypted_response_alg: Optional(oneOf(...validJWA)),
|
|
2079
|
+
id_token_encrypted_response_enc: Optional(oneOf(...validJWA), MustHave("id_token_encrypted_response_alg")),
|
|
2080
|
+
userinfo_signed_response_alg: Optional(oneOf(...validJWA)),
|
|
2081
|
+
userinfo_encrypted_response_alg: Optional(oneOf(...validJWA)),
|
|
2082
|
+
userinfo_encrypted_response_enc: Optional(oneOf(...validJWA), MustHave("userinfo_encrypted_response_alg")),
|
|
2083
|
+
request_object_signing_alg: Optional(oneOf(...validJWA)),
|
|
2084
|
+
request_object_encryption_alg: Optional(oneOf(...validJWA)),
|
|
2085
|
+
request_object_encryption_enc: Optional(oneOf(...validJWA)),
|
|
2086
|
+
token_endpoint_auth_method: Optional(oneOf(...validAuthMethods2)),
|
|
2087
|
+
token_endpoint_auth_signing_alg: Optional(oneOf(...validJWA)),
|
|
2088
|
+
default_max_age: Optional(Number),
|
|
2089
|
+
require_auth_time: Optional(Boolean),
|
|
2090
|
+
default_acr_values: Optional([String]),
|
|
2091
|
+
initiate_login_uri: Optional([validURL]),
|
|
2092
|
+
request_uris: Optional([validURL])
|
|
1934
2093
|
};
|
|
1935
|
-
|
|
1936
|
-
client:
|
|
1937
|
-
registration_endpoint:
|
|
2094
|
+
assert(options, {
|
|
2095
|
+
client: Optional(instanceOf(everything_default.client().constructor)),
|
|
2096
|
+
registration_endpoint: validURL,
|
|
1938
2097
|
client_info: openid_client_metadata
|
|
1939
2098
|
});
|
|
1940
2099
|
const defaultOptions = {
|
|
@@ -1995,13 +2154,13 @@
|
|
|
1995
2154
|
}
|
|
1996
2155
|
};
|
|
1997
2156
|
options = Object.assign({}, defaultOptions, options);
|
|
1998
|
-
|
|
1999
|
-
client:
|
|
2157
|
+
assert(options, {
|
|
2158
|
+
client: Required(instanceOf(client().constructor)),
|
|
2000
2159
|
// required because it is set in defaultOptions
|
|
2001
|
-
client_info:
|
|
2002
|
-
issuer:
|
|
2003
|
-
oauth2:
|
|
2004
|
-
openid_configuration:
|
|
2160
|
+
client_info: Required(),
|
|
2161
|
+
issuer: Required(validURL),
|
|
2162
|
+
oauth2: Optional({}),
|
|
2163
|
+
openid_configuration: Optional()
|
|
2005
2164
|
});
|
|
2006
2165
|
if (!options.store) {
|
|
2007
2166
|
options.store = oidcStore(options.issuer);
|
|
@@ -2125,6 +2284,6 @@
|
|
|
2125
2284
|
if (!globalThis.metro.oidc) {
|
|
2126
2285
|
globalThis.metro.oidc = oidc;
|
|
2127
2286
|
}
|
|
2128
|
-
var
|
|
2287
|
+
var browser_default2 = oidc;
|
|
2129
2288
|
})();
|
|
2130
2289
|
//# sourceMappingURL=browser.js.map
|