@meistrari/data-token 0.0.9 → 0.0.10
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.js +5 -2
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { createRemoteJWKSet, jwtVerify } from 'jose';
|
|
1
|
+
import { createRemoteJWKSet, errors, jwtVerify } from 'jose';
|
|
2
|
+
import { ExponentialBackoff, handleType, retry } from 'cockatiel';
|
|
2
3
|
import { DataToken } from './types';
|
|
4
|
+
const retryJWKS = retry(handleType(errors.JWKSTimeout)
|
|
5
|
+
.orWhen(err => err.message.includes('ECONNRESET')), { maxAttempts: 3, backoff: new ExponentialBackoff() });
|
|
3
6
|
export function getValidator(jwksUrl, { algorithms } = { algorithms: ['RS256'] }) {
|
|
4
7
|
const JWKS = createRemoteJWKSet(new URL(jwksUrl));
|
|
5
8
|
return async (token) => {
|
|
6
|
-
const { payload } = await jwtVerify(token, JWKS, { algorithms });
|
|
9
|
+
const { payload } = await retryJWKS.execute(async () => jwtVerify(token, JWKS, { algorithms }));
|
|
7
10
|
return DataToken.parse(payload);
|
|
8
11
|
};
|
|
9
12
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meistrari/data-token",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.10",
|
|
5
5
|
"description": "Internal library to verify and decode the API Gateway data token",
|
|
6
6
|
"author": "Roz <roz@meistrari.com>",
|
|
7
7
|
"license": "UNLICENSED",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"prepack": "bun run build"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
+
"cockatiel": "^3.2.1",
|
|
31
32
|
"jose": "^5.8.0",
|
|
32
33
|
"zod": "^3.23.8"
|
|
33
34
|
},
|