-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
base.ts
207 lines (180 loc) · 6.66 KB
/
base.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
import { IUserPool } from '../user-pool';
/**
* An attribute available from a third party identity provider.
*/
export class ProviderAttribute {
/** The email attribute provided by Apple */
public static readonly APPLE_EMAIL = new ProviderAttribute('email');
/** The name attribute provided by Apple */
public static readonly APPLE_NAME = new ProviderAttribute('name');
/** The first name attribute provided by Apple */
public static readonly APPLE_FIRST_NAME = new ProviderAttribute('firstName');
/** The last name attribute provided by Apple */
public static readonly APPLE_LAST_NAME = new ProviderAttribute('lastName');
/** The user id attribute provided by Amazon */
public static readonly AMAZON_USER_ID = new ProviderAttribute('user_id');
/** The email attribute provided by Amazon */
public static readonly AMAZON_EMAIL = new ProviderAttribute('email');
/** The name attribute provided by Amazon */
public static readonly AMAZON_NAME = new ProviderAttribute('name');
/** The postal code attribute provided by Amazon */
public static readonly AMAZON_POSTAL_CODE = new ProviderAttribute('postal_code');
/** The user id attribute provided by Facebook */
public static readonly FACEBOOK_ID = new ProviderAttribute('id');
/** The birthday attribute provided by Facebook */
public static readonly FACEBOOK_BIRTHDAY = new ProviderAttribute('birthday');
/** The email attribute provided by Facebook */
public static readonly FACEBOOK_EMAIL = new ProviderAttribute('email');
/** The name attribute provided by Facebook */
public static readonly FACEBOOK_NAME = new ProviderAttribute('name');
/** The first name attribute provided by Facebook */
public static readonly FACEBOOK_FIRST_NAME = new ProviderAttribute('first_name');
/** The last name attribute provided by Facebook */
public static readonly FACEBOOK_LAST_NAME = new ProviderAttribute('last_name');
/** The middle name attribute provided by Facebook */
public static readonly FACEBOOK_MIDDLE_NAME = new ProviderAttribute('middle_name');
/** The gender attribute provided by Facebook */
public static readonly FACEBOOK_GENDER = new ProviderAttribute('gender');
/** The locale attribute provided by Facebook */
public static readonly FACEBOOK_LOCALE = new ProviderAttribute('locale');
/** The name attribute provided by Google */
public static readonly GOOGLE_NAMES = new ProviderAttribute('names');
/** The gender attribute provided by Google */
public static readonly GOOGLE_GENDER = new ProviderAttribute('gender');
/** The birthday attribute provided by Google */
public static readonly GOOGLE_BIRTHDAYS = new ProviderAttribute('birthdays');
/** The phone number attribute provided by Google */
public static readonly GOOGLE_PHONE_NUMBERS = new ProviderAttribute('phoneNumbers');
/** The email attribute provided by Google */
public static readonly GOOGLE_EMAIL = new ProviderAttribute('email');
/** The name attribute provided by Google */
public static readonly GOOGLE_NAME = new ProviderAttribute('name');
/** The picture attribute provided by Google */
public static readonly GOOGLE_PICTURE = new ProviderAttribute('picture');
/** The given name attribute provided by Google */
public static readonly GOOGLE_GIVEN_NAME = new ProviderAttribute('given_name');
/** The family name attribute provided by Google */
public static readonly GOOGLE_FAMILY_NAME = new ProviderAttribute('family_name');
/**
* Use this to specify an attribute from the identity provider that is not pre-defined in the CDK.
* @param attributeName the attribute value string as recognized by the provider
*/
public static other(attributeName: string): ProviderAttribute {
return new ProviderAttribute(attributeName);
}
/** The attribute value string as recognized by the provider. */
public readonly attributeName: string;
private constructor(attributeName: string) {
this.attributeName = attributeName;
}
}
/**
* The mapping of user pool attributes to the attributes provided by the identity providers.
*/
export interface AttributeMapping {
/**
* The user's postal address is a required attribute.
* @default - not mapped
*/
readonly address?: ProviderAttribute;
/**
* The user's birthday.
* @default - not mapped
*/
readonly birthdate?: ProviderAttribute;
/**
* The user's e-mail address.
* @default - not mapped
*/
readonly email?: ProviderAttribute;
/**
* The surname or last name of user.
* @default - not mapped
*/
readonly familyName?: ProviderAttribute;
/**
* The user's gender.
* @default - not mapped
*/
readonly gender?: ProviderAttribute;
/**
* The user's first name or give name.
* @default - not mapped
*/
readonly givenName?: ProviderAttribute;
/**
* The user's locale.
* @default - not mapped
*/
readonly locale?: ProviderAttribute;
/**
* The user's middle name.
* @default - not mapped
*/
readonly middleName?: ProviderAttribute;
/**
* The user's full name in displayable form.
* @default - not mapped
*/
readonly fullname?: ProviderAttribute;
/**
* The user's nickname or casual name.
* @default - not mapped
*/
readonly nickname?: ProviderAttribute;
/**
* The user's telephone number.
* @default - not mapped
*/
readonly phoneNumber?: ProviderAttribute;
/**
* The URL to the user's profile picture.
* @default - not mapped
*/
readonly profilePicture?: ProviderAttribute;
/**
* The user's preferred username.
* @default - not mapped
*/
readonly preferredUsername?: ProviderAttribute;
/**
* The URL to the user's profile page.
* @default - not mapped
*/
readonly profilePage?: ProviderAttribute;
/**
* The user's time zone.
* @default - not mapped
*/
readonly timezone?: ProviderAttribute;
/**
* Time, the user's information was last updated.
* @default - not mapped
*/
readonly lastUpdateTime?: ProviderAttribute;
/**
* The URL to the user's web page or blog.
* @default - not mapped
*/
readonly website?: ProviderAttribute;
/**
* Specify custom attribute mapping here and mapping for any standard attributes not supported yet.
* @default - no custom attribute mapping
*/
readonly custom?: { [key: string]: ProviderAttribute };
}
/**
* Properties to create a new instance of UserPoolIdentityProvider
*
*/
export interface UserPoolIdentityProviderProps {
/**
* The user pool to which this construct provides identities.
*/
readonly userPool: IUserPool;
/**
* Mapping attributes from the identity provider to standard and custom attributes of the user pool.
* @default - no attribute mapping
*/
readonly attributeMapping?: AttributeMapping;
}