1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | import * as Koa from 'koa';
|
10 |
|
11 | export = cors;
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | declare function cors(options?: cors.Options): Koa.Middleware;
|
19 |
|
20 | declare namespace cors {
|
21 | |
22 |
|
23 |
|
24 | interface Options {
|
25 | |
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | origin?: ((ctx: Koa.Context) => string) | ((ctx: Koa.Context) => PromiseLike<string>) | string | undefined;
|
34 |
|
35 | /**
|
36 | * `Access-Control-Allow-Methods`, default is
|
37 | * 'GET,HEAD,PUT,POST,DELETE,PATCH'
|
38 | */
|
39 | allowMethods?: string[] | string | undefined;
|
40 |
|
41 | /**
|
42 | * `Access-Control-Expose-Headers`
|
43 | */
|
44 | exposeHeaders?: string[] | string | undefined;
|
45 |
|
46 | /**
|
47 | * `Access-Control-Allow-Headers`
|
48 | */
|
49 | allowHeaders?: string[] | string | undefined;
|
50 |
|
51 | /**
|
52 | * `Access-Control-Max-Age` in seconds
|
53 | */
|
54 | maxAge?: number | string | undefined;
|
55 |
|
56 | /**
|
57 | * `Access-Control-Allow-Credentials`
|
58 | *
|
59 | * @remarks
|
60 | * If a function is provided, it will be called for each request with
|
61 | * the koa context object. It may return a boolean or a promise that
|
62 | * will resolve with a boolean.
|
63 | */
|
64 | credentials?:
|
65 | | ((ctx: Koa.Context) => boolean)
|
66 | | ((ctx: Koa.Context) => PromiseLike<boolean>)
|
67 | | boolean
|
68 | | undefined;
|
69 |
|
70 | /**
|
71 | * Add set headers to `err.header` if an error is thrown
|
72 | */
|
73 | keepHeadersOnError?: boolean | undefined;
|
74 |
|
75 | /**
|
76 | * Add `Cross-Origin-Opener-Policy` & `Cross-Origin-Embedder-Policy` to response headers
|
77 | *
|
78 | * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/Planned_changes
|
79 | */
|
80 | secureContext?: boolean | undefined;
|
81 |
|
82 | /**
|
83 | * Handle `Access-Control-Request-Private-Network` request by return `Access-Control-Allow-Private-Network`
|
84 | *
|
85 | * @see https://wicg.github.io/private-network-access/
|
86 | */
|
87 | privateNetworkAccess?: boolean | undefined;
|
88 | }
|
89 | }
|
90 |
|
\ | No newline at end of file |