@financial-times/privacy-legislation-client 1.0.0 → 1.1.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/dist/cjs/main.d.ts +3 -4
- package/dist/cjs/main.js +4 -3
- package/dist/esm/main.d.ts +3 -4
- package/dist/esm/main.js +4 -3
- package/package.json +2 -2
- package/src/main.ts +7 -5
- package/tsconfig.json +4 -2
package/dist/cjs/main.d.ts
CHANGED
|
@@ -2,19 +2,18 @@ export declare const API_URL = "https://privacy.ft.com/api/v1";
|
|
|
2
2
|
export declare const API_ENDPOINTS: {
|
|
3
3
|
complianceRegion: string;
|
|
4
4
|
};
|
|
5
|
-
|
|
5
|
+
export type RegionalCompliance = {
|
|
6
6
|
region: string;
|
|
7
7
|
legislation: Set<string>;
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
type Props = {
|
|
10
10
|
url: string;
|
|
11
11
|
legislation: Set<string>;
|
|
12
12
|
referrer?: string;
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
15
|
* Return a promise resolving to an object containing information about the
|
|
16
|
-
* user's legal protections:
|
|
17
|
-
*
|
|
16
|
+
* user's legal protections: *
|
|
18
17
|
* - region: A string consisting of a country code or country-region ("GB", "US-CA")
|
|
19
18
|
* - legislation: A Set of the applicable legislationIds
|
|
20
19
|
*/
|
package/dist/cjs/main.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.buildConsentPageUrl = exports.fetchLegislation = exports.API_ENDPOINTS = exports.API_URL = void 0;
|
|
4
5
|
exports.API_URL = "https://privacy.ft.com/api/v1";
|
|
@@ -35,8 +36,7 @@ function getHostname(referrer) {
|
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
37
38
|
* Return a promise resolving to an object containing information about the
|
|
38
|
-
* user's legal protections:
|
|
39
|
-
*
|
|
39
|
+
* user's legal protections: *
|
|
40
40
|
* - region: A string consisting of a country code or country-region ("GB", "US-CA")
|
|
41
41
|
* - legislation: A Set of the applicable legislationIds
|
|
42
42
|
*/
|
|
@@ -50,7 +50,8 @@ async function fetchLegislation() {
|
|
|
50
50
|
// Not found in session storage, fetch from API
|
|
51
51
|
else {
|
|
52
52
|
try {
|
|
53
|
-
const
|
|
53
|
+
const url = `${exports.API_URL}${exports.API_ENDPOINTS.complianceRegion}`;
|
|
54
|
+
const res = await fetch(url);
|
|
54
55
|
const compliance = await (res.ok ? res.json() : Promise.reject(res));
|
|
55
56
|
if (sessionStorageOk()) {
|
|
56
57
|
sessionStorage.setItem("user-compliance", JSON.stringify(compliance));
|
package/dist/esm/main.d.ts
CHANGED
|
@@ -2,19 +2,18 @@ export declare const API_URL = "https://privacy.ft.com/api/v1";
|
|
|
2
2
|
export declare const API_ENDPOINTS: {
|
|
3
3
|
complianceRegion: string;
|
|
4
4
|
};
|
|
5
|
-
|
|
5
|
+
export type RegionalCompliance = {
|
|
6
6
|
region: string;
|
|
7
7
|
legislation: Set<string>;
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
type Props = {
|
|
10
10
|
url: string;
|
|
11
11
|
legislation: Set<string>;
|
|
12
12
|
referrer?: string;
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
15
|
* Return a promise resolving to an object containing information about the
|
|
16
|
-
* user's legal protections:
|
|
17
|
-
*
|
|
16
|
+
* user's legal protections: *
|
|
18
17
|
* - region: A string consisting of a country code or country-region ("GB", "US-CA")
|
|
19
18
|
* - legislation: A Set of the applicable legislationIds
|
|
20
19
|
*/
|
package/dist/esm/main.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1
2
|
export const API_URL = "https://privacy.ft.com/api/v1";
|
|
2
3
|
export const API_ENDPOINTS = {
|
|
3
4
|
complianceRegion: "/compliance-region.json",
|
|
@@ -32,8 +33,7 @@ function getHostname(referrer) {
|
|
|
32
33
|
}
|
|
33
34
|
/**
|
|
34
35
|
* Return a promise resolving to an object containing information about the
|
|
35
|
-
* user's legal protections:
|
|
36
|
-
*
|
|
36
|
+
* user's legal protections: *
|
|
37
37
|
* - region: A string consisting of a country code or country-region ("GB", "US-CA")
|
|
38
38
|
* - legislation: A Set of the applicable legislationIds
|
|
39
39
|
*/
|
|
@@ -47,7 +47,8 @@ export async function fetchLegislation() {
|
|
|
47
47
|
// Not found in session storage, fetch from API
|
|
48
48
|
else {
|
|
49
49
|
try {
|
|
50
|
-
const
|
|
50
|
+
const url = `${API_URL}${API_ENDPOINTS.complianceRegion}`;
|
|
51
|
+
const res = await fetch(url);
|
|
51
52
|
const compliance = await (res.ok ? res.json() : Promise.reject(res));
|
|
52
53
|
if (sessionStorageOk()) {
|
|
53
54
|
sessionStorage.setItem("user-compliance", JSON.stringify(compliance));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@financial-times/privacy-legislation-client",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"main": "dist/cjs/main.js",
|
|
6
6
|
"module": "dist/esm/main.js",
|
|
7
7
|
"types": "dist/cjs/main.d.ts",
|
|
@@ -18,4 +18,4 @@
|
|
|
18
18
|
"prebuild": "npm run clean",
|
|
19
19
|
"build": "run-p build:*"
|
|
20
20
|
}
|
|
21
|
-
}
|
|
21
|
+
}
|
package/src/main.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
|
|
1
3
|
export const API_URL = "https://privacy.ft.com/api/v1";
|
|
2
4
|
export const API_ENDPOINTS = {
|
|
3
5
|
complianceRegion: "/compliance-region.json",
|
|
4
6
|
};
|
|
5
7
|
|
|
6
|
-
type RegionalCompliance = {
|
|
8
|
+
export type RegionalCompliance = {
|
|
7
9
|
region: string;
|
|
8
10
|
legislation: Set<string>;
|
|
9
11
|
};
|
|
@@ -46,8 +48,7 @@ function getHostname(referrer?: string): string {
|
|
|
46
48
|
|
|
47
49
|
/**
|
|
48
50
|
* Return a promise resolving to an object containing information about the
|
|
49
|
-
* user's legal protections:
|
|
50
|
-
*
|
|
51
|
+
* user's legal protections: *
|
|
51
52
|
* - region: A string consisting of a country code or country-region ("GB", "US-CA")
|
|
52
53
|
* - legislation: A Set of the applicable legislationIds
|
|
53
54
|
*/
|
|
@@ -61,14 +62,15 @@ export async function fetchLegislation(): Promise<RegionalCompliance> {
|
|
|
61
62
|
// Not found in session storage, fetch from API
|
|
62
63
|
else {
|
|
63
64
|
try {
|
|
64
|
-
const
|
|
65
|
+
const url = `${API_URL}${API_ENDPOINTS.complianceRegion}`;
|
|
66
|
+
const res = await fetch(url);
|
|
65
67
|
const compliance = await (res.ok ? res.json() : Promise.reject(res));
|
|
66
68
|
if (sessionStorageOk()) {
|
|
67
69
|
sessionStorage.setItem("user-compliance", JSON.stringify(compliance));
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
return formatResponse(compliance);
|
|
71
|
-
} catch (err) {
|
|
73
|
+
} catch (err: any) {
|
|
72
74
|
throw new Error(err.status);
|
|
73
75
|
}
|
|
74
76
|
}
|
package/tsconfig.json
CHANGED