@webiny/aws-helpers 6.3.0 → 6.4.0-beta.1

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 (57) hide show
  1. package/cloudfrontFunctions/cookies.js +15 -24
  2. package/cloudfrontFunctions/cookies.js.map +1 -1
  3. package/cloudfrontFunctions/headers.js +19 -20
  4. package/cloudfrontFunctions/headers.js.map +1 -1
  5. package/cloudfrontFunctions/index.js +0 -2
  6. package/cloudfrontFunctions/querystring.js +14 -24
  7. package/cloudfrontFunctions/querystring.js.map +1 -1
  8. package/cloudfrontFunctions/redirect.js +15 -17
  9. package/cloudfrontFunctions/redirect.js.map +1 -1
  10. package/cloudfrontFunctions/types.js +0 -3
  11. package/cloudfrontFunctions/utils.js +6 -19
  12. package/cloudfrontFunctions/utils.js.map +1 -1
  13. package/index.js +0 -2
  14. package/lambdaEdge/cookies.js +16 -17
  15. package/lambdaEdge/cookies.js.map +1 -1
  16. package/lambdaEdge/headers.js +7 -4
  17. package/lambdaEdge/headers.js.map +1 -1
  18. package/lambdaEdge/index.js +0 -2
  19. package/lambdaEdge/redirect.js +26 -26
  20. package/lambdaEdge/redirect.js.map +1 -1
  21. package/lambdaEdge/request.js +22 -17
  22. package/lambdaEdge/request.js.map +1 -1
  23. package/lambdaEdge/response.js +7 -6
  24. package/lambdaEdge/response.js.map +1 -1
  25. package/lambdaEdge/types.js +0 -3
  26. package/lambdaEdge/utils.js +5 -4
  27. package/lambdaEdge/utils.js.map +1 -1
  28. package/package.json +3 -3
  29. package/rslib-runtime.js +14 -0
  30. package/rslib-runtime.js.map +1 -0
  31. package/stagedRollouts/functions/adminOriginRequest.js +18 -22
  32. package/stagedRollouts/functions/adminOriginRequest.js.map +1 -1
  33. package/stagedRollouts/functions/configOriginRequest.js +44 -46
  34. package/stagedRollouts/functions/configOriginRequest.js.map +1 -1
  35. package/stagedRollouts/functions/originRequest.js +11 -10
  36. package/stagedRollouts/functions/originRequest.js.map +1 -1
  37. package/stagedRollouts/functions/viewerRequest.js +15 -35
  38. package/stagedRollouts/functions/viewerRequest.js.map +1 -1
  39. package/stagedRollouts/functions/viewerResponse.js +8 -10
  40. package/stagedRollouts/functions/viewerResponse.js.map +1 -1
  41. package/stagedRollouts/utils/common.js +5 -4
  42. package/stagedRollouts/utils/common.js.map +1 -1
  43. package/stagedRollouts/utils/headerBlacklist.js +27 -13
  44. package/stagedRollouts/utils/headerBlacklist.js.map +1 -1
  45. package/stagedRollouts/utils/loadOriginPage.js +70 -91
  46. package/stagedRollouts/utils/loadOriginPage.js.map +1 -1
  47. package/stagedRollouts/utils/loadTrafficSplittingConfig.js +35 -51
  48. package/stagedRollouts/utils/loadTrafficSplittingConfig.js.map +1 -1
  49. package/stagedRollouts/utils/loadVariantOrigin.js +41 -60
  50. package/stagedRollouts/utils/loadVariantOrigin.js.map +1 -1
  51. package/stagedRollouts/utils/log.js +3 -6
  52. package/stagedRollouts/utils/log.js.map +1 -1
  53. package/cloudfrontFunctions/index.js.map +0 -1
  54. package/cloudfrontFunctions/types.js.map +0 -1
  55. package/index.js.map +0 -1
  56. package/lambdaEdge/index.js.map +0 -1
  57. package/lambdaEdge/types.js.map +0 -1
