()
| 39 | } |
| 40 | |
| 41 | private async getClient(): Promise<Client> { |
| 42 | if (this.client) { |
| 43 | return this.client; |
| 44 | } |
| 45 | |
| 46 | if (this.initPromise) { |
| 47 | return this.initPromise; |
| 48 | } |
| 49 | |
| 50 | const initPromise = (async () => { |
| 51 | const client = await withTimeout( |
| 52 | createClient({ |
| 53 | auth: new DesktopAuth(this.accountName), |
| 54 | integrationName: INTEGRATION_NAME, |
| 55 | integrationVersion: INTEGRATION_VERSION, |
| 56 | }), |
| 57 | RESOLVE_TIMEOUT_MS, |
| 58 | `1Password client initialization timed out after ${RESOLVE_TIMEOUT_MS}ms` |
| 59 | ); |
| 60 | |
| 61 | this.client = client; |
| 62 | return client; |
| 63 | })().finally(() => { |
| 64 | this.initPromise = null; |
| 65 | }); |
| 66 | |
| 67 | this.initPromise = initPromise; |
| 68 | return initPromise; |
| 69 | } |
| 70 | |
| 71 | private invalidateAvailabilityCache(): void { |
| 72 | this.available = false; |
no test coverage detected