Showing the changes to examples/all-plugins/src (1 of 32 files). Show all
Unified · Split
| @@ -18,12 +18,13 @@ · 17 unmodified lines | ||
| 18 | 18 | // default. |
| 19 | 19 | // --------------------------------------------------------------------------- |
| 20 | 20 | |
| 21 | −import { Cause, Effect, Result } from "effect"; | |
| 21 | +import { Cause, Effect, Redacted, Result } from "effect"; | |
| 22 | 22 | |
| 23 | 23 | import { |
| 24 | 24 | AuthTemplateSlug, |
| 25 | 25 | ConnectionName, |
| 26 | 26 | createExecutor, |
| 27 | + credentialValueToWrite, | |
| 27 | 28 | IntegrationSlug, |
| 28 | 29 | ProviderItemId, |
| 29 | 30 | ProviderKey, |
| @@ -61,15 +62,20 @@ import { workosVaultPlugin } from "@executor-js/plugin-workos-vault"; · 31 unmodified lines | ||
| 61 | 62 | // A connection's value lives in a writable credential provider. This tiny |
| 62 | 63 | // in-memory store is enough for a script; the keychain / file-secrets / |
| 63 | 64 | // 1Password plugins below contribute durable ones. Providers are Effect-native, |
| 64 | −// so `get`/`set` return `Effect`s. | |
| 65 | +// so `get`/`set` return `Effect`s, and `get` hands back a `Redacted` so a | |
| 66 | +// credential cannot land in a log by accident. | |
| 65 | 67 | const memory = new Map<string, string>(); |
| 66 | 68 | const memoryProvider: CredentialProvider = { |
| 67 | 69 | key: ProviderKey.make("memory"), |
| 68 | 70 | writable: true, |
| 69 | − get: (id: ProviderItemId) => Effect.sync(() => memory.get(String(id)) ?? null), | |
| 70 | − set: (id: ProviderItemId, value: string) => | |
| 71 | + get: (id: ProviderItemId) => | |
| 71 | 72 | Effect.sync(() => { |
| 72 | − memory.set(String(id), value); | |
| 73 | + const value = memory.get(String(id)); | |
| 74 | + return value === undefined ? null : Redacted.make(value); | |
| 75 | + }), | |
| 76 | + set: (id: ProviderItemId, value: string | Redacted.Redacted<string>) => | |
| 77 | + Effect.sync(() => { | |
| 78 | + memory.set(String(id), credentialValueToWrite(value)); | |
| 73 | 79 | }), |
| 74 | 80 | }; |
| 75 | 81 | |