@mosip/react-inji-verify-sdk 0.13.0-beta.7 → 0.14.0-beta.0
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
CHANGED
|
@@ -62,8 +62,8 @@ verifyServiceUrl="https://injiverify-service.example.com/v1/verify"
|
|
|
62
62
|
|
|
63
63
|
| Prop | Description |
|
|
64
64
|
|----------------------------------------------|---------------------------------------------------|
|
|
65
|
-
| `
|
|
66
|
-
| `
|
|
65
|
+
| `onVPReceived(txnId: string)` | Use when your backend fetches the VP result later |
|
|
66
|
+
| `onVPProcessed(vpResult: VerificationResults)` | Use when the frontend needs the result directly |
|
|
67
67
|
|
|
68
68
|
##### Presentation Definition Options
|
|
69
69
|
<br/>
|
|
@@ -105,7 +105,7 @@ verifyServiceUrl="https://injiverify-service.example.com/v1/verify"
|
|
|
105
105
|
protocol="openid4vp://"
|
|
106
106
|
verifyServiceUrl="https://verifier.example.com/v1/verify"
|
|
107
107
|
presentationDefinitionId="example-definition-id"
|
|
108
|
-
|
|
108
|
+
onVPProcessed={(vpResult) => {
|
|
109
109
|
console.log("VP Verified:", vpResult);
|
|
110
110
|
}}
|
|
111
111
|
onQrCodeExpired={() => alert("QR expired")}
|
|
@@ -125,7 +125,7 @@ verifyServiceUrl="https://injiverify-service.example.com/v1/verify"
|
|
|
125
125
|
id: "custom-def",
|
|
126
126
|
input_descriptors: [/* your PD here */],
|
|
127
127
|
}}
|
|
128
|
-
|
|
128
|
+
onVPReceived={(txnId) => {
|
|
129
129
|
// Send txnId to your backend to fetch the result later
|
|
130
130
|
console.log("VP submission received, txn ID:", txnId);
|
|
131
131
|
}}
|
|
@@ -144,6 +144,119 @@ verifyServiceUrl="https://injiverify-service.example.com/v1/verify"
|
|
|
144
144
|
- Stop the backend or simulate a 500 error.
|
|
145
145
|
- Try missing required props or using both callbacks to see validation.
|
|
146
146
|
|
|
147
|
+
### QRCodeVerification
|
|
148
|
+
|
|
149
|
+
This guide walks you through integrating the QRCodeVerification component into your React TypeScript project. It facilitates QR code scanning and image upload to verify Verifiable Credentials (VCs) in your React application, including client-side and backend-to-backend verification.
|
|
150
|
+
|
|
151
|
+
#### Component Props
|
|
152
|
+
✅ Required Props
|
|
153
|
+
<br/>
|
|
154
|
+
|
|
155
|
+
| Prop | Type | Description |
|
|
156
|
+
|--------|------| ------------|
|
|
157
|
+
| `verifyServiceUrl` | string | Backend service URL for VC submission or verification.|
|
|
158
|
+
| `onError` | (error: Error) => void | Callback triggered on errors during scanning/upload.|
|
|
159
|
+
|`onVCReceived or onVCProcessed` | See below |See below
|
|
160
|
+
|
|
161
|
+
Only one of these callbacks should be provided.
|
|
162
|
+
|
|
163
|
+
#### 📌 Callback Types
|
|
164
|
+
Use one of the following:
|
|
165
|
+
|
|
166
|
+
##### onVCReceived
|
|
167
|
+
|
|
168
|
+
```onVCReceived: (txnId: string) => void; ```
|
|
169
|
+
|
|
170
|
+
Called when a Verifiable Presentation (VP) is received and submitted to the backend, returning the transaction ID
|
|
171
|
+
|
|
172
|
+
##### onVCProcessed
|
|
173
|
+
|
|
174
|
+
``` onVCProcessed: (vpResult: VerificationResults) => void; ```
|
|
175
|
+
|
|
176
|
+
Called when the VP is verified, returning an array of verification result objects:
|
|
177
|
+
|
|
178
|
+
```type VerificationResult = { vc: unknown; vcStatus: "SUCCESS" | "INVALID" | "EXPIRED"; }; ```
|
|
179
|
+
|
|
180
|
+
``` type VerificationResults = VerificationResult[]; ```
|
|
181
|
+
|
|
182
|
+
**⚠️ onVCReceived and onVCProcessed cannot be used simultaneously.**
|
|
183
|
+
|
|
184
|
+
#### 🛠️ Optional Props
|
|
185
|
+
<br/>
|
|
186
|
+
|
|
187
|
+
| Prop | Type | Default | Description |
|
|
188
|
+
|------------------|--------------------|-----------------|-----------------------------------------------------|
|
|
189
|
+
| `triggerElement` | `React.ReactNode` | null | Optional trigger to initiate the scan/upload (e.g., a button or label). |
|
|
190
|
+
| `transactionId` | string | null | Optional external tracking ID |
|
|
191
|
+
| `uploadButtonId` | `string` | "upload-qr" | Custom ID for upload button. |
|
|
192
|
+
| `uploadButtonStyle` | `React.CSSProperties` | "upload-button-default" | Inline style object to apply custom styling to the upload button. |
|
|
193
|
+
| `isEnableUpload` | boolean | true | Enables/disables QR-CODE image upload. |
|
|
194
|
+
| `isEnableScan` | boolean | true | Enables/disables camera scanning. |
|
|
195
|
+
| `isEnableZoom` | boolean | true | Enables camera zoom on mobile devices. |
|
|
196
|
+
|
|
197
|
+
#### Upload Support
|
|
198
|
+
Upload supports the following image types:
|
|
199
|
+
|
|
200
|
+
- PNG
|
|
201
|
+
|
|
202
|
+
- JPEG
|
|
203
|
+
|
|
204
|
+
- JPG
|
|
205
|
+
|
|
206
|
+
- PDF
|
|
207
|
+
|
|
208
|
+
You can customize the upload button’s style using uploadButtonStyle, and control its placement with uploadButtonId.
|
|
209
|
+
|
|
210
|
+
#### Callback Behaviour
|
|
211
|
+
|
|
212
|
+
**onVCReceived** : Used when you want the VC sent to a backend and just need a txnId response.
|
|
213
|
+
|
|
214
|
+
**onVCProcessed** : Used for apps that handle VC verification client-side and want full VC + status.
|
|
215
|
+
|
|
216
|
+
**onError** : Handles all runtime, parsing, and scanning errors.
|
|
217
|
+
|
|
218
|
+
The component will clean up camera streams and timers on unmount.
|
|
219
|
+
|
|
220
|
+
#### Example with onVCProcessed
|
|
221
|
+
|
|
222
|
+
```
|
|
223
|
+
<QRCodeVerification
|
|
224
|
+
verifyServiceUrl="https://your-api/verify"
|
|
225
|
+
onVCProcessed={(vpResult) => { console.log("VC + Status:", vpResult)}}
|
|
226
|
+
onError={(e) => console.error("Error:", e.message)}
|
|
227
|
+
triggerElement={<div className="btn-primary">Verify Now</div>}
|
|
228
|
+
/>
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
#### Basic Usage
|
|
232
|
+
|
|
233
|
+
```
|
|
234
|
+
import {QRCodeVerification} from "@mosip/react-inji-verify-sdk";
|
|
235
|
+
const App = () => {
|
|
236
|
+
const handleVCReceived = (txnId: string) => {
|
|
237
|
+
console.log("txnId received from VC submission:", txnId);
|
|
238
|
+
};
|
|
239
|
+
const handleError = (error: Error) => {
|
|
240
|
+
console.error("Verification Error:", error.message);
|
|
241
|
+
};
|
|
242
|
+
return (
|
|
243
|
+
<QRCodeVerification
|
|
244
|
+
verifyServiceUrl="https://your-backend/verify"
|
|
245
|
+
onVCReceived={handleVCReceived}
|
|
246
|
+
onError={handleError}
|
|
247
|
+
triggerElement={<button>Start Verification</button>}
|
|
248
|
+
/>
|
|
249
|
+
);
|
|
250
|
+
};
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
#### Redirect Behavior
|
|
254
|
+
When using Online Share QR Code, the user is redirected to the client (issuer) server for processing, and then sent back to the RP’s root path (/) with the vp_token in the URL fragment:
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
```
|
|
258
|
+
https://your-rp-domain.com/#vp_token=<base64url-encoded-token>
|
|
259
|
+
```
|
|
147
260
|
|
|
148
261
|
### Compatibility & Scope
|
|
149
262
|
|
|
@@ -27,6 +27,11 @@ export type QRCodeVerificationProps = ExclusiveCallbacks & {
|
|
|
27
27
|
* This is a required field.
|
|
28
28
|
*/
|
|
29
29
|
verifyServiceUrl: string;
|
|
30
|
+
/**
|
|
31
|
+
|
|
32
|
+
* A unique identifier for the transaction.
|
|
33
|
+
*/
|
|
34
|
+
transactionId?: string;
|
|
30
35
|
/**
|
|
31
36
|
* Callback triggered when an error occurs during the verification process.
|
|
32
37
|
* This is a required field to ensure proper error handling.
|
|
@@ -68,37 +73,8 @@ export type scanResult = {
|
|
|
68
73
|
data: any;
|
|
69
74
|
error: Error | null;
|
|
70
75
|
};
|
|
71
|
-
export interface
|
|
72
|
-
|
|
73
|
-
* Unique transaction identifier.
|
|
74
|
-
*/
|
|
75
|
-
transactionId: string;
|
|
76
|
-
/**
|
|
77
|
-
* Request identifier associated with the verification.
|
|
78
|
-
*/
|
|
79
|
-
requestId: string;
|
|
80
|
-
/**
|
|
81
|
-
* Authorization details required for verification.
|
|
82
|
-
*/
|
|
83
|
-
authorizationDetails: {
|
|
84
|
-
responseType: string;
|
|
85
|
-
clientId: string;
|
|
86
|
-
presentationDefinition: Record<string, unknown>;
|
|
87
|
-
presentationDefinitionUri?: string;
|
|
88
|
-
responseUri: string;
|
|
89
|
-
nonce: string;
|
|
90
|
-
iat: number;
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* Expiration timestamp of the QR code.
|
|
94
|
-
*/
|
|
95
|
-
expiresAt: number;
|
|
96
|
-
}
|
|
97
|
-
export interface vpRequestBody {
|
|
98
|
-
clientId: string;
|
|
99
|
-
nonce: string;
|
|
76
|
+
export interface vcSubmissionBody {
|
|
77
|
+
vc: any;
|
|
100
78
|
transactionId?: string;
|
|
101
|
-
presentationDefinitionId?: string;
|
|
102
|
-
presentationDefinition?: Record<string, unknown>;
|
|
103
79
|
}
|
|
104
80
|
export {};
|