@thumbmarkjs/thumbmarkjs 1.1.0-rc.2 → 1.1.0-rc.4

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/src/options.ts CHANGED
@@ -7,6 +7,7 @@ export interface optionsInterface {
7
7
  api_key?: string,
8
8
  cache_api_call?: boolean,
9
9
  performance?: boolean,
10
+ stabilize?: string[],
10
11
  }
11
12
 
12
13
  export const API_ENDPOINT = 'https://api.thumbmarkjs.com';
@@ -14,6 +15,7 @@ export const API_ENDPOINT = 'https://api.thumbmarkjs.com';
14
15
  export const defaultOptions: optionsInterface = {
15
16
  exclude: [],
16
17
  include: [],
18
+ stabilize: ['private', 'iframe'],
17
19
  logging: true,
18
20
  timeout: 5000,
19
21
  cache_api_call: true,
@@ -27,11 +29,30 @@ export let options = {...defaultOptions};
27
29
  * @param value
28
30
  */
29
31
  export function setOption<K extends keyof optionsInterface>(key: K, value: optionsInterface[K]) {
30
- if (!['include', 'exclude', 'permissions_to_check', 'retries', 'timeout', 'logging', 'api_key', 'cache_api_call'].includes(key))
31
- throw new Error('Unknown option ' + key)
32
- if (['include', 'exclude', 'permissions_to_check'].includes(key) && !(Array.isArray(value) && value.every(item => typeof item === 'string')) )
33
- throw new Error('The value of the include, exclude and permissions_to_check must be an array of strings');
34
- if ([ 'retries', 'timeout'].includes(key) && typeof value !== 'number')
35
- throw new Error('The value of retries must be a number');
36
32
  options[key] = value;
37
33
  }
34
+
35
+ export const stabilizationExclusionRules = {
36
+ 'private': [
37
+ { exclude: ['canvas'], browsers: ['firefox', 'safari>=17', 'brave' ]},
38
+ { exclude: ['audio'], browsers: ['samsungbrowser', 'safari' ]},
39
+ { exclude: ['fonts'], browsers: ['firefox']},
40
+ { exclude: ['plugins'], browsers: ['brave']},
41
+ ],
42
+ 'iframe': [
43
+ {
44
+ exclude: [
45
+ 'permissions.camera',
46
+ 'permission.geolocation',
47
+ 'permissions.microphone',
48
+ 'system.applePayVersion',
49
+ 'system.cookieEnabled'
50
+ ],
51
+ browsers: ['safari']
52
+ },
53
+
54
+ ],
55
+ 'vpn': [
56
+ { exclude: ['ip'] },
57
+ ],
58
+ }
@@ -0,0 +1,23 @@
1
+ import { componentInterface } from '../factory';
2
+
3
+ /**
4
+ * Recursively sorts the keys of a component object alphabetically.
5
+ * This ensures a consistent order for hashing.
6
+ * @param obj The component object to sort.
7
+ * @returns A new object with sorted keys.
8
+ */
9
+ export function sortComponentKeys(obj: componentInterface): componentInterface {
10
+ // Arrays, primitives, and null values are returned as is.
11
+ if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {
12
+ return obj;
13
+ }
14
+
15
+ return Object.keys(obj)
16
+ .sort()
17
+ .reduce((acc: componentInterface, key: string) => {
18
+ const value = obj[key];
19
+ // Recurse for nested objects
20
+ acc[key] = sortComponentKeys(value as componentInterface);
21
+ return acc;
22
+ }, {});
23
+ }