-import n from"node-fetch";var r=n=>encodeURIComponent(n).replace(/[!'()*]/g,n=>`%${n.charCodeAt(0).toString(16).toUpperCase()}`);function t(n,t){return t.encode?t.strict?r(n):encodeURIComponent(n):n}var e=function(r){return{social:function(n){return"https://"+r+".myshopify.com/apps/dimensionauth/"+n+"/1?native=1"},passwordless:function(e){try{var i=!1;function a(n){return i?n:{success:!1}}var s=e.email,c=o()+" "+o()+" "+Math.floor(10*Math.random()),u=function(){if(s&&s.length>5&&s.indexOf("@")>-1)return Promise.resolve(n("https://"+r+".myshopify.com/apps/dimensionauth/passwordless?"+((n,r)=>{if(!n)return"";const e=function(n){switch(n.arrayFormat){case"index":return r=>(e,o)=>{const i=e.length;return void 0===o?e:null===o?[...e,[t(r,n),"[",i,"]"].join("")]:[...e,[t(r,n),"[",t(i,n),"]=",t(o,n)].join("")]};case"bracket":return r=>(e,o)=>void 0===o?e:null===o?[...e,[t(r,n),"[]"].join("")]:[...e,[t(r,n),"[]=",t(o,n)].join("")];case"comma":return r=>(e,o,i)=>null==o||0===o.length?e:0===i?[[t(r,n),"=",t(o,n)].join("")]:[[e,t(o,n)].join(",")];default:return r=>(e,o)=>void 0===o?e:null===o?[...e,t(r,n)]:[...e,[t(r,n),"=",t(o,n)].join("")]}}(r=Object.assign({encode:!0,strict:!0,arrayFormat:"none"},r)),o=Object.keys(n);return!1!==r.sort&&o.sort(r.sort),o.map(o=>{const i=n[o];return void 0===i?"":null===i?t(o,r):Array.isArray(i)?i.reduce(e(o),[]).join("&"):t(o,r)+"="+t(i,r)}).filter(n=>n.length>0).join("&")})({email:s,code:c,native:1}))).then(function(n){return i=!0,n.json()})}();return Promise.resolve(u&&u.then?u.then(a):a(u))}catch(n){return Promise.reject(n)}}}};function o(){var n=["a","e","i","o","u"],r=["b","c","d","f","g","h","j","k","l","m","n","p","q","r","s","t","v","w","x","y","z"];return r[Math.floor(Math.random()*r.length)]+n[Math.floor(Math.random()*n.length)]}export{e as login};
0 commit comments