From 68f370b9f74ad4de2dcffc067d8b1335e0543c35 Mon Sep 17 00:00:00 2001 From: Nir Gur Arie Date: Sun, 3 Nov 2024 09:00:48 +0200 Subject: [PATCH 1/2] expose restartOnError on all sdks --- .../src/lib/components/descope/descope.component.ts | 8 ++++++++ .../components/sign-in-flow/sign-in-flow.component.html | 2 ++ .../lib/components/sign-in-flow/sign-in-flow.component.ts | 4 +++- .../components/sign-up-flow/sign-up-flow.component.html | 2 ++ .../lib/components/sign-up-flow/sign-up-flow.component.ts | 4 +++- .../sign-up-or-in-flow/sign-up-or-in-flow.component.html | 2 ++ .../sign-up-or-in-flow/sign-up-or-in-flow.component.ts | 4 +++- packages/sdks/react-sdk/src/components/Descope.tsx | 4 ++++ packages/sdks/react-sdk/src/types.ts | 1 + packages/sdks/vue-sdk/src/Descope.vue | 4 ++++ 10 files changed, 32 insertions(+), 3 deletions(-) diff --git a/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/descope/descope.component.ts b/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/descope/descope.component.ts index c24ce3f1c..888620ee5 100644 --- a/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/descope/descope.component.ts +++ b/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/descope/descope.component.ts @@ -32,6 +32,8 @@ export class DescopeComponent implements OnInit, OnChanges { @Input() telemetryKey: string; @Input() redirectUrl: string; @Input() autoFocus: true | false | 'skipFirstScreen'; + @Input() validateOnBlur: boolean; + @Input() restartOnError: boolean; @Input() debug: boolean; @Input() errorTransformer: (error: { text: string; type: string }) => string; @@ -122,6 +124,12 @@ export class DescopeComponent implements OnInit, OnChanges { if (this.autoFocus) { this.webComponent.setAttribute('auto-focus', this.autoFocus.toString()); } + if (this.validateOnBlur) { + this.webComponent.setAttribute('validate-on-blur', this.autoFocus.toString()); + } + if (this.restartOnError) { + this.webComponent.setAttribute('restart-on-error', this.autoFocus.toString()); + } if (this.debug) { this.webComponent.setAttribute('debug', this.debug.toString()); } diff --git a/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/sign-in-flow/sign-in-flow.component.html b/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/sign-in-flow/sign-in-flow.component.html index 929a036cc..62c54409b 100644 --- a/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/sign-in-flow/sign-in-flow.component.html +++ b/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/sign-in-flow/sign-in-flow.component.html @@ -8,6 +8,8 @@ [telemetryKey]="telemetryKey" [redirectUrl]="redirectUrl" [autoFocus]="autoFocus" + [validateOnBlur]="validateOnBlur" + [restartOnError]="restartOnError" [debug]="debug" [errorTransformer]="errorTransformer" [client]="client" diff --git a/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/sign-in-flow/sign-in-flow.component.ts b/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/sign-in-flow/sign-in-flow.component.ts index 65754e2ed..1338fdaaf 100644 --- a/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/sign-in-flow/sign-in-flow.component.ts +++ b/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/sign-in-flow/sign-in-flow.component.ts @@ -18,7 +18,9 @@ export class SignInFlowComponent { @Input() telemetryKey: string; @Input() redirectUrl: string; @Input() autoFocus: true | false | 'skipFirstScreen'; - + @Input() validateOnBlur: boolean; + @Input() restartOnError: boolean; + @Input() debug: boolean; @Input() errorTransformer: (error: { text: string; type: string }) => string; @Input() client: Record; diff --git a/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/sign-up-flow/sign-up-flow.component.html b/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/sign-up-flow/sign-up-flow.component.html index 338104a29..f11396328 100644 --- a/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/sign-up-flow/sign-up-flow.component.html +++ b/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/sign-up-flow/sign-up-flow.component.html @@ -8,6 +8,8 @@ [telemetryKey]="telemetryKey" [redirectUrl]="redirectUrl" [autoFocus]="autoFocus" + [validateOnBlur]="validateOnBlur" + [restartOnError]="restartOnError" [debug]="debug" [errorTransformer]="errorTransformer" [client]="client" diff --git a/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/sign-up-flow/sign-up-flow.component.ts b/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/sign-up-flow/sign-up-flow.component.ts index 132659b9e..46844446e 100644 --- a/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/sign-up-flow/sign-up-flow.component.ts +++ b/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/sign-up-flow/sign-up-flow.component.ts @@ -18,7 +18,9 @@ export class SignUpFlowComponent { @Input() telemetryKey: string; @Input() redirectUrl: string; @Input() autoFocus: true | false | 'skipFirstScreen'; - + @Input() validateOnBlur: boolean; + @Input() restartOnError: boolean; + @Input() debug: boolean; @Input() errorTransformer: (error: { text: string; type: string }) => string; @Input() client: Record; diff --git a/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.html b/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.html index 4d9339ae3..9c3020d26 100644 --- a/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.html +++ b/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.html @@ -8,6 +8,8 @@ [telemetryKey]="telemetryKey" [redirectUrl]="redirectUrl" [autoFocus]="autoFocus" + [validateOnBlur]="validateOnBlur" + [restartOnError]="restartOnError" [debug]="debug" [errorTransformer]="errorTransformer" [client]="client" diff --git a/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.ts b/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.ts index 24d3a7d43..7c9d6483c 100644 --- a/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.ts +++ b/packages/sdks/angular-sdk/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.ts @@ -18,7 +18,9 @@ export class SignUpOrInFlowComponent { @Input() telemetryKey: string; @Input() redirectUrl: string; @Input() autoFocus: true | false | 'skipFirstScreen'; - + @Input() validateOnBlur: boolean; + @Input() restartOnError: boolean; + @Input() debug: boolean; @Input() errorTransformer: (error: { text: string; type: string }) => string; @Input() client: Record; diff --git a/packages/sdks/react-sdk/src/components/Descope.tsx b/packages/sdks/react-sdk/src/components/Descope.tsx index 4484c0ae3..62618de7e 100644 --- a/packages/sdks/react-sdk/src/components/Descope.tsx +++ b/packages/sdks/react-sdk/src/components/Descope.tsx @@ -53,6 +53,7 @@ const DescopeWC = lazy(async () => { styleId, autoFocus, validateOnBlur, + restartOnError, storeLastAuthenticatedUser, }) => ( { redirect-url={redirectUrl} auto-focus={autoFocus} validate-on-blur={validateOnBlur} + restart-on-error={restartOnError} store-last-authenticated-user={storeLastAuthenticatedUser} /> ), @@ -95,6 +97,7 @@ const Descope = React.forwardRef( redirectUrl, autoFocus, validateOnBlur, + restartOnError, errorTransformer, styleId, }, @@ -217,6 +220,7 @@ const Descope = React.forwardRef( autoFocus={autoFocus} styleId={styleId} validateOnBlur={validateOnBlur} + restartOnError={restartOnError} storeLastAuthenticatedUser={storeLastAuthenticatedUser} keepLastAuthenticatedUserAfterLogout={ keepLastAuthenticatedUserAfterLogout diff --git a/packages/sdks/react-sdk/src/types.ts b/packages/sdks/react-sdk/src/types.ts index 6f40cdff1..b324a1c69 100644 --- a/packages/sdks/react-sdk/src/types.ts +++ b/packages/sdks/react-sdk/src/types.ts @@ -116,6 +116,7 @@ export type DescopeProps = { locale?: string; autoFocus?: AutoFocusOptions; validateOnBlur?: boolean; + restartOnError?: boolean; debug?: boolean; telemetryKey?: string; redirectUrl?: string; diff --git a/packages/sdks/vue-sdk/src/Descope.vue b/packages/sdks/vue-sdk/src/Descope.vue index 508992dff..f23097881 100644 --- a/packages/sdks/vue-sdk/src/Descope.vue +++ b/packages/sdks/vue-sdk/src/Descope.vue @@ -15,6 +15,7 @@ :auto-focus="autoFocus" :style-id="styleId" :validate-on-blur="validateOnBlur" + :restart-on-error="restartOnError" :store-last-authenticated-user="storeLastAuthenticatedUser" :errorTransformer.prop="errorTransformer" :form.attr="formStr" @@ -85,6 +86,9 @@ const props = defineProps({ validateOnBlur: { type: Boolean, }, + restartOnError: { + type: Boolean, + }, errorTransformer: { type: Function, }, From 95b6c4f222dd362292ba38d94f30880c51c4b451 Mon Sep 17 00:00:00 2001 From: Nir Gur Arie Date: Sun, 3 Nov 2024 09:18:24 +0200 Subject: [PATCH 2/2] expose restartOnError on all sdks --- packages/sdks/angular-sdk/README.md | 8 ++++++++ packages/sdks/react-sdk/README.md | 4 +++- packages/sdks/vue-sdk/README.md | 1 + packages/sdks/web-component/README.md | 5 +++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/sdks/angular-sdk/README.md b/packages/sdks/angular-sdk/README.md index cfea515f7..73a3cae46 100644 --- a/packages/sdks/angular-sdk/README.md +++ b/packages/sdks/angular-sdk/README.md @@ -148,6 +148,14 @@ export class AppComponent { - "skipFirstScreen": automatically focus on the first input of each screen, except first screen autoFocus="skipFirstScreen" + validateOnBlur can be true or false. Default is false. + - true: Trigger input validation upon blur, in addition to the validation on submit + - false: do not trigger input validation upon blur + + restartOnError can be true or false. Default is false. + - true: In case of flow version mismatch, will restart the flow if the components version was not changed + - false: Will not auto restart the flow in case of a flow version mismatch + errorTransformer is a function that receives an error object and returns a string. The returned string will be displayed to the user. NOTE: errorTransformer is not required. If not provided, the error object will be displayed as is. Example: diff --git a/packages/sdks/react-sdk/README.md b/packages/sdks/react-sdk/README.md index d64e6d9ed..c080de616 100644 --- a/packages/sdks/react-sdk/README.md +++ b/packages/sdks/react-sdk/README.md @@ -99,7 +99,9 @@ const App = () => { // - "skipFirstScreen": automatically focus on the first input of each screen, except first screen // autoFocus="skipFirstScreen" - // validateOnBlur: set it to true will show input validation errors on blur, in addition to on submit + // validateOnBlur: set it to true will show input validation errors on blur, in addition to on submit + + // restartOnError: if set to true, in case of flow version mismatch, will restart the flow if the components version was not changed. Default is false // errorTransformer is a function that receives an error object and returns a string. The returned string will be displayed to the user. // NOTE: errorTransformer is not required. If not provided, the error object will be displayed as is. diff --git a/packages/sdks/vue-sdk/README.md b/packages/sdks/vue-sdk/README.md index 786f57319..4c6fc2740 100644 --- a/packages/sdks/vue-sdk/README.md +++ b/packages/sdks/vue-sdk/README.md @@ -50,6 +50,7 @@ app.mount('#app'); + diff --git a/packages/sdks/web-component/README.md b/packages/sdks/web-component/README.md index 621fce31c..f93bd35b2 100644 --- a/packages/sdks/web-component/README.md +++ b/packages/sdks/web-component/README.md @@ -78,6 +78,11 @@ NOTE: This package is a part of a monorepo. so if you make changes in a dependen | debug | **"true"** - Enable debugger
**"false"** - Disable debugger | **"false"** | | preview | **"true"** - Run flow in a preview mode
**"false"** - Do run flow in a preview mode | **"false"** | | auto-focus | **"true"** - Automatically focus on the first input of each screen
**"false"** - Do not automatically focus on screen's inputs
**"skipFirstScreen"** - Automatically focus on the first input of each screen, except first screen | **"true"** | + +| validate-on-blur | **"true"** - Triggers the input validation upon blur in addition to the validation on submit
**"false"** - Do not triggers validation upon blur
| **"false"** | + +| restart-on-error | **"true"** - In case of flow version mismatch, will restart the flow if the components version was not changed
**"false"** - Do not restart the flow automatically
| **"false"** | + | storage-prefix | **String** - A prefix to add to the key of the local storage when persisting tokens | **""** | | store-last-authenticated-user | **"true"** - Stores last-authenticated user details in local storage when flow is completed
**"false"** - Do not store last-auth user details. Disabling this flag may cause last-authenticated user features to not function properly | **"true"** | | keep-last-authenticated-user-after-logout | **"true"** - Do not clear the last authenticated user details from the browser storage after logout
**"false"** - Clear the last authenticated user details from the browser storage after logout | **"false"** |