@@ -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
- if (cookie.maxAge) {
7
- attrs += ` Max-Age=${cookie.maxAge};`;
8
- }
9
- if (current) {
10
- // If there is already the same cookie set in a response,
11
- // we add another entry using `multivalue`.
12
- // This is how you set multiple same cookies in CloudFront Functions.
13
- // It DOES make sense to set the same cookie multiple times,
14
- // for example when dealing with SameSite issue (https://web.dev/samesite-cookies-explained/)
15
- const multivalue = current.multivalue ?? (current.multivalue = []);
16
- multivalue.push({
17
- value: cookie.value,
18
- attributes: attrs
19
- });
20
- } else {
21
- cookies[cookie.name] = {
22
- value: cookie.value,
23
- 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
24
15
  };
25
- }
26
16
  }
17
+ export { setResponseCookie };
27
18
 
28
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 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"],"mappings":"AAQA;AACA,OAAO,SAASA,iBAAiBA,CAACC,QAA4B,EAAEC,MAAoB,EAAE;EAClF,MAAMC,OAAO,GAAGF,QAAQ,CAACE,OAAO,KAAKF,QAAQ,CAACE,OAAO,GAAG,CAAC,CAAC,CAAC;EAE3D,MAAMC,OAAO,GAAGD,OAAO,CAACD,MAAM,CAACG,IAAI,CAAC;EACpC,IAAIC,KAAK,GAAG,iBAAiB;EAE7B,IAAIJ,MAAM,CAACK,MAAM,EAAE;IACfD,KAAK,IAAI,YAAYJ,MAAM,CAACK,MAAM,GAAG;EACzC;EAEA,IAAIH,OAAO,EAAE;IACT;IACA;IACA;IACA;IACA;IACA,MAAMI,UAAU,GAAGJ,OAAO,CAACI,UAAU,KAAKJ,OAAO,CAACI,UAAU,GAAG,EAAE,CAAC;IAClEA,UAAU,CAACC,IAAI,CAAC;MACZC,KAAK,EAAER,MAAM,CAACQ,KAAK;MACnBC,UAAU,EAAEL;IAChB,CAAC,CAAC;EACN,CAAC,MAAM;IACHH,OAAO,CAACD,MAAM,CAACG,IAAI,CAAC,GAAG;MACnBK,KAAK,EAAER,MAAM,CAACQ,KAAK;MACnBC,UAAU,EAAEL;IAChB,CAAC;EACL;AACJ","ignoreList":[]}
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,26 +1,25 @@
1
- export function getHeader(headers, header) {
2
- return headers[header]?.value;
1
+ function getHeader(headers, header) {
2
+ return headers[header]?.value;
3
3
  }
4
- export function setHeader(headers, header) {
5
- headers[header.key] = {
6
- value: header.value
7
- };
4
+ function setHeader(headers, header) {
5
+ headers[header.key] = {
6
+ value: header.value
7
+ };
8
8
  }
9
- export function setHeaders(headers, headersToSet) {
10
- for (let i = 0; i < headersToSet.length; i++) {
11
- setHeader(headers, headersToSet[i]);
12
- }
9
+ function setHeaders(headers, headersToSet) {
10
+ for(let i = 0; i < headersToSet.length; i++)setHeader(headers, headersToSet[i]);
13
11
  }
14
- export function setNoCacheHeaders(headers) {
15
- headers["cache-control"] = {
16
- value: "no-cache, no-store, must-revalidate"
17
- };
18
- headers["pragma"] = {
19
- value: "no-cache"
20
- };
21
- headers["expires"] = {
22
- value: "0"
23
- };
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
+ };
24
22
  }
23
+ export { getHeader, setHeader, setHeaders, setNoCacheHeaders };
25
24
 
26
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 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"],"mappings":"AAEA,OAAO,SAASA,SAASA,CAACC,OAA0B,EAAEC,MAAc,EAAE;EAClE,OAAOD,OAAO,CAACC,MAAM,CAAC,EAAEC,KAAK;AACjC;AAEA,OAAO,SAASC,SAASA,CAACH,OAA0B,EAAEC,MAAc,EAAE;EAClED,OAAO,CAACC,MAAM,CAACG,GAAG,CAAC,GAAG;IAClBF,KAAK,EAAED,MAAM,CAACC;EAClB,CAAC;AACL;AAEA,OAAO,SAASG,UAAUA,CAACL,OAA0B,EAAEM,YAAsB,EAAE;EAC3E,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,YAAY,CAACE,MAAM,EAAED,CAAC,EAAE,EAAE;IAC1CJ,SAAS,CAACH,OAAO,EAAEM,YAAY,CAACC,CAAC,CAAC,CAAC;EACvC;AACJ;AAEA,OAAO,SAASE,iBAAiBA,CAACT,OAA0B,EAAE;EAC1DA,OAAO,CAAC,eAAe,CAAC,GAAG;IAAEE,KAAK,EAAE;EAAsC,CAAC;EAC3EF,OAAO,CAAC,QAAQ,CAAC,GAAG;IAAEE,KAAK,EAAE;EAAW,CAAC;EACzCF,OAAO,CAAC,SAAS,CAAC,GAAG;IAAEE,KAAK,EAAE;EAAI,CAAC;AACvC","ignoreList":[]}
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"}
@@ -4,5 +4,3 @@ export * from "./querystring.js";
4
4
  export * from "./redirect.js";
5
5
  export * from "./types.js";
6
6
  export * from "./utils.js";
7
-
8
- //# sourceMappingURL=index.js.map
@@ -1,31 +1,21 @@
1
- export function stringifyQuery(query) {
2
- let qs = "";
3
- for (const key of Object.keys(query)) {
4
- const value = query[key];
5
- if (!value) {
6
- continue;
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
+ }
7
9
  }
8
- qs = appendQueryString(qs, key, value?.value);
9
- if (value.multivalue) {
10
- for (let i = 0; i < value.multivalue.length; i++) {
11
- qs = appendQueryString(qs, key, value.multivalue[i].value);
12
- }
13
- }
14
- }
15
- if (qs) {
16
- qs = "?" + qs;
17
- }
18
- return qs;
10
+ if (qs) qs = "?" + qs;
11
+ return qs;
19
12
  }
20
13
  function appendQueryString(qs, key, value) {
21
- if (value === null) {
14
+ if (null === value) return qs;
15
+ if (qs.length) qs += "&";
16
+ qs += `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
22
17
  return qs;
23
- }
24
- if (qs.length) {
25
- qs += "&";
26
- }
27
- qs += `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
28
- return qs;
29
18
  }
19
+ export { stringifyQuery };
30
20
 
31
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 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"],"mappings":"AAEA,OAAO,SAASA,cAAcA,CAACC,KAAsB,EAAE;EACnD,IAAIC,EAAE,GAAG,EAAE;EAEX,KAAK,MAAMC,GAAG,IAAIC,MAAM,CAACC,IAAI,CAACJ,KAAK,CAAC,EAAE;IAClC,MAAMK,KAAK,GAAGL,KAAK,CAACE,GAAG,CAAC;IACxB,IAAI,CAACG,KAAK,EAAE;MACR;IACJ;IAEAJ,EAAE,GAAGK,iBAAiB,CAACL,EAAE,EAAEC,GAAG,EAAEG,KAAK,EAAEA,KAAK,CAAC;IAE7C,IAAIA,KAAK,CAACE,UAAU,EAAE;MAClB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,KAAK,CAACE,UAAU,CAACE,MAAM,EAAED,CAAC,EAAE,EAAE;QAC9CP,EAAE,GAAGK,iBAAiB,CAACL,EAAE,EAAEC,GAAG,EAAEG,KAAK,CAACE,UAAU,CAACC,CAAC,CAAC,CAACH,KAAK,CAAC;MAC9D;IACJ;EACJ;EAEA,IAAIJ,EAAE,EAAE;IACJA,EAAE,GAAG,GAAG,GAAGA,EAAE;EACjB;EAEA,OAAOA,EAAE;AACb;AAEA,SAASK,iBAAiBA,CAACL,EAAU,EAAEC,GAAW,EAAEG,KAAoB,EAAE;EACtE,IAAIA,KAAK,KAAK,IAAI,EAAE;IAChB,OAAOJ,EAAE;EACb;EAEA,IAAIA,EAAE,CAACQ,MAAM,EAAE;IACXR,EAAE,IAAI,GAAG;EACb;EAEAA,EAAE,IAAI,GAAGS,kBAAkB,CAACR,GAAG,CAAC,IAAIQ,kBAAkB,CAACL,KAAK,CAAC,EAAE;EAE/D,OAAOJ,EAAE;AACb","ignoreList":[]}
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,22 +1,20 @@
1
1
  import { setNoCacheHeaders } from "./headers.js";
2
2
  import { stringifyQuery } from "./querystring.js";
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
- if (!permanent) {
16
- // For temporary redirects make sure they won't be cached.
17
- setNoCacheHeaders(response.headers);
18
- }
19
- return response;
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;
20
17
  }
18
+ export { redirectResponse };
21
19
 
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 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"],"mappings":"AACA,SAASA,iBAAiB;AAC1B,SAASC,cAAc;AAQvB,OAAO,SAASC,gBAAgBA,CAACC,MAAsB,EAAE;EACrD,MAAMC,KAAK,GAAGD,MAAM,CAACC,KAAK,GAAGH,cAAc,CAACE,MAAM,CAACC,KAAK,CAAC,GAAG,EAAE;EAC9D,MAAMC,SAAS,GAAGF,MAAM,CAACG,MAAM,KAAK,GAAG;EAEvC,MAAMC,QAA4B,GAAG;IACjCC,UAAU,EAAEL,MAAM,CAACG,MAAM,IAAI,GAAG;IAChCG,iBAAiB,EAAEN,MAAM,CAACG,MAAM,KAAK,GAAG,GAAG,mBAAmB,GAAG,OAAO;IACxEI,OAAO,EAAE;MACLC,QAAQ,EAAE;QAAEC,KAAK,EAAET,MAAM,CAACU,GAAG,GAAGT;MAAM;IAC1C;EACJ,CAAC;EAED,IAAI,CAACC,SAAS,EAAE;IACZ;IACAL,iBAAiB,CAACO,QAAQ,CAACG,OAAO,CAAC;EACvC;EAEA,OAAOH,QAAQ;AACnB","ignoreList":[]}
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"}
@@ -1,3 +0,0 @@
1
- export {};
2
-
3
- //# sourceMappingURL=types.js.map
@@ -1,23 +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
- /**
13
- * Helper function to easier define CloudFront Function response handler.
14
- *
15
- * Lambdas use exports, but CloudFront Functions use a global `handler` variable.
16
- * This way you only have to run the function within your handler script,
17
- * and you are provided with working handler and full typing.
18
- **/
19
- export function defineCloudfrontFunctionResponseHandler(handler) {
20
- global.handler = handler;
5
+ function defineCloudfrontFunctionResponseHandler(handler) {
6
+ __webpack_require__.g.handler = handler;
21
7
  }
8
+ export { defineCloudfrontFunctionRequestHandler, defineCloudfrontFunctionResponseHandler };
22
9
 
23
10
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["defineCloudfrontFunctionRequestHandler","handler","global","defineCloudfrontFunctionResponseHandler"],"sources":["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"],"mappings":"AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,sCAAsCA,CAACC,OAAiC,EAAE;EACtFC,MAAM,CAACD,OAAO,GAAGA,OAAO;AAC5B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,uCAAuCA,CAACF,OAAkC,EAAE;EACxFC,MAAM,CAACD,OAAO,GAAGA,OAAO;AAC5B","ignoreList":[]}
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.js CHANGED
@@ -1,3 +1 @@
1
1
  export * from "./lambdaEdge/index.js";
2
-
3
- //# sourceMappingURL=index.js.map
@@ -1,23 +1,22 @@
1
1
  import { getHeader } from "./headers.js";
2
- export function getRequestCookies(request) {
3
- const header = getHeader(request.headers, "cookie");
4
- const cookies = {};
5
- if (!header) {
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
+ }
6
11
  return cookies;
7
- }
8
- const cookiesArray = decodeURIComponent(header).split(";");
9
- for (const cookie of cookiesArray) {
10
- const [name, value] = cookie.trim().split("=");
11
- cookies[name] = value;
12
- }
13
- return cookies;
14
12
  }
