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