opencode-collaboration 0.7.0 → 0.8.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 +7 -4
- package/README.zh-CN.md +7 -4
- package/dist/commands.js +2 -103
- package/dist/config.js +2 -52
- package/dist/delivery.js +2 -241
- package/dist/feedback.js +2 -40
- package/dist/format.js +2 -107
- package/dist/gating.js +2 -16
- package/dist/index.js +2 -461
- package/dist/listener.js +2 -335
- package/dist/outbox.js +2 -110
- package/dist/permissions.js +2 -194
- package/dist/queue.js +2 -824
- package/dist/registry.js +2 -308
- package/dist/sanitize.js +2 -38
- package/dist/scope.js +2 -23
- package/dist/sender.js +2 -139
- package/dist/session-runtime.js +2 -434
- package/dist/session-tracker.js +2 -39
- package/dist/title-suffix.js +2 -23
- package/dist/tools/peers-tools.js +2 -182
- package/dist/transport.js +2 -46
- package/dist/types.js +2 -1
- package/package.json +8 -4
package/dist/listener.js
CHANGED
|
@@ -1,335 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
* Peers POST messages here instead of touching the opencode server directly,
|
|
4
|
-
* so inbound gating (accept/hold/refuse) and queueing stay under our control.
|
|
5
|
-
*/
|
|
6
|
-
import { chmod, lstat, mkdir, rm } from "node:fs/promises";
|
|
7
|
-
import { createServer } from "node:http";
|
|
8
|
-
import { connect } from "node:net";
|
|
9
|
-
import { tmpdir } from "node:os";
|
|
10
|
-
import { join } from "node:path";
|
|
11
|
-
import { z } from "zod";
|
|
12
|
-
const MAX_HOPS = 4;
|
|
13
|
-
const peerFromSchema = z
|
|
14
|
-
.object({
|
|
15
|
-
instanceId: z.string().min(1),
|
|
16
|
-
name: z.string().min(1),
|
|
17
|
-
directory: z.string().min(1),
|
|
18
|
-
})
|
|
19
|
-
.passthrough();
|
|
20
|
-
const inboundMessageV1Schema = z
|
|
21
|
-
.object({
|
|
22
|
-
id: z.string().min(1),
|
|
23
|
-
from: peerFromSchema,
|
|
24
|
-
text: z.string(),
|
|
25
|
-
via: z.array(z.string()).max(MAX_HOPS),
|
|
26
|
-
sentAt: z.number().finite(),
|
|
27
|
-
})
|
|
28
|
-
.passthrough();
|
|
29
|
-
const inboundMessageV2Schema = z
|
|
30
|
-
.object({
|
|
31
|
-
version: z.literal(2),
|
|
32
|
-
messageId: z.string().min(1),
|
|
33
|
-
fromEndpointId: z.string().min(1),
|
|
34
|
-
toEndpointId: z.string().min(1),
|
|
35
|
-
from: peerFromSchema,
|
|
36
|
-
text: z.string(),
|
|
37
|
-
via: z.array(z.string()).max(MAX_HOPS),
|
|
38
|
-
sentAt: z.number().finite(),
|
|
39
|
-
})
|
|
40
|
-
.passthrough();
|
|
41
|
-
const acknowledgementV2Schema = z.object({
|
|
42
|
-
version: z.literal(2),
|
|
43
|
-
messageId: z.string().min(1),
|
|
44
|
-
fromEndpointId: z.string().min(1),
|
|
45
|
-
toEndpointId: z.string().min(1),
|
|
46
|
-
status: z.enum(["delivered", "refused", "expired", "dropped", "duplicate"]),
|
|
47
|
-
acknowledgedAt: z.number().finite(),
|
|
48
|
-
}).passthrough();
|
|
49
|
-
function statusToHttp(status) {
|
|
50
|
-
switch (status) {
|
|
51
|
-
case "refused":
|
|
52
|
-
return 403;
|
|
53
|
-
case "full":
|
|
54
|
-
return 429;
|
|
55
|
-
default:
|
|
56
|
-
return 202;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
function parseMessage(body) {
|
|
60
|
-
if (typeof body === "object" && body !== null && "version" in body && body.version === 2) {
|
|
61
|
-
const parsed = inboundMessageV2Schema.safeParse(body);
|
|
62
|
-
if (!parsed.success)
|
|
63
|
-
return null;
|
|
64
|
-
const message = parsed.data;
|
|
65
|
-
return {
|
|
66
|
-
message: {
|
|
67
|
-
id: message.messageId,
|
|
68
|
-
from: {
|
|
69
|
-
instanceId: message.fromEndpointId,
|
|
70
|
-
name: message.from.name,
|
|
71
|
-
directory: message.from.directory,
|
|
72
|
-
},
|
|
73
|
-
text: message.text,
|
|
74
|
-
via: message.via,
|
|
75
|
-
sentAt: message.sentAt,
|
|
76
|
-
},
|
|
77
|
-
route: { version: 2, toEndpointId: message.toEndpointId },
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
const parsed = inboundMessageV1Schema.safeParse(body);
|
|
81
|
-
return parsed.success ? { message: parsed.data, route: { version: 1 } } : null;
|
|
82
|
-
}
|
|
83
|
-
export function defaultRuntimeDirectory(env = process.env, uid = typeof process.getuid === "function" ? process.getuid() : 0) {
|
|
84
|
-
return env.XDG_RUNTIME_DIR
|
|
85
|
-
? join(env.XDG_RUNTIME_DIR, "opencode-collaboration")
|
|
86
|
-
: join(tmpdir(), `ocp-${uid}`);
|
|
87
|
-
}
|
|
88
|
-
export function InboxListener(opts) {
|
|
89
|
-
let primaryServer = null;
|
|
90
|
-
let compatibilityServer = null;
|
|
91
|
-
let ownedSocketPath = null;
|
|
92
|
-
let lifecycle = "new";
|
|
93
|
-
function authorized(authHeader) {
|
|
94
|
-
return authHeader === `Bearer ${opts.token}`;
|
|
95
|
-
}
|
|
96
|
-
async function handle(req, res) {
|
|
97
|
-
const send = (code, body) => {
|
|
98
|
-
res.writeHead(code, { "content-type": "application/json" });
|
|
99
|
-
res.end(JSON.stringify(body));
|
|
100
|
-
};
|
|
101
|
-
if (!authorized(req.headers.authorization)) {
|
|
102
|
-
send(401, { error: "unauthorized" });
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
if (req.method === "GET" && req.url === "/health") {
|
|
106
|
-
send(200, { ok: true });
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
if (req.method !== "POST" || (req.url !== "/message" && req.url !== "/ack")) {
|
|
110
|
-
send(404, { error: "not found" });
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
const chunks = [];
|
|
114
|
-
let size = 0;
|
|
115
|
-
for await (const chunk of req) {
|
|
116
|
-
size += chunk.length;
|
|
117
|
-
if (size > opts.maxBodyBytes) {
|
|
118
|
-
send(413, { error: "message too large" });
|
|
119
|
-
req.destroy();
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
chunks.push(chunk);
|
|
123
|
-
}
|
|
124
|
-
let parsed;
|
|
125
|
-
try {
|
|
126
|
-
parsed = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
127
|
-
}
|
|
128
|
-
catch {
|
|
129
|
-
send(400, { error: "invalid json" });
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
if (req.url === "/ack") {
|
|
133
|
-
const ack = acknowledgementV2Schema.safeParse(parsed);
|
|
134
|
-
if (!ack.success) {
|
|
135
|
-
send(400, { error: "invalid acknowledgement shape" });
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
await opts.onAcknowledgement?.(ack.data);
|
|
139
|
-
send(202, { status: "accepted" });
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
const envelope = parseMessage(parsed);
|
|
143
|
-
if (!envelope) {
|
|
144
|
-
send(400, { error: "invalid message shape" });
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
const msg = envelope.message;
|
|
148
|
-
if (Buffer.byteLength(msg.text, "utf8") > (opts.maxMessageBytes ?? 8192)) {
|
|
149
|
-
send(413, { error: "message too large" });
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
if (Math.abs(Date.now() - msg.sentAt) > (opts.maxMessageAgeMs ?? 300_000)) {
|
|
153
|
-
send(400, { error: "stale message" });
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
try {
|
|
157
|
-
const endpointId = await opts.resolveEndpoint?.(envelope.route);
|
|
158
|
-
if (opts.resolveEndpoint && !endpointId) {
|
|
159
|
-
send(404, { error: "endpoint not found" });
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
const status = await opts.onMessage(msg, endpointId ?? envelope.route.toEndpointId);
|
|
163
|
-
send(statusToHttp(status), { status });
|
|
164
|
-
}
|
|
165
|
-
catch (err) {
|
|
166
|
-
await opts.logger("error", "onMessage handler failed", { error: String(err) });
|
|
167
|
-
send(500, { error: "internal error" });
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
function listenerServer() {
|
|
171
|
-
return createServer((req, res) => {
|
|
172
|
-
handle(req, res).catch((err) => {
|
|
173
|
-
void opts.logger("error", "listener error", { error: String(err) });
|
|
174
|
-
if (!res.headersSent)
|
|
175
|
-
res.writeHead(500).end();
|
|
176
|
-
else
|
|
177
|
-
res.end();
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
function listenUnix(server, socketPath) {
|
|
182
|
-
return new Promise((resolve, reject) => {
|
|
183
|
-
const onError = (err) => {
|
|
184
|
-
server.off("listening", onListening);
|
|
185
|
-
reject(err);
|
|
186
|
-
};
|
|
187
|
-
const onListening = () => {
|
|
188
|
-
server.off("error", onError);
|
|
189
|
-
resolve();
|
|
190
|
-
};
|
|
191
|
-
server.once("error", onError);
|
|
192
|
-
server.once("listening", onListening);
|
|
193
|
-
server.listen(socketPath);
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
function listenTcp(server) {
|
|
197
|
-
return new Promise((resolve, reject) => {
|
|
198
|
-
const onError = (err) => {
|
|
199
|
-
server.off("listening", onListening);
|
|
200
|
-
reject(err);
|
|
201
|
-
};
|
|
202
|
-
const onListening = () => {
|
|
203
|
-
server.off("error", onError);
|
|
204
|
-
resolve(server.address().port);
|
|
205
|
-
};
|
|
206
|
-
server.once("error", onError);
|
|
207
|
-
server.once("listening", onListening);
|
|
208
|
-
server.listen(0, "127.0.0.1");
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
function closeServer(server) {
|
|
212
|
-
return new Promise((resolve, reject) => {
|
|
213
|
-
if (!server?.listening) {
|
|
214
|
-
resolve();
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
server.close((err) => err ? reject(err) : resolve());
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
function liveUnixSocket(socketPath) {
|
|
221
|
-
return new Promise((resolve, reject) => {
|
|
222
|
-
const socket = connect({ path: socketPath });
|
|
223
|
-
let settled = false;
|
|
224
|
-
const finish = (result, err) => {
|
|
225
|
-
if (settled)
|
|
226
|
-
return;
|
|
227
|
-
settled = true;
|
|
228
|
-
socket.destroy();
|
|
229
|
-
if (err)
|
|
230
|
-
reject(err);
|
|
231
|
-
else
|
|
232
|
-
resolve(result);
|
|
233
|
-
};
|
|
234
|
-
socket.once("connect", () => finish(true));
|
|
235
|
-
socket.once("error", (err) => {
|
|
236
|
-
if (err.code === "ECONNREFUSED" || err.code === "ENOENT")
|
|
237
|
-
finish(false);
|
|
238
|
-
else
|
|
239
|
-
finish(false, err);
|
|
240
|
-
});
|
|
241
|
-
socket.setTimeout(500, () => finish(true));
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
async function prepareUnixSocket(socketPath) {
|
|
245
|
-
try {
|
|
246
|
-
const info = await lstat(socketPath);
|
|
247
|
-
if (!info.isSocket())
|
|
248
|
-
throw new Error(`runtime socket path collision: ${socketPath}`);
|
|
249
|
-
if (await liveUnixSocket(socketPath))
|
|
250
|
-
throw new Error(`runtime socket already in use: ${socketPath}`);
|
|
251
|
-
await rm(socketPath);
|
|
252
|
-
}
|
|
253
|
-
catch (err) {
|
|
254
|
-
if (err.code !== "ENOENT")
|
|
255
|
-
throw err;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
return {
|
|
259
|
-
async start() {
|
|
260
|
-
if (lifecycle !== "new")
|
|
261
|
-
throw new Error(`listener cannot start while ${lifecycle}`);
|
|
262
|
-
lifecycle = "starting";
|
|
263
|
-
const platform = opts.platform ?? (opts.processId ? process.platform : "win32");
|
|
264
|
-
if (platform === "win32") {
|
|
265
|
-
primaryServer = listenerServer();
|
|
266
|
-
try {
|
|
267
|
-
const port = await listenTcp(primaryServer);
|
|
268
|
-
lifecycle = "running";
|
|
269
|
-
const url = `http://127.0.0.1:${port}`;
|
|
270
|
-
return {
|
|
271
|
-
port,
|
|
272
|
-
url,
|
|
273
|
-
compatibilityUrl: url,
|
|
274
|
-
address: { type: "tcp", host: "127.0.0.1", port },
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
catch (err) {
|
|
278
|
-
await closeServer(primaryServer).catch(() => { });
|
|
279
|
-
primaryServer = null;
|
|
280
|
-
lifecycle = "stopped";
|
|
281
|
-
throw err;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
const directory = opts.runtimeDir ?? defaultRuntimeDirectory();
|
|
285
|
-
const socketPath = join(directory, `${opts.processId ?? process.pid}.sock`);
|
|
286
|
-
let boundUnixSocket = false;
|
|
287
|
-
try {
|
|
288
|
-
await mkdir(directory, { recursive: true, mode: 0o700 });
|
|
289
|
-
await chmod(directory, 0o700);
|
|
290
|
-
await prepareUnixSocket(socketPath);
|
|
291
|
-
primaryServer = listenerServer();
|
|
292
|
-
await listenUnix(primaryServer, socketPath);
|
|
293
|
-
boundUnixSocket = true;
|
|
294
|
-
ownedSocketPath = socketPath;
|
|
295
|
-
await chmod(socketPath, 0o600);
|
|
296
|
-
compatibilityServer = listenerServer();
|
|
297
|
-
const compatibilityPort = await listenTcp(compatibilityServer);
|
|
298
|
-
lifecycle = "running";
|
|
299
|
-
return {
|
|
300
|
-
port: compatibilityPort,
|
|
301
|
-
url: `http+unix://${encodeURIComponent(socketPath)}`,
|
|
302
|
-
compatibilityUrl: `http://127.0.0.1:${compatibilityPort}`,
|
|
303
|
-
address: { type: "unix", path: socketPath },
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
catch (err) {
|
|
307
|
-
await Promise.all([
|
|
308
|
-
closeServer(compatibilityServer).catch(() => { }),
|
|
309
|
-
closeServer(primaryServer).catch(() => { }),
|
|
310
|
-
]);
|
|
311
|
-
compatibilityServer = null;
|
|
312
|
-
primaryServer = null;
|
|
313
|
-
if (boundUnixSocket)
|
|
314
|
-
await rm(socketPath, { force: true }).catch(() => { });
|
|
315
|
-
ownedSocketPath = null;
|
|
316
|
-
lifecycle = "stopped";
|
|
317
|
-
throw err;
|
|
318
|
-
}
|
|
319
|
-
},
|
|
320
|
-
async stop() {
|
|
321
|
-
if (lifecycle === "stopped")
|
|
322
|
-
return;
|
|
323
|
-
lifecycle = "stopping";
|
|
324
|
-
const unixPath = ownedSocketPath;
|
|
325
|
-
const servers = [compatibilityServer, primaryServer];
|
|
326
|
-
compatibilityServer = null;
|
|
327
|
-
primaryServer = null;
|
|
328
|
-
ownedSocketPath = null;
|
|
329
|
-
await Promise.all(servers.map((server) => closeServer(server)));
|
|
330
|
-
if (unixPath)
|
|
331
|
-
await rm(unixPath, { force: true });
|
|
332
|
-
lifecycle = "stopped";
|
|
333
|
-
},
|
|
334
|
-
};
|
|
335
|
-
}
|
|
1
|
+
function _0x55ee(){const _0x446185=['C3rHCNrPBMC','Dg9fBMrWB2LUDeLK','Bwf4','y29Uy2f0','DxjS','mJmYntCZofn3uLrqqW','ywnJzxb0zwq','Aw52ywXPzcbTzxnZywDLihnOyxbL','zgvZDhjVEq','C3rVChbPBMC','B2nWlq','ue9tva','BwvZC2fNzuLK','Dgv4Da','ChjVy2vZC0LK','ndq3mZz5qxjvyKi','zgvSAxzLCMvK','y29UBMvJDa','BM90igzVDw5K','Dw5HDxrOB3jPEMvK','BwfW','D2LUmZi','zhjVChbLza','z2v0DwLK','C2fMzvbHCNnL','ywrKCMvZCW','BwvZC2fNzsb0B28GBgfYz2u','Dg9tDhjPBMC','B2zM','DMLH','y29Kzq','Cg9YDa','Bwf4qM9KEuj5DgvZ','Aw52ywXPzcbQC29U','CgfYC2u','nwn3BNvUAa','ywXS','y2f0y2G','CNvUBMLUzW','zNjVBuvUzhbVAw50swq','mtrpwhvou1u','zw5KCg9PBNqGBM90igzVDw5K','BNvTyMvY','BMv3','CMvMDxnLza','zw5K','B25Jzq','l21LC3nHz2u','mZGXodyWnNvXuhDvwG','CNvUDgLTzurPCG','C2v0vgLTzw91Da','werhx1jvtLrjtuvFreLs','Bwv0Ag9K','zNvUy3rPB24','nZeYntfsu0PVy2m','AgvHzgvYC1nLBNq','DMvYC2LVBG','CNvUDgLTzsbZB2nRzxqGywXYzwfKEsbPBIb1C2u6ia','Bg9Nz2vY','CM91Dgu','B25nzxnZywDL','zxjYB3i','D3jPDgvizwfK','CgXHDgzVCM0','zhvWBgLJyxrL','ru5pru5u','B25by2TUB3DSzwrNzw1LBNq','Ahr0CcT1BML4oI8V','C3rYAw5NAwz5','Ahr0CdOVlZeYnY4WlJaUmtO','DxrMoa','C3rYAw5N','Dw5PEa','ogfSzhHOtG','C3vJy2vZCW','zgLYzwn0B3j5','zNvSBa','yNL0zuXLBMD0Aa','BwLU','zMLUAxrL','l2HLywX0Aa','yxjYyxK','B3bLBMnVzguTy29SBgfIB3jHDgLVBG','C3rVChbLza','zxHWAxjLza','Aw50zxjUywWGzxjYB3i','yxbWBgLJyxrPB24VANnVBG','BMfTzq','CgfZC3rOCM91z2G','BgLZDgvUAw5N','zw51Bq','CNvUDgLTzsbZB2nRzxqGCgf0AcbJB2XSAxnPB246ia','mJCXmZi5mu1PsLvdBG','mJyZn0XHzMXnEG','ywjZ','lNnVy2S','B2jQzwn0','zgf0yq','CgLK','mti3lJaUmc4X','mta2nNrKsxDXvW','qMvHCMvYia','runptK5sruzvu0ve','CMvZB2X2zuvUzhbVAw50','AxntB2nRzxq','mJrgy3LcBMO','r0vu','BgvUz3rO','C2vUDef0','BgLZDgvUzxiGzxjYB3i','AgvHzgvYCW','odeZnZjTtuXzsgO','l2fJAW','Aw52ywXPzcbHy2TUB3DSzwrNzw1LBNqGC2HHCgu','nJuYmfPoz09hAW','zNjVBq'];_0x55ee=function(){return _0x446185;};return _0x55ee();}const _0x474033=_0x1058;(function(stringArrayFunction,_0x4453db){const _0x27f9d1=_0x1058,stringArray=stringArrayFunction();while(!![]){try{const _0x844133=-parseInt(_0x27f9d1(0xb7))/0x1*(parseInt(_0x27f9d1(0xa9))/0x2)+parseInt(_0x27f9d1(0xea))/0x3*(parseInt(_0x27f9d1(0x104))/0x4)+-parseInt(_0x27f9d1(0xa4))/0x5*(parseInt(_0x27f9d1(0xfa))/0x6)+parseInt(_0x27f9d1(0xdd))/0x7*(parseInt(_0x27f9d1(0xca))/0x8)+parseInt(_0x27f9d1(0xde))/0x9*(-parseInt(_0x27f9d1(0xf3))/0xa)+parseInt(_0x27f9d1(0xb1))/0xb+parseInt(_0x27f9d1(0xf0))/0xc*(parseInt(_0x27f9d1(0xe5))/0xd);if(_0x844133===_0x4453db)break;else stringArray['push'](stringArray['shift']());}catch(_0x24307d){stringArray['push'](stringArray['shift']());}}}(_0x55ee,0x49f09));import{chmod,lstat,mkdir,rm}from'node:fs/promises';import{createServer}from'node:http';import{connect}from'node:net';import{tmpdir}from'node:os';import{join}from'node:path';import{z}from'zod';function _0x1058(_0x19c3fc,_0x8e6022){_0x19c3fc=_0x19c3fc-0x95;const _0x55ee24=_0x55ee();let _0x105865=_0x55ee24[_0x19c3fc];if(_0x1058['wsjcmA']===undefined){var _0x2fab5f=function(_0x1cb9e0){const _0x4768bd='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x708431='',_0x2183e6='';for(let _0x473de7=0x0,_0x4f89a9,_0x15e52b,_0x98069f=0x0;_0x15e52b=_0x1cb9e0['charAt'](_0x98069f++);~_0x15e52b&&(_0x4f89a9=_0x473de7%0x4?_0x4f89a9*0x40+_0x15e52b:_0x15e52b,_0x473de7++%0x4)?_0x708431+=String['fromCharCode'](0xff&_0x4f89a9>>(-0x2*_0x473de7&0x6)):0x0){_0x15e52b=_0x4768bd['indexOf'](_0x15e52b);}for(let _0x2e8a4a=0x0,_0x4f376d=_0x708431['length'];_0x2e8a4a<_0x4f376d;_0x2e8a4a++){_0x2183e6+='%'+('00'+_0x708431['charCodeAt'](_0x2e8a4a)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x2183e6);};_0x1058['CGxLlp']=_0x2fab5f,_0x1058['QUheDS']={},_0x1058['wsjcmA']=!![];}const _0x2ed3c3=_0x55ee24[0x0];_0x1058['VzbiHJ']!==_0x2ed3c3&&(_0x1058['QUheDS']={},_0x1058['VzbiHJ']=_0x2ed3c3);const _0x39a54d=_0x1058['QUheDS'][_0x19c3fc];return _0x39a54d===undefined?(_0x105865=_0x1058['CGxLlp'](_0x105865),_0x1058['QUheDS'][_0x19c3fc]=_0x105865):_0x105865=_0x39a54d,_0x105865;}const _0x2183e6=0x4,_0x473de7=z['object']({'instanceId':z[_0x474033(0xc8)]()['min'](0x1),'name':z[_0x474033(0xc8)]()['min'](0x1),'directory':z[_0x474033(0xc8)]()[_0x474033(0xcf)](0x1)})[_0x474033(0xd9)](),_0x4f89a9=z['object']({'id':z[_0x474033(0xc8)]()[_0x474033(0xcf)](0x1),'from':_0x473de7,'text':z[_0x474033(0xc8)](),'via':z['array'](z['string']())[_0x474033(0xf7)](_0x2183e6),'sentAt':z[_0x474033(0xab)]()['finite']()})['passthrough'](),_0x15e52b=z[_0x474033(0xe1)]({'version':z['literal'](0x2),'messageId':z[_0x474033(0xc8)]()['min'](0x1),'fromEndpointId':z[_0x474033(0xc8)]()[_0x474033(0xcf)](0x1),'toEndpointId':z[_0x474033(0xc8)]()[_0x474033(0xcf)](0x1),'from':_0x473de7,'text':z[_0x474033(0xc8)](),'via':z[_0x474033(0xd2)](z[_0x474033(0xc8)]())[_0x474033(0xf7)](_0x2183e6),'sentAt':z[_0x474033(0xab)]()[_0x474033(0xd0)]()})[_0x474033(0xd9)](),_0x98069f=z[_0x474033(0xe1)]({'version':z['literal'](0x2),'messageId':z[_0x474033(0xc8)]()[_0x474033(0xcf)](0x1),'fromEndpointId':z[_0x474033(0xc8)]()[_0x474033(0xcf)](0x1),'toEndpointId':z['string']()['min'](0x1),'status':z[_0x474033(0xdb)]([_0x474033(0x105),_0x474033(0xad),_0x474033(0xd5),_0x474033(0x97),_0x474033(0xc1)]),'acknowledgedAt':z['number']()[_0x474033(0xd0)]()})[_0x474033(0xd9)]();function _0x2e8a4a(_0x288a38){const _0x16f695=_0x474033;switch(_0x288a38){case _0x16f695(0xad):return 0x193;case _0x16f695(0xcd):return 0x1ad;default:return 0xca;}}function _0x4f376d(_0x2da531){const _0x43e723=_0x474033;if(typeof _0x2da531===_0x43e723(0xe1)&&_0x2da531!==null&&_0x43e723(0xb9)in _0x2da531&&_0x2da531[_0x43e723(0xb9)]===0x2){const _0x539499=_0x15e52b[_0x43e723(0x99)](_0x2da531);if(!_0x539499[_0x43e723(0xcb)])return null;const _0x327d63=_0x539499[_0x43e723(0xe2)];return{'message':{'id':_0x327d63[_0x43e723(0x101)],'from':{'instanceId':_0x327d63[_0x43e723(0xa8)],'name':_0x327d63[_0x43e723(0xf4)][_0x43e723(0xd8)],'directory':_0x327d63[_0x43e723(0xf4)][_0x43e723(0xcc)]},'text':_0x327d63[_0x43e723(0x102)],'via':_0x327d63[_0x43e723(0x9e)],'sentAt':_0x327d63[_0x43e723(0xed)]},'route':{'version':0x2,'toEndpointId':_0x327d63[_0x43e723(0xf6)]}};}const _0x1bad8a=_0x4f89a9[_0x43e723(0x99)](_0x2da531);return _0x1bad8a[_0x43e723(0xcb)]?{'message':_0x1bad8a[_0x43e723(0xe2)],'route':{'version':0x1}}:null;}export function defaultRuntimeDirectory(_0x5ec108=process.env,_0x4e9490=typeof process[_0x474033(0x98)]===_0x474033(0xb6)?process[_0x474033(0x98)]():0x0){const _0x1a0a66=_0x474033;return _0x5ec108[_0x1a0a66(0xb4)]?join(_0x5ec108[_0x1a0a66(0xb4)],_0x1a0a66(0xd3)):join(tmpdir(),_0x1a0a66(0xff)+_0x4e9490);}export function InboxListener(_0x51965c){const _0x252a64=_0x474033;let _0x21b7e6=null,_0x5a848d=null,_0x247876=null,_0xf6c62e=_0x252a64(0xac);function _0x518490(_0x4dbb9b){const _0x807657=_0x252a64;return _0x4dbb9b===_0x807657(0xe6)+_0x51965c['token'];}async function _0x5118e9(_0x29e4e8,_0x31d512){const _0x2e5768=_0x252a64,_0x58a21f=(_0x3f37ef,_0x7e7eb7)=>{const _0x16bd61=_0x1058;_0x31d512[_0x16bd61(0xbf)](_0x3f37ef,{'content-type':_0x16bd61(0xd7)}),_0x31d512[_0x16bd61(0xae)](JSON[_0x16bd61(0xc5)](_0x7e7eb7));};if(!_0x518490(_0x29e4e8[_0x2e5768(0xef)]['authorization'])){_0x58a21f(0x191,{'error':_0x2e5768(0x108)});return;}if(_0x29e4e8[_0x2e5768(0xb5)]===_0x2e5768(0xeb)&&_0x29e4e8[_0x2e5768(0xf9)]===_0x2e5768(0xd1)){_0x58a21f(0xc8,{'ok':!![]});return;}if(_0x29e4e8[_0x2e5768(0xb5)]!==_0x2e5768(0x100)||_0x29e4e8[_0x2e5768(0xf9)]!==_0x2e5768(0xb0)&&_0x29e4e8[_0x2e5768(0xf9)]!==_0x2e5768(0xf1)){_0x58a21f(0x194,{'error':_0x2e5768(0x107)});return;}const _0x38f70d=[];let _0x3fa861=0x0;for await(const _0x47eb39 of _0x29e4e8){_0x3fa861+=_0x47eb39[_0x2e5768(0xec)];if(_0x3fa861>_0x51965c[_0x2e5768(0xa1)]){_0x58a21f(0x19d,{'error':_0x2e5768(0x9b)}),_0x29e4e8[_0x2e5768(0xfd)]();return;}_0x38f70d['push'](_0x47eb39);}let _0x12bae3;try{_0x12bae3=JSON[_0x2e5768(0xa3)](Buffer[_0x2e5768(0xf8)](_0x38f70d)[_0x2e5768(0x9c)](_0x2e5768(0xc7)));}catch{_0x58a21f(0x190,{'error':_0x2e5768(0xa2)});return;}if(_0x29e4e8[_0x2e5768(0xf9)]===_0x2e5768(0xf1)){const _0x3cf028=_0x98069f[_0x2e5768(0x99)](_0x12bae3);if(!_0x3cf028[_0x2e5768(0xcb)]){_0x58a21f(0x190,{'error':_0x2e5768(0xf2)});return;}await _0x51965c[_0x2e5768(0xc3)]?.(_0x3cf028[_0x2e5768(0xe2)]),_0x58a21f(0xca,{'status':_0x2e5768(0xfb)});return;}const _0x1d9e6a=_0x4f376d(_0x12bae3);if(!_0x1d9e6a){_0x58a21f(0x190,{'error':_0x2e5768(0xfc)});return;}const _0x453ca2=_0x1d9e6a['message'];if(Buffer[_0x2e5768(0xce)](_0x453ca2[_0x2e5768(0x102)],'utf8')>(_0x51965c['maxMessageBytes']??0x2000)){_0x58a21f(0x19d,{'error':_0x2e5768(0x9b)});return;}if(Math[_0x2e5768(0xdf)](Date['now']()-_0x453ca2[_0x2e5768(0xed)])>(_0x51965c['maxMessageAgeMs']??0x493e0)){_0x58a21f(0x190,{'error':'stale\x20message'});return;}try{const _0x32e5e9=await _0x51965c[_0x2e5768(0xe8)]?.(_0x1d9e6a[_0x2e5768(0xbc)]);if(_0x51965c[_0x2e5768(0xe8)]&&!_0x32e5e9){_0x58a21f(0x194,{'error':_0x2e5768(0xaa)});return;}const _0x4dbc2f=await _0x51965c[_0x2e5768(0xbd)](_0x453ca2,_0x32e5e9??_0x1d9e6a[_0x2e5768(0xbc)][_0x2e5768(0xf6)]);_0x58a21f(_0x2e8a4a(_0x4dbc2f),{'status':_0x4dbc2f});}catch(_0x2ee276){await _0x51965c[_0x2e5768(0xbb)](_0x2e5768(0xbe),'onMessage\x20handler\x20failed',{'error':String(_0x2ee276)}),_0x58a21f(0x1f4,{'error':_0x2e5768(0xd6)});}}function _0x3aa340(){return createServer((_0x2f46ec,_0x5b137a)=>{const _0x470ee2=_0x1058;_0x5118e9(_0x2f46ec,_0x5b137a)[_0x470ee2(0xa6)](_0x25be9a=>{const _0xc65df2=_0x470ee2;void _0x51965c[_0xc65df2(0xbb)](_0xc65df2(0xbe),_0xc65df2(0xee),{'error':String(_0x25be9a)});if(!_0x5b137a[_0xc65df2(0xb8)])_0x5b137a[_0xc65df2(0xbf)](0x1f4)[_0xc65df2(0xae)]();else _0x5b137a[_0xc65df2(0xae)]();});});}function _0x2e4eaf(_0x5d3abd,_0x253624){return new Promise((_0x3573e6,_0x101804)=>{const _0x583e5b=_0x1058,onError=_0x3af2de=>{const _0x45acb1=_0x1058;_0x5d3abd[_0x45acb1(0x9d)]('listening',_0x23e81e),_0x101804(_0x3af2de);},_0x23e81e=()=>{_0x5d3abd['off']('error',onError),_0x3573e6();};_0x5d3abd[_0x583e5b(0xaf)](_0x583e5b(0xbe),onError),_0x5d3abd[_0x583e5b(0xaf)](_0x583e5b(0xda),_0x23e81e),_0x5d3abd['listen'](_0x253624);});}function _0x272940(_0x49a830){return new Promise((_0x20c876,_0x393fa3)=>{const _0x151147=_0x1058,onError=_0x2df2d0=>{const _0x4e34c9=_0x1058;_0x49a830[_0x4e34c9(0x9d)](_0x4e34c9(0xda),_0x53aa99),_0x393fa3(_0x2df2d0);},_0x53aa99=()=>{const _0x5a1ed3=_0x1058;_0x49a830[_0x5a1ed3(0x9d)](_0x5a1ed3(0xbe),onError),_0x20c876(_0x49a830[_0x5a1ed3(0x9a)]()[_0x5a1ed3(0xa0)]);};_0x49a830[_0x151147(0xaf)](_0x151147(0xbe),onError),_0x49a830[_0x151147(0xaf)](_0x151147(0xda),_0x53aa99),_0x49a830['listen'](0x0,_0x151147(0xe4));});}function _0x84336f(_0x27826a){return new Promise((_0x3ec62d,_0x265254)=>{const _0x26d63e=_0x1058;if(!_0x27826a?.[_0x26d63e(0xda)]){_0x3ec62d();return;}_0x27826a['close'](_0x15f817=>_0x15f817?_0x265254(_0x15f817):_0x3ec62d());});}function _0x59b81e(_0x1252f9){return new Promise((_0x2f7cff,_0x4a0d03)=>{const _0x15d057=_0x1058,_0x5dc759=connect({'path':_0x1252f9});let _0x26138c=![];const _0x2cb9a3=(_0x205add,_0x53a428)=>{const _0x1e6e15=_0x1058;if(_0x26138c)return;_0x26138c=!![],_0x5dc759[_0x1e6e15(0xfd)]();if(_0x53a428)_0x4a0d03(_0x53a428);else _0x2f7cff(_0x205add);};_0x5dc759[_0x15d057(0xaf)](_0x15d057(0x106),()=>_0x2cb9a3(!![])),_0x5dc759[_0x15d057(0xaf)](_0x15d057(0xbe),_0x50cde8=>{const _0x4caa53=_0x15d057;if(_0x50cde8[_0x4caa53(0x9f)]===_0x4caa53(0xe7)||_0x50cde8[_0x4caa53(0x9f)]==='ENOENT')_0x2cb9a3(![]);else _0x2cb9a3(![],_0x50cde8);}),_0x5dc759[_0x15d057(0xb3)](0x1f4,()=>_0x2cb9a3(!![]));});}async function _0x5f1b63(_0x33718f){const _0x1735a5=_0x252a64;try{const _0x21dc46=await lstat(_0x33718f);if(!_0x21dc46[_0x1735a5(0xe9)]())throw new Error(_0x1735a5(0xdc)+_0x33718f);if(await _0x59b81e(_0x33718f))throw new Error(_0x1735a5(0xba)+_0x33718f);await rm(_0x33718f);}catch(_0x187baa){if(_0x187baa[_0x1735a5(0x9f)]!==_0x1735a5(0xc2))throw _0x187baa;}}return{async 'start'(){const _0x4cc101=_0x252a64;if(_0xf6c62e!==_0x4cc101(0xac))throw new Error('listener\x20cannot\x20start\x20while\x20'+_0xf6c62e);_0xf6c62e=_0x4cc101(0xf5);const _0xcc3b69=_0x51965c[_0x4cc101(0xc0)]??(_0x51965c[_0x4cc101(0x103)]?process[_0x4cc101(0xc0)]:_0x4cc101(0x96));if(_0xcc3b69===_0x4cc101(0x96)){_0x21b7e6=_0x3aa340();try{const _0x3a7482=await _0x272940(_0x21b7e6);_0xf6c62e=_0x4cc101(0xa7);const _0x1d624d='http://127.0.0.1:'+_0x3a7482;return{'port':_0x3a7482,'url':_0x1d624d,'compatibilityUrl':_0x1d624d,'address':{'type':'tcp','host':_0x4cc101(0xe4),'port':_0x3a7482}};}catch(_0x46d7a1){await _0x84336f(_0x21b7e6)['catch'](()=>{}),_0x21b7e6=null,_0xf6c62e='stopped';throw _0x46d7a1;}}const _0x371e25=_0x51965c[_0x4cc101(0xb2)]??defaultRuntimeDirectory(),_0x9cf2eb=join(_0x371e25,(_0x51965c[_0x4cc101(0x103)]??process[_0x4cc101(0xe3)])+_0x4cc101(0xe0));let _0x55f2ee=![];try{await mkdir(_0x371e25,{'recursive':!![],'mode':0x1c0}),await chmod(_0x371e25,0x1c0),await _0x5f1b63(_0x9cf2eb),_0x21b7e6=_0x3aa340(),await _0x2e4eaf(_0x21b7e6,_0x9cf2eb),_0x55f2ee=!![],_0x247876=_0x9cf2eb,await chmod(_0x9cf2eb,0x180),_0x5a848d=_0x3aa340();const _0x27a9a2=await _0x272940(_0x5a848d);return _0xf6c62e=_0x4cc101(0xa7),{'port':_0x27a9a2,'url':_0x4cc101(0xc4)+encodeURIComponent(_0x9cf2eb),'compatibilityUrl':_0x4cc101(0xc6)+_0x27a9a2,'address':{'type':_0x4cc101(0xc9),'path':_0x9cf2eb}};}catch(_0x5ae776){await Promise[_0x4cc101(0xa5)]([_0x84336f(_0x5a848d)[_0x4cc101(0xa6)](()=>{}),_0x84336f(_0x21b7e6)[_0x4cc101(0xa6)](()=>{})]),_0x5a848d=null,_0x21b7e6=null;if(_0x55f2ee)await rm(_0x9cf2eb,{'force':!![]})[_0x4cc101(0xa6)](()=>{});_0x247876=null,_0xf6c62e=_0x4cc101(0xd4);throw _0x5ae776;}},async 'stop'(){const _0x132afe=_0x252a64;if(_0xf6c62e===_0x132afe(0xd4))return;_0xf6c62e=_0x132afe(0xfe);const _0xf17c7e=_0x247876,_0x3c5a3e=[_0x5a848d,_0x21b7e6];_0x5a848d=null,_0x21b7e6=null,_0x247876=null,await Promise[_0x132afe(0xa5)](_0x3c5a3e[_0x132afe(0x95)](_0x2f3ee2=>_0x84336f(_0x2f3ee2)));if(_0xf17c7e)await rm(_0xf17c7e,{'force':!![]});_0xf6c62e=_0x132afe(0xd4);}};}
|
|
2
|
+
//# sourceMappingURL=.js.map
|
package/dist/outbox.js
CHANGED
|
@@ -1,110 +1,2 @@
|
|
|
1
|
-
import { randomBytes }
|
|
2
|
-
|
|
3
|
-
import { dirname, join } from "node:path";
|
|
4
|
-
function safe(value) {
|
|
5
|
-
return value.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
6
|
-
}
|
|
7
|
-
export function Outbox(opts) {
|
|
8
|
-
const root = join(opts.storageDir, "outbox");
|
|
9
|
-
function ensure(directory) {
|
|
10
|
-
mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
11
|
-
chmodSync(directory, 0o700);
|
|
12
|
-
}
|
|
13
|
-
function pathFor(endpointId, messageId) {
|
|
14
|
-
return join(root, safe(endpointId), `${safe(messageId)}.json`);
|
|
15
|
-
}
|
|
16
|
-
function read(endpointId, messageId) {
|
|
17
|
-
try {
|
|
18
|
-
const value = JSON.parse(readFileSync(pathFor(endpointId, messageId), "utf8"));
|
|
19
|
-
return value.version === 1 && value.messageId === messageId && value.fromEndpointId === endpointId ? value : null;
|
|
20
|
-
}
|
|
21
|
-
catch {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function persist(record) {
|
|
26
|
-
const target = pathFor(record.fromEndpointId, record.messageId);
|
|
27
|
-
const directory = dirname(target);
|
|
28
|
-
ensure(root);
|
|
29
|
-
ensure(directory);
|
|
30
|
-
const temp = join(directory, `.${process.pid}.${randomBytes(8).toString("hex")}.tmp`);
|
|
31
|
-
const fd = openSync(temp, "wx", 0o600);
|
|
32
|
-
try {
|
|
33
|
-
writeSync(fd, JSON.stringify(record));
|
|
34
|
-
fsyncSync(fd);
|
|
35
|
-
}
|
|
36
|
-
finally {
|
|
37
|
-
closeSync(fd);
|
|
38
|
-
}
|
|
39
|
-
chmodSync(temp, 0o600);
|
|
40
|
-
renameSync(temp, target);
|
|
41
|
-
if (process.platform !== "win32") {
|
|
42
|
-
const dirFd = openSync(directory, "r");
|
|
43
|
-
try {
|
|
44
|
-
fsyncSync(dirFd);
|
|
45
|
-
}
|
|
46
|
-
finally {
|
|
47
|
-
closeSync(dirFd);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function update(endpointId, messageId, values) {
|
|
52
|
-
const current = read(endpointId, messageId);
|
|
53
|
-
if (!current)
|
|
54
|
-
return null;
|
|
55
|
-
const next = { ...current, ...values, updatedAt: Date.now() };
|
|
56
|
-
persist(next);
|
|
57
|
-
return next;
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
async recordPending(message, toName) {
|
|
61
|
-
const existing = read(message.fromEndpointId, message.messageId);
|
|
62
|
-
if (existing)
|
|
63
|
-
return existing;
|
|
64
|
-
const record = {
|
|
65
|
-
version: 1,
|
|
66
|
-
messageId: message.messageId,
|
|
67
|
-
fromEndpointId: message.fromEndpointId,
|
|
68
|
-
toEndpointId: message.toEndpointId,
|
|
69
|
-
toName,
|
|
70
|
-
text: message.text,
|
|
71
|
-
createdAt: Date.now(),
|
|
72
|
-
updatedAt: Date.now(),
|
|
73
|
-
};
|
|
74
|
-
persist(record);
|
|
75
|
-
return record;
|
|
76
|
-
},
|
|
77
|
-
async recordReceipt(messageId, fromEndpointId, status) {
|
|
78
|
-
return update(fromEndpointId, messageId, { receiptStatus: status, error: undefined });
|
|
79
|
-
},
|
|
80
|
-
async recordFailure(messageId, fromEndpointId, error) {
|
|
81
|
-
return update(fromEndpointId, messageId, { error });
|
|
82
|
-
},
|
|
83
|
-
async applyAcknowledgement(ack) {
|
|
84
|
-
const record = read(ack.fromEndpointId, ack.messageId);
|
|
85
|
-
if (!record || record.toEndpointId !== ack.toEndpointId)
|
|
86
|
-
return false;
|
|
87
|
-
update(ack.fromEndpointId, ack.messageId, {
|
|
88
|
-
finalStatus: ack.status,
|
|
89
|
-
acknowledgedAt: ack.acknowledgedAt,
|
|
90
|
-
error: undefined,
|
|
91
|
-
});
|
|
92
|
-
return true;
|
|
93
|
-
},
|
|
94
|
-
get: read,
|
|
95
|
-
list(fromEndpointId) {
|
|
96
|
-
const directory = join(root, safe(fromEndpointId));
|
|
97
|
-
if (!existsSync(directory))
|
|
98
|
-
return [];
|
|
99
|
-
return readdirSync(directory).filter((file) => file.endsWith(".json")).flatMap((file) => {
|
|
100
|
-
try {
|
|
101
|
-
const record = JSON.parse(readFileSync(join(directory, file), "utf8"));
|
|
102
|
-
return record.version === 1 && record.fromEndpointId === fromEndpointId ? [record] : [];
|
|
103
|
-
}
|
|
104
|
-
catch {
|
|
105
|
-
return [];
|
|
106
|
-
}
|
|
107
|
-
}).sort((a, b) => b.createdAt - a.createdAt || b.messageId.localeCompare(a.messageId));
|
|
108
|
-
},
|
|
109
|
-
};
|
|
110
|
-
}
|
|
1
|
+
(function(stringArrayFunction,_0x37ebfa){const _0x3b639e=_0x4cde,stringArray=stringArrayFunction();while(!![]){try{const _0x19ddac=-parseInt(_0x3b639e(0x83))/0x1+parseInt(_0x3b639e(0x89))/0x2+parseInt(_0x3b639e(0x82))/0x3+-parseInt(_0x3b639e(0x7e))/0x4+-parseInt(_0x3b639e(0x7c))/0x5+parseInt(_0x3b639e(0x75))/0x6*(parseInt(_0x3b639e(0x8a))/0x7)+parseInt(_0x3b639e(0x8d))/0x8;if(_0x19ddac===_0x37ebfa)break;else stringArray['push'](stringArray['shift']());}catch(_0x17c392){stringArray['push'](stringArray['shift']());}}}(_0x12ee,0x7d4d7));import{randomBytes}from'node:crypto';import{chmodSync,closeSync,existsSync,fsyncSync,mkdirSync,openSync,readFileSync,readdirSync,renameSync,writeSync}from'node:fs';import{dirname,join}from'node:path';function _0x254a6c(_0x55bd76){const _0x2ae928=_0x4cde;return _0x55bd76[_0x2ae928(0x78)](/[^a-zA-Z0-9_-]/g,'_');}export function Outbox(_0x11d044){const _0x580b36=_0x4cde,_0x28a8cb=join(_0x11d044[_0x580b36(0x7b)],_0x580b36(0x8f));function _0x40f2be(_0x547b6d){mkdirSync(_0x547b6d,{'recursive':!![],'mode':0x1c0}),chmodSync(_0x547b6d,0x1c0);}function _0x51efd0(_0x3ccdf1,_0x269f27){const _0x5c165a=_0x580b36;return join(_0x28a8cb,_0x254a6c(_0x3ccdf1),_0x254a6c(_0x269f27)+_0x5c165a(0x86));}function _0x2239ea(_0x486f72,_0x433921){const _0x4b156b=_0x580b36;try{const _0x2aedc7=JSON[_0x4b156b(0x80)](readFileSync(_0x51efd0(_0x486f72,_0x433921),'utf8'));return _0x2aedc7[_0x4b156b(0x7a)]===0x1&&_0x2aedc7[_0x4b156b(0x8e)]===_0x433921&&_0x2aedc7[_0x4b156b(0x85)]===_0x486f72?_0x2aedc7:null;}catch{return null;}}function _0x5a594e(_0x2e6a82){const _0x19d1b0=_0x580b36,_0x314990=_0x51efd0(_0x2e6a82[_0x19d1b0(0x85)],_0x2e6a82[_0x19d1b0(0x8e)]),_0x11d6ef=dirname(_0x314990);_0x40f2be(_0x28a8cb),_0x40f2be(_0x11d6ef);const _0x8ff7ee=join(_0x11d6ef,'.'+process[_0x19d1b0(0x7d)]+'.'+randomBytes(0x8)[_0x19d1b0(0x88)](_0x19d1b0(0x8c))+_0x19d1b0(0x79)),_0x55d004=openSync(_0x8ff7ee,'wx',0x180);try{writeSync(_0x55d004,JSON['stringify'](_0x2e6a82)),fsyncSync(_0x55d004);}finally{closeSync(_0x55d004);}chmodSync(_0x8ff7ee,0x180),renameSync(_0x8ff7ee,_0x314990);if(process['platform']!==_0x19d1b0(0x73)){const _0x347b37=openSync(_0x11d6ef,'r');try{fsyncSync(_0x347b37);}finally{closeSync(_0x347b37);}}}function _0x325bea(_0x5050b5,_0x3b1895,_0x3a82d9){const _0x5f1090=_0x580b36,_0x3bd558=_0x2239ea(_0x5050b5,_0x3b1895);if(!_0x3bd558)return null;const _0x46b866={..._0x3bd558,..._0x3a82d9,'updatedAt':Date[_0x5f1090(0x90)]()};return _0x5a594e(_0x46b866),_0x46b866;}return{async 'recordPending'(_0x31c157,_0x3aa4e3){const _0x1ceb37=_0x580b36,_0x58f338=_0x2239ea(_0x31c157[_0x1ceb37(0x85)],_0x31c157['messageId']);if(_0x58f338)return _0x58f338;const _0x2a3361={'version':0x1,'messageId':_0x31c157[_0x1ceb37(0x8e)],'fromEndpointId':_0x31c157['fromEndpointId'],'toEndpointId':_0x31c157['toEndpointId'],'toName':_0x3aa4e3,'text':_0x31c157[_0x1ceb37(0x77)],'createdAt':Date['now'](),'updatedAt':Date['now']()};return _0x5a594e(_0x2a3361),_0x2a3361;},async 'recordReceipt'(_0x573136,fromEndpointId,_0x3cdab8){return _0x325bea(fromEndpointId,_0x573136,{'receiptStatus':_0x3cdab8,'error':undefined});},async 'recordFailure'(_0x283130,fromEndpointId,_0x1e3095){return _0x325bea(fromEndpointId,_0x283130,{'error':_0x1e3095});},async 'applyAcknowledgement'(_0x4979f3){const _0xc1cd8=_0x580b36,_0x30654c=_0x2239ea(_0x4979f3[_0xc1cd8(0x85)],_0x4979f3[_0xc1cd8(0x8e)]);if(!_0x30654c||_0x30654c[_0xc1cd8(0x8b)]!==_0x4979f3[_0xc1cd8(0x8b)])return![];return _0x325bea(_0x4979f3[_0xc1cd8(0x85)],_0x4979f3['messageId'],{'finalStatus':_0x4979f3[_0xc1cd8(0x81)],'acknowledgedAt':_0x4979f3[_0xc1cd8(0x7f)],'error':undefined}),!![];},'get':_0x2239ea,'list'(fromEndpointId){const _0x57e711=_0x580b36,_0x1aa1ed=join(_0x28a8cb,_0x254a6c(fromEndpointId));if(!existsSync(_0x1aa1ed))return[];return readdirSync(_0x1aa1ed)[_0x57e711(0x72)](_0x3bc714=>_0x3bc714[_0x57e711(0x76)](_0x57e711(0x86)))[_0x57e711(0x74)](_0x25f0bc=>{const _0xa6d9a8=_0x57e711;try{const _0x3d4bb3=JSON['parse'](readFileSync(join(_0x1aa1ed,_0x25f0bc),'utf8'));return _0x3d4bb3[_0xa6d9a8(0x7a)]===0x1&&_0x3d4bb3[_0xa6d9a8(0x85)]===fromEndpointId?[_0x3d4bb3]:[];}catch{return[];}})['sort']((_0x1e043d,_0x97b7e8)=>_0x97b7e8[_0x57e711(0x87)]-_0x1e043d[_0x57e711(0x87)]||_0x97b7e8[_0x57e711(0x8e)][_0x57e711(0x84)](_0x1e043d['messageId']));}};}function _0x4cde(_0x195740,_0x492988){_0x195740=_0x195740-0x72;const _0x12ee43=_0x12ee();let _0x4cde93=_0x12ee43[_0x195740];if(_0x4cde['zQqolV']===undefined){var _0x26a46a=function(_0x11a736){const _0x4dba49='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x2269c0='',_0x254a6c='';for(let _0x55bd76=0x0,_0x11d044,_0x28a8cb,_0x40f2be=0x0;_0x28a8cb=_0x11a736['charAt'](_0x40f2be++);~_0x28a8cb&&(_0x11d044=_0x55bd76%0x4?_0x11d044*0x40+_0x28a8cb:_0x28a8cb,_0x55bd76++%0x4)?_0x2269c0+=String['fromCharCode'](0xff&_0x11d044>>(-0x2*_0x55bd76&0x6)):0x0){_0x28a8cb=_0x4dba49['indexOf'](_0x28a8cb);}for(let _0x51efd0=0x0,_0x2239ea=_0x2269c0['length'];_0x51efd0<_0x2239ea;_0x51efd0++){_0x254a6c+='%'+('00'+_0x2269c0['charCodeAt'](_0x51efd0)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x254a6c);};_0x4cde['bgpsUg']=_0x26a46a,_0x4cde['VSOzPp']={},_0x4cde['zQqolV']=!![];}const _0x53098b=_0x12ee43[0x0];_0x4cde['mJxZPt']!==_0x53098b&&(_0x4cde['VSOzPp']={},_0x4cde['mJxZPt']=_0x53098b);const _0x361e61=_0x4cde['VSOzPp'][_0x195740];return _0x361e61===undefined?(_0x4cde93=_0x4cde['bgpsUg'](_0x4cde93),_0x4cde['VSOzPp'][_0x195740]=_0x4cde93):_0x4cde93=_0x361e61,_0x4cde93;}function _0x12ee(){const _0x486732=['BwvZC2fNzuLK','B3v0yM94','BM93','zMLSDgvY','D2LUmZi','zMXHDe1HCa','nMzyseLktG','zw5KC1DPDgG','Dgv4Da','CMvWBgfJzq','lNrTCa','DMvYC2LVBG','C3rVCMfNzurPCG','ndmZntu4mg5Vu3fUyG','CgLK','mtyZntmYnfLuExnesq','ywnRBM93BgvKz2vKqxq','CgfYC2u','C3rHDhvZ','mJK0nty1oe9Ls1zJEq','ntmYntbfyu11sKu','Bg9JywXLq29TCgfYzq','zNjVBuvUzhbVAw50swq','lMPZB24','y3jLyxrLzef0','Dg9tDhjPBMC','mZKWmdC2uLfsENbU','nda2mdK1oxbdyMn1zG','Dg9fBMrWB2LUDeLK','Agv4','nJGZmdaWB0fWs3fI'];_0x12ee=function(){return _0x486732;};return _0x12ee();}
|
|
2
|
+
//# sourceMappingURL=.js.map
|