mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-09 21:48:04 -05:00
[INJIMOB-3226]: update logic not to stringify the VCs before sending to ovp library (#1931)
* [INJIMOB-3226]: update logic not to stringify the VCs before sending to ovp library Signed-off-by: Alka Prasad <prasadalka1998@gmail.com> * [INJIMOB-3226]: fix a error in locale files caused due to resolving merge conflicts Signed-off-by: Alka Prasad <prasadalka1998@gmail.com> * [INJIMOB-3226]: remove extra file added by mistake file Signed-off-by: Alka Prasad <prasadalka1998@gmail.com> * [INJIMOB-3015] fix ecr1 jwk creation for android Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> * [INJIMOB-3226]: adding resolution strategy to pick newer versions of library and not from cache Signed-off-by: Alka Prasad <prasadalka1998@gmail.com> * [INJIMOB-3226] update pixelpass and ovp lib version Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> --------- Signed-off-by: Alka Prasad <prasadalka1998@gmail.com> Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> Co-authored-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> Co-authored-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>
This commit is contained in:
@@ -41,9 +41,7 @@ export class OpenID4VP {
|
||||
}
|
||||
|
||||
static async constructUnsignedVPToken(selectedVCs: Record<string, VC[]>) {
|
||||
let updatedSelectedVCs = this.stringifyValues(
|
||||
this.processSelectedVCs(selectedVCs),
|
||||
);
|
||||
let updatedSelectedVCs = this.processSelectedVCs(selectedVCs);
|
||||
|
||||
const unSignedVpTokens =
|
||||
await OpenID4VP.InjiOpenID4VP.constructUnsignedVPToken(
|
||||
@@ -64,30 +62,12 @@ export class OpenID4VP {
|
||||
OpenID4VP.InjiOpenID4VP.sendErrorToVerifier(error);
|
||||
}
|
||||
|
||||
private static stringifyValues = (
|
||||
data: Record<string, Record<string, Array<any>>>,
|
||||
): Record<string, Record<string, string[]>> => {
|
||||
const result = {};
|
||||
for (const [outerKey, innerObject] of Object.entries(data)) {
|
||||
result[outerKey] = {};
|
||||
for (const [innerKey, array] of Object.entries(innerObject)) {
|
||||
if (innerKey === VCFormat.ldp_vc.valueOf())
|
||||
result[outerKey][innerKey] = array.map(item => JSON.stringify(item));
|
||||
else result[outerKey][innerKey] = array;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
private static processSelectedVCs(selectedVCs: Record<string, VC[]>) {
|
||||
const selectedVcsData: SelectedCredentialsForVPSharing = {};
|
||||
Object.entries(selectedVCs).forEach(([inputDescriptorId, vcsArray]) => {
|
||||
vcsArray.forEach(vcData => {
|
||||
const credentialFormat = vcData.vcMetadata.format;
|
||||
//TODO: this should be done irrespective of the format.
|
||||
if (credentialFormat === VCFormat.mso_mdoc.valueOf()) {
|
||||
vcData = vcData.verifiableCredential.credential;
|
||||
}
|
||||
vcData = vcData.verifiableCredential.credential;
|
||||
if (!selectedVcsData[inputDescriptorId]) {
|
||||
selectedVcsData[inputDescriptorId] = {};
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
VerifiableCredential,
|
||||
} from '../../machines/VerifiableCredential/VCMetaMachine/vc';
|
||||
import getAllConfigurations, {CACHED_API} from '../api';
|
||||
import {isIOS} from '../constants';
|
||||
import {isAndroid, isIOS} from '../constants';
|
||||
import {getJWT} from '../cryptoutil/cryptoUtil';
|
||||
import {isMockVC} from '../Utils';
|
||||
import {
|
||||
@@ -329,14 +329,21 @@ async function getJWKRSA(publicKey): Promise<any> {
|
||||
return publicKeyJWKString.toJSON();
|
||||
}
|
||||
async function getJWKECR1(publicKey): Promise<any> {
|
||||
const x = base64url(Buffer.from(publicKey.slice(1, 33))); // Skip the first byte (0x04) in the uncompressed public key
|
||||
const y = base64url(Buffer.from(publicKey.slice(33,65)));
|
||||
const jwk = {
|
||||
kty: 'EC',
|
||||
crv: 'P-256',
|
||||
x: x,
|
||||
y: y,
|
||||
};
|
||||
let jwk = {};
|
||||
if (isAndroid()) {
|
||||
const publicKeyJWKString = await jose.JWK.asKey(publicKey, 'pem');
|
||||
jwk = publicKeyJWKString.toJSON();
|
||||
} else {
|
||||
const x = base64url(Buffer.from(publicKey.slice(1, 33))); // Skip the first byte (0x04) in the uncompressed public key
|
||||
const y = base64url(Buffer.from(publicKey.slice(33, 65)));
|
||||
jwk = {
|
||||
kty: 'EC',
|
||||
crv: 'P-256',
|
||||
x: x,
|
||||
y: y,
|
||||
};
|
||||
}
|
||||
|
||||
return jwk;
|
||||
}
|
||||
function getJWKECK1(publicKey): any {
|
||||
|
||||
Reference in New Issue
Block a user