Connect
connect() opens an authenticated session. It's what you call every time you need to act on behalf of a user.
API Key — server-to-server (recommended for backends)
The simplest path. Pass your sk_ key and the SDK auto-exchanges it for a JWT.
The client object now has full access to all SDK capabilities:
Verify: client.urn resolves to your identity
did:bloque:your-origin:your-alias
Origin Key — connect as a specific user
When using originKey auth (managing user identities directly), pass the alias to connect as that user:
The user must be registered first via sdk.register(). See Register.
JWT — browser and React Native
For frontend apps where users authenticate directly:
Use secure token storage in production
localStorage is vulnerable to XSS. For production browser apps, use httpOnly cookies. For React Native, use expo-secure-store or equivalent.
API Key vs Origin Key
An API key (sk_) is scoped to your account — it connects as you. An Origin Key is scoped to your Origin namespace — it lets you connect as any user registered in that namespace. Use API keys for your own backend operations; use Origin keys when managing identities on behalf of others.
What's next
→ Sandbox — test safely before going to production