iso-passkeys
TypeScript icon, indicating that this package has built-in type declarations

0.2.2 • Public • Published

iso-passkeys NPM Version License iso-passkeys

Isomorphic passkeys tooling

Install

pnpm install iso-passkeys

Usage

import { supports, credentialsCreate, credentialsGet } from 'iso-passkeys'

const credential = await credentialsCreate({
  publicKey: {
    challenge: base64url.encode(new Uint8Array([1, 2, 3, 4])),
    rp: {
      id: 'example.com',
      name: 'Example',
    },
    user: {
      id: user.id,
      name: username,
      displayName: 'Joe Doe',
    },
    attestation: 'none',
    authenticatorSelection: {
      userVerification: 'required',
      requireResidentKey: true,
      residentKey: 'required',
    },
    extensions: {
      credProps: true,
      largeBlob: {
        support: 'preferred',
      },
      prf: {
        eval: {
          first: new Uint8Array(new Array(32).fill(1)).buffer,
          second: new Uint8Array(new Array(32).fill(1)).buffer,
        },
      },
    },
  },
})

const assertion = await credentialsGet({
  mediation: 'conditional',
  publicKey: {
    challenge: base64url.encode(new Uint8Array([1, 2, 3, 4])),,
    allowCredentials: [],
    userVerification: 'required',
    rpId: 'example.com',
    extensions: {
      largeBlob: {
        // read: true,
        write: utf8.decode('hello world').buffer,
      },
      prf: {
        eval: {
          first: utf8.decode('first-salt').buffer,
          second: utf8.decode('second-salt').buffer,
        },
      },
    },
  },
})

Docs

Check https://hugomrdias.github.io/iso-repo/modules/iso_passkeys.html

License

MIT © Hugo Dias

Package Sidebar

Install

npm i iso-passkeys

Weekly Downloads

4

Version

0.2.2

License

MIT

Unpacked Size

69.7 kB

Total Files

26

Last publish

Collaborators

  • hugomrdias