@0xmonaco/types 0.8.7 → 0.8.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.
Files changed (48) hide show
  1. package/dist/api/index.d.ts +13 -5
  2. package/dist/api/index.js +1 -1
  3. package/dist/applications/index.d.ts +47 -5
  4. package/dist/applications/index.js +2 -1
  5. package/dist/applications/requests.d.ts +78 -0
  6. package/dist/applications/requests.js +7 -0
  7. package/dist/applications/responses.d.ts +211 -1
  8. package/dist/applications/responses.js +3 -1
  9. package/dist/auth/index.d.ts +29 -31
  10. package/dist/auth/index.js +2 -2
  11. package/dist/auth/responses.d.ts +23 -20
  12. package/dist/delegated-agents/index.d.ts +17 -1
  13. package/dist/faucet/index.d.ts +54 -0
  14. package/dist/faucet/index.js +10 -0
  15. package/dist/index.d.ts +4 -0
  16. package/dist/index.js +4 -0
  17. package/dist/margin-accounts/index.d.ts +11 -14
  18. package/dist/market/index.d.ts +83 -0
  19. package/dist/positions/index.d.ts +1 -0
  20. package/dist/profile/index.d.ts +88 -1
  21. package/dist/sdk/index.d.ts +40 -2
  22. package/dist/sub-accounts/index.d.ts +145 -0
  23. package/dist/sub-accounts/index.js +9 -0
  24. package/dist/trading/index.d.ts +6 -6
  25. package/dist/trading/responses.d.ts +8 -27
  26. package/dist/validation/margin-accounts.d.ts +7 -9
  27. package/dist/validation/margin-accounts.js +7 -9
  28. package/dist/validation/profile.d.ts +7 -0
  29. package/dist/validation/profile.js +7 -0
  30. package/dist/validation/trading.d.ts +8 -33
  31. package/dist/validation/trading.js +42 -33
  32. package/dist/whitelist/index.d.ts +44 -0
  33. package/dist/whitelist/index.js +10 -0
  34. package/dist/wire/assert.d.ts +54 -0
  35. package/dist/wire/assert.js +0 -0
  36. package/dist/wire/audit.d.ts +47 -0
  37. package/dist/wire/audit.js +43 -0
  38. package/dist/wire/coverage.d.ts +1 -0
  39. package/dist/wire/coverage.js +0 -0
  40. package/dist/wire/index.d.ts +21 -0
  41. package/dist/wire/index.js +2 -0
  42. package/dist/wire/operations.d.ts +15 -0
  43. package/dist/wire/operations.js +93 -0
  44. package/dist/wire/schema.d.ts +8352 -0
  45. package/dist/wire/schema.js +4 -0
  46. package/dist/withdrawals/index.d.ts +43 -0
  47. package/dist/withdrawals/index.js +0 -0
  48. package/package.json +6 -2
@@ -2,17 +2,25 @@
2
2
  * Base API Types
3
3
  *
4
4
  * Common interface that all API implementations should inherit from.
5
- * Provides standardized methods for token management and common functionality.
5
+ * Provides standardized methods for session-key management and common functionality.
6
6
  */
7
+ import type { SessionCredentials } from "../auth/responses";
7
8
  /**
8
9
  * Base API interface that all API implementations should inherit from.
9
- * Provides common functionality for access token management.
10
+ * Provides common functionality for session-key management.
10
11
  */
11
12
  export interface BaseAPI {
12
13
  /**
13
- * Set the access token for authenticated requests.
14
+ * Set (or clear) the session keypair used to sign authenticated requests.
14
15
  *
15
- * @param token - JWT access token
16
+ * @param credentials - Hex-encoded session keypair, or `undefined` to clear.
16
17
  */
17
- setAccessToken(token: string): void;
18
+ setSessionKeypair(credentials: SessionCredentials | undefined): void;
19
+ /**
20
+ * Set (or clear) the application secret key used for backend-authenticated
21
+ * requests. When set, it is sent in the `x-server-key` header.
22
+ *
23
+ * @param serverKey - The application secret key (`sk_...`), or `undefined` to clear.
24
+ */
25
+ setServerKey(serverKey: string | undefined): void;
18
26
  }
package/dist/api/index.js CHANGED
@@ -2,5 +2,5 @@
2
2
  * Base API Types
3
3
  *
4
4
  * Common interface that all API implementations should inherit from.
