@usesocial/cli 0.18.1 → 0.18.2
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/CHANGELOG.md +6 -0
- package/README.md +10 -8
- package/dist/index.mjs +181 -296
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -22601,16 +22601,16 @@ const resolveLinkedinDisconnectAccount = (accounts, identifier) => {
|
|
|
22601
22601
|
const LINKEDIN_PLATFORM = "linkedin";
|
|
22602
22602
|
const DEFAULT_POLL_INTERVAL_MS = 2e3;
|
|
22603
22603
|
const DEFAULT_POLL_TIMEOUT_MS = 12e4;
|
|
22604
|
-
const SEAT_POLL_TIMEOUT_MS$
|
|
22604
|
+
const SEAT_POLL_TIMEOUT_MS$1 = 600 * 1e3;
|
|
22605
22605
|
const surfaceURL$1 = (deps, url, options = {}) => {
|
|
22606
22606
|
const log = deps.log ?? console.error;
|
|
22607
22607
|
if (options.log ?? true) log(`Open this URL: ${url}`);
|
|
22608
22608
|
};
|
|
22609
|
-
const pollForSeat$
|
|
22609
|
+
const pollForSeat$1 = async (deps) => {
|
|
22610
22610
|
const intervalMs = deps.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
22611
22611
|
const sleep = deps.sleep ?? setTimeout$1;
|
|
22612
22612
|
const startedAt = Date.now();
|
|
22613
|
-
while (Date.now() - startedAt < SEAT_POLL_TIMEOUT_MS$
|
|
22613
|
+
while (Date.now() - startedAt < SEAT_POLL_TIMEOUT_MS$1) {
|
|
22614
22614
|
if ((await deps.client.billing.status()).canConnect) return;
|
|
22615
22615
|
await sleep(intervalMs);
|
|
22616
22616
|
}
|
|
@@ -22621,7 +22621,7 @@ const prepareAccountConnect$1 = async (deps) => {
|
|
|
22621
22621
|
const status = await deps.client.billing.prepareAccountConnect();
|
|
22622
22622
|
if (status.canConnect) return;
|
|
22623
22623
|
if (status.paymentURL) surfaceURL$1(deps, status.paymentURL);
|
|
22624
|
-
await pollForSeat$
|
|
22624
|
+
await pollForSeat$1(deps);
|
|
22625
22625
|
};
|
|
22626
22626
|
const accountUsername = (account) => account.username.replace(/^@+/, "");
|
|
22627
22627
|
const listLinkedinLifecycleAccounts = (deps, includeDisconnected = true) => deps.client.listAccounts({
|
|
@@ -22708,7 +22708,7 @@ const disconnectLinkedinAccount = async (deps, identifier) => {
|
|
|
22708
22708
|
//#endregion
|
|
22709
22709
|
//#region ../../packages/x/src/cli/lifecycle.ts
|
|
22710
22710
|
const CONNECT_TIMEOUT_MS = 300 * 1e3;
|
|
22711
|
-
const SEAT_POLL_TIMEOUT_MS
|
|
22711
|
+
const SEAT_POLL_TIMEOUT_MS = 600 * 1e3;
|
|
22712
22712
|
const POLL_INTERVAL_MS = 2 * 1e3;
|
|
22713
22713
|
var XConnectTimedOut = class extends h("XConnectTimedOut")() {
|
|
22714
22714
|
constructor(args) {
|
|
@@ -22723,7 +22723,7 @@ var XBillingSeatTimedOut = class extends h("XBillingSeatTimedOut")() {
|
|
|
22723
22723
|
constructor() {
|
|
22724
22724
|
super({
|
|
22725
22725
|
operation: "prepareAccountConnect",
|
|
22726
|
-
timeoutMS: SEAT_POLL_TIMEOUT_MS
|
|
22726
|
+
timeoutMS: SEAT_POLL_TIMEOUT_MS,
|
|
22727
22727
|
message: "billing_seat_timed_out"
|
|
22728
22728
|
});
|
|
22729
22729
|
this.name = "XBillingSeatTimedOut";
|
|
@@ -22791,11 +22791,11 @@ const authURLFor = async (deps, operation) => ({
|
|
|
22791
22791
|
url: deps.handshakeAuthURL ? await deps.handshakeAuthURL(operation) : await operation(),
|
|
22792
22792
|
openingLogged: deps.handshakeAuthURL !== void 0
|
|
22793
22793
|
});
|
|
22794
|
-
const pollForSeat
|
|
22794
|
+
const pollForSeat = async (deps) => {
|
|
22795
22795
|
const sleep = deps.sleep ?? defaultSleep;
|
|
22796
22796
|
const now = deps.now ?? Date.now;
|
|
22797
22797
|
const startedAt = now();
|
|
22798
|
-
while (now() - startedAt < SEAT_POLL_TIMEOUT_MS
|
|
22798
|
+
while (now() - startedAt < SEAT_POLL_TIMEOUT_MS) {
|
|
22799
22799
|
if ((await deps.client.billing.status()).canConnect) return G.ok();
|
|
22800
22800
|
await sleep(POLL_INTERVAL_MS);
|
|
22801
22801
|
}
|
|
@@ -22806,7 +22806,7 @@ const prepareAccountConnect = async (deps) => {
|
|
|
22806
22806
|
const status = await deps.client.billing.prepareAccountConnect();
|
|
22807
22807
|
if (status.canConnect) return G.ok();
|
|
22808
22808
|
if (status.paymentURL) surfaceURL(deps, status.paymentURL);
|
|
22809
|
-
return pollForSeat
|
|
22809
|
+
return pollForSeat(deps);
|
|
22810
22810
|
};
|
|
22811
22811
|
const accountKey = (account) => account.profileId;
|
|
22812
22812
|
const timestampMS = (value) => value instanceof Date ? value.getTime() : void 0;
|
|
@@ -24272,7 +24272,7 @@ function createEnv(opts) {
|
|
|
24272
24272
|
}
|
|
24273
24273
|
//#endregion
|
|
24274
24274
|
//#region package.json
|
|
24275
|
-
var version$1 = "0.18.
|
|
24275
|
+
var version$1 = "0.18.2";
|
|
24276
24276
|
//#endregion
|
|
24277
24277
|
//#region src/lib/env.ts
|
|
24278
24278
|
const URLWithTrailingSlash = url().transform(ensureTrailingSlash);
|
|
@@ -24453,7 +24453,7 @@ const retryContextKey = (request) => `${request.method} ${request.url}`;
|
|
|
24453
24453
|
const isLinkedInRateLimitError = (error) => error instanceof HTTPError && error.response.status === 429 && isLinkedInProxyRequest(error.request);
|
|
24454
24454
|
const readBearerToken = async () => {
|
|
24455
24455
|
const credentials = await readCredentials();
|
|
24456
|
-
if (!credentials?.accessToken) throw new AuthError("Not logged in. Run `social account
|
|
24456
|
+
if (!credentials?.accessToken) throw new AuthError("Not logged in. Run `social account setup` first.");
|
|
24457
24457
|
return credentials.accessToken;
|
|
24458
24458
|
};
|
|
24459
24459
|
const linkedInRateLimitFallbackDelaySeconds = (retryCount) => Math.min(2 ** Math.max(0, retryCount - 1), LINKEDIN_RATE_LIMIT_MAX_FALLBACK_SECONDS);
|
|
@@ -30616,8 +30616,8 @@ const FIRST_RUN_NOTICE = [
|
|
|
30616
30616
|
const ALLOWLISTED_MESSAGES = /* @__PURE__ */ new Set([
|
|
30617
30617
|
"Cancelled.",
|
|
30618
30618
|
"Invalid credentials.",
|
|
30619
|
-
"Not logged in. Run `social account
|
|
30620
|
-
"Session expired before login finished. Run `social account
|
|
30619
|
+
"Not logged in. Run `social account setup` first.",
|
|
30620
|
+
"Session expired before login finished. Run `social account setup` again."
|
|
30621
30621
|
]);
|
|
30622
30622
|
const hasCittyErrorShape = (error) => error instanceof Error && error.name === "CLIError" && "code" in error && typeof error.code === "string";
|
|
30623
30623
|
const errorName = (error) => error instanceof Error && error.name ? error.name : "Error";
|
|
@@ -32169,7 +32169,7 @@ const pollDeviceTokenOnce = async (deviceCode, poster = authAPI) => {
|
|
|
32169
32169
|
/**
|
|
32170
32170
|
* Device-authorization onboarding state machine.
|
|
32171
32171
|
*
|
|
32172
|
-
* Non-TTY `social account
|
|
32172
|
+
* Non-TTY `social account setup` is a poll: each invocation is a fresh process,
|
|
32173
32173
|
* so the in-flight device code is persisted to `~/.social/device-login*.json`
|
|
32174
32174
|
* (namespaced by API URL exactly like credentials). The engine advances and
|
|
32175
32175
|
* reports onboarding state as a discriminated union — a skill can call login
|
|
@@ -32214,6 +32214,7 @@ const defaultClearPending = async (apiURL) => {
|
|
|
32214
32214
|
const resolveDeps = (deps) => ({
|
|
32215
32215
|
now: deps.now ?? Date.now,
|
|
32216
32216
|
apiURL: deps.apiURL ?? env.SOCIAL_API_URL,
|
|
32217
|
+
webURL: deps.webURL ?? env.SOCIAL_WEB_URL,
|
|
32217
32218
|
poster: deps.poster,
|
|
32218
32219
|
readPending: deps.readPending ?? defaultReadPending,
|
|
32219
32220
|
writePending: deps.writePending ?? defaultWritePending,
|
|
@@ -32231,9 +32232,15 @@ const accountFromCredentials = (credentials) => ({
|
|
|
32231
32232
|
scope: credentials.scope ?? null,
|
|
32232
32233
|
expiresAt: credentials.expiresAt ? new Date(credentials.expiresAt).toISOString() : null
|
|
32233
32234
|
});
|
|
32234
|
-
const
|
|
32235
|
+
const trustedVerificationURL = (value, webURL) => {
|
|
32236
|
+
const candidate = new URL(value);
|
|
32237
|
+
const trusted = new URL(webURL);
|
|
32238
|
+
if (candidate.origin !== trusted.origin || candidate.username.length > 0 || candidate.password.length > 0) throw new Error("untrusted_device_verification_url");
|
|
32239
|
+
return candidate.toString();
|
|
32240
|
+
};
|
|
32241
|
+
const pendingState = (pending, webURL) => ({
|
|
32235
32242
|
status: "pending_approval",
|
|
32236
|
-
verificationURL: pending.verificationURL,
|
|
32243
|
+
verificationURL: trustedVerificationURL(pending.verificationURL, webURL),
|
|
32237
32244
|
userCode: pending.userCode,
|
|
32238
32245
|
expiresAt: pending.expiresAt,
|
|
32239
32246
|
scope: pending.scope
|
|
@@ -32241,17 +32248,18 @@ const pendingState = (pending) => ({
|
|
|
32241
32248
|
const startDeviceFlow = async (scope, resolved) => {
|
|
32242
32249
|
const deviceCode = await createDeviceCode(scope, resolved.poster);
|
|
32243
32250
|
const expiresAt = new Date(resolved.now() + deviceCode.expires_in * 1e3).toISOString();
|
|
32251
|
+
const verificationURL = trustedVerificationURL(deviceCode.verification_uri_complete, resolved.webURL);
|
|
32244
32252
|
const pending = {
|
|
32245
32253
|
version: STATE_VERSION,
|
|
32246
32254
|
apiURL: resolved.apiURL,
|
|
32247
32255
|
scope,
|
|
32248
32256
|
deviceCode: deviceCode.device_code,
|
|
32249
32257
|
userCode: deviceCode.user_code,
|
|
32250
|
-
verificationURL
|
|
32258
|
+
verificationURL,
|
|
32251
32259
|
expiresAt
|
|
32252
32260
|
};
|
|
32253
32261
|
await resolved.writePending(pending);
|
|
32254
|
-
return pendingState(pending);
|
|
32262
|
+
return pendingState(pending, resolved.webURL);
|
|
32255
32263
|
};
|
|
32256
32264
|
/**
|
|
32257
32265
|
* Advance the non-TTY device login by exactly one step.
|
|
@@ -32275,7 +32283,7 @@ const advanceDeviceLogin = async (scope, deps = {}) => {
|
|
|
32275
32283
|
return { status: "expired" };
|
|
32276
32284
|
}
|
|
32277
32285
|
const outcome = await pollDeviceTokenOnce(pending.deviceCode, resolved.poster);
|
|
32278
|
-
if (outcome.kind === "pending") return pendingState(pending);
|
|
32286
|
+
if (outcome.kind === "pending") return pendingState(pending, resolved.webURL);
|
|
32279
32287
|
if (outcome.kind === "expired") {
|
|
32280
32288
|
await resolved.clearPending(resolved.apiURL);
|
|
32281
32289
|
return { status: "expired" };
|
|
@@ -32552,56 +32560,6 @@ const parseScopeAlias = (value) => {
|
|
|
32552
32560
|
if (G.isOk(parsed)) return parsed.value;
|
|
32553
32561
|
throw new Error(parsed.error.message);
|
|
32554
32562
|
};
|
|
32555
|
-
const scopePhase = async (ctx) => {
|
|
32556
|
-
const scopeAlias = parseScopeAlias(ctx.args.scope);
|
|
32557
|
-
return {
|
|
32558
|
-
status: "done",
|
|
32559
|
-
data: await ctx.client.cli.session.upsert({ scopeAlias })
|
|
32560
|
-
};
|
|
32561
|
-
};
|
|
32562
|
-
//#endregion
|
|
32563
|
-
//#region src/login/phases/2.seat.ts
|
|
32564
|
-
const SEAT_BILLING_DETAILS_URL = publicRouteURLs.pricing;
|
|
32565
|
-
const SEAT_PRICING_MESSAGE = `${productBrand.name} costs $20/month/account + usage. Full details at ${SEAT_BILLING_DETAILS_URL}. Continue?`;
|
|
32566
|
-
const SEAT_CHECKOUT_RETURN_PATH = "/setup/billing/done";
|
|
32567
|
-
const SEAT_POLL_INTERVAL_MS = 2e3;
|
|
32568
|
-
const SEAT_POLL_TIMEOUT_MS = 1800 * 1e3;
|
|
32569
|
-
const seatAvailable = (status) => status.seats.available > 0;
|
|
32570
|
-
const pollForSeat = async (ctx, deps = {}) => {
|
|
32571
|
-
const sleep = deps.sleep ?? setTimeout$1;
|
|
32572
|
-
const now = deps.now ?? Date.now;
|
|
32573
|
-
const startedAt = now();
|
|
32574
|
-
const intervalMs = deps.pollIntervalMs ?? SEAT_POLL_INTERVAL_MS;
|
|
32575
|
-
const timeoutMs = deps.pollTimeoutMs ?? SEAT_POLL_TIMEOUT_MS;
|
|
32576
|
-
while (now() - startedAt <= timeoutMs) {
|
|
32577
|
-
const status = await ctx.client.billing.status();
|
|
32578
|
-
if (seatAvailable(status)) return status;
|
|
32579
|
-
await sleep(intervalMs);
|
|
32580
|
-
}
|
|
32581
|
-
throw new Error("Billing checkout did not complete within 30 minutes. Finish checkout in the browser, then run `social account login` again.");
|
|
32582
|
-
};
|
|
32583
|
-
const runSeatPhase = async (ctx, deps = {}) => {
|
|
32584
|
-
const status = await ctx.client.billing.status();
|
|
32585
|
-
if (seatAvailable(status)) return {
|
|
32586
|
-
status: "done",
|
|
32587
|
-
data: status
|
|
32588
|
-
};
|
|
32589
|
-
if (!await ctx.ui.confirm({
|
|
32590
|
-
message: SEAT_PRICING_MESSAGE,
|
|
32591
|
-
initialValue: true
|
|
32592
|
-
})) return {
|
|
32593
|
-
status: "needs_input",
|
|
32594
|
-
missing: ["billing_confirmation"],
|
|
32595
|
-
reason: "Checkout was not started."
|
|
32596
|
-
};
|
|
32597
|
-
const checkout = await ctx.client.billing.checkoutURL({ returnPath: SEAT_CHECKOUT_RETURN_PATH });
|
|
32598
|
-
ctx.ui.info(checkout.url);
|
|
32599
|
-
return {
|
|
32600
|
-
status: "done",
|
|
32601
|
-
data: await ctx.ui.spinElapsed("Waiting for billing checkout", () => pollForSeat(ctx, deps), "Billing ready")
|
|
32602
|
-
};
|
|
32603
|
-
};
|
|
32604
|
-
const seatPhase = (ctx) => runSeatPhase(ctx);
|
|
32605
32563
|
//#endregion
|
|
32606
32564
|
//#region src/login/index.ts
|
|
32607
32565
|
const ScopeAliasOutput = _enum(CLI_SCOPE_ALIASES);
|
|
@@ -32616,37 +32574,22 @@ const LoginSeatsOutput = object({
|
|
|
32616
32574
|
used: number().int().nonnegative(),
|
|
32617
32575
|
available: number().int().nonnegative()
|
|
32618
32576
|
});
|
|
32619
|
-
const LoginCredentialOutput = object({
|
|
32620
|
-
apiURL: string(),
|
|
32621
|
-
namespace: string().nullable(),
|
|
32622
|
-
account: string(),
|
|
32623
|
-
path: string(),
|
|
32624
|
-
present: boolean$1(),
|
|
32625
|
-
valid: boolean$1(),
|
|
32626
|
-
expiresAt: string().nullable(),
|
|
32627
|
-
scope: string().nullable(),
|
|
32628
|
-
capabilities: array(string())
|
|
32629
|
-
});
|
|
32630
|
-
const DeviceAccountOutput = object({
|
|
32631
|
-
scope: string().nullable(),
|
|
32632
|
-
expiresAt: string().nullable()
|
|
32633
|
-
});
|
|
32634
32577
|
const LoginOutput = discriminatedUnion("status", [
|
|
32635
32578
|
object({
|
|
32636
|
-
status: literal("
|
|
32579
|
+
status: literal("pending_billing"),
|
|
32637
32580
|
user: LoginUserOutput,
|
|
32638
32581
|
scope: ScopeAliasOutput,
|
|
32582
|
+
capabilities: array(string()),
|
|
32639
32583
|
seats: LoginSeatsOutput,
|
|
32584
|
+
checkoutURL: string(),
|
|
32640
32585
|
nextCommands: array(string())
|
|
32641
32586
|
}),
|
|
32642
32587
|
object({
|
|
32643
|
-
status: literal("
|
|
32644
|
-
message: string(),
|
|
32588
|
+
status: literal("ready"),
|
|
32645
32589
|
user: LoginUserOutput,
|
|
32646
|
-
sessionId: string(),
|
|
32647
32590
|
scope: ScopeAliasOutput,
|
|
32648
32591
|
capabilities: array(string()),
|
|
32649
|
-
|
|
32592
|
+
seats: LoginSeatsOutput,
|
|
32650
32593
|
nextCommands: array(string())
|
|
32651
32594
|
}),
|
|
32652
32595
|
object({
|
|
@@ -32657,11 +32600,6 @@ const LoginOutput = discriminatedUnion("status", [
|
|
|
32657
32600
|
scope: ScopeAliasOutput,
|
|
32658
32601
|
nextCommands: array(string())
|
|
32659
32602
|
}),
|
|
32660
|
-
object({
|
|
32661
|
-
status: literal("logged_in"),
|
|
32662
|
-
account: DeviceAccountOutput,
|
|
32663
|
-
nextCommands: array(string())
|
|
32664
|
-
}),
|
|
32665
32603
|
object({
|
|
32666
32604
|
status: literal("expired"),
|
|
32667
32605
|
message: string()
|
|
@@ -32678,60 +32616,37 @@ const LoginOutput = discriminatedUnion("status", [
|
|
|
32678
32616
|
details: unknown().optional()
|
|
32679
32617
|
})
|
|
32680
32618
|
]);
|
|
32681
|
-
const phases = [
|
|
32682
|
-
|
|
32683
|
-
|
|
32684
|
-
|
|
32685
|
-
|
|
32686
|
-
|
|
32687
|
-
|
|
32688
|
-
run: signInPhase
|
|
32689
|
-
},
|
|
32690
|
-
{
|
|
32691
|
-
name: "scope",
|
|
32692
|
-
run: scopePhase
|
|
32693
|
-
},
|
|
32694
|
-
{
|
|
32695
|
-
name: "seat",
|
|
32696
|
-
run: seatPhase
|
|
32697
|
-
}
|
|
32698
|
-
];
|
|
32619
|
+
const phases = [{
|
|
32620
|
+
name: "access",
|
|
32621
|
+
run: accessPhase
|
|
32622
|
+
}, {
|
|
32623
|
+
name: "sign-in",
|
|
32624
|
+
run: signInPhase
|
|
32625
|
+
}];
|
|
32699
32626
|
const errorOutput = (error) => ({
|
|
32700
32627
|
status: "error",
|
|
32701
32628
|
code: error instanceof Error ? error.name : "Error",
|
|
32702
32629
|
message: error instanceof Error ? error.message : String(error)
|
|
32703
32630
|
});
|
|
32704
32631
|
const nextCommands = ["social account connect linkedin", "social account connect x"];
|
|
32705
|
-
const
|
|
32706
|
-
const
|
|
32707
|
-
|
|
32708
|
-
const credentialScopeFor = (session) => {
|
|
32709
|
-
const parsed = ScopeAliasOutput.safeParse(session.credential.scope);
|
|
32710
|
-
return parsed.success ? parsed.data : null;
|
|
32711
|
-
};
|
|
32712
|
-
const existingSessionSupportsScope = (session, requested) => {
|
|
32713
|
-
if (scopeAliasIncludes(session.session.scope, requested)) return true;
|
|
32714
|
-
const credentialScope = credentialScopeFor(session);
|
|
32715
|
-
return credentialScope ? scopeAliasIncludes(credentialScope, requested) : false;
|
|
32716
|
-
};
|
|
32717
|
-
const nextCommandsMessage = `Now run \`${nextCommands[0]}\` or \`${nextCommands[1]}\`.`;
|
|
32718
|
-
const billingReady = (billing) => billing.seats.available > 0;
|
|
32719
|
-
const alreadyLoggedInOutput = ({ credential, session }) => ({
|
|
32720
|
-
status: "already_logged_in",
|
|
32721
|
-
message: "Already logged in.",
|
|
32722
|
-
user: session.user,
|
|
32723
|
-
sessionId: session.sessionId,
|
|
32724
|
-
scope: session.scope,
|
|
32725
|
-
capabilities: session.capabilities,
|
|
32726
|
-
credential,
|
|
32727
|
-
nextCommands
|
|
32632
|
+
const availableConnectCommands = (capabilities) => nextCommands.filter((command) => {
|
|
32633
|
+
const platform = command.endsWith(" linkedin") ? "linkedin" : "x";
|
|
32634
|
+
return capabilities.some((capability) => capability.startsWith(`${platform}:`));
|
|
32728
32635
|
});
|
|
32636
|
+
const setupOutputFor = (setup) => ({
|
|
32637
|
+
...setup,
|
|
32638
|
+
nextCommands: setup.status === "pending_billing" ? ["social account setup"] : availableConnectCommands(setup.capabilities)
|
|
32639
|
+
});
|
|
32640
|
+
const deviceExpiredMessage = "Sign-in expired before approval. Run `social account setup` again to restart.";
|
|
32641
|
+
const scopeUpgradeRequiresReauthorization = "Existing CLI session is read-only. Run `social account logout`, then `social account setup` to approve a new write-capable session.";
|
|
32642
|
+
const scopeAliasIncludes = (granted, requested) => granted === requested || granted === "read,write";
|
|
32643
|
+
const existingSessionSupportsScope = (session, requested) => scopeAliasIncludes(session.session.scope, requested);
|
|
32729
32644
|
const offlineOutput = () => ({
|
|
32730
32645
|
status: "error",
|
|
32731
32646
|
code: "offline",
|
|
32732
32647
|
message: "Couldn't reach the server. Check your network connection and try again."
|
|
32733
32648
|
});
|
|
32734
|
-
const loginOutputForDeviceState = (state
|
|
32649
|
+
const loginOutputForDeviceState = (state) => {
|
|
32735
32650
|
switch (state.status) {
|
|
32736
32651
|
case "pending_approval": return {
|
|
32737
32652
|
status: "pending_approval",
|
|
@@ -32739,16 +32654,9 @@ const loginOutputForDeviceState = (state, sessionScope) => {
|
|
|
32739
32654
|
userCode: state.userCode,
|
|
32740
32655
|
expiresAt: state.expiresAt,
|
|
32741
32656
|
scope: state.scope,
|
|
32742
|
-
nextCommands: ["social account
|
|
32743
|
-
};
|
|
32744
|
-
case "logged_in": return {
|
|
32745
|
-
status: "logged_in",
|
|
32746
|
-
account: {
|
|
32747
|
-
...state.account,
|
|
32748
|
-
scope: sessionScope ?? state.account.scope
|
|
32749
|
-
},
|
|
32750
|
-
nextCommands
|
|
32657
|
+
nextCommands: ["social account setup"]
|
|
32751
32658
|
};
|
|
32659
|
+
case "logged_in": throw new Error("Approved device login must continue through account setup.");
|
|
32752
32660
|
case "expired": return {
|
|
32753
32661
|
status: "expired",
|
|
32754
32662
|
message: deviceExpiredMessage
|
|
@@ -32759,10 +32667,10 @@ const loginOutputForDeviceState = (state, sessionScope) => {
|
|
|
32759
32667
|
};
|
|
32760
32668
|
}
|
|
32761
32669
|
};
|
|
32762
|
-
const planLoginStep = ({
|
|
32670
|
+
const planLoginStep = ({ deviceState, existing, isInteractiveTerminal, requestedScope }) => {
|
|
32763
32671
|
if (deviceState) return {
|
|
32764
32672
|
action: "printOutput",
|
|
32765
|
-
output: loginOutputForDeviceState(deviceState
|
|
32673
|
+
output: loginOutputForDeviceState(deviceState)
|
|
32766
32674
|
};
|
|
32767
32675
|
if (existing.kind === "existing") {
|
|
32768
32676
|
if (!existingSessionSupportsScope(existing.session, requestedScope)) return {
|
|
@@ -32773,15 +32681,7 @@ const planLoginStep = ({ billingSeatAvailable, deviceSessionScope, deviceState,
|
|
|
32773
32681
|
message: scopeUpgradeRequiresReauthorization
|
|
32774
32682
|
}
|
|
32775
32683
|
};
|
|
32776
|
-
|
|
32777
|
-
action: "useExistingSession",
|
|
32778
|
-
output: alreadyLoggedInOutput(existing.session),
|
|
32779
|
-
repairScope: requestedScope
|
|
32780
|
-
};
|
|
32781
|
-
return {
|
|
32782
|
-
action: "runInteractiveSeatOnly",
|
|
32783
|
-
repairScope: requestedScope
|
|
32784
|
-
};
|
|
32684
|
+
return { action: "useExistingSession" };
|
|
32785
32685
|
}
|
|
32786
32686
|
if (existing.kind === "offline") return {
|
|
32787
32687
|
action: "offline",
|
|
@@ -32794,25 +32694,12 @@ const runLogin = async (ctx, loginPhases = phases, deps = {}) => {
|
|
|
32794
32694
|
const readLocalCredentials = deps.readCredentials ?? readCredentials;
|
|
32795
32695
|
analytics.capture("login_started");
|
|
32796
32696
|
for (const phase of loginPhases) {
|
|
32797
|
-
if (phase.name !== "access" && phase.name !== "sign-in" && deps.authenticated !== true && !bearerIsValid(await readLocalCredentials())) throw new AuthError("Session expired before login finished. Run `social account
|
|
32697
|
+
if (phase.name !== "access" && phase.name !== "sign-in" && deps.authenticated !== true && !bearerIsValid(await readLocalCredentials())) throw new AuthError("Session expired before login finished. Run `social account setup` again.");
|
|
32798
32698
|
const result = await phase.run(ctx);
|
|
32799
32699
|
if (result.status !== "done") return result;
|
|
32800
32700
|
analytics.capture("login_phase_completed", { phase: phase.name });
|
|
32801
32701
|
}
|
|
32802
|
-
|
|
32803
|
-
const billing = await ctx.client.billing.status();
|
|
32804
|
-
ctx.ui.info(nextCommandsMessage);
|
|
32805
|
-
return {
|
|
32806
|
-
status: "ok",
|
|
32807
|
-
user: session.user,
|
|
32808
|
-
scope: session.scopeAlias,
|
|
32809
|
-
seats: {
|
|
32810
|
-
total: billing.seats.total,
|
|
32811
|
-
used: billing.seats.used,
|
|
32812
|
-
available: billing.seats.available
|
|
32813
|
-
},
|
|
32814
|
-
nextCommands
|
|
32815
|
-
};
|
|
32702
|
+
return setupOutputFor(await ctx.client.billing.accountSetup());
|
|
32816
32703
|
};
|
|
32817
32704
|
const loginExitCodeFor = (output) => {
|
|
32818
32705
|
if (output.status === "error") return exitCodeFor(new Error(output.message));
|
|
@@ -32826,15 +32713,16 @@ const loginExitCodeFor = (output) => {
|
|
|
32826
32713
|
*/
|
|
32827
32714
|
const createLoginCommand = (deps = {}) => {
|
|
32828
32715
|
const commandDeps = {
|
|
32829
|
-
advanceDeviceLogin: deps.advanceDeviceLogin ?? advanceDeviceLogin,
|
|
32716
|
+
advanceDeviceLogin: deps.advanceDeviceLogin ?? ((scope) => advanceDeviceLogin(scope, deps.deviceDeps)),
|
|
32830
32717
|
createClient: deps.createClient ?? createORPCAPIClient,
|
|
32718
|
+
deviceDeps: deps.deviceDeps ?? {},
|
|
32831
32719
|
isInteractiveTerminal: deps.isInteractiveTerminal ?? (() => process.stdin.isTTY === true && process.stdout.isTTY === true),
|
|
32832
32720
|
readExistingAuthSession: deps.readExistingAuthSession ?? readExistingAuthSession
|
|
32833
32721
|
};
|
|
32834
32722
|
return defineCommand({
|
|
32835
32723
|
meta: commandMeta({
|
|
32836
|
-
name: "
|
|
32837
|
-
description: "
|
|
32724
|
+
name: "setup",
|
|
32725
|
+
description: "Authenticate Social and ensure billing is ready",
|
|
32838
32726
|
contract: localCLIContract({
|
|
32839
32727
|
auth: {
|
|
32840
32728
|
interactive: true,
|
|
@@ -32861,21 +32749,15 @@ const createLoginCommand = (deps = {}) => {
|
|
|
32861
32749
|
const existing = await commandDeps.readExistingAuthSession(client);
|
|
32862
32750
|
const requestedScope = parseScopeAlias(loginArgs.scope);
|
|
32863
32751
|
const isInteractive = commandDeps.isInteractiveTerminal();
|
|
32864
|
-
const billingSeatAvailable = existing.kind === "existing" && existingSessionSupportsScope(existing.session, requestedScope) ? billingReady(await client.billing.status()) : void 0;
|
|
32865
32752
|
const plan = planLoginStep({
|
|
32866
32753
|
existing,
|
|
32867
32754
|
requestedScope,
|
|
32868
|
-
isInteractiveTerminal: isInteractive
|
|
32869
|
-
billingSeatAvailable
|
|
32755
|
+
isInteractiveTerminal: isInteractive
|
|
32870
32756
|
});
|
|
32871
32757
|
switch (plan.action) {
|
|
32872
32758
|
case "useExistingSession": {
|
|
32873
|
-
const
|
|
32874
|
-
output =
|
|
32875
|
-
...plan.output,
|
|
32876
|
-
scope: grant.scopeAlias,
|
|
32877
|
-
capabilities: grant.capabilities
|
|
32878
|
-
};
|
|
32759
|
+
const setup = await client.billing.accountSetup();
|
|
32760
|
+
output = setupOutputFor(setup);
|
|
32879
32761
|
break;
|
|
32880
32762
|
}
|
|
32881
32763
|
case "requireScopeReauth":
|
|
@@ -32883,17 +32765,6 @@ const createLoginCommand = (deps = {}) => {
|
|
|
32883
32765
|
case "printOutput":
|
|
32884
32766
|
output = plan.output;
|
|
32885
32767
|
break;
|
|
32886
|
-
case "runInteractiveSeatOnly":
|
|
32887
|
-
await client.cli.session.upsert({ scopeAlias: plan.repairScope });
|
|
32888
|
-
output = await runLogin({
|
|
32889
|
-
ui: createUI(true),
|
|
32890
|
-
client,
|
|
32891
|
-
args: loginArgs
|
|
32892
|
-
}, [{
|
|
32893
|
-
name: "seat",
|
|
32894
|
-
run: seatPhase
|
|
32895
|
-
}], { authenticated: true });
|
|
32896
|
-
break;
|
|
32897
32768
|
case "runInteractiveFullLogin":
|
|
32898
32769
|
output = await runLogin({
|
|
32899
32770
|
ui: createUI(true),
|
|
@@ -32903,13 +32774,17 @@ const createLoginCommand = (deps = {}) => {
|
|
|
32903
32774
|
break;
|
|
32904
32775
|
case "advanceDeviceLogin": {
|
|
32905
32776
|
const state = await commandDeps.advanceDeviceLogin(requestedScope);
|
|
32906
|
-
|
|
32777
|
+
if (state.status === "logged_in") {
|
|
32778
|
+
const approvedScope = ScopeAliasOutput.safeParse(state.account.scope);
|
|
32779
|
+
if (!(approvedScope.success && scopeAliasIncludes(approvedScope.data, requestedScope))) throw new Error("Device authorization returned an insufficient scope.");
|
|
32780
|
+
output = setupOutputFor(await client.billing.accountSetup());
|
|
32781
|
+
break;
|
|
32782
|
+
}
|
|
32907
32783
|
const devicePlan = planLoginStep({
|
|
32908
32784
|
existing,
|
|
32909
32785
|
requestedScope,
|
|
32910
32786
|
isInteractiveTerminal: isInteractive,
|
|
32911
|
-
deviceState: state
|
|
32912
|
-
deviceSessionScope: sessionScope
|
|
32787
|
+
deviceState: state
|
|
32913
32788
|
});
|
|
32914
32789
|
if (devicePlan.action !== "printOutput") throw new Error("Device login produced no printable state.");
|
|
32915
32790
|
output = devicePlan.output;
|
|
@@ -32920,21 +32795,14 @@ const createLoginCommand = (deps = {}) => {
|
|
|
32920
32795
|
output = errorOutput(error);
|
|
32921
32796
|
exitCode = exitCodeFor(error);
|
|
32922
32797
|
}
|
|
32923
|
-
if (output.status === "
|
|
32798
|
+
if (output.status === "ready") {
|
|
32924
32799
|
analytics.identifyUser(output.user.id);
|
|
32925
32800
|
analytics.capture("login_completed", {
|
|
32926
32801
|
scope: output.scope,
|
|
32927
|
-
|
|
32928
|
-
|
|
32929
|
-
seats_total: output.seats.total,
|
|
32930
|
-
seats_available: output.seats.available
|
|
32931
|
-
} : {}
|
|
32802
|
+
seats_total: output.seats.total,
|
|
32803
|
+
seats_available: output.seats.available
|
|
32932
32804
|
});
|
|
32933
|
-
} else if (output.status === "
|
|
32934
|
-
already_logged_in: false,
|
|
32935
|
-
non_tty: true
|
|
32936
|
-
});
|
|
32937
|
-
else if (output.status === "expired") analytics.capture("login_failed", { code: "expired" });
|
|
32805
|
+
} else if (output.status === "expired") analytics.capture("login_failed", { code: "expired" });
|
|
32938
32806
|
else if (output.status === "needs_input") analytics.capture("login_failed", {
|
|
32939
32807
|
code: "needs_input",
|
|
32940
32808
|
reason: output.reason
|
|
@@ -32945,7 +32813,19 @@ const createLoginCommand = (deps = {}) => {
|
|
|
32945
32813
|
}
|
|
32946
32814
|
});
|
|
32947
32815
|
};
|
|
32948
|
-
const
|
|
32816
|
+
const setupCommand = createLoginCommand();
|
|
32817
|
+
const hiddenLoginAliasFor = (command) => {
|
|
32818
|
+
const meta = {
|
|
32819
|
+
...command.meta,
|
|
32820
|
+
hidden: true,
|
|
32821
|
+
schemaHidden: true
|
|
32822
|
+
};
|
|
32823
|
+
return {
|
|
32824
|
+
...command,
|
|
32825
|
+
meta
|
|
32826
|
+
};
|
|
32827
|
+
};
|
|
32828
|
+
hiddenLoginAliasFor(setupCommand);
|
|
32949
32829
|
//#endregion
|
|
32950
32830
|
//#region src/logout.ts
|
|
32951
32831
|
const revokeServerSide = async (accessToken) => {
|
|
@@ -32987,7 +32867,7 @@ const logoutCommand = defineCommand({
|
|
|
32987
32867
|
const credentials = await readCredentials();
|
|
32988
32868
|
if (!credentials?.accessToken) {
|
|
32989
32869
|
await clearCredentials();
|
|
32990
|
-
throw new AuthError("Not logged in. Run `social account
|
|
32870
|
+
throw new AuthError("Not logged in. Run `social account setup` first.");
|
|
32991
32871
|
}
|
|
32992
32872
|
const revoked = await revokeServerSide(credentials.accessToken);
|
|
32993
32873
|
await clearCredentials();
|
|
@@ -33419,7 +33299,7 @@ const isInteractiveConnect = (deps) => deps.isInteractiveTerminal?.() === true;
|
|
|
33419
33299
|
* One non-blocking step of a connect handshake for a non-TTY caller. Returns the
|
|
33420
33300
|
* connected account if one is already linked, otherwise emits the connect URL and
|
|
33421
33301
|
* reports `pending_approval`. A repeated call re-checks and advances — the skill
|
|
33422
|
-
* polls this the same way it polls `social account
|
|
33302
|
+
* polls this the same way it polls `social account setup`.
|
|
33423
33303
|
*/
|
|
33424
33304
|
const runConnectStep = async (deps, platform, listConnected, connectURL) => {
|
|
33425
33305
|
const connected = (await listConnected()).find((account) => account.status === "connected");
|
|
@@ -33486,7 +33366,7 @@ const listConnectedAccounts = async (deps) => {
|
|
|
33486
33366
|
});
|
|
33487
33367
|
};
|
|
33488
33368
|
const defaultWhoamiOutput = () => authWhoamiOutput(createORPCAPIClient());
|
|
33489
|
-
const createAccountCommand = (deps) => {
|
|
33369
|
+
const createAccountCommand = (deps, accountSetupCommand = setupCommand) => {
|
|
33490
33370
|
const accountDefaultsClient = deps.client.accounts.default;
|
|
33491
33371
|
const defaultCommand = defineCommand({
|
|
33492
33372
|
meta: {
|
|
@@ -33542,67 +33422,79 @@ const createAccountCommand = (deps) => {
|
|
|
33542
33422
|
})
|
|
33543
33423
|
}
|
|
33544
33424
|
});
|
|
33545
|
-
const
|
|
33546
|
-
|
|
33547
|
-
|
|
33548
|
-
|
|
33549
|
-
|
|
33550
|
-
|
|
33551
|
-
|
|
33552
|
-
|
|
33553
|
-
|
|
33554
|
-
|
|
33555
|
-
|
|
33556
|
-
|
|
33557
|
-
|
|
33558
|
-
|
|
33559
|
-
|
|
33560
|
-
}),
|
|
33561
|
-
x: createConnectPlatformCommand("x", async () => {
|
|
33562
|
-
if (isInteractiveConnect(deps)) {
|
|
33563
|
-
await runConnectOutput(deps, async (connectDeps) => {
|
|
33564
|
-
const result = await connectXAccount(connectDeps);
|
|
33565
|
-
if (G.isError(result)) throwXLifecycleError(result.error);
|
|
33566
|
-
return result.value;
|
|
33567
|
-
});
|
|
33568
|
-
return;
|
|
33569
|
-
}
|
|
33570
|
-
await runConnectStep(deps, "x", async () => {
|
|
33571
|
-
const result = await listXLifecycleAccounts(deps, true);
|
|
33572
|
-
if (G.isError(result)) throwXLifecycleError(result.error);
|
|
33573
|
-
return result.value;
|
|
33574
|
-
}, () => createXConnectURL(deps));
|
|
33575
|
-
})
|
|
33576
|
-
}
|
|
33577
|
-
}),
|
|
33578
|
-
reconnect: defineCommand({
|
|
33579
|
-
meta: {
|
|
33580
|
-
name: "reconnect",
|
|
33581
|
-
description: "Reconnect a LinkedIn or X account."
|
|
33582
|
-
},
|
|
33583
|
-
subCommands: {
|
|
33584
|
-
linkedin: createAccountPlatformCommand("linkedin", "Reconnect a LinkedIn account.", async (args) => {
|
|
33585
|
-
await runConnectOutput(deps, (connectDeps) => reconnectLinkedinAccount(connectDeps, String(args.account)));
|
|
33586
|
-
}, { accountArg: linkedinReconnectAccountArg }),
|
|
33587
|
-
x: createAccountPlatformCommand("x", "Reconnect an X account.", async (args) => {
|
|
33425
|
+
const connect = defineCommand({
|
|
33426
|
+
meta: {
|
|
33427
|
+
name: "connect",
|
|
33428
|
+
description: "Connect a LinkedIn or X account."
|
|
33429
|
+
},
|
|
33430
|
+
subCommands: {
|
|
33431
|
+
linkedin: createConnectPlatformCommand("linkedin", async () => {
|
|
33432
|
+
if (isInteractiveConnect(deps)) {
|
|
33433
|
+
await runConnectOutput(deps, connectLinkedinAccount);
|
|
33434
|
+
return;
|
|
33435
|
+
}
|
|
33436
|
+
await runConnectStep(deps, "linkedin", () => listLinkedinLifecycleAccounts(deps), () => createLinkedinConnectURL(deps));
|
|
33437
|
+
}),
|
|
33438
|
+
x: createConnectPlatformCommand("x", async () => {
|
|
33439
|
+
if (isInteractiveConnect(deps)) {
|
|
33588
33440
|
await runConnectOutput(deps, async (connectDeps) => {
|
|
33589
|
-
const result = await
|
|
33441
|
+
const result = await connectXAccount(connectDeps);
|
|
33590
33442
|
if (G.isError(result)) throwXLifecycleError(result.error);
|
|
33591
33443
|
return result.value;
|
|
33592
33444
|
});
|
|
33593
|
-
|
|
33594
|
-
|
|
33595
|
-
|
|
33596
|
-
|
|
33597
|
-
|
|
33598
|
-
|
|
33599
|
-
|
|
33600
|
-
}
|
|
33601
|
-
|
|
33602
|
-
|
|
33603
|
-
|
|
33604
|
-
|
|
33605
|
-
|
|
33445
|
+
return;
|
|
33446
|
+
}
|
|
33447
|
+
await runConnectStep(deps, "x", async () => {
|
|
33448
|
+
const result = await listXLifecycleAccounts(deps, true);
|
|
33449
|
+
if (G.isError(result)) throwXLifecycleError(result.error);
|
|
33450
|
+
return result.value;
|
|
33451
|
+
}, () => createXConnectURL(deps));
|
|
33452
|
+
})
|
|
33453
|
+
}
|
|
33454
|
+
});
|
|
33455
|
+
const reconnect = defineCommand({
|
|
33456
|
+
meta: {
|
|
33457
|
+
name: "reconnect",
|
|
33458
|
+
description: "Reconnect a LinkedIn or X account."
|
|
33459
|
+
},
|
|
33460
|
+
subCommands: {
|
|
33461
|
+
linkedin: createAccountPlatformCommand("linkedin", "Reconnect a LinkedIn account.", async (args) => {
|
|
33462
|
+
await runConnectOutput(deps, (connectDeps) => reconnectLinkedinAccount(connectDeps, String(args.account)));
|
|
33463
|
+
}, { accountArg: linkedinReconnectAccountArg }),
|
|
33464
|
+
x: createAccountPlatformCommand("x", "Reconnect an X account.", async (args) => {
|
|
33465
|
+
await runConnectOutput(deps, async (connectDeps) => {
|
|
33466
|
+
const result = await reconnectXAccount(connectDeps, { account: String(args.account) });
|
|
33467
|
+
if (G.isError(result)) throwXLifecycleError(result.error);
|
|
33468
|
+
return result.value;
|
|
33469
|
+
});
|
|
33470
|
+
}, { accountArg: xAccountArg })
|
|
33471
|
+
}
|
|
33472
|
+
});
|
|
33473
|
+
const disconnect = defineCommand({
|
|
33474
|
+
meta: {
|
|
33475
|
+
name: "disconnect",
|
|
33476
|
+
description: "Disconnect a LinkedIn or X account."
|
|
33477
|
+
},
|
|
33478
|
+
subCommands: {
|
|
33479
|
+
linkedin: createAccountPlatformCommand("linkedin", "Disconnect a LinkedIn account.", async (args) => {
|
|
33480
|
+
const result = await disconnectLinkedinAccount(deps, String(args.account));
|
|
33481
|
+
await writeOutput(deps, result);
|
|
33482
|
+
}, { contract: writeCLIContract({
|
|
33483
|
+
outputSchema: AccountDisconnectOutput,
|
|
33484
|
+
idempotency: "non-idempotent",
|
|
33485
|
+
hazard: advisoryHazard("destructive"),
|
|
33486
|
+
hazards: [{
|
|
33487
|
+
code: "account_disconnect",
|
|
33488
|
+
message: "Destructive account disconnect; requires an exact account identifier."
|
|
33489
|
+
}]
|
|
33490
|
+
}) }),
|
|
33491
|
+
x: createAccountPlatformCommand("x", "Disconnect an X account.", async (args) => {
|
|
33492
|
+
const result = await disconnectXAccount(deps, String(args.account));
|
|
33493
|
+
if (G.isError(result)) throwXLifecycleError(result.error);
|
|
33494
|
+
await writeOutput(deps, result.value);
|
|
33495
|
+
}, {
|
|
33496
|
+
accountArg: xAccountArg,
|
|
33497
|
+
contract: writeCLIContract({
|
|
33606
33498
|
outputSchema: AccountDisconnectOutput,
|
|
33607
33499
|
idempotency: "non-idempotent",
|
|
33608
33500
|
hazard: advisoryHazard("destructive"),
|
|
@@ -33610,25 +33502,17 @@ const createAccountCommand = (deps) => {
|
|
|
33610
33502
|
code: "account_disconnect",
|
|
33611
33503
|
message: "Destructive account disconnect; requires an exact account identifier."
|
|
33612
33504
|
}]
|
|
33613
|
-
}) }),
|
|
33614
|
-
x: createAccountPlatformCommand("x", "Disconnect an X account.", async (args) => {
|
|
33615
|
-
const result = await disconnectXAccount(deps, String(args.account));
|
|
33616
|
-
if (G.isError(result)) throwXLifecycleError(result.error);
|
|
33617
|
-
await writeOutput(deps, result.value);
|
|
33618
|
-
}, {
|
|
33619
|
-
accountArg: xAccountArg,
|
|
33620
|
-
contract: writeCLIContract({
|
|
33621
|
-
outputSchema: AccountDisconnectOutput,
|
|
33622
|
-
idempotency: "non-idempotent",
|
|
33623
|
-
hazard: advisoryHazard("destructive"),
|
|
33624
|
-
hazards: [{
|
|
33625
|
-
code: "account_disconnect",
|
|
33626
|
-
message: "Destructive account disconnect; requires an exact account identifier."
|
|
33627
|
-
}]
|
|
33628
|
-
})
|
|
33629
33505
|
})
|
|
33630
|
-
}
|
|
33631
|
-
}
|
|
33506
|
+
})
|
|
33507
|
+
}
|
|
33508
|
+
});
|
|
33509
|
+
const subCommands = {
|
|
33510
|
+
setup: accountSetupCommand,
|
|
33511
|
+
login: hiddenLoginAliasFor(accountSetupCommand),
|
|
33512
|
+
logout: logoutCommand,
|
|
33513
|
+
connect,
|
|
33514
|
+
reconnect,
|
|
33515
|
+
disconnect,
|
|
33632
33516
|
default: defaultCommand,
|
|
33633
33517
|
billing: createBillingCommand(deps),
|
|
33634
33518
|
usage: createUsageCommand(deps),
|
|
@@ -39115,6 +38999,7 @@ const pathPartsFrom = (...values) => {
|
|
|
39115
38999
|
const commandName = (command, fallback) => typeof command.meta?.name === "string" ? command.meta.name : fallback;
|
|
39116
39000
|
const commandDescription = (command) => typeof command.meta?.description === "string" ? command.meta.description : "";
|
|
39117
39001
|
const isHiddenCommand = (command) => command.meta?.hidden === true;
|
|
39002
|
+
const isSchemaHiddenCommand = (command) => command.meta?.schemaHidden === true;
|
|
39118
39003
|
const inputSourceFor = (command) => command.meta?.stdin === true ? { inputSource: "stdin" } : {};
|
|
39119
39004
|
const isRecord = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
39120
39005
|
const childCommandsFor = (command) => ({
|
|
@@ -39416,7 +39301,7 @@ const commandAtPath = (command, path) => {
|
|
|
39416
39301
|
const resolved = [];
|
|
39417
39302
|
for (const [index, part] of parts.entries()) {
|
|
39418
39303
|
const next = childCommandsFor(current)[part];
|
|
39419
|
-
if (!next) {
|
|
39304
|
+
if (!next || isSchemaHiddenCommand(next)) {
|
|
39420
39305
|
const tail = parts.slice(index);
|
|
39421
39306
|
const match = positionalPathMatch(current, resolved, tail);
|
|
39422
39307
|
if (match) return {
|
|
@@ -40089,10 +39974,10 @@ process.emitWarning = ((warning, ...rest) => {
|
|
|
40089
39974
|
const asMutableCommand = (command) => {
|
|
40090
39975
|
return command;
|
|
40091
39976
|
};
|
|
40092
|
-
const
|
|
40093
|
-
if (
|
|
40094
|
-
const
|
|
40095
|
-
const extra = rawArgs.slice(
|
|
39977
|
+
const setupExtraArgError = (rawArgs, path) => {
|
|
39978
|
+
if (!["account setup", "account login"].includes(path.join(" "))) return;
|
|
39979
|
+
const setupIndex = Math.max(rawArgs.lastIndexOf("setup"), rawArgs.lastIndexOf("login"));
|
|
39980
|
+
const extra = rawArgs.slice(setupIndex + 1).filter((arg) => arg !== "--").at(0);
|
|
40096
39981
|
if (!extra) return;
|
|
40097
39982
|
const message = extra.startsWith("-") ? `Unknown option: ${extra}` : `Unknown argument: ${extra}`;
|
|
40098
39983
|
return Object.assign(new Error(message), {
|
|
@@ -40259,8 +40144,8 @@ const printUsage = async (command, rawArgs) => {
|
|
|
40259
40144
|
const usage = await commandForUsage(command, rawArgs);
|
|
40260
40145
|
printLine(`${await renderUsage(usage.command, usage.parent)}\n`);
|
|
40261
40146
|
};
|
|
40262
|
-
const createSocialCommand = (deps = createCLIDeps()) => {
|
|
40263
|
-
const accountCommand = asMutableCommand(createAccountCommand(deps));
|
|
40147
|
+
const createSocialCommand = (deps = createCLIDeps(), options = {}) => {
|
|
40148
|
+
const accountCommand = asMutableCommand(createAccountCommand(deps, options.setupCommand));
|
|
40264
40149
|
const linkedinCommand = asMutableCommand(createLinkedinCommands(deps));
|
|
40265
40150
|
const xCommand = asMutableCommand(createXCommands(deps));
|
|
40266
40151
|
const feedbackCommand = asMutableCommand(createFeedbackCommand(deps));
|
|
@@ -40312,8 +40197,8 @@ const runSocial = async ({ command = createSocialCommand(), now = Date.now, rawA
|
|
|
40312
40197
|
startedAt: now()
|
|
40313
40198
|
};
|
|
40314
40199
|
try {
|
|
40315
|
-
const
|
|
40316
|
-
if (
|
|
40200
|
+
const setupArgError = setupExtraArgError(rawArgs, path);
|
|
40201
|
+
if (setupArgError) throw setupArgError;
|
|
40317
40202
|
await runCommand(command, { rawArgs });
|
|
40318
40203
|
} catch (error) {
|
|
40319
40204
|
if (error instanceof SilentExit) return await finish(error.code, telemetry, now);
|