@@ -15,26 +15,24 @@ import {
1515 type ClientKey ,
1616} from '../client/client-helper' ;
1717
18+ export type UserIdentityAttributes = 'given_name' | 'family_name' | 'preferred_username' ;
19+
1820type TestUserStaticDetails = {
1921 userId : string ;
2022 clientKey : ClientKey ;
2123 /**
2224 * If `userAttributes` is omitted, user will be created with full identity attributes:
2325 * preferred_username, given_name, and family_name.
2426 */
25- userAttributes ?: Array < 'given_name' | 'family_name' | 'preferred_username' > ;
27+ userAttributes ?: Array < UserIdentityAttributes > ;
2628} ;
2729
2830type TestUserDynamicDetails = {
2931 email : string ;
3032 clientId : string ;
3133 password : string ;
3234 clientName ?: string ;
33- identityAttributes ?: {
34- given_name ?: string ;
35- family_name ?: string ;
36- preferred_username ?: string ;
37- } ;
35+ identityAttributes ?: Partial < Record < UserIdentityAttributes , string > > ;
3836} ;
3937
4038export type TestUserContext = TestUserStaticDetails &
@@ -237,10 +235,10 @@ export class CognitoAuthHelper {
237235
238236 const {
239237 userId,
240- userAttributes = [ 'preferred_username' , 'given_name' , 'family_name' ] ,
238+ userAttributes = [ 'preferred_username' , 'given_name' , 'family_name' ] as UserIdentityAttributes [ ] ,
241239 } = userDetails ;
242240
243- const identityAttributes : Record < string , string > = { } ;
241+ const identityAttributes : Partial < Record < UserIdentityAttributes , string > > = { } ;
244242
245243 if ( userAttributes . includes ( 'given_name' ) )
246244 identityAttributes . given_name = 'Test' ;
0 commit comments