5
- * Provides standardized methods for token management and common functionality.
5
+ * Provides standardized methods for session-key management and common functionality.
6
6
  */
@@ -1,23 +1,65 @@
1
1
  /**
2
2
  * Applications Types
3
3
  *
4
- * Types for application configuration operations.
4
+ * Types for application configuration and the backend-authenticated
5
+ * application reporting endpoints.
5
6
  */
6
7
  import type { BaseAPI } from "../api";
7
- import type { ApplicationConfigResponse } from "./responses";
8
+ import type { GetAppStatsParams, ListAppBalancesParams, ListAppMovementsParams, ListAppOrdersParams, ListAppUsersParams } from "./requests";
9
+ import type { ApplicationConfigResponse, GetAppStatsResponse, ListAppBalancesResponse, ListAppMovementsResponse, ListAppOrdersResponse, ListAppUsersResponse } from "./responses";
8
10
  /**
9
11
  * Applications API interface.
10
- * Provides methods for retrieving application configuration.
12
+ *
13
+ * `getApplicationConfig` is session-authenticated (signed with the session
14
+ * key). The reporting methods are backend-authenticated: set the application's
15
+ * secret key with {@link BaseAPI.setServerKey} before calling them — each
16
+ * request sends it in the `x-server-key` header.
11
17
  */
12
18
  export interface ApplicationsAPI extends BaseAPI {
13
19
  /**
14
20
  * Gets the configuration for the authenticated application.
15
21
  *
16
22
  * Returns the application's configuration including allowed origins,
17
- * webhook URL, and other settings. Requires valid authentication.
23
+ * webhook URL, and other settings. Requires valid session authentication.
18
24
  *
19
25
  * @returns Promise resolving to the application configuration
20
26
  */
21
27
  getApplicationConfig(): Promise<ApplicationConfigResponse>;
28
+ /**
29
+ * Lists orders placed by the application's users. Backend-authenticated.
30
+ *
31
+ * @param params - Pagination and filter options
32
+ * @returns Promise resolving to a paginated list of orders
33
+ */
34
+ listApplicationOrders(params?: ListAppOrdersParams): Promise<ListAppOrdersResponse>;
35
+ /**
36
+ * Lists the application's users. Backend-authenticated.
37
+ *
38
+ * @param params - Pagination and filter options
39
+ * @returns Promise resolving to a paginated list of users
40
+ */
41
+ listApplicationUsers(params?: ListAppUsersParams): Promise<ListAppUsersResponse>;
42
+ /**
43
+ * Lists ledger movements for the application's users. Backend-authenticated.
44
+ *
45
+ * @param params - Pagination and filter options
46
+ * @returns Promise resolving to a paginated list of movements
47
+ */
48
+ listApplicationMovements(params?: ListAppMovementsParams): Promise<ListAppMovementsResponse>;
49
+ /**
50
+ * Lists user balances held within the application. Backend-authenticated.
51
+ *
52
+ * @param params - Pagination and filter options
53
+ * @returns Promise resolving to a paginated list of balances
54
+ */
55
+ listApplicationBalances(params?: ListAppBalancesParams): Promise<ListAppBalancesResponse>;
56
+ /**
57
+ * Gets aggregate volume and fee stats for the application. Backend-authenticated.
58
+ *
59
+ * @param params - Optional `since` filter
60
+ * @returns Promise resolving to the application stats
61
+ */
62
+ getApplicationStats(params?: GetAppStatsParams): Promise<GetAppStatsResponse>;
22
63
  }
23
- export type { ApplicationConfigResponse } from "./responses";
64
+ export type { GetAppStatsParams, ListAppBalancesParams, ListAppMovementsParams, ListAppOrdersParams, ListAppUsersParams } from "./requests";
65
+ export type { AppBalance, ApplicationConfigResponse, AppMovement, AppOrder, AppUser, GetAppStatsResponse, ListAppBalancesResponse, ListAppMovementsResponse, ListAppOrdersResponse, ListAppUsersResponse, } from "./responses";
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * Applications Types
3
3
  *
