@reachfive/identity-ui 1.19.0 → 1.20.1

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