@canmingir/link-express 1.7.11 → 1.7.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canmingir/link-express",
3
- "version": "1.7.11",
3
+ "version": "1.7.12",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "types": "index.ts",
@@ -1,11 +1,29 @@
1
1
  import { CognitoJwtVerifier } from "aws-jwt-verify";
2
2
 
3
- export const cognitoAccessTokenVerifier = CognitoJwtVerifier.create({
4
- userPoolId: process.env.COGNITO_USER_POOL_ID!,
5
- tokenUse: "access",
6
- clientId: process.env.COGNITO_CLIENT_ID!,
7
- });
3
+ const userPoolId = process.env.COGNITO_USER_POOL_ID;
4
+ const clientId = process.env.COGNITO_CLIENT_ID;
5
+
6
+ if (!userPoolId || !clientId) {
7
+ console.warn(
8
+ "Cognito is not fully configured. Missing COGNITO_USER_POOL_ID or COGNITO_CLIENT_ID.",
9
+ );
10
+ }
11
+
12
+ const cognitoAccessTokenVerifier =
13
+ userPoolId && clientId
14
+ ? CognitoJwtVerifier.create({
15
+ userPoolId,
16
+ tokenUse: "access",
17
+ clientId,
18
+ })
19
+ : null;
8
20
 
9
21
  export async function verifyCognitoAccessToken(token: string) {
22
+ if (!cognitoAccessTokenVerifier) {
23
+ throw new Error(
24
+ "Cognito is not configured. Set COGNITO_USER_POOL_ID and COGNITO_CLIENT_ID.",
25
+ );
26
+ }
27
+
10
28
  return cognitoAccessTokenVerifier.verify(token);
11
29
  }