Skip to content

feat(gl-sdk): add high-level auth API with Config, register, recover, connect#688

Open
angelix wants to merge 1 commit intomainfrom
wip/sdk-improvements
Open

feat(gl-sdk): add high-level auth API with Config, register, recover, connect#688
angelix wants to merge 1 commit intomainfrom
wip/sdk-improvements

Conversation

@angelix
Copy link
Copy Markdown
Contributor

@angelix angelix commented Apr 1, 2026

Summary

  • Add a high-level auth API (register, recover, connect, register_or_recover) that replaces the multi-object ceremony (Signer → Scheduler → register/recover → build Node) with single function calls
  • Add Config builder type for network selection and optional DeveloperCert
  • Add Node.credentials() / Node.disconnect() and guard all RPC methods against use-after-disconnect
  • Move signer execution to a shared tokio runtime (Handle::spawn) to avoid per-signer threads and block_on deadlocks

Motivation

The current low-level API requires apps to manually orchestrate 4+ objects to get a working node. This is error-prone and exposes internal details (credential serialization, signer lifecycle, runtime management) that most apps don't need to
think about. The high-level API reduces the happy path to:

let config = Config::new();
let node = register_or_recover(mnemonic, invite_code, &config)?;
let creds = node.credentials()?; // persist these
// ... later ...                                                                                                                                                                                                                                
let node = connect(mnemonic, saved_creds, &config)?;
                                                                                                                                                                                                                                                
The low-level API (Signer, Scheduler, Node::new) remains available and unchanged.

Test plan

- Python integration tests (libs/gl-sdk/tests/test_auth_api.py): Config builder, register, recover, connect, register_or_recover, disconnect idempotency, duplicate register error, credentials roundtrip, multiple simultaneous nodes,         
disconnect blocks RPC, low-level credentials still work
- Android instrumented tests (AuthApiTest.kt, NodeOperationsTest.kt): Config construction, bad mnemonic errors, register-or-recover flow, credentials roundtrip via connect, disconnect idempotency, invoice creation, low-level API still works
- Verify low-level Signer.start() still works (uses Handle::spawn internally now)                                                                                                                                                               
 

@angelix angelix force-pushed the wip/sdk-improvements branch from 8990533 to 75c4a4f Compare April 1, 2026 19:27
High-level auth API: Config type (network + optional DeveloperCert)
and four free functions — register(), recover(), connect(),
register_or_recover() — replacing the multi-object auth ceremony.

Node gains credentials(), disconnect() with AtomicBool guard on all
RPC methods, and with_signer() internal constructor. Handle::spawn()
runs signers on a dedicated tokio runtime to avoid block_on deadlock.

NAPI fix: Node lost Clone when AtomicBool was added. Wrap inner
GlNode in Arc at the NAPI wrapper level for spawn_blocking, matching
the existing NodeEventStream pattern.

Includes Python and Android instrumented tests for the auth API.
@angelix angelix force-pushed the wip/sdk-improvements branch from 75c4a4f to 5cb9e0a Compare April 1, 2026 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant