WebAuthn

Trust evaluation of a W3C WebAuthn (Level 3) / passkey attestation: parse the attestation object + authenticatorData, decode the COSE credential public key, and verify each defined attestation-statement format (packed, tpm, android-key, apple, fido-u2f, none) -- the attestation-statement signature and each format's structural bindings. The attestation CBOR is decoded by the strict, fail-closed pki.cbor codec (WebAuthn keys are CTAP2-canonical), the signature by pki.webcrypto. Chaining the returned x5c trust path to a caller-pinned root via pki.path.validate is the caller's step: this module verifies the statement, not the certificate chain. A verifier, not a ceremony client: the relying party supplies the clientDataHash + any trust anchors; this module never touches a socket. Fail-closed -- every malformed shape or failed check throws a typed WebauthnError, never a partial verdict.

pki.webauthn.parseAttestationObject

since 0.2.5 experimental
pki.webauthn.parseAttestationObject(bytes) -> { fmt, attStmt, authData, authDataBytes }

Structurally decode a WebAuthn attestation object (the CBOR {fmt, attStmt, authData}) and its authenticatorData, fail-closed. authData carries the decoded rpIdHash / flags / signCount and, when the AT flag is set, the attestedCredentialData (aaguid, credentialId, and the decoded COSE credentialPublicKey). authDataBytes is the raw authenticatorData -- the exact bytes an attestation signature covers. A malformed object throws webauthn/bad-attestation-object.

Example

var att = pki.webauthn.parseAttestationObject(attestationObject);
att.fmt;                               // "packed"
att.authData.credentialPublicKey.kty;  // 2 (EC2)

References

  • spec W3C WebAuthn Level 3 sec. 6.5.4 / 6.1

pki.webauthn.verify

since 0.2.5 experimental
pki.webauthn.verify(attestationObject, clientDataHash, opts) -> Promise<{ verified, fmt, attestationType, trustPath, aaguid, credentialPublicKey }>

Verify a WebAuthn attestation statement: the attestation signature over authenticatorData || clientDataHash and (for the x5c formats) the format's certificate requirements. clientDataHash is the SHA-256 of the serialized client data, supplied by the relying party. Resolves the attestation type + trust path or throws a typed webauthn/* error; a signature that does not verify is a webauthn/verify-failed verdict, never a silent pass.

Example

async function example() {
  var res = await pki.webauthn.verify(attestationObject, clientDataHash, {});
  res.verified;         // true (statement signature + bindings hold)
  res.attestationType;  // "Basic"
  // anchor res.trustPath to your pinned roots with pki.path.validate
}
example();

References

  • spec W3C WebAuthn Level 3 sec. 8