@sitecore-cloudsdk/utils 0.1.0-rc.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.
- package/README.md +11 -0
- package/dist/cjs/src/index.d.ts +19 -0
- package/dist/cjs/src/index.js +30 -0
- package/dist/cjs/src/lib/converters/base-64-converter.d.ts +3 -0
- package/dist/cjs/src/lib/converters/base-64-converter.js +19 -0
- package/dist/cjs/src/lib/converters/flatten-object.d.ts +35 -0
- package/dist/cjs/src/lib/converters/flatten-object.js +35 -0
- package/dist/cjs/src/lib/cookies/consts.d.ts +1 -0
- package/dist/cjs/src/lib/cookies/consts.js +6 -0
- package/dist/cjs/src/lib/cookies/cookie-exists-in-server-side.d.ts +7 -0
- package/dist/cjs/src/lib/cookies/cookie-exists-in-server-side.js +15 -0
- package/dist/cjs/src/lib/cookies/cookie-exists.d.ts +7 -0
- package/dist/cjs/src/lib/cookies/cookie-exists.js +14 -0
- package/dist/cjs/src/lib/cookies/create-cookie-string.d.ts +9 -0
- package/dist/cjs/src/lib/cookies/create-cookie-string.js +21 -0
- package/dist/cjs/src/lib/cookies/delete-cookie.d.ts +5 -0
- package/dist/cjs/src/lib/cookies/delete-cookie.js +12 -0
- package/dist/cjs/src/lib/cookies/get-cookie-server-side.d.ts +10 -0
- package/dist/cjs/src/lib/cookies/get-cookie-server-side.js +15 -0
- package/dist/cjs/src/lib/cookies/get-cookie-value-client-side.d.ts +6 -0
- package/dist/cjs/src/lib/cookies/get-cookie-value-client-side.js +15 -0
- package/dist/cjs/src/lib/cookies/get-cookie.d.ts +10 -0
- package/dist/cjs/src/lib/cookies/get-cookie.js +19 -0
- package/dist/cjs/src/lib/cookies/interfaces.d.ts +19 -0
- package/dist/cjs/src/lib/cookies/interfaces.js +3 -0
- package/dist/cjs/src/lib/fetch-with-timeout.d.ts +12 -0
- package/dist/cjs/src/lib/fetch-with-timeout.js +34 -0
- package/dist/cjs/src/lib/interfaces.d.ts +48 -0
- package/dist/cjs/src/lib/interfaces.js +3 -0
- package/dist/cjs/src/lib/typeguards/is-http-request.d.ts +9 -0
- package/dist/cjs/src/lib/typeguards/is-http-request.js +15 -0
- package/dist/cjs/src/lib/typeguards/is-http-response.d.ts +9 -0
- package/dist/cjs/src/lib/typeguards/is-http-response.js +15 -0
- package/dist/cjs/src/lib/typeguards/is-next-js-middleware-request.d.ts +9 -0
- package/dist/cjs/src/lib/typeguards/is-next-js-middleware-request.js +15 -0
- package/dist/cjs/src/lib/typeguards/is-next-js-middleware-response.d.ts +9 -0
- package/dist/cjs/src/lib/typeguards/is-next-js-middleware-response.js +15 -0
- package/dist/cjs/src/lib/validators/is-iso-date-string.d.ts +1 -0
- package/dist/cjs/src/lib/validators/is-iso-date-string.js +14 -0
- package/dist/cjs/src/lib/validators/is-short-iso-date-string.d.ts +6 -0
- package/dist/cjs/src/lib/validators/is-short-iso-date-string.js +20 -0
- package/dist/cjs/src/lib/validators/is-valid-email.d.ts +6 -0
- package/dist/cjs/src/lib/validators/is-valid-email.js +14 -0
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/esm/src/index.d.ts +19 -0
- package/dist/esm/src/index.js +16 -0
- package/dist/esm/src/lib/converters/base-64-converter.d.ts +3 -0
- package/dist/esm/src/lib/converters/base-64-converter.js +15 -0
- package/dist/esm/src/lib/converters/flatten-object.d.ts +35 -0
- package/dist/esm/src/lib/converters/flatten-object.js +31 -0
- package/dist/esm/src/lib/cookies/consts.d.ts +1 -0
- package/dist/esm/src/lib/cookies/consts.js +3 -0
- package/dist/esm/src/lib/cookies/cookie-exists-in-server-side.d.ts +7 -0
- package/dist/esm/src/lib/cookies/cookie-exists-in-server-side.js +11 -0
- package/dist/esm/src/lib/cookies/cookie-exists.d.ts +7 -0
- package/dist/esm/src/lib/cookies/cookie-exists.js +10 -0
- package/dist/esm/src/lib/cookies/create-cookie-string.d.ts +9 -0
- package/dist/esm/src/lib/cookies/create-cookie-string.js +17 -0
- package/dist/esm/src/lib/cookies/delete-cookie.d.ts +5 -0
- package/dist/esm/src/lib/cookies/delete-cookie.js +8 -0
- package/dist/esm/src/lib/cookies/get-cookie-server-side.d.ts +10 -0
- package/dist/esm/src/lib/cookies/get-cookie-server-side.js +11 -0
- package/dist/esm/src/lib/cookies/get-cookie-value-client-side.d.ts +6 -0
- package/dist/esm/src/lib/cookies/get-cookie-value-client-side.js +11 -0
- package/dist/esm/src/lib/cookies/get-cookie.d.ts +10 -0
- package/dist/esm/src/lib/cookies/get-cookie.js +15 -0
- package/dist/esm/src/lib/cookies/interfaces.d.ts +19 -0
- package/dist/esm/src/lib/cookies/interfaces.js +2 -0
- package/dist/esm/src/lib/fetch-with-timeout.d.ts +12 -0
- package/dist/esm/src/lib/fetch-with-timeout.js +30 -0
- package/dist/esm/src/lib/interfaces.d.ts +48 -0
- package/dist/esm/src/lib/interfaces.js +2 -0
- package/dist/esm/src/lib/typeguards/is-http-request.d.ts +9 -0
- package/dist/esm/src/lib/typeguards/is-http-request.js +11 -0
- package/dist/esm/src/lib/typeguards/is-http-response.d.ts +9 -0
- package/dist/esm/src/lib/typeguards/is-http-response.js +11 -0
- package/dist/esm/src/lib/typeguards/is-next-js-middleware-request.d.ts +9 -0
- package/dist/esm/src/lib/typeguards/is-next-js-middleware-request.js +11 -0
- package/dist/esm/src/lib/typeguards/is-next-js-middleware-response.d.ts +9 -0
- package/dist/esm/src/lib/typeguards/is-next-js-middleware-response.js +11 -0
- package/dist/esm/src/lib/validators/is-iso-date-string.d.ts +1 -0
- package/dist/esm/src/lib/validators/is-iso-date-string.js +10 -0
- package/dist/esm/src/lib/validators/is-short-iso-date-string.d.ts +6 -0
- package/dist/esm/src/lib/validators/is-short-iso-date-string.js +16 -0
- package/dist/esm/src/lib/validators/is-valid-email.d.ts +6 -0
- package/dist/esm/src/lib/validators/is-valid-email.js +10 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -0
- package/package.json +27 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.isShortISODateString = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* Checks if the provided string is a shortened version of ISO 8601 date format ‘YYYY-MM-DD’T’hh:mm’
|
|
7
|
+
* @param date - The date string provided by the developer
|
|
8
|
+
* @returns - A boolean if the string is valid otherwise false
|
|
9
|
+
*/
|
|
10
|
+
function isShortISODateString(date) {
|
|
11
|
+
try {
|
|
12
|
+
const dateString = date + 'Z';
|
|
13
|
+
const convertedDate = new Date(dateString).toISOString().substring(0, 16);
|
|
14
|
+
return convertedDate === date;
|
|
15
|
+
}
|
|
16
|
+
catch (_) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.isShortISODateString = isShortISODateString;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isValidEmail = void 0;
|
|
4
|
+
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param email - the email string to be validated
|
|
8
|
+
* @returns - a boolean value depending on whether the email value passed is valid
|
|
9
|
+
*/
|
|
10
|
+
function isValidEmail(email) {
|
|
11
|
+
const regx = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
12
|
+
return regx.test(email);
|
|
13
|
+
}
|
|
14
|
+
exports.isValidEmail = isValidEmail;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"program":{"fileNames":["../../../../node_modules/typescript/lib/lib.es5.d.ts","../../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../../node_modules/typescript/lib/lib.dom.d.ts","../../../../node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../../node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../../../../node_modules/typescript/lib/lib.scripthost.d.ts","../../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../../node_modules/typescript/lib/lib.decorators.d.ts","../../../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../../node_modules/typescript/lib/lib.es2020.full.d.ts","../../src/lib/cookies/interfaces.ts","../../src/lib/cookies/create-cookie-string.ts","../../src/lib/fetch-with-timeout.ts","../../src/lib/cookies/get-cookie.ts","../../src/lib/cookies/get-cookie-value-client-side.ts","../../src/lib/interfaces.ts","../../src/lib/typeguards/is-next-js-middleware-request.ts","../../src/lib/typeguards/is-next-js-middleware-response.ts","../../src/lib/typeguards/is-http-request.ts","../../src/lib/typeguards/is-http-response.ts","../../src/lib/cookies/get-cookie-server-side.ts","../../src/lib/cookies/cookie-exists.ts","../../src/lib/converters/flatten-object.ts","../../src/lib/validators/is-short-iso-date-string.ts","../../src/lib/validators/is-valid-email.ts","../../src/index.ts","../../src/lib/converters/base-64-converter.ts","../../src/lib/cookies/consts.ts","../../src/lib/cookies/cookie-exists-in-server-side.ts","../../src/lib/cookies/delete-cookie.ts","../../src/lib/validators/is-iso-date-string.ts","../../../../node_modules/@jest/expect-utils/build/index.d.ts","../../../../node_modules/chalk/index.d.ts","../../../../node_modules/@sinclair/typebox/typebox.d.ts","../../../../node_modules/@jest/schemas/build/index.d.ts","../../../../node_modules/jest-diff/node_modules/pretty-format/build/index.d.ts","../../../../node_modules/jest-diff/build/index.d.ts","../../../../node_modules/jest-matcher-utils/build/index.d.ts","../../../../node_modules/expect/build/index.d.ts","../../../../node_modules/@types/jest/node_modules/pretty-format/build/index.d.ts","../../../../node_modules/@types/jest/index.d.ts","../../../../node_modules/@types/node/assert.d.ts","../../../../node_modules/@types/node/assert/strict.d.ts","../../../../node_modules/@types/node/globals.d.ts","../../../../node_modules/@types/node/async_hooks.d.ts","../../../../node_modules/@types/node/buffer.d.ts","../../../../node_modules/@types/node/child_process.d.ts","../../../../node_modules/@types/node/cluster.d.ts","../../../../node_modules/@types/node/console.d.ts","../../../../node_modules/@types/node/constants.d.ts","../../../../node_modules/@types/node/crypto.d.ts","../../../../node_modules/@types/node/dgram.d.ts","../../../../node_modules/@types/node/diagnostics_channel.d.ts","../../../../node_modules/@types/node/dns.d.ts","../../../../node_modules/@types/node/dns/promises.d.ts","../../../../node_modules/@types/node/domain.d.ts","../../../../node_modules/@types/node/dom-events.d.ts","../../../../node_modules/@types/node/events.d.ts","../../../../node_modules/@types/node/fs.d.ts","../../../../node_modules/@types/node/fs/promises.d.ts","../../../../node_modules/@types/node/http.d.ts","../../../../node_modules/@types/node/http2.d.ts","../../../../node_modules/@types/node/https.d.ts","../../../../node_modules/@types/node/inspector.d.ts","../../../../node_modules/@types/node/module.d.ts","../../../../node_modules/@types/node/net.d.ts","../../../../node_modules/@types/node/os.d.ts","../../../../node_modules/@types/node/path.d.ts","../../../../node_modules/@types/node/perf_hooks.d.ts","../../../../node_modules/@types/node/process.d.ts","../../../../node_modules/@types/node/punycode.d.ts","../../../../node_modules/@types/node/querystring.d.ts","../../../../node_modules/@types/node/readline.d.ts","../../../../node_modules/@types/node/readline/promises.d.ts","../../../../node_modules/@types/node/repl.d.ts","../../../../node_modules/@types/node/stream.d.ts","../../../../node_modules/@types/node/stream/promises.d.ts","../../../../node_modules/@types/node/stream/consumers.d.ts","../../../../node_modules/@types/node/stream/web.d.ts","../../../../node_modules/@types/node/string_decoder.d.ts","../../../../node_modules/@types/node/test.d.ts","../../../../node_modules/@types/node/timers.d.ts","../../../../node_modules/@types/node/timers/promises.d.ts","../../../../node_modules/@types/node/tls.d.ts","../../../../node_modules/@types/node/trace_events.d.ts","../../../../node_modules/@types/node/tty.d.ts","../../../../node_modules/@types/node/url.d.ts","../../../../node_modules/@types/node/util.d.ts","../../../../node_modules/@types/node/v8.d.ts","../../../../node_modules/@types/node/vm.d.ts","../../../../node_modules/@types/node/wasi.d.ts","../../../../node_modules/@types/node/worker_threads.d.ts","../../../../node_modules/@types/node/zlib.d.ts","../../../../node_modules/@types/node/globals.global.d.ts","../../../../node_modules/@types/node/index.d.ts"],"fileInfos":[{"version":"f59215c5f1d886b05395ee7aca73e0ac69ddfad2843aa88530e797879d511bad","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","dc48272d7c333ccf58034c0026162576b7d50ea0e69c3b9292f803fc20720fd5","27147504487dc1159369da4f4da8a26406364624fa9bc3db632f7d94a5bae2c3","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4",{"version":"3dda5344576193a4ae48b8d03f105c86f20b2f2aff0a1d1fd7935f5d68649654","affectsGlobalScope":true},{"version":"35299ae4a62086698444a5aaee27fc7aa377c68cbb90b441c9ace246ffd05c97","affectsGlobalScope":true},{"version":"c5c5565225fce2ede835725a92a28ece149f83542aa4866cfb10290bff7b8996","affectsGlobalScope":true},{"version":"7d2dbc2a0250400af0809b0ad5f84686e84c73526de931f84560e483eb16b03c","affectsGlobalScope":true},{"version":"9d9885c728913c1d16e0d2831b40341d6ad9a0ceecaabc55209b306ad9c736a5","affectsGlobalScope":true},{"version":"17bea081b9c0541f39dd1ae9bc8c78bdd561879a682e60e2f25f688c0ecab248","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"ab22100fdd0d24cfc2cc59d0a00fc8cf449830d9c4030dc54390a46bd562e929","affectsGlobalScope":true},{"version":"f7bd636ae3a4623c503359ada74510c4005df5b36de7f23e1db8a5c543fd176b","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"0c20f4d2358eb679e4ae8a4432bdd96c857a2960fd6800b21ec4008ec59d60ea","affectsGlobalScope":true},{"version":"36ae84ccc0633f7c0787bc6108386c8b773e95d3b052d9464a99cd9b8795fbec","affectsGlobalScope":true},{"version":"82d0d8e269b9eeac02c3bd1c9e884e85d483fcb2cd168bccd6bc54df663da031","affectsGlobalScope":true},{"version":"b8deab98702588840be73d67f02412a2d45a417a3c097b2e96f7f3a42ac483d1","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"376d554d042fb409cb55b5cbaf0b2b4b7e669619493c5d18d5fa8bd67273f82a","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"c4138a3dd7cd6cf1f363ca0f905554e8d81b45844feea17786cdf1626cb8ea06","affectsGlobalScope":true},{"version":"6ff3e2452b055d8f0ec026511c6582b55d935675af67cdb67dd1dc671e8065df","affectsGlobalScope":true},{"version":"03de17b810f426a2f47396b0b99b53a82c1b60e9cba7a7edda47f9bb077882f4","affectsGlobalScope":true},{"version":"8184c6ddf48f0c98429326b428478ecc6143c27f79b79e85740f17e6feb090f1","affectsGlobalScope":true},{"version":"261c4d2cf86ac5a89ad3fb3fafed74cbb6f2f7c1d139b0540933df567d64a6ca","affectsGlobalScope":true},{"version":"6af1425e9973f4924fca986636ac19a0cf9909a7e0d9d3009c349e6244e957b6","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"15a630d6817718a2ddd7088c4f83e4673fde19fa992d2eae2cf51132a302a5d3","affectsGlobalScope":true},{"version":"f06948deb2a51aae25184561c9640fb66afeddb34531a9212d011792b1d19e0a","affectsGlobalScope":true},{"version":"01e0ee7e1f661acedb08b51f8a9b7d7f959e9cdb6441360f06522cc3aea1bf2e","affectsGlobalScope":true},{"version":"ac17a97f816d53d9dd79b0d235e1c0ed54a8cc6a0677e9a3d61efb480b2a3e4e","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"ec0104fee478075cb5171e5f4e3f23add8e02d845ae0165bfa3f1099241fa2aa","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"9cc66b0513ad41cb5f5372cca86ef83a0d37d1c1017580b7dace3ea5661836df","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"307c8b7ebbd7f23a92b73a4c6c0a697beca05b06b036c23a34553e5fe65e4fdc","affectsGlobalScope":true},{"version":"189c0703923150aa30673fa3de411346d727cc44a11c75d05d7cf9ef095daa22","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},"322cc0ca9c311414642c0d7ef3b57beedbac198ca074e3e109a4be4c366dcb81",{"version":"98e38e23c7c5996d38e27b9798e98c5486e3b6833663a78aa896b21298cd3b08","signature":"8a097d689786f46d5f2e6433a49d383b044597073e5e0b1fea48f3efa042cb79"},{"version":"8a2d076ff53a3b76a4929f5d334fdaa22262f746de4c696bf47e370814c4fe36","signature":"bc93e02cfc0e3019072cf0ec0a57ded2e3f5813870dca04623e5db3e1d2f03e2"},{"version":"3ae377c28537919e03cb77dfe944e361245dd5979722c3c3be36a8226ed32c84","signature":"4d991768db6e5c49ae62899e3ca696b6ebd2d83865adc5ee387c67ab5906d6f8"},{"version":"e1aba13019cb998742f2a1bb9b5b19e9680e83b182d638d3d8849ae72027629d","signature":"ac8c3a873b20c5f64c0dd1e9e504ae2a7a1e45177e3bcaefdadbf9d5ec1261c8"},{"version":"9bf99a04a35c5a01212efdd77141acd5e3bc1423982dafecd71c8f90e308b48d","signature":"70f72bf6ae0d50e11a1771689db30fe9dc7cece2955286423cfa442be5e1263a"},{"version":"0eaf9dfb5151cb10a38616a078ecfd1c42ba93bf9f3a32f5e01ef25ae8e6a545","signature":"800324653fc8a4a83e13eaf657897aa036b1301e08680ccb92f1f25700520283"},{"version":"be068457c08c513f9207f7e1ac717b73e3ee5da91b00cf16a2a917149ac8f640","signature":"988259d717cdcad1948c91db5c45a06d03b362bc632104f7f757e87a8a9c0ace"},{"version":"e471bc314304f6f66221444a9c08acc83ef556b43cb365cb6cbe8e1ef0730e59","signature":"fb892dfd2a188b6d704f8b170e28b4154cedcd9c2d7932ef31a1bf09b99694d4"},{"version":"7a44eed161c0073a783d813bab71eaa3a26edd51edfbad4828958854d7241061","signature":"d8cb56e6c1f33c1f89f50c3d3e7460a2ffa5ead63890efb89c6601bf371400a0"},{"version":"e93d9d7180df245060a528b51479b800a4bc11b4ae0a392d6d40abcd2d451f30","signature":"6b911aac7d12ff36549b5106659918afcf836477cca6bc1e9b86253ae8065561"},{"version":"c1e93f7c3a36ad419122e9474e56a01c4a10759c6172470413b4ecf0d87c1760","signature":"71be9175dc8a1c1cd6eee99770d6afb634c9f7dee2befff0f4ce9c8ca704522e"},{"version":"f5f3a1dc043d05c61a76e4d4e3e0bcd491d342128f46b2de5315878d4b860f3c","signature":"134134de823f2c8466a1138fa7f84989df4a3fa189d752144fee6ebc5ee32bd9"},{"version":"9fcf9bb295d47219b4f644f1ded34d8372062abd034f63f33725e4ce4b968965","signature":"1e5c5277a6f3466ddcaa3302779e026d9c981105011e146a6c57d7bf7a76bfdd"},{"version":"c3751ae2a8b4b5911b19b4cfadf662e5f2fbd73959f73e316c5c6a695ed90791","signature":"2349625342a54f6ce6f4511d96353950cf57fb58e424f3322e797f2d04f1dec4"},{"version":"b11cb315c9b797b1a1e7d0607d94fb8186fe42ab827af7b14419ea67b1a88f59","signature":"c13a58be4eba73d3a4944e8d3c7ae3b0ac1dad71ae4dbfc53d4e6ac8ac4fe2c8"},{"version":"8b97672b1d1ada043215b6d6788127e55fec28615aa0eb8a45105b7fc470ae6d","signature":"bbce5333ed4bfd02bb85eeb4d0624f9f9c3a161aa531e97e1328f97061e6752d"},{"version":"a9df3b1b3df0a59ae576c576c6d4c752cdac9ccc3ff6ea075d6d03924546c1b9","signature":"34a727992de7024dd5e9e09a7982c02f339c049f20ac38dde6481bc15cb3cc34"},{"version":"9a6131da142839141b7ae9786354e1c8d70355e1ab66dac6ab83f540375a06c7","signature":"cf78caece5387023e049c4743e9e69ba2b0672daec5d44709b500d5a3414bfb2"},{"version":"633550246f0aed44225590fd5694a29c7d3e44d8a491c9c6746544f4c99ec2eb","signature":"8e990f2aff88c7f27d77f8ae073fbca7e18d89a6b0014690be004486f2a1234a"},{"version":"61fd09bfd302b267f1e9316927e8016be746d8f2d303c304dc9cf83423fe5c08","signature":"38d806f13d45fe7bd54b91ad6c83ec77e73496c2cd06ce6539c4afe72c096af2"},{"version":"d1c4c729fdd997343a6b618b8e1b35193b6756dc009218f4c6b68c3d0b9de9d8","signature":"ff081d5e2a0696c61ab5023c2dc6d6e54f57a2dd9e71276d3f411a6829ec6e99"},"cdcc132f207d097d7d3aa75615ab9a2e71d6a478162dde8b67f88ea19f3e54de","0d14fa22c41fdc7277e6f71473b20ebc07f40f00e38875142335d5b63cdfc9d2","c085e9aa62d1ae1375794c1fb927a445fa105fed891a7e24edbb1c3300f7384a","f315e1e65a1f80992f0509e84e4ae2df15ecd9ef73df975f7c98813b71e4c8da","5b9586e9b0b6322e5bfbd2c29bd3b8e21ab9d871f82346cb71020e3d84bae73e","3e70a7e67c2cb16f8cd49097360c0309fe9d1e3210ff9222e9dac1f8df9d4fb6","ab68d2a3e3e8767c3fba8f80de099a1cfc18c0de79e42cb02ae66e22dfe14a66","d96cc6598148bf1a98fb2e8dcf01c63a4b3558bdaec6ef35e087fd0562eb40ec","5b9586e9b0b6322e5bfbd2c29bd3b8e21ab9d871f82346cb71020e3d84bae73e",{"version":"9afcfd847523b81d526c73130a247fbb65aa1eba2a1d4195cfacd677a9e4de08","affectsGlobalScope":true},"7e771891adaa85b690266bc37bd6eb43bc57eecc4b54693ead36467e7369952a","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"ca72190df0eb9b09d4b600821c8c7b6c9747b75a1c700c4d57dc0bb72abc074c","affectsGlobalScope":true},"11e2d554398d2bd460e7d06b2fa5827a297c8acfbe00b4f894a224ac0862857f",{"version":"fc811ced095f38ad4438bb94a8d665c63bf4943e58a71ada16627add5ad93226","affectsGlobalScope":true},"374ca798f244e464346f14301dc2a8b4b111af1a83b49fffef5906c338a1f922","5a94487653355b56018122d92392beb2e5f4a6c63ba5cef83bbe1c99775ef713",{"version":"d5135ad93b33adcce80b18f8065087934cdc1730d63db58562edcf017e1aad9b","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","5eb881ed2a0d5b17ea36df5cd4c4be500e460c412f270c3170e906bec65580ac","bb9c4ffa5e6290c6980b63c815cdd1625876dadb2efaf77edbe82984be93e55e","489532ff54b714f0e0939947a1c560e516d3ae93d51d639ab02e907a0e950114","f30bb836526d930a74593f7b0f5c1c46d10856415a8f69e5e2fc3db80371e362","14b5aa23c5d0ae1907bc696ac7b6915d88f7d85799cc0dc2dcf98fbce2c5a67c","5c439dafdc09abe4d6c260a96b822fa0ba5be7203c71a63ab1f1423cd9e838ea",{"version":"6b526a5ec4a401ca7c26cfe6a48e641d8f30af76673bad3b06a1b4504594a960","affectsGlobalScope":true},{"version":"816ad2e607a96de5bcac7d437f843f5afd8957f1fa5eefa6bba8e4ed7ca8fd84","affectsGlobalScope":true},"cec36af22f514322f870e81d30675c78df82ae8bf4863f5fd4e4424c040c678d","d903fafe96674bc0b2ac38a5be4a8fc07b14c2548d1cdb165a80ea24c44c0c54","5eec82ac21f84d83586c59a16b9b8502d34505d1393393556682fe7e7fde9ef2","04eb6578a588d6a46f50299b55f30e3a04ef27d0c5a46c57d8fcc211cd530faa","8d3c583a07e0c37e876908c2d5da575019f689df8d9fa4c081d99119d53dba22","2c828a5405191d006115ab34e191b8474bc6c86ffdc401d1a9864b1b6e088a58",{"version":"e630e5528e899219ae319e83bef54bf3bcb91b01d76861ecf881e8e614b167f0","affectsGlobalScope":true},"2c45b35f4850881ab132f80d3cb51e8a359a4d8fafdc5ff2401d260dc27862f4","7c013aa892414a7fdcfd861ae524a668eaa3ede8c7c0acafaf611948122c8d93","b0973c3cbcdc59b37bf477731d468696ecaf442593ec51bab497a613a580fe30",{"version":"4989e92ba5b69b182d2caaea6295af52b7dc73a4f7a2e336a676722884e7139d","affectsGlobalScope":true},{"version":"b3624aed92dab6da8484280d3cb3e2f4130ec3f4ef3f8201c95144ae9e898bb6","affectsGlobalScope":true},"5153a2fd150e46ce57bb3f8db1318d33f6ad3261ed70ceeff92281c0608c74a3","210d54cd652ec0fec8c8916e4af59bb341065576ecda039842f9ffb2e908507c","36b03690b628eab08703d63f04eaa89c5df202e5f1edf3989f13ad389cd2c091","0effadd232a20498b11308058e334d3339cc5bf8c4c858393e38d9d4c0013dcf","25846d43937c672bab7e8195f3d881f93495df712ee901860effc109918938cc","fd93cee2621ff42dabe57b7be402783fd1aa69ece755bcba1e0290547ae60513","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff","69ee23dd0d215b09907ad30d23f88b7790c93329d1faf31d7835552a10cf7cbf","44b8b584a338b190a59f4f6929d072431950c7bd92ec2694821c11bce180c8a5","23b89798789dffbd437c0c423f5d02d11f9736aea73d6abf16db4f812ff36eda","09326ae5f7e3d49be5cd9ea00eb814770e71870a438faa2efd8bdd9b4db21320",{"version":"970a90f76d4d219ad60819d61f5994514087ba94c985647a3474a5a3d12714ed","affectsGlobalScope":true},"e10177274a35a9d07c825615340b2fcde2f610f53f3fb40269fd196b4288dda6","c4577fb855ca259bdbf3ea663ca73988ce5f84251a92b4aef80a1f4122b6f98e","3c13ef48634e7b5012fcf7e8fce7496352c2d779a7201389ca96a2a81ee4314d","5d0a25ec910fa36595f85a67ac992d7a53dd4064a1ba6aea1c9f14ab73a023f2",{"version":"f0900cd5d00fe1263ff41201fb8073dbeb984397e4af3b8002a5c207a30bdc33","affectsGlobalScope":true},{"version":"ff07a9a03c65732ccc59b3c65bc584173da093bd563a6565411c01f5703bd3cb","affectsGlobalScope":true},"06d7c42d256f0ce6afe1b2b6cfbc97ab391f29dadb00dd0ae8e8f23f5bc916c3","ec4bd1b200670fb567920db572d6701ed42a9641d09c4ff6869768c8f81b404c","e59a892d87e72733e2a9ca21611b9beb52977be2696c7ba4b216cbbb9a48f5aa",{"version":"da26af7362f53d122283bc69fed862b9a9fe27e01bc6a69d1d682e0e5a4df3e6","affectsGlobalScope":true},"8a300fa9b698845a1f9c41ecbe2c5966634582a8e2020d51abcace9b55aa959e",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"ed2a670a77a1b80653c5bde2d813b0ab2e92872cc9b2b611ce11050b95139be6"],"root":[[49,69]],"options":{"composite":true,"declaration":true,"esModuleInterop":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../..","strict":true,"target":7},"fileIdsList":[[126],[72,126],[74,77,126],[73,126],[80,126],[83,126],[84,89,117,126],[85,96,97,104,114,125,126],[85,86,96,104,126],[87,126],[88,89,97,105,126],[89,114,122,126],[90,92,96,104,126],[91,126],[92,93,126],[96,126],[94,96,126],[96,97,98,114,125,126],[96,97,98,111,114,117,126],[126,130],[92,99,104,114,125,126],[96,97,99,100,104,114,122,125,126],[99,101,114,122,125,126],[80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132],[96,102,126],[103,125,126],[92,96,104,114,126],[105,126],[106,126],[83,107,126],[108,124,126,130],[109,126],[110,126],[96,111,112,126],[111,113,126,128],[84,96,114,115,116,117,126],[84,114,116,126],[114,115,126],[117,126],[118,126],[96,120,121,126],[120,121,126],[89,104,114,122,126],[123,126],[104,124,126],[84,99,110,125,126],[89,126],[114,126,127],[126,128],[126,129],[84,89,96,98,107,114,125,126,128,130],[114,126,131],[70,76,126],[74,126],[71,75,126],[49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,126],[54,126],[59,126],[49,126],[52,126],[49,50,51,52,53,54,55,56,57,58,59,60,61,62,63],[54],[49]],"referencedMap":[[70,1],[73,2],[72,1],[79,3],[78,4],[80,5],[81,5],[83,6],[84,7],[85,8],[86,9],[87,10],[88,11],[89,12],[90,13],[91,14],[92,15],[93,15],[95,16],[94,17],[96,16],[97,18],[98,19],[82,20],[132,1],[99,21],[100,22],[101,23],[133,24],[102,25],[103,26],[104,27],[105,28],[106,29],[107,30],[108,31],[109,32],[110,33],[111,34],[112,34],[113,35],[114,36],[116,37],[115,38],[117,39],[118,40],[119,1],[120,41],[121,42],[122,43],[123,44],[124,45],[125,46],[126,47],[127,48],[128,49],[129,50],[130,51],[131,52],[71,1],[77,53],[75,54],[74,4],[76,55],[46,1],[47,1],[8,1],[9,1],[13,1],[12,1],[2,1],[14,1],[15,1],[16,1],[17,1],[18,1],[19,1],[20,1],[21,1],[3,1],[4,1],[25,1],[22,1],[23,1],[24,1],[26,1],[27,1],[28,1],[5,1],[29,1],[30,1],[31,1],[32,1],[6,1],[36,1],[33,1],[34,1],[35,1],[37,1],[7,1],[38,1],[48,1],[43,1],[44,1],[39,1],[40,1],[41,1],[42,1],[1,1],[45,1],[11,1],[10,1],[64,56],[65,1],[61,57],[66,1],[67,58],[60,1],[50,59],[68,1],[59,60],[53,60],[52,1],[49,1],[51,1],[54,59],[57,57],[58,57],[55,57],[56,57],[69,1],[62,1],[63,1]],"exportedModulesMap":[[70,1],[73,2],[72,1],[79,3],[78,4],[80,5],[81,5],[83,6],[84,7],[85,8],[86,9],[87,10],[88,11],[89,12],[90,13],[91,14],[92,15],[93,15],[95,16],[94,17],[96,16],[97,18],[98,19],[82,20],[132,1],[99,21],[100,22],[101,23],[133,24],[102,25],[103,26],[104,27],[105,28],[106,29],[107,30],[108,31],[109,32],[110,33],[111,34],[112,34],[113,35],[114,36],[116,37],[115,38],[117,39],[118,40],[119,1],[120,41],[121,42],[122,43],[123,44],[124,45],[125,46],[126,47],[127,48],[128,49],[129,50],[130,51],[131,52],[71,1],[77,53],[75,54],[74,4],[76,55],[46,1],[47,1],[8,1],[9,1],[13,1],[12,1],[2,1],[14,1],[15,1],[16,1],[17,1],[18,1],[19,1],[20,1],[21,1],[3,1],[4,1],[25,1],[22,1],[23,1],[24,1],[26,1],[27,1],[28,1],[5,1],[29,1],[30,1],[31,1],[32,1],[6,1],[36,1],[33,1],[34,1],[35,1],[37,1],[7,1],[38,1],[48,1],[43,1],[44,1],[39,1],[40,1],[41,1],[42,1],[1,1],[45,1],[11,1],[10,1],[64,61],[61,62],[50,63],[54,63],[57,62],[58,62],[55,62],[56,62]],"semanticDiagnosticsPerFile":[70,73,72,79,78,80,81,83,84,85,86,87,88,89,90,91,92,93,95,94,96,97,98,82,132,99,100,101,133,102,103,104,105,106,107,108,109,110,111,112,113,114,116,115,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,71,77,75,74,76,46,47,8,9,13,12,2,14,15,16,17,18,19,20,21,3,4,25,22,23,24,26,27,28,5,29,30,31,32,6,36,33,34,35,37,7,38,48,43,44,39,40,41,42,1,45,11,10,64,65,61,66,67,60,50,68,59,53,52,49,51,54,57,58,55,56,69,62,63],"latestChangedDtsFile":"./src/lib/validators/is-iso-date-string.d.ts"},"version":"5.1.6"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createCookieString } from './lib/cookies/create-cookie-string';
|
|
2
|
+
import { ICookieProperties } from './lib/cookies/interfaces';
|
|
3
|
+
import { fetchWithTimeout } from './lib/fetch-with-timeout';
|
|
4
|
+
import { getCookieValueClientSide } from './lib/cookies/get-cookie-value-client-side';
|
|
5
|
+
import { isNextJsMiddlewareRequest } from './lib/typeguards/is-next-js-middleware-request';
|
|
6
|
+
import { isNextJsMiddlewareResponse } from './lib/typeguards/is-next-js-middleware-response';
|
|
7
|
+
import { isHttpRequest } from './lib/typeguards/is-http-request';
|
|
8
|
+
import { isHttpResponse } from './lib/typeguards/is-http-response';
|
|
9
|
+
import { getCookie } from './lib/cookies/get-cookie';
|
|
10
|
+
import { getCookieServerSide } from './lib/cookies/get-cookie-server-side';
|
|
11
|
+
import { cookieExists } from './lib/cookies/cookie-exists';
|
|
12
|
+
import { flattenObject, INestedObject, IFlattenedObject } from './lib/converters/flatten-object';
|
|
13
|
+
import { isShortISODateString } from './lib/validators/is-short-iso-date-string';
|
|
14
|
+
import { isValidEmail } from './lib/validators/is-valid-email';
|
|
15
|
+
import type { TRequest, IMiddlewareNextResponse, IHttpResponse, IMiddlewareRequest, IHttpRequest, BasicTypes } from './lib/interfaces';
|
|
16
|
+
import type { ICookie } from './lib/cookies/interfaces';
|
|
17
|
+
export { createCookieString, fetchWithTimeout, getCookieValueClientSide, isNextJsMiddlewareRequest, isNextJsMiddlewareResponse, isHttpRequest, isHttpResponse, getCookie, getCookieServerSide, cookieExists, flattenObject, isShortISODateString, isValidEmail, };
|
|
18
|
+
export type { INestedObject, TRequest, IMiddlewareNextResponse, BasicTypes, IHttpResponse, IHttpRequest, IMiddlewareRequest, IFlattenedObject, };
|
|
19
|
+
export type { ICookie, ICookieProperties };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
2
|
+
import { createCookieString } from './lib/cookies/create-cookie-string';
|
|
3
|
+
import { fetchWithTimeout } from './lib/fetch-with-timeout';
|
|
4
|
+
import { getCookieValueClientSide } from './lib/cookies/get-cookie-value-client-side';
|
|
5
|
+
import { isNextJsMiddlewareRequest } from './lib/typeguards/is-next-js-middleware-request';
|
|
6
|
+
import { isNextJsMiddlewareResponse } from './lib/typeguards/is-next-js-middleware-response';
|
|
7
|
+
import { isHttpRequest } from './lib/typeguards/is-http-request';
|
|
8
|
+
import { isHttpResponse } from './lib/typeguards/is-http-response';
|
|
9
|
+
import { getCookie } from './lib/cookies/get-cookie';
|
|
10
|
+
import { getCookieServerSide } from './lib/cookies/get-cookie-server-side';
|
|
11
|
+
import { cookieExists } from './lib/cookies/cookie-exists';
|
|
12
|
+
import { flattenObject } from './lib/converters/flatten-object';
|
|
13
|
+
import { isShortISODateString } from './lib/validators/is-short-iso-date-string';
|
|
14
|
+
import { isValidEmail } from './lib/validators/is-valid-email';
|
|
15
|
+
// Exports
|
|
16
|
+
export { createCookieString, fetchWithTimeout, getCookieValueClientSide, isNextJsMiddlewareRequest, isNextJsMiddlewareResponse, isHttpRequest, isHttpResponse, getCookie, getCookieServerSide, cookieExists, flattenObject, isShortISODateString, isValidEmail, };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
2
|
+
/*
|
|
3
|
+
* A function that converts a string or an object to a base64 string
|
|
4
|
+
* @param input - The string or object to be converted
|
|
5
|
+
* @returns A base64 string
|
|
6
|
+
*/
|
|
7
|
+
export function convertToBase64(input) {
|
|
8
|
+
const data = typeof input === 'string' ? input : JSON.stringify(input);
|
|
9
|
+
const stringFormat = 'base64';
|
|
10
|
+
if (typeof Buffer === 'function')
|
|
11
|
+
return Buffer.from(data).toString(stringFormat);
|
|
12
|
+
if (typeof window?.btoa === 'function')
|
|
13
|
+
return window.btoa(data);
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BasicTypes } from '../interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* A function that flattens an object, by combining the keys with an "_".
|
|
4
|
+
* @param data - An object that has the required data to perform the flattening
|
|
5
|
+
* @returns - A new flattened object
|
|
6
|
+
* @example
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* const object = {order:{amount: 1, delivered: false}}
|
|
10
|
+
* const flattenedObject = flattenObject(object)
|
|
11
|
+
* // flattenedObject will be {order_amount: 1, order_delivered: false}
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function flattenObject(data: IFlattenObjectDataParameters): IFlattenedObject;
|
|
15
|
+
/**
|
|
16
|
+
* Interface for the data object parameter of the flattenObject function
|
|
17
|
+
*/
|
|
18
|
+
interface IFlattenObjectDataParameters {
|
|
19
|
+
object: INestedObject;
|
|
20
|
+
currentKey?: string;
|
|
21
|
+
newObject?: IFlattenedObject;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Interface for the return object of the flattenObject function
|
|
25
|
+
*/
|
|
26
|
+
export interface IFlattenedObject {
|
|
27
|
+
[key: string]: BasicTypes;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Interface of the object to flatten
|
|
31
|
+
*/
|
|
32
|
+
export interface INestedObject {
|
|
33
|
+
[key: string]: BasicTypes | INestedObject;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
2
|
+
/**
|
|
3
|
+
* A function that flattens an object, by combining the keys with an "_".
|
|
4
|
+
* @param data - An object that has the required data to perform the flattening
|
|
5
|
+
* @returns - A new flattened object
|
|
6
|
+
* @example
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* const object = {order:{amount: 1, delivered: false}}
|
|
10
|
+
* const flattenedObject = flattenObject(object)
|
|
11
|
+
* // flattenedObject will be {order_amount: 1, order_delivered: false}
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export function flattenObject(data) {
|
|
15
|
+
const { currentKey, object } = data;
|
|
16
|
+
const newObject = data.newObject ?? {};
|
|
17
|
+
for (const key in object) {
|
|
18
|
+
const value = object[key];
|
|
19
|
+
if (value === undefined)
|
|
20
|
+
continue;
|
|
21
|
+
if (typeof value === 'object' && !Array.isArray(value))
|
|
22
|
+
flattenObject({
|
|
23
|
+
currentKey: `${currentKey ? `${currentKey}_${key}` : key}`,
|
|
24
|
+
newObject,
|
|
25
|
+
object: value,
|
|
26
|
+
});
|
|
27
|
+
else
|
|
28
|
+
newObject[currentKey ? `${currentKey}_${key}` : key] = value;
|
|
29
|
+
}
|
|
30
|
+
return newObject;
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DAILY_SECONDS = 86400;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evaluates whether a specified cookie name exists in the request header
|
|
3
|
+
* @param cookiesHeader - The cookie string of the request header
|
|
4
|
+
* @param cookieName - The cookie name to be found
|
|
5
|
+
* @returns - A boolean value if cookie exists
|
|
6
|
+
*/
|
|
7
|
+
export declare function cookieExistsInServerSide(cookiesHeader: string, cookieName: string): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
2
|
+
import { getCookieServerSide } from './get-cookie-server-side';
|
|
3
|
+
/**
|
|
4
|
+
* Evaluates whether a specified cookie name exists in the request header
|
|
5
|
+
* @param cookiesHeader - The cookie string of the request header
|
|
6
|
+
* @param cookieName - The cookie name to be found
|
|
7
|
+
* @returns - A boolean value if cookie exists
|
|
8
|
+
*/
|
|
9
|
+
export function cookieExistsInServerSide(cookiesHeader, cookieName) {
|
|
10
|
+
return getCookieServerSide(cookiesHeader, cookieName) !== undefined;
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the cookie exists in the cookie string
|
|
3
|
+
* @param cookieStr - The cookie string containing every cookie
|
|
4
|
+
* @param cookieName - The cookie name to be found
|
|
5
|
+
* @returns - boolean value, if the cookie is found in the cookie string
|
|
6
|
+
*/
|
|
7
|
+
export declare function cookieExists(cookieStr: string, cookieName: string): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the cookie exists in the cookie string
|
|
4
|
+
* @param cookieStr - The cookie string containing every cookie
|
|
5
|
+
* @param cookieName - The cookie name to be found
|
|
6
|
+
* @returns - boolean value, if the cookie is found in the cookie string
|
|
7
|
+
*/
|
|
8
|
+
export function cookieExists(cookieStr, cookieName) {
|
|
9
|
+
return cookieStr.split('; ').some((cookie) => cookie.split('=')[0] === cookieName);
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ICookieProperties } from './interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* Creates the cookie string with the respectively cookie attributes
|
|
4
|
+
* @param name - name of the cookie
|
|
5
|
+
* @param value - value of the cookie
|
|
6
|
+
* @param attributes - an object of supported cookie attributes
|
|
7
|
+
* @returns - a string that will be passed to document.cookie
|
|
8
|
+
*/
|
|
9
|
+
export declare function createCookieString(name: string, value: string, attributes: ICookieProperties): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
2
|
+
/**
|
|
3
|
+
* Creates the cookie string with the respectively cookie attributes
|
|
4
|
+
* @param name - name of the cookie
|
|
5
|
+
* @param value - value of the cookie
|
|
6
|
+
* @param attributes - an object of supported cookie attributes
|
|
7
|
+
* @returns - a string that will be passed to document.cookie
|
|
8
|
+
*/
|
|
9
|
+
export function createCookieString(name, value, attributes) {
|
|
10
|
+
let cookieString = `${name}=${value};`;
|
|
11
|
+
cookieString += ` Max-Age=${attributes.maxAge}; SameSite=${attributes.sameSite};`;
|
|
12
|
+
cookieString += attributes.secure ? ' Secure;' : '';
|
|
13
|
+
cookieString += attributes.path ? ` Path=${attributes.path};` : '';
|
|
14
|
+
cookieString += attributes.domain ? ` Domain=${attributes.domain};` : '';
|
|
15
|
+
cookieString = cookieString.substring(0, cookieString.length - 1);
|
|
16
|
+
return cookieString;
|
|
17
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
2
|
+
/**
|
|
3
|
+
* Deletes a cookie from the document (client-side only)
|
|
4
|
+
* @param cookieName - The cookie to be deleted
|
|
5
|
+
*/
|
|
6
|
+
export function deleteCookie(cookieName) {
|
|
7
|
+
document.cookie = cookieName + '=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
|
|
8
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieves the cookie name and value from the request header
|
|
3
|
+
* @param cookiesHeader - The cookie string of the request header
|
|
4
|
+
* @param cookieName - The cookie name to be found
|
|
5
|
+
* @returns - The name and value of the cookie, or undefined
|
|
6
|
+
*/
|
|
7
|
+
export declare function getCookieServerSide(cookiesHeader: string | undefined, cookieName: string): {
|
|
8
|
+
name: string;
|
|
9
|
+
value: string;
|
|
10
|
+
} | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
2
|
+
import { getCookie } from './get-cookie';
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves the cookie name and value from the request header
|
|
5
|
+
* @param cookiesHeader - The cookie string of the request header
|
|
6
|
+
* @param cookieName - The cookie name to be found
|
|
7
|
+
* @returns - The name and value of the cookie, or undefined
|
|
8
|
+
*/
|
|
9
|
+
export function getCookieServerSide(cookiesHeader, cookieName) {
|
|
10
|
+
return getCookie(cookiesHeader, cookieName);
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
2
|
+
import { getCookie } from './get-cookie';
|
|
3
|
+
/**
|
|
4
|
+
* Gets the value for a given cookie name
|
|
5
|
+
* @param cookieName - The cookie name to be found
|
|
6
|
+
* @returns - The value of the cookie if it exists or empty string
|
|
7
|
+
*/
|
|
8
|
+
export function getCookieValueClientSide(cookieName) {
|
|
9
|
+
const cookie = getCookie(document.cookie, cookieName);
|
|
10
|
+
return cookie?.value ?? '';
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieves the cookie, if it exists in the cookie string
|
|
3
|
+
* @param cookieStr - The cookie string containing every cookie
|
|
4
|
+
* @param cookieName - The cookie name to be found
|
|
5
|
+
* @returns - an object that contains the cookie name and value or undefined, if not found
|
|
6
|
+
*/
|
|
7
|
+
export declare function getCookie(cookieStr: string | undefined, cookieName: string): {
|
|
8
|
+
name: string;
|
|
9
|
+
value: string;
|
|
10
|
+
} | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the cookie, if it exists in the cookie string
|
|
4
|
+
* @param cookieStr - The cookie string containing every cookie
|
|
5
|
+
* @param cookieName - The cookie name to be found
|
|
6
|
+
* @returns - an object that contains the cookie name and value or undefined, if not found
|
|
7
|
+
*/
|
|
8
|
+
export function getCookie(cookieStr, cookieName) {
|
|
9
|
+
if (!cookieStr)
|
|
10
|
+
return undefined;
|
|
11
|
+
const found = cookieStr.split('; ').find((cookie) => {
|
|
12
|
+
return cookie.indexOf('=') > 0 && cookie.split('=')[0] === cookieName;
|
|
13
|
+
});
|
|
14
|
+
return found !== undefined ? { name: found.split('=')[0], value: found.split('=')[1] } : undefined;
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cookie properties
|
|
3
|
+
*/
|
|
4
|
+
export interface ICookieProperties {
|
|
5
|
+
maxAge: number;
|
|
6
|
+
sameSite: string;
|
|
7
|
+
secure: boolean;
|
|
8
|
+
path?: string;
|
|
9
|
+
httpOnly?: boolean;
|
|
10
|
+
expires?: Date;
|
|
11
|
+
domain?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Interface that represents a cookie (name, value)
|
|
15
|
+
*/
|
|
16
|
+
export interface ICookie {
|
|
17
|
+
name: string;
|
|
18
|
+
value: string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetches data from the specified URL within the given timeout period.
|
|
3
|
+
*
|
|
4
|
+
* @param url - The URL to fetch data from.
|
|
5
|
+
* @param timeout - The time in milliseconds to wait before timing out the request.
|
|
6
|
+
* @param fetchOptions - The options to pass to the fetch API.
|
|
7
|
+
* @returns - A Promise that resolves to the fetched data, or null if the request was aborted or timed out.
|
|
8
|
+
* @throws - If the timeout value is invalid.
|
|
9
|
+
*/
|
|
10
|
+
export declare function fetchWithTimeout(url: string, timeout: number, fetchOptions: {
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
}): Promise<null | unknown>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
2
|
+
/**
|
|
3
|
+
* Fetches data from the specified URL within the given timeout period.
|
|
4
|
+
*
|
|
5
|
+
* @param url - The URL to fetch data from.
|
|
6
|
+
* @param timeout - The time in milliseconds to wait before timing out the request.
|
|
7
|
+
* @param fetchOptions - The options to pass to the fetch API.
|
|
8
|
+
* @returns - A Promise that resolves to the fetched data, or null if the request was aborted or timed out.
|
|
9
|
+
* @throws - If the timeout value is invalid.
|
|
10
|
+
*/
|
|
11
|
+
export async function fetchWithTimeout(url, timeout, fetchOptions) {
|
|
12
|
+
if (!Number.isInteger(timeout) || timeout < 0)
|
|
13
|
+
throw new Error('[IV-0006] Incorrect value for the timeout parameter. Set the value to an integer greater than or equal to 0.');
|
|
14
|
+
const abortController = new AbortController();
|
|
15
|
+
const signal = abortController.signal;
|
|
16
|
+
const timeoutHandler = setTimeout(() => {
|
|
17
|
+
abortController.abort();
|
|
18
|
+
}, timeout);
|
|
19
|
+
return fetch(url, { ...fetchOptions, signal })
|
|
20
|
+
.then((response) => {
|
|
21
|
+
clearTimeout(timeoutHandler);
|
|
22
|
+
return response.json();
|
|
23
|
+
})
|
|
24
|
+
.then((data) => data)
|
|
25
|
+
.catch((error) => {
|
|
26
|
+
if (error.name === 'AbortError')
|
|
27
|
+
throw new Error('[IE-0002] Timeout exceeded. The server did not respond within the allotted time.');
|
|
28
|
+
return null;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ICookie } from './cookies/interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* A reusable type that accepts only basic types and arrays of those
|
|
4
|
+
*/
|
|
5
|
+
export type BasicTypes = string | boolean | number | undefined | Array<string | boolean | number | {
|
|
6
|
+
[key: string]: BasicTypes;
|
|
7
|
+
} | Array<BasicTypes>>;
|
|
8
|
+
/**
|
|
9
|
+
* Interface for supporting request IncomingMessage http node type
|
|
10
|
+
*/
|
|
11
|
+
export interface IHttpRequest {
|
|
12
|
+
headers: {
|
|
13
|
+
'cookie'?: string;
|
|
14
|
+
'content-language'?: string;
|
|
15
|
+
'referer'?: string;
|
|
16
|
+
};
|
|
17
|
+
url?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Interface for supporting response OutgoingMessage http node type
|
|
21
|
+
*/
|
|
22
|
+
export interface IHttpResponse {
|
|
23
|
+
setHeader(name: string, value: number | string | ReadonlyArray<string>): void;
|
|
24
|
+
}
|
|
25
|
+
export type TRequest = IHttpRequest | IMiddlewareRequest;
|
|
26
|
+
/**
|
|
27
|
+
* Interface for supporting request from Edge Next.js
|
|
28
|
+
* includes types compatible with both NextJS versions 12 & 13
|
|
29
|
+
*/
|
|
30
|
+
export interface IMiddlewareRequest {
|
|
31
|
+
cookies: {
|
|
32
|
+
set: ((key: string, value: string, options: any) => any) | ((...args: [key: string, value: string] | [options: ICookie]) => any);
|
|
33
|
+
get: (key: string) => ICookie | string | undefined;
|
|
34
|
+
};
|
|
35
|
+
headers: {
|
|
36
|
+
get: (name: string) => string | null;
|
|
37
|
+
};
|
|
38
|
+
url?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Interface for Edge Next.js Response
|
|
42
|
+
* includes types compatible with both NextJS versions 12 & 13
|
|
43
|
+
*/
|
|
44
|
+
export interface IMiddlewareNextResponse {
|
|
45
|
+
cookies: {
|
|
46
|
+
set: ((key: string, value: unknown, options?: any) => any) | ((...args: [key: string, value: string] | [options: ICookie]) => any);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IHttpRequest, TRequest } from '../interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the given 'request' object is a valid HTTP Request
|
|
4
|
+
* by verifying the presence of necessary properties.
|
|
5
|
+
*
|
|
6
|
+
* @param request - The request object to be validated.
|
|
7
|
+
* @returns Returns true if 'request' is a valid HTTP Request, otherwise false.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isHttpRequest(request: TRequest): request is IHttpRequest;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the given 'request' object is a valid HTTP Request
|
|
4
|
+
* by verifying the presence of necessary properties.
|
|
5
|
+
*
|
|
6
|
+
* @param request - The request object to be validated.
|
|
7
|
+
* @returns Returns true if 'request' is a valid HTTP Request, otherwise false.
|
|
8
|
+
*/
|
|
9
|
+
export function isHttpRequest(request) {
|
|
10
|
+
return 'headers' in request;
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IHttpResponse, IMiddlewareNextResponse } from '../interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the given 'response' object is a valid HTTP Response
|
|
4
|
+
* by verifying the presence of necessary properties.
|
|
5
|
+
*
|
|
6
|
+
* @param response - IMiddlewareNextResponse | IHttpResponse - The response object to be validated.
|
|
7
|
+
* @returns Returns true if 'response' is a valid HTTP Response, otherwise false.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isHttpResponse(response: IMiddlewareNextResponse | IHttpResponse): response is IHttpResponse;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the given 'response' object is a valid HTTP Response
|
|
4
|
+
* by verifying the presence of necessary properties.
|
|
5
|
+
*
|
|
6
|
+
* @param response - IMiddlewareNextResponse | IHttpResponse - The response object to be validated.
|
|
7
|
+
* @returns Returns true if 'response' is a valid HTTP Response, otherwise false.
|
|
8
|
+
*/
|
|
9
|
+
export function isHttpResponse(response) {
|
|
10
|
+
return 'setHeader' in response;
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IMiddlewareRequest, TRequest } from '../interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the given 'request' object is a valid Middleware Request
|
|
4
|
+
* by verifying the presence of necessary properties.
|
|
5
|
+
*
|
|
6
|
+
* @param request - The request object to be validated.
|
|
7
|
+
* @returns Returns true if 'request' is a valid Middleware Request, otherwise false.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isNextJsMiddlewareRequest(request: TRequest): request is IMiddlewareRequest;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the given 'request' object is a valid Middleware Request
|
|
4
|
+
* by verifying the presence of necessary properties.
|
|
5
|
+
*
|
|
6
|
+
* @param request - The request object to be validated.
|
|
7
|
+
* @returns Returns true if 'request' is a valid Middleware Request, otherwise false.
|
|
8
|
+
*/
|
|
9
|
+
export function isNextJsMiddlewareRequest(request) {
|
|
10
|
+
return 'cookies' in request && 'get' in request.cookies && 'set' in request.cookies;
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IHttpResponse, IMiddlewareNextResponse } from '../interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the given 'response' object is a valid IMiddlewareNextResponse Response
|
|
4
|
+
* by verifying the presence of necessary properties.
|
|
5
|
+
*
|
|
6
|
+
* @param response - IMiddlewareNextResponse | IHttpResponse - The response object to be validated.
|
|
7
|
+
* @returns Returns true if 'response' is a valid IMiddlewareNextResponse Response, otherwise false.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isNextJsMiddlewareResponse(response: IMiddlewareNextResponse | IHttpResponse): response is IMiddlewareNextResponse;
|