arn-browser 0.0.3 → 0.0.5
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/README.md +3 -2
- package/package.json +31 -47
- package/src/all_routes/routeWithSuperagent.d.ts +67 -0
- package/src/all_routes/routeWithSuperagent.js +322 -0
- package/src/human-cursor/HumanCursor.js +448 -0
- package/src/human-cursor/bezier.js +248 -0
- package/src/human-cursor/index.d.ts +154 -0
- package/src/human-cursor/index.js +9 -0
- package/src/human-cursor/randomizer.js +149 -0
- package/src/human-cursor/tweening.js +260 -0
- package/src/index.d.ts +19 -0
- package/src/index.js +15 -0
- package/src/others/totp-generator.d.ts +15 -0
- package/src/others/totp-generator.js +86 -0
- package/src/utility/deleteDirectory.js +105 -0
- package/src/utility/launchBrowser.d.ts +248 -0
- package/src/utility/launchBrowser.js +899 -0
- package/src/utility/multilogin_token_manager.js +164 -0
- package/src/utility/playwright-helper.d.ts +61 -0
- package/src/utility/playwright-helper.js +129 -0
- package/src/utility/proxy-utility/custom-proxy.d.ts +93 -0
- package/src/utility/proxy-utility/custom-proxy.js +625 -0
- package/src/utility/proxy-utility/proxy-chain.d.ts +123 -0
- package/src/utility/proxy-utility/proxy-chain.js +337 -0
- package/src/utility/proxy-utility/proxy-helper.d.ts +91 -0
- package/src/utility/proxy-utility/proxy-helper.js +222 -0
- package/dist/__main__.d.ts +0 -2
- package/dist/__main__.js +0 -127
- package/dist/__version__.d.ts +0 -11
- package/dist/__version__.js +0 -16
- package/dist/addons.d.ts +0 -17
- package/dist/addons.js +0 -70
- package/dist/data-files/territoryInfo.xml +0 -2024
- package/dist/data-files/webgl_data.db +0 -0
- package/dist/exceptions.d.ts +0 -76
- package/dist/exceptions.js +0 -153
- package/dist/fingerprints.d.ts +0 -4
- package/dist/fingerprints.js +0 -82
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -3
- package/dist/ip.d.ts +0 -25
- package/dist/ip.js +0 -90
- package/dist/locale.d.ts +0 -26
- package/dist/locale.js +0 -280
- package/dist/mappings/browserforge.config.d.ts +0 -47
- package/dist/mappings/browserforge.config.js +0 -72
- package/dist/mappings/fonts.config.d.ts +0 -6
- package/dist/mappings/fonts.config.js +0 -822
- package/dist/mappings/warnings.config.d.ts +0 -16
- package/dist/mappings/warnings.config.js +0 -28
- package/dist/pkgman.d.ts +0 -62
- package/dist/pkgman.js +0 -347
- package/dist/server.d.ts +0 -6
- package/dist/server.js +0 -9
- package/dist/sync_api.d.ts +0 -7
- package/dist/sync_api.js +0 -27
- package/dist/utils.d.ts +0 -88
- package/dist/utils.js +0 -500
- package/dist/virtdisplay.d.ts +0 -20
- package/dist/virtdisplay.js +0 -123
- package/dist/warnings.d.ts +0 -4
- package/dist/warnings.js +0 -30
- package/dist/webgl/db-compat.d.ts +0 -9
- package/dist/webgl/db-compat.js +0 -44
- package/dist/webgl/sample.d.ts +0 -19
- package/dist/webgl/sample.js +0 -85
- /package/{LICENSE.md → LICENSE} +0 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript declarations for human-cursor-playwright
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { Page, Locator, Response, PageScreenshotOptions, WaitForURLOptions } from 'playwright';
|
|
6
|
+
|
|
7
|
+
// ============= Tweening Functions =============
|
|
8
|
+
|
|
9
|
+
export type EasingFunction = (n: number) => number;
|
|
10
|
+
|
|
11
|
+
export function linear(n: number): number;
|
|
12
|
+
export function easeOutQuad(n: number): number;
|
|
13
|
+
export function easeInQuad(n: number): number;
|
|
14
|
+
export function easeInOutQuad(n: number): number;
|
|
15
|
+
export function easeOutCubic(n: number): number;
|
|
16
|
+
export function easeInCubic(n: number): number;
|
|
17
|
+
export function easeInOutCubic(n: number): number;
|
|
18
|
+
export function easeOutQuart(n: number): number;
|
|
19
|
+
export function easeInQuart(n: number): number;
|
|
20
|
+
export function easeInOutQuart(n: number): number;
|
|
21
|
+
export function easeOutQuint(n: number): number;
|
|
22
|
+
export function easeInQuint(n: number): number;
|
|
23
|
+
export function easeInOutQuint(n: number): number;
|
|
24
|
+
export function easeOutSine(n: number): number;
|
|
25
|
+
export function easeInSine(n: number): number;
|
|
26
|
+
export function easeInOutSine(n: number): number;
|
|
27
|
+
export function easeOutExpo(n: number): number;
|
|
28
|
+
export function easeInExpo(n: number): number;
|
|
29
|
+
export function easeInOutExpo(n: number): number;
|
|
30
|
+
export function easeOutCirc(n: number): number;
|
|
31
|
+
export function easeInCirc(n: number): number;
|
|
32
|
+
export function easeInOutCirc(n: number): number;
|
|
33
|
+
|
|
34
|
+
export const easingFunctions: Record<string, EasingFunction>;
|
|
35
|
+
|
|
36
|
+
// ============= Bezier Curve =============
|
|
37
|
+
|
|
38
|
+
export interface CurveOptions {
|
|
39
|
+
offsetBoundaryX?: number;
|
|
40
|
+
offsetBoundaryY?: number;
|
|
41
|
+
knotsCount?: number;
|
|
42
|
+
distortionMean?: number;
|
|
43
|
+
distortionStdDev?: number;
|
|
44
|
+
distortionFrequency?: number;
|
|
45
|
+
tweening?: EasingFunction;
|
|
46
|
+
targetPoints?: number;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export class HumanizeMouseTrajectory {
|
|
50
|
+
fromPoint: [number, number];
|
|
51
|
+
toPoint: [number, number];
|
|
52
|
+
points: Array<[number, number]>;
|
|
53
|
+
|
|
54
|
+
constructor(fromPoint: [number, number], toPoint: [number, number], options?: CurveOptions);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// ============= HumanLocator =============
|
|
58
|
+
|
|
59
|
+
export interface HumanClickOptions {
|
|
60
|
+
clickCount?: number;
|
|
61
|
+
button?: 'left' | 'right' | 'middle';
|
|
62
|
+
delay?: number;
|
|
63
|
+
position?: { x: number; y: number };
|
|
64
|
+
steady?: boolean;
|
|
65
|
+
moveSpeed?: number;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface HumanFillOptions extends HumanClickOptions {
|
|
69
|
+
minDelay?: number;
|
|
70
|
+
maxDelay?: number;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Locator with human-like cursor movement
|
|
75
|
+
* All Playwright Locator methods work, with click/fill/type using human cursor
|
|
76
|
+
*/
|
|
77
|
+
export interface HumanLocator extends Locator {
|
|
78
|
+
click(options?: HumanClickOptions): Promise<void>;
|
|
79
|
+
dblclick(options?: HumanClickOptions): Promise<void>;
|
|
80
|
+
fill(value: string, options?: HumanFillOptions): Promise<void>;
|
|
81
|
+
type(text: string, options?: HumanFillOptions): Promise<void>;
|
|
82
|
+
hover(options?: HumanClickOptions): Promise<void>;
|
|
83
|
+
press(key: string, options?: HumanClickOptions): Promise<void>;
|
|
84
|
+
|
|
85
|
+
// Chainable methods return HumanLocator
|
|
86
|
+
filter(options: { has?: Locator; hasNot?: Locator; hasText?: string | RegExp }): HumanLocator;
|
|
87
|
+
first(): HumanLocator;
|
|
88
|
+
last(): HumanLocator;
|
|
89
|
+
nth(index: number): HumanLocator;
|
|
90
|
+
locator(selector: string): HumanLocator;
|
|
91
|
+
getByText(text: string | RegExp, options?: { exact?: boolean }): HumanLocator;
|
|
92
|
+
getByRole(role: string, options?: { name?: string | RegExp; exact?: boolean }): HumanLocator;
|
|
93
|
+
getByLabel(text: string | RegExp, options?: { exact?: boolean }): HumanLocator;
|
|
94
|
+
getByPlaceholder(text: string | RegExp, options?: { exact?: boolean }): HumanLocator;
|
|
95
|
+
getByTestId(testId: string | RegExp): HumanLocator;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// ============= HumanCursor Options =============
|
|
99
|
+
|
|
100
|
+
export interface CreateCursorOptions {
|
|
101
|
+
/** Enable/disable human-like cursor movement (default: true) */
|
|
102
|
+
humanize?: boolean;
|
|
103
|
+
/** Maximum movement time in seconds (default: 1.5) */
|
|
104
|
+
maxTime?: number;
|
|
105
|
+
/** Minimum movement time in seconds (default: 0.5) */
|
|
106
|
+
minTime?: number;
|
|
107
|
+
/** Auto-show cursor indicator after goto (default: true) */
|
|
108
|
+
showCursor?: boolean;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// ============= HumanPage =============
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Page with human-like cursor movement
|
|
115
|
+
* All Playwright Page methods work, with locator methods returning HumanLocators
|
|
116
|
+
*/
|
|
117
|
+
export interface HumanPage extends Page {
|
|
118
|
+
// Override locator methods to return HumanLocator
|
|
119
|
+
locator(selector: string): HumanLocator;
|
|
120
|
+
getByText(text: string | RegExp, options?: { exact?: boolean }): HumanLocator;
|
|
121
|
+
getByRole(role: string, options?: { name?: string | RegExp; exact?: boolean }): HumanLocator;
|
|
122
|
+
getByLabel(text: string | RegExp, options?: { exact?: boolean }): HumanLocator;
|
|
123
|
+
getByPlaceholder(text: string | RegExp, options?: { exact?: boolean }): HumanLocator;
|
|
124
|
+
getByAltText(text: string | RegExp, options?: { exact?: boolean }): HumanLocator;
|
|
125
|
+
getByTitle(text: string | RegExp, options?: { exact?: boolean }): HumanLocator;
|
|
126
|
+
getByTestId(testId: string | RegExp): HumanLocator;
|
|
127
|
+
|
|
128
|
+
// Additional cursor utilities
|
|
129
|
+
showCursor(): Promise<void>;
|
|
130
|
+
originCoordinates: [number, number];
|
|
131
|
+
setPosition(x: number, y: number): void;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// ============= Main Export =============
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Create a cursor that acts as a drop-in replacement for Page
|
|
138
|
+
* All Page methods work, but locator actions (click, fill, type, hover) use human cursor
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* const cursor = createCursor(page, { showCursor: true });
|
|
143
|
+
* await cursor.goto('https://example.com');
|
|
144
|
+
* await cursor.locator('button').click(); // Uses human cursor!
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
export function createCursor(page: Page, options?: CreateCursorOptions): HumanPage;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* @deprecated Use createCursor() instead
|
|
151
|
+
*/
|
|
152
|
+
export class HumanCursor {
|
|
153
|
+
constructor(page: Page, options?: CreateCursorOptions);
|
|
154
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* human-cursor-playwright
|
|
3
|
+
* Human-like cursor movements for Playwright
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export { HumanCursor, createCursor } from './HumanCursor.js';
|
|
7
|
+
export { HumanizeMouseTrajectory, calculatePointsInCurve, bernsteinPolynomial } from './bezier.js';
|
|
8
|
+
export * from './tweening.js';
|
|
9
|
+
export { generateRandomCurveParameters, calculateAbsoluteOffset } from './randomizer.js';
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Random curve parameter generation
|
|
3
|
+
* Ported from Python HumanCursor library
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as tweening from './tweening.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Random integer between min and max (inclusive)
|
|
10
|
+
* @param {number} min
|
|
11
|
+
* @param {number} max
|
|
12
|
+
* @returns {number}
|
|
13
|
+
*/
|
|
14
|
+
function randInt(min, max) {
|
|
15
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Randomly select from array
|
|
20
|
+
* @template T
|
|
21
|
+
* @param {T[]} arr
|
|
22
|
+
* @returns {T}
|
|
23
|
+
*/
|
|
24
|
+
function randomChoice(arr) {
|
|
25
|
+
return arr[Math.floor(Math.random() * arr.length)];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Weighted random selection
|
|
30
|
+
* @template T
|
|
31
|
+
* @param {T[]} choices
|
|
32
|
+
* @param {number[]} weights
|
|
33
|
+
* @returns {T}
|
|
34
|
+
*/
|
|
35
|
+
function weightedChoice(choices, weights) {
|
|
36
|
+
const totalWeight = weights.reduce((a, b) => a + b, 0);
|
|
37
|
+
let random = Math.random() * totalWeight;
|
|
38
|
+
for (let i = 0; i < choices.length; i++) {
|
|
39
|
+
random -= weights[i];
|
|
40
|
+
if (random <= 0) return choices[i];
|
|
41
|
+
}
|
|
42
|
+
return choices[choices.length - 1];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Calculate exact pixel offsets from relative position values
|
|
47
|
+
* @param {{ width: number, height: number }} size - Element dimensions
|
|
48
|
+
* @param {[number, number]} relativePosition - [x, y] percentages (0 to 1)
|
|
49
|
+
* @returns {[number, number]} Absolute pixel offsets
|
|
50
|
+
*/
|
|
51
|
+
export function calculateAbsoluteOffset(size, relativePosition) {
|
|
52
|
+
const xFinal = size.width * relativePosition[0];
|
|
53
|
+
const yFinal = size.height * relativePosition[1];
|
|
54
|
+
return [Math.floor(xFinal), Math.floor(yFinal)];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* List of easing functions for random selection
|
|
59
|
+
*/
|
|
60
|
+
const tweenOptions = [
|
|
61
|
+
tweening.easeOutExpo,
|
|
62
|
+
tweening.easeInOutQuint,
|
|
63
|
+
tweening.easeInOutSine,
|
|
64
|
+
tweening.easeInOutQuart,
|
|
65
|
+
tweening.easeInOutExpo,
|
|
66
|
+
tweening.easeInOutCubic,
|
|
67
|
+
tweening.easeInOutCirc,
|
|
68
|
+
tweening.linear,
|
|
69
|
+
tweening.easeOutSine,
|
|
70
|
+
tweening.easeOutQuart,
|
|
71
|
+
tweening.easeOutQuint,
|
|
72
|
+
tweening.easeOutCubic,
|
|
73
|
+
tweening.easeOutCirc,
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Generate random parameters for human-like curve
|
|
78
|
+
* @param {{ width: number, height: number }} viewportSize - Browser viewport size
|
|
79
|
+
* @param {[number, number]} preOrigin - Starting point
|
|
80
|
+
* @param {[number, number]} postDestination - Ending point
|
|
81
|
+
* @returns {Object} Curve parameters
|
|
82
|
+
*/
|
|
83
|
+
export function generateRandomCurveParameters(viewportSize, preOrigin, postDestination) {
|
|
84
|
+
const viewportWidth = viewportSize.width;
|
|
85
|
+
const viewportHeight = viewportSize.height;
|
|
86
|
+
|
|
87
|
+
const minWidth = viewportWidth * 0.15;
|
|
88
|
+
const maxWidth = viewportWidth * 0.85;
|
|
89
|
+
const minHeight = viewportHeight * 0.15;
|
|
90
|
+
const maxHeight = viewportHeight * 0.85;
|
|
91
|
+
|
|
92
|
+
const tween = randomChoice(tweenOptions);
|
|
93
|
+
|
|
94
|
+
let offsetBoundaryX = randomChoice(
|
|
95
|
+
weightedChoice(
|
|
96
|
+
[[20, 45], [45, 75], [75, 100]],
|
|
97
|
+
[0.2, 0.65, 0.15]
|
|
98
|
+
).map(v => randInt(v, v))
|
|
99
|
+
) || randInt(45, 75);
|
|
100
|
+
|
|
101
|
+
let offsetBoundaryY = randomChoice(
|
|
102
|
+
weightedChoice(
|
|
103
|
+
[[20, 45], [45, 75], [75, 100]],
|
|
104
|
+
[0.2, 0.65, 0.15]
|
|
105
|
+
).map(v => randInt(v, v))
|
|
106
|
+
) || randInt(45, 75);
|
|
107
|
+
|
|
108
|
+
let knotsCount = weightedChoice(
|
|
109
|
+
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
|
110
|
+
[0.15, 0.36, 0.17, 0.12, 0.08, 0.04, 0.03, 0.02, 0.015, 0.005]
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const distortionMean = randInt(80, 110) / 100;
|
|
114
|
+
const distortionStdDev = randInt(85, 110) / 100;
|
|
115
|
+
const distortionFrequency = randInt(25, 70) / 100;
|
|
116
|
+
|
|
117
|
+
const targetPoints = randomChoice(
|
|
118
|
+
weightedChoice(
|
|
119
|
+
[[35, 45], [45, 60], [60, 80]],
|
|
120
|
+
[0.53, 0.32, 0.15]
|
|
121
|
+
).map(range => randInt(range[0], range[1]))
|
|
122
|
+
) || randInt(45, 60);
|
|
123
|
+
|
|
124
|
+
// Reduce curve complexity if near viewport edges
|
|
125
|
+
const isOriginNearEdge =
|
|
126
|
+
preOrigin[0] < minWidth || preOrigin[0] > maxWidth ||
|
|
127
|
+
preOrigin[1] < minHeight || preOrigin[1] > maxHeight;
|
|
128
|
+
|
|
129
|
+
const isDestNearEdge =
|
|
130
|
+
postDestination[0] < minWidth || postDestination[0] > maxWidth ||
|
|
131
|
+
postDestination[1] < minHeight || postDestination[1] > maxHeight;
|
|
132
|
+
|
|
133
|
+
if (isOriginNearEdge || isDestNearEdge) {
|
|
134
|
+
offsetBoundaryX = 1;
|
|
135
|
+
offsetBoundaryY = 1;
|
|
136
|
+
knotsCount = 1;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return {
|
|
140
|
+
offsetBoundaryX,
|
|
141
|
+
offsetBoundaryY,
|
|
142
|
+
knotsCount,
|
|
143
|
+
distortionMean,
|
|
144
|
+
distortionStdDev,
|
|
145
|
+
distortionFrequency,
|
|
146
|
+
tween,
|
|
147
|
+
targetPoints
|
|
148
|
+
};
|
|
149
|
+
}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure JavaScript easing functions (no external dependencies)
|
|
3
|
+
* Ported from pytweening for human-like cursor movement
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Linear easing - constant speed
|
|
8
|
+
* @param {number} n - Progress (0 to 1)
|
|
9
|
+
* @returns {number}
|
|
10
|
+
*/
|
|
11
|
+
export function linear(n) {
|
|
12
|
+
return n;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Quadratic ease out - decelerating
|
|
17
|
+
* @param {number} n - Progress (0 to 1)
|
|
18
|
+
* @returns {number}
|
|
19
|
+
*/
|
|
20
|
+
export function easeOutQuad(n) {
|
|
21
|
+
return -n * (n - 2);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Quadratic ease in - accelerating
|
|
26
|
+
* @param {number} n - Progress (0 to 1)
|
|
27
|
+
* @returns {number}
|
|
28
|
+
*/
|
|
29
|
+
export function easeInQuad(n) {
|
|
30
|
+
return n * n;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Quadratic ease in-out
|
|
35
|
+
* @param {number} n - Progress (0 to 1)
|
|
36
|
+
* @returns {number}
|
|
37
|
+
*/
|
|
38
|
+
export function easeInOutQuad(n) {
|
|
39
|
+
if (n < 0.5) {
|
|
40
|
+
return 2 * n * n;
|
|
41
|
+
}
|
|
42
|
+
return -2 * n * n + 4 * n - 1;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Cubic ease out - decelerating
|
|
47
|
+
* @param {number} n - Progress (0 to 1)
|
|
48
|
+
* @returns {number}
|
|
49
|
+
*/
|
|
50
|
+
export function easeOutCubic(n) {
|
|
51
|
+
const n1 = n - 1;
|
|
52
|
+
return n1 * n1 * n1 + 1;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Cubic ease in - accelerating
|
|
57
|
+
* @param {number} n - Progress (0 to 1)
|
|
58
|
+
* @returns {number}
|
|
59
|
+
*/
|
|
60
|
+
export function easeInCubic(n) {
|
|
61
|
+
return n * n * n;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Cubic ease in-out
|
|
66
|
+
* @param {number} n - Progress (0 to 1)
|
|
67
|
+
* @returns {number}
|
|
68
|
+
*/
|
|
69
|
+
export function easeInOutCubic(n) {
|
|
70
|
+
if (n < 0.5) {
|
|
71
|
+
return 4 * n * n * n;
|
|
72
|
+
}
|
|
73
|
+
const p = 2 * n - 2;
|
|
74
|
+
return 0.5 * p * p * p + 1;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Quartic ease out - decelerating
|
|
79
|
+
* @param {number} n - Progress (0 to 1)
|
|
80
|
+
* @returns {number}
|
|
81
|
+
*/
|
|
82
|
+
export function easeOutQuart(n) {
|
|
83
|
+
const n1 = n - 1;
|
|
84
|
+
return -(n1 * n1 * n1 * n1 - 1);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Quartic ease in - accelerating
|
|
89
|
+
* @param {number} n - Progress (0 to 1)
|
|
90
|
+
* @returns {number}
|
|
91
|
+
*/
|
|
92
|
+
export function easeInQuart(n) {
|
|
93
|
+
return n * n * n * n;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Quartic ease in-out
|
|
98
|
+
* @param {number} n - Progress (0 to 1)
|
|
99
|
+
* @returns {number}
|
|
100
|
+
*/
|
|
101
|
+
export function easeInOutQuart(n) {
|
|
102
|
+
if (n < 0.5) {
|
|
103
|
+
return 8 * n * n * n * n;
|
|
104
|
+
}
|
|
105
|
+
const n1 = n - 1;
|
|
106
|
+
return -8 * n1 * n1 * n1 * n1 + 1;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Quintic ease out - decelerating
|
|
111
|
+
* @param {number} n - Progress (0 to 1)
|
|
112
|
+
* @returns {number}
|
|
113
|
+
*/
|
|
114
|
+
export function easeOutQuint(n) {
|
|
115
|
+
const n1 = n - 1;
|
|
116
|
+
return n1 * n1 * n1 * n1 * n1 + 1;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Quintic ease in - accelerating
|
|
121
|
+
* @param {number} n - Progress (0 to 1)
|
|
122
|
+
* @returns {number}
|
|
123
|
+
*/
|
|
124
|
+
export function easeInQuint(n) {
|
|
125
|
+
return n * n * n * n * n;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Quintic ease in-out
|
|
130
|
+
* @param {number} n - Progress (0 to 1)
|
|
131
|
+
* @returns {number}
|
|
132
|
+
*/
|
|
133
|
+
export function easeInOutQuint(n) {
|
|
134
|
+
if (n < 0.5) {
|
|
135
|
+
return 16 * n * n * n * n * n;
|
|
136
|
+
}
|
|
137
|
+
const p = 2 * n - 2;
|
|
138
|
+
return 0.5 * p * p * p * p * p + 1;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Sinusoidal ease out - decelerating
|
|
143
|
+
* @param {number} n - Progress (0 to 1)
|
|
144
|
+
* @returns {number}
|
|
145
|
+
*/
|
|
146
|
+
export function easeOutSine(n) {
|
|
147
|
+
return Math.sin(n * Math.PI / 2);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Sinusoidal ease in - accelerating
|
|
152
|
+
* @param {number} n - Progress (0 to 1)
|
|
153
|
+
* @returns {number}
|
|
154
|
+
*/
|
|
155
|
+
export function easeInSine(n) {
|
|
156
|
+
return -Math.cos(n * Math.PI / 2) + 1;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Sinusoidal ease in-out
|
|
161
|
+
* @param {number} n - Progress (0 to 1)
|
|
162
|
+
* @returns {number}
|
|
163
|
+
*/
|
|
164
|
+
export function easeInOutSine(n) {
|
|
165
|
+
return -0.5 * (Math.cos(Math.PI * n) - 1);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Exponential ease out - decelerating
|
|
170
|
+
* @param {number} n - Progress (0 to 1)
|
|
171
|
+
* @returns {number}
|
|
172
|
+
*/
|
|
173
|
+
export function easeOutExpo(n) {
|
|
174
|
+
if (n === 1) return 1;
|
|
175
|
+
return -(Math.pow(2, -10 * n)) + 1;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Exponential ease in - accelerating
|
|
180
|
+
* @param {number} n - Progress (0 to 1)
|
|
181
|
+
* @returns {number}
|
|
182
|
+
*/
|
|
183
|
+
export function easeInExpo(n) {
|
|
184
|
+
if (n === 0) return 0;
|
|
185
|
+
return Math.pow(2, 10 * (n - 1));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Exponential ease in-out
|
|
190
|
+
* @param {number} n - Progress (0 to 1)
|
|
191
|
+
* @returns {number}
|
|
192
|
+
*/
|
|
193
|
+
export function easeInOutExpo(n) {
|
|
194
|
+
if (n === 0) return 0;
|
|
195
|
+
if (n === 1) return 1;
|
|
196
|
+
if (n < 0.5) {
|
|
197
|
+
return 0.5 * Math.pow(2, 20 * n - 10);
|
|
198
|
+
}
|
|
199
|
+
return 1 - 0.5 * Math.pow(2, -20 * n + 10);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Circular ease out - decelerating
|
|
204
|
+
* @param {number} n - Progress (0 to 1)
|
|
205
|
+
* @returns {number}
|
|
206
|
+
*/
|
|
207
|
+
export function easeOutCirc(n) {
|
|
208
|
+
const n1 = n - 1;
|
|
209
|
+
return Math.sqrt(1 - n1 * n1);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Circular ease in - accelerating
|
|
214
|
+
* @param {number} n - Progress (0 to 1)
|
|
215
|
+
* @returns {number}
|
|
216
|
+
*/
|
|
217
|
+
export function easeInCirc(n) {
|
|
218
|
+
return -(Math.sqrt(1 - n * n) - 1);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Circular ease in-out
|
|
223
|
+
* @param {number} n - Progress (0 to 1)
|
|
224
|
+
* @returns {number}
|
|
225
|
+
*/
|
|
226
|
+
export function easeInOutCirc(n) {
|
|
227
|
+
if (n < 0.5) {
|
|
228
|
+
return -0.5 * (Math.sqrt(1 - 4 * n * n) - 1);
|
|
229
|
+
}
|
|
230
|
+
const n1 = 2 * n - 2;
|
|
231
|
+
return 0.5 * (Math.sqrt(1 - n1 * n1) + 1);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* All available easing functions
|
|
236
|
+
*/
|
|
237
|
+
export const easingFunctions = {
|
|
238
|
+
linear,
|
|
239
|
+
easeOutQuad,
|
|
240
|
+
easeInQuad,
|
|
241
|
+
easeInOutQuad,
|
|
242
|
+
easeOutCubic,
|
|
243
|
+
easeInCubic,
|
|
244
|
+
easeInOutCubic,
|
|
245
|
+
easeOutQuart,
|
|
246
|
+
easeInQuart,
|
|
247
|
+
easeInOutQuart,
|
|
248
|
+
easeOutQuint,
|
|
249
|
+
easeInQuint,
|
|
250
|
+
easeInOutQuint,
|
|
251
|
+
easeOutSine,
|
|
252
|
+
easeInSine,
|
|
253
|
+
easeInOutSine,
|
|
254
|
+
easeOutExpo,
|
|
255
|
+
easeInExpo,
|
|
256
|
+
easeInOutExpo,
|
|
257
|
+
easeOutCirc,
|
|
258
|
+
easeInCirc,
|
|
259
|
+
easeInOutCirc
|
|
260
|
+
};
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/index.d.ts
|
|
2
|
+
|
|
3
|
+
export * from "./utility/proxy-utility/custom-proxy";
|
|
4
|
+
export * from "./utility/proxy-utility/proxy-chain";
|
|
5
|
+
export * from "./all_routes/routeWithSuperagent";
|
|
6
|
+
export {
|
|
7
|
+
type CamoufoxOptions,
|
|
8
|
+
type MultiloginOptions,
|
|
9
|
+
type LaunchOptions,
|
|
10
|
+
type BrowserController,
|
|
11
|
+
launchBrowser
|
|
12
|
+
// ProxyConfig is excluded - already exported from "./utility/proxy-utility/proxy-chain"
|
|
13
|
+
} from "./utility/launchBrowser";
|
|
14
|
+
export * from "./utility/proxy-utility/proxy-helper";
|
|
15
|
+
|
|
16
|
+
export * from "./others/totp-generator";
|
|
17
|
+
|
|
18
|
+
export * from "./utility/playwright-helper";
|
|
19
|
+
//
|
package/src/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Export the browser launcher (and any other exports from launchBrowser.js)
|
|
2
|
+
export * from "./utility/launchBrowser.js";
|
|
3
|
+
|
|
4
|
+
// Export the routing/request interception logic
|
|
5
|
+
export * from "./all_routes/routeWithSuperagent.js";
|
|
6
|
+
|
|
7
|
+
export * from "./utility/proxy-utility/proxy-chain.js";
|
|
8
|
+
|
|
9
|
+
export * from "./utility/proxy-utility/custom-proxy.js";
|
|
10
|
+
|
|
11
|
+
export * from "./utility/proxy-utility/proxy-helper.js";
|
|
12
|
+
|
|
13
|
+
export * from "./others/totp-generator.js";
|
|
14
|
+
|
|
15
|
+
export * from "./utility/playwright-helper.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface OTPResponse {
|
|
2
|
+
data: {
|
|
3
|
+
token: string;
|
|
4
|
+
time: string;
|
|
5
|
+
secondsRemaining: number;
|
|
6
|
+
} | null;
|
|
7
|
+
error: string | null;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface OTPOptions {
|
|
11
|
+
secret: string;
|
|
12
|
+
remainingSecond?: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function generateOTP(options: OTPOptions): Promise<OTPResponse>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import speakeasy from "speakeasy";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Helper to format a Date object as "YYYY-MM-DD HH:mm:ss" using local time.
|
|
5
|
+
* Replaces moment(unix).format("YYYY-MM-DD HH:mm:ss")
|
|
6
|
+
*/
|
|
7
|
+
function formatLocalTime(date) {
|
|
8
|
+
const pad = (num) => num.toString().padStart(2, "0");
|
|
9
|
+
|
|
10
|
+
const year = date.getFullYear();
|
|
11
|
+
const month = pad(date.getMonth() + 1); // Months are 0-indexed
|
|
12
|
+
const day = pad(date.getDate());
|
|
13
|
+
const hours = pad(date.getHours());
|
|
14
|
+
const minutes = pad(date.getMinutes());
|
|
15
|
+
const seconds = pad(date.getSeconds());
|
|
16
|
+
|
|
17
|
+
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Generates a Time-based One-Time Password (TOTP) token.
|
|
22
|
+
*
|
|
23
|
+
* @param {Object} options - Configuration options.
|
|
24
|
+
* @param {string} options.secret - The secret key for generating the token.
|
|
25
|
+
* @param {number} [options.remainingSecond=10] - Minimum seconds remaining in the current window.
|
|
26
|
+
* @returns {Promise<{data: {token: string, time: string, secondsRemaining: number}|null, error: string|null}>}
|
|
27
|
+
*/
|
|
28
|
+
export const generateOTP = async ({ secret, remainingSecond = 10 }) => {
|
|
29
|
+
try {
|
|
30
|
+
if (!secret) {
|
|
31
|
+
throw new Error("Secret is required for OTP generation");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Remove any spaces from the secret
|
|
35
|
+
const formattedSecret = secret.replace(/\s+/g, "");
|
|
36
|
+
|
|
37
|
+
// Get current time in seconds
|
|
38
|
+
const now = Math.floor(Date.now() / 1000);
|
|
39
|
+
const remaining = 30 - (now % 30);
|
|
40
|
+
|
|
41
|
+
if (remaining < remainingSecond) {
|
|
42
|
+
console.log(`Waiting for ${remaining} seconds to generate a new token...`);
|
|
43
|
+
// Adding 2 seconds buffer to ensure we are safely in the new window
|
|
44
|
+
await new Promise((resolve) => setTimeout(resolve, (remaining + 2) * 1000));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Recalculate time after potentially waiting
|
|
48
|
+
const newNowSeconds = Math.floor(Date.now() / 1000);
|
|
49
|
+
const newDate = new Date(newNowSeconds * 1000);
|
|
50
|
+
|
|
51
|
+
// Generate the token
|
|
52
|
+
const token = speakeasy.totp({
|
|
53
|
+
secret: formattedSecret,
|
|
54
|
+
encoding: "base32",
|
|
55
|
+
step: 30,
|
|
56
|
+
window: 0,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const secondsRemaining = 30 - (newNowSeconds % 30);
|
|
60
|
+
const formattedTime = formatLocalTime(newDate);
|
|
61
|
+
|
|
62
|
+
// Log output
|
|
63
|
+
console.log("Current Time:", formattedTime);
|
|
64
|
+
console.log("Token:", token);
|
|
65
|
+
console.log("Seconds remaining:", secondsRemaining);
|
|
66
|
+
|
|
67
|
+
if (!token) {
|
|
68
|
+
throw new Error("Token generation returned null");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
data: {
|
|
73
|
+
token,
|
|
74
|
+
time: formattedTime,
|
|
75
|
+
secondsRemaining,
|
|
76
|
+
},
|
|
77
|
+
error: null,
|
|
78
|
+
};
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.error("Error generating token:", error.message);
|
|
81
|
+
return {
|
|
82
|
+
data: null,
|
|
83
|
+
error: error.message,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
};
|