@meistrari/data-token 1.0.2 → 1.0.3
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/index.mjs +14 -13
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -80,20 +80,21 @@ function getValidator(jwksUrl, {
|
|
|
80
80
|
);
|
|
81
81
|
return DataToken.parse(payload);
|
|
82
82
|
} catch (error) {
|
|
83
|
-
if (error instanceof errors.
|
|
84
|
-
|
|
85
|
-
const tokenHeader = JSON.parse(Buffer.from(header, "base64").toString("utf-8"));
|
|
86
|
-
const jwksResponse = await fetch(jwksUrl);
|
|
87
|
-
const jwksText = await jwksResponse.json();
|
|
88
|
-
logger.error({
|
|
89
|
-
level: "error",
|
|
90
|
-
message: "No matching key found in JWKS for token",
|
|
91
|
-
jwksUrl,
|
|
92
|
-
algorithms,
|
|
93
|
-
jwks: jwksText,
|
|
94
|
-
tokenHeader
|
|
95
|
-
});
|
|
83
|
+
if (error instanceof errors.JWTExpired) {
|
|
84
|
+
throw error;
|
|
96
85
|
}
|
|
86
|
+
const [header] = token.split(".");
|
|
87
|
+
const tokenHeader = JSON.parse(Buffer.from(header, "base64").toString("utf-8"));
|
|
88
|
+
const jwksResponse = await fetch(jwksUrl);
|
|
89
|
+
const jwksText = await jwksResponse.json();
|
|
90
|
+
logger.error({
|
|
91
|
+
level: "error",
|
|
92
|
+
error,
|
|
93
|
+
jwksUrl,
|
|
94
|
+
algorithms,
|
|
95
|
+
jwks: jwksText,
|
|
96
|
+
tokenHeader
|
|
97
|
+
}, "Failed to validate data token");
|
|
97
98
|
throw error;
|
|
98
99
|
}
|
|
99
100
|
};
|
package/package.json
CHANGED