tardis-machine 18.3.7 → 18.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/ws/subscriptionsmappers.d.ts.map +1 -1
  2. package/dist/ws/subscriptionsmappers.js +1 -0
  3. package/dist/ws/subscriptionsmappers.js.map +1 -1
  4. package/node_modules/tardis-dev/dist/consts.d.ts +6 -5
  5. package/node_modules/tardis-dev/dist/consts.d.ts.map +1 -1
  6. package/node_modules/tardis-dev/dist/consts.js +31 -5
  7. package/node_modules/tardis-dev/dist/consts.js.map +1 -1
  8. package/node_modules/tardis-dev/dist/mappers/ascendex.d.ts +4 -4
  9. package/node_modules/tardis-dev/dist/mappers/aster.d.ts +8 -8
  10. package/node_modules/tardis-dev/dist/mappers/binance.d.ts +18 -18
  11. package/node_modules/tardis-dev/dist/mappers/binanceeuropeanoptions.d.ts +1 -1
  12. package/node_modules/tardis-dev/dist/mappers/bitfinex.d.ts +8 -8
  13. package/node_modules/tardis-dev/dist/mappers/bitflyer.d.ts +1 -1
  14. package/node_modules/tardis-dev/dist/mappers/bitget.d.ts +1 -1
  15. package/node_modules/tardis-dev/dist/mappers/bithumb.d.ts +2 -2
  16. package/node_modules/tardis-dev/dist/mappers/bitmex.d.ts +2 -2
  17. package/node_modules/tardis-dev/dist/mappers/bitnomial.d.ts +1 -1
  18. package/node_modules/tardis-dev/dist/mappers/bitstamp.d.ts +3 -2
  19. package/node_modules/tardis-dev/dist/mappers/bitstamp.d.ts.map +1 -1
  20. package/node_modules/tardis-dev/dist/mappers/bitstamp.js +49 -2
  21. package/node_modules/tardis-dev/dist/mappers/bitstamp.js.map +1 -1
  22. package/node_modules/tardis-dev/dist/mappers/bitvavo.d.ts +3 -3
  23. package/node_modules/tardis-dev/dist/mappers/blockchaincom.d.ts +2 -2
  24. package/node_modules/tardis-dev/dist/mappers/bullish.d.ts +5 -5
  25. package/node_modules/tardis-dev/dist/mappers/bybit.d.ts +26 -7
  26. package/node_modules/tardis-dev/dist/mappers/bybit.d.ts.map +1 -1
  27. package/node_modules/tardis-dev/dist/mappers/bybit.js +4 -0
  28. package/node_modules/tardis-dev/dist/mappers/bybit.js.map +1 -1
  29. package/node_modules/tardis-dev/dist/mappers/bybitspot.d.ts +1 -1
  30. package/node_modules/tardis-dev/dist/mappers/coinbase.d.ts +1 -1
  31. package/node_modules/tardis-dev/dist/mappers/coinbaseinternational.d.ts +2 -2
  32. package/node_modules/tardis-dev/dist/mappers/coinflex.d.ts +1 -1
  33. package/node_modules/tardis-dev/dist/mappers/cryptocom.d.ts +5 -5
  34. package/node_modules/tardis-dev/dist/mappers/cryptofacilities.d.ts +2 -2
  35. package/node_modules/tardis-dev/dist/mappers/delta.d.ts +1 -1
  36. package/node_modules/tardis-dev/dist/mappers/deribit.d.ts +3 -3
  37. package/node_modules/tardis-dev/dist/mappers/dydx.d.ts +3 -3
  38. package/node_modules/tardis-dev/dist/mappers/dydxv4.d.ts +4 -4
  39. package/node_modules/tardis-dev/dist/mappers/ftx.d.ts +8 -8
  40. package/node_modules/tardis-dev/dist/mappers/ftx.js +1 -1
  41. package/node_modules/tardis-dev/dist/mappers/ftx.js.map +1 -1
  42. package/node_modules/tardis-dev/dist/mappers/gateio.d.ts +1 -1
  43. package/node_modules/tardis-dev/dist/mappers/gateiofutures.d.ts +4 -4
  44. package/node_modules/tardis-dev/dist/mappers/gemini.d.ts +1 -1
  45. package/node_modules/tardis-dev/dist/mappers/huobi.d.ts +26 -26
  46. package/node_modules/tardis-dev/dist/mappers/hyperliquid.d.ts +3 -3
  47. package/node_modules/tardis-dev/dist/mappers/index.d.ts +204 -183
  48. package/node_modules/tardis-dev/dist/mappers/index.d.ts.map +1 -1
  49. package/node_modules/tardis-dev/dist/mappers/kucoin.d.ts +3 -3
  50. package/node_modules/tardis-dev/dist/mappers/kucoinfutures.d.ts +4 -4
  51. package/node_modules/tardis-dev/dist/mappers/lighter.d.ts +10 -10
  52. package/node_modules/tardis-dev/dist/mappers/mexc.d.ts +3 -3
  53. package/node_modules/tardis-dev/dist/mappers/mexcfutures.d.ts +3 -3
  54. package/node_modules/tardis-dev/dist/mappers/okex.d.ts +15 -15
  55. package/node_modules/tardis-dev/dist/mappers/phemex.d.ts +1 -1
  56. package/node_modules/tardis-dev/dist/mappers/polymarket.d.ts +3 -3
  57. package/node_modules/tardis-dev/dist/mappers/serum.d.ts +9 -9
  58. package/node_modules/tardis-dev/dist/mappers/upbit.d.ts +2 -2
  59. package/node_modules/tardis-dev/dist/realtimefeeds/bitstamp.d.ts +12 -2
  60. package/node_modules/tardis-dev/dist/realtimefeeds/bitstamp.d.ts.map +1 -1
  61. package/node_modules/tardis-dev/dist/realtimefeeds/bitstamp.js +36 -3
  62. package/node_modules/tardis-dev/dist/realtimefeeds/bitstamp.js.map +1 -1
  63. package/node_modules/tardis-dev/dist/realtimefeeds/bybit.d.ts +3 -0
  64. package/node_modules/tardis-dev/dist/realtimefeeds/bybit.d.ts.map +1 -1
  65. package/node_modules/tardis-dev/dist/realtimefeeds/bybit.js +3 -0
  66. package/node_modules/tardis-dev/dist/realtimefeeds/bybit.js.map +1 -1
  67. package/node_modules/tardis-dev/dist/realtimefeeds/index.d.ts.map +1 -1
  68. package/node_modules/tardis-dev/dist/realtimefeeds/index.js +2 -3
  69. package/node_modules/tardis-dev/dist/realtimefeeds/index.js.map +1 -1
  70. package/node_modules/tardis-dev/dist/realtimefeeds/okex.d.ts.map +1 -1
  71. package/node_modules/tardis-dev/dist/realtimefeeds/okex.js +4 -4
  72. package/node_modules/tardis-dev/dist/realtimefeeds/okex.js.map +1 -1
  73. package/node_modules/tardis-dev/dist/realtimefeeds/okexspreads.d.ts.map +1 -1
  74. package/node_modules/tardis-dev/dist/realtimefeeds/okexspreads.js +1 -1
  75. package/node_modules/tardis-dev/dist/realtimefeeds/okexspreads.js.map +1 -1
  76. package/node_modules/tardis-dev/package.json +1 -1
  77. package/node_modules/tardis-dev/src/consts.ts +32 -5
  78. package/node_modules/tardis-dev/src/mappers/bitstamp.ts +101 -27
  79. package/node_modules/tardis-dev/src/mappers/bybit.ts +6 -2
  80. package/node_modules/tardis-dev/src/mappers/ftx.ts +1 -1
  81. package/node_modules/tardis-dev/src/realtimefeeds/bitstamp.ts +50 -3
  82. package/node_modules/tardis-dev/src/realtimefeeds/bybit.ts +4 -0
  83. package/node_modules/tardis-dev/src/realtimefeeds/index.ts +2 -3
  84. package/node_modules/tardis-dev/src/realtimefeeds/okex.ts +4 -10
  85. package/node_modules/tardis-dev/src/realtimefeeds/okexspreads.ts +1 -1
  86. package/package.json +2 -2
  87. package/src/ws/subscriptionsmappers.ts +1 -0
  88. package/node_modules/tardis-dev/dist/realtimefeeds/coinbaseinternational.d.ts +0 -10
  89. package/node_modules/tardis-dev/dist/realtimefeeds/coinbaseinternational.d.ts.map +0 -1
  90. package/node_modules/tardis-dev/dist/realtimefeeds/coinbaseinternational.js +0 -47
  91. package/node_modules/tardis-dev/dist/realtimefeeds/coinbaseinternational.js.map +0 -1
  92. package/node_modules/tardis-dev/src/realtimefeeds/coinbaseinternational.ts +0 -60
