You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This will create a user with the username and password with TOTP MFA enabled. The TOTP code is generated using the `otpauth` library.
239
+
This will create a user with the username and password with TOTP MFA enabled. The TOTP code is generated using the `otpauth` library. The user will then be signed in and the TOTP code will be generated.
240
+
The timeout ensures the previous TOTP code expires before generating a new code for sign-in. This prevents potential conflicts that could occur if the same TOTP code were used for both user creation and authentication.
This behavior is particularly important when seeding multiple users in your application, as you'll need to carefully manage which user should be signed out at the end of your seeding process.
416
459
460
+
### MFA Challenge Handling
461
+
462
+
- For sign-up challenges, each MFA type has its specific challenge callback:
463
+
- TOTP: `totpSignUpChallenge`
464
+
- Email: `emailSignUpChallenge`
465
+
466
+
- For sign-in, there's a single `signInChallenge` callback that works for all MFA types
467
+
468
+
- Command line prompts work with all forms of MFA during sign-in
469
+
- For sign-up, command line prompts work with EMAIL and SMS, but not with TOTP
470
+
- When MFA is set to "Optional" in a user pool, users will be sent through the Password flow
471
+
472
+
### TOTP Considerations
473
+
474
+
When working with TOTP MFA, be aware of these behaviors:
475
+
476
+
- Using the same TOTP setup secret multiple times for different TOTP instances will result in an error
477
+
- Using the same 6-digit passcode for both sign-up and sign-in (before it expires) will cause an error
478
+
- When creating multiple users or performing multiple sign-ins with TOTP:
479
+
- Wait for the previous passcode to expire before generating a new one
480
+
- The example includes a timeout to handle this: `await new Promise((resolve) => setTimeout(resolve, 35000));`
481
+
417
482
418
483
## Seed APIs
419
484
420
-
The `@aws-amplify/seed` package provides a set of APIs to help you seed your sandbox environment.
485
+
The `@aws-amplify/seed` package provides a set of APIs that are compatible with the Amplify JS Auth APIs to help you seed your sandbox environment.
421
486
422
487
### Secret APIs
423
488
@@ -437,39 +502,52 @@ Secret APIs use AWS Parameter Store and are compatible with `ampx sandbox secret
437
502
438
503
Auth APIs allow you to create and manage users in your sandbox environment and are compatible with Amplify JS Auth APIs.
439
504
440
-
-**createAndSignUpUser** - Creates a user based on the properties passed in, returns the created user's username and the sign-up flow they were created with
505
+
-**createAndSignUpUser** - Creates a user based on the properties passed in
441
506
```typescript
442
507
const user =awaitcreateAndSignUpUser({
443
508
username: 'username',
444
509
password: 'password',
445
510
signInAfterCreation: true,
446
-
signInFlow: 'Password'
511
+
signInFlow: 'Password',
512
+
userAttributes?: StandardUserAttributes// Optional user attributes
447
513
});
448
514
```
449
-
450
-
**MFA Support:**
451
-
- Can be used with MFA by passing a `signUpChallenge` callback function to automate the response to MFA challenges
452
-
- If no `signUpChallenge` is provided, SMS and EMAIL MFA will prompt for input via command line, while TOTP will throw an error
453
-
- Each MFA type has its own challenge callback (e.g., `totpSignUpChallenge` for TOTP)
454
-
- The `totpSignUpChallenge` receives a `totpSetup` argument to help set up TOTP devices
455
-
- When MFA is set to "Optional" in a user pool, users will be sent through the Password flow
456
-
457
-
-**addToUserGroup** - Adds a user to an existing user group
458
-
```typescript
459
-
awaitaddToUserGroup(user, 'GroupName');
460
-
```
461
515
462
516
-**signInUser** - Signs in a user using their username, password, and sign-in flow
463
517
```typescript
464
518
awaitsignInUser({
465
519
username: 'username',
466
520
password: 'password',
467
-
signInFlow: 'Password'
521
+
signInFlow: 'Password'|'MFA',
522
+
signInChallenge?: () =>Promise<ChallengeResponse>// Optional for MFA
468
523
});
469
524
```
470
-
471
-
**MFA Support:**
472
-
- Can pass a `signInChallenge` callback to automate MFA responses
473
-
- If no callback is provided, the user will be prompted for input via command line
474
525
526
+
-**addToUserGroup** - Adds a user to an existing user group
527
+
```typescript
528
+
awaitaddToUserGroup({
529
+
username: 'username'// User to add to group
530
+
}, 'GroupName');
531
+
```
532
+
533
+
### Additional APIs
534
+
535
+
The `@aws-amplify/seed` package additionally provides the following APIs:
536
+
537
+
-`AuthSignUp` - API for user sign-up configuration
538
+
-`AuthUser` - API for user authentication information
539
+
-`ChallengeResponse` - API for MFA challenge responses
540
+
-`StandardUserAttributes` - API for managing user attributes during sign-up
541
+
-`PasswordSignInFlow` - API for password-based authentication
542
+
-`MfaSignUpFlow` - API for MFA during sign-up
543
+
-`MfaSignInFlow` - API for MFA during sign-in
544
+
-`MfaWithTotpSignUpFlow` - API for TOTP-specific MFA during sign-up
545
+
546
+
The following challenge callback APIs are available for MFA flows:
547
+
-`emailSignUpChallenge` - Handles Email MFA during sign-up
548
+
-`smsSignUpChallenge` - Handles SMS MFA during sign-up
549
+
-`totpSignUpChallenge` - Handles TOTP MFA during sign-up
550
+
-`signInChallenge` - Universal handler for all MFA types during sign-in
551
+
552
+
For information on using these APIs, refer to the [Amplify JS Auth API documentation](/[platform]/build-a-backend/auth/connect-your-frontend/).
0 commit comments