4
- * Types for application configuration operations.
4
+ * Types for application configuration and the backend-authenticated
5
+ * application reporting endpoints.
5
6
  */
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Applications Request Types
3
+ *
4
+ * Query parameters for the backend-authenticated application reporting
5
+ * endpoints. Field names match the wire (snake_case) so they can be passed
6
+ * straight through to the query string.
7
+ */
8
+ /**
9
+ * Query parameters for listing application orders.
10
+ */
11
+ export interface ListAppOrdersParams {
12
+ /** Page number (starts from 1) */
13
+ page?: number;
14
+ /** Items per page (max 100) */
15
+ page_size?: number;
16
+ /** Filter by order status (e.g. SUBMITTED, PARTIALLY_FILLED, FILLED, SETTLED, CANCELLED, EXPIRED, REJECTED) */
17
+ status?: string;
18
+ /** Filter by user UUID */
19
+ user_id?: string;
20
+ /** Filter by trading pair UUID */
21
+ trading_pair_id?: string;
22
+ /** Filter by order side: BUY or SELL */
23
+ side?: string;
24
+ /** Filter by order type (e.g. LIMIT, MARKET, STOP_LOSS, TAKE_PROFIT, STOP_LIMIT, TRAILING_STOP) */
25
+ order_type?: string;
26
+ }
27
+ /**
28
+ * Query parameters for listing application users.
29
+ */
30
+ export interface ListAppUsersParams {
31
+ /** Page number (starts from 1) */
32
+ page?: number;
33
+ /** Items per page (max 100) */
34
+ page_size?: number;
35
+ /** Filter by active status */
36
+ is_active?: boolean;
37
+ /** Filter by account type: master or sub */
38
+ account_type?: string;
39
+ /** Filter by wallet address (partial match, case-insensitive) */
40
+ address?: string;
41
+ }
42
+ /**
43
+ * Query parameters for listing application movements.
44
+ */
45
+ export interface ListAppMovementsParams {
46
+ /** Page number (starts from 1) */
47
+ page?: number;
48
+ /** Items per page (max 100) */
49
+ page_size?: number;
50
+ /** Filter by user UUID */
51
+ user_id?: string;
52
+ /** Filter by transaction type (e.g. DEPOSIT, WITHDRAWAL, TRADE, FEE, FUNDING, LIQUIDATION, INTEREST, REWARD) */
53
+ transaction_type?: string;
54
+ /** Filter by entry type (e.g. CREDIT, DEBIT, LOCK, UNLOCK, FEE) */
55
+ entry_type?: string;
56
+ /** Filter by asset UUID */
57
+ asset_id?: string;
58
+ }
59
+ /**
60
+ * Query parameters for listing application balances.
61
+ */
62
+ export interface ListAppBalancesParams {
63
+ /** Page number (starts from 1) */
64
+ page?: number;
65
+ /** Items per page (max 100) */
66
+ page_size?: number;
67
+ /** Filter by user UUID */
68
+ user_id?: string;
69
+ /** Filter by asset UUID */
70
+ asset_id?: string;
71
+ }
72
+ /**
73
+ * Query parameters for application stats.
74
+ */
75
+ export interface GetAppStatsParams {
76
+ /** ISO 8601 datetime to filter stats from (e.g. 2026-01-01T00:00:00Z). Omit for all-time. */
77
+ since?: string;
78
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Applications Request Types
3
+ *
4
+ * Query parameters for the backend-authenticated application reporting
5
+ * endpoints. Field names match the wire (snake_case) so they can be passed
6
+ * straight through to the query string.
7
+ */
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * Applications Response Types
3
3
  *
4
- * Response types for application configuration operations.
4
+ * Response types for application configuration operations and the
5
+ * backend-authenticated application reporting endpoints. Reporting types use
6
+ * the wire shape (snake_case); optional fields are `null` rather than omitted.
5
7
  */
6
8
  /**
7
9
  * Response to an application configuration request.
@@ -20,3 +22,211 @@ export interface ApplicationConfigResponse {
20
22
  /** Application client ID, embedded in on-chain deposit calls */
21
23
  clientId: string;
22
24
  }
