diff --git a/packages/web-core/src/services/WebAuthnService.ts b/packages/web-core/src/services/WebAuthnService.ts
index a2ff7a6c..ebd39b1f 100644
--- a/packages/web-core/src/services/WebAuthnService.ts
+++ b/packages/web-core/src/services/WebAuthnService.ts
@@ -2,6 +2,7 @@
/// <- add this line
import type { ClientCapabilities } from '@corbado/types';
import { create, get } from '@corbado/webauthn-json';
+import { createResponseToJSON, getResponseToJSON } from '@corbado/webauthn-json/extended';
import FingerprintJS from '@fingerprintjs/fingerprintjs';
import { detectIncognito } from 'detectincognitojs';
import log from 'loglevel';
@@ -73,10 +74,17 @@ export class WebAuthnService {
} as never)) as PublicKeyCredential;
}
- return {
- response: JSON.stringify(credential.toJSON()),
- message: '',
- };
+ try {
+ return {
+ response: JSON.stringify(credential.toJSON()),
+ message: '',
+ };
+ } catch (e) {
+ return {
+ response: JSON.stringify(createResponseToJSON(credential)),
+ message: 'toJSON() not available on PublicKeyCredential',
+ };
+ }
}
async login(
@@ -125,10 +133,17 @@ export class WebAuthnService {
signal: abortController.signal,
})) as PublicKeyCredential;
- return {
- response: JSON.stringify(credential.toJSON()),
- message: '',
- };
+ try {
+ return {
+ response: JSON.stringify(credential.toJSON()),
+ message: '',
+ };
+ } catch (e) {
+ return {
+ response: JSON.stringify(getResponseToJSON(credential)),
+ message: 'toJSON() not available on PublicKeyCredential',
+ };
+ }
}
async getClientInformation(maybeClientHandle: ClientStateEntry | undefined): Promise {