Skip to content

Commit

Permalink
Merge pull request #351 from sree96/use-pixelpass
Browse files Browse the repository at this point in the history
Use @mosip/pixelpass to generate VC QR codes
  • Loading branch information
pallakartheekreddy authored Nov 12, 2024
2 parents f67d066 + 05691ce commit 09ef58b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion services/credentials-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@digitalbazaar/vc": "^6.3.0",
"@fastify/static": "^7.0.4",
"@fastify/view": "^9.1.0",
"@mosip/pixelpass": "^0.5.0",
"@nestjs/axios": "^3.0.2",
"@nestjs/common": "^9.0.0",
"@nestjs/config": "^2.2.0",
Expand All @@ -51,7 +52,6 @@
"jsonld": "^8.3.2",
"jsonld-signatures": "7.0.0",
"jsonwebtoken": "^8.5.1",
"jszip": "^3.10.1",
"prisma": "4.8.1",
"qrcode": "^1.5.3",
"reflect-metadata": "^0.1.13",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { JwtCredentialSubject } from 'src/app.interface';
import * as wkhtmltopdf from 'wkhtmltopdf';
import { compile } from 'handlebars';
import * as QRCode from 'qrcode';
import JSZip from 'jszip';
import {generateQRCode } from '@mosip/pixelpass';

@Injectable()
export class RenderingUtilsService {
Expand All @@ -21,17 +21,9 @@ export class RenderingUtilsService {
}
let qrData = `${process.env.CREDENTIAL_SERVICE_BASE_URL}/credentials/${cred.id}/verify`;
if(process?.env?.QR_TYPE === "W3C_VC") {
const zip = new JSZip();
zip.file("certificate.json", JSON.stringify(cred), {
compression: "DEFLATE"
});
qrData = await zip.generateAsync({type: 'string', compression: "DEFLATE"})
.then(function (content) {
return content;
});
return QRCode.toDataURL(qrData, {scale: 3});
return generateQRCode(JSON.stringify(cred))
}
return QRCode.toDataURL(qrData);
return generateQRCode(qrData);
} catch (err) {
console.log(err);
this.logger.error('Error rendering QR: ', err);
Expand Down
23 changes: 22 additions & 1 deletion services/credentials-service/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,17 @@
resolved "https://registry.yarnpkg.com/@lukeed/ms/-/ms-2.0.2.tgz#07f09e59a74c52f4d88c6db5c1054e819538e2a8"
integrity sha512-9I2Zn6+NJLfaGoz9jN3lpwDgAYvfGeNYdbAIjJOqzs4Tpc+VU3Jqq4IofSUBKajiDS8k9fZIg18/z13mpk1bsA==

"@mosip/pixelpass@^0.5.0":
version "0.5.0"
resolved "https://registry.yarnpkg.com/@mosip/pixelpass/-/pixelpass-0.5.0.tgz#2a844ac057eeacdd682febbaeec61e363dc7d8a6"
integrity sha512-JDv8S5PvD0/xbUzrkLhU75wZq2xBV8S/YS4ejKXT8orE2NwbXcAo3NXqWoO3he6XdYLXC4n8K9aAJeup7GPh8A==
dependencies:
base45-web "^1.0.2"
cbor-web "^9.0.2"
jszip "^3.10.1"
pako "^2.1.0"
qrcode "^1.5.3"

"@multiformats/base-x@^4.0.1":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@multiformats/base-x/-/base-x-4.0.1.tgz#95ff0fa58711789d53aefb2590a8b7a4e715d121"
Expand Down Expand Up @@ -1947,6 +1958,11 @@ base-x@^3.0.2:
dependencies:
safe-buffer "^5.0.1"

base45-web@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/base45-web/-/base45-web-1.0.2.tgz#890c11271656f83d005755b7dbb133334113a741"
integrity sha512-9GS/w7MkVbXIKWzG9FjIoSJP/kfxcbvkKEL8gemZxNB21MOyBypSCL7qqFFQSEi699E6bdUA6kPPXFu5THLAPg==

base58-universal@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/base58-universal/-/base58-universal-2.0.0.tgz#243c8256591afa7d5210f87ad1655e05081f4be4"
Expand Down Expand Up @@ -2184,6 +2200,11 @@ caseless@~0.12.0:
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"
integrity sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==

cbor-web@^9.0.2:
version "9.0.2"
resolved "https://registry.yarnpkg.com/cbor-web/-/cbor-web-9.0.2.tgz#1915f1ef1a72ea905db07480f71cf12ff601c661"
integrity sha512-N6gU2GsJS8RR5gy1d9wQcSPgn9FGJFY7KNvdDRlwHfz6kCxrQr2TDnrjXHmr6TFSl6Fd0FC4zRnityEldjRGvQ==

[email protected], chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
Expand Down Expand Up @@ -5328,7 +5349,7 @@ p-try@^2.0.0:
resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6"
integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==

pako@^2.0.4:
pako@^2.0.4, pako@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/pako/-/pako-2.1.0.tgz#266cc37f98c7d883545d11335c00fbd4062c9a86"
integrity sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==
Expand Down

0 comments on commit 09ef58b

Please sign in to comment.