Optimize JSON and QR codes
- Replaced original JSON with minimized binary format (gzip + base64). - Adjusted rendering and QR code generation for compatibility. - Reduced payload size for improved efficiency.
This commit is contained in:
1 parent
ec04bebf22
commit
d2830b9c46
8 files changed
+824
-212
No files matched your search
+1
-1
@@ -1 +1 @@
|
||||
*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border:0 solid #e5e7eb}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media Line truncated
|
||||
*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border:0 solid #e5e7eb}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media Line truncated
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../src/crypto/EnhancedSecureCryptoUtils.js", "../src/transfer/EnhancedSecureFileTransfer.js", "../src/network/EnhancedSecureWebRTCManager.js", "../src/components/ui/SessionTimer.jsx", "../src/components/ui/Header.jsx", "../src/components/ui/DownloadApps.jsx", "../src/components/ui/UniqueFeatureSlider.jsx", "../src/components/ui/SecurityFeatures.jsx", "../src/components/ui/Testimonials.jsx", "../src/components/ui/ComparisonTable.jsx", "../src/components/ui/Roadmap.jsx", "../src/components/ui/FileTransfer.jsx", "../src/scripts/app-boot.js"],
|
||||
"sourcesContent": ["class EnhancedSecureCryptoUtils {\n\n static _keyMetadata = new WeakMap();\n \n // Initialize secure logging system after class definition\n\n // Utility to sort object keys for deterministic serialization\n static sortObjectKeys(obj) {\n if (typeof obj !== 'object' || obj === null) {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map(EnhancedSecureCryptoUtils.sortObjectKeys);\n }\n\n const sortedObj = {};\n Object.keys(obj).sort().forEach(key => {\n sortedObj[key] = EnhancedSecureCryptoUtils.sortObjectKeys(obj[key]);\n });\n return sortedObj;\n }\n\n // Utility to assert CryptoKey type and properties\n static assertCryptoKey(key, expectedName = null, expectedUsages = []) {\n if (!(key instanceof CryptoKey)) throw new Error('Expected CryptoKey');\n if (expectedName && key.algorithm?.name !== expectedName) {\n throw new Error(`Expected algorithm ${expectedName}, got ${key.algorithm?.name}`);\n }\n for (const u of expectedUsages) {\n if (!key.usages || !key.usages.includes(u)) {\n throw new Error(`Missing required key usage: ${u}`);\n }\n }\n }\n // Helper function to convert ArrayBuffer to Base64\n static arrayBufferToBase64(buffer) {\n let binary = '';\n const bytes = new Uint8Array(buffer);\n const len = bytes.byteLength;\n for (let i = 0; i < len; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n }\n\n // Helper function to convert Base64 to ArrayBuffer\n static base64ToArrayBuffer(base64) {\n try {\n // Validate input\n if (typeof base64 !== 'string' || !base64) {\n throw new Error('Invalid base64 input: must be a non-empty string');\n }\n\n // Remove any whitespace and validate base64 format\n const cleanBase64 = base64.trim();\n if (!/^[A-Za-z0-9+/]*={0,2}$/.test(cleanBase64)) {\n throw new Error('Invalid base64 format');\n }\n\n // Handle empty string case\n if (cleanBase64 === '') {\n return new ArrayBuffer(0);\n }\n\n const binaryString = atob(cleanBase64);\n const len = binaryString.length;\n const bytes = new Uint8Array(len);\n for (let i = 0; i < len; i++) {\n bytes[i] = binaryString.charCodeAt(i);\n }\n return bytes.buffer;\n } catch (error) {\n console.error('Base64 to ArrayBuffer conversion failed:', error.message);\n throw new Error(`Base64 conversion error: ${error.message}`);\n }\n }\n\n // Helper function to convert hex string to Uint8Array\n static hexToUint8Array(hexString) {\n try {\n if (!hexString || typeof hexString !== 'string') {\n throw new Error('Invalid hex string input: must be a non-empty string');\n }\n\n // Remove colons and spaces from hex string (e.g., \"aa:bb:cc\" -> \"aabbcc\")\n const cleanHex = hexString.replace(/:/g, '').replace(/\\s/g, '');\n \n // Validate hex format\n if (!/^[0-9a-fA-F]*$/.test(cleanHex)) {\n throw new Error('Invalid hex format: contains non-hex characters');\n }\n \n // Ensure even length\n if (cleanHex.length % 2 !== 0) {\n throw new Error('Invalid hex format: odd length');\n }\n\n // Convert hex string to bytes\n const bytes = new Uint8Array(cleanHex.length / 2);\n for (let i = 0; i < cleanHex.length; i += 2) {\n bytes[i / 2] = parseInt(cleanHex.substr(i, 2), 16);\n }\n \n return bytes;\n } catch (error) {\n console.error('Hex to Uint8Array conversion failed:', error.message);\n throw new Error(`Hex conversion error: ${error.message}`);\n }\n }\n\n static async encryptData(data, password) {\n try {\n const dataString = typeof data === 'string' ? data : JSON.stringify(data);\n const salt = crypto.getRandomValues(new Uint8Array(16));\n const encoder = new TextEncoder();\n const passwordBuffer = encoder.encode(password);\n\n const keyMaterial = await crypto.subtle.importKey(\n 'raw',\n passwordBuffer,\n { name: 'PBKDF2' },\n false,\n ['deriveKey']\n );\n\n const key = await crypto.subtle.deriveKey(\n {\n name: 'PBKDF2',\n salt: salt,\n iterations: 100000,\n hash: 'SHA-256',\n },Line truncated
|
||||
"sourcesContent": ["class EnhancedSecureCryptoUtils {\r\n\r\n static _keyMetadata = new WeakMap();\r\n \r\n // Initialize secure logging system after class definition\r\n\r\n // Utility to sort object keys for deterministic serialization\r\n static sortObjectKeys(obj) {\r\n if (typeof obj !== 'object' || obj === null) {\r\n return obj;\r\n }\r\n\r\n if (Array.isArray(obj)) {\r\n return obj.map(EnhancedSecureCryptoUtils.sortObjectKeys);\r\n }\r\n\r\n const sortedObj = {};\r\n Object.keys(obj).sort().forEach(key => {\r\n sortedObj[key] = EnhancedSecureCryptoUtils.sortObjectKeys(obj[key]);\r\n });\r\n return sortedObj;\r\n }\r\n\r\n // Utility to assert CryptoKey type and properties\r\n static assertCryptoKey(key, expectedName = null, expectedUsages = []) {\r\n if (!(key instanceof CryptoKey)) throw new Error('Expected CryptoKey');\r\n if (expectedName && key.algorithm?.name !== expectedName) {\r\n throw new Error(`Expected algorithm ${expectedName}, got ${key.algorithm?.name}`);\r\n }\r\n for (const u of expectedUsages) {\r\n if (!key.usages || !key.usages.includes(u)) {\r\n throw new Error(`Missing required key usage: ${u}`);\r\n }\r\n }\r\n }\r\n // Helper function to convert ArrayBuffer to Base64\r\n static arrayBufferToBase64(buffer) {\r\n let binary = '';\r\n const bytes = new Uint8Array(buffer);\r\n const len = bytes.byteLength;\r\n for (let i = 0; i < len; i++) {\r\n binary += String.fromCharCode(bytes[i]);\r\n }\r\n return btoa(binary);\r\n }\r\n\r\n // Helper function to convert Base64 to ArrayBuffer\r\n static base64ToArrayBuffer(base64) {\r\n try {\r\n // Validate input\r\n if (typeof base64 !== 'string' || !base64) {\r\n throw new Error('Invalid base64 input: must be a non-empty string');\r\n }\r\n\r\n // Remove any whitespace and validate base64 format\r\n const cleanBase64 = base64.trim();\r\n if (!/^[A-Za-z0-9+/]*={0,2}$/.test(cleanBase64)) {\r\n throw new Error('Invalid base64 format');\r\n }\r\n\r\n // Handle empty string case\r\n if (cleanBase64 === '') {\r\n return new ArrayBuffer(0);\r\n }\r\n\r\n const binaryString = atob(cleanBase64);\r\n const len = binaryString.length;\r\n const bytes = new Uint8Array(len);\r\n for (let i = 0; i < len; i++) {\r\n bytes[i] = binaryString.charCodeAt(i);\r\n }\r\n return bytes.buffer;\r\n } catch (error) {\r\n console.error('Base64 to ArrayBuffer conversion failed:', error.message);\r\n throw new Error(`Base64 conversion error: ${error.message}`);\r\n }\r\n }\r\n\r\n // Helper function to convert hex string to Uint8Array\r\n static hexToUint8Array(hexString) {\r\n try {\r\n if (!hexString || typeof hexString !== 'string') {\r\n throw new Error('Invalid hex string input: must be a non-empty string');\r\n }\r\n\r\n // Remove colons and spaces from hex string (e.g., \"aa:bb:cc\" -> \"aabbcc\")\r\n const cleanHex = hexString.replace(/:/g, '').replace(/\\s/g, '');\r\n \r\n // Validate hex format\r\n if (!/^[0-9a-fA-F]*$/.test(cleanHex)) {\r\n throw new Error('Invalid hex format: contains non-hex characters');\r\n }\r\n \r\n // Ensure even length\r\n if (cleanHex.length % 2 !== 0) {\r\n throw new Error('Invalid hex format: odd length');\r\n }\r\n\r\n // Convert hex string to bytes\r\n const bytes = new Uint8Array(cleanHex.length / 2);\r\n for (let i = 0; i < cleanHex.length; i += 2) {\r\n bytes[i / 2] = parseInt(cleanHex.substr(i, 2), 16);\r\n }\r\n \r\n return bytes;\r\n } catch (error) {\r\n console.error('Hex to Uint8Array conversion failed:', error.message);\r\n throw new Error(`Hex conversion error: ${error.message}`);\r\n }\r\n }\r\n\r\n static async encryptData(data, password) {\r\n try {\r\n const dataString = typeof data === 'string' ? data : JSON.stringify(data);\r\n const salt = crypto.getRandomValues(new Uint8Array(16));\r\n const encoder = new TextEncoder();\r\n const passwordBuffer = encoder.encode(password);\r\n\r\n const keyMaterial = await crypto.subtle.importKey(\r\n 'raw',\r\n passwordBuffer,\r\n { name: 'PBKDF2' },\r\n false,\r\n ['deriveKey']\r\n Line truncated
|
||||
"mappings": ";AAAA,IAAM,4BAAN,MAAM,2BAA0B;AAAA,EAE5B,OAAO,eAAe,oBAAI,QAAQ;AAAA;AAAA;AAAA,EAKlC,OAAO,eAAe,KAAK;AACvB,QAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM;AACzC,aAAO;AAAA,IACX;AAEA,QAAI,MAAM,QAAQ,GAAG,GAAG;AACpB,aAAO,IAAI,IAAI,2BAA0B,cAAc;AAAA,IAC3D;AAEA,UAAM,YAAY,CAAC;AACnB,WAAO,KAAK,GAAG,EAAE,KAAK,EAAE,QAAQ,SAAO;AACnC,gBAAU,GAAG,IAAI,2BAA0B,eAAe,IAAI,GAAG,CAAC;AAAA,IACtE,CAAC;AACD,WAAO;AAAA,EACX;AAAA;AAAA,EAGA,OAAO,gBAAgB,KAAK,eAAe,MAAM,iBAAiB,CAAC,GAAG;AAClE,QAAI,EAAE,eAAe,WAAY,OAAM,IAAI,MAAM,oBAAoB;AACrE,QAAI,gBAAgB,IAAI,WAAW,SAAS,cAAc;AACtD,YAAM,IAAI,MAAM,sBAAsB,YAAY,SAAS,IAAI,WAAW,IAAI,EAAE;AAAA,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WAAW,KAAK,IAAI;AAAA,UACpB,SAAS;AAAA,UACT,YAAY;AAAA,QAChB;AAAA,MACJ;AAGA,YAAM,cAAc;AACpB,YAAM,gBAAgB;AAGtB,UAAI;AACA,cAAM,mBAAmB,MAAM,2BAA0B,iBAAiB,eAAe;AACzF,YAAI,iBAAiB,QAAQ;AACzB,mBAAS;AACT,8BAAoB,mBAAmB,EAAE,QAAQ,MAAM,SAAS,Line truncated
|
||||
"names": ["fileMessageTypes", "attempts", "start", "error", "attempts", "chunk", "fileMessageTypes", "window", "start", "webrtcManager", "start"]
|
||||
}
|
||||
Vendored
+272
-81
@@ -489,7 +489,7 @@ var EnhancedConnectionSetup = ({
|
||||
}, "Creating a secure channel")
|
||||
]),
|
||||
// Step 1
|
||||
React.createElement("div", {
|
||||
!showAnswerStep && React.createElement("div", {
|
||||
key: "step1",
|
||||
className: "card-minimal rounded-xl p-6"
|
||||
}, [
|
||||
@@ -510,16 +510,16 @@ var EnhancedConnectionSetup = ({
|
||||
key: "description",
|
||||
className: "text-secondary text-sm mb-4"
|
||||
}, "Creating cryptographically strong keys and codes to protect against attacks"),
|
||||
React.createElement("button", {
|
||||
!showOfferStep && React.createElement("button", {
|
||||
key: "create-btn",
|
||||
onClick: onCreateOffer,
|
||||
disabled: connectionStatus === "connecting" || showOfferStep,
|
||||
disabled: connectionStatus === "connecting",
|
||||
className: `w-full btn-primary text-white py-3 px-4 rounded-lg font-medium transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed`
|
||||
}, [
|
||||
React.createElement("i", {
|
||||
className: "fas fa-shield-alt mr-2"
|
||||
}),
|
||||
showOfferStep ? "Keys created \u2713" : "Create secure keys"
|
||||
"Create secure keys"
|
||||
]),
|
||||
showOfferStep && React.createElement("div", {
|
||||
key: "offer-result",
|
||||
@@ -542,46 +542,29 @@ var EnhancedConnectionSetup = ({
|
||||
key: "offer-data",
|
||||
className: "space-y-3"
|
||||
}, [
|
||||
React.createElement("textarea", {
|
||||
key: "textarea",
|
||||
value: typeof offerData === "object" ? JSON.stringify(offerData, null, 2) : offerData,
|
||||
readOnly: true,
|
||||
rows: 8,
|
||||
className: "w-full p-3 bg-custom-bg border border-gray-500/20 rounded-lg font-mono text-xs text-secondary resize-none custom-scrollbar"
|
||||
}),
|
||||
// Raw JSON hidden intentionally; users copy compressed string or use QR
|
||||
React.createElement("div", {
|
||||
key: "buttons",
|
||||
className: "flex gap-2"
|
||||
}, [
|
||||
React.createElement(EnhancedCopyButton, {
|
||||
key: "copy",
|
||||
text: typeof offerData === "object" ? JSON.stringify(offerData, null, 2) : offerData,
|
||||
className: "flex-1 px-3 py-2 bg-orange-500/10 hover:bg-orange-500/20 text-orange-400 border border-orange-500/20 rounded text-sm font-medium"
|
||||
}, "Copy invitation code"),
|
||||
React.createElement("button", {
|
||||
key: "qr-toggle",
|
||||
onClick: async () => {
|
||||
const next = !showQRCode;
|
||||
setShowQRCode(next);
|
||||
if (next) {
|
||||
try {
|
||||
const payload = typeof offerData === "object" ? JSON.stringify(offerData) : offerData;
|
||||
if (payload && payload.length) {
|
||||
await generateQRCode(payload);
|
||||
}
|
||||
} catch (e2) {
|
||||
console.warn("QR regenerate on toggle failed:", e2);
|
||||
text: (() => {
|
||||
try {
|
||||
const min = typeof offerData === "object" ? JSON.stringify(offerData) : offerData || "";
|
||||
if (typeof window.encodeBinaryToPrefixed === "function") {
|
||||
return window.encodeBinaryToPrefixed(min);
|
||||
}
|
||||
if (typeof window.compressToPrefixedGzip === "function") {
|
||||
return window.compressToPrefixedGzip(min);
|
||||
}
|
||||
return min;
|
||||
} catch {
|
||||
return typeof offerData === "object" ? JSON.stringify(offerData) : offerData || "";
|
||||
}
|
||||
},
|
||||
className: "px-3 py-2 bg-blue-500/10 hover:bg-blue-500/20 text-blue-400 border border-blue-500/20 rounded text-sm font-medium transition-all duration-200"
|
||||
}, [
|
||||
React.createElement("i", {
|
||||
key: "icon",
|
||||
className: showQRCode ? "fas fa-eye-slash mr-1" : "fas fa-qrcode mr-1"
|
||||
}),
|
||||
showQRCode ? "Hide QR" : "Show QR"
|
||||
])
|
||||
})(),
|
||||
className: "flex-1 px-3 py-2 bg-orange-500/10 hover:bg-orange-500/20 text-orange-400 border border-orange-500/20 rounded text-sm font-medium"
|
||||
}, "Copy invitation code")
|
||||
]),
|
||||
showQRCode && qrCodeUrl && React.createElement("div", {
|
||||
key: "qr-container",
|
||||
@@ -785,8 +768,7 @@ var EnhancedConnectionSetup = ({
|
||||
className: "text-xl font-semibold text-primary mb-2"
|
||||
}, "Joining the secure channel")
|
||||
]),
|
||||
// Step 1
|
||||
React.createElement("div", {
|
||||
showAnswerStep ? null : React.createElement("div", {
|
||||
key: "step1",
|
||||
className: "card-minimal rounded-xl p-6"
|
||||
}, [
|
||||
@@ -934,16 +916,23 @@ var EnhancedConnectionSetup = ({
|
||||
key: "answer-data",
|
||||
className: "space-y-3 mb-4"
|
||||
}, [
|
||||
React.createElement("textarea", {
|
||||
key: "textarea",
|
||||
value: typeof answerData === "object" ? JSON.stringify(answerData, null, 2) : answerData,
|
||||
readOnly: true,
|
||||
rows: 6,
|
||||
className: "w-full p-3 bg-custom-bg border border-green-500/20 rounded-lg font-mono text-xs text-secondary resize-none custom-scrollbar"
|
||||
}),
|
||||
// Raw JSON hidden intentionally; users copy compressed string or use QR
|
||||
React.createElement(EnhancedCopyButton, {
|
||||
key: "copy",
|
||||
text: typeof answerData === "object" ? JSON.stringify(answerData, null, 2) : answerData,
|
||||
text: (() => {
|
||||
try {
|
||||
const min = typeof answerData === "object" ? JSON.stringify(answerData) : answerData || "";
|
||||
if (typeof window.encodeBinaryToPrefixed === "function") {
|
||||
return window.encodeBinaryToPrefixed(min);
|
||||
}
|
||||
if (typeof window.compressToPrefixedGzip === "function") {
|
||||
return window.compressToPrefixedGzip(min);
|
||||
}
|
||||
return min;
|
||||
} catch {
|
||||
return typeof answerData === "object" ? JSON.stringify(answerData) : answerData || "";
|
||||
}
|
||||
})(),
|
||||
className: "w-full px-3 py-2 bg-green-500/10 hover:bg-green-500/20 text-green-400 border border-green-500/20 rounded text-sm font-medium"
|
||||
}, "Copy response code")
|
||||
]),
|
||||
@@ -1823,6 +1812,7 @@ var EnhancedSecureP2PChat = () => {
|
||||
return templateOffer;
|
||||
};
|
||||
const MAX_QR_LEN = 800;
|
||||
const BIN_MAX_QR_LEN = 400;
|
||||
const [qrFramesTotal, setQrFramesTotal] = React.useState(0);
|
||||
const [qrFrameIndex, setQrFrameIndex] = React.useState(0);
|
||||
const [qrManualMode, setQrManualMode] = React.useState(false);
|
||||
@@ -1839,6 +1829,29 @@ var EnhancedSecureP2PChat = () => {
|
||||
setQrFramesTotal(0);
|
||||
setQrManualMode(false);
|
||||
};
|
||||
const renderCurrent = async () => {
|
||||
const { chunks, idx } = qrAnimationRef.current || {};
|
||||
if (!chunks || !chunks.length) return;
|
||||
const current = chunks[idx % chunks.length];
|
||||
try {
|
||||
const isDesktop = typeof window !== "undefined" && (window.innerWidth || 0) >= 1024;
|
||||
const QR_SIZE = isDesktop ? 720 : 512;
|
||||
const url = await (window.generateQRCode ? window.generateQRCode(current, { errorCorrectionLevel: "M", margin: 2, size: QR_SIZE }) : Promise.resolve(""));
|
||||
if (url) setQrCodeUrl(url);
|
||||
} catch (e2) {
|
||||
console.warn("Animated QR render error (current):", e2);
|
||||
}
|
||||
setQrFrameIndex((qrAnimationRef.current?.idx || 0) % (qrAnimationRef.current?.chunks?.length || 1) + 1);
|
||||
};
|
||||
const renderAndAdvance = async () => {
|
||||
await renderCurrent();
|
||||
const len = qrAnimationRef.current?.chunks?.length || 0;
|
||||
if (len > 0) {
|
||||
const nextIdx = ((qrAnimationRef.current?.idx || 0) + 1) % len;
|
||||
qrAnimationRef.current.idx = nextIdx;
|
||||
setQrFrameIndex(nextIdx + 1);
|
||||
}
|
||||
};
|
||||
const toggleQrManualMode = () => {
|
||||
const newManualMode = !qrManualMode;
|
||||
setQrManualMode(newManualMode);
|
||||
@@ -1849,39 +1862,65 @@ var EnhancedSecureP2PChat = () => {
|
||||
}
|
||||
console.log("QR Manual mode enabled - auto-scroll stopped");
|
||||
} else {
|
||||
if (qrAnimationRef.current.chunks.length > 1 && qrAnimationRef.current.active) {
|
||||
const intervalMs = 4e3;
|
||||
qrAnimationRef.current.timer = setInterval(renderNext, intervalMs);
|
||||
if (qrAnimationRef.current.chunks.length > 1) {
|
||||
const intervalMs = 3e3;
|
||||
qrAnimationRef.current.active = true;
|
||||
clearInterval(qrAnimationRef.current.timer);
|
||||
qrAnimationRef.current.timer = setInterval(renderAndAdvance, intervalMs);
|
||||
}
|
||||
console.log("QR Manual mode disabled - auto-scroll resumed");
|
||||
}
|
||||
};
|
||||
const nextQrFrame = () => {
|
||||
const nextQrFrame = async () => {
|
||||
console.log("\u{1F3AE} nextQrFrame called, qrFramesTotal:", qrFramesTotal, "qrAnimationRef.current:", qrAnimationRef.current);
|
||||
if (qrAnimationRef.current.chunks.length > 1) {
|
||||
const nextIdx = (qrAnimationRef.current.idx + 1) % qrAnimationRef.current.chunks.length;
|
||||
qrAnimationRef.current.idx = nextIdx;
|
||||
setQrFrameIndex(nextIdx + 1);
|
||||
console.log("\u{1F3AE} Next frame index:", nextIdx + 1);
|
||||
renderNext();
|
||||
try {
|
||||
clearInterval(qrAnimationRef.current.timer);
|
||||
} catch {
|
||||
}
|
||||
qrAnimationRef.current.timer = null;
|
||||
await renderCurrent();
|
||||
if (!qrManualMode && qrAnimationRef.current.chunks.length > 1) {
|
||||
const intervalMs = 3e3;
|
||||
qrAnimationRef.current.active = true;
|
||||
qrAnimationRef.current.timer = setInterval(renderAndAdvance, intervalMs);
|
||||
} else {
|
||||
qrAnimationRef.current.active = false;
|
||||
}
|
||||
} else {
|
||||
console.log("\u{1F3AE} No multiple frames to navigate");
|
||||
}
|
||||
};
|
||||
const prevQrFrame = () => {
|
||||
const prevQrFrame = async () => {
|
||||
console.log("\u{1F3AE} prevQrFrame called, qrFramesTotal:", qrFramesTotal, "qrAnimationRef.current:", qrAnimationRef.current);
|
||||
if (qrAnimationRef.current.chunks.length > 1) {
|
||||
const prevIdx = (qrAnimationRef.current.idx - 1 + qrAnimationRef.current.chunks.length) % qrAnimationRef.current.chunks.length;
|
||||
qrAnimationRef.current.idx = prevIdx;
|
||||
setQrFrameIndex(prevIdx + 1);
|
||||
console.log("\u{1F3AE} Previous frame index:", prevIdx + 1);
|
||||
renderNext();
|
||||
try {
|
||||
clearInterval(qrAnimationRef.current.timer);
|
||||
} catch {
|
||||
}
|
||||
qrAnimationRef.current.timer = null;
|
||||
await renderCurrent();
|
||||
if (!qrManualMode && qrAnimationRef.current.chunks.length > 1) {
|
||||
const intervalMs = 3e3;
|
||||
qrAnimationRef.current.active = true;
|
||||
qrAnimationRef.current.timer = setInterval(renderAndAdvance, intervalMs);
|
||||
} else {
|
||||
qrAnimationRef.current.active = false;
|
||||
}
|
||||
} else {
|
||||
console.log("\u{1F3AE} No multiple frames to navigate");
|
||||
}
|
||||
};
|
||||
const qrChunksBufferRef = React.useRef({ id: null, total: 0, seen: /* @__PURE__ */ new Set(), items: [] });
|
||||
const generateQRCode2 = async (data) => {
|
||||
const generateQRCode = async (data) => {
|
||||
try {
|
||||
const originalSize = typeof data === "string" ? data.length : JSON.stringify(data).length;
|
||||
const payload = typeof data === "string" ? data : JSON.stringify(data);
|
||||
@@ -1889,14 +1928,32 @@ var EnhancedSecureP2PChat = () => {
|
||||
const QR_SIZE = isDesktop ? 720 : 512;
|
||||
if (payload.length <= MAX_QR_LEN) {
|
||||
if (!window.generateQRCode) throw new Error("QR code generator unavailable");
|
||||
stopQrAnimation();
|
||||
try {
|
||||
if (qrAnimationRef.current && qrAnimationRef.current.timer) {
|
||||
clearInterval(qrAnimationRef.current.timer);
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
qrAnimationRef.current = { timer: null, chunks: [], idx: 0, active: false };
|
||||
setQrFrameIndex(0);
|
||||
setQrFramesTotal(0);
|
||||
setQrManualMode(false);
|
||||
const qrDataUrl = await window.generateQRCode(payload, { errorCorrectionLevel: "M", size: QR_SIZE, margin: 2 });
|
||||
setQrCodeUrl(qrDataUrl);
|
||||
setQrFramesTotal(1);
|
||||
setQrFrameIndex(1);
|
||||
return;
|
||||
}
|
||||
stopQrAnimation();
|
||||
try {
|
||||
if (qrAnimationRef.current && qrAnimationRef.current.timer) {
|
||||
clearInterval(qrAnimationRef.current.timer);
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
qrAnimationRef.current = { timer: null, chunks: [], idx: 0, active: false };
|
||||
setQrFrameIndex(0);
|
||||
setQrFramesTotal(0);
|
||||
setQrManualMode(false);
|
||||
const id = `raw_${Date.now()}_${Math.random().toString(36).slice(2)}`;
|
||||
const TARGET_CHUNKS = 10;
|
||||
const FRAME_MAX = Math.max(200, Math.floor(payload.length / TARGET_CHUNKS));
|
||||
@@ -1921,26 +1978,11 @@ var EnhancedSecureP2PChat = () => {
|
||||
setQrFramesTotal(rawChunks.length);
|
||||
setQrFrameIndex(1);
|
||||
const EC_OPTS = { errorCorrectionLevel: "M", margin: 2, size: QR_SIZE };
|
||||
const renderNext2 = async () => {
|
||||
const { chunks, idx, active } = qrAnimationRef.current;
|
||||
if (!active || !chunks.length) return;
|
||||
const current = chunks[idx % chunks.length];
|
||||
try {
|
||||
const url = await window.generateQRCode(current, EC_OPTS);
|
||||
setQrCodeUrl(url);
|
||||
} catch (e2) {
|
||||
console.warn("Animated QR render error (raw):", e2);
|
||||
}
|
||||
const nextIdx = (idx + 1) % chunks.length;
|
||||
qrAnimationRef.current.idx = nextIdx;
|
||||
setQrFrameIndex(nextIdx + 1);
|
||||
};
|
||||
await renderNext2();
|
||||
await renderNext();
|
||||
if (!qrManualMode) {
|
||||
const ua = typeof navigator !== "undefined" && navigator.userAgent ? navigator.userAgent : "";
|
||||
const isIOS = /iPhone|iPad|iPod/i.test(ua);
|
||||
const intervalMs = 4e3;
|
||||
qrAnimationRef.current.timer = setInterval(renderNext2, intervalMs);
|
||||
qrAnimationRef.current.active = true;
|
||||
qrAnimationRef.current.timer = setInterval(renderAndAdvance, intervalMs);
|
||||
}
|
||||
return;
|
||||
} catch (error) {
|
||||
@@ -2018,7 +2060,18 @@ var EnhancedSecureP2PChat = () => {
|
||||
};
|
||||
const handleQRScan = async (scannedData) => {
|
||||
try {
|
||||
const parsedData = JSON.parse(scannedData);
|
||||
let parsedData;
|
||||
if (typeof window.decodeAnyPayload === "function") {
|
||||
const any = window.decodeAnyPayload(scannedData);
|
||||
if (typeof any === "string") {
|
||||
parsedData = JSON.parse(any);
|
||||
} else {
|
||||
parsedData = any;
|
||||
}
|
||||
} else {
|
||||
const maybeDecompressed = typeof window.decompressIfNeeded === "function" ? window.decompressIfNeeded(scannedData) : scannedData;
|
||||
parsedData = JSON.parse(maybeDecompressed);
|
||||
}
|
||||
if (parsedData.hdr && parsedData.body) {
|
||||
const { hdr } = parsedData;
|
||||
if (!qrChunksBufferRef.current.id || qrChunksBufferRef.current.id !== hdr.id) {
|
||||
@@ -2064,6 +2117,34 @@ var EnhancedSecureP2PChat = () => {
|
||||
console.warn("RAW multi-frame reconstruction failed:", e2);
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
} else if (hdr.rt === "bin") {
|
||||
try {
|
||||
const parts = qrChunksBufferRef.current.items.map((s) => JSON.parse(s)).sort((a, b) => (a.hdr.seq || 0) - (b.hdr.seq || 0)).map((p) => p.body || "");
|
||||
const fullText = parts.join("");
|
||||
let payloadObj;
|
||||
if (typeof window.decodeAnyPayload === "function") {
|
||||
const any = window.decodeAnyPayload(fullText);
|
||||
payloadObj = typeof any === "string" ? JSON.parse(any) : any;
|
||||
} else {
|
||||
payloadObj = JSON.parse(fullText);
|
||||
}
|
||||
if (showOfferStep) {
|
||||
setAnswerInput(JSON.stringify(payloadObj, null, 2));
|
||||
} else {
|
||||
setOfferInput(JSON.stringify(payloadObj, null, 2));
|
||||
}
|
||||
setMessages((prev) => [...prev, { message: "All frames captured. BIN payload reconstructed.", type: "success" }]);
|
||||
try {
|
||||
document.dispatchEvent(new CustomEvent("qr-scan-complete", { detail: { id: hdr.id } }));
|
||||
} catch {
|
||||
}
|
||||
qrChunksBufferRef.current = { id: null, total: 0, seen: /* @__PURE__ */ new Set(), items: [] };
|
||||
setShowQRScannerModal(false);
|
||||
return Promise.resolve(true);
|
||||
} catch (e2) {
|
||||
console.warn("BIN multi-frame reconstruction failed:", e2);
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
} else if (window.receiveAndProcess) {
|
||||
try {
|
||||
const results = await window.receiveAndProcess(qrChunksBufferRef.current.items);
|
||||
@@ -2130,9 +2211,9 @@ var EnhancedSecureP2PChat = () => {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!parsedData.sdp) {
|
||||
if (!parsedData.sdp && parsedData.type === "enhanced_secure_offer") {
|
||||
setMessages((prev) => [...prev, {
|
||||
message: "QR code contains compressed data (SDP removed). Please use copy/paste for full data.",
|
||||
message: "Compressed QR may omit SDP for brevity. Use copy/paste if connection fails.",
|
||||
type: "warning"
|
||||
}]);
|
||||
}
|
||||
@@ -2174,7 +2255,50 @@ var EnhancedSecureP2PChat = () => {
|
||||
setOfferData(offer);
|
||||
setShowOfferStep(true);
|
||||
const offerString = typeof offer === "object" ? JSON.stringify(offer) : offer;
|
||||
await generateQRCode2(offerString);
|
||||
try {
|
||||
if (typeof window.encodeBinaryToPrefixed === "function") {
|
||||
const bin = window.encodeBinaryToPrefixed(offerString);
|
||||
const id = `bin_${Date.now()}_${Math.random().toString(36).slice(2)}`;
|
||||
const TARGET_CHUNKS = 10;
|
||||
let FRAME_MAX = Math.max(200, Math.floor(bin.length / TARGET_CHUNKS));
|
||||
if (FRAME_MAX <= 0) FRAME_MAX = 200;
|
||||
let total = Math.ceil(bin.length / FRAME_MAX);
|
||||
if (total < 2) {
|
||||
total = 2;
|
||||
FRAME_MAX = Math.ceil(bin.length / 2) || 1;
|
||||
}
|
||||
const chunks = [];
|
||||
for (let i = 0; i < total; i++) {
|
||||
const seq = i + 1;
|
||||
const part = bin.slice(i * FRAME_MAX, (i + 1) * FRAME_MAX);
|
||||
chunks.push(JSON.stringify({ hdr: { v: 1, id, seq, total, rt: "bin" }, body: part }));
|
||||
}
|
||||
const isDesktop = typeof window !== "undefined" && (window.innerWidth || 0) >= 1024;
|
||||
const QR_SIZE = isDesktop ? 720 : 512;
|
||||
if (window.generateQRCode && chunks.length > 0) {
|
||||
const firstUrl = await window.generateQRCode(chunks[0], { errorCorrectionLevel: "M", size: QR_SIZE, margin: 2 });
|
||||
if (firstUrl) setQrCodeUrl(firstUrl);
|
||||
}
|
||||
try {
|
||||
if (qrAnimationRef.current && qrAnimationRef.current.timer) {
|
||||
clearInterval(qrAnimationRef.current.timer);
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
qrAnimationRef.current = { timer: null, chunks, idx: 0, active: true };
|
||||
setQrFramesTotal(chunks.length);
|
||||
setQrFrameIndex(1);
|
||||
setQrManualMode(false);
|
||||
const intervalMs = 3e3;
|
||||
qrAnimationRef.current.timer = setInterval(renderAndAdvance, intervalMs);
|
||||
try {
|
||||
setShowQRCode(true);
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
} catch (e2) {
|
||||
console.warn("Offer QR precompute failed:", e2);
|
||||
}
|
||||
const existingMessages = messages.filter(
|
||||
(m) => m.type === "system" && (m.message.includes("Secure invitation created") || m.message.includes("Send the encrypted code"))
|
||||
);
|
||||
@@ -2224,7 +2348,13 @@ var EnhancedSecureP2PChat = () => {
|
||||
}]);
|
||||
let offer;
|
||||
try {
|
||||
offer = JSON.parse(offerInput.trim());
|
||||
if (typeof window.decodeAnyPayload === "function") {
|
||||
const any = window.decodeAnyPayload(offerInput.trim());
|
||||
offer = typeof any === "string" ? JSON.parse(any) : any;
|
||||
} else {
|
||||
const rawText = typeof window.decompressIfNeeded === "function" ? window.decompressIfNeeded(offerInput.trim()) : offerInput.trim();
|
||||
offer = JSON.parse(rawText);
|
||||
}
|
||||
} catch (parseError) {
|
||||
throw new Error(`Invalid invitation format: ${parseError.message}`);
|
||||
}
|
||||
@@ -2239,7 +2369,62 @@ var EnhancedSecureP2PChat = () => {
|
||||
setAnswerData(answer);
|
||||
setShowAnswerStep(true);
|
||||
const answerString = typeof answer === "object" ? JSON.stringify(answer) : answer;
|
||||
await generateQRCode2(answerString);
|
||||
try {
|
||||
if (typeof window.encodeBinaryToPrefixed === "function") {
|
||||
const bin = window.encodeBinaryToPrefixed(answerString);
|
||||
const id = `ans_${Date.now()}_${Math.random().toString(36).slice(2)}`;
|
||||
const TARGET_CHUNKS = 10;
|
||||
let FRAME_MAX = Math.max(200, Math.floor(bin.length / TARGET_CHUNKS));
|
||||
if (FRAME_MAX <= 0) FRAME_MAX = 200;
|
||||
let total = Math.ceil(bin.length / FRAME_MAX);
|
||||
if (total < 2) {
|
||||
total = 2;
|
||||
FRAME_MAX = Math.ceil(bin.length / 2) || 1;
|
||||
}
|
||||
const chunks = [];
|
||||
for (let i = 0; i < total; i++) {
|
||||
const seq = i + 1;
|
||||
const part = bin.slice(i * FRAME_MAX, (i + 1) * FRAME_MAX);
|
||||
chunks.push(JSON.stringify({ hdr: { v: 1, id, seq, total, rt: "bin" }, body: part }));
|
||||
}
|
||||
const isDesktop = typeof window !== "undefined" && (window.innerWidth || 0) >= 1024;
|
||||
const QR_SIZE = isDesktop ? 720 : 512;
|
||||
if (window.generateQRCode && chunks.length > 0) {
|
||||
const firstUrl = await window.generateQRCode(chunks[0], { errorCorrectionLevel: "M", size: QR_SIZE, margin: 2 });
|
||||
if (firstUrl) setQrCodeUrl(firstUrl);
|
||||
}
|
||||
try {
|
||||
if (qrAnimationRef.current && qrAnimationRef.current.timer) {
|
||||
clearInterval(qrAnimationRef.current.timer);
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
qrAnimationRef.current = { timer: null, chunks, idx: 0, active: true };
|
||||
setQrFramesTotal(chunks.length);
|
||||
setQrFrameIndex(1);
|
||||
setQrManualMode(false);
|
||||
const intervalMs = 3e3;
|
||||
qrAnimationRef.current.timer = setInterval(renderAndAdvance, intervalMs);
|
||||
try {
|
||||
setShowQRCode(true);
|
||||
} catch {
|
||||
}
|
||||
} else {
|
||||
let url = "";
|
||||
if (typeof window.generateCompressedQRCode === "function") {
|
||||
url = await window.generateCompressedQRCode(answerString);
|
||||
} else {
|
||||
url = await generateQRCode(answerString);
|
||||
}
|
||||
if (url) setQrCodeUrl(url);
|
||||
try {
|
||||
setShowQRCode(true);
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
} catch (e2) {
|
||||
console.warn("Answer QR generation failed:", e2);
|
||||
}
|
||||
if (e.target.value.trim().length > 0) {
|
||||
if (typeof markAnswerCreated === "function") {
|
||||
markAnswerCreated();
|
||||
@@ -2304,7 +2489,13 @@ var EnhancedSecureP2PChat = () => {
|
||||
}]);
|
||||
let answer;
|
||||
try {
|
||||
answer = JSON.parse(answerInput.trim());
|
||||
if (typeof window.decodeAnyPayload === "function") {
|
||||
const anyAnswer = window.decodeAnyPayload(answerInput.trim());
|
||||
answer = typeof anyAnswer === "string" ? JSON.parse(anyAnswer) : anyAnswer;
|
||||
} else {
|
||||
const rawText = typeof window.decompressIfNeeded === "function" ? window.decompressIfNeeded(answerInput.trim()) : answerInput.trim();
|
||||
answer = JSON.parse(rawText);
|
||||
}
|
||||
} catch (parseError) {
|
||||
throw new Error(`Invalid response format: ${parseError.message}`);
|
||||
}
|
||||
|
||||
Vendored
+3
-3
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../src/app.jsx"],
|
||||
"sourcesContent": ["\n // Enhanced Copy Button with better UX\n const EnhancedCopyButton = ({ text, className = \"\", children }) => {\n const [copied, setCopied] = React.useState(false);\n \n const handleCopy = async () => {\n try {\n await navigator.clipboard.writeText(text);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n } catch (error) {\n console.error('Copy failed:', error);\n // Fallback for older browsers\n const textArea = document.createElement('textarea');\n textArea.value = text;\n document.body.appendChild(textArea);\n textArea.select();\n document.execCommand('copy');\n document.body.removeChild(textArea);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n }\n };\n \n return React.createElement('button', {\n onClick: handleCopy,\n className: `${className} transition-all duration-200`\n }, [\n React.createElement('i', {\n key: 'icon',\n className: `${copied ? 'fas fa-check accent-green' : 'fas fa-copy text-secondary'} mr-2`\n }),\n copied ? 'Copied!' : children\n ]);\n };\n \n // Verification Component\n const VerificationStep = ({ verificationCode, onConfirm, onReject, localConfirmed, remoteConfirmed, bothConfirmed }) => {\n return React.createElement('div', {\n className: \"card-minimal rounded-xl p-6 border-purple-500/20\"\n }, [\n React.createElement('div', {\n key: 'header',\n className: \"flex items-center mb-4\"\n }, [\n React.createElement('div', {\n key: 'icon',\n className: \"w-10 h-10 bg-purple-500/10 border border-purple-500/20 rounded-lg flex items-center justify-center mr-3\"\n }, [\n React.createElement('i', {\n className: 'fas fa-shield-alt accent-purple'\n })\n ]),\n React.createElement('h3', {\n key: 'title',\n className: \"text-lg font-medium text-primary\"\n }, \"Security verification\")\n ]),\n React.createElement('div', {\n key: 'content',\n className: \"space-y-4\"\n }, [\n React.createElement('p', {\n key: 'description',\n className: \"text-secondary text-sm\"\n }, \"Verify the security code with your contact via another communication channel (voice, SMS, etc.):\"),\n React.createElement('div', {\n key: 'code-display',\n className: \"text-center\"\n }, [\n React.createElement('div', {\n key: 'code',\n className: \"verification-code text-2xl py-4\"\n }, verificationCode)\n ]),\n // Verification status indicators\n React.createElement('div', {\n key: 'verification-status',\n className: \"space-y-2\"\n }, [\n React.createElement('div', {\n key: 'local-status',\n className: `flex items-center justify-between p-2 rounded-lg ${localConfirmed ? 'bg-green-500/10 border border-green-500/20' : 'bg-gray-500/10 border border-gray-500/20'}`\n }, [\n React.createElement('span', {\n key: 'local-label',\n className: \"text-sm text-secondary\"\n Line truncated
|
||||
"mappings": ";AAEgB,IAAM,qBAAqB,CAAC,EAAE,MAAM,YAAY,IAAI,SAAS,MAAM;AAC/D,QAAM,CAAC,QAAQ,SAAS,IAAI,MAAM,SAAS,KAAK;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,WAAW,SAAS,CAAC;AAAA,UACxB,MAAM,cAAc,QAAQ;AAAA,YACxB,KAAK;AAAA,YACL,WAAW;AAAA,UACf,GAAG,MAAM,KAAK;AAAA,QAClB,CAAC;AAAA,MACL,CAAC;AAAA,IACL,CAAC;AAAA,EACL,CAAC;AACL;AAGA,IAAM,0BAA0B,CAAC;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,MAAM;AACF,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,QAAQ;AAE/C,QAAM,gBAAgB,MALine truncated
|
||||
"names": ["e", "offerData", "generateQRCode", "renderNext"]
|
||||
"sourcesContent": ["\r\n // Enhanced Copy Button with better UX\r\n const EnhancedCopyButton = ({ text, className = \"\", children }) => {\r\n const [copied, setCopied] = React.useState(false);\r\n \r\n const handleCopy = async () => {\r\n try {\r\n await navigator.clipboard.writeText(text);\r\n setCopied(true);\r\n setTimeout(() => setCopied(false), 2000);\r\n } catch (error) {\r\n console.error('Copy failed:', error);\r\n // Fallback for older browsers\r\n const textArea = document.createElement('textarea');\r\n textArea.value = text;\r\n document.body.appendChild(textArea);\r\n textArea.select();\r\n document.execCommand('copy');\r\n document.body.removeChild(textArea);\r\n setCopied(true);\r\n setTimeout(() => setCopied(false), 2000);\r\n }\r\n };\r\n \r\n return React.createElement('button', {\r\n onClick: handleCopy,\r\n className: `${className} transition-all duration-200`\r\n }, [\r\n React.createElement('i', {\r\n key: 'icon',\r\n className: `${copied ? 'fas fa-check accent-green' : 'fas fa-copy text-secondary'} mr-2`\r\n }),\r\n copied ? 'Copied!' : children\r\n ]);\r\n };\r\n \r\n // Verification Component\r\n const VerificationStep = ({ verificationCode, onConfirm, onReject, localConfirmed, remoteConfirmed, bothConfirmed }) => {\r\n return React.createElement('div', {\r\n className: \"card-minimal rounded-xl p-6 border-purple-500/20\"\r\n }, [\r\n React.createElement('div', {\r\n key: 'header',\r\n className: \"flex items-center mb-4\"\r\n }, [\r\n React.createElement('div', {\r\n key: 'icon',\r\n className: \"w-10 h-10 bg-purple-500/10 border border-purple-500/20 rounded-lg flex items-center justify-center mr-3\"\r\n }, [\r\n React.createElement('i', {\r\n className: 'fas fa-shield-alt accent-purple'\r\n })\r\n ]),\r\n React.createElement('h3', {\r\n key: 'title',\r\n className: \"text-lg font-medium text-primary\"\r\n }, \"Security verification\")\r\n ]),\r\n React.createElement('div', {\r\n key: 'content',\r\n className: \"space-y-4\"\r\n }, [\r\n React.createElement('p', {\r\n key: 'description',\r\n className: \"text-secondary text-sm\"\r\n }, \"Verify the security code with your contact via another communication channel (voice, SMS, etc.):\"),\r\n React.createElement('div', {\r\n key: 'code-display',\r\n className: \"text-center\"\r\n }, [\r\n React.createElement('div', {\r\n key: 'code',\r\n className: \"verification-code text-2xl py-4\"\r\n }, verificationCode)\r\n ]),\r\n // Verification status indicators\r\n React.createElement('div', {\r\n key: 'verification-status',\r\n className: \"space-y-2\"\r\n }, [\r\n React.createElement('div', {\r\n key: 'local-status',\r\n className: `flex items-center justify-between p-2 rounded-lg ${localConfirmed ? 'bg-green-500/10 border border-green-500/20' : 'bg-gray-500/10 border border-gray-500/20'}`\r\n }, [\r\n React.createElement('span', {\r\n Line truncated
|
||||
"mappings": ";AAEgB,IAAM,qBAAqB,CAAC,EAAE,MAAM,YAAY,IAAI,SAAS,MAAM;AAC/D,QAAM,CAAC,QAAQ,SAAS,IAAI,MAAM,SAAS,KAAK;AAEhD,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SAAS,CAAC;AAAA,UACxB,MAAM,cAAc,QAAQ;AAAA,YACxB,KAAK;AAAA,YACL,WAAW;AAAA,UACf,GAAG,MAAM,KAAK;AAAA,QAClB,CAAC;AAAA,MACL,CAAC;AAAA,IACL,CAAC;AAAA,EACL,CAAC;AACL;AAGA,IAAM,0BAA0B,CAAC;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,MAAM;AACF,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,QAAQ;AAE/C,QAAM,gBAAgB,MALine truncated
|
||||
"names": ["e", "offerData"]
|
||||
}
|
||||
Vendored
+133
-8
@@ -860,7 +860,7 @@ var require_reed_solomon_encoder = __commonJS({
|
||||
this.degree = degree;
|
||||
this.genPoly = Polynomial.generateECPolynomial(this.degree);
|
||||
};
|
||||
ReedSolomonEncoder.prototype.encode = function encode2(data) {
|
||||
ReedSolomonEncoder.prototype.encode = function encode3(data) {
|
||||
if (!this.genPoly) {
|
||||
throw new Error("Encoder not initialized");
|
||||
}
|
||||
@@ -27551,7 +27551,7 @@ var require_cbor = __commonJS({
|
||||
(function(global2, undefined2) {
|
||||
"use strict";
|
||||
var POW_2_24 = Math.pow(2, -24), POW_2_32 = Math.pow(2, 32), POW_2_53 = Math.pow(2, 53);
|
||||
function encode2(value) {
|
||||
function encode3(value) {
|
||||
var data = new ArrayBuffer(256);
|
||||
var dataView = new DataView(data);
|
||||
var lastLength;
|
||||
@@ -27694,7 +27694,7 @@ var require_cbor = __commonJS({
|
||||
retView.setUint8(i, dataView.getUint8(i));
|
||||
return ret;
|
||||
}
|
||||
function decode2(data, tagger, simpleValue) {
|
||||
function decode3(data, tagger, simpleValue) {
|
||||
var dataView = new DataView(data);
|
||||
var offset = 0;
|
||||
if (typeof tagger !== "function")
|
||||
@@ -27890,7 +27890,7 @@ var require_cbor = __commonJS({
|
||||
throw "Remaining bytes";
|
||||
return ret;
|
||||
}
|
||||
var obj = { encode: encode2, decode: decode2 };
|
||||
var obj = { encode: encode3, decode: decode3 };
|
||||
if (typeof define === "function" && define.amd)
|
||||
define("cbor/cbor", obj);
|
||||
else if (typeof module !== "undefined" && module.exports)
|
||||
@@ -31900,9 +31900,6 @@ var Html5QrcodeScanner = (function() {
|
||||
return Html5QrcodeScanner2;
|
||||
})();
|
||||
|
||||
// src/crypto/cose-qr.js
|
||||
var cbor = __toESM(require_cbor());
|
||||
|
||||
// node_modules/pako/dist/pako.esm.mjs
|
||||
var Z_FIXED$1 = 4;
|
||||
var Z_BINARY = 0;
|
||||
@@ -36076,9 +36073,15 @@ var inflate_1$1 = {
|
||||
var { Deflate, deflate, deflateRaw, gzip } = deflate_1$1;
|
||||
var { Inflate, inflate, inflateRaw, ungzip } = inflate_1$1;
|
||||
var deflate_1 = deflate;
|
||||
var gzip_1 = gzip;
|
||||
var inflate_1 = inflate;
|
||||
var ungzip_1 = ungzip;
|
||||
|
||||
// src/scripts/qr-local.js
|
||||
var cbor2 = __toESM(require_cbor());
|
||||
|
||||
// src/crypto/cose-qr.js
|
||||
var cbor = __toESM(require_cbor());
|
||||
var base64 = __toESM(require_base64_js());
|
||||
function toBase64Url(uint8) {
|
||||
let b64 = base64.fromByteArray(uint8);
|
||||
@@ -36421,12 +36424,83 @@ window.packSecurePayload = packSecurePayload;
|
||||
window.receiveAndProcess = receiveAndProcess;
|
||||
|
||||
// src/scripts/qr-local.js
|
||||
var COMPRESSION_PREFIX = "SB1:gz:";
|
||||
var BINARY_PREFIX = "SB1:bin:";
|
||||
function uint8ToBase64(bytes) {
|
||||
let binary = "";
|
||||
const chunkSize = 32768;
|
||||
for (let i = 0; i < bytes.length; i += chunkSize) {
|
||||
const chunk = bytes.subarray(i, i + chunkSize);
|
||||
binary += String.fromCharCode.apply(null, chunk);
|
||||
}
|
||||
return btoa(binary);
|
||||
}
|
||||
function base64ToUint8(b64) {
|
||||
const binary = atob(b64);
|
||||
const len = binary.length;
|
||||
const bytes = new Uint8Array(len);
|
||||
for (let i = 0; i < len; i++) bytes[i] = binary.charCodeAt(i);
|
||||
return bytes;
|
||||
}
|
||||
function compressStringToBase64Gzip(text) {
|
||||
const utf8 = new TextEncoder().encode(text);
|
||||
const gz = gzip_1(utf8);
|
||||
return uint8ToBase64(gz);
|
||||
}
|
||||
function decompressBase64GzipToString(b64) {
|
||||
const gz = base64ToUint8(b64);
|
||||
const out = ungzip_1(gz);
|
||||
return new TextDecoder().decode(out);
|
||||
}
|
||||
async function generateQRCode(text, opts = {}) {
|
||||
const size = opts.size || 512;
|
||||
const margin = opts.margin ?? 2;
|
||||
const errorCorrectionLevel = opts.errorCorrectionLevel || "M";
|
||||
return await QRCode.toDataURL(text, { width: size, margin, errorCorrectionLevel });
|
||||
}
|
||||
async function generateCompressedQRCode(text, opts = {}) {
|
||||
try {
|
||||
const compressedB64 = compressStringToBase64Gzip(text);
|
||||
const payload = COMPRESSION_PREFIX + compressedB64;
|
||||
return await generateQRCode(payload, opts);
|
||||
} catch (e) {
|
||||
console.warn("generateCompressedQRCode failed, falling back to plain:", e?.message || e);
|
||||
return await generateQRCode(text, opts);
|
||||
}
|
||||
}
|
||||
function base64ToBase64Url(b64) {
|
||||
return b64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
||||
}
|
||||
function base64UrlToBase64(b64url) {
|
||||
let b64 = b64url.replace(/-/g, "+").replace(/_/g, "/");
|
||||
const pad = b64.length % 4;
|
||||
if (pad) b64 += "=".repeat(4 - pad);
|
||||
return b64;
|
||||
}
|
||||
function encodeObjectToBinaryBase64Url(obj) {
|
||||
const cborBytes = cbor2.encode(obj);
|
||||
const compressed = deflate_1(new Uint8Array(cborBytes));
|
||||
const b64 = uint8ToBase64(compressed);
|
||||
return base64ToBase64Url(b64);
|
||||
}
|
||||
function decodeBinaryBase64UrlToObject(b64url) {
|
||||
const b64 = base64UrlToBase64(b64url);
|
||||
const compressed = base64ToUint8(b64);
|
||||
const decompressed = inflate_1(compressed);
|
||||
const ab = decompressed.buffer.slice(decompressed.byteOffset, decompressed.byteOffset + decompressed.byteLength);
|
||||
return cbor2.decode(ab);
|
||||
}
|
||||
async function generateBinaryQRCodeFromObject(obj, opts = {}) {
|
||||
try {
|
||||
const b64url = encodeObjectToBinaryBase64Url(obj);
|
||||
const payload = BINARY_PREFIX + b64url;
|
||||
return await generateQRCode(payload, opts);
|
||||
} catch (e) {
|
||||
console.warn("generateBinaryQRCodeFromObject failed, falling back to JSON compressed:", e?.message || e);
|
||||
const text = JSON.stringify(obj);
|
||||
return await generateCompressedQRCode(text, opts);
|
||||
}
|
||||
}
|
||||
async function generateCOSEQRCode(data, senderKey = null, recipientKey = null) {
|
||||
try {
|
||||
console.log("\u{1F510} Generating COSE-based QR code...");
|
||||
@@ -36443,11 +36517,62 @@ async function generateCOSEQRCode(data, senderKey = null, recipientKey = null) {
|
||||
}
|
||||
}
|
||||
window.generateQRCode = generateQRCode;
|
||||
window.generateCompressedQRCode = generateCompressedQRCode;
|
||||
window.generateBinaryQRCodeFromObject = generateBinaryQRCodeFromObject;
|
||||
window.generateCOSEQRCode = generateCOSEQRCode;
|
||||
window.Html5Qrcode = Html5Qrcode;
|
||||
window.packSecurePayload = packSecurePayload;
|
||||
window.receiveAndProcess = receiveAndProcess;
|
||||
console.log("QR libraries loaded: generateQRCode, generateCOSEQRCode, Html5Qrcode, COSE functions");
|
||||
window.decompressIfNeeded = function(scannedText) {
|
||||
try {
|
||||
if (typeof scannedText === "string" && scannedText.startsWith(COMPRESSION_PREFIX)) {
|
||||
const b64 = scannedText.slice(COMPRESSION_PREFIX.length);
|
||||
return decompressBase64GzipToString(b64);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("decompressIfNeeded failed:", e?.message || e);
|
||||
}
|
||||
return scannedText;
|
||||
};
|
||||
window.compressToPrefixedGzip = function(text) {
|
||||
try {
|
||||
const payload = String(text || "");
|
||||
const compressedB64 = compressStringToBase64Gzip(payload);
|
||||
return COMPRESSION_PREFIX + compressedB64;
|
||||
} catch (e) {
|
||||
console.warn("compressToPrefixedGzip failed:", e?.message || e);
|
||||
return String(text || "");
|
||||
}
|
||||
};
|
||||
window.encodeBinaryToPrefixed = function(objOrJson) {
|
||||
try {
|
||||
const obj = typeof objOrJson === "string" ? JSON.parse(objOrJson) : objOrJson;
|
||||
const b64url = encodeObjectToBinaryBase64Url(obj);
|
||||
return BINARY_PREFIX + b64url;
|
||||
} catch (e) {
|
||||
console.warn("encodeBinaryToPrefixed failed:", e?.message || e);
|
||||
return typeof objOrJson === "string" ? objOrJson : JSON.stringify(objOrJson);
|
||||
}
|
||||
};
|
||||
window.decodeAnyPayload = function(scannedText) {
|
||||
try {
|
||||
if (typeof scannedText === "string") {
|
||||
if (scannedText.startsWith(BINARY_PREFIX)) {
|
||||
const b64url = scannedText.slice(BINARY_PREFIX.length);
|
||||
return decodeBinaryBase64UrlToObject(b64url);
|
||||
}
|
||||
if (scannedText.startsWith(COMPRESSION_PREFIX)) {
|
||||
const s = window.decompressIfNeeded(scannedText);
|
||||
return s;
|
||||
}
|
||||
return scannedText;
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("decodeAnyPayload failed:", e?.message || e);
|
||||
}
|
||||
return scannedText;
|
||||
};
|
||||
console.log("QR libraries loaded: generateQRCode, generateCompressedQRCode, generateBinaryQRCodeFromObject, Html5Qrcode, COSE functions");
|
||||
/*! Bundled license information:
|
||||
|
||||
pako/dist/pako.esm.mjs:
|
||||
|
||||
Vendored
+4
-4
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../node_modules/qrcode/lib/can-promise.js", "../node_modules/qrcode/lib/core/utils.js", "../node_modules/qrcode/lib/core/error-correction-level.js", "../node_modules/qrcode/lib/core/bit-buffer.js", "../node_modules/qrcode/lib/core/bit-matrix.js", "../node_modules/qrcode/lib/core/alignment-pattern.js", "../node_modules/qrcode/lib/core/finder-pattern.js", "../node_modules/qrcode/lib/core/mask-pattern.js", "../node_modules/qrcode/lib/core/error-correction-code.js", "../node_modules/qrcode/lib/core/galois-field.js", "../node_modules/qrcode/lib/core/polynomial.js", "../node_modules/qrcode/lib/core/reed-solomon-encoder.js", "../node_modules/qrcode/lib/core/version-check.js", "../node_modules/qrcode/lib/core/regex.js", "../node_modules/qrcode/lib/core/mode.js", "../node_modules/qrcode/lib/core/version.js", "../node_modules/qrcode/lib/core/format-info.js", "../node_modules/qrcode/lib/core/numeric-data.js", "../node_modules/qrcode/lib/core/alphanumeric-data.js", "../node_modules/qrcode/lib/core/byte-data.js", "../node_modules/qrcode/lib/core/kanji-data.js", "../node_modules/dijkstrajs/dijkstra.js", "../node_modules/qrcode/lib/core/segments.js", "../node_modules/qrcode/lib/core/qrcode.js", "../node_modules/qrcode/lib/renderer/utils.js", "../node_modules/qrcode/lib/renderer/canvas.js", "../node_modules/qrcode/lib/renderer/svg-tag.js", "../node_modules/qrcode/lib/browser.js", "../node_modules/html5-qrcode/third_party/zxing-js.umd.js", "../node_modules/cbor-js/cbor.js", "../node_modules/base64-js/index.js", "../src/scripts/qr-local.js", "../node_modules/src/core.ts", "../node_modules/src/strings.ts", "../node_modules/src/utils.ts", "../node_modules/src/zxing-html5-qrcode-decoder.ts", "../node_modules/src/native-bar-code-detector.ts", "../node_modules/src/code-decoder.ts", "../node_modules/src/camera/core-impl.ts", "../node_modules/src/camera/factories.ts", "../node_modules/src/camera/retriever.ts", "../node_modules/src/state-manager.ts", "../node_modules/src/html5-qrcode.ts", "../node_modules/src/image-assets.ts", "../node_modules/src/storage.ts", "../node_modules/src/ui.ts", "../node_modules/src/camera/permissions.ts", "../node_modules/src/ui/scanner/scan-type-selector.ts", "../node_modules/src/ui/scanner/base.ts", "../node_modules/src/ui/scanner/torch-button.ts", "../node_modules/src/ui/scanner/file-selection-ui.ts", "../node_modules/src/ui/scanner/camera-selection-ui.ts", "../node_modules/src/ui/scanner/camera-zoom-ui.ts", "../node_modules/src/html5-qrcode-scanner.ts", "../src/crypto/cose-qr.js", "../node_modules/pako/dist/pako.esm.mjs"],
|
||||
"sourcesContent": ["// can-promise has a crash in some versions of react native that dont have\n// standard global objects\n// https://github.com/soldair/node-qrcode/issues/157\n\nmodule.exports = function () {\n return typeof Promise === 'function' && Promise.prototype && Promise.prototype.then\n}\n", "let toSJISFunction\nconst CODEWORDS_COUNT = [\n 0, // Not used\n 26, 44, 70, 100, 134, 172, 196, 242, 292, 346,\n 404, 466, 532, 581, 655, 733, 815, 901, 991, 1085,\n 1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051, 2185,\n 2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706\n]\n\n/**\n * Returns the QR Code size for the specified version\n *\n * @param {Number} version QR Code version\n * @return {Number} size of QR code\n */\nexports.getSymbolSize = function getSymbolSize (version) {\n if (!version) throw new Error('\"version\" cannot be null or undefined')\n if (version < 1 || version > 40) throw new Error('\"version\" should be in range from 1 to 40')\n return version * 4 + 17\n}\n\n/**\n * Returns the total number of codewords used to store data and EC information.\n *\n * @param {Number} version QR Code version\n * @return {Number} Data length in bits\n */\nexports.getSymbolTotalCodewords = function getSymbolTotalCodewords (version) {\n return CODEWORDS_COUNT[version]\n}\n\n/**\n * Encode data with Bose-Chaudhuri-Hocquenghem\n *\n * @param {Number} data Value to encode\n * @return {Number} Encoded value\n */\nexports.getBCHDigit = function (data) {\n let digit = 0\n\n while (data !== 0) {\n digit++\n data >>>= 1\n }\n\n return digit\n}\n\nexports.setToSJISFunction = function setToSJISFunction (f) {\n if (typeof f !== 'function') {\n throw new Error('\"toSJISFunc\" is not a valid function.')\n }\n\n toSJISFunction = f\n}\n\nexports.isKanjiModeEnabled = function () {\n return typeof toSJISFunction !== 'undefined'\n}\n\nexports.toSJIS = function toSJIS (kanji) {\n return toSJISFunction(kanji)\n}\n", "exports.L = { bit: 1 }\nexports.M = { bit: 0 }\nexports.Q = { bit: 3 }\nexports.H = { bit: 2 }\n\nfunction fromString (string) {\n if (typeof string !== 'string') {\n throw new Error('Param is not a string')\n }\n\n const lcStr = string.toLowerCase()\n\n switch (lcStr) {\n case 'l':\n case 'low':\n return exports.L\n\n case 'm':\n case 'medium':\n return exports.M\n\n case 'q':\n case 'quartile':\n return exports.Q\n\n case 'h':\n case 'high':\n return exports.H\n\n default:\n throw new Error('Unknown EC Level: ' + string)\n }\n}\n\nexports.isValid = function isValid (level) {\n return level && typeof level.bit !== 'undefined' &&\n level.bit >= 0 && level.bit < 4\n}\n\nexports.from = function from (value, defaultValue) {\n if (exports.isValid(value)) {\n return value\n }\n\n try {\n return fromString(value)\n } catch (e) {\n return defaultValue\n }\n}\n", "function BitBuffer () {\n this.buffer = []\n this.length = 0\n}\n\nBitBuffer.prototype = {\n\n get: function (index) {\n const bufIndex = Math.floor(index / 8)\n return ((this.buffer[bufIndex] >>> (7 - index % 8)) & 1) === 1\n },\n\n put: function (num, length) {\n for (let i = 0; i < length; i++) {\n this.putBit(((num >>> (length - i - 1)) & 1) === 1)\n }\n },\n\n getLengthInBits: function () {\n return this.length\n },\n\n putBit: function (bit) {\n const bufIndex = Math.floor(this.length / 8)\n if (this.buffer.length <= bufIndex) {\n this.buffer.push(0)\n }\n\n if (bit) {\n this.buffer[bufIndex] |= (0x80 >>> (this.length % 8))\n }\n\n this.length++\n }\n}\n\nmodule.exports = BitBuffer\n", "/**\n * Helper class to handle QR Code symbol modules\n *\n * @param {Number} size Symbol size\n */\nfunction BitMatrix (size) {\n if (!size || size < 1) {\n throw new Error('BitMatrix size must be defined and greater than 0')\n }\n\n this.size = size\n this.data = new Uint8Array(size * size)\n this.reservedBit = new Uint8Array(size * size)\n}\n\n/**\n * Set bit value at specified location\n * If reserved flag is set, this bit will be ignored during masking process\n *\n * @param {Number} row\n * @param {Number} col\n * @param {Boolean} value\n * @param {Boolean} reserved\n */\nBitMatrix.prototype.set = function (row, col, value, reserved) {\n const index = row * this.size + col\n this.data[index] = value\n if (reserved) this.reservedBit[index] = true\n}\n\n/**\n * Returns bit value at specified location\n *\n * @param {Number} row\n * @param {Number} col\n * @return {Boolean}\n */\nBitMatrix.prototype.get = function (row, col) {\n return this.data[row * this.size + col]\n}\n\n/**\n * Applies xor operator at specified location\n * (used during masking process)\n *\n * @param {Number} row\n * @param {Number} col\n * @param {Boolean} value\n */\nBitMatrix.prototype.xor = function (row, col, value) {\n this.data[row * this.size + col] ^= value\n}\n\n/*Line truncated
|
||||
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAIA,WAAO,UAAU,WAAY;AAC3B,aAAO,OAAO,YAAY,cAAc,QAAQ,aAAa,QAAQ,UAAU;AAAA,IACjF;AAAA;AAAA;;;ACNA;AAAA;AAAA,QAAI;AACJ,QAAM,kBAAkB;AAAA,MACtB;AAAA;AAAA,MACA;AAAA,MAAI;AAAA,MAAI;AAAA,MAAI;AAAA,MAAK;AAAA,MAAK;AAAA,MAAK;AAAA,MAAK;AAAA,MAAK;AAAA,MAAK;AAAA,MAC1C;AAAA,MAAK;AAAA,MAAK;AAAA,MAAK;AAAA,MAAK;AAAA,MAAK;AAAA,MAAK;AAAA,MAAK;AAAA,MAAK;AAAA,MAAK;AAAA,MAC7C;AAAA,MAAM;AAAA,MAAM;AAAA,MAAM;AAAA,MAAM;AAAA,MAAM;AAAA,MAAM;AAAA,MAAM;AAAA,MAAM;AAAA,MAAM;AAAA,MACtD;AAAA,MAAM;AAAA,MAAM;AAAA,MAAM;AAAA,MAAM;AAAA,MAAM;AAAA,MAAM;AAAA,MAAM;AAAA,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SAAS,KAAM,OAAO;AACnC,aAAO,QAAQ,QAAQ,KAAK,IAAI,SAAS,OAAO,EAAE,IAAI;AAAA,IACxD;AASA,YAAQ,eAAe,SAAS,aAAc,MAAM;AAClD,YAAM,OAAO,KAAK;AAClB,UAAI,SAAS;AACb,UAAI,eAAe;AACnB,UAAI,eAAe;AACnB,UAAI,UAAU;AACd,UAAI,UAAU;AAEd,eAAS,MAAM,GAAG,MAAM,MAAM,OAAO;AACnC,uBAAe,eAAe;AAC9B,kBAAU,UALine truncated
|
||||
"names": ["module", "encode", "toString", "require_utils", "QRCode", "global", "exports", "isNullOrUndefined", "__extends", "CustomError", "BinaryBitmap", "DecodeHintType", "CharacterSetValueIdentifiers", "localLuminances", "HybridBinarizer", "HTMLCanvasElementLuminanceSource", "__awaiter", "err", "BarcodeFormat", "ResultMetadataType", "Table", "cx", "cy", "resultPoint", "numeric", "value", "Mode", "ErrorCorrectionLevelValues", "DataMaskValues", "ModeValues", "column", "MultiFormatReader", "EncodeHintType", "QRCode", "SHIFT_TABLE", "CHAR_MAP", "add", "global", "undefined", "encode", "i", "value", "dataView", "decode", "toByteArray", "fromByteArray", "len", "i", "len2", "Html5QrcodeSupportedFormats", "DecodedTextType", "Html5QrcodeScanType", "Html5QrcodeConstants", "QrcodeResultFormat", "Html5QrcodeResultFactory", "Html5QrcodeErrorTypes", "Html5QrcodeErrorFactory", "BaseLoggger", "Html5QrcodeStrings", "Html5QrcodeScannerStrings", "LibraryInfoStrings", "VideoConstraintsUtil", "ZXingHtml5QrcodeDecoder", "BarcodeDetectorDelegate", "Html5QrcodeShim", "AbstractCameraCapability", "AbstractRangeCameraCapability", "ZoomFeatureImpl", "TorchFeatureImpl", "CameraCapabilitiesImpl", "RenderedCameraImpl", "CameraImpl", "CameraFactory", "CameraRetriever", "_i", "Html5QrcodeScannerState", "StateManagerImpl", "StateManagerProxy", "StateManagerFactory", "__extends", "Constants", "InternalHtml5QrcodeConfig", "Html5Qrcode", "PersistedDataFactory", "PersistedDataManager", "LibraryInfoDiv", "LibraryInfoIcon", "LibraryInfoContainer", "CameraPermissions", "ScanTypeSelector", "PublicUiElementIdAndClasses", "BaseUiElementFactory", "TorchController", "TorchButton", "__awaiter", "FileSelectionUi", "CameraSelectionUi", "CameraZoomUi", "Html5QrcodeScannerStatus", "Html5QrcodeScanner", "cameraId", "_", "rank", "compressed", "payload"]
|
||||
"sources": ["../node_modules/qrcode/lib/can-promise.js", "../node_modules/qrcode/lib/core/utils.js", "../node_modules/qrcode/lib/core/error-correction-level.js", "../node_modules/qrcode/lib/core/bit-buffer.js", "../node_modules/qrcode/lib/core/bit-matrix.js", "../node_modules/qrcode/lib/core/alignment-pattern.js", "../node_modules/qrcode/lib/core/finder-pattern.js", "../node_modules/qrcode/lib/core/mask-pattern.js", "../node_modules/qrcode/lib/core/error-correction-code.js", "../node_modules/qrcode/lib/core/galois-field.js", "../node_modules/qrcode/lib/core/polynomial.js", "../node_modules/qrcode/lib/core/reed-solomon-encoder.js", "../node_modules/qrcode/lib/core/version-check.js", "../node_modules/qrcode/lib/core/regex.js", "../node_modules/qrcode/lib/core/mode.js", "../node_modules/qrcode/lib/core/version.js", "../node_modules/qrcode/lib/core/format-info.js", "../node_modules/qrcode/lib/core/numeric-data.js", "../node_modules/qrcode/lib/core/alphanumeric-data.js", "../node_modules/qrcode/lib/core/byte-data.js", "../node_modules/qrcode/lib/core/kanji-data.js", "../node_modules/dijkstrajs/dijkstra.js", "../node_modules/qrcode/lib/core/segments.js", "../node_modules/qrcode/lib/core/qrcode.js", "../node_modules/qrcode/lib/renderer/utils.js", "../node_modules/qrcode/lib/renderer/canvas.js", "../node_modules/qrcode/lib/renderer/svg-tag.js", "../node_modules/qrcode/lib/browser.js", "../node_modules/html5-qrcode/third_party/zxing-js.umd.js", "../node_modules/cbor-js/cbor.js", "../node_modules/base64-js/index.js", "../src/scripts/qr-local.js", "../node_modules/src/core.ts", "../node_modules/src/strings.ts", "../node_modules/src/utils.ts", "../node_modules/src/zxing-html5-qrcode-decoder.ts", "../node_modules/src/native-bar-code-detector.ts", "../node_modules/src/code-decoder.ts", "../node_modules/src/camera/core-impl.ts", "../node_modules/src/camera/factories.ts", "../node_modules/src/camera/retriever.ts", "../node_modules/src/state-manager.ts", "../node_modules/src/html5-qrcode.ts", "../node_modules/src/image-assets.ts", "../node_modules/src/storage.ts", "../node_modules/src/ui.ts", "../node_modules/src/camera/permissions.ts", "../node_modules/src/ui/scanner/scan-type-selector.ts", "../node_modules/src/ui/scanner/base.ts", "../node_modules/src/ui/scanner/torch-button.ts", "../node_modules/src/ui/scanner/file-selection-ui.ts", "../node_modules/src/ui/scanner/camera-selection-ui.ts", "../node_modules/src/ui/scanner/camera-zoom-ui.ts", "../node_modules/src/html5-qrcode-scanner.ts", "../node_modules/pako/dist/pako.esm.mjs", "../src/crypto/cose-qr.js"],
|
||||
"sourcesContent": ["// can-promise has a crash in some versions of react native that dont have\n// standard global objects\n// https://github.com/soldair/node-qrcode/issues/157\n\nmodule.exports = function () {\n return typeof Promise === 'function' && Promise.prototype && Promise.prototype.then\n}\n", "let toSJISFunction\nconst CODEWORDS_COUNT = [\n 0, // Not used\n 26, 44, 70, 100, 134, 172, 196, 242, 292, 346,\n 404, 466, 532, 581, 655, 733, 815, 901, 991, 1085,\n 1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051, 2185,\n 2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706\n]\n\n/**\n * Returns the QR Code size for the specified version\n *\n * @param {Number} version QR Code version\n * @return {Number} size of QR code\n */\nexports.getSymbolSize = function getSymbolSize (version) {\n if (!version) throw new Error('\"version\" cannot be null or undefined')\n if (version < 1 || version > 40) throw new Error('\"version\" should be in range from 1 to 40')\n return version * 4 + 17\n}\n\n/**\n * Returns the total number of codewords used to store data and EC information.\n *\n * @param {Number} version QR Code version\n * @return {Number} Data length in bits\n */\nexports.getSymbolTotalCodewords = function getSymbolTotalCodewords (version) {\n return CODEWORDS_COUNT[version]\n}\n\n/**\n * Encode data with Bose-Chaudhuri-Hocquenghem\n *\n * @param {Number} data Value to encode\n * @return {Number} Encoded value\n */\nexports.getBCHDigit = function (data) {\n let digit = 0\n\n while (data !== 0) {\n digit++\n data >>>= 1\n }\n\n return digit\n}\n\nexports.setToSJISFunction = function setToSJISFunction (f) {\n if (typeof f !== 'function') {\n throw new Error('\"toSJISFunc\" is not a valid function.')\n }\n\n toSJISFunction = f\n}\n\nexports.isKanjiModeEnabled = function () {\n return typeof toSJISFunction !== 'undefined'\n}\n\nexports.toSJIS = function toSJIS (kanji) {\n return toSJISFunction(kanji)\n}\n", "exports.L = { bit: 1 }\nexports.M = { bit: 0 }\nexports.Q = { bit: 3 }\nexports.H = { bit: 2 }\n\nfunction fromString (string) {\n if (typeof string !== 'string') {\n throw new Error('Param is not a string')\n }\n\n const lcStr = string.toLowerCase()\n\n switch (lcStr) {\n case 'l':\n case 'low':\n return exports.L\n\n case 'm':\n case 'medium':\n return exports.M\n\n case 'q':\n case 'quartile':\n return exports.Q\n\n case 'h':\n case 'high':\n return exports.H\n\n default:\n throw new Error('Unknown EC Level: ' + string)\n }\n}\n\nexports.isValid = function isValid (level) {\n return level && typeof level.bit !== 'undefined' &&\n level.bit >= 0 && level.bit < 4\n}\n\nexports.from = function from (value, defaultValue) {\n if (exports.isValid(value)) {\n return value\n }\n\n try {\n return fromString(value)\n } catch (e) {\n return defaultValue\n }\n}\n", "function BitBuffer () {\n this.buffer = []\n this.length = 0\n}\n\nBitBuffer.prototype = {\n\n get: function (index) {\n const bufIndex = Math.floor(index / 8)\n return ((this.buffer[bufIndex] >>> (7 - index % 8)) & 1) === 1\n },\n\n put: function (num, length) {\n for (let i = 0; i < length; i++) {\n this.putBit(((num >>> (length - i - 1)) & 1) === 1)\n }\n },\n\n getLengthInBits: function () {\n return this.length\n },\n\n putBit: function (bit) {\n const bufIndex = Math.floor(this.length / 8)\n if (this.buffer.length <= bufIndex) {\n this.buffer.push(0)\n }\n\n if (bit) {\n this.buffer[bufIndex] |= (0x80 >>> (this.length % 8))\n }\n\n this.length++\n }\n}\n\nmodule.exports = BitBuffer\n", "/**\n * Helper class to handle QR Code symbol modules\n *\n * @param {Number} size Symbol size\n */\nfunction BitMatrix (size) {\n if (!size || size < 1) {\n throw new Error('BitMatrix size must be defined and greater than 0')\n }\n\n this.size = size\n this.data = new Uint8Array(size * size)\n this.reservedBit = new Uint8Array(size * size)\n}\n\n/**\n * Set bit value at specified location\n * If reserved flag is set, this bit will be ignored during masking process\n *\n * @param {Number} row\n * @param {Number} col\n * @param {Boolean} value\n * @param {Boolean} reserved\n */\nBitMatrix.prototype.set = function (row, col, value, reserved) {\n const index = row * this.size + col\n this.data[index] = value\n if (reserved) this.reservedBit[index] = true\n}\n\n/**\n * Returns bit value at specified location\n *\n * @param {Number} row\n * @param {Number} col\n * @return {Boolean}\n */\nBitMatrix.prototype.get = function (row, col) {\n return this.data[row * this.size + col]\n}\n\n/**\n * Applies xor operator at specified location\n * (used during masking process)\n *\n * @param {Number} row\n * @param {Number} col\n * @param {Boolean} value\n */\nBitMatrix.prototype.xor = function (row, col, value) {\n this.data[row * this.size + col] ^= value\n}\n\n/*Line truncated
|
||||
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAIA,WAAO,UAAU,WAAY;AAC3B,aAAO,OAAO,YAAY,cAAc,QAAQ,aAAa,QAAQ,UAAU;AAAA,IACjF;AAAA;AAAA;;;ACNA;AAAA;AAAA,QAAI;AACJ,QAAM,kBAAkB;AAAA,MACtB;AAAA;AAAA,MACA;AAAA,MAAI;AAAA,MAAI;AAAA,MAAI;AAAA,MAAK;AAAA,MAAK;AAAA,MAAK;AAAA,MAAK;AAAA,MAAK;AAAA,MAAK;AAAA,MAC1C;AAAA,MAAK;AAAA,MAAK;AAAA,MAAK;AAAA,MAAK;AAAA,MAAK;AAAA,MAAK;AAAA,MAAK;AAAA,MAAK;AAAA,MAAK;AAAA,MAC7C;AAAA,MAAM;AAAA,M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ACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IACN;AAQA,YAAQ,UAAU,SAAS,QAAS,MAAM;AACxC,aAAO,QAAQ,QAAQ,SAAS,MAAM,CAAC,MAAM,IAAI,KAAK,QAAQ,KAAK,QAAQ;AAAA,IAC7E;AASA,YAAQ,OAAO,SAAS,KAAM,OAAO;AACnC,aAAO,QAAQ,QAAQ,KAAK,IAAI,SAAS,OAAO,EAAE,IAAI;AAAA,IACxD;AASA,YAAQ,eAAe,SAAS,aAAc,MAAM;AAClD,YAAM,OAAO,KAAK;AAClB,UAAI,SAAS;AACb,UAAI,eAAe;AACnB,UAAI,eAAe;AACnB,UAAI,UAAU;AACd,UAAI,UAAU;AAEd,eAAS,MAAM,GAAG,MAAM,MAAM,OAAO;AACnC,uBAAe,eAAe;AAC9B,kBAAU,UALine truncated
|
||||
"names": ["module", "encode", "toString", "require_utils", "QRCode", "global", "exports", "isNullOrUndefined", "__extends", "CustomError", "BinaryBitmap", "DecodeHintType", "CharacterSetValueIdentifiers", "localLuminances", "HybridBinarizer", "HTMLCanvasElementLuminanceSource", "__awaiter", "err", "BarcodeFormat", "ResultMetadataType", "Table", "cx", "cy", "resultPoint", "numeric", "value", "Mode", "ErrorCorrectionLevelValues", "DataMaskValues", "ModeValues", "column", "MultiFormatReader", "EncodeHintType", "QRCode", "SHIFT_TABLE", "CHAR_MAP", "add", "global", "undefined", "encode", "i", "value", "dataView", "decode", "toByteArray", "fromByteArray", "len", "i", "len2", "Html5QrcodeSupportedFormats", "DecodedTextType", "Html5QrcodeScanType", "Html5QrcodeConstants", "QrcodeResultFormat", "Html5QrcodeResultFactory", "Html5QrcodeErrorTypes", "Html5QrcodeErrorFactory", "BaseLoggger", "Html5QrcodeStrings", "Html5QrcodeScannerStrings", "LibraryInfoStrings", "VideoConstraintsUtil", "ZXingHtml5QrcodeDecoder", "BarcodeDetectorDelegate", "Html5QrcodeShim", "AbstractCameraCapability", "AbstractRangeCameraCapability", "ZoomFeatureImpl", "TorchFeatureImpl", "CameraCapabilitiesImpl", "RenderedCameraImpl", "CameraImpl", "CameraFactory", "CameraRetriever", "_i", "Html5QrcodeScannerState", "StateManagerImpl", "StateManagerProxy", "StateManagerFactory", "__extends", "Constants", "InternalHtml5QrcodeConfig", "Html5Qrcode", "PersistedDataFactory", "PersistedDataManager", "LibraryInfoDiv", "LibraryInfoIcon", "LibraryInfoContainer", "CameraPermissions", "ScanTypeSelector", "PublicUiElementIdAndClasses", "BaseUiElementFactory", "TorchController", "TorchButton", "__awaiter", "FileSelectionUi", "CameraSelectionUi", "CameraZoomUi", "Html5QrcodeScannerStatus", "Html5QrcodeScanner", "cameraId", "_", "rank", "cbor", "compressed", "payload"]
|
||||
}
|
||||
+264
-113
@@ -517,7 +517,7 @@
|
||||
]),
|
||||
|
||||
// Step 1
|
||||
React.createElement('div', {
|
||||
!showAnswerStep && React.createElement('div', {
|
||||
key: 'step1',
|
||||
className: "card-minimal rounded-xl p-6"
|
||||
}, [
|
||||
@@ -538,16 +538,16 @@
|
||||
key: 'description',
|
||||
className: "text-secondary text-sm mb-4"
|
||||
}, "Creating cryptographically strong keys and codes to protect against attacks"),
|
||||
React.createElement('button', {
|
||||
!showOfferStep && React.createElement('button', {
|
||||
key: 'create-btn',
|
||||
onClick: onCreateOffer,
|
||||
disabled: connectionStatus === 'connecting' || showOfferStep,
|
||||
disabled: connectionStatus === 'connecting',
|
||||
className: `w-full btn-primary text-white py-3 px-4 rounded-lg font-medium transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed`
|
||||
}, [
|
||||
React.createElement('i', {
|
||||
className: 'fas fa-shield-alt mr-2'
|
||||
}),
|
||||
showOfferStep ? 'Keys created ✓' : 'Create secure keys'
|
||||
'Create secure keys'
|
||||
]),
|
||||
|
||||
showOfferStep && React.createElement('div', {
|
||||
@@ -571,46 +571,27 @@
|
||||
key: 'offer-data',
|
||||
className: "space-y-3"
|
||||
}, [
|
||||
React.createElement('textarea', {
|
||||
key: 'textarea',
|
||||
value: typeof offerData === 'object' ? JSON.stringify(offerData, null, 2) : offerData,
|
||||
readOnly: true,
|
||||
rows: 8,
|
||||
className: "w-full p-3 bg-custom-bg border border-gray-500/20 rounded-lg font-mono text-xs text-secondary resize-none custom-scrollbar"
|
||||
}),
|
||||
// Raw JSON hidden intentionally; users copy compressed string or use QR
|
||||
React.createElement('div', {
|
||||
key: 'buttons',
|
||||
className: "flex gap-2"
|
||||
}, [
|
||||
React.createElement(EnhancedCopyButton, {
|
||||
key: 'copy',
|
||||
text: typeof offerData === 'object' ? JSON.stringify(offerData, null, 2) : offerData,
|
||||
className: "flex-1 px-3 py-2 bg-orange-500/10 hover:bg-orange-500/20 text-orange-400 border border-orange-500/20 rounded text-sm font-medium"
|
||||
}, 'Copy invitation code'),
|
||||
React.createElement('button', {
|
||||
key: 'qr-toggle',
|
||||
onClick: async () => {
|
||||
const next = !showQRCode;
|
||||
setShowQRCode(next);
|
||||
if (next) {
|
||||
try {
|
||||
const payload = typeof offerData === 'object' ? JSON.stringify(offerData) : offerData;
|
||||
if (payload && payload.length) {
|
||||
await generateQRCode(payload);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('QR regenerate on toggle failed:', e);
|
||||
}
|
||||
text: (() => {
|
||||
try {
|
||||
const min = typeof offerData === 'object' ? JSON.stringify(offerData) : (offerData || '');
|
||||
if (typeof window.encodeBinaryToPrefixed === 'function') {
|
||||
return window.encodeBinaryToPrefixed(min);
|
||||
}
|
||||
},
|
||||
className: "px-3 py-2 bg-blue-500/10 hover:bg-blue-500/20 text-blue-400 border border-blue-500/20 rounded text-sm font-medium transition-all duration-200"
|
||||
}, [
|
||||
React.createElement('i', {
|
||||
key: 'icon',
|
||||
className: showQRCode ? 'fas fa-eye-slash mr-1' : 'fas fa-qrcode mr-1'
|
||||
}),
|
||||
showQRCode ? 'Hide QR' : 'Show QR'
|
||||
])
|
||||
if (typeof window.compressToPrefixedGzip === 'function') {
|
||||
return window.compressToPrefixedGzip(min);
|
||||
}
|
||||
return min;
|
||||
} catch { return typeof offerData === 'object' ? JSON.stringify(offerData) : (offerData || ''); }
|
||||
})(),
|
||||
className: "flex-1 px-3 py-2 bg-orange-500/10 hover:bg-orange-500/20 text-orange-400 border border-orange-500/20 rounded text-sm font-medium"
|
||||
}, 'Copy invitation code')
|
||||
]),
|
||||
showQRCode && qrCodeUrl && React.createElement('div', {
|
||||
key: 'qr-container',
|
||||
@@ -827,8 +808,7 @@
|
||||
}, 'Joining the secure channel')
|
||||
]),
|
||||
|
||||
// Step 1
|
||||
React.createElement('div', {
|
||||
(showAnswerStep ? null : React.createElement('div', {
|
||||
key: 'step1',
|
||||
className: "card-minimal rounded-xl p-6"
|
||||
}, [
|
||||
@@ -854,13 +834,11 @@
|
||||
value: offerInput,
|
||||
onChange: (e) => {
|
||||
setOfferInput(e.target.value);
|
||||
// Mark answer as created when user manually enters data
|
||||
if (e.target.value.trim().length > 0) {
|
||||
if (typeof markAnswerCreated === 'function') {
|
||||
markAnswerCreated();
|
||||
if (typeof markAnswerCreated === 'function') {
|
||||
markAnswerCreated();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
rows: 8,
|
||||
placeholder: "Paste the encrypted invitation code or scan QR code...",
|
||||
@@ -881,17 +859,17 @@
|
||||
}),
|
||||
'Scan QR Code'
|
||||
]),
|
||||
React.createElement('button', {
|
||||
key: 'process-btn',
|
||||
onClick: onCreateAnswer,
|
||||
disabled: !offerInput.trim() || connectionStatus === 'connecting',
|
||||
className: "flex-1 btn-secondary text-white py-2 px-4 rounded-lg font-medium transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
}, [
|
||||
React.createElement('i', {
|
||||
className: 'fas fa-cogs mr-2'
|
||||
}),
|
||||
'Process invitation'
|
||||
])
|
||||
React.createElement('button', {
|
||||
key: 'process-btn',
|
||||
onClick: onCreateAnswer,
|
||||
disabled: !offerInput.trim() || connectionStatus === 'connecting',
|
||||
className: "flex-1 btn-secondary text-white py-2 px-4 rounded-lg font-medium transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
}, [
|
||||
React.createElement('i', {
|
||||
className: 'fas fa-cogs mr-2'
|
||||
}),
|
||||
'Process invitation'
|
||||
])
|
||||
]),
|
||||
showQRScanner && React.createElement('div', {
|
||||
key: 'qr-scanner',
|
||||
@@ -908,7 +886,6 @@
|
||||
React.createElement('button', {
|
||||
key: 'open-scanner',
|
||||
onClick: () => {
|
||||
|
||||
if (typeof setShowQRScannerModal === 'function') {
|
||||
setShowQRScannerModal(true);
|
||||
} else {
|
||||
@@ -931,7 +908,6 @@
|
||||
const testData = '{"type":"test","message":"Hello QR Scanner!"}';
|
||||
const qrUrl = await window.generateQRCode(testData);
|
||||
console.log('Test QR code generated:', qrUrl);
|
||||
// Open QR code in new tab for testing
|
||||
const newWindow = window.open();
|
||||
newWindow.document.write(`<img src="${qrUrl}" style="width: 300px; height: 300px;">`);
|
||||
}
|
||||
@@ -944,7 +920,7 @@
|
||||
className: "px-3 py-1 bg-gray-600/20 hover:bg-gray-600/30 text-gray-300 border border-gray-500/20 rounded text-xs font-medium transition-all duration-200"
|
||||
}, 'Close Scanner')
|
||||
])
|
||||
]),
|
||||
])),
|
||||
|
||||
// Step 2
|
||||
showAnswerStep && React.createElement('div', {
|
||||
@@ -981,16 +957,21 @@
|
||||
key: 'answer-data',
|
||||
className: "space-y-3 mb-4"
|
||||
}, [
|
||||
React.createElement('textarea', {
|
||||
key: 'textarea',
|
||||
value: typeof answerData === 'object' ? JSON.stringify(answerData, null, 2) : answerData,
|
||||
readOnly: true,
|
||||
rows: 6,
|
||||
className: "w-full p-3 bg-custom-bg border border-green-500/20 rounded-lg font-mono text-xs text-secondary resize-none custom-scrollbar"
|
||||
}),
|
||||
// Raw JSON hidden intentionally; users copy compressed string or use QR
|
||||
React.createElement(EnhancedCopyButton, {
|
||||
key: 'copy',
|
||||
text: typeof answerData === 'object' ? JSON.stringify(answerData, null, 2) : answerData,
|
||||
text: (() => {
|
||||
try {
|
||||
const min = typeof answerData === 'object' ? JSON.stringify(answerData) : (answerData || '');
|
||||
if (typeof window.encodeBinaryToPrefixed === 'function') {
|
||||
return window.encodeBinaryToPrefixed(min);
|
||||
}
|
||||
if (typeof window.compressToPrefixedGzip === 'function') {
|
||||
return window.compressToPrefixedGzip(min);
|
||||
}
|
||||
return min;
|
||||
} catch { return typeof answerData === 'object' ? JSON.stringify(answerData) : (answerData || ''); }
|
||||
})(),
|
||||
className: "w-full px-3 py-2 bg-green-500/10 hover:bg-green-500/20 text-green-400 border border-green-500/20 rounded text-sm font-medium"
|
||||
}, 'Copy response code')
|
||||
]),
|
||||
@@ -2067,8 +2048,9 @@
|
||||
return templateOffer;
|
||||
};
|
||||
|
||||
// Conservative QR payload limit (characters). Adjust per error correction level.
|
||||
const MAX_QR_LEN = 800;
|
||||
// Conservative QR payload limits (characters). Adjust per error correction level.
|
||||
const MAX_QR_LEN = 800; // for JSON/plain/gzip
|
||||
const BIN_MAX_QR_LEN = 400; // stricter for SB1:bin to improve scan reliability
|
||||
const [qrFramesTotal, setQrFramesTotal] = React.useState(0);
|
||||
const [qrFrameIndex, setQrFrameIndex] = React.useState(0);
|
||||
const [qrManualMode, setQrManualMode] = React.useState(false);
|
||||
@@ -2083,6 +2065,33 @@
|
||||
setQrManualMode(false);
|
||||
};
|
||||
|
||||
// Render frame at current index (no index mutation)
|
||||
const renderCurrent = async () => {
|
||||
const { chunks, idx } = qrAnimationRef.current || {};
|
||||
if (!chunks || !chunks.length) return;
|
||||
const current = chunks[idx % chunks.length];
|
||||
try {
|
||||
const isDesktop = (typeof window !== 'undefined') && ((window.innerWidth || 0) >= 1024);
|
||||
const QR_SIZE = isDesktop ? 720 : 512;
|
||||
const url = await (window.generateQRCode ? window.generateQRCode(current, { errorCorrectionLevel: 'M', margin: 2, size: QR_SIZE }) : Promise.resolve(''));
|
||||
if (url) setQrCodeUrl(url);
|
||||
} catch (e) {
|
||||
console.warn('Animated QR render error (current):', e);
|
||||
}
|
||||
setQrFrameIndex(((qrAnimationRef.current?.idx || 0) % (qrAnimationRef.current?.chunks?.length || 1)) + 1);
|
||||
};
|
||||
|
||||
// Render current frame, then advance index by 1
|
||||
const renderAndAdvance = async () => {
|
||||
await renderCurrent();
|
||||
const len = qrAnimationRef.current?.chunks?.length || 0;
|
||||
if (len > 0) {
|
||||
const nextIdx = ((qrAnimationRef.current?.idx || 0) + 1) % len;
|
||||
qrAnimationRef.current.idx = nextIdx;
|
||||
setQrFrameIndex(nextIdx + 1);
|
||||
}
|
||||
};
|
||||
|
||||
const toggleQrManualMode = () => {
|
||||
const newManualMode = !qrManualMode;
|
||||
setQrManualMode(newManualMode);
|
||||
@@ -2095,35 +2104,57 @@
|
||||
}
|
||||
console.log('QR Manual mode enabled - auto-scroll stopped');
|
||||
} else {
|
||||
if (qrAnimationRef.current.chunks.length > 1 && qrAnimationRef.current.active) {
|
||||
const intervalMs = 4000;
|
||||
qrAnimationRef.current.timer = setInterval(renderNext, intervalMs);
|
||||
if (qrAnimationRef.current.chunks.length > 1) {
|
||||
const intervalMs = 3000;
|
||||
qrAnimationRef.current.active = true;
|
||||
clearInterval(qrAnimationRef.current.timer);
|
||||
qrAnimationRef.current.timer = setInterval(renderAndAdvance, intervalMs);
|
||||
}
|
||||
console.log('QR Manual mode disabled - auto-scroll resumed');
|
||||
}
|
||||
};
|
||||
|
||||
const nextQrFrame = () => {
|
||||
const nextQrFrame = async () => {
|
||||
console.log('🎮 nextQrFrame called, qrFramesTotal:', qrFramesTotal, 'qrAnimationRef.current:', qrAnimationRef.current);
|
||||
if (qrAnimationRef.current.chunks.length > 1) {
|
||||
const nextIdx = (qrAnimationRef.current.idx + 1) % qrAnimationRef.current.chunks.length;
|
||||
qrAnimationRef.current.idx = nextIdx;
|
||||
setQrFrameIndex(nextIdx + 1);
|
||||
console.log('🎮 Next frame index:', nextIdx + 1);
|
||||
renderNext();
|
||||
// Ensure auto-advance timer runs in manual mode too
|
||||
try { clearInterval(qrAnimationRef.current.timer); } catch {}
|
||||
qrAnimationRef.current.timer = null;
|
||||
await renderCurrent();
|
||||
// If not in manual mode, restart auto timer
|
||||
if (!qrManualMode && qrAnimationRef.current.chunks.length > 1) {
|
||||
const intervalMs = 3000;
|
||||
qrAnimationRef.current.active = true;
|
||||
qrAnimationRef.current.timer = setInterval(renderAndAdvance, intervalMs);
|
||||
} else {
|
||||
qrAnimationRef.current.active = false;
|
||||
}
|
||||
} else {
|
||||
console.log('🎮 No multiple frames to navigate');
|
||||
}
|
||||
};
|
||||
|
||||
const prevQrFrame = () => {
|
||||
const prevQrFrame = async () => {
|
||||
console.log('🎮 prevQrFrame called, qrFramesTotal:', qrFramesTotal, 'qrAnimationRef.current:', qrAnimationRef.current);
|
||||
if (qrAnimationRef.current.chunks.length > 1) {
|
||||
const prevIdx = (qrAnimationRef.current.idx - 1 + qrAnimationRef.current.chunks.length) % qrAnimationRef.current.chunks.length;
|
||||
qrAnimationRef.current.idx = prevIdx;
|
||||
setQrFrameIndex(prevIdx + 1);
|
||||
console.log('🎮 Previous frame index:', prevIdx + 1);
|
||||
renderNext();
|
||||
try { clearInterval(qrAnimationRef.current.timer); } catch {}
|
||||
qrAnimationRef.current.timer = null;
|
||||
await renderCurrent();
|
||||
if (!qrManualMode && qrAnimationRef.current.chunks.length > 1) {
|
||||
const intervalMs = 3000;
|
||||
qrAnimationRef.current.active = true;
|
||||
qrAnimationRef.current.timer = setInterval(renderAndAdvance, intervalMs);
|
||||
} else {
|
||||
qrAnimationRef.current.active = false;
|
||||
}
|
||||
} else {
|
||||
console.log('🎮 No multiple frames to navigate');
|
||||
}
|
||||
@@ -2141,7 +2172,11 @@
|
||||
const QR_SIZE = isDesktop ? 720 : 512;
|
||||
if (payload.length <= MAX_QR_LEN) {
|
||||
if (!window.generateQRCode) throw new Error('QR code generator unavailable');
|
||||
stopQrAnimation();
|
||||
try { if (qrAnimationRef.current && qrAnimationRef.current.timer) { clearInterval(qrAnimationRef.current.timer); } } catch {}
|
||||
qrAnimationRef.current = { timer: null, chunks: [], idx: 0, active: false };
|
||||
setQrFrameIndex(0);
|
||||
setQrFramesTotal(0);
|
||||
setQrManualMode(false);
|
||||
const qrDataUrl = await window.generateQRCode(payload, { errorCorrectionLevel: 'M', size: QR_SIZE, margin: 2 });
|
||||
setQrCodeUrl(qrDataUrl);
|
||||
setQrFramesTotal(1);
|
||||
@@ -2149,7 +2184,11 @@
|
||||
return;
|
||||
}
|
||||
|
||||
stopQrAnimation();
|
||||
try { if (qrAnimationRef.current && qrAnimationRef.current.timer) { clearInterval(qrAnimationRef.current.timer); } } catch {}
|
||||
qrAnimationRef.current = { timer: null, chunks: [], idx: 0, active: false };
|
||||
setQrFrameIndex(0);
|
||||
setQrFramesTotal(0);
|
||||
setQrManualMode(false);
|
||||
const id = `raw_${Date.now()}_${Math.random().toString(36).slice(2)}`;
|
||||
|
||||
const TARGET_CHUNKS = 10;
|
||||
@@ -2175,27 +2214,12 @@
|
||||
setQrFramesTotal(rawChunks.length);
|
||||
setQrFrameIndex(1);
|
||||
const EC_OPTS = { errorCorrectionLevel: 'M', margin: 2, size: QR_SIZE };
|
||||
const renderNext = async () => {
|
||||
const { chunks, idx, active } = qrAnimationRef.current;
|
||||
if (!active || !chunks.length) return;
|
||||
const current = chunks[idx % chunks.length];
|
||||
try {
|
||||
const url = await window.generateQRCode(current, EC_OPTS);
|
||||
setQrCodeUrl(url);
|
||||
} catch (e) {
|
||||
console.warn('Animated QR render error (raw):', e);
|
||||
}
|
||||
const nextIdx = (idx + 1) % chunks.length;
|
||||
qrAnimationRef.current.idx = nextIdx;
|
||||
setQrFrameIndex(nextIdx + 1);
|
||||
};
|
||||
await renderNext();
|
||||
await renderNext();
|
||||
|
||||
if (!qrManualMode) {
|
||||
const ua = (typeof navigator !== 'undefined' && navigator.userAgent) ? navigator.userAgent : '';
|
||||
const isIOS = /iPhone|iPad|iPod/i.test(ua);
|
||||
const intervalMs = 4000; // 4 seconds per frame for better readability
|
||||
qrAnimationRef.current.timer = setInterval(renderNext, intervalMs);
|
||||
qrAnimationRef.current.active = true;
|
||||
qrAnimationRef.current.timer = setInterval(renderAndAdvance, intervalMs);
|
||||
}
|
||||
return;
|
||||
} catch (error) {
|
||||
@@ -2279,11 +2303,21 @@
|
||||
|
||||
const handleQRScan = async (scannedData) => {
|
||||
try {
|
||||
// Prefer binary (CBOR) decode, else gzip JSON, else raw JSON
|
||||
let parsedData;
|
||||
if (typeof window.decodeAnyPayload === 'function') {
|
||||
const any = window.decodeAnyPayload(scannedData);
|
||||
if (typeof any === 'string') {
|
||||
parsedData = JSON.parse(any);
|
||||
} else {
|
||||
parsedData = any; // object from binary
|
||||
}
|
||||
} else {
|
||||
const maybeDecompressed = (typeof window.decompressIfNeeded === 'function') ? window.decompressIfNeeded(scannedData) : scannedData;
|
||||
parsedData = JSON.parse(maybeDecompressed);
|
||||
}
|
||||
|
||||
// Try to parse as JSON first
|
||||
const parsedData = JSON.parse(scannedData);
|
||||
|
||||
// QR with hdr/body: COSE or RAW animated frames
|
||||
// QR with hdr/body: COSE or RAW/BIN animated frames
|
||||
if (parsedData.hdr && parsedData.body) {
|
||||
const { hdr } = parsedData;
|
||||
// Initialize/rotate buffer by id
|
||||
@@ -2309,7 +2343,7 @@
|
||||
// Explicitly keep scanner open
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
// Completed: decide RAW vs COSE
|
||||
// Completed: decide RAW vs BIN vs COSE
|
||||
if (hdr.rt === 'raw') {
|
||||
try {
|
||||
// Sort by seq and concatenate bodies
|
||||
@@ -2334,6 +2368,34 @@
|
||||
console.warn('RAW multi-frame reconstruction failed:', e);
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
} else if (hdr.rt === 'bin') {
|
||||
try {
|
||||
const parts = qrChunksBufferRef.current.items
|
||||
.map(s => JSON.parse(s))
|
||||
.sort((a, b) => (a.hdr.seq || 0) - (b.hdr.seq || 0))
|
||||
.map(p => p.body || '');
|
||||
const fullText = parts.join(''); // SB1:bin:...
|
||||
let payloadObj;
|
||||
if (typeof window.decodeAnyPayload === 'function') {
|
||||
const any = window.decodeAnyPayload(fullText);
|
||||
payloadObj = (typeof any === 'string') ? JSON.parse(any) : any;
|
||||
} else {
|
||||
payloadObj = JSON.parse(fullText);
|
||||
}
|
||||
if (showOfferStep) {
|
||||
setAnswerInput(JSON.stringify(payloadObj, null, 2));
|
||||
} else {
|
||||
setOfferInput(JSON.stringify(payloadObj, null, 2));
|
||||
}
|
||||
setMessages(prev => [...prev, { message: 'All frames captured. BIN payload reconstructed.', type: 'success' }]);
|
||||
try { document.dispatchEvent(new CustomEvent('qr-scan-complete', { detail: { id: hdr.id } })); } catch {}
|
||||
qrChunksBufferRef.current = { id: null, total: 0, seen: new Set(), items: [] };
|
||||
setShowQRScannerModal(false);
|
||||
return Promise.resolve(true);
|
||||
} catch (e) {
|
||||
console.warn('BIN multi-frame reconstruction failed:', e);
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
} else if (window.receiveAndProcess) {
|
||||
try {
|
||||
const results = await window.receiveAndProcess(qrChunksBufferRef.current.items);
|
||||
@@ -2409,10 +2471,10 @@
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Check if this is compressed data (missing SDP)
|
||||
if (!parsedData.sdp) {
|
||||
// If payload was compressed, it's already decompressed above; keep legacy warning only when clearly incomplete
|
||||
if (!parsedData.sdp && parsedData.type === 'enhanced_secure_offer') {
|
||||
setMessages(prev => [...prev, {
|
||||
message: 'QR code contains compressed data (SDP removed). Please use copy/paste for full data.',
|
||||
message: 'Compressed QR may omit SDP for brevity. Use copy/paste if connection fails.',
|
||||
type: 'warning'
|
||||
}]);
|
||||
}
|
||||
@@ -2467,10 +2529,46 @@
|
||||
setOfferData(offer);
|
||||
setShowOfferStep(true);
|
||||
|
||||
// Generate QR code for the offer data
|
||||
// Use compact JSON (no pretty-printing) to reduce size
|
||||
// Do not auto-generate single QR; prepare animated binary frames when user opens QR
|
||||
const offerString = typeof offer === 'object' ? JSON.stringify(offer) : offer;
|
||||
await generateQRCode(offerString);
|
||||
try {
|
||||
if (typeof window.encodeBinaryToPrefixed === 'function') {
|
||||
const bin = window.encodeBinaryToPrefixed(offerString);
|
||||
// Precompute frames to be ready instantly on show
|
||||
const id = `bin_${Date.now()}_${Math.random().toString(36).slice(2)}`;
|
||||
const TARGET_CHUNKS = 10;
|
||||
let FRAME_MAX = Math.max(200, Math.floor(bin.length / TARGET_CHUNKS));
|
||||
if (FRAME_MAX <= 0) FRAME_MAX = 200;
|
||||
let total = Math.ceil(bin.length / FRAME_MAX);
|
||||
if (total < 2) { total = 2; FRAME_MAX = Math.ceil(bin.length / 2) || 1; }
|
||||
const chunks = [];
|
||||
for (let i = 0; i < total; i++) {
|
||||
const seq = i + 1;
|
||||
const part = bin.slice(i * FRAME_MAX, (i + 1) * FRAME_MAX);
|
||||
chunks.push(JSON.stringify({ hdr: { v: 1, id, seq, total, rt: 'bin' }, body: part }));
|
||||
}
|
||||
// Seed first frame and start auto-advance immediately
|
||||
const isDesktop = (typeof window !== 'undefined') && ((window.innerWidth || 0) >= 1024);
|
||||
const QR_SIZE = isDesktop ? 720 : 512;
|
||||
if (window.generateQRCode && chunks.length > 0) {
|
||||
const firstUrl = await window.generateQRCode(chunks[0], { errorCorrectionLevel: 'M', size: QR_SIZE, margin: 2 });
|
||||
if (firstUrl) setQrCodeUrl(firstUrl);
|
||||
}
|
||||
// Store precomputed chunks to ref, ready for animation
|
||||
try { if (qrAnimationRef.current && qrAnimationRef.current.timer) { clearInterval(qrAnimationRef.current.timer); } } catch {}
|
||||
qrAnimationRef.current = { timer: null, chunks, idx: 0, active: true };
|
||||
setQrFramesTotal(chunks.length);
|
||||
setQrFrameIndex(1);
|
||||
setQrManualMode(false);
|
||||
// Start auto-advance loop for Offer immediately
|
||||
const intervalMs = 3000;
|
||||
qrAnimationRef.current.timer = setInterval(renderAndAdvance, intervalMs);
|
||||
// Show QR immediately for Offer flow
|
||||
try { setShowQRCode(true); } catch {}
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Offer QR precompute failed:', e);
|
||||
}
|
||||
|
||||
const existingMessages = messages.filter(m =>
|
||||
m.type === 'system' &&
|
||||
@@ -2530,8 +2628,14 @@
|
||||
|
||||
let offer;
|
||||
try {
|
||||
// Parse the offer data directly (no decryption needed with SAS)
|
||||
offer = JSON.parse(offerInput.trim());
|
||||
// Prefer binary decode first, then gzip JSON
|
||||
if (typeof window.decodeAnyPayload === 'function') {
|
||||
const any = window.decodeAnyPayload(offerInput.trim());
|
||||
offer = (typeof any === 'string') ? JSON.parse(any) : any;
|
||||
} else {
|
||||
const rawText = (typeof window.decompressIfNeeded === 'function') ? window.decompressIfNeeded(offerInput.trim()) : offerInput.trim();
|
||||
offer = JSON.parse(rawText);
|
||||
}
|
||||
} catch (parseError) {
|
||||
throw new Error(`Invalid invitation format: ${parseError.message}`);
|
||||
}
|
||||
@@ -2552,10 +2656,51 @@
|
||||
setAnswerData(answer);
|
||||
setShowAnswerStep(true);
|
||||
|
||||
// Generate QR code for the answer data
|
||||
// Answer QR: precompute binary frames and start animation immediately
|
||||
const answerString = typeof answer === 'object' ? JSON.stringify(answer) : answer;
|
||||
|
||||
await generateQRCode(answerString);
|
||||
try {
|
||||
if (typeof window.encodeBinaryToPrefixed === 'function') {
|
||||
const bin = window.encodeBinaryToPrefixed(answerString);
|
||||
const id = `ans_${Date.now()}_${Math.random().toString(36).slice(2)}`;
|
||||
const TARGET_CHUNKS = 10;
|
||||
let FRAME_MAX = Math.max(200, Math.floor(bin.length / TARGET_CHUNKS));
|
||||
if (FRAME_MAX <= 0) FRAME_MAX = 200;
|
||||
let total = Math.ceil(bin.length / FRAME_MAX);
|
||||
if (total < 2) { total = 2; FRAME_MAX = Math.ceil(bin.length / 2) || 1; }
|
||||
const chunks = [];
|
||||
for (let i = 0; i < total; i++) {
|
||||
const seq = i + 1;
|
||||
const part = bin.slice(i * FRAME_MAX, (i + 1) * FRAME_MAX);
|
||||
chunks.push(JSON.stringify({ hdr: { v: 1, id, seq, total, rt: 'bin' }, body: part }));
|
||||
}
|
||||
const isDesktop = (typeof window !== 'undefined') && ((window.innerWidth || 0) >= 1024);
|
||||
const QR_SIZE = isDesktop ? 720 : 512;
|
||||
if (window.generateQRCode && chunks.length > 0) {
|
||||
const firstUrl = await window.generateQRCode(chunks[0], { errorCorrectionLevel: 'M', size: QR_SIZE, margin: 2 });
|
||||
if (firstUrl) setQrCodeUrl(firstUrl);
|
||||
}
|
||||
try { if (qrAnimationRef.current && qrAnimationRef.current.timer) { clearInterval(qrAnimationRef.current.timer); } } catch {}
|
||||
qrAnimationRef.current = { timer: null, chunks, idx: 0, active: true };
|
||||
setQrFramesTotal(chunks.length);
|
||||
setQrFrameIndex(1);
|
||||
setQrManualMode(false);
|
||||
const intervalMs = 3000;
|
||||
qrAnimationRef.current.timer = setInterval(renderAndAdvance, intervalMs);
|
||||
try { setShowQRCode(true); } catch {}
|
||||
} else {
|
||||
// Fallback: single QR compressed or plain
|
||||
let url = '';
|
||||
if (typeof window.generateCompressedQRCode === 'function') {
|
||||
url = await window.generateCompressedQRCode(answerString);
|
||||
} else {
|
||||
url = await generateQRCode(answerString);
|
||||
}
|
||||
if (url) setQrCodeUrl(url);
|
||||
try { setShowQRCode(true); } catch {}
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Answer QR generation failed:', e);
|
||||
}
|
||||
|
||||
// Mark answer as created for state management
|
||||
if (e.target.value.trim().length > 0) {
|
||||
@@ -2633,8 +2778,14 @@
|
||||
|
||||
let answer;
|
||||
try {
|
||||
// Parse the answer data directly (no decryption needed with SAS)
|
||||
answer = JSON.parse(answerInput.trim());
|
||||
// Prefer binary decode first, then gzip JSON
|
||||
if (typeof window.decodeAnyPayload === 'function') {
|
||||
const anyAnswer = window.decodeAnyPayload(answerInput.trim());
|
||||
answer = (typeof anyAnswer === 'string') ? JSON.parse(anyAnswer) : anyAnswer;
|
||||
} else {
|
||||
const rawText = (typeof window.decompressIfNeeded === 'function') ? window.decompressIfNeeded(answerInput.trim()) : answerInput.trim();
|
||||
answer = JSON.parse(rawText);
|
||||
}
|
||||
} catch (parseError) {
|
||||
throw new Error(`Invalid response format: ${parseError.message}`);
|
||||
}
|
||||
|
||||
+146
-1
@@ -7,8 +7,44 @@
|
||||
|
||||
import * as QRCode from 'qrcode';
|
||||
import { Html5Qrcode } from 'html5-qrcode';
|
||||
import { gzip, ungzip, deflate, inflate } from 'pako';
|
||||
import * as cbor from 'cbor-js';
|
||||
import { packSecurePayload, receiveAndProcess } from '../crypto/cose-qr.js';
|
||||
|
||||
// Compact payload prefix to signal gzip+base64 content
|
||||
const COMPRESSION_PREFIX = 'SB1:gz:';
|
||||
const BINARY_PREFIX = 'SB1:bin:'; // CBOR + deflate + base64url
|
||||
|
||||
function uint8ToBase64(bytes) {
|
||||
let binary = '';
|
||||
const chunkSize = 0x8000;
|
||||
for (let i = 0; i < bytes.length; i += chunkSize) {
|
||||
const chunk = bytes.subarray(i, i + chunkSize);
|
||||
binary += String.fromCharCode.apply(null, chunk);
|
||||
}
|
||||
return btoa(binary);
|
||||
}
|
||||
|
||||
function base64ToUint8(b64) {
|
||||
const binary = atob(b64);
|
||||
const len = binary.length;
|
||||
const bytes = new Uint8Array(len);
|
||||
for (let i = 0; i < len; i++) bytes[i] = binary.charCodeAt(i);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
function compressStringToBase64Gzip(text) {
|
||||
const utf8 = new TextEncoder().encode(text);
|
||||
const gz = gzip(utf8);
|
||||
return uint8ToBase64(gz);
|
||||
}
|
||||
|
||||
function decompressBase64GzipToString(b64) {
|
||||
const gz = base64ToUint8(b64);
|
||||
const out = ungzip(gz);
|
||||
return new TextDecoder().decode(out);
|
||||
}
|
||||
|
||||
async function generateQRCode(text, opts = {}) {
|
||||
const size = opts.size || 512;
|
||||
const margin = opts.margin ?? 2;
|
||||
@@ -16,6 +52,56 @@ async function generateQRCode(text, opts = {}) {
|
||||
return await QRCode.toDataURL(text, { width: size, margin, errorCorrectionLevel });
|
||||
}
|
||||
|
||||
// Generate QR with gzip+base64 payload and recognizable prefix for scanners
|
||||
async function generateCompressedQRCode(text, opts = {}) {
|
||||
try {
|
||||
const compressedB64 = compressStringToBase64Gzip(text);
|
||||
const payload = COMPRESSION_PREFIX + compressedB64;
|
||||
return await generateQRCode(payload, opts);
|
||||
} catch (e) {
|
||||
console.warn('generateCompressedQRCode failed, falling back to plain:', e?.message || e);
|
||||
return await generateQRCode(text, opts);
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Binary (CBOR) encode/decode helpers ----
|
||||
function base64ToBase64Url(b64) {
|
||||
return b64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/g, '');
|
||||
}
|
||||
function base64UrlToBase64(b64url) {
|
||||
let b64 = b64url.replace(/-/g, '+').replace(/_/g, '/');
|
||||
const pad = b64.length % 4;
|
||||
if (pad) b64 += '='.repeat(4 - pad);
|
||||
return b64;
|
||||
}
|
||||
|
||||
function encodeObjectToBinaryBase64Url(obj) {
|
||||
const cborBytes = cbor.encode(obj);
|
||||
const compressed = deflate(new Uint8Array(cborBytes));
|
||||
const b64 = uint8ToBase64(compressed);
|
||||
return base64ToBase64Url(b64);
|
||||
}
|
||||
|
||||
function decodeBinaryBase64UrlToObject(b64url) {
|
||||
const b64 = base64UrlToBase64(b64url);
|
||||
const compressed = base64ToUint8(b64);
|
||||
const decompressed = inflate(compressed);
|
||||
const ab = decompressed.buffer.slice(decompressed.byteOffset, decompressed.byteOffset + decompressed.byteLength);
|
||||
return cbor.decode(ab);
|
||||
}
|
||||
|
||||
async function generateBinaryQRCodeFromObject(obj, opts = {}) {
|
||||
try {
|
||||
const b64url = encodeObjectToBinaryBase64Url(obj);
|
||||
const payload = BINARY_PREFIX + b64url;
|
||||
return await generateQRCode(payload, opts);
|
||||
} catch (e) {
|
||||
console.warn('generateBinaryQRCodeFromObject failed, falling back to JSON compressed:', e?.message || e);
|
||||
const text = JSON.stringify(obj);
|
||||
return await generateCompressedQRCode(text, opts);
|
||||
}
|
||||
}
|
||||
|
||||
// COSE-based QR generation for large data
|
||||
async function generateCOSEQRCode(data, senderKey = null, recipientKey = null) {
|
||||
try {
|
||||
@@ -40,9 +126,68 @@ async function generateCOSEQRCode(data, senderKey = null, recipientKey = null) {
|
||||
|
||||
// Expose functions to global scope
|
||||
window.generateQRCode = generateQRCode;
|
||||
window.generateCompressedQRCode = generateCompressedQRCode;
|
||||
window.generateBinaryQRCodeFromObject = generateBinaryQRCodeFromObject;
|
||||
window.generateCOSEQRCode = generateCOSEQRCode;
|
||||
window.Html5Qrcode = Html5Qrcode;
|
||||
window.packSecurePayload = packSecurePayload;
|
||||
window.receiveAndProcess = receiveAndProcess;
|
||||
|
||||
console.log('QR libraries loaded: generateQRCode, generateCOSEQRCode, Html5Qrcode, COSE functions');
|
||||
// Expose helper to transparently decompress scanner payloads
|
||||
window.decompressIfNeeded = function (scannedText) {
|
||||
try {
|
||||
if (typeof scannedText === 'string' && scannedText.startsWith(COMPRESSION_PREFIX)) {
|
||||
const b64 = scannedText.slice(COMPRESSION_PREFIX.length);
|
||||
return decompressBase64GzipToString(b64);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('decompressIfNeeded failed:', e?.message || e);
|
||||
}
|
||||
return scannedText;
|
||||
};
|
||||
|
||||
// Expose helper to get compressed string with prefix for copy/paste flows
|
||||
window.compressToPrefixedGzip = function (text) {
|
||||
try {
|
||||
const payload = String(text || '');
|
||||
const compressedB64 = compressStringToBase64Gzip(payload);
|
||||
return COMPRESSION_PREFIX + compressedB64;
|
||||
} catch (e) {
|
||||
console.warn('compressToPrefixedGzip failed:', e?.message || e);
|
||||
return String(text || '');
|
||||
}
|
||||
};
|
||||
|
||||
// Expose helpers for binary payloads in copy/paste
|
||||
window.encodeBinaryToPrefixed = function (objOrJson) {
|
||||
try {
|
||||
const obj = typeof objOrJson === 'string' ? JSON.parse(objOrJson) : objOrJson;
|
||||
const b64url = encodeObjectToBinaryBase64Url(obj);
|
||||
return BINARY_PREFIX + b64url;
|
||||
} catch (e) {
|
||||
console.warn('encodeBinaryToPrefixed failed:', e?.message || e);
|
||||
return typeof objOrJson === 'string' ? objOrJson : JSON.stringify(objOrJson);
|
||||
}
|
||||
};
|
||||
|
||||
window.decodeAnyPayload = function (scannedText) {
|
||||
try {
|
||||
if (typeof scannedText === 'string') {
|
||||
if (scannedText.startsWith(BINARY_PREFIX)) {
|
||||
const b64url = scannedText.slice(BINARY_PREFIX.length);
|
||||
return decodeBinaryBase64UrlToObject(b64url); // returns object
|
||||
}
|
||||
if (scannedText.startsWith(COMPRESSION_PREFIX)) {
|
||||
const s = window.decompressIfNeeded(scannedText);
|
||||
return s; // returns JSON string
|
||||
}
|
||||
// Not prefixed: return as-is
|
||||
return scannedText;
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('decodeAnyPayload failed:', e?.message || e);
|
||||
}
|
||||
return scannedText;
|
||||
};
|
||||
|
||||
console.log('QR libraries loaded: generateQRCode, generateCompressedQRCode, generateBinaryQRCodeFromObject, Html5Qrcode, COSE functions');
|
||||
Reference in new issue
Block a user