Skip to content

Commit

Permalink
refactor(INJI-205): rename variable and remove redundant comments
Browse files Browse the repository at this point in the history
  • Loading branch information
KiruthikaJeyashankar authored and vharsh committed Oct 9, 2023
1 parent 728dc55 commit 9f8c778
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 88 deletions.
14 changes: 6 additions & 8 deletions machines/issuersMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ enum OIDCErrors {
const model = createModel(
{
issuers: [] as issuerType[],
tempSelectedIssuer: '' as string,
selectedIssuerId: '' as string,
selectedIssuer: {} as issuerType,
tokenResponse: {} as AuthorizeResult,
errorMessage: '' as string,
Expand Down Expand Up @@ -122,8 +122,7 @@ export const IssuersMachine = model.createMachine(
actions: sendParent('DOWNLOAD_ID'),
},
SELECTED_ISSUER: {
// set the issuer obj from the issuerStore
actions: 'updateTmpSelectedIssuer',
actions: 'updateSelectedIssuerId',
target: 'downloadIssuerConfig',
},
},
Expand All @@ -134,7 +133,6 @@ export const IssuersMachine = model.createMachine(
src: 'downloadIssuerConfig',
onDone: {
actions: 'setSelectedIssuers',
// TODO: move checkInternet before downloadIssuerConfig
target: 'checkInternet',
},
onError: {
Expand Down Expand Up @@ -300,7 +298,7 @@ export const IssuersMachine = model.createMachine(
}),
setError: model.assign({
errorMessage: (_, event) => {
console.log('Error while fetching issuers ', event.data.message);
console.log('Error occured ', event.data.message);
return event.data.message === 'Network request failed'
? 'noInternetConnection'
: 'generic';
Expand Down Expand Up @@ -380,8 +378,8 @@ export const IssuersMachine = model.createMachine(
setSelectedIssuers: model.assign({
selectedIssuer: (_, event) => event.data,
}),
updateTmpSelectedIssuer: model.assign({
tempSelectedIssuer: (_, event) => event.id,
updateSelectedIssuerId: model.assign({
selectedIssuerId: (_, event) => event.id,
}),
setTokenResponse: model.assign({
tokenResponse: (_, event) => event.data,
Expand Down Expand Up @@ -432,7 +430,7 @@ export const IssuersMachine = model.createMachine(
},
checkInternet: async () => await NetInfo.fetch(),
downloadIssuerConfig: async (context, _) => {
return await CACHED_API.fetchIssuerConfig(context.tempSelectedIssuer);
return await CACHED_API.fetchIssuerConfig(context.selectedIssuerId);
},
downloadCredential: async context => {
const body = await getBody(context);
Expand Down
224 changes: 144 additions & 80 deletions machines/issuersMachine.typegen.ts
Original file line number Diff line number Diff line change
@@ -1,81 +1,145 @@
// This file was automatically generated. Edits will be overwritten

// This file was automatically generated. Edits will be overwritten

export interface Typegen0 {
'@@xstate/typegen': true;
internalEvents: {
"done.invoke.checkInternet": { type: "done.invoke.checkInternet"; 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: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.downloadIssuerConfig:invocation[0]": { type: "done.invoke.issuersMachine.downloadIssuerConfig:invocation[0]"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." };
"done.invoke.issuersMachine.generateKeyPair:invocation[0]": { type: "done.invoke.issuersMachine.generateKeyPair:invocation[0]"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." };
"done.invoke.issuersMachine.performAuthorization:invocation[0]": { type: "done.invoke.issuersMachine.performAuthorization: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.checkInternet": { type: "error.platform.checkInternet"; data: unknown };
"error.platform.issuersMachine.displayIssuers:invocation[0]": { type: "error.platform.issuersMachine.displayIssuers:invocation[0]"; data: unknown };
"error.platform.issuersMachine.downloadCredentials:invocation[0]": { type: "error.platform.issuersMachine.downloadCredentials:invocation[0]"; data: unknown };
"error.platform.issuersMachine.downloadIssuerConfig:invocation[0]": { type: "error.platform.issuersMachine.downloadIssuerConfig:invocation[0]"; data: unknown };
"error.platform.issuersMachine.performAuthorization:invocation[0]": { type: "error.platform.issuersMachine.performAuthorization:invocation[0]"; data: unknown };
"xstate.init": { type: "xstate.init" };
};
invokeSrcNameMap: {
"checkInternet": "done.invoke.checkInternet";
"downloadCredential": "done.invoke.issuersMachine.downloadCredentials:invocation[0]";
"downloadIssuerConfig": "done.invoke.issuersMachine.downloadIssuerConfig:invocation[0]";
"downloadIssuersList": "done.invoke.issuersMachine.displayIssuers:invocation[0]";
"generateKeyPair": "done.invoke.issuersMachine.generateKeyPair:invocation[0]";
"invokeAuthorization": "done.invoke.issuersMachine.performAuthorization:invocation[0]";
"verifyCredential": "done.invoke.issuersMachine.verifyingCredential:invocation[0]";
};
missingImplementations: {
actions: never;
delays: never;
guards: never;
services: never;
};
eventsCausingActions: {
"getKeyPairFromStore": "done.invoke.issuersMachine.performAuthorization:invocation[0]";
"loadKeyPair": "done.invoke.issuersMachine.performAuthorization:invocation[0]";
"logDownloaded": "done.invoke.issuersMachine.verifyingCredential:invocation[0]";
"resetError": "RESET_ERROR" | "TRY_AGAIN" | "error.platform.issuersMachine.performAuthorization:invocation[0]";
"setCredentialWrapper": "done.invoke.issuersMachine.downloadCredentials:invocation[0]";
"setError": "error.platform.issuersMachine.displayIssuers:invocation[0]" | "error.platform.issuersMachine.downloadCredentials:invocation[0]" | "error.platform.issuersMachine.downloadIssuerConfig:invocation[0]" | "error.platform.issuersMachine.performAuthorization:invocation[0]";
"setIssuers": "done.invoke.issuersMachine.displayIssuers:invocation[0]";
"setLoadingIssuer": "TRY_AGAIN";
"setNoInternet": "done.invoke.checkInternet";
"setPrivateKey": "done.invoke.issuersMachine.generateKeyPair:invocation[0]";
"setPublicKey": "done.invoke.issuersMachine.generateKeyPair:invocation[0]";
"setSelectedIssuers": "done.invoke.issuersMachine.downloadIssuerConfig:invocation[0]";
"setTokenResponse": "done.invoke.issuersMachine.performAuthorization:invocation[0]";
"setVerifiableCredential": "done.invoke.issuersMachine.downloadCredentials:invocation[0]";
"storeKeyPair": "done.invoke.issuersMachine.generateKeyPair:invocation[0]";
"storeVcMetaContext": "done.invoke.issuersMachine.verifyingCredential:invocation[0]";
"storeVcsContext": "done.invoke.issuersMachine.verifyingCredential:invocation[0]";
"storeVerifiableCredentialData": "done.invoke.issuersMachine.verifyingCredential:invocation[0]";
"storeVerifiableCredentialMeta": "done.invoke.issuersMachine.verifyingCredential:invocation[0]";
"unsetLoadingReason": "done.invoke.checkInternet" | "done.invoke.issuersMachine.displayIssuers:invocation[0]" | "error.platform.issuersMachine.performAuthorization:invocation[0]";
"updateTmpSelectedIssuer": "SELECTED_ISSUER";
};
eventsCausingDelays: {

};
eventsCausingGuards: {
"hasKeyPair": "CHECK_KEY_PAIR";
"isCustomSecureKeystore": "done.invoke.issuersMachine.generateKeyPair:invocation[0]";
"isInternetConnected": "done.invoke.checkInternet";
"isOIDCflowCancelled": "error.platform.issuersMachine.performAuthorization:invocation[0]";
"shouldFetchIssuersAgain": "TRY_AGAIN";
};
eventsCausingServices: {
"checkInternet": "done.invoke.issuersMachine.downloadIssuerConfig:invocation[0]";
"downloadCredential": "CHECK_KEY_PAIR" | "done.invoke.issuersMachine.generateKeyPair:invocation[0]";
"downloadIssuerConfig": "SELECTED_ISSUER" | "TRY_AGAIN";
"downloadIssuersList": "TRY_AGAIN" | "xstate.init";
"generateKeyPair": "CHECK_KEY_PAIR";
"invokeAuthorization": "done.invoke.checkInternet";
"verifyCredential": "done.invoke.issuersMachine.downloadCredentials:invocation[0]";
};
matchesStates: "checkInternet" | "checkKeyPair" | "displayIssuers" | "done" | "downloadCredentials" | "downloadIssuerConfig" | "error" | "generateKeyPair" | "idle" | "performAuthorization" | "selectingIssuer" | "storing" | "verifyingCredential";
tags: never;
}

export interface Typegen0 {
'@@xstate/typegen': true;
internalEvents: {
'done.invoke.checkInternet': {
type: 'done.invoke.checkInternet';
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: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.downloadIssuerConfig:invocation[0]': {
type: 'done.invoke.issuersMachine.downloadIssuerConfig:invocation[0]';
data: unknown;
__tip: 'See the XState TS docs to learn how to strongly type this.';
};
'done.invoke.issuersMachine.generateKeyPair:invocation[0]': {
type: 'done.invoke.issuersMachine.generateKeyPair:invocation[0]';
data: unknown;
__tip: 'See the XState TS docs to learn how to strongly type this.';
};
'done.invoke.issuersMachine.performAuthorization:invocation[0]': {
type: 'done.invoke.issuersMachine.performAuthorization: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.checkInternet': {
type: 'error.platform.checkInternet';
data: unknown;
};
'error.platform.issuersMachine.displayIssuers:invocation[0]': {
type: 'error.platform.issuersMachine.displayIssuers:invocation[0]';
data: unknown;
};
'error.platform.issuersMachine.downloadCredentials:invocation[0]': {
type: 'error.platform.issuersMachine.downloadCredentials:invocation[0]';
data: unknown;
};
'error.platform.issuersMachine.downloadIssuerConfig:invocation[0]': {
type: 'error.platform.issuersMachine.downloadIssuerConfig:invocation[0]';
data: unknown;
};
'error.platform.issuersMachine.performAuthorization:invocation[0]': {
type: 'error.platform.issuersMachine.performAuthorization:invocation[0]';
data: unknown;
};
'xstate.init': {type: 'xstate.init'};
};
invokeSrcNameMap: {
checkInternet: 'done.invoke.checkInternet';
downloadCredential: 'done.invoke.issuersMachine.downloadCredentials:invocation[0]';
downloadIssuerConfig: 'done.invoke.issuersMachine.downloadIssuerConfig:invocation[0]';
downloadIssuersList: 'done.invoke.issuersMachine.displayIssuers:invocation[0]';
generateKeyPair: 'done.invoke.issuersMachine.generateKeyPair:invocation[0]';
invokeAuthorization: 'done.invoke.issuersMachine.performAuthorization:invocation[0]';
verifyCredential: 'done.invoke.issuersMachine.verifyingCredential:invocation[0]';
};
missingImplementations: {
actions: never;
delays: never;
guards: never;
services: never;
};
eventsCausingActions: {
getKeyPairFromStore: 'done.invoke.issuersMachine.performAuthorization:invocation[0]';
loadKeyPair: 'done.invoke.issuersMachine.performAuthorization:invocation[0]';
logDownloaded: 'done.invoke.issuersMachine.verifyingCredential:invocation[0]';
resetError:
| 'RESET_ERROR'
| 'TRY_AGAIN'
| 'error.platform.issuersMachine.performAuthorization:invocation[0]';
setCredentialWrapper: 'done.invoke.issuersMachine.downloadCredentials:invocation[0]';
setError:
| 'error.platform.issuersMachine.displayIssuers:invocation[0]'
| 'error.platform.issuersMachine.downloadCredentials:invocation[0]'
| 'error.platform.issuersMachine.downloadIssuerConfig:invocation[0]'
| 'error.platform.issuersMachine.performAuthorization:invocation[0]';
setIssuers: 'done.invoke.issuersMachine.displayIssuers:invocation[0]';
setLoadingIssuer: 'TRY_AGAIN';
setNoInternet: 'done.invoke.checkInternet';
setPrivateKey: 'done.invoke.issuersMachine.generateKeyPair:invocation[0]';
setPublicKey: 'done.invoke.issuersMachine.generateKeyPair:invocation[0]';
setSelectedIssuers: 'done.invoke.issuersMachine.downloadIssuerConfig:invocation[0]';
setTokenResponse: 'done.invoke.issuersMachine.performAuthorization:invocation[0]';
setVerifiableCredential: 'done.invoke.issuersMachine.downloadCredentials:invocation[0]';
storeKeyPair: 'done.invoke.issuersMachine.generateKeyPair:invocation[0]';
storeVcMetaContext: 'done.invoke.issuersMachine.verifyingCredential:invocation[0]';
storeVcsContext: 'done.invoke.issuersMachine.verifyingCredential:invocation[0]';
storeVerifiableCredentialData: 'done.invoke.issuersMachine.verifyingCredential:invocation[0]';
storeVerifiableCredentialMeta: 'done.invoke.issuersMachine.verifyingCredential:invocation[0]';
unsetLoadingReason:
| 'done.invoke.checkInternet'
| 'done.invoke.issuersMachine.displayIssuers:invocation[0]'
| 'error.platform.issuersMachine.performAuthorization:invocation[0]';
updateSelectedIssuerId: 'SELECTED_ISSUER';
};
eventsCausingDelays: {};
eventsCausingGuards: {
hasKeyPair: 'CHECK_KEY_PAIR';
isCustomSecureKeystore: 'done.invoke.issuersMachine.generateKeyPair:invocation[0]';
isInternetConnected: 'done.invoke.checkInternet';
isOIDCflowCancelled: 'error.platform.issuersMachine.performAuthorization:invocation[0]';
shouldFetchIssuersAgain: 'TRY_AGAIN';
};
eventsCausingServices: {
checkInternet: 'done.invoke.issuersMachine.downloadIssuerConfig:invocation[0]';
downloadCredential:
| 'CHECK_KEY_PAIR'
| 'done.invoke.issuersMachine.generateKeyPair:invocation[0]';
downloadIssuerConfig: 'SELECTED_ISSUER' | 'TRY_AGAIN';
downloadIssuersList: 'TRY_AGAIN' | 'xstate.init';
generateKeyPair: 'CHECK_KEY_PAIR';
invokeAuthorization: 'done.invoke.checkInternet';
verifyCredential: 'done.invoke.issuersMachine.downloadCredentials:invocation[0]';
};
matchesStates:
| 'checkInternet'
| 'checkKeyPair'
| 'displayIssuers'
| 'done'
| 'downloadCredentials'
| 'downloadIssuerConfig'
| 'error'
| 'generateKeyPair'
| 'idle'
| 'performAuthorization'
| 'selectingIssuer'
| 'storing'
| 'verifyingCredential';
tags: never;
}

0 comments on commit 9f8c778

Please sign in to comment.