Skip to main content

Module auth

Module auth 

Source
Expand description

Tempo wallet device-code authorization flow.

Implements the CLI side of the tempoxyz/accounts cli-auth device-code protocol: generates a local secp256k1 access key, creates a PKCE-protected device code, opens wallet.tempo.xyz/cli-auth?code=<CODE> in the browser, polls until the user authorizes the key on their passkey wallet, and writes the resulting access key to the Tempo Accounts store.json.

Re-exportsΒ§

use crate::tempo::decode_key_authorization; πŸ”’
use alloy_primitives::Address; πŸ”’
use alloy_primitives::B256; πŸ”’
use alloy_primitives::hex; πŸ”’
use alloy_primitives::hex; πŸ”’
use alloy_signer_local::PrivateKeySigner; πŸ”’
use base64::Engine; πŸ”’
use base64::engine::general_purpose::URL_SAFE_NO_PAD; πŸ”’
use eyre::Result; πŸ”’
use serde::Deserialize; πŸ”’
use serde::Deserialize; πŸ”’
use serde::Serialize; πŸ”’
use serde::Serialize; πŸ”’
use sha2::Digest; πŸ”’
use sha2::Sha256; πŸ”’
use std::env; πŸ”’
use std::env; πŸ”’
use std::sync::LazyLock; πŸ”’
use std::time::Duration; πŸ”’
use std::time::Instant; πŸ”’
use tempo_alloy::accounts::TempoAccountsKeyAuthorization; πŸ”’
use tempo_alloy::accounts::TempoAccountsStore; πŸ”’
use tempo_primitives::transaction::SignatureType; πŸ”’
use tempo_primitives::transaction::SignedKeyAuthorization; πŸ”’
use tokio::sync::Mutex; πŸ”’
use std::process::Command; πŸ”’ Unix or Windows

StructsΒ§

AccessKeyOutcome
Result of ensure_access_key.
CreateCodeRequest πŸ”’
CreateCodeResponse πŸ”’
EnsureAccessKeyConfig
Configuration for ensure_access_key.
PollRequest πŸ”’

EnumsΒ§

PollKeyAuthorization πŸ”’
PollResponse πŸ”’
Matches tempoxyz/wallet poll response shape.

ConstantsΒ§

DEFAULT_CLI_AUTH_URL πŸ”’
Default device-code service URL (production wallet.tempo.xyz).
DEFAULT_POLL_INTERVAL πŸ”’
DEFAULT_TIMEOUT πŸ”’
TEMPO_CLI_AUTH_URL_ENV πŸ”’
Env var to override the device-code service URL (for tests / staging).

StaticsΒ§

AUTH_LOCK πŸ”’
Per-process serialization of concurrent ensure_access_key calls.

FunctionsΒ§

create_code_with_retry πŸ”’
POST /code with exponential backoff on transient errors, bounded by timeout.
ensure_access_key
Run the device-code flow, persist the resulting key to store.json, and return the new entry’s identifying fields.
is_known_tempo_endpoint πŸ”’
Returns true if url’s host is tempo.xyz or a subdomain of it.
is_transient_error πŸ”’
is_transient_status πŸ”’
open_browser πŸ”’
Open url via the OS default browser handler. On platforms without a known opener, this is a no-op (the URL is still printed by ensure_access_key).
random_code_verifier πŸ”’
serialize_u64_hex πŸ”’
sha256_b64url πŸ”’