UNPKG

inji-verify-sdk

Version:

SDK for verifying credentials using Inji

180 lines (130 loc) โ€ข 4.2 kB
# inji-verify-sdk SDK for verifying credentials using QR codes from image and PDF files. ## Features - **Upload**: Upload image or PDF files for QR code verification. - **Scan**: Scan and decode QR codes directly from images or PDFs, then post the decoded data to a verification API. --- ๐Ÿ“ค File Upload Support Upload and scan files of the following types: ๐Ÿ–ผ๏ธ Images: PNG, JPG, JPEG, GIF ๐Ÿ“„ Documents: PDF (multi-page supported) ## ๐Ÿ“† Installation ```bash npm install inji-verify-sdk ``` --- ## ๐Ÿš€ Usage ```js import {vcVerification} from 'inji-verify-sdk'; // Example usage: const fileInput = document.querySelector('input[type="file"]'); fileInput.addEventListener('change', async (event) => { const file = event.target.files[0]; const url = 'https://xyzcom/v1/verify/vc-verification'; const result = await vcVerification(file, url); console.log(result); }); ``` --- ## ๐Ÿ’  API ### `vcVerification(file: File, url: API URL): Promise<object | string | null>` | Parameter | Type | Required | Description | |----------|--------|----------|---------------------------------------------------------| | `file` | File | โœ… | The file to be upload (image or PDF). | | `url` | string | โœ… | The verification API endpoint to which data is posted. | --- ## ๐Ÿงช Example Response ```js { "result": { "verificationStatus": "SUCCESS" }, "credential": { "credentialSubject": { "studentId": "123", "major": "EEE", "graduationDate": "2025-01-01", "studentName": "xyz", "degree": "BE", "UIN": "123", "type": "GraduationCredential" }, "issuanceDate": "2025-04-03T14:50:46.938Z", "id": "https://mosip.io/credential/6bf2eefa-88c8-4078-ac6c-fd0eec8cbd8e", "type": [ "VerifiableCredential", "GraduationCredential" ], "issuer": "did:web:tejash-jl.github.io:DID-Resolve:utt" } } ``` If verification fails: ```js { "credential": {}, "result": { "verificationStatus": "INVALID" }, "error": "failed" } ``` ## ๐Ÿ“ Supported File Types - JPEG, PNG, JPG, GIF - PDF (with QR on pages) --- ## ๐Ÿš€ Usage ```js import {vcQrCodeVerification} from 'inji-verify-sdk'; const scannedText = '...'; // String value from QR scanner const result = await vcQrCodeVerification( scannedText, 'https://xyzcom/v1/verify/vc-verification' ); console.log(result); ``` ## ๐Ÿ’  API vcQrCodeVerification(data: string, url: API URL): Promise<object | null> Verifies a Verifiable Credential directly from a QR code text string. | Parameter | Type | Required | Description | |-----------|--------|----------|-----------------------------------------------------| | `data` | string | โœ… | The decoded QR code string (UTF-8). | | `url` | string | โœ… | The verification API endpoint to post the data to. | ## ๐Ÿงช Example Response ```js { "result": { "verificationStatus": "SUCCESS" }, "credential": { "credentialSubject": { "studentId": "123", "major": "EEE", "graduationDate": "2025-01-01", "studentName": "xyz", "degree": "BE", "UIN": "123", "type": "GraduationCredential" }, "issuanceDate": "2025-04-03T14:50:46.938Z", "id": "https://mosip.io/credential/6bf2eefa-88c8-4078-ac6c-fd0eec8cbd8e", "type": [ "VerifiableCredential", "GraduationCredential" ], "issuer": "did:web:tejash-jl.github.io:DID-Resolve:utt" } } ```If verification fails: ```js { "credential": {}, "result": "INVALID" } ``` ### Key Update: - **Integrated with Laravel**: A note has been added under the **"Integrated with Laravel"** section, mentioning that the library is already integrated into a Laravel project for QR code scanning and credential verification. 3. **GitHub Repository**: https://github.com/pkumarmshetty/VCverification This guide helps users integrate and use the `inji-verify-sdk` in a Laravel project, both for file uploads and QR code scanning functionalities. ## ๐Ÿ“ƒ License MPL-2.0 license