25
+ /**
26
+ * One order belonging to an application's users.
27
+ */
28
+ export interface AppOrder {
29
+ /** Order UUID */
30
+ id: string;
31
+ /** User UUID who placed the order */
32
+ user_id: string;
33
+ /** Trading pair UUID */
34
+ trading_pair_id: string;
35
+ /** Order type: LIMIT, MARKET, STOP_LOSS, TAKE_PROFIT, STOP_LIMIT, or TRAILING_STOP */
36
+ order_type: string;
37
+ /** Order side: BUY or SELL */
38
+ side: string;
39
+ /** Order price (null for market orders) */
40
+ price: string | null;
41
+ /** Order quantity (normalized for display) */
42
+ quantity: string;
43
+ /** Order quantity in raw format (for precision) */
44
+ quantity_raw: string;
45
+ /** Filled quantity (normalized for display) */
46
+ filled_quantity: string | null;
47
+ /** Filled quantity in raw format */
48
+ filled_quantity_raw: string | null;
49
+ /** Volume-weighted average fill price */
50
+ average_fill_price: string | null;
51
+ /** Order status */
52
+ status: string;
53
+ /** Trading mode: SPOT or MARGIN */
54
+ trading_mode: string;
55
+ /** Time in force: GTC, IOC, or FOK */
56
+ time_in_force: string | null;
57
+ /** Order creation timestamp (ISO 8601) */
58
+ created_at: string | null;
59
+ /** Order last update timestamp (ISO 8601) */
60
+ updated_at: string | null;
61
+ }
62
+ /**
63
+ * One user belonging to an application.
64
+ */
65
+ export interface AppUser {
66
+ /** User UUID */
67
+ id: string;
68
+ /** Wallet address */
69
+ address: string;
70
+ /** Display username */
71
+ username: string | null;
72
+ /** Account type: master or sub */
73
+ account_type: string;
74
+ /** Whether the user is allowed to withdraw */
75
+ can_withdraw: boolean;
76
+ /** Account creation timestamp (ISO 8601) */
77
+ created_at: string | null;
78
+ /** Email address */
79
+ email: string | null;
80
+ /** Whether the user account is active */
81
+ is_active: boolean | null;
82
+ /** Whether the user is banned */
83
+ is_banned: boolean | null;
84
+ /** Master account ID (for sub-accounts) */
85
+ master_account_id: string | null;
86
+ /** Last update timestamp (ISO 8601) */
87
+ updated_at: string | null;
88
+ }
89
+ /**
90
+ * One ledger movement (deposit, withdrawal, trade, etc.) for an application.
91
+ */
92
+ export interface AppMovement {
93
+ /** Transaction amount */
94
+ amount: string;
95
+ /** Balance after this transaction */
96
+ balance_after: string | null;
97
+ /** Balance before this transaction */
98
+ balance_before: string | null;
99
+ /** Balance UUID this movement affects */
100
+ balance_id: string;
101
+ /** Blockchain block number */
102
+ block_number: number | null;
103
+ /** Transaction timestamp (ISO 8601) */
104
+ created_at: string | null;
105
+ /** Human readable description */
106
+ description: string | null;
107
+ /** Type of ledger entry */
108
+ entry_type: string;
109
+ /** Movement UUID */
110
+ id: string;
111
+ /** Locked balance after transaction */
112
+ locked_after: string | null;
113
+ /** Locked balance before transaction */
114
+ locked_before: string | null;
115
+ /** Reference identifier for related operations */
116
+ reference_id: string | null;
117
+ /** Reference type */
118
+ reference_type: string | null;
119
+ /** Token address */
120
+ token: string;
121
+ /** Type of transaction */
122
+ transaction_type: string;
123
+ /** Blockchain transaction hash */
124
+ tx_hash: string | null;
125
+ /** User UUID who owns this movement */
126
+ user_id: string;
127
+ }
128
+ /**
129
+ * One user balance held within an application.
130
+ */
131
+ export interface AppBalance {
132
+ /** Available balance for trading */
133
+ available_balance: string;
134
+ /** Balance creation timestamp (ISO 8601) */
135
+ created_at: string | null;
136
+ /** Token decimals */
137
+ decimals: number;
138
+ /** Balance UUID */
139
+ id: string;
140
+ /** Last sync timestamp (ISO 8601) */
141
+ last_sync_at: string | null;
142
+ /** Last sync block number */
143
+ last_sync_block: number | null;
144
+ /** Locked balance */
145
+ locked_balance: string;
146
+ /** On-chain balance */
147
+ on_chain_balance: string;
148
+ /** Token symbol */
149
+ symbol: string | null;
150
+ /** Token address */
151
+ token: string;
152
+ /** Total balance */
153
+ total_balance: string;
154
+ /** Balance last update timestamp (ISO 8601) */
155
+ updated_at: string | null;
156
+ /** User UUID who owns this balance */
157
+ user_id: string;
158
+ }
159
+ /**
160
+ * Paginated list of application orders.
161
+ */
162
+ export interface ListAppOrdersResponse {
163
+ orders: AppOrder[];
164
+ /** Total matching orders */
165
+ total: number;
166
+ /** Current page number */
167
+ page: number;
168
+ /** Items per page */
169
+ page_size: number;
170
+ /** Total number of pages */
171
+ total_pages: number;
172
+ }
173
+ /**
174
+ * Paginated list of application users.
175
+ */
176
+ export interface ListAppUsersResponse {
177
+ users: AppUser[];
178
+ /** Total number of users */
179
+ total: number;
180
+ /** Current page number */
181
+ page: number;
182
+ /** Items per page */
183
+ page_size: number;
184
+ /** Total number of pages */
185
+ total_pages: number;
186
+ }
187
+ /**
188
+ * Paginated list of application movements.
189
+ */
190
+ export interface ListAppMovementsResponse {
191
+ movements: AppMovement[];
192
+ /** Total matching movements */
193
+ total: number;
194
+ /** Current page number */
195
+ page: number;
196
+ /** Items per page */
197
+ page_size: number;
198
+ /** Total number of pages */
199
+ total_pages: number;
200
+ }
201
+ /**
202
+ * Paginated list of application balances.
203
+ */
204
+ export interface ListAppBalancesResponse {
205
+ balances: AppBalance[];
206
+ /** Total matching balances */
207
+ total: number;
208
+ /** Current page number */
209
+ page: number;
210
+ /** Items per page */
211
+ page_size: number;
212
+ /** Total number of pages */
213
+ total_pages: number;
214
+ }
215
+ /**
216
+ * Aggregate volume and fee stats for an application.
217
+ *
218
+ * Stats are scoped to trades where the application's users were the taker.
219
+ * All monetary values are normalized (human-readable quote token units).
220
+ */
221
+ export interface GetAppStatsResponse {
222
+ /** Total quote volume for trades where this application's users were the taker */
223
+ volume: string;
224
+ /** Total maker fees collected */
225
+ maker_fee: string;
226
+ /** Total taker fees collected */
227
+ taker_fee: string;
228
+ /** Application revenue share from taker fees */
229
+ application_taker_fee: string;
230
+ /** Total number of trades */
231
+ trade_count: number;
232
+ }
@@ -1,5 +1,7 @@
1
1
  /**
2
2
  * Applications Response Types
3
3
  *
4
- * Response types for application configuration operations.
4
+ * Response types for application configuration operations and the
5
+ * backend-authenticated application reporting endpoints. Reporting types use
6
+ * the wire shape (snake_case); optional fields are `null` rather than omitted.
5
7
  */
