@stellar/stellar-base 10.0.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.
Files changed (80) hide show
  1. package/CHANGELOG.md +1262 -0
  2. package/LICENSE +202 -0
  3. package/README.md +198 -0
  4. package/dist/stellar-base.js +30777 -0
  5. package/dist/stellar-base.min.js +2 -0
  6. package/lib/account.js +80 -0
  7. package/lib/address.js +169 -0
  8. package/lib/asset.js +323 -0
  9. package/lib/auth.js +253 -0
  10. package/lib/claimant.js +193 -0
  11. package/lib/contract.js +113 -0
  12. package/lib/events.js +42 -0
  13. package/lib/fee_bump_transaction.js +134 -0
  14. package/lib/generated/curr_generated.js +8315 -0
  15. package/lib/generated/next_generated.js +8315 -0
  16. package/lib/get_liquidity_pool_id.js +57 -0
  17. package/lib/hashing.js +12 -0
  18. package/lib/index.js +385 -0
  19. package/lib/invocation.js +195 -0
  20. package/lib/keypair.js +308 -0
  21. package/lib/liquidity_pool_asset.js +126 -0
  22. package/lib/liquidity_pool_id.js +101 -0
  23. package/lib/memo.js +270 -0
  24. package/lib/muxed_account.js +159 -0
  25. package/lib/network.js +22 -0
  26. package/lib/numbers/index.js +85 -0
  27. package/lib/numbers/int128.js +50 -0
  28. package/lib/numbers/int256.js +50 -0
  29. package/lib/numbers/sc_int.js +134 -0
  30. package/lib/numbers/uint128.js +50 -0
  31. package/lib/numbers/uint256.js +50 -0
  32. package/lib/numbers/xdr_large_int.js +267 -0
  33. package/lib/operation.js +715 -0
  34. package/lib/operations/account_merge.js +32 -0
  35. package/lib/operations/allow_trust.js +57 -0
  36. package/lib/operations/begin_sponsoring_future_reserves.js +38 -0
  37. package/lib/operations/bump_sequence.js +37 -0
  38. package/lib/operations/change_trust.js +52 -0
  39. package/lib/operations/claim_claimable_balance.js +40 -0
  40. package/lib/operations/clawback.js +46 -0
  41. package/lib/operations/clawback_claimable_balance.js +39 -0
  42. package/lib/operations/create_account.js +37 -0
  43. package/lib/operations/create_claimable_balance.js +65 -0
  44. package/lib/operations/create_passive_sell_offer.js +44 -0
  45. package/lib/operations/end_sponsoring_future_reserves.js +27 -0
  46. package/lib/operations/extend_footprint_ttl.js +45 -0
  47. package/lib/operations/index.js +254 -0
  48. package/lib/operations/inflation.js +23 -0
  49. package/lib/operations/invoke_host_function.js +219 -0
  50. package/lib/operations/liquidity_pool_deposit.js +64 -0
  51. package/lib/operations/liquidity_pool_withdraw.js +50 -0
  52. package/lib/operations/manage_buy_offer.js +50 -0
  53. package/lib/operations/manage_data.js +41 -0
  54. package/lib/operations/manage_sell_offer.js +50 -0
  55. package/lib/operations/path_payment_strict_receive.js +68 -0
  56. package/lib/operations/path_payment_strict_send.js +68 -0
  57. package/lib/operations/payment.js +47 -0
  58. package/lib/operations/restore_footprint.js +38 -0
  59. package/lib/operations/revoke_sponsorship.js +301 -0
  60. package/lib/operations/set_options.js +135 -0
  61. package/lib/operations/set_trustline_flags.js +84 -0
  62. package/lib/scval.js +369 -0
  63. package/lib/signerkey.js +103 -0
  64. package/lib/signing.js +96 -0
  65. package/lib/soroban.js +96 -0
  66. package/lib/sorobandata_builder.js +218 -0
  67. package/lib/strkey.js +400 -0
  68. package/lib/transaction.js +369 -0
  69. package/lib/transaction_base.js +248 -0
  70. package/lib/transaction_builder.js +753 -0
  71. package/lib/util/checksum.js +20 -0
  72. package/lib/util/continued_fraction.js +58 -0
  73. package/lib/util/decode_encode_muxed_account.js +116 -0
  74. package/lib/util/util.js +14 -0
  75. package/lib/xdr.js +9 -0
  76. package/package.json +133 -0
  77. package/types/curr.d.ts +14078 -0
  78. package/types/index.d.ts +1270 -0
  79. package/types/next.d.ts +14078 -0
  80. package/types/xdr.d.ts +1 -0
