@webiny/aws-helpers 5.26.1-beta.0

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 (83) hide show
  1. package/LICENSE +26 -0
  2. package/cloudfrontFunctions/cookies.d.ts +8 -0
  3. package/cloudfrontFunctions/cookies.js +28 -0
  4. package/cloudfrontFunctions/cookies.js.map +1 -0
  5. package/cloudfrontFunctions/headers.d.ts +5 -0
  6. package/cloudfrontFunctions/headers.js +26 -0
  7. package/cloudfrontFunctions/headers.js.map +1 -0
  8. package/cloudfrontFunctions/index.d.ts +6 -0
  9. package/cloudfrontFunctions/index.js +6 -0
  10. package/cloudfrontFunctions/index.js.map +1 -0
  11. package/cloudfrontFunctions/querystring.d.ts +2 -0
  12. package/cloudfrontFunctions/querystring.js +38 -0
  13. package/cloudfrontFunctions/querystring.js.map +1 -0
  14. package/cloudfrontFunctions/redirect.d.ts +8 -0
  15. package/cloudfrontFunctions/redirect.js +22 -0
  16. package/cloudfrontFunctions/redirect.js.map +1 -0
  17. package/cloudfrontFunctions/types.d.ts +78 -0
  18. package/cloudfrontFunctions/types.js +1 -0
  19. package/cloudfrontFunctions/types.js.map +1 -0
  20. package/cloudfrontFunctions/utils.d.ts +17 -0
  21. package/cloudfrontFunctions/utils.js +21 -0
  22. package/cloudfrontFunctions/utils.js.map +1 -0
  23. package/index.d.ts +1 -0
  24. package/index.js +1 -0
  25. package/index.js.map +1 -0
  26. package/lambdaEdge/cookies.d.ts +3 -0
  27. package/lambdaEdge/cookies.js +25 -0
  28. package/lambdaEdge/cookies.js.map +1 -0
  29. package/lambdaEdge/headers.d.ts +6 -0
  30. package/lambdaEdge/headers.js +8 -0
  31. package/lambdaEdge/headers.js.map +1 -0
  32. package/lambdaEdge/index.d.ts +7 -0
  33. package/lambdaEdge/index.js +7 -0
  34. package/lambdaEdge/index.js.map +1 -0
  35. package/lambdaEdge/redirect.d.ts +8 -0
  36. package/lambdaEdge/redirect.js +32 -0
  37. package/lambdaEdge/redirect.js.map +1 -0
  38. package/lambdaEdge/request.d.ts +2 -0
  39. package/lambdaEdge/request.js +19 -0
  40. package/lambdaEdge/request.js.map +1 -0
  41. package/lambdaEdge/response.d.ts +2 -0
  42. package/lambdaEdge/response.js +7 -0
  43. package/lambdaEdge/response.js.map +1 -0
  44. package/lambdaEdge/types.d.ts +10 -0
  45. package/lambdaEdge/types.js +1 -0
  46. package/lambdaEdge/types.js.map +1 -0
  47. package/lambdaEdge/utils.d.ts +3 -0
  48. package/lambdaEdge/utils.js +6 -0
  49. package/lambdaEdge/utils.js.map +1 -0
  50. package/package.json +48 -0
  51. package/stagedRollouts/functions/adminOriginRequest.d.ts +2 -0
  52. package/stagedRollouts/functions/adminOriginRequest.js +29 -0
  53. package/stagedRollouts/functions/adminOriginRequest.js.map +1 -0
  54. package/stagedRollouts/functions/configOriginRequest.d.ts +2 -0
  55. package/stagedRollouts/functions/configOriginRequest.js +52 -0
  56. package/stagedRollouts/functions/configOriginRequest.js.map +1 -0
  57. package/stagedRollouts/functions/originRequest.d.ts +2 -0
  58. package/stagedRollouts/functions/originRequest.js +15 -0
  59. package/stagedRollouts/functions/originRequest.js.map +1 -0
  60. package/stagedRollouts/functions/viewerRequest.d.ts +1 -0
  61. package/stagedRollouts/functions/viewerRequest.js +42 -0
  62. package/stagedRollouts/functions/viewerRequest.js.map +1 -0
  63. package/stagedRollouts/functions/viewerResponse.d.ts +1 -0
  64. package/stagedRollouts/functions/viewerResponse.js +18 -0
  65. package/stagedRollouts/functions/viewerResponse.js.map +1 -0
  66. package/stagedRollouts/utils/common.d.ts +3 -0
  67. package/stagedRollouts/utils/common.js +5 -0
  68. package/stagedRollouts/utils/common.js.map +1 -0
  69. package/stagedRollouts/utils/headerBlacklist.d.ts +5 -0
  70. package/stagedRollouts/utils/headerBlacklist.js +13 -0
  71. package/stagedRollouts/utils/headerBlacklist.js.map +1 -0
  72. package/stagedRollouts/utils/loadOriginPage.d.ts +8 -0
  73. package/stagedRollouts/utils/loadOriginPage.js +107 -0
  74. package/stagedRollouts/utils/loadOriginPage.js.map +1 -0
  75. package/stagedRollouts/utils/loadTrafficSplittingConfig.d.ts +12 -0
  76. package/stagedRollouts/utils/loadTrafficSplittingConfig.js +65 -0
  77. package/stagedRollouts/utils/loadTrafficSplittingConfig.js.map +1 -0
  78. package/stagedRollouts/utils/loadVariantOrigin.d.ts +4 -0
  79. package/stagedRollouts/utils/loadVariantOrigin.js +83 -0
  80. package/stagedRollouts/utils/loadVariantOrigin.js.map +1 -0
  81. package/stagedRollouts/utils/log.d.ts +1 -0
  82. package/stagedRollouts/utils/log.js +7 -0
  83. package/stagedRollouts/utils/log.js.map +1 -0
