This repository was archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathcreate-js-context.ts
99 lines (92 loc) · 3.46 KB
/
create-js-context.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import { noOpTelemetryRecorder } from '@sourcegraph/shared/src/telemetry'
import type { SourcegraphContext } from '../../src/jscontext'
import { ENVIRONMENT_CONFIG } from './environment-config'
import { getSiteConfig } from './get-site-config'
// TODO: share with `client/web/src/integration/jscontext` which is not included into `tsconfig.json` now.
export const builtinAuthProvider = {
serviceType: 'builtin' as const,
serviceID: '',
clientID: '',
displayName: 'Builtin username-password authentication',
isBuiltin: true,
authenticationURL: '',
noSignIn: false,
requiredForAuthz: false,
}
// Create dummy JS context that will be added to index.html when `WEB_BUILDER_SERVE_INDEX` is set to true.
export const createJsContext = ({ sourcegraphBaseUrl }: { sourcegraphBaseUrl: string }): SourcegraphContext => {
const siteConfig = getSiteConfig()
if (siteConfig?.authProviders) {
siteConfig.authProviders.unshift(builtinAuthProvider)
}
const jsContext: SourcegraphContext = {
currentUser: null,
temporarySettings: null,
externalURL: sourcegraphBaseUrl,
accessTokensAllow: 'all-users-create',
accessTokensAllowNoExpiration: false,
accessTokensExpirationDaysDefault: 90,
accessTokensExpirationDaysOptions: [7, 14, 30, 60, 90],
allowSignup: true,
batchChangesEnabled: true,
applianceManaged: false,
batchChangesDisableWebhooksWarning: false,
batchChangesWebhookLogsEnabled: true,
executorsEnabled: false,
codyEnabledOnInstance: true,
codyEnabledForCurrentUser: true,
codyRequiresVerifiedEmail: false,
codeSearchEnabledOnInstance: true,
codeIntelAutoIndexingEnabled: false,
codeIntelAutoIndexingAllowGlobalPolicies: false,
codeIntelligenceEnabled: true,
codeIntelRankingDocumentReferenceCountsEnabled: false,
codeInsightsEnabled: true,
codeMonitoringEnabled: true,
searchJobsEnabled: true,
productResearchPageEnabled: true,
assetsRoot: '/.assets',
deployType: 'dev',
debug: true,
emailEnabled: false,
experimentalFeatures: {},
extsvcConfigAllowEdits: false,
extsvcConfigFileExists: false,
isAuthenticatedUser: true,
needServerRestart: false,
needsSiteInit: false,
needsRepositoryConfiguration: false,
notebooksEnabled: true,
ownEnabled: true,
resetPasswordEnabled: true,
runningOnMacOS: true,
searchAggregationEnabled: true,
searchContextsEnabled: true,
sentryDSN: null,
site: {
'update.channel': 'release',
},
siteID: 'TestSiteID',
siteGQLID: 'TestGQLSiteID',
sourcegraphDotComMode: ENVIRONMENT_CONFIG.SOURCEGRAPHDOTCOM_MODE,
userAgentIsBot: false,
version: '0.0.0',
xhrHeaders: {},
authProviders: [builtinAuthProvider],
authMinPasswordLength: 12,
authPasswordPolicy: {
enabled: false,
numberOfSpecialCharacters: 2,
requireAtLeastOneNumber: true,
requireUpperandLowerCase: true,
},
openTelemetry: {
endpoint: ENVIRONMENT_CONFIG.CLIENT_OTEL_EXPORTER_OTLP_ENDPOINT,
},
telemetryRecorder: noOpTelemetryRecorder,
primaryLoginProvidersCount: 5,
// Site-config overrides default JS context
...siteConfig,
}
return jsContext
}