@repobit/dex-utils 2.1.12 → 2.2.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.
- package/CHANGELOG.md +15 -0
- package/README.md +23 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/typeDefinitions.d.ts +3 -0
- package/dist/src/typeDefinitions.js.map +1 -1
- package/dist/src/utils.d.ts +1 -0
- package/dist/src/utils.js +6 -0
- package/dist/src/utils.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,21 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.2.1](https://github.com/bitdefender/dex-core/compare/@repobit/dex-utils@2.2.0...@repobit/dex-utils@2.2.1) (2026-04-14)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @repobit/dex-utils
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [2.2.0](https://github.com/bitdefender/dex-core/compare/@repobit/dex-utils@2.1.12...@repobit/dex-utils@2.2.0) (2026-04-08)
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* **DEX-26966:** added getUserVisitorId function in utils
|
|
19
|
+
|
|
20
|
+
|
|
6
21
|
## [2.1.12](https://github.com/bitdefender/dex-core/compare/@repobit/dex-utils@2.1.11...@repobit/dex-utils@2.1.12) (2026-04-06)
|
|
7
22
|
|
|
8
23
|
**Note:** Version bump only for package @repobit/dex-utils
|
package/README.md
CHANGED
|
@@ -251,4 +251,26 @@ const debouncedFunction = debounce(() => {
|
|
|
251
251
|
}, 300);
|
|
252
252
|
|
|
253
253
|
document.querySelector('input')?.addEventListener('input', debouncedFunction);
|
|
254
|
-
```
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## getUserVisitorId
|
|
259
|
+
|
|
260
|
+
### Description
|
|
261
|
+
Fetches the current user's visitor ID from the `/bduuid` endpoint and returns the `bd_visitor_id` value from the response payload.
|
|
262
|
+
|
|
263
|
+
### Parameters:
|
|
264
|
+
|
|
265
|
+
This function does not accept any parameters.
|
|
266
|
+
|
|
267
|
+
### Returns:
|
|
268
|
+
|
|
269
|
+
- #### Promise<string> - Resolves to the user's visitor ID.
|
|
270
|
+
|
|
271
|
+
### Usage
|
|
272
|
+
|
|
273
|
+
```typescript
|
|
274
|
+
const visitorId = await getUserVisitorId();
|
|
275
|
+
console.log(visitorId);
|
|
276
|
+
```
|
package/dist/src/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import Cookies from "./cookies.js";
|
|
|
2
2
|
import Page from "./page.js";
|
|
3
3
|
import User from "./user.js";
|
|
4
4
|
import UserAgent from "./user-agent/index.js";
|
|
5
|
-
export { debounce, loadScript, throttle } from "./utils.js";
|
|
5
|
+
export { debounce, getUserVisitorId, loadScript, throttle } from "./utils.js";
|
|
6
6
|
export { Cookies, Page, User, UserAgent };
|
package/dist/src/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import Cookies from "./cookies.js";
|
|
|
2
2
|
import Page from "./page.js";
|
|
3
3
|
import User from "./user.js";
|
|
4
4
|
import UserAgent from "./user-agent/index.js";
|
|
5
|
-
export { debounce, loadScript, throttle } from "./utils.js";
|
|
5
|
+
export { debounce, getUserVisitorId, loadScript, throttle } from "./utils.js";
|
|
6
6
|
export { Cookies, Page, User, UserAgent };
|
|
7
7
|
const w = window;
|
|
8
8
|
w.BD = w.BD || {};
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAE1C,MAAM,CAAC,GAAG,MAIP,CAAA;AAEH,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;AAClB,CAAC,CAAC,EAAE,CAAC,OAAO,GAAG,OAAO,CAAC;AACvB,CAAC,CAAC,EAAE,CAAC,SAAS,GAAG,SAAS,CAAC","sourcesContent":["import Cookies from \"./cookies\";\nimport Page from \"./page\";\nimport User from \"./user\";\nimport UserAgent from \"./user-agent\";\nexport { debounce, getUserVisitorId, loadScript, throttle } from \"./utils\";\nexport { Cookies, Page, User, UserAgent };\n\nconst w = window as unknown as { BD: {\n Cookies : typeof Cookies,\n User : User,\n UserAgent: UserAgent\n} }\n\nw.BD = w.BD || {};\nw.BD.Cookies = Cookies;\nw.BD.UserAgent = UserAgent;"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeDefinitions.js","sourceRoot":"","sources":["../../src/typeDefinitions.ts"],"names":[],"mappings":"","sourcesContent":["export type ScriptParameters = {\n [key: string]: string\n};\n\nexport type UserInfoResult = {\n lastname : string,\n firstname : string,\n email : string,\n fingerprint: string\n}\n\nexport type CssuaUserAgent = {\n desktop: string,\n mobile : string,\n edge : boolean,\n chrome : boolean,\n firefox: boolean,\n safari : boolean,\n vivaldi: boolean,\n ie : boolean,\n opera : boolean\n}
|
|
1
|
+
{"version":3,"file":"typeDefinitions.js","sourceRoot":"","sources":["../../src/typeDefinitions.ts"],"names":[],"mappings":"","sourcesContent":["export type ScriptParameters = {\n [key: string]: string\n};\n\nexport type UserInfoResult = {\n lastname : string,\n firstname : string,\n email : string,\n fingerprint: string\n}\n\nexport type CssuaUserAgent = {\n desktop: string,\n mobile : string,\n edge : boolean,\n chrome : boolean,\n firefox: boolean,\n safari : boolean,\n vivaldi: boolean,\n ie : boolean,\n opera : boolean\n};\n\nexport type BDUUIDData = {\n bd_visitor_id: string\n}"]}
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ import { ScriptParameters } from "./typeDefinitions.js";
|
|
|
2
2
|
export declare function loadScript(src: string, attrs?: ScriptParameters): Promise<void>;
|
|
3
3
|
export declare function throttle(callback: Function, delay?: number): Function;
|
|
4
4
|
export declare function debounce(callback: Function, delay?: number, immediate?: boolean): (...args: unknown[]) => void;
|
|
5
|
+
export declare function getUserVisitorId(): Promise<string>;
|
package/dist/src/utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Constants } from "@repobit/dex-constants";
|
|
1
2
|
export function loadScript(src, attrs = {}) {
|
|
2
3
|
return new Promise((resolve, reject) => {
|
|
3
4
|
if (!document.querySelector(`head > script[src="${src}"]`)) {
|
|
@@ -47,4 +48,9 @@ export function debounce(callback, delay = 250, immediate = false) {
|
|
|
47
48
|
}
|
|
48
49
|
};
|
|
49
50
|
}
|
|
51
|
+
export async function getUserVisitorId() {
|
|
52
|
+
const uuidFetchCall = await fetch(`${Constants.PUBLIC_URL_ORIGIN}/bduuid`);
|
|
53
|
+
const uuidFetchData = await uuidFetchCall.json();
|
|
54
|
+
return uuidFetchData.bd_visitor_id;
|
|
55
|
+
}
|
|
50
56
|
//# sourceMappingURL=utils.js.map
|
package/dist/src/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGnD,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,QAA0B,EAAE;IAClE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,sBAAsB,GAAG,IAAI,CAAC,EAAE,CAAC;YAC3D,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;YAChD,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC;YACjB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;YACzC,CAAC;YAED,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;YAChC,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC;YACxB,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC/B,CAAC;aAAM,CAAC;YACN,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,QAAQ,CAAC,QAAkB,EAAE,QAAgB,GAAG;IAC9D,IAAI,UAAU,GAAG,KAAK,CAAC;IAEvB,OAAO,CAAC,GAAG,IAAe,EAAE,EAAE;QAC5B,IAAI,UAAU,EAAE,CAAC;YACf,OAAO;QACT,CAAC;QAED,UAAU,GAAG,IAAI,CAAC;QAClB,UAAU,CAAC,GAAG,EAAE;YACd,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;YAClB,UAAU,GAAG,KAAK,CAAC;QACrB,CAAC,EAAE,KAAK,CAAC,CAAC;IACZ,CAAC,CAAC;AACJ,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,QAAQ,CAAC,QAAkB,EAAE,QAAgB,GAAG,EAAE,YAAqB,KAAK;IAC1F,IAAI,OAAO,GAA0B,IAAI,CAAC;IAE1C,OAAO,CAAC,GAAG,IAAe,EAAE,EAAE;QAC5B,MAAM,KAAK,GAAG,GAAG,EAAE;YACjB,OAAO,GAAG,IAAI,CAAC;YACf,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;YACpB,CAAC;QACH,CAAC,CAAC;QAEF,MAAM,OAAO,GAAG,SAAS,IAAI,CAAC,OAAO,CAAC;QACtC,YAAY,CAAC,OAAyB,CAAC,CAAC;QACxC,OAAO,GAAG,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACnC,IAAI,OAAO,EAAE,CAAC;YACZ,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;QACpB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,MAAM,aAAa,GAAG,MAAM,KAAK,CAAC,GAAG,SAAS,CAAC,iBAAiB,SAAS,CAAC,CAAC;IAC3E,MAAM,aAAa,GAAe,MAAM,aAAa,CAAC,IAAI,EAAE,CAAC;IAE7D,OAAO,aAAa,CAAC,aAAa,CAAC;AACrC,CAAC","sourcesContent":["import { Constants } from \"@repobit/dex-constants\";\nimport { BDUUIDData, ScriptParameters } from \"./typeDefinitions\";\n\nexport function loadScript(src: string, attrs: ScriptParameters = {}): Promise<void> {\n return new Promise((resolve, reject) => {\n if (!document.querySelector(`head > script[src=\"${src}\"]`)) {\n const script = document.createElement('script');\n script.src = src;\n for (const attr in attrs) {\n script.setAttribute(attr, attrs[attr]);\n }\n\n script.onload = () => resolve();\n script.onerror = reject;\n document.head.append(script);\n } else {\n resolve();\n }\n });\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nexport function throttle(callback: Function, delay: number = 250): Function {\n let shouldWait = false;\n\n return (...args: unknown[]) => {\n if (shouldWait) {\n return;\n }\n\n shouldWait = true;\n setTimeout(() => {\n callback(...args);\n shouldWait = false;\n }, delay);\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nexport function debounce(callback: Function, delay: number = 250, immediate: boolean = false) {\n let timeout: NodeJS.Timeout | null = null;\n\n return (...args: unknown[]) => {\n const later = () => {\n timeout = null;\n if (!immediate) {\n callback(...args);\n }\n };\n\n const callNow = immediate && !timeout;\n clearTimeout(timeout as NodeJS.Timeout);\n timeout = setTimeout(later, delay);\n if (callNow) {\n callback(...args);\n }\n };\n}\n\nexport async function getUserVisitorId(): Promise<string> {\n const uuidFetchCall = await fetch(`${Constants.PUBLIC_URL_ORIGIN}/bduuid`);\n const uuidFetchData: BDUUIDData = await uuidFetchCall.json();\n\n return uuidFetchData.bd_visitor_id;\n}"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@repobit/dex-utils",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "Client for Utils",
|
|
5
5
|
"author": "Constantin Ioan Mihai <iconstantin@bitdefender.com>",
|
|
6
6
|
"homepage": "https://github.com/bitdefender/dex-core#readme",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"type": "module",
|
|
31
31
|
"types": "dist/src/index.d.ts",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@repobit/dex-constants": "^2.
|
|
33
|
+
"@repobit/dex-constants": "^2.1.1",
|
|
34
34
|
"js-cookie": "^3.0.5"
|
|
35
35
|
},
|
|
36
36
|
"volta": {
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/js-cookie": "^3.0.6"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "b5e5567f6d68800a73154c9da2e4a3023eb18945"
|
|
43
43
|
}
|