@@ -1,27 +1,28 @@
1
1
  /**
2
2
  * Auth Types
3
3
  *
4
- * Types for authentication operations including challenge creation,
5
- * signature verification, and backend authentication.
4
+ * Types for wallet authentication operations including challenge creation,
5
+ * signature verification, and session lifecycle.
6
6
  */
7
7
  import type { BaseAPI } from "../api";
8
- import type { AuthState, BackendAuthResponse, ChallengeResponse, TokenRefreshResponse } from "./responses";
8
+ import type { AuthState, ChallengeResponse, SessionCredentials, SessionRefreshResponse } from "./responses";
9
9
  /**
10
10
  * Auth API interface.
11
- * Provides methods for frontend and backend authentication.
12
- * Handles challenge creation, signature verification, and backend auth.
11
+ * Provides methods for wallet-based authentication.
12
+ * Handles challenge creation, signature verification, and session lifecycle.
13
13
  */
14
14
  export interface AuthAPI extends BaseAPI {
15
15
  /**
16
16
  * Complete authentication flow for frontend applications.
17
17
  *
18
18
  * This method handles the entire authentication process:
19
- * 1. Creates a challenge
20
- * 2. Signs the challenge message
21
- * 3. Verifies the signature and returns JWT tokens
19
+ * 1. Generates a fresh ed25519 session keypair locally
20
+ * 2. Creates a challenge that commits to the session public key
21
+ * 3. Signs the challenge message with the wallet
22
+ * 4. Verifies the signature, registering the session public key
22
23
  *
23
24
  * @param clientId - Client ID of the application
24
- * @returns Promise resolving to the authentication state with JWT tokens
25
+ * @returns Promise resolving to the authentication state (including the session keypair)
25
26
  */
26
27
  authenticate(clientId: string): Promise<AuthState>;
27
28
  /**
@@ -36,41 +37,38 @@ export interface AuthAPI extends BaseAPI {
36
37
  signChallenge(message: string): Promise<string>;
37
38
  /**
38
39
  * Creates a challenge for frontend authentication.
39
- * Generates a unique nonce and message that the user must sign with their wallet.
40
+ * Generates a unique nonce and a message (embedding the session public key)
41
+ * that the user must sign with their wallet.
40
42
  * @param address - Wallet address of the user
41
43
  * @param clientId - Client ID of the application
44
+ * @param sessionPublicKey - Hex-encoded ed25519 session public key to bind
42
45
  * @returns Promise resolving to the challenge response
43
46
  */
44
- createChallenge(address: string, clientId: string): Promise<ChallengeResponse>;
47
+ createChallenge(address: string, clientId: string, sessionPublicKey: string): Promise<ChallengeResponse>;
45
48
  /**
46
49
  * Verifies a signature for frontend authentication.
47
- * Validates the signature against the challenge and returns JWT tokens.
50
+ * Validates the wallet signature against the challenge and registers the
51
+ * session public key, returning the new authentication state.
48
52
  * @param address - Wallet address of the user
49
- * @param signature - Signature of the challenge message
53
+ * @param signature - Wallet signature of the challenge message
50
54
  * @param nonce - Nonce from the challenge response
51
55
  * @param clientId - Client ID of the application
52
- * @returns Promise resolving to the authentication state with JWT tokens
56
+ * @param session - The locally-generated session keypair (hex-encoded)
57
+ * @returns Promise resolving to the authentication state
53
58
  */
54
- verifySignature(address: string, signature: string, nonce: string, clientId: string): Promise<AuthState>;
59
+ verifySignature(address: string, signature: string, nonce: string, clientId: string, session: SessionCredentials): Promise<AuthState>;
55
60
  /**
56
- * Authenticates a backend service using a secret key.
57
- * Returns JWT tokens for API access.
58
- * @param secretKey - Secret key of the application
59
- * @returns Promise resolving to the backend auth response with JWT tokens
61
+ * Extends the current session's expiry. The request is signed with the
62
+ * active session key (set via {@link setSessionKeypair}).
63
+ * @returns Promise resolving to the new expiry
60
64
  */
61
- authenticateBackend(secretKey: string): Promise<BackendAuthResponse>;
65
+ refreshSession(): Promise<SessionRefreshResponse>;
62
66
  /**
63
- * Refreshes an access token using a refresh token.
64
- * @param refreshToken - The refresh token to use
65
- * @returns Promise resolving to new access and refresh tokens
67
+ * Revokes the current session. The request is signed with the active session
68
+ * key, and the server deletes the matching session row.
69
+ * @returns Promise resolving when the session is revoked
66
70
  */
67
- refreshToken(refreshToken: string): Promise<TokenRefreshResponse>;
68
- /**
69
- * Revokes the current session's refresh token.
70
- * The server identifies the token to revoke from the access token in the Authorization header.
71
- * @returns Promise resolving when the token is revoked
72
- */
73
- revokeToken(): Promise<void>;
71
+ revokeSession(): Promise<void>;
74
72
  /**
75
73
  * Sets the wallet client for signing operations.
76
74
  * Used when the wallet becomes available after SDK initialization.
@@ -78,4 +76,4 @@ export interface AuthAPI extends BaseAPI {
78
76
  */
79
77
  setWalletClient(walletClient: unknown): void;
80
78
  }
