webauthn-client
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

[WIP] Simple client for Go WebAuthn powered servers.

WIP Project

It is not tested in any means yet.

Synopsis (typescript)

import {Client} from 'webauthn-client';

const cl = new Client({
    // endpoint to retrieve credential creation options for registration
    beginReg: '/webauthn/register/request',
    // endpoint to submit attestation
    confirmReg: '/webauthn/register/verify',
    // endpoint to retrieve credential creation options for login
    beginAuth: '/webauthn/login/request',
    // endpoint to submit assertion
    confirmAuth: '/webauthn/login/verify',
    // api server hostname. BE AWARE! webauthn ONLY work in secure site (https)
    // You should leave this empty in most case.
    host: 'https://example.com',
});

interface MyRegResp {
  msg: string;
}

try {
    const resp = await cl.register<MyRegResp>({
      myData: 1,
      someOtherData: [2, 3, 4],
    });
    
    alert(resp.msg);
} catch (e) {
    alert("cannot register: " + e);
}

APIs

  • Register.register: Registers a new credential for the user. Submits custom data to beginReg endpoint, and returns data received from confirmReg endpoint.
  • Auth.login: Authenticates the user with previously registered credential. Submits custom data to beginAuth endpoint, and returns data received from confirmAuth endpoint.
  • isSupported: See if current browser supports WebAuthn.
  • Client: Wraps both Register and Auth in an object.

Endpoints have default values:

  • beginReg: /register/challenge
  • confirmReg: /register/verify
  • beginAuth: /login/challenge
  • confirmAuth: /login/verify

License

Copyright (c) 2019 Ronmi Ren ronmi.ren@gmail.com

Licensed under the MPL-2.0 license.

Readme

Keywords

Package Sidebar

Install

npm i webauthn-client

Weekly Downloads

0

Version

0.0.4

License

MPL-2.0

Unpacked Size

12.5 kB

Total Files

9

Last publish

Collaborators

  • ronmi