(credentialsId?: string | null)
| 29 | }; |
| 30 | |
| 31 | const onAuthFailure = (credentialsId?: string | null): AuthFailureCallback => { |
| 32 | return async url => { |
| 33 | console.log(`[git-event] Auth Failure: ${url}`); |
| 34 | |
| 35 | try { |
| 36 | invariant(credentialsId, 'No credentials ID provided for auth failure handling'); |
| 37 | const credentials = await services.gitCredentials.getById(credentialsId); |
| 38 | invariant(credentials, 'Credentials not found for auth failure handling'); |
| 39 | invariant(isGitCredentialsV2(credentials), 'Legacy credentials are not supported'); |
| 40 | |
| 41 | const provider = gitRemoteProviderRegistry.get(credentials.provider); |
| 42 | |
| 43 | if (!provider || !provider.authFailureCallback) { |
| 44 | console.log('[git-event] No provider or auth failure callback available'); |
| 45 | return; |
| 46 | } |
| 47 | |
| 48 | const authFailureCallback = provider.authFailureCallback(credentials); |
| 49 | |
| 50 | return authFailureCallback; |
| 51 | } catch (error) { |
| 52 | console.warn('[git-event] Failed to refresh token', error); |
| 53 | return; |
| 54 | } |
| 55 | }; |
| 56 | }; |
| 57 | |
| 58 | const onAuthSuccess: AuthSuccessCallback = message => { |
| 59 | console.log(`[git-event] Auth Success: ${message}`); |
no test coverage detected