81
- export type { ApplicationInfo, AuthState, BackendAuthResponse, ChallengeResponse, TokenRefreshResponse, User, } from "./responses";
79
+ export type { ApplicationInfo, AuthState, ChallengeResponse, SessionCredentials, SessionRefreshResponse, User, } from "./responses";
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auth Types
3
3
  *
4
- * Types for authentication operations including challenge creation,
5
- * signature verification, and backend authentication.
4
+ * Types for wallet authentication operations including challenge creation,
5
+ * signature verification, and session lifecycle.
6
6
  */
@@ -23,16 +23,22 @@ export interface User {
23
23
  username?: string;
24
24
  }
25
25
  /**
26
- * Authentication state containing all tokens and metadata
26
+ * Authentication state for the noncustodial session-key scheme.
27
27
  *
28
- * Returned by authentication methods and contains the tokens needed for API access.
28
+ * On login the SDK generates an ed25519 keypair locally and registers the
29
+ * public key with the server. Subsequent requests are signed with the private
30
+ * key — the server never holds a credential that can impersonate the user.
31
+ *
32
+ * The private key is the long-lived credential: persist it (e.g. localStorage,
33
+ * same risk profile as a JWT) to survive page reloads without re-prompting the
34
+ * wallet. When the session expires, call `refreshAuth()` or re-`login()`.
29
35
  */
