Create a User Passkey Session
A passkey session is an expiring session enabled by an initial passkey authentication. You could think of this as a “lightning mode” of sorts: creating a passkey session allows users to authenticate subsequent requests touch-free. Under the hood, this is powered by our indexedDbStamper. These sessions are enabled by creating a short-lived embedded API key in the browser, stored in localStorage, and cryptographically scoped to a public key generated by IndexedDB.
By calling loginWithPasskey()
, the SDK stores the session and active client in localStorage. The signing key material remains securely stored in the browser’s IndexedDB and is never extractable. Turnkey uses this public key to scope and encrypt the session to the appropriate user.
Steps using @turnkey/sdk-react
This process is made seamless by leveraging our React package. Read on for a non-React implementation below.
Initialize the React Provider
Login with a Passkey and Create a Session
Use the session to make requests
getActiveClient()
returns the currently active client (e.g. IndexedDb-backed), refreshing automatically if needed.
Alternative Steps (non-React)
Initialize the Passkey and IndexedDB Clients
Login with a Passkey and Create a Session
Use the session to make requests
Once loginWithPasskey
completes, the session is stored in localStorage and all requests are signed using the IndexedDb-backed keypair.