@lightconexyz/lightcone-sdk 0.1.0 → 0.2.1
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 +33 -206
- package/dist/auth/client.d.ts +25 -0
- package/dist/auth/client.d.ts.map +1 -0
- package/dist/auth/client.js +120 -0
- package/dist/auth/client.js.map +1 -0
- package/dist/auth/index.d.ts +73 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +42 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/native.d.ts +8 -0
- package/dist/auth/native.d.ts.map +1 -0
- package/dist/auth/native.js +19 -0
- package/dist/auth/native.js.map +1 -0
- package/dist/auth.d.ts +1 -79
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +15 -145
- package/dist/auth.js.map +1 -1
- package/dist/client.d.ts +69 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +158 -0
- package/dist/client.js.map +1 -0
- package/dist/domain/admin/client.d.ts +17 -0
- package/dist/domain/admin/client.d.ts.map +1 -0
- package/dist/domain/admin/client.js +32 -0
- package/dist/domain/admin/client.js.map +1 -0
- package/dist/domain/admin/index.d.ts +7 -0
- package/dist/domain/admin/index.d.ts.map +1 -0
- package/dist/domain/admin/index.js +19 -0
- package/dist/domain/admin/index.js.map +1 -0
- package/dist/domain/admin/wire.d.ts +117 -0
- package/dist/domain/admin/wire.d.ts.map +1 -0
- package/dist/domain/admin/wire.js +3 -0
- package/dist/domain/admin/wire.js.map +1 -0
- package/dist/domain/index.d.ts +9 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/domain/index.js +45 -0
- package/dist/domain/index.js.map +1 -0
- package/dist/domain/market/client.d.ts +21 -0
- package/dist/domain/market/client.d.ts.map +1 -0
- package/dist/domain/market/client.js +70 -0
- package/dist/domain/market/client.js.map +1 -0
- package/dist/domain/market/convert.d.ts +8 -0
- package/dist/domain/market/convert.d.ts.map +1 -0
- package/dist/domain/market/convert.js +96 -0
- package/dist/domain/market/convert.js.map +1 -0
- package/dist/domain/market/index.d.ts +47 -0
- package/dist/domain/market/index.d.ts.map +1 -0
- package/dist/domain/market/index.js +58 -0
- package/dist/domain/market/index.js.map +1 -0
- package/dist/domain/market/outcome.d.ts +12 -0
- package/dist/domain/market/outcome.d.ts.map +1 -0
- package/dist/domain/market/outcome.js +28 -0
- package/dist/domain/market/outcome.js.map +1 -0
- package/dist/domain/market/tokens.d.ts +42 -0
- package/dist/domain/market/tokens.d.ts.map +1 -0
- package/dist/domain/market/tokens.js +106 -0
- package/dist/domain/market/tokens.js.map +1 -0
- package/dist/domain/market/wire.d.ts +116 -0
- package/dist/domain/market/wire.d.ts.map +1 -0
- package/dist/domain/market/wire.js +3 -0
- package/dist/domain/market/wire.js.map +1 -0
- package/dist/domain/order/client.d.ts +187 -0
- package/dist/domain/order/client.d.ts.map +1 -0
- package/dist/domain/order/client.js +122 -0
- package/dist/domain/order/client.js.map +1 -0
- package/dist/domain/order/convert.d.ts +8 -0
- package/dist/domain/order/convert.d.ts.map +1 -0
- package/dist/domain/order/convert.js +80 -0
- package/dist/domain/order/convert.js.map +1 -0
- package/dist/domain/order/index.d.ts +48 -0
- package/dist/domain/order/index.d.ts.map +1 -0
- package/dist/domain/order/index.js +41 -0
- package/dist/domain/order/index.js.map +1 -0
- package/dist/domain/order/state.d.ts +26 -0
- package/dist/domain/order/state.d.ts.map +1 -0
- package/dist/domain/order/state.js +85 -0
- package/dist/domain/order/state.js.map +1 -0
- package/dist/domain/order/wire.d.ts +123 -0
- package/dist/domain/order/wire.d.ts.map +1 -0
- package/dist/domain/order/wire.js +3 -0
- package/dist/domain/order/wire.js.map +1 -0
- package/dist/domain/orderbook/client.d.ts +20 -0
- package/dist/domain/orderbook/client.d.ts.map +1 -0
- package/dist/domain/orderbook/client.js +30 -0
- package/dist/domain/orderbook/client.js.map +1 -0
- package/dist/domain/orderbook/convert.d.ts +5 -0
- package/dist/domain/orderbook/convert.d.ts.map +1 -0
- package/dist/domain/orderbook/convert.js +34 -0
- package/dist/domain/orderbook/convert.js.map +1 -0
- package/dist/domain/orderbook/index.d.ts +36 -0
- package/dist/domain/orderbook/index.d.ts.map +1 -0
- package/dist/domain/orderbook/index.js +63 -0
- package/dist/domain/orderbook/index.js.map +1 -0
- package/dist/domain/orderbook/state.d.ts +19 -0
- package/dist/domain/orderbook/state.d.ts.map +1 -0
- package/dist/domain/orderbook/state.js +86 -0
- package/dist/domain/orderbook/state.js.map +1 -0
- package/dist/domain/orderbook/ticker.d.ts +8 -0
- package/dist/domain/orderbook/ticker.d.ts.map +1 -0
- package/dist/domain/orderbook/ticker.js +3 -0
- package/dist/domain/orderbook/ticker.js.map +1 -0
- package/dist/domain/orderbook/wire.d.ts +63 -0
- package/dist/domain/orderbook/wire.d.ts.map +1 -0
- package/dist/domain/orderbook/wire.js +3 -0
- package/dist/domain/orderbook/wire.js.map +1 -0
- package/dist/domain/position/client.d.ts +13 -0
- package/dist/domain/position/client.d.ts.map +1 -0
- package/dist/domain/position/client.js +20 -0
- package/dist/domain/position/client.js.map +1 -0
- package/dist/domain/position/index.d.ts +66 -0
- package/dist/domain/position/index.d.ts.map +1 -0
- package/dist/domain/position/index.js +19 -0
- package/dist/domain/position/index.js.map +1 -0
- package/dist/domain/position/wire.d.ts +29 -0
- package/dist/domain/position/wire.d.ts.map +1 -0
- package/dist/domain/position/wire.js +3 -0
- package/dist/domain/position/wire.js.map +1 -0
- package/dist/domain/price_history/client.d.ts +12 -0
- package/dist/domain/price_history/client.d.ts.map +1 -0
- package/dist/domain/price_history/client.js +24 -0
- package/dist/domain/price_history/client.js.map +1 -0
- package/dist/domain/price_history/index.d.ts +14 -0
- package/dist/domain/price_history/index.d.ts.map +1 -0
- package/dist/domain/price_history/index.js +27 -0
- package/dist/domain/price_history/index.js.map +1 -0
- package/dist/domain/price_history/state.d.ts +11 -0
- package/dist/domain/price_history/state.d.ts.map +1 -0
- package/dist/domain/price_history/state.js +35 -0
- package/dist/domain/price_history/state.js.map +1 -0
- package/dist/domain/price_history/wire.d.ts +45 -0
- package/dist/domain/price_history/wire.d.ts.map +1 -0
- package/dist/domain/price_history/wire.js +3 -0
- package/dist/domain/price_history/wire.js.map +1 -0
- package/dist/domain/referral/client.d.ts +13 -0
- package/dist/domain/referral/client.d.ts.map +1 -0
- package/dist/domain/referral/client.js +34 -0
- package/dist/domain/referral/client.js.map +1 -0
- package/dist/domain/referral/index.d.ts +17 -0
- package/dist/domain/referral/index.d.ts.map +1 -0
- package/dist/domain/referral/index.js +19 -0
- package/dist/domain/referral/index.js.map +1 -0
- package/dist/domain/referral/wire.d.ts +22 -0
- package/dist/domain/referral/wire.d.ts.map +1 -0
- package/dist/domain/referral/wire.js +3 -0
- package/dist/domain/referral/wire.js.map +1 -0
- package/dist/domain/trade/client.d.ts +12 -0
- package/dist/domain/trade/client.d.ts.map +1 -0
- package/dist/domain/trade/client.js +27 -0
- package/dist/domain/trade/client.js.map +1 -0
- package/dist/domain/trade/convert.d.ts +5 -0
- package/dist/domain/trade/convert.d.ts.map +1 -0
- package/dist/domain/trade/convert.js +25 -0
- package/dist/domain/trade/convert.js.map +1 -0
- package/dist/domain/trade/index.d.ts +19 -0
- package/dist/domain/trade/index.d.ts.map +1 -0
- package/dist/domain/trade/index.js +24 -0
- package/dist/domain/trade/index.js.map +1 -0
- package/dist/domain/trade/state.d.ts +16 -0
- package/dist/domain/trade/state.d.ts.map +1 -0
- package/dist/domain/trade/state.js +40 -0
- package/dist/domain/trade/state.js.map +1 -0
- package/dist/domain/trade/wire.d.ts +34 -0
- package/dist/domain/trade/wire.d.ts.map +1 -0
- package/dist/domain/trade/wire.js +3 -0
- package/dist/domain/trade/wire.js.map +1 -0
- package/dist/error.d.ts +44 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +126 -0
- package/dist/error.js.map +1 -0
- package/dist/http/client.d.ts +16 -0
- package/dist/http/client.d.ts.map +1 -0
- package/dist/http/client.js +146 -0
- package/dist/http/client.js.map +1 -0
- package/dist/http/index.d.ts +3 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +12 -0
- package/dist/http/index.js.map +1 -0
- package/dist/http/retry.d.ts +30 -0
- package/dist/http/retry.d.ts.map +1 -0
- package/dist/http/retry.js +48 -0
- package/dist/http/retry.js.map +1 -0
- package/dist/index.d.ts +13 -51
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -68
- package/dist/index.js.map +1 -1
- package/dist/network.d.ts +4 -4
- package/dist/network.d.ts.map +1 -1
- package/dist/network.js +4 -4
- package/dist/network.js.map +1 -1
- package/dist/prelude.d.ts +41 -0
- package/dist/prelude.d.ts.map +1 -0
- package/dist/prelude.js +55 -0
- package/dist/prelude.js.map +1 -0
- package/dist/privy/client.d.ts +17 -0
- package/dist/privy/client.d.ts.map +1 -0
- package/dist/privy/client.js +66 -0
- package/dist/privy/client.js.map +1 -0
- package/dist/privy/index.d.ts +57 -0
- package/dist/privy/index.d.ts.map +1 -0
- package/dist/privy/index.js +80 -0
- package/dist/privy/index.js.map +1 -0
- package/dist/program/accounts.d.ts +16 -1
- package/dist/program/accounts.d.ts.map +1 -1
- package/dist/program/accounts.js +41 -0
- package/dist/program/accounts.js.map +1 -1
- package/dist/program/builder.d.ts +15 -11
- package/dist/program/builder.d.ts.map +1 -1
- package/dist/program/builder.js +30 -22
- package/dist/program/builder.js.map +1 -1
- package/dist/program/client.d.ts +37 -1
- package/dist/program/client.d.ts.map +1 -1
- package/dist/program/client.js +82 -2
- package/dist/program/client.js.map +1 -1
- package/dist/program/constants.d.ts +9 -1
- package/dist/program/constants.d.ts.map +1 -1
- package/dist/program/constants.js +9 -1
- package/dist/program/constants.js.map +1 -1
- package/dist/program/envelope.d.ts +94 -0
- package/dist/program/envelope.d.ts.map +1 -0
- package/dist/program/envelope.js +258 -0
- package/dist/program/envelope.js.map +1 -0
- package/dist/program/error.d.ts +8 -0
- package/dist/program/error.d.ts.map +1 -0
- package/dist/program/error.js +20 -0
- package/dist/program/error.js.map +1 -0
- package/dist/program/index.d.ts +8 -5
- package/dist/program/index.d.ts.map +1 -1
- package/dist/program/index.js +28 -3
- package/dist/program/index.js.map +1 -1
- package/dist/program/instructions.d.ts +78 -1
- package/dist/program/instructions.d.ts.map +1 -1
- package/dist/program/instructions.js +277 -3
- package/dist/program/instructions.js.map +1 -1
- package/dist/program/orders.d.ts +26 -8
- package/dist/program/orders.d.ts.map +1 -1
- package/dist/program/orders.js +58 -31
- package/dist/program/orders.js.map +1 -1
- package/dist/program/pda.d.ts +19 -0
- package/dist/program/pda.d.ts.map +1 -1
- package/dist/program/pda.js +28 -0
- package/dist/program/pda.js.map +1 -1
- package/dist/program/types.d.ts +72 -9
- package/dist/program/types.d.ts.map +1 -1
- package/dist/program/types.js.map +1 -1
- package/dist/shared/fmt/decimal.d.ts +5 -0
- package/dist/shared/fmt/decimal.d.ts.map +1 -0
- package/dist/shared/fmt/decimal.js +54 -0
- package/dist/shared/fmt/decimal.js.map +1 -0
- package/dist/shared/fmt/index.d.ts +3 -0
- package/dist/shared/fmt/index.d.ts.map +1 -0
- package/dist/shared/fmt/index.js +39 -0
- package/dist/shared/fmt/index.js.map +1 -0
- package/dist/shared/fmt/num.d.ts +6 -0
- package/dist/shared/fmt/num.d.ts.map +1 -0
- package/dist/shared/fmt/num.js +44 -0
- package/dist/shared/fmt/num.js.map +1 -0
- package/dist/shared/index.d.ts +4 -7
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +19 -7
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/price.d.ts +5 -33
- package/dist/shared/price.d.ts.map +1 -1
- package/dist/shared/price.js +11 -39
- package/dist/shared/price.js.map +1 -1
- package/dist/shared/scaling.d.ts +17 -30
- package/dist/shared/scaling.d.ts.map +1 -1
- package/dist/shared/scaling.js +88 -57
- package/dist/shared/scaling.js.map +1 -1
- package/dist/shared/types.d.ts +66 -16
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/shared/types.js +81 -17
- package/dist/shared/types.js.map +1 -1
- package/dist/ws/client.browser.d.ts +46 -0
- package/dist/ws/client.browser.d.ts.map +1 -0
- package/dist/ws/client.browser.js +245 -0
- package/dist/ws/client.browser.js.map +1 -0
- package/dist/ws/client.node.d.ts +36 -0
- package/dist/ws/client.node.d.ts.map +1 -0
- package/dist/ws/client.node.js +226 -0
- package/dist/ws/client.node.js.map +1 -0
- package/dist/ws/index.d.ts +110 -0
- package/dist/ws/index.d.ts.map +1 -0
- package/dist/ws/index.js +181 -0
- package/dist/ws/index.js.map +1 -0
- package/dist/ws/subscriptions.d.ts +51 -0
- package/dist/ws/subscriptions.d.ts.map +1 -0
- package/dist/ws/subscriptions.js +44 -0
- package/dist/ws/subscriptions.js.map +1 -0
- package/dist/ws/types.d.ts +23 -0
- package/dist/ws/types.d.ts.map +1 -0
- package/dist/ws/types.js +3 -0
- package/dist/ws/types.js.map +1 -0
- package/package.json +10 -13
- package/dist/api/client.d.ts +0 -225
- package/dist/api/client.d.ts.map +0 -1
- package/dist/api/client.js +0 -452
- package/dist/api/client.js.map +0 -1
- package/dist/api/error.d.ts +0 -58
- package/dist/api/error.d.ts.map +0 -1
- package/dist/api/error.js +0 -98
- package/dist/api/error.js.map +0 -1
- package/dist/api/index.d.ts +0 -23
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/index.js +0 -51
- package/dist/api/index.js.map +0 -1
- package/dist/api/types/admin.d.ts +0 -49
- package/dist/api/types/admin.d.ts.map +0 -1
- package/dist/api/types/admin.js +0 -13
- package/dist/api/types/admin.js.map +0 -1
- package/dist/api/types/index.d.ts +0 -14
- package/dist/api/types/index.d.ts.map +0 -1
- package/dist/api/types/index.js +0 -13
- package/dist/api/types/index.js.map +0 -1
- package/dist/api/types/market.d.ts +0 -186
- package/dist/api/types/market.d.ts.map +0 -1
- package/dist/api/types/market.js +0 -6
- package/dist/api/types/market.js.map +0 -1
- package/dist/api/types/order.d.ts +0 -190
- package/dist/api/types/order.d.ts.map +0 -1
- package/dist/api/types/order.js +0 -6
- package/dist/api/types/order.js.map +0 -1
- package/dist/api/types/orderbook.d.ts +0 -36
- package/dist/api/types/orderbook.d.ts.map +0 -1
- package/dist/api/types/orderbook.js +0 -6
- package/dist/api/types/orderbook.js.map +0 -1
- package/dist/api/types/position.d.ts +0 -60
- package/dist/api/types/position.d.ts.map +0 -1
- package/dist/api/types/position.js +0 -6
- package/dist/api/types/position.js.map +0 -1
- package/dist/api/types/price_history.d.ts +0 -68
- package/dist/api/types/price_history.d.ts.map +0 -1
- package/dist/api/types/price_history.js +0 -13
- package/dist/api/types/price_history.js.map +0 -1
- package/dist/api/types/trade.d.ts +0 -67
- package/dist/api/types/trade.d.ts.map +0 -1
- package/dist/api/types/trade.js +0 -13
- package/dist/api/types/trade.js.map +0 -1
- package/dist/api/validation.d.ts +0 -24
- package/dist/api/validation.d.ts.map +0 -1
- package/dist/api/validation.js +0 -53
- package/dist/api/validation.js.map +0 -1
- package/dist/websocket/client.d.ts +0 -238
- package/dist/websocket/client.d.ts.map +0 -1
- package/dist/websocket/client.js +0 -580
- package/dist/websocket/client.js.map +0 -1
- package/dist/websocket/error.d.ts +0 -47
- package/dist/websocket/error.d.ts.map +0 -1
- package/dist/websocket/error.js +0 -83
- package/dist/websocket/error.js.map +0 -1
- package/dist/websocket/handlers.d.ts +0 -97
- package/dist/websocket/handlers.d.ts.map +0 -1
- package/dist/websocket/handlers.js +0 -277
- package/dist/websocket/handlers.js.map +0 -1
- package/dist/websocket/index.d.ts +0 -38
- package/dist/websocket/index.d.ts.map +0 -1
- package/dist/websocket/index.js +0 -75
- package/dist/websocket/index.js.map +0 -1
- package/dist/websocket/state/index.d.ts +0 -7
- package/dist/websocket/state/index.d.ts.map +0 -1
- package/dist/websocket/state/index.js +0 -14
- package/dist/websocket/state/index.js.map +0 -1
- package/dist/websocket/state/orderbook.d.ts +0 -107
- package/dist/websocket/state/orderbook.d.ts.map +0 -1
- package/dist/websocket/state/orderbook.js +0 -293
- package/dist/websocket/state/orderbook.js.map +0 -1
- package/dist/websocket/state/price.d.ts +0 -108
- package/dist/websocket/state/price.d.ts.map +0 -1
- package/dist/websocket/state/price.js +0 -243
- package/dist/websocket/state/price.js.map +0 -1
- package/dist/websocket/state/user.d.ts +0 -83
- package/dist/websocket/state/user.d.ts.map +0 -1
- package/dist/websocket/state/user.js +0 -228
- package/dist/websocket/state/user.js.map +0 -1
- package/dist/websocket/subscriptions.d.ts +0 -143
- package/dist/websocket/subscriptions.d.ts.map +0 -1
- package/dist/websocket/subscriptions.js +0 -244
- package/dist/websocket/subscriptions.js.map +0 -1
- package/dist/websocket/types.d.ts +0 -417
- package/dist/websocket/types.d.ts.map +0 -1
- package/dist/websocket/types.js +0 -195
- package/dist/websocket/types.js.map +0 -1
package/dist/auth.d.ts
CHANGED
|
@@ -1,80 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Authentication module for Lightcone.
|
|
3
|
-
*
|
|
4
|
-
* Provides functionality for authenticating with the Lightcone API.
|
|
5
|
-
* Used by both the REST API client and WebSocket client.
|
|
6
|
-
*
|
|
7
|
-
* # Authentication Flow
|
|
8
|
-
*
|
|
9
|
-
* 1. Generate a sign-in message with timestamp
|
|
10
|
-
* 2. Sign the message with an Ed25519 keypair
|
|
11
|
-
* 3. POST to the authentication endpoint
|
|
12
|
-
* 4. Extract token from JSON response
|
|
13
|
-
*/
|
|
14
|
-
import { Keypair } from "@solana/web3.js";
|
|
15
|
-
/**
|
|
16
|
-
* Auth error variants (mirrors Rust's AuthError enum).
|
|
17
|
-
*/
|
|
18
|
-
export type AuthErrorVariant = "SystemTime" | "HttpError" | "AuthenticationFailed";
|
|
19
|
-
/**
|
|
20
|
-
* Authentication error class.
|
|
21
|
-
*/
|
|
22
|
-
export declare class AuthError extends Error {
|
|
23
|
-
readonly variant: AuthErrorVariant;
|
|
24
|
-
constructor(variant: AuthErrorVariant, message: string);
|
|
25
|
-
static systemTime(message: string): AuthError;
|
|
26
|
-
static httpError(message: string): AuthError;
|
|
27
|
-
static authenticationFailed(message: string): AuthError;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Authentication credentials returned after successful login.
|
|
31
|
-
*/
|
|
32
|
-
export interface AuthCredentials {
|
|
33
|
-
/** The authentication token to use for WebSocket connection */
|
|
34
|
-
authToken: string;
|
|
35
|
-
/** The user's public key (Base58 encoded) */
|
|
36
|
-
userPubkey: string;
|
|
37
|
-
/** The user's ID */
|
|
38
|
-
userId: string;
|
|
39
|
-
/** Token expiration timestamp (Unix seconds) */
|
|
40
|
-
expiresAt: number;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Generate the sign-in message with current timestamp.
|
|
44
|
-
*
|
|
45
|
-
* @returns The message to be signed
|
|
46
|
-
*/
|
|
47
|
-
export declare function generateSigninMessage(): string;
|
|
48
|
-
/**
|
|
49
|
-
* Generate the sign-in message with a specific timestamp.
|
|
50
|
-
*
|
|
51
|
-
* @param timestampMs - Unix timestamp in milliseconds
|
|
52
|
-
* @returns The message to be signed
|
|
53
|
-
*/
|
|
54
|
-
export declare function generateSigninMessageWithTimestamp(timestampMs: number): string;
|
|
55
|
-
/**
|
|
56
|
-
* Authenticate with Lightcone and obtain credentials using a Solana Keypair.
|
|
57
|
-
*
|
|
58
|
-
* @param keypair - The Solana Keypair for authentication
|
|
59
|
-
* @returns AuthCredentials containing the auth token and user public key
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```typescript
|
|
63
|
-
* import { Keypair } from "@solana/web3.js";
|
|
64
|
-
* import { auth } from "@lightcone/sdk";
|
|
65
|
-
*
|
|
66
|
-
* const keypair = Keypair.generate();
|
|
67
|
-
* const credentials = await auth.authenticate(keypair);
|
|
68
|
-
* console.log("Auth token:", credentials.authToken);
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
export declare function authenticate(keypair: Keypair): Promise<AuthCredentials>;
|
|
72
|
-
/**
|
|
73
|
-
* Sign a message with a Solana Keypair.
|
|
74
|
-
*
|
|
75
|
-
* @param message - The message to sign
|
|
76
|
-
* @param keypair - The Solana Keypair
|
|
77
|
-
* @returns The Base58-encoded signature
|
|
78
|
-
*/
|
|
79
|
-
export declare function signMessage(message: string, keypair: Keypair): string;
|
|
1
|
+
export * from "./auth/index";
|
|
80
2
|
//# sourceMappingURL=auth.d.ts.map
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC"}
|
package/dist/auth.js
CHANGED
|
@@ -1,149 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
15
|
};
|
|
18
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
|
|
20
|
-
exports
|
|
21
|
-
exports.generateSigninMessageWithTimestamp = generateSigninMessageWithTimestamp;
|
|
22
|
-
exports.authenticate = authenticate;
|
|
23
|
-
exports.signMessage = signMessage;
|
|
24
|
-
const bs58_1 = __importDefault(require("bs58"));
|
|
25
|
-
const tweetnacl_1 = __importDefault(require("tweetnacl"));
|
|
26
|
-
const network_1 = require("./network");
|
|
27
|
-
/** Authentication timeout in milliseconds */
|
|
28
|
-
const AUTH_TIMEOUT_MS = 10000;
|
|
29
|
-
/**
|
|
30
|
-
* Authentication error class.
|
|
31
|
-
*/
|
|
32
|
-
class AuthError extends Error {
|
|
33
|
-
variant;
|
|
34
|
-
constructor(variant, message) {
|
|
35
|
-
super(message);
|
|
36
|
-
this.name = "AuthError";
|
|
37
|
-
this.variant = variant;
|
|
38
|
-
}
|
|
39
|
-
static systemTime(message) {
|
|
40
|
-
return new AuthError("SystemTime", `System time error: ${message}`);
|
|
41
|
-
}
|
|
42
|
-
static httpError(message) {
|
|
43
|
-
return new AuthError("HttpError", `HTTP error: ${message}`);
|
|
44
|
-
}
|
|
45
|
-
static authenticationFailed(message) {
|
|
46
|
-
return new AuthError("AuthenticationFailed", `Authentication failed: ${message}`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.AuthError = AuthError;
|
|
50
|
-
/**
|
|
51
|
-
* Generate the sign-in message with current timestamp.
|
|
52
|
-
*
|
|
53
|
-
* @returns The message to be signed
|
|
54
|
-
*/
|
|
55
|
-
function generateSigninMessage() {
|
|
56
|
-
const timestampMs = Date.now();
|
|
57
|
-
return `Sign in to Lightcone\n\nTimestamp: ${timestampMs}`;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Generate the sign-in message with a specific timestamp.
|
|
61
|
-
*
|
|
62
|
-
* @param timestampMs - Unix timestamp in milliseconds
|
|
63
|
-
* @returns The message to be signed
|
|
64
|
-
*/
|
|
65
|
-
function generateSigninMessageWithTimestamp(timestampMs) {
|
|
66
|
-
return `Sign in to Lightcone\n\nTimestamp: ${timestampMs}`;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Authenticate with Lightcone and obtain credentials using a Solana Keypair.
|
|
70
|
-
*
|
|
71
|
-
* @param keypair - The Solana Keypair for authentication
|
|
72
|
-
* @returns AuthCredentials containing the auth token and user public key
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```typescript
|
|
76
|
-
* import { Keypair } from "@solana/web3.js";
|
|
77
|
-
* import { auth } from "@lightcone/sdk";
|
|
78
|
-
*
|
|
79
|
-
* const keypair = Keypair.generate();
|
|
80
|
-
* const credentials = await auth.authenticate(keypair);
|
|
81
|
-
* console.log("Auth token:", credentials.authToken);
|
|
82
|
-
* ```
|
|
83
|
-
*/
|
|
84
|
-
async function authenticate(keypair) {
|
|
85
|
-
// Generate the message
|
|
86
|
-
const message = generateSigninMessage();
|
|
87
|
-
// Sign the message
|
|
88
|
-
const messageBytes = new TextEncoder().encode(message);
|
|
89
|
-
const signature = tweetnacl_1.default.sign.detached(messageBytes, keypair.secretKey);
|
|
90
|
-
const signatureB58 = bs58_1.default.encode(signature);
|
|
91
|
-
// Get the public key
|
|
92
|
-
const publicKeyB58 = keypair.publicKey.toBase58();
|
|
93
|
-
// Create the request body
|
|
94
|
-
const request = {
|
|
95
|
-
pubkey_bytes: Array.from(keypair.publicKey.toBytes()),
|
|
96
|
-
message,
|
|
97
|
-
signature_bs58: signatureB58,
|
|
98
|
-
};
|
|
99
|
-
// Send the authentication request with timeout
|
|
100
|
-
const url = `${network_1.DEFAULT_API_URL}/auth/login_or_register_with_message`;
|
|
101
|
-
const controller = new AbortController();
|
|
102
|
-
const timeoutId = setTimeout(() => controller.abort(), AUTH_TIMEOUT_MS);
|
|
103
|
-
let response;
|
|
104
|
-
try {
|
|
105
|
-
response = await fetch(url, {
|
|
106
|
-
method: "POST",
|
|
107
|
-
headers: {
|
|
108
|
-
"Content-Type": "application/json",
|
|
109
|
-
},
|
|
110
|
-
body: JSON.stringify(request),
|
|
111
|
-
signal: controller.signal,
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
catch (error) {
|
|
115
|
-
clearTimeout(timeoutId);
|
|
116
|
-
if (error instanceof Error && error.name === "AbortError") {
|
|
117
|
-
throw AuthError.authenticationFailed("Authentication request timed out");
|
|
118
|
-
}
|
|
119
|
-
throw AuthError.httpError(error instanceof Error ? error.message : String(error));
|
|
120
|
-
}
|
|
121
|
-
finally {
|
|
122
|
-
clearTimeout(timeoutId);
|
|
123
|
-
}
|
|
124
|
-
// Check for HTTP errors
|
|
125
|
-
if (!response.ok) {
|
|
126
|
-
throw AuthError.httpError(`HTTP ${response.status}`);
|
|
127
|
-
}
|
|
128
|
-
// Parse the response body
|
|
129
|
-
const loginResponse = (await response.json());
|
|
130
|
-
return {
|
|
131
|
-
authToken: loginResponse.token,
|
|
132
|
-
userPubkey: publicKeyB58,
|
|
133
|
-
userId: loginResponse.user_id,
|
|
134
|
-
expiresAt: loginResponse.expires_at,
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Sign a message with a Solana Keypair.
|
|
139
|
-
*
|
|
140
|
-
* @param message - The message to sign
|
|
141
|
-
* @param keypair - The Solana Keypair
|
|
142
|
-
* @returns The Base58-encoded signature
|
|
143
|
-
*/
|
|
144
|
-
function signMessage(message, keypair) {
|
|
145
|
-
const messageBytes = new TextEncoder().encode(message);
|
|
146
|
-
const signature = tweetnacl_1.default.sign.detached(messageBytes, keypair.secretKey);
|
|
147
|
-
return bs58_1.default.encode(signature);
|
|
148
|
-
}
|
|
17
|
+
// Compatibility shim for `import "./auth"` paths.
|
|
18
|
+
__exportStar(require("./auth/index"), exports);
|
|
149
19
|
//# sourceMappingURL=auth.js.map
|
package/dist/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAkD;AAClD,+CAA6B","sourcesContent":["// Compatibility shim for `import \"./auth\"` paths.\nexport * from \"./auth/index\";\n"]}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Auth, type AuthCredentials } from "./auth";
|
|
2
|
+
import { Admin } from "./domain/admin";
|
|
3
|
+
import { Markets } from "./domain/market";
|
|
4
|
+
import { Orders } from "./domain/order";
|
|
5
|
+
import { Orderbooks } from "./domain/orderbook";
|
|
6
|
+
import type { DecimalsResponse } from "./domain/orderbook";
|
|
7
|
+
import { Positions } from "./domain/position";
|
|
8
|
+
import { PriceHistoryClient } from "./domain/price_history";
|
|
9
|
+
import { Referrals } from "./domain/referral";
|
|
10
|
+
import { Trades } from "./domain/trade";
|
|
11
|
+
import { LightconeHttp } from "./http";
|
|
12
|
+
import { Privy } from "./privy";
|
|
13
|
+
import { WsClient, type WsConfig } from "./ws";
|
|
14
|
+
declare class DecimalsCache {
|
|
15
|
+
private readonly map;
|
|
16
|
+
get(orderbookId: string): DecimalsResponse | undefined;
|
|
17
|
+
set(orderbookId: string, response: DecimalsResponse): void;
|
|
18
|
+
clear(): void;
|
|
19
|
+
}
|
|
20
|
+
declare class AuthState {
|
|
21
|
+
private readonly clearCachesFn;
|
|
22
|
+
private credentialsValue;
|
|
23
|
+
constructor(clearCachesFn: () => Promise<void>, initial?: AuthCredentials);
|
|
24
|
+
getCredentials(): AuthCredentials | undefined;
|
|
25
|
+
setCredentials(credentials: AuthCredentials | undefined): void;
|
|
26
|
+
clearCaches(): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
export declare class LightconeClient {
|
|
29
|
+
readonly http: LightconeHttp;
|
|
30
|
+
private readonly wsConfigValue;
|
|
31
|
+
private readonly decimalsCacheStore;
|
|
32
|
+
private readonly authStateStore;
|
|
33
|
+
constructor(params: {
|
|
34
|
+
http: LightconeHttp;
|
|
35
|
+
wsConfig: WsConfig;
|
|
36
|
+
authCredentials?: AuthCredentials;
|
|
37
|
+
decimalsCache?: DecimalsCache;
|
|
38
|
+
authState?: AuthState;
|
|
39
|
+
});
|
|
40
|
+
static builder(): LightconeClientBuilder;
|
|
41
|
+
markets(): Markets;
|
|
42
|
+
orderbooks(): Orderbooks;
|
|
43
|
+
orders(): Orders;
|
|
44
|
+
positions(): Positions;
|
|
45
|
+
trades(): Trades;
|
|
46
|
+
priceHistory(): PriceHistoryClient;
|
|
47
|
+
admin(): Admin;
|
|
48
|
+
auth(): Auth;
|
|
49
|
+
privy(): Privy;
|
|
50
|
+
referrals(): Referrals;
|
|
51
|
+
wsConfig(): WsConfig;
|
|
52
|
+
ws(): WsClient;
|
|
53
|
+
clearDecimalsCache(): Promise<void>;
|
|
54
|
+
clone(): LightconeClient;
|
|
55
|
+
}
|
|
56
|
+
export declare class LightconeClientBuilder {
|
|
57
|
+
private baseUrlValue;
|
|
58
|
+
private wsUrlValue;
|
|
59
|
+
private authCredentials?;
|
|
60
|
+
baseUrl(url: string): LightconeClientBuilder;
|
|
61
|
+
withBaseUrl(url: string): LightconeClientBuilder;
|
|
62
|
+
wsUrl(url: string): LightconeClientBuilder;
|
|
63
|
+
withWsUrl(url: string): LightconeClientBuilder;
|
|
64
|
+
auth(credentials: AuthCredentials): LightconeClientBuilder;
|
|
65
|
+
withAuth(credentials: AuthCredentials): LightconeClientBuilder;
|
|
66
|
+
build(): LightconeClient;
|
|
67
|
+
}
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,eAAe,EAAE,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,KAAK,IAAI,eAAe;CAczB"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LightconeClientBuilder = exports.LightconeClient = void 0;
|
|
4
|
+
const auth_1 = require("./auth");
|
|
5
|
+
const admin_1 = require("./domain/admin");
|
|
6
|
+
const market_1 = require("./domain/market");
|
|
7
|
+
const order_1 = require("./domain/order");
|
|
8
|
+
const orderbook_1 = require("./domain/orderbook");
|
|
9
|
+
const position_1 = require("./domain/position");
|
|
10
|
+
const price_history_1 = require("./domain/price_history");
|
|
11
|
+
const referral_1 = require("./domain/referral");
|
|
12
|
+
const trade_1 = require("./domain/trade");
|
|
13
|
+
const http_1 = require("./http");
|
|
14
|
+
const network_1 = require("./network");
|
|
15
|
+
const privy_1 = require("./privy");
|
|
16
|
+
const ws_1 = require("./ws");
|
|
17
|
+
class DecimalsCache {
|
|
18
|
+
map = new Map();
|
|
19
|
+
get(orderbookId) {
|
|
20
|
+
return this.map.get(orderbookId);
|
|
21
|
+
}
|
|
22
|
+
set(orderbookId, response) {
|
|
23
|
+
this.map.set(orderbookId, response);
|
|
24
|
+
}
|
|
25
|
+
clear() {
|
|
26
|
+
this.map.clear();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
class AuthState {
|
|
30
|
+
clearCachesFn;
|
|
31
|
+
credentialsValue;
|
|
32
|
+
constructor(clearCachesFn, initial) {
|
|
33
|
+
this.clearCachesFn = clearCachesFn;
|
|
34
|
+
this.credentialsValue = initial;
|
|
35
|
+
}
|
|
36
|
+
getCredentials() {
|
|
37
|
+
return this.credentialsValue;
|
|
38
|
+
}
|
|
39
|
+
setCredentials(credentials) {
|
|
40
|
+
this.credentialsValue = credentials;
|
|
41
|
+
}
|
|
42
|
+
async clearCaches() {
|
|
43
|
+
await this.clearCachesFn();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
class LightconeClient {
|
|
47
|
+
http;
|
|
48
|
+
wsConfigValue;
|
|
49
|
+
decimalsCacheStore;
|
|
50
|
+
authStateStore;
|
|
51
|
+
constructor(params) {
|
|
52
|
+
this.http = params.http;
|
|
53
|
+
this.wsConfigValue = params.wsConfig;
|
|
54
|
+
this.decimalsCacheStore = params.decimalsCache ?? new DecimalsCache();
|
|
55
|
+
this.authStateStore =
|
|
56
|
+
params.authState ??
|
|
57
|
+
new AuthState(async () => this.clearDecimalsCache(), params.authCredentials);
|
|
58
|
+
}
|
|
59
|
+
static builder() {
|
|
60
|
+
return new LightconeClientBuilder();
|
|
61
|
+
}
|
|
62
|
+
markets() {
|
|
63
|
+
return new market_1.Markets(this);
|
|
64
|
+
}
|
|
65
|
+
orderbooks() {
|
|
66
|
+
return new orderbook_1.Orderbooks({
|
|
67
|
+
http: this.http,
|
|
68
|
+
decimalsCache: this.decimalsCacheStore,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
orders() {
|
|
72
|
+
return new order_1.Orders(this);
|
|
73
|
+
}
|
|
74
|
+
positions() {
|
|
75
|
+
return new position_1.Positions(this);
|
|
76
|
+
}
|
|
77
|
+
trades() {
|
|
78
|
+
return new trade_1.Trades(this);
|
|
79
|
+
}
|
|
80
|
+
priceHistory() {
|
|
81
|
+
return new price_history_1.PriceHistoryClient(this);
|
|
82
|
+
}
|
|
83
|
+
admin() {
|
|
84
|
+
return new admin_1.Admin(this);
|
|
85
|
+
}
|
|
86
|
+
auth() {
|
|
87
|
+
return new auth_1.Auth({
|
|
88
|
+
http: this.http,
|
|
89
|
+
authState: this.authStateStore,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
privy() {
|
|
93
|
+
return new privy_1.Privy(this);
|
|
94
|
+
}
|
|
95
|
+
referrals() {
|
|
96
|
+
return new referral_1.Referrals(this);
|
|
97
|
+
}
|
|
98
|
+
wsConfig() {
|
|
99
|
+
return this.wsConfigValue;
|
|
100
|
+
}
|
|
101
|
+
ws() {
|
|
102
|
+
return new ws_1.WsClient(this.wsConfigValue, this.http.authTokenRef());
|
|
103
|
+
}
|
|
104
|
+
async clearDecimalsCache() {
|
|
105
|
+
this.decimalsCacheStore.clear();
|
|
106
|
+
}
|
|
107
|
+
clone() {
|
|
108
|
+
return new LightconeClient({
|
|
109
|
+
http: this.http,
|
|
110
|
+
wsConfig: { ...this.wsConfigValue },
|
|
111
|
+
decimalsCache: this.decimalsCacheStore,
|
|
112
|
+
authState: this.authStateStore,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.LightconeClient = LightconeClient;
|
|
117
|
+
class LightconeClientBuilder {
|
|
118
|
+
baseUrlValue = network_1.DEFAULT_API_URL;
|
|
119
|
+
wsUrlValue = network_1.DEFAULT_WS_URL;
|
|
120
|
+
authCredentials;
|
|
121
|
+
baseUrl(url) {
|
|
122
|
+
return this.withBaseUrl(url);
|
|
123
|
+
}
|
|
124
|
+
withBaseUrl(url) {
|
|
125
|
+
this.baseUrlValue = url;
|
|
126
|
+
return this;
|
|
127
|
+
}
|
|
128
|
+
wsUrl(url) {
|
|
129
|
+
return this.withWsUrl(url);
|
|
130
|
+
}
|
|
131
|
+
withWsUrl(url) {
|
|
132
|
+
this.wsUrlValue = url;
|
|
133
|
+
return this;
|
|
134
|
+
}
|
|
135
|
+
auth(credentials) {
|
|
136
|
+
return this.withAuth(credentials);
|
|
137
|
+
}
|
|
138
|
+
withAuth(credentials) {
|
|
139
|
+
this.authCredentials = credentials;
|
|
140
|
+
return this;
|
|
141
|
+
}
|
|
142
|
+
build() {
|
|
143
|
+
return new LightconeClient({
|
|
144
|
+
http: new http_1.LightconeHttp(this.baseUrlValue),
|
|
145
|
+
wsConfig: {
|
|
146
|
+
url: this.wsUrlValue,
|
|
147
|
+
reconnect: true,
|
|
148
|
+
maxReconnectAttempts: 10,
|
|
149
|
+
baseReconnectDelayMs: 1_000,
|
|
150
|
+
pingIntervalMs: 30_000,
|
|
151
|
+
pongTimeoutMs: 1_000,
|
|
152
|
+
},
|
|
153
|
+
authCredentials: this.authCredentials,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
exports.LightconeClientBuilder = LightconeClientBuilder;
|
|
158
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,iCAAoD;AACpD,0CAAuC;AACvC,4CAA0C;AAC1C,0CAAwC;AACxC,kDAAgD;AAEhD,gDAA8C;AAC9C,0DAA4D;AAC5D,gDAA8C;AAC9C,0CAAwC;AACxC,iCAAuC;AACvC,uCAA4D;AAC5D,mCAAgC;AAChC,6BAA+C;AAE/C,MAAM,aAAa;IACA,GAAG,GAAG,IAAI,GAAG,EAA4B,CAAC;IAE3D,GAAG,CAAC,WAAmB;QACrB,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;IAED,GAAG,CAAC,WAAmB,EAAE,QAA0B;QACjD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACtC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;IACnB,CAAC;CACF;AAED,MAAM,SAAS;IAIM;IAHX,gBAAgB,CAA8B;IAEtD,YACmB,aAAkC,EACnD,OAAyB;QADR,kBAAa,GAAb,aAAa,CAAqB;QAGnD,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC;IAClC,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAED,cAAc,CAAC,WAAwC;QACrD,IAAI,CAAC,gBAAgB,GAAG,WAAW,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,WAAW;QACf,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;IAC7B,CAAC;CACF;AAED,MAAa,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,WAAW,CAAC,CAAC;IACpC,CAAC;IAED,QAAQ,CAAC,WAA4B;QACnC,IAAI,CAAC,eAAe,GAAG,WAAW,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK;QACH,OAAO,IAAI,eAAe,CAAC;YACzB,IAAI,EAAE,IAAI,oBAAa,CAAC,IAAI,CAAC,YAAY,CAAC;YAC1C,QAAQ,EAAE;gBACR,GAAG,EAAE,IAAI,CAAC,UAAU;gBACpB,SAAS,EAAE,IAAI;gBACf,oBAAoB,EAAE,EAAE;gBACxB,oBAAoB,EAAE,KAAK;gBAC3B,cAAc,EAAE,MAAM;gBACtB,aAAa,EAAE,KAAK;aACrB;YACD,eAAe,EAAE,IAAI,CAAC,eAAe;SACtC,CAAC,CAAC;IACL,CAAC;CACF;AA9CD,wDA8CC","sourcesContent":["import { Auth, type AuthCredentials } from \"./auth\";\nimport { Admin } from \"./domain/admin\";\nimport { Markets } from \"./domain/market\";\nimport { Orders } from \"./domain/order\";\nimport { Orderbooks } from \"./domain/orderbook\";\nimport type { DecimalsResponse } from \"./domain/orderbook\";\nimport { Positions } from \"./domain/position\";\nimport { PriceHistoryClient } from \"./domain/price_history\";\nimport { Referrals } from \"./domain/referral\";\nimport { Trades } from \"./domain/trade\";\nimport { LightconeHttp } from \"./http\";\nimport { DEFAULT_API_URL, DEFAULT_WS_URL } from \"./network\";\nimport { Privy } from \"./privy\";\nimport { WsClient, type WsConfig } from \"./ws\";\n\nclass DecimalsCache {\n private readonly map = new Map<string, DecimalsResponse>();\n\n get(orderbookId: string): DecimalsResponse | undefined {\n return this.map.get(orderbookId);\n }\n\n set(orderbookId: string, response: DecimalsResponse): void {\n this.map.set(orderbookId, response);\n }\n\n clear(): void {\n this.map.clear();\n }\n}\n\nclass AuthState {\n private credentialsValue: AuthCredentials | undefined;\n\n constructor(\n private readonly clearCachesFn: () => Promise<void>,\n initial?: AuthCredentials\n ) {\n this.credentialsValue = initial;\n }\n\n getCredentials(): AuthCredentials | undefined {\n return this.credentialsValue;\n }\n\n setCredentials(credentials: AuthCredentials | undefined): void {\n this.credentialsValue = credentials;\n }\n\n async clearCaches(): Promise<void> {\n await this.clearCachesFn();\n }\n}\n\nexport class LightconeClient {\n readonly http: LightconeHttp;\n private readonly wsConfigValue: WsConfig;\n private readonly decimalsCacheStore: DecimalsCache;\n private readonly authStateStore: AuthState;\n\n constructor(params: {\n http: LightconeHttp;\n wsConfig: WsConfig;\n authCredentials?: AuthCredentials;\n decimalsCache?: DecimalsCache;\n authState?: AuthState;\n }) {\n this.http = params.http;\n this.wsConfigValue = params.wsConfig;\n this.decimalsCacheStore = params.decimalsCache ?? new DecimalsCache();\n this.authStateStore =\n params.authState ??\n new AuthState(async () => this.clearDecimalsCache(), params.authCredentials);\n }\n\n static builder(): LightconeClientBuilder {\n return new LightconeClientBuilder();\n }\n\n markets(): Markets {\n return new Markets(this);\n }\n\n orderbooks(): Orderbooks {\n return new Orderbooks({\n http: this.http,\n decimalsCache: this.decimalsCacheStore,\n });\n }\n\n orders(): Orders {\n return new Orders(this);\n }\n\n positions(): Positions {\n return new Positions(this);\n }\n\n trades(): Trades {\n return new Trades(this);\n }\n\n priceHistory(): PriceHistoryClient {\n return new PriceHistoryClient(this);\n }\n\n admin(): Admin {\n return new Admin(this);\n }\n\n auth(): Auth {\n return new Auth({\n http: this.http,\n authState: this.authStateStore,\n });\n }\n\n privy(): Privy {\n return new Privy(this);\n }\n\n referrals(): Referrals {\n return new Referrals(this);\n }\n\n wsConfig(): WsConfig {\n return this.wsConfigValue;\n }\n\n ws(): WsClient {\n return new WsClient(this.wsConfigValue, this.http.authTokenRef());\n }\n\n async clearDecimalsCache(): Promise<void> {\n this.decimalsCacheStore.clear();\n }\n\n clone(): LightconeClient {\n return new LightconeClient({\n http: this.http,\n wsConfig: { ...this.wsConfigValue },\n decimalsCache: this.decimalsCacheStore,\n authState: this.authStateStore,\n });\n }\n}\n\nexport class LightconeClientBuilder {\n private baseUrlValue: string = DEFAULT_API_URL;\n private wsUrlValue: string = DEFAULT_WS_URL;\n private authCredentials?: AuthCredentials;\n\n baseUrl(url: string): LightconeClientBuilder {\n return this.withBaseUrl(url);\n }\n\n withBaseUrl(url: string): LightconeClientBuilder {\n this.baseUrlValue = url;\n return this;\n }\n\n wsUrl(url: string): LightconeClientBuilder {\n return this.withWsUrl(url);\n }\n\n withWsUrl(url: string): LightconeClientBuilder {\n this.wsUrlValue = url;\n return this;\n }\n\n auth(credentials: AuthCredentials): LightconeClientBuilder {\n return this.withAuth(credentials);\n }\n\n withAuth(credentials: AuthCredentials): LightconeClientBuilder {\n this.authCredentials = credentials;\n return this;\n }\n\n build(): LightconeClient {\n return new LightconeClient({\n http: new LightconeHttp(this.baseUrlValue),\n wsConfig: {\n url: this.wsUrlValue,\n reconnect: true,\n maxReconnectAttempts: 10,\n baseReconnectDelayMs: 1_000,\n pingIntervalMs: 30_000,\n pongTimeoutMs: 1_000,\n },\n authCredentials: this.authCredentials,\n });\n }\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type LightconeHttp } from "../../http";
|
|
2
|
+
import type { AdminEnvelope } from "./index";
|
|
3
|
+
import type { AllocateCodesRequest, AllocateCodesResponse, RevokeRequest, RevokeResponse, UnifiedMetadataRequest, UnifiedMetadataResponse, UnrevokeRequest, UnrevokeResponse, WhitelistRequest, WhitelistResponse } from "./wire";
|
|
4
|
+
interface ClientContext {
|
|
5
|
+
http: LightconeHttp;
|
|
6
|
+
}
|
|
7
|
+
export declare class Admin {
|
|
8
|
+
private readonly client;
|
|
9
|
+
constructor(client: ClientContext);
|
|
10
|
+
upsertMetadata(envelope: AdminEnvelope<UnifiedMetadataRequest>): Promise<UnifiedMetadataResponse>;
|
|
11
|
+
allocateCodes(envelope: AdminEnvelope<AllocateCodesRequest>): Promise<AllocateCodesResponse>;
|
|
12
|
+
whitelist(envelope: AdminEnvelope<WhitelistRequest>): Promise<WhitelistResponse>;
|
|
13
|
+
revoke(envelope: AdminEnvelope<RevokeRequest>): Promise<RevokeResponse>;
|
|
14
|
+
unrevoke(envelope: AdminEnvelope<UnrevokeRequest>): Promise<UnrevokeResponse>;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/domain/admin/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,QAAQ,CAAC;AAEhB,UAAU,aAAa;IACrB,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,qBAAa,KAAK;IACJ,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAE5C,cAAc,CAClB,QAAQ,EAAE,aAAa,CAAC,sBAAsB,CAAC,GAC9C,OAAO,CAAC,uBAAuB,CAAC;IAS7B,aAAa,CACjB,QAAQ,EAAE,aAAa,CAAC,oBAAoB,CAAC,GAC5C,OAAO,CAAC,qBAAqB,CAAC;IAS3B,SAAS,CAAC,QAAQ,EAAE,aAAa,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAShF,MAAM,CAAC,QAAQ,EAAE,aAAa,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;IASvE,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAQpF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Admin = void 0;
|
|
4
|
+
const http_1 = require("../../http");
|
|
5
|
+
class Admin {
|
|
6
|
+
client;
|
|
7
|
+
constructor(client) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
}
|
|
10
|
+
async upsertMetadata(envelope) {
|
|
11
|
+
const url = `${this.client.http.baseUrl()}/api/admin/metadata`;
|
|
12
|
+
return this.client.http.post(url, envelope, http_1.RetryPolicy.None);
|
|
13
|
+
}
|
|
14
|
+
async allocateCodes(envelope) {
|
|
15
|
+
const url = `${this.client.http.baseUrl()}/api/admin/referral/allocate`;
|
|
16
|
+
return this.client.http.post(url, envelope, http_1.RetryPolicy.None);
|
|
17
|
+
}
|
|
18
|
+
async whitelist(envelope) {
|
|
19
|
+
const url = `${this.client.http.baseUrl()}/api/admin/referral/whitelist`;
|
|
20
|
+
return this.client.http.post(url, envelope, http_1.RetryPolicy.None);
|
|
21
|
+
}
|
|
22
|
+
async revoke(envelope) {
|
|
23
|
+
const url = `${this.client.http.baseUrl()}/api/admin/referral/revoke`;
|
|
24
|
+
return this.client.http.post(url, envelope, http_1.RetryPolicy.None);
|
|
25
|
+
}
|
|
26
|
+
async unrevoke(envelope) {
|
|
27
|
+
const url = `${this.client.http.baseUrl()}/api/admin/referral/unrevoke`;
|
|
28
|
+
return this.client.http.post(url, envelope, http_1.RetryPolicy.None);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.Admin = Admin;
|
|
32
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/domain/admin/client.ts"],"names":[],"mappings":";;;AAAA,qCAA6D;AAmB7D,MAAa,KAAK;IACa;IAA7B,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAEtD,KAAK,CAAC,cAAc,CAClB,QAA+C;QAE/C,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,M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ent":["import { RetryPolicy, type LightconeHttp } from \"../../http\";\nimport type { AdminEnvelope } from \"./index\";\nimport type {\n AllocateCodesRequest,\n AllocateCodesResponse,\n RevokeRequest,\n RevokeResponse,\n UnifiedMetadataRequest,\n UnifiedMetadataResponse,\n UnrevokeRequest,\n UnrevokeResponse,\n WhitelistRequest,\n WhitelistResponse,\n} from \"./wire\";\n\ninterface ClientContext {\n http: LightconeHttp;\n}\n\nexport class Admin {\n constructor(private readonly client: ClientContext) {}\n\n async upsertMetadata(\n envelope: AdminEnvelope<UnifiedMetadataRequest>\n ): Promise<UnifiedMetadataResponse> {\n const url = `${this.client.http.baseUrl()}/api/admin/metadata`;\n return this.client.http.post<UnifiedMetadataResponse, AdminEnvelope<UnifiedMetadataRequest>>(\n url,\n envelope,\n RetryPolicy.None\n );\n }\n\n async allocateCodes(\n envelope: AdminEnvelope<AllocateCodesRequest>\n ): Promise<AllocateCodesResponse> {\n const url = `${this.client.http.baseUrl()}/api/admin/referral/allocate`;\n return this.client.http.post<AllocateCodesResponse, AdminEnvelope<AllocateCodesRequest>>(\n url,\n envelope,\n RetryPolicy.None\n );\n }\n\n async whitelist(envelope: AdminEnvelope<WhitelistRequest>): Promise<WhitelistResponse> {\n const url = `${this.client.http.baseUrl()}/api/admin/referral/whitelist`;\n return this.client.http.post<WhitelistResponse, AdminEnvelope<WhitelistRequest>>(\n url,\n envelope,\n RetryPolicy.None\n );\n }\n\n async revoke(envelope: AdminEnvelope<RevokeRequest>): Promise<RevokeResponse> {\n const url = `${this.client.http.baseUrl()}/api/admin/referral/revoke`;\n return this.client.http.post<RevokeResponse, AdminEnvelope<RevokeRequest>>(\n url,\n envelope,\n RetryPolicy.None\n );\n }\n\n async unrevoke(envelope: AdminEnvelope<UnrevokeRequest>): Promise<UnrevokeResponse> {\n const url = `${this.client.http.baseUrl()}/api/admin/referral/unrevoke`;\n return this.client.http.post<UnrevokeResponse, AdminEnvelope<UnrevokeRequest>>(\n url,\n envelope,\n RetryPolicy.None\n );\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/domain/admin/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AAEvB,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,OAAO,EAAE,CAAC,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./client"), exports);
|
|
18
|
+
__exportStar(require("./wire"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/admin/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,yCAAuB","sourcesContent":["export * from \"./client\";\nexport * from \"./wire\";\n\nexport interface AdminEnvelope<T> {\n payload: T;\n signature: string;\n}\n"]}
|