fca-nx 7.5.6 → 7.6.0

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.
@@ -16,18 +16,14 @@ try {
16
16
  storage: path.join(databasePath, "database.sqlite"),
17
17
  logging: false,
18
18
  pool: {
19
- max: 5,
19
+ max: 1,
20
20
  min: 0,
21
- acquire: 30000,
21
+ acquire: 5000,
22
22
  idle: 10000
23
23
  },
24
24
  retry: {
25
- max: 3
26
- },
27
- dialectOptions: {
28
- timeout: 5000
29
- },
30
- isolationLevel: Sequelize.Transaction.ISOLATION_LEVELS.READ_COMMITTED
25
+ max: 0
26
+ }
31
27
  });
32
28
 
33
29
  // Load models with error handling
@@ -64,17 +60,25 @@ try {
64
60
  models.sequelize = sequelize;
65
61
  models.Sequelize = Sequelize;
66
62
  models.isReady = true;
67
- models.syncAll = async () => {
68
- try {
69
- if (!sequelize) {
70
- throw new Error("Sequelize instance not initialized");
71
- }
72
- await sequelize.sync({ force: false });
73
- } catch (error) {
74
- console.error("Failed to synchronize models:", error && error.message ? error.message : String(error));
75
- throw error;
63
+ let readyPromise = null;
64
+ models.ensureReady = () => {
65
+ if (!sequelize) return Promise.reject(new Error("Database not initialized"));
66
+ if (!readyPromise) {
67
+ readyPromise = (async () => {
68
+ await sequelize.authenticate();
69
+ await sequelize.query("PRAGMA journal_mode=WAL;");
70
+ await sequelize.query("PRAGMA synchronous=NORMAL;");
71
+ await sequelize.query("PRAGMA busy_timeout=2000;");
72
+ await sequelize.query("PRAGMA temp_store=MEMORY;");
73
+ await sequelize.sync({ force: false });
74
+ })().catch((error) => {
75
+ readyPromise = null;
76
+ throw error;
77
+ });
76
78
  }
79
+ return readyPromise;
77
80
  };
81
+ models.syncAll = () => models.ensureReady();
78
82
  } catch (initError) {
79
83
  console.error("Database initialization error:", initError && initError.message ? initError.message : String(initError));
80
84
  models.sequelize = null;
@@ -83,6 +87,7 @@ try {
83
87
  models.syncAll = async () => {
84
88
  throw new Error("Database not initialized");
85
89
  };
90
+ models.ensureReady = models.syncAll;
86
91
  }
87
92
 
88
93
  module.exports = models;
@@ -19,6 +19,7 @@ module.exports = function (bot) {
19
19
  return { thread: { threadID: validateId(threadID, ID_FIELD), ...(data || {}) }, created: true };
20
20
  }
21
21
  try {
22
+ if (typeof models.ensureReady === "function") await models.ensureReady();
22
23
  threadID = validateId(threadID, ID_FIELD);
23
24
  let thread = await Thread.findOne({ where: { threadID } });
24
25
  if (thread) return { thread: thread.get(), created: false };
@@ -32,6 +33,7 @@ module.exports = function (bot) {
32
33
  async get(threadID) {
33
34
  if (!Thread) return null;
34
35
  try {
36
+ if (typeof models.ensureReady === "function") await models.ensureReady();
35
37
  threadID = validateId(threadID, ID_FIELD);
36
38
  const thread = await Thread.findOne({ where: { threadID } });
37
39
  return thread ? thread.get() : null;
@@ -45,6 +47,7 @@ module.exports = function (bot) {
45
47
  return { thread: { threadID: validateId(threadID, ID_FIELD), ...(data || {}) }, created: false };
46
48
  }
47
49
  try {
50
+ if (typeof models.ensureReady === "function") await models.ensureReady();
48
51
  threadID = validateId(threadID, ID_FIELD);
49
52
  validateData(data);
50
53
  const thread = await Thread.findOne({ where: { threadID } });
@@ -62,6 +65,7 @@ module.exports = function (bot) {
62
65
  async del(threadID) {
63
66
  if (!Thread) throw new Error(DB_NOT_INIT);
64
67
  try {
68
+ if (typeof models.ensureReady === "function") await models.ensureReady();
65
69
  threadID = validateId(threadID, ID_FIELD);
66
70
  const result = await Thread.destroy({ where: { threadID } });
67
71
  if (result === 0) throw new Error("No thread found with the specified threadID");
@@ -74,6 +78,7 @@ module.exports = function (bot) {
74
78
  async delAll() {
75
79
  if (!Thread) return 0;
76
80
  try {
81
+ if (typeof models.ensureReady === "function") await models.ensureReady();
77
82
  return await Thread.destroy({ where: {} });
78
83
  } catch (err) {
79
84
  throw wrapError("Failed to delete all threads", err);
@@ -83,6 +88,7 @@ module.exports = function (bot) {
83
88
  async getAll(keys = null) {
84
89
  if (!Thread) return [];
85
90
  try {
91
+ if (typeof models.ensureReady === "function") await models.ensureReady();
86
92
  const attributes = normalizeAttributes(keys);
87
93
  const rows = await Thread.findAll({ attributes });
88
94
  return rows.map((t) => t.get());
@@ -22,6 +22,7 @@ module.exports = function (bot) {
22
22
  async create(userID, data) {
23
23
  if (!User) return stubUser(validateId(userID, ID_FIELD), data);
24
24
  try {
25
+ if (typeof models.ensureReady === "function") await models.ensureReady();
25
26
  userID = validateId(userID, ID_FIELD);
26
27
  validateData(data);
27
28
  const payload = normalizePayload(data, "data");
@@ -37,6 +38,7 @@ module.exports = function (bot) {
37
38
  async get(userID) {
38
39
  if (!User) return null;
39
40
  try {
41
+ if (typeof models.ensureReady === "function") await models.ensureReady();
40
42
  userID = validateId(userID, ID_FIELD);
41
43
  const user = await User.findOne({ where: { userID } });
42
44
  return user ? user.get() : null;
@@ -48,6 +50,7 @@ module.exports = function (bot) {
48
50
  async update(userID, data) {
49
51
  if (!User) return { user: { userID: validateId(userID, ID_FIELD), ...normalizePayload(data || {}, "data") }, created: false };
50
52
  try {
53
+ if (typeof models.ensureReady === "function") await models.ensureReady();
51
54
  userID = validateId(userID, ID_FIELD);
52
55
  validateData(data);
53
56
  const payload = normalizePayload(data, "data");
@@ -66,6 +69,7 @@ module.exports = function (bot) {
66
69
  async del(userID) {
67
70
  if (!User) throw new Error(DB_NOT_INIT);
68
71
  try {
72
+ if (typeof models.ensureReady === "function") await models.ensureReady();
69
73
  userID = validateId(userID, ID_FIELD);
70
74
  const result = await User.destroy({ where: { userID } });
71
75
  if (result === 0) throw new Error("No user found with the specified userID");
@@ -78,6 +82,7 @@ module.exports = function (bot) {
78
82
  async delAll() {
79
83
  if (!User) return 0;
80
84
  try {
85
+ if (typeof models.ensureReady === "function") await models.ensureReady();
81
86
  return await User.destroy({ where: {} });
82
87
  } catch (err) {
83
88
  throw wrapError("Failed to delete all users", err);
@@ -87,6 +92,7 @@ module.exports = function (bot) {
87
92
  async getAll(keys = null) {
88
93
  if (!User) return [];
89
94
  try {
95
+ if (typeof models.ensureReady === "function") await models.ensureReady();
90
96
  const attributes = normalizeAttributes(keys);
91
97
  const rows = await User.findAll({ attributes });
92
98
  return rows.map((u) => u.get());
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+
3
+ // Cookie / appstate parsing shared by login and session restore.
4
+ // Chrome exports expirationDate as UNIX seconds. Values >= 1e12 are milliseconds.
5
+ // Never log cookie values from this module.
6
+
7
+ const SESSION_SENTINELS = new Set(["infinity", "session", ""]);
8
+
9
+ function parseCookieHeader(input) {
10
+ let str = String(input || "").trim();
11
+ if (!str) return [];
12
+ if (/^cookie\s*:/i.test(str)) str = str.replace(/^cookie\s*:/i, "").trim();
13
+ str = str.replace(/\r?\n/g, " ");
14
+ const out = [];
15
+ for (const part of str.split(";")) {
16
+ const token = part.trim();
17
+ if (!token) continue;
18
+ const eq = token.indexOf("=");
19
+ if (eq <= 0) continue;
20
+ const key = token.slice(0, eq).trim();
21
+ let value = token.slice(eq + 1).trim();
22
+ if (
23
+ (value.startsWith('"') && value.endsWith('"') && value.length >= 2) ||
24
+ (value.startsWith("'") && value.endsWith("'") && value.length >= 2)
25
+ ) {
26
+ value = value.slice(1, -1);
27
+ }
28
+ if (!key) continue;
29
+ out.push({
30
+ key,
31
+ value,
32
+ domain: ".facebook.com",
33
+ path: "/",
34
+ hostOnly: false,
35
+ secure: true,
36
+ httpOnly: false
37
+ });
38
+ }
39
+ return out;
40
+ }
41
+
42
+ function coerceExpires(raw) {
43
+ if (raw == null) return null;
44
+ if (typeof raw === "string" && SESSION_SENTINELS.has(raw.trim().toLowerCase())) return null;
45
+ if (raw === Infinity) return null;
46
+ if (raw instanceof Date) return Number.isNaN(raw.getTime()) ? null : raw;
47
+ if (typeof raw === "number") {
48
+ if (!Number.isFinite(raw) || raw <= 0) return null;
49
+ const ms = raw < 1e12 ? raw * 1000 : raw;
50
+ const date = new Date(ms);
51
+ return Number.isNaN(date.getTime()) ? null : date;
52
+ }
53
+ if (typeof raw === "string") {
54
+ const trimmed = raw.trim();
55
+ if (!trimmed) return null;
56
+ if (/^-?\d+(\.\d+)?$/.test(trimmed)) return coerceExpires(Number(trimmed));
57
+ const date = new Date(trimmed);
58
+ return Number.isNaN(date.getTime()) ? null : date;
59
+ }
60
+ return null;
61
+ }
62
+
63
+ function expiryFromRecord(record) {
64
+ if (!record || typeof record !== "object") return null;
65
+ if (record.expirationDate !== undefined && record.expirationDate !== null && record.expirationDate !== "") {
66
+ return coerceExpires(record.expirationDate);
67
+ }
68
+ if (record.expires !== undefined) return coerceExpires(record.expires);
69
+ return null;
70
+ }
71
+
72
+ function cloneCookieRecord(record) {
73
+ if (!record || typeof record !== "object") return null;
74
+ const key = record.key || record.name;
75
+ if (!key || record.value === undefined || record.value === null) return null;
76
+ const value = String(record.value).replace(/[\r\n]/g, "");
77
+ if (!value) return null;
78
+ return {
79
+ key: String(key),
80
+ value,
81
+ domain: record.domain || ".facebook.com",
82
+ path: record.path || "/",
83
+ hostOnly: !!record.hostOnly,
84
+ secure: record.secure !== false,
85
+ httpOnly: !!record.httpOnly,
86
+ sameSite: record.sameSite || null,
87
+ expirationDate: record.expirationDate,
88
+ expires: record.expires
89
+ };
90
+ }
91
+
92
+ function parseAppStateInput(appState) {
93
+ if (appState == null || appState === "") return [];
94
+ if (Array.isArray(appState)) {
95
+ return appState.map(cloneCookieRecord).filter(Boolean);
96
+ }
97
+ if (typeof appState === "string") {
98
+ const trimmed = appState.trim();
99
+ if (!trimmed) return [];
100
+ if (trimmed.startsWith("[") || trimmed.startsWith("{")) {
101
+ try {
102
+ const parsed = JSON.parse(trimmed);
103
+ if (Array.isArray(parsed)) return parsed.map(cloneCookieRecord).filter(Boolean);
104
+ if (parsed && typeof parsed === "object") {
105
+ return Object.entries(parsed).map(([key, value]) => cloneCookieRecord({ key, value })).filter(Boolean);
106
+ }
107
+ } catch (_) {
108
+ // Fall through to a raw Cookie header.
109
+ }
110
+ }
111
+ return parseCookieHeader(trimmed);
112
+ }
113
+ const error = new Error("Invalid appState format. Expected a cookie array, a JSON array, or a Cookie header string.");
114
+ error.code = "INVALID_APPSTATE";
115
+ error.category = "invalid_request";
116
+ error.recovery = "Pass the appstate array exported from the browser, or a single Cookie header string. Do not include passwords.";
117
+ throw error;
118
+ }
119
+
120
+ function buildSetCookie(record, domainOverride) {
121
+ const cloned = cloneCookieRecord(record);
122
+ if (!cloned) return null;
123
+ const domain = domainOverride || cloned.domain || ".facebook.com";
124
+ let value = cloned.value;
125
+ if (/[;\r\n]/.test(value)) value = encodeURIComponent(value);
126
+ const parts = [`${cloned.key}=${value}`, `Domain=${domain}`, `Path=${cloned.path || "/"}`];
127
+ const expiry = expiryFromRecord(cloned);
128
+ if (expiry) parts.push(`Expires=${expiry.toUTCString()}`);
129
+ if (cloned.secure) parts.push("Secure");
130
+ if (cloned.httpOnly) parts.push("HttpOnly");
131
+ if (cloned.sameSite) {
132
+ const sameSite = String(cloned.sameSite).toLowerCase();
133
+ if (sameSite === "strict" || sameSite === "lax" || sameSite === "none") {
134
+ parts.push(`SameSite=${sameSite.charAt(0).toUpperCase()}${sameSite.slice(1)}`);
135
+ }
136
+ }
137
+ return {
138
+ cookie: parts.join("; "),
139
+ key: cloned.key,
140
+ expired: !!(expiry && expiry.getTime() <= Date.now())
141
+ };
142
+ }
143
+
144
+ module.exports = {
145
+ parseCookieHeader,
146
+ coerceExpires,
147
+ expiryFromRecord,
148
+ cloneCookieRecord,
149
+ parseAppStateInput,
150
+ buildSetCookie
151
+ };
@@ -0,0 +1,188 @@
1
+ "use strict";
2
+
3
+ const {
4
+ SESSION_ENFORCEMENT_REQUIRED,
5
+ isSessionEnforcement,
6
+ isTransientTransportError
7
+ } = require("./sessionStatus");
8
+
9
+ const CATEGORIES = Object.freeze({
10
+ CHECKPOINT: "checkpoint",
11
+ ACCOUNT_RESTRICTION: "account_restriction",
12
+ AUTHENTICATION: "authentication_failure",
13
+ SESSION_EXPIRED: "session_expired",
14
+ TWO_FACTOR: "two_factor_required",
15
+ RATE_LIMIT: "rate_limit",
16
+ SECURITY_CHALLENGE: "security_challenge",
17
+ PERMISSION: "permission",
18
+ INVALID_REQUEST: "invalid_request",
19
+ NETWORK: "network",
20
+ UNSUPPORTED: "unsupported_endpoint",
21
+ PLATFORM: "platform_outage",
22
+ UNKNOWN: "unknown"
23
+ });
24
+
25
+ class FcaError extends Error {
26
+ constructor(fields) {
27
+ super(fields.message);
28
+ this.name = "FcaError";
29
+ this.code = fields.code;
30
+ this.category = fields.category;
31
+ this.recovery = fields.recovery;
32
+ this.diagnostic = fields.diagnostic || "";
33
+ }
34
+ }
35
+
36
+ function safeDiagnostic(value) {
37
+ if (value == null) return "";
38
+ const text = typeof value === "string" ? value : (value.code || value.error || value.message || "");
39
+ return String(text).replace(/\s+/g, " ").slice(0, 180);
40
+ }
41
+
42
+ function statusOf(value) {
43
+ if (!value || typeof value !== "object") return 0;
44
+ return Number(value.status || value.statusCode || (value.response && value.response.status) || 0) || 0;
45
+ }
46
+
47
+ function classifyError(input) {
48
+ if (!input) {
49
+ return new FcaError({
50
+ code: "UNKNOWN",
51
+ category: CATEGORIES.UNKNOWN,
52
+ message: "Unknown error.",
53
+ recovery: "Retry the action once. If it continues, capture the sanitized error code only.",
54
+ diagnostic: ""
55
+ });
56
+ }
57
+ if (input instanceof FcaError) return input;
58
+
59
+ const status = statusOf(input);
60
+ const code = input && input.code ? String(input.code) : "";
61
+ const text = safeDiagnostic(input.message || input.error || input.errorSummary || code);
62
+
63
+ if (
64
+ input.code === SESSION_ENFORCEMENT_REQUIRED ||
65
+ input.requiresManualAction === true ||
66
+ isSessionEnforcement(input)
67
+ ) {
68
+ const restriction = /restrict|suspend|disabled|locked/i.test(text);
69
+ return new FcaError({
70
+ code: SESSION_ENFORCEMENT_REQUIRED,
71
+ category: restriction ? CATEGORIES.ACCOUNT_RESTRICTION : CATEGORIES.CHECKPOINT,
72
+ message: restriction
73
+ ? "Facebook reports that this account is restricted. Automatic login has stopped."
74
+ : "Facebook requires a manual checkpoint or security review. Automatic login has stopped.",
75
+ recovery: "Open Facebook in a browser, complete the notice yourself, then export a new appstate. This package cannot remove checkpoints, two-factor prompts, or account restrictions.",
76
+ diagnostic: text
77
+ });
78
+ }
79
+
80
+ if (/two[- ]factor|2fa|approvals_code|login_approval/i.test(text) || code === "TWO_FACTOR_REQUIRED") {
81
+ return new FcaError({
82
+ code: "TWO_FACTOR_REQUIRED",
83
+ category: CATEGORIES.TWO_FACTOR,
84
+ message: "Facebook is asking for two-factor authentication.",
85
+ recovery: "Complete the code prompt in a browser or your authenticator app, then export a fresh appstate. Do not send a 2FA secret to an untrusted server.",
86
+ diagnostic: "two_factor"
87
+ });
88
+ }
89
+
90
+ if (status === 429 || code === "RATE_LIMITED" || /rate limit/i.test(text)) {
91
+ return new FcaError({
92
+ code: "RATE_LIMITED",
93
+ category: CATEGORIES.RATE_LIMIT,
94
+ message: "Facebook rate-limited this client.",
95
+ recovery: "Slow down. Wait for the cooldown and retry. Do not open extra sessions for the same account.",
96
+ diagnostic: status ? `HTTP ${status}` : "rate_limit"
97
+ });
98
+ }
99
+
100
+ if (/permission denied|missing permission|cannot (?:do|perform)/i.test(text)) {
101
+ return new FcaError({
102
+ code: "PERMISSION",
103
+ category: CATEGORIES.PERMISSION,
104
+ message: "Facebook denied permission for this action.",
105
+ recovery: "Confirm the account can perform this action in Messenger. Do not attempt to bypass the denial.",
106
+ diagnostic: text
107
+ });
108
+ }
109
+
110
+ if (status === 401 || /not logged in|session expired|invalid session/i.test(text) || code === "SESSION_EXPIRED") {
111
+ return new FcaError({
112
+ code: "SESSION_EXPIRED",
113
+ category: CATEGORIES.SESSION_EXPIRED,
114
+ message: "The saved session is no longer logged in.",
115
+ recovery: "Export a new appstate from a browser where this account is logged in, replace the old file, and restart. Do not keep retrying a dead session.",
116
+ diagnostic: status ? `HTTP ${status}` : text
117
+ });
118
+ }
119
+
120
+ if (isTransientTransportError(input) || status >= 502) {
121
+ const platform = status >= 502;
122
+ return new FcaError({
123
+ code: platform ? "PLATFORM_UNAVAILABLE" : "NETWORK",
124
+ category: platform ? CATEGORIES.PLATFORM : CATEGORIES.NETWORK,
125
+ message: platform
126
+ ? "Facebook did not return a usable response."
127
+ : "The network request failed before a session decision was made.",
128
+ recovery: platform
129
+ ? "This is not an account restriction. Wait and retry with the same appstate."
130
+ : "Check connectivity and retry. A network failure is not a logout.",
131
+ diagnostic: code || text || (status ? `HTTP ${status}` : "network")
132
+ });
133
+ }
134
+
135
+ if (status === 404 || code === "UNSUPPORTED_ENDPOINT") {
136
+ return new FcaError({
137
+ code: "UNSUPPORTED_ENDPOINT",
138
+ category: CATEGORIES.UNSUPPORTED,
139
+ message: "This endpoint did not accept the request.",
140
+ recovery: "Treat the feature as unavailable. Do not invent a replacement endpoint.",
141
+ diagnostic: status ? `HTTP ${status}` : text
142
+ });
143
+ }
144
+
145
+ if (status === 400 || code === "INVALID_APPSTATE" || code === "INVALID_REQUEST") {
146
+ return new FcaError({
147
+ code: code || "INVALID_REQUEST",
148
+ category: CATEGORIES.INVALID_REQUEST,
149
+ message: text || "The request was rejected as invalid.",
150
+ recovery: "Check the arguments. For login, pass a complete appstate with c_user and xs.",
151
+ diagnostic: text
152
+ });
153
+ }
154
+
155
+ if (status === 403) {
156
+ return new FcaError({
157
+ code: "PERMISSION",
158
+ category: CATEGORIES.PERMISSION,
159
+ message: "Facebook denied this request.",
160
+ recovery: "If the browser shows a checkpoint, resolve it there and export a new appstate. Otherwise the account may not be allowed to perform this action.",
161
+ diagnostic: text || "HTTP 403"
162
+ });
163
+ }
164
+
165
+ return new FcaError({
166
+ code: code || "UNKNOWN",
167
+ category: CATEGORIES.UNKNOWN,
168
+ message: text || "Request failed.",
169
+ recovery: "Inspect the error code. If Facebook is asking for a manual review, stop automation and resolve it in the browser.",
170
+ diagnostic: text
171
+ });
172
+ }
173
+
174
+ function annotateError(error) {
175
+ if (!error || typeof error !== "object") return error;
176
+ const classified = classifyError(error);
177
+ if (!error.code) error.code = classified.code;
178
+ if (!error.category) error.category = classified.category;
179
+ if (!error.recovery) error.recovery = classified.recovery;
180
+ return error;
181
+ }
182
+
183
+ module.exports = {
184
+ CATEGORIES,
185
+ FcaError,
186
+ classifyError,
187
+ annotateError
188
+ };
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ const { CookieJar } = require("tough-cookie");
4
+
5
+ // Copy cookies for a one-off request. The legacy Messenger endpoint can
6
+ // answer a failed send with Set-Cookie that clears the real session.
7
+ function snapshotJar(jar) {
8
+ if (!jar || typeof jar.serializeSync !== "function" || typeof CookieJar.deserializeSync !== "function") {
9
+ return jar;
10
+ }
11
+ try {
12
+ return CookieJar.deserializeSync(jar.serializeSync());
13
+ } catch (_) {
14
+ return jar;
15
+ }
16
+ }
17
+
18
+ module.exports = {
19
+ snapshotJar
20
+ };
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ const SENSITIVE_KEY = /cookie|c_user|xs\b|datr|fr\b|sb\b|access[_-]?token|password|twofactor|twoFactor|authorization|sessionid|secret/i;
4
+
5
+ function redactAssignment(text) {
6
+ return String(text)
7
+ .replace(
8
+ /(cookie|xs|c_user|datr|sb|fr|access_token|access-token|password|twofactor|twoFactor|authorization)\s*[:=]\s*("?)[^\s"',;]{0,12}[^\s"',;]*/gi,
9
+ (_match, key, quote) => `${key}=${quote || ""}[redacted]`
10
+ )
11
+ .replace(/(Bearer\s+)[A-Za-z0-9._~+/-]{8,}/gi, "$1[redacted]");
12
+ }
13
+
14
+ function sanitizeForLog(value) {
15
+ let text;
16
+ if (value instanceof Error) {
17
+ text = value.stack || value.message || String(value);
18
+ } else if (value && typeof value === "object") {
19
+ const parts = [];
20
+ if (value.code) parts.push(`code=${value.code}`);
21
+ if (value.category) parts.push(`category=${value.category}`);
22
+ if (value.status) parts.push(`status=${value.status}`);
23
+ if (value.message && !SENSITIVE_KEY.test(String(value.message))) parts.push(value.message);
24
+ else if (value.message) parts.push(redactAssignment(value.message));
25
+ text = parts.join(" ") || "[object]";
26
+ } else {
27
+ text = String(value == null ? "" : value);
28
+ }
29
+ text = redactAssignment(text).replace(/\s+/g, " ").trim();
30
+ if (text.length > 1200) text = text.slice(0, 1200) + "...";
31
+ return text;
32
+ }
33
+
34
+ module.exports = {
35
+ sanitizeForLog
36
+ };
@@ -63,9 +63,10 @@ function post(url, reqJar, form, options, ctx, customHeader) {
63
63
  }
64
64
  return requestWithRetry(
65
65
  () => client.post(url, data, cfg({ reqJar, headers, proxyUrl: options?.proxy })),
66
- 3,
66
+ 2,
67
67
  1000,
68
- ctx
68
+ ctx,
69
+ { method: "POST", idempotent: false }
69
70
  );
70
71
  }
71
72
 
@@ -149,9 +150,10 @@ async function postFormData(url, reqJar, form, qs, options, ctx) {
149
150
  const headers = { ...getHeaders(url, options, ctx), ...fd.getHeaders() };
150
151
  return requestWithRetry(
151
152
  () => client.post(url, fd, cfg({ reqJar, headers, params: qs, proxyUrl: options?.proxy })),
152
- 3,
153
+ 2,
153
154
  1000,
154
- ctx
155
+ ctx,
156
+ { method: "POST", idempotent: false }
155
157
  );
156
158
  }
157
159