@reachfive/identity-ui 1.19.0 → 1.20.0

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/index.d.ts CHANGED
@@ -1,21 +1,23 @@
1
- export { ErrorResponse } from '@reachfive/identity-core'
1
+ export * as Core from '@reachfive/identity-core'
2
+ export { Client as CoreClient, ErrorResponse } from '@reachfive/identity-core'
2
3
 
3
4
  export function createClient(creationConfig: Config): Client
4
5
 
5
6
  export interface Client {
6
- showAuth(options: any): Promise<void>,
7
- showEmailEditor(options: any): Promise<void>,
8
- showPasswordEditor(options: any): Promise<void>,
9
- showPhoneNumberEditor(options: any): Promise<void>,
10
- showPasswordReset(options: any): Promise<void>,
11
- showPasswordless(options: any): Promise<void>,
12
- showProfileEditor(options: any): Promise<void>,
13
- showSocialAccounts(options: any): Promise<void>,
14
- showSocialLogin(options: any): Promise<void>,
15
- showWebAuthnDevices(options: any): Promise<void>,
16
- showMfa(options: any): Promise<void>,
17
- showMfaCredentials(options: any): Promise<void>,
18
- showStepUp(options: any): Promise<void>
7
+ core: CoreClient,
8
+ showAuth(options: AuthOptions): Promise<void>,
9
+ showEmailEditor(options: EmailEditorOptions): Promise<void>,
10
+ showPasswordEditor(options: PasswordEditorOptions): Promise<void>,
11
+ showPhoneNumberEditor(options: PhoneNumberEditorOptions): Promise<void>,
12
+ showPasswordReset(options: PasswordResetOptions): Promise<void>,
13
+ showPasswordless(options: PassswordlessOptions): Promise<void>,
14
+ showProfileEditor(options: ProfileEditorOptions): Promise<void>,
15
+ showSocialAccounts(options: SocialAccountsOptions): Promise<void>,
16
+ showSocialLogin(options: SocialLoginOptions): Promise<void>,
17
+ showWebAuthnDevices(options: WebAuthnDevicesOptions): Promise<void>,
18
+ showMfa(options: MfaOptions): Promise<void>,
19
+ showMfaCredentials(options: MfaCredentialsOptions): Promise<void>,
20
+ showStepUp(options: StepUpOptions): Promise<void>
19
21
  }
20
22
 
