Rust crate novren-id
Sign-in for desktop apps through the system browser, with the loopback callback on 127.0.0.1 (RFC 8252). The twin of @novren/id-client/app: same protocol, same cryptography (AES-256-GCM, HKDF, Ed25519, X-Wing).
[dependencies]
novren-id = { git = "https://github.com/novrenIris/novrenID", tag = "packages-v2026.11.6" }Async functions use reqwest with rustls; any Tokio runtime works. Errors are novren_id::Error; novren_id::Result<T> is the short form.
A complete example is in Desktop apps.
novren_id::app
begin_login(account_url, client_id)
Binds a listener on 127.0.0.1:0, prepares PKCE, state and the ephemeral key, and builds the callback URL http://127.0.0.1:<port>/callback.
Returns Result<(String, Loopback)>: the URL to open in the system browser and the Loopback that waits for the answer. loopback.pending is the PendingLogin.
The client must have the loopback callback with path /callback.
create_login_request(account_url, client_id, redirect_uri)
Prepares a request without a local server, for a redirect_uri you choose (for example when the embedded form is shown in your app's window and the return address is collected another way).
Returns Result<(String, PendingLogin)>.
callback_from_return_url(return_url, pending)
Reads a complete return address (query + fragment) and checks state.
Returns Result<Callback>.
Loopback::wait(timeout) and wait_cancellable(timeout, cancelled)
Wait for the browser to come back, up to timeout. wait_cancellable also stops when the AtomicBool becomes true (a "Cancel" button). They serve a tiny page that posts the fragment back to the local server, accept a single post, then close.
Returns Result<Callback>.
Callback
| Field | Type | Meaning |
|---|---|---|
code | String | the one-time code (60 seconds) |
envelope | String | the sealed app key |
account_id | String | the account id |
product | String | your app id |
email | Option<String> | to display |
open_product_key(callback, pending)
Opens the envelope with the ephemeral key and the context of this request.
Returns Result<ProductLogin>: account_id, product, product_key: Zeroizing<[u8; 32]> (wiped on drop), identity: ProductIdentity.
exchange_code(id_server_url, pending, code)
POST /oauth/token with the code and the PKCE verifier.
Returns Result<TokenResponse>: access_token, refresh_token, expires_in, token_type. 400/401 from the server become Error::Login; other failures Error::Network.
refresh(id_server_url, client_id, refresh_token)
New tokens. The old refresh token stops working; presenting it again closes the chain. Error::Login means: sign in again.
revoke(id_server_url, client_id, refresh_token)
Closes the chain (logout).
Other modules
The crate also exposes the cryptographic building blocks used above (envelope, handoff, identity, primitives, protocol, xwing). You don't need them for sign-in; they exist so desktop apps can share the exact formats of the web SDK.