in runtimes/runtimes/auth/auth.ts [43:90]
private credentialsDeleteHandler?: (type: CredentialsType) => void
constructor(
private readonly connection: Connection,
lspRouter: LspRouter,
key?: string,
encoding?: CredentialsEncoding
) {
if (key) {
this.key = Buffer.from(key, 'base64')
this.credentialsEncoding = encoding
}
this.lspRouter = lspRouter
this.credentialsProvider = {
getCredentials: (type: CredentialsType): Credentials | undefined => {
if (type === 'iam') {
return this.iamCredentials
}
if (type === 'bearer') {
return this.bearerCredentials
}
throw new Error(`Unsupported credentials type: ${type}`)
},
hasCredentials: (type: CredentialsType): boolean => {
if (type === 'iam') {
return this.iamCredentials !== undefined
}
if (type === 'bearer') {
return this.bearerCredentials !== undefined
}
throw new Error(`Unsupported credentials type: ${type}`)
},
getConnectionMetadata: () => {
return this.connectionMetadata
},
getConnectionType: () => {
const startUrl = this.connectionMetadata?.sso?.startUrl
return !startUrl ? 'none' : startUrl.includes(BUILDER_ID_START_URL) ? 'builderId' : 'identityCenter'
},
onCredentialsDeleted: (handler: (type: CredentialsType) => void) => {
this.credentialsDeleteHandler = handler
},
}
this.registerLspCredentialsUpdateHandlers()
}