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