New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

webauthn-encoding

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webauthn-encoding

decode/encode webauthn api config/to plain objects for http requests

latest
Source
npmnpm
Version
0.1.0-rc1
Version published
Maintainers
1
Created
Source

webauthn-encoding

A JavaScript library for decoding/encoding WebAuthn API arguments/returns from/to plain objects.

Usage

const enc = new WebauthnEncoding({
    base64Safe: true,
    base64NoPadding: true
})

// 1. Registration

// fetch JSON from backend service
const res1 = await fetch("/api/sign_up/init")

// create
const res2 = await navigator.credentials.create(
    enc.decodeCreationRequest(res1.json())   
)

// send back data to backend service
await fetch("/api/sign_up/finish", {
    method:'POST',
    headers: {
        'content-type': 'application/json'
    },
    body: JSON.stringify(enc.encodeCreationResponse(res2))
})

// 2. Validation

// fetch JSON from backend service
const res3 = await fetch("/api/sign_in/init")

// create
const res4 = await navigator.credentials.get(
    enc.decodeCredentialRequest(res3.json())
)

// send back data to backend service
await fetch("/api/sign_in/finish", {
    method:'POST',
    headers: {
        'content-type': 'application/json'
    },
    body: JSON.stringify(enc.encodeCredentialResponse(res4))
})


Compatible Backend Service

  • https://github.com/go-webauthn/webauthn

Donation

View https://guoyk.xyz/donation

Credits

Guo Y.K., MIT License

Keywords

webauthn

FAQs

Package last updated on 23 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts