@tchain/tcabci-read-js-client 2.8.1 → 2.8.2

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/client.js CHANGED
@@ -70,7 +70,6 @@ export default class TCaBCIClient {
70
70
  _connected = false
71
71
  _chainName = 'transferchain'
72
72
  _chainVersion = 'v1'
73
- _version = `v2.8.0`
74
73
  /**
75
74
  * @type {?SuccessCallback}
76
75
  */
package/constants.d.ts CHANGED
@@ -1 +1,3 @@
1
- export declare const READ_NODE_ADDRESS: string, READ_NODE_WS_ADDRESS: string
1
+ export declare const CLIENT_VERSION: string,
2
+ READ_NODE_ADDRESS: string,
3
+ READ_NODE_WS_ADDRESS: string
package/constants.js CHANGED
@@ -1,2 +1,3 @@
1
- export const READ_NODE_ADDRESS = 'https://read-node-01.transferchain.io',
1
+ export const CLIENT_VERSION = '2.8.2',
2
+ READ_NODE_ADDRESS = 'https://read-node-01.transferchain.io',
2
3
  READ_NODE_WS_ADDRESS = 'wss://read-node-01.transferchain.io/ws'
package/http.js CHANGED
@@ -2,12 +2,12 @@ import { SendThrow } from './util.js'
2
2
  import { ERR_NETWORK, FetchError, INVALID_ARGUMENTS } from './errors.js'
3
3
  import { Breaker } from './breaker.js'
4
4
  import {
5
- CLIENT_VERSION,
6
5
  endpoint,
7
6
  positiveInteger,
8
7
  cloneAndFreeze,
9
8
  byteLength
10
9
  } from './validation.js'
10
+ import { CLIENT_VERSION } from './constants.js'
11
11
 
12
12
  export class HTTP {
13
13
  _baseURL
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tchain/tcabci-read-js-client",
3
- "version": "2.8.1",
3
+ "version": "2.8.2",
4
4
  "description": "TransferChain Fastest Read Network WebSocket Client",
5
5
  "homepage": "https://github.com/TransferChain/tcabci-read-js-client#readme",
6
6
  "bugs": {
package/validation.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { JSONValue } from './types.js'
2
2
 
3
- export declare const CLIENT_VERSION: string, MAX_ADDRESSES: number
3
+ export declare const MAX_ADDRESSES: number
4
4
 
5
5
  export declare function positiveInteger(value: number, name: string): number
6
6
 
package/validation.js CHANGED
@@ -1,5 +1,4 @@
1
- export const CLIENT_VERSION = '2.8.0',
2
- MAX_ADDRESSES = 251
1
+ export const MAX_ADDRESSES = 251
3
2
 
4
3
  export function positiveInteger(value, name) {
5
4
  if (!Number.isSafeInteger(value) || value <= 0)
@@ -1,5 +1,6 @@
1
1
  import { createWSAuthorityV3 } from './authority.js'
2
- import { CLIENT_VERSION, endpoint, positiveInteger } from './validation.js'
2
+ import { endpoint, positiveInteger } from './validation.js'
3
+ import { CLIENT_VERSION } from './constants.js'
3
4
 
4
5
  export const HTTPSPort = 443,
5
6
  HTTPPort = 80,
@@ -332,25 +333,30 @@ export class Options {
332
333
  make() {
333
334
  let WS = this._customWS
334
335
 
335
- if (this._authority) {
336
+ if (this._authority || typeof WS?.prototype?.on === 'function') {
336
337
  const Base = WS,
337
- options = this
338
+ options = this,
339
+ requiresAuthority = Boolean(this._authority)
338
340
 
339
341
  WS = class extends Base {
340
342
  constructor(url, protocols) {
341
343
  const authority = options._authority
342
344
 
343
- if (!authority)
345
+ if (requiresAuthority && !authority
344
346
  throw new Error('Websocket authority configuration released')
345
347
 
346
348
  super(url, protocols, {
347
349
  followRedirects: false,
348
350
  headers: {
349
351
  Client: `tcabci-read-js-client/${CLIENT_VERSION}`,
350
- 'X-Authority': createWSAuthorityV3(
351
- authority.address,
352
- authority.sign
353
- )
352
+ ...(authority
353
+ ? {
354
+ 'X-Authority': createWSAuthorityV3(
355
+ authority.address,
356
+ authority.sign
357
+ )
358
+ }
359
+ : {})
354
360
  }
355
361
  })
356
362
  }
@@ -370,7 +376,7 @@ export class Options {
370
376
  // ReconnectingWebSocket debug logs outgoing payloads. Never enable it.
371
377
  debug: false,
372
378
  headers: {
373
- Client: `tcabaci-read-js-client/${this._version}`
379
+ Client: `tcabci-read-js-client/${this._version}`
374
380
  }
375
381
  }
376
382
  }