Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ios/Inji.xcworkspace/xcshareddata/swiftpm/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions machines/openID4VP/openID4VPMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ export const openID4VPMachine = model.createMachine(
},
RESET_ERROR: {
actions: 'resetError',
target: 'waitingForData',
},
},
},
Expand Down
11 changes: 1 addition & 10 deletions shared/hooks/useOvpErrorModal.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {useEffect, useState} from 'react';
import {MatchingVcsResult, VerifierInfo,} from '../openID4VP/openid4vp.types';
import {MatchingVcsResult, VerifierInfo} from '../openID4VP/openid4vp.types';

interface OvpErrorModal {
show: boolean;
Expand Down Expand Up @@ -156,15 +156,6 @@ export function useOvpErrorModal({
showRetryButton: false,
});
generateAndStoreLogMessage('REQUEST_COULD_NOT_BE_PROCESSED');
} else if (error.includes('invalid_client')) {
setErrorModal({
show: true,
title: t('errors.invalidQrCode.title'),
message: t('errors.invalidQrCode.message'),
additionalMessage,
showRetryButton: false,
});
generateAndStoreLogMessage('REQUEST_COULD_NOT_BE_PROCESSED');
} else if (error.includes('VERIFIER_RESPONSE_ERROR')) {
setErrorModal({
show: true,
Expand Down
27 changes: 18 additions & 9 deletions shared/openID4VP/OpenID4VPHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,23 @@ import getAllConfigurations, {CACHED_API} from '../api';
import {JWT_ALG_TO_KEY_TYPE} from '../constants';
import {SignatureAlgorithms} from '../cryptoutil/KeyTypes';
import {UnsignedVPToken, VPTokenSigningResult} from './openid4vp.types';
import {defaultWalletConfig} from "./walletConfig/WalletConfig";
import {defaultWalletConfig} from './walletConfig/WalletConfig';
import forge from 'node-forge';

export async function getWalletConfig() {
const config = await getAllConfigurations();
let walletConfig = config.openid4vpWalletConfig;
if (!walletConfig) {
console.warn("There is no wallet configuration available in the config. Using default wallet configuration.");
console.warn(
'There is no wallet configuration available in the config. Using default wallet configuration.',
);
walletConfig = {...defaultWalletConfig};
} else {
walletConfig = parseJSON(walletConfig)
walletConfig = parseJSON(walletConfig);
}

walletConfig["validate_pre_registered_verifier"] = config.openid4vpClientValidation === 'true'
walletConfig['validate_pre_registered_verifier'] =
config.openid4vpClientValidation === 'true';

try {
const trustedVerifiersResponse =
Expand Down Expand Up @@ -72,7 +76,6 @@ export const signDataForVpPreparation = async (
return keyTypeToKeysPromise[keyType];
};


const result: Promise<VPTokenSigningResult>[] = unSignedVpTokens.map(
async unsignedVPToken => {
let signature: string | undefined = '';
Expand All @@ -89,7 +92,10 @@ export const signDataForVpPreparation = async (
payload, // Payload is in base64 url encoded form - decode it before signing
signatureAlgorithm,
);
return {signedData: signature, id: unsignedVPToken.id} as VPTokenSigningResult;
return {
signedData: signature,
id: unsignedVPToken.id,
} as VPTokenSigningResult;
Comment thread
KiruthikaJeyashankar marked this conversation as resolved.
},
);

Expand All @@ -102,11 +108,14 @@ async function signData(
base64EncodedPayload: string,
keyType: string,
) {
const payloadBytes = base64ToByteArray(base64EncodedPayload);
const payloadBytes: Uint8Array = base64ToByteArray(base64EncodedPayload);

switch (keyType) {
case SignatureAlgorithms.RS256:
return createSignatureRSA(privateKey, base64EncodedPayload);
return createSignatureRSA(
privateKey,
forge.util.binary.raw.encode(payloadBytes),
);
case SignatureAlgorithms.ES256:
return createSignatureECR1(privateKey, payloadBytes);
case SignatureAlgorithms.ES256K:
Expand All @@ -115,7 +124,7 @@ async function signData(
return createSignatureED(privateKey, payloadBytes);
}
default:
break;
throw new Error(`Unsupported signature algorithm: ${keyType}`);
}
}

Expand Down
Loading