adspower-browser 2.1.7-beta.2 → 2.1.7-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.MD +31 -3
- package/cli/authWorker.js +1 -1
- package/cli/credentialWorker.js +203 -32
- package/cli/index.js +1 -1
- package/package.json +2 -1
package/README.MD
CHANGED
|
@@ -251,25 +251,52 @@ The logged-in desktop client returns apiKey, apiPort (Local API), rpaPort (RPA P
|
|
|
251
251
|
Both actual services must be ready. The callback worker survives foreground process termination,
|
|
252
252
|
waits five minutes, uses a random callback port and serializes login workers on port 59753.
|
|
253
253
|
|
|
254
|
-
API Keys are stored in macOS login Keychain
|
|
254
|
+
API Keys are stored in macOS login Keychain, Windows Credential Manager, or Linux Secret Service, scoped to the
|
|
255
255
|
current OS user under `com.adspower.cli.client.v1`. The account identifier is SHA-256(userId).
|
|
256
256
|
`~/.adspowerCli/<md5(userId)>` contains only version-2 connection metadata (userId, ports,
|
|
257
257
|
credentialAccount), never the API Key. `client-user.json` selects the current user.
|
|
258
258
|
|
|
259
259
|
The native helper uses Koffi prebuilt binaries (macOS arm64/x64; Windows arm64/x64/ia32).
|
|
260
260
|
No compiler, PowerShell, shell command or key in process arguments is required. Keep the
|
|
261
|
-
`koffi` runtime
|
|
261
|
+
`koffi` and `dbus-next` runtime dependencies and `cli/credentialWorker.js` when packaging. The workspace
|
|
262
262
|
explicitly disables its install script because supported targets already ship prebuilds.
|
|
263
263
|
Native-library load failure is an error, not an invitation to use plaintext storage.
|
|
264
264
|
|
|
265
265
|
All credential operations are noninteractive and limited to five seconds per helper call.
|
|
266
266
|
macOS explicitly disables Keychain UI and restores the previous policy after each operation.
|
|
267
267
|
Windows uses generic CredReadW/CredWriteW/CredDeleteW credentials, without CredUI calls.
|
|
268
|
+
Linux talks directly to an already-running `org.freedesktop.secrets` provider (for example,
|
|
269
|
+
GNOME Keyring) on the user's D-Bus session bus. It never calls Unlock, Prompt or CreateCollection,
|
|
270
|
+
and never auto-starts the provider. A returned prompt is dismissed and reported as an error.
|
|
271
|
+
Secrets use the protocol's encrypted DH/HKDF/AES session; unsupported encryption fails without
|
|
272
|
+
retrying a plain session. No API Key is placed in process arguments or plaintext files.
|
|
268
273
|
Run WorkBuddy and the CLI under the same OS account, with access to that account's credential
|
|
269
274
|
store. A locked Keychain, changed host trust, missing credential or unavailable store produces
|
|
270
275
|
an explicit error. This cannot guarantee successful access under every OS security policy;
|
|
271
276
|
it guarantees no interactive fallback. Windows generic credentials are limited to 2560 bytes.
|
|
272
277
|
|
|
278
|
+
### Linux prerequisites
|
|
279
|
+
|
|
280
|
+
- Start the CLI and WorkBuddy as the same logged-in OS user, with that user's existing
|
|
281
|
+
`DBUS_SESSION_BUS_ADDRESS` (typically `unix:path=/run/user/<uid>/bus`). This implementation
|
|
282
|
+
supports filesystem Unix sockets only; abstract sockets and remote/TCP buses are rejected.
|
|
283
|
+
- A Secret Service provider must already be running with an unlocked, persistent default
|
|
284
|
+
collection. Create/unlock that collection through the desktop's credential manager before
|
|
285
|
+
running noninteractive CLI commands. Do not use an unencrypted or temporary session keyring.
|
|
286
|
+
- The Node D-Bus transport requires no `secret-tool`, Python, or native compiler. Its optional
|
|
287
|
+
`usocket` build is disabled in this workspace; filesystem sockets use Node's built-in transport.
|
|
288
|
+
- SSH, services and containers do not automatically inherit a desktop credential store.
|
|
289
|
+
Without an explicitly configured user bus and unlocked provider, login/status/API commands
|
|
290
|
+
fail. Do not run the CLI under `sudo` or substitute a different user's bus.
|
|
291
|
+
|
|
292
|
+
Linux errors include `LINUX_SESSION_BUS_UNAVAILABLE` (missing/unsupported bus),
|
|
293
|
+
`LINUX_SECRET_SERVICE_UNAVAILABLE` (service/transport/encrypted session failure), `LINUX_LOCKED`,
|
|
294
|
+
`LINUX_PERSISTENT_COLLECTION_REQUIRED`, `LINUX_NOT_FOUND`, `LINUX_AMBIGUOUS_CREDENTIAL`, and
|
|
295
|
+
`LINUX_INTERACTION_REQUIRED`. Timeout uses `HELPER_FAILED_OR_TIMED_OUT`. None falls back to
|
|
296
|
+
plaintext storage. Resolve the OS credential-store condition and retry; a missing saved key
|
|
297
|
+
requires `ads login` again. System-user credential storage does not isolate a key from every
|
|
298
|
+
malicious process already running under that user.
|
|
299
|
+
|
|
273
300
|
`logstatus` reads the system credential and metadata, exits nonzero with an error if credential
|
|
274
301
|
access fails, and does not probe client liveness or validate the key remotely. Business commands
|
|
275
302
|
also fail before calling APIs if the credential cannot be read. `logout` first deletes the current
|
|
@@ -287,7 +314,8 @@ fake account and cleans up its OS credential. Run it under the same Node executa
|
|
|
287
314
|
used by WorkBuddy on each supported OS. Tests cannot override OS policies or unlock a store.
|
|
288
315
|
|
|
289
316
|
Native API references: [Apple Keychain UI control](https://developer.apple.com/documentation/security/seckeychainsetuserinteractionallowed(_:)),
|
|
290
|
-
[Windows CredReadW](https://learn.microsoft.com/en-us/windows/win32/api/wincred/nf-wincred-credreadw)
|
|
317
|
+
[Windows CredReadW](https://learn.microsoft.com/en-us/windows/win32/api/wincred/nf-wincred-credreadw),
|
|
318
|
+
[Linux Secret Service](https://specifications.freedesktop.org/secret-service/latest/).
|
|
291
319
|
|
|
292
320
|
Deploy the matching frontend to both the authorization site and the desktop renderer site.
|
|
293
321
|
The native client must forward the complete protocol URL through renderer-scheme.
|
package/cli/authWorker.js
CHANGED
|
@@ -51,7 +51,7 @@ var CredentialStoreError = class extends Error {
|
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
53
|
function invoke(operation, account, secret) {
|
|
54
|
-
if (!["darwin", "win32"].includes(process.platform)) throw new CredentialStoreError("UNSUPPORTED_PLATFORM");
|
|
54
|
+
if (!["darwin", "win32", "linux"].includes(process.platform)) throw new CredentialStoreError("UNSUPPORTED_PLATFORM");
|
|
55
55
|
if (!/^[a-f0-9]{64}$/.test(account)) throw new CredentialStoreError("INVALID_ACCOUNT");
|
|
56
56
|
let output;
|
|
57
57
|
try {
|
package/cli/credentialWorker.js
CHANGED
|
@@ -5,6 +5,13 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
8
15
|
var __copyProps = (to, from, except, desc) => {
|
|
9
16
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
17
|
for (let key of __getOwnPropNames(from))
|
|
@@ -22,17 +29,162 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
29
|
mod
|
|
23
30
|
));
|
|
24
31
|
|
|
25
|
-
// src/
|
|
26
|
-
var
|
|
32
|
+
// src/linuxCredentials.ts
|
|
33
|
+
var linuxCredentials_exports = {};
|
|
34
|
+
__export(linuxCredentials_exports, {
|
|
35
|
+
linuxCredentials: () => linuxCredentials
|
|
36
|
+
});
|
|
37
|
+
async function linuxCredentials(request) {
|
|
38
|
+
const address = process.env.DBUS_SESSION_BUS_ADDRESS;
|
|
39
|
+
if (!address || !/^unix:(?:path|socket)=[^;,]+(?:,guid=[a-f0-9]+)?$/.test(address)) {
|
|
40
|
+
return fail("SESSION_BUS_UNAVAILABLE");
|
|
41
|
+
}
|
|
42
|
+
let bus;
|
|
43
|
+
let session;
|
|
44
|
+
let key;
|
|
45
|
+
let destination = SERVICE;
|
|
46
|
+
let rejectConnection = () => {
|
|
47
|
+
};
|
|
48
|
+
const connectionFailure = new Promise((_, reject) => {
|
|
49
|
+
rejectConnection = reject;
|
|
50
|
+
});
|
|
51
|
+
void connectionFailure.catch(() => {
|
|
52
|
+
});
|
|
53
|
+
const call = async (path, iface, member, signature = "", body = [], target = destination) => {
|
|
54
|
+
const reply = await Promise.race([bus.call(new import_dbus_next.Message({
|
|
55
|
+
destination: target,
|
|
56
|
+
path,
|
|
57
|
+
interface: iface,
|
|
58
|
+
member,
|
|
59
|
+
signature,
|
|
60
|
+
body,
|
|
61
|
+
flags: 2
|
|
62
|
+
// D-Bus NO_AUTO_START: never start a service or its setup UI.
|
|
63
|
+
})), connectionFailure]);
|
|
64
|
+
if (!reply) return fail("INVALID_RESPONSE");
|
|
65
|
+
return reply.body;
|
|
66
|
+
};
|
|
67
|
+
const checkPrompt = async (prompt) => {
|
|
68
|
+
if (prompt === "/") return;
|
|
69
|
+
try {
|
|
70
|
+
await call(prompt, `${PREFIX}.Prompt`, "Dismiss");
|
|
71
|
+
} catch {
|
|
72
|
+
}
|
|
73
|
+
fail("INTERACTION_REQUIRED");
|
|
74
|
+
};
|
|
75
|
+
const assertUnlocked = async (path, iface) => {
|
|
76
|
+
const [locked] = await call(path, "org.freedesktop.DBus.Properties", "Get", "ss", [iface, "Locked"]);
|
|
77
|
+
if (locked?.signature !== "b" || locked.value !== false) fail("LOCKED");
|
|
78
|
+
};
|
|
79
|
+
const openSession = async () => {
|
|
80
|
+
const dh = (0, import_node_crypto.getDiffieHellman)("modp2");
|
|
81
|
+
const [peer, sessionPath] = await call(ROOT, `${PREFIX}.Service`, "OpenSession", "sv", [ALGORITHM, new import_dbus_next.Variant("ay", dh.generateKeys())]);
|
|
82
|
+
if (peer?.signature !== "ay" || !sessionPath || sessionPath === "/") fail("INVALID_SESSION");
|
|
83
|
+
session = sessionPath;
|
|
84
|
+
const shared = dh.computeSecret(Buffer.from(peer.value));
|
|
85
|
+
try {
|
|
86
|
+
key = Buffer.from((0, import_node_crypto.hkdfSync)("sha256", shared, Buffer.alloc(0), Buffer.alloc(0), 16));
|
|
87
|
+
} finally {
|
|
88
|
+
shared.fill(0);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
try {
|
|
92
|
+
bus = (0, import_dbus_next.sessionBus)({ busAddress: address, authMethods: ["EXTERNAL"] });
|
|
93
|
+
bus.on("error", () => rejectConnection(new NativeCredentialError("LINUX_SESSION_BUS_UNAVAILABLE")));
|
|
94
|
+
[destination] = await call("/org/freedesktop/DBus", "org.freedesktop.DBus", "GetNameOwner", "s", [SERVICE], "org.freedesktop.DBus");
|
|
95
|
+
const attributes = { service: NAMESPACE, account: request.account };
|
|
96
|
+
const [items, locked] = await call(ROOT, `${PREFIX}.Service`, "SearchItems", "a{ss}", [attributes]);
|
|
97
|
+
if (locked.length) fail("LOCKED");
|
|
98
|
+
if (items.length > 1) fail("AMBIGUOUS_CREDENTIAL");
|
|
99
|
+
const item = items[0];
|
|
100
|
+
if (item?.startsWith(`${ROOT}/collection/session/`)) fail("PERSISTENT_COLLECTION_REQUIRED");
|
|
101
|
+
if (item) await assertUnlocked(item, `${PREFIX}.Item`);
|
|
102
|
+
if (request.operation === "delete") {
|
|
103
|
+
if (item) {
|
|
104
|
+
const [prompt] = await call(item, `${PREFIX}.Item`, "Delete");
|
|
105
|
+
await checkPrompt(prompt);
|
|
106
|
+
}
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (request.operation === "read" && !item) fail("NOT_FOUND");
|
|
110
|
+
let collection;
|
|
111
|
+
if (request.operation === "write" && !item) {
|
|
112
|
+
[collection] = await call(ROOT, `${PREFIX}.Service`, "ReadAlias", "s", ["default"]);
|
|
113
|
+
if (!collection || collection === "/" || collection === `${ROOT}/collection/session`) fail("PERSISTENT_COLLECTION_REQUIRED");
|
|
114
|
+
await assertUnlocked(collection, `${PREFIX}.Collection`);
|
|
115
|
+
}
|
|
116
|
+
await openSession();
|
|
117
|
+
if (request.operation === "read") {
|
|
118
|
+
const [value] = await call(item, `${PREFIX}.Item`, "GetSecret", "o", [session]);
|
|
119
|
+
if (!Array.isArray(value) || value.length !== 4 || value[0] !== session) fail("INVALID_SECRET");
|
|
120
|
+
const iv = Buffer.from(value[1]);
|
|
121
|
+
const ciphertext = Buffer.from(value[2]);
|
|
122
|
+
if (iv.length !== 16 || !ciphertext.length || ciphertext.length > 16400 || ciphertext.length % 16) fail("INVALID_SECRET");
|
|
123
|
+
const decipher = (0, import_node_crypto.createDecipheriv)("aes-128-cbc", key, iv);
|
|
124
|
+
const chunks = [decipher.update(ciphertext)];
|
|
125
|
+
let bytes2;
|
|
126
|
+
try {
|
|
127
|
+
chunks.push(decipher.final());
|
|
128
|
+
bytes2 = Buffer.concat(chunks);
|
|
129
|
+
return bytes2.toString("utf8");
|
|
130
|
+
} finally {
|
|
131
|
+
chunks.forEach((chunk) => chunk.fill(0));
|
|
132
|
+
bytes2?.fill(0);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const bytes = Buffer.from(request.secret, "utf8");
|
|
136
|
+
try {
|
|
137
|
+
const iv = (0, import_node_crypto.randomBytes)(16);
|
|
138
|
+
const cipher = (0, import_node_crypto.createCipheriv)("aes-128-cbc", key, iv);
|
|
139
|
+
const value = [session, iv, Buffer.concat([cipher.update(bytes), cipher.final()]), "text/plain; charset=utf-8"];
|
|
140
|
+
if (item) {
|
|
141
|
+
await call(item, `${PREFIX}.Item`, "SetSecret", "(oayays)", [value]);
|
|
142
|
+
} else {
|
|
143
|
+
const [created, prompt] = await call(collection, `${PREFIX}.Collection`, "CreateItem", "a{sv}(oayays)b", [{
|
|
144
|
+
[`${PREFIX}.Item.Label`]: new import_dbus_next.Variant("s", "AdsPower CLI client connection"),
|
|
145
|
+
[`${PREFIX}.Item.Attributes`]: new import_dbus_next.Variant("a{ss}", attributes)
|
|
146
|
+
}, value, true]);
|
|
147
|
+
await checkPrompt(prompt);
|
|
148
|
+
if (!created || created === "/") fail("WRITE_FAILED");
|
|
149
|
+
}
|
|
150
|
+
} finally {
|
|
151
|
+
bytes.fill(0);
|
|
152
|
+
}
|
|
153
|
+
} catch (error) {
|
|
154
|
+
if (error instanceof NativeCredentialError) throw error;
|
|
155
|
+
fail("SECRET_SERVICE_UNAVAILABLE");
|
|
156
|
+
} finally {
|
|
157
|
+
key?.fill(0);
|
|
158
|
+
if (bus) {
|
|
159
|
+
if (session) {
|
|
160
|
+
try {
|
|
161
|
+
await call(session, `${PREFIX}.Session`, "Close");
|
|
162
|
+
} catch {
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
bus.disconnect();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
var import_node_crypto, import_dbus_next, SERVICE, ROOT, PREFIX, NAMESPACE, ALGORITHM, fail;
|
|
170
|
+
var init_linuxCredentials = __esm({
|
|
171
|
+
"src/linuxCredentials.ts"() {
|
|
172
|
+
"use strict";
|
|
173
|
+
import_node_crypto = require("crypto");
|
|
174
|
+
import_dbus_next = require("dbus-next");
|
|
175
|
+
init_nativeCredentials();
|
|
176
|
+
SERVICE = "org.freedesktop.secrets";
|
|
177
|
+
ROOT = "/org/freedesktop/secrets";
|
|
178
|
+
PREFIX = "org.freedesktop.Secret";
|
|
179
|
+
NAMESPACE = "com.adspower.cli.client.v1";
|
|
180
|
+
ALGORITHM = "dh-ietf1024-sha256-aes128-cbc-pkcs7";
|
|
181
|
+
fail = (code) => {
|
|
182
|
+
throw new NativeCredentialError(`LINUX_${code}`);
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
});
|
|
27
186
|
|
|
28
187
|
// src/nativeCredentials.ts
|
|
29
|
-
var import_koffi = __toESM(require("koffi"));
|
|
30
|
-
var SERVICE = "com.adspower.cli.client.v1";
|
|
31
|
-
var NativeCredentialError = class extends Error {
|
|
32
|
-
};
|
|
33
|
-
var fail = (platform, code) => {
|
|
34
|
-
throw new NativeCredentialError(`${platform}_${code}`);
|
|
35
|
-
};
|
|
36
188
|
function macCredentials(request) {
|
|
37
189
|
const security = import_koffi.default.load("/System/Library/Frameworks/Security.framework/Security");
|
|
38
190
|
const core = import_koffi.default.load("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation");
|
|
@@ -46,15 +198,15 @@ function macCredentials(request) {
|
|
|
46
198
|
const release = core.func("void CFRelease(void *value)");
|
|
47
199
|
const previous = [0];
|
|
48
200
|
let status = getInteraction(previous);
|
|
49
|
-
if (status)
|
|
201
|
+
if (status) fail2("MACOS", status);
|
|
50
202
|
status = setInteraction(0);
|
|
51
|
-
if (status)
|
|
203
|
+
if (status) fail2("MACOS", status);
|
|
52
204
|
const data = [null], item = [null], length = [0];
|
|
53
205
|
try {
|
|
54
206
|
status = find(
|
|
55
207
|
null,
|
|
56
|
-
Buffer.byteLength(
|
|
57
|
-
|
|
208
|
+
Buffer.byteLength(SERVICE2),
|
|
209
|
+
SERVICE2,
|
|
58
210
|
request.account.length,
|
|
59
211
|
request.account,
|
|
60
212
|
request.operation === "read" ? length : null,
|
|
@@ -62,19 +214,19 @@ function macCredentials(request) {
|
|
|
62
214
|
item
|
|
63
215
|
);
|
|
64
216
|
const missing = status === -25300;
|
|
65
|
-
if (status && !missing)
|
|
217
|
+
if (status && !missing) fail2("MACOS", status);
|
|
66
218
|
if (request.operation === "delete") {
|
|
67
219
|
if (missing) return;
|
|
68
220
|
status = remove(item[0]);
|
|
69
221
|
} else if (request.operation === "write") {
|
|
70
222
|
const bytes = Buffer.from(request.secret, "utf8");
|
|
71
223
|
try {
|
|
72
|
-
status = missing ? add(null, Buffer.byteLength(
|
|
224
|
+
status = missing ? add(null, Buffer.byteLength(SERVICE2), SERVICE2, request.account.length, request.account, bytes.length, bytes, null) : modify(item[0], null, bytes.length, bytes);
|
|
73
225
|
} finally {
|
|
74
226
|
bytes.fill(0);
|
|
75
227
|
}
|
|
76
228
|
} else {
|
|
77
|
-
if (missing)
|
|
229
|
+
if (missing) fail2("MACOS", status);
|
|
78
230
|
if (!data[0] || length[0] < 1 || length[0] > 16384) throw new NativeCredentialError("INVALID_SECRET");
|
|
79
231
|
const bytes = Buffer.from(import_koffi.default.decode(data[0], "uint8_t", length[0]));
|
|
80
232
|
try {
|
|
@@ -83,12 +235,12 @@ function macCredentials(request) {
|
|
|
83
235
|
bytes.fill(0);
|
|
84
236
|
}
|
|
85
237
|
}
|
|
86
|
-
if (status)
|
|
238
|
+
if (status) fail2("MACOS", status);
|
|
87
239
|
} finally {
|
|
88
240
|
if (data[0]) free(null, data[0]);
|
|
89
241
|
if (item[0]) release(item[0]);
|
|
90
242
|
const restored = setInteraction(previous[0]);
|
|
91
|
-
if (restored)
|
|
243
|
+
if (restored) fail2("MACOS", restored);
|
|
92
244
|
}
|
|
93
245
|
}
|
|
94
246
|
function windowsCredentials(request) {
|
|
@@ -113,11 +265,11 @@ function windowsCredentials(request) {
|
|
|
113
265
|
const remove = advapi.func("int __stdcall CredDeleteW(const char16_t *target, uint32_t type, uint32_t flags)");
|
|
114
266
|
const free = advapi.func("void __stdcall CredFree(void *buffer)");
|
|
115
267
|
const lastError = kernel.func("uint32_t __stdcall GetLastError()");
|
|
116
|
-
const target = `${
|
|
268
|
+
const target = `${SERVICE2}/${request.account}`;
|
|
117
269
|
if (request.operation === "delete") {
|
|
118
270
|
if (!remove(target, 1, 0)) {
|
|
119
271
|
const code = lastError();
|
|
120
|
-
if (code !== 1168)
|
|
272
|
+
if (code !== 1168) fail2("WINDOWS", code);
|
|
121
273
|
}
|
|
122
274
|
return;
|
|
123
275
|
}
|
|
@@ -138,14 +290,14 @@ function windowsCredentials(request) {
|
|
|
138
290
|
Attributes: null,
|
|
139
291
|
TargetAlias: null,
|
|
140
292
|
UserName: request.account
|
|
141
|
-
}, 0))
|
|
293
|
+
}, 0)) fail2("WINDOWS", lastError());
|
|
142
294
|
} finally {
|
|
143
295
|
bytes.fill(0);
|
|
144
296
|
}
|
|
145
297
|
return;
|
|
146
298
|
}
|
|
147
299
|
const result = [null];
|
|
148
|
-
if (!read(target, 1, 0, result))
|
|
300
|
+
if (!read(target, 1, 0, result)) fail2("WINDOWS", lastError());
|
|
149
301
|
try {
|
|
150
302
|
const value = import_koffi.default.decode(result[0], credential);
|
|
151
303
|
if (!value.CredentialBlob || value.CredentialBlobSize < 1 || value.CredentialBlobSize > 2560) throw new NativeCredentialError("INVALID_SECRET");
|
|
@@ -160,20 +312,39 @@ function windowsCredentials(request) {
|
|
|
160
312
|
}
|
|
161
313
|
}
|
|
162
314
|
function nativeCredentials(request) {
|
|
315
|
+
if (process.platform === "linux") return Promise.resolve().then(() => (init_linuxCredentials(), linuxCredentials_exports)).then((module2) => module2.linuxCredentials(request));
|
|
163
316
|
if (process.platform === "darwin") return macCredentials(request);
|
|
164
317
|
if (process.platform === "win32") return windowsCredentials(request);
|
|
165
318
|
throw new NativeCredentialError("UNSUPPORTED_PLATFORM");
|
|
166
319
|
}
|
|
320
|
+
var import_koffi, SERVICE2, NativeCredentialError, fail2;
|
|
321
|
+
var init_nativeCredentials = __esm({
|
|
322
|
+
"src/nativeCredentials.ts"() {
|
|
323
|
+
"use strict";
|
|
324
|
+
import_koffi = __toESM(require("koffi"));
|
|
325
|
+
SERVICE2 = "com.adspower.cli.client.v1";
|
|
326
|
+
NativeCredentialError = class extends Error {
|
|
327
|
+
};
|
|
328
|
+
fail2 = (platform, code) => {
|
|
329
|
+
throw new NativeCredentialError(`${platform}_${code}`);
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
});
|
|
167
333
|
|
|
168
334
|
// src/credentialWorker.ts
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
335
|
+
var fs = __toESM(require("fs"));
|
|
336
|
+
init_nativeCredentials();
|
|
337
|
+
async function main() {
|
|
338
|
+
try {
|
|
339
|
+
const input = fs.readFileSync(0, "utf8");
|
|
340
|
+
if (Buffer.byteLength(input) > 32768) throw new Error("Invalid request");
|
|
341
|
+
const request = JSON.parse(input);
|
|
342
|
+
if (!["read", "write", "delete"].includes(request.operation) || !/^[a-f0-9]{64}$/.test(request.account) || request.operation === "write" && (typeof request.secret !== "string" || !request.secret.trim() || request.secret.length > 4096 || /[\r\n]/.test(request.secret))) throw new Error("Invalid request");
|
|
343
|
+
const secret = await nativeCredentials(request);
|
|
344
|
+
process.stdout.write(JSON.stringify({ ok: true, ...request.operation === "read" ? { secret } : {} }));
|
|
345
|
+
} catch (error) {
|
|
346
|
+
const code = error instanceof NativeCredentialError ? error.message : "NATIVE_FAILURE";
|
|
347
|
+
process.stdout.write(JSON.stringify({ ok: false, code }));
|
|
348
|
+
}
|
|
179
349
|
}
|
|
350
|
+
void main();
|
package/cli/index.js
CHANGED
|
@@ -38,7 +38,7 @@ var CredentialStoreError = class extends Error {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
function invoke(operation, account, secret) {
|
|
41
|
-
if (!["darwin", "win32"].includes(process.platform)) throw new CredentialStoreError("UNSUPPORTED_PLATFORM");
|
|
41
|
+
if (!["darwin", "win32", "linux"].includes(process.platform)) throw new CredentialStoreError("UNSUPPORTED_PLATFORM");
|
|
42
42
|
if (!/^[a-f0-9]{64}$/.test(account)) throw new CredentialStoreError("INVALID_ACCOUNT");
|
|
43
43
|
let output;
|
|
44
44
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adspower-browser",
|
|
3
|
-
"version": "2.1.7-beta.
|
|
3
|
+
"version": "2.1.7-beta.3",
|
|
4
4
|
"main": "cli/index.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"bin": {
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"axios": "^1.8.4",
|
|
18
18
|
"colors": "^1.4.0",
|
|
19
19
|
"commander": "^14.0.3",
|
|
20
|
+
"dbus-next": "0.10.2",
|
|
20
21
|
"fs-extra2": "^1.0.1",
|
|
21
22
|
"koffi": "2.15.2",
|
|
22
23
|
"playwright-core": "^1.51.1",
|