Expand description
Server-side SDK for Decane Connect Kit.
Verify a caller’s Decane access token, resolve their wallet addresses, sign users in from a backend, read and write per-user records, and create users and wallets before they sign in. Async-only, on tokio.
use decane::DecaneClient;
let decane = DecaneClient::builder()
.app_id("your-project-id")
// api_key, project_secret and verification_key can also come from
// DECANE_API_KEY, DECANE_PROJECT_SECRET and DECANE_VERIFICATION_KEY.
.build()?;
// Any authenticated route: pull the bearer token and verify it.
let claims = decane.verify_access_token("…").await?;
claims.user_id; // the stable Decane user id
// Server-side sign-in:
decane.connect_with_email("user@example.com").await?;
let session = decane.verify_email_code("user@example.com", "123456").await?;
session.access_token; // a Decane JWT: verify it, or hand it to the clientTwo verification modes: a static verification key (your project’s ES256 SPKI PEM public key, verified offline with no network call) or the JWKS Decane publishes (fetched lazily, cached for ten minutes, and refetched once when a signature fails, so key rotation needs no redeploy).
Verification is stateless (signature, expiry and project_id). It does not
consult Decane’s server-side revocation list; gate sensitive routes on a
fresh backend call as well if you need immediate sign-out enforcement.
Structs§
- Addresses
- A user’s public wallet addresses. Never contains key material.
- Auth
Profile - Provider profile passed through at sign-in: Google returns name, email and picture; KingsChat name and email. Decane never stores it; it exists only in the sign-in response.
- Auth
Result - The result of a successful server-side sign-in.
- Claims
- Verified, normalised claims from a Decane access token.
- Create
User Options - Options for
DecaneClient::create_user. Unset fields are left out of the request. - Created
User - What
create_userandcreate_user_walletresolve to. - Created
User Info - The user part of a
CreatedUser. - Decane
Client - Verifies Decane access tokens, resolves user addresses, signs users in, reads and writes per-user records, and creates users and wallets.
- Decane
Client Builder - Builds a
DecaneClient. Every field is optional; see each setter for its env-var fallback. - Kings
Chat Config - The project’s KingsChat OAuth client config, for building a consent URL.
- Link
Result - The outcome of
DecaneClient::link_external_login. - Linked
Account - A linked-wallet account, in a Privy-compatible shape for easy migration.
- Linked
Login - A login attached to an account with
DecaneClient::link_external_login. - User
- A resolved user: verified identity plus their on-chain addresses.
Enums§
- ApiError
Code - Backend error codes surfaced by
DecaneError::Api. - Auth
Error Reason - Why an access token was refused.
- Chain
Type - The chain family of a
LinkedAccount. - Decane
Error - Everything this crate can fail with.
- Linked
Account Type - The kind of a
LinkedAccount; only wallets today. - Record
Value - A value in a per-user record: a string, a number or a boolean.
- User
Identifier - Who a pre-created user is, in the terms the matching sign-in will use. The person’s first sign-in with this identifier lands on the same user (and the wallet made for them), because Decane keys the row exactly as that sign-in would.
- Wallet
Outcome - The wallet outcome of a creation call.
Constants§
- DEFAULT_
API_ BASE - Default Decane backend base URL. Override per environment with
DecaneClientBuilder::api_baseor theDECANE_API_BASEenv var.
Type Aliases§
- Record
- A per-user record as Decane stores it: flat, with string, number and
boolean values under short keys (
[A-Za-z0-9_.-]{1,64}). At most 100 keys and 32 KB serialised; strings at most 2048 characters. - Record
Patch - A merge: each key is set to its value, or removed when the value is
None. Keys not named are untouched. - Result
ResultwithDecaneErroras the default error type.- Source
- The underlying error behind a
DecaneError, when there is one.