-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(INJI-205): Error handling in OIDC flow #878
feat(INJI-205): Error handling in OIDC flow #878
Conversation
shared/request.ts
Outdated
@@ -16,30 +16,41 @@ export async function request( | |||
method: 'GET' | 'POST' | 'PATCH', | |||
path: `/${string}`, | |||
body?: Record<string, unknown>, | |||
timeout?: undefined | number, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add timeout as last parameter as it's optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this change, I am hoping QR login will not work as we are sending ESIGNET_HOST as last argument in function call. Please check it once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused with the definitive/recommended order of parameters in typescript and I've not found the guidelines on the order of parameters of different types such as normal
, optional
and default
.
962512b
to
9f8c778
Compare
07eea13
to
4347a96
Compare
machines/issuersMachine.ts
Outdated
{ | ||
description: 'not fetched issuers config yet', | ||
cond: 'shouldFetchIssuersAgain', | ||
actions: ['setLoadingIssuer', 'resetError'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we are updating the loadingReason context, can we rename setLoadingIssuer to setLoadingReason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are updating loading reason to be 'loading issuers' and in other areas we update loading reason to downloading credentials & so. so we are using setLoadingIssuers name for the action to differentiate loadingReason setup for different areas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed function accordingly
machines/issuersMachine.ts
Outdated
setDownloadingCreds: model.assign({ | ||
loadingReason: 'downloadingCredentials', | ||
}), | ||
setTokenLoadingReason: model.assign({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean like inline actions? if so, Wouldn't inline actions make it hard to debug / visualize the machine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed function accordingly
- `internet not available` on network request failure to issuer - generic error message on other errors in the flow - OIDC flow cancel error message Signed-off-by: Kiruthika Jeyashankar <[email protected]>
Signed-off-by: Kiruthika Jeyashankar <[email protected]>
granular level changes: - merged error states - move to a two-step issuer-ID assign of issuer from issuerScreen to state machine - improved OIDC cancel flow handling for android/iOS openid platform libs Co-authored-by: Kiruthika Jeyashankar <[email protected]> Signed-off-by: Kiruthika Jeyashankar <[email protected]>
Co-authored-by: Kiruthika Jeyashankar <[email protected]> Signed-off-by: Kiruthika Jeyashankar <[email protected]>
Co-authored-by: Kiruthika Jeyashankar <[email protected]> Signed-off-by: Kiruthika Jeyashankar <[email protected]>
this feature was added in [RN 0.60](https://github.com/react-native-community/releases/blob/master/CHANGELOG.md#v0600) Signed-off-by: Kiruthika Jeyashankar <[email protected]>
Signed-off-by: Kiruthika Jeyashankar <[email protected]>
Co-authored-by: Kiruthika Jeyashankar <[email protected]> Signed-off-by: Kiruthika Jeyashankar <[email protected]>
the timeout is kept as 30 seconds Co-authored-by: Harsh Vardhan <[email protected]> Signed-off-by: Kiruthika Jeyashankar <[email protected]>
Co-authored-by: Harsh Vardhan <[email protected]> Signed-off-by: Kiruthika Jeyashankar <[email protected]>
Co-authored-by: Kiruthika Jeyashankar <[email protected]> Signed-off-by: Kiruthika Jeyashankar <[email protected]>
Co-authored-by: Kiruthika Jeyashankar <[email protected]> Signed-off-by: Kiruthika Jeyashankar <[email protected]>
afc30a5
to
bcd500f
Compare
Signed-off-by: Kiruthika Jeyashankar <[email protected]>
shared/openId4VCI/Utils.ts
Outdated
@@ -92,3 +92,20 @@ export const getJWT = async context => { | |||
throw e; | |||
} | |||
}; | |||
export const VC_DOWNLOAD_TIMEOUT = 30; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we move this property to inji-default.properties
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, let's move it to inji-default.properties and add as Initial config which is being used for caching
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change included
shared/openId4VCI/Utils.ts
Outdated
REQUEST_TIMEDOUT = 'requestTimedOut', | ||
} | ||
export const NETWORK_REQUEST_FAILED = 'Network request failed'; | ||
export const REQUEST_TIMEOUT = 'request timedout'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
request.ts is not using this constant REQUEST_TIMEOUT variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored
Co-authored-by: Harsh Vardhan <[email protected]> Signed-off-by: Kiruthika Jeyashankar <[email protected]>
Co-authored-by: Harsh Vardhan <[email protected]> Signed-off-by: Kiruthika Jeyashankar <[email protected]>
Co-authored-by: Harsh Vardhan <[email protected]> Signed-off-by: Kiruthika Jeyashankar <[email protected]>
Co-authored-by: Harsh Vardhan <[email protected]> Signed-off-by: Kiruthika Jeyashankar <[email protected]>
Co-authored-by: Harsh Vardhan <[email protected]> Signed-off-by: Kiruthika Jeyashankar <[email protected]>
machines/issuersMachine.ts
Outdated
actions: ['setPublicKey', 'setPrivateKey', 'storeKeyPair'], | ||
actions: [ | ||
'setPublicKey', | ||
'setLoadingReasonAsDownloadingCreds', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove the abbreviation "creds" and use full name for more clarity "credential"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored
machines/issuersMachine.ts
Outdated
return state.context.errorMessage; | ||
export function selectErrorMessageType(state: State) { | ||
return state.context.errorMessage === '' || | ||
state.context.errorMessage === 'noInternetConnection' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use the ErrorMessage enums here as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored
screens/Issuers/IssuersScreen.tsx
Outdated
@@ -50,14 +54,18 @@ export const IssuersScreen: React.FC< | |||
}; | |||
|
|||
const isGenericError = () => { | |||
return controller.errorMessage === 'generic'; | |||
return controller.errorMessageType === 'generic'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use ErrorMessage enum here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored
shared/openId4VCI/Utils.ts
Outdated
@@ -92,3 +93,19 @@ export const getJWT = async context => { | |||
throw e; | |||
} | |||
}; | |||
export const VC_DOWNLOAD_TIMEOUT = | |||
Number(getConfig('openId4VCIDownloadVCTimeout')) || 30000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont need default value 30000 here, as cached response itself will set it, if not avl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the promise fails to resolve or the key is missing from the server, the promise.catch would return ''
and Number('')
would evaluate to 0
, hence this or condition is required.
shared/commonprops/commonProps.ts
Outdated
@@ -10,6 +10,14 @@ export default async function getAllConfigurations(host = undefined) { | |||
return await CACHED_API.getAllProperties(); | |||
} | |||
|
|||
export function getConfig(key: string): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove this function and use getAllConfiguration, no need for separate function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a helper function we've written for future convenience usage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored to use getAllConfigurations
Signed-off-by: Kiruthika Jeyashankar <[email protected]>
Co-authored-by: Harsh Vardhan <[email protected]> Signed-off-by: Kiruthika Jeyashankar <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changes looks good to me.
User visible scenarios handled
No internet connectivity
message shownthe library will pass a config error
hence this will result in a generic errorSomething went wrong
message shownCode changes
shared/request.ts
for requestTimeout without breaking other's changesWhat needs to be improved ?
efficacy of timeout handling onthis has been implemented using AbortController's polyfill added in ReactNative 0.60, hence it works on React Native 0.60 & abovefetch
is sort of debatable, it'd need to be tested wellRequest timeout feature implementation
The server writing the response for the above request had a sleep for 10seconds, the server did wait for 10seconds to write the response but from the client logs the Promise got rejected with this log. The logs are sort of a real-world proof that the timeout should work on physical devices.