forked from clerk/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
55 lines (48 loc) · 1.66 KB
/
Copy pathtypes.ts
File metadata and controls
55 lines (48 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import type { AuthenticateRequestOptions, AuthObject, Clerk, SignedInAuthObject } from '@clerk/backend';
import type { MultiDomainAndOrProxy } from '@clerk/types';
import type { NextFunction, Request, Response } from 'express';
import type { IncomingMessage } from 'http';
type LegacyAuthObject<T extends AuthObject> = Pick<T, 'sessionId' | 'userId' | 'actor' | 'getToken' | 'debug'> & {
claims: AuthObject['sessionClaims'];
};
export type MiddlewareWithAuthProp = (
// req: WithAuthProp<Request>
req: Request,
res: Response,
next: NextFunction,
) => Promise<void>;
export type MiddlewareRequireAuthProp = (
// req: RequireAuthProp<Request>,
req: Request,
res: Response,
next: NextFunction,
) => Promise<void>;
export type LooseAuthProp = { auth: LegacyAuthObject<AuthObject> };
export type StrictAuthProp = { auth: LegacyAuthObject<SignedInAuthObject> };
export type WithAuthProp<T> = T & LooseAuthProp;
export type RequireAuthProp<T> = T & StrictAuthProp;
export type ClerkMiddleware = MiddlewareWithAuthProp | MiddlewareRequireAuthProp;
export type ClerkMiddlewareOptions = {
onError?: (error: any) => unknown;
authorizedParties?: string[];
audience?: AuthenticateRequestOptions['audience'];
jwtKey?: string;
strict?: boolean;
signInUrl?: string;
} & MultiDomainAndOrProxy;
export type ClerkClient = ReturnType<typeof Clerk>;
export type AuthenticateRequestParams = {
clerkClient: ClerkClient;
publishableKey?: string;
secretKey?: string;
/**
* @deprecated Use `publishableKey` instead.
*/
frontendApi?: string;
/**
* @deprecated Use `secretKey` instead.
*/
apiKey?: string;
req: IncomingMessage;
options?: ClerkMiddlewareOptions;
};