MCPcopy
hub / github.com/coder/mux / getClient

Method getClient

src/node/services/onePasswordService.ts:41–69  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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;

Callers 3

attemptMethod · 0.95
isAvailableMethod · 0.95
resolveWithClientMethod · 0.95

Calls 2

withTimeoutFunction · 0.70
createClientFunction · 0.50

Tested by

no test coverage detected