@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 +0 -1
- package/constants.d.ts +3 -1
- package/constants.js +2 -1
- package/http.js +1 -1
- package/package.json +1 -1
- package/validation.d.ts +1 -1
- package/validation.js +1 -2
- package/websocketOptions.js +15 -9
package/client.js
CHANGED
package/constants.d.ts
CHANGED
package/constants.js
CHANGED
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
package/validation.d.ts
CHANGED
package/validation.js
CHANGED
package/websocketOptions.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createWSAuthorityV3 } from './authority.js'
|
|
2
|
-
import {
|
|
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
|
-
|
|
351
|
-
|
|
352
|
-
|
|
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: `
|
|
379
|
+
Client: `tcabci-read-js-client/${this._version}`
|
|
374
380
|
}
|
|
375
381
|
}
|
|
376
382
|
}
|