@mack1ch/fingerprint-js 0.1.1 → 0.1.2
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/README.md +228 -73
- package/dist/index.cjs +848 -13
- package/dist/index.d.cts +65 -1
- package/dist/index.d.ts +65 -1
- package/dist/index.js +865 -15
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
5
10
|
var __export = (target, all) => {
|
|
6
11
|
for (var name in all)
|
|
7
12
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -14,16 +19,567 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
19
|
}
|
|
15
20
|
return to;
|
|
16
21
|
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
+
mod
|
|
29
|
+
));
|
|
17
30
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
31
|
|
|
32
|
+
// node_modules/js-md5/src/md5.js
|
|
33
|
+
var require_md5 = __commonJS({
|
|
34
|
+
"node_modules/js-md5/src/md5.js"(exports2, module2) {
|
|
35
|
+
(function() {
|
|
36
|
+
"use strict";
|
|
37
|
+
var INPUT_ERROR = "input is invalid type";
|
|
38
|
+
var FINALIZE_ERROR = "finalize already called";
|
|
39
|
+
var WINDOW = typeof window === "object";
|
|
40
|
+
var root = WINDOW ? window : {};
|
|
41
|
+
if (root.JS_MD5_NO_WINDOW) {
|
|
42
|
+
WINDOW = false;
|
|
43
|
+
}
|
|
44
|
+
var WEB_WORKER = !WINDOW && typeof self === "object";
|
|
45
|
+
var NODE_JS = !root.JS_MD5_NO_NODE_JS && typeof process === "object" && process.versions && process.versions.node;
|
|
46
|
+
if (NODE_JS) {
|
|
47
|
+
root = global;
|
|
48
|
+
} else if (WEB_WORKER) {
|
|
49
|
+
root = self;
|
|
50
|
+
}
|
|
51
|
+
var COMMON_JS = !root.JS_MD5_NO_COMMON_JS && typeof module2 === "object" && module2.exports;
|
|
52
|
+
var AMD = typeof define === "function" && define.amd;
|
|
53
|
+
var ARRAY_BUFFER = !root.JS_MD5_NO_ARRAY_BUFFER && typeof ArrayBuffer !== "undefined";
|
|
54
|
+
var HEX_CHARS = "0123456789abcdef".split("");
|
|
55
|
+
var EXTRA = [128, 32768, 8388608, -2147483648];
|
|
56
|
+
var SHIFT = [0, 8, 16, 24];
|
|
57
|
+
var OUTPUT_TYPES = ["hex", "array", "digest", "buffer", "arrayBuffer", "base64"];
|
|
58
|
+
var BASE64_ENCODE_CHAR = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
|
|
59
|
+
var blocks = [], buffer8;
|
|
60
|
+
if (ARRAY_BUFFER) {
|
|
61
|
+
var buffer = new ArrayBuffer(68);
|
|
62
|
+
buffer8 = new Uint8Array(buffer);
|
|
63
|
+
blocks = new Uint32Array(buffer);
|
|
64
|
+
}
|
|
65
|
+
var isArray = Array.isArray;
|
|
66
|
+
if (root.JS_MD5_NO_NODE_JS || !isArray) {
|
|
67
|
+
isArray = function(obj) {
|
|
68
|
+
return Object.prototype.toString.call(obj) === "[object Array]";
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
var isView = ArrayBuffer.isView;
|
|
72
|
+
if (ARRAY_BUFFER && (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !isView)) {
|
|
73
|
+
isView = function(obj) {
|
|
74
|
+
return typeof obj === "object" && obj.buffer && obj.buffer.constructor === ArrayBuffer;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
var formatMessage = function(message) {
|
|
78
|
+
var type = typeof message;
|
|
79
|
+
if (type === "string") {
|
|
80
|
+
return [message, true];
|
|
81
|
+
}
|
|
82
|
+
if (type !== "object" || message === null) {
|
|
83
|
+
throw new Error(INPUT_ERROR);
|
|
84
|
+
}
|
|
85
|
+
if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
|
|
86
|
+
return [new Uint8Array(message), false];
|
|
87
|
+
}
|
|
88
|
+
if (!isArray(message) && !isView(message)) {
|
|
89
|
+
throw new Error(INPUT_ERROR);
|
|
90
|
+
}
|
|
91
|
+
return [message, false];
|
|
92
|
+
};
|
|
93
|
+
var createOutputMethod = function(outputType) {
|
|
94
|
+
return function(message) {
|
|
95
|
+
return new Md5(true).update(message)[outputType]();
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
var createMethod = function() {
|
|
99
|
+
var method = createOutputMethod("hex");
|
|
100
|
+
if (NODE_JS) {
|
|
101
|
+
method = nodeWrap(method);
|
|
102
|
+
}
|
|
103
|
+
method.create = function() {
|
|
104
|
+
return new Md5();
|
|
105
|
+
};
|
|
106
|
+
method.update = function(message) {
|
|
107
|
+
return method.create().update(message);
|
|
108
|
+
};
|
|
109
|
+
for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
|
|
110
|
+
var type = OUTPUT_TYPES[i];
|
|
111
|
+
method[type] = createOutputMethod(type);
|
|
112
|
+
}
|
|
113
|
+
return method;
|
|
114
|
+
};
|
|
115
|
+
var nodeWrap = function(method) {
|
|
116
|
+
var crypto2 = require("crypto");
|
|
117
|
+
var Buffer2 = require("buffer").Buffer;
|
|
118
|
+
var bufferFrom;
|
|
119
|
+
if (Buffer2.from && !root.JS_MD5_NO_BUFFER_FROM) {
|
|
120
|
+
bufferFrom = Buffer2.from;
|
|
121
|
+
} else {
|
|
122
|
+
bufferFrom = function(message) {
|
|
123
|
+
return new Buffer2(message);
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
var nodeMethod = function(message) {
|
|
127
|
+
if (typeof message === "string") {
|
|
128
|
+
return crypto2.createHash("md5").update(message, "utf8").digest("hex");
|
|
129
|
+
} else {
|
|
130
|
+
if (message === null || message === void 0) {
|
|
131
|
+
throw new Error(INPUT_ERROR);
|
|
132
|
+
} else if (message.constructor === ArrayBuffer) {
|
|
133
|
+
message = new Uint8Array(message);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (isArray(message) || isView(message) || message.constructor === Buffer2) {
|
|
137
|
+
return crypto2.createHash("md5").update(bufferFrom(message)).digest("hex");
|
|
138
|
+
} else {
|
|
139
|
+
return method(message);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
return nodeMethod;
|
|
143
|
+
};
|
|
144
|
+
var createHmacOutputMethod = function(outputType) {
|
|
145
|
+
return function(key, message) {
|
|
146
|
+
return new HmacMd5(key, true).update(message)[outputType]();
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
var createHmacMethod = function() {
|
|
150
|
+
var method = createHmacOutputMethod("hex");
|
|
151
|
+
method.create = function(key) {
|
|
152
|
+
return new HmacMd5(key);
|
|
153
|
+
};
|
|
154
|
+
method.update = function(key, message) {
|
|
155
|
+
return method.create(key).update(message);
|
|
156
|
+
};
|
|
157
|
+
for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
|
|
158
|
+
var type = OUTPUT_TYPES[i];
|
|
159
|
+
method[type] = createHmacOutputMethod(type);
|
|
160
|
+
}
|
|
161
|
+
return method;
|
|
162
|
+
};
|
|
163
|
+
function Md5(sharedMemory) {
|
|
164
|
+
if (sharedMemory) {
|
|
165
|
+
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;
|
|
166
|
+
this.blocks = blocks;
|
|
167
|
+
this.buffer8 = buffer8;
|
|
168
|
+
} else {
|
|
169
|
+
if (ARRAY_BUFFER) {
|
|
170
|
+
var buffer2 = new ArrayBuffer(68);
|
|
171
|
+
this.buffer8 = new Uint8Array(buffer2);
|
|
172
|
+
this.blocks = new Uint32Array(buffer2);
|
|
173
|
+
} else {
|
|
174
|
+
this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
this.h0 = this.h1 = this.h2 = this.h3 = this.start = this.bytes = this.hBytes = 0;
|
|
178
|
+
this.finalized = this.hashed = false;
|
|
179
|
+
this.first = true;
|
|
180
|
+
}
|
|
181
|
+
Md5.prototype.update = function(message) {
|
|
182
|
+
if (this.finalized) {
|
|
183
|
+
throw new Error(FINALIZE_ERROR);
|
|
184
|
+
}
|
|
185
|
+
var result = formatMessage(message);
|
|
186
|
+
message = result[0];
|
|
187
|
+
var isString = result[1];
|
|
188
|
+
var code, index = 0, i, length = message.length, blocks2 = this.blocks;
|
|
189
|
+
var buffer82 = this.buffer8;
|
|
190
|
+
while (index < length) {
|
|
191
|
+
if (this.hashed) {
|
|
192
|
+
this.hashed = false;
|
|
193
|
+
blocks2[0] = blocks2[16];
|
|
194
|
+
blocks2[16] = blocks2[1] = blocks2[2] = blocks2[3] = blocks2[4] = blocks2[5] = blocks2[6] = blocks2[7] = blocks2[8] = blocks2[9] = blocks2[10] = blocks2[11] = blocks2[12] = blocks2[13] = blocks2[14] = blocks2[15] = 0;
|
|
195
|
+
}
|
|
196
|
+
if (isString) {
|
|
197
|
+
if (ARRAY_BUFFER) {
|
|
198
|
+
for (i = this.start; index < length && i < 64; ++index) {
|
|
199
|
+
code = message.charCodeAt(index);
|
|
200
|
+
if (code < 128) {
|
|
201
|
+
buffer82[i++] = code;
|
|
202
|
+
} else if (code < 2048) {
|
|
203
|
+
buffer82[i++] = 192 | code >>> 6;
|
|
204
|
+
buffer82[i++] = 128 | code & 63;
|
|
205
|
+
} else if (code < 55296 || code >= 57344) {
|
|
206
|
+
buffer82[i++] = 224 | code >>> 12;
|
|
207
|
+
buffer82[i++] = 128 | code >>> 6 & 63;
|
|
208
|
+
buffer82[i++] = 128 | code & 63;
|
|
209
|
+
} else {
|
|
210
|
+
code = 65536 + ((code & 1023) << 10 | message.charCodeAt(++index) & 1023);
|
|
211
|
+
buffer82[i++] = 240 | code >>> 18;
|
|
212
|
+
buffer82[i++] = 128 | code >>> 12 & 63;
|
|
213
|
+
buffer82[i++] = 128 | code >>> 6 & 63;
|
|
214
|
+
buffer82[i++] = 128 | code & 63;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
} else {
|
|
218
|
+
for (i = this.start; index < length && i < 64; ++index) {
|
|
219
|
+
code = message.charCodeAt(index);
|
|
220
|
+
if (code < 128) {
|
|
221
|
+
blocks2[i >>> 2] |= code << SHIFT[i++ & 3];
|
|
222
|
+
} else if (code < 2048) {
|
|
223
|
+
blocks2[i >>> 2] |= (192 | code >>> 6) << SHIFT[i++ & 3];
|
|
224
|
+
blocks2[i >>> 2] |= (128 | code & 63) << SHIFT[i++ & 3];
|
|
225
|
+
} else if (code < 55296 || code >= 57344) {
|
|
226
|
+
blocks2[i >>> 2] |= (224 | code >>> 12) << SHIFT[i++ & 3];
|
|
227
|
+
blocks2[i >>> 2] |= (128 | code >>> 6 & 63) << SHIFT[i++ & 3];
|
|
228
|
+
blocks2[i >>> 2] |= (128 | code & 63) << SHIFT[i++ & 3];
|
|
229
|
+
} else {
|
|
230
|
+
code = 65536 + ((code & 1023) << 10 | message.charCodeAt(++index) & 1023);
|
|
231
|
+
blocks2[i >>> 2] |= (240 | code >>> 18) << SHIFT[i++ & 3];
|
|
232
|
+
blocks2[i >>> 2] |= (128 | code >>> 12 & 63) << SHIFT[i++ & 3];
|
|
233
|
+
blocks2[i >>> 2] |= (128 | code >>> 6 & 63) << SHIFT[i++ & 3];
|
|
234
|
+
blocks2[i >>> 2] |= (128 | code & 63) << SHIFT[i++ & 3];
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
} else {
|
|
239
|
+
if (ARRAY_BUFFER) {
|
|
240
|
+
for (i = this.start; index < length && i < 64; ++index) {
|
|
241
|
+
buffer82[i++] = message[index];
|
|
242
|
+
}
|
|
243
|
+
} else {
|
|
244
|
+
for (i = this.start; index < length && i < 64; ++index) {
|
|
245
|
+
blocks2[i >>> 2] |= message[index] << SHIFT[i++ & 3];
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
this.lastByteIndex = i;
|
|
250
|
+
this.bytes += i - this.start;
|
|
251
|
+
if (i >= 64) {
|
|
252
|
+
this.start = i - 64;
|
|
253
|
+
this.hash();
|
|
254
|
+
this.hashed = true;
|
|
255
|
+
} else {
|
|
256
|
+
this.start = i;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (this.bytes > 4294967295) {
|
|
260
|
+
this.hBytes += this.bytes / 4294967296 << 0;
|
|
261
|
+
this.bytes = this.bytes % 4294967296;
|
|
262
|
+
}
|
|
263
|
+
return this;
|
|
264
|
+
};
|
|
265
|
+
Md5.prototype.finalize = function() {
|
|
266
|
+
if (this.finalized) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
this.finalized = true;
|
|
270
|
+
var blocks2 = this.blocks, i = this.lastByteIndex;
|
|
271
|
+
blocks2[i >>> 2] |= EXTRA[i & 3];
|
|
272
|
+
if (i >= 56) {
|
|
273
|
+
if (!this.hashed) {
|
|
274
|
+
this.hash();
|
|
275
|
+
}
|
|
276
|
+
blocks2[0] = blocks2[16];
|
|
277
|
+
blocks2[16] = blocks2[1] = blocks2[2] = blocks2[3] = blocks2[4] = blocks2[5] = blocks2[6] = blocks2[7] = blocks2[8] = blocks2[9] = blocks2[10] = blocks2[11] = blocks2[12] = blocks2[13] = blocks2[14] = blocks2[15] = 0;
|
|
278
|
+
}
|
|
279
|
+
blocks2[14] = this.bytes << 3;
|
|
280
|
+
blocks2[15] = this.hBytes << 3 | this.bytes >>> 29;
|
|
281
|
+
this.hash();
|
|
282
|
+
};
|
|
283
|
+
Md5.prototype.hash = function() {
|
|
284
|
+
var a, b, c, d, bc, da, blocks2 = this.blocks;
|
|
285
|
+
if (this.first) {
|
|
286
|
+
a = blocks2[0] - 680876937;
|
|
287
|
+
a = (a << 7 | a >>> 25) - 271733879 << 0;
|
|
288
|
+
d = (-1732584194 ^ a & 2004318071) + blocks2[1] - 117830708;
|
|
289
|
+
d = (d << 12 | d >>> 20) + a << 0;
|
|
290
|
+
c = (-271733879 ^ d & (a ^ -271733879)) + blocks2[2] - 1126478375;
|
|
291
|
+
c = (c << 17 | c >>> 15) + d << 0;
|
|
292
|
+
b = (a ^ c & (d ^ a)) + blocks2[3] - 1316259209;
|
|
293
|
+
b = (b << 22 | b >>> 10) + c << 0;
|
|
294
|
+
} else {
|
|
295
|
+
a = this.h0;
|
|
296
|
+
b = this.h1;
|
|
297
|
+
c = this.h2;
|
|
298
|
+
d = this.h3;
|
|
299
|
+
a += (d ^ b & (c ^ d)) + blocks2[0] - 680876936;
|
|
300
|
+
a = (a << 7 | a >>> 25) + b << 0;
|
|
301
|
+
d += (c ^ a & (b ^ c)) + blocks2[1] - 389564586;
|
|
302
|
+
d = (d << 12 | d >>> 20) + a << 0;
|
|
303
|
+
c += (b ^ d & (a ^ b)) + blocks2[2] + 606105819;
|
|
304
|
+
c = (c << 17 | c >>> 15) + d << 0;
|
|
305
|
+
b += (a ^ c & (d ^ a)) + blocks2[3] - 1044525330;
|
|
306
|
+
b = (b << 22 | b >>> 10) + c << 0;
|
|
307
|
+
}
|
|
308
|
+
a += (d ^ b & (c ^ d)) + blocks2[4] - 176418897;
|
|
309
|
+
a = (a << 7 | a >>> 25) + b << 0;
|
|
310
|
+
d += (c ^ a & (b ^ c)) + blocks2[5] + 1200080426;
|
|
311
|
+
d = (d << 12 | d >>> 20) + a << 0;
|
|
312
|
+
c += (b ^ d & (a ^ b)) + blocks2[6] - 1473231341;
|
|
313
|
+
c = (c << 17 | c >>> 15) + d << 0;
|
|
314
|
+
b += (a ^ c & (d ^ a)) + blocks2[7] - 45705983;
|
|
315
|
+
b = (b << 22 | b >>> 10) + c << 0;
|
|
316
|
+
a += (d ^ b & (c ^ d)) + blocks2[8] + 1770035416;
|
|
317
|
+
a = (a << 7 | a >>> 25) + b << 0;
|
|
318
|
+
d += (c ^ a & (b ^ c)) + blocks2[9] - 1958414417;
|
|
319
|
+
d = (d << 12 | d >>> 20) + a << 0;
|
|
320
|
+
c += (b ^ d & (a ^ b)) + blocks2[10] - 42063;
|
|
321
|
+
c = (c << 17 | c >>> 15) + d << 0;
|
|
322
|
+
b += (a ^ c & (d ^ a)) + blocks2[11] - 1990404162;
|
|
323
|
+
b = (b << 22 | b >>> 10) + c << 0;
|
|
324
|
+
a += (d ^ b & (c ^ d)) + blocks2[12] + 1804603682;
|
|
325
|
+
a = (a << 7 | a >>> 25) + b << 0;
|
|
326
|
+
d += (c ^ a & (b ^ c)) + blocks2[13] - 40341101;
|
|
327
|
+
d = (d << 12 | d >>> 20) + a << 0;
|
|
328
|
+
c += (b ^ d & (a ^ b)) + blocks2[14] - 1502002290;
|
|
329
|
+
c = (c << 17 | c >>> 15) + d << 0;
|
|
330
|
+
b += (a ^ c & (d ^ a)) + blocks2[15] + 1236535329;
|
|
331
|
+
b = (b << 22 | b >>> 10) + c << 0;
|
|
332
|
+
a += (c ^ d & (b ^ c)) + blocks2[1] - 165796510;
|
|
333
|
+
a = (a << 5 | a >>> 27) + b << 0;
|
|
334
|
+
d += (b ^ c & (a ^ b)) + blocks2[6] - 1069501632;
|
|
335
|
+
d = (d << 9 | d >>> 23) + a << 0;
|
|
336
|
+
c += (a ^ b & (d ^ a)) + blocks2[11] + 643717713;
|
|
337
|
+
c = (c << 14 | c >>> 18) + d << 0;
|
|
338
|
+
b += (d ^ a & (c ^ d)) + blocks2[0] - 373897302;
|
|
339
|
+
b = (b << 20 | b >>> 12) + c << 0;
|
|
340
|
+
a += (c ^ d & (b ^ c)) + blocks2[5] - 701558691;
|
|
341
|
+
a = (a << 5 | a >>> 27) + b << 0;
|
|
342
|
+
d += (b ^ c & (a ^ b)) + blocks2[10] + 38016083;
|
|
343
|
+
d = (d << 9 | d >>> 23) + a << 0;
|
|
344
|
+
c += (a ^ b & (d ^ a)) + blocks2[15] - 660478335;
|
|
345
|
+
c = (c << 14 | c >>> 18) + d << 0;
|
|
346
|
+
b += (d ^ a & (c ^ d)) + blocks2[4] - 405537848;
|
|
347
|
+
b = (b << 20 | b >>> 12) + c << 0;
|
|
348
|
+
a += (c ^ d & (b ^ c)) + blocks2[9] + 568446438;
|
|
349
|
+
a = (a << 5 | a >>> 27) + b << 0;
|
|
350
|
+
d += (b ^ c & (a ^ b)) + blocks2[14] - 1019803690;
|
|
351
|
+
d = (d << 9 | d >>> 23) + a << 0;
|
|
352
|
+
c += (a ^ b & (d ^ a)) + blocks2[3] - 187363961;
|
|
353
|
+
c = (c << 14 | c >>> 18) + d << 0;
|
|
354
|
+
b += (d ^ a & (c ^ d)) + blocks2[8] + 1163531501;
|
|
355
|
+
b = (b << 20 | b >>> 12) + c << 0;
|
|
356
|
+
a += (c ^ d & (b ^ c)) + blocks2[13] - 1444681467;
|
|
357
|
+
a = (a << 5 | a >>> 27) + b << 0;
|
|
358
|
+
d += (b ^ c & (a ^ b)) + blocks2[2] - 51403784;
|
|
359
|
+
d = (d << 9 | d >>> 23) + a << 0;
|
|
360
|
+
c += (a ^ b & (d ^ a)) + blocks2[7] + 1735328473;
|
|
361
|
+
c = (c << 14 | c >>> 18) + d << 0;
|
|
362
|
+
b += (d ^ a & (c ^ d)) + blocks2[12] - 1926607734;
|
|
363
|
+
b = (b << 20 | b >>> 12) + c << 0;
|
|
364
|
+
bc = b ^ c;
|
|
365
|
+
a += (bc ^ d) + blocks2[5] - 378558;
|
|
366
|
+
a = (a << 4 | a >>> 28) + b << 0;
|
|
367
|
+
d += (bc ^ a) + blocks2[8] - 2022574463;
|
|
368
|
+
d = (d << 11 | d >>> 21) + a << 0;
|
|
369
|
+
da = d ^ a;
|
|
370
|
+
c += (da ^ b) + blocks2[11] + 1839030562;
|
|
371
|
+
c = (c << 16 | c >>> 16) + d << 0;
|
|
372
|
+
b += (da ^ c) + blocks2[14] - 35309556;
|
|
373
|
+
b = (b << 23 | b >>> 9) + c << 0;
|
|
374
|
+
bc = b ^ c;
|
|
375
|
+
a += (bc ^ d) + blocks2[1] - 1530992060;
|
|
376
|
+
a = (a << 4 | a >>> 28) + b << 0;
|
|
377
|
+
d += (bc ^ a) + blocks2[4] + 1272893353;
|
|
378
|
+
d = (d << 11 | d >>> 21) + a << 0;
|
|
379
|
+
da = d ^ a;
|
|
380
|
+
c += (da ^ b) + blocks2[7] - 155497632;
|
|
381
|
+
c = (c << 16 | c >>> 16) + d << 0;
|
|
382
|
+
b += (da ^ c) + blocks2[10] - 1094730640;
|
|
383
|
+
b = (b << 23 | b >>> 9) + c << 0;
|
|
384
|
+
bc = b ^ c;
|
|
385
|
+
a += (bc ^ d) + blocks2[13] + 681279174;
|
|
386
|
+
a = (a << 4 | a >>> 28) + b << 0;
|
|
387
|
+
d += (bc ^ a) + blocks2[0] - 358537222;
|
|
388
|
+
d = (d << 11 | d >>> 21) + a << 0;
|
|
389
|
+
da = d ^ a;
|
|
390
|
+
c += (da ^ b) + blocks2[3] - 722521979;
|
|
391
|
+
c = (c << 16 | c >>> 16) + d << 0;
|
|
392
|
+
b += (da ^ c) + blocks2[6] + 76029189;
|
|
393
|
+
b = (b << 23 | b >>> 9) + c << 0;
|
|
394
|
+
bc = b ^ c;
|
|
395
|
+
a += (bc ^ d) + blocks2[9] - 640364487;
|
|
396
|
+
a = (a << 4 | a >>> 28) + b << 0;
|
|
397
|
+
d += (bc ^ a) + blocks2[12] - 421815835;
|
|
398
|
+
d = (d << 11 | d >>> 21) + a << 0;
|
|
399
|
+
da = d ^ a;
|
|
400
|
+
c += (da ^ b) + blocks2[15] + 530742520;
|
|
401
|
+
c = (c << 16 | c >>> 16) + d << 0;
|
|
402
|
+
b += (da ^ c) + blocks2[2] - 995338651;
|
|
403
|
+
b = (b << 23 | b >>> 9) + c << 0;
|
|
404
|
+
a += (c ^ (b | ~d)) + blocks2[0] - 198630844;
|
|
405
|
+
a = (a << 6 | a >>> 26) + b << 0;
|
|
406
|
+
d += (b ^ (a | ~c)) + blocks2[7] + 1126891415;
|
|
407
|
+
d = (d << 10 | d >>> 22) + a << 0;
|
|
408
|
+
c += (a ^ (d | ~b)) + blocks2[14] - 1416354905;
|
|
409
|
+
c = (c << 15 | c >>> 17) + d << 0;
|
|
410
|
+
b += (d ^ (c | ~a)) + blocks2[5] - 57434055;
|
|
411
|
+
b = (b << 21 | b >>> 11) + c << 0;
|
|
412
|
+
a += (c ^ (b | ~d)) + blocks2[12] + 1700485571;
|
|
413
|
+
a = (a << 6 | a >>> 26) + b << 0;
|
|
414
|
+
d += (b ^ (a | ~c)) + blocks2[3] - 1894986606;
|
|
415
|
+
d = (d << 10 | d >>> 22) + a << 0;
|
|
416
|
+
c += (a ^ (d | ~b)) + blocks2[10] - 1051523;
|
|
417
|
+
c = (c << 15 | c >>> 17) + d << 0;
|
|
418
|
+
b += (d ^ (c | ~a)) + blocks2[1] - 2054922799;
|
|
419
|
+
b = (b << 21 | b >>> 11) + c << 0;
|
|
420
|
+
a += (c ^ (b | ~d)) + blocks2[8] + 1873313359;
|
|
421
|
+
a = (a << 6 | a >>> 26) + b << 0;
|
|
422
|
+
d += (b ^ (a | ~c)) + blocks2[15] - 30611744;
|
|
423
|
+
d = (d << 10 | d >>> 22) + a << 0;
|
|
424
|
+
c += (a ^ (d | ~b)) + blocks2[6] - 1560198380;
|
|
425
|
+
c = (c << 15 | c >>> 17) + d << 0;
|
|
426
|
+
b += (d ^ (c | ~a)) + blocks2[13] + 1309151649;
|
|
427
|
+
b = (b << 21 | b >>> 11) + c << 0;
|
|
428
|
+
a += (c ^ (b | ~d)) + blocks2[4] - 145523070;
|
|
429
|
+
a = (a << 6 | a >>> 26) + b << 0;
|
|
430
|
+
d += (b ^ (a | ~c)) + blocks2[11] - 1120210379;
|
|
431
|
+
d = (d << 10 | d >>> 22) + a << 0;
|
|
432
|
+
c += (a ^ (d | ~b)) + blocks2[2] + 718787259;
|
|
433
|
+
c = (c << 15 | c >>> 17) + d << 0;
|
|
434
|
+
b += (d ^ (c | ~a)) + blocks2[9] - 343485551;
|
|
435
|
+
b = (b << 21 | b >>> 11) + c << 0;
|
|
436
|
+
if (this.first) {
|
|
437
|
+
this.h0 = a + 1732584193 << 0;
|
|
438
|
+
this.h1 = b - 271733879 << 0;
|
|
439
|
+
this.h2 = c - 1732584194 << 0;
|
|
440
|
+
this.h3 = d + 271733878 << 0;
|
|
441
|
+
this.first = false;
|
|
442
|
+
} else {
|
|
443
|
+
this.h0 = this.h0 + a << 0;
|
|
444
|
+
this.h1 = this.h1 + b << 0;
|
|
445
|
+
this.h2 = this.h2 + c << 0;
|
|
446
|
+
this.h3 = this.h3 + d << 0;
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
Md5.prototype.hex = function() {
|
|
450
|
+
this.finalize();
|
|
451
|
+
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3;
|
|
452
|
+
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];
|
|
453
|
+
};
|
|
454
|
+
Md5.prototype.toString = Md5.prototype.hex;
|
|
455
|
+
Md5.prototype.digest = function() {
|
|
456
|
+
this.finalize();
|
|
457
|
+
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3;
|
|
458
|
+
return [
|
|
459
|
+
h0 & 255,
|
|
460
|
+
h0 >>> 8 & 255,
|
|
461
|
+
h0 >>> 16 & 255,
|
|
462
|
+
h0 >>> 24 & 255,
|
|
463
|
+
h1 & 255,
|
|
464
|
+
h1 >>> 8 & 255,
|
|
465
|
+
h1 >>> 16 & 255,
|
|
466
|
+
h1 >>> 24 & 255,
|
|
467
|
+
h2 & 255,
|
|
468
|
+
h2 >>> 8 & 255,
|
|
469
|
+
h2 >>> 16 & 255,
|
|
470
|
+
h2 >>> 24 & 255,
|
|
471
|
+
h3 & 255,
|
|
472
|
+
h3 >>> 8 & 255,
|
|
473
|
+
h3 >>> 16 & 255,
|
|
474
|
+
h3 >>> 24 & 255
|
|
475
|
+
];
|
|
476
|
+
};
|
|
477
|
+
Md5.prototype.array = Md5.prototype.digest;
|
|
478
|
+
Md5.prototype.arrayBuffer = function() {
|
|
479
|
+
this.finalize();
|
|
480
|
+
var buffer2 = new ArrayBuffer(16);
|
|
481
|
+
var blocks2 = new Uint32Array(buffer2);
|
|
482
|
+
blocks2[0] = this.h0;
|
|
483
|
+
blocks2[1] = this.h1;
|
|
484
|
+
blocks2[2] = this.h2;
|
|
485
|
+
blocks2[3] = this.h3;
|
|
486
|
+
return buffer2;
|
|
487
|
+
};
|
|
488
|
+
Md5.prototype.buffer = Md5.prototype.arrayBuffer;
|
|
489
|
+
Md5.prototype.base64 = function() {
|
|
490
|
+
var v1, v2, v3, base64Str = "", bytes = this.array();
|
|
491
|
+
for (var i = 0; i < 15; ) {
|
|
492
|
+
v1 = bytes[i++];
|
|
493
|
+
v2 = bytes[i++];
|
|
494
|
+
v3 = bytes[i++];
|
|
495
|
+
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];
|
|
496
|
+
}
|
|
497
|
+
v1 = bytes[i];
|
|
498
|
+
base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] + BASE64_ENCODE_CHAR[v1 << 4 & 63] + "==";
|
|
499
|
+
return base64Str;
|
|
500
|
+
};
|
|
501
|
+
function HmacMd5(key, sharedMemory) {
|
|
502
|
+
var i, result = formatMessage(key);
|
|
503
|
+
key = result[0];
|
|
504
|
+
if (result[1]) {
|
|
505
|
+
var bytes = [], length = key.length, index = 0, code;
|
|
506
|
+
for (i = 0; i < length; ++i) {
|
|
507
|
+
code = key.charCodeAt(i);
|
|
508
|
+
if (code < 128) {
|
|
509
|
+
bytes[index++] = code;
|
|
510
|
+
} else if (code < 2048) {
|
|
511
|
+
bytes[index++] = 192 | code >>> 6;
|
|
512
|
+
bytes[index++] = 128 | code & 63;
|
|
513
|
+
} else if (code < 55296 || code >= 57344) {
|
|
514
|
+
bytes[index++] = 224 | code >>> 12;
|
|
515
|
+
bytes[index++] = 128 | code >>> 6 & 63;
|
|
516
|
+
bytes[index++] = 128 | code & 63;
|
|
517
|
+
} else {
|
|
518
|
+
code = 65536 + ((code & 1023) << 10 | key.charCodeAt(++i) & 1023);
|
|
519
|
+
bytes[index++] = 240 | code >>> 18;
|
|
520
|
+
bytes[index++] = 128 | code >>> 12 & 63;
|
|
521
|
+
bytes[index++] = 128 | code >>> 6 & 63;
|
|
522
|
+
bytes[index++] = 128 | code & 63;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
key = bytes;
|
|
526
|
+
}
|
|
527
|
+
if (key.length > 64) {
|
|
528
|
+
key = new Md5(true).update(key).array();
|
|
529
|
+
}
|
|
530
|
+
var oKeyPad = [], iKeyPad = [];
|
|
531
|
+
for (i = 0; i < 64; ++i) {
|
|
532
|
+
var b = key[i] || 0;
|
|
533
|
+
oKeyPad[i] = 92 ^ b;
|
|
534
|
+
iKeyPad[i] = 54 ^ b;
|
|
535
|
+
}
|
|
536
|
+
Md5.call(this, sharedMemory);
|
|
537
|
+
this.update(iKeyPad);
|
|
538
|
+
this.oKeyPad = oKeyPad;
|
|
539
|
+
this.inner = true;
|
|
540
|
+
this.sharedMemory = sharedMemory;
|
|
541
|
+
}
|
|
542
|
+
HmacMd5.prototype = new Md5();
|
|
543
|
+
HmacMd5.prototype.finalize = function() {
|
|
544
|
+
Md5.prototype.finalize.call(this);
|
|
545
|
+
if (this.inner) {
|
|
546
|
+
this.inner = false;
|
|
547
|
+
var innerHash = this.array();
|
|
548
|
+
Md5.call(this, this.sharedMemory);
|
|
549
|
+
this.update(this.oKeyPad);
|
|
550
|
+
this.update(innerHash);
|
|
551
|
+
Md5.prototype.finalize.call(this);
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
var exports3 = createMethod();
|
|
555
|
+
exports3.md5 = exports3;
|
|
556
|
+
exports3.md5.hmac = createHmacMethod();
|
|
557
|
+
if (COMMON_JS) {
|
|
558
|
+
module2.exports = exports3;
|
|
559
|
+
} else {
|
|
560
|
+
root.md5 = exports3;
|
|
561
|
+
if (AMD) {
|
|
562
|
+
define(function() {
|
|
563
|
+
return exports3;
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
})();
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
|
|
19
571
|
// src/fingerprint/index.ts
|
|
20
572
|
var index_exports = {};
|
|
21
573
|
__export(index_exports, {
|
|
574
|
+
assessPaymentRisk: () => assessPaymentRisk,
|
|
22
575
|
buildIdentityId: () => buildIdentityId,
|
|
576
|
+
capturePaymentFingerprintNow: () => capturePaymentFingerprintNow,
|
|
577
|
+
compareFingerprintAgainstHistory: () => compareFingerprintAgainstHistory,
|
|
23
578
|
compareFingerprints: () => compareFingerprints,
|
|
24
579
|
getFingerprint: () => getFingerprint,
|
|
25
580
|
getFingerprintQuick: () => getFingerprintQuick,
|
|
26
|
-
resolveFingerprintPerformance: () => resolveFingerprintPerformance
|
|
581
|
+
resolveFingerprintPerformance: () => resolveFingerprintPerformance,
|
|
582
|
+
startPaymentFingerprintSession: () => startPaymentFingerprintSession
|
|
27
583
|
});
|
|
28
584
|
module.exports = __toCommonJS(index_exports);
|
|
29
585
|
|
|
@@ -73,7 +629,7 @@ function resolvePerformance(options) {
|
|
|
73
629
|
}
|
|
74
630
|
|
|
75
631
|
// src/utils/collectUserData.ts
|
|
76
|
-
var import_js_md5 =
|
|
632
|
+
var import_js_md5 = __toESM(require_md5(), 1);
|
|
77
633
|
function item(category, key, label, value) {
|
|
78
634
|
return { category, key, label, value: String(value ?? "\u2014") };
|
|
79
635
|
}
|
|
@@ -692,6 +1248,8 @@ async function fetchWebRtcLocalIp() {
|
|
|
692
1248
|
|
|
693
1249
|
// src/fingerprint/collectors.ts
|
|
694
1250
|
var collectorCache = /* @__PURE__ */ new Map();
|
|
1251
|
+
var syncCache = null;
|
|
1252
|
+
var SYNC_CACHE_TTL_MS = 15e3;
|
|
695
1253
|
var ASYNC_COLLECTORS = {
|
|
696
1254
|
network: fetchIpAndGeo,
|
|
697
1255
|
webrtc: fetchWebRtcLocalIp,
|
|
@@ -766,6 +1324,18 @@ function buildCacheKey(collect, timeoutMs) {
|
|
|
766
1324
|
function toSignalMap(items) {
|
|
767
1325
|
return Object.fromEntries(items.map((entry) => [entry.key, entry.value]));
|
|
768
1326
|
}
|
|
1327
|
+
function getSyncItemsCached() {
|
|
1328
|
+
const now = Date.now();
|
|
1329
|
+
if (syncCache && syncCache.expiresAt > now) {
|
|
1330
|
+
return syncCache.value;
|
|
1331
|
+
}
|
|
1332
|
+
const value = collectUserData();
|
|
1333
|
+
syncCache = {
|
|
1334
|
+
value,
|
|
1335
|
+
expiresAt: now + SYNC_CACHE_TTL_MS
|
|
1336
|
+
};
|
|
1337
|
+
return value;
|
|
1338
|
+
}
|
|
769
1339
|
async function gatherSignals(options) {
|
|
770
1340
|
const requiredInputs = sanitizeInputMap(options.required);
|
|
771
1341
|
const optionalInputs = sanitizeInputMap(options.optional ?? {});
|
|
@@ -774,7 +1344,7 @@ async function gatherSignals(options) {
|
|
|
774
1344
|
...options.collect ?? {}
|
|
775
1345
|
};
|
|
776
1346
|
const performance = resolvePerformance(options.performance);
|
|
777
|
-
const syncItems =
|
|
1347
|
+
const syncItems = getSyncItemsCached();
|
|
778
1348
|
const cacheKey = buildCacheKey(mergedCollect, performance.timeoutMs);
|
|
779
1349
|
const cacheEntry = collectorCache.get(cacheKey);
|
|
780
1350
|
const now = Date.now();
|
|
@@ -823,7 +1393,7 @@ async function gatherSignals(options) {
|
|
|
823
1393
|
function gatherQuickSignals(options) {
|
|
824
1394
|
const requiredInputs = sanitizeInputMap(options.required);
|
|
825
1395
|
const optionalInputs = sanitizeInputMap(options.optional ?? {});
|
|
826
|
-
const rawItems =
|
|
1396
|
+
const rawItems = getSyncItemsCached();
|
|
827
1397
|
return {
|
|
828
1398
|
rawItems,
|
|
829
1399
|
deviceSignals: toSignalMap(rawItems),
|
|
@@ -836,7 +1406,7 @@ function gatherQuickSignals(options) {
|
|
|
836
1406
|
}
|
|
837
1407
|
|
|
838
1408
|
// src/fingerprint/hash.ts
|
|
839
|
-
var import_js_md52 =
|
|
1409
|
+
var import_js_md52 = __toESM(require_md5(), 1);
|
|
840
1410
|
function toHex(buffer) {
|
|
841
1411
|
const bytes = new Uint8Array(buffer);
|
|
842
1412
|
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
@@ -1018,8 +1588,10 @@ async function getFingerprint(options) {
|
|
|
1018
1588
|
const corePayload = toCoreCanonicalPayload(components);
|
|
1019
1589
|
const fullPayload = toCanonicalPayload(components);
|
|
1020
1590
|
const digestAlgorithm = ((_a = options.hash) == null ? void 0 : _a.algorithm) ?? "SHA-256";
|
|
1021
|
-
const coreHash = await
|
|
1022
|
-
|
|
1591
|
+
const [coreHash, fullHash] = await Promise.all([
|
|
1592
|
+
createDigest(corePayload, digestAlgorithm),
|
|
1593
|
+
createDigest(fullPayload, digestAlgorithm)
|
|
1594
|
+
]);
|
|
1023
1595
|
const completedAtMs = Date.now();
|
|
1024
1596
|
const includeRaw = ((_b = options.privacy) == null ? void 0 : _b.includeRaw) ?? true;
|
|
1025
1597
|
const maskedRaw = applyPrivacy(gathered.rawItems, ((_c = options.privacy) == null ? void 0 : _c.maskSensitive) ?? false);
|
|
@@ -1067,8 +1639,10 @@ async function getFingerprintQuick(options) {
|
|
|
1067
1639
|
const corePayload = toCoreCanonicalPayload(components);
|
|
1068
1640
|
const fullPayload = toCanonicalPayload(components);
|
|
1069
1641
|
const digestAlgorithm = ((_a = options.hash) == null ? void 0 : _a.algorithm) ?? "SHA-256";
|
|
1070
|
-
const coreHash = await
|
|
1071
|
-
|
|
1642
|
+
const [coreHash, fullHash] = await Promise.all([
|
|
1643
|
+
createDigest(corePayload, digestAlgorithm),
|
|
1644
|
+
createDigest(fullPayload, digestAlgorithm)
|
|
1645
|
+
]);
|
|
1072
1646
|
const completedAtMs = Date.now();
|
|
1073
1647
|
const includeRaw = ((_b = options.privacy) == null ? void 0 : _b.includeRaw) ?? true;
|
|
1074
1648
|
const maskedRaw = applyPrivacy(gathered.rawItems, ((_c = options.privacy) == null ? void 0 : _c.maskSensitive) ?? false);
|
|
@@ -1103,7 +1677,38 @@ function resolveFingerprintPerformance(options) {
|
|
|
1103
1677
|
function round3(value) {
|
|
1104
1678
|
return Math.max(0, Math.min(1, Number(value.toFixed(3))));
|
|
1105
1679
|
}
|
|
1680
|
+
function tokenize(value) {
|
|
1681
|
+
return value.split(/[,;| ]+/).map((token) => token.trim()).filter(Boolean);
|
|
1682
|
+
}
|
|
1683
|
+
function setOverlapRatio(left, right) {
|
|
1684
|
+
const a = new Set(tokenize(left));
|
|
1685
|
+
const b = new Set(tokenize(right));
|
|
1686
|
+
if (a.size === 0 || b.size === 0) {
|
|
1687
|
+
return 0;
|
|
1688
|
+
}
|
|
1689
|
+
let overlap = 0;
|
|
1690
|
+
for (const token of a) {
|
|
1691
|
+
if (b.has(token)) overlap += 1;
|
|
1692
|
+
}
|
|
1693
|
+
return overlap / Math.max(a.size, b.size);
|
|
1694
|
+
}
|
|
1695
|
+
function valueSimilarity(left, right) {
|
|
1696
|
+
if (left === right) return 1;
|
|
1697
|
+
const leftNum = Number(left);
|
|
1698
|
+
const rightNum = Number(right);
|
|
1699
|
+
if (!Number.isNaN(leftNum) && !Number.isNaN(rightNum)) {
|
|
1700
|
+
const maxAbs = Math.max(Math.abs(leftNum), Math.abs(rightNum), 1);
|
|
1701
|
+
const distance = Math.abs(leftNum - rightNum) / maxAbs;
|
|
1702
|
+
return Math.max(0, 1 - distance);
|
|
1703
|
+
}
|
|
1704
|
+
const overlap = setOverlapRatio(left, right);
|
|
1705
|
+
if (overlap >= 0.8) return 0.85;
|
|
1706
|
+
if (overlap >= 0.5) return 0.65;
|
|
1707
|
+
if (overlap >= 0.25) return 0.35;
|
|
1708
|
+
return 0;
|
|
1709
|
+
}
|
|
1106
1710
|
function compareFingerprints(current, reference) {
|
|
1711
|
+
const currentMap = new Map(current.components.map((component) => [component.key, component]));
|
|
1107
1712
|
let totalReferenceWeight = 0;
|
|
1108
1713
|
let matchedWeight = 0;
|
|
1109
1714
|
const changedStableKeys = [];
|
|
@@ -1111,9 +1716,17 @@ function compareFingerprints(current, reference) {
|
|
|
1111
1716
|
for (const refComponent of reference.components) {
|
|
1112
1717
|
if (!refComponent.present) continue;
|
|
1113
1718
|
totalReferenceWeight += refComponent.weight;
|
|
1114
|
-
const currentComponent =
|
|
1115
|
-
if (currentComponent && currentComponent.present
|
|
1116
|
-
|
|
1719
|
+
const currentComponent = currentMap.get(refComponent.key);
|
|
1720
|
+
if (currentComponent && currentComponent.present) {
|
|
1721
|
+
const similarity = valueSimilarity(currentComponent.value, refComponent.value);
|
|
1722
|
+
matchedWeight += refComponent.weight * similarity;
|
|
1723
|
+
if (similarity >= 0.7) {
|
|
1724
|
+
continue;
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
if (!currentComponent || !currentComponent.present) {
|
|
1728
|
+
if (refComponent.stability === "stable") changedStableKeys.push(refComponent.key);
|
|
1729
|
+
if (refComponent.stability === "volatile") changedVolatileKeys.push(refComponent.key);
|
|
1117
1730
|
continue;
|
|
1118
1731
|
}
|
|
1119
1732
|
if (refComponent.stability === "stable") changedStableKeys.push(refComponent.key);
|
|
@@ -1148,6 +1761,19 @@ function compareFingerprints(current, reference) {
|
|
|
1148
1761
|
risk += 0.05;
|
|
1149
1762
|
reasons.push("Fingerprint confidence is limited");
|
|
1150
1763
|
}
|
|
1764
|
+
const cdc = current.deviceSignals.chromeCdc === "true";
|
|
1765
|
+
const webdriver = current.deviceSignals.webdriver === "true";
|
|
1766
|
+
const playwright = current.deviceSignals.playwright === "true";
|
|
1767
|
+
if (cdc || webdriver || playwright) {
|
|
1768
|
+
risk += 0.2;
|
|
1769
|
+
reasons.push("Explicit automation indicators detected");
|
|
1770
|
+
}
|
|
1771
|
+
const localIpBlocked = (current.deviceSignals.localIp ?? "").includes("\u043D\u0435 \u043E\u0431\u043D\u0430\u0440\u0443\u0436\u0435\u043D");
|
|
1772
|
+
const publicIpMissing = (current.deviceSignals.ip ?? "").includes("\u043D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u043E\u043B\u0443\u0447\u0438\u0442\u044C");
|
|
1773
|
+
if (localIpBlocked && publicIpMissing) {
|
|
1774
|
+
risk += 0.05;
|
|
1775
|
+
reasons.push("Network identity signals are partially unavailable");
|
|
1776
|
+
}
|
|
1151
1777
|
const riskScore = round3(risk);
|
|
1152
1778
|
let verdict = "different_device";
|
|
1153
1779
|
if (similarityScore >= 0.85 && riskScore < 0.35) verdict = "same_device";
|
|
@@ -1170,11 +1796,220 @@ function compareFingerprints(current, reference) {
|
|
|
1170
1796
|
function buildIdentityId(profile) {
|
|
1171
1797
|
return profile.coreHash;
|
|
1172
1798
|
}
|
|
1799
|
+
function compareFingerprintAgainstHistory(current, history2) {
|
|
1800
|
+
if (!history2.length) {
|
|
1801
|
+
const self2 = compareFingerprints(current, current);
|
|
1802
|
+
return {
|
|
1803
|
+
best: self2,
|
|
1804
|
+
bestIndex: -1,
|
|
1805
|
+
comparedCount: 0,
|
|
1806
|
+
aggregateRiskScore: self2.riskScore,
|
|
1807
|
+
aggregateSimilarityScore: self2.similarityScore
|
|
1808
|
+
};
|
|
1809
|
+
}
|
|
1810
|
+
const comparisons = history2.map((entry) => compareFingerprints(current, entry));
|
|
1811
|
+
let bestIndex = 0;
|
|
1812
|
+
for (let i = 1; i < comparisons.length; i += 1) {
|
|
1813
|
+
const candidate = comparisons[i];
|
|
1814
|
+
const best = comparisons[bestIndex];
|
|
1815
|
+
if (candidate.similarityScore > best.similarityScore) {
|
|
1816
|
+
bestIndex = i;
|
|
1817
|
+
} else if (candidate.similarityScore === best.similarityScore && candidate.riskScore < best.riskScore) {
|
|
1818
|
+
bestIndex = i;
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
const aggregateRiskScore = round3(
|
|
1822
|
+
comparisons.reduce((sum, item2) => sum + item2.riskScore, 0) / comparisons.length
|
|
1823
|
+
);
|
|
1824
|
+
const aggregateSimilarityScore = round3(
|
|
1825
|
+
comparisons.reduce((sum, item2) => sum + item2.similarityScore, 0) / comparisons.length
|
|
1826
|
+
);
|
|
1827
|
+
return {
|
|
1828
|
+
best: comparisons[bestIndex],
|
|
1829
|
+
bestIndex,
|
|
1830
|
+
comparedCount: comparisons.length,
|
|
1831
|
+
aggregateRiskScore,
|
|
1832
|
+
aggregateSimilarityScore
|
|
1833
|
+
};
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1836
|
+
// src/fingerprint/payment.ts
|
|
1837
|
+
function makeSessionId() {
|
|
1838
|
+
try {
|
|
1839
|
+
return crypto.randomUUID();
|
|
1840
|
+
} catch {
|
|
1841
|
+
return `pf-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
function normalizeRequired(options) {
|
|
1845
|
+
const out = {
|
|
1846
|
+
merchantId: options.required.merchantId,
|
|
1847
|
+
paymentId: options.required.paymentId
|
|
1848
|
+
};
|
|
1849
|
+
if (options.required.customerId) {
|
|
1850
|
+
out.customerId = options.required.customerId;
|
|
1851
|
+
}
|
|
1852
|
+
return out;
|
|
1853
|
+
}
|
|
1854
|
+
function scheduleBackgroundTask(run, useIdle) {
|
|
1855
|
+
if (useIdle && typeof window !== "undefined" && "requestIdleCallback" in window) {
|
|
1856
|
+
return new Promise((resolve, reject) => {
|
|
1857
|
+
const idle = window.requestIdleCallback;
|
|
1858
|
+
idle(() => {
|
|
1859
|
+
run().then(resolve).catch(reject);
|
|
1860
|
+
}, { timeout: 1500 });
|
|
1861
|
+
});
|
|
1862
|
+
}
|
|
1863
|
+
return new Promise((resolve, reject) => {
|
|
1864
|
+
setTimeout(() => {
|
|
1865
|
+
run().then(resolve).catch(reject);
|
|
1866
|
+
}, 0);
|
|
1867
|
+
});
|
|
1868
|
+
}
|
|
1869
|
+
function startPaymentFingerprintSession(options) {
|
|
1870
|
+
var _a, _b;
|
|
1871
|
+
const sessionId = makeSessionId();
|
|
1872
|
+
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1873
|
+
const required = normalizeRequired(options);
|
|
1874
|
+
fetch("http://127.0.0.1:7417/ingest/67545057-d930-4022-a3c5-818008410ad2", { method: "POST", headers: { "Content-Type": "application/json", "X-Debug-Session-Id": "ce1cd9" }, body: JSON.stringify({ sessionId: "ce1cd9", runId: sessionId, hypothesisId: "H1", location: "src/fingerprint/payment.ts:startPaymentFingerprintSession", message: "payment fingerprint session started", data: { hasCustomerId: Boolean(required.customerId), hasOptional: Boolean(options.optional), collectConfigured: Boolean(options.collect) }, timestamp: Date.now() }) }).catch(() => {
|
|
1875
|
+
});
|
|
1876
|
+
const quickPromise = getFingerprintQuick({
|
|
1877
|
+
required,
|
|
1878
|
+
optional: options.optional,
|
|
1879
|
+
privacy: options.privacy,
|
|
1880
|
+
hash: options.hash
|
|
1881
|
+
}).then((result) => {
|
|
1882
|
+
var _a2, _b2;
|
|
1883
|
+
fetch("http://127.0.0.1:7417/ingest/67545057-d930-4022-a3c5-818008410ad2", { method: "POST", headers: { "Content-Type": "application/json", "X-Debug-Session-Id": "ce1cd9" }, body: JSON.stringify({ sessionId: "ce1cd9", runId: sessionId, hypothesisId: "H2", location: "src/fingerprint/payment.ts:quickPromise.then", message: "quick fingerprint completed", data: { elapsedMs: result.meta.elapsedMs, confidence: result.meta.confidenceScore, coreHashPrefix: result.coreHash.slice(0, 12) }, timestamp: Date.now() }) }).catch(() => {
|
|
1884
|
+
});
|
|
1885
|
+
(_b2 = (_a2 = options.hooks) == null ? void 0 : _a2.onQuick) == null ? void 0 : _b2.call(_a2, result);
|
|
1886
|
+
return result;
|
|
1887
|
+
}).catch((error) => {
|
|
1888
|
+
var _a2, _b2;
|
|
1889
|
+
(_b2 = (_a2 = options.hooks) == null ? void 0 : _a2.onError) == null ? void 0 : _b2.call(_a2, error);
|
|
1890
|
+
throw error;
|
|
1891
|
+
});
|
|
1892
|
+
const fullMode = ((_a = options.performance) == null ? void 0 : _a.fullMode) ?? "balanced";
|
|
1893
|
+
const startFullOnIdle = ((_b = options.performance) == null ? void 0 : _b.startFullOnIdle) ?? true;
|
|
1894
|
+
const fullPromise = scheduleBackgroundTask(
|
|
1895
|
+
() => getFingerprint({
|
|
1896
|
+
required,
|
|
1897
|
+
optional: options.optional,
|
|
1898
|
+
collect: options.collect,
|
|
1899
|
+
performance: { mode: fullMode },
|
|
1900
|
+
privacy: options.privacy,
|
|
1901
|
+
hash: options.hash
|
|
1902
|
+
}),
|
|
1903
|
+
startFullOnIdle
|
|
1904
|
+
).then((result) => {
|
|
1905
|
+
var _a2, _b2;
|
|
1906
|
+
fetch("http://127.0.0.1:7417/ingest/67545057-d930-4022-a3c5-818008410ad2", { method: "POST", headers: { "Content-Type": "application/json", "X-Debug-Session-Id": "ce1cd9" }, body: JSON.stringify({ sessionId: "ce1cd9", runId: sessionId, hypothesisId: "H3", location: "src/fingerprint/payment.ts:fullPromise.then", message: "full fingerprint completed", data: { elapsedMs: result.meta.elapsedMs, confidence: result.meta.confidenceScore, cacheHit: result.meta.cacheHit, timedOutCollectors: result.meta.timedOutCollectors.length }, timestamp: Date.now() }) }).catch(() => {
|
|
1907
|
+
});
|
|
1908
|
+
(_b2 = (_a2 = options.hooks) == null ? void 0 : _a2.onFull) == null ? void 0 : _b2.call(_a2, result);
|
|
1909
|
+
return result;
|
|
1910
|
+
}).catch((error) => {
|
|
1911
|
+
var _a2, _b2;
|
|
1912
|
+
(_b2 = (_a2 = options.hooks) == null ? void 0 : _a2.onError) == null ? void 0 : _b2.call(_a2, error);
|
|
1913
|
+
throw error;
|
|
1914
|
+
});
|
|
1915
|
+
return {
|
|
1916
|
+
sessionId,
|
|
1917
|
+
startedAt,
|
|
1918
|
+
quickPromise,
|
|
1919
|
+
fullPromise,
|
|
1920
|
+
waitForQuick: () => quickPromise,
|
|
1921
|
+
waitForFull: () => fullPromise,
|
|
1922
|
+
buildStagePayload: (stage, result) => ({
|
|
1923
|
+
stage,
|
|
1924
|
+
sessionId,
|
|
1925
|
+
startedAt,
|
|
1926
|
+
fingerprint: result
|
|
1927
|
+
})
|
|
1928
|
+
};
|
|
1929
|
+
}
|
|
1930
|
+
function assessPaymentRisk(input) {
|
|
1931
|
+
var _a, _b, _c, _d;
|
|
1932
|
+
const reasons = [...input.comparison.reasons];
|
|
1933
|
+
let score = input.comparison.riskScore;
|
|
1934
|
+
const similarityScore = input.comparison.similarityScore;
|
|
1935
|
+
if (input.history) {
|
|
1936
|
+
if (input.history.aggregateRiskScore > 0.6) {
|
|
1937
|
+
score += 0.1;
|
|
1938
|
+
reasons.push("Historical aggregate risk is elevated");
|
|
1939
|
+
}
|
|
1940
|
+
if (input.history.aggregateSimilarityScore < 0.55) {
|
|
1941
|
+
score += 0.1;
|
|
1942
|
+
reasons.push("Historical similarity is low");
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
const amount = ((_a = input.paymentContext) == null ? void 0 : _a.amount) ?? 0;
|
|
1946
|
+
if (amount >= 1e3) {
|
|
1947
|
+
score += 0.05;
|
|
1948
|
+
reasons.push("High transaction amount");
|
|
1949
|
+
}
|
|
1950
|
+
if ((((_b = input.paymentContext) == null ? void 0 : _b.attemptCount) ?? 0) >= 3) {
|
|
1951
|
+
score += 0.1;
|
|
1952
|
+
reasons.push("Multiple payment attempts in short time");
|
|
1953
|
+
}
|
|
1954
|
+
if ((_c = input.paymentContext) == null ? void 0 : _c.cardCountryMismatch) {
|
|
1955
|
+
score += 0.15;
|
|
1956
|
+
reasons.push("Card country mismatch detected");
|
|
1957
|
+
}
|
|
1958
|
+
if ((_d = input.paymentContext) == null ? void 0 : _d.velocityFlag) {
|
|
1959
|
+
score += 0.15;
|
|
1960
|
+
reasons.push("Velocity rule triggered");
|
|
1961
|
+
}
|
|
1962
|
+
const finalScore = Math.max(0, Math.min(1, Number(score.toFixed(3))));
|
|
1963
|
+
let decision = "manual_review";
|
|
1964
|
+
if (finalScore < 0.35 && similarityScore >= 0.82) decision = "allow";
|
|
1965
|
+
else if (finalScore < 0.55 && similarityScore >= 0.65) decision = "challenge";
|
|
1966
|
+
else if (finalScore >= 0.8 || similarityScore < 0.35) decision = "deny";
|
|
1967
|
+
const output = {
|
|
1968
|
+
decision,
|
|
1969
|
+
score: finalScore,
|
|
1970
|
+
reasons: Array.from(new Set(reasons)),
|
|
1971
|
+
similarityScore,
|
|
1972
|
+
riskScore: input.comparison.riskScore
|
|
1973
|
+
};
|
|
1974
|
+
fetch("http://127.0.0.1:7417/ingest/67545057-d930-4022-a3c5-818008410ad2", { method: "POST", headers: { "Content-Type": "application/json", "X-Debug-Session-Id": "ce1cd9" }, body: JSON.stringify({ sessionId: "ce1cd9", runId: "payment-risk", hypothesisId: "H4", location: "src/fingerprint/payment.ts:assessPaymentRisk", message: "payment risk assessed", data: { decision: output.decision, score: output.score, similarity: output.similarityScore, risk: output.riskScore, reasonsCount: output.reasons.length }, timestamp: Date.now() }) }).catch(() => {
|
|
1975
|
+
});
|
|
1976
|
+
return output;
|
|
1977
|
+
}
|
|
1978
|
+
async function capturePaymentFingerprintNow(options) {
|
|
1979
|
+
var _a;
|
|
1980
|
+
const required = normalizeRequired(options);
|
|
1981
|
+
const fullMode = ((_a = options.performance) == null ? void 0 : _a.fullMode) ?? "balanced";
|
|
1982
|
+
return getFingerprint({
|
|
1983
|
+
required,
|
|
1984
|
+
optional: options.optional,
|
|
1985
|
+
collect: options.collect,
|
|
1986
|
+
performance: { mode: fullMode },
|
|
1987
|
+
privacy: options.privacy,
|
|
1988
|
+
hash: options.hash
|
|
1989
|
+
});
|
|
1990
|
+
}
|
|
1173
1991
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1174
1992
|
0 && (module.exports = {
|
|
1993
|
+
assessPaymentRisk,
|
|
1175
1994
|
buildIdentityId,
|
|
1995
|
+
capturePaymentFingerprintNow,
|
|
1996
|
+
compareFingerprintAgainstHistory,
|
|
1176
1997
|
compareFingerprints,
|
|
1177
1998
|
getFingerprint,
|
|
1178
1999
|
getFingerprintQuick,
|
|
1179
|
-
resolveFingerprintPerformance
|
|
2000
|
+
resolveFingerprintPerformance,
|
|
2001
|
+
startPaymentFingerprintSession
|
|
1180
2002
|
});
|
|
2003
|
+
/*! Bundled license information:
|
|
2004
|
+
|
|
2005
|
+
js-md5/src/md5.js:
|
|
2006
|
+
(**
|
|
2007
|
+
* [js-md5]{@link https://github.com/emn178/js-md5}
|
|
2008
|
+
*
|
|
2009
|
+
* @namespace md5
|
|
2010
|
+
* @version 0.8.3
|
|
2011
|
+
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
2012
|
+
* @copyright Chen, Yi-Cyuan 2014-2023
|
|
2013
|
+
* @license MIT
|
|
2014
|
+
*)
|
|
2015
|
+
*/
|