Skip to content

Commit f0126a7

Browse files
authored
Fix(clerk-sdk-node): Make request.auth to be AuthObject instead of LegacyAuthObject(clerk#2609)
* fix(clerk-sdk-node): Make `request.auth` to be AuthObject instead of LegacyAuthObject * chore(repo): Add changeset
1 parent d607192 commit f0126a7

2 files changed

Lines changed: 31 additions & 6 deletions

File tree

.changeset/neat-crabs-know.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
'@clerk/clerk-sdk-node': major
3+
---
4+
5+
Changes the `request.auth` type from `LegacyAuthObject` to `AuthObject`.
6+
```typescript
7+
type LegacyAuthObject = {
8+
sessionId: string | null;
9+
actor: ActClaim | undefined | null;
10+
userId: string | null;
11+
getToken: ServerGetToken | null;
12+
debug: AuthObjectDebug | null;
13+
claims: JwtPayload | null;
14+
}
15+
16+
type AuthObject = {
17+
sessionClaims: JwtPayload | null;
18+
sessionId: string | null;
19+
actor: ActClaim | undefined | null;
20+
userId: string | null;
21+
orgId: string | undefined | null;
22+
orgRole: OrganizationCustomRoleKey | undefined | null;
23+
orgSlug: string | undefined | null;
24+
orgPermissions: OrganizationCustomPermissionKey[] | undefined | null;
25+
getToken: ServerGetToken | null;
26+
has: CheckAuthorizationWithCustomPermissions | null;
27+
debug: AuthObjectDebug | null;
28+
};
29+
```

packages/sdk-node/src/types.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ import type { MultiDomainAndOrProxy } from '@clerk/types';
44
import type { NextFunction, Request, Response } from 'express';
55
import type { IncomingMessage } from 'http';
66

7-
type LegacyAuthObject<T extends AuthObject> = Pick<T, 'sessionId' | 'userId' | 'actor' | 'getToken' | 'debug'> & {
8-
claims: AuthObject['sessionClaims'];
9-
};
10-
117
export type MiddlewareWithAuthProp = (
128
// req: WithAuthProp<Request>
139
req: Request,
@@ -22,8 +18,8 @@ export type MiddlewareRequireAuthProp = (
2218
next: NextFunction,
2319
) => Promise<void>;
2420

25-
export type LooseAuthProp = { auth: LegacyAuthObject<AuthObject> };
26-
export type StrictAuthProp = { auth: LegacyAuthObject<SignedInAuthObject> };
21+
export type LooseAuthProp = { auth: AuthObject };
22+
export type StrictAuthProp = { auth: SignedInAuthObject };
2723
export type WithAuthProp<T> = T & LooseAuthProp;
2824
export type RequireAuthProp<T> = T & StrictAuthProp;
2925

0 commit comments

Comments
 (0)