Skip to main content
Use this tutorial to add a working OpenKey connect-and-sign flow to a small browser app.

Prerequisites

  • Node.js 18 or later
  • A browser with WebAuthn support
  • A passkey-capable device or hardware security key

Create the app

Replace src/main.ts with:
Start the development server:
Open the local URL, select Connect OpenKey, and complete the OpenKey flow. The page should show an Ethereum address. Select Sign message and it should replace that result with the address and a hex-encoded signature.

What happened

connect() returns the selected key’s address, keyId, and keyType. signMessage() uses that keyId and returns the signature plus the signing address. The default iframe mode falls back to a popup if the app’s content security policy blocks the frame.

Sign out

signOut() clears local state, cancels any open OpenKey flows, and asks OpenKey to end the session. It resolves to { requestId, revoked }: revoked: true means OpenKey confirmed the old session no longer works.
Since 0.10.2 the embedding page never receives an OpenKey session token: getSessionToken() always returns null. Server-side signing needs an OAuth access token; see OAuth.

Next step

To use the connected key as TinyCloud’s wallet provider, continue to TinyCloud Integration.