Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/connect-react/src/types/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ export class Flags {
addFlags(items: Record<string, string>) {
for (const [name, value] of Object.entries(items)) {
this.items[name] = value;

if (
name === keyConditionalUI &&
value === 'false' &&
this.items[keyEventLow] &&
this.items[keyEventLow] === 'true'
) {
this.items[keyEventLow] = 'false';
}
}
}

Expand Down
27 changes: 24 additions & 3 deletions packages/web-core/src/services/WebAuthnService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,22 @@ export class WebAuthnService {
} as never)) as PublicKeyCredential;
}

if (WebAuthnService.isInjectedCredential(credential) || !credential.toJSON) {
return {
response: JSON.stringify(createResponseToJSON(credential)),
message: 'using fallback serializer (extension-injected credential)',
};
}

try {
console.log('credential', credential);
return {
response: JSON.stringify(credential.toJSON()),
message: '',
};
} catch (e) {
return {
response: JSON.stringify(createResponseToJSON(credential)),
message: 'toJSON() not available on PublicKeyCredential',
message: 'toJSON() threw on PublicKeyCredential',
};
}
}
Expand Down Expand Up @@ -134,6 +140,13 @@ export class WebAuthnService {
signal: abortController.signal,
})) as PublicKeyCredential;

if (WebAuthnService.isInjectedCredential(credential) || !credential.toJSON) {
return {
response: JSON.stringify(getResponseToJSON(credential)),
message: 'using fallback serializer (extension-injected credential)',
};
}

try {
return {
response: JSON.stringify(credential.toJSON()),
Expand All @@ -142,7 +155,7 @@ export class WebAuthnService {
} catch (e) {
return {
response: JSON.stringify(getResponseToJSON(credential)),
message: 'toJSON() not available on PublicKeyCredential',
message: 'toJSON() threw on PublicKeyCredential',
};
}
}
Expand Down Expand Up @@ -339,6 +352,14 @@ export class WebAuthnService {
}
}

static isInjectedCredential(credential: PublicKeyCredential): boolean {
try {
return credential.getClientExtensionResults !== PublicKeyCredential.prototype.getClientExtensionResults;
} catch (e) {
return true;
}
}

static async raceWithTimeout<T>(p: Promise<T>, ms: number): Promise<T> {
const timeout = new Promise<never>((_, reject) =>
setTimeout(() => reject(new ConnectError(ConnectErrorType.RaceTimeout, `timeout of ${ms}ms reached`)), ms),
Expand Down
Loading