Skip to content

Commit cada27d

Browse files
committed
refactor: add more error handling
1 parent 1ba19f4 commit cada27d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/lib/auth/auth.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ function getSecret(): Uint8Array {
2929
}
3030

3131
// Token expiration constants
32-
const TOKEN_ONE_HOUR_MS = 60 * 60 * 1000; // milliseconds
33-
const TOKEN_SEVEN_DAYS_SECONDS = 7 * 24 * 60 * 60; // seconds
32+
const TOKEN_ONE_HOUR_MS = 60 * 60 * 1000; // 1 hour in ms
33+
const TOKEN_SEVEN_DAYS_SECONDS = 7 * 24 * 60 * 60; // 7 days in seconds
3434

3535
// Cookie configuration
3636
const COOKIE_NAME = "oidc_token" as const;
@@ -105,7 +105,9 @@ export async function decrypt(jwe: string): Promise<OidcTokenData> {
105105
if (error instanceof jose.errors.JWEInvalid) {
106106
throw new Error("Invalid JWE format");
107107
}
108-
throw error;
108+
// Wrap unexpected errors to avoid exposing internal details
109+
const message = error instanceof Error ? error.message : "Unknown error";
110+
throw new Error(`Token decryption error: ${message}`);
109111
}
110112
}
111113

0 commit comments

Comments
 (0)