@dropins/storefront-auth 2.0.4-alpha1 → 2.1.0-alpha2
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.
|
@@ -10,6 +10,7 @@ interface getCustomerTokenProps {
|
|
|
10
10
|
export declare const getCustomerToken: ({ email, password, translations, onErrorCallback, handleSetInLineAlertProps, }: getCustomerTokenProps) => Promise<{
|
|
11
11
|
errorMessage: string;
|
|
12
12
|
userName: string;
|
|
13
|
+
userEmail: string;
|
|
13
14
|
}>;
|
|
14
15
|
export {};
|
|
15
16
|
//# sourceMappingURL=getCustomerToken.d.ts.map
|
package/chunks/SignUpForm.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as c,jsxs as $}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as nr,classes as Fr}from"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{g as Pr,c as
|
|
3
|
+
import{jsx as c,jsxs as $}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as nr,classes as Fr}from"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{g as Pr,c as Er,a as br}from"./createCustomerAddress.js";import{useState as w,useEffect as Nr,useCallback as C,useMemo as _r}from"@dropins/tools/preact-hooks.js";import{s as mr,b as Lr}from"./simplifyTransformAttributesForm.js";import{v as yr,u as Mr,a as Ur}from"./usePasswordValidationMessage.js";import{a as Cr}from"./getCustomerToken.js";import{p as Sr,E as xr}from"./acdl.js";import{c as O,g as Tr,u as qr,B as ur}from"./Button2.js";import{c as vr}from"./transform-attributes-form.js";import{f as dr,E as Ar}from"./focusOnEmptyPasswordField.js";import{Header as Br,InLineAlert as Kr,InputPassword as cr,Field as jr,Checkbox as Ir}from"@dropins/tools/components.js";import{u as Gr,F as Hr}from"./Button.js";import{S as Vr}from"./SkeletonLoader.js";const fr=(n,e)=>e!=null&&e.length?n.map(r=>{var d;const t=(d=e.find(({code:s})=>s===r.code))==null?void 0:d.defaultValue;return t?{...r,defaultValue:t}:r}):n,Wr=({inputsDefaultValueSet:n,fieldsConfigForApiVersion1:e,apiVersion2:r})=>{const[t,d]=w([]);return Nr(()=>{(async()=>{if(r){const o=await Pr("customer_account_create");if(o!=null&&o.length)if(n!=null&&n.length){const b=fr(o,n);d(b)}else d(o)}else{const o=mr(Lr),b=mr(e),L=fr(o,n);d(e&&e.length?b:L)}})()},[r,e,n]),{fieldsListConfigs:t.map(s=>({...s,...s.code==="email"?{autocomplete:"username"}:{}}))}},$r=(n,e)=>{const r=["dob","email","firstname","gender","lastname","middlename","password","prefix","suffix","taxvat"],t=vr(n,"snakeCase",{firstName:"firstname",lastName:"lastname"});if(!e)return{...t,...t!=null&&t.gender?{gender:Number(t==null?void 0:t.gender)}:{}};const d={},s=[];return Object.keys(t).forEach(o=>{r.includes(o)?d[o]=o.includes("gender")?Number(t[o]):t[o]:s.push({attribute_code:o,value:t[o]})}),s.length>0&&(d.custom_attributes=s),d},Or=({requireRetypePassword:n,addressesData:e,translations:r,isEmailConfirmationRequired:t,apiVersion2:d=!0,passwordConfigs:s,isAutoSignInEnabled:o,routeRedirectOnSignIn:b,routeSignIn:L,onErrorCallback:S,onSuccessCallback:h,setActiveComponent:F,handleSetInLineAlertProps:P,routeRedirectOnEmailConfirmationClose:T})=>{const[l,m]=w(!1),[i,I]=w(""),[q,u]=w(""),[G,v]=w(""),[J,H]=w(!1),[Q,A]=w({userName:"",status:!1}),[f,x]=w(""),[X,V]=w(!1),[W,y]=w(!1),[Y,Z]=w(!0),k=C(a=>{const p=a.target.value;m(!p.length),p.length&&i.length&&p!==i&&u(r.passwordMismatch)},[i,r.passwordMismatch]),z=C(a=>{const p=a.target.value;u(p.length?"":r.requiredFieldError),p.length&&f.length&&p!==f&&u(r.passwordMismatch)},[f,r.passwordMismatch,r.requiredFieldError]),R=C(a=>{I(a),u(a?f===a?"":r.passwordMismatch:r.requiredFieldError)},[r,f]),D=C(({target:a})=>{Z(a.checked)},[]),rr=C(()=>{if(O(F)){F("signInForm");return}O(L)&&(window.location.href=L())},[F,L]),B=C(a=>{x(a),m(!a.length),a===i&&u("")},[i]),E=C(()=>{P(),x(""),O(T)?window.location.href=T():(H(!1),F==null||F("signInForm"))},[P,T,F]),K=()=>{V(!0),y(!1)},er=(a,p)=>{const tr=f.length&&i.length,j=f!==i,N=()=>{m(!f.length),i||u(r.requiredFieldError),tr&&j&&u(r.passwordMismatch)},M=()=>{u(i.length?r.passwordMismatch:r.requiredFieldError),dr(a,f,i)};return p?n&&(q.length||j)?(K(),M(),!0):(dr(a,f,""),N(),!1):(K(),N(),!0)};return{showPasswordErrorMessage:l,confirmPassword:i,confirmPasswordMessage:q,isKeepMeLogged:Y,userEmail:G,showEmailConfirmationForm:J,isSuccessful:Q,isClickSubmit:X,signUpPasswordValue:f,isLoading:W,onSubmitSignUp:async(a,p)=>{var sr,or,ir;if(P(),u(""),y(!0),er(a,p))return;const{confirmPasswordField:tr,...j}=Tr(a.target),{email:N,password:M}=j,gr=(s==null?void 0:s.requiredCharacterClasses)||0,hr=(s==null?void 0:s.minLength)||1;if(!yr(M,gr)||hr>(M==null?void 0:M.length)){K();return}const pr=$r({...j},d),_=await Er(pr,d);if((sr=_==null?void 0:_.errors)!=null&&sr.length){const{errors:U}=_;P==null||P({type:"error",text:(or=U[0])==null?void 0:or.message}),S==null||S(U),v(N)}else{const U=_==null?void 0:_.firstName;if(Sr(xr.CREATE_ACCOUNT_EVENT,{..._}),t||!o){if(h==null||h({userName:U,userEmail:N,status:!0}),t){(ir=a.target)==null||ir.reset(),x(""),H(!0),v(N),y(!1);return}if(!o){y(!1),A({userName:U,status:!0});return}}const g=await Cr({email:N,password:M,translations:r,handleSetInLineAlertProps:P,onErrorCallback:S});if(g!=null&&g.userName){if(e!=null&&e.length)for(const ar of e)try{await br(ar)}catch(wr){console.error(r.failedCreateCustomerAddress,ar,wr)}h==null||h({userName:g==null?void 0:g.userName,userEmail:g==null?void 0:g.userEmail,status:!0}),O(b)?window.location.href=b():A({userName:g==null?void 0:g.userName,status:!0})}else h==null||h({userName:U,userEmail:N,status:!0}),A({userName:U,status:!0})}y(!1)},signInButton:rr,handleSetSignUpPasswordValue:B,onKeepMeLoggedChange:D,handleHideEmailConfirmationForm:E,handleConfirmPasswordChange:R,onBlurPassword:k,onBlurConfirmPassword:z}},ne=({requireRetypePassword:n=!1,addressesData:e,formSize:r="default",inputsDefaultValueSet:t,fieldsConfigForApiVersion1:d,apiVersion2:s=!0,isAutoSignInEnabled:o=!0,hideCloseBtnOnEmailConfirmation:b=!1,routeRedirectOnEmailConfirmationClose:L,routeRedirectOnSignIn:S,routeSignIn:h,onErrorCallback:F,onSuccessCallback:P,setActiveComponent:T,slots:l})=>{const m=Gr({title:"Auth.SignUpForm.title",buttonPrimary:"Auth.SignUpForm.buttonPrimary",buttonSecondary:"Auth.SignUpForm.buttonSecondary",keepMeLoggedText:"Auth.SignUpForm.keepMeLoggedText",customerTokenErrorMessage:"Auth.Api.customerTokenErrorMessage",failedCreateCustomerAddress:"Auth.SignUpForm.failedCreateCustomerAddress",placeholder:"Auth.InputPassword.placeholder",floatingLabel:"Auth.InputPassword.floatingLabel",requiredFieldError:"Auth.FormText.requiredFieldError.default",confirmPasswordPlaceholder:"Auth.SignUpForm.confirmPassword.placeholder",confirmPasswordFloatingLabel:"Auth.SignUpForm.confirmPassword.floatingLabel",passwordMismatch:"Auth.SignUpForm.confirmPassword.passwordMismatch"}),{passwordConfigs:i,isEmailConfirmationRequired:I}=Mr(),{fieldsListConfigs:q}=Wr({fieldsConfigForApiVersion1:d,apiVersion2:s,inputsDefaultValueSet:t}),{inLineAlertProps:u,handleSetInLineAlertProps:G}=qr(),{showPasswordErrorMessage:v,confirmPassword:J,confirmPasswordMessage:H,isKeepMeLogged:Q,userEmail:A,showEmailConfirmationForm:f,isSuccessful:x,isClickSubmit:X,signUpPasswordValue:V,isLoading:W,onSubmitSignUp:y,signInButton:Y,handleSetSignUpPasswordValue:Z,onKeepMeLoggedChange:k,handleHideEmailConfirmationForm:z,handleConfirmPasswordChange:R,onBlurPassword:D,onBlurConfirmPassword:rr}=Or({requireRetypePassword:n,addressesData:e,translations:m,isEmailConfirmationRequired:I,apiVersion2:s,passwordConfigs:i,isAutoSignInEnabled:o,routeRedirectOnSignIn:S,routeSignIn:h,onErrorCallback:F,onSuccessCallback:P,setActiveComponent:T,handleSetInLineAlertProps:G,routeRedirectOnEmailConfirmationClose:L}),{isValidUniqueSymbols:B,defaultLengthMessage:E}=Ur({password:V,isClickSubmit:X,passwordConfigs:i}),K=_r(()=>v?m.requiredFieldError:B==="error"||(E==null?void 0:E.status)==="error"?" ":"",[E==null?void 0:E.status,B,v,m.requiredFieldError]),er=!I&&(e==null?void 0:e.length);return!q.length&&s?c("div",{className:`auth-sign-up-form auth-sign-up-form--${r} skeleton-loader`,"data-testid":"SignUpForm",children:c(Vr,{activeSkeleton:"signUpForm"})}):x.status&&(l!=null&&l.SuccessNotification)?c(nr,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:l==null?void 0:l.SuccessNotification,context:{isSuccessful:x}}):f?c(Ar,{formSize:r,userEmail:A,inLineAlertProps:u,hideCloseBtnOnEmailConfirmation:b,handleSetInLineAlertProps:G,onPrimaryButtonClick:z}):$("div",{className:Fr(["auth-sign-up-form",`auth-sign-up-form--${r}`]),"data-testid":"SignUpForm",children:[c(Br,{title:m.title,divider:!1,className:"auth-sign-up-form__title"}),u.text?c(Kr,{className:"auth-sign-up-form__notification",type:u.type,variant:"secondary",heading:u.text,icon:u.icon}):null,$(Hr,{onSubmit:y,className:"auth-sign-up-form__form",loading:W,name:"signUp_form",fieldsConfig:q,slots:l,children:[$(cr,{validateLengthConfig:E,className:"auth-sign-up-form__form__field",autoComplete:"current-password",name:"password",minLength:i==null?void 0:i.minLength,errorMessage:K,defaultValue:V,uniqueSymbolsStatus:B,requiredCharacterClasses:i==null?void 0:i.requiredCharacterClasses,onValue:Z,placeholder:m.placeholder,floatingLabel:m.floatingLabel,onBlur:D,children:[n?c("div",{className:"auth-sign-up-form__form__confirm-wrapper",children:c(cr,{className:"auth-sign-up-form__form__field auth-sign-up-form__form__field--confirm-password",autoComplete:"confirmPassword",name:"confirmPasswordField",placeholder:m.confirmPasswordPlaceholder,floatingLabel:m.confirmPasswordFloatingLabel,errorMessage:H,defaultValue:J,onValue:R,onBlur:rr})}):null,er?c("div",{className:"auth-sign-up-form__automatic-login","data-testid":"automaticLogin",children:c(jr,{children:c(Ir,{name:"",placeholder:m.keepMeLoggedText,label:m.keepMeLoggedText,checked:Q,onChange:k})})}):null]}),c(nr,{name:"PrivacyPolicyConsent","data-testid":"privacyPolicyConsent",slot:l==null?void 0:l.PrivacyPolicyConsent},"privacyPolicyConsent"),$("div",{className:"auth-sign-up-form-buttons",children:[c(ur,{className:"auth-sign-up-form-buttons--signin",type:"button",variant:"tertiary",style:{padding:0},buttonText:m.buttonSecondary,enableLoader:!1,onClick:Y}),c(ur,{type:"submit",buttonText:m.buttonPrimary,variant:"primary",enableLoader:W})]})]}),c("div",{id:"createCustomerV2"})]})};export{ne as S};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{a as G,f as h,h as $}from"./network-error.js";import"@dropins/tools/recaptcha.js";import{events as w}from"@dropins/tools/event-bus.js";import{merge as k}from"@dropins/tools/lib.js";import{c as R}from"./initialize.js";import{CUSTOMER_INFORMATION_FRAGMENT as C}from"../fragments.js";import{a as U,C as O}from"./verifyToken.js";import{p as x,E as y}from"./acdl.js";import{s as F}from"./setReCaptchaToken.js";const v=t=>{var f,o,i,a,c,m,u,
|
|
3
|
+
import{a as G,f as h,h as $}from"./network-error.js";import"@dropins/tools/recaptcha.js";import{events as w}from"@dropins/tools/event-bus.js";import{merge as k}from"@dropins/tools/lib.js";import{c as R}from"./initialize.js";import{CUSTOMER_INFORMATION_FRAGMENT as C}from"../fragments.js";import{a as U,C as O}from"./verifyToken.js";import{p as x,E as y}from"./acdl.js";import{s as F}from"./setReCaptchaToken.js";const v=t=>{var f,o,i,a,c,m,u,s,T,r,g;const e={email:((o=(f=t==null?void 0:t.data)==null?void 0:f.customer)==null?void 0:o.email)??"",firstName:((a=(i=t==null?void 0:t.data)==null?void 0:i.customer)==null?void 0:a.firstname)??"",lastName:((m=(c=t==null?void 0:t.data)==null?void 0:c.customer)==null?void 0:m.lastname)??""};return k(e,(g=(r=(T=(s=(u=R)==null?void 0:u.getConfig())==null?void 0:s.models)==null?void 0:T.CustomerModel)==null?void 0:r.transformer)==null?void 0:g.call(r,t.data))},D=`
|
|
4
4
|
query GET_CUSTOMER_DATA {
|
|
5
5
|
customer {
|
|
6
6
|
...CUSTOMER_INFORMATION_FRAGMENT
|
|
@@ -13,4 +13,4 @@ import{a as G,f as h,h as $}from"./network-error.js";import"@dropins/tools/recap
|
|
|
13
13
|
token
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
`,V=async({email:t,password:e,translations:f,onErrorCallback:o,handleSetInLineAlertProps:i})=>{var r,
|
|
16
|
+
`,V=async({email:t,password:e,translations:f,onErrorCallback:o,handleSetInLineAlertProps:i})=>{var r,g,E,_,d;await F();const a=await h(H,{method:"POST",variables:{email:t,password:e}}).catch($);if(!((g=(r=a==null?void 0:a.data)==null?void 0:r.generateCustomerToken)!=null&&g.token)){const M=f.customerTokenErrorMessage,N=a!=null&&a.errors?a.errors[0].message:M;return o==null||o(N),i==null||i({type:"error",text:N}),{errorMessage:N,userName:""}}const c=(_=(E=a==null?void 0:a.data)==null?void 0:E.generateCustomerToken)==null?void 0:_.token,m=await K(c),u=m==null?void 0:m.firstName,s=m==null?void 0:m.email;if(!u||!s){const M=f.customerTokenErrorMessage;return o==null||o(M),i==null||i({type:"error",text:M}),{errorMessage:M,userName:"",userEmail:""}}const T=await U();return document.cookie=`${O.auth_dropin_firstname}=${u}; path=/; ${T}; `,document.cookie=`${O.auth_dropin_user_token}=${c}; path=/; ${T}; `,w.emit("authenticated",!!c),x((d=y)==null?void 0:d.SIGN_IN,{...m}),{errorMessage:"",userName:u,userEmail:s}};export{V as a,K as g};
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@dropins/storefront-auth", "version": "2.0
|
|
1
|
+
{"name": "@dropins/storefront-auth", "version": "2.1.0-alpha2", "@dropins/tools": "~1.2.0", "license": "SEE LICENSE IN LICENSE.md"}
|