15
- export function setResponseCookie(response, cookie) {
16
- const headers = response.headers;
17
- const cookies = headers["set-cookie"] || (headers["set-cookie"] = []);
18
- cookies.push({
19
- value: cookie
20
- });
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
+ });
21
19
  }
20
+ export { getRequestCookies, setResponseCookie };
22
21
 
23
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.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"],"mappings":"AAAA,SAASA,SAAS;AAGlB,OAAO,SAASC,iBAAiBA,CAACC,OAA0B,EAAE;EAC1D,MAAMC,MAAM,GAAGH,SAAS,CAACE,OAAO,CAACE,OAAO,EAAE,QAAQ,CAAC;EACnD,MAAMC,OAA2C,GAAG,CAAC,CAAC;EAEtD,IAAI,CAACF,MAAM,EAAE;IACT,OAAOE,OAAO;EAClB;EAEA,MAAMC,YAAY,GAAGC,kBAAkB,CAACJ,MAAM,CAAC,CAACK,KAAK,CAAC,GAAG,CAAC;EAE1D,KAAK,MAAMC,MAAM,IAAIH,YAAY,EAAE;IAC/B,MAAM,CAACI,IAAI,EAAEC,KAAK,CAAC,GAAGF,MAAM,CAACG,IAAI,CAAC,CAAC,CAACJ,KAAK,CAAC,GAAG,CAAC;IAC9CH,OAAO,CAACK,IAAI,CAAC,GAAGC,KAAK;EACzB;EAEA,OAAON,OAAO;AAClB;AAEA,OAAO,SAASQ,iBAAiBA,CAACC,QAA4B,EAAEL,MAAc,EAAE;EAC5E,MAAML,OAAO,GAAGU,QAAQ,CAACV,OAAO;EAChC,MAAMC,OAAO,GAAGD,OAAO,CAAC,YAAY,CAAC,KAAKA,OAAO,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC;EAErEC,OAAO,CAACU,IAAI,CAAC;IACTJ,KAAK,EAAEF;EACX,CAAC,CAAC;AACN","ignoreList":[]}
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,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
- return headers?.[header]?.[0].value;
6
+ function getHeader(headers, header) {
7
+ return headers?.[header]?.[0].value;
6
8
  }
