Skip to main content

Crate decane

Crate decane 

Source
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 client

Two 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.
AuthProfile
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.
AuthResult
The result of a successful server-side sign-in.
Claims
Verified, normalised claims from a Decane access token.
CreateUserOptions
Options for DecaneClient::create_user. Unset fields are left out of the request.
CreatedUser
What create_user and create_user_wallet resolve to.
CreatedUserInfo
The user part of a CreatedUser.
DecaneClient
Verifies Decane access tokens, resolves user addresses, signs users in, reads and writes per-user records, and creates users and wallets.
DecaneClientBuilder
Builds a DecaneClient. Every field is optional; see each setter for its env-var fallback.
KingsChatConfig
The project’s KingsChat OAuth client config, for building a consent URL.
LinkResult
The outcome of DecaneClient::link_external_login.
LinkedAccount
A linked-wallet account, in a Privy-compatible shape for easy migration.
LinkedLogin
A login attached to an account with DecaneClient::link_external_login.
User
A resolved user: verified identity plus their on-chain addresses.

Enums§

ApiErrorCode
Backend error codes surfaced by DecaneError::Api.
AuthErrorReason
Why an access token was refused.
ChainType
The chain family of a LinkedAccount.
DecaneError
Everything this crate can fail with.
LinkedAccountType
The kind of a LinkedAccount; only wallets today.
RecordValue
A value in a per-user record: a string, a number or a boolean.
UserIdentifier
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.
WalletOutcome
The wallet outcome of a creation call.

Constants§

DEFAULT_API_BASE
Default Decane backend base URL. Override per environment with DecaneClientBuilder::api_base or the DECANE_API_BASE env 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.
RecordPatch
A merge: each key is set to its value, or removed when the value is None. Keys not named are untouched.
Result
Result with DecaneError as the default error type.
Source
The underlying error behind a DecaneError, when there is one.