@pezkuwi/react-qr 3.16.6

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 (132) hide show
  1. package/README.md +3 -0
  2. package/build/Display.d.ts +12 -0
  3. package/build/Display.js +91 -0
  4. package/build/DisplayAddress.d.ts +12 -0
  5. package/build/DisplayAddress.js +12 -0
  6. package/build/DisplayPayload.d.ts +15 -0
  7. package/build/DisplayPayload.js +12 -0
  8. package/build/LICENSE +201 -0
  9. package/build/NetworkSpecs.d.ts +11 -0
  10. package/build/NetworkSpecs.js +12 -0
  11. package/build/README.md +3 -0
  12. package/build/Scan.d.ts +12 -0
  13. package/build/Scan.js +53 -0
  14. package/build/ScanAddress.d.ts +19 -0
  15. package/build/ScanAddress.js +41 -0
  16. package/build/ScanSignature.d.ts +15 -0
  17. package/build/ScanSignature.js +8 -0
  18. package/build/bundle-pezkuwi-react-qr.js +26227 -0
  19. package/build/bundle.d.ts +6 -0
  20. package/build/bundle.js +6 -0
  21. package/build/cjs/Display.d.ts +12 -0
  22. package/build/cjs/Display.js +95 -0
  23. package/build/cjs/DisplayAddress.d.ts +12 -0
  24. package/build/cjs/DisplayAddress.js +16 -0
  25. package/build/cjs/DisplayPayload.d.ts +15 -0
  26. package/build/cjs/DisplayPayload.js +16 -0
  27. package/build/cjs/NetworkSpecs.d.ts +11 -0
  28. package/build/cjs/NetworkSpecs.js +16 -0
  29. package/build/cjs/Scan.d.ts +12 -0
  30. package/build/cjs/Scan.js +57 -0
  31. package/build/cjs/ScanAddress.d.ts +19 -0
  32. package/build/cjs/ScanAddress.js +45 -0
  33. package/build/cjs/ScanSignature.d.ts +15 -0
  34. package/build/cjs/ScanSignature.js +12 -0
  35. package/build/cjs/bundle.d.ts +6 -0
  36. package/build/cjs/bundle.js +15 -0
  37. package/build/cjs/constants.d.ts +9 -0
  38. package/build/cjs/constants.js +12 -0
  39. package/build/cjs/index.d.ts +2 -0
  40. package/build/cjs/index.js +5 -0
  41. package/build/cjs/package.json +3 -0
  42. package/build/cjs/packageDetect.d.ts +1 -0
  43. package/build/cjs/packageDetect.js +5 -0
  44. package/build/cjs/packageInfo.d.ts +6 -0
  45. package/build/cjs/packageInfo.js +4 -0
  46. package/build/cjs/qrcode.d.ts +3 -0
  47. package/build/cjs/qrcode.js +8 -0
  48. package/build/cjs/styled.d.ts +1 -0
  49. package/build/cjs/styled.js +5 -0
  50. package/build/cjs/util.d.ts +7 -0
  51. package/build/cjs/util.js +59 -0
  52. package/build/constants.d.ts +9 -0
  53. package/build/constants.js +9 -0
  54. package/build/index.d.ts +2 -0
  55. package/build/index.js +2 -0
  56. package/build/package.json +274 -0
  57. package/build/packageDetect.d.ts +1 -0
  58. package/build/packageDetect.js +3 -0
  59. package/build/packageInfo.d.ts +6 -0
  60. package/build/packageInfo.js +1 -0
  61. package/build/qrcode.d.ts +3 -0
  62. package/build/qrcode.js +4 -0
  63. package/build/styled.d.ts +1 -0
  64. package/build/styled.js +1 -0
  65. package/build/util.d.ts +7 -0
  66. package/build/util.js +50 -0
  67. package/build-tsc/Display.d.ts +12 -0
  68. package/build-tsc/DisplayAddress.d.ts +12 -0
  69. package/build-tsc/DisplayPayload.d.ts +15 -0
  70. package/build-tsc/NetworkSpecs.d.ts +11 -0
  71. package/build-tsc/Scan.d.ts +12 -0
  72. package/build-tsc/ScanAddress.d.ts +19 -0
  73. package/build-tsc/ScanSignature.d.ts +15 -0
  74. package/build-tsc/bundle.d.ts +6 -0
  75. package/build-tsc/constants.d.ts +9 -0
  76. package/build-tsc/index.d.ts +2 -0
  77. package/build-tsc/packageDetect.d.ts +1 -0
  78. package/build-tsc/packageInfo.d.ts +6 -0
  79. package/build-tsc/qrcode.d.ts +3 -0
  80. package/build-tsc/styled.d.ts +1 -0
  81. package/build-tsc/util.d.ts +7 -0
  82. package/build-tsc-cjs/Display.js +95 -0
  83. package/build-tsc-cjs/DisplayAddress.js +16 -0
  84. package/build-tsc-cjs/DisplayPayload.js +16 -0
  85. package/build-tsc-cjs/NetworkSpecs.js +16 -0
  86. package/build-tsc-cjs/Scan.js +57 -0
  87. package/build-tsc-cjs/ScanAddress.js +45 -0
  88. package/build-tsc-cjs/ScanSignature.js +12 -0
  89. package/build-tsc-cjs/bundle.js +15 -0
  90. package/build-tsc-cjs/constants.js +12 -0
  91. package/build-tsc-cjs/index.js +5 -0
  92. package/build-tsc-cjs/packageDetect.js +5 -0
  93. package/build-tsc-cjs/packageInfo.js +4 -0
  94. package/build-tsc-cjs/qrcode.js +8 -0
  95. package/build-tsc-cjs/styled.js +5 -0
  96. package/build-tsc-cjs/util.js +59 -0
  97. package/build-tsc-esm/Display.js +91 -0
  98. package/build-tsc-esm/DisplayAddress.js +12 -0
  99. package/build-tsc-esm/DisplayPayload.js +12 -0
  100. package/build-tsc-esm/NetworkSpecs.js +12 -0
  101. package/build-tsc-esm/Scan.js +53 -0
  102. package/build-tsc-esm/ScanAddress.js +41 -0
  103. package/build-tsc-esm/ScanSignature.js +8 -0
  104. package/build-tsc-esm/bundle.js +6 -0
  105. package/build-tsc-esm/constants.js +9 -0
  106. package/build-tsc-esm/index.js +2 -0
  107. package/build-tsc-esm/packageDetect.js +3 -0
  108. package/build-tsc-esm/packageInfo.js +1 -0
  109. package/build-tsc-esm/qrcode.js +4 -0
  110. package/build-tsc-esm/styled.js +1 -0
  111. package/build-tsc-esm/util.js +50 -0
  112. package/package.json +40 -0
  113. package/src/Display.tsx +153 -0
  114. package/src/DisplayAddress.tsx +40 -0
  115. package/src/DisplayPayload.tsx +42 -0
  116. package/src/NetworkSpecs.tsx +39 -0
  117. package/src/Scan.tsx +100 -0
  118. package/src/ScanAddress.tsx +82 -0
  119. package/src/ScanSignature.tsx +39 -0
  120. package/src/bundle.ts +9 -0
  121. package/src/constants.ts +12 -0
  122. package/src/index.ts +6 -0
  123. package/src/packageDetect.ts +11 -0
  124. package/src/packageInfo.ts +6 -0
  125. package/src/qrcode.ts +15 -0
  126. package/src/styled.ts +4 -0
  127. package/src/util.spec.ts +100 -0
  128. package/src/util.ts +83 -0
  129. package/tsconfig.build.json +14 -0
  130. package/tsconfig.build.tsbuildinfo +1 -0
  131. package/tsconfig.spec.json +16 -0
  132. package/tsconfig.spec.tsbuildinfo +1 -0
