qr-payload-parser 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +106 -104
  3. package/index.d.ts +152 -120
  4. package/index.js +479 -479
  5. package/package.json +1 -1
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Sunasty (https://sunasty.com)
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sunasty (https://sunasty.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,104 +1,106 @@
1
- # qr-payload-parser
2
-
3
- [![npm version](https://img.shields.io/npm/v/qr-payload-parser.svg)](https://www.npmjs.com/package/qr-payload-parser)
4
- [![CI](https://github.com/sunasty-labs/qr-payload/actions/workflows/ci.yml/badge.svg)](https://github.com/sunasty-labs/qr-payload/actions/workflows/ci.yml)
5
- ![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)
6
- ![Dependencies: Zero](https://img.shields.io/badge/dependencies-zero-brightgreen.svg)
7
-
8
- Zero-dependency JavaScript and TypeScript parser for structured QR code payloads (`WIFI:`, `otpauth://totp/`, `BEGIN:VCARD`, `mailto:`, `MATMSG:`, `smsto:`, `sms:`, `tel:`, and HTTP/HTTPS URLs with security inspection) paired with a Web Crypto `SubtleCrypto` RFC 6238 TOTP generator and RFC 4180 CSV/JSON serializers.
9
-
10
- - **Documentation**: [Sunasty Labs Docs](https://sunasty-docs.readthedocs.io/en/latest/packages/javascript-qr-payload/)
11
- - **Live Browser Tool**: [Sunasty QR Scanner](https://sunasty.com/qr-scan/) · [Sunasty QR Generator](https://sunasty.com/qr/)
12
-
13
- ## Features
14
-
15
- - **Structured QR Payload Parser**: `parseQrPayload` normalizes raw QR strings into a strongly typed discriminated union (`wifi`, `totp`, `vcard`, `email`, `sms`, `phone`, `url`, `text`).
16
- - **RFC 6238 TOTP Generator**: `generateTotpCode` computes 6-digit (or N-digit) HMAC-SHA1 time-based one-time passwords using the standard Web Crypto `SubtleCrypto` API in Node.js (>= 18), browsers, and Service Workers.
17
- - **URL Security Inspection**: `analyzeUrlSecurity` detects unencrypted `http://` links and raw IPv4/IPv6 hostnames before navigation.
18
- - **Low-Contrast Image Preprocessors**: `applyHighContrastThreshold` and `normalizeAndBinarizeLowContrast` prepare RGBA buffers for QR matrix detection.
19
- - **Batch History Export**: `serializeScanHistoryToCsv` (RFC 4180 compliant) and `serializeScanHistoryToJson`.
20
-
21
- ## Installation
22
-
23
- Via npm or JSR:
24
-
25
- ```bash
26
- npm install qr-payload-parser
27
- # or via JSR
28
- npx jsr add @sunasty/qr-payload
29
- ```
30
-
31
- Or import directly in browsers and Deno via ESM CDN (jsDelivr):
32
-
33
- ```js
34
- import {
35
- parseQrPayload,
36
- generateTotpCode,
37
- analyzeUrlSecurity,
38
- } from 'https://cdn.jsdelivr.net/npm/qr-payload-parser@1.0.0/+esm';
39
- ```
40
-
41
- ## Usage
42
-
43
- ### Parsing Structured QR Payloads
44
-
45
- ```js
46
- import { parseQrPayload } from 'qr-payload-parser';
47
-
48
- const wifi = parseQrPayload('WIFI:S:ProdNetwork;T:WPA2;P:SecretKey2026;H:false;;');
49
- // { kind: 'wifi', ssid: 'ProdNetwork', encryption: 'WPA2', password: 'SecretKey2026', hidden: false }
50
-
51
- const vcard = parseQrPayload(
52
- 'BEGIN:VCARD\nVERSION:3.0\nFN:Alex Martin\nORG:Sunasty\nTEL:+33123456789\nEMAIL:alex@sunasty.com\nEND:VCARD'
53
- );
54
- // { kind: 'vcard', fullName: 'Alex Martin', org: 'Sunasty', phone: '+33123456789', email: 'alex@sunasty.com', ... }
55
-
56
- const urlInfo = parseQrPayload('http://192.168.1.1/login');
57
- // { kind: 'url', domain: '192.168.1.1', isInsecureHttp: true, isRawIp: true, hasSecurityWarning: true, ... }
58
- ```
59
-
60
- ### Generating RFC 6238 2FA TOTP Codes
61
-
62
- ```js
63
- import { parseQrPayload, generateTotpCode } from 'qr-payload-parser';
64
-
65
- const parsed = parseQrPayload(
66
- 'otpauth://totp/Sunasty:ops@sunasty.com?secret=JBSWY3DPEHPK3PXP&issuer=Sunasty'
67
- );
68
-
69
- if (parsed.kind === 'totp') {
70
- const { code, remainingSeconds } = await generateTotpCode(
71
- parsed.secret,
72
- Date.now(),
73
- parsed.period,
74
- parsed.digits
75
- );
76
- console.log(`Current 2FA code: ${code} (valid for ${remainingSeconds}s)`);
77
- }
78
- ```
79
-
80
- ### Exporting Scan History to RFC 4180 CSV
81
-
82
- ```js
83
- import { serializeScanHistoryToCsv } from 'qr-payload-parser';
84
-
85
- const csv = serializeScanHistoryToCsv([
86
- {
87
- timestamp: '2026-10-22T12:00:00.000Z',
88
- source: 'camera',
89
- type: 'url',
90
- isUrl: true,
91
- data: 'https://sunasty.com/qr-scan/',
92
- },
93
- ]);
94
- ```
95
-
96
- ## Web Utilities
97
-
98
- - Client-side QR code scanner from image or webcam: [https://sunasty.com/qr-scan/](https://sunasty.com/qr-scan/)
99
- - Custom SVG and PNG QR code generator: [https://sunasty.com/qr-code/](https://sunasty.com/qr-code/)
100
- - Chrome/Chromium MV3 extension repository: [https://github.com/sunasty-labs/qr-scanner](https://github.com/sunasty-labs/qr-scanner)
101
-
102
- ## License
103
-
104
- MIT
1
+ # qr-payload-parser (`@sunasty/qr-payload`)
2
+
3
+ [![npm version](https://img.shields.io/npm/v/qr-payload-parser.svg)](https://www.npmjs.com/package/qr-payload-parser)
4
+ [![JSR](https://jsr.io/badges/@sunasty/qr-payload)](https://jsr.io/@sunasty/qr-payload)
5
+ [![CI](https://github.com/sunasty-labs/qr-payload/actions/workflows/ci.yml/badge.svg)](https://github.com/sunasty-labs/qr-payload/actions/workflows/ci.yml)
6
+ ![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)
7
+ ![Dependencies: Zero](https://img.shields.io/badge/dependencies-zero-brightgreen.svg)
8
+
9
+ Zero-dependency JavaScript and TypeScript parser for structured QR code payloads (`WIFI:`, `otpauth://totp/`, `BEGIN:VCARD`, `mailto:`, `MATMSG:`, `smsto:`, `sms:`, `tel:`, and HTTP/HTTPS URLs with security inspection) paired with a Web Crypto `SubtleCrypto` RFC 6238 TOTP generator and RFC 4180 CSV/JSON serializers.
10
+
11
+ - **Documentation**: [qr-payload-parser Reference](https://sunasty-docs.readthedocs.io/en/latest/packages/javascript-qr-payload/)
12
+ - **Live Browser Tool**: [Sunasty QR Scanner](https://sunasty.com/qr-scan/) · [Sunasty QR Generator](https://sunasty.com/qr-code/)
13
+
14
+ ## Features
15
+
16
+ - **Structured QR Payload Parser**: `parseQrPayload` normalizes raw QR strings into a strongly typed discriminated union (`wifi`, `totp`, `vcard`, `email`, `sms`, `phone`, `url`, `text`).
17
+ - **RFC 6238 TOTP Generator**: `generateTotpCode` computes 6-digit (or N-digit) HMAC-SHA1 time-based one-time passwords using the standard Web Crypto `SubtleCrypto` API in Node.js (>= 18), browsers, and Service Workers (`decodeBase32`).
18
+ - **URL Security Inspection**: `analyzeUrlSecurity` detects unencrypted `http://` links and raw IPv4/IPv6 hostnames before navigation (`looksLikeUrl`).
19
+ - **Scan Validation & Preprocessing**: `SCAN_ACCEPTED_MIME`, `SCAN_MAX_BYTES`, `isAcceptedScanMime`, `applyHighContrastThreshold`, and `normalizeAndBinarizeLowContrast` validate and prepare RGBA buffers.
20
+ - **Batch History Export**: `serializeScanHistoryToCsv` (RFC 4180 compliant), `serializeScanHistoryToJson`, and `truncateForDisplay`.
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ # npm (Node.js / bundlers)
26
+ npm install qr-payload-parser
27
+
28
+ # JSR (@sunasty/qr-payload for Deno / Bun / Node)
29
+ npx jsr add @sunasty/qr-payload
30
+ deno add jsr:@sunasty/qr-payload
31
+ ```
32
+
33
+ Or import directly in browsers and Deno via ESM CDN (jsDelivr):
34
+
35
+ ```js
36
+ import {
37
+ parseQrPayload,
38
+ generateTotpCode,
39
+ analyzeUrlSecurity,
40
+ } from 'https://cdn.jsdelivr.net/npm/qr-payload-parser@1.0.2/+esm';
41
+ ```
42
+
43
+ ## Usage
44
+
45
+ ### Parsing Structured QR Payloads
46
+
47
+ ```js
48
+ import { parseQrPayload } from 'qr-payload-parser'; // or '@sunasty/qr-payload' on JSR
49
+
50
+ const wifi = parseQrPayload('WIFI:S:ProdNetwork;T:WPA2;P:SecretKey2026;H:false;;');
51
+ // { kind: 'wifi', ssid: 'ProdNetwork', encryption: 'WPA2', password: 'SecretKey2026', hidden: false }
52
+
53
+ const vcard = parseQrPayload(
54
+ 'BEGIN:VCARD\nVERSION:3.0\nFN:Alex Martin\nORG:Sunasty\nTEL:+33123456789\nEMAIL:alex@sunasty.com\nEND:VCARD'
55
+ );
56
+ // { kind: 'vcard', fullName: 'Alex Martin', org: 'Sunasty', phone: '+33123456789', email: 'alex@sunasty.com', ... }
57
+
58
+ const urlInfo = parseQrPayload('http://192.168.1.1/login');
59
+ // { kind: 'url', domain: '192.168.1.1', isInsecureHttp: true, isRawIp: true, hasSecurityWarning: true, ... }
60
+ ```
61
+
62
+ ### Generating RFC 6238 2FA TOTP Codes
63
+
64
+ ```js
65
+ import { parseQrPayload, generateTotpCode } from 'qr-payload-parser';
66
+
67
+ const parsed = parseQrPayload(
68
+ 'otpauth://totp/Sunasty:ops@sunasty.com?secret=JBSWY3DPEHPK3PXP&issuer=Sunasty'
69
+ );
70
+
71
+ if (parsed.kind === 'totp') {
72
+ const { code, remainingSeconds } = await generateTotpCode(
73
+ parsed.secret,
74
+ Date.now(),
75
+ parsed.period,
76
+ parsed.digits
77
+ );
78
+ console.log(`Current 2FA code: ${code} (valid for ${remainingSeconds}s)`);
79
+ }
80
+ ```
81
+
82
+ ### Exporting Scan History to RFC 4180 CSV
83
+
84
+ ```js
85
+ import { serializeScanHistoryToCsv } from 'qr-payload-parser';
86
+
87
+ const csv = serializeScanHistoryToCsv([
88
+ {
89
+ timestamp: '2026-10-22T12:00:00.000Z',
90
+ source: 'camera',
91
+ type: 'url',
92
+ isUrl: true,
93
+ data: 'https://sunasty.com/qr-scan/',
94
+ },
95
+ ]);
96
+ ```
97
+
98
+ ## Web Utilities
99
+
100
+ - Client-side QR code scanner from image or webcam: [https://sunasty.com/qr-scan/](https://sunasty.com/qr-scan/)
101
+ - Custom SVG and PNG QR code generator: [https://sunasty.com/qr-code/](https://sunasty.com/qr-code/)
102
+ - Chrome/Chromium MV3 extension repository: [https://github.com/sunasty-labs/qr-scanner](https://github.com/sunasty-labs/qr-scanner)
103
+
104
+ ## License
105
+
106
+ MIT
package/index.d.ts CHANGED
@@ -1,120 +1,152 @@
1
- export declare const SCAN_ACCEPTED_MIME: string[];
2
- export declare const SCAN_MAX_BYTES: number;
3
-
4
- export interface UrlSecurityAnalysis {
5
- valid: boolean;
6
- href: string;
7
- protocol: string;
8
- domain: string;
9
- pathAndQuery: string;
10
- isInsecureHttp: boolean;
11
- isRawIp: boolean;
12
- hasSecurityWarning: boolean;
13
- }
14
-
15
- export interface WifiPayload {
16
- kind: 'wifi';
17
- ssid: string;
18
- encryption: string;
19
- password: string;
20
- hidden: boolean;
21
- }
22
-
23
- export interface VcardPayload {
24
- kind: 'vcard';
25
- fullName: string;
26
- phone: string;
27
- email: string;
28
- org: string;
29
- rawVcard: string;
30
- }
31
-
32
- export interface EmailPayload {
33
- kind: 'email';
34
- to: string;
35
- subject: string;
36
- body: string;
37
- mailtoHref: string;
38
- }
39
-
40
- export interface SmsPayload {
41
- kind: 'sms';
42
- number: string;
43
- message: string;
44
- smsHref: string;
45
- }
46
-
47
- export interface PhonePayload {
48
- kind: 'phone';
49
- number: string;
50
- telHref: string;
51
- }
52
-
53
- export interface TotpPayload {
54
- kind: 'totp';
55
- label: string;
56
- account: string;
57
- issuer: string;
58
- secret: string;
59
- digits: number;
60
- period: number;
61
- }
62
-
63
- export interface UrlPayload extends UrlSecurityAnalysis {
64
- kind: 'url';
65
- text: string;
66
- }
67
-
68
- export interface TextPayload {
69
- kind: 'text';
70
- text: string;
71
- }
72
-
73
- export type ParsedQrPayload =
74
- | WifiPayload
75
- | VcardPayload
76
- | EmailPayload
77
- | SmsPayload
78
- | PhonePayload
79
- | TotpPayload
80
- | UrlPayload
81
- | TextPayload;
82
-
83
- export interface TotpResult {
84
- code: string;
85
- remainingSeconds: number;
86
- period: number;
87
- counter: number;
88
- }
89
-
90
- export interface ScanRecord {
91
- timestamp?: string;
92
- source?: string;
93
- type?: string;
94
- isUrl?: boolean;
95
- data: string;
96
- [key: string]: unknown;
97
- }
98
-
99
- export declare function isAcceptedScanMime(mime: string): boolean;
100
- export declare function looksLikeUrl(data: string): boolean;
101
- export declare function analyzeUrlSecurity(rawUrl: string): UrlSecurityAnalysis;
102
- export declare function parseQrPayload(data: string): ParsedQrPayload;
103
- export declare function decodeBase32(base32: string): Uint8Array;
104
- export declare function generateTotpCode(
105
- secretBase32: string,
106
- timestampMs?: number,
107
- period?: number,
108
- digits?: number
109
- ): Promise<TotpResult>;
110
- export declare function applyHighContrastThreshold(
111
- data: Uint8ClampedArray,
112
- threshold?: number,
113
- invert?: boolean
114
- ): Uint8ClampedArray;
115
- export declare function normalizeAndBinarizeLowContrast(
116
- data: Uint8ClampedArray
117
- ): Uint8ClampedArray;
118
- export declare function serializeScanHistoryToCsv(results: ScanRecord[]): string;
119
- export declare function serializeScanHistoryToJson(results: Array<Record<string, unknown>>): string;
120
- export declare function truncateForDisplay(data: string, maxLen?: number): string;
1
+ /**
2
+ * Zero-dependency structured QR payload parser (Wi-Fi, TOTP otpauth://, vCard,
3
+ * mailto, MATMSG, SMS, tel, URL security analyzer) and WebCrypto RFC 6238 TOTP generator.
4
+ *
5
+ * @module
6
+ */
7
+
8
+ /** Accepted MIME types for local QR code image scanning (`SCAN_ACCEPTED_MIME`). */
9
+ export declare const SCAN_ACCEPTED_MIME: string[];
10
+ /** Maximum image byte size accepted for local QR decoding (`SCAN_MAX_BYTES`). */
11
+ export declare const SCAN_MAX_BYTES: number;
12
+
13
+ /** Security inspection summary for HTTP/HTTPS and host-based URLs. */
14
+ export interface UrlSecurityAnalysis {
15
+ valid: boolean;
16
+ href: string;
17
+ protocol: string;
18
+ domain: string;
19
+ pathAndQuery: string;
20
+ isInsecureHttp: boolean;
21
+ isRawIp: boolean;
22
+ hasSecurityWarning: boolean;
23
+ }
24
+
25
+ /** Parsed `WIFI:` network QR code payload. */
26
+ export interface WifiPayload {
27
+ kind: 'wifi';
28
+ ssid: string;
29
+ encryption: string;
30
+ password: string;
31
+ hidden: boolean;
32
+ }
33
+
34
+ /** Parsed `BEGIN:VCARD` contact card QR payload. */
35
+ export interface VcardPayload {
36
+ kind: 'vcard';
37
+ fullName: string;
38
+ phone: string;
39
+ email: string;
40
+ org: string;
41
+ rawVcard: string;
42
+ }
43
+
44
+ /** Parsed `mailto:` or `MATMSG:` email QR payload. */
45
+ export interface EmailPayload {
46
+ kind: 'email';
47
+ to: string;
48
+ subject: string;
49
+ body: string;
50
+ mailtoHref: string;
51
+ }
52
+
53
+ /** Parsed `smsto:` or `sms:` message QR payload. */
54
+ export interface SmsPayload {
55
+ kind: 'sms';
56
+ number: string;
57
+ message: string;
58
+ smsHref: string;
59
+ }
60
+
61
+ /** Parsed `tel:` phone call QR payload. */
62
+ export interface PhonePayload {
63
+ kind: 'phone';
64
+ number: string;
65
+ telHref: string;
66
+ }
67
+
68
+ /** Parsed `otpauth://` TOTP/HOTP 2FA provisioning payload. */
69
+ export interface TotpPayload {
70
+ kind: 'totp';
71
+ label: string;
72
+ account: string;
73
+ issuer: string;
74
+ secret: string;
75
+ digits: number;
76
+ period: number;
77
+ }
78
+
79
+ /** Parsed HTTP/HTTPS URL payload enriched with {@link UrlSecurityAnalysis}. */
80
+ export interface UrlPayload extends UrlSecurityAnalysis {
81
+ kind: 'url';
82
+ text: string;
83
+ }
84
+
85
+ /** Fallback plain-text QR payload when no structured URI schema matches. */
86
+ export interface TextPayload {
87
+ kind: 'text';
88
+ text: string;
89
+ }
90
+
91
+ /** Discriminated union of all structured QR payload variants returned by {@link parseQrPayload}. */
92
+ export type ParsedQrPayload =
93
+ | WifiPayload
94
+ | VcardPayload
95
+ | EmailPayload
96
+ | SmsPayload
97
+ | PhonePayload
98
+ | TotpPayload
99
+ | UrlPayload
100
+ | TextPayload;
101
+
102
+ /** Generated RFC 6238 TOTP token and validity counter window returned by {@link generateTotpCode}. */
103
+ export interface TotpResult {
104
+ code: string;
105
+ remainingSeconds: number;
106
+ period: number;
107
+ counter: number;
108
+ }
109
+
110
+ /** Scan history record serialized by {@link serializeScanHistoryToCsv} and {@link serializeScanHistoryToJson}. */
111
+ export interface ScanRecord {
112
+ timestamp?: string;
113
+ source?: string;
114
+ type?: string;
115
+ isUrl?: boolean;
116
+ data: string;
117
+ [key: string]: unknown;
118
+ }
119
+
120
+ /** Returns true when `mime` is an accepted local image MIME type for QR scanning. */
121
+ export declare function isAcceptedScanMime(mime: string): boolean;
122
+ /** Returns true when raw decoded text appears to be an HTTP/HTTPS URL. */
123
+ export declare function looksLikeUrl(data: string): boolean;
124
+ /** Inspects a URL string for insecure `http:` protocol or raw IPv4/IPv6 hostnames. */
125
+ export declare function analyzeUrlSecurity(rawUrl: string): UrlSecurityAnalysis;
126
+ /** Parses a raw decoded QR string into a strongly typed {@link ParsedQrPayload} discriminated union. */
127
+ export declare function parseQrPayload(data: string): ParsedQrPayload;
128
+ /** Decodes an RFC 4648 Base32 secret string into raw key bytes. */
129
+ export declare function decodeBase32(base32: string): Uint8Array;
130
+ /** Generates an RFC 6238 HMAC-SHA1 TOTP code asynchronously using Web Crypto `SubtleCrypto`. */
131
+ export declare function generateTotpCode(
132
+ secretBase32: string,
133
+ timestampMs?: number,
134
+ period?: number,
135
+ digits?: number
136
+ ): Promise<TotpResult>;
137
+ /** Applies a luminance threshold (with optional inversion) to an RGBA pixel buffer. */
138
+ export declare function applyHighContrastThreshold(
139
+ data: Uint8ClampedArray,
140
+ threshold?: number,
141
+ invert?: boolean
142
+ ): Uint8ClampedArray;
143
+ /** Normalizes and binarizes low-contrast RGBA image data prior to QR decoding. */
144
+ export declare function normalizeAndBinarizeLowContrast(
145
+ data: Uint8ClampedArray
146
+ ): Uint8ClampedArray;
147
+ /** Exports scan history records as RFC 4180 CSV with spreadsheet formula-injection neutralization. */
148
+ export declare function serializeScanHistoryToCsv(results: ScanRecord[]): string;
149
+ /** Exports scan history records as pretty-printed JSON. */
150
+ export declare function serializeScanHistoryToJson(results: Array<Record<string, unknown>>): string;
151
+ /** Truncates long QR payload text safely for UI display up to `maxLen`. */
152
+ export declare function truncateForDisplay(data: string, maxLen?: number): string;