| 147 | (key?: string, detail?: string, cancelToken?: vscode.CancellationToken) => Promise<string | undefined>; |
| 148 | |
| 149 | export class PassphraseInteractor implements IInteractor { |
| 150 | static ID = 'passphrase'; |
| 151 | |
| 152 | constructor(private readonly passphraseProvider: IStringProvider) { } |
| 153 | |
| 154 | get id(): string { |
| 155 | return PassphraseInteractor.ID; |
| 156 | } |
| 157 | |
| 158 | async onData(data: string, cancelToken?: vscode.CancellationToken): Promise<IInteraction> { |
| 159 | const result: IInteraction = { postAction: 'keep' }; |
| 160 | const lines: string[] = data.trim().split('\n'); |
| 161 | if (lines.some(l => l.indexOf('Enter passphrase for') >= 0)) { |
| 162 | result.postAction = 'consume'; |
| 163 | const passphrase: string | undefined = await this.passphraseProvider(undefined, undefined, cancelToken); // TODO keep track of the key name |
| 164 | if (typeof passphrase === 'string') { |
| 165 | result.response = passphrase; |
| 166 | result.isPassword = true; |
| 167 | } else { |
| 168 | result.canceled = true; |
| 169 | } |
| 170 | } else if (lines.some(l => l.indexOf('Identity added:') >= 0)) { |
| 171 | result.postAction = 'consume'; |
| 172 | } |
| 173 | |
| 174 | return result; |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | export function getExitCode(output: string, marker: string): number | undefined { |
| 179 | const regex: RegExp = new RegExp(`${marker}##([0-9]*)##`); |
nothing calls this directly
no outgoing calls
no test coverage detected