@@ -2,8 +2,7 @@ import { Logger } from "winston";
22import { RepoAuthCredentials , RepoWithConnections } from "./types.js" ;
33import path from 'path' ;
44import { PrismaClient , Repo } from "@sourcebot/db" ;
5- import { getTokenFromConfig as getTokenFromConfigBase } from "@sourcebot/crypto" ;
6- import { BackendException , BackendError } from "@sourcebot/error" ;
5+ import { getTokenFromConfig } from "@sourcebot/crypto" ;
76import * as Sentry from "@sentry/node" ;
87import { GithubConnectionConfig , GitlabConnectionConfig , GiteaConnectionConfig , BitbucketConnectionConfig , AzureDevOpsConnectionConfig } from '@sourcebot/schemas/v3/connection.type' ;
98import { GithubAppManager } from "./ee/githubAppManager.js" ;
@@ -24,22 +23,6 @@ export const marshalBool = (value?: boolean) => {
2423 return ! ! value ? '1' : '0' ;
2524}
2625
27- export const getTokenFromConfig = async ( token : any , orgId : number , db : PrismaClient , logger ?: Logger ) => {
28- try {
29- return await getTokenFromConfigBase ( token , orgId , db ) ;
30- } catch ( error : unknown ) {
31- if ( error instanceof Error ) {
32- const e = new BackendException ( BackendError . CONNECTION_SYNC_SECRET_DNE , {
33- message : error . message ,
34- } ) ;
35- Sentry . captureException ( e ) ;
36- logger ?. error ( error . message ) ;
37- throw e ;
38- }
39- throw error ;
40- }
41- } ;
42-
4326export const resolvePathRelativeToConfig = ( localPath : string , configPath : string ) => {
4427 let absolutePath = localPath ;
4528 if ( ! path . isAbsolute ( absolutePath ) ) {
@@ -156,7 +139,7 @@ export const getAuthCredentialsForRepo = async (repo: RepoWithConnections, db: P
156139 if ( connection . connectionType === 'github' ) {
157140 const config = connection . config as unknown as GithubConnectionConfig ;
158141 if ( config . token ) {
159- const token = await getTokenFromConfig ( config . token , connection . orgId , db , logger ) ;
142+ const token = await getTokenFromConfig ( config . token , connection . orgId , db ) ;
160143 return {
161144 hostUrl : config . url ,
162145 token,
@@ -171,7 +154,7 @@ export const getAuthCredentialsForRepo = async (repo: RepoWithConnections, db: P
171154 } else if ( connection . connectionType === 'gitlab' ) {
172155 const config = connection . config as unknown as GitlabConnectionConfig ;
173156 if ( config . token ) {
174- const token = await getTokenFromConfig ( config . token , connection . orgId , db , logger ) ;
157+ const token = await getTokenFromConfig ( config . token , connection . orgId , db ) ;
175158 return {
176159 hostUrl : config . url ,
177160 token,
@@ -187,7 +170,7 @@ export const getAuthCredentialsForRepo = async (repo: RepoWithConnections, db: P
187170 } else if ( connection . connectionType === 'gitea' ) {
188171 const config = connection . config as unknown as GiteaConnectionConfig ;
189172 if ( config . token ) {
190- const token = await getTokenFromConfig ( config . token , connection . orgId , db , logger ) ;
173+ const token = await getTokenFromConfig ( config . token , connection . orgId , db ) ;
191174 return {
192175 hostUrl : config . url ,
193176 token,
@@ -202,7 +185,7 @@ export const getAuthCredentialsForRepo = async (repo: RepoWithConnections, db: P
202185 } else if ( connection . connectionType === 'bitbucket' ) {
203186 const config = connection . config as unknown as BitbucketConnectionConfig ;
204187 if ( config . token ) {
205- const token = await getTokenFromConfig ( config . token , connection . orgId , db , logger ) ;
188+ const token = await getTokenFromConfig ( config . token , connection . orgId , db ) ;
206189 const username = config . user ?? 'x-token-auth' ;
207190 return {
208191 hostUrl : config . url ,
@@ -219,7 +202,7 @@ export const getAuthCredentialsForRepo = async (repo: RepoWithConnections, db: P
219202 } else if ( connection . connectionType === 'azuredevops' ) {
220203 const config = connection . config as unknown as AzureDevOpsConnectionConfig ;
221204 if ( config . token ) {
222- const token = await getTokenFromConfig ( config . token , connection . orgId , db , logger ) ;
205+ const token = await getTokenFromConfig ( config . token , connection . orgId , db ) ;
223206
224207 // For ADO server, multiple auth schemes may be supported. If the ADO deployment supports NTLM, the git clone will default
225208 // to this over basic auth. As a result, we cannot embed the token in the clone URL and must force basic auth by passing in the token
0 commit comments