|
8 | 8 | ProjectConfigRemoteVersion, |
9 | 9 | IGitHubRepositoryDataSource, |
10 | 10 | GitHubRepository, |
11 | | - GitHubRepositoryRef |
| 11 | + GitHubRepositoryRef, |
| 12 | + ProjectConfigRemoteSpecification |
12 | 13 | } from "../domain" |
13 | 14 | import RemoteConfig from "../domain/RemoteConfig" |
14 | 15 | import { IRemoteConfigEncoder } from "../domain/RemoteConfigEncoder" |
@@ -178,11 +179,7 @@ export default class GitHubProjectDataSource implements IProjectDataSource { |
178 | 179 | const specifications = remoteVersion.specifications.map(e => { |
179 | 180 | const remoteConfig: RemoteConfig = { |
180 | 181 | url: e.url, |
181 | | - auth: e.auth ? { |
182 | | - type: e.auth.type, |
183 | | - username: this.encryptionService.decrypt(e.auth.encryptedUsername), |
184 | | - password: this.encryptionService.decrypt(e.auth.encryptedPassword) |
185 | | - } : undefined |
| 182 | + auth: this.tryDecryptAuth(e) |
186 | 183 | }; |
187 | 184 |
|
188 | 185 | const encodedRemoteConfig = this.remoteConfigEncoder.encode(remoteConfig); |
@@ -232,4 +229,21 @@ export default class GitHubProjectDataSource implements IProjectDataSource { |
232 | 229 | .replace(/ /g, "-") |
233 | 230 | .replace(/[^A-Za-z0-9-]/g, "") |
234 | 231 | } |
| 232 | + |
| 233 | + private tryDecryptAuth(projectConfigRemoteSpec: ProjectConfigRemoteSpecification): { type: string, username: string, password: string } | undefined { |
| 234 | + if (!projectConfigRemoteSpec.auth) { |
| 235 | + return undefined |
| 236 | + } |
| 237 | + |
| 238 | + try { |
| 239 | + return { |
| 240 | + type: projectConfigRemoteSpec.auth.type, |
| 241 | + username: this.encryptionService.decrypt(projectConfigRemoteSpec.auth.encryptedUsername), |
| 242 | + password: this.encryptionService.decrypt(projectConfigRemoteSpec.auth.encryptedPassword) |
| 243 | + } |
| 244 | + } catch (error) { |
| 245 | + console.error(`Failed to decrypt remote specification auth for ${projectConfigRemoteSpec.url}. Perhaps a different public key was used?:`, error); |
| 246 | + return undefined |
| 247 | + } |
| 248 | + } |
235 | 249 | } |
0 commit comments