@ketch-sdk/ketch-data-layer 1.1.7 → 1.1.8
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/dist/cookie/util.d.ts +3 -8
- package/dist/cookie/util.js +4 -30
- package/dist/managed/fetcher.js +6 -6
- package/package.json +1 -1
package/dist/cookie/util.d.ts
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Get a value from a cookie by the key.
|
|
3
|
-
*
|
|
4
|
-
* @param w The window object
|
|
5
|
-
* @param key The cookie key
|
|
6
|
-
*/
|
|
7
|
-
export declare function getCookie(w: Window, key: string): string;
|
|
1
|
+
import { getCookie } from '@ketch-com/ketch-cookie';
|
|
8
2
|
/**
|
|
9
3
|
* Set the value against the given key
|
|
10
4
|
*
|
|
@@ -13,4 +7,5 @@ export declare function getCookie(w: Window, key: string): string;
|
|
|
13
7
|
* @param value The value to set
|
|
14
8
|
* @param ttl The TTL of the cookie value in days
|
|
15
9
|
*/
|
|
16
|
-
|
|
10
|
+
declare function setCookie(w: Window, key: string, value: any, ttl?: number): void;
|
|
11
|
+
export { getCookie, setCookie };
|
package/dist/cookie/util.js
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setCookie = exports.getCookie = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
* @param w The window object
|
|
8
|
-
* @param key The cookie key
|
|
9
|
-
*/
|
|
10
|
-
function getCookie(w, key) {
|
|
11
|
-
return w.document.cookie.split('; ').reduce((r, v) => {
|
|
12
|
-
const parts = v.split('=');
|
|
13
|
-
return parts[0] === key ? decodeURIComponent(parts[1]) : r;
|
|
14
|
-
}, '');
|
|
15
|
-
}
|
|
16
|
-
exports.getCookie = getCookie;
|
|
4
|
+
const ketch_cookie_1 = require("@ketch-com/ketch-cookie");
|
|
5
|
+
Object.defineProperty(exports, "getCookie", { enumerable: true, get: function () { return ketch_cookie_1.getCookie; } });
|
|
17
6
|
/**
|
|
18
7
|
* Set the value against the given key
|
|
19
8
|
*
|
|
@@ -23,22 +12,7 @@ exports.getCookie = getCookie;
|
|
|
23
12
|
* @param ttl The TTL of the cookie value in days
|
|
24
13
|
*/
|
|
25
14
|
function setCookie(w, key, value, ttl) {
|
|
26
|
-
|
|
27
|
-
const expires = new Date(Date.now() + days * 864e5).toUTCString();
|
|
28
|
-
const hostnameParts = w.document.location.hostname.split('.');
|
|
29
|
-
const details = `${key}=${encodeURIComponent(value)}; expires=${expires}; path=/; SameSite=None; Secure`;
|
|
30
|
-
// try to set cookie for last i parts of the domain
|
|
31
|
-
// if cookie not found (likely because domain in public suffix list), retry with an additional part on the domain
|
|
32
|
-
for (let i = 2; i <= hostnameParts.length; i++) {
|
|
33
|
-
// set cookie
|
|
34
|
-
w.document.cookie = `${details}; domain=${hostnameParts.slice(-1 * i).join('.')}`;
|
|
35
|
-
// return if set, otherwise retry with an additional part on the domain
|
|
36
|
-
if (getCookie(w, key)) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
// set cookie without domain if hostnameParts.length < 2 or other error
|
|
41
|
-
w.document.cookie = details;
|
|
15
|
+
(0, ketch_cookie_1.setCookie)(w, key, value, ttl ? ttl * 86400 : ttl);
|
|
42
16
|
}
|
|
43
17
|
exports.setCookie = setCookie;
|
|
44
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
18
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb29raWUvdXRpbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSwwREFBb0U7QUFjM0QsMEZBZEEsd0JBQVMsT0FjQTtBQVpsQjs7Ozs7OztHQU9HO0FBQ0gsU0FBUyxTQUFTLENBQUMsQ0FBUyxFQUFFLEdBQVcsRUFBRSxLQUFVLEVBQUUsR0FBWTtJQUNqRSxJQUFBLHdCQUFFLEVBQUMsQ0FBQyxFQUFFLEdBQUcsRUFBRSxLQUFLLEVBQUUsR0FBRyxDQUFDLENBQUMsQ0FBQyxHQUFHLEdBQUcsS0FBSyxDQUFDLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQTtBQUM1QyxDQUFDO0FBRW1CLDhCQUFTIn0=
|
package/dist/managed/fetcher.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const
|
|
4
|
+
const ketch_cookie_1 = require("@ketch-com/ketch-cookie");
|
|
5
5
|
const uuid_1 = require("uuid");
|
|
6
|
-
const MANAGED_IDENTITY_TTL = 730;
|
|
6
|
+
const MANAGED_IDENTITY_TTL = 730 * 86400;
|
|
7
7
|
function managedFetcher(w, name) {
|
|
8
8
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
9
|
if (!w || name.length === 0) {
|
|
10
10
|
return [];
|
|
11
11
|
}
|
|
12
12
|
name = '_swb';
|
|
13
|
-
let pv = (0,
|
|
13
|
+
let pv = (0, ketch_cookie_1.getCookie)(w, name);
|
|
14
14
|
if (pv) {
|
|
15
15
|
return [pv];
|
|
16
16
|
}
|
|
17
|
-
(0,
|
|
18
|
-
pv = (0,
|
|
17
|
+
(0, ketch_cookie_1.setCookie)(w, name, (0, uuid_1.v4)(), MANAGED_IDENTITY_TTL);
|
|
18
|
+
pv = (0, ketch_cookie_1.getCookie)(w, name);
|
|
19
19
|
if (pv) {
|
|
20
20
|
return [pv];
|
|
21
21
|
}
|
|
@@ -23,4 +23,4 @@ function managedFetcher(w, name) {
|
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
exports.default = managedFetcher;
|
|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k/ketch-data-layer", "version": "1.1.
|
|
1
|
+
{"name": "@ketch-sdk/ketch-data-layer", "version": "1.1.8", "description": "Ketch Data Layer interface", "main": "dist/index.js", "types": "dist/index.d.ts", "type": "commonjs", "scripts": {"all": "npm run lint && npm run format-check && npm run test && npm run build && npm run docs", "build": "tsc -p .", "format": "prettier --write \"**/*.{ts,tsx,yml,yaml}\"", "format-check": "prettier --check '**/*.ts'", "lint": "eslint src/**/*.ts", "test": "jest --runInBand --passWithNoTests", "docs": "typedoc --githubPages true --excludeExternals --excludeInternal src/index.ts"}, "repository": {"type": "git", "url": "git+https://github.com/ketch-sdk/ketch-data-layer.git"}, "homepage": "https://github.com/ketch-sdk/ketch-data-layer", "bugs": {"url": "https://github.com/ketch-sdk/ketch-data-layer/issues"}, "keywords": ["Ketch", "dataLayer"], "author": "Ketch Kloud, Inc.", "license": "MIT", "devDependencies": {"@ketch-sdk/ketch-types": "^1.4.5", "@types/events": "^3.0.0", "@types/jest": "^29.2.6", "@types/nano-equal": "^2.0.0", "@types/uuid": "^9.0.0", "@typescript-eslint/eslint-plugin": "^5.49.0", "@typescript-eslint/parser": "^5.49.0", "eslint": "^8.32.0", "eslint-config-prettier": "^8.6.0", "eslint-plugin-import": "^2.27.5", "eslint-plugin-jest": "^27.2.1", "eslint-plugin-prettier": "^4.2.1", "jest": "^29.4.0", "jest-environment-jsdom": "^29.4.0", "jest-junit": "^15.0.0", "js-yaml": "^4.1.0", "prettier": "^2.8.3", "ts-jest": "^29.0.5", "typedoc": "^0.23.24", "typescript": "^4.9.4"}, "dependencies": {"@ketch-com/ketch-cookie": "^1.0.0", "@ketch-sdk/ketch-logging": "^1.0.3", "events": "^3.3.0", "nano-equal": "^2.0.2", "tslib": "^2.4.1", "uuid": "^9.0.0"}, "files": ["dist/"]}
|