@buildaureon/sdk 0.1.1 → 0.1.7
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/README.md +655 -640
- package/dist/index.d.ts +713 -89
- package/dist/index.js +1754 -190
- package/dist/index.js.map +1 -1
- package/docs/architecture.md +206 -206
- package/docs/auth.md +174 -174
- package/docs/client-api.md +782 -605
- package/docs/data-contracts.md +710 -635
- package/docs/error-model.md +217 -217
- package/docs/integration-guide.md +397 -257
- package/docs/receipt-validation.md +63 -0
- package/docs/security.md +120 -120
- package/docs/transport.md +142 -142
- package/examples/ai-to-objective-to-portfolio/main.ts +127 -0
- package/examples/audit-trail/main.ts +53 -0
- package/examples/drift-detect-restore/main.ts +96 -0
- package/examples/full-aureon-loop/main.ts +83 -0
- package/examples/green-vs-plan/main.ts +139 -0
- package/examples/market-event/main.ts +67 -65
- package/examples/portfolio-watch/main.ts +84 -0
- package/examples/quickstart/main.ts +72 -72
- package/examples/receipt-verification/main.ts +87 -0
- package/examples/registry-register/main.ts +44 -0
- package/package.json +8 -1
package/docs/auth.md
CHANGED
|
@@ -1,174 +1,174 @@
|
|
|
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
|
-
baseUrl: "https://api.aureonlabs.network",
|
|
44
|
-
apiKey: process.env.AUREON_API_KEY!, // issued key from Developers
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const me = await aureon.me();
|
|
48
|
-
console.log("wallet", me.walletAddress);
|
|
49
|
-
|
|
50
|
-
const vault = await aureon.getVaultStatus();
|
|
51
|
-
const objectives = await aureon.listObjectives();
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
No Bearer token is required for this path. The gateway resolves the wallet bound to the issued key.
|
|
55
|
-
|
|
56
|
-
### Deposit / withdraw still need a private key
|
|
57
|
-
|
|
58
|
-
```ts
|
|
59
|
-
const prep = await aureon.prepareVaultDeposit({ symbol: "ETH", amount: "0.1" });
|
|
60
|
-
// prep.steps are UNSIGNED — sign and broadcast with viem / ethers / your wallet host
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
The API key can request prepare steps. It cannot sign chain transactions.
|
|
64
|
-
|
|
65
|
-
---
|
|
66
|
-
|
|
67
|
-
## 3. Optional Bearer handshake
|
|
68
|
-
|
|
69
|
-
Use when you intentionally want a wallet session, or when you only have an env bootstrap key (no issued key).
|
|
70
|
-
|
|
71
|
-
```mermaid
|
|
72
|
-
sequenceDiagram
|
|
73
|
-
autonumber
|
|
74
|
-
participant Client as SDK_client
|
|
75
|
-
participant API as Aureon_API
|
|
76
|
-
participant Signer as Wallet_signer
|
|
77
|
-
|
|
78
|
-
Client->>API: GET /auth/nonce?address=0x...
|
|
79
|
-
API-->>Client: challenge message
|
|
80
|
-
Client->>Signer: personal_sign(message)
|
|
81
|
-
Signer-->>Client: signature
|
|
82
|
-
Client->>API: POST /auth/verify
|
|
83
|
-
API-->>Client: session token
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
```ts
|
|
87
|
-
import { createAureonClient, createSessionTokenProvider } from "@buildaureon/sdk";
|
|
88
|
-
|
|
89
|
-
const session = createSessionTokenProvider(null);
|
|
90
|
-
const aureon = createAureonClient({
|
|
91
|
-
baseUrl: "https://api.aureonlabs.network",
|
|
92
|
-
apiKey: process.env.AUREON_API_KEY,
|
|
93
|
-
getAccessToken: session.getAccessToken,
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
const { message } = await aureon.getAuthNonce(address);
|
|
97
|
-
const signature = await wallet.signMessage({ message });
|
|
98
|
-
const login = await aureon.verifyWallet({ address, message, signature });
|
|
99
|
-
session.setToken(login.token);
|
|
100
|
-
|
|
101
|
-
await aureon.me();
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### Challenge message shape
|
|
105
|
-
|
|
106
|
-
```text
|
|
107
|
-
AUREON Login Challenge
|
|
108
|
-
Wallet: 0x742d35Cc6634C0532925a3b844Bc454e4438f44e
|
|
109
|
-
Nonce: c8a99478fcd9185a494f
|
|
110
|
-
Timestamp: 2026-07-15T22:45:00.000Z
|
|
111
|
-
Expires: 2026-07-15T22:50:00.000Z
|
|
112
|
-
|
|
113
|
-
Sign this message to prove ownership of the wallet.
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
### Session provider lifecycle
|
|
117
|
-
|
|
118
|
-
```ts
|
|
119
|
-
session.setToken(login.token); // after verify
|
|
120
|
-
await aureon.logout();
|
|
121
|
-
session.clear();
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
`createSessionTokenProvider` keeps the client free of global mutable auth state. Prefer `getAccessToken` over a static `authToken` when sessions can rotate.
|
|
125
|
-
|
|
126
|
-
---
|
|
127
|
-
|
|
128
|
-
## 4. Precedence and edge cases
|
|
129
|
-
|
|
130
|
-
| Situation | Result |
|
|
131
|
-
| --- | --- |
|
|
132
|
-
| Issued key only | Act as key-bound wallet |
|
|
133
|
-
| Bearer only | Act as session wallet |
|
|
134
|
-
| Bearer + any key | Bearer wins (key validated if sent) |
|
|
135
|
-
| Env bootstrap key only | 401 — cannot identify a wallet |
|
|
136
|
-
| Invalid / paused / revoked issued key | 401 |
|
|
137
|
-
| `devLogin()` | Local preview APIs only — not production |
|
|
138
|
-
|
|
139
|
-
---
|
|
140
|
-
|
|
141
|
-
## 5. Environment variables
|
|
142
|
-
|
|
143
|
-
| Variable | Required | Description |
|
|
144
|
-
| --- | --- | --- |
|
|
145
|
-
| `AUREON_API_KEY` | Recommended | Issued developer key |
|
|
146
|
-
| `AUREON_API_URL` | No | Defaults to `https://api.aureonlabs.network` |
|
|
147
|
-
| `AUREON_TOKEN` | No | Optional Bearer for CLI / scripts |
|
|
148
|
-
|
|
149
|
-
CLI example:
|
|
150
|
-
|
|
151
|
-
```bash
|
|
152
|
-
export AUREON_API_KEY=aureon_....
|
|
153
|
-
pnpm --filter @buildaureon/sdk cli me
|
|
154
|
-
pnpm --filter @buildaureon/sdk cli sync
|
|
155
|
-
pnpm --filter @buildaureon/sdk cli objectives
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
---
|
|
159
|
-
|
|
160
|
-
## 6. Security rules
|
|
161
|
-
|
|
162
|
-
- Treat issued keys like passwords: pause, revoke, rotate in Developers.
|
|
163
|
-
- Never commit keys or Bearer tokens.
|
|
164
|
-
- Never put private keys in SDK env for “convenience.”
|
|
165
|
-
- Do not log `Authorization` or `X-Aureon-Api-Key` headers.
|
|
166
|
-
|
|
167
|
-
---
|
|
168
|
-
|
|
169
|
-
## 7. Related docs
|
|
170
|
-
|
|
171
|
-
- [Integration guide](./integration-guide.md)
|
|
172
|
-
- [Security](./security.md)
|
|
173
|
-
- [Client API](./client-api.md)
|
|
174
|
-
- [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
|
+
baseUrl: "https://api.aureonlabs.network",
|
|
44
|
+
apiKey: process.env.AUREON_API_KEY!, // issued key from Developers
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const me = await aureon.me();
|
|
48
|
+
console.log("wallet", me.walletAddress);
|
|
49
|
+
|
|
50
|
+
const vault = await aureon.getVaultStatus();
|
|
51
|
+
const objectives = await aureon.listObjectives();
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
No Bearer token is required for this path. The gateway resolves the wallet bound to the issued key.
|
|
55
|
+
|
|
56
|
+
### Deposit / withdraw still need a private key
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
const prep = await aureon.prepareVaultDeposit({ symbol: "ETH", amount: "0.1" });
|
|
60
|
+
// prep.steps are UNSIGNED — sign and broadcast with viem / ethers / your wallet host
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The API key can request prepare steps. It cannot sign chain transactions.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## 3. Optional Bearer handshake
|
|
68
|
+
|
|
69
|
+
Use when you intentionally want a wallet session, or when you only have an env bootstrap key (no issued key).
|
|
70
|
+
|
|
71
|
+
```mermaid
|
|
72
|
+
sequenceDiagram
|
|
73
|
+
autonumber
|
|
74
|
+
participant Client as SDK_client
|
|
75
|
+
participant API as Aureon_API
|
|
76
|
+
participant Signer as Wallet_signer
|
|
77
|
+
|
|
78
|
+
Client->>API: GET /auth/nonce?address=0x...
|
|
79
|
+
API-->>Client: challenge message
|
|
80
|
+
Client->>Signer: personal_sign(message)
|
|
81
|
+
Signer-->>Client: signature
|
|
82
|
+
Client->>API: POST /auth/verify
|
|
83
|
+
API-->>Client: session token
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
import { createAureonClient, createSessionTokenProvider } from "@buildaureon/sdk";
|
|
88
|
+
|
|
89
|
+
const session = createSessionTokenProvider(null);
|
|
90
|
+
const aureon = createAureonClient({
|
|
91
|
+
baseUrl: "https://api.aureonlabs.network",
|
|
92
|
+
apiKey: process.env.AUREON_API_KEY,
|
|
93
|
+
getAccessToken: session.getAccessToken,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const { message } = await aureon.getAuthNonce(address);
|
|
97
|
+
const signature = await wallet.signMessage({ message });
|
|
98
|
+
const login = await aureon.verifyWallet({ address, message, signature });
|
|
99
|
+
session.setToken(login.token);
|
|
100
|
+
|
|
101
|
+
await aureon.me();
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Challenge message shape
|
|
105
|
+
|
|
106
|
+
```text
|
|
107
|
+
AUREON Login Challenge
|
|
108
|
+
Wallet: 0x742d35Cc6634C0532925a3b844Bc454e4438f44e
|
|
109
|
+
Nonce: c8a99478fcd9185a494f
|
|
110
|
+
Timestamp: 2026-07-15T22:45:00.000Z
|
|
111
|
+
Expires: 2026-07-15T22:50:00.000Z
|
|
112
|
+
|
|
113
|
+
Sign this message to prove ownership of the wallet.
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Session provider lifecycle
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
session.setToken(login.token); // after verify
|
|
120
|
+
await aureon.logout();
|
|
121
|
+
session.clear();
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`createSessionTokenProvider` keeps the client free of global mutable auth state. Prefer `getAccessToken` over a static `authToken` when sessions can rotate.
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## 4. Precedence and edge cases
|
|
129
|
+
|
|
130
|
+
| Situation | Result |
|
|
131
|
+
| --- | --- |
|
|
132
|
+
| Issued key only | Act as key-bound wallet |
|
|
133
|
+
| Bearer only | Act as session wallet |
|
|
134
|
+
| Bearer + any key | Bearer wins (key validated if sent) |
|
|
135
|
+
| Env bootstrap key only | 401 — cannot identify a wallet |
|
|
136
|
+
| Invalid / paused / revoked issued key | 401 |
|
|
137
|
+
| `devLogin()` | Local preview APIs only — not production |
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 5. Environment variables
|
|
142
|
+
|
|
143
|
+
| Variable | Required | Description |
|
|
144
|
+
| --- | --- | --- |
|
|
145
|
+
| `AUREON_API_KEY` | Recommended | Issued developer key |
|
|
146
|
+
| `AUREON_API_URL` | No | Defaults to `https://api.aureonlabs.network` |
|
|
147
|
+
| `AUREON_TOKEN` | No | Optional Bearer for CLI / scripts |
|
|
148
|
+
|
|
149
|
+
CLI example:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
export AUREON_API_KEY=aureon_....
|
|
153
|
+
pnpm --filter @buildaureon/sdk cli me
|
|
154
|
+
pnpm --filter @buildaureon/sdk cli sync
|
|
155
|
+
pnpm --filter @buildaureon/sdk cli objectives
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## 6. Security rules
|
|
161
|
+
|
|
162
|
+
- Treat issued keys like passwords: pause, revoke, rotate in Developers.
|
|
163
|
+
- Never commit keys or Bearer tokens.
|
|
164
|
+
- Never put private keys in SDK env for “convenience.”
|
|
165
|
+
- Do not log `Authorization` or `X-Aureon-Api-Key` headers.
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## 7. Related docs
|
|
170
|
+
|
|
171
|
+
- [Integration guide](./integration-guide.md)
|
|
172
|
+
- [Security](./security.md)
|
|
173
|
+
- [Client API](./client-api.md)
|
|
174
|
+
- [Error model](./error-model.md)
|