(cause: unknown)
| 53 | const SERVICE_ACCOUNT_TOKEN_RE = /ops_[A-Za-z0-9_-]+/g; |
| 54 | |
| 55 | const formatCause = (cause: unknown): string => { |
| 56 | // oxlint-disable-next-line executor/no-unknown-error-message -- boundary: normalizing untyped op-js/SDK throwables into OnePasswordError.message |
| 57 | const maybeMessage = (cause as { readonly message?: unknown } | null | undefined)?.message; |
| 58 | const raw = |
| 59 | // oxlint-disable-next-line executor/no-unknown-error-message -- boundary: last-resort stringification of a non-Error throwable |
| 60 | typeof maybeMessage === "string" && maybeMessage.length > 0 ? maybeMessage : String(cause); |
| 61 | return raw |
| 62 | .replace(SERVICE_ACCOUNT_TOKEN_RE, "[redacted 1Password token]") |
| 63 | .replace(/\s+/g, " ") |
| 64 | .trim(); |
| 65 | }; |
| 66 | |
| 67 | const messageWithCause = (prefix: string, cause: unknown): string => { |
| 68 | const causeMessage = formatCause(cause); |
no test coverage detected