9
+ export { getHeader, setHeader };
7
10
 
8
11
  //# sourceMappingURL=headers.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["setHeader","headers","header","key","getHeader","value"],"sources":["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"],"mappings":"AAEA,OAAO,SAASA,SAASA,CAACC,OAA0B,EAAEC,MAAsC,EAAE;EAC1FD,OAAO,CAACC,MAAM,CAACC,GAAG,CAAC,GAAG,CAACD,MAAM,CAAC;AAClC;AAEA,OAAO,SAASE,SAASA,CAACH,OAAsC,EAAEC,MAAc,EAAE;EAC9E,OAAOD,OAAO,GAAGC,MAAM,CAAC,GAAG,CAAC,CAAC,CAACG,KAAK;AACvC","ignoreList":[]}
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"}
@@ -5,5 +5,3 @@ export * from "./request.js";
5
5
  export * from "./response.js";
6
6
  export * from "./types.js";
7
7
  export * from "./utils.js";
8
-
9
- //# sourceMappingURL=index.js.map
@@ -1,32 +1,32 @@
1
1
  import { setHeader } from "./headers.js";
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
- if (!permanent) {
15
- // for temporary redirects make sure they won't be cached
2
+ function redirectResponse(params) {
3
+ const query = params.query || "";
4
+ const permanent = 301 === params.status;
5
+ const response = {
6
+ status: String(params.status || 302),
7
+ statusDescription: permanent ? "Moved permanently" : "Found",
8
+ headers: {}
9
+ };
16
10
  setHeader(response.headers, {
17
- key: "cache-control",
18
- value: "no-cache, no-store, must-revalidate"
11
+ key: "location",
12
+ value: params.url + query
19
13
  });
20
- setHeader(response.headers, {
21
- key: "pragma",
22
- value: "no-cache"
23
- });
24
- setHeader(response.headers, {
25
- key: "expires",
26
- value: "0"
27
- });
28
- }
29
- return response;
14
+ if (!permanent) {
15
+ setHeader(response.headers, {
16
+ key: "cache-control",
17
+ value: "no-cache, no-store, must-revalidate"
18
+ });
19
+ setHeader(response.headers, {
20
+ key: "pragma",
21
+ value: "no-cache"
22
+ });
23
+ setHeader(response.headers, {
24
+ key: "expires",
25
+ value: "0"
26
+ });
27
+ }
28
+ return response;
30
29
  }
