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