notte-sdk 1.9.0 → 1.9.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/README.md +93 -0
- package/dist/index.d.mts +1142 -261
- package/dist/index.d.ts +1142 -261
- package/dist/index.js +814 -126
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +788 -108
- package/dist/index.mjs.map +1 -1
- package/dist/proxy/core.js +21 -0
- package/dist/proxy/core.js.map +1 -1
- package/dist/proxy/core.mjs +21 -0
- package/dist/proxy/core.mjs.map +1 -1
- package/dist/proxy/next.js +21 -0
- package/dist/proxy/next.js.map +1 -1
- package/dist/proxy/next.mjs +21 -0
- package/dist/proxy/next.mjs.map +1 -1
- package/package.json +5 -2
package/dist/index.js
CHANGED
|
@@ -47,12 +47,14 @@ __export(index_exports, {
|
|
|
47
47
|
FileExistsError: () => FileExistsError,
|
|
48
48
|
FileNotFoundError: () => FileNotFoundError,
|
|
49
49
|
InvalidRequestError: () => InvalidRequestError,
|
|
50
|
+
ManagedAuthError: () => ManagedAuthError,
|
|
50
51
|
NotteAPIError: () => NotteAPIError,
|
|
51
52
|
NotteAPIExecutionError: () => NotteAPIExecutionError,
|
|
52
53
|
NotteAnything: () => NotteAnything,
|
|
53
54
|
NotteClient: () => NotteClient3,
|
|
54
55
|
NotteError: () => NotteError,
|
|
55
56
|
NotteFunction: () => NotteFunction,
|
|
57
|
+
NotteManagedAuth: () => NotteManagedAuth,
|
|
56
58
|
NottePersona: () => NottePersona,
|
|
57
59
|
NotteProxyAuthError: () => NotteProxyAuthError,
|
|
58
60
|
NotteSecrets: () => NotteSecrets,
|
|
@@ -82,11 +84,14 @@ __export(index_exports, {
|
|
|
82
84
|
connectLinkMailboxes: () => connectLinkMailboxes,
|
|
83
85
|
connectLinkStatus: () => connectLinkStatus,
|
|
84
86
|
connectLinkSubmit: () => connectLinkSubmit,
|
|
87
|
+
connectPaymentWallet: () => connectPaymentWallet,
|
|
85
88
|
createClient: () => createClient2,
|
|
86
89
|
createOrAppendCookiesToFile: () => createOrAppendCookiesToFile,
|
|
90
|
+
createPayment: () => createPayment,
|
|
87
91
|
default: () => NotteClient3,
|
|
88
92
|
deleteSecret: () => deleteSecret,
|
|
89
93
|
deleteSessionFile: () => deleteSessionFile,
|
|
94
|
+
disconnectPaymentWallet: () => disconnectPaymentWallet,
|
|
90
95
|
downloadSessionFile: () => downloadSessionFile,
|
|
91
96
|
functionCreate: () => functionCreate,
|
|
92
97
|
functionDelete: () => functionDelete,
|
|
@@ -102,6 +107,7 @@ __export(index_exports, {
|
|
|
102
107
|
functionScheduleDelete: () => functionScheduleDelete,
|
|
103
108
|
functionScheduleSet: () => functionScheduleSet,
|
|
104
109
|
functionUpdate: () => functionUpdate,
|
|
110
|
+
getPayment: () => getPayment,
|
|
105
111
|
getRootDomain: () => getRootDomain,
|
|
106
112
|
getScript: () => getScript,
|
|
107
113
|
getSecret: () => getSecret,
|
|
@@ -158,11 +164,13 @@ __export(index_exports, {
|
|
|
158
164
|
scrapeFromHtml: () => scrapeFromHtml,
|
|
159
165
|
scrapeWebpage: () => scrapeWebpage,
|
|
160
166
|
searchWeb: () => searchWeb,
|
|
167
|
+
sessionAuthReadiness: () => sessionAuthReadiness,
|
|
161
168
|
sessionCookiesGet: () => sessionCookiesGet,
|
|
162
169
|
sessionCookiesSet: () => sessionCookiesSet,
|
|
163
170
|
sessionDebugInfo: () => sessionDebugInfo,
|
|
164
171
|
sessionNetworkLogs: () => sessionNetworkLogs,
|
|
165
172
|
sessionOffset: () => sessionOffset,
|
|
173
|
+
sessionProfilePreview: () => sessionProfilePreview,
|
|
166
174
|
sessionReplay: () => sessionReplay,
|
|
167
175
|
sessionStart: () => sessionStart,
|
|
168
176
|
sessionStatus: () => sessionStatus,
|
|
@@ -187,7 +195,7 @@ __export(index_exports, {
|
|
|
187
195
|
module.exports = __toCommonJS(index_exports);
|
|
188
196
|
|
|
189
197
|
// src/version.ts
|
|
190
|
-
var SDK_VERSION = true ? "1.9.
|
|
198
|
+
var SDK_VERSION = true ? "1.9.1" : "dev";
|
|
191
199
|
var SDK_PACKAGE_NAME = true ? "notte-sdk" : "notte-sdk";
|
|
192
200
|
|
|
193
201
|
// src/version-check.ts
|
|
@@ -1120,6 +1128,11 @@ var createClient = (config = {}) => {
|
|
|
1120
1128
|
var client = createClient(createConfig({ baseUrl: "https://api.notte.cc" }));
|
|
1121
1129
|
|
|
1122
1130
|
// src/lib/client/sdk.gen.ts
|
|
1131
|
+
var sessionAuthReadiness = (options) => (options.client ?? client).get({
|
|
1132
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1133
|
+
url: "/sessions/{session_id}/auth",
|
|
1134
|
+
...options
|
|
1135
|
+
});
|
|
1123
1136
|
var listSessions = (options) => (options?.client ?? client).get({
|
|
1124
1137
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1125
1138
|
url: "/sessions",
|
|
@@ -1139,6 +1152,11 @@ var sessionStatus = (options) => (options.client ?? client).get({
|
|
|
1139
1152
|
url: "/sessions/{session_id}",
|
|
1140
1153
|
...options
|
|
1141
1154
|
});
|
|
1155
|
+
var sessionProfilePreview = (options) => (options.client ?? client).get({
|
|
1156
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1157
|
+
url: "/sessions/{session_id}/profile-preview",
|
|
1158
|
+
...options
|
|
1159
|
+
});
|
|
1142
1160
|
var getSessionScript = (options) => (options.client ?? client).get({
|
|
1143
1161
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1144
1162
|
url: "/sessions/{session_id}/workflow/code",
|
|
@@ -1450,6 +1468,38 @@ var listVaults = (options) => (options?.client ?? client).get({
|
|
|
1450
1468
|
url: "/vaults",
|
|
1451
1469
|
...options
|
|
1452
1470
|
});
|
|
1471
|
+
var connectPaymentWallet = (options) => (options.client ?? client).post({
|
|
1472
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1473
|
+
url: "/payments/connect",
|
|
1474
|
+
...options,
|
|
1475
|
+
headers: {
|
|
1476
|
+
"Content-Type": "application/json",
|
|
1477
|
+
...options.headers
|
|
1478
|
+
}
|
|
1479
|
+
});
|
|
1480
|
+
var disconnectPaymentWallet = (options) => (options.client ?? client).post({
|
|
1481
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1482
|
+
url: "/payments/disconnect",
|
|
1483
|
+
...options,
|
|
1484
|
+
headers: {
|
|
1485
|
+
"Content-Type": "application/json",
|
|
1486
|
+
...options.headers
|
|
1487
|
+
}
|
|
1488
|
+
});
|
|
1489
|
+
var createPayment = (options) => (options.client ?? client).post({
|
|
1490
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1491
|
+
url: "/sessions/{session_id}/payments",
|
|
1492
|
+
...options,
|
|
1493
|
+
headers: {
|
|
1494
|
+
"Content-Type": "application/json",
|
|
1495
|
+
...options.headers
|
|
1496
|
+
}
|
|
1497
|
+
});
|
|
1498
|
+
var getPayment = (options) => (options.client ?? client).get({
|
|
1499
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1500
|
+
url: "/payments/{payment_id}",
|
|
1501
|
+
...options
|
|
1502
|
+
});
|
|
1453
1503
|
var profileCreate = (options) => (options.client ?? client).post({
|
|
1454
1504
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1455
1505
|
url: "/profiles/create",
|
|
@@ -1707,10 +1757,8 @@ var scrapeFromHtml = (options) => (options.client ?? client).post({
|
|
|
1707
1757
|
}
|
|
1708
1758
|
});
|
|
1709
1759
|
|
|
1710
|
-
// src/
|
|
1711
|
-
var
|
|
1712
|
-
var import_promises2 = require("fs/promises");
|
|
1713
|
-
var import_node_path2 = require("path");
|
|
1760
|
+
// src/managed-auth.ts
|
|
1761
|
+
var import_promises = require("timers/promises");
|
|
1714
1762
|
|
|
1715
1763
|
// src/errors.ts
|
|
1716
1764
|
var NotteError = class extends Error {
|
|
@@ -1864,70 +1912,544 @@ function sleep(ms) {
|
|
|
1864
1912
|
return new Promise((resolve3) => setTimeout(resolve3, ms));
|
|
1865
1913
|
}
|
|
1866
1914
|
|
|
1867
|
-
// src/
|
|
1868
|
-
|
|
1869
|
-
|
|
1915
|
+
// src/managed-auth.ts
|
|
1916
|
+
var ManagedAuthError = class extends NotteError {
|
|
1917
|
+
};
|
|
1918
|
+
function validateAuthRetry(value) {
|
|
1919
|
+
if (!Number.isInteger(value) || value < 0 || value > 2) {
|
|
1920
|
+
throw new InvalidRequestError("auth_retry must be an integer between 0 and 2");
|
|
1921
|
+
}
|
|
1870
1922
|
}
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1923
|
+
async function pollAuth(read, options) {
|
|
1924
|
+
const timeoutMs = options.timeoutMs ?? 615e3;
|
|
1925
|
+
const interval = options.pollIntervalMs ?? 1e3;
|
|
1926
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0 || !Number.isFinite(interval) || interval <= 0) {
|
|
1927
|
+
throw new InvalidRequestError("timeoutMs and pollIntervalMs must be positive finite numbers");
|
|
1928
|
+
}
|
|
1929
|
+
const deadline = new AbortController();
|
|
1930
|
+
const timer = setTimeout(() => deadline.abort(new NotteTimeoutError("Timed out waiting for authentication")), timeoutMs);
|
|
1931
|
+
const cancel = () => deadline.abort(options.signal?.reason);
|
|
1932
|
+
if (options.signal?.aborted) cancel();
|
|
1933
|
+
else options.signal?.addEventListener("abort", cancel, { once: true });
|
|
1934
|
+
const signal = deadline.signal;
|
|
1935
|
+
let errors = 0;
|
|
1936
|
+
try {
|
|
1937
|
+
while (true) {
|
|
1938
|
+
signal.throwIfAborted();
|
|
1939
|
+
try {
|
|
1940
|
+
const value = await read(signal);
|
|
1941
|
+
signal.throwIfAborted();
|
|
1942
|
+
if (value !== void 0) return value;
|
|
1943
|
+
errors = 0;
|
|
1944
|
+
} catch (error) {
|
|
1945
|
+
signal.throwIfAborted();
|
|
1946
|
+
const retryable = error instanceof NotteAPIError ? error.statusCode >= 500 : error instanceof TypeError || error instanceof NotteTimeoutError;
|
|
1947
|
+
if (!retryable || ++errors >= 3) throw error;
|
|
1948
|
+
}
|
|
1949
|
+
await (0, import_promises.setTimeout)(interval, void 0, { signal });
|
|
1950
|
+
}
|
|
1951
|
+
} catch (error) {
|
|
1952
|
+
signal.throwIfAborted();
|
|
1953
|
+
throw error;
|
|
1954
|
+
} finally {
|
|
1955
|
+
clearTimeout(timer);
|
|
1956
|
+
options.signal?.removeEventListener("abort", cancel);
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
var NotteManagedAuth = class {
|
|
1960
|
+
constructor(client2) {
|
|
1961
|
+
this.client = client2;
|
|
1962
|
+
}
|
|
1963
|
+
/** Run only the verifier; this does not submit login credentials. */
|
|
1964
|
+
async checkConnection(connectionId) {
|
|
1965
|
+
const response = await this.client.getClient().post({
|
|
1966
|
+
url: `/managed-auth/connections/${encodeURIComponent(connectionId)}/check`,
|
|
1967
|
+
body: {},
|
|
1968
|
+
headers: { "Content-Type": "application/json" },
|
|
1969
|
+
throwOnError: true
|
|
1970
|
+
});
|
|
1971
|
+
return response.data;
|
|
1972
|
+
}
|
|
1973
|
+
async getOperation(operationId, options = {}) {
|
|
1974
|
+
const response = await this.client.getClient().get({
|
|
1975
|
+
url: `/managed-auth/operations/${encodeURIComponent(operationId)}`,
|
|
1976
|
+
headers: { [TIMEOUT_HEADER]: "10000" },
|
|
1977
|
+
signal: options.signal,
|
|
1978
|
+
throwOnError: true
|
|
1979
|
+
});
|
|
1980
|
+
return response.data;
|
|
1981
|
+
}
|
|
1982
|
+
/** Wait for an accepted operation. Aborting this wait does not cancel the server operation. */
|
|
1983
|
+
async waitForAuth(operation, options = {}) {
|
|
1984
|
+
const completed = (value) => {
|
|
1985
|
+
if (value.status === "succeeded") return value;
|
|
1986
|
+
if (value.status === "pending" || value.status === "running") return void 0;
|
|
1987
|
+
throw new ManagedAuthError(value.error || "Connection authentication failed");
|
|
1988
|
+
};
|
|
1989
|
+
options.signal?.throwIfAborted();
|
|
1990
|
+
const result = completed(operation);
|
|
1991
|
+
if (result) return result;
|
|
1992
|
+
return pollAuth(async (signal) => completed(await this.getOperation(operation.id, { signal })), options);
|
|
1993
|
+
}
|
|
1994
|
+
/** Verify first, logging in only when required and automatic recovery is allowed. */
|
|
1995
|
+
async refreshConnection(connectionId, options = {}) {
|
|
1996
|
+
return this.run(connectionId, "refresh", options);
|
|
1997
|
+
}
|
|
1998
|
+
/** Explicitly request a new login. Conflicting operations remain HTTP 409 errors. */
|
|
1999
|
+
async reauthenticateConnection(connectionId, options = {}) {
|
|
2000
|
+
return this.run(connectionId, "reauthenticate", options);
|
|
2001
|
+
}
|
|
2002
|
+
async run(connectionId, action, options) {
|
|
2003
|
+
const authRetry = options.auth_retry ?? 0;
|
|
2004
|
+
validateAuthRetry(authRetry);
|
|
2005
|
+
options.signal?.throwIfAborted();
|
|
2006
|
+
const response = await this.client.getClient().post({
|
|
2007
|
+
url: `/managed-auth/connections/${encodeURIComponent(connectionId)}/${action}`,
|
|
2008
|
+
body: { auth_retry: authRetry },
|
|
2009
|
+
headers: { "Content-Type": "application/json" },
|
|
2010
|
+
signal: options.signal,
|
|
2011
|
+
throwOnError: true
|
|
2012
|
+
});
|
|
2013
|
+
return options.wait === false ? response.data : this.waitForAuth(response.data, options);
|
|
2014
|
+
}
|
|
1928
2015
|
};
|
|
1929
|
-
|
|
1930
|
-
|
|
2016
|
+
|
|
2017
|
+
// src/resources.gen.ts
|
|
2018
|
+
function createResources(client2, getApiKey) {
|
|
2019
|
+
return {
|
|
2020
|
+
sessions: {
|
|
2021
|
+
/** sessionAuthReadiness: /sessions/{session_id}/auth. Returns the API response body. */
|
|
2022
|
+
authReadiness: async (sessionId, requestOptions = {}) => {
|
|
2023
|
+
const response = await sessionAuthReadiness({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId } });
|
|
2024
|
+
return response.data;
|
|
2025
|
+
},
|
|
2026
|
+
/** createPayment: /sessions/{session_id}/payments. Returns the API response body. */
|
|
2027
|
+
createPayment: async (sessionId, body, query = void 0, requestOptions) => {
|
|
2028
|
+
const response = await createPayment({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, body, query });
|
|
2029
|
+
return response.data;
|
|
2030
|
+
},
|
|
2031
|
+
/** sessionDebugInfo: /sessions/{session_id}/debug. Returns the API response body. */
|
|
2032
|
+
debugInfo: async (sessionId, query = void 0, requestOptions = {}) => {
|
|
2033
|
+
const response = await sessionDebugInfo({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, query });
|
|
2034
|
+
return response.data;
|
|
2035
|
+
},
|
|
2036
|
+
/** deleteSessionFile: /sessions/{session_id}/files/{file_id}. Returns the API response body. */
|
|
2037
|
+
deleteSessionFile: async (sessionId, fileId, requestOptions = {}) => {
|
|
2038
|
+
const response = await deleteSessionFile({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId, "file_id": fileId } });
|
|
2039
|
+
return response.data;
|
|
2040
|
+
},
|
|
2041
|
+
/** downloadSessionFile: /sessions/{session_id}/files/{file_id}. Returns the API response body. */
|
|
2042
|
+
downloadSessionFile: async (sessionId, fileId, requestOptions = {}) => {
|
|
2043
|
+
const response = await downloadSessionFile({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId, "file_id": fileId } });
|
|
2044
|
+
return response.data;
|
|
2045
|
+
},
|
|
2046
|
+
/** pageExecute: /sessions/{session_id}/page/execute. Returns the API response body. */
|
|
2047
|
+
execute: async (sessionId, body, query = void 0, requestOptions = {}) => {
|
|
2048
|
+
const response = await pageExecute({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, body, query });
|
|
2049
|
+
return response.data;
|
|
2050
|
+
},
|
|
2051
|
+
/** sessionCookiesGet: /sessions/{session_id}/cookies. Returns the API response body. */
|
|
2052
|
+
getCookies: async (sessionId, query = void 0, requestOptions = {}) => {
|
|
2053
|
+
const response = await sessionCookiesGet({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, query });
|
|
2054
|
+
return response.data;
|
|
2055
|
+
},
|
|
2056
|
+
/** getSessionScript: /sessions/{session_id}/workflow/code. Returns the API response body. */
|
|
2057
|
+
getSessionScript: async (sessionId, query, requestOptions = {}) => {
|
|
2058
|
+
const response = await getSessionScript({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, query });
|
|
2059
|
+
return response.data;
|
|
2060
|
+
},
|
|
2061
|
+
/** listSessions: /sessions. Returns the API response body. */
|
|
2062
|
+
list: async (query = void 0, requestOptions = {}) => {
|
|
2063
|
+
const response = await listSessions({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, query });
|
|
2064
|
+
return response.data;
|
|
2065
|
+
},
|
|
2066
|
+
/** listSessionFiles: /sessions/{session_id}/files. Returns the API response body. */
|
|
2067
|
+
listSessionFiles: async (sessionId, query = void 0, requestOptions = {}) => {
|
|
2068
|
+
const response = await listSessionFiles({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, query });
|
|
2069
|
+
return response.data;
|
|
2070
|
+
},
|
|
2071
|
+
/** sessionNetworkLogs: /sessions/{session_id}/network/logs. Returns the API response body. */
|
|
2072
|
+
networkLogs: async (sessionId, query = void 0, requestOptions = {}) => {
|
|
2073
|
+
const response = await sessionNetworkLogs({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, query });
|
|
2074
|
+
return response.data;
|
|
2075
|
+
},
|
|
2076
|
+
/** pageObserve: /sessions/{session_id}/page/observe. Returns the API response body. */
|
|
2077
|
+
observe: async (sessionId, body, query = void 0, requestOptions = {}) => {
|
|
2078
|
+
const response = await pageObserve({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, body, query });
|
|
2079
|
+
return response.data;
|
|
2080
|
+
},
|
|
2081
|
+
/** sessionOffset: /sessions/{session_id}/offset. Returns the API response body. */
|
|
2082
|
+
offset: async (sessionId, requestOptions = {}) => {
|
|
2083
|
+
const response = await sessionOffset({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId } });
|
|
2084
|
+
return response.data;
|
|
2085
|
+
},
|
|
2086
|
+
/** pageScreenshot: /sessions/{session_id}/page/screenshot. Returns the API response body. */
|
|
2087
|
+
pageScreenshot: async (sessionId, query = void 0, requestOptions = {}) => {
|
|
2088
|
+
const response = await pageScreenshot({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, query });
|
|
2089
|
+
return response.data;
|
|
2090
|
+
},
|
|
2091
|
+
/** sessionProfilePreview: /sessions/{session_id}/profile-preview. Returns the API response body. */
|
|
2092
|
+
profilePreview: async (sessionId, query = void 0, requestOptions = {}) => {
|
|
2093
|
+
const response = await sessionProfilePreview({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, query });
|
|
2094
|
+
return response.data;
|
|
2095
|
+
},
|
|
2096
|
+
/** sessionReplay: /sessions/{session_id}/replay. Returns the API response body. */
|
|
2097
|
+
replay: async (sessionId, requestOptions = {}) => {
|
|
2098
|
+
const response = await sessionReplay({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId } });
|
|
2099
|
+
return response.data;
|
|
2100
|
+
},
|
|
2101
|
+
/** pageScrape: /sessions/{session_id}/page/scrape. Returns the API response body. */
|
|
2102
|
+
scrape: async (sessionId, body, query = void 0, requestOptions = {}) => {
|
|
2103
|
+
const response = await pageScrape({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, body, query });
|
|
2104
|
+
return response.data;
|
|
2105
|
+
},
|
|
2106
|
+
/** sessionCookiesSet: /sessions/{session_id}/cookies. Returns the API response body. */
|
|
2107
|
+
setCookies: async (sessionId, body, query = void 0, requestOptions = {}) => {
|
|
2108
|
+
const response = await sessionCookiesSet({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, body, query });
|
|
2109
|
+
return response.data;
|
|
2110
|
+
},
|
|
2111
|
+
/** sessionStart: /sessions/start. Returns the API response body. */
|
|
2112
|
+
start: async (body, requestOptions = {}) => {
|
|
2113
|
+
const response = await sessionStart({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, body });
|
|
2114
|
+
return response.data;
|
|
2115
|
+
},
|
|
2116
|
+
/** sessionStatus: /sessions/{session_id}. Returns the API response body. */
|
|
2117
|
+
status: async (sessionId, requestOptions = {}) => {
|
|
2118
|
+
const response = await sessionStatus({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId } });
|
|
2119
|
+
return response.data;
|
|
2120
|
+
},
|
|
2121
|
+
/** sessionStop: /sessions/{session_id}/stop. Returns the API response body. */
|
|
2122
|
+
stop: async (sessionId, query = void 0, requestOptions = {}) => {
|
|
2123
|
+
const response = await sessionStop({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, query });
|
|
2124
|
+
return response.data;
|
|
2125
|
+
},
|
|
2126
|
+
/** uploadSessionFile: /sessions/{session_id}/files. Returns the API response body. */
|
|
2127
|
+
uploadSessionFile: async (sessionId, body, requestOptions = {}) => {
|
|
2128
|
+
const response = await uploadSessionFile({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, body });
|
|
2129
|
+
return response.data;
|
|
2130
|
+
}
|
|
2131
|
+
},
|
|
2132
|
+
agents: {
|
|
2133
|
+
/** getScript: /agents/{agent_id}/workflow/code. Returns the API response body. */
|
|
2134
|
+
getScript: async (agentId, query, requestOptions = {}) => {
|
|
2135
|
+
const response = await getScript({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "agent_id": agentId }, query });
|
|
2136
|
+
return response.data;
|
|
2137
|
+
},
|
|
2138
|
+
/** listAgents: /agents. Returns the API response body. */
|
|
2139
|
+
list: async (query = void 0, requestOptions = {}) => {
|
|
2140
|
+
const response = await listAgents({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, query });
|
|
2141
|
+
return response.data;
|
|
2142
|
+
},
|
|
2143
|
+
/** agentStart: /agents/start. Returns the API response body. */
|
|
2144
|
+
start: async (body, requestOptions = {}) => {
|
|
2145
|
+
const response = await agentStart({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, body });
|
|
2146
|
+
return response.data;
|
|
2147
|
+
},
|
|
2148
|
+
/** agentStatus: /agents/{agent_id}. Returns the API response body. */
|
|
2149
|
+
status: async (agentId, requestOptions = {}) => {
|
|
2150
|
+
const response = await agentStatus({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "agent_id": agentId } });
|
|
2151
|
+
return response.data;
|
|
2152
|
+
},
|
|
2153
|
+
/** agentStop: /agents/{agent_id}/stop. Returns the API response body. */
|
|
2154
|
+
stop: async (agentId, query, requestOptions = {}) => {
|
|
2155
|
+
const response = await agentStop({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "agent_id": agentId }, query });
|
|
2156
|
+
return response.data;
|
|
2157
|
+
}
|
|
2158
|
+
},
|
|
2159
|
+
functions: {
|
|
2160
|
+
/** functionCreate: /functions. Returns the API response body. */
|
|
2161
|
+
create: async (body, query = void 0, requestOptions = {}) => {
|
|
2162
|
+
const response = await functionCreate({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, body, query });
|
|
2163
|
+
return response.data;
|
|
2164
|
+
},
|
|
2165
|
+
/** functionDelete: /functions/{function_id}. Returns the API response body. */
|
|
2166
|
+
delete: async (functionId, requestOptions = {}) => {
|
|
2167
|
+
const response = await functionDelete({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "function_id": functionId } });
|
|
2168
|
+
return response.data;
|
|
2169
|
+
},
|
|
2170
|
+
/** functionScheduleDelete: /functions/{function_id}/schedule. Returns the API response body. */
|
|
2171
|
+
deleteSchedule: async (functionId, requestOptions = {}) => {
|
|
2172
|
+
const response = await functionScheduleDelete({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "function_id": functionId } });
|
|
2173
|
+
return response.data;
|
|
2174
|
+
},
|
|
2175
|
+
/** functionDownloadUrl: /functions/{function_id}. Returns the API response body. */
|
|
2176
|
+
downloadUrl: async (functionId, query = void 0, requestOptions = {}) => {
|
|
2177
|
+
const response = await functionDownloadUrl({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "function_id": functionId }, query });
|
|
2178
|
+
return response.data;
|
|
2179
|
+
},
|
|
2180
|
+
/** functionFork: /functions/{function_id}/fork. Returns the API response body. */
|
|
2181
|
+
fork: async (functionId, requestOptions = {}) => {
|
|
2182
|
+
const response = await functionFork({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "function_id": functionId } });
|
|
2183
|
+
return response.data;
|
|
2184
|
+
},
|
|
2185
|
+
/** listFunctions: /functions. Returns the API response body. */
|
|
2186
|
+
list: async (query = void 0, requestOptions = {}) => {
|
|
2187
|
+
const response = await listFunctions({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, query });
|
|
2188
|
+
return response.data;
|
|
2189
|
+
},
|
|
2190
|
+
/** listFunctionRunsByFunctionId: /functions/{function_id}/runs. Returns the API response body. */
|
|
2191
|
+
listRuns: async (functionId, query = void 0, requestOptions = {}) => {
|
|
2192
|
+
const response = await listFunctionRunsByFunctionId({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "function_id": functionId }, query });
|
|
2193
|
+
return response.data;
|
|
2194
|
+
},
|
|
2195
|
+
/** functionMetadataUpdate: /functions/{function_id}. Returns the API response body. */
|
|
2196
|
+
metadataUpdate: async (functionId, body, requestOptions = {}) => {
|
|
2197
|
+
const response = await functionMetadataUpdate({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "function_id": functionId }, body });
|
|
2198
|
+
return response.data;
|
|
2199
|
+
},
|
|
2200
|
+
/** functionRollback: /functions/{function_id}/rollback. Returns the API response body. */
|
|
2201
|
+
rollback: async (functionId, body, query = void 0, requestOptions = {}) => {
|
|
2202
|
+
const response = await functionRollback({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "function_id": functionId }, body, query });
|
|
2203
|
+
return response.data;
|
|
2204
|
+
},
|
|
2205
|
+
/** functionRunGetMetadata: /functions/{function_id}/runs/{run_id}. Returns the API response body. */
|
|
2206
|
+
runGetMetadata: async (functionId, runId, requestOptions = {}) => {
|
|
2207
|
+
const response = await functionRunGetMetadata({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "function_id": functionId, "run_id": runId } });
|
|
2208
|
+
return response.data;
|
|
2209
|
+
},
|
|
2210
|
+
/** functionRunStart: /functions/{function_id}/runs/start. Returns the API response body. */
|
|
2211
|
+
runStart: async (functionId, body, requestOptions = {}) => {
|
|
2212
|
+
const response = await functionRunStart({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers, "x-notte-api-key": getApiKey() }, path: { "function_id": functionId }, body });
|
|
2213
|
+
return response.data;
|
|
2214
|
+
},
|
|
2215
|
+
/** functionRunStop: /functions/{function_id}/runs/{run_id}. Returns the API response body. */
|
|
2216
|
+
runStop: async (functionId, runId, requestOptions = {}) => {
|
|
2217
|
+
const response = await functionRunStop({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "function_id": functionId, "run_id": runId } });
|
|
2218
|
+
return response.data;
|
|
2219
|
+
},
|
|
2220
|
+
/** functionRunUpdateMetadata: /functions/{function_id}/runs/{run_id}. Returns the API response body. */
|
|
2221
|
+
runUpdateMetadata: async (functionId, runId, body, requestOptions = {}) => {
|
|
2222
|
+
const response = await functionRunUpdateMetadata({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "function_id": functionId, "run_id": runId }, body });
|
|
2223
|
+
return response.data;
|
|
2224
|
+
},
|
|
2225
|
+
/** functionRuntimeHealth: /functions/health. Returns the API response body. */
|
|
2226
|
+
runtimeHealth: async (requestOptions = {}) => {
|
|
2227
|
+
const response = await functionRuntimeHealth({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers } });
|
|
2228
|
+
return response.data;
|
|
2229
|
+
},
|
|
2230
|
+
/** functionScheduleSet: /functions/{function_id}/schedule. Returns the API response body. */
|
|
2231
|
+
setSchedule: async (functionId, body, requestOptions = {}) => {
|
|
2232
|
+
const response = await functionScheduleSet({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "function_id": functionId }, body });
|
|
2233
|
+
return response.data;
|
|
2234
|
+
},
|
|
2235
|
+
/** functionUpdate: /functions/{function_id}. Returns the API response body. */
|
|
2236
|
+
update: async (functionId, body, query = void 0, requestOptions = {}) => {
|
|
2237
|
+
const response = await functionUpdate({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "function_id": functionId }, body, query });
|
|
2238
|
+
return response.data;
|
|
2239
|
+
}
|
|
2240
|
+
},
|
|
2241
|
+
vaults: {
|
|
2242
|
+
/** vaultCreate: /vaults/create. Returns the API response body. */
|
|
2243
|
+
create: async (body, requestOptions = {}) => {
|
|
2244
|
+
const response = await vaultCreate({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, body });
|
|
2245
|
+
return response.data;
|
|
2246
|
+
},
|
|
2247
|
+
/** vaultCredentialsAdd: /vaults/{vault_id}/credentials. Returns the API response body. */
|
|
2248
|
+
credentialsAdd: async (vaultId, body, requestOptions = {}) => {
|
|
2249
|
+
const response = await vaultCredentialsAdd({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "vault_id": vaultId }, body });
|
|
2250
|
+
return response.data;
|
|
2251
|
+
},
|
|
2252
|
+
/** vaultCredentialsDelete: /vaults/{vault_id}/credentials. Returns the API response body. */
|
|
2253
|
+
credentialsDelete: async (vaultId, query, requestOptions = {}) => {
|
|
2254
|
+
const response = await vaultCredentialsDelete({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "vault_id": vaultId }, query });
|
|
2255
|
+
return response.data;
|
|
2256
|
+
},
|
|
2257
|
+
/** vaultCredentialsGet: /vaults/{vault_id}/credentials. Returns the API response body. */
|
|
2258
|
+
credentialsGet: async (vaultId, query, requestOptions = {}) => {
|
|
2259
|
+
const response = await vaultCredentialsGet({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "vault_id": vaultId }, query });
|
|
2260
|
+
return response.data;
|
|
2261
|
+
},
|
|
2262
|
+
/** vaultCredentialsList: /vaults/{vault_id}. Returns the API response body. */
|
|
2263
|
+
credentialsList: async (vaultId, requestOptions = {}) => {
|
|
2264
|
+
const response = await vaultCredentialsList({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "vault_id": vaultId } });
|
|
2265
|
+
return response.data;
|
|
2266
|
+
},
|
|
2267
|
+
/** vaultCreditCardDelete: /vaults/{vault_id}/card. Returns the API response body. */
|
|
2268
|
+
creditCardDelete: async (vaultId, requestOptions = {}) => {
|
|
2269
|
+
const response = await vaultCreditCardDelete({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "vault_id": vaultId } });
|
|
2270
|
+
return response.data;
|
|
2271
|
+
},
|
|
2272
|
+
/** vaultCreditCardGet: /vaults/{vault_id}/card. Returns the API response body. */
|
|
2273
|
+
creditCardGet: async (vaultId, requestOptions = {}) => {
|
|
2274
|
+
const response = await vaultCreditCardGet({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "vault_id": vaultId } });
|
|
2275
|
+
return response.data;
|
|
2276
|
+
},
|
|
2277
|
+
/** vaultCreditCardSet: /vaults/{vault_id}/card. Returns the API response body. */
|
|
2278
|
+
creditCardSet: async (vaultId, body, requestOptions = {}) => {
|
|
2279
|
+
const response = await vaultCreditCardSet({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "vault_id": vaultId }, body });
|
|
2280
|
+
return response.data;
|
|
2281
|
+
},
|
|
2282
|
+
/** vaultDelete: /vaults/{vault_id}. Returns the API response body. */
|
|
2283
|
+
delete: async (vaultId, requestOptions = {}) => {
|
|
2284
|
+
const response = await vaultDelete({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "vault_id": vaultId } });
|
|
2285
|
+
return response.data;
|
|
2286
|
+
},
|
|
2287
|
+
/** listVaults: /vaults. Returns the API response body. */
|
|
2288
|
+
list: async (query = void 0, requestOptions = {}) => {
|
|
2289
|
+
const response = await listVaults({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, query });
|
|
2290
|
+
return response.data;
|
|
2291
|
+
},
|
|
2292
|
+
/** vaultUpdate: /vaults/{vault_id}. Returns the API response body. */
|
|
2293
|
+
update: async (vaultId, body, requestOptions = {}) => {
|
|
2294
|
+
const response = await vaultUpdate({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "vault_id": vaultId }, body });
|
|
2295
|
+
return response.data;
|
|
2296
|
+
}
|
|
2297
|
+
},
|
|
2298
|
+
personas: {
|
|
2299
|
+
/** personaCreate: /personas/create. Returns the API response body. */
|
|
2300
|
+
create: async (body, requestOptions = {}) => {
|
|
2301
|
+
const response = await personaCreate({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, body });
|
|
2302
|
+
return response.data;
|
|
2303
|
+
},
|
|
2304
|
+
/** personaDelete: /personas/{persona_id}. Returns the API response body. */
|
|
2305
|
+
delete: async (personaId, requestOptions = {}) => {
|
|
2306
|
+
const response = await personaDelete({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "persona_id": personaId } });
|
|
2307
|
+
return response.data;
|
|
2308
|
+
},
|
|
2309
|
+
/** personaEmailsList: /personas/{persona_id}/emails. Returns the API response body. */
|
|
2310
|
+
emailsList: async (personaId, query = void 0, requestOptions = {}) => {
|
|
2311
|
+
const response = await personaEmailsList({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "persona_id": personaId }, query });
|
|
2312
|
+
return response.data;
|
|
2313
|
+
},
|
|
2314
|
+
/** personaGet: /personas/{persona_id}. Returns the API response body. */
|
|
2315
|
+
get: async (personaId, requestOptions = {}) => {
|
|
2316
|
+
const response = await personaGet({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "persona_id": personaId } });
|
|
2317
|
+
return response.data;
|
|
2318
|
+
},
|
|
2319
|
+
/** listPersonas: /personas. Returns the API response body. */
|
|
2320
|
+
list: async (query = void 0, requestOptions = {}) => {
|
|
2321
|
+
const response = await listPersonas({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, query });
|
|
2322
|
+
return response.data;
|
|
2323
|
+
},
|
|
2324
|
+
/** personaSmsList: /personas/{persona_id}/sms. Returns the API response body. */
|
|
2325
|
+
smsList: async (personaId, query = void 0, requestOptions = {}) => {
|
|
2326
|
+
const response = await personaSmsList({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "persona_id": personaId }, query });
|
|
2327
|
+
return response.data;
|
|
2328
|
+
},
|
|
2329
|
+
/** personaUpdate: /personas/{persona_id}. Returns the API response body. */
|
|
2330
|
+
update: async (personaId, body, requestOptions = {}) => {
|
|
2331
|
+
const response = await personaUpdate({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "persona_id": personaId }, body });
|
|
2332
|
+
return response.data;
|
|
2333
|
+
}
|
|
2334
|
+
},
|
|
2335
|
+
profiles: {
|
|
2336
|
+
/** profileCookiesGet: /profiles/{profile_id}/cookies. Returns the API response body. */
|
|
2337
|
+
cookiesGet: async (profileId, requestOptions = {}) => {
|
|
2338
|
+
const response = await profileCookiesGet({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "profile_id": profileId } });
|
|
2339
|
+
return response.data;
|
|
2340
|
+
},
|
|
2341
|
+
/** profileCookiesSet: /profiles/{profile_id}/cookies. Returns the API response body. */
|
|
2342
|
+
cookiesSet: async (profileId, body, requestOptions = {}) => {
|
|
2343
|
+
const response = await profileCookiesSet({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "profile_id": profileId }, body });
|
|
2344
|
+
return response.data;
|
|
2345
|
+
},
|
|
2346
|
+
/** profileCreate: /profiles/create. Returns the API response body. */
|
|
2347
|
+
create: async (body, requestOptions = {}) => {
|
|
2348
|
+
const response = await profileCreate({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, body });
|
|
2349
|
+
return response.data;
|
|
2350
|
+
},
|
|
2351
|
+
/** profileDelete: /profiles/{profile_id}. Returns the API response body. */
|
|
2352
|
+
delete: async (profileId, requestOptions = {}) => {
|
|
2353
|
+
const response = await profileDelete({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "profile_id": profileId } });
|
|
2354
|
+
return response.data;
|
|
2355
|
+
},
|
|
2356
|
+
/** profileDuplicate: /profiles/{profile_id}/duplicate. Returns the API response body. */
|
|
2357
|
+
duplicate: async (profileId, body, requestOptions = {}) => {
|
|
2358
|
+
const response = await profileDuplicate({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "profile_id": profileId }, body });
|
|
2359
|
+
return response.data;
|
|
2360
|
+
},
|
|
2361
|
+
/** profileGet: /profiles/{profile_id}. Returns the API response body. */
|
|
2362
|
+
get: async (profileId, requestOptions = {}) => {
|
|
2363
|
+
const response = await profileGet({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "profile_id": profileId } });
|
|
2364
|
+
return response.data;
|
|
2365
|
+
},
|
|
2366
|
+
/** profileList: /profiles. Returns the API response body. */
|
|
2367
|
+
list: async (query = void 0, requestOptions = {}) => {
|
|
2368
|
+
const response = await profileList({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, query });
|
|
2369
|
+
return response.data;
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
};
|
|
2373
|
+
}
|
|
2374
|
+
|
|
2375
|
+
// src/session.ts
|
|
2376
|
+
var import_node_fs = require("fs");
|
|
2377
|
+
var import_promises3 = require("fs/promises");
|
|
2378
|
+
var import_node_path2 = require("path");
|
|
2379
|
+
var import_promises4 = require("timers/promises");
|
|
2380
|
+
|
|
2381
|
+
// src/captcha.ts
|
|
2382
|
+
async function executeWithCaptcha(action, budgetSeconds, request) {
|
|
2383
|
+
const explicit = action.type === "captcha_solve";
|
|
2384
|
+
let deadline = explicit ? performance.now() + budgetSeconds * 1e3 : void 0;
|
|
2385
|
+
let params = { captcha_timeout_seconds: budgetSeconds };
|
|
2386
|
+
let requestAction = action;
|
|
2387
|
+
let original;
|
|
2388
|
+
let last;
|
|
2389
|
+
const remaining = () => deadline === void 0 ? budgetSeconds : (deadline - performance.now()) / 1e3;
|
|
2390
|
+
const pause = (ms = 1e3) => sleep(Math.max(0, Math.min(ms, remaining() * 1e3)));
|
|
2391
|
+
const failure = (message, code) => ({
|
|
2392
|
+
started_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2393
|
+
ended_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2394
|
+
...original ?? last,
|
|
2395
|
+
action,
|
|
2396
|
+
success: false,
|
|
2397
|
+
message,
|
|
2398
|
+
code,
|
|
2399
|
+
exception: message,
|
|
2400
|
+
exception_detail: null,
|
|
2401
|
+
captcha: last?.captcha
|
|
2402
|
+
});
|
|
2403
|
+
while (true) {
|
|
2404
|
+
const left = remaining();
|
|
2405
|
+
if (left <= 0) return failure("CAPTCHA wait deadline exceeded", "captcha_timeout");
|
|
2406
|
+
params.captcha_timeout_seconds = left;
|
|
2407
|
+
const polling = requestAction.type === "captcha_solve";
|
|
2408
|
+
let result;
|
|
2409
|
+
try {
|
|
2410
|
+
result = await request(requestAction, { ...params }, polling ? Math.min(1e4, left * 1e3) : void 0);
|
|
2411
|
+
} catch (error) {
|
|
2412
|
+
const transport = error instanceof NotteTimeoutError || error instanceof TypeError || error instanceof SyntaxError;
|
|
2413
|
+
const transient = params.captcha_id !== void 0 && error instanceof NotteAPIError && [408, 429, 502, 503, 504].includes(error.statusCode);
|
|
2414
|
+
if (!polling || params.captcha_id === void 0 || !transport && !transient) throw error;
|
|
2415
|
+
await pause();
|
|
2416
|
+
continue;
|
|
2417
|
+
}
|
|
2418
|
+
last = result;
|
|
2419
|
+
const status = result.captcha;
|
|
2420
|
+
if (!status) {
|
|
2421
|
+
return params.captcha_id ? failure("Server omitted CAPTCHA polling status", "captcha_protocol_error") : result;
|
|
2422
|
+
}
|
|
2423
|
+
if (params.captcha_id && status.captcha_id !== params.captcha_id) {
|
|
2424
|
+
return failure("Server returned a different CAPTCHA solve", "captcha_protocol_error");
|
|
2425
|
+
}
|
|
2426
|
+
deadline ??= performance.now() + budgetSeconds * 1e3;
|
|
2427
|
+
if (!original && !explicit && result.action_executed === true) original = result;
|
|
2428
|
+
if (status.state === "cancelled" && status.cancel_reason === "navigation" && original) {
|
|
2429
|
+
return { ...original, captcha: status };
|
|
2430
|
+
}
|
|
2431
|
+
if (status.state === "failed" || status.state === "cancelled") {
|
|
2432
|
+
return failure(status.message || `CAPTCHA ${status.state}`, `captcha_${status.state}`);
|
|
2433
|
+
}
|
|
2434
|
+
if (status.state === "solved") {
|
|
2435
|
+
if (explicit) return result;
|
|
2436
|
+
if (original) return { ...original, captcha: status };
|
|
2437
|
+
if (!params.captcha_id && result.action_executed !== false) return result;
|
|
2438
|
+
params = {
|
|
2439
|
+
captcha_timeout_seconds: remaining(),
|
|
2440
|
+
target_page_id: status.page_id,
|
|
2441
|
+
target_generation: status.generation
|
|
2442
|
+
};
|
|
2443
|
+
requestAction = action;
|
|
2444
|
+
continue;
|
|
2445
|
+
}
|
|
2446
|
+
if (!explicit && !original && !params.captcha_id && result.action_executed !== false) {
|
|
2447
|
+
return failure("Server did not confirm whether the action executed", "captcha_execution_unknown");
|
|
2448
|
+
}
|
|
2449
|
+
params.captcha_id = status.captcha_id;
|
|
2450
|
+
requestAction = { type: "captcha_solve" };
|
|
2451
|
+
await pause(Math.min(1e3, Math.max(100, status.retry_after_ms ?? 1e3)));
|
|
2452
|
+
}
|
|
1931
2453
|
}
|
|
1932
2454
|
|
|
1933
2455
|
// src/page-fetch.ts
|
|
@@ -2183,10 +2705,10 @@ function responseFromEvaluated(raw) {
|
|
|
2183
2705
|
}
|
|
2184
2706
|
|
|
2185
2707
|
// src/cookies.ts
|
|
2186
|
-
var
|
|
2708
|
+
var import_promises2 = require("fs/promises");
|
|
2187
2709
|
var import_node_path = require("path");
|
|
2188
2710
|
async function readCookiesFile(cookieFile) {
|
|
2189
|
-
const cookies = JSON.parse(await (0,
|
|
2711
|
+
const cookies = JSON.parse(await (0, import_promises2.readFile)(cookieFile, "utf-8"));
|
|
2190
2712
|
if (!Array.isArray(cookies)) {
|
|
2191
2713
|
throw new InvalidRequestError(`Cookie file ${cookieFile} must contain a JSON list of cookies`);
|
|
2192
2714
|
}
|
|
@@ -2204,7 +2726,7 @@ async function createOrAppendCookiesToFile(cookieFile, cookies) {
|
|
|
2204
2726
|
}
|
|
2205
2727
|
}
|
|
2206
2728
|
existing.push(...cookies);
|
|
2207
|
-
await (0,
|
|
2729
|
+
await (0, import_promises2.writeFile)(cookieFile, JSON.stringify(existing), "utf-8");
|
|
2208
2730
|
});
|
|
2209
2731
|
}
|
|
2210
2732
|
var fileLocks = /* @__PURE__ */ new Map();
|
|
@@ -2328,7 +2850,6 @@ function openBrowser(url) {
|
|
|
2328
2850
|
var SESSION_START_TRIES = 3;
|
|
2329
2851
|
var CLUSTER_OVERLOAD_RETRY_DELAY_MS = 3e4;
|
|
2330
2852
|
var CAPTCHA_SOLVE_TIMEOUT_MS = 1e5;
|
|
2331
|
-
var CAPTCHA_SOLVE_TRIES = 3;
|
|
2332
2853
|
function observeServerOwnedDialog(_dialog) {
|
|
2333
2854
|
}
|
|
2334
2855
|
function installServerOwnedDialogPolicy(browser) {
|
|
@@ -2344,6 +2865,9 @@ var Session = class {
|
|
|
2344
2865
|
defaultRaiseOnFailure;
|
|
2345
2866
|
defaultPerceptionType;
|
|
2346
2867
|
cookieFile;
|
|
2868
|
+
cookiesLoaded = false;
|
|
2869
|
+
cookieLoadPromise;
|
|
2870
|
+
authenticationReady = false;
|
|
2347
2871
|
fileStorage;
|
|
2348
2872
|
sessionId = null;
|
|
2349
2873
|
isActive = false;
|
|
@@ -2379,12 +2903,17 @@ var Session = class {
|
|
|
2379
2903
|
* `CLUSTER_OVERLOAD_RETRY_DELAY_MS` on HTTP 529 (cluster overload). 4xx
|
|
2380
2904
|
* errors are never retried.
|
|
2381
2905
|
*
|
|
2906
|
+
* Managed-auth sessions wait for readiness by default. Pass
|
|
2907
|
+
* `{ wait_for_authentication: false }` for an explicit nonblocking start,
|
|
2908
|
+
* then call `waitForAuth()` before executing actions or connecting over CDP.
|
|
2909
|
+
* Cancellation during creation waits for its response so the new session can
|
|
2910
|
+
* be closed. Cancellation or failure during the startup wait also closes it.
|
|
2382
2911
|
* Prefer `session.use(async session => { ... })`, which also stops the session.
|
|
2383
2912
|
* @example
|
|
2384
2913
|
* const session = client.Session();
|
|
2385
2914
|
* await session.start();
|
|
2386
2915
|
*/
|
|
2387
|
-
async start() {
|
|
2916
|
+
async start(options = {}) {
|
|
2388
2917
|
if (this.legacyHeadless === false) {
|
|
2389
2918
|
throw new Error(
|
|
2390
2919
|
"Remote `headless: false` is no longer supported. `headless: true` sessions still include session replays and access to the live viewer."
|
|
@@ -2397,11 +2926,19 @@ var Session = class {
|
|
|
2397
2926
|
if (this.isActive) {
|
|
2398
2927
|
throw new Error("Session is already active");
|
|
2399
2928
|
}
|
|
2400
|
-
|
|
2929
|
+
options.signal?.throwIfAborted();
|
|
2930
|
+
validateAuthRetry(this.options.auth_retry ?? 0);
|
|
2931
|
+
const { auth_retry, wait_for_authentication, ...request } = this.options;
|
|
2932
|
+
const body = {
|
|
2933
|
+
...request,
|
|
2934
|
+
...request.auth_ids?.length ? { auth_retry: auth_retry ?? 0, wait_for_authentication: false } : {}
|
|
2935
|
+
};
|
|
2936
|
+
const shouldWait = options.wait_for_authentication ?? wait_for_authentication ?? true;
|
|
2401
2937
|
let tries = SESSION_START_TRIES;
|
|
2402
2938
|
const origTries = tries;
|
|
2403
2939
|
let sessionData;
|
|
2404
2940
|
while (tries > 0) {
|
|
2941
|
+
options.signal?.throwIfAborted();
|
|
2405
2942
|
tries -= 1;
|
|
2406
2943
|
try {
|
|
2407
2944
|
const response = await sessionStart({ client: this.client.getClient(), body, throwOnError: true });
|
|
@@ -2416,7 +2953,16 @@ var Session = class {
|
|
|
2416
2953
|
console.warn(
|
|
2417
2954
|
`Failed to start session due to cluster overload, retrying in ${CLUSTER_OVERLOAD_RETRY_DELAY_MS / 1e3} seconds (${retryStr})...`
|
|
2418
2955
|
);
|
|
2419
|
-
|
|
2956
|
+
if (options.signal) {
|
|
2957
|
+
try {
|
|
2958
|
+
await (0, import_promises4.setTimeout)(CLUSTER_OVERLOAD_RETRY_DELAY_MS, void 0, { signal: options.signal });
|
|
2959
|
+
} catch (error2) {
|
|
2960
|
+
options.signal.throwIfAborted();
|
|
2961
|
+
throw error2;
|
|
2962
|
+
}
|
|
2963
|
+
} else {
|
|
2964
|
+
await sleep(CLUSTER_OVERLOAD_RETRY_DELAY_MS);
|
|
2965
|
+
}
|
|
2420
2966
|
} else {
|
|
2421
2967
|
console.warn(`Failed to start session: retrying (${retryStr})`);
|
|
2422
2968
|
}
|
|
@@ -2428,19 +2974,17 @@ var Session = class {
|
|
|
2428
2974
|
this.sessionId = sessionData.session_id;
|
|
2429
2975
|
this.isActive = true;
|
|
2430
2976
|
this.response = sessionData;
|
|
2977
|
+
this.cookiesLoaded = false;
|
|
2978
|
+
this.cookieLoadPromise = void 0;
|
|
2979
|
+
this.authenticationReady = false;
|
|
2431
2980
|
this.fileStorage = this.fileStorage?.forSession(sessionData.session_id);
|
|
2432
2981
|
try {
|
|
2982
|
+
options.signal?.throwIfAborted();
|
|
2983
|
+
if (shouldWait) await this.waitForAuth(options);
|
|
2433
2984
|
if (this.openViewer) {
|
|
2434
2985
|
this.openViewerInBrowser();
|
|
2435
2986
|
}
|
|
2436
|
-
if (this.
|
|
2437
|
-
if ((0, import_node_fs.existsSync)(this.cookieFile)) {
|
|
2438
|
-
console.info(`\u{1F36A} Automatically loading cookies from ${this.cookieFile}`);
|
|
2439
|
-
await this.setCookiesFromFile(this.cookieFile);
|
|
2440
|
-
} else {
|
|
2441
|
-
console.warn(`\u{1F36A} Cookie file ${this.cookieFile} not found, skipping cookie loading`);
|
|
2442
|
-
}
|
|
2443
|
-
}
|
|
2987
|
+
if (this.response?.status === "active") await this.loadInitialCookies();
|
|
2444
2988
|
} catch (error) {
|
|
2445
2989
|
try {
|
|
2446
2990
|
await this.stop("error");
|
|
@@ -2450,6 +2994,65 @@ var Session = class {
|
|
|
2450
2994
|
throw error;
|
|
2451
2995
|
}
|
|
2452
2996
|
}
|
|
2997
|
+
/**
|
|
2998
|
+
* Wait for this session to become usable without creating a session or submitting another login.
|
|
2999
|
+
* A standalone wait leaves session ownership with the caller, including on timeout or cancellation.
|
|
3000
|
+
*/
|
|
3001
|
+
async waitForAuth(options = {}) {
|
|
3002
|
+
options.signal?.throwIfAborted();
|
|
3003
|
+
if (!this.response) throw new Error("Session has not started");
|
|
3004
|
+
if (this.response.status === "active") {
|
|
3005
|
+
await this.loadInitialCookies();
|
|
3006
|
+
return;
|
|
3007
|
+
}
|
|
3008
|
+
const sessionId = this.lastSessionId();
|
|
3009
|
+
this.response = await pollAuth(async (signal) => {
|
|
3010
|
+
const response = await sessionAuthReadiness({
|
|
3011
|
+
client: this.client.getClient(),
|
|
3012
|
+
path: { session_id: sessionId },
|
|
3013
|
+
headers: { [TIMEOUT_HEADER]: "10000" },
|
|
3014
|
+
signal,
|
|
3015
|
+
throwOnError: true
|
|
3016
|
+
});
|
|
3017
|
+
let result = response.data;
|
|
3018
|
+
if (result.status === "active") {
|
|
3019
|
+
this.authenticationReady = true;
|
|
3020
|
+
result = (await sessionStatus({
|
|
3021
|
+
client: this.client.getClient(),
|
|
3022
|
+
path: { session_id: sessionId },
|
|
3023
|
+
headers: { [TIMEOUT_HEADER]: "10000" },
|
|
3024
|
+
signal,
|
|
3025
|
+
throwOnError: true
|
|
3026
|
+
})).data;
|
|
3027
|
+
this.authenticationReady = result.status === "active";
|
|
3028
|
+
if (this.authenticationReady) return result;
|
|
3029
|
+
}
|
|
3030
|
+
if (result.status !== "authenticating") throw new ManagedAuthError(result.error || "Session authentication failed");
|
|
3031
|
+
return void 0;
|
|
3032
|
+
}, options);
|
|
3033
|
+
await this.loadInitialCookies();
|
|
3034
|
+
}
|
|
3035
|
+
async loadInitialCookies() {
|
|
3036
|
+
if (this.cookiesLoaded || this.cookieFile === void 0) return;
|
|
3037
|
+
if (!this.cookieLoadPromise) {
|
|
3038
|
+
const cookieFile = this.cookieFile;
|
|
3039
|
+
this.cookieLoadPromise = (async () => {
|
|
3040
|
+
if ((0, import_node_fs.existsSync)(cookieFile)) {
|
|
3041
|
+
console.info(`\u{1F36A} Automatically loading cookies from ${cookieFile}`);
|
|
3042
|
+
await this.setCookiesFromFile(cookieFile);
|
|
3043
|
+
} else {
|
|
3044
|
+
console.warn(`\u{1F36A} Cookie file ${cookieFile} not found, skipping cookie loading`);
|
|
3045
|
+
}
|
|
3046
|
+
this.cookiesLoaded = true;
|
|
3047
|
+
})();
|
|
3048
|
+
}
|
|
3049
|
+
const pending = this.cookieLoadPromise;
|
|
3050
|
+
try {
|
|
3051
|
+
await pending;
|
|
3052
|
+
} finally {
|
|
3053
|
+
if (this.cookieLoadPromise === pending) this.cookieLoadPromise = void 0;
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
2453
3056
|
/**
|
|
2454
3057
|
* Stop the session and clean up resources (including any Playwright
|
|
2455
3058
|
* connection opened with `page()`). When a `cookie_file` was given, the
|
|
@@ -2465,7 +3068,7 @@ var Session = class {
|
|
|
2465
3068
|
}
|
|
2466
3069
|
const sessionId = this.sessionId;
|
|
2467
3070
|
await this.closePlaywright();
|
|
2468
|
-
if (this.cookieFile !== void 0) {
|
|
3071
|
+
if (this.cookieFile !== void 0 && (this.authenticationReady || this.response?.status === "active")) {
|
|
2469
3072
|
try {
|
|
2470
3073
|
const cookies = await this.getCookies();
|
|
2471
3074
|
await createOrAppendCookiesToFile(this.cookieFile, cookies);
|
|
@@ -2644,7 +3247,7 @@ var Session = class {
|
|
|
2644
3247
|
throw new Error(`Failed to download replay: HTTP ${response.status}`);
|
|
2645
3248
|
}
|
|
2646
3249
|
const target = (0, import_node_path2.resolve)(path);
|
|
2647
|
-
await (0,
|
|
3250
|
+
await (0, import_promises3.writeFile)(target, new Uint8Array(await response.arrayBuffer()));
|
|
2648
3251
|
return target;
|
|
2649
3252
|
}
|
|
2650
3253
|
// #######################################################################
|
|
@@ -2826,32 +3429,22 @@ var Session = class {
|
|
|
2826
3429
|
async execute(action, options = {}) {
|
|
2827
3430
|
const sessionId = this.requireSessionId();
|
|
2828
3431
|
const raiseOnFailure = typeof options === "boolean" ? options : options.raiseOnFailure ?? this.defaultRaiseOnFailure;
|
|
2829
|
-
const
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
3432
|
+
const result = await executeWithCaptcha(
|
|
3433
|
+
action,
|
|
3434
|
+
this.client.getConfig().captchaTimeoutSeconds ?? 180,
|
|
3435
|
+
async (requestAction, params, timeoutMs) => {
|
|
3436
|
+
const query = params;
|
|
2834
3437
|
const response = await pageExecute({
|
|
2835
3438
|
client: this.client.getClient(),
|
|
2836
3439
|
path: { session_id: sessionId },
|
|
2837
|
-
body:
|
|
2838
|
-
|
|
3440
|
+
body: requestAction,
|
|
3441
|
+
query,
|
|
3442
|
+
headers: timeoutMs === void 0 ? void 0 : { [TIMEOUT_HEADER]: String(timeoutMs) },
|
|
2839
3443
|
throwOnError: true
|
|
2840
3444
|
});
|
|
2841
|
-
|
|
2842
|
-
break;
|
|
2843
|
-
} catch (error) {
|
|
2844
|
-
if (isCaptcha && error instanceof NotteAPIError && error.statusCode === 408) {
|
|
2845
|
-
lastError = error;
|
|
2846
|
-
console.warn("Solve captcha action timed out. This can happen for long and complex captchas. Retrying...");
|
|
2847
|
-
continue;
|
|
2848
|
-
}
|
|
2849
|
-
throw error;
|
|
3445
|
+
return response.data;
|
|
2850
3446
|
}
|
|
2851
|
-
|
|
2852
|
-
if (!result) {
|
|
2853
|
-
throw lastError ?? new Error(`Failed to execute action '${action.type}'. This should not happen. Please report this issue.`);
|
|
2854
|
-
}
|
|
3447
|
+
);
|
|
2855
3448
|
if (raiseOnFailure && !result.success) {
|
|
2856
3449
|
console.error(`\u{1F6A8} Execution failed with message: '${result.message}'`);
|
|
2857
3450
|
if (result.exception_detail) {
|
|
@@ -2945,7 +3538,10 @@ var Session = class {
|
|
|
2945
3538
|
* Context manager pattern: start the session, run the callback and stop the
|
|
2946
3539
|
* session, with close reason `error` when the callback throws.
|
|
2947
3540
|
*
|
|
2948
|
-
*
|
|
3541
|
+
* Always waits for Managed Auth readiness before invoking the callback.
|
|
3542
|
+
*
|
|
3543
|
+
* @param callback - Async work to perform with the ready session.
|
|
3544
|
+
* @param options - Controls the Managed Auth readiness wait, including timeout and cancellation.
|
|
2949
3545
|
* @returns The callback's return value after session cleanup has been attempted.
|
|
2950
3546
|
* @throws Error if startup fails, the callback throws, or cleanup fails after a successful callback.
|
|
2951
3547
|
* @example
|
|
@@ -2953,8 +3549,8 @@ var Session = class {
|
|
|
2953
3549
|
* await session.execute({ type: 'goto', url: 'https://www.notte.cc' });
|
|
2954
3550
|
* });
|
|
2955
3551
|
*/
|
|
2956
|
-
async use(callback) {
|
|
2957
|
-
await this.start();
|
|
3552
|
+
async use(callback, options = {}) {
|
|
3553
|
+
await this.start({ ...options, wait_for_authentication: true });
|
|
2958
3554
|
let callbackFailed = false;
|
|
2959
3555
|
try {
|
|
2960
3556
|
return await callback(this);
|
|
@@ -3992,7 +4588,7 @@ var NottePersona = class {
|
|
|
3992
4588
|
};
|
|
3993
4589
|
|
|
3994
4590
|
// src/functions.ts
|
|
3995
|
-
var
|
|
4591
|
+
var import_promises5 = require("fs/promises");
|
|
3996
4592
|
var import_node_path3 = require("path");
|
|
3997
4593
|
|
|
3998
4594
|
// src/encryption.ts
|
|
@@ -4475,7 +5071,7 @@ var NotteFunction = class {
|
|
|
4475
5071
|
}
|
|
4476
5072
|
const code = await response.text();
|
|
4477
5073
|
if (path !== void 0) {
|
|
4478
|
-
await (0,
|
|
5074
|
+
await (0, import_promises5.writeFile)(path, code, "utf8");
|
|
4479
5075
|
}
|
|
4480
5076
|
return code;
|
|
4481
5077
|
}
|
|
@@ -4513,7 +5109,7 @@ async function readPythonFile(path) {
|
|
|
4513
5109
|
assertPythonPath(path);
|
|
4514
5110
|
let bytes;
|
|
4515
5111
|
try {
|
|
4516
|
-
bytes = await (0,
|
|
5112
|
+
bytes = await (0, import_promises5.readFile)(path);
|
|
4517
5113
|
} catch (error) {
|
|
4518
5114
|
throw new InvalidRequestError(
|
|
4519
5115
|
`The file '${path}' could not be read: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -4630,11 +5226,11 @@ async function readFunctionStream(body, onLog, path, signal) {
|
|
|
4630
5226
|
|
|
4631
5227
|
// src/files.ts
|
|
4632
5228
|
var import_node_fs2 = require("fs");
|
|
4633
|
-
var
|
|
5229
|
+
var import_promises6 = require("fs/promises");
|
|
4634
5230
|
var import_node_path4 = require("path");
|
|
4635
5231
|
var import_node_crypto2 = require("crypto");
|
|
4636
5232
|
var import_node_stream = require("stream");
|
|
4637
|
-
var
|
|
5233
|
+
var import_promises7 = require("stream/promises");
|
|
4638
5234
|
var FileNotFoundError = class extends NotteError {
|
|
4639
5235
|
};
|
|
4640
5236
|
var FileExistsError = class extends NotteError {
|
|
@@ -4834,11 +5430,11 @@ var RemoteFileStorage = class _RemoteFileStorage {
|
|
|
4834
5430
|
async upload(file, uploadFileName) {
|
|
4835
5431
|
const files = this.files();
|
|
4836
5432
|
if (typeof file === "string") {
|
|
4837
|
-
const info = await (0,
|
|
5433
|
+
const info = await (0, import_promises6.stat)(file).catch(() => null);
|
|
4838
5434
|
if (!info?.isFile()) {
|
|
4839
5435
|
throw new InvalidRequestError(`Cannot upload file ${file}: it is not a file`);
|
|
4840
5436
|
}
|
|
4841
|
-
const bytes = await (0,
|
|
5437
|
+
const bytes = await (0, import_promises6.readFile)(file);
|
|
4842
5438
|
return files.upload(bytes, uploadFileName ?? (0, import_node_path4.basename)(file));
|
|
4843
5439
|
}
|
|
4844
5440
|
const filename = uploadFileName ?? (file instanceof File ? file.name : "file");
|
|
@@ -4890,10 +5486,10 @@ var RemoteFileStorage = class _RemoteFileStorage {
|
|
|
4890
5486
|
if (safeName === "" || safeName === "." || safeName === "..") {
|
|
4891
5487
|
throw new NotteError(`Unsafe filename returned for file ${fileId}: ${JSON.stringify(metadata.filename)}`);
|
|
4892
5488
|
}
|
|
4893
|
-
await (0,
|
|
5489
|
+
await (0, import_promises6.mkdir)(localDir, { recursive: true });
|
|
4894
5490
|
const destination = (0, import_node_path4.join)(localDir, safeName);
|
|
4895
5491
|
if (!options.force) {
|
|
4896
|
-
const exists = await (0,
|
|
5492
|
+
const exists = await (0, import_promises6.stat)(destination).then(() => true, () => false);
|
|
4897
5493
|
if (exists) {
|
|
4898
5494
|
throw new FileExistsError(`${destination} already exists; pass force: true to overwrite it`);
|
|
4899
5495
|
}
|
|
@@ -4901,25 +5497,25 @@ var RemoteFileStorage = class _RemoteFileStorage {
|
|
|
4901
5497
|
const body = await files.stream(fileId);
|
|
4902
5498
|
const temporary = (0, import_node_path4.join)(localDir, `.${safeName}.${(0, import_node_crypto2.randomBytes)(8).toString("hex")}.part`);
|
|
4903
5499
|
try {
|
|
4904
|
-
await (0,
|
|
5500
|
+
await (0, import_promises7.pipeline)(
|
|
4905
5501
|
import_node_stream.Readable.fromWeb(body),
|
|
4906
5502
|
(0, import_node_fs2.createWriteStream)(temporary, { flags: "wx" })
|
|
4907
5503
|
);
|
|
4908
5504
|
if (options.force) {
|
|
4909
|
-
await (0,
|
|
5505
|
+
await (0, import_promises6.rename)(temporary, destination);
|
|
4910
5506
|
} else {
|
|
4911
5507
|
try {
|
|
4912
|
-
await (0,
|
|
5508
|
+
await (0, import_promises6.link)(temporary, destination);
|
|
4913
5509
|
} catch (error) {
|
|
4914
5510
|
if (error.code === "EEXIST") {
|
|
4915
5511
|
throw new FileExistsError(`${destination} already exists; pass force: true to overwrite it`);
|
|
4916
5512
|
}
|
|
4917
5513
|
throw error;
|
|
4918
5514
|
}
|
|
4919
|
-
await (0,
|
|
5515
|
+
await (0, import_promises6.rm)(temporary, { force: true });
|
|
4920
5516
|
}
|
|
4921
5517
|
} catch (error) {
|
|
4922
|
-
await (0,
|
|
5518
|
+
await (0, import_promises6.rm)(temporary, { force: true });
|
|
4923
5519
|
throw error;
|
|
4924
5520
|
}
|
|
4925
5521
|
return destination;
|
|
@@ -5079,11 +5675,16 @@ function isRelativeProxyUrl(baseUrl) {
|
|
|
5079
5675
|
var NotteClient3 = class {
|
|
5080
5676
|
config;
|
|
5081
5677
|
client = createClient();
|
|
5678
|
+
resources = createResources(this.client, () => this.config.apiKey ?? "");
|
|
5082
5679
|
constructor(config = {}) {
|
|
5083
5680
|
const apiKey = config.apiKey || process.env.NOTTE_API_KEY;
|
|
5084
5681
|
const baseUrl = config.baseUrl || process.env.NOTTE_API_URL || DEFAULT_NOTTE_API_URL;
|
|
5085
5682
|
const dbPreview = config.dbPreview || process.env[DB_PREVIEW_ENV] || void 0;
|
|
5086
5683
|
const timeoutMs = config.timeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
|
5684
|
+
const captchaTimeoutSeconds = config.captchaTimeoutSeconds ?? 180;
|
|
5685
|
+
if (!Number.isFinite(captchaTimeoutSeconds) || captchaTimeoutSeconds <= 0) {
|
|
5686
|
+
throw new InvalidRequestError("captchaTimeoutSeconds must be positive and finite");
|
|
5687
|
+
}
|
|
5087
5688
|
if (!(timeoutMs >= 0)) {
|
|
5088
5689
|
throw new InvalidRequestError("timeoutMs must be a non-negative number");
|
|
5089
5690
|
}
|
|
@@ -5102,7 +5703,7 @@ var NotteClient3 = class {
|
|
|
5102
5703
|
"NOTTE_API_KEY needs to be provided. Pass config.apiKey or set the NOTTE_API_KEY environment variable."
|
|
5103
5704
|
);
|
|
5104
5705
|
}
|
|
5105
|
-
this.config = { baseUrl, apiKey, timeoutMs, dbPreview, verbose: config.verbose ?? false };
|
|
5706
|
+
this.config = { baseUrl, apiKey, timeoutMs, captchaTimeoutSeconds, dbPreview, verbose: config.verbose ?? false };
|
|
5106
5707
|
if (baseUrl !== DEFAULT_NOTTE_API_URL && !isProxyMode) {
|
|
5107
5708
|
console.warn(`NOTTE_API_URL is set to: ${baseUrl}`);
|
|
5108
5709
|
}
|
|
@@ -5317,36 +5918,40 @@ var NotteClient3 = class {
|
|
|
5317
5918
|
Function(options) {
|
|
5318
5919
|
return this.NotteFunction(options);
|
|
5319
5920
|
}
|
|
5320
|
-
/**
|
|
5921
|
+
/** Client-bound session API operations. `list()` retains its array return value. */
|
|
5321
5922
|
get sessions() {
|
|
5322
5923
|
return {
|
|
5924
|
+
...this.resources.sessions,
|
|
5323
5925
|
list: async (options = {}) => {
|
|
5324
5926
|
const response = await listSessions({ client: this.getClient(), query: options });
|
|
5325
5927
|
return response.data?.items ?? [];
|
|
5326
5928
|
}
|
|
5327
5929
|
};
|
|
5328
5930
|
}
|
|
5329
|
-
/**
|
|
5931
|
+
/** Client-bound agent API operations. `list()` retains its array return value. */
|
|
5330
5932
|
get agents() {
|
|
5331
5933
|
return {
|
|
5934
|
+
...this.resources.agents,
|
|
5332
5935
|
list: async (options = {}) => {
|
|
5333
5936
|
const response = await listAgents({ client: this.getClient(), query: options });
|
|
5334
5937
|
return response.data?.items ?? [];
|
|
5335
5938
|
}
|
|
5336
5939
|
};
|
|
5337
5940
|
}
|
|
5338
|
-
/**
|
|
5941
|
+
/** Client-bound vault API operations. `list()` retains its array return value. */
|
|
5339
5942
|
get vaults() {
|
|
5340
5943
|
return {
|
|
5944
|
+
...this.resources.vaults,
|
|
5341
5945
|
list: async (options = {}) => {
|
|
5342
5946
|
const response = await listVaults({ client: this.getClient(), query: options });
|
|
5343
5947
|
return response.data?.items ?? [];
|
|
5344
5948
|
}
|
|
5345
5949
|
};
|
|
5346
5950
|
}
|
|
5347
|
-
/**
|
|
5951
|
+
/** Client-bound function API operations. `list()` retains its array return value. */
|
|
5348
5952
|
get functions() {
|
|
5349
5953
|
return {
|
|
5954
|
+
...this.resources.functions,
|
|
5350
5955
|
list: async (options = {}) => {
|
|
5351
5956
|
const response = await listFunctions({ client: this.getClient(), query: options });
|
|
5352
5957
|
return response.data?.items ?? [];
|
|
@@ -5369,6 +5974,10 @@ var NotteClient3 = class {
|
|
|
5369
5974
|
get secrets() {
|
|
5370
5975
|
return new NotteSecrets(this);
|
|
5371
5976
|
}
|
|
5977
|
+
/** Managed authentication: verify connections, request login, and wait for readiness. */
|
|
5978
|
+
get managedAuth() {
|
|
5979
|
+
return new NotteManagedAuth(this);
|
|
5980
|
+
}
|
|
5372
5981
|
/** Usage and billing (`/usage`, `/usage/logs`). */
|
|
5373
5982
|
get usage() {
|
|
5374
5983
|
return new NotteUsage(this);
|
|
@@ -5378,6 +5987,7 @@ var NotteClient3 = class {
|
|
|
5378
5987
|
*/
|
|
5379
5988
|
get personas() {
|
|
5380
5989
|
return {
|
|
5990
|
+
...this.resources.personas,
|
|
5381
5991
|
list: async (options) => {
|
|
5382
5992
|
const response = await listPersonas({
|
|
5383
5993
|
client: this.getClient(),
|
|
@@ -5393,6 +6003,10 @@ var NotteClient3 = class {
|
|
|
5393
6003
|
getClient() {
|
|
5394
6004
|
return this.client;
|
|
5395
6005
|
}
|
|
6006
|
+
/** Client-bound profile API operations, generated from OpenAPI. */
|
|
6007
|
+
get profiles() {
|
|
6008
|
+
return this.resources.profiles;
|
|
6009
|
+
}
|
|
5396
6010
|
async scrape(url, options = {}) {
|
|
5397
6011
|
const body = await buildScrapeBody(options);
|
|
5398
6012
|
const response = await scrapeWebpage({
|
|
@@ -5466,6 +6080,72 @@ function withTimeout(signal, timeoutMs) {
|
|
|
5466
6080
|
return { signal: composite, release };
|
|
5467
6081
|
}
|
|
5468
6082
|
|
|
6083
|
+
// src/actions.ts
|
|
6084
|
+
function builder(type) {
|
|
6085
|
+
return (...[input]) => ({ ...input ?? {}, type });
|
|
6086
|
+
}
|
|
6087
|
+
var goto = builder("goto");
|
|
6088
|
+
var gotoNewTab = builder("goto_new_tab");
|
|
6089
|
+
var closeTab = builder("close_tab");
|
|
6090
|
+
var switchTab = builder("switch_tab");
|
|
6091
|
+
var goBack = builder("go_back");
|
|
6092
|
+
var goForward = builder("go_forward");
|
|
6093
|
+
var reload = builder("reload");
|
|
6094
|
+
var wait = builder("wait");
|
|
6095
|
+
var pressKey = builder("press_key");
|
|
6096
|
+
var scrollUp = builder("scroll_up");
|
|
6097
|
+
var scrollDown = builder("scroll_down");
|
|
6098
|
+
var captchaSolve = builder("captcha_solve");
|
|
6099
|
+
var help = builder("help");
|
|
6100
|
+
var completion = builder("completion");
|
|
6101
|
+
var scrape = builder("scrape");
|
|
6102
|
+
var emailRead = builder("email_read");
|
|
6103
|
+
var emailVerificationRead = builder("email_verification_read");
|
|
6104
|
+
var smsRead = builder("sms_read");
|
|
6105
|
+
var evaluateJs = builder("evaluate_js");
|
|
6106
|
+
var formFill = builder("form_fill");
|
|
6107
|
+
var click = builder("click");
|
|
6108
|
+
var fill = builder("fill");
|
|
6109
|
+
var multiFactorFill = builder("multi_factor_fill");
|
|
6110
|
+
var fallbackFill = builder("fallback_fill");
|
|
6111
|
+
var check = builder("check");
|
|
6112
|
+
var selectDropdownOption = builder("select_dropdown_option");
|
|
6113
|
+
var uploadFile = builder("upload_file");
|
|
6114
|
+
var downloadFile = builder("download_file");
|
|
6115
|
+
var actions = {
|
|
6116
|
+
goto,
|
|
6117
|
+
gotoNewTab,
|
|
6118
|
+
closeTab,
|
|
6119
|
+
switchTab,
|
|
6120
|
+
goBack,
|
|
6121
|
+
goForward,
|
|
6122
|
+
reload,
|
|
6123
|
+
wait,
|
|
6124
|
+
pressKey,
|
|
6125
|
+
scrollUp,
|
|
6126
|
+
scrollDown,
|
|
6127
|
+
captchaSolve,
|
|
6128
|
+
help,
|
|
6129
|
+
completion,
|
|
6130
|
+
scrape,
|
|
6131
|
+
emailRead,
|
|
6132
|
+
emailVerificationRead,
|
|
6133
|
+
smsRead,
|
|
6134
|
+
evaluateJs,
|
|
6135
|
+
formFill,
|
|
6136
|
+
click,
|
|
6137
|
+
fill,
|
|
6138
|
+
multiFactorFill,
|
|
6139
|
+
fallbackFill,
|
|
6140
|
+
check,
|
|
6141
|
+
selectDropdownOption,
|
|
6142
|
+
uploadFile,
|
|
6143
|
+
downloadFile
|
|
6144
|
+
};
|
|
6145
|
+
function isCaptchaSolveAction(action) {
|
|
6146
|
+
return action.type === "captcha_solve";
|
|
6147
|
+
}
|
|
6148
|
+
|
|
5469
6149
|
// src/proxy/types.ts
|
|
5470
6150
|
var NotteProxyAuthError = class extends Error {
|
|
5471
6151
|
constructor(message = "Unauthorized") {
|
|
@@ -5507,12 +6187,14 @@ var createClient2 = (config) => {
|
|
|
5507
6187
|
FileExistsError,
|
|
5508
6188
|
FileNotFoundError,
|
|
5509
6189
|
InvalidRequestError,
|
|
6190
|
+
ManagedAuthError,
|
|
5510
6191
|
NotteAPIError,
|
|
5511
6192
|
NotteAPIExecutionError,
|
|
5512
6193
|
NotteAnything,
|
|
5513
6194
|
NotteClient,
|
|
5514
6195
|
NotteError,
|
|
5515
6196
|
NotteFunction,
|
|
6197
|
+
NotteManagedAuth,
|
|
5516
6198
|
NottePersona,
|
|
5517
6199
|
NotteProxyAuthError,
|
|
5518
6200
|
NotteSecrets,
|
|
@@ -5542,10 +6224,13 @@ var createClient2 = (config) => {
|
|
|
5542
6224
|
connectLinkMailboxes,
|
|
5543
6225
|
connectLinkStatus,
|
|
5544
6226
|
connectLinkSubmit,
|
|
6227
|
+
connectPaymentWallet,
|
|
5545
6228
|
createClient,
|
|
5546
6229
|
createOrAppendCookiesToFile,
|
|
6230
|
+
createPayment,
|
|
5547
6231
|
deleteSecret,
|
|
5548
6232
|
deleteSessionFile,
|
|
6233
|
+
disconnectPaymentWallet,
|
|
5549
6234
|
downloadSessionFile,
|
|
5550
6235
|
functionCreate,
|
|
5551
6236
|
functionDelete,
|
|
@@ -5561,6 +6246,7 @@ var createClient2 = (config) => {
|
|
|
5561
6246
|
functionScheduleDelete,
|
|
5562
6247
|
functionScheduleSet,
|
|
5563
6248
|
functionUpdate,
|
|
6249
|
+
getPayment,
|
|
5564
6250
|
getRootDomain,
|
|
5565
6251
|
getScript,
|
|
5566
6252
|
getSecret,
|
|
@@ -5617,11 +6303,13 @@ var createClient2 = (config) => {
|
|
|
5617
6303
|
scrapeFromHtml,
|
|
5618
6304
|
scrapeWebpage,
|
|
5619
6305
|
searchWeb,
|
|
6306
|
+
sessionAuthReadiness,
|
|
5620
6307
|
sessionCookiesGet,
|
|
5621
6308
|
sessionCookiesSet,
|
|
5622
6309
|
sessionDebugInfo,
|
|
5623
6310
|
sessionNetworkLogs,
|
|
5624
6311
|
sessionOffset,
|
|
6312
|
+
sessionProfilePreview,
|
|
5625
6313
|
sessionReplay,
|
|
5626
6314
|
sessionStart,
|
|
5627
6315
|
sessionStatus,
|