Skip to content

contrib: add PII redaction helper for consumer-supplied logging hooks - #343

Merged
davedumto merged 1 commit into
Vellar-Wallet:devfrom
arandomogg:contrib/issue-291-pii-redaction
Aug 31, 2026
Merged

contrib: add PII redaction helper for consumer-supplied logging hooks#343
davedumto merged 1 commit into
Vellar-Wallet:devfrom
arandomogg:contrib/issue-291-pii-redaction

Conversation

@arandomogg

Copy link
Copy Markdown

Summary

Adds a self-contained reference implementation under contrib/examples/issue-291-pii-redaction-logging-hooks/ for redacting known-sensitive fields before they reach a consumer-supplied logging hook.

Scoped entirely to contrib/ per CONTRIBUTING.md and contrib/README.md.

The problem

The SDK never logs anything itself, but it does hand structured details objects to consumer-supplied hooks — onDebugLog on createPasskeyKitConnector (src/passkeykit-connector.ts) today — that a host typically pipes straight into their own logger or telemetry pipeline. Those objects can carry fields identifying a specific user or wallet. None are secrets the SDK holds, but they are stable, wallet-linkable identifiers a log aggregator or support export should not retain in plaintext.

SDK-internal fields flagged as sensitive

Field(s) Why
secretKey, secret, privateKey Key material. Reachable if a consumer's payload carries a signer config.
publicKey, previousPublicKey, newPublicKey ed25519 session-key public keys, passed to onDebugLog by session-key rotation.
accountId, contractId The smart-account C-address — directly identifies the wallet.
keyId The WebAuthn credential id (WalletSession.keyId) — identifies the passkey/device.
sessionId, serverSessionId Server-side session record ids.
signature Auth-entry / WebAuthn assertion signature bytes.

Files

  • pii-redaction-logging-hooks.tsSENSITIVE_LOG_FIELDS, redactSensitiveFields(value, options?), and withRedaction(hook) which wraps a hook once so no call site can forget. Includes a runnable main() demo.
  • pii-redaction-logging-hooks.test.ts — 15 tests.
  • README.md — the flagged-field table, usage both ways, and the redaction guidance.

Non-plain values (Error, Date, class/XDR instances) pass through untouched rather than being flattened; circular references become "[circular]"; a configurable maxDepth bounds the walk; extraFields covers consumer-specific fields.

Requirements checklist

  • Identify SDK-internal fields that should be flagged as sensitive
  • Helper that redacts known sensitive fields before passing to logging hooks
  • Tests verifying redacted fields never reach the logging hook
  • Redaction guidance documented (in the example's README, since this PR is scoped to contrib/)

Test plan

npx vitest run contrib/examples/issue-291-pii-redaction-logging-hooks

15 tests, all passing — including two that assert the raw sensitive value never appears anywhere in what the wrapped hook received, checked by string search over the full captured payload rather than only structural equality.

closes #291

Self-contained reference for issue Vellar-Wallet#291 under contrib/examples. The SDK hands
structured details objects to consumer-supplied hooks like onDebugLog, which
hosts typically pipe straight into their own logger. Those details can carry
wallet-linkable identifiers: session-key public keys, the smart-account
contract id, the WebAuthn credential id, and server-side session ids.

Adds redactSensitiveFields, a pure helper that replaces any field matching a
known-sensitive name with a redacted marker, case-insensitively, through
nested objects and arrays, without flattening non-plain values like Error or
Date and without looping on circular references. withRedaction wraps a hook
once so no call site can forget to redact.

Includes 15 tests, covering the redaction logic and verifying that raw
sensitive values never appear in anything the wrapped hook receives, plus a
README documenting the flagged fields and the redaction guidance.
@vercel

vercel Bot commented Aug 29, 2026

Copy link
Copy Markdown

@arandomogg is attempting to deploy a commit to the david's projects Team on Vercel.

A member of the Team first needs to authorize it.

@davedumto
davedumto merged commit d98bc7c into Vellar-Wallet:dev Aug 31, 2026
1 of 2 checks passed
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.

2 participants