@frak-labs/core-sdk 0.1.1-beta.74fa073f → 0.1.1-beta.86e41c13

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.
Files changed (37) hide show
  1. package/cdn/bundle.js +3 -3
  2. package/dist/actions.cjs +1 -1
  3. package/dist/actions.d.cts +2 -2
  4. package/dist/actions.d.ts +2 -2
  5. package/dist/actions.js +1 -1
  6. package/dist/bundle.cjs +1 -1
  7. package/dist/bundle.d.cts +3 -3
  8. package/dist/bundle.d.ts +3 -3
  9. package/dist/bundle.js +1 -1
  10. package/dist/{computeLegacyProductId-fl_Sx8v5.d.cts → computeLegacyProductId-B-2-L7VT.d.cts} +1 -1
  11. package/dist/{computeLegacyProductId-CSSiQO4V.d.ts → computeLegacyProductId-M9k7vnUf.d.ts} +1 -1
  12. package/dist/index.cjs +1 -1
  13. package/dist/index.d.cts +2 -2
  14. package/dist/index.d.ts +2 -2
  15. package/dist/index.js +1 -1
  16. package/dist/{openSso-CC1-loUk.d.cts → openSso-DTFns_5E.d.cts} +5 -2
  17. package/dist/{openSso-tkqaDQLV.d.ts → openSso-DXL8K2tc.d.ts} +5 -2
  18. package/dist/setupClient-UMz34Dmb.js +13 -0
  19. package/dist/setupClient-asUiwNYi.cjs +13 -0
  20. package/dist/siweAuthenticate-BvlTzQEa.cjs +1 -0
  21. package/dist/{siweAuthenticate-BOqz9Uww.d.ts → siweAuthenticate-BxRXLOpn.d.ts} +1 -1
  22. package/dist/{siweAuthenticate-DfiQdngJ.d.cts → siweAuthenticate-D_AfTjZY.d.cts} +1 -1
  23. package/dist/siweAuthenticate-JMWtaEGT.js +1 -0
  24. package/dist/trackEvent-2_5BW61g.cjs +1 -0
  25. package/dist/trackEvent-BXs0TMuA.js +1 -0
  26. package/package.json +3 -3
  27. package/src/actions/sendInteraction.ts +2 -1
  28. package/src/clients/createIFrameFrakClient.ts +6 -1
  29. package/src/clients/transports/iframeLifecycleManager.ts +49 -2
  30. package/src/types/rpc.ts +6 -2
  31. package/src/utils/clientId.ts +3 -0
  32. package/dist/setupClient-CO8HTRRE.js +0 -13
  33. package/dist/setupClient-Cc88LYkD.cjs +0 -13
  34. package/dist/siweAuthenticate-BKSiU7Ej.js +0 -1
  35. package/dist/siweAuthenticate-CVMVEe3M.cjs +0 -1
  36. package/dist/trackEvent-B0S5E6_h.js +0 -1
  37. package/dist/trackEvent-BbX2d3g_.cjs +0 -1
