@repobit/dex-utils 0.3.0 → 0.3.3
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/src/constants.d.ts +13 -0
- package/dist/src/constants.js +22 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/cookies.d.ts +5 -0
- package/dist/src/cookies.js +11 -0
- package/dist/src/cookies.js.map +1 -0
- package/dist/src/index.d.ts +16 -0
- package/dist/src/index.js +12 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/page.d.ts +14 -0
- package/dist/src/page.js +26 -0
- package/dist/src/page.js.map +1 -0
- package/dist/src/typeDefinitions.d.ts +20 -0
- package/dist/src/typeDefinitions.js +1 -0
- package/dist/src/typeDefinitions.js.map +1 -0
- package/dist/src/user-agent/cssua.d.ts +8 -0
- package/dist/src/user-agent/cssua.js +309 -0
- package/dist/src/user-agent/cssua.js.map +1 -0
- package/dist/src/user-agent/index.d.ts +32 -0
- package/dist/src/user-agent/index.js +77 -0
- package/dist/src/user-agent/index.js.map +1 -0
- package/dist/src/user.d.ts +24 -0
- package/dist/src/user.js +120 -0
- package/dist/src/user.js.map +1 -0
- package/dist/src/utils.d.ts +4 -0
- package/dist/src/utils.js +50 -0
- package/dist/src/utils.js.map +1 -0
- package/package.json +10 -25
- package/dist/index.js +0 -12
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const Constants: {
|
|
2
|
+
ADOBE_MC_LOADED: string;
|
|
3
|
+
LAUNCH_URL: string;
|
|
4
|
+
ADOBE_MC_URL_ENV_MAP: Map<string, string>;
|
|
5
|
+
FINGERPRINT_LOCAL_STORAGE_NAME: string;
|
|
6
|
+
NO_FINGERPRINT_COOKIE_NAME: string;
|
|
7
|
+
LOGIN_LOGGED_USER_EXPIRY_COOKIE_NAME: string;
|
|
8
|
+
PUBLIC_URL_ORIGIN: string;
|
|
9
|
+
WWW_ONLY_ORIGIN: string;
|
|
10
|
+
FINGERPRINT_HEADER: string;
|
|
11
|
+
LOGIN_ATTEMPT_SESSION_STORAGE_KEY: string;
|
|
12
|
+
LOGIN_ENDPOINT: string;
|
|
13
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const Constants = {
|
|
2
|
+
ADOBE_MC_LOADED: 'adobe_mc::loaded',
|
|
3
|
+
LAUNCH_URL: 'https://assets.adobedtm.com',
|
|
4
|
+
ADOBE_MC_URL_ENV_MAP: new Map([
|
|
5
|
+
['prod', '8a93f8486ba4/5492896ad67e/launch-b1f76be4d2ee.min.js'],
|
|
6
|
+
['stage', '8a93f8486ba4/5492896ad67e/launch-3e7065dd10db-staging.min.js'],
|
|
7
|
+
['dev', '8a93f8486ba4/5492896ad67e/launch-fbd6d02d30e8-development.min.js']
|
|
8
|
+
]),
|
|
9
|
+
FINGERPRINT_LOCAL_STORAGE_NAME: 'rhvID',
|
|
10
|
+
NO_FINGERPRINT_COOKIE_NAME: 'fgpnoneBD',
|
|
11
|
+
LOGIN_LOGGED_USER_EXPIRY_COOKIE_NAME: 'bdcslue',
|
|
12
|
+
PUBLIC_URL_ORIGIN: ['www.', 'stage.'].some(domain => window.location.hostname.includes(domain))
|
|
13
|
+
? window.location.origin
|
|
14
|
+
: 'https://www.bitdefender.com',
|
|
15
|
+
WWW_ONLY_ORIGIN: window.location.hostname.includes('www.')
|
|
16
|
+
? ''
|
|
17
|
+
: 'https://www.bitdefender.com',
|
|
18
|
+
FINGERPRINT_HEADER: 'BDUSRH_8D053E77FD604F168345E0F77318E993',
|
|
19
|
+
LOGIN_ATTEMPT_SESSION_STORAGE_KEY: 'login-attempt',
|
|
20
|
+
LOGIN_ENDPOINT: '/bin/login/init'
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,eAAe,EAAO,kBAAkB;IACxC,UAAU,EAAY,6BAA6B;IACnD,oBAAoB,EAAE,IAAI,GAAG,CAAC;QAC5B,CAAC,MAAM,EAAE,sDAAsD,CAAC;QAChE,CAAC,OAAO,EAAE,8DAA8D,CAAC;QACzE,CAAC,KAAK,EAAE,kEAAkE,CAAC;KAC5E,CAAC;IACF,8BAA8B,EAAQ,OAAO;IAC7C,0BAA0B,EAAY,WAAW;IACjD,oCAAoC,EAAE,SAAS;IAC/C,iBAAiB,EAAqB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAChH,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM;QACxB,CAAC,CAAC,6BAA6B;IACjC,eAAe,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;QACxD,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,6BAA6B;IACjC,kBAAkB,EAAiB,yCAAyC;IAC5E,iCAAiC,EAAE,eAAe;IAClD,cAAc,EAAqB,iBAAiB;CACrD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as Cookie from "js-cookie";
|
|
2
|
+
const Cookies = Cookie.default;
|
|
3
|
+
Cookies.has = function (name) {
|
|
4
|
+
const cookieChecked = this.get(name);
|
|
5
|
+
if (cookieChecked !== '' && typeof cookieChecked !== 'undefined') {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
return false;
|
|
9
|
+
};
|
|
10
|
+
export default Cookies;
|
|
11
|
+
//# sourceMappingURL=cookies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookies.js","sourceRoot":"","sources":["../../src/cookies.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AAMpC,MAAM,OAAO,GAAG,MAAM,CAAC,OAA4B,CAAC;AACpD,OAAO,CAAC,GAAG,GAAG,UAAS,IAAY;IACjC,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,aAAa,KAAK,EAAE,IAAI,OAAO,aAAa,KAAK,WAAW,EAAE,CAAC;QACjE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Cookies from "./cookies.js";
|
|
2
|
+
import Page from "./page.js";
|
|
3
|
+
import User from "./user.js";
|
|
4
|
+
import UserAgent from "./user-agent/index.js";
|
|
5
|
+
export { Constants } from "./constants.js";
|
|
6
|
+
export { debounce, loadScript, throttle } from "./utils.js";
|
|
7
|
+
export { Cookies, Page, User, UserAgent };
|
|
8
|
+
declare global {
|
|
9
|
+
interface Window {
|
|
10
|
+
BD: {
|
|
11
|
+
Cookies: typeof Cookies;
|
|
12
|
+
User: User;
|
|
13
|
+
UserAgent: UserAgent;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Cookies from "./cookies.js";
|
|
2
|
+
import Page from "./page.js";
|
|
3
|
+
import User from "./user.js";
|
|
4
|
+
import UserAgent from "./user-agent/index.js";
|
|
5
|
+
export { Constants } from "./constants.js";
|
|
6
|
+
export { debounce, loadScript, throttle } from "./utils.js";
|
|
7
|
+
export { Cookies, Page, User, UserAgent };
|
|
8
|
+
window.BD = window.BD || {};
|
|
9
|
+
window.BD.Cookies = Cookies;
|
|
10
|
+
window.BD.User = User;
|
|
11
|
+
window.BD.UserAgent = UserAgent;
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAY1C,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC;AAC5B,MAAM,CAAC,EAAE,CAAC,OAAO,GAAG,OAAO,CAAC;AAC5B,MAAM,CAAC,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC;AACtB,MAAM,CAAC,EAAE,CAAC,SAAS,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This class should hold all the page related information
|
|
3
|
+
*/
|
|
4
|
+
export default class Page {
|
|
5
|
+
country: string;
|
|
6
|
+
language: string;
|
|
7
|
+
locale: `${string}-${string}`;
|
|
8
|
+
name: string;
|
|
9
|
+
queryParams: URLSearchParams;
|
|
10
|
+
environment: 'dev' | 'stage' | 'prod';
|
|
11
|
+
constructor(locale: `${string}-${string}`, name: string, environment: 'dev' | 'stage' | 'prod');
|
|
12
|
+
private getQueryParams;
|
|
13
|
+
getParamValue(key: string): string | null;
|
|
14
|
+
}
|
package/dist/src/page.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This class should hold all the page related information
|
|
3
|
+
*/
|
|
4
|
+
export default class Page {
|
|
5
|
+
country;
|
|
6
|
+
language;
|
|
7
|
+
locale;
|
|
8
|
+
name;
|
|
9
|
+
queryParams;
|
|
10
|
+
environment;
|
|
11
|
+
constructor(locale, name, environment) {
|
|
12
|
+
this.locale = locale;
|
|
13
|
+
this.name = name;
|
|
14
|
+
this.environment = environment;
|
|
15
|
+
this.country = this.locale.split('-')[1];
|
|
16
|
+
this.language = this.locale.split('-')[0];
|
|
17
|
+
this.queryParams = this.getQueryParams();
|
|
18
|
+
}
|
|
19
|
+
getQueryParams() {
|
|
20
|
+
return new URLSearchParams(window.location.search);
|
|
21
|
+
}
|
|
22
|
+
getParamValue(key) {
|
|
23
|
+
return this.queryParams.get(key);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.js","sourceRoot":"","sources":["../../src/page.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,IAAI;IAChB,OAAO,CAAa;IACpB,QAAQ,CAAY;IACpB,MAAM,CAA6B;IACnC,IAAI,CAAgB;IACpB,WAAW,CAAkB;IAC7B,WAAW,CAA2B;IAE7C,YAAY,MAA6B,EAAE,IAAY,EAAE,WAAqC;QAC5F,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACzC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;IAC3C,CAAC;IAEO,cAAc;QACpB,OAAO,IAAI,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC;IAEM,aAAa,CAAC,GAAW;QAC9B,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type ScriptParameters = {
|
|
2
|
+
[key: string]: string;
|
|
3
|
+
};
|
|
4
|
+
export type UserInfoResult = {
|
|
5
|
+
lastname: string;
|
|
6
|
+
firstname: string;
|
|
7
|
+
email: string;
|
|
8
|
+
fingerprint: string;
|
|
9
|
+
};
|
|
10
|
+
export type CssuaUserAgent = {
|
|
11
|
+
desktop: string;
|
|
12
|
+
mobile: string;
|
|
13
|
+
edge: boolean;
|
|
14
|
+
chrome: boolean;
|
|
15
|
+
firefox: boolean;
|
|
16
|
+
safari: boolean;
|
|
17
|
+
vivaldi: boolean;
|
|
18
|
+
ie: boolean;
|
|
19
|
+
opera: boolean;
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=typeDefinitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeDefinitions.js","sourceRoot":"","sources":["../../src/typeDefinitions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
/* eslint-disable no-prototype-builtins */
|
|
3
|
+
/* eslint-disable prefer-const */
|
|
4
|
+
/* eslint-disable no-useless-escape */
|
|
5
|
+
const cssua = (html, userAgent, sa) => {
|
|
6
|
+
'use strict';
|
|
7
|
+
/**
|
|
8
|
+
* @const
|
|
9
|
+
* @type {string}
|
|
10
|
+
*/
|
|
11
|
+
const PREFIX = ' ua-';
|
|
12
|
+
/**
|
|
13
|
+
* @const
|
|
14
|
+
* @type {RegExp}
|
|
15
|
+
*/
|
|
16
|
+
const R_Platform = /\s*([\-\w ]+)[\s\/\:]([\d_]+\b(?:[\-\._\/]\w+)*)/;
|
|
17
|
+
/**
|
|
18
|
+
* @const
|
|
19
|
+
* @type {RegExp}
|
|
20
|
+
*/
|
|
21
|
+
const R_Version = /([\w\-\.]+[\s\/][v]?[\d_]+\b(?:[\-\._\/]\w+)*)/g;
|
|
22
|
+
/**
|
|
23
|
+
* @const
|
|
24
|
+
* @type {RegExp}
|
|
25
|
+
*/
|
|
26
|
+
const R_BlackBerry = /\b(?:(blackberry\w*|bb10)|(rim tablet os))(?:\/(\d+\.\d+(?:\.\w+)*))?/;
|
|
27
|
+
/**
|
|
28
|
+
* @const
|
|
29
|
+
* @type {RegExp}
|
|
30
|
+
*/
|
|
31
|
+
const R_Silk = /\bsilk-accelerated=true\b/;
|
|
32
|
+
/**
|
|
33
|
+
* @const
|
|
34
|
+
* @type {RegExp}
|
|
35
|
+
*/
|
|
36
|
+
const R_FluidApp = /\bfluidapp\b/;
|
|
37
|
+
/**
|
|
38
|
+
* @const
|
|
39
|
+
* @type {RegExp}
|
|
40
|
+
*/
|
|
41
|
+
const R_desktop = /(\bwindows\b|\bmacintosh\b|\blinux\b|\bunix\b)/;
|
|
42
|
+
/**
|
|
43
|
+
* @const
|
|
44
|
+
* @type {RegExp}
|
|
45
|
+
*/
|
|
46
|
+
const R_mobile = /(\bandroid\b|\bipad\b|\bipod\b|\bwindows phone\b|\bwpdesktop\b|\bxblwp7\b|\bzunewp7\b|\bwindows ce\b|\bblackberry\w*|\bbb10\b|\brim tablet os\b|\bmeego|\bwebos\b|\bpalm|\bsymbian|\bj2me\b|\bdocomo\b|\bpda\b|\bchtml\b|\bmidp\b|\bcldc\b|\w*?mobile\w*?|\w*?phone\w*?)/;
|
|
47
|
+
/**
|
|
48
|
+
* @const
|
|
49
|
+
* @type {RegExp}
|
|
50
|
+
*/
|
|
51
|
+
const R_game = /(\bxbox\b|\bplaystation\b|\bnintendo\s+\w+)/;
|
|
52
|
+
/**
|
|
53
|
+
* The root CssUserAgent
|
|
54
|
+
* @type {Object}
|
|
55
|
+
*/
|
|
56
|
+
const cssua = {
|
|
57
|
+
parse:
|
|
58
|
+
/**
|
|
59
|
+
* @param uaStr {string}
|
|
60
|
+
* @return {Object}
|
|
61
|
+
*/
|
|
62
|
+
function (uaStr, sa) {
|
|
63
|
+
/**
|
|
64
|
+
* @type {Object}
|
|
65
|
+
*/
|
|
66
|
+
const ua = {};
|
|
67
|
+
if (sa) {
|
|
68
|
+
ua.standalone = sa;
|
|
69
|
+
}
|
|
70
|
+
uaStr = ('' + uaStr).toLowerCase();
|
|
71
|
+
if (!uaStr) {
|
|
72
|
+
return ua;
|
|
73
|
+
}
|
|
74
|
+
let i, count, raw = uaStr.split(/[()]/);
|
|
75
|
+
for (let j = 0, rawCount = raw.length; j < rawCount; j++) {
|
|
76
|
+
if (j % 2) {
|
|
77
|
+
// inside parens covers platform identifiers
|
|
78
|
+
const platforms = raw[j].split(';');
|
|
79
|
+
for (i = 0, count = platforms.length; i < count; i++) {
|
|
80
|
+
if (R_Platform.exec(platforms[i])) {
|
|
81
|
+
const key = RegExp.$1.split(' ').join('_'), val = RegExp.$2;
|
|
82
|
+
// if duplicate entries favor highest version
|
|
83
|
+
if ((!ua[key] || parseFloat(ua[key]) < parseFloat(val))) {
|
|
84
|
+
ua[key] = val;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
// outside parens covers most version identifiers
|
|
91
|
+
const uas = raw[j].match(R_Version);
|
|
92
|
+
if (uas) {
|
|
93
|
+
for (i = 0, count = uas.length; i < count; i++) {
|
|
94
|
+
const parts = uas[i].split(/[\/\s]+/);
|
|
95
|
+
if (parts.length && parts[0] !== 'mozilla') {
|
|
96
|
+
ua[parts[0].split(' ').join('_')] = parts.slice(1).join('-');
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (R_mobile.exec(uaStr)) {
|
|
103
|
+
// mobile device indicators
|
|
104
|
+
ua.mobile = RegExp.$1;
|
|
105
|
+
if (R_BlackBerry.exec(uaStr)) {
|
|
106
|
+
delete ua[ua.mobile];
|
|
107
|
+
ua.blackberry = ua.version || RegExp.$3 || RegExp.$2 || RegExp.$1;
|
|
108
|
+
if (RegExp.$1) {
|
|
109
|
+
// standardize non-tablet blackberry
|
|
110
|
+
ua.mobile = 'blackberry';
|
|
111
|
+
}
|
|
112
|
+
else if (ua.version === '0.0.1') {
|
|
113
|
+
// fix playbook 1.0 quirk
|
|
114
|
+
ua.blackberry = '7.1.0.0';
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else if (R_game.exec(uaStr)) {
|
|
119
|
+
// game console indicators
|
|
120
|
+
ua.game = RegExp.$1;
|
|
121
|
+
const game = ua.game.split(' ').join('_');
|
|
122
|
+
if (ua.version && !ua[game]) {
|
|
123
|
+
ua[game] = ua.version;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else if (R_desktop.exec(uaStr)) {
|
|
127
|
+
// desktop OS indicators
|
|
128
|
+
ua.desktop = RegExp.$1;
|
|
129
|
+
}
|
|
130
|
+
// platform naming standardizations
|
|
131
|
+
if (ua.intel_mac_os_x) {
|
|
132
|
+
ua.mac_os_x = ua.intel_mac_os_x.split('_').join('.');
|
|
133
|
+
delete ua.intel_mac_os_x;
|
|
134
|
+
}
|
|
135
|
+
else if (ua.cpu_iphone_os) {
|
|
136
|
+
ua.ios = ua.cpu_iphone_os.split('_').join('.');
|
|
137
|
+
delete ua.cpu_iphone_os;
|
|
138
|
+
}
|
|
139
|
+
else if (ua.cpu_os) {
|
|
140
|
+
ua.ios = ua.cpu_os.split('_').join('.');
|
|
141
|
+
delete ua.cpu_os;
|
|
142
|
+
}
|
|
143
|
+
else if (ua.mobile === 'iphone' && !ua.ios) {
|
|
144
|
+
ua.ios = '1';
|
|
145
|
+
}
|
|
146
|
+
// UA naming standardizations
|
|
147
|
+
if (ua.opera && ua.version) {
|
|
148
|
+
ua.opera = ua.version;
|
|
149
|
+
// version/XXX refers to opera
|
|
150
|
+
delete ua.blackberry;
|
|
151
|
+
}
|
|
152
|
+
else if (R_Silk.exec(uaStr)) {
|
|
153
|
+
ua.silk_accelerated = true;
|
|
154
|
+
}
|
|
155
|
+
else if (R_FluidApp.exec(uaStr)) {
|
|
156
|
+
ua.fluidapp = ua.version;
|
|
157
|
+
}
|
|
158
|
+
if (ua.edge) {
|
|
159
|
+
delete ua.applewebkit;
|
|
160
|
+
delete ua.safari;
|
|
161
|
+
delete ua.chrome;
|
|
162
|
+
delete ua.android;
|
|
163
|
+
}
|
|
164
|
+
if (ua.applewebkit) {
|
|
165
|
+
ua.webkit = ua.applewebkit;
|
|
166
|
+
delete ua.applewebkit;
|
|
167
|
+
if (ua.opr) {
|
|
168
|
+
ua.opera = ua.opr;
|
|
169
|
+
delete ua.opr;
|
|
170
|
+
delete ua.chrome;
|
|
171
|
+
}
|
|
172
|
+
if (ua.safari) {
|
|
173
|
+
if (ua.chrome || ua.crios || ua.fxios || ua.opera || ua.silk || ua.fluidapp || ua.phantomjs || (ua.mobile && !ua.ios)) {
|
|
174
|
+
delete ua.safari;
|
|
175
|
+
if (ua.vivaldi) {
|
|
176
|
+
delete ua.chrome;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
else if (ua.version && !ua.rim_tablet_os) {
|
|
180
|
+
ua.safari = ua.version;
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
ua.safari = ({
|
|
184
|
+
'419': '2.0.4',
|
|
185
|
+
'417': '2.0.3',
|
|
186
|
+
'416': '2.0.2',
|
|
187
|
+
'412': '2.0',
|
|
188
|
+
'312': '1.3',
|
|
189
|
+
'125': '1.2',
|
|
190
|
+
'85': '1.0'
|
|
191
|
+
})[parseInt(ua.safari, 10)] || ua.safari;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
else if (ua.msie || ua.trident) {
|
|
196
|
+
if (!ua.opera) {
|
|
197
|
+
// standardize Internet Explorer
|
|
198
|
+
ua.ie = ua.msie || ua.rv;
|
|
199
|
+
}
|
|
200
|
+
delete ua.msie;
|
|
201
|
+
delete ua.android;
|
|
202
|
+
if (ua.windows_phone_os) {
|
|
203
|
+
// standardize window phone
|
|
204
|
+
ua.windows_phone = ua.windows_phone_os;
|
|
205
|
+
delete ua.windows_phone_os;
|
|
206
|
+
}
|
|
207
|
+
else if (ua.mobile === 'wpdesktop' || ua.mobile === 'xblwp7' || ua.mobile === 'zunewp7') {
|
|
208
|
+
ua.mobile = 'windows desktop';
|
|
209
|
+
ua.windows_phone = (+ua.ie < 9) ? '7.0' : (+ua.ie < 10) ? '7.5' : '8.0';
|
|
210
|
+
delete ua.windows_nt;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
else if (ua.gecko || ua.firefox) {
|
|
214
|
+
ua.gecko = ua.rv;
|
|
215
|
+
}
|
|
216
|
+
if (ua.rv) {
|
|
217
|
+
delete ua.rv;
|
|
218
|
+
}
|
|
219
|
+
if (ua.version) {
|
|
220
|
+
delete ua.version;
|
|
221
|
+
}
|
|
222
|
+
return ua;
|
|
223
|
+
},
|
|
224
|
+
format:
|
|
225
|
+
/**
|
|
226
|
+
* @param ua {Object}
|
|
227
|
+
* @return {string}
|
|
228
|
+
*/
|
|
229
|
+
function (ua) {
|
|
230
|
+
/**
|
|
231
|
+
* @param b {string} browser key
|
|
232
|
+
* @param v {string} browser value
|
|
233
|
+
* @return {string} formatted CSS classes
|
|
234
|
+
*/
|
|
235
|
+
function format(b, v) {
|
|
236
|
+
b = b.split('.').join('-');
|
|
237
|
+
/**
|
|
238
|
+
* @type {string}
|
|
239
|
+
*/
|
|
240
|
+
let css = PREFIX + b;
|
|
241
|
+
if (typeof v === 'string') {
|
|
242
|
+
v = v.split(' ').join('_')
|
|
243
|
+
.split('.')
|
|
244
|
+
.join('-');
|
|
245
|
+
let i = v.indexOf('-');
|
|
246
|
+
while (i > 0) {
|
|
247
|
+
// loop through chopping last '-' to end off
|
|
248
|
+
// concat result onto return string
|
|
249
|
+
css += PREFIX + b + '-' + v.substring(0, i);
|
|
250
|
+
i = v.indexOf('-', i + 1);
|
|
251
|
+
}
|
|
252
|
+
css += PREFIX + b + '-' + v;
|
|
253
|
+
}
|
|
254
|
+
return css;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* @type {string}
|
|
258
|
+
*/
|
|
259
|
+
let uaCss = '';
|
|
260
|
+
for (const b in ua) {
|
|
261
|
+
if (b && ua.hasOwnProperty(b)) {
|
|
262
|
+
uaCss += format(b, ua[b]);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
// user-agent classNames
|
|
266
|
+
return uaCss;
|
|
267
|
+
},
|
|
268
|
+
encode:
|
|
269
|
+
/**
|
|
270
|
+
* Encodes parsed userAgent object as a compact URI-Encoded key-value collection
|
|
271
|
+
* @param ua {Object}
|
|
272
|
+
* @return {string}
|
|
273
|
+
*/
|
|
274
|
+
function (ua) {
|
|
275
|
+
let query = '';
|
|
276
|
+
for (const b in ua) {
|
|
277
|
+
if (b && ua.hasOwnProperty(b)) {
|
|
278
|
+
if (query) {
|
|
279
|
+
query += '&';
|
|
280
|
+
}
|
|
281
|
+
query += encodeURIComponent(b) + '=' + encodeURIComponent(ua[b]);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return query;
|
|
285
|
+
},
|
|
286
|
+
userAgent: {},
|
|
287
|
+
ua: {}
|
|
288
|
+
};
|
|
289
|
+
/**
|
|
290
|
+
* @const
|
|
291
|
+
* @type {Object}
|
|
292
|
+
*/
|
|
293
|
+
cssua.userAgent = cssua.ua = cssua.parse(userAgent, sa);
|
|
294
|
+
/**
|
|
295
|
+
* @const
|
|
296
|
+
* @type {string}
|
|
297
|
+
*/
|
|
298
|
+
const ua = cssua.format(cssua.ua) + ' js';
|
|
299
|
+
// append CSS classes to HTML node
|
|
300
|
+
if (html.className) {
|
|
301
|
+
html.className = html.className.replace(/\bno-js\b/g, '') + ua;
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
html.className = ua.substr(1);
|
|
305
|
+
}
|
|
306
|
+
return cssua;
|
|
307
|
+
};
|
|
308
|
+
export default cssua(document.documentElement, navigator.userAgent, navigator.standalone);
|
|
309
|
+
//# sourceMappingURL=cssua.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cssua.js","sourceRoot":"","sources":["../../../src/user-agent/cssua.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,0CAA0C;AAC1C,iCAAiC;AACjC,sCAAsC;AAEtC,MAAM,KAAK,GAAG,CAAC,IAAiB,EAAE,SAAiB,EAAE,EAAO,EAAE,EAAE;IAC9D,YAAY,CAAC;IAEb;;;SAGK;IACL,MAAM,MAAM,GAAG,MAAM,CAAC;IAEtB;;;SAGK;IACL,MAAM,UAAU,GAAG,kDAAkD,CAAC;IAEtE;;;SAGK;IACL,MAAM,SAAS,GAAG,iDAAiD,CAAC;IAEpE;;;SAGK;IACL,MAAM,YAAY,GAAG,uEAAuE,CAAC;IAE7F;;;SAGK;IACL,MAAM,MAAM,GAAG,2BAA2B,CAAC;IAE3C;;;SAGK;IACL,MAAM,UAAU,GAAG,cAAc,CAAC;IAElC;;;SAGK;IACL,MAAM,SAAS,GAAG,gDAAgD,CAAC;IAEnE;;;SAGK;IACL,MAAM,QAAQ,GAAG,0QAA0Q,CAAC;IAE5R;;;SAGK;IACL,MAAM,MAAM,GAAG,6CAA6C,CAAC;IAE7D;;;SAGK;IACL,MAAM,KAAK,GAAG;QAEZ,KAAK;QACG;;;WAGG;QACH,UAAS,KAAa,EAAE,EAAO;YAE7B;;iBAEK;YACL,MAAM,EAAE,GAAQ,EAAE,CAAC;YACnB,IAAI,EAAE,EAAE,CAAC;gBACP,EAAE,CAAC,UAAU,GAAG,EAAE,CAAC;YACrB,CAAC;YAED,KAAK,GAAG,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;YACnC,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,OAAO,EAAE,CAAC;YACZ,CAAC;YAED,IAAI,CAAC,EAAE,KAAK,EAAE,G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AE,GAAG,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAExD;;;SAGK;IACL,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC;IAE1C,kCAAkC;IAClC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC;IAEjE,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,KAAK,CAAC;AAEf,CAAC,CAAA;AACD,eAAe,KAAK,CAAC,QAAQ,CAAC,eAAe,EAAE,SAAS,CAAC,SAAS,EAAG,SAAiB,CAAC,UAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export default abstract class UserAgent {
|
|
2
|
+
private static cssuaUserAgent;
|
|
3
|
+
static get windows(): string;
|
|
4
|
+
static get macos(): string;
|
|
5
|
+
static get ios(): string;
|
|
6
|
+
static get android(): string;
|
|
7
|
+
static get linux(): string;
|
|
8
|
+
static get edge(): string;
|
|
9
|
+
static get chrome(): string;
|
|
10
|
+
static get firefox(): string;
|
|
11
|
+
static get safari(): string;
|
|
12
|
+
static get opera(): string;
|
|
13
|
+
static get ie(): string;
|
|
14
|
+
static get vivaldi(): string;
|
|
15
|
+
static get isWindows(): boolean;
|
|
16
|
+
static get isMacos(): boolean;
|
|
17
|
+
static get isLinux(): boolean;
|
|
18
|
+
static get isUnix(): boolean;
|
|
19
|
+
static get isAndroid(): boolean;
|
|
20
|
+
static get isIos(): boolean;
|
|
21
|
+
static get isDesktop(): boolean;
|
|
22
|
+
static get isMobile(): boolean;
|
|
23
|
+
static get isEdge(): boolean;
|
|
24
|
+
static get isChrome(): boolean;
|
|
25
|
+
static get isFirefox(): boolean;
|
|
26
|
+
static get isSafari(): boolean;
|
|
27
|
+
static get isOpera(): boolean;
|
|
28
|
+
static get isVivaldi(): boolean;
|
|
29
|
+
static get isIe(): boolean;
|
|
30
|
+
static get os(): string | undefined;
|
|
31
|
+
static get browser(): string | undefined;
|
|
32
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import cssua from "./cssua.js";
|
|
2
|
+
export default class UserAgent {
|
|
3
|
+
// typed cssua User Agent
|
|
4
|
+
static cssuaUserAgent = cssua.userAgent;
|
|
5
|
+
// OS
|
|
6
|
+
static get windows() { return "Windows"; }
|
|
7
|
+
static get macos() { return "Mac/iOS"; }
|
|
8
|
+
static get ios() { return "ios"; }
|
|
9
|
+
static get android() { return "android"; }
|
|
10
|
+
static get linux() { return "Linux"; }
|
|
11
|
+
// Browsers
|
|
12
|
+
static get edge() { return "edge"; }
|
|
13
|
+
static get chrome() { return "chrome"; }
|
|
14
|
+
static get firefox() { return "firefox"; }
|
|
15
|
+
static get safari() { return "safari"; }
|
|
16
|
+
static get opera() { return "opera"; }
|
|
17
|
+
static get ie() { return "ie"; }
|
|
18
|
+
static get vivaldi() { return "vivaldi"; }
|
|
19
|
+
// OS logic
|
|
20
|
+
static get isWindows() { return this.cssuaUserAgent.desktop === "windows"; }
|
|
21
|
+
static get isMacos() { return this.cssuaUserAgent.desktop === "macintosh"; }
|
|
22
|
+
static get isLinux() { return this.cssuaUserAgent.desktop === "linux"; }
|
|
23
|
+
static get isUnix() { return this.cssuaUserAgent.desktop === "unix"; }
|
|
24
|
+
static get isAndroid() { return this.cssuaUserAgent.mobile === "android"; }
|
|
25
|
+
static get isIos() { return this.cssuaUserAgent.mobile === "iphone" || this.cssuaUserAgent.mobile === "ipad"; }
|
|
26
|
+
static get isDesktop() { return this.isWindows || this.isMacos; }
|
|
27
|
+
static get isMobile() { return this.isAndroid || this.isIos; }
|
|
28
|
+
// Browser logic
|
|
29
|
+
static get isEdge() { return this.cssuaUserAgent.edge; }
|
|
30
|
+
static get isChrome() { return this.cssuaUserAgent.chrome; }
|
|
31
|
+
static get isFirefox() { return this.cssuaUserAgent.firefox; }
|
|
32
|
+
static get isSafari() { return this.cssuaUserAgent.safari; }
|
|
33
|
+
static get isOpera() { return this.cssuaUserAgent.opera; }
|
|
34
|
+
static get isVivaldi() { return this.cssuaUserAgent.vivaldi; }
|
|
35
|
+
static get isIe() { return this.cssuaUserAgent.ie; }
|
|
36
|
+
static get os() {
|
|
37
|
+
if (this.isWindows) {
|
|
38
|
+
return this.windows;
|
|
39
|
+
}
|
|
40
|
+
if (this.isMacos) {
|
|
41
|
+
return this.macos;
|
|
42
|
+
}
|
|
43
|
+
if (this.isAndroid) {
|
|
44
|
+
return this.android;
|
|
45
|
+
}
|
|
46
|
+
if (this.isIos) {
|
|
47
|
+
return this.ios;
|
|
48
|
+
}
|
|
49
|
+
if (this.isLinux || this.isUnix) {
|
|
50
|
+
return this.linux;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
static get browser() {
|
|
54
|
+
if (this.isEdge) {
|
|
55
|
+
return this.edge;
|
|
56
|
+
}
|
|
57
|
+
if (this.isChrome) {
|
|
58
|
+
return this.chrome;
|
|
59
|
+
}
|
|
60
|
+
if (this.isFirefox) {
|
|
61
|
+
return this.firefox;
|
|
62
|
+
}
|
|
63
|
+
if (this.isSafari) {
|
|
64
|
+
return this.safari;
|
|
65
|
+
}
|
|
66
|
+
if (this.isOpera) {
|
|
67
|
+
return this.opera;
|
|
68
|
+
}
|
|
69
|
+
if (this.isVivaldi) {
|
|
70
|
+
return this.vivaldi;
|
|
71
|
+
}
|
|
72
|
+
if (this.isIe) {
|
|
73
|
+
return this.ie;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/user-agent/index.ts"],"names":[],"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;QAC5C,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAAC,OAAO,IAAI,CAAC,KAAK,CAAC;QAAC,CAAC;QACxC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YAAC,OAAO,IAAI,CAAC,OAAO,CAAC;QAAC,CAAC;QAC5C,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAAC,OAAO,IAAI,CAAC,GAAG,CAAC;QAAC,CAAC;QACpC,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,MAAM,EAAG,CAAC;YAAC,OAAO,IAAI,CAAC,KAAK,CAAC;QAAC,CAAC;IAC1D,CAAC;IAED,MAAM,KAAK,OAAO;QAChB,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAAC,OAAO,IAAI,CAAC,IAAI,CAAC;QAAC,CAAC;QACtC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAAC,OAAO,IAAI,CAAC,MAAM,CAAC;QAAC,CAAC;QAC1C,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YAAC,OAAO,IAAI,CAAC,OAAO,CAAC;QAAC,CAAC;QAC5C,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAAC,OAAO,IAAI,CAAC,MAAM,CAAC;QAAC,CAAC;QAC1C,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAAC,OAAO,IAAI,CAAC,KAAK,CAAC;QAAC,CAAC;QACxC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YAAC,OAAO,IAAI,CAAC,OAAO,CAAC;QAAC,CAAC;QAC5C,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAAC,OAAO,IAAI,CAAC,EAAE,CAAC;QAAC,CAAC;IAEpC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { UserInfoResult } from "./typeDefinitions.js";
|
|
2
|
+
export default abstract class User {
|
|
3
|
+
private static _info;
|
|
4
|
+
private static _fingerprint;
|
|
5
|
+
private static _country;
|
|
6
|
+
private static _locale;
|
|
7
|
+
private static staticInitialise;
|
|
8
|
+
private static getFingerprint;
|
|
9
|
+
/**
|
|
10
|
+
* Handling User Geolocation
|
|
11
|
+
* This wil fetch the user's country
|
|
12
|
+
*/
|
|
13
|
+
private static getGeolocation;
|
|
14
|
+
/** Getting the User's Locale */
|
|
15
|
+
private static getUserLocale;
|
|
16
|
+
/** attempt to log the user in.
|
|
17
|
+
* You can access it from the mega menu if it is imported.
|
|
18
|
+
* If the login fails, this operation will not be permited in the same tab session. */
|
|
19
|
+
static login(): Promise<void>;
|
|
20
|
+
static get info(): Promise<UserInfoResult | null>;
|
|
21
|
+
static get fingerprint(): Promise<string | null>;
|
|
22
|
+
static get country(): Promise<string>;
|
|
23
|
+
static get locale(): Promise<`${string}-${string}`>;
|
|
24
|
+
}
|
package/dist/src/user.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { Constants } from "./constants.js";
|
|
2
|
+
import Cookies from "./cookies.js";
|
|
3
|
+
import UserAgent from "./user-agent/index.js";
|
|
4
|
+
export default class User {
|
|
5
|
+
static _info = this.staticInitialise();
|
|
6
|
+
static _fingerprint = this.getFingerprint();
|
|
7
|
+
static _country = this.getGeolocation();
|
|
8
|
+
static _locale = this.getUserLocale();
|
|
9
|
+
static async staticInitialise() {
|
|
10
|
+
if (!Cookies.has(Constants.LOGIN_LOGGED_USER_EXPIRY_COOKIE_NAME)) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
const userDataResponse = await fetch(`${Constants.PUBLIC_URL_ORIGIN}/bin/login/userInfo.json`);
|
|
15
|
+
return userDataResponse.ok ? (await userDataResponse.json()).result : null;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
static async getFingerprint() {
|
|
22
|
+
// Try to grab the fingeprint from localstoraage
|
|
23
|
+
const storageFingerprint = localStorage.getItem(Constants.FINGERPRINT_LOCAL_STORAGE_NAME);
|
|
24
|
+
if (storageFingerprint) {
|
|
25
|
+
return storageFingerprint;
|
|
26
|
+
}
|
|
27
|
+
// Try to grab fingerprint from login data
|
|
28
|
+
const userInfo = await this._info;
|
|
29
|
+
if (userInfo) {
|
|
30
|
+
localStorage.setItem(Constants.FINGERPRINT_LOCAL_STORAGE_NAME, userInfo.fingerprint);
|
|
31
|
+
return userInfo.fingerprint;
|
|
32
|
+
}
|
|
33
|
+
// Try to grab fingerprint from dummyPost (from user local antivirus instance)
|
|
34
|
+
const fingerprintNotExist = Cookies.has(Constants.NO_FINGERPRINT_COOKIE_NAME);
|
|
35
|
+
if (!fingerprintNotExist && UserAgent.isWindows) {
|
|
36
|
+
try {
|
|
37
|
+
const fingerprintReq = await fetch(`${Constants.WWW_ONLY_ORIGIN}/site/Main/dummyPost?${Math.random()}`, {
|
|
38
|
+
method: "POST",
|
|
39
|
+
headers: {
|
|
40
|
+
"Content-type": "application/x-www-form-urlencoded",
|
|
41
|
+
"Pragma": "no-cache",
|
|
42
|
+
"Cache-Control": "no-store, no-cache, must-revalidate, max-age=0",
|
|
43
|
+
"Expires": "Tue, 01 Jan 1971 02:00:00 GMT",
|
|
44
|
+
"BDUS_A312C09A2666456D9F2B2AA5D6B463D6": "check.bitdefender"
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
if (fingerprintReq.ok && fingerprintReq.headers.has(Constants.FINGERPRINT_HEADER)) {
|
|
48
|
+
const fingerprint = fingerprintReq.headers.get(Constants.FINGERPRINT_HEADER);
|
|
49
|
+
localStorage.setItem(Constants.FINGERPRINT_LOCAL_STORAGE_NAME, fingerprint);
|
|
50
|
+
return fingerprint;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
Cookies.set(Constants.NO_FINGERPRINT_COOKIE_NAME, "true", { expires: 1 });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch { /* empty */ }
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Handling User Geolocation
|
|
62
|
+
* This wil fetch the user's country
|
|
63
|
+
*/
|
|
64
|
+
static async getGeolocation() {
|
|
65
|
+
try {
|
|
66
|
+
const response = await fetch(`${Constants.PUBLIC_URL_ORIGIN}/geoip`);
|
|
67
|
+
if (!response.ok) {
|
|
68
|
+
return "us";
|
|
69
|
+
}
|
|
70
|
+
const country = await response.json();
|
|
71
|
+
if (country.error_code) {
|
|
72
|
+
return "us";
|
|
73
|
+
}
|
|
74
|
+
return country["country"].toLowerCase();
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return "us";
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** Getting the User's Locale */
|
|
81
|
+
static async getUserLocale() {
|
|
82
|
+
const userCountry = await this._country;
|
|
83
|
+
try {
|
|
84
|
+
const userGeoIpCall = await fetch(`${Constants.WWW_ONLY_ORIGIN}/p-api/v1/countries/${userCountry.toUpperCase()}/locales`);
|
|
85
|
+
const userGeoIpData = await userGeoIpCall.json();
|
|
86
|
+
return userGeoIpData[0].locale.toLowerCase();
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return "en-us";
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** attempt to log the user in.
|
|
93
|
+
* You can access it from the mega menu if it is imported.
|
|
94
|
+
* If the login fails, this operation will not be permited in the same tab session. */
|
|
95
|
+
static async login() {
|
|
96
|
+
const loginAttempt = sessionStorage.getItem(Constants.LOGIN_ATTEMPT_SESSION_STORAGE_KEY);
|
|
97
|
+
const userData = await this._info;
|
|
98
|
+
const userLoggedInExpirationDate = Number(Cookies.get(Constants.LOGIN_LOGGED_USER_EXPIRY_COOKIE_NAME)) || 0;
|
|
99
|
+
if (!loginAttempt && !userData
|
|
100
|
+
&& userLoggedInExpirationDate > Date.now()) {
|
|
101
|
+
sessionStorage.setItem(Constants.LOGIN_ATTEMPT_SESSION_STORAGE_KEY, 'true');
|
|
102
|
+
const loginEndpointUrl = new URL(`${Constants.PUBLIC_URL_ORIGIN}${Constants.LOGIN_ENDPOINT}`);
|
|
103
|
+
loginEndpointUrl.searchParams.set('origin', `${window.location.pathname}${window.location.search}`);
|
|
104
|
+
window.location.href = loginEndpointUrl.href;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
static get info() {
|
|
108
|
+
return this._info;
|
|
109
|
+
}
|
|
110
|
+
static get fingerprint() {
|
|
111
|
+
return this._fingerprint;
|
|
112
|
+
}
|
|
113
|
+
static get country() {
|
|
114
|
+
return this._country;
|
|
115
|
+
}
|
|
116
|
+
static get locale() {
|
|
117
|
+
return this._locale;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,MAAM,CAAC,OAAO,OAAgB,IAAI;IAExB,MAAM,CAAC,KAAK,GAA0C,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAC9E,MAAM,CAAC,YAAY,GAA2B,IAAI,CAAC,cAAc,EAAE,CAAC;IACpE,MAAM,CAAC,QAAQ,GAAwB,IAAI,CAAC,cAAc,EAAE,CAAC;IAC7D,MAAM,CAAC,OAAO,GAAwC,IAAI,CAAC,aAAa,EAAE,CAAC;IAE3E,MAAM,CAAC,KAAK,CAAC,gBAAgB;QACnC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,oCAAoC,CAAC,EAAE,CAAC;YACjE,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,CAAC;YACH,MAAM,gBAAgB,GAAG,MAAM,KAAK,CAAC,GAAG,SAAS,CAAC,iBAAiB,0B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AM,KAAK,OAAO;QACvB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAEM,MAAM,KAAK,MAAM;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ScriptParameters } from "./typeDefinitions.js";
|
|
2
|
+
export declare function loadScript(src: string, attrs?: ScriptParameters): Promise<void>;
|
|
3
|
+
export declare function throttle(callback: Function, delay?: number): Function;
|
|
4
|
+
export declare function debounce(callback: Function, delay?: number, immediate?: boolean): (...args: unknown[]) => void;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export async function loadScript(src, attrs = {}) {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
if (!document.querySelector(`head > script[src="${src}"]`)) {
|
|
4
|
+
const script = document.createElement('script');
|
|
5
|
+
script.src = src;
|
|
6
|
+
for (const attr in attrs) {
|
|
7
|
+
script.setAttribute(attr, attrs[attr]);
|
|
8
|
+
}
|
|
9
|
+
script.onload = () => resolve();
|
|
10
|
+
script.onerror = reject;
|
|
11
|
+
document.head.append(script);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
resolve();
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
19
|
+
export function throttle(callback, delay = 250) {
|
|
20
|
+
let shouldWait = false;
|
|
21
|
+
return (...args) => {
|
|
22
|
+
if (shouldWait) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
shouldWait = true;
|
|
26
|
+
setTimeout(() => {
|
|
27
|
+
callback(...args);
|
|
28
|
+
shouldWait = false;
|
|
29
|
+
}, delay);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
33
|
+
export function debounce(callback, delay = 250, immediate = false) {
|
|
34
|
+
let timeout = null;
|
|
35
|
+
return (...args) => {
|
|
36
|
+
const later = () => {
|
|
37
|
+
timeout = null;
|
|
38
|
+
if (!immediate) {
|
|
39
|
+
callback(...args);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const callNow = immediate && !timeout;
|
|
43
|
+
clearTimeout(timeout);
|
|
44
|
+
timeout = setTimeout(later, delay);
|
|
45
|
+
if (callNow) {
|
|
46
|
+
callback(...args);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAW,EAAE,QAA0B,EAAE;IACxE,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"}
|
package/package.json
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@repobit/dex-utils",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
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",
|
|
7
7
|
"license": "ISC",
|
|
8
|
-
"main": "dist/index.js",
|
|
9
|
-
"directories": {
|
|
10
|
-
"src": "src",
|
|
11
|
-
"test": "__tests__"
|
|
12
|
-
},
|
|
8
|
+
"main": "dist/src/index.js",
|
|
13
9
|
"files": [
|
|
14
|
-
"
|
|
10
|
+
"dist/src"
|
|
15
11
|
],
|
|
16
12
|
"publishConfig": {
|
|
17
13
|
"access": "public"
|
|
@@ -21,34 +17,23 @@
|
|
|
21
17
|
"url": "git+https://github.com/bitdefender/dex-core.git"
|
|
22
18
|
},
|
|
23
19
|
"scripts": {
|
|
24
|
-
"build": "tsc -
|
|
20
|
+
"build": "tsc && tsc-alias",
|
|
25
21
|
"test": "jest --passWithNoTests"
|
|
26
22
|
},
|
|
27
23
|
"bugs": {
|
|
28
24
|
"url": "https://github.com/bitdefender/dex-core/issues"
|
|
29
25
|
},
|
|
30
|
-
"module": "dist/index.js",
|
|
26
|
+
"module": "dist/src/index.js",
|
|
31
27
|
"type": "module",
|
|
32
|
-
"types": "dist/index.d.ts",
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"@eslint/js": "^9.19.0",
|
|
35
|
-
"@stylistic/eslint-plugin": "^3.0.1",
|
|
36
|
-
"@types/jest": "^29.5.14",
|
|
37
|
-
"@types/js-cookie": "^3.0.6",
|
|
38
|
-
"eslint": "^9.19.0",
|
|
39
|
-
"globals": "^15.14.0",
|
|
40
|
-
"jest": "^29.7.0",
|
|
41
|
-
"jiti": "^2.4.2",
|
|
42
|
-
"ts-jest": "^29.2.5",
|
|
43
|
-
"ts-node": "^10.9.2",
|
|
44
|
-
"typescript": "^5.7.3",
|
|
45
|
-
"typescript-eslint": "^8.23.0"
|
|
46
|
-
},
|
|
28
|
+
"types": "dist/src/index.d.ts",
|
|
47
29
|
"dependencies": {
|
|
48
30
|
"js-cookie": "^3.0.5"
|
|
49
31
|
},
|
|
50
32
|
"volta": {
|
|
51
33
|
"node": "22.14.0"
|
|
52
34
|
},
|
|
53
|
-
"
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/js-cookie": "^3.0.6"
|
|
37
|
+
},
|
|
38
|
+
"gitHead": "f9220c88046a8ba9402ec2d19ecf4888e0af8b5a"
|
|
54
39
|
}
|
package/dist/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import Cookies from "./cookies";
|
|
2
|
-
import Page from "./page";
|
|
3
|
-
import User from "./user";
|
|
4
|
-
import UserAgent from "./user-agent";
|
|
5
|
-
export { Constants } from "./constants";
|
|
6
|
-
export { debounce, loadScript, throttle } from "./utils";
|
|
7
|
-
export { Cookies, Page, User, UserAgent };
|
|
8
|
-
window.BD = window.BD || {};
|
|
9
|
-
window.BD.Cookies = Cookies;
|
|
10
|
-
window.BD.User = User;
|
|
11
|
-
window.BD.UserAgent = UserAgent;
|
|
12
|
-
//# sourceMappingURL=index.js.map
|