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
44 lines (38 loc) · 1.39 KB
/
Copy pathtypes.ts
File metadata and controls
44 lines (38 loc) · 1.39 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
import type { AuthObject, createClerkClient } from '@clerk/backend';
import type { AuthenticateRequestOptions, SignedInAuthObject } from '@clerk/backend/internal';
import type { MultiDomainAndOrProxy } from '@clerk/types';
import type { NextFunction, Request, Response } from 'express';
import type { IncomingMessage } from 'http';
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: AuthObject };
export type StrictAuthProp = { auth: 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 createClerkClient>;
export type AuthenticateRequestParams = {
clerkClient: ClerkClient;
publishableKey?: string;
secretKey?: string;
req: IncomingMessage;
options?: ClerkMiddlewareOptions;
};