quickblox 2.17.2-beta.2-logger → 2.17.3-logger

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.
Files changed (124) hide show
  1. package/LICENSE +330 -201
  2. package/README.md +2 -2
  3. package/package.json +1 -2
  4. package/quickblox.js +19389 -21772
  5. package/quickblox.min.js +1 -1
  6. package/src/libs/strophe/strophe.common.js +6657 -0
  7. package/src/libs/strophe/strophe.esm.js +6649 -0
  8. package/src/libs/strophe/strophe.umd.js +6862 -0
  9. package/src/libs/strophe/strophe.umd.min.js +1 -0
  10. package/src/modules/chat/qbChat.js +131 -11
  11. package/src/modules/webrtc/qbWebRTCSignalingProcessor.js +2 -1
  12. package/src/modules/webrtc/qbWebRTCSignalingProvider.js +2 -1
  13. package/src/qbConfig.js +2 -2
  14. package/src/qbProxy.js +1 -1
  15. package/src/qbStrophe.js +2 -6
  16. package/strophejs-1.4.0/.eslintrc.json +264 -0
  17. package/strophejs-1.4.0/.gitattributes +1 -0
  18. package/strophejs-1.4.0/CHANGELOG.md +250 -0
  19. package/strophejs-1.4.0/LICENSE.txt +19 -0
  20. package/strophejs-1.4.0/Makefile +92 -0
  21. package/strophejs-1.4.0/README.md +45 -0
  22. package/strophejs-1.4.0/RELEASE_CHECKLIST.md +16 -0
  23. package/strophejs-1.4.0/contrib/discojs/README.txt +42 -0
  24. package/strophejs-1.4.0/contrib/discojs/css/disco.css +16 -0
  25. package/strophejs-1.4.0/contrib/discojs/index.html +47 -0
  26. package/strophejs-1.4.0/contrib/discojs/punjab.tac +18 -0
  27. package/strophejs-1.4.0/contrib/discojs/scripts/basic.js +102 -0
  28. package/strophejs-1.4.0/contrib/discojs/scripts/disco.js +60 -0
  29. package/strophejs-1.4.0/docs.css +797 -0
  30. package/strophejs-1.4.0/examples/amd.html +21 -0
  31. package/strophejs-1.4.0/examples/attach/README +37 -0
  32. package/strophejs-1.4.0/examples/attach/__init__.py +0 -0
  33. package/strophejs-1.4.0/examples/attach/attacher/__init__.py +0 -0
  34. package/strophejs-1.4.0/examples/attach/attacher/views.py +18 -0
  35. package/strophejs-1.4.0/examples/attach/boshclient.py +158 -0
  36. package/strophejs-1.4.0/examples/attach/manage.py +11 -0
  37. package/strophejs-1.4.0/examples/attach/settings.py +85 -0
  38. package/strophejs-1.4.0/examples/attach/templates/attacher/index.html +88 -0
  39. package/strophejs-1.4.0/examples/attach/urls.py +19 -0
  40. package/strophejs-1.4.0/examples/basic.html +23 -0
  41. package/strophejs-1.4.0/examples/basic.js +73 -0
  42. package/strophejs-1.4.0/examples/echobot.html +25 -0
  43. package/strophejs-1.4.0/examples/echobot.js +79 -0
  44. package/strophejs-1.4.0/examples/main.js +59 -0
  45. package/strophejs-1.4.0/examples/prebind.html +39 -0
  46. package/strophejs-1.4.0/examples/prebind.js +103 -0
  47. package/strophejs-1.4.0/examples/restore.html +24 -0
  48. package/strophejs-1.4.0/examples/restore.js +71 -0
  49. package/strophejs-1.4.0/package-lock.json +8631 -0
  50. package/strophejs-1.4.0/package.json +84 -0
  51. package/strophejs-1.4.0/rollup.config.js +76 -0
  52. package/strophejs-1.4.0/src/bosh.js +916 -0
  53. package/strophejs-1.4.0/src/core.js +3530 -0
  54. package/strophejs-1.4.0/src/md5.js +204 -0
  55. package/strophejs-1.4.0/src/sha1.js +172 -0
  56. package/strophejs-1.4.0/src/shared-connection-worker.js +114 -0
  57. package/strophejs-1.4.0/src/shims.js +123 -0
  58. package/strophejs-1.4.0/src/strophe.js +14 -0
  59. package/strophejs-1.4.0/src/utils.js +63 -0
  60. package/strophejs-1.4.0/src/websocket.js +557 -0
  61. package/strophejs-1.4.0/src/worker-websocket.js +150 -0
  62. package/strophejs-1.4.0/tests/index.html +21 -0
  63. package/strophejs-1.4.0/tests/main.js +49 -0
  64. package/strophejs-1.4.0/tests/tests.js +929 -0
  65. package/strophejs-1.6.1/.eslintrc.json +264 -0
  66. package/strophejs-1.6.1/.gitattributes +1 -0
  67. package/strophejs-1.6.1/.nvmrc +1 -0
  68. package/strophejs-1.6.1/CHANGELOG.md +288 -0
  69. package/strophejs-1.6.1/LICENSE.txt +19 -0
  70. package/strophejs-1.6.1/Makefile +92 -0
  71. package/strophejs-1.6.1/README.md +46 -0
  72. package/strophejs-1.6.1/RELEASE_CHECKLIST.md +18 -0
  73. package/strophejs-1.6.1/babel.config.json +10 -0
  74. package/strophejs-1.6.1/contrib/discojs/README.txt +42 -0
  75. package/strophejs-1.6.1/contrib/discojs/css/disco.css +16 -0
  76. package/strophejs-1.6.1/contrib/discojs/index.html +47 -0
  77. package/strophejs-1.6.1/contrib/discojs/punjab.tac +18 -0
  78. package/strophejs-1.6.1/contrib/discojs/scripts/basic.js +102 -0
  79. package/strophejs-1.6.1/contrib/discojs/scripts/disco.js +60 -0
  80. package/strophejs-1.6.1/docs.css +797 -0
  81. package/strophejs-1.6.1/examples/amd.html +21 -0
  82. package/strophejs-1.6.1/examples/attach/README +37 -0
  83. package/strophejs-1.6.1/examples/attach/__init__.py +0 -0
  84. package/strophejs-1.6.1/examples/attach/attacher/__init__.py +0 -0
  85. package/strophejs-1.6.1/examples/attach/attacher/views.py +18 -0
  86. package/strophejs-1.6.1/examples/attach/boshclient.py +158 -0
  87. package/strophejs-1.6.1/examples/attach/manage.py +11 -0
  88. package/strophejs-1.6.1/examples/attach/settings.py +85 -0
  89. package/strophejs-1.6.1/examples/attach/templates/attacher/index.html +88 -0
  90. package/strophejs-1.6.1/examples/attach/urls.py +19 -0
  91. package/strophejs-1.6.1/examples/basic.html +23 -0
  92. package/strophejs-1.6.1/examples/basic.js +73 -0
  93. package/strophejs-1.6.1/examples/echobot.html +25 -0
  94. package/strophejs-1.6.1/examples/echobot.js +79 -0
  95. package/strophejs-1.6.1/examples/main.js +59 -0
  96. package/strophejs-1.6.1/examples/prebind.html +39 -0
  97. package/strophejs-1.6.1/examples/prebind.js +103 -0
  98. package/strophejs-1.6.1/examples/restore.html +24 -0
  99. package/strophejs-1.6.1/examples/restore.js +71 -0
  100. package/strophejs-1.6.1/package-lock.json +18461 -0
  101. package/strophejs-1.6.1/package.json +87 -0
  102. package/strophejs-1.6.1/rollup.config.js +70 -0
  103. package/strophejs-1.6.1/src/bosh.js +916 -0
  104. package/strophejs-1.6.1/src/builder.js +239 -0
  105. package/strophejs-1.6.1/src/constants.js +155 -0
  106. package/strophejs-1.6.1/src/core.js +2377 -0
  107. package/strophejs-1.6.1/src/sasl-anon.js +17 -0
  108. package/strophejs-1.6.1/src/sasl-external.js +27 -0
  109. package/strophejs-1.6.1/src/sasl-oauthbearer.js +30 -0
  110. package/strophejs-1.6.1/src/sasl-plain.js +32 -0
  111. package/strophejs-1.6.1/src/sasl-sha1.js +24 -0
  112. package/strophejs-1.6.1/src/sasl-sha256.js +24 -0
  113. package/strophejs-1.6.1/src/sasl-sha384.js +24 -0
  114. package/strophejs-1.6.1/src/sasl-sha512.js +24 -0
  115. package/strophejs-1.6.1/src/sasl-xoauth2.js +27 -0
  116. package/strophejs-1.6.1/src/sasl.js +143 -0
  117. package/strophejs-1.6.1/src/scram.js +182 -0
  118. package/strophejs-1.6.1/src/shared-connection-worker.js +114 -0
  119. package/strophejs-1.6.1/src/shims.js +122 -0
  120. package/strophejs-1.6.1/src/strophe.js +15 -0
  121. package/strophejs-1.6.1/src/utils.js +626 -0
  122. package/strophejs-1.6.1/src/websocket.js +556 -0
  123. package/strophejs-1.6.1/src/worker-websocket.js +149 -0
  124. package/strophejs-1.6.1/tests.js +993 -0