30
+ export { redirectResponse };
31
31
 
32
32
  //# sourceMappingURL=redirect.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["setHeader","redirectResponse","params","query","permanent","status","response","String","statusDescription","headers","key","value","url"],"sources":["redirect.ts"],"sourcesContent":["import type { CloudFrontResponse } from \"./types.js\";\nimport { setHeader } from \"./headers.js\";\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"],"mappings":"AACA,SAASA,SAAS;AAQlB,OAAO,SAASC,gBAAgBA,CAACC,MAAsB,EAAsB;EACzE,MAAMC,KAAK,GAAGD,MAAM,CAACC,KAAK,IAAI,EAAE;EAChC,MAAMC,SAAS,GAAGF,MAAM,CAACG,MAAM,KAAK,GAAG;EAEvC,MAAMC,QAA4B,GAAG;IACjCD,MAAM,EAAEE,MAAM,CAACL,MAAM,CAACG,MAAM,IAAI,GAAG,CAAC;IACpCG,iBAAiB,EAAEJ,SAAS,GAAG,mBAAmB,GAAG,OAAO;IAC5DK,OAAO,EAAE,CAAC;EACd,CAAC;EAEDT,SAAS,CAACM,QAAQ,CAACG,OAAO,EAAE;IACxBC,GAAG,EAAE,UAAU;IACfC,KAAK,EAAET,MAAM,CAACU,GAAG,GAAGT;EACxB,CAAC,CAAC;EAEF,IAAI,CAACC,SAAS,EAAE;IACZ;IACAJ,SAAS,CAACM,QAAQ,CAACG,OAAO,EAAE;MACxBC,GAAG,EAAE,eAAe;MACpBC,KAAK,EAAE;IACX,CAAC,CAAC;IACFX,SAAS,CAACM,QAAQ,CAACG,OAAO,EAAE;MACxBC,GAAG,EAAE,QAAQ;MACbC,KAAK,EAAE;IACX,CAAC,CAAC;IACFX,SAAS,CAACM,QAAQ,CAACG,OAAO,EAAE;MACxBC,GAAG,EAAE,SAAS;MACdC,KAAK,EAAE;IACX,CAAC,CAAC;EACN;EAEA,OAAOL,QAAQ;AACnB","ignoreList":[]}
