@cvolny/webauthn-client

1.0.1 • Public • Published

@cvolny/webauthn-client

Webauthn client leveraging Axios and CBOR encoding.

I have request/response interceptors set on an axios instance inside of webauthn.js such that CBOR encoding/decoding is performed for you. I also configured the axios xsrf settings for the Django web framework default configuration.

Example Usage:

import {
  webauthn_login,
  webauthn_register,
} from "webauthn-client";

...

login_passwordless = (username) => {
    const success = (res) => this.setState({authenticated: true});
    const failure = (res, code) => console.log('webauthn login failed', code, res);
    webauthn_login({username: username}, success, failure);
};

login_2fa = (username, password) => {
    const success = (res) => this.setState({authenticated: true});
    const failure = (res, code) => console.log('webauthn login failed', code, res);
    webauthn_login({username: username, password: password}, success, failure);
};

register = () => {
    const success = (res) => console.log('registered!');
    const failure = (res, code) => console.log('webauthn registration failed', code, res);
    webauthn_register({}, success, failure);
};

Notes:

Really any map can be passed for authentication payload (username, password, token, etc).

Package Sidebar

Install

npm i @cvolny/webauthn-client

Weekly Downloads

0

Version

1.0.1

License

LGPL-2.1

Unpacked Size

34.7 kB

Total Files

4

Last publish

Collaborators

  • cvolny