@meistrari/data-token 1.2.4 → 1.2.5

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.
@@ -1,6 +1,5 @@
1
1
  import Elysia from 'elysia';
2
2
  import { getValidator } from '../index.mjs';
3
- import 'node:buffer';
4
3
  import 'jose';
5
4
  import '@meistrari/logger';
6
5
  import 'zod';
@@ -1,6 +1,5 @@
1
1
  import { createMiddleware } from 'hono/factory';
2
2
  import { getValidator } from '../index.mjs';
3
- import 'node:buffer';
4
3
  import 'jose';
5
4
  import '@meistrari/logger';
6
5
  import 'zod';
package/dist/index.mjs CHANGED
@@ -1,4 +1,3 @@
1
- import { Buffer } from 'node:buffer';
2
1
  import { createRemoteJWKSet, jwtVerify, errors, decodeJwt } from 'jose';
3
2
  import pino from '@meistrari/logger';
4
3
  import { z } from 'zod';
@@ -90,17 +89,10 @@ function getValidator(jwksUrl, {
90
89
  if (error instanceof errors.JWTExpired) {
91
90
  throw error;
92
91
  }
93
- const [header] = token.split(".");
94
- const tokenHeader = JSON.parse(Buffer.from(header, "base64").toString("utf-8"));
95
- const jwksResponse = await fetch(jwksUrl);
96
- const jwksText = await jwksResponse.json();
97
- logger.error({
98
- error,
99
- jwksUrl,
100
- algorithms,
101
- jwks: jwksText,
102
- tokenHeader
103
- }, "Failed to validate data token");
92
+ try {
93
+ logger.error({ error, jwksUrl, algorithms }, "Failed to validate data token");
94
+ } catch {
95
+ }
104
96
  throw error;
105
97
  }
106
98
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@meistrari/data-token",
3
3
  "type": "module",
4
- "version": "1.2.4",
4
+ "version": "1.2.5",
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",
@@ -32,12 +32,12 @@
32
32
  "node": "^20.15.1"
33
33
  },
34
34
  "scripts": {
35
- "test": "echo \"Error: no test specified\" && exit 1",
35
+ "test": "ENVIRONMENT=unknown bun test src",
36
36
  "build": "unbuild",
37
37
  "prepare": "husky",
38
38
  "lint": "eslint src",
39
39
  "lint:fix": "eslint src --fix",
40
- "check": "bun run lint && bun tsc --noEmit",
40
+ "check": "bun run lint && bun tsc --noEmit && bun run test",
41
41
  "prepack": "bun run build"
42
42
  },
43
43
  "dependencies": {