sourcegraph/client/web/dev/utils/create-js-context.ts
Erik Seliger e1004086f4
Remove externalServiceUserMode configuration (#57445)
Those services are no longer supported, just removing some more leftovers of that.
2023-10-12 05:30:26 +02:00

85 lines
2.9 KiB
TypeScript

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: '',
}
// 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',
allowSignup: true,
batchChangesEnabled: true,
batchChangesDisableWebhooksWarning: false,
batchChangesWebhookLogsEnabled: true,
executorsEnabled: false,
codyEnabled: true,
codyEnabledForCurrentUser: true,
codyRequiresVerifiedEmail: false,
codeIntelAutoIndexingEnabled: false,
codeIntelAutoIndexingAllowGlobalPolicies: false,
codeInsightsEnabled: true,
productResearchPageEnabled: true,
assetsRoot: '/.assets',
deployType: 'dev',
debug: true,
emailEnabled: false,
experimentalFeatures: {},
extsvcConfigAllowEdits: false,
extsvcConfigFileExists: false,
isAuthenticatedUser: true,
needServerRestart: false,
needsSiteInit: false,
needsRepositoryConfiguration: false,
resetPasswordEnabled: true,
runningOnMacOS: true,
sentryDSN: null,
site: {
'update.channel': 'release',
},
siteID: 'TestSiteID',
siteGQLID: 'TestGQLSiteID',
sourcegraphDotComMode: ENVIRONMENT_CONFIG.SOURCEGRAPHDOTCOM_MODE,
codyAppMode: false,
srcServeGitUrl: 'http://127.0.0.1:3434',
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,
},
embeddingsEnabled: false,
primaryLoginProvidersCount: 5,
// Site-config overrides default JS context
...siteConfig,
}
return jsContext
}