Theia API Documentation v1.76.0
    Preparing search index...

    Authentication against GitHub Copilot, performed by the official Copilot CLI on our behalf.

    Access to the Copilot features is granted per OAuth application and the built-in Theia OAuth app is not entitled for them, whereas the Copilot CLI is. This provider therefore does not run an OAuth flow of its own but drives copilot login --device-code and reports its progress, so that the familiar sign-in dialog can be used.

    The credentials end up owned by this application rather than by the CLI: the login is run against a private, temporary Copilot home with the system keychain disabled, so that the CLI writes its token there instead of into the user's keyring. The token is then moved into CopilotCredentialStore and the temporary home is removed. Signing out consequently only has to delete our own entry, and never touches credentials of the user's machine such as their keyring entries or their GitHub CLI sign-in.

    Index

    Constructors

    Properties

    cliLocator: CopilotCliLocator
    credentialStore: CopilotCredentialStore
    logger: ILogger
    loginAccountLabel: undefined | string
    loginEnterpriseUrl: undefined | string
    loginHome: undefined | string
    loginProcess: undefined | ChildProcess
    loginResult: undefined | Deferred<boolean>
    sdkClientProvider: CopilotSdkClientProvider

    Methods

    • Terminates a login that is still in progress, if any.

      Resolves once the token the CLI may already have written has been removed again, so that a caller which cancels a sign-in can rely on nothing being left behind in plain text.

      Returns Promise<void>

    • Builds the environment for the login process.

      The CLI is pointed at a private home and its use of the system keychain is disabled, so that it persists the token where we can take it over instead of in the keyring of the user. Tokens from the environment are removed so that a sign-in always establishes fresh credentials rather than silently succeeding with something the user configured elsewhere.

      Parameters

      • home: string
      • noopBrowser: string

      Returns Record<string, string | undefined>

    • Writes the opener the CLI is pointed at instead of a real browser, and returns its path.

      The CLI opens a browser whenever it believes one is available, even for the device code flow, and prefers the command in BROWSER over the opener of the platform. Pointing it at a script that does nothing is therefore the reliable way to keep the flow in the dialog, where the user can read and copy the code. Opening a browser would also be wrong whenever the backend does not run on the user's own machine.

      Parameters

      • home: string

      Returns Promise<string>

    • Describes why a login failed, based on what the CLI reported.

      A line that names the problem is preferred, and the tail of the output is used otherwise, since the wording of the CLI is not stable enough to rely on and a bare exit code is not diagnosable.

      Parameters

      • output: string

      Returns undefined | string

    • Searches the configuration the CLI wrote in its private home for the persisted token.

      The file and the field the CLI uses are not part of its public interface, so every JSON file it wrote is searched for a value shaped like a GitHub token rather than relying on a fixed layout.

      Parameters

      • home: string

      Returns Promise<undefined | string>

    • Searches text for a value shaped like a GitHub token.

      Only the files the CLI wrote into the private home of this sign-in are searched, so anything shaped like a token in them is the token that was just obtained.

      Parameters

      • text: string

      Returns undefined | string

    • Reports whether this application holds Copilot credentials.

      Deliberately based on our own store rather than on what the Copilot CLI reports: the CLI also accepts a token from the environment or the sign-in of the GitHub CLI, and neither of those is a sign-in of this application, so neither may make it appear signed in.

      Returns Promise<CopilotAuthState>

    • The files of the private home that are inspected for the token.

      The logs are skipped, and the configuration the CLI writes is not plain JSON but carries comments, so the files are searched as text rather than parsed.

      Parameters

      • home: string

      Returns Promise<string[]>

    • Stops a sign-in that is still in progress when the connection this provider belongs to closes. Unbinding a container runs @preDestroy rather than dispose, matching the client provider. Without this, the copilot login child process and the temporary home holding its token would be left behind.

      Returns void

    • Turns the configured GitHub Enterprise deployment into the URL the CLI is pointed at.

      A bare domain is the expected form and gets a scheme. Plain HTTP is upgraded rather than passed on: the sign-in carries credentials, and a host that only matched "http" at the start of its name, such as httpbin.example.com, must not be mistaken for a URL that already has a scheme.

      Parameters

      • enterpriseUrl: string

      Returns string