@sip-protocol/sdk 0.2.9 → 0.2.10
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/LICENSE +21 -0
- package/dist/browser.d.mts +100 -2
- package/dist/browser.d.ts +100 -2
- package/dist/browser.js +774 -114
- package/dist/browser.mjs +498 -16
- package/dist/{chunk-KXN6IWL5.mjs → chunk-AV37IZST.mjs} +284 -0
- package/dist/{chunk-VITVG25F.mjs → chunk-XLEPIR2P.mjs} +2 -100
- package/dist/index-BFOKTz2z.d.ts +6062 -0
- package/dist/index-CAhjA4kh.d.mts +6062 -0
- package/dist/index.d.mts +2 -5897
- package/dist/index.d.ts +2 -5897
- package/dist/index.mjs +1 -1
- package/dist/{noir-BHQtFvRk.d.mts → noir-BTyLXLlZ.d.mts} +1 -1
- package/dist/{noir-BHQtFvRk.d.ts → noir-BTyLXLlZ.d.ts} +1 -1
- package/dist/proofs/noir.d.mts +1 -1
- package/dist/proofs/noir.d.ts +1 -1
- package/dist/proofs/noir.js +11 -112
- package/dist/proofs/noir.mjs +10 -13
- package/package.json +16 -16
- package/src/browser.ts +23 -0
- package/src/proofs/browser-utils.ts +389 -0
- package/src/proofs/browser.ts +246 -19
- package/src/proofs/circuits/funding_proof.json +1 -1
- package/src/proofs/noir.ts +14 -14
- package/src/proofs/worker.ts +426 -0
- package/dist/chunk-4VJHI66K.mjs +0 -12120
- package/dist/chunk-5BAS4D44.mjs +0 -10283
- package/dist/chunk-6WOV2YNG.mjs +0 -10179
- package/dist/chunk-DU7LQDD2.mjs +0 -10148
- package/dist/chunk-MR7HRCRS.mjs +0 -10165
- package/dist/chunk-NDGUWOOZ.mjs +0 -10157
- package/dist/chunk-O4Y2ZUDL.mjs +0 -12721
- package/dist/chunk-UPTISVCY.mjs +0 -10304
- package/dist/chunk-VXSHK7US.mjs +0 -10158
|
@@ -3031,6 +3031,280 @@ var MockProofProvider = class {
|
|
|
3031
3031
|
};
|
|
3032
3032
|
|
|
3033
3033
|
// src/proofs/browser-utils.ts
|
|
3034
|
+
function detectMobilePlatform() {
|
|
3035
|
+
if (typeof navigator === "undefined") return "desktop";
|
|
3036
|
+
const ua = navigator.userAgent.toLowerCase();
|
|
3037
|
+
if (/iphone|ipad|ipod/.test(ua) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1) {
|
|
3038
|
+
return "ios";
|
|
3039
|
+
}
|
|
3040
|
+
if (/android/.test(ua)) {
|
|
3041
|
+
return "android";
|
|
3042
|
+
}
|
|
3043
|
+
if (/mobile|webos|blackberry|opera mini|opera mobi|iemobile|wpdesktop/.test(ua)) {
|
|
3044
|
+
return "other";
|
|
3045
|
+
}
|
|
3046
|
+
return "desktop";
|
|
3047
|
+
}
|
|
3048
|
+
function detectMobileBrowser() {
|
|
3049
|
+
if (typeof navigator === "undefined") return "other";
|
|
3050
|
+
const ua = navigator.userAgent.toLowerCase();
|
|
3051
|
+
if (/safari/.test(ua) && /iphone|ipad|ipod/.test(ua) && !/crios|fxios/.test(ua)) {
|
|
3052
|
+
return "safari";
|
|
3053
|
+
}
|
|
3054
|
+
if (/chrome|crios/.test(ua) && !/edg|opr|samsung/.test(ua)) {
|
|
3055
|
+
return "chrome";
|
|
3056
|
+
}
|
|
3057
|
+
if (/firefox|fxios/.test(ua)) {
|
|
3058
|
+
return "firefox";
|
|
3059
|
+
}
|
|
3060
|
+
if (/samsung/.test(ua)) {
|
|
3061
|
+
return "samsung";
|
|
3062
|
+
}
|
|
3063
|
+
if (/opr|opera/.test(ua)) {
|
|
3064
|
+
return "opera";
|
|
3065
|
+
}
|
|
3066
|
+
if (/edg/.test(ua)) {
|
|
3067
|
+
return "edge";
|
|
3068
|
+
}
|
|
3069
|
+
return "other";
|
|
3070
|
+
}
|
|
3071
|
+
function getBrowserVersion() {
|
|
3072
|
+
if (typeof navigator === "undefined") return null;
|
|
3073
|
+
const ua = navigator.userAgent;
|
|
3074
|
+
const browser = detectMobileBrowser();
|
|
3075
|
+
const patterns = {
|
|
3076
|
+
safari: /version\/(\d+(\.\d+)*)/i,
|
|
3077
|
+
chrome: /chrome\/(\d+(\.\d+)*)|crios\/(\d+(\.\d+)*)/i,
|
|
3078
|
+
firefox: /firefox\/(\d+(\.\d+)*)|fxios\/(\d+(\.\d+)*)/i,
|
|
3079
|
+
samsung: /samsungbrowser\/(\d+(\.\d+)*)/i,
|
|
3080
|
+
opera: /opr\/(\d+(\.\d+)*)/i,
|
|
3081
|
+
edge: /edg\/(\d+(\.\d+)*)/i,
|
|
3082
|
+
other: /version\/(\d+(\.\d+)*)/i
|
|
3083
|
+
};
|
|
3084
|
+
const pattern = patterns[browser] || patterns.other;
|
|
3085
|
+
const match = ua.match(pattern);
|
|
3086
|
+
if (match) {
|
|
3087
|
+
for (let i = 1; i < match.length; i++) {
|
|
3088
|
+
if (match[i]) return match[i];
|
|
3089
|
+
}
|
|
3090
|
+
}
|
|
3091
|
+
return null;
|
|
3092
|
+
}
|
|
3093
|
+
function getOSVersion() {
|
|
3094
|
+
if (typeof navigator === "undefined") return null;
|
|
3095
|
+
const ua = navigator.userAgent;
|
|
3096
|
+
const platform = detectMobilePlatform();
|
|
3097
|
+
if (platform === "ios") {
|
|
3098
|
+
const match = ua.match(/os (\d+[_\d]*)/i);
|
|
3099
|
+
return match ? match[1].replace(/_/g, ".") : null;
|
|
3100
|
+
}
|
|
3101
|
+
if (platform === "android") {
|
|
3102
|
+
const match = ua.match(/android (\d+(\.\d+)*)/i);
|
|
3103
|
+
return match ? match[1] : null;
|
|
3104
|
+
}
|
|
3105
|
+
return null;
|
|
3106
|
+
}
|
|
3107
|
+
function isTablet() {
|
|
3108
|
+
if (typeof navigator === "undefined") return false;
|
|
3109
|
+
const ua = navigator.userAgent.toLowerCase();
|
|
3110
|
+
if (/ipad/.test(ua) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1) {
|
|
3111
|
+
return true;
|
|
3112
|
+
}
|
|
3113
|
+
if (/android/.test(ua) && !/mobile/.test(ua)) {
|
|
3114
|
+
return true;
|
|
3115
|
+
}
|
|
3116
|
+
return false;
|
|
3117
|
+
}
|
|
3118
|
+
function supportsTouch() {
|
|
3119
|
+
if (typeof window === "undefined") return false;
|
|
3120
|
+
return "ontouchstart" in window || navigator.maxTouchPoints > 0;
|
|
3121
|
+
}
|
|
3122
|
+
function getMobileDeviceInfo() {
|
|
3123
|
+
const platform = detectMobilePlatform();
|
|
3124
|
+
return {
|
|
3125
|
+
isMobile: platform !== "desktop",
|
|
3126
|
+
platform,
|
|
3127
|
+
browser: detectMobileBrowser(),
|
|
3128
|
+
browserVersion: getBrowserVersion(),
|
|
3129
|
+
osVersion: getOSVersion(),
|
|
3130
|
+
isTablet: isTablet(),
|
|
3131
|
+
supportsTouch: supportsTouch(),
|
|
3132
|
+
deviceMemoryGB: (
|
|
3133
|
+
// @ts-expect-error - deviceMemory is non-standard
|
|
3134
|
+
typeof navigator !== "undefined" && navigator.deviceMemory ? (
|
|
3135
|
+
// @ts-expect-error - deviceMemory is non-standard
|
|
3136
|
+
navigator.deviceMemory
|
|
3137
|
+
) : null
|
|
3138
|
+
),
|
|
3139
|
+
hardwareConcurrency: typeof navigator !== "undefined" && navigator.hardwareConcurrency ? navigator.hardwareConcurrency : null
|
|
3140
|
+
};
|
|
3141
|
+
}
|
|
3142
|
+
function supportsWASMSimd() {
|
|
3143
|
+
try {
|
|
3144
|
+
return WebAssembly.validate(
|
|
3145
|
+
new Uint8Array([
|
|
3146
|
+
0,
|
|
3147
|
+
97,
|
|
3148
|
+
115,
|
|
3149
|
+
109,
|
|
3150
|
+
1,
|
|
3151
|
+
0,
|
|
3152
|
+
0,
|
|
3153
|
+
0,
|
|
3154
|
+
1,
|
|
3155
|
+
5,
|
|
3156
|
+
1,
|
|
3157
|
+
96,
|
|
3158
|
+
0,
|
|
3159
|
+
1,
|
|
3160
|
+
123,
|
|
3161
|
+
3,
|
|
3162
|
+
2,
|
|
3163
|
+
1,
|
|
3164
|
+
0,
|
|
3165
|
+
10,
|
|
3166
|
+
10,
|
|
3167
|
+
1,
|
|
3168
|
+
8,
|
|
3169
|
+
0,
|
|
3170
|
+
65,
|
|
3171
|
+
0,
|
|
3172
|
+
253,
|
|
3173
|
+
15,
|
|
3174
|
+
253,
|
|
3175
|
+
98,
|
|
3176
|
+
11
|
|
3177
|
+
])
|
|
3178
|
+
);
|
|
3179
|
+
} catch {
|
|
3180
|
+
return false;
|
|
3181
|
+
}
|
|
3182
|
+
}
|
|
3183
|
+
function supportsWASMBulkMemory() {
|
|
3184
|
+
try {
|
|
3185
|
+
return WebAssembly.validate(
|
|
3186
|
+
new Uint8Array([
|
|
3187
|
+
0,
|
|
3188
|
+
97,
|
|
3189
|
+
115,
|
|
3190
|
+
109,
|
|
3191
|
+
1,
|
|
3192
|
+
0,
|
|
3193
|
+
0,
|
|
3194
|
+
0,
|
|
3195
|
+
1,
|
|
3196
|
+
4,
|
|
3197
|
+
1,
|
|
3198
|
+
96,
|
|
3199
|
+
0,
|
|
3200
|
+
0,
|
|
3201
|
+
3,
|
|
3202
|
+
2,
|
|
3203
|
+
1,
|
|
3204
|
+
0,
|
|
3205
|
+
5,
|
|
3206
|
+
3,
|
|
3207
|
+
1,
|
|
3208
|
+
0,
|
|
3209
|
+
1,
|
|
3210
|
+
10,
|
|
3211
|
+
13,
|
|
3212
|
+
1,
|
|
3213
|
+
11,
|
|
3214
|
+
0,
|
|
3215
|
+
65,
|
|
3216
|
+
0,
|
|
3217
|
+
65,
|
|
3218
|
+
0,
|
|
3219
|
+
65,
|
|
3220
|
+
0,
|
|
3221
|
+
252,
|
|
3222
|
+
11,
|
|
3223
|
+
0,
|
|
3224
|
+
11
|
|
3225
|
+
])
|
|
3226
|
+
);
|
|
3227
|
+
} catch {
|
|
3228
|
+
return false;
|
|
3229
|
+
}
|
|
3230
|
+
}
|
|
3231
|
+
function checkMobileWASMCompatibility() {
|
|
3232
|
+
const issues = [];
|
|
3233
|
+
const recommendations = [];
|
|
3234
|
+
let score = 100;
|
|
3235
|
+
const webAssembly = typeof WebAssembly !== "undefined";
|
|
3236
|
+
if (!webAssembly) {
|
|
3237
|
+
issues.push("WebAssembly not supported");
|
|
3238
|
+
score -= 50;
|
|
3239
|
+
}
|
|
3240
|
+
const sharedArrayBuffer = supportsSharedArrayBuffer();
|
|
3241
|
+
if (!sharedArrayBuffer) {
|
|
3242
|
+
issues.push("SharedArrayBuffer not available (requires COOP/COEP headers)");
|
|
3243
|
+
recommendations.push("Server must send Cross-Origin-Opener-Policy: same-origin");
|
|
3244
|
+
recommendations.push("Server must send Cross-Origin-Embedder-Policy: require-corp");
|
|
3245
|
+
score -= 20;
|
|
3246
|
+
}
|
|
3247
|
+
const webWorkers = supportsWebWorkers();
|
|
3248
|
+
if (!webWorkers) {
|
|
3249
|
+
issues.push("Web Workers not supported");
|
|
3250
|
+
recommendations.push("Consider using a polyfill or fallback to main-thread execution");
|
|
3251
|
+
score -= 15;
|
|
3252
|
+
}
|
|
3253
|
+
const simd = supportsWASMSimd();
|
|
3254
|
+
if (!simd) {
|
|
3255
|
+
recommendations.push("WASM SIMD not supported - proofs will be slower");
|
|
3256
|
+
score -= 5;
|
|
3257
|
+
}
|
|
3258
|
+
const bulkMemory = supportsWASMBulkMemory();
|
|
3259
|
+
if (!bulkMemory) {
|
|
3260
|
+
recommendations.push("WASM bulk memory not supported - may affect performance");
|
|
3261
|
+
score -= 5;
|
|
3262
|
+
}
|
|
3263
|
+
const bigInt = typeof BigInt !== "undefined";
|
|
3264
|
+
if (!bigInt) {
|
|
3265
|
+
issues.push("BigInt not supported (required for 64-bit operations)");
|
|
3266
|
+
score -= 10;
|
|
3267
|
+
}
|
|
3268
|
+
const deviceInfo = getMobileDeviceInfo();
|
|
3269
|
+
if (deviceInfo.isMobile) {
|
|
3270
|
+
if (deviceInfo.deviceMemoryGB !== null && deviceInfo.deviceMemoryGB < 2) {
|
|
3271
|
+
recommendations.push(`Low device memory (${deviceInfo.deviceMemoryGB}GB) - may experience issues with large proofs`);
|
|
3272
|
+
score -= 5;
|
|
3273
|
+
}
|
|
3274
|
+
if (deviceInfo.platform === "ios" && deviceInfo.browser === "safari") {
|
|
3275
|
+
if (!sharedArrayBuffer) {
|
|
3276
|
+
recommendations.push("iOS Safari requires iOS 15.2+ for SharedArrayBuffer support");
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
if (deviceInfo.platform === "android" && deviceInfo.browser === "chrome") {
|
|
3280
|
+
if (!sharedArrayBuffer) {
|
|
3281
|
+
recommendations.push("Ensure COOP/COEP headers are set - Chrome Android requires them");
|
|
3282
|
+
}
|
|
3283
|
+
}
|
|
3284
|
+
}
|
|
3285
|
+
let summary;
|
|
3286
|
+
if (score >= 90) {
|
|
3287
|
+
summary = "Excellent - Full WASM proof support";
|
|
3288
|
+
} else if (score >= 70) {
|
|
3289
|
+
summary = "Good - WASM proofs supported with minor limitations";
|
|
3290
|
+
} else if (score >= 50) {
|
|
3291
|
+
summary = "Limited - WASM proofs may work with reduced performance";
|
|
3292
|
+
} else {
|
|
3293
|
+
summary = "Poor - WASM proofs not recommended on this device";
|
|
3294
|
+
}
|
|
3295
|
+
return {
|
|
3296
|
+
webAssembly,
|
|
3297
|
+
sharedArrayBuffer,
|
|
3298
|
+
webWorkers,
|
|
3299
|
+
simd,
|
|
3300
|
+
bulkMemory,
|
|
3301
|
+
bigInt,
|
|
3302
|
+
score: Math.max(0, score),
|
|
3303
|
+
summary,
|
|
3304
|
+
issues,
|
|
3305
|
+
recommendations
|
|
3306
|
+
};
|
|
3307
|
+
}
|
|
3034
3308
|
function hexToBytes5(hex) {
|
|
3035
3309
|
const h = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
3036
3310
|
if (h.length === 0) return new Uint8Array(0);
|
|
@@ -10612,6 +10886,16 @@ export {
|
|
|
10612
10886
|
createSIP,
|
|
10613
10887
|
createProductionSIP,
|
|
10614
10888
|
MockProofProvider,
|
|
10889
|
+
detectMobilePlatform,
|
|
10890
|
+
detectMobileBrowser,
|
|
10891
|
+
getBrowserVersion,
|
|
10892
|
+
getOSVersion,
|
|
10893
|
+
isTablet,
|
|
10894
|
+
supportsTouch,
|
|
10895
|
+
getMobileDeviceInfo,
|
|
10896
|
+
supportsWASMSimd,
|
|
10897
|
+
supportsWASMBulkMemory,
|
|
10898
|
+
checkMobileWASMCompatibility,
|
|
10615
10899
|
hexToBytes5 as hexToBytes,
|
|
10616
10900
|
bytesToHex7 as bytesToHex,
|
|
10617
10901
|
isBrowser,
|