@@ -132,7 +132,7 @@ class FTXDerivativeTickerMapper implements Mapper<'ftx', DerivativeTicker> {
132
132
  return [
133
133
  {
134
134
  channel: 'instrument',
135
- symbols: symbols !== undefined ? symbols.filter((s) => s.includes('/') === false) : undefined
135
+ symbols
136
136
  } as const
137
137
  ]
138
138
  }
@@ -1,10 +1,57 @@
1
+ import { Writable } from 'stream'
1
2
  import { getJSON } from '../handy.ts'
2
3
  import { Filter } from '../types.ts'
3
- import { RealTimeFeedBase } from './realtimefeed.ts'
4
+ import { MultiConnectionRealTimeFeedBase, PoolingClientBase, RealTimeFeedBase } from './realtimefeed.ts'
4
5
 
5
- export class BitstampRealTimeFeed extends RealTimeFeedBase {
6
+ const BITSTAMP_HTTP_URL = 'https://www.bitstamp.net/api/v2'
7
+
8
+ export class BitstampRealTimeFeed extends MultiConnectionRealTimeFeedBase {
9
+ protected *_getRealTimeFeeds(exchange: string, filters: Filter<string>[], timeoutIntervalMS?: number, onError?: (error: Error) => void) {
10
+ const wsFilters = filters.filter((f) => f.channel !== 'ticker')
11
+ if (wsFilters.length > 0) {
12
+ yield new BitstampWebSocketRealTimeFeed(exchange, wsFilters, timeoutIntervalMS, onError)
13
+ }
14
+
15
+ const tickerFilters = filters.filter((f) => f.channel === 'ticker')
16
+ if (tickerFilters.length > 0) {
17
+ yield new BitstampTickerClient(
18
+ exchange,
19
+ tickerFilters.flatMap((f) => f.symbols ?? []),
20
+ onError
21
+ )
22
+ }
23
+ }
24
+ }
25
+
26
+ // Bitstamp WebSocket has no ticker channel; the recorder polls the REST ticker and stores it in this generated message shape.
27
+ class BitstampTickerClient extends PoolingClientBase {
28
+ constructor(
29
+ exchange: string,
30
+ private readonly _symbols: string[],
31
+ onError?: (error: Error) => void
32
+ ) {
33
+ super(exchange, 6, onError)
34
+ }
35
+
36
+ protected async poolDataToStream(outputStream: Writable) {
37
+ const { data: tickers } = await getJSON<{ market: string }[]>(`${BITSTAMP_HTTP_URL}/ticker/`, { timeout: 10000 })
38
+
39
+ for (const ticker of tickers) {
40
+ const symbol = ticker.market.replace('/', '').toLowerCase()
41
+ if (this._symbols.length > 0 && this._symbols.includes(symbol) === false) {
42
+ continue
43
+ }
44
+
45
+ if (outputStream.writable) {
46
+ outputStream.write({ data: ticker, channel: `ticker_${symbol}`, event: 'ticker', generated: true })
47
+ }
48
+ }
49
+ }
50
+ }
51
+
52
+ class BitstampWebSocketRealTimeFeed extends RealTimeFeedBase {
6
53
  protected wssURL = 'wss://ws.bitstamp.net'
7
- protected httpURL = 'https://www.bitstamp.net/api/v2'
54
+ protected httpURL = BITSTAMP_HTTP_URL
8
55
 
9
56
  protected mapToSubscribeMessages(filters: Filter<string>[]): any[] {
10
57
  return filters
@@ -90,6 +90,10 @@ export class BybitSpotRealTimeDataFeed extends BybitSingleConnectionRealTimeData
90
90
  protected wssURL: string = 'wss://stream.bybit.com/v5/public/spot'
91
91
  }
92
92
 
93
+ export class BybitSpreadRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed {
94
+ protected wssURL: string = 'wss://stream.bybit.com/v5/public/spread'
95
+ }
96
+
93
97
  export class BybitOptionsRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed {
94
98
  protected wssURL: string = 'wss://stream.bybit.com/v5/public/option'
95
99
 
@@ -13,7 +13,7 @@ import { BitflyerRealTimeFeed } from './bitflyer.ts'
13
13
  import { BithumbRealTimeFeed } from './bithumb.ts'
14
14
  import { BitstampRealTimeFeed } from './bitstamp.ts'
15
15
  import { BitvavoRealTimeFeed } from './bitvavo.ts'
16
- import { BybitOptionsRealTimeDataFeed, BybitRealTimeDataFeed, BybitSpotRealTimeDataFeed } from './bybit.ts'
16
+ import { BybitOptionsRealTimeDataFeed, BybitRealTimeDataFeed, BybitSpotRealTimeDataFeed, BybitSpreadRealTimeDataFeed } from './bybit.ts'
17
17
  import { CoinbaseRealTimeFeed } from './coinbase.ts'
18
18
  import { CryptofacilitiesRealTimeFeed } from './cryptofacilities.ts'
19
19
  import { DeribitRealTimeDataFeed } from './deribit.ts'
@@ -51,7 +51,6 @@ import { OkexSpreadsRealTimeFeed } from './okexspreads.ts'
51
51
  import { KucoinFuturesRealTimeFeed } from './kucoinfutures.ts'
52
52
  import { DydxV4RealTimeFeed } from './dydx_v4.ts'
53
53
  import { BitgetFuturesRealTimeFeed, BitgetRealTimeFeed } from './bitget.ts'
54
- import { CoinbaseInternationalRealTimeFeed } from './coinbaseinternational.ts'
55
54
  import { HyperliquidRealTimeFeed } from './hyperliquid.ts'
56
55
  import { LighterRealTimeFeed, LighterRhRealTimeFeed } from './lighter.ts'
57
56
  import { BullishRealTimeFeed } from './bullish.ts'
@@ -111,6 +110,7 @@ const realTimeFeedsMap: {
111
110
  mango: MangoRealTimeFeed,
112
111
  'bybit-spot': BybitSpotRealTimeDataFeed,
113
112
  'bybit-options': BybitOptionsRealTimeDataFeed,
113
+ 'bybit-spread': BybitSpreadRealTimeDataFeed,
114
114
  'crypto-com': CryptoComRealTimeFeed,
115
115
  kucoin: KucoinRealTimeFeed,
116
116
  bitnomial: BitnomialRealTimeFeed,
@@ -122,7 +122,6 @@ const realTimeFeedsMap: {
122
122
  'dydx-v4': DydxV4RealTimeFeed,
123
123
  bitget: BitgetRealTimeFeed,
124
124
  'bitget-futures': BitgetFuturesRealTimeFeed,
125
- 'coinbase-international': CoinbaseInternationalRealTimeFeed,
126
125
  hyperliquid: HyperliquidRealTimeFeed,
127
126
  lighter: LighterRealTimeFeed,
128
127
  'lighter-rh': LighterRhRealTimeFeed,
@@ -9,13 +9,13 @@ export class OkexRealTimeFeed extends MultiConnectionRealTimeFeedBase {
9
9
  const nonBusinessFilters = filters.filter((f) => f.channel !== 'trades-all')
10
10
 
11
11
  if (nonBusinessFilters.length > 0) {
12
- yield new OkexSingleRealTimeFeed('wss://ws.okx.com:8443/ws/v5/public', exchange, nonBusinessFilters, timeoutIntervalMS, onError)
12
+ yield new OkexSingleRealTimeFeed('wss://ws.okx.com/ws/v5/public', exchange, nonBusinessFilters, timeoutIntervalMS, onError)
13
13
  }
14
14
 
15
15
  const businessFilters = filters.filter((f) => f.channel === 'trades-all')
16
16
 
17
17
  if (businessFilters.length > 0) {
18
- yield new OkexSingleRealTimeFeed('wss://ws.okx.com:8443/ws/v5/business', exchange, businessFilters, timeoutIntervalMS, onError)
18
+ yield new OkexSingleRealTimeFeed('wss://ws.okx.com/ws/v5/business', exchange, businessFilters, timeoutIntervalMS, onError)
19
19
  }
20
20
  }
21
21
  }
@@ -113,19 +113,13 @@ export class OkexOptionsRealTimeFeed extends MultiConnectionRealTimeFeedBase {
113
113
  const nonBusinessFilters = filters.filter((f) => f.channel !== 'trades-all')
114
114
 
115
115
  if (nonBusinessFilters.length > 0) {
116
- yield new OkexOptionsSingleRealTimeFeed(
117
- 'wss://ws.okx.com:8443/ws/v5/public',
118
- exchange,
119
- nonBusinessFilters,
120
- timeoutIntervalMS,
121
- onError
122
- )
116
+ yield new OkexOptionsSingleRealTimeFeed('wss://ws.okx.com/ws/v5/public', exchange, nonBusinessFilters, timeoutIntervalMS, onError)
123
117
  }
124
118
 
125
119
  const businessFilters = filters.filter((f) => f.channel === 'trades-all')
126
120
 
127
121
  if (businessFilters.length > 0) {
128
- yield new OkexOptionsSingleRealTimeFeed('wss://ws.okx.com:8443/ws/v5/business', exchange, businessFilters, timeoutIntervalMS, onError)
122
+ yield new OkexOptionsSingleRealTimeFeed('wss://ws.okx.com/ws/v5/business', exchange, businessFilters, timeoutIntervalMS, onError)
129
123
  }
130
124
  }
131
125
  }
@@ -4,7 +4,7 @@ import { Filter } from '../types.ts'
4
4
  import { RealTimeFeedBase } from './realtimefeed.ts'
5
5
 
6
6
  export class OkexSpreadsRealTimeFeed extends RealTimeFeedBase {
7
- protected wssURL = 'wss://ws.okx.com:8443/ws/v5/business'
7
+ protected wssURL = 'wss://ws.okx.com/ws/v5/business'
8
8
 
9
9
  private _hasCredentials = process.env.OKX_API_KEY !== undefined
10
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tardis-machine",
3
- "version": "18.3.7",
3
+ "version": "18.4.0",
4
4
  "engines": {
5
5
  "node": ">=24.19"
6
6
  },
@@ -76,7 +76,7 @@
76
76
  "license": "MPL-2.0",
77
77
  "dependencies": {
78
78
  "debug": "^4.4.3",
79
- "tardis-dev": "^18.3.7",
79
+ "tardis-dev": "^18.4.0",
80
80
  "ws": "^8.21.3"
81
81
  },
82
82
  "bundleDependencies": true,
@@ -863,6 +863,7 @@ export const subscriptionsMappers: Record<Exchange, SubscriptionMapper> = {
863
863
  'woo-x': wooxMapper,
864
864
  'blockchain-com': blockchainComMapper,
865
865
  'bybit-options': bybitMapper,
866
+ 'bybit-spread': bybitMapper,
866
867
  'binance-european-options': binanceMapper,
867
868
  'okex-spreads': okexMapper,
868
869
  'kucoin-futures': kucoinMapper,
@@ -1,10 +0,0 @@
1
- import { Filter } from '../types.ts';
2
- import { RealTimeFeedBase } from './realtimefeed.ts';
3
- export declare class CoinbaseInternationalRealTimeFeed extends RealTimeFeedBase {
4
- private _hasCredentials;
5
- protected get wssURL(): string;
6
- protected mapToSubscribeMessages(filters: Filter<string>[]): any[];
7
- private getAuthParams;
8
- protected messageIsError(message: any): boolean;
9
- }
10
- //# sourceMappingURL=coinbaseinternational.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"coinbaseinternational.d.ts","sourceRoot":"","sources":["../../src/realtimefeeds/coinbaseinternational.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAEpD,qBAAa,iCAAkC,SAAQ,gBAAgB;IACrE,OAAO,CAAC,eAAe,CAG0C;IAEjE,SAAS,KAAK,MAAM,WAEnB;IAED,SAAS,CAAC,sBAAsB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,GAAG,EAAE;IA0BlE,OAAO,CAAC,aAAa;IAgBrB,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO;CAGhD"}
@@ -1,47 +0,0 @@
1
- import crypto from 'crypto';
2
- import { RealTimeFeedBase } from "./realtimefeed.js";
3
- export class CoinbaseInternationalRealTimeFeed extends RealTimeFeedBase {
4
- _hasCredentials = process.env.COINBASE_INTERNATIONAL_API_KEY !== undefined &&
5
- process.env.COINBASE_INTERNATIONAL_API_SECRET !== undefined &&
6
- process.env.COINBASE_INTERNATIONAL_API_PASSPHRASE !== undefined;
7
- get wssURL() {
8
- return 'wss://ws-md.international.coinbase.com';
9
- }
10
- mapToSubscribeMessages(filters) {
11
- if (this._hasCredentials == false) {
12
- throw new Error('CoinbaseInternationalRealTimeFeed requires auth credentials env vars set(COINBASE_INTERNATIONAL_API_KEY, COINBASE_INTERNATIONAL_API_SECRET, COINBASE_INTERNATIONAL_API_PASSPHRASE)');
13
- }
14
- const authParams = this.getAuthParams();
15
- return filters.map((filter) => {
16
- if (!filter.symbols || filter.symbols.length === 0) {
17
- throw new Error('CoinbaseInternationalRealTimeFeed requires explicitly specified symbols when subscribing to live feed');
18
- }
19
- return {
20
- type: 'SUBSCRIBE',
21
- product_ids: filter.symbols,
22
- channels: [filter.channel],
23
- signature: authParams.signature,
24
- key: authParams.key,
25
- time: authParams.time,
26
- passphrase: authParams.passphrase
27
- };
28
- });
29
- }
30
- getAuthParams() {
31
- const time = Math.floor(Date.now().valueOf() / 1000);
32
- const apiSecret = process.env.COINBASE_INTERNATIONAL_API_SECRET;
33
- const message = `${time}${process.env.COINBASE_INTERNATIONAL_API_KEY}CBINTLMD${process.env.COINBASE_INTERNATIONAL_API_PASSPHRASE}`;
34
- const hmac = crypto.createHmac('sha256', Buffer.from(apiSecret, 'base64'));
35
- const signature = hmac.update(message).digest('base64');
36
- return {
37
- signature,
38
- key: process.env.COINBASE_INTERNATIONAL_API_KEY,
39
- passphrase: process.env.COINBASE_INTERNATIONAL_API_PASSPHRASE,
40
- time
41
- };
42
- }
43
- messageIsError(message) {
44
- return message.type === 'REJECT';
45
- }
46
- }
47
- //# sourceMappingURL=coinbaseinternational.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"coinbaseinternational.js","sourceRoot":"","sources":["../../src/realtimefeeds/coinbaseinternational.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAEpD,MAAM,OAAO,iCAAkC,SAAQ,gBAAgB;IAC7D,eAAe,GACrB,OAAO,CAAC,GAAG,CAAC,8BAA8B,KAAK,SAAS;QACxD,OAAO,CAAC,GAAG,CAAC,iCAAiC,KAAK,SAAS;QAC3D,OAAO,CAAC,GAAG,CAAC,qCAAqC,KAAK,SAAS,CAAA;IAEjE,IAAc,MAAM;QAClB,OAAO,wCAAwC,CAAA;IACjD,CAAC;IAES,sBAAsB,CAAC,OAAyB;QACxD,IAAI,IAAI,CAAC,eAAe,IAAI,KAAK,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CACb,oLAAoL,CACrL,CAAA;QACH,CAAC;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAA;QAEvC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YAC5B,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACnD,MAAM,IAAI,KAAK,CAAC,uGAAuG,CAAC,CAAA;YAC1H,CAAC;YAED,OAAO;gBACL,IAAI,EAAE,WAAW;gBACjB,WAAW,EAAE,MAAM,CAAC,OAAO;gBAC3B,QAAQ,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC;gBAC1B,SAAS,EAAE,UAAU,CAAC,SAAS;gBAC/B,GAAG,EAAE,UAAU,CAAC,GAAG;gBACnB,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,UAAU,EAAE,UAAU,CAAC,UAAU;aAClC,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAEO,aAAa;QACnB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAA;QACpD,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,iCAAkC,CAAA;QAChE,MAAM,OAAO,GAAG,GAAG,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,8BAA8B,WAAW,OAAO,CAAC,GAAG,CAAC,qCAAqC,EAAE,CAAA;QAElI,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAA;QAC1E,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QAEvD,OAAO;YACL,SAAS;YACT,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,8BAA+B;YAChD,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,qCAAsC;YAC9D,IAAI;SACL,CAAA;IACH,CAAC;IAES,cAAc,CAAC,OAAY;QACnC,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAA;IAClC,CAAC;CACF"}
@@ -1,60 +0,0 @@
1
- import crypto from 'crypto'
2
- import { Filter } from '../types.ts'
3
- import { RealTimeFeedBase } from './realtimefeed.ts'
4
-
5
- export class CoinbaseInternationalRealTimeFeed extends RealTimeFeedBase {
6
- private _hasCredentials =
7
- process.env.COINBASE_INTERNATIONAL_API_KEY !== undefined &&
8
- process.env.COINBASE_INTERNATIONAL_API_SECRET !== undefined &&
9
- process.env.COINBASE_INTERNATIONAL_API_PASSPHRASE !== undefined
10
-
11
- protected get wssURL() {
12
- return 'wss://ws-md.international.coinbase.com'
13
- }
14
-
15
- protected mapToSubscribeMessages(filters: Filter<string>[]): any[] {
16
- if (this._hasCredentials == false) {
17
- throw new Error(
18
- 'CoinbaseInternationalRealTimeFeed requires auth credentials env vars set(COINBASE_INTERNATIONAL_API_KEY, COINBASE_INTERNATIONAL_API_SECRET, COINBASE_INTERNATIONAL_API_PASSPHRASE)'
19
- )
20
- }
21
-
22
- const authParams = this.getAuthParams()
23
-
24
- return filters.map((filter) => {
25
- if (!filter.symbols || filter.symbols.length === 0) {
26
- throw new Error('CoinbaseInternationalRealTimeFeed requires explicitly specified symbols when subscribing to live feed')
27
- }
28
-
29
- return {
30
- type: 'SUBSCRIBE',
31
- product_ids: filter.symbols,
32
- channels: [filter.channel],
33
- signature: authParams.signature,
34
- key: authParams.key,
35
- time: authParams.time,
36
- passphrase: authParams.passphrase
37
- }
38
- })
39
- }
40
-
41
- private getAuthParams() {
42
- const time = Math.floor(Date.now().valueOf() / 1000)
43
- const apiSecret = process.env.COINBASE_INTERNATIONAL_API_SECRET!
44
- const message = `${time}${process.env.COINBASE_INTERNATIONAL_API_KEY}CBINTLMD${process.env.COINBASE_INTERNATIONAL_API_PASSPHRASE}`
45
-
46
- const hmac = crypto.createHmac('sha256', Buffer.from(apiSecret, 'base64'))
47
- const signature = hmac.update(message).digest('base64')
48
-
49
- return {
50
- signature,
51
- key: process.env.COINBASE_INTERNATIONAL_API_KEY!,
52
- passphrase: process.env.COINBASE_INTERNATIONAL_API_PASSPHRASE!,
53
- time
54
- }
55
- }
56
-
57
- protected messageIsError(message: any): boolean {
58
- return message.type === 'REJECT'
59
- }
60
- }