1
+ {"version":3,"file":"lambdaEdge/redirect.js","sources":["../../src/lambdaEdge/redirect.ts"],"sourcesContent":["import type { CloudFrontResponse } from \"./types.js\";\nimport { setHeader } from \"./headers.js\";\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"],"names":["redirectResponse","params","query","permanent","response","String","setHeader"],"mappings":";AASO,SAASA,iBAAiBC,MAAsB;IACnD,MAAMC,QAAQD,OAAO,KAAK,IAAI;IAC9B,MAAME,YAAYF,AAAkB,QAAlBA,OAAO,MAAM;IAE/B,MAAMG,WAA+B;QACjC,QAAQC,OAAOJ,OAAO,MAAM,IAAI;QAChC,mBAAmBE,YAAY,sBAAsB;QACrD,SAAS,CAAC;IACd;IAEAG,UAAUF,SAAS,OAAO,EAAE;QACxB,KAAK;QACL,OAAOH,OAAO,GAAG,GAAGC;IACxB;IAEA,IAAI,CAACC,WAAW;QAEZG,UAAUF,SAAS,OAAO,EAAE;YACxB,KAAK;YACL,OAAO;QACX;QACAE,UAAUF,SAAS,OAAO,EAAE;YACxB,KAAK;YACL,OAAO;QACX;QACAE,UAAUF,SAAS,OAAO,EAAE;YACxB,KAAK;YACL,OAAO;QACX;IACJ;IAEA,OAAOA;AACX"}
@@ -1,21 +1,26 @@
1
1
  import { setHeader } from "./headers.js";
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
- });
2
+ function setDomainOrigin(request, domain) {
3
+ request.origin = {
4
+ custom: {
5
+ domainName: domain,
6
+ port: 443,
7
+ protocol: "https",
8
+ path: "",
9
+ sslProtocols: [
10
+ "TLSv1",
11
+ "TLSv1.1",
12
+ "TLSv1.2"
13
+ ],
14
+ readTimeout: 5,
15
+ keepaliveTimeout: 5,
16
+ customHeaders: {}
17
+ }
18
+ };
19
+ setHeader(request.headers, {
20
+ key: "host",
21
+ value: domain
22
+ });
19
23
  }
