Skip to content

feat: redact secrets from errors, telemetry, and agent tool results - #278

Open
aswadi wants to merge 1 commit into
wraith-protocol:developfrom
aswadi:feat/redact-secrets-telemetry-errors-276
Open

aswadi wants to merge 1 commit into
wraith-protocol:developfrom
aswadi:feat/redact-secrets-telemetry-errors-276

Conversation

@aswadi

@aswadi aswadi commented Nov 15, 2026

Copy link
Copy Markdown

Summary

Implements a central deterministic secret redaction policy across structured SDK errors, telemetry hooks, KeyVault, Stellar RPC/scanner instrumentation, and @wraith-protocol/sdk-agent tools.

  • Central redaction policy (src/redaction.ts, exported from root @wraith-protocol/sdk):
    • Adds REDACTED_VALUE, isSensitiveFieldName,
      edactUrl,
      edactString,
      edactValue,
      edactError, sanitizeTelemetryAttributeValue, sanitizeTelemetryAttributes, and sanitizeTelemetryException.
    • Deterministically redacts viewing/spending/private keys and scalars, Stellar S... secret seeds, Solana secret keypairs, BIP-39 mnemonics, PEM blocks, hex/base58 signatures, Bearer/Basic/JWT/API tokens, RPC URL credentials (user:pass@, ?api_key=, #access_token=, /api-key/), encrypted vault envelopes (salt, iv, checkIv, ciphertext, checkCiphertext, �uthTag, __vaultType buffers), and sensitive metadata while preserving operational diagnostics (code, docsLink, HTTP status, public addresses, st::... meta-addresses, xHash, ephemeralPubKey, asset balances, and non-sensitive query params).
  • Structured errors & vault hardening (src/errors.ts, src/chains/errorUtils.ts, src/vault/index.ts):
    • Applies
      edactError in WraithError.toJSON(), sanitizes URLs/messages in network and wallet error constructors (RPCRequestError, HorizonResponseError, AgentResponseError, RPCRetryExhaustedError, RPCTimeoutError, RPCAbortedError, WraithWalletError), and redacts getUnknownErrorMessage.
    • Adds KeyVault.toJSON() ({ locked, dbName }) and normalizes corrupt-entry decryption and IndexedDB storage errors so ciphertexts/IVs or partial plaintext never leak.
  • Safe telemetry hooks (src/telemetry.ts, src/chains/stellar/scan.ts, src/chains/stellar/rpc.ts):
    • Updates withSpan (preserving the zero-allocation NOOP_TRACER fast path) and exports startSafeSpan and createSafeTracer so user-provided Tracer / Span hooks receive only redacted primitive attributes and sanitized Error instances stripped of raw provider causes, headers, or keys.
    • Redacts endpoint credentials in createRpcClient failover events and Stellar streaming scan spans.
  • Agent tool & client defaults (packages/sdk-agent):
    • Prevents createClaudeAgentTools().scan() from returning stealthPrivateScalar or raw metadata by default (exposing only safe public fields and the 1-byte �iewTag, with explicit opt-in via includeSensitive: true), redacts memos in sendToMetaAddress / withdraw, sanitizes tool-call details in WraithAgent.chat(), and adds Wraith.toJSON() so API keys are never serialized.
  • Bundle budgets (package.json, BUNDLE_SIZE.md) & API reports (etc/sdk.api.md, etc/sdk-vault.api.md):
    • Updates API Extractor reports and adjusts Root ESM, Solana ESM/CJS, and Stellar ESM/CJS bundle budgets (~1.3 KB brotli shared across WraithError and elemetry) per BUNDLE_SIZE.md.

Verification

  • pnpm build (ESM, CJS, DTS across @wraith-protocol/sdk and @wraith-protocol/sdk-agent)
  • pnpm api:check (all 6 API Extractor reports clean)
  • pnpm format:check & pnpm test:types
  • pnpm size (all 12 bundle-size entries passing)
  • �itest run ( est/redaction.test.ts secret-corpus & telemetry safe-shape suite + full SDK & sdk-agent + sdk-svelte suites passing)

Closes #276

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Wave 11] Redact secrets from errors, telemetry, and agent tool results

1 participant