@dropins/storefront-auth 2.2.0-alpha002 → 2.2.0-alpha004
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 +5 -17
- package/api/verifyToken/verifyToken.d.ts +1 -1
- package/api.js +1 -34
- package/api.js.map +1 -1
- package/chunks/createCustomerAddress.js +1 -1
- package/chunks/createCustomerAddress.js.map +1 -1
- package/chunks/getCustomerRolePermissions.js +37 -0
- package/chunks/getCustomerRolePermissions.js.map +1 -0
- package/chunks/getCustomerToken.js +2 -2
- package/chunks/getCustomerToken.js.map +1 -1
- package/chunks/index2.js +1 -1
- package/chunks/index3.js +1 -1
- package/chunks/network-error.js +1 -1
- package/chunks/setReCaptchaToken.js +1 -1
- package/chunks/verifyToken.js +2 -2
- package/chunks/verifyToken.js.map +1 -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/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/package.json +1 -1
- package/render.js +1 -1
- package/render.js.map +1 -1
- package/chunks/initialize.js +0 -4
- package/chunks/initialize.js.map +0 -1
|
@@ -1,24 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
interface FlattenedPermissions {
|
|
10
|
-
all?: boolean;
|
|
11
|
-
admin?: boolean;
|
|
12
|
-
[key: string]: boolean | undefined;
|
|
13
|
-
}
|
|
1
|
+
import { PermissionsModel } from '../../data/models';
|
|
2
|
+
|
|
14
3
|
/**
|
|
15
4
|
* Gets user role permissions with caching
|
|
16
5
|
*/
|
|
17
|
-
export declare const getCustomerRolePermissions: () => Promise<
|
|
6
|
+
export declare const getCustomerRolePermissions: () => Promise<PermissionsModel>;
|
|
18
7
|
/**
|
|
19
|
-
*
|
|
8
|
+
* Resets the permissions cache
|
|
20
9
|
* @internal
|
|
21
10
|
*/
|
|
22
|
-
export declare const
|
|
23
|
-
export {};
|
|
11
|
+
export declare const _resetCache: () => void;
|
|
24
12
|
//# sourceMappingURL=getCustomerRolePermissions.d.ts.map
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* is strictly forbidden unless prior written permission is obtained
|
|
15
15
|
* from Adobe.
|
|
16
16
|
*******************************************************************/
|
|
17
|
-
export declare const verifyToken: (authType?: string, type?: string) => Promise<
|
|
17
|
+
export declare const verifyToken: (authType?: string, type?: string) => Promise<boolean>;
|
|
18
18
|
//# sourceMappingURL=verifyToken.d.ts.map
|
package/api.js
CHANGED
|
@@ -1,37 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{c as
|
|
4
|
-
query GET_CUSTOMER_ROLE_PERMISSIONS {
|
|
5
|
-
customer {
|
|
6
|
-
role {
|
|
7
|
-
id
|
|
8
|
-
name
|
|
9
|
-
permissions {
|
|
10
|
-
id
|
|
11
|
-
text
|
|
12
|
-
children {
|
|
13
|
-
id
|
|
14
|
-
text
|
|
15
|
-
children {
|
|
16
|
-
id
|
|
17
|
-
text
|
|
18
|
-
children {
|
|
19
|
-
id
|
|
20
|
-
text
|
|
21
|
-
children {
|
|
22
|
-
id
|
|
23
|
-
text
|
|
24
|
-
children {
|
|
25
|
-
id
|
|
26
|
-
text
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
`;let n=null,i=null;const p=e=>{const s={},t=r=>{r.forEach(o=>{var a;s[o.text]=!0,(a=o.children)!=null&&a.length&&t(o.children)})};return t(e),s},l=e=>(e==null?void 0:e.id)==="MA=="&&Array.isArray(e.permissions)&&e.permissions.length===0,f=e=>{var t;if(l(e))return{admin:!0};const s={all:!0};if((t=e==null?void 0:e.permissions)!=null&&t.length){const r=p(e.permissions);return{...s,...r}}return s},d=async()=>{var e,s,t;try{const r=await m(c,{method:"GET"});(e=r.errors)!=null&&e.length&&console.error("GraphQL errors",r.errors);const o=f((t=(s=r.data)==null?void 0:s.customer)==null?void 0:t.role);return n=o,i=null,o}catch(r){throw i=null,r}},S=()=>n?Promise.resolve(n):(i||(i=d()),i),G=()=>{n=null,i=null};export{G as __clearCacheForTesting,$ as config,D as confirmEmail,A as createCustomer,O as createCustomerAddress,m as fetchGraphQl,v as getAttributesForm,K as getConfig,M as getCustomerData,S as getCustomerRolePermissions,Q as getCustomerToken,k as getStoreConfig,ee as initialize,V as removeFetchGraphQlHeader,b as requestPasswordResetEmail,B as resendConfirmationEmail,L as resetPassword,N as revokeCustomerToken,W as setEndpoint,X as setFetchGraphQlHeader,Y as setFetchGraphQlHeaders,w as verifyToken};
|
|
3
|
+
import{c as g,a as n,g as c}from"./chunks/createCustomerAddress.js";import{g as C,a as d}from"./chunks/getCustomerToken.js";import{g as l,v as u}from"./chunks/verifyToken.js";import{r as v}from"./chunks/requestPasswordResetEmail.js";import{r as F}from"./chunks/resetPassword.js";import{r as Q}from"./chunks/revokeCustomerToken.js";import{c as P}from"./chunks/confirmEmail.js";import{r as b}from"./chunks/resendConfirmationEmail.js";import{_ as A,c as R,g as _,i as q}from"./chunks/getCustomerRolePermissions.js";import{f as z,g as D,r as S,s as j,a as B,b as I}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{A as _resetCache,R as config,P as confirmEmail,g as createCustomer,n as createCustomerAddress,z as fetchGraphQl,c as getAttributesForm,D as getConfig,C as getCustomerData,_ as getCustomerRolePermissions,d as getCustomerToken,l as getStoreConfig,q as initialize,S as removeFetchGraphQlHeader,v as requestPasswordResetEmail,b as resendConfirmationEmail,F as resetPassword,Q as revokeCustomerToken,j as setEndpoint,B as setFetchGraphQlHeader,I as setFetchGraphQlHeaders,u as verifyToken};
|
|
37
4
|
//# sourceMappingURL=api.js.map
|
package/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sources":[
|
|
1
|
+
{"version":3,"file":"api.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -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 p}from"@dropins/tools/lib.js";import{c as N}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 p}from"@dropins/tools/lib.js";import{c as N}from"./getCustomerRolePermissions.js";import{t as F}from"./transform-attributes-form.js";import{h as S}from"./verifyToken.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":"2YAmBO,MAAMA,EAAgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQzCC,CAA6B;AAAA,ECRpBC,E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ins/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":"2ZAmBO,M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sB,WAAa,EAC1D,CAAC,EACA,MAAM8B,CAAkB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{Initializer as f}from"@dropins/tools/lib.js";import{events as c}from"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{v as u}from"./verifyToken.js";import{f as d}from"./network-error.js";const m=new f({init:async e=>{const t={...{authHeaderConfig:{header:"Authorization",tokenPrefix:"Bearer"}},...e};m.config.setConfig(t),u(t.authHeaderConfig.header,t.authHeaderConfig.tokenPrefix),await C()},listeners:()=>[]}),y=m.config,h=`
|
|
4
|
+
query GET_CUSTOMER_ROLE_PERMISSIONS {
|
|
5
|
+
customer {
|
|
6
|
+
role {
|
|
7
|
+
id
|
|
8
|
+
name
|
|
9
|
+
permissions {
|
|
10
|
+
id
|
|
11
|
+
text
|
|
12
|
+
children {
|
|
13
|
+
id
|
|
14
|
+
text
|
|
15
|
+
children {
|
|
16
|
+
id
|
|
17
|
+
text
|
|
18
|
+
children {
|
|
19
|
+
id
|
|
20
|
+
text
|
|
21
|
+
children {
|
|
22
|
+
id
|
|
23
|
+
text
|
|
24
|
+
children {
|
|
25
|
+
id
|
|
26
|
+
text
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
`;let r=null,n=null;const l=e=>{const s={},t=i=>{i.forEach(o=>{var a;s[o.text]=!0,(a=o.children)!=null&&a.length&&t(o.children)})};return t(e),s},g=e=>(e==null?void 0:e.id)==="MA=="&&Array.isArray(e.permissions)&&e.permissions.length===0,p=e=>{var t;if(g(e))return{admin:!0};const s={all:!0};if((t=e==null?void 0:e.permissions)!=null&&t.length){const i=l(e.permissions);return{...s,...i}}return s},P=async()=>{var e,s;try{const t=await d(h,{method:"GET"}),i=p((s=(e=t.data)==null?void 0:e.customer)==null?void 0:s.role);return r=i,n=null,i}catch(t){throw n=null,t}},C=()=>r?(c.emit("auth/permissions",r),Promise.resolve(r)):(n||(n=P().then(e=>(c.emit("auth/permissions",e),e))),n),T=()=>{r=null,n=null};export{T as _,y as c,C as g,m as i};
|
|
37
|
+
//# sourceMappingURL=getCustomerRolePermissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCustomerRolePermissions.js","sources":["/@dropins/storefront-auth/src/api/initialize/initialize.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\nimport { Initializer, Model } from '@adobe-commerce/elsie/lib';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { CustomerModel } from '@/auth/data/models';\nimport { verifyToken, getCustomerRolePermissions } from '@/auth/api';\n\ntype ConfigProps = {\n langDefinitions?: Lang;\n authHeaderConfig: {\n header: string;\n tokenPrefix: string;\n };\n models?: {\n CustomerModel?: Model<CustomerModel>;\n };\n};\n\nexport const initialize = new Initializer<ConfigProps>({\n init: async (config) => {\n const defaultConfig = {\n authHeaderConfig: {\n header: 'Authorization',\n tokenPrefix: 'Bearer',\n },\n };\n\n const mergedConfig = { ...defaultConfig, ...config };\n\n initialize.config.setConfig(mergedConfig);\n\n verifyToken(\n mergedConfig.authHeaderConfig.header,\n mergedConfig.authHeaderConfig.tokenPrefix\n );\n\n await getCustomerRolePermissions();\n },\n\n listeners: () => [],\n});\n\nexport const config = initialize.config;\n","export const GET_CUSTOMER_ROLE_PERMISSIONS = `\n query GET_CUSTOMER_ROLE_PERMISSIONS {\n customer {\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 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 = (permissions: Permission[]): Record<string, boolean> => {\n const flattened: Record<string, boolean> = {};\n\n const processPermissions = (perms: Permission[]): void => {\n perms.forEach(permission => {\n flattened[permission.text] = true;\n if (permission.children?.length) {\n processPermissions(permission.children);\n }\n });\n };\n\n processPermissions(permissions);\n return flattened;\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 role?.id === 'MA==' &&\n Array.isArray(role.permissions) &&\n role.permissions.length === 0;\n};\n\n/**\n * Processes role data into flattened permissions\n */\nconst processUserPermissions = (role?: Role): PermissionsModel => {\n if (isAdminUser(role)) {\n return { admin: true };\n }\n\n const basePermissions: PermissionsModel = { all: true };\n \n if (role?.permissions?.length) {\n const flattenedPerms = flattenPermissionTree(role.permissions);\n return { ...basePermissions, ...flattenedPerms };\n }\n\n return basePermissions;\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(response.data?.customer?.role);\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":["initialize","Initializer","config","mergedConfig","verifyToken","getCustomerRolePermissions","GET_CUSTOMER_ROLE_PERMISSIONS","permissionsCache","fetchPromise","flattenPermissionTree","permissions","flattened","processPermissions","perms","permission","_a","isAdminUser","role","processUserPermissions","basePermissions","flattenedPerms","fetchUserRolePermissions","response","fetchGraphQl","_b","error","events","_resetCache"],"mappings":"yNAiCO,MAAMA,EAAa,IAAIC,EAAyB,CACrD,KAAM,MAAOC,GAAW,CAQtB,MAAMC,EAAe,CAAE,GAPD,CACpB,iBAAkB,CAChB,OAAQ,gBACR,YAAa,QAAA,CACf,EAGuC,GA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AT,EAAAO,EAAS,OAAT,YAAAP,EAAe,WAAf,YAAAS,EAAyB,IAAI,EAGxE,OAAAjB,EAAmBG,EACnBF,EAAe,KAERE,CACT,OAASe,EAAO,CACd,MAAAjB,EAAe,KACTiB,CACR,CACF,EAKapB,EAA6B,IAEpCE,GACFmB,EAAO,KAAK,mBAAoBnB,CAAgB,EACzC,QAAQ,QAAQA,CAAgB,IAIpCC,IACHA,EAAea,EAAA,EAA2B,KAAKX,IAC7CgB,EAAO,KAAK,mBAAoBhB,CAAW,EACpCA,EACR,GAGIF,GAOImB,EAAc,IAAY,CACrCpB,EAAmB,KACnBC,EAAe,IACjB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{
|
|
3
|
+
import{a as G,f as h,h as $}from"./network-error.js";import"@dropins/tools/recaptcha.js";import{events as w}from"@dropins/tools/event-bus.js";import{merge as k}from"@dropins/tools/lib.js";import{c as R}from"./getCustomerRolePermissions.js";import{CUSTOMER_INFORMATION_FRAGMENT as C}from"../fragments.js";import{a as U,C as O}from"./verifyToken.js";import{p as x,E as y}from"./acdl.js";import{s as F}from"./setReCaptchaToken.js";const v=t=>{var f,o,i,a,c,m,u,s,T,r,g;const e={email:((o=(f=t==null?void 0:t.data)==null?void 0:f.customer)==null?void 0:o.email)??"",firstName:((a=(i=t==null?void 0:t.data)==null?void 0:i.customer)==null?void 0:a.firstname)??"",lastName:((m=(c=t==null?void 0:t.data)==null?void 0:c.customer)==null?void 0:m.lastname)??""};return k(e,(g=(r=(T=(s=(u=R)==null?void 0:u.getConfig())==null?void 0:s.models)==null?void 0:T.CustomerModel)==null?void 0:r.transformer)==null?void 0:g.call(r,t.data))},D=`
|
|
4
4
|
query GET_CUSTOMER_DATA {
|
|
5
5
|
customer {
|
|
6
6
|
...CUSTOMER_INFORMATION_FRAGMENT
|
|
@@ -13,5 +13,5 @@ import{s as G,f as h,h as $}from"./network-error.js";import"@dropins/tools/recap
|
|
|
13
13
|
token
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
`,V=async({email:t,password:e,translations:
|
|
16
|
+
`,V=async({email:t,password:e,translations:f,onErrorCallback:o,handleSetInLineAlertProps:i})=>{var r,g,E,_,d;await F();const a=await h(K,{method:"POST",variables:{email:t,password:e}}).catch($);if(!((g=(r=a==null?void 0:a.data)==null?void 0:r.generateCustomerToken)!=null&&g.token)){const M=f.customerTokenErrorMessage,N=a!=null&&a.errors?a.errors[0].message:M;return o==null||o(N),i==null||i({type:"error",text:N}),{errorMessage:N,userName:""}}const c=(_=(E=a==null?void 0:a.data)==null?void 0:E.generateCustomerToken)==null?void 0:_.token,m=await S(c),u=m==null?void 0:m.firstName,s=m==null?void 0:m.email;if(!u||!s){const M=f.customerTokenErrorMessage;return o==null||o(M),i==null||i({type:"error",text:M}),{errorMessage:M,userName:"",userEmail:""}}const T=await U();return document.cookie=`${O.auth_dropin_firstname}=${u}; path=/; ${T}; Secure;`,document.cookie=`${O.auth_dropin_user_token}=${c}; path=/; ${T}; Secure;`,w.emit("authenticated",!!c),x((d=y)==null?void 0:d.SIGN_IN,{...m}),{errorMessage:"",userName:u,userEmail:s}};export{V as a,S as g};
|
|
17
17
|
//# sourceMappingURL=getCustomerToken.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCustomerToken.js","sources":["/@dropins/storefront-auth/src/data/transforms/transform-customer-data.ts","/@dropins/storefront-auth/src/api/getCustomerData/graphql/getCustomerData.graphql.ts","/@dropins/storefront-auth/src/api/getCustomerData/getCustomerData.ts","/@dropins/storefront-auth/src/api/getCustomerToken/graphql/getCustomerToken.graphql.ts","/@dropins/storefront-auth/src/api/getCustomerToken/getCustomerToken.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { getCustomerDataResponse } from '@/auth/types';\nimport { CustomerModel } from '../models';\nimport { config } from '@/auth/api';\nimport { merge } from '@adobe-commerce/elsie/lib';\n\nexport const transformCustomerData = (\n response: getCustomerDataResponse\n): CustomerModel => {\n const model = {\n email: response?.data?.customer?.email ?? '',\n firstName: response?.data?.customer?.firstname ?? '',\n lastName: response?.data?.customer?.lastname ?? '',\n };\n\n // Extend the model merging custom transformer, if provided\n return merge(\n model, // default transformer\n config?.getConfig()?.models?.CustomerModel?.transformer?.(response.data) // custom transformer\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CUSTOMER_INFORMATION_FRAGMENT } from '@/auth/api/fragments';\n\nexport const GET_CUSTOMER_DATA = /* GraphQL */ `\n query GET_CUSTOMER_DATA {\n customer {\n ...CUSTOMER_INFORMATION_FRAGMENT\n }\n }\n ${CUSTOMER_INFORMATION_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl, setFetchGraphQlHeader, config } from '@/auth/api';\nimport { GET_CUSTOMER_DATA } from './graphql/getCustomerData.graphql';\nimport { handleNetworkError } from '@/auth/lib/network-error';\nimport { CustomerModel } from '@/auth/data/models';\nimport { transformCustomerData } from '@/auth/data/transforms';\n\nexport const getCustomerData = async (\n user_token: string\n): Promise<CustomerModel> => {\n if (user_token) {\n const { authHeaderConfig } = config.getConfig();\n\n setFetchGraphQlHeader(\n authHeaderConfig.header,\n authHeaderConfig.tokenPrefix\n ? `${authHeaderConfig.tokenPrefix} ${user_token}`\n : user_token\n );\n }\n\n return await fetchGraphQl(GET_CUSTOMER_DATA, {\n method: 'GET',\n cache: 'force-cache',\n })\n .then((response) => {\n return transformCustomerData(response);\n })\n .catch(handleNetworkError);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const GET_CUSTOMER_TOKEN = /* GraphQL */ `\n mutation GET_CUSTOMER_TOKEN($email: String!, $password: String!) {\n generateCustomerToken(email: $email, password: $password) {\n token\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { handleNetworkError } from '@/auth/lib/network-error';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { GET_CUSTOMER_TOKEN } from './graphql/getCustomerToken.graphql';\nimport { getCustomerData } from '../getCustomerData';\nimport { InLineAlertInterface } from '@/auth/types';\nimport { events } from '@adobe-commerce/event-bus';\nimport { COOKIE_NAMES } from '@/auth/configs/cookieConfigs';\nimport { getCookiesLifetime } from '@/auth/lib/cookieUtils';\nimport { publishEvents, EventsList } from '@/auth/lib/acdl';\nimport { setReCaptchaToken } from '@/auth/lib/setReCaptchaToken';\n\ninterface getCustomerTokenProps {\n email: string;\n password: string;\n handleSetInLineAlertProps: (value?: InLineAlertInterface) => void;\n translations: Record<string, string>;\n onErrorCallback?: (value?: unknown) => void;\n}\n\nexport const getCustomerToken = async ({\n email,\n password,\n translations,\n onErrorCallback,\n handleSetInLineAlertProps,\n}: getCustomerTokenProps): Promise<{\n errorMessage: string;\n userName: string;\n userEmail: string;\n}> => {\n await setReCaptchaToken();\n\n const response = await fetchGraphQl(GET_CUSTOMER_TOKEN, {\n method: 'POST',\n variables: { email, password },\n }).catch(handleNetworkError);\n\n if (!response?.data?.generateCustomerToken?.token) {\n // Fallback error message\n const defaultErrorMessage = translations.customerTokenErrorMessage;\n const errorMessage = response?.errors\n ? response.errors[0].message\n : defaultErrorMessage;\n\n onErrorCallback?.(errorMessage);\n handleSetInLineAlertProps?.({ type: 'error', text: errorMessage });\n\n return { errorMessage, userName: '' };\n }\n\n const userToken = response?.data?.generateCustomerToken?.token;\n\n const responseCustomer = await getCustomerData(userToken);\n const userName = responseCustomer?.firstName;\n const userEmail = responseCustomer?.email;\n\n if (!userName || !userEmail) {\n const errorMessage = translations.customerTokenErrorMessage;\n\n onErrorCallback?.(errorMessage);\n handleSetInLineAlertProps?.({ type: 'error', text: errorMessage });\n\n return { errorMessage, userName: '', userEmail: '' };\n }\n\n const cookiesLifetime = await getCookiesLifetime();\n\n document.cookie = `${COOKIE_NAMES.auth_dropin_firstname}=${userName}; path=/; ${cookiesLifetime}; Secure;`;\n document.cookie = `${COOKIE_NAMES.auth_dropin_user_token}=${userToken}; path=/; ${cookiesLifetime}; Secure;`;\n\n events.emit('authenticated', !!userToken);\n\n publishEvents(EventsList?.SIGN_IN, { ...responseCustomer });\n\n return { errorMessage: '', userName, userEmail };\n};\n"],"names":["transformCustomerData","response","model","_b","_a","_d","_c","_f","_e","merge","_k","_j","_i","_h","_g","config","GET_CUSTOMER_DATA","CUSTOMER_INFORMATION_FRAGMENT","getCustomerData","user_token","authHeaderConfig","setFetchGraphQlHeader","fetchGraphQl","handleNetworkError","GET_CUSTOMER_TOKEN","getCustomerToken","email","password","translations","onErrorCallback","handleSetInLineAlertProps","setReCaptchaToken","defaultErrorMessage","errorMessage","userToken","responseCustomer","userName","userEmail","cookiesLifetime","getCookiesLifetime","COOKIE_NAMES","events","publishEvents","EventsList"],"mappings":"4ZAsBO,MAAMA,EACXC,GACkB,2BAClB,MAAMC,EAAQ,CACZ,QAAOC,GAAAC,EAAAH,GAAA,YAAAA,EAAU,OAAV,YAAAG,EAAgB,WAAhB,YAAAD,EAA0B,QAAS,GAC1C,YAAWE,GAAAC,EAAAL,GAAA,YAAAA,EAAU,OAAV,YAAAK,EAAgB,WAAhB,YAAAD,EAA0B,YAAa,GAClD,WAAUE,GAAAC,EAAAP,GAAA,YAAAA,EAAU,OAAV,YAAAO,EAAgB,WAAhB,YAAAD,EAA0B,WAAY,EAAA,EAIlD,OAAOE,EACLP,GACAQ,GAAAC,GAAAC,GAAAC,GAAAC,EAAAC,IAAA,YAAAD,EAAQ,cAAR,YAAAD,EAAqB,SAArB,YAAAD,EAA6B,gBAA7B,YAAAD,EAA4C,cAA5C,YAAAD,EAAA,KAAAC,EAA0DV,EAAS,KAAI,CAE3E,ECjBae,EAAkC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAM3CC,CAA6B;AAAA,ECFpBC,EAAkB,MAC7BC,GAC2B,CAC3B,GAAIA,EAAY,CACd,KAAM,CAAE,iBAA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AAAA,EAA4B,CAAE,KAAM,QAAS,KAAMG,IAE5C,CAAE,aAAAA,EAAc,SAAU,GAAI,UAAW,EAAA,CAClD,CAEA,MAAMK,EAAkB,MAAMC,EAAA,EAE9B,gBAAS,OAAS,GAAGC,EAAa,qBAAqB,IAAIJ,CAAQ,aAAaE,CAAe,YAC/F,SAAS,OAAS,GAAGE,EAAa,sBAAsB,IAAIN,CAAS,aAAaI,CAAe,YAEjGG,EAAO,KAAK,gBAAiB,CAAC,CAACP,CAAS,EAExCQ,GAAclC,EAAAmC,IAAA,YAAAnC,EAAY,QAAS,CAAE,GAAG2B,EAAkB,EAEnD,CAAE,aAAc,GAAI,SAAAC,EAAU,UAAAC,CAAA,CACvC"}
|
|
1
|
+
{"version":3,"file":"getCustomerToken.js","sources":["/@dropins/storefront-auth/src/data/transforms/transform-customer-data.ts","/@dropins/storefront-auth/src/api/getCustomerData/graphql/getCustomerData.graphql.ts","/@dropins/storefront-auth/src/api/getCustomerData/getCustomerData.ts","/@dropins/storefront-auth/src/api/getCustomerToken/graphql/getCustomerToken.graphql.ts","/@dropins/storefront-auth/src/api/getCustomerToken/getCustomerToken.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { getCustomerDataResponse } from '@/auth/types';\nimport { CustomerModel } from '../models';\nimport { config } from '@/auth/api';\nimport { merge } from '@adobe-commerce/elsie/lib';\n\nexport const transformCustomerData = (\n response: getCustomerDataResponse\n): CustomerModel => {\n const model = {\n email: response?.data?.customer?.email ?? '',\n firstName: response?.data?.customer?.firstname ?? '',\n lastName: response?.data?.customer?.lastname ?? '',\n };\n\n // Extend the model merging custom transformer, if provided\n return merge(\n model, // default transformer\n config?.getConfig()?.models?.CustomerModel?.transformer?.(response.data) // custom transformer\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CUSTOMER_INFORMATION_FRAGMENT } from '@/auth/api/fragments';\n\nexport const GET_CUSTOMER_DATA = /* GraphQL */ `\n query GET_CUSTOMER_DATA {\n customer {\n ...CUSTOMER_INFORMATION_FRAGMENT\n }\n }\n ${CUSTOMER_INFORMATION_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl, setFetchGraphQlHeader, config } from '@/auth/api';\nimport { GET_CUSTOMER_DATA } from './graphql/getCustomerData.graphql';\nimport { handleNetworkError } from '@/auth/lib/network-error';\nimport { CustomerModel } from '@/auth/data/models';\nimport { transformCustomerData } from '@/auth/data/transforms';\n\nexport const getCustomerData = async (\n user_token: string\n): Promise<CustomerModel> => {\n if (user_token) {\n const { authHeaderConfig } = config.getConfig();\n\n setFetchGraphQlHeader(\n authHeaderConfig.header,\n authHeaderConfig.tokenPrefix\n ? `${authHeaderConfig.tokenPrefix} ${user_token}`\n : user_token\n );\n }\n\n return await fetchGraphQl(GET_CUSTOMER_DATA, {\n method: 'GET',\n cache: 'force-cache',\n })\n .then((response) => {\n return transformCustomerData(response);\n })\n .catch(handleNetworkError);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const GET_CUSTOMER_TOKEN = /* GraphQL */ `\n mutation GET_CUSTOMER_TOKEN($email: String!, $password: String!) {\n generateCustomerToken(email: $email, password: $password) {\n token\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { handleNetworkError } from '@/auth/lib/network-error';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { GET_CUSTOMER_TOKEN } from './graphql/getCustomerToken.graphql';\nimport { getCustomerData } from '../getCustomerData';\nimport { InLineAlertInterface } from '@/auth/types';\nimport { events } from '@adobe-commerce/event-bus';\nimport { COOKIE_NAMES } from '@/auth/configs/cookieConfigs';\nimport { getCookiesLifetime } from '@/auth/lib/cookieUtils';\nimport { publishEvents, EventsList } from '@/auth/lib/acdl';\nimport { setReCaptchaToken } from '@/auth/lib/setReCaptchaToken';\n\ninterface getCustomerTokenProps {\n email: string;\n password: string;\n handleSetInLineAlertProps: (value?: InLineAlertInterface) => void;\n translations: Record<string, string>;\n onErrorCallback?: (value?: unknown) => void;\n}\n\nexport const getCustomerToken = async ({\n email,\n password,\n translations,\n onErrorCallback,\n handleSetInLineAlertProps,\n}: getCustomerTokenProps): Promise<{\n errorMessage: string;\n userName: string;\n userEmail: string;\n}> => {\n await setReCaptchaToken();\n\n const response = await fetchGraphQl(GET_CUSTOMER_TOKEN, {\n method: 'POST',\n variables: { email, password },\n }).catch(handleNetworkError);\n\n if (!response?.data?.generateCustomerToken?.token) {\n // Fallback error message\n const defaultErrorMessage = translations.customerTokenErrorMessage;\n const errorMessage = response?.errors\n ? response.errors[0].message\n : defaultErrorMessage;\n\n onErrorCallback?.(errorMessage);\n handleSetInLineAlertProps?.({ type: 'error', text: errorMessage });\n\n return { errorMessage, userName: '' };\n }\n\n const userToken = response?.data?.generateCustomerToken?.token;\n\n const responseCustomer = await getCustomerData(userToken);\n const userName = responseCustomer?.firstName;\n const userEmail = responseCustomer?.email;\n\n if (!userName || !userEmail) {\n const errorMessage = translations.customerTokenErrorMessage;\n\n onErrorCallback?.(errorMessage);\n handleSetInLineAlertProps?.({ type: 'error', text: errorMessage });\n\n return { errorMessage, userName: '', userEmail: '' };\n }\n\n const cookiesLifetime = await getCookiesLifetime();\n\n document.cookie = `${COOKIE_NAMES.auth_dropin_firstname}=${userName}; path=/; ${cookiesLifetime}; Secure;`;\n document.cookie = `${COOKIE_NAMES.auth_dropin_user_token}=${userToken}; path=/; ${cookiesLifetime}; Secure;`;\n\n events.emit('authenticated', !!userToken);\n\n publishEvents(EventsList?.SIGN_IN, { ...responseCustomer });\n\n return { errorMessage: '', userName, userEmail };\n};\n"],"names":["transformCustomerData","response","model","_b","_a","_d","_c","_f","_e","merge","_k","_j","_i","_h","_g","config","GET_CUSTOMER_DATA","CUSTOMER_INFORMATION_FRAGMENT","getCustomerData","user_token","authHeaderConfig","setFetchGraphQlHeader","fetchGraphQl","handleNetworkError","GET_CUSTOMER_TOKEN","getCustomerToken","email","password","translations","onErrorCallback","handleSetInLineAlertProps","setReCaptchaToken","defaultErrorMessage","errorMessage","userToken","responseCustomer","userName","userEmail","cookiesLifetime","getCookiesLifetime","COOKIE_NAMES","events","publishEvents","EventsList"],"mappings":"4aAsBO,MAAMA,EACXC,GACkB,2BAClB,MAAMC,EAAQ,CACZ,QAAOC,GAAAC,EAAAH,GAAA,YAAAA,EAAU,OAAV,YAAAG,EAAgB,WAAhB,YAAAD,EAA0B,QAAS,GAC1C,YAAWE,GAAAC,EAAAL,GAAA,YAAAA,EAAU,OAAV,YAAAK,EAAgB,WAAhB,YAAAD,EAA0B,YAAa,GAClD,WAAUE,GAAAC,EAAAP,GAAA,YAAAA,EAAU,OAAV,YAAAO,EAAgB,WAAhB,YAAAD,EAA0B,WAAY,EAAA,EAIlD,OAAOE,EACLP,GACAQ,GAAAC,GAAAC,GAAAC,GAAAC,EAAAC,IAAA,YAAAD,EAAQ,cAAR,YAAAD,EAAqB,SAArB,YAAAD,EAA6B,gBAA7B,YAAAD,EAA4C,cAA5C,YAAAD,EAAA,KAAAC,EAA0DV,EAAS,KAAI,CAE3E,ECjBae,EAAkC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAM3CC,CAA6B;AAAA,ECFpBC,EAAkB,MAC7BC,GAC2B,CAC3B,GAAIA,EAAY,CACd,KAAM,CAAE,iBAAAC,CAAA,EAAqBL,EAAO,UAAA,EAEpCM,EACED,EAAiB,OACjBA,EAAiB,YACb,GAAGA,EAAiB,WAAW,IAAID,CAAU,GAC7CA,CAAA,CAER,CAEA,OAAO,MAAMG,EAAaN,EAAmB,CAC3C,OAAQ,MACR,MAAO,aAAA,CACR,EACE,KAAMf,GACED,EAAsBC,CAAQ,CACtC,EACA,MAAMsB,CAAkB,CAC7B,EC5BaC,EAAmC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECmBnCC,EAAmB,MAAO,CACrC,MAAAC,EACA,SAAAC,EACA,aAAAC,EACA,gBAAAC,EAC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,EAEnD,CAAE,aAAc,GAAI,SAAAC,EAAU,UAAAC,CAAA,CACvC"}
|
package/chunks/index2.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{S as v,S as w}from"./SignInForm.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"./Button2.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/components.js";import"./Button.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/i18n.js";import"@dropins/tools/event-bus.js";import"./getCustomerToken.js";import"./network-error.js";import"@dropins/tools/fetch-graphql.js";import"./
|
|
3
|
+
import{S as v,S as w}from"./SignInForm.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"./Button2.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/components.js";import"./Button.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/i18n.js";import"@dropins/tools/event-bus.js";import"./getCustomerToken.js";import"./network-error.js";import"@dropins/tools/fetch-graphql.js";import"./getCustomerRolePermissions.js";import"./verifyToken.js";import"../fragments.js";import"./acdl.js";import"./setReCaptchaToken.js";import"./resendConfirmationEmail.js";import"./simplifyTransformAttributesForm.js";import"./transform-attributes-form.js";import"./focusOnEmptyPasswordField.js";import"./confirmEmail.js";export{v as SignInForm,w as default};
|
|
4
4
|
//# sourceMappingURL=index2.js.map
|
package/chunks/index3.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{S as y,S as z}from"./SignUpForm.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import"./createCustomerAddress.js";import"../fragments.js";import"./network-error.js";import"@dropins/tools/fetch-graphql.js";import"./setReCaptchaToken.js";import"./
|
|
3
|
+
import{S as y,S as z}from"./SignUpForm.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import"./createCustomerAddress.js";import"../fragments.js";import"./network-error.js";import"@dropins/tools/fetch-graphql.js";import"./setReCaptchaToken.js";import"./getCustomerRolePermissions.js";import"./verifyToken.js";import"./transform-attributes-form.js";import"@dropins/tools/preact-hooks.js";import"./simplifyTransformAttributesForm.js";import"./usePasswordValidationMessage.js";import"@dropins/tools/i18n.js";import"./getCustomerToken.js";import"./acdl.js";import"./Button2.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/components.js";import"./Button.js";import"./focusOnEmptyPasswordField.js";import"./resendConfirmationEmail.js";import"./SkeletonLoader.js";export{y as SignUpForm,z as default};
|
|
4
4
|
//# sourceMappingURL=index3.js.map
|
package/chunks/network-error.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{FetchGraphQL as e}from"@dropins/tools/fetch-graphql.js";import{events as r}from"@dropins/tools/event-bus.js";const{setEndpoint:h,setFetchGraphQlHeader:n,removeFetchGraphQlHeader:c,setFetchGraphQlHeaders:p,fetchGraphQl:i,getConfig:f}=new e().getMethods(),m=t=>{throw t instanceof DOMException&&t.name==="AbortError"||r.emit("auth/error",{source:"auth",type:"network",error:t}),t};export{
|
|
3
|
+
import{FetchGraphQL as e}from"@dropins/tools/fetch-graphql.js";import{events as r}from"@dropins/tools/event-bus.js";const{setEndpoint:h,setFetchGraphQlHeader:n,removeFetchGraphQlHeader:c,setFetchGraphQlHeaders:p,fetchGraphQl:i,getConfig:f}=new e().getMethods(),m=t=>{throw t instanceof DOMException&&t.name==="AbortError"||r.emit("auth/error",{source:"auth",type:"network",error:t}),t};export{n as a,p as b,i as f,f as g,m as h,c as r,h as s};
|
|
4
4
|
//# sourceMappingURL=network-error.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{verifyReCaptcha as
|
|
3
|
+
import{verifyReCaptcha as t}from"@dropins/tools/recaptcha.js";import"@dropins/tools/event-bus.js";import{a as e}from"./network-error.js";const s=async()=>{const a=await t();a&&e("X-ReCaptcha",a)};export{s};
|
|
4
4
|
//# sourceMappingURL=setReCaptchaToken.js.map
|
package/chunks/verifyToken.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{events as f}from"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{f as d,h as g,
|
|
3
|
+
import{events as f}from"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{f as d,h as g,a as l,r as C}from"./network-error.js";const h={auth_dropin_user_token:"auth_dropin_user_token",auth_dropin_firstname:"auth_dropin_firstname"},s=3600,k=t=>{var o,e,r,c,a,i,n,u,_,m;return{autocompleteOnStorefront:((e=(o=t==null?void 0:t.data)==null?void 0:o.storeConfig)==null?void 0:e.autocomplete_on_storefront)||!1,minLength:((c=(r=t==null?void 0:t.data)==null?void 0:r.storeConfig)==null?void 0:c.minimum_password_length)||3,requiredCharacterClasses:+((i=(a=t==null?void 0:t.data)==null?void 0:a.storeConfig)==null?void 0:i.required_character_classes_number)||0,createAccountConfirmation:((u=(n=t==null?void 0:t.data)==null?void 0:n.storeConfig)==null?void 0:u.create_account_confirmation)||!1,customerAccessTokenLifetime:((m=(_=t==null?void 0:t.data)==null?void 0:_.storeConfig)==null?void 0:m.customer_access_token_lifetime)*s||s}},E=t=>{const o=t.map(e=>e.message).join(" ");throw Error(o)},T=t=>{const o=document.cookie.split(";");let e;return o.forEach(r=>{const[c,a]=r.trim().split("=");c===t&&(e=decodeURIComponent(a))}),e},O=t=>{document.cookie=`${t}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`},N=async()=>{try{const t=sessionStorage.getItem("storeConfig");let e=(t?JSON.parse(t):{}).customerAccessTokenLifetime;if(!e){const r=await A();sessionStorage.setItem("storeConfig",JSON.stringify(r)),e=(r==null?void 0:r.customerAccessTokenLifetime)||s}return`Max-Age=${e}`}catch(t){return console.error("getCookiesLifetime() Error:",t),`Max-Age=${s}`}},S=`
|
|
4
4
|
query GET_STORE_CONFIG {
|
|
5
5
|
storeConfig {
|
|
6
6
|
autocomplete_on_storefront
|
|
@@ -20,5 +20,5 @@ import{events as f}from"@dropins/tools/event-bus.js";import"@dropins/tools/recap
|
|
|
20
20
|
id
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
`,q=async(t="Authorization",o="Bearer")=>{const e=T(h.auth_dropin_user_token);
|
|
23
|
+
`,q=async(t="Authorization",o="Bearer")=>{const e=T(h.auth_dropin_user_token);return f.emit("authenticated",!!e),e?(l(t,`${o} ${e}`),d(I).then(r=>{var a;return!((a=r.errors)!=null&&a.find(i=>{var n;return((n=i.extensions)==null?void 0:n.category)==="graphql-authentication"}))?!0:(O(h.auth_dropin_user_token),C(t),f.emit("authenticated",!1),!1)})):!1};export{h as C,N as a,O as d,A as g,E as h,q as v};
|
|
24
24
|
//# sourceMappingURL=verifyToken.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyToken.js","sources":["/@dropins/storefront-auth/src/configs/cookieConfigs.ts","/@dropins/storefront-auth/src/data/transforms/transform-store-config.ts","/@dropins/storefront-auth/src/lib/fetch-error.ts","/@dropins/storefront-auth/src/lib/cookieUtils.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"],"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 COOKIE_LIFETIME = 3600;\n\nexport { COOKIE_NAMES, COOKIE_LIFETIME };\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/* 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\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 customerCart {\n id\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';\n\nexport const verifyToken = async (\n authType = 'Authorization',\n type = 'Bearer'\n) => {\n const token = getCookie(COOKIE_NAMES.auth_dropin_user_token);\n\n events.emit('authenticated', !!token);\n\n if (!token) return;\n\n setFetchGraphQlHeader(authType, `${type} ${token}`);\n\n return fetchGraphQl(VALIDATE_CUSTOMER_TOKEN).then((res) => {\n const unauthenticated = !!res.errors?.find(\n (error) => error.extensions?.category === 'graphql-authentication'\n );\n\n if (!unauthenticated) return;\n\n deleteCookie(COOKIE_NAMES.auth_dropin_user_token);\n removeFetchGraphQlHeader(authType);\n events.emit('authenticated', false);\n });\n};\n"],"names":["COOKIE_NAMES","COOKIE_LIFETIME","transformStoreConfig","response","_b","_a","_d","_c","_f","_e","_h","_g","_j","_i","handleFetchError","errors","errorMessage","getCookie","cookieName","cookies","foundValue","cookie","name","value","deleteCookie","getCookiesLifetime","storeConfigString","accessTokenLifeTime","storeConfig","getStoreConfig","error","GET_STORE_CONFIG","fetchGraphQl","handleNetworkError","VALIDATE_CUSTOMER_TOKEN","verifyToken","authType","type","token","events","setFetchGraphQlHeader","res","removeFetchGraphQlHeader"],"mappings":"qJAiBA,MAAMA,EAAe,CACnB,uBAAwB,yBACxB,sBAAuB,uBACzB,EAEMC,EAAkB,KCDXC,EACXC,GACqB,yBACrB,MAAO,CACL,2BACEC,GAAAC,EAAAF,GAAA,YAAAA,EAAU,OAAV,YAAAE,EAAgB,cAAhB,YAAAD,EAA6B,6BAA8B,GAE7D,YAAWE,GAAAC,EAAAJ,GAAA,YAAAA,EAAU,OAAV,YAAAI,EAAgB,cAAhB,YAAAD,EAA6B,0BAA2B,EACnE,yBACE,GAACE,GAAAC,EAAAN,GAAA,YAAAA,EAAU,OAAV,YAAAM,EAAgB,cAAhB,YAAAD,EAA6B,oCAAqC,EACrE,4BACEE,GAAAC,EAAAR,GAAA,YAAAA,EAAU,OAAV,YAAAQ,EAAgB,cAAhB,YAAAD,EAA6B,8BAA+B,GAC9D,8BACEE,GAAAC,EAAAV,GAAA,YAAAA,EAAU,OAAV,YAAAU,EAAgB,cAAhB,YAAAD,EAA6B,gCAC3BX,GAAmBA,CAAA,CAE3B,ECnBaa,EAAoBC,GAAuC,CACtE,MAAMC,EAAeD,EAAO,IAAK,GAAW,EAAE,OAAO,EAAE,KAAK,GAAG,EAE/D,MAAM,MAAMC,CAAY,CAC1B,ECDaC,EAAaC,GAAuB,CAC/C,MAAMC,EAAU,SAAS,OAAO,MAAM,GA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AAU,GAAGC,CAAI,IAAIC,CAAK,EAAE,EAE3CN,EAAaE,CAAuB,EAAE,KAAMO,GAAQ,QAC/BpC,EAAAoC,EAAI,SAAJ,MAAApC,EAAY,KACnCyB,GAAA,OAAU,QAAAzB,EAAAyB,EAAM,aAAN,YAAAzB,EAAkB,YAAa,6BAK5CmB,EAAaxB,EAAa,sBAAsB,EAChD0C,EAAyBN,CAAQ,EACjCG,EAAO,KAAK,gBAAiB,EAAK,EACpC,CAAC,CACH"}
|
|
1
|
+
{"version":3,"file":"verifyToken.js","sources":["/@dropins/storefront-auth/src/configs/cookieConfigs.ts","/@dropins/storefront-auth/src/data/transforms/transform-store-config.ts","/@dropins/storefront-auth/src/lib/fetch-error.ts","/@dropins/storefront-auth/src/lib/cookieUtils.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"],"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 COOKIE_LIFETIME = 3600;\n\nexport { COOKIE_NAMES, COOKIE_LIFETIME };\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/* 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\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 customerCart {\n id\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';\n\nexport const verifyToken = async (\n authType = 'Authorization',\n type = 'Bearer'\n) => {\n const token = getCookie(COOKIE_NAMES.auth_dropin_user_token);\n\n events.emit('authenticated', !!token);\n\n if (!token) return false;\n\n setFetchGraphQlHeader(authType, `${type} ${token}`);\n\n return fetchGraphQl(VALIDATE_CUSTOMER_TOKEN).then((res) => {\n const unauthenticated = !!res.errors?.find(\n (error) => error.extensions?.category === 'graphql-authentication'\n );\n\n if (!unauthenticated) return true;\n\n deleteCookie(COOKIE_NAMES.auth_dropin_user_token);\n removeFetchGraphQlHeader(authType);\n events.emit('authenticated', false);\n return false;\n });\n};\n"],"names":["COOKIE_NAMES","COOKIE_LIFETIME","transformStoreConfig","response","_b","_a","_d","_c","_f","_e","_h","_g","_j","_i","handleFetchError","errors","errorMessage","getCookie","cookieName","cookies","foundValue","cookie","name","value","deleteCookie","getCookiesLifetime","storeConfigString","accessTokenLifeTime","storeConfig","getStoreConfig","error","GET_STORE_CONFIG","fetchGraphQl","handleNetworkError","VALIDATE_CUSTOMER_TOKEN","verifyToken","authType","type","token","events","setFetchGraphQlHeader","res","removeFetchGraphQlHeader"],"mappings":"qJAiBA,MAAMA,EAAe,CACnB,uBAAwB,yBACxB,sBAAuB,uBACzB,EAEMC,EAAkB,KCDXC,EACXC,GACqB,yBACrB,MAAO,CACL,2B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Aa,8BAA+B3B,CAChD,CAEA,MAAO,WAAW0B,CAAmB,EACvC,OAASG,EAAO,CACd,eAAQ,MAAM,8BAA+BA,CAAK,EAC3C,WAAW7B,CAAe,EACnC,CACF,EC7Ca8B,EAAiC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECQjCF,EAAiB,SACrB,MAAMG,EAAaD,EAAkB,CAC1C,OAAQ,MACR,MAAO,aAAA,CACR,EACE,KAAM5B,GAAqC,OAC1C,OAAIE,EAAAF,EAAS,SAAT,MAAAE,EAAiB,OAAeS,EAAiBX,EAAS,MAAM,EAE7DD,EAAqBC,CAAQ,CACtC,CAAC,EACA,MAAM8B,CAAkB,EClBhBC,EAAwC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECUxCC,EAAc,MACzBC,EAAW,gBACXC,EAAO,WACJ,CACH,MAAMC,EAAQrB,EAAUjB,EAAa,sBAAsB,EAI3D,OAFAuC,EAAO,KAAK,gBAAiB,CAAC,CAACD,CAAK,EAE/BA,GAELE,EAAsBJ,EAAU,GAAGC,CAAI,IAAIC,CAAK,EAAE,EAE3CN,EAAaE,CAAuB,EAAE,KAAMO,GAAQ,OAKzD,MAJyB,GAACpC,EAAAoC,EAAI,SAAJ,MAAApC,EAAY,KACnCyB,GAAA,OAAU,QAAAzB,EAAAyB,EAAM,aAAN,YAAAzB,EAAkB,YAAa,4BAGf,IAE7BmB,EAAaxB,EAAa,sBAAsB,EAChD0C,EAAyBN,CAAQ,EACjCG,EAAO,KAAK,gBAAiB,EAAK,EAC3B,GACT,CAAC,GAfkB,EAgBrB"}
|
package/containers/SignIn.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/preact-hooks.js";import"../chunks/Button.js";import"@dropins/tools/i18n.js";import{S as u}from"../chunks/SignInForm.js";import"@dropins/tools/preact-compat.js";import"../chunks/Button2.js";import"../chunks/getCustomerToken.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/
|
|
3
|
+
import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/preact-hooks.js";import"../chunks/Button.js";import"@dropins/tools/i18n.js";import{S as u}from"../chunks/SignInForm.js";import"@dropins/tools/preact-compat.js";import"../chunks/Button2.js";import"../chunks/getCustomerToken.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/getCustomerRolePermissions.js";import"../chunks/verifyToken.js";import"../fragments.js";import"../chunks/acdl.js";import"../chunks/setReCaptchaToken.js";import"../chunks/resendConfirmationEmail.js";import"../chunks/simplifyTransformAttributesForm.js";import"../chunks/transform-attributes-form.js";import"../chunks/focusOnEmptyPasswordField.js";import"../chunks/confirmEmail.js";const M=({slots:i,labels:o,enableEmailConfirmation:t,initialEmailValue:m,formSize:p,renderSignUpLink:n,hideCloseBtnOnEmailConfirmation:s,routeRedirectOnEmailConfirmationClose:a,routeRedirectOnSignIn:e,routeForgotPassword:c,routeSignUp:d,onSuccessCallback:f,onErrorCallback:g,onSignUpLinkClick:l})=>r("div",{className:"auth-sign-in",children:r(u,{slots:i,labels:o,formSize:p,renderSignUpLink:n,initialEmailValue:m,enableEmailConfirmation:t,hideCloseBtnOnEmailConfirmation:s,routeRedirectOnEmailConfirmationClose:a,routeSignUp:d,onErrorCallback:g,onSuccessCallback:f,onSignUpLinkClick:l,routeForgotPassword:c,routeRedirectOnSignIn:e})});export{M as SignIn,M as default};
|
|
4
4
|
//# sourceMappingURL=SignIn.js.map
|
package/containers/SignIn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignIn.js","sources":["/@dropins/storefront-auth/src/containers/SignIn/SignIn.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { SignInForm } from '@/auth/components';\nimport { SignInProps } from '@/auth/types';\n\nexport const SignIn: Container<SignInProps> = ({\n slots,\n labels,\n enableEmailConfirmation,\n initialEmailValue,\n formSize,\n renderSignUpLink,\n hideCloseBtnOnEmailConfirmation,\n routeRedirectOnEmailConfirmationClose,\n routeRedirectOnSignIn,\n routeForgotPassword,\n routeSignUp,\n onSuccessCallback,\n onErrorCallback,\n onSignUpLinkClick,\n}) => {\n return (\n <div className=\"auth-sign-in\">\n <SignInForm\n slots={slots}\n labels={labels}\n formSize={formSize}\n renderSignUpLink={renderSignUpLink}\n initialEmailValue={initialEmailValue}\n enableEmailConfirmation={enableEmailConfirmation}\n hideCloseBtnOnEmailConfirmation={hideCloseBtnOnEmailConfirmation}\n routeRedirectOnEmailConfirmationClose={\n routeRedirectOnEmailConfirmationClose\n }\n routeSignUp={routeSignUp}\n onErrorCallback={onErrorCallback}\n onSuccessCallback={onSuccessCallback}\n onSignUpLinkClick={onSignUpLinkClick}\n routeForgotPassword={routeForgotPassword}\n routeRedirectOnSignIn={routeRedirectOnSignIn}\n />\n </div>\n );\n};\n"],"names":["SignIn","slots","labels","enableEmailConfirmation","initialEmailValue","formSize","renderSignUpLink","hideCloseBtnOnEmailConfirmation","routeRedirectOnEmailConfirmationClose","routeRedirectOnSignIn","routeForgotPassword","routeSignUp","onSuccessCallback","onErrorCallback","onSignUpLinkClick","jsx","SignInForm"],"mappings":"
|
|
1
|
+
{"version":3,"file":"SignIn.js","sources":["/@dropins/storefront-auth/src/containers/SignIn/SignIn.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { SignInForm } from '@/auth/components';\nimport { SignInProps } from '@/auth/types';\n\nexport const SignIn: Container<SignInProps> = ({\n slots,\n labels,\n enableEmailConfirmation,\n initialEmailValue,\n formSize,\n renderSignUpLink,\n hideCloseBtnOnEmailConfirmation,\n routeRedirectOnEmailConfirmationClose,\n routeRedirectOnSignIn,\n routeForgotPassword,\n routeSignUp,\n onSuccessCallback,\n onErrorCallback,\n onSignUpLinkClick,\n}) => {\n return (\n <div className=\"auth-sign-in\">\n <SignInForm\n slots={slots}\n labels={labels}\n formSize={formSize}\n renderSignUpLink={renderSignUpLink}\n initialEmailValue={initialEmailValue}\n enableEmailConfirmation={enableEmailConfirmation}\n hideCloseBtnOnEmailConfirmation={hideCloseBtnOnEmailConfirmation}\n routeRedirectOnEmailConfirmationClose={\n routeRedirectOnEmailConfirmationClose\n }\n routeSignUp={routeSignUp}\n onErrorCallback={onErrorCallback}\n onSuccessCallback={onSuccessCallback}\n onSignUpLinkClick={onSignUpLinkClick}\n routeForgotPassword={routeForgotPassword}\n routeRedirectOnSignIn={routeRedirectOnSignIn}\n />\n </div>\n );\n};\n"],"names":["SignIn","slots","labels","enableEmailConfirmation","initialEmailValue","formSize","renderSignUpLink","hideCloseBtnOnEmailConfirmation","routeRedirectOnEmailConfirmationClose","routeRedirectOnSignIn","routeForgotPassword","routeSignUp","onSuccessCallback","onErrorCallback","onSignUpLinkClick","jsx","SignInForm"],"mappings":"s5BAqBO,MAAMA,EAAiC,CAAC,CAC7C,MAAAC,EACA,OAAAC,EACA,wBAAAC,EACA,kBAAAC,EACA,SAAAC,EACA,iBAAAC,EACA,gCAAAC,EACA,sCAAAC,EACA,sBAAAC,EACA,oBAAAC,EACA,YAAAC,EACA,kBAAAC,EACA,gBAAAC,EACA,kBAAAC,CACF,IAEIC,EAAC,MAAA,CAAI,UAAU,eACb,SAAAA,EAACC,EAAA,CACC,MAAAf,EACA,OAAAC,EACA,SAAAG,EACA,iBAAAC,EACA,kBAAAF,EACA,wBAAAD,EACA,gCAAAI,EACA,sCAAAC,EAGA,YAAAG,EACA,gBAAAE,EACA,kBAAAD,EACA,kBAAAE,EACA,oBAAAJ,EACA,sBAAAD,CAAA,CAAA,EAEJ"}
|
package/containers/SignUp.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/preact-hooks.js";import"../chunks/Button.js";import"@dropins/tools/i18n.js";import{S as l}from"../chunks/SignUpForm.js";import"@dropins/tools/preact-compat.js";import"../chunks/createCustomerAddress.js";import"../fragments.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/setReCaptchaToken.js";import"../chunks/
|
|
3
|
+
import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/preact-hooks.js";import"../chunks/Button.js";import"@dropins/tools/i18n.js";import{S as l}from"../chunks/SignUpForm.js";import"@dropins/tools/preact-compat.js";import"../chunks/createCustomerAddress.js";import"../fragments.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/setReCaptchaToken.js";import"../chunks/getCustomerRolePermissions.js";import"../chunks/verifyToken.js";import"../chunks/transform-attributes-form.js";import"../chunks/simplifyTransformAttributesForm.js";import"../chunks/usePasswordValidationMessage.js";import"../chunks/getCustomerToken.js";import"../chunks/acdl.js";import"../chunks/Button2.js";import"../chunks/focusOnEmptyPasswordField.js";import"../chunks/resendConfirmationEmail.js";import"../chunks/SkeletonLoader.js";const O=({slots:i,formSize:o,apiVersion2:t,addressesData:m,isAutoSignInEnabled:p,requireRetypePassword:s,inputsDefaultValueSet:a,fieldsConfigForApiVersion1:n,hideCloseBtnOnEmailConfirmation:e,routeRedirectOnEmailConfirmationClose:u,routeRedirectOnSignIn:c,onSuccessCallback:d,onErrorCallback:f,routeSignIn:g})=>r("div",{className:"auth-sign-up",children:r(l,{requireRetypePassword:s,formSize:o,apiVersion2:t,addressesData:m,isAutoSignInEnabled:p,inputsDefaultValueSet:a,fieldsConfigForApiVersion1:n,hideCloseBtnOnEmailConfirmation:e,routeRedirectOnEmailConfirmationClose:u,routeRedirectOnSignIn:c,routeSignIn:g,slots:i,onErrorCallback:f,onSuccessCallback:d})});export{O as SignUp,O as default};
|
|
4
4
|
//# sourceMappingURL=SignUp.js.map
|
package/containers/SignUp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignUp.js","sources":["/@dropins/storefront-auth/src/containers/SignUp/SignUp.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { SignUpForm } from '@/auth/components';\nimport { SignUpProps } from '@/auth/types';\n\nexport const SignUp: Container<SignUpProps> = ({\n slots,\n formSize,\n apiVersion2,\n addressesData,\n isAutoSignInEnabled,\n requireRetypePassword,\n inputsDefaultValueSet,\n fieldsConfigForApiVersion1,\n hideCloseBtnOnEmailConfirmation,\n routeRedirectOnEmailConfirmationClose,\n routeRedirectOnSignIn,\n onSuccessCallback,\n onErrorCallback,\n routeSignIn,\n}) => {\n return (\n <div className=\"auth-sign-up\">\n <SignUpForm\n requireRetypePassword={requireRetypePassword}\n formSize={formSize}\n apiVersion2={apiVersion2}\n addressesData={addressesData}\n isAutoSignInEnabled={isAutoSignInEnabled}\n inputsDefaultValueSet={inputsDefaultValueSet}\n fieldsConfigForApiVersion1={fieldsConfigForApiVersion1}\n hideCloseBtnOnEmailConfirmation={hideCloseBtnOnEmailConfirmation}\n routeRedirectOnEmailConfirmationClose={\n routeRedirectOnEmailConfirmationClose\n }\n routeRedirectOnSignIn={routeRedirectOnSignIn}\n routeSignIn={routeSignIn}\n slots={slots}\n onErrorCallback={onErrorCallback}\n onSuccessCallback={onSuccessCallback}\n />\n </div>\n );\n};\n"],"names":["SignUp","slots","formSize","apiVersion2","addressesData","isAutoSignInEnabled","requireRetypePassword","inputsDefaultValueSet","fieldsConfigForApiVersion1","hideCloseBtnOnEmailConfirmation","routeRedirectOnEmailConfirmationClose","routeRedirectOnSignIn","onSuccessCallback","onErrorCallback","routeSignIn","jsx","SignUpForm"],"mappings":"q
|
|
1
|
+
{"version":3,"file":"SignUp.js","sources":["/@dropins/storefront-auth/src/containers/SignUp/SignUp.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { SignUpForm } from '@/auth/components';\nimport { SignUpProps } from '@/auth/types';\n\nexport const SignUp: Container<SignUpProps> = ({\n slots,\n formSize,\n apiVersion2,\n addressesData,\n isAutoSignInEnabled,\n requireRetypePassword,\n inputsDefaultValueSet,\n fieldsConfigForApiVersion1,\n hideCloseBtnOnEmailConfirmation,\n routeRedirectOnEmailConfirmationClose,\n routeRedirectOnSignIn,\n onSuccessCallback,\n onErrorCallback,\n routeSignIn,\n}) => {\n return (\n <div className=\"auth-sign-up\">\n <SignUpForm\n requireRetypePassword={requireRetypePassword}\n formSize={formSize}\n apiVersion2={apiVersion2}\n addressesData={addressesData}\n isAutoSignInEnabled={isAutoSignInEnabled}\n inputsDefaultValueSet={inputsDefaultValueSet}\n fieldsConfigForApiVersion1={fieldsConfigForApiVersion1}\n hideCloseBtnOnEmailConfirmation={hideCloseBtnOnEmailConfirmation}\n routeRedirectOnEmailConfirmationClose={\n routeRedirectOnEmailConfirmationClose\n }\n routeRedirectOnSignIn={routeRedirectOnSignIn}\n routeSignIn={routeSignIn}\n slots={slots}\n onErrorCallback={onErrorCallback}\n onSuccessCallback={onSuccessCallback}\n />\n </div>\n );\n};\n"],"names":["SignUp","slots","formSize","apiVersion2","addressesData","isAutoSignInEnabled","requireRetypePassword","inputsDefaultValueSet","fieldsConfigForApiVersion1","hideCloseBtnOnEmailConfirmation","routeRedirectOnEmailConfirmationClose","routeRedirectOnSignIn","onSuccessCallback","onErrorCallback","routeSignIn","jsx","SignUpForm"],"mappings":"q/BAqBO,MAAMA,EAAiC,CAAC,CAC7C,MAAAC,EACA,SAAAC,EACA,YAAAC,EACA,cAAAC,EACA,oBAAAC,EACA,sBAAAC,EACA,sBAAAC,EACA,2BAAAC,EACA,gCAAAC,EACA,sCAAAC,EACA,sBAAAC,EACA,kBAAAC,EACA,gBAAAC,EACA,YAAAC,CACF,IAEIC,EAAC,MAAA,CAAI,UAAU,eACb,SAAAA,EAACC,EAAA,CACC,sBAAAV,EACA,SAAAJ,EACA,YAAAC,EACA,cAAAC,EACA,oBAAAC,EACA,sBAAAE,EACA,2BAAAC,EACA,gCAAAC,EACA,sCAAAC,EAGA,sBAAAC,EACA,YAAAG,EACA,MAAAb,EACA,gBAAAY,EACA,kBAAAD,CAAA,CAAA,EAEJ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as u,jsxs as H}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as Y,classes as $}from"@dropins/tools/lib.js";import{Header as Z,InLineAlert as k,InputPassword as S}from"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{useState as h,useEffect as z,useCallback as I}from"@dropins/tools/preact-hooks.js";import{u as W,F as O}from"../chunks/Button.js";import{v as g,u as R,a as C}from"../chunks/usePasswordValidationMessage.js";import{a as tt}from"../chunks/getCustomerToken.js";import{r as et}from"../chunks/resetPassword.js";import{c as j,g as at,u as st,B as rt}from"../chunks/Button2.js";import{useText as it}from"@dropins/tools/i18n.js";import"@dropins/tools/preact-compat.js";import"../chunks/verifyToken.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/
|
|
3
|
+
import{jsx as u,jsxs as H}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as Y,classes as $}from"@dropins/tools/lib.js";import{Header as Z,InLineAlert as k,InputPassword as S}from"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{useState as h,useEffect as z,useCallback as I}from"@dropins/tools/preact-hooks.js";import{u as W,F as O}from"../chunks/Button.js";import{v as g,u as R,a as C}from"../chunks/usePasswordValidationMessage.js";import{a as tt}from"../chunks/getCustomerToken.js";import{r as et}from"../chunks/resetPassword.js";import{c as j,g as at,u as st,B as rt}from"../chunks/Button2.js";import{useText as it}from"@dropins/tools/i18n.js";import"@dropins/tools/preact-compat.js";import"../chunks/verifyToken.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/getCustomerRolePermissions.js";import"../fragments.js";import"../chunks/acdl.js";import"../chunks/setReCaptchaToken.js";const J=(d,p)=>d.split("&").filter(r=>r.includes(p)).map(r=>r.split("=")[1])[0],ot=({isEmailConfirmationRequired:d,signInOnSuccess:p,passwordConfigs:t,routeRedirectOnSignIn:r,routeWrongUrlRedirect:w,onErrorCallback:a,onSuccessCallback:i,handleSetInLineAlertProps:m,routeRedirectOnPasswordUpdate:N,routeSignInPage:o})=>{const s=it({errorNotification:"Auth.Notification.errorNotification",updatePasswordMessage:"Auth.Notification.updatePasswordMessage",updatePasswordActionMessage:"Auth.Notification.updatePasswordActionMessage",customerTokenErrorMessage:"Auth.Api.customerTokenErrorMessage"}),[U,n]=h({userName:"",status:!1}),[x,F]=h(""),[v,A]=h(!1),[P,L]=h(""),[y,M]=h(""),[T,c]=h(!1),[_,q]=h(!1),[b,B]=h([]);z(()=>{v&&!b.length&&(x.length?q(!1):q(!0))},[v,x,b]),z(()=>{const{search:f}=window.location;!f.includes("token=")&&!f.includes("email=")&&j(w)&&(window.location.href=w());const e=decodeURIComponent(f),V=J(e,"token"),E=J(e,"email");L(E),M(V)},[w]);const K=I(async f=>{f.preventDefault(),c(!0),B([]);const e=at(f.target),V=(e==null?void 0:e.password)&&P&&y;e!=null&&e.password||(q(!0),c(!1));const E=(t==null?void 0:t.requiredCharacterClasses)??0,X=(t==null?void 0:t.minLength)??0;if(!g(e==null?void 0:e.password,E)||e.password.length<+X){A(!0),c(!1);return}if(!V){m({type:"error",text:s.errorNotification}),c(!1);return}const{message:D,success:G}=await et(P,y,e.password);if(G){if(d||!d&&!p){i==null||i(),j(N)&&(window.location.href=N()),A(!0),c(!1),q(!1),F(""),B([{label:s.updatePasswordActionMessage,onClick:()=>{window.location.href=o==null?void 0:o()}}]),m({type:"success",text:s.updatePasswordMessage});return}const l=await tt({email:P,password:e.password,handleSetInLineAlertProps:m,onErrorCallback:a,translations:s});l!=null&&l.userName&&(i==null||i(l==null?void 0:l.userName),j(r)?window.location.href=r():n({userName:l==null?void 0:l.userName,status:!0}))}else m({type:"error",text:D}),a==null||a({message:D,success:G});c(!1)},[P,y,t==null?void 0:t.requiredCharacterClasses,t==null?void 0:t.minLength,s,d,p,o,a,i,r,m,N]),Q=I(f=>{F(f)},[]);return{additionalActionsAlert:b,passwordError:_,isSuccessful:U,updatePasswordValue:x,isClickSubmit:v,isLoading:T,submitUpdatePassword:K,handleSetUpdatePasswordValue:Q,setIsClickSubmit:A}},ut=({signInOnSuccess:d=!0,formSize:p="default",routeRedirectOnSignIn:t,routeWrongUrlRedirect:r,routeSignInPage:w,slots:a,onErrorCallback:i,onSuccessCallback:m,routeRedirectOnPasswordUpdate:N})=>{const o=W({title:"Auth.UpdatePasswordForm.title",buttonPrimary:"Auth.UpdatePasswordForm.buttonPrimary",placeholder:"Auth.InputPassword.placeholder",floatingLabel:"Auth.InputPassword.floatingLabel",requiredFieldError:"Auth.FormText.requiredFieldError.default"}),{passwordConfigs:s,isEmailConfirmationRequired:U}=R(),{inLineAlertProps:n,handleSetInLineAlertProps:x}=st(),{additionalActionsAlert:F,passwordError:v,isSuccessful:A,updatePasswordValue:P,isClickSubmit:L,isLoading:y,submitUpdatePassword:M,handleSetUpdatePasswordValue:T}=ot({isEmailConfirmationRequired:U,signInOnSuccess:d,passwordConfigs:s,routeRedirectOnSignIn:t,routeWrongUrlRedirect:r,onErrorCallback:i,onSuccessCallback:m,handleSetInLineAlertProps:x,routeRedirectOnPasswordUpdate:N,routeSignInPage:w}),{isValidUniqueSymbols:c,defaultLengthMessage:_}=C({password:P,isClickSubmit:L,passwordConfigs:s});return A.status&&(a!=null&&a.SuccessNotification)?u(Y,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:a==null?void 0:a.SuccessNotification,context:{isSuccessful:A}}):H("div",{className:$(["auth-update-password-form",`auth-update-password-form--${p}`]),children:[u(Z,{title:o.title,divider:!1,className:"auth-update-password-form__title"}),u(k,{className:$(["auth-update-password-form__notification",["auth-update-password-form__notification--show",!!(n!=null&&n.text)]]),variant:"secondary",heading:n==null?void 0:n.text,icon:n.icon,additionalActions:F}),H(O,{name:"updatePassword_form",className:"auth-update-password-form__form",onSubmit:M,loading:y,fieldsConfig:[],children:[u("div",{style:"display: none;",children:u("input",{type:"text",id:"username",name:"username",autoComplete:"username"})}),u(S,{defaultValue:P,onValue:T,className:"auth-update-password-form__form__item",autoComplete:"new-password",name:"password",errorMessage:v||c==="error"||(_==null?void 0:_.status)==="error"?o.requiredFieldError:void 0,minLength:s==null?void 0:s.minLength,uniqueSymbolsStatus:c,validateLengthConfig:_,requiredCharacterClasses:s==null?void 0:s.requiredCharacterClasses,placeholder:o.placeholder,floatingLabel:o.floatingLabel}),u("div",{className:"auth-update-password-form__button",children:u(rt,{type:"submit",buttonText:o.buttonPrimary,variant:"primary",enableLoader:y})})]})]})},Mt=({slots:d,formSize:p,signInOnSuccess:t,routeRedirectOnPasswordUpdate:r,routeRedirectOnSignIn:w,routeSignInPage:a,routeWrongUrlRedirect:i,onErrorCallback:m,onSuccessCallback:N})=>u("div",{className:"auth-update-password",children:u(ut,{formSize:p,signInOnSuccess:t,routeSignInPage:a,routeRedirectOnSignIn:w,routeWrongUrlRedirect:i,onErrorCallback:m,onSuccessCallback:N,slots:d,routeRedirectOnPasswordUpdate:r})});export{Mt as UpdatePassword,Mt as default};
|
|
4
4
|
//# sourceMappingURL=UpdatePassword.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpdatePassword.js","sources":["/@dropins/storefront-auth/src/lib/getUrlParam.ts","/@dropins/storefront-auth/src/hooks/components/useUpdatePasswordForm.tsx","/@dropins/storefront-auth/src/components/UpdatePasswordForm/UpdatePasswordForm.tsx","/@dropins/storefront-auth/src/containers/UpdatePassword/UpdatePassword.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 getUrlParam = (url: string, param: string): string => {\n const result = url\n .split('&')\n .filter((el) => el.includes(param))\n .map((item) => {\n return item.split('=')[1];\n });\n\n return result[0];\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 { resetPassword, getCustomerToken } from '@/auth/api';\nimport { getFormValues } from '@/auth/lib/getFormValues';\nimport { getUrlParam } from '@/auth/lib/getUrlParam';\nimport { validationUniqueSymbolsPassword } from '@/auth/lib/validationUniqueSymbolsPassword';\nimport { useCallback, useEffect, useState } from 'preact/hooks';\nimport {\n AdditionalActionsAlertProps,\n UseUpdatePasswordFormProps,\n} from '@/auth/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { checkIsFunction } from '@/auth/lib/checkIsFunction';\n\nexport const useUpdatePasswordForm = ({\n isEmailConfirmationRequired,\n signInOnSuccess,\n passwordConfigs,\n routeRedirectOnSignIn,\n routeWrongUrlRedirect,\n onErrorCallback,\n onSuccessCallback,\n handleSetInLineAlertProps,\n routeRedirectOnPasswordUpdate,\n routeSignInPage,\n}: UseUpdatePasswordFormProps) => {\n const translations = useText({\n errorNotification: 'Auth.Notification.errorNotification',\n updatePasswordMessage: 'Auth.Notification.updatePasswordMessage',\n updatePasswordActionMessage:\n 'Auth.Notification.updatePasswordActionMessage',\n customerTokenErrorMessage: 'Auth.Api.customerTokenErrorMessage',\n });\n\n const [isSuccessful, setIsSuccessful] = useState({\n userName: '',\n status: false,\n });\n const [updatePasswordValue, setUpdatePasswordValue] = useState('');\n const [isClickSubmit, setIsClickSubmit] = useState(false);\n const [email, setEmail] = useState('');\n const [token, setToken] = useState('');\n const [isLoading, setIsLoading] = useState(false);\n const [passwordError, setPasswordError] = useState(false);\n const [additionalActionsAlert, setAdditionalActionsAlert] =\n useState<AdditionalActionsAlertProps>([]);\n\n useEffect(() => {\n if (isClickSubmit && !additionalActionsAlert.length) {\n if (updatePasswordValue.length) {\n setPasswordError(false);\n } else {\n setPasswordError(true);\n }\n }\n }, [isClickSubmit, updatePasswordValue, additionalActionsAlert]);\n\n useEffect(() => {\n const { search } = window.location;\n\n if (\n !search.includes('token=') &&\n !search.includes('email=') &&\n checkIsFunction(routeWrongUrlRedirect)\n ) {\n window.location.href = routeWrongUrlRedirect();\n }\n\n const url = decodeURIComponent(search);\n const tokenParam = getUrlParam(url, 'token');\n const emailParam = getUrlParam(url, 'email');\n\n setEmail(emailParam);\n setToken(tokenParam);\n }, [routeWrongUrlRedirect]);\n\n const submitUpdatePassword = useCallback(\n async (event: Event): Promise<void> => {\n event.preventDefault();\n\n setIsLoading(true);\n setAdditionalActionsAlert([]);\n\n const formValues = getFormValues(event.target);\n const validationData = formValues?.password && email && token;\n\n if (!formValues?.password) {\n setPasswordError(true);\n setIsLoading(false);\n }\n\n const requiredCharacterClasses =\n passwordConfigs?.requiredCharacterClasses ?? 0;\n const minLength = passwordConfigs?.minLength ?? 0;\n\n if (\n !validationUniqueSymbolsPassword(\n formValues?.password,\n requiredCharacterClasses\n ) ||\n formValues.password.length < +minLength\n ) {\n setIsClickSubmit(true);\n setIsLoading(false);\n\n return;\n }\n\n if (!validationData) {\n handleSetInLineAlertProps({\n type: 'error',\n text: translations.errorNotification,\n });\n\n setIsLoading(false);\n\n return;\n }\n\n const { message, success } = await resetPassword(\n email,\n token,\n formValues.password\n );\n\n if (success) {\n if (\n isEmailConfirmationRequired ||\n (!isEmailConfirmationRequired && !signInOnSuccess)\n ) {\n onSuccessCallback?.();\n\n if (checkIsFunction(routeRedirectOnPasswordUpdate)) {\n window.location.href = routeRedirectOnPasswordUpdate();\n }\n\n setIsClickSubmit(true);\n setIsLoading(false);\n setPasswordError(false);\n setUpdatePasswordValue('');\n setAdditionalActionsAlert([\n {\n label: translations.updatePasswordActionMessage,\n onClick: () => {\n window.location.href = routeSignInPage?.() as string;\n },\n },\n ]);\n handleSetInLineAlertProps({\n type: 'success',\n text: translations.updatePasswordMessage,\n });\n\n return;\n }\n\n const loginResponse = await getCustomerToken({\n email,\n password: formValues.password,\n handleSetInLineAlertProps,\n onErrorCallback,\n translations,\n });\n\n if (loginResponse?.userName) {\n onSuccessCallback?.(loginResponse?.userName);\n\n if (checkIsFunction(routeRedirectOnSignIn)) {\n window.location.href = routeRedirectOnSignIn();\n } else {\n setIsSuccessful({\n userName: loginResponse?.userName,\n status: true,\n });\n }\n }\n } else {\n handleSetInLineAlertProps({ type: 'error', text: message });\n onErrorCallback?.({ message, success });\n }\n\n setIsLoading(false);\n },\n [\n email,\n token,\n passwordConfigs?.requiredCharacterClasses,\n passwordConfigs?.minLength,\n translations,\n isEmailConfirmationRequired,\n signInOnSuccess,\n routeSignInPage,\n onErrorCallback,\n onSuccessCallback,\n routeRedirectOnSignIn,\n handleSetInLineAlertProps,\n routeRedirectOnPasswordUpdate,\n ]\n );\n\n const handleSetUpdatePasswordValue = useCallback((value: string) => {\n setUpdatePasswordValue(value);\n }, []);\n\n return {\n additionalActionsAlert,\n passwordError,\n isSuccessful,\n updatePasswordValue,\n isClickSubmit,\n isLoading,\n submitUpdatePassword,\n handleSetUpdatePasswordValue,\n setIsClickSubmit,\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 { classes, Slot } from '@adobe-commerce/elsie/lib';\nimport { useGetStoreConfigs } from '@/auth/hooks/api/useGetStoreConfigs';\nimport { usePasswordValidationMessage } from '@/auth/hooks/components/usePasswordValidationMessage';\nimport { useUpdatePasswordForm } from '@/auth/hooks/components/useUpdatePasswordForm';\nimport { UpdatePasswordFormProps } from '@/auth/types';\nimport { Form, Button } from '@/auth/components';\nimport { useInLineAlert } from '@/auth/hooks/useInLineAlert';\nimport { Header, InLineAlert, InputPassword } from '@adobe-commerce/elsie/components';\nimport '@/auth/components/UpdatePasswordForm/UpdatePasswordForm.css';\nimport { useCustomTranslations } from '@/auth/hooks/useCustomTranslations';\n\nexport const UpdatePasswordForm: FunctionComponent<UpdatePasswordFormProps> = ({\n signInOnSuccess = true,\n formSize = 'default',\n routeRedirectOnSignIn,\n routeWrongUrlRedirect,\n routeSignInPage,\n slots,\n onErrorCallback,\n onSuccessCallback,\n routeRedirectOnPasswordUpdate,\n}) => {\n /**\n * useCustomTranslations is required to support extensibility of error messages.\n * Ensure all error-related translation paths include \".default\"\n * to allow future handling of dynamic or nested error messages.\n */\n const translations = useCustomTranslations({\n title: 'Auth.UpdatePasswordForm.title',\n buttonPrimary: 'Auth.UpdatePasswordForm.buttonPrimary',\n placeholder: 'Auth.InputPassword.placeholder',\n floatingLabel: 'Auth.InputPassword.floatingLabel',\n requiredFieldError: 'Auth.FormText.requiredFieldError.default',\n });\n\n const { passwordConfigs, isEmailConfirmationRequired } = useGetStoreConfigs();\n\n const { inLineAlertProps, handleSetInLineAlertProps } = useInLineAlert();\n\n const {\n additionalActionsAlert,\n passwordError,\n isSuccessful,\n updatePasswordValue,\n isClickSubmit,\n isLoading,\n submitUpdatePassword,\n handleSetUpdatePasswordValue,\n } = useUpdatePasswordForm({\n isEmailConfirmationRequired,\n signInOnSuccess,\n passwordConfigs,\n routeRedirectOnSignIn,\n routeWrongUrlRedirect,\n onErrorCallback,\n onSuccessCallback,\n handleSetInLineAlertProps,\n routeRedirectOnPasswordUpdate,\n routeSignInPage,\n });\n\n const { isValidUniqueSymbols, defaultLengthMessage } =\n usePasswordValidationMessage({\n password: updatePasswordValue,\n isClickSubmit,\n passwordConfigs,\n });\n\n if (isSuccessful.status && slots?.SuccessNotification) {\n return (\n <Slot\n data-testid=\"successNotificationTestId\"\n name=\"SuccessNotification\"\n slot={slots?.SuccessNotification}\n context={{ isSuccessful }}\n />\n );\n }\n\n return (\n <div\n className={classes([\n 'auth-update-password-form',\n `auth-update-password-form--${formSize}`,\n ])}\n >\n <Header\n title={translations.title}\n divider={false}\n className=\"auth-update-password-form__title\"\n />\n <InLineAlert\n className={classes([\n 'auth-update-password-form__notification',\n [\n 'auth-update-password-form__notification--show',\n !!inLineAlertProps?.text,\n ],\n ])}\n variant=\"secondary\"\n heading={inLineAlertProps?.text as string}\n icon={inLineAlertProps.icon}\n additionalActions={additionalActionsAlert}\n />\n <Form\n name=\"updatePassword_form\"\n className=\"auth-update-password-form__form\"\n onSubmit={submitUpdatePassword}\n loading={isLoading}\n fieldsConfig={[]}\n >\n <div style=\"display: none;\">\n <input\n type=\"text\"\n id=\"username\"\n name=\"username\"\n autoComplete=\"username\"\n />\n </div>\n <InputPassword\n defaultValue={updatePasswordValue}\n onValue={handleSetUpdatePasswordValue}\n className=\"auth-update-password-form__form__item\"\n autoComplete={'new-password'}\n name={'password'}\n errorMessage={\n passwordError ||\n isValidUniqueSymbols === 'error' ||\n defaultLengthMessage?.status === 'error'\n ? translations.requiredFieldError\n : undefined\n }\n minLength={passwordConfigs?.minLength}\n uniqueSymbolsStatus={isValidUniqueSymbols}\n validateLengthConfig={defaultLengthMessage}\n requiredCharacterClasses={passwordConfigs?.requiredCharacterClasses}\n placeholder={translations.placeholder}\n floatingLabel={translations.floatingLabel}\n />\n\n <div className=\"auth-update-password-form__button\">\n <Button\n type=\"submit\"\n buttonText={translations.buttonPrimary}\n variant=\"primary\"\n enableLoader={isLoading}\n />\n </div>\n </Form>\n </div>\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 { Container } from '@adobe-commerce/elsie/lib';\nimport { UpdatePasswordForm } from '@/auth/components';\nimport { UpdatePasswordProps } from '@/auth/types';\n\nexport const UpdatePassword: Container<UpdatePasswordProps> = ({\n slots,\n formSize,\n signInOnSuccess,\n routeRedirectOnPasswordUpdate,\n routeRedirectOnSignIn,\n routeSignInPage,\n routeWrongUrlRedirect,\n onErrorCallback,\n onSuccessCallback,\n}) => {\n return (\n <div className=\"auth-update-password\">\n <UpdatePasswordForm\n formSize={formSize}\n signInOnSuccess={signInOnSuccess}\n routeSignInPage={routeSignInPage}\n routeRedirectOnSignIn={routeRedirectOnSignIn}\n routeWrongUrlRedirect={routeWrongUrlRedirect}\n onErrorCallback={onErrorCallback}\n onSuccessCallback={onSuccessCallback}\n slots={slots}\n routeRedirectOnPasswordUpdate={routeRedirectOnPasswordUpdate}\n />\n </div>\n );\n};\n"],"names":["getUrlParam","url","param","el","item","useUpdatePasswordForm","isEmailConfirmationRequired","signInOnSuccess","passwordConfigs","routeRedirectOnSignIn","routeWrongUrlRedirect","onErrorCallback","onSuccessCallback","handleSetInLineAlertProps","routeRedirectOnPasswordUpdate","routeSignInPage","translations","useText","isSuccessful","setIsSuccessful","useState","updatePasswordValue","setUpdatePasswordValue","isClickSubmit","setIsClickSubmit","email","setEmail","token","setToken","isLoading","setIsLoading","passwordError","setPasswordError","additionalActionsAlert","setAdditionalActionsAlert","useEffect","search","checkIsFunction","tokenParam","emailParam","submitUpdatePassword","useCallback","event","formValues","getFormValues","validationData","requiredCharacterClasses","minLength","validationUniqueSymbolsPassword","message","success","resetPassword","loginResponse","getCustomerToken","handleSetUpdatePasswordValue","value","UpdatePasswordForm","formSize","slots","useCustomTranslations","useGetStoreConfigs","inLineAlertProps","useInLineAlert","isValidUniqueSymbols","defaultLengthMessage","usePasswordValidationMessage","jsx","Slot","jsxs","classes","Header","InLineAlert","Form","InputPassword","Button","UpdatePassword"],"mappings":"y9BAiBO,MAAMA,EAAc,CAACC,EAAaC,IACxBD,EACZ,MAAM,GAAG,EACT,OAAQE,GAAOA,EAAG,SAASD,CAAK,CAAC,EACjC,IAAKE,GACGA,EAAK,MAAM,GAAG,EAAE,CAAC,CACzB,EAEW,CAAC,ECIJC,GAAwB,CAAC,CACpC,4BAAAC,EACA,gBAAAC,EACA,gBAAAC,EACA,sBAAAC,EACA,sBAAAC,EACA,gBAAAC,EACA,kBAAAC,EACA,0BAAAC,EACA,8BAAAC,EACA,gBAAAC,CACF,IAAkC,CAChC,MAAMC,EAAeC,GAAQ,CAC3B,kBAAmB,sCACnB,sBAAuB,0CACvB,4BACE,gDACF,0BAA2B,oCAAA,CAC5B,EAEK,CAACC,EAAcC,CAAe,EAAIC,EAAS,CAC/C,SAAU,GACV,OAAQ,EAAA,CACT,EACK,CAACC,EAAqBC,CAAsB,EAAIF,EAAS,EAAE,EAC3D,CAACG,EAAe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IAEIsD,EAAC,MAAA,CAAI,UAAU,uBACb,SAAAA,EAACV,GAAA,CACC,SAAAC,EACA,gBAAAlD,EACA,gBAAAQ,EACA,sBAAAN,EACA,sBAAAC,EACA,gBAAAC,EACA,kBAAAC,EACA,MAAA8C,EACA,8BAAA5C,CAAA,CAAA,EAEJ"}
|
|
1
|
+
{"version":3,"file":"UpdatePassword.js","sources":["/@dropins/storefront-auth/src/lib/getUrlParam.ts","/@dropins/storefront-auth/src/hooks/components/useUpdatePasswordForm.tsx","/@dropins/storefront-auth/src/components/UpdatePasswordForm/UpdatePasswordForm.tsx","/@dropins/storefront-auth/src/containers/UpdatePassword/UpdatePassword.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 getUrlParam = (url: string, param: string): string => {\n const result = url\n .split('&')\n .filter((el) => el.includes(param))\n .map((item) => {\n return item.split('=')[1];\n });\n\n return result[0];\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 { resetPassword, getCustomerToken } from '@/auth/api';\nimport { getFormValues } from '@/auth/lib/getFormValues';\nimport { getUrlParam } from '@/auth/lib/getUrlParam';\nimport { validationUniqueSymbolsPassword } from '@/auth/lib/validationUniqueSymbolsPassword';\nimport { useCallback, useEffect, useState } from 'preact/hooks';\nimport {\n AdditionalActionsAlertProps,\n UseUpdatePasswordFormProps,\n} from '@/auth/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { checkIsFunction } from '@/auth/lib/checkIsFunction';\n\nexport const useUpdatePasswordForm = ({\n isEmailConfirmationRequired,\n signInOnSuccess,\n passwordConfigs,\n routeRedirectOnSignIn,\n routeWrongUrlRedirect,\n onErrorCallback,\n onSuccessCallback,\n handleSetInLineAlertProps,\n routeRedirectOnPasswordUpdate,\n routeSignInPage,\n}: UseUpdatePasswordFormProps) => {\n const translations = useText({\n errorNotification: 'Auth.Notification.errorNotification',\n updatePasswordMessage: 'Auth.Notification.updatePasswordMessage',\n updatePasswordActionMessage:\n 'Auth.Notification.updatePasswordActionMessage',\n customerTokenErrorMessage: 'Auth.Api.customerTokenErrorMessage',\n });\n\n const [isSuccessful, setIsSuccessful] = useState({\n userName: '',\n status: false,\n });\n const [updatePasswordValue, setUpdatePasswordValue] = useState('');\n const [isClickSubmit, setIsClickSubmit] = useState(false);\n const [email, setEmail] = useState('');\n const [token, setToken] = useState('');\n const [isLoading, setIsLoading] = useState(false);\n const [passwordError, setPasswordError] = useState(false);\n const [additionalActionsAlert, setAdditionalActionsAlert] =\n useState<AdditionalActionsAlertProps>([]);\n\n useEffect(() => {\n if (isClickSubmit && !additionalActionsAlert.length) {\n if (updatePasswordValue.length) {\n setPasswordError(false);\n } else {\n setPasswordError(true);\n }\n }\n }, [isClickSubmit, updatePasswordValue, additionalActionsAlert]);\n\n useEffect(() => {\n const { search } = window.location;\n\n if (\n !search.includes('token=') &&\n !search.includes('email=') &&\n checkIsFunction(routeWrongUrlRedirect)\n ) {\n window.location.href = routeWrongUrlRedirect();\n }\n\n const url = decodeURIComponent(search);\n const tokenParam = getUrlParam(url, 'token');\n const emailParam = getUrlParam(url, 'email');\n\n setEmail(emailParam);\n setToken(tokenParam);\n }, [routeWrongUrlRedirect]);\n\n const submitUpdatePassword = useCallback(\n async (event: Event): Promise<void> => {\n event.preventDefault();\n\n setIsLoading(true);\n setAdditionalActionsAlert([]);\n\n const formValues = getFormValues(event.target);\n const validationData = formValues?.password && email && token;\n\n if (!formValues?.password) {\n setPasswordError(true);\n setIsLoading(false);\n }\n\n const requiredCharacterClasses =\n passwordConfigs?.requiredCharacterClasses ?? 0;\n const minLength = passwordConfigs?.minLength ?? 0;\n\n if (\n !validationUniqueSymbolsPassword(\n formValues?.password,\n requiredCharacterClasses\n ) ||\n formValues.password.length < +minLength\n ) {\n setIsClickSubmit(true);\n setIsLoading(false);\n\n return;\n }\n\n if (!validationData) {\n handleSetInLineAlertProps({\n type: 'error',\n text: translations.errorNotification,\n });\n\n setIsLoading(false);\n\n return;\n }\n\n const { message, success } = await resetPassword(\n email,\n token,\n formValues.password\n );\n\n if (success) {\n if (\n isEmailConfirmationRequired ||\n (!isEmailConfirmationRequired && !signInOnSuccess)\n ) {\n onSuccessCallback?.();\n\n if (checkIsFunction(routeRedirectOnPasswordUpdate)) {\n window.location.href = routeRedirectOnPasswordUpdate();\n }\n\n setIsClickSubmit(true);\n setIsLoading(false);\n setPasswordError(false);\n setUpdatePasswordValue('');\n setAdditionalActionsAlert([\n {\n label: translations.updatePasswordActionMessage,\n onClick: () => {\n window.location.href = routeSignInPage?.() as string;\n },\n },\n ]);\n handleSetInLineAlertProps({\n type: 'success',\n text: translations.updatePasswordMessage,\n });\n\n return;\n }\n\n const loginResponse = await getCustomerToken({\n email,\n password: formValues.password,\n handleSetInLineAlertProps,\n onErrorCallback,\n translations,\n });\n\n if (loginResponse?.userName) {\n onSuccessCallback?.(loginResponse?.userName);\n\n if (checkIsFunction(routeRedirectOnSignIn)) {\n window.location.href = routeRedirectOnSignIn();\n } else {\n setIsSuccessful({\n userName: loginResponse?.userName,\n status: true,\n });\n }\n }\n } else {\n handleSetInLineAlertProps({ type: 'error', text: message });\n onErrorCallback?.({ message, success });\n }\n\n setIsLoading(false);\n },\n [\n email,\n token,\n passwordConfigs?.requiredCharacterClasses,\n passwordConfigs?.minLength,\n translations,\n isEmailConfirmationRequired,\n signInOnSuccess,\n routeSignInPage,\n onErrorCallback,\n onSuccessCallback,\n routeRedirectOnSignIn,\n handleSetInLineAlertProps,\n routeRedirectOnPasswordUpdate,\n ]\n );\n\n const handleSetUpdatePasswordValue = useCallback((value: string) => {\n setUpdatePasswordValue(value);\n }, []);\n\n return {\n additionalActionsAlert,\n passwordError,\n isSuccessful,\n updatePasswordValue,\n isClickSubmit,\n isLoading,\n submitUpdatePassword,\n handleSetUpdatePasswordValue,\n setIsClickSubmit,\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 { classes, Slot } from '@adobe-commerce/elsie/lib';\nimport { useGetStoreConfigs } from '@/auth/hooks/api/useGetStoreConfigs';\nimport { usePasswordValidationMessage } from '@/auth/hooks/components/usePasswordValidationMessage';\nimport { useUpdatePasswordForm } from '@/auth/hooks/components/useUpdatePasswordForm';\nimport { UpdatePasswordFormProps } from '@/auth/types';\nimport { Form, Button } from '@/auth/components';\nimport { useInLineAlert } from '@/auth/hooks/useInLineAlert';\nimport { Header, InLineAlert, InputPassword } from '@adobe-commerce/elsie/components';\nimport '@/auth/components/UpdatePasswordForm/UpdatePasswordForm.css';\nimport { useCustomTranslations } from '@/auth/hooks/useCustomTranslations';\n\nexport const UpdatePasswordForm: FunctionComponent<UpdatePasswordFormProps> = ({\n signInOnSuccess = true,\n formSize = 'default',\n routeRedirectOnSignIn,\n routeWrongUrlRedirect,\n routeSignInPage,\n slots,\n onErrorCallback,\n onSuccessCallback,\n routeRedirectOnPasswordUpdate,\n}) => {\n /**\n * useCustomTranslations is required to support extensibility of error messages.\n * Ensure all error-related translation paths include \".default\"\n * to allow future handling of dynamic or nested error messages.\n */\n const translations = useCustomTranslations({\n title: 'Auth.UpdatePasswordForm.title',\n buttonPrimary: 'Auth.UpdatePasswordForm.buttonPrimary',\n placeholder: 'Auth.InputPassword.placeholder',\n floatingLabel: 'Auth.InputPassword.floatingLabel',\n requiredFieldError: 'Auth.FormText.requiredFieldError.default',\n });\n\n const { passwordConfigs, isEmailConfirmationRequired } = useGetStoreConfigs();\n\n const { inLineAlertProps, handleSetInLineAlertProps } = useInLineAlert();\n\n const {\n additionalActionsAlert,\n passwordError,\n isSuccessful,\n updatePasswordValue,\n isClickSubmit,\n isLoading,\n submitUpdatePassword,\n handleSetUpdatePasswordValue,\n } = useUpdatePasswordForm({\n isEmailConfirmationRequired,\n signInOnSuccess,\n passwordConfigs,\n routeRedirectOnSignIn,\n routeWrongUrlRedirect,\n onErrorCallback,\n onSuccessCallback,\n handleSetInLineAlertProps,\n routeRedirectOnPasswordUpdate,\n routeSignInPage,\n });\n\n const { isValidUniqueSymbols, defaultLengthMessage } =\n usePasswordValidationMessage({\n password: updatePasswordValue,\n isClickSubmit,\n passwordConfigs,\n });\n\n if (isSuccessful.status && slots?.SuccessNotification) {\n return (\n <Slot\n data-testid=\"successNotificationTestId\"\n name=\"SuccessNotification\"\n slot={slots?.SuccessNotification}\n context={{ isSuccessful }}\n />\n );\n }\n\n return (\n <div\n className={classes([\n 'auth-update-password-form',\n `auth-update-password-form--${formSize}`,\n ])}\n >\n <Header\n title={translations.title}\n divider={false}\n className=\"auth-update-password-form__title\"\n />\n <InLineAlert\n className={classes([\n 'auth-update-password-form__notification',\n [\n 'auth-update-password-form__notification--show',\n !!inLineAlertProps?.text,\n ],\n ])}\n variant=\"secondary\"\n heading={inLineAlertProps?.text as string}\n icon={inLineAlertProps.icon}\n additionalActions={additionalActionsAlert}\n />\n <Form\n name=\"updatePassword_form\"\n className=\"auth-update-password-form__form\"\n onSubmit={submitUpdatePassword}\n loading={isLoading}\n fieldsConfig={[]}\n >\n <div style=\"display: none;\">\n <input\n type=\"text\"\n id=\"username\"\n name=\"username\"\n autoComplete=\"username\"\n />\n </div>\n <InputPassword\n defaultValue={updatePasswordValue}\n onValue={handleSetUpdatePasswordValue}\n className=\"auth-update-password-form__form__item\"\n autoComplete={'new-password'}\n name={'password'}\n errorMessage={\n passwordError ||\n isValidUniqueSymbols === 'error' ||\n defaultLengthMessage?.status === 'error'\n ? translations.requiredFieldError\n : undefined\n }\n minLength={passwordConfigs?.minLength}\n uniqueSymbolsStatus={isValidUniqueSymbols}\n validateLengthConfig={defaultLengthMessage}\n requiredCharacterClasses={passwordConfigs?.requiredCharacterClasses}\n placeholder={translations.placeholder}\n floatingLabel={translations.floatingLabel}\n />\n\n <div className=\"auth-update-password-form__button\">\n <Button\n type=\"submit\"\n buttonText={translations.buttonPrimary}\n variant=\"primary\"\n enableLoader={isLoading}\n />\n </div>\n </Form>\n </div>\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 { Container } from '@adobe-commerce/elsie/lib';\nimport { UpdatePasswordForm } from '@/auth/components';\nimport { UpdatePasswordProps } from '@/auth/types';\n\nexport const UpdatePassword: Container<UpdatePasswordProps> = ({\n slots,\n formSize,\n signInOnSuccess,\n routeRedirectOnPasswordUpdate,\n routeRedirectOnSignIn,\n routeSignInPage,\n routeWrongUrlRedirect,\n onErrorCallback,\n onSuccessCallback,\n}) => {\n return (\n <div className=\"auth-update-password\">\n <UpdatePasswordForm\n formSize={formSize}\n signInOnSuccess={signInOnSuccess}\n routeSignInPage={routeSignInPage}\n routeRedirectOnSignIn={routeRedirectOnSignIn}\n routeWrongUrlRedirect={routeWrongUrlRedirect}\n onErrorCallback={onErrorCallback}\n onSuccessCallback={onSuccessCallback}\n slots={slots}\n routeRedirectOnPasswordUpdate={routeRedirectOnPasswordUpdate}\n />\n </div>\n );\n};\n"],"names":["getUrlParam","url","param","el","item","useUpdatePasswordForm","isEmailConfirmationRequired","signInOnSuccess","passwordConfigs","routeRedirectOnSignIn","routeWrongUrlRedirect","onErrorCallback","onSuccessCallback","handleSetInLineAlertProps","routeRedirectOnPasswordUpdate","routeSignInPage","translations","useText","isSuccessful","setIsSuccessful","useState","updatePasswordValue","setUpdatePasswordValue","isClickSubmit","setIsClickSubmit","email","setEmail","token","setToken","isLoading","setIsLoading","passwordError","setPasswordError","additionalActionsAlert","setAdditionalActionsAlert","useEffect","search","checkIsFunction","tokenParam","emailParam","submitUpdatePassword","useCallback","event","formValues","getFormValues","validationData","requiredCharacterClasses","minLength","validationUniqueSymbolsPassword","message","success","resetPassword","loginResponse","getCustomerToken","handleSetUpdatePasswordValue","value","UpdatePasswordForm","formSize","slots","useCustomTranslations","useGetStoreConfigs","inLineAlertProps","useInLineAlert","isValidUniqueSymbols","defaultLengthMessage","usePasswordValidationMessage","jsx","Slot","jsxs","classes","Header","InLineAlert","Form","InputPassword","Button","UpdatePassword"],"mappings":"y+BAiBO,MAAMA,EAAc,CAACC,EAAaC,IACxBD,EACZ,MAAM,GAAG,EACT,OAAQE,GAAOA,EAAG,SAASD,CAAK,CAAC,EACjC,IAAKE,GACGA,EAAK,MAAM,GAAG,EAAE,CAAC,CACzB,EAEW,CAAC,ECIJC,GAAwB,CAAC,CACpC,4BAAAC,EACA,gBAAAC,EACA,gBAAAC,EACA,sBAAAC,EACA,sBAAAC,EACA,gBAAAC,EACA,kBAAAC,EAC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,SAAAA,EAACQ,GAAA,CACC,KAAK,SACL,WAAY1D,EAAa,cACzB,QAAQ,UACR,aAAca,CAAA,CAAA,CAChB,CACF,CAAA,CAAA,CAAA,CACF,CAAA,CAAA,CAGN,ECpJa8C,GAAiD,CAAC,CAC7D,MAAAjB,EACA,SAAAD,EACA,gBAAAlD,EACA,8BAAAO,EACA,sBAAAL,EACA,gBAAAM,EACA,sBAAAL,EACA,gBAAAC,EACA,kBAAAC,CACF,IAEIsD,EAAC,MAAA,CAAI,UAAU,uBACb,SAAAA,EAACV,GAAA,CACC,SAAAC,EACA,gBAAAlD,EACA,gBAAAQ,EACA,sBAAAN,EACA,sBAAAC,EACA,gBAAAC,EACA,kBAAAC,EACA,MAAA8C,EACA,8BAAA5C,CAAA,CAAA,EAEJ"}
|
package/data/models/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@dropins/storefront-auth", "version": "2.2.0-
|
|
1
|
+
{"name": "@dropins/storefront-auth", "version": "2.2.0-alpha004", "@dropins/tools": "1.5.0-beta4", "license": "SEE LICENSE IN LICENSE.md"}
|
package/render.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
3
|
(function(o,t){try{if(typeof document<"u"){const a=document.createElement("style"),n=t.styleId;for(const i in t.attributes)a.setAttribute(i,t.attributes[i]);a.setAttribute("data-dropin",n),a.appendChild(document.createTextNode(o));const r=document.querySelector('style[data-dropin="sdk"]');if(r)r.after(a);else{const i=document.querySelector('link[rel="stylesheet"], style');i?i.before(a):document.head.append(a)}}}catch(a){console.error("dropin-styles (injectCodeFunction)",a)}})('.auth-email-confirmation-form{border-radius:8px;background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small);text-align:start}@media (min-width: 768px){.auth-email-confirmation-form{padding:var(--spacing-big) var(--spacing-xbig) var(--spacing-xxbig) var(--spacing-xbig)}}.auth-email-confirmation-form__title{font:var(--type-headline-2-default-font);letter-spacing:var(--type-display-1-letter-spacing);color:var(--color-neutral-800, #3d3d3d)}.auth-email-confirmation-form__subtitle{display:block;font:var(--type-details-caption-2-font);letter-spacing:var(--type-button-2-letter-spacing);color:var(--color-neutral-700, #666666)}.auth-email-confirmation-form__notification{margin-bottom:var(--spacing-medium)}.auth-email-confirmation-form.auth-email-confirmation-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-email-confirmation-form.auth-email-confirmation-form--small .auth-email-confirmation-form__buttons{grid-template-columns:1fr;gap:20px 0}.auth-email-confirmation-form__buttons{display:grid;grid-template-columns:auto auto;justify-content:space-between}@media (max-width: 768px){.auth-email-confirmation-form__buttons{gap:20px 0;grid-template-columns:1fr}}.auth-email-confirmation-form__text{display:block;font-family:var(--type-body-1-default-font);letter-spacing:var(--type-display-1-letter-spacing);color:var(--neutrals-neutral-800);padding:var(--spacing-big) 0}.auth-email-confirmation-form.auth-email-confirmation-form--small .auth-email-confirmation-form__buttons{justify-content:center;flex-wrap:wrap}.auth-email-confirmation-form.auth-email-confirmation-form--small .auth-email-confirmation-form__buttons{flex-basis:100%;margin-top:var(--spacing-medium)}.auth-email-confirmation-form.auth-email-confirmation-form--small .auth-email-confirmation-form__buttons>span{display:none}.auth-email-confirmation-form__buttons>span{border:1px solid var(--color-brand-500);margin:var(--spacing-small) var(--spacing-xsmall);font:var(--type-button-2-font)}@media (max-width: 768px){.auth-email-confirmation-form__buttons{justify-content:center;flex-wrap:wrap}.auth-email-confirmation-form__buttons{flex-basis:100%;margin-top:var(--spacing-medium)}.auth-email-confirmation-form__buttons>span{display:none}}.auth-update-password-form{border-radius:var(--shape-border-radius-2);background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-update-password-form{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}}.auth-update-password-form.auth-update-password-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-update-password-form.auth-update-password-form--small .auth-update-password-form__form__item{margin-bottom:var(--spacing-big)}.auth-update-password-form.auth-update-password-form--small .auth-update-password-form__title{margin-bottom:var(--spacing-small)}.auth-update-password-form__title{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-update-password-form__title{margin-bottom:var(--spacing-xxbig)}}.auth-update-password-form__form .auth-update-password-form__form__item{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-update-password-form__form .auth-update-password-form__form__item{margin-bottom:var(--spacing-xxbig)}}.auth-update-password-form__notification{display:none}.auth-update-password-form__notification--show{display:grid;margin-bottom:var(--spacing-medium)}.auth-success-notification-form{display:flex;justify-content:center;align-items:center;flex-direction:column;border-radius:var(--shape-border-radius-2);background:var(--color-neutral-50, #fff);padding:var(--spacing-xbig) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-success-notification-form{padding:var(--spacing-big) var(--spacing-xbig) var(--spacing-xxbig) var(--spacing-xbig)}}.auth-success-notification-form.auth-success-notification-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-success-notification-form__title{color:var(--color-neutral-800, #2b2b2b);font:var(--type-headline-2-strong-font);letter-spacing:var(--type-details-caption-1-letter-spacing);margin-bottom:var(--spacing-medium)}.auth-success-notification-form__content-text{color:var(--color-neutral-800, #2b2b2b);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);text-align:center;margin-bottom:var(--spacing-xxbig)}.auth-success-notification-form__button--top{margin-bottom:var(--spacing-xsmall)}.auth-sign-up-form{border-radius:var(--shape-border-radius-2);background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-sign-up-form{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}}.auth-sign-up-form.auth-sign-up-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-sign-up-form.auth-sign-up-form--small .auth-sign-up-form__title{margin-bottom:var(--spacing-small)}.auth-sign-up-form.auth-sign-up-form--small .auth-sign-up-form__form__field .auth-sign-up-form__form__field:nth-child(2),.auth-sign-up-form.auth-sign-up-form--small .auth-sign-up-form__form__field .auth-sign-up-form__form__field:nth-child(3){flex-basis:100%}.auth-sign-up-form.auth-sign-up-form--small .auth-sign-up-form__form{grid-template-columns:1fr}.auth-sign-up-form__form__confirm-wrapper>.auth-sign-up-form__form__field--confirm-password{margin:var(--spacing-medium) 0}.auth-sign-up-form__title{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-sign-up-form__title{margin-bottom:var(--spacing-xxbig)}}.auth-sign-up-form__notification{margin-bottom:var(--spacing-medium)}.auth-sign-up-form__form{display:flex;flex-wrap:wrap;flex-direction:row;gap:0 13px}.auth-sign-up-form__form__field{margin-bottom:var(--spacing-medium);flex-basis:100%;flex-grow:1;flex-shrink:0}.auth-sign-up-form__automatic-login{margin-top:12px}.auth-sign-up-form__form__field:nth-child(2),.auth-sign-up-form__form__field:nth-child(3){flex-shrink:1;flex-grow:1;flex-basis:100%}.auth-sign-up-form-buttons{flex-basis:100%;display:grid;grid-template-columns:1fr;gap:var(--spacing-medium) 0;justify-content:center;grid-area:buttons}@media (min-width: 768px){.auth-sign-up-form-buttons{display:grid;grid-template-columns:auto auto;justify-content:space-between}.auth-sign-up-form__form__field:nth-child(2),.auth-sign-up-form__form__field:nth-child(3){flex-shrink:1;flex-grow:.5;flex-basis:48%}}.auth-sign-in-form{border-radius:var(--shape-border-radius-2);background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-sign-in-form{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}}.auth-sign-in-form__notification{margin-bottom:var(--spacing-medium)}.auth-sign-in-form.auth-sign-in-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__email,.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__password,.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__title{margin-bottom:var(--spacing-medium)}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__buttons{grid-template-columns:1fr;gap:20px 0}.auth-sign-in-form__title{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-sign-in-form__title{margin-bottom:var(--spacing-xxbig)}}.auth-sign-in-form__form{display:grid;grid-template-columns:1fr}.auth-sign-in-form__form__email{margin-bottom:var(--spacing-medium)}.auth-sign-in-form__form__password{margin-bottom:var(--spacing-big)}.auth-sign-in-form__form__buttons{display:grid;grid-template-columns:auto auto;justify-content:space-between}@media (max-width: 768px){.auth-sign-in-form__form__buttons{gap:20px 0;grid-template-columns:1fr}}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine{justify-content:center;flex-wrap:wrap}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine .auth-sign-in-form__button--signup{flex-basis:100%;margin-top:20px}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine>span{display:none}.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine{display:flex}.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine>span{border:var(--shape-border-width-1) solid var(--color-brand-500);margin:13px 10px;font:var(--type-button-2-font)}.auth-sign-in-form__resend-email-notification button{font:var(--type-button-3-font);color:var(--textColor);display:inline;background-color:transparent;border:none;cursor:pointer;padding:0;margin:0}.auth-sign-in-form__resend-email-notification button:hover{color:var(--color-brand-700);text-decoration:solid underline var(--color-brand-700);text-underline-offset:6px;color:var(--color-informational-500)}@media (max-width: 768px){.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine{justify-content:center;flex-wrap:wrap}.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine .auth-sign-in-form__button--signup{flex-basis:100%;margin-top:20px}.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine>span{display:none}}.auth-reset-password-form{border-radius:var(--shape-border-radius-2);background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-reset-password-form{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}}.auth-reset-password-form.auth-reset-password-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-reset-password-form.auth-reset-password-form--small .auth-reset-password-form__form__item,.auth-reset-password-form.auth-reset-password-form--small .auth-reset-password-form__title{margin-bottom:var(--spacing-medium)}.auth-reset-password-form__form{display:grid;grid-template-columns:1fr}.auth-reset-password-form__form__item{margin-bottom:var(--spacing-medium)}.auth-reset-password-form__buttons{display:grid;grid-template-columns:1fr;gap:20px 0}.auth-reset-password-form.auth-reset-password-form--small{grid-template-columns:1fr;gap:20px 0}.auth-reset-password-form__notification{margin-bottom:var(--spacing-medium)}.auth-reset-password-form__title{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-reset-password-form__title{margin-bottom:var(--spacing-xxbig)}}@media (min-width: 600px){.auth-reset-password-form__buttons{grid-template-columns:auto auto;justify-content:space-between}}.auth-button{position:relative}.auth-button__wrapper{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);opacity:0;display:none}.auth-custom-button__loader{width:20px;height:20px;border:5px solid #fff;border-radius:50%;display:inline-block;box-sizing:border-box;position:relative;animation:pulse 1s linear infinite}.auth-button__loader:after{content:"";position:absolute;width:20px;height:20px;border:5px solid #fff;border-radius:50%;display:inline-block;box-sizing:border-box;left:50%;top:50%;transform:translate(-50%,-50%);animation:scaleUp 1s linear infinite}@keyframes scaleUp{0%{transform:translate(-50%,-50%) scale(0)}60%,to{transform:translate(-50%,-50%) scale(1)}}@keyframes pulse{0%,60%,to{transform:scale(1)}80%{transform:scale(1.2)}}.auth-button.enableLoader .auth-button__text{opacity:0}.auth-button.enableLoader .auth-button__wrapper{opacity:1;display:inline-flex}',{styleId:"Auth"});
|
|
4
|
-
import{jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{deepmerge as d,Render as m}from"@dropins/tools/lib.js";import{useState as u,useEffect as p}from"@dropins/tools/preact-hooks.js";import{UIProvider as h}from"@dropins/tools/components.js";import{events as g}from"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{c as f}from"./chunks/
|
|
4
|
+
import{jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{deepmerge as d,Render as m}from"@dropins/tools/lib.js";import{useState as u,useEffect as p}from"@dropins/tools/preact-hooks.js";import{UIProvider as h}from"@dropins/tools/components.js";import{events as g}from"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{c as f}from"./chunks/getCustomerRolePermissions.js";import"./chunks/verifyToken.js";import"./chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";const w={PasswordValidationMessage:{chartTwoSymbols:"Use characters and numbers or symbols",chartThreeSymbols:"Use characters, numbers and symbols",chartFourSymbols:"Use uppercase characters, lowercase characters, numbers and symbols",messageLengthPassword:"At least {minLength} characters long"},ResetPasswordForm:{title:"Reset your password",buttonPrimary:"Reset password",buttonSecondary:"Back to sign in",formAriaLabel:"Reset your password form"},SignInForm:{title:"Sign in",buttonPrimary:"Sign in",buttonSecondary:"Sign up",buttonTertiary:"Forgot password?"},SignUpForm:{title:"Sign up",buttonPrimary:"Create account",buttonSecondary:"Already a member? Sign in",keepMeLoggedText:"Keep me logged in after account creation",failedCreateCustomerAddress:"Failed to create customer addresses:",confirmPassword:{placeholder:"Confirm password",floatingLabel:"Confirm password *",passwordMismatch:"Passwords do not match. Please make sure both password fields are identical."}},UpdatePasswordForm:{title:"Update password",buttonPrimary:"Update password"},FormText:{requiredFieldError:"This is a required field.",numericError:"Only numeric values are allowed.",alphaNumWithSpacesError:"Only alphanumeric characters and spaces are allowed.",alphaNumericError:"Only alphanumeric characters are allowed.",alphaError:"Only alphabetic characters are allowed.",emailError:"Please enter a valid email address.",dateError:"Please enter a valid date.",dateLengthError:"Date must be between {min} and {max}.",dateMaxError:"Date must be less than or equal to {max}.",dateMinError:"Date must be greater than or equal to {min}.",urlError:"Please enter a valid URL, e.g., https://www.website.com.",lengthTextError:"Text length must be between {min} and {max} characters."},EmailConfirmationForm:{title:"Verify your email address",subtitle:"We`ve sent an email to",mainText:"Check your inbox and click on the link we just send you to confirm your email address and activate your account.",buttonSecondary:"Resend email",buttonPrimary:"Close",accountConfirmMessage:"Account confirmed",accountConfirmationEmailSuccessMessage:"Congratulations! Your account at {email} email has been successfully confirmed."},Notification:{errorNotification:"Your password update failed due to validation errors. Please check your information and try again.",updatePasswordMessage:"The password has been updated.",updatePasswordActionMessage:"Sign in",successPasswordResetEmailNotification:"If there is an account associated with {email} you will receive an email with a link to reset your password.",resendEmailNotification:{informationText:"This account is not confirmed.",buttonText:"Resend confirmation email"},emailConfirmationMessage:"Please check your email for confirmation link.",technicalErrors:{technicalErrorSendEmail:"A technical error occurred while trying to send the email. Please try again later."}},SuccessNotification:{headingText:"Welcome!",messageText:"We are glad to see you!",primaryButtonText:"Continue shopping",secondaryButtonText:"Logout"},Api:{customerTokenErrorMessage:"Unable to log in. Please try again later or contact support if the issue persists."},InputPassword:{placeholder:"Password",floatingLabel:"Password *"}},y={Auth:w},b={default:y},P=({children:n})=>{var a,t;const[e,i]=u("en_US"),c=(t=(a=f)==null?void 0:a.getConfig())==null?void 0:t.langDefinitions;p(()=>{const r=g.on("locale",o=>{o!==e&&i(o)},{eager:!0});return()=>{r==null||r.off()}},[e]);const l=d(b,c??{});return s(h,{lang:e,langDefinitions:l,children:n})},A=new m(s(P,{}));export{A as render};
|
|
5
5
|
//# sourceMappingURL=render.js.map
|
package/render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sources":["/@dropins/storefront-auth/src/render/Provider.tsx","/@dropins/storefront-auth/src/render/render.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FunctionComponent } from 'preact';\nimport { useState, useEffect } from 'preact/hooks';\nimport { UIProvider } from '@adobe-commerce/elsie/components';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { events } from '@adobe-commerce/event-bus';\nimport { config } from '@/auth/api';\nimport { deepmerge } from '@adobe-commerce/elsie/lib';\n\nimport en_US from '../i18n/en_US.json';\n\n// Langs\nconst langDefinitions = {\n default: en_US,\n};\n\ninterface CartProviderProps {\n children?: any;\n}\n\nexport const Provider: FunctionComponent<CartProviderProps> = ({\n children,\n}) => {\n const [locale, setLang] = useState<Lang>('en_US');\n\n const userLangDefinitions = config?.getConfig()?.langDefinitions;\n\n // Events\n useEffect(() => {\n const localeEvent = events.on(\n 'locale',\n (payload) => {\n if (payload !== locale) setLang(payload as Lang);\n },\n { eager: true }\n );\n return () => {\n localeEvent?.off();\n };\n }, [locale]);\n\n // Merge language definitions with user language definitions\n const definitions = deepmerge(langDefinitions, userLangDefinitions ?? {});\n\n return (\n <UIProvider lang={locale} langDefinitions={definitions}>\n {children}\n </UIProvider>\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 { Render } from '@adobe-commerce/elsie/lib';\nimport { Provider } from './Provider';\n\nexport const render = new Render(<Provider />);\n"],"names":["langDefinitions","en_US","Provider","children","locale","setLang","useState","userLangDefinitions","_b","_a","config","useEffect","localeEvent","events","payload","definitions","deepmerge","UIProvider","render","Render","jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"render.js","sources":["/@dropins/storefront-auth/src/render/Provider.tsx","/@dropins/storefront-auth/src/render/render.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FunctionComponent } from 'preact';\nimport { useState, useEffect } from 'preact/hooks';\nimport { UIProvider } from '@adobe-commerce/elsie/components';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { events } from '@adobe-commerce/event-bus';\nimport { config } from '@/auth/api';\nimport { deepmerge } from '@adobe-commerce/elsie/lib';\n\nimport en_US from '../i18n/en_US.json';\n\n// Langs\nconst langDefinitions = {\n default: en_US,\n};\n\ninterface CartProviderProps {\n children?: any;\n}\n\nexport const Provider: FunctionComponent<CartProviderProps> = ({\n children,\n}) => {\n const [locale, setLang] = useState<Lang>('en_US');\n\n const userLangDefinitions = config?.getConfig()?.langDefinitions;\n\n // Events\n useEffect(() => {\n const localeEvent = events.on(\n 'locale',\n (payload) => {\n if (payload !== locale) setLang(payload as Lang);\n },\n { eager: true }\n );\n return () => {\n localeEvent?.off();\n };\n }, [locale]);\n\n // Merge language definitions with user language definitions\n const definitions = deepmerge(langDefinitions, userLangDefinitions ?? {});\n\n return (\n <UIProvider lang={locale} langDefinitions={definitions}>\n {children}\n </UIProvider>\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 { Render } from '@adobe-commerce/elsie/lib';\nimport { Provider } from './Provider';\n\nexport const render = new Render(<Provider />);\n"],"names":["langDefinitions","en_US","Provider","children","locale","setLang","useState","userLangDefinitions","_b","_a","config","useEffect","localeEvent","events","payload","definitions","deepmerge","UIProvider","render","Render","jsx"],"mappings":"ipHA4BMA,EAAkB,CACtB,QAASC,CACX,EAMaC,EAAiD,CAAC,CAC7D,SAAAC,CACF,IAAM,SACJ,KAAM,CAACC,EAAQC,CAAO,EAAIC,EAAe,OAAO,EAE1CC,GAAsBC,GAAAC,EAAAC,IAAA,YAAAD,EAAQ,cAAR,YAAAD,EAAqB,gBAGjDG,EAAU,IAAM,CACd,MAAMC,EAAcC,EAAO,GACzB,SACCC,GAAY,CACPA,IAAYV,GAAQC,EAAQS,CAAe,CACjD,EACA,CAAE,MAAO,EAAA,CAAK,EAEhB,MAAO,IAAM,CACXF,GAAA,MAAAA,EAAa,KACf,CACF,EAAG,CAACR,CAAM,CAAC,EAGX,MAAMW,EAAcC,EAAUhB,EAAiBO,GAAuB,CAAA,CAAE,EAExE,SACGU,EAAA,CAAW,KAAMb,EAAQ,gBAAiBW,EACxC,SAAAZ,EACH,CAEJ,EC7Cae,EAAS,IAAIC,EAAOC,EAAClB,IAAS,CAAE"}
|
package/chunks/initialize.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*! Copyright 2025 Adobe
|
|
2
|
-
All Rights Reserved. */
|
|
3
|
-
import{Initializer as n}from"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{v as t}from"./verifyToken.js";const e=new n({init:async o=>{const i={...{authHeaderConfig:{header:"Authorization",tokenPrefix:"Bearer"}},...o};e.config.setConfig(i),t(i.authHeaderConfig.header,i.authHeaderConfig.tokenPrefix)},listeners:()=>[]}),c=e.config;export{c,e as i};
|
|
4
|
-
//# sourceMappingURL=initialize.js.map
|
package/chunks/initialize.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sources":["/@dropins/storefront-auth/src/api/initialize/initialize.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 { Initializer, Model } from '@adobe-commerce/elsie/lib';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { CustomerModel } from '@/auth/data/models';\nimport { verifyToken } from '@/auth/api';\n\ntype ConfigProps = {\n langDefinitions?: Lang;\n authHeaderConfig: {\n header: string;\n tokenPrefix: string;\n };\n models?: {\n CustomerModel?: Model<CustomerModel>;\n };\n};\n\nexport const initialize = new Initializer<ConfigProps>({\n init: async (config) => {\n const defaultConfig = {\n authHeaderConfig: {\n header: 'Authorization',\n tokenPrefix: 'Bearer',\n },\n };\n\n const mergedConfig = { ...defaultConfig, ...config };\n\n initialize.config.setConfig(mergedConfig);\n\n verifyToken(\n mergedConfig.authHeaderConfig.header,\n mergedConfig.authHeaderConfig.tokenPrefix\n );\n },\n\n listeners: () => [],\n});\n\nexport const config = initialize.config;\n"],"names":["initialize","Initializer","config","mergedConfig","verifyToken"],"mappings":"iKAiCO,MAAMA,EAAa,IAAIC,EAAyB,CACrD,KAAM,MAAOC,GAAW,CAQtB,MAAMC,EAAe,CAAE,GAPD,CACpB,iBAAkB,CAChB,OAAQ,gBACR,YAAa,QAAA,CACf,EAGuC,GAAGD,CAAAA,EAE5CF,EAAW,OAAO,UAAUG,CAAY,EAExCC,EACED,EAAa,iBAAiB,OAC9BA,EAAa,iBAAiB,WAAA,CAElC,EAEA,UAAW,IAAM,CAAA,CACnB,CAAC,EAEYD,EAASF,EAAW"}
|