Last active
February 5, 2021 17:21
-
-
Save bewest/b3bd5535e80bd03b4aa7193f34a875d5 to your computer and use it in GitHub Desktop.
Revisions
-
bewest revised this gist
Feb 5, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -87,7 +87,7 @@ var refreshingBearerTokenFetchMachine = Machine({ } }, // Does making this a final state mean it can't be re-used in a polling activity? success: { on: { '': 'idle' } }, failure: { on: { RETRY: '#RefreshingTokenAccessFetchMachine.unauthorized' -
bewest revised this gist
Feb 5, 2021 . No changes.There are no files selected for viewing
-
bewest revised this gist
Feb 5, 2021 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -86,10 +86,11 @@ var refreshingBearerTokenFetchMachine = Machine({ REJECT: 'failure' } }, // Does making this a final state mean it can't be re-used in a polling activity? success: { type: 'final' }, failure: { on: { RETRY: '#RefreshingTokenAccessFetchMachine.unauthorized' } }, } -
bewest revised this gist
Feb 5, 2021 . No changes.There are no files selected for viewing
-
bewest revised this gist
Feb 5, 2021 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,7 +27,7 @@ var refreshingBearerTokenFetchMachine = Machine({ on: { NEXT: 'step_five_bearer' } }, step_five_bearer: { on: { NEXT: '#RefreshingTokenAccessFetchMachine.authorized' } }, } }, @@ -62,7 +62,7 @@ var refreshingBearerTokenFetchMachine = Machine({ }, invalid: { on: { '': '#RefreshingTokenAccessFetchMachine.unauthorized' } }, @@ -75,7 +75,7 @@ var refreshingBearerTokenFetchMachine = Machine({ on: { FETCH: [{ target: 'loading', in: '#RefreshingTokenAccessFetchMachine.authorized.token.valid' }] } -
bewest revised this gist
Feb 5, 2021 . 1 changed file with 9 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,13 @@ /* Our client is expected to access a web service on a regular interval as part of a polling activity. The access itself requires a Bearer token, which can sometimes be renewed. If it cannot be renewed, a new one must be created by going through a sequence of steps. */ var refreshingBearerTokenFetchMachine = Machine({ id: 'RefreshingTokenAccessFetchMachine', initial: 'idle', states: { idle: { on: { FETCH: 'unauthorized' } }, -
bewest created this gist
Feb 5, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,96 @@ var minimedFetchMachine = Machine({ id: 'CarelinkFetchMachine', initial: 'idle', states: { idle: { on: { FETCH: 'unauthorized' } }, unauthorized: { initial: 'step_one_portal', states: { step_one_portal: { on: { NEXT: 'step_two_location' } }, step_two_location: { on: { NEXT: 'step_three_login' } }, step_three_login: { on: { NEXT: 'step_four_consent' } }, step_four_consent: { on: { NEXT: 'step_five_bearer' } }, step_five_bearer: { on: { NEXT: '#CarelinkFetchMachine.authorized' } }, } }, authorized: { type: 'parallel', states: { token: { initial: 'valid', states: { valid: { on: { RENEW: 'expiring', EXPIRE: 'expired' } }, expiring: { on: { REFRESH: 'refreshing' } }, refreshing: { on: { RESOLVE: 'valid', REJECT: 'invalid' } }, expired: { on: { '': 'invalid' } }, invalid: { on: { '': '#CarelinkFetchMachine.unauthorized' } }, }, }, data: { initial: 'idle', states: { idle: { on: { FETCH: [{ target: 'loading', in: '#CarelinkFetchMachine.authorized.token.valid' }] } }, loading: { on: { RESOLVE: 'success', REJECT: 'failure' } }, success: { type: 'final' }, failure: { on: { RETRY: 'loading' } }, } } } }, } });