@@ -0,0 +1,204 @@
1
+ /*
2
+ * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
3
+ * Digest Algorithm, as defined in RFC 1321.
4
+ * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
5
+ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
6
+ * Distributed under the BSD License
7
+ * See http://pajhome.org.uk/crypt/md5 for more info.
8
+ */
9
+ /*
10
+ * Everything that isn't used by Strophe has been stripped here!
11
+ */
12
+
13
+ /*
14
+ * Add integers, wrapping at 2^32. This uses 16-bit operations internally
15
+ * to work around bugs in some JS interpreters.
16
+ */
17
+ const safe_add = function (x, y) {
18
+ const lsw = (x & 0xFFFF) + (y & 0xFFFF);
19
+ const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
20
+ return (msw << 16) | (lsw & 0xFFFF);
21
+ };
22
+
23
+ /*
24
+ * Bitwise rotate a 32-bit number to the left.
25
+ */
26
+ const bit_rol = function (num, cnt) {
27
+ return (num << cnt) | (num >>> (32 - cnt));
28
+ };
29
+
30
+ /*
31
+ * Convert a string to an array of little-endian words
32
+ */
33
+ const str2binl = function (str) {
34
+ if (typeof str !== "string") {
35
+ throw new Error("str2binl was passed a non-string");
36
+ }
37
+ const bin = [];
38
+ for(let i = 0; i < str.length * 8; i += 8)
39
+ {
40
+ bin[i>>5] |= (str.charCodeAt(i / 8) & 255) << (i%32);
41
+ }
42
+ return bin;
43
+ };
44
+
45
+ /*
46
+ * Convert an array of little-endian words to a string
47
+ */
48
+ const binl2str = function (bin) {
49
+ let str = "";
50
+ for(let i = 0; i < bin.length * 32; i += 8)
51
+ {
52
+ str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & 255);
53
+ }
54
+ return str;
55
+ };
56
+
57
+ /*
58
+ * Convert an array of little-endian words to a hex string.
59
+ */
60
+ const binl2hex = function (binarray) {
61
+ const hex_tab = "0123456789abcdef";
62
+ let str = "";
63
+ for(let i = 0; i < binarray.length * 4; i++)
64
+ {
65
+ str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
66
+ hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
67
+ }
68
+ return str;
69
+ };
70
+
71
+ /*
72
+ * These functions implement the four basic operations the algorithm uses.
73
+ */
74
+ const md5_cmn = function (q, a, b, x, s, t) {
75
+ return safe_add(bit_rol(safe_add(safe_add(a, q),safe_add(x, t)), s),b);
76
+ };
77
+
78
+ const md5_ff = function (a, b, c, d, x, s, t) {
79
+ return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
80
+ };
81
+
82
+ const md5_gg = function (a, b, c, d, x, s, t) {
83
+ return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
84
+ };
85
+
86
+ const md5_hh = function (a, b, c, d, x, s, t) {
87
+ return md5_cmn(b ^ c ^ d, a, b, x, s, t);
88
+ };
89
+
90
+ const md5_ii = function (a, b, c, d, x, s, t) {
91
+ return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
92
+ };
93
+
94
+ /*
95
+ * Calculate the MD5 of an array of little-endian words, and a bit length
96
+ */
97
+ const core_md5 = function (x, len) {
98
+ /* append padding */
99
+ x[len >> 5] |= 0x80 << ((len) % 32);
100
+ x[(((len + 64) >>> 9) << 4) + 14] = len;
101
+
102
+ let a = 1732584193;
103
+ let b = -271733879;
104
+ let c = -1732584194;
105
+ let d = 271733878;
106
+
107
+ let olda, oldb, oldc, oldd;
108
+ for (let i = 0; i < x.length; i += 16)
109
+ {
110
+ olda = a;
111
+ oldb = b;
112
+ oldc = c;
113
+ oldd = d;
114
+
115
+ a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
116
+ d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
117
+ c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
118
+ b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
119
+ a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
120
+ d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
121
+ c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
122
+ b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
123
+ a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
124
+ d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
125
+ c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
126
+ b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
127
+ a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
128
+ d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
129
+ c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
130
+ b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
131
+
132
+ a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
133
+ d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
134
+ c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
135
+ b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
136
+ a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
137
+ d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
138
+ c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
139
+ b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
140
+ a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
141
+ d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
142
+ c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
143
+ b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
144
+ a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
145
+ d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
146
+ c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
147
+ b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
148
+
149
+ a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
150
+ d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
151
+ c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
152
+ b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
153
+ a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
154
+ d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
155
+ c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
156
+ b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
157
+ a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
158
+ d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
159
+ c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
160
+ b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
161
+ a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
162
+ d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
163
+ c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
164
+ b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
165
+
166
+ a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
167
+ d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
168
+ c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
169
+ b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
170
+ a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
171
+ d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
172
+ c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
173
+ b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
174
+ a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
175
+ d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
176
+ c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
177
+ b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
178
+ a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
179
+ d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
180
+ c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
181
+ b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
182
+
183
+ a = safe_add(a, olda);
184
+ b = safe_add(b, oldb);
185
+ c = safe_add(c, oldc);
186
+ d = safe_add(d, oldd);
187
+ }
188
+ return [a, b, c, d];
189
+ };
190
+
191
+ /*
192
+ * These are the functions you'll usually want to call.
193
+ * They take string arguments and return either hex or base-64 encoded
194
+ * strings.
195
+ */
196
+ const MD5 = {
197
+ hexdigest: function (s) {
198
+ return binl2hex(core_md5(str2binl(s), s.length * 8));
199
+ },
200
+ hash: function (s) {
201
+ return binl2str(core_md5(str2binl(s), s.length * 8));
202
+ }
203
+ };
204
+ export { MD5 as default };
@@ -0,0 +1,172 @@
1
+ /*
2
+ * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
3
+ * in FIPS PUB 180-1
4
+ * Version 2.1a Copyright Paul Johnston 2000 - 2002.
5
+ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
6
+ * Distributed under the BSD License
7
+ * See http://pajhome.org.uk/crypt/md5 for details.
8
+ */
9
+ /* global define */
10
+
11
+ /* Some functions and variables have been stripped for use with Strophe */
12
+
13
+ /*
14
+ * Calculate the SHA-1 of an array of big-endian words, and a bit length
15
+ */
16
+ function core_sha1(x, len) {
17
+ /* append padding */
18
+ x[len >> 5] |= 0x80 << (24 - len % 32);
19
+ x[((len + 64 >> 9) << 4) + 15] = len;
20
+
21
+ var w = new Array(80);
22
+ var a = 1732584193;
23
+ var b = -271733879;
24
+ var c = -1732584194;
25
+ var d = 271733878;
26
+ var e = -1009589776;
27
+
28
+ var i, j, t, olda, oldb, oldc, oldd, olde;
29
+ for (i = 0; i < x.length; i += 16) {
30
+ olda = a;
31
+ oldb = b;
32
+ oldc = c;
33
+ oldd = d;
34
+ olde = e;
35
+
36
+ for (j = 0; j < 80; j++) {
37
+ if (j < 16) {
38
+ w[j] = x[i + j];
39
+ } else {
40
+ w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
41
+ }
42
+
43
+ t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)),
44
+ safe_add(safe_add(e, w[j]), sha1_kt(j)));
45
+ e = d;
46
+ d = c;
47
+ c = rol(b, 30);
48
+ b = a;
49
+ a = t;
50
+ }
51
+
52
+ a = safe_add(a, olda);
53
+ b = safe_add(b, oldb);
54
+ c = safe_add(c, oldc);
55
+ d = safe_add(d, oldd);
56
+ e = safe_add(e, olde);
57
+ }
58
+ return [a, b, c, d, e];
59
+ }
60
+
61
+ /*
62
+ * Perform the appropriate triplet combination function for the current
63
+ * iteration
64
+ */
65
+ function sha1_ft (t, b, c, d) {
66
+ if (t < 20) { return (b & c) | ((~b) & d); }
67
+ if (t < 40) { return b ^ c ^ d; }
68
+ if (t < 60) { return (b & c) | (b & d) | (c & d); }
69
+ return b ^ c ^ d;
70
+ }
71
+
72
+ /*
73
+ * Determine the appropriate additive constant for the current iteration
74
+ */
75
+ function sha1_kt(t) {
76
+ return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 : (t < 60) ? -1894007588 : -899497514;
77
+ }
78
+
79
+ /*
80
+ * Calculate the HMAC-SHA1 of a key and some data
81
+ */
82
+ function core_hmac_sha1(key, data) {
83
+ var bkey = str2binb(key);
84
+ if (bkey.length > 16) {
85
+ bkey = core_sha1(bkey, key.length * 8);
86
+ }
87
+
88
+ var ipad = new Array(16), opad = new Array(16);
89
+ for (var i = 0; i < 16; i++) {
90
+ ipad[i] = bkey[i] ^ 0x36363636;
91
+ opad[i] = bkey[i] ^ 0x5C5C5C5C;
92
+ }
93
+
94
+ var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * 8);
95
+ return core_sha1(opad.concat(hash), 512 + 160);
96
+ }
97
+
98
+ /*
99
+ * Add integers, wrapping at 2^32. This uses 16-bit operations internally
100
+ * to work around bugs in some JS interpreters.
101
+ */
102
+ function safe_add(x, y) {
103
+ var lsw = (x & 0xFFFF) + (y & 0xFFFF);
104
+ var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
105
+ return (msw << 16) | (lsw & 0xFFFF);
106
+ }
107
+
108
+ /*
109
+ * Bitwise rotate a 32-bit number to the left.
110
+ */
111
+ function rol(num, cnt) {
112
+ return (num << cnt) | (num >>> (32 - cnt));
113
+ }
114
+
115
+ /*
116
+ * Convert an 8-bit or 16-bit string to an array of big-endian words
117
+ * In 8-bit function, characters >255 have their hi-byte silently ignored.
118
+ */
119
+ function str2binb(str) {
120
+ var bin = [];
121
+ var mask = 255;
122
+ for (var i = 0; i < str.length * 8; i += 8) {
123
+ bin[i>>5] |= (str.charCodeAt(i / 8) & mask) << (24 - i%32);
124
+ }
125
+ return bin;
126
+ }
127
+
128
+ /*
129
+ * Convert an array of big-endian words to a base-64 string
130
+ */
131
+ function binb2b64 (binarray) {
132
+ var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
133
+ var str = "";
134
+ var triplet, j;
135
+ for (var i = 0; i < binarray.length * 4; i += 3) {
136
+ triplet = (((binarray[i >> 2] >> 8 * (3 - i %4)) & 0xFF) << 16) |
137
+ (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 ) |
138
+ ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF);
139
+
140
+ for (j = 0; j < 4; j++) {
141
+ if (i * 8 + j * 6 > binarray.length * 32) { str += "="; }
142
+ else { str += tab.charAt((triplet >> 6*(3-j)) & 0x3F); }
143
+ }
144
+ }
145
+ return str;
146
+ }
147
+
148
+ /*
149
+ * Convert an array of big-endian words to a string
150
+ */
151
+ function binb2str(bin) {
152
+ var str = "";
153
+ var mask = 255;
154
+ for (var i = 0; i < bin.length * 32; i += 8) {
155
+ str += String.fromCharCode((bin[i>>5] >>> (24 - i%32)) & mask);
156
+ }
157
+ return str;
158
+ }
159
+
160
+ /*
161
+ * These are the functions you'll usually want to call
162
+ * They take string arguments and return either hex or base-64 encoded strings
163
+ */
164
+ const SHA1 = {
165
+ b64_hmac_sha1: function (key, data){ return binb2b64(core_hmac_sha1(key, data)); },
166
+ b64_sha1: function (s) { return binb2b64(core_sha1(str2binb(s),s.length * 8)); },
167
+ binb2str: binb2str,
168
+ core_hmac_sha1: core_hmac_sha1,
169
+ str_hmac_sha1: function (key, data){ return binb2str(core_hmac_sha1(key, data)); },
170
+ str_sha1: function (s) { return binb2str(core_sha1(str2binb(s),s.length * 8)); },
171
+ };
172
+ export { SHA1 as default };
@@ -0,0 +1,114 @@
1
+ let manager;
2
+
3
+
4
+ const Status = {
5
+ ERROR: 0,
6
+ CONNECTING: 1,
7
+ CONNFAIL: 2,
8
+ AUTHENTICATING: 3,
9
+ AUTHFAIL: 4,
10
+ CONNECTED: 5,
11
+ DISCONNECTED: 6,
12
+ DISCONNECTING: 7,
13
+ ATTACHED: 8,
14
+ REDIRECT: 9,
15
+ CONNTIMEOUT: 10,
16
+ BINDREQUIRED: 11,
17
+ ATTACHFAIL: 12
18
+ }
19
+
20
+
21
+ /** Class: ConnectionManager
22
+ *
23
+ * Manages the shared websocket connection as well as the ports of the
24
+ * connected tabs.
25
+ */
26
+ class ConnectionManager {
27
+
28
+ constructor () {
29
+ this.ports = [];
30
+ }
31
+
32
+ addPort (port) {
33
+ this.ports.push(port);
34
+ port.addEventListener('message', e => {
35
+ const method = e.data[0];
36
+ try {
37
+ this[method](e.data.splice(1))
38
+ } catch (e) {
39
+ console?.error(e);
40
+ }
41
+ });
42
+ port.start();
43
+ }
44
+
45
+ _connect (data) {
46
+ this.jid = data[1];
47
+ this._closeSocket();
48
+ this.socket = new WebSocket(data[0], "xmpp");
49
+ this.socket.onopen = () => this._onOpen();
50
+ this.socket.onerror = (e) => this._onError(e);
51
+ this.socket.onclose = (e) => this._onClose(e);
52
+ this.socket.onmessage = (message) => this._onMessage(message);
53
+ }
54
+
55
+ _attach () {
56
+ if (this.socket && this.socket.readyState !== WebSocket.CLOSED) {
57
+ this.ports.forEach(p => p.postMessage(['_attachCallback', Status.ATTACHED, this.jid]));
58
+ } else {
59
+ this.ports.forEach(p => p.postMessage(['_attachCallback', Status.ATTACHFAIL]));
60
+ }
61
+ }
62
+
63
+ send (str) {
64
+ this.socket.send(str);
65
+ }
66
+
67
+ close (str) {
68
+ if (this.socket && this.socket.readyState !== WebSocket.CLOSED) {
69
+ try {
70
+ this.socket.send(str);
71
+ } catch (e) {
72
+ this.ports.forEach(p => p.postMessage(['log', 'error', e]));
73
+ this.ports.forEach(p => p.postMessage(
74
+ ['log', 'error', "Couldn't send <close /> tag."]));
75
+ }
76
+ }
77
+ }
78
+
79
+ _onOpen () {
80
+ this.ports.forEach(p => p.postMessage(['_onOpen']));
81
+ }
82
+
83
+ _onClose (e) {
84
+ this.ports.forEach(p => p.postMessage(['_onClose', e.reason]));
85
+ }
86
+
87
+ _onMessage (message) {
88
+ const o = { 'data': message.data }
89
+ this.ports.forEach(p => p.postMessage(['_onMessage', o]));
90
+ }
91
+
92
+ _onError (error) {
93
+ this.ports.forEach(p => p.postMessage(['_onError', error.reason]));
94
+ }
95
+
96
+ _closeSocket () {
97
+ if (this.socket) {
98
+ try {
99
+ this.socket.onclose = null;
100
+ this.socket.onerror = null;
101
+ this.socket.onmessage = null;
102
+ this.socket.close();
103
+ } catch (e) {
104
+ this.ports.forEach(p => p.postMessage(['log', 'error', e]));
105
+ }
106
+ }
107
+ this.socket = null;
108
+ }
109
+ }
110
+
111
+ onconnect = function (e) { // eslint-disable-line no-undef
112
+ manager = manager || new ConnectionManager();
113
+ manager.addPort(e.ports[0]);
114
+ }
@@ -0,0 +1,123 @@
1
+ /*
2
+ * This module provides uniform
3
+ * Shims APIs and globals that are not present in all JS environments,
4
+ * the most common example for Strophe being browser APIs like WebSocket
5
+ * and DOM that don't exist under nodejs.
6
+ *
7
+ * Usually these will be supplied in nodejs by conditionally requiring a
8
+ * NPM module that provides a compatible implementation.
9
+ */
10
+
11
+ /* global global */
12
+
13
+ /**
14
+ * WHATWG WebSockets API
15
+ * https://www.w3.org/TR/websockets/
16
+ *
17
+ * Interface to use the web socket protocol
18
+ *
19
+ * Used implementations:
20
+ * - supported browsers: built-in in WebSocket global
21
+ * https://developer.mozilla.org/en-US/docs/Web/API/WebSocket#Browser_compatibility
22
+ * - nodejs: use standard-compliant 'ws' module
23
+ * https://www.npmjs.com/package/ws
24
+ */
25
+ function getWebSocketImplementation () {
26
+ let WebSocketImplementation = global.WebSocket
27
+ if (typeof WebSocketImplementation === 'undefined') {
28
+ try {
29
+ WebSocketImplementation = require('ws');
30
+ } catch (err) {
31
+ throw new Error('You must install the "ws" package to use Strophe in nodejs.');
32
+ }
33
+ }
34
+ return WebSocketImplementation
35
+ }
36
+ export const WebSocket = getWebSocketImplementation()
37
+
38
+ /**
39
+ * DOMParser
40
+ * https://w3c.github.io/DOM-Parsing/#the-domparser-interface
41
+ *
42
+ * Interface to parse XML strings into Document objects
43
+ *
44
+ * Used implementations:
45
+ * - supported browsers: built-in in DOMParser global
46
+ * https://developer.mozilla.org/en-US/docs/Web/API/DOMParser#Browser_compatibility
47
+ * - nodejs: use 'xmldom' module
48
+ * https://www.npmjs.com/package/xmldom
49
+ */
50
+ function getDOMParserImplementation () {
51
+ let DOMParserImplementation = global.DOMParser
52
+ if (typeof DOMParserImplementation === 'undefined') {
53
+ try {
54
+ DOMParserImplementation = require('xmldom').DOMParser;
55
+ } catch (err) {
56
+ throw new Error('You must install the "xmldom" package to use Strophe in nodejs.');
57
+ }
58
+ }
59
+ return DOMParserImplementation
60
+ }
61
+ export const DOMParser = getDOMParserImplementation()
62
+
63
+ /**
64
+ * Gets IE xml doc object. Used by getDummyXMLDocument shim.
65
+ *
66
+ * Returns:
67
+ * A Microsoft XML DOM Object
68
+ * See Also:
69
+ * http://msdn.microsoft.com/en-us/library/ms757837%28VS.85%29.aspx
70
+ */
71
+ function _getIEXmlDom () {
72
+ const docStrings = [
73
+ "Msxml2.DOMDocument.6.0",
74
+ "Msxml2.DOMDocument.5.0",
75
+ "Msxml2.DOMDocument.4.0",
76
+ "MSXML2.DOMDocument.3.0",
77
+ "MSXML2.DOMDocument",
78
+ "MSXML.DOMDocument",
79
+ "Microsoft.XMLDOM"
80
+ ];
81
+ for (let d = 0; d < docStrings.length; d++) {
82
+ try {
83
+ // eslint-disable-next-line no-undef
84
+ const doc = new ActiveXObject(docStrings[d]);
85
+ return doc
86
+ } catch (e) {
87
+ // Try next one
88
+ }
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Creates a dummy XML DOM document to serve as an element and text node generator.
94
+ *
95
+ * Used implementations:
96
+ * - IE < 10: avoid using createDocument() due to a memory leak, use ie-specific
97
+ * workaround
98
+ * - other supported browsers: use document's createDocument
99
+ * - nodejs: use 'xmldom'
100
+ */
101
+ export function getDummyXMLDOMDocument () {
102
+ // nodejs
103
+ if (typeof document === 'undefined') {
104
+ try {
105
+ const DOMImplementation = require('xmldom').DOMImplementation;
106
+ return new DOMImplementation().createDocument('jabber:client', 'strophe', null);
107
+ } catch (err) {
108
+ throw new Error('You must install the "xmldom" package to use Strophe in nodejs.');
109
+ }
110
+ }
111
+ // IE < 10
112
+ if (
113
+ document.implementation.createDocument === undefined ||
114
+ document.implementation.createDocument && document.documentMode && document.documentMode < 10
115
+ ) {
116
+ const doc = _getIEXmlDom();
117
+ doc.appendChild(doc.createElement('strophe'));
118
+ return doc
119
+ }
120
+ // All other supported browsers
121
+ return document.implementation.createDocument('jabber:client', 'strophe', null)
122
+ }
123
+
@@ -0,0 +1,14 @@
1
+ /*global global*/
2
+
3
+ import './bosh';
4
+ import './websocket';
5
+ import './worker-websocket';
6
+ import * as strophe from './core';
7
+
8
+ global.$build = strophe.default.$build;
9
+ global.$iq = strophe.default.$iq;
10
+ global.$msg = strophe.default.$msg;
11
+ global.$pres = strophe.default.$pres;
12
+ global.Strophe = strophe.default.Strophe;
13
+
14
+ export { Strophe, $build, $iq, $msg, $pres } from './core';
@@ -0,0 +1,63 @@
1
+ const utils = {
2
+
3
+ utf16to8: function (str) {
4
+ var i, c;
5
+ var out = "";
6
+ var len = str.length;
7
+ for (i = 0; i < len; i++) {
8
+ c = str.charCodeAt(i);
9
+ if ((c >= 0x0000) && (c <= 0x007F)) {
10
+ out += str.charAt(i);
11
+ } else if (c > 0x07FF) {
12
+ out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
13
+ out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
14
+ out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
15
+ } else {
16
+ out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
17
+ out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
18
+ }
19
+ }
20
+ return out;
21
+ },
22
+
23
+ addCookies: function (cookies) {
24
+ /* Parameters:
25
+ * (Object) cookies - either a map of cookie names
26
+ * to string values or to maps of cookie values.
27
+ *
28
+ * For example:
29
+ * { "myCookie": "1234" }
30
+ *
31
+ * or:
32
+ * { "myCookie": {
33
+ * "value": "1234",
34
+ * "domain": ".example.org",
35
+ * "path": "/",
36
+ * "expires": expirationDate
37
+ * }
38
+ * }
39
+ *
40
+ * These values get passed to Strophe.Connection via
41
+ * options.cookies
42
+ */
43
+ cookies = cookies || {};
44
+ for (const cookieName in cookies) {
45
+ if (Object.prototype.hasOwnProperty.call(cookies, cookieName)) {
46
+ let expires = '';
47
+ let domain = '';
48
+ let path = '';
49
+ const cookieObj = cookies[cookieName];
50
+ const isObj = typeof cookieObj === "object";
51
+ const cookieValue = escape(unescape(isObj ? cookieObj.value : cookieObj));
52
+ if (isObj) {
53
+ expires = cookieObj.expires ? ";expires="+cookieObj.expires : '';
54
+ domain = cookieObj.domain ? ";domain="+cookieObj.domain : '';
55
+ path = cookieObj.path ? ";path="+cookieObj.path : '';
56
+ }
57
+ document.cookie = cookieName+'='+cookieValue + expires + domain + path;
58
+ }
59
+ }
60
+ }
61
+ };
62
+
63
+ export { utils as default };