@0xmonaco/core 0.8.7-develop.5d0e403 → 0.8.7-develop.a107b34

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/coverage.js CHANGED
@@ -1,7 +1,92 @@
1
+ /** operationId → the @0xmonaco/core client method that covers it. */
2
+ export const COVERED = {
3
+ add_position_margin: "addPositionMargin",
4
+ attach_position_tp_sl: "attachPositionTpSl",
5
+ batch_cancel_all: "batchCancelAll",
6
+ batch_cancel_all_by_pair: "batchCancelAll (with tradingPairId)",
7
+ batch_cancel_orders: "batchCancel",
8
+ batch_close_all_positions: "batchCloseAllPositions",
9
+ batch_create_orders: "batchCreate",
10
+ batch_replace_orders: "batchReplace",
11
+ cancel_conditional_order: "cancelConditionalOrder",
12
+ cancel_order: "cancelOrder",
13
+ close_position: "closePosition",
14
+ create_challenge: "createChallenge",
15
+ create_delegated_session: "createDelegatedSession",
16
+ create_order: "placeLimitOrder / placeMarketOrder",
17
+ create_sub_account_limit: "subAccounts.createLimit",
18
+ delete_sub_account_limit: "subAccounts.deleteLimit",
19
+ get_application_config: "getApplicationConfig",
20
+ get_application_stats: "getApplicationStats",
21
+ get_available_collateral: "getAvailableCollateral",
22
+ get_candles: "getCandlesticks",
23
+ get_funding_state: "getFundingState",
24
+ get_index_price: "getIndexPrice",
25
+ get_margin_account_movements: "getMarginAccountMovements",
26
+ get_margin_account_summary: "getMarginAccountSummary",
27
+ get_mark_price: "getMarkPrice",
28
+ get_market_metadata: "getMarketMetadata",
29
+ get_market_stats: "getMarketStats",
30
+ get_open_interest: "getOpenInterest",
31
+ get_order_by_id: "getOrder",
32
+ get_orderbook_snapshot: "getOrderbook",
33
+ get_orders: "getPaginatedOrders",
34
+ get_perp_market_config: "getPerpMarketConfig",
35
+ get_perp_market_summary: "getPerpMarketSummary",
36
+ get_portfolio_chart: "getPortfolioChart",
37
+ get_portfolio_stats: "getPortfolioStats",
38
+ get_position: "getPosition",
39
+ get_position_risk: "getPositionRisk",
40
+ get_parent_margin_account_movements: "getParentMarginAccountMovements",
41
+ get_parent_margin_account_summary: "getParentMarginAccountSummary",
42
+ get_screener: "getScreener",
43
+ get_sub_account_limits: "subAccounts.getLimits",
44
+ get_trade_by_id: "getTradeById",
45
+ get_trades: "getTrades",
46
+ get_trading_pair_by_id: "getTradingPair",
47
+ get_user_balance_by_asset: "getUserBalanceByAssetId",
48
+ get_user_balances: "getUserBalances",
49
+ get_user_movements: "getPaginatedUserMovements",
50
+ get_user_profile: "getProfile",
51
+ get_user_trades: "getUserTrades",
52
+ get_withdrawal: "getWithdrawal",
53
+ initiate_withdrawal: "initiateWithdrawal",
54
+ list_application_balances: "listApplicationBalances",
55
+ list_application_movements: "listApplicationMovements",
56
+ list_application_orders: "listApplicationOrders",
57
+ list_application_users: "listApplicationUsers",
58
+ list_conditional_orders: "listConditionalOrders",
59
+ list_delegated_agent_owners: "listDelegatedOwners",
60
+ list_delegated_agents: "listDelegatedAgents",
61
+ list_funding_history: "listFundingHistory",
62
+ list_funding_payments: "listFundingPayments",
63
+ list_margin_accounts: "listMarginAccounts",
64
+ list_position_history: "listPositionHistory",
65
+ list_positions: "listPositions",
66
+ list_sub_accounts_with_balances: "subAccounts.list",
67
+ list_trading_pairs: "getPaginatedTradingPairs",
68
+ mint_tokens: "faucet.mint",
69
+ reduce_position_margin: "reducePositionMargin",
70
+ refresh_session: "refreshSession",
71
+ replace_order: "replaceOrder",
72
+ revoke_delegated_agent: "revokeDelegatedAgent",
73
+ revoke_session: "revokeSession",
74
+ simulate_risk_bucket_order_risk: "simulateRiskBucketOrderRisk",
75
+ simulate_fees: "simulateFees",
76
+ simulate_order_risk: "simulateOrderRisk",
77
+ simulate_parent_margin_order_risk: "simulateParentMarginOrderRisk",
78
+ submit_whitelist: "whitelist.submit",
79
+ transfer_collateral_from_parent_margin_account: "transferCollateralFromParentMarginAccount",
80
+ transfer_collateral_from_margin_account: "transferCollateralFromMarginAccount",
81
+ transfer_collateral_to_margin_account: "transferCollateralToMarginAccount",
82
+ transfer_collateral_to_parent_margin_account: "transferCollateralToParentMarginAccount",
83
+ transfer_collateral_to_risk_bucket: "transferCollateralToRiskBucket",
84
+ update_sub_account_limit: "subAccounts.updateLimit",
85
+ upsert_delegated_agent: "upsertDelegatedAgent",
86
+ verify_signature: "verifySignature",
87
+ };
1
88
  /** operationId → reason it is intentionally not covered by @0xmonaco/core. */