30
36
  export interface AuthState {
31
- /** JWT access token for authenticated requests */
32
- accessToken: string;
33
- /** JWT refresh token for token renewal and revocation */
34
- refreshToken: string;
35
- /** Unix timestamp (in seconds) when the access token expires */
37
+ /** Hex-encoded (64 chars) ed25519 session public key registered with the server */
38
+ sessionPublicKey: string;
39
+ /** Hex-encoded (64 chars) ed25519 session private key used to sign requests */
40
+ sessionPrivateKey: string;
41
+ /** Unix timestamp (in seconds) when the session expires */
36
42
  expiresAt: number;
37
43
  /** Information about the authenticated user */
38
44
  user: User;
@@ -46,22 +52,19 @@ export interface ApplicationInfo {
46
52
  clientId: string;
47
53
  }
48
54
  /**
49
- * Response to a backend authentication request.
55
+ * A session keypair, hex-encoded. The private key is used to sign requests;
56
+ * the public key identifies the session server-side.
50
57
  */
51
- export interface BackendAuthResponse {
52
- /** JWT access token for authenticated requests */
53
- accessToken: string;
54
- /** Unix timestamp when the access token expires */
55
- expiresAt: number;
56
- /** Information about the application */
57
- application: ApplicationInfo;
58
+ export interface SessionCredentials {
59
+ /** Hex-encoded (64 chars) ed25519 public key */
60
+ publicKey: string;
61
+ /** Hex-encoded (64 chars) ed25519 private key */
62
+ privateKey: string;
58
63
  }
59
64
  /**
60
- * Response to a token refresh request.
65
+ * Response to a session refresh request — extends the session's expiry.
61
66
  */
62
- export interface TokenRefreshResponse {
63
- /** New JWT access token */
64
- accessToken: string;
65
- /** Unix timestamp when the access token expires */
67
+ export interface SessionRefreshResponse {
68
+ /** Unix timestamp when the session expires after refresh */
66
69
  expiresAt: number;
67
70
  }
@@ -33,11 +33,26 @@ export interface DelegatedAgent {
33
33
  export interface ListDelegatedAgentsResponse {
34
34
  agents: DelegatedAgent[];
35
35
  }
36
+ export interface DelegatedAgentOwner {
37
+ owner_user_id: string;
38
+ delegation_id: string;
39
+ name?: string;
40
+ is_active: boolean;
41
+ expires_at?: string;
42
+ }
43
+ export interface ListDelegatedOwnersResponse {
44
+ owners: DelegatedAgentOwner[];
45
+ }
36
46
  export interface CreateDelegatedSessionRequest {
37
47
  ownerUserId: string;
48
+ /**
49
+ * Lowercase-hex (64 chars) ed25519 public key the agent generated for this
50
+ * delegated session. Required: subsequent requests acting on the owner's
51
+ * behalf are signed with the matching private key.
52
+ */
53
+ sessionPublicKey: string;
38
54
  }
39
55
  export interface CreateDelegatedSessionResponse {
40
- access_token: string;
41
56
  expires_at: number;
42
57
  delegation_id: string;
43
58
  owner_user_id: string;
@@ -46,6 +61,7 @@ export interface CreateDelegatedSessionResponse {
46
61
  export interface DelegatedAgentsAPI extends BaseAPI {
47
62
  upsertDelegatedAgent(request: UpsertDelegatedAgentRequest): Promise<DelegatedAgent>;
48
63
  listDelegatedAgents(): Promise<ListDelegatedAgentsResponse>;
64
+ listDelegatedOwners(): Promise<ListDelegatedOwnersResponse>;
49
65
  revokeDelegatedAgent(delegatedAgentId: string): Promise<{
50
66
  status: "REVOKED";
51
67
  }>;