24
+ export { setDomainOrigin };
20
25
 
21
26
  //# sourceMappingURL=request.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["setHeader","setDomainOrigin","request","domain","origin","custom","domainName","port","protocol","path","sslProtocols","readTimeout","keepaliveTimeout","customHeaders","headers","key","value"],"sources":["request.ts"],"sourcesContent":["import { setHeader } from \"./headers.js\";\nimport type { CloudFrontRequest } from \"./types.js\";\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"],"mappings":"AAAA,SAASA,SAAS;AAGlB,OAAO,SAASC,eAAeA,CAACC,OAA0B,EAAEC,MAAc,EAAE;EACxED,OAAO,CAACE,MAAM,GAAG;IACbC,MAAM,EAAE;MACJC,UAAU,EAAEH,MAAM;MAClBI,IAAI,EAAE,GAAG;MACTC,QAAQ,EAAE,OAAO;MACjBC,IAAI,EAAE,EAAE;MACRC,YAAY,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC;MAC7CC,WAAW,EAAE,CAAC;MACdC,gBAAgB,EAAE,CAAC;MACnBC,aAAa,EAAE,CAAC;IACpB;EACJ,CAAC;EAEDb,SAAS,CAACE,OAAO,CAACY,OAAO,EAAE;IACvBC,GAAG,EAAE,MAAM;IACXC,KAAK,EAAEb;EACX,CAAC,CAAC;AACN","ignoreList":[]}
