diff --git a/.github/workflows/npmpublish.yml b/.github/workflows/npmpublish.yml index 543c3fee..6cab3487 100644 --- a/.github/workflows/npmpublish.yml +++ b/.github/workflows/npmpublish.yml @@ -8,19 +8,26 @@ on: branches: - master +permissions: + id-token: 'write' + contents: 'read' + jobs: build: + name: 'Publish NPM' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - name: 'Checkout source code' + uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 with: - node-version: 12 - # - run: npm ci - # - run: npm test + node-version-file: '.nvmrc' + registry-url: 'https://registry.npmjs.org/' + cache: 'npm' publish-npm: - needs: build + name: 'Publish NPM' runs-on: ubuntu-latest steps: - name: Package Version Updated @@ -31,36 +38,28 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - uses: actions/checkout@v2 + - name: 'Checkout source code' if: steps.version-updated.outputs.has-updated + uses: actions/checkout@v4 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v4 if: steps.version-updated.outputs.has-updated with: - node-version: 12 - registry-url: https://registry.npmjs.org/ + node-version-file: '.nvmrc' + registry-url: 'https://registry.npmjs.org/' + cache: 'npm' - - run: npm ci --ignore-scripts + - name: Install + run: npm ci --ignore-scripts if: steps.version-updated.outputs.has-updated + - run: npm run clean if: steps.version-updated.outputs.has-updated + - run: npm run build if: steps.version-updated.outputs.has-updated - - run: npm publish --ignore-scripts + + - run: npm publish --ignore-scripts --provenance if: steps.version-updated.outputs.has-updated env: NODE_AUTH_TOKEN: ${{secrets.npm_token}} - - #publish-gpr: - #needs: build - #runs-on: ubuntu-latest - #steps: - #- uses: actions/checkout@v2 - #- uses: actions/setup-node@v1 - # with: - # node-version: 12 - # registry-url: https://npm.pkg.github.com/ - #- run: npm ci - #- run: npm publish - # env: - # NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..79439539 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,35 @@ +name: 'Build & Test' + +on: [push] + +jobs: + build: + name: 'Build & Test' + runs-on: ubuntu-latest + + steps: + - name: 'Checkout source code' + uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + registry-url: 'https://registry.npmjs.org/' + cache: 'npm' + + - name: Install + run: npm ci --ignore-scripts + + - name: Build + run: npm run build + + - name: Test + run: npm run test + env: + API_KEY_COM: ${{ secrets.API_KEY_COM }} + API_SECRET_COM: ${{ secrets.API_SECRET_COM }} + PROXY_ENABLED: ${{ secrets.PROXY_ENABLED }} + PROXY_HOST: ${{ secrets.PROXY_HOST }} + PROXY_PORT: ${{ secrets.PROXY_PORT }} + PROXY_USER: ${{ secrets.PROXY_USER }} + PROXY_PASS: ${{ secrets.PROXY_PASS }} diff --git a/package.json b/package.json index 97774c03..42e0532c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "binance", - "version": "2.9.4", + "version": "2.9.5", "description": "Node.js & JavaScript SDK for Binance REST APIs & WebSockets, with TypeScript & end-to-end tests.", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/types/websockets.ts b/src/types/websockets.ts index e718bed3..255819c4 100644 --- a/src/types/websockets.ts +++ b/src/types/websockets.ts @@ -311,7 +311,7 @@ export interface WsMessage24hrTickerFormatted extends WsSharedBase { closeQuantity: number; bestBid: number; bestBidQuantity: number; - bestAsk: number; + bestAskPrice: number; bestAskQuantity: number; open: number; high: number; diff --git a/test/futures-coinm/private.test.ts b/test/futures-coinm/private.test.ts index 3304247a..a73a6a64 100644 --- a/test/futures-coinm/private.test.ts +++ b/test/futures-coinm/private.test.ts @@ -12,7 +12,7 @@ describe('Private Futures USDM REST API Endpoints', () => { api_key: API_KEY, api_secret: API_SECRET, }, - { httpsAgent: getTestProxy() }, + getTestProxy(), ); let book: CoinMSymbolOrderBookTicker[]; diff --git a/test/futures-usdm/private.test.ts b/test/futures-usdm/private.test.ts index 9e716575..e925afc5 100644 --- a/test/futures-usdm/private.test.ts +++ b/test/futures-usdm/private.test.ts @@ -11,7 +11,7 @@ describe('Private Futures USDM REST API Endpoints', () => { api_key: API_KEY, api_secret: API_SECRET, }, - { httpsAgent: getTestProxy() }, + getTestProxy(), ); const symbol = 'BTCUSDT'; diff --git a/test/futures-usdm/public.test.ts b/test/futures-usdm/public.test.ts index 879d853d..440af5d9 100644 --- a/test/futures-usdm/public.test.ts +++ b/test/futures-usdm/public.test.ts @@ -7,7 +7,7 @@ import { USDMClient } from '../../src/usdm-client'; import { getTestProxy } from '../proxy.util'; describe('Public Futures USDM REST API Endpoints', () => { - const api = new USDMClient({}, { httpsAgent: getTestProxy() }); + const api = new USDMClient({}, getTestProxy()); const symbol = 'BTCUSDT'; const interval = '15m'; diff --git a/test/proxy.util.ts b/test/proxy.util.ts index 004fbe28..5918391f 100644 --- a/test/proxy.util.ts +++ b/test/proxy.util.ts @@ -1,17 +1,26 @@ -import { getHttpsProxyAgent } from '../src'; +import { AxiosRequestConfig } from 'axios'; -export function getTestProxy() { +export function getTestProxy(): AxiosRequestConfig { if (process.env.PROXY_ENABLED !== 'true') { - return; + return {}; } const host = process.env.PROXY_HOST; const port = process.env.PROXY_PORT; const user = process.env.PROXY_USER; const pass = process.env.PROXY_PASS; if (!host || !port || !user || !pass) { - throw new Error(`One or more env vars missing for proxy support`); + throw new Error('One or more env vars missing for proxy support'); } - const httpsAgent = getHttpsProxyAgent(host, port, user, pass); - return httpsAgent; + return { + proxy: { + host, + port: Number(port), + auth: { + username: user, + password: pass, + }, + protocol: 'http', + }, + }; } diff --git a/test/spot/private.test.ts b/test/spot/private.test.ts index 5a30c8d0..508cc47f 100644 --- a/test/spot/private.test.ts +++ b/test/spot/private.test.ts @@ -16,7 +16,7 @@ describe('Private Spot REST API Endpoints', () => { }, { timeout: 1000 * 60, - httpsAgent: getTestProxy(), + ...getTestProxy(), }, ); diff --git a/test/spot/public.test.ts b/test/spot/public.test.ts index bab9fd48..017fed7a 100644 --- a/test/spot/public.test.ts +++ b/test/spot/public.test.ts @@ -7,7 +7,7 @@ import { } from '../response.util'; describe('Public Spot REST API Endpoints', () => { - const api = new MainClient({}, { httpsAgent: getTestProxy() }); + const api = new MainClient({}, getTestProxy()); const symbol = 'BTCUSDT'; const interval = '15m'; diff --git a/test/spot/staking.test.ts b/test/spot/staking.test.ts index 4584965a..9922f455 100644 --- a/test/spot/staking.test.ts +++ b/test/spot/staking.test.ts @@ -12,7 +12,7 @@ describe('Staking API Endpoints', () => { }, { timeout: 1000 * 60, - httpsAgent: getTestProxy(), + ...getTestProxy(), }, );