mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-09 13:38:01 -05:00
[INJIMOB-3392] add token request logic in wallet for vci flow (#2014)
* [INJIMOB-3392] add token request logic in wallet for vci flow Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> * [INJIMOB-3392] chore: update integration of VCIClient native module Changes are updated as per new changes in the library Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3390] refactor: event structure of token request Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3392] fix tokenEndpoint method and refactorings Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> * [INJIMOB-3392] cnonce decode from accesstoken and credential response destructuring fix Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> * [INJIMOB-3390] add: getIssuerMetadata in kotlin NativeModule Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3393] fix: auth callback in android Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3390] fix: proofJwt issue in download flow Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3392] fix credentialofferflow Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> * [INJIMOB-3392]fix format issues in bridge layer Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> * [INJIMOB-3392]fix activity log texts on application reopen Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> * [INJIMOB-3392]cache issuer metadata by key: issuerhost Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> * [INJIMOB-3392] fix error scenarios and cleanup issuermachine Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> * [INJIMOB-3392] refactor request method to handle missing error scenarios Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> * [INJIMOB-3392] fix max lines for txcode description to 2 Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> * [INJIMOB-3392] rename credentialissueruri to credentialissuer Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> * [INJIMOB-3392] take cnonce from outside accesstoken Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> * [INJIMOB-3392] declare random-values at entry file Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> * [INJIMOB-3392] set fallback keytype to user priority first Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> * [INJIMOB-3392] add locales for network request failed error Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> * [INJIMOB-3392] remove console log Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> * [INJIMOB-3392] refactor and clean up code Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@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>
This commit is contained in:
committed by
GitHub
parent
0fe6915bb8
commit
5305e7d7ea
@@ -8,6 +8,7 @@ import {
|
||||
import {
|
||||
EXPIRED_VC_ERROR_CODE,
|
||||
MY_VCS_STORE_KEY,
|
||||
NO_INTERNET,
|
||||
REQUEST_TIMEOUT,
|
||||
isIOS,
|
||||
} from '../../shared/constants';
|
||||
@@ -25,9 +26,8 @@ import {
|
||||
} from '../../shared/telemetry/TelemetryUtils';
|
||||
import {TelemetryConstants} from '../../shared/telemetry/TelemetryConstants';
|
||||
import {NativeModules} from 'react-native';
|
||||
import {KeyTypes} from '../../shared/cryptoutil/KeyTypes';
|
||||
import {VCActivityLog} from '../../components/ActivityLogEvent';
|
||||
import {isNetworkError} from '../../shared/Utils';
|
||||
import {isNetworkError, parseJSON} from '../../shared/Utils';
|
||||
import {issuerType} from './IssuersMachine';
|
||||
|
||||
const {RNSecureKeystoreModule} = NativeModules;
|
||||
@@ -52,9 +52,6 @@ export const IssuersActions = (model: any) => {
|
||||
setIssuers: model.assign({
|
||||
issuers: (_: any, event: any) => event.data as issuerType[],
|
||||
}),
|
||||
setNoInternet: model.assign({
|
||||
errorMessage: () => ErrorMessage.NO_INTERNET,
|
||||
}),
|
||||
setLoadingReasonAsDisplayIssuers: model.assign({
|
||||
loadingReason: 'displayIssuers',
|
||||
}),
|
||||
@@ -75,7 +72,7 @@ export const IssuersActions = (model: any) => {
|
||||
return proofTypesSupported.jwt
|
||||
.proof_signing_alg_values_supported as string[];
|
||||
} else {
|
||||
return [KeyTypes.RS256] as string[];
|
||||
return [] as string[];
|
||||
}
|
||||
},
|
||||
}),
|
||||
@@ -85,17 +82,6 @@ export const IssuersActions = (model: any) => {
|
||||
resetSelectedCredentialType: model.assign({
|
||||
selectedCredentialType: {},
|
||||
}),
|
||||
setNetworkOrTechnicalError: model.assign({
|
||||
errorMessage: (_: any, event: any) => {
|
||||
console.error(
|
||||
`Error occurred during ${event} flow`,
|
||||
event.data.message,
|
||||
);
|
||||
return isNetworkError(event.data.message)
|
||||
? ErrorMessage.NO_INTERNET
|
||||
: ErrorMessage.TECHNICAL_DIFFICULTIES;
|
||||
},
|
||||
}),
|
||||
setCredentialTypeListDownloadFailureError: model.assign({
|
||||
errorMessage: (_: any, event: any) => {
|
||||
if (isNetworkError(event.data.message)) {
|
||||
@@ -109,9 +95,12 @@ export const IssuersActions = (model: any) => {
|
||||
errorMessage: (_: any, event: any) => {
|
||||
console.error(`Error occurred while ${event} -> `, event.data.message);
|
||||
const error = event.data.message;
|
||||
if (isNetworkError(error)) {
|
||||
if (error.includes(NO_INTERNET)) {
|
||||
return ErrorMessage.NO_INTERNET;
|
||||
}
|
||||
if (isNetworkError(error)) {
|
||||
return ErrorMessage.NETWORK_REQUEST_FAILED;
|
||||
}
|
||||
if (error.includes(REQUEST_TIMEOUT)) {
|
||||
return ErrorMessage.REQUEST_TIMEDOUT;
|
||||
}
|
||||
@@ -126,9 +115,6 @@ export const IssuersActions = (model: any) => {
|
||||
return ErrorMessage.GENERIC;
|
||||
},
|
||||
}),
|
||||
setOIDCConfigError: model.assign({
|
||||
errorMessage: (_: any, event: any) => event.data.toString(),
|
||||
}),
|
||||
resetError: model.assign({
|
||||
errorMessage: '',
|
||||
}),
|
||||
@@ -236,20 +222,24 @@ export const IssuersActions = (model: any) => {
|
||||
return context.issuers.find(issuer => issuer.issuer_id === event.id);
|
||||
},
|
||||
}),
|
||||
|
||||
resetSelectedIssuer: model.assign({
|
||||
selectedIssuer: () => ({} as issuerType),
|
||||
}),
|
||||
updateIssuerFromWellknown: model.assign({
|
||||
selectedIssuer: (context: any, event: any) => ({
|
||||
...context.selectedIssuer,
|
||||
credential_audience: event.data.credential_issuer,
|
||||
credential_endpoint: event.data.credential_endpoint,
|
||||
credential_configurations_supported:
|
||||
event.data.credential_configurations_supported,
|
||||
display: event.data.display,
|
||||
authorization_servers: event.data.authorization_servers,
|
||||
}),
|
||||
selectedIssuerWellknownResponse: (_: any, event: any) => {
|
||||
return event.data;
|
||||
},
|
||||
}),
|
||||
setCredential: model.assign({
|
||||
credential: (_: any, event: any) => event.data,
|
||||
credential: (_: any, event: any) => event.data.credential,
|
||||
}),
|
||||
setQrData: model.assign({
|
||||
qrData: (_: any, event: any) => event.data,
|
||||
@@ -261,7 +251,7 @@ export const IssuersActions = (model: any) => {
|
||||
}),
|
||||
setAccessToken: model.assign({
|
||||
accessToken: (_: any, event: any) => {
|
||||
return event.accessToken;
|
||||
return event.data.access_token;
|
||||
},
|
||||
}),
|
||||
setCNonce: model.assign({
|
||||
@@ -269,20 +259,41 @@ export const IssuersActions = (model: any) => {
|
||||
return event.cNonce;
|
||||
},
|
||||
}),
|
||||
setOfferCredentialTypeContexts: model.assign({
|
||||
selectedCredentialType: (context: any, event: any) => {
|
||||
return event.credentialTypes[0];
|
||||
},
|
||||
supportedCredentialTypes: (context: any, event: any) => {
|
||||
return event.credentialTypes;
|
||||
},
|
||||
accessToken: (context: any, event: any) => {
|
||||
return event.accessToken;
|
||||
},
|
||||
cNonce: (context: any, event: any) => {
|
||||
return event.cNonce;
|
||||
setCredentialConfigurationId: model.assign({
|
||||
credentialConfigurationId: (_: any, event: any) => {
|
||||
return event.data.credentialConfigurationId;
|
||||
},
|
||||
}),
|
||||
setCredentialOfferCredentialType: model.assign({
|
||||
selectedCredentialType: (context: any, event: any) => {
|
||||
let credentialTypes: Array<{id: string; [key: string]: any}> = [];
|
||||
const credentialConfigurationId = context.credentialConfigurationId;
|
||||
const issuerMetadata = context.selectedIssuerWellknownResponse;
|
||||
if (
|
||||
issuerMetadata.credential_configurations_supported[
|
||||
credentialConfigurationId
|
||||
]
|
||||
) {
|
||||
credentialTypes.push({
|
||||
id: credentialConfigurationId,
|
||||
...issuerMetadata.credential_configurations_supported[
|
||||
credentialConfigurationId
|
||||
],
|
||||
});
|
||||
return credentialTypes[0];
|
||||
}
|
||||
},
|
||||
}),
|
||||
supportedCredentialTypes: (context: any, event: any) => {
|
||||
return event.credentialTypes;
|
||||
},
|
||||
accessToken: (context: any, event: any) => {
|
||||
return event.accessToken;
|
||||
},
|
||||
cNonce: (context: any, event: any) => {
|
||||
return event.cNonce;
|
||||
},
|
||||
|
||||
setRequestTxCode: model.assign({
|
||||
isTransactionCodeRequested: (_: any, event: any) => {
|
||||
return true;
|
||||
@@ -295,22 +306,32 @@ export const IssuersActions = (model: any) => {
|
||||
},
|
||||
}),
|
||||
setCredentialOfferIssuerWellknownResponse: model.assign({
|
||||
selectedIssuerWellknownResponse: (_: any, event: any) => {
|
||||
return event.issuerMetadata;
|
||||
selectedIssuer: (_: any, event: any) => {
|
||||
return event.data;
|
||||
},
|
||||
wellknownKeyTypes: (_: any, event: any) => {
|
||||
const credType = Object.entries(event.credentialTypes)[0][1];
|
||||
const proofTypesSupported = credType.proof_types_supported;
|
||||
if (proofTypesSupported?.jwt) {
|
||||
return proofTypesSupported.jwt
|
||||
.proof_signing_alg_values_supported as string[];
|
||||
} else {
|
||||
return [KeyTypes.RS256] as string[];
|
||||
}
|
||||
selectedIssuerWellknownResponse: (_: any, event: any) => {
|
||||
return event.data;
|
||||
},
|
||||
}),
|
||||
updateSelectedIssuerWellknownResponse: model.assign({
|
||||
selectedIssuerWellknownResponse: (_: any, event: any) => event.data,
|
||||
setWellknwonKeyTypes: model.assign({
|
||||
wellknownKeyTypes: (_: any, event: any) => {
|
||||
return event.proofSigningAlgosSupported;
|
||||
},
|
||||
}),
|
||||
setSelectedCredentialIssuer: model.assign({
|
||||
credentialOfferCredentialIssuer: (_: any, event: any) => {
|
||||
return event.issuer;
|
||||
},
|
||||
}),
|
||||
setTokenRequestObject: model.assign({
|
||||
tokenRequestObject: (_: any, event: any) => {
|
||||
return parseJSON(event.tokenRequest);
|
||||
},
|
||||
}),
|
||||
setTokenResponseObject: model.assign({
|
||||
tokenResponse: (_: any, event: any) => {
|
||||
return event.data;
|
||||
},
|
||||
}),
|
||||
setSelectedIssuerId: model.assign({
|
||||
selectedIssuerId: (_: any, event: any) => event.id,
|
||||
@@ -330,22 +351,17 @@ export const IssuersActions = (model: any) => {
|
||||
txCodeDescription: (_: any, event: any) => event.description,
|
||||
txCodeLength: (_: any, event: any) => event.length,
|
||||
}),
|
||||
setCredentialOfferIssuerMetadata: model.assign({
|
||||
credentialOfferIssuerMetadata: (_: any, event: any) => {
|
||||
return event.issuerMetadata;
|
||||
},
|
||||
}),
|
||||
setIssuerDisplayDetails: model.assign({
|
||||
issuerLogo: (context: any, _: any) => {
|
||||
const displayArray = context.credentialOfferIssuerMetadata?.display;
|
||||
issuerLogo: (_: any, event: any) => {
|
||||
const displayArray = event.issuerDisplay;
|
||||
const display = displayArray
|
||||
? getDisplayObjectForCurrentLanguage(displayArray)
|
||||
: undefined;
|
||||
|
||||
return display?.logo?.url ?? '';
|
||||
},
|
||||
issuerName: (context: any, _: any) => {
|
||||
const displayArray = context.credentialOfferIssuerMetadata?.display;
|
||||
issuerName: (_: any, event: any) => {
|
||||
const displayArray = event.issuerDisplay;
|
||||
const display = displayArray
|
||||
? getDisplayObjectForCurrentLanguage(displayArray)
|
||||
: undefined;
|
||||
@@ -353,13 +369,13 @@ export const IssuersActions = (model: any) => {
|
||||
},
|
||||
}),
|
||||
|
||||
setFlowType: model.assign({
|
||||
setCredentialOfferFlowType: model.assign({
|
||||
isCredentialOfferFlow: (_: any, event: any) => {
|
||||
return true;
|
||||
},
|
||||
}),
|
||||
|
||||
resetFlowType: model.assign({
|
||||
resetCredentialOfferFlowType: model.assign({
|
||||
isCredentialOfferFlow: (_: any, event: any) => {
|
||||
return false;
|
||||
},
|
||||
@@ -402,7 +418,9 @@ export const IssuersActions = (model: any) => {
|
||||
type: 'VC_DOWNLOADED',
|
||||
timestamp: Date.now(),
|
||||
deviceName: '',
|
||||
issuer: context.selectedIssuerId,
|
||||
issuer:
|
||||
context.selectedIssuer.credential_issuer_host ??
|
||||
context.credentialOfferCredentialIssuer,
|
||||
credentialConfigurationId: context.selectedCredentialType.id,
|
||||
}),
|
||||
context.selectedIssuerWellknownResponse,
|
||||
@@ -441,8 +459,9 @@ export const IssuersActions = (model: any) => {
|
||||
},
|
||||
|
||||
updateVerificationErrorMessage: assign({
|
||||
verificationErrorMessage: (_, event: any) =>
|
||||
(event.data as Error).message,
|
||||
verificationErrorMessage: (_, event: any) => {
|
||||
return (event.data as Error).message;
|
||||
},
|
||||
}),
|
||||
|
||||
resetVerificationErrorMessage: model.assign({
|
||||
|
||||
@@ -33,5 +33,6 @@ export const IssuersEvents = {
|
||||
TX_CODE_REQUEST: () => ({}),
|
||||
TX_CODE_RECEIVED: (txCode: string) => ({txCode}),
|
||||
ON_CONSENT_GIVEN: () => ({}),
|
||||
TRUST_ISSUER_CONSENT_REQUEST: (issuerMetadata: object) => ({issuerMetadata})
|
||||
TRUST_ISSUER_CONSENT_REQUEST: (issuerMetadata: object) => ({issuerMetadata}),
|
||||
TOKEN_REQUEST: (tokenRequest: object) => ({tokenRequest}),
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {isSignedInResult} from '../../shared/CloudBackupAndRestoreUtils';
|
||||
import {ErrorMessage, OIDCErrors} from '../../shared/openId4VCI/Utils';
|
||||
import {isHardwareKeystoreExists} from '../../shared/cryptoutil/cryptoUtil';
|
||||
import {BiometricCancellationError} from '../../shared/error/BiometricCancellationError';
|
||||
import {VerificationErrorType} from '../../shared/vcjs/verifyCredential';
|
||||
|
||||
@@ -17,32 +16,6 @@ export const IssuersGuards = () => {
|
||||
return context.keyType == '';
|
||||
},
|
||||
isInternetConnected: (_: any, event: any) => !!event.data.isConnected,
|
||||
isOIDCflowCancelled: (_: any, event: any) => {
|
||||
// iOS & Android have different error strings for user cancelled flow
|
||||
const err = [
|
||||
OIDCErrors.OIDC_FLOW_CANCELLED_ANDROID,
|
||||
OIDCErrors.OIDC_FLOW_CANCELLED_IOS,
|
||||
];
|
||||
return (
|
||||
!!event.data &&
|
||||
typeof event.data.toString === 'function' &&
|
||||
err.some(e => event.data.toString().includes(e))
|
||||
);
|
||||
},
|
||||
isOIDCConfigError: (_: any, event: any) => {
|
||||
return (
|
||||
!!event.data &&
|
||||
typeof event.data.toString === 'function' &&
|
||||
event.data.toString().includes(OIDCErrors.OIDC_CONFIG_ERROR_PREFIX)
|
||||
);
|
||||
},
|
||||
isGrantTypeNotSupportedError: (_: any, event: any) => {
|
||||
return (
|
||||
!!event.data &&
|
||||
event.data.toString() ===
|
||||
OIDCErrors.AUTHORIZATION_ENDPOINT_DISCOVERY.GRANT_TYPE_NOT_SUPPORTED
|
||||
);
|
||||
},
|
||||
canSelectIssuerAgain: (context: any) => {
|
||||
return (
|
||||
context.errorMessage.includes(OIDCErrors.OIDC_CONFIG_ERROR_PREFIX) ||
|
||||
@@ -50,18 +23,13 @@ export const IssuersGuards = () => {
|
||||
);
|
||||
},
|
||||
shouldFetchIssuersAgain: (context: any) => context.issuers.length === 0,
|
||||
isCustomSecureKeystore: () => isHardwareKeystoreExists,
|
||||
hasUserCancelledBiometric: (_: any, event: any) =>
|
||||
event.data instanceof BiometricCancellationError,
|
||||
isGenericError: (_: any, event: any) => {
|
||||
const errorMessage = event.data.message;
|
||||
return errorMessage === ErrorMessage.GENERIC;
|
||||
},
|
||||
isCredentialOfferFlow: (context: any) => {
|
||||
return context.isCredentialOfferFlow;
|
||||
},
|
||||
isIssuerIdInTrustedIssuers: (_: any,event:any) => {
|
||||
isIssuerIdInTrustedIssuers: (_: any, event: any) => {
|
||||
return event.data;
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,556 +0,0 @@
|
||||
// This file was automatically generated. Edits will be overwritten
|
||||
|
||||
export interface Typegen0 {
|
||||
'@@xstate/typegen': true;
|
||||
internalEvents: {
|
||||
'done.invoke.issuersMachine.credentialDownloadFromOffer.checkingIssuerTrust:invocation[0]': {
|
||||
type: 'done.invoke.issuersMachine.credentialDownloadFromOffer.checkingIssuerTrust:invocation[0]';
|
||||
data: unknown;
|
||||
__tip: 'See the XState TS docs to learn how to strongly type this.';
|
||||
};
|
||||
'done.invoke.issuersMachine.credentialDownloadFromOffer.keyManagement.generateKeyPair:invocation[0]': {
|
||||
type: 'done.invoke.issuersMachine.credentialDownloadFromOffer.keyManagement.generateKeyPair:invocation[0]';
|
||||
data: unknown;
|
||||
__tip: 'See the XState TS docs to learn how to strongly type this.';
|
||||
};
|
||||
'done.invoke.issuersMachine.credentialDownloadFromOffer.keyManagement.getKeyPairFromKeystore:invocation[0]': {
|
||||
type: 'done.invoke.issuersMachine.credentialDownloadFromOffer.keyManagement.getKeyPairFromKeystore:invocation[0]';
|
||||
data: unknown;
|
||||
__tip: 'See the XState TS docs to learn how to strongly type this.';
|
||||
};
|
||||
'done.invoke.issuersMachine.credentialDownloadFromOffer.keyManagement.setSelectedKey:invocation[0]': {
|
||||
type: 'done.invoke.issuersMachine.credentialDownloadFromOffer.keyManagement.setSelectedKey:invocation[0]';
|
||||
data: unknown;
|
||||
__tip: 'See the XState TS docs to learn how to strongly type this.';
|
||||
};
|
||||
'done.invoke.issuersMachine.credentialDownloadFromOffer.sendConsentGiven.updatingTrustedIssuerList:invocation[0]': {
|
||||
type: 'done.invoke.issuersMachine.credentialDownloadFromOffer.sendConsentGiven.updatingTrustedIssuerList:invocation[0]';
|
||||
data: unknown;
|
||||
__tip: 'See the XState TS docs to learn how to strongly type this.';
|
||||
};
|
||||
'done.invoke.issuersMachine.credentialDownloadFromOffer.sendConsentGiven:invocation[0]': {
|
||||
type: 'done.invoke.issuersMachine.credentialDownloadFromOffer.sendConsentGiven:invocation[0]';
|
||||
data: unknown;
|
||||
__tip: 'See the XState TS docs to learn how to strongly type this.';
|
||||
};
|
||||
'done.invoke.issuersMachine.credentialDownloadFromOffer:invocation[0]': {
|
||||
type: 'done.invoke.issuersMachine.credentialDownloadFromOffer:invocation[0]';
|
||||
data: unknown;
|
||||
__tip: 'See the XState TS docs to learn how to strongly type this.';
|
||||
};
|
||||
'done.invoke.issuersMachine.displayIssuers:invocation[0]': {
|
||||
type: 'done.invoke.issuersMachine.displayIssuers:invocation[0]';
|
||||
data: unknown;
|
||||
__tip: 'See the XState TS docs to learn how to strongly type this.';
|
||||
};
|
||||
'done.invoke.issuersMachine.downloadCredentials.keyManagement.generateKeyPair:invocation[0]': {
|
||||
type: 'done.invoke.issuersMachine.downloadCredentials.keyManagement.generateKeyPair:invocation[0]';
|
||||
data: unknown;
|
||||
__tip: 'See the XState TS docs to learn how to strongly type this.';
|
||||
};
|
||||
'done.invoke.issuersMachine.downloadCredentials.keyManagement.getKeyPairFromKeystore:invocation[0]': {
|
||||
type: 'done.invoke.issuersMachine.downloadCredentials.keyManagement.getKeyPairFromKeystore:invocation[0]';
|
||||
data: unknown;
|
||||
__tip: 'See the XState TS docs to learn how to strongly type this.';
|
||||
};
|
||||
'done.invoke.issuersMachine.downloadCredentials.keyManagement.setSelectedKey:invocation[0]': {
|
||||
type: 'done.invoke.issuersMachine.downloadCredentials.keyManagement.setSelectedKey:invocation[0]';
|
||||
data: unknown;
|
||||
__tip: 'See the XState TS docs to learn how to strongly type this.';
|
||||
};
|
||||
'done.invoke.issuersMachine.downloadCredentials:invocation[0]': {
|
||||
type: 'done.invoke.issuersMachine.downloadCredentials:invocation[0]';
|
||||
data: unknown;
|
||||
__tip: 'See the XState TS docs to learn how to strongly type this.';
|
||||
};
|
||||
'done.invoke.issuersMachine.downloadIssuerWellknown:invocation[0]': {
|
||||
type: 'done.invoke.issuersMachine.downloadIssuerWellknown:invocation[0]';
|
||||
data: unknown;
|
||||
__tip: 'See the XState TS docs to learn how to strongly type this.';
|
||||
};
|
||||
'done.invoke.issuersMachine.getCredentialTypes:invocation[0]': {
|
||||
type: 'done.invoke.issuersMachine.getCredentialTypes:invocation[0]';
|
||||
data: unknown;
|
||||
__tip: 'See the XState TS docs to learn how to strongly type this.';
|
||||
};
|
||||
'done.invoke.issuersMachine.proccessingCredential:invocation[0]': {
|
||||
type: 'done.invoke.issuersMachine.proccessingCredential:invocation[0]';
|
||||
data: unknown;
|
||||
__tip: 'See the XState TS docs to learn how to strongly type this.';
|
||||
};
|
||||
'done.invoke.issuersMachine.storing:invocation[0]': {
|
||||
type: 'done.invoke.issuersMachine.storing:invocation[0]';
|
||||
data: unknown;
|
||||
__tip: 'See the XState TS docs to learn how to strongly type this.';
|
||||
};
|
||||
'done.invoke.issuersMachine.verifyingCredential:invocation[0]': {
|
||||
type: 'done.invoke.issuersMachine.verifyingCredential:invocation[0]';
|
||||
data: unknown;
|
||||
__tip: 'See the XState TS docs to learn how to strongly type this.';
|
||||
};
|
||||
'error.platform.issuersMachine.credentialDownloadFromOffer.keyManagement.constructProof:invocation[0]': {
|
||||
type: 'error.platform.issuersMachine.credentialDownloadFromOffer.keyManagement.constructProof:invocation[0]';
|
||||
data: unknown;
|
||||
};
|
||||
'error.platform.issuersMachine.credentialDownloadFromOffer.keyManagement.getKeyPairFromKeystore:invocation[0]': {
|
||||
type: 'error.platform.issuersMachine.credentialDownloadFromOffer.keyManagement.getKeyPairFromKeystore:invocation[0]';
|
||||
data: unknown;
|
||||
};
|
||||
'error.platform.issuersMachine.credentialDownloadFromOffer.keyManagement.setSelectedKey:invocation[0]': {
|
||||
type: 'error.platform.issuersMachine.credentialDownloadFromOffer.keyManagement.setSelectedKey:invocation[0]';
|
||||
data: unknown;
|
||||
};
|
||||
'error.platform.issuersMachine.credentialDownloadFromOffer.sendConsentGiven:invocation[0]': {
|
||||
type: 'error.platform.issuersMachine.credentialDownloadFromOffer.sendConsentGiven:invocation[0]';
|
||||
data: unknown;
|
||||
};
|
||||
'error.platform.issuersMachine.credentialDownloadFromOffer.sendTxCode:invocation[0]': {
|
||||
type: 'error.platform.issuersMachine.credentialDownloadFromOffer.sendTxCode:invocation[0]';
|
||||
data: unknown;
|
||||
};
|
||||
'error.platform.issuersMachine.credentialDownloadFromOffer:invocation[0]': {
|
||||
type: 'error.platform.issuersMachine.credentialDownloadFromOffer:invocation[0]';
|
||||
data: unknown;
|
||||
};
|
||||
'error.platform.issuersMachine.displayIssuers:invocation[0]': {
|
||||
type: 'error.platform.issuersMachine.displayIssuers:invocation[0]';
|
||||
data: unknown;
|
||||
};
|
||||
'error.platform.issuersMachine.downloadCredentials.constructProof:invocation[0]': {
|
||||
type: 'error.platform.issuersMachine.downloadCredentials.constructProof:invocation[0]';
|
||||
data: unknown;
|
||||
};
|
||||
'error.platform.issuersMachine.downloadCredentials.keyManagement.getKeyPairFromKeystore:invocation[0]': {
|
||||
type: 'error.platform.issuersMachine.downloadCredentials.keyManagement.getKeyPairFromKeystore:invocation[0]';
|
||||
data: unknown;
|
||||
};
|
||||
'error.platform.issuersMachine.downloadCredentials.keyManagement.setSelectedKey:invocation[0]': {
|
||||
type: 'error.platform.issuersMachine.downloadCredentials.keyManagement.setSelectedKey:invocation[0]';
|
||||
data: unknown;
|
||||
};
|
||||
'error.platform.issuersMachine.downloadCredentials:invocation[0]': {
|
||||
type: 'error.platform.issuersMachine.downloadCredentials:invocation[0]';
|
||||
data: unknown;
|
||||
};
|
||||
'error.platform.issuersMachine.downloadIssuerWellknown:invocation[0]': {
|
||||
type: 'error.platform.issuersMachine.downloadIssuerWellknown:invocation[0]';
|
||||
data: unknown;
|
||||
};
|
||||
'error.platform.issuersMachine.getCredentialTypes:invocation[0]': {
|
||||
type: 'error.platform.issuersMachine.getCredentialTypes:invocation[0]';
|
||||
data: unknown;
|
||||
};
|
||||
'error.platform.issuersMachine.verifyingCredential:invocation[0]': {
|
||||
type: 'error.platform.issuersMachine.verifyingCredential:invocation[0]';
|
||||
data: unknown;
|
||||
};
|
||||
'xstate.init': {type: 'xstate.init'};
|
||||
};
|
||||
invokeSrcNameMap: {
|
||||
addIssuerToTrustedIssuers: 'done.invoke.issuersMachine.credentialDownloadFromOffer.sendConsentGiven.addingIssuerToTrustedIssuers:invocation[0]';
|
||||
checkIssuerIdInStoredTrustedIssuers:
|
||||
| 'done.invoke.issuersMachine.credentialDownloadFromOffer.checkingIssuerTrust:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.credentialDownloadFromOffer.sendConsentGiven.updatingTrustedIssuerList:invocation[0]';
|
||||
constructProof: 'done.invoke.issuersMachine.credentialDownloadFromOffer.keyManagement.constructProof:invocation[0]';
|
||||
constructProofForTrustedIssuers: 'done.invoke.issuersMachine.downloadCredentials.constructProof:invocation[0]';
|
||||
downloadCredential: 'done.invoke.issuersMachine.downloadCredentials:invocation[0]';
|
||||
downloadCredentialFromOffer: 'done.invoke.issuersMachine.credentialDownloadFromOffer:invocation[0]';
|
||||
downloadIssuerWellknown: 'done.invoke.issuersMachine.downloadIssuerWellknown:invocation[0]';
|
||||
downloadIssuersList: 'done.invoke.issuersMachine.displayIssuers:invocation[0]';
|
||||
generateKeyPair:
|
||||
| 'done.invoke.issuersMachine.credentialDownloadFromOffer.keyManagement.generateKeyPair:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.downloadCredentials.keyManagement.generateKeyPair:invocation[0]';
|
||||
getCredentialTypes: 'done.invoke.issuersMachine.getCredentialTypes:invocation[0]';
|
||||
getKeyOrderList:
|
||||
| 'done.invoke.issuersMachine.credentialDownloadFromOffer.keyManagement.setSelectedKey:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.downloadCredentials.keyManagement.setSelectedKey:invocation[0]';
|
||||
getKeyPair:
|
||||
| 'done.invoke.issuersMachine.credentialDownloadFromOffer.keyManagement.getKeyPairFromKeystore:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.downloadCredentials.keyManagement.getKeyPairFromKeystore:invocation[0]';
|
||||
isUserSignedAlready: 'done.invoke.issuersMachine.storing:invocation[0]';
|
||||
sendConsentGiven: 'done.invoke.issuersMachine.credentialDownloadFromOffer.sendConsentGiven:invocation[0]';
|
||||
sendConsentNotGiven: 'done.invoke.issuersMachine.credentialDownloadFromOffer.sendConsentNotGiven:invocation[0]';
|
||||
sendTxCode: 'done.invoke.issuersMachine.credentialDownloadFromOffer.sendTxCode:invocation[0]';
|
||||
updateCredential: 'done.invoke.issuersMachine.proccessingCredential:invocation[0]';
|
||||
verifyCredential: 'done.invoke.issuersMachine.verifyingCredential:invocation[0]';
|
||||
};
|
||||
missingImplementations: {
|
||||
actions:
|
||||
| 'downloadIssuerWellknown'
|
||||
| 'loadKeyPair'
|
||||
| 'logDownloaded'
|
||||
| 'resetCredentialOfferIssuer'
|
||||
| 'resetError'
|
||||
| 'resetLoadingReason'
|
||||
| 'resetQrData'
|
||||
| 'resetRequestConsentToTrustIssuer'
|
||||
| 'resetRequestTxCode'
|
||||
| 'resetSelectedCredentialType'
|
||||
| 'resetVerificationErrorMessage'
|
||||
| 'resetVerificationResult'
|
||||
| 'sendBackupEvent'
|
||||
| 'sendDownloadingFailedToVcMeta'
|
||||
| 'sendErrorEndEvent'
|
||||
| 'sendImpressionEvent'
|
||||
| 'sendSuccessEndEvent'
|
||||
| 'setAccessToken'
|
||||
| 'setCNonce'
|
||||
| 'setCredential'
|
||||
| 'setCredentialOfferIssuer'
|
||||
| 'setCredentialOfferIssuerMetadata'
|
||||
| 'setCredentialOfferIssuerWellknownResponse'
|
||||
| 'setCredentialTypeListDownloadFailureError'
|
||||
| 'setCredentialWrapper'
|
||||
| 'setError'
|
||||
| 'setIssuerDisplayDetails'
|
||||
| 'setIssuers'
|
||||
| 'setLoadingReasonAsDisplayIssuers'
|
||||
| 'setLoadingReasonAsDownloadingCredentials'
|
||||
| 'setLoadingReasonAsSettingUp'
|
||||
| 'setMetadataInCredentialData'
|
||||
| 'setNetworkOrTechnicalError'
|
||||
| 'setOfferCredentialTypeContexts'
|
||||
| 'setPrivateKey'
|
||||
| 'setPublicKey'
|
||||
| 'setQrData'
|
||||
| 'setRequestConsentToTrustIssuer'
|
||||
| 'setRequestTxCode'
|
||||
| 'setSelectedCredentialType'
|
||||
| 'setSelectedIssuerId'
|
||||
| 'setSelectedIssuers'
|
||||
| 'setSelectedKey'
|
||||
| 'setSupportedCredentialTypes'
|
||||
| 'setTxCode'
|
||||
| 'setTxCodeDisplayDetails'
|
||||
| 'setVCMetadata'
|
||||
| 'setVerifiableCredential'
|
||||
| 'setVerificationResult'
|
||||
| 'storeKeyPair'
|
||||
| 'storeVcMetaContext'
|
||||
| 'storeVcsContext'
|
||||
| 'storeVerifiableCredentialData'
|
||||
| 'storeVerifiableCredentialMeta'
|
||||
| 'updateIssuerFromWellknown'
|
||||
| 'updateSelectedIssuerWellknownResponse'
|
||||
| 'updateVerificationErrorMessage';
|
||||
delays: never;
|
||||
guards:
|
||||
| 'canSelectIssuerAgain'
|
||||
| 'hasUserCancelledBiometric'
|
||||
| 'isCredentialOfferFlow'
|
||||
| 'isGenericError'
|
||||
| 'isIssuerIdInTrustedIssuers'
|
||||
| 'isKeyTypeNotFound'
|
||||
| 'isSignedIn'
|
||||
| 'isVerificationPendingBecauseOfNetworkIssue'
|
||||
| 'shouldFetchIssuersAgain';
|
||||
services:
|
||||
| 'addIssuerToTrustedIssuers'
|
||||
| 'checkIssuerIdInStoredTrustedIssuers'
|
||||
| 'constructProof'
|
||||
| 'constructProofForTrustedIssuers'
|
||||
| 'downloadCredential'
|
||||
| 'downloadCredentialFromOffer'
|
||||
| 'downloadIssuerWellknown'
|
||||
| 'downloadIssuersList'
|
||||
| 'generateKeyPair'
|
||||
| 'getCredentialTypes'
|
||||
| 'getKeyOrderList'
|
||||
| 'getKeyPair'
|
||||
| 'isUserSignedAlready'
|
||||
| 'sendConsentGiven'
|
||||
| 'sendConsentNotGiven'
|
||||
| 'sendTxCode'
|
||||
| 'updateCredential'
|
||||
| 'verifyCredential';
|
||||
};
|
||||
eventsCausingActions: {
|
||||
downloadIssuerWellknown: 'TRY_AGAIN';
|
||||
loadKeyPair:
|
||||
| 'done.invoke.issuersMachine.credentialDownloadFromOffer.keyManagement.getKeyPairFromKeystore:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.downloadCredentials.keyManagement.getKeyPairFromKeystore:invocation[0]';
|
||||
logDownloaded:
|
||||
| 'done.invoke.issuersMachine.proccessingCredential:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.verifyingCredential:invocation[0]'
|
||||
| 'error.platform.issuersMachine.verifyingCredential:invocation[0]';
|
||||
resetCredentialOfferIssuer:
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer.sendConsentGiven:invocation[0]'
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer.sendTxCode:invocation[0]';
|
||||
resetError: 'RESET_ERROR' | 'TRY_AGAIN';
|
||||
resetLoadingReason:
|
||||
| 'CANCEL'
|
||||
| 'RESET_ERROR'
|
||||
| 'done.invoke.issuersMachine.displayIssuers:invocation[0]'
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer.keyManagement.constructProof:invocation[0]'
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer.keyManagement.getKeyPairFromKeystore:invocation[0]'
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer.keyManagement.setSelectedKey:invocation[0]'
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer.sendConsentGiven:invocation[0]'
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer.sendTxCode:invocation[0]'
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer:invocation[0]'
|
||||
| 'error.platform.issuersMachine.downloadCredentials.constructProof:invocation[0]'
|
||||
| 'error.platform.issuersMachine.downloadCredentials.keyManagement.getKeyPairFromKeystore:invocation[0]'
|
||||
| 'error.platform.issuersMachine.downloadCredentials.keyManagement.setSelectedKey:invocation[0]'
|
||||
| 'error.platform.issuersMachine.downloadCredentials:invocation[0]'
|
||||
| 'error.platform.issuersMachine.downloadIssuerWellknown:invocation[0]'
|
||||
| 'error.platform.issuersMachine.getCredentialTypes:invocation[0]'
|
||||
| 'error.platform.issuersMachine.verifyingCredential:invocation[0]';
|
||||
resetQrData:
|
||||
| 'CANCEL'
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer.sendConsentGiven:invocation[0]'
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer.sendTxCode:invocation[0]';
|
||||
resetRequestConsentToTrustIssuer:
|
||||
| 'CANCEL'
|
||||
| 'ON_CONSENT_GIVEN'
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer.sendConsentGiven:invocation[0]';
|
||||
resetRequestTxCode:
|
||||
| 'CANCEL'
|
||||
| 'TX_CODE_RECEIVED'
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer.sendTxCode:invocation[0]';
|
||||
resetSelectedCredentialType:
|
||||
| 'CANCEL'
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer.keyManagement.constructProof:invocation[0]'
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer.keyManagement.getKeyPairFromKeystore:invocation[0]'
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer.keyManagement.setSelectedKey:invocation[0]'
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer:invocation[0]'
|
||||
| 'error.platform.issuersMachine.downloadCredentials.constructProof:invocation[0]'
|
||||
| 'error.platform.issuersMachine.downloadCredentials.keyManagement.getKeyPairFromKeystore:invocation[0]'
|
||||
| 'error.platform.issuersMachine.downloadCredentials.keyManagement.setSelectedKey:invocation[0]'
|
||||
| 'error.platform.issuersMachine.downloadCredentials:invocation[0]';
|
||||
resetVerificationErrorMessage: 'RESET_VERIFY_ERROR';
|
||||
resetVerificationResult: 'error.platform.issuersMachine.verifyingCredential:invocation[0]';
|
||||
sendBackupEvent: 'done.invoke.issuersMachine.storing:invocation[0]';
|
||||
sendDownloadingFailedToVcMeta:
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer.keyManagement.constructProof:invocation[0]'
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer.keyManagement.getKeyPairFromKeystore:invocation[0]'
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer.keyManagement.setSelectedKey:invocation[0]'
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer:invocation[0]'
|
||||
| 'error.platform.issuersMachine.downloadCredentials.constructProof:invocation[0]'
|
||||
| 'error.platform.issuersMachine.downloadCredentials.keyManagement.getKeyPairFromKeystore:invocation[0]'
|
||||
| 'error.platform.issuersMachine.downloadCredentials.keyManagement.setSelectedKey:invocation[0]'
|
||||
| 'error.platform.issuersMachine.downloadCredentials:invocation[0]';
|
||||
sendErrorEndEvent: 'error.platform.issuersMachine.verifyingCredential:invocation[0]';
|
||||
sendImpressionEvent: 'done.invoke.issuersMachine.displayIssuers:invocation[0]';
|
||||
sendSuccessEndEvent:
|
||||
| 'done.invoke.issuersMachine.proccessingCredential:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.verifyingCredential:invocation[0]';
|
||||
setAccessToken: 'PROOF_REQUEST';
|
||||
setCNonce: 'PROOF_REQUEST';
|
||||
setCredential: 'done.invoke.issuersMachine.credentialDownloadFromOffer:invocation[0]';
|
||||
setCredentialOfferIssuer: 'PROOF_REQUEST';
|
||||
setCredentialOfferIssuerMetadata: 'TRUST_ISSUER_CONSENT_REQUEST';
|
||||
setCredentialOfferIssuerWellknownResponse: 'PROOF_REQUEST';
|
||||
setCredentialTypeListDownloadFailureError: 'error.platform.issuersMachine.getCredentialTypes:invocation[0]';
|
||||
setCredentialWrapper:
|
||||
| 'done.invoke.issuersMachine.downloadCredentials:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.proccessingCredential:invocation[0]';
|
||||
setError:
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer.keyManagement.constructProof:invocation[0]'
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer.keyManagement.getKeyPairFromKeystore:invocation[0]'
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer.keyManagement.setSelectedKey:invocation[0]'
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer:invocation[0]'
|
||||
| 'error.platform.issuersMachine.displayIssuers:invocation[0]'
|
||||
| 'error.platform.issuersMachine.downloadCredentials.constructProof:invocation[0]'
|
||||
| 'error.platform.issuersMachine.downloadCredentials.keyManagement.getKeyPairFromKeystore:invocation[0]'
|
||||
| 'error.platform.issuersMachine.downloadCredentials.keyManagement.setSelectedKey:invocation[0]'
|
||||
| 'error.platform.issuersMachine.downloadCredentials:invocation[0]';
|
||||
setIssuerDisplayDetails: 'done.invoke.issuersMachine.credentialDownloadFromOffer.checkingIssuerTrust:invocation[0]';
|
||||
setIssuers: 'done.invoke.issuersMachine.displayIssuers:invocation[0]';
|
||||
setLoadingReasonAsDisplayIssuers: 'TRY_AGAIN';
|
||||
setLoadingReasonAsDownloadingCredentials:
|
||||
| 'ON_CONSENT_GIVEN'
|
||||
| 'QR_CODE_SCANNED'
|
||||
| 'SELECTED_CREDENTIAL_TYPE'
|
||||
| 'TRY_AGAIN'
|
||||
| 'done.invoke.issuersMachine.credentialDownloadFromOffer.keyManagement.generateKeyPair:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.downloadCredentials.keyManagement.generateKeyPair:invocation[0]';
|
||||
setLoadingReasonAsSettingUp: 'SELECTED_ISSUER' | 'TRY_AGAIN';
|
||||
setMetadataInCredentialData:
|
||||
| 'done.invoke.issuersMachine.proccessingCredential:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.verifyingCredential:invocation[0]'
|
||||
| 'error.platform.issuersMachine.verifyingCredential:invocation[0]';
|
||||
setNetworkOrTechnicalError: 'error.platform.issuersMachine.downloadIssuerWellknown:invocation[0]';
|
||||
setOfferCredentialTypeContexts: 'PROOF_REQUEST';
|
||||
setPrivateKey:
|
||||
| 'done.invoke.issuersMachine.credentialDownloadFromOffer.keyManagement.generateKeyPair:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.downloadCredentials.keyManagement.generateKeyPair:invocation[0]';
|
||||
setPublicKey:
|
||||
| 'done.invoke.issuersMachine.credentialDownloadFromOffer.keyManagement.generateKeyPair:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.downloadCredentials.keyManagement.generateKeyPair:invocation[0]';
|
||||
setQrData: 'ON_CONSENT_GIVEN' | 'QR_CODE_SCANNED';
|
||||
setRequestConsentToTrustIssuer: 'done.invoke.issuersMachine.credentialDownloadFromOffer.checkingIssuerTrust:invocation[0]';
|
||||
setRequestTxCode: 'TX_CODE_REQUEST';
|
||||
setSelectedCredentialType: 'SELECTED_CREDENTIAL_TYPE';
|
||||
setSelectedIssuerId: 'SELECTED_ISSUER';
|
||||
setSelectedIssuers: 'SELECTED_ISSUER';
|
||||
setSelectedKey:
|
||||
| 'done.invoke.issuersMachine.credentialDownloadFromOffer.keyManagement.setSelectedKey:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.downloadCredentials.keyManagement.setSelectedKey:invocation[0]';
|
||||
setSupportedCredentialTypes: 'done.invoke.issuersMachine.getCredentialTypes:invocation[0]';
|
||||
setTxCode: 'TX_CODE_RECEIVED';
|
||||
setTxCodeDisplayDetails: 'TX_CODE_REQUEST';
|
||||
setVCMetadata:
|
||||
| 'done.invoke.issuersMachine.proccessingCredential:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.verifyingCredential:invocation[0]'
|
||||
| 'error.platform.issuersMachine.verifyingCredential:invocation[0]';
|
||||
setVerifiableCredential:
|
||||
| 'done.invoke.issuersMachine.downloadCredentials:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.proccessingCredential:invocation[0]';
|
||||
setVerificationResult:
|
||||
| 'done.invoke.issuersMachine.proccessingCredential:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.verifyingCredential:invocation[0]';
|
||||
storeKeyPair:
|
||||
| 'done.invoke.issuersMachine.credentialDownloadFromOffer.keyManagement.generateKeyPair:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.downloadCredentials.keyManagement.generateKeyPair:invocation[0]';
|
||||
storeVcMetaContext:
|
||||
| 'done.invoke.issuersMachine.proccessingCredential:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.verifyingCredential:invocation[0]'
|
||||
| 'error.platform.issuersMachine.verifyingCredential:invocation[0]';
|
||||
storeVcsContext:
|
||||
| 'done.invoke.issuersMachine.proccessingCredential:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.verifyingCredential:invocation[0]'
|
||||
| 'error.platform.issuersMachine.verifyingCredential:invocation[0]';
|
||||
storeVerifiableCredentialData:
|
||||
| 'done.invoke.issuersMachine.proccessingCredential:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.verifyingCredential:invocation[0]'
|
||||
| 'error.platform.issuersMachine.verifyingCredential:invocation[0]';
|
||||
storeVerifiableCredentialMeta:
|
||||
| 'done.invoke.issuersMachine.proccessingCredential:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.verifyingCredential:invocation[0]'
|
||||
| 'error.platform.issuersMachine.verifyingCredential:invocation[0]';
|
||||
updateIssuerFromWellknown: 'done.invoke.issuersMachine.downloadIssuerWellknown:invocation[0]';
|
||||
updateSelectedIssuerWellknownResponse: 'done.invoke.issuersMachine.downloadIssuerWellknown:invocation[0]';
|
||||
updateVerificationErrorMessage: 'error.platform.issuersMachine.verifyingCredential:invocation[0]';
|
||||
};
|
||||
eventsCausingDelays: {};
|
||||
eventsCausingGuards: {
|
||||
canSelectIssuerAgain: 'TRY_AGAIN';
|
||||
hasUserCancelledBiometric:
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer.keyManagement.getKeyPairFromKeystore:invocation[0]'
|
||||
| 'error.platform.issuersMachine.downloadCredentials.constructProof:invocation[0]'
|
||||
| 'error.platform.issuersMachine.downloadCredentials.keyManagement.getKeyPairFromKeystore:invocation[0]'
|
||||
| 'error.platform.issuersMachine.downloadCredentials:invocation[0]';
|
||||
isCredentialOfferFlow: 'TRY_AGAIN';
|
||||
isGenericError:
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer:invocation[0]'
|
||||
| 'error.platform.issuersMachine.downloadCredentials:invocation[0]';
|
||||
isIssuerIdInTrustedIssuers:
|
||||
| 'done.invoke.issuersMachine.credentialDownloadFromOffer.checkingIssuerTrust:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.credentialDownloadFromOffer.sendConsentGiven.updatingTrustedIssuerList:invocation[0]';
|
||||
isKeyTypeNotFound:
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer.keyManagement.getKeyPairFromKeystore:invocation[0]'
|
||||
| 'error.platform.issuersMachine.downloadCredentials.keyManagement.getKeyPairFromKeystore:invocation[0]';
|
||||
isSignedIn: 'done.invoke.issuersMachine.storing:invocation[0]';
|
||||
isVerificationPendingBecauseOfNetworkIssue: 'error.platform.issuersMachine.verifyingCredential:invocation[0]';
|
||||
shouldFetchIssuersAgain: 'TRY_AGAIN';
|
||||
};
|
||||
eventsCausingServices: {
|
||||
addIssuerToTrustedIssuers: 'done.invoke.issuersMachine.credentialDownloadFromOffer.sendConsentGiven.updatingTrustedIssuerList:invocation[0]';
|
||||
checkIssuerIdInStoredTrustedIssuers:
|
||||
| 'TRUST_ISSUER_CONSENT_REQUEST'
|
||||
| 'done.invoke.issuersMachine.credentialDownloadFromOffer.sendConsentGiven:invocation[0]';
|
||||
constructProof:
|
||||
| 'done.invoke.issuersMachine.credentialDownloadFromOffer.keyManagement.generateKeyPair:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.credentialDownloadFromOffer.keyManagement.getKeyPairFromKeystore:invocation[0]';
|
||||
constructProofForTrustedIssuers:
|
||||
| 'TRY_AGAIN'
|
||||
| 'done.invoke.issuersMachine.downloadCredentials.keyManagement.getKeyPairFromKeystore:invocation[0]';
|
||||
downloadCredential: 'SELECTED_CREDENTIAL_TYPE';
|
||||
downloadCredentialFromOffer: 'QR_CODE_SCANNED';
|
||||
downloadIssuerWellknown: 'SELECTED_ISSUER' | 'TRY_AGAIN';
|
||||
downloadIssuersList: 'CANCEL' | 'TRY_AGAIN' | 'xstate.init';
|
||||
generateKeyPair:
|
||||
| 'error.platform.issuersMachine.credentialDownloadFromOffer.keyManagement.getKeyPairFromKeystore:invocation[0]'
|
||||
| 'error.platform.issuersMachine.downloadCredentials.keyManagement.getKeyPairFromKeystore:invocation[0]';
|
||||
getCredentialTypes: 'done.invoke.issuersMachine.downloadIssuerWellknown:invocation[0]';
|
||||
getKeyOrderList: 'PROOF_REQUEST';
|
||||
getKeyPair:
|
||||
| 'TRY_AGAIN'
|
||||
| 'done.invoke.issuersMachine.credentialDownloadFromOffer.keyManagement.setSelectedKey:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.downloadCredentials.keyManagement.setSelectedKey:invocation[0]';
|
||||
isUserSignedAlready:
|
||||
| 'done.invoke.issuersMachine.proccessingCredential:invocation[0]'
|
||||
| 'done.invoke.issuersMachine.verifyingCredential:invocation[0]'
|
||||
| 'error.platform.issuersMachine.verifyingCredential:invocation[0]';
|
||||
sendConsentGiven:
|
||||
| 'ON_CONSENT_GIVEN'
|
||||
| 'done.invoke.issuersMachine.credentialDownloadFromOffer.checkingIssuerTrust:invocation[0]';
|
||||
sendConsentNotGiven: 'CANCEL';
|
||||
sendTxCode: 'TX_CODE_RECEIVED';
|
||||
updateCredential: 'done.invoke.issuersMachine.credentialDownloadFromOffer:invocation[0]';
|
||||
verifyCredential: 'done.invoke.issuersMachine.downloadCredentials:invocation[0]';
|
||||
};
|
||||
matchesStates:
|
||||
| 'credentialDownloadFromOffer'
|
||||
| 'credentialDownloadFromOffer.checkingIssuerTrust'
|
||||
| 'credentialDownloadFromOffer.credentialOfferDownloadConsent'
|
||||
| 'credentialDownloadFromOffer.idle'
|
||||
| 'credentialDownloadFromOffer.keyManagement'
|
||||
| 'credentialDownloadFromOffer.keyManagement.constructProof'
|
||||
| 'credentialDownloadFromOffer.keyManagement.generateKeyPair'
|
||||
| 'credentialDownloadFromOffer.keyManagement.getKeyPairFromKeystore'
|
||||
| 'credentialDownloadFromOffer.keyManagement.setSelectedKey'
|
||||
| 'credentialDownloadFromOffer.keyManagement.userCancelledBiometric'
|
||||
| 'credentialDownloadFromOffer.sendConsentGiven'
|
||||
| 'credentialDownloadFromOffer.sendConsentGiven.addingIssuerToTrustedIssuers'
|
||||
| 'credentialDownloadFromOffer.sendConsentGiven.updatingTrustedIssuerList'
|
||||
| 'credentialDownloadFromOffer.sendConsentNotGiven'
|
||||
| 'credentialDownloadFromOffer.sendTxCode'
|
||||
| 'credentialDownloadFromOffer.waitingForTxCode'
|
||||
| 'displayIssuers'
|
||||
| 'done'
|
||||
| 'downloadCredentials'
|
||||
| 'downloadCredentials.constructProof'
|
||||
| 'downloadCredentials.idle'
|
||||
| 'downloadCredentials.keyManagement'
|
||||
| 'downloadCredentials.keyManagement.generateKeyPair'
|
||||
| 'downloadCredentials.keyManagement.getKeyPairFromKeystore'
|
||||
| 'downloadCredentials.keyManagement.setSelectedKey'
|
||||
| 'downloadCredentials.keyManagement.userCancelledBiometric'
|
||||
| 'downloadCredentials.userCancelledBiometric'
|
||||
| 'downloadIssuerWellknown'
|
||||
| 'error'
|
||||
| 'getCredentialTypes'
|
||||
| 'handleVCVerificationFailure'
|
||||
| 'idle'
|
||||
| 'proccessingCredential'
|
||||
| 'selectingCredentialType'
|
||||
| 'selectingIssuer'
|
||||
| 'storing'
|
||||
| 'verifyingCredential'
|
||||
| 'waitingForQrScan'
|
||||
| {
|
||||
credentialDownloadFromOffer?:
|
||||
| 'checkingIssuerTrust'
|
||||
| 'credentialOfferDownloadConsent'
|
||||
| 'idle'
|
||||
| 'keyManagement'
|
||||
| 'sendConsentGiven'
|
||||
| 'sendConsentNotGiven'
|
||||
| 'sendTxCode'
|
||||
| 'waitingForTxCode'
|
||||
| {
|
||||
keyManagement?:
|
||||
| 'constructProof'
|
||||
| 'generateKeyPair'
|
||||
| 'getKeyPairFromKeystore'
|
||||
| 'setSelectedKey'
|
||||
| 'userCancelledBiometric';
|
||||
sendConsentGiven?:
|
||||
| 'addingIssuerToTrustedIssuers'
|
||||
| 'updatingTrustedIssuerList';
|
||||
};
|
||||
downloadCredentials?:
|
||||
| 'constructProof'
|
||||
| 'idle'
|
||||
| 'keyManagement'
|
||||
| 'userCancelledBiometric'
|
||||
| {
|
||||
keyManagement?:
|
||||
| 'generateKeyPair'
|
||||
| 'getKeyPairFromKeystore'
|
||||
| 'setSelectedKey'
|
||||
| 'userCancelledBiometric';
|
||||
};
|
||||
};
|
||||
tags: never;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import {createModel} from 'xstate/lib/model';
|
||||
import {AuthorizeResult} from 'react-native-app-auth';
|
||||
import { createModel } from 'xstate/lib/model';
|
||||
import {
|
||||
CredentialTypes,
|
||||
CredentialWrapper,
|
||||
IssuerWellknownResponse,
|
||||
VerifiableCredential,
|
||||
} from '../VerifiableCredential/VCMetaMachine/vc';
|
||||
import {AppServices} from '../../shared/GlobalContext';
|
||||
import {VCMetadata} from '../../shared/VCMetadata';
|
||||
import {IssuersEvents} from './IssuersEvents';
|
||||
import {issuerType} from './IssuersMachine';
|
||||
import { AppServices } from '../../shared/GlobalContext';
|
||||
import { VCMetadata } from '../../shared/VCMetadata';
|
||||
import { IssuersEvents } from './IssuersEvents';
|
||||
import { issuerType } from './IssuersMachine';
|
||||
|
||||
export const IssuersModel = createModel(
|
||||
{
|
||||
@@ -18,7 +17,7 @@ export const IssuersModel = createModel(
|
||||
qrData: '' as string,
|
||||
selectedIssuer: {} as issuerType,
|
||||
selectedIssuerWellknownResponse: {} as IssuerWellknownResponse,
|
||||
tokenResponse: {} as AuthorizeResult,
|
||||
tokenResponse: {} as object,
|
||||
errorMessage: '' as string,
|
||||
loadingReason: 'displayIssuers' as string,
|
||||
verifiableCredential: null as VerifiableCredential | null,
|
||||
@@ -45,7 +44,9 @@ export const IssuersModel = createModel(
|
||||
txCodeDescription: '' as string,
|
||||
txCodeLength: null as number | null,
|
||||
isCredentialOfferFlow: false as boolean,
|
||||
credentialOfferIssuerMetadata: {} as object,
|
||||
credentialOfferCredentialIssuer: {} as string,
|
||||
tokenRequestObject: {} as object,
|
||||
credentialConfigurationId: '' as string,
|
||||
},
|
||||
{
|
||||
events: IssuersEvents,
|
||||
|
||||
@@ -104,7 +104,3 @@ export function selectSupportedCredentialTypes(state: State) {
|
||||
export function selectIsQrScanning(state: State) {
|
||||
return state.matches('waitingForQrScan');
|
||||
}
|
||||
|
||||
export function selectCredentialOfferData(state: State) {
|
||||
return state.context.credentialOfferData;
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
import NetInfo from '@react-native-community/netinfo';
|
||||
import {NativeModules} from 'react-native';
|
||||
import { NativeModules } from 'react-native';
|
||||
import Cloud from '../../shared/CloudBackupAndRestoreUtils';
|
||||
import {CACHED_API} from '../../shared/api';
|
||||
import getAllConfigurations, { CACHED_API } from '../../shared/api';
|
||||
import {
|
||||
fetchKeyPair,
|
||||
generateKeyPair,
|
||||
} from '../../shared/cryptoutil/cryptoUtil';
|
||||
import {
|
||||
constructIssuerMetaData,
|
||||
constructProofJWT,
|
||||
hasKeyPair,
|
||||
updateCredentialInformation,
|
||||
verifyCredentialData,
|
||||
} from '../../shared/openId4VCI/Utils';
|
||||
import VciClient from '../../shared/vciClient/VciClient';
|
||||
import {issuerType} from './IssuersMachine';
|
||||
import {setItem} from '../store';
|
||||
import {API_CACHED_STORAGE_KEYS} from '../../shared/constants';
|
||||
import {createCacheObject} from '../../shared/Utils';
|
||||
import { displayType, issuerType } from './IssuersMachine';
|
||||
import { setItem } from '../store';
|
||||
import { API_CACHED_STORAGE_KEYS } from '../../shared/constants';
|
||||
import { createCacheObject } from '../../shared/Utils';
|
||||
import { VerificationResult } from '../../shared/vcjs/verifyCredential';
|
||||
|
||||
export const IssuersService = () => {
|
||||
return {
|
||||
@@ -30,21 +30,26 @@ export const IssuersService = () => {
|
||||
},
|
||||
checkInternet: async () => await NetInfo.fetch(),
|
||||
downloadIssuerWellknown: async (context: any) => {
|
||||
const wellknownResponse = await CACHED_API.fetchIssuerWellknownConfig(
|
||||
context.selectedIssuer.issuer_id,
|
||||
context.selectedIssuer.credential_issuer_host
|
||||
? context.selectedIssuer.credential_issuer_host
|
||||
: context.selectedIssuer.credential_issuer,
|
||||
const wellknownResponse = (await VciClient.getInstance().getIssuerMetadata(
|
||||
context.selectedIssuer.credential_issuer_host,
|
||||
)) as issuerType;
|
||||
const wellknownCacheObject = createCacheObject(wellknownResponse);
|
||||
await setItem(
|
||||
API_CACHED_STORAGE_KEYS.fetchIssuerWellknownConfig(
|
||||
context.selectedIssuer.credential_issuer_host,
|
||||
),
|
||||
wellknownCacheObject,
|
||||
'',
|
||||
);
|
||||
return wellknownResponse;
|
||||
},
|
||||
getCredentialTypes: async (context: any) => {
|
||||
const credentialTypes = [];
|
||||
const credentialTypes: Array<{id: string; [key: string]: any}> = [];
|
||||
const selectedIssuer = context.selectedIssuer;
|
||||
|
||||
const keys =
|
||||
selectedIssuer.credential_configuration_ids ??
|
||||
Object.keys(selectedIssuer.credential_configurations_supported);
|
||||
const keys = Object.keys(
|
||||
selectedIssuer.credential_configurations_supported,
|
||||
);
|
||||
|
||||
for (const key of keys) {
|
||||
if (selectedIssuer.credential_configurations_supported[key]) {
|
||||
@@ -70,26 +75,35 @@ export const IssuersService = () => {
|
||||
authEndpoint: authorizationEndpoint,
|
||||
});
|
||||
};
|
||||
const getProofJwt = async (accessToken: string, cNonce: string) => {
|
||||
const getProofJwt = async (
|
||||
credentialIssuer: string,
|
||||
cNonce: string | null,
|
||||
proofSigningAlgosSupported: string[] | null,
|
||||
) => {
|
||||
sendBack({
|
||||
type: 'PROOF_REQUEST',
|
||||
accessToken: accessToken,
|
||||
credentialIssuer: credentialIssuer,
|
||||
cNonce: cNonce,
|
||||
proofSigningAlgosSupported: proofSigningAlgosSupported,
|
||||
});
|
||||
};
|
||||
const credential =
|
||||
const getTokenResponse = (tokenRequest: object) => {
|
||||
sendBack({
|
||||
type: 'TOKEN_REQUEST',
|
||||
tokenRequest: tokenRequest,
|
||||
});
|
||||
};
|
||||
const {credential} =
|
||||
await VciClient.getInstance().requestCredentialFromTrustedIssuer(
|
||||
constructIssuerMetaData(
|
||||
context.selectedIssuer,
|
||||
context.selectedCredentialType,
|
||||
context.selectedCredentialType.scope,
|
||||
),
|
||||
context.selectedIssuer.credential_issuer_host,
|
||||
context.selectedCredentialType.id,
|
||||
{
|
||||
clientId: context.selectedIssuer.client_id,
|
||||
redirectUri: context.selectedIssuer.redirect_uri,
|
||||
},
|
||||
getProofJwt,
|
||||
navigateToAuthView,
|
||||
getTokenResponse,
|
||||
);
|
||||
return updateCredentialInformation(context, credential);
|
||||
},
|
||||
@@ -109,7 +123,7 @@ export const IssuersService = () => {
|
||||
const {RNSecureKeystoreModule} = NativeModules;
|
||||
try {
|
||||
return await RNSecureKeystoreModule.hasAlias(
|
||||
context.credentialOfferIssuerMetadata.credential_issuer,
|
||||
context.credentialOfferCredentialIssuer,
|
||||
);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
@@ -123,8 +137,8 @@ export const IssuersService = () => {
|
||||
const {RNSecureKeystoreModule} = NativeModules;
|
||||
try {
|
||||
await RNSecureKeystoreModule.storeData(
|
||||
context.credentialOfferIssuerMetadata.credential_issuer,
|
||||
JSON.stringify(context.credentialOfferIssuerMetadata),
|
||||
context.credentialOfferCredentialIssuer,
|
||||
'trusted',
|
||||
);
|
||||
} catch {
|
||||
console.error('Error updating issuer trust in keystore');
|
||||
@@ -138,39 +152,16 @@ export const IssuersService = () => {
|
||||
});
|
||||
};
|
||||
const getSignedProofJwt = async (
|
||||
accessToken: string,
|
||||
credentialIssuer: string,
|
||||
cNonce: string | null,
|
||||
issuerMetadata: object,
|
||||
credentialConfigurationId: string,
|
||||
proofSigningAlgosSupported: string[] | null,
|
||||
) => {
|
||||
let issuer = issuerMetadata as issuerType;
|
||||
issuer.issuer_id = issuer.credential_issuer;
|
||||
const wellknownCacheObject = createCacheObject(issuer);
|
||||
await setItem(
|
||||
API_CACHED_STORAGE_KEYS.fetchIssuerWellknownConfig(issuer.issuer_id),
|
||||
wellknownCacheObject,
|
||||
'',
|
||||
);
|
||||
|
||||
let credentialTypes: Array<{id: string; [key: string]: any}> = [];
|
||||
if (
|
||||
issuer.credential_configurations_supported[credentialConfigurationId]
|
||||
) {
|
||||
credentialTypes.push({
|
||||
id: credentialConfigurationId,
|
||||
...issuer.credential_configurations_supported[
|
||||
credentialConfigurationId
|
||||
],
|
||||
});
|
||||
sendBack({
|
||||
type: 'PROOF_REQUEST',
|
||||
accessToken: accessToken,
|
||||
cNonce: cNonce,
|
||||
issuerMetadata: issuerMetadata,
|
||||
issuer: issuer,
|
||||
credentialTypes: credentialTypes,
|
||||
});
|
||||
}
|
||||
sendBack({
|
||||
type: 'PROOF_REQUEST',
|
||||
cNonce: cNonce,
|
||||
issuer: credentialIssuer,
|
||||
proofSigningAlgosSupported: proofSigningAlgosSupported,
|
||||
});
|
||||
};
|
||||
|
||||
const getTxCode = async (
|
||||
@@ -186,24 +177,55 @@ export const IssuersService = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const requesTrustIssuerConsent = async (issuerMetadata: object) => {
|
||||
const issuerMetadataObject = issuerMetadata as issuerType;
|
||||
const requesTrustIssuerConsent = async (
|
||||
credentialIssuer: string,
|
||||
issuerDisplay: object[],
|
||||
) => {
|
||||
const issuerDisplayObject = issuerDisplay as displayType[];
|
||||
|
||||
sendBack({
|
||||
type: 'TRUST_ISSUER_CONSENT_REQUEST',
|
||||
issuerMetadata: issuerMetadataObject,
|
||||
issuerDisplay: issuerDisplayObject,
|
||||
issuer: credentialIssuer,
|
||||
});
|
||||
};
|
||||
const getTokenResponse = (tokenRequest: object) => {
|
||||
sendBack({
|
||||
type: 'TOKEN_REQUEST',
|
||||
tokenRequest: tokenRequest,
|
||||
});
|
||||
};
|
||||
|
||||
const credential = await VciClient.getInstance().requestCredentialByOffer(
|
||||
context.qrData,
|
||||
getTxCode,
|
||||
getSignedProofJwt,
|
||||
navigateToAuthView,
|
||||
requesTrustIssuerConsent,
|
||||
);
|
||||
return credential;
|
||||
const credentialResponse =
|
||||
await VciClient.getInstance().requestCredentialByOffer(
|
||||
context.qrData,
|
||||
getTxCode,
|
||||
getSignedProofJwt,
|
||||
navigateToAuthView,
|
||||
getTokenResponse,
|
||||
requesTrustIssuerConsent,
|
||||
);
|
||||
return credentialResponse;
|
||||
},
|
||||
sendTokenRequest: async (context: any) => {
|
||||
const tokenRequestObject = context.tokenRequestObject;
|
||||
return await sendTokenRequest(
|
||||
tokenRequestObject,
|
||||
context.selectedIssuer?.token_endpoint,
|
||||
);
|
||||
},
|
||||
sendTokenResponse: async (context: any) => {
|
||||
const tokenResponse = context.tokenResponse;
|
||||
if (!tokenResponse) {
|
||||
throw new Error(
|
||||
'Could not send token response, tokenResponse is undefined or null',
|
||||
);
|
||||
}
|
||||
return await VciClient.getInstance().sendTokenResponse(
|
||||
JSON.stringify(tokenResponse),
|
||||
);
|
||||
},
|
||||
|
||||
updateCredential: async (context: any) => {
|
||||
const credential = await updateCredentialInformation(
|
||||
context,
|
||||
@@ -211,13 +233,25 @@ export const IssuersService = () => {
|
||||
);
|
||||
return credential;
|
||||
},
|
||||
cacheIssuerWellknown: async (context: any) => {
|
||||
const credentialIssuer = context.credentialOfferCredentialIssuer;
|
||||
const issuerMetadata = (await VciClient.getInstance().getIssuerMetadata(
|
||||
credentialIssuer,
|
||||
)) as issuerType;
|
||||
const wellknownCacheObject = createCacheObject(issuerMetadata);
|
||||
await setItem(
|
||||
API_CACHED_STORAGE_KEYS.fetchIssuerWellknownConfig(credentialIssuer),
|
||||
wellknownCacheObject,
|
||||
'',
|
||||
);
|
||||
return issuerMetadata;
|
||||
},
|
||||
constructProof: async (context: any) => {
|
||||
const issuerMeta = context.selectedIssuer;
|
||||
const proofJWT = await constructProofJWT(
|
||||
context.publicKey,
|
||||
context.privateKey,
|
||||
context.accessToken,
|
||||
issuerMeta,
|
||||
context.credentialOfferCredentialIssuer,
|
||||
null,
|
||||
context.keyType,
|
||||
context.wellknownKeyTypes,
|
||||
true,
|
||||
@@ -226,13 +260,13 @@ export const IssuersService = () => {
|
||||
await VciClient.getInstance().sendProof(proofJWT);
|
||||
return proofJWT;
|
||||
},
|
||||
constructProofForTrustedIssuers: async (context: any) => {
|
||||
constructAndSendProofForTrustedIssuers: async (context: any) => {
|
||||
const issuerMeta = context.selectedIssuer;
|
||||
const proofJWT = await constructProofJWT(
|
||||
context.publicKey,
|
||||
context.privateKey,
|
||||
context.accessToken,
|
||||
issuerMeta,
|
||||
context.selectedIssuer.credential_issuer_host,
|
||||
context.selectedIssuer.client_id,
|
||||
context.keyType,
|
||||
context.wellknownKeyTypes,
|
||||
false,
|
||||
@@ -267,16 +301,82 @@ export const IssuersService = () => {
|
||||
return context.keyType;
|
||||
},
|
||||
|
||||
verifyCredential: async (context: any) => {
|
||||
verifyCredential: async (context: any): Promise<VerificationResult> => {
|
||||
const { isCredentialOfferFlow, verifiableCredential, selectedCredentialType } = context;
|
||||
if (isCredentialOfferFlow) {
|
||||
const configurations = await getAllConfigurations();
|
||||
if (configurations.disableCredentialOfferVcVerification) {
|
||||
return {
|
||||
isVerified: true,
|
||||
verificationMessage: '',
|
||||
verificationErrorCode: '',
|
||||
};
|
||||
}
|
||||
}
|
||||
const verificationResult = await verifyCredentialData(
|
||||
context.verifiableCredential?.credential,
|
||||
context.selectedCredentialType.format
|
||||
verifiableCredential?.credential,
|
||||
selectedCredentialType.format,
|
||||
);
|
||||
if (!verificationResult.isVerified) {
|
||||
throw new Error(verificationResult.verificationErrorCode);
|
||||
}
|
||||
|
||||
|
||||
return verificationResult;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
async function sendTokenRequest(
|
||||
tokenRequestObject: any,
|
||||
proxyTokenEndpoint: any = null,
|
||||
) {
|
||||
if (proxyTokenEndpoint) {
|
||||
tokenRequestObject.tokenEndpoint = proxyTokenEndpoint;
|
||||
}
|
||||
if (!tokenRequestObject?.tokenEndpoint) {
|
||||
console.error('tokenEndpoint is not provided in tokenRequestObject');
|
||||
throw new Error('tokenEndpoint is required');
|
||||
}
|
||||
|
||||
const formBody = new URLSearchParams();
|
||||
|
||||
formBody.append('grant_type', tokenRequestObject.grantType);
|
||||
|
||||
if (tokenRequestObject.authCode) {
|
||||
formBody.append('code', tokenRequestObject.authCode);
|
||||
}
|
||||
if (tokenRequestObject.preAuthCode) {
|
||||
formBody.append('pre-authorized_code', tokenRequestObject.preAuthCode);
|
||||
}
|
||||
if (tokenRequestObject.txCode) {
|
||||
formBody.append('tx_code', tokenRequestObject.txCode);
|
||||
}
|
||||
if (tokenRequestObject.clientId) {
|
||||
formBody.append('client_id', tokenRequestObject.clientId);
|
||||
}
|
||||
if (tokenRequestObject.redirectUri) {
|
||||
formBody.append('redirect_uri', tokenRequestObject.redirectUri);
|
||||
}
|
||||
if (tokenRequestObject.codeVerifier) {
|
||||
formBody.append('code_verifier', tokenRequestObject.codeVerifier);
|
||||
}
|
||||
const response = await fetch(tokenRequestObject.tokenEndpoint, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
};
|
||||
};
|
||||
body: formBody.toString(),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
console.error(
|
||||
'Token request failed with status:',
|
||||
response.status,
|
||||
errorText,
|
||||
);
|
||||
throw new Error(`Token request failed: ${response.status} ${errorText}`);
|
||||
}
|
||||
const tokenResponse = await response.json();
|
||||
return tokenResponse;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user