MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / makeProvider

Function makeProvider

packages/plugins/onepassword/src/sdk/plugin.ts:198–236  ·  view source on GitHub ↗
(
  ctx: PluginCtx<OnePasswordStore>,
  timeoutMs: number,
  preferSdk: boolean | undefined,
)

Source from the content-addressed store, hash-verified

196// ---------------------------------------------------------------------------
197
198const makeProvider = (
199 ctx: PluginCtx<OnePasswordStore>,
200 timeoutMs: number,
201 preferSdk: boolean | undefined,
202): CredentialProvider => ({
203 key: PROVIDER_KEY,
204 writable: false,
205
206 get: (id: ProviderItemId): Effect.Effect<string | null, StorageFailure> =>
207 ctx.storage.getConfig().pipe(
208 Effect.flatMap((config) => {
209 if (!config) return Effect.succeed(null as string | null);
210
211 const uri = configuredVaultUri(config, id);
212 if (uri === null) return Effect.succeed(null as string | null);
213
214 return getServiceFromConfig(config, timeoutMs, preferSdk).pipe(
215 Effect.flatMap((svc) => svc.resolveSecret(uri)),
216 Effect.map((v): string | null => v),
217 Effect.orElseSucceed(() => null),
218 );
219 }),
220 Effect.catch(() => Effect.succeed(null as string | null)),
221 ),
222
223 list: (): Effect.Effect<readonly ProviderEntry[], StorageFailure> =>
224 ctx.storage.getConfig().pipe(
225 Effect.flatMap((config) => {
226 if (!config) return Effect.succeed([] as readonly ProviderEntry[]);
227 return getServiceFromConfig(config, timeoutMs, preferSdk).pipe(
228 Effect.flatMap((svc) => svc.listItems(config.vaultId)),
229 Effect.map((items): readonly ProviderEntry[] =>
230 items.map((item) => ({ id: ProviderItemId.make(item.id), name: item.title })),
231 ),
232 );
233 }),
234 Effect.catch(() => Effect.succeed([] as readonly ProviderEntry[])),
235 ),
236});
237
238// ---------------------------------------------------------------------------
239// Owner resolution — config is a single shared 1Password binding. We persist

Callers 1

plugin.tsFile · 0.70

Calls 2

configuredVaultUriFunction · 0.85
getServiceFromConfigFunction · 0.85

Tested by

no test coverage detected