0.9.30 โ€ข Published 10 months ago

@passlock/client v0.9.30

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Features

Passkeys and the WebAuthn API are quite complex. I've taken an opinionated approach to simplify things for you. Following the 80/20 principle, I've tried to focus on the features most valuable to developers and users.

  1. ๐Ÿ” Primary or secondary authentication - 2FA or a complete replacement for passwords

  2. ๐Ÿš€ Social login - Supporting Apple & Google. GitHub coming soon..

  3. โ˜๐Ÿป Biometrics - Frictionless facial or fingerprint recognition for your webapps

  4. ๐Ÿ–ฅ๏ธ Management console - Suspend users, disable or revoke passkeys and more..

  5. ๐Ÿ•ต๏ธ Audit trail - View a full audit trail for each user

  6. ๐Ÿ–ฅ๏ธ Dev console - Something not working? check the web console for details

  7. ๐Ÿ‘Œ Headless components - You have 100% control over the UI

Screenshots

SvelteKit template using this library

Passlock user profile

Usage

Register a passkey

import { Passlock, PasslockError } from '@passlock/client'

// you can find these details in the settings area of your Passlock console
const tenancyId = '...'
const clientId = '...'

const passlock = new Passlock({ tenancyId, clientId })

// to register a new passkey, call registerPasskey(). We're using placeholders for
// the user data. You should grab this from an HTML form, React store, Redux etc.
const [email, givenName, familyName] = ["jdoe@gmail.com", "John", "Doe"]

// Passlock doesn't throw but instead returns a union: result | error
const result = await passlock.registerPasskey({ email, givenName, familyName })

// ensure we're error free
if (!PasslockError.isError(result)) {
  // send the token to your backend (json/fetch or hidden form field etc)
  console.log('Token: %s', result.token)
}

Authenticate using a passkey

import { Passlock, PasslockError } from '@passlock/client'

const tenancyId = '...'
const clientId = '...'

const passlock = new Passlock({ tenancyId, clientId })
const result = await passlock.authenticatePasskey()

if (!PasslockError.isError(result)) {
  // send the token to your backend for verification
  console.log('Token: %s', result.token)
}

Backend verification

Verify the token and obtain the passkey registration or authentication details. You can make a simple GET request to https://api.passlock.dev/{tenancyId}/token/{token} or use the @passlock/node library:

import { Passlock } from '@passlock/node'

// API Keys can be found in your passlock console
const passlock = new Passlock({ tenancyId, apiKey })

// token comes from your frontend
const principal = await passlock.fetchPrincipal({ token })

// get the user id
console.log(principal.user.id)

More information

Please see the tutorial and documentation

0.9.30

10 months ago

0.9.27

10 months ago

0.9.28

10 months ago

0.9.29

10 months ago

0.9.25

11 months ago

0.9.24

11 months ago

0.9.23

12 months ago

0.9.13

1 year ago

0.9.15

1 year ago

0.9.21

12 months ago

0.9.22

12 months ago

0.9.16

1 year ago

0.9.17

1 year ago

0.9.19

1 year ago

0.9.12

1 year ago

0.9.11

1 year ago

0.9.10

1 year ago

0.9.9

1 year ago

0.9.8

1 year ago

0.9.7

1 year ago

0.9.4

1 year ago

0.9.6

1 year ago

0.9.5

1 year ago

0.9.3

1 year ago

0.9.2

1 year ago

0.9.1

1 year ago

0.9.0

1 year ago