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