@agg-build/sdk 1.2.11 → 1.2.13
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/index.d.mts +53 -6
- package/dist/index.d.ts +53 -6
- package/dist/index.js +4 -1
- package/dist/index.mjs +4 -1
- package/dist/server.d.mts +62 -6
- package/dist/server.d.ts +62 -6
- package/dist/server.js +61 -2
- package/dist/server.mjs +58 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -375,7 +375,9 @@ type WalletChainBalance = {
|
|
|
375
375
|
chainId: number;
|
|
376
376
|
tokenAddress: string;
|
|
377
377
|
balanceRaw: string;
|
|
378
|
+
decimals: number;
|
|
378
379
|
lastSyncedAt: string;
|
|
380
|
+
tokenSymbol?: string | undefined;
|
|
379
381
|
};
|
|
380
382
|
type WalletTokenBalance = {
|
|
381
383
|
tokenSymbol: string;
|
|
@@ -2093,6 +2095,7 @@ interface ExecuteManagedParams {
|
|
|
2093
2095
|
side: "buy" | "sell";
|
|
2094
2096
|
maxSpend?: number;
|
|
2095
2097
|
sellShares?: number;
|
|
2098
|
+
allowedVenues?: Venue[];
|
|
2096
2099
|
};
|
|
2097
2100
|
}
|
|
2098
2101
|
interface ExecuteManagedResponse {
|
|
@@ -2154,8 +2157,9 @@ interface WithdrawManagedSourceItem {
|
|
|
2154
2157
|
bridgeOperationId: string | null;
|
|
2155
2158
|
}
|
|
2156
2159
|
/**
|
|
2157
|
-
* `pricingStatus === "
|
|
2158
|
-
*
|
|
2160
|
+
* `pricingStatus === "quoted"` means the response includes a fresh preflight
|
|
2161
|
+
* quote; other states may carry null `expected.*` fields. Do NOT treat null
|
|
2162
|
+
* fields as missing.
|
|
2159
2163
|
*/
|
|
2160
2164
|
interface WithdrawalExpected {
|
|
2161
2165
|
outputRaw: string | null;
|
|
@@ -2181,7 +2185,7 @@ interface WithdrawManagedResponse {
|
|
|
2181
2185
|
};
|
|
2182
2186
|
legs: WithdrawalLeg[];
|
|
2183
2187
|
expected: WithdrawalExpected;
|
|
2184
|
-
pricingStatus: "unquoted" | "quoted";
|
|
2188
|
+
pricingStatus: "unquoted" | "quoting" | "quoted" | "unviable";
|
|
2185
2189
|
/**
|
|
2186
2190
|
* Persisted terminal-state error reason. Always `null` until the
|
|
2187
2191
|
* withdrawal reaches `failed` / `partial`. The submit response always
|
|
@@ -2246,7 +2250,7 @@ type ExecutionOrdersQuery = GetOrdersQuery;
|
|
|
2246
2250
|
type ExecutionOrderItem = OrderListItem;
|
|
2247
2251
|
type ExecutionPositionsQuery = GetPositionsQuery;
|
|
2248
2252
|
type ExecutionPositionGroup = PositionGroup;
|
|
2249
|
-
type UserActivityType = "trade" | "withdrawal" | "bridge" | "deposit" | "user_op";
|
|
2253
|
+
type UserActivityType = "trade" | "withdrawal" | "bridge" | "deposit" | "user_op" | "redeem";
|
|
2250
2254
|
interface UserActivityBase {
|
|
2251
2255
|
id: string;
|
|
2252
2256
|
createdAt: string;
|
|
@@ -2315,7 +2319,25 @@ interface UserActivityUserOp extends UserActivityBase {
|
|
|
2315
2319
|
txHash: string | null;
|
|
2316
2320
|
confirmedAt: string | null;
|
|
2317
2321
|
}
|
|
2318
|
-
|
|
2322
|
+
interface UserActivityRedeemLeg {
|
|
2323
|
+
id: string;
|
|
2324
|
+
venueMarketOutcomeId: string;
|
|
2325
|
+
venue: string;
|
|
2326
|
+
status: string;
|
|
2327
|
+
chainId: string;
|
|
2328
|
+
payoutTokenSymbol: string;
|
|
2329
|
+
payoutAmountRaw: string | null;
|
|
2330
|
+
txHash: string | null;
|
|
2331
|
+
errorMessage: string | null;
|
|
2332
|
+
venueMarket: UserActivityVenueMarket | null;
|
|
2333
|
+
venueMarketOutcome: Omit<UserActivityVenueMarketOutcome, "price"> | null;
|
|
2334
|
+
}
|
|
2335
|
+
interface UserActivityRedeem extends UserActivityBase {
|
|
2336
|
+
type: "redeem";
|
|
2337
|
+
totalPayoutRaw: string | null;
|
|
2338
|
+
legs: UserActivityRedeemLeg[];
|
|
2339
|
+
}
|
|
2340
|
+
type UserActivityItem = UserActivityTrade | UserActivityWithdrawal | UserActivityBridge | UserActivityDeposit | UserActivityUserOp | UserActivityRedeem;
|
|
2319
2341
|
interface UserActivityQuery {
|
|
2320
2342
|
type?: UserActivityType;
|
|
2321
2343
|
cursor?: string;
|
|
@@ -2378,6 +2400,23 @@ interface SmartRouteVenueFill {
|
|
|
2378
2400
|
fills: SmartRouteFill[];
|
|
2379
2401
|
venueQty: number;
|
|
2380
2402
|
}
|
|
2403
|
+
interface SmartRouteAllocation {
|
|
2404
|
+
sourceChainId: string;
|
|
2405
|
+
venue: string;
|
|
2406
|
+
amount: number;
|
|
2407
|
+
sourceTokenAddress?: string;
|
|
2408
|
+
custodyKind?: "EOA" | "DEPOSIT_WALLET";
|
|
2409
|
+
custodyAddress?: string;
|
|
2410
|
+
exactToken?: boolean;
|
|
2411
|
+
}
|
|
2412
|
+
interface SmartRouteBridgeStep {
|
|
2413
|
+
sourceChainId: string;
|
|
2414
|
+
destChainId: string;
|
|
2415
|
+
amount: number;
|
|
2416
|
+
cost: number;
|
|
2417
|
+
sourceTokenAddress?: string;
|
|
2418
|
+
destTokenAddress?: string;
|
|
2419
|
+
}
|
|
2381
2420
|
interface VenueSoloQuote {
|
|
2382
2421
|
/**
|
|
2383
2422
|
* Minted by the API per successful + executable solo; send this to
|
|
@@ -2396,6 +2435,8 @@ interface VenueSoloQuote {
|
|
|
2396
2435
|
status: string;
|
|
2397
2436
|
/** Per-price-level fills, identical shape to primary fills. Empty for non-ok statuses. */
|
|
2398
2437
|
fills: SmartRouteVenueFill[];
|
|
2438
|
+
allocations?: SmartRouteAllocation[];
|
|
2439
|
+
bridgeSteps?: SmartRouteBridgeStep[];
|
|
2399
2440
|
/**
|
|
2400
2441
|
* One-time setup costs for this solo's chosen venue + market. Populated
|
|
2401
2442
|
* only when the originating quote opted in via `deepEstimate=true`; absent
|
|
@@ -2429,6 +2470,8 @@ interface SmartRouteParams {
|
|
|
2429
2470
|
chainBalances?: Record<string, number>;
|
|
2430
2471
|
slipCapBps?: number;
|
|
2431
2472
|
compareVenues?: boolean;
|
|
2473
|
+
/** Restrict this quote to one or more executable venues. */
|
|
2474
|
+
allowedVenues?: Venue[];
|
|
2432
2475
|
/**
|
|
2433
2476
|
* Opt in to the deep cost-estimate surface. When `true`, the response
|
|
2434
2477
|
* `feeBreakdown` includes `setupCosts` (one-time chain approvals + Kalshi
|
|
@@ -2526,6 +2569,8 @@ interface SmartRouteResponse {
|
|
|
2526
2569
|
reason: string;
|
|
2527
2570
|
}>;
|
|
2528
2571
|
venueSoloQuotes?: VenueSoloQuote[];
|
|
2572
|
+
allocations?: SmartRouteAllocation[];
|
|
2573
|
+
bridgeSteps?: SmartRouteBridgeStep[];
|
|
2529
2574
|
/** Estimated payout if the outcome wins (= totalFilled shares × $1). */
|
|
2530
2575
|
estimatedPayout?: number;
|
|
2531
2576
|
/** Total cost including all fees (rawExecCost + venueFees + bridgeFees +
|
|
@@ -2860,6 +2905,7 @@ declare class AggClient {
|
|
|
2860
2905
|
status?: MarketStatus[];
|
|
2861
2906
|
sortBy?: string;
|
|
2862
2907
|
sortDir?: string;
|
|
2908
|
+
recurrence?: string;
|
|
2863
2909
|
limit?: number;
|
|
2864
2910
|
cursor?: string;
|
|
2865
2911
|
minYesPrice?: number;
|
|
@@ -2888,6 +2934,7 @@ declare class AggClient {
|
|
|
2888
2934
|
getCategories(options?: {
|
|
2889
2935
|
limit?: number;
|
|
2890
2936
|
cursor?: string;
|
|
2937
|
+
parentId?: string;
|
|
2891
2938
|
}): Promise<PaginatedResponse<Category>>;
|
|
2892
2939
|
/** Get per-app UI config (disabled venues + category presets). Requires appId. */
|
|
2893
2940
|
getAppConfig(init?: RequestInit): Promise<AppClientConfigResponse>;
|
|
@@ -3094,4 +3141,4 @@ declare function aggregateMidpoint(midpoints: (number | null | undefined)[]): nu
|
|
|
3094
3141
|
|
|
3095
3142
|
declare function createAggClient(options: AggClientOptions): AggClient;
|
|
3096
3143
|
|
|
3097
|
-
export { type Account, AccountProvider, AccountType, type AggAuthDeliveryMode, type AggAuthProviderType, type AggAuthStartBody, type AggAuthStartResult, type AggAuthVerifyBody, AggClient, type AggClientAuthOptions, type AggClientSessionInput, type AggLinkAccountBody, type AggLinkAccountConfirmResult, type AggLinkAccountResult, type AggSessionUser, AggWebSocket, type AggWebSocketCallbacks, type AggWebSocketOptions, type AggregatedOrderbookLevel, type AggregatedOrderbookResponse, type App, type AppClientConfigResponse, type AttributedOrderbook, type AttributedOrderbookLevel, type AuthCodeResponse, type AuthStatus, type AuthTokenResponse, type AuthUser, type BatchMidpointsResponse, type BatchOrderbooksResponse, type BuildVenueUrlOpts, CONFIRMED_MATCH_STATUSES, type CancelManagedExecutionResponse, type Candle, CandleBuilder, type CandleInterval, type Category, Chain, type ChartBarsResponse, type ChartCandle, type ChartResolution, type ChartVenueCandles, type ComputeSplitsRequest, type ComputeSplitsResponse, type ComputeSplitsSelection, type CorrelatedMarketCascadeItem, type CorrelatedMarketCascadeResponse, type CorrelatedMarketQueryResult, type CorrelatedMarketSide, type CorrelatedMarketSignal, type CorrelatedMarketSignalBatch, type CorrelatedMarketSignalDirection, type CorrelatedMarketsStatus, type CreateApp, type DepositAddressesPendingResponse, type DepositAddressesReadyResponse, type DepositAddressesResponse, type DepositAddressesSupportedChain, type DepositAddressesToken, type DepositStep, type DiagnosticCallback, type DiagnosticEvent, type ExecuteManagedParams, type ExecuteManagedRequest, type ExecuteManagedResponse, type ExecuteTradeRequest, type ExecuteTradeResponse, type ExecutionOrderItem, type ExecutionOrdersQuery, type ExecutionPositionGroup, type ExecutionPositionsQuery, type GetBalanceQuery, type GetBalanceResponse, type GetHoldingsQuery, type GetHoldingsResponse, type GetOrdersParams, type GetOrdersQuery, type GetPositionsParams, type GetPositionsQuery, type HelloResponse, IMAGE_SIZES, ImageSize, type MarkSource, type MarketPriceHistory, MarketStatus, MatchStatus, MatchType, type MatchedMidpoint, type MatchedMidpointOutcome, type MatchedOrderbookMarket, type MatchedVenueMarketOutcomeRef, type MatchingReport, type MidpointItem, type MidpointRow, type NonceResponse, type OrderListItem, type OrderListQuery, OrderStatus, type Orderbook, type OrderbookBatchItemError, type OrderbookBatchItemErrorCode, type OrderbookBatchItemStatus, type OrderbookHistoryPoint, type OrderbookHistoryResponse, type OrderbookLevel, type OrderbookQuoteFill, type OrderbookQuoteParams, type OrderbookQuoteResponse, type OrderbookServiceUnavailableError, type OrderbookState, type OrderbooksOnlyError, type OutcomeMidpoint, type OutcomeMidpointRow, type OutcomeOrderbookResponse, type PaginatedResponse, type PersistedAuthSnapshot, type PositionGroup, type PositionRedeemStatus, type PricePoint, type PriceSource, type PricesHistoryResponse, type QuoteManagedParams, type QuoteManagedRequest, type QuoteManagedResponse, type QuoteManagedSplit, type QuoteManagedStep, type QuoteSplit, type QuoteStep, type RampQuote, type RampQuoteRequest, type RampSessionRequest, type RampWidgetSession, type RedeemLegResult, type RedeemLegStatus, type RedeemRequest, type RedeemResponse, type RequestedOrderbookMarket, type ResolveCorrelatedMarketsParams, type ResolveCorrelatedMarketsResponse, type ResolvedCorrelatedMarketsResponse, type SafeParseFailure, type SafeParseResult, type SafeParseSuccess, type ServerWallet, type SettlementSource, type SetupDepositAddressStep, type SetupVenueKeyStep, type SimpleOrderbookLevel, type SmartRouteFeeBreakdown, type SmartRouteFill, type SmartRouteParams, type SmartRouteResponse, type SmartRouteSetupCostLine, type SmartRouteSide, type SmartRouteStatus, type SmartRouteVenueFill, type SplitsByAmountResult, type SyncBalancesResponse, type TradeExecutorOrder, type TradeExecutorOrderListResponse, TradeSide$1 as TradeSide, type TradeSplit, type TradeStep, TurnstileChallengeError, type UnifiedBalanceResponse, type UpdateUserBody, type UpsertVenueKey, type UserActivityBridge, type UserActivityDeposit, type UserActivityItem, type UserActivityQuery, type UserActivityTrade, type UserActivityType, type UserActivityUserOp, type UserActivityWithdrawal, type UserHolding, type UserProfile, VENUES, type ValidateBalanceOnClientStep, type ValidateManagedParams, type ValidateManagedRequest, type ValidateManagedResponse, type ValidateTradeRequest, type ValidateTradeResponse, Venue, type VenueEvent, type VenueEventListItem, type VenueEventWithMarkets, type VenueKeySummary, type VenueMarket, type VenueMarketClusterNode, type VenueMarketListItem, type VenueMarketOutcome, type VenueMarketRef, type VenueOrderbookEntry, type VenueOrderbookLevel, type VenuePositionBalance, type VenuePriceInfo, type VenueSoloQuote, type VerifyBody, type VerifyResponse, type WalletChainBalance, type WalletTokenBalance, type WithdrawManagedParams, type WithdrawManagedRequest, type WithdrawManagedResponse, type WithdrawManagedSourceItem, type WithdrawTokenSymbol, type WithdrawalExpected, type WithdrawalLeg, type WithdrawalLegStatus, type WithdrawalLegType, type WithdrawalLifecycleStatus, type WithdrawalSource, type WithdrawalSourceItem, type WithdrawalSourceStatus, type WsAttributedLevel, type WsAuthenticated, type WsBalanceUpdate, type WsCandleInterval, type WsClientMessage, type WsConnected, type WsError, type WsHeartbeat, type WsMarkSource, type WsMarketResolved, type WsOrderEvent, type WsOrderEventType, type WsOrderSubmitted, type WsOrderbookDelta, type WsOrderbookSnapshot, type WsRedeemEvent, type WsServerMessage, type WsSubscribed, type WsTrade, type WsUnsubscribed, type WsVenueBook, type WsVenueInfo, type WsVenueLevel, type WsWithdrawalLegStatus, type WsWithdrawalLifecycleEvent, type WsWithdrawalLifecycleLeg, type WsWithdrawalLifecycleStatus, aggregateMidpoint, applyOrderbookDelta, buildVenueUrl, computeBestSplitsByAmount, computeChecksum, createAggClient, enumGuard, formatMarketQuestion, formatOutcomeLabel, formatOutcomeTitle, getWalletAddressFromUserProfile, hasShape, isEmail, isEnum, isFiniteNonNeg, isNonEmptyString, mergeCandles, mergeClosedCandles, normalizeVenueMarketCluster, optimizedImageUrl, parse, parseEmail, parseEmailStrict, safeParse, snapshotToOrderbook, sortVenues };
|
|
3144
|
+
export { type Account, AccountProvider, AccountType, type AggAuthDeliveryMode, type AggAuthProviderType, type AggAuthStartBody, type AggAuthStartResult, type AggAuthVerifyBody, AggClient, type AggClientAuthOptions, type AggClientSessionInput, type AggLinkAccountBody, type AggLinkAccountConfirmResult, type AggLinkAccountResult, type AggSessionUser, AggWebSocket, type AggWebSocketCallbacks, type AggWebSocketOptions, type AggregatedOrderbookLevel, type AggregatedOrderbookResponse, type App, type AppClientConfigResponse, type AttributedOrderbook, type AttributedOrderbookLevel, type AuthCodeResponse, type AuthStatus, type AuthTokenResponse, type AuthUser, type BatchMidpointsResponse, type BatchOrderbooksResponse, type BuildVenueUrlOpts, CONFIRMED_MATCH_STATUSES, type CancelManagedExecutionResponse, type Candle, CandleBuilder, type CandleInterval, type Category, Chain, type ChartBarsResponse, type ChartCandle, type ChartResolution, type ChartVenueCandles, type ComputeSplitsRequest, type ComputeSplitsResponse, type ComputeSplitsSelection, type CorrelatedMarketCascadeItem, type CorrelatedMarketCascadeResponse, type CorrelatedMarketQueryResult, type CorrelatedMarketSide, type CorrelatedMarketSignal, type CorrelatedMarketSignalBatch, type CorrelatedMarketSignalDirection, type CorrelatedMarketsStatus, type CreateApp, type DepositAddressesPendingResponse, type DepositAddressesReadyResponse, type DepositAddressesResponse, type DepositAddressesSupportedChain, type DepositAddressesToken, type DepositStep, type DiagnosticCallback, type DiagnosticEvent, type ExecuteManagedParams, type ExecuteManagedRequest, type ExecuteManagedResponse, type ExecuteTradeRequest, type ExecuteTradeResponse, type ExecutionOrderItem, type ExecutionOrdersQuery, type ExecutionPositionGroup, type ExecutionPositionsQuery, type GetBalanceQuery, type GetBalanceResponse, type GetHoldingsQuery, type GetHoldingsResponse, type GetOrdersParams, type GetOrdersQuery, type GetPositionsParams, type GetPositionsQuery, type HelloResponse, IMAGE_SIZES, ImageSize, type MarkSource, type MarketPriceHistory, MarketStatus, MatchStatus, MatchType, type MatchedMidpoint, type MatchedMidpointOutcome, type MatchedOrderbookMarket, type MatchedVenueMarketOutcomeRef, type MatchingReport, type MidpointItem, type MidpointRow, type NonceResponse, type OrderListItem, type OrderListQuery, OrderStatus, type Orderbook, type OrderbookBatchItemError, type OrderbookBatchItemErrorCode, type OrderbookBatchItemStatus, type OrderbookHistoryPoint, type OrderbookHistoryResponse, type OrderbookLevel, type OrderbookQuoteFill, type OrderbookQuoteParams, type OrderbookQuoteResponse, type OrderbookServiceUnavailableError, type OrderbookState, type OrderbooksOnlyError, type OutcomeMidpoint, type OutcomeMidpointRow, type OutcomeOrderbookResponse, type PaginatedResponse, type PersistedAuthSnapshot, type PositionGroup, type PositionRedeemStatus, type PricePoint, type PriceSource, type PricesHistoryResponse, type QuoteManagedParams, type QuoteManagedRequest, type QuoteManagedResponse, type QuoteManagedSplit, type QuoteManagedStep, type QuoteSplit, type QuoteStep, type RampQuote, type RampQuoteRequest, type RampSessionRequest, type RampWidgetSession, type RedeemLegResult, type RedeemLegStatus, type RedeemRequest, type RedeemResponse, type RequestedOrderbookMarket, type ResolveCorrelatedMarketsParams, type ResolveCorrelatedMarketsResponse, type ResolvedCorrelatedMarketsResponse, type SafeParseFailure, type SafeParseResult, type SafeParseSuccess, type ServerWallet, type SettlementSource, type SetupDepositAddressStep, type SetupVenueKeyStep, type SimpleOrderbookLevel, type SmartRouteAllocation, type SmartRouteBridgeStep, type SmartRouteFeeBreakdown, type SmartRouteFill, type SmartRouteParams, type SmartRouteResponse, type SmartRouteSetupCostLine, type SmartRouteSide, type SmartRouteStatus, type SmartRouteVenueFill, type SplitsByAmountResult, type SyncBalancesResponse, type TradeExecutorOrder, type TradeExecutorOrderListResponse, TradeSide$1 as TradeSide, type TradeSplit, type TradeStep, TurnstileChallengeError, type UnifiedBalanceResponse, type UpdateUserBody, type UpsertVenueKey, type UserActivityBridge, type UserActivityDeposit, type UserActivityItem, type UserActivityQuery, type UserActivityRedeem, type UserActivityRedeemLeg, type UserActivityTrade, type UserActivityType, type UserActivityUserOp, type UserActivityWithdrawal, type UserHolding, type UserProfile, VENUES, type ValidateBalanceOnClientStep, type ValidateManagedParams, type ValidateManagedRequest, type ValidateManagedResponse, type ValidateTradeRequest, type ValidateTradeResponse, Venue, type VenueEvent, type VenueEventListItem, type VenueEventWithMarkets, type VenueKeySummary, type VenueMarket, type VenueMarketClusterNode, type VenueMarketListItem, type VenueMarketOutcome, type VenueMarketRef, type VenueOrderbookEntry, type VenueOrderbookLevel, type VenuePositionBalance, type VenuePriceInfo, type VenueSoloQuote, type VerifyBody, type VerifyResponse, type WalletChainBalance, type WalletTokenBalance, type WithdrawManagedParams, type WithdrawManagedRequest, type WithdrawManagedResponse, type WithdrawManagedSourceItem, type WithdrawTokenSymbol, type WithdrawalExpected, type WithdrawalLeg, type WithdrawalLegStatus, type WithdrawalLegType, type WithdrawalLifecycleStatus, type WithdrawalSource, type WithdrawalSourceItem, type WithdrawalSourceStatus, type WsAttributedLevel, type WsAuthenticated, type WsBalanceUpdate, type WsCandleInterval, type WsClientMessage, type WsConnected, type WsError, type WsHeartbeat, type WsMarkSource, type WsMarketResolved, type WsOrderEvent, type WsOrderEventType, type WsOrderSubmitted, type WsOrderbookDelta, type WsOrderbookSnapshot, type WsRedeemEvent, type WsServerMessage, type WsSubscribed, type WsTrade, type WsUnsubscribed, type WsVenueBook, type WsVenueInfo, type WsVenueLevel, type WsWithdrawalLegStatus, type WsWithdrawalLifecycleEvent, type WsWithdrawalLifecycleLeg, type WsWithdrawalLifecycleStatus, aggregateMidpoint, applyOrderbookDelta, buildVenueUrl, computeBestSplitsByAmount, computeChecksum, createAggClient, enumGuard, formatMarketQuestion, formatOutcomeLabel, formatOutcomeTitle, getWalletAddressFromUserProfile, hasShape, isEmail, isEnum, isFiniteNonNeg, isNonEmptyString, mergeCandles, mergeClosedCandles, normalizeVenueMarketCluster, optimizedImageUrl, parse, parseEmail, parseEmailStrict, safeParse, snapshotToOrderbook, sortVenues };
|
package/dist/index.d.ts
CHANGED
|
@@ -375,7 +375,9 @@ type WalletChainBalance = {
|
|
|
375
375
|
chainId: number;
|
|
376
376
|
tokenAddress: string;
|
|
377
377
|
balanceRaw: string;
|
|
378
|
+
decimals: number;
|
|
378
379
|
lastSyncedAt: string;
|
|
380
|
+
tokenSymbol?: string | undefined;
|
|
379
381
|
};
|
|
380
382
|
type WalletTokenBalance = {
|
|
381
383
|
tokenSymbol: string;
|
|
@@ -2093,6 +2095,7 @@ interface ExecuteManagedParams {
|
|
|
2093
2095
|
side: "buy" | "sell";
|
|
2094
2096
|
maxSpend?: number;
|
|
2095
2097
|
sellShares?: number;
|
|
2098
|
+
allowedVenues?: Venue[];
|
|
2096
2099
|
};
|
|
2097
2100
|
}
|
|
2098
2101
|
interface ExecuteManagedResponse {
|
|
@@ -2154,8 +2157,9 @@ interface WithdrawManagedSourceItem {
|
|
|
2154
2157
|
bridgeOperationId: string | null;
|
|
2155
2158
|
}
|
|
2156
2159
|
/**
|
|
2157
|
-
* `pricingStatus === "
|
|
2158
|
-
*
|
|
2160
|
+
* `pricingStatus === "quoted"` means the response includes a fresh preflight
|
|
2161
|
+
* quote; other states may carry null `expected.*` fields. Do NOT treat null
|
|
2162
|
+
* fields as missing.
|
|
2159
2163
|
*/
|
|
2160
2164
|
interface WithdrawalExpected {
|
|
2161
2165
|
outputRaw: string | null;
|
|
@@ -2181,7 +2185,7 @@ interface WithdrawManagedResponse {
|
|
|
2181
2185
|
};
|
|
2182
2186
|
legs: WithdrawalLeg[];
|
|
2183
2187
|
expected: WithdrawalExpected;
|
|
2184
|
-
pricingStatus: "unquoted" | "quoted";
|
|
2188
|
+
pricingStatus: "unquoted" | "quoting" | "quoted" | "unviable";
|
|
2185
2189
|
/**
|
|
2186
2190
|
* Persisted terminal-state error reason. Always `null` until the
|
|
2187
2191
|
* withdrawal reaches `failed` / `partial`. The submit response always
|
|
@@ -2246,7 +2250,7 @@ type ExecutionOrdersQuery = GetOrdersQuery;
|
|
|
2246
2250
|
type ExecutionOrderItem = OrderListItem;
|
|
2247
2251
|
type ExecutionPositionsQuery = GetPositionsQuery;
|
|
2248
2252
|
type ExecutionPositionGroup = PositionGroup;
|
|
2249
|
-
type UserActivityType = "trade" | "withdrawal" | "bridge" | "deposit" | "user_op";
|
|
2253
|
+
type UserActivityType = "trade" | "withdrawal" | "bridge" | "deposit" | "user_op" | "redeem";
|
|
2250
2254
|
interface UserActivityBase {
|
|
2251
2255
|
id: string;
|
|
2252
2256
|
createdAt: string;
|
|
@@ -2315,7 +2319,25 @@ interface UserActivityUserOp extends UserActivityBase {
|
|
|
2315
2319
|
txHash: string | null;
|
|
2316
2320
|
confirmedAt: string | null;
|
|
2317
2321
|
}
|
|
2318
|
-
|
|
2322
|
+
interface UserActivityRedeemLeg {
|
|
2323
|
+
id: string;
|
|
2324
|
+
venueMarketOutcomeId: string;
|
|
2325
|
+
venue: string;
|
|
2326
|
+
status: string;
|
|
2327
|
+
chainId: string;
|
|
2328
|
+
payoutTokenSymbol: string;
|
|
2329
|
+
payoutAmountRaw: string | null;
|
|
2330
|
+
txHash: string | null;
|
|
2331
|
+
errorMessage: string | null;
|
|
2332
|
+
venueMarket: UserActivityVenueMarket | null;
|
|
2333
|
+
venueMarketOutcome: Omit<UserActivityVenueMarketOutcome, "price"> | null;
|
|
2334
|
+
}
|
|
2335
|
+
interface UserActivityRedeem extends UserActivityBase {
|
|
2336
|
+
type: "redeem";
|
|
2337
|
+
totalPayoutRaw: string | null;
|
|
2338
|
+
legs: UserActivityRedeemLeg[];
|
|
2339
|
+
}
|
|
2340
|
+
type UserActivityItem = UserActivityTrade | UserActivityWithdrawal | UserActivityBridge | UserActivityDeposit | UserActivityUserOp | UserActivityRedeem;
|
|
2319
2341
|
interface UserActivityQuery {
|
|
2320
2342
|
type?: UserActivityType;
|
|
2321
2343
|
cursor?: string;
|
|
@@ -2378,6 +2400,23 @@ interface SmartRouteVenueFill {
|
|
|
2378
2400
|
fills: SmartRouteFill[];
|
|
2379
2401
|
venueQty: number;
|
|
2380
2402
|
}
|
|
2403
|
+
interface SmartRouteAllocation {
|
|
2404
|
+
sourceChainId: string;
|
|
2405
|
+
venue: string;
|
|
2406
|
+
amount: number;
|
|
2407
|
+
sourceTokenAddress?: string;
|
|
2408
|
+
custodyKind?: "EOA" | "DEPOSIT_WALLET";
|
|
2409
|
+
custodyAddress?: string;
|
|
2410
|
+
exactToken?: boolean;
|
|
2411
|
+
}
|
|
2412
|
+
interface SmartRouteBridgeStep {
|
|
2413
|
+
sourceChainId: string;
|
|
2414
|
+
destChainId: string;
|
|
2415
|
+
amount: number;
|
|
2416
|
+
cost: number;
|
|
2417
|
+
sourceTokenAddress?: string;
|
|
2418
|
+
destTokenAddress?: string;
|
|
2419
|
+
}
|
|
2381
2420
|
interface VenueSoloQuote {
|
|
2382
2421
|
/**
|
|
2383
2422
|
* Minted by the API per successful + executable solo; send this to
|
|
@@ -2396,6 +2435,8 @@ interface VenueSoloQuote {
|
|
|
2396
2435
|
status: string;
|
|
2397
2436
|
/** Per-price-level fills, identical shape to primary fills. Empty for non-ok statuses. */
|
|
2398
2437
|
fills: SmartRouteVenueFill[];
|
|
2438
|
+
allocations?: SmartRouteAllocation[];
|
|
2439
|
+
bridgeSteps?: SmartRouteBridgeStep[];
|
|
2399
2440
|
/**
|
|
2400
2441
|
* One-time setup costs for this solo's chosen venue + market. Populated
|
|
2401
2442
|
* only when the originating quote opted in via `deepEstimate=true`; absent
|
|
@@ -2429,6 +2470,8 @@ interface SmartRouteParams {
|
|
|
2429
2470
|
chainBalances?: Record<string, number>;
|
|
2430
2471
|
slipCapBps?: number;
|
|
2431
2472
|
compareVenues?: boolean;
|
|
2473
|
+
/** Restrict this quote to one or more executable venues. */
|
|
2474
|
+
allowedVenues?: Venue[];
|
|
2432
2475
|
/**
|
|
2433
2476
|
* Opt in to the deep cost-estimate surface. When `true`, the response
|
|
2434
2477
|
* `feeBreakdown` includes `setupCosts` (one-time chain approvals + Kalshi
|
|
@@ -2526,6 +2569,8 @@ interface SmartRouteResponse {
|
|
|
2526
2569
|
reason: string;
|
|
2527
2570
|
}>;
|
|
2528
2571
|
venueSoloQuotes?: VenueSoloQuote[];
|
|
2572
|
+
allocations?: SmartRouteAllocation[];
|
|
2573
|
+
bridgeSteps?: SmartRouteBridgeStep[];
|
|
2529
2574
|
/** Estimated payout if the outcome wins (= totalFilled shares × $1). */
|
|
2530
2575
|
estimatedPayout?: number;
|
|
2531
2576
|
/** Total cost including all fees (rawExecCost + venueFees + bridgeFees +
|
|
@@ -2860,6 +2905,7 @@ declare class AggClient {
|
|
|
2860
2905
|
status?: MarketStatus[];
|
|
2861
2906
|
sortBy?: string;
|
|
2862
2907
|
sortDir?: string;
|
|
2908
|
+
recurrence?: string;
|
|
2863
2909
|
limit?: number;
|
|
2864
2910
|
cursor?: string;
|
|
2865
2911
|
minYesPrice?: number;
|
|
@@ -2888,6 +2934,7 @@ declare class AggClient {
|
|
|
2888
2934
|
getCategories(options?: {
|
|
2889
2935
|
limit?: number;
|
|
2890
2936
|
cursor?: string;
|
|
2937
|
+
parentId?: string;
|
|
2891
2938
|
}): Promise<PaginatedResponse<Category>>;
|
|
2892
2939
|
/** Get per-app UI config (disabled venues + category presets). Requires appId. */
|
|
2893
2940
|
getAppConfig(init?: RequestInit): Promise<AppClientConfigResponse>;
|
|
@@ -3094,4 +3141,4 @@ declare function aggregateMidpoint(midpoints: (number | null | undefined)[]): nu
|
|
|
3094
3141
|
|
|
3095
3142
|
declare function createAggClient(options: AggClientOptions): AggClient;
|
|
3096
3143
|
|
|
3097
|
-
export { type Account, AccountProvider, AccountType, type AggAuthDeliveryMode, type AggAuthProviderType, type AggAuthStartBody, type AggAuthStartResult, type AggAuthVerifyBody, AggClient, type AggClientAuthOptions, type AggClientSessionInput, type AggLinkAccountBody, type AggLinkAccountConfirmResult, type AggLinkAccountResult, type AggSessionUser, AggWebSocket, type AggWebSocketCallbacks, type AggWebSocketOptions, type AggregatedOrderbookLevel, type AggregatedOrderbookResponse, type App, type AppClientConfigResponse, type AttributedOrderbook, type AttributedOrderbookLevel, type AuthCodeResponse, type AuthStatus, type AuthTokenResponse, type AuthUser, type BatchMidpointsResponse, type BatchOrderbooksResponse, type BuildVenueUrlOpts, CONFIRMED_MATCH_STATUSES, type CancelManagedExecutionResponse, type Candle, CandleBuilder, type CandleInterval, type Category, Chain, type ChartBarsResponse, type ChartCandle, type ChartResolution, type ChartVenueCandles, type ComputeSplitsRequest, type ComputeSplitsResponse, type ComputeSplitsSelection, type CorrelatedMarketCascadeItem, type CorrelatedMarketCascadeResponse, type CorrelatedMarketQueryResult, type CorrelatedMarketSide, type CorrelatedMarketSignal, type CorrelatedMarketSignalBatch, type CorrelatedMarketSignalDirection, type CorrelatedMarketsStatus, type CreateApp, type DepositAddressesPendingResponse, type DepositAddressesReadyResponse, type DepositAddressesResponse, type DepositAddressesSupportedChain, type DepositAddressesToken, type DepositStep, type DiagnosticCallback, type DiagnosticEvent, type ExecuteManagedParams, type ExecuteManagedRequest, type ExecuteManagedResponse, type ExecuteTradeRequest, type ExecuteTradeResponse, type ExecutionOrderItem, type ExecutionOrdersQuery, type ExecutionPositionGroup, type ExecutionPositionsQuery, type GetBalanceQuery, type GetBalanceResponse, type GetHoldingsQuery, type GetHoldingsResponse, type GetOrdersParams, type GetOrdersQuery, type GetPositionsParams, type GetPositionsQuery, type HelloResponse, IMAGE_SIZES, ImageSize, type MarkSource, type MarketPriceHistory, MarketStatus, MatchStatus, MatchType, type MatchedMidpoint, type MatchedMidpointOutcome, type MatchedOrderbookMarket, type MatchedVenueMarketOutcomeRef, type MatchingReport, type MidpointItem, type MidpointRow, type NonceResponse, type OrderListItem, type OrderListQuery, OrderStatus, type Orderbook, type OrderbookBatchItemError, type OrderbookBatchItemErrorCode, type OrderbookBatchItemStatus, type OrderbookHistoryPoint, type OrderbookHistoryResponse, type OrderbookLevel, type OrderbookQuoteFill, type OrderbookQuoteParams, type OrderbookQuoteResponse, type OrderbookServiceUnavailableError, type OrderbookState, type OrderbooksOnlyError, type OutcomeMidpoint, type OutcomeMidpointRow, type OutcomeOrderbookResponse, type PaginatedResponse, type PersistedAuthSnapshot, type PositionGroup, type PositionRedeemStatus, type PricePoint, type PriceSource, type PricesHistoryResponse, type QuoteManagedParams, type QuoteManagedRequest, type QuoteManagedResponse, type QuoteManagedSplit, type QuoteManagedStep, type QuoteSplit, type QuoteStep, type RampQuote, type RampQuoteRequest, type RampSessionRequest, type RampWidgetSession, type RedeemLegResult, type RedeemLegStatus, type RedeemRequest, type RedeemResponse, type RequestedOrderbookMarket, type ResolveCorrelatedMarketsParams, type ResolveCorrelatedMarketsResponse, type ResolvedCorrelatedMarketsResponse, type SafeParseFailure, type SafeParseResult, type SafeParseSuccess, type ServerWallet, type SettlementSource, type SetupDepositAddressStep, type SetupVenueKeyStep, type SimpleOrderbookLevel, type SmartRouteFeeBreakdown, type SmartRouteFill, type SmartRouteParams, type SmartRouteResponse, type SmartRouteSetupCostLine, type SmartRouteSide, type SmartRouteStatus, type SmartRouteVenueFill, type SplitsByAmountResult, type SyncBalancesResponse, type TradeExecutorOrder, type TradeExecutorOrderListResponse, TradeSide$1 as TradeSide, type TradeSplit, type TradeStep, TurnstileChallengeError, type UnifiedBalanceResponse, type UpdateUserBody, type UpsertVenueKey, type UserActivityBridge, type UserActivityDeposit, type UserActivityItem, type UserActivityQuery, type UserActivityTrade, type UserActivityType, type UserActivityUserOp, type UserActivityWithdrawal, type UserHolding, type UserProfile, VENUES, type ValidateBalanceOnClientStep, type ValidateManagedParams, type ValidateManagedRequest, type ValidateManagedResponse, type ValidateTradeRequest, type ValidateTradeResponse, Venue, type VenueEvent, type VenueEventListItem, type VenueEventWithMarkets, type VenueKeySummary, type VenueMarket, type VenueMarketClusterNode, type VenueMarketListItem, type VenueMarketOutcome, type VenueMarketRef, type VenueOrderbookEntry, type VenueOrderbookLevel, type VenuePositionBalance, type VenuePriceInfo, type VenueSoloQuote, type VerifyBody, type VerifyResponse, type WalletChainBalance, type WalletTokenBalance, type WithdrawManagedParams, type WithdrawManagedRequest, type WithdrawManagedResponse, type WithdrawManagedSourceItem, type WithdrawTokenSymbol, type WithdrawalExpected, type WithdrawalLeg, type WithdrawalLegStatus, type WithdrawalLegType, type WithdrawalLifecycleStatus, type WithdrawalSource, type WithdrawalSourceItem, type WithdrawalSourceStatus, type WsAttributedLevel, type WsAuthenticated, type WsBalanceUpdate, type WsCandleInterval, type WsClientMessage, type WsConnected, type WsError, type WsHeartbeat, type WsMarkSource, type WsMarketResolved, type WsOrderEvent, type WsOrderEventType, type WsOrderSubmitted, type WsOrderbookDelta, type WsOrderbookSnapshot, type WsRedeemEvent, type WsServerMessage, type WsSubscribed, type WsTrade, type WsUnsubscribed, type WsVenueBook, type WsVenueInfo, type WsVenueLevel, type WsWithdrawalLegStatus, type WsWithdrawalLifecycleEvent, type WsWithdrawalLifecycleLeg, type WsWithdrawalLifecycleStatus, aggregateMidpoint, applyOrderbookDelta, buildVenueUrl, computeBestSplitsByAmount, computeChecksum, createAggClient, enumGuard, formatMarketQuestion, formatOutcomeLabel, formatOutcomeTitle, getWalletAddressFromUserProfile, hasShape, isEmail, isEnum, isFiniteNonNeg, isNonEmptyString, mergeCandles, mergeClosedCandles, normalizeVenueMarketCluster, optimizedImageUrl, parse, parseEmail, parseEmailStrict, safeParse, snapshotToOrderbook, sortVenues };
|
|
3144
|
+
export { type Account, AccountProvider, AccountType, type AggAuthDeliveryMode, type AggAuthProviderType, type AggAuthStartBody, type AggAuthStartResult, type AggAuthVerifyBody, AggClient, type AggClientAuthOptions, type AggClientSessionInput, type AggLinkAccountBody, type AggLinkAccountConfirmResult, type AggLinkAccountResult, type AggSessionUser, AggWebSocket, type AggWebSocketCallbacks, type AggWebSocketOptions, type AggregatedOrderbookLevel, type AggregatedOrderbookResponse, type App, type AppClientConfigResponse, type AttributedOrderbook, type AttributedOrderbookLevel, type AuthCodeResponse, type AuthStatus, type AuthTokenResponse, type AuthUser, type BatchMidpointsResponse, type BatchOrderbooksResponse, type BuildVenueUrlOpts, CONFIRMED_MATCH_STATUSES, type CancelManagedExecutionResponse, type Candle, CandleBuilder, type CandleInterval, type Category, Chain, type ChartBarsResponse, type ChartCandle, type ChartResolution, type ChartVenueCandles, type ComputeSplitsRequest, type ComputeSplitsResponse, type ComputeSplitsSelection, type CorrelatedMarketCascadeItem, type CorrelatedMarketCascadeResponse, type CorrelatedMarketQueryResult, type CorrelatedMarketSide, type CorrelatedMarketSignal, type CorrelatedMarketSignalBatch, type CorrelatedMarketSignalDirection, type CorrelatedMarketsStatus, type CreateApp, type DepositAddressesPendingResponse, type DepositAddressesReadyResponse, type DepositAddressesResponse, type DepositAddressesSupportedChain, type DepositAddressesToken, type DepositStep, type DiagnosticCallback, type DiagnosticEvent, type ExecuteManagedParams, type ExecuteManagedRequest, type ExecuteManagedResponse, type ExecuteTradeRequest, type ExecuteTradeResponse, type ExecutionOrderItem, type ExecutionOrdersQuery, type ExecutionPositionGroup, type ExecutionPositionsQuery, type GetBalanceQuery, type GetBalanceResponse, type GetHoldingsQuery, type GetHoldingsResponse, type GetOrdersParams, type GetOrdersQuery, type GetPositionsParams, type GetPositionsQuery, type HelloResponse, IMAGE_SIZES, ImageSize, type MarkSource, type MarketPriceHistory, MarketStatus, MatchStatus, MatchType, type MatchedMidpoint, type MatchedMidpointOutcome, type MatchedOrderbookMarket, type MatchedVenueMarketOutcomeRef, type MatchingReport, type MidpointItem, type MidpointRow, type NonceResponse, type OrderListItem, type OrderListQuery, OrderStatus, type Orderbook, type OrderbookBatchItemError, type OrderbookBatchItemErrorCode, type OrderbookBatchItemStatus, type OrderbookHistoryPoint, type OrderbookHistoryResponse, type OrderbookLevel, type OrderbookQuoteFill, type OrderbookQuoteParams, type OrderbookQuoteResponse, type OrderbookServiceUnavailableError, type OrderbookState, type OrderbooksOnlyError, type OutcomeMidpoint, type OutcomeMidpointRow, type OutcomeOrderbookResponse, type PaginatedResponse, type PersistedAuthSnapshot, type PositionGroup, type PositionRedeemStatus, type PricePoint, type PriceSource, type PricesHistoryResponse, type QuoteManagedParams, type QuoteManagedRequest, type QuoteManagedResponse, type QuoteManagedSplit, type QuoteManagedStep, type QuoteSplit, type QuoteStep, type RampQuote, type RampQuoteRequest, type RampSessionRequest, type RampWidgetSession, type RedeemLegResult, type RedeemLegStatus, type RedeemRequest, type RedeemResponse, type RequestedOrderbookMarket, type ResolveCorrelatedMarketsParams, type ResolveCorrelatedMarketsResponse, type ResolvedCorrelatedMarketsResponse, type SafeParseFailure, type SafeParseResult, type SafeParseSuccess, type ServerWallet, type SettlementSource, type SetupDepositAddressStep, type SetupVenueKeyStep, type SimpleOrderbookLevel, type SmartRouteAllocation, type SmartRouteBridgeStep, type SmartRouteFeeBreakdown, type SmartRouteFill, type SmartRouteParams, type SmartRouteResponse, type SmartRouteSetupCostLine, type SmartRouteSide, type SmartRouteStatus, type SmartRouteVenueFill, type SplitsByAmountResult, type SyncBalancesResponse, type TradeExecutorOrder, type TradeExecutorOrderListResponse, TradeSide$1 as TradeSide, type TradeSplit, type TradeStep, TurnstileChallengeError, type UnifiedBalanceResponse, type UpdateUserBody, type UpsertVenueKey, type UserActivityBridge, type UserActivityDeposit, type UserActivityItem, type UserActivityQuery, type UserActivityRedeem, type UserActivityRedeemLeg, type UserActivityTrade, type UserActivityType, type UserActivityUserOp, type UserActivityWithdrawal, type UserHolding, type UserProfile, VENUES, type ValidateBalanceOnClientStep, type ValidateManagedParams, type ValidateManagedRequest, type ValidateManagedResponse, type ValidateTradeRequest, type ValidateTradeResponse, Venue, type VenueEvent, type VenueEventListItem, type VenueEventWithMarkets, type VenueKeySummary, type VenueMarket, type VenueMarketClusterNode, type VenueMarketListItem, type VenueMarketOutcome, type VenueMarketRef, type VenueOrderbookEntry, type VenueOrderbookLevel, type VenuePositionBalance, type VenuePriceInfo, type VenueSoloQuote, type VerifyBody, type VerifyResponse, type WalletChainBalance, type WalletTokenBalance, type WithdrawManagedParams, type WithdrawManagedRequest, type WithdrawManagedResponse, type WithdrawManagedSourceItem, type WithdrawTokenSymbol, type WithdrawalExpected, type WithdrawalLeg, type WithdrawalLegStatus, type WithdrawalLegType, type WithdrawalLifecycleStatus, type WithdrawalSource, type WithdrawalSourceItem, type WithdrawalSourceStatus, type WsAttributedLevel, type WsAuthenticated, type WsBalanceUpdate, type WsCandleInterval, type WsClientMessage, type WsConnected, type WsError, type WsHeartbeat, type WsMarkSource, type WsMarketResolved, type WsOrderEvent, type WsOrderEventType, type WsOrderSubmitted, type WsOrderbookDelta, type WsOrderbookSnapshot, type WsRedeemEvent, type WsServerMessage, type WsSubscribed, type WsTrade, type WsUnsubscribed, type WsVenueBook, type WsVenueInfo, type WsVenueLevel, type WsWithdrawalLegStatus, type WsWithdrawalLifecycleEvent, type WsWithdrawalLifecycleLeg, type WsWithdrawalLifecycleStatus, aggregateMidpoint, applyOrderbookDelta, buildVenueUrl, computeBestSplitsByAmount, computeChecksum, createAggClient, enumGuard, formatMarketQuestion, formatOutcomeLabel, formatOutcomeTitle, getWalletAddressFromUserProfile, hasShape, isEmail, isEnum, isFiniteNonNeg, isNonEmptyString, mergeCandles, mergeClosedCandles, normalizeVenueMarketCluster, optimizedImageUrl, parse, parseEmail, parseEmailStrict, safeParse, snapshotToOrderbook, sortVenues };
|
package/dist/index.js
CHANGED
|
@@ -2156,6 +2156,7 @@ Issued At: ${issuedAt}`;
|
|
|
2156
2156
|
if ((options == null ? void 0 : options.status) && options.status.length > 0) query.status = options.status;
|
|
2157
2157
|
if (options == null ? void 0 : options.sortBy) query.sortBy = options.sortBy;
|
|
2158
2158
|
if (options == null ? void 0 : options.sortDir) query.sortDir = options.sortDir;
|
|
2159
|
+
if (options == null ? void 0 : options.recurrence) query.recurrence = options.recurrence;
|
|
2159
2160
|
if ((options == null ? void 0 : options.limit) != null) query.limit = String(options.limit);
|
|
2160
2161
|
if (options == null ? void 0 : options.cursor) query.cursor = options.cursor;
|
|
2161
2162
|
if ((options == null ? void 0 : options.minYesPrice) != null) query.minYesPrice = String(options.minYesPrice);
|
|
@@ -2201,6 +2202,7 @@ Issued At: ${issuedAt}`;
|
|
|
2201
2202
|
const query = {};
|
|
2202
2203
|
if ((options == null ? void 0 : options.limit) != null) query.limit = String(options.limit);
|
|
2203
2204
|
if (options == null ? void 0 : options.cursor) query.cursor = options.cursor;
|
|
2205
|
+
if (options == null ? void 0 : options.parentId) query.parentId = options.parentId;
|
|
2204
2206
|
return this.request("/categories", {
|
|
2205
2207
|
query: Object.keys(query).length > 0 ? query : void 0
|
|
2206
2208
|
});
|
|
@@ -2358,7 +2360,7 @@ Issued At: ${issuedAt}`;
|
|
|
2358
2360
|
*/
|
|
2359
2361
|
getSmartRoute(params, options) {
|
|
2360
2362
|
return __async(this, null, function* () {
|
|
2361
|
-
var _a, _b;
|
|
2363
|
+
var _a, _b, _c;
|
|
2362
2364
|
const venueMarketOutcomeId = (_b = (_a = params.venueMarketOutcomeId) != null ? _a : params.venueMarketId) != null ? _b : params.outcomeId;
|
|
2363
2365
|
if (!venueMarketOutcomeId) {
|
|
2364
2366
|
throw new Error("getSmartRoute requires venueMarketOutcomeId");
|
|
@@ -2369,6 +2371,7 @@ Issued At: ${issuedAt}`;
|
|
|
2369
2371
|
if (params.chainBalances) query.chainBalances = JSON.stringify(params.chainBalances);
|
|
2370
2372
|
if (params.slipCapBps != null) query.slipCapBps = String(params.slipCapBps);
|
|
2371
2373
|
if (params.compareVenues) query.compareVenues = "true";
|
|
2374
|
+
if ((_c = params.allowedVenues) == null ? void 0 : _c.length) query.allowedVenues = params.allowedVenues.map(String);
|
|
2372
2375
|
if (params.tradeSide) query.side = params.tradeSide;
|
|
2373
2376
|
if (params.deepEstimate) query.deepEstimate = "true";
|
|
2374
2377
|
const response = yield this.request(
|
package/dist/index.mjs
CHANGED
|
@@ -2057,6 +2057,7 @@ Issued At: ${issuedAt}`;
|
|
|
2057
2057
|
if ((options == null ? void 0 : options.status) && options.status.length > 0) query.status = options.status;
|
|
2058
2058
|
if (options == null ? void 0 : options.sortBy) query.sortBy = options.sortBy;
|
|
2059
2059
|
if (options == null ? void 0 : options.sortDir) query.sortDir = options.sortDir;
|
|
2060
|
+
if (options == null ? void 0 : options.recurrence) query.recurrence = options.recurrence;
|
|
2060
2061
|
if ((options == null ? void 0 : options.limit) != null) query.limit = String(options.limit);
|
|
2061
2062
|
if (options == null ? void 0 : options.cursor) query.cursor = options.cursor;
|
|
2062
2063
|
if ((options == null ? void 0 : options.minYesPrice) != null) query.minYesPrice = String(options.minYesPrice);
|
|
@@ -2102,6 +2103,7 @@ Issued At: ${issuedAt}`;
|
|
|
2102
2103
|
const query = {};
|
|
2103
2104
|
if ((options == null ? void 0 : options.limit) != null) query.limit = String(options.limit);
|
|
2104
2105
|
if (options == null ? void 0 : options.cursor) query.cursor = options.cursor;
|
|
2106
|
+
if (options == null ? void 0 : options.parentId) query.parentId = options.parentId;
|
|
2105
2107
|
return this.request("/categories", {
|
|
2106
2108
|
query: Object.keys(query).length > 0 ? query : void 0
|
|
2107
2109
|
});
|
|
@@ -2259,7 +2261,7 @@ Issued At: ${issuedAt}`;
|
|
|
2259
2261
|
*/
|
|
2260
2262
|
getSmartRoute(params, options) {
|
|
2261
2263
|
return __async(this, null, function* () {
|
|
2262
|
-
var _a, _b;
|
|
2264
|
+
var _a, _b, _c;
|
|
2263
2265
|
const venueMarketOutcomeId = (_b = (_a = params.venueMarketOutcomeId) != null ? _a : params.venueMarketId) != null ? _b : params.outcomeId;
|
|
2264
2266
|
if (!venueMarketOutcomeId) {
|
|
2265
2267
|
throw new Error("getSmartRoute requires venueMarketOutcomeId");
|
|
@@ -2270,6 +2272,7 @@ Issued At: ${issuedAt}`;
|
|
|
2270
2272
|
if (params.chainBalances) query.chainBalances = JSON.stringify(params.chainBalances);
|
|
2271
2273
|
if (params.slipCapBps != null) query.slipCapBps = String(params.slipCapBps);
|
|
2272
2274
|
if (params.compareVenues) query.compareVenues = "true";
|
|
2275
|
+
if ((_c = params.allowedVenues) == null ? void 0 : _c.length) query.allowedVenues = params.allowedVenues.map(String);
|
|
2273
2276
|
if (params.tradeSide) query.side = params.tradeSide;
|
|
2274
2277
|
if (params.deepEstimate) query.deepEstimate = "true";
|
|
2275
2278
|
const response = yield this.request(
|
package/dist/server.d.mts
CHANGED
|
@@ -12,6 +12,16 @@ interface VerifyWebhookOptions {
|
|
|
12
12
|
}
|
|
13
13
|
declare function verifyWebhook(payload: string, headers: Record<string, string | string[] | undefined>, secret: string, options?: VerifyWebhookOptions): void;
|
|
14
14
|
declare function parseWebhookEvent(payload: string, headers: Record<string, string | string[] | undefined>, secret: string, options?: VerifyWebhookOptions): WebhookEvent;
|
|
15
|
+
/**
|
|
16
|
+
* Async, edge-runtime-friendly variant of {@link verifyWebhook}. Same
|
|
17
|
+
* Svix v1 signing scheme. Use this in Cloudflare Workers / Vercel Edge /
|
|
18
|
+
* Deno / Bun. The sync variant remains available for Node.js consumers.
|
|
19
|
+
*/
|
|
20
|
+
declare function verifyWebhookAsync(payload: string, headers: Record<string, string | string[] | undefined>, secret: string, options?: VerifyWebhookOptions): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Async, edge-runtime-friendly variant of {@link parseWebhookEvent}.
|
|
23
|
+
*/
|
|
24
|
+
declare function parseWebhookEventAsync(payload: string, headers: Record<string, string | string[] | undefined>, secret: string, options?: VerifyWebhookOptions): Promise<WebhookEvent>;
|
|
15
25
|
interface WebhookEventBase {
|
|
16
26
|
id: string;
|
|
17
27
|
createdAt: string;
|
|
@@ -21,6 +31,8 @@ interface AccountsCreatedEvent extends WebhookEventBase {
|
|
|
21
31
|
data: {
|
|
22
32
|
userId: string;
|
|
23
33
|
appId: string;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
email: string | null;
|
|
24
36
|
};
|
|
25
37
|
}
|
|
26
38
|
interface AccountsLinkedEvent extends WebhookEventBase {
|
|
@@ -37,6 +49,7 @@ interface WalletsReadyEvent extends WebhookEventBase {
|
|
|
37
49
|
userId: string;
|
|
38
50
|
evmAddress: string;
|
|
39
51
|
svmAddress: string;
|
|
52
|
+
createdAt: string;
|
|
40
53
|
};
|
|
41
54
|
}
|
|
42
55
|
interface TradesPlacedEvent extends WebhookEventBase {
|
|
@@ -45,8 +58,16 @@ interface TradesPlacedEvent extends WebhookEventBase {
|
|
|
45
58
|
orderId: string;
|
|
46
59
|
userId: string;
|
|
47
60
|
side: string;
|
|
48
|
-
|
|
49
|
-
|
|
61
|
+
timestamp: string;
|
|
62
|
+
/**
|
|
63
|
+
* @deprecated Never emitted by the server in 1.x — the SDK type lied
|
|
64
|
+
* here for several releases. Reads always return `undefined`. The field
|
|
65
|
+
* is retained as `undefined`-typed for one minor release so existing
|
|
66
|
+
* partner code that destructures it keeps compiling; remove in 2.0.
|
|
67
|
+
*/
|
|
68
|
+
venue?: undefined;
|
|
69
|
+
/** @deprecated See `venue`. */
|
|
70
|
+
venueMarketId?: undefined;
|
|
50
71
|
};
|
|
51
72
|
}
|
|
52
73
|
interface TradesFilledEvent extends WebhookEventBase {
|
|
@@ -55,16 +76,49 @@ interface TradesFilledEvent extends WebhookEventBase {
|
|
|
55
76
|
orderId: string;
|
|
56
77
|
userId: string;
|
|
57
78
|
status: string;
|
|
58
|
-
|
|
59
|
-
|
|
79
|
+
timestamp: string;
|
|
80
|
+
/**
|
|
81
|
+
* Post-execution accuracy data. All `*Raw` values are decimal strings in
|
|
82
|
+
* 6-decimal atomic units. `*PriceRaw` are decimal strings (e.g. "0.5").
|
|
83
|
+
* `partialFillReason` is set only on `status === "partial_fill"`.
|
|
84
|
+
*/
|
|
85
|
+
filledAmountRaw?: string;
|
|
86
|
+
quotedSharesRaw?: string;
|
|
87
|
+
actualSharesRaw?: string;
|
|
88
|
+
quotedToWinRaw?: string;
|
|
89
|
+
actualToWinRaw?: string;
|
|
90
|
+
quotedPriceRaw?: string;
|
|
91
|
+
executionPriceRaw?: string;
|
|
92
|
+
partialFillReason?: string;
|
|
93
|
+
/** @deprecated See `executionPriceRaw` — never emitted; remove in 2.0. */
|
|
94
|
+
fillPrice?: undefined;
|
|
95
|
+
/** @deprecated See `actualSharesRaw` / `filledAmountRaw` — never emitted; remove in 2.0. */
|
|
96
|
+
fillSize?: undefined;
|
|
60
97
|
};
|
|
61
98
|
}
|
|
62
99
|
interface MarketsResolvedEvent extends WebhookEventBase {
|
|
63
100
|
type: "markets.resolved";
|
|
64
101
|
data: {
|
|
65
102
|
venueMarketId: string;
|
|
66
|
-
|
|
103
|
+
externalIdentifier: string;
|
|
104
|
+
status: string;
|
|
105
|
+
outcomes: Array<{
|
|
106
|
+
label: string;
|
|
107
|
+
winner?: boolean;
|
|
108
|
+
externalIdentifier?: string;
|
|
109
|
+
}>;
|
|
67
110
|
affectedUsersCount: number;
|
|
111
|
+
/**
|
|
112
|
+
* Path on the AGG API where this resolution's affected users can be
|
|
113
|
+
* paginated. Combine with the configured base URL — e.g.
|
|
114
|
+
* `https://api.agg.market${detailsPath}`.
|
|
115
|
+
*/
|
|
116
|
+
detailsPath: string;
|
|
117
|
+
/**
|
|
118
|
+
* @deprecated Singular `outcome` was never emitted; use `outcomes` array.
|
|
119
|
+
* Remove in 2.0.
|
|
120
|
+
*/
|
|
121
|
+
outcome?: undefined;
|
|
68
122
|
};
|
|
69
123
|
}
|
|
70
124
|
interface UnknownWebhookEvent extends WebhookEventBase {
|
|
@@ -118,7 +172,9 @@ declare class AggAdminClient {
|
|
|
118
172
|
ordersByStatus: Record<string, number>;
|
|
119
173
|
ordersByVenue: Record<string, number>;
|
|
120
174
|
usersLast30Days: number;
|
|
175
|
+
usersLast7Days: number;
|
|
121
176
|
ordersLast30Days: number;
|
|
177
|
+
ordersLast7Days: number;
|
|
122
178
|
}>;
|
|
123
179
|
listOrders(appId: string, query?: {
|
|
124
180
|
limit?: number;
|
|
@@ -152,4 +208,4 @@ declare class AggAdminClient {
|
|
|
152
208
|
}>;
|
|
153
209
|
}
|
|
154
210
|
|
|
155
|
-
export { type AccountsCreatedEvent, type AccountsLinkedEvent, AggAdminClient, type AggAdminClientOptions, type ExternalIdAssertion, type KnownWebhookEvent, type MarketsResolvedEvent, type TradesFilledEvent, type TradesPlacedEvent, type UnknownWebhookEvent, type VerifyWebhookOptions, type WalletsReadyEvent, type WebhookEvent, WebhookVerificationError, parseWebhookEvent, signExternalId, verifyWebhook };
|
|
211
|
+
export { type AccountsCreatedEvent, type AccountsLinkedEvent, AggAdminClient, type AggAdminClientOptions, type ExternalIdAssertion, type KnownWebhookEvent, type MarketsResolvedEvent, type TradesFilledEvent, type TradesPlacedEvent, type UnknownWebhookEvent, type VerifyWebhookOptions, type WalletsReadyEvent, type WebhookEvent, WebhookVerificationError, parseWebhookEvent, parseWebhookEventAsync, signExternalId, verifyWebhook, verifyWebhookAsync };
|
package/dist/server.d.ts
CHANGED
|
@@ -12,6 +12,16 @@ interface VerifyWebhookOptions {
|
|
|
12
12
|
}
|
|
13
13
|
declare function verifyWebhook(payload: string, headers: Record<string, string | string[] | undefined>, secret: string, options?: VerifyWebhookOptions): void;
|
|
14
14
|
declare function parseWebhookEvent(payload: string, headers: Record<string, string | string[] | undefined>, secret: string, options?: VerifyWebhookOptions): WebhookEvent;
|
|
15
|
+
/**
|
|
16
|
+
* Async, edge-runtime-friendly variant of {@link verifyWebhook}. Same
|
|
17
|
+
* Svix v1 signing scheme. Use this in Cloudflare Workers / Vercel Edge /
|
|
18
|
+
* Deno / Bun. The sync variant remains available for Node.js consumers.
|
|
19
|
+
*/
|
|
20
|
+
declare function verifyWebhookAsync(payload: string, headers: Record<string, string | string[] | undefined>, secret: string, options?: VerifyWebhookOptions): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Async, edge-runtime-friendly variant of {@link parseWebhookEvent}.
|
|
23
|
+
*/
|
|
24
|
+
declare function parseWebhookEventAsync(payload: string, headers: Record<string, string | string[] | undefined>, secret: string, options?: VerifyWebhookOptions): Promise<WebhookEvent>;
|
|
15
25
|
interface WebhookEventBase {
|
|
16
26
|
id: string;
|
|
17
27
|
createdAt: string;
|
|
@@ -21,6 +31,8 @@ interface AccountsCreatedEvent extends WebhookEventBase {
|
|
|
21
31
|
data: {
|
|
22
32
|
userId: string;
|
|
23
33
|
appId: string;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
email: string | null;
|
|
24
36
|
};
|
|
25
37
|
}
|
|
26
38
|
interface AccountsLinkedEvent extends WebhookEventBase {
|
|
@@ -37,6 +49,7 @@ interface WalletsReadyEvent extends WebhookEventBase {
|
|
|
37
49
|
userId: string;
|
|
38
50
|
evmAddress: string;
|
|
39
51
|
svmAddress: string;
|
|
52
|
+
createdAt: string;
|
|
40
53
|
};
|
|
41
54
|
}
|
|
42
55
|
interface TradesPlacedEvent extends WebhookEventBase {
|
|
@@ -45,8 +58,16 @@ interface TradesPlacedEvent extends WebhookEventBase {
|
|
|
45
58
|
orderId: string;
|
|
46
59
|
userId: string;
|
|
47
60
|
side: string;
|
|
48
|
-
|
|
49
|
-
|
|
61
|
+
timestamp: string;
|
|
62
|
+
/**
|
|
63
|
+
* @deprecated Never emitted by the server in 1.x — the SDK type lied
|
|
64
|
+
* here for several releases. Reads always return `undefined`. The field
|
|
65
|
+
* is retained as `undefined`-typed for one minor release so existing
|
|
66
|
+
* partner code that destructures it keeps compiling; remove in 2.0.
|
|
67
|
+
*/
|
|
68
|
+
venue?: undefined;
|
|
69
|
+
/** @deprecated See `venue`. */
|
|
70
|
+
venueMarketId?: undefined;
|
|
50
71
|
};
|
|
51
72
|
}
|
|
52
73
|
interface TradesFilledEvent extends WebhookEventBase {
|
|
@@ -55,16 +76,49 @@ interface TradesFilledEvent extends WebhookEventBase {
|
|
|
55
76
|
orderId: string;
|
|
56
77
|
userId: string;
|
|
57
78
|
status: string;
|
|
58
|
-
|
|
59
|
-
|
|
79
|
+
timestamp: string;
|
|
80
|
+
/**
|
|
81
|
+
* Post-execution accuracy data. All `*Raw` values are decimal strings in
|
|
82
|
+
* 6-decimal atomic units. `*PriceRaw` are decimal strings (e.g. "0.5").
|
|
83
|
+
* `partialFillReason` is set only on `status === "partial_fill"`.
|
|
84
|
+
*/
|
|
85
|
+
filledAmountRaw?: string;
|
|
86
|
+
quotedSharesRaw?: string;
|
|
87
|
+
actualSharesRaw?: string;
|
|
88
|
+
quotedToWinRaw?: string;
|
|
89
|
+
actualToWinRaw?: string;
|
|
90
|
+
quotedPriceRaw?: string;
|
|
91
|
+
executionPriceRaw?: string;
|
|
92
|
+
partialFillReason?: string;
|
|
93
|
+
/** @deprecated See `executionPriceRaw` — never emitted; remove in 2.0. */
|
|
94
|
+
fillPrice?: undefined;
|
|
95
|
+
/** @deprecated See `actualSharesRaw` / `filledAmountRaw` — never emitted; remove in 2.0. */
|
|
96
|
+
fillSize?: undefined;
|
|
60
97
|
};
|
|
61
98
|
}
|
|
62
99
|
interface MarketsResolvedEvent extends WebhookEventBase {
|
|
63
100
|
type: "markets.resolved";
|
|
64
101
|
data: {
|
|
65
102
|
venueMarketId: string;
|
|
66
|
-
|
|
103
|
+
externalIdentifier: string;
|
|
104
|
+
status: string;
|
|
105
|
+
outcomes: Array<{
|
|
106
|
+
label: string;
|
|
107
|
+
winner?: boolean;
|
|
108
|
+
externalIdentifier?: string;
|
|
109
|
+
}>;
|
|
67
110
|
affectedUsersCount: number;
|
|
111
|
+
/**
|
|
112
|
+
* Path on the AGG API where this resolution's affected users can be
|
|
113
|
+
* paginated. Combine with the configured base URL — e.g.
|
|
114
|
+
* `https://api.agg.market${detailsPath}`.
|
|
115
|
+
*/
|
|
116
|
+
detailsPath: string;
|
|
117
|
+
/**
|
|
118
|
+
* @deprecated Singular `outcome` was never emitted; use `outcomes` array.
|
|
119
|
+
* Remove in 2.0.
|
|
120
|
+
*/
|
|
121
|
+
outcome?: undefined;
|
|
68
122
|
};
|
|
69
123
|
}
|
|
70
124
|
interface UnknownWebhookEvent extends WebhookEventBase {
|
|
@@ -118,7 +172,9 @@ declare class AggAdminClient {
|
|
|
118
172
|
ordersByStatus: Record<string, number>;
|
|
119
173
|
ordersByVenue: Record<string, number>;
|
|
120
174
|
usersLast30Days: number;
|
|
175
|
+
usersLast7Days: number;
|
|
121
176
|
ordersLast30Days: number;
|
|
177
|
+
ordersLast7Days: number;
|
|
122
178
|
}>;
|
|
123
179
|
listOrders(appId: string, query?: {
|
|
124
180
|
limit?: number;
|
|
@@ -152,4 +208,4 @@ declare class AggAdminClient {
|
|
|
152
208
|
}>;
|
|
153
209
|
}
|
|
154
210
|
|
|
155
|
-
export { type AccountsCreatedEvent, type AccountsLinkedEvent, AggAdminClient, type AggAdminClientOptions, type ExternalIdAssertion, type KnownWebhookEvent, type MarketsResolvedEvent, type TradesFilledEvent, type TradesPlacedEvent, type UnknownWebhookEvent, type VerifyWebhookOptions, type WalletsReadyEvent, type WebhookEvent, WebhookVerificationError, parseWebhookEvent, signExternalId, verifyWebhook };
|
|
211
|
+
export { type AccountsCreatedEvent, type AccountsLinkedEvent, AggAdminClient, type AggAdminClientOptions, type ExternalIdAssertion, type KnownWebhookEvent, type MarketsResolvedEvent, type TradesFilledEvent, type TradesPlacedEvent, type UnknownWebhookEvent, type VerifyWebhookOptions, type WalletsReadyEvent, type WebhookEvent, WebhookVerificationError, parseWebhookEvent, parseWebhookEventAsync, signExternalId, verifyWebhook, verifyWebhookAsync };
|
package/dist/server.js
CHANGED
|
@@ -60,8 +60,10 @@ __export(server_exports, {
|
|
|
60
60
|
AggAdminClient: () => AggAdminClient,
|
|
61
61
|
WebhookVerificationError: () => WebhookVerificationError,
|
|
62
62
|
parseWebhookEvent: () => parseWebhookEvent,
|
|
63
|
+
parseWebhookEventAsync: () => parseWebhookEventAsync,
|
|
63
64
|
signExternalId: () => signExternalId,
|
|
64
|
-
verifyWebhook: () => verifyWebhook
|
|
65
|
+
verifyWebhook: () => verifyWebhook,
|
|
66
|
+
verifyWebhookAsync: () => verifyWebhookAsync
|
|
65
67
|
});
|
|
66
68
|
module.exports = __toCommonJS(server_exports);
|
|
67
69
|
var import_node_crypto = require("crypto");
|
|
@@ -74,6 +76,22 @@ function signExternalId(appSecret, externalId) {
|
|
|
74
76
|
hmac
|
|
75
77
|
};
|
|
76
78
|
}
|
|
79
|
+
var textEncoder = new TextEncoder();
|
|
80
|
+
function base64Decode(s) {
|
|
81
|
+
const bin = atob(s);
|
|
82
|
+
const out = new Uint8Array(bin.length);
|
|
83
|
+
for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);
|
|
84
|
+
return out;
|
|
85
|
+
}
|
|
86
|
+
function importHmacKey(secret) {
|
|
87
|
+
return __async(this, null, function* () {
|
|
88
|
+
const keyBytes = base64Decode(secret.replace(/^whsec_/, ""));
|
|
89
|
+
return crypto.subtle.importKey("raw", keyBytes, { name: "HMAC", hash: "SHA-256" }, false, [
|
|
90
|
+
"sign",
|
|
91
|
+
"verify"
|
|
92
|
+
]);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
77
95
|
var WebhookVerificationError = class extends Error {
|
|
78
96
|
constructor(message) {
|
|
79
97
|
super(message);
|
|
@@ -113,6 +131,45 @@ function parseWebhookEvent(payload, headers, secret, options) {
|
|
|
113
131
|
const parsed = JSON.parse(payload);
|
|
114
132
|
return parsed;
|
|
115
133
|
}
|
|
134
|
+
function verifyWebhookAsync(payload, headers, secret, options) {
|
|
135
|
+
return __async(this, null, function* () {
|
|
136
|
+
var _a;
|
|
137
|
+
const tolerance = (_a = options == null ? void 0 : options.toleranceSeconds) != null ? _a : 300;
|
|
138
|
+
const msgId = getHeader(headers, "webhook-id");
|
|
139
|
+
const timestamp = getHeader(headers, "webhook-timestamp");
|
|
140
|
+
const signatures = getHeader(headers, "webhook-signature");
|
|
141
|
+
if (!msgId) throw new WebhookVerificationError("Missing Webhook-Id header");
|
|
142
|
+
if (!timestamp) throw new WebhookVerificationError("Missing Webhook-Timestamp header");
|
|
143
|
+
if (!signatures) throw new WebhookVerificationError("Missing Webhook-Signature header");
|
|
144
|
+
const ts = parseInt(timestamp, 10);
|
|
145
|
+
if (isNaN(ts)) throw new WebhookVerificationError("Invalid Webhook-Timestamp");
|
|
146
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
147
|
+
if (Math.abs(now - ts) > tolerance) {
|
|
148
|
+
throw new WebhookVerificationError("Webhook timestamp outside tolerance window");
|
|
149
|
+
}
|
|
150
|
+
const key = yield importHmacKey(secret);
|
|
151
|
+
const signed = textEncoder.encode(`${msgId}.${timestamp}.${payload}`);
|
|
152
|
+
for (const sig of signatures.split(" ")) {
|
|
153
|
+
if (!sig.startsWith("v1,")) continue;
|
|
154
|
+
let sigBytes;
|
|
155
|
+
try {
|
|
156
|
+
sigBytes = base64Decode(sig.slice(3));
|
|
157
|
+
} catch (e) {
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
const ok = yield crypto.subtle.verify("HMAC", key, sigBytes, signed);
|
|
161
|
+
if (ok) return;
|
|
162
|
+
}
|
|
163
|
+
throw new WebhookVerificationError("Invalid webhook signature");
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function parseWebhookEventAsync(payload, headers, secret, options) {
|
|
167
|
+
return __async(this, null, function* () {
|
|
168
|
+
yield verifyWebhookAsync(payload, headers, secret, options);
|
|
169
|
+
const parsed = JSON.parse(payload);
|
|
170
|
+
return parsed;
|
|
171
|
+
});
|
|
172
|
+
}
|
|
116
173
|
var AggAdminClient = class {
|
|
117
174
|
constructor(options) {
|
|
118
175
|
this.baseUrl = options.baseUrl.replace(/\/$/, "");
|
|
@@ -249,6 +306,8 @@ function getHeader(headers, name) {
|
|
|
249
306
|
AggAdminClient,
|
|
250
307
|
WebhookVerificationError,
|
|
251
308
|
parseWebhookEvent,
|
|
309
|
+
parseWebhookEventAsync,
|
|
252
310
|
signExternalId,
|
|
253
|
-
verifyWebhook
|
|
311
|
+
verifyWebhook,
|
|
312
|
+
verifyWebhookAsync
|
|
254
313
|
});
|
package/dist/server.mjs
CHANGED
|
@@ -15,6 +15,22 @@ function signExternalId(appSecret, externalId) {
|
|
|
15
15
|
hmac
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
+
var textEncoder = new TextEncoder();
|
|
19
|
+
function base64Decode(s) {
|
|
20
|
+
const bin = atob(s);
|
|
21
|
+
const out = new Uint8Array(bin.length);
|
|
22
|
+
for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
25
|
+
function importHmacKey(secret) {
|
|
26
|
+
return __async(this, null, function* () {
|
|
27
|
+
const keyBytes = base64Decode(secret.replace(/^whsec_/, ""));
|
|
28
|
+
return crypto.subtle.importKey("raw", keyBytes, { name: "HMAC", hash: "SHA-256" }, false, [
|
|
29
|
+
"sign",
|
|
30
|
+
"verify"
|
|
31
|
+
]);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
18
34
|
var WebhookVerificationError = class extends Error {
|
|
19
35
|
constructor(message) {
|
|
20
36
|
super(message);
|
|
@@ -54,6 +70,45 @@ function parseWebhookEvent(payload, headers, secret, options) {
|
|
|
54
70
|
const parsed = JSON.parse(payload);
|
|
55
71
|
return parsed;
|
|
56
72
|
}
|
|
73
|
+
function verifyWebhookAsync(payload, headers, secret, options) {
|
|
74
|
+
return __async(this, null, function* () {
|
|
75
|
+
var _a;
|
|
76
|
+
const tolerance = (_a = options == null ? void 0 : options.toleranceSeconds) != null ? _a : 300;
|
|
77
|
+
const msgId = getHeader(headers, "webhook-id");
|
|
78
|
+
const timestamp = getHeader(headers, "webhook-timestamp");
|
|
79
|
+
const signatures = getHeader(headers, "webhook-signature");
|
|
80
|
+
if (!msgId) throw new WebhookVerificationError("Missing Webhook-Id header");
|
|
81
|
+
if (!timestamp) throw new WebhookVerificationError("Missing Webhook-Timestamp header");
|
|
82
|
+
if (!signatures) throw new WebhookVerificationError("Missing Webhook-Signature header");
|
|
83
|
+
const ts = parseInt(timestamp, 10);
|
|
84
|
+
if (isNaN(ts)) throw new WebhookVerificationError("Invalid Webhook-Timestamp");
|
|
85
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
86
|
+
if (Math.abs(now - ts) > tolerance) {
|
|
87
|
+
throw new WebhookVerificationError("Webhook timestamp outside tolerance window");
|
|
88
|
+
}
|
|
89
|
+
const key = yield importHmacKey(secret);
|
|
90
|
+
const signed = textEncoder.encode(`${msgId}.${timestamp}.${payload}`);
|
|
91
|
+
for (const sig of signatures.split(" ")) {
|
|
92
|
+
if (!sig.startsWith("v1,")) continue;
|
|
93
|
+
let sigBytes;
|
|
94
|
+
try {
|
|
95
|
+
sigBytes = base64Decode(sig.slice(3));
|
|
96
|
+
} catch (e) {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const ok = yield crypto.subtle.verify("HMAC", key, sigBytes, signed);
|
|
100
|
+
if (ok) return;
|
|
101
|
+
}
|
|
102
|
+
throw new WebhookVerificationError("Invalid webhook signature");
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function parseWebhookEventAsync(payload, headers, secret, options) {
|
|
106
|
+
return __async(this, null, function* () {
|
|
107
|
+
yield verifyWebhookAsync(payload, headers, secret, options);
|
|
108
|
+
const parsed = JSON.parse(payload);
|
|
109
|
+
return parsed;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
57
112
|
var AggAdminClient = class {
|
|
58
113
|
constructor(options) {
|
|
59
114
|
this.baseUrl = options.baseUrl.replace(/\/$/, "");
|
|
@@ -189,6 +244,8 @@ export {
|
|
|
189
244
|
AggAdminClient,
|
|
190
245
|
WebhookVerificationError,
|
|
191
246
|
parseWebhookEvent,
|
|
247
|
+
parseWebhookEventAsync,
|
|
192
248
|
signExternalId,
|
|
193
|
-
verifyWebhook
|
|
249
|
+
verifyWebhook,
|
|
250
|
+
verifyWebhookAsync
|
|
194
251
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agg-build/sdk",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.13",
|
|
4
4
|
"description": "Vanilla TypeScript client for the AGG prediction market aggregator (auth, markets, orderbooks, charts, trading, managed execution, WebSockets). Works in browsers, Node.js, and React Native.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "MIT",
|