@dropins/storefront-auth 2.2.1-beta1 → 3.0.0-beta1
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/getCustomerRolePermissions/getCustomerRolePermissions.d.ts +12 -0
- package/api/getCustomerRolePermissions/graphql/getCustomerRolePermissions.graphql.d.ts +2 -0
- package/api/getCustomerRolePermissions/index.d.ts +10 -0
- package/api/index.d.ts +1 -0
- package/api/initialize/initialize.d.ts +3 -10
- package/api.js +1 -1
- package/chunks/Button2.js +1 -1
- package/chunks/Button2.js.map +1 -1
- package/chunks/ResetPasswordForm.js +1 -1
- package/chunks/ResetPasswordForm.js.map +1 -1
- package/chunks/createCustomerAddress.js +1 -1
- package/chunks/createCustomerAddress.js.map +1 -1
- package/chunks/getCustomerRolePermissions.js +60 -0
- package/chunks/getCustomerRolePermissions.js.map +1 -0
- package/chunks/getCustomerToken.js +4 -4
- package/chunks/getCustomerToken.js.map +1 -1
- package/chunks/index2.js +1 -1
- package/chunks/index3.js +1 -1
- package/chunks/revokeCustomerToken.js +3 -3
- package/chunks/revokeCustomerToken.js.map +1 -1
- package/chunks/usePasswordValidationMessage.js +1 -1
- package/chunks/usePasswordValidationMessage.js.map +1 -1
- package/configs/cookieConfigs.d.ts +2 -1
- package/containers/SignIn.js +1 -1
- package/containers/SignIn.js.map +1 -1
- package/containers/SignUp.js +1 -1
- package/containers/SignUp.js.map +1 -1
- package/containers/SuccessNotification.js +1 -1
- package/containers/SuccessNotification.js.map +1 -1
- package/containers/UpdatePassword.js +1 -1
- package/containers/UpdatePassword.js.map +1 -1
- package/data/models/index.d.ts +1 -0
- package/data/models/permissions.d.ts +6 -0
- package/lib/base64ToSha1.d.ts +23 -0
- package/lib/emitAuthGroupId.d.ts +33 -0
- package/package.json +1 -1
- package/render.js +1 -1
- package/render.js.map +1 -1
- package/chunks/verifyToken.js +0 -26
- package/chunks/verifyToken.js.map +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PermissionsModel } from '../../data/models';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Gets user role permissions with caching
|
|
5
|
+
*/
|
|
6
|
+
export declare const getCustomerRolePermissions: () => Promise<PermissionsModel>;
|
|
7
|
+
/**
|
|
8
|
+
* Resets the permissions cache
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare const _resetCache: () => void;
|
|
12
|
+
//# sourceMappingURL=getCustomerRolePermissions.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const GET_CUSTOMER_ROLE_PERMISSIONS = "\n query GET_CUSTOMER_ROLE_PERMISSIONS {\n customer {\n purchase_orders_enabled\n role {\n id\n name\n permissions {\n id\n text\n children {\n id\n text\n children {\n id\n text\n children {\n id\n text\n children {\n id\n text\n children {\n id\n text\n }\n }\n }\n }\n }\n }\n }\n }\n }\n";
|
|
2
|
+
//# sourceMappingURL=getCustomerRolePermissions.graphql.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* Copyright 2025 Adobe
|
|
3
|
+
* All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* NOTICE: Adobe permits you to use, modify, and distribute this
|
|
6
|
+
* file in accordance with the terms of the Adobe license agreement
|
|
7
|
+
* accompanying it.
|
|
8
|
+
*******************************************************************/
|
|
9
|
+
export * from './getCustomerRolePermissions';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
package/api/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Initializer, Model } from '@dropins/tools/types/elsie/src/lib';
|
|
1
|
+
import { Initializer, Model, Config } from '@dropins/tools/types/elsie/src/lib';
|
|
2
2
|
import { Lang } from '@dropins/tools/types/elsie/src/i18n';
|
|
3
3
|
import { CustomerModel } from '../../data/models';
|
|
4
4
|
|
|
@@ -8,19 +8,12 @@ type ConfigProps = {
|
|
|
8
8
|
header: string;
|
|
9
9
|
tokenPrefix: string;
|
|
10
10
|
};
|
|
11
|
+
customerPermissionRoles?: boolean;
|
|
11
12
|
models?: {
|
|
12
13
|
CustomerModel?: Model<CustomerModel>;
|
|
13
14
|
};
|
|
14
15
|
};
|
|
15
|
-
/**
|
|
16
|
-
* Default customer group ID for Not Logged In (NLI) users.
|
|
17
|
-
* This value is emitted via the 'auth/group-uid' event when:
|
|
18
|
-
* - A user is not authenticated
|
|
19
|
-
* - Token verification fails
|
|
20
|
-
* - User logs out
|
|
21
|
-
*/
|
|
22
|
-
export declare const DEFAULT_NLI_CUSTOMER_GROUP_ID = "b6589fc6ab0dc82cf12099d1c2d40ab994e8410c";
|
|
23
16
|
export declare const initialize: Initializer<ConfigProps>;
|
|
24
|
-
export declare const config:
|
|
17
|
+
export declare const config: Config<ConfigProps>;
|
|
25
18
|
export {};
|
|
26
19
|
//# sourceMappingURL=initialize.d.ts.map
|
package/api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{c as n,a as g,g as c}from"./chunks/createCustomerAddress.js";import{g as
|
|
3
|
+
import{c as n,a as g,g as c}from"./chunks/createCustomerAddress.js";import{g as d,a as h}from"./chunks/getCustomerToken.js";import{_ as x,c as u,a as k,g as v,i as E,v as F}from"./chunks/getCustomerRolePermissions.js";import{r as Q}from"./chunks/requestPasswordResetEmail.js";import{r as P}from"./chunks/resetPassword.js";import{r as b}from"./chunks/revokeCustomerToken.js";import{c as A}from"./chunks/confirmEmail.js";import{r as _}from"./chunks/resendConfirmationEmail.js";import{f as y,g as z,r as D,s as S,a as j,b as B}from"./chunks/network-error.js";import"./fragments.js";import"./chunks/setReCaptchaToken.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";import"./chunks/transform-attributes-form.js";import"./chunks/acdl.js";import"@dropins/tools/fetch-graphql.js";export{x as _resetCache,u as config,A as confirmEmail,n as createCustomer,g as createCustomerAddress,y as fetchGraphQl,c as getAttributesForm,z as getConfig,d as getCustomerData,k as getCustomerRolePermissions,h as getCustomerToken,v as getStoreConfig,E as initialize,D as removeFetchGraphQlHeader,Q as requestPasswordResetEmail,_ as resendConfirmationEmail,P as resetPassword,b as revokeCustomerToken,S as setEndpoint,j as setFetchGraphQlHeader,B as setFetchGraphQlHeaders,F as verifyToken};
|
|
4
4
|
//# sourceMappingURL=api.js.map
|
package/chunks/Button2.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as s,jsxs as f}from"@dropins/tools/preact-jsx-runtime.js";import{useState as g,useCallback as
|
|
3
|
+
import{jsx as s,jsxs as f}from"@dropins/tools/preact-jsx-runtime.js";import{useState as g,useCallback as i}from"@dropins/tools/preact-hooks.js";import*as t from"@dropins/tools/preact-compat.js";import{classes as d}from"@dropins/tools/lib.js";import{Button as w}from"@dropins/tools/components.js";import"./Button.js";const M=e=>{if(!e)return null;const r=new FormData(e);if(r&&typeof r.entries=="function"){const n=r.entries();if(n&&typeof n[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(n)))||{}}return{}},S=e=>typeof e=="function",E=e=>t.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},t.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),t.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),k=e=>t.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},t.createElement("g",{clipPath:"url(#clip0_841_1324)"},t.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),t.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),t.createElement("defs",null,t.createElement("clipPath",{id:"clip0_841_1324"},t.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)",strokeWidth:1})))),v=e=>t.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},t.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),t.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),L={success:s(E,{}),warning:s(k,{}),error:s(v,{})},W=()=>{const[e,r]=g({}),n=i(o=>{if(!o||!o.type){r({});return}const c=L[o.type];r({...o,icon:c})},[]);return{inLineAlertProps:e,handleSetInLineAlertProps:n}},b=({type:e,buttonText:r,variant:n,className:o="",enableLoader:c=!1,onClick:a,style:l,icon:u,...h})=>{const m=i(p=>{a==null||a(p)},[a]);return f(w,{icon:u,style:l,type:e,variant:n,className:d(["auth-button",o,c?"enableLoader":""]),onClick:m,...h,children:[s("span",{className:"auth-button__text",children:r}),c?s("div",{className:"auth-button__wrapper",children:s("span",{className:"auth-button__loader"})}):null]})};export{b as B,S as c,M as g,W as u};
|
|
4
4
|
//# sourceMappingURL=Button2.js.map
|
package/chunks/Button2.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button2.js","sources":["/@dropins/storefront-auth/src/lib/getFormValues.ts","/@dropins/storefront-auth/src/lib/checkIsFunction.ts","../../node_modules/@adobe-commerce/elsie/src/icons/Warning.svg","../../node_modules/@adobe-commerce/elsie/src/icons/CheckWithCircle.svg","../../node_modules/@adobe-commerce/elsie/src/icons/WarningWithCircle.svg","/@dropins/storefront-auth/src/hooks/useInLineAlert.tsx","/@dropins/storefront-auth/src/components/Button/Button.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\nexport const getFormValues = (form: any) => {\n if (!form) return null;\n\n const formData = new FormData(form);\n\n if (formData && typeof formData.entries === 'function') {\n const entries = formData.entries();\n if (entries && typeof entries[Symbol.iterator] === 'function') {\n return JSON.parse(JSON.stringify(Object.fromEntries(entries))) || {};\n }\n }\n return {};\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 checkIsFunction = (value: any): value is Function => {\n return typeof value === 'function';\n};\n","import * as React from \"react\";\nconst SvgWarning = (props) => /* @__PURE__ */ React.createElement(\"svg\", { id: \"Icon_Warning_Base\", width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"g\", { clipPath: \"url(#clip0_841_1324)\" }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z\", stroke: \"currentColor\", strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z\", stroke: \"currentColor\", strokeLinecap: \"round\", strokeLinejoin: \"round\" })), /* @__PURE__ */ React.createElement(\"defs\", null, /* @__PURE__ */ React.createElement(\"clipPath\", { id: \"clip0_841_1324\" }, /* @__PURE__ */ React.createElement(\"rect\", { width: 24, height: 21, fill: \"white\", transform: \"translate(0 1.5)\" }))));\nexport default SvgWarning;\n","import * as React from \"react\";\nconst SvgCheckWithCircle = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z\", stroke: \"currentColor\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M6.75 12.762L10.2385 15.75L17.25 9\", stroke: \"currentColor\" }));\nexport default SvgCheckWithCircle;\n","import * as React from \"react\";\nconst SvgWarningWithCircle = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z\", stroke: \"currentColor\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z\", stroke: \"currentColor\" }));\nexport default SvgWarningWithCircle;\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 { useState, useCallback } from 'preact/hooks';\nimport { InLineAlertInterface } from '../types';\nimport {\n CheckWithCircle as Success,\n Warning,\n WarningWithCircle as Error,\n} from '@adobe-commerce/elsie/icons';\n\nconst iconsList = {\n success: <Success />,\n warning: <Warning />,\n error: <Error />,\n};\n\nexport const useInLineAlert = () => {\n const [inLineAlertProps, setInLineAlertProps] =\n useState<InLineAlertInterface>({});\n\n const handleSetInLineAlertProps = useCallback(\n (notification: InLineAlertInterface | undefined) => {\n if (!notification || !notification.type) {\n setInLineAlertProps({});\n return;\n }\n\n const icon = iconsList[notification.type];\n\n setInLineAlertProps({\n ...notification,\n icon,\n });\n },\n []\n );\n\n return { inLineAlertProps, handleSetInLineAlertProps };\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, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { useCallback } from 'preact/hooks';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport { Button as ElsieButton } from '@adobe-commerce/elsie/components';\nimport '@/auth/components/Button/Button.css';\n\nexport interface ButtonProps {\n type: 'submit' | 'button';\n variant?: 'primary' | 'secondary' | 'tertiary';\n className?: string;\n buttonText: string;\n enableLoader?: boolean;\n onClick?: (event: MouseEvent) => void;\n style?: Record<string, string | number>;\n icon?: VNode<HTMLAttributes<SVGSVGElement>>;\n disabled?: boolean;\n}\n\nexport const Button: FunctionComponent<ButtonProps> = ({\n type,\n buttonText,\n variant,\n className = '',\n enableLoader = false,\n onClick,\n style,\n icon,\n ...props\n}) => {\n const handleOnclick = useCallback(\n (event: MouseEvent) => {\n onClick?.(event);\n },\n [onClick]\n );\n\n const isLoader = enableLoader ? 'enableLoader' : '';\n\n return (\n <ElsieButton\n icon={icon}\n style={style}\n type={type}\n variant={variant}\n className={classes(['auth-button', className, isLoader])}\n onClick={handleOnclick}\n {...props}\n >\n <span className=\"auth-button__text\">{buttonText}</span>\n {enableLoader ? (\n <div className=\"auth-button__wrapper\">\n <span className=\"auth-button__loader\" />\n </div>\n ) : null}\n </ElsieButton>\n );\n};\n"],"names":["getFormValues","form","formData","entries","checkIsFunction","value","SvgWarning","props","React","SvgCheckWithCircle","SvgWarningWithCircle","iconsList","Success","Warning","Error","useInLineAlert","inLineAlertProps","setInLineAlertProps","useState","handleSetInLineAlertProps","useCallback","notification","icon","Button","type","buttonText","variant","className","enableLoader","onClick","style","handleOnclick","event","jsxs","ElsieButton","classes","jsx"],"mappings":"4TAiBO,MAAMA,EAAiBC,GAAc,CAC1C,GAAI,CAACA,EAAM,OAAO,KAElB,MAAMC,EAAW,IAAI,SAASD,CAAI,EAElC,GAAIC,GAAY,OAAOA,EAAS,SAAY,WAAY,CACtD,MAAMC,EAAUD,EAAS,QAAA,EACzB,GAAIC,GAAW,OAAOA,EAAQ,OAAO,QAAQ,GAAM,WACjD,OAAO,KAAK,MAAM,KAAK,UAAU,OAAO,YAAYA,CAAO,CAAC,CAAC,GAAK,CAAA,CAEtE,CACA,MAAO,CAAA,CACT,ECZaC,EAAmBC,GACvB,OAAOA,GAAU,WCjBpBC,EAAcC,GAA0BC,EAAM,cAAc,MAAO,CAAE,GAAI,oBAAqB,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,OAAQ,MAAO,6BAA8B,GAAGD,CAAK,EAAoBC,EAAM,cAAc,IAAK,CAAE,SAAU,wBAA0CA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,6DAA8D,OAAQ,eAAgB,cAAe,QAAS,eAAgB,OAAO,CAAE,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,qIAAsI,OAAQ,eAAgB,cAAe,QAAS,eAAgB,OAAO,CAAE,CAAC,EAAmBA,EAAM,cAAc,OAAQ,KAAsBA,EAAM,cAAc,WAAY,CAAE,GAAI,gBAAgB,EAAoBA,EAAM,cAAc,OAAQ,CAAE,MAAO,GAAI,OAAQ,GAAI,KAAM,QAAS,UAAW,mBAAoB,CAAC,CAAC,CAAC,ECAlhCC,EAAsBF,GAA0BC,EAAM,cAAc,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,OAAQ,MAAO,6BAA8B,GAAGD,CAAK,EAAoBC,EAAM,cAAc,OAAQ,CAAE,aAAc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AWS,EAAQ,CAAC,cAAeR,EARtBC,EAAe,eAAiB,EAQS,CAAC,EACvD,QAASG,EACR,GAAGxB,EAEJ,SAAA,CAAA6B,EAAC,OAAA,CAAK,UAAU,oBAAqB,SAAAX,EAAW,EAC/CG,EACCQ,EAAC,MAAA,CAAI,UAAU,uBACb,WAAC,OAAA,CAAK,UAAU,qBAAA,CAAsB,CAAA,CACxC,EACE,IAAA,CAAA,CAAA,CAGV","x_google_ignoreList":[2,3,4]}
|
|
1
|
+
{"version":3,"file":"Button2.js","sources":["/@dropins/storefront-auth/src/lib/getFormValues.ts","/@dropins/storefront-auth/src/lib/checkIsFunction.ts","../../node_modules/@adobe-commerce/elsie/src/icons/CheckWithCircle.svg","../../node_modules/@adobe-commerce/elsie/src/icons/Warning.svg","../../node_modules/@adobe-commerce/elsie/src/icons/WarningWithCircle.svg","/@dropins/storefront-auth/src/hooks/useInLineAlert.tsx","/@dropins/storefront-auth/src/components/Button/Button.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\nexport const getFormValues = (form: any) => {\n if (!form) return null;\n\n const formData = new FormData(form);\n\n if (formData && typeof formData.entries === 'function') {\n const entries = formData.entries();\n if (entries && typeof entries[Symbol.iterator] === 'function') {\n return JSON.parse(JSON.stringify(Object.fromEntries(entries))) || {};\n }\n }\n return {};\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 checkIsFunction = (value: any): value is Function => {\n return typeof value === 'function';\n};\n","import * as React from \"react\";\nconst SvgCheckWithCircle = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z\", stroke: \"currentColor\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M6.75 12.762L10.2385 15.75L17.25 9\", stroke: \"currentColor\" }));\nexport default SvgCheckWithCircle;\n","import * as React from \"react\";\nconst SvgWarning = (props) => /* @__PURE__ */ React.createElement(\"svg\", { id: \"Icon_Warning_Base\", width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"g\", { clipPath: \"url(#clip0_841_1324)\" }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" })), /* @__PURE__ */ React.createElement(\"defs\", null, /* @__PURE__ */ React.createElement(\"clipPath\", { id: \"clip0_841_1324\" }, /* @__PURE__ */ React.createElement(\"rect\", { width: 24, height: 21, fill: \"white\", transform: \"translate(0 1.5)\", strokeWidth: 1 }))));\nexport default SvgWarning;\n","import * as React from \"react\";\nconst SvgWarningWithCircle = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z\", stroke: \"currentColor\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z\", stroke: \"currentColor\" }));\nexport default SvgWarningWithCircle;\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 { useState, useCallback } from 'preact/hooks';\nimport { InLineAlertInterface } from '../types';\nimport {\n CheckWithCircle as Success,\n Warning,\n WarningWithCircle as Error,\n} from '@adobe-commerce/elsie/icons';\n\nconst iconsList = {\n success: <Success />,\n warning: <Warning />,\n error: <Error />,\n};\n\nexport const useInLineAlert = () => {\n const [inLineAlertProps, setInLineAlertProps] =\n useState<InLineAlertInterface>({});\n\n const handleSetInLineAlertProps = useCallback(\n (notification: InLineAlertInterface | undefined) => {\n if (!notification || !notification.type) {\n setInLineAlertProps({});\n return;\n }\n\n const icon = iconsList[notification.type];\n\n setInLineAlertProps({\n ...notification,\n icon,\n });\n },\n []\n );\n\n return { inLineAlertProps, handleSetInLineAlertProps };\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, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { useCallback } from 'preact/hooks';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport { Button as ElsieButton } from '@adobe-commerce/elsie/components';\nimport '@/auth/components/Button/Button.css';\n\nexport interface ButtonProps {\n type: 'submit' | 'button';\n variant?: 'primary' | 'secondary' | 'tertiary';\n className?: string;\n buttonText: string;\n enableLoader?: boolean;\n onClick?: (event: MouseEvent) => void;\n style?: Record<string, string | number>;\n icon?: VNode<HTMLAttributes<SVGSVGElement>>;\n disabled?: boolean;\n}\n\nexport const Button: FunctionComponent<ButtonProps> = ({\n type,\n buttonText,\n variant,\n className = '',\n enableLoader = false,\n onClick,\n style,\n icon,\n ...props\n}) => {\n const handleOnclick = useCallback(\n (event: MouseEvent) => {\n onClick?.(event);\n },\n [onClick]\n );\n\n const isLoader = enableLoader ? 'enableLoader' : '';\n\n return (\n <ElsieButton\n icon={icon}\n style={style}\n type={type}\n variant={variant}\n className={classes(['auth-button', className, isLoader])}\n onClick={handleOnclick}\n {...props}\n >\n <span className=\"auth-button__text\">{buttonText}</span>\n {enableLoader ? (\n <div className=\"auth-button__wrapper\">\n <span className=\"auth-button__loader\" />\n </div>\n ) : null}\n </ElsieButton>\n );\n};\n"],"names":["getFormValues","form","formData","entries","checkIsFunction","value","SvgCheckWithCircle","props","React","SvgWarning","SvgWarningWithCircle","iconsList","Success","Warning","Error","useInLineAlert","inLineAlertProps","setInLineAlertProps","useState","handleSetInLineAlertProps","useCallback","notification","icon","Button","type","buttonText","variant","className","enableLoader","onClick","style","handleOnclick","event","jsxs","ElsieButton","classes","jsx"],"mappings":"4TAiBO,MAAMA,EAAiBC,GAAc,CAC1C,GAAI,CAACA,EAAM,OAAO,KAElB,MAAMC,EAAW,IAAI,SAASD,CAAI,EAElC,GAAIC,GAAY,OAAOA,EAAS,SAAY,WAAY,CACtD,MAAMC,EAAUD,EAAS,QAAA,EACzB,GAAIC,GAAW,OAAOA,EAAQ,OAAO,QAAQ,GAAM,WACjD,OAAO,KAAK,MAAM,KAAK,UAAU,OAAO,YAAYA,CAAO,CAAC,CAAC,GAAK,CAAA,CAEtE,CACA,MAAO,CAAA,CACT,ECZaC,EAAmBC,GACvB,OAAOA,GAAU,WCjBpBC,EAAsBC,GAA0BC,EAAM,cAAc,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,OAAQ,MAAO,6BAA8B,GAAGD,CAAK,EAAoBC,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,0JAA2J,OAAQ,cAAc,CAAE,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,qCAAsC,OAAQ,cAAc,CAAE,CAAC,ECAxlBC,EAAcF,GAA0BC,EAAM,cAAc,MAAO,CAAE,GAAI,oBAAqB,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,OAAQ,MAAO,6BAA8B,GAAGD,GAAyBC,EAAM,cAAc,IAAK,CAAE,SAAU,sBAAsB,EAAoBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,6DAA8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AAC,EAAe,GACf,QAAAC,EACA,MAAAC,EACA,KAAAR,EACA,GAAGf,CACL,IAAM,CACJ,MAAMwB,EAAgBX,EACnBY,GAAsB,CACrBH,GAAA,MAAAA,EAAUG,EACZ,EACA,CAACH,CAAO,CAAA,EAKV,OACEI,EAACC,EAAA,CACC,KAAAZ,EACA,MAAAQ,EACA,KAAAN,EACA,QAAAE,EACA,UAAWS,EAAQ,CAAC,cAAeR,EARtBC,EAAe,eAAiB,EAQS,CAAC,EACvD,QAASG,EACR,GAAGxB,EAEJ,SAAA,CAAA6B,EAAC,OAAA,CAAK,UAAU,oBAAqB,SAAAX,EAAW,EAC/CG,EACCQ,EAAC,MAAA,CAAI,UAAU,uBACb,WAAC,OAAA,CAAK,UAAU,qBAAA,CAAsB,CAAA,CACxC,EACE,IAAA,CAAA,CAAA,CAGV","x_google_ignoreList":[2,3,4]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsxs as l,jsx as
|
|
3
|
+
import{jsxs as l,jsx as o}from"@dropins/tools/preact-jsx-runtime.js";import{classes as h}from"@dropins/tools/lib.js";import{v as _,F}from"./Button.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{r as P}from"./requestPasswordResetEmail.js";import{g as v,c as p,u as x,B as g}from"./Button2.js";import{useState as N,useCallback as y}from"@dropins/tools/preact-hooks.js";import{useText as b}from"@dropins/tools/i18n.js";import{Header as E,InLineAlert as L}from"@dropins/tools/components.js";import{s as T,D}from"./simplifyTransformAttributesForm.js";import*as R from"@dropins/tools/preact-compat.js";const A=s=>R.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},R.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1,strokeLinecap:"square",strokeLinejoin:"round"})),j=({routeSignIn:s,onErrorCallback:a,onSuccessCallback:m,setActiveComponent:n,handleSetInLineAlertProps:t})=>{const c=b({successPasswordResetEmailNotification:"Auth.Notification.successPasswordResetEmailNotification"}),[i,e]=N(!1),f=y(async d=>{d.preventDefault();const r=v(d.target);if(!_(r==null?void 0:r.email))return;e(!0);const w=await P(r.email);if(e(!1),!w.success){a==null||a(w),t==null||t({type:"error",text:w.message});return}if(m){await m();return}t==null||t({type:"success",text:c.successPasswordResetEmailNotification.replace("{email}",r.email)})},[t,a,m,c.successPasswordResetEmailNotification]),u=y(()=>{if(p(n)){n("signInForm");return}p(s)&&(window.location.href=s())},[n,s]);return{isLoading:i,submitResetPassword:f,redirectToSignInPage:u}},J=({formSize:s="default",routeSignIn:a,setActiveComponent:m,onErrorCallback:n,onSuccessCallback:t,...c})=>{const i=b({title:"Auth.ResetPasswordForm.title",buttonPrimary:"Auth.ResetPasswordForm.buttonPrimary",buttonSecondary:"Auth.ResetPasswordForm.buttonSecondary",formAriaLabel:"Auth.ResetPasswordForm.formAriaLabel"}),{inLineAlertProps:e,handleSetInLineAlertProps:f}=x(),{isLoading:u,submitResetPassword:d,redirectToSignInPage:r}=j({routeSignIn:a,setActiveComponent:m,onErrorCallback:n,onSuccessCallback:t,handleSetInLineAlertProps:f});return l("div",{...c,className:h(["auth-reset-password-form",`auth-reset-password-form--${s}`]),"data-testid":"resetPasswordForm",children:[o(E,{title:i.title,divider:!1,className:"auth-reset-password-form__title"}),e.text?o(L,{className:"auth-reset-password-form__notification",type:e.type,variant:"secondary",heading:e.text,icon:e.icon}):null,o(F,{"aria-labelledby":i.formAriaLabel,name:"resetPassword_form",className:"auth-reset-password-form__form",onSubmit:d,loading:u,fieldsConfig:T(D),children:l("div",{className:"auth-reset-password-form__buttons",children:[o(g,{className:"auth-reset-password-form__buttons--signin",type:"button",variant:"tertiary",style:{padding:"0"},icon:o(A,{style:{transform:"rotate(90deg)"}}),buttonText:i.buttonSecondary,enableLoader:!1,onClick:r}),o(g,{type:"submit",buttonText:i.buttonPrimary,variant:"primary",enableLoader:u})]})}),o("div",{id:"requestPasswordResetEmail"})]})};export{J as R};
|
|
4
4
|
//# sourceMappingURL=ResetPasswordForm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResetPasswordForm.js","sources":["../../node_modules/@adobe-commerce/elsie/src/icons/ChevronDown.svg","/@dropins/storefront-auth/src/hooks/components/useResetPasswordForm.tsx","/@dropins/storefront-auth/src/components/ResetPasswordForm/ResetPasswordForm.tsx"],"sourcesContent":["import * as React from \"react\";\nconst SvgChevronDown = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { d: \"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701\", stroke: \"currentColor\", strokeWidth: 1.5, strokeLinecap: \"square\", strokeLinejoin: \"round\" }));\nexport default SvgChevronDown;\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 { requestPasswordResetEmail } from '@/auth/api';\nimport { checkIsFunction } from '@/auth/lib/checkIsFunction';\nimport { getFormValues } from '@/auth/lib/getFormValues';\nimport { UseResetPasswordFormProps } from '@/auth/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { useCallback, useState } from 'preact/hooks';\nimport { validateEmail } from '@/auth/lib/validationFields';\n\nexport const useResetPasswordForm = ({\n routeSignIn,\n onErrorCallback,\n onSuccessCallback,\n setActiveComponent,\n handleSetInLineAlertProps,\n}: UseResetPasswordFormProps) => {\n const translations = useText({\n successPasswordResetEmailNotification:\n 'Auth.Notification.successPasswordResetEmailNotification',\n });\n const [isLoading, setIsLoading] = useState(false);\n\n const submitResetPassword = useCallback(\n async (event: any): Promise<void> => {\n event.preventDefault();\n\n const formValues = getFormValues(event.target);\n\n if (!validateEmail(formValues?.email)) {\n return;\n }\n\n setIsLoading(true);\n\n const response = await requestPasswordResetEmail(formValues.email);\n\n setIsLoading(false);\n\n if (!response.success) {\n onErrorCallback?.(response);\n handleSetInLineAlertProps?.({\n type: 'error',\n text: response.message,\n });\n return;\n }\n\n if (onSuccessCallback) {\n await onSuccessCallback();\n return;\n }\n\n handleSetInLineAlertProps?.({\n type: 'success',\n text: translations.successPasswordResetEmailNotification.replace(\n '{email}',\n formValues.email\n ),\n });\n },\n [\n handleSetInLineAlertProps,\n onErrorCallback,\n onSuccessCallback,\n translations.successPasswordResetEmailNotification,\n ]\n );\n\n const redirectToSignInPage = useCallback(() => {\n if (checkIsFunction(setActiveComponent)) {\n setActiveComponent('signInForm');\n return;\n }\n\n if (checkIsFunction(routeSignIn)) {\n window.location.href = routeSignIn();\n }\n }, [setActiveComponent, routeSignIn]);\n\n return {\n isLoading,\n submitResetPassword,\n redirectToSignInPage,\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 { FunctionComponent } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport '@/auth/components/ResetPasswordForm/ResetPasswordForm.css';\nimport { useResetPasswordForm } from '@/auth/hooks/components/useResetPasswordForm';\nimport { ResetPasswordFormProps } from '@/auth/types';\nimport { ChevronDown as ChevronLeft } from '@adobe-commerce/elsie/icons';\nimport { Form, Button } from '@/auth/components';\nimport { useInLineAlert } from '@/auth/hooks/useInLineAlert';\nimport { Header, InLineAlert } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { simplifyTransformAttributesForm } from '@/auth/lib/simplifyTransformAttributesForm';\nimport { DEFAULT__RESET_PASSWORD_EMAIL_FIELD } from '@/auth/configs/defaultCreateUserConfigs';\n\nexport const ResetPasswordForm: FunctionComponent<\n ResetPasswordFormProps & HTMLAttributes<HTMLDivElement>\n> = ({\n formSize = 'default',\n routeSignIn,\n setActiveComponent,\n onErrorCallback,\n onSuccessCallback,\n ...props\n}) => {\n const translations = useText({\n title: 'Auth.ResetPasswordForm.title',\n buttonPrimary: 'Auth.ResetPasswordForm.buttonPrimary',\n buttonSecondary: 'Auth.ResetPasswordForm.buttonSecondary',\n formAriaLabel: 'Auth.ResetPasswordForm.formAriaLabel',\n });\n\n const { inLineAlertProps, handleSetInLineAlertProps } = useInLineAlert();\n\n const { isLoading, submitResetPassword, redirectToSignInPage } =\n useResetPasswordForm({\n routeSignIn,\n setActiveComponent,\n onErrorCallback,\n onSuccessCallback,\n handleSetInLineAlertProps,\n });\n\n return (\n <div\n {...props}\n className={classes([\n 'auth-reset-password-form',\n `auth-reset-password-form--${formSize}`,\n ])}\n data-testid=\"resetPasswordForm\"\n >\n <Header\n title={translations.title}\n divider={false}\n className=\"auth-reset-password-form__title\"\n />\n {inLineAlertProps.text ? (\n <InLineAlert\n className=\"auth-reset-password-form__notification\"\n type={inLineAlertProps.type}\n variant=\"secondary\"\n heading={inLineAlertProps.text}\n icon={inLineAlertProps.icon}\n />\n ) : null}\n <Form\n aria-labelledby={translations.formAriaLabel}\n name=\"resetPassword_form\"\n className=\"auth-reset-password-form__form\"\n onSubmit={submitResetPassword}\n loading={isLoading}\n fieldsConfig={simplifyTransformAttributesForm(\n DEFAULT__RESET_PASSWORD_EMAIL_FIELD\n )}\n >\n <div className=\"auth-reset-password-form__buttons\">\n <Button\n className=\"auth-reset-password-form__buttons--signin\"\n type=\"button\"\n variant=\"tertiary\"\n style={{ padding: '0' }}\n icon={<ChevronLeft style={{ transform: 'rotate(90deg)' }} />}\n buttonText={translations.buttonSecondary}\n enableLoader={false}\n onClick={redirectToSignInPage}\n />\n <Button\n type=\"submit\"\n buttonText={translations.buttonPrimary}\n variant=\"primary\"\n enableLoader={isLoading}\n />\n </div>\n </Form>\n <div id=\"requestPasswordResetEmail\" />\n </div>\n );\n};\n"],"names":["SvgChevronDown","props","React","useResetPasswordForm","routeSignIn","onErrorCallback","onSuccessCallback","setActiveComponent","handleSetInLineAlertProps","translations","useText","isLoading","setIsLoading","useState","submitResetPassword","useCallback","event","formValues","getFormValues","validateEmail","response","requestPasswordResetEmail","redirectToSignInPage","checkIsFunction","ResetPasswordForm","formSize","inLineAlertProps","useInLineAlert","jsxs","classes","jsx","Header","InLineAlert","Form","simplifyTransformAttributesForm","DEFAULT__RESET_PASSWORD_EMAIL_FIELD","Button","ChevronLeft"],"mappings":"wnBACA,MAAMA,EAAkBC,GAA0BC,EAAM,cAAc,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,OAAQ,MAAO,6BAA8B,GAAGD,CAAK,EAAoBC,EAAM,cAAc,OAAQ,CAAE,EAAG,kDAAmD,OAAQ,eAAgB,YAAa,IAAK,cAAe,SAAU,eAAgB,OAAO,CAAE,CAAC,ECwB/WC,EAAuB,CAAC,CACnC,YAAAC,EACA,gBAAAC,EACA,kBAAAC,EACA,mBAAAC,EACA,0BAAAC,CACF,IAAiC,CAC/B,MAAMC,EAAeC,EAAQ,CAC3B,sCACE,yDAAA,CACH,EACK,CAACC,EAAWC,CAAY,EAAIC,EAAS,EAAK,EAE1CC,EAAsBC,EAC1B,MAAOC,GAA8B,CACnCA,EAAM,eAAA,EAEN,MAAMC,EAAa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AW4B,EAAQ,CACjB,2BACA,6BAA6BJ,CAAQ,EAAA,CACtC,EACD,cAAY,oBAEZ,SAAA,CAAAK,EAACC,EAAA,CACC,MAAOtB,EAAa,MACpB,QAAS,GACT,UAAU,iCAAA,CAAA,EAEXiB,EAAiB,KAChBI,EAACE,EAAA,CACC,UAAU,yCACV,KAAMN,EAAiB,KACvB,QAAQ,YACR,QAASA,EAAiB,KAC1B,KAAMA,EAAiB,IAAA,CAAA,EAEvB,KACJI,EAACG,EAAA,CACC,kBAAiBxB,EAAa,cAC9B,KAAK,qBACL,UAAU,iCACV,SAAUK,EACV,QAASH,EACT,aAAcuB,EACZC,CAAA,EAGF,SAAAP,EAAC,MAAA,CAAI,UAAU,oCACb,SAAA,CAAAE,EAACM,EAAA,CACC,UAAU,4CACV,KAAK,SACL,QAAQ,WACR,MAAO,CAAE,QAAS,GAAA,EAClB,KAAMN,EAACO,EAAA,CAAY,MAAO,CAAE,UAAW,iBAAmB,EAC1D,WAAY5B,EAAa,gBACzB,aAAc,GACd,QAASa,CAAA,CAAA,EAEXQ,EAACM,EAAA,CACC,KAAK,SACL,WAAY3B,EAAa,cACzB,QAAQ,UACR,aAAcE,CAAA,CAAA,CAChB,CAAA,CACF,CAAA,CAAA,EAEFmB,EAAC,MAAA,CAAI,GAAG,2BAAA,CAA4B,CAAA,CAAA,CAAA,CAG1C","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"ResetPasswordForm.js","sources":["../../node_modules/@adobe-commerce/elsie/src/icons/ChevronDown.svg","/@dropins/storefront-auth/src/hooks/components/useResetPasswordForm.tsx","/@dropins/storefront-auth/src/components/ResetPasswordForm/ResetPasswordForm.tsx"],"sourcesContent":["import * as React from \"react\";\nconst SvgChevronDown = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"square\", strokeLinejoin: \"round\" }));\nexport default SvgChevronDown;\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 { requestPasswordResetEmail } from '@/auth/api';\nimport { checkIsFunction } from '@/auth/lib/checkIsFunction';\nimport { getFormValues } from '@/auth/lib/getFormValues';\nimport { UseResetPasswordFormProps } from '@/auth/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { useCallback, useState } from 'preact/hooks';\nimport { validateEmail } from '@/auth/lib/validationFields';\n\nexport const useResetPasswordForm = ({\n routeSignIn,\n onErrorCallback,\n onSuccessCallback,\n setActiveComponent,\n handleSetInLineAlertProps,\n}: UseResetPasswordFormProps) => {\n const translations = useText({\n successPasswordResetEmailNotification:\n 'Auth.Notification.successPasswordResetEmailNotification',\n });\n const [isLoading, setIsLoading] = useState(false);\n\n const submitResetPassword = useCallback(\n async (event: any): Promise<void> => {\n event.preventDefault();\n\n const formValues = getFormValues(event.target);\n\n if (!validateEmail(formValues?.email)) {\n return;\n }\n\n setIsLoading(true);\n\n const response = await requestPasswordResetEmail(formValues.email);\n\n setIsLoading(false);\n\n if (!response.success) {\n onErrorCallback?.(response);\n handleSetInLineAlertProps?.({\n type: 'error',\n text: response.message,\n });\n return;\n }\n\n if (onSuccessCallback) {\n await onSuccessCallback();\n return;\n }\n\n handleSetInLineAlertProps?.({\n type: 'success',\n text: translations.successPasswordResetEmailNotification.replace(\n '{email}',\n formValues.email\n ),\n });\n },\n [\n handleSetInLineAlertProps,\n onErrorCallback,\n onSuccessCallback,\n translations.successPasswordResetEmailNotification,\n ]\n );\n\n const redirectToSignInPage = useCallback(() => {\n if (checkIsFunction(setActiveComponent)) {\n setActiveComponent('signInForm');\n return;\n }\n\n if (checkIsFunction(routeSignIn)) {\n window.location.href = routeSignIn();\n }\n }, [setActiveComponent, routeSignIn]);\n\n return {\n isLoading,\n submitResetPassword,\n redirectToSignInPage,\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 { FunctionComponent } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport '@/auth/components/ResetPasswordForm/ResetPasswordForm.css';\nimport { useResetPasswordForm } from '@/auth/hooks/components/useResetPasswordForm';\nimport { ResetPasswordFormProps } from '@/auth/types';\nimport { ChevronDown as ChevronLeft } from '@adobe-commerce/elsie/icons';\nimport { Form, Button } from '@/auth/components';\nimport { useInLineAlert } from '@/auth/hooks/useInLineAlert';\nimport { Header, InLineAlert } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { simplifyTransformAttributesForm } from '@/auth/lib/simplifyTransformAttributesForm';\nimport { DEFAULT__RESET_PASSWORD_EMAIL_FIELD } from '@/auth/configs/defaultCreateUserConfigs';\n\nexport const ResetPasswordForm: FunctionComponent<\n ResetPasswordFormProps & HTMLAttributes<HTMLDivElement>\n> = ({\n formSize = 'default',\n routeSignIn,\n setActiveComponent,\n onErrorCallback,\n onSuccessCallback,\n ...props\n}) => {\n const translations = useText({\n title: 'Auth.ResetPasswordForm.title',\n buttonPrimary: 'Auth.ResetPasswordForm.buttonPrimary',\n buttonSecondary: 'Auth.ResetPasswordForm.buttonSecondary',\n formAriaLabel: 'Auth.ResetPasswordForm.formAriaLabel',\n });\n\n const { inLineAlertProps, handleSetInLineAlertProps } = useInLineAlert();\n\n const { isLoading, submitResetPassword, redirectToSignInPage } =\n useResetPasswordForm({\n routeSignIn,\n setActiveComponent,\n onErrorCallback,\n onSuccessCallback,\n handleSetInLineAlertProps,\n });\n\n return (\n <div\n {...props}\n className={classes([\n 'auth-reset-password-form',\n `auth-reset-password-form--${formSize}`,\n ])}\n data-testid=\"resetPasswordForm\"\n >\n <Header\n title={translations.title}\n divider={false}\n className=\"auth-reset-password-form__title\"\n />\n {inLineAlertProps.text ? (\n <InLineAlert\n className=\"auth-reset-password-form__notification\"\n type={inLineAlertProps.type}\n variant=\"secondary\"\n heading={inLineAlertProps.text}\n icon={inLineAlertProps.icon}\n />\n ) : null}\n <Form\n aria-labelledby={translations.formAriaLabel}\n name=\"resetPassword_form\"\n className=\"auth-reset-password-form__form\"\n onSubmit={submitResetPassword}\n loading={isLoading}\n fieldsConfig={simplifyTransformAttributesForm(\n DEFAULT__RESET_PASSWORD_EMAIL_FIELD\n )}\n >\n <div className=\"auth-reset-password-form__buttons\">\n <Button\n className=\"auth-reset-password-form__buttons--signin\"\n type=\"button\"\n variant=\"tertiary\"\n style={{ padding: '0' }}\n icon={<ChevronLeft style={{ transform: 'rotate(90deg)' }} />}\n buttonText={translations.buttonSecondary}\n enableLoader={false}\n onClick={redirectToSignInPage}\n />\n <Button\n type=\"submit\"\n buttonText={translations.buttonPrimary}\n variant=\"primary\"\n enableLoader={isLoading}\n />\n </div>\n </Form>\n <div id=\"requestPasswordResetEmail\" />\n </div>\n );\n};\n"],"names":["SvgChevronDown","props","React","useResetPasswordForm","routeSignIn","onErrorCallback","onSuccessCallback","setActiveComponent","handleSetInLineAlertProps","translations","useText","isLoading","setIsLoading","useState","submitResetPassword","useCallback","event","formValues","getFormValues","validateEmail","response","requestPasswordResetEmail","redirectToSignInPage","checkIsFunction","ResetPasswordForm","formSize","inLineAlertProps","useInLineAlert","jsxs","classes","jsx","Header","InLineAlert","Form","simplifyTransformAttributesForm","DEFAULT__RESET_PASSWORD_EMAIL_FIELD","Button","ChevronLeft"],"mappings":"wnBACA,MAAMA,EAAkBC,GAA0BC,EAAM,cAAc,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,OAAQ,MAAO,6BAA8B,GAAGD,CAAK,EAAoBC,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,kDAAmD,OAAQ,eAAgB,YAAa,EAAG,cAAe,SAAU,eAAgB,OAAO,CAAE,CAAC,ECwBjZC,EAAuB,CAAC,CACnC,YAAAC,EACA,gBAAAC,EACA,kBAAAC,EACA,mBAAAC,EACA,0BAAAC,CACF,IAAiC,CAC/B,MAAMC,EAAeC,EAAQ,CAC3B,sCACE,yDAAA,CACH,EACK,CAACC,EAAWC,CAAY,EAAIC,EAAS,EAAK,EAE1CC,EAAsBC,EAC1B,MAAOC,GAA8B,CACnCA,EAAM,eAAA,EAEN,MAAMC,EAAaC,EAAcF,EAAM,MAAM,EAE7C,GAAI,CAACG,EAAcF,GAAA,YAAAA,EAAY,KAAK,EAClC,OAGFL,EAAa,EAAI,EAEjB,MAAMQ,EAAW,MAAMC,EAA0BJ,EAAW,KAAK,EAIjE,GAFAL,EAAa,EAAK,EAEd,CAACQ,EAAS,QAAS,CACrBf,GAAA,MAAAA,EAAkBe,GAClBZ,GAAA,MAAAA,EAA4B,CAC1B,KAAM,QACN,KAAMY,EAAS,OAAA,GAEjB,MACF,CAEA,GAAId,EAAmB,CACrB,MAAMA,EAAA,EACN,MACF,CAEAE,GAAA,MAAAA,EAA4B,CAC1B,KAAM,UACN,KAAMC,EAAa,sCAAsC,QACvD,UACAQ,EAAW,KAAA,CACb,EAEJ,EACA,CACET,EACAH,EACAC,EACA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,4CACV,KAAK,SACL,QAAQ,WACR,MAAO,CAAE,QAAS,GAAA,EAClB,KAAMN,EAACO,EAAA,CAAY,MAAO,CAAE,UAAW,iBAAmB,EAC1D,WAAY5B,EAAa,gBACzB,aAAc,GACd,QAASa,CAAA,CAAA,EAEXQ,EAACM,EAAA,CACC,KAAK,SACL,WAAY3B,EAAa,cACzB,QAAQ,UACR,aAAcE,CAAA,CAAA,CAChB,CAAA,CACF,CAAA,CAAA,EAEFmB,EAAC,MAAA,CAAI,GAAG,2BAAA,CAA4B,CAAA,CAAA,CAAA,CAG1C","x_google_ignoreList":[0]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{CUSTOMER_INFORMATION_FRAGMENT as O}from"../fragments.js";import{f as s,h as u}from"./network-error.js";import{s as b}from"./setReCaptchaToken.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{merge as N}from"@dropins/tools/lib.js";import{c as p,h as S}from"./
|
|
3
|
+
import{CUSTOMER_INFORMATION_FRAGMENT as O}from"../fragments.js";import{f as s,h as u}from"./network-error.js";import{s as b}from"./setReCaptchaToken.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{merge as N}from"@dropins/tools/lib.js";import{c as p,h as S}from"./getCustomerRolePermissions.js";import{t as F}from"./transform-attributes-form.js";const I=`
|
|
4
4
|
mutation CREATE_CUSTOMER($input: CustomerInput!) {
|
|
5
5
|
createCustomer(input: $input) {
|
|
6
6
|
customer {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCustomerAddress.js","sources":["/@dropins/storefront-auth/src/api/createCustomer/graphql/createCustomer.graphql.ts","/@dropins/storefront-auth/src/api/createCustomer/graphql/createCustomerV2.graphql.ts","/@dropins/storefront-auth/src/data/transforms/transform-create-customer.tsx","/@dropins/storefront-auth/src/lib/transformDobForm.ts","/@dropins/storefront-auth/src/api/createCustomer/createCustomer.ts","/@dropins/storefront-auth/src/api/getAttributesForm/graphql/getAttributesForm.graphql.ts","/@dropins/storefront-auth/src/api/getAttributesForm/getAttributesForm.ts","/@dropins/storefront-auth/src/api/createCustomerAddress/graphql/createCustomerAddress.graphql.ts","/@dropins/storefront-auth/src/api/createCustomerAddress/createCustomerAddress.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 { CUSTOMER_INFORMATION_FRAGMENT } from '@/auth/api/fragments';\n\nexport const CREATE_CUSTOMER = /* GraphQL */ `\n mutation CREATE_CUSTOMER($input: CustomerInput!) {\n createCustomer(input: $input) {\n customer {\n ...CUSTOMER_INFORMATION_FRAGMENT\n }\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 { CUSTOMER_INFORMATION_FRAGMENT } from '@/auth/api/fragments';\n\nexport const CREATE_CUSTOMER_V2 = /* GraphQL */ `\n mutation CREATE_CUSTOMER_V2($input: CustomerCreateInput!) {\n createCustomerV2(input: $input) {\n customer {\n ...CUSTOMER_INFORMATION_FRAGMENT\n }\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 { DataCreateCustomerV2, DataCreateCustomer } from '@/auth/types';\nimport { config } from '@/auth/api';\nimport { merge } from '@adobe-commerce/elsie/lib';\nimport { CustomerModel } from '../models';\n\ntype ApiResponse<T extends boolean> = T extends true\n ? DataCreateCustomerV2\n : DataCreateCustomer;\n\nexport const transformCreateCustomer = <T extends boolean>(\n response: ApiResponse<T>,\n apiVersion2: T\n): CustomerModel => {\n let model: CustomerModel;\n\n if (apiVersion2) {\n const { data } = response as DataCreateCustomerV2;\n\n model = {\n firstName: data?.createCustomerV2?.customer?.firstname ?? '',\n lastName: data?.createCustomerV2?.customer?.lastname ?? '',\n email: data?.createCustomerV2?.customer?.email ?? '',\n customAttributes: data?.createCustomerV2?.custom_attributes ?? [],\n errors: response?.errors ?? [],\n };\n } else {\n const { data } = response as DataCreateCustomer;\n\n model = {\n firstName: data?.createCustomer?.customer?.firstname ?? '',\n lastName: data?.createCustomer?.customer?.lastname ?? '',\n email: data?.createCustomer?.customer?.email ?? '',\n errors: response?.errors ?? [],\n };\n }\n\n return merge(\n model, // default transformer\n config.getConfig().models?.CustomerModel?.transformer?.(response) // custom transformer\n );\n};\n","export const transformDobForm = (\n form: Record<string, any>\n): Record<string, any> => {\n if (!form.dob) return form;\n\n const { dob, ...rest } = form;\n return { ...rest, date_of_birth: dob };\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 } from '@/auth/types';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { CREATE_CUSTOMER } from './graphql/createCustomer.graphql';\nimport { CREATE_CUSTOMER_V2 } from './graphql/createCustomerV2.graphql';\nimport { handleNetworkError } from '@/auth/lib/network-error';\nimport { setReCaptchaToken } from '@/auth/lib/setReCaptchaToken';\nimport { transformCreateCustomer } from '@/auth/data/transforms';\nimport { CustomerModel } from '@/auth/data/models';\nimport { transformDobForm } from '@/auth/lib/transformDobForm';\n\nexport const createCustomer = async (\n forms: Customer,\n apiVersion2: boolean\n): Promise<CustomerModel> => {\n await setReCaptchaToken();\n\n const response = await fetchGraphQl(\n apiVersion2 ? CREATE_CUSTOMER_V2 : CREATE_CUSTOMER,\n {\n method: 'POST',\n variables: {\n input: {\n ...transformDobForm(forms),\n },\n },\n }\n ).catch(handleNetworkError);\n\n return transformCreateCustomer(response, apiVersion2);\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_ATTRIBUTES_FORM = /* GraphQL */ `\n query GET_ATTRIBUTES_FORM($formCode: String!) {\n attributesForm(formCode: $formCode) {\n items {\n code\n default_value\n entity_type\n frontend_class\n frontend_input\n is_required\n is_unique\n label\n options {\n is_default\n label\n value\n }\n ... on CustomerAttributeMetadata {\n multiline_count\n sort_order\n validate_rules {\n name\n value\n }\n }\n }\n errors {\n type\n message\n }\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 { fetchGraphQl } from '../fetch-graphql';\nimport { GET_ATTRIBUTES_FORM } from './graphql/getAttributesForm.graphql';\nimport { handleNetworkError } from '@/auth/lib/network-error';\nimport { transformAttributesForm } from '@/auth/data/transforms';\nimport { handleFetchError } from '@/auth/lib/fetch-error';\nimport { AttributesFormModel } from '@/auth/data/models';\nimport { GetAttributesFormResponse } from '@/auth/types';\n\nexport const getAttributesForm = async (\n formCode: string\n): Promise<AttributesFormModel[]> => {\n return await fetchGraphQl(GET_ATTRIBUTES_FORM, {\n method: 'GET',\n cache: 'force-cache',\n variables: { formCode },\n })\n .then((response: GetAttributesFormResponse) => {\n if (response.errors?.length) return handleFetchError(response.errors);\n\n return transformAttributesForm(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 CREATE_CUSTOMER_ADDRESS = /* GraphQL */ `\n mutation CREATE_CUSTOMER_ADDRESS($input: CustomerAddressInput!) {\n createCustomerAddress(input: $input) {\n firstname\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 { AddressFormProps, CreateCustomerAddressResponse } from '@/auth/types';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { CREATE_CUSTOMER_ADDRESS } from './graphql/createCustomerAddress.graphql';\nimport { handleNetworkError } from '@/auth/lib/network-error';\nimport { handleFetchError } from '@/auth/lib/fetch-error';\n\nexport const createCustomerAddress = async (\n address: AddressFormProps\n): Promise<string> => {\n return await fetchGraphQl(CREATE_CUSTOMER_ADDRESS, {\n method: 'POST',\n variables: {\n input: address,\n },\n })\n .then((response: CreateCustomerAddressResponse) => {\n if (response.errors?.length) return handleFetchError(response.errors);\n\n return response.data.createCustomerAddress.firstname || '';\n })\n .catch(handleNetworkError);\n};\n"],"names":["CREATE_CUSTOMER","CUSTOMER_INFORMATION_FRAGMENT","CREATE_CUSTOMER_V2","transformCreateCustomer","response","apiVersion2","model","data","_b","_a","_d","_c","_f","_e","_g","_i","_h","_k","_j","_m","_l","merge","_p","_o","_n","config","transformDobForm","form","dob","rest","createCustomer","forms","setReCaptchaToken","fetchGraphQl","handleNetworkError","GET_ATTRIBUTES_FORM","getAttributesForm","formCode","handleFetchError","transformAttributesForm","CREATE_CUSTOMER_ADDRESS","createCustomerAddress","address"],"mappings":"8WAmBO,MAAMA,EAAgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQzCC,CAA6B;AAAA,ECRpBC,EAAmC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQ5CD,CAA6B;AAAA,ECDpBE,EAA0B,CACrCC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A,CACnC,ECoBaE,EAAiB,MAC5BC,EACA1B,IAC2B,CAC3B,MAAM2B,EAAA,EAEN,MAAM5B,EAAW,MAAM6B,EACrB5B,EAAcH,EAAqBF,EACnC,CACE,OAAQ,OACR,UAAW,CACT,MAAO,CACL,GAAG0B,EAAiBK,CAAK,CAAA,CAC3B,CACF,CACF,EACA,MAAMG,CAAkB,EAE1B,OAAO/B,EAAwBC,EAAUC,CAAW,CACtD,EC7Ba8B,EAAoC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECQpCC,EAAoB,MAC/BC,GAEO,MAAMJ,EAAaE,EAAqB,CAC7C,OAAQ,MACR,MAAO,cACP,UAAW,CAAE,SAAAE,CAAA,CAAS,CACvB,EACE,KAAMjC,GAAwC,OAC7C,OAAIK,EAAAL,EAAS,SAAT,MAAAK,EAAiB,OAAe6B,EAAiBlC,EAAS,MAAM,EAE7DmC,EAAwBnC,CAAQ,CACzC,CAAC,EACA,MAAM8B,CAAkB,ECrBhBM,EAAwC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECMxCC,EAAwB,MACnCC,GAEO,MAAMT,EAAaO,EAAyB,CACjD,OAAQ,OACR,UAAW,CACT,MAAOE,CAAA,CACT,CACD,EACE,KAAMtC,GAA4C,OACjD,OAAIK,EAAAL,EAAS,SAAT,MAAAK,EAAiB,OAAe6B,EAAiBlC,EAAS,MAAM,EAE7DA,EAAS,KAAK,sBAAsB,WAAa,EAC1D,CAAC,EACA,MAAM8B,CAAkB"}
|
|
1
|
+
{"version":3,"file":"createCustomerAddress.js","sources":["/@dropins/storefront-auth/src/api/createCustomer/graphql/createCustomer.graphql.ts","/@dropins/storefront-auth/src/api/createCustomer/graphql/createCustomerV2.graphql.ts","/@dropins/storefront-auth/src/data/transforms/transform-create-customer.tsx","/@dropins/storefront-auth/src/lib/transformDobForm.ts","/@dropins/storefront-auth/src/api/createCustomer/createCustomer.ts","/@dropins/storefront-auth/src/api/getAttributesForm/graphql/getAttributesForm.graphql.ts","/@dropins/storefront-auth/src/api/getAttributesForm/getAttributesForm.ts","/@dropins/storefront-auth/src/api/createCustomerAddress/graphql/createCustomerAddress.graphql.ts","/@dropins/storefront-auth/src/api/createCustomerAddress/createCustomerAddress.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 { CUSTOMER_INFORMATION_FRAGMENT } from '@/auth/api/fragments';\n\nexport const CREATE_CUSTOMER = /* GraphQL */ `\n mutation CREATE_CUSTOMER($input: CustomerInput!) {\n createCustomer(input: $input) {\n customer {\n ...CUSTOMER_INFORMATION_FRAGMENT\n }\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 { CUSTOMER_INFORMATION_FRAGMENT } from '@/auth/api/fragments';\n\nexport const CREATE_CUSTOMER_V2 = /* GraphQL */ `\n mutation CREATE_CUSTOMER_V2($input: CustomerCreateInput!) {\n createCustomerV2(input: $input) {\n customer {\n ...CUSTOMER_INFORMATION_FRAGMENT\n }\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 { DataCreateCustomerV2, DataCreateCustomer } from '@/auth/types';\nimport { config } from '@/auth/api';\nimport { merge } from '@adobe-commerce/elsie/lib';\nimport { CustomerModel } from '../models';\n\ntype ApiResponse<T extends boolean> = T extends true\n ? DataCreateCustomerV2\n : DataCreateCustomer;\n\nexport const transformCreateCustomer = <T extends boolean>(\n response: ApiResponse<T>,\n apiVersion2: T\n): CustomerModel => {\n let model: CustomerModel;\n\n if (apiVersion2) {\n const { data } = response as DataCreateCustomerV2;\n\n model = {\n firstName: data?.createCustomerV2?.customer?.firstname ?? '',\n lastName: data?.createCustomerV2?.customer?.lastname ?? '',\n email: data?.createCustomerV2?.customer?.email ?? '',\n customAttributes: data?.createCustomerV2?.custom_attributes ?? [],\n errors: response?.errors ?? [],\n };\n } else {\n const { data } = response as DataCreateCustomer;\n\n model = {\n firstName: data?.createCustomer?.customer?.firstname ?? '',\n lastName: data?.createCustomer?.customer?.lastname ?? '',\n email: data?.createCustomer?.customer?.email ?? '',\n errors: response?.errors ?? [],\n };\n }\n\n return merge(\n model, // default transformer\n config.getConfig().models?.CustomerModel?.transformer?.(response) // custom transformer\n );\n};\n","export const transformDobForm = (\n form: Record<string, any>\n): Record<string, any> => {\n if (!form.dob) return form;\n\n const { dob, ...rest } = form;\n return { ...rest, date_of_birth: dob };\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 } from '@/auth/types';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { CREATE_CUSTOMER } from './graphql/createCustomer.graphql';\nimport { CREATE_CUSTOMER_V2 } from './graphql/createCustomerV2.graphql';\nimport { handleNetworkError } from '@/auth/lib/network-error';\nimport { setReCaptchaToken } from '@/auth/lib/setReCaptchaToken';\nimport { transformCreateCustomer } from '@/auth/data/transforms';\nimport { CustomerModel } from '@/auth/data/models';\nimport { transformDobForm } from '@/auth/lib/transformDobForm';\n\nexport const createCustomer = async (\n forms: Customer,\n apiVersion2: boolean\n): Promise<CustomerModel> => {\n await setReCaptchaToken();\n\n const response = await fetchGraphQl(\n apiVersion2 ? CREATE_CUSTOMER_V2 : CREATE_CUSTOMER,\n {\n method: 'POST',\n variables: {\n input: {\n ...transformDobForm(forms),\n },\n },\n }\n ).catch(handleNetworkError);\n\n return transformCreateCustomer(response, apiVersion2);\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_ATTRIBUTES_FORM = /* GraphQL */ `\n query GET_ATTRIBUTES_FORM($formCode: String!) {\n attributesForm(formCode: $formCode) {\n items {\n code\n default_value\n entity_type\n frontend_class\n frontend_input\n is_required\n is_unique\n label\n options {\n is_default\n label\n value\n }\n ... on CustomerAttributeMetadata {\n multiline_count\n sort_order\n validate_rules {\n name\n value\n }\n }\n }\n errors {\n type\n message\n }\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 { fetchGraphQl } from '../fetch-graphql';\nimport { GET_ATTRIBUTES_FORM } from './graphql/getAttributesForm.graphql';\nimport { handleNetworkError } from '@/auth/lib/network-error';\nimport { transformAttributesForm } from '@/auth/data/transforms';\nimport { handleFetchError } from '@/auth/lib/fetch-error';\nimport { AttributesFormModel } from '@/auth/data/models';\nimport { GetAttributesFormResponse } from '@/auth/types';\n\nexport const getAttributesForm = async (\n formCode: string\n): Promise<AttributesFormModel[]> => {\n return await fetchGraphQl(GET_ATTRIBUTES_FORM, {\n method: 'GET',\n cache: 'force-cache',\n variables: { formCode },\n })\n .then((response: GetAttributesFormResponse) => {\n if (response.errors?.length) return handleFetchError(response.errors);\n\n return transformAttributesForm(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 CREATE_CUSTOMER_ADDRESS = /* GraphQL */ `\n mutation CREATE_CUSTOMER_ADDRESS($input: CustomerAddressInput!) {\n createCustomerAddress(input: $input) {\n firstname\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 { AddressFormProps, CreateCustomerAddressResponse } from '@/auth/types';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { CREATE_CUSTOMER_ADDRESS } from './graphql/createCustomerAddress.graphql';\nimport { handleNetworkError } from '@/auth/lib/network-error';\nimport { handleFetchError } from '@/auth/lib/fetch-error';\n\nexport const createCustomerAddress = async (\n address: AddressFormProps\n): Promise<string> => {\n return await fetchGraphQl(CREATE_CUSTOMER_ADDRESS, {\n method: 'POST',\n variables: {\n input: address,\n },\n })\n .then((response: CreateCustomerAddressResponse) => {\n if (response.errors?.length) return handleFetchError(response.errors);\n\n return response.data.createCustomerAddress.firstname || '';\n })\n .catch(handleNetworkError);\n};\n"],"names":["CREATE_CUSTOMER","CUSTOMER_INFORMATION_FRAGMENT","CREATE_CUSTOMER_V2","transformCreateCustomer","response","apiVersion2","model","data","_b","_a","_d","_c","_f","_e","_g","_i","_h","_k","_j","_m","_l","merge","_p","_o","_n","config","transformDobForm","form","dob","rest","createCustomer","forms","setReCaptchaToken","fetchGraphQl","handleNetworkError","GET_ATTRIBUTES_FORM","getAttributesForm","formCode","handleFetchError","transformAttributesForm","CREATE_CUSTOMER_ADDRESS","createCustomerAddress","address"],"mappings":"6XAmBO,MAAMA,EAAgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQzCC,CAA6B;AAAA,ECRpBC,EAAmC;A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obe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{Initializer as S,Config as A}from"@dropins/tools/lib.js";import{events as i}from"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{f as p,h as T,a as y,r as k}from"./network-error.js";const C={auth_dropin_user_token:"auth_dropin_user_token",auth_dropin_firstname:"auth_dropin_firstname"},V=["localhost","127.0.0.1","::1"],f=3600,P=e=>{const t=document.cookie.split(";");let r;return t.forEach(o=>{const[n,s]=o.trim().split("=");n===e&&(r=decodeURIComponent(s))}),r},R=e=>{document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`},j=async()=>{try{const e=sessionStorage.getItem("storeConfig");let r=(e?JSON.parse(e):{}).customerAccessTokenLifetime;if(!r){const o=await b();sessionStorage.setItem("storeConfig",JSON.stringify(o)),r=(o==null?void 0:o.customerAccessTokenLifetime)||f}return`Max-Age=${r}`}catch(e){return console.error("getCookiesLifetime() Error:",e),`Max-Age=${f}`}},l=new A(void 0),E=new S({init:async e=>{const r={...{authHeaderConfig:{header:"Authorization",tokenPrefix:"Bearer"},customerPermissionRoles:!1},...e};E.config.setConfig(r);const o=P(C.auth_dropin_user_token),[n]=await Promise.all([U(r.authHeaderConfig.header,r.authHeaderConfig.tokenPrefix),r.customerPermissionRoles&&o?O():Promise.resolve()]);l.setConfig(n)},listeners:()=>[i.on("authenticated",e=>{const t=l.getConfig();if(t!==void 0&&e!==t){l.setConfig(e);const{customerPermissionRoles:r}=E.config.getConfig();r&&O()}})]}),W=E.config,w=e=>{var t,r,o,n,s,a,u,h,m,d;return{autocompleteOnStorefront:((r=(t=e==null?void 0:e.data)==null?void 0:t.storeConfig)==null?void 0:r.autocomplete_on_storefront)||!1,minLength:((n=(o=e==null?void 0:e.data)==null?void 0:o.storeConfig)==null?void 0:n.minimum_password_length)||3,requiredCharacterClasses:+((a=(s=e==null?void 0:e.data)==null?void 0:s.storeConfig)==null?void 0:a.required_character_classes_number)||0,createAccountConfirmation:((h=(u=e==null?void 0:e.data)==null?void 0:u.storeConfig)==null?void 0:h.create_account_confirmation)||!1,customerAccessTokenLifetime:((d=(m=e==null?void 0:e.data)==null?void 0:m.storeConfig)==null?void 0:d.customer_access_token_lifetime)*f||f}},I=e=>{const t=e.map(r=>r.message).join(" ");throw Error(t)},v=async e=>{if(!e||e.trim()==="")return"";try{const t=atob(e),r=new Uint8Array(t.length);for(let a=0;a<t.length;a++)r[a]=t.charCodeAt(a);const o=await crypto.subtle.digest("SHA-1",r);return Array.from(new Uint8Array(o)).map(a=>a.toString(16).padStart(2,"0")).join("")}catch(t){return console.error(`Failed to convert base64 to SHA1: ${t instanceof Error?t.message:"Unknown error"}`),""}},M="b6589fc6ab0dc82cf12099d1c2d40ab994e8410c",g=async e=>{const t=e?await v(e):M;i.emit("auth/group-uid",t)},L=`
|
|
4
|
+
query GET_STORE_CONFIG {
|
|
5
|
+
storeConfig {
|
|
6
|
+
autocomplete_on_storefront
|
|
7
|
+
minimum_password_length
|
|
8
|
+
required_character_classes_number
|
|
9
|
+
store_code
|
|
10
|
+
store_name
|
|
11
|
+
store_group_code
|
|
12
|
+
locale
|
|
13
|
+
create_account_confirmation
|
|
14
|
+
customer_access_token_lifetime
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
`,b=async()=>await p(L,{method:"GET",cache:"force-cache"}).then(e=>{var t;return(t=e.errors)!=null&&t.length?I(e.errors):w(e)}).catch(T),x=`
|
|
18
|
+
query VALIDATE_TOKEN {
|
|
19
|
+
customer {
|
|
20
|
+
group {
|
|
21
|
+
uid
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
`,U=async(e="Authorization",t="Bearer")=>{const r=P(C.auth_dropin_user_token);return r?(y(e,`${t} ${r}`),p(x).then(async o=>{var s,a,u,h;return!((s=o.errors)!=null&&s.find(m=>{var d;return((d=m.extensions)==null?void 0:d.category)==="graphql-authentication"}))?(await g((h=(u=(a=o.data)==null?void 0:a.customer)==null?void 0:u.group)==null?void 0:h.uid),i.emit("authenticated",!0),!0):(R(C.auth_dropin_user_token),k(e),await g(),i.emit("authenticated",!1),!1)})):(await g(),i.emit("authenticated",!1),!1)},G=`
|
|
26
|
+
query GET_CUSTOMER_ROLE_PERMISSIONS {
|
|
27
|
+
customer {
|
|
28
|
+
purchase_orders_enabled
|
|
29
|
+
role {
|
|
30
|
+
id
|
|
31
|
+
name
|
|
32
|
+
permissions {
|
|
33
|
+
id
|
|
34
|
+
text
|
|
35
|
+
children {
|
|
36
|
+
id
|
|
37
|
+
text
|
|
38
|
+
children {
|
|
39
|
+
id
|
|
40
|
+
text
|
|
41
|
+
children {
|
|
42
|
+
id
|
|
43
|
+
text
|
|
44
|
+
children {
|
|
45
|
+
id
|
|
46
|
+
text
|
|
47
|
+
children {
|
|
48
|
+
id
|
|
49
|
+
text
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
`;let _=null,c=null;const H=e=>{const t={},r=o=>{o.forEach(n=>{var s;t[n.id]=!0,(s=n.children)!=null&&s.length&&r(n.children)})};return r(e),t},N=["Magento_PurchaseOrder::all","Magento_PurchaseOrder::view_purchase_orders","Magento_PurchaseOrder::view_purchase_orders_for_subordinates","Magento_PurchaseOrder::view_purchase_orders_for_company","Magento_PurchaseOrder::autoapprove_purchase_order","Magento_PurchaseOrderRule::super_approve_purchase_order","Magento_PurchaseOrderRule::view_approval_rules","Magento_PurchaseOrderRule::manage_approval_rules"],F=e=>(e==null?void 0:e.id)==="MA=="&&Array.isArray(e.permissions)&&e.permissions.length===0,q=e=>{var t;return(t=e==null?void 0:e.permissions)!=null&&t.length?H(e.permissions):{}},$=(e,t)=>{if(t===!0)return e;const r={...e};return N.forEach(o=>{r[o]=!1}),r},D=(e,t)=>{const r=F(e),o=q(e),n=$(o,t);return{...{all:!0,...r&&{admin:!0}},...n}},z=async()=>{var e,t,r,o;try{const n=await p(G,{method:"GET"}),s=D((t=(e=n.data)==null?void 0:e.customer)==null?void 0:t.role,(o=(r=n.data)==null?void 0:r.customer)==null?void 0:o.purchase_orders_enabled);return _=s,c=null,s}catch(n){throw c=null,n}},O=()=>_?(i.emit("auth/permissions",_),Promise.resolve(_)):(c||(c=z().then(e=>(i.emit("auth/permissions",e),e))),c),X=()=>{_=null,c=null};export{C,V as L,X as _,O as a,j as b,W as c,R as d,g as e,b as g,I as h,E as i,U as v};
|
|
60
|
+
//# sourceMappingURL=getCustomerRolePermissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCustomerRolePermissions.js","sources":["/@dropins/storefront-auth/src/configs/cookieConfigs.ts","/@dropins/storefront-auth/src/lib/cookieUtils.ts","/@dropins/storefront-auth/src/api/initialize/initialize.ts","/@dropins/storefront-auth/src/data/transforms/transform-store-config.ts","/@dropins/storefront-auth/src/lib/fetch-error.ts","/@dropins/storefront-auth/src/lib/base64ToSha1.ts","/@dropins/storefront-auth/src/lib/emitAuthGroupId.ts","/@dropins/storefront-auth/src/api/getStoreConfig/graphql/getStoreConfig.graphql.ts","/@dropins/storefront-auth/src/api/getStoreConfig/getStoreConfig.ts","/@dropins/storefront-auth/src/api/verifyToken/graphql/verifyToken.graphql.ts","/@dropins/storefront-auth/src/api/verifyToken/verifyToken.ts","/@dropins/storefront-auth/src/api/getCustomerRolePermissions/graphql/getCustomerRolePermissions.graphql.ts","/@dropins/storefront-auth/src/api/getCustomerRolePermissions/getCustomerRolePermissions.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\nconst COOKIE_NAMES = {\n auth_dropin_user_token: 'auth_dropin_user_token',\n auth_dropin_firstname: 'auth_dropin_firstname',\n};\n\nconst LOCALHOST = [\n 'localhost',\n '127.0.0.1',\n '::1'\n];\n\nconst COOKIE_LIFETIME = 3600;\n\nexport { COOKIE_NAMES, COOKIE_LIFETIME, LOCALHOST };\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\n/* eslint-disable no-useless-escape */\nimport { getStoreConfig } from '@/auth/api';\nimport { COOKIE_LIFETIME } from '@/auth/configs/cookieConfigs';\n\nexport const getCookie = (cookieName: string) => {\n const cookies = document.cookie.split(';');\n let foundValue;\n\n cookies.forEach((cookie) => {\n const [name, value] = cookie.trim().split('=');\n if (name === cookieName) {\n foundValue = decodeURIComponent(value);\n }\n });\n\n return foundValue;\n};\n\nexport const deleteCookie = (cookieName: string) => {\n document.cookie = `${cookieName}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;\n};\n\nexport const getCookiesLifetime = async () => {\n try {\n const storeConfigString = sessionStorage.getItem('storeConfig');\n const cachedStoreConfig = storeConfigString\n ? JSON.parse(storeConfigString)\n : {};\n\n let accessTokenLifeTime = cachedStoreConfig.customerAccessTokenLifetime;\n\n if (!accessTokenLifeTime) {\n const storeConfig = await getStoreConfig();\n\n sessionStorage.setItem('storeConfig', JSON.stringify(storeConfig));\n\n accessTokenLifeTime =\n storeConfig?.customerAccessTokenLifetime || COOKIE_LIFETIME;\n }\n\n return `Max-Age=${accessTokenLifeTime}`;\n } catch (error) {\n console.error('getCookiesLifetime() Error:', error);\n return `Max-Age=${COOKIE_LIFETIME}`;\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 { Initializer, Model, Config } from '@adobe-commerce/elsie/lib';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { getCookie } from '@/auth/lib/cookieUtils';\nimport { CustomerModel } from '@/auth/data/models';\nimport { verifyToken, getCustomerRolePermissions } from '@/auth/api';\nimport { events } from '@adobe-commerce/event-bus';\nimport { COOKIE_NAMES } from '@/auth/configs/cookieConfigs';\n\ntype ConfigProps = {\n langDefinitions?: Lang;\n authHeaderConfig: {\n header: string;\n tokenPrefix: string;\n };\n customerPermissionRoles?: boolean;\n models?: {\n CustomerModel?: Model<CustomerModel>;\n };\n};\n\nconst _authenticated = new Config<boolean | undefined>(undefined);\n\nexport const initialize = new Initializer<ConfigProps>({\n init: async (config) => {\n const defaultConfig = {\n authHeaderConfig: {\n header: 'Authorization',\n tokenPrefix: 'Bearer',\n },\n customerPermissionRoles: false,\n };\n\n const mergedConfig = { ...defaultConfig, ...config };\n\n initialize.config.setConfig(mergedConfig);\n\n const token = getCookie(COOKIE_NAMES.auth_dropin_user_token);\n\n const [authenticated] = await Promise.all([\n verifyToken(\n mergedConfig.authHeaderConfig.header,\n mergedConfig.authHeaderConfig.tokenPrefix\n ),\n mergedConfig.customerPermissionRoles && token\n ? getCustomerRolePermissions()\n : Promise.resolve(),\n ]);\n\n _authenticated.setConfig(authenticated);\n },\n\n listeners: () => [\n events.on('authenticated', (next) => {\n const prev = _authenticated.getConfig();\n\n if (prev !== undefined && next !== prev) {\n _authenticated.setConfig(next);\n const { customerPermissionRoles } = initialize.config.getConfig();\n if (customerPermissionRoles) {\n getCustomerRolePermissions();\n }\n }\n }),\n ],\n});\n\nexport const config = initialize.config;\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 { getStoreConfigResponse } from '@/auth/types';\nimport { COOKIE_LIFETIME } from '@/auth/configs/cookieConfigs';\nimport { StoreConfigModel } from '../models';\n\nexport const transformStoreConfig = (\n response: getStoreConfigResponse\n): StoreConfigModel => {\n return {\n autocompleteOnStorefront:\n response?.data?.storeConfig?.autocomplete_on_storefront || false,\n // Need information about min length in response undefined\n minLength: response?.data?.storeConfig?.minimum_password_length || 3,\n requiredCharacterClasses:\n +response?.data?.storeConfig?.required_character_classes_number || 0,\n createAccountConfirmation:\n response?.data?.storeConfig?.create_account_confirmation || false,\n customerAccessTokenLifetime:\n response?.data?.storeConfig?.customer_access_token_lifetime *\n COOKIE_LIFETIME || COOKIE_LIFETIME,\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\n/** Actions */\nexport const handleFetchError = (errors: Array<{ message: string }>) => {\n const errorMessage = errors.map((e: any) => e.message).join(' ');\n\n throw Error(errorMessage);\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\n/**\n * Converts a base64 encoded string to a SHA1 hash string\n * @param base64String - The base64 encoded string to convert\n * @returns A promise that resolves to the SHA1 hash as a hexadecimal string, or empty string if input is undefined/null/empty or if conversion fails\n */\nexport const base64ToSha1 = async (\n base64String?: string | null\n): Promise<string> => {\n // Handle edge cases: undefined, null, or empty string\n if (!base64String || base64String.trim() === '') {\n return '';\n }\n\n try {\n // Decode base64 string to binary data\n const binaryString = atob(base64String);\n const bytes = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n bytes[i] = binaryString.charCodeAt(i);\n }\n\n // Compute SHA1 hash using Web Crypto API\n const hashBuffer = await crypto.subtle.digest('SHA-1', bytes);\n\n // Convert hash to hexadecimal string\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n const hashHex = hashArray\n .map((byte) => byte.toString(16).padStart(2, '0'))\n .join('');\n\n return hashHex;\n } catch (error) {\n console.error(\n `Failed to convert base64 to SHA1: ${error instanceof Error ? error.message : 'Unknown error'}`\n );\n return '';\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 { events } from '@adobe-commerce/event-bus';\nimport { base64ToSha1 } from './base64ToSha1';\n\n/**\n * Default customer group ID for non-logged-in (NLI) customers.\n * This value is emitted via the 'auth/group-uid' event when:\n * - A customer is not authenticated\n * - Token validation fails\n * - Customer logs out\n */\nexport const DEFAULT_NLI_CUSTOMER_GROUP_ID = 'b6589fc6ab0dc82cf12099d1c2d40ab994e8410c';\n\n/**\n * Emits the auth/group-uid event with the provided group UID.\n * If a value is provided, it will be converted from base64 to SHA1 hash.\n * If no value is provided, the default NLI customer group ID will be emitted.\n * \n * @param groupUid - The base64 encoded group UID, or undefined/null for default\n */\nexport const emitAuthGroupIdEvent = async (\n groupUid?: string | null\n): Promise<void> => {\n const groupIdHash = groupUid \n ? await base64ToSha1(groupUid) \n : DEFAULT_NLI_CUSTOMER_GROUP_ID;\n \n events.emit('auth/group-uid', groupIdHash);\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 GET_STORE_CONFIG = /* GraphQL */ `\n query GET_STORE_CONFIG {\n storeConfig {\n autocomplete_on_storefront\n minimum_password_length\n required_character_classes_number\n store_code\n store_name\n store_group_code\n locale\n create_account_confirmation\n customer_access_token_lifetime\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 { getStoreConfigResponse } from '@/auth/types';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { GET_STORE_CONFIG } from './graphql/getStoreConfig.graphql';\nimport { handleNetworkError } from '@/auth/lib/network-error';\nimport { transformStoreConfig } from '@/auth/data/transforms';\nimport { StoreConfigModel } from '@/auth/data/models';\nimport { handleFetchError } from '@/auth/lib/fetch-error';\n\nexport const getStoreConfig = async (): Promise<StoreConfigModel> => {\n return await fetchGraphQl(GET_STORE_CONFIG, {\n method: 'GET',\n cache: 'force-cache',\n })\n .then((response: getStoreConfigResponse) => {\n if (response.errors?.length) return handleFetchError(response.errors);\n\n return transformStoreConfig(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 VALIDATE_CUSTOMER_TOKEN = /* GraphQL */ `\n query VALIDATE_TOKEN {\n customer {\n group {\n uid\n }\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 { events } from '@adobe-commerce/event-bus';\nimport {\n fetchGraphQl,\n removeFetchGraphQlHeader,\n setFetchGraphQlHeader,\n} from '../fetch-graphql';\nimport { deleteCookie, getCookie } from '@/auth/lib/cookieUtils';\nimport { COOKIE_NAMES } from '@/auth/configs/cookieConfigs';\nimport { VALIDATE_CUSTOMER_TOKEN } from './graphql/verifyToken.graphql';\nimport { emitAuthGroupIdEvent } from '@/auth/lib/emitAuthGroupId';\n\nexport const verifyToken = async (\n authType = 'Authorization',\n type = 'Bearer'\n) => {\n const token = getCookie(COOKIE_NAMES.auth_dropin_user_token);\n\n if (!token) {\n await emitAuthGroupIdEvent();\n events.emit('authenticated', false);\n return false;\n }\n\n setFetchGraphQlHeader(authType, `${type} ${token}`);\n\n return fetchGraphQl(VALIDATE_CUSTOMER_TOKEN).then(async (res) => {\n const unauthenticated = !!res.errors?.find(\n (error) => error.extensions?.category === 'graphql-authentication'\n );\n\n if (!unauthenticated) {\n await emitAuthGroupIdEvent(res.data?.customer?.group?.uid);\n events.emit('authenticated', true);\n return true;\n };\n\n deleteCookie(COOKIE_NAMES.auth_dropin_user_token);\n removeFetchGraphQlHeader(authType);\n await emitAuthGroupIdEvent();\n events.emit('authenticated', false);\n return false;\n });\n};\n","export const GET_CUSTOMER_ROLE_PERMISSIONS = `\n query GET_CUSTOMER_ROLE_PERMISSIONS {\n customer {\n purchase_orders_enabled\n role {\n id\n name\n permissions {\n id\n text\n children {\n id\n text\n children {\n id\n text\n children {\n id\n text\n children {\n id\n text\n children {\n id\n text\n }\n }\n }\n }\n }\n }\n }\n }\n }\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { events } from '@adobe-commerce/event-bus';\nimport { fetchGraphQl } from '@/auth/api/fetch-graphql';\nimport { PermissionsModel } from '@/auth/data/models';\nimport { GET_CUSTOMER_ROLE_PERMISSIONS } from './graphql/getCustomerRolePermissions.graphql';\n\n// TypeScript interfaces\ninterface Permission {\n id: string;\n text: string;\n children?: Permission[];\n}\n\ninterface Role {\n id: string;\n name: string;\n permissions?: Permission[];\n}\n\ninterface GetCustomerRolePermissionsResponse {\n data?: {\n customer?: {\n purchase_orders_enabled?: boolean;\n role?: Role;\n };\n };\n errors?: {\n message: string;\n }[];\n}\n\n// Module-level cache\nlet permissionsCache: PermissionsModel | null = null;\nlet fetchPromise: Promise<PermissionsModel> | null = null;\n\n/**\n * Recursively flattens permission tree into a flat object\n */\nconst flattenPermissionTree = (\n permissions: Permission[]\n): Record<string, boolean> => {\n const flattened: Record<string, boolean> = {};\n\n const processPermissions = (perms: Permission[]): void => {\n perms.forEach((permission) => {\n flattened[permission.id] = true;\n if (permission.children?.length) {\n processPermissions(permission.children);\n }\n });\n };\n\n processPermissions(permissions);\n return flattened;\n};\n\n/**\n * Purchase Order related permissions that should be set to false\n * when purchase orders are disabled\n */\nconst PURCHASE_ORDER_PERMISSIONS = [\n 'Magento_PurchaseOrder::all',\n 'Magento_PurchaseOrder::view_purchase_orders',\n 'Magento_PurchaseOrder::view_purchase_orders_for_subordinates',\n 'Magento_PurchaseOrder::view_purchase_orders_for_company',\n 'Magento_PurchaseOrder::autoapprove_purchase_order',\n 'Magento_PurchaseOrderRule::super_approve_purchase_order',\n 'Magento_PurchaseOrderRule::view_approval_rules',\n 'Magento_PurchaseOrderRule::manage_approval_rules',\n];\n\n/**\n * Determines if user has admin privileges\n * Admin is only when user has role ID 'MA==' AND has an empty permissions array\n */\nconst isAdminUser = (role?: Role): boolean => {\n return (\n role?.id === 'MA==' &&\n Array.isArray(role.permissions) &&\n role.permissions.length === 0\n );\n};\n\n/**\n * Gets all available permissions from the GraphQL response\n * Returns an empty object if no permissions (e.g., admin users have empty array)\n */\nconst getAllPermissions = (role?: Role): Record<string, boolean> => {\n if (role?.permissions?.length) {\n return flattenPermissionTree(role.permissions);\n }\n return {};\n};\n\n/**\n * Handles purchase order permissions based on PO enabled status\n * When PO is disabled, explicitly sets all PO permissions to false\n * This ensures consumers can distinguish between \"no data\" and \"explicitly disabled\"\n */\nconst overridePurchaseOrderPermissions = (\n permissions: Record<string, boolean>,\n purchaseOrdersEnabled?: boolean\n): Record<string, boolean> => {\n // If PO is enabled, return permissions as-is from backend\n if (purchaseOrdersEnabled === true) {\n return permissions;\n }\n\n // When PO is disabled, explicitly set all PO permissions to false\n const result = { ...permissions };\n PURCHASE_ORDER_PERMISSIONS.forEach((permission) => {\n result[permission] = false;\n });\n\n return result;\n};\n\n/**\n * Processes role data into flattened permissions\n */\nconst processUserPermissions = (\n role?: Role,\n purchaseOrdersEnabled?: boolean\n): PermissionsModel => {\n const isAdmin = isAdminUser(role);\n\n // Get all permissions (for both admin and non-admin users)\n const allPermissions = getAllPermissions(role);\n\n // Override PO permissions to false if PO is disabled\n const processedPermissions = overridePurchaseOrderPermissions(\n allPermissions,\n purchaseOrdersEnabled\n );\n\n const basePermissions: PermissionsModel = {\n all: true,\n ...(isAdmin && { admin: true }),\n };\n\n return { ...basePermissions, ...processedPermissions };\n};\n\n/**\n * Fetches user role permissions from GraphQL API\n */\nconst fetchUserRolePermissions = async (): Promise<PermissionsModel> => {\n try {\n const response = (await fetchGraphQl(GET_CUSTOMER_ROLE_PERMISSIONS, {\n method: 'GET',\n })) as GetCustomerRolePermissionsResponse;\n\n const permissions = processUserPermissions(\n response.data?.customer?.role,\n response.data?.customer?.purchase_orders_enabled\n );\n\n // Update cache\n permissionsCache = permissions;\n fetchPromise = null;\n\n return permissions;\n } catch (error) {\n fetchPromise = null;\n throw error;\n }\n};\n\n/**\n * Gets user role permissions with caching\n */\nexport const getCustomerRolePermissions = (): Promise<PermissionsModel> => {\n // Return cached data as resolved promise if available\n if (permissionsCache) {\n events.emit('auth/permissions', permissionsCache);\n return Promise.resolve(permissionsCache);\n }\n\n // No cache available - create and return fetch promise if not already fetching\n if (!fetchPromise) {\n fetchPromise = fetchUserRolePermissions().then((permissions) => {\n events.emit('auth/permissions', permissions);\n return permissions;\n });\n }\n\n return fetchPromise;\n};\n\n/**\n * Resets the permissions cache\n * @internal\n */\nexport const _resetCache = (): void => {\n permissionsCache = null;\n fetchPromise = null;\n};\n"],"names":["COOKIE_NAMES","LOCALHOST","COOKIE_LIFETIME","getCookie","cookieName","cookies","foundValue","cookie","name","value","deleteCookie","getCookiesLifetime","storeConfigString","accessTokenLifeTime","storeConfig","getStoreConfig","error","_authenticated","Config","initialize","Initializer","config","mergedConfig","token","authenticated","verifyToken","getCustomerRolePermissions","events","next","prev","customerPermissionRoles","transformStoreConfig","response","_b","_a","_d","_c","_f","_e","_h","_g","_j","_i","handleFetchError","errors","errorMessage","e","base64ToSha1","base64String","binaryString","bytes","i","hashBuffer","byte","DEFAULT_NLI_CUSTOMER_GROUP_ID","emitAuthGroupIdEvent","groupUid","groupIdHash","GET_STORE_CONFIG","fetchGraphQl","handleNetworkError","VALIDATE_CUSTOMER_TOKEN","authType","type","setFetchGraphQlHeader","res","removeFetchGraphQlHeader","GET_CUSTOMER_ROLE_PERMISSIONS","permissionsCache","fetchPromise","flattenPermissionTree","permissions","flattened","processPermissions","perms","permission","PURCHASE_ORDER_PERMISSIONS","isAdminUser","role","getAllPermissions","overridePurchaseOrderPermissions","purchaseOrdersEnabled","result","processUserPermissions","isAdmin","allPermissions","processedPermissions","fetchUserRolePermissions","_resetCache"],"mappings":"qNAiBA,MAAMA,EAAe,CACnB,uBAAwB,yBACxB,sBAAuB,uBACzB,EAEMC,EAAY,CAChB,YACA,YACA,KACF,EAEMC,EAAkB,KCPXC,EAAaC,GAAuB,CAC/C,MAAMC,EAAU,SAAS,OAAO,MAAM,GAAG,EACzC,IAAIC,EAEJ,OAAAD,EAAQ,QAASE,GAAW,CAC1B,KAAM,CAACC,EAAMC,CAAK,EAAIF,EAAO,KAAA,EAAO,MAAM,GAAG,EACzCC,IAASJ,IACXE,EAAa,mBAAmBG,CAAK,EAEzC,CAAC,EAEMH,CACT,EAEaI,EAAgBN,GAAuB,CAClD,SAAS,OAAS,GAAGA,CAAU,mDAC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EAGF,GAAGE,CAAA,CAClC,EAKMC,EAA2B,SAAuC,aACtE,GAAI,CACF,MAAMvD,EAAY,MAAM2B,EAAaQ,EAA+B,CAClE,OAAQ,KAAA,CACT,EAEKI,EAAcY,GAClBlD,GAAAC,EAAAF,EAAS,OAAT,YAAAE,EAAe,WAAf,YAAAD,EAAyB,MACzBE,GAAAC,EAAAJ,EAAS,OAAT,YAAAI,EAAe,WAAf,YAAAD,EAAyB,uBAAA,EAI3B,OAAAiC,EAAmBG,EACnBF,EAAe,KAERE,CACT,OAASvD,EAAO,CACd,MAAAqD,EAAe,KACTrD,CACR,CACF,EAKaU,EAA6B,IAEpC0C,GACFzC,EAAO,KAAK,mBAAoByC,CAAgB,EACzC,QAAQ,QAAQA,CAAgB,IAIpCC,IACHA,EAAekB,EAAA,EAA2B,KAAMhB,IAC9C5C,EAAO,KAAK,mBAAoB4C,CAAW,EACpCA,EACR,GAGIF,GAOImB,EAAc,IAAY,CACrCpB,EAAmB,KACnBC,EAAe,IACjB"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{a as
|
|
3
|
+
import{a as R,f as $,h as w}from"./network-error.js";import"@dropins/tools/recaptcha.js";import{events as k}from"@dropins/tools/event-bus.js";import{merge as U}from"@dropins/tools/lib.js";import{c as G,b as C,C as h,e as v,L as F}from"./getCustomerRolePermissions.js";import{CUSTOMER_INFORMATION_FRAGMENT as x}from"../fragments.js";import{p as y,E as S}from"./acdl.js";import{s as D}from"./setReCaptchaToken.js";const H=t=>{var T,e,o,a,c,m,r,f,g,d,s,E,u,M;const i={email:((e=(T=t==null?void 0:t.data)==null?void 0:T.customer)==null?void 0:e.email)??"",firstName:((a=(o=t==null?void 0:t.data)==null?void 0:o.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)??"",groupUid:((g=(f=(r=t==null?void 0:t.data)==null?void 0:r.customer)==null?void 0:f.group)==null?void 0:g.uid)??""};return U(i,(M=(u=(E=(s=(d=G)==null?void 0:d.getConfig())==null?void 0:s.models)==null?void 0:E.CustomerModel)==null?void 0:u.transformer)==null?void 0:M.call(u,t.data))},K=`
|
|
4
4
|
query GET_CUSTOMER_DATA {
|
|
5
5
|
customer {
|
|
6
6
|
...CUSTOMER_INFORMATION_FRAGMENT
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
${
|
|
10
|
-
`,
|
|
9
|
+
${x}
|
|
10
|
+
`,A=async t=>{if(t){const{authHeaderConfig:i}=G.getConfig();R(i.header,i.tokenPrefix?`${i.tokenPrefix} ${t}`:t)}return await $(K,{method:"GET",cache:"force-cache"}).then(i=>H(i)).catch(w)},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
|
+
`,Y=async({email:t,password:i,translations:T,onErrorCallback:e,handleSetInLineAlertProps:o})=>{var s,E,u,M,_;await D();const a=await $(Q,{method:"POST",variables:{email:t,password:i}}).catch(w);if(!((E=(s=a==null?void 0:a.data)==null?void 0:s.generateCustomerToken)!=null&&E.token)){const N=T.customerTokenErrorMessage,O=a!=null&&a.errors?a.errors[0].message:N;return e==null||e(O),o==null||o({type:"error",text:O}),{errorMessage:O,userName:"",userEmail:""}}const c=(M=(u=a==null?void 0:a.data)==null?void 0:u.generateCustomerToken)==null?void 0:M.token,m=await A(c),r=m==null?void 0:m.firstName,f=m==null?void 0:m.email;if(!r||!f){const N=T.customerTokenErrorMessage;return e==null||e(N),o==null||o({type:"error",text:N}),{errorMessage:N,userName:"",userEmail:""}}const g=await C(),d=F.includes(window.location.hostname)?"":"Secure";return document.cookie=`${h.auth_dropin_firstname}=${r}; path=/; ${g}; ${d};`,document.cookie=`${h.auth_dropin_user_token}=${c}; path=/; ${g}; ${d};`,await v(c?m==null?void 0:m.groupUid:void 0),k.emit("authenticated",!!c),y((_=S)==null?void 0:_.SIGN_IN,{...m}),{errorMessage:"",userName:r,userEmail:f}};export{Y as a,A as g};
|
|
17
17
|
//# sourceMappingURL=getCustomerToken.js.map
|