@webiny/aws-helpers 0.0.0-unstable.78f581c1d2 → 0.0.0-unstable.7be00a75a9

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.
Files changed (78) hide show
  1. package/LICENSE +2 -7
  2. package/README.md +11 -0
  3. package/cloudfrontFunctions/cookies.d.ts +1 -1
  4. package/cloudfrontFunctions/cookies.js +18 -27
  5. package/cloudfrontFunctions/cookies.js.map +1 -1
  6. package/cloudfrontFunctions/headers.d.ts +1 -1
  7. package/cloudfrontFunctions/headers.js +22 -23
  8. package/cloudfrontFunctions/headers.js.map +1 -1
  9. package/cloudfrontFunctions/index.d.ts +6 -6
  10. package/cloudfrontFunctions/index.js +6 -6
  11. package/cloudfrontFunctions/querystring.d.ts +1 -1
  12. package/cloudfrontFunctions/querystring.js +16 -33
  13. package/cloudfrontFunctions/querystring.js.map +1 -1
  14. package/cloudfrontFunctions/redirect.d.ts +1 -1
  15. package/cloudfrontFunctions/redirect.js +19 -21
  16. package/cloudfrontFunctions/redirect.js.map +1 -1
  17. package/cloudfrontFunctions/types.d.ts +6 -6
  18. package/cloudfrontFunctions/types.js +0 -1
  19. package/cloudfrontFunctions/utils.d.ts +1 -1
  20. package/cloudfrontFunctions/utils.js +8 -19
  21. package/cloudfrontFunctions/utils.js.map +1 -1
  22. package/index.d.ts +1 -1
  23. package/index.js +1 -1
  24. package/lambdaEdge/cookies.d.ts +1 -1
  25. package/lambdaEdge/cookies.js +20 -23
  26. package/lambdaEdge/cookies.js.map +1 -1
  27. package/lambdaEdge/headers.d.ts +1 -1
  28. package/lambdaEdge/headers.js +9 -6
  29. package/lambdaEdge/headers.js.map +1 -1
  30. package/lambdaEdge/index.d.ts +7 -7
  31. package/lambdaEdge/index.js +7 -7
  32. package/lambdaEdge/redirect.d.ts +1 -1
  33. package/lambdaEdge/redirect.js +29 -29
  34. package/lambdaEdge/redirect.js.map +1 -1
  35. package/lambdaEdge/request.d.ts +1 -1
  36. package/lambdaEdge/request.js +26 -19
  37. package/lambdaEdge/request.js.map +1 -1
  38. package/lambdaEdge/response.d.ts +1 -1
  39. package/lambdaEdge/response.js +10 -7
  40. package/lambdaEdge/response.js.map +1 -1
  41. package/lambdaEdge/types.d.ts +8 -8
  42. package/lambdaEdge/types.js +0 -1
  43. package/lambdaEdge/utils.d.ts +1 -1
  44. package/lambdaEdge/utils.js +8 -5
  45. package/lambdaEdge/utils.js.map +1 -1
  46. package/package.json +11 -8
  47. package/rslib-runtime.js +14 -0
  48. package/rslib-runtime.js.map +1 -0
  49. package/stagedRollouts/functions/adminOriginRequest.js +24 -27
  50. package/stagedRollouts/functions/adminOriginRequest.js.map +1 -1
  51. package/stagedRollouts/functions/configOriginRequest.js +48 -48
  52. package/stagedRollouts/functions/configOriginRequest.js.map +1 -1
  53. package/stagedRollouts/functions/originRequest.js +15 -14
  54. package/stagedRollouts/functions/originRequest.js.map +1 -1
  55. package/stagedRollouts/functions/viewerRequest.js +20 -40
  56. package/stagedRollouts/functions/viewerRequest.js.map +1 -1
  57. package/stagedRollouts/functions/viewerResponse.js +12 -16
  58. package/stagedRollouts/functions/viewerResponse.js.map +1 -1
  59. package/stagedRollouts/utils/common.js +8 -5
  60. package/stagedRollouts/utils/common.js.map +1 -1
  61. package/stagedRollouts/utils/headerBlacklist.js +30 -12
  62. package/stagedRollouts/utils/headerBlacklist.js.map +1 -1
  63. package/stagedRollouts/utils/loadOriginPage.d.ts +1 -1
  64. package/stagedRollouts/utils/loadOriginPage.js +75 -98
  65. package/stagedRollouts/utils/loadOriginPage.js.map +1 -1
  66. package/stagedRollouts/utils/loadTrafficSplittingConfig.d.ts +2 -2
  67. package/stagedRollouts/utils/loadTrafficSplittingConfig.js +39 -57
  68. package/stagedRollouts/utils/loadTrafficSplittingConfig.js.map +1 -1
  69. package/stagedRollouts/utils/loadVariantOrigin.d.ts +2 -2
  70. package/stagedRollouts/utils/loadVariantOrigin.js +45 -77
  71. package/stagedRollouts/utils/loadVariantOrigin.js.map +1 -1
  72. package/stagedRollouts/utils/log.js +6 -7
  73. package/stagedRollouts/utils/log.js.map +1 -1
  74. package/cloudfrontFunctions/index.js.map +0 -1
  75. package/cloudfrontFunctions/types.js.map +0 -1
  76. package/index.js.map +0 -1
  77. package/lambdaEdge/index.js.map +0 -1
  78. package/lambdaEdge/types.js.map +0 -1
package/LICENSE CHANGED
@@ -1,11 +1,6 @@
1
- Copyright (c) Webiny Ltd.
1
+ MIT License
2
2
 
3
- Portions of this software are licensed as follows:
4
-
5
- * All content that resides under the "enterprise/" directories of this repository, is licensed under the license defined in their respective "enterprise/LICENSE" file.
6
- * All content that resides under the "packages/" sub-directories of this repository, is licensed under the license defined in their respective "packages/*/LICENSE" file.
7
- * All third party components incorporated into the Webiny Software are licensed under the original license provided by the owner of the applicable component.
8
- * Content outside of the above mentioned directories or restrictions above is available under the "MIT" license as defined below.
3
+ Copyright (c) Webiny
9
4
 
