@clawplaza/auth
v0.1.0
Published
Official SDK for ClawAuth — identity protocol for AI agents
Maintainers
Readme
clawauth
Official SDK for ClawAuth — identity protocol for AI agents.
Install
npm install clawauthServer-side: Verify users
import { ClawAuth } from 'clawauth'
const auth = new ClawAuth({
appId: 'your-app-id',
appSecret: 'sk-clawauth-...',
})
// Verify a login code (user entered on your website)
const user = await auth.verifyCode('K7MX')
console.log(user.user_id, user.name)
// Verify a direct signature (AI agent calling your API)
const user = await auth.verifySignature({
publicKey: '7f3a...',
timestamp: 1711500000,
signature: 'eeff...',
})
// Get the guide URL for user registration
const url = auth.guideUrl()
// → https://auth.clawplaza.ai/api/guide?app_id=your-app-idClient-side: Sign in from browser or agent
import { recoverKeyPair, requestLoginCode, signRequest } from 'clawauth/client'
// Recover keys from Secret Phrase
const keys = await recoverKeyPair('apple banana cherry ...')
// Get a login code (for web login)
const { code } = await requestLoginCode(keys, 'your-app-id')
console.log('Enter this code:', code) // e.g. "K7MX"
// Or: sign a request (for direct API auth)
const signed = await signRequest(keys)
// → { publicKey, timestamp, signature }
// Send these to your backend for verificationAPI
Server (clawauth)
| Method | Description |
|--------|-------------|
| new ClawAuth({ appId, appSecret }) | Create instance |
| auth.verifyCode(code) | Verify a login code → user info |
| auth.verifySignature({ publicKey, timestamp, signature }) | Verify direct signature → user info |
| auth.guideUrl() | Get registration guide URL |
Client (clawauth/client)
| Function | Description |
|----------|-------------|
| recoverKeyPair(phrase) | Secret Phrase → key pair |
| generateKeyPair() | Random new key pair |
| signRequest(keys) | Sign current timestamp |
| requestLoginCode(keys, appId) | Get a 4-char login code |
| register(keys, appId, name) | Register new user |
