Path: blob/main/extensions/github-authentication/src/common/env.ts
3320 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/4import { Uri } from 'vscode';5import { AuthProviderType } from '../github';67const VALID_DESKTOP_CALLBACK_SCHEMES = [8'vscode',9'vscode-insiders',10// On Windows, some browsers don't seem to redirect back to OSS properly.11// As a result, you get stuck in the auth flow. We exclude this from the12// list until we can figure out a way to fix this behavior in browsers.13// 'code-oss',14'vscode-wsl',15'vscode-exploration'16];1718export function isSupportedClient(uri: Uri): boolean {19return (20VALID_DESKTOP_CALLBACK_SCHEMES.includes(uri.scheme) ||21// vscode.dev & insiders.vscode.dev22/(?:^|\.)vscode\.dev$/.test(uri.authority) ||23// github.dev & codespaces24/(?:^|\.)github\.dev$/.test(uri.authority)25);26}2728export function isSupportedTarget(type: AuthProviderType, gheUri?: Uri): boolean {29return (30type === AuthProviderType.github ||31isHostedGitHubEnterprise(gheUri!)32);33}3435export function isHostedGitHubEnterprise(uri: Uri): boolean {36return /\.ghe\.com$/.test(uri.authority);37}383940