1const customGQLApi=(function(){const apiVersion="2021-07",customerAccessTokenLocalKey="customerAccessToken",storefrontAPIAccessToken="35fbafb4c356d015dbf54bae5f6011be",gqlEndpoint=function(){return window.location.origin+window.Shopify.routes.root+`api/${apiVersion}/graphql.json`},defaultHeaders={"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":storefrontAPIAccessToken},loginMutation=` 2 mutation customerAccessTokenCreate($input: CustomerAccessTokenCreateInput!) { 3 customerAccessTokenCreate(input: $input) { 4 customerAccessToken { 5 accessToken 6 expiresAt 7 } 8 customerUserErrors { 9 code 10 field 11 message 12 } 13 } 14 } 15 `,updateCustomerMutation=` 16 mutation customerUpdate($customerAccessToken: String!, $customer: CustomerUpdateInput!) { 17 customerUpdate(customerAccessToken: $customerAccessToken, customer: $customer) { 18 customer { 19 id 20 } 21 userErrors { 22 field 23 message 24 } 25 } 26 } 27 `,customerAccessTokenDeleteMutation=` 28 mutation customerAccessTokenDelete($customerAccessToken: String!) { 29 customerAccessTokenDelete(customerAccessToken: $customerAccessToken) { 30 deletedAccessToken 31 deletedCustomerAccessTokenId 32 userErrors { 33 field 34 message 35 } 36 } 37 } 38 `,fetchGQL=function(body){return console.log("gqlEndpointSTART"),console.log("gqlEndpoint: ",gqlEndpoint()),fetch(gqlEndpoint(),{method:"POST",headers:defaultHeaders,body:JSON.stringify(body)})};return{getCustomerAccessToken:async function(email,password){if(!email||!password)return null;const jsonResponse=await(await fetchGQL({query:loginMutation,variables:{input:{email,password}}})).json();console.log("gqlEndpointRESPONSE: ",jsonResponse);const cat=jsonResponse?.data?.customerAccessTokenCreate?.customerAccessToken?.accessToken??null;return cat&&localStorage.setItem(customerAccessTokenLocalKey,cat),cat},updateCustomer:async function(firstName,lastName,email,password){const variables={customerAccessToken:localStorage.getItem(customerAccessTokenLocalKey),customer:{firstName,lastName,email,password}};return(await(await fetchGQL({query:updateCustomerMutation,variables})).json()).data.customerUpdate},getToken:async function(customerEmail,customerPassword){const tokenUrl=`${window.location.origin}/api/2024-07/graphql.json`,jsonBody={query:`mutation customerAccessTokenCreate { customerAccessTokenCreate(input: {email: "${customerEmail}", password: "${customerPassword}"}) { customerAccessToken { accessToken } customerUserErrors { message } } }`};try{const response=await fetch(tokenUrl,{method:"POST",body:JSON.stringify(jsonBody),headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":"35fbafb4c356d015dbf54bae5f6011be",Accept:"application/json"}});if(!response.ok)throw new Error(`Response status: ${response.status}`);const json=await response.json();return json.data.customerAccessTokenCreate.customerAccessToken?.accessToken?json.data.customerAccessTokenCreate.customerAccessToken.accessToken:null}catch(error){console.log(error)}},updateCustomerMarketingSubscription:async function(acceptsMarketing){const variables={customerAccessToken:localStorage.getItem(customerAccessTokenLocalKey),customer:{acceptsMarketing}};return(await(await fetchGQL({query:updateCustomerMutation,variables})).json()).data.customerUpdate},removeCustomerAccessToken:async function(){const accessToken=localStorage.getItem(customerAccessTokenLocalKey);if(!accessToken)return;localStorage.removeItem(customerAccessTokenLocalKey),await(await fetchGQL({query:customerAccessTokenDeleteMutation,variables:{customerAccessToken:accessToken}})).json()}}})(),links=document.querySelectorAll("a.menu-item");links.forEach(link=>{link.textContent.trim()==="Sign Out"&&link.addEventListener("click",function(){customGQLApi.removeCustomerAccessToken()})}); 39//# sourceMappingURL=/cdn/shop/t/29/assets/custom-graphql-api.js.map?v=156682149043995938911756909623
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.