@metamask/connect-multichain 0.4.0 → 0.5.1
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/CHANGELOG.md +33 -1
- package/dist/browser/es/connect-multichain.d.mts +26 -9
- package/dist/browser/es/connect-multichain.mjs +370 -100
- package/dist/browser/es/connect-multichain.mjs.map +1 -1
- package/dist/browser/es/metafile-esm.json +1 -1
- package/dist/browser/iife/connect-multichain.d.ts +26 -9
- package/dist/browser/iife/connect-multichain.js +2829 -224
- package/dist/browser/iife/connect-multichain.js.map +1 -1
- package/dist/browser/iife/metafile-iife.json +1 -1
- package/dist/browser/umd/connect-multichain.d.ts +26 -9
- package/dist/browser/umd/connect-multichain.js +370 -100
- package/dist/browser/umd/connect-multichain.js.map +1 -1
- package/dist/browser/umd/metafile-cjs.json +1 -1
- package/dist/node/cjs/connect-multichain.d.ts +26 -9
- package/dist/node/cjs/connect-multichain.js +364 -101
- package/dist/node/cjs/connect-multichain.js.map +1 -1
- package/dist/node/cjs/metafile-cjs.json +1 -1
- package/dist/node/es/connect-multichain.d.mts +26 -9
- package/dist/node/es/connect-multichain.mjs +363 -100
- package/dist/node/es/connect-multichain.mjs.map +1 -1
- package/dist/node/es/metafile-esm.json +1 -1
- package/dist/react-native/es/connect-multichain.d.mts +26 -9
- package/dist/react-native/es/connect-multichain.mjs +357 -91
- package/dist/react-native/es/connect-multichain.mjs.map +1 -1
- package/dist/react-native/es/metafile-esm.json +1 -1
- package/dist/src/domain/multichain/index.d.ts +4 -4
- package/dist/src/domain/multichain/index.d.ts.map +1 -1
- package/dist/src/domain/multichain/index.js.map +1 -1
- package/dist/src/domain/multichain/types.d.ts +4 -3
- package/dist/src/domain/multichain/types.d.ts.map +1 -1
- package/dist/src/domain/ui/types.d.ts +7 -0
- package/dist/src/domain/ui/types.d.ts.map +1 -1
- package/dist/src/domain/ui/types.js.map +1 -1
- package/dist/src/index.browser.d.ts +2 -1
- package/dist/src/index.browser.d.ts.map +1 -1
- package/dist/src/index.browser.js +5 -3
- package/dist/src/index.browser.js.map +1 -1
- package/dist/src/index.native.d.ts +2 -1
- package/dist/src/index.native.d.ts.map +1 -1
- package/dist/src/index.native.js +6 -4
- package/dist/src/index.native.js.map +1 -1
- package/dist/src/index.node.d.ts +1 -1
- package/dist/src/index.node.d.ts.map +1 -1
- package/dist/src/index.node.js +3 -3
- package/dist/src/index.node.js.map +1 -1
- package/dist/src/multichain/index.d.ts +8 -8
- package/dist/src/multichain/index.d.ts.map +1 -1
- package/dist/src/multichain/index.js +161 -101
- package/dist/src/multichain/index.js.map +1 -1
- package/dist/src/multichain/transports/default/index.d.ts +2 -1
- package/dist/src/multichain/transports/default/index.d.ts.map +1 -1
- package/dist/src/multichain/transports/default/index.js +1 -0
- package/dist/src/multichain/transports/default/index.js.map +1 -1
- package/dist/src/multichain/transports/multichainApiClientWrapper/index.d.ts +21 -0
- package/dist/src/multichain/transports/multichainApiClientWrapper/index.d.ts.map +1 -0
- package/dist/src/multichain/transports/multichainApiClientWrapper/index.js +159 -0
- package/dist/src/multichain/transports/multichainApiClientWrapper/index.js.map +1 -0
- package/dist/src/multichain/transports/mwp/index.d.ts +4 -1
- package/dist/src/multichain/transports/mwp/index.d.ts.map +1 -1
- package/dist/src/multichain/transports/mwp/index.js +54 -2
- package/dist/src/multichain/transports/mwp/index.js.map +1 -1
- package/dist/src/polyfills/buffer-shim.d.ts +2 -0
- package/dist/src/polyfills/buffer-shim.d.ts.map +1 -0
- package/dist/src/polyfills/buffer-shim.js +22 -0
- package/dist/src/polyfills/buffer-shim.js.map +1 -0
- package/dist/src/ui/ModalFactory.d.ts +54 -0
- package/dist/src/ui/ModalFactory.d.ts.map +1 -0
- package/dist/src/ui/ModalFactory.js +171 -0
- package/dist/src/ui/ModalFactory.js.map +1 -0
- package/dist/src/ui/index.d.ts +14 -38
- package/dist/src/ui/index.d.ts.map +1 -1
- package/dist/src/ui/index.js +24 -142
- package/dist/src/ui/index.js.map +1 -1
- package/dist/src/ui/index.native.d.ts +13 -0
- package/dist/src/ui/index.native.d.ts.map +1 -0
- package/dist/src/ui/{preload.native.js → index.native.js} +12 -6
- package/dist/src/ui/index.native.js.map +1 -0
- package/dist/src/ui/modals/base/AbstractInstallModal.d.ts.map +1 -1
- package/dist/src/ui/modals/base/AbstractInstallModal.js +0 -4
- package/dist/src/ui/modals/base/AbstractInstallModal.js.map +1 -1
- package/dist/types/connect-multichain.d.ts +26 -9
- package/package.json +9 -3
- package/dist/src/ui/preload.native.d.ts +0 -5
- package/dist/src/ui/preload.native.d.ts.map +0 -1
- package/dist/src/ui/preload.native.js.map +0 -1
- package/dist/src/ui/preload.web.d.ts +0 -5
- package/dist/src/ui/preload.web.d.ts.map +0 -1
- package/dist/src/ui/preload.web.js +0 -27
- package/dist/src/ui/preload.web.js.map +0 -1
|
@@ -73,6 +73,7 @@ var MetaMaskSDK = (() => {
|
|
|
73
73
|
mod
|
|
74
74
|
));
|
|
75
75
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
76
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
76
77
|
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
77
78
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
78
79
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
@@ -131,6 +132,1783 @@ var MetaMaskSDK = (() => {
|
|
|
131
132
|
}, "return" in obj && method("return"), it;
|
|
132
133
|
};
|
|
133
134
|
|
|
135
|
+
// ../../node_modules/base64-js/index.js
|
|
136
|
+
var require_base64_js = __commonJS({
|
|
137
|
+
"../../node_modules/base64-js/index.js"(exports) {
|
|
138
|
+
"use strict";
|
|
139
|
+
exports.byteLength = byteLength;
|
|
140
|
+
exports.toByteArray = toByteArray;
|
|
141
|
+
exports.fromByteArray = fromByteArray;
|
|
142
|
+
var lookup = [];
|
|
143
|
+
var revLookup = [];
|
|
144
|
+
var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
|
|
145
|
+
var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
146
|
+
for (i = 0, len = code.length; i < len; ++i) {
|
|
147
|
+
lookup[i] = code[i];
|
|
148
|
+
revLookup[code.charCodeAt(i)] = i;
|
|
149
|
+
}
|
|
150
|
+
var i;
|
|
151
|
+
var len;
|
|
152
|
+
revLookup["-".charCodeAt(0)] = 62;
|
|
153
|
+
revLookup["_".charCodeAt(0)] = 63;
|
|
154
|
+
function getLens(b64) {
|
|
155
|
+
var len2 = b64.length;
|
|
156
|
+
if (len2 % 4 > 0) {
|
|
157
|
+
throw new Error("Invalid string. Length must be a multiple of 4");
|
|
158
|
+
}
|
|
159
|
+
var validLen = b64.indexOf("=");
|
|
160
|
+
if (validLen === -1) validLen = len2;
|
|
161
|
+
var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
|
|
162
|
+
return [validLen, placeHoldersLen];
|
|
163
|
+
}
|
|
164
|
+
function byteLength(b64) {
|
|
165
|
+
var lens = getLens(b64);
|
|
166
|
+
var validLen = lens[0];
|
|
167
|
+
var placeHoldersLen = lens[1];
|
|
168
|
+
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
|
|
169
|
+
}
|
|
170
|
+
function _byteLength(b64, validLen, placeHoldersLen) {
|
|
171
|
+
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
|
|
172
|
+
}
|
|
173
|
+
function toByteArray(b64) {
|
|
174
|
+
var tmp;
|
|
175
|
+
var lens = getLens(b64);
|
|
176
|
+
var validLen = lens[0];
|
|
177
|
+
var placeHoldersLen = lens[1];
|
|
178
|
+
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
|
|
179
|
+
var curByte = 0;
|
|
180
|
+
var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen;
|
|
181
|
+
var i2;
|
|
182
|
+
for (i2 = 0; i2 < len2; i2 += 4) {
|
|
183
|
+
tmp = revLookup[b64.charCodeAt(i2)] << 18 | revLookup[b64.charCodeAt(i2 + 1)] << 12 | revLookup[b64.charCodeAt(i2 + 2)] << 6 | revLookup[b64.charCodeAt(i2 + 3)];
|
|
184
|
+
arr[curByte++] = tmp >> 16 & 255;
|
|
185
|
+
arr[curByte++] = tmp >> 8 & 255;
|
|
186
|
+
arr[curByte++] = tmp & 255;
|
|
187
|
+
}
|
|
188
|
+
if (placeHoldersLen === 2) {
|
|
189
|
+
tmp = revLookup[b64.charCodeAt(i2)] << 2 | revLookup[b64.charCodeAt(i2 + 1)] >> 4;
|
|
190
|
+
arr[curByte++] = tmp & 255;
|
|
191
|
+
}
|
|
192
|
+
if (placeHoldersLen === 1) {
|
|
193
|
+
tmp = revLookup[b64.charCodeAt(i2)] << 10 | revLookup[b64.charCodeAt(i2 + 1)] << 4 | revLookup[b64.charCodeAt(i2 + 2)] >> 2;
|
|
194
|
+
arr[curByte++] = tmp >> 8 & 255;
|
|
195
|
+
arr[curByte++] = tmp & 255;
|
|
196
|
+
}
|
|
197
|
+
return arr;
|
|
198
|
+
}
|
|
199
|
+
function tripletToBase64(num) {
|
|
200
|
+
return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
|
|
201
|
+
}
|
|
202
|
+
function encodeChunk(uint8, start, end) {
|
|
203
|
+
var tmp;
|
|
204
|
+
var output = [];
|
|
205
|
+
for (var i2 = start; i2 < end; i2 += 3) {
|
|
206
|
+
tmp = (uint8[i2] << 16 & 16711680) + (uint8[i2 + 1] << 8 & 65280) + (uint8[i2 + 2] & 255);
|
|
207
|
+
output.push(tripletToBase64(tmp));
|
|
208
|
+
}
|
|
209
|
+
return output.join("");
|
|
210
|
+
}
|
|
211
|
+
function fromByteArray(uint8) {
|
|
212
|
+
var tmp;
|
|
213
|
+
var len2 = uint8.length;
|
|
214
|
+
var extraBytes = len2 % 3;
|
|
215
|
+
var parts = [];
|
|
216
|
+
var maxChunkLength = 16383;
|
|
217
|
+
for (var i2 = 0, len22 = len2 - extraBytes; i2 < len22; i2 += maxChunkLength) {
|
|
218
|
+
parts.push(encodeChunk(uint8, i2, i2 + maxChunkLength > len22 ? len22 : i2 + maxChunkLength));
|
|
219
|
+
}
|
|
220
|
+
if (extraBytes === 1) {
|
|
221
|
+
tmp = uint8[len2 - 1];
|
|
222
|
+
parts.push(
|
|
223
|
+
lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "=="
|
|
224
|
+
);
|
|
225
|
+
} else if (extraBytes === 2) {
|
|
226
|
+
tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
|
|
227
|
+
parts.push(
|
|
228
|
+
lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "="
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
return parts.join("");
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
// ../../node_modules/ieee754/index.js
|
|
237
|
+
var require_ieee754 = __commonJS({
|
|
238
|
+
"../../node_modules/ieee754/index.js"(exports) {
|
|
239
|
+
"use strict";
|
|
240
|
+
exports.read = function(buffer, offset, isLE2, mLen, nBytes) {
|
|
241
|
+
var e, m;
|
|
242
|
+
var eLen = nBytes * 8 - mLen - 1;
|
|
243
|
+
var eMax = (1 << eLen) - 1;
|
|
244
|
+
var eBias = eMax >> 1;
|
|
245
|
+
var nBits = -7;
|
|
246
|
+
var i = isLE2 ? nBytes - 1 : 0;
|
|
247
|
+
var d = isLE2 ? -1 : 1;
|
|
248
|
+
var s = buffer[offset + i];
|
|
249
|
+
i += d;
|
|
250
|
+
e = s & (1 << -nBits) - 1;
|
|
251
|
+
s >>= -nBits;
|
|
252
|
+
nBits += eLen;
|
|
253
|
+
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {
|
|
254
|
+
}
|
|
255
|
+
m = e & (1 << -nBits) - 1;
|
|
256
|
+
e >>= -nBits;
|
|
257
|
+
nBits += mLen;
|
|
258
|
+
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {
|
|
259
|
+
}
|
|
260
|
+
if (e === 0) {
|
|
261
|
+
e = 1 - eBias;
|
|
262
|
+
} else if (e === eMax) {
|
|
263
|
+
return m ? NaN : (s ? -1 : 1) * Infinity;
|
|
264
|
+
} else {
|
|
265
|
+
m = m + Math.pow(2, mLen);
|
|
266
|
+
e = e - eBias;
|
|
267
|
+
}
|
|
268
|
+
return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
|
|
269
|
+
};
|
|
270
|
+
exports.write = function(buffer, value, offset, isLE2, mLen, nBytes) {
|
|
271
|
+
var e, m, c;
|
|
272
|
+
var eLen = nBytes * 8 - mLen - 1;
|
|
273
|
+
var eMax = (1 << eLen) - 1;
|
|
274
|
+
var eBias = eMax >> 1;
|
|
275
|
+
var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
|
|
276
|
+
var i = isLE2 ? 0 : nBytes - 1;
|
|
277
|
+
var d = isLE2 ? 1 : -1;
|
|
278
|
+
var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
|
|
279
|
+
value = Math.abs(value);
|
|
280
|
+
if (isNaN(value) || value === Infinity) {
|
|
281
|
+
m = isNaN(value) ? 1 : 0;
|
|
282
|
+
e = eMax;
|
|
283
|
+
} else {
|
|
284
|
+
e = Math.floor(Math.log(value) / Math.LN2);
|
|
285
|
+
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
286
|
+
e--;
|
|
287
|
+
c *= 2;
|
|
288
|
+
}
|
|
289
|
+
if (e + eBias >= 1) {
|
|
290
|
+
value += rt / c;
|
|
291
|
+
} else {
|
|
292
|
+
value += rt * Math.pow(2, 1 - eBias);
|
|
293
|
+
}
|
|
294
|
+
if (value * c >= 2) {
|
|
295
|
+
e++;
|
|
296
|
+
c /= 2;
|
|
297
|
+
}
|
|
298
|
+
if (e + eBias >= eMax) {
|
|
299
|
+
m = 0;
|
|
300
|
+
e = eMax;
|
|
301
|
+
} else if (e + eBias >= 1) {
|
|
302
|
+
m = (value * c - 1) * Math.pow(2, mLen);
|
|
303
|
+
e = e + eBias;
|
|
304
|
+
} else {
|
|
305
|
+
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
|
|
306
|
+
e = 0;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
|
|
310
|
+
}
|
|
311
|
+
e = e << mLen | m;
|
|
312
|
+
eLen += mLen;
|
|
313
|
+
for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
|
|
314
|
+
}
|
|
315
|
+
buffer[offset + i - d] |= s * 128;
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
// ../../node_modules/buffer/index.js
|
|
321
|
+
var require_buffer = __commonJS({
|
|
322
|
+
"../../node_modules/buffer/index.js"(exports) {
|
|
323
|
+
"use strict";
|
|
324
|
+
var base642 = require_base64_js();
|
|
325
|
+
var ieee754 = require_ieee754();
|
|
326
|
+
var customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
|
|
327
|
+
exports.Buffer = Buffer3;
|
|
328
|
+
exports.SlowBuffer = SlowBuffer;
|
|
329
|
+
exports.INSPECT_MAX_BYTES = 50;
|
|
330
|
+
var K_MAX_LENGTH = 2147483647;
|
|
331
|
+
exports.kMaxLength = K_MAX_LENGTH;
|
|
332
|
+
Buffer3.TYPED_ARRAY_SUPPORT = typedArraySupport();
|
|
333
|
+
if (!Buffer3.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") {
|
|
334
|
+
console.error(
|
|
335
|
+
"This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
function typedArraySupport() {
|
|
339
|
+
try {
|
|
340
|
+
const arr = new Uint8Array(1);
|
|
341
|
+
const proto = { foo: function() {
|
|
342
|
+
return 42;
|
|
343
|
+
} };
|
|
344
|
+
Object.setPrototypeOf(proto, Uint8Array.prototype);
|
|
345
|
+
Object.setPrototypeOf(arr, proto);
|
|
346
|
+
return arr.foo() === 42;
|
|
347
|
+
} catch (e) {
|
|
348
|
+
return false;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
Object.defineProperty(Buffer3.prototype, "parent", {
|
|
352
|
+
enumerable: true,
|
|
353
|
+
get: function() {
|
|
354
|
+
if (!Buffer3.isBuffer(this)) return void 0;
|
|
355
|
+
return this.buffer;
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
Object.defineProperty(Buffer3.prototype, "offset", {
|
|
359
|
+
enumerable: true,
|
|
360
|
+
get: function() {
|
|
361
|
+
if (!Buffer3.isBuffer(this)) return void 0;
|
|
362
|
+
return this.byteOffset;
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
function createBuffer(length) {
|
|
366
|
+
if (length > K_MAX_LENGTH) {
|
|
367
|
+
throw new RangeError('The value "' + length + '" is invalid for option "size"');
|
|
368
|
+
}
|
|
369
|
+
const buf = new Uint8Array(length);
|
|
370
|
+
Object.setPrototypeOf(buf, Buffer3.prototype);
|
|
371
|
+
return buf;
|
|
372
|
+
}
|
|
373
|
+
function Buffer3(arg, encodingOrOffset, length) {
|
|
374
|
+
if (typeof arg === "number") {
|
|
375
|
+
if (typeof encodingOrOffset === "string") {
|
|
376
|
+
throw new TypeError(
|
|
377
|
+
'The "string" argument must be of type string. Received type number'
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
return allocUnsafe(arg);
|
|
381
|
+
}
|
|
382
|
+
return from(arg, encodingOrOffset, length);
|
|
383
|
+
}
|
|
384
|
+
Buffer3.poolSize = 8192;
|
|
385
|
+
function from(value, encodingOrOffset, length) {
|
|
386
|
+
if (typeof value === "string") {
|
|
387
|
+
return fromString(value, encodingOrOffset);
|
|
388
|
+
}
|
|
389
|
+
if (ArrayBuffer.isView(value)) {
|
|
390
|
+
return fromArrayView(value);
|
|
391
|
+
}
|
|
392
|
+
if (value == null) {
|
|
393
|
+
throw new TypeError(
|
|
394
|
+
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) {
|
|
398
|
+
return fromArrayBuffer(value, encodingOrOffset, length);
|
|
399
|
+
}
|
|
400
|
+
if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) {
|
|
401
|
+
return fromArrayBuffer(value, encodingOrOffset, length);
|
|
402
|
+
}
|
|
403
|
+
if (typeof value === "number") {
|
|
404
|
+
throw new TypeError(
|
|
405
|
+
'The "value" argument must not be of type number. Received type number'
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
const valueOf = value.valueOf && value.valueOf();
|
|
409
|
+
if (valueOf != null && valueOf !== value) {
|
|
410
|
+
return Buffer3.from(valueOf, encodingOrOffset, length);
|
|
411
|
+
}
|
|
412
|
+
const b = fromObject(value);
|
|
413
|
+
if (b) return b;
|
|
414
|
+
if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") {
|
|
415
|
+
return Buffer3.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length);
|
|
416
|
+
}
|
|
417
|
+
throw new TypeError(
|
|
418
|
+
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
Buffer3.from = function(value, encodingOrOffset, length) {
|
|
422
|
+
return from(value, encodingOrOffset, length);
|
|
423
|
+
};
|
|
424
|
+
Object.setPrototypeOf(Buffer3.prototype, Uint8Array.prototype);
|
|
425
|
+
Object.setPrototypeOf(Buffer3, Uint8Array);
|
|
426
|
+
function assertSize(size2) {
|
|
427
|
+
if (typeof size2 !== "number") {
|
|
428
|
+
throw new TypeError('"size" argument must be of type number');
|
|
429
|
+
} else if (size2 < 0) {
|
|
430
|
+
throw new RangeError('The value "' + size2 + '" is invalid for option "size"');
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
function alloc(size2, fill, encoding) {
|
|
434
|
+
assertSize(size2);
|
|
435
|
+
if (size2 <= 0) {
|
|
436
|
+
return createBuffer(size2);
|
|
437
|
+
}
|
|
438
|
+
if (fill !== void 0) {
|
|
439
|
+
return typeof encoding === "string" ? createBuffer(size2).fill(fill, encoding) : createBuffer(size2).fill(fill);
|
|
440
|
+
}
|
|
441
|
+
return createBuffer(size2);
|
|
442
|
+
}
|
|
443
|
+
Buffer3.alloc = function(size2, fill, encoding) {
|
|
444
|
+
return alloc(size2, fill, encoding);
|
|
445
|
+
};
|
|
446
|
+
function allocUnsafe(size2) {
|
|
447
|
+
assertSize(size2);
|
|
448
|
+
return createBuffer(size2 < 0 ? 0 : checked(size2) | 0);
|
|
449
|
+
}
|
|
450
|
+
Buffer3.allocUnsafe = function(size2) {
|
|
451
|
+
return allocUnsafe(size2);
|
|
452
|
+
};
|
|
453
|
+
Buffer3.allocUnsafeSlow = function(size2) {
|
|
454
|
+
return allocUnsafe(size2);
|
|
455
|
+
};
|
|
456
|
+
function fromString(string2, encoding) {
|
|
457
|
+
if (typeof encoding !== "string" || encoding === "") {
|
|
458
|
+
encoding = "utf8";
|
|
459
|
+
}
|
|
460
|
+
if (!Buffer3.isEncoding(encoding)) {
|
|
461
|
+
throw new TypeError("Unknown encoding: " + encoding);
|
|
462
|
+
}
|
|
463
|
+
const length = byteLength(string2, encoding) | 0;
|
|
464
|
+
let buf = createBuffer(length);
|
|
465
|
+
const actual = buf.write(string2, encoding);
|
|
466
|
+
if (actual !== length) {
|
|
467
|
+
buf = buf.slice(0, actual);
|
|
468
|
+
}
|
|
469
|
+
return buf;
|
|
470
|
+
}
|
|
471
|
+
function fromArrayLike(array2) {
|
|
472
|
+
const length = array2.length < 0 ? 0 : checked(array2.length) | 0;
|
|
473
|
+
const buf = createBuffer(length);
|
|
474
|
+
for (let i = 0; i < length; i += 1) {
|
|
475
|
+
buf[i] = array2[i] & 255;
|
|
476
|
+
}
|
|
477
|
+
return buf;
|
|
478
|
+
}
|
|
479
|
+
function fromArrayView(arrayView) {
|
|
480
|
+
if (isInstance(arrayView, Uint8Array)) {
|
|
481
|
+
const copy = new Uint8Array(arrayView);
|
|
482
|
+
return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength);
|
|
483
|
+
}
|
|
484
|
+
return fromArrayLike(arrayView);
|
|
485
|
+
}
|
|
486
|
+
function fromArrayBuffer(array2, byteOffset, length) {
|
|
487
|
+
if (byteOffset < 0 || array2.byteLength < byteOffset) {
|
|
488
|
+
throw new RangeError('"offset" is outside of buffer bounds');
|
|
489
|
+
}
|
|
490
|
+
if (array2.byteLength < byteOffset + (length || 0)) {
|
|
491
|
+
throw new RangeError('"length" is outside of buffer bounds');
|
|
492
|
+
}
|
|
493
|
+
let buf;
|
|
494
|
+
if (byteOffset === void 0 && length === void 0) {
|
|
495
|
+
buf = new Uint8Array(array2);
|
|
496
|
+
} else if (length === void 0) {
|
|
497
|
+
buf = new Uint8Array(array2, byteOffset);
|
|
498
|
+
} else {
|
|
499
|
+
buf = new Uint8Array(array2, byteOffset, length);
|
|
500
|
+
}
|
|
501
|
+
Object.setPrototypeOf(buf, Buffer3.prototype);
|
|
502
|
+
return buf;
|
|
503
|
+
}
|
|
504
|
+
function fromObject(obj) {
|
|
505
|
+
if (Buffer3.isBuffer(obj)) {
|
|
506
|
+
const len = checked(obj.length) | 0;
|
|
507
|
+
const buf = createBuffer(len);
|
|
508
|
+
if (buf.length === 0) {
|
|
509
|
+
return buf;
|
|
510
|
+
}
|
|
511
|
+
obj.copy(buf, 0, 0, len);
|
|
512
|
+
return buf;
|
|
513
|
+
}
|
|
514
|
+
if (obj.length !== void 0) {
|
|
515
|
+
if (typeof obj.length !== "number" || numberIsNaN(obj.length)) {
|
|
516
|
+
return createBuffer(0);
|
|
517
|
+
}
|
|
518
|
+
return fromArrayLike(obj);
|
|
519
|
+
}
|
|
520
|
+
if (obj.type === "Buffer" && Array.isArray(obj.data)) {
|
|
521
|
+
return fromArrayLike(obj.data);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
function checked(length) {
|
|
525
|
+
if (length >= K_MAX_LENGTH) {
|
|
526
|
+
throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes");
|
|
527
|
+
}
|
|
528
|
+
return length | 0;
|
|
529
|
+
}
|
|
530
|
+
function SlowBuffer(length) {
|
|
531
|
+
if (+length != length) {
|
|
532
|
+
length = 0;
|
|
533
|
+
}
|
|
534
|
+
return Buffer3.alloc(+length);
|
|
535
|
+
}
|
|
536
|
+
Buffer3.isBuffer = function isBuffer(b) {
|
|
537
|
+
return b != null && b._isBuffer === true && b !== Buffer3.prototype;
|
|
538
|
+
};
|
|
539
|
+
Buffer3.compare = function compare(a, b) {
|
|
540
|
+
if (isInstance(a, Uint8Array)) a = Buffer3.from(a, a.offset, a.byteLength);
|
|
541
|
+
if (isInstance(b, Uint8Array)) b = Buffer3.from(b, b.offset, b.byteLength);
|
|
542
|
+
if (!Buffer3.isBuffer(a) || !Buffer3.isBuffer(b)) {
|
|
543
|
+
throw new TypeError(
|
|
544
|
+
'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
if (a === b) return 0;
|
|
548
|
+
let x = a.length;
|
|
549
|
+
let y = b.length;
|
|
550
|
+
for (let i = 0, len = Math.min(x, y); i < len; ++i) {
|
|
551
|
+
if (a[i] !== b[i]) {
|
|
552
|
+
x = a[i];
|
|
553
|
+
y = b[i];
|
|
554
|
+
break;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
if (x < y) return -1;
|
|
558
|
+
if (y < x) return 1;
|
|
559
|
+
return 0;
|
|
560
|
+
};
|
|
561
|
+
Buffer3.isEncoding = function isEncoding(encoding) {
|
|
562
|
+
switch (String(encoding).toLowerCase()) {
|
|
563
|
+
case "hex":
|
|
564
|
+
case "utf8":
|
|
565
|
+
case "utf-8":
|
|
566
|
+
case "ascii":
|
|
567
|
+
case "latin1":
|
|
568
|
+
case "binary":
|
|
569
|
+
case "base64":
|
|
570
|
+
case "ucs2":
|
|
571
|
+
case "ucs-2":
|
|
572
|
+
case "utf16le":
|
|
573
|
+
case "utf-16le":
|
|
574
|
+
return true;
|
|
575
|
+
default:
|
|
576
|
+
return false;
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
Buffer3.concat = function concat(list, length) {
|
|
580
|
+
if (!Array.isArray(list)) {
|
|
581
|
+
throw new TypeError('"list" argument must be an Array of Buffers');
|
|
582
|
+
}
|
|
583
|
+
if (list.length === 0) {
|
|
584
|
+
return Buffer3.alloc(0);
|
|
585
|
+
}
|
|
586
|
+
let i;
|
|
587
|
+
if (length === void 0) {
|
|
588
|
+
length = 0;
|
|
589
|
+
for (i = 0; i < list.length; ++i) {
|
|
590
|
+
length += list[i].length;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
const buffer = Buffer3.allocUnsafe(length);
|
|
594
|
+
let pos = 0;
|
|
595
|
+
for (i = 0; i < list.length; ++i) {
|
|
596
|
+
let buf = list[i];
|
|
597
|
+
if (isInstance(buf, Uint8Array)) {
|
|
598
|
+
if (pos + buf.length > buffer.length) {
|
|
599
|
+
if (!Buffer3.isBuffer(buf)) buf = Buffer3.from(buf);
|
|
600
|
+
buf.copy(buffer, pos);
|
|
601
|
+
} else {
|
|
602
|
+
Uint8Array.prototype.set.call(
|
|
603
|
+
buffer,
|
|
604
|
+
buf,
|
|
605
|
+
pos
|
|
606
|
+
);
|
|
607
|
+
}
|
|
608
|
+
} else if (!Buffer3.isBuffer(buf)) {
|
|
609
|
+
throw new TypeError('"list" argument must be an Array of Buffers');
|
|
610
|
+
} else {
|
|
611
|
+
buf.copy(buffer, pos);
|
|
612
|
+
}
|
|
613
|
+
pos += buf.length;
|
|
614
|
+
}
|
|
615
|
+
return buffer;
|
|
616
|
+
};
|
|
617
|
+
function byteLength(string2, encoding) {
|
|
618
|
+
if (Buffer3.isBuffer(string2)) {
|
|
619
|
+
return string2.length;
|
|
620
|
+
}
|
|
621
|
+
if (ArrayBuffer.isView(string2) || isInstance(string2, ArrayBuffer)) {
|
|
622
|
+
return string2.byteLength;
|
|
623
|
+
}
|
|
624
|
+
if (typeof string2 !== "string") {
|
|
625
|
+
throw new TypeError(
|
|
626
|
+
'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string2
|
|
627
|
+
);
|
|
628
|
+
}
|
|
629
|
+
const len = string2.length;
|
|
630
|
+
const mustMatch = arguments.length > 2 && arguments[2] === true;
|
|
631
|
+
if (!mustMatch && len === 0) return 0;
|
|
632
|
+
let loweredCase = false;
|
|
633
|
+
for (; ; ) {
|
|
634
|
+
switch (encoding) {
|
|
635
|
+
case "ascii":
|
|
636
|
+
case "latin1":
|
|
637
|
+
case "binary":
|
|
638
|
+
return len;
|
|
639
|
+
case "utf8":
|
|
640
|
+
case "utf-8":
|
|
641
|
+
return utf8ToBytes2(string2).length;
|
|
642
|
+
case "ucs2":
|
|
643
|
+
case "ucs-2":
|
|
644
|
+
case "utf16le":
|
|
645
|
+
case "utf-16le":
|
|
646
|
+
return len * 2;
|
|
647
|
+
case "hex":
|
|
648
|
+
return len >>> 1;
|
|
649
|
+
case "base64":
|
|
650
|
+
return base64ToBytes(string2).length;
|
|
651
|
+
default:
|
|
652
|
+
if (loweredCase) {
|
|
653
|
+
return mustMatch ? -1 : utf8ToBytes2(string2).length;
|
|
654
|
+
}
|
|
655
|
+
encoding = ("" + encoding).toLowerCase();
|
|
656
|
+
loweredCase = true;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
Buffer3.byteLength = byteLength;
|
|
661
|
+
function slowToString(encoding, start, end) {
|
|
662
|
+
let loweredCase = false;
|
|
663
|
+
if (start === void 0 || start < 0) {
|
|
664
|
+
start = 0;
|
|
665
|
+
}
|
|
666
|
+
if (start > this.length) {
|
|
667
|
+
return "";
|
|
668
|
+
}
|
|
669
|
+
if (end === void 0 || end > this.length) {
|
|
670
|
+
end = this.length;
|
|
671
|
+
}
|
|
672
|
+
if (end <= 0) {
|
|
673
|
+
return "";
|
|
674
|
+
}
|
|
675
|
+
end >>>= 0;
|
|
676
|
+
start >>>= 0;
|
|
677
|
+
if (end <= start) {
|
|
678
|
+
return "";
|
|
679
|
+
}
|
|
680
|
+
if (!encoding) encoding = "utf8";
|
|
681
|
+
while (true) {
|
|
682
|
+
switch (encoding) {
|
|
683
|
+
case "hex":
|
|
684
|
+
return hexSlice(this, start, end);
|
|
685
|
+
case "utf8":
|
|
686
|
+
case "utf-8":
|
|
687
|
+
return utf8Slice(this, start, end);
|
|
688
|
+
case "ascii":
|
|
689
|
+
return asciiSlice(this, start, end);
|
|
690
|
+
case "latin1":
|
|
691
|
+
case "binary":
|
|
692
|
+
return latin1Slice(this, start, end);
|
|
693
|
+
case "base64":
|
|
694
|
+
return base64Slice(this, start, end);
|
|
695
|
+
case "ucs2":
|
|
696
|
+
case "ucs-2":
|
|
697
|
+
case "utf16le":
|
|
698
|
+
case "utf-16le":
|
|
699
|
+
return utf16leSlice(this, start, end);
|
|
700
|
+
default:
|
|
701
|
+
if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
|
|
702
|
+
encoding = (encoding + "").toLowerCase();
|
|
703
|
+
loweredCase = true;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
Buffer3.prototype._isBuffer = true;
|
|
708
|
+
function swap(b, n, m) {
|
|
709
|
+
const i = b[n];
|
|
710
|
+
b[n] = b[m];
|
|
711
|
+
b[m] = i;
|
|
712
|
+
}
|
|
713
|
+
Buffer3.prototype.swap16 = function swap16() {
|
|
714
|
+
const len = this.length;
|
|
715
|
+
if (len % 2 !== 0) {
|
|
716
|
+
throw new RangeError("Buffer size must be a multiple of 16-bits");
|
|
717
|
+
}
|
|
718
|
+
for (let i = 0; i < len; i += 2) {
|
|
719
|
+
swap(this, i, i + 1);
|
|
720
|
+
}
|
|
721
|
+
return this;
|
|
722
|
+
};
|
|
723
|
+
Buffer3.prototype.swap32 = function swap32() {
|
|
724
|
+
const len = this.length;
|
|
725
|
+
if (len % 4 !== 0) {
|
|
726
|
+
throw new RangeError("Buffer size must be a multiple of 32-bits");
|
|
727
|
+
}
|
|
728
|
+
for (let i = 0; i < len; i += 4) {
|
|
729
|
+
swap(this, i, i + 3);
|
|
730
|
+
swap(this, i + 1, i + 2);
|
|
731
|
+
}
|
|
732
|
+
return this;
|
|
733
|
+
};
|
|
734
|
+
Buffer3.prototype.swap64 = function swap64() {
|
|
735
|
+
const len = this.length;
|
|
736
|
+
if (len % 8 !== 0) {
|
|
737
|
+
throw new RangeError("Buffer size must be a multiple of 64-bits");
|
|
738
|
+
}
|
|
739
|
+
for (let i = 0; i < len; i += 8) {
|
|
740
|
+
swap(this, i, i + 7);
|
|
741
|
+
swap(this, i + 1, i + 6);
|
|
742
|
+
swap(this, i + 2, i + 5);
|
|
743
|
+
swap(this, i + 3, i + 4);
|
|
744
|
+
}
|
|
745
|
+
return this;
|
|
746
|
+
};
|
|
747
|
+
Buffer3.prototype.toString = function toString2() {
|
|
748
|
+
const length = this.length;
|
|
749
|
+
if (length === 0) return "";
|
|
750
|
+
if (arguments.length === 0) return utf8Slice(this, 0, length);
|
|
751
|
+
return slowToString.apply(this, arguments);
|
|
752
|
+
};
|
|
753
|
+
Buffer3.prototype.toLocaleString = Buffer3.prototype.toString;
|
|
754
|
+
Buffer3.prototype.equals = function equals(b) {
|
|
755
|
+
if (!Buffer3.isBuffer(b)) throw new TypeError("Argument must be a Buffer");
|
|
756
|
+
if (this === b) return true;
|
|
757
|
+
return Buffer3.compare(this, b) === 0;
|
|
758
|
+
};
|
|
759
|
+
Buffer3.prototype.inspect = function inspect() {
|
|
760
|
+
let str = "";
|
|
761
|
+
const max = exports.INSPECT_MAX_BYTES;
|
|
762
|
+
str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim();
|
|
763
|
+
if (this.length > max) str += " ... ";
|
|
764
|
+
return "<Buffer " + str + ">";
|
|
765
|
+
};
|
|
766
|
+
if (customInspectSymbol) {
|
|
767
|
+
Buffer3.prototype[customInspectSymbol] = Buffer3.prototype.inspect;
|
|
768
|
+
}
|
|
769
|
+
Buffer3.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
|
|
770
|
+
if (isInstance(target, Uint8Array)) {
|
|
771
|
+
target = Buffer3.from(target, target.offset, target.byteLength);
|
|
772
|
+
}
|
|
773
|
+
if (!Buffer3.isBuffer(target)) {
|
|
774
|
+
throw new TypeError(
|
|
775
|
+
'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target
|
|
776
|
+
);
|
|
777
|
+
}
|
|
778
|
+
if (start === void 0) {
|
|
779
|
+
start = 0;
|
|
780
|
+
}
|
|
781
|
+
if (end === void 0) {
|
|
782
|
+
end = target ? target.length : 0;
|
|
783
|
+
}
|
|
784
|
+
if (thisStart === void 0) {
|
|
785
|
+
thisStart = 0;
|
|
786
|
+
}
|
|
787
|
+
if (thisEnd === void 0) {
|
|
788
|
+
thisEnd = this.length;
|
|
789
|
+
}
|
|
790
|
+
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
|
|
791
|
+
throw new RangeError("out of range index");
|
|
792
|
+
}
|
|
793
|
+
if (thisStart >= thisEnd && start >= end) {
|
|
794
|
+
return 0;
|
|
795
|
+
}
|
|
796
|
+
if (thisStart >= thisEnd) {
|
|
797
|
+
return -1;
|
|
798
|
+
}
|
|
799
|
+
if (start >= end) {
|
|
800
|
+
return 1;
|
|
801
|
+
}
|
|
802
|
+
start >>>= 0;
|
|
803
|
+
end >>>= 0;
|
|
804
|
+
thisStart >>>= 0;
|
|
805
|
+
thisEnd >>>= 0;
|
|
806
|
+
if (this === target) return 0;
|
|
807
|
+
let x = thisEnd - thisStart;
|
|
808
|
+
let y = end - start;
|
|
809
|
+
const len = Math.min(x, y);
|
|
810
|
+
const thisCopy = this.slice(thisStart, thisEnd);
|
|
811
|
+
const targetCopy = target.slice(start, end);
|
|
812
|
+
for (let i = 0; i < len; ++i) {
|
|
813
|
+
if (thisCopy[i] !== targetCopy[i]) {
|
|
814
|
+
x = thisCopy[i];
|
|
815
|
+
y = targetCopy[i];
|
|
816
|
+
break;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
if (x < y) return -1;
|
|
820
|
+
if (y < x) return 1;
|
|
821
|
+
return 0;
|
|
822
|
+
};
|
|
823
|
+
function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
|
|
824
|
+
if (buffer.length === 0) return -1;
|
|
825
|
+
if (typeof byteOffset === "string") {
|
|
826
|
+
encoding = byteOffset;
|
|
827
|
+
byteOffset = 0;
|
|
828
|
+
} else if (byteOffset > 2147483647) {
|
|
829
|
+
byteOffset = 2147483647;
|
|
830
|
+
} else if (byteOffset < -2147483648) {
|
|
831
|
+
byteOffset = -2147483648;
|
|
832
|
+
}
|
|
833
|
+
byteOffset = +byteOffset;
|
|
834
|
+
if (numberIsNaN(byteOffset)) {
|
|
835
|
+
byteOffset = dir ? 0 : buffer.length - 1;
|
|
836
|
+
}
|
|
837
|
+
if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
|
|
838
|
+
if (byteOffset >= buffer.length) {
|
|
839
|
+
if (dir) return -1;
|
|
840
|
+
else byteOffset = buffer.length - 1;
|
|
841
|
+
} else if (byteOffset < 0) {
|
|
842
|
+
if (dir) byteOffset = 0;
|
|
843
|
+
else return -1;
|
|
844
|
+
}
|
|
845
|
+
if (typeof val === "string") {
|
|
846
|
+
val = Buffer3.from(val, encoding);
|
|
847
|
+
}
|
|
848
|
+
if (Buffer3.isBuffer(val)) {
|
|
849
|
+
if (val.length === 0) {
|
|
850
|
+
return -1;
|
|
851
|
+
}
|
|
852
|
+
return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
|
|
853
|
+
} else if (typeof val === "number") {
|
|
854
|
+
val = val & 255;
|
|
855
|
+
if (typeof Uint8Array.prototype.indexOf === "function") {
|
|
856
|
+
if (dir) {
|
|
857
|
+
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
|
|
858
|
+
} else {
|
|
859
|
+
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
|
|
863
|
+
}
|
|
864
|
+
throw new TypeError("val must be string, number or Buffer");
|
|
865
|
+
}
|
|
866
|
+
function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
|
|
867
|
+
let indexSize = 1;
|
|
868
|
+
let arrLength = arr.length;
|
|
869
|
+
let valLength = val.length;
|
|
870
|
+
if (encoding !== void 0) {
|
|
871
|
+
encoding = String(encoding).toLowerCase();
|
|
872
|
+
if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
|
|
873
|
+
if (arr.length < 2 || val.length < 2) {
|
|
874
|
+
return -1;
|
|
875
|
+
}
|
|
876
|
+
indexSize = 2;
|
|
877
|
+
arrLength /= 2;
|
|
878
|
+
valLength /= 2;
|
|
879
|
+
byteOffset /= 2;
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
function read(buf, i2) {
|
|
883
|
+
if (indexSize === 1) {
|
|
884
|
+
return buf[i2];
|
|
885
|
+
} else {
|
|
886
|
+
return buf.readUInt16BE(i2 * indexSize);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
let i;
|
|
890
|
+
if (dir) {
|
|
891
|
+
let foundIndex = -1;
|
|
892
|
+
for (i = byteOffset; i < arrLength; i++) {
|
|
893
|
+
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
|
894
|
+
if (foundIndex === -1) foundIndex = i;
|
|
895
|
+
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
|
|
896
|
+
} else {
|
|
897
|
+
if (foundIndex !== -1) i -= i - foundIndex;
|
|
898
|
+
foundIndex = -1;
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
} else {
|
|
902
|
+
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
|
|
903
|
+
for (i = byteOffset; i >= 0; i--) {
|
|
904
|
+
let found = true;
|
|
905
|
+
for (let j = 0; j < valLength; j++) {
|
|
906
|
+
if (read(arr, i + j) !== read(val, j)) {
|
|
907
|
+
found = false;
|
|
908
|
+
break;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
if (found) return i;
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
return -1;
|
|
915
|
+
}
|
|
916
|
+
Buffer3.prototype.includes = function includes(val, byteOffset, encoding) {
|
|
917
|
+
return this.indexOf(val, byteOffset, encoding) !== -1;
|
|
918
|
+
};
|
|
919
|
+
Buffer3.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
|
|
920
|
+
return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
|
|
921
|
+
};
|
|
922
|
+
Buffer3.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
|
|
923
|
+
return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
|
|
924
|
+
};
|
|
925
|
+
function hexWrite(buf, string2, offset, length) {
|
|
926
|
+
offset = Number(offset) || 0;
|
|
927
|
+
const remaining = buf.length - offset;
|
|
928
|
+
if (!length) {
|
|
929
|
+
length = remaining;
|
|
930
|
+
} else {
|
|
931
|
+
length = Number(length);
|
|
932
|
+
if (length > remaining) {
|
|
933
|
+
length = remaining;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
const strLen = string2.length;
|
|
937
|
+
if (length > strLen / 2) {
|
|
938
|
+
length = strLen / 2;
|
|
939
|
+
}
|
|
940
|
+
let i;
|
|
941
|
+
for (i = 0; i < length; ++i) {
|
|
942
|
+
const parsed = parseInt(string2.substr(i * 2, 2), 16);
|
|
943
|
+
if (numberIsNaN(parsed)) return i;
|
|
944
|
+
buf[offset + i] = parsed;
|
|
945
|
+
}
|
|
946
|
+
return i;
|
|
947
|
+
}
|
|
948
|
+
function utf8Write(buf, string2, offset, length) {
|
|
949
|
+
return blitBuffer(utf8ToBytes2(string2, buf.length - offset), buf, offset, length);
|
|
950
|
+
}
|
|
951
|
+
function asciiWrite(buf, string2, offset, length) {
|
|
952
|
+
return blitBuffer(asciiToBytes(string2), buf, offset, length);
|
|
953
|
+
}
|
|
954
|
+
function base64Write(buf, string2, offset, length) {
|
|
955
|
+
return blitBuffer(base64ToBytes(string2), buf, offset, length);
|
|
956
|
+
}
|
|
957
|
+
function ucs2Write(buf, string2, offset, length) {
|
|
958
|
+
return blitBuffer(utf16leToBytes(string2, buf.length - offset), buf, offset, length);
|
|
959
|
+
}
|
|
960
|
+
Buffer3.prototype.write = function write(string2, offset, length, encoding) {
|
|
961
|
+
if (offset === void 0) {
|
|
962
|
+
encoding = "utf8";
|
|
963
|
+
length = this.length;
|
|
964
|
+
offset = 0;
|
|
965
|
+
} else if (length === void 0 && typeof offset === "string") {
|
|
966
|
+
encoding = offset;
|
|
967
|
+
length = this.length;
|
|
968
|
+
offset = 0;
|
|
969
|
+
} else if (isFinite(offset)) {
|
|
970
|
+
offset = offset >>> 0;
|
|
971
|
+
if (isFinite(length)) {
|
|
972
|
+
length = length >>> 0;
|
|
973
|
+
if (encoding === void 0) encoding = "utf8";
|
|
974
|
+
} else {
|
|
975
|
+
encoding = length;
|
|
976
|
+
length = void 0;
|
|
977
|
+
}
|
|
978
|
+
} else {
|
|
979
|
+
throw new Error(
|
|
980
|
+
"Buffer.write(string, encoding, offset[, length]) is no longer supported"
|
|
981
|
+
);
|
|
982
|
+
}
|
|
983
|
+
const remaining = this.length - offset;
|
|
984
|
+
if (length === void 0 || length > remaining) length = remaining;
|
|
985
|
+
if (string2.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
|
|
986
|
+
throw new RangeError("Attempt to write outside buffer bounds");
|
|
987
|
+
}
|
|
988
|
+
if (!encoding) encoding = "utf8";
|
|
989
|
+
let loweredCase = false;
|
|
990
|
+
for (; ; ) {
|
|
991
|
+
switch (encoding) {
|
|
992
|
+
case "hex":
|
|
993
|
+
return hexWrite(this, string2, offset, length);
|
|
994
|
+
case "utf8":
|
|
995
|
+
case "utf-8":
|
|
996
|
+
return utf8Write(this, string2, offset, length);
|
|
997
|
+
case "ascii":
|
|
998
|
+
case "latin1":
|
|
999
|
+
case "binary":
|
|
1000
|
+
return asciiWrite(this, string2, offset, length);
|
|
1001
|
+
case "base64":
|
|
1002
|
+
return base64Write(this, string2, offset, length);
|
|
1003
|
+
case "ucs2":
|
|
1004
|
+
case "ucs-2":
|
|
1005
|
+
case "utf16le":
|
|
1006
|
+
case "utf-16le":
|
|
1007
|
+
return ucs2Write(this, string2, offset, length);
|
|
1008
|
+
default:
|
|
1009
|
+
if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
|
|
1010
|
+
encoding = ("" + encoding).toLowerCase();
|
|
1011
|
+
loweredCase = true;
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
};
|
|
1015
|
+
Buffer3.prototype.toJSON = function toJSON() {
|
|
1016
|
+
return {
|
|
1017
|
+
type: "Buffer",
|
|
1018
|
+
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
1019
|
+
};
|
|
1020
|
+
};
|
|
1021
|
+
function base64Slice(buf, start, end) {
|
|
1022
|
+
if (start === 0 && end === buf.length) {
|
|
1023
|
+
return base642.fromByteArray(buf);
|
|
1024
|
+
} else {
|
|
1025
|
+
return base642.fromByteArray(buf.slice(start, end));
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
function utf8Slice(buf, start, end) {
|
|
1029
|
+
end = Math.min(buf.length, end);
|
|
1030
|
+
const res = [];
|
|
1031
|
+
let i = start;
|
|
1032
|
+
while (i < end) {
|
|
1033
|
+
const firstByte = buf[i];
|
|
1034
|
+
let codePoint = null;
|
|
1035
|
+
let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
|
|
1036
|
+
if (i + bytesPerSequence <= end) {
|
|
1037
|
+
let secondByte, thirdByte, fourthByte, tempCodePoint;
|
|
1038
|
+
switch (bytesPerSequence) {
|
|
1039
|
+
case 1:
|
|
1040
|
+
if (firstByte < 128) {
|
|
1041
|
+
codePoint = firstByte;
|
|
1042
|
+
}
|
|
1043
|
+
break;
|
|
1044
|
+
case 2:
|
|
1045
|
+
secondByte = buf[i + 1];
|
|
1046
|
+
if ((secondByte & 192) === 128) {
|
|
1047
|
+
tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
|
|
1048
|
+
if (tempCodePoint > 127) {
|
|
1049
|
+
codePoint = tempCodePoint;
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
break;
|
|
1053
|
+
case 3:
|
|
1054
|
+
secondByte = buf[i + 1];
|
|
1055
|
+
thirdByte = buf[i + 2];
|
|
1056
|
+
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
|
|
1057
|
+
tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
|
|
1058
|
+
if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) {
|
|
1059
|
+
codePoint = tempCodePoint;
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
break;
|
|
1063
|
+
case 4:
|
|
1064
|
+
secondByte = buf[i + 1];
|
|
1065
|
+
thirdByte = buf[i + 2];
|
|
1066
|
+
fourthByte = buf[i + 3];
|
|
1067
|
+
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
|
|
1068
|
+
tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
|
|
1069
|
+
if (tempCodePoint > 65535 && tempCodePoint < 1114112) {
|
|
1070
|
+
codePoint = tempCodePoint;
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
if (codePoint === null) {
|
|
1076
|
+
codePoint = 65533;
|
|
1077
|
+
bytesPerSequence = 1;
|
|
1078
|
+
} else if (codePoint > 65535) {
|
|
1079
|
+
codePoint -= 65536;
|
|
1080
|
+
res.push(codePoint >>> 10 & 1023 | 55296);
|
|
1081
|
+
codePoint = 56320 | codePoint & 1023;
|
|
1082
|
+
}
|
|
1083
|
+
res.push(codePoint);
|
|
1084
|
+
i += bytesPerSequence;
|
|
1085
|
+
}
|
|
1086
|
+
return decodeCodePointsArray(res);
|
|
1087
|
+
}
|
|
1088
|
+
var MAX_ARGUMENTS_LENGTH = 4096;
|
|
1089
|
+
function decodeCodePointsArray(codePoints) {
|
|
1090
|
+
const len = codePoints.length;
|
|
1091
|
+
if (len <= MAX_ARGUMENTS_LENGTH) {
|
|
1092
|
+
return String.fromCharCode.apply(String, codePoints);
|
|
1093
|
+
}
|
|
1094
|
+
let res = "";
|
|
1095
|
+
let i = 0;
|
|
1096
|
+
while (i < len) {
|
|
1097
|
+
res += String.fromCharCode.apply(
|
|
1098
|
+
String,
|
|
1099
|
+
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
|
1100
|
+
);
|
|
1101
|
+
}
|
|
1102
|
+
return res;
|
|
1103
|
+
}
|
|
1104
|
+
function asciiSlice(buf, start, end) {
|
|
1105
|
+
let ret = "";
|
|
1106
|
+
end = Math.min(buf.length, end);
|
|
1107
|
+
for (let i = start; i < end; ++i) {
|
|
1108
|
+
ret += String.fromCharCode(buf[i] & 127);
|
|
1109
|
+
}
|
|
1110
|
+
return ret;
|
|
1111
|
+
}
|
|
1112
|
+
function latin1Slice(buf, start, end) {
|
|
1113
|
+
let ret = "";
|
|
1114
|
+
end = Math.min(buf.length, end);
|
|
1115
|
+
for (let i = start; i < end; ++i) {
|
|
1116
|
+
ret += String.fromCharCode(buf[i]);
|
|
1117
|
+
}
|
|
1118
|
+
return ret;
|
|
1119
|
+
}
|
|
1120
|
+
function hexSlice(buf, start, end) {
|
|
1121
|
+
const len = buf.length;
|
|
1122
|
+
if (!start || start < 0) start = 0;
|
|
1123
|
+
if (!end || end < 0 || end > len) end = len;
|
|
1124
|
+
let out = "";
|
|
1125
|
+
for (let i = start; i < end; ++i) {
|
|
1126
|
+
out += hexSliceLookupTable[buf[i]];
|
|
1127
|
+
}
|
|
1128
|
+
return out;
|
|
1129
|
+
}
|
|
1130
|
+
function utf16leSlice(buf, start, end) {
|
|
1131
|
+
const bytes = buf.slice(start, end);
|
|
1132
|
+
let res = "";
|
|
1133
|
+
for (let i = 0; i < bytes.length - 1; i += 2) {
|
|
1134
|
+
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
|
|
1135
|
+
}
|
|
1136
|
+
return res;
|
|
1137
|
+
}
|
|
1138
|
+
Buffer3.prototype.slice = function slice(start, end) {
|
|
1139
|
+
const len = this.length;
|
|
1140
|
+
start = ~~start;
|
|
1141
|
+
end = end === void 0 ? len : ~~end;
|
|
1142
|
+
if (start < 0) {
|
|
1143
|
+
start += len;
|
|
1144
|
+
if (start < 0) start = 0;
|
|
1145
|
+
} else if (start > len) {
|
|
1146
|
+
start = len;
|
|
1147
|
+
}
|
|
1148
|
+
if (end < 0) {
|
|
1149
|
+
end += len;
|
|
1150
|
+
if (end < 0) end = 0;
|
|
1151
|
+
} else if (end > len) {
|
|
1152
|
+
end = len;
|
|
1153
|
+
}
|
|
1154
|
+
if (end < start) end = start;
|
|
1155
|
+
const newBuf = this.subarray(start, end);
|
|
1156
|
+
Object.setPrototypeOf(newBuf, Buffer3.prototype);
|
|
1157
|
+
return newBuf;
|
|
1158
|
+
};
|
|
1159
|
+
function checkOffset(offset, ext, length) {
|
|
1160
|
+
if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint");
|
|
1161
|
+
if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length");
|
|
1162
|
+
}
|
|
1163
|
+
Buffer3.prototype.readUintLE = Buffer3.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) {
|
|
1164
|
+
offset = offset >>> 0;
|
|
1165
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1166
|
+
if (!noAssert) checkOffset(offset, byteLength2, this.length);
|
|
1167
|
+
let val = this[offset];
|
|
1168
|
+
let mul = 1;
|
|
1169
|
+
let i = 0;
|
|
1170
|
+
while (++i < byteLength2 && (mul *= 256)) {
|
|
1171
|
+
val += this[offset + i] * mul;
|
|
1172
|
+
}
|
|
1173
|
+
return val;
|
|
1174
|
+
};
|
|
1175
|
+
Buffer3.prototype.readUintBE = Buffer3.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) {
|
|
1176
|
+
offset = offset >>> 0;
|
|
1177
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1178
|
+
if (!noAssert) {
|
|
1179
|
+
checkOffset(offset, byteLength2, this.length);
|
|
1180
|
+
}
|
|
1181
|
+
let val = this[offset + --byteLength2];
|
|
1182
|
+
let mul = 1;
|
|
1183
|
+
while (byteLength2 > 0 && (mul *= 256)) {
|
|
1184
|
+
val += this[offset + --byteLength2] * mul;
|
|
1185
|
+
}
|
|
1186
|
+
return val;
|
|
1187
|
+
};
|
|
1188
|
+
Buffer3.prototype.readUint8 = Buffer3.prototype.readUInt8 = function readUInt8(offset, noAssert) {
|
|
1189
|
+
offset = offset >>> 0;
|
|
1190
|
+
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
1191
|
+
return this[offset];
|
|
1192
|
+
};
|
|
1193
|
+
Buffer3.prototype.readUint16LE = Buffer3.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
|
|
1194
|
+
offset = offset >>> 0;
|
|
1195
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1196
|
+
return this[offset] | this[offset + 1] << 8;
|
|
1197
|
+
};
|
|
1198
|
+
Buffer3.prototype.readUint16BE = Buffer3.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
|
|
1199
|
+
offset = offset >>> 0;
|
|
1200
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1201
|
+
return this[offset] << 8 | this[offset + 1];
|
|
1202
|
+
};
|
|
1203
|
+
Buffer3.prototype.readUint32LE = Buffer3.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
|
|
1204
|
+
offset = offset >>> 0;
|
|
1205
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1206
|
+
return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
|
|
1207
|
+
};
|
|
1208
|
+
Buffer3.prototype.readUint32BE = Buffer3.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
|
|
1209
|
+
offset = offset >>> 0;
|
|
1210
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1211
|
+
return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
|
|
1212
|
+
};
|
|
1213
|
+
Buffer3.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) {
|
|
1214
|
+
offset = offset >>> 0;
|
|
1215
|
+
validateNumber(offset, "offset");
|
|
1216
|
+
const first = this[offset];
|
|
1217
|
+
const last = this[offset + 7];
|
|
1218
|
+
if (first === void 0 || last === void 0) {
|
|
1219
|
+
boundsError(offset, this.length - 8);
|
|
1220
|
+
}
|
|
1221
|
+
const lo = first + this[++offset] * __pow(2, 8) + this[++offset] * __pow(2, 16) + this[++offset] * __pow(2, 24);
|
|
1222
|
+
const hi = this[++offset] + this[++offset] * __pow(2, 8) + this[++offset] * __pow(2, 16) + last * __pow(2, 24);
|
|
1223
|
+
return BigInt(lo) + (BigInt(hi) << BigInt(32));
|
|
1224
|
+
});
|
|
1225
|
+
Buffer3.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) {
|
|
1226
|
+
offset = offset >>> 0;
|
|
1227
|
+
validateNumber(offset, "offset");
|
|
1228
|
+
const first = this[offset];
|
|
1229
|
+
const last = this[offset + 7];
|
|
1230
|
+
if (first === void 0 || last === void 0) {
|
|
1231
|
+
boundsError(offset, this.length - 8);
|
|
1232
|
+
}
|
|
1233
|
+
const hi = first * __pow(2, 24) + this[++offset] * __pow(2, 16) + this[++offset] * __pow(2, 8) + this[++offset];
|
|
1234
|
+
const lo = this[++offset] * __pow(2, 24) + this[++offset] * __pow(2, 16) + this[++offset] * __pow(2, 8) + last;
|
|
1235
|
+
return (BigInt(hi) << BigInt(32)) + BigInt(lo);
|
|
1236
|
+
});
|
|
1237
|
+
Buffer3.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) {
|
|
1238
|
+
offset = offset >>> 0;
|
|
1239
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1240
|
+
if (!noAssert) checkOffset(offset, byteLength2, this.length);
|
|
1241
|
+
let val = this[offset];
|
|
1242
|
+
let mul = 1;
|
|
1243
|
+
let i = 0;
|
|
1244
|
+
while (++i < byteLength2 && (mul *= 256)) {
|
|
1245
|
+
val += this[offset + i] * mul;
|
|
1246
|
+
}
|
|
1247
|
+
mul *= 128;
|
|
1248
|
+
if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
|
|
1249
|
+
return val;
|
|
1250
|
+
};
|
|
1251
|
+
Buffer3.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) {
|
|
1252
|
+
offset = offset >>> 0;
|
|
1253
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1254
|
+
if (!noAssert) checkOffset(offset, byteLength2, this.length);
|
|
1255
|
+
let i = byteLength2;
|
|
1256
|
+
let mul = 1;
|
|
1257
|
+
let val = this[offset + --i];
|
|
1258
|
+
while (i > 0 && (mul *= 256)) {
|
|
1259
|
+
val += this[offset + --i] * mul;
|
|
1260
|
+
}
|
|
1261
|
+
mul *= 128;
|
|
1262
|
+
if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
|
|
1263
|
+
return val;
|
|
1264
|
+
};
|
|
1265
|
+
Buffer3.prototype.readInt8 = function readInt8(offset, noAssert) {
|
|
1266
|
+
offset = offset >>> 0;
|
|
1267
|
+
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
1268
|
+
if (!(this[offset] & 128)) return this[offset];
|
|
1269
|
+
return (255 - this[offset] + 1) * -1;
|
|
1270
|
+
};
|
|
1271
|
+
Buffer3.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
|
|
1272
|
+
offset = offset >>> 0;
|
|
1273
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1274
|
+
const val = this[offset] | this[offset + 1] << 8;
|
|
1275
|
+
return val & 32768 ? val | 4294901760 : val;
|
|
1276
|
+
};
|
|
1277
|
+
Buffer3.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
|
|
1278
|
+
offset = offset >>> 0;
|
|
1279
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1280
|
+
const val = this[offset + 1] | this[offset] << 8;
|
|
1281
|
+
return val & 32768 ? val | 4294901760 : val;
|
|
1282
|
+
};
|
|
1283
|
+
Buffer3.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
|
|
1284
|
+
offset = offset >>> 0;
|
|
1285
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1286
|
+
return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
|
|
1287
|
+
};
|
|
1288
|
+
Buffer3.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
|
|
1289
|
+
offset = offset >>> 0;
|
|
1290
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1291
|
+
return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
|
|
1292
|
+
};
|
|
1293
|
+
Buffer3.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) {
|
|
1294
|
+
offset = offset >>> 0;
|
|
1295
|
+
validateNumber(offset, "offset");
|
|
1296
|
+
const first = this[offset];
|
|
1297
|
+
const last = this[offset + 7];
|
|
1298
|
+
if (first === void 0 || last === void 0) {
|
|
1299
|
+
boundsError(offset, this.length - 8);
|
|
1300
|
+
}
|
|
1301
|
+
const val = this[offset + 4] + this[offset + 5] * __pow(2, 8) + this[offset + 6] * __pow(2, 16) + (last << 24);
|
|
1302
|
+
return (BigInt(val) << BigInt(32)) + BigInt(first + this[++offset] * __pow(2, 8) + this[++offset] * __pow(2, 16) + this[++offset] * __pow(2, 24));
|
|
1303
|
+
});
|
|
1304
|
+
Buffer3.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) {
|
|
1305
|
+
offset = offset >>> 0;
|
|
1306
|
+
validateNumber(offset, "offset");
|
|
1307
|
+
const first = this[offset];
|
|
1308
|
+
const last = this[offset + 7];
|
|
1309
|
+
if (first === void 0 || last === void 0) {
|
|
1310
|
+
boundsError(offset, this.length - 8);
|
|
1311
|
+
}
|
|
1312
|
+
const val = (first << 24) + // Overflow
|
|
1313
|
+
this[++offset] * __pow(2, 16) + this[++offset] * __pow(2, 8) + this[++offset];
|
|
1314
|
+
return (BigInt(val) << BigInt(32)) + BigInt(this[++offset] * __pow(2, 24) + this[++offset] * __pow(2, 16) + this[++offset] * __pow(2, 8) + last);
|
|
1315
|
+
});
|
|
1316
|
+
Buffer3.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
|
|
1317
|
+
offset = offset >>> 0;
|
|
1318
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1319
|
+
return ieee754.read(this, offset, true, 23, 4);
|
|
1320
|
+
};
|
|
1321
|
+
Buffer3.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
|
|
1322
|
+
offset = offset >>> 0;
|
|
1323
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1324
|
+
return ieee754.read(this, offset, false, 23, 4);
|
|
1325
|
+
};
|
|
1326
|
+
Buffer3.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
|
|
1327
|
+
offset = offset >>> 0;
|
|
1328
|
+
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
1329
|
+
return ieee754.read(this, offset, true, 52, 8);
|
|
1330
|
+
};
|
|
1331
|
+
Buffer3.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
|
|
1332
|
+
offset = offset >>> 0;
|
|
1333
|
+
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
1334
|
+
return ieee754.read(this, offset, false, 52, 8);
|
|
1335
|
+
};
|
|
1336
|
+
function checkInt(buf, value, offset, ext, max, min) {
|
|
1337
|
+
if (!Buffer3.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance');
|
|
1338
|
+
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds');
|
|
1339
|
+
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
|
1340
|
+
}
|
|
1341
|
+
Buffer3.prototype.writeUintLE = Buffer3.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) {
|
|
1342
|
+
value = +value;
|
|
1343
|
+
offset = offset >>> 0;
|
|
1344
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1345
|
+
if (!noAssert) {
|
|
1346
|
+
const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
|
|
1347
|
+
checkInt(this, value, offset, byteLength2, maxBytes, 0);
|
|
1348
|
+
}
|
|
1349
|
+
let mul = 1;
|
|
1350
|
+
let i = 0;
|
|
1351
|
+
this[offset] = value & 255;
|
|
1352
|
+
while (++i < byteLength2 && (mul *= 256)) {
|
|
1353
|
+
this[offset + i] = value / mul & 255;
|
|
1354
|
+
}
|
|
1355
|
+
return offset + byteLength2;
|
|
1356
|
+
};
|
|
1357
|
+
Buffer3.prototype.writeUintBE = Buffer3.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) {
|
|
1358
|
+
value = +value;
|
|
1359
|
+
offset = offset >>> 0;
|
|
1360
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1361
|
+
if (!noAssert) {
|
|
1362
|
+
const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
|
|
1363
|
+
checkInt(this, value, offset, byteLength2, maxBytes, 0);
|
|
1364
|
+
}
|
|
1365
|
+
let i = byteLength2 - 1;
|
|
1366
|
+
let mul = 1;
|
|
1367
|
+
this[offset + i] = value & 255;
|
|
1368
|
+
while (--i >= 0 && (mul *= 256)) {
|
|
1369
|
+
this[offset + i] = value / mul & 255;
|
|
1370
|
+
}
|
|
1371
|
+
return offset + byteLength2;
|
|
1372
|
+
};
|
|
1373
|
+
Buffer3.prototype.writeUint8 = Buffer3.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
|
|
1374
|
+
value = +value;
|
|
1375
|
+
offset = offset >>> 0;
|
|
1376
|
+
if (!noAssert) checkInt(this, value, offset, 1, 255, 0);
|
|
1377
|
+
this[offset] = value & 255;
|
|
1378
|
+
return offset + 1;
|
|
1379
|
+
};
|
|
1380
|
+
Buffer3.prototype.writeUint16LE = Buffer3.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
|
|
1381
|
+
value = +value;
|
|
1382
|
+
offset = offset >>> 0;
|
|
1383
|
+
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
|
|
1384
|
+
this[offset] = value & 255;
|
|
1385
|
+
this[offset + 1] = value >>> 8;
|
|
1386
|
+
return offset + 2;
|
|
1387
|
+
};
|
|
1388
|
+
Buffer3.prototype.writeUint16BE = Buffer3.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
|
|
1389
|
+
value = +value;
|
|
1390
|
+
offset = offset >>> 0;
|
|
1391
|
+
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
|
|
1392
|
+
this[offset] = value >>> 8;
|
|
1393
|
+
this[offset + 1] = value & 255;
|
|
1394
|
+
return offset + 2;
|
|
1395
|
+
};
|
|
1396
|
+
Buffer3.prototype.writeUint32LE = Buffer3.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
|
|
1397
|
+
value = +value;
|
|
1398
|
+
offset = offset >>> 0;
|
|
1399
|
+
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
|
|
1400
|
+
this[offset + 3] = value >>> 24;
|
|
1401
|
+
this[offset + 2] = value >>> 16;
|
|
1402
|
+
this[offset + 1] = value >>> 8;
|
|
1403
|
+
this[offset] = value & 255;
|
|
1404
|
+
return offset + 4;
|
|
1405
|
+
};
|
|
1406
|
+
Buffer3.prototype.writeUint32BE = Buffer3.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
|
|
1407
|
+
value = +value;
|
|
1408
|
+
offset = offset >>> 0;
|
|
1409
|
+
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
|
|
1410
|
+
this[offset] = value >>> 24;
|
|
1411
|
+
this[offset + 1] = value >>> 16;
|
|
1412
|
+
this[offset + 2] = value >>> 8;
|
|
1413
|
+
this[offset + 3] = value & 255;
|
|
1414
|
+
return offset + 4;
|
|
1415
|
+
};
|
|
1416
|
+
function wrtBigUInt64LE(buf, value, offset, min, max) {
|
|
1417
|
+
checkIntBI(value, min, max, buf, offset, 7);
|
|
1418
|
+
let lo = Number(value & BigInt(4294967295));
|
|
1419
|
+
buf[offset++] = lo;
|
|
1420
|
+
lo = lo >> 8;
|
|
1421
|
+
buf[offset++] = lo;
|
|
1422
|
+
lo = lo >> 8;
|
|
1423
|
+
buf[offset++] = lo;
|
|
1424
|
+
lo = lo >> 8;
|
|
1425
|
+
buf[offset++] = lo;
|
|
1426
|
+
let hi = Number(value >> BigInt(32) & BigInt(4294967295));
|
|
1427
|
+
buf[offset++] = hi;
|
|
1428
|
+
hi = hi >> 8;
|
|
1429
|
+
buf[offset++] = hi;
|
|
1430
|
+
hi = hi >> 8;
|
|
1431
|
+
buf[offset++] = hi;
|
|
1432
|
+
hi = hi >> 8;
|
|
1433
|
+
buf[offset++] = hi;
|
|
1434
|
+
return offset;
|
|
1435
|
+
}
|
|
1436
|
+
function wrtBigUInt64BE(buf, value, offset, min, max) {
|
|
1437
|
+
checkIntBI(value, min, max, buf, offset, 7);
|
|
1438
|
+
let lo = Number(value & BigInt(4294967295));
|
|
1439
|
+
buf[offset + 7] = lo;
|
|
1440
|
+
lo = lo >> 8;
|
|
1441
|
+
buf[offset + 6] = lo;
|
|
1442
|
+
lo = lo >> 8;
|
|
1443
|
+
buf[offset + 5] = lo;
|
|
1444
|
+
lo = lo >> 8;
|
|
1445
|
+
buf[offset + 4] = lo;
|
|
1446
|
+
let hi = Number(value >> BigInt(32) & BigInt(4294967295));
|
|
1447
|
+
buf[offset + 3] = hi;
|
|
1448
|
+
hi = hi >> 8;
|
|
1449
|
+
buf[offset + 2] = hi;
|
|
1450
|
+
hi = hi >> 8;
|
|
1451
|
+
buf[offset + 1] = hi;
|
|
1452
|
+
hi = hi >> 8;
|
|
1453
|
+
buf[offset] = hi;
|
|
1454
|
+
return offset + 8;
|
|
1455
|
+
}
|
|
1456
|
+
Buffer3.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) {
|
|
1457
|
+
return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
|
|
1458
|
+
});
|
|
1459
|
+
Buffer3.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) {
|
|
1460
|
+
return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
|
|
1461
|
+
});
|
|
1462
|
+
Buffer3.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) {
|
|
1463
|
+
value = +value;
|
|
1464
|
+
offset = offset >>> 0;
|
|
1465
|
+
if (!noAssert) {
|
|
1466
|
+
const limit = Math.pow(2, 8 * byteLength2 - 1);
|
|
1467
|
+
checkInt(this, value, offset, byteLength2, limit - 1, -limit);
|
|
1468
|
+
}
|
|
1469
|
+
let i = 0;
|
|
1470
|
+
let mul = 1;
|
|
1471
|
+
let sub = 0;
|
|
1472
|
+
this[offset] = value & 255;
|
|
1473
|
+
while (++i < byteLength2 && (mul *= 256)) {
|
|
1474
|
+
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
|
1475
|
+
sub = 1;
|
|
1476
|
+
}
|
|
1477
|
+
this[offset + i] = (value / mul >> 0) - sub & 255;
|
|
1478
|
+
}
|
|
1479
|
+
return offset + byteLength2;
|
|
1480
|
+
};
|
|
1481
|
+
Buffer3.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) {
|
|
1482
|
+
value = +value;
|
|
1483
|
+
offset = offset >>> 0;
|
|
1484
|
+
if (!noAssert) {
|
|
1485
|
+
const limit = Math.pow(2, 8 * byteLength2 - 1);
|
|
1486
|
+
checkInt(this, value, offset, byteLength2, limit - 1, -limit);
|
|
1487
|
+
}
|
|
1488
|
+
let i = byteLength2 - 1;
|
|
1489
|
+
let mul = 1;
|
|
1490
|
+
let sub = 0;
|
|
1491
|
+
this[offset + i] = value & 255;
|
|
1492
|
+
while (--i >= 0 && (mul *= 256)) {
|
|
1493
|
+
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
|
1494
|
+
sub = 1;
|
|
1495
|
+
}
|
|
1496
|
+
this[offset + i] = (value / mul >> 0) - sub & 255;
|
|
1497
|
+
}
|
|
1498
|
+
return offset + byteLength2;
|
|
1499
|
+
};
|
|
1500
|
+
Buffer3.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
|
|
1501
|
+
value = +value;
|
|
1502
|
+
offset = offset >>> 0;
|
|
1503
|
+
if (!noAssert) checkInt(this, value, offset, 1, 127, -128);
|
|
1504
|
+
if (value < 0) value = 255 + value + 1;
|
|
1505
|
+
this[offset] = value & 255;
|
|
1506
|
+
return offset + 1;
|
|
1507
|
+
};
|
|
1508
|
+
Buffer3.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
|
|
1509
|
+
value = +value;
|
|
1510
|
+
offset = offset >>> 0;
|
|
1511
|
+
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
|
|
1512
|
+
this[offset] = value & 255;
|
|
1513
|
+
this[offset + 1] = value >>> 8;
|
|
1514
|
+
return offset + 2;
|
|
1515
|
+
};
|
|
1516
|
+
Buffer3.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
|
|
1517
|
+
value = +value;
|
|
1518
|
+
offset = offset >>> 0;
|
|
1519
|
+
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
|
|
1520
|
+
this[offset] = value >>> 8;
|
|
1521
|
+
this[offset + 1] = value & 255;
|
|
1522
|
+
return offset + 2;
|
|
1523
|
+
};
|
|
1524
|
+
Buffer3.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
|
|
1525
|
+
value = +value;
|
|
1526
|
+
offset = offset >>> 0;
|
|
1527
|
+
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
|
1528
|
+
this[offset] = value & 255;
|
|
1529
|
+
this[offset + 1] = value >>> 8;
|
|
1530
|
+
this[offset + 2] = value >>> 16;
|
|
1531
|
+
this[offset + 3] = value >>> 24;
|
|
1532
|
+
return offset + 4;
|
|
1533
|
+
};
|
|
1534
|
+
Buffer3.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
|
|
1535
|
+
value = +value;
|
|
1536
|
+
offset = offset >>> 0;
|
|
1537
|
+
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
|
1538
|
+
if (value < 0) value = 4294967295 + value + 1;
|
|
1539
|
+
this[offset] = value >>> 24;
|
|
1540
|
+
this[offset + 1] = value >>> 16;
|
|
1541
|
+
this[offset + 2] = value >>> 8;
|
|
1542
|
+
this[offset + 3] = value & 255;
|
|
1543
|
+
return offset + 4;
|
|
1544
|
+
};
|
|
1545
|
+
Buffer3.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) {
|
|
1546
|
+
return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
1547
|
+
});
|
|
1548
|
+
Buffer3.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) {
|
|
1549
|
+
return wrtBigUInt64BE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
1550
|
+
});
|
|
1551
|
+
function checkIEEE754(buf, value, offset, ext, max, min) {
|
|
1552
|
+
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
|
1553
|
+
if (offset < 0) throw new RangeError("Index out of range");
|
|
1554
|
+
}
|
|
1555
|
+
function writeFloat(buf, value, offset, littleEndian, noAssert) {
|
|
1556
|
+
value = +value;
|
|
1557
|
+
offset = offset >>> 0;
|
|
1558
|
+
if (!noAssert) {
|
|
1559
|
+
checkIEEE754(buf, value, offset, 4, 34028234663852886e22, -34028234663852886e22);
|
|
1560
|
+
}
|
|
1561
|
+
ieee754.write(buf, value, offset, littleEndian, 23, 4);
|
|
1562
|
+
return offset + 4;
|
|
1563
|
+
}
|
|
1564
|
+
Buffer3.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
|
|
1565
|
+
return writeFloat(this, value, offset, true, noAssert);
|
|
1566
|
+
};
|
|
1567
|
+
Buffer3.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
|
|
1568
|
+
return writeFloat(this, value, offset, false, noAssert);
|
|
1569
|
+
};
|
|
1570
|
+
function writeDouble(buf, value, offset, littleEndian, noAssert) {
|
|
1571
|
+
value = +value;
|
|
1572
|
+
offset = offset >>> 0;
|
|
1573
|
+
if (!noAssert) {
|
|
1574
|
+
checkIEEE754(buf, value, offset, 8, 17976931348623157e292, -17976931348623157e292);
|
|
1575
|
+
}
|
|
1576
|
+
ieee754.write(buf, value, offset, littleEndian, 52, 8);
|
|
1577
|
+
return offset + 8;
|
|
1578
|
+
}
|
|
1579
|
+
Buffer3.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
|
|
1580
|
+
return writeDouble(this, value, offset, true, noAssert);
|
|
1581
|
+
};
|
|
1582
|
+
Buffer3.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
|
|
1583
|
+
return writeDouble(this, value, offset, false, noAssert);
|
|
1584
|
+
};
|
|
1585
|
+
Buffer3.prototype.copy = function copy(target, targetStart, start, end) {
|
|
1586
|
+
if (!Buffer3.isBuffer(target)) throw new TypeError("argument should be a Buffer");
|
|
1587
|
+
if (!start) start = 0;
|
|
1588
|
+
if (!end && end !== 0) end = this.length;
|
|
1589
|
+
if (targetStart >= target.length) targetStart = target.length;
|
|
1590
|
+
if (!targetStart) targetStart = 0;
|
|
1591
|
+
if (end > 0 && end < start) end = start;
|
|
1592
|
+
if (end === start) return 0;
|
|
1593
|
+
if (target.length === 0 || this.length === 0) return 0;
|
|
1594
|
+
if (targetStart < 0) {
|
|
1595
|
+
throw new RangeError("targetStart out of bounds");
|
|
1596
|
+
}
|
|
1597
|
+
if (start < 0 || start >= this.length) throw new RangeError("Index out of range");
|
|
1598
|
+
if (end < 0) throw new RangeError("sourceEnd out of bounds");
|
|
1599
|
+
if (end > this.length) end = this.length;
|
|
1600
|
+
if (target.length - targetStart < end - start) {
|
|
1601
|
+
end = target.length - targetStart + start;
|
|
1602
|
+
}
|
|
1603
|
+
const len = end - start;
|
|
1604
|
+
if (this === target && typeof Uint8Array.prototype.copyWithin === "function") {
|
|
1605
|
+
this.copyWithin(targetStart, start, end);
|
|
1606
|
+
} else {
|
|
1607
|
+
Uint8Array.prototype.set.call(
|
|
1608
|
+
target,
|
|
1609
|
+
this.subarray(start, end),
|
|
1610
|
+
targetStart
|
|
1611
|
+
);
|
|
1612
|
+
}
|
|
1613
|
+
return len;
|
|
1614
|
+
};
|
|
1615
|
+
Buffer3.prototype.fill = function fill(val, start, end, encoding) {
|
|
1616
|
+
if (typeof val === "string") {
|
|
1617
|
+
if (typeof start === "string") {
|
|
1618
|
+
encoding = start;
|
|
1619
|
+
start = 0;
|
|
1620
|
+
end = this.length;
|
|
1621
|
+
} else if (typeof end === "string") {
|
|
1622
|
+
encoding = end;
|
|
1623
|
+
end = this.length;
|
|
1624
|
+
}
|
|
1625
|
+
if (encoding !== void 0 && typeof encoding !== "string") {
|
|
1626
|
+
throw new TypeError("encoding must be a string");
|
|
1627
|
+
}
|
|
1628
|
+
if (typeof encoding === "string" && !Buffer3.isEncoding(encoding)) {
|
|
1629
|
+
throw new TypeError("Unknown encoding: " + encoding);
|
|
1630
|
+
}
|
|
1631
|
+
if (val.length === 1) {
|
|
1632
|
+
const code = val.charCodeAt(0);
|
|
1633
|
+
if (encoding === "utf8" && code < 128 || encoding === "latin1") {
|
|
1634
|
+
val = code;
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
} else if (typeof val === "number") {
|
|
1638
|
+
val = val & 255;
|
|
1639
|
+
} else if (typeof val === "boolean") {
|
|
1640
|
+
val = Number(val);
|
|
1641
|
+
}
|
|
1642
|
+
if (start < 0 || this.length < start || this.length < end) {
|
|
1643
|
+
throw new RangeError("Out of range index");
|
|
1644
|
+
}
|
|
1645
|
+
if (end <= start) {
|
|
1646
|
+
return this;
|
|
1647
|
+
}
|
|
1648
|
+
start = start >>> 0;
|
|
1649
|
+
end = end === void 0 ? this.length : end >>> 0;
|
|
1650
|
+
if (!val) val = 0;
|
|
1651
|
+
let i;
|
|
1652
|
+
if (typeof val === "number") {
|
|
1653
|
+
for (i = start; i < end; ++i) {
|
|
1654
|
+
this[i] = val;
|
|
1655
|
+
}
|
|
1656
|
+
} else {
|
|
1657
|
+
const bytes = Buffer3.isBuffer(val) ? val : Buffer3.from(val, encoding);
|
|
1658
|
+
const len = bytes.length;
|
|
1659
|
+
if (len === 0) {
|
|
1660
|
+
throw new TypeError('The value "' + val + '" is invalid for argument "value"');
|
|
1661
|
+
}
|
|
1662
|
+
for (i = 0; i < end - start; ++i) {
|
|
1663
|
+
this[i + start] = bytes[i % len];
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
return this;
|
|
1667
|
+
};
|
|
1668
|
+
var errors = {};
|
|
1669
|
+
function E(sym, getMessage, Base) {
|
|
1670
|
+
errors[sym] = class NodeError extends Base {
|
|
1671
|
+
constructor() {
|
|
1672
|
+
super();
|
|
1673
|
+
Object.defineProperty(this, "message", {
|
|
1674
|
+
value: getMessage.apply(this, arguments),
|
|
1675
|
+
writable: true,
|
|
1676
|
+
configurable: true
|
|
1677
|
+
});
|
|
1678
|
+
this.name = `${this.name} [${sym}]`;
|
|
1679
|
+
this.stack;
|
|
1680
|
+
delete this.name;
|
|
1681
|
+
}
|
|
1682
|
+
get code() {
|
|
1683
|
+
return sym;
|
|
1684
|
+
}
|
|
1685
|
+
set code(value) {
|
|
1686
|
+
Object.defineProperty(this, "code", {
|
|
1687
|
+
configurable: true,
|
|
1688
|
+
enumerable: true,
|
|
1689
|
+
value,
|
|
1690
|
+
writable: true
|
|
1691
|
+
});
|
|
1692
|
+
}
|
|
1693
|
+
toString() {
|
|
1694
|
+
return `${this.name} [${sym}]: ${this.message}`;
|
|
1695
|
+
}
|
|
1696
|
+
};
|
|
1697
|
+
}
|
|
1698
|
+
E(
|
|
1699
|
+
"ERR_BUFFER_OUT_OF_BOUNDS",
|
|
1700
|
+
function(name) {
|
|
1701
|
+
if (name) {
|
|
1702
|
+
return `${name} is outside of buffer bounds`;
|
|
1703
|
+
}
|
|
1704
|
+
return "Attempt to access memory outside buffer bounds";
|
|
1705
|
+
},
|
|
1706
|
+
RangeError
|
|
1707
|
+
);
|
|
1708
|
+
E(
|
|
1709
|
+
"ERR_INVALID_ARG_TYPE",
|
|
1710
|
+
function(name, actual) {
|
|
1711
|
+
return `The "${name}" argument must be of type number. Received type ${typeof actual}`;
|
|
1712
|
+
},
|
|
1713
|
+
TypeError
|
|
1714
|
+
);
|
|
1715
|
+
E(
|
|
1716
|
+
"ERR_OUT_OF_RANGE",
|
|
1717
|
+
function(str, range, input) {
|
|
1718
|
+
let msg = `The value of "${str}" is out of range.`;
|
|
1719
|
+
let received = input;
|
|
1720
|
+
if (Number.isInteger(input) && Math.abs(input) > __pow(2, 32)) {
|
|
1721
|
+
received = addNumericalSeparator(String(input));
|
|
1722
|
+
} else if (typeof input === "bigint") {
|
|
1723
|
+
received = String(input);
|
|
1724
|
+
if (input > __pow(BigInt(2), BigInt(32)) || input < -__pow(BigInt(2), BigInt(32))) {
|
|
1725
|
+
received = addNumericalSeparator(received);
|
|
1726
|
+
}
|
|
1727
|
+
received += "n";
|
|
1728
|
+
}
|
|
1729
|
+
msg += ` It must be ${range}. Received ${received}`;
|
|
1730
|
+
return msg;
|
|
1731
|
+
},
|
|
1732
|
+
RangeError
|
|
1733
|
+
);
|
|
1734
|
+
function addNumericalSeparator(val) {
|
|
1735
|
+
let res = "";
|
|
1736
|
+
let i = val.length;
|
|
1737
|
+
const start = val[0] === "-" ? 1 : 0;
|
|
1738
|
+
for (; i >= start + 4; i -= 3) {
|
|
1739
|
+
res = `_${val.slice(i - 3, i)}${res}`;
|
|
1740
|
+
}
|
|
1741
|
+
return `${val.slice(0, i)}${res}`;
|
|
1742
|
+
}
|
|
1743
|
+
function checkBounds(buf, offset, byteLength2) {
|
|
1744
|
+
validateNumber(offset, "offset");
|
|
1745
|
+
if (buf[offset] === void 0 || buf[offset + byteLength2] === void 0) {
|
|
1746
|
+
boundsError(offset, buf.length - (byteLength2 + 1));
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
function checkIntBI(value, min, max, buf, offset, byteLength2) {
|
|
1750
|
+
if (value > max || value < min) {
|
|
1751
|
+
const n = typeof min === "bigint" ? "n" : "";
|
|
1752
|
+
let range;
|
|
1753
|
+
if (byteLength2 > 3) {
|
|
1754
|
+
if (min === 0 || min === BigInt(0)) {
|
|
1755
|
+
range = `>= 0${n} and < 2${n} ** ${(byteLength2 + 1) * 8}${n}`;
|
|
1756
|
+
} else {
|
|
1757
|
+
range = `>= -(2${n} ** ${(byteLength2 + 1) * 8 - 1}${n}) and < 2 ** ${(byteLength2 + 1) * 8 - 1}${n}`;
|
|
1758
|
+
}
|
|
1759
|
+
} else {
|
|
1760
|
+
range = `>= ${min}${n} and <= ${max}${n}`;
|
|
1761
|
+
}
|
|
1762
|
+
throw new errors.ERR_OUT_OF_RANGE("value", range, value);
|
|
1763
|
+
}
|
|
1764
|
+
checkBounds(buf, offset, byteLength2);
|
|
1765
|
+
}
|
|
1766
|
+
function validateNumber(value, name) {
|
|
1767
|
+
if (typeof value !== "number") {
|
|
1768
|
+
throw new errors.ERR_INVALID_ARG_TYPE(name, "number", value);
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
function boundsError(value, length, type) {
|
|
1772
|
+
if (Math.floor(value) !== value) {
|
|
1773
|
+
validateNumber(value, type);
|
|
1774
|
+
throw new errors.ERR_OUT_OF_RANGE(type || "offset", "an integer", value);
|
|
1775
|
+
}
|
|
1776
|
+
if (length < 0) {
|
|
1777
|
+
throw new errors.ERR_BUFFER_OUT_OF_BOUNDS();
|
|
1778
|
+
}
|
|
1779
|
+
throw new errors.ERR_OUT_OF_RANGE(
|
|
1780
|
+
type || "offset",
|
|
1781
|
+
`>= ${type ? 1 : 0} and <= ${length}`,
|
|
1782
|
+
value
|
|
1783
|
+
);
|
|
1784
|
+
}
|
|
1785
|
+
var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
|
|
1786
|
+
function base64clean(str) {
|
|
1787
|
+
str = str.split("=")[0];
|
|
1788
|
+
str = str.trim().replace(INVALID_BASE64_RE, "");
|
|
1789
|
+
if (str.length < 2) return "";
|
|
1790
|
+
while (str.length % 4 !== 0) {
|
|
1791
|
+
str = str + "=";
|
|
1792
|
+
}
|
|
1793
|
+
return str;
|
|
1794
|
+
}
|
|
1795
|
+
function utf8ToBytes2(string2, units) {
|
|
1796
|
+
units = units || Infinity;
|
|
1797
|
+
let codePoint;
|
|
1798
|
+
const length = string2.length;
|
|
1799
|
+
let leadSurrogate = null;
|
|
1800
|
+
const bytes = [];
|
|
1801
|
+
for (let i = 0; i < length; ++i) {
|
|
1802
|
+
codePoint = string2.charCodeAt(i);
|
|
1803
|
+
if (codePoint > 55295 && codePoint < 57344) {
|
|
1804
|
+
if (!leadSurrogate) {
|
|
1805
|
+
if (codePoint > 56319) {
|
|
1806
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1807
|
+
continue;
|
|
1808
|
+
} else if (i + 1 === length) {
|
|
1809
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1810
|
+
continue;
|
|
1811
|
+
}
|
|
1812
|
+
leadSurrogate = codePoint;
|
|
1813
|
+
continue;
|
|
1814
|
+
}
|
|
1815
|
+
if (codePoint < 56320) {
|
|
1816
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1817
|
+
leadSurrogate = codePoint;
|
|
1818
|
+
continue;
|
|
1819
|
+
}
|
|
1820
|
+
codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
|
|
1821
|
+
} else if (leadSurrogate) {
|
|
1822
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1823
|
+
}
|
|
1824
|
+
leadSurrogate = null;
|
|
1825
|
+
if (codePoint < 128) {
|
|
1826
|
+
if ((units -= 1) < 0) break;
|
|
1827
|
+
bytes.push(codePoint);
|
|
1828
|
+
} else if (codePoint < 2048) {
|
|
1829
|
+
if ((units -= 2) < 0) break;
|
|
1830
|
+
bytes.push(
|
|
1831
|
+
codePoint >> 6 | 192,
|
|
1832
|
+
codePoint & 63 | 128
|
|
1833
|
+
);
|
|
1834
|
+
} else if (codePoint < 65536) {
|
|
1835
|
+
if ((units -= 3) < 0) break;
|
|
1836
|
+
bytes.push(
|
|
1837
|
+
codePoint >> 12 | 224,
|
|
1838
|
+
codePoint >> 6 & 63 | 128,
|
|
1839
|
+
codePoint & 63 | 128
|
|
1840
|
+
);
|
|
1841
|
+
} else if (codePoint < 1114112) {
|
|
1842
|
+
if ((units -= 4) < 0) break;
|
|
1843
|
+
bytes.push(
|
|
1844
|
+
codePoint >> 18 | 240,
|
|
1845
|
+
codePoint >> 12 & 63 | 128,
|
|
1846
|
+
codePoint >> 6 & 63 | 128,
|
|
1847
|
+
codePoint & 63 | 128
|
|
1848
|
+
);
|
|
1849
|
+
} else {
|
|
1850
|
+
throw new Error("Invalid code point");
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
return bytes;
|
|
1854
|
+
}
|
|
1855
|
+
function asciiToBytes(str) {
|
|
1856
|
+
const byteArray = [];
|
|
1857
|
+
for (let i = 0; i < str.length; ++i) {
|
|
1858
|
+
byteArray.push(str.charCodeAt(i) & 255);
|
|
1859
|
+
}
|
|
1860
|
+
return byteArray;
|
|
1861
|
+
}
|
|
1862
|
+
function utf16leToBytes(str, units) {
|
|
1863
|
+
let c, hi, lo;
|
|
1864
|
+
const byteArray = [];
|
|
1865
|
+
for (let i = 0; i < str.length; ++i) {
|
|
1866
|
+
if ((units -= 2) < 0) break;
|
|
1867
|
+
c = str.charCodeAt(i);
|
|
1868
|
+
hi = c >> 8;
|
|
1869
|
+
lo = c % 256;
|
|
1870
|
+
byteArray.push(lo);
|
|
1871
|
+
byteArray.push(hi);
|
|
1872
|
+
}
|
|
1873
|
+
return byteArray;
|
|
1874
|
+
}
|
|
1875
|
+
function base64ToBytes(str) {
|
|
1876
|
+
return base642.toByteArray(base64clean(str));
|
|
1877
|
+
}
|
|
1878
|
+
function blitBuffer(src, dst, offset, length) {
|
|
1879
|
+
let i;
|
|
1880
|
+
for (i = 0; i < length; ++i) {
|
|
1881
|
+
if (i + offset >= dst.length || i >= src.length) break;
|
|
1882
|
+
dst[i + offset] = src[i];
|
|
1883
|
+
}
|
|
1884
|
+
return i;
|
|
1885
|
+
}
|
|
1886
|
+
function isInstance(obj, type) {
|
|
1887
|
+
return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name;
|
|
1888
|
+
}
|
|
1889
|
+
function numberIsNaN(obj) {
|
|
1890
|
+
return obj !== obj;
|
|
1891
|
+
}
|
|
1892
|
+
var hexSliceLookupTable = (function() {
|
|
1893
|
+
const alphabet = "0123456789abcdef";
|
|
1894
|
+
const table = new Array(256);
|
|
1895
|
+
for (let i = 0; i < 16; ++i) {
|
|
1896
|
+
const i16 = i * 16;
|
|
1897
|
+
for (let j = 0; j < 16; ++j) {
|
|
1898
|
+
table[i16 + j] = alphabet[i] + alphabet[j];
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
return table;
|
|
1902
|
+
})();
|
|
1903
|
+
function defineBigIntMethod(fn) {
|
|
1904
|
+
return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn;
|
|
1905
|
+
}
|
|
1906
|
+
function BufferBigIntNotDefined() {
|
|
1907
|
+
throw new Error("BigInt not supported");
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
});
|
|
1911
|
+
|
|
134
1912
|
// ../../node_modules/eventemitter3/index.js
|
|
135
1913
|
var require_eventemitter3 = __commonJS({
|
|
136
1914
|
"../../node_modules/eventemitter3/index.js"(exports, module) {
|
|
@@ -692,19 +2470,19 @@ var MetaMaskSDK = (() => {
|
|
|
692
2470
|
var eventsExports = events.exports;
|
|
693
2471
|
var EventEmitter$1 = /* @__PURE__ */ getDefaultExportFromCjs2(eventsExports);
|
|
694
2472
|
exports.errorCodes = void 0;
|
|
695
|
-
(function(
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
2473
|
+
(function(errorCodes2) {
|
|
2474
|
+
errorCodes2[errorCodes2["timeout"] = 1] = "timeout";
|
|
2475
|
+
errorCodes2[errorCodes2["transportClosed"] = 2] = "transportClosed";
|
|
2476
|
+
errorCodes2[errorCodes2["clientDisconnected"] = 3] = "clientDisconnected";
|
|
2477
|
+
errorCodes2[errorCodes2["clientClosed"] = 4] = "clientClosed";
|
|
2478
|
+
errorCodes2[errorCodes2["clientConnectToken"] = 5] = "clientConnectToken";
|
|
2479
|
+
errorCodes2[errorCodes2["clientRefreshToken"] = 6] = "clientRefreshToken";
|
|
2480
|
+
errorCodes2[errorCodes2["subscriptionUnsubscribed"] = 7] = "subscriptionUnsubscribed";
|
|
2481
|
+
errorCodes2[errorCodes2["subscriptionSubscribeToken"] = 8] = "subscriptionSubscribeToken";
|
|
2482
|
+
errorCodes2[errorCodes2["subscriptionRefreshToken"] = 9] = "subscriptionRefreshToken";
|
|
2483
|
+
errorCodes2[errorCodes2["transportWriteError"] = 10] = "transportWriteError";
|
|
2484
|
+
errorCodes2[errorCodes2["connectionClosed"] = 11] = "connectionClosed";
|
|
2485
|
+
errorCodes2[errorCodes2["badConfiguration"] = 12] = "badConfiguration";
|
|
708
2486
|
})(exports.errorCodes || (exports.errorCodes = {}));
|
|
709
2487
|
exports.connectingCodes = void 0;
|
|
710
2488
|
(function(connectingCodes) {
|
|
@@ -6507,20 +8285,20 @@ var MetaMaskSDK = (() => {
|
|
|
6507
8285
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6508
8286
|
exports.run = exports.toFailures = exports.toFailure = exports.shiftIterator = exports.print = exports.isPlainObject = exports.isObject = void 0;
|
|
6509
8287
|
function isIterable2(value) {
|
|
6510
|
-
return
|
|
8288
|
+
return isObject3(value) && typeof value[Symbol.iterator] === "function";
|
|
6511
8289
|
}
|
|
6512
|
-
function
|
|
8290
|
+
function isObject3(value) {
|
|
6513
8291
|
return typeof value === "object" && value !== null;
|
|
6514
8292
|
}
|
|
6515
|
-
exports.isObject =
|
|
6516
|
-
function
|
|
8293
|
+
exports.isObject = isObject3;
|
|
8294
|
+
function isPlainObject2(value) {
|
|
6517
8295
|
if (Object.prototype.toString.call(value) !== "[object Object]") {
|
|
6518
8296
|
return false;
|
|
6519
8297
|
}
|
|
6520
8298
|
const prototype = Object.getPrototypeOf(value);
|
|
6521
8299
|
return prototype === null || prototype === Object.prototype;
|
|
6522
8300
|
}
|
|
6523
|
-
exports.isPlainObject =
|
|
8301
|
+
exports.isPlainObject = isPlainObject2;
|
|
6524
8302
|
function print2(value) {
|
|
6525
8303
|
if (typeof value === "symbol") {
|
|
6526
8304
|
return value.toString();
|
|
@@ -6573,7 +8351,7 @@ var MetaMaskSDK = (() => {
|
|
|
6573
8351
|
const context = { path, branch };
|
|
6574
8352
|
if (coerce2) {
|
|
6575
8353
|
value = struct.coercer(value, context);
|
|
6576
|
-
if (mask2 && struct.type !== "type" &&
|
|
8354
|
+
if (mask2 && struct.type !== "type" && isObject3(struct.schema) && isObject3(value) && !Array.isArray(value)) {
|
|
6577
8355
|
for (const key in value) {
|
|
6578
8356
|
if (struct.schema[key] === void 0) {
|
|
6579
8357
|
delete value[key];
|
|
@@ -6607,7 +8385,7 @@ var MetaMaskSDK = (() => {
|
|
|
6607
8385
|
value.set(innerKey, innerValue);
|
|
6608
8386
|
} else if (value instanceof Set) {
|
|
6609
8387
|
value.add(innerValue);
|
|
6610
|
-
} else if (
|
|
8388
|
+
} else if (isObject3(value)) {
|
|
6611
8389
|
if (innerValue !== void 0 || innerKey in value) {
|
|
6612
8390
|
value[innerKey] = innerValue;
|
|
6613
8391
|
}
|
|
@@ -7520,10 +9298,10 @@ var MetaMaskSDK = (() => {
|
|
|
7520
9298
|
return value === null || value === void 0;
|
|
7521
9299
|
}
|
|
7522
9300
|
exports.isNullOrUndefined = isNullOrUndefined;
|
|
7523
|
-
function
|
|
9301
|
+
function isObject3(value) {
|
|
7524
9302
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
7525
9303
|
}
|
|
7526
|
-
exports.isObject =
|
|
9304
|
+
exports.isObject = isObject3;
|
|
7527
9305
|
var hasProperty2 = (objectToCheck, name) => Object.hasOwnProperty.call(objectToCheck, name);
|
|
7528
9306
|
exports.hasProperty = hasProperty2;
|
|
7529
9307
|
function getKnownPropertyNames(object3) {
|
|
@@ -7542,7 +9320,7 @@ var MetaMaskSDK = (() => {
|
|
|
7542
9320
|
JsonSize3[JsonSize3["Date"] = 24] = "Date";
|
|
7543
9321
|
})(JsonSize2 = exports.JsonSize || (exports.JsonSize = {}));
|
|
7544
9322
|
exports.ESCAPE_CHARACTERS_REGEXP = /"|\\|\n|\r|\t/gu;
|
|
7545
|
-
function
|
|
9323
|
+
function isPlainObject2(value) {
|
|
7546
9324
|
if (typeof value !== "object" || value === null) {
|
|
7547
9325
|
return false;
|
|
7548
9326
|
}
|
|
@@ -7556,7 +9334,7 @@ var MetaMaskSDK = (() => {
|
|
|
7556
9334
|
return false;
|
|
7557
9335
|
}
|
|
7558
9336
|
}
|
|
7559
|
-
exports.isPlainObject =
|
|
9337
|
+
exports.isPlainObject = isPlainObject2;
|
|
7560
9338
|
function isASCII(character) {
|
|
7561
9339
|
return character.charCodeAt(0) <= 127;
|
|
7562
9340
|
}
|
|
@@ -9377,19 +11155,19 @@ var MetaMaskSDK = (() => {
|
|
|
9377
11155
|
return propValue;
|
|
9378
11156
|
}));
|
|
9379
11157
|
});
|
|
9380
|
-
function
|
|
11158
|
+
function isValidJson2(value) {
|
|
9381
11159
|
try {
|
|
9382
|
-
|
|
11160
|
+
getSafeJson2(value);
|
|
9383
11161
|
return true;
|
|
9384
11162
|
} catch (e) {
|
|
9385
11163
|
return false;
|
|
9386
11164
|
}
|
|
9387
11165
|
}
|
|
9388
|
-
exports.isValidJson =
|
|
9389
|
-
function
|
|
11166
|
+
exports.isValidJson = isValidJson2;
|
|
11167
|
+
function getSafeJson2(value) {
|
|
9390
11168
|
return (0, superstruct_1.create)(value, exports.JsonStruct);
|
|
9391
11169
|
}
|
|
9392
|
-
exports.getSafeJson =
|
|
11170
|
+
exports.getSafeJson = getSafeJson2;
|
|
9393
11171
|
function getJsonSize(value) {
|
|
9394
11172
|
(0, assert_1.assertStruct)(value, exports.JsonStruct, "Invalid JSON value");
|
|
9395
11173
|
const json = JSON.stringify(value);
|
|
@@ -9485,10 +11263,10 @@ var MetaMaskSDK = (() => {
|
|
|
9485
11263
|
(0, assert_1.assertStruct)(value, exports.JsonRpcFailureStruct, "Invalid JSON-RPC failure response", ErrorWrapper);
|
|
9486
11264
|
}
|
|
9487
11265
|
exports.assertIsJsonRpcFailure = assertIsJsonRpcFailure;
|
|
9488
|
-
function
|
|
11266
|
+
function isJsonRpcError2(value) {
|
|
9489
11267
|
return (0, superstruct_1.is)(value, exports.JsonRpcErrorStruct);
|
|
9490
11268
|
}
|
|
9491
|
-
exports.isJsonRpcError =
|
|
11269
|
+
exports.isJsonRpcError = isJsonRpcError2;
|
|
9492
11270
|
function assertIsJsonRpcError(value, ErrorWrapper) {
|
|
9493
11271
|
(0, assert_1.assertStruct)(value, exports.JsonRpcErrorStruct, "Invalid JSON-RPC error", ErrorWrapper);
|
|
9494
11272
|
}
|
|
@@ -18365,6 +20143,23 @@ var MetaMaskSDK = (() => {
|
|
|
18365
20143
|
});
|
|
18366
20144
|
|
|
18367
20145
|
// ../../node_modules/@metamask/utils/dist/misc.mjs
|
|
20146
|
+
function isObject2(value) {
|
|
20147
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
20148
|
+
}
|
|
20149
|
+
function isPlainObject(value) {
|
|
20150
|
+
if (typeof value !== "object" || value === null) {
|
|
20151
|
+
return false;
|
|
20152
|
+
}
|
|
20153
|
+
try {
|
|
20154
|
+
let proto = value;
|
|
20155
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
|
20156
|
+
proto = Object.getPrototypeOf(proto);
|
|
20157
|
+
}
|
|
20158
|
+
return Object.getPrototypeOf(value) === proto;
|
|
20159
|
+
} catch (_) {
|
|
20160
|
+
return false;
|
|
20161
|
+
}
|
|
20162
|
+
}
|
|
18368
20163
|
var hasProperty, JsonSize;
|
|
18369
20164
|
var init_misc = __esm({
|
|
18370
20165
|
"../../node_modules/@metamask/utils/dist/misc.mjs"() {
|
|
@@ -19445,7 +21240,7 @@ var MetaMaskSDK = (() => {
|
|
|
19445
21240
|
var coreJsData = context["__core-js_shared__"];
|
|
19446
21241
|
var funcToString = funcProto.toString;
|
|
19447
21242
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
19448
|
-
var
|
|
21243
|
+
var idCounter3 = 0;
|
|
19449
21244
|
var maskSrcKey = (function() {
|
|
19450
21245
|
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
|
|
19451
21246
|
return uid ? "Symbol(src)_1." + uid : "";
|
|
@@ -19456,7 +21251,7 @@ var MetaMaskSDK = (() => {
|
|
|
19456
21251
|
var reIsNative = RegExp2(
|
|
19457
21252
|
"^" + funcToString.call(hasOwnProperty).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
19458
21253
|
);
|
|
19459
|
-
var
|
|
21254
|
+
var Buffer3 = moduleExports ? context.Buffer : undefined2, Symbol2 = context.Symbol, Uint8Array2 = context.Uint8Array, allocUnsafe = Buffer3 ? Buffer3.allocUnsafe : undefined2, getPrototype = overArg(Object2.getPrototypeOf, Object2), objectCreate = Object2.create, propertyIsEnumerable = objectProto.propertyIsEnumerable, splice = arrayProto.splice, spreadableSymbol = Symbol2 ? Symbol2.isConcatSpreadable : undefined2, symIterator = Symbol2 ? Symbol2.iterator : undefined2, symToStringTag = Symbol2 ? Symbol2.toStringTag : undefined2;
|
|
19460
21255
|
var defineProperty = (function() {
|
|
19461
21256
|
try {
|
|
19462
21257
|
var func = getNative(Object2, "defineProperty");
|
|
@@ -19466,7 +21261,7 @@ var MetaMaskSDK = (() => {
|
|
|
19466
21261
|
}
|
|
19467
21262
|
})();
|
|
19468
21263
|
var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, ctxNow = Date2 && Date2.now !== root.Date.now && Date2.now, ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
|
|
19469
|
-
var nativeCeil = Math2.ceil, nativeFloor = Math2.floor, nativeGetSymbols = Object2.getOwnPropertySymbols, nativeIsBuffer =
|
|
21264
|
+
var nativeCeil = Math2.ceil, nativeFloor = Math2.floor, nativeGetSymbols = Object2.getOwnPropertySymbols, nativeIsBuffer = Buffer3 ? Buffer3.isBuffer : undefined2, nativeIsFinite = context.isFinite, nativeJoin = arrayProto.join, nativeKeys = overArg(Object2.keys, Object2), nativeMax = Math2.max, nativeMin = Math2.min, nativeNow = Date2.now, nativeParseInt = context.parseInt, nativeRandom = Math2.random, nativeReverse = arrayProto.reverse;
|
|
19470
21265
|
var DataView2 = getNative(context, "DataView"), Map2 = getNative(context, "Map"), Promise2 = getNative(context, "Promise"), Set2 = getNative(context, "Set"), WeakMap2 = getNative(context, "WeakMap"), nativeCreate = getNative(Object2, "create");
|
|
19471
21266
|
var metaMap = WeakMap2 && new WeakMap2();
|
|
19472
21267
|
var realNames = {};
|
|
@@ -19487,7 +21282,7 @@ var MetaMaskSDK = (() => {
|
|
|
19487
21282
|
function object3() {
|
|
19488
21283
|
}
|
|
19489
21284
|
return function(proto) {
|
|
19490
|
-
if (!
|
|
21285
|
+
if (!isObject3(proto)) {
|
|
19491
21286
|
return {};
|
|
19492
21287
|
}
|
|
19493
21288
|
if (objectCreate) {
|
|
@@ -19889,7 +21684,7 @@ var MetaMaskSDK = (() => {
|
|
|
19889
21684
|
if (result2 !== undefined2) {
|
|
19890
21685
|
return result2;
|
|
19891
21686
|
}
|
|
19892
|
-
if (!
|
|
21687
|
+
if (!isObject3(value)) {
|
|
19893
21688
|
return value;
|
|
19894
21689
|
}
|
|
19895
21690
|
var isArr = isArray(value);
|
|
@@ -20236,7 +22031,7 @@ var MetaMaskSDK = (() => {
|
|
|
20236
22031
|
return true;
|
|
20237
22032
|
}
|
|
20238
22033
|
function baseIsNative(value) {
|
|
20239
|
-
if (!
|
|
22034
|
+
if (!isObject3(value) || isMasked(value)) {
|
|
20240
22035
|
return false;
|
|
20241
22036
|
}
|
|
20242
22037
|
var pattern2 = isFunction(value) ? reIsNative : reIsHostCtor;
|
|
@@ -20276,7 +22071,7 @@ var MetaMaskSDK = (() => {
|
|
|
20276
22071
|
return result2;
|
|
20277
22072
|
}
|
|
20278
22073
|
function baseKeysIn(object3) {
|
|
20279
|
-
if (!
|
|
22074
|
+
if (!isObject3(object3)) {
|
|
20280
22075
|
return nativeKeysIn(object3);
|
|
20281
22076
|
}
|
|
20282
22077
|
var isProto = isPrototype(object3), result2 = [];
|
|
@@ -20321,7 +22116,7 @@ var MetaMaskSDK = (() => {
|
|
|
20321
22116
|
}
|
|
20322
22117
|
baseFor(source, function(srcValue, key) {
|
|
20323
22118
|
stack || (stack = new Stack());
|
|
20324
|
-
if (
|
|
22119
|
+
if (isObject3(srcValue)) {
|
|
20325
22120
|
baseMergeDeep(object3, source, key, srcIndex, baseMerge, customizer, stack);
|
|
20326
22121
|
} else {
|
|
20327
22122
|
var newValue = customizer ? customizer(safeGet(object3, key), srcValue, key + "", object3, source, stack) : undefined2;
|
|
@@ -20357,11 +22152,11 @@ var MetaMaskSDK = (() => {
|
|
|
20357
22152
|
} else {
|
|
20358
22153
|
newValue = [];
|
|
20359
22154
|
}
|
|
20360
|
-
} else if (
|
|
22155
|
+
} else if (isPlainObject2(srcValue) || isArguments(srcValue)) {
|
|
20361
22156
|
newValue = objValue;
|
|
20362
22157
|
if (isArguments(objValue)) {
|
|
20363
22158
|
newValue = toPlainObject(objValue);
|
|
20364
|
-
} else if (!
|
|
22159
|
+
} else if (!isObject3(objValue) || isFunction(objValue)) {
|
|
20365
22160
|
newValue = initCloneObject(srcValue);
|
|
20366
22161
|
}
|
|
20367
22162
|
} else {
|
|
@@ -20500,7 +22295,7 @@ var MetaMaskSDK = (() => {
|
|
|
20500
22295
|
return shuffleSelf(array2, baseClamp(n, 0, array2.length));
|
|
20501
22296
|
}
|
|
20502
22297
|
function baseSet(object3, path, value, customizer) {
|
|
20503
|
-
if (!
|
|
22298
|
+
if (!isObject3(object3)) {
|
|
20504
22299
|
return object3;
|
|
20505
22300
|
}
|
|
20506
22301
|
path = castPath(path, object3);
|
|
@@ -20514,7 +22309,7 @@ var MetaMaskSDK = (() => {
|
|
|
20514
22309
|
var objValue = nested[key];
|
|
20515
22310
|
newValue = customizer ? customizer(objValue, key, nested) : undefined2;
|
|
20516
22311
|
if (newValue === undefined2) {
|
|
20517
|
-
newValue =
|
|
22312
|
+
newValue = isObject3(objValue) ? objValue : isIndex(path[index + 1]) ? [] : {};
|
|
20518
22313
|
}
|
|
20519
22314
|
}
|
|
20520
22315
|
assignValue(nested, key, newValue);
|
|
@@ -20964,7 +22759,7 @@ var MetaMaskSDK = (() => {
|
|
|
20964
22759
|
return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
|
|
20965
22760
|
}
|
|
20966
22761
|
var thisBinding = baseCreate(Ctor.prototype), result2 = Ctor.apply(thisBinding, args);
|
|
20967
|
-
return
|
|
22762
|
+
return isObject3(result2) ? result2 : thisBinding;
|
|
20968
22763
|
};
|
|
20969
22764
|
}
|
|
20970
22765
|
function createCurry(func, bitmask, arity) {
|
|
@@ -21300,7 +23095,7 @@ var MetaMaskSDK = (() => {
|
|
|
21300
23095
|
return objValue;
|
|
21301
23096
|
}
|
|
21302
23097
|
function customDefaultsMerge(objValue, srcValue, key, object3, source, stack) {
|
|
21303
|
-
if (
|
|
23098
|
+
if (isObject3(objValue) && isObject3(srcValue)) {
|
|
21304
23099
|
stack.set(srcValue, objValue);
|
|
21305
23100
|
baseMerge(objValue, srcValue, undefined2, customDefaultsMerge, stack);
|
|
21306
23101
|
stack["delete"](srcValue);
|
|
@@ -21308,7 +23103,7 @@ var MetaMaskSDK = (() => {
|
|
|
21308
23103
|
return objValue;
|
|
21309
23104
|
}
|
|
21310
23105
|
function customOmitClone(value) {
|
|
21311
|
-
return
|
|
23106
|
+
return isPlainObject2(value) ? undefined2 : value;
|
|
21312
23107
|
}
|
|
21313
23108
|
function equalArrays(array2, other, bitmask, customizer, equalFunc, stack) {
|
|
21314
23109
|
var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array2.length, othLength = other.length;
|
|
@@ -21648,7 +23443,7 @@ var MetaMaskSDK = (() => {
|
|
|
21648
23443
|
return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
|
|
21649
23444
|
}
|
|
21650
23445
|
function isIterateeCall(value, index, object3) {
|
|
21651
|
-
if (!
|
|
23446
|
+
if (!isObject3(object3)) {
|
|
21652
23447
|
return false;
|
|
21653
23448
|
}
|
|
21654
23449
|
var type = typeof index;
|
|
@@ -21691,7 +23486,7 @@ var MetaMaskSDK = (() => {
|
|
|
21691
23486
|
return value === proto;
|
|
21692
23487
|
}
|
|
21693
23488
|
function isStrictComparable(value) {
|
|
21694
|
-
return value === value && !
|
|
23489
|
+
return value === value && !isObject3(value);
|
|
21695
23490
|
}
|
|
21696
23491
|
function matchesStrictComparable(key, srcValue) {
|
|
21697
23492
|
return function(object3) {
|
|
@@ -22573,7 +24368,7 @@ var MetaMaskSDK = (() => {
|
|
|
22573
24368
|
throw new TypeError2(FUNC_ERROR_TEXT);
|
|
22574
24369
|
}
|
|
22575
24370
|
wait = toNumber(wait) || 0;
|
|
22576
|
-
if (
|
|
24371
|
+
if (isObject3(options)) {
|
|
22577
24372
|
leading = !!options.leading;
|
|
22578
24373
|
maxing = "maxWait" in options;
|
|
22579
24374
|
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
@@ -22743,7 +24538,7 @@ var MetaMaskSDK = (() => {
|
|
|
22743
24538
|
if (typeof func != "function") {
|
|
22744
24539
|
throw new TypeError2(FUNC_ERROR_TEXT);
|
|
22745
24540
|
}
|
|
22746
|
-
if (
|
|
24541
|
+
if (isObject3(options)) {
|
|
22747
24542
|
leading = "leading" in options ? !!options.leading : leading;
|
|
22748
24543
|
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
22749
24544
|
}
|
|
@@ -22809,7 +24604,7 @@ var MetaMaskSDK = (() => {
|
|
|
22809
24604
|
var isBuffer = nativeIsBuffer || stubFalse;
|
|
22810
24605
|
var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
|
|
22811
24606
|
function isElement(value) {
|
|
22812
|
-
return isObjectLike(value) && value.nodeType === 1 && !
|
|
24607
|
+
return isObjectLike(value) && value.nodeType === 1 && !isPlainObject2(value);
|
|
22813
24608
|
}
|
|
22814
24609
|
function isEmpty(value) {
|
|
22815
24610
|
if (value == null) {
|
|
@@ -22845,13 +24640,13 @@ var MetaMaskSDK = (() => {
|
|
|
22845
24640
|
return false;
|
|
22846
24641
|
}
|
|
22847
24642
|
var tag = baseGetTag(value);
|
|
22848
|
-
return tag == errorTag || tag == domExcTag || typeof value.message == "string" && typeof value.name == "string" && !
|
|
24643
|
+
return tag == errorTag || tag == domExcTag || typeof value.message == "string" && typeof value.name == "string" && !isPlainObject2(value);
|
|
22849
24644
|
}
|
|
22850
24645
|
function isFinite2(value) {
|
|
22851
24646
|
return typeof value == "number" && nativeIsFinite(value);
|
|
22852
24647
|
}
|
|
22853
24648
|
function isFunction(value) {
|
|
22854
|
-
if (!
|
|
24649
|
+
if (!isObject3(value)) {
|
|
22855
24650
|
return false;
|
|
22856
24651
|
}
|
|
22857
24652
|
var tag = baseGetTag(value);
|
|
@@ -22863,7 +24658,7 @@ var MetaMaskSDK = (() => {
|
|
|
22863
24658
|
function isLength(value) {
|
|
22864
24659
|
return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
22865
24660
|
}
|
|
22866
|
-
function
|
|
24661
|
+
function isObject3(value) {
|
|
22867
24662
|
var type = typeof value;
|
|
22868
24663
|
return value != null && (type == "object" || type == "function");
|
|
22869
24664
|
}
|
|
@@ -22896,7 +24691,7 @@ var MetaMaskSDK = (() => {
|
|
|
22896
24691
|
function isNumber(value) {
|
|
22897
24692
|
return typeof value == "number" || isObjectLike(value) && baseGetTag(value) == numberTag;
|
|
22898
24693
|
}
|
|
22899
|
-
function
|
|
24694
|
+
function isPlainObject2(value) {
|
|
22900
24695
|
if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
|
|
22901
24696
|
return false;
|
|
22902
24697
|
}
|
|
@@ -22970,9 +24765,9 @@ var MetaMaskSDK = (() => {
|
|
|
22970
24765
|
if (isSymbol(value)) {
|
|
22971
24766
|
return NAN;
|
|
22972
24767
|
}
|
|
22973
|
-
if (
|
|
24768
|
+
if (isObject3(value)) {
|
|
22974
24769
|
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
22975
|
-
value =
|
|
24770
|
+
value = isObject3(other) ? other + "" : other;
|
|
22976
24771
|
}
|
|
22977
24772
|
if (typeof value != "string") {
|
|
22978
24773
|
return value === 0 ? value : +value;
|
|
@@ -23193,7 +24988,7 @@ var MetaMaskSDK = (() => {
|
|
|
23193
24988
|
var Ctor = object3 && object3.constructor;
|
|
23194
24989
|
if (isArrLike) {
|
|
23195
24990
|
accumulator = isArr ? new Ctor() : [];
|
|
23196
|
-
} else if (
|
|
24991
|
+
} else if (isObject3(object3)) {
|
|
23197
24992
|
accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object3)) : {};
|
|
23198
24993
|
} else {
|
|
23199
24994
|
accumulator = {};
|
|
@@ -23478,7 +25273,7 @@ var MetaMaskSDK = (() => {
|
|
|
23478
25273
|
}
|
|
23479
25274
|
function truncate(string2, options) {
|
|
23480
25275
|
var length = DEFAULT_TRUNC_LENGTH, omission = DEFAULT_TRUNC_OMISSION;
|
|
23481
|
-
if (
|
|
25276
|
+
if (isObject3(options)) {
|
|
23482
25277
|
var separator = "separator" in options ? options.separator : separator;
|
|
23483
25278
|
length = "length" in options ? toInteger(options.length) : length;
|
|
23484
25279
|
omission = "omission" in options ? baseToString(options.omission) : omission;
|
|
@@ -23608,13 +25403,13 @@ var MetaMaskSDK = (() => {
|
|
|
23608
25403
|
});
|
|
23609
25404
|
function mixin(object3, source, options) {
|
|
23610
25405
|
var props = keys(source), methodNames = baseFunctions(source, props);
|
|
23611
|
-
if (options == null && !(
|
|
25406
|
+
if (options == null && !(isObject3(source) && (methodNames.length || !props.length))) {
|
|
23612
25407
|
options = source;
|
|
23613
25408
|
source = object3;
|
|
23614
25409
|
object3 = this;
|
|
23615
25410
|
methodNames = baseFunctions(source, keys(source));
|
|
23616
25411
|
}
|
|
23617
|
-
var chain2 = !(
|
|
25412
|
+
var chain2 = !(isObject3(options) && "chain" in options) || !!options.chain, isFunc = isFunction(object3);
|
|
23618
25413
|
arrayEach(methodNames, function(methodName) {
|
|
23619
25414
|
var func = source[methodName];
|
|
23620
25415
|
object3[methodName] = func;
|
|
@@ -23696,7 +25491,7 @@ var MetaMaskSDK = (() => {
|
|
|
23696
25491
|
return isSymbol(value) ? [value] : copyArray(stringToPath(toString2(value)));
|
|
23697
25492
|
}
|
|
23698
25493
|
function uniqueId(prefix) {
|
|
23699
|
-
var id = ++
|
|
25494
|
+
var id = ++idCounter3;
|
|
23700
25495
|
return toString2(prefix) + id;
|
|
23701
25496
|
}
|
|
23702
25497
|
var add = createMathOperation(function(augend, addend) {
|
|
@@ -23960,9 +25755,9 @@ var MetaMaskSDK = (() => {
|
|
|
23960
25755
|
lodash.isNil = isNil;
|
|
23961
25756
|
lodash.isNull = isNull;
|
|
23962
25757
|
lodash.isNumber = isNumber;
|
|
23963
|
-
lodash.isObject =
|
|
25758
|
+
lodash.isObject = isObject3;
|
|
23964
25759
|
lodash.isObjectLike = isObjectLike;
|
|
23965
|
-
lodash.isPlainObject =
|
|
25760
|
+
lodash.isPlainObject = isPlainObject2;
|
|
23966
25761
|
lodash.isRegExp = isRegExp;
|
|
23967
25762
|
lodash.isSafeInteger = isSafeInteger;
|
|
23968
25763
|
lodash.isSet = isSet;
|
|
@@ -24605,6 +26400,17 @@ var MetaMaskSDK = (() => {
|
|
|
24605
26400
|
}
|
|
24606
26401
|
return false;
|
|
24607
26402
|
}
|
|
26403
|
+
function isValidJson(value) {
|
|
26404
|
+
try {
|
|
26405
|
+
getSafeJson(value);
|
|
26406
|
+
return true;
|
|
26407
|
+
} catch (e) {
|
|
26408
|
+
return false;
|
|
26409
|
+
}
|
|
26410
|
+
}
|
|
26411
|
+
function getSafeJson(value) {
|
|
26412
|
+
return create(value, JsonStruct);
|
|
26413
|
+
}
|
|
24608
26414
|
var object2, UnsafeJsonStruct, JsonStruct, jsonrpc2, JsonRpcVersionStruct, JsonRpcIdStruct, JsonRpcErrorStruct, JsonRpcParamsStruct, JsonRpcRequestStruct, JsonRpcNotificationStruct, PendingJsonRpcResponseStruct, JsonRpcSuccessStruct, JsonRpcFailureStruct, JsonRpcResponseStruct;
|
|
24609
26415
|
var init_json = __esm({
|
|
24610
26416
|
"../../node_modules/@metamask/utils/dist/json.mjs"() {
|
|
@@ -25068,12 +26874,12 @@ var MetaMaskSDK = (() => {
|
|
|
25068
26874
|
})();
|
|
25069
26875
|
(function(globalThis2) {
|
|
25070
26876
|
var irrelevant = (function(exports2) {
|
|
25071
|
-
var
|
|
26877
|
+
var g2 = typeof globalThis2 !== "undefined" && globalThis2 || typeof self !== "undefined" && self || // eslint-disable-next-line no-undef
|
|
25072
26878
|
typeof global !== "undefined" && global || {};
|
|
25073
26879
|
var support = {
|
|
25074
|
-
searchParams: "URLSearchParams" in
|
|
25075
|
-
iterable: "Symbol" in
|
|
25076
|
-
blob: "FileReader" in
|
|
26880
|
+
searchParams: "URLSearchParams" in g2,
|
|
26881
|
+
iterable: "Symbol" in g2 && "iterator" in Symbol,
|
|
26882
|
+
blob: "FileReader" in g2 && "Blob" in g2 && (function() {
|
|
25077
26883
|
try {
|
|
25078
26884
|
new Blob();
|
|
25079
26885
|
return true;
|
|
@@ -25081,8 +26887,8 @@ var MetaMaskSDK = (() => {
|
|
|
25081
26887
|
return false;
|
|
25082
26888
|
}
|
|
25083
26889
|
})(),
|
|
25084
|
-
formData: "FormData" in
|
|
25085
|
-
arrayBuffer: "ArrayBuffer" in
|
|
26890
|
+
formData: "FormData" in g2,
|
|
26891
|
+
arrayBuffer: "ArrayBuffer" in g2
|
|
25086
26892
|
};
|
|
25087
26893
|
function isDataView(obj) {
|
|
25088
26894
|
return obj && DataView.prototype.isPrototypeOf(obj);
|
|
@@ -25383,7 +27189,7 @@ var MetaMaskSDK = (() => {
|
|
|
25383
27189
|
this.method = normalizeMethod(options.method || this.method || "GET");
|
|
25384
27190
|
this.mode = options.mode || this.mode || null;
|
|
25385
27191
|
this.signal = options.signal || this.signal || (function() {
|
|
25386
|
-
if ("AbortController" in
|
|
27192
|
+
if ("AbortController" in g2) {
|
|
25387
27193
|
var ctrl = new AbortController();
|
|
25388
27194
|
return ctrl.signal;
|
|
25389
27195
|
}
|
|
@@ -25481,7 +27287,7 @@ var MetaMaskSDK = (() => {
|
|
|
25481
27287
|
}
|
|
25482
27288
|
return new Response2(null, { status, headers: { location: url } });
|
|
25483
27289
|
};
|
|
25484
|
-
exports2.DOMException =
|
|
27290
|
+
exports2.DOMException = g2.DOMException;
|
|
25485
27291
|
try {
|
|
25486
27292
|
new exports2.DOMException();
|
|
25487
27293
|
} catch (err3) {
|
|
@@ -25537,7 +27343,7 @@ var MetaMaskSDK = (() => {
|
|
|
25537
27343
|
};
|
|
25538
27344
|
function fixUrl(url) {
|
|
25539
27345
|
try {
|
|
25540
|
-
return url === "" &&
|
|
27346
|
+
return url === "" && g2.location.href ? g2.location.href : url;
|
|
25541
27347
|
} catch (e) {
|
|
25542
27348
|
return url;
|
|
25543
27349
|
}
|
|
@@ -25555,7 +27361,7 @@ var MetaMaskSDK = (() => {
|
|
|
25555
27361
|
xhr.responseType = "arraybuffer";
|
|
25556
27362
|
}
|
|
25557
27363
|
}
|
|
25558
|
-
if (init && typeof init.headers === "object" && !(init.headers instanceof Headers2 ||
|
|
27364
|
+
if (init && typeof init.headers === "object" && !(init.headers instanceof Headers2 || g2.Headers && init.headers instanceof g2.Headers)) {
|
|
25559
27365
|
var names = [];
|
|
25560
27366
|
Object.getOwnPropertyNames(init.headers).forEach(function(name) {
|
|
25561
27367
|
names.push(normalizeName(name));
|
|
@@ -25583,11 +27389,11 @@ var MetaMaskSDK = (() => {
|
|
|
25583
27389
|
});
|
|
25584
27390
|
}
|
|
25585
27391
|
fetch3.polyfill = true;
|
|
25586
|
-
if (!
|
|
25587
|
-
|
|
25588
|
-
|
|
25589
|
-
|
|
25590
|
-
|
|
27392
|
+
if (!g2.fetch) {
|
|
27393
|
+
g2.fetch = fetch3;
|
|
27394
|
+
g2.Headers = Headers2;
|
|
27395
|
+
g2.Request = Request;
|
|
27396
|
+
g2.Response = Response2;
|
|
25591
27397
|
}
|
|
25592
27398
|
exports2.Headers = Headers2;
|
|
25593
27399
|
exports2.Request = Request;
|
|
@@ -31352,9 +33158,9 @@ var MetaMaskSDK = (() => {
|
|
|
31352
33158
|
const nonceLen = EMPTY_BLOCK.slice();
|
|
31353
33159
|
const view = (0, utils_ts_1.createView)(nonceLen);
|
|
31354
33160
|
(0, utils_ts_1.setBigUint64)(view, 8, BigInt(nonce.length * 8), false);
|
|
31355
|
-
const
|
|
31356
|
-
|
|
31357
|
-
|
|
33161
|
+
const g2 = _polyval_ts_1.ghash.create(authKey).update(nonce).update(nonceLen);
|
|
33162
|
+
g2.digestInto(counter);
|
|
33163
|
+
g2.destroy();
|
|
31358
33164
|
}
|
|
31359
33165
|
const tagMask = ctr32(xk, false, counter, EMPTY_BLOCK);
|
|
31360
33166
|
return { xk, authKey, counter, tagMask };
|
|
@@ -31914,7 +33720,7 @@ var MetaMaskSDK = (() => {
|
|
|
31914
33720
|
}
|
|
31915
33721
|
finalize() {
|
|
31916
33722
|
const { h: h2, pad } = this;
|
|
31917
|
-
const
|
|
33723
|
+
const g2 = new Uint16Array(10);
|
|
31918
33724
|
let c = h2[1] >>> 13;
|
|
31919
33725
|
h2[1] &= 8191;
|
|
31920
33726
|
for (let i = 2; i < 10; i++) {
|
|
@@ -31929,21 +33735,21 @@ var MetaMaskSDK = (() => {
|
|
|
31929
33735
|
c = h2[1] >>> 13;
|
|
31930
33736
|
h2[1] &= 8191;
|
|
31931
33737
|
h2[2] += c;
|
|
31932
|
-
|
|
31933
|
-
c =
|
|
31934
|
-
|
|
33738
|
+
g2[0] = h2[0] + 5;
|
|
33739
|
+
c = g2[0] >>> 13;
|
|
33740
|
+
g2[0] &= 8191;
|
|
31935
33741
|
for (let i = 1; i < 10; i++) {
|
|
31936
|
-
|
|
31937
|
-
c =
|
|
31938
|
-
|
|
33742
|
+
g2[i] = h2[i] + c;
|
|
33743
|
+
c = g2[i] >>> 13;
|
|
33744
|
+
g2[i] &= 8191;
|
|
31939
33745
|
}
|
|
31940
|
-
|
|
33746
|
+
g2[9] -= 1 << 13;
|
|
31941
33747
|
let mask2 = (c ^ 1) - 1;
|
|
31942
33748
|
for (let i = 0; i < 10; i++)
|
|
31943
|
-
|
|
33749
|
+
g2[i] &= mask2;
|
|
31944
33750
|
mask2 = ~mask2;
|
|
31945
33751
|
for (let i = 0; i < 10; i++)
|
|
31946
|
-
h2[i] = h2[i] & mask2 |
|
|
33752
|
+
h2[i] = h2[i] & mask2 | g2[i];
|
|
31947
33753
|
h2[0] = (h2[0] | h2[1] << 13) & 65535;
|
|
31948
33754
|
h2[1] = (h2[1] >>> 3 | h2[2] << 10) & 65535;
|
|
31949
33755
|
h2[2] = (h2[2] >>> 6 | h2[3] << 7) & 65535;
|
|
@@ -31958,7 +33764,7 @@ var MetaMaskSDK = (() => {
|
|
|
31958
33764
|
f = (h2[i] + pad[i] | 0) + (f >>> 16) | 0;
|
|
31959
33765
|
h2[i] = f & 65535;
|
|
31960
33766
|
}
|
|
31961
|
-
(0, utils_ts_1.clean)(
|
|
33767
|
+
(0, utils_ts_1.clean)(g2);
|
|
31962
33768
|
}
|
|
31963
33769
|
update(data) {
|
|
31964
33770
|
(0, utils_ts_1.aexists)(this);
|
|
@@ -32598,6 +34404,201 @@ var MetaMaskSDK = (() => {
|
|
|
32598
34404
|
}
|
|
32599
34405
|
});
|
|
32600
34406
|
|
|
34407
|
+
// ../../node_modules/fast-safe-stringify/index.js
|
|
34408
|
+
var require_fast_safe_stringify = __commonJS({
|
|
34409
|
+
"../../node_modules/fast-safe-stringify/index.js"(exports, module) {
|
|
34410
|
+
"use strict";
|
|
34411
|
+
module.exports = stringify;
|
|
34412
|
+
stringify.default = stringify;
|
|
34413
|
+
stringify.stable = deterministicStringify;
|
|
34414
|
+
stringify.stableStringify = deterministicStringify;
|
|
34415
|
+
var LIMIT_REPLACE_NODE = "[...]";
|
|
34416
|
+
var CIRCULAR_REPLACE_NODE = "[Circular]";
|
|
34417
|
+
var arr = [];
|
|
34418
|
+
var replacerStack = [];
|
|
34419
|
+
function defaultOptions() {
|
|
34420
|
+
return {
|
|
34421
|
+
depthLimit: Number.MAX_SAFE_INTEGER,
|
|
34422
|
+
edgesLimit: Number.MAX_SAFE_INTEGER
|
|
34423
|
+
};
|
|
34424
|
+
}
|
|
34425
|
+
function stringify(obj, replacer, spacer, options) {
|
|
34426
|
+
if (typeof options === "undefined") {
|
|
34427
|
+
options = defaultOptions();
|
|
34428
|
+
}
|
|
34429
|
+
decirc(obj, "", 0, [], void 0, 0, options);
|
|
34430
|
+
var res;
|
|
34431
|
+
try {
|
|
34432
|
+
if (replacerStack.length === 0) {
|
|
34433
|
+
res = JSON.stringify(obj, replacer, spacer);
|
|
34434
|
+
} else {
|
|
34435
|
+
res = JSON.stringify(obj, replaceGetterValues(replacer), spacer);
|
|
34436
|
+
}
|
|
34437
|
+
} catch (_) {
|
|
34438
|
+
return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]");
|
|
34439
|
+
} finally {
|
|
34440
|
+
while (arr.length !== 0) {
|
|
34441
|
+
var part = arr.pop();
|
|
34442
|
+
if (part.length === 4) {
|
|
34443
|
+
Object.defineProperty(part[0], part[1], part[3]);
|
|
34444
|
+
} else {
|
|
34445
|
+
part[0][part[1]] = part[2];
|
|
34446
|
+
}
|
|
34447
|
+
}
|
|
34448
|
+
}
|
|
34449
|
+
return res;
|
|
34450
|
+
}
|
|
34451
|
+
function setReplace(replace, val, k, parent) {
|
|
34452
|
+
var propertyDescriptor = Object.getOwnPropertyDescriptor(parent, k);
|
|
34453
|
+
if (propertyDescriptor.get !== void 0) {
|
|
34454
|
+
if (propertyDescriptor.configurable) {
|
|
34455
|
+
Object.defineProperty(parent, k, { value: replace });
|
|
34456
|
+
arr.push([parent, k, val, propertyDescriptor]);
|
|
34457
|
+
} else {
|
|
34458
|
+
replacerStack.push([val, k, replace]);
|
|
34459
|
+
}
|
|
34460
|
+
} else {
|
|
34461
|
+
parent[k] = replace;
|
|
34462
|
+
arr.push([parent, k, val]);
|
|
34463
|
+
}
|
|
34464
|
+
}
|
|
34465
|
+
function decirc(val, k, edgeIndex, stack, parent, depth, options) {
|
|
34466
|
+
depth += 1;
|
|
34467
|
+
var i;
|
|
34468
|
+
if (typeof val === "object" && val !== null) {
|
|
34469
|
+
for (i = 0; i < stack.length; i++) {
|
|
34470
|
+
if (stack[i] === val) {
|
|
34471
|
+
setReplace(CIRCULAR_REPLACE_NODE, val, k, parent);
|
|
34472
|
+
return;
|
|
34473
|
+
}
|
|
34474
|
+
}
|
|
34475
|
+
if (typeof options.depthLimit !== "undefined" && depth > options.depthLimit) {
|
|
34476
|
+
setReplace(LIMIT_REPLACE_NODE, val, k, parent);
|
|
34477
|
+
return;
|
|
34478
|
+
}
|
|
34479
|
+
if (typeof options.edgesLimit !== "undefined" && edgeIndex + 1 > options.edgesLimit) {
|
|
34480
|
+
setReplace(LIMIT_REPLACE_NODE, val, k, parent);
|
|
34481
|
+
return;
|
|
34482
|
+
}
|
|
34483
|
+
stack.push(val);
|
|
34484
|
+
if (Array.isArray(val)) {
|
|
34485
|
+
for (i = 0; i < val.length; i++) {
|
|
34486
|
+
decirc(val[i], i, i, stack, val, depth, options);
|
|
34487
|
+
}
|
|
34488
|
+
} else {
|
|
34489
|
+
var keys = Object.keys(val);
|
|
34490
|
+
for (i = 0; i < keys.length; i++) {
|
|
34491
|
+
var key = keys[i];
|
|
34492
|
+
decirc(val[key], key, i, stack, val, depth, options);
|
|
34493
|
+
}
|
|
34494
|
+
}
|
|
34495
|
+
stack.pop();
|
|
34496
|
+
}
|
|
34497
|
+
}
|
|
34498
|
+
function compareFunction(a, b) {
|
|
34499
|
+
if (a < b) {
|
|
34500
|
+
return -1;
|
|
34501
|
+
}
|
|
34502
|
+
if (a > b) {
|
|
34503
|
+
return 1;
|
|
34504
|
+
}
|
|
34505
|
+
return 0;
|
|
34506
|
+
}
|
|
34507
|
+
function deterministicStringify(obj, replacer, spacer, options) {
|
|
34508
|
+
if (typeof options === "undefined") {
|
|
34509
|
+
options = defaultOptions();
|
|
34510
|
+
}
|
|
34511
|
+
var tmp = deterministicDecirc(obj, "", 0, [], void 0, 0, options) || obj;
|
|
34512
|
+
var res;
|
|
34513
|
+
try {
|
|
34514
|
+
if (replacerStack.length === 0) {
|
|
34515
|
+
res = JSON.stringify(tmp, replacer, spacer);
|
|
34516
|
+
} else {
|
|
34517
|
+
res = JSON.stringify(tmp, replaceGetterValues(replacer), spacer);
|
|
34518
|
+
}
|
|
34519
|
+
} catch (_) {
|
|
34520
|
+
return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]");
|
|
34521
|
+
} finally {
|
|
34522
|
+
while (arr.length !== 0) {
|
|
34523
|
+
var part = arr.pop();
|
|
34524
|
+
if (part.length === 4) {
|
|
34525
|
+
Object.defineProperty(part[0], part[1], part[3]);
|
|
34526
|
+
} else {
|
|
34527
|
+
part[0][part[1]] = part[2];
|
|
34528
|
+
}
|
|
34529
|
+
}
|
|
34530
|
+
}
|
|
34531
|
+
return res;
|
|
34532
|
+
}
|
|
34533
|
+
function deterministicDecirc(val, k, edgeIndex, stack, parent, depth, options) {
|
|
34534
|
+
depth += 1;
|
|
34535
|
+
var i;
|
|
34536
|
+
if (typeof val === "object" && val !== null) {
|
|
34537
|
+
for (i = 0; i < stack.length; i++) {
|
|
34538
|
+
if (stack[i] === val) {
|
|
34539
|
+
setReplace(CIRCULAR_REPLACE_NODE, val, k, parent);
|
|
34540
|
+
return;
|
|
34541
|
+
}
|
|
34542
|
+
}
|
|
34543
|
+
try {
|
|
34544
|
+
if (typeof val.toJSON === "function") {
|
|
34545
|
+
return;
|
|
34546
|
+
}
|
|
34547
|
+
} catch (_) {
|
|
34548
|
+
return;
|
|
34549
|
+
}
|
|
34550
|
+
if (typeof options.depthLimit !== "undefined" && depth > options.depthLimit) {
|
|
34551
|
+
setReplace(LIMIT_REPLACE_NODE, val, k, parent);
|
|
34552
|
+
return;
|
|
34553
|
+
}
|
|
34554
|
+
if (typeof options.edgesLimit !== "undefined" && edgeIndex + 1 > options.edgesLimit) {
|
|
34555
|
+
setReplace(LIMIT_REPLACE_NODE, val, k, parent);
|
|
34556
|
+
return;
|
|
34557
|
+
}
|
|
34558
|
+
stack.push(val);
|
|
34559
|
+
if (Array.isArray(val)) {
|
|
34560
|
+
for (i = 0; i < val.length; i++) {
|
|
34561
|
+
deterministicDecirc(val[i], i, i, stack, val, depth, options);
|
|
34562
|
+
}
|
|
34563
|
+
} else {
|
|
34564
|
+
var tmp = {};
|
|
34565
|
+
var keys = Object.keys(val).sort(compareFunction);
|
|
34566
|
+
for (i = 0; i < keys.length; i++) {
|
|
34567
|
+
var key = keys[i];
|
|
34568
|
+
deterministicDecirc(val[key], key, i, stack, val, depth, options);
|
|
34569
|
+
tmp[key] = val[key];
|
|
34570
|
+
}
|
|
34571
|
+
if (typeof parent !== "undefined") {
|
|
34572
|
+
arr.push([parent, k, val]);
|
|
34573
|
+
parent[k] = tmp;
|
|
34574
|
+
} else {
|
|
34575
|
+
return tmp;
|
|
34576
|
+
}
|
|
34577
|
+
}
|
|
34578
|
+
stack.pop();
|
|
34579
|
+
}
|
|
34580
|
+
}
|
|
34581
|
+
function replaceGetterValues(replacer) {
|
|
34582
|
+
replacer = typeof replacer !== "undefined" ? replacer : function(k, v) {
|
|
34583
|
+
return v;
|
|
34584
|
+
};
|
|
34585
|
+
return function(key, val) {
|
|
34586
|
+
if (replacerStack.length > 0) {
|
|
34587
|
+
for (var i = 0; i < replacerStack.length; i++) {
|
|
34588
|
+
var part = replacerStack[i];
|
|
34589
|
+
if (part[1] === key && part[0] === val) {
|
|
34590
|
+
val = part[2];
|
|
34591
|
+
replacerStack.splice(i, 1);
|
|
34592
|
+
break;
|
|
34593
|
+
}
|
|
34594
|
+
}
|
|
34595
|
+
}
|
|
34596
|
+
return replacer.call(this, key, val);
|
|
34597
|
+
};
|
|
34598
|
+
}
|
|
34599
|
+
}
|
|
34600
|
+
});
|
|
34601
|
+
|
|
32601
34602
|
// ../../node_modules/ws/browser.js
|
|
32602
34603
|
var require_browser2 = __commonJS({
|
|
32603
34604
|
"../../node_modules/ws/browser.js"(exports, module) {
|
|
@@ -32718,8 +34719,8 @@ var MetaMaskSDK = (() => {
|
|
|
32718
34719
|
r6 = Math.max(r6, u2), n5 = Math.max(n5, c2), o4[h5] = new Array(u2);
|
|
32719
34720
|
for (var l2 = 0; l2 < o4[h5].length; l2 += 1) o4[h5][l2] = 255 & t6.getBuffer()[l2 + i6];
|
|
32720
34721
|
i6 += u2;
|
|
32721
|
-
var
|
|
32722
|
-
for (s3[h5] = new Array(
|
|
34722
|
+
var g3 = a.getErrorCorrectPolynomial(c2), f2 = d(o4[h5], g3.getLength() - 1).mod(g3);
|
|
34723
|
+
for (s3[h5] = new Array(g3.getLength() - 1), l2 = 0; l2 < s3[h5].length; l2 += 1) {
|
|
32723
34724
|
var w2 = l2 + f2.getLength() - s3[h5].length;
|
|
32724
34725
|
s3[h5][l2] = w2 >= 0 ? f2.getAt(w2) : 0;
|
|
32725
34726
|
}
|
|
@@ -32739,7 +34740,7 @@ var MetaMaskSDK = (() => {
|
|
|
32739
34740
|
i5 = l(t5);
|
|
32740
34741
|
break;
|
|
32741
34742
|
case "Alphanumeric":
|
|
32742
|
-
i5 =
|
|
34743
|
+
i5 = g2(t5);
|
|
32743
34744
|
break;
|
|
32744
34745
|
case "Byte":
|
|
32745
34746
|
i5 = f(t5);
|
|
@@ -33078,7 +35079,7 @@ var MetaMaskSDK = (() => {
|
|
|
33078
35079
|
throw "illegal char :" + t5;
|
|
33079
35080
|
};
|
|
33080
35081
|
return i4;
|
|
33081
|
-
},
|
|
35082
|
+
}, g2 = function(t4) {
|
|
33082
35083
|
var e4 = t4, i4 = { getMode: function() {
|
|
33083
35084
|
return 2;
|
|
33084
35085
|
}, getLength: function(t5) {
|
|
@@ -33208,10 +35209,10 @@ var MetaMaskSDK = (() => {
|
|
|
33208
35209
|
d3 > 0 && h4.writeByte(u2);
|
|
33209
35210
|
} });
|
|
33210
35211
|
l2.write(e6, r6);
|
|
33211
|
-
var
|
|
33212
|
-
for (
|
|
33213
|
-
var w2 = String.fromCharCode(n4[
|
|
33214
|
-
|
|
35212
|
+
var g3 = 0, f2 = String.fromCharCode(n4[g3]);
|
|
35213
|
+
for (g3 += 1; g3 < n4.length; ) {
|
|
35214
|
+
var w2 = String.fromCharCode(n4[g3]);
|
|
35215
|
+
g3 += 1, o4.contains(f2 + w2) ? f2 += w2 : (l2.write(o4.indexOf(f2), r6), o4.size() < 4095 && (o4.size() == 1 << r6 && (r6 += 1), o4.add(f2 + w2)), f2 = w2);
|
|
33215
35216
|
}
|
|
33216
35217
|
return l2.write(o4.indexOf(f2), r6), l2.write(i6, r6), l2.flush(), c2.toByteArray();
|
|
33217
35218
|
}, a3 = function() {
|
|
@@ -33496,7 +35497,7 @@ var MetaMaskSDK = (() => {
|
|
|
33496
35497
|
this._basicSquare({ x: t3, y: e3, size: i2, rotation: r2 });
|
|
33497
35498
|
}
|
|
33498
35499
|
}
|
|
33499
|
-
const
|
|
35500
|
+
const g2 = "circle", f = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]], w = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]];
|
|
33500
35501
|
class p {
|
|
33501
35502
|
constructor(t3, e3) {
|
|
33502
35503
|
this._roundSize = (t4) => this._options.dotsOptions.roundSize ? Math.floor(t4) : t4, this._window = e3, this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "svg"), this._element.setAttribute("width", String(t3.width)), this._element.setAttribute("height", String(t3.height)), this._element.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink"), t3.dotsOptions.roundSize || this._element.setAttribute("shape-rendering", "crispEdges"), this._element.setAttribute("viewBox", `0 0 ${t3.width} ${t3.height}`), this._defs = this._window.document.createElementNS("http://www.w3.org/2000/svg", "defs"), this._element.appendChild(this._defs), this._imageUri = t3.image, this._instanceId = p.instanceCount++, this._options = t3;
|
|
@@ -33512,7 +35513,7 @@ var MetaMaskSDK = (() => {
|
|
|
33512
35513
|
}
|
|
33513
35514
|
drawQR(t3) {
|
|
33514
35515
|
return __async(this, null, function* () {
|
|
33515
|
-
const e3 = t3.getModuleCount(), i2 = Math.min(this._options.width, this._options.height) - 2 * this._options.margin, r2 = this._options.shape ===
|
|
35516
|
+
const e3 = t3.getModuleCount(), i2 = Math.min(this._options.width, this._options.height) - 2 * this._options.margin, r2 = this._options.shape === g2 ? i2 / Math.sqrt(2) : i2, n2 = this._roundSize(r2 / e3);
|
|
33516
35517
|
let s2 = { hideXDots: 0, hideYDots: 0, width: 0, height: 0 };
|
|
33517
35518
|
if (this._qr = t3, this._options.image) {
|
|
33518
35519
|
if (yield this.loadImage(), !this._image) return;
|
|
@@ -33547,10 +35548,10 @@ var MetaMaskSDK = (() => {
|
|
|
33547
35548
|
if (!this._qr) throw "QR code is not defined";
|
|
33548
35549
|
const r2 = this._options, n2 = this._qr.getModuleCount();
|
|
33549
35550
|
if (n2 > r2.width || n2 > r2.height) throw "The canvas is too small.";
|
|
33550
|
-
const o2 = Math.min(r2.width, r2.height) - 2 * r2.margin, a2 = r2.shape ===
|
|
35551
|
+
const o2 = Math.min(r2.width, r2.height) - 2 * r2.margin, a2 = r2.shape === g2 ? o2 / Math.sqrt(2) : o2, h3 = this._roundSize(a2 / n2), d2 = this._roundSize((r2.width - n2 * h3) / 2), u2 = this._roundSize((r2.height - n2 * h3) / 2), c2 = new s({ svg: this._element, type: r2.dotsOptions.type, window: this._window });
|
|
33551
35552
|
this._dotsClipPath = this._window.document.createElementNS("http://www.w3.org/2000/svg", "clipPath"), this._dotsClipPath.setAttribute("id", `clip-path-dot-color-${this._instanceId}`), this._defs.appendChild(this._dotsClipPath), this._createColor({ options: null === (e3 = r2.dotsOptions) || void 0 === e3 ? void 0 : e3.gradient, color: r2.dotsOptions.color, additionalRotation: 0, x: 0, y: 0, height: r2.height, width: r2.width, name: `dot-color-${this._instanceId}` });
|
|
33552
35553
|
for (let e4 = 0; e4 < n2; e4++) for (let r3 = 0; r3 < n2; r3++) t3 && !t3(e4, r3) || (null === (i2 = this._qr) || void 0 === i2 ? void 0 : i2.isDark(e4, r3)) && (c2.draw(d2 + r3 * h3, u2 + e4 * h3, h3, ((i3, o3) => !(r3 + i3 < 0 || e4 + o3 < 0 || r3 + i3 >= n2 || e4 + o3 >= n2) && !(t3 && !t3(e4 + o3, r3 + i3)) && !!this._qr && this._qr.isDark(e4 + o3, r3 + i3))), c2._element && this._dotsClipPath && this._dotsClipPath.appendChild(c2._element));
|
|
33553
|
-
if (r2.shape ===
|
|
35554
|
+
if (r2.shape === g2) {
|
|
33554
35555
|
const t4 = this._roundSize((o2 / h3 - n2) / 2), e4 = n2 + 2 * t4, i3 = d2 - t4 * h3, r3 = u2 - t4 * h3, s2 = [], a3 = this._roundSize(e4 / 2);
|
|
33555
35556
|
for (let i4 = 0; i4 < e4; i4++) {
|
|
33556
35557
|
s2[i4] = [];
|
|
@@ -33566,12 +35567,12 @@ var MetaMaskSDK = (() => {
|
|
|
33566
35567
|
if (!this._qr) throw "QR code is not defined";
|
|
33567
35568
|
const t3 = this._element, e3 = this._options;
|
|
33568
35569
|
if (!t3) throw "Element code is not defined";
|
|
33569
|
-
const i2 = this._qr.getModuleCount(), r2 = Math.min(e3.width, e3.height) - 2 * e3.margin, n2 = e3.shape ===
|
|
35570
|
+
const i2 = this._qr.getModuleCount(), r2 = Math.min(e3.width, e3.height) - 2 * e3.margin, n2 = e3.shape === g2 ? r2 / Math.sqrt(2) : r2, o2 = this._roundSize(n2 / i2), a2 = 7 * o2, u2 = 3 * o2, p2 = this._roundSize((e3.width - i2 * o2) / 2), v2 = this._roundSize((e3.height - i2 * o2) / 2);
|
|
33570
35571
|
[[0, 0, 0], [1, 0, Math.PI / 2], [0, 1, -Math.PI / 2]].forEach((([t4, r3, n3]) => {
|
|
33571
|
-
var
|
|
35572
|
+
var g3, _2, m2, b2, y2, x2, S2, C2, A2, M2, $2, O, D, k;
|
|
33572
35573
|
const z = p2 + t4 * o2 * (i2 - 7), B = v2 + r3 * o2 * (i2 - 7);
|
|
33573
35574
|
let P = this._dotsClipPath, I = this._dotsClipPath;
|
|
33574
|
-
if (((null === (
|
|
35575
|
+
if (((null === (g3 = e3.cornersSquareOptions) || void 0 === g3 ? void 0 : g3.gradient) || (null === (_2 = e3.cornersSquareOptions) || void 0 === _2 ? void 0 : _2.color)) && (P = this._window.document.createElementNS("http://www.w3.org/2000/svg", "clipPath"), P.setAttribute("id", `clip-path-corners-square-color-${t4}-${r3}-${this._instanceId}`), this._defs.appendChild(P), this._cornersSquareClipPath = this._cornersDotClipPath = I = P, this._createColor({ options: null === (m2 = e3.cornersSquareOptions) || void 0 === m2 ? void 0 : m2.gradient, color: null === (b2 = e3.cornersSquareOptions) || void 0 === b2 ? void 0 : b2.color, additionalRotation: n3, x: z, y: B, height: a2, width: a2, name: `corners-square-color-${t4}-${r3}-${this._instanceId}` })), (null === (y2 = e3.cornersSquareOptions) || void 0 === y2 ? void 0 : y2.type) && h2.includes(e3.cornersSquareOptions.type)) {
|
|
33575
35576
|
const t5 = new d({ svg: this._element, type: e3.cornersSquareOptions.type, window: this._window });
|
|
33576
35577
|
t5.draw(z, B, a2, n3), t5._element && P && P.appendChild(t5._element);
|
|
33577
35578
|
} else {
|
|
@@ -33639,8 +35640,8 @@ var MetaMaskSDK = (() => {
|
|
|
33639
35640
|
if ("radial" === t3.type) e4 = this._window.document.createElementNS("http://www.w3.org/2000/svg", "radialGradient"), e4.setAttribute("id", a2), e4.setAttribute("gradientUnits", "userSpaceOnUse"), e4.setAttribute("fx", String(r2 + s2 / 2)), e4.setAttribute("fy", String(n2 + o2 / 2)), e4.setAttribute("cx", String(r2 + s2 / 2)), e4.setAttribute("cy", String(n2 + o2 / 2)), e4.setAttribute("r", String(h3 / 2));
|
|
33640
35641
|
else {
|
|
33641
35642
|
const h4 = ((t3.rotation || 0) + i2) % (2 * Math.PI), d3 = (h4 + 2 * Math.PI) % (2 * Math.PI);
|
|
33642
|
-
let u2 = r2 + s2 / 2, c2 = n2 + o2 / 2, l2 = r2 + s2 / 2,
|
|
33643
|
-
d3 >= 0 && d3 <= 0.25 * Math.PI || d3 > 1.75 * Math.PI && d3 <= 2 * Math.PI ? (u2 -= s2 / 2, c2 -= o2 / 2 * Math.tan(h4), l2 += s2 / 2,
|
|
35643
|
+
let u2 = r2 + s2 / 2, c2 = n2 + o2 / 2, l2 = r2 + s2 / 2, g3 = n2 + o2 / 2;
|
|
35644
|
+
d3 >= 0 && d3 <= 0.25 * Math.PI || d3 > 1.75 * Math.PI && d3 <= 2 * Math.PI ? (u2 -= s2 / 2, c2 -= o2 / 2 * Math.tan(h4), l2 += s2 / 2, g3 += o2 / 2 * Math.tan(h4)) : d3 > 0.25 * Math.PI && d3 <= 0.75 * Math.PI ? (c2 -= o2 / 2, u2 -= s2 / 2 / Math.tan(h4), g3 += o2 / 2, l2 += s2 / 2 / Math.tan(h4)) : d3 > 0.75 * Math.PI && d3 <= 1.25 * Math.PI ? (u2 += s2 / 2, c2 += o2 / 2 * Math.tan(h4), l2 -= s2 / 2, g3 -= o2 / 2 * Math.tan(h4)) : d3 > 1.25 * Math.PI && d3 <= 1.75 * Math.PI && (c2 += o2 / 2, u2 += s2 / 2 / Math.tan(h4), g3 -= o2 / 2, l2 -= s2 / 2 / Math.tan(h4)), e4 = this._window.document.createElementNS("http://www.w3.org/2000/svg", "linearGradient"), e4.setAttribute("id", a2), e4.setAttribute("gradientUnits", "userSpaceOnUse"), e4.setAttribute("x1", String(Math.round(u2))), e4.setAttribute("y1", String(Math.round(c2))), e4.setAttribute("x2", String(Math.round(l2))), e4.setAttribute("y2", String(Math.round(g3)));
|
|
33644
35645
|
}
|
|
33645
35646
|
t3.colorStops.forEach((({ offset: t4, color: i3 }) => {
|
|
33646
35647
|
const r3 = this._window.document.createElementNS("http://www.w3.org/2000/svg", "stop");
|
|
@@ -35459,11 +37460,6 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
35459
37460
|
`[UI: InstallModal-nodejs()] \u274C Error generating new QR code: ${error}`
|
|
35460
37461
|
);
|
|
35461
37462
|
}
|
|
35462
|
-
} else {
|
|
35463
|
-
const generateQRCode = yield this.options.generateQRCode(
|
|
35464
|
-
currentConnectionRequest
|
|
35465
|
-
);
|
|
35466
|
-
this.renderQRCode(generateQRCode, currentConnectionRequest);
|
|
35467
37463
|
}
|
|
35468
37464
|
}), 1e3);
|
|
35469
37465
|
}
|
|
@@ -35693,7 +37689,7 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
35693
37689
|
StoreClient: () => StoreClient,
|
|
35694
37690
|
TransportType: () => TransportType,
|
|
35695
37691
|
createLogger: () => createLogger,
|
|
35696
|
-
|
|
37692
|
+
createMultichainClient: () => createMultichainClient,
|
|
35697
37693
|
enableDebug: () => enableDebug,
|
|
35698
37694
|
getInfuraRpcUrls: () => getInfuraRpcUrls,
|
|
35699
37695
|
getPlatformType: () => getPlatformType,
|
|
@@ -35708,6 +37704,13 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
35708
37704
|
isSecure: () => isSecure
|
|
35709
37705
|
});
|
|
35710
37706
|
|
|
37707
|
+
// src/polyfills/buffer-shim.ts
|
|
37708
|
+
var import_buffer = __toESM(require_buffer());
|
|
37709
|
+
var g = typeof globalThis !== "undefined" ? globalThis : typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : {};
|
|
37710
|
+
if (!g.Buffer) {
|
|
37711
|
+
g.Buffer = import_buffer.Buffer;
|
|
37712
|
+
}
|
|
37713
|
+
|
|
35711
37714
|
// ../../node_modules/openapi-fetch/dist/index.js
|
|
35712
37715
|
var PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
35713
37716
|
var supportsRequestInitExt = () => {
|
|
@@ -36189,13 +38192,17 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
36189
38192
|
return url;
|
|
36190
38193
|
}
|
|
36191
38194
|
|
|
36192
|
-
// ../analytics/
|
|
38195
|
+
// ../analytics/dist/index.mjs
|
|
36193
38196
|
var Sender = class {
|
|
36194
38197
|
constructor(options) {
|
|
36195
|
-
this
|
|
36196
|
-
this
|
|
36197
|
-
this
|
|
36198
|
-
this
|
|
38198
|
+
__publicField(this, "sendFn");
|
|
38199
|
+
__publicField(this, "batch", []);
|
|
38200
|
+
__publicField(this, "batchSize");
|
|
38201
|
+
__publicField(this, "baseTimeoutMs");
|
|
38202
|
+
__publicField(this, "currentTimeoutMs");
|
|
38203
|
+
__publicField(this, "maxTimeoutMs", 3e4);
|
|
38204
|
+
__publicField(this, "timeoutId", null);
|
|
38205
|
+
__publicField(this, "isSending", false);
|
|
36199
38206
|
this.batchSize = options.batchSize;
|
|
36200
38207
|
this.baseTimeoutMs = options.baseTimeoutMs;
|
|
36201
38208
|
this.currentTimeoutMs = options.baseTimeoutMs;
|
|
@@ -36239,12 +38246,11 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
36239
38246
|
}
|
|
36240
38247
|
};
|
|
36241
38248
|
var sender_default = Sender;
|
|
36242
|
-
|
|
36243
|
-
// ../analytics/src/analytics.ts
|
|
36244
38249
|
var Analytics = class {
|
|
36245
38250
|
constructor(baseUrl) {
|
|
36246
|
-
this
|
|
36247
|
-
this
|
|
38251
|
+
__publicField(this, "enabled", false);
|
|
38252
|
+
__publicField(this, "sender");
|
|
38253
|
+
__publicField(this, "properties", {});
|
|
36248
38254
|
const client2 = createClient({ baseUrl });
|
|
36249
38255
|
const sendFn = (batch) => __async(null, null, function* () {
|
|
36250
38256
|
const res = yield client2.POST("/v2/events", { body: batch });
|
|
@@ -36273,8 +38279,6 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
36273
38279
|
}
|
|
36274
38280
|
};
|
|
36275
38281
|
var analytics_default = Analytics;
|
|
36276
|
-
|
|
36277
|
-
// ../analytics/src/index.ts
|
|
36278
38282
|
var endpoint;
|
|
36279
38283
|
var _a;
|
|
36280
38284
|
if (typeof process !== "undefined" && process.env) {
|
|
@@ -37026,7 +39030,8 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
37026
39030
|
getValidAccounts((_g = options == null ? void 0 : options.caipAccountIds) != null ? _g : [])
|
|
37027
39031
|
);
|
|
37028
39032
|
const createSessionParams = {
|
|
37029
|
-
optionalScopes
|
|
39033
|
+
optionalScopes,
|
|
39034
|
+
sessionProperties: options == null ? void 0 : options.sessionProperties
|
|
37030
39035
|
};
|
|
37031
39036
|
const response = yield this.request(
|
|
37032
39037
|
{ method: "wallet_createSession", params: createSessionParams },
|
|
@@ -37165,6 +39170,7 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
37165
39170
|
var DEFAULT_REQUEST_TIMEOUT3 = 60 * 1e3;
|
|
37166
39171
|
var CONNECTION_GRACE_PERIOD = 60 * 1e3;
|
|
37167
39172
|
var DEFAULT_CONNECTION_TIMEOUT = DEFAULT_REQUEST_TIMEOUT3 + CONNECTION_GRACE_PERIOD;
|
|
39173
|
+
var DEFAULT_RESUME_TIMEOUT = 10 * 1e3;
|
|
37168
39174
|
var SESSION_STORE_KEY = "cache_wallet_getSession";
|
|
37169
39175
|
var ACCOUNTS_STORE_KEY = "cache_eth_accounts";
|
|
37170
39176
|
var CHAIN_STORE_KEY = "cache_eth_chainId";
|
|
@@ -37181,7 +39187,8 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
37181
39187
|
var MWPTransport = class {
|
|
37182
39188
|
constructor(dappClient, kvstore, options = {
|
|
37183
39189
|
requestTimeout: DEFAULT_REQUEST_TIMEOUT3,
|
|
37184
|
-
connectionTimeout: DEFAULT_CONNECTION_TIMEOUT
|
|
39190
|
+
connectionTimeout: DEFAULT_CONNECTION_TIMEOUT,
|
|
39191
|
+
resumeTimeout: DEFAULT_RESUME_TIMEOUT
|
|
37185
39192
|
}) {
|
|
37186
39193
|
this.dappClient = dappClient;
|
|
37187
39194
|
this.kvstore = kvstore;
|
|
@@ -37256,6 +39263,13 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
37256
39263
|
)
|
|
37257
39264
|
);
|
|
37258
39265
|
}
|
|
39266
|
+
if (message.data.method === "wallet_sessionChanged") {
|
|
39267
|
+
const notification = message.data;
|
|
39268
|
+
const response = {
|
|
39269
|
+
result: notification.params
|
|
39270
|
+
};
|
|
39271
|
+
this.kvstore.set(SESSION_STORE_KEY, JSON.stringify(response));
|
|
39272
|
+
}
|
|
37259
39273
|
this.notifyCallbacks(message.data);
|
|
37260
39274
|
}
|
|
37261
39275
|
}
|
|
@@ -37265,6 +39279,7 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
37265
39279
|
return __async(this, null, function* () {
|
|
37266
39280
|
var _a3, _b, _c, _d, _e, _f, _g;
|
|
37267
39281
|
try {
|
|
39282
|
+
yield this.waitForWalletSessionIfNotCached();
|
|
37268
39283
|
const sessionRequest = yield this.request({
|
|
37269
39284
|
method: "wallet_getSession"
|
|
37270
39285
|
});
|
|
@@ -37369,7 +39384,7 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
37369
39384
|
}
|
|
37370
39385
|
let timeout;
|
|
37371
39386
|
let initialConnectionMessageHandler;
|
|
37372
|
-
const connectionPromise = new Promise((resolve, reject) => {
|
|
39387
|
+
const connectionPromise = new Promise((resolve, reject) => __async(this, null, function* () {
|
|
37373
39388
|
let connection;
|
|
37374
39389
|
if (session) {
|
|
37375
39390
|
connection = new Promise((resumeResolve, resumeReject) => {
|
|
@@ -37392,7 +39407,8 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
37392
39407
|
getValidAccounts((_b = options == null ? void 0 : options.caipAccountIds) != null ? _b : [])
|
|
37393
39408
|
);
|
|
37394
39409
|
const sessionRequest = {
|
|
37395
|
-
optionalScopes
|
|
39410
|
+
optionalScopes,
|
|
39411
|
+
sessionProperties: options == null ? void 0 : options.sessionProperties
|
|
37396
39412
|
};
|
|
37397
39413
|
const request2 = {
|
|
37398
39414
|
jsonrpc: "2.0",
|
|
@@ -37447,7 +39463,7 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
37447
39463
|
reject(new TransportTimeoutError());
|
|
37448
39464
|
}, this.options.connectionTimeout);
|
|
37449
39465
|
connection.then(resolve).catch(reject);
|
|
37450
|
-
});
|
|
39466
|
+
}));
|
|
37451
39467
|
return connectionPromise.catch((error) => {
|
|
37452
39468
|
throw error;
|
|
37453
39469
|
}).finally(() => {
|
|
@@ -37632,6 +39648,43 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
37632
39648
|
}
|
|
37633
39649
|
});
|
|
37634
39650
|
}
|
|
39651
|
+
// This method checks if an existing CAIP session response is cached or waits for one
|
|
39652
|
+
// to be received from the wallet if not cached. This is necessary because there is an edge
|
|
39653
|
+
// case during the initial connection flow where after the user has accepted the permission approval
|
|
39654
|
+
// and returned back to the dapp from the wallet, the dapp page may have gotten unloaded and refreshed.
|
|
39655
|
+
// When it is unloaded and refreshed, it will try to resume the session by making a request for wallet_getSession
|
|
39656
|
+
// which should resolve from cache, but because a race condition makes it possible for the response from the wallet
|
|
39657
|
+
// for the initial wallet_createSession connection request to not have been handled and cached yet. This results
|
|
39658
|
+
// in the wallet_getSession request never resolving unless we wait for it explicitly as done in this method.
|
|
39659
|
+
waitForWalletSessionIfNotCached() {
|
|
39660
|
+
return __async(this, null, function* () {
|
|
39661
|
+
const cachedWalletGetSessionResponse = yield this.kvstore.get(SESSION_STORE_KEY);
|
|
39662
|
+
if (cachedWalletGetSessionResponse) {
|
|
39663
|
+
return;
|
|
39664
|
+
}
|
|
39665
|
+
let unsubscribe;
|
|
39666
|
+
const responsePromise = new Promise((resolve) => {
|
|
39667
|
+
unsubscribe = this.onNotification((message) => {
|
|
39668
|
+
if (typeof message === "object" && message !== null) {
|
|
39669
|
+
if ("data" in message) {
|
|
39670
|
+
const messagePayload = message.data;
|
|
39671
|
+
if (messagePayload.method === "wallet_getSession" || messagePayload.method === "wallet_sessionChanged") {
|
|
39672
|
+
unsubscribe();
|
|
39673
|
+
resolve();
|
|
39674
|
+
}
|
|
39675
|
+
}
|
|
39676
|
+
}
|
|
39677
|
+
});
|
|
39678
|
+
});
|
|
39679
|
+
const timeoutPromise = new Promise((_resolve, reject) => {
|
|
39680
|
+
setTimeout(() => {
|
|
39681
|
+
unsubscribe();
|
|
39682
|
+
reject(new TransportTimeoutError());
|
|
39683
|
+
}, this.options.resumeTimeout);
|
|
39684
|
+
});
|
|
39685
|
+
return Promise.race([responsePromise, timeoutPromise]);
|
|
39686
|
+
});
|
|
39687
|
+
}
|
|
37635
39688
|
};
|
|
37636
39689
|
|
|
37637
39690
|
// src/multichain/transports/mwp/KeyManager.ts
|
|
@@ -37663,9 +39716,489 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
37663
39716
|
|
|
37664
39717
|
// src/multichain/index.ts
|
|
37665
39718
|
init_utils3();
|
|
39719
|
+
|
|
39720
|
+
// ../../node_modules/@metamask/rpc-errors/dist/classes.mjs
|
|
39721
|
+
init_dist2();
|
|
39722
|
+
var import_fast_safe_stringify = __toESM(require_fast_safe_stringify(), 1);
|
|
39723
|
+
|
|
39724
|
+
// ../../node_modules/@metamask/rpc-errors/dist/utils.mjs
|
|
39725
|
+
init_dist2();
|
|
39726
|
+
|
|
39727
|
+
// ../../node_modules/@metamask/rpc-errors/dist/error-constants.mjs
|
|
39728
|
+
var errorCodes = {
|
|
39729
|
+
rpc: {
|
|
39730
|
+
invalidInput: -32e3,
|
|
39731
|
+
resourceNotFound: -32001,
|
|
39732
|
+
resourceUnavailable: -32002,
|
|
39733
|
+
transactionRejected: -32003,
|
|
39734
|
+
methodNotSupported: -32004,
|
|
39735
|
+
limitExceeded: -32005,
|
|
39736
|
+
parse: -32700,
|
|
39737
|
+
invalidRequest: -32600,
|
|
39738
|
+
methodNotFound: -32601,
|
|
39739
|
+
invalidParams: -32602,
|
|
39740
|
+
internal: -32603
|
|
39741
|
+
},
|
|
39742
|
+
provider: {
|
|
39743
|
+
userRejectedRequest: 4001,
|
|
39744
|
+
unauthorized: 4100,
|
|
39745
|
+
unsupportedMethod: 4200,
|
|
39746
|
+
disconnected: 4900,
|
|
39747
|
+
chainDisconnected: 4901
|
|
39748
|
+
}
|
|
39749
|
+
};
|
|
39750
|
+
var errorValues = {
|
|
39751
|
+
"-32700": {
|
|
39752
|
+
standard: "JSON RPC 2.0",
|
|
39753
|
+
message: "Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."
|
|
39754
|
+
},
|
|
39755
|
+
"-32600": {
|
|
39756
|
+
standard: "JSON RPC 2.0",
|
|
39757
|
+
message: "The JSON sent is not a valid Request object."
|
|
39758
|
+
},
|
|
39759
|
+
"-32601": {
|
|
39760
|
+
standard: "JSON RPC 2.0",
|
|
39761
|
+
message: "The method does not exist / is not available."
|
|
39762
|
+
},
|
|
39763
|
+
"-32602": {
|
|
39764
|
+
standard: "JSON RPC 2.0",
|
|
39765
|
+
message: "Invalid method parameter(s)."
|
|
39766
|
+
},
|
|
39767
|
+
"-32603": {
|
|
39768
|
+
standard: "JSON RPC 2.0",
|
|
39769
|
+
message: "Internal JSON-RPC error."
|
|
39770
|
+
},
|
|
39771
|
+
"-32000": {
|
|
39772
|
+
standard: "EIP-1474",
|
|
39773
|
+
message: "Invalid input."
|
|
39774
|
+
},
|
|
39775
|
+
"-32001": {
|
|
39776
|
+
standard: "EIP-1474",
|
|
39777
|
+
message: "Resource not found."
|
|
39778
|
+
},
|
|
39779
|
+
"-32002": {
|
|
39780
|
+
standard: "EIP-1474",
|
|
39781
|
+
message: "Resource unavailable."
|
|
39782
|
+
},
|
|
39783
|
+
"-32003": {
|
|
39784
|
+
standard: "EIP-1474",
|
|
39785
|
+
message: "Transaction rejected."
|
|
39786
|
+
},
|
|
39787
|
+
"-32004": {
|
|
39788
|
+
standard: "EIP-1474",
|
|
39789
|
+
message: "Method not supported."
|
|
39790
|
+
},
|
|
39791
|
+
"-32005": {
|
|
39792
|
+
standard: "EIP-1474",
|
|
39793
|
+
message: "Request limit exceeded."
|
|
39794
|
+
},
|
|
39795
|
+
"4001": {
|
|
39796
|
+
standard: "EIP-1193",
|
|
39797
|
+
message: "User rejected the request."
|
|
39798
|
+
},
|
|
39799
|
+
"4100": {
|
|
39800
|
+
standard: "EIP-1193",
|
|
39801
|
+
message: "The requested account and/or method has not been authorized by the user."
|
|
39802
|
+
},
|
|
39803
|
+
"4200": {
|
|
39804
|
+
standard: "EIP-1193",
|
|
39805
|
+
message: "The requested method is not supported by this Ethereum provider."
|
|
39806
|
+
},
|
|
39807
|
+
"4900": {
|
|
39808
|
+
standard: "EIP-1193",
|
|
39809
|
+
message: "The provider is disconnected from all chains."
|
|
39810
|
+
},
|
|
39811
|
+
"4901": {
|
|
39812
|
+
standard: "EIP-1193",
|
|
39813
|
+
message: "The provider is disconnected from the specified chain."
|
|
39814
|
+
}
|
|
39815
|
+
};
|
|
39816
|
+
|
|
39817
|
+
// ../../node_modules/@metamask/rpc-errors/dist/utils.mjs
|
|
39818
|
+
var FALLBACK_ERROR_CODE = errorCodes.rpc.internal;
|
|
39819
|
+
var FALLBACK_MESSAGE = "Unspecified error message. This is a bug, please report it.";
|
|
39820
|
+
var FALLBACK_ERROR = {
|
|
39821
|
+
code: FALLBACK_ERROR_CODE,
|
|
39822
|
+
message: getMessageFromCode(FALLBACK_ERROR_CODE)
|
|
39823
|
+
};
|
|
39824
|
+
var JSON_RPC_SERVER_ERROR_MESSAGE = "Unspecified server error.";
|
|
39825
|
+
function getMessageFromCode(code, fallbackMessage = FALLBACK_MESSAGE) {
|
|
39826
|
+
if (isValidCode(code)) {
|
|
39827
|
+
const codeString = code.toString();
|
|
39828
|
+
if (hasProperty(errorValues, codeString)) {
|
|
39829
|
+
return errorValues[codeString].message;
|
|
39830
|
+
}
|
|
39831
|
+
if (isJsonRpcServerError(code)) {
|
|
39832
|
+
return JSON_RPC_SERVER_ERROR_MESSAGE;
|
|
39833
|
+
}
|
|
39834
|
+
}
|
|
39835
|
+
return fallbackMessage;
|
|
39836
|
+
}
|
|
39837
|
+
function isValidCode(code) {
|
|
39838
|
+
return Number.isInteger(code);
|
|
39839
|
+
}
|
|
39840
|
+
function isJsonRpcServerError(code) {
|
|
39841
|
+
return code >= -32099 && code <= -32e3;
|
|
39842
|
+
}
|
|
39843
|
+
function serializeCause(error) {
|
|
39844
|
+
if (Array.isArray(error)) {
|
|
39845
|
+
return error.map((entry) => {
|
|
39846
|
+
if (isValidJson(entry)) {
|
|
39847
|
+
return entry;
|
|
39848
|
+
} else if (isObject2(entry)) {
|
|
39849
|
+
return serializeObject(entry);
|
|
39850
|
+
}
|
|
39851
|
+
return null;
|
|
39852
|
+
});
|
|
39853
|
+
} else if (isObject2(error)) {
|
|
39854
|
+
return serializeObject(error);
|
|
39855
|
+
}
|
|
39856
|
+
if (isValidJson(error)) {
|
|
39857
|
+
return error;
|
|
39858
|
+
}
|
|
39859
|
+
return null;
|
|
39860
|
+
}
|
|
39861
|
+
function serializeObject(object3) {
|
|
39862
|
+
return Object.getOwnPropertyNames(object3).reduce((acc, key) => {
|
|
39863
|
+
const value = object3[key];
|
|
39864
|
+
if (isValidJson(value)) {
|
|
39865
|
+
acc[key] = value;
|
|
39866
|
+
}
|
|
39867
|
+
return acc;
|
|
39868
|
+
}, {});
|
|
39869
|
+
}
|
|
39870
|
+
function dataHasCause(data) {
|
|
39871
|
+
return isObject2(data) && hasProperty(data, "cause") && isObject2(data.cause);
|
|
39872
|
+
}
|
|
39873
|
+
|
|
39874
|
+
// ../../node_modules/@metamask/rpc-errors/dist/classes.mjs
|
|
39875
|
+
function $importDefault(module) {
|
|
39876
|
+
if (module == null ? void 0 : module.__esModule) {
|
|
39877
|
+
return module.default;
|
|
39878
|
+
}
|
|
39879
|
+
return module;
|
|
39880
|
+
}
|
|
39881
|
+
var safeStringify = $importDefault(import_fast_safe_stringify.default);
|
|
39882
|
+
var JsonRpcError = class extends Error {
|
|
39883
|
+
constructor(code, message, data) {
|
|
39884
|
+
if (!Number.isInteger(code)) {
|
|
39885
|
+
throw new Error('"code" must be an integer.');
|
|
39886
|
+
}
|
|
39887
|
+
if (!message || typeof message !== "string") {
|
|
39888
|
+
throw new Error('"message" must be a non-empty string.');
|
|
39889
|
+
}
|
|
39890
|
+
if (dataHasCause(data)) {
|
|
39891
|
+
super(message, { cause: data.cause });
|
|
39892
|
+
if (!hasProperty(this, "cause")) {
|
|
39893
|
+
Object.assign(this, { cause: data.cause });
|
|
39894
|
+
}
|
|
39895
|
+
} else {
|
|
39896
|
+
super(message);
|
|
39897
|
+
}
|
|
39898
|
+
if (data !== void 0) {
|
|
39899
|
+
this.data = data;
|
|
39900
|
+
}
|
|
39901
|
+
this.code = code;
|
|
39902
|
+
}
|
|
39903
|
+
/**
|
|
39904
|
+
* Get the error as JSON-serializable object.
|
|
39905
|
+
*
|
|
39906
|
+
* @returns A plain object with all public class properties.
|
|
39907
|
+
*/
|
|
39908
|
+
serialize() {
|
|
39909
|
+
const serialized = {
|
|
39910
|
+
code: this.code,
|
|
39911
|
+
message: this.message
|
|
39912
|
+
};
|
|
39913
|
+
if (this.data !== void 0) {
|
|
39914
|
+
serialized.data = this.data;
|
|
39915
|
+
if (isPlainObject(this.data)) {
|
|
39916
|
+
serialized.data.cause = serializeCause(this.data.cause);
|
|
39917
|
+
}
|
|
39918
|
+
}
|
|
39919
|
+
if (this.stack) {
|
|
39920
|
+
serialized.stack = this.stack;
|
|
39921
|
+
}
|
|
39922
|
+
return serialized;
|
|
39923
|
+
}
|
|
39924
|
+
/**
|
|
39925
|
+
* Get a string representation of the serialized error, omitting any circular
|
|
39926
|
+
* references.
|
|
39927
|
+
*
|
|
39928
|
+
* @returns A string representation of the serialized error.
|
|
39929
|
+
*/
|
|
39930
|
+
toString() {
|
|
39931
|
+
return safeStringify(this.serialize(), stringifyReplacer, 2);
|
|
39932
|
+
}
|
|
39933
|
+
};
|
|
39934
|
+
var EthereumProviderError = class extends JsonRpcError {
|
|
39935
|
+
/**
|
|
39936
|
+
* Create an Ethereum Provider JSON-RPC error.
|
|
39937
|
+
*
|
|
39938
|
+
* @param code - The JSON-RPC error code. Must be an integer in the
|
|
39939
|
+
* `1000 <= n <= 4999` range.
|
|
39940
|
+
* @param message - The JSON-RPC error message.
|
|
39941
|
+
* @param data - Optional data to include in the error.
|
|
39942
|
+
*/
|
|
39943
|
+
constructor(code, message, data) {
|
|
39944
|
+
if (!isValidEthProviderCode(code)) {
|
|
39945
|
+
throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');
|
|
39946
|
+
}
|
|
39947
|
+
super(code, message, data);
|
|
39948
|
+
}
|
|
39949
|
+
};
|
|
39950
|
+
function isValidEthProviderCode(code) {
|
|
39951
|
+
return Number.isInteger(code) && code >= 1e3 && code <= 4999;
|
|
39952
|
+
}
|
|
39953
|
+
function stringifyReplacer(_, value) {
|
|
39954
|
+
if (value === "[Circular]") {
|
|
39955
|
+
return void 0;
|
|
39956
|
+
}
|
|
39957
|
+
return value;
|
|
39958
|
+
}
|
|
39959
|
+
|
|
39960
|
+
// ../../node_modules/@metamask/rpc-errors/dist/errors.mjs
|
|
39961
|
+
var providerErrors = {
|
|
39962
|
+
/**
|
|
39963
|
+
* Get an Ethereum Provider User Rejected Request (4001) error.
|
|
39964
|
+
*
|
|
39965
|
+
* @param arg - The error message or options bag.
|
|
39966
|
+
* @returns An instance of the {@link EthereumProviderError} class.
|
|
39967
|
+
*/
|
|
39968
|
+
userRejectedRequest: (arg) => {
|
|
39969
|
+
return getEthProviderError(errorCodes.provider.userRejectedRequest, arg);
|
|
39970
|
+
},
|
|
39971
|
+
/**
|
|
39972
|
+
* Get an Ethereum Provider Unauthorized (4100) error.
|
|
39973
|
+
*
|
|
39974
|
+
* @param arg - The error message or options bag.
|
|
39975
|
+
* @returns An instance of the {@link EthereumProviderError} class.
|
|
39976
|
+
*/
|
|
39977
|
+
unauthorized: (arg) => {
|
|
39978
|
+
return getEthProviderError(errorCodes.provider.unauthorized, arg);
|
|
39979
|
+
},
|
|
39980
|
+
/**
|
|
39981
|
+
* Get an Ethereum Provider Unsupported Method (4200) error.
|
|
39982
|
+
*
|
|
39983
|
+
* @param arg - The error message or options bag.
|
|
39984
|
+
* @returns An instance of the {@link EthereumProviderError} class.
|
|
39985
|
+
*/
|
|
39986
|
+
unsupportedMethod: (arg) => {
|
|
39987
|
+
return getEthProviderError(errorCodes.provider.unsupportedMethod, arg);
|
|
39988
|
+
},
|
|
39989
|
+
/**
|
|
39990
|
+
* Get an Ethereum Provider Not Connected (4900) error.
|
|
39991
|
+
*
|
|
39992
|
+
* @param arg - The error message or options bag.
|
|
39993
|
+
* @returns An instance of the {@link EthereumProviderError} class.
|
|
39994
|
+
*/
|
|
39995
|
+
disconnected: (arg) => {
|
|
39996
|
+
return getEthProviderError(errorCodes.provider.disconnected, arg);
|
|
39997
|
+
},
|
|
39998
|
+
/**
|
|
39999
|
+
* Get an Ethereum Provider Chain Not Connected (4901) error.
|
|
40000
|
+
*
|
|
40001
|
+
* @param arg - The error message or options bag.
|
|
40002
|
+
* @returns An instance of the {@link EthereumProviderError} class.
|
|
40003
|
+
*/
|
|
40004
|
+
chainDisconnected: (arg) => {
|
|
40005
|
+
return getEthProviderError(errorCodes.provider.chainDisconnected, arg);
|
|
40006
|
+
},
|
|
40007
|
+
/**
|
|
40008
|
+
* Get a custom Ethereum Provider error.
|
|
40009
|
+
*
|
|
40010
|
+
* @param opts - The error options bag.
|
|
40011
|
+
* @returns An instance of the {@link EthereumProviderError} class.
|
|
40012
|
+
*/
|
|
40013
|
+
custom: (opts) => {
|
|
40014
|
+
if (!opts || typeof opts !== "object" || Array.isArray(opts)) {
|
|
40015
|
+
throw new Error("Ethereum Provider custom errors must provide single object argument.");
|
|
40016
|
+
}
|
|
40017
|
+
const { code, message, data } = opts;
|
|
40018
|
+
if (!message || typeof message !== "string") {
|
|
40019
|
+
throw new Error('"message" must be a nonempty string');
|
|
40020
|
+
}
|
|
40021
|
+
return new EthereumProviderError(code, message, data);
|
|
40022
|
+
}
|
|
40023
|
+
};
|
|
40024
|
+
function getEthProviderError(code, arg) {
|
|
40025
|
+
const [message, data] = parseOpts(arg);
|
|
40026
|
+
return new EthereumProviderError(code, message != null ? message : getMessageFromCode(code), data);
|
|
40027
|
+
}
|
|
40028
|
+
function parseOpts(arg) {
|
|
40029
|
+
if (arg) {
|
|
40030
|
+
if (typeof arg === "string") {
|
|
40031
|
+
return [arg];
|
|
40032
|
+
} else if (typeof arg === "object" && !Array.isArray(arg)) {
|
|
40033
|
+
const { message, data } = arg;
|
|
40034
|
+
if (message && typeof message !== "string") {
|
|
40035
|
+
throw new Error("Must specify string message.");
|
|
40036
|
+
}
|
|
40037
|
+
return [message != null ? message : void 0, data];
|
|
40038
|
+
}
|
|
40039
|
+
}
|
|
40040
|
+
return [];
|
|
40041
|
+
}
|
|
40042
|
+
|
|
40043
|
+
// src/multichain/transports/multichainApiClientWrapper/index.ts
|
|
40044
|
+
var MAX2 = 4294967295;
|
|
40045
|
+
var idCounter2 = Math.floor(Math.random() * MAX2);
|
|
40046
|
+
var getUniqueId2 = () => {
|
|
40047
|
+
idCounter2 = (idCounter2 + 1) % MAX2;
|
|
40048
|
+
return idCounter2;
|
|
40049
|
+
};
|
|
40050
|
+
var _MultichainApiClientWrapperTransport_instances, walletCreateSession_fn, walletGetSession_fn, walletRevokeSession_fn, walletInvokeMethod_fn;
|
|
40051
|
+
var MultichainApiClientWrapperTransport = class {
|
|
40052
|
+
constructor(metamaskConnectMultichain) {
|
|
40053
|
+
this.metamaskConnectMultichain = metamaskConnectMultichain;
|
|
40054
|
+
__privateAdd(this, _MultichainApiClientWrapperTransport_instances);
|
|
40055
|
+
this.requestId = getUniqueId2();
|
|
40056
|
+
this.notificationCallbacks = /* @__PURE__ */ new Set();
|
|
40057
|
+
}
|
|
40058
|
+
isTransportDefined() {
|
|
40059
|
+
try {
|
|
40060
|
+
return Boolean(this.metamaskConnectMultichain.transport);
|
|
40061
|
+
} catch (error) {
|
|
40062
|
+
return false;
|
|
40063
|
+
}
|
|
40064
|
+
}
|
|
40065
|
+
clearNotificationCallbacks() {
|
|
40066
|
+
this.notificationCallbacks.clear();
|
|
40067
|
+
}
|
|
40068
|
+
notifyCallbacks(data) {
|
|
40069
|
+
this.notificationCallbacks.forEach((callback) => {
|
|
40070
|
+
callback(data);
|
|
40071
|
+
});
|
|
40072
|
+
}
|
|
40073
|
+
setupNotifcationListener() {
|
|
40074
|
+
this.metamaskConnectMultichain.transport.onNotification(
|
|
40075
|
+
this.notifyCallbacks.bind(this)
|
|
40076
|
+
);
|
|
40077
|
+
}
|
|
40078
|
+
connect() {
|
|
40079
|
+
return __async(this, null, function* () {
|
|
40080
|
+
console.log("\u{1F4DA} connect");
|
|
40081
|
+
return Promise.resolve();
|
|
40082
|
+
});
|
|
40083
|
+
}
|
|
40084
|
+
disconnect() {
|
|
40085
|
+
return __async(this, null, function* () {
|
|
40086
|
+
return Promise.resolve();
|
|
40087
|
+
});
|
|
40088
|
+
}
|
|
40089
|
+
isConnected() {
|
|
40090
|
+
return true;
|
|
40091
|
+
}
|
|
40092
|
+
request(_0) {
|
|
40093
|
+
return __async(this, arguments, function* (params, _options = {}) {
|
|
40094
|
+
const id = this.requestId++;
|
|
40095
|
+
const requestPayload = __spreadValues({
|
|
40096
|
+
id,
|
|
40097
|
+
jsonrpc: "2.0"
|
|
40098
|
+
}, params);
|
|
40099
|
+
switch (requestPayload.method) {
|
|
40100
|
+
case "wallet_createSession":
|
|
40101
|
+
return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletCreateSession_fn).call(this, requestPayload);
|
|
40102
|
+
case "wallet_getSession":
|
|
40103
|
+
return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletGetSession_fn).call(this, requestPayload);
|
|
40104
|
+
case "wallet_revokeSession":
|
|
40105
|
+
return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletRevokeSession_fn).call(this, requestPayload);
|
|
40106
|
+
case "wallet_invokeMethod":
|
|
40107
|
+
return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletInvokeMethod_fn).call(this, requestPayload);
|
|
40108
|
+
default:
|
|
40109
|
+
throw new Error(`Unsupported method: ${requestPayload.method}`);
|
|
40110
|
+
}
|
|
40111
|
+
throw new Error(`Unknown method: ${requestPayload.method}`);
|
|
40112
|
+
});
|
|
40113
|
+
}
|
|
40114
|
+
onNotification(callback) {
|
|
40115
|
+
if (!this.isTransportDefined()) {
|
|
40116
|
+
this.notificationCallbacks.add(callback);
|
|
40117
|
+
return () => {
|
|
40118
|
+
this.notificationCallbacks.delete(callback);
|
|
40119
|
+
};
|
|
40120
|
+
}
|
|
40121
|
+
return this.metamaskConnectMultichain.transport.onNotification(callback);
|
|
40122
|
+
}
|
|
40123
|
+
};
|
|
40124
|
+
_MultichainApiClientWrapperTransport_instances = new WeakSet();
|
|
40125
|
+
walletCreateSession_fn = function(request2) {
|
|
40126
|
+
return __async(this, null, function* () {
|
|
40127
|
+
console.log("\u{1F4DA} #walletCreateSession", request2);
|
|
40128
|
+
const createSessionParams = request2.params;
|
|
40129
|
+
const scopes = Object.keys(__spreadValues(__spreadValues({}, createSessionParams.optionalScopes), createSessionParams.requiredScopes));
|
|
40130
|
+
const scopeAccounts = [];
|
|
40131
|
+
scopes.forEach((scope) => {
|
|
40132
|
+
var _a3, _b, _c, _d;
|
|
40133
|
+
const requiredScope = (_a3 = createSessionParams.requiredScopes) == null ? void 0 : _a3[scope];
|
|
40134
|
+
const optionalScope = (_b = createSessionParams.optionalScopes) == null ? void 0 : _b[scope];
|
|
40135
|
+
if (requiredScope) {
|
|
40136
|
+
scopeAccounts.push(...(_c = requiredScope.accounts) != null ? _c : []);
|
|
40137
|
+
}
|
|
40138
|
+
if (optionalScope) {
|
|
40139
|
+
scopeAccounts.push(...(_d = optionalScope.accounts) != null ? _d : []);
|
|
40140
|
+
}
|
|
40141
|
+
});
|
|
40142
|
+
const accounts = [...new Set(scopeAccounts)];
|
|
40143
|
+
console.log("\u{1F4DA} SDK connect");
|
|
40144
|
+
yield this.metamaskConnectMultichain.connect(
|
|
40145
|
+
scopes,
|
|
40146
|
+
accounts,
|
|
40147
|
+
createSessionParams.sessionProperties
|
|
40148
|
+
);
|
|
40149
|
+
console.log("\u{1F4DA} SDK connected");
|
|
40150
|
+
return this.metamaskConnectMultichain.transport.request({
|
|
40151
|
+
method: "wallet_getSession"
|
|
40152
|
+
});
|
|
40153
|
+
});
|
|
40154
|
+
};
|
|
40155
|
+
walletGetSession_fn = function(request2) {
|
|
40156
|
+
return __async(this, null, function* () {
|
|
40157
|
+
if (!this.isTransportDefined()) {
|
|
40158
|
+
return {
|
|
40159
|
+
jsonrpc: "2.0",
|
|
40160
|
+
id: request2.id,
|
|
40161
|
+
result: {
|
|
40162
|
+
sessionScopes: {}
|
|
40163
|
+
}
|
|
40164
|
+
};
|
|
40165
|
+
}
|
|
40166
|
+
return this.metamaskConnectMultichain.transport.request({
|
|
40167
|
+
method: "wallet_getSession"
|
|
40168
|
+
});
|
|
40169
|
+
});
|
|
40170
|
+
};
|
|
40171
|
+
walletRevokeSession_fn = function(request2) {
|
|
40172
|
+
return __async(this, null, function* () {
|
|
40173
|
+
if (!this.isTransportDefined()) {
|
|
40174
|
+
return { jsonrpc: "2.0", id: request2.id, result: true };
|
|
40175
|
+
}
|
|
40176
|
+
try {
|
|
40177
|
+
this.metamaskConnectMultichain.disconnect();
|
|
40178
|
+
return { jsonrpc: "2.0", id: request2.id, result: true };
|
|
40179
|
+
} catch (error) {
|
|
40180
|
+
return { jsonrpc: "2.0", id: request2.id, result: false };
|
|
40181
|
+
}
|
|
40182
|
+
});
|
|
40183
|
+
};
|
|
40184
|
+
walletInvokeMethod_fn = function(request2) {
|
|
40185
|
+
return __async(this, null, function* () {
|
|
40186
|
+
if (!this.isTransportDefined()) {
|
|
40187
|
+
return { error: providerErrors.unauthorized() };
|
|
40188
|
+
}
|
|
40189
|
+
const result = this.metamaskConnectMultichain.invokeMethod(
|
|
40190
|
+
request2.params
|
|
40191
|
+
);
|
|
40192
|
+
return {
|
|
40193
|
+
result
|
|
40194
|
+
};
|
|
40195
|
+
});
|
|
40196
|
+
};
|
|
40197
|
+
|
|
40198
|
+
// src/multichain/index.ts
|
|
37666
40199
|
var logger2 = createLogger("metamask-sdk:core");
|
|
37667
|
-
var _a2, _provider, _transport2, _dappClient, _beforeUnloadListener, _listener, _sdkInfo,
|
|
37668
|
-
var
|
|
40200
|
+
var _a2, _provider, _providerTransportWrapper, _transport2, _dappClient, _beforeUnloadListener, _listener, _sdkInfo, _MetaMaskConnectMultichain_instances, setupAnalytics_fn, onTransportNotification_fn, getStoredTransport_fn, setupTransport_fn, init_fn, createDappClient_fn, setupMWP_fn, onBeforeUnload_fn, createBeforeUnloadListener_fn, renderInstallModalAsync_fn, showInstallModal_fn, headlessConnect_fn, setupDefaultTransport_fn, deeplinkConnect_fn, handleConnection_fn;
|
|
40201
|
+
var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends MultichainCore {
|
|
37669
40202
|
constructor(options) {
|
|
37670
40203
|
var _a3, _b, _c, _d, _e, _f;
|
|
37671
40204
|
const withDappMetadata = setupDappMetadata(options);
|
|
@@ -37681,34 +40214,30 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
37681
40214
|
})
|
|
37682
40215
|
});
|
|
37683
40216
|
super(allOptions);
|
|
37684
|
-
__privateAdd(this,
|
|
40217
|
+
__privateAdd(this, _MetaMaskConnectMultichain_instances);
|
|
37685
40218
|
__privateAdd(this, _provider);
|
|
40219
|
+
__privateAdd(this, _providerTransportWrapper);
|
|
37686
40220
|
__privateAdd(this, _transport2);
|
|
37687
40221
|
__privateAdd(this, _dappClient);
|
|
37688
40222
|
__privateAdd(this, _beforeUnloadListener);
|
|
37689
|
-
this.
|
|
40223
|
+
this._status = "pending";
|
|
37690
40224
|
__privateAdd(this, _listener);
|
|
37691
40225
|
__privateAdd(this, _sdkInfo, `Sdk/Javascript SdkVersion/${getVersion()} Platform/${getPlatformType()} dApp/${(_a2 = this.options.dapp.url) != null ? _a2 : this.options.dapp.name} dAppTitle/${this.options.dapp.name}`);
|
|
40226
|
+
__privateSet(this, _providerTransportWrapper, new MultichainApiClientWrapperTransport(this));
|
|
40227
|
+
__privateSet(this, _provider, getMultichainClient({ transport: __privateGet(this, _providerTransportWrapper) }));
|
|
37692
40228
|
}
|
|
37693
|
-
get
|
|
37694
|
-
return this.
|
|
40229
|
+
get status() {
|
|
40230
|
+
return this._status;
|
|
37695
40231
|
}
|
|
37696
|
-
set
|
|
40232
|
+
set status(value) {
|
|
37697
40233
|
var _a3, _b;
|
|
37698
|
-
this.
|
|
40234
|
+
this._status = value;
|
|
37699
40235
|
(_b = (_a3 = this.options.transport) == null ? void 0 : _a3.onNotification) == null ? void 0 : _b.call(_a3, {
|
|
37700
40236
|
method: "stateChanged",
|
|
37701
40237
|
params: value
|
|
37702
40238
|
});
|
|
37703
40239
|
}
|
|
37704
40240
|
get provider() {
|
|
37705
|
-
if (!__privateGet(this, _provider) && __privateGet(this, _transport2)) {
|
|
37706
|
-
__privateSet(this, _provider, getMultichainClient({ transport: __privateGet(this, _transport2) }));
|
|
37707
|
-
return __privateGet(this, _provider);
|
|
37708
|
-
}
|
|
37709
|
-
if (!__privateGet(this, _provider)) {
|
|
37710
|
-
throw new Error("Provider not initialized, establish connection first");
|
|
37711
|
-
}
|
|
37712
40241
|
return __privateGet(this, _provider);
|
|
37713
40242
|
}
|
|
37714
40243
|
get transport() {
|
|
@@ -37732,7 +40261,7 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
37732
40261
|
static create(options) {
|
|
37733
40262
|
return __async(this, null, function* () {
|
|
37734
40263
|
var _a3;
|
|
37735
|
-
const instance2 = new
|
|
40264
|
+
const instance2 = new _MetaMaskConnectMultichain(options);
|
|
37736
40265
|
const isEnabled2 = yield isEnabled(
|
|
37737
40266
|
"metamask-sdk:core",
|
|
37738
40267
|
instance2.options.storage
|
|
@@ -37740,14 +40269,15 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
37740
40269
|
if (isEnabled2) {
|
|
37741
40270
|
enableDebug("metamask-sdk:core");
|
|
37742
40271
|
}
|
|
37743
|
-
yield __privateMethod(_a3 = instance2,
|
|
40272
|
+
yield __privateMethod(_a3 = instance2, _MetaMaskConnectMultichain_instances, init_fn).call(_a3);
|
|
37744
40273
|
return instance2;
|
|
37745
40274
|
});
|
|
37746
40275
|
}
|
|
37747
|
-
|
|
40276
|
+
// TODO: make this into param object
|
|
40277
|
+
connect(scopes, caipAccountIds, sessionProperties, forceRequest) {
|
|
37748
40278
|
return __async(this, null, function* () {
|
|
37749
40279
|
var _a3;
|
|
37750
|
-
if (this.
|
|
40280
|
+
if (this.status !== "connected") {
|
|
37751
40281
|
yield this.disconnect();
|
|
37752
40282
|
}
|
|
37753
40283
|
const { ui } = this.options;
|
|
@@ -37779,7 +40309,7 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
37779
40309
|
logger2("Error tracking connection_initiated event", error);
|
|
37780
40310
|
}
|
|
37781
40311
|
if (((_a3 = __privateGet(this, _transport2)) == null ? void 0 : _a3.isConnected()) && !secure) {
|
|
37782
|
-
return __privateMethod(this,
|
|
40312
|
+
return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, __privateGet(this, _transport2).connect({ scopes, caipAccountIds, sessionProperties, forceRequest }).then(() => __async(this, null, function* () {
|
|
37783
40313
|
if (__privateGet(this, _transport2) instanceof MWPTransport) {
|
|
37784
40314
|
return this.storage.setTransport("mwp" /* MWP */);
|
|
37785
40315
|
}
|
|
@@ -37787,19 +40317,19 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
37787
40317
|
})), scopes, transportType);
|
|
37788
40318
|
}
|
|
37789
40319
|
if (platformType === "in-app-browser" /* MetaMaskMobileWebview */) {
|
|
37790
|
-
const defaultTransport = yield __privateMethod(this,
|
|
37791
|
-
return __privateMethod(this,
|
|
40320
|
+
const defaultTransport = yield __privateMethod(this, _MetaMaskConnectMultichain_instances, setupDefaultTransport_fn).call(this);
|
|
40321
|
+
return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, defaultTransport.connect({ scopes, caipAccountIds, sessionProperties, forceRequest }), scopes, transportType);
|
|
37792
40322
|
}
|
|
37793
40323
|
if (isWeb && hasExtensionInstalled && preferExtension) {
|
|
37794
|
-
const defaultTransport = yield __privateMethod(this,
|
|
37795
|
-
return __privateMethod(this,
|
|
40324
|
+
const defaultTransport = yield __privateMethod(this, _MetaMaskConnectMultichain_instances, setupDefaultTransport_fn).call(this);
|
|
40325
|
+
return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, defaultTransport.connect({ scopes, caipAccountIds, sessionProperties, forceRequest }), scopes, transportType);
|
|
37796
40326
|
}
|
|
37797
|
-
yield __privateMethod(this,
|
|
40327
|
+
yield __privateMethod(this, _MetaMaskConnectMultichain_instances, setupMWP_fn).call(this);
|
|
37798
40328
|
const shouldShowInstallModal = hasExtensionInstalled ? showInstallModal : !preferExtension || showInstallModal;
|
|
37799
40329
|
if (secure && !shouldShowInstallModal) {
|
|
37800
|
-
return __privateMethod(this,
|
|
40330
|
+
return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, __privateMethod(this, _MetaMaskConnectMultichain_instances, deeplinkConnect_fn).call(this, scopes, caipAccountIds, sessionProperties), scopes, transportType);
|
|
37801
40331
|
}
|
|
37802
|
-
return __privateMethod(this,
|
|
40332
|
+
return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, __privateMethod(this, _MetaMaskConnectMultichain_instances, showInstallModal_fn).call(this, shouldShowInstallModal, scopes, caipAccountIds, sessionProperties), scopes, transportType);
|
|
37803
40333
|
});
|
|
37804
40334
|
}
|
|
37805
40335
|
emit(event, args) {
|
|
@@ -37818,15 +40348,13 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
37818
40348
|
__privateSet(this, _listener, void 0);
|
|
37819
40349
|
__privateSet(this, _beforeUnloadListener, void 0);
|
|
37820
40350
|
__privateSet(this, _transport2, void 0);
|
|
37821
|
-
|
|
40351
|
+
__privateGet(this, _providerTransportWrapper).clearNotificationCallbacks();
|
|
37822
40352
|
__privateSet(this, _dappClient, void 0);
|
|
37823
40353
|
});
|
|
37824
40354
|
}
|
|
37825
40355
|
invokeMethod(request2) {
|
|
37826
40356
|
return __async(this, null, function* () {
|
|
37827
|
-
var _a3;
|
|
37828
40357
|
const { transport, options } = this;
|
|
37829
|
-
(_a3 = __privateGet(this, _provider)) != null ? _a3 : __privateSet(this, _provider, getMultichainClient({ transport }));
|
|
37830
40358
|
const rpcClient = new RpcClient(options, __privateGet(this, _sdkInfo));
|
|
37831
40359
|
const requestRouter = new RequestRouter(transport, rpcClient, options);
|
|
37832
40360
|
return requestRouter.invokeMethod(request2);
|
|
@@ -37855,12 +40383,13 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
37855
40383
|
}
|
|
37856
40384
|
};
|
|
37857
40385
|
_provider = new WeakMap();
|
|
40386
|
+
_providerTransportWrapper = new WeakMap();
|
|
37858
40387
|
_transport2 = new WeakMap();
|
|
37859
40388
|
_dappClient = new WeakMap();
|
|
37860
40389
|
_beforeUnloadListener = new WeakMap();
|
|
37861
40390
|
_listener = new WeakMap();
|
|
37862
40391
|
_sdkInfo = new WeakMap();
|
|
37863
|
-
|
|
40392
|
+
_MetaMaskConnectMultichain_instances = new WeakSet();
|
|
37864
40393
|
setupAnalytics_fn = function() {
|
|
37865
40394
|
return __async(this, null, function* () {
|
|
37866
40395
|
var _a3;
|
|
@@ -37901,19 +40430,21 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
37901
40430
|
if (hasExtensionInstalled) {
|
|
37902
40431
|
const apiTransport = new DefaultTransport();
|
|
37903
40432
|
__privateSet(this, _transport2, apiTransport);
|
|
40433
|
+
__privateGet(this, _providerTransportWrapper).setupNotifcationListener();
|
|
37904
40434
|
__privateSet(this, _listener, apiTransport.onNotification(
|
|
37905
|
-
__privateMethod(this,
|
|
40435
|
+
__privateMethod(this, _MetaMaskConnectMultichain_instances, onTransportNotification_fn).bind(this)
|
|
37906
40436
|
));
|
|
37907
40437
|
return apiTransport;
|
|
37908
40438
|
}
|
|
37909
40439
|
} else if (transportType === "mwp" /* MWP */) {
|
|
37910
40440
|
const { adapter: kvstore } = this.options.storage;
|
|
37911
|
-
const dappClient = yield __privateMethod(this,
|
|
40441
|
+
const dappClient = yield __privateMethod(this, _MetaMaskConnectMultichain_instances, createDappClient_fn).call(this);
|
|
37912
40442
|
const apiTransport = new MWPTransport(dappClient, kvstore);
|
|
37913
40443
|
__privateSet(this, _dappClient, dappClient);
|
|
37914
40444
|
__privateSet(this, _transport2, apiTransport);
|
|
40445
|
+
__privateGet(this, _providerTransportWrapper).setupNotifcationListener();
|
|
37915
40446
|
__privateSet(this, _listener, apiTransport.onNotification(
|
|
37916
|
-
__privateMethod(this,
|
|
40447
|
+
__privateMethod(this, _MetaMaskConnectMultichain_instances, onTransportNotification_fn).bind(this)
|
|
37917
40448
|
));
|
|
37918
40449
|
return apiTransport;
|
|
37919
40450
|
}
|
|
@@ -37924,20 +40455,20 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
37924
40455
|
};
|
|
37925
40456
|
setupTransport_fn = function() {
|
|
37926
40457
|
return __async(this, null, function* () {
|
|
37927
|
-
const transport = yield __privateMethod(this,
|
|
40458
|
+
const transport = yield __privateMethod(this, _MetaMaskConnectMultichain_instances, getStoredTransport_fn).call(this);
|
|
37928
40459
|
if (transport) {
|
|
37929
40460
|
if (!this.transport.isConnected()) {
|
|
37930
|
-
this.
|
|
40461
|
+
this.status = "connecting";
|
|
37931
40462
|
yield this.transport.connect();
|
|
37932
40463
|
}
|
|
37933
|
-
this.
|
|
40464
|
+
this.status = "connected";
|
|
37934
40465
|
if (this.transport instanceof MWPTransport) {
|
|
37935
40466
|
yield this.storage.setTransport("mwp" /* MWP */);
|
|
37936
40467
|
} else {
|
|
37937
40468
|
yield this.storage.setTransport("browser" /* Browser */);
|
|
37938
40469
|
}
|
|
37939
40470
|
} else {
|
|
37940
|
-
this.
|
|
40471
|
+
this.status = "loaded";
|
|
37941
40472
|
}
|
|
37942
40473
|
});
|
|
37943
40474
|
};
|
|
@@ -37948,8 +40479,8 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
37948
40479
|
if (typeof window !== "undefined" && ((_a3 = window.mmsdk) == null ? void 0 : _a3.isInitialized)) {
|
|
37949
40480
|
logger2("MetaMaskSDK: init already initialized");
|
|
37950
40481
|
} else {
|
|
37951
|
-
yield __privateMethod(this,
|
|
37952
|
-
yield __privateMethod(this,
|
|
40482
|
+
yield __privateMethod(this, _MetaMaskConnectMultichain_instances, setupAnalytics_fn).call(this);
|
|
40483
|
+
yield __privateMethod(this, _MetaMaskConnectMultichain_instances, setupTransport_fn).call(this);
|
|
37953
40484
|
try {
|
|
37954
40485
|
const baseProps = yield getBaseAnalyticsProperties(
|
|
37955
40486
|
this.options,
|
|
@@ -37965,7 +40496,7 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
37965
40496
|
}
|
|
37966
40497
|
} catch (error) {
|
|
37967
40498
|
yield this.storage.removeTransport();
|
|
37968
|
-
this.
|
|
40499
|
+
this.status = "pending";
|
|
37969
40500
|
logger2("MetaMaskSDK error during initialization", error);
|
|
37970
40501
|
}
|
|
37971
40502
|
});
|
|
@@ -37993,12 +40524,13 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
37993
40524
|
return;
|
|
37994
40525
|
}
|
|
37995
40526
|
const { adapter: kvstore } = this.options.storage;
|
|
37996
|
-
const dappClient = yield __privateMethod(this,
|
|
40527
|
+
const dappClient = yield __privateMethod(this, _MetaMaskConnectMultichain_instances, createDappClient_fn).call(this);
|
|
37997
40528
|
__privateSet(this, _dappClient, dappClient);
|
|
37998
40529
|
const apiTransport = new MWPTransport(dappClient, kvstore);
|
|
37999
40530
|
__privateSet(this, _transport2, apiTransport);
|
|
40531
|
+
__privateGet(this, _providerTransportWrapper).setupNotifcationListener();
|
|
38000
40532
|
__privateSet(this, _listener, this.transport.onNotification(
|
|
38001
|
-
__privateMethod(this,
|
|
40533
|
+
__privateMethod(this, _MetaMaskConnectMultichain_instances, onTransportNotification_fn).bind(this)
|
|
38002
40534
|
));
|
|
38003
40535
|
yield this.storage.setTransport("mwp" /* MWP */);
|
|
38004
40536
|
});
|
|
@@ -38013,18 +40545,18 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
38013
40545
|
};
|
|
38014
40546
|
createBeforeUnloadListener_fn = function() {
|
|
38015
40547
|
if (typeof window !== "undefined" && typeof window.addEventListener !== "undefined") {
|
|
38016
|
-
window.addEventListener("beforeunload", __privateMethod(this,
|
|
40548
|
+
window.addEventListener("beforeunload", __privateMethod(this, _MetaMaskConnectMultichain_instances, onBeforeUnload_fn).bind(this));
|
|
38017
40549
|
}
|
|
38018
40550
|
return () => {
|
|
38019
40551
|
if (typeof window !== "undefined" && typeof window.removeEventListener !== "undefined") {
|
|
38020
40552
|
window.removeEventListener(
|
|
38021
40553
|
"beforeunload",
|
|
38022
|
-
__privateMethod(this,
|
|
40554
|
+
__privateMethod(this, _MetaMaskConnectMultichain_instances, onBeforeUnload_fn).bind(this)
|
|
38023
40555
|
);
|
|
38024
40556
|
}
|
|
38025
40557
|
};
|
|
38026
40558
|
};
|
|
38027
|
-
renderInstallModalAsync_fn = function(desktopPreferred, scopes, caipAccountIds) {
|
|
40559
|
+
renderInstallModalAsync_fn = function(desktopPreferred, scopes, caipAccountIds, sessionProperties) {
|
|
38028
40560
|
return __async(this, null, function* () {
|
|
38029
40561
|
return new Promise((resolve, reject) => {
|
|
38030
40562
|
this.options.ui.factory.renderInstallModal(
|
|
@@ -38052,19 +40584,19 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
38052
40584
|
(() => __async(this, null, function* () {
|
|
38053
40585
|
var _a3;
|
|
38054
40586
|
try {
|
|
38055
|
-
yield this.transport.connect({ scopes, caipAccountIds });
|
|
40587
|
+
yield this.transport.connect({ scopes, caipAccountIds, sessionProperties });
|
|
38056
40588
|
yield this.options.ui.factory.unload();
|
|
38057
40589
|
(_a3 = this.options.ui.factory.modal) == null ? void 0 : _a3.unmount();
|
|
38058
|
-
this.
|
|
40590
|
+
this.status = "connected";
|
|
38059
40591
|
yield this.storage.setTransport("mwp" /* MWP */);
|
|
38060
40592
|
} catch (error) {
|
|
38061
40593
|
if (error instanceof import_mobile_wallet_protocol_core2.ProtocolError) {
|
|
38062
40594
|
if (error.code !== import_mobile_wallet_protocol_core2.ErrorCode.REQUEST_EXPIRED) {
|
|
38063
|
-
this.
|
|
40595
|
+
this.status = "disconnected";
|
|
38064
40596
|
reject(error);
|
|
38065
40597
|
}
|
|
38066
40598
|
} else {
|
|
38067
|
-
this.
|
|
40599
|
+
this.status = "disconnected";
|
|
38068
40600
|
reject(
|
|
38069
40601
|
error instanceof Error ? error : new Error(String(error))
|
|
38070
40602
|
);
|
|
@@ -38082,33 +40614,83 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
38082
40614
|
yield this.storage.setTransport("mwp" /* MWP */);
|
|
38083
40615
|
resolve();
|
|
38084
40616
|
}
|
|
38085
|
-
})
|
|
40617
|
+
}),
|
|
40618
|
+
(uri) => {
|
|
40619
|
+
this.emit("display_uri", uri);
|
|
40620
|
+
}
|
|
38086
40621
|
).catch((error) => {
|
|
38087
40622
|
reject(error instanceof Error ? error : new Error(String(error)));
|
|
38088
40623
|
});
|
|
38089
40624
|
});
|
|
38090
40625
|
});
|
|
38091
40626
|
};
|
|
38092
|
-
showInstallModal_fn = function(desktopPreferred, scopes, caipAccountIds) {
|
|
40627
|
+
showInstallModal_fn = function(desktopPreferred, scopes, caipAccountIds, sessionProperties) {
|
|
38093
40628
|
return __async(this, null, function* () {
|
|
38094
40629
|
var _a3;
|
|
38095
|
-
(_a3 = __privateGet(this, _beforeUnloadListener)) != null ? _a3 : __privateSet(this, _beforeUnloadListener, __privateMethod(this,
|
|
38096
|
-
|
|
40630
|
+
(_a3 = __privateGet(this, _beforeUnloadListener)) != null ? _a3 : __privateSet(this, _beforeUnloadListener, __privateMethod(this, _MetaMaskConnectMultichain_instances, createBeforeUnloadListener_fn).call(this));
|
|
40631
|
+
if (this.options.ui.headless) {
|
|
40632
|
+
yield __privateMethod(this, _MetaMaskConnectMultichain_instances, headlessConnect_fn).call(this, scopes, caipAccountIds, sessionProperties);
|
|
40633
|
+
} else {
|
|
40634
|
+
yield __privateMethod(this, _MetaMaskConnectMultichain_instances, renderInstallModalAsync_fn).call(this, desktopPreferred, scopes, caipAccountIds, sessionProperties);
|
|
40635
|
+
}
|
|
40636
|
+
});
|
|
40637
|
+
};
|
|
40638
|
+
headlessConnect_fn = function(scopes, caipAccountIds, sessionProperties) {
|
|
40639
|
+
return __async(this, null, function* () {
|
|
40640
|
+
return new Promise((resolve, reject) => {
|
|
40641
|
+
if (this.dappClient.state === "CONNECTED" || this.dappClient.state === "CONNECTING") {
|
|
40642
|
+
this.dappClient.disconnect().catch(() => {
|
|
40643
|
+
});
|
|
40644
|
+
}
|
|
40645
|
+
this.dappClient.on(
|
|
40646
|
+
"session_request",
|
|
40647
|
+
(sessionRequest) => {
|
|
40648
|
+
const connectionRequest = {
|
|
40649
|
+
sessionRequest,
|
|
40650
|
+
metadata: {
|
|
40651
|
+
dapp: this.options.dapp,
|
|
40652
|
+
sdk: {
|
|
40653
|
+
version: getVersion(),
|
|
40654
|
+
platform: getPlatformType()
|
|
40655
|
+
}
|
|
40656
|
+
}
|
|
40657
|
+
};
|
|
40658
|
+
const deeplink = this.options.ui.factory.createConnectionDeeplink(connectionRequest);
|
|
40659
|
+
this.emit("display_uri", deeplink);
|
|
40660
|
+
}
|
|
40661
|
+
);
|
|
40662
|
+
this.transport.connect({ scopes, caipAccountIds, sessionProperties }).then(() => __async(this, null, function* () {
|
|
40663
|
+
this.status = "connected";
|
|
40664
|
+
yield this.storage.setTransport("mwp" /* MWP */);
|
|
40665
|
+
resolve();
|
|
40666
|
+
})).catch((error) => __async(this, null, function* () {
|
|
40667
|
+
if (error instanceof import_mobile_wallet_protocol_core2.ProtocolError) {
|
|
40668
|
+
this.status = "disconnected";
|
|
40669
|
+
yield this.storage.removeTransport();
|
|
40670
|
+
reject(error);
|
|
40671
|
+
} else {
|
|
40672
|
+
this.status = "disconnected";
|
|
40673
|
+
yield this.storage.removeTransport();
|
|
40674
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
40675
|
+
}
|
|
40676
|
+
}));
|
|
40677
|
+
});
|
|
38097
40678
|
});
|
|
38098
40679
|
};
|
|
38099
40680
|
setupDefaultTransport_fn = function() {
|
|
38100
40681
|
return __async(this, null, function* () {
|
|
38101
|
-
this.
|
|
40682
|
+
this.status = "connecting";
|
|
38102
40683
|
yield this.storage.setTransport("browser" /* Browser */);
|
|
38103
40684
|
const transport = new DefaultTransport();
|
|
38104
40685
|
__privateSet(this, _listener, transport.onNotification(
|
|
38105
|
-
__privateMethod(this,
|
|
40686
|
+
__privateMethod(this, _MetaMaskConnectMultichain_instances, onTransportNotification_fn).bind(this)
|
|
38106
40687
|
));
|
|
38107
40688
|
__privateSet(this, _transport2, transport);
|
|
40689
|
+
__privateGet(this, _providerTransportWrapper).setupNotifcationListener();
|
|
38108
40690
|
return transport;
|
|
38109
40691
|
});
|
|
38110
40692
|
};
|
|
38111
|
-
deeplinkConnect_fn = function(scopes, caipAccountIds) {
|
|
40693
|
+
deeplinkConnect_fn = function(scopes, caipAccountIds, sessionProperties) {
|
|
38112
40694
|
return __async(this, null, function* () {
|
|
38113
40695
|
return new Promise((resolve, reject) => {
|
|
38114
40696
|
const dappClientMessageHandler = (payload) => {
|
|
@@ -38151,6 +40733,7 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
38151
40733
|
const universalLink = this.options.ui.factory.createConnectionUniversalLink(
|
|
38152
40734
|
connectionRequest
|
|
38153
40735
|
);
|
|
40736
|
+
this.emit("display_uri", deeplink);
|
|
38154
40737
|
if ((_a3 = this.options.mobile) == null ? void 0 : _a3.preferredOpenLink) {
|
|
38155
40738
|
this.options.mobile.preferredOpenLink(deeplink, "_self");
|
|
38156
40739
|
} else {
|
|
@@ -38159,7 +40742,7 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
38159
40742
|
}
|
|
38160
40743
|
);
|
|
38161
40744
|
}
|
|
38162
|
-
return this.transport.connect({ scopes, caipAccountIds }).then(resolve).catch((error) => __async(this, null, function* () {
|
|
40745
|
+
return this.transport.connect({ scopes, caipAccountIds, sessionProperties }).then(resolve).catch((error) => __async(this, null, function* () {
|
|
38163
40746
|
yield this.storage.removeTransport();
|
|
38164
40747
|
this.dappClient.off("message", dappClientMessageHandler);
|
|
38165
40748
|
reject(error instanceof Error ? error : new Error(String(error)));
|
|
@@ -38173,9 +40756,9 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
38173
40756
|
};
|
|
38174
40757
|
handleConnection_fn = function(promise, scopes, transportType) {
|
|
38175
40758
|
return __async(this, null, function* () {
|
|
38176
|
-
this.
|
|
40759
|
+
this.status = "connecting";
|
|
38177
40760
|
return promise.then(() => __async(this, null, function* () {
|
|
38178
|
-
this.
|
|
40761
|
+
this.status = "connected";
|
|
38179
40762
|
try {
|
|
38180
40763
|
const baseProps = yield getBaseAnalyticsProperties(
|
|
38181
40764
|
this.options,
|
|
@@ -38190,7 +40773,7 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
38190
40773
|
}
|
|
38191
40774
|
return void 0;
|
|
38192
40775
|
})).catch((error) => __async(this, null, function* () {
|
|
38193
|
-
this.
|
|
40776
|
+
this.status = "disconnected";
|
|
38194
40777
|
try {
|
|
38195
40778
|
const baseProps = yield getBaseAnalyticsProperties(
|
|
38196
40779
|
this.options,
|
|
@@ -38213,7 +40796,7 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
38213
40796
|
}));
|
|
38214
40797
|
});
|
|
38215
40798
|
};
|
|
38216
|
-
var
|
|
40799
|
+
var MetaMaskConnectMultichain = _MetaMaskConnectMultichain;
|
|
38217
40800
|
|
|
38218
40801
|
// ../../node_modules/uuid/dist/esm-browser/stringify.js
|
|
38219
40802
|
var byteToHex = [];
|
|
@@ -38477,10 +41060,10 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
38477
41060
|
var _ = { label: 0, sent: function() {
|
|
38478
41061
|
if (t[0] & 1) throw t[1];
|
|
38479
41062
|
return t[1];
|
|
38480
|
-
}, trys: [], ops: [] }, f, y, t,
|
|
38481
|
-
return
|
|
41063
|
+
}, trys: [], ops: [] }, f, y, t, g2;
|
|
41064
|
+
return g2 = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g2[Symbol.iterator] = function() {
|
|
38482
41065
|
return this;
|
|
38483
|
-
}),
|
|
41066
|
+
}), g2;
|
|
38484
41067
|
function verb(n) {
|
|
38485
41068
|
return function(v) {
|
|
38486
41069
|
return step([n, v]);
|
|
@@ -38714,27 +41297,10 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
38714
41297
|
);
|
|
38715
41298
|
var metamask_onboarding_es_default = Onboarding;
|
|
38716
41299
|
|
|
38717
|
-
// src/ui/
|
|
41300
|
+
// src/ui/ModalFactory.ts
|
|
38718
41301
|
init_domain();
|
|
38719
41302
|
init_utils3();
|
|
38720
|
-
|
|
38721
|
-
// src/ui/preload.web.ts
|
|
38722
|
-
function preload() {
|
|
38723
|
-
return __async(this, null, function* () {
|
|
38724
|
-
if (typeof document === "undefined") {
|
|
38725
|
-
return;
|
|
38726
|
-
}
|
|
38727
|
-
try {
|
|
38728
|
-
const { defineCustomElements: defineCustomElements2 } = yield Promise.resolve().then(() => (init_loader2(), loader_exports));
|
|
38729
|
-
yield defineCustomElements2();
|
|
38730
|
-
} catch (error) {
|
|
38731
|
-
console.error("Failed to load customElements:", error);
|
|
38732
|
-
}
|
|
38733
|
-
});
|
|
38734
|
-
}
|
|
38735
|
-
|
|
38736
|
-
// src/ui/index.ts
|
|
38737
|
-
var ModalFactory = class {
|
|
41303
|
+
var BaseModalFactory = class {
|
|
38738
41304
|
/**
|
|
38739
41305
|
* Creates a new modal factory instance.
|
|
38740
41306
|
*
|
|
@@ -38823,15 +41389,17 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
38823
41389
|
onStartDesktopOnboarding() {
|
|
38824
41390
|
new metamask_onboarding_es_default().startOnboarding();
|
|
38825
41391
|
}
|
|
38826
|
-
renderInstallModal(showInstallModal, createConnectionRequest, successCallback) {
|
|
41392
|
+
renderInstallModal(showInstallModal, createConnectionRequest, successCallback, onDisplayUri) {
|
|
38827
41393
|
return __async(this, null, function* () {
|
|
38828
|
-
var _a3;
|
|
41394
|
+
var _a3, _b;
|
|
38829
41395
|
(_a3 = this.modal) == null ? void 0 : _a3.unmount();
|
|
38830
|
-
yield preload();
|
|
41396
|
+
yield this.preload();
|
|
38831
41397
|
this.successCallback = successCallback;
|
|
41398
|
+
this.displayUriCallback = onDisplayUri;
|
|
38832
41399
|
const parentElement = this.getMountedContainer();
|
|
38833
41400
|
const connectionRequest = yield createConnectionRequest();
|
|
38834
41401
|
const qrCodeLink = this.createConnectionDeeplink(connectionRequest);
|
|
41402
|
+
(_b = this.displayUriCallback) == null ? void 0 : _b.call(this, qrCodeLink);
|
|
38835
41403
|
const modal = new this.options.InstallModal({
|
|
38836
41404
|
expiresIn: (connectionRequest.sessionRequest.expiresAt - Date.now()) / 1e3,
|
|
38837
41405
|
connectionRequest,
|
|
@@ -38840,11 +41408,15 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
38840
41408
|
link: qrCodeLink,
|
|
38841
41409
|
sdkVersion: getVersion(),
|
|
38842
41410
|
generateQRCode: (request2) => __async(this, null, function* () {
|
|
38843
|
-
|
|
41411
|
+
var _a4;
|
|
41412
|
+
const newLink = this.createConnectionDeeplink(request2);
|
|
41413
|
+
(_a4 = this.displayUriCallback) == null ? void 0 : _a4.call(this, newLink);
|
|
41414
|
+
return newLink;
|
|
38844
41415
|
}),
|
|
38845
41416
|
onClose: this.onCloseModal.bind(this),
|
|
38846
41417
|
startDesktopOnboarding: this.onStartDesktopOnboarding.bind(this),
|
|
38847
|
-
createConnectionRequest
|
|
41418
|
+
createConnectionRequest,
|
|
41419
|
+
onDisplayUri: this.displayUriCallback
|
|
38848
41420
|
});
|
|
38849
41421
|
this.modal = modal;
|
|
38850
41422
|
modal.mount();
|
|
@@ -38854,7 +41426,7 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
38854
41426
|
return __async(this, null, function* () {
|
|
38855
41427
|
var _a3;
|
|
38856
41428
|
(_a3 = this.modal) == null ? void 0 : _a3.unmount();
|
|
38857
|
-
yield preload();
|
|
41429
|
+
yield this.preload();
|
|
38858
41430
|
this.successCallback = successCallback;
|
|
38859
41431
|
const container = this.getMountedContainer();
|
|
38860
41432
|
const otpCode = yield createOTPCode();
|
|
@@ -38872,9 +41444,31 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
38872
41444
|
}
|
|
38873
41445
|
};
|
|
38874
41446
|
|
|
41447
|
+
// src/ui/index.ts
|
|
41448
|
+
function preload() {
|
|
41449
|
+
return __async(this, null, function* () {
|
|
41450
|
+
if (typeof document === "undefined") {
|
|
41451
|
+
return;
|
|
41452
|
+
}
|
|
41453
|
+
try {
|
|
41454
|
+
const { defineCustomElements: defineCustomElements2 } = yield Promise.resolve().then(() => (init_loader2(), loader_exports));
|
|
41455
|
+
yield defineCustomElements2();
|
|
41456
|
+
} catch (error) {
|
|
41457
|
+
console.error("Failed to load customElements:", error);
|
|
41458
|
+
}
|
|
41459
|
+
});
|
|
41460
|
+
}
|
|
41461
|
+
var ModalFactory = class extends BaseModalFactory {
|
|
41462
|
+
preload() {
|
|
41463
|
+
return __async(this, null, function* () {
|
|
41464
|
+
return preload();
|
|
41465
|
+
});
|
|
41466
|
+
}
|
|
41467
|
+
};
|
|
41468
|
+
|
|
38875
41469
|
// src/index.browser.ts
|
|
38876
41470
|
init_domain();
|
|
38877
|
-
var
|
|
41471
|
+
var createMultichainClient = (options) => __async(null, null, function* () {
|
|
38878
41472
|
const uiModules = yield Promise.resolve().then(() => (init_web(), web_exports));
|
|
38879
41473
|
let storage;
|
|
38880
41474
|
if (!options.storage) {
|
|
@@ -38885,7 +41479,7 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
38885
41479
|
storage = options.storage;
|
|
38886
41480
|
}
|
|
38887
41481
|
const factory = new ModalFactory(uiModules);
|
|
38888
|
-
return
|
|
41482
|
+
return MetaMaskConnectMultichain.create(__spreadProps(__spreadValues({}, options), {
|
|
38889
41483
|
storage,
|
|
38890
41484
|
ui: __spreadProps(__spreadValues({}, options.ui), {
|
|
38891
41485
|
factory
|
|
@@ -38896,6 +41490,17 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
38896
41490
|
})();
|
|
38897
41491
|
/*! Bundled license information:
|
|
38898
41492
|
|
|
41493
|
+
ieee754/index.js:
|
|
41494
|
+
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
41495
|
+
|
|
41496
|
+
buffer/index.js:
|
|
41497
|
+
(*!
|
|
41498
|
+
* The buffer module from node.js, for the browser.
|
|
41499
|
+
*
|
|
41500
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
41501
|
+
* @license MIT
|
|
41502
|
+
*)
|
|
41503
|
+
|
|
38899
41504
|
@scure/base/lib/index.js:
|
|
38900
41505
|
(*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
38901
41506
|
|