@aomex/cors 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,37 +1,17 @@
1
1
  # @aomex/cors
2
2
 
3
- ## 0.0.4
3
+ ## 0.0.6
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - Updated dependencies [[`d3a2757`](https://github.com/aomex/aomex/commit/d3a2757b38391ad70a206d95eac09520c64e9b85), [`07c8575`](https://github.com/aomex/aomex/commit/07c857565ede4eca7e88de4e8c5e5f244f9d16cb), [`e80844a`](https://github.com/aomex/aomex/commit/e80844a6808fd0f3b9d613ec3163b06357316cae), [`146b6b5`](https://github.com/aomex/aomex/commit/146b6b5f09d4b9f557c1771686f3585bebf4cfc9), [`56f65c8`](https://github.com/aomex/aomex/commit/56f65c8509b40679272ed58f63e12d98e1818503), [`c6df4de`](https://github.com/aomex/aomex/commit/c6df4de61fc28f452f8a202c9a485e1a061b3eb6), [`79e19c1`](https://github.com/aomex/aomex/commit/79e19c1ae2a35b38580a4d2a27b6dde634345126), [`9adefaa`](https://github.com/aomex/aomex/commit/9adefaa8baaaafb7be610c7a98920c9830d10a3c), [`a8bb601`](https://github.com/aomex/aomex/commit/a8bb601acaf1e1d580511ae886a4ae99bf19f699), [`902597b`](https://github.com/aomex/aomex/commit/902597b2f98fda7e63f7419a5ef62ab2acb7c863), [`e8dee7c`](https://github.com/aomex/aomex/commit/e8dee7c3f064587cd2afb9cb95ab3341f63ccd27)]:
8
- - @aomex/web@0.0.6
9
- - @aomex/core@0.0.5
7
+ - Updated dependencies [[`dcf2f4b`](https://github.com/aomex/aomex/commit/dcf2f4b6a13228d4731e4969e6abff9bef8ef0e2), [`d788ce7`](https://github.com/aomex/aomex/commit/d788ce731af885eae3819683813b2a9502742cea), [`c6fe6cb`](https://github.com/aomex/aomex/commit/c6fe6cb2f21acf74bc06db1509deff4aa35c48b3), [`a2727fb`](https://github.com/aomex/aomex/commit/a2727fb7619341dc3b23736e5dc11cee7d65e0bc), [`4253004`](https://github.com/aomex/aomex/commit/42530043854956a42d16be090b89fbac70e2fa17), [`fc7008e`](https://github.com/aomex/aomex/commit/fc7008e889a55e6a0a268bb77cab5be0f0bd9d30), [`d80df1a`](https://github.com/aomex/aomex/commit/d80df1a07eb92214a9c3c7fa15c629ea1ee88c43)]:
8
+ - @aomex/web@0.0.8
9
+ - @aomex/core@0.0.7
10
10
 
11
- ## 0.0.3
11
+ ## 0.0.5
12
12
 
13
13
  ### Patch Changes
14
14
 
15
- - [`d8debb9`](https://github.com/aomex/aomex/commit/d8debb9b6319d30e48cb77d97103b5559c57789c) Thanks [@geekact](https://github.com/geekact)! - refactor(web): response 的 header 均使用首字母大写的格式
16
-
17
- - Updated dependencies [[`d8debb9`](https://github.com/aomex/aomex/commit/d8debb9b6319d30e48cb77d97103b5559c57789c), [`64c10e1`](https://github.com/aomex/aomex/commit/64c10e17ff92251bb2d9f45e0bddde5cba8a3b20), [`6a57463`](https://github.com/aomex/aomex/commit/6a57463c1107c38a8b8cf5fa00ff3289bf629c0a), [`8857115`](https://github.com/aomex/aomex/commit/88571153b7e84ec6d66d37970c3ef7b4e1924a03), [`68b1365`](https://github.com/aomex/aomex/commit/68b13655922a0714bcdd2101ce659da382d44e8b), [`b51a81a`](https://github.com/aomex/aomex/commit/b51a81a65313073dff5307b310b6656da2ad5186), [`ee021e3`](https://github.com/aomex/aomex/commit/ee021e342814f12777e538c06a19971e1020f201), [`b5aaec5`](https://github.com/aomex/aomex/commit/b5aaec540e3d732868a270a969a94ccd6ff9ac6a), [`fd6ae40`](https://github.com/aomex/aomex/commit/fd6ae40577bd9a62c211d4615483fc5dd58f5865)]:
18
- - @aomex/web@0.0.5
19
- - @aomex/core@0.0.4
20
-
21
- ## 0.0.2
22
-
23
- ### Patch Changes
24
-
25
- - Updated dependencies [[`121253a`](https://github.com/aomex/aomex/commit/121253a6fc203e427bfd25e82d713bec6ac13b38), [`59dc183`](https://github.com/aomex/aomex/commit/59dc183bcec9b7221c18865563b38cba5d82869b), [`8cb74fd`](https://github.com/aomex/aomex/commit/8cb74fdd27626037aa9bc80cb2930e4f0d67f8e6), [`d834392`](https://github.com/aomex/aomex/commit/d834392b1e0f6333d66d11378d9f4ceb813a58a9), [`91feda4`](https://github.com/aomex/aomex/commit/91feda457dfa8bd8dd2c8f38bfaaf4f7f2f7702f)]:
26
- - @aomex/web@0.0.4
27
- - @aomex/core@0.0.3
28
-
29
- ## 0.0.1
30
-
31
- ### Patch Changes
32
-
33
- - [`8a6f70c`](https://github.com/aomex/aomex/commit/8a6f70c32145b26b1896e976bc6f6454516c7a4d) Thanks [@geekact](https://github.com/geekact)! - 增加 web 插件 cors
34
-
35
- - Updated dependencies [[`4735157`](https://github.com/aomex/aomex/commit/4735157c52d0abecc41d6c7f416280ebfd6ee696), [`d6ac7b5`](https://github.com/aomex/aomex/commit/d6ac7b5403334b51fa15dbe82dd6b5b6d048f661), [`9254754`](https://github.com/aomex/aomex/commit/9254754d234fc0062eb5d600284ee8453825306c), [`d1ce4e2`](https://github.com/aomex/aomex/commit/d1ce4e2276f93c44e67ea06666d048917fa94e53), [`6056f55`](https://github.com/aomex/aomex/commit/6056f556577865220d6b5be2a4eafad9e4dbf8d4), [`1c67399`](https://github.com/aomex/aomex/commit/1c673992c4b313c2accb4cbc1fc66537a9886c29), [`352642a`](https://github.com/aomex/aomex/commit/352642abf2ccb3fe97e2d83a691d8428ccfc9758)]:
36
- - @aomex/web@0.0.3
37
- - @aomex/core@0.0.2
15
+ - Updated dependencies [[`bbc8dda`](https://github.com/aomex/aomex/commit/bbc8dda9f0876c3402608133085350cc693def6f), [`ceb2d82`](https://github.com/aomex/aomex/commit/ceb2d8269755dca3f79b755224259b8a99bc65d0)]:
16
+ - @aomex/core@0.0.6
17
+ - @aomex/web@0.0.7
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ interface CorsOptions {
6
6
  *
7
7
  * @remarks
8
8
  * If a function is provided, it will be called for each request with
9
- * the koa context object. It may return a string or a promise that
9
+ * the web context object. It may return a string or a promise that
10
10
  * will resolve with a string.
11
11
  */
12
12
  origin?: ((ctx: WebContext) => string) | ((ctx: WebContext) => PromiseLike<string>) | string;
@@ -32,7 +32,7 @@ interface CorsOptions {
32
32
  *
33
33
  * @remarks
34
34
  * If a function is provided, it will be called for each request with
35
- * the koa context object. It may return a boolean or a promise that
35
+ * the web context object. It may return a boolean or a promise that
36
36
  * will resolve with a boolean.
37
37
  */
38
38
  credentials?: ((ctx: WebContext) => boolean) | ((ctx: WebContext) => PromiseLike<boolean>) | boolean;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { HttpError, WebContext, WebMiddleware } from '@aomex/web';\nimport { middleware } from '@aomex/core';\n\nexport interface CorsOptions {\n /**\n * `Access-Control-Allow-Origin`, default is request Origin header.\n *\n * @remarks\n * If a function is provided, it will be called for each request with\n * the koa context object. It may return a string or a promise that\n * will resolve with a string.\n */\n origin?:\n | ((ctx: WebContext) => string)\n | ((ctx: WebContext) => PromiseLike<string>)\n | string;\n\n /**\n * `Access-Control-Allow-Methods`, default is\n * 'GET,HEAD,PUT,POST,DELETE,PATCH'\n */\n allowMethods?: string[] | string;\n\n /**\n * `Access-Control-Expose-Headers`\n */\n exposeHeaders?: string[] | string;\n\n /**\n * `Access-Control-Allow-Headers`\n */\n allowHeaders?: string[] | string;\n\n /**\n * `Access-Control-Max-Age` in seconds\n */\n maxAge?: number | string;\n\n /**\n * `Access-Control-Allow-Credentials`\n *\n * @remarks\n * If a function is provided, it will be called for each request with\n * the koa context object. It may return a boolean or a promise that\n * will resolve with a boolean.\n */\n credentials?:\n | ((ctx: WebContext) => boolean)\n | ((ctx: WebContext) => PromiseLike<boolean>)\n | boolean;\n\n /**\n * Add set headers to `err.header` if an error is thrown\n */\n keepHeadersOnError?: boolean;\n\n /**\n * Add `Cross-Origin-Opener-Policy` & `Cross-Origin-Embedder-Policy` to response headers\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/Planned_changes\n */\n secureContext?: boolean;\n\n /**\n * Handle `Access-Control-Request-Private-Network` request by return `Access-Control-Allow-Private-Network`\n *\n * @see https://wicg.github.io/private-network-access/\n */\n privateNetworkAccess?: boolean;\n}\n\nconst defaults: CorsOptions = {\n allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',\n secureContext: false,\n};\n\nexport const cors = (options: CorsOptions = {}): WebMiddleware => {\n options = {\n ...defaults,\n ...options,\n };\n\n (<const>['exposeHeaders', 'allowMethods', 'allowHeaders']).forEach((key) => {\n const value = options[key];\n if (Array.isArray(value)) {\n options[key] = value.join(',');\n }\n });\n\n if (options.maxAge) {\n options.maxAge = String(options.maxAge);\n }\n\n options.keepHeadersOnError = options.keepHeadersOnError !== false;\n\n return middleware.web(async (ctx, next) => {\n const { request, response } = ctx;\n const requestOrigin = request.headers['origin'];\n\n // Always set Vary header\n // https://github.com/rs/cors/issues/10\n response.vary('Origin');\n\n if (!requestOrigin) return next();\n\n let origin: string;\n if (typeof options.origin === 'function') {\n origin = await options.origin(ctx);\n if (!origin) return next();\n } else {\n origin = options.origin || requestOrigin;\n }\n\n let credentials;\n if (typeof options.credentials === 'function') {\n credentials = await options.credentials(ctx);\n } else {\n credentials = !!options.credentials;\n }\n\n const headersSet: Record<string, any> = {};\n\n function setAndRecordHeader(key: string, value: any) {\n response.setHeader(key, value);\n headersSet[key] = value;\n }\n\n if (request.method !== 'OPTIONS') {\n // Simple Cross-Origin Request, Actual Request, and Redirects\n setAndRecordHeader('Access-Control-Allow-Origin', origin);\n credentials &&\n setAndRecordHeader('Access-Control-Allow-Credentials', 'true');\n\n if (options.exposeHeaders) {\n setAndRecordHeader(\n 'Access-Control-Expose-Headers',\n options.exposeHeaders,\n );\n }\n\n if (options.secureContext) {\n setAndRecordHeader('Cross-Origin-Opener-Policy', 'same-origin');\n setAndRecordHeader('Cross-Origin-Embedder-Policy', 'require-corp');\n }\n\n if (!options.keepHeadersOnError) return next();\n\n return next().catch((err: HttpError) => {\n const errHeadersSet = err.headers || {};\n const varyWithOrigin = response.varyAppend(\n errHeadersSet['vary'] || errHeadersSet['Vary'] || '',\n 'Origin',\n );\n delete errHeadersSet['Vary'];\n\n err.headers = {\n ...errHeadersSet,\n ...headersSet,\n ...{ vary: varyWithOrigin },\n };\n\n return Promise.reject(err);\n });\n } else {\n if (!request.headers['access-control-request-method']) return next();\n\n response.setHeader('Access-Control-Allow-Origin', origin);\n\n if (credentials === true) {\n response.setHeader('Access-Control-Allow-Credentials', 'true');\n }\n\n if (options.maxAge) {\n response.setHeader('Access-Control-Max-Age', options.maxAge);\n }\n\n if (\n options.privateNetworkAccess &&\n request.headers['access-control-request-private-network']\n ) {\n response.setHeader('Access-Control-Allow-Private-Network', 'true');\n }\n\n if (options.allowMethods) {\n response.setHeader(\n 'Access-Control-Allow-Methods',\n options.allowMethods,\n );\n }\n\n if (options.secureContext) {\n setAndRecordHeader('Cross-Origin-Opener-Policy', 'same-origin');\n setAndRecordHeader('Cross-Origin-Embedder-Policy', 'require-corp');\n }\n\n const allowHeaders =\n options.allowHeaders ||\n request.headers['access-control-request-headers'];\n if (allowHeaders) {\n response.setHeader('Access-Control-Allow-Headers', allowHeaders);\n }\n\n ctx.send(204);\n }\n });\n};\n"],"mappings":";AACA,SAAS,kBAAkB;AAsE3B,IAAM,WAAwB;AAAA,EAC5B,cAAc;AAAA,EACd,eAAe;AACjB;AAEO,IAAM,OAAO,CAAC,UAAuB,CAAC,MAAqB;AAChE,YAAU;AAAA,IACR,GAAG;AAAA,IACH,GAAG;AAAA,EACL;AAEA,EAAQ,CAAC,iBAAiB,gBAAgB,cAAc,EAAG,QAAQ,CAAC,QAAQ;AAC1E,UAAM,QAAQ,QAAQ,GAAG;AACzB,QAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,cAAQ,GAAG,IAAI,MAAM,KA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;AAAA,UAC9B,cAAc,MAAM,KAAK,cAAc,MAAM,KAAK;AAAA,UAClD;AAAA,QACF;AACA,eAAO,cAAc,MAAM;AAE3B,YAAI,UAAU;AAAA,UACZ,GAAG;AAAA,UACH,GAAG;AAAA,UACH,GAAG,EAAE,MAAM,eAAe;AAAA,QAC5B;AAEA,eAAO,QAAQ,OAAO,GAAG;AAAA,MAC3B,CAAC;AAAA,IACH,OAAO;AACL,UAAI,CAAC,QAAQ,QAAQ,+BAA+B;AAAG,eAAO,KAAK;AAEnE,eAAS,UAAU,+BAA+B,MAAM;AAExD,UAAI,gBAAgB,MAAM;AACxB,iBAAS,UAAU,oCAAoC,MAAM;AAAA,MAC/D;AAEA,UAAI,QAAQ,QAAQ;AAClB,iBAAS,UAAU,0BAA0B,QAAQ,MAAM;AAAA,MAC7D;AAEA,UACE,QAAQ,wBACR,QAAQ,QAAQ,wCAAwC,GACxD;AACA,iBAAS,UAAU,wCAAwC,MAAM;AAAA,MACnE;AAEA,UAAI,QAAQ,cAAc;AACxB,iBAAS;AAAA,UACP;AAAA,UACA,QAAQ;AAAA,QACV;AAAA,MACF;AAEA,UAAI,QAAQ,eAAe;AACzB,2BAAmB,8BAA8B,aAAa;AAC9D,2BAAmB,gCAAgC,cAAc;AAAA,MACnE;AAEA,YAAM,eACJ,QAAQ,gBACR,QAAQ,QAAQ,gCAAgC;AAClD,UAAI,cAAc;AAChB,iBAAS,UAAU,gCAAgC,YAAY;AAAA,MACjE;AAEA,UAAI,KAAK,GAAG;AAAA,IACd;AAAA,EACF,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { HttpError, WebContext, WebMiddleware } from '@aomex/web';\nimport { middleware } from '@aomex/core';\n\nexport interface CorsOptions {\n /**\n * `Access-Control-Allow-Origin`, default is request Origin header.\n *\n * @remarks\n * If a function is provided, it will be called for each request with\n * the web context object. It may return a string or a promise that\n * will resolve with a string.\n */\n origin?:\n | ((ctx: WebContext) => string)\n | ((ctx: WebContext) => PromiseLike<string>)\n | string;\n\n /**\n * `Access-Control-Allow-Methods`, default is\n * 'GET,HEAD,PUT,POST,DELETE,PATCH'\n */\n allowMethods?: string[] | string;\n\n /**\n * `Access-Control-Expose-Headers`\n */\n exposeHeaders?: string[] | string;\n\n /**\n * `Access-Control-Allow-Headers`\n */\n allowHeaders?: string[] | string;\n\n /**\n * `Access-Control-Max-Age` in seconds\n */\n maxAge?: number | string;\n\n /**\n * `Access-Control-Allow-Credentials`\n *\n * @remarks\n * If a function is provided, it will be called for each request with\n * the web context object. It may return a boolean or a promise that\n * will resolve with a boolean.\n */\n credentials?:\n | ((ctx: WebContext) => boolean)\n | ((ctx: WebContext) => PromiseLike<boolean>)\n | boolean;\n\n /**\n * Add set headers to `err.header` if an error is thrown\n */\n keepHeadersOnError?: boolean;\n\n /**\n * Add `Cross-Origin-Opener-Policy` & `Cross-Origin-Embedder-Policy` to response headers\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/Planned_changes\n */\n secureContext?: boolean;\n\n /**\n * Handle `Access-Control-Request-Private-Network` request by return `Access-Control-Allow-Private-Network`\n *\n * @see https://wicg.github.io/private-network-access/\n */\n privateNetworkAccess?: boolean;\n}\n\nconst defaults: CorsOptions = {\n allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',\n secureContext: false,\n};\n\nexport const cors = (options: CorsOptions = {}): WebMiddleware => {\n options = {\n ...defaults,\n ...options,\n };\n\n (<const>['exposeHeaders', 'allowMethods', 'allowHeaders']).forEach((key) => {\n const value = options[key];\n if (Array.isArray(value)) {\n options[key] = value.join(',');\n }\n });\n\n if (options.maxAge) {\n options.maxAge = String(options.maxAge);\n }\n\n options.keepHeadersOnError = options.keepHeadersOnError !== false;\n\n return middleware.web(async (ctx, next) => {\n const { request, response } = ctx;\n const requestOrigin = request.headers['origin'];\n\n // Always set Vary header\n // https://github.com/rs/cors/issues/10\n response.vary('Origin');\n\n if (!requestOrigin) return next();\n\n let origin: string;\n if (typeof options.origin === 'function') {\n origin = await options.origin(ctx);\n if (!origin) return next();\n } else {\n origin = options.origin || requestOrigin;\n }\n\n let credentials;\n if (typeof options.credentials === 'function') {\n credentials = await options.credentials(ctx);\n } else {\n credentials = !!options.credentials;\n }\n\n const headersSet: Record<string, any> = {};\n\n function setAndRecordHeader(key: string, value: any) {\n response.setHeader(key, value);\n headersSet[key] = value;\n }\n\n if (request.method !== 'OPTIONS') {\n // Simple Cross-Origin Request, Actual Request, and Redirects\n setAndRecordHeader('Access-Control-Allow-Origin', origin);\n credentials &&\n setAndRecordHeader('Access-Control-Allow-Credentials', 'true');\n\n if (options.exposeHeaders) {\n setAndRecordHeader(\n 'Access-Control-Expose-Headers',\n options.exposeHeaders,\n );\n }\n\n if (options.secureContext) {\n setAndRecordHeader('Cross-Origin-Opener-Policy', 'same-origin');\n setAndRecordHeader('Cross-Origin-Embedder-Policy', 'require-corp');\n }\n\n if (!options.keepHeadersOnError) return next();\n\n return next().catch((err: HttpError) => {\n const errHeadersSet = err.headers || {};\n const varyWithOrigin = response.varyAppend(\n errHeadersSet['vary'] || errHeadersSet['Vary'] || '',\n 'Origin',\n );\n delete errHeadersSet['Vary'];\n\n err.headers = {\n ...errHeadersSet,\n ...headersSet,\n ...{ vary: varyWithOrigin },\n };\n\n return Promise.reject(err);\n });\n } else {\n if (!request.headers['access-control-request-method']) return next();\n\n response.setHeader('Access-Control-Allow-Origin', origin);\n\n if (credentials === true) {\n response.setHeader('Access-Control-Allow-Credentials', 'true');\n }\n\n if (options.maxAge) {\n response.setHeader('Access-Control-Max-Age', options.maxAge);\n }\n\n if (\n options.privateNetworkAccess &&\n request.headers['access-control-request-private-network']\n ) {\n response.setHeader('Access-Control-Allow-Private-Network', 'true');\n }\n\n if (options.allowMethods) {\n response.setHeader(\n 'Access-Control-Allow-Methods',\n options.allowMethods,\n );\n }\n\n if (options.secureContext) {\n setAndRecordHeader('Cross-Origin-Opener-Policy', 'same-origin');\n setAndRecordHeader('Cross-Origin-Embedder-Policy', 'require-corp');\n }\n\n const allowHeaders =\n options.allowHeaders ||\n request.headers['access-control-request-headers'];\n if (allowHeaders) {\n response.setHeader('Access-Control-Allow-Headers', allowHeaders);\n }\n\n ctx.send(204);\n }\n });\n};\n"],"mappings":";AACA,SAAS,kBAAkB;AAsE3B,IAAM,WAAwB;AAAA,EAC5B,cAAc;AAAA,EACd,eAAe;AACjB;AAEO,IAAM,OAAO,CAAC,UAAuB,CAAC,MAAqB;AAChE,YAAU;AAAA,IACR,GAAG;AAAA,IACH,GAAG;AAAA,EACL;AAEA,EAAQ,CAAC,iBAAiB,gBAAgB,cAAc,EAAG,QAAQ,CAAC,QAAQ;AAC1E,UAAM,QAAQ,QAAQ,GAAG;AACzB,QAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,cAAQ,GAAG,IAAI,MAAM,KAAK,GAAG;AAAA,IAC/B;AAAA,EACF,CAAC;AAED,MAAI,QAAQ,QAAQ;AAClB,YAAQ,SAAS,OAAO,QAAQ,MAAM;AAAA,EACxC;AAEA,UAAQ,qBAAqB,QAAQ,uBAAuB;AAE5D,SAAO,WAAW,IAAI,OAAO,KAAK,SAAS;AACzC,UAAM,EAAE,SAAS,SAAS,IAAI;AAC9B,UAAM,gBAAgB,QAAQ,QAAQ,QAAQ;AAI9C,aAAS,KAAK,QAAQ;AAEtB,QAAI,CAAC;AAAe,aAAO,KAAK;AAEhC,QAAI;AACJ,QAAI,OAAO,QAAQ,WAAW,YAAY;AACxC,eAAS,MAAM,QAAQ,OAAO,GAAG;AACjC,UAAI,CAAC;AAAQ,eAAO,KAAK;AAAA,IAC3B,OAAO;AACL,eAAS,QAAQ,UAAU;AAAA,IAC7B;AAEA,QAAI;AACJ,QAAI,OAAO,QAAQ,gBAAgB,YAAY;AAC7C,oBAAc,MAAM,QAAQ,YAAY,GAAG;AAAA,IAC7C,OAAO;AACL,oBAAc,CAAC,CAAC,QAAQ;AAAA,IAC1B;AAEA,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QACV;AAAA,MACF;AAEA,UAAI,QAAQ,eAAe;AACzB,2BAAmB,8BAA8B,aAAa;AAC9D,2BAAmB,gCAAgC,cAAc;AAAA,MACnE;AAEA,YAAM,eACJ,QAAQ,gBACR,QAAQ,QAAQ,gCAAgC;AAClD,UAAI,cAAc;AAChB,iBAAS,UAAU,gCAAgC,YAAY;AAAA,MACjE;AAEA,UAAI,KAAK,GAAG;AAAA,IACd;AAAA,EACF,CAAC;AACH;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aomex/cors",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "跨站资源共享",
5
5
  "keywords": [
6
6
  "cors"
@@ -29,12 +29,12 @@
29
29
  "access": "public"
30
30
  },
31
31
  "peerDependencies": {
32
- "@aomex/core": "^0.0.5",
33
- "@aomex/web": "^0.0.6"
32
+ "@aomex/core": "^0.0.7",
33
+ "@aomex/web": "^0.0.8"
34
34
  },
35
35
  "devDependencies": {
36
- "@aomex/core": "^0.0.5",
37
- "@aomex/web": "^0.0.6"
36
+ "@aomex/core": "^0.0.7",
37
+ "@aomex/web": "^0.0.8"
38
38
  },
39
39
  "scripts": {}
40
40
  }