@0xmonaco/types 0.8.5 → 0.8.7-develop.0e951a5
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/dist/api/index.d.ts +6 -5
- package/dist/api/index.js +1 -1
- package/dist/auth/index.d.ts +26 -22
- package/dist/auth/responses.d.ts +26 -12
- package/dist/market/index.d.ts +1 -0
- package/dist/profile/index.d.ts +6 -2
- package/dist/sdk/index.d.ts +19 -2
- package/dist/trading/responses.d.ts +1 -1
- package/package.json +2 -2
package/dist/api/index.d.ts
CHANGED
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
* Base API Types
|
|
3
3
|
*
|
|
4
4
|
* Common interface that all API implementations should inherit from.
|
|
5
|
-
* Provides standardized methods for
|
|
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
|
|
10
|
+
* Provides common functionality for session-key management.
|
|
10
11
|
*/
|
|
11
12
|
export interface BaseAPI {
|
|
12
13
|
/**
|
|
13
|
-
* Set the
|
|
14
|
+
* Set (or clear) the session keypair used to sign authenticated requests.
|
|
14
15
|
*
|
|
15
|
-
* @param
|
|
16
|
+
* @param credentials - Hex-encoded session keypair, or `undefined` to clear.
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
|
+
setSessionKeypair(credentials: SessionCredentials | undefined): void;
|
|
18
19
|
}
|
package/dist/api/index.js
CHANGED
package/dist/auth/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* signature verification, and backend authentication.
|
|
6
6
|
*/
|
|
7
7
|
import type { BaseAPI } from "../api";
|
|
8
|
-
import type { AuthState, BackendAuthResponse, ChallengeResponse,
|
|
8
|
+
import type { AuthState, BackendAuthResponse, ChallengeResponse, SessionCredentials, SessionRefreshResponse } from "./responses";
|
|
9
9
|
/**
|
|
10
10
|
* Auth API interface.
|
|
11
11
|
* Provides methods for frontend and backend authentication.
|
|
@@ -16,12 +16,13 @@ export interface AuthAPI extends BaseAPI {
|
|
|
16
16
|
* Complete authentication flow for frontend applications.
|
|
17
17
|
*
|
|
18
18
|
* This method handles the entire authentication process:
|
|
19
|
-
* 1.
|
|
20
|
-
* 2.
|
|
21
|
-
* 3.
|
|
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
|
|
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,44 @@ 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
|
|
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
|
|
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 -
|
|
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
|
-
* @
|
|
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
61
|
* Authenticates a backend service using a secret key.
|
|
57
|
-
* Returns JWT tokens for API access.
|
|
58
62
|
* @param secretKey - Secret key of the application
|
|
59
|
-
* @returns Promise resolving to the backend auth response
|
|
63
|
+
* @returns Promise resolving to the backend auth response
|
|
60
64
|
*/
|
|
61
65
|
authenticateBackend(secretKey: string): Promise<BackendAuthResponse>;
|
|
62
66
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* @returns Promise resolving to new
|
|
67
|
+
* Extends the current session's expiry. The request is signed with the
|
|
68
|
+
* active session key (set via {@link setSessionKeypair}).
|
|
69
|
+
* @returns Promise resolving to the new expiry
|
|
66
70
|
*/
|
|
67
|
-
|
|
71
|
+
refreshSession(): Promise<SessionRefreshResponse>;
|
|
68
72
|
/**
|
|
69
|
-
* Revokes the current session
|
|
70
|
-
*
|
|
71
|
-
* @returns Promise resolving when the
|
|
73
|
+
* Revokes the current session. The request is signed with the active session
|
|
74
|
+
* key, and the server deletes the matching session row.
|
|
75
|
+
* @returns Promise resolving when the session is revoked
|
|
72
76
|
*/
|
|
73
|
-
|
|
77
|
+
revokeSession(): Promise<void>;
|
|
74
78
|
/**
|
|
75
79
|
* Sets the wallet client for signing operations.
|
|
76
80
|
* Used when the wallet becomes available after SDK initialization.
|
|
@@ -78,4 +82,4 @@ export interface AuthAPI extends BaseAPI {
|
|
|
78
82
|
*/
|
|
79
83
|
setWalletClient(walletClient: unknown): void;
|
|
80
84
|
}
|
|
81
|
-
export type { ApplicationInfo, AuthState, BackendAuthResponse, ChallengeResponse,
|
|
85
|
+
export type { ApplicationInfo, AuthState, BackendAuthResponse, ChallengeResponse, SessionCredentials, SessionRefreshResponse, User, } from "./responses";
|
package/dist/auth/responses.d.ts
CHANGED
|
@@ -23,16 +23,22 @@ export interface User {
|
|
|
23
23
|
username?: string;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Authentication state
|
|
26
|
+
* Authentication state for the noncustodial session-key scheme.
|
|
27
27
|
*
|
|
28
|
-
*
|
|
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
|
-
/**
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
/** Unix timestamp (in seconds) when the
|
|
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;
|
|
@@ -57,11 +63,19 @@ export interface BackendAuthResponse {
|
|
|
57
63
|
application: ApplicationInfo;
|
|
58
64
|
}
|
|
59
65
|
/**
|
|
60
|
-
*
|
|
66
|
+
* A session keypair, hex-encoded. The private key is used to sign requests;
|
|
67
|
+
* the public key identifies the session server-side.
|
|
61
68
|
*/
|
|
62
|
-
export interface
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
/**
|
|
69
|
+
export interface SessionCredentials {
|
|
70
|
+
/** Hex-encoded (64 chars) ed25519 public key */
|
|
71
|
+
publicKey: string;
|
|
72
|
+
/** Hex-encoded (64 chars) ed25519 private key */
|
|
73
|
+
privateKey: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Response to a session refresh request — extends the session's expiry.
|
|
77
|
+
*/
|
|
78
|
+
export interface SessionRefreshResponse {
|
|
79
|
+
/** Unix timestamp when the session expires after refresh */
|
|
66
80
|
expiresAt: number;
|
|
67
81
|
}
|
package/dist/market/index.d.ts
CHANGED
package/dist/profile/index.d.ts
CHANGED
|
@@ -116,7 +116,7 @@ export interface GetUserBalancesParams {
|
|
|
116
116
|
*/
|
|
117
117
|
export interface GetPaginatedUserMovementsResponse {
|
|
118
118
|
/**
|
|
119
|
-
* Latest movements from
|
|
119
|
+
* Latest movements from the live engine cache (real-time, instant updates).
|
|
120
120
|
* These are the most recent movements that may not yet be in PostgreSQL.
|
|
121
121
|
* Only populated on page 1; empty for subsequent pages.
|
|
122
122
|
*/
|
|
@@ -190,12 +190,16 @@ export interface AccountBalance {
|
|
|
190
190
|
available_balance: string;
|
|
191
191
|
/** Locked balance (in orders or pending operations, normalized) */
|
|
192
192
|
locked_balance: string;
|
|
193
|
-
/**
|
|
193
|
+
/** Collateral posted into margin (perps) accounts (normalized) */
|
|
194
|
+
margin_locked: string;
|
|
195
|
+
/** Total balance (available + locked + margin_locked, normalized) */
|
|
194
196
|
total_balance: string;
|
|
195
197
|
/** Available balance in raw format (wei) */
|
|
196
198
|
available_balance_raw: string;
|
|
197
199
|
/** Locked balance in raw format (wei) */
|
|
198
200
|
locked_balance_raw: string;
|
|
201
|
+
/** Margin-locked balance in raw format (wei) */
|
|
202
|
+
margin_locked_raw: string;
|
|
199
203
|
}
|
|
200
204
|
/**
|
|
201
205
|
* A single user trade execution.
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PublicClient, TransactionReceipt, WalletClient } from "viem";
|
|
2
2
|
import type { ApplicationsAPI } from "../applications";
|
|
3
|
-
import type { AuthAPI, AuthState } from "../auth/index";
|
|
3
|
+
import type { AuthAPI, AuthState, SessionCredentials } from "../auth/index";
|
|
4
4
|
import type { DelegatedAgentsAPI } from "../delegated-agents";
|
|
5
5
|
import type { FeesAPI } from "../fees";
|
|
6
6
|
import type { MarginAccountsAPI } from "../margin-accounts";
|
|
@@ -29,10 +29,27 @@ export interface SDKConfig {
|
|
|
29
29
|
* - "mainnet": https://api.monaco.xyz
|
|
30
30
|
*
|
|
31
31
|
* Only "mainnet" uses the Sei mainnet chain. All other networks use Sei testnet.
|
|
32
|
+
* `network` always selects the chain; supply {@link apiUrl} / {@link wsUrl}
|
|
33
|
+
* to point the SDK at a gateway that the preset URL doesn't cover.
|
|
32
34
|
*/
|
|
33
35
|
network: Network;
|
|
34
36
|
/** RPC URL for Sei blockchain interactions */
|
|
35
37
|
seiRpcUrl: string;
|
|
38
|
+
/**
|
|
39
|
+
* Override the API gateway base URL. When set, the SDK sends all HTTP
|
|
40
|
+
* requests here instead of the {@link network} preset's default URL. Use for
|
|
41
|
+
* self-hosted gateways or e2e/dev stacks reachable only by a custom host
|
|
42
|
+
* (e.g. Docker DNS `http://api-gateway:8080`). `network` still selects the
|
|
43
|
+
* chain. Must be a valid absolute URL.
|
|
44
|
+
*/
|
|
45
|
+
apiUrl?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Override the WebSocket base URL. When set, the SDK connects here instead of
|
|
48
|
+
* the {@link network} preset's default WS URL. Pair with {@link apiUrl} when
|
|
49
|
+
* the WS service is reachable at a different host than the API gateway
|
|
50
|
+
* (e.g. Docker DNS `ws://ws-api:8080/ws`). Must be a valid absolute URL.
|
|
51
|
+
*/
|
|
52
|
+
wsUrl?: string;
|
|
36
53
|
}
|
|
37
54
|
/**
|
|
38
55
|
* Core SDK interface providing access to all Monaco functionality.
|
|
@@ -86,7 +103,7 @@ export interface MonacoSDK {
|
|
|
86
103
|
disconnect: () => void;
|
|
87
104
|
isConnected: () => boolean;
|
|
88
105
|
getStatus: () => "connected" | "connecting" | "disconnected" | "reconnecting";
|
|
89
|
-
|
|
106
|
+
setSessionKeypair: (credentials: SessionCredentials | undefined) => void;
|
|
90
107
|
orders: (tradingPairId: string, tradingMode: TradingMode, handler: (event: OrderEvent) => void) => () => void;
|
|
91
108
|
orderbook: (tradingPairId: string, tradingMode: TradingMode, magnitude: number, quotationMode: OrderbookQuotationMode, handler: (event: OrderbookEvent) => void) => () => void;
|
|
92
109
|
ohlcv: (tradingPairId: string, tradingMode: TradingMode, interval: Interval, handler: (event: OHLCVEvent) => void) => () => void;
|
|
@@ -141,7 +141,7 @@ export interface GetPaginatedOrdersParams {
|
|
|
141
141
|
* Response from getting paginated orders
|
|
142
142
|
*/
|
|
143
143
|
export interface GetPaginatedOrdersResponse {
|
|
144
|
-
/** Latest orders from
|
|
144
|
+
/** Latest orders from the live engine cache (real-time, instant updates).
|
|
145
145
|
* These are the most recently created/updated orders that may not yet be in PostgreSQL.
|
|
146
146
|
* Only populated on page 1.
|
|
147
147
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xmonaco/types",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.7-develop.0e951a5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"lint": "biome lint ."
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@0xmonaco/contracts": "0.8.
|
|
23
|
+
"@0xmonaco/contracts": "0.8.7-develop.0e951a5",
|
|
24
24
|
"zod": "^4.1.12"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|