package/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) Webiny Ltd.
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.
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
@@ -0,0 +1,8 @@
1
+ import { CloudFrontResponse } from "./types";
2
+ export interface CookieParams {
3
+ name: string;
4
+ value: string;
5
+ maxAge?: number;
6
+ }
7
+ /** Sets cookie for the HTTP response */
8
+ export declare function setResponseCookie(response: CloudFrontResponse, cookie: CookieParams): void;
@@ -0,0 +1,28 @@
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
26
+ };
27
+ }
28
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["cookies.ts"],"names":["setResponseCookie","response","cookie","cookies","current","name","attrs","maxAge","multivalue","push","value","attributes"],"mappings":"AAQA;AACA,OAAO,SAASA,iBAAT,CAA2BC,QAA3B,EAAyDC,MAAzD,EAA+E;AAClF,QAAMC,OAAO,GAAGF,QAAQ,CAACE,OAAT,KAAqBF,QAAQ,CAACE,OAAT,GAAmB,EAAxC,CAAhB;AAEA,QAAMC,OAAO,GAAGD,OAAO,CAACD,MAAM,CAACG,IAAR,CAAvB;AACA,MAAIC,KAAK,GAAI,iBAAb;;AAEA,MAAIJ,MAAM,CAACK,MAAX,EAAmB;AACfD,IAAAA,KAAK,IAAK,YAAWJ,MAAM,CAACK,MAAO,GAAnC;AACH;;AAED,MAAIH,OAAJ,EAAa;AACT;AACA;AACA;AACA;AACA;AACA,UAAMI,UAAU,GAAGJ,OAAO,CAACI,UAAR,KAAuBJ,OAAO,CAACI,UAAR,GAAqB,EAA5C,CAAnB;AACAA,IAAAA,UAAU,CAACC,IAAX,CAAgB;AACZC,MAAAA,KAAK,EAAER,MAAM,CAACQ,KADF;AAEZC,MAAAA,UAAU,EAAEL;AAFA,KAAhB;AAIH,GAXD,MAWO;AACHH,IAAAA,OAAO,CAACD,MAAM,CAACG,IAAR,CAAP,GAAuB;AACnBK,MAAAA,KAAK,EAAER,MAAM,CAACQ,KADK;AAEnBC,MAAAA,UAAU,EAAEL;AAFO,KAAvB;AAIH;AACJ","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"]}
@@ -0,0 +1,5 @@
1
+ import { CloudFrontHeaders, Header } from "./types";
2
+ export declare function getHeader(headers: CloudFrontHeaders, header: string): string | undefined;
3
+ export declare function setHeader(headers: CloudFrontHeaders, header: Header): void;
4
+ export declare function setHeaders(headers: CloudFrontHeaders, headersToSet: Header[]): void;
5
+ export declare function setNoCacheHeaders(headers: CloudFrontHeaders): void;
@@ -0,0 +1,26 @@
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;
5
+ }
6
+ export function setHeader(headers, header) {
7
+ headers[header.key] = {
8
+ value: header.value
9
+ };
10
+ }
11
+ export function setHeaders(headers, headersToSet) {
12
+ for (let i = 0; i < headersToSet.length; i++) {
13
+ setHeader(headers, headersToSet[i]);
14
+ }
15
+ }
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
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["headers.ts"],"names":["getHeader","headers","header","value","setHeader","key","setHeaders","headersToSet","i","length","setNoCacheHeaders"],"mappings":"AAEA,OAAO,SAASA,SAAT,CAAmBC,OAAnB,EAA+CC,MAA/C,EAA+D;AAAA;;AAClE,4BAAOD,OAAO,CAACC,MAAD,CAAd,oDAAO,gBAAiBC,KAAxB;AACH;AAED,OAAO,SAASC,SAAT,CAAmBH,OAAnB,EAA+CC,MAA/C,EAA+D;AAClED,EAAAA,OAAO,CAACC,MAAM,CAACG,GAAR,CAAP,GAAsB;AAClBF,IAAAA,KAAK,EAAED,MAAM,CAACC;AADI,GAAtB;AAGH;AAED,OAAO,SAASG,UAAT,CAAoBL,OAApB,EAAgDM,YAAhD,EAAwE;AAC3E,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGD,YAAY,CAACE,MAAjC,EAAyCD,CAAC,EAA1C,EAA8C;AAC1CJ,IAAAA,SAAS,CAACH,OAAD,EAAUM,YAAY,CAACC,CAAD,CAAtB,CAAT;AACH;AACJ;AAED,OAAO,SAASE,iBAAT,CAA2BT,OAA3B,EAAuD;AAC1DA,EAAAA,OAAO,CAAC,eAAD,CAAP,GAA2B;AAAEE,IAAAA,KAAK,EAAE;AAAT,GAA3B;AACAF,EAAAA,OAAO,CAAC,QAAD,CAAP,GAAoB;AAAEE,IAAAA,KAAK,EAAE;AAAT,GAApB;AACAF,EAAAA,OAAO,CAAC,SAAD,CAAP,GAAqB;AAAEE,IAAAA,KAAK,EAAE;AAAT,GAArB;AACH","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"]}
@@ -0,0 +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";
@@ -0,0 +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";
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA","sourcesContent":["export * from \"./cookies\";\nexport * from \"./headers\";\nexport * from \"./querystring\";\nexport * from \"./redirect\";\nexport * from \"./types\";\nexport * from \"./utils\";\n"]}
@@ -0,0 +1,2 @@
1
+ import { CloudFrontQuery } from "./types";
2
+ export declare function stringifyQuery(query: CloudFrontQuery): string;
@@ -0,0 +1,38 @@
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
+ }
17
+ }
18
+ }
19
+
20
+ if (qs) {
21
+ qs = "?" + qs;
22
+ }
23
+
24
+ return qs;
25
+ }
26
+
27
+ function appendQueryString(qs, key, value) {
28
+ if (value === null) {
29
+ return qs;
30
+ }
31
+
32
+ if (qs.length) {
33
+ qs += "&";
34
+ }
35
+
36
+ qs += `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
37
+ return qs;
38
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["querystring.ts"],"names":["stringifyQuery","query","qs","key","Object","keys","value","appendQueryString","multivalue","i","length","encodeURIComponent"],"mappings":"AAEA,OAAO,SAASA,cAAT,CAAwBC,KAAxB,EAAgD;AACnD,MAAIC,EAAE,GAAG,EAAT;;AAEA,OAAK,MAAMC,GAAX,IAAkBC,MAAM,CAACC,IAAP,CAAYJ,KAAZ,CAAlB,EAAsC;AAClC,UAAMK,KAAK,GAAGL,KAAK,CAACE,GAAD,CAAnB;;AACA,QAAI,CAACG,KAAL,EAAY;AACR;AACH;;AAEDJ,IAAAA,EAAE,GAAGK,iBAAiB,CAACL,EAAD,EAAKC,GAAL,EAAUG,KAAV,aAAUA,KAAV,uBAAUA,KAAK,CAAEA,KAAjB,CAAtB;;AAEA,QAAIA,KAAK,CAACE,UAAV,EAAsB;AAClB,WAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGH,KAAK,CAACE,UAAN,CAAiBE,MAArC,EAA6CD,CAAC,EAA9C,EAAkD;AAC9CP,QAAAA,EAAE,GAAGK,iBAAiB,CAACL,EAAD,EAAKC,GAAL,EAAUG,KAAK,CAACE,UAAN,CAAiBC,CAAjB,EAAoBH,KAA9B,CAAtB;AACH;AACJ;AACJ;;AAED,MAAIJ,EAAJ,EAAQ;AACJA,IAAAA,EAAE,GAAG,MAAMA,EAAX;AACH;;AAED,SAAOA,EAAP;AACH;;AAED,SAASK,iBAAT,CAA2BL,EAA3B,EAAuCC,GAAvC,EAAoDG,KAApD,EAA0E;AACtE,MAAIA,KAAK,KAAK,IAAd,EAAoB;AAChB,WAAOJ,EAAP;AACH;;AAED,MAAIA,EAAE,CAACQ,MAAP,EAAe;AACXR,IAAAA,EAAE,IAAI,GAAN;AACH;;AAEDA,EAAAA,EAAE,IAAK,GAAES,kBAAkB,CAACR,GAAD,CAAM,IAAGQ,kBAAkB,CAACL,KAAD,CAAQ,EAA9D;AAEA,SAAOJ,EAAP;AACH","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"]}
@@ -0,0 +1,8 @@
1
+ import { CloudFrontQuery, CloudFrontResponse } from "./types";
2
+ interface RedirectParams {
3
+ url: string;
4
+ query?: CloudFrontQuery;
5
+ status?: number;
6
+ }
7
+ export declare function redirectResponse(params: RedirectParams): CloudFrontResponse;
8
+ export {};
@@ -0,0 +1,22 @@
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
+ };
15
+
16
+ if (!permanent) {
17
+ // For temporary redirects make sure they won't be cached.
18
+ setNoCacheHeaders(response.headers);
19
+ }
20
+
21
+ return response;
22
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["redirect.ts"],"names":["setNoCacheHeaders","stringifyQuery","redirectResponse","params","query","permanent","status","response","statusCode","statusDescription","headers","location","value","url"],"mappings":"AACA,SAASA,iBAAT;AACA,SAASC,cAAT;AAQA,OAAO,SAASC,gBAAT,CAA0BC,MAA1B,EAAkD;AACrD,QAAMC,KAAK,GAAGD,MAAM,CAACC,KAAP,GAAeH,cAAc,CAACE,MAAM,CAACC,KAAR,CAA7B,GAA8C,EAA5D;AACA,QAAMC,SAAS,GAAGF,MAAM,CAACG,MAAP,KAAkB,GAApC;AAEA,QAAMC,QAA4B,GAAG;AACjCC,IAAAA,UAAU,EAAEL,MAAM,CAACG,MAAP,IAAiB,GADI;AAEjCG,IAAAA,iBAAiB,EAAEN,MAAM,CAACG,MAAP,KAAkB,GAAlB,GAAwB,mBAAxB,GAA8C,OAFhC;AAGjCI,IAAAA,OAAO,EAAE;AACLC,MAAAA,QAAQ,EAAE;AAAEC,QAAAA,KAAK,EAAET,MAAM,CAACU,GAAP,GAAaT;AAAtB;AADL;AAHwB,GAArC;;AAQA,MAAI,CAACC,SAAL,EAAgB;AACZ;AACAL,IAAAA,iBAAiB,CAACO,QAAQ,CAACG,OAAV,CAAjB;AACH;;AAED,SAAOH,QAAP;AACH","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"]}
@@ -0,0 +1,78 @@
1
+ export interface SingleValue {
2
+ value: string;
3
+ }
4
+ export interface Header extends SingleValue {
5
+ key: string;
6
+ }
7
+ export interface ResponseCookie extends SingleValue {
8
+ attributes?: string;
9
+ }
10
+ /**
11
+ * In principle you may have multiple same headers and cookies in one request or response.
12
+ * This is a wrapper interface for simpler use.
13
+ */
14
+ export declare type MultiValue<T> = T & {
15
+ /** Additional values for the same item (for example multiple values for the same cookie.) */
16
+ multivalue?: T[];
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>;
23
+ /**
24
+ * Interface type for request in CloudFront Functions
25
+ * see: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/functions-event-structure.html
26
+ */
27
+ export interface CloudFrontRequest {
28
+ method: string;
29
+ uri: string;
30
+ querystring?: CloudFrontQuery;
31
+ headers: CloudFrontHeaders;
32
+ cookies?: CloudFrontRequestCookies;
33
+ }
34
+ /**
35
+ * Interface type for response in CloudFront Functions
36
+ * see: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/functions-event-structure.html
37
+ */
38
+ export interface CloudFrontResponse {
39
+ statusCode: number;
40
+ statusDescription?: string;
41
+ headers: CloudFrontHeaders;
42
+ cookies?: CloudFrontResponseCookies;
43
+ }
44
+ /**
45
+ * Interface type for request event in CloudFront Functions
46
+ * see: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/functions-event-structure.html
47
+ */
48
+ export interface CloudFrontRequestEvent {
49
+ version: string;
50
+ context: {
51
+ eventType: "viewer-request";
52
+ };
53
+ viewer: {
54
+ ip: string;
55
+ };
56
+ request: CloudFrontRequest;
57
+ }
58
+ /**
59
+ * Interface type for response event in CloudFront Functions
60
+ * see: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/functions-event-structure.html
61
+ */
62
+ export interface CloudFrontResponseEvent {
63
+ version: string;
64
+ context: {
65
+ eventType: "viewer-response";
66
+ };
67
+ viewer: {
68
+ ip: string;
69
+ };
70
+ response: CloudFrontResponse;
71
+ request: CloudFrontRequest;
72
+ }
73
+ export interface CloudFrontRequestHandler {
74
+ (event: CloudFrontRequestEvent): CloudFrontRequest | CloudFrontResponse;
75
+ }
76
+ export interface CloudFrontResponseHandler {
77
+ (event: CloudFrontResponseEvent): CloudFrontResponse;
78
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -0,0 +1,17 @@
1
+ import { CloudFrontRequestHandler, CloudFrontResponseHandler } from "./types";
2
+ /**
3
+ * Helper function to easier define CloudFront Function request handler.
4
+ *
5
+ * Lambdas use exports, but CloudFront Functions use a global `handler` variable.
6
+ * This way you only have to run the function within your handler script,
7
+ * and you are provided with working handler and full typing.
8
+ **/
9
+ export declare function defineCloudfrontFunctionRequestHandler(handler: CloudFrontRequestHandler): void;
10
+ /**
11
+ * Helper function to easier define CloudFront Function response handler.
12
+ *
13
+ * Lambdas use exports, but CloudFront Functions use a global `handler` variable.
14
+ * This way you only have to run the function within your handler script,
15
+ * and you are provided with working handler and full typing.
16
+ **/
17
+ export declare function defineCloudfrontFunctionResponseHandler(handler: CloudFrontResponseHandler): void;
@@ -0,0 +1,21 @@
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;
10
+ }
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
+ **/
18
+
19
+ export function defineCloudfrontFunctionResponseHandler(handler) {
20
+ global.handler = handler;
21
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils.ts"],"names":["defineCloudfrontFunctionRequestHandler","handler","global","defineCloudfrontFunctionResponseHandler"],"mappings":"AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,sCAAT,CAAgDC,OAAhD,EAAmF;AACtFC,EAAAA,MAAM,CAACD,OAAP,GAAiBA,OAAjB;AACH;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,uCAAT,CAAiDF,OAAjD,EAAqF;AACxFC,EAAAA,MAAM,CAACD,OAAP,GAAiBA,OAAjB;AACH","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"]}
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./lambdaEdge";
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from "./lambdaEdge";
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA","sourcesContent":["export * from \"./lambdaEdge\";\n"]}
@@ -0,0 +1,3 @@
1
+ import { CloudFrontRequest, CloudFrontResponse } from "./types";
2
+ export declare function getRequestCookies(request: CloudFrontRequest): Record<string, string | undefined>;
3
+ export declare function setResponseCookie(response: CloudFrontResponse, cookie: string): void;
@@ -0,0 +1,25 @@
1
+ import { getHeader } from "./headers";
2
+ export function getRequestCookies(request) {
3
+ const header = getHeader(request.headers, "cookie");
4
+ const cookies = {};
5
+
6
+ if (!header) {
7
+ 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
+ }
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
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["cookies.ts"],"names":["getHeader","getRequestCookies","request","header","headers","cookies","cookiesArray","decodeURIComponent","split","cookie","name","value","trim","setResponseCookie","response","push"],"mappings":"AAAA,SAASA,SAAT;AAGA,OAAO,SAASC,iBAAT,CAA2BC,OAA3B,EAAuD;AAC1D,QAAMC,MAAM,GAAGH,SAAS,CAACE,OAAO,CAACE,OAAT,EAAkB,QAAlB,CAAxB;AACA,QAAMC,OAA2C,GAAG,EAApD;;AAEA,MAAI,CAACF,MAAL,EAAa;AACT,WAAOE,OAAP;AACH;;AAED,QAAMC,YAAY,GAAGC,kBAAkB,CAACJ,MAAD,CAAlB,CAA2BK,KAA3B,CAAiC,GAAjC,CAArB;;AAEA,OAAK,MAAMC,MAAX,IAAqBH,YAArB,EAAmC;AAC/B,UAAM,CAACI,IAAD,EAAOC,KAAP,IAAgBF,MAAM,CAACG,IAAP,GAAcJ,KAAd,CAAoB,GAApB,CAAtB;AACAH,IAAAA,OAAO,CAACK,IAAD,CAAP,GAAgBC,KAAhB;AACH;;AAED,SAAON,OAAP;AACH;AAED,OAAO,SAASQ,iBAAT,CAA2BC,QAA3B,EAAyDL,MAAzD,EAAyE;AAC5E,QAAML,OAAO,GAAGU,QAAQ,CAACV,OAAzB;AACA,QAAMC,OAAO,GAAGD,OAAO,CAAC,YAAD,CAAP,KAA0BA,OAAO,CAAC,YAAD,CAAP,GAAwB,EAAlD,CAAhB;AAEAC,EAAAA,OAAO,CAACU,IAAR,CAAa;AACTJ,IAAAA,KAAK,EAAEF;AADE,GAAb;AAGH","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"]}
@@ -0,0 +1,6 @@
1
+ import { CloudFrontHeaders } from "./types";
2
+ export declare function setHeader(headers: CloudFrontHeaders, header: {
3
+ key: string;
4
+ value: string;
5
+ }): void;
6
+ export declare function getHeader(headers: CloudFrontHeaders | undefined, header: string): string | undefined;
@@ -0,0 +1,8 @@
1
+ export function setHeader(headers, header) {
2
+ headers[header.key] = [header];
3
+ }
4
+ export function getHeader(headers, header) {
5
+ var _headers$header;
6
+
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
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["headers.ts"],"names":["setHeader","headers","header","key","getHeader","value"],"mappings":"AAEA,OAAO,SAASA,SAAT,CAAmBC,OAAnB,EAA+CC,MAA/C,EAAuF;AAC1FD,EAAAA,OAAO,CAACC,MAAM,CAACC,GAAR,CAAP,GAAsB,CAACD,MAAD,CAAtB;AACH;AAED,OAAO,SAASE,SAAT,CAAmBH,OAAnB,EAA2DC,MAA3D,EAA2E;AAAA;;AAC9E,SAAOD,OAAP,aAAOA,OAAP,0CAAOA,OAAO,CAAGC,MAAH,CAAd,oDAAO,gBAAoB,CAApB,EAAuBG,KAA9B;AACH","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"]}
@@ -0,0 +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";
@@ -0,0 +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";
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA","sourcesContent":["export * from \"./cookies\";\nexport * from \"./headers\";\nexport * from \"./redirect\";\nexport * from \"./request\";\nexport * from \"./response\";\nexport * from \"./types\";\nexport * from \"./utils\";\n"]}
@@ -0,0 +1,8 @@
1
+ import { CloudFrontResponse } from "./types";
2
+ interface RedirectParams {
3
+ url: string;
4
+ query?: string;
5
+ status?: number;
6
+ }
7
+ export declare function redirectResponse(params: RedirectParams): CloudFrontResponse;
8
+ export {};
@@ -0,0 +1,32 @@
1
+ import { setHeader } from "./headers";
2
+ export function redirectResponse(params) {
3
+ const query = params.query || "";
4
+ const permanent = params.status === 301;
5
+ const response = {
6
+ status: String(params.status || 302),
7
+ statusDescription: permanent ? "Moved permanently" : "Found",
8
+ headers: {}
9
+ };
10
+ setHeader(response.headers, {
11
+ key: "location",
12
+ value: params.url + query
13
+ });
14
+
15
+ if (!permanent) {
16
+ // for temporary redirects make sure they won't be cached
17
+ setHeader(response.headers, {
18
+ key: "cache-control",
19
+ value: "no-cache, no-store, must-revalidate"
20
+ });
21
+ setHeader(response.headers, {
22
+ key: "pragma",
23
+ value: "no-cache"
24
+ });
25
+ setHeader(response.headers, {
26
+ key: "expires",
27
+ value: "0"
28
+ });
29
+ }
30
+
31
+ return response;
32
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["redirect.ts"],"names":["setHeader","redirectResponse","params","query","permanent","status","response","String","statusDescription","headers","key","value","url"],"mappings":"AACA,SAASA,SAAT;AAQA,OAAO,SAASC,gBAAT,CAA0BC,MAA1B,EAAsE;AACzE,QAAMC,KAAK,GAAGD,MAAM,CAACC,KAAP,IAAgB,EAA9B;AACA,QAAMC,SAAS,GAAGF,MAAM,CAACG,MAAP,KAAkB,GAApC;AAEA,QAAMC,QAA4B,GAAG;AACjCD,IAAAA,MAAM,EAAEE,MAAM,CAACL,MAAM,CAACG,MAAP,IAAiB,GAAlB,CADmB;AAEjCG,IAAAA,iBAAiB,EAAEJ,SAAS,GAAG,mBAAH,GAAyB,OAFpB;AAGjCK,IAAAA,OAAO,EAAE;AAHwB,GAArC;AAMAT,EAAAA,SAAS,CAACM,QAAQ,CAACG,OAAV,EAAmB;AACxBC,IAAAA,GAAG,EAAE,UADmB;AAExBC,IAAAA,KAAK,EAAET,MAAM,CAACU,GAAP,GAAaT;AAFI,GAAnB,CAAT;;AAKA,MAAI,CAACC,SAAL,EAAgB;AACZ;AACAJ,IAAAA,SAAS,CAACM,QAAQ,CAACG,OAAV,EAAmB;AACxBC,MAAAA,GAAG,EAAE,eADmB;AAExBC,MAAAA,KAAK,EAAE;AAFiB,KAAnB,CAAT;AAIAX,IAAAA,SAAS,CAACM,QAAQ,CAACG,OAAV,EAAmB;AACxBC,MAAAA,GAAG,EAAE,QADmB;AAExBC,MAAAA,KAAK,EAAE;AAFiB,KAAnB,CAAT;AAIAX,IAAAA,SAAS,CAACM,QAAQ,CAACG,OAAV,EAAmB;AACxBC,MAAAA,GAAG,EAAE,SADmB;AAExBC,MAAAA,KAAK,EAAE;AAFiB,KAAnB,CAAT;AAIH;;AAED,SAAOL,QAAP;AACH","sourcesContent":["import { CloudFrontResponse } from \"./types\";\nimport { setHeader } from \"./headers\";\n\ninterface RedirectParams {\n url: string;\n query?: string;\n status?: number;\n}\n\nexport function redirectResponse(params: RedirectParams): CloudFrontResponse {\n const query = params.query || \"\";\n const permanent = params.status === 301;\n\n const response: CloudFrontResponse = {\n status: String(params.status || 302),\n statusDescription: permanent ? \"Moved permanently\" : \"Found\",\n headers: {}\n };\n\n setHeader(response.headers, {\n key: \"location\",\n value: params.url + query\n });\n\n if (!permanent) {\n // for temporary redirects make sure they won't be cached\n setHeader(response.headers, {\n key: \"cache-control\",\n value: \"no-cache, no-store, must-revalidate\"\n });\n setHeader(response.headers, {\n key: \"pragma\",\n value: \"no-cache\"\n });\n setHeader(response.headers, {\n key: \"expires\",\n value: \"0\"\n });\n }\n\n return response;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { CloudFrontRequest } from "./types";
2
+ export declare function setDomainOrigin(request: CloudFrontRequest, domain: string): void;
@@ -0,0 +1,19 @@
1
+ import { setHeader } from "./headers";
2
+ export function setDomainOrigin(request, domain) {
3
+ request.origin = {
4
+ custom: {
5
+ domainName: domain,
6
+ port: 443,
7
+ protocol: "https",
8
+ path: "",
9
+ sslProtocols: ["TLSv1", "TLSv1.1", "TLSv1.2"],
10
+ readTimeout: 5,
11
+ keepaliveTimeout: 5,
12
+ customHeaders: {}
13
+ }
14
+ };
15
+ setHeader(request.headers, {
16
+ key: "host",
17
+ value: domain
18
+ });
19
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["request.ts"],"names":["setHeader","setDomainOrigin","request","domain","origin","custom","domainName","port","protocol","path","sslProtocols","readTimeout","keepaliveTimeout","customHeaders","headers","key","value"],"mappings":"AAAA,SAASA,SAAT;AAGA,OAAO,SAASC,eAAT,CAAyBC,OAAzB,EAAqDC,MAArD,EAAqE;AACxED,EAAAA,OAAO,CAACE,MAAR,GAAiB;AACbC,IAAAA,MAAM,EAAE;AACJC,MAAAA,UAAU,EAAEH,MADR;AAEJI,MAAAA,IAAI,EAAE,GAFF;AAGJC,MAAAA,QAAQ,EAAE,OAHN;AAIJC,MAAAA,IAAI,EAAE,EAJF;AAKJC,MAAAA,YAAY,EAAE,CAAC,OAAD,EAAU,SAAV,EAAqB,SAArB,CALV;AAMJC,MAAAA,WAAW,EAAE,CANT;AAOJC,MAAAA,gBAAgB,EAAE,CAPd;AAQJC,MAAAA,aAAa,EAAE;AARX;AADK,GAAjB;AAaAb,EAAAA,SAAS,CAACE,OAAO,CAACY,OAAT,EAAkB;AACvBC,IAAAA,GAAG,EAAE,MADkB;AAEvBC,IAAAA,KAAK,EAAEb;AAFgB,GAAlB,CAAT;AAIH","sourcesContent":["import { setHeader } from \"./headers\";\nimport { CloudFrontRequest } from \"./types\";\n\nexport function setDomainOrigin(request: CloudFrontRequest, domain: string) {\n request.origin = {\n custom: {\n domainName: domain,\n port: 443,\n protocol: \"https\",\n path: \"\",\n sslProtocols: [\"TLSv1\", \"TLSv1.1\", \"TLSv1.2\"],\n readTimeout: 5,\n keepaliveTimeout: 5,\n customHeaders: {}\n }\n };\n\n setHeader(request.headers, {\n key: \"host\",\n value: domain\n });\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { CloudFrontResultResponse } from "./types";
2
+ export declare function notFoundResponse(message?: string): CloudFrontResultResponse;
@@ -0,0 +1,7 @@
1
+ export function notFoundResponse(message) {
2
+ return {
3
+ status: "404",
4
+ statusDescription: "Not found",
5
+ body: message || "Not found"
6
+ };
7
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["response.ts"],"names":["notFoundResponse","message","status","statusDescription","body"],"mappings":"AAEA,OAAO,SAASA,gBAAT,CAA0BC,OAA1B,EAAsE;AACzE,SAAO;AACHC,IAAAA,MAAM,EAAE,KADL;AAEHC,IAAAA,iBAAiB,EAAE,WAFhB;AAGHC,IAAAA,IAAI,EAAEH,OAAO,IAAI;AAHd,GAAP;AAKH","sourcesContent":["import { CloudFrontResultResponse } from \"./types\";\n\nexport function notFoundResponse(message?: string): CloudFrontResultResponse {\n return {\n status: \"404\",\n statusDescription: \"Not found\",\n body: message || \"Not found\"\n };\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import * as awsLambda from "aws-lambda";
2
+ export declare type CloudFrontEvent = awsLambda.CloudFrontEvent;
3
+ export declare type CloudFrontRequest = awsLambda.CloudFrontRequest;
4
+ export declare type CloudFrontRequestEvent = awsLambda.CloudFrontRequestEvent;
5
+ export declare type CloudFrontResponse = awsLambda.CloudFrontResponse & {
6
+ body?: string;
7
+ };
8
+ export declare type CloudFrontResponseEvent = awsLambda.CloudFrontResponseEvent;
9
+ export declare type CloudFrontResultResponse = awsLambda.CloudFrontResultResponse;
10
+ export declare type CloudFrontHeaders = awsLambda.CloudFrontHeaders;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -0,0 +1,3 @@
1
+ import { CloudFrontRequestHandler, CloudFrontResponseHandler } from "aws-lambda";
2
+ export declare function defineLambdaEdgeRequestHandler(handler: CloudFrontRequestHandler): CloudFrontRequestHandler;
3
+ export declare function defineLambdaEdgeResponseHandler(handler: CloudFrontResponseHandler): CloudFrontResponseHandler;
@@ -0,0 +1,6 @@
1
+ export function defineLambdaEdgeRequestHandler(handler) {
2
+ return handler;
3
+ }
4
+ export function defineLambdaEdgeResponseHandler(handler) {
5
+ return handler;
6
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils.ts"],"names":["defineLambdaEdgeRequestHandler","handler","defineLambdaEdgeResponseHandler"],"mappings":"AAEA,OAAO,SAASA,8BAAT,CAAwCC,OAAxC,EAA2E;AAC9E,SAAOA,OAAP;AACH;AAED,OAAO,SAASC,+BAAT,CAAyCD,OAAzC,EAA6E;AAChF,SAAOA,OAAP;AACH","sourcesContent":["import { CloudFrontRequestHandler, CloudFrontResponseHandler } from \"aws-lambda\";\n\nexport function defineLambdaEdgeRequestHandler(handler: CloudFrontRequestHandler) {\n return handler;\n}\n\nexport function defineLambdaEdgeResponseHandler(handler: CloudFrontResponseHandler) {\n return handler;\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@webiny/aws-helpers",
3
+ "version": "5.26.1-beta.0",
4
+ "types": "dist/index.d.ts",
5
+ "exports": {
6
+ ".": {
7
+ "import": "./dist/index.js"
8
+ },
9
+ "./stagedRollouts/*": {
10
+ "import": "./dist/stagedRollouts/*.js"
11
+ }
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/webiny/webiny-js.git",
16
+ "directory": "packages/aws-helpers"
17
+ },
18
+ "author": "Webiny Ltd.",
19
+ "contributors": [
20
+ "Michał Kędrzyński <michal@webiny.com>"
21
+ ],
22
+ "description": "An utility package for developing AWS based services",
23
+ "license": "MIT",
24
+ "publishConfig": {
25
+ "access": "public",
26
+ "directory": "dist"
27
+ },
28
+ "gitHead": "d85df0d292bfd4ee2422cbb59de18ee8899df076",
29
+ "dependencies": {
30
+ "@types/aws-lambda": "8.10.93",
31
+ "cheerio": "1.0.0-rc.10",
32
+ "srcset": "4.0.0"
33
+ },
34
+ "devDependencies": {
35
+ "@webiny/project-utils": "^5.26.1-beta.0"
36
+ },
37
+ "sideEffects": false,
38
+ "adio": {
39
+ "ignore": {
40
+ "src": [
41
+ "aws-lambda"
42
+ ],
43
+ "dependencies": [
44
+ "@types/aws-lambda"
45
+ ]
46
+ }
47
+ }
48
+ }