@islom929/react-eimzo 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -76
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,10 +20,7 @@ import { EimzoProvider } from '@islom929/react-eimzo'
|
|
|
20
20
|
function App() {
|
|
21
21
|
return (
|
|
22
22
|
<EimzoProvider
|
|
23
|
-
apiKeys={[
|
|
24
|
-
'yourdomain.uz', 'YOUR_PRODUCTION_API_KEY_HERE',
|
|
25
|
-
'test.yourdomain.uz', 'YOUR_TEST_API_KEY_HERE',
|
|
26
|
-
]}
|
|
23
|
+
apiKeys={['yourdomain.uz', 'YOUR_API_KEY_HERE']}
|
|
27
24
|
>
|
|
28
25
|
<YourApp />
|
|
29
26
|
</EimzoProvider>
|
|
@@ -172,78 +169,6 @@ function TokenSign() {
|
|
|
172
169
|
}
|
|
173
170
|
```
|
|
174
171
|
|
|
175
|
-
### Form submission with signature
|
|
176
|
-
|
|
177
|
-
Sign form data before submitting to backend.
|
|
178
|
-
|
|
179
|
-
```tsx
|
|
180
|
-
function ApplicationForm() {
|
|
181
|
-
const { sign, loadKeys, keyList, isInstalled } = useEimzo()
|
|
182
|
-
const [step, setStep] = useState<'form' | 'sign'>('form')
|
|
183
|
-
const [formData, setFormData] = useState({ name: '', amount: 0 })
|
|
184
|
-
|
|
185
|
-
const handleSubmit = (e: React.FormEvent) => {
|
|
186
|
-
e.preventDefault()
|
|
187
|
-
loadKeys()
|
|
188
|
-
setStep('sign')
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const handleSign = (cert: ICertificate) => {
|
|
192
|
-
sign({
|
|
193
|
-
keyId: cert,
|
|
194
|
-
data: JSON.stringify(formData),
|
|
195
|
-
onSuccess: async (pkcs7) => {
|
|
196
|
-
await fetch('/api/applications', {
|
|
197
|
-
method: 'POST',
|
|
198
|
-
headers: { 'Content-Type': 'application/json' },
|
|
199
|
-
body: JSON.stringify({ ...formData, pkcs7 }),
|
|
200
|
-
})
|
|
201
|
-
alert('Application submitted!')
|
|
202
|
-
setStep('form')
|
|
203
|
-
},
|
|
204
|
-
onError: (err) => alert(`Signing failed: ${err}`),
|
|
205
|
-
})
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (step === 'form') {
|
|
209
|
-
return (
|
|
210
|
-
<form onSubmit={handleSubmit}>
|
|
211
|
-
<input
|
|
212
|
-
value={formData.name}
|
|
213
|
-
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
|
|
214
|
-
placeholder="Name"
|
|
215
|
-
/>
|
|
216
|
-
<input
|
|
217
|
-
type="number"
|
|
218
|
-
value={formData.amount}
|
|
219
|
-
onChange={(e) => setFormData({ ...formData, amount: +e.target.value })}
|
|
220
|
-
placeholder="Amount"
|
|
221
|
-
/>
|
|
222
|
-
<button type="submit" disabled={!isInstalled}>
|
|
223
|
-
Sign & Submit
|
|
224
|
-
</button>
|
|
225
|
-
</form>
|
|
226
|
-
)
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
return (
|
|
230
|
-
<div>
|
|
231
|
-
<h3>Select certificate to sign:</h3>
|
|
232
|
-
{keyList.map((cert, i) => (
|
|
233
|
-
<button
|
|
234
|
-
key={`${cert.serialNumber}-${i}`}
|
|
235
|
-
onClick={() => handleSign(cert)}
|
|
236
|
-
disabled={cert.expired}
|
|
237
|
-
>
|
|
238
|
-
{cert.CN}
|
|
239
|
-
</button>
|
|
240
|
-
))}
|
|
241
|
-
<button onClick={() => setStep('form')}>Back</button>
|
|
242
|
-
</div>
|
|
243
|
-
)
|
|
244
|
-
}
|
|
245
|
-
```
|
|
246
|
-
|
|
247
172
|
### Check E-IMZO installation
|
|
248
173
|
|
|
249
174
|
```tsx
|