Skip to content

Commit 91b0367

Browse files
authored
[service-utils] fix auth cache for cf workers (#6219)
1 parent c86e13b commit 91b0367

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

.changeset/hungry-books-jump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@thirdweb-dev/service-utils": patch
3+
---
4+
5+
[service-utils] fix auth for cf workers

packages/service-utils/src/cf-worker/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import type {
66
import type { Request } from "@cloudflare/workers-types";
77
import type { CoreServiceConfig, TeamAndProjectResponse } from "../core/api.js";
88
import { authorize } from "../core/authorize/index.js";
9-
import type { AuthorizationInput } from "../core/authorize/index.js";
9+
import type {
10+
AuthorizationInput,
11+
TeamAndProjectCacheWithPossibleTTL,
12+
} from "../core/authorize/index.js";
1013
import type { AuthorizationResult } from "../core/authorize/types.js";
1114
import type { CoreAuthInput } from "../core/types.js";
1215

@@ -54,14 +57,14 @@ export async function authorizeWorker(
5457

5558
return await authorize(authData, serviceConfig, {
5659
get: async (clientId: string) => serviceConfig.kvStore.get(clientId),
57-
put: (clientId: string, data: TeamAndProjectResponse) =>
60+
put: (clientId: string, teamAndProjectResponse: TeamAndProjectResponse) =>
5861
serviceConfig.ctx.waitUntil(
5962
serviceConfig.kvStore.put(
6063
clientId,
6164
JSON.stringify({
6265
updatedAt: Date.now(),
63-
data,
64-
}),
66+
teamAndProjectResponse,
67+
} satisfies TeamAndProjectCacheWithPossibleTTL),
6568
{
6669
expirationTtl:
6770
serviceConfig.cacheTtlSeconds &&

packages/service-utils/src/core/authorize/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export type CacheOptions = {
2828
cacheTtlSeconds: number;
2929
};
3030

31-
type TeamAndProjectCacheWithPossibleTTL =
31+
export type TeamAndProjectCacheWithPossibleTTL =
3232
| {
3333
teamAndProjectResponse: TeamAndProjectResponse;
3434
updatedAt: number;

0 commit comments

Comments
 (0)