Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/rename-authenticatordevice-type #625

Merged
merged 3 commits into from
Oct 11, 2024

Conversation

MasterKale
Copy link
Owner

@MasterKale MasterKale commented Oct 8, 2024

This PR renames the @simplewebauthn/types AuthenticatorDevice type to WebAuthnCredential. AuthenticatorDevice.credentialID and AuthenticatorDevice.credentialPublicKey have been shortened to WebAuthnCredential.id and WebAuthnCredential.publicKey respectively.

@simplewebauthn/server's verifyRegistrationResponse() has been updated to return a new credential value of type WebAuthnCredential. The old credentialID, credentialPublicKey, and counter values have been replaced by credential.id, credential.publicKey, and credential.counter respectively.

The authenticator argument in @simplewebauthn/server's verifyAuthenticationResponse() has also been renamed to credential of type WebAuthnCredential.

Fixes #558.

Breaking Changes - verifyRegistrationResponse()

Update code that stores credentialID, credentialPublicKey, and counter out of verifyRegistrationResponse() to store credential.id, credential.publicKey, and credential.counter instead:

Before:

const { registrationInfo } = await verifyRegistrationResponse({...});

storeInDatabase(
  registrationInfo.credentialID,
  registrationInfo.credentialPublicKey,
  registrationInfo.counter,
  body.response.transports,
);

After:

const { registrationInfo } = await verifyRegistrationResponse({...});

storeInDatabase(
  registrationInfo.credential.id,
  registrationInfo.credential.publicKey,
  registrationInfo.credential.counter,
  registrationInfo.credential.transports,
);

Breaking Changes - verifyAuthenticationResponse()

Update calls to verifyAuthenticationResponse() to match the new credential argument that replaces the authenticator argument:

Before:

import { AuthenticatorDevice } from '@simplewebauthn/types';

const authenticator: AuthenticatorDevice = {
  credentialID: ...,
  credentialPublicKey: ...,
  counter: 0,
  transports: [...],
};

const verification = await verifyAuthenticationResponse({
  // ...
  authenticator,
});

After:

import { WebAuthnCredential } from '@simplewebauthn/types';

const credential: WebAuthnCredential = {
  id: ...,
  publicKey: ...,
  counter: 0,
  transports: [...],
};

const verification = await verifyAuthenticationResponse({
  // ...
  credential,
});

@MasterKale MasterKale added package:server @simplewebauthn/server package:types @simplewebauthn/typescript-types labels Oct 8, 2024
@MasterKale MasterKale added this to the v11.0.0 milestone Oct 8, 2024
@MasterKale MasterKale merged commit 0aedc62 into master Oct 11, 2024
1 check passed
@MasterKale MasterKale deleted the fix/rename-authenticatordevice-type branch October 11, 2024 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:server @simplewebauthn/server package:types @simplewebauthn/typescript-types
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rename AuthenticatorDevice type and usage
1 participant