1
+ {"version":3,"file":"lambdaEdge/request.js","sources":["../../src/lambdaEdge/request.ts"],"sourcesContent":["import { setHeader } from \"./headers.js\";\nimport type { CloudFrontRequest } from \"./types.js\";\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"],"names":["setDomainOrigin","request","domain","setHeader"],"mappings":";AAGO,SAASA,gBAAgBC,OAA0B,EAAEC,MAAc;IACtED,QAAQ,MAAM,GAAG;QACb,QAAQ;YACJ,YAAYC;YACZ,MAAM;YACN,UAAU;YACV,MAAM;YACN,cAAc;gBAAC;gBAAS;gBAAW;aAAU;YAC7C,aAAa;YACb,kBAAkB;YAClB,eAAe,CAAC;QACpB;IACJ;IAEAC,UAAUF,QAAQ,OAAO,EAAE;QACvB,KAAK;QACL,OAAOC;IACX;AACJ"}
@@ -1,9 +1,10 @@
1
- export function notFoundResponse(message) {
2
- return {
3
- status: "404",
4
- statusDescription: "Not found",
5
- body: message || "Not found"
6
- };
1
+ function notFoundResponse(message) {
2
+ return {
3
+ status: "404",
4
+ statusDescription: "Not found",
5
+ body: message || "Not found"
6
+ };
7
7
  }
8
+ export { notFoundResponse };
8
9
 
9
10
  //# sourceMappingURL=response.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["notFoundResponse","message","status","statusDescription","body"],"sources":["response.ts"],"sourcesContent":["import type { CloudFrontResultResponse } from \"./types.js\";\n\nexport function notFoundResponse(message?: string): CloudFrontResultResponse {\n return {\n status: \"404\",\n statusDescription: \"Not found\",\n body: message || \"Not found\"\n };\n}\n"],"mappings":"AAEA,OAAO,SAASA,gBAAgBA,CAACC,OAAgB,EAA4B;EACzE,OAAO;IACHC,MAAM,EAAE,KAAK;IACbC,iBAAiB,EAAE,WAAW;IAC9BC,IAAI,EAAEH,OAAO,IAAI;EACrB,CAAC;AACL","ignoreList":[]}
1
+ {"version":3,"file":"lambdaEdge/response.js","sources":["../../src/lambdaEdge/response.ts"],"sourcesContent":["import type { CloudFrontResultResponse } from \"./types.js\";\n\nexport function notFoundResponse(message?: string): CloudFrontResultResponse {\n return {\n status: \"404\",\n statusDescription: \"Not found\",\n body: message || \"Not found\"\n };\n}\n"],"names":["notFoundResponse","message"],"mappings":"AAEO,SAASA,iBAAiBC,OAAgB;IAC7C,OAAO;QACH,QAAQ;QACR,mBAAmB;QACnB,MAAMA,WAAW;IACrB;AACJ"}
@@ -1,3 +0,0 @@
1
- export {};
2
-
3
- //# sourceMappingURL=types.js.map
@@ -1,8 +1,9 @@
1
- export function defineLambdaEdgeRequestHandler(handler) {
2
- return handler;
1
+ function defineLambdaEdgeRequestHandler(handler) {
2
+ return handler;
3
3
  }
4
- export function defineLambdaEdgeResponseHandler(handler) {
5
- return handler;
4
+ function defineLambdaEdgeResponseHandler(handler) {
5
+ return handler;
6
6
  }
7
+ export { defineLambdaEdgeRequestHandler, defineLambdaEdgeResponseHandler };
7
8
 
8
9
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["defineLambdaEdgeRequestHandler","handler","defineLambdaEdgeResponseHandler"],"sources":["utils.ts"],"sourcesContent":["import type { 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"],"mappings":"AAEA,OAAO,SAASA,8BAA8BA,CAACC,OAAiC,EAAE;EAC9E,OAAOA,OAAO;AAClB;AAEA,OAAO,SAASC,+BAA+BA,CAACD,OAAkC,EAAE;EAChF,OAAOA,OAAO;AAClB","ignoreList":[]}
1
+ {"version":3,"file":"lambdaEdge/utils.js","sources":["../../src/lambdaEdge/utils.ts"],"sourcesContent":["import type { 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"],"names":["defineLambdaEdgeRequestHandler","handler","defineLambdaEdgeResponseHandler"],"mappings":"AAEO,SAASA,+BAA+BC,OAAiC;IAC5E,OAAOA;AACX;AAEO,SAASC,gCAAgCD,OAAkC;IAC9E,OAAOA;AACX"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/aws-helpers",
3
- "version": "6.3.0",
3
+ "version": "6.4.0-beta.1",
4
4
  "type": "module",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
@@ -26,14 +26,14 @@
26
26
  "access": "public",
27
27
  "directory": "dist"
28
28
  },
29
- "gitHead": "7cefe15431dbd65504e1f58147dc9e55bcbfa693",
29
+ "gitHead": "73237b8243693038c072bae1c0b783387448cbbe",
30
30
  "dependencies": {
31
31
  "@types/aws-lambda": "8.10.161",
32
32
  "cheerio": "1.2.0",
33
33
  "srcset": "5.0.3"
34
34
  },
35
35
  "devDependencies": {
36
- "@webiny/build-tools": "6.3.0"
36
+ "@webiny/build-tools": "6.4.0-beta.1"
37
37
  },
38
38
  "sideEffects": false,
39
39
  "adio": {
@@ -0,0 +1,14 @@
1
+ var __webpack_require__ = {};
2
+ (()=>{
3
+ __webpack_require__.g = (()=>{
4
+ if ('object' == typeof globalThis) return globalThis;
5
+ try {
6
+ return this || new Function('return this')();
7
+ } catch (e) {
8
+ if ('object' == typeof window) return window;
9
+ }
10
+ })();
11
+ })();
12
+ export { __webpack_require__ };
13
+
14
+ //# sourceMappingURL=rslib-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rslib-runtime.js","sources":["webpack://webpack/runtime/global"],"sourcesContent":["__webpack_require__.g = (() => {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();"],"names":["__webpack_require__","globalThis","Function","e","window"],"mappings":";;IAAAA,oBAAoB,CAAC,GAAG,AAAC;QACxB,IAAI,AAAsB,YAAtB,OAAOC,YAAyB,OAAOA;QAC3C,IAAI;YACH,OAAO,IAAI,IAAI,IAAIC,SAAS;QAC7B,EAAE,OAAOC,GAAG;YACX,IAAI,AAAkB,YAAlB,OAAOC,QAAqB,OAAOA;QACxC;IACD"}