History

Merge remote-tracking branch 'origin/codex/effect-lint-keychain-extension' into codex/effect-lint-integration

Rhys Sullivan committed 6 months ago

Commit 45f07342 parents 1a269ea b0d47df1 file · +26 −25Browse files

Unified · Split

packages/plugins/keychain/src/index.ts+26−25
@@ -46,16 +46,7 @@ export interface KeychainPluginConfig { · 45 unmodified lines
4646 // Plugin extension — public API on executor.keychain
4747 // ---------------------------------------------------------------------------
4848
49−export interface KeychainExtension {
50− /** Human-readable name for the keychain on this platform */
51− readonly displayName: string;
52−
53− /** Whether the current platform supports system keychain */
54− readonly isSupported: boolean;
55−
56− /** Check if a secret exists in the system keychain */
57− readonly has: (id: string) => Effect.Effect<boolean>;
58−}
49+export type KeychainExtension = ReturnType<typeof makeKeychainExtension>;
5950
6051 // ---------------------------------------------------------------------------
6152 // Plugin definition
@@ -69,25 +60,35 @@ const scopedServiceName = ( · 7 unmodified lines
6960 ctx: PluginCtx<unknown>,
7061 options: KeychainPluginConfig | undefined,
7162 ): string =>
72− `${resolveServiceName(options?.serviceName)}/${ctx.scopes[0]!.id as string}`;
63+ `${resolveServiceName(options?.serviceName)}/${ctx.scopes[0]!.id}`;
64+
65+const makeKeychainExtension = (
66+ ctx: PluginCtx<unknown>,
67+ options: KeychainPluginConfig | undefined,
68+) => {
69+ const serviceName = scopedServiceName(ctx, options);
70+ return {
71+ /** Human-readable name for the keychain on this platform */
72+ displayName: displayName(),
73+
74+ /** Whether the current platform supports system keychain */
75+ isSupported: isSupportedPlatform(),
76+
77+ /** Check if a secret exists in the system keychain */
78+ has: (id: string) =>
79+ getPassword(serviceName, id).pipe(
80+ Effect.map((v) => v !== null),
81+ Effect.orElseSucceed(() => false),
82+ ),
83+ };
84+};
7385
7486 export const keychainPlugin = definePlugin(
7587 (options?: KeychainPluginConfig) => ({
7688 id: "keychain" as const,
7789 storage: () => ({}),
7890
79− extension: (ctx): KeychainExtension => {
80− const serviceName = scopedServiceName(ctx, options);
81− return {
82− displayName: displayName(),
83− isSupported: isSupportedPlatform(),
84− has: (id) =>
85− getPassword(serviceName, id).pipe(
86− Effect.map((v) => v !== null),
87− Effect.orElseSucceed(() => false),
88− ),
89− };
90− },
91+ extension: (ctx): KeychainExtension => makeKeychainExtension(ctx, options),
9192
9293 secretProviders: (ctx): Effect.Effect<readonly SecretProvider[]> =>
9394 Effect.gen(function* () {
@@ -103,9 +104,9 @@ export const keychainPlugin = definePlugin( · 9 unmodified lines
103104 ),
104105 ),
105106 Effect.as(true),
106− Effect.catch((cause) =>
107+ Effect.catch(() =>
107108 Effect.logWarning(
108− `keychain unavailable, skipping provider registration: ${cause.message}`,
109+ "keychain unavailable, skipping provider registration",
109110 ).pipe(Effect.as(false)),
110111 ),
111112 );