webAI provides two APIs for identity and security: UserIdentityManager for accessing the current user’s identity, and E2ECrypto for encrypting and decrypting data between peers. These APIs are especially useful when building collaborative apps where you need to identify participants or secure data in transit.Documentation Index
Fetch the complete documentation index at: https://developers.webai.com/llms.txt
Use this file to discover all available pages before exploring further.
UserIdentityManager
UserIdentityManager provides access to the current user’s decentralized identity. In webAI, every device generates a unique identity called an (On-Device Identity) — there are no accounts, no usernames, and no central identity server.Getting the user’s identity
getOrCreateIdentity()
Returns the current user’s device identity. If no identity exists yet, one is created automatically.
Returns: Promise<{ odid: string, displayName: string }>
| Field | Type | Description |
|---|---|---|
odid | string | The unique on-device identity string |
displayName | string | The user’s chosen display name |
getAuthHeaders()
Returns HTTP-style authentication headers for requests. Useful when your app needs to make authenticated requests to other peers in a space.
Promise<object> — a headers object suitable for use with fetch() or similar.
Handling identity in local development
When running outside the webAI shell,UserIdentityManager is null. Return sensible defaults so your app still works:
Using identity in your app
- React
- Vue
End-to-end encryption
The E2ECrypto API provides encrypt and decrypt helpers for securing data exchanged between peers. This is the same encryption layer used internally by the collaboration system.encrypt(text, recipientPublicKeyJwk)
Encrypts plaintext using the recipient’s RSA public key.
- Algorithm: RSA-OAEP with SHA-256
- Input: plaintext
stringand recipient’s public key in JWK format - Returns:
Promise<string>— base64-encoded ciphertext
decrypt(encryptedBase64, privateKeyJwk)
Decrypts base64-encoded ciphertext using your private key.
- Algorithm: RSA-OAEP with SHA-256
- Input: base64 ciphertext
stringand your private key in JWK format - Returns:
Promise<string>— decrypted plaintext - On failure, returns
"[Unable to decrypt message]"instead of throwing
E2ECrypto is automatically used by the platform’s built-in collaboration features. You only need to use it directly if you’re building custom encrypted data flows on top of the collaboration layer.
API summary
| API | Method | Description |
|---|---|---|
UserIdentityManager | getOrCreateIdentity() | Returns the user’s ODID and display name |
UserIdentityManager | getAuthHeaders() | Returns auth headers for P2P requests |
E2ECrypto | encrypt(text, pubKeyJwk) | RSA-OAEP encrypt with recipient’s public key |
E2ECrypto | decrypt(ciphertext, privKeyJwk) | RSA-OAEP decrypt with your private key |
Next steps
App lifecycle
Build, bundle, and deploy your finished app.
Collaboration API
Combine identity with spaces for a full collaborative experience.