package/lib/strkey.js ADDED
@@ -0,0 +1,400 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.StrKey = void 0;
7
+ exports.decodeCheck = decodeCheck;
8
+ exports.encodeCheck = encodeCheck;
9
+ var _base = _interopRequireDefault(require("base32.js"));
10
+ var _checksum = require("./util/checksum");
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
13
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
15
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
16
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
17
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /* eslint no-bitwise: ["error", {"allow": ["<<", ">>", "^", "&", "&="]}] */
18
+ var versionBytes = {
19
+ ed25519PublicKey: 6 << 3,
20
+ // G (when encoded in base32)
21
+ ed25519SecretSeed: 18 << 3,
22
+ // S
23
+ med25519PublicKey: 12 << 3,
24
+ // M
25
+ preAuthTx: 19 << 3,
26
+ // T
27
+ sha256Hash: 23 << 3,
28
+ // X
29
+ signedPayload: 15 << 3,
30
+ // P
31
+ contract: 2 << 3 // C
32
+ };
33
+ var strkeyTypes = {
34
+ G: 'ed25519PublicKey',
35
+ S: 'ed25519SecretSeed',
36
+ M: 'med25519PublicKey',
37
+ T: 'preAuthTx',
38
+ X: 'sha256Hash',
39
+ P: 'signedPayload',
40
+ C: 'contract'
41
+ };
42
+
43
+ /**
44
+ * StrKey is a helper class that allows encoding and decoding Stellar keys
45
+ * to/from strings, i.e. between their binary (Buffer, xdr.PublicKey, etc.) and
46
+ * string (i.e. "GABCD...", etc.) representations.
47
+ */
48
+ var StrKey = exports.StrKey = /*#__PURE__*/function () {
49
+ function StrKey() {
50
+ _classCallCheck(this, StrKey);
51
+ }
52
+ _createClass(StrKey, null, [{
53
+ key: "encodeEd25519PublicKey",
54
+ value:
55
+ /**
56
+ * Encodes `data` to strkey ed25519 public key.
57
+ *
58
+ * @param {Buffer} data raw data to encode
59
+ * @returns {string} "G..." representation of the key
60
+ */
61
+ function encodeEd25519PublicKey(data) {
62
+ return encodeCheck('ed25519PublicKey', data);
63
+ }
64
+
65
+ /**
66
+ * Decodes strkey ed25519 public key to raw data.
67
+ *
68
+ * If the parameter is a muxed account key ("M..."), this will only encode it
69
+ * as a basic Ed25519 key (as if in "G..." format).
70
+ *
71
+ * @param {string} data "G..." (or "M...") key representation to decode
72
+ * @returns {Buffer} raw key
73
+ */
74
+ }, {
75
+ key: "decodeEd25519PublicKey",
76
+ value: function decodeEd25519PublicKey(data) {
77
+ return decodeCheck('ed25519PublicKey', data);
78
+ }
79
+
80
+ /**
81
+ * Returns true if the given Stellar public key is a valid ed25519 public key.
82
+ * @param {string} publicKey public key to check
83
+ * @returns {boolean}
84
+ */
85
+ }, {
86
+ key: "isValidEd25519PublicKey",
87
+ value: function isValidEd25519PublicKey(publicKey) {
88
+ return isValid('ed25519PublicKey', publicKey);
89
+ }
90
+
91
+ /**
92
+ * Encodes data to strkey ed25519 seed.
93
+ * @param {Buffer} data data to encode
94
+ * @returns {string}
95
+ */
96
+ }, {
97
+ key: "encodeEd25519SecretSeed",
98
+ value: function encodeEd25519SecretSeed(data) {
99
+ return encodeCheck('ed25519SecretSeed', data);
100
+ }
101
+
102
+ /**
103
+ * Decodes strkey ed25519 seed to raw data.
104
+ * @param {string} address data to decode
105
+ * @returns {Buffer}
106
+ */
107
+ }, {
108
+ key: "decodeEd25519SecretSeed",
109
+ value: function decodeEd25519SecretSeed(address) {
110
+ return decodeCheck('ed25519SecretSeed', address);
111
+ }
112
+
113
+ /**
114
+ * Returns true if the given Stellar secret key is a valid ed25519 secret seed.
115
+ * @param {string} seed seed to check
116
+ * @returns {boolean}
117
+ */
118
+ }, {
119
+ key: "isValidEd25519SecretSeed",
120
+ value: function isValidEd25519SecretSeed(seed) {
121
+ return isValid('ed25519SecretSeed', seed);
122
+ }
123
+
124
+ /**
125
+ * Encodes data to strkey med25519 public key.
126
+ * @param {Buffer} data data to encode
127
+ * @returns {string}
128
+ */
129
+ }, {
130
+ key: "encodeMed25519PublicKey",
131
+ value: function encodeMed25519PublicKey(data) {
132
+ return encodeCheck('med25519PublicKey', data);
133
+ }
134
+
135
+ /**
136
+ * Decodes strkey med25519 public key to raw data.
137
+ * @param {string} address data to decode
138
+ * @returns {Buffer}
139
+ */
140
+ }, {
141
+ key: "decodeMed25519PublicKey",
142
+ value: function decodeMed25519PublicKey(address) {
143
+ return decodeCheck('med25519PublicKey', address);
144
+ }
145
+
146
+ /**
147
+ * Returns true if the given Stellar public key is a valid med25519 public key.
148
+ * @param {string} publicKey public key to check
149
+ * @returns {boolean}
150
+ */
151
+ }, {
152
+ key: "isValidMed25519PublicKey",
153
+ value: function isValidMed25519PublicKey(publicKey) {
154
+ return isValid('med25519PublicKey', publicKey);
155
+ }
156
+
157
+ /**
158
+ * Encodes data to strkey preAuthTx.
159
+ * @param {Buffer} data data to encode
160
+ * @returns {string}
161
+ */
162
+ }, {
163
+ key: "encodePreAuthTx",
164
+ value: function encodePreAuthTx(data) {
165
+ return encodeCheck('preAuthTx', data);
166
+ }
167
+
168
+ /**
169
+ * Decodes strkey PreAuthTx to raw data.
170
+ * @param {string} address data to decode
171
+ * @returns {Buffer}
172
+ */
173
+ }, {
174
+ key: "decodePreAuthTx",
175
+ value: function decodePreAuthTx(address) {
176
+ return decodeCheck('preAuthTx', address);
177
+ }
178
+
179
+ /**
180
+ * Encodes data to strkey sha256 hash.
181
+ * @param {Buffer} data data to encode
182
+ * @returns {string}
183
+ */
184
+ }, {
185
+ key: "encodeSha256Hash",
186
+ value: function encodeSha256Hash(data) {
187
+ return encodeCheck('sha256Hash', data);
188
+ }
189
+
190
+ /**
191
+ * Decodes strkey sha256 hash to raw data.
192
+ * @param {string} address data to decode
193
+ * @returns {Buffer}
194
+ */
195
+ }, {
196
+ key: "decodeSha256Hash",
197
+ value: function decodeSha256Hash(address) {
198
+ return decodeCheck('sha256Hash', address);
199
+ }
200
+
201
+ /**
202
+ * Encodes raw data to strkey signed payload (P...).
203
+ * @param {Buffer} data data to encode
204
+ * @returns {string}
205
+ */
206
+ }, {
207
+ key: "encodeSignedPayload",
208
+ value: function encodeSignedPayload(data) {
209
+ return encodeCheck('signedPayload', data);
210
+ }
211
+
212
+ /**
213
+ * Decodes strkey signed payload (P...) to raw data.
214
+ * @param {string} address address to decode
215
+ * @returns {Buffer}
216
+ */
217
+ }, {
218
+ key: "decodeSignedPayload",
219
+ value: function decodeSignedPayload(address) {
220
+ return decodeCheck('signedPayload', address);
221
+ }
222
+
223
+ /**
224
+ * Checks validity of alleged signed payload (P...) strkey address.
225
+ * @param {string} address signer key to check
226
+ * @returns {boolean}
227
+ */
228
+ }, {
229
+ key: "isValidSignedPayload",
230
+ value: function isValidSignedPayload(address) {
231
+ return isValid('signedPayload', address);
232
+ }
233
+
234
+ /**
235
+ * Encodes raw data to strkey contract (C...).
236
+ * @param {Buffer} data data to encode
237
+ * @returns {string}
238
+ */
239
+ }, {
240
+ key: "encodeContract",
241
+ value: function encodeContract(data) {
242
+ return encodeCheck('contract', data);
243
+ }
244
+
245
+ /**
246
+ * Decodes strkey contract (C...) to raw data.
247
+ * @param {string} address address to decode
248
+ * @returns {Buffer}
249
+ */
250
+ }, {
251
+ key: "decodeContract",
252
+ value: function decodeContract(address) {
253
+ return decodeCheck('contract', address);
254
+ }
255
+
256
+ /**
257
+ * Checks validity of alleged contract (C...) strkey address.
258
+ * @param {string} address signer key to check
259
+ * @returns {boolean}
260
+ */
261
+ }, {
262
+ key: "isValidContract",
263
+ value: function isValidContract(address) {
264
+ return isValid('contract', address);
265
+ }
266
+ }, {
267
+ key: "getVersionByteForPrefix",
268
+ value: function getVersionByteForPrefix(address) {
269
+ return strkeyTypes[address[0]];
270
+ }
271
+ }]);
272
+ return StrKey;
273
+ }();
274
+ /**
275
+ * Sanity-checks whether or not a strkey *appears* valid.
276
+ *
277
+ * @param {string} versionByteName the type of strkey to expect in `encoded`
278
+ * @param {string} encoded the strkey to validate
279
+ *
280
+ * @return {Boolean} whether or not the `encoded` strkey appears valid for the
281
+ * `versionByteName` strkey type (see `versionBytes`, above).
282
+ *
283
+ * @note This isn't a *definitive* check of validity, but rather a best-effort
284
+ * check based on (a) input length, (b) whether or not it can be decoded,
285
+ * and (c) output length.
286
+ */
287
+ function isValid(versionByteName, encoded) {
288
+ if (typeof encoded !== 'string') {
289
+ return false;
290
+ }
291
+
292
+ // basic length checks on the strkey lengths
293
+ switch (versionByteName) {
294
+ case 'ed25519PublicKey': // falls through
295
+ case 'ed25519SecretSeed': // falls through
296
+ case 'preAuthTx': // falls through
297
+ case 'sha256Hash': // falls through
298
+ case 'contract':
299
+ if (encoded.length !== 56) {
300
+ return false;
301
+ }
302
+ break;
303
+ case 'med25519PublicKey':
304
+ if (encoded.length !== 69) {
305
+ return false;
306
+ }
307
+ break;
308
+ case 'signedPayload':
309
+ if (encoded.length < 56 || encoded.length > 165) {
310
+ return false;
311
+ }
312
+ break;
313
+ default:
314
+ return false;
315
+ }
316
+ var decoded = '';
317
+ try {
318
+ decoded = decodeCheck(versionByteName, encoded);
319
+ } catch (err) {
320
+ return false;
321
+ }
322
+
323
+ // basic length checks on the resulting buffer sizes
324
+ switch (versionByteName) {
325
+ case 'ed25519PublicKey': // falls through
326
+ case 'ed25519SecretSeed': // falls through
327
+ case 'preAuthTx': // falls through
328
+ case 'sha256Hash': // falls through
329
+ case 'contract':
330
+ return decoded.length === 32;
331
+ case 'med25519PublicKey':
332
+ return decoded.length === 40;
333
+ // +8 bytes for the ID
334
+
335
+ case 'signedPayload':
336
+ return (
337
+ // 32 for the signer, +4 for the payload size, then either +4 for the
338
+ // min or +64 for the max payload
339
+ decoded.length >= 32 + 4 + 4 && decoded.length <= 32 + 4 + 64
340
+ );
341
+ default:
342
+ return false;
343
+ }
344
+ }
345
+ function decodeCheck(versionByteName, encoded) {
346
+ if (typeof encoded !== 'string') {
347
+ throw new TypeError('encoded argument must be of type String');
348
+ }
349
+ var decoded = _base["default"].decode(encoded);
350
+ var versionByte = decoded[0];
351
+ var payload = decoded.slice(0, -2);
352
+ var data = payload.slice(1);
353
+ var checksum = decoded.slice(-2);
354
+ if (encoded !== _base["default"].encode(decoded)) {
355
+ throw new Error('invalid encoded string');
356
+ }
357
+ var expectedVersion = versionBytes[versionByteName];
358
+ if (expectedVersion === undefined) {
359
+ throw new Error("".concat(versionByteName, " is not a valid version byte name. ") + "Expected one of ".concat(Object.keys(versionBytes).join(', ')));
360
+ }
361
+ if (versionByte !== expectedVersion) {
362
+ throw new Error("invalid version byte. expected ".concat(expectedVersion, ", got ").concat(versionByte));
363
+ }
364
+ var expectedChecksum = calculateChecksum(payload);
365
+ if (!(0, _checksum.verifyChecksum)(expectedChecksum, checksum)) {
366
+ throw new Error("invalid checksum");
367
+ }
368
+ return Buffer.from(data);
369
+ }
370
+ function encodeCheck(versionByteName, data) {
371
+ if (data === null || data === undefined) {
372
+ throw new Error('cannot encode null data');
373
+ }
374
+ var versionByte = versionBytes[versionByteName];
375
+ if (versionByte === undefined) {
376
+ throw new Error("".concat(versionByteName, " is not a valid version byte name. ") + "Expected one of ".concat(Object.keys(versionBytes).join(', ')));
377
+ }
378
+ data = Buffer.from(data);
379
+ var versionBuffer = Buffer.from([versionByte]);
380
+ var payload = Buffer.concat([versionBuffer, data]);
381
+ var checksum = calculateChecksum(payload);
382
+ var unencoded = Buffer.concat([payload, checksum]);
383
+ return _base["default"].encode(unencoded);
384
+ }
385
+
386
+ // Computes the CRC16-XModem checksum of `payload` in little-endian order
387
+ function calculateChecksum(payload) {
388
+ var crcTable = [0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0];
389
+ var crc16 = 0x0;
390
+ for (var i = 0; i < payload.length; i += 1) {
391
+ var _byte = payload[i];
392
+ var lookupIndex = crc16 >> 8 ^ _byte;
393
+ crc16 = crc16 << 8 ^ crcTable[lookupIndex];
394
+ crc16 &= 0xffff;
395
+ }
396
+ var checksum = new Uint8Array(2);
397
+ checksum[0] = crc16 & 0xff;
398
+ checksum[1] = crc16 >> 8 & 0xff;
399
+ return checksum;
400
+ }