(user: string | undefined, token: string | undefined)
| 134 | } |
| 135 | |
| 136 | export function createBitbucketCloudClient(user: string | undefined, token: string | undefined): BitbucketClient { |
| 137 | const authorizationString = |
| 138 | token |
| 139 | ? (!user || user === "x-token-auth") |
| 140 | ? `Bearer ${token}` |
| 141 | : `Basic ${Buffer.from(`${user}:${token}`).toString('base64')}` |
| 142 | : undefined; |
| 143 | |
| 144 | const clientOptions: ClientOptions = { |
| 145 | baseUrl: BITBUCKET_CLOUD_API, |
| 146 | headers: { |
| 147 | Accept: "application/json", |
| 148 | ...(authorizationString ? { Authorization: authorizationString } : {}), |
| 149 | }, |
| 150 | }; |
| 151 | |
| 152 | const apiClient = createBitbucketCloudClientBase(clientOptions); |
| 153 | apiClient.use(throwOnHttpError); |
| 154 | var client: BitbucketClient = { |
| 155 | deploymentType: BITBUCKET_CLOUD, |
| 156 | token: token, |
| 157 | apiClient: apiClient, |
| 158 | baseUrl: BITBUCKET_CLOUD_API, |
| 159 | gitUrl: BITBUCKET_CLOUD_GIT, |
| 160 | getReposForWorkspace: cloudGetReposForWorkspace, |
| 161 | getReposForProjects: cloudGetReposForProjects, |
| 162 | getRepos: cloudGetRepos, |
| 163 | shouldExcludeRepo: cloudShouldExcludeRepo, |
| 164 | } |
| 165 | |
| 166 | return client; |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * We need to do `V extends CloudGetRequestPath` since we will need to call `apiClient.GET(url, ...)`, which |
no outgoing calls
no test coverage detected