oidc-spa 4.13.0 → 4.13.2

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.
Files changed (40) hide show
  1. package/OidcInitializationError.js +51 -32
  2. package/OidcInitializationError.js.map +1 -1
  3. package/backend.d.ts +0 -4
  4. package/backend.js +193 -109
  5. package/backend.js.map +1 -1
  6. package/mock/oidc.js +103 -57
  7. package/mock/oidc.js.map +1 -1
  8. package/mock/react.js +2 -2
  9. package/mock/react.js.map +1 -1
  10. package/oidc.js +944 -721
  11. package/oidc.js.map +1 -1
  12. package/package.json +1 -1
  13. package/react/react.js +135 -70
  14. package/react/react.js.map +1 -1
  15. package/src/backend.ts +0 -5
  16. package/tools/Deferred.js +35 -13
  17. package/tools/Deferred.js.map +1 -1
  18. package/tools/StatefulObservable.js +11 -11
  19. package/tools/StatefulObservable.js.map +1 -1
  20. package/tools/createIsUserActive.js +15 -15
  21. package/tools/createIsUserActive.js.map +1 -1
  22. package/tools/createObjectThatThrowsIfAccessed.js +61 -13
  23. package/tools/createObjectThatThrowsIfAccessed.js.map +1 -1
  24. package/tools/decodeJwt.js +1 -1
  25. package/tools/decodeJwt.js.map +1 -1
  26. package/tools/fnv1aHashToHex.js +2 -2
  27. package/tools/getDownlinkAndRtt.js +30 -8
  28. package/tools/getDownlinkAndRtt.js.map +1 -1
  29. package/tools/getPrUserInteraction.js +4 -4
  30. package/tools/getPrUserInteraction.js.map +1 -1
  31. package/tools/powerhooks/useGuaranteedMemo.js +29 -4
  32. package/tools/powerhooks/useGuaranteedMemo.js.map +1 -1
  33. package/tools/readExpirationTimeInJwt.js +3 -3
  34. package/tools/readExpirationTimeInJwt.js.map +1 -1
  35. package/tools/startCountdown.js +65 -17
  36. package/tools/startCountdown.js.map +1 -1
  37. package/tools/subscribeToUserInteraction.js +67 -18
  38. package/tools/subscribeToUserInteraction.js.map +1 -1
  39. package/tools/urlQueryParams.js +48 -29
  40. package/tools/urlQueryParams.js.map +1 -1
@@ -1,58 +1,75 @@
1
1
  "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
2
17
  Object.defineProperty(exports, "__esModule", { value: true });
3
18
  exports.OidcInitializationError = void 0;
