0.0.4 • Published 6 years ago
webauthn-client v0.0.4
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 tobeginRegendpoint, and returns data received fromconfirmRegendpoint.Auth.login: Authenticates the user with previously registered credential. Submits custom data tobeginAuthendpoint, and returns data received fromconfirmAuthendpoint.isSupported: See if current browser supports WebAuthn.Client: Wraps bothRegisterandAuthin an object.
Endpoints have default values:
beginReg: /register/challengeconfirmReg: /register/verifybeginAuth: /login/challengeconfirmAuth: /login/verify
License
Copyright (c) 2019 Ronmi Ren ronmi.ren@gmail.com
Licensed under the MPL-2.0 license.