2
89
  export const INTENTIONALLY_EXCLUDED = {
3
90
  authenticate_backend: "Backend auth is header-based via setServerKey()/the x-server-key header, not an endpoint method (MON-1486).",
4
91
  health_check: "Infrastructure liveness probe (GET /health); not part of the data SDK surface.",
5
- list_funding_payments: "gRPC-only: accounts.proto declares the HTTP annotation but api-gateway-rust has no Actix route for GET /api/v1/accounts/funding-payments, so it is unreachable from a REST client.",
6
- list_user_trades: "gRPC-only: trades.proto declares the HTTP annotation but there is no Actix route; GET /api/v1/trades/user is shadowed by GET /api/v1/trades/{id}. Equivalent data is exposed via get_user_trades (GET /api/v1/accounts/trades).",
7
92
  };
package/dist/sdk.d.ts CHANGED
@@ -85,6 +85,15 @@ export declare class MonacoSDKImpl implements MonacoSDK {
85
85
  login(clientId: string, options?: {
86
86
  connectWebSocket?: boolean;
87
87
  }): Promise<AuthState>;
88
+ /**
89
+ * Create and adopt an owner-scoped delegated session.
90
+ *
91
+ * This must be called while authenticated as the agent wallet. The delegated
92
+ * session uses a fresh ed25519 keypair generated locally; the current agent
93
+ * session signs the registration request, and subsequent SDK calls use the
94
+ * delegated session keypair.
95
+ */
96
+ loginAsDelegatedOwner(ownerUserId: string): Promise<AuthState>;
88
97
  /**
89
98
  * Get the current authentication state
90
99
  *
package/dist/sdk.js CHANGED
@@ -15,6 +15,7 @@ import { TradingAPIImpl } from "./api/trading";
15
15
  import { VaultAPIImpl } from "./api/vault";
16
16
  import { WhitelistAPIImpl } from "./api/whitelist";
17
17
  import { WithdrawalsAPIImpl } from "./api/withdrawals";
18
+ import { generateSessionKeypair, privateKeyHex, publicKeyHex } from "./crypto/session";
18
19
  import { APIError, InvalidConfigError, InvalidStateError } from "./errors";
19
20
  import { resolveApiUrl, resolveWsUrl } from "./networks";
20
21
  /** Validate a user-supplied URL override, returning it unchanged when valid. */
@@ -214,6 +215,42 @@ export class MonacoSDKImpl {
214
215
  }
215
216
  return this.authState;
216
217
  }
218
+ /**
219
+ * Create and adopt an owner-scoped delegated session.
220
+ *
221
+ * This must be called while authenticated as the agent wallet. The delegated
222
+ * session uses a fresh ed25519 keypair generated locally; the current agent
223
+ * session signs the registration request, and subsequent SDK calls use the
224
+ * delegated session keypair.
225
+ */
226
+ async loginAsDelegatedOwner(ownerUserId) {
227
+ if (!this.authState) {
228
+ throw new APIError("No active agent session to create delegated session", {
229
+ endpoint: "delegated-agents/sessions",
230
+ statusCode: StatusCodes.UNAUTHORIZED,
231
+ });
232
+ }
233
+ const keypair = generateSessionKeypair();
234
+ const session = {
235
+ publicKey: publicKeyHex(keypair),
236
+ privateKey: privateKeyHex(keypair),
237
+ };
238
+ const delegatedSession = await this.delegatedAgents.createDelegatedSession({
239
+ ownerUserId,
240
+ sessionPublicKey: session.publicKey,
241
+ });
242
+ this.authState = {
243
+ sessionPublicKey: session.publicKey,
244
+ sessionPrivateKey: session.privateKey,
245
+ expiresAt: delegatedSession.expires_at,
246
+ user: {
247
+ id: delegatedSession.owner_user_id,
248
+ address: delegatedSession.agent_address,
249
+ },
250
+ };
251
+ this.propagateSession(this.sessionFromAuthState(this.authState));
252
+ return this.authState;
253
+ }
217
254
  /**
218
255
  * Get the current authentication state
219
256
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xmonaco/core",
3
- "version": "0.8.7-develop.5d0e403",
3
+ "version": "0.8.7-develop.a107b34",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,8 +23,8 @@
23
23
  "viem": "^2.45.2"
24
24
  },
25
25
  "dependencies": {
26
- "@0xmonaco/contracts": "0.8.7-develop.5d0e403",
27
- "@0xmonaco/types": "0.8.7-develop.5d0e403",
26
+ "@0xmonaco/contracts": "0.8.7-develop.a107b34",
27
+ "@0xmonaco/types": "0.8.7-develop.a107b34",
28
28
  "@noble/curves": "^1.9.1",
29
29
  "@noble/hashes": "^1.8.0",
30
30
  "http-status-codes": "^2.3.0"