expf-sigma-node.js 3.0.2 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/public/sigma.js +1616 -1604
package/public/sigma.js
CHANGED
|
@@ -1,1604 +1,1616 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
-
mod
|
|
22
|
-
));
|
|
23
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
-
|
|
25
|
-
// src/sigma.js
|
|
26
|
-
var sigma_exports = {};
|
|
27
|
-
__export(sigma_exports, {
|
|
28
|
-
default: () => sigma_default
|
|
29
|
-
});
|
|
30
|
-
module.exports = __toCommonJS(sigma_exports);
|
|
31
|
-
var import_node_fetch = __toESM(require("node-fetch"));
|
|
32
|
-
|
|
33
|
-
// src/modules/sigmaUserData.js
|
|
34
|
-
var SigmaUserData = class {
|
|
35
|
-
constructor() {
|
|
36
|
-
this.user = {
|
|
37
|
-
userId: null,
|
|
38
|
-
profileId: null,
|
|
39
|
-
deviceId: null,
|
|
40
|
-
ip: null,
|
|
41
|
-
email: null,
|
|
42
|
-
appVersion: null,
|
|
43
|
-
geo: {
|
|
44
|
-
country: null,
|
|
45
|
-
code: null,
|
|
46
|
-
state: null,
|
|
47
|
-
city: null
|
|
48
|
-
},
|
|
49
|
-
browser: {
|
|
50
|
-
version: null,
|
|
51
|
-
name: null
|
|
52
|
-
},
|
|
53
|
-
os: {
|
|
54
|
-
version: null,
|
|
55
|
-
name: null
|
|
56
|
-
},
|
|
57
|
-
custom: {
|
|
58
|
-
name: null,
|
|
59
|
-
value: null
|
|
60
|
-
},
|
|
61
|
-
time: null,
|
|
62
|
-
date: null,
|
|
63
|
-
deviceCategory: null,
|
|
64
|
-
featureFlags: [],
|
|
65
|
-
domain: null,
|
|
66
|
-
url: null,
|
|
67
|
-
query: null,
|
|
68
|
-
pathname: null
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
init({
|
|
72
|
-
userId,
|
|
73
|
-
profileId,
|
|
74
|
-
deviceId,
|
|
75
|
-
ip,
|
|
76
|
-
email,
|
|
77
|
-
appVersion,
|
|
78
|
-
custom,
|
|
79
|
-
deviceCategory,
|
|
80
|
-
os,
|
|
81
|
-
browser,
|
|
82
|
-
geo,
|
|
83
|
-
domain,
|
|
84
|
-
url,
|
|
85
|
-
query,
|
|
86
|
-
pathname
|
|
87
|
-
}) {
|
|
88
|
-
this.user.userId = userId;
|
|
89
|
-
this.user.profileId = profileId;
|
|
90
|
-
this.user.deviceId = deviceId;
|
|
91
|
-
this.user.ip = ip;
|
|
92
|
-
this.user.email = email;
|
|
93
|
-
this.user.appVersion = appVersion;
|
|
94
|
-
this.user.custom = custom;
|
|
95
|
-
this.user.time = new Date().getTime() / (1e3 * 60 * 60);
|
|
96
|
-
this.user.date = Math.floor(new Date().getTime() / (1e3 * 60 * 60 * 24));
|
|
97
|
-
this.user.deviceCategory = deviceCategory;
|
|
98
|
-
this.user.os = os;
|
|
99
|
-
this.user.browser = browser;
|
|
100
|
-
this.user.geo = geo;
|
|
101
|
-
this.user.domain = domain;
|
|
102
|
-
this.user.url = url;
|
|
103
|
-
this.user.query = query;
|
|
104
|
-
this.user.pathname = pathname;
|
|
105
|
-
}
|
|
106
|
-
setUserId(userId) {
|
|
107
|
-
this.user.userId = userId;
|
|
108
|
-
}
|
|
109
|
-
setIp(ip) {
|
|
110
|
-
this.user.ip = ip;
|
|
111
|
-
}
|
|
112
|
-
addFlag(flagName, flagRule) {
|
|
113
|
-
const { user } = this;
|
|
114
|
-
user.featureFlags.
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
this.user.
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
var
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
function
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
);
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
)
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
x
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
function
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
this.
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
throw new Error(
|
|
1068
|
-
}
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
const
|
|
1090
|
-
this.
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
try {
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
if (
|
|
1110
|
-
throw new Error(`
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
return
|
|
1231
|
-
case "
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
return
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
const
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
}
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
if (!
|
|
1372
|
-
|
|
1373
|
-
}
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
if (!
|
|
1433
|
-
return null;
|
|
1434
|
-
}
|
|
1435
|
-
|
|
1436
|
-
let
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
for (let
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
}
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
}
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
return
|
|
1600
|
-
}
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
|
|
25
|
+
// src/sigma.js
|
|
26
|
+
var sigma_exports = {};
|
|
27
|
+
__export(sigma_exports, {
|
|
28
|
+
default: () => sigma_default
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(sigma_exports);
|
|
31
|
+
var import_node_fetch = __toESM(require("node-fetch"));
|
|
32
|
+
|
|
33
|
+
// src/modules/sigmaUserData.js
|
|
34
|
+
var SigmaUserData = class {
|
|
35
|
+
constructor() {
|
|
36
|
+
this.user = {
|
|
37
|
+
userId: null,
|
|
38
|
+
profileId: null,
|
|
39
|
+
deviceId: null,
|
|
40
|
+
ip: null,
|
|
41
|
+
email: null,
|
|
42
|
+
appVersion: null,
|
|
43
|
+
geo: {
|
|
44
|
+
country: null,
|
|
45
|
+
code: null,
|
|
46
|
+
state: null,
|
|
47
|
+
city: null
|
|
48
|
+
},
|
|
49
|
+
browser: {
|
|
50
|
+
version: null,
|
|
51
|
+
name: null
|
|
52
|
+
},
|
|
53
|
+
os: {
|
|
54
|
+
version: null,
|
|
55
|
+
name: null
|
|
56
|
+
},
|
|
57
|
+
custom: {
|
|
58
|
+
name: null,
|
|
59
|
+
value: null
|
|
60
|
+
},
|
|
61
|
+
time: null,
|
|
62
|
+
date: null,
|
|
63
|
+
deviceCategory: null,
|
|
64
|
+
featureFlags: [],
|
|
65
|
+
domain: null,
|
|
66
|
+
url: null,
|
|
67
|
+
query: null,
|
|
68
|
+
pathname: null
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
init({
|
|
72
|
+
userId,
|
|
73
|
+
profileId,
|
|
74
|
+
deviceId,
|
|
75
|
+
ip,
|
|
76
|
+
email,
|
|
77
|
+
appVersion,
|
|
78
|
+
custom,
|
|
79
|
+
deviceCategory,
|
|
80
|
+
os,
|
|
81
|
+
browser,
|
|
82
|
+
geo,
|
|
83
|
+
domain,
|
|
84
|
+
url,
|
|
85
|
+
query,
|
|
86
|
+
pathname
|
|
87
|
+
}) {
|
|
88
|
+
this.user.userId = userId;
|
|
89
|
+
this.user.profileId = profileId;
|
|
90
|
+
this.user.deviceId = deviceId;
|
|
91
|
+
this.user.ip = ip;
|
|
92
|
+
this.user.email = email;
|
|
93
|
+
this.user.appVersion = appVersion;
|
|
94
|
+
this.user.custom = custom;
|
|
95
|
+
this.user.time = new Date().getTime() / (1e3 * 60 * 60);
|
|
96
|
+
this.user.date = Math.floor(new Date().getTime() / (1e3 * 60 * 60 * 24));
|
|
97
|
+
this.user.deviceCategory = deviceCategory;
|
|
98
|
+
this.user.os = os;
|
|
99
|
+
this.user.browser = browser;
|
|
100
|
+
this.user.geo = geo;
|
|
101
|
+
this.user.domain = domain;
|
|
102
|
+
this.user.url = url;
|
|
103
|
+
this.user.query = query;
|
|
104
|
+
this.user.pathname = pathname;
|
|
105
|
+
}
|
|
106
|
+
setUserId(userId) {
|
|
107
|
+
this.user.userId = userId;
|
|
108
|
+
}
|
|
109
|
+
setIp(ip) {
|
|
110
|
+
this.user.ip = ip;
|
|
111
|
+
}
|
|
112
|
+
addFlag(flagName, flagRule) {
|
|
113
|
+
const { user } = this;
|
|
114
|
+
const userHasFlag = user.featureFlags.find((item) => item.name === flagName);
|
|
115
|
+
if (!userHasFlag) {
|
|
116
|
+
user.featureFlags.push({
|
|
117
|
+
name: flagName,
|
|
118
|
+
rule: flagRule
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
clearFlags() {
|
|
123
|
+
this.user.featureFlags = [];
|
|
124
|
+
}
|
|
125
|
+
setGeo(data) {
|
|
126
|
+
this.user.geo = data;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// src/modules/sigmaCache.js
|
|
131
|
+
var import_node_cache = __toESM(require("node-cache"));
|
|
132
|
+
|
|
133
|
+
// src/modules/sigmaHashes.js
|
|
134
|
+
var Hashes;
|
|
135
|
+
function utf8Encode(str) {
|
|
136
|
+
var x, y, output = "", i = -1, l;
|
|
137
|
+
if (str && str.length) {
|
|
138
|
+
l = str.length;
|
|
139
|
+
while ((i += 1) < l) {
|
|
140
|
+
x = str.charCodeAt(i);
|
|
141
|
+
y = i + 1 < l ? str.charCodeAt(i + 1) : 0;
|
|
142
|
+
if (55296 <= x && x <= 56319 && 56320 <= y && y <= 57343) {
|
|
143
|
+
x = 65536 + ((x & 1023) << 10) + (y & 1023);
|
|
144
|
+
i += 1;
|
|
145
|
+
}
|
|
146
|
+
if (x <= 127) {
|
|
147
|
+
output += String.fromCharCode(x);
|
|
148
|
+
} else if (x <= 2047) {
|
|
149
|
+
output += String.fromCharCode(
|
|
150
|
+
192 | x >>> 6 & 31,
|
|
151
|
+
128 | x & 63
|
|
152
|
+
);
|
|
153
|
+
} else if (x <= 65535) {
|
|
154
|
+
output += String.fromCharCode(
|
|
155
|
+
224 | x >>> 12 & 15,
|
|
156
|
+
128 | x >>> 6 & 63,
|
|
157
|
+
128 | x & 63
|
|
158
|
+
);
|
|
159
|
+
} else if (x <= 2097151) {
|
|
160
|
+
output += String.fromCharCode(
|
|
161
|
+
240 | x >>> 18 & 7,
|
|
162
|
+
128 | x >>> 12 & 63,
|
|
163
|
+
128 | x >>> 6 & 63,
|
|
164
|
+
128 | x & 63
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return output;
|
|
170
|
+
}
|
|
171
|
+
function utf8Decode(str) {
|
|
172
|
+
var i, ac, c1, c2, c3, arr = [], l;
|
|
173
|
+
i = ac = c1 = c2 = c3 = 0;
|
|
174
|
+
if (str && str.length) {
|
|
175
|
+
l = str.length;
|
|
176
|
+
str += "";
|
|
177
|
+
while (i < l) {
|
|
178
|
+
c1 = str.charCodeAt(i);
|
|
179
|
+
ac += 1;
|
|
180
|
+
if (c1 < 128) {
|
|
181
|
+
arr[ac] = String.fromCharCode(c1);
|
|
182
|
+
i += 1;
|
|
183
|
+
} else if (c1 > 191 && c1 < 224) {
|
|
184
|
+
c2 = str.charCodeAt(i + 1);
|
|
185
|
+
arr[ac] = String.fromCharCode((c1 & 31) << 6 | c2 & 63);
|
|
186
|
+
i += 2;
|
|
187
|
+
} else {
|
|
188
|
+
c2 = str.charCodeAt(i + 1);
|
|
189
|
+
c3 = str.charCodeAt(i + 2);
|
|
190
|
+
arr[ac] = String.fromCharCode(
|
|
191
|
+
(c1 & 15) << 12 | (c2 & 63) << 6 | c3 & 63
|
|
192
|
+
);
|
|
193
|
+
i += 3;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return arr.join("");
|
|
198
|
+
}
|
|
199
|
+
function safe_add(x, y) {
|
|
200
|
+
var lsw = (x & 65535) + (y & 65535), msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
|
201
|
+
return msw << 16 | lsw & 65535;
|
|
202
|
+
}
|
|
203
|
+
function bit_rol(num, cnt) {
|
|
204
|
+
return num << cnt | num >>> 32 - cnt;
|
|
205
|
+
}
|
|
206
|
+
function rstr2hex(input, hexcase) {
|
|
207
|
+
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef", output = "", x, i = 0, l = input.length;
|
|
208
|
+
for (; i < l; i += 1) {
|
|
209
|
+
x = input.charCodeAt(i);
|
|
210
|
+
output += hex_tab.charAt(x >>> 4 & 15) + hex_tab.charAt(x & 15);
|
|
211
|
+
}
|
|
212
|
+
return output;
|
|
213
|
+
}
|
|
214
|
+
function binb2rstr(input) {
|
|
215
|
+
var i, l = input.length * 32, output = "";
|
|
216
|
+
for (i = 0; i < l; i += 8) {
|
|
217
|
+
output += String.fromCharCode(input[i >> 5] >>> 24 - i % 32 & 255);
|
|
218
|
+
}
|
|
219
|
+
return output;
|
|
220
|
+
}
|
|
221
|
+
function binl2rstr(input) {
|
|
222
|
+
var i, l = input.length * 32, output = "";
|
|
223
|
+
for (i = 0; i < l; i += 8) {
|
|
224
|
+
output += String.fromCharCode(input[i >> 5] >>> i % 32 & 255);
|
|
225
|
+
}
|
|
226
|
+
return output;
|
|
227
|
+
}
|
|
228
|
+
function rstr2binl(input) {
|
|
229
|
+
var i, l = input.length * 8, output = Array(input.length >> 2), lo = output.length;
|
|
230
|
+
for (i = 0; i < lo; i += 1) {
|
|
231
|
+
output[i] = 0;
|
|
232
|
+
}
|
|
233
|
+
for (i = 0; i < l; i += 8) {
|
|
234
|
+
output[i >> 5] |= (input.charCodeAt(i / 8) & 255) << i % 32;
|
|
235
|
+
}
|
|
236
|
+
return output;
|
|
237
|
+
}
|
|
238
|
+
function rstr2binb(input) {
|
|
239
|
+
var i, l = input.length * 8, output = Array(input.length >> 2), lo = output.length;
|
|
240
|
+
for (i = 0; i < lo; i += 1) {
|
|
241
|
+
output[i] = 0;
|
|
242
|
+
}
|
|
243
|
+
for (i = 0; i < l; i += 8) {
|
|
244
|
+
output[i >> 5] |= (input.charCodeAt(i / 8) & 255) << 24 - i % 32;
|
|
245
|
+
}
|
|
246
|
+
return output;
|
|
247
|
+
}
|
|
248
|
+
function rstr2any(input, encoding) {
|
|
249
|
+
var divisor = encoding.length, remainders = Array(), i, q, x, ld, quotient, dividend, output, full_length;
|
|
250
|
+
dividend = Array(Math.ceil(input.length / 2));
|
|
251
|
+
ld = dividend.length;
|
|
252
|
+
for (i = 0; i < ld; i += 1) {
|
|
253
|
+
dividend[i] = input.charCodeAt(i * 2) << 8 | input.charCodeAt(i * 2 + 1);
|
|
254
|
+
}
|
|
255
|
+
while (dividend.length > 0) {
|
|
256
|
+
quotient = Array();
|
|
257
|
+
x = 0;
|
|
258
|
+
for (i = 0; i < dividend.length; i += 1) {
|
|
259
|
+
x = (x << 16) + dividend[i];
|
|
260
|
+
q = Math.floor(x / divisor);
|
|
261
|
+
x -= q * divisor;
|
|
262
|
+
if (quotient.length > 0 || q > 0) {
|
|
263
|
+
quotient[quotient.length] = q;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
remainders[remainders.length] = x;
|
|
267
|
+
dividend = quotient;
|
|
268
|
+
}
|
|
269
|
+
output = "";
|
|
270
|
+
for (i = remainders.length - 1; i >= 0; i--) {
|
|
271
|
+
output += encoding.charAt(remainders[i]);
|
|
272
|
+
}
|
|
273
|
+
full_length = Math.ceil(
|
|
274
|
+
input.length * 8 / (Math.log(encoding.length) / Math.log(2))
|
|
275
|
+
);
|
|
276
|
+
for (i = output.length; i < full_length; i += 1) {
|
|
277
|
+
output = encoding[0] + output;
|
|
278
|
+
}
|
|
279
|
+
return output;
|
|
280
|
+
}
|
|
281
|
+
function rstr2b64(input, b64pad) {
|
|
282
|
+
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", output = "", len2 = input.length, i, j, triplet;
|
|
283
|
+
b64pad = b64pad || "=";
|
|
284
|
+
for (i = 0; i < len2; i += 3) {
|
|
285
|
+
triplet = input.charCodeAt(i) << 16 | (i + 1 < len2 ? input.charCodeAt(i + 1) << 8 : 0) | (i + 2 < len2 ? input.charCodeAt(i + 2) : 0);
|
|
286
|
+
for (j = 0; j < 4; j += 1) {
|
|
287
|
+
if (i * 8 + j * 6 > input.length * 8) {
|
|
288
|
+
output += b64pad;
|
|
289
|
+
} else {
|
|
290
|
+
output += tab.charAt(triplet >>> 6 * (3 - j) & 63);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return output;
|
|
295
|
+
}
|
|
296
|
+
Hashes = {
|
|
297
|
+
VERSION: "1.0.6",
|
|
298
|
+
Base64: function() {
|
|
299
|
+
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", pad = "=", url = false, utf8 = true;
|
|
300
|
+
this.encode = function(input) {
|
|
301
|
+
var i, j, triplet, output = "";
|
|
302
|
+
pad = pad || "=";
|
|
303
|
+
input = utf8 ? utf8Encode(input) : input;
|
|
304
|
+
len = input.length;
|
|
305
|
+
for (i = 0; i < len; i += 3) {
|
|
306
|
+
triplet = input.charCodeAt(i) << 16 | (i + 1 < len ? input.charCodeAt(i + 1) << 8 : 0) | (i + 2 < len ? input.charCodeAt(i + 2) : 0);
|
|
307
|
+
for (j = 0; j < 4; j += 1) {
|
|
308
|
+
if (i * 8 + j * 6 > len * 8) {
|
|
309
|
+
output += pad;
|
|
310
|
+
} else {
|
|
311
|
+
output += tab.charAt(triplet >>> 6 * (3 - j) & 63);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return output;
|
|
316
|
+
};
|
|
317
|
+
this.decode = function(input) {
|
|
318
|
+
var i, o1, o2, o3, h1, h2, h3, h4, bits, ac, dec = "", arr = [];
|
|
319
|
+
if (!input) {
|
|
320
|
+
return input;
|
|
321
|
+
}
|
|
322
|
+
i = ac = 0;
|
|
323
|
+
input = input.replace(new RegExp("\\" + pad, "gi"), "");
|
|
324
|
+
do {
|
|
325
|
+
h1 = tab.indexOf(input.charAt(i++));
|
|
326
|
+
h2 = tab.indexOf(input.charAt(i++));
|
|
327
|
+
h3 = tab.indexOf(input.charAt(i++));
|
|
328
|
+
h4 = tab.indexOf(input.charAt(i++));
|
|
329
|
+
bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;
|
|
330
|
+
o1 = bits >> 16 & 255;
|
|
331
|
+
o2 = bits >> 8 & 255;
|
|
332
|
+
o3 = bits & 255;
|
|
333
|
+
ac += 1;
|
|
334
|
+
if (h3 === 64) {
|
|
335
|
+
arr[ac] = String.fromCharCode(o1);
|
|
336
|
+
} else if (h4 === 64) {
|
|
337
|
+
arr[ac] = String.fromCharCode(o1, o2);
|
|
338
|
+
} else {
|
|
339
|
+
arr[ac] = String.fromCharCode(o1, o2, o3);
|
|
340
|
+
}
|
|
341
|
+
} while (i < input.length);
|
|
342
|
+
dec = arr.join("");
|
|
343
|
+
dec = utf8 ? utf8Decode(dec) : dec;
|
|
344
|
+
return dec;
|
|
345
|
+
};
|
|
346
|
+
this.setPad = function(str) {
|
|
347
|
+
pad = str || pad;
|
|
348
|
+
return this;
|
|
349
|
+
};
|
|
350
|
+
this.setTab = function(str) {
|
|
351
|
+
tab = str || tab;
|
|
352
|
+
return this;
|
|
353
|
+
};
|
|
354
|
+
this.setUTF8 = function(bool) {
|
|
355
|
+
if (typeof bool === "boolean") {
|
|
356
|
+
utf8 = bool;
|
|
357
|
+
}
|
|
358
|
+
return this;
|
|
359
|
+
};
|
|
360
|
+
},
|
|
361
|
+
CRC32: function(str) {
|
|
362
|
+
var crc = 0, x = 0, y = 0, table, i, iTop;
|
|
363
|
+
str = utf8Encode(str);
|
|
364
|
+
table = [
|
|
365
|
+
"00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 ",
|
|
366
|
+
"79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 ",
|
|
367
|
+
"84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F ",
|
|
368
|
+
"63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD ",
|
|
369
|
+
"A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC ",
|
|
370
|
+
"51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 ",
|
|
371
|
+
"B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 ",
|
|
372
|
+
"06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 ",
|
|
373
|
+
"E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 ",
|
|
374
|
+
"12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 ",
|
|
375
|
+
"D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 ",
|
|
376
|
+
"33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 ",
|
|
377
|
+
"CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 ",
|
|
378
|
+
"9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E ",
|
|
379
|
+
"7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D ",
|
|
380
|
+
"806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 ",
|
|
381
|
+
"60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA ",
|
|
382
|
+
"AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 ",
|
|
383
|
+
"5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 ",
|
|
384
|
+
"B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 ",
|
|
385
|
+
"05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 ",
|
|
386
|
+
"F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA ",
|
|
387
|
+
"11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 ",
|
|
388
|
+
"D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F ",
|
|
389
|
+
"30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E ",
|
|
390
|
+
"C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D"
|
|
391
|
+
].join("");
|
|
392
|
+
crc = crc ^ -1;
|
|
393
|
+
for (i = 0, iTop = str.length; i < iTop; i += 1) {
|
|
394
|
+
y = (crc ^ str.charCodeAt(i)) & 255;
|
|
395
|
+
x = "0x" + table.substr(y * 9, 8);
|
|
396
|
+
crc = crc >>> 8 ^ x;
|
|
397
|
+
}
|
|
398
|
+
return (crc ^ -1) >>> 0;
|
|
399
|
+
},
|
|
400
|
+
MD5: function(options) {
|
|
401
|
+
var hexcase = options && typeof options.uppercase === "boolean" ? options.uppercase : false, b64pad = options && typeof options.pad === "string" ? options.pad : "=", utf8 = options && typeof options.utf8 === "boolean" ? options.utf8 : true;
|
|
402
|
+
this.hex = function(s) {
|
|
403
|
+
return rstr2hex(rstr(s, utf8), hexcase);
|
|
404
|
+
};
|
|
405
|
+
this.setUpperCase = function(a) {
|
|
406
|
+
if (typeof a === "boolean") {
|
|
407
|
+
hexcase = a;
|
|
408
|
+
}
|
|
409
|
+
return this;
|
|
410
|
+
};
|
|
411
|
+
this.setPad = function(a) {
|
|
412
|
+
b64pad = a || b64pad;
|
|
413
|
+
return this;
|
|
414
|
+
};
|
|
415
|
+
this.setUTF8 = function(a) {
|
|
416
|
+
if (typeof a === "boolean") {
|
|
417
|
+
utf8 = a;
|
|
418
|
+
}
|
|
419
|
+
return this;
|
|
420
|
+
};
|
|
421
|
+
function rstr(s) {
|
|
422
|
+
s = utf8 ? utf8Encode(s) : s;
|
|
423
|
+
return binl2rstr(binl(rstr2binl(s), s.length * 8));
|
|
424
|
+
}
|
|
425
|
+
function rstr_hmac(key, data) {
|
|
426
|
+
var bkey, ipad, opad, hash, i;
|
|
427
|
+
key = utf8 ? utf8Encode(key) : key;
|
|
428
|
+
data = utf8 ? utf8Encode(data) : data;
|
|
429
|
+
bkey = rstr2binl(key);
|
|
430
|
+
if (bkey.length > 16) {
|
|
431
|
+
bkey = binl(bkey, key.length * 8);
|
|
432
|
+
}
|
|
433
|
+
ipad = Array(16), opad = Array(16);
|
|
434
|
+
for (i = 0; i < 16; i += 1) {
|
|
435
|
+
ipad[i] = bkey[i] ^ 909522486;
|
|
436
|
+
opad[i] = bkey[i] ^ 1549556828;
|
|
437
|
+
}
|
|
438
|
+
hash = binl(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
|
|
439
|
+
return binl2rstr(binl(opad.concat(hash), 512 + 128));
|
|
440
|
+
}
|
|
441
|
+
function binl(x, len2) {
|
|
442
|
+
var i, olda, oldb, oldc, oldd, a = 1732584193, b = -271733879, c = -1732584194, d = 271733878;
|
|
443
|
+
x[len2 >> 5] |= 128 << len2 % 32;
|
|
444
|
+
x[(len2 + 64 >>> 9 << 4) + 14] = len2;
|
|
445
|
+
for (i = 0; i < x.length; i += 16) {
|
|
446
|
+
olda = a;
|
|
447
|
+
oldb = b;
|
|
448
|
+
oldc = c;
|
|
449
|
+
oldd = d;
|
|
450
|
+
a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936);
|
|
451
|
+
d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
|
|
452
|
+
c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
|
|
453
|
+
b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
|
|
454
|
+
a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
|
|
455
|
+
d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
|
|
456
|
+
c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
|
|
457
|
+
b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
|
|
458
|
+
a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
|
|
459
|
+
d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
|
|
460
|
+
c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
|
|
461
|
+
b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
|
|
462
|
+
a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
|
|
463
|
+
d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
|
|
464
|
+
c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
|
|
465
|
+
b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
|
|
466
|
+
a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
|
|
467
|
+
d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
|
|
468
|
+
c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
|
|
469
|
+
b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302);
|
|
470
|
+
a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
|
|
471
|
+
d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
|
|
472
|
+
c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
|
|
473
|
+
b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
|
|
474
|
+
a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
|
|
475
|
+
d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
|
|
476
|
+
c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
|
|
477
|
+
b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
|
|
478
|
+
a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
|
|
479
|
+
d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
|
|
480
|
+
c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
|
|
481
|
+
b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
|
|
482
|
+
a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
|
|
483
|
+
d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
|
|
484
|
+
c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
|
|
485
|
+
b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
|
|
486
|
+
a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
|
|
487
|
+
d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
|
|
488
|
+
c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
|
|
489
|
+
b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
|
|
490
|
+
a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
|
|
491
|
+
d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222);
|
|
492
|
+
c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
|
|
493
|
+
b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
|
|
494
|
+
a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
|
|
495
|
+
d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
|
|
496
|
+
c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
|
|
497
|
+
b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
|
|
498
|
+
a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844);
|
|
499
|
+
d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
|
|
500
|
+
c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
|
|
501
|
+
b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
|
|
502
|
+
a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
|
|
503
|
+
d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
|
|
504
|
+
c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
|
|
505
|
+
b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
|
|
506
|
+
a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
|
|
507
|
+
d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
|
|
508
|
+
c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
|
|
509
|
+
b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
|
|
510
|
+
a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
|
|
511
|
+
d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
|
|
512
|
+
c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
|
|
513
|
+
b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
|
|
514
|
+
a = safe_add(a, olda);
|
|
515
|
+
b = safe_add(b, oldb);
|
|
516
|
+
c = safe_add(c, oldc);
|
|
517
|
+
d = safe_add(d, oldd);
|
|
518
|
+
}
|
|
519
|
+
return Array(a, b, c, d);
|
|
520
|
+
}
|
|
521
|
+
function md5_cmn(q, a, b, x, s, t) {
|
|
522
|
+
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
|
|
523
|
+
}
|
|
524
|
+
function md5_ff(a, b, c, d, x, s, t) {
|
|
525
|
+
return md5_cmn(b & c | ~b & d, a, b, x, s, t);
|
|
526
|
+
}
|
|
527
|
+
function md5_gg(a, b, c, d, x, s, t) {
|
|
528
|
+
return md5_cmn(b & d | c & ~d, a, b, x, s, t);
|
|
529
|
+
}
|
|
530
|
+
function md5_hh(a, b, c, d, x, s, t) {
|
|
531
|
+
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
|
|
532
|
+
}
|
|
533
|
+
function md5_ii(a, b, c, d, x, s, t) {
|
|
534
|
+
return md5_cmn(c ^ (b | ~d), a, b, x, s, t);
|
|
535
|
+
}
|
|
536
|
+
},
|
|
537
|
+
SHA256: function(options) {
|
|
538
|
+
var hexcase = options && typeof options.uppercase === "boolean" ? options.uppercase : false, b64pad = options && typeof options.pad === "string" ? options.pad : "=", utf8 = options && typeof options.utf8 === "boolean" ? options.utf8 : true, sha256_K;
|
|
539
|
+
this.hex = function(s) {
|
|
540
|
+
return rstr2hex(rstr(s, utf8));
|
|
541
|
+
};
|
|
542
|
+
this.b64 = function(s) {
|
|
543
|
+
return rstr2b64(rstr(s, utf8), b64pad);
|
|
544
|
+
};
|
|
545
|
+
this.any = function(s, e) {
|
|
546
|
+
return rstr2any(rstr(s, utf8), e);
|
|
547
|
+
};
|
|
548
|
+
this.raw = function(s) {
|
|
549
|
+
return rstr(s, utf8);
|
|
550
|
+
};
|
|
551
|
+
this.hex_hmac = function(k, d) {
|
|
552
|
+
return rstr2hex(rstr_hmac(k, d));
|
|
553
|
+
};
|
|
554
|
+
this.b64_hmac = function(k, d) {
|
|
555
|
+
return rstr2b64(rstr_hmac(k, d), b64pad);
|
|
556
|
+
};
|
|
557
|
+
this.any_hmac = function(k, d, e) {
|
|
558
|
+
return rstr2any(rstr_hmac(k, d), e);
|
|
559
|
+
};
|
|
560
|
+
this.vm_test = function() {
|
|
561
|
+
return hex("abc").toLowerCase() === "900150983cd24fb0d6963f7d28e17f72";
|
|
562
|
+
};
|
|
563
|
+
this.setUpperCase = function(a) {
|
|
564
|
+
if (typeof a === "boolean") {
|
|
565
|
+
hexcase = a;
|
|
566
|
+
}
|
|
567
|
+
return this;
|
|
568
|
+
};
|
|
569
|
+
this.setPad = function(a) {
|
|
570
|
+
b64pad = a || b64pad;
|
|
571
|
+
return this;
|
|
572
|
+
};
|
|
573
|
+
this.setUTF8 = function(a) {
|
|
574
|
+
if (typeof a === "boolean") {
|
|
575
|
+
utf8 = a;
|
|
576
|
+
}
|
|
577
|
+
return this;
|
|
578
|
+
};
|
|
579
|
+
function rstr(s, utf82) {
|
|
580
|
+
s = utf82 ? utf8Encode(s) : s;
|
|
581
|
+
return binb2rstr(binb(rstr2binb(s), s.length * 8));
|
|
582
|
+
}
|
|
583
|
+
function rstr_hmac(key, data) {
|
|
584
|
+
key = utf8 ? utf8Encode(key) : key;
|
|
585
|
+
data = utf8 ? utf8Encode(data) : data;
|
|
586
|
+
var hash, i = 0, bkey = rstr2binb(key), ipad = Array(16), opad = Array(16);
|
|
587
|
+
if (bkey.length > 16) {
|
|
588
|
+
bkey = binb(bkey, key.length * 8);
|
|
589
|
+
}
|
|
590
|
+
for (; i < 16; i += 1) {
|
|
591
|
+
ipad[i] = bkey[i] ^ 909522486;
|
|
592
|
+
opad[i] = bkey[i] ^ 1549556828;
|
|
593
|
+
}
|
|
594
|
+
hash = binb(ipad.concat(rstr2binb(data)), 512 + data.length * 8);
|
|
595
|
+
return binb2rstr(binb(opad.concat(hash), 512 + 256));
|
|
596
|
+
}
|
|
597
|
+
function sha256_S(X, n) {
|
|
598
|
+
return X >>> n | X << 32 - n;
|
|
599
|
+
}
|
|
600
|
+
function sha256_R(X, n) {
|
|
601
|
+
return X >>> n;
|
|
602
|
+
}
|
|
603
|
+
function sha256_Ch(x, y, z) {
|
|
604
|
+
return x & y ^ ~x & z;
|
|
605
|
+
}
|
|
606
|
+
function sha256_Maj(x, y, z) {
|
|
607
|
+
return x & y ^ x & z ^ y & z;
|
|
608
|
+
}
|
|
609
|
+
function sha256_Sigma0256(x) {
|
|
610
|
+
return sha256_S(x, 2) ^ sha256_S(x, 13) ^ sha256_S(x, 22);
|
|
611
|
+
}
|
|
612
|
+
function sha256_Sigma1256(x) {
|
|
613
|
+
return sha256_S(x, 6) ^ sha256_S(x, 11) ^ sha256_S(x, 25);
|
|
614
|
+
}
|
|
615
|
+
function sha256_Gamma0256(x) {
|
|
616
|
+
return sha256_S(x, 7) ^ sha256_S(x, 18) ^ sha256_R(x, 3);
|
|
617
|
+
}
|
|
618
|
+
function sha256_Gamma1256(x) {
|
|
619
|
+
return sha256_S(x, 17) ^ sha256_S(x, 19) ^ sha256_R(x, 10);
|
|
620
|
+
}
|
|
621
|
+
function sha256_Sigma0512(x) {
|
|
622
|
+
return sha256_S(x, 28) ^ sha256_S(x, 34) ^ sha256_S(x, 39);
|
|
623
|
+
}
|
|
624
|
+
function sha256_Sigma1512(x) {
|
|
625
|
+
return sha256_S(x, 14) ^ sha256_S(x, 18) ^ sha256_S(x, 41);
|
|
626
|
+
}
|
|
627
|
+
function sha256_Gamma0512(x) {
|
|
628
|
+
return sha256_S(x, 1) ^ sha256_S(x, 8) ^ sha256_R(x, 7);
|
|
629
|
+
}
|
|
630
|
+
function sha256_Gamma1512(x) {
|
|
631
|
+
return sha256_S(x, 19) ^ sha256_S(x, 61) ^ sha256_R(x, 6);
|
|
632
|
+
}
|
|
633
|
+
sha256_K = [
|
|
634
|
+
1116352408,
|
|
635
|
+
1899447441,
|
|
636
|
+
-1245643825,
|
|
637
|
+
-373957723,
|
|
638
|
+
961987163,
|
|
639
|
+
1508970993,
|
|
640
|
+
-1841331548,
|
|
641
|
+
-1424204075,
|
|
642
|
+
-670586216,
|
|
643
|
+
310598401,
|
|
644
|
+
607225278,
|
|
645
|
+
1426881987,
|
|
646
|
+
1925078388,
|
|
647
|
+
-2132889090,
|
|
648
|
+
-1680079193,
|
|
649
|
+
-1046744716,
|
|
650
|
+
-459576895,
|
|
651
|
+
-272742522,
|
|
652
|
+
264347078,
|
|
653
|
+
604807628,
|
|
654
|
+
770255983,
|
|
655
|
+
1249150122,
|
|
656
|
+
1555081692,
|
|
657
|
+
1996064986,
|
|
658
|
+
-1740746414,
|
|
659
|
+
-1473132947,
|
|
660
|
+
-1341970488,
|
|
661
|
+
-1084653625,
|
|
662
|
+
-958395405,
|
|
663
|
+
-710438585,
|
|
664
|
+
113926993,
|
|
665
|
+
338241895,
|
|
666
|
+
666307205,
|
|
667
|
+
773529912,
|
|
668
|
+
1294757372,
|
|
669
|
+
1396182291,
|
|
670
|
+
1695183700,
|
|
671
|
+
1986661051,
|
|
672
|
+
-2117940946,
|
|
673
|
+
-1838011259,
|
|
674
|
+
-1564481375,
|
|
675
|
+
-1474664885,
|
|
676
|
+
-1035236496,
|
|
677
|
+
-949202525,
|
|
678
|
+
-778901479,
|
|
679
|
+
-694614492,
|
|
680
|
+
-200395387,
|
|
681
|
+
275423344,
|
|
682
|
+
430227734,
|
|
683
|
+
506948616,
|
|
684
|
+
659060556,
|
|
685
|
+
883997877,
|
|
686
|
+
958139571,
|
|
687
|
+
1322822218,
|
|
688
|
+
1537002063,
|
|
689
|
+
1747873779,
|
|
690
|
+
1955562222,
|
|
691
|
+
2024104815,
|
|
692
|
+
-2067236844,
|
|
693
|
+
-1933114872,
|
|
694
|
+
-1866530822,
|
|
695
|
+
-1538233109,
|
|
696
|
+
-1090935817,
|
|
697
|
+
-965641998
|
|
698
|
+
];
|
|
699
|
+
function binb(m, l) {
|
|
700
|
+
var HASH = [
|
|
701
|
+
1779033703,
|
|
702
|
+
-1150833019,
|
|
703
|
+
1013904242,
|
|
704
|
+
-1521486534,
|
|
705
|
+
1359893119,
|
|
706
|
+
-1694144372,
|
|
707
|
+
528734635,
|
|
708
|
+
1541459225
|
|
709
|
+
];
|
|
710
|
+
var W = new Array(64);
|
|
711
|
+
var a, b, c, d, e, f, g, h;
|
|
712
|
+
var i, j, T1, T2;
|
|
713
|
+
m[l >> 5] |= 128 << 24 - l % 32;
|
|
714
|
+
m[(l + 64 >> 9 << 4) + 15] = l;
|
|
715
|
+
for (i = 0; i < m.length; i += 16) {
|
|
716
|
+
a = HASH[0];
|
|
717
|
+
b = HASH[1];
|
|
718
|
+
c = HASH[2];
|
|
719
|
+
d = HASH[3];
|
|
720
|
+
e = HASH[4];
|
|
721
|
+
f = HASH[5];
|
|
722
|
+
g = HASH[6];
|
|
723
|
+
h = HASH[7];
|
|
724
|
+
for (j = 0; j < 64; j += 1) {
|
|
725
|
+
if (j < 16) {
|
|
726
|
+
W[j] = m[j + i];
|
|
727
|
+
} else {
|
|
728
|
+
W[j] = safe_add(
|
|
729
|
+
safe_add(
|
|
730
|
+
safe_add(sha256_Gamma1256(W[j - 2]), W[j - 7]),
|
|
731
|
+
sha256_Gamma0256(W[j - 15])
|
|
732
|
+
),
|
|
733
|
+
W[j - 16]
|
|
734
|
+
);
|
|
735
|
+
}
|
|
736
|
+
T1 = safe_add(
|
|
737
|
+
safe_add(
|
|
738
|
+
safe_add(safe_add(h, sha256_Sigma1256(e)), sha256_Ch(e, f, g)),
|
|
739
|
+
sha256_K[j]
|
|
740
|
+
),
|
|
741
|
+
W[j]
|
|
742
|
+
);
|
|
743
|
+
T2 = safe_add(sha256_Sigma0256(a), sha256_Maj(a, b, c));
|
|
744
|
+
h = g;
|
|
745
|
+
g = f;
|
|
746
|
+
f = e;
|
|
747
|
+
e = safe_add(d, T1);
|
|
748
|
+
d = c;
|
|
749
|
+
c = b;
|
|
750
|
+
b = a;
|
|
751
|
+
a = safe_add(T1, T2);
|
|
752
|
+
}
|
|
753
|
+
HASH[0] = safe_add(a, HASH[0]);
|
|
754
|
+
HASH[1] = safe_add(b, HASH[1]);
|
|
755
|
+
HASH[2] = safe_add(c, HASH[2]);
|
|
756
|
+
HASH[3] = safe_add(d, HASH[3]);
|
|
757
|
+
HASH[4] = safe_add(e, HASH[4]);
|
|
758
|
+
HASH[5] = safe_add(f, HASH[5]);
|
|
759
|
+
HASH[6] = safe_add(g, HASH[6]);
|
|
760
|
+
HASH[7] = safe_add(h, HASH[7]);
|
|
761
|
+
}
|
|
762
|
+
return HASH;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
};
|
|
766
|
+
var sigmaHashes_default = Hashes;
|
|
767
|
+
|
|
768
|
+
// src/helpers/constants.js
|
|
769
|
+
var defaultApi = "https://api.expf.ru/api/v1";
|
|
770
|
+
var sigmaUserId = "sigmaUserId";
|
|
771
|
+
var sigmaProfileId = "sigmaProfileId";
|
|
772
|
+
var sigmaDeviceId = "sigmaDeviceId";
|
|
773
|
+
var sigmaPrivateId = "sigmaPrivateId";
|
|
774
|
+
var sigmaHash = "sigmaHash";
|
|
775
|
+
var sigmaDataFileLastUpdate = "sigmaDataFileLastUpdate";
|
|
776
|
+
var sigmaExpiration = "sigmaExpiration";
|
|
777
|
+
var sigmaDataFile = "sigmaDataFile";
|
|
778
|
+
var sigmaExperiments = "sigmaExperiments";
|
|
779
|
+
var max_decimal_64 = 18446744073709552e3;
|
|
780
|
+
var zeta = 8540717056e4;
|
|
781
|
+
var SHA256 = new sigmaHashes_default.SHA256();
|
|
782
|
+
var MD5 = new sigmaHashes_default.MD5();
|
|
783
|
+
var expirationDate = 24 * 60 * 60 * 1e3;
|
|
784
|
+
var secondsIn24Hours = 24 * 60 * 60;
|
|
785
|
+
|
|
786
|
+
// src/modules/sigmaCache.js
|
|
787
|
+
var sigmaCache = new import_node_cache.default({ stdTTL: secondsIn24Hours });
|
|
788
|
+
var SigmaCache = class {
|
|
789
|
+
constructor(postfix) {
|
|
790
|
+
this.postfix = "";
|
|
791
|
+
if (postfix)
|
|
792
|
+
this.postfix = "__" + postfix;
|
|
793
|
+
}
|
|
794
|
+
get(key) {
|
|
795
|
+
try {
|
|
796
|
+
return sigmaCache.get(key + this.postfix);
|
|
797
|
+
} catch (e) {
|
|
798
|
+
console.log(e);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
set(key, value) {
|
|
802
|
+
try {
|
|
803
|
+
sigmaCache.set(key + this.postfix, value);
|
|
804
|
+
return;
|
|
805
|
+
} catch (e) {
|
|
806
|
+
console.log(e);
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
remove(key) {
|
|
810
|
+
try {
|
|
811
|
+
return sigmaCache.del(key + this.postfix);
|
|
812
|
+
} catch (e) {
|
|
813
|
+
console.log(e);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
parse(data) {
|
|
817
|
+
if (!this.get(data)) {
|
|
818
|
+
throw new Error(`${data} not found in cache`);
|
|
819
|
+
}
|
|
820
|
+
return JSON.parse(this.get(data));
|
|
821
|
+
}
|
|
822
|
+
};
|
|
823
|
+
|
|
824
|
+
// src/modules/sigmaGeoCache.js
|
|
825
|
+
var import_node_cache2 = __toESM(require("node-cache"));
|
|
826
|
+
var defaultGeoCacheTTL = 5 * 60;
|
|
827
|
+
var maxGeoCacheTTL = 120 * 60;
|
|
828
|
+
var minGeoCacheTTL = 1 * 60;
|
|
829
|
+
var sigmaGeoCache = new import_node_cache2.default({ stdTTL: secondsIn24Hours });
|
|
830
|
+
var SigmaGeoCache = class {
|
|
831
|
+
constructor(postfix, geoCacheTTL) {
|
|
832
|
+
this.geoCacheTTL = geoCacheTTL || defaultGeoCacheTTL;
|
|
833
|
+
if (geoCacheTTL > maxGeoCacheTTL || geoCacheTTL < minGeoCacheTTL) {
|
|
834
|
+
this.geoCacheTTL = defaultGeoCacheTTL;
|
|
835
|
+
}
|
|
836
|
+
this.postfix = "";
|
|
837
|
+
if (postfix)
|
|
838
|
+
this.postfix = "__" + postfix;
|
|
839
|
+
}
|
|
840
|
+
get(key) {
|
|
841
|
+
try {
|
|
842
|
+
return sigmaGeoCache.get(key + this.postfix);
|
|
843
|
+
} catch (e) {
|
|
844
|
+
console.log(e);
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
set(key, value) {
|
|
848
|
+
try {
|
|
849
|
+
return sigmaGeoCache.set(key + this.postfix, value, this.geoCacheTTL);
|
|
850
|
+
} catch (e) {
|
|
851
|
+
console.log(e);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
keys() {
|
|
855
|
+
return sigmaGeoCache.keys();
|
|
856
|
+
}
|
|
857
|
+
};
|
|
858
|
+
|
|
859
|
+
// src/helpers/checkBoolValue.js
|
|
860
|
+
function checkBoolValue(value) {
|
|
861
|
+
if (value)
|
|
862
|
+
return true;
|
|
863
|
+
return false;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
// src/helpers/checkForcedList.js
|
|
867
|
+
function checkForcedList(usersList, data) {
|
|
868
|
+
if (usersList.length) {
|
|
869
|
+
for (let id in usersList) {
|
|
870
|
+
if (usersList[id] == data) {
|
|
871
|
+
return true;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
return false;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
// src/helpers/compareVersions.js
|
|
879
|
+
function compareVersions(versionA, versionB, strict = true) {
|
|
880
|
+
let resultCompare;
|
|
881
|
+
const versionsLength = Math.max(versionA.length, versionB.length);
|
|
882
|
+
versionA = (versionA + "").split(".");
|
|
883
|
+
versionB = (versionB + "").split(".");
|
|
884
|
+
for (let i = 0; i < versionsLength; i++) {
|
|
885
|
+
if (versionA[i] === void 0) {
|
|
886
|
+
versionA[i] = "0";
|
|
887
|
+
}
|
|
888
|
+
if (versionB[i] === void 0) {
|
|
889
|
+
versionB[i] = "0";
|
|
890
|
+
}
|
|
891
|
+
resultCompare = parseInt(versionA[i], 10) - parseInt(versionB[i], 10);
|
|
892
|
+
if (resultCompare !== 0) {
|
|
893
|
+
return resultCompare < 0 ? false : true;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
if (strict) {
|
|
897
|
+
return false;
|
|
898
|
+
}
|
|
899
|
+
if (!strict) {
|
|
900
|
+
return true;
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
// src/helpers/delay.js
|
|
905
|
+
function delay(ms) {
|
|
906
|
+
return new Promise((resolve) => setTimeout(() => resolve(void 0), ms));
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
// src/helpers/digestHash.js
|
|
910
|
+
function digestHash(string) {
|
|
911
|
+
let hash = 0, i, chr;
|
|
912
|
+
if (string.length === 0)
|
|
913
|
+
return hash;
|
|
914
|
+
for (i = 0; i < string.length; i++) {
|
|
915
|
+
chr = string.charCodeAt(i);
|
|
916
|
+
hash = (hash << 5) - hash + chr;
|
|
917
|
+
hash |= 0;
|
|
918
|
+
}
|
|
919
|
+
return hash;
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
// src/helpers/doTypeConversion.js
|
|
923
|
+
function doTypeConversion(type, value) {
|
|
924
|
+
if (type === "string")
|
|
925
|
+
return value;
|
|
926
|
+
if (type === "bool") {
|
|
927
|
+
return value === "true" ? true : false;
|
|
928
|
+
}
|
|
929
|
+
if (type === "integer" || type === "number")
|
|
930
|
+
return parseFloat(value);
|
|
931
|
+
return value;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
// src/helpers/generateRandomId.js
|
|
935
|
+
function generateRandomId() {
|
|
936
|
+
let text = "";
|
|
937
|
+
let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
938
|
+
for (let i = 0; i < 80; i++)
|
|
939
|
+
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
|
940
|
+
return text;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
// src/helpers/getUserGroup.js
|
|
944
|
+
function getUserGroup(salt, exposureRate, controlBucketPerc, forcedExp) {
|
|
945
|
+
let userInGroup = "a";
|
|
946
|
+
let currentDiapason = 0;
|
|
947
|
+
if (Math.abs(salt) / 100 <= parseFloat(exposureRate) * 100 || forcedExp) {
|
|
948
|
+
let bucket = Math.abs(salt) % 100;
|
|
949
|
+
for (let i = 0; i < controlBucketPerc.length; i++) {
|
|
950
|
+
currentDiapason += controlBucketPerc[i].weight * 100;
|
|
951
|
+
if (bucket <= currentDiapason) {
|
|
952
|
+
return userInGroup = controlBucketPerc[i].name;
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
return userInGroup;
|
|
956
|
+
}
|
|
957
|
+
return false;
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
// src/sigma.js
|
|
961
|
+
if (typeof import_node_fetch.default.default !== "undefined")
|
|
962
|
+
import_node_fetch.default.default;
|
|
963
|
+
var Sigma = class {
|
|
964
|
+
constructor(token, userData, cacheTTL = 10, options = {
|
|
965
|
+
api: "",
|
|
966
|
+
retries: "",
|
|
967
|
+
postfix: "",
|
|
968
|
+
geoCacheTTL: null
|
|
969
|
+
}) {
|
|
970
|
+
if (!token) {
|
|
971
|
+
throw new Error("Please specify a token");
|
|
972
|
+
}
|
|
973
|
+
this.token = token;
|
|
974
|
+
this.userData = userData || {};
|
|
975
|
+
cacheTTL < 10 ? this.cacheTTL = 10 : this.cacheTTL = cacheTTL;
|
|
976
|
+
this.api = options.api || `${defaultApi}`;
|
|
977
|
+
this.retries = options.retries || 3;
|
|
978
|
+
this.sigmaUserData = new SigmaUserData();
|
|
979
|
+
this.postfix = options.postfix || "";
|
|
980
|
+
this.cache = new SigmaCache(this.postfix);
|
|
981
|
+
this.sigmaUserData.init({
|
|
982
|
+
userId: this.userData.userId || null,
|
|
983
|
+
profileId: this.userData.profileId || null,
|
|
984
|
+
deviceId: this.userData.deviceId || null,
|
|
985
|
+
ip: this.userData.ip || null,
|
|
986
|
+
email: this.userData.email || null,
|
|
987
|
+
appVersion: this.userData.appVersion || null,
|
|
988
|
+
custom: this.userData.custom || null,
|
|
989
|
+
deviceCategory: this.userData.deviceCategory || null,
|
|
990
|
+
browser: this.userData.browser || { version: null, name: null },
|
|
991
|
+
os: this.userData.os || { version: null, name: null },
|
|
992
|
+
geo: this.userData.geo || null,
|
|
993
|
+
domain: this.userData.domain || null,
|
|
994
|
+
url: this.userData.url || null,
|
|
995
|
+
query: this.userData.query || null,
|
|
996
|
+
pathname: this.userData.pathname || null
|
|
997
|
+
});
|
|
998
|
+
this.geoCache = new SigmaGeoCache(this.token, options.geoCacheTTL);
|
|
999
|
+
this.setSplitIdsToCache(this.userData);
|
|
1000
|
+
this.makePrivateIdInCache();
|
|
1001
|
+
}
|
|
1002
|
+
setSplitIdsToCache(userData) {
|
|
1003
|
+
for (let [key, value] of Object.entries(userData)) {
|
|
1004
|
+
if (!value || !String(value).trim().length)
|
|
1005
|
+
continue;
|
|
1006
|
+
switch (key) {
|
|
1007
|
+
case "userId":
|
|
1008
|
+
this.cache.set(sigmaUserId, String(value).trim());
|
|
1009
|
+
this.cache.set(sigmaExpiration, new Date().getTime() + expirationDate);
|
|
1010
|
+
break;
|
|
1011
|
+
case "profileId":
|
|
1012
|
+
this.cache.set(sigmaProfileId, String(value).trim());
|
|
1013
|
+
break;
|
|
1014
|
+
case "deviceId":
|
|
1015
|
+
this.cache.set(sigmaDeviceId, String(value).trim());
|
|
1016
|
+
break;
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
makePrivateIdInCache() {
|
|
1021
|
+
let privateId = this.cache.get(sigmaPrivateId);
|
|
1022
|
+
if (!privateId) {
|
|
1023
|
+
privateId = generateRandomId();
|
|
1024
|
+
this.cache.set(sigmaPrivateId, privateId);
|
|
1025
|
+
}
|
|
1026
|
+
return privateId;
|
|
1027
|
+
}
|
|
1028
|
+
retryFetch(url, fetchOptions, retries = 3, timeout) {
|
|
1029
|
+
return new Promise((resolve, reject) => {
|
|
1030
|
+
if (timeout)
|
|
1031
|
+
setTimeout(() => reject("error: timeout"), timeout);
|
|
1032
|
+
const wrapper = (n) => {
|
|
1033
|
+
(0, import_node_fetch.default)(url, fetchOptions).then((res) => resolve(res)).catch((err) => {
|
|
1034
|
+
if (n > 0) {
|
|
1035
|
+
delay(1e3).then(() => {
|
|
1036
|
+
wrapper(--n);
|
|
1037
|
+
});
|
|
1038
|
+
} else {
|
|
1039
|
+
reject(err);
|
|
1040
|
+
}
|
|
1041
|
+
});
|
|
1042
|
+
};
|
|
1043
|
+
wrapper(retries);
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
async getDataFile(url, method, body) {
|
|
1047
|
+
const options = {
|
|
1048
|
+
method: method || "GET",
|
|
1049
|
+
body,
|
|
1050
|
+
credentials: "same-origin",
|
|
1051
|
+
headers: {
|
|
1052
|
+
"ip": this.userData.ip,
|
|
1053
|
+
"X-Real-IP": this.userData.ip,
|
|
1054
|
+
token: this.token,
|
|
1055
|
+
"user-id": this.cache.get(sigmaPrivateId)
|
|
1056
|
+
}
|
|
1057
|
+
};
|
|
1058
|
+
if (method !== "GET") {
|
|
1059
|
+
options.headers["Content-Type"] = "application/json; charset=utf-8";
|
|
1060
|
+
}
|
|
1061
|
+
const data = await this.retryFetch(
|
|
1062
|
+
url,
|
|
1063
|
+
options,
|
|
1064
|
+
this.retries
|
|
1065
|
+
);
|
|
1066
|
+
if (data.status !== 200) {
|
|
1067
|
+
throw new Error(`${data.status} Token: ${this.token}`);
|
|
1068
|
+
}
|
|
1069
|
+
return data.json();
|
|
1070
|
+
}
|
|
1071
|
+
async getUserGeoData() {
|
|
1072
|
+
try {
|
|
1073
|
+
const data = await this.getDataFile(`${this.api}/geo`);
|
|
1074
|
+
return data;
|
|
1075
|
+
} catch (error) {
|
|
1076
|
+
throw new Error(`Get geo: ${error}`);
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
async setUserGeoData() {
|
|
1080
|
+
if (!this.userData.ip)
|
|
1081
|
+
return;
|
|
1082
|
+
const geoKey = `${this.userData.ip}__${this.token}`;
|
|
1083
|
+
const foundingGeoKey = this.geoCache.keys().find((k) => k === geoKey);
|
|
1084
|
+
if (foundingGeoKey) {
|
|
1085
|
+
const userGeoData = this.geoCache.get(this.userData.ip);
|
|
1086
|
+
this.sigmaUserData.setGeo(userGeoData);
|
|
1087
|
+
return;
|
|
1088
|
+
} else {
|
|
1089
|
+
const userGeoData = await this.getUserGeoData();
|
|
1090
|
+
this.geoCache.set(this.userData.ip, userGeoData);
|
|
1091
|
+
this.sigmaUserData.setGeo(userGeoData);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
async saveToCache() {
|
|
1095
|
+
const { api } = this;
|
|
1096
|
+
const localStorageHash = this.cache.get(sigmaHash);
|
|
1097
|
+
try {
|
|
1098
|
+
const timeRecord = Math.floor(Date.now() / 1e3);
|
|
1099
|
+
this.cache.set(sigmaDataFileLastUpdate, timeRecord);
|
|
1100
|
+
} catch (error) {
|
|
1101
|
+
throw new Error(`save last update to cache: ${error},
|
|
1102
|
+
token: ${this.token}
|
|
1103
|
+
`);
|
|
1104
|
+
}
|
|
1105
|
+
let data;
|
|
1106
|
+
try {
|
|
1107
|
+
data = await this.getDataFile(`${api}/config.json`);
|
|
1108
|
+
} catch (error) {
|
|
1109
|
+
if (!this.cache.get(sigmaDataFile)) {
|
|
1110
|
+
throw new Error(` Get config: ${error}`);
|
|
1111
|
+
} else {
|
|
1112
|
+
console.error(`Get config: ${error}`);
|
|
1113
|
+
return true;
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
let hash;
|
|
1117
|
+
try {
|
|
1118
|
+
if (typeof data !== "object") {
|
|
1119
|
+
throw new Error(`typeof config.json is not an object`);
|
|
1120
|
+
}
|
|
1121
|
+
hash = await SHA256.hex(JSON.stringify(data));
|
|
1122
|
+
if (!localStorageHash || localStorageHash !== hash) {
|
|
1123
|
+
this.cache.set(sigmaHash, hash);
|
|
1124
|
+
this.cache.set(sigmaDataFile, JSON.stringify(data));
|
|
1125
|
+
this.sigmaUserData.clearFlags();
|
|
1126
|
+
}
|
|
1127
|
+
} catch (error) {
|
|
1128
|
+
throw new Error(`Save data to local storage`);
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
hasExpireCache() {
|
|
1132
|
+
const lastUpdate = parseInt(
|
|
1133
|
+
this.cache.get(sigmaDataFileLastUpdate)
|
|
1134
|
+
);
|
|
1135
|
+
const currentTime = Math.floor(Date.now() / 1e3);
|
|
1136
|
+
if (currentTime > lastUpdate + this.cacheTTL) {
|
|
1137
|
+
return true;
|
|
1138
|
+
}
|
|
1139
|
+
return false;
|
|
1140
|
+
}
|
|
1141
|
+
updateCache() {
|
|
1142
|
+
if (!this.cache.get(sigmaDataFile) || this.hasExpireCache()) {
|
|
1143
|
+
return this.saveToCache();
|
|
1144
|
+
}
|
|
1145
|
+
return true;
|
|
1146
|
+
}
|
|
1147
|
+
async getFlags() {
|
|
1148
|
+
await this.updateCache();
|
|
1149
|
+
const flags = this.cache.parse(sigmaDataFile);
|
|
1150
|
+
if (!flags.feature_flags)
|
|
1151
|
+
return;
|
|
1152
|
+
return flags.feature_flags;
|
|
1153
|
+
}
|
|
1154
|
+
async checkFlag(flagName) {
|
|
1155
|
+
if (!flagName) {
|
|
1156
|
+
return null;
|
|
1157
|
+
}
|
|
1158
|
+
await this.updateCache();
|
|
1159
|
+
await this.setUserGeoData();
|
|
1160
|
+
const cacheKey = this.cache.parse(sigmaDataFile);
|
|
1161
|
+
if (!cacheKey.feature_flags)
|
|
1162
|
+
return;
|
|
1163
|
+
let flag = null;
|
|
1164
|
+
const expName = this.getExperimentByFeatureFlag(cacheKey, flagName);
|
|
1165
|
+
if (expName) {
|
|
1166
|
+
const experimentByFlag = await this.getExperiment(expName).then((res) => res.getFeatureValue(flagName));
|
|
1167
|
+
if (experimentByFlag)
|
|
1168
|
+
return experimentByFlag;
|
|
1169
|
+
}
|
|
1170
|
+
for (let i = 0; i < cacheKey.feature_flags.length; i++) {
|
|
1171
|
+
if (cacheKey.feature_flags[i]["name"] === flagName) {
|
|
1172
|
+
flag = cacheKey.feature_flags[i];
|
|
1173
|
+
break;
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
if (!flag)
|
|
1177
|
+
return null;
|
|
1178
|
+
return this.findingSpotCondition(flag, this.sigmaUserData);
|
|
1179
|
+
}
|
|
1180
|
+
getExperimentByFeatureFlag(cache, flagName) {
|
|
1181
|
+
for (let i = 0; i < cache.experiments.length; i++) {
|
|
1182
|
+
if (cache.experiments[i].feature_flags.length) {
|
|
1183
|
+
for (let j in cache.experiments[i].feature_flags) {
|
|
1184
|
+
if (cache.experiments[i].feature_flags[j].name === flagName) {
|
|
1185
|
+
return cache.experiments[i].name;
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
return null;
|
|
1191
|
+
}
|
|
1192
|
+
getFlag(key) {
|
|
1193
|
+
if (!key) {
|
|
1194
|
+
return false;
|
|
1195
|
+
}
|
|
1196
|
+
const userFlags = this.sigmaUserData.user.featureFlags;
|
|
1197
|
+
let flagValue = null;
|
|
1198
|
+
for (let i in userFlags) {
|
|
1199
|
+
if (userFlags[i]["name"] === key) {
|
|
1200
|
+
flagValue = userFlags[i]["rule"].value;
|
|
1201
|
+
break;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
if (!flagValue) {
|
|
1205
|
+
return false;
|
|
1206
|
+
}
|
|
1207
|
+
return flagValue;
|
|
1208
|
+
}
|
|
1209
|
+
conditionOperation(userValue, conditionValues, operation) {
|
|
1210
|
+
!operation ? operation = "=" : operation;
|
|
1211
|
+
if (userValue === null || typeof userValue === "undefined" || !conditionValues)
|
|
1212
|
+
return false;
|
|
1213
|
+
userValue = String(userValue);
|
|
1214
|
+
if (!Array.isArray(conditionValues))
|
|
1215
|
+
conditionValues = String(conditionValues);
|
|
1216
|
+
switch (operation.trim()) {
|
|
1217
|
+
case "equal":
|
|
1218
|
+
return userValue.toLowerCase().trim() == conditionValues.toLowerCase().trim();
|
|
1219
|
+
case "not equal":
|
|
1220
|
+
return userValue.toLowerCase().trim() != conditionValues.toLowerCase().trim();
|
|
1221
|
+
case "greater":
|
|
1222
|
+
return compareVersions(userValue.trim(), conditionValues.trim());
|
|
1223
|
+
case "less":
|
|
1224
|
+
return compareVersions(conditionValues.trim(), userValue.trim());
|
|
1225
|
+
case "greater equal":
|
|
1226
|
+
return compareVersions(userValue.trim(), conditionValues.trim(), false);
|
|
1227
|
+
case "less equal":
|
|
1228
|
+
return compareVersions(conditionValues.trim(), userValue.trim(), false);
|
|
1229
|
+
case "any of":
|
|
1230
|
+
return conditionValues.includes(userValue);
|
|
1231
|
+
case "none of":
|
|
1232
|
+
return !conditionValues.includes(userValue);
|
|
1233
|
+
case "contains any of":
|
|
1234
|
+
for (let i = 0; i < conditionValues.length; i++) {
|
|
1235
|
+
if (userValue.includes(conditionValues[i])) {
|
|
1236
|
+
return true;
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
return false;
|
|
1240
|
+
case "contains none of":
|
|
1241
|
+
for (let i = 0; i < conditionValues.length; i++) {
|
|
1242
|
+
if (userValue.includes(conditionValues[i])) {
|
|
1243
|
+
return false;
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
return true;
|
|
1247
|
+
case "on date":
|
|
1248
|
+
return Math.floor(
|
|
1249
|
+
new Date(conditionValues.trim()).getTime() / (1e3 * 60 * 60 * 24)
|
|
1250
|
+
) == this.sigmaUserData.user.date;
|
|
1251
|
+
case "after time":
|
|
1252
|
+
return new Date(conditionValues.trim()).getTime() / (1e3 * 60 * 60) < this.sigmaUserData.user.time;
|
|
1253
|
+
case "before time":
|
|
1254
|
+
return new Date(conditionValues.trim()).getTime() / (1e3 * 60 * 60) > this.sigmaUserData.user.time;
|
|
1255
|
+
default:
|
|
1256
|
+
return false;
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
getUserParamValue(paramKey, privateFlag = null, isConditionSignForHash = false) {
|
|
1260
|
+
if (!paramKey)
|
|
1261
|
+
return false;
|
|
1262
|
+
const user = this.sigmaUserData.user;
|
|
1263
|
+
let defaultValue = null;
|
|
1264
|
+
if (paramKey.includes(".")) {
|
|
1265
|
+
const paramsArray = paramKey.split(".");
|
|
1266
|
+
const parent = paramsArray[0];
|
|
1267
|
+
const child = paramsArray[1];
|
|
1268
|
+
if (!child)
|
|
1269
|
+
return false;
|
|
1270
|
+
const isSetParentInUserData = Object.keys(user).find((i) => i === parent);
|
|
1271
|
+
if (!user[isSetParentInUserData]) {
|
|
1272
|
+
return false;
|
|
1273
|
+
}
|
|
1274
|
+
const userObject = Object.entries(user[isSetParentInUserData]);
|
|
1275
|
+
for (let [userParamKey, userParamValue] of userObject) {
|
|
1276
|
+
if (userParamKey == child) {
|
|
1277
|
+
defaultValue = userParamValue;
|
|
1278
|
+
break;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
} else {
|
|
1282
|
+
for (let [key, value] of Object.entries(user)) {
|
|
1283
|
+
if (key == paramKey) {
|
|
1284
|
+
defaultValue = value;
|
|
1285
|
+
break;
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
if (defaultValue != null)
|
|
1290
|
+
defaultValue = String(defaultValue);
|
|
1291
|
+
if (privateFlag && defaultValue && isConditionSignForHash) {
|
|
1292
|
+
return MD5.hex(defaultValue);
|
|
1293
|
+
}
|
|
1294
|
+
return defaultValue;
|
|
1295
|
+
}
|
|
1296
|
+
calcUserInGroup(salt, exposureRate, controlBucketPerc, forcedExp = false, layer = null, layerBounds = [], splitBy) {
|
|
1297
|
+
if (!splitBy)
|
|
1298
|
+
return false;
|
|
1299
|
+
const md5R = MD5.hex(String(splitBy) + salt);
|
|
1300
|
+
const R = digestHash(md5R) * zeta / max_decimal_64;
|
|
1301
|
+
let md5L = null;
|
|
1302
|
+
if (!layer && !layerBounds.length || forcedExp) {
|
|
1303
|
+
return getUserGroup(R, exposureRate, controlBucketPerc, forcedExp);
|
|
1304
|
+
} else {
|
|
1305
|
+
md5L = MD5.hex(String(splitBy) + layer);
|
|
1306
|
+
const L = digestHash(md5L) * zeta / max_decimal_64;
|
|
1307
|
+
for (let i in layerBounds) {
|
|
1308
|
+
const result = Math.abs(L / 10);
|
|
1309
|
+
if (result <= layerBounds[i].lower_bound || layerBounds[i].upper_bound <= result) {
|
|
1310
|
+
continue;
|
|
1311
|
+
} else {
|
|
1312
|
+
return getUserGroup(R, exposureRate, controlBucketPerc, forcedExp);
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
return false;
|
|
1317
|
+
}
|
|
1318
|
+
getSplitById(experiment) {
|
|
1319
|
+
if (!experiment)
|
|
1320
|
+
return;
|
|
1321
|
+
let id = null;
|
|
1322
|
+
if (!experiment.split_by) {
|
|
1323
|
+
experiment.split_by = "userId";
|
|
1324
|
+
}
|
|
1325
|
+
switch (experiment.split_by) {
|
|
1326
|
+
case "userId":
|
|
1327
|
+
id = this.cache.get(sigmaUserId) || null;
|
|
1328
|
+
if (this.cache.get(sigmaExpiration) && parseInt(new Date().getTime()) >= parseInt(this.cache.get(sigmaExpiration))) {
|
|
1329
|
+
id = null;
|
|
1330
|
+
}
|
|
1331
|
+
break;
|
|
1332
|
+
case "profileId":
|
|
1333
|
+
id = this.cache.get(sigmaProfileId) || null;
|
|
1334
|
+
break;
|
|
1335
|
+
case "deviceId":
|
|
1336
|
+
id = this.cache.get(sigmaDeviceId) || null;
|
|
1337
|
+
break;
|
|
1338
|
+
}
|
|
1339
|
+
return id;
|
|
1340
|
+
}
|
|
1341
|
+
checkTargetConditions(experiment) {
|
|
1342
|
+
if (experiment.targets && experiment.targets.conditions && experiment.targets.conditions.length > 0) {
|
|
1343
|
+
const targets = experiment.targets;
|
|
1344
|
+
let results = [];
|
|
1345
|
+
for (let index in targets.conditions) {
|
|
1346
|
+
const userValue = this.getUserParamValue(
|
|
1347
|
+
targets.conditions[index].name,
|
|
1348
|
+
experiment.is_private,
|
|
1349
|
+
this.checkConditionSignForHash(targets.conditions[index].condition_sign)
|
|
1350
|
+
);
|
|
1351
|
+
results.push(
|
|
1352
|
+
this.conditionOperation(
|
|
1353
|
+
userValue,
|
|
1354
|
+
targets.conditions[index].value,
|
|
1355
|
+
targets.conditions[index].condition_sign
|
|
1356
|
+
)
|
|
1357
|
+
);
|
|
1358
|
+
}
|
|
1359
|
+
return this.checkConditionsStatement(targets.conditional_statement, results);
|
|
1360
|
+
}
|
|
1361
|
+
return false;
|
|
1362
|
+
}
|
|
1363
|
+
checkConditionSignForHash(condition) {
|
|
1364
|
+
return ["equal", "not equal", "any of", "none of"].includes(condition);
|
|
1365
|
+
}
|
|
1366
|
+
experimentDefinition(experiment, forcedUserInGroup) {
|
|
1367
|
+
if (forcedUserInGroup) {
|
|
1368
|
+
return experiment;
|
|
1369
|
+
} else if (experiment.targets && experiment.targets.conditions.length > 0 && this.checkTargetConditions(experiment)) {
|
|
1370
|
+
return experiment;
|
|
1371
|
+
} else if (!experiment.targets || experiment.targets && experiment.targets.conditions.length === 0) {
|
|
1372
|
+
return experiment;
|
|
1373
|
+
}
|
|
1374
|
+
return null;
|
|
1375
|
+
}
|
|
1376
|
+
async getExperiment(experimentName) {
|
|
1377
|
+
if (!experimentName) {
|
|
1378
|
+
return null;
|
|
1379
|
+
}
|
|
1380
|
+
await this.updateCache();
|
|
1381
|
+
await this.setUserGeoData();
|
|
1382
|
+
const sigmaDataLs = await this.cache.parse(sigmaDataFile);
|
|
1383
|
+
if (!sigmaDataLs.experiments) {
|
|
1384
|
+
throw new Error("Experiments not found in cache");
|
|
1385
|
+
}
|
|
1386
|
+
let experiment = null;
|
|
1387
|
+
let layer = null;
|
|
1388
|
+
let bounds = [];
|
|
1389
|
+
let userInGroupExperiment = null;
|
|
1390
|
+
let forcedUser = false;
|
|
1391
|
+
let splitById = null;
|
|
1392
|
+
for (let i = 0; i < sigmaDataLs.experiments.length; i++) {
|
|
1393
|
+
if (sigmaDataLs.experiments[i]["name"] === experimentName && checkBoolValue(sigmaDataLs.experiments[i]["layer_id"])) {
|
|
1394
|
+
layer = sigmaDataLs.experiments[i]["layer_id"];
|
|
1395
|
+
bounds = sigmaDataLs.experiments[i]["layer_bounds"];
|
|
1396
|
+
}
|
|
1397
|
+
if (sigmaDataLs.experiments[i]["name"] === experimentName && !experiment) {
|
|
1398
|
+
splitById = this.getSplitById(sigmaDataLs.experiments[i]);
|
|
1399
|
+
forcedUser = checkForcedList(sigmaDataLs.experiments[i].forced_user_list, this.sigmaUserData.user.userId);
|
|
1400
|
+
userInGroupExperiment = this.findUserInForcedGroup(sigmaDataLs.experiments[i]);
|
|
1401
|
+
experiment = this.experimentDefinition(sigmaDataLs.experiments[i], userInGroupExperiment);
|
|
1402
|
+
break;
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
const localStorageGroupName = `sigma_group_${experimentName}`;
|
|
1406
|
+
if (experiment) {
|
|
1407
|
+
if (!userInGroupExperiment) {
|
|
1408
|
+
userInGroupExperiment = this.calcUserInGroup(
|
|
1409
|
+
experiment.salt,
|
|
1410
|
+
experiment.allocation,
|
|
1411
|
+
experiment.groups,
|
|
1412
|
+
forcedUser,
|
|
1413
|
+
layer,
|
|
1414
|
+
bounds,
|
|
1415
|
+
splitById
|
|
1416
|
+
);
|
|
1417
|
+
}
|
|
1418
|
+
this.cache.set(localStorageGroupName, userInGroupExperiment);
|
|
1419
|
+
}
|
|
1420
|
+
const getParamValue = (paramName) => {
|
|
1421
|
+
if (!paramName || !experiment) {
|
|
1422
|
+
return null;
|
|
1423
|
+
}
|
|
1424
|
+
const groupName = this.cache.get(localStorageGroupName);
|
|
1425
|
+
let params = null;
|
|
1426
|
+
for (let i = 0; i < experiment.params.length; i++) {
|
|
1427
|
+
if (experiment.params[i]["name"] === paramName) {
|
|
1428
|
+
params = experiment.params[i];
|
|
1429
|
+
break;
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
if (!params) {
|
|
1433
|
+
return null;
|
|
1434
|
+
}
|
|
1435
|
+
let paramValue = null;
|
|
1436
|
+
for (let item in params.values) {
|
|
1437
|
+
if (params.values[item].group === groupName) {
|
|
1438
|
+
paramValue = doTypeConversion(params.type, params.values[item].value);
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
return paramValue;
|
|
1442
|
+
};
|
|
1443
|
+
const getFeatureValue = (flagName) => {
|
|
1444
|
+
if (!flagName || !experiment) {
|
|
1445
|
+
return null;
|
|
1446
|
+
}
|
|
1447
|
+
const groupName = this.cache.get(localStorageGroupName);
|
|
1448
|
+
let flagExperiment = null;
|
|
1449
|
+
for (let i = 0; i < experiment.feature_flags.length; i++) {
|
|
1450
|
+
if (experiment.feature_flags[i]["name"] === flagName) {
|
|
1451
|
+
flagExperiment = experiment.feature_flags[i];
|
|
1452
|
+
break;
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
if (!flagExperiment)
|
|
1456
|
+
return null;
|
|
1457
|
+
let flag = null;
|
|
1458
|
+
for (let i = 0; i < flagExperiment.groups.length; i++) {
|
|
1459
|
+
if (flagExperiment.groups[i]["group"] === groupName) {
|
|
1460
|
+
flag = flagExperiment.groups[i];
|
|
1461
|
+
break;
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
if (!flag)
|
|
1465
|
+
return null;
|
|
1466
|
+
let flagExperimentFeatureValue = this.findingSpotCondition(flag, false, experiment);
|
|
1467
|
+
return doTypeConversion(flagExperiment.type, flagExperimentFeatureValue);
|
|
1468
|
+
};
|
|
1469
|
+
return {
|
|
1470
|
+
getParamValue,
|
|
1471
|
+
getFeatureValue
|
|
1472
|
+
};
|
|
1473
|
+
}
|
|
1474
|
+
async getAllUserExperiments() {
|
|
1475
|
+
await this.updateCache();
|
|
1476
|
+
const sigmaDataLs = this.cache.parse(sigmaDataFile);
|
|
1477
|
+
if (!sigmaDataLs.experiments.length)
|
|
1478
|
+
return null;
|
|
1479
|
+
let result = "";
|
|
1480
|
+
for (let i in sigmaDataLs.experiments) {
|
|
1481
|
+
let layer = null;
|
|
1482
|
+
let bounds = [];
|
|
1483
|
+
let splitById = this.getSplitById(sigmaDataLs.experiments[i]);
|
|
1484
|
+
let userInGroupExperiment = this.findUserInForcedGroup(sigmaDataLs.experiments[i]);
|
|
1485
|
+
let experiment = this.experimentDefinition(sigmaDataLs.experiments[i], userInGroupExperiment);
|
|
1486
|
+
if (experiment) {
|
|
1487
|
+
if (checkBoolValue(experiment["layer_id"]) && !userInGroupExperiment) {
|
|
1488
|
+
layer = experiment["layer_id"];
|
|
1489
|
+
bounds = experiment["layer_bounds"];
|
|
1490
|
+
}
|
|
1491
|
+
if (!userInGroupExperiment) {
|
|
1492
|
+
userInGroupExperiment = this.calcUserInGroup(
|
|
1493
|
+
experiment.salt,
|
|
1494
|
+
experiment.allocation,
|
|
1495
|
+
experiment.groups,
|
|
1496
|
+
checkForcedList(experiment.forced_user_list, splitById),
|
|
1497
|
+
layer,
|
|
1498
|
+
bounds,
|
|
1499
|
+
splitById
|
|
1500
|
+
);
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
if (userInGroupExperiment) {
|
|
1504
|
+
const groupIndex = experiment.groups.findIndex((i2) => i2.name == userInGroupExperiment);
|
|
1505
|
+
result = result.concat(experiment.name).concat(".").concat(groupIndex).concat("|");
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
if (result.length > 0) {
|
|
1509
|
+
this.cache.set(sigmaExperiments, result.slice(0, -1));
|
|
1510
|
+
return result.slice(0, -1);
|
|
1511
|
+
} else {
|
|
1512
|
+
this.cache.remove(sigmaExperiments);
|
|
1513
|
+
}
|
|
1514
|
+
return null;
|
|
1515
|
+
}
|
|
1516
|
+
findUserInForcedGroup(experiment) {
|
|
1517
|
+
let groupName = false;
|
|
1518
|
+
for (const groupItem in experiment.groups) {
|
|
1519
|
+
const forcedList = experiment.groups[groupItem].forced_user_list;
|
|
1520
|
+
if (forcedList && forcedList.length) {
|
|
1521
|
+
for (const item in forcedList) {
|
|
1522
|
+
if (forcedList[item] === this.getSplitById(experiment)) {
|
|
1523
|
+
return groupName = experiment.groups[groupItem].name;
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
return groupName;
|
|
1529
|
+
}
|
|
1530
|
+
findingSpotCondition(flag, saveToUser = false, exp = null) {
|
|
1531
|
+
let flagRules = flag.rules;
|
|
1532
|
+
let flagDefaultResult = null;
|
|
1533
|
+
for (let defaultRule in flagRules) {
|
|
1534
|
+
if (flagRules[defaultRule].is_default) {
|
|
1535
|
+
flagDefaultResult = {
|
|
1536
|
+
id: flagRules[defaultRule].id,
|
|
1537
|
+
value: flagRules[defaultRule].value,
|
|
1538
|
+
type: flag.type
|
|
1539
|
+
};
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
if (!flagDefaultResult) {
|
|
1543
|
+
throw new Error("bad config.json");
|
|
1544
|
+
}
|
|
1545
|
+
for (let flagIndex in flagRules) {
|
|
1546
|
+
const statement = flagRules[flagIndex].conditional_statement;
|
|
1547
|
+
if (!statement && flagRules.length === 1) {
|
|
1548
|
+
this.sigmaUserData.addFlag(flag.name, flagDefaultResult);
|
|
1549
|
+
return true;
|
|
1550
|
+
}
|
|
1551
|
+
for (let rule in flagRules) {
|
|
1552
|
+
const conditions = flagRules[rule].conditions;
|
|
1553
|
+
let results = [];
|
|
1554
|
+
for (let i in conditions) {
|
|
1555
|
+
let userValue = this.getUserParamValue(
|
|
1556
|
+
conditions[i].name,
|
|
1557
|
+
exp ? exp.is_private : flag.is_private,
|
|
1558
|
+
this.checkConditionSignForHash(conditions[i].condition_sign)
|
|
1559
|
+
);
|
|
1560
|
+
results.push(
|
|
1561
|
+
this.conditionOperation(
|
|
1562
|
+
userValue,
|
|
1563
|
+
conditions[i].value,
|
|
1564
|
+
conditions[i].condition_sign
|
|
1565
|
+
)
|
|
1566
|
+
);
|
|
1567
|
+
}
|
|
1568
|
+
let isSuccessRule = this.checkConditionsStatement(flagRules[rule].conditional_statement, results);
|
|
1569
|
+
let ruleValue = doTypeConversion(flag.type, flagRules[rule].value);
|
|
1570
|
+
if (isSuccessRule) {
|
|
1571
|
+
if (saveToUser) {
|
|
1572
|
+
saveToUser.addFlag(flag.name, {
|
|
1573
|
+
id: flagRules[rule].id,
|
|
1574
|
+
value: ruleValue,
|
|
1575
|
+
type: flag.type
|
|
1576
|
+
});
|
|
1577
|
+
}
|
|
1578
|
+
return ruleValue;
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
let defaultValue = doTypeConversion(flagDefaultResult.type, flagDefaultResult.value);
|
|
1582
|
+
if (saveToUser) {
|
|
1583
|
+
flagDefaultResult.value = defaultValue;
|
|
1584
|
+
saveToUser.addFlag(flag.name, flagDefaultResult);
|
|
1585
|
+
}
|
|
1586
|
+
return defaultValue;
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
async getCacheDataFile() {
|
|
1590
|
+
await this.updateCache();
|
|
1591
|
+
return this.cache.parse(sigmaDataFile);
|
|
1592
|
+
}
|
|
1593
|
+
async getCacheHash() {
|
|
1594
|
+
const data = await this.cache.get(sigmaHash);
|
|
1595
|
+
return data;
|
|
1596
|
+
}
|
|
1597
|
+
async getCacheUserId() {
|
|
1598
|
+
const data = await this.cache.get(sigmaUserId);
|
|
1599
|
+
return data;
|
|
1600
|
+
}
|
|
1601
|
+
checkConditionsStatement(ruleStatement, items) {
|
|
1602
|
+
let isSuccessRule = false;
|
|
1603
|
+
if (ruleStatement == "OR") {
|
|
1604
|
+
const findingItem = items.find((item) => item === true);
|
|
1605
|
+
findingItem === true ? isSuccessRule = true : isSuccessRule;
|
|
1606
|
+
}
|
|
1607
|
+
if (ruleStatement == "AND") {
|
|
1608
|
+
const findingItem = items.find((item) => item === false);
|
|
1609
|
+
findingItem === false ? isSuccessRule : isSuccessRule = true;
|
|
1610
|
+
}
|
|
1611
|
+
return isSuccessRule;
|
|
1612
|
+
}
|
|
1613
|
+
};
|
|
1614
|
+
var sigma_default = Sigma;
|
|
1615
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1616
|
+
0 && (module.exports = {});
|