diff --git a/.env.sample b/.env.sample index f206c384..dd1dcdd3 100644 --- a/.env.sample +++ b/.env.sample @@ -18,4 +18,7 @@ PROOF_TEMPLATE_URL= # Google Signin GOOGLE_WEB_CLIENT_ID=CLIENT_ID -GOOGLE_IOS_CLIENT_ID=CLIENT_ID \ No newline at end of file +GOOGLE_IOS_CLIENT_ID=CLIENT_ID + +# DATA ENCYPTION KEY +DATA_ENCRYPTION_KEY=DATA_ENCRYPTION_KEY diff --git a/app/screens/CredentialDetailsW3C.tsx b/app/screens/CredentialDetailsW3C.tsx index 21c7a3ea..a19efce7 100644 --- a/app/screens/CredentialDetailsW3C.tsx +++ b/app/screens/CredentialDetailsW3C.tsx @@ -7,10 +7,10 @@ import { deleteCredentialExchangeRecordById, useCredentialByState, CredentialState, - createInvitation, } from '@adeya/ssi' import { BrandingOverlay } from '@hyperledger/aries-oca' import { CredentialOverlay } from '@hyperledger/aries-oca/build/legacy' +import * as CryptoJS from 'crypto-js' import { toString as toQRCodeString } from 'qrcode' import React, { useCallback, useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' @@ -330,19 +330,25 @@ const CredentialDetailsW3C: React.FC = ({ navigation, ro try { setIsGeneratingPdf(true) - const invitation = await createInvitation(agent, 'https://adeya.com') + const certificateAttributes = w3cCredential?.credential.credentialSubject.claims + + const dataToEncrypt = JSON.stringify({ + email: certificateAttributes['email'] ?? 'email', + schemaUrl: w3cCredential?.credential.type[1], + }) - const qrCodeSvg = await generateQRCodeString(invitation.invitationUrl) + // eslint-disable-next-line import/namespace + const encryptedToken = CryptoJS.AES.encrypt(dataToEncrypt, 'dataEncryptionKey').toString() - const certificateAttributes = w3cCredential?.credential.credentialSubject.claims + const qrCodeSvg = await generateQRCodeString(encryptedToken) const prettyVc = w3cCredential?.credential.prettyVc let content = prettyVc.certificate - const invitationUrlPlaceholder = '{{invitationUrl}}' - const invitationUrlEscapedPlaceholder = invitationUrlPlaceholder.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + const contactDetailsPlaceholder = '{{qrcode}}' + const contactDetailsEscapedPlaceholder = contactDetailsPlaceholder.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') - content = content.replace(new RegExp(invitationUrlEscapedPlaceholder, 'g'), qrCodeSvg) + content = content.replace(new RegExp(contactDetailsEscapedPlaceholder, 'g'), qrCodeSvg) Object.keys(certificateAttributes).forEach(key => { // Statically picking the value of placeholder diff --git a/ios/AdeyaWallet.xcodeproj/project.pbxproj b/ios/AdeyaWallet.xcodeproj/project.pbxproj index 793352c8..1cb4e082 100644 --- a/ios/AdeyaWallet.xcodeproj/project.pbxproj +++ b/ios/AdeyaWallet.xcodeproj/project.pbxproj @@ -507,7 +507,7 @@ ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = AdeyaWallet/AdeyaWallet.entitlements; - CURRENT_PROJECT_VERSION = 33; + CURRENT_PROJECT_VERSION = 34; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = Z5W7KRPGHZ; ENABLE_BITCODE = NO; @@ -545,7 +545,7 @@ CODE_SIGN_ENTITLEMENTS = AdeyaWallet/AdeyaWallet.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 33; + CURRENT_PROJECT_VERSION = 34; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = Z5W7KRPGHZ; INFOPLIST_FILE = AdeyaWallet/Info.plist; diff --git a/package.json b/package.json index 21c23f2a..7782afec 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "@robinbobin/react-native-google-drive-api-wrapper": "^1.2.4", "axios": "^1.6.0", "bip39": "^3.1.0", + "crypto-js": "^4.2.0", "events": "^1.1.1", "expo-modules-core": "^1.2.7", "i18next": "^23.4.1", @@ -106,6 +107,7 @@ "@react-native/eslint-config": "^0.72.2", "@react-native/metro-config": "^0.72.9", "@tsconfig/react-native": "^3.0.0", + "@types/crypto-js": "^4.2.2", "@types/lodash.flatten": "^4.4.7", "@types/lodash.merge": "^4.6.7", "@types/lodash.shuffle": "^4.2.7", diff --git a/yarn.lock b/yarn.lock index a4a55e2c..a326ae36 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3505,6 +3505,11 @@ dependencies: "@babel/types" "^7.20.7" +"@types/crypto-js@^4.2.2": + version "4.2.2" + resolved "https://registry.yarnpkg.com/@types/crypto-js/-/crypto-js-4.2.2.tgz#771c4a768d94eb5922cc202a3009558204df0cea" + integrity sha512-sDOLlVbHhXpAUAL0YHDUUwDZf3iN4Bwi4W6a0W0b+QcAezUbRtH4FVb+9J4h+XFPW7l/gQ9F8qC7P+Ec4k8QVQ== + "@types/graceful-fs@^4.1.3": version "4.1.6" resolved "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.6.tgz" @@ -5182,7 +5187,7 @@ cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3: shebang-command "^2.0.0" which "^2.0.1" -crypto-js@4.2.0: +crypto-js@4.2.0, crypto-js@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-4.2.0.tgz#4d931639ecdfd12ff80e8186dba6af2c2e856631" integrity sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==