trace-kdzs-sdk 0.1.0 → 0.2.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.
@@ -0,0 +1,871 @@
1
+ // node_modules/js-md5/build/md5.mjs
2
+ function getDefaultExportFromCjs(x) {
3
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
4
+ }
5
+ var md5$1 = { exports: {} };
6
+ /**
7
+ * [js-md5]{@link https://github.com/emn178/js-md5}
8
+ *
9
+ * @namespace md5
10
+ * @version 0.11.0
11
+ * @author Chen, Yi-Cyuan [emn178@gmail.com]
12
+ * @copyright Chen, Yi-Cyuan 2014-2026
13
+ * @license MIT
14
+ */
15
+ (function(module) {
16
+ (function() {
17
+ var INPUT_ERROR = "input is invalid type";
18
+ var FINALIZE_ERROR = "finalize already called";
19
+ var WINDOW = typeof window === "object";
20
+ var root = WINDOW ? window : {};
21
+ if (root.JS_MD5_NO_WINDOW) WINDOW = false;
22
+ if (typeof WorkerGlobalScope !== "undefined" && typeof self !== "undefined" && self instanceof WorkerGlobalScope) root = self;
23
+ var COMMON_JS = !root.JS_MD5_NO_COMMON_JS && module.exports;
24
+ /* istanbul ignore next */
25
+ var ARRAY_BUFFER = !root.JS_MD5_NO_ARRAY_BUFFER && typeof ArrayBuffer !== "undefined";
26
+ var HEX_CHARS = "0123456789abcdef".split("");
27
+ var EXTRA = [
28
+ 128,
29
+ 32768,
30
+ 8388608,
31
+ -2147483648
32
+ ];
33
+ var SHIFT = [
34
+ 0,
35
+ 8,
36
+ 16,
37
+ 24
38
+ ];
39
+ var OUTPUT_TYPES = [
40
+ "hex",
41
+ "array",
42
+ "digest",
43
+ "arrayBuffer"
44
+ ];
45
+ OUTPUT_TYPES.push("buffer");
46
+ OUTPUT_TYPES.push("base64");
47
+ /* istanbul ignore next */
48
+ var BASE64_ENCODE_CHAR = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
49
+ var blocks = [], buffer8;
50
+ if (ARRAY_BUFFER) {
51
+ var buffer = /* @__PURE__ */ new ArrayBuffer(68);
52
+ buffer8 = new Uint8Array(buffer);
53
+ blocks = new Uint32Array(buffer);
54
+ }
55
+ var isArray = Array.isArray;
56
+ /* istanbul ignore else */
57
+ if (root.JS_MD5_NO_NODE_JS || !isArray) isArray = function(obj) {
58
+ return Object.prototype.toString.call(obj) === "[object Array]";
59
+ };
60
+ var isView = ARRAY_BUFFER ? ArrayBuffer.isView : null;
61
+ /* istanbul ignore else */
62
+ if (ARRAY_BUFFER && (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !isView)) isView = function(obj) {
63
+ return typeof obj === "object" && obj.buffer && obj.buffer.constructor === ArrayBuffer;
64
+ };
65
+ var formatMessage = function(message) {
66
+ var type = typeof message;
67
+ if (type === "string") return [message, true];
68
+ if (type !== "object" || message === null) throw new Error(INPUT_ERROR);
69
+ if (ARRAY_BUFFER && message.constructor === ArrayBuffer) return [new Uint8Array(message), false];
70
+ if (isArray(message)) return [message, false];
71
+ if (!ARRAY_BUFFER || !isView(message)) throw new Error(INPUT_ERROR);
72
+ return [new Uint8Array(message.buffer, message.byteOffset, message.byteLength), false];
73
+ };
74
+ /**
75
+ * @method hex
76
+ * @memberof md5
77
+ * @description Output hash as hex string
78
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
79
+ * @returns {String} Hex string
80
+ * @example
81
+ * md5.hex('The quick brown fox jumps over the lazy dog');
82
+ * // equal to
83
+ * md5('The quick brown fox jumps over the lazy dog');
84
+ */
85
+ /**
86
+ * @method digest
87
+ * @memberof md5
88
+ * @description Output hash as bytes array
89
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
90
+ * @returns {Array} Bytes array
91
+ * @example
92
+ * md5.digest('The quick brown fox jumps over the lazy dog');
93
+ */
94
+ /**
95
+ * @method array
96
+ * @memberof md5
97
+ * @description Output hash as bytes array
98
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
99
+ * @returns {Array} Bytes array
100
+ * @example
101
+ * md5.array('The quick brown fox jumps over the lazy dog');
102
+ */
103
+ /**
104
+ * @method arrayBuffer
105
+ * @memberof md5
106
+ * @description Output hash as ArrayBuffer
107
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
108
+ * @returns {ArrayBuffer} ArrayBuffer
109
+ * @example
110
+ * md5.arrayBuffer('The quick brown fox jumps over the lazy dog');
111
+ */
112
+ /**
113
+ * @method buffer
114
+ * @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.
115
+ * @memberof md5
116
+ * @description Output hash as ArrayBuffer
117
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
118
+ * @returns {ArrayBuffer} ArrayBuffer
119
+ * @example
120
+ * md5.buffer('The quick brown fox jumps over the lazy dog');
121
+ */
122
+ /**
123
+ * @method base64
124
+ * @memberof md5
125
+ * @description Output hash as base64 string
126
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
127
+ * @returns {String} base64 string
128
+ * @example
129
+ * md5.base64('The quick brown fox jumps over the lazy dog');
130
+ */
131
+ var createOutputMethod = function(outputType) {
132
+ return function(message) {
133
+ return new Md5(true).update(message)[outputType]();
134
+ };
135
+ };
136
+ /**
137
+ * @method create
138
+ * @memberof md5
139
+ * @description Create Md5 object
140
+ * @returns {Md5} Md5 object.
141
+ * @example
142
+ * var hash = md5.create();
143
+ */
144
+ /**
145
+ * @method update
146
+ * @memberof md5
147
+ * @description Create and update Md5 object
148
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
149
+ * @returns {Md5} Md5 object.
150
+ * @example
151
+ * var hash = md5.update('The quick brown fox jumps over the lazy dog');
152
+ * // equal to
153
+ * var hash = md5.create();
154
+ * hash.update('The quick brown fox jumps over the lazy dog');
155
+ */
156
+ var createMethod = function() {
157
+ var method = createOutputMethod("hex");
158
+ method.create = function() {
159
+ return new Md5();
160
+ };
161
+ method.update = function(message) {
162
+ return method.create().update(message);
163
+ };
164
+ for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
165
+ var type = OUTPUT_TYPES[i];
166
+ method[type] = createOutputMethod(type);
167
+ }
168
+ return method;
169
+ };
170
+ /**
171
+ * @namespace md5.hmac
172
+ */
173
+ /**
174
+ * @method hex
175
+ * @memberof md5.hmac
176
+ * @description Output hash as hex string
177
+ * @param {String|Array|Uint8Array|ArrayBuffer} key key
178
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
179
+ * @returns {String} Hex string
180
+ * @example
181
+ * md5.hmac.hex('key', 'The quick brown fox jumps over the lazy dog');
182
+ * // equal to
183
+ * md5.hmac('key', 'The quick brown fox jumps over the lazy dog');
184
+ */
185
+ /**
186
+ * @method digest
187
+ * @memberof md5.hmac
188
+ * @description Output hash as bytes array
189
+ * @param {String|Array|Uint8Array|ArrayBuffer} key key
190
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
191
+ * @returns {Array} Bytes array
192
+ * @example
193
+ * md5.hmac.digest('key', 'The quick brown fox jumps over the lazy dog');
194
+ */
195
+ /**
196
+ * @method array
197
+ * @memberof md5.hmac
198
+ * @description Output hash as bytes array
199
+ * @param {String|Array|Uint8Array|ArrayBuffer} key key
200
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
201
+ * @returns {Array} Bytes array
202
+ * @example
203
+ * md5.hmac.array('key', 'The quick brown fox jumps over the lazy dog');
204
+ */
205
+ /**
206
+ * @method arrayBuffer
207
+ * @memberof md5.hmac
208
+ * @description Output hash as ArrayBuffer
209
+ * @param {String|Array|Uint8Array|ArrayBuffer} key key
210
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
211
+ * @returns {ArrayBuffer} ArrayBuffer
212
+ * @example
213
+ * md5.hmac.arrayBuffer('key', 'The quick brown fox jumps over the lazy dog');
214
+ */
215
+ /**
216
+ * @method buffer
217
+ * @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.
218
+ * @memberof md5.hmac
219
+ * @description Output hash as ArrayBuffer
220
+ * @param {String|Array|Uint8Array|ArrayBuffer} key key
221
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
222
+ * @returns {ArrayBuffer} ArrayBuffer
223
+ * @example
224
+ * md5.hmac.buffer('key', 'The quick brown fox jumps over the lazy dog');
225
+ */
226
+ /**
227
+ * @method base64
228
+ * @memberof md5.hmac
229
+ * @description Output hash as base64 string
230
+ * @param {String|Array|Uint8Array|ArrayBuffer} key key
231
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
232
+ * @returns {String} base64 string
233
+ * @example
234
+ * md5.hmac.base64('key', 'The quick brown fox jumps over the lazy dog');
235
+ */
236
+ var createHmacOutputMethod = function(outputType) {
237
+ return function(key, message) {
238
+ return new HmacMd5(key, true).update(message)[outputType]();
239
+ };
240
+ };
241
+ /**
242
+ * @method create
243
+ * @memberof md5.hmac
244
+ * @description Create HmacMd5 object
245
+ * @param {String|Array|Uint8Array|ArrayBuffer} key key
246
+ * @returns {HmacMd5} HmacMd5 object.
247
+ * @example
248
+ * var hash = md5.hmac.create('key');
249
+ */
250
+ /**
251
+ * @method update
252
+ * @memberof md5.hmac
253
+ * @description Create and update HmacMd5 object
254
+ * @param {String|Array|Uint8Array|ArrayBuffer} key key
255
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
256
+ * @returns {HmacMd5} HmacMd5 object.
257
+ * @example
258
+ * var hash = md5.hmac.update('key', 'The quick brown fox jumps over the lazy dog');
259
+ * // equal to
260
+ * var hash = md5.hmac.create('key');
261
+ * hash.update('The quick brown fox jumps over the lazy dog');
262
+ */
263
+ var createHmacMethod = function() {
264
+ var method = createHmacOutputMethod("hex");
265
+ method.create = function(key) {
266
+ return new HmacMd5(key);
267
+ };
268
+ method.update = function(key, message) {
269
+ return method.create(key).update(message);
270
+ };
271
+ for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
272
+ var type = OUTPUT_TYPES[i];
273
+ method[type] = createHmacOutputMethod(type);
274
+ }
275
+ return method;
276
+ };
277
+ /**
278
+ * Md5 class
279
+ * @class Md5
280
+ * @description This is internal class.
281
+ * @see {@link md5.create}
282
+ */
283
+ function Md5(sharedMemory) {
284
+ if (sharedMemory) {
285
+ blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] = blocks[4] = blocks[5] = blocks[6] = blocks[7] = blocks[8] = blocks[9] = blocks[10] = blocks[11] = blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
286
+ this.blocks = blocks;
287
+ this.buffer8 = buffer8;
288
+ } else if (ARRAY_BUFFER) {
289
+ var buffer = /* @__PURE__ */ new ArrayBuffer(68);
290
+ this.buffer8 = new Uint8Array(buffer);
291
+ this.blocks = new Uint32Array(buffer);
292
+ } else this.blocks = [
293
+ 0,
294
+ 0,
295
+ 0,
296
+ 0,
297
+ 0,
298
+ 0,
299
+ 0,
300
+ 0,
301
+ 0,
302
+ 0,
303
+ 0,
304
+ 0,
305
+ 0,
306
+ 0,
307
+ 0,
308
+ 0,
309
+ 0
310
+ ];
311
+ this.h0 = this.h1 = this.h2 = this.h3 = this.start = this.bytes = this.hBytes = 0;
312
+ this.finalized = this.hashed = false;
313
+ this.first = true;
314
+ }
315
+ /**
316
+ * @method update
317
+ * @memberof Md5
318
+ * @instance
319
+ * @description Update hash
320
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
321
+ * @returns {Md5} Md5 object.
322
+ * @see {@link md5.update}
323
+ */
324
+ Md5.prototype.update = function(message) {
325
+ if (this.finalized) throw new Error(FINALIZE_ERROR);
326
+ var result = formatMessage(message);
327
+ message = result[0];
328
+ var isString = result[1];
329
+ var code, code2, index = 0, i, length = message.length, blocks = this.blocks;
330
+ var buffer8 = this.buffer8;
331
+ while (index < length) {
332
+ if (this.hashed) {
333
+ this.hashed = false;
334
+ blocks[0] = blocks[16];
335
+ blocks[16] = blocks[1] = blocks[2] = blocks[3] = blocks[4] = blocks[5] = blocks[6] = blocks[7] = blocks[8] = blocks[9] = blocks[10] = blocks[11] = blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
336
+ }
337
+ if (isString) {
338
+ if (ARRAY_BUFFER) for (i = this.start; index < length && i < 64; ++index) {
339
+ code = message.charCodeAt(index);
340
+ if (code < 128) buffer8[i++] = code;
341
+ else if (code < 2048) {
342
+ buffer8[i++] = 192 | code >>> 6;
343
+ buffer8[i++] = 128 | code & 63;
344
+ } else if (code < 55296 || code >= 57344) {
345
+ buffer8[i++] = 224 | code >>> 12;
346
+ buffer8[i++] = 128 | code >>> 6 & 63;
347
+ buffer8[i++] = 128 | code & 63;
348
+ } else if (code < 56320 && (code2 = message.charCodeAt(index + 1)) >= 56320 && code2 < 57344) {
349
+ ++index;
350
+ code = 65536 + ((code & 1023) << 10 | code2 & 1023);
351
+ buffer8[i++] = 240 | code >>> 18;
352
+ buffer8[i++] = 128 | code >>> 12 & 63;
353
+ buffer8[i++] = 128 | code >>> 6 & 63;
354
+ buffer8[i++] = 128 | code & 63;
355
+ } else {
356
+ buffer8[i++] = 239;
357
+ buffer8[i++] = 191;
358
+ buffer8[i++] = 189;
359
+ }
360
+ }
361
+ else for (i = this.start; index < length && i < 64; ++index) {
362
+ code = message.charCodeAt(index);
363
+ if (code < 128) blocks[i >>> 2] |= code << SHIFT[i++ & 3];
364
+ else if (code < 2048) {
365
+ blocks[i >>> 2] |= (192 | code >>> 6) << SHIFT[i++ & 3];
366
+ blocks[i >>> 2] |= (128 | code & 63) << SHIFT[i++ & 3];
367
+ } else if (code < 55296 || code >= 57344) {
368
+ blocks[i >>> 2] |= (224 | code >>> 12) << SHIFT[i++ & 3];
369
+ blocks[i >>> 2] |= (128 | code >>> 6 & 63) << SHIFT[i++ & 3];
370
+ blocks[i >>> 2] |= (128 | code & 63) << SHIFT[i++ & 3];
371
+ } else if (code < 56320 && (code2 = message.charCodeAt(index + 1)) >= 56320 && code2 < 57344) {
372
+ ++index;
373
+ code = 65536 + ((code & 1023) << 10 | code2 & 1023);
374
+ blocks[i >>> 2] |= (240 | code >>> 18) << SHIFT[i++ & 3];
375
+ blocks[i >>> 2] |= (128 | code >>> 12 & 63) << SHIFT[i++ & 3];
376
+ blocks[i >>> 2] |= (128 | code >>> 6 & 63) << SHIFT[i++ & 3];
377
+ blocks[i >>> 2] |= (128 | code & 63) << SHIFT[i++ & 3];
378
+ } else {
379
+ blocks[i >>> 2] |= 239 << SHIFT[i++ & 3];
380
+ blocks[i >>> 2] |= 191 << SHIFT[i++ & 3];
381
+ blocks[i >>> 2] |= 189 << SHIFT[i++ & 3];
382
+ }
383
+ }
384
+ } else if (ARRAY_BUFFER) for (i = this.start; index < length && i < 64; ++index) buffer8[i++] = message[index];
385
+ else for (i = this.start; index < length && i < 64; ++index) blocks[i >>> 2] |= message[index] << SHIFT[i++ & 3];
386
+ this.lastByteIndex = i;
387
+ this.bytes += i - this.start;
388
+ if (i >= 64) {
389
+ this.start = i - 64;
390
+ this.hash();
391
+ this.hashed = true;
392
+ } else this.start = i;
393
+ }
394
+ if (this.bytes > 4294967295) {
395
+ this.hBytes += this.bytes / 4294967296 << 0;
396
+ this.bytes = this.bytes % 4294967296;
397
+ }
398
+ return this;
399
+ };
400
+ Md5.prototype.finalize = function() {
401
+ if (this.finalized) return;
402
+ this.finalized = true;
403
+ var blocks = this.blocks, i = this.lastByteIndex;
404
+ blocks[i >>> 2] |= EXTRA[i & 3];
405
+ if (i >= 56) {
406
+ if (!this.hashed) this.hash();
407
+ blocks[0] = blocks[16];
408
+ blocks[16] = blocks[1] = blocks[2] = blocks[3] = blocks[4] = blocks[5] = blocks[6] = blocks[7] = blocks[8] = blocks[9] = blocks[10] = blocks[11] = blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
409
+ }
410
+ blocks[14] = this.bytes << 3;
411
+ blocks[15] = this.hBytes << 3 | this.bytes >>> 29;
412
+ this.hash();
413
+ };
414
+ Md5.prototype.hash = function() {
415
+ var a, b, c, d, bc, da, blocks = this.blocks;
416
+ if (this.first) {
417
+ a = blocks[0] - 680876937;
418
+ a = (a << 7 | a >>> 25) - 271733879 << 0;
419
+ d = (-1732584194 ^ a & 2004318071) + blocks[1] - 117830708;
420
+ d = (d << 12 | d >>> 20) + a << 0;
421
+ c = (-271733879 ^ d & (a ^ -271733879)) + blocks[2] - 1126478375;
422
+ c = (c << 17 | c >>> 15) + d << 0;
423
+ b = (a ^ c & (d ^ a)) + blocks[3] - 1316259209;
424
+ b = (b << 22 | b >>> 10) + c << 0;
425
+ } else {
426
+ a = this.h0;
427
+ b = this.h1;
428
+ c = this.h2;
429
+ d = this.h3;
430
+ a += (d ^ b & (c ^ d)) + blocks[0] - 680876936;
431
+ a = (a << 7 | a >>> 25) + b << 0;
432
+ d += (c ^ a & (b ^ c)) + blocks[1] - 389564586;
433
+ d = (d << 12 | d >>> 20) + a << 0;
434
+ c += (b ^ d & (a ^ b)) + blocks[2] + 606105819;
435
+ c = (c << 17 | c >>> 15) + d << 0;
436
+ b += (a ^ c & (d ^ a)) + blocks[3] - 1044525330;
437
+ b = (b << 22 | b >>> 10) + c << 0;
438
+ }
439
+ a += (d ^ b & (c ^ d)) + blocks[4] - 176418897;
440
+ a = (a << 7 | a >>> 25) + b << 0;
441
+ d += (c ^ a & (b ^ c)) + blocks[5] + 1200080426;
442
+ d = (d << 12 | d >>> 20) + a << 0;
443
+ c += (b ^ d & (a ^ b)) + blocks[6] - 1473231341;
444
+ c = (c << 17 | c >>> 15) + d << 0;
445
+ b += (a ^ c & (d ^ a)) + blocks[7] - 45705983;
446
+ b = (b << 22 | b >>> 10) + c << 0;
447
+ a += (d ^ b & (c ^ d)) + blocks[8] + 1770035416;
448
+ a = (a << 7 | a >>> 25) + b << 0;
449
+ d += (c ^ a & (b ^ c)) + blocks[9] - 1958414417;
450
+ d = (d << 12 | d >>> 20) + a << 0;
451
+ c += (b ^ d & (a ^ b)) + blocks[10] - 42063;
452
+ c = (c << 17 | c >>> 15) + d << 0;
453
+ b += (a ^ c & (d ^ a)) + blocks[11] - 1990404162;
454
+ b = (b << 22 | b >>> 10) + c << 0;
455
+ a += (d ^ b & (c ^ d)) + blocks[12] + 1804603682;
456
+ a = (a << 7 | a >>> 25) + b << 0;
457
+ d += (c ^ a & (b ^ c)) + blocks[13] - 40341101;
458
+ d = (d << 12 | d >>> 20) + a << 0;
459
+ c += (b ^ d & (a ^ b)) + blocks[14] - 1502002290;
460
+ c = (c << 17 | c >>> 15) + d << 0;
461
+ b += (a ^ c & (d ^ a)) + blocks[15] + 1236535329;
462
+ b = (b << 22 | b >>> 10) + c << 0;
463
+ a += (c ^ d & (b ^ c)) + blocks[1] - 165796510;
464
+ a = (a << 5 | a >>> 27) + b << 0;
465
+ d += (b ^ c & (a ^ b)) + blocks[6] - 1069501632;
466
+ d = (d << 9 | d >>> 23) + a << 0;
467
+ c += (a ^ b & (d ^ a)) + blocks[11] + 643717713;
468
+ c = (c << 14 | c >>> 18) + d << 0;
469
+ b += (d ^ a & (c ^ d)) + blocks[0] - 373897302;
470
+ b = (b << 20 | b >>> 12) + c << 0;
471
+ a += (c ^ d & (b ^ c)) + blocks[5] - 701558691;
472
+ a = (a << 5 | a >>> 27) + b << 0;
473
+ d += (b ^ c & (a ^ b)) + blocks[10] + 38016083;
474
+ d = (d << 9 | d >>> 23) + a << 0;
475
+ c += (a ^ b & (d ^ a)) + blocks[15] - 660478335;
476
+ c = (c << 14 | c >>> 18) + d << 0;
477
+ b += (d ^ a & (c ^ d)) + blocks[4] - 405537848;
478
+ b = (b << 20 | b >>> 12) + c << 0;
479
+ a += (c ^ d & (b ^ c)) + blocks[9] + 568446438;
480
+ a = (a << 5 | a >>> 27) + b << 0;
481
+ d += (b ^ c & (a ^ b)) + blocks[14] - 1019803690;
482
+ d = (d << 9 | d >>> 23) + a << 0;
483
+ c += (a ^ b & (d ^ a)) + blocks[3] - 187363961;
484
+ c = (c << 14 | c >>> 18) + d << 0;
485
+ b += (d ^ a & (c ^ d)) + blocks[8] + 1163531501;
486
+ b = (b << 20 | b >>> 12) + c << 0;
487
+ a += (c ^ d & (b ^ c)) + blocks[13] - 1444681467;
488
+ a = (a << 5 | a >>> 27) + b << 0;
489
+ d += (b ^ c & (a ^ b)) + blocks[2] - 51403784;
490
+ d = (d << 9 | d >>> 23) + a << 0;
491
+ c += (a ^ b & (d ^ a)) + blocks[7] + 1735328473;
492
+ c = (c << 14 | c >>> 18) + d << 0;
493
+ b += (d ^ a & (c ^ d)) + blocks[12] - 1926607734;
494
+ b = (b << 20 | b >>> 12) + c << 0;
495
+ bc = b ^ c;
496
+ a += (bc ^ d) + blocks[5] - 378558;
497
+ a = (a << 4 | a >>> 28) + b << 0;
498
+ d += (bc ^ a) + blocks[8] - 2022574463;
499
+ d = (d << 11 | d >>> 21) + a << 0;
500
+ da = d ^ a;
501
+ c += (da ^ b) + blocks[11] + 1839030562;
502
+ c = (c << 16 | c >>> 16) + d << 0;
503
+ b += (da ^ c) + blocks[14] - 35309556;
504
+ b = (b << 23 | b >>> 9) + c << 0;
505
+ bc = b ^ c;
506
+ a += (bc ^ d) + blocks[1] - 1530992060;
507
+ a = (a << 4 | a >>> 28) + b << 0;
508
+ d += (bc ^ a) + blocks[4] + 1272893353;
509
+ d = (d << 11 | d >>> 21) + a << 0;
510
+ da = d ^ a;
511
+ c += (da ^ b) + blocks[7] - 155497632;
512
+ c = (c << 16 | c >>> 16) + d << 0;
513
+ b += (da ^ c) + blocks[10] - 1094730640;
514
+ b = (b << 23 | b >>> 9) + c << 0;
515
+ bc = b ^ c;
516
+ a += (bc ^ d) + blocks[13] + 681279174;
517
+ a = (a << 4 | a >>> 28) + b << 0;
518
+ d += (bc ^ a) + blocks[0] - 358537222;
519
+ d = (d << 11 | d >>> 21) + a << 0;
520
+ da = d ^ a;
521
+ c += (da ^ b) + blocks[3] - 722521979;
522
+ c = (c << 16 | c >>> 16) + d << 0;
523
+ b += (da ^ c) + blocks[6] + 76029189;
524
+ b = (b << 23 | b >>> 9) + c << 0;
525
+ bc = b ^ c;
526
+ a += (bc ^ d) + blocks[9] - 640364487;
527
+ a = (a << 4 | a >>> 28) + b << 0;
528
+ d += (bc ^ a) + blocks[12] - 421815835;
529
+ d = (d << 11 | d >>> 21) + a << 0;
530
+ da = d ^ a;
531
+ c += (da ^ b) + blocks[15] + 530742520;
532
+ c = (c << 16 | c >>> 16) + d << 0;
533
+ b += (da ^ c) + blocks[2] - 995338651;
534
+ b = (b << 23 | b >>> 9) + c << 0;
535
+ a += (c ^ (b | ~d)) + blocks[0] - 198630844;
536
+ a = (a << 6 | a >>> 26) + b << 0;
537
+ d += (b ^ (a | ~c)) + blocks[7] + 1126891415;
538
+ d = (d << 10 | d >>> 22) + a << 0;
539
+ c += (a ^ (d | ~b)) + blocks[14] - 1416354905;
540
+ c = (c << 15 | c >>> 17) + d << 0;
541
+ b += (d ^ (c | ~a)) + blocks[5] - 57434055;
542
+ b = (b << 21 | b >>> 11) + c << 0;
543
+ a += (c ^ (b | ~d)) + blocks[12] + 1700485571;
544
+ a = (a << 6 | a >>> 26) + b << 0;
545
+ d += (b ^ (a | ~c)) + blocks[3] - 1894986606;
546
+ d = (d << 10 | d >>> 22) + a << 0;
547
+ c += (a ^ (d | ~b)) + blocks[10] - 1051523;
548
+ c = (c << 15 | c >>> 17) + d << 0;
549
+ b += (d ^ (c | ~a)) + blocks[1] - 2054922799;
550
+ b = (b << 21 | b >>> 11) + c << 0;
551
+ a += (c ^ (b | ~d)) + blocks[8] + 1873313359;
552
+ a = (a << 6 | a >>> 26) + b << 0;
553
+ d += (b ^ (a | ~c)) + blocks[15] - 30611744;
554
+ d = (d << 10 | d >>> 22) + a << 0;
555
+ c += (a ^ (d | ~b)) + blocks[6] - 1560198380;
556
+ c = (c << 15 | c >>> 17) + d << 0;
557
+ b += (d ^ (c | ~a)) + blocks[13] + 1309151649;
558
+ b = (b << 21 | b >>> 11) + c << 0;
559
+ a += (c ^ (b | ~d)) + blocks[4] - 145523070;
560
+ a = (a << 6 | a >>> 26) + b << 0;
561
+ d += (b ^ (a | ~c)) + blocks[11] - 1120210379;
562
+ d = (d << 10 | d >>> 22) + a << 0;
563
+ c += (a ^ (d | ~b)) + blocks[2] + 718787259;
564
+ c = (c << 15 | c >>> 17) + d << 0;
565
+ b += (d ^ (c | ~a)) + blocks[9] - 343485551;
566
+ b = (b << 21 | b >>> 11) + c << 0;
567
+ if (this.first) {
568
+ this.h0 = a + 1732584193 << 0;
569
+ this.h1 = b - 271733879 << 0;
570
+ this.h2 = c - 1732584194 << 0;
571
+ this.h3 = d + 271733878 << 0;
572
+ this.first = false;
573
+ } else {
574
+ this.h0 = this.h0 + a << 0;
575
+ this.h1 = this.h1 + b << 0;
576
+ this.h2 = this.h2 + c << 0;
577
+ this.h3 = this.h3 + d << 0;
578
+ }
579
+ };
580
+ /**
581
+ * @method hex
582
+ * @memberof Md5
583
+ * @instance
584
+ * @description Output hash as hex string
585
+ * @returns {String} Hex string
586
+ * @see {@link md5.hex}
587
+ * @example
588
+ * hash.hex();
589
+ */
590
+ Md5.prototype.hex = function() {
591
+ this.finalize();
592
+ var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3;
593
+ return HEX_CHARS[h0 >>> 4 & 15] + HEX_CHARS[h0 & 15] + HEX_CHARS[h0 >>> 12 & 15] + HEX_CHARS[h0 >>> 8 & 15] + HEX_CHARS[h0 >>> 20 & 15] + HEX_CHARS[h0 >>> 16 & 15] + HEX_CHARS[h0 >>> 28 & 15] + HEX_CHARS[h0 >>> 24 & 15] + HEX_CHARS[h1 >>> 4 & 15] + HEX_CHARS[h1 & 15] + HEX_CHARS[h1 >>> 12 & 15] + HEX_CHARS[h1 >>> 8 & 15] + HEX_CHARS[h1 >>> 20 & 15] + HEX_CHARS[h1 >>> 16 & 15] + HEX_CHARS[h1 >>> 28 & 15] + HEX_CHARS[h1 >>> 24 & 15] + HEX_CHARS[h2 >>> 4 & 15] + HEX_CHARS[h2 & 15] + HEX_CHARS[h2 >>> 12 & 15] + HEX_CHARS[h2 >>> 8 & 15] + HEX_CHARS[h2 >>> 20 & 15] + HEX_CHARS[h2 >>> 16 & 15] + HEX_CHARS[h2 >>> 28 & 15] + HEX_CHARS[h2 >>> 24 & 15] + HEX_CHARS[h3 >>> 4 & 15] + HEX_CHARS[h3 & 15] + HEX_CHARS[h3 >>> 12 & 15] + HEX_CHARS[h3 >>> 8 & 15] + HEX_CHARS[h3 >>> 20 & 15] + HEX_CHARS[h3 >>> 16 & 15] + HEX_CHARS[h3 >>> 28 & 15] + HEX_CHARS[h3 >>> 24 & 15];
594
+ };
595
+ /**
596
+ * @method toString
597
+ * @memberof Md5
598
+ * @instance
599
+ * @description Output hash as hex string
600
+ * @returns {String} Hex string
601
+ * @see {@link md5.hex}
602
+ * @example
603
+ * hash.toString();
604
+ */
605
+ Md5.prototype.toString = Md5.prototype.hex;
606
+ /**
607
+ * @method digest
608
+ * @memberof Md5
609
+ * @instance
610
+ * @description Output hash as bytes array
611
+ * @returns {Array} Bytes array
612
+ * @see {@link md5.digest}
613
+ * @example
614
+ * hash.digest();
615
+ */
616
+ Md5.prototype.digest = function() {
617
+ this.finalize();
618
+ var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3;
619
+ return [
620
+ h0 & 255,
621
+ h0 >>> 8 & 255,
622
+ h0 >>> 16 & 255,
623
+ h0 >>> 24 & 255,
624
+ h1 & 255,
625
+ h1 >>> 8 & 255,
626
+ h1 >>> 16 & 255,
627
+ h1 >>> 24 & 255,
628
+ h2 & 255,
629
+ h2 >>> 8 & 255,
630
+ h2 >>> 16 & 255,
631
+ h2 >>> 24 & 255,
632
+ h3 & 255,
633
+ h3 >>> 8 & 255,
634
+ h3 >>> 16 & 255,
635
+ h3 >>> 24 & 255
636
+ ];
637
+ };
638
+ /**
639
+ * @method array
640
+ * @memberof Md5
641
+ * @instance
642
+ * @description Output hash as bytes array
643
+ * @returns {Array} Bytes array
644
+ * @see {@link md5.array}
645
+ * @example
646
+ * hash.array();
647
+ */
648
+ Md5.prototype.array = Md5.prototype.digest;
649
+ /**
650
+ * @method arrayBuffer
651
+ * @memberof Md5
652
+ * @instance
653
+ * @description Output hash as ArrayBuffer
654
+ * @returns {ArrayBuffer} ArrayBuffer
655
+ * @see {@link md5.arrayBuffer}
656
+ * @example
657
+ * hash.arrayBuffer();
658
+ */
659
+ Md5.prototype.arrayBuffer = function() {
660
+ this.finalize();
661
+ var buffer = /* @__PURE__ */ new ArrayBuffer(16);
662
+ var blocks = new Uint32Array(buffer);
663
+ blocks[0] = this.h0;
664
+ blocks[1] = this.h1;
665
+ blocks[2] = this.h2;
666
+ blocks[3] = this.h3;
667
+ return buffer;
668
+ };
669
+ Md5.prototype.buffer = Md5.prototype.arrayBuffer;
670
+ Md5.prototype.base64 = function() {
671
+ var v1, v2, v3, base64Str = "", bytes = this.array();
672
+ for (var i = 0; i < 15;) {
673
+ v1 = bytes[i++];
674
+ v2 = bytes[i++];
675
+ v3 = bytes[i++];
676
+ base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] + BASE64_ENCODE_CHAR[(v1 << 4 | v2 >>> 4) & 63] + BASE64_ENCODE_CHAR[(v2 << 2 | v3 >>> 6) & 63] + BASE64_ENCODE_CHAR[v3 & 63];
677
+ }
678
+ v1 = bytes[i];
679
+ base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] + BASE64_ENCODE_CHAR[v1 << 4 & 63] + "==";
680
+ return base64Str;
681
+ };
682
+ /**
683
+ * HmacMd5 class
684
+ * @class HmacMd5
685
+ * @extends Md5
686
+ * @description This is internal class.
687
+ * @see {@link md5.hmac.create}
688
+ */
689
+ function HmacMd5(key, sharedMemory) {
690
+ var i, result = formatMessage(key);
691
+ key = result[0];
692
+ if (result[1]) {
693
+ var bytes = [], length = key.length, index = 0, code, code2;
694
+ for (i = 0; i < length; ++i) {
695
+ code = key.charCodeAt(i);
696
+ if (code < 128) bytes[index++] = code;
697
+ else if (code < 2048) {
698
+ bytes[index++] = 192 | code >>> 6;
699
+ bytes[index++] = 128 | code & 63;
700
+ } else if (code < 55296 || code >= 57344) {
701
+ bytes[index++] = 224 | code >>> 12;
702
+ bytes[index++] = 128 | code >>> 6 & 63;
703
+ bytes[index++] = 128 | code & 63;
704
+ } else if (code < 56320 && (code2 = key.charCodeAt(i + 1)) >= 56320 && code2 < 57344) {
705
+ ++i;
706
+ code = 65536 + ((code & 1023) << 10 | code2 & 1023);
707
+ bytes[index++] = 240 | code >>> 18;
708
+ bytes[index++] = 128 | code >>> 12 & 63;
709
+ bytes[index++] = 128 | code >>> 6 & 63;
710
+ bytes[index++] = 128 | code & 63;
711
+ } else {
712
+ bytes[index++] = 239;
713
+ bytes[index++] = 191;
714
+ bytes[index++] = 189;
715
+ }
716
+ }
717
+ key = bytes;
718
+ }
719
+ if (key.length > 64) key = new Md5(true).update(key).array();
720
+ var oKeyPad = [], iKeyPad = [];
721
+ for (i = 0; i < 64; ++i) {
722
+ var b = key[i] || 0;
723
+ oKeyPad[i] = 92 ^ b;
724
+ iKeyPad[i] = 54 ^ b;
725
+ }
726
+ Md5.call(this, sharedMemory);
727
+ this.update(iKeyPad);
728
+ this.oKeyPad = oKeyPad;
729
+ this.inner = true;
730
+ this.sharedMemory = sharedMemory;
731
+ }
732
+ HmacMd5.prototype = new Md5();
733
+ HmacMd5.prototype.finalize = function() {
734
+ Md5.prototype.finalize.call(this);
735
+ if (this.inner) {
736
+ this.inner = false;
737
+ var innerHash = this.array();
738
+ Md5.call(this, this.sharedMemory);
739
+ this.update(this.oKeyPad);
740
+ this.update(innerHash);
741
+ Md5.prototype.finalize.call(this);
742
+ }
743
+ };
744
+ var exports = createMethod();
745
+ exports.md5 = exports;
746
+ exports.md5.hmac = createHmacMethod();
747
+ if (COMMON_JS) module.exports = exports;
748
+ else
749
+ /**
750
+ * @method md5
751
+ * @description Md5 hash function, export to global in browsers.
752
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
753
+ * @returns {String} md5 hashes
754
+ * @example
755
+ * md5(''); // d41d8cd98f00b204e9800998ecf8427e
756
+ * md5('The quick brown fox jumps over the lazy dog'); // 9e107d9d372bb6826bd81d3542a419d6
757
+ * md5('The quick brown fox jumps over the lazy dog.'); // e4d909c290d0fb1ca068ffaddf22cbd0
758
+ *
759
+ * // It also supports UTF-8 encoding
760
+ * md5('中文'); // a7bac2239fcdcb3a067903d8077c4a07
761
+ *
762
+ * // It also supports byte `Array`, `Uint8Array`, `ArrayBuffer`
763
+ * md5([]); // d41d8cd98f00b204e9800998ecf8427e
764
+ * md5(new Uint8Array([])); // d41d8cd98f00b204e9800998ecf8427e
765
+ */
766
+ root.md5 = exports;
767
+ })();
768
+ })(md5$1);
769
+ var md5Exports = md5$1.exports;
770
+ var md5 = /*@__PURE__*/ getDefaultExportFromCjs(md5Exports);
771
+ // node_modules/@lukeed/uuid/dist/index.mjs
772
+ var IDX = 256;
773
+ var HEX = [];
774
+ var BUFFER;
775
+ while (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1);
776
+ function v4() {
777
+ var i = 0, num, out = "";
778
+ if (!BUFFER || IDX + 16 > 256) {
779
+ BUFFER = Array(i = 256);
780
+ while (i--) BUFFER[i] = 256 * Math.random() | 0;
781
+ i = IDX = 0;
782
+ }
783
+ for (; i < 16; i++) {
784
+ num = BUFFER[IDX + i];
785
+ if (i == 6) out += HEX[num & 15 | 64];
786
+ else if (i == 8) out += HEX[num & 63 | 128];
787
+ else out += HEX[num];
788
+ if (i & 1 && i > 1 && i < 11) out += "-";
789
+ }
790
+ IDX++;
791
+ return out;
792
+ }
793
+ // src/core/index.ts
794
+ function generateTraceId() {
795
+ return v4().replace(/-/g, "").slice(0, 16);
796
+ }
797
+ function snapshot(page) {
798
+ return {
799
+ ...page,
800
+ spanId: `S${page.spanId}`
801
+ };
802
+ }
803
+ var TraceCore = class {
804
+ constructor(options = {}) {
805
+ var _options$generateFlow, _options$generateTrac;
806
+ this.pages = /* @__PURE__ */ new Map();
807
+ this.appId = options.appId;
808
+ this.generateFlowId = (_options$generateFlow = options.generateFlowId) !== null && _options$generateFlow !== void 0 ? _options$generateFlow : ((pageKey) => md5(pageKey).slice(0, 8));
809
+ this.generateTraceId = (_options$generateTrac = options.generateTraceId) !== null && _options$generateTrac !== void 0 ? _options$generateTrac : generateTraceId;
810
+ }
811
+ /** 由适配器提供页面解析能力,core 不依赖平台路由对象。 */
812
+ setPageKeyResolver(resolve) {
813
+ this.resolvePageKey = resolve;
814
+ }
815
+ getPageKey() {
816
+ if (!this.resolvePageKey) throw new Error("请先注册页面解析器");
817
+ return this.resolvePageKey();
818
+ }
819
+ /** 开启新业务,使用新的 traceId并重置请求序号 */
820
+ startTrace(pageKey = this.getPageKey()) {
821
+ const page = this.getOrCreatePage(pageKey);
822
+ const traceId = generateTraceId();
823
+ page.previousTraceId = page.traceId;
824
+ page.traceId = traceId;
825
+ page.spanId = 0;
826
+ return traceId;
827
+ }
828
+ ensurePage(pageKey) {
829
+ return snapshot(this.getOrCreatePage(pageKey));
830
+ }
831
+ getContext(pageKey) {
832
+ const page = this.pages.get(pageKey);
833
+ return page ? snapshot(page) : void 0;
834
+ }
835
+ setFlowId(pageKey, flowId) {
836
+ this.getOrCreatePage(pageKey).flowId = flowId;
837
+ }
838
+ setTraceId(pageKey, traceId) {
839
+ const page = this.getOrCreatePage(pageKey);
840
+ if (page.traceId !== traceId) {
841
+ page.previousTraceId = page.traceId;
842
+ page.traceId = traceId;
843
+ }
844
+ }
845
+ nextRequestContext(pageKey) {
846
+ const page = this.getOrCreatePage(pageKey);
847
+ page.spanId += 1;
848
+ return snapshot(page);
849
+ }
850
+ removePage(pageKey) {
851
+ return this.pages.delete(pageKey);
852
+ }
853
+ clear() {
854
+ this.pages.clear();
855
+ }
856
+ getOrCreatePage(pageKey) {
857
+ const existing = this.pages.get(pageKey);
858
+ if (existing) return existing;
859
+ const flowId = this.generateFlowId(pageKey);
860
+ const page = {
861
+ flowId,
862
+ traceId: this.generateTraceId(pageKey, flowId),
863
+ spanId: 0
864
+ };
865
+ this.pages.set(pageKey, page);
866
+ return page;
867
+ }
868
+ };
869
+ export { TraceCore as t };
870
+
871
+ //# sourceMappingURL=core-DQb65OGC.mjs.map