496 lines
20 KiB
JavaScript
496 lines
20 KiB
JavaScript
// Offscreen document: hosts the live OF signer (needs eval) and runs the
|
|
// whole DRM pipeline. The SW relays messages here.
|
|
import { loadLiveSigner } from "./lib/signer.js";
|
|
import { buildPath } from "./lib/paths.js";
|
|
import {
|
|
holdsDir, streamIntoHold, holdFileUrl, removeHolds,
|
|
decryptTrackToOpfs, pushTrackMoofs, writeMuxedFile, drmCapture,
|
|
} from "./lib/holds.js";
|
|
|
|
function toUnixSeconds(d) {
|
|
if (d == null) return null;
|
|
if (typeof d === "number") return d > 1e12 ? Math.floor(d / 1000) : Math.floor(d);
|
|
const parsed = Date.parse(d);
|
|
return Number.isNaN(parsed) ? null : Math.floor(parsed / 1000);
|
|
}
|
|
import {
|
|
buildChallenge, processLicense, widevinePsshFromMpd, kidFromMpd,
|
|
} from "./lib/wv.js";
|
|
import { tryParse } from "./lib/pb.js";
|
|
|
|
const log = [];
|
|
const say = (m) => {
|
|
log.push(m);
|
|
if (log.length > 120) log.splice(0, log.length - 120); // cap: bundles log a lot
|
|
console.log("[ofsaver]", m);
|
|
};
|
|
|
|
const b64ToBytes = (b64) => Uint8Array.from(atob(b64), (c) => c.charCodeAt(0));
|
|
const bytesToB64 = (bytes) => {
|
|
let s = "";
|
|
for (const b of bytes) s += String.fromCharCode(b);
|
|
return btoa(s);
|
|
};
|
|
|
|
let signerPromise = null;
|
|
function getSigner() {
|
|
if (!signerPromise) {
|
|
signerPromise = loadLiveSigner(say).catch((err) => {
|
|
signerPromise = null;
|
|
throw err;
|
|
});
|
|
}
|
|
return signerPromise;
|
|
}
|
|
|
|
/** The logged-in account id from the browser cookie jar. */
|
|
async function authUserId() {
|
|
try {
|
|
const c = await chrome.cookies.get({ url: "https://onlyfans.com", name: "auth_id" });
|
|
return c?.value ?? "0";
|
|
} catch { return "0"; }
|
|
}
|
|
|
|
/** Signed headers for an OF API call (same shape as ofsaver's OfApi). */
|
|
let cachedUserId = null;
|
|
function setUserId(id) { if (id) cachedUserId = String(id); }
|
|
|
|
let activeSigner = null;
|
|
async function signedHeaders(pathWithQuery, method = "GET", hasBody = false) {
|
|
const signer = await getSigner();
|
|
activeSigner = signer;
|
|
const userId = cachedUserId ?? "0";
|
|
const { sign, time } = signer.sign(pathWithQuery, userId);
|
|
const headers = {
|
|
accept: "application/json, text/plain, */*",
|
|
"app-token": signer.appToken,
|
|
"user-id": userId,
|
|
referer: "https://onlyfans.com/",
|
|
"user-agent": navigator.userAgent,
|
|
sign,
|
|
time,
|
|
"x-of-rev": signer.revision,
|
|
};
|
|
if (hasBody) headers["content-type"] = "application/json";
|
|
return headers;
|
|
}
|
|
|
|
const CANON = {
|
|
"CloudFront-Policy": "Policy",
|
|
"CloudFront-Signature": "Signature",
|
|
"CloudFront-Key-Pair-Id": "Key-Pair-Id",
|
|
};
|
|
|
|
function signedCdnUrl(rawUrl, sig) {
|
|
const url = new URL(rawUrl);
|
|
for (const [k, v] of Object.entries(sig ?? {})) {
|
|
const name = CANON[k] ?? k;
|
|
url.searchParams.delete(k);
|
|
url.searchParams.set(name, v);
|
|
}
|
|
return url.toString();
|
|
}
|
|
|
|
/** Plain-media download URL from a crawled media object. */
|
|
function plainDownload(mediaItem) {
|
|
const files = mediaItem.files ?? {};
|
|
const type = mediaItem.type;
|
|
if (type === "video" || type === "audio") {
|
|
const url = files.source?.url ?? files.full?.url ?? null;
|
|
return url ? { url, ext: "mp4" } : null;
|
|
}
|
|
if (type === "photo" || type === "gif") {
|
|
const url = files.full?.url ?? files.preview?.url ?? null;
|
|
return url ? { url, ext: type === "gif" ? "gif" : "jpg" } : null;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/** Creator bundle: resolve, crawl timeline, license DRM videos, list downloads. */
|
|
async function runBundle(who, max = 200) {
|
|
const t0 = Date.now();
|
|
const uPath = `/api2/v2/users/${encodeURIComponent(String(who).replace(/^@/, ""))}`;
|
|
let headers;
|
|
try { headers = await signedHeaders(uPath); }
|
|
catch (e) { headers = { referer: "https://onlyfans.com/" }; }
|
|
const uRes = await fetch(`https://onlyfans.com${uPath}`, { credentials: "include", headers });
|
|
if (!uRes.ok) throw new Error(`user HTTP ${uRes.status}`);
|
|
const user = await uRes.json();
|
|
say(`bundle: ${user.username} (${user.id})`);
|
|
|
|
const mediaItems = []; // {media, postId, responseType}
|
|
let cursor = "";
|
|
for (let page = 0; page < 40 && mediaItems.length < max; page++) {
|
|
let path = `/api2/v2/users/${user.id}/posts/medias?limit=50&order=publish_date_desc&skip_users=all&format=infinite&counters=1`;
|
|
if (cursor) path += `&beforePublishTime=${encodeURIComponent(cursor)}`;
|
|
let h;
|
|
try { h = await signedHeaders(path); } catch { h = { referer: "https://onlyfans.com/" }; }
|
|
const res = await fetch(`https://onlyfans.com${path}`, { credentials: "include", headers: h });
|
|
if (!res.ok) throw new Error(`timeline HTTP ${res.status}`);
|
|
const data = await res.json();
|
|
const list = Array.isArray(data) ? data : data?.list ?? [];
|
|
if (!list.length) break;
|
|
for (const post of list) {
|
|
for (const m of post.media ?? []) {
|
|
mediaItems.push({ media: m, postId: post.id, responseType: post.responseType });
|
|
}
|
|
}
|
|
say(` page ${page + 1}: +${list.length} posts (total media ${mediaItems.length})`);
|
|
if (data?.hasMore !== true) break;
|
|
cursor = data?.tailMarker ?? list[list.length - 1]?.postedAtPrecise ?? "";
|
|
if (!cursor) break;
|
|
await new Promise((r) => setTimeout(r, 400 + Math.floor(Math.random() * 400)));
|
|
}
|
|
|
|
const downloads = [];
|
|
const keys = [];
|
|
let licensed = 0;
|
|
for (const item of mediaItems.slice(0, max)) {
|
|
const m = item.media;
|
|
if (m.files?.drm?.manifest) {
|
|
try {
|
|
const r = await runDrm({
|
|
id: m.id,
|
|
postId: item.postId,
|
|
responseType: item.responseType === "message" ? "message" : "post",
|
|
drm: m.files.drm,
|
|
});
|
|
keys.push({ mediaId: m.id, kid: r.summary.kid, key: r.summary.key });
|
|
savedIds.push(m.id);
|
|
licensed++;
|
|
for (const rep of r.summary.reps) {
|
|
downloads.push({
|
|
url: rep.url,
|
|
filename: buildPath({
|
|
scheme: msg.naming?.bulkScheme ?? "creator-section-type",
|
|
bulk: true,
|
|
creator: user.username,
|
|
type: m.type,
|
|
section: "Timeline",
|
|
date: m.createdAt ?? item.post?.postedAt ?? null,
|
|
timestamp: toUnixSeconds(m.createdAt ?? item.post?.postedAt),
|
|
mediaId: m.id,
|
|
postId: item.postId,
|
|
quality: "source", // bundle takes the best rep = original
|
|
ext: "mp4",
|
|
template: msg.naming?.nameTemplate,
|
|
}),
|
|
});
|
|
}
|
|
await new Promise((r2) => setTimeout(r2, 300));
|
|
} catch (e) {
|
|
say(` media ${m.id}: ${e.message}`);
|
|
}
|
|
} else {
|
|
const d = plainDownload(m);
|
|
if (d && m.canView !== false) {
|
|
savedIds.push(m.id);
|
|
downloads.push({
|
|
url: d.url,
|
|
filename: buildPath({
|
|
scheme: msg.naming?.bulkScheme ?? "creator-section-type",
|
|
bulk: true,
|
|
creator: user.username,
|
|
type: m.type,
|
|
section: "Timeline",
|
|
date: m.createdAt ?? item.post?.postedAt ?? null,
|
|
timestamp: toUnixSeconds(m.createdAt ?? item.post?.postedAt),
|
|
mediaId: m.id,
|
|
postId: item.postId,
|
|
ext: d.ext,
|
|
template: msg.naming?.nameTemplate,
|
|
}),
|
|
});
|
|
}
|
|
}
|
|
}
|
|
say(`bundle done: ${downloads.length} downloads, ${licensed} licensed (${Date.now() - t0}ms)`);
|
|
return { ok: true, summary: { count: downloads.length, downloads, keys, savedIds, user: user.username, ms: Date.now() - t0 } };
|
|
}
|
|
|
|
/** Phase 1: fetch MPD, build challenge + signed headers. */
|
|
async function prepareLicense(media) {
|
|
const { manifest, signature } = media.drm;
|
|
const mpdUrl = signedCdnUrl(manifest.dash, signature?.dash);
|
|
say(`MPD: ${mpdUrl.slice(0, 100)}`);
|
|
const mpdRes = await fetch(mpdUrl, {
|
|
credentials: "include",
|
|
headers: { referer: "https://onlyfans.com/", origin: "https://onlyfans.com" },
|
|
});
|
|
if (!mpdRes.ok) {
|
|
const body = (await mpdRes.text().catch(() => "")).replace(/\s+/g, " ").slice(0, 110);
|
|
throw new Error(`MPD HTTP ${mpdRes.status} ${mpdUrl.split("?")[0].slice(-40)} :: ${body}`);
|
|
}
|
|
const mpd = await mpdRes.text();
|
|
say(`MPD ${mpd.length}B`);
|
|
|
|
const psshPayload = widevinePsshFromMpd(mpd);
|
|
const kid = kidFromMpd(mpd);
|
|
if (!psshPayload) throw new Error("no widevine pssh in MPD");
|
|
say(`KID ${kid} · pssh ${psshPayload.length}B`);
|
|
|
|
const challenge = await buildChallenge(psshPayload);
|
|
const licenseRequest = new Uint8Array(tryParse(challenge).find(([f]) => f === 2)[2]);
|
|
|
|
const responseType = media.responseType === "message" ? "message" : "post";
|
|
const licensePath =
|
|
`/api2/v2/users/media/${media.id}/drm/${responseType}/${media.postId}?type=widevine`;
|
|
const headers = await signedHeaders(licensePath, "POST", true);
|
|
headers["content-type"] = "application/octet-stream";
|
|
// match the captured relay exactly: accept: application/json,
|
|
// x-bc header (fp cookie), no user-agent/referer (the page adds its own)
|
|
headers["accept"] = "application/json";
|
|
headers["x-bc"] = media.xBc ?? headers["x-bc"] ?? "";
|
|
delete headers["user-agent"];
|
|
|
|
say(`challenge ${challenge.length}B ready — relaying through page`);
|
|
return {
|
|
ok: true,
|
|
phase: "prepare",
|
|
diag: { uid: cachedUserId ?? "none", bcLen: String(media.xBc ?? "").length, rev: activeSigner?.revision ?? "?" },
|
|
mpd, kid, mpdUrl,
|
|
licensePath,
|
|
challengeB64: bytesToB64(challenge),
|
|
licenseRequestB64: bytesToB64(licenseRequest),
|
|
headers,
|
|
};
|
|
}
|
|
|
|
/** Phase 2: process the license the page fetched for us. */
|
|
async function finishLicense(msg) {
|
|
const licenseBuf = b64ToBytes(msg.licenseB64);
|
|
const licenseRequest = b64ToBytes(msg.licenseRequestB64);
|
|
const { keys, signatureOk, sessionKeyHex } = await processLicense(licenseBuf, licenseRequest);
|
|
say(`license HMAC ok: ${signatureOk}; keys: ${keys.length}`);
|
|
const contentKey = keys.find((k) => k.type === 2);
|
|
if (!contentKey) throw new Error("no content key in license");
|
|
|
|
const mpd = msg.mpd;
|
|
const mpdUrl = msg.mpdUrl;
|
|
const reps = [];
|
|
const sets = [...mpd.matchAll(/<AdaptationSet[\s\S]*?<\/AdaptationSet>/g)];
|
|
for (const set of sets) {
|
|
const kind = /video\/mp4/.test(set[0]) ? "video" : "audio";
|
|
let best = null;
|
|
for (const m of set[0].matchAll(/<Representation[^>]*bandwidth="(\d+)"[\s\S]*?<\/Representation>/g)) {
|
|
const bw = Number(m[1]);
|
|
if (!best || bw > best.bw) best = { bw, body: m[0] };
|
|
}
|
|
if (!best) continue;
|
|
const file = /<BaseURL>([^<]+)<\/BaseURL>/.exec(best.body)?.[1];
|
|
if (file) {
|
|
const dir = mpdUrl.slice(0, mpdUrl.lastIndexOf("/") + 1);
|
|
// the CloudFront signature lives in the MPD's query — carry it onto
|
|
// each representation file (they're under the same signed wildcard)
|
|
const query = mpdUrl.slice(mpdUrl.indexOf("?"));
|
|
const rHeight = /\sheight="(\d+)"/.exec(best.body)?.[1] ?? null;
|
|
const rWidth = /\swidth="(\d+)"/.exec(best.body)?.[1] ?? null;
|
|
reps.push({ kind, bandwidth: best.bw, height: rHeight ? Number(rHeight) : null, width: rWidth ? Number(rWidth) : null, url: dir + file + query });
|
|
}
|
|
}
|
|
say(`reps: ${reps.map((r) => r.kind).join("+")}`);
|
|
return {
|
|
ok: true,
|
|
summary: {
|
|
kid: contentKey.kidHex,
|
|
key: contentKey.keyHex,
|
|
sessionKeyHex,
|
|
signatureOk,
|
|
mpdUrl,
|
|
reps,
|
|
},
|
|
};
|
|
}
|
|
|
|
chrome.runtime.onMessage.addListener((msg, _sender, sendResponse) => {
|
|
if (msg.op === "lastLog") {
|
|
// synchronous probe: names the stage an item hung on (or proves the doc's
|
|
// event loop is blocked, when even this never answers)
|
|
sendResponse({ ok: true, line: log[log.length - 1] ?? "" });
|
|
return;
|
|
}
|
|
if (msg.op === "prepareLicense") {
|
|
setUserId(msg.userId);
|
|
prepareLicense(msg.media)
|
|
.then((r) => sendResponse({ ...r, log }))
|
|
.catch((err) => sendResponse({ ok: false, error: String(err.message ?? err), log }));
|
|
return true;
|
|
}
|
|
if (msg.op === "finishLicense") {
|
|
finishLicense(msg)
|
|
.then((r) => sendResponse({ ...r, log }))
|
|
.catch((err) => sendResponse({ ok: false, error: String(err.message ?? err), log }));
|
|
return true;
|
|
}
|
|
if (msg.op === "fetchAndHold") {
|
|
// fetch files in the offscreen (extension origin + host permissions work
|
|
// here), streaming each straight into OPFS so even multi-GB files never
|
|
// sit in RAM. Returns blob URLs (disk-backed) + hold ids.
|
|
(async () => {
|
|
try {
|
|
const dir = await holdsDir();
|
|
const held = [];
|
|
const mimeFor = (fn) => {
|
|
const ext2 = (fn.split(".").pop() ?? "").toLowerCase();
|
|
return { jpg: "image/jpeg", jpeg: "image/jpeg", png: "image/png", gif: "image/gif", mp4: "video/mp4", webm: "video/webm" }[ext2] ?? "application/octet-stream";
|
|
};
|
|
let total = 0, got = 0, last = 0;
|
|
const report = () => {
|
|
if (!msg.tabId || !total) return;
|
|
const now = Date.now();
|
|
if (now - last < 250 && got < total) return;
|
|
last = now;
|
|
chrome.runtime.sendMessage({ op: "dlProgress", tabId: msg.tabId, id: msg.dlId, pct: Math.min(80, Math.round((got / total) * 80)) }).catch(() => {});
|
|
};
|
|
for (const f of msg.files ?? []) {
|
|
const res = await fetch(f.url, { credentials: "include", headers: { referer: "https://onlyfans.com/" } });
|
|
if (!res.ok) { held.push({ filename: f.filename, ok: false, error: "HTTP " + res.status }); continue; }
|
|
total += Number(res.headers.get("content-length") || 0);
|
|
const { id, size } = await streamIntoHold(dir, res, (n) => { got += n; report(); });
|
|
held.push({ id, filename: f.filename, ok: true, size, blobUrl: await holdFileUrl(dir, id, mimeFor(f.filename)) });
|
|
}
|
|
sendResponse({ ok: true, held });
|
|
} catch (e) {
|
|
sendResponse({ ok: false, error: String(e.message ?? e) });
|
|
}
|
|
})();
|
|
return true;
|
|
}
|
|
if (msg.op === "refreshDrm") {
|
|
// DRM manifest signatures are short-lived — re-fetch the owning post
|
|
// with a signed request and return the media's fresh drm object
|
|
setUserId(msg.userId);
|
|
(async () => {
|
|
try {
|
|
const path = `/api2/v2/post/${msg.postId}?userId=${cachedUserId ?? "0"}`;
|
|
const headers = await signedHeaders(path);
|
|
const res = await fetch(`https://onlyfans.com${path}`, { credentials: "include", headers });
|
|
if (!res.ok) { sendResponse({ ok: false, error: "HTTP " + res.status }); return; }
|
|
const data = await res.json();
|
|
let fresh = null;
|
|
const walk = (x) => {
|
|
if (!x || typeof x !== "object" || fresh) return;
|
|
if (Array.isArray(x)) { for (const v of x) walk(v); return; }
|
|
if (String(x.id) === String(msg.mediaId) && x.files?.drm) { fresh = x; return; }
|
|
for (const k of Object.keys(x)) walk(x[k]);
|
|
};
|
|
walk(data);
|
|
sendResponse({ ok: true, media: fresh });
|
|
} catch (e) {
|
|
sendResponse({ ok: false, error: String(e.message ?? e) });
|
|
}
|
|
})();
|
|
return true;
|
|
}
|
|
if (msg.op === "getCapture") {
|
|
const jsonB64 = globalThis.__ofsaverCapB64 ?? null;
|
|
globalThis.__ofsaverCapB64 = null;
|
|
sendResponse({ ok: true, jsonB64 });
|
|
return;
|
|
}
|
|
if (msg.op === "revokeUrls") {
|
|
for (const u of msg.urls ?? []) { try { URL.revokeObjectURL(u); } catch {} }
|
|
sendResponse({ ok: true });
|
|
return;
|
|
}
|
|
if (msg.op === "dropHeld") {
|
|
// remove held/decrypted/muxed files from OPFS once a download finished
|
|
(async () => {
|
|
try {
|
|
await removeHolds(await holdsDir(), msg.ids ?? []);
|
|
sendResponse({ ok: true });
|
|
} catch { sendResponse({ ok: true }); } // best effort
|
|
})();
|
|
return true;
|
|
}
|
|
if (msg.op === "decryptAndMux") {
|
|
// Stream the DRM flow: tracks stream from OPFS holds, decrypt fragment
|
|
// by fragment into OPFS, and the muxed mp4 is assembled on disk — RAM
|
|
// stays flat no matter the file size.
|
|
(async () => {
|
|
let dir = null;
|
|
const decVideo = "d_" + String(msg.videoId ?? "").replace(/^h_/, "");
|
|
const decAudio = msg.audioId ? "d_" + String(msg.audioId).replace(/^h_/, "") : null;
|
|
const finalName = "m_" + Math.random().toString(36).slice(2);
|
|
try {
|
|
const { initDrmWasm, decryptAndStripFragment, decryptAndStripFragmentCbcs,
|
|
stripInit, tencMarker, tencConstantIv, tencCryptPattern, MuxPlanner } =
|
|
await import(chrome.runtime.getURL("lib/owndrm.js"));
|
|
await initDrmWasm();
|
|
const keyBytes = b64ToBytes(msg.keyB64);
|
|
dir = await holdsDir();
|
|
const fns = { stripInit, tencMarker, tencCryptPattern, tencConstantIv, decryptAndStripFragment, decryptAndStripFragmentCbcs };
|
|
let last = 0;
|
|
const report = (pct) => {
|
|
if (!msg.tabId) return;
|
|
const now = Date.now();
|
|
if (now - last < 250 && pct < 99) return;
|
|
last = now;
|
|
chrome.runtime.sendMessage({ op: "dlProgress", tabId: msg.tabId, id: msg.dlId, pct }).catch(() => {});
|
|
};
|
|
const { header: vHeader } = await decryptTrackToOpfs(dir, msg.videoId, decVideo, keyBytes, fns, "video", (done, tot) => report(80 + Math.round((done / tot) * 12)));
|
|
let aHeader = null;
|
|
if (msg.audioId) aHeader = (await decryptTrackToOpfs(dir, msg.audioId, decAudio, keyBytes, fns, "audio", (done, tot) => report(92 + Math.round((done / tot) * 6)))).header;
|
|
say(`decrypted tracks: video ok${msg.audioId ? ", audio ok" : ""}`);
|
|
const planner = new MuxPlanner(vHeader, aHeader ?? undefined);
|
|
await pushTrackMoofs(dir, decVideo, planner, true);
|
|
if (msg.audioId) await pushTrackMoofs(dir, decAudio, planner, false);
|
|
const muxed = planner.finish();
|
|
const vFile = await (await dir.getFileHandle(decVideo)).getFile();
|
|
const aFile = decAudio ? await (await dir.getFileHandle(decAudio)).getFile() : null;
|
|
report(99);
|
|
const out = await writeMuxedFile(dir, finalName, muxed, vFile, aFile);
|
|
report(100);
|
|
say(`muxed final: ${out.size}B`);
|
|
await removeHolds(dir, [decVideo, ...(decAudio ? [decAudio] : [])]);
|
|
let capB64 = null;
|
|
if (!drmCapture.sent && drmCapture.frags.length) {
|
|
drmCapture.headers.mux = drmCapture.mux ? drmCapture.mux.header : null;
|
|
drmCapture.layout = drmCapture.mux ? drmCapture.mux.layout : null;
|
|
capB64 = btoa(JSON.stringify(drmCapture));
|
|
drmCapture.sent = true;
|
|
}
|
|
if (capB64) globalThis.__ofsaverCapB64 = capB64;
|
|
sendResponse({ ok: true, blobUrl: out.blobUrl, size: out.size, files: [finalName], capB64 });
|
|
} catch (e) {
|
|
if (dir) await removeHolds(dir, [decVideo, decAudio, finalName].filter(Boolean));
|
|
sendResponse({ ok: false, error: String(e.message ?? e), log });
|
|
}
|
|
})();
|
|
return true;
|
|
}
|
|
if (msg.op === "fetchPostMedia") {
|
|
// signed GET of a post's full media list (bundle backfill)
|
|
(async () => {
|
|
try {
|
|
const { postId, creatorId, username } = msg;
|
|
let id = creatorId ?? null;
|
|
if (!id && username) {
|
|
const uPath = `/api2/v2/users/${encodeURIComponent(username)}`;
|
|
let h;
|
|
try { h = await signedHeaders(uPath); } catch { h = { referer: "https://onlyfans.com/" }; }
|
|
const uRes = await fetch(`https://onlyfans.com${uPath}`, { credentials: "include", headers: h });
|
|
if (uRes.ok) id = (await uRes.json())?.id ?? null;
|
|
}
|
|
if (!id) { sendResponse({ ok: false, error: "no creator id" }); return; }
|
|
const path = `/api2/v2/post/${postId}?userId=${id}`;
|
|
let h2;
|
|
try { h2 = await signedHeaders(path); } catch { h2 = { referer: "https://onlyfans.com/" }; }
|
|
const res = await fetch(`https://onlyfans.com${path}`, { credentials: "include", headers: h2 });
|
|
if (!res.ok) { sendResponse({ ok: false, error: "post HTTP " + res.status }); return; }
|
|
sendResponse({ ok: true, data: await res.json() });
|
|
} catch (e) {
|
|
sendResponse({ ok: false, error: String(e.message ?? e) });
|
|
}
|
|
})();
|
|
return true;
|
|
}
|
|
if (msg.op === "bundle") {
|
|
setUserId(msg.userId);
|
|
runBundle(msg.who, msg.max)
|
|
.then((r) => sendResponse({ ...r, log }))
|
|
.catch((err) => sendResponse({ ok: false, error: String(err.message ?? err), log }));
|
|
return true;
|
|
}
|
|
});
|