@zodic/shared 0.0.103 → 0.0.104

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 (2) hide show
  1. package/package.json +1 -1
  2. package/utils/index.ts +4 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zodic/shared",
3
- "version": "0.0.103",
3
+ "version": "0.0.104",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "publishConfig": {
package/utils/index.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { jwtVerify } from 'jose';
2
- import { webcrypto } from 'node:crypto';
3
2
  import { AuthCtx, Gender, JWKS, VALID_GENDERS_ARRAY } from '../types';
4
3
 
5
4
  export const verifyToken = async (
@@ -10,7 +9,8 @@ export const verifyToken = async (
10
9
  const audience = c.env.GOOGLE_OAUTH_CLIENT_ID;
11
10
  const issuer = 'https://accounts.google.com';
12
11
 
13
- if (!jwtSecret) throw new Error('JWT Secret is not defined in the environment');
12
+ if (!jwtSecret)
13
+ throw new Error('JWT Secret is not defined in the environment');
14
14
 
15
15
  try {
16
16
  // ✅ Detect if token is from Google OAuth (ID Token)
@@ -30,7 +30,7 @@ export const verifyToken = async (
30
30
  const key = googleKeys.keys.find((k: any) => k.kid === kid);
31
31
  if (!key) throw new Error('Google public key not found');
32
32
 
33
- const publicKey = await webcrypto.subtle.importKey(
33
+ const publicKey = await crypto.subtle.importKey(
34
34
  'jwk',
35
35
  key,
36
36
  { name: 'RSASSA-PKCS1-v1_5', hash: 'SHA-256' },
@@ -49,7 +49,7 @@ export const verifyToken = async (
49
49
 
50
50
  return {
51
51
  userId: payload.sub, // Google User ID
52
- email: payload.email as string || undefined, // Email might be missing, so fallback to undefined
52
+ email: (payload.email as string) || undefined, // Email might be missing, so fallback to undefined
53
53
  };
54
54
  } else {
55
55
  // 🔹 Regular User Token → Verify with JWT_SECRET