4
- const tsafe_1 = require("./vendor/frontend/tsafe");
5
- class OidcInitializationError extends Error {
6
- constructor(params) {
7
- super((() => {
19
+ var tsafe_1 = require("./vendor/frontend/tsafe");
20
+ var OidcInitializationError = /** @class */ (function (_super) {
21
+ __extends(OidcInitializationError, _super);
22
+ function OidcInitializationError(params) {
23
+ var _newTarget = this.constructor;
24
+ var _this = _super.call(this, (function () {
8
25
  var _a;
9
26
  switch (params.type) {
10
27
  case "server down":
11
28
  return [
12
- `The OIDC server seems to be down.`,
13
- `If you know it's not the case it means that the issuerUri: ${params.issuerUri} is incorrect.`,
14
- `If you are using Keycloak makes sure that the realm exists and that the url is well formed.\n`,
15
- `More info: https://docs.oidc-spa.dev/resources/usage-with-keycloak`
29
+ "The OIDC server seems to be down.",
30
+ "If you know it's not the case it means that the issuerUri: ".concat(params.issuerUri, " is incorrect."),
31
+ "If you are using Keycloak makes sure that the realm exists and that the url is well formed.\n",
32
+ "More info: https://docs.oidc-spa.dev/resources/usage-with-keycloak"
16
33
  ].join(" ");
17
34
  case "bad configuration":
18
35
  switch (params.likelyCause.type) {
19
36
  case "misconfigured OIDC client":
20
37
  return [
21
- `The OIDC client ${params.likelyCause.clientId} seems to be misconfigured on your OIDC server.`,
22
- `If you are using Keycloak you likely need to add "${(_a = params.likelyCause.publicUrl) !== null && _a !== void 0 ? _a : window.location.origin}/*" to the list of Valid Redirect URIs`,
23
- `in the ${params.likelyCause.clientId} client configuration.\n`,
24
- `More info: https://docs.oidc-spa.dev/resources/usage-with-keycloak`,
25
- `Silent SSO timed out after ${params.likelyCause.timeoutDelayMs}ms.`
38
+ "The OIDC client ".concat(params.likelyCause.clientId, " seems to be misconfigured on your OIDC server."),
39
+ "If you are using Keycloak you likely need to add \"".concat((_a = params.likelyCause.publicUrl) !== null && _a !== void 0 ? _a : window.location.origin, "/*\" to the list of Valid Redirect URIs"),
40
+ "in the ".concat(params.likelyCause.clientId, " client configuration.\n"),
41
+ "More info: https://docs.oidc-spa.dev/resources/usage-with-keycloak",
42
+ "Silent SSO timed out after ".concat(params.likelyCause.timeoutDelayMs, "ms.")
26
43
  ].join(" ");
27
44
  case "not in Web Origins":
28
45
  return [
29
- `It seems that there is a CORS issue.`,
30
- `If you are using Keycloak check the "Web Origins" option in your ${params.likelyCause.clientId} client configuration.`,
31
- `You should probably add "${location.origin}/*" to the list.`,
32
- `More info: https://docs.oidc-spa.dev/resources/usage-with-keycloak`
46
+ "It seems that there is a CORS issue.",
47
+ "If you are using Keycloak check the \"Web Origins\" option in your ".concat(params.likelyCause.clientId, " client configuration."),
48
+ "You should probably add \"".concat(location.origin, "/*\" to the list."),
49
+ "More info: https://docs.oidc-spa.dev/resources/usage-with-keycloak"
33
50
  ].join(" ");
34
51
  case "silent-sso.html not reachable":
35
52
  return [
36
- `${params.likelyCause.silentSsoHtmlUrl} is not reachable. Make sure you've created the silent-sso.html file`,
37
- `in your public directory. More info: https://docs.oidc-spa.dev/documentation/installation`
53
+ "".concat(params.likelyCause.silentSsoHtmlUrl, " is not reachable. Make sure you've created the silent-sso.html file"),
54
+ "in your public directory. More info: https://docs.oidc-spa.dev/documentation/installation"
38
55
  ].join(" ");
39
56
  case "frame-ancestors none":
40
57
  return [
41
58
  params.likelyCause.silentSso.hasDedicatedHtmlFile
42
- ? `The silent-sso.html file, `
43
- : `The URI used for Silent SSO, `,
44
- `${params.likelyCause.silentSso.redirectUri}, `,
59
+ ? "The silent-sso.html file, "
60
+ : "The URI used for Silent SSO, ",
61
+ "".concat(params.likelyCause.silentSso.redirectUri, ", "),
45
62
  "is served by your web server with the HTTP header `Content-Security-Policy: frame-ancestors none` in the response.\n",
46
63
  "This header prevents the silent sign-in process from working.\n",
47
64
  "To fix this issue, you should configure your web server to not send this header or to use `frame-ancestors self` instead of `frame-ancestors none`.\n",
48
65
  "If you use Nginx, you can replace:\n",
49
- `add_header Content-Security-Policy "frame-ancestors 'none'";\n`,
66
+ "add_header Content-Security-Policy \"frame-ancestors 'none'\";\n",
50
67
  "with:\n",
51
- `map $uri $add_content_security_policy {\n`,
52
- ` "~*silent-sso\.html$" "frame-ancestors 'self'";\n`,
53
- ` default "frame-ancestors 'none'";\n`,
54
- `}\n`,
55
- `add_header Content-Security-Policy $add_content_security_policy;\n`
68
+ "map $uri $add_content_security_policy {\n",
69
+ " \"~*silent-sso.html$\" \"frame-ancestors 'self'\";\n",
70
+ " default \"frame-ancestors 'none'\";\n",
71
+ "}\n",
72
+ "add_header Content-Security-Policy $add_content_security_policy;\n"
56
73
  ].join(" ");
57
74
  }
58
75
  case "unknown":
@@ -61,10 +78,12 @@ class OidcInitializationError extends Error {
61
78
  (0, tsafe_1.assert)(false);
62
79
  })(),
63
80
  // @ts-expect-error
64
- { "cause": params.type === "unknown" ? params.cause : undefined });
65
- this.type = params.type;
66
- Object.setPrototypeOf(this, new.target.prototype);
81
+ { "cause": params.type === "unknown" ? params.cause : undefined }) || this;
82
+ _this.type = params.type;
83
+ Object.setPrototypeOf(_this, _newTarget.prototype);
84
+ return _this;
67
85
  }
68
- }
86
+ return OidcInitializationError;
87
+ }(Error));
69
88
  exports.OidcInitializationError = OidcInitializationError;
70
89
  //# sourceMappingURL=OidcInitializationError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OidcInitializationError.js","sourceRoot":"","sources":["src/OidcInitializationError.ts"],"names":[],"mappings":";;;AAAA,mDAA8D;AAE9D,MAAa,uBAAwB,SAAQ,KAAK;IAG9C,YACI,MAkCO;QAEP,KAAK,CACD,CAAC,GAAG,EAAE;;YACF,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;gBAClB,KAAK,aAAa;oBACd,OAAO;wBACH,mCAAmC;wBACnC,8DAA8D,MAAM,CAAC,SAAS,gBAAgB;wBAC9F,+FAA+F;wBAC/F,oEAAoE;qBACvE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAChB,KAAK,mBAAmB;oBACpB,QAAQ,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;wBAC9B,KAAK,2BAA2B;4BAC5B,OAAO;gCACH,mBAAmB,MAAM,CAAC,WAAW,CAAC,QAAQ,iDAAiD;gCAC/F,qDACI,MAAA,MAAM,CAAC,WAAW,CAAC,SAAS,mCAAI,MAAM,CAAC,QAAQ,CAAC,MACpD,wCAAwC;gCACxC,UAAU,MAAM,CAAC,WAAW,CAAC,QAAQ,0BAA0B;gCAC/D,oEAAoE;gCACpE,8BAA8B,MAAM,CAAC,WAAW,CAAC,cAAc,KAAK;6BACvE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;wBAChB,KAAK,oBAAoB;4BACrB,OAAO;gCACH,sCAAsC;gCACtC,oEAAoE,MAAM,CAAC,WAAW,CAAC,QAAQ,wBAAwB;gCACvH,4BAA4B,QAAQ,CAAC,MAAM,kBAAkB;gCAC7D,oEAAoE;6BACvE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;wBAChB,KAAK,+BAA+B;4BAChC,OAAO;gCACH,GAAG,MAAM,CAAC,WAAW,CAAC,gBAAgB,sEAAsE;gCAC5G,2FAA2F;6BAC9F,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;wBAChB,KAAK,sBAAsB;4BACvB,O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oBACpB,CAAC;gBACL,KAAK,SAAS;oBACV,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;YACpC,CAAC;YACD,IAAA,cAAM,EAA+B,KAAK,CAAC,CAAC;QAChD,CAAC,CAAC,EAAE;QACJ,mBAAmB;QACnB,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,EAAE,CACpE,SAAC;QACF,KAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACxB,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,WAAW,SAAS,CAAC,CAAC;;IACtD,CAAC;IACL,8BAAC;AAAD,CAAC,AAxGD,CAA6C,KAAK,GAwGjD;AAxGY,0DAAuB"}
package/backend.d.ts CHANGED
@@ -1,7 +1,3 @@
1
- export type KeycloakParams = {
2
- url: string;
3
- realm: string;
4
- };
5
1
  export type ParamsOfCreateOidcBackend<DecodedAccessToken extends Record<string, unknown>> = {
6
2
  issuerUri: string;
7
3
  decodedAccessTokenSchema?: {
package/backend.js CHANGED
@@ -22,120 +22,204 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __generator = (this && this.__generator) || function (thisArg, body) {
35
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
+ function verb(n) { return function (v) { return step([n, v]); }; }
38
+ function step(op) {
39
+ if (f) throw new TypeError("Generator is already executing.");
40
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
41
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
42
+ if (y = 0, t) op = [op[0] & 2, t.value];
43
+ switch (op[0]) {
44
+ case 0: case 1: t = op; break;
45
+ case 4: _.label++; return { value: op[1], done: false };
46
+ case 5: _.label++; y = op[1]; op = [0]; continue;
47
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
+ default:
49
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
+ if (t[2]) _.ops.pop();
54
+ _.trys.pop(); continue;
55
+ }
56
+ op = body.call(thisArg, _);
57
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
+ }
60
+ };
25
61
  Object.defineProperty(exports, "__esModule", { value: true });
26
62
  exports.createOidcBackend = createOidcBackend;
27
- const node_fetch_1 = require("./vendor/backend/node-fetch");
28
- const tsafe_1 = require("./vendor/backend/tsafe");
29
- const jwt = __importStar(require("./vendor/backend/jsonwebtoken"));
30
- const zod_1 = require("./vendor/backend/zod");
31
- const evt_1 = require("./vendor/backend/evt");
32
- const evt_2 = require("./vendor/backend/evt");
33
- async function createOidcBackend(params) {
34
- const { issuerUri, decodedAccessTokenSchema = zod_1.z.record(zod_1.z.unknown()) } = params;
35
- let { publicKey, signingAlgorithm } = await fetchPublicKeyAndSigningAlgorithm({ issuerUri });
36
- const evtInvalidSignature = evt_1.Evt.create();
37
- evtInvalidSignature.pipe((0, evt_2.throttleTime)(3600000)).attach(async () => {
38
- const wrap = await (async function callee(count) {
39
- let wrap;
40
- try {
41
- wrap = await fetchPublicKeyAndSigningAlgorithm({ issuerUri });
42
- }
43
- catch (error) {
44
- if (count === 9) {
45
- console.warn(`Failed to refresh public key and signing algorithm after ${count + 1} attempts`);
46
- return undefined;
47
- }
48
- const delayMs = 1000 * Math.pow(2, count);
49
- console.warn(`Failed to refresh public key and signing algorithm: ${String(error)}, retrying in ${delayMs}ms`);
50
- await new Promise(resolve => setTimeout(resolve, delayMs));
51
- return callee(count + 1);
63
+ var node_fetch_1 = require("./vendor/backend/node-fetch");
64
+ var tsafe_1 = require("./vendor/backend/tsafe");
65
+ var jwt = __importStar(require("./vendor/backend/jsonwebtoken"));
66
+ var zod_1 = require("./vendor/backend/zod");
67
+ var evt_1 = require("./vendor/backend/evt");
68
+ var evt_2 = require("./vendor/backend/evt");
69
+ function createOidcBackend(params) {
70
+ return __awaiter(this, void 0, void 0, function () {
71
+ var issuerUri, _a, decodedAccessTokenSchema, _b, publicKey, signingAlgorithm, evtInvalidSignature;
72
+ var _this = this;
73
+ return __generator(this, function (_c) {
74
+ switch (_c.label) {
75
+ case 0:
76
+ issuerUri = params.issuerUri, _a = params.decodedAccessTokenSchema, decodedAccessTokenSchema = _a === void 0 ? zod_1.z.record(zod_1.z.unknown()) : _a;
77
+ return [4 /*yield*/, fetchPublicKeyAndSigningAlgorithm({ issuerUri: issuerUri })];
78
+ case 1:
79
+ _b = _c.sent(), publicKey = _b.publicKey, signingAlgorithm = _b.signingAlgorithm;
80
+ evtInvalidSignature = evt_1.Evt.create();
81
+ evtInvalidSignature.pipe((0, evt_2.throttleTime)(3600000)).attach(function () { return __awaiter(_this, void 0, void 0, function () {
82
+ var wrap;
83
+ return __generator(this, function (_a) {
84
+ switch (_a.label) {
85
+ case 0: return [4 /*yield*/, (function callee(count) {
86
+ return __awaiter(this, void 0, void 0, function () {
87
+ var wrap, error_1, delayMs_1;
88
+ return __generator(this, function (_a) {
89
+ switch (_a.label) {
90
+ case 0:
91
+ _a.trys.push([0, 2, , 4]);
92
+ return [4 /*yield*/, fetchPublicKeyAndSigningAlgorithm({ issuerUri: issuerUri })];
93
+ case 1:
94
+ wrap = _a.sent();
95
+ return [3 /*break*/, 4];
96
+ case 2:
97
+ error_1 = _a.sent();
98
+ if (count === 9) {
99
+ console.warn("Failed to refresh public key and signing algorithm after ".concat(count + 1, " attempts"));
100
+ return [2 /*return*/, undefined];
101
+ }
102
+ delayMs_1 = 1000 * Math.pow(2, count);
103
+ console.warn("Failed to refresh public key and signing algorithm: ".concat(String(error_1), ", retrying in ").concat(delayMs_1, "ms"));
104
+ return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, delayMs_1); })];
105
+ case 3:
106
+ _a.sent();
107
+ return [2 /*return*/, callee(count + 1)];
108
+ case 4: return [2 /*return*/, wrap];
109
+ }
110
+ });
111
+ });
112
+ })(0)];
113
+ case 1:
114
+ wrap = _a.sent();
115
+ if (wrap === undefined) {
116
+ return [2 /*return*/];
117
+ }
118
+ publicKey = wrap.publicKey;
119
+ signingAlgorithm = wrap.signingAlgorithm;
120
+ return [2 /*return*/];
121
+ }
122
+ });
123
+ }); });
124
+ return [2 /*return*/, {
125
+ "verifyAndDecodeAccessToken": function (_a) {
126
+ var accessToken = _a.accessToken;
127
+ var result = (0, tsafe_1.id)(undefined);
128
+ jwt.verify(accessToken, publicKey, { algorithms: [signingAlgorithm] }, function (err, decoded) {
129
+ invalid: {
130
+ if (!err) {
131
+ break invalid;
132
+ }
133
+ if (err.name === "TokenExpiredError") {
134
+ result = (0, tsafe_1.id)({
135
+ "isValid": false,
136
+ "errorCase": "expired",
137
+ "errorMessage": err.message
138
+ });
139
+ return;
140
+ }
141
+ evtInvalidSignature.post();
142
+ result = (0, tsafe_1.id)({
143
+ "isValid": false,
144
+ "errorCase": "invalid signature",
145
+ "errorMessage": err.message
146
+ });
147
+ return;
148
+ }
149
+ var decodedAccessToken;
150
+ try {
151
+ decodedAccessToken = decodedAccessTokenSchema.parse(decoded);
152
+ }
153
+ catch (error) {
154
+ result = (0, tsafe_1.id)({
155
+ "isValid": false,
156
+ "errorCase": "does not respect schema",
157
+ "errorMessage": String(error)
158
+ });
159
+ return;
160
+ }
161
+ result = (0, tsafe_1.id)({
162
+ "isValid": true,
163
+ "decodedAccessToken": decodedAccessToken
164
+ });
165
+ });
166
+ (0, tsafe_1.assert)(result !== undefined);
167
+ return result;
168
+ }
169
+ }];
52
170
  }
53
- return wrap;
54
- })(0);
55
- if (wrap === undefined) {
56
- return;
57
- }
58
- publicKey = wrap.publicKey;
59
- signingAlgorithm = wrap.signingAlgorithm;
171
+ });
60
172
  });
61
- return {
62
- "verifyAndDecodeAccessToken": ({ accessToken }) => {
63
- let result = (0, tsafe_1.id)(undefined);
64
- jwt.verify(accessToken, publicKey, { algorithms: [signingAlgorithm] }, (err, decoded) => {
65
- invalid: {
66
- if (!err) {
67
- break invalid;
68
- }
69
- if (err.name === "TokenExpiredError") {
70
- result = (0, tsafe_1.id)({
71
- "isValid": false,
72
- "errorCase": "expired",
73
- "errorMessage": err.message
74
- });
75
- return;
173
+ }
174
+ function fetchPublicKeyAndSigningAlgorithm(params) {
175
+ return __awaiter(this, void 0, void 0, function () {
176
+ var issuerUri, certUri, response, data, error_2, keys, signatureKey, signingAlgorithm, publicKey;
177
+ return __generator(this, function (_a) {
178
+ switch (_a.label) {
179
+ case 0:
180
+ issuerUri = params.issuerUri;
181
+ certUri = "".concat(issuerUri.replace(/\/$/, ""), "/protocol/openid-connect/certs");
182
+ return [4 /*yield*/, (0, node_fetch_1.fetch)(certUri)];
183
+ case 1:
184
+ response = _a.sent();
185
+ if (!response.ok) {
186
+ throw new Error("Failed to fetch public key and algorithm from ".concat(certUri, ": ").concat(response.statusText));
76
187
  }
77
- evtInvalidSignature.post();
78
- result = (0, tsafe_1.id)({
79
- "isValid": false,
80
- "errorCase": "invalid signature",
81
- "errorMessage": err.message
82
- });
83
- return;
84
- }
85
- let decodedAccessToken;
86
- try {
87
- decodedAccessToken = decodedAccessTokenSchema.parse(decoded);
88
- }
89
- catch (error) {
90
- result = (0, tsafe_1.id)({
91
- "isValid": false,
92
- "errorCase": "does not respect schema",
93
- "errorMessage": String(error)
188
+ _a.label = 2;
189
+ case 2:
190
+ _a.trys.push([2, 4, , 5]);
191
+ return [4 /*yield*/, response.json()];
192
+ case 3:
193
+ data = _a.sent();
194
+ return [3 /*break*/, 5];
195
+ case 4:
196
+ error_2 = _a.sent();
197
+ throw new Error("Failed to parse json from ".concat(certUri, ": ").concat(String(error_2)));
198
+ case 5:
199
+ keys = zod_1.z
200
+ .object({
201
+ "keys": zod_1.z.array(zod_1.z.object({
202
+ "use": zod_1.z.string(),
203
+ "alg": zod_1.z.string(),
204
+ "x5c": zod_1.z.tuple([zod_1.z.string()])
205
+ }))
206
+ })
207
+ .parse(data).keys;
208
+ signatureKey = keys.find(function (_a) {
209
+ var use = _a.use;
210
+ return use === "sig";
94
211
  });
95
- return;
96
- }
97
- result = (0, tsafe_1.id)({
98
- "isValid": true,
99
- "decodedAccessToken": decodedAccessToken
100
- });
101
- });
102
- (0, tsafe_1.assert)(result !== undefined);
103
- return result;
104
- }
105
- };
106
- }
107
- async function fetchPublicKeyAndSigningAlgorithm(params) {
108
- const { issuerUri } = params;
109
- const certUri = `${issuerUri.replace(/\/$/, "")}/protocol/openid-connect/certs`;
110
- const response = await (0, node_fetch_1.fetch)(certUri);
111
- if (!response.ok) {
112
- throw new Error(`Failed to fetch public key and algorithm from ${certUri}: ${response.statusText}`);
113
- }
114
- let data;
115
- try {
116
- data = await response.json();
117
- }
118
- catch (error) {
119
- throw new Error(`Failed to parse json from ${certUri}: ${String(error)}`);
120
- }
121
- const { keys } = zod_1.z
122
- .object({
123
- "keys": zod_1.z.array(zod_1.z.object({
124
- "use": zod_1.z.string(),
125
- "alg": zod_1.z.string(),
126
- "x5c": zod_1.z.tuple([zod_1.z.string()])
127
- }))
128
- })
129
- .parse(data);
130
- const signatureKey = keys.find(({ use }) => use === "sig");
131
- (0, tsafe_1.assert)(signatureKey !== undefined, "No signature key found");
132
- const signingAlgorithm = signatureKey["alg"];
133
- (0, tsafe_1.assert)((0, tsafe_1.isAmong)(["RS256", "RS384", "RS512"], signingAlgorithm), `Unsupported algorithm ${signingAlgorithm}`);
134
- const publicKey = [
135
- "-----BEGIN CERTIFICATE-----",
136
- signatureKey.x5c[0],
137
- "-----END CERTIFICATE-----"
138
- ].join("\n");
139
- return { publicKey, signingAlgorithm };
212
+ (0, tsafe_1.assert)(signatureKey !== undefined, "No signature key found");
213
+ signingAlgorithm = signatureKey["alg"];
214
+ (0, tsafe_1.assert)((0, tsafe_1.isAmong)(["RS256", "RS384", "RS512"], signingAlgorithm), "Unsupported algorithm ".concat(signingAlgorithm));
215
+ publicKey = [
216
+ "-----BEGIN CERTIFICATE-----",
217
+ signatureKey.x5c[0],
218
+ "-----END CERTIFICATE-----"
219
+ ].join("\n");
220
+ return [2 /*return*/, { publicKey: publicKey, signingAlgorithm: signingAlgorithm }];
221
+ }
222
+ });
223
+ });
140
224
  }
141
225
  //# sourceMappingURL=backend.js.map
package/backend.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"backend.js","sourceRoot":"","sources":["src/backend.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,8CAyGC;AAtJD,4DAAoD;AACpD,kDAA6D;AAC7D,mEAAqD;AACrD,8CAAyC;AACzC,8CAA2C;AAC3C,8CAAoD;AAwC7C,KAAK,UAAU,iBAAiB,CACnC,MAAqD;IAErD,MAAM,EAAE,SAAS,EAAE,wBAAwB,GAAG,OAAC,CAAC,MAAM,CAAC,OAAC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