Lines 1-39javascript
2 * Wizard step for OAuth 2.0 (PKCE flow) authorization.
5 * 1. Read optional local/team OAuth app defaults, if present.
6 * 2. Otherwise present a "what is this?" intro pointing the user at
7 * Linear's OAuth app registration page, then prompt for `client_id`,
8 * optional `client_secret`, port, scopes.
9 * 3. Generate PKCE verifier + state, build the authorize URL.
10 * 4. Try to open the system browser; fall back to printing the URL.
11 * 5. Spin a localhost listener (or fall back to pasted-code prompt) to
12 * receive the redirect.
13 * 6. Exchange code for tokens.
14 * 7. Validate by calling `viewer { ... }` with the new bearer token.
15 * 8. Persist `oauth.json` to the active profile.
17 * Idempotent: if a fresh `oauth.json` already exists, offer keep / re-auth /
18 * revoke before doing anything else.
20import { spawn } from "node:child_process";
21import { checkbox, input, password, select } from "@inquirer/prompts";
22import { readTeamOAuthConfig } from "../../auth/oauth-app-config.js";
23import { DEFAULT_CALLBACK_PATH, runLocalhostCallback, } from "../../auth/oauth-callback.js";
24import { ALL_SCOPES, buildAuthorizeUrl, DEFAULT_SCOPES, generatePkce, generateState, SCOPE_DESCRIPTIONS, validateActorScopes, validateScopes, } from "../../auth/oauth-client.js";
25import { promptForPastedCode } from "../../auth/oauth-headless.js";
26import { clearOAuthState, OAUTH_STATE_VERSION, readOAuthState, writeOAuthState, } from "../../auth/oauth-storage.js";
27import { exchangeCodeForTokens, revokeToken, } from "../../auth/oauth-token.js";
28import { GraphQLService } from "../../utils/graphql-service.js";
29import { sanitizeForLog } from "./token.js";
30const DEFAULT_PORT = 8765;
31const REGISTRATION_URL = "https://linear.app/settings/api/applications/new";
32const VIEWER_QUERY = /* GraphQL */ `
HighSandbox Evasion Gated Capability
Source gates dangerous network, credential, or execution behavior behind CI, host, platform, time, or geo fingerprint checks.
dist/commands/init/oauth.jsView on unpkg · L19