@aws-amplify/ui 6.0.8 → 6.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/helpers/authenticator/getRoute.mjs +11 -1
- package/dist/esm/machines/authenticator/actors/signIn.mjs +2 -7
- package/dist/esm/machines/authenticator/actors/signUp.mjs +10 -13
- package/dist/esm/machines/authenticator/actors/utils.mjs +10 -0
- package/dist/esm/machines/authenticator/index.mjs +8 -6
- package/dist/index.js +38 -27
- package/dist/types/helpers/authenticator/debugUtils.d.ts +11 -0
- package/dist/types/helpers/authenticator/getRoute.d.ts +3 -1
- package/dist/types/machines/authenticator/actors/utils.d.ts +13 -0
- package/package.json +1 -1
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
const getRoute = (state, actorState) => {
|
|
2
|
+
// 'federatedSignIn' exists as a state on both the 'signInActor' and 'signUpActor',
|
|
3
|
+
// match against the `actorState` initially to determine if the federated sign in flow
|
|
4
|
+
// has begun, then which actor has begun the flow and return the corresponding `route`
|
|
5
|
+
if (actorState?.matches('federatedSignIn')) {
|
|
6
|
+
if (state.matches('signUpActor')) {
|
|
7
|
+
return 'signUp';
|
|
8
|
+
}
|
|
9
|
+
if (state.matches('signInActor')) {
|
|
10
|
+
return 'signIn';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
2
13
|
switch (true) {
|
|
3
14
|
case state.matches('idle'):
|
|
4
15
|
return 'idle';
|
|
@@ -17,7 +28,6 @@ const getRoute = (state, actorState) => {
|
|
|
17
28
|
case actorState?.matches('setupTotp.submit'):
|
|
18
29
|
return 'setupTotp';
|
|
19
30
|
case actorState?.matches('signIn'):
|
|
20
|
-
case actorState?.matches('federatedSignIn'):
|
|
21
31
|
return 'signIn';
|
|
22
32
|
case actorState?.matches('signUp'):
|
|
23
33
|
case actorState?.matches('autoSignIn'):
|
|
@@ -4,6 +4,7 @@ import { runValidators } from '../../../validators/index.mjs';
|
|
|
4
4
|
import ACTIONS from '../actions.mjs';
|
|
5
5
|
import { defaultServices } from '../defaultServices.mjs';
|
|
6
6
|
import GUARDS from '../guards.mjs';
|
|
7
|
+
import { getFederatedSignInState } from './utils.mjs';
|
|
7
8
|
|
|
8
9
|
const handleSignInResponse = {
|
|
9
10
|
onDone: [
|
|
@@ -83,13 +84,7 @@ function signInActor({ services }) {
|
|
|
83
84
|
{ target: 'signIn' },
|
|
84
85
|
],
|
|
85
86
|
},
|
|
86
|
-
federatedSignIn:
|
|
87
|
-
entry: ['sendUpdate', 'clearError'],
|
|
88
|
-
invoke: {
|
|
89
|
-
src: 'signInWithRedirect',
|
|
90
|
-
onError: { actions: 'setRemoteError' },
|
|
91
|
-
},
|
|
92
|
-
},
|
|
87
|
+
federatedSignIn: getFederatedSignInState('signIn'),
|
|
93
88
|
fetchUserAttributes: {
|
|
94
89
|
invoke: {
|
|
95
90
|
src: 'fetchUserAttributes',
|
|
@@ -4,6 +4,7 @@ import { getSignUpInput } from '../utils.mjs';
|
|
|
4
4
|
import { runValidators } from '../../../validators/index.mjs';
|
|
5
5
|
import ACTIONS from '../actions.mjs';
|
|
6
6
|
import GUARDS from '../guards.mjs';
|
|
7
|
+
import { getFederatedSignInState } from './utils.mjs';
|
|
7
8
|
|
|
8
9
|
const handleResetPasswordResponse = {
|
|
9
10
|
onDone: [
|
|
@@ -90,6 +91,7 @@ function signUpActor({ services }) {
|
|
|
90
91
|
...handleFetchUserAttributesResponse,
|
|
91
92
|
},
|
|
92
93
|
},
|
|
94
|
+
federatedSignIn: getFederatedSignInState('signUp'),
|
|
93
95
|
resetPassword: {
|
|
94
96
|
invoke: { src: 'resetPassword', ...handleResetPasswordResponse },
|
|
95
97
|
},
|
|
@@ -115,6 +117,9 @@ function signUpActor({ services }) {
|
|
|
115
117
|
signUp: {
|
|
116
118
|
type: 'parallel',
|
|
117
119
|
exit: 'clearTouched',
|
|
120
|
+
on: {
|
|
121
|
+
FEDERATED_SIGN_IN: { target: 'federatedSignIn' },
|
|
122
|
+
},
|
|
118
123
|
states: {
|
|
119
124
|
validation: {
|
|
120
125
|
initial: 'pending',
|
|
@@ -133,8 +138,8 @@ function signUpActor({ services }) {
|
|
|
133
138
|
invalid: { entry: 'sendUpdate' },
|
|
134
139
|
},
|
|
135
140
|
on: {
|
|
136
|
-
CHANGE: { actions: 'handleInput', target: '.pending' },
|
|
137
141
|
BLUR: { actions: 'handleBlur', target: '.pending' },
|
|
142
|
+
CHANGE: { actions: 'handleInput', target: '.pending' },
|
|
138
143
|
},
|
|
139
144
|
},
|
|
140
145
|
submission: {
|
|
@@ -144,14 +149,6 @@ function signUpActor({ services }) {
|
|
|
144
149
|
entry: ['sendUpdate'],
|
|
145
150
|
on: {
|
|
146
151
|
SUBMIT: { actions: 'handleSubmit', target: 'validate' },
|
|
147
|
-
FEDERATED_SIGN_IN: 'federatedSignIn',
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
federatedSignIn: {
|
|
151
|
-
entry: ['sendUpdate', 'clearError'],
|
|
152
|
-
invoke: {
|
|
153
|
-
src: 'federatedSignIn',
|
|
154
|
-
onError: { actions: 'setRemoteError' },
|
|
155
152
|
},
|
|
156
153
|
},
|
|
157
154
|
validate: {
|
|
@@ -159,13 +156,13 @@ function signUpActor({ services }) {
|
|
|
159
156
|
invoke: {
|
|
160
157
|
src: 'validateSignUp',
|
|
161
158
|
onDone: {
|
|
162
|
-
target: '
|
|
159
|
+
target: 'handleSignUp',
|
|
163
160
|
actions: 'clearValidationError',
|
|
164
161
|
},
|
|
165
162
|
onError: { actions: 'setFieldErrors', target: 'idle' },
|
|
166
163
|
},
|
|
167
164
|
},
|
|
168
|
-
|
|
165
|
+
handleSignUp: {
|
|
169
166
|
tags: 'pending',
|
|
170
167
|
entry: ['setUsernameSignUp', 'clearError'],
|
|
171
168
|
exit: 'sendUpdate',
|
|
@@ -268,10 +265,10 @@ function signUpActor({ services }) {
|
|
|
268
265
|
resendSignUpCode({ username }) {
|
|
269
266
|
return resendSignUpCode({ username });
|
|
270
267
|
},
|
|
271
|
-
|
|
268
|
+
signInWithRedirect(_, { data }) {
|
|
272
269
|
return signInWithRedirect(data);
|
|
273
270
|
},
|
|
274
|
-
|
|
271
|
+
handleSignUp(context) {
|
|
275
272
|
const { formValues, loginMechanisms, username } = context;
|
|
276
273
|
const loginMechanism = loginMechanisms[0];
|
|
277
274
|
const input = getSignUpInput(username, formValues, loginMechanism);
|
|
@@ -31,7 +31,7 @@ const stopActor = (machineId) => stop(machineId);
|
|
|
31
31
|
const LEGACY_WAIT_CONFIG = {
|
|
32
32
|
on: {
|
|
33
33
|
INIT: {
|
|
34
|
-
actions:
|
|
34
|
+
actions: 'configure',
|
|
35
35
|
target: 'getConfig',
|
|
36
36
|
},
|
|
37
37
|
SIGN_OUT: '#authenticator.signOut',
|
|
@@ -39,7 +39,7 @@ const LEGACY_WAIT_CONFIG = {
|
|
|
39
39
|
};
|
|
40
40
|
// setup step proceeds directly to configure
|
|
41
41
|
const NEXT_WAIT_CONFIG = {
|
|
42
|
-
always: { actions:
|
|
42
|
+
always: { actions: 'configure', target: 'getConfig' },
|
|
43
43
|
};
|
|
44
44
|
function createAuthenticatorMachine(options) {
|
|
45
45
|
const { useNextWaitConfig, ...overrideConfigServices } = options ?? {};
|
|
@@ -165,6 +165,11 @@ function createAuthenticatorMachine(options) {
|
|
|
165
165
|
cond: 'hasCompletedAttributeConfirmation',
|
|
166
166
|
target: '#authenticator.getCurrentUser',
|
|
167
167
|
},
|
|
168
|
+
{
|
|
169
|
+
cond: 'isShouldConfirmUserAttributeStep',
|
|
170
|
+
actions: 'setActorDoneData',
|
|
171
|
+
target: '#authenticator.verifyUserAttributesActor',
|
|
172
|
+
},
|
|
168
173
|
{
|
|
169
174
|
cond: 'isConfirmUserAttributeStep',
|
|
170
175
|
target: '#authenticator.verifyUserAttributesActor',
|
|
@@ -238,10 +243,7 @@ function createAuthenticatorMachine(options) {
|
|
|
238
243
|
initial: 'spawnActor',
|
|
239
244
|
states: {
|
|
240
245
|
spawnActor: {
|
|
241
|
-
always: {
|
|
242
|
-
actions: 'spawnSignOutActor',
|
|
243
|
-
target: 'runActor',
|
|
244
|
-
},
|
|
246
|
+
always: { actions: 'spawnSignOutActor', target: 'runActor' },
|
|
245
247
|
},
|
|
246
248
|
runActor: {
|
|
247
249
|
entry: 'clearActorDoneData',
|
package/dist/index.js
CHANGED
|
@@ -2345,6 +2345,17 @@ const NAVIGABLE_ROUTE_EVENT = {
|
|
|
2345
2345
|
};
|
|
2346
2346
|
|
|
2347
2347
|
const getRoute = (state, actorState) => {
|
|
2348
|
+
// 'federatedSignIn' exists as a state on both the 'signInActor' and 'signUpActor',
|
|
2349
|
+
// match against the `actorState` initially to determine if the federated sign in flow
|
|
2350
|
+
// has begun, then which actor has begun the flow and return the corresponding `route`
|
|
2351
|
+
if (actorState?.matches('federatedSignIn')) {
|
|
2352
|
+
if (state.matches('signUpActor')) {
|
|
2353
|
+
return 'signUp';
|
|
2354
|
+
}
|
|
2355
|
+
if (state.matches('signInActor')) {
|
|
2356
|
+
return 'signIn';
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2348
2359
|
switch (true) {
|
|
2349
2360
|
case state.matches('idle'):
|
|
2350
2361
|
return 'idle';
|
|
@@ -2363,7 +2374,6 @@ const getRoute = (state, actorState) => {
|
|
|
2363
2374
|
case actorState?.matches('setupTotp.submit'):
|
|
2364
2375
|
return 'setupTotp';
|
|
2365
2376
|
case actorState?.matches('signIn'):
|
|
2366
|
-
case actorState?.matches('federatedSignIn'):
|
|
2367
2377
|
return 'signIn';
|
|
2368
2378
|
case actorState?.matches('signUp'):
|
|
2369
2379
|
case actorState?.matches('autoSignIn'):
|
|
@@ -3883,6 +3893,15 @@ function forgotPasswordActor({ services, }) {
|
|
|
3883
3893
|
});
|
|
3884
3894
|
}
|
|
3885
3895
|
|
|
3896
|
+
const getFederatedSignInState = (target) => ({
|
|
3897
|
+
entry: ['sendUpdate', 'clearError'],
|
|
3898
|
+
invoke: {
|
|
3899
|
+
src: 'signInWithRedirect',
|
|
3900
|
+
onDone: { target },
|
|
3901
|
+
onError: { actions: 'setRemoteError', target },
|
|
3902
|
+
},
|
|
3903
|
+
});
|
|
3904
|
+
|
|
3886
3905
|
const handleSignInResponse = {
|
|
3887
3906
|
onDone: [
|
|
3888
3907
|
{
|
|
@@ -3961,13 +3980,7 @@ function signInActor({ services }) {
|
|
|
3961
3980
|
{ target: 'signIn' },
|
|
3962
3981
|
],
|
|
3963
3982
|
},
|
|
3964
|
-
federatedSignIn:
|
|
3965
|
-
entry: ['sendUpdate', 'clearError'],
|
|
3966
|
-
invoke: {
|
|
3967
|
-
src: 'signInWithRedirect',
|
|
3968
|
-
onError: { actions: 'setRemoteError' },
|
|
3969
|
-
},
|
|
3970
|
-
},
|
|
3983
|
+
federatedSignIn: getFederatedSignInState('signIn'),
|
|
3971
3984
|
fetchUserAttributes: {
|
|
3972
3985
|
invoke: {
|
|
3973
3986
|
src: 'fetchUserAttributes',
|
|
@@ -4288,6 +4301,7 @@ function signUpActor({ services }) {
|
|
|
4288
4301
|
...handleFetchUserAttributesResponse,
|
|
4289
4302
|
},
|
|
4290
4303
|
},
|
|
4304
|
+
federatedSignIn: getFederatedSignInState('signUp'),
|
|
4291
4305
|
resetPassword: {
|
|
4292
4306
|
invoke: { src: 'resetPassword', ...handleResetPasswordResponse },
|
|
4293
4307
|
},
|
|
@@ -4313,6 +4327,9 @@ function signUpActor({ services }) {
|
|
|
4313
4327
|
signUp: {
|
|
4314
4328
|
type: 'parallel',
|
|
4315
4329
|
exit: 'clearTouched',
|
|
4330
|
+
on: {
|
|
4331
|
+
FEDERATED_SIGN_IN: { target: 'federatedSignIn' },
|
|
4332
|
+
},
|
|
4316
4333
|
states: {
|
|
4317
4334
|
validation: {
|
|
4318
4335
|
initial: 'pending',
|
|
@@ -4331,8 +4348,8 @@ function signUpActor({ services }) {
|
|
|
4331
4348
|
invalid: { entry: 'sendUpdate' },
|
|
4332
4349
|
},
|
|
4333
4350
|
on: {
|
|
4334
|
-
CHANGE: { actions: 'handleInput', target: '.pending' },
|
|
4335
4351
|
BLUR: { actions: 'handleBlur', target: '.pending' },
|
|
4352
|
+
CHANGE: { actions: 'handleInput', target: '.pending' },
|
|
4336
4353
|
},
|
|
4337
4354
|
},
|
|
4338
4355
|
submission: {
|
|
@@ -4342,14 +4359,6 @@ function signUpActor({ services }) {
|
|
|
4342
4359
|
entry: ['sendUpdate'],
|
|
4343
4360
|
on: {
|
|
4344
4361
|
SUBMIT: { actions: 'handleSubmit', target: 'validate' },
|
|
4345
|
-
FEDERATED_SIGN_IN: 'federatedSignIn',
|
|
4346
|
-
},
|
|
4347
|
-
},
|
|
4348
|
-
federatedSignIn: {
|
|
4349
|
-
entry: ['sendUpdate', 'clearError'],
|
|
4350
|
-
invoke: {
|
|
4351
|
-
src: 'federatedSignIn',
|
|
4352
|
-
onError: { actions: 'setRemoteError' },
|
|
4353
4362
|
},
|
|
4354
4363
|
},
|
|
4355
4364
|
validate: {
|
|
@@ -4357,13 +4366,13 @@ function signUpActor({ services }) {
|
|
|
4357
4366
|
invoke: {
|
|
4358
4367
|
src: 'validateSignUp',
|
|
4359
4368
|
onDone: {
|
|
4360
|
-
target: '
|
|
4369
|
+
target: 'handleSignUp',
|
|
4361
4370
|
actions: 'clearValidationError',
|
|
4362
4371
|
},
|
|
4363
4372
|
onError: { actions: 'setFieldErrors', target: 'idle' },
|
|
4364
4373
|
},
|
|
4365
4374
|
},
|
|
4366
|
-
|
|
4375
|
+
handleSignUp: {
|
|
4367
4376
|
tags: 'pending',
|
|
4368
4377
|
entry: ['setUsernameSignUp', 'clearError'],
|
|
4369
4378
|
exit: 'sendUpdate',
|
|
@@ -4466,10 +4475,10 @@ function signUpActor({ services }) {
|
|
|
4466
4475
|
resendSignUpCode({ username }) {
|
|
4467
4476
|
return auth.resendSignUpCode({ username });
|
|
4468
4477
|
},
|
|
4469
|
-
|
|
4478
|
+
signInWithRedirect(_, { data }) {
|
|
4470
4479
|
return auth.signInWithRedirect(data);
|
|
4471
4480
|
},
|
|
4472
|
-
|
|
4481
|
+
handleSignUp(context) {
|
|
4473
4482
|
const { formValues, loginMechanisms, username } = context;
|
|
4474
4483
|
const loginMechanism = loginMechanisms[0];
|
|
4475
4484
|
const input = getSignUpInput(username, formValues, loginMechanism);
|
|
@@ -4634,7 +4643,7 @@ const stopActor = (machineId) => stop(machineId);
|
|
|
4634
4643
|
const LEGACY_WAIT_CONFIG = {
|
|
4635
4644
|
on: {
|
|
4636
4645
|
INIT: {
|
|
4637
|
-
actions:
|
|
4646
|
+
actions: 'configure',
|
|
4638
4647
|
target: 'getConfig',
|
|
4639
4648
|
},
|
|
4640
4649
|
SIGN_OUT: '#authenticator.signOut',
|
|
@@ -4642,7 +4651,7 @@ const LEGACY_WAIT_CONFIG = {
|
|
|
4642
4651
|
};
|
|
4643
4652
|
// setup step proceeds directly to configure
|
|
4644
4653
|
const NEXT_WAIT_CONFIG = {
|
|
4645
|
-
always: { actions:
|
|
4654
|
+
always: { actions: 'configure', target: 'getConfig' },
|
|
4646
4655
|
};
|
|
4647
4656
|
function createAuthenticatorMachine(options) {
|
|
4648
4657
|
const { useNextWaitConfig, ...overrideConfigServices } = options ?? {};
|
|
@@ -4768,6 +4777,11 @@ function createAuthenticatorMachine(options) {
|
|
|
4768
4777
|
cond: 'hasCompletedAttributeConfirmation',
|
|
4769
4778
|
target: '#authenticator.getCurrentUser',
|
|
4770
4779
|
},
|
|
4780
|
+
{
|
|
4781
|
+
cond: 'isShouldConfirmUserAttributeStep',
|
|
4782
|
+
actions: 'setActorDoneData',
|
|
4783
|
+
target: '#authenticator.verifyUserAttributesActor',
|
|
4784
|
+
},
|
|
4771
4785
|
{
|
|
4772
4786
|
cond: 'isConfirmUserAttributeStep',
|
|
4773
4787
|
target: '#authenticator.verifyUserAttributesActor',
|
|
@@ -4841,10 +4855,7 @@ function createAuthenticatorMachine(options) {
|
|
|
4841
4855
|
initial: 'spawnActor',
|
|
4842
4856
|
states: {
|
|
4843
4857
|
spawnActor: {
|
|
4844
|
-
always: {
|
|
4845
|
-
actions: 'spawnSignOutActor',
|
|
4846
|
-
target: 'runActor',
|
|
4847
|
-
},
|
|
4858
|
+
always: { actions: 'spawnSignOutActor', target: 'runActor' },
|
|
4848
4859
|
},
|
|
4849
4860
|
runActor: {
|
|
4850
4861
|
entry: 'clearActorDoneData',
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GetRoute } from './getRoute';
|
|
2
|
+
/**
|
|
3
|
+
* @internal Not to be used in production
|
|
4
|
+
* @description Debugging tool for logging `state` and `actorState`
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const getRouteWithLogs = logRouteChanges(getRoute);
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare const logRouteChanges: (fn: GetRoute) => GetRoute;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { AuthActorState, AuthMachineState } from '../../machines/authenticator/types';
|
|
2
|
-
|
|
2
|
+
import { AuthenticatorRoute } from './facade';
|
|
3
|
+
export type GetRoute = (state: AuthMachineState, actorState: AuthActorState) => AuthenticatorRoute;
|
|
4
|
+
export declare const getRoute: (state: AuthMachineState, actorState: AuthActorState) => AuthenticatorRoute;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const getFederatedSignInState: (target: 'signIn' | 'signUp') => {
|
|
2
|
+
entry: string[];
|
|
3
|
+
invoke: {
|
|
4
|
+
src: string;
|
|
5
|
+
onDone: {
|
|
6
|
+
target: "signIn" | "signUp";
|
|
7
|
+
};
|
|
8
|
+
onError: {
|
|
9
|
+
actions: string;
|
|
10
|
+
target: "signIn" | "signUp";
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|