linkedin-relay-mcp 3.23.0 → 3.24.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.
- package/.claude/skills/linkedin-relay/SKILL.md +2 -1
- package/README.md +1 -1
- package/dist/cli.js +529 -68
- package/dist/cli.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp-shim.js +18 -8
- package/dist/mcp-shim.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// src/cli.ts
|
|
3
|
-
import { readFileSync as
|
|
3
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
4
4
|
|
|
5
5
|
// src/args.ts
|
|
6
6
|
function parseArgs(argv) {
|
|
@@ -1481,10 +1481,10 @@ function classify(res, opts = {}) {
|
|
|
1481
1481
|
function referencesUrns(data) {
|
|
1482
1482
|
if (data === void 0) return false;
|
|
1483
1483
|
let found = false;
|
|
1484
|
-
const
|
|
1484
|
+
const walk2 = (node) => {
|
|
1485
1485
|
if (found || node === null || typeof node !== "object") return;
|
|
1486
1486
|
if (Array.isArray(node)) {
|
|
1487
|
-
for (const item of node)
|
|
1487
|
+
for (const item of node) walk2(item);
|
|
1488
1488
|
return;
|
|
1489
1489
|
}
|
|
1490
1490
|
for (const [key, value] of Object.entries(node)) {
|
|
@@ -1496,10 +1496,10 @@ function referencesUrns(data) {
|
|
|
1496
1496
|
found = true;
|
|
1497
1497
|
return;
|
|
1498
1498
|
}
|
|
1499
|
-
|
|
1499
|
+
walk2(value);
|
|
1500
1500
|
}
|
|
1501
1501
|
};
|
|
1502
|
-
|
|
1502
|
+
walk2(data);
|
|
1503
1503
|
return found;
|
|
1504
1504
|
}
|
|
1505
1505
|
|
|
@@ -1698,18 +1698,18 @@ function findRefs(data) {
|
|
|
1698
1698
|
}
|
|
1699
1699
|
}
|
|
1700
1700
|
const refs = [];
|
|
1701
|
-
const
|
|
1701
|
+
const walk2 = (node) => {
|
|
1702
1702
|
if (node === null || typeof node !== "object") return;
|
|
1703
1703
|
if (Array.isArray(node)) {
|
|
1704
|
-
for (const item of node)
|
|
1704
|
+
for (const item of node) walk2(item);
|
|
1705
1705
|
return;
|
|
1706
1706
|
}
|
|
1707
1707
|
for (const [key, value] of Object.entries(node)) {
|
|
1708
1708
|
if (key.startsWith("*") && typeof value === "string") refs.push(value);
|
|
1709
|
-
else
|
|
1709
|
+
else walk2(value);
|
|
1710
1710
|
}
|
|
1711
1711
|
};
|
|
1712
|
-
|
|
1712
|
+
walk2(data);
|
|
1713
1713
|
return refs;
|
|
1714
1714
|
}
|
|
1715
1715
|
function parseSingle(payload) {
|
|
@@ -1754,9 +1754,9 @@ function parseCollection(payload, opts) {
|
|
|
1754
1754
|
`LinkedIn claims ${opts.claimedCount} items but returned none \u2014 treat this as a FAILED FETCH, not an empty result.`
|
|
1755
1755
|
);
|
|
1756
1756
|
}
|
|
1757
|
-
const
|
|
1757
|
+
const state2 = unresolved.length > 0 ? "partial" : opts.truncated === true ? "unknown" : "complete";
|
|
1758
1758
|
const meta = {
|
|
1759
|
-
state,
|
|
1759
|
+
state: state2,
|
|
1760
1760
|
operation: opts.operation,
|
|
1761
1761
|
contractCapturedAt: opts.contractCapturedAt ?? "unknown",
|
|
1762
1762
|
// parsedCount counts what we kept; `items` includes the unknowns, which is
|
|
@@ -2045,7 +2045,7 @@ async function mintSessionFromBrowser() {
|
|
|
2045
2045
|
};
|
|
2046
2046
|
}
|
|
2047
2047
|
function getAllCookies(wsUrl) {
|
|
2048
|
-
return new Promise((
|
|
2048
|
+
return new Promise((resolve2, reject) => {
|
|
2049
2049
|
const ws = new WebSocket(wsUrl);
|
|
2050
2050
|
const timer = setTimeout(() => {
|
|
2051
2051
|
ws.close();
|
|
@@ -2057,7 +2057,7 @@ function getAllCookies(wsUrl) {
|
|
|
2057
2057
|
if (msg.id === 1 && msg.result !== void 0) {
|
|
2058
2058
|
clearTimeout(timer);
|
|
2059
2059
|
ws.close();
|
|
2060
|
-
|
|
2060
|
+
resolve2(msg.result.cookies);
|
|
2061
2061
|
}
|
|
2062
2062
|
};
|
|
2063
2063
|
ws.onerror = () => {
|
|
@@ -2296,14 +2296,14 @@ function evaluate(expression, model) {
|
|
|
2296
2296
|
const value = bool2(expression, model);
|
|
2297
2297
|
return value === null ? unknownExpression(JSON.stringify(expression).slice(0, 80)) : { ok: true, value };
|
|
2298
2298
|
}
|
|
2299
|
-
function wireStates(keys, model,
|
|
2299
|
+
function wireStates(keys, model, resolve2) {
|
|
2300
2300
|
const out = [];
|
|
2301
2301
|
for (const id of keys) {
|
|
2302
|
-
const
|
|
2303
|
-
if (
|
|
2304
|
-
let value =
|
|
2305
|
-
if (
|
|
2306
|
-
const r =
|
|
2302
|
+
const state2 = model.get(id);
|
|
2303
|
+
if (state2 === void 0) continue;
|
|
2304
|
+
let value = state2.value;
|
|
2305
|
+
if (state2.protoCase === "expression") {
|
|
2306
|
+
const r = resolve2(id, state2) ?? evaluate(state2.value, model);
|
|
2307
2307
|
if (!r.ok) return r;
|
|
2308
2308
|
value = r.value;
|
|
2309
2309
|
}
|
|
@@ -2311,7 +2311,7 @@ function wireStates(keys, model, resolve) {
|
|
|
2311
2311
|
key: id,
|
|
2312
2312
|
namespace: "MemoryNamespace",
|
|
2313
2313
|
value,
|
|
2314
|
-
originalProtoCase:
|
|
2314
|
+
originalProtoCase: state2.protoCase,
|
|
2315
2315
|
protoKey: { $type: "proto.sdui.Key", value: { $case: "id", id } }
|
|
2316
2316
|
});
|
|
2317
2317
|
}
|
|
@@ -2489,7 +2489,7 @@ function firstIn(rows, ids, find) {
|
|
|
2489
2489
|
}
|
|
2490
2490
|
function authorOf(rows, actor) {
|
|
2491
2491
|
if (actor === void 0) return { fields: {}, used: [] };
|
|
2492
|
-
const
|
|
2492
|
+
const state2 = (key) => (row) => {
|
|
2493
2493
|
const m = row.match(new RegExp(`"${key}"[^]*?"stringValue":"((?:[^"\\\\]|\\\\.)*)"`));
|
|
2494
2494
|
return m?.[1] === void 0 ? void 0 : jsonString(m[1]);
|
|
2495
2495
|
};
|
|
@@ -2500,8 +2500,8 @@ function authorOf(rows, actor) {
|
|
|
2500
2500
|
/"(?:https:\/\/www\.linkedin\.com)?(\/(?:in|company|school|showcase)\/[^"?/]+)/
|
|
2501
2501
|
)?.[1]
|
|
2502
2502
|
);
|
|
2503
|
-
const person = firstIn(rows, actor.under,
|
|
2504
|
-
const headline = firstIn(rows, actor.under,
|
|
2503
|
+
const person = firstIn(rows, actor.under, state2("profile_name_loading_state"));
|
|
2504
|
+
const headline = firstIn(rows, actor.under, state2("profile_headline_loading_state"));
|
|
2505
2505
|
const page = person !== void 0 ? void 0 : firstIn(rows, actor.under, (row) => {
|
|
2506
2506
|
const labels = [...row.matchAll(/"aria-label":"((?:[^"\\]|\\.)+)"/g)].map(
|
|
2507
2507
|
(m) => jsonString(m[1]).trim()
|
|
@@ -4105,8 +4105,8 @@ async function fetchScheduled(client, pageSize = PAGE_SIZE2) {
|
|
|
4105
4105
|
}
|
|
4106
4106
|
if (posts.length >= claimedCount || fresh.length === 0) break;
|
|
4107
4107
|
}
|
|
4108
|
-
const
|
|
4109
|
-
return { ok: true, posts, claimedCount, state };
|
|
4108
|
+
const state2 = posts.length >= claimedCount ? "complete" : "partial";
|
|
4109
|
+
return { ok: true, posts, claimedCount, state: state2 };
|
|
4110
4110
|
}
|
|
4111
4111
|
|
|
4112
4112
|
// src/engine/voyager-write.ts
|
|
@@ -6401,12 +6401,12 @@ var USERINFO = "https://api.linkedin.com/v2/userinfo";
|
|
|
6401
6401
|
var CALLBACK_PORT = 53682;
|
|
6402
6402
|
var REDIRECT_URI = `http://localhost:${CALLBACK_PORT}/callback`;
|
|
6403
6403
|
var SCOPES = ["openid", "profile", "w_member_social"];
|
|
6404
|
-
function authorizationUrl(clientId,
|
|
6404
|
+
function authorizationUrl(clientId, state2) {
|
|
6405
6405
|
const params = new URLSearchParams({
|
|
6406
6406
|
response_type: "code",
|
|
6407
6407
|
client_id: clientId,
|
|
6408
6408
|
redirect_uri: REDIRECT_URI,
|
|
6409
|
-
state,
|
|
6409
|
+
state: state2,
|
|
6410
6410
|
scope: SCOPES.join(" ")
|
|
6411
6411
|
});
|
|
6412
6412
|
return `${AUTHORIZE}?${params.toString()}`;
|
|
@@ -6483,8 +6483,8 @@ function parseCallback(rawUrl, expectedState) {
|
|
|
6483
6483
|
const description = url.searchParams.get("error_description") ?? "";
|
|
6484
6484
|
return { ok: false, message: `LinkedIn denied the request: ${error} ${description}`.trim() };
|
|
6485
6485
|
}
|
|
6486
|
-
const
|
|
6487
|
-
if (
|
|
6486
|
+
const state2 = url.searchParams.get("state");
|
|
6487
|
+
if (state2 !== expectedState) {
|
|
6488
6488
|
return { ok: false, message: "state mismatch \u2014 this callback did not come from this login" };
|
|
6489
6489
|
}
|
|
6490
6490
|
const code = url.searchParams.get("code");
|
|
@@ -6529,7 +6529,7 @@ var CALLBACK_TIMEOUT_MS = 3e5;
|
|
|
6529
6529
|
var DONE_PAGE = `<!doctype html><meta charset="utf-8"><title>lnrelay</title>
|
|
6530
6530
|
<body style="font:16px system-ui;padding:3rem;max-width:32rem">
|
|
6531
6531
|
<h1>Authorised.</h1><p>You can close this tab and go back to the terminal.</p>`;
|
|
6532
|
-
function listenForCallback(
|
|
6532
|
+
function listenForCallback(state2, timeoutMs = CALLBACK_TIMEOUT_MS) {
|
|
6533
6533
|
return new Promise((ready) => {
|
|
6534
6534
|
let settle = () => {
|
|
6535
6535
|
};
|
|
@@ -6545,7 +6545,7 @@ function listenForCallback(state, timeoutMs = CALLBACK_TIMEOUT_MS) {
|
|
|
6545
6545
|
}
|
|
6546
6546
|
res.writeHead(200, { "content-type": "text/html; charset=utf-8", connection: "close" });
|
|
6547
6547
|
res.end(DONE_PAGE);
|
|
6548
|
-
settle(parseCallback(url,
|
|
6548
|
+
settle(parseCallback(url, state2));
|
|
6549
6549
|
});
|
|
6550
6550
|
const timer = setTimeout(() => {
|
|
6551
6551
|
settle({
|
|
@@ -6579,7 +6579,7 @@ function openBrowser(url) {
|
|
|
6579
6579
|
function loginDeps() {
|
|
6580
6580
|
return {
|
|
6581
6581
|
state: () => crypto.randomUUID(),
|
|
6582
|
-
listen: (
|
|
6582
|
+
listen: (state2) => listenForCallback(state2),
|
|
6583
6583
|
open: openBrowser,
|
|
6584
6584
|
write: (s) => process.stderr.write(s),
|
|
6585
6585
|
isTty: process.stdin.isTTY === true && process.stderr.isTTY === true,
|
|
@@ -6617,13 +6617,13 @@ ${OAUTH_SETUP}`
|
|
|
6617
6617
|
async function runOauthLogin(opts, deps = loginDeps()) {
|
|
6618
6618
|
const creds = await credentials(opts, deps);
|
|
6619
6619
|
if ("ok" in creds) return creds;
|
|
6620
|
-
const
|
|
6621
|
-
const listener = await deps.listen(
|
|
6620
|
+
const state2 = deps.state();
|
|
6621
|
+
const listener = await deps.listen(state2);
|
|
6622
6622
|
if (!listener.ok) {
|
|
6623
6623
|
return err("oauth", "AUTH_FAILED", listener.message);
|
|
6624
6624
|
}
|
|
6625
6625
|
try {
|
|
6626
|
-
const url = authorizationUrl(creds.clientId,
|
|
6626
|
+
const url = authorizationUrl(creds.clientId, state2);
|
|
6627
6627
|
deps.write(`Opening LinkedIn for consent. If nothing opens, visit:
|
|
6628
6628
|
|
|
6629
6629
|
${url}
|
|
@@ -7471,8 +7471,8 @@ var COMMANDS = [
|
|
|
7471
7471
|
{
|
|
7472
7472
|
name: "edit",
|
|
7473
7473
|
cost: "1 read + 1 write",
|
|
7474
|
-
summary: "Change the text of a comment or post you wrote, or your profile
|
|
7475
|
-
usage: 'lnrelay edit <comment-urn | share-urn | ugcPost-urn> "<text>"\n lnrelay edit headline|about ("<text>" | --file <path>)\n A post is edited by the urn it was created as (`share` prints it; `my-posts` lists\n it as shareUrn), not its activity urn. The whole text is replaced. A profile edit\n shows the current text beside the new one, sends every other profile field back as\n LinkedIn holds it, and reads the profile back to confirm. Headline max 220 characters.',
|
|
7474
|
+
summary: "Change the text of a comment or post you wrote, your profile headline or About, or your profile photo or cover image. Its own verb, so a comment urn can never be mistaken for something to comment ON.",
|
|
7475
|
+
usage: 'lnrelay edit <comment-urn | share-urn | ugcPost-urn> "<text>"\n lnrelay edit headline|about ("<text>" | --file <path>)\n lnrelay edit photo|banner <image.png|jpg> (photo square, banner 4:1, max 8 MB)\n A post is edited by the urn it was created as (`share` prints it; `my-posts` lists\n it as shareUrn), not its activity urn. The whole text is replaced. A profile edit\n shows the current text beside the new one, sends every other profile field back as\n LinkedIn holds it, and reads the profile back to confirm. Headline max 220 characters.\n An image is uploaded as it is, uncropped, and read back: it must be the one showing.',
|
|
7476
7476
|
audience: ["cli"],
|
|
7477
7477
|
risk: "write",
|
|
7478
7478
|
implemented: true
|
|
@@ -7839,8 +7839,8 @@ async function sendPositionDelete(form, client) {
|
|
|
7839
7839
|
}
|
|
7840
7840
|
|
|
7841
7841
|
// src/commands/write.ts
|
|
7842
|
-
import { readFileSync as
|
|
7843
|
-
import { basename } from "path";
|
|
7842
|
+
import { readFileSync as readFileSync4, statSync as statSync2 } from "fs";
|
|
7843
|
+
import { basename as basename2 } from "path";
|
|
7844
7844
|
|
|
7845
7845
|
// src/engine/oauth-write.ts
|
|
7846
7846
|
var API = "https://api.linkedin.com";
|
|
@@ -7975,7 +7975,7 @@ function states(text6, body) {
|
|
|
7975
7975
|
function commentBody(activityId, text6, tokens, feedType) {
|
|
7976
7976
|
const body = keyBody(tokens.bindingKey);
|
|
7977
7977
|
const activityUrn = { activityUrn: { activityId } };
|
|
7978
|
-
const
|
|
7978
|
+
const binding2 = (prefix) => ({
|
|
7979
7979
|
key: stateKey(prefix, body),
|
|
7980
7980
|
namespace: "MemoryNamespace"
|
|
7981
7981
|
});
|
|
@@ -7995,11 +7995,11 @@ function commentBody(activityId, text6, tokens, feedType) {
|
|
|
7995
7995
|
},
|
|
7996
7996
|
threadUrn: { threadUrnActivityThreadUrn: activityUrn }
|
|
7997
7997
|
},
|
|
7998
|
-
commentFieldBinding:
|
|
7999
|
-
richCommentFieldBinding:
|
|
8000
|
-
linkPreviewIngestedContentId:
|
|
8001
|
-
externalImageUrl:
|
|
8002
|
-
externalImageId:
|
|
7998
|
+
commentFieldBinding: binding2("commentBoxText"),
|
|
7999
|
+
richCommentFieldBinding: binding2("richCommentBoxText"),
|
|
8000
|
+
linkPreviewIngestedContentId: binding2("commentBoxLinkPreviewIngestedContentId"),
|
|
8001
|
+
externalImageUrl: binding2("commentBoxExternalImageUrl"),
|
|
8002
|
+
externalImageId: binding2("commentBoxExternalImageId")
|
|
8003
8003
|
};
|
|
8004
8004
|
const requestedStateKeys = STATE_PREFIXES.map((p) => ({
|
|
8005
8005
|
key: { value: { $case: "id", id: stateKey(p, body) } }
|
|
@@ -8206,6 +8206,463 @@ async function replyToComment(confirmed, client) {
|
|
|
8206
8206
|
return { ok: true, parent: parentThreadUrn(ref) };
|
|
8207
8207
|
}
|
|
8208
8208
|
|
|
8209
|
+
// src/commands/profile-image.ts
|
|
8210
|
+
import { readFileSync as readFileSync3, statSync } from "fs";
|
|
8211
|
+
import { basename, resolve } from "path";
|
|
8212
|
+
|
|
8213
|
+
// src/engine/sdui-profile-image.ts
|
|
8214
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
8215
|
+
var IMAGE_KINDS = {
|
|
8216
|
+
photo: {
|
|
8217
|
+
name: "photo",
|
|
8218
|
+
label: "profile photo",
|
|
8219
|
+
screen: "com.linkedin.sdui.flagshipnav.profile.ProfileAddPicture",
|
|
8220
|
+
originalType: "ProfileOriginalPhoto",
|
|
8221
|
+
displayType: "ProfileDisplayPhoto",
|
|
8222
|
+
save: "com.linkedin.sdui.requests.profile.saveProfilePicture",
|
|
8223
|
+
aspect: 1
|
|
8224
|
+
},
|
|
8225
|
+
banner: {
|
|
8226
|
+
name: "banner",
|
|
8227
|
+
label: "cover image",
|
|
8228
|
+
screen: "com.linkedin.sdui.flagshipnav.profile.ProfileAddBackgroundImage",
|
|
8229
|
+
originalType: "ProfileOriginalBackground",
|
|
8230
|
+
displayType: "ProfileDisplayBackground",
|
|
8231
|
+
save: "com.linkedin.sdui.requests.profile.saveProfileBackgroundImage",
|
|
8232
|
+
aspect: 4
|
|
8233
|
+
}
|
|
8234
|
+
};
|
|
8235
|
+
var REGISTER = "com.linkedin.sdui.requests.profile.profileImageRegister";
|
|
8236
|
+
var REGISTER_REQUEST = REGISTER;
|
|
8237
|
+
var NS = "MemoryNamespace";
|
|
8238
|
+
var PHOTO_SAVING = "ADD_PHOTOPROFILE_PHOTO_UPLOAD_IS_SAVING";
|
|
8239
|
+
var binding = () => `auto-binding-${randomUUID2()}`;
|
|
8240
|
+
var pointer = () => Math.random().toString(36).slice(2, 13).padEnd(11, "0");
|
|
8241
|
+
function newKeys(kind) {
|
|
8242
|
+
return {
|
|
8243
|
+
originalMedia: binding(),
|
|
8244
|
+
originalAssetUrns: binding(),
|
|
8245
|
+
displayMedia: binding(),
|
|
8246
|
+
displayAssetUrns: binding(),
|
|
8247
|
+
saving: kind.name === "photo" ? PHOTO_SAVING : binding(),
|
|
8248
|
+
originalPointer: pointer(),
|
|
8249
|
+
displayPointer: pointer()
|
|
8250
|
+
};
|
|
8251
|
+
}
|
|
8252
|
+
var focusKey = (vanity) => `ProfileComponentStateLastPerformedActionRef${vanity}ProfileComponentState`;
|
|
8253
|
+
var bind = (key) => ({ key, namespace: NS });
|
|
8254
|
+
var stateKey2 = (id) => ({ key: { value: { $case: "id", id } } });
|
|
8255
|
+
var META = { $type: "proto.sdui.common.RequestMetadata" };
|
|
8256
|
+
var WHOLE_IMAGE = {
|
|
8257
|
+
$type: "proto.sdui.media.MediaEditData",
|
|
8258
|
+
croppedRegion: {
|
|
8259
|
+
$type: "proto.sdui.common.Rect",
|
|
8260
|
+
topLeft: { $type: "proto.sdui.common.Coordinate2D", x: 0, y: 0 },
|
|
8261
|
+
topRight: { $type: "proto.sdui.common.Coordinate2D", x: 1, y: 0 },
|
|
8262
|
+
bottomLeft: { $type: "proto.sdui.common.Coordinate2D", x: 0, y: 1 },
|
|
8263
|
+
bottomRight: { $type: "proto.sdui.common.Coordinate2D", x: 1, y: 1 }
|
|
8264
|
+
},
|
|
8265
|
+
scaleRatio: 1,
|
|
8266
|
+
brightness: 0,
|
|
8267
|
+
contrast: 0,
|
|
8268
|
+
saturation: 0,
|
|
8269
|
+
vignette: 0,
|
|
8270
|
+
imageFilter: "ImageFilter_None"
|
|
8271
|
+
};
|
|
8272
|
+
function mediaList(file, name, ptr, edited) {
|
|
8273
|
+
const size = String(file.size);
|
|
8274
|
+
return {
|
|
8275
|
+
$type: "proto.sdui.media.MediaList",
|
|
8276
|
+
mediaFiles: [
|
|
8277
|
+
{
|
|
8278
|
+
mediaAttributions: [],
|
|
8279
|
+
analysisData: {},
|
|
8280
|
+
fileName: name,
|
|
8281
|
+
source: {
|
|
8282
|
+
$case: "localFile",
|
|
8283
|
+
localFile: {
|
|
8284
|
+
fileName: name,
|
|
8285
|
+
mimeType: file.mimeType,
|
|
8286
|
+
filePointer: ptr,
|
|
8287
|
+
size,
|
|
8288
|
+
shouldIncludeFileContents: false
|
|
8289
|
+
}
|
|
8290
|
+
},
|
|
8291
|
+
size,
|
|
8292
|
+
mimeType: file.mimeType,
|
|
8293
|
+
filePointer: ptr,
|
|
8294
|
+
mediaFileId: ptr,
|
|
8295
|
+
...edited ? { editData: WHOLE_IMAGE } : {},
|
|
8296
|
+
captions: [],
|
|
8297
|
+
thumbnails: []
|
|
8298
|
+
}
|
|
8299
|
+
]
|
|
8300
|
+
};
|
|
8301
|
+
}
|
|
8302
|
+
var CASES = {
|
|
8303
|
+
object: "mediaListValue",
|
|
8304
|
+
array: "stringListValue",
|
|
8305
|
+
string: "stringValue",
|
|
8306
|
+
boolean: "booleanValue"
|
|
8307
|
+
};
|
|
8308
|
+
function state(key, value) {
|
|
8309
|
+
const kind = Array.isArray(value) ? "array" : typeof value;
|
|
8310
|
+
return {
|
|
8311
|
+
key,
|
|
8312
|
+
namespace: NS,
|
|
8313
|
+
value,
|
|
8314
|
+
originalProtoCase: CASES[kind],
|
|
8315
|
+
protoKey: { $type: "proto.sdui.Key", value: { $case: "id", id: key } }
|
|
8316
|
+
};
|
|
8317
|
+
}
|
|
8318
|
+
function serverRequest(requestId, payload, states2, screenId) {
|
|
8319
|
+
const requestedStateKeys = states2.map((s) => stateKey2(s.key));
|
|
8320
|
+
const requestedArguments = {
|
|
8321
|
+
$type: "proto.sdui.actions.requests.RequestedArguments",
|
|
8322
|
+
requestedStateKeys,
|
|
8323
|
+
payload,
|
|
8324
|
+
requestMetadata: META
|
|
8325
|
+
};
|
|
8326
|
+
return {
|
|
8327
|
+
requestId,
|
|
8328
|
+
serverRequest: {
|
|
8329
|
+
requestId,
|
|
8330
|
+
requestedArguments,
|
|
8331
|
+
isApfcEnabled: false,
|
|
8332
|
+
isStreaming: false,
|
|
8333
|
+
rumPageKey: ""
|
|
8334
|
+
},
|
|
8335
|
+
states: states2,
|
|
8336
|
+
requestedArguments: { ...requestedArguments, states: states2, screenId, knownTemplateIds: [] }
|
|
8337
|
+
};
|
|
8338
|
+
}
|
|
8339
|
+
var displayNameOf = (req) => req.displayName ?? `edited-image-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.${req.file.name.split(".").pop()}`;
|
|
8340
|
+
function savePlan(kind, req) {
|
|
8341
|
+
const k = req.keys;
|
|
8342
|
+
const focus = focusKey(req.vanity);
|
|
8343
|
+
if (kind.name === "photo") {
|
|
8344
|
+
return {
|
|
8345
|
+
payload: {
|
|
8346
|
+
profileId: req.profileId,
|
|
8347
|
+
vanityName: req.vanity,
|
|
8348
|
+
newMedia: bind(k.displayMedia),
|
|
8349
|
+
originalAssetUrns: bind(k.originalAssetUrns),
|
|
8350
|
+
displayAssetUrns: bind(k.displayAssetUrns),
|
|
8351
|
+
isSavingProfilePhoto: bind(k.saving),
|
|
8352
|
+
focusableComponentRefKey: bind(focus)
|
|
8353
|
+
},
|
|
8354
|
+
keys: [k.displayMedia, k.originalAssetUrns, k.displayAssetUrns, k.saving, focus],
|
|
8355
|
+
focusValue: "topcard-logo-image-referencekey"
|
|
8356
|
+
};
|
|
8357
|
+
}
|
|
8358
|
+
return {
|
|
8359
|
+
payload: {
|
|
8360
|
+
vanityName: req.vanity,
|
|
8361
|
+
profileId: req.profileId,
|
|
8362
|
+
editedMedia: bind(k.displayMedia),
|
|
8363
|
+
displayAssetUrns: bind(k.displayAssetUrns),
|
|
8364
|
+
originalAssetUrns: bind(k.originalAssetUrns),
|
|
8365
|
+
focusableComponentRefKey: bind(focus),
|
|
8366
|
+
isSaving: bind(k.saving),
|
|
8367
|
+
omitDefaultPhotoFilterEditInfo: true
|
|
8368
|
+
},
|
|
8369
|
+
keys: [k.displayMedia, k.displayAssetUrns, k.originalAssetUrns, focus],
|
|
8370
|
+
focusValue: `${req.vanity}_cover_edit_button`
|
|
8371
|
+
};
|
|
8372
|
+
}
|
|
8373
|
+
function registerBody(kind, req) {
|
|
8374
|
+
const k = req.keys;
|
|
8375
|
+
const save = savePlan(kind, req);
|
|
8376
|
+
const payload = {
|
|
8377
|
+
profileId: req.profileId,
|
|
8378
|
+
originalMedia: bind(k.originalMedia),
|
|
8379
|
+
originalAssetUrns: bind(k.originalAssetUrns),
|
|
8380
|
+
originalMediaType: kind.originalType,
|
|
8381
|
+
displayMedia: bind(k.displayMedia),
|
|
8382
|
+
displayMediaType: kind.displayType,
|
|
8383
|
+
displayAssetUrns: bind(k.displayAssetUrns),
|
|
8384
|
+
uploadOriginal: true,
|
|
8385
|
+
followUpRequest: { key: kind.save, data: save.payload, stateKeys: save.keys.map(bind) },
|
|
8386
|
+
skipEdit: false,
|
|
8387
|
+
isSaving: bind(k.saving)
|
|
8388
|
+
};
|
|
8389
|
+
return serverRequest(
|
|
8390
|
+
REGISTER,
|
|
8391
|
+
payload,
|
|
8392
|
+
[
|
|
8393
|
+
state(k.originalMedia, mediaList(req.file, req.file.name, k.originalPointer, false)),
|
|
8394
|
+
state(k.originalAssetUrns, []),
|
|
8395
|
+
state(k.displayMedia, mediaList(req.file, displayNameOf(req), k.displayPointer, true)),
|
|
8396
|
+
state(k.displayAssetUrns, []),
|
|
8397
|
+
state(k.saving, true)
|
|
8398
|
+
],
|
|
8399
|
+
kind.screen
|
|
8400
|
+
);
|
|
8401
|
+
}
|
|
8402
|
+
function saveBody2(kind, req) {
|
|
8403
|
+
const k = req.keys;
|
|
8404
|
+
const save = savePlan(kind, req);
|
|
8405
|
+
const values = {
|
|
8406
|
+
[k.displayMedia]: mediaList(req.file, displayNameOf(req), k.displayPointer, true),
|
|
8407
|
+
[k.originalAssetUrns]: [req.originalId],
|
|
8408
|
+
[k.displayAssetUrns]: [req.displayId],
|
|
8409
|
+
[k.saving]: true,
|
|
8410
|
+
[focusKey(req.vanity)]: save.focusValue
|
|
8411
|
+
};
|
|
8412
|
+
return serverRequest(
|
|
8413
|
+
kind.save,
|
|
8414
|
+
save.payload,
|
|
8415
|
+
save.keys.map((key) => state(key, values[key])),
|
|
8416
|
+
kind.screen
|
|
8417
|
+
);
|
|
8418
|
+
}
|
|
8419
|
+
function* walk(v) {
|
|
8420
|
+
if (Array.isArray(v)) for (const x of v) yield* walk(x);
|
|
8421
|
+
else if (v !== null && typeof v === "object") {
|
|
8422
|
+
yield v;
|
|
8423
|
+
for (const x of Object.values(v)) yield* walk(x);
|
|
8424
|
+
}
|
|
8425
|
+
}
|
|
8426
|
+
var headerName = (key) => key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
|
8427
|
+
function assetIdOf(n) {
|
|
8428
|
+
if (n.$type !== "proto.sdui.actions.core.SetState") return void 0;
|
|
8429
|
+
const s = n.value?.state;
|
|
8430
|
+
const id = s?.key?.key?.value;
|
|
8431
|
+
const list2 = s?.value?.stringListValue?.stringValues;
|
|
8432
|
+
return typeof id?.id === "string" && typeof list2?.[0] === "string" ? [id.id, list2[0]] : void 0;
|
|
8433
|
+
}
|
|
8434
|
+
function uploadOf(n) {
|
|
8435
|
+
if (typeof n.fileReference !== "string") return void 0;
|
|
8436
|
+
const instruction = n.uploadInstruction?.instruction;
|
|
8437
|
+
const single = instruction?.singleRequestUploadInstruction;
|
|
8438
|
+
if (typeof single?.uploadUrl !== "string") return [n.fileReference, "multipart"];
|
|
8439
|
+
const headers2 = {};
|
|
8440
|
+
for (const h of single.uploadHeaders ?? [])
|
|
8441
|
+
if (typeof h.key === "string" && typeof h.value === "string")
|
|
8442
|
+
headers2[headerName(h.key)] = h.value;
|
|
8443
|
+
return [n.fileReference, { url: single.uploadUrl, headers: headers2 }];
|
|
8444
|
+
}
|
|
8445
|
+
function rowZero(raw) {
|
|
8446
|
+
const row = raw.match(/(?:^|\n)0:(\{.*)/)?.[1];
|
|
8447
|
+
try {
|
|
8448
|
+
return row === void 0 ? void 0 : JSON.parse(row);
|
|
8449
|
+
} catch {
|
|
8450
|
+
return void 0;
|
|
8451
|
+
}
|
|
8452
|
+
}
|
|
8453
|
+
function parseRegister(raw, keys) {
|
|
8454
|
+
const refused = responseErrors(raw);
|
|
8455
|
+
if (refused !== null)
|
|
8456
|
+
return { ok: false, code: "INVALID_INPUT", message: `LinkedIn refused the image: ${refused}` };
|
|
8457
|
+
const ids = /* @__PURE__ */ new Map();
|
|
8458
|
+
const uploads = /* @__PURE__ */ new Map();
|
|
8459
|
+
for (const n of walk(rowZero(raw))) {
|
|
8460
|
+
const id = assetIdOf(n);
|
|
8461
|
+
if (id !== void 0) ids.set(...id);
|
|
8462
|
+
const up = uploadOf(n);
|
|
8463
|
+
if (up !== void 0) uploads.set(...up);
|
|
8464
|
+
}
|
|
8465
|
+
const originalId = ids.get(keys.originalAssetUrns);
|
|
8466
|
+
const displayId = ids.get(keys.displayAssetUrns);
|
|
8467
|
+
const original = uploads.get(keys.originalPointer);
|
|
8468
|
+
const display = uploads.get(keys.displayPointer);
|
|
8469
|
+
if (original === "multipart" || display === "multipart")
|
|
8470
|
+
return {
|
|
8471
|
+
ok: false,
|
|
8472
|
+
code: "NOT_IMPLEMENTED",
|
|
8473
|
+
message: "LinkedIn asked for a multi-part upload, which has not been observed here. Nothing was uploaded. Try a smaller file."
|
|
8474
|
+
};
|
|
8475
|
+
if (originalId === void 0 || displayId === void 0 || !original || !display)
|
|
8476
|
+
return {
|
|
8477
|
+
ok: false,
|
|
8478
|
+
code: "SCHEMA_DRIFT",
|
|
8479
|
+
message: "the image registration carried no asset ids or upload urls; nothing was uploaded"
|
|
8480
|
+
};
|
|
8481
|
+
return { ok: true, originalId, displayId, uploads: { original, display } };
|
|
8482
|
+
}
|
|
8483
|
+
function imageSizeOf(bytes) {
|
|
8484
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
8485
|
+
const png = [137, 80, 78, 71, 13, 10, 26, 10];
|
|
8486
|
+
if (bytes.length >= 24 && png.every((b, i) => bytes[i] === b))
|
|
8487
|
+
return { width: view.getUint32(16), height: view.getUint32(20), mimeType: "image/png" };
|
|
8488
|
+
if (bytes[0] !== 255 || bytes[1] !== 216) return null;
|
|
8489
|
+
let at = 2;
|
|
8490
|
+
while (at + 9 <= bytes.length) {
|
|
8491
|
+
if (bytes[at] !== 255) return null;
|
|
8492
|
+
const marker = bytes[at + 1];
|
|
8493
|
+
if (marker >= 192 && marker <= 207 && ![196, 200, 204].includes(marker))
|
|
8494
|
+
return {
|
|
8495
|
+
height: view.getUint16(at + 5),
|
|
8496
|
+
width: view.getUint16(at + 7),
|
|
8497
|
+
mimeType: "image/jpeg"
|
|
8498
|
+
};
|
|
8499
|
+
at += 2 + view.getUint16(at + 2);
|
|
8500
|
+
}
|
|
8501
|
+
return null;
|
|
8502
|
+
}
|
|
8503
|
+
function picturesOf(json) {
|
|
8504
|
+
const root = json;
|
|
8505
|
+
const urn = root?.data?.["*elements"]?.[0];
|
|
8506
|
+
const p = (root?.included ?? []).find((n) => n.entityUrn === urn);
|
|
8507
|
+
const profileId2 = typeof urn === "string" ? urn.split(":").pop() : void 0;
|
|
8508
|
+
if (p === void 0 || profileId2 === void 0)
|
|
8509
|
+
return { ok: false, code: "SCHEMA_DRIFT", message: "the profile answer carried no profile" };
|
|
8510
|
+
const asset = (pic) => String(pic?.displayImageUrn ?? "").match(/digitalmediaAsset:(.+)$/)?.[1];
|
|
8511
|
+
const photo = asset(p.profilePicture);
|
|
8512
|
+
const banner = asset(p.backgroundPicture);
|
|
8513
|
+
return {
|
|
8514
|
+
ok: true,
|
|
8515
|
+
profileId: profileId2,
|
|
8516
|
+
...photo !== void 0 ? { photo } : {},
|
|
8517
|
+
...banner !== void 0 ? { banner } : {}
|
|
8518
|
+
};
|
|
8519
|
+
}
|
|
8520
|
+
|
|
8521
|
+
// src/commands/profile-image.ts
|
|
8522
|
+
function liveImages(session) {
|
|
8523
|
+
const client = createLiveClient(session);
|
|
8524
|
+
return {
|
|
8525
|
+
vanity: async () => {
|
|
8526
|
+
const me = await createEngine(session).whoami();
|
|
8527
|
+
if (!me.ok) return me;
|
|
8528
|
+
const id = me.value?.publicIdentifier;
|
|
8529
|
+
return typeof id === "string" && id !== "" ? { ok: true, vanity: id } : { ok: false, code: "SCHEMA_DRIFT", message: "whoami returned no public profile id" };
|
|
8530
|
+
},
|
|
8531
|
+
pictures: async (vanity) => {
|
|
8532
|
+
const r = await client.request({
|
|
8533
|
+
url: fullProfileUrl(vanity),
|
|
8534
|
+
spendClass: "profile",
|
|
8535
|
+
operation: "profile-pictures"
|
|
8536
|
+
});
|
|
8537
|
+
return r.ok ? picturesOf(r.json) : r;
|
|
8538
|
+
},
|
|
8539
|
+
register: async (body) => {
|
|
8540
|
+
const raw = await sendAction(REGISTER_REQUEST, body, client, "image-register");
|
|
8541
|
+
return typeof raw === "string" ? { ok: true, raw } : raw;
|
|
8542
|
+
},
|
|
8543
|
+
put: async (upload, bytes, mimeType) => {
|
|
8544
|
+
const r = await client.request({
|
|
8545
|
+
url: upload.url,
|
|
8546
|
+
method: "PUT",
|
|
8547
|
+
bytes,
|
|
8548
|
+
headers: { "content-type": mimeType, ...upload.headers },
|
|
8549
|
+
spendClass: "write",
|
|
8550
|
+
operation: "image-upload"
|
|
8551
|
+
});
|
|
8552
|
+
return r.ok ? { ok: true } : r;
|
|
8553
|
+
},
|
|
8554
|
+
save: async (kind, body) => {
|
|
8555
|
+
const raw = await sendAction(kind.save, body, client, `${kind.name}-save`);
|
|
8556
|
+
return typeof raw === "string" ? { ok: true } : raw;
|
|
8557
|
+
}
|
|
8558
|
+
};
|
|
8559
|
+
}
|
|
8560
|
+
var MAX_BYTES = 8 * 1024 * 1024;
|
|
8561
|
+
function pick(kind, path) {
|
|
8562
|
+
let bytes;
|
|
8563
|
+
try {
|
|
8564
|
+
if (!statSync(path).isFile()) throw new Error("not a file");
|
|
8565
|
+
bytes = new Uint8Array(readFileSync3(path));
|
|
8566
|
+
} catch {
|
|
8567
|
+
return err("edit", "INVALID_INPUT", `cannot read ${path}`);
|
|
8568
|
+
}
|
|
8569
|
+
if (bytes.byteLength > MAX_BYTES)
|
|
8570
|
+
return err("edit", "INVALID_INPUT", `${basename(path)} is over LinkedIn's 8 MB limit`);
|
|
8571
|
+
const size = imageSizeOf(bytes);
|
|
8572
|
+
if (size === null)
|
|
8573
|
+
return err("edit", "INVALID_INPUT", `${basename(path)} is not a PNG or JPEG image`);
|
|
8574
|
+
const ratio = size.width / size.height;
|
|
8575
|
+
if (Math.abs(ratio / kind.aspect - 1) > 0.02) {
|
|
8576
|
+
const want = kind.name === "photo" ? "square" : "4:1 (1584 \xD7 396)";
|
|
8577
|
+
return err(
|
|
8578
|
+
"edit",
|
|
8579
|
+
"INVALID_INPUT",
|
|
8580
|
+
`${basename(path)} is ${size.width} \xD7 ${size.height}; a ${kind.label} must be ${want}`,
|
|
8581
|
+
"It is uploaded as it is, uncropped: crop it to that shape first."
|
|
8582
|
+
);
|
|
8583
|
+
}
|
|
8584
|
+
return { bytes, ...size };
|
|
8585
|
+
}
|
|
8586
|
+
function planOf(kind, file, picked, was, author) {
|
|
8587
|
+
const sha256 = mediaDigest(picked.bytes);
|
|
8588
|
+
return {
|
|
8589
|
+
action: `replace your ${kind.label}`,
|
|
8590
|
+
payload: { image: kind.name, file, sha256, was: was ?? null },
|
|
8591
|
+
summary: [
|
|
8592
|
+
author,
|
|
8593
|
+
`image ${kind.label}`,
|
|
8594
|
+
`file ${file}`,
|
|
8595
|
+
` ${picked.width} \xD7 ${picked.height}, ${picked.bytes.byteLength} bytes, sha256 ${sha256.slice(0, 16)}\u2026`,
|
|
8596
|
+
`now ${was === void 0 ? "none" : `asset ${was}`}`
|
|
8597
|
+
],
|
|
8598
|
+
reversibility: "replaceable again with any file, but the current image is not kept here: have the original file before replacing it. Everyone who can see your profile sees the change.",
|
|
8599
|
+
transport: "voyager"
|
|
8600
|
+
};
|
|
8601
|
+
}
|
|
8602
|
+
async function send2(li, kind, req, picked) {
|
|
8603
|
+
const nothing = (f, step) => err("edit", f.code, `${step} failed (${f.message}); nothing changed on your profile`, f.hint);
|
|
8604
|
+
const registered = await li.register(registerBody(kind, req));
|
|
8605
|
+
if (!registered.ok) return nothing(registered, "registering the image");
|
|
8606
|
+
const ticket = parseRegister(registered.raw, req.keys);
|
|
8607
|
+
if (!ticket.ok) return nothing(ticket, "registering the image");
|
|
8608
|
+
for (const upload of [ticket.uploads.original, ticket.uploads.display]) {
|
|
8609
|
+
const put2 = await li.put(upload, picked.bytes, picked.mimeType);
|
|
8610
|
+
if (!put2.ok) return nothing(put2, "uploading the image");
|
|
8611
|
+
}
|
|
8612
|
+
const saved = await li.save(kind, saveBody2(kind, { ...req, ...ticket }));
|
|
8613
|
+
if (!saved.ok)
|
|
8614
|
+
return err("edit", saved.code, `saving the ${kind.label} failed: ${saved.message}`);
|
|
8615
|
+
return { ok: true, displayId: ticket.displayId };
|
|
8616
|
+
}
|
|
8617
|
+
async function runEditImage(name, path, now = Date.now(), deps = terminalDeps(), surface, keys) {
|
|
8618
|
+
const kind = IMAGE_KINDS[name];
|
|
8619
|
+
if (kind === void 0)
|
|
8620
|
+
return err("edit", "INVALID_INPUT", `'${name}' is not an image this edits`, "photo, banner");
|
|
8621
|
+
if (path === void 0 || path.trim() === "")
|
|
8622
|
+
return err("edit", "INVALID_INPUT", "an image file is required", `lnrelay edit ${name} <file>`);
|
|
8623
|
+
const file = resolve(path);
|
|
8624
|
+
const picked = pick(kind, file);
|
|
8625
|
+
if ("ok" in picked) return picked;
|
|
8626
|
+
const unapprovable = refuseUnapprovable("edit", "editing", deps);
|
|
8627
|
+
if (unapprovable !== null) return unapprovable;
|
|
8628
|
+
const ctx = prepare("edit", now, "voyager", 4);
|
|
8629
|
+
if ("ok" in ctx) return ctx;
|
|
8630
|
+
if (ctx.transport.kind !== "voyager")
|
|
8631
|
+
return err("edit", "NOT_IMPLEMENTED", "profile edits go over the browser session only");
|
|
8632
|
+
const li = surface ?? liveImages(ctx.transport.session);
|
|
8633
|
+
const me = await li.vanity();
|
|
8634
|
+
if (!me.ok) return err("edit", me.code, me.message, me.hint);
|
|
8635
|
+
const before = await li.pictures(me.vanity);
|
|
8636
|
+
if (!before.ok) return err("edit", before.code, before.message, before.hint);
|
|
8637
|
+
const plan = planOf(kind, file, picked, before[kind.name], authorLine(ctx.transport));
|
|
8638
|
+
const gated = await gate("edit", plan, ctx, deps);
|
|
8639
|
+
if ("ok" in gated) return gated;
|
|
8640
|
+
const ext = picked.mimeType === "image/png" ? "png" : "jpg";
|
|
8641
|
+
const sent = await send2(
|
|
8642
|
+
li,
|
|
8643
|
+
kind,
|
|
8644
|
+
{
|
|
8645
|
+
profileId: before.profileId,
|
|
8646
|
+
vanity: me.vanity,
|
|
8647
|
+
file: { name: basename(file), mimeType: picked.mimeType, size: picked.bytes.byteLength },
|
|
8648
|
+
keys: keys ?? newKeys(kind),
|
|
8649
|
+
displayName: `edited-image-${new Date(now).toISOString().replace(/[:.]/g, "-")}.${ext}`
|
|
8650
|
+
},
|
|
8651
|
+
picked
|
|
8652
|
+
);
|
|
8653
|
+
if (!("displayId" in sent)) return sent;
|
|
8654
|
+
const after = await li.pictures(me.vanity);
|
|
8655
|
+
if (!after.ok || after[kind.name] !== sent.displayId) {
|
|
8656
|
+
return err(
|
|
8657
|
+
"edit",
|
|
8658
|
+
"SCHEMA_DRIFT",
|
|
8659
|
+
`LinkedIn accepted the save, but your ${kind.label} does not read back as the new image`,
|
|
8660
|
+
after.ok ? `It shows asset ${after[kind.name] ?? "none"}; the upload was ${sent.displayId}.` : `The read-back failed: ${after.message}`
|
|
8661
|
+
);
|
|
8662
|
+
}
|
|
8663
|
+
return ok("edit", { image: kind.name, verified: true, asset: sent.displayId });
|
|
8664
|
+
}
|
|
8665
|
+
|
|
8209
8666
|
// src/commands/transport.ts
|
|
8210
8667
|
var NO_CREDENTIAL_HINT = [
|
|
8211
8668
|
"Two ways to write, and you need one of them:",
|
|
@@ -8370,7 +8827,7 @@ function loadMedia(flag, path) {
|
|
|
8370
8827
|
return err(
|
|
8371
8828
|
"share",
|
|
8372
8829
|
"INVALID_INPUT",
|
|
8373
|
-
`unsupported file type: ${
|
|
8830
|
+
`unsupported file type: ${basename2(path)}`,
|
|
8374
8831
|
"images: png, jpg, jpeg, gif, webp. videos: mp4, mov. documents: pdf."
|
|
8375
8832
|
);
|
|
8376
8833
|
}
|
|
@@ -8378,21 +8835,21 @@ function loadMedia(flag, path) {
|
|
|
8378
8835
|
return err(
|
|
8379
8836
|
"share",
|
|
8380
8837
|
"INVALID_INPUT",
|
|
8381
|
-
`${
|
|
8838
|
+
`${basename2(path)} is not ${flag === "image" ? "an image" : `a ${flag}`}`,
|
|
8382
8839
|
`pass it with ${KIND_FLAG[kind.kind]}`
|
|
8383
8840
|
);
|
|
8384
8841
|
}
|
|
8385
8842
|
let bytes;
|
|
8386
8843
|
try {
|
|
8387
|
-
if (!
|
|
8388
|
-
bytes = new Uint8Array(
|
|
8844
|
+
if (!statSync2(path).isFile()) throw new Error("not a file");
|
|
8845
|
+
bytes = new Uint8Array(readFileSync4(path));
|
|
8389
8846
|
} catch {
|
|
8390
8847
|
return err("share", "INVALID_INPUT", `cannot read ${path}`);
|
|
8391
8848
|
}
|
|
8392
8849
|
return {
|
|
8393
8850
|
bytes,
|
|
8394
8851
|
approved: {
|
|
8395
|
-
filename:
|
|
8852
|
+
filename: basename2(path),
|
|
8396
8853
|
kind: kind.kind,
|
|
8397
8854
|
contentType: kind.contentType,
|
|
8398
8855
|
size: bytes.byteLength,
|
|
@@ -8810,6 +9267,9 @@ async function runEdit(commentUrn, text6, now = Date.now(), deps = terminalDeps(
|
|
|
8810
9267
|
'lnrelay edit <comment-urn> "<text>"'
|
|
8811
9268
|
);
|
|
8812
9269
|
}
|
|
9270
|
+
if (commentUrn === "photo" || commentUrn === "banner") {
|
|
9271
|
+
return runEditImage(commentUrn, text6, now, deps);
|
|
9272
|
+
}
|
|
8813
9273
|
const ref = parseCommentUrn(commentUrn);
|
|
8814
9274
|
if (ref === null && !commentUrn.startsWith("urn:")) {
|
|
8815
9275
|
return runEditProfile(commentUrn, text6, now, deps);
|
|
@@ -9741,24 +10201,24 @@ var SERVER_REQUEST = "https://www.linkedin.com/flagship-web/rsc-action/actions/s
|
|
|
9741
10201
|
var VIEWERS_URL = `${SERVER_REQUEST}?sduiid=WvmpEntityList`;
|
|
9742
10202
|
var VIEW_TOTALS_URL = `${SERVER_REQUEST}?sduiid=WvmpAnalytics`;
|
|
9743
10203
|
var RANGE = "WvmpSearchFilterType_DATE_RANGE";
|
|
9744
|
-
var
|
|
9745
|
-
function
|
|
9746
|
-
const
|
|
9747
|
-
key:
|
|
10204
|
+
var META2 = { $type: "proto.sdui.common.RequestMetadata" };
|
|
10205
|
+
function serverRequest2(requestId, stateKey3, payload) {
|
|
10206
|
+
const state2 = {
|
|
10207
|
+
key: stateKey3,
|
|
9748
10208
|
namespace: "MemoryNamespace",
|
|
9749
10209
|
value: [],
|
|
9750
10210
|
originalProtoCase: "stringListValue",
|
|
9751
|
-
protoKey: { $type: "proto.sdui.Key", value: { $case: "id", id:
|
|
10211
|
+
protoKey: { $type: "proto.sdui.Key", value: { $case: "id", id: stateKey3 } }
|
|
9752
10212
|
};
|
|
9753
10213
|
const requestedArguments = {
|
|
9754
10214
|
$type: "proto.sdui.actions.requests.RequestedArguments",
|
|
9755
|
-
requestedStateKeys: [{ key: { value: { $case: "id", id:
|
|
10215
|
+
requestedStateKeys: [{ key: { value: { $case: "id", id: stateKey3 } } }],
|
|
9756
10216
|
payload: {
|
|
9757
10217
|
...payload,
|
|
9758
10218
|
filterTypeList: [RANGE],
|
|
9759
|
-
dateRangeSelectionFilters: { key:
|
|
10219
|
+
dateRangeSelectionFilters: { key: stateKey3, namespace: "MemoryNamespace" }
|
|
9760
10220
|
},
|
|
9761
|
-
requestMetadata:
|
|
10221
|
+
requestMetadata: META2
|
|
9762
10222
|
};
|
|
9763
10223
|
return {
|
|
9764
10224
|
requestId,
|
|
@@ -9769,22 +10229,22 @@ function serverRequest(requestId, stateKey2, payload) {
|
|
|
9769
10229
|
isStreaming: false,
|
|
9770
10230
|
rumPageKey: ""
|
|
9771
10231
|
},
|
|
9772
|
-
states: [
|
|
10232
|
+
states: [state2],
|
|
9773
10233
|
requestedArguments: {
|
|
9774
10234
|
...requestedArguments,
|
|
9775
|
-
states: [
|
|
10235
|
+
states: [state2],
|
|
9776
10236
|
screenId: "com.linkedin.sdui.flagshipnav.home.Home",
|
|
9777
10237
|
knownTemplateIds: []
|
|
9778
10238
|
}
|
|
9779
10239
|
};
|
|
9780
10240
|
}
|
|
9781
10241
|
function viewersBody() {
|
|
9782
|
-
return
|
|
10242
|
+
return serverRequest2("WvmpEntityList", `entityListQueryFilterPrefix${RANGE}`, {
|
|
9783
10243
|
sortType: "ProfileViewSortType_TIME_DESCENDING"
|
|
9784
10244
|
});
|
|
9785
10245
|
}
|
|
9786
10246
|
function viewTotalsBody() {
|
|
9787
|
-
return
|
|
10247
|
+
return serverRequest2("WvmpAnalytics", `analyticsFieldsFilterPrefix${RANGE}`, {
|
|
9788
10248
|
highlightCardDimensions: [
|
|
9789
10249
|
"DimensionType_LOCATION",
|
|
9790
10250
|
"DimensionType_INDUSTRY",
|
|
@@ -9929,18 +10389,18 @@ async function runViewers(opts = {}, fetch2) {
|
|
|
9929
10389
|
const list2 = listRes.ok ? parseViewers(listRes.raw) : listRes;
|
|
9930
10390
|
if (!list2.ok) return err("viewers", list2.code, list2.message, list2.hint);
|
|
9931
10391
|
const shown = list2.viewers.length;
|
|
9932
|
-
const
|
|
10392
|
+
const state2 = !totals.ok ? "unknown" : totals.total > shown ? "partial" : "complete";
|
|
9933
10393
|
return ok("viewers", {
|
|
9934
10394
|
...totals.ok ? { total: totals.total, ...totals.period !== void 0 ? { period: totals.period } : {} } : { totalError: `${totals.code}: ${totals.message}` },
|
|
9935
10395
|
...list2.privateViewers !== void 0 ? { privateViewers: list2.privateViewers } : {},
|
|
9936
10396
|
items: shape(list2.viewers, opts, compactViewer),
|
|
9937
|
-
meta: { state, operation: "viewers", returnedCount: shown }
|
|
10397
|
+
meta: { state: state2, operation: "viewers", returnedCount: shown }
|
|
9938
10398
|
});
|
|
9939
10399
|
}
|
|
9940
10400
|
|
|
9941
10401
|
// src/entry.ts
|
|
9942
10402
|
import { realpathSync } from "fs";
|
|
9943
|
-
import { basename as
|
|
10403
|
+
import { basename as basename3 } from "path";
|
|
9944
10404
|
import { fileURLToPath } from "url";
|
|
9945
10405
|
function isMainModule(argv1, moduleUrl, importMetaMain) {
|
|
9946
10406
|
if (importMetaMain === true) return true;
|
|
@@ -9955,7 +10415,7 @@ function isMainModule(argv1, moduleUrl, importMetaMain) {
|
|
|
9955
10415
|
}
|
|
9956
10416
|
function shouldForceEntry(argv1, binNames) {
|
|
9957
10417
|
if (argv1 === void 0) return false;
|
|
9958
|
-
return binNames.includes(
|
|
10418
|
+
return binNames.includes(basename3(argv1));
|
|
9959
10419
|
}
|
|
9960
10420
|
function shouldRunAsEntry(argv1, moduleUrl, importMetaMain, binNames) {
|
|
9961
10421
|
if (isMainModule(argv1, moduleUrl, importMetaMain)) {
|
|
@@ -10394,13 +10854,14 @@ function edit(args, now, deps) {
|
|
|
10394
10854
|
const [target2, inline] = args.positionals;
|
|
10395
10855
|
if (args.flags.file === true) return err("edit", "INVALID_INPUT", "--file needs a path");
|
|
10396
10856
|
const file = str(args, "file");
|
|
10857
|
+
if (target2 === "photo" || target2 === "banner") return runEdit(target2, file ?? inline, now, deps);
|
|
10397
10858
|
if (file === void 0) return runEdit(target2, inline, now, deps);
|
|
10398
10859
|
if (inline !== void 0) {
|
|
10399
10860
|
return err("edit", "INVALID_INPUT", "pass the new text inline or with --file, not both");
|
|
10400
10861
|
}
|
|
10401
10862
|
let text6;
|
|
10402
10863
|
try {
|
|
10403
|
-
text6 =
|
|
10864
|
+
text6 = readFileSync5(file, "utf-8").replace(/\n$/, "");
|
|
10404
10865
|
} catch {
|
|
10405
10866
|
return err("edit", "INVALID_INPUT", `cannot read ${file}`);
|
|
10406
10867
|
}
|
|
@@ -10431,7 +10892,7 @@ function role2(args, now, deps) {
|
|
|
10431
10892
|
return err("role", "INVALID_INPUT", "pass --description or --description-file, not both");
|
|
10432
10893
|
}
|
|
10433
10894
|
try {
|
|
10434
|
-
req.description =
|
|
10895
|
+
req.description = readFileSync5(file, "utf-8").replace(/\n$/, "");
|
|
10435
10896
|
} catch {
|
|
10436
10897
|
return err("role", "INVALID_INPUT", `cannot read ${file}`);
|
|
10437
10898
|
}
|