Skip to content

fix(auth): add toJSON to WebAuthnError for correct JSON serialization - #2313

Merged
mandarini merged 1 commit into
developfrom
fix/oniani1-auth-webauthn-error-tojson
May 4, 2026
Merged

mandarini merged 1 commit into
developfrom
fix/oniani1-auth-webauthn-error-tojson

Conversation

@mandarini

Copy link
Copy Markdown
Contributor

WebAuthnError and WebAuthnUnknownError extend Error, so JSON.stringify produces an object missing message, name, and code (those props are non-enumerable on Error). AuthError, FunctionsError, StorageError, and several other auth error subclasses already have toJSON; the WebAuthn classes added in #2283 missed it.

Adds a toJSON to WebAuthnError returning { name, message, code }. WebAuthnUnknownError inherits the method, so its originalError is no longer surfaced in serialized form.

Tests in test/webauthn.errors.test.ts cover both classes and confirm the inherited path doesn't leak originalError.

Closes #2306

Original PR: #2307

@mandarini
mandarini requested review from a team as code owners May 4, 2026 11:28
@github-actions github-actions Bot added the auth-js Related to the auth-js library. label May 4, 2026
@pkg-pr-new

pkg-pr-new Bot commented May 4, 2026

Copy link
Copy Markdown

Open in StackBlitz

@supabase/auth-js

npm i https://pkg.pr.new/@supabase/auth-js@2313

@supabase/functions-js

npm i https://pkg.pr.new/@supabase/functions-js@2313

@supabase/postgrest-js

npm i https://pkg.pr.new/@supabase/postgrest-js@2313

@supabase/realtime-js

npm i https://pkg.pr.new/@supabase/realtime-js@2313

@supabase/storage-js

npm i https://pkg.pr.new/@supabase/storage-js@2313

@supabase/supabase-js

npm i https://pkg.pr.new/@supabase/supabase-js@2313

commit: 7edc287

@mandarini
mandarini merged commit 7ed0f74 into develop May 4, 2026
25 checks passed
@mandarini
mandarini deleted the fix/oniani1-auth-webauthn-error-tojson branch May 4, 2026 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auth-js Related to the auth-js library.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WebAuthnError missing toJSON loses message and code on JSON.stringify

3 participants