21
23
  export interface Config {
@@ -27,3 +29,472 @@ export interface Config {
27
29
  export interface WidgetInstance {
28
30
  destroy(): void
29
31
  }
32
+
33
+ interface Container {
34
+ /** The DOM element or the `id` of a DOM element in which the widget should be embedded. */
35
+ container: HTMLElement | string
36
+ }
37
+
38
+ interface AccessToken {
39
+ /** The authorization credential JSON Web Token (JWT) used to access the ReachFive API, less than five minutes old. */
40
+ accessToken: string
41
+ }
42
+
43
+ interface I18n {
44
+ /** Widget labels and error messages to override. Falls back to the default wordings in `en`, `fr`, `es`, `it` and `nl`. */
45
+ i18n?: Record<string, string>
46
+ }
47
+
48
+ interface OnReady {
49
+ /**
50
+ * Callback function called after the widget has been successfully loaded and rendered inside the container.
51
+ * The callback is called with the widget instance.
52
+ */
53
+ onReady?: (arg: WidgetInstance) => void
54
+ }
55
+
56
+ interface OnSuccess {
57
+ /** Callback function called when the request has failed. */
58
+ onSuccess?: () => void
59
+ }
60
+
61
+ interface OnError {
62
+ /** Callback function called after the widget has been successfully loaded and rendered inside the container. The callback is called with the widget instance. */
63
+ onError?: (error: ErrorResponse) => void
64
+ }
65
+
66
+ interface Theme {
67
+ /**
68
+ * The options to set up to customize the appearance of the widget.
69
+ *
70
+ * @type Theme
71
+ */
72
+ theme?: ThemeOptions
73
+ }
74
+
75
+ export interface ThemeOptions {
76
+ /**
77
+ * The button and link default color.
78
+ * @default "#229955"
79
+ */
80
+ primaryColor?: string
81
+
82
+ /**
83
+ * The radius of the social login button and other input (in px).
84
+ * @default "3"
85
+ */
86
+ borderRadius?: string
87
+
88
+ /** Social button theming options. */
89
+ socialButton?: SocialButtonTheme
90
+ }
91
+
92
+ export interface SocialButtonTheme {
93
+ /** Boolean that specifies if the buttons are inline (horizonally-aligned). */
94
+ inline?: boolean
95
+ /** Boolean that specifies if the text is visible. */
96
+ textVisible?: boolean
97
+ /** Specifies the font-weight (such as normal, bold, or 900). */
98
+ fontWeight?: string
99
+ /** Specifies the font-size. */
100
+ fontSize?: string
101
+ /** Specifies the line-height. */
102
+ lineHeight?: string
103
+ /** Specifies the padding for the x axis. (left and right) */
104
+ paddingX?: string
105
+ /** Specifies the padding for the y axis. (top and bottom) */
106
+ paddingY?: string
107
+ /** Specifies the border-radius. */
108
+ borderRadius?: string
109
+ /** Specifies the border-width. */
110
+ borderWidth?: string
111
+ /** Boolean that specifies if there is a box shadow on the button or not. */
112
+ focusBoxShadow?: boolean
113
+ }
114
+
115
+ /**
116
+ * The field's type.
117
+ * @enum {('hidden' | 'text' | 'number' | 'email' | 'tel')}
118
+ */
119
+ export type FieldType = 'hidden' | 'text' | 'number' | 'email' | 'tel'
120
+
121
+ /** The field's representation. */
122
+ export interface Field {
123
+ key: string
124
+ label?: string
125
+ required?: boolean
126
+ type?: FieldType
127
+ }
128
+
129
+ /** The social provider keys. */
130
+ export const providerKeys = [
131
+ 'facebook',
132
+ 'google',
133
+ 'apple',
134
+ 'linkedin',
135
+ 'microsoft',
136
+ 'twitter',
137
+ 'paypal',
138
+ 'amazon',
139
+ 'vkontakte',
140
+ 'weibo',
141
+ 'wechat',
142
+ 'qq',
143
+ 'line',
144
+ 'yandex',
145
+ 'mailru',
146
+ 'kakaotalk',
147
+ 'franceconnect',
148
+ 'oney',
149
+ 'bconnect',
150
+ 'naver'
151
+ ] as const
152
+ export type ProviderId = typeof providerKeys[number]
153
+
154
+ /**
155
+ * The widget’s initial screen.
156
+ * @enum {('login' | 'login-with-web-authn' | 'signup' | 'forgot-password')}
157
+ */
158
+ export const initialScreens = ['login', 'login-with-web-authn', 'signup', 'forgot-password'] as const
159
+ export type InitialScreen = typeof initialScreens[number]
160
+
161
+ /**
162
+ * The auth type.
163
+ * @enum {('magic_link' | 'sms')}
164
+ */
165
+ export type AuthType = 'magic_link' | 'sms'
166
+
167
+ export interface AuthOptions extends Container, I18n, OnReady, Theme {
168
+ /**
169
+ * Boolean that specifies if the forgot password option is enabled.
170
+ *
171
+ * If the `allowLogin` and `allowSignup` properties are set to `false`, the forgot password feature is enabled even if `allowForgotPassword` is set to `false`.
172
+ *
173
+ * @default true
174
+ */
175
+ allowForgotPassword?: boolean
176
+
177
+ /**
178
+ * Boolean that specifies whether biometric login is enabled.
179
+ *
180
+ * @default false
181
+ */
182
+ allowWebAuthnLogin?: boolean
183
+
184
+ /**
185
+ * Boolean that specifies whether biometric signup is enabled.
186
+ *
187
+ * @default false
188
+ */
189
+ allowWebAuthnSignup?: boolean
190
+
191
+ /**
192
+ * Boolean that specifies whether login is enabled.
193
+ *
194
+ * @default true
195
+ */
196
+ allowLogin?: boolean
197
+
198
+ /**
199
+ * Boolean that specifies whether signup is enabled.
200
+ *
201
+ * @default true
202
+ */
203
+
204
+ allowSignup?: boolean
205
+ /**
206
+ * Boolean that specifies whether an additional field for the custom identifier is shown.
207
+ *
208
+ * @default false
209
+ */
210
+
211
+ allowCustomIdentifier?: boolean
212
+
213
+ /** List of authentication options */
214
+ auth?: Core.AuthOptions
215
+
216
+ /**
217
+ * Whether or not to provide the display password in clear text option.
218
+ *
219
+ * @default false
220
+ */
221
+ canShowPassword?: boolean
222
+
223
+ /**
224
+ * The [ISO country](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code useful to format phone numbers.
225
+ * Defaults to the predefined country code in your account settings or `FR`.
226
+ */
227
+ countryCode?: string
228
+
229
+ /**
230
+ * Whether or not to display a safe error message on password reset, given an invalid email address.
231
+ * This mode ensures not to leak email addresses registered to the platform.
232
+ *
233
+ * @default false
234
+ */
235
+ displaySafeErrorMessage?: boolean
236
+
237
+ /**
238
+ * The widget’s initial screen.
239
+ *
240
+ * - if `allowLogin` is set to `true`, it defaults to `login`.
241
+ * - if `allowLogin` is set to `false` and `allowSignup` is set to `true`, it defaults to `signup`.
242
+ * - if `allowLogin` is set to `false` and `allowWebAuthnLogin` is set to `true`, it defaults to `login-with-web-authn`.
243
+ * - otherwise, defaults to `forgot-password`.
244
+ */
245
+ initialScreen?: InitialScreen
246
+
247
+ /**
248
+ * The URL sent in the email to which the user is redirected.
249
+ * This URL must be whitelisted in the `Allowed Callback URLs` field of your ReachFive client settings.
250
+ * */
251
+ redirectUrl?: string
252
+
253
+ /**
254
+ * Returned in the `redirectUrl` as a query parameter, this parameter is used as the post-email confirmation URL.
255
+ * Important: This parameter should only be used with Hosted Pages.
256
+ */
257
+ returnToAfterEmailConfirmation?: string
258
+
259
+ /**
260
+ * Returned in the `redirectUrl` as a query parameter, this parameter is used to redirect users to a specific URL after a password reset.
261
+ * Important: This parameter should only be used with Hosted Pages.
262
+ */
263
+ returnToAfterPasswordReset?: string
264
+
265
+ /**
266
+ * Whether the signup form fields' labels are displayed on the login view.
267
+ *
268
+ * @default false
269
+ */
270
+ showLabels?: boolean
271
+
272
+ /**
273
+ * Whether the Remember me checkbox is displayed on the login view. Affects user session duration.
274
+ *
275
+ * The account session duration configured in the ReachFive Console (Settings Security SSO) applies when:
276
+ * - The checkbox is hidden from the user
277
+ * - The checkbox is visible and selected by the user
278
+ *
279
+ * If the checkbox is visible and not selected by the user, the default session duration of 1 day applies.
280
+ *
281
+ * @default false
282
+ */
283
+ showRememberMe?: boolean
284
+
285
+ /**
286
+ * List of the signup fields to display in the form.
287
+ *
288
+ * You can pass a field as an object to override default values :
289
+ *
290
+ * @example
291
+ * {
292
+ * "key": "family_name",
293
+ * "defaultValue": "Moreau",
294
+ * "required": true
295
+ * }
296
+ */
297
+ signupFields?: (Field | string)[]
298
+
299
+ /**
300
+ * Lists the available social providers. This is an array of strings.
301
+ * Tip: If you pass an empty array, social providers will not be displayed.
302
+ */
303
+ socialProviders?: ProviderId[]
304
+
305
+ /** Boolean that specifies whether reCAPTCHA is enabled or not. */
306
+ recaptcha_enabled?: boolean
307
+
308
+ /** The SITE key that comes from your [reCAPTCHA](https://www.google.com/recaptcha/admin/create) setup. This must be paired with the appropriate secret key that you received when setting up reCAPTCHA. */
309
+ recaptcha_site_key?: string
310
+ }
311
+
312
+ export interface EmailEditorOptions extends AccessToken, Container, I18n, OnReady, Theme {
313
+ /** The URL sent in the email to which the user is redirected. This URL must be whitelisted in the `Allowed Callback URLs` field of your ReachFive client settings. */
314
+ redirectUrl?: string
315
+
316
+ /**
317
+ * Whether the signup form fields' labels are displayed on the login view.
318
+ * @default false
319
+ */
320
+ showLabels?: boolean
321
+ }
322
+
323
+ export interface PasswordEditorOptions extends AccessToken, Container, I18n, OnReady, OnSuccess, OnError, Theme {
324
+ /**
325
+ * Whether the signup form fields' labels are displayed on the login view.
326
+ * @default false
327
+ */
328
+ showLabels?: boolean
329
+
330
+ /**
331
+ * Ask for the old password before entering a new one.
332
+ * @default false
333
+ */
334
+ promptOldPassword?: boolean
335
+
336
+ /** The URL sent in the email to which the user is redirected. This URL must be whitelisted in the Allowed Callback URLs field of your ReachFive client settings. */
337
+ redirectUrl?: string
338
+ }
339
+
340
+ export interface PasswordResetOptions extends Container, OnReady, I18n, Theme {
341
+ /** The URL to which the user is redirected after a password reset. */
342
+ loginLink?: string
343
+
344
+ /**
345
+ * Whether or not to provide the display password in clear text option.
346
+ * @default false
347
+ */
348
+ canShowPassword?: boolean
349
+
350
+ /** The URL sent in the email to which the user is redirected. This URL must be whitelisted in the Allowed Callback URLs field of your ReachFive client settings. */
351
+ redirectUrl?: string
352
+ }
353
+
354
+ export interface PhoneNumberEditorOptions extends AccessToken, Container, OnReady, I18n, Theme {
355
+ /**
356
+ * Whether the signup form fields' labels are displayed on the login view.
357
+ * @default false
358
+ */
359
+ showLabels?: boolean
360
+
361
+ /**
362
+ * The [ISO country](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code useful to format phone numbers.
363
+ *
364
+ * Defaults to the predefined country code in your account settings or `FR`.
365
+ */
366
+ countryCode?: string
367
+ }
368
+
369
+ export interface ProfileEditorOptions extends AccessToken, Container, OnReady, OnSuccess, OnError, I18n, Theme {
370
+ /**
371
+ * List of the fields to display in the form.
372
+ *
373
+ * **Important:**
374
+ *
375
+ * The following fields can not be changed with this widget:
376
+ * - `password`
377
+ * - `password_confirmation`
378
+ *
379
+ * It is not possible to update the primary identifier submitted at registration (email or phone number). When the primary identifier is the email address (SMS feature disabled), users can only enter a phone number and update without limit.
380
+ */
381
+ fields?: (Field | string)[]
382
+
383
+ /**
384
+ * Whether the signup form fields' labels are displayed on the login view.
385
+ * @default false
386
+ */
387
+ showLabels?: boolean
388
+
389
+ /**
390
+ * The [ISO country](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code useful to format phone numbers.
391
+ *
392
+ * Defaults to the predefined country code in your account settings or `FR`.
393
+ */
394
+ countryCode?: string
395
+
396
+ /** The URL sent in the email to which the user is redirected. This URL must be whitelisted in the `Allowed Callback URLs` field of your ReachFive client settings. */
397
+ redirectUrl?: string
398
+ }
399
+
400
+ export interface SocialAccountsOptions extends AccessToken, Container, I18n, OnReady, Theme {
401
+ /**
402
+ * Lists the available social providers. This is an array of strings.
403
+ *
404
+ * Tip: If you pass an empty array, social providers will not be displayed.
405
+ * */
406
+ socialProviders?: ProviderId[]
407
+
408
+ /** List of authentication options */
409
+ auth?: Core.AuthOptions
410
+ }
411
+
412
+ export interface SocialLoginOptions extends Container, I18n, OnReady, Theme {
413
+ /**
414
+ * Lists the available social providers. This is an array of strings.
415
+ *
416
+ * Tip: If you pass an empty array, social providers will not be displayed.
417
+ * */
418
+ socialProviders?: ProviderId[]
419
+
420
+ /** List of authentication options */
421
+ auth?: Core.AuthOptions
422
+
423
+ /** The URL sent in the email to which the user is redirected. This URL must be whitelisted in the Allowed Callback URLs field of your ReachFive client settings. */
424
+ redirectUrl?: string
425
+ }
426
+
427
+ export interface PassswordlessOptions extends Container, I18n, OnReady, OnSuccess, OnError, Theme {
428
+ /**
429
+ * The passwordless auth type (`magic_link` or `sms`).
430
+ * @default "magic_link"
431
+ */
432
+ authType?: AuthType
433
+
434
+ /**
435
+ * Show the social login buttons.
436
+ * @default false
437
+ */
438
+ showSocialLogins?: boolean
439
+
440
+ /**
441
+ * Lists the available social providers. This is an array of strings.
442
+ *
443
+ * Tip: If you pass an empty array, social providers will not be displayed.
444
+ */
445
+ socialProviders?: ProviderId[]
446
+
447
+ /**
448
+ * Show the introduction text.
449
+ * @default true
450
+ */
451
+ showIntro?: boolean
452
+
453
+ /**
454
+ * The [ISO country](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code useful to format phone numbers.
455
+ *
456
+ * Defaults to the predefined country code in your account settings or `FR`.
457
+ */
458
+ countryCode?: string
459
+
460
+ /** List of authentication options */
461
+ auth?: Core.AuthOptions
462
+
463
+ /** The URL sent in the email to which the user is redirected. This URL must be whitelisted in the Allowed Callback URLs field of your ReachFive client settings. */
464
+ redirectUrl?: string
465
+
466
+ /** Boolean that specifies whether reCAPTCHA is enabled or not. */
467
+ recaptcha_enabled?: boolean
468
+
469
+ /** The SITE key that comes from your [reCAPTCHA](https://www.google.com/recaptcha/admin/create) setup. This must be paired with the appropriate secret key that you received when setting up reCAPTCHA. */
470
+ recaptcha_site_key?: string
471
+ }
472
+
473
+ export interface WebAuthnDevicesOptions extends AccessToken, Container, I18n, OnReady, Theme {}
474
+
475
+ export interface MfaOptions extends AccessToken, Container, I18n, OnReady, Theme {
476
+ /**
477
+ * Show the introduction text.
478
+ * @default true
479
+ */
480
+ showIntro?: boolean
481
+
482
+ /**
483
+ * Boolean to enable (`true`) or disable (`false`) whether the option to remove MFA credentials are displayed.
484
+ * @default true
485
+ */
486
+ showRemoveMfaCredentials?: boolean
487
+ }
488
+
489
+ export interface MfaCredentialsOptions extends AccessToken, Container, I18n, OnReady, Theme {}
490
+
491
+ export interface StepUpOptions extends AccessToken, Container, I18n, OnReady, Theme {
492
+ /** List of authentication options */
493
+ auth?: Core.AuthOptions
494
+
495
+ /**
496
+ * Show the introduction text.
497
+ * @default true
498
+ */
499
+ showIntro?: boolean
500
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reachfive/identity-ui",
3
- "version": "1.19.0",
3
+ "version": "1.20.0",
4
4
  "description": "ReachFive Identity Web UI SDK",
5
5
  "author": "ReachFive",
6
6
  "repository": {
@@ -15,7 +15,8 @@
15
15
  "build": "npx rollup --config",
16
16
  "watch": "npm run build -- --watch",
17
17
  "test": "npx jest",
18
- "test:update": "npm run test -- --update-snapshot"
18
+ "test:update": "npm run test -- --update-snapshot",
19
+ "lint": "eslint --ext .js,.jsx,.ts,.tsx src/"
19
20
  },
20
21
  "dependencies": {
21
22
  "@hypnosphi/recompose": "0.30.5",
@@ -23,8 +24,9 @@
23
24
  "@reachfive/zxcvbn": "1.0.0-alpha.2",
24
25
  "char-info": "0.3.2",
25
26
  "classnames": "2.2.6",
26
- "libphonenumber-js": "1.7.54",
27
+ "libphonenumber-js": "^1.10.44",
27
28
  "lodash-es": "4.17.21",
29
+ "luxon": "^3.4.3",
28
30
  "polished": "3.6.5",
29
31
  "prop-types": "15.7.2",
30
32
  "react": "16.13.1",
@@ -45,12 +47,18 @@
45
47
  "@rollup/plugin-replace": "2.3.3",
46
48
  "@rollup/plugin-url": "5.0.1",
47
49
  "@svgr/rollup": "6.5.0",
50
+ "@typescript-eslint/eslint-plugin": "^6.5.0",
51
+ "@typescript-eslint/parser": "^6.5.0",
48
52
  "babel-plugin-dynamic-import-node": "2.3.3",
49
53
  "babel-preset-jest": "26.1.0",
50
54
  "cheerio": "1.0.0-rc.10",
51
55
  "core-js": "3.6.5",
52
56
  "enzyme": "3.11.0",
53
57
  "enzyme-adapter-react-16": "1.15.2",
58
+ "eslint": "^8.48.0",
59
+ "eslint-plugin-compat": "^4.2.0",
60
+ "eslint-plugin-react": "^7.33.2",
61
+ "eslint-plugin-react-hooks": "^4.6.0",
54
62
  "jest": "26.1.0",
55
63
  "jest-styled-components": "7.0.5",
56
64
  "react-test-renderer": "16.13.1",
@@ -58,7 +66,8 @@
58
66
  "rollup-plugin-babel": "4.4.0",
59
67
  "rollup-plugin-node-builtins": "2.1.2",
60
68
  "rollup-plugin-node-globals": "1.4.0",
61
- "rollup-plugin-uglify": "6.0.4"
69
+ "rollup-plugin-uglify": "6.0.4",
70
+ "typescript": "^5.2.2"
62
71
  },
63
72
  "files": [
64
73
  "cjs",