@@ -0,0 +1,274 @@
1
+ {
2
+ "author": "Jaco Greeff <jacogr@gmail.com>",
3
+ "bugs": "https://github.com/pezkuwichain/ui/issues",
4
+ "description": "Generates and reads QR codes",
5
+ "engines": {
6
+ "node": ">=18"
7
+ },
8
+ "homepage": "https://github.com/pezkuwichain/ui/tree/master/packages/react-qr#readme",
9
+ "license": "Apache-2.0",
10
+ "name": "@pezkuwi/react-qr",
11
+ "repository": {
12
+ "directory": "packages/react-qr",
13
+ "type": "git",
14
+ "url": "https://github.com/pezkuwichain/ui.git"
15
+ },
16
+ "sideEffects": [
17
+ "./packageDetect.js",
18
+ "./cjs/packageDetect.js"
19
+ ],
20
+ "type": "module",
21
+ "version": "3.16.6",
22
+ "main": "./cjs/index.js",
23
+ "module": "./index.js",
24
+ "types": "./index.d.ts",
25
+ "exports": {
26
+ "./cjs/package.json": "./cjs/package.json",
27
+ "./cjs/*": "./cjs/*.js",
28
+ ".": {
29
+ "module": {
30
+ "types": "./index.d.ts",
31
+ "default": "./index.js"
32
+ },
33
+ "require": {
34
+ "types": "./cjs/index.d.ts",
35
+ "default": "./cjs/index.js"
36
+ },
37
+ "default": {
38
+ "types": "./index.d.ts",
39
+ "default": "./index.js"
40
+ }
41
+ },
42
+ "./bundle": {
43
+ "module": {
44
+ "types": "./bundle.d.ts",
45
+ "default": "./bundle.js"
46
+ },
47
+ "require": {
48
+ "types": "./cjs/bundle.d.ts",
49
+ "default": "./cjs/bundle.js"
50
+ },
51
+ "default": {
52
+ "types": "./bundle.d.ts",
53
+ "default": "./bundle.js"
54
+ }
55
+ },
56
+ "./constants": {
57
+ "module": {
58
+ "types": "./constants.d.ts",
59
+ "default": "./constants.js"
60
+ },
61
+ "require": {
62
+ "types": "./cjs/constants.d.ts",
63
+ "default": "./cjs/constants.js"
64
+ },
65
+ "default": {
66
+ "types": "./constants.d.ts",
67
+ "default": "./constants.js"
68
+ }
69
+ },
70
+ "./Display": {
71
+ "module": {
72
+ "types": "./Display.d.ts",
73
+ "default": "./Display.js"
74
+ },
75
+ "require": {
76
+ "types": "./cjs/Display.d.ts",
77
+ "default": "./cjs/Display.js"
78
+ },
79
+ "default": {
80
+ "types": "./Display.d.ts",
81
+ "default": "./Display.js"
82
+ }
83
+ },
84
+ "./DisplayAddress": {
85
+ "module": {
86
+ "types": "./DisplayAddress.d.ts",
87
+ "default": "./DisplayAddress.js"
88
+ },
89
+ "require": {
90
+ "types": "./cjs/DisplayAddress.d.ts",
91
+ "default": "./cjs/DisplayAddress.js"
92
+ },
93
+ "default": {
94
+ "types": "./DisplayAddress.d.ts",
95
+ "default": "./DisplayAddress.js"
96
+ }
97
+ },
98
+ "./DisplayPayload": {
99
+ "module": {
100
+ "types": "./DisplayPayload.d.ts",
101
+ "default": "./DisplayPayload.js"
102
+ },
103
+ "require": {
104
+ "types": "./cjs/DisplayPayload.d.ts",
105
+ "default": "./cjs/DisplayPayload.js"
106
+ },
107
+ "default": {
108
+ "types": "./DisplayPayload.d.ts",
109
+ "default": "./DisplayPayload.js"
110
+ }
111
+ },
112
+ "./NetworkSpecs": {
113
+ "module": {
114
+ "types": "./NetworkSpecs.d.ts",
115
+ "default": "./NetworkSpecs.js"
116
+ },
117
+ "require": {
118
+ "types": "./cjs/NetworkSpecs.d.ts",
119
+ "default": "./cjs/NetworkSpecs.js"
120
+ },
121
+ "default": {
122
+ "types": "./NetworkSpecs.d.ts",
123
+ "default": "./NetworkSpecs.js"
124
+ }
125
+ },
126
+ "./package.json": {
127
+ "require": "./cjs/package.json",
128
+ "default": "./package.json"
129
+ },
130
+ "./packageDetect": {
131
+ "module": {
132
+ "types": "./packageDetect.d.ts",
133
+ "default": "./packageDetect.js"
134
+ },
135
+ "require": {
136
+ "types": "./cjs/packageDetect.d.ts",
137
+ "default": "./cjs/packageDetect.js"
138
+ },
139
+ "default": {
140
+ "types": "./packageDetect.d.ts",
141
+ "default": "./packageDetect.js"
142
+ }
143
+ },
144
+ "./packageInfo.js": {
145
+ "module": {
146
+ "types": "./packageInfo.d.ts",
147
+ "default": "./packageInfo.js"
148
+ },
149
+ "require": {
150
+ "types": "./cjs/packageInfo.d.ts",
151
+ "default": "./cjs/packageInfo.js"
152
+ },
153
+ "default": {
154
+ "types": "./packageInfo.d.ts",
155
+ "default": "./packageInfo.js"
156
+ }
157
+ },
158
+ "./packageInfo": {
159
+ "module": {
160
+ "types": "./packageInfo.d.ts",
161
+ "default": "./packageInfo.js"
162
+ },
163
+ "require": {
164
+ "types": "./cjs/packageInfo.d.ts",
165
+ "default": "./cjs/packageInfo.js"
166
+ },
167
+ "default": {
168
+ "types": "./packageInfo.d.ts",
169
+ "default": "./packageInfo.js"
170
+ }
171
+ },
172
+ "./qrcode": {
173
+ "module": {
174
+ "types": "./qrcode.d.ts",
175
+ "default": "./qrcode.js"
176
+ },
177
+ "require": {
178
+ "types": "./cjs/qrcode.d.ts",
179
+ "default": "./cjs/qrcode.js"
180
+ },
181
+ "default": {
182
+ "types": "./qrcode.d.ts",
183
+ "default": "./qrcode.js"
184
+ }
185
+ },
186
+ "./Scan": {
187
+ "module": {
188
+ "types": "./Scan.d.ts",
189
+ "default": "./Scan.js"
190
+ },
191
+ "require": {
192
+ "types": "./cjs/Scan.d.ts",
193
+ "default": "./cjs/Scan.js"
194
+ },
195
+ "default": {
196
+ "types": "./Scan.d.ts",
197
+ "default": "./Scan.js"
198
+ }
199
+ },
200
+ "./ScanAddress": {
201
+ "module": {
202
+ "types": "./ScanAddress.d.ts",
203
+ "default": "./ScanAddress.js"
204
+ },
205
+ "require": {
206
+ "types": "./cjs/ScanAddress.d.ts",
207
+ "default": "./cjs/ScanAddress.js"
208
+ },
209
+ "default": {
210
+ "types": "./ScanAddress.d.ts",
211
+ "default": "./ScanAddress.js"
212
+ }
213
+ },
214
+ "./ScanSignature": {
215
+ "module": {
216
+ "types": "./ScanSignature.d.ts",
217
+ "default": "./ScanSignature.js"
218
+ },
219
+ "require": {
220
+ "types": "./cjs/ScanSignature.d.ts",
221
+ "default": "./cjs/ScanSignature.js"
222
+ },
223
+ "default": {
224
+ "types": "./ScanSignature.d.ts",
225
+ "default": "./ScanSignature.js"
226
+ }
227
+ },
228
+ "./styled": {
229
+ "module": {
230
+ "types": "./styled.d.ts",
231
+ "default": "./styled.js"
232
+ },
233
+ "require": {
234
+ "types": "./cjs/styled.d.ts",
235
+ "default": "./cjs/styled.js"
236
+ },
237
+ "default": {
238
+ "types": "./styled.d.ts",
239
+ "default": "./styled.js"
240
+ }
241
+ },
242
+ "./util": {
243
+ "module": {
244
+ "types": "./util.d.ts",
245
+ "default": "./util.js"
246
+ },
247
+ "require": {
248
+ "types": "./cjs/util.d.ts",
249
+ "default": "./cjs/util.js"
250
+ },
251
+ "default": {
252
+ "types": "./util.d.ts",
253
+ "default": "./util.js"
254
+ }
255
+ }
256
+ },
257
+ "dependencies": {
258
+ "@pezkuwi/ui-settings": "3.16.6",
259
+ "@pezkuwi/util": "^14.0.5",
260
+ "@pezkuwi/util-crypto": "^14.0.5",
261
+ "@zxing/browser": "^0.1.5",
262
+ "@zxing/library": "^0.21.2",
263
+ "qrcode-generator": "^1.4.4",
264
+ "styled-components": "^6.1.1",
265
+ "tslib": "^2.8.1"
266
+ },
267
+ "peerDependencies": {
268
+ "@pezkuwi/util": "*",
269
+ "@pezkuwi/util-crypto": "*",
270
+ "react": "*",
271
+ "react-dom": "*",
272
+ "react-is": "*"
273
+ }
274
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { detectPackage } from '@pezkuwi/util';
2
+ import { packageInfo } from './packageInfo.js';
3
+ detectPackage(packageInfo, null, []);
@@ -0,0 +1,6 @@
1
+ export declare const packageInfo: {
2
+ name: string;
3
+ path: string;
4
+ type: string;
5
+ version: string;
6
+ };
@@ -0,0 +1 @@
1
+ export const packageInfo = { name: '@pezkuwi/react-qr', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '3.16.6' };
@@ -0,0 +1,3 @@
1
+ import _qrcode from 'qrcode-generator';
2
+ declare const qrcode: typeof _qrcode;
3
+ export { qrcode };
@@ -0,0 +1,4 @@
1
+ import _qrcode from 'qrcode-generator';
2
+ const qrcode = _qrcode;
3
+ qrcode.stringToBytes = (data) => data;
4
+ export { qrcode };
@@ -0,0 +1 @@
1
+ export { styled } from 'styled-components';
@@ -0,0 +1 @@
1
+ export { styled } from 'styled-components';
@@ -0,0 +1,7 @@
1
+ export declare function encodeNumber(value: number): Uint8Array;
2
+ export declare function encodeString(value: string): Uint8Array;
3
+ export declare function decodeString(value: Uint8Array): string;
4
+ export declare function createAddressPayload(address: string, genesisHash: string): Uint8Array;
5
+ export declare function createSignPayload(address: string, cmd: number, payload: string | Uint8Array, genesisHash: string | Uint8Array): Uint8Array;
6
+ export declare function createFrames(input: Uint8Array): Uint8Array[];
7
+ export declare function createImgSize(size?: string | number): Record<string, string>;
package/build/util.js ADDED
@@ -0,0 +1,50 @@
1
+ import { isString, u8aConcat, u8aToU8a } from '@pezkuwi/util';
2
+ import { decodeAddress } from '@pezkuwi/util-crypto';
3
+ import { ADDRESS_PREFIX, CRYPTO_SR25519, FRAME_SIZE, SUBSTRATE_ID } from './constants.js';
4
+ const MULTIPART = new Uint8Array([0]);
5
+ export function encodeNumber(value) {
6
+ return new Uint8Array([value >> 8, value & 0xff]);
7
+ }
8
+ export function encodeString(value) {
9
+ const count = value.length;
10
+ const u8a = new Uint8Array(count);
11
+ for (let i = 0; i < count; i++) {
12
+ u8a[i] = value.charCodeAt(i);
13
+ }
14
+ return u8a;
15
+ }
16
+ export function decodeString(value) {
17
+ return value.reduce((str, code) => {
18
+ return str + String.fromCharCode(code);
19
+ }, '');
20
+ }
21
+ export function createAddressPayload(address, genesisHash) {
22
+ return encodeString(`${ADDRESS_PREFIX}:${address}:${genesisHash}`);
23
+ }
24
+ export function createSignPayload(address, cmd, payload, genesisHash) {
25
+ return u8aConcat(SUBSTRATE_ID, CRYPTO_SR25519, new Uint8Array([cmd]), decodeAddress(address), u8aToU8a(payload), u8aToU8a(genesisHash));
26
+ }
27
+ export function createFrames(input) {
28
+ const frames = [];
29
+ let idx = 0;
30
+ while (idx < input.length) {
31
+ frames.push(input.subarray(idx, idx + FRAME_SIZE));
32
+ idx += FRAME_SIZE;
33
+ }
34
+ return frames.map((frame, index) => u8aConcat(MULTIPART, encodeNumber(frames.length), encodeNumber(index), frame));
35
+ }
36
+ export function createImgSize(size) {
37
+ if (!size) {
38
+ return {
39
+ height: 'auto',
40
+ width: '100%'
41
+ };
42
+ }
43
+ const height = isString(size)
44
+ ? size
45
+ : `${size}px`;
46
+ return {
47
+ height,
48
+ width: height
49
+ };
50
+ }
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ interface Props {
3
+ className?: string | undefined;
4
+ size?: string | number | undefined;
5
+ skipEncoding?: boolean;
6
+ style?: React.CSSProperties | undefined;
7
+ timerDelay?: number | undefined;
8
+ value: Uint8Array;
9
+ }
10
+ declare function Display({ className, size, skipEncoding, style, timerDelay, value }: Props): React.ReactElement<Props> | null;
11
+ export declare const QrDisplay: React.MemoExoticComponent<typeof Display>;
12
+ export {};
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ interface Props {
3
+ address: string;
4
+ genesisHash: string;
5
+ className?: string;
6
+ size?: string | number;
7
+ style?: React.CSSProperties;
8
+ timerDelay?: number;
9
+ }
10
+ declare function DisplayAddress({ address, className, genesisHash, size, style, timerDelay }: Props): React.ReactElement<Props> | null;
11
+ export declare const QrDisplayAddress: React.MemoExoticComponent<typeof DisplayAddress>;
12
+ export {};
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ interface Props {
3
+ address: string;
4
+ className?: string;
5
+ cmd: number;
6
+ delay?: number;
7
+ genesisHash: Uint8Array | string;
8
+ payload: Uint8Array;
9
+ size?: string | number;
10
+ style?: React.CSSProperties;
11
+ timerDelay?: number;
12
+ }
13
+ declare function DisplayPayload({ address, className, cmd, genesisHash, payload, size, style, timerDelay }: Props): React.ReactElement<Props> | null;
14
+ export declare const QrDisplayPayload: React.MemoExoticComponent<typeof DisplayPayload>;
15
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { NetworkSpecsStruct } from '@pezkuwi/ui-settings/types';
2
+ import React from 'react';
3
+ interface Props {
4
+ className?: string;
5
+ networkSpecs: NetworkSpecsStruct;
6
+ size?: string | number;
7
+ style?: React.CSSProperties;
8
+ }
9
+ declare function DisplayNetworkSpecs({ className, networkSpecs, size, style }: Props): React.ReactElement<Props> | null;
10
+ export declare const QrNetworkSpecs: React.MemoExoticComponent<typeof DisplayNetworkSpecs>;
11
+ export {};
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ interface Props {
3
+ className?: string | undefined;
4
+ delay?: number;
5
+ onError?: undefined | ((error: Error) => void);
6
+ onScan: (data: string) => void;
7
+ size?: string | number | undefined;
8
+ style?: React.CSSProperties | undefined;
9
+ }
10
+ declare function Scan({ className, delay, onError, onScan, size, style }: Props): React.ReactElement<Props>;
11
+ export declare const QrScan: React.MemoExoticComponent<typeof Scan>;
12
+ export {};
@@ -0,0 +1,19 @@
1
+ import type { HexString } from '@pezkuwi/util/types';
2
+ import React from 'react';
3
+ interface ScanType {
4
+ isAddress: boolean;
5
+ content: string;
6
+ genesisHash: HexString | null;
7
+ name?: string | undefined;
8
+ }
9
+ interface Props {
10
+ className?: string;
11
+ onError?: (error: Error) => void;
12
+ onScan: (scanned: ScanType) => void;
13
+ size?: string | number;
14
+ style?: React.CSSProperties;
15
+ isEthereum?: boolean;
16
+ }
17
+ declare function ScanAddress({ className, isEthereum, onError, onScan, size, style }: Props): React.ReactElement<Props>;
18
+ export declare const QrScanAddress: React.MemoExoticComponent<typeof ScanAddress>;
19
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { HexString } from '@pezkuwi/util/types';
2
+ import React from 'react';
3
+ interface ScanType {
4
+ signature: HexString;
5
+ }
6
+ interface Props {
7
+ className?: string;
8
+ onError?: (error: Error) => void;
9
+ onScan: (scanned: ScanType) => void;
10
+ size?: string | number;
11
+ style?: React.CSSProperties;
12
+ }
13
+ declare function ScanSignature({ className, onError, onScan, size, style }: Props): React.ReactElement<Props>;
14
+ export declare const QrScanSignature: React.MemoExoticComponent<typeof ScanSignature>;
15
+ export {};
@@ -0,0 +1,6 @@
1
+ export { QrDisplayAddress } from './DisplayAddress.js';
2
+ export { QrDisplayPayload } from './DisplayPayload.js';
3
+ export { QrNetworkSpecs } from './NetworkSpecs.js';
4
+ export { packageInfo } from './packageInfo.js';
5
+ export { QrScanAddress } from './ScanAddress.js';
6
+ export { QrScanSignature } from './ScanSignature.js';
@@ -0,0 +1,9 @@
1
+ export declare const ADDRESS_PREFIX = "substrate";
2
+ export declare const SEED_PREFIX = "secret";
3
+ export declare const FRAME_SIZE = 1024;
4
+ export declare const SUBSTRATE_ID: Uint8Array;
5
+ export declare const CRYPTO_SR25519: Uint8Array;
6
+ export declare const CMD_SIGN_TX: Uint8Array;
7
+ export declare const CMD_SIGN_TX_HASH: Uint8Array;
8
+ export declare const CMD_SIGN_IMMORTAL_TX: Uint8Array;
9
+ export declare const CMD_SIGN_MSG: Uint8Array;
@@ -0,0 +1,2 @@
1
+ import './packageDetect.js';
2
+ export * from './bundle.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ export declare const packageInfo: {
2
+ name: string;
3
+ path: string;
4
+ type: string;
5
+ version: string;
6
+ };
@@ -0,0 +1,3 @@
1
+ import _qrcode from 'qrcode-generator';
2
+ declare const qrcode: typeof _qrcode;
3
+ export { qrcode };
@@ -0,0 +1 @@
1
+ export { styled } from 'styled-components';
@@ -0,0 +1,7 @@
1
+ export declare function encodeNumber(value: number): Uint8Array;
2
+ export declare function encodeString(value: string): Uint8Array;
3
+ export declare function decodeString(value: Uint8Array): string;
4
+ export declare function createAddressPayload(address: string, genesisHash: string): Uint8Array;
5
+ export declare function createSignPayload(address: string, cmd: number, payload: string | Uint8Array, genesisHash: string | Uint8Array): Uint8Array;
6
+ export declare function createFrames(input: Uint8Array): Uint8Array[];
7
+ export declare function createImgSize(size?: string | number): Record<string, string>;
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QrDisplay = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = tslib_1.__importStar(require("react"));
7
+ const util_1 = require("@pezkuwi/util");
8
+ const util_crypto_1 = require("@pezkuwi/util-crypto");
9
+ const qrcode_js_1 = require("./qrcode.js");
10
+ const styled_js_1 = require("./styled.js");
11
+ const util_js_1 = require("./util.js");
12
+ const DEFAULT_FRAME_DELAY = 2750;
13
+ const TIMER_INC = 500;
14
+ function getDataUrl(value) {
15
+ const qr = (0, qrcode_js_1.qrcode)(0, 'M');
16
+ // HACK See our qrcode stringToBytes override as used internally. This
17
+ // will only work for the case where we actually pass `Bytes` in here
18
+ qr.addData(value, 'Byte');
19
+ qr.make();
20
+ return qr.createDataURL(16, 0);
21
+ }
22
+ function Display({ className = '', size, skipEncoding, style = {}, timerDelay = DEFAULT_FRAME_DELAY, value }) {
23
+ const [{ image }, setFrameState] = (0, react_1.useState)({ frameIdx: 0, frames: [], image: null, valueHash: null });
24
+ const timerRef = (0, react_1.useRef)({ timerDelay, timerId: null });
25
+ const containerStyle = (0, react_1.useMemo)(() => (0, util_js_1.createImgSize)(size), [size]);
26
+ // run on initial load to setup the global timer and provide and unsubscribe
27
+ (0, react_1.useEffect)(() => {
28
+ const nextFrame = () => setFrameState((state) => {
29
+ // when we have a single frame, we only ever fire once
30
+ if (state.frames.length <= 1) {
31
+ return state;
32
+ }
33
+ let frameIdx = state.frameIdx + 1;
34
+ // when we overflow, skip to the first and slightly increase the delay between frames
35
+ if (frameIdx === state.frames.length) {
36
+ frameIdx = 0;
37
+ timerRef.current.timerDelay = timerRef.current.timerDelay + TIMER_INC;
38
+ }
39
+ // only encode the frames on demand, not above as part of the
40
+ // state derivation - in the case of large payloads, this should
41
+ // be slightly more responsive on initial load
42
+ const newState = (0, util_1.objectSpread)({}, state, {
43
+ frameIdx,
44
+ image: getDataUrl(state.frames[frameIdx])
45
+ });
46
+ // set the new timer last
47
+ timerRef.current.timerId = setTimeout(nextFrame, timerRef.current.timerDelay);
48
+ return newState;
49
+ });
50
+ timerRef.current.timerId = setTimeout(nextFrame, timerRef.current.timerDelay);
51
+ return () => {
52
+ // eslint-disable-next-line react-hooks/exhaustive-deps
53
+ timerRef.current.timerId && clearTimeout(timerRef.current.timerId);
54
+ };
55
+ // eslint-disable-next-line react-hooks/exhaustive-deps
56
+ }, []);
57
+ (0, react_1.useEffect)(() => {
58
+ setFrameState((state) => {
59
+ const valueHash = (0, util_crypto_1.xxhashAsHex)(value);
60
+ if (valueHash === state.valueHash) {
61
+ return state;
62
+ }
63
+ const frames = skipEncoding
64
+ ? [value]
65
+ : (0, util_js_1.createFrames)(value);
66
+ // encode on demand
67
+ return {
68
+ frameIdx: 0,
69
+ frames,
70
+ image: getDataUrl(frames[0]),
71
+ valueHash
72
+ };
73
+ });
74
+ }, [skipEncoding, value]);
75
+ if (!image) {
76
+ return null;
77
+ }
78
+ return ((0, jsx_runtime_1.jsx)(StyledDiv, { className: className, style: containerStyle, children: (0, jsx_runtime_1.jsx)("div", { className: 'ui--qr-Display', style: style, children: (0, jsx_runtime_1.jsx)("img", { src: image }) }) }));
79
+ }
80
+ const StyledDiv = styled_js_1.styled.div `
81
+ .ui--qr-Display {
82
+ height: 100%;
83
+ width: 100%;
84
+
85
+ img,
86
+ svg {
87
+ background: white;
88
+ height: auto !important;
89
+ max-height: 100%;
90
+ max-width: 100%;
91
+ width: auto !important;
92
+ }
93
+ }
94
+ `;
95
+ exports.QrDisplay = react_1.default.memo(Display);
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QrDisplayAddress = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = tslib_1.__importStar(require("react"));
7
+ const Display_js_1 = require("./Display.js");
8
+ const util_js_1 = require("./util.js");
9
+ function DisplayAddress({ address, className, genesisHash, size, style, timerDelay }) {
10
+ const data = (0, react_1.useMemo)(() => (0, util_js_1.createAddressPayload)(address, genesisHash), [address, genesisHash]);
11
+ if (!data) {
12
+ return null;
13
+ }
14
+ return ((0, jsx_runtime_1.jsx)(Display_js_1.QrDisplay, { className: className, size: size, skipEncoding: true, style: style, timerDelay: timerDelay, value: data }));
15
+ }
16
+ exports.QrDisplayAddress = react_1.default.memo(DisplayAddress);
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QrDisplayPayload = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = tslib_1.__importStar(require("react"));
7
+ const Display_js_1 = require("./Display.js");
8
+ const util_js_1 = require("./util.js");
9
+ function DisplayPayload({ address, className, cmd, genesisHash, payload, size, style, timerDelay }) {
10
+ const data = (0, react_1.useMemo)(() => (0, util_js_1.createSignPayload)(address, cmd, payload, genesisHash), [address, cmd, payload, genesisHash]);
11
+ if (!data) {
12
+ return null;
13
+ }
14
+ return ((0, jsx_runtime_1.jsx)(Display_js_1.QrDisplay, { className: className, size: size, style: style, timerDelay: timerDelay, value: data }));
15
+ }
16
+ exports.QrDisplayPayload = react_1.default.memo(DisplayPayload);