@dropins/storefront-auth 3.0.0 → 3.1.0-beta2
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/api/getCustomerToken/getCustomerToken.d.ts +3 -1
- package/chunks/SignInForm.js +1 -1
- package/chunks/SignInForm.js.map +1 -1
- package/chunks/getCustomerToken.js +4 -4
- package/chunks/getCustomerToken.js.map +1 -1
- package/containers/SignIn.js +1 -1
- package/containers/SignIn.js.map +1 -1
- package/hooks/components/useSignInForm.d.ts +1 -1
- package/package.json +1 -1
- package/types/signIn.types.d.ts +1 -0
|
@@ -6,9 +6,11 @@ interface getCustomerTokenProps {
|
|
|
6
6
|
handleSetInLineAlertProps: (value?: InLineAlertInterface) => void;
|
|
7
7
|
translations: Record<string, string>;
|
|
8
8
|
onErrorCallback?: (value?: unknown) => void;
|
|
9
|
+
apiErrorMessageOverride?: string;
|
|
9
10
|
}
|
|
10
|
-
export declare const getCustomerToken: ({ email, password, translations, onErrorCallback, handleSetInLineAlertProps, }: getCustomerTokenProps) => Promise<{
|
|
11
|
+
export declare const getCustomerToken: ({ email, password, translations, onErrorCallback, handleSetInLineAlertProps, apiErrorMessageOverride, }: getCustomerTokenProps) => Promise<{
|
|
11
12
|
errorMessage: string;
|
|
13
|
+
displayErrorMessage: string;
|
|
12
14
|
userName: string;
|
|
13
15
|
userEmail: string;
|
|
14
16
|
}>;
|
package/chunks/SignInForm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2026 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as m,jsxs as
|
|
3
|
+
import{jsx as m,jsxs as L}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as O,classes as R}from"@dropins/tools/lib.js";import{c as E,g as tt,u as rt,B as $}from"./Button2.js";import{useState as y,useCallback as c,useEffect as Q,useMemo as at}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{a as ot}from"./getCustomerToken.js";import{r as et}from"./resendConfirmationEmail.js";import{s as it,a as st}from"./simplifyTransformAttributesForm.js";import{f as nt,E as ut}from"./focusOnEmptyPasswordField.js";import{c as mt}from"./confirmEmail.js";import{useText as ct}from"@dropins/tools/i18n.js";import{Header as ft,InLineAlert as dt,InputPassword as lt}from"@dropins/tools/components.js";import{u as ht,F as gt}from"./Button.js";const wt=({emailConfirmationStatusMessage:t,translations:o,initialEmailValue:s,routeSignUp:l,routeForgotPassword:u,routeRedirectOnSignIn:F,onErrorCallback:_,setActiveComponent:a,onSuccessCallback:f,onSignUpLinkClick:h,handleSetInLineAlertProps:i,routeRedirectOnEmailConfirmationClose:b,apiErrorMessageOverride:A})=>{const[M,v]=y(""),[U,n]=y(!1),[g,d]=y(""),[P,w]=y(!1),[j,q]=y({userName:"",status:!1}),[V,x]=y(!1),[k,N]=y([]),p=c(async r=>{i(),n(!0),w(!1),N([]),await et(r)},[i]),D=c(r=>{r.length?w(!1):w(!0),d(r)},[]);Q(()=>{t!=null&&t.text&&i({text:t.text,type:t.status?t.status:void 0})},[t,i]);const G=c(()=>{g.length||w(!0)},[g]),B=c((r,e)=>g.length?!1:(w(!0),e&&nt(r,g,""),!0),[g]),C=c((r,e)=>{e!=null&&e.userName&&(r.target.reset(),E(F)?window.location.href=F():(f==null||f({userName:e==null?void 0:e.userName,status:!0}),q({userName:e==null?void 0:e.userName,status:!0})))},[f,F]),S=c((r,e)=>{var I;if((I=r==null?void 0:r.errorMessage)!=null&&I.length){v(e);const K=r.errorMessage.includes("This account isn't confirmed. Verify and try again."),T=K?o.resendEmailInformationText:r.displayErrorMessage;N(K?[{label:o.resendEmailButtonText,onClick:()=>{p(e)}}]:[]),i({text:T,type:"error"}),d("")}},[p,i,o.resendEmailButtonText,o.resendEmailInformationText]),H=c(async(r,e)=>{if(i(),B(r,e))return;x(!0);const I=tt(r.target);if(Object.values(I).every(T=>T)){const{email:T,password:z}=I,J=await ot({email:T,password:z,handleSetInLineAlertProps:i,onErrorCallback:_,translations:o,apiErrorMessageOverride:A});S(J,T),C(r,J),w(!1)}x(!1)},[o,_,B,S,C,i,A]),W=c(()=>{if(E(a)){a("resetPasswordForm");return}E(u)&&(window.location.href=u())},[u,a]),X=c(()=>{if(E(h)&&h(),E(a)){a("signUpForm");return}E(l)&&(window.location.href=l())},[h,l,a]),Y=at(()=>{const r=it(st);return s!=null&&s.length?r==null?void 0:r.map(e=>({...e,defaultValue:s})):r},[s]),Z=c(()=>{i(),E(b)?window.location.href=b():n(!1)},[i,b]);return{additionalActionsAlert:k,userEmail:M,defaultEnhancedEmailFields:Y,passwordError:P,isSuccessful:j,isLoading:V,signInPasswordValue:g,showEmailConfirmationForm:U,setShowEmailConfirmationForm:n,setSignInPasswordValue:d,submitLogInUser:H,forgotPasswordCallback:W,onSignUpLinkClickCallback:X,handledOnPrimaryButtonClick:Z,handleSetPassword:D,onBlurPassword:G}},yt=()=>{let t=new URL(window.location.href),o=t.searchParams.get("email"),s=t.searchParams.get("key");o&&s&&(t.searchParams.delete("email"),t.searchParams.delete("key"),window.history.replaceState({},document.title,t.toString()))},_t=({enableEmailConfirmation:t})=>{const o=ct({accountConfirmMessage:"Auth.EmailConfirmationForm.accountConfirmMessage",accountConfirmationEmailSuccessMessage:"Auth.EmailConfirmationForm.accountConfirmationEmailSuccessMessage"}),[s,l]=y({text:"",status:""});return Q(()=>{if(t){const{search:u}=window.location;u.includes("email=")&&u.includes("key=")&&(async()=>{var f,h,i;const _=new URLSearchParams(u),a=await mt({customerEmail:_.get("email"),customerConfirmationKey:_.get("key")});if(!a)return null;(f=a==null?void 0:a.errors)!=null&&f.length?l({text:a==null?void 0:a.errors[0].message,status:"error"}):(l({text:a.data.confirmEmail.customer.email?o.accountConfirmationEmailSuccessMessage.replace("{email}",(i=(h=a==null?void 0:a.data)==null?void 0:h.confirmEmail.customer)==null?void 0:i.email):o.accountConfirmMessage,status:"success"}),yt())})()}},[t,o]),{emailConfirmationStatusMessage:s}},Lt=({slots:t,labels:o,formSize:s="default",initialEmailValue:l="",renderSignUpLink:u=!1,enableEmailConfirmation:F=!1,hideCloseBtnOnEmailConfirmation:_=!1,routeRedirectOnEmailConfirmationClose:a,routeRedirectOnSignIn:f,routeForgotPassword:h,routeSignUp:i,onSuccessCallback:b,setActiveComponent:A,onErrorCallback:M,onSignUpLinkClick:v,apiErrorMessageOverride:U})=>{const n=ht({title:"Auth.SignInForm.title",buttonPrimary:"Auth.SignInForm.buttonPrimary",buttonSecondary:"Auth.SignInForm.buttonSecondary",buttonTertiary:"Auth.SignInForm.buttonTertiary",resendEmailInformationText:"Auth.Notification.resendEmailNotification.informationText",resendEmailButtonText:"Auth.Notification.resendEmailNotification.buttonText",customerTokenErrorMessage:"Auth.Api.customerTokenErrorMessage",placeholder:"Auth.InputPassword.placeholder",floatingLabel:"Auth.InputPassword.floatingLabel",requiredFieldError:"Auth.FormText.requiredFieldError.default"}),{emailConfirmationStatusMessage:g}=_t({enableEmailConfirmation:F}),{inLineAlertProps:d,handleSetInLineAlertProps:P}=rt(),{userEmail:w,additionalActionsAlert:j,defaultEnhancedEmailFields:q,passwordError:V,isSuccessful:x,isLoading:k,signInPasswordValue:N,showEmailConfirmationForm:p,submitLogInUser:D,forgotPasswordCallback:G,onSignUpLinkClickCallback:B,handledOnPrimaryButtonClick:C,handleSetPassword:S,onBlurPassword:H}=wt({translations:n,emailConfirmationStatusMessage:g,initialEmailValue:l,routeSignUp:i,routeForgotPassword:h,routeRedirectOnSignIn:f,setActiveComponent:A,onErrorCallback:M,onSuccessCallback:b,onSignUpLinkClick:v,handleSetInLineAlertProps:P,routeRedirectOnEmailConfirmationClose:a,apiErrorMessageOverride:U});return x.status&&(t!=null&&t.SuccessNotification)?m(O,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:t==null?void 0:t.SuccessNotification,context:{isSuccessful:x}}):p?m(ut,{formSize:s,userEmail:w,inLineAlertProps:d,hideCloseBtnOnEmailConfirmation:_,handleSetInLineAlertProps:P,onPrimaryButtonClick:C}):L("div",{className:R(["auth-sign-in-form",`auth-sign-in-form--${s}`]),"data-testid":"signInForm",children:[m(ft,{title:(o==null?void 0:o.formTitleText)??n.title,divider:!1,className:"auth-sign-in-form__title"}),d.text?m(dt,{"data-testid":"authInLineAlert",className:"auth-sign-in-form__notification",type:d.type,variant:"secondary",heading:d.text,icon:d.icon,additionalActions:j}):null,L(gt,{name:"signIn_form",className:"auth-sign-in-form__form",onSubmit:D,loading:k,fieldsConfig:q,children:[m(lt,{hideStatusIndicator:!0,className:"auth-sign-in-form__form__password",autoComplete:"current-password",errorMessage:V?n.requiredFieldError:void 0,defaultValue:N,onValue:S,onBlur:H,placeholder:n.placeholder,floatingLabel:n.floatingLabel}),L("div",{className:"auth-sign-in-form__form__buttons",children:[L("div",{className:"auth-sign-in-form__form__buttons__combine",children:[m($,{type:"button",variant:"tertiary",style:{padding:0},buttonText:n.buttonTertiary,className:"auth-sign-in-form__button auth-sign-in-form__button--forgot",enableLoader:!1,onClick:G,"data-testid":"switchToSignUp"}),u?m("span",{}):null,u?m($,{type:"button",variant:"tertiary",style:{padding:0},buttonText:n.buttonSecondary,className:"auth-sign-in-form__button auth-sign-in-form__button--signup",enableLoader:!1,onClick:B}):null]}),m($,{type:"submit",buttonText:(o==null?void 0:o.primaryButtonText)??n.buttonPrimary,variant:"primary",className:"auth-sign-in-form__button auth-sign-in-form__button--submit",enableLoader:k})]})]}),m("div",{id:"generateCustomerToken"})]})};export{Lt as S};
|
|
4
4
|
//# sourceMappingURL=SignInForm.js.map
|
package/chunks/SignInForm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignInForm.js","sources":["/@dropins/storefront-auth/src/hooks/components/useSignInForm.tsx","/@dropins/storefront-auth/src/lib/clearUrlAndReplace.ts","/@dropins/storefront-auth/src/hooks/useEmailConfirmation.tsx","/@dropins/storefront-auth/src/components/SignInForm/SignInForm.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { getFormValues } from '@/auth/lib/getFormValues';\nimport { useCallback, useState, useMemo, useEffect } from 'preact/hooks';\nimport { getCustomerToken, resendConfirmationEmail } from '@/auth/api';\nimport { AdditionalActionsAlertProps, useSignInFormProps } from '@/auth/types';\nimport { DEFAULT__SIGN_IN_EMAIL_FIELD } from '@/auth/configs/defaultCreateUserConfigs';\nimport { simplifyTransformAttributesForm } from '@/auth/lib/simplifyTransformAttributesForm';\nimport { checkIsFunction } from '@/auth/lib/checkIsFunction';\nimport { focusOnEmptyPasswordField } from '@/auth/lib/focusOnEmptyPasswordField';\n\nexport const useSignInForm = ({\n emailConfirmationStatusMessage,\n translations,\n initialEmailValue,\n routeSignUp,\n routeForgotPassword,\n routeRedirectOnSignIn,\n onErrorCallback,\n setActiveComponent,\n onSuccessCallback,\n onSignUpLinkClick,\n handleSetInLineAlertProps,\n routeRedirectOnEmailConfirmationClose,\n}: useSignInFormProps) => {\n const [userEmail, setUserEmail] = useState('');\n const [showEmailConfirmationForm, setShowEmailConfirmationForm] =\n useState(false);\n const [signInPasswordValue, setSignInPasswordValue] = useState('');\n const [passwordError, setPasswordError] = useState(false);\n const [isSuccessful, setIsSuccessful] = useState({\n userName: '',\n status: false,\n });\n const [isLoading, setIsLoading] = useState(false);\n const [additionalActionsAlert, setAdditionalActionsAlert] =\n useState<AdditionalActionsAlertProps>([]);\n\n const actionsShowNotificationForm = useCallback(\n async (email: string) => {\n handleSetInLineAlertProps();\n setShowEmailConfirmationForm(true);\n setPasswordError(false);\n setAdditionalActionsAlert([]);\n\n await resendConfirmationEmail(email);\n },\n [handleSetInLineAlertProps]\n );\n\n const handleSetPassword = useCallback((value: string) => {\n if (value.length) {\n setPasswordError(false);\n } else {\n setPasswordError(true);\n }\n setSignInPasswordValue(value);\n }, []);\n\n useEffect(() => {\n if (emailConfirmationStatusMessage?.text) {\n handleSetInLineAlertProps({\n text: emailConfirmationStatusMessage.text,\n type: emailConfirmationStatusMessage.status\n ? emailConfirmationStatusMessage.status\n : undefined,\n });\n }\n }, [emailConfirmationStatusMessage, handleSetInLineAlertProps]);\n\n const onBlurPassword = useCallback(() => {\n if (!signInPasswordValue.length) {\n setPasswordError(true);\n }\n }, [signInPasswordValue]);\n\n const checkPasswordAndFocus = useCallback(\n (event: SubmitEvent, isValid: boolean): boolean => {\n if (!signInPasswordValue.length) {\n setPasswordError(true);\n\n if (!isValid) return true;\n\n focusOnEmptyPasswordField(event, signInPasswordValue, '');\n return true;\n }\n\n return false;\n },\n [signInPasswordValue]\n );\n\n const onAuthenticationSuccess = useCallback(\n (event: SubmitEvent, loginResponse: Record<string, string>) => {\n if (loginResponse?.userName) {\n (event.target as HTMLFormElement).reset();\n\n if (checkIsFunction(routeRedirectOnSignIn)) {\n window.location.href = routeRedirectOnSignIn();\n } else {\n onSuccessCallback?.({\n userName: loginResponse?.userName,\n status: true,\n });\n\n setIsSuccessful({\n userName: loginResponse?.userName,\n status: true,\n });\n }\n }\n },\n [onSuccessCallback, routeRedirectOnSignIn]\n );\n\n const onAuthenticationFailed = useCallback(\n (loginResponse: { errorMessage: string }, email: string) => {\n if (loginResponse?.errorMessage?.length) {\n setUserEmail(email);\n\n /**\n * TODO: Use error code when available, instead of comparing to response text\n *\n * This implementation is a temporary solution.\n * The backend functionality is planned to be improved to obtain accurate data that will help correctly identify error types and handle them.\n */\n const isIncludesMessage = loginResponse.errorMessage.includes(\n \"This account isn't confirmed. Verify and try again.\"\n );\n\n const errorMessage: string = isIncludesMessage\n ? translations.resendEmailInformationText\n : loginResponse.errorMessage;\n\n if (isIncludesMessage) {\n setAdditionalActionsAlert([\n {\n label: translations.resendEmailButtonText,\n onClick: () => {\n actionsShowNotificationForm(email);\n },\n },\n ]);\n } else {\n setAdditionalActionsAlert([]);\n }\n\n handleSetInLineAlertProps({\n text: errorMessage,\n type: 'error',\n });\n\n setSignInPasswordValue('');\n }\n },\n [\n actionsShowNotificationForm,\n handleSetInLineAlertProps,\n translations.resendEmailButtonText,\n translations.resendEmailInformationText,\n ]\n );\n\n const submitLogInUser = useCallback(\n async (event: SubmitEvent, isValid: boolean): Promise<void> => {\n handleSetInLineAlertProps();\n\n if (checkPasswordAndFocus(event, isValid)) return;\n\n setIsLoading(true);\n\n const formValues = getFormValues(event.target);\n const isFormComplete = Object.values(formValues).every((value) => value);\n\n if (isFormComplete) {\n const { email, password } = formValues;\n\n const loginResponse = await getCustomerToken({\n email,\n password,\n handleSetInLineAlertProps,\n onErrorCallback,\n translations,\n });\n\n onAuthenticationFailed(loginResponse, email);\n onAuthenticationSuccess(event, loginResponse);\n\n setPasswordError(false);\n }\n\n setIsLoading(false);\n },\n [\n translations,\n onErrorCallback,\n checkPasswordAndFocus,\n onAuthenticationFailed,\n onAuthenticationSuccess,\n handleSetInLineAlertProps,\n ]\n );\n\n const forgotPasswordCallback = useCallback(() => {\n if (checkIsFunction(setActiveComponent)) {\n setActiveComponent('resetPasswordForm');\n\n return;\n }\n\n if (checkIsFunction(routeForgotPassword)) {\n window.location.href = routeForgotPassword();\n }\n }, [routeForgotPassword, setActiveComponent]);\n\n const onSignUpLinkClickCallback = useCallback(() => {\n if (checkIsFunction(onSignUpLinkClick)) {\n onSignUpLinkClick();\n }\n\n if (checkIsFunction(setActiveComponent)) {\n setActiveComponent('signUpForm');\n\n return;\n }\n\n if (checkIsFunction(routeSignUp)) {\n window.location.href = routeSignUp();\n }\n }, [onSignUpLinkClick, routeSignUp, setActiveComponent]);\n\n const defaultEnhancedEmailFields: any = useMemo(() => {\n const fieldsList = simplifyTransformAttributesForm(\n DEFAULT__SIGN_IN_EMAIL_FIELD\n );\n\n if (!initialEmailValue?.length) return fieldsList;\n\n return fieldsList?.map((el: any) => ({\n ...el,\n defaultValue: initialEmailValue,\n }));\n }, [initialEmailValue]);\n\n const handledOnPrimaryButtonClick = useCallback(() => {\n handleSetInLineAlertProps();\n\n if (checkIsFunction(routeRedirectOnEmailConfirmationClose)) {\n window.location.href = routeRedirectOnEmailConfirmationClose();\n } else {\n setShowEmailConfirmationForm(false);\n }\n }, [handleSetInLineAlertProps, routeRedirectOnEmailConfirmationClose]);\n\n return {\n additionalActionsAlert,\n userEmail,\n defaultEnhancedEmailFields,\n passwordError,\n isSuccessful,\n isLoading,\n signInPasswordValue,\n showEmailConfirmationForm,\n setShowEmailConfirmationForm,\n setSignInPasswordValue,\n submitLogInUser,\n forgotPasswordCallback,\n onSignUpLinkClickCallback,\n handledOnPrimaryButtonClick,\n handleSetPassword,\n onBlurPassword,\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const clearUrlAndReplace = () => {\n let url = new URL(window.location.href);\n\n let email = url.searchParams.get('email');\n let token = url.searchParams.get('key');\n\n if (email && token) {\n url.searchParams.delete('email');\n url.searchParams.delete('key');\n\n window.history.replaceState({}, document.title, url.toString());\n }\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { useEffect, useState } from 'preact/hooks';\nimport { clearUrlAndReplace } from '../lib/clearUrlAndReplace';\nimport { confirmEmail } from '../api';\nimport { useText } from '@adobe-commerce/elsie/i18n';\n\ninterface useEmailConfirmationProps {\n enableEmailConfirmation: boolean;\n}\n\n// The client receives a confirmation of the validation via email. When the client follows the provided link, they are directed to the login page with three query parameters. If these parameters are present, we make a request to validate the status. This request returns a response that we display to the user.\nexport const useEmailConfirmation = ({\n enableEmailConfirmation,\n}: useEmailConfirmationProps) => {\n const translations = useText({\n accountConfirmMessage: 'Auth.EmailConfirmationForm.accountConfirmMessage',\n accountConfirmationEmailSuccessMessage:\n 'Auth.EmailConfirmationForm.accountConfirmationEmailSuccessMessage',\n });\n const [emailConfirmationStatusMessage, setEmailConfirmationStatusMessage] =\n useState<{\n text: string;\n status: '' | 'success' | 'error';\n }>({\n text: '',\n status: '',\n });\n\n useEffect(() => {\n if (enableEmailConfirmation) {\n const { search } = window.location;\n\n if (search.includes('email=') && search.includes('key=')) {\n const validateEmailStatus = async () => {\n const params = new URLSearchParams(search);\n\n const response = await confirmEmail({\n customerEmail: params.get('email') as string,\n customerConfirmationKey: params.get('key') as string,\n });\n\n if (!response) return null;\n\n if (response?.errors?.length) {\n setEmailConfirmationStatusMessage({\n text: response?.errors[0].message,\n status: 'error',\n });\n } else {\n setEmailConfirmationStatusMessage({\n text: response.data.confirmEmail.customer.email\n ? translations.accountConfirmationEmailSuccessMessage.replace(\n '{email}',\n response?.data?.confirmEmail.customer?.email\n )\n : translations.accountConfirmMessage,\n status: 'success',\n });\n\n clearUrlAndReplace();\n }\n };\n\n validateEmailStatus();\n }\n }\n }, [enableEmailConfirmation, translations]);\n\n return { emailConfirmationStatusMessage };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FunctionComponent } from 'preact';\nimport { classes, Slot } from '@adobe-commerce/elsie/lib';\nimport { useSignInForm } from '@/auth/hooks/components/useSignInForm';\nimport { SignInFormProps } from '@/auth/types';\nimport { useEmailConfirmation } from '@/auth/hooks/useEmailConfirmation';\nimport { Form, Button, EmailConfirmationForm } from '@/auth/components';\nimport { useInLineAlert } from '@/auth/hooks/useInLineAlert';\nimport { Header, InLineAlert, InputPassword } from '@adobe-commerce/elsie/components';\nimport '@/auth/components/SignInForm/SignInForm.css';\nimport { useCustomTranslations } from '@/auth/hooks/useCustomTranslations';\n\nexport const SignInForm: FunctionComponent<SignInFormProps> = ({\n slots,\n labels,\n formSize = 'default',\n initialEmailValue = '',\n renderSignUpLink = false,\n enableEmailConfirmation = false,\n hideCloseBtnOnEmailConfirmation = false,\n routeRedirectOnEmailConfirmationClose,\n routeRedirectOnSignIn,\n routeForgotPassword,\n routeSignUp,\n onSuccessCallback,\n setActiveComponent,\n onErrorCallback,\n onSignUpLinkClick,\n}) => {\n /**\n * useCustomTranslations is required to support extensibility of error messages.\n * Ensure all error-related translation paths include \".default\"\n * to allow future handling of dynamic or nested error messages.\n */\n const translations = useCustomTranslations({\n title: 'Auth.SignInForm.title',\n buttonPrimary: 'Auth.SignInForm.buttonPrimary',\n buttonSecondary: 'Auth.SignInForm.buttonSecondary',\n buttonTertiary: 'Auth.SignInForm.buttonTertiary',\n resendEmailInformationText:\n 'Auth.Notification.resendEmailNotification.informationText',\n resendEmailButtonText:\n 'Auth.Notification.resendEmailNotification.buttonText',\n customerTokenErrorMessage: 'Auth.Api.customerTokenErrorMessage',\n placeholder: 'Auth.InputPassword.placeholder',\n floatingLabel: 'Auth.InputPassword.floatingLabel',\n requiredFieldError: 'Auth.FormText.requiredFieldError.default',\n });\n\n const { emailConfirmationStatusMessage } = useEmailConfirmation({\n enableEmailConfirmation,\n });\n\n const { inLineAlertProps, handleSetInLineAlertProps } = useInLineAlert();\n\n const {\n userEmail,\n additionalActionsAlert,\n defaultEnhancedEmailFields,\n passwordError,\n isSuccessful,\n isLoading,\n signInPasswordValue,\n showEmailConfirmationForm,\n submitLogInUser,\n forgotPasswordCallback,\n onSignUpLinkClickCallback,\n handledOnPrimaryButtonClick,\n handleSetPassword,\n onBlurPassword,\n } = useSignInForm({\n translations,\n emailConfirmationStatusMessage,\n initialEmailValue,\n routeSignUp,\n routeForgotPassword,\n routeRedirectOnSignIn,\n setActiveComponent,\n onErrorCallback,\n onSuccessCallback,\n onSignUpLinkClick,\n handleSetInLineAlertProps,\n routeRedirectOnEmailConfirmationClose,\n });\n\n if (isSuccessful.status && slots?.SuccessNotification) {\n return (\n <Slot\n data-testid=\"successNotificationTestId\"\n name=\"SuccessNotification\"\n slot={slots?.SuccessNotification}\n context={{ isSuccessful }}\n />\n );\n }\n\n if (showEmailConfirmationForm) {\n return (\n <EmailConfirmationForm\n formSize={formSize}\n userEmail={userEmail}\n inLineAlertProps={inLineAlertProps}\n hideCloseBtnOnEmailConfirmation={hideCloseBtnOnEmailConfirmation}\n handleSetInLineAlertProps={handleSetInLineAlertProps}\n onPrimaryButtonClick={handledOnPrimaryButtonClick}\n />\n );\n }\n\n return (\n <div\n className={classes([\n 'auth-sign-in-form',\n `auth-sign-in-form--${formSize}`,\n ])}\n data-testid=\"signInForm\"\n >\n <Header\n title={labels?.formTitleText ?? translations.title}\n divider={false}\n className=\"auth-sign-in-form__title\"\n />\n {inLineAlertProps.text ? (\n <InLineAlert\n data-testid=\"authInLineAlert\"\n className=\"auth-sign-in-form__notification\"\n type={inLineAlertProps.type}\n variant=\"secondary\"\n heading={inLineAlertProps.text}\n icon={inLineAlertProps.icon}\n additionalActions={additionalActionsAlert}\n />\n ) : null}\n <Form\n name=\"signIn_form\"\n className=\"auth-sign-in-form__form\"\n onSubmit={submitLogInUser}\n loading={isLoading}\n fieldsConfig={defaultEnhancedEmailFields}\n >\n <InputPassword\n hideStatusIndicator\n className=\"auth-sign-in-form__form__password\"\n autoComplete={'current-password'}\n errorMessage={\n passwordError ? translations.requiredFieldError : undefined\n }\n defaultValue={signInPasswordValue}\n onValue={handleSetPassword}\n onBlur={onBlurPassword}\n placeholder={translations.placeholder}\n floatingLabel={translations.floatingLabel}\n />\n <div className=\"auth-sign-in-form__form__buttons\">\n <div className=\"auth-sign-in-form__form__buttons__combine\">\n <Button\n type=\"button\"\n variant=\"tertiary\"\n style={{ padding: 0 }}\n buttonText={translations.buttonTertiary}\n className=\"auth-sign-in-form__button auth-sign-in-form__button--forgot\"\n enableLoader={false}\n onClick={forgotPasswordCallback}\n data-testid=\"switchToSignUp\"\n />\n {renderSignUpLink ? <span /> : null}\n {renderSignUpLink ? (\n <Button\n type=\"button\"\n variant=\"tertiary\"\n style={{ padding: 0 }}\n buttonText={translations.buttonSecondary}\n className=\"auth-sign-in-form__button auth-sign-in-form__button--signup\"\n enableLoader={false}\n onClick={onSignUpLinkClickCallback}\n />\n ) : null}\n </div>\n <Button\n type=\"submit\"\n buttonText={labels?.primaryButtonText ?? translations.buttonPrimary}\n variant=\"primary\"\n className=\"auth-sign-in-form__button auth-sign-in-form__button--submit\"\n enableLoader={isLoading}\n />\n </div>\n </Form>\n <div id=\"generateCustomerToken\" />\n </div>\n );\n};\n"],"names":["useSignInForm","emailConfirmationStatusMessage","translations","initialEmailValue","routeSignUp","routeForgotPassword","routeRedirectOnSignIn","onErrorCallback","setActiveComponent","onSuccessCallback","onSignUpLinkClick","handleSetInLineAlertProps","routeRedirectOnEmailConfirmationClose","userEmail","setUserEmail","useState","showEmailConfirmationForm","setShowEmailConfirmationForm","signInPasswordValue","setSignInPasswordValue","passwordError","setPasswordError","isSuccessful","setIsSuccessful","isLoading","setIsLoading","additionalActionsAlert","setAdditionalActionsAlert","actionsShowNotificationForm","useCallback","email","resendConfirmationEmail","handleSetPassword","value","useEffect","onBlurPassword","checkPasswordAndFocus","event","isValid","focusOnEmptyPasswordField","onAuthenticationSuccess","loginResponse","checkIsFunction","onAuthenticationFailed","_a","isIncludesMessage","errorMessage","submitLogInUser","formValues","getFormValues","password","getCustomerToken","forgotPasswordCallback","onSignUpLinkClickCallback","defaultEnhancedEmailFields","useMemo","fieldsList","simplifyTransformAttributesForm","DEFAULT__SIGN_IN_EMAIL_FIELD","el","handledOnPrimaryButtonClick","clearUrlAndReplace","url","token","useEmailConfirmation","enableEmailConfirmation","useText","setEmailConfirmationStatusMessage","search","params","response","confirmEmail","_c","_b","SignInForm","slots","labels","formSize","renderSignUpLink","hideCloseBtnOnEmailConfirmation","useCustomTranslations","inLineAlertProps","useInLineAlert","jsx","Slot","EmailConfirmationForm","jsxs","classes","Header","InLineAlert","Form","InputPassword","Button"],"mappings":"gyBA0BO,MAAMA,GAAgB,CAAC,CAC5B,+BAAAC,EACA,aAAAC,EACA,kBAAAC,EACA,YAAAC,EACA,oBAAAC,EACA,sBAAAC,EACA,gBAAAC,EACA,mBAAAC,EACA,kBAAAC,EACA,kBAAAC,EACA,0BAAAC,EACA,sCAAAC,CACF,IAA0B,CACxB,KAAM,CAACC,EAAWC,CAAY,EAAIC,EAAS,EAAE,EACvC,CAACC,EAA2BC,CAA4B,EAC5DF,EAAS,EAAK,EACV,CAACG,EAAqBC,CAAsB,EAAIJ,EAAS,EAAE,EAC3D,CAACK,EAAeC,CAAgB,EAAIN,EAAS,EAAK,EAClD,CAACO,EAAcC,CAAe,EAAIR,EAAS,CAC/C,SAAU,GACV,OAAQ,EAAA,CACT,EACK,CAACS,EAAWC,CAAY,EAAIV,EAAS,EAAK,EAC1C,CAACW,EAAwBC,CAAyB,EACtDZ,EAAsC,CAAA,CAAE,EAEpCa,EAA8BC,EAClC,MAAOC,GAAkB,CACvBnB,EAAA,EACAM,EAA6B,E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AEd,SAAA,CAAA6B,EAACQ,GAAA,CACC,oBAAmB,GACnB,UAAU,oCACV,aAAc,mBACd,aACEvE,EAAgBlB,EAAa,mBAAqB,OAEpD,aAAcgB,EACd,QAASc,EACT,OAAQG,EACR,YAAajC,EAAa,YAC1B,cAAeA,EAAa,aAAA,CAAA,EAE9BoF,EAAC,MAAA,CAAI,UAAU,mCACb,SAAA,CAAAA,EAAC,MAAA,CAAI,UAAU,4CACb,SAAA,CAAAH,EAACS,EAAA,CACC,KAAK,SACL,QAAQ,WACR,MAAO,CAAE,QAAS,CAAA,EAClB,WAAY1F,EAAa,eACzB,UAAU,8DACV,aAAc,GACd,QAASkD,EACT,cAAY,gBAAA,CAAA,EAEb0B,EAAmBK,EAAC,OAAA,CAAA,CAAK,EAAK,KAC9BL,EACCK,EAACS,EAAA,CACC,KAAK,SACL,QAAQ,WACR,MAAO,CAAE,QAAS,CAAA,EAClB,WAAY1F,EAAa,gBACzB,UAAU,8DACV,aAAc,GACd,QAASmD,CAAA,CAAA,EAET,IAAA,EACN,EACA8B,EAACS,EAAA,CACC,KAAK,SACL,YAAYhB,GAAA,YAAAA,EAAQ,oBAAqB1E,EAAa,cACtD,QAAQ,UACR,UAAU,8DACV,aAAcsB,CAAA,CAAA,CAChB,CAAA,CACF,CAAA,CAAA,CAAA,EAEF2D,EAAC,MAAA,CAAI,GAAG,uBAAA,CAAwB,CAAA,CAAA,CAAA,CAGtC"}
|
|
1
|
+
{"version":3,"file":"SignInForm.js","sources":["/@dropins/storefront-auth/src/hooks/components/useSignInForm.tsx","/@dropins/storefront-auth/src/lib/clearUrlAndReplace.ts","/@dropins/storefront-auth/src/hooks/useEmailConfirmation.tsx","/@dropins/storefront-auth/src/components/SignInForm/SignInForm.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { getFormValues } from '@/auth/lib/getFormValues';\nimport { useCallback, useState, useMemo, useEffect } from 'preact/hooks';\nimport { getCustomerToken, resendConfirmationEmail } from '@/auth/api';\nimport { AdditionalActionsAlertProps, useSignInFormProps } from '@/auth/types';\nimport { DEFAULT__SIGN_IN_EMAIL_FIELD } from '@/auth/configs/defaultCreateUserConfigs';\nimport { simplifyTransformAttributesForm } from '@/auth/lib/simplifyTransformAttributesForm';\nimport { checkIsFunction } from '@/auth/lib/checkIsFunction';\nimport { focusOnEmptyPasswordField } from '@/auth/lib/focusOnEmptyPasswordField';\n\nexport const useSignInForm = ({\n emailConfirmationStatusMessage,\n translations,\n initialEmailValue,\n routeSignUp,\n routeForgotPassword,\n routeRedirectOnSignIn,\n onErrorCallback,\n setActiveComponent,\n onSuccessCallback,\n onSignUpLinkClick,\n handleSetInLineAlertProps,\n routeRedirectOnEmailConfirmationClose,\n apiErrorMessageOverride,\n}: useSignInFormProps) => {\n const [userEmail, setUserEmail] = useState('');\n const [showEmailConfirmationForm, setShowEmailConfirmationForm] =\n useState(false);\n const [signInPasswordValue, setSignInPasswordValue] = useState('');\n const [passwordError, setPasswordError] = useState(false);\n const [isSuccessful, setIsSuccessful] = useState({\n userName: '',\n status: false,\n });\n const [isLoading, setIsLoading] = useState(false);\n const [additionalActionsAlert, setAdditionalActionsAlert] =\n useState<AdditionalActionsAlertProps>([]);\n\n const actionsShowNotificationForm = useCallback(\n async (email: string) => {\n handleSetInLineAlertProps();\n setShowEmailConfirmationForm(true);\n setPasswordError(false);\n setAdditionalActionsAlert([]);\n\n await resendConfirmationEmail(email);\n },\n [handleSetInLineAlertProps]\n );\n\n const handleSetPassword = useCallback((value: string) => {\n if (value.length) {\n setPasswordError(false);\n } else {\n setPasswordError(true);\n }\n setSignInPasswordValue(value);\n }, []);\n\n useEffect(() => {\n if (emailConfirmationStatusMessage?.text) {\n handleSetInLineAlertProps({\n text: emailConfirmationStatusMessage.text,\n type: emailConfirmationStatusMessage.status\n ? emailConfirmationStatusMessage.status\n : undefined,\n });\n }\n }, [emailConfirmationStatusMessage, handleSetInLineAlertProps]);\n\n const onBlurPassword = useCallback(() => {\n if (!signInPasswordValue.length) {\n setPasswordError(true);\n }\n }, [signInPasswordValue]);\n\n const checkPasswordAndFocus = useCallback(\n (event: SubmitEvent, isValid: boolean): boolean => {\n if (!signInPasswordValue.length) {\n setPasswordError(true);\n\n if (!isValid) return true;\n\n focusOnEmptyPasswordField(event, signInPasswordValue, '');\n return true;\n }\n\n return false;\n },\n [signInPasswordValue]\n );\n\n const onAuthenticationSuccess = useCallback(\n (event: SubmitEvent, loginResponse: Record<string, string>) => {\n if (loginResponse?.userName) {\n (event.target as HTMLFormElement).reset();\n\n if (checkIsFunction(routeRedirectOnSignIn)) {\n window.location.href = routeRedirectOnSignIn();\n } else {\n onSuccessCallback?.({\n userName: loginResponse?.userName,\n status: true,\n });\n\n setIsSuccessful({\n userName: loginResponse?.userName,\n status: true,\n });\n }\n }\n },\n [onSuccessCallback, routeRedirectOnSignIn]\n );\n\n const onAuthenticationFailed = useCallback(\n (loginResponse: { errorMessage: string; displayErrorMessage: string }, email: string) => {\n if (loginResponse?.errorMessage?.length) {\n setUserEmail(email);\n\n /**\n * TODO: Use error code when available, instead of comparing to response text\n *\n * This implementation is a temporary solution.\n * The backend functionality is planned to be improved to obtain accurate data that will help correctly identify error types and handle them.\n */\n // Use original errorMessage for detection (not the override)\n const isIncludesMessage = loginResponse.errorMessage.includes(\n \"This account isn't confirmed. Verify and try again.\"\n );\n\n // Use displayErrorMessage for display (respects apiErrorMessageOverride)\n const errorMessage: string = isIncludesMessage\n ? translations.resendEmailInformationText\n : loginResponse.displayErrorMessage;\n\n if (isIncludesMessage) {\n setAdditionalActionsAlert([\n {\n label: translations.resendEmailButtonText,\n onClick: () => {\n actionsShowNotificationForm(email);\n },\n },\n ]);\n } else {\n setAdditionalActionsAlert([]);\n }\n\n handleSetInLineAlertProps({\n text: errorMessage,\n type: 'error',\n });\n\n setSignInPasswordValue('');\n }\n },\n [\n actionsShowNotificationForm,\n handleSetInLineAlertProps,\n translations.resendEmailButtonText,\n translations.resendEmailInformationText,\n ]\n );\n\n const submitLogInUser = useCallback(\n async (event: SubmitEvent, isValid: boolean): Promise<void> => {\n handleSetInLineAlertProps();\n\n if (checkPasswordAndFocus(event, isValid)) return;\n\n setIsLoading(true);\n\n const formValues = getFormValues(event.target);\n const isFormComplete = Object.values(formValues).every((value) => value);\n\n if (isFormComplete) {\n const { email, password } = formValues;\n\n const loginResponse = await getCustomerToken({\n email,\n password,\n handleSetInLineAlertProps,\n onErrorCallback,\n translations,\n apiErrorMessageOverride,\n });\n\n onAuthenticationFailed(loginResponse, email);\n onAuthenticationSuccess(event, loginResponse);\n\n setPasswordError(false);\n }\n\n setIsLoading(false);\n },\n [\n translations,\n onErrorCallback,\n checkPasswordAndFocus,\n onAuthenticationFailed,\n onAuthenticationSuccess,\n handleSetInLineAlertProps,\n apiErrorMessageOverride,\n ]\n );\n\n const forgotPasswordCallback = useCallback(() => {\n if (checkIsFunction(setActiveComponent)) {\n setActiveComponent('resetPasswordForm');\n\n return;\n }\n\n if (checkIsFunction(routeForgotPassword)) {\n window.location.href = routeForgotPassword();\n }\n }, [routeForgotPassword, setActiveComponent]);\n\n const onSignUpLinkClickCallback = useCallback(() => {\n if (checkIsFunction(onSignUpLinkClick)) {\n onSignUpLinkClick();\n }\n\n if (checkIsFunction(setActiveComponent)) {\n setActiveComponent('signUpForm');\n\n return;\n }\n\n if (checkIsFunction(routeSignUp)) {\n window.location.href = routeSignUp();\n }\n }, [onSignUpLinkClick, routeSignUp, setActiveComponent]);\n\n const defaultEnhancedEmailFields: any = useMemo(() => {\n const fieldsList = simplifyTransformAttributesForm(\n DEFAULT__SIGN_IN_EMAIL_FIELD\n );\n\n if (!initialEmailValue?.length) return fieldsList;\n\n return fieldsList?.map((el: any) => ({\n ...el,\n defaultValue: initialEmailValue,\n }));\n }, [initialEmailValue]);\n\n const handledOnPrimaryButtonClick = useCallback(() => {\n handleSetInLineAlertProps();\n\n if (checkIsFunction(routeRedirectOnEmailConfirmationClose)) {\n window.location.href = routeRedirectOnEmailConfirmationClose();\n } else {\n setShowEmailConfirmationForm(false);\n }\n }, [handleSetInLineAlertProps, routeRedirectOnEmailConfirmationClose]);\n\n return {\n additionalActionsAlert,\n userEmail,\n defaultEnhancedEmailFields,\n passwordError,\n isSuccessful,\n isLoading,\n signInPasswordValue,\n showEmailConfirmationForm,\n setShowEmailConfirmationForm,\n setSignInPasswordValue,\n submitLogInUser,\n forgotPasswordCallback,\n onSignUpLinkClickCallback,\n handledOnPrimaryButtonClick,\n handleSetPassword,\n onBlurPassword,\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const clearUrlAndReplace = () => {\n let url = new URL(window.location.href);\n\n let email = url.searchParams.get('email');\n let token = url.searchParams.get('key');\n\n if (email && token) {\n url.searchParams.delete('email');\n url.searchParams.delete('key');\n\n window.history.replaceState({}, document.title, url.toString());\n }\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { useEffect, useState } from 'preact/hooks';\nimport { clearUrlAndReplace } from '../lib/clearUrlAndReplace';\nimport { confirmEmail } from '../api';\nimport { useText } from '@adobe-commerce/elsie/i18n';\n\ninterface useEmailConfirmationProps {\n enableEmailConfirmation: boolean;\n}\n\n// The client receives a confirmation of the validation via email. When the client follows the provided link, they are directed to the login page with three query parameters. If these parameters are present, we make a request to validate the status. This request returns a response that we display to the user.\nexport const useEmailConfirmation = ({\n enableEmailConfirmation,\n}: useEmailConfirmationProps) => {\n const translations = useText({\n accountConfirmMessage: 'Auth.EmailConfirmationForm.accountConfirmMessage',\n accountConfirmationEmailSuccessMessage:\n 'Auth.EmailConfirmationForm.accountConfirmationEmailSuccessMessage',\n });\n const [emailConfirmationStatusMessage, setEmailConfirmationStatusMessage] =\n useState<{\n text: string;\n status: '' | 'success' | 'error';\n }>({\n text: '',\n status: '',\n });\n\n useEffect(() => {\n if (enableEmailConfirmation) {\n const { search } = window.location;\n\n if (search.includes('email=') && search.includes('key=')) {\n const validateEmailStatus = async () => {\n const params = new URLSearchParams(search);\n\n const response = await confirmEmail({\n customerEmail: params.get('email') as string,\n customerConfirmationKey: params.get('key') as string,\n });\n\n if (!response) return null;\n\n if (response?.errors?.length) {\n setEmailConfirmationStatusMessage({\n text: response?.errors[0].message,\n status: 'error',\n });\n } else {\n setEmailConfirmationStatusMessage({\n text: response.data.confirmEmail.customer.email\n ? translations.accountConfirmationEmailSuccessMessage.replace(\n '{email}',\n response?.data?.confirmEmail.customer?.email\n )\n : translations.accountConfirmMessage,\n status: 'success',\n });\n\n clearUrlAndReplace();\n }\n };\n\n validateEmailStatus();\n }\n }\n }, [enableEmailConfirmation, translations]);\n\n return { emailConfirmationStatusMessage };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FunctionComponent } from 'preact';\nimport { classes, Slot } from '@adobe-commerce/elsie/lib';\nimport { useSignInForm } from '@/auth/hooks/components/useSignInForm';\nimport { SignInFormProps } from '@/auth/types';\nimport { useEmailConfirmation } from '@/auth/hooks/useEmailConfirmation';\nimport { Form, Button, EmailConfirmationForm } from '@/auth/components';\nimport { useInLineAlert } from '@/auth/hooks/useInLineAlert';\nimport { Header, InLineAlert, InputPassword } from '@adobe-commerce/elsie/components';\nimport '@/auth/components/SignInForm/SignInForm.css';\nimport { useCustomTranslations } from '@/auth/hooks/useCustomTranslations';\n\nexport const SignInForm: FunctionComponent<SignInFormProps> = ({\n slots,\n labels,\n formSize = 'default',\n initialEmailValue = '',\n renderSignUpLink = false,\n enableEmailConfirmation = false,\n hideCloseBtnOnEmailConfirmation = false,\n routeRedirectOnEmailConfirmationClose,\n routeRedirectOnSignIn,\n routeForgotPassword,\n routeSignUp,\n onSuccessCallback,\n setActiveComponent,\n onErrorCallback,\n onSignUpLinkClick,\n apiErrorMessageOverride,\n}) => {\n /**\n * useCustomTranslations is required to support extensibility of error messages.\n * Ensure all error-related translation paths include \".default\"\n * to allow future handling of dynamic or nested error messages.\n */\n const translations = useCustomTranslations({\n title: 'Auth.SignInForm.title',\n buttonPrimary: 'Auth.SignInForm.buttonPrimary',\n buttonSecondary: 'Auth.SignInForm.buttonSecondary',\n buttonTertiary: 'Auth.SignInForm.buttonTertiary',\n resendEmailInformationText:\n 'Auth.Notification.resendEmailNotification.informationText',\n resendEmailButtonText:\n 'Auth.Notification.resendEmailNotification.buttonText',\n customerTokenErrorMessage: 'Auth.Api.customerTokenErrorMessage',\n placeholder: 'Auth.InputPassword.placeholder',\n floatingLabel: 'Auth.InputPassword.floatingLabel',\n requiredFieldError: 'Auth.FormText.requiredFieldError.default',\n });\n\n const { emailConfirmationStatusMessage } = useEmailConfirmation({\n enableEmailConfirmation,\n });\n\n const { inLineAlertProps, handleSetInLineAlertProps } = useInLineAlert();\n\n const {\n userEmail,\n additionalActionsAlert,\n defaultEnhancedEmailFields,\n passwordError,\n isSuccessful,\n isLoading,\n signInPasswordValue,\n showEmailConfirmationForm,\n submitLogInUser,\n forgotPasswordCallback,\n onSignUpLinkClickCallback,\n handledOnPrimaryButtonClick,\n handleSetPassword,\n onBlurPassword,\n } = useSignInForm({\n translations,\n emailConfirmationStatusMessage,\n initialEmailValue,\n routeSignUp,\n routeForgotPassword,\n routeRedirectOnSignIn,\n setActiveComponent,\n onErrorCallback,\n onSuccessCallback,\n onSignUpLinkClick,\n handleSetInLineAlertProps,\n routeRedirectOnEmailConfirmationClose,\n apiErrorMessageOverride,\n });\n\n if (isSuccessful.status && slots?.SuccessNotification) {\n return (\n <Slot\n data-testid=\"successNotificationTestId\"\n name=\"SuccessNotification\"\n slot={slots?.SuccessNotification}\n context={{ isSuccessful }}\n />\n );\n }\n\n if (showEmailConfirmationForm) {\n return (\n <EmailConfirmationForm\n formSize={formSize}\n userEmail={userEmail}\n inLineAlertProps={inLineAlertProps}\n hideCloseBtnOnEmailConfirmation={hideCloseBtnOnEmailConfirmation}\n handleSetInLineAlertProps={handleSetInLineAlertProps}\n onPrimaryButtonClick={handledOnPrimaryButtonClick}\n />\n );\n }\n\n return (\n <div\n className={classes([\n 'auth-sign-in-form',\n `auth-sign-in-form--${formSize}`,\n ])}\n data-testid=\"signInForm\"\n >\n <Header\n title={labels?.formTitleText ?? translations.title}\n divider={false}\n className=\"auth-sign-in-form__title\"\n />\n {inLineAlertProps.text ? (\n <InLineAlert\n data-testid=\"authInLineAlert\"\n className=\"auth-sign-in-form__notification\"\n type={inLineAlertProps.type}\n variant=\"secondary\"\n heading={inLineAlertProps.text}\n icon={inLineAlertProps.icon}\n additionalActions={additionalActionsAlert}\n />\n ) : null}\n <Form\n name=\"signIn_form\"\n className=\"auth-sign-in-form__form\"\n onSubmit={submitLogInUser}\n loading={isLoading}\n fieldsConfig={defaultEnhancedEmailFields}\n >\n <InputPassword\n hideStatusIndicator\n className=\"auth-sign-in-form__form__password\"\n autoComplete={'current-password'}\n errorMessage={\n passwordError ? translations.requiredFieldError : undefined\n }\n defaultValue={signInPasswordValue}\n onValue={handleSetPassword}\n onBlur={onBlurPassword}\n placeholder={translations.placeholder}\n floatingLabel={translations.floatingLabel}\n />\n <div className=\"auth-sign-in-form__form__buttons\">\n <div className=\"auth-sign-in-form__form__buttons__combine\">\n <Button\n type=\"button\"\n variant=\"tertiary\"\n style={{ padding: 0 }}\n buttonText={translations.buttonTertiary}\n className=\"auth-sign-in-form__button auth-sign-in-form__button--forgot\"\n enableLoader={false}\n onClick={forgotPasswordCallback}\n data-testid=\"switchToSignUp\"\n />\n {renderSignUpLink ? <span /> : null}\n {renderSignUpLink ? (\n <Button\n type=\"button\"\n variant=\"tertiary\"\n style={{ padding: 0 }}\n buttonText={translations.buttonSecondary}\n className=\"auth-sign-in-form__button auth-sign-in-form__button--signup\"\n enableLoader={false}\n onClick={onSignUpLinkClickCallback}\n />\n ) : null}\n </div>\n <Button\n type=\"submit\"\n buttonText={labels?.primaryButtonText ?? translations.buttonPrimary}\n variant=\"primary\"\n className=\"auth-sign-in-form__button auth-sign-in-form__button--submit\"\n enableLoader={isLoading}\n />\n </div>\n </Form>\n <div id=\"generateCustomerToken\" />\n </div>\n );\n};\n"],"names":["useSignInForm","emailConfirmationStatusMessage","translations","initialEmailValue","routeSignUp","routeForgotPassword","routeRedirectOnSignIn","onErrorCallback","setActiveComponent","onSuccessCallback","onSignUpLinkClick","handleSetInLineAlertProps","routeRedirectOnEmailConfirmationClose","apiErrorMessageOverride","userEmail","setUserEmail","useState","showEmailConfirmationForm","setShowEmailConfirmationForm","signInPasswordValue","setSignInPasswordValue","passwordError","setPasswordError","isSuccessful","setIsSuccessful","isLoading","setIsLoading","additionalActionsAlert","setAdditionalActionsAlert","actionsShowNotificationForm","useCallback","email","resendConfirmationEmail","handleSetPassword","value","useEffect","onBlurPassword","checkPasswordAndFocus","event","isValid","focusOnEmptyPasswordField","onAuthenticationSuccess","loginResponse","checkIsFunction","onAuthenticationFailed","_a","isIncludesMessage","errorMessage","submitLogInUser","formValues","getFormValues","password","getCustomerToken","forgotPasswordCallback","onSignUpLinkClickCallback","defaultEnhancedEmailFields","useMemo","fieldsList","simplifyTransformAttributesForm","DEFAULT__SIGN_IN_EMAIL_FIELD","el","handledOnPrimaryButtonClick","clearUrlAndReplace","url","token","useEmailConfirmation","enableEmailConfirmation","useText","setEmailConfirmationStatusMessage","search","params","response","confirmEmail","_c","_b","SignInForm","slots","labels","formSize","renderSignUpLink","hideCloseBtnOnEmailConfirmation","useCustomTranslations","inLineAlertProps","useInLineAlert","jsx","Slot","EmailConfirmationForm","jsxs","classes","Header","InLineAlert","Form","InputPassword","Button"],"mappings":"iyBA0BO,MAAMA,GAAgB,CAAC,CAC5B,+BAAAC,EACA,aAAAC,EACA,kBAAAC,EACA,YAAAC,EACA,oBAAAC,EACA,sBAAAC,EACA,gBAAAC,EACA,mBAAAC,EACA,kBAAAC,EACA,kBAAAC,EACA,0BAAAC,EACA,sCAAAC,EACA,wBAAAC,CACF,IAA0B,CACxB,KAAM,CAACC,EAAWC,CAAY,EAAIC,EAAS,EAAE,EACvC,CAACC,EAA2BC,CAA4B,EAC5DF,EAAS,EAAK,EACV,CAACG,EAAqBC,CAAsB,EAAIJ,EAAS,EAAE,EAC3D,CAACK,EAAeC,CAAgB,EAAIN,EAAS,EAAK,EAClD,CAACO,EAAcC,CAAe,EAAIR,EAAS,CAC/C,SAAU,GACV,OAAQ,EAAA,CACT,EACK,CAACS,EAAWC,CAAY,EAAIV,EAAS,EAAK,EAC1C,CAACW,EAAwBC,CAAyB,EACtDZ,EAAsC,CAAA,CAAE,EAEp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AAA,CAAA,EAEnB,KACJ4D,EAACI,GAAA,CACC,KAAK,cACL,UAAU,0BACV,SAAU3C,EACV,QAASvB,EACT,aAAc8B,EAEd,SAAA,CAAA6B,EAACQ,GAAA,CACC,oBAAmB,GACnB,UAAU,oCACV,aAAc,mBACd,aACEvE,EAAgBnB,EAAa,mBAAqB,OAEpD,aAAciB,EACd,QAASc,EACT,OAAQG,EACR,YAAalC,EAAa,YAC1B,cAAeA,EAAa,aAAA,CAAA,EAE9BqF,EAAC,MAAA,CAAI,UAAU,mCACb,SAAA,CAAAA,EAAC,MAAA,CAAI,UAAU,4CACb,SAAA,CAAAH,EAACS,EAAA,CACC,KAAK,SACL,QAAQ,WACR,MAAO,CAAE,QAAS,CAAA,EAClB,WAAY3F,EAAa,eACzB,UAAU,8DACV,aAAc,GACd,QAASmD,EACT,cAAY,gBAAA,CAAA,EAEb0B,EAAmBK,EAAC,OAAA,CAAA,CAAK,EAAK,KAC9BL,EACCK,EAACS,EAAA,CACC,KAAK,SACL,QAAQ,WACR,MAAO,CAAE,QAAS,CAAA,EAClB,WAAY3F,EAAa,gBACzB,UAAU,8DACV,aAAc,GACd,QAASoD,CAAA,CAAA,EAET,IAAA,EACN,EACA8B,EAACS,EAAA,CACC,KAAK,SACL,YAAYhB,GAAA,YAAAA,EAAQ,oBAAqB3E,EAAa,cACtD,QAAQ,UACR,UAAU,8DACV,aAAcuB,CAAA,CAAA,CAChB,CAAA,CACF,CAAA,CAAA,CAAA,EAEF2D,EAAC,MAAA,CAAI,GAAG,uBAAA,CAAwB,CAAA,CAAA,CAAA,CAGtC"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/*! Copyright 2026 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{a as
|
|
3
|
+
import{a as y,f as G,h as R}from"./network-error.js";import"@dropins/tools/recaptcha.js";import{events as U}from"@dropins/tools/event-bus.js";import{merge as C}from"@dropins/tools/lib.js";import{c as k,f as F,C as w,e as v,L as x}from"./getAdobeCommerceOptimizerData.js";import{CUSTOMER_INFORMATION_FRAGMENT as S}from"../fragments.js";import{p as D,E as H}from"./acdl.js";import{s as K}from"./setReCaptchaToken.js";const A=t=>{var g,e,o,s,a,c,m,u,T,d,E,M,r,N;const i={email:((e=(g=t==null?void 0:t.data)==null?void 0:g.customer)==null?void 0:e.email)??"",firstName:((s=(o=t==null?void 0:t.data)==null?void 0:o.customer)==null?void 0:s.firstname)??"",lastName:((c=(a=t==null?void 0:t.data)==null?void 0:a.customer)==null?void 0:c.lastname)??"",groupUid:((T=(u=(m=t==null?void 0:t.data)==null?void 0:m.customer)==null?void 0:u.group)==null?void 0:T.uid)??""};return C(i,(N=(r=(M=(E=(d=k)==null?void 0:d.getConfig())==null?void 0:E.models)==null?void 0:M.CustomerModel)==null?void 0:r.transformer)==null?void 0:N.call(r,t.data))},Q=`
|
|
4
4
|
query GET_CUSTOMER_DATA {
|
|
5
5
|
customer {
|
|
6
6
|
...CUSTOMER_INFORMATION_FRAGMENT
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
${
|
|
10
|
-
`,
|
|
9
|
+
${S}
|
|
10
|
+
`,n=async t=>{if(t){const{authHeaderConfig:i}=k.getConfig();y(i.header,i.tokenPrefix?`${i.tokenPrefix} ${t}`:t)}return await G(Q,{method:"GET",cache:"force-cache"}).then(i=>A(i)).catch(R)},q=`
|
|
11
11
|
mutation GET_CUSTOMER_TOKEN($email: String!, $password: String!) {
|
|
12
12
|
generateCustomerToken(email: $email, password: $password) {
|
|
13
13
|
token
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
`,
|
|
16
|
+
`,Z=async({email:t,password:i,translations:g,onErrorCallback:e,handleSetInLineAlertProps:o,apiErrorMessageOverride:s})=>{var M,r,N,O,h;await K();const a=await G(q,{method:"POST",variables:{email:t,password:i}}).catch(R);if(!((r=(M=a==null?void 0:a.data)==null?void 0:M.generateCustomerToken)!=null&&r.token)){const _=g.customerTokenErrorMessage,f=a!=null&&a.errors?a.errors[0].message:_,$=s??f;return e==null||e(f),o==null||o({type:"error",text:$}),{errorMessage:f,displayErrorMessage:$,userName:"",userEmail:""}}const c=(O=(N=a==null?void 0:a.data)==null?void 0:N.generateCustomerToken)==null?void 0:O.token,m=await n(c),u=m==null?void 0:m.firstName,T=m==null?void 0:m.email;if(!u||!T){const _=g.customerTokenErrorMessage,f=s??_;return e==null||e(_),o==null||o({type:"error",text:f}),{errorMessage:_,displayErrorMessage:f,userName:"",userEmail:""}}const d=await F(),E=x.includes(window.location.hostname)?"":"Secure";return document.cookie=`${w.auth_dropin_firstname}=${u}; path=/; ${d}; ${E};`,document.cookie=`${w.auth_dropin_user_token}=${c}; path=/; ${d}; ${E};`,await v(c?m==null?void 0:m.groupUid:void 0),U.emit("authenticated",!!c),D((h=H)==null?void 0:h.SIGN_IN,{...m}),{errorMessage:"",displayErrorMessage:"",userName:u,userEmail:T}};export{Z as a,n as g};
|
|
17
17
|
//# sourceMappingURL=getCustomerToken.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCustomerToken.js","sources":["/@dropins/storefront-auth/src/data/transforms/transform-customer-data.ts","/@dropins/storefront-auth/src/api/getCustomerData/graphql/getCustomerData.graphql.ts","/@dropins/storefront-auth/src/api/getCustomerData/getCustomerData.ts","/@dropins/storefront-auth/src/api/getCustomerToken/graphql/getCustomerToken.graphql.ts","/@dropins/storefront-auth/src/api/getCustomerToken/getCustomerToken.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { getCustomerDataResponse } from '@/auth/types';\nimport { CustomerModel } from '../models';\nimport { config } from '@/auth/api';\nimport { merge } from '@adobe-commerce/elsie/lib';\n\nexport const transformCustomerData = (\n response: getCustomerDataResponse\n): CustomerModel => {\n const model = {\n email: response?.data?.customer?.email ?? '',\n firstName: response?.data?.customer?.firstname ?? '',\n lastName: response?.data?.customer?.lastname ?? '',\n groupUid: response?.data?.customer?.group?.uid ?? '',\n };\n\n // Extend the model merging custom transformer, if provided\n return merge(\n model, // default transformer\n config?.getConfig()?.models?.CustomerModel?.transformer?.(response.data) // custom transformer\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CUSTOMER_INFORMATION_FRAGMENT } from '@/auth/api/fragments';\n\nexport const GET_CUSTOMER_DATA = /* GraphQL */ `\n query GET_CUSTOMER_DATA {\n customer {\n ...CUSTOMER_INFORMATION_FRAGMENT\n }\n }\n ${CUSTOMER_INFORMATION_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl, setFetchGraphQlHeader, config } from '@/auth/api';\nimport { GET_CUSTOMER_DATA } from './graphql/getCustomerData.graphql';\nimport { handleNetworkError } from '@/auth/lib/network-error';\nimport { CustomerModel } from '@/auth/data/models';\nimport { transformCustomerData } from '@/auth/data/transforms';\n\nexport const getCustomerData = async (\n user_token: string\n): Promise<CustomerModel> => {\n if (user_token) {\n const { authHeaderConfig } = config.getConfig();\n\n setFetchGraphQlHeader(\n authHeaderConfig.header,\n authHeaderConfig.tokenPrefix\n ? `${authHeaderConfig.tokenPrefix} ${user_token}`\n : user_token\n );\n }\n\n return await fetchGraphQl(GET_CUSTOMER_DATA, {\n method: 'GET',\n cache: 'force-cache',\n })\n .then((response) => {\n return transformCustomerData(response);\n })\n .catch(handleNetworkError);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const GET_CUSTOMER_TOKEN = /* GraphQL */ `\n mutation GET_CUSTOMER_TOKEN($email: String!, $password: String!) {\n generateCustomerToken(email: $email, password: $password) {\n token\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { handleNetworkError } from '@/auth/lib/network-error';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { GET_CUSTOMER_TOKEN } from './graphql/getCustomerToken.graphql';\nimport { getCustomerData } from '../getCustomerData';\nimport { InLineAlertInterface } from '@/auth/types';\nimport { events } from '@adobe-commerce/event-bus';\nimport { COOKIE_NAMES, LOCALHOST } from '@/auth/configs/cookieConfigs';\nimport { getCookiesLifetime } from '@/auth/lib/cookieUtils';\nimport { publishEvents, EventsList } from '@/auth/lib/acdl';\nimport { setReCaptchaToken } from '@/auth/lib/setReCaptchaToken';\nimport { emitAuthGroupIdEvent } from '@/auth/lib/emitAuthGroupId';\n\ninterface getCustomerTokenProps {\n email: string;\n password: string;\n handleSetInLineAlertProps: (value?: InLineAlertInterface) => void;\n translations: Record<string, string>;\n onErrorCallback?: (value?: unknown) => void;\n}\n\nexport const getCustomerToken = async ({\n email,\n password,\n translations,\n onErrorCallback,\n handleSetInLineAlertProps,\n}: getCustomerTokenProps): Promise<{\n errorMessage: string;\n userName: string;\n userEmail: string;\n}> => {\n await setReCaptchaToken();\n\n const response = await fetchGraphQl(GET_CUSTOMER_TOKEN, {\n method: 'POST',\n variables: { email, password },\n }).catch(handleNetworkError);\n\n if (!response?.data?.generateCustomerToken?.token) {\n // Fallback error message\n const defaultErrorMessage = translations.customerTokenErrorMessage;\n const errorMessage = response?.errors\n ? response.errors[0].message\n : defaultErrorMessage;\n\n onErrorCallback?.(errorMessage);\n handleSetInLineAlertProps?.({ type: 'error', text: errorMessage });\n\n return { errorMessage, userName: '', userEmail: '' };\n }\n\n const userToken = response?.data?.generateCustomerToken?.token;\n\n const responseCustomer = await getCustomerData(userToken);\n const userName = responseCustomer?.firstName;\n const userEmail = responseCustomer?.email;\n\n if (!userName || !userEmail) {\n const errorMessage = translations.customerTokenErrorMessage;\n\n onErrorCallback?.(errorMessage);\n handleSetInLineAlertProps?.({ type: 'error', text: errorMessage });\n\n return { errorMessage, userName: '', userEmail: '' };\n }\n\n const cookiesLifetime = await getCookiesLifetime();\n\n // Do not set 'Secure' flag on auth cookies when running on localhost (fix for Safari browser)\n const cookieSecureFlag: string | null = LOCALHOST.includes(window.location.hostname) ? '' : 'Secure';\n\n document.cookie = `${COOKIE_NAMES.auth_dropin_firstname}=${userName}; path=/; ${cookiesLifetime}; ${cookieSecureFlag};`;\n document.cookie = `${COOKIE_NAMES.auth_dropin_user_token}=${userToken}; path=/; ${cookiesLifetime}; ${cookieSecureFlag};`;\n\n await emitAuthGroupIdEvent(userToken ? responseCustomer?.groupUid : undefined);\n events.emit('authenticated', !!userToken);\n\n publishEvents(EventsList?.SIGN_IN, { ...responseCustomer });\n\n return { errorMessage: '', userName, userEmail };\n};\n"],"names":["transformCustomerData","response","model","_b","_a","_d","_c","_f","_e","_i","_h","_g","merge","_n","_m","_l","_k","_j","config","GET_CUSTOMER_DATA","CUSTOMER_INFORMATION_FRAGMENT","getCustomerData","user_token","authHeaderConfig","setFetchGraphQlHeader","fetchGraphQl","handleNetworkError","GET_CUSTOMER_TOKEN","getCustomerToken","email","password","translations","onErrorCallback","handleSetInLineAlertProps","setReCaptchaToken","defaultErrorMessage","errorMessage","userToken","responseCustomer","userName","userEmail","cookiesLifetime","getCookiesLifetime","cookieSecureFlag","LOCALHOST","COOKIE_NAMES","emitAuthGroupIdEvent","events","publishEvents","EventsList"],"mappings":"+ZAsBO,MAAMA,EACXC,GACkB,iCAClB,MAAMC,EAAQ,CACZ,QAAOC,GAAAC,EAAAH,GAAA,YAAAA,EAAU,OAAV,YAAAG,EAAgB,WAAhB,YAAAD,EAA0B,QAAS,GAC1C,YAAWE,GAAAC,EAAAL,GAAA,YAAAA,EAAU,OAAV,YAAAK,EAAgB,WAAhB,YAAAD,EAA0B,YAAa,GAClD,WAAUE,GAAAC,EAAAP,GAAA,YAAAA,EAAU,OAAV,YAAAO,EAAgB,WAAhB,YAAAD,EAA0B,WAAY,GAChD,WAAUE,GAAAC,GAAAC,EAAAV,GAAA,YAAAA,EAAU,OAAV,YAAAU,EAAgB,WAAhB,YAAAD,EAA0B,QAA1B,YAAAD,EAAiC,MAAO,EAAA,EAIpD,OAAOG,EACLV,GACAW,GAAAC,GAAAC,GAAAC,GAAAC,EAAAC,IAAA,YAAAD,EAAQ,cAAR,YAAAD,EA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AK,EAAgB,wBAAhB,YAAAD,EAAuC,MAEnDiC,EAAmB,MAAMjB,EAAgBgB,CAAS,EAClDE,EAAWD,GAAA,YAAAA,EAAkB,UAC7BE,EAAYF,GAAA,YAAAA,EAAkB,MAEpC,GAAI,CAACC,GAAY,CAACC,EAAW,CAC3B,MAAMJ,EAAeL,EAAa,0BAElC,OAAAC,GAAA,MAAAA,EAAkBI,GAClBH,GAAA,MAAAA,EAA4B,CAAE,KAAM,QAAS,KAAMG,IAE5C,CAAE,aAAAA,EAAc,SAAU,GAAI,UAAW,EAAA,CAClD,CAEA,MAAMK,EAAkB,MAAMC,EAAA,EAGxBC,EAAkCC,EAAU,SAAS,OAAO,SAAS,QAAQ,EAAI,GAAK,SAE5F,gBAAS,OAAS,GAAGC,EAAa,qBAAqB,IAAIN,CAAQ,aAAaE,CAAe,KAAKE,CAAgB,IACpH,SAAS,OAAS,GAAGE,EAAa,sBAAsB,IAAIR,CAAS,aAAaI,CAAe,KAAKE,CAAgB,IAEtH,MAAMG,EAAqBT,EAAYC,GAAA,YAAAA,EAAkB,SAAW,MAAS,EAC7ES,EAAO,KAAK,gBAAiB,CAAC,CAACV,CAAS,EAExCW,GAAcxC,EAAAyC,IAAA,YAAAzC,EAAY,QAAS,CAAE,GAAG8B,EAAkB,EAEnD,CAAE,aAAc,GAAI,SAAAC,EAAU,UAAAC,CAAA,CACvC"}
|
|
1
|
+
{"version":3,"file":"getCustomerToken.js","sources":["/@dropins/storefront-auth/src/data/transforms/transform-customer-data.ts","/@dropins/storefront-auth/src/api/getCustomerData/graphql/getCustomerData.graphql.ts","/@dropins/storefront-auth/src/api/getCustomerData/getCustomerData.ts","/@dropins/storefront-auth/src/api/getCustomerToken/graphql/getCustomerToken.graphql.ts","/@dropins/storefront-auth/src/api/getCustomerToken/getCustomerToken.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { getCustomerDataResponse } from '@/auth/types';\nimport { CustomerModel } from '../models';\nimport { config } from '@/auth/api';\nimport { merge } from '@adobe-commerce/elsie/lib';\n\nexport const transformCustomerData = (\n response: getCustomerDataResponse\n): CustomerModel => {\n const model = {\n email: response?.data?.customer?.email ?? '',\n firstName: response?.data?.customer?.firstname ?? '',\n lastName: response?.data?.customer?.lastname ?? '',\n groupUid: response?.data?.customer?.group?.uid ?? '',\n };\n\n // Extend the model merging custom transformer, if provided\n return merge(\n model, // default transformer\n config?.getConfig()?.models?.CustomerModel?.transformer?.(response.data) // custom transformer\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CUSTOMER_INFORMATION_FRAGMENT } from '@/auth/api/fragments';\n\nexport const GET_CUSTOMER_DATA = /* GraphQL */ `\n query GET_CUSTOMER_DATA {\n customer {\n ...CUSTOMER_INFORMATION_FRAGMENT\n }\n }\n ${CUSTOMER_INFORMATION_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl, setFetchGraphQlHeader, config } from '@/auth/api';\nimport { GET_CUSTOMER_DATA } from './graphql/getCustomerData.graphql';\nimport { handleNetworkError } from '@/auth/lib/network-error';\nimport { CustomerModel } from '@/auth/data/models';\nimport { transformCustomerData } from '@/auth/data/transforms';\n\nexport const getCustomerData = async (\n user_token: string\n): Promise<CustomerModel> => {\n if (user_token) {\n const { authHeaderConfig } = config.getConfig();\n\n setFetchGraphQlHeader(\n authHeaderConfig.header,\n authHeaderConfig.tokenPrefix\n ? `${authHeaderConfig.tokenPrefix} ${user_token}`\n : user_token\n );\n }\n\n return await fetchGraphQl(GET_CUSTOMER_DATA, {\n method: 'GET',\n cache: 'force-cache',\n })\n .then((response) => {\n return transformCustomerData(response);\n })\n .catch(handleNetworkError);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const GET_CUSTOMER_TOKEN = /* GraphQL */ `\n mutation GET_CUSTOMER_TOKEN($email: String!, $password: String!) {\n generateCustomerToken(email: $email, password: $password) {\n token\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { handleNetworkError } from '@/auth/lib/network-error';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { GET_CUSTOMER_TOKEN } from './graphql/getCustomerToken.graphql';\nimport { getCustomerData } from '../getCustomerData';\nimport { InLineAlertInterface } from '@/auth/types';\nimport { events } from '@adobe-commerce/event-bus';\nimport { COOKIE_NAMES, LOCALHOST } from '@/auth/configs/cookieConfigs';\nimport { getCookiesLifetime } from '@/auth/lib/cookieUtils';\nimport { publishEvents, EventsList } from '@/auth/lib/acdl';\nimport { setReCaptchaToken } from '@/auth/lib/setReCaptchaToken';\nimport { emitAuthGroupIdEvent } from '@/auth/lib/emitAuthGroupId';\n\ninterface getCustomerTokenProps {\n email: string;\n password: string;\n handleSetInLineAlertProps: (value?: InLineAlertInterface) => void;\n translations: Record<string, string>;\n onErrorCallback?: (value?: unknown) => void;\n apiErrorMessageOverride?: string;\n}\n\nexport const getCustomerToken = async ({\n email,\n password,\n translations,\n onErrorCallback,\n handleSetInLineAlertProps,\n apiErrorMessageOverride,\n}: getCustomerTokenProps): Promise<{\n errorMessage: string;\n displayErrorMessage: string;\n userName: string;\n userEmail: string;\n}> => {\n await setReCaptchaToken();\n\n const response = await fetchGraphQl(GET_CUSTOMER_TOKEN, {\n method: 'POST',\n variables: { email, password },\n }).catch(handleNetworkError);\n\n if (!response?.data?.generateCustomerToken?.token) {\n // Fallback error message\n const defaultErrorMessage = translations.customerTokenErrorMessage;\n // Original error message from API or default (used for error detection logic)\n const errorMessage = response?.errors\n ? response.errors[0].message\n : defaultErrorMessage;\n // Display error message (override if provided, otherwise original)\n const displayErrorMessage = apiErrorMessageOverride ?? errorMessage;\n\n onErrorCallback?.(errorMessage);\n handleSetInLineAlertProps?.({ type: 'error', text: displayErrorMessage });\n\n return { errorMessage, displayErrorMessage, userName: '', userEmail: '' };\n }\n\n const userToken = response?.data?.generateCustomerToken?.token;\n\n const responseCustomer = await getCustomerData(userToken);\n const userName = responseCustomer?.firstName;\n const userEmail = responseCustomer?.email;\n\n if (!userName || !userEmail) {\n const errorMessage = translations.customerTokenErrorMessage;\n const displayErrorMessage = apiErrorMessageOverride ?? errorMessage;\n\n onErrorCallback?.(errorMessage);\n handleSetInLineAlertProps?.({ type: 'error', text: displayErrorMessage });\n\n return { errorMessage, displayErrorMessage, userName: '', userEmail: '' };\n }\n\n const cookiesLifetime = await getCookiesLifetime();\n\n // Do not set 'Secure' flag on auth cookies when running on localhost (fix for Safari browser)\n const cookieSecureFlag: string | null = LOCALHOST.includes(window.location.hostname) ? '' : 'Secure';\n\n document.cookie = `${COOKIE_NAMES.auth_dropin_firstname}=${userName}; path=/; ${cookiesLifetime}; ${cookieSecureFlag};`;\n document.cookie = `${COOKIE_NAMES.auth_dropin_user_token}=${userToken}; path=/; ${cookiesLifetime}; ${cookieSecureFlag};`;\n\n await emitAuthGroupIdEvent(userToken ? responseCustomer?.groupUid : undefined);\n events.emit('authenticated', !!userToken);\n\n publishEvents(EventsList?.SIGN_IN, { ...responseCustomer });\n\n return { errorMessage: '', displayErrorMessage: '', userName, userEmail };\n};\n"],"names":["transformCustomerData","response","model","_b","_a","_d","_c","_f","_e","_i","_h","_g","merge","_n","_m","_l","_k","_j","config","GET_CUSTOMER_DATA","CUSTOMER_INFORMATION_FRAGMENT","getCustomerData","user_token","authHeaderConfig","setFetchGraphQlHeader","fetchGraphQl","handleNetworkError","GET_CUSTOMER_TOKEN","getCustomerToken","email","password","translations","onErrorCallback","handleSetInLineAlertProps","apiErrorMessageOverride","setReCaptchaToken","defaultErrorMessage","errorMessage","displayErrorMessage","userToken","responseCustomer","userName","userEmail","cookiesLifetime","getCookiesLifetime","cookieSecureFlag","LOCALHOST","COOKIE_NAMES","emitAuthGroupIdEvent","events","publishEvents","EventsList"],"mappings":"+ZAsBO,MAAMA,EACXC,GACkB,iCAClB,MAAMC,EAAQ,CACZ,QAAOC,GAAAC,EAAAH,GAAA,YAAAA,EAAU,OAAV,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MAAS,EAC7ES,EAAO,KAAK,gBAAiB,CAAC,CAACV,CAAS,EAExCW,GAAc1C,EAAA2C,IAAA,YAAA3C,EAAY,QAAS,CAAE,GAAGgC,EAAkB,EAEnD,CAAE,aAAc,GAAI,oBAAqB,GAAI,SAAAC,EAAU,UAAAC,CAAA,CAChE"}
|
package/containers/SignIn.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2026 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/preact-hooks.js";import"../chunks/Button.js";import"@dropins/tools/i18n.js";import{S
|
|
3
|
+
import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/preact-hooks.js";import"../chunks/Button.js";import"@dropins/tools/i18n.js";import{S}from"../chunks/SignInForm.js";import"@dropins/tools/preact-compat.js";import"../chunks/Button2.js";import"../chunks/getCustomerToken.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/getAdobeCommerceOptimizerData.js";import"../fragments.js";import"../chunks/acdl.js";import"../chunks/setReCaptchaToken.js";import"../chunks/resendConfirmationEmail.js";import"../chunks/simplifyTransformAttributesForm.js";import"../chunks/transform-attributes-form.js";import"../chunks/focusOnEmptyPasswordField.js";import"../chunks/confirmEmail.js";const M=({slots:i,labels:o,enableEmailConfirmation:t,initialEmailValue:m,formSize:p,renderSignUpLink:n,hideCloseBtnOnEmailConfirmation:s,routeRedirectOnEmailConfirmationClose:a,routeRedirectOnSignIn:e,routeForgotPassword:c,routeSignUp:d,onSuccessCallback:f,onErrorCallback:g,onSignUpLinkClick:l,apiErrorMessageOverride:u})=>r("div",{className:"auth-sign-in",children:r(S,{slots:i,labels:o,formSize:p,renderSignUpLink:n,initialEmailValue:m,enableEmailConfirmation:t,hideCloseBtnOnEmailConfirmation:s,routeRedirectOnEmailConfirmationClose:a,routeSignUp:d,onErrorCallback:g,onSuccessCallback:f,onSignUpLinkClick:l,routeForgotPassword:c,routeRedirectOnSignIn:e,apiErrorMessageOverride:u})});export{M as SignIn,M as default};
|
|
4
4
|
//# sourceMappingURL=SignIn.js.map
|
package/containers/SignIn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignIn.js","sources":["/@dropins/storefront-auth/src/containers/SignIn/SignIn.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { SignInForm } from '@/auth/components';\nimport { SignInProps } from '@/auth/types';\n\nexport const SignIn: Container<SignInProps> = ({\n slots,\n labels,\n enableEmailConfirmation,\n initialEmailValue,\n formSize,\n renderSignUpLink,\n hideCloseBtnOnEmailConfirmation,\n routeRedirectOnEmailConfirmationClose,\n routeRedirectOnSignIn,\n routeForgotPassword,\n routeSignUp,\n onSuccessCallback,\n onErrorCallback,\n onSignUpLinkClick,\n}) => {\n return (\n <div className=\"auth-sign-in\">\n <SignInForm\n slots={slots}\n labels={labels}\n formSize={formSize}\n renderSignUpLink={renderSignUpLink}\n initialEmailValue={initialEmailValue}\n enableEmailConfirmation={enableEmailConfirmation}\n hideCloseBtnOnEmailConfirmation={hideCloseBtnOnEmailConfirmation}\n routeRedirectOnEmailConfirmationClose={\n routeRedirectOnEmailConfirmationClose\n }\n routeSignUp={routeSignUp}\n onErrorCallback={onErrorCallback}\n onSuccessCallback={onSuccessCallback}\n onSignUpLinkClick={onSignUpLinkClick}\n routeForgotPassword={routeForgotPassword}\n routeRedirectOnSignIn={routeRedirectOnSignIn}\n />\n </div>\n );\n};\n"],"names":["SignIn","slots","labels","enableEmailConfirmation","initialEmailValue","formSize","renderSignUpLink","hideCloseBtnOnEmailConfirmation","routeRedirectOnEmailConfirmationClose","routeRedirectOnSignIn","routeForgotPassword","routeSignUp","onSuccessCallback","onErrorCallback","onSignUpLinkClick","jsx","SignInForm"],"mappings":"
|
|
1
|
+
{"version":3,"file":"SignIn.js","sources":["/@dropins/storefront-auth/src/containers/SignIn/SignIn.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { SignInForm } from '@/auth/components';\nimport { SignInProps } from '@/auth/types';\n\nexport const SignIn: Container<SignInProps> = ({\n slots,\n labels,\n enableEmailConfirmation,\n initialEmailValue,\n formSize,\n renderSignUpLink,\n hideCloseBtnOnEmailConfirmation,\n routeRedirectOnEmailConfirmationClose,\n routeRedirectOnSignIn,\n routeForgotPassword,\n routeSignUp,\n onSuccessCallback,\n onErrorCallback,\n onSignUpLinkClick,\n apiErrorMessageOverride,\n}) => {\n return (\n <div className=\"auth-sign-in\">\n <SignInForm\n slots={slots}\n labels={labels}\n formSize={formSize}\n renderSignUpLink={renderSignUpLink}\n initialEmailValue={initialEmailValue}\n enableEmailConfirmation={enableEmailConfirmation}\n hideCloseBtnOnEmailConfirmation={hideCloseBtnOnEmailConfirmation}\n routeRedirectOnEmailConfirmationClose={\n routeRedirectOnEmailConfirmationClose\n }\n routeSignUp={routeSignUp}\n onErrorCallback={onErrorCallback}\n onSuccessCallback={onSuccessCallback}\n onSignUpLinkClick={onSignUpLinkClick}\n routeForgotPassword={routeForgotPassword}\n routeRedirectOnSignIn={routeRedirectOnSignIn}\n apiErrorMessageOverride={apiErrorMessageOverride}\n />\n </div>\n );\n};\n"],"names":["SignIn","slots","labels","enableEmailConfirmation","initialEmailValue","formSize","renderSignUpLink","hideCloseBtnOnEmailConfirmation","routeRedirectOnEmailConfirmationClose","routeRedirectOnSignIn","routeForgotPassword","routeSignUp","onSuccessCallback","onErrorCallback","onSignUpLinkClick","apiErrorMessageOverride","jsx","SignInForm"],"mappings":"m3BAqBO,MAAMA,EAAiC,CAAC,CAC7C,MAAAC,EACA,OAAAC,EACA,wBAAAC,EACA,kBAAAC,EACA,SAAAC,EACA,iBAAAC,EACA,gCAAAC,EACA,sCAAAC,EACA,sBAAAC,EACA,oBAAAC,EACA,YAAAC,EACA,kBAAAC,EACA,gBAAAC,EACA,kBAAAC,EACA,wBAAAC,CACF,IAEIC,EAAC,MAAA,CAAI,UAAU,eACb,SAAAA,EAACC,EAAA,CACC,MAAAhB,EACA,OAAAC,EACA,SAAAG,EACA,iBAAAC,EACA,kBAAAF,EACA,wBAAAD,EACA,gCAAAI,EACA,sCAAAC,EAGA,YAAAG,EACA,gBAAAE,EACA,kBAAAD,EACA,kBAAAE,EACA,oBAAAJ,EACA,sBAAAD,EACA,wBAAAM,CAAA,CAAA,EAEJ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AdditionalActionsAlertProps, useSignInFormProps } from '../../types';
|
|
2
2
|
|
|
3
|
-
export declare const useSignInForm: ({ emailConfirmationStatusMessage, translations, initialEmailValue, routeSignUp, routeForgotPassword, routeRedirectOnSignIn, onErrorCallback, setActiveComponent, onSuccessCallback, onSignUpLinkClick, handleSetInLineAlertProps, routeRedirectOnEmailConfirmationClose, }: useSignInFormProps) => {
|
|
3
|
+
export declare const useSignInForm: ({ emailConfirmationStatusMessage, translations, initialEmailValue, routeSignUp, routeForgotPassword, routeRedirectOnSignIn, onErrorCallback, setActiveComponent, onSuccessCallback, onSignUpLinkClick, handleSetInLineAlertProps, routeRedirectOnEmailConfirmationClose, apiErrorMessageOverride, }: useSignInFormProps) => {
|
|
4
4
|
additionalActionsAlert: AdditionalActionsAlertProps;
|
|
5
5
|
userEmail: string;
|
|
6
6
|
defaultEnhancedEmailFields: any;
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@dropins/storefront-auth", "version": "3.
|
|
1
|
+
{"name": "@dropins/storefront-auth", "version": "3.1.0-beta2", "@dropins/tools": "~1.7.0-beta3", "license": "SEE LICENSE IN LICENSE.md"}
|
package/types/signIn.types.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export interface SignInProps {
|
|
|
28
28
|
}) => Promise<void>;
|
|
29
29
|
onErrorCallback?: (error?: unknown) => void;
|
|
30
30
|
onSignUpLinkClick?: () => void;
|
|
31
|
+
apiErrorMessageOverride?: string;
|
|
31
32
|
}
|
|
32
33
|
export interface SignInFormProps extends SignInProps {
|
|
33
34
|
setActiveComponent?: (componentName: activeComponentType) => void;
|