Skip to content

Commit

Permalink
Merge pull request #25 from shiva-beehyv/expose-qr-enocde-funtion-con…
Browse files Browse the repository at this point in the history
…sole

Expose encode vc function to console
  • Loading branch information
challabeehyv authored Apr 23, 2024
2 parents a5ec156 + 3d39b6f commit 3106602
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ const DisplayActiveStep = () => {
navigate('/offline');
}
setVcStatus(status);
setVc(vc);
if (vcStatus?.status === "OK") {
setVc(vc);
}
})
.catch(error => {
console.error("Error occurred while verifying the VC: ", error);
Expand Down
3 changes: 3 additions & 0 deletions inji-verify/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import App from './App';
import reportWebVitals from './reportWebVitals';
import {GlobalStyles, ThemeProvider} from "@mui/material";
import {InjiTheme} from "./utils/inji-theme";
import {encodeData} from "./utils/qr-utils";

const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
Expand All @@ -13,6 +14,8 @@ const root = ReactDOM.createRoot(
// Store in a constant to avoid re-rendering and recalculating the style
const inputGlobalStyles = <GlobalStyles styles={{ fontFamily: 'Inter'}} />;

window.encodeVc = (vc: any) => encodeData(JSON.stringify(vc));

root.render(
<React.StrictMode>
<ThemeProvider theme={InjiTheme}>
Expand Down
7 changes: 7 additions & 0 deletions inji-verify/src/types/global.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export {};

declare global {
interface Window {
encodeVc: (vc: any) => void;
}
}
4 changes: 3 additions & 1 deletion inji-verify/src/utils/qr-utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { scanFile } from "@openhealthnz-credentials/pdf-image-qr-scanner";
import {decodeData} from '@mosip/pixelpass';
import {decodeData, generateQRData} from '@mosip/pixelpass';
import {HEADER_DELIMITER, SUPPORTED_QR_HEADERS} from "./config";

export const scanFilesForQr = async (selectedFile) => {
Expand Down Expand Up @@ -34,3 +34,5 @@ export const decodeQrData = (qrData) => {
console.log('Decoded data: ', decodedData);
return decodedData;
}

export const encodeData = (data) => generateQRData(data);

0 comments on commit 3106602

Please sign in to comment.