infinispan 0.12.0 → 0.14.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.
- package/Dockerfile.server +8 -0
- package/README.md +5 -11
- package/docker-compose.yml +272 -0
- package/gen-asciidoc.sh +46 -0
- package/lib/codec.js +358 -27
- package/lib/functional.js +40 -7
- package/lib/infinispan.js +503 -52
- package/lib/io.js +399 -43
- package/lib/listeners.js +50 -3
- package/lib/near-cache.js +99 -0
- package/lib/protocols.js +560 -75
- package/lib/sasl/digest.js +22 -17
- package/lib/sasl/external.js +7 -4
- package/lib/sasl/factory.js +6 -5
- package/lib/sasl/oauthbearer.js +7 -5
- package/lib/sasl/plain.js +6 -4
- package/lib/sasl/scram.js +19 -11
- package/lib/utils.js +89 -24
- package/package.json +8 -7
- package/run-docker-testsuite.sh +72 -0
- package/types/index.d.ts +192 -1
- package/.eslintrc +0 -25
- package/.flowconfig +0 -6
- package/Jenkinsfile +0 -50
- package/Jenkinsfile-release +0 -63
- package/documentation/asciidoc/stories/assembly_client_usage_examples.adoc +0 -10
- package/documentation/asciidoc/stories/assembly_installation_configuration.adoc +0 -20
- package/documentation/asciidoc/titles/js_client.asciidoc +0 -28
- package/documentation/asciidoc/titles/stories.adoc +0 -5
- package/documentation/asciidoc/topics/attributes/community-attributes.adoc +0 -9
- package/documentation/asciidoc/topics/attributes/downstream-attributes.adoc +0 -2
- package/documentation/asciidoc/topics/code_examples/authentication-digest.js +0 -12
- package/documentation/asciidoc/topics/code_examples/authentication-external.js +0 -15
- package/documentation/asciidoc/topics/code_examples/authentication-oauthbearer.js +0 -10
- package/documentation/asciidoc/topics/code_examples/authentication-plain.js +0 -11
- package/documentation/asciidoc/topics/code_examples/authentication-scram.js +0 -11
- package/documentation/asciidoc/topics/code_examples/await-multiple-entries.js +0 -36
- package/documentation/asciidoc/topics/code_examples/await-single-entries.js +0 -29
- package/documentation/asciidoc/topics/code_examples/conditional-operations.js +0 -57
- package/documentation/asciidoc/topics/code_examples/connection-multiple-servers.js +0 -23
- package/documentation/asciidoc/topics/code_examples/connection-xsite-cluster-switch.js +0 -39
- package/documentation/asciidoc/topics/code_examples/connection-xsite.js +0 -13
- package/documentation/asciidoc/topics/code_examples/data-types.js +0 -30
- package/documentation/asciidoc/topics/code_examples/encryption-crypto-store.js +0 -11
- package/documentation/asciidoc/topics/code_examples/encryption-private-key.js +0 -13
- package/documentation/asciidoc/topics/code_examples/encryption-sni-hostname.js +0 -9
- package/documentation/asciidoc/topics/code_examples/encryption-trust-certs.js +0 -8
- package/documentation/asciidoc/topics/code_examples/ephemeral-data.js +0 -52
- package/documentation/asciidoc/topics/code_examples/hello-world.js +0 -42
- package/documentation/asciidoc/topics/code_examples/key-value-converter.js +0 -67
- package/documentation/asciidoc/topics/code_examples/logging-configuration.js +0 -2
- package/documentation/asciidoc/topics/code_examples/multiple-entries.js +0 -64
- package/documentation/asciidoc/topics/code_examples/queries.js +0 -92
- package/documentation/asciidoc/topics/code_examples/register-event-listener.js +0 -64
- package/documentation/asciidoc/topics/code_examples/sample-script-execute.js +0 -33
- package/documentation/asciidoc/topics/code_examples/sample-script.js +0 -3
- package/documentation/asciidoc/topics/code_examples/single-entries.js +0 -49
- package/documentation/asciidoc/topics/config_examples/logging.json +0 -14
- package/documentation/asciidoc/topics/proc_configuring_authentication.adoc +0 -16
- package/documentation/asciidoc/topics/proc_configuring_connections.adoc +0 -25
- package/documentation/asciidoc/topics/proc_configuring_connections_xsite.adoc +0 -18
- package/documentation/asciidoc/topics/proc_configuring_data_formats.adoc +0 -30
- package/documentation/asciidoc/topics/proc_configuring_encryption.adoc +0 -15
- package/documentation/asciidoc/topics/proc_configuring_logging.adoc +0 -28
- package/documentation/asciidoc/topics/proc_installing_clients.adoc +0 -58
- package/documentation/asciidoc/topics/proc_switching_clusters.adoc +0 -17
- package/documentation/asciidoc/topics/ref_authentication_mechanisms.adoc +0 -68
- package/documentation/asciidoc/topics/ref_client_usage.adoc +0 -128
- package/documentation/asciidoc/topics/ref_encryption.adoc +0 -71
- package/gen-jsdoc.sh +0 -6
- package/make-ssl.sh +0 -335
- package/memory-profiling/helper.js +0 -9
- package/memory-profiling/infinispan_memory_many_get.js +0 -50
- package/memory-profiling/infinispan_memory_one_get.js +0 -56
- package/release.sh +0 -19
- package/run-servers.sh +0 -171
- package/run-testsuite.sh +0 -6
- package/server/.keep +0 -0
- package/set-npm-auth-token.sh +0 -4
- package/smoke-tests.sh +0 -21
- package/spec/codec_spec.js +0 -224
- package/spec/configs/clean/infinispan.xml +0 -55
- package/spec/configs/infinispan-clustered.xml +0 -63
- package/spec/configs/infinispan-ssl.xml +0 -115
- package/spec/configs/infinispan-xsite-EARTH.xml +0 -187
- package/spec/configs/infinispan-xsite-MOON.xml +0 -189
- package/spec/configs/infinispan.xml +0 -77
- package/spec/functional_spec.js +0 -73
- package/spec/infinispan_auth_spec.js +0 -19
- package/spec/infinispan_cluster_spec.js +0 -176
- package/spec/infinispan_expiry_spec.js +0 -218
- package/spec/infinispan_failover_listener_spec.js +0 -52
- package/spec/infinispan_failover_spec.js +0 -63
- package/spec/infinispan_json_spec.js +0 -182
- package/spec/infinispan_local_spec.js +0 -354
- package/spec/infinispan_ssl_spec.js +0 -442
- package/spec/infinispan_stress_spec.js +0 -32
- package/spec/infinispan_xsite_spec.js +0 -99
- package/spec/protocols_spec.js +0 -82
- package/spec/protostream_spec.js +0 -237
- package/spec/tests.js +0 -28
- package/spec/utils/test-log4js.json +0 -14
- package/spec/utils/testing.js +0 -762
- package/spec/utils/typed-cachemanager-put-get.js +0 -3
- package/spec/utils/typed-null-return-dist.js +0 -2
- package/spec/utils/typed-null-return.js +0 -2
- package/spec/utils/typed-put-get-dist.js +0 -3
- package/spec/utils/typed-put-get-unicode.js +0 -3
- package/spec/utils/typed-put-get.js +0 -3
- package/spec/utils/typed-size.js +0 -2
- package/spec/utils_spec.js +0 -154
- package/spec-manual/infinispan_manual_stress_get_spec.js +0 -50
- package/spec-manual/infinispan_manual_stress_iterate_spec.js +0 -86
package/lib/sasl/digest.js
CHANGED
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
* References:
|
|
17
17
|
* - [RFC 2831](http://tools.ietf.org/html/rfc2831)
|
|
18
18
|
*
|
|
19
|
+
* @param {Object} options Configuration options.
|
|
20
|
+
* @returns {void}
|
|
19
21
|
* @api public
|
|
20
22
|
*/
|
|
21
23
|
function Mechanism(options) {
|
|
@@ -36,7 +38,8 @@
|
|
|
36
38
|
* - `serviceType`
|
|
37
39
|
* - `authzid` authorization identity (optional)
|
|
38
40
|
*
|
|
39
|
-
* @param {Object} cred
|
|
41
|
+
* @param {Object} cred Credentials containing username, password, host, serviceType, and optional authzid.
|
|
42
|
+
* @returns {String} The encoded DIGEST response string.
|
|
40
43
|
* @api public
|
|
41
44
|
*/
|
|
42
45
|
Mechanism.prototype.response = function (cred) {
|
|
@@ -56,9 +59,9 @@
|
|
|
56
59
|
// the fact that TLS has largely superseded this functionality,
|
|
57
60
|
// implementing it is a low priority.
|
|
58
61
|
|
|
59
|
-
var uri = cred.serviceType
|
|
62
|
+
var uri = `${cred.serviceType }/${ cred.host}`;
|
|
60
63
|
if (cred.serviceName && cred.host !== cred.serviceName) {
|
|
61
|
-
uri +=
|
|
64
|
+
uri += `/${ serviceName}`;
|
|
62
65
|
}
|
|
63
66
|
var realm = cred.realm || this._realm || ''
|
|
64
67
|
, cnonce = this._genNonce()
|
|
@@ -68,13 +71,13 @@
|
|
|
68
71
|
, ha2
|
|
69
72
|
, digest;
|
|
70
73
|
var str = '';
|
|
71
|
-
str +=
|
|
72
|
-
if (realm) { str +=
|
|
73
|
-
str +=
|
|
74
|
-
str +=
|
|
75
|
-
str +=
|
|
76
|
-
str +=
|
|
77
|
-
str +=
|
|
74
|
+
str += `username="${ cred.username }"`;
|
|
75
|
+
if (realm) { str += `,realm="${ realm }"`; };
|
|
76
|
+
str += `,nonce="${ this._nonce }"`;
|
|
77
|
+
str += `,cnonce="${ cnonce }"`;
|
|
78
|
+
str += `,nc=${ nc}`;
|
|
79
|
+
str += `,qop=${ qop}`;
|
|
80
|
+
str += `,digest-uri="${ uri }"`;
|
|
78
81
|
var base = crypto.createHash('md5')
|
|
79
82
|
.update(cred.username)
|
|
80
83
|
.update(':')
|
|
@@ -112,17 +115,17 @@
|
|
|
112
115
|
.update(':')
|
|
113
116
|
.update(ha2)
|
|
114
117
|
.digest('hex');
|
|
115
|
-
str +=
|
|
118
|
+
str += `,response=${ digest}`;
|
|
116
119
|
if (this._charset == 'utf-8') { str += ',charset=utf-8'; }
|
|
117
|
-
if (cred.authzid) { str +=
|
|
120
|
+
if (cred.authzid) { str += `authzid="${ cred.authzid }"`; }
|
|
118
121
|
return str;
|
|
119
122
|
};
|
|
120
123
|
|
|
121
124
|
/**
|
|
122
125
|
* Decode a challenge issued by the server.
|
|
123
126
|
*
|
|
124
|
-
* @param {String} chal
|
|
125
|
-
* @
|
|
127
|
+
* @param {String} chal Challenge string from server.
|
|
128
|
+
* @returns {Mechanism} for chaining
|
|
126
129
|
* @api public
|
|
127
130
|
*/
|
|
128
131
|
Mechanism.prototype.challenge = function (chal) {
|
|
@@ -146,6 +149,8 @@
|
|
|
146
149
|
/**
|
|
147
150
|
* Parse challenge.
|
|
148
151
|
*
|
|
152
|
+
* @param {String} chal Challenge string to parse.
|
|
153
|
+
* @returns {Object} Parsed directives.
|
|
149
154
|
* @api private
|
|
150
155
|
*/
|
|
151
156
|
function parse(chal) {
|
|
@@ -166,8 +171,8 @@
|
|
|
166
171
|
* genNonce(10)();
|
|
167
172
|
* // => "FDaS435D2z"
|
|
168
173
|
*
|
|
169
|
-
* @param {Number} len
|
|
170
|
-
* @
|
|
174
|
+
* @param {Number} len Length of the nonce.
|
|
175
|
+
* @returns {Function} A function that generates a random nonce.
|
|
171
176
|
* @api private
|
|
172
177
|
*/
|
|
173
178
|
function genNonce(len) {
|
|
@@ -180,7 +185,7 @@
|
|
|
180
185
|
buf.push(chars[Math.random() * charlen | 0]);
|
|
181
186
|
}
|
|
182
187
|
return buf.join('');
|
|
183
|
-
}
|
|
188
|
+
};
|
|
184
189
|
}
|
|
185
190
|
|
|
186
191
|
exports = module.exports = Mechanism;
|
package/lib/sasl/external.js
CHANGED
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
* This class implements the EXTERNAL SASL mechanism.
|
|
15
15
|
*
|
|
16
16
|
* The EXTERNAL SASL mechanism provides support for authentication using
|
|
17
|
-
* credentials established by external means.
|
|
17
|
+
* credentials established by external means.
|
|
18
18
|
*
|
|
19
19
|
* References:
|
|
20
20
|
* - [RFC 4422](http://tools.ietf.org/html/rfc4422)
|
|
21
21
|
*
|
|
22
|
+
* @returns {void}
|
|
22
23
|
* @api public
|
|
23
24
|
*/
|
|
24
25
|
function Mechanism() {
|
|
@@ -33,7 +34,8 @@
|
|
|
33
34
|
* Options:
|
|
34
35
|
* - `authzid` authorization identity (optional)
|
|
35
36
|
*
|
|
36
|
-
* @param {Object} cred
|
|
37
|
+
* @param {Object} cred Credentials containing optional authzid.
|
|
38
|
+
* @returns {String} The authorization identity or empty string.
|
|
37
39
|
* @api public
|
|
38
40
|
*/
|
|
39
41
|
Mechanism.prototype.response = function (cred) {
|
|
@@ -43,10 +45,11 @@
|
|
|
43
45
|
/**
|
|
44
46
|
* Decode a challenge issued by the server.
|
|
45
47
|
*
|
|
46
|
-
* @param {String} chal
|
|
48
|
+
* @param {String} chal Challenge string from server.
|
|
49
|
+
* @returns {void}
|
|
47
50
|
* @api public
|
|
48
51
|
*/
|
|
49
|
-
Mechanism.prototype.challenge = function (chal) {
|
|
52
|
+
Mechanism.prototype.challenge = function (chal) { // eslint-disable-line no-unused-vars
|
|
50
53
|
};
|
|
51
54
|
|
|
52
55
|
exports = module.exports = Mechanism;
|
package/lib/sasl/factory.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
/**
|
|
12
12
|
* `Factory` constructor.
|
|
13
13
|
*
|
|
14
|
+
* @returns {void}
|
|
14
15
|
* @api public
|
|
15
16
|
*/
|
|
16
17
|
function Factory() {
|
|
@@ -27,9 +28,9 @@
|
|
|
27
28
|
*
|
|
28
29
|
* factory.use('XFOO', FooMechanism);
|
|
29
30
|
*
|
|
30
|
-
* @param {String|Mechanism} name
|
|
31
|
-
* @param {Mechanism} mech
|
|
32
|
-
* @
|
|
31
|
+
* @param {String|Mechanism} name Mechanism name or constructor.
|
|
32
|
+
* @param {Mechanism} mech Mechanism constructor when name is a string.
|
|
33
|
+
* @returns {Factory} for chaining
|
|
33
34
|
* @api public
|
|
34
35
|
*/
|
|
35
36
|
Factory.prototype.use = function(name, mech) {
|
|
@@ -50,8 +51,8 @@
|
|
|
50
51
|
*
|
|
51
52
|
* var mech = factory.create(['FOO', 'BAR']);
|
|
52
53
|
*
|
|
53
|
-
* @param {Array} mechs
|
|
54
|
-
* @
|
|
54
|
+
* @param {Array} mechs List of supported mechanism names.
|
|
55
|
+
* @returns {Mechanism} A new mechanism instance or null.
|
|
55
56
|
* @api public
|
|
56
57
|
*/
|
|
57
58
|
Factory.prototype.create = function(mechs) {
|
package/lib/sasl/oauthbearer.js
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* References:
|
|
19
19
|
* - [RFC 4616](http://tools.ietf.org/html/rfc4616)
|
|
20
20
|
*
|
|
21
|
+
* @returns {void}
|
|
21
22
|
* @api public
|
|
22
23
|
*/
|
|
23
24
|
function Mechanism() {
|
|
@@ -33,13 +34,14 @@
|
|
|
33
34
|
* - `token` an OAuth token
|
|
34
35
|
* - `authzid` authorization identity (optional)
|
|
35
36
|
*
|
|
36
|
-
* @param {Object} cred
|
|
37
|
+
* @param {Object} cred Credentials containing token and optional authzid.
|
|
38
|
+
* @returns {String} The encoded OAUTHBEARER response string.
|
|
37
39
|
* @api public
|
|
38
40
|
*/
|
|
39
41
|
Mechanism.prototype.response = function (cred) {
|
|
40
42
|
var str = 'n,';
|
|
41
43
|
if (cred.authzid) {
|
|
42
|
-
str +=
|
|
44
|
+
str += `a=${ cred.authzid}`;
|
|
43
45
|
}
|
|
44
46
|
str += ',%x01,auth=Bearer ';
|
|
45
47
|
str += cred.token;
|
|
@@ -50,11 +52,11 @@
|
|
|
50
52
|
/**
|
|
51
53
|
* Decode a challenge issued by the server.
|
|
52
54
|
*
|
|
53
|
-
* @param {String} chal
|
|
54
|
-
* @
|
|
55
|
+
* @param {String} chal Challenge string from server.
|
|
56
|
+
* @returns {Mechanism} for chaining
|
|
55
57
|
* @api public
|
|
56
58
|
*/
|
|
57
|
-
Mechanism.prototype.challenge = function (chal) {
|
|
59
|
+
Mechanism.prototype.challenge = function (chal) { // eslint-disable-line no-unused-vars
|
|
58
60
|
return this;
|
|
59
61
|
};
|
|
60
62
|
|
package/lib/sasl/plain.js
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
* References:
|
|
21
21
|
* - [RFC 4616](http://tools.ietf.org/html/rfc4616)
|
|
22
22
|
*
|
|
23
|
+
* @returns {void}
|
|
23
24
|
* @api public
|
|
24
25
|
*/
|
|
25
26
|
function Mechanism() {
|
|
@@ -36,7 +37,8 @@
|
|
|
36
37
|
* - `password`
|
|
37
38
|
* - `authzid` authorization identity (optional)
|
|
38
39
|
*
|
|
39
|
-
* @param {Object} cred
|
|
40
|
+
* @param {Object} cred Credentials containing username, password, and optional authzid.
|
|
41
|
+
* @returns {String} The encoded PLAIN response string.
|
|
40
42
|
* @api public
|
|
41
43
|
*/
|
|
42
44
|
Mechanism.prototype.response = function (cred) {
|
|
@@ -52,11 +54,11 @@
|
|
|
52
54
|
/**
|
|
53
55
|
* Decode a challenge issued by the server.
|
|
54
56
|
*
|
|
55
|
-
* @param {String} chal
|
|
56
|
-
* @
|
|
57
|
+
* @param {String} chal Challenge string from server.
|
|
58
|
+
* @returns {Mechanism} for chaining
|
|
57
59
|
* @api public
|
|
58
60
|
*/
|
|
59
|
-
Mechanism.prototype.challenge = function (chal) {
|
|
61
|
+
Mechanism.prototype.challenge = function (chal) { // eslint-disable-line no-unused-vars
|
|
60
62
|
return this;
|
|
61
63
|
};
|
|
62
64
|
|
package/lib/sasl/scram.js
CHANGED
|
@@ -11,6 +11,12 @@
|
|
|
11
11
|
var CLIENT_KEY = 'Client Key';
|
|
12
12
|
var SERVER_KEY = 'Server Key';
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Constructs a SCRAM SASL mechanism instance.
|
|
16
|
+
* @param {Object} [options] Optional configuration with a genNonce function.
|
|
17
|
+
* @constructs Mechanism
|
|
18
|
+
* @returns {void}
|
|
19
|
+
*/
|
|
14
20
|
function Mechanism(options) {
|
|
15
21
|
options = options || {};
|
|
16
22
|
this._genNonce = options.genNonce || utils.genNonce;
|
|
@@ -40,6 +46,8 @@
|
|
|
40
46
|
/**
|
|
41
47
|
* Parse challenge.
|
|
42
48
|
*
|
|
49
|
+
* @param {String} chal Challenge string to parse.
|
|
50
|
+
* @returns {Object} Parsed key-value pairs.
|
|
43
51
|
* @api private
|
|
44
52
|
*/
|
|
45
53
|
function parse(chal) {
|
|
@@ -60,15 +68,15 @@
|
|
|
60
68
|
|
|
61
69
|
var authzid = '';
|
|
62
70
|
if (cred.authzid) {
|
|
63
|
-
authzid =
|
|
71
|
+
authzid = `a=${ utils.saslname(cred.authzid)}`;
|
|
64
72
|
}
|
|
65
73
|
|
|
66
|
-
mech._gs2Header =
|
|
74
|
+
mech._gs2Header = `n,${ authzid },`;
|
|
67
75
|
|
|
68
|
-
var nonce =
|
|
69
|
-
var username =
|
|
76
|
+
var nonce = `r=${ mech._cnonce}`;
|
|
77
|
+
var username = `n=${ utils.saslname(cred.username || '')}`;
|
|
70
78
|
|
|
71
|
-
mech._clientFirstMessageBare = username
|
|
79
|
+
mech._clientFirstMessageBare = `${username },${ nonce}`;
|
|
72
80
|
var result = mech._gs2Header + mech._clientFirstMessageBare;
|
|
73
81
|
|
|
74
82
|
mech._stage = 'two';
|
|
@@ -79,11 +87,11 @@
|
|
|
79
87
|
|
|
80
88
|
RESP.two = function (mech, cred) {
|
|
81
89
|
var gs2Header = Buffer.from(mech._gs2Header).toString('base64');
|
|
82
|
-
mech._clientFinalMessageWithoutProof =
|
|
90
|
+
mech._clientFinalMessageWithoutProof = `c=${ gs2Header },r=${ mech._nonce}`;
|
|
83
91
|
|
|
84
92
|
var saltedPassword, clientKey, serverKey;
|
|
85
93
|
|
|
86
|
-
var algorithm = cred.mechanism.substring(6).toLowerCase().replace(
|
|
94
|
+
var algorithm = cred.mechanism.substring(6).toLowerCase().replace('-', '');
|
|
87
95
|
|
|
88
96
|
// If our cached salt is the same, we can reuse cached credentials to speed
|
|
89
97
|
// up the hashing process.
|
|
@@ -103,16 +111,16 @@
|
|
|
103
111
|
}
|
|
104
112
|
|
|
105
113
|
var storedKey = bitops.H(algorithm, clientKey);
|
|
106
|
-
var authMessage = mech._clientFirstMessageBare
|
|
107
|
-
mech._challenge
|
|
108
|
-
mech._clientFinalMessageWithoutProof
|
|
114
|
+
var authMessage = `${mech._clientFirstMessageBare },${
|
|
115
|
+
mech._challenge },${
|
|
116
|
+
mech._clientFinalMessageWithoutProof}`;
|
|
109
117
|
var clientSignature = bitops.HMAC(algorithm, storedKey, authMessage);
|
|
110
118
|
|
|
111
119
|
var clientProof = bitops.XOR(clientKey, clientSignature).toString('base64');
|
|
112
120
|
|
|
113
121
|
mech._serverSignature = bitops.HMAC(algorithm, serverKey, authMessage);
|
|
114
122
|
|
|
115
|
-
var result = mech._clientFinalMessageWithoutProof
|
|
123
|
+
var result = `${mech._clientFinalMessageWithoutProof },p=${ clientProof}`;
|
|
116
124
|
|
|
117
125
|
mech._stage = 'final';
|
|
118
126
|
|
package/lib/utils.js
CHANGED
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
exports.context = function(size) {
|
|
16
16
|
return {buf: Buffer.alloc(size), offset: 0, id: parseInt(_.uniqueId()), triedAddrs: []};
|
|
17
17
|
};
|
|
18
|
-
exports.showAddress = function(addr) { return addr.host
|
|
18
|
+
exports.showAddress = function(addr) { return `${addr.host }:${ addr.port}`; };
|
|
19
19
|
exports.showArrayAddress = function(addrs) {
|
|
20
|
-
return [
|
|
20
|
+
return ['[', _.map(addrs, function(a) { return exports.showAddress(a); }).join(','), ']'].join('');
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
exports.parse = function (chal) {
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
logger.trace.apply(logger, fun());
|
|
90
90
|
},
|
|
91
91
|
error: function() { logger.error.apply(logger, arguments); }
|
|
92
|
-
}
|
|
92
|
+
};
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
var ReplayableBuffer = function() {
|
|
@@ -129,42 +129,69 @@
|
|
|
129
129
|
buf.copy(b);
|
|
130
130
|
return b;
|
|
131
131
|
}
|
|
132
|
-
}
|
|
132
|
+
};
|
|
133
133
|
};
|
|
134
134
|
|
|
135
135
|
var polyToString = f.dispatch(
|
|
136
|
-
function(s) { return !f.existy(s) ? 'undefined' : undefined },
|
|
137
|
-
function(s) { return _.isString(s) ? (s.length > 1024 ? s.substring(0, 1024)
|
|
138
|
-
function(s) { return _.isArray(s) ? stringifyArray(s) : undefined },
|
|
139
|
-
function(s) { return _.isObject(s) ? JSON.stringify(s) : undefined },
|
|
140
|
-
function(s) { return s.toString() });
|
|
141
|
-
|
|
136
|
+
function(s) { return !f.existy(s) ? 'undefined' : undefined; },
|
|
137
|
+
function(s) { return _.isString(s) ? (s.length > 1024 ? `${s.substring(0, 1024) }...` : s) : undefined;},
|
|
138
|
+
function(s) { return _.isArray(s) ? stringifyArray(s) : undefined; },
|
|
139
|
+
function(s) { return _.isObject(s) ? JSON.stringify(s) : undefined; },
|
|
140
|
+
function(s) { return s.toString(); });
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Converts a value to its string representation using polymorphic dispatch.
|
|
144
|
+
* @param {*} o Value to convert to string.
|
|
145
|
+
* @returns {string} String representation of the value.
|
|
146
|
+
*/
|
|
142
147
|
function str(o) {
|
|
143
148
|
return polyToString(o);
|
|
144
149
|
}
|
|
145
150
|
|
|
151
|
+
/**
|
|
152
|
+
* Converts an array to a bracketed, comma-separated string.
|
|
153
|
+
* @param {Array} ary Array to stringify.
|
|
154
|
+
* @returns {string} String representation of the array.
|
|
155
|
+
*/
|
|
146
156
|
function stringifyArray(ary) {
|
|
147
|
-
return [
|
|
157
|
+
return ['[', _.map(ary, polyToString).join(','), ']'].join('');
|
|
148
158
|
}
|
|
149
159
|
|
|
160
|
+
/**
|
|
161
|
+
* Normalizes server address arguments into a uniform array of address objects.
|
|
162
|
+
* @param {Object|Object[]|undefined} args Address object, array of addresses, or undefined.
|
|
163
|
+
* @returns {Object[]} Array of address objects with host and port properties.
|
|
164
|
+
*/
|
|
150
165
|
function normalizeAddresses(args) {
|
|
151
166
|
var normalizer = f.dispatch(
|
|
152
|
-
function(xs) { return _.isArray(xs) ? xs : undefined },
|
|
153
|
-
function(x) { return _.isObject(x) ? [x] : undefined },
|
|
167
|
+
function(xs) { return _.isArray(xs) ? xs : undefined; },
|
|
168
|
+
function(x) { return _.isObject(x) ? [x] : undefined; },
|
|
154
169
|
function(x) {
|
|
155
|
-
if (f.existy(x)) throw new Error(
|
|
156
|
-
return [{port: 11222, host: '127.0.0.1'}]
|
|
170
|
+
if (f.existy(x)) throw new Error(`Unknown server addresses: ${ x}`);
|
|
171
|
+
return [{port: 11222, host: '127.0.0.1'}];
|
|
157
172
|
});
|
|
158
173
|
return normalizer(args);
|
|
159
174
|
}
|
|
160
175
|
|
|
161
176
|
var MurmurHash3 = function() {
|
|
177
|
+
/**
|
|
178
|
+
* XORs two 64-bit integers represented as two-element 32-bit int arrays.
|
|
179
|
+
* @param {number[]} m First 64-bit integer as [high, low].
|
|
180
|
+
* @param {number[]} n Second 64-bit integer as [high, low].
|
|
181
|
+
* @returns {number[]} XOR result as [high, low].
|
|
182
|
+
*/
|
|
162
183
|
function x64Xor(m, n) {
|
|
163
184
|
// Given two 64bit ints (as an array of two 32bit ints) returns the two
|
|
164
185
|
// xored together as a 64bit int (as an array of two 32bit ints).
|
|
165
186
|
return [m[0] ^ n[0], m[1] ^ n[1]];
|
|
166
187
|
}
|
|
167
188
|
|
|
189
|
+
/**
|
|
190
|
+
* Multiplies two 64-bit integers represented as two-element 32-bit int arrays.
|
|
191
|
+
* @param {number[]} m First 64-bit integer as [high, low].
|
|
192
|
+
* @param {number[]} n Second 64-bit integer as [high, low].
|
|
193
|
+
* @returns {number[]} Product as [high, low].
|
|
194
|
+
*/
|
|
168
195
|
function x64Multiply(m, n) {
|
|
169
196
|
// Given two 64bit ints (as an array of two 32bit ints) returns the two
|
|
170
197
|
// multiplied together as a 64bit int (as an array of two 32bit ints).
|
|
@@ -202,6 +229,12 @@
|
|
|
202
229
|
return [(o[0] << 16) | o[1], (o[2] << 16) | o[3]];
|
|
203
230
|
}
|
|
204
231
|
|
|
232
|
+
/**
|
|
233
|
+
* Rotates a 64-bit integer left by the given number of bit positions.
|
|
234
|
+
* @param {number[]} m 64-bit integer as [high, low].
|
|
235
|
+
* @param {number} n Number of bit positions to rotate.
|
|
236
|
+
* @returns {number[]} Rotated result as [high, low].
|
|
237
|
+
*/
|
|
205
238
|
function x64Rotl(m, n) {
|
|
206
239
|
// Given a 64bit int (as an array of two 32bit ints) and an int
|
|
207
240
|
// representing a number of bit positions, returns the 64bit int (as an
|
|
@@ -218,6 +251,12 @@
|
|
|
218
251
|
}
|
|
219
252
|
}
|
|
220
253
|
|
|
254
|
+
/**
|
|
255
|
+
* Adds two 64-bit integers represented as two-element 32-bit int arrays.
|
|
256
|
+
* @param {number[]} m First 64-bit integer as [high, low].
|
|
257
|
+
* @param {number[]} n Second 64-bit integer as [high, low].
|
|
258
|
+
* @returns {number[]} Sum as [high, low].
|
|
259
|
+
*/
|
|
221
260
|
function x64Add(m, n) {
|
|
222
261
|
// Given two 64bit ints (as an array of two 32bit ints) returns the two
|
|
223
262
|
// added together as a 64bit int (as an array of two 32bit ints).
|
|
@@ -243,6 +282,12 @@
|
|
|
243
282
|
return [(o[0] << 16) | o[1], (o[2] << 16) | o[3]];
|
|
244
283
|
}
|
|
245
284
|
|
|
285
|
+
/**
|
|
286
|
+
* Shifts a 64-bit integer left by the given number of bit positions.
|
|
287
|
+
* @param {number[]} m 64-bit integer as [high, low].
|
|
288
|
+
* @param {number} n Number of bit positions to shift.
|
|
289
|
+
* @returns {number[]} Shifted result as [high, low].
|
|
290
|
+
*/
|
|
246
291
|
function x64LeftShift(m, n) {
|
|
247
292
|
// Given a 64bit int (as an array of two 32bit ints) and an int
|
|
248
293
|
// representing a number of bit positions, returns the 64bit int (as an
|
|
@@ -257,6 +302,12 @@
|
|
|
257
302
|
return [m[1] << (n - 32), 0];
|
|
258
303
|
}
|
|
259
304
|
|
|
305
|
+
/**
|
|
306
|
+
* Reads a 64-bit block from the key buffer at the given byte index.
|
|
307
|
+
* @param {Buffer} key Key buffer to read from.
|
|
308
|
+
* @param {number} i Byte offset into the key buffer.
|
|
309
|
+
* @returns {number[]} 64-bit block as [high, low].
|
|
310
|
+
*/
|
|
260
311
|
function getblock(key, i) {
|
|
261
312
|
return [
|
|
262
313
|
((key[i + 4] & 0xff))
|
|
@@ -270,6 +321,11 @@
|
|
|
270
321
|
];
|
|
271
322
|
}
|
|
272
323
|
|
|
324
|
+
/**
|
|
325
|
+
* Performs the MurmurHash3 block mix operation on the hash state.
|
|
326
|
+
* @param {Object} state Mutable hash state with h1, h2, k1, k2, c1, c2 fields.
|
|
327
|
+
* @returns {void}
|
|
328
|
+
*/
|
|
273
329
|
function bmix(state) {
|
|
274
330
|
state.k1 = x64Multiply(state.k1, state.c1);
|
|
275
331
|
state.k1 = x64Rotl(state.k1, 23);
|
|
@@ -293,6 +349,11 @@
|
|
|
293
349
|
state.c2 = x64Add(x64Multiply(state.c2, [0, 5]), [0, 0x6bce6396]);
|
|
294
350
|
}
|
|
295
351
|
|
|
352
|
+
/**
|
|
353
|
+
* Applies the MurmurHash3 final mix (fmix) to a 64-bit block.
|
|
354
|
+
* @param {number[]} h 64-bit block as [high, low].
|
|
355
|
+
* @returns {number[]} Mixed result as [high, low].
|
|
356
|
+
*/
|
|
296
357
|
function x64Fmix(h) {
|
|
297
358
|
// Given a block, returns murmurHash3's final x64 mix of that block.
|
|
298
359
|
// (`[0, h[0] >>> 1]` is a 33 bit unsigned right shift. This is the
|
|
@@ -305,17 +366,21 @@
|
|
|
305
366
|
return h;
|
|
306
367
|
}
|
|
307
368
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
}
|
|
314
|
-
|
|
369
|
+
/**
|
|
370
|
+
* Converts a 32-bit integer to a 64-bit representation as a two-element array.
|
|
371
|
+
* @param {number} num 32-bit integer.
|
|
372
|
+
* @returns {number[]} 64-bit representation as [high, low].
|
|
373
|
+
*/
|
|
315
374
|
function _x32tox64(num) {
|
|
316
375
|
return num < 0 ? [0xffffffff, num] : [0, num];
|
|
317
376
|
}
|
|
318
377
|
|
|
378
|
+
/**
|
|
379
|
+
* Computes the MurmurHash3 x64 128-bit hash and returns the first 64 bits.
|
|
380
|
+
* @param {Buffer} key Key buffer to hash.
|
|
381
|
+
* @param {number[]} seed 64-bit seed as [high, low].
|
|
382
|
+
* @returns {number[]} First 64-bit hash value as [high, low].
|
|
383
|
+
*/
|
|
319
384
|
function murmurHash3_x64_64(key, seed) {
|
|
320
385
|
var state = {};
|
|
321
386
|
|
|
@@ -389,7 +454,7 @@
|
|
|
389
454
|
var h = murmurHash3_x64_64(key, [0, 9001]);
|
|
390
455
|
return h[0] >>> 32;
|
|
391
456
|
}
|
|
392
|
-
}
|
|
393
|
-
}
|
|
457
|
+
};
|
|
458
|
+
};
|
|
394
459
|
|
|
395
460
|
}.call(this));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "infinispan",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Infinispan Javascript client",
|
|
5
5
|
"main": "index",
|
|
6
6
|
"typings": "./types",
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
"test": "test"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
-
"lint": "eslint --ignore-path .gitignore .",
|
|
12
|
-
"test": "
|
|
11
|
+
"lint": "eslint --ignore-path .gitignore lib spec index.js",
|
|
12
|
+
"test": "jasmine"
|
|
13
13
|
},
|
|
14
|
-
"author": "
|
|
14
|
+
"author": "Infinispan Community",
|
|
15
15
|
"license": "Apache-2.0",
|
|
16
16
|
"keywords": [
|
|
17
17
|
"infinispan",
|
|
@@ -24,18 +24,19 @@
|
|
|
24
24
|
],
|
|
25
25
|
"repository": {
|
|
26
26
|
"type": "git",
|
|
27
|
-
"url": "https://github.com/infinispan/js-client"
|
|
27
|
+
"url": "git+https://github.com/infinispan/js-client.git"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"buffer-xor": "^2.0.2",
|
|
31
|
+
"jsdoc": "^4.0.2",
|
|
31
32
|
"log4js": "^6.4.6",
|
|
32
33
|
"protobufjs": "^7.0.0",
|
|
33
34
|
"underscore": "^1.13.3",
|
|
34
|
-
"urllib": "^
|
|
35
|
+
"urllib": "^4.9.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"eslint": "^8.26.0",
|
|
38
|
-
"jasmine
|
|
39
|
+
"jasmine": "^6.1.0",
|
|
39
40
|
"long": "^5.2.3"
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
|
|
5
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
+
cd "$SCRIPT_DIR"
|
|
7
|
+
|
|
8
|
+
COMPOSE_PROJECT="ispn-test"
|
|
9
|
+
|
|
10
|
+
# Always tear down on exit
|
|
11
|
+
cleanup() {
|
|
12
|
+
echo "Tearing down Docker containers..."
|
|
13
|
+
docker compose -p "$COMPOSE_PROJECT" --profile failover down --remove-orphans 2>/dev/null || true
|
|
14
|
+
}
|
|
15
|
+
trap cleanup EXIT
|
|
16
|
+
|
|
17
|
+
# ── Step 1: Generate SSL certificates if needed ─────────────────────────
|
|
18
|
+
if [ ! -f "out/ssl/server/server.p12" ]; then
|
|
19
|
+
echo "Generating SSL certificates..."
|
|
20
|
+
./make-ssl.sh
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
# ── Step 2: Start containers ────────────────────────────────────────────
|
|
24
|
+
echo "Starting Infinispan containers..."
|
|
25
|
+
docker compose -p "$COMPOSE_PROJECT" up -d --wait
|
|
26
|
+
docker compose -p "$COMPOSE_PROJECT" --profile failover create server-failover-one server-failover-two server-failover-three
|
|
27
|
+
|
|
28
|
+
# ── Step 3: Detect container IPs ────────────────────────────────────────
|
|
29
|
+
get_container_ip() {
|
|
30
|
+
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$1"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export ISPN_LOCAL_HOST=$(get_container_ip ispn-local)
|
|
34
|
+
export ISPN_CLUSTER1_HOST=$(get_container_ip ispn-cluster-1)
|
|
35
|
+
export ISPN_CLUSTER2_HOST=$(get_container_ip ispn-cluster-2)
|
|
36
|
+
export ISPN_CLUSTER3_HOST=$(get_container_ip ispn-cluster-3)
|
|
37
|
+
export ISPN_SSL_HOST=$(get_container_ip ispn-ssl)
|
|
38
|
+
export ISPN_EARTH_HOST=$(get_container_ip ispn-earth)
|
|
39
|
+
export ISPN_MOON_HOST=$(get_container_ip ispn-moon)
|
|
40
|
+
export ISPN_FAILOVER1_HOST=$(get_container_ip ispn-failover-1)
|
|
41
|
+
export ISPN_FAILOVER2_HOST=$(get_container_ip ispn-failover-2)
|
|
42
|
+
export ISPN_FAILOVER3_HOST=$(get_container_ip ispn-failover-3)
|
|
43
|
+
export ISPN_DOCKER=true
|
|
44
|
+
|
|
45
|
+
echo "Container IPs:"
|
|
46
|
+
echo " local: $ISPN_LOCAL_HOST"
|
|
47
|
+
echo " cluster: $ISPN_CLUSTER1_HOST, $ISPN_CLUSTER2_HOST, $ISPN_CLUSTER3_HOST"
|
|
48
|
+
echo " ssl: $ISPN_SSL_HOST"
|
|
49
|
+
echo " failover: $ISPN_FAILOVER1_HOST, $ISPN_FAILOVER2_HOST, $ISPN_FAILOVER3_HOST"
|
|
50
|
+
echo " earth: $ISPN_EARTH_HOST"
|
|
51
|
+
echo " moon: $ISPN_MOON_HOST"
|
|
52
|
+
|
|
53
|
+
# ── Step 4: Wait for cluster to form ────────────────────────────────────
|
|
54
|
+
echo "Waiting for cluster to form..."
|
|
55
|
+
MAX_RETRIES=30
|
|
56
|
+
for i in $(seq 1 $MAX_RETRIES); do
|
|
57
|
+
CLUSTER_SIZE=$(curl -sf --digest -u admin:pass "http://$ISPN_CLUSTER1_HOST:11222/rest/v2/container" 2>/dev/null | python3 -c "import sys,json; print(json.load(sys.stdin).get('cluster_size',0))" 2>/dev/null || echo "0")
|
|
58
|
+
if [ "$CLUSTER_SIZE" = "3" ]; then
|
|
59
|
+
echo "Cluster formed with 3 nodes."
|
|
60
|
+
break
|
|
61
|
+
fi
|
|
62
|
+
if [ "$i" = "$MAX_RETRIES" ]; then
|
|
63
|
+
echo "ERROR: Cluster did not form within timeout (size=$CLUSTER_SIZE)"
|
|
64
|
+
exit 1
|
|
65
|
+
fi
|
|
66
|
+
echo " Cluster size: $CLUSTER_SIZE (attempt $i/$MAX_RETRIES)"
|
|
67
|
+
sleep 5
|
|
68
|
+
done
|
|
69
|
+
|
|
70
|
+
# ── Step 5: Run tests ──────────────────────────────────────────────────
|
|
71
|
+
echo "Running tests..."
|
|
72
|
+
npx jasmine "$@"
|