@mushi-mushi/core 1.19.2 → 1.20.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +14 -2
- package/SECURITY.md +1 -1
- package/dist/index.cjs +41 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +41 -15
- package/dist/index.js.map +1 -1
- package/package.json +13 -6
package/dist/index.d.cts
CHANGED
|
@@ -315,6 +315,27 @@ interface MushiCaptureConfig {
|
|
|
315
315
|
ignoreUrls?: MushiUrlMatcher[];
|
|
316
316
|
performance?: boolean;
|
|
317
317
|
screenshot?: 'on-report' | 'auto' | 'off';
|
|
318
|
+
/**
|
|
319
|
+
* Custom screenshot capture function. When provided, the SDK calls this
|
|
320
|
+
* instead of its built-in DOM-snapshot capturer. Return a JPEG/PNG data URI
|
|
321
|
+
* on success, or `null` to skip attachment. If the function throws the SDK
|
|
322
|
+
* falls back to the built-in capturer.
|
|
323
|
+
*
|
|
324
|
+
* Primary use-case: Capacitor / WebView hosts that route through a native
|
|
325
|
+
* plugin (e.g. `@capawesome/capacitor-screenshot`) to obtain a real pixel-
|
|
326
|
+
* accurate screen grab instead of the SVG-foreignObject DOM reconstruction.
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* capture: {
|
|
330
|
+
* screenshot: 'auto',
|
|
331
|
+
* screenshotProvider: async () => {
|
|
332
|
+
* const { Screenshot } = await import('@capawesome/capacitor-screenshot');
|
|
333
|
+
* const { uri } = await Screenshot.take();
|
|
334
|
+
* return uri; // data URI on web, file:// on native (SDK handles both)
|
|
335
|
+
* },
|
|
336
|
+
* }
|
|
337
|
+
*/
|
|
338
|
+
screenshotProvider?: () => Promise<string | null>;
|
|
318
339
|
elementSelector?: boolean;
|
|
319
340
|
replay?: 'sentry' | 'rrweb' | 'lite' | 'off';
|
|
320
341
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -315,6 +315,27 @@ interface MushiCaptureConfig {
|
|
|
315
315
|
ignoreUrls?: MushiUrlMatcher[];
|
|
316
316
|
performance?: boolean;
|
|
317
317
|
screenshot?: 'on-report' | 'auto' | 'off';
|
|
318
|
+
/**
|
|
319
|
+
* Custom screenshot capture function. When provided, the SDK calls this
|
|
320
|
+
* instead of its built-in DOM-snapshot capturer. Return a JPEG/PNG data URI
|
|
321
|
+
* on success, or `null` to skip attachment. If the function throws the SDK
|
|
322
|
+
* falls back to the built-in capturer.
|
|
323
|
+
*
|
|
324
|
+
* Primary use-case: Capacitor / WebView hosts that route through a native
|
|
325
|
+
* plugin (e.g. `@capawesome/capacitor-screenshot`) to obtain a real pixel-
|
|
326
|
+
* accurate screen grab instead of the SVG-foreignObject DOM reconstruction.
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* capture: {
|
|
330
|
+
* screenshot: 'auto',
|
|
331
|
+
* screenshotProvider: async () => {
|
|
332
|
+
* const { Screenshot } = await import('@capawesome/capacitor-screenshot');
|
|
333
|
+
* const { uri } = await Screenshot.take();
|
|
334
|
+
* return uri; // data URI on web, file:// on native (SDK handles both)
|
|
335
|
+
* },
|
|
336
|
+
* }
|
|
337
|
+
*/
|
|
338
|
+
screenshotProvider?: () => Promise<string | null>;
|
|
318
339
|
elementSelector?: boolean;
|
|
319
340
|
replay?: 'sentry' | 'rrweb' | 'lite' | 'off';
|
|
320
341
|
/**
|
package/dist/index.js
CHANGED
|
@@ -40,6 +40,47 @@ function formatBytes(n) {
|
|
|
40
40
|
return `${(n / (1024 * 1024)).toFixed(2)} MB`;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
// src/digest.ts
|
|
44
|
+
function getSubtle() {
|
|
45
|
+
try {
|
|
46
|
+
const g = globalThis;
|
|
47
|
+
const crypto2 = g["crypto"];
|
|
48
|
+
if (crypto2?.subtle) return crypto2.subtle;
|
|
49
|
+
} catch {
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
function bytesToHex(bytes) {
|
|
54
|
+
return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
55
|
+
}
|
|
56
|
+
async function sha256Hex(value) {
|
|
57
|
+
const subtle = getSubtle();
|
|
58
|
+
if (subtle) {
|
|
59
|
+
const buffer = await subtle.digest("SHA-256", new TextEncoder().encode(value));
|
|
60
|
+
return bytesToHex(new Uint8Array(buffer));
|
|
61
|
+
}
|
|
62
|
+
const { sha256 } = await import('@noble/hashes/sha2.js');
|
|
63
|
+
return bytesToHex(sha256(new TextEncoder().encode(value)));
|
|
64
|
+
}
|
|
65
|
+
async function hmacSha256Hex(secret, value) {
|
|
66
|
+
const subtle = getSubtle();
|
|
67
|
+
if (subtle) {
|
|
68
|
+
const key = await subtle.importKey(
|
|
69
|
+
"raw",
|
|
70
|
+
new TextEncoder().encode(secret),
|
|
71
|
+
{ name: "HMAC", hash: "SHA-256" },
|
|
72
|
+
false,
|
|
73
|
+
["sign"]
|
|
74
|
+
);
|
|
75
|
+
const buffer = await subtle.sign("HMAC", key, new TextEncoder().encode(value));
|
|
76
|
+
return bytesToHex(new Uint8Array(buffer));
|
|
77
|
+
}
|
|
78
|
+
const { hmac } = await import('@noble/hashes/hmac.js');
|
|
79
|
+
const { sha256 } = await import('@noble/hashes/sha2.js');
|
|
80
|
+
const result = hmac(sha256, new TextEncoder().encode(secret), new TextEncoder().encode(value));
|
|
81
|
+
return bytesToHex(result);
|
|
82
|
+
}
|
|
83
|
+
|
|
43
84
|
// src/api-client.ts
|
|
44
85
|
var _credWarningEmitted = false;
|
|
45
86
|
var MUSHI_USER_TOKEN_HEADER = "X-Mushi-User-Token";
|
|
@@ -409,21 +450,6 @@ function createApiClient(options) {
|
|
|
409
450
|
}
|
|
410
451
|
};
|
|
411
452
|
}
|
|
412
|
-
async function sha256Hex(value) {
|
|
413
|
-
const buffer = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(value));
|
|
414
|
-
return Array.from(new Uint8Array(buffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
415
|
-
}
|
|
416
|
-
async function hmacSha256Hex(secret, value) {
|
|
417
|
-
const key = await crypto.subtle.importKey(
|
|
418
|
-
"raw",
|
|
419
|
-
new TextEncoder().encode(secret),
|
|
420
|
-
{ name: "HMAC", hash: "SHA-256" },
|
|
421
|
-
false,
|
|
422
|
-
["sign"]
|
|
423
|
-
);
|
|
424
|
-
const buffer = await crypto.subtle.sign("HMAC", key, new TextEncoder().encode(value));
|
|
425
|
-
return Array.from(new Uint8Array(buffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
426
|
-
}
|
|
427
453
|
function sleep(ms) {
|
|
428
454
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
429
455
|
}
|