@buildaureon/sdk 0.1.8 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/auth.md CHANGED
@@ -1,176 +1,176 @@
1
- # Authentication Guide
2
-
3
- How `@buildaureon/sdk` authenticates to the hosted AUREON API for agents, scripts, and server integrations.
4
-
5
- **Automation note:** The SDK path is designed for **Automatic** objectives only (`automationMode: "auto"`). Manual operator Approve flows belong in the utility UI, not in SDK agent loops.
6
-
7
- ---
8
-
9
- ## 1. Authentication topology
10
-
11
- ```mermaid
12
- graph TD
13
- Request[Client_request] --> BearerCheck{Valid_Bearer?}
14
- BearerCheck -->|Yes| Process[Act_as_session_wallet]
15
- BearerCheck -->|No| KeyCheck{API_key_present?}
16
- KeyCheck -->|No| Reject1[401_missing_credentials]
17
- KeyCheck -->|Yes| IssuedCheck{Issued_developer_key?}
18
- IssuedCheck -->|Yes| ProcessKey[Act_as_key_bound_wallet]
19
- IssuedCheck -->|No_env_bootstrap| Reject2[401_need_issued_key_or_Bearer]
20
- ```
21
-
22
- | Credential | Header | Role |
23
- | --- | --- | --- |
24
- | **Issued API key** (Developers console) | `X-Aureon-Api-Key` | Product access **and** wallet identity for control-plane calls |
25
- | **Env bootstrap key** (`AUREON_API_KEYS` on server) | `X-Aureon-Api-Key` | Product gate only — does **not** identify a wallet |
26
- | **Wallet Bearer** | `Authorization: Bearer …` | Optional session identity. **Wins** when both Bearer and key are present |
27
- | **Private key** | (chain only) | Sign/broadcast deposit & withdraw txs — never sent to the API |
28
-
29
- Control-plane calls (sync, objectives, health, restore, vault reads, prepare-*) need an **issued** developer key **or** a Bearer session. Moving capital on-chain always needs a local signer.
30
-
31
- ---
32
-
33
- ## 2. Recommended path: issued API key
34
-
35
- 1. Open the operator utility → **Developers**.
36
- 2. Create a key. Copy the plaintext once.
37
- 3. Set env and construct the client:
38
-
39
- ```ts
40
- import { createAureonClient } from "@buildaureon/sdk";
41
-
42
- const aureon = createAureonClient({
43
- apiKey: process.env.AUREON_API_KEY!, // issued key from Developers
44
- // omit network → mainnet 4663 / http://127.0.0.1:8788
45
- // network: "testnet" → public host (still 46630)
46
- });
47
-
48
- const me = await aureon.me();
49
- console.log("wallet", me.walletAddress);
50
-
51
- const vault = await aureon.getVaultStatus();
52
- const objectives = await aureon.listObjectives();
53
- ```
54
-
55
- No Bearer token is required for this path. The gateway resolves the wallet bound to the issued key.
56
-
57
- ### Deposit / withdraw still need a private key
58
-
59
- ```ts
60
- const prep = await aureon.prepareVaultDeposit({ symbol: "ETH", amount: "0.1" });
61
- // prep.steps are UNSIGNED — sign and broadcast with viem / ethers / your wallet host
62
- ```
63
-
64
- The API key can request prepare steps. It cannot sign chain transactions.
65
-
66
- ---
67
-
68
- ## 3. Optional Bearer handshake
69
-
70
- Use when you intentionally want a wallet session, or when you only have an env bootstrap key (no issued key).
71
-
72
- ```mermaid
73
- sequenceDiagram
74
- autonumber
75
- participant Client as SDK_client
76
- participant API as Aureon_API
77
- participant Signer as Wallet_signer
78
-
79
- Client->>API: GET /auth/nonce?address=0x...
80
- API-->>Client: challenge message
81
- Client->>Signer: personal_sign(message)
82
- Signer-->>Client: signature
83
- Client->>API: POST /auth/verify
84
- API-->>Client: session token
85
- ```
86
-
87
- ```ts
88
- import { createAureonClient, createSessionTokenProvider } from "@buildaureon/sdk";
89
-
90
- const session = createSessionTokenProvider(null);
91
- const aureon = createAureonClient({
92
- network: "testnet", // public host, still chain 46630
93
- apiKey: process.env.AUREON_API_KEY,
94
- getAccessToken: session.getAccessToken,
95
- });
96
-
97
- const { message } = await aureon.getAuthNonce(address);
98
- const signature = await wallet.signMessage({ message });
99
- const login = await aureon.verifyWallet({ address, message, signature });
100
- session.setToken(login.token);
101
-
102
- await aureon.me();
103
- ```
104
-
105
- ### Challenge message shape
106
-
107
- ```text
108
- AUREON Login Challenge
109
- Wallet: 0x742d35Cc6634C0532925a3b844Bc454e4438f44e
110
- Nonce: c8a99478fcd9185a494f
111
- Timestamp: 2026-07-15T22:45:00.000Z
112
- Expires: 2026-07-15T22:50:00.000Z
113
-
114
- Sign this message to prove ownership of the wallet.
115
- ```
116
-
117
- ### Session provider lifecycle
118
-
119
- ```ts
120
- session.setToken(login.token); // after verify
121
- await aureon.logout();
122
- session.clear();
123
- ```
124
-
125
- `createSessionTokenProvider` keeps the client free of global mutable auth state. Prefer `getAccessToken` over a static `authToken` when sessions can rotate.
126
-
127
- ---
128
-
129
- ## 4. Precedence and edge cases
130
-
131
- | Situation | Result |
132
- | --- | --- |
133
- | Issued key only | Act as key-bound wallet |
134
- | Bearer only | Act as session wallet |
135
- | Bearer + any key | Bearer wins (key validated if sent) |
136
- | Env bootstrap key only | 401 — cannot identify a wallet |
137
- | Invalid / paused / revoked issued key | 401 |
138
- | `devLogin()` | Local preview APIs only — not production |
139
-
140
- ---
141
-
142
- ## 5. Environment variables
143
-
144
- | Variable | Required | Description |
145
- | --- | --- | --- |
146
- | `AUREON_API_KEY` | Recommended | Issued developer key |
147
- | `AUREON_NETWORK` | No | Omit for mainnet 4663 / `http://127.0.0.1:8788`. Set `testnet` for the public host (still 46630). |
148
- | `AUREON_API_URL` | No | Optional override. Must match `AUREON_NETWORK` if both are set. |
149
- | `AUREON_TOKEN` | No | Optional Bearer for CLI / scripts |
150
-
151
- CLI example:
152
-
153
- ```bash
154
- export AUREON_API_KEY=aureon_....
155
- pnpm --filter @buildaureon/sdk cli me
156
- pnpm --filter @buildaureon/sdk cli sync
157
- pnpm --filter @buildaureon/sdk cli objectives
158
- ```
159
-
160
- ---
161
-
162
- ## 6. Security rules
163
-
164
- - Treat issued keys like passwords: pause, revoke, rotate in Developers.
165
- - Never commit keys or Bearer tokens.
166
- - Never put private keys in SDK env for “convenience.”
167
- - Do not log `Authorization` or `X-Aureon-Api-Key` headers.
168
-
169
- ---
170
-
171
- ## 7. Related docs
172
-
173
- - [Integration guide](./integration-guide.md)
174
- - [Security](./security.md)
175
- - [Client API](./client-api.md)
176
- - [Error model](./error-model.md)
1
+ # Authentication Guide
2
+
3
+ How `@buildaureon/sdk` authenticates to the hosted AUREON API for agents, scripts, and server integrations.
4
+
5
+ **Automation note:** The SDK path is designed for **Automatic** objectives only (`automationMode: "auto"`). Manual operator Approve flows belong in the utility UI, not in SDK agent loops.
6
+
7
+ ---
8
+
9
+ ## 1. Authentication topology
10
+
11
+ ```mermaid
12
+ graph TD
13
+ Request[Client_request] --> BearerCheck{Valid_Bearer?}
14
+ BearerCheck -->|Yes| Process[Act_as_session_wallet]
15
+ BearerCheck -->|No| KeyCheck{API_key_present?}
16
+ KeyCheck -->|No| Reject1[401_missing_credentials]
17
+ KeyCheck -->|Yes| IssuedCheck{Issued_developer_key?}
18
+ IssuedCheck -->|Yes| ProcessKey[Act_as_key_bound_wallet]
19
+ IssuedCheck -->|No_env_bootstrap| Reject2[401_need_issued_key_or_Bearer]
20
+ ```
21
+
22
+ | Credential | Header | Role |
23
+ | --- | --- | --- |
24
+ | **Issued API key** (Developers console) | `X-Aureon-Api-Key` | Product access **and** wallet identity for control-plane calls |
25
+ | **Env bootstrap key** (`AUREON_API_KEYS` on server) | `X-Aureon-Api-Key` | Product gate only — does **not** identify a wallet |
26
+ | **Wallet Bearer** | `Authorization: Bearer …` | Optional session identity. **Wins** when both Bearer and key are present |
27
+ | **Private key** | (chain only) | Sign/broadcast deposit & withdraw txs — never sent to the API |
28
+
29
+ Control-plane calls (sync, objectives, health, restore, vault reads, prepare-*) need an **issued** developer key **or** a Bearer session. Moving capital on-chain always needs a local signer.
30
+
31
+ ---
32
+
33
+ ## 2. Recommended path: issued API key
34
+
35
+ 1. Open the operator utility → **Developers**.
36
+ 2. Create a key. Copy the plaintext once.
37
+ 3. Set env and construct the client:
38
+
39
+ ```ts
40
+ import { createAureonClient } from "@buildaureon/sdk";
41
+
42
+ const aureon = createAureonClient({
43
+ apiKey: process.env.AUREON_API_KEY!, // issued key from Developers
44
+ // omit network → official API / mainnet
45
+ // network: "testnet" → stay on testnet on the same official host
46
+ });
47
+
48
+ const me = await aureon.me();
49
+ console.log("wallet", me.walletAddress);
50
+
51
+ const vault = await aureon.getVaultStatus();
52
+ const objectives = await aureon.listObjectives();
53
+ ```
54
+
55
+ No Bearer token is required for this path. The gateway resolves the wallet bound to the issued key.
56
+
57
+ ### Deposit / withdraw still need a private key
58
+
59
+ ```ts
60
+ const prep = await aureon.prepareVaultDeposit({ symbol: "ETH", amount: "0.1" });
61
+ // prep.steps are UNSIGNED — sign and broadcast with viem / ethers / your wallet host
62
+ ```
63
+
64
+ The API key can request prepare steps. It cannot sign chain transactions.
65
+
66
+ ---
67
+
68
+ ## 3. Optional Bearer handshake
69
+
70
+ Use when you intentionally want a wallet session, or when you only have an env bootstrap key (no issued key).
71
+
72
+ ```mermaid
73
+ sequenceDiagram
74
+ autonumber
75
+ participant Client as SDK_client
76
+ participant API as Aureon_API
77
+ participant Signer as Wallet_signer
78
+
79
+ Client->>API: GET /auth/nonce?address=0x...
80
+ API-->>Client: challenge message
81
+ Client->>Signer: personal_sign(message)
82
+ Signer-->>Client: signature
83
+ Client->>API: POST /auth/verify
84
+ API-->>Client: session token
85
+ ```
86
+
87
+ ```ts
88
+ import { createAureonClient, createSessionTokenProvider } from "@buildaureon/sdk";
89
+
90
+ const session = createSessionTokenProvider(null);
91
+ const aureon = createAureonClient({
92
+ network: "testnet", // opt-in testnet, chain 46630
93
+ apiKey: process.env.AUREON_API_KEY,
94
+ getAccessToken: session.getAccessToken,
95
+ });
96
+
97
+ const { message } = await aureon.getAuthNonce(address);
98
+ const signature = await wallet.signMessage({ message });
99
+ const login = await aureon.verifyWallet({ address, message, signature });
100
+ session.setToken(login.token);
101
+
102
+ await aureon.me();
103
+ ```
104
+
105
+ ### Challenge message shape
106
+
107
+ ```text
108
+ AUREON Login Challenge
109
+ Wallet: 0x742d35Cc6634C0532925a3b844Bc454e4438f44e
110
+ Nonce: c8a99478fcd9185a494f
111
+ Timestamp: 2026-07-15T22:45:00.000Z
112
+ Expires: 2026-07-15T22:50:00.000Z
113
+
114
+ Sign this message to prove ownership of the wallet.
115
+ ```
116
+
117
+ ### Session provider lifecycle
118
+
119
+ ```ts
120
+ session.setToken(login.token); // after verify
121
+ await aureon.logout();
122
+ session.clear();
123
+ ```
124
+
125
+ `createSessionTokenProvider` keeps the client free of global mutable auth state. Prefer `getAccessToken` over a static `authToken` when sessions can rotate.
126
+
127
+ ---
128
+
129
+ ## 4. Precedence and edge cases
130
+
131
+ | Situation | Result |
132
+ | --- | --- |
133
+ | Issued key only | Act as key-bound wallet |
134
+ | Bearer only | Act as session wallet |
135
+ | Bearer + any key | Bearer wins (key validated if sent) |
136
+ | Env bootstrap key only | 401 — cannot identify a wallet |
137
+ | Invalid / paused / revoked issued key | 401 |
138
+ | `devLogin()` | Local preview APIs only — not production |
139
+
140
+ ---
141
+
142
+ ## 5. Environment variables
143
+
144
+ | Variable | Required | Description |
145
+ | --- | --- | --- |
146
+ | `AUREON_API_KEY` | Recommended | Issued developer key |
147
+ | `AUREON_NETWORK` | No | Omit for official API / mainnet. Set `testnet` to stay on testnet. |
148
+ | `AUREON_API_URL` | No | Optional override of `https://api.aureonlabs.network`. |
149
+ | `AUREON_TOKEN` | No | Optional Bearer for CLI / scripts |
150
+
151
+ CLI example:
152
+
153
+ ```bash
154
+ export AUREON_API_KEY=aureon_....
155
+ pnpm --filter @buildaureon/sdk cli me
156
+ pnpm --filter @buildaureon/sdk cli sync
157
+ pnpm --filter @buildaureon/sdk cli objectives
158
+ ```
159
+
160
+ ---
161
+
162
+ ## 6. Security rules
163
+
164
+ - Treat issued keys like passwords: pause, revoke, rotate in Developers.
165
+ - Never commit keys or Bearer tokens.
166
+ - Never put private keys in SDK env for “convenience.”
167
+ - Do not log `Authorization` or `X-Aureon-Api-Key` headers.
168
+
169
+ ---
170
+
171
+ ## 7. Related docs
172
+
173
+ - [Integration guide](./integration-guide.md)
174
+ - [Security](./security.md)
175
+ - [Client API](./client-api.md)
176
+ - [Error model](./error-model.md)