10
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
11
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @webiny/aws-helpers
2
+
3
+ > [!NOTE]
4
+ > This package is part of the [Webiny](https://www.webiny.com) monorepo.
5
+ > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
6
+
7
+ 📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
8
+
9
+ ---
10
+
11
+ _This README file is automatically generated during the publish process._
@@ -1,4 +1,4 @@
1
- import { CloudFrontResponse } from "./types";
1
+ import type { CloudFrontResponse } from "./types.js";
2
2
  export interface CookieParams {
3
3
  name: string;
4
4
  value: string;
@@ -1,28 +1,19 @@
1
- /** Sets cookie for the HTTP response */
2
- export function setResponseCookie(response, cookie) {
3
- const cookies = response.cookies || (response.cookies = {});
4
- const current = cookies[cookie.name];
5
- let attrs = `Secure; Path=/;`;
6
-
7
- if (cookie.maxAge) {
8
- attrs += ` Max-Age=${cookie.maxAge};`;
9
- }
10
-
11
- if (current) {
12
- // If there is already the same cookie set in a response,
13
- // we add another entry using `multivalue`.
14
- // This is how you set multiple same cookies in CloudFront Functions.
15
- // It DOES make sense to set the same cookie multiple times,
16
- // for example when dealing with SameSite issue (https://web.dev/samesite-cookies-explained/)
17
- const multivalue = current.multivalue ?? (current.multivalue = []);
18
- multivalue.push({
19
- value: cookie.value,
20
- attributes: attrs
21
- });
22
- } else {
23
- cookies[cookie.name] = {
24
- value: cookie.value,
25
- attributes: attrs
1
+ function setResponseCookie(response, cookie) {
2
+ const cookies = response.cookies || (response.cookies = {});
3
+ const current = cookies[cookie.name];
4
+ let attrs = "Secure; Path=/;";
5
+ if (cookie.maxAge) attrs += ` Max-Age=${cookie.maxAge};`;
6
+ if (current) {
7
+ const multivalue = current.multivalue ?? (current.multivalue = []);
8
+ multivalue.push({
9
+ value: cookie.value,
10
+ attributes: attrs
11
+ });
12
+ } else cookies[cookie.name] = {
13
+ value: cookie.value,
14
+ attributes: attrs
26
15
  };
27
- }
28
- }
16
+ }
17
+ export { setResponseCookie };
18
+
19
+ //# sourceMappingURL=cookies.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["setResponseCookie","response","cookie","cookies","current","name","attrs","maxAge","multivalue","push","value","attributes"],"sources":["cookies.ts"],"sourcesContent":["import { CloudFrontResponse } from \"./types\";\n\nexport interface CookieParams {\n name: string;\n value: string;\n maxAge?: number;\n}\n\n/** Sets cookie for the HTTP response */\nexport function setResponseCookie(response: CloudFrontResponse, cookie: CookieParams) {\n const cookies = response.cookies || (response.cookies = {});\n\n const current = cookies[cookie.name];\n let attrs = `Secure; Path=/;`;\n\n if (cookie.maxAge) {\n attrs += ` Max-Age=${cookie.maxAge};`;\n }\n\n if (current) {\n // If there is already the same cookie set in a response,\n // we add another entry using `multivalue`.\n // This is how you set multiple same cookies in CloudFront Functions.\n // It DOES make sense to set the same cookie multiple times,\n // for example when dealing with SameSite issue (https://web.dev/samesite-cookies-explained/)\n const multivalue = current.multivalue ?? (current.multivalue = []);\n multivalue.push({\n value: cookie.value,\n attributes: attrs\n });\n } else {\n cookies[cookie.name] = {\n value: cookie.value,\n attributes: attrs\n };\n }\n}\n"],"mappings":"AAQA;AACA,OAAO,SAASA,iBAAT,CAA2BC,QAA3B,EAAyDC,MAAzD,EAA+E;EAClF,MAAMC,OAAO,GAAGF,QAAQ,CAACE,OAAT,KAAqBF,QAAQ,CAACE,OAAT,GAAmB,EAAxC,CAAhB;EAEA,MAAMC,OAAO,GAAGD,OAAO,CAACD,MAAM,CAACG,IAAR,CAAvB;EACA,IAAIC,KAAK,GAAI,iBAAb;;EAEA,IAAIJ,MAAM,CAACK,MAAX,EAAmB;IACfD,KAAK,IAAK,YAAWJ,MAAM,CAACK,MAAO,GAAnC;EACH;;EAED,IAAIH,OAAJ,EAAa;IACT;IACA;IACA;IACA;IACA;IACA,MAAMI,UAAU,GAAGJ,OAAO,CAACI,UAAR,KAAuBJ,OAAO,CAACI,UAAR,GAAqB,EAA5C,CAAnB;IACAA,UAAU,CAACC,IAAX,CAAgB;MACZC,KAAK,EAAER,MAAM,CAACQ,KADF;MAEZC,UAAU,EAAEL;IAFA,CAAhB;EAIH,CAXD,MAWO;IACHH,OAAO,CAACD,MAAM,CAACG,IAAR,CAAP,GAAuB;MACnBK,KAAK,EAAER,MAAM,CAACQ,KADK;MAEnBC,UAAU,EAAEL;IAFO,CAAvB;EAIH;AACJ"}
1
+ {"version":3,"file":"cloudfrontFunctions/cookies.js","sources":["../../src/cloudfrontFunctions/cookies.ts"],"sourcesContent":["import type { CloudFrontResponse } from \"./types.js\";\n\nexport interface CookieParams {\n name: string;\n value: string;\n maxAge?: number;\n}\n\n/** Sets cookie for the HTTP response */\nexport function setResponseCookie(response: CloudFrontResponse, cookie: CookieParams) {\n const cookies = response.cookies || (response.cookies = {});\n\n const current = cookies[cookie.name];\n let attrs = `Secure; Path=/;`;\n\n if (cookie.maxAge) {\n attrs += ` Max-Age=${cookie.maxAge};`;\n }\n\n if (current) {\n // If there is already the same cookie set in a response,\n // we add another entry using `multivalue`.\n // This is how you set multiple same cookies in CloudFront Functions.\n // It DOES make sense to set the same cookie multiple times,\n // for example when dealing with SameSite issue (https://web.dev/samesite-cookies-explained/)\n const multivalue = current.multivalue ?? (current.multivalue = []);\n multivalue.push({\n value: cookie.value,\n attributes: attrs\n });\n } else {\n cookies[cookie.name] = {\n value: cookie.value,\n attributes: attrs\n };\n }\n}\n"],"names":["setResponseCookie","response","cookie","cookies","current","attrs","multivalue"],"mappings":"AASO,SAASA,kBAAkBC,QAA4B,EAAEC,MAAoB;IAChF,MAAMC,UAAUF,SAAS,OAAO,IAAKA,CAAAA,SAAS,OAAO,GAAG,CAAC;IAEzD,MAAMG,UAAUD,OAAO,CAACD,OAAO,IAAI,CAAC;IACpC,IAAIG,QAAQ;IAEZ,IAAIH,OAAO,MAAM,EACbG,SAAS,CAAC,SAAS,EAAEH,OAAO,MAAM,CAAC,CAAC,CAAC;IAGzC,IAAIE,SAAS;QAMT,MAAME,aAAaF,QAAQ,UAAU,IAAKA,CAAAA,QAAQ,UAAU,GAAG,EAAC;QAChEE,WAAW,IAAI,CAAC;YACZ,OAAOJ,OAAO,KAAK;YACnB,YAAYG;QAChB;IACJ,OACIF,OAAO,CAACD,OAAO,IAAI,CAAC,GAAG;QACnB,OAAOA,OAAO,KAAK;QACnB,YAAYG;IAChB;AAER"}
@@ -1,4 +1,4 @@
1
- import { CloudFrontHeaders, Header } from "./types";
1
+ import type { CloudFrontHeaders, Header } from "./types.js";
2
2
  export declare function getHeader(headers: CloudFrontHeaders, header: string): string | undefined;
3
3
  export declare function setHeader(headers: CloudFrontHeaders, header: Header): void;
4
4
  export declare function setHeaders(headers: CloudFrontHeaders, headersToSet: Header[]): void;
@@ -1,26 +1,25 @@
1
- export function getHeader(headers, header) {
2
- var _headers$header;
3
-
4
- return (_headers$header = headers[header]) === null || _headers$header === void 0 ? void 0 : _headers$header.value;
1
+ function getHeader(headers, header) {
2
+ return headers[header]?.value;
3
+ }
4
+ function setHeader(headers, header) {
5
+ headers[header.key] = {
6
+ value: header.value
7
+ };
5
8
  }
6
- export function setHeader(headers, header) {
7
- headers[header.key] = {
8
- value: header.value
9
- };
9
+ function setHeaders(headers, headersToSet) {
10
+ for(let i = 0; i < headersToSet.length; i++)setHeader(headers, headersToSet[i]);
10
11
  }
11
- export function setHeaders(headers, headersToSet) {
12
- for (let i = 0; i < headersToSet.length; i++) {
13
- setHeader(headers, headersToSet[i]);
14
- }
12
+ function setNoCacheHeaders(headers) {
13
+ headers["cache-control"] = {
14
+ value: "no-cache, no-store, must-revalidate"
15
+ };
16
+ headers["pragma"] = {
17
+ value: "no-cache"
18
+ };
19
+ headers["expires"] = {
20
+ value: "0"
21
+ };
15
22
  }
16
- export function setNoCacheHeaders(headers) {
17
- headers["cache-control"] = {
18
- value: "no-cache, no-store, must-revalidate"
19
- };
20
- headers["pragma"] = {
21
- value: "no-cache"
22
- };
23
- headers["expires"] = {
24
- value: "0"
25
- };
26
- }
23
+ export { getHeader, setHeader, setHeaders, setNoCacheHeaders };
24
+
25
+ //# sourceMappingURL=headers.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getHeader","headers","header","value","setHeader","key","setHeaders","headersToSet","i","length","setNoCacheHeaders"],"sources":["headers.ts"],"sourcesContent":["import { CloudFrontHeaders, Header } from \"./types\";\n\nexport function getHeader(headers: CloudFrontHeaders, header: string) {\n return headers[header]?.value;\n}\n\nexport function setHeader(headers: CloudFrontHeaders, header: Header) {\n headers[header.key] = {\n value: header.value\n };\n}\n\nexport function setHeaders(headers: CloudFrontHeaders, headersToSet: Header[]) {\n for (let i = 0; i < headersToSet.length; i++) {\n setHeader(headers, headersToSet[i]);\n }\n}\n\nexport function setNoCacheHeaders(headers: CloudFrontHeaders) {\n headers[\"cache-control\"] = { value: \"no-cache, no-store, must-revalidate\" };\n headers[\"pragma\"] = { value: \"no-cache\" };\n headers[\"expires\"] = { value: \"0\" };\n}\n"],"mappings":"AAEA,OAAO,SAASA,SAAT,CAAmBC,OAAnB,EAA+CC,MAA/C,EAA+D;EAAA;;EAClE,0BAAOD,OAAO,CAACC,MAAD,CAAd,oDAAO,gBAAiBC,KAAxB;AACH;AAED,OAAO,SAASC,SAAT,CAAmBH,OAAnB,EAA+CC,MAA/C,EAA+D;EAClED,OAAO,CAACC,MAAM,CAACG,GAAR,CAAP,GAAsB;IAClBF,KAAK,EAAED,MAAM,CAACC;EADI,CAAtB;AAGH;AAED,OAAO,SAASG,UAAT,CAAoBL,OAApB,EAAgDM,YAAhD,EAAwE;EAC3E,KAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGD,YAAY,CAACE,MAAjC,EAAyCD,CAAC,EAA1C,EAA8C;IAC1CJ,SAAS,CAACH,OAAD,EAAUM,YAAY,CAACC,CAAD,CAAtB,CAAT;EACH;AACJ;AAED,OAAO,SAASE,iBAAT,CAA2BT,OAA3B,EAAuD;EAC1DA,OAAO,CAAC,eAAD,CAAP,GAA2B;IAAEE,KAAK,EAAE;EAAT,CAA3B;EACAF,OAAO,CAAC,QAAD,CAAP,GAAoB;IAAEE,KAAK,EAAE;EAAT,CAApB;EACAF,OAAO,CAAC,SAAD,CAAP,GAAqB;IAAEE,KAAK,EAAE;EAAT,CAArB;AACH"}
1
+ {"version":3,"file":"cloudfrontFunctions/headers.js","sources":["../../src/cloudfrontFunctions/headers.ts"],"sourcesContent":["import type { CloudFrontHeaders, Header } from \"./types.js\";\n\nexport function getHeader(headers: CloudFrontHeaders, header: string) {\n return headers[header]?.value;\n}\n\nexport function setHeader(headers: CloudFrontHeaders, header: Header) {\n headers[header.key] = {\n value: header.value\n };\n}\n\nexport function setHeaders(headers: CloudFrontHeaders, headersToSet: Header[]) {\n for (let i = 0; i < headersToSet.length; i++) {\n setHeader(headers, headersToSet[i]);\n }\n}\n\nexport function setNoCacheHeaders(headers: CloudFrontHeaders) {\n headers[\"cache-control\"] = { value: \"no-cache, no-store, must-revalidate\" };\n headers[\"pragma\"] = { value: \"no-cache\" };\n headers[\"expires\"] = { value: \"0\" };\n}\n"],"names":["getHeader","headers","header","setHeader","setHeaders","headersToSet","i","setNoCacheHeaders"],"mappings":"AAEO,SAASA,UAAUC,OAA0B,EAAEC,MAAc;IAChE,OAAOD,OAAO,CAACC,OAAO,EAAE;AAC5B;AAEO,SAASC,UAAUF,OAA0B,EAAEC,MAAc;IAChED,OAAO,CAACC,OAAO,GAAG,CAAC,GAAG;QAClB,OAAOA,OAAO,KAAK;IACvB;AACJ;AAEO,SAASE,WAAWH,OAA0B,EAAEI,YAAsB;IACzE,IAAK,IAAIC,IAAI,GAAGA,IAAID,aAAa,MAAM,EAAEC,IACrCH,UAAUF,SAASI,YAAY,CAACC,EAAE;AAE1C;AAEO,SAASC,kBAAkBN,OAA0B;IACxDA,OAAO,CAAC,gBAAgB,GAAG;QAAE,OAAO;IAAsC;IAC1EA,OAAO,CAAC,SAAS,GAAG;QAAE,OAAO;IAAW;IACxCA,OAAO,CAAC,UAAU,GAAG;QAAE,OAAO;IAAI;AACtC"}
@@ -1,6 +1,6 @@
1
- export * from "./cookies";
2
- export * from "./headers";
3
- export * from "./querystring";
4
- export * from "./redirect";
5
- export * from "./types";
6
- export * from "./utils";
1
+ export * from "./cookies.js";
2
+ export * from "./headers.js";
3
+ export * from "./querystring.js";
4
+ export * from "./redirect.js";
5
+ export * from "./types.js";
6
+ export * from "./utils.js";
@@ -1,6 +1,6 @@
1
- export * from "./cookies";
2
- export * from "./headers";
3
- export * from "./querystring";
4
- export * from "./redirect";
5
- export * from "./types";
6
- export * from "./utils";
1
+ export * from "./cookies.js";
2
+ export * from "./headers.js";
3
+ export * from "./querystring.js";
4
+ export * from "./redirect.js";
5
+ export * from "./types.js";
6
+ export * from "./utils.js";
@@ -1,2 +1,2 @@
1
- import { CloudFrontQuery } from "./types";
1
+ import type { CloudFrontQuery } from "./types.js";
2
2
  export declare function stringifyQuery(query: CloudFrontQuery): string;
@@ -1,38 +1,21 @@
1
- export function stringifyQuery(query) {
2
- let qs = "";
3
-
4
- for (const key of Object.keys(query)) {
5
- const value = query[key];
6
-
7
- if (!value) {
8
- continue;
9
- }
10
-
11
- qs = appendQueryString(qs, key, value === null || value === void 0 ? void 0 : value.value);
12
-
13
- if (value.multivalue) {
14
- for (let i = 0; i < value.multivalue.length; i++) {
15
- qs = appendQueryString(qs, key, value.multivalue[i].value);
16
- }
1
+ function stringifyQuery(query) {
2
+ let qs = "";
3
+ for (const key of Object.keys(query)){
4
+ const value = query[key];
5
+ if (value) {
6
+ qs = appendQueryString(qs, key, value?.value);
7
+ if (value.multivalue) for(let i = 0; i < value.multivalue.length; i++)qs = appendQueryString(qs, key, value.multivalue[i].value);
8
+ }
17
9
  }
18
- }
19
-
20
- if (qs) {
21
- qs = "?" + qs;
22
- }
23
-
24
- return qs;
10
+ if (qs) qs = "?" + qs;
11
+ return qs;
25
12
  }
26
-
27
13
  function appendQueryString(qs, key, value) {
28
- if (value === null) {
14
+ if (null === value) return qs;
15
+ if (qs.length) qs += "&";
16
+ qs += `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
29
17
  return qs;
30
- }
31
-
32
- if (qs.length) {
33
- qs += "&";
34
- }
18
+ }
19
+ export { stringifyQuery };
35
20
 
36
- qs += `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
37
- return qs;
38
- }
21
+ //# sourceMappingURL=querystring.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["stringifyQuery","query","qs","key","Object","keys","value","appendQueryString","multivalue","i","length","encodeURIComponent"],"sources":["querystring.ts"],"sourcesContent":["import { CloudFrontQuery } from \"./types\";\n\nexport function stringifyQuery(query: CloudFrontQuery) {\n let qs = \"\";\n\n for (const key of Object.keys(query)) {\n const value = query[key];\n if (!value) {\n continue;\n }\n\n qs = appendQueryString(qs, key, value?.value);\n\n if (value.multivalue) {\n for (let i = 0; i < value.multivalue.length; i++) {\n qs = appendQueryString(qs, key, value.multivalue[i].value);\n }\n }\n }\n\n if (qs) {\n qs = \"?\" + qs;\n }\n\n return qs;\n}\n\nfunction appendQueryString(qs: string, key: string, value: string | null) {\n if (value === null) {\n return qs;\n }\n\n if (qs.length) {\n qs += \"&\";\n }\n\n qs += `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;\n\n return qs;\n}\n"],"mappings":"AAEA,OAAO,SAASA,cAAT,CAAwBC,KAAxB,EAAgD;EACnD,IAAIC,EAAE,GAAG,EAAT;;EAEA,KAAK,MAAMC,GAAX,IAAkBC,MAAM,CAACC,IAAP,CAAYJ,KAAZ,CAAlB,EAAsC;IAClC,MAAMK,KAAK,GAAGL,KAAK,CAACE,GAAD,CAAnB;;IACA,IAAI,CAACG,KAAL,EAAY;MACR;IACH;;IAEDJ,EAAE,GAAGK,iBAAiB,CAACL,EAAD,EAAKC,GAAL,EAAUG,KAAV,aAAUA,KAAV,uBAAUA,KAAK,CAAEA,KAAjB,CAAtB;;IAEA,IAAIA,KAAK,CAACE,UAAV,EAAsB;MAClB,KAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGH,KAAK,CAACE,UAAN,CAAiBE,MAArC,EAA6CD,CAAC,EAA9C,EAAkD;QAC9CP,EAAE,GAAGK,iBAAiB,CAACL,EAAD,EAAKC,GAAL,EAAUG,KAAK,CAACE,UAAN,CAAiBC,CAAjB,EAAoBH,KAA9B,CAAtB;MACH;IACJ;EACJ;;EAED,IAAIJ,EAAJ,EAAQ;IACJA,EAAE,GAAG,MAAMA,EAAX;EACH;;EAED,OAAOA,EAAP;AACH;;AAED,SAASK,iBAAT,CAA2BL,EAA3B,EAAuCC,GAAvC,EAAoDG,KAApD,EAA0E;EACtE,IAAIA,KAAK,KAAK,IAAd,EAAoB;IAChB,OAAOJ,EAAP;EACH;;EAED,IAAIA,EAAE,CAACQ,MAAP,EAAe;IACXR,EAAE,IAAI,GAAN;EACH;;EAEDA,EAAE,IAAK,GAAES,kBAAkB,CAACR,GAAD,CAAM,IAAGQ,kBAAkB,CAACL,KAAD,CAAQ,EAA9D;EAEA,OAAOJ,EAAP;AACH"}
1
+ {"version":3,"file":"cloudfrontFunctions/querystring.js","sources":["../../src/cloudfrontFunctions/querystring.ts"],"sourcesContent":["import type { CloudFrontQuery } from \"./types.js\";\n\nexport function stringifyQuery(query: CloudFrontQuery) {\n let qs = \"\";\n\n for (const key of Object.keys(query)) {\n const value = query[key];\n if (!value) {\n continue;\n }\n\n qs = appendQueryString(qs, key, value?.value);\n\n if (value.multivalue) {\n for (let i = 0; i < value.multivalue.length; i++) {\n qs = appendQueryString(qs, key, value.multivalue[i].value);\n }\n }\n }\n\n if (qs) {\n qs = \"?\" + qs;\n }\n\n return qs;\n}\n\nfunction appendQueryString(qs: string, key: string, value: string | null) {\n if (value === null) {\n return qs;\n }\n\n if (qs.length) {\n qs += \"&\";\n }\n\n qs += `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;\n\n return qs;\n}\n"],"names":["stringifyQuery","query","qs","key","Object","value","appendQueryString","i","encodeURIComponent"],"mappings":"AAEO,SAASA,eAAeC,KAAsB;IACjD,IAAIC,KAAK;IAET,KAAK,MAAMC,OAAOC,OAAO,IAAI,CAACH,OAAQ;QAClC,MAAMI,QAAQJ,KAAK,CAACE,IAAI;QACxB,IAAKE;YAILH,KAAKI,kBAAkBJ,IAAIC,KAAKE,OAAO;YAEvC,IAAIA,MAAM,UAAU,EAChB,IAAK,IAAIE,IAAI,GAAGA,IAAIF,MAAM,UAAU,CAAC,MAAM,EAAEE,IACzCL,KAAKI,kBAAkBJ,IAAIC,KAAKE,MAAM,UAAU,CAACE,EAAE,CAAC,KAAK;;IAGrE;IAEA,IAAIL,IACAA,KAAK,MAAMA;IAGf,OAAOA;AACX;AAEA,SAASI,kBAAkBJ,EAAU,EAAEC,GAAW,EAAEE,KAAoB;IACpE,IAAIA,AAAU,SAAVA,OACA,OAAOH;IAGX,IAAIA,GAAG,MAAM,EACTA,MAAM;IAGVA,MAAM,GAAGM,mBAAmBL,KAAK,CAAC,EAAEK,mBAAmBH,QAAQ;IAE/D,OAAOH;AACX"}
@@ -1,4 +1,4 @@
1
- import { CloudFrontQuery, CloudFrontResponse } from "./types";
1
+ import type { CloudFrontQuery, CloudFrontResponse } from "./types.js";
2
2
  interface RedirectParams {
3
3
  url: string;
4
4
  query?: CloudFrontQuery;
@@ -1,22 +1,20 @@
1
- import { setNoCacheHeaders } from "./headers";
2
- import { stringifyQuery } from "./querystring";
3
- export function redirectResponse(params) {
4
- const query = params.query ? stringifyQuery(params.query) : "";
5
- const permanent = params.status === 301;
6
- const response = {
7
- statusCode: params.status || 302,
8
- statusDescription: params.status === 301 ? "Moved permanently" : "Found",
9
- headers: {
10
- location: {
11
- value: params.url + query
12
- }
13
- }
14
- };
1
+ import { setNoCacheHeaders } from "./headers.js";
2
+ import { stringifyQuery } from "./querystring.js";
3
+ function redirectResponse(params) {
4
+ const query = params.query ? stringifyQuery(params.query) : "";
5
+ const permanent = 301 === params.status;
6
+ const response = {
7
+ statusCode: params.status || 302,
8
+ statusDescription: 301 === params.status ? "Moved permanently" : "Found",
9
+ headers: {
10
+ location: {
11
+ value: params.url + query
12
+ }
13
+ }
14
+ };
15
+ if (!permanent) setNoCacheHeaders(response.headers);
16
+ return response;
17
+ }
18
+ export { redirectResponse };
15
19
 
16
- if (!permanent) {
17
- // For temporary redirects make sure they won't be cached.
18
- setNoCacheHeaders(response.headers);
19
- }
20
-
21
- return response;
22
- }
20
+ //# sourceMappingURL=redirect.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["setNoCacheHeaders","stringifyQuery","redirectResponse","params","query","permanent","status","response","statusCode","statusDescription","headers","location","value","url"],"sources":["redirect.ts"],"sourcesContent":["import { CloudFrontQuery, CloudFrontResponse } from \"./types\";\nimport { setNoCacheHeaders } from \"./headers\";\nimport { stringifyQuery } from \"./querystring\";\n\ninterface RedirectParams {\n url: string;\n query?: CloudFrontQuery;\n status?: number;\n}\n\nexport function redirectResponse(params: RedirectParams) {\n const query = params.query ? stringifyQuery(params.query) : \"\";\n const permanent = params.status === 301;\n\n const response: CloudFrontResponse = {\n statusCode: params.status || 302,\n statusDescription: params.status === 301 ? \"Moved permanently\" : \"Found\",\n headers: {\n location: { value: params.url + query }\n }\n };\n\n if (!permanent) {\n // For temporary redirects make sure they won't be cached.\n setNoCacheHeaders(response.headers);\n }\n\n return response;\n}\n"],"mappings":"AACA,SAASA,iBAAT;AACA,SAASC,cAAT;AAQA,OAAO,SAASC,gBAAT,CAA0BC,MAA1B,EAAkD;EACrD,MAAMC,KAAK,GAAGD,MAAM,CAACC,KAAP,GAAeH,cAAc,CAACE,MAAM,CAACC,KAAR,CAA7B,GAA8C,EAA5D;EACA,MAAMC,SAAS,GAAGF,MAAM,CAACG,MAAP,KAAkB,GAApC;EAEA,MAAMC,QAA4B,GAAG;IACjCC,UAAU,EAAEL,MAAM,CAACG,MAAP,IAAiB,GADI;IAEjCG,iBAAiB,EAAEN,MAAM,CAACG,MAAP,KAAkB,GAAlB,GAAwB,mBAAxB,GAA8C,OAFhC;IAGjCI,OAAO,EAAE;MACLC,QAAQ,EAAE;QAAEC,KAAK,EAAET,MAAM,CAACU,GAAP,GAAaT;MAAtB;IADL;EAHwB,CAArC;;EAQA,IAAI,CAACC,SAAL,EAAgB;IACZ;IACAL,iBAAiB,CAACO,QAAQ,CAACG,OAAV,CAAjB;EACH;;EAED,OAAOH,QAAP;AACH"}
1
+ {"version":3,"file":"cloudfrontFunctions/redirect.js","sources":["../../src/cloudfrontFunctions/redirect.ts"],"sourcesContent":["import type { CloudFrontQuery, CloudFrontResponse } from \"./types.js\";\nimport { setNoCacheHeaders } from \"./headers.js\";\nimport { stringifyQuery } from \"./querystring.js\";\n\ninterface RedirectParams {\n url: string;\n query?: CloudFrontQuery;\n status?: number;\n}\n\nexport function redirectResponse(params: RedirectParams) {\n const query = params.query ? stringifyQuery(params.query) : \"\";\n const permanent = params.status === 301;\n\n const response: CloudFrontResponse = {\n statusCode: params.status || 302,\n statusDescription: params.status === 301 ? \"Moved permanently\" : \"Found\",\n headers: {\n location: { value: params.url + query }\n }\n };\n\n if (!permanent) {\n // For temporary redirects make sure they won't be cached.\n setNoCacheHeaders(response.headers);\n }\n\n return response;\n}\n"],"names":["redirectResponse","params","query","stringifyQuery","permanent","response","setNoCacheHeaders"],"mappings":";;AAUO,SAASA,iBAAiBC,MAAsB;IACnD,MAAMC,QAAQD,OAAO,KAAK,GAAGE,eAAeF,OAAO,KAAK,IAAI;IAC5D,MAAMG,YAAYH,AAAkB,QAAlBA,OAAO,MAAM;IAE/B,MAAMI,WAA+B;QACjC,YAAYJ,OAAO,MAAM,IAAI;QAC7B,mBAAmBA,AAAkB,QAAlBA,OAAO,MAAM,GAAW,sBAAsB;QACjE,SAAS;YACL,UAAU;gBAAE,OAAOA,OAAO,GAAG,GAAGC;YAAM;QAC1C;IACJ;IAEA,IAAI,CAACE,WAEDE,kBAAkBD,SAAS,OAAO;IAGtC,OAAOA;AACX"}
@@ -11,15 +11,15 @@ export interface ResponseCookie extends SingleValue {
11
11
  * In principle you may have multiple same headers and cookies in one request or response.
12
12
  * This is a wrapper interface for simpler use.
13
13
  */
14
- export declare type MultiValue<T> = T & {
14
+ export type MultiValue<T> = T & {
15
15
  /** Additional values for the same item (for example multiple values for the same cookie.) */
16
16
  multivalue?: T[];
17
17
  };
18
- export declare type MultiValueDictionary<T> = Record<string, MultiValue<T> | undefined>;
19
- export declare type CloudFrontHeaders = MultiValueDictionary<SingleValue>;
20
- export declare type CloudFrontRequestCookies = MultiValueDictionary<SingleValue>;
21
- export declare type CloudFrontResponseCookies = MultiValueDictionary<ResponseCookie>;
22
- export declare type CloudFrontQuery = MultiValueDictionary<SingleValue>;
18
+ export type MultiValueDictionary<T> = Record<string, MultiValue<T> | undefined>;
19
+ export type CloudFrontHeaders = MultiValueDictionary<SingleValue>;
20
+ export type CloudFrontRequestCookies = MultiValueDictionary<SingleValue>;
21
+ export type CloudFrontResponseCookies = MultiValueDictionary<ResponseCookie>;
22
+ export type CloudFrontQuery = MultiValueDictionary<SingleValue>;
23
23
  /**
24
24
  * Interface type for request in CloudFront Functions
25
25
  * see: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/functions-event-structure.html
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +1,4 @@
1
- import { CloudFrontRequestHandler, CloudFrontResponseHandler } from "./types";
1
+ import type { CloudFrontRequestHandler, CloudFrontResponseHandler } from "./types.js";
2
2
  /**
3
3
  * Helper function to easier define CloudFront Function request handler.
4
4
  *
@@ -1,21 +1,10 @@
1
- /**
2
- * Helper function to easier define CloudFront Function request handler.
3
- *
4
- * Lambdas use exports, but CloudFront Functions use a global `handler` variable.
5
- * This way you only have to run the function within your handler script,
6
- * and you are provided with working handler and full typing.
7
- **/
8
- export function defineCloudfrontFunctionRequestHandler(handler) {
9
- global.handler = handler;
1
+ import { __webpack_require__ } from "../rslib-runtime.js";
2
+ function defineCloudfrontFunctionRequestHandler(handler) {
3
+ __webpack_require__.g.handler = handler;
10
4
  }
11
- /**
12
- * Helper function to easier define CloudFront Function response handler.
13
- *
14
- * Lambdas use exports, but CloudFront Functions use a global `handler` variable.
15
- * This way you only have to run the function within your handler script,
16
- * and you are provided with working handler and full typing.
17
- **/
5
+ function defineCloudfrontFunctionResponseHandler(handler) {
6
+ __webpack_require__.g.handler = handler;
7
+ }
8
+ export { defineCloudfrontFunctionRequestHandler, defineCloudfrontFunctionResponseHandler };
18
9
 
19
- export function defineCloudfrontFunctionResponseHandler(handler) {
20
- global.handler = handler;
21
- }
10
+ //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["defineCloudfrontFunctionRequestHandler","handler","global","defineCloudfrontFunctionResponseHandler"],"sources":["utils.ts"],"sourcesContent":["import { CloudFrontRequestHandler, CloudFrontResponseHandler } from \"./types\";\n\ndeclare const global: typeof globalThis & {\n // CloudFront Functions use global handler value, not exports.\n handler: Function;\n};\n\n/**\n * Helper function to easier define CloudFront Function request handler.\n *\n * Lambdas use exports, but CloudFront Functions use a global `handler` variable.\n * This way you only have to run the function within your handler script,\n * and you are provided with working handler and full typing.\n **/\nexport function defineCloudfrontFunctionRequestHandler(handler: CloudFrontRequestHandler) {\n global.handler = handler;\n}\n\n/**\n * Helper function to easier define CloudFront Function response handler.\n *\n * Lambdas use exports, but CloudFront Functions use a global `handler` variable.\n * This way you only have to run the function within your handler script,\n * and you are provided with working handler and full typing.\n **/\nexport function defineCloudfrontFunctionResponseHandler(handler: CloudFrontResponseHandler) {\n global.handler = handler;\n}\n"],"mappings":"AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,sCAAT,CAAgDC,OAAhD,EAAmF;EACtFC,MAAM,CAACD,OAAP,GAAiBA,OAAjB;AACH;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,uCAAT,CAAiDF,OAAjD,EAAqF;EACxFC,MAAM,CAACD,OAAP,GAAiBA,OAAjB;AACH"}
1
+ {"version":3,"file":"cloudfrontFunctions/utils.js","sources":["../../src/cloudfrontFunctions/utils.ts"],"sourcesContent":["import type { CloudFrontRequestHandler, CloudFrontResponseHandler } from \"./types.js\";\n\ndeclare const global: typeof globalThis & {\n handler: CloudFrontRequestHandler | CloudFrontResponseHandler;\n};\n\n/**\n * Helper function to easier define CloudFront Function request handler.\n *\n * Lambdas use exports, but CloudFront Functions use a global `handler` variable.\n * This way you only have to run the function within your handler script,\n * and you are provided with working handler and full typing.\n **/\nexport function defineCloudfrontFunctionRequestHandler(handler: CloudFrontRequestHandler) {\n global.handler = handler;\n}\n\n/**\n * Helper function to easier define CloudFront Function response handler.\n *\n * Lambdas use exports, but CloudFront Functions use a global `handler` variable.\n * This way you only have to run the function within your handler script,\n * and you are provided with working handler and full typing.\n **/\nexport function defineCloudfrontFunctionResponseHandler(handler: CloudFrontResponseHandler) {\n global.handler = handler;\n}\n"],"names":["defineCloudfrontFunctionRequestHandler","handler","global","defineCloudfrontFunctionResponseHandler"],"mappings":";AAaO,SAASA,uCAAuCC,OAAiC;IACpFC,oBAAAA,CAAMA,CAAC,OAAO,GAAGD;AACrB;AASO,SAASE,wCAAwCF,OAAkC;IACtFC,oBAAAA,CAAMA,CAAC,OAAO,GAAGD;AACrB"}
package/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./lambdaEdge";
1
+ export * from "./lambdaEdge/index.js";
package/index.js CHANGED
@@ -1 +1 @@
1
- export * from "./lambdaEdge";
1
+ export * from "./lambdaEdge/index.js";
@@ -1,3 +1,3 @@
1
- import { CloudFrontRequest, CloudFrontResponse } from "./types";
1
+ import type { CloudFrontRequest, CloudFrontResponse } from "./types.js";
2
2
  export declare function getRequestCookies(request: CloudFrontRequest): Record<string, string | undefined>;
3
3
  export declare function setResponseCookie(response: CloudFrontResponse, cookie: string): void;
@@ -1,25 +1,22 @@
1
- import { getHeader } from "./headers";
2
- export function getRequestCookies(request) {
3
- const header = getHeader(request.headers, "cookie");
4
- const cookies = {};
5
-
6
- if (!header) {
1
+ import { getHeader } from "./headers.js";
2
+ function getRequestCookies(request) {
3
+ const header = getHeader(request.headers, "cookie");
4
+ const cookies = {};
5
+ if (!header) return cookies;
6
+ const cookiesArray = decodeURIComponent(header).split(";");
7
+ for (const cookie of cookiesArray){
8
+ const [name, value] = cookie.trim().split("=");
9
+ cookies[name] = value;
10
+ }
7
11
  return cookies;
8
- }
9
-
10
- const cookiesArray = decodeURIComponent(header).split(";");
11
-
12
- for (const cookie of cookiesArray) {
13
- const [name, value] = cookie.trim().split("=");
14
- cookies[name] = value;
15
- }
16
-
17
- return cookies;
18
12
  }
19
- export function setResponseCookie(response, cookie) {
20
- const headers = response.headers;
21
- const cookies = headers["set-cookie"] || (headers["set-cookie"] = []);
22
- cookies.push({
23
- value: cookie
24
- });
25
- }
13
+ function setResponseCookie(response, cookie) {
14
+ const headers = response.headers;
15
+ const cookies = headers["set-cookie"] || (headers["set-cookie"] = []);
16
+ cookies.push({
17
+ value: cookie
18
+ });
19
+ }
20
+ export { getRequestCookies, setResponseCookie };
21
+
22
+ //# sourceMappingURL=cookies.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getHeader","getRequestCookies","request","header","headers","cookies","cookiesArray","decodeURIComponent","split","cookie","name","value","trim","setResponseCookie","response","push"],"sources":["cookies.ts"],"sourcesContent":["import { getHeader } from \"./headers\";\nimport { CloudFrontRequest, CloudFrontResponse } from \"./types\";\n\nexport function getRequestCookies(request: CloudFrontRequest) {\n const header = getHeader(request.headers, \"cookie\");\n const cookies: Record<string, string | undefined> = {};\n\n if (!header) {\n return cookies;\n }\n\n const cookiesArray = decodeURIComponent(header).split(\";\");\n\n for (const cookie of cookiesArray) {\n const [name, value] = cookie.trim().split(\"=\");\n cookies[name] = value;\n }\n\n return cookies;\n}\n\nexport function setResponseCookie(response: CloudFrontResponse, cookie: string) {\n const headers = response.headers;\n const cookies = headers[\"set-cookie\"] || (headers[\"set-cookie\"] = []);\n\n cookies.push({\n value: cookie\n });\n}\n"],"mappings":"AAAA,SAASA,SAAT;AAGA,OAAO,SAASC,iBAAT,CAA2BC,OAA3B,EAAuD;EAC1D,MAAMC,MAAM,GAAGH,SAAS,CAACE,OAAO,CAACE,OAAT,EAAkB,QAAlB,CAAxB;EACA,MAAMC,OAA2C,GAAG,EAApD;;EAEA,IAAI,CAACF,MAAL,EAAa;IACT,OAAOE,OAAP;EACH;;EAED,MAAMC,YAAY,GAAGC,kBAAkB,CAACJ,MAAD,CAAlB,CAA2BK,KAA3B,CAAiC,GAAjC,CAArB;;EAEA,KAAK,MAAMC,MAAX,IAAqBH,YAArB,EAAmC;IAC/B,MAAM,CAACI,IAAD,EAAOC,KAAP,IAAgBF,MAAM,CAACG,IAAP,GAAcJ,KAAd,CAAoB,GAApB,CAAtB;IACAH,OAAO,CAACK,IAAD,CAAP,GAAgBC,KAAhB;EACH;;EAED,OAAON,OAAP;AACH;AAED,OAAO,SAASQ,iBAAT,CAA2BC,QAA3B,EAAyDL,MAAzD,EAAyE;EAC5E,MAAML,OAAO,GAAGU,QAAQ,CAACV,OAAzB;EACA,MAAMC,OAAO,GAAGD,OAAO,CAAC,YAAD,CAAP,KAA0BA,OAAO,CAAC,YAAD,CAAP,GAAwB,EAAlD,CAAhB;EAEAC,OAAO,CAACU,IAAR,CAAa;IACTJ,KAAK,EAAEF;EADE,CAAb;AAGH"}
1
+ {"version":3,"file":"lambdaEdge/cookies.js","sources":["../../src/lambdaEdge/cookies.ts"],"sourcesContent":["import { getHeader } from \"./headers.js\";\nimport type { CloudFrontRequest, CloudFrontResponse } from \"./types.js\";\n\nexport function getRequestCookies(request: CloudFrontRequest) {\n const header = getHeader(request.headers, \"cookie\");\n const cookies: Record<string, string | undefined> = {};\n\n if (!header) {\n return cookies;\n }\n\n const cookiesArray = decodeURIComponent(header).split(\";\");\n\n for (const cookie of cookiesArray) {\n const [name, value] = cookie.trim().split(\"=\");\n cookies[name] = value;\n }\n\n return cookies;\n}\n\nexport function setResponseCookie(response: CloudFrontResponse, cookie: string) {\n const headers = response.headers;\n const cookies = headers[\"set-cookie\"] || (headers[\"set-cookie\"] = []);\n\n cookies.push({\n value: cookie\n });\n}\n"],"names":["getRequestCookies","request","header","getHeader","cookies","cookiesArray","decodeURIComponent","cookie","name","value","setResponseCookie","response","headers"],"mappings":";AAGO,SAASA,kBAAkBC,OAA0B;IACxD,MAAMC,SAASC,UAAUF,QAAQ,OAAO,EAAE;IAC1C,MAAMG,UAA8C,CAAC;IAErD,IAAI,CAACF,QACD,OAAOE;IAGX,MAAMC,eAAeC,mBAAmBJ,QAAQ,KAAK,CAAC;IAEtD,KAAK,MAAMK,UAAUF,aAAc;QAC/B,MAAM,CAACG,MAAMC,MAAM,GAAGF,OAAO,IAAI,GAAG,KAAK,CAAC;QAC1CH,OAAO,CAACI,KAAK,GAAGC;IACpB;IAEA,OAAOL;AACX;AAEO,SAASM,kBAAkBC,QAA4B,EAAEJ,MAAc;IAC1E,MAAMK,UAAUD,SAAS,OAAO;IAChC,MAAMP,UAAUQ,OAAO,CAAC,aAAa,IAAKA,CAAAA,OAAO,CAAC,aAAa,GAAG,EAAC;IAEnER,QAAQ,IAAI,CAAC;QACT,OAAOG;IACX;AACJ"}
@@ -1,4 +1,4 @@
1
- import { CloudFrontHeaders } from "./types";
1
+ import type { CloudFrontHeaders } from "./types.js";
2
2
  export declare function setHeader(headers: CloudFrontHeaders, header: {
3
3
  key: string;
4
4
  value: string;
@@ -1,8 +1,11 @@
1
- export function setHeader(headers, header) {
2
- headers[header.key] = [header];
1
+ function setHeader(headers, header) {
2
+ headers[header.key] = [
3
+ header
4
+ ];
3
5
  }
4
- export function getHeader(headers, header) {
5
- var _headers$header;
6
+ function getHeader(headers, header) {
7
+ return headers?.[header]?.[0].value;
8
+ }
9
+ export { getHeader, setHeader };
6
10
 
7
- return headers === null || headers === void 0 ? void 0 : (_headers$header = headers[header]) === null || _headers$header === void 0 ? void 0 : _headers$header[0].value;
8
- }
11
+ //# sourceMappingURL=headers.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["setHeader","headers","header","key","getHeader","value"],"sources":["headers.ts"],"sourcesContent":["import { CloudFrontHeaders } from \"./types\";\n\nexport function setHeader(headers: CloudFrontHeaders, header: { key: string; value: string }) {\n headers[header.key] = [header];\n}\n\nexport function getHeader(headers: CloudFrontHeaders | undefined, header: string) {\n return headers?.[header]?.[0].value;\n}\n"],"mappings":"AAEA,OAAO,SAASA,SAAT,CAAmBC,OAAnB,EAA+CC,MAA/C,EAAuF;EAC1FD,OAAO,CAACC,MAAM,CAACC,GAAR,CAAP,GAAsB,CAACD,MAAD,CAAtB;AACH;AAED,OAAO,SAASE,SAAT,CAAmBH,OAAnB,EAA2DC,MAA3D,EAA2E;EAAA;;EAC9E,OAAOD,OAAP,aAAOA,OAAP,0CAAOA,OAAO,CAAGC,MAAH,CAAd,oDAAO,gBAAoB,CAApB,EAAuBG,KAA9B;AACH"}
1
+ {"version":3,"file":"lambdaEdge/headers.js","sources":["../../src/lambdaEdge/headers.ts"],"sourcesContent":["import type { CloudFrontHeaders } from \"./types.js\";\n\nexport function setHeader(headers: CloudFrontHeaders, header: { key: string; value: string }) {\n headers[header.key] = [header];\n}\n\nexport function getHeader(headers: CloudFrontHeaders | undefined, header: string) {\n return headers?.[header]?.[0].value;\n}\n"],"names":["setHeader","headers","header","getHeader"],"mappings":"AAEO,SAASA,UAAUC,OAA0B,EAAEC,MAAsC;IACxFD,OAAO,CAACC,OAAO,GAAG,CAAC,GAAG;QAACA;KAAO;AAClC;AAEO,SAASC,UAAUF,OAAsC,EAAEC,MAAc;IAC5E,OAAOD,SAAS,CAACC,OAAO,EAAE,CAAC,EAAE,CAAC;AAClC"}
@@ -1,7 +1,7 @@
1
- export * from "./cookies";
2
- export * from "./headers";
3
- export * from "./redirect";
4
- export * from "./request";
5
- export * from "./response";
6
- export * from "./types";
7
- export * from "./utils";
1
+ export * from "./cookies.js";
2
+ export * from "./headers.js";
3
+ export * from "./redirect.js";
4
+ export * from "./request.js";
5
+ export * from "./response.js";
6
+ export * from "./types.js";
7
+ export * from "./utils.js";
@@ -1,7 +1,7 @@
1
- export * from "./cookies";
2
- export * from "./headers";
3
- export * from "./redirect";
4
- export * from "./request";
5
- export * from "./response";
6
- export * from "./types";
7
- export * from "./utils";
1
+ export * from "./cookies.js";
2
+ export * from "./headers.js";
3
+ export * from "./redirect.js";
4
+ export * from "./request.js";
5
+ export * from "./response.js";
6
+ export * from "./types.js";
7
+ export * from "./utils.js";
@@ -1,4 +1,4 @@
1
- import { CloudFrontResponse } from "./types";
1
+ import type { CloudFrontResponse } from "./types.js";
2
2
  interface RedirectParams {
3
3
  url: string;
4
4
  query?: string;