@usesocial/cli 0.18.1 → 0.18.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +10 -8
- package/dist/index.mjs +188 -296
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -11283,12 +11283,19 @@ pgTable("proxy_call_logs", {
|
|
|
11283
11283
|
retryAfterSeconds: integer("retry_after_seconds"),
|
|
11284
11284
|
costBPS: integer("cost_bps").notNull().default(0),
|
|
11285
11285
|
billedBPS: integer("billed_bps").notNull().default(0),
|
|
11286
|
+
usageUnits: integer("usage_units").notNull().default(0),
|
|
11287
|
+
entityId: text$1("entity_id"),
|
|
11288
|
+
meteringLockId: text$1("metering_lock_id"),
|
|
11289
|
+
meteringLockExpiresAt: timestamptz("metering_lock_expires_at"),
|
|
11290
|
+
meteredAt: timestamptz("metered_at"),
|
|
11286
11291
|
latencyMs: integer("latency_ms").notNull(),
|
|
11287
11292
|
createdAt: timestamptz("created_at").notNull().defaultNow()
|
|
11288
11293
|
}, (table) => [
|
|
11289
11294
|
index("proxy_call_logs_user_created_idx").on(table.userId, table.createdAt.desc()),
|
|
11290
11295
|
index("proxy_call_logs_user_platform_created_idx").on(table.userId, table.platform, table.createdAt.desc()),
|
|
11291
11296
|
index("proxy_call_logs_user_billing_period_idx").on(table.userId, table.createdAt).where(sql`${table.responseStatus} >= 200 and ${table.responseStatus} < 300`),
|
|
11297
|
+
uniqueIndex("proxy_call_logs_metering_lock_id_key").on(table.meteringLockId).where(sql`${table.meteringLockId} is not null`),
|
|
11298
|
+
index("proxy_call_logs_pending_metering_idx").on(table.createdAt).where(sql`${table.meteredAt} is null and ${table.billedBPS} > 0 and ${table.usageUnits} > 0`),
|
|
11292
11299
|
check("proxy_call_logs_surface_check", sqlCheckIn(table.surface, PROXY_SURFACES)),
|
|
11293
11300
|
check("proxy_call_logs_cache_status_check", sqlCheckIn(table.cacheStatus, PROXY_CACHE_STATUSES))
|
|
11294
11301
|
]);
|
|
@@ -22601,16 +22608,16 @@ const resolveLinkedinDisconnectAccount = (accounts, identifier) => {
|
|
|
22601
22608
|
const LINKEDIN_PLATFORM = "linkedin";
|
|
22602
22609
|
const DEFAULT_POLL_INTERVAL_MS = 2e3;
|
|
22603
22610
|
const DEFAULT_POLL_TIMEOUT_MS = 12e4;
|
|
22604
|
-
const SEAT_POLL_TIMEOUT_MS$
|
|
22611
|
+
const SEAT_POLL_TIMEOUT_MS$1 = 600 * 1e3;
|
|
22605
22612
|
const surfaceURL$1 = (deps, url, options = {}) => {
|
|
22606
22613
|
const log = deps.log ?? console.error;
|
|
22607
22614
|
if (options.log ?? true) log(`Open this URL: ${url}`);
|
|
22608
22615
|
};
|
|
22609
|
-
const pollForSeat$
|
|
22616
|
+
const pollForSeat$1 = async (deps) => {
|
|
22610
22617
|
const intervalMs = deps.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
22611
22618
|
const sleep = deps.sleep ?? setTimeout$1;
|
|
22612
22619
|
const startedAt = Date.now();
|
|
22613
|
-
while (Date.now() - startedAt < SEAT_POLL_TIMEOUT_MS$
|
|
22620
|
+
while (Date.now() - startedAt < SEAT_POLL_TIMEOUT_MS$1) {
|
|
22614
22621
|
if ((await deps.client.billing.status()).canConnect) return;
|
|
22615
22622
|
await sleep(intervalMs);
|
|
22616
22623
|
}
|
|
@@ -22621,7 +22628,7 @@ const prepareAccountConnect$1 = async (deps) => {
|
|
|
22621
22628
|
const status = await deps.client.billing.prepareAccountConnect();
|
|
22622
22629
|
if (status.canConnect) return;
|
|
22623
22630
|
if (status.paymentURL) surfaceURL$1(deps, status.paymentURL);
|
|
22624
|
-
await pollForSeat$
|
|
22631
|
+
await pollForSeat$1(deps);
|
|
22625
22632
|
};
|
|
22626
22633
|
const accountUsername = (account) => account.username.replace(/^@+/, "");
|
|
22627
22634
|
const listLinkedinLifecycleAccounts = (deps, includeDisconnected = true) => deps.client.listAccounts({
|
|
@@ -22708,7 +22715,7 @@ const disconnectLinkedinAccount = async (deps, identifier) => {
|
|
|
22708
22715
|
//#endregion
|
|
22709
22716
|
//#region ../../packages/x/src/cli/lifecycle.ts
|
|
22710
22717
|
const CONNECT_TIMEOUT_MS = 300 * 1e3;
|
|
22711
|
-
const SEAT_POLL_TIMEOUT_MS
|
|
22718
|
+
const SEAT_POLL_TIMEOUT_MS = 600 * 1e3;
|
|
22712
22719
|
const POLL_INTERVAL_MS = 2 * 1e3;
|
|
22713
22720
|
var XConnectTimedOut = class extends h("XConnectTimedOut")() {
|
|
22714
22721
|
constructor(args) {
|
|
@@ -22723,7 +22730,7 @@ var XBillingSeatTimedOut = class extends h("XBillingSeatTimedOut")() {
|
|
|
22723
22730
|
constructor() {
|
|
22724
22731
|
super({
|
|
22725
22732
|
operation: "prepareAccountConnect",
|
|
22726
|
-
timeoutMS: SEAT_POLL_TIMEOUT_MS
|
|
22733
|
+
timeoutMS: SEAT_POLL_TIMEOUT_MS,
|
|
22727
22734
|
message: "billing_seat_timed_out"
|
|
22728
22735
|
});
|
|
22729
22736
|
this.name = "XBillingSeatTimedOut";
|
|
@@ -22791,11 +22798,11 @@ const authURLFor = async (deps, operation) => ({
|
|
|
22791
22798
|
url: deps.handshakeAuthURL ? await deps.handshakeAuthURL(operation) : await operation(),
|
|
22792
22799
|
openingLogged: deps.handshakeAuthURL !== void 0
|
|
22793
22800
|
});
|
|
22794
|
-
const pollForSeat
|
|
22801
|
+
const pollForSeat = async (deps) => {
|
|
22795
22802
|
const sleep = deps.sleep ?? defaultSleep;
|
|
22796
22803
|
const now = deps.now ?? Date.now;
|
|
22797
22804
|
const startedAt = now();
|
|
22798
|
-
while (now() - startedAt < SEAT_POLL_TIMEOUT_MS
|
|
22805
|
+
while (now() - startedAt < SEAT_POLL_TIMEOUT_MS) {
|
|
22799
22806
|
if ((await deps.client.billing.status()).canConnect) return G.ok();
|
|
22800
22807
|
await sleep(POLL_INTERVAL_MS);
|
|
22801
22808
|
}
|
|
@@ -22806,7 +22813,7 @@ const prepareAccountConnect = async (deps) => {
|
|
|
22806
22813
|
const status = await deps.client.billing.prepareAccountConnect();
|
|
22807
22814
|
if (status.canConnect) return G.ok();
|
|
22808
22815
|
if (status.paymentURL) surfaceURL(deps, status.paymentURL);
|
|
22809
|
-
return pollForSeat
|
|
22816
|
+
return pollForSeat(deps);
|
|
22810
22817
|
};
|
|
22811
22818
|
const accountKey = (account) => account.profileId;
|
|
22812
22819
|
const timestampMS = (value) => value instanceof Date ? value.getTime() : void 0;
|
|
@@ -24272,7 +24279,7 @@ function createEnv(opts) {
|
|
|
24272
24279
|
}
|
|
24273
24280
|
//#endregion
|
|
24274
24281
|
//#region package.json
|
|
24275
|
-
var version$1 = "0.18.
|
|
24282
|
+
var version$1 = "0.18.3";
|
|
24276
24283
|
//#endregion
|
|
24277
24284
|
//#region src/lib/env.ts
|
|
24278
24285
|
const URLWithTrailingSlash = url().transform(ensureTrailingSlash);
|
|
@@ -24453,7 +24460,7 @@ const retryContextKey = (request) => `${request.method} ${request.url}`;
|
|
|
24453
24460
|
const isLinkedInRateLimitError = (error) => error instanceof HTTPError && error.response.status === 429 && isLinkedInProxyRequest(error.request);
|
|
24454
24461
|
const readBearerToken = async () => {
|
|
24455
24462
|
const credentials = await readCredentials();
|
|
24456
|
-
if (!credentials?.accessToken) throw new AuthError("Not logged in. Run `social account
|
|
24463
|
+
if (!credentials?.accessToken) throw new AuthError("Not logged in. Run `social account setup` first.");
|
|
24457
24464
|
return credentials.accessToken;
|
|
24458
24465
|
};
|
|
24459
24466
|
const linkedInRateLimitFallbackDelaySeconds = (retryCount) => Math.min(2 ** Math.max(0, retryCount - 1), LINKEDIN_RATE_LIMIT_MAX_FALLBACK_SECONDS);
|
|
@@ -30616,8 +30623,8 @@ const FIRST_RUN_NOTICE = [
|
|
|
30616
30623
|
const ALLOWLISTED_MESSAGES = /* @__PURE__ */ new Set([
|
|
30617
30624
|
"Cancelled.",
|
|
30618
30625
|
"Invalid credentials.",
|
|
30619
|
-
"Not logged in. Run `social account
|
|
30620
|
-
"Session expired before login finished. Run `social account
|
|
30626
|
+
"Not logged in. Run `social account setup` first.",
|
|
30627
|
+
"Session expired before login finished. Run `social account setup` again."
|
|
30621
30628
|
]);
|
|
30622
30629
|
const hasCittyErrorShape = (error) => error instanceof Error && error.name === "CLIError" && "code" in error && typeof error.code === "string";
|
|
30623
30630
|
const errorName = (error) => error instanceof Error && error.name ? error.name : "Error";
|
|
@@ -32169,7 +32176,7 @@ const pollDeviceTokenOnce = async (deviceCode, poster = authAPI) => {
|
|
|
32169
32176
|
/**
|
|
32170
32177
|
* Device-authorization onboarding state machine.
|
|
32171
32178
|
*
|
|
32172
|
-
* Non-TTY `social account
|
|
32179
|
+
* Non-TTY `social account setup` is a poll: each invocation is a fresh process,
|
|
32173
32180
|
* so the in-flight device code is persisted to `~/.social/device-login*.json`
|
|
32174
32181
|
* (namespaced by API URL exactly like credentials). The engine advances and
|
|
32175
32182
|
* reports onboarding state as a discriminated union — a skill can call login
|
|
@@ -32214,6 +32221,7 @@ const defaultClearPending = async (apiURL) => {
|
|
|
32214
32221
|
const resolveDeps = (deps) => ({
|
|
32215
32222
|
now: deps.now ?? Date.now,
|
|
32216
32223
|
apiURL: deps.apiURL ?? env.SOCIAL_API_URL,
|
|
32224
|
+
webURL: deps.webURL ?? env.SOCIAL_WEB_URL,
|
|
32217
32225
|
poster: deps.poster,
|
|
32218
32226
|
readPending: deps.readPending ?? defaultReadPending,
|
|
32219
32227
|
writePending: deps.writePending ?? defaultWritePending,
|
|
@@ -32231,9 +32239,15 @@ const accountFromCredentials = (credentials) => ({
|
|
|
32231
32239
|
scope: credentials.scope ?? null,
|
|
32232
32240
|
expiresAt: credentials.expiresAt ? new Date(credentials.expiresAt).toISOString() : null
|
|
32233
32241
|
});
|
|
32234
|
-
const
|
|
32242
|
+
const trustedVerificationURL = (value, webURL) => {
|
|
32243
|
+
const candidate = new URL(value);
|
|
32244
|
+
const trusted = new URL(webURL);
|
|
32245
|
+
if (candidate.origin !== trusted.origin || candidate.username.length > 0 || candidate.password.length > 0) throw new Error("untrusted_device_verification_url");
|
|
32246
|
+
return candidate.toString();
|
|
32247
|
+
};
|
|
32248
|
+
const pendingState = (pending, webURL) => ({
|
|
32235
32249
|
status: "pending_approval",
|
|
32236
|
-
verificationURL: pending.verificationURL,
|
|
32250
|
+
verificationURL: trustedVerificationURL(pending.verificationURL, webURL),
|
|
32237
32251
|
userCode: pending.userCode,
|
|
32238
32252
|
expiresAt: pending.expiresAt,
|
|
32239
32253
|
scope: pending.scope
|
|
@@ -32241,17 +32255,18 @@ const pendingState = (pending) => ({
|
|
|
32241
32255
|
const startDeviceFlow = async (scope, resolved) => {
|
|
32242
32256
|
const deviceCode = await createDeviceCode(scope, resolved.poster);
|
|
32243
32257
|
const expiresAt = new Date(resolved.now() + deviceCode.expires_in * 1e3).toISOString();
|
|
32258
|
+
const verificationURL = trustedVerificationURL(deviceCode.verification_uri_complete, resolved.webURL);
|
|
32244
32259
|
const pending = {
|
|
32245
32260
|
version: STATE_VERSION,
|
|
32246
32261
|
apiURL: resolved.apiURL,
|
|
32247
32262
|
scope,
|
|
32248
32263
|
deviceCode: deviceCode.device_code,
|
|
32249
32264
|
userCode: deviceCode.user_code,
|
|
32250
|
-
verificationURL
|
|
32265
|
+
verificationURL,
|
|
32251
32266
|
expiresAt
|
|
32252
32267
|
};
|
|
32253
32268
|
await resolved.writePending(pending);
|
|
32254
|
-
return pendingState(pending);
|
|
32269
|
+
return pendingState(pending, resolved.webURL);
|
|
32255
32270
|
};
|
|
32256
32271
|
/**
|
|
32257
32272
|
* Advance the non-TTY device login by exactly one step.
|
|
@@ -32275,7 +32290,7 @@ const advanceDeviceLogin = async (scope, deps = {}) => {
|
|
|
32275
32290
|
return { status: "expired" };
|
|
32276
32291
|
}
|
|
32277
32292
|
const outcome = await pollDeviceTokenOnce(pending.deviceCode, resolved.poster);
|
|
32278
|
-
if (outcome.kind === "pending") return pendingState(pending);
|
|
32293
|
+
if (outcome.kind === "pending") return pendingState(pending, resolved.webURL);
|
|
32279
32294
|
if (outcome.kind === "expired") {
|
|
32280
32295
|
await resolved.clearPending(resolved.apiURL);
|
|
32281
32296
|
return { status: "expired" };
|
|
@@ -32552,56 +32567,6 @@ const parseScopeAlias = (value) => {
|
|
|
32552
32567
|
if (G.isOk(parsed)) return parsed.value;
|
|
32553
32568
|
throw new Error(parsed.error.message);
|
|
32554
32569
|
};
|
|
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
32570
|
//#endregion
|
|
32606
32571
|
//#region src/login/index.ts
|
|
32607
32572
|
const ScopeAliasOutput = _enum(CLI_SCOPE_ALIASES);
|
|
@@ -32616,37 +32581,22 @@ const LoginSeatsOutput = object({
|
|
|
32616
32581
|
used: number().int().nonnegative(),
|
|
32617
32582
|
available: number().int().nonnegative()
|
|
32618
32583
|
});
|
|
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
32584
|
const LoginOutput = discriminatedUnion("status", [
|
|
32635
32585
|
object({
|
|
32636
|
-
status: literal("
|
|
32586
|
+
status: literal("pending_billing"),
|
|
32637
32587
|
user: LoginUserOutput,
|
|
32638
32588
|
scope: ScopeAliasOutput,
|
|
32589
|
+
capabilities: array(string()),
|
|
32639
32590
|
seats: LoginSeatsOutput,
|
|
32591
|
+
checkoutURL: string(),
|
|
32640
32592
|
nextCommands: array(string())
|
|
32641
32593
|
}),
|
|
32642
32594
|
object({
|
|
32643
|
-
status: literal("
|
|
32644
|
-
message: string(),
|
|
32595
|
+
status: literal("ready"),
|
|
32645
32596
|
user: LoginUserOutput,
|
|
32646
|
-
sessionId: string(),
|
|
32647
32597
|
scope: ScopeAliasOutput,
|
|
32648
32598
|
capabilities: array(string()),
|
|
32649
|
-
|
|
32599
|
+
seats: LoginSeatsOutput,
|
|
32650
32600
|
nextCommands: array(string())
|
|
32651
32601
|
}),
|
|
32652
32602
|
object({
|
|
@@ -32657,11 +32607,6 @@ const LoginOutput = discriminatedUnion("status", [
|
|
|
32657
32607
|
scope: ScopeAliasOutput,
|
|
32658
32608
|
nextCommands: array(string())
|
|
32659
32609
|
}),
|
|
32660
|
-
object({
|
|
32661
|
-
status: literal("logged_in"),
|
|
32662
|
-
account: DeviceAccountOutput,
|
|
32663
|
-
nextCommands: array(string())
|
|
32664
|
-
}),
|
|
32665
32610
|
object({
|
|
32666
32611
|
status: literal("expired"),
|
|
32667
32612
|
message: string()
|
|
@@ -32678,60 +32623,37 @@ const LoginOutput = discriminatedUnion("status", [
|
|
|
32678
32623
|
details: unknown().optional()
|
|
32679
32624
|
})
|
|
32680
32625
|
]);
|
|
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
|
-
];
|
|
32626
|
+
const phases = [{
|
|
32627
|
+
name: "access",
|
|
32628
|
+
run: accessPhase
|
|
32629
|
+
}, {
|
|
32630
|
+
name: "sign-in",
|
|
32631
|
+
run: signInPhase
|
|
32632
|
+
}];
|
|
32699
32633
|
const errorOutput = (error) => ({
|
|
32700
32634
|
status: "error",
|
|
32701
32635
|
code: error instanceof Error ? error.name : "Error",
|
|
32702
32636
|
message: error instanceof Error ? error.message : String(error)
|
|
32703
32637
|
});
|
|
32704
32638
|
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
|
|
32639
|
+
const availableConnectCommands = (capabilities) => nextCommands.filter((command) => {
|
|
32640
|
+
const platform = command.endsWith(" linkedin") ? "linkedin" : "x";
|
|
32641
|
+
return capabilities.some((capability) => capability.startsWith(`${platform}:`));
|
|
32728
32642
|
});
|
|
32643
|
+
const setupOutputFor = (setup) => ({
|
|
32644
|
+
...setup,
|
|
32645
|
+
nextCommands: setup.status === "pending_billing" ? ["social account setup"] : availableConnectCommands(setup.capabilities)
|
|
32646
|
+
});
|
|
32647
|
+
const deviceExpiredMessage = "Sign-in expired before approval. Run `social account setup` again to restart.";
|
|
32648
|
+
const scopeUpgradeRequiresReauthorization = "Existing CLI session is read-only. Run `social account logout`, then `social account setup` to approve a new write-capable session.";
|
|
32649
|
+
const scopeAliasIncludes = (granted, requested) => granted === requested || granted === "read,write";
|
|
32650
|
+
const existingSessionSupportsScope = (session, requested) => scopeAliasIncludes(session.session.scope, requested);
|
|
32729
32651
|
const offlineOutput = () => ({
|
|
32730
32652
|
status: "error",
|
|
32731
32653
|
code: "offline",
|
|
32732
32654
|
message: "Couldn't reach the server. Check your network connection and try again."
|
|
32733
32655
|
});
|
|
32734
|
-
const loginOutputForDeviceState = (state
|
|
32656
|
+
const loginOutputForDeviceState = (state) => {
|
|
32735
32657
|
switch (state.status) {
|
|
32736
32658
|
case "pending_approval": return {
|
|
32737
32659
|
status: "pending_approval",
|
|
@@ -32739,16 +32661,9 @@ const loginOutputForDeviceState = (state, sessionScope) => {
|
|
|
32739
32661
|
userCode: state.userCode,
|
|
32740
32662
|
expiresAt: state.expiresAt,
|
|
32741
32663
|
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
|
|
32664
|
+
nextCommands: ["social account setup"]
|
|
32751
32665
|
};
|
|
32666
|
+
case "logged_in": throw new Error("Approved device login must continue through account setup.");
|
|
32752
32667
|
case "expired": return {
|
|
32753
32668
|
status: "expired",
|
|
32754
32669
|
message: deviceExpiredMessage
|
|
@@ -32759,10 +32674,10 @@ const loginOutputForDeviceState = (state, sessionScope) => {
|
|
|
32759
32674
|
};
|
|
32760
32675
|
}
|
|
32761
32676
|
};
|
|
32762
|
-
const planLoginStep = ({
|
|
32677
|
+
const planLoginStep = ({ deviceState, existing, isInteractiveTerminal, requestedScope }) => {
|
|
32763
32678
|
if (deviceState) return {
|
|
32764
32679
|
action: "printOutput",
|
|
32765
|
-
output: loginOutputForDeviceState(deviceState
|
|
32680
|
+
output: loginOutputForDeviceState(deviceState)
|
|
32766
32681
|
};
|
|
32767
32682
|
if (existing.kind === "existing") {
|
|
32768
32683
|
if (!existingSessionSupportsScope(existing.session, requestedScope)) return {
|
|
@@ -32773,15 +32688,7 @@ const planLoginStep = ({ billingSeatAvailable, deviceSessionScope, deviceState,
|
|
|
32773
32688
|
message: scopeUpgradeRequiresReauthorization
|
|
32774
32689
|
}
|
|
32775
32690
|
};
|
|
32776
|
-
|
|
32777
|
-
action: "useExistingSession",
|
|
32778
|
-
output: alreadyLoggedInOutput(existing.session),
|
|
32779
|
-
repairScope: requestedScope
|
|
32780
|
-
};
|
|
32781
|
-
return {
|
|
32782
|
-
action: "runInteractiveSeatOnly",
|
|
32783
|
-
repairScope: requestedScope
|
|
32784
|
-
};
|
|
32691
|
+
return { action: "useExistingSession" };
|
|
32785
32692
|
}
|
|
32786
32693
|
if (existing.kind === "offline") return {
|
|
32787
32694
|
action: "offline",
|
|
@@ -32794,25 +32701,12 @@ const runLogin = async (ctx, loginPhases = phases, deps = {}) => {
|
|
|
32794
32701
|
const readLocalCredentials = deps.readCredentials ?? readCredentials;
|
|
32795
32702
|
analytics.capture("login_started");
|
|
32796
32703
|
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
|
|
32704
|
+
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
32705
|
const result = await phase.run(ctx);
|
|
32799
32706
|
if (result.status !== "done") return result;
|
|
32800
32707
|
analytics.capture("login_phase_completed", { phase: phase.name });
|
|
32801
32708
|
}
|
|
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
|
-
};
|
|
32709
|
+
return setupOutputFor(await ctx.client.billing.accountSetup());
|
|
32816
32710
|
};
|
|
32817
32711
|
const loginExitCodeFor = (output) => {
|
|
32818
32712
|
if (output.status === "error") return exitCodeFor(new Error(output.message));
|
|
@@ -32826,15 +32720,16 @@ const loginExitCodeFor = (output) => {
|
|
|
32826
32720
|
*/
|
|
32827
32721
|
const createLoginCommand = (deps = {}) => {
|
|
32828
32722
|
const commandDeps = {
|
|
32829
|
-
advanceDeviceLogin: deps.advanceDeviceLogin ?? advanceDeviceLogin,
|
|
32723
|
+
advanceDeviceLogin: deps.advanceDeviceLogin ?? ((scope) => advanceDeviceLogin(scope, deps.deviceDeps)),
|
|
32830
32724
|
createClient: deps.createClient ?? createORPCAPIClient,
|
|
32725
|
+
deviceDeps: deps.deviceDeps ?? {},
|
|
32831
32726
|
isInteractiveTerminal: deps.isInteractiveTerminal ?? (() => process.stdin.isTTY === true && process.stdout.isTTY === true),
|
|
32832
32727
|
readExistingAuthSession: deps.readExistingAuthSession ?? readExistingAuthSession
|
|
32833
32728
|
};
|
|
32834
32729
|
return defineCommand({
|
|
32835
32730
|
meta: commandMeta({
|
|
32836
|
-
name: "
|
|
32837
|
-
description: "
|
|
32731
|
+
name: "setup",
|
|
32732
|
+
description: "Authenticate Social and ensure billing is ready",
|
|
32838
32733
|
contract: localCLIContract({
|
|
32839
32734
|
auth: {
|
|
32840
32735
|
interactive: true,
|
|
@@ -32861,21 +32756,15 @@ const createLoginCommand = (deps = {}) => {
|
|
|
32861
32756
|
const existing = await commandDeps.readExistingAuthSession(client);
|
|
32862
32757
|
const requestedScope = parseScopeAlias(loginArgs.scope);
|
|
32863
32758
|
const isInteractive = commandDeps.isInteractiveTerminal();
|
|
32864
|
-
const billingSeatAvailable = existing.kind === "existing" && existingSessionSupportsScope(existing.session, requestedScope) ? billingReady(await client.billing.status()) : void 0;
|
|
32865
32759
|
const plan = planLoginStep({
|
|
32866
32760
|
existing,
|
|
32867
32761
|
requestedScope,
|
|
32868
|
-
isInteractiveTerminal: isInteractive
|
|
32869
|
-
billingSeatAvailable
|
|
32762
|
+
isInteractiveTerminal: isInteractive
|
|
32870
32763
|
});
|
|
32871
32764
|
switch (plan.action) {
|
|
32872
32765
|
case "useExistingSession": {
|
|
32873
|
-
const
|
|
32874
|
-
output =
|
|
32875
|
-
...plan.output,
|
|
32876
|
-
scope: grant.scopeAlias,
|
|
32877
|
-
capabilities: grant.capabilities
|
|
32878
|
-
};
|
|
32766
|
+
const setup = await client.billing.accountSetup();
|
|
32767
|
+
output = setupOutputFor(setup);
|
|
32879
32768
|
break;
|
|
32880
32769
|
}
|
|
32881
32770
|
case "requireScopeReauth":
|
|
@@ -32883,17 +32772,6 @@ const createLoginCommand = (deps = {}) => {
|
|
|
32883
32772
|
case "printOutput":
|
|
32884
32773
|
output = plan.output;
|
|
32885
32774
|
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
32775
|
case "runInteractiveFullLogin":
|
|
32898
32776
|
output = await runLogin({
|
|
32899
32777
|
ui: createUI(true),
|
|
@@ -32903,13 +32781,17 @@ const createLoginCommand = (deps = {}) => {
|
|
|
32903
32781
|
break;
|
|
32904
32782
|
case "advanceDeviceLogin": {
|
|
32905
32783
|
const state = await commandDeps.advanceDeviceLogin(requestedScope);
|
|
32906
|
-
|
|
32784
|
+
if (state.status === "logged_in") {
|
|
32785
|
+
const approvedScope = ScopeAliasOutput.safeParse(state.account.scope);
|
|
32786
|
+
if (!(approvedScope.success && scopeAliasIncludes(approvedScope.data, requestedScope))) throw new Error("Device authorization returned an insufficient scope.");
|
|
32787
|
+
output = setupOutputFor(await client.billing.accountSetup());
|
|
32788
|
+
break;
|
|
32789
|
+
}
|
|
32907
32790
|
const devicePlan = planLoginStep({
|
|
32908
32791
|
existing,
|
|
32909
32792
|
requestedScope,
|
|
32910
32793
|
isInteractiveTerminal: isInteractive,
|
|
32911
|
-
deviceState: state
|
|
32912
|
-
deviceSessionScope: sessionScope
|
|
32794
|
+
deviceState: state
|
|
32913
32795
|
});
|
|
32914
32796
|
if (devicePlan.action !== "printOutput") throw new Error("Device login produced no printable state.");
|
|
32915
32797
|
output = devicePlan.output;
|
|
@@ -32920,21 +32802,14 @@ const createLoginCommand = (deps = {}) => {
|
|
|
32920
32802
|
output = errorOutput(error);
|
|
32921
32803
|
exitCode = exitCodeFor(error);
|
|
32922
32804
|
}
|
|
32923
|
-
if (output.status === "
|
|
32805
|
+
if (output.status === "ready") {
|
|
32924
32806
|
analytics.identifyUser(output.user.id);
|
|
32925
32807
|
analytics.capture("login_completed", {
|
|
32926
32808
|
scope: output.scope,
|
|
32927
|
-
|
|
32928
|
-
|
|
32929
|
-
seats_total: output.seats.total,
|
|
32930
|
-
seats_available: output.seats.available
|
|
32931
|
-
} : {}
|
|
32809
|
+
seats_total: output.seats.total,
|
|
32810
|
+
seats_available: output.seats.available
|
|
32932
32811
|
});
|
|
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" });
|
|
32812
|
+
} else if (output.status === "expired") analytics.capture("login_failed", { code: "expired" });
|
|
32938
32813
|
else if (output.status === "needs_input") analytics.capture("login_failed", {
|
|
32939
32814
|
code: "needs_input",
|
|
32940
32815
|
reason: output.reason
|
|
@@ -32945,7 +32820,19 @@ const createLoginCommand = (deps = {}) => {
|
|
|
32945
32820
|
}
|
|
32946
32821
|
});
|
|
32947
32822
|
};
|
|
32948
|
-
const
|
|
32823
|
+
const setupCommand = createLoginCommand();
|
|
32824
|
+
const hiddenLoginAliasFor = (command) => {
|
|
32825
|
+
const meta = {
|
|
32826
|
+
...command.meta,
|
|
32827
|
+
hidden: true,
|
|
32828
|
+
schemaHidden: true
|
|
32829
|
+
};
|
|
32830
|
+
return {
|
|
32831
|
+
...command,
|
|
32832
|
+
meta
|
|
32833
|
+
};
|
|
32834
|
+
};
|
|
32835
|
+
hiddenLoginAliasFor(setupCommand);
|
|
32949
32836
|
//#endregion
|
|
32950
32837
|
//#region src/logout.ts
|
|
32951
32838
|
const revokeServerSide = async (accessToken) => {
|
|
@@ -32987,7 +32874,7 @@ const logoutCommand = defineCommand({
|
|
|
32987
32874
|
const credentials = await readCredentials();
|
|
32988
32875
|
if (!credentials?.accessToken) {
|
|
32989
32876
|
await clearCredentials();
|
|
32990
|
-
throw new AuthError("Not logged in. Run `social account
|
|
32877
|
+
throw new AuthError("Not logged in. Run `social account setup` first.");
|
|
32991
32878
|
}
|
|
32992
32879
|
const revoked = await revokeServerSide(credentials.accessToken);
|
|
32993
32880
|
await clearCredentials();
|
|
@@ -33419,7 +33306,7 @@ const isInteractiveConnect = (deps) => deps.isInteractiveTerminal?.() === true;
|
|
|
33419
33306
|
* One non-blocking step of a connect handshake for a non-TTY caller. Returns the
|
|
33420
33307
|
* connected account if one is already linked, otherwise emits the connect URL and
|
|
33421
33308
|
* reports `pending_approval`. A repeated call re-checks and advances — the skill
|
|
33422
|
-
* polls this the same way it polls `social account
|
|
33309
|
+
* polls this the same way it polls `social account setup`.
|
|
33423
33310
|
*/
|
|
33424
33311
|
const runConnectStep = async (deps, platform, listConnected, connectURL) => {
|
|
33425
33312
|
const connected = (await listConnected()).find((account) => account.status === "connected");
|
|
@@ -33486,7 +33373,7 @@ const listConnectedAccounts = async (deps) => {
|
|
|
33486
33373
|
});
|
|
33487
33374
|
};
|
|
33488
33375
|
const defaultWhoamiOutput = () => authWhoamiOutput(createORPCAPIClient());
|
|
33489
|
-
const createAccountCommand = (deps) => {
|
|
33376
|
+
const createAccountCommand = (deps, accountSetupCommand = setupCommand) => {
|
|
33490
33377
|
const accountDefaultsClient = deps.client.accounts.default;
|
|
33491
33378
|
const defaultCommand = defineCommand({
|
|
33492
33379
|
meta: {
|
|
@@ -33542,67 +33429,79 @@ const createAccountCommand = (deps) => {
|
|
|
33542
33429
|
})
|
|
33543
33430
|
}
|
|
33544
33431
|
});
|
|
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) => {
|
|
33432
|
+
const connect = defineCommand({
|
|
33433
|
+
meta: {
|
|
33434
|
+
name: "connect",
|
|
33435
|
+
description: "Connect a LinkedIn or X account."
|
|
33436
|
+
},
|
|
33437
|
+
subCommands: {
|
|
33438
|
+
linkedin: createConnectPlatformCommand("linkedin", async () => {
|
|
33439
|
+
if (isInteractiveConnect(deps)) {
|
|
33440
|
+
await runConnectOutput(deps, connectLinkedinAccount);
|
|
33441
|
+
return;
|
|
33442
|
+
}
|
|
33443
|
+
await runConnectStep(deps, "linkedin", () => listLinkedinLifecycleAccounts(deps), () => createLinkedinConnectURL(deps));
|
|
33444
|
+
}),
|
|
33445
|
+
x: createConnectPlatformCommand("x", async () => {
|
|
33446
|
+
if (isInteractiveConnect(deps)) {
|
|
33588
33447
|
await runConnectOutput(deps, async (connectDeps) => {
|
|
33589
|
-
const result = await
|
|
33448
|
+
const result = await connectXAccount(connectDeps);
|
|
33590
33449
|
if (G.isError(result)) throwXLifecycleError(result.error);
|
|
33591
33450
|
return result.value;
|
|
33592
33451
|
});
|
|
33593
|
-
|
|
33594
|
-
|
|
33595
|
-
|
|
33596
|
-
|
|
33597
|
-
|
|
33598
|
-
|
|
33599
|
-
|
|
33600
|
-
}
|
|
33601
|
-
|
|
33602
|
-
|
|
33603
|
-
|
|
33604
|
-
|
|
33605
|
-
|
|
33452
|
+
return;
|
|
33453
|
+
}
|
|
33454
|
+
await runConnectStep(deps, "x", async () => {
|
|
33455
|
+
const result = await listXLifecycleAccounts(deps, true);
|
|
33456
|
+
if (G.isError(result)) throwXLifecycleError(result.error);
|
|
33457
|
+
return result.value;
|
|
33458
|
+
}, () => createXConnectURL(deps));
|
|
33459
|
+
})
|
|
33460
|
+
}
|
|
33461
|
+
});
|
|
33462
|
+
const reconnect = defineCommand({
|
|
33463
|
+
meta: {
|
|
33464
|
+
name: "reconnect",
|
|
33465
|
+
description: "Reconnect a LinkedIn or X account."
|
|
33466
|
+
},
|
|
33467
|
+
subCommands: {
|
|
33468
|
+
linkedin: createAccountPlatformCommand("linkedin", "Reconnect a LinkedIn account.", async (args) => {
|
|
33469
|
+
await runConnectOutput(deps, (connectDeps) => reconnectLinkedinAccount(connectDeps, String(args.account)));
|
|
33470
|
+
}, { accountArg: linkedinReconnectAccountArg }),
|
|
33471
|
+
x: createAccountPlatformCommand("x", "Reconnect an X account.", async (args) => {
|
|
33472
|
+
await runConnectOutput(deps, async (connectDeps) => {
|
|
33473
|
+
const result = await reconnectXAccount(connectDeps, { account: String(args.account) });
|
|
33474
|
+
if (G.isError(result)) throwXLifecycleError(result.error);
|
|
33475
|
+
return result.value;
|
|
33476
|
+
});
|
|
33477
|
+
}, { accountArg: xAccountArg })
|
|
33478
|
+
}
|
|
33479
|
+
});
|
|
33480
|
+
const disconnect = defineCommand({
|
|
33481
|
+
meta: {
|
|
33482
|
+
name: "disconnect",
|
|
33483
|
+
description: "Disconnect a LinkedIn or X account."
|
|
33484
|
+
},
|
|
33485
|
+
subCommands: {
|
|
33486
|
+
linkedin: createAccountPlatformCommand("linkedin", "Disconnect a LinkedIn account.", async (args) => {
|
|
33487
|
+
const result = await disconnectLinkedinAccount(deps, String(args.account));
|
|
33488
|
+
await writeOutput(deps, result);
|
|
33489
|
+
}, { contract: writeCLIContract({
|
|
33490
|
+
outputSchema: AccountDisconnectOutput,
|
|
33491
|
+
idempotency: "non-idempotent",
|
|
33492
|
+
hazard: advisoryHazard("destructive"),
|
|
33493
|
+
hazards: [{
|
|
33494
|
+
code: "account_disconnect",
|
|
33495
|
+
message: "Destructive account disconnect; requires an exact account identifier."
|
|
33496
|
+
}]
|
|
33497
|
+
}) }),
|
|
33498
|
+
x: createAccountPlatformCommand("x", "Disconnect an X account.", async (args) => {
|
|
33499
|
+
const result = await disconnectXAccount(deps, String(args.account));
|
|
33500
|
+
if (G.isError(result)) throwXLifecycleError(result.error);
|
|
33501
|
+
await writeOutput(deps, result.value);
|
|
33502
|
+
}, {
|
|
33503
|
+
accountArg: xAccountArg,
|
|
33504
|
+
contract: writeCLIContract({
|
|
33606
33505
|
outputSchema: AccountDisconnectOutput,
|
|
33607
33506
|
idempotency: "non-idempotent",
|
|
33608
33507
|
hazard: advisoryHazard("destructive"),
|
|
@@ -33610,25 +33509,17 @@ const createAccountCommand = (deps) => {
|
|
|
33610
33509
|
code: "account_disconnect",
|
|
33611
33510
|
message: "Destructive account disconnect; requires an exact account identifier."
|
|
33612
33511
|
}]
|
|
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
33512
|
})
|
|
33630
|
-
}
|
|
33631
|
-
}
|
|
33513
|
+
})
|
|
33514
|
+
}
|
|
33515
|
+
});
|
|
33516
|
+
const subCommands = {
|
|
33517
|
+
setup: accountSetupCommand,
|
|
33518
|
+
login: hiddenLoginAliasFor(accountSetupCommand),
|
|
33519
|
+
logout: logoutCommand,
|
|
33520
|
+
connect,
|
|
33521
|
+
reconnect,
|
|
33522
|
+
disconnect,
|
|
33632
33523
|
default: defaultCommand,
|
|
33633
33524
|
billing: createBillingCommand(deps),
|
|
33634
33525
|
usage: createUsageCommand(deps),
|
|
@@ -39115,6 +39006,7 @@ const pathPartsFrom = (...values) => {
|
|
|
39115
39006
|
const commandName = (command, fallback) => typeof command.meta?.name === "string" ? command.meta.name : fallback;
|
|
39116
39007
|
const commandDescription = (command) => typeof command.meta?.description === "string" ? command.meta.description : "";
|
|
39117
39008
|
const isHiddenCommand = (command) => command.meta?.hidden === true;
|
|
39009
|
+
const isSchemaHiddenCommand = (command) => command.meta?.schemaHidden === true;
|
|
39118
39010
|
const inputSourceFor = (command) => command.meta?.stdin === true ? { inputSource: "stdin" } : {};
|
|
39119
39011
|
const isRecord = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
39120
39012
|
const childCommandsFor = (command) => ({
|
|
@@ -39416,7 +39308,7 @@ const commandAtPath = (command, path) => {
|
|
|
39416
39308
|
const resolved = [];
|
|
39417
39309
|
for (const [index, part] of parts.entries()) {
|
|
39418
39310
|
const next = childCommandsFor(current)[part];
|
|
39419
|
-
if (!next) {
|
|
39311
|
+
if (!next || isSchemaHiddenCommand(next)) {
|
|
39420
39312
|
const tail = parts.slice(index);
|
|
39421
39313
|
const match = positionalPathMatch(current, resolved, tail);
|
|
39422
39314
|
if (match) return {
|
|
@@ -40089,10 +39981,10 @@ process.emitWarning = ((warning, ...rest) => {
|
|
|
40089
39981
|
const asMutableCommand = (command) => {
|
|
40090
39982
|
return command;
|
|
40091
39983
|
};
|
|
40092
|
-
const
|
|
40093
|
-
if (
|
|
40094
|
-
const
|
|
40095
|
-
const extra = rawArgs.slice(
|
|
39984
|
+
const setupExtraArgError = (rawArgs, path) => {
|
|
39985
|
+
if (!["account setup", "account login"].includes(path.join(" "))) return;
|
|
39986
|
+
const setupIndex = Math.max(rawArgs.lastIndexOf("setup"), rawArgs.lastIndexOf("login"));
|
|
39987
|
+
const extra = rawArgs.slice(setupIndex + 1).filter((arg) => arg !== "--").at(0);
|
|
40096
39988
|
if (!extra) return;
|
|
40097
39989
|
const message = extra.startsWith("-") ? `Unknown option: ${extra}` : `Unknown argument: ${extra}`;
|
|
40098
39990
|
return Object.assign(new Error(message), {
|
|
@@ -40259,8 +40151,8 @@ const printUsage = async (command, rawArgs) => {
|
|
|
40259
40151
|
const usage = await commandForUsage(command, rawArgs);
|
|
40260
40152
|
printLine(`${await renderUsage(usage.command, usage.parent)}\n`);
|
|
40261
40153
|
};
|
|
40262
|
-
const createSocialCommand = (deps = createCLIDeps()) => {
|
|
40263
|
-
const accountCommand = asMutableCommand(createAccountCommand(deps));
|
|
40154
|
+
const createSocialCommand = (deps = createCLIDeps(), options = {}) => {
|
|
40155
|
+
const accountCommand = asMutableCommand(createAccountCommand(deps, options.setupCommand));
|
|
40264
40156
|
const linkedinCommand = asMutableCommand(createLinkedinCommands(deps));
|
|
40265
40157
|
const xCommand = asMutableCommand(createXCommands(deps));
|
|
40266
40158
|
const feedbackCommand = asMutableCommand(createFeedbackCommand(deps));
|
|
@@ -40312,8 +40204,8 @@ const runSocial = async ({ command = createSocialCommand(), now = Date.now, rawA
|
|
|
40312
40204
|
startedAt: now()
|
|
40313
40205
|
};
|
|
40314
40206
|
try {
|
|
40315
|
-
const
|
|
40316
|
-
if (
|
|
40207
|
+
const setupArgError = setupExtraArgError(rawArgs, path);
|
|
40208
|
+
if (setupArgError) throw setupArgError;
|
|
40317
40209
|
await runCommand(command, { rawArgs });
|
|
40318
40210
|
} catch (error) {
|
|
40319
40211
|
if (error instanceof SilentExit) return await finish(error.code, telemetry, now);
|