@nxtedition/deepstream.io-client-js 26.0.19 → 26.0.22
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/package.json
CHANGED
|
@@ -2,7 +2,6 @@ import * as utils from '../utils/utils.js'
|
|
|
2
2
|
import * as messageParser from './message-parser.js'
|
|
3
3
|
import * as messageBuilder from './message-builder.js'
|
|
4
4
|
import * as C from '../constants/constants.js'
|
|
5
|
-
import xxhash from 'xxhash-wasm'
|
|
6
5
|
import FixedQueue from '../utils/fixed-queue.js'
|
|
7
6
|
import Emitter from 'component-emitter2'
|
|
8
7
|
|
|
@@ -38,12 +37,6 @@ export default function Connection(client, url, options) {
|
|
|
38
37
|
this._url = new URL(url)
|
|
39
38
|
|
|
40
39
|
this._state = C.CONNECTION_STATE.CLOSED
|
|
41
|
-
|
|
42
|
-
this.hasher = null
|
|
43
|
-
xxhash().then((hasher) => {
|
|
44
|
-
this.hasher = hasher
|
|
45
|
-
this._createEndpoint()
|
|
46
|
-
})
|
|
47
40
|
}
|
|
48
41
|
|
|
49
42
|
Emitter(Connection.prototype)
|
|
@@ -166,7 +159,7 @@ Connection.prototype._sendAuthParams = function () {
|
|
|
166
159
|
this._setState(C.CONNECTION_STATE.AUTHENTICATING)
|
|
167
160
|
const authMessage = messageBuilder.getMsg(C.TOPIC.AUTH, C.ACTIONS.REQUEST, [
|
|
168
161
|
this._authParams,
|
|
169
|
-
'26.0.
|
|
162
|
+
'26.0.22',
|
|
170
163
|
utils.isNode
|
|
171
164
|
? `Node/${process.version}`
|
|
172
165
|
: globalThis.navigator && globalThis.navigator.userAgent,
|
|
@@ -51,9 +51,12 @@ export function getMsg(topic, action, data) {
|
|
|
51
51
|
const start = poolOffset
|
|
52
52
|
|
|
53
53
|
const headerSize = 8
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
for (let n = 0; n < headerSize; n++) {
|
|
55
|
+
poolBuffer[poolOffset++] = 0
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let headerPos = start
|
|
59
|
+
poolBuffer[headerPos++] = 128 + headerSize
|
|
57
60
|
|
|
58
61
|
poolBuffer[poolOffset++] = topic.charCodeAt(0)
|
|
59
62
|
poolBuffer[poolOffset++] = 31
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import * as rxjs from 'rxjs'
|
|
1
2
|
import * as C from '../constants/constants.js'
|
|
2
|
-
import
|
|
3
|
+
import { h64ToString } from '../utils/utils.js'
|
|
3
4
|
|
|
4
5
|
export default class Listener {
|
|
5
6
|
constructor(topic, pattern, callback, handler, { recursive = false, stringify = null } = {}) {
|
|
@@ -151,7 +152,7 @@ export default class Listener {
|
|
|
151
152
|
}
|
|
152
153
|
|
|
153
154
|
const body = typeof value !== 'string' ? this._stringify(value) : value
|
|
154
|
-
const hash =
|
|
155
|
+
const hash = h64ToString(body)
|
|
155
156
|
const version = `INF-${hash}`
|
|
156
157
|
|
|
157
158
|
if (provider.version !== version) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import * as rxjs from 'rxjs'
|
|
1
2
|
import * as C from '../constants/constants.js'
|
|
2
|
-
import
|
|
3
|
-
import rxjs from 'rxjs'
|
|
3
|
+
import { h64ToString } from '../utils/utils.js'
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const valuePipe = rxjs.pipe(
|
|
6
|
+
rxjs.map((value) => {
|
|
7
7
|
let data
|
|
8
8
|
if (value && typeof value === 'string') {
|
|
9
9
|
if (value.charAt(0) !== '{' && value.charAt(0) !== '[') {
|
|
@@ -18,7 +18,7 @@ const PIPE = rxjs.pipe(
|
|
|
18
18
|
|
|
19
19
|
return data
|
|
20
20
|
}),
|
|
21
|
-
|
|
21
|
+
rxjs.distinctUntilChanged(),
|
|
22
22
|
)
|
|
23
23
|
|
|
24
24
|
export default class Listener {
|
|
@@ -69,14 +69,14 @@ export default class Listener {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
if (value$) {
|
|
72
|
-
const subscription = value$.pipe(
|
|
72
|
+
const subscription = value$.pipe(valuePipe).subscribe({
|
|
73
73
|
next: (data) => {
|
|
74
74
|
if (data == null) {
|
|
75
75
|
this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN_REJECT, [this._pattern, name])
|
|
76
76
|
this._subscriptions.delete(name)
|
|
77
77
|
subscription.unsubscribe()
|
|
78
78
|
} else {
|
|
79
|
-
const version = `INF-${
|
|
79
|
+
const version = `INF-${h64ToString(data)}`
|
|
80
80
|
this._connection.sendMsg(this._topic, C.ACTIONS.UPDATE, [name, version, data])
|
|
81
81
|
}
|
|
82
82
|
},
|
package/src/utils/utils.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import xxhash from 'xxhash-wasm'
|
|
2
|
+
|
|
1
3
|
const NODE_ENV = typeof process !== 'undefined' && process.env && process.env.NODE_ENV
|
|
2
4
|
export const isNode = typeof process !== 'undefined' && process.toString() === '[object process]'
|
|
3
5
|
export const isProduction = NODE_ENV === 'production'
|
|
@@ -174,3 +176,17 @@ export function removeAbortListener(signal, handler) {
|
|
|
174
176
|
}
|
|
175
177
|
}
|
|
176
178
|
}
|
|
179
|
+
|
|
180
|
+
const HASHER = await xxhash()
|
|
181
|
+
|
|
182
|
+
export function h64(str) {
|
|
183
|
+
return HASHER.h64(str)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function h64ToString(str) {
|
|
187
|
+
return HASHER.h64ToString(str)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export function h64Raw(str) {
|
|
191
|
+
return HASHER.h64Raw(str)
|
|
192
|
+
}
|