Skip to content

Commit 6475f73

Browse files
committed
Make expiresAt mandatory since it is validated as mandatory at runtime
1 parent c94ba4b commit 6475f73

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/server/auth/middleware/bearerAuth.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ describe("requireBearerAuth middleware", () => {
9595
token: "no-expiration-token",
9696
clientId: "client-123",
9797
scopes: ["read", "write"],
98-
expiresAt
98+
99+
// Type does not accept possible undefined so an assertion is required for this test
100+
expiresAt: expiresAt as number
99101
};
100102
mockVerifyAccessToken.mockResolvedValue(noExpirationAuthInfo);
101103

@@ -146,6 +148,7 @@ describe("requireBearerAuth middleware", () => {
146148
token: "valid-token",
147149
clientId: "client-123",
148150
scopes: ["read"],
151+
expiresAt: Math.floor(Date.now() / 1000) + 3600,
149152
};
150153
mockVerifyAccessToken.mockResolvedValue(authInfo);
151154

@@ -418,6 +421,7 @@ describe("requireBearerAuth middleware", () => {
418421
token: "valid-token",
419422
clientId: "client-123",
420423
scopes: ["read"],
424+
expiresAt: Math.floor(Date.now() / 1000) + 3600,
421425
};
422426
mockVerifyAccessToken.mockResolvedValue(authInfo);
423427

src/server/auth/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export interface AuthInfo {
2020
/**
2121
* When the token expires (in seconds since epoch).
2222
*/
23-
expiresAt?: number;
23+
expiresAt: number;
2424

2525
/**
2626
* The RFC 8707 resource server identifier for which this token is valid.
@@ -33,4 +33,4 @@ export interface AuthInfo {
3333
* This field should be used for any additional data that needs to be attached to the auth info.
3434
*/
3535
extra?: Record<string, unknown>;
36-
}
36+
}

0 commit comments

Comments
 (0)