package/cdn/bundle.js CHANGED
@@ -1,5 +1,5 @@
1
- var FrakSDK=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=(e,t)=>()=>(e&&(t=e(e=0)),t);async function n(e,t){return await e.request({method:`frak_displayEmbeddedWallet`,params:[t,e.config.metadata]})}async function r(e,{steps:t,metadata:n}){return await e.request({method:`frak_displayModal`,params:[t,n,e.config.metadata]})}async function i(e){return await e.request({method:`frak_getMerchantInformation`})}function a(e,{strict:t=!0}={}){return!e||typeof e!=`string`?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith(`0x`)}var o=t((()=>{}));function s(e){return a(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}var c=t((()=>{o()})),l,ee=t((()=>{l=`2.46.2`}));function u(e,t){return t?.(e)?e:e&&typeof e==`object`&&`cause`in e&&e.cause!==void 0?u(e.cause,t):t?null:e}var d,f,p=t((()=>{ee(),d={getDocsUrl:({docsBaseUrl:e,docsPath:t=``,docsSlug:n})=>t?`${e??`https://viem.sh`}${t}${n?`#${n}`:``}`:void 0,version:`viem@${l}`},f=class e extends Error{constructor(t,n={}){let r=n.cause instanceof e?n.cause.details:n.cause?.message?n.cause.message:n.details,i=n.cause instanceof e&&n.cause.docsPath||n.docsPath,a=d.getDocsUrl?.({...n,docsPath:i}),o=[t||`An error occurred.`,``,...n.metaMessages?[...n.metaMessages,``]:[],...a?[`Docs: ${a}`]:[],...r?[`Details: ${r}`]:[],...d.version?[`Version: ${d.version}`]:[]].join(`
2
- `);super(o,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,`details`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,`docsPath`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,`metaMessages`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,`shortMessage`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,`version`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,`name`,{enumerable:!0,configurable:!0,writable:!0,value:`BaseError`}),this.details=r,this.docsPath=i,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=t,this.version=l}walk(e){return u(this,e)}}})),m,h=t((()=>{p(),m=class extends f{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:`SizeExceedsPaddingSizeError`})}}}));function g(e,{dir:t,size:n=32}={}){return typeof e==`string`?te(e,{dir:t,size:n}):ne(e,{dir:t,size:n})}function te(e,{dir:t,size:n=32}={}){if(n===null)return e;let r=e.replace(`0x`,``);if(r.length>n*2)throw new m({size:Math.ceil(r.length/2),targetSize:n,type:`hex`});return`0x${r[t===`right`?`padEnd`:`padStart`](n*2,`0`)}`}function ne(e,{dir:t,size:n=32}={}){if(n===null)return e;if(e.length>n)throw new m({size:e.length,targetSize:n,type:`bytes`});let r=new Uint8Array(n);for(let i=0;i<n;i++){let a=t===`right`;r[a?i:n-i-1]=e[a?i:e.length-i-1]}return r}var re=t((()=>{h()})),_,v,ie=t((()=>{p(),_=class extends f{constructor({max:e,min:t,signed:n,size:r,value:i}){super(`Number "${i}" is not in safe ${r?`${r*8}-bit ${n?`signed`:`unsigned`} `:``}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:`IntegerOutOfRangeError`})}},v=class extends f{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:`SizeOverflowError`})}}}));function y(e,{size:t}){if(s(e)>t)throw new v({givenSize:s(e),maxSize:t})}var ae=t((()=>{ie(),c()}));function oe(e,t={}){return typeof e==`number`||typeof e==`bigint`?ce(e,t):typeof e==`string`?le(e,t):typeof e==`boolean`?se(e,t):b(e,t)}function se(e,t={}){let n=`0x${Number(e)}`;return typeof t.size==`number`?(y(n,{size:t.size}),g(n,{size:t.size})):n}function b(e,t={}){let n=``;for(let t=0;t<e.length;t++)n+=ue[e[t]];let r=`0x${n}`;return typeof t.size==`number`?(y(r,{size:t.size}),g(r,{dir:`right`,size:t.size})):r}function ce(e,t={}){let{signed:n,size:r}=t,i=BigInt(e),a;r?a=n?(1n<<BigInt(r)*8n-1n)-1n:2n**(BigInt(r)*8n)-1n:typeof e==`number`&&(a=BigInt(2**53-1));let o=typeof a==`bigint`&&n?-a-1n:0;if(a&&i>a||i<o){let t=typeof e==`bigint`?`n`:``;throw new _({max:a?`${a}${t}`:void 0,min:`${o}${t}`,signed:n,size:r,value:`${e}${t}`})}let s=`0x${(n&&i<0?(1n<<BigInt(r*8))+BigInt(i):i).toString(16)}`;return r?g(s,{size:r}):s}function le(e,t={}){return b(de.encode(e),t)}var ue,de;function fe(e,t={}){return typeof e==`number`||typeof e==`bigint`?he(e,t):typeof e==`boolean`?pe(e,t):a(e)?x(e,t):ge(e,t)}function pe(e,t={}){let n=new Uint8Array(1);return n[0]=Number(e),typeof t.size==`number`?(y(n,{size:t.size}),g(n,{size:t.size})):n}function me(e){if(e>=S.zero&&e<=S.nine)return e-S.zero;if(e>=S.A&&e<=S.F)return e-(S.A-10);if(e>=S.a&&e<=S.f)return e-(S.a-10)}function x(e,t={}){let n=e;t.size&&(y(n,{size:t.size}),n=g(n,{dir:`right`,size:t.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);let i=r.length/2,a=new Uint8Array(i);for(let e=0,t=0;e<i;e++){let n=me(r.charCodeAt(t++)),i=me(r.charCodeAt(t++));if(n===void 0||i===void 0)throw new f(`Invalid byte sequence ("${r[t-2]}${r[t-1]}" in "${r}").`);a[e]=n*16+i}return a}function he(e,t){return x(ce(e,t))}function ge(e,t={}){let n=_e.encode(e);return typeof t.size==`number`?(y(n,{size:t.size}),g(n,{dir:`right`,size:t.size})):n}var _e,S,ve,ye;function be(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function xe(e,...t){if(!be(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function Se(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Ce(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}var we,Te;function C(e,t){let n=t||`hex`,r=Te(a(e,{strict:!1})?fe(e):e);return n===`bytes`?r:oe(r)}var w;function Ee(e,t){if(T.has(`${e}.${t}`))return T.get(`${e}.${t}`);let n=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),r=C(ge(n),`bytes`),i=(t?n.substring(`${t}0x`.length):n).split(``);for(let e=0;e<40;e+=2)r[e>>1]>>4>=8&&i[e]&&(i[e]=i[e].toUpperCase()),(r[e>>1]&15)>=8&&i[e+1]&&(i[e+1]=i[e+1].toUpperCase());let a=`0x${i.join(``)}`;return T.set(`${e}.${t}`,a),a}var T;function E(e,t){let{strict:n=!0}=t??{},r=`${e}.${n}`;if(D.has(r))return D.get(r);let i=De.test(e)?e.toLowerCase()===e?!0:n?Ee(e)===e:!0:!1;return D.set(r,i),i}var De,D;function Oe(e,t){if(!E(e,{strict:!1}))throw new w({address:e});if(!E(t,{strict:!1}))throw new w({address:t});return e.toLowerCase()===t.toLowerCase()}let O=256,k;function ke(e=11){if(!k||O+e>256*2){k=``,O=0;for(let e=0;e<256;e++)k+=(256+Math.random()*256|0).toString(16).substring(1)}return k.substring(O,O+++e)}function A({domain:e}={}){return C(oe((e??window.location.host).replace(`www.`,``)))}let j=`frak-client-id`;function M(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function N(){if(typeof window>`u`||!window.localStorage)return M();let e=localStorage.getItem(j);return e||(e=M(),localStorage.setItem(j,e)),e}let P={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603,serverError:-32e3,clientNotConnected:-32001,configError:-32002,corruptedResponse:-32003,clientAborted:-32004,walletNotConnected:-32005,serverErrorForInteractionDelegation:-32006,userRejected:-32007};var F=class extends Error{constructor(e,t,n){super(t),this.code=e,this.data=n}toJSON(){return{code:this.code,message:this.message,data:this.data}}},I=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve=e=>{this._resolve?.(e)};reject=e=>{this._reject?.(e)}};function Ae(e){let{emittingTransport:t,listeningTransport:n,targetOrigin:r,middleware:i=[],lifecycleHandlers:a}=e,o=new Map;function s(e){return typeof e!=`object`||!e?!1:`clientLifecycle`in e||`iframeLifecycle`in e}function c(e){return typeof e!=`object`||!e?!1:`id`in e&&`topic`in e&&`data`in e}async function l(e){try{`clientLifecycle`in e&&a?.clientLifecycle?await a.clientLifecycle(e,{origin:r,source:null}):`iframeLifecycle`in e&&a?.iframeLifecycle&&await a.iframeLifecycle(e,{origin:r,source:null})}catch(e){console.error(`[RPC Client] Lifecycle handler error:`,e)}}async function ee(e){let t={origin:r,source:null};for(let n of i)n.onRequest&&await n.onRequest(e,t);return e}async function u(e,t){let n={origin:r,source:null},a=t;for(let t of i)t.onResponse&&(a=await t.onResponse(e,a,n));return a}async function d(e){try{let t=new URL(e.origin).origin.toLowerCase(),n=new URL(r).origin.toLowerCase();if(t!==n){console.log(`Not expected origin`,t,n);return}}catch(e){console.error(`[RPC Client] Invalid origin`,e);return}if(s(e.data)){await l(e.data);return}if(!c(e.data))return;let t;try{let n=e.data.data,r=n instanceof Uint8Array||ArrayBuffer.isView(n)?{result:n}:n;t=await u(e.data,r)}catch(e){console.error(`[RPC Client] Middleware error on response:`,e);return}let n=o.get(e.data.id);n&&n(t)}async function f(e){let n=e;try{n=await ee(e)}catch(e){throw console.error(`[RPC Client] Middleware error on request:`,e),e}t.postMessage(n,r)}function p(e){t.postMessage(e,r)}function m(){return`${Date.now()}-${Math.random().toString(36).substring(2,9)}`}n.addEventListener(`message`,d);function h(e){let t=m(),n=new I;return o.set(t,e=>{e.error?n.reject(new F(e.error.code,e.error.message,e.error.data)):n.resolve(e.result),o.delete(t)}),f({id:t,topic:e.method,data:{method:e.method,params:e.params}}).catch(e=>{o.delete(t),n.reject(e)}),n.promise}function g(e,t){let n=m();return o.set(n,e=>{e.error?(console.error(`[RPC Client] Listener error:`,e.error),o.delete(n)):t(e.result)}),f({id:n,topic:e.method,data:{method:e.method,params:e.params}}).catch(e=>{console.error(`[RPC Client] Failed to send listener request:`,e),o.delete(n)}),()=>{o.delete(n)}}function te(){n.removeEventListener(`message`,d),o.clear()}return{request:h,listen:g,sendLifecycle:p,cleanup:te}}function je(e){return new TextEncoder().encode(JSON.stringify(e))}function Me(e){try{return JSON.parse(new TextDecoder().decode(e))}catch{return null}}function L(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function R(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(e.length+(t===0?0:4-t),`=`)),e=>e.charCodeAt(0))}function Ne(e){return L(je(e))}function Pe(e,t,n,r,i,a){let o=Ne(Fe({redirectUrl:t.redirectUrl,directExit:t.directExit,lang:t.lang,merchantId:n,metadata:{name:r,css:i,logoUrl:t.metadata?.logoUrl,homepageLink:t.metadata?.homepageLink},clientId:a??N()})),s=new URL(e);return s.pathname=`/sso`,s.searchParams.set(`p`,o),s.toString()}function Fe(e){return{r:e.redirectUrl,cId:e.clientId,d:e.directExit,l:e.lang,m:e.merchantId,md:{n:e.metadata?.name,css:e.metadata?.css,l:e.metadata?.logoUrl,h:e.metadata?.homepageLink}}}let Ie=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,Le=`frak-sso`;async function Re(e,t){let{metadata:n,customizations:r,walletUrl:i}=e.config;if(t.openInSameWindow??!!t.redirectUrl)return await e.request({method:`frak_openSso`,params:[t,n.name,r?.css]});let a=t.ssoPopupUrl??Pe(i??`https://wallet.frak.id`,t,A(),n.name,r?.css),o=window.open(a,Le,Ie);if(!o)throw Error(`Popup was blocked. Please allow popups for this site.`);return o.focus(),await e.request({method:`frak_openSso`,params:[t,n.name,r?.css]})??{}}async function ze(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}let Be=`https://backend.frak.id`;function Ve(e){return e.includes(`localhost:3000`)||e.includes(`localhost:3010`)}function He(e){return Ve(e)?`http://localhost:3030`:e.includes(`wallet-dev.frak.id`)||e.includes(`wallet.gcp-dev.frak.id`)?`https://backend.gcp-dev.frak.id`:Be}function z(e){if(e)return He(e);if(typeof window<`u`){let e=window.FrakSetup?.client?.config?.walletUrl;if(e)return He(e)}return Be}function Ue(e){return Me(R(e))}let B=`nexus-wallet-backup`,We=`frakwallet://`;function Ge(){let e=navigator.userAgent;return/Android/i.test(e)&&/Chrome\/\d+/i.test(e)}function Ke(e){return`intent://${e.slice(13)}#Intent;scheme=frakwallet;end`}function qe(e,t){let n=t?.timeout??2500,r=!1,i=()=>{document.hidden&&(r=!0)};document.addEventListener(`visibilitychange`,i);let a=Ge()&&V(e)?Ke(e):e;window.location.href=a,setTimeout(()=>{document.removeEventListener(`visibilitychange`,i),r||t?.onFallback?.()},n)}function V(e){return e.startsWith(We)}let H=`fCtx`;function Je(e){if(e?.r)try{return L(x(e.r))}catch(t){console.error(`Error compressing Frak context`,{e:t,context:e})}}function Ye(e){if(!(!e||e.length===0))try{return{r:b(R(e),{size:20})}}catch(t){console.error(`Error decompressing Frak context`,{e:t,context:e})}}function Xe({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(H);return t?Ye(t):null}function Ze({url:e,context:t}){if(!e)return null;let n=Xe({url:e}),r=n?{...n,...t}:t;if(!r.r)return null;let i=Je(r);if(!i)return null;let a=new URL(e);return a.searchParams.set(H,i),a.toString()}function Qe(e){let t=new URL(e);return t.searchParams.delete(H),t.toString()}function $e({url:e,context:t}){if(!window.location?.href||typeof window>`u`){console.error(`No window found, can't update context`);return}let n=e??window.location.href,r;r=t===null?Qe(n):Ze({url:n,context:t}),r&&window.history.replaceState(null,``,r.toString())}let U={compress:Je,decompress:Ye,parse:Xe,update:Ze,remove:Qe,replaceUrl:$e},W={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function G(e){return e&&e in W?e:`eur`}function et(e){return e?W[e]??W.eur:W.eur}function tt(e,t){let n=et(t),r=G(t);return e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function nt(e){return e?`${e}Amount`:`eurAmount`}let K={id:`frak-wallet`,name:`frak-wallet`,title:`Frak Wallet`,allow:`publickey-credentials-get *; clipboard-write; web-share *`,style:{width:`0`,height:`0`,border:`0`,position:`absolute`,zIndex:2000001,top:`-1000px`,left:`-1000px`,colorScheme:`auto`}};function rt({walletBaseUrl:e,config:t}){let n=document.querySelector(`#frak-wallet`);n&&n.remove();let r=document.createElement(`iframe`);return r.id=K.id,r.name=K.name,r.allow=K.allow,r.style.zIndex=K.style.zIndex.toString(),it({iframe:r,isVisible:!1}),r.src=`${t?.walletUrl??e??`https://wallet.frak.id`}/listener`,new Promise(e=>{r.addEventListener(`load`,()=>e(r)),document.body.appendChild(r)})}function it({iframe:e,isVisible:t}){if(!t){e.style.width=`0`,e.style.height=`0`,e.style.border=`0`,e.style.position=`fixed`,e.style.top=`-1000px`,e.style.left=`-1000px`;return}e.style.position=`fixed`,e.style.top=`0`,e.style.left=`0`,e.style.width=`100%`,e.style.height=`100%`,e.style.pointerEvents=`auto`}function at(e=`/listener`){if(!window.opener)return null;let t=t=>{try{return t.location.origin===window.location.origin&&t.location.pathname===e}catch{return!1}};if(t(window.opener))return window.opener;try{let e=window.opener.frames;for(let n=0;n<e.length;n++)if(t(e[n]))return e[n];return null}catch(t){return console.error(`[findIframeInOpener] Error finding iframe with pathname ${e}:`,t),null}}let q=`frak-merchant-id`,J,Y;async function X(e,t){if(J)return J;if(typeof window<`u`){let e=window.sessionStorage.getItem(q);if(e)return J=e,e}if(Y)return Y;Y=ot(e,t);let n=await Y;return Y=void 0,n}async function ot(e,t){let n=e??(typeof window<`u`?window.location.hostname:``);if(n)try{let e=z(t),r=await fetch(`${e}/user/merchant/resolve?domain=${encodeURIComponent(n)}`);if(!r.ok){console.warn(`[Frak SDK] Merchant lookup failed for domain ${n}: ${r.status}`);return}let i=await r.json();return J=i.merchantId,typeof window<`u`&&window.sessionStorage.setItem(q,i.merchantId),J}catch(e){console.warn(`[Frak SDK] Failed to fetch merchantId:`,e);return}}function st(){J=void 0,Y=void 0,typeof window<`u`&&window.sessionStorage.removeItem(q)}async function ct(e,t){return e.metadata?.merchantId?e.metadata.merchantId:X(void 0,t)}function Z(e,t,n={}){if(!e){console.debug(`[Frak] No client provided, skipping event tracking`);return}try{e.openPanel?.track(t,n)}catch(e){console.debug(`[Frak] Failed to track event:`,t,e)}}async function lt(e,t){try{await e.request({method:`frak_sendInteraction`,params:[t]})}catch{console.warn(`[Frak SDK] Failed to send interaction:`,t.type)}}async function ut(e,{walletStatus:t,frakContext:n,modalConfig:r,options:i}){if(!n?.r)return`no-referrer`;Z(e,`user_referred_started`,{properties:{referrer:n?.r,walletStatus:t?.key}}),lt(e,{type:`arrival`,referrerWallet:n.r,landingUrl:typeof window<`u`?window.location.href:void 0});let a=!1;async function o(){if(!a)return a=!0,ft(e,{modalConfig:{...r,loggedIn:{action:{key:`referred`}}},walletStatus:t})}try{let{status:r,currentWallet:a}=await dt({initialWalletStatus:t,getFreshWalletStatus:o,frakContext:n});return U.replaceUrl({url:window.location?.href,context:i?.alwaysAppendUrl?{r:a}:null}),Z(e,`user_referred_completed`,{properties:{status:r,referrer:n?.r,wallet:a}}),r}catch(r){return console.log(`Error processing referral`,{error:r}),Z(e,`user_referred_error`,{properties:{referrer:n?.r,error:r instanceof F?`[${r.code}] ${r.name} - ${r.message}`:r instanceof Error?r.message:`undefined`}}),U.replaceUrl({url:window.location?.href,context:i?.alwaysAppendUrl?{r:t?.wallet}:null}),pt(r)}}async function dt({initialWalletStatus:e,getFreshWalletStatus:t,frakContext:n}){let r=e?.wallet;return r||=await t(),r&&Oe(n.r,r)?{status:`self-referral`,currentWallet:r}:{status:`success`,currentWallet:r}}async function ft(e,{modalConfig:t,walletStatus:r}){return r?.key===`connected`?r.wallet??void 0:(await n(e,t??{}))?.wallet??void 0}function pt(e){if(e instanceof F)switch(e.code){case P.walletNotConnected:return`no-wallet`;default:return`error`}return`error`}async function mt(e,{modalConfig:t,options:n}={}){let r=U.parse({url:window.location.href}),i=await gt(e);try{return await ut(e,{walletStatus:i,frakContext:r,modalConfig:t,options:n})}catch(e){console.warn(`Error processing referral`,{error:e})}}async function ht(e){if(typeof window>`u`){console.warn(`[Frak] No window found, can't track purchase`);return}let t=window.sessionStorage.getItem(`frak-wallet-interaction-token`),n=N();if(!t&&!n){console.warn(`[Frak] No identity found, skipping purchase check`);return}let r=window.sessionStorage.getItem(`frak-merchant-id`),i=e.merchantId??r??await X();if(!i){console.warn(`[Frak] No merchant id found, skipping purchase check`);return}let a={Accept:`application/json`,"Content-Type":`application/json`};t&&(a[`x-wallet-sdk-auth`]=t),n&&(a[`x-frak-client-id`]=n);let o=z();await fetch(`${o}/user/track/purchase`,{method:`POST`,headers:a,body:JSON.stringify({customerId:e.customerId,orderId:e.orderId,token:e.token,merchantId:i})})}function gt(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(_t(e,t),t));let n=new I,r=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},i=>{_t(e,i),t(i),r||=(n.resolve(i),!0)}),n.promise}function _t(e,t){typeof window>`u`||(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function vt(e,{metadata:t,login:n}){return Q(e,{steps:{login:n??{}},metadata:t})}function Q(e,t){function n(n){return Q(e,{...t,steps:{...t.steps,sendTransaction:n}})}function i(n){return Q(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}function a(n,r){return Q(e,{...t,steps:{...t.steps,final:{...r,action:{key:`sharing`,options:n}}}})}async function o(n){return n&&(t.metadata=n(t.metadata??{})),await r(e,t)}return{params:t,sendTx:n,reward:i,sharing:a,display:o}}async function yt(e,{tx:t,metadata:n}){return(await r(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}function bt(){return ke(96)}async function xt(e,{siwe:t,metadata:n}){let i=e.config?.domain??window.location.host,a=t?.statement??`I confirm that I want to use my Frak wallet on: ${e.config.metadata.name}`;return(await r(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:a,nonce:t?.nonce??bt(),uri:t?.uri??`https://${i}`,version:t?.version??`1`,domain:i}}}})).siweAuthenticate}var St=class{constructor(e){this.baseUrl=e.baseUrl,this.headers={"Content-Type":`application/json`,...e.defaultHeaders},this.maxRetries=e.maxRetries??3,this.initialRetryDelay=e.initialRetryDelay??500}async resolveHeaders(){let e={};for(let[t,n]of Object.entries(this.headers)){let r=await n;r!==null&&(e[t]=r)}return e}addHeader(e,t){this.headers[e]=t}async post(e,t,n,r){try{let r=await fetch(e,{method:`POST`,headers:await this.resolveHeaders(),body:t?JSON.stringify(t??{}):void 0,keepalive:!0,...n});if(r.status===401)return null;if(r.status!==200&&r.status!==202)throw Error(`HTTP error! status: ${r.status}`);let i=await r.text();return i?JSON.parse(i):null}catch(i){if(r<this.maxRetries){let i=this.initialRetryDelay*2**r;return await new Promise(e=>setTimeout(e,i)),this.post(e,t,n,r+1)}return console.error(`Max retries reached:`,i),null}}async fetch(e,t,n={}){let r=`${this.baseUrl}${e}`;return this.post(r,t,n,0)}},Ct=class{constructor(e){this.options=e,this.queue=[];let t={"openpanel-client-id":e.clientId};e.clientSecret&&(t[`openpanel-client-secret`]=e.clientSecret),t[`openpanel-sdk-name`]=e.sdk||`node`,t[`openpanel-sdk-version`]=e.sdkVersion||`1.0.4`,this.api=new St({baseUrl:e.apiUrl||`https://api.openpanel.dev`,defaultHeaders:t})}init(){}ready(){this.options.waitForProfile=!1,this.flush()}async send(e){return this.options.disabled||this.options.filter&&!this.options.filter(e)?Promise.resolve():this.options.waitForProfile&&!this.profileId?(this.queue.push(e),Promise.resolve()):this.api.fetch(`/track`,e)}setGlobalProperties(e){this.global={...this.global,...e}}async track(e,t){return this.log(`track event`,e,t),this.send({type:`track`,payload:{name:e,profileId:t?.profileId??this.profileId,properties:{...this.global??{},...t??{}}}})}async identify(e){if(this.log(`identify user`,e),e.profileId&&(this.profileId=e.profileId,this.flush()),Object.keys(e).length>1)return this.send({type:`identify`,payload:{...e,properties:{...this.global,...e.properties}}})}async alias(e){}async increment(e){return this.send({type:`increment`,payload:e})}async decrement(e){return this.send({type:`decrement`,payload:e})}async revenue(e,t){let n=t?.deviceId;return delete t?.deviceId,this.track(`revenue`,{...t??{},...n?{__deviceId:n}:{},__revenue:e})}async fetchDeviceId(){return(await this.api.fetch(`/track/device-id`,void 0,{method:`GET`,keepalive:!1}))?.deviceId??``}clear(){this.profileId=void 0}flush(){this.queue.forEach(e=>{this.send({...e,payload:{...e.payload,profileId:e.payload.profileId??this.profileId}})}),this.queue=[]}log(...e){this.options.debug&&console.log(`[OpenPanel.dev]`,...e)}};function wt(e){return e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``))}var Tt=class extends Ct{constructor(e){if(super({sdk:`web`,sdkVersion:`1.0.7`,...e}),this.options=e,this.lastPath=``,this.pendingRevenues=[],!this.isServer()){try{let e=sessionStorage.getItem(`openpanel-pending-revenues`);if(e){let t=JSON.parse(e);Array.isArray(t)&&(this.pendingRevenues=t)}}catch{this.pendingRevenues=[]}this.setGlobalProperties({__referrer:document.referrer}),this.options.trackScreenViews&&(this.trackScreenViews(),setTimeout(()=>this.screenView(),0)),this.options.trackOutgoingLinks&&this.trackOutgoingLinks(),this.options.trackAttributes&&this.trackAttributes()}}debounce(e,t){clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(e,t)}isServer(){return typeof document>`u`}trackOutgoingLinks(){this.isServer()||document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`a`);if(n&&t){let e=n.getAttribute(`href`);if(e?.startsWith(`http`))try{let r=new URL(e),i=window.location.hostname;r.hostname!==i&&super.track(`link_out`,{href:e,text:n.innerText||n.getAttribute(`title`)||t.getAttribute(`alt`)||t.getAttribute(`title`)})}catch{}}})}trackScreenViews(){if(this.isServer())return;let e=history.pushState;history.pushState=function(...t){let n=e.apply(this,t);return window.dispatchEvent(new Event(`pushstate`)),window.dispatchEvent(new Event(`locationchange`)),n};let t=history.replaceState;history.replaceState=function(...e){let n=t.apply(this,e);return window.dispatchEvent(new Event(`replacestate`)),window.dispatchEvent(new Event(`locationchange`)),n},window.addEventListener(`popstate`,()=>{window.dispatchEvent(new Event(`locationchange`))});let n=()=>this.debounce(()=>this.screenView(),50);this.options.trackHashChanges?window.addEventListener(`hashchange`,n):window.addEventListener(`locationchange`,n)}trackAttributes(){this.isServer()||document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`button`),r=t.closest(`a`),i=n?.getAttribute(`data-track`)?n:r?.getAttribute(`data-track`)?r:null;if(i){let e={};for(let t of i.attributes)t.name.startsWith(`data-`)&&t.name!==`data-track`&&(e[wt(t.name.replace(/^data-/,``))]=t.value);let t=i.getAttribute(`data-track`);t&&super.track(t,e)}})}screenView(e,t){if(this.isServer())return;let n,r;typeof e==`string`?(n=e,r=t):(n=window.location.href,r=e),this.lastPath!==n&&(this.lastPath=n,super.track(`screen_view`,{...r??{},__path:n,__title:document.title}))}async flushRevenue(){let e=this.pendingRevenues.map(e=>super.revenue(e.amount,e.properties));await Promise.all(e),this.clearRevenue()}clearRevenue(){if(this.pendingRevenues=[],!this.isServer())try{sessionStorage.removeItem(`openpanel-pending-revenues`)}catch{}}pendingRevenue(e,t){if(this.pendingRevenues.push({amount:e,properties:t}),!this.isServer())try{sessionStorage.setItem(`openpanel-pending-revenues`,JSON.stringify(this.pendingRevenues))}catch{}}};function Et(e,t){if(typeof window>`u`)return;let n=new URL(window.location.href),r=n.searchParams.get(`sso`);r&&(t.then(()=>{e.sendLifecycle({clientLifecycle:`sso-redirect-complete`,data:{compressed:r}}),console.log(`[SSO URL Listener] Forwarded compressed SSO data to iframe`)}).catch(e=>{console.error(`[SSO URL Listener] Failed to forward SSO data:`,e)}),n.searchParams.delete(`sso`),window.history.replaceState({},``,n.toString()),console.log(`[SSO URL Listener] SSO parameter detected and URL cleaned`))}var $=class e{config;iframe;isSetupDone=!1;lastResponse=null;lastRequest=null;constructor(e,t){this.config=e,this.iframe=t,this.lastRequest=null,this.lastResponse=null}setLastResponse(e,t){this.lastResponse={message:e,response:t,timestamp:Date.now()}}setLastRequest(e){this.lastRequest={event:e,timestamp:Date.now()}}updateSetupStatus(e){this.isSetupDone=e}base64Encode(e){try{return btoa(JSON.stringify(e))}catch(e){return console.warn(`Failed to encode debug data`,e),btoa(`Failed to encode data`)}}getIframeStatus(){return this.iframe?{loading:this.iframe.hasAttribute(`loading`),url:this.iframe.src,readyState:this.iframe.contentDocument?.readyState?this.iframe.contentDocument.readyState===`complete`?1:0:-1,contentWindow:!!this.iframe.contentWindow,isConnected:this.iframe.isConnected}:null}getNavigatorInfo(){return navigator?{userAgent:navigator.userAgent,language:navigator.language,onLine:navigator.onLine,screenWidth:window.screen.width,screenHeight:window.screen.height,pixelRatio:window.devicePixelRatio}:null}gatherDebugInfo(e){let t=this.getIframeStatus(),n=this.getNavigatorInfo(),r=`Unknown`;return e instanceof F?r=`FrakRpcError: ${e.code} '${e.message}'`:e instanceof Error?r=e.message:typeof e==`string`&&(r=e),{timestamp:new Date().toISOString(),encodedUrl:btoa(window.location.href),encodedConfig:this.config?this.base64Encode(this.config):`no-config`,navigatorInfo:n?this.base64Encode(n):`no-navigator`,iframeStatus:t?this.base64Encode(t):`not-iframe`,lastRequest:this.lastRequest?this.base64Encode(this.lastRequest):`No Frak request logged`,lastResponse:this.lastResponse?this.base64Encode(this.lastResponse):`No Frak response logged`,clientStatus:this.isSetupDone?`setup`:`not-setup`,error:r}}static empty(){return new e}formatDebugInfo(e){let t=this.gatherDebugInfo(e);return`
1
+ var FrakSDK=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=(e,t)=>()=>(e&&(t=e(e=0)),t);async function n(e,t){return await e.request({method:`frak_displayEmbeddedWallet`,params:[t,e.config.metadata]})}async function r(e,{steps:t,metadata:n}){return await e.request({method:`frak_displayModal`,params:[t,n,e.config.metadata]})}async function i(e){return await e.request({method:`frak_getMerchantInformation`})}function a(e,{strict:t=!0}={}){return!e||typeof e!=`string`?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith(`0x`)}var o=t((()=>{}));function s(e){return a(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}var c=t((()=>{o()})),l,ee=t((()=>{l=`2.46.3`}));function u(e,t){return t?.(e)?e:e&&typeof e==`object`&&`cause`in e&&e.cause!==void 0?u(e.cause,t):t?null:e}var d,f,p=t((()=>{ee(),d={getDocsUrl:({docsBaseUrl:e,docsPath:t=``,docsSlug:n})=>t?`${e??`https://viem.sh`}${t}${n?`#${n}`:``}`:void 0,version:`viem@${l}`},f=class e extends Error{constructor(t,n={}){let r=n.cause instanceof e?n.cause.details:n.cause?.message?n.cause.message:n.details,i=n.cause instanceof e&&n.cause.docsPath||n.docsPath,a=d.getDocsUrl?.({...n,docsPath:i}),o=[t||`An error occurred.`,``,...n.metaMessages?[...n.metaMessages,``]:[],...a?[`Docs: ${a}`]:[],...r?[`Details: ${r}`]:[],...d.version?[`Version: ${d.version}`]:[]].join(`
2
+ `);super(o,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,`details`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,`docsPath`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,`metaMessages`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,`shortMessage`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,`version`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,`name`,{enumerable:!0,configurable:!0,writable:!0,value:`BaseError`}),this.details=r,this.docsPath=i,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=t,this.version=l}walk(e){return u(this,e)}}})),m,h=t((()=>{p(),m=class extends f{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:`SizeExceedsPaddingSizeError`})}}}));function g(e,{dir:t,size:n=32}={}){return typeof e==`string`?te(e,{dir:t,size:n}):ne(e,{dir:t,size:n})}function te(e,{dir:t,size:n=32}={}){if(n===null)return e;let r=e.replace(`0x`,``);if(r.length>n*2)throw new m({size:Math.ceil(r.length/2),targetSize:n,type:`hex`});return`0x${r[t===`right`?`padEnd`:`padStart`](n*2,`0`)}`}function ne(e,{dir:t,size:n=32}={}){if(n===null)return e;if(e.length>n)throw new m({size:e.length,targetSize:n,type:`bytes`});let r=new Uint8Array(n);for(let i=0;i<n;i++){let a=t===`right`;r[a?i:n-i-1]=e[a?i:e.length-i-1]}return r}var re=t((()=>{h()})),_,v,ie=t((()=>{p(),_=class extends f{constructor({max:e,min:t,signed:n,size:r,value:i}){super(`Number "${i}" is not in safe ${r?`${r*8}-bit ${n?`signed`:`unsigned`} `:``}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:`IntegerOutOfRangeError`})}},v=class extends f{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:`SizeOverflowError`})}}}));function y(e,{size:t}){if(s(e)>t)throw new v({givenSize:s(e),maxSize:t})}var ae=t((()=>{ie(),c()}));function oe(e,t={}){return typeof e==`number`||typeof e==`bigint`?ce(e,t):typeof e==`string`?le(e,t):typeof e==`boolean`?se(e,t):b(e,t)}function se(e,t={}){let n=`0x${Number(e)}`;return typeof t.size==`number`?(y(n,{size:t.size}),g(n,{size:t.size})):n}function b(e,t={}){let n=``;for(let t=0;t<e.length;t++)n+=ue[e[t]];let r=`0x${n}`;return typeof t.size==`number`?(y(r,{size:t.size}),g(r,{dir:`right`,size:t.size})):r}function ce(e,t={}){let{signed:n,size:r}=t,i=BigInt(e),a;r?a=n?(1n<<BigInt(r)*8n-1n)-1n:2n**(BigInt(r)*8n)-1n:typeof e==`number`&&(a=BigInt(2**53-1));let o=typeof a==`bigint`&&n?-a-1n:0;if(a&&i>a||i<o){let t=typeof e==`bigint`?`n`:``;throw new _({max:a?`${a}${t}`:void 0,min:`${o}${t}`,signed:n,size:r,value:`${e}${t}`})}let s=`0x${(n&&i<0?(1n<<BigInt(r*8))+BigInt(i):i).toString(16)}`;return r?g(s,{size:r}):s}function le(e,t={}){return b(de.encode(e),t)}var ue,de;function fe(e,t={}){return typeof e==`number`||typeof e==`bigint`?he(e,t):typeof e==`boolean`?pe(e,t):a(e)?x(e,t):ge(e,t)}function pe(e,t={}){let n=new Uint8Array(1);return n[0]=Number(e),typeof t.size==`number`?(y(n,{size:t.size}),g(n,{size:t.size})):n}function me(e){if(e>=S.zero&&e<=S.nine)return e-S.zero;if(e>=S.A&&e<=S.F)return e-(S.A-10);if(e>=S.a&&e<=S.f)return e-(S.a-10)}function x(e,t={}){let n=e;t.size&&(y(n,{size:t.size}),n=g(n,{dir:`right`,size:t.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);let i=r.length/2,a=new Uint8Array(i);for(let e=0,t=0;e<i;e++){let n=me(r.charCodeAt(t++)),i=me(r.charCodeAt(t++));if(n===void 0||i===void 0)throw new f(`Invalid byte sequence ("${r[t-2]}${r[t-1]}" in "${r}").`);a[e]=n*16+i}return a}function he(e,t){return x(ce(e,t))}function ge(e,t={}){let n=_e.encode(e);return typeof t.size==`number`?(y(n,{size:t.size}),g(n,{dir:`right`,size:t.size})):n}var _e,S,ve,ye;function be(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function xe(e,...t){if(!be(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function Se(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Ce(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}var we,Te;function C(e,t){let n=t||`hex`,r=Te(a(e,{strict:!1})?fe(e):e);return n===`bytes`?r:oe(r)}var w;function Ee(e,t){if(T.has(`${e}.${t}`))return T.get(`${e}.${t}`);let n=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),r=C(ge(n),`bytes`),i=(t?n.substring(`${t}0x`.length):n).split(``);for(let e=0;e<40;e+=2)r[e>>1]>>4>=8&&i[e]&&(i[e]=i[e].toUpperCase()),(r[e>>1]&15)>=8&&i[e+1]&&(i[e+1]=i[e+1].toUpperCase());let a=`0x${i.join(``)}`;return T.set(`${e}.${t}`,a),a}var T;function E(e,t){let{strict:n=!0}=t??{},r=`${e}.${n}`;if(D.has(r))return D.get(r);let i=De.test(e)?e.toLowerCase()===e?!0:n?Ee(e)===e:!0:!1;return D.set(r,i),i}var De,D;function Oe(e,t){if(!E(e,{strict:!1}))throw new w({address:e});if(!E(t,{strict:!1}))throw new w({address:t});return e.toLowerCase()===t.toLowerCase()}let O=256,k;function ke(e=11){if(!k||O+e>256*2){k=``,O=0;for(let e=0;e<256;e++)k+=(256+Math.random()*256|0).toString(16).substring(1)}return k.substring(O,O+++e)}function A({domain:e}={}){return C(oe((e??window.location.host).replace(`www.`,``)))}let j=`frak-client-id`;function M(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function N(){if(typeof window>`u`||!window.localStorage)return console.warn(`[Frak SDK] No Window / localStorage available to save the clientId`),M();let e=localStorage.getItem(j);return e||(e=M(),localStorage.setItem(j,e)),e}let P={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603,serverError:-32e3,clientNotConnected:-32001,configError:-32002,corruptedResponse:-32003,clientAborted:-32004,walletNotConnected:-32005,serverErrorForInteractionDelegation:-32006,userRejected:-32007};var F=class extends Error{constructor(e,t,n){super(t),this.code=e,this.data=n}toJSON(){return{code:this.code,message:this.message,data:this.data}}},I=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve=e=>{this._resolve?.(e)};reject=e=>{this._reject?.(e)}};function Ae(e){let{emittingTransport:t,listeningTransport:n,targetOrigin:r,middleware:i=[],lifecycleHandlers:a}=e,o=new Map;function s(e){return typeof e!=`object`||!e?!1:`clientLifecycle`in e||`iframeLifecycle`in e}function c(e){return typeof e!=`object`||!e?!1:`id`in e&&`topic`in e&&`data`in e}async function l(e){try{`clientLifecycle`in e&&a?.clientLifecycle?await a.clientLifecycle(e,{origin:r,source:null}):`iframeLifecycle`in e&&a?.iframeLifecycle&&await a.iframeLifecycle(e,{origin:r,source:null})}catch(e){console.error(`[RPC Client] Lifecycle handler error:`,e)}}async function ee(e){let t={origin:r,source:null};for(let n of i)n.onRequest&&await n.onRequest(e,t);return e}async function u(e,t){let n={origin:r,source:null},a=t;for(let t of i)t.onResponse&&(a=await t.onResponse(e,a,n));return a}async function d(e){try{let t=new URL(e.origin).origin.toLowerCase(),n=new URL(r).origin.toLowerCase();if(t!==n){console.log(`Not expected origin`,t,n);return}}catch(e){console.error(`[RPC Client] Invalid origin`,e);return}if(s(e.data)){await l(e.data);return}if(!c(e.data))return;let t;try{let n=e.data.data,r=n instanceof Uint8Array||ArrayBuffer.isView(n)?{result:n}:n;t=await u(e.data,r)}catch(e){console.error(`[RPC Client] Middleware error on response:`,e);return}let n=o.get(e.data.id);n&&n(t)}async function f(e){let n=e;try{n=await ee(e)}catch(e){throw console.error(`[RPC Client] Middleware error on request:`,e),e}t.postMessage(n,r)}function p(e){t.postMessage(e,r)}function m(){return`${Date.now()}-${Math.random().toString(36).substring(2,9)}`}n.addEventListener(`message`,d);function h(e){let t=m(),n=new I;return o.set(t,e=>{e.error?n.reject(new F(e.error.code,e.error.message,e.error.data)):n.resolve(e.result),o.delete(t)}),f({id:t,topic:e.method,data:{method:e.method,params:e.params}}).catch(e=>{o.delete(t),n.reject(e)}),n.promise}function g(e,t){let n=m();return o.set(n,e=>{e.error?(console.error(`[RPC Client] Listener error:`,e.error),o.delete(n)):t(e.result)}),f({id:n,topic:e.method,data:{method:e.method,params:e.params}}).catch(e=>{console.error(`[RPC Client] Failed to send listener request:`,e),o.delete(n)}),()=>{o.delete(n)}}function te(){n.removeEventListener(`message`,d),o.clear()}return{request:h,listen:g,sendLifecycle:p,cleanup:te}}function je(e){return new TextEncoder().encode(JSON.stringify(e))}function Me(e){try{return JSON.parse(new TextDecoder().decode(e))}catch{return null}}function L(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function R(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(e.length+(t===0?0:4-t),`=`)),e=>e.charCodeAt(0))}function z(e){return L(je(e))}function Ne(e,t,n,r,i,a){let o=z(Pe({redirectUrl:t.redirectUrl,directExit:t.directExit,lang:t.lang,merchantId:n,metadata:{name:r,css:i,logoUrl:t.metadata?.logoUrl,homepageLink:t.metadata?.homepageLink},clientId:a??N()})),s=new URL(e);return s.pathname=`/sso`,s.searchParams.set(`p`,o),s.toString()}function Pe(e){return{r:e.redirectUrl,cId:e.clientId,d:e.directExit,l:e.lang,m:e.merchantId,md:{n:e.metadata?.name,css:e.metadata?.css,l:e.metadata?.logoUrl,h:e.metadata?.homepageLink}}}let Fe=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,Ie=`frak-sso`;async function Le(e,t){let{metadata:n,customizations:r,walletUrl:i}=e.config;if(t.openInSameWindow??!!t.redirectUrl)return await e.request({method:`frak_openSso`,params:[t,n.name,r?.css]});let a=t.ssoPopupUrl??Ne(i??`https://wallet.frak.id`,t,A(),n.name,r?.css),o=window.open(a,Ie,Fe);if(!o)throw Error(`Popup was blocked. Please allow popups for this site.`);return o.focus(),await e.request({method:`frak_openSso`,params:[t,n.name,r?.css]})??{}}async function Re(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}let ze=`https://backend.frak.id`;function Be(e){return e.includes(`localhost:3000`)||e.includes(`localhost:3010`)}function Ve(e){return Be(e)?`http://localhost:3030`:e.includes(`wallet-dev.frak.id`)||e.includes(`wallet.gcp-dev.frak.id`)?`https://backend.gcp-dev.frak.id`:ze}function B(e){if(e)return Ve(e);if(typeof window<`u`){let e=window.FrakSetup?.client?.config?.walletUrl;if(e)return Ve(e)}return ze}function He(e){return Me(R(e))}let V=`nexus-wallet-backup`,Ue=`frakwallet://`;function We(){let e=navigator.userAgent;return/Android/i.test(e)&&/Chrome\/\d+/i.test(e)}function Ge(e){return`intent://${e.slice(13)}#Intent;scheme=frakwallet;end`}function Ke(e,t){let n=t?.timeout??2500,r=!1,i=()=>{document.hidden&&(r=!0)};document.addEventListener(`visibilitychange`,i);let a=We()&&H(e)?Ge(e):e;window.location.href=a,setTimeout(()=>{document.removeEventListener(`visibilitychange`,i),r||t?.onFallback?.()},n)}function H(e){return e.startsWith(Ue)}let U=`fCtx`;function qe(e){if(e?.r)try{return L(x(e.r))}catch(t){console.error(`Error compressing Frak context`,{e:t,context:e})}}function Je(e){if(!(!e||e.length===0))try{return{r:b(R(e),{size:20})}}catch(t){console.error(`Error decompressing Frak context`,{e:t,context:e})}}function Ye({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(U);return t?Je(t):null}function Xe({url:e,context:t}){if(!e)return null;let n=Ye({url:e}),r=n?{...n,...t}:t;if(!r.r)return null;let i=qe(r);if(!i)return null;let a=new URL(e);return a.searchParams.set(U,i),a.toString()}function Ze(e){let t=new URL(e);return t.searchParams.delete(U),t.toString()}function Qe({url:e,context:t}){if(!window.location?.href||typeof window>`u`){console.error(`No window found, can't update context`);return}let n=e??window.location.href,r;r=t===null?Ze(n):Xe({url:n,context:t}),r&&window.history.replaceState(null,``,r.toString())}let W={compress:qe,decompress:Je,parse:Ye,update:Xe,remove:Ze,replaceUrl:Qe},G={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function K(e){return e&&e in G?e:`eur`}function $e(e){return e?G[e]??G.eur:G.eur}function et(e,t){let n=$e(t),r=K(t);return e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function tt(e){return e?`${e}Amount`:`eurAmount`}let q={id:`frak-wallet`,name:`frak-wallet`,title:`Frak Wallet`,allow:`publickey-credentials-get *; clipboard-write; web-share *`,style:{width:`0`,height:`0`,border:`0`,position:`absolute`,zIndex:2000001,top:`-1000px`,left:`-1000px`,colorScheme:`auto`}};function nt({walletBaseUrl:e,config:t}){let n=document.querySelector(`#frak-wallet`);n&&n.remove();let r=document.createElement(`iframe`);return r.id=q.id,r.name=q.name,r.allow=q.allow,r.style.zIndex=q.style.zIndex.toString(),rt({iframe:r,isVisible:!1}),r.src=`${t?.walletUrl??e??`https://wallet.frak.id`}/listener`,new Promise(e=>{r.addEventListener(`load`,()=>e(r)),document.body.appendChild(r)})}function rt({iframe:e,isVisible:t}){if(!t){e.style.width=`0`,e.style.height=`0`,e.style.border=`0`,e.style.position=`fixed`,e.style.top=`-1000px`,e.style.left=`-1000px`;return}e.style.position=`fixed`,e.style.top=`0`,e.style.left=`0`,e.style.width=`100%`,e.style.height=`100%`,e.style.pointerEvents=`auto`}function it(e=`/listener`){if(!window.opener)return null;let t=t=>{try{return t.location.origin===window.location.origin&&t.location.pathname===e}catch{return!1}};if(t(window.opener))return window.opener;try{let e=window.opener.frames;for(let n=0;n<e.length;n++)if(t(e[n]))return e[n];return null}catch(t){return console.error(`[findIframeInOpener] Error finding iframe with pathname ${e}:`,t),null}}let J=`frak-merchant-id`,Y,X;async function Z(e,t){if(Y)return Y;if(typeof window<`u`){let e=window.sessionStorage.getItem(J);if(e)return Y=e,e}if(X)return X;X=at(e,t);let n=await X;return X=void 0,n}async function at(e,t){let n=e??(typeof window<`u`?window.location.hostname:``);if(n)try{let e=B(t),r=await fetch(`${e}/user/merchant/resolve?domain=${encodeURIComponent(n)}`);if(!r.ok){console.warn(`[Frak SDK] Merchant lookup failed for domain ${n}: ${r.status}`);return}let i=await r.json();return Y=i.merchantId,typeof window<`u`&&window.sessionStorage.setItem(J,i.merchantId),Y}catch(e){console.warn(`[Frak SDK] Failed to fetch merchantId:`,e);return}}function ot(){Y=void 0,X=void 0,typeof window<`u`&&window.sessionStorage.removeItem(J)}async function st(e,t){return e.metadata?.merchantId?e.metadata.merchantId:Z(void 0,t)}function Q(e,t,n={}){if(!e){console.debug(`[Frak] No client provided, skipping event tracking`);return}try{e.openPanel?.track(t,n)}catch(e){console.debug(`[Frak] Failed to track event:`,t,e)}}async function ct(e,t){try{await e.request({method:`frak_sendInteraction`,params:[t,{clientId:N()}]})}catch{console.warn(`[Frak SDK] Failed to send interaction:`,t.type)}}async function lt(e,{walletStatus:t,frakContext:n,modalConfig:r,options:i}){if(!n?.r)return`no-referrer`;Q(e,`user_referred_started`,{properties:{referrer:n?.r,walletStatus:t?.key}}),ct(e,{type:`arrival`,referrerWallet:n.r,landingUrl:typeof window<`u`?window.location.href:void 0});let a=!1;async function o(){if(!a)return a=!0,dt(e,{modalConfig:{...r,loggedIn:{action:{key:`referred`}}},walletStatus:t})}try{let{status:r,currentWallet:a}=await ut({initialWalletStatus:t,getFreshWalletStatus:o,frakContext:n});return W.replaceUrl({url:window.location?.href,context:i?.alwaysAppendUrl?{r:a}:null}),Q(e,`user_referred_completed`,{properties:{status:r,referrer:n?.r,wallet:a}}),r}catch(r){return console.log(`Error processing referral`,{error:r}),Q(e,`user_referred_error`,{properties:{referrer:n?.r,error:r instanceof F?`[${r.code}] ${r.name} - ${r.message}`:r instanceof Error?r.message:`undefined`}}),W.replaceUrl({url:window.location?.href,context:i?.alwaysAppendUrl?{r:t?.wallet}:null}),ft(r)}}async function ut({initialWalletStatus:e,getFreshWalletStatus:t,frakContext:n}){let r=e?.wallet;return r||=await t(),r&&Oe(n.r,r)?{status:`self-referral`,currentWallet:r}:{status:`success`,currentWallet:r}}async function dt(e,{modalConfig:t,walletStatus:r}){return r?.key===`connected`?r.wallet??void 0:(await n(e,t??{}))?.wallet??void 0}function ft(e){if(e instanceof F)switch(e.code){case P.walletNotConnected:return`no-wallet`;default:return`error`}return`error`}async function pt(e,{modalConfig:t,options:n}={}){let r=W.parse({url:window.location.href}),i=await ht(e);try{return await lt(e,{walletStatus:i,frakContext:r,modalConfig:t,options:n})}catch(e){console.warn(`Error processing referral`,{error:e})}}async function mt(e){if(typeof window>`u`){console.warn(`[Frak] No window found, can't track purchase`);return}let t=window.sessionStorage.getItem(`frak-wallet-interaction-token`),n=N();if(!t&&!n){console.warn(`[Frak] No identity found, skipping purchase check`);return}let r=window.sessionStorage.getItem(`frak-merchant-id`),i=e.merchantId??r??await Z();if(!i){console.warn(`[Frak] No merchant id found, skipping purchase check`);return}let a={Accept:`application/json`,"Content-Type":`application/json`};t&&(a[`x-wallet-sdk-auth`]=t),n&&(a[`x-frak-client-id`]=n);let o=B();await fetch(`${o}/user/track/purchase`,{method:`POST`,headers:a,body:JSON.stringify({customerId:e.customerId,orderId:e.orderId,token:e.token,merchantId:i})})}function ht(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(gt(e,t),t));let n=new I,r=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},i=>{gt(e,i),t(i),r||=(n.resolve(i),!0)}),n.promise}function gt(e,t){typeof window>`u`||(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function _t(e,{metadata:t,login:n}){return $(e,{steps:{login:n??{}},metadata:t})}function $(e,t){function n(n){return $(e,{...t,steps:{...t.steps,sendTransaction:n}})}function i(n){return $(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}function a(n,r){return $(e,{...t,steps:{...t.steps,final:{...r,action:{key:`sharing`,options:n}}}})}async function o(n){return n&&(t.metadata=n(t.metadata??{})),await r(e,t)}return{params:t,sendTx:n,reward:i,sharing:a,display:o}}async function vt(e,{tx:t,metadata:n}){return(await r(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}function yt(){return ke(96)}async function bt(e,{siwe:t,metadata:n}){let i=e.config?.domain??window.location.host,a=t?.statement??`I confirm that I want to use my Frak wallet on: ${e.config.metadata.name}`;return(await r(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:a,nonce:t?.nonce??yt(),uri:t?.uri??`https://${i}`,version:t?.version??`1`,domain:i}}}})).siweAuthenticate}var xt=class{constructor(e){this.baseUrl=e.baseUrl,this.headers={"Content-Type":`application/json`,...e.defaultHeaders},this.maxRetries=e.maxRetries??3,this.initialRetryDelay=e.initialRetryDelay??500}async resolveHeaders(){let e={};for(let[t,n]of Object.entries(this.headers)){let r=await n;r!==null&&(e[t]=r)}return e}addHeader(e,t){this.headers[e]=t}async post(e,t,n,r){try{let r=await fetch(e,{method:`POST`,headers:await this.resolveHeaders(),body:t?JSON.stringify(t??{}):void 0,keepalive:!0,...n});if(r.status===401)return null;if(r.status!==200&&r.status!==202)throw Error(`HTTP error! status: ${r.status}`);let i=await r.text();return i?JSON.parse(i):null}catch(i){if(r<this.maxRetries){let i=this.initialRetryDelay*2**r;return await new Promise(e=>setTimeout(e,i)),this.post(e,t,n,r+1)}return console.error(`Max retries reached:`,i),null}}async fetch(e,t,n={}){let r=`${this.baseUrl}${e}`;return this.post(r,t,n,0)}},St=class{constructor(e){this.options=e,this.queue=[];let t={"openpanel-client-id":e.clientId};e.clientSecret&&(t[`openpanel-client-secret`]=e.clientSecret),t[`openpanel-sdk-name`]=e.sdk||`node`,t[`openpanel-sdk-version`]=e.sdkVersion||`1.0.4`,this.api=new xt({baseUrl:e.apiUrl||`https://api.openpanel.dev`,defaultHeaders:t})}init(){}ready(){this.options.waitForProfile=!1,this.flush()}async send(e){return this.options.disabled||this.options.filter&&!this.options.filter(e)?Promise.resolve():this.options.waitForProfile&&!this.profileId?(this.queue.push(e),Promise.resolve()):this.api.fetch(`/track`,e)}setGlobalProperties(e){this.global={...this.global,...e}}async track(e,t){return this.log(`track event`,e,t),this.send({type:`track`,payload:{name:e,profileId:t?.profileId??this.profileId,properties:{...this.global??{},...t??{}}}})}async identify(e){if(this.log(`identify user`,e),e.profileId&&(this.profileId=e.profileId,this.flush()),Object.keys(e).length>1)return this.send({type:`identify`,payload:{...e,properties:{...this.global,...e.properties}}})}async alias(e){}async increment(e){return this.send({type:`increment`,payload:e})}async decrement(e){return this.send({type:`decrement`,payload:e})}async revenue(e,t){let n=t?.deviceId;return delete t?.deviceId,this.track(`revenue`,{...t??{},...n?{__deviceId:n}:{},__revenue:e})}async fetchDeviceId(){return(await this.api.fetch(`/track/device-id`,void 0,{method:`GET`,keepalive:!1}))?.deviceId??``}clear(){this.profileId=void 0}flush(){this.queue.forEach(e=>{this.send({...e,payload:{...e.payload,profileId:e.payload.profileId??this.profileId}})}),this.queue=[]}log(...e){this.options.debug&&console.log(`[OpenPanel.dev]`,...e)}};function Ct(e){return e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``))}var wt=class extends St{constructor(e){if(super({sdk:`web`,sdkVersion:`1.0.7`,...e}),this.options=e,this.lastPath=``,this.pendingRevenues=[],!this.isServer()){try{let e=sessionStorage.getItem(`openpanel-pending-revenues`);if(e){let t=JSON.parse(e);Array.isArray(t)&&(this.pendingRevenues=t)}}catch{this.pendingRevenues=[]}this.setGlobalProperties({__referrer:document.referrer}),this.options.trackScreenViews&&(this.trackScreenViews(),setTimeout(()=>this.screenView(),0)),this.options.trackOutgoingLinks&&this.trackOutgoingLinks(),this.options.trackAttributes&&this.trackAttributes()}}debounce(e,t){clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(e,t)}isServer(){return typeof document>`u`}trackOutgoingLinks(){this.isServer()||document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`a`);if(n&&t){let e=n.getAttribute(`href`);if(e?.startsWith(`http`))try{let r=new URL(e),i=window.location.hostname;r.hostname!==i&&super.track(`link_out`,{href:e,text:n.innerText||n.getAttribute(`title`)||t.getAttribute(`alt`)||t.getAttribute(`title`)})}catch{}}})}trackScreenViews(){if(this.isServer())return;let e=history.pushState;history.pushState=function(...t){let n=e.apply(this,t);return window.dispatchEvent(new Event(`pushstate`)),window.dispatchEvent(new Event(`locationchange`)),n};let t=history.replaceState;history.replaceState=function(...e){let n=t.apply(this,e);return window.dispatchEvent(new Event(`replacestate`)),window.dispatchEvent(new Event(`locationchange`)),n},window.addEventListener(`popstate`,()=>{window.dispatchEvent(new Event(`locationchange`))});let n=()=>this.debounce(()=>this.screenView(),50);this.options.trackHashChanges?window.addEventListener(`hashchange`,n):window.addEventListener(`locationchange`,n)}trackAttributes(){this.isServer()||document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`button`),r=t.closest(`a`),i=n?.getAttribute(`data-track`)?n:r?.getAttribute(`data-track`)?r:null;if(i){let e={};for(let t of i.attributes)t.name.startsWith(`data-`)&&t.name!==`data-track`&&(e[Ct(t.name.replace(/^data-/,``))]=t.value);let t=i.getAttribute(`data-track`);t&&super.track(t,e)}})}screenView(e,t){if(this.isServer())return;let n,r;typeof e==`string`?(n=e,r=t):(n=window.location.href,r=e),this.lastPath!==n&&(this.lastPath=n,super.track(`screen_view`,{...r??{},__path:n,__title:document.title}))}async flushRevenue(){let e=this.pendingRevenues.map(e=>super.revenue(e.amount,e.properties));await Promise.all(e),this.clearRevenue()}clearRevenue(){if(this.pendingRevenues=[],!this.isServer())try{sessionStorage.removeItem(`openpanel-pending-revenues`)}catch{}}pendingRevenue(e,t){if(this.pendingRevenues.push({amount:e,properties:t}),!this.isServer())try{sessionStorage.setItem(`openpanel-pending-revenues`,JSON.stringify(this.pendingRevenues))}catch{}}};function Tt(e,t){if(typeof window>`u`)return;let n=new URL(window.location.href),r=n.searchParams.get(`sso`);r&&(t.then(()=>{e.sendLifecycle({clientLifecycle:`sso-redirect-complete`,data:{compressed:r}}),console.log(`[SSO URL Listener] Forwarded compressed SSO data to iframe`)}).catch(e=>{console.error(`[SSO URL Listener] Failed to forward SSO data:`,e)}),n.searchParams.delete(`sso`),window.history.replaceState({},``,n.toString()),console.log(`[SSO URL Listener] SSO parameter detected and URL cleaned`))}var Et=class e{config;iframe;isSetupDone=!1;lastResponse=null;lastRequest=null;constructor(e,t){this.config=e,this.iframe=t,this.lastRequest=null,this.lastResponse=null}setLastResponse(e,t){this.lastResponse={message:e,response:t,timestamp:Date.now()}}setLastRequest(e){this.lastRequest={event:e,timestamp:Date.now()}}updateSetupStatus(e){this.isSetupDone=e}base64Encode(e){try{return btoa(JSON.stringify(e))}catch(e){return console.warn(`Failed to encode debug data`,e),btoa(`Failed to encode data`)}}getIframeStatus(){return this.iframe?{loading:this.iframe.hasAttribute(`loading`),url:this.iframe.src,readyState:this.iframe.contentDocument?.readyState?this.iframe.contentDocument.readyState===`complete`?1:0:-1,contentWindow:!!this.iframe.contentWindow,isConnected:this.iframe.isConnected}:null}getNavigatorInfo(){return navigator?{userAgent:navigator.userAgent,language:navigator.language,onLine:navigator.onLine,screenWidth:window.screen.width,screenHeight:window.screen.height,pixelRatio:window.devicePixelRatio}:null}gatherDebugInfo(e){let t=this.getIframeStatus(),n=this.getNavigatorInfo(),r=`Unknown`;return e instanceof F?r=`FrakRpcError: ${e.code} '${e.message}'`:e instanceof Error?r=e.message:typeof e==`string`&&(r=e),{timestamp:new Date().toISOString(),encodedUrl:btoa(window.location.href),encodedConfig:this.config?this.base64Encode(this.config):`no-config`,navigatorInfo:n?this.base64Encode(n):`no-navigator`,iframeStatus:t?this.base64Encode(t):`not-iframe`,lastRequest:this.lastRequest?this.base64Encode(this.lastRequest):`No Frak request logged`,lastResponse:this.lastResponse?this.base64Encode(this.lastResponse):`No Frak response logged`,clientStatus:this.isSetupDone?`setup`:`not-setup`,error:r}}static empty(){return new e}formatDebugInfo(e){let t=this.gatherDebugInfo(e);return`
3
3
  Debug Information:
4
4
  -----------------
5
5
  Timestamp: ${t.timestamp}
@@ -11,4 +11,4 @@ var FrakSDK=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Modu
11
11
  Last Response: ${t.lastResponse}
12
12
  Client Status: ${t.clientStatus}
13
13
  Error: ${t.error}
14
- `.trim()}};function Dt(e){e?localStorage.setItem(B,e):localStorage.removeItem(B)}function Ot(e,t,n,r){let i=new URL(window.location.href),a=i.searchParams.get(`fmt`)??void 0;e.contentWindow?.postMessage({clientLifecycle:`handshake-response`,data:{token:t,currentUrl:window.location.href,clientId:N(),pendingMergeToken:a,configDomain:r}},n),a&&(i.searchParams.delete(`fmt`),window.history.replaceState({},``,i.toString()))}function kt(e,t){try{let n=new URL(e);return n.searchParams.has(`u`)?(n.searchParams.delete(`u`),n.searchParams.append(`u`,window.location.href),t&&n.searchParams.append(`fmt`,t),n.toString()):e}catch{return e}}function At(e,t,n,r){let i=kt(t,r);V(t)?qe(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}}):window.location.href=i}function jt({iframe:e,targetOrigin:t,configDomain:n}){let r=new I;return{handleEvent:async i=>{if(!(`iframeLifecycle`in i))return;let{iframeLifecycle:a,data:o}=i;switch(a){case`connected`:r.resolve(!0);break;case`do-backup`:Dt(o.backup);break;case`remove-backup`:localStorage.removeItem(B);break;case`show`:case`hide`:it({iframe:e,isVisible:a===`show`});break;case`handshake`:Ot(e,o.token,t,n);break;case`redirect`:At(e,o.baseRedirectUrl,t,o.mergeToken);break}},isConnected:r.promise}}function Mt({config:e,iframe:t}){let n=e?.walletUrl??`https://wallet.frak.id`,r=jt({iframe:t,targetOrigin:n,configDomain:e.domain}),i=new $(e,t);if(!t.contentWindow)throw new F(P.configError,`The iframe does not have a content window`);let a=Ae({emittingTransport:t.contentWindow,listeningTransport:window,targetOrigin:n,middleware:[{async onRequest(e,t){if(!await r.isConnected)throw new F(P.clientNotConnected,`The iframe provider isn't connected yet`);return t}},{onRequest(e,t){return i.setLastRequest(e),t},onResponse(e,t){return i.setLastResponse(e,t),t}}],lifecycleHandlers:{iframeLifecycle:async(e,t)=>{await r.handleEvent(e)}}}),o=Nt(a,r),s=async()=>{o(),a.cleanup(),t.remove()},c;console.log(`[Frak SDK] Initializing OpenPanel`),c=new Tt({apiUrl:`https://op-api.gcp.frak.id`,clientId:`6eacc8d7-49ac-4936-95e9-81ef29449570`,trackScreenViews:!0,trackOutgoingLinks:!0,trackAttributes:!1,filter:({type:e,payload:t})=>(e!==`track`||!t?.properties||`sdkVersion`in t.properties||(t.properties={...t.properties,sdkVersion:`0.1.1`}),!0)}),c.setGlobalProperties({sdkVersion:`0.1.1`}),c.init();let l=Pt({config:e,rpcClient:a,lifecycleManager:r}).then(()=>i.updateSetupStatus(!0));return{config:e,debugInfo:i,waitForConnection:r.isConnected,waitForSetup:l,request:a.request,listenerRequest:a.listen,destroy:s,openPanel:c}}function Nt(e,t){let n,r,i=()=>e.sendLifecycle({clientLifecycle:`heartbeat`});async function a(){i(),n=setInterval(i,1e3),r=setTimeout(()=>{o(),console.log(`Heartbeat timeout: connection failed`)},3e4),await t.isConnected,o()}function o(){n&&clearInterval(n),r&&clearTimeout(r)}return a(),o}async function Pt({config:e,rpcClient:t,lifecycleManager:n}){await n.isConnected,Et(t,n.isConnected);async function r(){let n=e.customizations?.css;if(!n)return;let r={clientLifecycle:`modal-css`,data:{cssLink:n}};t.sendLifecycle(r)}async function i(){let n=e.customizations?.i18n;if(!n)return;let r={clientLifecycle:`modal-i18n`,data:{i18n:n}};t.sendLifecycle(r)}async function a(){if(typeof window>`u`)return;let e=window.localStorage.getItem(B);if(!e)return;let n={clientLifecycle:`restore-backup`,data:{backup:e}};t.sendLifecycle(n)}await Promise.allSettled([r(),i(),a()])}async function Ft({config:e}){let t=It(e),n=await rt({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=Mt({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error(`Failed to connect to client`);return}return r}function It(e){let t=G(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}return e.DEEP_LINK_SCHEME=We,e.DebugInfoGatherer=$,e.FrakContextManager=U,e.base64urlDecode=R,e.base64urlEncode=L,e.baseIframeProps=K,e.clearMerchantIdCache=st,e.compressJsonToB64=Ne,e.computeLegacyProductId=A,e.createIFrameFrakClient=Mt,e.createIframe=rt,e.decompressJsonFromB64=Ue,e.displayEmbeddedWallet=n,e.displayModal=r,e.fetchMerchantId=X,e.findIframeInOpener=at,e.formatAmount=tt,e.generateSsoUrl=Pe,e.getBackendUrl=z,e.getClientId=N,e.getCurrencyAmountKey=nt,e.getMerchantInformation=i,e.getSupportedCurrency=G,e.getSupportedLocale=et,e.isChromiumAndroid=Ge,e.isFrakDeepLink=V,e.locales=W,e.modalBuilder=vt,e.openSso=Re,e.prepareSso=ze,e.processReferral=ut,e.referralInteraction=mt,e.resolveMerchantId=ct,e.sendInteraction=lt,e.sendTransaction=yt,e.setupClient=Ft,e.siweAuthenticate=xt,e.ssoPopupFeatures=Ie,e.ssoPopupName=Le,e.toAndroidIntentUrl=Ke,e.trackEvent=Z,e.trackPurchaseStatus=ht,e.triggerDeepLinkWithFallback=qe,e.watchWalletStatus=gt,e})({});
14
+ `.trim()}};let Dt=(()=>{if(typeof navigator>`u`)return!1;let e=navigator.userAgent;if(!(/iPhone|iPad|iPod/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1))return!1;let t=e.toLowerCase();return t.includes(`instagram`)||t.includes(`fban`)||t.includes(`fbav`)||t.includes(`facebook`)})();function Ot(e){e?localStorage.setItem(V,e):localStorage.removeItem(V)}function kt(e,t,n,r){let i=new URL(window.location.href),a=i.searchParams.get(`fmt`)??void 0;e.contentWindow?.postMessage({clientLifecycle:`handshake-response`,data:{token:t,currentUrl:window.location.href,clientId:N(),pendingMergeToken:a,configDomain:r}},n),a&&(i.searchParams.delete(`fmt`),window.history.replaceState({},``,i.toString()))}function At(e,t){try{let n=new URL(e);return n.searchParams.has(`u`)?(n.searchParams.delete(`u`),n.searchParams.append(`u`,window.location.href),t&&n.searchParams.append(`fmt`,t),n.toString()):e}catch{return e}}function jt(e){let t=new URL(window.location.href);e&&t.searchParams.set(`fmt`,e);let n=t.protocol===`http:`?`x-safari-http`:`x-safari-https`;window.location.href=`${n}://${t.host}${t.pathname}${t.search}${t.hash}`}function Mt(e){return e.includes(`/common/social`)}function Nt(e,t,n,r){if(H(t)){let i=At(t,r);Ke(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}})}else if(Dt&&Mt(t))jt(r);else{let e=At(t,r);window.location.href=e}}function Pt({iframe:e,targetOrigin:t,configDomain:n}){let r=new I;return{handleEvent:async i=>{if(!(`iframeLifecycle`in i))return;let{iframeLifecycle:a,data:o}=i;switch(a){case`connected`:r.resolve(!0);break;case`do-backup`:Ot(o.backup);break;case`remove-backup`:localStorage.removeItem(V);break;case`show`:case`hide`:rt({iframe:e,isVisible:a===`show`});break;case`handshake`:kt(e,o.token,t,n);break;case`redirect`:Nt(e,o.baseRedirectUrl,t,o.mergeToken);break}},isConnected:r.promise}}function Ft({config:e,iframe:t}){let n=e?.walletUrl??`https://wallet.frak.id`;N();let r=Pt({iframe:t,targetOrigin:n,configDomain:e.domain}),i=new Et(e,t);if(!t.contentWindow)throw new F(P.configError,`The iframe does not have a content window`);let a=Ae({emittingTransport:t.contentWindow,listeningTransport:window,targetOrigin:n,middleware:[{async onRequest(e,t){if(!await r.isConnected)throw new F(P.clientNotConnected,`The iframe provider isn't connected yet`);return t}},{onRequest(e,t){return i.setLastRequest(e),t},onResponse(e,t){return i.setLastResponse(e,t),t}}],lifecycleHandlers:{iframeLifecycle:async(e,t)=>{await r.handleEvent(e)}}}),o=It(a,r),s=async()=>{o(),a.cleanup(),t.remove()},c;console.log(`[Frak SDK] Initializing OpenPanel`),c=new wt({apiUrl:`https://op-api.gcp.frak.id`,clientId:`6eacc8d7-49ac-4936-95e9-81ef29449570`,trackScreenViews:!0,trackOutgoingLinks:!0,trackAttributes:!1,filter:({type:e,payload:t})=>(e!==`track`||!t?.properties||`sdkVersion`in t.properties||(t.properties={...t.properties,sdkVersion:`0.1.1`,userAnonymousClientId:N()}),!0)}),c.setGlobalProperties({sdkVersion:`0.1.1`,userAnonymousClientId:N()}),c.init();let l=Lt({config:e,rpcClient:a,lifecycleManager:r}).then(()=>i.updateSetupStatus(!0));return{config:e,debugInfo:i,waitForConnection:r.isConnected,waitForSetup:l,request:a.request,listenerRequest:a.listen,destroy:s,openPanel:c}}function It(e,t){let n,r,i=()=>e.sendLifecycle({clientLifecycle:`heartbeat`});async function a(){i(),n=setInterval(i,1e3),r=setTimeout(()=>{o(),console.log(`Heartbeat timeout: connection failed`)},3e4),await t.isConnected,o()}function o(){n&&clearInterval(n),r&&clearTimeout(r)}return a(),o}async function Lt({config:e,rpcClient:t,lifecycleManager:n}){await n.isConnected,Tt(t,n.isConnected);async function r(){let n=e.customizations?.css;if(!n)return;let r={clientLifecycle:`modal-css`,data:{cssLink:n}};t.sendLifecycle(r)}async function i(){let n=e.customizations?.i18n;if(!n)return;let r={clientLifecycle:`modal-i18n`,data:{i18n:n}};t.sendLifecycle(r)}async function a(){if(typeof window>`u`)return;let e=window.localStorage.getItem(V);if(!e)return;let n={clientLifecycle:`restore-backup`,data:{backup:e}};t.sendLifecycle(n)}await Promise.allSettled([r(),i(),a()])}async function Rt({config:e}){let t=zt(e),n=await nt({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=Ft({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error(`Failed to connect to client`);return}return r}function zt(e){let t=K(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}return e.DEEP_LINK_SCHEME=Ue,e.DebugInfoGatherer=Et,e.FrakContextManager=W,e.base64urlDecode=R,e.base64urlEncode=L,e.baseIframeProps=q,e.clearMerchantIdCache=ot,e.compressJsonToB64=z,e.computeLegacyProductId=A,e.createIFrameFrakClient=Ft,e.createIframe=nt,e.decompressJsonFromB64=He,e.displayEmbeddedWallet=n,e.displayModal=r,e.fetchMerchantId=Z,e.findIframeInOpener=it,e.formatAmount=et,e.generateSsoUrl=Ne,e.getBackendUrl=B,e.getClientId=N,e.getCurrencyAmountKey=tt,e.getMerchantInformation=i,e.getSupportedCurrency=K,e.getSupportedLocale=$e,e.isChromiumAndroid=We,e.isFrakDeepLink=H,e.locales=G,e.modalBuilder=_t,e.openSso=Le,e.prepareSso=Re,e.processReferral=lt,e.referralInteraction=pt,e.resolveMerchantId=st,e.sendInteraction=ct,e.sendTransaction=vt,e.setupClient=Rt,e.siweAuthenticate=bt,e.ssoPopupFeatures=Fe,e.ssoPopupName=Ie,e.toAndroidIntentUrl=Ge,e.trackEvent=Q,e.trackPurchaseStatus=mt,e.triggerDeepLinkWithFallback=Ke,e.watchWalletStatus=ht,e})({});
package/dist/actions.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./trackEvent-BbX2d3g_.cjs`),t=require(`./siweAuthenticate-CVMVEe3M.cjs`);exports.displayEmbeddedWallet=t.f,exports.displayModal=t.d,exports.getMerchantInformation=t.u,exports.modalBuilder=t.r,exports.openSso=e.s,exports.prepareSso=t.l,exports.processReferral=t.s,exports.referralInteraction=t.o,exports.sendInteraction=t.c,exports.sendTransaction=t.n,exports.siweAuthenticate=t.t,exports.trackPurchaseStatus=t.a,exports.watchWalletStatus=t.i;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./trackEvent-2_5BW61g.cjs`),t=require(`./siweAuthenticate-BvlTzQEa.cjs`);exports.displayEmbeddedWallet=t.f,exports.displayModal=t.d,exports.getMerchantInformation=t.u,exports.modalBuilder=t.r,exports.openSso=e.s,exports.prepareSso=t.l,exports.processReferral=t.s,exports.referralInteraction=t.o,exports.sendInteraction=t.c,exports.sendTransaction=t.n,exports.siweAuthenticate=t.t,exports.trackPurchaseStatus=t.a,exports.watchWalletStatus=t.i;
@@ -1,3 +1,3 @@
1
- import { t as openSso } from "./openSso-CC1-loUk.cjs";
2
- import { _ as displayEmbeddedWallet, a as ModalBuilder, c as watchWalletStatus, d as referralInteraction, f as ProcessReferralOptions, g as displayModal, h as getMerchantInformation, i as sendTransaction, l as trackPurchaseStatus, m as prepareSso, n as siweAuthenticate, o as ModalStepBuilder, p as processReferral, r as SendTransactionParams, s as modalBuilder, t as SiweAuthenticateModalParams, u as sendInteraction } from "./siweAuthenticate-DfiQdngJ.cjs";
1
+ import { t as openSso } from "./openSso-DTFns_5E.cjs";
2
+ import { _ as displayEmbeddedWallet, a as ModalBuilder, c as watchWalletStatus, d as referralInteraction, f as ProcessReferralOptions, g as displayModal, h as getMerchantInformation, i as sendTransaction, l as trackPurchaseStatus, m as prepareSso, n as siweAuthenticate, o as ModalStepBuilder, p as processReferral, r as SendTransactionParams, s as modalBuilder, t as SiweAuthenticateModalParams, u as sendInteraction } from "./siweAuthenticate-D_AfTjZY.cjs";
3
3
  export { type ModalBuilder, type ModalStepBuilder, type ProcessReferralOptions, type SendTransactionParams, type SiweAuthenticateModalParams, displayEmbeddedWallet, displayModal, getMerchantInformation, modalBuilder, openSso, prepareSso, processReferral, referralInteraction, sendInteraction, sendTransaction, siweAuthenticate, trackPurchaseStatus, watchWalletStatus };
package/dist/actions.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { t as openSso } from "./openSso-tkqaDQLV.js";
2
- import { _ as displayEmbeddedWallet, a as ModalBuilder, c as watchWalletStatus, d as referralInteraction, f as ProcessReferralOptions, g as displayModal, h as getMerchantInformation, i as sendTransaction, l as trackPurchaseStatus, m as prepareSso, n as siweAuthenticate, o as ModalStepBuilder, p as processReferral, r as SendTransactionParams, s as modalBuilder, t as SiweAuthenticateModalParams, u as sendInteraction } from "./siweAuthenticate-BOqz9Uww.js";
1
+ import { t as openSso } from "./openSso-DXL8K2tc.js";
2
+ import { _ as displayEmbeddedWallet, a as ModalBuilder, c as watchWalletStatus, d as referralInteraction, f as ProcessReferralOptions, g as displayModal, h as getMerchantInformation, i as sendTransaction, l as trackPurchaseStatus, m as prepareSso, n as siweAuthenticate, o as ModalStepBuilder, p as processReferral, r as SendTransactionParams, s as modalBuilder, t as SiweAuthenticateModalParams, u as sendInteraction } from "./siweAuthenticate-BxRXLOpn.js";
3
3
  export { type ModalBuilder, type ModalStepBuilder, type ProcessReferralOptions, type SendTransactionParams, type SiweAuthenticateModalParams, displayEmbeddedWallet, displayModal, getMerchantInformation, modalBuilder, openSso, prepareSso, processReferral, referralInteraction, sendInteraction, sendTransaction, siweAuthenticate, trackPurchaseStatus, watchWalletStatus };
package/dist/actions.js CHANGED
@@ -1 +1 @@
1
- import{s as e}from"./trackEvent-B0S5E6_h.js";import{a as t,c as n,d as r,f as i,i as a,l as o,n as s,o as c,r as l,s as u,t as d,u as f}from"./siweAuthenticate-BKSiU7Ej.js";export{i as displayEmbeddedWallet,r as displayModal,f as getMerchantInformation,l as modalBuilder,e as openSso,o as prepareSso,u as processReferral,c as referralInteraction,n as sendInteraction,s as sendTransaction,d as siweAuthenticate,t as trackPurchaseStatus,a as watchWalletStatus};
1
+ import{s as e}from"./trackEvent-BXs0TMuA.js";import{a as t,c as n,d as r,f as i,i as a,l as o,n as s,o as c,r as l,s as u,t as d,u as f}from"./siweAuthenticate-JMWtaEGT.js";export{i as displayEmbeddedWallet,r as displayModal,f as getMerchantInformation,l as modalBuilder,e as openSso,o as prepareSso,u as processReferral,c as referralInteraction,n as sendInteraction,s as sendTransaction,d as siweAuthenticate,t as trackPurchaseStatus,a as watchWalletStatus};
package/dist/bundle.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./trackEvent-BbX2d3g_.cjs`),t=require(`./setupClient-Cc88LYkD.cjs`),n=require(`./siweAuthenticate-CVMVEe3M.cjs`);exports.DEEP_LINK_SCHEME=t._,exports.DebugInfoGatherer=t.g,exports.FrakContextManager=e.a,exports.base64urlDecode=e.f,exports.base64urlEncode=e.p,exports.baseIframeProps=t.l,exports.clearMerchantIdCache=e.n,exports.compressJsonToB64=e.d,exports.computeLegacyProductId=e.h,exports.createIFrameFrakClient=t.c,exports.createIframe=t.u,exports.decompressJsonFromB64=t.s,exports.displayEmbeddedWallet=n.f,exports.displayModal=n.d,exports.fetchMerchantId=e.r,exports.findIframeInOpener=t.d,exports.formatAmount=t.r,exports.generateSsoUrl=e.u,exports.getBackendUrl=e.o,exports.getClientId=e.m,exports.getCurrencyAmountKey=t.n,exports.getMerchantInformation=n.u,exports.getSupportedCurrency=t.a,exports.getSupportedLocale=t.i,exports.isChromiumAndroid=t.f,exports.isFrakDeepLink=t.p,exports.locales=t.o,exports.modalBuilder=n.r,exports.openSso=e.s,exports.prepareSso=n.l,exports.processReferral=n.s,exports.referralInteraction=n.o,exports.resolveMerchantId=e.i,exports.sendInteraction=n.c,exports.sendTransaction=n.n,exports.setupClient=t.t,exports.siweAuthenticate=n.t,exports.ssoPopupFeatures=e.c,exports.ssoPopupName=e.l,exports.toAndroidIntentUrl=t.m,exports.trackEvent=e.t,exports.trackPurchaseStatus=n.a,exports.triggerDeepLinkWithFallback=t.h,exports.watchWalletStatus=n.i;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./trackEvent-2_5BW61g.cjs`),t=require(`./setupClient-asUiwNYi.cjs`),n=require(`./siweAuthenticate-BvlTzQEa.cjs`);exports.DEEP_LINK_SCHEME=t.g,exports.DebugInfoGatherer=t.r,exports.FrakContextManager=e.a,exports.base64urlDecode=e.f,exports.base64urlEncode=e.p,exports.baseIframeProps=t.i,exports.clearMerchantIdCache=e.n,exports.compressJsonToB64=e.d,exports.computeLegacyProductId=e.h,exports.createIFrameFrakClient=t.n,exports.createIframe=t.a,exports.decompressJsonFromB64=t._,exports.displayEmbeddedWallet=n.f,exports.displayModal=n.d,exports.fetchMerchantId=e.r,exports.findIframeInOpener=t.o,exports.formatAmount=t.c,exports.generateSsoUrl=e.u,exports.getBackendUrl=e.o,exports.getClientId=e.m,exports.getCurrencyAmountKey=t.s,exports.getMerchantInformation=n.u,exports.getSupportedCurrency=t.u,exports.getSupportedLocale=t.l,exports.isChromiumAndroid=t.f,exports.isFrakDeepLink=t.p,exports.locales=t.d,exports.modalBuilder=n.r,exports.openSso=e.s,exports.prepareSso=n.l,exports.processReferral=n.s,exports.referralInteraction=n.o,exports.resolveMerchantId=e.i,exports.sendInteraction=n.c,exports.sendTransaction=n.n,exports.setupClient=t.t,exports.siweAuthenticate=n.t,exports.ssoPopupFeatures=e.c,exports.ssoPopupName=e.l,exports.toAndroidIntentUrl=t.m,exports.trackEvent=e.t,exports.trackPurchaseStatus=n.a,exports.triggerDeepLinkWithFallback=t.h,exports.watchWalletStatus=n.i;
package/dist/bundle.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as SiweAuthenticateReturnType, B as ModalStepMetadata, C as ModalRpcStepsInput, D as SendTransactionReturnType, E as SendTransactionModalStepType, F as PrepareSsoParamsType, G as FrakWalletSdkConfig, H as IFrameLifecycleEvent, I as PrepareSsoReturnType, J as LocalizedI18nConfig, K as I18nConfig, L as SsoMetadata, M as LoginModalStepType, N as OpenSsoParamsType, O as SendTransactionTxType, P as OpenSsoReturnType, R as FinalActionType, S as ModalRpcMetadata, T as ModalStepTypes, U as ClientLifecycleEvent, V as InteractionTypeKey, W as Currency, _ as LoggedOutEmbeddedView, a as FrakClient, b as LoggedInEmbeddedView, c as IFrameRpcSchema, d as GetMerchantInformationReturnType, f as RewardTier, g as DisplayEmbeddedWalletResultType, h as DisplayEmbeddedWalletParamsType, i as FrakContext, j as SiweAuthenticationParams, k as SiweAuthenticateModalStepType, l as WalletStatusReturnType, m as SendInteractionParamsType, n as ssoPopupFeatures, o as FrakLifecycleEvent, p as TokenAmountType, q as Language, r as ssoPopupName, s as IFrameTransport, t as openSso, u as EstimatedReward, v as EmbeddedViewActionReferred, w as ModalRpcStepsResultType, x as DisplayModalParamsType, y as EmbeddedViewActionSharing, z as FinalModalStepType } from "./openSso-CC1-loUk.cjs";
2
- import { A as getBackendUrl, B as HashProtectedData, C as triggerDeepLinkWithFallback, D as base64urlDecode, E as compressJsonToB64, F as createIFrameFrakClient, I as TrackArrivalParams, L as TrackArrivalResult, M as locales, N as setupClient, O as base64urlEncode, P as DebugInfoGatherer, R as UtmParams, S as toAndroidIntentUrl, T as decompressJsonFromB64, V as KeyProvider, _ as formatAmount, a as CompressedSsoData, b as isChromiumAndroid, c as clearMerchantIdCache, d as baseIframeProps, f as createIframe, g as getCurrencyAmountKey, h as getSupportedCurrency, i as AppSpecificSsoMetadata, j as LocalesKey, k as getClientId, l as fetchMerchantId, m as getSupportedLocale, n as FrakEvent, o as FullSsoParams, p as findIframeInOpener, r as trackEvent, s as generateSsoUrl, t as computeLegacyProductId, u as resolveMerchantId, v as FrakContextManager, w as DEEP_LINK_SCHEME, x as isFrakDeepLink, y as DeepLinkFallbackOptions, z as CompressedData } from "./computeLegacyProductId-fl_Sx8v5.cjs";
3
- import { _ as displayEmbeddedWallet, a as ModalBuilder, c as watchWalletStatus, d as referralInteraction, f as ProcessReferralOptions, g as displayModal, h as getMerchantInformation, i as sendTransaction, l as trackPurchaseStatus, m as prepareSso, n as siweAuthenticate, o as ModalStepBuilder, p as processReferral, r as SendTransactionParams, s as modalBuilder, t as SiweAuthenticateModalParams, u as sendInteraction } from "./siweAuthenticate-DfiQdngJ.cjs";
1
+ import { A as SiweAuthenticateReturnType, B as ModalStepMetadata, C as ModalRpcStepsInput, D as SendTransactionReturnType, E as SendTransactionModalStepType, F as PrepareSsoParamsType, G as FrakWalletSdkConfig, H as IFrameLifecycleEvent, I as PrepareSsoReturnType, J as LocalizedI18nConfig, K as I18nConfig, L as SsoMetadata, M as LoginModalStepType, N as OpenSsoParamsType, O as SendTransactionTxType, P as OpenSsoReturnType, R as FinalActionType, S as ModalRpcMetadata, T as ModalStepTypes, U as ClientLifecycleEvent, V as InteractionTypeKey, W as Currency, _ as LoggedOutEmbeddedView, a as FrakClient, b as LoggedInEmbeddedView, c as IFrameRpcSchema, d as GetMerchantInformationReturnType, f as RewardTier, g as DisplayEmbeddedWalletResultType, h as DisplayEmbeddedWalletParamsType, i as FrakContext, j as SiweAuthenticationParams, k as SiweAuthenticateModalStepType, l as WalletStatusReturnType, m as SendInteractionParamsType, n as ssoPopupFeatures, o as FrakLifecycleEvent, p as TokenAmountType, q as Language, r as ssoPopupName, s as IFrameTransport, t as openSso, u as EstimatedReward, v as EmbeddedViewActionReferred, w as ModalRpcStepsResultType, x as DisplayModalParamsType, y as EmbeddedViewActionSharing, z as FinalModalStepType } from "./openSso-DTFns_5E.cjs";
2
+ import { A as getBackendUrl, B as HashProtectedData, C as triggerDeepLinkWithFallback, D as base64urlDecode, E as compressJsonToB64, F as createIFrameFrakClient, I as TrackArrivalParams, L as TrackArrivalResult, M as locales, N as setupClient, O as base64urlEncode, P as DebugInfoGatherer, R as UtmParams, S as toAndroidIntentUrl, T as decompressJsonFromB64, V as KeyProvider, _ as formatAmount, a as CompressedSsoData, b as isChromiumAndroid, c as clearMerchantIdCache, d as baseIframeProps, f as createIframe, g as getCurrencyAmountKey, h as getSupportedCurrency, i as AppSpecificSsoMetadata, j as LocalesKey, k as getClientId, l as fetchMerchantId, m as getSupportedLocale, n as FrakEvent, o as FullSsoParams, p as findIframeInOpener, r as trackEvent, s as generateSsoUrl, t as computeLegacyProductId, u as resolveMerchantId, v as FrakContextManager, w as DEEP_LINK_SCHEME, x as isFrakDeepLink, y as DeepLinkFallbackOptions, z as CompressedData } from "./computeLegacyProductId-B-2-L7VT.cjs";
3
+ import { _ as displayEmbeddedWallet, a as ModalBuilder, c as watchWalletStatus, d as referralInteraction, f as ProcessReferralOptions, g as displayModal, h as getMerchantInformation, i as sendTransaction, l as trackPurchaseStatus, m as prepareSso, n as siweAuthenticate, o as ModalStepBuilder, p as processReferral, r as SendTransactionParams, s as modalBuilder, t as SiweAuthenticateModalParams, u as sendInteraction } from "./siweAuthenticate-D_AfTjZY.cjs";
4
4
  export { AppSpecificSsoMetadata, ClientLifecycleEvent, CompressedData, CompressedSsoData, Currency, DEEP_LINK_SCHEME, DebugInfoGatherer, DeepLinkFallbackOptions, DisplayEmbeddedWalletParamsType, DisplayEmbeddedWalletResultType, DisplayModalParamsType, EmbeddedViewActionReferred, EmbeddedViewActionSharing, EstimatedReward, FinalActionType, FinalModalStepType, FrakClient, FrakContext, FrakContextManager, FrakEvent, FrakLifecycleEvent, FrakWalletSdkConfig, FullSsoParams, GetMerchantInformationReturnType, HashProtectedData, I18nConfig, IFrameLifecycleEvent, IFrameRpcSchema, IFrameTransport, InteractionTypeKey, KeyProvider, Language, LocalesKey, LocalizedI18nConfig, LoggedInEmbeddedView, LoggedOutEmbeddedView, LoginModalStepType, ModalBuilder, ModalRpcMetadata, ModalRpcStepsInput, ModalRpcStepsResultType, ModalStepBuilder, ModalStepMetadata, ModalStepTypes, OpenSsoParamsType, OpenSsoReturnType, PrepareSsoParamsType, PrepareSsoReturnType, ProcessReferralOptions, RewardTier, SendInteractionParamsType, SendTransactionModalStepType, SendTransactionParams, SendTransactionReturnType, SendTransactionTxType, SiweAuthenticateModalParams, SiweAuthenticateModalStepType, SiweAuthenticateReturnType, SiweAuthenticationParams, SsoMetadata, TokenAmountType, TrackArrivalParams, TrackArrivalResult, UtmParams, WalletStatusReturnType, base64urlDecode, base64urlEncode, baseIframeProps, clearMerchantIdCache, compressJsonToB64, computeLegacyProductId, createIFrameFrakClient, createIframe, decompressJsonFromB64, displayEmbeddedWallet, displayModal, fetchMerchantId, findIframeInOpener, formatAmount, generateSsoUrl, getBackendUrl, getClientId, getCurrencyAmountKey, getMerchantInformation, getSupportedCurrency, getSupportedLocale, isChromiumAndroid, isFrakDeepLink, locales, modalBuilder, openSso, prepareSso, processReferral, referralInteraction, resolveMerchantId, sendInteraction, sendTransaction, setupClient, siweAuthenticate, ssoPopupFeatures, ssoPopupName, toAndroidIntentUrl, trackEvent, trackPurchaseStatus, triggerDeepLinkWithFallback, watchWalletStatus };
package/dist/bundle.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as SiweAuthenticateReturnType, B as ModalStepMetadata, C as ModalRpcStepsInput, D as SendTransactionReturnType, E as SendTransactionModalStepType, F as PrepareSsoParamsType, G as FrakWalletSdkConfig, H as IFrameLifecycleEvent, I as PrepareSsoReturnType, J as LocalizedI18nConfig, K as I18nConfig, L as SsoMetadata, M as LoginModalStepType, N as OpenSsoParamsType, O as SendTransactionTxType, P as OpenSsoReturnType, R as FinalActionType, S as ModalRpcMetadata, T as ModalStepTypes, U as ClientLifecycleEvent, V as InteractionTypeKey, W as Currency, _ as LoggedOutEmbeddedView, a as FrakClient, b as LoggedInEmbeddedView, c as IFrameRpcSchema, d as GetMerchantInformationReturnType, f as RewardTier, g as DisplayEmbeddedWalletResultType, h as DisplayEmbeddedWalletParamsType, i as FrakContext, j as SiweAuthenticationParams, k as SiweAuthenticateModalStepType, l as WalletStatusReturnType, m as SendInteractionParamsType, n as ssoPopupFeatures, o as FrakLifecycleEvent, p as TokenAmountType, q as Language, r as ssoPopupName, s as IFrameTransport, t as openSso, u as EstimatedReward, v as EmbeddedViewActionReferred, w as ModalRpcStepsResultType, x as DisplayModalParamsType, y as EmbeddedViewActionSharing, z as FinalModalStepType } from "./openSso-tkqaDQLV.js";
2
- import { A as getBackendUrl, B as HashProtectedData, C as triggerDeepLinkWithFallback, D as base64urlDecode, E as compressJsonToB64, F as createIFrameFrakClient, I as TrackArrivalParams, L as TrackArrivalResult, M as locales, N as setupClient, O as base64urlEncode, P as DebugInfoGatherer, R as UtmParams, S as toAndroidIntentUrl, T as decompressJsonFromB64, V as KeyProvider, _ as formatAmount, a as CompressedSsoData, b as isChromiumAndroid, c as clearMerchantIdCache, d as baseIframeProps, f as createIframe, g as getCurrencyAmountKey, h as getSupportedCurrency, i as AppSpecificSsoMetadata, j as LocalesKey, k as getClientId, l as fetchMerchantId, m as getSupportedLocale, n as FrakEvent, o as FullSsoParams, p as findIframeInOpener, r as trackEvent, s as generateSsoUrl, t as computeLegacyProductId, u as resolveMerchantId, v as FrakContextManager, w as DEEP_LINK_SCHEME, x as isFrakDeepLink, y as DeepLinkFallbackOptions, z as CompressedData } from "./computeLegacyProductId-CSSiQO4V.js";
3
- import { _ as displayEmbeddedWallet, a as ModalBuilder, c as watchWalletStatus, d as referralInteraction, f as ProcessReferralOptions, g as displayModal, h as getMerchantInformation, i as sendTransaction, l as trackPurchaseStatus, m as prepareSso, n as siweAuthenticate, o as ModalStepBuilder, p as processReferral, r as SendTransactionParams, s as modalBuilder, t as SiweAuthenticateModalParams, u as sendInteraction } from "./siweAuthenticate-BOqz9Uww.js";
1
+ import { A as SiweAuthenticateReturnType, B as ModalStepMetadata, C as ModalRpcStepsInput, D as SendTransactionReturnType, E as SendTransactionModalStepType, F as PrepareSsoParamsType, G as FrakWalletSdkConfig, H as IFrameLifecycleEvent, I as PrepareSsoReturnType, J as LocalizedI18nConfig, K as I18nConfig, L as SsoMetadata, M as LoginModalStepType, N as OpenSsoParamsType, O as SendTransactionTxType, P as OpenSsoReturnType, R as FinalActionType, S as ModalRpcMetadata, T as ModalStepTypes, U as ClientLifecycleEvent, V as InteractionTypeKey, W as Currency, _ as LoggedOutEmbeddedView, a as FrakClient, b as LoggedInEmbeddedView, c as IFrameRpcSchema, d as GetMerchantInformationReturnType, f as RewardTier, g as DisplayEmbeddedWalletResultType, h as DisplayEmbeddedWalletParamsType, i as FrakContext, j as SiweAuthenticationParams, k as SiweAuthenticateModalStepType, l as WalletStatusReturnType, m as SendInteractionParamsType, n as ssoPopupFeatures, o as FrakLifecycleEvent, p as TokenAmountType, q as Language, r as ssoPopupName, s as IFrameTransport, t as openSso, u as EstimatedReward, v as EmbeddedViewActionReferred, w as ModalRpcStepsResultType, x as DisplayModalParamsType, y as EmbeddedViewActionSharing, z as FinalModalStepType } from "./openSso-DXL8K2tc.js";
2
+ import { A as getBackendUrl, B as HashProtectedData, C as triggerDeepLinkWithFallback, D as base64urlDecode, E as compressJsonToB64, F as createIFrameFrakClient, I as TrackArrivalParams, L as TrackArrivalResult, M as locales, N as setupClient, O as base64urlEncode, P as DebugInfoGatherer, R as UtmParams, S as toAndroidIntentUrl, T as decompressJsonFromB64, V as KeyProvider, _ as formatAmount, a as CompressedSsoData, b as isChromiumAndroid, c as clearMerchantIdCache, d as baseIframeProps, f as createIframe, g as getCurrencyAmountKey, h as getSupportedCurrency, i as AppSpecificSsoMetadata, j as LocalesKey, k as getClientId, l as fetchMerchantId, m as getSupportedLocale, n as FrakEvent, o as FullSsoParams, p as findIframeInOpener, r as trackEvent, s as generateSsoUrl, t as computeLegacyProductId, u as resolveMerchantId, v as FrakContextManager, w as DEEP_LINK_SCHEME, x as isFrakDeepLink, y as DeepLinkFallbackOptions, z as CompressedData } from "./computeLegacyProductId-M9k7vnUf.js";
3
+ import { _ as displayEmbeddedWallet, a as ModalBuilder, c as watchWalletStatus, d as referralInteraction, f as ProcessReferralOptions, g as displayModal, h as getMerchantInformation, i as sendTransaction, l as trackPurchaseStatus, m as prepareSso, n as siweAuthenticate, o as ModalStepBuilder, p as processReferral, r as SendTransactionParams, s as modalBuilder, t as SiweAuthenticateModalParams, u as sendInteraction } from "./siweAuthenticate-BxRXLOpn.js";
4
4
  export { AppSpecificSsoMetadata, ClientLifecycleEvent, CompressedData, CompressedSsoData, Currency, DEEP_LINK_SCHEME, DebugInfoGatherer, DeepLinkFallbackOptions, DisplayEmbeddedWalletParamsType, DisplayEmbeddedWalletResultType, DisplayModalParamsType, EmbeddedViewActionReferred, EmbeddedViewActionSharing, EstimatedReward, FinalActionType, FinalModalStepType, FrakClient, FrakContext, FrakContextManager, FrakEvent, FrakLifecycleEvent, FrakWalletSdkConfig, FullSsoParams, GetMerchantInformationReturnType, HashProtectedData, I18nConfig, IFrameLifecycleEvent, IFrameRpcSchema, IFrameTransport, InteractionTypeKey, KeyProvider, Language, LocalesKey, LocalizedI18nConfig, LoggedInEmbeddedView, LoggedOutEmbeddedView, LoginModalStepType, ModalBuilder, ModalRpcMetadata, ModalRpcStepsInput, ModalRpcStepsResultType, ModalStepBuilder, ModalStepMetadata, ModalStepTypes, OpenSsoParamsType, OpenSsoReturnType, PrepareSsoParamsType, PrepareSsoReturnType, ProcessReferralOptions, RewardTier, SendInteractionParamsType, SendTransactionModalStepType, SendTransactionParams, SendTransactionReturnType, SendTransactionTxType, SiweAuthenticateModalParams, SiweAuthenticateModalStepType, SiweAuthenticateReturnType, SiweAuthenticationParams, SsoMetadata, TokenAmountType, TrackArrivalParams, TrackArrivalResult, UtmParams, WalletStatusReturnType, base64urlDecode, base64urlEncode, baseIframeProps, clearMerchantIdCache, compressJsonToB64, computeLegacyProductId, createIFrameFrakClient, createIframe, decompressJsonFromB64, displayEmbeddedWallet, displayModal, fetchMerchantId, findIframeInOpener, formatAmount, generateSsoUrl, getBackendUrl, getClientId, getCurrencyAmountKey, getMerchantInformation, getSupportedCurrency, getSupportedLocale, isChromiumAndroid, isFrakDeepLink, locales, modalBuilder, openSso, prepareSso, processReferral, referralInteraction, resolveMerchantId, sendInteraction, sendTransaction, setupClient, siweAuthenticate, ssoPopupFeatures, ssoPopupName, toAndroidIntentUrl, trackEvent, trackPurchaseStatus, triggerDeepLinkWithFallback, watchWalletStatus };
package/dist/bundle.js CHANGED
@@ -1 +1 @@
1
- import{a as e,c as t,d as n,f as r,h as i,i as a,l as o,m as s,n as c,o as l,p as u,r as d,s as f,t as p,u as m}from"./trackEvent-B0S5E6_h.js";import{_ as h,a as g,c as _,d as v,f as y,g as b,h as x,i as S,l as C,m as w,n as T,o as E,p as D,r as O,s as k,t as A,u as j}from"./setupClient-CO8HTRRE.js";import{a as M,c as N,d as P,f as F,i as I,l as L,n as R,o as z,r as B,s as V,t as H,u as U}from"./siweAuthenticate-BKSiU7Ej.js";export{h as DEEP_LINK_SCHEME,b as DebugInfoGatherer,e as FrakContextManager,r as base64urlDecode,u as base64urlEncode,C as baseIframeProps,c as clearMerchantIdCache,n as compressJsonToB64,i as computeLegacyProductId,_ as createIFrameFrakClient,j as createIframe,k as decompressJsonFromB64,F as displayEmbeddedWallet,P as displayModal,d as fetchMerchantId,v as findIframeInOpener,O as formatAmount,m as generateSsoUrl,l as getBackendUrl,s as getClientId,T as getCurrencyAmountKey,U as getMerchantInformation,g as getSupportedCurrency,S as getSupportedLocale,y as isChromiumAndroid,D as isFrakDeepLink,E as locales,B as modalBuilder,f as openSso,L as prepareSso,V as processReferral,z as referralInteraction,a as resolveMerchantId,N as sendInteraction,R as sendTransaction,A as setupClient,H as siweAuthenticate,t as ssoPopupFeatures,o as ssoPopupName,w as toAndroidIntentUrl,p as trackEvent,M as trackPurchaseStatus,x as triggerDeepLinkWithFallback,I as watchWalletStatus};
1
+ import{a as e,c as t,d as n,f as r,h as i,i as a,l as o,m as s,n as c,o as l,p as u,r as d,s as f,t as p,u as m}from"./trackEvent-BXs0TMuA.js";import{_ as h,a as g,c as _,d as v,f as y,g as b,h as x,i as S,l as C,m as w,n as T,o as E,p as D,r as O,s as k,t as A,u as j}from"./setupClient-UMz34Dmb.js";import{a as M,c as N,d as P,f as F,i as I,l as L,n as R,o as z,r as B,s as V,t as H,u as U}from"./siweAuthenticate-JMWtaEGT.js";export{b as DEEP_LINK_SCHEME,O as DebugInfoGatherer,e as FrakContextManager,r as base64urlDecode,u as base64urlEncode,S as baseIframeProps,c as clearMerchantIdCache,n as compressJsonToB64,i as computeLegacyProductId,T as createIFrameFrakClient,g as createIframe,h as decompressJsonFromB64,F as displayEmbeddedWallet,P as displayModal,d as fetchMerchantId,E as findIframeInOpener,_ as formatAmount,m as generateSsoUrl,l as getBackendUrl,s as getClientId,k as getCurrencyAmountKey,U as getMerchantInformation,j as getSupportedCurrency,C as getSupportedLocale,y as isChromiumAndroid,D as isFrakDeepLink,v as locales,B as modalBuilder,f as openSso,L as prepareSso,V as processReferral,z as referralInteraction,a as resolveMerchantId,N as sendInteraction,R as sendTransaction,A as setupClient,H as siweAuthenticate,t as ssoPopupFeatures,o as ssoPopupName,w as toAndroidIntentUrl,p as trackEvent,M as trackPurchaseStatus,x as triggerDeepLinkWithFallback,I as watchWalletStatus};
@@ -1,4 +1,4 @@
1
- import { F as PrepareSsoParamsType, G as FrakWalletSdkConfig, L as SsoMetadata, W as Currency, a as FrakClient, i as FrakContext, p as TokenAmountType } from "./openSso-CC1-loUk.cjs";
1
+ import { F as PrepareSsoParamsType, G as FrakWalletSdkConfig, L as SsoMetadata, W as Currency, a as FrakClient, i as FrakContext, p as TokenAmountType } from "./openSso-DTFns_5E.cjs";
2
2
  import { RpcMessage, RpcResponse } from "@frak-labs/frame-connector";
3
3
  import { Address, Hex } from "viem";
4
4
 
@@ -1,4 +1,4 @@
1
- import { F as PrepareSsoParamsType, G as FrakWalletSdkConfig, L as SsoMetadata, W as Currency, a as FrakClient, i as FrakContext, p as TokenAmountType } from "./openSso-tkqaDQLV.js";
1
+ import { F as PrepareSsoParamsType, G as FrakWalletSdkConfig, L as SsoMetadata, W as Currency, a as FrakClient, i as FrakContext, p as TokenAmountType } from "./openSso-DXL8K2tc.js";
2
2
  import { Address, Hex } from "viem";
3
3
  import { RpcMessage, RpcResponse } from "@frak-labs/frame-connector";
4
4
 
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./trackEvent-BbX2d3g_.cjs`),t=require(`./setupClient-Cc88LYkD.cjs`);exports.DEEP_LINK_SCHEME=t._,exports.DebugInfoGatherer=t.g,exports.FrakContextManager=e.a,exports.base64urlDecode=e.f,exports.base64urlEncode=e.p,exports.baseIframeProps=t.l,exports.clearMerchantIdCache=e.n,exports.compressJsonToB64=e.d,exports.computeLegacyProductId=e.h,exports.createIFrameFrakClient=t.c,exports.createIframe=t.u,exports.decompressJsonFromB64=t.s,exports.fetchMerchantId=e.r,exports.findIframeInOpener=t.d,exports.formatAmount=t.r,exports.generateSsoUrl=e.u,exports.getBackendUrl=e.o,exports.getClientId=e.m,exports.getCurrencyAmountKey=t.n,exports.getSupportedCurrency=t.a,exports.getSupportedLocale=t.i,exports.isChromiumAndroid=t.f,exports.isFrakDeepLink=t.p,exports.locales=t.o,exports.resolveMerchantId=e.i,exports.setupClient=t.t,exports.ssoPopupFeatures=e.c,exports.ssoPopupName=e.l,exports.toAndroidIntentUrl=t.m,exports.trackEvent=e.t,exports.triggerDeepLinkWithFallback=t.h;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./trackEvent-2_5BW61g.cjs`),t=require(`./setupClient-asUiwNYi.cjs`);exports.DEEP_LINK_SCHEME=t.g,exports.DebugInfoGatherer=t.r,exports.FrakContextManager=e.a,exports.base64urlDecode=e.f,exports.base64urlEncode=e.p,exports.baseIframeProps=t.i,exports.clearMerchantIdCache=e.n,exports.compressJsonToB64=e.d,exports.computeLegacyProductId=e.h,exports.createIFrameFrakClient=t.n,exports.createIframe=t.a,exports.decompressJsonFromB64=t._,exports.fetchMerchantId=e.r,exports.findIframeInOpener=t.o,exports.formatAmount=t.c,exports.generateSsoUrl=e.u,exports.getBackendUrl=e.o,exports.getClientId=e.m,exports.getCurrencyAmountKey=t.s,exports.getSupportedCurrency=t.u,exports.getSupportedLocale=t.l,exports.isChromiumAndroid=t.f,exports.isFrakDeepLink=t.p,exports.locales=t.d,exports.resolveMerchantId=e.i,exports.setupClient=t.t,exports.ssoPopupFeatures=e.c,exports.ssoPopupName=e.l,exports.toAndroidIntentUrl=t.m,exports.trackEvent=e.t,exports.triggerDeepLinkWithFallback=t.h;
package/dist/index.d.cts CHANGED
@@ -1,3 +1,3 @@
1
- import { A as SiweAuthenticateReturnType, B as ModalStepMetadata, C as ModalRpcStepsInput, D as SendTransactionReturnType, E as SendTransactionModalStepType, F as PrepareSsoParamsType, G as FrakWalletSdkConfig, H as IFrameLifecycleEvent, I as PrepareSsoReturnType, J as LocalizedI18nConfig, K as I18nConfig, L as SsoMetadata, M as LoginModalStepType, N as OpenSsoParamsType, O as SendTransactionTxType, P as OpenSsoReturnType, R as FinalActionType, S as ModalRpcMetadata, T as ModalStepTypes, U as ClientLifecycleEvent, V as InteractionTypeKey, W as Currency, _ as LoggedOutEmbeddedView, a as FrakClient, b as LoggedInEmbeddedView, c as IFrameRpcSchema, d as GetMerchantInformationReturnType, f as RewardTier, g as DisplayEmbeddedWalletResultType, h as DisplayEmbeddedWalletParamsType, i as FrakContext, j as SiweAuthenticationParams, k as SiweAuthenticateModalStepType, l as WalletStatusReturnType, m as SendInteractionParamsType, n as ssoPopupFeatures, o as FrakLifecycleEvent, p as TokenAmountType, q as Language, r as ssoPopupName, s as IFrameTransport, u as EstimatedReward, v as EmbeddedViewActionReferred, w as ModalRpcStepsResultType, x as DisplayModalParamsType, y as EmbeddedViewActionSharing, z as FinalModalStepType } from "./openSso-CC1-loUk.cjs";
2
- import { A as getBackendUrl, B as HashProtectedData, C as triggerDeepLinkWithFallback, D as base64urlDecode, E as compressJsonToB64, F as createIFrameFrakClient, I as TrackArrivalParams, L as TrackArrivalResult, M as locales, N as setupClient, O as base64urlEncode, P as DebugInfoGatherer, R as UtmParams, S as toAndroidIntentUrl, T as decompressJsonFromB64, V as KeyProvider, _ as formatAmount, a as CompressedSsoData, b as isChromiumAndroid, c as clearMerchantIdCache, d as baseIframeProps, f as createIframe, g as getCurrencyAmountKey, h as getSupportedCurrency, i as AppSpecificSsoMetadata, j as LocalesKey, k as getClientId, l as fetchMerchantId, m as getSupportedLocale, n as FrakEvent, o as FullSsoParams, p as findIframeInOpener, r as trackEvent, s as generateSsoUrl, t as computeLegacyProductId, u as resolveMerchantId, v as FrakContextManager, w as DEEP_LINK_SCHEME, x as isFrakDeepLink, y as DeepLinkFallbackOptions, z as CompressedData } from "./computeLegacyProductId-fl_Sx8v5.cjs";
1
+ import { A as SiweAuthenticateReturnType, B as ModalStepMetadata, C as ModalRpcStepsInput, D as SendTransactionReturnType, E as SendTransactionModalStepType, F as PrepareSsoParamsType, G as FrakWalletSdkConfig, H as IFrameLifecycleEvent, I as PrepareSsoReturnType, J as LocalizedI18nConfig, K as I18nConfig, L as SsoMetadata, M as LoginModalStepType, N as OpenSsoParamsType, O as SendTransactionTxType, P as OpenSsoReturnType, R as FinalActionType, S as ModalRpcMetadata, T as ModalStepTypes, U as ClientLifecycleEvent, V as InteractionTypeKey, W as Currency, _ as LoggedOutEmbeddedView, a as FrakClient, b as LoggedInEmbeddedView, c as IFrameRpcSchema, d as GetMerchantInformationReturnType, f as RewardTier, g as DisplayEmbeddedWalletResultType, h as DisplayEmbeddedWalletParamsType, i as FrakContext, j as SiweAuthenticationParams, k as SiweAuthenticateModalStepType, l as WalletStatusReturnType, m as SendInteractionParamsType, n as ssoPopupFeatures, o as FrakLifecycleEvent, p as TokenAmountType, q as Language, r as ssoPopupName, s as IFrameTransport, u as EstimatedReward, v as EmbeddedViewActionReferred, w as ModalRpcStepsResultType, x as DisplayModalParamsType, y as EmbeddedViewActionSharing, z as FinalModalStepType } from "./openSso-DTFns_5E.cjs";
2
+ import { A as getBackendUrl, B as HashProtectedData, C as triggerDeepLinkWithFallback, D as base64urlDecode, E as compressJsonToB64, F as createIFrameFrakClient, I as TrackArrivalParams, L as TrackArrivalResult, M as locales, N as setupClient, O as base64urlEncode, P as DebugInfoGatherer, R as UtmParams, S as toAndroidIntentUrl, T as decompressJsonFromB64, V as KeyProvider, _ as formatAmount, a as CompressedSsoData, b as isChromiumAndroid, c as clearMerchantIdCache, d as baseIframeProps, f as createIframe, g as getCurrencyAmountKey, h as getSupportedCurrency, i as AppSpecificSsoMetadata, j as LocalesKey, k as getClientId, l as fetchMerchantId, m as getSupportedLocale, n as FrakEvent, o as FullSsoParams, p as findIframeInOpener, r as trackEvent, s as generateSsoUrl, t as computeLegacyProductId, u as resolveMerchantId, v as FrakContextManager, w as DEEP_LINK_SCHEME, x as isFrakDeepLink, y as DeepLinkFallbackOptions, z as CompressedData } from "./computeLegacyProductId-B-2-L7VT.cjs";
3
3
  export { type AppSpecificSsoMetadata, type ClientLifecycleEvent, type CompressedData, type CompressedSsoData, type Currency, DEEP_LINK_SCHEME, DebugInfoGatherer, type DeepLinkFallbackOptions, type DisplayEmbeddedWalletParamsType, type DisplayEmbeddedWalletResultType, type DisplayModalParamsType, type EmbeddedViewActionReferred, type EmbeddedViewActionSharing, type EstimatedReward, type FinalActionType, type FinalModalStepType, type FrakClient, type FrakContext, FrakContextManager, type FrakEvent, type FrakLifecycleEvent, type FrakWalletSdkConfig, type FullSsoParams, type GetMerchantInformationReturnType, type HashProtectedData, type I18nConfig, type IFrameLifecycleEvent, type IFrameRpcSchema, type IFrameTransport, type InteractionTypeKey, type KeyProvider, type Language, type LocalesKey, type LocalizedI18nConfig, type LoggedInEmbeddedView, type LoggedOutEmbeddedView, type LoginModalStepType, type ModalRpcMetadata, type ModalRpcStepsInput, type ModalRpcStepsResultType, type ModalStepMetadata, type ModalStepTypes, type OpenSsoParamsType, type OpenSsoReturnType, type PrepareSsoParamsType, type PrepareSsoReturnType, type RewardTier, type SendInteractionParamsType, type SendTransactionModalStepType, type SendTransactionReturnType, type SendTransactionTxType, type SiweAuthenticateModalStepType, type SiweAuthenticateReturnType, type SiweAuthenticationParams, type SsoMetadata, type TokenAmountType, type TrackArrivalParams, type TrackArrivalResult, type UtmParams, type WalletStatusReturnType, base64urlDecode, base64urlEncode, baseIframeProps, clearMerchantIdCache, compressJsonToB64, computeLegacyProductId, createIFrameFrakClient, createIframe, decompressJsonFromB64, fetchMerchantId, findIframeInOpener, formatAmount, generateSsoUrl, getBackendUrl, getClientId, getCurrencyAmountKey, getSupportedCurrency, getSupportedLocale, isChromiumAndroid, isFrakDeepLink, locales, resolveMerchantId, setupClient, ssoPopupFeatures, ssoPopupName, toAndroidIntentUrl, trackEvent, triggerDeepLinkWithFallback };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { A as SiweAuthenticateReturnType, B as ModalStepMetadata, C as ModalRpcStepsInput, D as SendTransactionReturnType, E as SendTransactionModalStepType, F as PrepareSsoParamsType, G as FrakWalletSdkConfig, H as IFrameLifecycleEvent, I as PrepareSsoReturnType, J as LocalizedI18nConfig, K as I18nConfig, L as SsoMetadata, M as LoginModalStepType, N as OpenSsoParamsType, O as SendTransactionTxType, P as OpenSsoReturnType, R as FinalActionType, S as ModalRpcMetadata, T as ModalStepTypes, U as ClientLifecycleEvent, V as InteractionTypeKey, W as Currency, _ as LoggedOutEmbeddedView, a as FrakClient, b as LoggedInEmbeddedView, c as IFrameRpcSchema, d as GetMerchantInformationReturnType, f as RewardTier, g as DisplayEmbeddedWalletResultType, h as DisplayEmbeddedWalletParamsType, i as FrakContext, j as SiweAuthenticationParams, k as SiweAuthenticateModalStepType, l as WalletStatusReturnType, m as SendInteractionParamsType, n as ssoPopupFeatures, o as FrakLifecycleEvent, p as TokenAmountType, q as Language, r as ssoPopupName, s as IFrameTransport, u as EstimatedReward, v as EmbeddedViewActionReferred, w as ModalRpcStepsResultType, x as DisplayModalParamsType, y as EmbeddedViewActionSharing, z as FinalModalStepType } from "./openSso-tkqaDQLV.js";
2
- import { A as getBackendUrl, B as HashProtectedData, C as triggerDeepLinkWithFallback, D as base64urlDecode, E as compressJsonToB64, F as createIFrameFrakClient, I as TrackArrivalParams, L as TrackArrivalResult, M as locales, N as setupClient, O as base64urlEncode, P as DebugInfoGatherer, R as UtmParams, S as toAndroidIntentUrl, T as decompressJsonFromB64, V as KeyProvider, _ as formatAmount, a as CompressedSsoData, b as isChromiumAndroid, c as clearMerchantIdCache, d as baseIframeProps, f as createIframe, g as getCurrencyAmountKey, h as getSupportedCurrency, i as AppSpecificSsoMetadata, j as LocalesKey, k as getClientId, l as fetchMerchantId, m as getSupportedLocale, n as FrakEvent, o as FullSsoParams, p as findIframeInOpener, r as trackEvent, s as generateSsoUrl, t as computeLegacyProductId, u as resolveMerchantId, v as FrakContextManager, w as DEEP_LINK_SCHEME, x as isFrakDeepLink, y as DeepLinkFallbackOptions, z as CompressedData } from "./computeLegacyProductId-CSSiQO4V.js";
1
+ import { A as SiweAuthenticateReturnType, B as ModalStepMetadata, C as ModalRpcStepsInput, D as SendTransactionReturnType, E as SendTransactionModalStepType, F as PrepareSsoParamsType, G as FrakWalletSdkConfig, H as IFrameLifecycleEvent, I as PrepareSsoReturnType, J as LocalizedI18nConfig, K as I18nConfig, L as SsoMetadata, M as LoginModalStepType, N as OpenSsoParamsType, O as SendTransactionTxType, P as OpenSsoReturnType, R as FinalActionType, S as ModalRpcMetadata, T as ModalStepTypes, U as ClientLifecycleEvent, V as InteractionTypeKey, W as Currency, _ as LoggedOutEmbeddedView, a as FrakClient, b as LoggedInEmbeddedView, c as IFrameRpcSchema, d as GetMerchantInformationReturnType, f as RewardTier, g as DisplayEmbeddedWalletResultType, h as DisplayEmbeddedWalletParamsType, i as FrakContext, j as SiweAuthenticationParams, k as SiweAuthenticateModalStepType, l as WalletStatusReturnType, m as SendInteractionParamsType, n as ssoPopupFeatures, o as FrakLifecycleEvent, p as TokenAmountType, q as Language, r as ssoPopupName, s as IFrameTransport, u as EstimatedReward, v as EmbeddedViewActionReferred, w as ModalRpcStepsResultType, x as DisplayModalParamsType, y as EmbeddedViewActionSharing, z as FinalModalStepType } from "./openSso-DXL8K2tc.js";
2
+ import { A as getBackendUrl, B as HashProtectedData, C as triggerDeepLinkWithFallback, D as base64urlDecode, E as compressJsonToB64, F as createIFrameFrakClient, I as TrackArrivalParams, L as TrackArrivalResult, M as locales, N as setupClient, O as base64urlEncode, P as DebugInfoGatherer, R as UtmParams, S as toAndroidIntentUrl, T as decompressJsonFromB64, V as KeyProvider, _ as formatAmount, a as CompressedSsoData, b as isChromiumAndroid, c as clearMerchantIdCache, d as baseIframeProps, f as createIframe, g as getCurrencyAmountKey, h as getSupportedCurrency, i as AppSpecificSsoMetadata, j as LocalesKey, k as getClientId, l as fetchMerchantId, m as getSupportedLocale, n as FrakEvent, o as FullSsoParams, p as findIframeInOpener, r as trackEvent, s as generateSsoUrl, t as computeLegacyProductId, u as resolveMerchantId, v as FrakContextManager, w as DEEP_LINK_SCHEME, x as isFrakDeepLink, y as DeepLinkFallbackOptions, z as CompressedData } from "./computeLegacyProductId-M9k7vnUf.js";
3
3
  export { type AppSpecificSsoMetadata, type ClientLifecycleEvent, type CompressedData, type CompressedSsoData, type Currency, DEEP_LINK_SCHEME, DebugInfoGatherer, type DeepLinkFallbackOptions, type DisplayEmbeddedWalletParamsType, type DisplayEmbeddedWalletResultType, type DisplayModalParamsType, type EmbeddedViewActionReferred, type EmbeddedViewActionSharing, type EstimatedReward, type FinalActionType, type FinalModalStepType, type FrakClient, type FrakContext, FrakContextManager, type FrakEvent, type FrakLifecycleEvent, type FrakWalletSdkConfig, type FullSsoParams, type GetMerchantInformationReturnType, type HashProtectedData, type I18nConfig, type IFrameLifecycleEvent, type IFrameRpcSchema, type IFrameTransport, type InteractionTypeKey, type KeyProvider, type Language, type LocalesKey, type LocalizedI18nConfig, type LoggedInEmbeddedView, type LoggedOutEmbeddedView, type LoginModalStepType, type ModalRpcMetadata, type ModalRpcStepsInput, type ModalRpcStepsResultType, type ModalStepMetadata, type ModalStepTypes, type OpenSsoParamsType, type OpenSsoReturnType, type PrepareSsoParamsType, type PrepareSsoReturnType, type RewardTier, type SendInteractionParamsType, type SendTransactionModalStepType, type SendTransactionReturnType, type SendTransactionTxType, type SiweAuthenticateModalStepType, type SiweAuthenticateReturnType, type SiweAuthenticationParams, type SsoMetadata, type TokenAmountType, type TrackArrivalParams, type TrackArrivalResult, type UtmParams, type WalletStatusReturnType, base64urlDecode, base64urlEncode, baseIframeProps, clearMerchantIdCache, compressJsonToB64, computeLegacyProductId, createIFrameFrakClient, createIframe, decompressJsonFromB64, fetchMerchantId, findIframeInOpener, formatAmount, generateSsoUrl, getBackendUrl, getClientId, getCurrencyAmountKey, getSupportedCurrency, getSupportedLocale, isChromiumAndroid, isFrakDeepLink, locales, resolveMerchantId, setupClient, ssoPopupFeatures, ssoPopupName, toAndroidIntentUrl, trackEvent, triggerDeepLinkWithFallback };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as e,c as t,d as n,f as r,h as i,i as a,l as o,m as s,n as c,o as l,p as u,r as d,t as f,u as p}from"./trackEvent-B0S5E6_h.js";import{_ as m,a as h,c as g,d as _,f as v,g as y,h as b,i as x,l as S,m as C,n as w,o as T,p as E,r as D,s as O,t as k,u as A}from"./setupClient-CO8HTRRE.js";export{m as DEEP_LINK_SCHEME,y as DebugInfoGatherer,e as FrakContextManager,r as base64urlDecode,u as base64urlEncode,S as baseIframeProps,c as clearMerchantIdCache,n as compressJsonToB64,i as computeLegacyProductId,g as createIFrameFrakClient,A as createIframe,O as decompressJsonFromB64,d as fetchMerchantId,_ as findIframeInOpener,D as formatAmount,p as generateSsoUrl,l as getBackendUrl,s as getClientId,w as getCurrencyAmountKey,h as getSupportedCurrency,x as getSupportedLocale,v as isChromiumAndroid,E as isFrakDeepLink,T as locales,a as resolveMerchantId,k as setupClient,t as ssoPopupFeatures,o as ssoPopupName,C as toAndroidIntentUrl,f as trackEvent,b as triggerDeepLinkWithFallback};
1
+ import{a as e,c as t,d as n,f as r,h as i,i as a,l as o,m as s,n as c,o as l,p as u,r as d,t as f,u as p}from"./trackEvent-BXs0TMuA.js";import{_ as m,a as h,c as g,d as _,f as v,g as y,h as b,i as x,l as S,m as C,n as w,o as T,p as E,r as D,s as O,t as k,u as A}from"./setupClient-UMz34Dmb.js";export{y as DEEP_LINK_SCHEME,D as DebugInfoGatherer,e as FrakContextManager,r as base64urlDecode,u as base64urlEncode,x as baseIframeProps,c as clearMerchantIdCache,n as compressJsonToB64,i as computeLegacyProductId,w as createIFrameFrakClient,h as createIframe,m as decompressJsonFromB64,d as fetchMerchantId,T as findIframeInOpener,g as formatAmount,p as generateSsoUrl,l as getBackendUrl,s as getClientId,O as getCurrencyAmountKey,A as getSupportedCurrency,S as getSupportedLocale,v as isChromiumAndroid,E as isFrakDeepLink,_ as locales,a as resolveMerchantId,k as setupClient,t as ssoPopupFeatures,o as ssoPopupName,C as toAndroidIntentUrl,f as trackEvent,b as triggerDeepLinkWithFallback};
@@ -895,11 +895,14 @@ type IFrameRpcSchema = [
895
895
  /**
896
896
  * Method to send interactions (arrival, sharing, custom events)
897
897
  * Fire-and-forget method - no return value expected
898
- * merchantId and clientId are resolved from context
898
+ * merchantId is resolved from context
899
+ * clientId is passed via metadata as safeguard against handshake race condition
899
900
  */
900
901
  {
901
902
  Method: "frak_sendInteraction";
902
- Parameters: [interaction: SendInteractionParamsType];
903
+ Parameters: [interaction: SendInteractionParamsType, metadata?: {
904
+ clientId?: string;
905
+ }];
903
906
  ReturnType: undefined;
904
907
  }];
905
908
  //#endregion
@@ -895,11 +895,14 @@ type IFrameRpcSchema = [
895
895
  /**
896
896
  * Method to send interactions (arrival, sharing, custom events)
897
897
  * Fire-and-forget method - no return value expected
898
- * merchantId and clientId are resolved from context
898
+ * merchantId is resolved from context
899
+ * clientId is passed via metadata as safeguard against handshake race condition
899
900
  */
900
901
  {
901
902
  Method: "frak_sendInteraction";
902
- Parameters: [interaction: SendInteractionParamsType];
903
+ Parameters: [interaction: SendInteractionParamsType, metadata?: {
904
+ clientId?: string;
905
+ }];
903
906
  ReturnType: undefined;
904
907
  }];
905
908
  //#endregion
@@ -0,0 +1,13 @@
1
+ import{f as e,m as t}from"./trackEvent-BXs0TMuA.js";import{Deferred as n,FrakRpcError as r,RpcErrorCodes as i,createRpcClient as a,jsonDecode as o}from"@frak-labs/frame-connector";import{OpenPanel as s}from"@openpanel/web";function c(t){return o(e(t))}const l=`nexus-wallet-backup`,u=`frakwallet://`;function d(){let e=navigator.userAgent;return/Android/i.test(e)&&/Chrome\/\d+/i.test(e)}function f(e){return`intent://${e.slice(13)}#Intent;scheme=frakwallet;end`}function p(e,t){let n=t?.timeout??2500,r=!1,i=()=>{document.hidden&&(r=!0)};document.addEventListener(`visibilitychange`,i);let a=d()&&m(e)?f(e):e;window.location.href=a,setTimeout(()=>{document.removeEventListener(`visibilitychange`,i),r||t?.onFallback?.()},n)}function m(e){return e.startsWith(u)}const h={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function g(e){return e&&e in h?e:`eur`}function _(e){return e?h[e]??h.eur:h.eur}function v(e,t){let n=_(t),r=g(t);return e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function y(e){return e?`${e}Amount`:`eurAmount`}const b={id:`frak-wallet`,name:`frak-wallet`,title:`Frak Wallet`,allow:`publickey-credentials-get *; clipboard-write; web-share *`,style:{width:`0`,height:`0`,border:`0`,position:`absolute`,zIndex:2000001,top:`-1000px`,left:`-1000px`,colorScheme:`auto`}};function x({walletBaseUrl:e,config:t}){let n=document.querySelector(`#frak-wallet`);n&&n.remove();let r=document.createElement(`iframe`);return r.id=b.id,r.name=b.name,r.allow=b.allow,r.style.zIndex=b.style.zIndex.toString(),S({iframe:r,isVisible:!1}),r.src=`${t?.walletUrl??e??`https://wallet.frak.id`}/listener`,new Promise(e=>{r.addEventListener(`load`,()=>e(r)),document.body.appendChild(r)})}function S({iframe:e,isVisible:t}){if(!t){e.style.width=`0`,e.style.height=`0`,e.style.border=`0`,e.style.position=`fixed`,e.style.top=`-1000px`,e.style.left=`-1000px`;return}e.style.position=`fixed`,e.style.top=`0`,e.style.left=`0`,e.style.width=`100%`,e.style.height=`100%`,e.style.pointerEvents=`auto`}function C(e=`/listener`){if(!window.opener)return null;let t=t=>{try{return t.location.origin===window.location.origin&&t.location.pathname===e}catch{return!1}};if(t(window.opener))return window.opener;try{let e=window.opener.frames;for(let n=0;n<e.length;n++)if(t(e[n]))return e[n];return null}catch(t){return console.error(`[findIframeInOpener] Error finding iframe with pathname ${e}:`,t),null}}function w(e,t){if(typeof window>`u`)return;let n=new URL(window.location.href),r=n.searchParams.get(`sso`);r&&(t.then(()=>{e.sendLifecycle({clientLifecycle:`sso-redirect-complete`,data:{compressed:r}}),console.log(`[SSO URL Listener] Forwarded compressed SSO data to iframe`)}).catch(e=>{console.error(`[SSO URL Listener] Failed to forward SSO data:`,e)}),n.searchParams.delete(`sso`),window.history.replaceState({},``,n.toString()),console.log(`[SSO URL Listener] SSO parameter detected and URL cleaned`))}var T=class e{config;iframe;isSetupDone=!1;lastResponse=null;lastRequest=null;constructor(e,t){this.config=e,this.iframe=t,this.lastRequest=null,this.lastResponse=null}setLastResponse(e,t){this.lastResponse={message:e,response:t,timestamp:Date.now()}}setLastRequest(e){this.lastRequest={event:e,timestamp:Date.now()}}updateSetupStatus(e){this.isSetupDone=e}base64Encode(e){try{return btoa(JSON.stringify(e))}catch(e){return console.warn(`Failed to encode debug data`,e),btoa(`Failed to encode data`)}}getIframeStatus(){return this.iframe?{loading:this.iframe.hasAttribute(`loading`),url:this.iframe.src,readyState:this.iframe.contentDocument?.readyState?this.iframe.contentDocument.readyState===`complete`?1:0:-1,contentWindow:!!this.iframe.contentWindow,isConnected:this.iframe.isConnected}:null}getNavigatorInfo(){return navigator?{userAgent:navigator.userAgent,language:navigator.language,onLine:navigator.onLine,screenWidth:window.screen.width,screenHeight:window.screen.height,pixelRatio:window.devicePixelRatio}:null}gatherDebugInfo(e){let t=this.getIframeStatus(),n=this.getNavigatorInfo(),i=`Unknown`;return e instanceof r?i=`FrakRpcError: ${e.code} '${e.message}'`:e instanceof Error?i=e.message:typeof e==`string`&&(i=e),{timestamp:new Date().toISOString(),encodedUrl:btoa(window.location.href),encodedConfig:this.config?this.base64Encode(this.config):`no-config`,navigatorInfo:n?this.base64Encode(n):`no-navigator`,iframeStatus:t?this.base64Encode(t):`not-iframe`,lastRequest:this.lastRequest?this.base64Encode(this.lastRequest):`No Frak request logged`,lastResponse:this.lastResponse?this.base64Encode(this.lastResponse):`No Frak response logged`,clientStatus:this.isSetupDone?`setup`:`not-setup`,error:i}}static empty(){return new e}formatDebugInfo(e){let t=this.gatherDebugInfo(e);return`
2
+ Debug Information:
3
+ -----------------
4
+ Timestamp: ${t.timestamp}
5
+ URL: ${t.encodedUrl}
6
+ Config: ${t.encodedConfig}
7
+ Navigator Info: ${t.navigatorInfo}
8
+ IFrame Status: ${t.iframeStatus}
9
+ Last Request: ${t.lastRequest}
10
+ Last Response: ${t.lastResponse}
11
+ Client Status: ${t.clientStatus}
12
+ Error: ${t.error}
13
+ `.trim()}};const E=(()=>{if(typeof navigator>`u`)return!1;let e=navigator.userAgent;if(!(/iPhone|iPad|iPod/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1))return!1;let t=e.toLowerCase();return t.includes(`instagram`)||t.includes(`fban`)||t.includes(`fbav`)||t.includes(`facebook`)})();function D(e){e?localStorage.setItem(l,e):localStorage.removeItem(l)}function O(e,n,r,i){let a=new URL(window.location.href),o=a.searchParams.get(`fmt`)??void 0;e.contentWindow?.postMessage({clientLifecycle:`handshake-response`,data:{token:n,currentUrl:window.location.href,clientId:t(),pendingMergeToken:o,configDomain:i}},r),o&&(a.searchParams.delete(`fmt`),window.history.replaceState({},``,a.toString()))}function k(e,t){try{let n=new URL(e);return n.searchParams.has(`u`)?(n.searchParams.delete(`u`),n.searchParams.append(`u`,window.location.href),t&&n.searchParams.append(`fmt`,t),n.toString()):e}catch{return e}}function A(e){let t=new URL(window.location.href);e&&t.searchParams.set(`fmt`,e);let n=t.protocol===`http:`?`x-safari-http`:`x-safari-https`;window.location.href=`${n}://${t.host}${t.pathname}${t.search}${t.hash}`}function j(e){return e.includes(`/common/social`)}function M(e,t,n,r){if(m(t)){let i=k(t,r);p(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}})}else if(E&&j(t))A(r);else{let e=k(t,r);window.location.href=e}}function N({iframe:e,targetOrigin:t,configDomain:r}){let i=new n;return{handleEvent:async n=>{if(!(`iframeLifecycle`in n))return;let{iframeLifecycle:a,data:o}=n;switch(a){case`connected`:i.resolve(!0);break;case`do-backup`:D(o.backup);break;case`remove-backup`:localStorage.removeItem(l);break;case`show`:case`hide`:S({iframe:e,isVisible:a===`show`});break;case`handshake`:O(e,o.token,t,r);break;case`redirect`:M(e,o.baseRedirectUrl,t,o.mergeToken);break}},isConnected:i.promise}}function P({config:e,iframe:n}){let o=e?.walletUrl??`https://wallet.frak.id`;t();let c=N({iframe:n,targetOrigin:o,configDomain:e.domain}),l=new T(e,n);if(!n.contentWindow)throw new r(i.configError,`The iframe does not have a content window`);let u=a({emittingTransport:n.contentWindow,listeningTransport:window,targetOrigin:o,middleware:[{async onRequest(e,t){if(!await c.isConnected)throw new r(i.clientNotConnected,`The iframe provider isn't connected yet`);return t}},{onRequest(e,t){return l.setLastRequest(e),t},onResponse(e,t){return l.setLastResponse(e,t),t}}],lifecycleHandlers:{iframeLifecycle:async(e,t)=>{await c.handleEvent(e)}}}),d=F(u,c),f=async()=>{d(),u.cleanup(),n.remove()},p;console.log(`[Frak SDK] Initializing OpenPanel`),p=new s({apiUrl:`https://op-api.gcp.frak.id`,clientId:`6eacc8d7-49ac-4936-95e9-81ef29449570`,trackScreenViews:!0,trackOutgoingLinks:!0,trackAttributes:!1,filter:({type:e,payload:n})=>(e!==`track`||!n?.properties||`sdkVersion`in n.properties||(n.properties={...n.properties,sdkVersion:`0.1.1`,userAnonymousClientId:t()}),!0)}),p.setGlobalProperties({sdkVersion:`0.1.1`,userAnonymousClientId:t()}),p.init();let m=I({config:e,rpcClient:u,lifecycleManager:c}).then(()=>l.updateSetupStatus(!0));return{config:e,debugInfo:l,waitForConnection:c.isConnected,waitForSetup:m,request:u.request,listenerRequest:u.listen,destroy:f,openPanel:p}}function F(e,t){let n,r,i=()=>e.sendLifecycle({clientLifecycle:`heartbeat`});async function a(){i(),n=setInterval(i,1e3),r=setTimeout(()=>{o(),console.log(`Heartbeat timeout: connection failed`)},3e4),await t.isConnected,o()}function o(){n&&clearInterval(n),r&&clearTimeout(r)}return a(),o}async function I({config:e,rpcClient:t,lifecycleManager:n}){await n.isConnected,w(t,n.isConnected);async function r(){let n=e.customizations?.css;if(!n)return;let r={clientLifecycle:`modal-css`,data:{cssLink:n}};t.sendLifecycle(r)}async function i(){let n=e.customizations?.i18n;if(!n)return;let r={clientLifecycle:`modal-i18n`,data:{i18n:n}};t.sendLifecycle(r)}async function a(){if(typeof window>`u`)return;let e=window.localStorage.getItem(l);if(!e)return;let n={clientLifecycle:`restore-backup`,data:{backup:e}};t.sendLifecycle(n)}await Promise.allSettled([r(),i(),a()])}async function L({config:e}){let t=R(e),n=await x({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=P({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error(`Failed to connect to client`);return}return r}function R(e){let t=g(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}export{c as _,x as a,v as c,h as d,d as f,u as g,p as h,b as i,_ as l,f as m,P as n,C as o,m as p,T as r,y as s,L as t,g as u};
@@ -0,0 +1,13 @@
1
+ const e=require(`./trackEvent-2_5BW61g.cjs`);let t=require(`@frak-labs/frame-connector`),n=require(`@openpanel/web`);function r(n){return(0,t.jsonDecode)(e.f(n))}const i=`nexus-wallet-backup`,a=`frakwallet://`;function o(){let e=navigator.userAgent;return/Android/i.test(e)&&/Chrome\/\d+/i.test(e)}function s(e){return`intent://${e.slice(13)}#Intent;scheme=frakwallet;end`}function c(e,t){let n=t?.timeout??2500,r=!1,i=()=>{document.hidden&&(r=!0)};document.addEventListener(`visibilitychange`,i);let a=o()&&l(e)?s(e):e;window.location.href=a,setTimeout(()=>{document.removeEventListener(`visibilitychange`,i),r||t?.onFallback?.()},n)}function l(e){return e.startsWith(a)}const u={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function d(e){return e&&e in u?e:`eur`}function f(e){return e?u[e]??u.eur:u.eur}function p(e,t){let n=f(t),r=d(t);return e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function m(e){return e?`${e}Amount`:`eurAmount`}const h={id:`frak-wallet`,name:`frak-wallet`,title:`Frak Wallet`,allow:`publickey-credentials-get *; clipboard-write; web-share *`,style:{width:`0`,height:`0`,border:`0`,position:`absolute`,zIndex:2000001,top:`-1000px`,left:`-1000px`,colorScheme:`auto`}};function g({walletBaseUrl:e,config:t}){let n=document.querySelector(`#frak-wallet`);n&&n.remove();let r=document.createElement(`iframe`);return r.id=h.id,r.name=h.name,r.allow=h.allow,r.style.zIndex=h.style.zIndex.toString(),_({iframe:r,isVisible:!1}),r.src=`${t?.walletUrl??e??`https://wallet.frak.id`}/listener`,new Promise(e=>{r.addEventListener(`load`,()=>e(r)),document.body.appendChild(r)})}function _({iframe:e,isVisible:t}){if(!t){e.style.width=`0`,e.style.height=`0`,e.style.border=`0`,e.style.position=`fixed`,e.style.top=`-1000px`,e.style.left=`-1000px`;return}e.style.position=`fixed`,e.style.top=`0`,e.style.left=`0`,e.style.width=`100%`,e.style.height=`100%`,e.style.pointerEvents=`auto`}function v(e=`/listener`){if(!window.opener)return null;let t=t=>{try{return t.location.origin===window.location.origin&&t.location.pathname===e}catch{return!1}};if(t(window.opener))return window.opener;try{let e=window.opener.frames;for(let n=0;n<e.length;n++)if(t(e[n]))return e[n];return null}catch(t){return console.error(`[findIframeInOpener] Error finding iframe with pathname ${e}:`,t),null}}function y(e,t){if(typeof window>`u`)return;let n=new URL(window.location.href),r=n.searchParams.get(`sso`);r&&(t.then(()=>{e.sendLifecycle({clientLifecycle:`sso-redirect-complete`,data:{compressed:r}}),console.log(`[SSO URL Listener] Forwarded compressed SSO data to iframe`)}).catch(e=>{console.error(`[SSO URL Listener] Failed to forward SSO data:`,e)}),n.searchParams.delete(`sso`),window.history.replaceState({},``,n.toString()),console.log(`[SSO URL Listener] SSO parameter detected and URL cleaned`))}var b=class e{config;iframe;isSetupDone=!1;lastResponse=null;lastRequest=null;constructor(e,t){this.config=e,this.iframe=t,this.lastRequest=null,this.lastResponse=null}setLastResponse(e,t){this.lastResponse={message:e,response:t,timestamp:Date.now()}}setLastRequest(e){this.lastRequest={event:e,timestamp:Date.now()}}updateSetupStatus(e){this.isSetupDone=e}base64Encode(e){try{return btoa(JSON.stringify(e))}catch(e){return console.warn(`Failed to encode debug data`,e),btoa(`Failed to encode data`)}}getIframeStatus(){return this.iframe?{loading:this.iframe.hasAttribute(`loading`),url:this.iframe.src,readyState:this.iframe.contentDocument?.readyState?this.iframe.contentDocument.readyState===`complete`?1:0:-1,contentWindow:!!this.iframe.contentWindow,isConnected:this.iframe.isConnected}:null}getNavigatorInfo(){return navigator?{userAgent:navigator.userAgent,language:navigator.language,onLine:navigator.onLine,screenWidth:window.screen.width,screenHeight:window.screen.height,pixelRatio:window.devicePixelRatio}:null}gatherDebugInfo(e){let n=this.getIframeStatus(),r=this.getNavigatorInfo(),i=`Unknown`;return e instanceof t.FrakRpcError?i=`FrakRpcError: ${e.code} '${e.message}'`:e instanceof Error?i=e.message:typeof e==`string`&&(i=e),{timestamp:new Date().toISOString(),encodedUrl:btoa(window.location.href),encodedConfig:this.config?this.base64Encode(this.config):`no-config`,navigatorInfo:r?this.base64Encode(r):`no-navigator`,iframeStatus:n?this.base64Encode(n):`not-iframe`,lastRequest:this.lastRequest?this.base64Encode(this.lastRequest):`No Frak request logged`,lastResponse:this.lastResponse?this.base64Encode(this.lastResponse):`No Frak response logged`,clientStatus:this.isSetupDone?`setup`:`not-setup`,error:i}}static empty(){return new e}formatDebugInfo(e){let t=this.gatherDebugInfo(e);return`
2
+ Debug Information:
3
+ -----------------
4
+ Timestamp: ${t.timestamp}
5
+ URL: ${t.encodedUrl}
6
+ Config: ${t.encodedConfig}
7
+ Navigator Info: ${t.navigatorInfo}
8
+ IFrame Status: ${t.iframeStatus}
9
+ Last Request: ${t.lastRequest}
10
+ Last Response: ${t.lastResponse}
11
+ Client Status: ${t.clientStatus}
12
+ Error: ${t.error}
13
+ `.trim()}};const x=(()=>{if(typeof navigator>`u`)return!1;let e=navigator.userAgent;if(!(/iPhone|iPad|iPod/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1))return!1;let t=e.toLowerCase();return t.includes(`instagram`)||t.includes(`fban`)||t.includes(`fbav`)||t.includes(`facebook`)})();function S(e){e?localStorage.setItem(i,e):localStorage.removeItem(i)}function C(t,n,r,i){let a=new URL(window.location.href),o=a.searchParams.get(`fmt`)??void 0;t.contentWindow?.postMessage({clientLifecycle:`handshake-response`,data:{token:n,currentUrl:window.location.href,clientId:e.m(),pendingMergeToken:o,configDomain:i}},r),o&&(a.searchParams.delete(`fmt`),window.history.replaceState({},``,a.toString()))}function w(e,t){try{let n=new URL(e);return n.searchParams.has(`u`)?(n.searchParams.delete(`u`),n.searchParams.append(`u`,window.location.href),t&&n.searchParams.append(`fmt`,t),n.toString()):e}catch{return e}}function T(e){let t=new URL(window.location.href);e&&t.searchParams.set(`fmt`,e);let n=t.protocol===`http:`?`x-safari-http`:`x-safari-https`;window.location.href=`${n}://${t.host}${t.pathname}${t.search}${t.hash}`}function E(e){return e.includes(`/common/social`)}function D(e,t,n,r){if(l(t)){let i=w(t,r);c(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}})}else if(x&&E(t))T(r);else{let e=w(t,r);window.location.href=e}}function O({iframe:e,targetOrigin:n,configDomain:r}){let a=new t.Deferred;return{handleEvent:async t=>{if(!(`iframeLifecycle`in t))return;let{iframeLifecycle:o,data:s}=t;switch(o){case`connected`:a.resolve(!0);break;case`do-backup`:S(s.backup);break;case`remove-backup`:localStorage.removeItem(i);break;case`show`:case`hide`:_({iframe:e,isVisible:o===`show`});break;case`handshake`:C(e,s.token,n,r);break;case`redirect`:D(e,s.baseRedirectUrl,n,s.mergeToken);break}},isConnected:a.promise}}function k({config:r,iframe:i}){let a=r?.walletUrl??`https://wallet.frak.id`;e.m();let o=O({iframe:i,targetOrigin:a,configDomain:r.domain}),s=new b(r,i);if(!i.contentWindow)throw new t.FrakRpcError(t.RpcErrorCodes.configError,`The iframe does not have a content window`);let c=(0,t.createRpcClient)({emittingTransport:i.contentWindow,listeningTransport:window,targetOrigin:a,middleware:[{async onRequest(e,n){if(!await o.isConnected)throw new t.FrakRpcError(t.RpcErrorCodes.clientNotConnected,`The iframe provider isn't connected yet`);return n}},{onRequest(e,t){return s.setLastRequest(e),t},onResponse(e,t){return s.setLastResponse(e,t),t}}],lifecycleHandlers:{iframeLifecycle:async(e,t)=>{await o.handleEvent(e)}}}),l=A(c,o),u=async()=>{l(),c.cleanup(),i.remove()},d;console.log(`[Frak SDK] Initializing OpenPanel`),d=new n.OpenPanel({apiUrl:`https://op-api.gcp.frak.id`,clientId:`6eacc8d7-49ac-4936-95e9-81ef29449570`,trackScreenViews:!0,trackOutgoingLinks:!0,trackAttributes:!1,filter:({type:t,payload:n})=>(t!==`track`||!n?.properties||`sdkVersion`in n.properties||(n.properties={...n.properties,sdkVersion:`0.1.1`,userAnonymousClientId:e.m()}),!0)}),d.setGlobalProperties({sdkVersion:`0.1.1`,userAnonymousClientId:e.m()}),d.init();let f=j({config:r,rpcClient:c,lifecycleManager:o}).then(()=>s.updateSetupStatus(!0));return{config:r,debugInfo:s,waitForConnection:o.isConnected,waitForSetup:f,request:c.request,listenerRequest:c.listen,destroy:u,openPanel:d}}function A(e,t){let n,r,i=()=>e.sendLifecycle({clientLifecycle:`heartbeat`});async function a(){i(),n=setInterval(i,1e3),r=setTimeout(()=>{o(),console.log(`Heartbeat timeout: connection failed`)},3e4),await t.isConnected,o()}function o(){n&&clearInterval(n),r&&clearTimeout(r)}return a(),o}async function j({config:e,rpcClient:t,lifecycleManager:n}){await n.isConnected,y(t,n.isConnected);async function r(){let n=e.customizations?.css;if(!n)return;let r={clientLifecycle:`modal-css`,data:{cssLink:n}};t.sendLifecycle(r)}async function a(){let n=e.customizations?.i18n;if(!n)return;let r={clientLifecycle:`modal-i18n`,data:{i18n:n}};t.sendLifecycle(r)}async function o(){if(typeof window>`u`)return;let e=window.localStorage.getItem(i);if(!e)return;let n={clientLifecycle:`restore-backup`,data:{backup:e}};t.sendLifecycle(n)}await Promise.allSettled([r(),a(),o()])}async function M({config:e}){let t=N(e),n=await g({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=k({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error(`Failed to connect to client`);return}return r}function N(e){let t=d(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return d}});
@@ -0,0 +1 @@
1
+ const e=require(`./trackEvent-2_5BW61g.cjs`);let t=require(`viem`),n=require(`@frak-labs/frame-connector`),r=require(`viem/siwe`);async function i(e,t){return await e.request({method:`frak_displayEmbeddedWallet`,params:[t,e.config.metadata]})}async function a(e,{steps:t,metadata:n}){return await e.request({method:`frak_displayModal`,params:[t,n,e.config.metadata]})}async function o(e){return await e.request({method:`frak_getMerchantInformation`})}async function s(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function c(t,n){try{await t.request({method:`frak_sendInteraction`,params:[n,{clientId:e.m()}]})}catch{console.warn(`[Frak SDK] Failed to send interaction:`,n.type)}}async function l(t,{walletStatus:r,frakContext:i,modalConfig:a,options:o}){if(!i?.r)return`no-referrer`;e.t(t,`user_referred_started`,{properties:{referrer:i?.r,walletStatus:r?.key}}),c(t,{type:`arrival`,referrerWallet:i.r,landingUrl:typeof window<`u`?window.location.href:void 0});let s=!1;async function l(){if(!s)return s=!0,d(t,{modalConfig:{...a,loggedIn:{action:{key:`referred`}}},walletStatus:r})}try{let{status:n,currentWallet:a}=await u({initialWalletStatus:r,getFreshWalletStatus:l,frakContext:i});return e.a.replaceUrl({url:window.location?.href,context:o?.alwaysAppendUrl?{r:a}:null}),e.t(t,`user_referred_completed`,{properties:{status:n,referrer:i?.r,wallet:a}}),n}catch(a){return console.log(`Error processing referral`,{error:a}),e.t(t,`user_referred_error`,{properties:{referrer:i?.r,error:a instanceof n.FrakRpcError?`[${a.code}] ${a.name} - ${a.message}`:a instanceof Error?a.message:`undefined`}}),e.a.replaceUrl({url:window.location?.href,context:o?.alwaysAppendUrl?{r:r?.wallet}:null}),f(a)}}async function u({initialWalletStatus:e,getFreshWalletStatus:n,frakContext:r}){let i=e?.wallet;return i||=await n(),i&&(0,t.isAddressEqual)(r.r,i)?{status:`self-referral`,currentWallet:i}:{status:`success`,currentWallet:i}}async function d(e,{modalConfig:t,walletStatus:n}){return n?.key===`connected`?n.wallet??void 0:(await i(e,t??{}))?.wallet??void 0}function f(e){if(e instanceof n.FrakRpcError)switch(e.code){case n.RpcErrorCodes.walletNotConnected:return`no-wallet`;default:return`error`}return`error`}async function p(t,{modalConfig:n,options:r}={}){let i=e.a.parse({url:window.location.href}),a=await h(t);try{return await l(t,{walletStatus:a,frakContext:i,modalConfig:n,options:r})}catch(e){console.warn(`Error processing referral`,{error:e})}}async function m(t){if(typeof window>`u`){console.warn(`[Frak] No window found, can't track purchase`);return}let n=window.sessionStorage.getItem(`frak-wallet-interaction-token`),r=e.m();if(!n&&!r){console.warn(`[Frak] No identity found, skipping purchase check`);return}let i=window.sessionStorage.getItem(`frak-merchant-id`),a=t.merchantId??i??await e.r();if(!a){console.warn(`[Frak] No merchant id found, skipping purchase check`);return}let o={Accept:`application/json`,"Content-Type":`application/json`};n&&(o[`x-wallet-sdk-auth`]=n),r&&(o[`x-frak-client-id`]=r);let s=e.o();await fetch(`${s}/user/track/purchase`,{method:`POST`,headers:o,body:JSON.stringify({customerId:t.customerId,orderId:t.orderId,token:t.token,merchantId:a})})}function h(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(g(e,t),t));let r=new n.Deferred,i=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},n=>{g(e,n),t(n),i||=(r.resolve(n),!0)}),r.promise}function g(e,t){typeof window>`u`||(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function _(e,{metadata:t,login:n}){return v(e,{steps:{login:n??{}},metadata:t})}function v(e,t){function n(n){return v(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return v(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}function i(n,r){return v(e,{...t,steps:{...t.steps,final:{...r,action:{key:`sharing`,options:n}}}})}async function o(n){return n&&(t.metadata=n(t.metadata??{})),await a(e,t)}return{params:t,sendTx:n,reward:r,sharing:i,display:o}}async function y(e,{tx:t,metadata:n}){return(await a(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}async function b(e,{siwe:t,metadata:n}){let i=e.config?.domain??window.location.host,o=t?.statement??`I confirm that I want to use my Frak wallet on: ${e.config.metadata.name}`;return(await a(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:o,nonce:t?.nonce??(0,r.generateSiweNonce)(),uri:t?.uri??`https://${i}`,version:t?.version??`1`,domain:i}}}})).siweAuthenticate}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return o}});
@@ -1,4 +1,4 @@
1
- import { A as SiweAuthenticateReturnType, D as SendTransactionReturnType, E as SendTransactionModalStepType, F as PrepareSsoParamsType, I as PrepareSsoReturnType, M as LoginModalStepType, R as FinalActionType, S as ModalRpcMetadata, T as ModalStepTypes, a as FrakClient, d as GetMerchantInformationReturnType, g as DisplayEmbeddedWalletResultType, h as DisplayEmbeddedWalletParamsType, i as FrakContext, j as SiweAuthenticationParams, l as WalletStatusReturnType, m as SendInteractionParamsType, w as ModalRpcStepsResultType, x as DisplayModalParamsType, z as FinalModalStepType } from "./openSso-tkqaDQLV.js";
1
+ import { A as SiweAuthenticateReturnType, D as SendTransactionReturnType, E as SendTransactionModalStepType, F as PrepareSsoParamsType, I as PrepareSsoReturnType, M as LoginModalStepType, R as FinalActionType, S as ModalRpcMetadata, T as ModalStepTypes, a as FrakClient, d as GetMerchantInformationReturnType, g as DisplayEmbeddedWalletResultType, h as DisplayEmbeddedWalletParamsType, i as FrakContext, j as SiweAuthenticationParams, l as WalletStatusReturnType, m as SendInteractionParamsType, w as ModalRpcStepsResultType, x as DisplayModalParamsType, z as FinalModalStepType } from "./openSso-DXL8K2tc.js";
2
2
 
3
3
  //#region src/actions/displayEmbeddedWallet.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { A as SiweAuthenticateReturnType, D as SendTransactionReturnType, E as SendTransactionModalStepType, F as PrepareSsoParamsType, I as PrepareSsoReturnType, M as LoginModalStepType, R as FinalActionType, S as ModalRpcMetadata, T as ModalStepTypes, a as FrakClient, d as GetMerchantInformationReturnType, g as DisplayEmbeddedWalletResultType, h as DisplayEmbeddedWalletParamsType, i as FrakContext, j as SiweAuthenticationParams, l as WalletStatusReturnType, m as SendInteractionParamsType, w as ModalRpcStepsResultType, x as DisplayModalParamsType, z as FinalModalStepType } from "./openSso-CC1-loUk.cjs";
1
+ import { A as SiweAuthenticateReturnType, D as SendTransactionReturnType, E as SendTransactionModalStepType, F as PrepareSsoParamsType, I as PrepareSsoReturnType, M as LoginModalStepType, R as FinalActionType, S as ModalRpcMetadata, T as ModalStepTypes, a as FrakClient, d as GetMerchantInformationReturnType, g as DisplayEmbeddedWalletResultType, h as DisplayEmbeddedWalletParamsType, i as FrakContext, j as SiweAuthenticationParams, l as WalletStatusReturnType, m as SendInteractionParamsType, w as ModalRpcStepsResultType, x as DisplayModalParamsType, z as FinalModalStepType } from "./openSso-DTFns_5E.cjs";
2
2
 
3
3
  //#region src/actions/displayEmbeddedWallet.d.ts
4
4
  /**
@@ -0,0 +1 @@
1
+ import{a as e,m as t,o as n,r,t as i}from"./trackEvent-BXs0TMuA.js";import{isAddressEqual as a}from"viem";import{Deferred as o,FrakRpcError as s,RpcErrorCodes as c}from"@frak-labs/frame-connector";import{generateSiweNonce as l}from"viem/siwe";async function u(e,t){return await e.request({method:`frak_displayEmbeddedWallet`,params:[t,e.config.metadata]})}async function d(e,{steps:t,metadata:n}){return await e.request({method:`frak_displayModal`,params:[t,n,e.config.metadata]})}async function f(e){return await e.request({method:`frak_getMerchantInformation`})}async function p(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function m(e,n){try{await e.request({method:`frak_sendInteraction`,params:[n,{clientId:t()}]})}catch{console.warn(`[Frak SDK] Failed to send interaction:`,n.type)}}async function h(t,{walletStatus:n,frakContext:r,modalConfig:a,options:o}){if(!r?.r)return`no-referrer`;i(t,`user_referred_started`,{properties:{referrer:r?.r,walletStatus:n?.key}}),m(t,{type:`arrival`,referrerWallet:r.r,landingUrl:typeof window<`u`?window.location.href:void 0});let c=!1;async function l(){if(!c)return c=!0,_(t,{modalConfig:{...a,loggedIn:{action:{key:`referred`}}},walletStatus:n})}try{let{status:a,currentWallet:s}=await g({initialWalletStatus:n,getFreshWalletStatus:l,frakContext:r});return e.replaceUrl({url:window.location?.href,context:o?.alwaysAppendUrl?{r:s}:null}),i(t,`user_referred_completed`,{properties:{status:a,referrer:r?.r,wallet:s}}),a}catch(a){return console.log(`Error processing referral`,{error:a}),i(t,`user_referred_error`,{properties:{referrer:r?.r,error:a instanceof s?`[${a.code}] ${a.name} - ${a.message}`:a instanceof Error?a.message:`undefined`}}),e.replaceUrl({url:window.location?.href,context:o?.alwaysAppendUrl?{r:n?.wallet}:null}),v(a)}}async function g({initialWalletStatus:e,getFreshWalletStatus:t,frakContext:n}){let r=e?.wallet;return r||=await t(),r&&a(n.r,r)?{status:`self-referral`,currentWallet:r}:{status:`success`,currentWallet:r}}async function _(e,{modalConfig:t,walletStatus:n}){return n?.key===`connected`?n.wallet??void 0:(await u(e,t??{}))?.wallet??void 0}function v(e){if(e instanceof s)switch(e.code){case c.walletNotConnected:return`no-wallet`;default:return`error`}return`error`}async function y(t,{modalConfig:n,options:r}={}){let i=e.parse({url:window.location.href}),a=await x(t);try{return await h(t,{walletStatus:a,frakContext:i,modalConfig:n,options:r})}catch(e){console.warn(`Error processing referral`,{error:e})}}async function b(e){if(typeof window>`u`){console.warn(`[Frak] No window found, can't track purchase`);return}let i=window.sessionStorage.getItem(`frak-wallet-interaction-token`),a=t();if(!i&&!a){console.warn(`[Frak] No identity found, skipping purchase check`);return}let o=window.sessionStorage.getItem(`frak-merchant-id`),s=e.merchantId??o??await r();if(!s){console.warn(`[Frak] No merchant id found, skipping purchase check`);return}let c={Accept:`application/json`,"Content-Type":`application/json`};i&&(c[`x-wallet-sdk-auth`]=i),a&&(c[`x-frak-client-id`]=a);let l=n();await fetch(`${l}/user/track/purchase`,{method:`POST`,headers:c,body:JSON.stringify({customerId:e.customerId,orderId:e.orderId,token:e.token,merchantId:s})})}function x(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(S(e,t),t));let n=new o,r=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},i=>{S(e,i),t(i),r||=(n.resolve(i),!0)}),n.promise}function S(e,t){typeof window>`u`||(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function C(e,{metadata:t,login:n}){return w(e,{steps:{login:n??{}},metadata:t})}function w(e,t){function n(n){return w(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return w(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}function i(n,r){return w(e,{...t,steps:{...t.steps,final:{...r,action:{key:`sharing`,options:n}}}})}async function a(n){return n&&(t.metadata=n(t.metadata??{})),await d(e,t)}return{params:t,sendTx:n,reward:r,sharing:i,display:a}}async function T(e,{tx:t,metadata:n}){return(await d(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}async function E(e,{siwe:t,metadata:n}){let r=e.config?.domain??window.location.host,i=t?.statement??`I confirm that I want to use my Frak wallet on: ${e.config.metadata.name}`;return(await d(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:i,nonce:t?.nonce??l(),uri:t?.uri??`https://${r}`,version:t?.version??`1`,domain:r}}}})).siweAuthenticate}export{b as a,m as c,d,u as f,x as i,p as l,T as n,y as o,C as r,h as s,E as t,f as u};
@@ -0,0 +1 @@
1
+ let e=require(`viem`),t=require(`@frak-labs/frame-connector`);function n({domain:t}={}){return(0,e.keccak256)((0,e.toHex)((t??window.location.host).replace(`www.`,``)))}const r=`frak-client-id`;function i(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function a(){if(typeof window>`u`||!window.localStorage)return console.warn(`[Frak SDK] No Window / localStorage available to save the clientId`),i();let e=localStorage.getItem(r);return e||(e=i(),localStorage.setItem(r,e)),e}function o(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function s(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(e.length+(t===0?0:4-t),`=`)),e=>e.charCodeAt(0))}function c(e){return o((0,t.jsonEncode)(e))}function l(e,t,n,r,i,o){let s=c(u({redirectUrl:t.redirectUrl,directExit:t.directExit,lang:t.lang,merchantId:n,metadata:{name:r,css:i,logoUrl:t.metadata?.logoUrl,homepageLink:t.metadata?.homepageLink},clientId:o??a()})),l=new URL(e);return l.pathname=`/sso`,l.searchParams.set(`p`,s),l.toString()}function u(e){return{r:e.redirectUrl,cId:e.clientId,d:e.directExit,l:e.lang,m:e.merchantId,md:{n:e.metadata?.name,css:e.metadata?.css,l:e.metadata?.logoUrl,h:e.metadata?.homepageLink}}}const d=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,f=`frak-sso`;async function p(e,t){let{metadata:r,customizations:i,walletUrl:a}=e.config;if(t.openInSameWindow??!!t.redirectUrl)return await e.request({method:`frak_openSso`,params:[t,r.name,i?.css]});let o=t.ssoPopupUrl??l(a??`https://wallet.frak.id`,t,n(),r.name,i?.css),s=window.open(o,f,d);if(!s)throw Error(`Popup was blocked. Please allow popups for this site.`);return s.focus(),await e.request({method:`frak_openSso`,params:[t,r.name,i?.css]})??{}}const m=`https://backend.frak.id`;function h(e){return e.includes(`localhost:3000`)||e.includes(`localhost:3010`)}function g(e){return h(e)?`http://localhost:3030`:e.includes(`wallet-dev.frak.id`)||e.includes(`wallet.gcp-dev.frak.id`)?`https://backend.gcp-dev.frak.id`:m}function _(e){if(e)return g(e);if(typeof window<`u`){let e=window.FrakSetup?.client?.config?.walletUrl;if(e)return g(e)}return m}const v=`fCtx`;function y(t){if(t?.r)try{return o((0,e.hexToBytes)(t.r))}catch(e){console.error(`Error compressing Frak context`,{e,context:t})}}function b(t){if(!(!t||t.length===0))try{return{r:(0,e.bytesToHex)(s(t),{size:20})}}catch(e){console.error(`Error decompressing Frak context`,{e,context:t})}}function x({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(v);return t?b(t):null}function S({url:e,context:t}){if(!e)return null;let n=x({url:e}),r=n?{...n,...t}:t;if(!r.r)return null;let i=y(r);if(!i)return null;let a=new URL(e);return a.searchParams.set(v,i),a.toString()}function C(e){let t=new URL(e);return t.searchParams.delete(v),t.toString()}function w({url:e,context:t}){if(!window.location?.href||typeof window>`u`){console.error(`No window found, can't update context`);return}let n=e??window.location.href,r;r=t===null?C(n):S({url:n,context:t}),r&&window.history.replaceState(null,``,r.toString())}const T={compress:y,decompress:b,parse:x,update:S,remove:C,replaceUrl:w},E=`frak-merchant-id`;let D,O;async function k(e,t){if(D)return D;if(typeof window<`u`){let e=window.sessionStorage.getItem(E);if(e)return D=e,e}if(O)return O;O=A(e,t);let n=await O;return O=void 0,n}async function A(e,t){let n=e??(typeof window<`u`?window.location.hostname:``);if(n)try{let e=_(t),r=await fetch(`${e}/user/merchant/resolve?domain=${encodeURIComponent(n)}`);if(!r.ok){console.warn(`[Frak SDK] Merchant lookup failed for domain ${n}: ${r.status}`);return}let i=await r.json();return D=i.merchantId,typeof window<`u`&&window.sessionStorage.setItem(E,i.merchantId),D}catch(e){console.warn(`[Frak SDK] Failed to fetch merchantId:`,e);return}}function j(){D=void 0,O=void 0,typeof window<`u`&&window.sessionStorage.removeItem(E)}async function M(e,t){return e.metadata?.merchantId?e.metadata.merchantId:k(void 0,t)}function N(e,t,n={}){if(!e){console.debug(`[Frak] No client provided, skipping event tracking`);return}try{e.openPanel?.track(t,n)}catch(e){console.debug(`[Frak] Failed to track event:`,t,e)}}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return l}});
@@ -0,0 +1 @@
1
+ import{bytesToHex as e,hexToBytes as t,keccak256 as n,toHex as r}from"viem";import{jsonEncode as i}from"@frak-labs/frame-connector";function a({domain:e}={}){return n(r((e??window.location.host).replace(`www.`,``)))}const o=`frak-client-id`;function s(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function c(){if(typeof window>`u`||!window.localStorage)return console.warn(`[Frak SDK] No Window / localStorage available to save the clientId`),s();let e=localStorage.getItem(o);return e||(e=s(),localStorage.setItem(o,e)),e}function l(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function u(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(e.length+(t===0?0:4-t),`=`)),e=>e.charCodeAt(0))}function d(e){return l(i(e))}function f(e,t,n,r,i,a){let o=d(p({redirectUrl:t.redirectUrl,directExit:t.directExit,lang:t.lang,merchantId:n,metadata:{name:r,css:i,logoUrl:t.metadata?.logoUrl,homepageLink:t.metadata?.homepageLink},clientId:a??c()})),s=new URL(e);return s.pathname=`/sso`,s.searchParams.set(`p`,o),s.toString()}function p(e){return{r:e.redirectUrl,cId:e.clientId,d:e.directExit,l:e.lang,m:e.merchantId,md:{n:e.metadata?.name,css:e.metadata?.css,l:e.metadata?.logoUrl,h:e.metadata?.homepageLink}}}const m=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,h=`frak-sso`;async function g(e,t){let{metadata:n,customizations:r,walletUrl:i}=e.config;if(t.openInSameWindow??!!t.redirectUrl)return await e.request({method:`frak_openSso`,params:[t,n.name,r?.css]});let o=t.ssoPopupUrl??f(i??`https://wallet.frak.id`,t,a(),n.name,r?.css),s=window.open(o,h,m);if(!s)throw Error(`Popup was blocked. Please allow popups for this site.`);return s.focus(),await e.request({method:`frak_openSso`,params:[t,n.name,r?.css]})??{}}const _=`https://backend.frak.id`;function v(e){return e.includes(`localhost:3000`)||e.includes(`localhost:3010`)}function y(e){return v(e)?`http://localhost:3030`:e.includes(`wallet-dev.frak.id`)||e.includes(`wallet.gcp-dev.frak.id`)?`https://backend.gcp-dev.frak.id`:_}function b(e){if(e)return y(e);if(typeof window<`u`){let e=window.FrakSetup?.client?.config?.walletUrl;if(e)return y(e)}return _}const x=`fCtx`;function S(e){if(e?.r)try{return l(t(e.r))}catch(t){console.error(`Error compressing Frak context`,{e:t,context:e})}}function C(t){if(!(!t||t.length===0))try{return{r:e(u(t),{size:20})}}catch(e){console.error(`Error decompressing Frak context`,{e,context:t})}}function w({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(x);return t?C(t):null}function T({url:e,context:t}){if(!e)return null;let n=w({url:e}),r=n?{...n,...t}:t;if(!r.r)return null;let i=S(r);if(!i)return null;let a=new URL(e);return a.searchParams.set(x,i),a.toString()}function E(e){let t=new URL(e);return t.searchParams.delete(x),t.toString()}function D({url:e,context:t}){if(!window.location?.href||typeof window>`u`){console.error(`No window found, can't update context`);return}let n=e??window.location.href,r;r=t===null?E(n):T({url:n,context:t}),r&&window.history.replaceState(null,``,r.toString())}const O={compress:S,decompress:C,parse:w,update:T,remove:E,replaceUrl:D},k=`frak-merchant-id`;let A,j;async function M(e,t){if(A)return A;if(typeof window<`u`){let e=window.sessionStorage.getItem(k);if(e)return A=e,e}if(j)return j;j=N(e,t);let n=await j;return j=void 0,n}async function N(e,t){let n=e??(typeof window<`u`?window.location.hostname:``);if(n)try{let e=b(t),r=await fetch(`${e}/user/merchant/resolve?domain=${encodeURIComponent(n)}`);if(!r.ok){console.warn(`[Frak SDK] Merchant lookup failed for domain ${n}: ${r.status}`);return}let i=await r.json();return A=i.merchantId,typeof window<`u`&&window.sessionStorage.setItem(k,i.merchantId),A}catch(e){console.warn(`[Frak SDK] Failed to fetch merchantId:`,e);return}}function P(){A=void 0,j=void 0,typeof window<`u`&&window.sessionStorage.removeItem(k)}async function F(e,t){return e.metadata?.merchantId?e.metadata.merchantId:M(void 0,t)}function I(e,t,n={}){if(!e){console.debug(`[Frak] No client provided, skipping event tracking`);return}try{e.openPanel?.track(t,n)}catch(e){console.debug(`[Frak] Failed to track event:`,t,e)}}export{O as a,m as c,d,u as f,a as h,F as i,h as l,c as m,P as n,b as o,l as p,M as r,g as s,I as t,f as u};
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "url": "https://twitter.com/QNivelais"
12
12
  }
13
13
  ],
14
- "version": "0.1.1-beta.74fa073f",
14
+ "version": "0.1.1-beta.86e41c13",
15
15
  "description": "Core SDK of the Frak wallet, low level library to interact directly with the frak ecosystem.",
16
16
  "repository": {
17
17
  "url": "https://github.com/frak-id/wallet",
@@ -80,7 +80,7 @@
80
80
  "build": "tsdown",
81
81
  "build:watch": "tsdown --watch",
82
82
  "check-exports": "attw --pack --profile node16 .",
83
- "typecheck": "tsc --noEmit",
83
+ "typecheck": "tsgo --noEmit",
84
84
  "test": "vitest",
85
85
  "test:ui": "vitest --ui",
86
86
  "test:coverage": "vitest --coverage",
@@ -91,7 +91,7 @@
91
91
  "viem": "^2.x"
92
92
  },
93
93
  "dependencies": {
94
- "@frak-labs/frame-connector": "0.1.0-beta.74fa073f",
94
+ "@frak-labs/frame-connector": "0.1.0-beta.86e41c13",
95
95
  "@openpanel/web": "^1.0.7"
96
96
  },
97
97
  "devDependencies": {
@@ -1,5 +1,6 @@
1
1
  import type { FrakClient } from "../types";
2
2
  import type { SendInteractionParamsType } from "../types/rpc/interaction";
3
+ import { getClientId } from "../utils/clientId";
3
4
 
4
5
  /**
5
6
  * Send an interaction to the backend via the listener RPC.
@@ -46,7 +47,7 @@ export async function sendInteraction(
46
47
  try {
47
48
  await client.request({
48
49
  method: "frak_sendInteraction",
49
- params: [params],
50
+ params: [params, { clientId: getClientId() }],
50
51
  });
51
52
  } catch {
52
53
  // Silent failure - fire-and-forget
@@ -9,9 +9,9 @@ import type { FrakLifecycleEvent } from "../types";
9
9
  import type { FrakClient } from "../types/client";
10
10
  import type { FrakWalletSdkConfig } from "../types/config";
11
11
  import type { IFrameRpcSchema } from "../types/rpc";
12
+ import { getClientId } from "../utils";
12
13
  import { BACKUP_KEY } from "../utils/constants";
13
14
  import { setupSsoUrlListener } from "../utils/ssoUrlListener";
14
-
15
15
  import { DebugInfoGatherer } from "./DebugInfo";
16
16
  import {
17
17
  createIFrameLifecycleManager,
@@ -46,6 +46,9 @@ export function createIFrameFrakClient({
46
46
  }): FrakClient {
47
47
  const frakWalletUrl = config?.walletUrl ?? "https://wallet.frak.id";
48
48
 
49
+ // Eagerly generate a clientId, to ensure we got our local storage populated
50
+ getClientId();
51
+
49
52
  // Create lifecycle manager
50
53
  const lifecycleManager = createIFrameLifecycleManager({
51
54
  iframe,
@@ -142,6 +145,7 @@ export function createIFrameFrakClient({
142
145
  payload.properties = {
143
146
  ...payload.properties,
144
147
  sdkVersion: process.env.SDK_VERSION,
148
+ userAnonymousClientId: getClientId(),
145
149
  };
146
150
  }
147
151
 
@@ -150,6 +154,7 @@ export function createIFrameFrakClient({
150
154
  });
151
155
  openPanel.setGlobalProperties({
152
156
  sdkVersion: process.env.SDK_VERSION,
157
+ userAnonymousClientId: getClientId(),
153
158
  });
154
159
  openPanel.init();
155
160
  }
@@ -8,6 +8,28 @@ import {
8
8
  } from "../../utils/deepLinkWithFallback";
9
9
  import { changeIframeVisibility } from "../../utils/iframeHelper";
10
10
 
11
+ /**
12
+ * Detect iOS in-app browsers (Instagram, Facebook) where server-side
13
+ * 302 redirects to custom URL schemes (x-safari-https://) are silently
14
+ * swallowed by WKWebView. Direct window.location.href assignment works.
15
+ */
16
+ const isIOSInAppBrowser = (() => {
17
+ if (typeof navigator === "undefined") return false;
18
+ const ua = navigator.userAgent;
19
+ // Standard iOS or iPadOS 13+ (reports as Macintosh with touch)
20
+ const isIOS =
21
+ /iPhone|iPad|iPod/i.test(ua) ||
22
+ (/Macintosh/i.test(ua) && navigator.maxTouchPoints > 1);
23
+ if (!isIOS) return false;
24
+ const lower = ua.toLowerCase();
25
+ return (
26
+ lower.includes("instagram") ||
27
+ lower.includes("fban") ||
28
+ lower.includes("fbav") ||
29
+ lower.includes("facebook")
30
+ );
31
+ })();
32
+
11
33
  /** @ignore */
12
34
  export type IframeLifecycleManager = {
13
35
  isConnected: Promise<boolean>;
@@ -87,6 +109,27 @@ function computeRedirectUrl(
87
109
  }
88
110
  }
89
111
 
112
+ /**
113
+ * Redirect current page to Safari via x-safari-https:// scheme.
114
+ * Used on iOS in-app browsers where backend 302 → custom scheme fails.
115
+ */
116
+ function redirectToSafari(mergeToken?: string) {
117
+ const url = new URL(window.location.href);
118
+ if (mergeToken) {
119
+ url.searchParams.set("fmt", mergeToken);
120
+ }
121
+ const scheme =
122
+ url.protocol === "http:" ? "x-safari-http" : "x-safari-https";
123
+ window.location.href = `${scheme}://${url.host}${url.pathname}${url.search}${url.hash}`;
124
+ }
125
+
126
+ /**
127
+ * Check if this is a social/in-app-browser escape redirect (contains /common/social)
128
+ */
129
+ function isSocialRedirect(url: string): boolean {
130
+ return url.includes("/common/social");
131
+ }
132
+
90
133
  /**
91
134
  * Handle redirect with deep link fallback
92
135
  */
@@ -96,9 +139,8 @@ function handleRedirect(
96
139
  targetOrigin: string,
97
140
  mergeToken?: string
98
141
  ): void {
99
- const finalUrl = computeRedirectUrl(baseRedirectUrl, mergeToken);
100
-
101
142
  if (isFrakDeepLink(baseRedirectUrl)) {
143
+ const finalUrl = computeRedirectUrl(baseRedirectUrl, mergeToken);
102
144
  triggerDeepLinkWithFallback(finalUrl, {
103
145
  onFallback: () => {
104
146
  iframe.contentWindow?.postMessage(
@@ -110,7 +152,12 @@ function handleRedirect(
110
152
  );
111
153
  },
112
154
  });
155
+ } else if (isIOSInAppBrowser && isSocialRedirect(baseRedirectUrl)) {
156
+ // iOS WKWebView silently swallows 302 redirects to custom URL
157
+ // schemes — bypass the server redirect entirely
158
+ redirectToSafari(mergeToken);
113
159
  } else {
160
+ const finalUrl = computeRedirectUrl(baseRedirectUrl, mergeToken);
114
161
  window.location.href = finalUrl;
115
162
  }
116
163
  }
package/src/types/rpc.ts CHANGED
@@ -136,11 +136,15 @@ export type IFrameRpcSchema = [
136
136
  /**
137
137
  * Method to send interactions (arrival, sharing, custom events)
138
138
  * Fire-and-forget method - no return value expected
139
- * merchantId and clientId are resolved from context
139
+ * merchantId is resolved from context
140
+ * clientId is passed via metadata as safeguard against handshake race condition
140
141
  */
141
142
  {
142
143
  Method: "frak_sendInteraction";
143
- Parameters: [interaction: SendInteractionParamsType];
144
+ Parameters: [
145
+ interaction: SendInteractionParamsType,
146
+ metadata?: { clientId?: string },
147
+ ];
144
148
  ReturnType: undefined;
145
149
  },
146
150
  ];
@@ -28,6 +28,9 @@ function generateUUID(): string {
28
28
  export function getClientId(): string {
29
29
  if (typeof window === "undefined" || !window.localStorage) {
30
30
  // SSR or no localStorage - generate ephemeral ID
31
+ console.warn(
32
+ "[Frak SDK] No Window / localStorage available to save the clientId"
33
+ );
31
34
  return generateUUID();
32
35
  }
33
36
 
@@ -1,13 +0,0 @@
1
- import{f as e,m as t}from"./trackEvent-B0S5E6_h.js";import{Deferred as n,FrakRpcError as r,RpcErrorCodes as i,createRpcClient as a,jsonDecode as o}from"@frak-labs/frame-connector";import{OpenPanel as s}from"@openpanel/web";const c=`nexus-wallet-backup`,l=`frakwallet://`;function u(e,t){if(typeof window>`u`)return;let n=new URL(window.location.href),r=n.searchParams.get(`sso`);r&&(t.then(()=>{e.sendLifecycle({clientLifecycle:`sso-redirect-complete`,data:{compressed:r}}),console.log(`[SSO URL Listener] Forwarded compressed SSO data to iframe`)}).catch(e=>{console.error(`[SSO URL Listener] Failed to forward SSO data:`,e)}),n.searchParams.delete(`sso`),window.history.replaceState({},``,n.toString()),console.log(`[SSO URL Listener] SSO parameter detected and URL cleaned`))}var d=class e{config;iframe;isSetupDone=!1;lastResponse=null;lastRequest=null;constructor(e,t){this.config=e,this.iframe=t,this.lastRequest=null,this.lastResponse=null}setLastResponse(e,t){this.lastResponse={message:e,response:t,timestamp:Date.now()}}setLastRequest(e){this.lastRequest={event:e,timestamp:Date.now()}}updateSetupStatus(e){this.isSetupDone=e}base64Encode(e){try{return btoa(JSON.stringify(e))}catch(e){return console.warn(`Failed to encode debug data`,e),btoa(`Failed to encode data`)}}getIframeStatus(){return this.iframe?{loading:this.iframe.hasAttribute(`loading`),url:this.iframe.src,readyState:this.iframe.contentDocument?.readyState?this.iframe.contentDocument.readyState===`complete`?1:0:-1,contentWindow:!!this.iframe.contentWindow,isConnected:this.iframe.isConnected}:null}getNavigatorInfo(){return navigator?{userAgent:navigator.userAgent,language:navigator.language,onLine:navigator.onLine,screenWidth:window.screen.width,screenHeight:window.screen.height,pixelRatio:window.devicePixelRatio}:null}gatherDebugInfo(e){let t=this.getIframeStatus(),n=this.getNavigatorInfo(),i=`Unknown`;return e instanceof r?i=`FrakRpcError: ${e.code} '${e.message}'`:e instanceof Error?i=e.message:typeof e==`string`&&(i=e),{timestamp:new Date().toISOString(),encodedUrl:btoa(window.location.href),encodedConfig:this.config?this.base64Encode(this.config):`no-config`,navigatorInfo:n?this.base64Encode(n):`no-navigator`,iframeStatus:t?this.base64Encode(t):`not-iframe`,lastRequest:this.lastRequest?this.base64Encode(this.lastRequest):`No Frak request logged`,lastResponse:this.lastResponse?this.base64Encode(this.lastResponse):`No Frak response logged`,clientStatus:this.isSetupDone?`setup`:`not-setup`,error:i}}static empty(){return new e}formatDebugInfo(e){let t=this.gatherDebugInfo(e);return`
2
- Debug Information:
3
- -----------------
4
- Timestamp: ${t.timestamp}
5
- URL: ${t.encodedUrl}
6
- Config: ${t.encodedConfig}
7
- Navigator Info: ${t.navigatorInfo}
8
- IFrame Status: ${t.iframeStatus}
9
- Last Request: ${t.lastRequest}
10
- Last Response: ${t.lastResponse}
11
- Client Status: ${t.clientStatus}
12
- Error: ${t.error}
13
- `.trim()}};function f(){let e=navigator.userAgent;return/Android/i.test(e)&&/Chrome\/\d+/i.test(e)}function p(e){return`intent://${e.slice(13)}#Intent;scheme=frakwallet;end`}function m(e,t){let n=t?.timeout??2500,r=!1,i=()=>{document.hidden&&(r=!0)};document.addEventListener(`visibilitychange`,i);let a=f()&&h(e)?p(e):e;window.location.href=a,setTimeout(()=>{document.removeEventListener(`visibilitychange`,i),r||t?.onFallback?.()},n)}function h(e){return e.startsWith(l)}const g={id:`frak-wallet`,name:`frak-wallet`,title:`Frak Wallet`,allow:`publickey-credentials-get *; clipboard-write; web-share *`,style:{width:`0`,height:`0`,border:`0`,position:`absolute`,zIndex:2000001,top:`-1000px`,left:`-1000px`,colorScheme:`auto`}};function _({walletBaseUrl:e,config:t}){let n=document.querySelector(`#frak-wallet`);n&&n.remove();let r=document.createElement(`iframe`);return r.id=g.id,r.name=g.name,r.allow=g.allow,r.style.zIndex=g.style.zIndex.toString(),v({iframe:r,isVisible:!1}),r.src=`${t?.walletUrl??e??`https://wallet.frak.id`}/listener`,new Promise(e=>{r.addEventListener(`load`,()=>e(r)),document.body.appendChild(r)})}function v({iframe:e,isVisible:t}){if(!t){e.style.width=`0`,e.style.height=`0`,e.style.border=`0`,e.style.position=`fixed`,e.style.top=`-1000px`,e.style.left=`-1000px`;return}e.style.position=`fixed`,e.style.top=`0`,e.style.left=`0`,e.style.width=`100%`,e.style.height=`100%`,e.style.pointerEvents=`auto`}function y(e=`/listener`){if(!window.opener)return null;let t=t=>{try{return t.location.origin===window.location.origin&&t.location.pathname===e}catch{return!1}};if(t(window.opener))return window.opener;try{let e=window.opener.frames;for(let n=0;n<e.length;n++)if(t(e[n]))return e[n];return null}catch(t){return console.error(`[findIframeInOpener] Error finding iframe with pathname ${e}:`,t),null}}function b(e){e?localStorage.setItem(c,e):localStorage.removeItem(c)}function x(e,n,r,i){let a=new URL(window.location.href),o=a.searchParams.get(`fmt`)??void 0;e.contentWindow?.postMessage({clientLifecycle:`handshake-response`,data:{token:n,currentUrl:window.location.href,clientId:t(),pendingMergeToken:o,configDomain:i}},r),o&&(a.searchParams.delete(`fmt`),window.history.replaceState({},``,a.toString()))}function S(e,t){try{let n=new URL(e);return n.searchParams.has(`u`)?(n.searchParams.delete(`u`),n.searchParams.append(`u`,window.location.href),t&&n.searchParams.append(`fmt`,t),n.toString()):e}catch{return e}}function C(e,t,n,r){let i=S(t,r);h(t)?m(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}}):window.location.href=i}function w({iframe:e,targetOrigin:t,configDomain:r}){let i=new n;return{handleEvent:async n=>{if(!(`iframeLifecycle`in n))return;let{iframeLifecycle:a,data:o}=n;switch(a){case`connected`:i.resolve(!0);break;case`do-backup`:b(o.backup);break;case`remove-backup`:localStorage.removeItem(c);break;case`show`:case`hide`:v({iframe:e,isVisible:a===`show`});break;case`handshake`:x(e,o.token,t,r);break;case`redirect`:C(e,o.baseRedirectUrl,t,o.mergeToken);break}},isConnected:i.promise}}function T({config:e,iframe:t}){let n=e?.walletUrl??`https://wallet.frak.id`,o=w({iframe:t,targetOrigin:n,configDomain:e.domain}),c=new d(e,t);if(!t.contentWindow)throw new r(i.configError,`The iframe does not have a content window`);let l=a({emittingTransport:t.contentWindow,listeningTransport:window,targetOrigin:n,middleware:[{async onRequest(e,t){if(!await o.isConnected)throw new r(i.clientNotConnected,`The iframe provider isn't connected yet`);return t}},{onRequest(e,t){return c.setLastRequest(e),t},onResponse(e,t){return c.setLastResponse(e,t),t}}],lifecycleHandlers:{iframeLifecycle:async(e,t)=>{await o.handleEvent(e)}}}),u=E(l,o),f=async()=>{u(),l.cleanup(),t.remove()},p;console.log(`[Frak SDK] Initializing OpenPanel`),p=new s({apiUrl:`https://op-api.gcp.frak.id`,clientId:`6eacc8d7-49ac-4936-95e9-81ef29449570`,trackScreenViews:!0,trackOutgoingLinks:!0,trackAttributes:!1,filter:({type:e,payload:t})=>(e!==`track`||!t?.properties||`sdkVersion`in t.properties||(t.properties={...t.properties,sdkVersion:`0.1.1`}),!0)}),p.setGlobalProperties({sdkVersion:`0.1.1`}),p.init();let m=D({config:e,rpcClient:l,lifecycleManager:o}).then(()=>c.updateSetupStatus(!0));return{config:e,debugInfo:c,waitForConnection:o.isConnected,waitForSetup:m,request:l.request,listenerRequest:l.listen,destroy:f,openPanel:p}}function E(e,t){let n,r,i=()=>e.sendLifecycle({clientLifecycle:`heartbeat`});async function a(){i(),n=setInterval(i,1e3),r=setTimeout(()=>{o(),console.log(`Heartbeat timeout: connection failed`)},3e4),await t.isConnected,o()}function o(){n&&clearInterval(n),r&&clearTimeout(r)}return a(),o}async function D({config:e,rpcClient:t,lifecycleManager:n}){await n.isConnected,u(t,n.isConnected);async function r(){let n=e.customizations?.css;if(!n)return;let r={clientLifecycle:`modal-css`,data:{cssLink:n}};t.sendLifecycle(r)}async function i(){let n=e.customizations?.i18n;if(!n)return;let r={clientLifecycle:`modal-i18n`,data:{i18n:n}};t.sendLifecycle(r)}async function a(){if(typeof window>`u`)return;let e=window.localStorage.getItem(c);if(!e)return;let n={clientLifecycle:`restore-backup`,data:{backup:e}};t.sendLifecycle(n)}await Promise.allSettled([r(),i(),a()])}function O(t){return o(e(t))}const k={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function A(e){return e&&e in k?e:`eur`}function j(e){return e?k[e]??k.eur:k.eur}function M(e,t){let n=j(t),r=A(t);return e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function N(e){return e?`${e}Amount`:`eurAmount`}async function P({config:e}){let t=F(e),n=await _({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=T({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error(`Failed to connect to client`);return}return r}function F(e){let t=A(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}export{l as _,A as a,T as c,y as d,f,d as g,m as h,j as i,g as l,p as m,N as n,k as o,h as p,M as r,O as s,P as t,_ as u};
@@ -1,13 +0,0 @@
1
- const e=require(`./trackEvent-BbX2d3g_.cjs`);let t=require(`@frak-labs/frame-connector`),n=require(`@openpanel/web`);const r=`nexus-wallet-backup`,i=`frakwallet://`;function a(e,t){if(typeof window>`u`)return;let n=new URL(window.location.href),r=n.searchParams.get(`sso`);r&&(t.then(()=>{e.sendLifecycle({clientLifecycle:`sso-redirect-complete`,data:{compressed:r}}),console.log(`[SSO URL Listener] Forwarded compressed SSO data to iframe`)}).catch(e=>{console.error(`[SSO URL Listener] Failed to forward SSO data:`,e)}),n.searchParams.delete(`sso`),window.history.replaceState({},``,n.toString()),console.log(`[SSO URL Listener] SSO parameter detected and URL cleaned`))}var o=class e{config;iframe;isSetupDone=!1;lastResponse=null;lastRequest=null;constructor(e,t){this.config=e,this.iframe=t,this.lastRequest=null,this.lastResponse=null}setLastResponse(e,t){this.lastResponse={message:e,response:t,timestamp:Date.now()}}setLastRequest(e){this.lastRequest={event:e,timestamp:Date.now()}}updateSetupStatus(e){this.isSetupDone=e}base64Encode(e){try{return btoa(JSON.stringify(e))}catch(e){return console.warn(`Failed to encode debug data`,e),btoa(`Failed to encode data`)}}getIframeStatus(){return this.iframe?{loading:this.iframe.hasAttribute(`loading`),url:this.iframe.src,readyState:this.iframe.contentDocument?.readyState?this.iframe.contentDocument.readyState===`complete`?1:0:-1,contentWindow:!!this.iframe.contentWindow,isConnected:this.iframe.isConnected}:null}getNavigatorInfo(){return navigator?{userAgent:navigator.userAgent,language:navigator.language,onLine:navigator.onLine,screenWidth:window.screen.width,screenHeight:window.screen.height,pixelRatio:window.devicePixelRatio}:null}gatherDebugInfo(e){let n=this.getIframeStatus(),r=this.getNavigatorInfo(),i=`Unknown`;return e instanceof t.FrakRpcError?i=`FrakRpcError: ${e.code} '${e.message}'`:e instanceof Error?i=e.message:typeof e==`string`&&(i=e),{timestamp:new Date().toISOString(),encodedUrl:btoa(window.location.href),encodedConfig:this.config?this.base64Encode(this.config):`no-config`,navigatorInfo:r?this.base64Encode(r):`no-navigator`,iframeStatus:n?this.base64Encode(n):`not-iframe`,lastRequest:this.lastRequest?this.base64Encode(this.lastRequest):`No Frak request logged`,lastResponse:this.lastResponse?this.base64Encode(this.lastResponse):`No Frak response logged`,clientStatus:this.isSetupDone?`setup`:`not-setup`,error:i}}static empty(){return new e}formatDebugInfo(e){let t=this.gatherDebugInfo(e);return`
2
- Debug Information:
3
- -----------------
4
- Timestamp: ${t.timestamp}
5
- URL: ${t.encodedUrl}
6
- Config: ${t.encodedConfig}
7
- Navigator Info: ${t.navigatorInfo}
8
- IFrame Status: ${t.iframeStatus}
9
- Last Request: ${t.lastRequest}
10
- Last Response: ${t.lastResponse}
11
- Client Status: ${t.clientStatus}
12
- Error: ${t.error}
13
- `.trim()}};function s(){let e=navigator.userAgent;return/Android/i.test(e)&&/Chrome\/\d+/i.test(e)}function c(e){return`intent://${e.slice(13)}#Intent;scheme=frakwallet;end`}function l(e,t){let n=t?.timeout??2500,r=!1,i=()=>{document.hidden&&(r=!0)};document.addEventListener(`visibilitychange`,i);let a=s()&&u(e)?c(e):e;window.location.href=a,setTimeout(()=>{document.removeEventListener(`visibilitychange`,i),r||t?.onFallback?.()},n)}function u(e){return e.startsWith(i)}const d={id:`frak-wallet`,name:`frak-wallet`,title:`Frak Wallet`,allow:`publickey-credentials-get *; clipboard-write; web-share *`,style:{width:`0`,height:`0`,border:`0`,position:`absolute`,zIndex:2000001,top:`-1000px`,left:`-1000px`,colorScheme:`auto`}};function f({walletBaseUrl:e,config:t}){let n=document.querySelector(`#frak-wallet`);n&&n.remove();let r=document.createElement(`iframe`);return r.id=d.id,r.name=d.name,r.allow=d.allow,r.style.zIndex=d.style.zIndex.toString(),p({iframe:r,isVisible:!1}),r.src=`${t?.walletUrl??e??`https://wallet.frak.id`}/listener`,new Promise(e=>{r.addEventListener(`load`,()=>e(r)),document.body.appendChild(r)})}function p({iframe:e,isVisible:t}){if(!t){e.style.width=`0`,e.style.height=`0`,e.style.border=`0`,e.style.position=`fixed`,e.style.top=`-1000px`,e.style.left=`-1000px`;return}e.style.position=`fixed`,e.style.top=`0`,e.style.left=`0`,e.style.width=`100%`,e.style.height=`100%`,e.style.pointerEvents=`auto`}function m(e=`/listener`){if(!window.opener)return null;let t=t=>{try{return t.location.origin===window.location.origin&&t.location.pathname===e}catch{return!1}};if(t(window.opener))return window.opener;try{let e=window.opener.frames;for(let n=0;n<e.length;n++)if(t(e[n]))return e[n];return null}catch(t){return console.error(`[findIframeInOpener] Error finding iframe with pathname ${e}:`,t),null}}function h(e){e?localStorage.setItem(r,e):localStorage.removeItem(r)}function g(t,n,r,i){let a=new URL(window.location.href),o=a.searchParams.get(`fmt`)??void 0;t.contentWindow?.postMessage({clientLifecycle:`handshake-response`,data:{token:n,currentUrl:window.location.href,clientId:e.m(),pendingMergeToken:o,configDomain:i}},r),o&&(a.searchParams.delete(`fmt`),window.history.replaceState({},``,a.toString()))}function _(e,t){try{let n=new URL(e);return n.searchParams.has(`u`)?(n.searchParams.delete(`u`),n.searchParams.append(`u`,window.location.href),t&&n.searchParams.append(`fmt`,t),n.toString()):e}catch{return e}}function v(e,t,n,r){let i=_(t,r);u(t)?l(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}}):window.location.href=i}function y({iframe:e,targetOrigin:n,configDomain:i}){let a=new t.Deferred;return{handleEvent:async t=>{if(!(`iframeLifecycle`in t))return;let{iframeLifecycle:o,data:s}=t;switch(o){case`connected`:a.resolve(!0);break;case`do-backup`:h(s.backup);break;case`remove-backup`:localStorage.removeItem(r);break;case`show`:case`hide`:p({iframe:e,isVisible:o===`show`});break;case`handshake`:g(e,s.token,n,i);break;case`redirect`:v(e,s.baseRedirectUrl,n,s.mergeToken);break}},isConnected:a.promise}}function b({config:e,iframe:r}){let i=e?.walletUrl??`https://wallet.frak.id`,a=y({iframe:r,targetOrigin:i,configDomain:e.domain}),s=new o(e,r);if(!r.contentWindow)throw new t.FrakRpcError(t.RpcErrorCodes.configError,`The iframe does not have a content window`);let c=(0,t.createRpcClient)({emittingTransport:r.contentWindow,listeningTransport:window,targetOrigin:i,middleware:[{async onRequest(e,n){if(!await a.isConnected)throw new t.FrakRpcError(t.RpcErrorCodes.clientNotConnected,`The iframe provider isn't connected yet`);return n}},{onRequest(e,t){return s.setLastRequest(e),t},onResponse(e,t){return s.setLastResponse(e,t),t}}],lifecycleHandlers:{iframeLifecycle:async(e,t)=>{await a.handleEvent(e)}}}),l=x(c,a),u=async()=>{l(),c.cleanup(),r.remove()},d;console.log(`[Frak SDK] Initializing OpenPanel`),d=new n.OpenPanel({apiUrl:`https://op-api.gcp.frak.id`,clientId:`6eacc8d7-49ac-4936-95e9-81ef29449570`,trackScreenViews:!0,trackOutgoingLinks:!0,trackAttributes:!1,filter:({type:e,payload:t})=>(e!==`track`||!t?.properties||`sdkVersion`in t.properties||(t.properties={...t.properties,sdkVersion:`0.1.1`}),!0)}),d.setGlobalProperties({sdkVersion:`0.1.1`}),d.init();let f=S({config:e,rpcClient:c,lifecycleManager:a}).then(()=>s.updateSetupStatus(!0));return{config:e,debugInfo:s,waitForConnection:a.isConnected,waitForSetup:f,request:c.request,listenerRequest:c.listen,destroy:u,openPanel:d}}function x(e,t){let n,r,i=()=>e.sendLifecycle({clientLifecycle:`heartbeat`});async function a(){i(),n=setInterval(i,1e3),r=setTimeout(()=>{o(),console.log(`Heartbeat timeout: connection failed`)},3e4),await t.isConnected,o()}function o(){n&&clearInterval(n),r&&clearTimeout(r)}return a(),o}async function S({config:e,rpcClient:t,lifecycleManager:n}){await n.isConnected,a(t,n.isConnected);async function i(){let n=e.customizations?.css;if(!n)return;let r={clientLifecycle:`modal-css`,data:{cssLink:n}};t.sendLifecycle(r)}async function o(){let n=e.customizations?.i18n;if(!n)return;let r={clientLifecycle:`modal-i18n`,data:{i18n:n}};t.sendLifecycle(r)}async function s(){if(typeof window>`u`)return;let e=window.localStorage.getItem(r);if(!e)return;let n={clientLifecycle:`restore-backup`,data:{backup:e}};t.sendLifecycle(n)}await Promise.allSettled([i(),o(),s()])}function C(n){return(0,t.jsonDecode)(e.f(n))}const w={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function T(e){return e&&e in w?e:`eur`}function E(e){return e?w[e]??w.eur:w.eur}function D(e,t){let n=E(t),r=T(t);return e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function O(e){return e?`${e}Amount`:`eurAmount`}async function k({config:e}){let t=A(e),n=await f({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=b({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error(`Failed to connect to client`);return}return r}function A(e){let t=T(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return f}});
@@ -1 +0,0 @@
1
- import{a as e,m as t,o as n,r,t as i}from"./trackEvent-B0S5E6_h.js";import{isAddressEqual as a}from"viem";import{Deferred as o,FrakRpcError as s,RpcErrorCodes as c}from"@frak-labs/frame-connector";import{generateSiweNonce as l}from"viem/siwe";async function u(e,t){return await e.request({method:`frak_displayEmbeddedWallet`,params:[t,e.config.metadata]})}async function d(e,{steps:t,metadata:n}){return await e.request({method:`frak_displayModal`,params:[t,n,e.config.metadata]})}async function f(e){return await e.request({method:`frak_getMerchantInformation`})}async function p(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function m(e,t){try{await e.request({method:`frak_sendInteraction`,params:[t]})}catch{console.warn(`[Frak SDK] Failed to send interaction:`,t.type)}}async function h(t,{walletStatus:n,frakContext:r,modalConfig:a,options:o}){if(!r?.r)return`no-referrer`;i(t,`user_referred_started`,{properties:{referrer:r?.r,walletStatus:n?.key}}),m(t,{type:`arrival`,referrerWallet:r.r,landingUrl:typeof window<`u`?window.location.href:void 0});let c=!1;async function l(){if(!c)return c=!0,_(t,{modalConfig:{...a,loggedIn:{action:{key:`referred`}}},walletStatus:n})}try{let{status:a,currentWallet:s}=await g({initialWalletStatus:n,getFreshWalletStatus:l,frakContext:r});return e.replaceUrl({url:window.location?.href,context:o?.alwaysAppendUrl?{r:s}:null}),i(t,`user_referred_completed`,{properties:{status:a,referrer:r?.r,wallet:s}}),a}catch(a){return console.log(`Error processing referral`,{error:a}),i(t,`user_referred_error`,{properties:{referrer:r?.r,error:a instanceof s?`[${a.code}] ${a.name} - ${a.message}`:a instanceof Error?a.message:`undefined`}}),e.replaceUrl({url:window.location?.href,context:o?.alwaysAppendUrl?{r:n?.wallet}:null}),v(a)}}async function g({initialWalletStatus:e,getFreshWalletStatus:t,frakContext:n}){let r=e?.wallet;return r||=await t(),r&&a(n.r,r)?{status:`self-referral`,currentWallet:r}:{status:`success`,currentWallet:r}}async function _(e,{modalConfig:t,walletStatus:n}){return n?.key===`connected`?n.wallet??void 0:(await u(e,t??{}))?.wallet??void 0}function v(e){if(e instanceof s)switch(e.code){case c.walletNotConnected:return`no-wallet`;default:return`error`}return`error`}async function y(t,{modalConfig:n,options:r}={}){let i=e.parse({url:window.location.href}),a=await x(t);try{return await h(t,{walletStatus:a,frakContext:i,modalConfig:n,options:r})}catch(e){console.warn(`Error processing referral`,{error:e})}}async function b(e){if(typeof window>`u`){console.warn(`[Frak] No window found, can't track purchase`);return}let i=window.sessionStorage.getItem(`frak-wallet-interaction-token`),a=t();if(!i&&!a){console.warn(`[Frak] No identity found, skipping purchase check`);return}let o=window.sessionStorage.getItem(`frak-merchant-id`),s=e.merchantId??o??await r();if(!s){console.warn(`[Frak] No merchant id found, skipping purchase check`);return}let c={Accept:`application/json`,"Content-Type":`application/json`};i&&(c[`x-wallet-sdk-auth`]=i),a&&(c[`x-frak-client-id`]=a);let l=n();await fetch(`${l}/user/track/purchase`,{method:`POST`,headers:c,body:JSON.stringify({customerId:e.customerId,orderId:e.orderId,token:e.token,merchantId:s})})}function x(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(S(e,t),t));let n=new o,r=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},i=>{S(e,i),t(i),r||=(n.resolve(i),!0)}),n.promise}function S(e,t){typeof window>`u`||(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function C(e,{metadata:t,login:n}){return w(e,{steps:{login:n??{}},metadata:t})}function w(e,t){function n(n){return w(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return w(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}function i(n,r){return w(e,{...t,steps:{...t.steps,final:{...r,action:{key:`sharing`,options:n}}}})}async function a(n){return n&&(t.metadata=n(t.metadata??{})),await d(e,t)}return{params:t,sendTx:n,reward:r,sharing:i,display:a}}async function T(e,{tx:t,metadata:n}){return(await d(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}async function E(e,{siwe:t,metadata:n}){let r=e.config?.domain??window.location.host,i=t?.statement??`I confirm that I want to use my Frak wallet on: ${e.config.metadata.name}`;return(await d(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:i,nonce:t?.nonce??l(),uri:t?.uri??`https://${r}`,version:t?.version??`1`,domain:r}}}})).siweAuthenticate}export{b as a,m as c,d,u as f,x as i,p as l,T as n,y as o,C as r,h as s,E as t,f as u};
@@ -1 +0,0 @@
1
- const e=require(`./trackEvent-BbX2d3g_.cjs`);let t=require(`viem`),n=require(`@frak-labs/frame-connector`),r=require(`viem/siwe`);async function i(e,t){return await e.request({method:`frak_displayEmbeddedWallet`,params:[t,e.config.metadata]})}async function a(e,{steps:t,metadata:n}){return await e.request({method:`frak_displayModal`,params:[t,n,e.config.metadata]})}async function o(e){return await e.request({method:`frak_getMerchantInformation`})}async function s(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function c(e,t){try{await e.request({method:`frak_sendInteraction`,params:[t]})}catch{console.warn(`[Frak SDK] Failed to send interaction:`,t.type)}}async function l(t,{walletStatus:r,frakContext:i,modalConfig:a,options:o}){if(!i?.r)return`no-referrer`;e.t(t,`user_referred_started`,{properties:{referrer:i?.r,walletStatus:r?.key}}),c(t,{type:`arrival`,referrerWallet:i.r,landingUrl:typeof window<`u`?window.location.href:void 0});let s=!1;async function l(){if(!s)return s=!0,d(t,{modalConfig:{...a,loggedIn:{action:{key:`referred`}}},walletStatus:r})}try{let{status:n,currentWallet:a}=await u({initialWalletStatus:r,getFreshWalletStatus:l,frakContext:i});return e.a.replaceUrl({url:window.location?.href,context:o?.alwaysAppendUrl?{r:a}:null}),e.t(t,`user_referred_completed`,{properties:{status:n,referrer:i?.r,wallet:a}}),n}catch(a){return console.log(`Error processing referral`,{error:a}),e.t(t,`user_referred_error`,{properties:{referrer:i?.r,error:a instanceof n.FrakRpcError?`[${a.code}] ${a.name} - ${a.message}`:a instanceof Error?a.message:`undefined`}}),e.a.replaceUrl({url:window.location?.href,context:o?.alwaysAppendUrl?{r:r?.wallet}:null}),f(a)}}async function u({initialWalletStatus:e,getFreshWalletStatus:n,frakContext:r}){let i=e?.wallet;return i||=await n(),i&&(0,t.isAddressEqual)(r.r,i)?{status:`self-referral`,currentWallet:i}:{status:`success`,currentWallet:i}}async function d(e,{modalConfig:t,walletStatus:n}){return n?.key===`connected`?n.wallet??void 0:(await i(e,t??{}))?.wallet??void 0}function f(e){if(e instanceof n.FrakRpcError)switch(e.code){case n.RpcErrorCodes.walletNotConnected:return`no-wallet`;default:return`error`}return`error`}async function p(t,{modalConfig:n,options:r}={}){let i=e.a.parse({url:window.location.href}),a=await h(t);try{return await l(t,{walletStatus:a,frakContext:i,modalConfig:n,options:r})}catch(e){console.warn(`Error processing referral`,{error:e})}}async function m(t){if(typeof window>`u`){console.warn(`[Frak] No window found, can't track purchase`);return}let n=window.sessionStorage.getItem(`frak-wallet-interaction-token`),r=e.m();if(!n&&!r){console.warn(`[Frak] No identity found, skipping purchase check`);return}let i=window.sessionStorage.getItem(`frak-merchant-id`),a=t.merchantId??i??await e.r();if(!a){console.warn(`[Frak] No merchant id found, skipping purchase check`);return}let o={Accept:`application/json`,"Content-Type":`application/json`};n&&(o[`x-wallet-sdk-auth`]=n),r&&(o[`x-frak-client-id`]=r);let s=e.o();await fetch(`${s}/user/track/purchase`,{method:`POST`,headers:o,body:JSON.stringify({customerId:t.customerId,orderId:t.orderId,token:t.token,merchantId:a})})}function h(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(g(e,t),t));let r=new n.Deferred,i=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},n=>{g(e,n),t(n),i||=(r.resolve(n),!0)}),r.promise}function g(e,t){typeof window>`u`||(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function _(e,{metadata:t,login:n}){return v(e,{steps:{login:n??{}},metadata:t})}function v(e,t){function n(n){return v(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return v(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}function i(n,r){return v(e,{...t,steps:{...t.steps,final:{...r,action:{key:`sharing`,options:n}}}})}async function o(n){return n&&(t.metadata=n(t.metadata??{})),await a(e,t)}return{params:t,sendTx:n,reward:r,sharing:i,display:o}}async function y(e,{tx:t,metadata:n}){return(await a(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}async function b(e,{siwe:t,metadata:n}){let i=e.config?.domain??window.location.host,o=t?.statement??`I confirm that I want to use my Frak wallet on: ${e.config.metadata.name}`;return(await a(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:o,nonce:t?.nonce??(0,r.generateSiweNonce)(),uri:t?.uri??`https://${i}`,version:t?.version??`1`,domain:i}}}})).siweAuthenticate}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return o}});
@@ -1 +0,0 @@
1
- import{bytesToHex as e,hexToBytes as t,keccak256 as n,toHex as r}from"viem";import{jsonEncode as i}from"@frak-labs/frame-connector";function a({domain:e}={}){return n(r((e??window.location.host).replace(`www.`,``)))}const o=`frak-client-id`;function s(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function c(){if(typeof window>`u`||!window.localStorage)return s();let e=localStorage.getItem(o);return e||(e=s(),localStorage.setItem(o,e)),e}function l(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function u(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(e.length+(t===0?0:4-t),`=`)),e=>e.charCodeAt(0))}function d(e){return l(i(e))}function f(e,t,n,r,i,a){let o=d(p({redirectUrl:t.redirectUrl,directExit:t.directExit,lang:t.lang,merchantId:n,metadata:{name:r,css:i,logoUrl:t.metadata?.logoUrl,homepageLink:t.metadata?.homepageLink},clientId:a??c()})),s=new URL(e);return s.pathname=`/sso`,s.searchParams.set(`p`,o),s.toString()}function p(e){return{r:e.redirectUrl,cId:e.clientId,d:e.directExit,l:e.lang,m:e.merchantId,md:{n:e.metadata?.name,css:e.metadata?.css,l:e.metadata?.logoUrl,h:e.metadata?.homepageLink}}}const m=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,h=`frak-sso`;async function g(e,t){let{metadata:n,customizations:r,walletUrl:i}=e.config;if(t.openInSameWindow??!!t.redirectUrl)return await e.request({method:`frak_openSso`,params:[t,n.name,r?.css]});let o=t.ssoPopupUrl??f(i??`https://wallet.frak.id`,t,a(),n.name,r?.css),s=window.open(o,h,m);if(!s)throw Error(`Popup was blocked. Please allow popups for this site.`);return s.focus(),await e.request({method:`frak_openSso`,params:[t,n.name,r?.css]})??{}}const _=`https://backend.frak.id`;function v(e){return e.includes(`localhost:3000`)||e.includes(`localhost:3010`)}function y(e){return v(e)?`http://localhost:3030`:e.includes(`wallet-dev.frak.id`)||e.includes(`wallet.gcp-dev.frak.id`)?`https://backend.gcp-dev.frak.id`:_}function b(e){if(e)return y(e);if(typeof window<`u`){let e=window.FrakSetup?.client?.config?.walletUrl;if(e)return y(e)}return _}const x=`fCtx`;function S(e){if(e?.r)try{return l(t(e.r))}catch(t){console.error(`Error compressing Frak context`,{e:t,context:e})}}function C(t){if(!(!t||t.length===0))try{return{r:e(u(t),{size:20})}}catch(e){console.error(`Error decompressing Frak context`,{e,context:t})}}function w({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(x);return t?C(t):null}function T({url:e,context:t}){if(!e)return null;let n=w({url:e}),r=n?{...n,...t}:t;if(!r.r)return null;let i=S(r);if(!i)return null;let a=new URL(e);return a.searchParams.set(x,i),a.toString()}function E(e){let t=new URL(e);return t.searchParams.delete(x),t.toString()}function D({url:e,context:t}){if(!window.location?.href||typeof window>`u`){console.error(`No window found, can't update context`);return}let n=e??window.location.href,r;r=t===null?E(n):T({url:n,context:t}),r&&window.history.replaceState(null,``,r.toString())}const O={compress:S,decompress:C,parse:w,update:T,remove:E,replaceUrl:D},k=`frak-merchant-id`;let A,j;async function M(e,t){if(A)return A;if(typeof window<`u`){let e=window.sessionStorage.getItem(k);if(e)return A=e,e}if(j)return j;j=N(e,t);let n=await j;return j=void 0,n}async function N(e,t){let n=e??(typeof window<`u`?window.location.hostname:``);if(n)try{let e=b(t),r=await fetch(`${e}/user/merchant/resolve?domain=${encodeURIComponent(n)}`);if(!r.ok){console.warn(`[Frak SDK] Merchant lookup failed for domain ${n}: ${r.status}`);return}let i=await r.json();return A=i.merchantId,typeof window<`u`&&window.sessionStorage.setItem(k,i.merchantId),A}catch(e){console.warn(`[Frak SDK] Failed to fetch merchantId:`,e);return}}function P(){A=void 0,j=void 0,typeof window<`u`&&window.sessionStorage.removeItem(k)}async function F(e,t){return e.metadata?.merchantId?e.metadata.merchantId:M(void 0,t)}function I(e,t,n={}){if(!e){console.debug(`[Frak] No client provided, skipping event tracking`);return}try{e.openPanel?.track(t,n)}catch(e){console.debug(`[Frak] Failed to track event:`,t,e)}}export{O as a,m as c,d,u as f,a as h,F as i,h as l,c as m,P as n,b as o,l as p,M as r,g as s,I as t,f as u};
@@ -1 +0,0 @@
1
- let e=require(`viem`),t=require(`@frak-labs/frame-connector`);function n({domain:t}={}){return(0,e.keccak256)((0,e.toHex)((t??window.location.host).replace(`www.`,``)))}const r=`frak-client-id`;function i(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function a(){if(typeof window>`u`||!window.localStorage)return i();let e=localStorage.getItem(r);return e||(e=i(),localStorage.setItem(r,e)),e}function o(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function s(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(e.length+(t===0?0:4-t),`=`)),e=>e.charCodeAt(0))}function c(e){return o((0,t.jsonEncode)(e))}function l(e,t,n,r,i,o){let s=c(u({redirectUrl:t.redirectUrl,directExit:t.directExit,lang:t.lang,merchantId:n,metadata:{name:r,css:i,logoUrl:t.metadata?.logoUrl,homepageLink:t.metadata?.homepageLink},clientId:o??a()})),l=new URL(e);return l.pathname=`/sso`,l.searchParams.set(`p`,s),l.toString()}function u(e){return{r:e.redirectUrl,cId:e.clientId,d:e.directExit,l:e.lang,m:e.merchantId,md:{n:e.metadata?.name,css:e.metadata?.css,l:e.metadata?.logoUrl,h:e.metadata?.homepageLink}}}const d=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,f=`frak-sso`;async function p(e,t){let{metadata:r,customizations:i,walletUrl:a}=e.config;if(t.openInSameWindow??!!t.redirectUrl)return await e.request({method:`frak_openSso`,params:[t,r.name,i?.css]});let o=t.ssoPopupUrl??l(a??`https://wallet.frak.id`,t,n(),r.name,i?.css),s=window.open(o,f,d);if(!s)throw Error(`Popup was blocked. Please allow popups for this site.`);return s.focus(),await e.request({method:`frak_openSso`,params:[t,r.name,i?.css]})??{}}const m=`https://backend.frak.id`;function h(e){return e.includes(`localhost:3000`)||e.includes(`localhost:3010`)}function g(e){return h(e)?`http://localhost:3030`:e.includes(`wallet-dev.frak.id`)||e.includes(`wallet.gcp-dev.frak.id`)?`https://backend.gcp-dev.frak.id`:m}function _(e){if(e)return g(e);if(typeof window<`u`){let e=window.FrakSetup?.client?.config?.walletUrl;if(e)return g(e)}return m}const v=`fCtx`;function y(t){if(t?.r)try{return o((0,e.hexToBytes)(t.r))}catch(e){console.error(`Error compressing Frak context`,{e,context:t})}}function b(t){if(!(!t||t.length===0))try{return{r:(0,e.bytesToHex)(s(t),{size:20})}}catch(e){console.error(`Error decompressing Frak context`,{e,context:t})}}function x({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(v);return t?b(t):null}function S({url:e,context:t}){if(!e)return null;let n=x({url:e}),r=n?{...n,...t}:t;if(!r.r)return null;let i=y(r);if(!i)return null;let a=new URL(e);return a.searchParams.set(v,i),a.toString()}function C(e){let t=new URL(e);return t.searchParams.delete(v),t.toString()}function w({url:e,context:t}){if(!window.location?.href||typeof window>`u`){console.error(`No window found, can't update context`);return}let n=e??window.location.href,r;r=t===null?C(n):S({url:n,context:t}),r&&window.history.replaceState(null,``,r.toString())}const T={compress:y,decompress:b,parse:x,update:S,remove:C,replaceUrl:w},E=`frak-merchant-id`;let D,O;async function k(e,t){if(D)return D;if(typeof window<`u`){let e=window.sessionStorage.getItem(E);if(e)return D=e,e}if(O)return O;O=A(e,t);let n=await O;return O=void 0,n}async function A(e,t){let n=e??(typeof window<`u`?window.location.hostname:``);if(n)try{let e=_(t),r=await fetch(`${e}/user/merchant/resolve?domain=${encodeURIComponent(n)}`);if(!r.ok){console.warn(`[Frak SDK] Merchant lookup failed for domain ${n}: ${r.status}`);return}let i=await r.json();return D=i.merchantId,typeof window<`u`&&window.sessionStorage.setItem(E,i.merchantId),D}catch(e){console.warn(`[Frak SDK] Failed to fetch merchantId:`,e);return}}function j(){D=void 0,O=void 0,typeof window<`u`&&window.sessionStorage.removeItem(E)}async function M(e,t){return e.metadata?.merchantId?e.metadata.merchantId:k(void 0,t)}function N(e,t,n={}){if(!e){console.debug(`[Frak] No client provided, skipping event tracking`);return}try{e.openPanel?.track(t,n)}catch(e){console.debug(`[Frak] Failed to track event:`,t,e)}}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return l}});