@asgardeo/react 0.6.22 → 0.6.24
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.
|
@@ -25,7 +25,7 @@ export declare const renderSignInComponents: (components: EmbeddedFlowComponent[
|
|
|
25
25
|
buttonClassName?: string;
|
|
26
26
|
inputClassName?: string;
|
|
27
27
|
onInputBlur?: (name: string) => void;
|
|
28
|
-
onSubmit?: (component: EmbeddedFlowComponent, data?: Record<string, any
|
|
28
|
+
onSubmit?: (component: EmbeddedFlowComponent, data?: Record<string, any>, skipValidation?: boolean) => void;
|
|
29
29
|
size?: "small" | "medium" | "large";
|
|
30
30
|
variant?: any;
|
|
31
31
|
}) => ReactElement[];
|
|
@@ -36,7 +36,7 @@ export declare const renderSignUpComponents: (components: EmbeddedFlowComponent[
|
|
|
36
36
|
buttonClassName?: string;
|
|
37
37
|
inputClassName?: string;
|
|
38
38
|
onInputBlur?: (name: string) => void;
|
|
39
|
-
onSubmit?: (component: EmbeddedFlowComponent, data?: Record<string, any
|
|
39
|
+
onSubmit?: (component: EmbeddedFlowComponent, data?: Record<string, any>, skipValidation?: boolean) => void;
|
|
40
40
|
size?: "small" | "medium" | "large";
|
|
41
41
|
variant?: any;
|
|
42
42
|
}) => ReactElement[];
|
package/dist/index.js
CHANGED
|
@@ -6879,7 +6879,9 @@ import React from "react";
|
|
|
6879
6879
|
import {
|
|
6880
6880
|
AsgardeoRuntimeError as AsgardeoRuntimeError7,
|
|
6881
6881
|
FieldType as FieldType7,
|
|
6882
|
-
EmbeddedFlowComponentTypeV2 as EmbeddedFlowComponentType
|
|
6882
|
+
EmbeddedFlowComponentTypeV2 as EmbeddedFlowComponentType,
|
|
6883
|
+
EmbeddedFlowActionVariantV2 as EmbeddedFlowActionVariant,
|
|
6884
|
+
EmbeddedFlowEventTypeV2 as EmbeddedFlowEventType
|
|
6883
6885
|
} from "@asgardeo/browser";
|
|
6884
6886
|
|
|
6885
6887
|
// src/components/adapters/SmsOtpButton.tsx
|
|
@@ -6944,9 +6946,12 @@ var getTypographyVariant = (variant) => {
|
|
|
6944
6946
|
};
|
|
6945
6947
|
return variantMap[variant] || "h3";
|
|
6946
6948
|
};
|
|
6947
|
-
var matchesSocialProvider = (actionId, eventType, buttonText, provider, authType) => {
|
|
6949
|
+
var matchesSocialProvider = (actionId, eventType, buttonText, provider, authType, componentVariant) => {
|
|
6948
6950
|
const providerId = `${provider}_auth`;
|
|
6949
6951
|
const providerMatches = actionId === providerId || eventType === providerId;
|
|
6952
|
+
if (componentVariant?.toUpperCase() === EmbeddedFlowActionVariant.Social) {
|
|
6953
|
+
return buttonText.toLowerCase().includes(provider);
|
|
6954
|
+
}
|
|
6950
6955
|
if (authType === "signup") {
|
|
6951
6956
|
return providerMatches || buttonText.toLowerCase().includes(provider);
|
|
6952
6957
|
}
|
|
@@ -6981,6 +6986,11 @@ var createAuthComponentFromFlow = (component, formValues, touchedFields, formErr
|
|
|
6981
6986
|
return React.cloneElement(field, { key });
|
|
6982
6987
|
}
|
|
6983
6988
|
case EmbeddedFlowComponentType.Action: {
|
|
6989
|
+
const actionId = component.id;
|
|
6990
|
+
const eventType = component.eventType || "";
|
|
6991
|
+
const buttonText = component.label || "";
|
|
6992
|
+
const componentVariant = component.variant || "";
|
|
6993
|
+
const shouldSkipValidation = eventType.toUpperCase() === EmbeddedFlowEventType.Trigger;
|
|
6984
6994
|
const handleClick = () => {
|
|
6985
6995
|
if (options.onSubmit) {
|
|
6986
6996
|
const formData = {};
|
|
@@ -6989,28 +6999,25 @@ var createAuthComponentFromFlow = (component, formValues, touchedFields, formErr
|
|
|
6989
6999
|
formData[field] = formValues[field];
|
|
6990
7000
|
}
|
|
6991
7001
|
});
|
|
6992
|
-
options.onSubmit(component, formData);
|
|
7002
|
+
options.onSubmit(component, formData, shouldSkipValidation);
|
|
6993
7003
|
}
|
|
6994
7004
|
};
|
|
6995
|
-
|
|
6996
|
-
const eventType = component.eventType || "";
|
|
6997
|
-
const buttonText = component.label || "";
|
|
6998
|
-
if (matchesSocialProvider(actionId, eventType, buttonText, "google", authType)) {
|
|
7005
|
+
if (matchesSocialProvider(actionId, eventType, buttonText, "google", authType, componentVariant)) {
|
|
6999
7006
|
return /* @__PURE__ */ jsx55(GoogleButton_default, { onClick: handleClick, className: options.buttonClassName }, key);
|
|
7000
7007
|
}
|
|
7001
|
-
if (matchesSocialProvider(actionId, eventType, buttonText, "github", authType)) {
|
|
7008
|
+
if (matchesSocialProvider(actionId, eventType, buttonText, "github", authType, componentVariant)) {
|
|
7002
7009
|
return /* @__PURE__ */ jsx55(GitHubButton_default, { onClick: handleClick, className: options.buttonClassName }, key);
|
|
7003
7010
|
}
|
|
7004
|
-
if (matchesSocialProvider(actionId, eventType, buttonText, "facebook", authType)) {
|
|
7011
|
+
if (matchesSocialProvider(actionId, eventType, buttonText, "facebook", authType, componentVariant)) {
|
|
7005
7012
|
return /* @__PURE__ */ jsx55(FacebookButton_default, { onClick: handleClick, className: options.buttonClassName }, key);
|
|
7006
7013
|
}
|
|
7007
|
-
if (matchesSocialProvider(actionId, eventType, buttonText, "microsoft", authType)) {
|
|
7014
|
+
if (matchesSocialProvider(actionId, eventType, buttonText, "microsoft", authType, componentVariant)) {
|
|
7008
7015
|
return /* @__PURE__ */ jsx55(MicrosoftButton_default, { onClick: handleClick, className: options.buttonClassName }, key);
|
|
7009
7016
|
}
|
|
7010
|
-
if (matchesSocialProvider(actionId, eventType, buttonText, "linkedin", authType)) {
|
|
7017
|
+
if (matchesSocialProvider(actionId, eventType, buttonText, "linkedin", authType, componentVariant)) {
|
|
7011
7018
|
return /* @__PURE__ */ jsx55(LinkedInButton_default, { onClick: handleClick, className: options.buttonClassName }, key);
|
|
7012
7019
|
}
|
|
7013
|
-
if (matchesSocialProvider(actionId, eventType, buttonText, "ethereum", authType)) {
|
|
7020
|
+
if (matchesSocialProvider(actionId, eventType, buttonText, "ethereum", authType, componentVariant)) {
|
|
7014
7021
|
return /* @__PURE__ */ jsx55(SignInWithEthereumButton_default, { onClick: handleClick, className: options.buttonClassName }, key);
|
|
7015
7022
|
}
|
|
7016
7023
|
if (actionId === "prompt_mobile" || eventType === "prompt_mobile") {
|
|
@@ -7034,6 +7041,9 @@ var createAuthComponentFromFlow = (component, formValues, touchedFields, formErr
|
|
|
7034
7041
|
const variant = getTypographyVariant(component.variant);
|
|
7035
7042
|
return /* @__PURE__ */ jsx55(Typography_default, { variant, children: component.label || "" }, key);
|
|
7036
7043
|
}
|
|
7044
|
+
case EmbeddedFlowComponentType.Divider: {
|
|
7045
|
+
return /* @__PURE__ */ jsx55(Divider_default, { children: component.label || "" }, key);
|
|
7046
|
+
}
|
|
7037
7047
|
case EmbeddedFlowComponentType.Block: {
|
|
7038
7048
|
if (component.components && component.components.length > 0) {
|
|
7039
7049
|
const blockComponents = component.components.map(
|
|
@@ -7052,7 +7062,7 @@ var createAuthComponentFromFlow = (component, formValues, touchedFields, formErr
|
|
|
7052
7062
|
}
|
|
7053
7063
|
)
|
|
7054
7064
|
).filter(Boolean);
|
|
7055
|
-
return /* @__PURE__ */ jsx55("
|
|
7065
|
+
return /* @__PURE__ */ jsx55("form", { id: component.id, children: blockComponents }, key);
|
|
7056
7066
|
}
|
|
7057
7067
|
return null;
|
|
7058
7068
|
}
|
|
@@ -7159,12 +7169,12 @@ var resolveTranslationsInArray = (items, t, properties) => {
|
|
|
7159
7169
|
var resolveTranslationsInArray_default = resolveTranslationsInArray;
|
|
7160
7170
|
|
|
7161
7171
|
// src/utils/v2/flowTransformer.ts
|
|
7162
|
-
var transformComponents = (response, t) => {
|
|
7172
|
+
var transformComponents = (response, t, resolveTranslations = true) => {
|
|
7163
7173
|
if (!response?.data?.meta?.components) {
|
|
7164
7174
|
return [];
|
|
7165
7175
|
}
|
|
7166
7176
|
const components = response.data.meta.components;
|
|
7167
|
-
return resolveTranslationsInArray_default(components, t);
|
|
7177
|
+
return resolveTranslations ? resolveTranslationsInArray_default(components, t) : components;
|
|
7168
7178
|
};
|
|
7169
7179
|
var extractErrorMessage = (error, t, defaultErrorKey = "errors.flow.generic") => {
|
|
7170
7180
|
if (error && typeof error === "object" && error.failureReason) {
|
|
@@ -7179,14 +7189,14 @@ var checkForErrorResponse = (response, t, defaultErrorKey = "errors.flow.generic
|
|
|
7179
7189
|
return null;
|
|
7180
7190
|
};
|
|
7181
7191
|
var normalizeFlowResponse = (response, t, options = {}) => {
|
|
7182
|
-
const { throwOnError = true, defaultErrorKey = "errors.flow.generic" } = options;
|
|
7192
|
+
const { throwOnError = true, defaultErrorKey = "errors.flow.generic", resolveTranslations = true } = options;
|
|
7183
7193
|
const errorMessage = checkForErrorResponse(response, t, defaultErrorKey);
|
|
7184
7194
|
if (errorMessage && throwOnError) {
|
|
7185
7195
|
throw response;
|
|
7186
7196
|
}
|
|
7187
7197
|
return {
|
|
7188
7198
|
flowId: response.flowId,
|
|
7189
|
-
components: transformComponents(response, t)
|
|
7199
|
+
components: transformComponents(response, t, resolveTranslations)
|
|
7190
7200
|
};
|
|
7191
7201
|
};
|
|
7192
7202
|
|
|
@@ -7348,11 +7358,13 @@ var BaseSignInContent2 = ({
|
|
|
7348
7358
|
const handleInputBlur = (name) => {
|
|
7349
7359
|
setFormTouched(name, true);
|
|
7350
7360
|
};
|
|
7351
|
-
const handleSubmit = async (component, data) => {
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7361
|
+
const handleSubmit = async (component, data, skipValidation) => {
|
|
7362
|
+
if (!skipValidation) {
|
|
7363
|
+
touchAllFields();
|
|
7364
|
+
const validation = validateForm();
|
|
7365
|
+
if (!validation.isValid) {
|
|
7366
|
+
return;
|
|
7367
|
+
}
|
|
7356
7368
|
}
|
|
7357
7369
|
setIsSubmitting(true);
|
|
7358
7370
|
clearMessages();
|
|
@@ -7654,7 +7666,9 @@ var SignIn = ({ className, size = "medium", onSuccess, onError, variant, childre
|
|
|
7654
7666
|
if (handleRedirection(response)) {
|
|
7655
7667
|
return;
|
|
7656
7668
|
}
|
|
7657
|
-
const { flowId, components: components2 } = normalizeFlowResponse(response, t
|
|
7669
|
+
const { flowId, components: components2 } = normalizeFlowResponse(response, t, {
|
|
7670
|
+
resolveTranslations: !children
|
|
7671
|
+
});
|
|
7658
7672
|
if (flowId && components2) {
|
|
7659
7673
|
setFlowId(flowId);
|
|
7660
7674
|
setComponents(components2);
|
|
@@ -7690,7 +7704,9 @@ var SignIn = ({ className, size = "medium", onSuccess, onError, variant, childre
|
|
|
7690
7704
|
if (handleRedirection(response)) {
|
|
7691
7705
|
return;
|
|
7692
7706
|
}
|
|
7693
|
-
const { flowId, components: components2 } = normalizeFlowResponse(response, t
|
|
7707
|
+
const { flowId, components: components2 } = normalizeFlowResponse(response, t, {
|
|
7708
|
+
resolveTranslations: !children
|
|
7709
|
+
});
|
|
7694
7710
|
if (response.flowStatus === EmbeddedSignInFlowStatusV2.Error) {
|
|
7695
7711
|
console.error("[SignIn] Flow returned Error status, clearing flow state");
|
|
7696
7712
|
clearFlowState();
|
|
@@ -9055,7 +9071,8 @@ var BaseSignUpContent2 = ({
|
|
|
9055
9071
|
if (response?.data) {
|
|
9056
9072
|
try {
|
|
9057
9073
|
const { components } = normalizeFlowResponse(response, t, {
|
|
9058
|
-
defaultErrorKey: "components.signUp.errors.generic"
|
|
9074
|
+
defaultErrorKey: "components.signUp.errors.generic",
|
|
9075
|
+
resolveTranslations: !children
|
|
9059
9076
|
});
|
|
9060
9077
|
return {
|
|
9061
9078
|
...response,
|
|
@@ -9070,7 +9087,7 @@ var BaseSignUpContent2 = ({
|
|
|
9070
9087
|
}
|
|
9071
9088
|
return response;
|
|
9072
9089
|
},
|
|
9073
|
-
[t]
|
|
9090
|
+
[t, children]
|
|
9074
9091
|
);
|
|
9075
9092
|
const extractFormFields = useCallback12(
|
|
9076
9093
|
(components) => {
|
|
@@ -9145,10 +9162,17 @@ var BaseSignUpContent2 = ({
|
|
|
9145
9162
|
setFormValue(name, value);
|
|
9146
9163
|
setFormTouched(name, true);
|
|
9147
9164
|
};
|
|
9148
|
-
const handleSubmit = async (component, data) => {
|
|
9165
|
+
const handleSubmit = async (component, data, skipValidation) => {
|
|
9149
9166
|
if (!currentFlow) {
|
|
9150
9167
|
return;
|
|
9151
9168
|
}
|
|
9169
|
+
if (!skipValidation) {
|
|
9170
|
+
touchAllFields();
|
|
9171
|
+
const validation = validateForm();
|
|
9172
|
+
if (!validation.isValid) {
|
|
9173
|
+
return;
|
|
9174
|
+
}
|
|
9175
|
+
}
|
|
9152
9176
|
setIsLoading(true);
|
|
9153
9177
|
clearMessages();
|
|
9154
9178
|
try {
|