Skip to content

Commit

Permalink
Merge pull request #13 from Laragear/fix/empty-credentials
Browse files Browse the repository at this point in the history
[1.x] Should fix empty credentials detection from authenticator
  • Loading branch information
DarkGhostHunter authored Mar 15, 2024
2 parents b23c6f5 + f5110c8 commit 8ebcaa8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/webpass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function webpass(config: Partial<Config> = {}): Webpass {
// Retrieve the attestation options from the server
const attestationOptions: ServerPublicKeyCredentialCreationOptions | undefined = await wfetch<ServerPublicKeyCredentialCreationOptions | undefined>(normalizedOptions)

console.debug('Attestation Options Received', attestationOptions)
console.debug("Attestation Options Received", attestationOptions)

// If the response is empty, bail out
if (!attestationOptions || isObjectEmpty(attestationOptions)) {
Expand All @@ -165,18 +165,18 @@ function webpass(config: Partial<Config> = {}): Webpass {
publicKey: parseServerCreationOptions(attestationOptions)
})

console.debug('Attestation Credentials Created', credentials);
console.debug("Attestation Credentials Created", credentials);

// If the user denied the permission, throw an error.
if (!credentials || isObjectEmpty(credentials)) {
if (!credentials) {
throw newError("AttestationCancelled", "The credentials creation was cancelled by the user or a timeout.")
}

const result = await wfetch<Record<string, any>>(
normalizedResponseOptions, parseOutgoingCredentials(credentials)
)

console.debug('Attestation benchmark', bench.stop())
console.debug("Attestation benchmark", bench.stop())

return result
}
Expand Down Expand Up @@ -232,7 +232,7 @@ function webpass(config: Partial<Config> = {}): Webpass {
// Get the assertion challenge from the server
const assertionOptions: ServerPublicKeyCredentialRequestOptions | undefined = await wfetch<ServerPublicKeyCredentialRequestOptions | undefined>(normalizedOptions)

console.debug('Assertion Options Received', assertionOptions)
console.debug("Assertion Options Received", assertionOptions)

// If we didn't receive anything, return it as an invalid server message.
if (!assertionOptions || isObjectEmpty(assertionOptions)) {
Expand All @@ -244,7 +244,7 @@ function webpass(config: Partial<Config> = {}): Webpass {
publicKey: parseServerRequestOptions(assertionOptions)
})

console.debug('Assertion Credentials Retrieved', assertionOptions)
console.debug("Assertion Credentials Retrieved", assertionOptions)

// If the user denied the permission, return null
if (!credentials) {
Expand All @@ -256,7 +256,7 @@ function webpass(config: Partial<Config> = {}): Webpass {
normalizedResponseOptions, parseOutgoingCredentials(credentials)
)

console.debug('Assertion benchmark', bench.stop())
console.debug("Assertion benchmark", bench.stop())

return result
}
Expand Down

0 comments on commit 8ebcaa8

Please sign in to comment.