| 1 | import * as Redacted from "effect/Redacted"; |
| 2 | |
| 3 | /** |
| 4 | * Unwrap a distilled `SensitiveString` (`string | Redacted<string>`) into a |
| 5 | * plain string, preserving `undefined`. |
| 6 | * |
| 7 | * The Account API marks contact fields (names, emails, phone numbers, |
| 8 | * addresses) as sensitive at the wire level, so distilled returns them as |
| 9 | * `string | Redacted<string>`. These are PII rather than credentials, so |
| 10 | * alchemy stores them as plain strings in Attributes. |
| 11 | */ |
| 12 | export const unwrapSensitive = ( |
| 13 | value: string | Redacted.Redacted<string> | undefined, |
| 14 | ): string | undefined => |
| 15 | value === undefined |
| 16 | ? undefined |
| 17 | : typeof value === "string" |
| 18 | ? value |
| 19 | : Redacted.value(value); |