* Get GitLab OAuth configuration
()
| 51 | * Get GitLab OAuth configuration |
| 52 | */ |
| 53 | async function getGitLabConfig() { |
| 54 | // Validate and use the environment variables if provided |
| 55 | if ( |
| 56 | (INSOMNIA_GITLAB_REDIRECT_URI && !INSOMNIA_GITLAB_CLIENT_ID) || |
| 57 | (!INSOMNIA_GITLAB_REDIRECT_URI && INSOMNIA_GITLAB_CLIENT_ID) |
| 58 | ) { |
| 59 | throw new Error('GitLab Client ID and Redirect URI must both be set.'); |
| 60 | } |
| 61 | |
| 62 | if (INSOMNIA_GITLAB_REDIRECT_URI && INSOMNIA_GITLAB_CLIENT_ID) { |
| 63 | return { |
| 64 | clientId: INSOMNIA_GITLAB_CLIENT_ID, |
| 65 | redirectUri: INSOMNIA_GITLAB_REDIRECT_URI, |
| 66 | }; |
| 67 | } |
| 68 | |
| 69 | const configResponse = await net.fetch(getApiBaseURL() + '/v1/oauth/gitlab/config', { |
| 70 | method: 'GET', |
| 71 | }); |
| 72 | |
| 73 | const { applicationId: clientId, redirectUri } = (await configResponse.json()) as { |
| 74 | applicationId: string; |
| 75 | redirectUri: string; |
| 76 | }; |
| 77 | |
| 78 | return { |
| 79 | clientId, |
| 80 | redirectUri, |
| 81 | }; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Base64 URL encode helper for PKCE |
no test coverage detected