@frak-labs/core-sdk 0.2.1-beta.b38eef2e → 0.2.1-beta.bbbb3d22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/cdn/bundle.js +55 -3
- package/dist/actions-CIb7OfPp.js +1 -0
- package/dist/actions-uSbbKcu2.cjs +1 -0
- package/dist/actions.cjs +1 -1
- package/dist/actions.d.cts +3 -3
- package/dist/actions.d.ts +3 -3
- package/dist/actions.js +1 -1
- package/dist/bundle.cjs +1 -1
- package/dist/bundle.d.cts +4 -4
- package/dist/bundle.d.ts +4 -4
- package/dist/bundle.js +1 -1
- package/dist/{computeLegacyProductId-CCAZvLa5.d.cts → index-BMGEHGK_.d.ts} +91 -37
- package/dist/{computeLegacyProductId-b5cUWdAm.d.ts → index-CZ6q9BCe.d.cts} +91 -37
- package/dist/{siweAuthenticate-CnCZ7mok.d.ts → index-D9j5kJQ_.d.cts} +122 -8
- package/dist/{siweAuthenticate-CVigMOxz.d.cts → index-r9cPHZJn.d.ts} +122 -8
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/{openSso-B0g7-807.d.cts → openSso-C6AZ6DHE.d.ts} +278 -46
- package/dist/{openSso-CMzwvaCa.d.ts → openSso-DDC7BA9w.d.cts} +278 -46
- package/dist/src-CeGtGFnJ.js +13 -0
- package/dist/src-PWfXcMJt.cjs +13 -0
- package/dist/trackEvent-Ce1XlsIE.js +1 -0
- package/dist/trackEvent-CvbJTTqA.cjs +1 -0
- package/package.json +12 -13
- package/src/actions/displayEmbeddedWallet.ts +6 -2
- package/src/actions/displayModal.ts +6 -2
- package/src/actions/displaySharingPage.ts +49 -0
- package/src/actions/ensureIdentity.ts +2 -2
- package/src/actions/getMerchantInformation.test.ts +13 -1
- package/src/actions/getMerchantInformation.ts +20 -5
- package/src/actions/getMergeToken.ts +33 -0
- package/src/actions/getUserReferralStatus.ts +42 -0
- package/src/actions/index.ts +8 -1
- package/src/actions/referral/setupReferral.test.ts +79 -0
- package/src/actions/referral/setupReferral.ts +32 -0
- package/src/actions/trackPurchaseStatus.test.ts +32 -20
- package/src/actions/trackPurchaseStatus.ts +3 -5
- package/src/actions/wrapper/modalBuilder.test.ts +4 -2
- package/src/actions/wrapper/modalBuilder.ts +6 -8
- package/src/clients/createIFrameFrakClient.ts +150 -27
- package/src/clients/transports/iframeLifecycleManager.test.ts +14 -94
- package/src/clients/transports/iframeLifecycleManager.ts +35 -53
- package/src/index.ts +17 -4
- package/src/types/config.ts +10 -3
- package/src/types/index.ts +13 -1
- package/src/types/lifecycle/client.ts +22 -27
- package/src/types/lifecycle/iframe.ts +7 -8
- package/src/types/resolvedConfig.ts +123 -0
- package/src/types/rpc/displaySharingPage.ts +77 -0
- package/src/types/rpc/embedded/index.ts +1 -1
- package/src/types/rpc/interaction.ts +4 -0
- package/src/types/rpc/userReferralStatus.ts +20 -0
- package/src/types/rpc.ts +54 -5
- package/src/utils/backendUrl.test.ts +2 -2
- package/src/utils/backendUrl.ts +1 -1
- package/src/utils/cache/index.ts +7 -0
- package/src/utils/cache/lruMap.test.ts +55 -0
- package/src/utils/cache/lruMap.ts +38 -0
- package/src/utils/cache/withCache.test.ts +162 -0
- package/src/utils/cache/withCache.ts +105 -0
- package/src/utils/inAppBrowser.ts +60 -0
- package/src/utils/index.ts +6 -4
- package/src/utils/sdkConfigStore.test.ts +405 -0
- package/src/utils/sdkConfigStore.ts +263 -0
- package/src/utils/sso.ts +3 -7
- package/dist/setupClient-CqTHGvVa.cjs +0 -13
- package/dist/setupClient-DTyvAPgh.js +0 -13
- package/dist/siweAuthenticate-BWmI2_TN.cjs +0 -1
- package/dist/siweAuthenticate-zczqxm0a.js +0 -1
- package/dist/trackEvent-CeLFVzZn.js +0 -1
- package/dist/trackEvent-Ew5r5zfI.cjs +0 -1
- package/src/utils/merchantId.test.ts +0 -653
- package/src/utils/merchantId.ts +0 -143
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,i as t,l as n,n as r,r as i,t as a,u as o,y as s}from"./trackEvent-Ce1XlsIE.js";import{isAddressEqual as c}from"viem";import{Deferred as l}from"@frak-labs/frame-connector";import{generateSiweNonce as u}from"viem/siwe";async function d(e,t,n){return await e.request({method:`frak_displayEmbeddedWallet`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function f(e,{steps:t,metadata:n},r){return await e.request({method:`frak_displayModal`,params:r?[t,n,e.config.metadata,r]:[t,n,e.config.metadata]})}async function p(e,t,n){return await e.request({method:`frak_displaySharingPage`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function m(e){if(typeof window>`u`)return;let t=s();if(!t)return;let n=await r.resolveMerchantId();if(!n)return;let i=`frak-identity-ensured-${n}`;if(!window.sessionStorage.getItem(i))try{let r=o();(await fetch(`${r}/user/identity/ensure`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"x-wallet-sdk-auth":e,"x-frak-client-id":t},body:JSON.stringify({merchantId:n})})).ok&&window.sessionStorage.setItem(i,`1`)}catch{}}async function h(e,t){return n(()=>e.request({method:`frak_getMerchantInformation`}),{cacheKey:`frak_getMerchantInformation`,cacheTime:t?.cacheTime})}async function g(e,t){return n(()=>e.request({method:`frak_getMergeToken`}),{cacheKey:`frak_getMergeToken`,cacheTime:t?.cacheTime})}async function _(e,t){return n(()=>e.request({method:`frak_getUserReferralStatus`}),{cacheKey:`frak_getUserReferralStatus`,cacheTime:t?.cacheTime})}async function v(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function y(e,t){try{await e.request({method:`frak_sendInteraction`,params:[t,{clientId:s()}]})}catch{console.warn(`[Frak SDK] Failed to send interaction:`,t.type)}}function b(n,r,i){let o=typeof window<`u`?window.location.href:void 0;return e(r)?(a(n,`user_referred_started`,{properties:{referrerClientId:r.c,walletStatus:i?.key}}),y(n,{type:`arrival`,referrerClientId:r.c,referrerMerchantId:r.m,referralTimestamp:r.t,landingUrl:o}),!0):t(r)?(a(n,`user_referred_started`,{properties:{referrer:r.r,walletStatus:i?.key}}),y(n,{type:`arrival`,referrerWallet:r.r,landingUrl:o}),!0):!1}function x(e){let t=s();return t?{v:2,c:t,m:e,t:Math.floor(Date.now()/1e3)}:null}function S(n,r){return e(n)?s()===n.c:t(n)&&r?.wallet?c(n.r,r.wallet):!1}function C(t,{walletStatus:n,frakContext:r,options:o}){if(!r)return`no-referrer`;if(S(r,n))return`self-referral`;if(!b(t,r,n))return`no-referrer`;let s=e(r)?r.m:o?.merchantId,c=o?.alwaysAppendUrl&&s?x(s):null;return i.replaceUrl({url:window.location?.href,context:c}),a(t,`user_referred_completed`,{properties:{status:`success`}}),`success`}async function w(e,{options:t}={}){let n=i.parse({url:window.location.href}),r=await O(e);try{return C(e,{walletStatus:r,frakContext:n,options:t})}catch(e){console.warn(`Error processing referral`,{error:e})}}const T=`frak:referral-success`;async function E(e){try{await w(e)===`success`&&window.dispatchEvent(new Event(T))}catch(e){console.warn(`[Frak] Referral setup failed`,e)}}async function D(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=s();if(!t&&!n){console.warn(`[Frak] No identity found, skipping purchase check`);return}let i=e.merchantId??await r.resolveMerchantId();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 c=o();await fetch(`${c}/user/track/purchase`,{method:`POST`,headers:a,body:JSON.stringify({customerId:e.customerId,orderId:e.orderId,token:e.token,merchantId:i})})}function O(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(k(e,t),t));let n=new l,r=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},i=>{k(e,i),t(i),r||=(n.resolve(i),!0)}),n.promise}function k(e,t){typeof window>`u`||(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?(window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken),m(t.interactionToken)):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function A(e,{metadata:t,login:n}){return j(e,{steps:{login:n??{}},metadata:t})}function j(e,t){function n(n){return j(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return j(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}function i(n,r){return j(e,{...t,steps:{...t.steps,final:{...r,action:{key:`sharing`,options:n}}}})}async function a(n,r){return n&&(t.metadata=n(t.metadata??{})),await f(e,t,r)}return{params:t,sendTx:n,reward:r,sharing:i,display:a}}async function M(e,{tx:t,metadata:n}){return(await f(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}async function N(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 f(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:i,nonce:t?.nonce??u(),uri:t?.uri??`https://${r}`,version:t?.version??`1`,domain:r}}}})).siweAuthenticate}export{f as _,D as a,w as c,v as d,_ as f,p as g,m as h,O as i,C as l,h as m,M as n,T as o,g as p,A as r,E as s,N as t,y as u,d as v};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./trackEvent-CvbJTTqA.cjs`);let t=require(`viem`),n=require(`@frak-labs/frame-connector`),r=require(`viem/siwe`);async function i(e,t,n){return await e.request({method:`frak_displayEmbeddedWallet`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function a(e,{steps:t,metadata:n},r){return await e.request({method:`frak_displayModal`,params:r?[t,n,e.config.metadata,r]:[t,n,e.config.metadata]})}async function o(e,t,n){return await e.request({method:`frak_displaySharingPage`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function s(t){if(typeof window>`u`)return;let n=e.y();if(!n)return;let r=await e.n.resolveMerchantId();if(!r)return;let i=`frak-identity-ensured-${r}`;if(!window.sessionStorage.getItem(i))try{let a=e.u();(await fetch(`${a}/user/identity/ensure`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"x-wallet-sdk-auth":t,"x-frak-client-id":n},body:JSON.stringify({merchantId:r})})).ok&&window.sessionStorage.setItem(i,`1`)}catch{}}async function c(t,n){return e.l(()=>t.request({method:`frak_getMerchantInformation`}),{cacheKey:`frak_getMerchantInformation`,cacheTime:n?.cacheTime})}async function l(t,n){return e.l(()=>t.request({method:`frak_getMergeToken`}),{cacheKey:`frak_getMergeToken`,cacheTime:n?.cacheTime})}async function u(t,n){return e.l(()=>t.request({method:`frak_getUserReferralStatus`}),{cacheKey:`frak_getUserReferralStatus`,cacheTime:n?.cacheTime})}async function d(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function f(t,n){try{await t.request({method:`frak_sendInteraction`,params:[n,{clientId:e.y()}]})}catch{console.warn(`[Frak SDK] Failed to send interaction:`,n.type)}}function p(t,n,r){let i=typeof window<`u`?window.location.href:void 0;return e.a(n)?(e.t(t,`user_referred_started`,{properties:{referrerClientId:n.c,walletStatus:r?.key}}),f(t,{type:`arrival`,referrerClientId:n.c,referrerMerchantId:n.m,referralTimestamp:n.t,landingUrl:i}),!0):e.i(n)?(e.t(t,`user_referred_started`,{properties:{referrer:n.r,walletStatus:r?.key}}),f(t,{type:`arrival`,referrerWallet:n.r,landingUrl:i}),!0):!1}function m(t){let n=e.y();return n?{v:2,c:n,m:t,t:Math.floor(Date.now()/1e3)}:null}function h(n,r){return e.a(n)?e.y()===n.c:e.i(n)&&r?.wallet?(0,t.isAddressEqual)(n.r,r.wallet):!1}function g(t,{walletStatus:n,frakContext:r,options:i}){if(!r)return`no-referrer`;if(h(r,n))return`self-referral`;if(!p(t,r,n))return`no-referrer`;let a=e.a(r)?r.m:i?.merchantId,o=i?.alwaysAppendUrl&&a?m(a):null;return e.r.replaceUrl({url:window.location?.href,context:o}),e.t(t,`user_referred_completed`,{properties:{status:`success`}}),`success`}async function _(t,{options:n}={}){let r=e.r.parse({url:window.location.href}),i=await x(t);try{return g(t,{walletStatus:i,frakContext:r,options:n})}catch(e){console.warn(`Error processing referral`,{error:e})}}const v=`frak:referral-success`;async function y(e){try{await _(e)===`success`&&window.dispatchEvent(new Event(v))}catch(e){console.warn(`[Frak] Referral setup failed`,e)}}async function b(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.y();if(!n&&!r){console.warn(`[Frak] No identity found, skipping purchase check`);return}let i=t.merchantId??await e.n.resolveMerchantId();if(!i){console.warn(`[Frak] No merchant id found, skipping purchase check`);return}let a={Accept:`application/json`,"Content-Type":`application/json`};n&&(a[`x-wallet-sdk-auth`]=n),r&&(a[`x-frak-client-id`]=r);let o=e.u();await fetch(`${o}/user/track/purchase`,{method:`POST`,headers:a,body:JSON.stringify({customerId:t.customerId,orderId:t.orderId,token:t.token,merchantId:i})})}function x(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(S(e,t),t));let r=new n.Deferred,i=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},n=>{S(e,n),t(n),i||=(r.resolve(n),!0)}),r.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),s(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 o(n,r){return n&&(t.metadata=n(t.metadata??{})),await a(e,t,r)}return{params:t,sendTx:n,reward:r,sharing:i,display:o}}async function T(e,{tx:t,metadata:n}){return(await a(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}async function E(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,`_`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return T}}),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 C}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return i}});
|
package/dist/actions.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./trackEvent-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./trackEvent-CvbJTTqA.cjs`),t=require(`./actions-uSbbKcu2.cjs`);exports.REFERRAL_SUCCESS_EVENT=t.o,exports.displayEmbeddedWallet=t.v,exports.displayModal=t._,exports.displaySharingPage=t.g,exports.ensureIdentity=t.h,exports.getMerchantInformation=t.m,exports.getMergeToken=t.p,exports.getUserReferralStatus=t.f,exports.modalBuilder=t.r,exports.openSso=e.d,exports.prepareSso=t.d,exports.processReferral=t.l,exports.referralInteraction=t.c,exports.sendInteraction=t.u,exports.sendTransaction=t.n,exports.setupReferral=t.s,exports.siweAuthenticate=t.t,exports.trackPurchaseStatus=t.a,exports.watchWalletStatus=t.i;
|
package/dist/actions.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as openSso } from "./openSso-
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
1
|
+
import { t as openSso } from "./openSso-DDC7BA9w.cjs";
|
|
2
|
+
import { C as displayEmbeddedWallet, S as displayModal, _ as getUserReferralStatus, a as ModalBuilder, b as ensureIdentity, c as watchWalletStatus, d as REFERRAL_SUCCESS_EVENT, f as setupReferral, g as prepareSso, h as processReferral, i as sendTransaction, l as trackPurchaseStatus, m as ProcessReferralOptions, n as siweAuthenticate, o as ModalStepBuilder, p as referralInteraction, r as SendTransactionParams, s as modalBuilder, t as SiweAuthenticateModalParams, u as sendInteraction, v as getMergeToken, x as displaySharingPage, y as getMerchantInformation } from "./index-D9j5kJQ_.cjs";
|
|
3
|
+
export { ModalBuilder, ModalStepBuilder, ProcessReferralOptions, REFERRAL_SUCCESS_EVENT, SendTransactionParams, SiweAuthenticateModalParams, displayEmbeddedWallet, displayModal, displaySharingPage, ensureIdentity, getMerchantInformation, getMergeToken, getUserReferralStatus, modalBuilder, openSso, prepareSso, processReferral, referralInteraction, sendInteraction, sendTransaction, setupReferral, siweAuthenticate, trackPurchaseStatus, watchWalletStatus };
|
package/dist/actions.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as openSso } from "./openSso-
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
1
|
+
import { t as openSso } from "./openSso-C6AZ6DHE.js";
|
|
2
|
+
import { C as displayEmbeddedWallet, S as displayModal, _ as getUserReferralStatus, a as ModalBuilder, b as ensureIdentity, c as watchWalletStatus, d as REFERRAL_SUCCESS_EVENT, f as setupReferral, g as prepareSso, h as processReferral, i as sendTransaction, l as trackPurchaseStatus, m as ProcessReferralOptions, n as siweAuthenticate, o as ModalStepBuilder, p as referralInteraction, r as SendTransactionParams, s as modalBuilder, t as SiweAuthenticateModalParams, u as sendInteraction, v as getMergeToken, x as displaySharingPage, y as getMerchantInformation } from "./index-r9cPHZJn.js";
|
|
3
|
+
export { ModalBuilder, ModalStepBuilder, ProcessReferralOptions, REFERRAL_SUCCESS_EVENT, SendTransactionParams, SiweAuthenticateModalParams, displayEmbeddedWallet, displayModal, displaySharingPage, ensureIdentity, getMerchantInformation, getMergeToken, getUserReferralStatus, modalBuilder, openSso, prepareSso, processReferral, referralInteraction, sendInteraction, sendTransaction, setupReferral, siweAuthenticate, trackPurchaseStatus, watchWalletStatus };
|
package/dist/actions.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{d as e}from"./trackEvent-Ce1XlsIE.js";import{_ as t,a as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as u,n as d,o as f,p,r as m,s as h,t as g,u as _,v}from"./actions-CIb7OfPp.js";export{f as REFERRAL_SUCCESS_EVENT,v as displayEmbeddedWallet,t as displayModal,o as displaySharingPage,s as ensureIdentity,u as getMerchantInformation,p as getMergeToken,a as getUserReferralStatus,m as modalBuilder,e as openSso,i as prepareSso,l as processReferral,r as referralInteraction,_ as sendInteraction,d as sendTransaction,h as setupReferral,g as siweAuthenticate,n as trackPurchaseStatus,c as watchWalletStatus};
|
package/dist/bundle.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./trackEvent-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./trackEvent-CvbJTTqA.cjs`),t=require(`./src-PWfXcMJt.cjs`),n=require(`./actions-uSbbKcu2.cjs`);exports.DEEP_LINK_SCHEME=t.y,exports.DebugInfoGatherer=t.r,exports.FrakContextManager=e.r,exports.REFERRAL_SUCCESS_EVENT=n.o,exports.base64urlDecode=e.g,exports.base64urlEncode=e._,exports.baseIframeProps=t.s,exports.clearAllCache=e.s,exports.compressJsonToB64=e.h,exports.computeLegacyProductId=e.v,exports.createIFrameFrakClient=t.n,exports.createIframe=t.c,exports.decompressJsonFromB64=e.o,exports.displayEmbeddedWallet=n.v,exports.displayModal=n._,exports.displaySharingPage=n.g,exports.ensureIdentity=n.h,exports.findIframeInOpener=t.l,exports.formatAmount=t.d,exports.generateSsoUrl=e.m,exports.getBackendUrl=e.u,exports.getCache=e.c,exports.getClientId=e.y,exports.getCurrencyAmountKey=t.u,exports.getMerchantInformation=n.m,exports.getMergeToken=n.p,exports.getSupportedCurrency=t.p,exports.getSupportedLocale=t.f,exports.getUserReferralStatus=n.f,exports.isChromiumAndroid=t.h,exports.isFrakDeepLink=t.g,exports.isIOS=t.i,exports.isInAppBrowser=t.a,exports.isV1Context=e.i,exports.isV2Context=e.a,exports.locales=t.m,exports.modalBuilder=n.r,exports.openSso=e.d,exports.prepareSso=n.d,exports.processReferral=n.l,exports.redirectToExternalBrowser=t.o,exports.referralInteraction=n.c,exports.sdkConfigStore=e.n,exports.sendInteraction=n.u,exports.sendTransaction=n.n,exports.setupClient=t.t,exports.setupReferral=n.s,exports.siweAuthenticate=n.t,exports.ssoPopupFeatures=e.f,exports.ssoPopupName=e.p,exports.toAndroidIntentUrl=t._,exports.trackEvent=e.t,exports.trackPurchaseStatus=n.a,exports.triggerDeepLinkWithFallback=t.v,exports.watchWalletStatus=n.i,exports.withCache=e.l;
|
package/dist/bundle.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { A as
|
|
3
|
-
import {
|
|
4
|
-
export { AppSpecificSsoMetadata, ClientLifecycleEvent, CompressedData, CompressedSsoData, Currency, DEEP_LINK_SCHEME, DebugInfoGatherer, DeepLinkFallbackOptions, DisplayEmbeddedWalletParamsType, DisplayEmbeddedWalletResultType, DisplayModalParamsType, EmbeddedViewActionReferred, EmbeddedViewActionSharing, EstimatedReward, FinalActionType, FinalModalStepType, FrakClient, FrakContext, FrakContextManager, FrakContextV1, FrakContextV2, 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,
|
|
1
|
+
import { $ as ResolvedPlacement, A as ModalRpcMetadata, B as LoginModalStepType, C as EmbeddedViewActionReferred, D as DisplaySharingPageResultType, E as DisplaySharingPageParamsType, F as SendTransactionReturnType, G as SsoMetadata, H as OpenSsoReturnType, I as SendTransactionTxType, J as ModalStepMetadata, K as FinalActionType, L as SiweAuthenticateModalStepType, M as ModalRpcStepsResultType, N as ModalStepTypes, O as SharingPageProduct, P as SendTransactionModalStepType, Q as MerchantConfigResponse, R as SiweAuthenticateReturnType, S as LoggedOutEmbeddedView, T as LoggedInEmbeddedView, U as PrepareSsoParamsType, V as OpenSsoParamsType, W as PrepareSsoReturnType, X as IFrameLifecycleEvent, Y as InteractionTypeKey, Z as ClientLifecycleEvent, _ as RewardTier, a as FrakContextV1, at as Language, b as DisplayEmbeddedWalletParamsType, c as isV2Context, d as IFrameTransport, et as ResolvedSdkConfig, f as IFrameRpcSchema, g as GetMerchantInformationReturnType, h as EstimatedReward, i as FrakContext, it as I18nConfig, j as ModalRpcStepsInput, k as DisplayModalParamsType, l as FrakClient, m as UserReferralStatusType, n as ssoPopupFeatures, nt as Currency, o as FrakContextV2, ot as LocalizedI18nConfig, p as WalletStatusReturnType, q as FinalModalStepType, r as ssoPopupName, rt as FrakWalletSdkConfig, s as isV1Context, t as openSso, tt as SdkResolvedConfig, u as FrakLifecycleEvent, v as TokenAmountType, w as EmbeddedViewActionSharing, x as DisplayEmbeddedWalletResultType, y as SendInteractionParamsType, z as SiweAuthenticationParams } from "./openSso-DDC7BA9w.cjs";
|
|
2
|
+
import { A as getClientId, B as TrackArrivalParams, C as toAndroidIntentUrl, D as compressJsonToB64, E as decompressJsonFromB64, F as LocalesKey, G as KeyProvider, H as UtmParams, I as locales, L as setupClient, M as getCache, N as withCache, O as base64urlDecode, P as getBackendUrl, R as DebugInfoGatherer, S as isFrakDeepLink, T as DEEP_LINK_SCHEME, U as CompressedData, V as TrackArrivalResult, W as HashProtectedData, _ as getCurrencyAmountKey, a as CompressedSsoData, b as DeepLinkFallbackOptions, c as sdkConfigStore, d as redirectToExternalBrowser, f as baseIframeProps, g as getSupportedCurrency, h as getSupportedLocale, i as AppSpecificSsoMetadata, j as clearAllCache, k as base64urlEncode, l as isIOS, m as findIframeInOpener, n as FrakEvent, o as FullSsoParams, p as createIframe, r as trackEvent, s as generateSsoUrl, t as computeLegacyProductId, u as isInAppBrowser, v as formatAmount, w as triggerDeepLinkWithFallback, x as isChromiumAndroid, y as FrakContextManager, z as createIFrameFrakClient } from "./index-CZ6q9BCe.cjs";
|
|
3
|
+
import { C as displayEmbeddedWallet, S as displayModal, _ as getUserReferralStatus, a as ModalBuilder, b as ensureIdentity, c as watchWalletStatus, d as REFERRAL_SUCCESS_EVENT, f as setupReferral, g as prepareSso, h as processReferral, i as sendTransaction, l as trackPurchaseStatus, m as ProcessReferralOptions, n as siweAuthenticate, o as ModalStepBuilder, p as referralInteraction, r as SendTransactionParams, s as modalBuilder, t as SiweAuthenticateModalParams, u as sendInteraction, v as getMergeToken, x as displaySharingPage, y as getMerchantInformation } from "./index-D9j5kJQ_.cjs";
|
|
4
|
+
export { AppSpecificSsoMetadata, ClientLifecycleEvent, CompressedData, CompressedSsoData, Currency, DEEP_LINK_SCHEME, DebugInfoGatherer, DeepLinkFallbackOptions, DisplayEmbeddedWalletParamsType, DisplayEmbeddedWalletResultType, DisplayModalParamsType, DisplaySharingPageParamsType, DisplaySharingPageResultType, EmbeddedViewActionReferred, EmbeddedViewActionSharing, EstimatedReward, FinalActionType, FinalModalStepType, FrakClient, FrakContext, FrakContextManager, FrakContextV1, FrakContextV2, FrakEvent, FrakLifecycleEvent, FrakWalletSdkConfig, FullSsoParams, GetMerchantInformationReturnType, HashProtectedData, I18nConfig, IFrameLifecycleEvent, IFrameRpcSchema, IFrameTransport, InteractionTypeKey, KeyProvider, Language, LocalesKey, LocalizedI18nConfig, LoggedInEmbeddedView, LoggedOutEmbeddedView, LoginModalStepType, MerchantConfigResponse, ModalBuilder, ModalRpcMetadata, ModalRpcStepsInput, ModalRpcStepsResultType, ModalStepBuilder, ModalStepMetadata, ModalStepTypes, OpenSsoParamsType, OpenSsoReturnType, PrepareSsoParamsType, PrepareSsoReturnType, ProcessReferralOptions, REFERRAL_SUCCESS_EVENT, ResolvedPlacement, ResolvedSdkConfig, RewardTier, SdkResolvedConfig, SendInteractionParamsType, SendTransactionModalStepType, SendTransactionParams, SendTransactionReturnType, SendTransactionTxType, SharingPageProduct, SiweAuthenticateModalParams, SiweAuthenticateModalStepType, SiweAuthenticateReturnType, SiweAuthenticationParams, SsoMetadata, TokenAmountType, TrackArrivalParams, TrackArrivalResult, UserReferralStatusType, UtmParams, WalletStatusReturnType, base64urlDecode, base64urlEncode, baseIframeProps, clearAllCache, compressJsonToB64, computeLegacyProductId, createIFrameFrakClient, createIframe, decompressJsonFromB64, displayEmbeddedWallet, displayModal, displaySharingPage, ensureIdentity, findIframeInOpener, formatAmount, generateSsoUrl, getBackendUrl, getCache, getClientId, getCurrencyAmountKey, getMerchantInformation, getMergeToken, getSupportedCurrency, getSupportedLocale, getUserReferralStatus, isChromiumAndroid, isFrakDeepLink, isIOS, isInAppBrowser, isV1Context, isV2Context, locales, modalBuilder, openSso, prepareSso, processReferral, redirectToExternalBrowser, referralInteraction, sdkConfigStore, sendInteraction, sendTransaction, setupClient, setupReferral, siweAuthenticate, ssoPopupFeatures, ssoPopupName, toAndroidIntentUrl, trackEvent, trackPurchaseStatus, triggerDeepLinkWithFallback, watchWalletStatus, withCache };
|
package/dist/bundle.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { A as
|
|
3
|
-
import {
|
|
4
|
-
export { AppSpecificSsoMetadata, ClientLifecycleEvent, CompressedData, CompressedSsoData, Currency, DEEP_LINK_SCHEME, DebugInfoGatherer, DeepLinkFallbackOptions, DisplayEmbeddedWalletParamsType, DisplayEmbeddedWalletResultType, DisplayModalParamsType, EmbeddedViewActionReferred, EmbeddedViewActionSharing, EstimatedReward, FinalActionType, FinalModalStepType, FrakClient, FrakContext, FrakContextManager, FrakContextV1, FrakContextV2, 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,
|
|
1
|
+
import { $ as ResolvedPlacement, A as ModalRpcMetadata, B as LoginModalStepType, C as EmbeddedViewActionReferred, D as DisplaySharingPageResultType, E as DisplaySharingPageParamsType, F as SendTransactionReturnType, G as SsoMetadata, H as OpenSsoReturnType, I as SendTransactionTxType, J as ModalStepMetadata, K as FinalActionType, L as SiweAuthenticateModalStepType, M as ModalRpcStepsResultType, N as ModalStepTypes, O as SharingPageProduct, P as SendTransactionModalStepType, Q as MerchantConfigResponse, R as SiweAuthenticateReturnType, S as LoggedOutEmbeddedView, T as LoggedInEmbeddedView, U as PrepareSsoParamsType, V as OpenSsoParamsType, W as PrepareSsoReturnType, X as IFrameLifecycleEvent, Y as InteractionTypeKey, Z as ClientLifecycleEvent, _ as RewardTier, a as FrakContextV1, at as Language, b as DisplayEmbeddedWalletParamsType, c as isV2Context, d as IFrameTransport, et as ResolvedSdkConfig, f as IFrameRpcSchema, g as GetMerchantInformationReturnType, h as EstimatedReward, i as FrakContext, it as I18nConfig, j as ModalRpcStepsInput, k as DisplayModalParamsType, l as FrakClient, m as UserReferralStatusType, n as ssoPopupFeatures, nt as Currency, o as FrakContextV2, ot as LocalizedI18nConfig, p as WalletStatusReturnType, q as FinalModalStepType, r as ssoPopupName, rt as FrakWalletSdkConfig, s as isV1Context, t as openSso, tt as SdkResolvedConfig, u as FrakLifecycleEvent, v as TokenAmountType, w as EmbeddedViewActionSharing, x as DisplayEmbeddedWalletResultType, y as SendInteractionParamsType, z as SiweAuthenticationParams } from "./openSso-C6AZ6DHE.js";
|
|
2
|
+
import { A as getClientId, B as TrackArrivalParams, C as toAndroidIntentUrl, D as compressJsonToB64, E as decompressJsonFromB64, F as LocalesKey, G as KeyProvider, H as UtmParams, I as locales, L as setupClient, M as getCache, N as withCache, O as base64urlDecode, P as getBackendUrl, R as DebugInfoGatherer, S as isFrakDeepLink, T as DEEP_LINK_SCHEME, U as CompressedData, V as TrackArrivalResult, W as HashProtectedData, _ as getCurrencyAmountKey, a as CompressedSsoData, b as DeepLinkFallbackOptions, c as sdkConfigStore, d as redirectToExternalBrowser, f as baseIframeProps, g as getSupportedCurrency, h as getSupportedLocale, i as AppSpecificSsoMetadata, j as clearAllCache, k as base64urlEncode, l as isIOS, m as findIframeInOpener, n as FrakEvent, o as FullSsoParams, p as createIframe, r as trackEvent, s as generateSsoUrl, t as computeLegacyProductId, u as isInAppBrowser, v as formatAmount, w as triggerDeepLinkWithFallback, x as isChromiumAndroid, y as FrakContextManager, z as createIFrameFrakClient } from "./index-BMGEHGK_.js";
|
|
3
|
+
import { C as displayEmbeddedWallet, S as displayModal, _ as getUserReferralStatus, a as ModalBuilder, b as ensureIdentity, c as watchWalletStatus, d as REFERRAL_SUCCESS_EVENT, f as setupReferral, g as prepareSso, h as processReferral, i as sendTransaction, l as trackPurchaseStatus, m as ProcessReferralOptions, n as siweAuthenticate, o as ModalStepBuilder, p as referralInteraction, r as SendTransactionParams, s as modalBuilder, t as SiweAuthenticateModalParams, u as sendInteraction, v as getMergeToken, x as displaySharingPage, y as getMerchantInformation } from "./index-r9cPHZJn.js";
|
|
4
|
+
export { AppSpecificSsoMetadata, ClientLifecycleEvent, CompressedData, CompressedSsoData, Currency, DEEP_LINK_SCHEME, DebugInfoGatherer, DeepLinkFallbackOptions, DisplayEmbeddedWalletParamsType, DisplayEmbeddedWalletResultType, DisplayModalParamsType, DisplaySharingPageParamsType, DisplaySharingPageResultType, EmbeddedViewActionReferred, EmbeddedViewActionSharing, EstimatedReward, FinalActionType, FinalModalStepType, FrakClient, FrakContext, FrakContextManager, FrakContextV1, FrakContextV2, FrakEvent, FrakLifecycleEvent, FrakWalletSdkConfig, FullSsoParams, GetMerchantInformationReturnType, HashProtectedData, I18nConfig, IFrameLifecycleEvent, IFrameRpcSchema, IFrameTransport, InteractionTypeKey, KeyProvider, Language, LocalesKey, LocalizedI18nConfig, LoggedInEmbeddedView, LoggedOutEmbeddedView, LoginModalStepType, MerchantConfigResponse, ModalBuilder, ModalRpcMetadata, ModalRpcStepsInput, ModalRpcStepsResultType, ModalStepBuilder, ModalStepMetadata, ModalStepTypes, OpenSsoParamsType, OpenSsoReturnType, PrepareSsoParamsType, PrepareSsoReturnType, ProcessReferralOptions, REFERRAL_SUCCESS_EVENT, ResolvedPlacement, ResolvedSdkConfig, RewardTier, SdkResolvedConfig, SendInteractionParamsType, SendTransactionModalStepType, SendTransactionParams, SendTransactionReturnType, SendTransactionTxType, SharingPageProduct, SiweAuthenticateModalParams, SiweAuthenticateModalStepType, SiweAuthenticateReturnType, SiweAuthenticationParams, SsoMetadata, TokenAmountType, TrackArrivalParams, TrackArrivalResult, UserReferralStatusType, UtmParams, WalletStatusReturnType, base64urlDecode, base64urlEncode, baseIframeProps, clearAllCache, compressJsonToB64, computeLegacyProductId, createIFrameFrakClient, createIframe, decompressJsonFromB64, displayEmbeddedWallet, displayModal, displaySharingPage, ensureIdentity, findIframeInOpener, formatAmount, generateSsoUrl, getBackendUrl, getCache, getClientId, getCurrencyAmountKey, getMerchantInformation, getMergeToken, getSupportedCurrency, getSupportedLocale, getUserReferralStatus, isChromiumAndroid, isFrakDeepLink, isIOS, isInAppBrowser, isV1Context, isV2Context, locales, modalBuilder, openSso, prepareSso, processReferral, redirectToExternalBrowser, referralInteraction, sdkConfigStore, sendInteraction, sendTransaction, setupClient, setupReferral, siweAuthenticate, ssoPopupFeatures, ssoPopupName, toAndroidIntentUrl, trackEvent, trackPurchaseStatus, triggerDeepLinkWithFallback, watchWalletStatus, withCache };
|
package/dist/bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,u as g,v as _}from"./trackEvent-
|
|
1
|
+
import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,u as g,v as _,y as v}from"./trackEvent-Ce1XlsIE.js";import{_ as y,a as b,c as x,d as S,f as C,g as w,h as T,i as E,l as D,m as O,n as k,o as A,p as j,r as M,s as N,t as P,u as F,v as I,y as L}from"./src-CeGtGFnJ.js";import{_ as R,a as z,c as B,d as V,f as H,g as U,h as W,i as G,l as K,m as q,n as J,o as Y,p as X,r as Z,s as Q,t as $,u as ee,v as te}from"./actions-CIb7OfPp.js";export{L as DEEP_LINK_SCHEME,M as DebugInfoGatherer,p as FrakContextManager,Y as REFERRAL_SUCCESS_EVENT,a as base64urlDecode,e as base64urlEncode,N as baseIframeProps,m as clearAllCache,o as compressJsonToB64,_ as computeLegacyProductId,k as createIFrameFrakClient,x as createIframe,d as decompressJsonFromB64,te as displayEmbeddedWallet,R as displayModal,U as displaySharingPage,W as ensureIdentity,D as findIframeInOpener,S as formatAmount,l as generateSsoUrl,g as getBackendUrl,n as getCache,v as getClientId,F as getCurrencyAmountKey,q as getMerchantInformation,X as getMergeToken,j as getSupportedCurrency,C as getSupportedLocale,H as getUserReferralStatus,T as isChromiumAndroid,w as isFrakDeepLink,E as isIOS,b as isInAppBrowser,s as isV1Context,t as isV2Context,O as locales,Z as modalBuilder,r as openSso,V as prepareSso,K as processReferral,A as redirectToExternalBrowser,B as referralInteraction,u as sdkConfigStore,ee as sendInteraction,J as sendTransaction,P as setupClient,Q as setupReferral,$ as siweAuthenticate,i as ssoPopupFeatures,f as ssoPopupName,y as toAndroidIntentUrl,h as trackEvent,z as trackPurchaseStatus,I as triggerDeepLinkWithFallback,G as watchWalletStatus,c as withCache};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { RpcMessage, RpcResponse } from "@frak-labs/frame-connector";
|
|
1
|
+
import { G as SsoMetadata, Q as MerchantConfigResponse, U as PrepareSsoParamsType, a as FrakContextV1, at as Language, i as FrakContext, l as FrakClient, nt as Currency, o as FrakContextV2, rt as FrakWalletSdkConfig, tt as SdkResolvedConfig, v as TokenAmountType } from "./openSso-C6AZ6DHE.js";
|
|
3
2
|
import { Address, Hex } from "viem";
|
|
3
|
+
import { RpcMessage, RpcResponse } from "@frak-labs/frame-connector";
|
|
4
4
|
|
|
5
5
|
//#region src/types/compression.d.ts
|
|
6
6
|
/**
|
|
@@ -50,7 +50,7 @@ type TrackArrivalResult = {
|
|
|
50
50
|
* Create a new iframe Frak client
|
|
51
51
|
* @param args
|
|
52
52
|
* @param args.config - The configuration to use for the Frak Wallet SDK.
|
|
53
|
-
* When `config.domain` is set, it is
|
|
53
|
+
* When `config.domain` is set, it is used to resolve the correct merchant config in tunneled/proxied environments (e.g. Shopify dev with Cloudflare tunnel).
|
|
54
54
|
* @param args.iframe - The iframe to use for the communication
|
|
55
55
|
* @returns The created Frak Client
|
|
56
56
|
*
|
|
@@ -143,6 +143,50 @@ declare const locales: {
|
|
|
143
143
|
*/
|
|
144
144
|
declare function getBackendUrl(walletUrl?: string): string;
|
|
145
145
|
//#endregion
|
|
146
|
+
//#region src/utils/cache/withCache.d.ts
|
|
147
|
+
type WithCacheOptions = {
|
|
148
|
+
/** The key to cache the data against */cacheKey: string; /** Time in ms that cached data will remain valid. Default: 30_000 (30s). Set to 0 to disable caching. */
|
|
149
|
+
cacheTime?: number;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Returns the result of a given promise, and caches the result for
|
|
153
|
+
* subsequent invocations against a provided cache key.
|
|
154
|
+
*
|
|
155
|
+
* Also deduplicates concurrent calls — if multiple callers request the same
|
|
156
|
+
* cache key while the promise is pending, they share the same promise.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```ts
|
|
160
|
+
* // First call fetches, subsequent calls return cached data for 30s
|
|
161
|
+
* const data = await withCache(
|
|
162
|
+
* () => client.request({ method: "frak_getMerchantInformation" }),
|
|
163
|
+
* { cacheKey: "merchantInfo", cacheTime: 30_000 }
|
|
164
|
+
* );
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
declare function withCache<TData>(fn: () => Promise<TData>, {
|
|
168
|
+
cacheKey,
|
|
169
|
+
cacheTime
|
|
170
|
+
}: WithCacheOptions): Promise<TData>;
|
|
171
|
+
/**
|
|
172
|
+
* Get a cache handle for a specific key, useful for manual invalidation.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```ts
|
|
176
|
+
* // Invalidate merchant info cache after a mutation
|
|
177
|
+
* getCache("frak_getMerchantInformation").clear();
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
declare function getCache(cacheKey: string): {
|
|
181
|
+
/** Clear both the pending promise and the cached response */clear: () => void; /** Check if a non-expired response exists */
|
|
182
|
+
has: (cacheTime?: number) => boolean;
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* Clear all cached data (both pending promises and resolved responses).
|
|
186
|
+
* Called automatically when the client is destroyed.
|
|
187
|
+
*/
|
|
188
|
+
declare function clearAllCache(): void;
|
|
189
|
+
//#endregion
|
|
146
190
|
//#region src/utils/clientId.d.ts
|
|
147
191
|
/**
|
|
148
192
|
* Client ID utilities for anonymous tracking
|
|
@@ -415,47 +459,57 @@ declare function createIframe({
|
|
|
415
459
|
*/
|
|
416
460
|
declare function findIframeInOpener(pathname?: string): Window | null;
|
|
417
461
|
//#endregion
|
|
418
|
-
//#region src/utils/
|
|
419
|
-
/**
|
|
420
|
-
* Merchant ID utilities for auto-fetching from backend
|
|
421
|
-
*/
|
|
462
|
+
//#region src/utils/inAppBrowser.d.ts
|
|
422
463
|
/**
|
|
423
|
-
*
|
|
424
|
-
*
|
|
425
|
-
* @param domain - The domain to lookup (defaults to current hostname)
|
|
426
|
-
* @param walletUrl - Optional wallet URL to derive backend URL
|
|
427
|
-
* @returns The merchantId if found, undefined otherwise
|
|
428
|
-
*
|
|
429
|
-
* @example
|
|
430
|
-
* ```ts
|
|
431
|
-
* const merchantId = await fetchMerchantId("shop.example.com");
|
|
432
|
-
* if (merchantId) {
|
|
433
|
-
* // Use merchantId for tracking
|
|
434
|
-
* }
|
|
435
|
-
* ```
|
|
464
|
+
* Whether the current device runs iOS (including iPadOS 13+).
|
|
436
465
|
*/
|
|
437
|
-
declare
|
|
466
|
+
declare const isIOS: boolean;
|
|
438
467
|
/**
|
|
439
|
-
*
|
|
440
|
-
*
|
|
468
|
+
* Whether the current browser is a social media in-app browser
|
|
469
|
+
* (Instagram, Facebook).
|
|
441
470
|
*/
|
|
442
|
-
declare
|
|
471
|
+
declare const isInAppBrowser: boolean;
|
|
443
472
|
/**
|
|
444
|
-
*
|
|
473
|
+
* Redirect to external browser from in-app WebView.
|
|
474
|
+
*
|
|
475
|
+
* - **iOS**: Uses `x-safari-https://` scheme — server-side 302 redirects
|
|
476
|
+
* to custom URL schemes are silently swallowed by WKWebView.
|
|
477
|
+
* Direct `window.location.href` assignment works (confirmed iOS 17+).
|
|
445
478
|
*
|
|
446
|
-
*
|
|
447
|
-
*
|
|
448
|
-
*
|
|
479
|
+
* - **Android**: Uses backend `/common/social` endpoint which returns a PDF
|
|
480
|
+
* Content-Type response, forcing the WebView to hand off to the default browser.
|
|
481
|
+
*
|
|
482
|
+
* @param targetUrl - The URL to open in the external browser
|
|
449
483
|
*/
|
|
450
|
-
declare function
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
484
|
+
declare function redirectToExternalBrowser(targetUrl: string): void;
|
|
485
|
+
//#endregion
|
|
486
|
+
//#region src/utils/sdkConfigStore.d.ts
|
|
487
|
+
declare const GLOBAL_KEY = "__frakSdkConfig";
|
|
488
|
+
declare global {
|
|
489
|
+
interface Window {
|
|
490
|
+
[GLOBAL_KEY]?: SdkResolvedConfig;
|
|
491
|
+
}
|
|
492
|
+
interface WindowEventMap {
|
|
493
|
+
"frak:config": CustomEvent<SdkResolvedConfig>;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
declare function getConfig(): SdkResolvedConfig;
|
|
497
|
+
declare const sdkConfigStore: {
|
|
498
|
+
getConfig: typeof getConfig;
|
|
499
|
+
readonly isResolved: boolean;
|
|
500
|
+
readonly isCacheFresh: boolean;
|
|
501
|
+
setCacheScope(domain: string, lang?: string): void;
|
|
502
|
+
setConfig(config: SdkResolvedConfig): void;
|
|
503
|
+
reset(): void;
|
|
504
|
+
clearCache(): void;
|
|
505
|
+
resolve(domain?: string, walletUrl?: string, lang?: Language): Promise<MerchantConfigResponse | undefined>;
|
|
506
|
+
getMerchantId(): string | undefined;
|
|
507
|
+
resolveMerchantId(domain?: string, walletUrl?: string): Promise<string | undefined>;
|
|
508
|
+
};
|
|
455
509
|
//#endregion
|
|
456
510
|
//#region src/utils/sso.d.ts
|
|
457
511
|
type AppSpecificSsoMetadata = SsoMetadata & {
|
|
458
|
-
name
|
|
512
|
+
name?: string;
|
|
459
513
|
css?: string;
|
|
460
514
|
};
|
|
461
515
|
/**
|
|
@@ -489,7 +543,7 @@ type FullSsoParams = Omit<PrepareSsoParamsType, "metadata"> & {
|
|
|
489
543
|
* // Returns: https://wallet.frak.id/sso?p=<compressed_base64>
|
|
490
544
|
* ```
|
|
491
545
|
*/
|
|
492
|
-
declare function generateSsoUrl(walletUrl: string, params: PrepareSsoParamsType, merchantId: string, name: string, clientId: string, css?: string): string;
|
|
546
|
+
declare function generateSsoUrl(walletUrl: string, params: PrepareSsoParamsType, merchantId: string, name: string | undefined, clientId: string, css?: string): string;
|
|
493
547
|
/**
|
|
494
548
|
* Type of compressed the sso data
|
|
495
549
|
*/
|
|
@@ -501,7 +555,7 @@ type CompressedSsoData = {
|
|
|
501
555
|
l?: "en" | "fr";
|
|
502
556
|
m: string;
|
|
503
557
|
md: {
|
|
504
|
-
n
|
|
558
|
+
n?: string;
|
|
505
559
|
css?: string;
|
|
506
560
|
l?: string;
|
|
507
561
|
h?: string;
|
|
@@ -534,4 +588,4 @@ declare function computeLegacyProductId({
|
|
|
534
588
|
domain?: string;
|
|
535
589
|
}): `0x${string}`;
|
|
536
590
|
//#endregion
|
|
537
|
-
export {
|
|
591
|
+
export { getClientId as A, TrackArrivalParams as B, toAndroidIntentUrl as C, compressJsonToB64 as D, decompressJsonFromB64 as E, LocalesKey as F, KeyProvider as G, UtmParams as H, locales as I, setupClient as L, getCache as M, withCache as N, base64urlDecode as O, getBackendUrl as P, DebugInfoGatherer as R, isFrakDeepLink as S, DEEP_LINK_SCHEME as T, CompressedData as U, TrackArrivalResult as V, HashProtectedData as W, getCurrencyAmountKey as _, CompressedSsoData as a, DeepLinkFallbackOptions as b, sdkConfigStore as c, redirectToExternalBrowser as d, baseIframeProps as f, getSupportedCurrency as g, getSupportedLocale as h, AppSpecificSsoMetadata as i, clearAllCache as j, base64urlEncode as k, isIOS as l, findIframeInOpener as m, FrakEvent as n, FullSsoParams as o, createIframe as p, trackEvent as r, generateSsoUrl as s, computeLegacyProductId as t, isInAppBrowser as u, formatAmount as v, triggerDeepLinkWithFallback as w, isChromiumAndroid as x, FrakContextManager as y, createIFrameFrakClient as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Address, Hex } from "viem";
|
|
1
|
+
import { G as SsoMetadata, Q as MerchantConfigResponse, U as PrepareSsoParamsType, a as FrakContextV1, at as Language, i as FrakContext, l as FrakClient, nt as Currency, o as FrakContextV2, rt as FrakWalletSdkConfig, tt as SdkResolvedConfig, v as TokenAmountType } from "./openSso-DDC7BA9w.cjs";
|
|
3
2
|
import { RpcMessage, RpcResponse } from "@frak-labs/frame-connector";
|
|
3
|
+
import { Address, Hex } from "viem";
|
|
4
4
|
|
|
5
5
|
//#region src/types/compression.d.ts
|
|
6
6
|
/**
|
|
@@ -50,7 +50,7 @@ type TrackArrivalResult = {
|
|
|
50
50
|
* Create a new iframe Frak client
|
|
51
51
|
* @param args
|
|
52
52
|
* @param args.config - The configuration to use for the Frak Wallet SDK.
|
|
53
|
-
* When `config.domain` is set, it is
|
|
53
|
+
* When `config.domain` is set, it is used to resolve the correct merchant config in tunneled/proxied environments (e.g. Shopify dev with Cloudflare tunnel).
|
|
54
54
|
* @param args.iframe - The iframe to use for the communication
|
|
55
55
|
* @returns The created Frak Client
|
|
56
56
|
*
|
|
@@ -143,6 +143,50 @@ declare const locales: {
|
|
|
143
143
|
*/
|
|
144
144
|
declare function getBackendUrl(walletUrl?: string): string;
|
|
145
145
|
//#endregion
|
|
146
|
+
//#region src/utils/cache/withCache.d.ts
|
|
147
|
+
type WithCacheOptions = {
|
|
148
|
+
/** The key to cache the data against */cacheKey: string; /** Time in ms that cached data will remain valid. Default: 30_000 (30s). Set to 0 to disable caching. */
|
|
149
|
+
cacheTime?: number;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Returns the result of a given promise, and caches the result for
|
|
153
|
+
* subsequent invocations against a provided cache key.
|
|
154
|
+
*
|
|
155
|
+
* Also deduplicates concurrent calls — if multiple callers request the same
|
|
156
|
+
* cache key while the promise is pending, they share the same promise.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```ts
|
|
160
|
+
* // First call fetches, subsequent calls return cached data for 30s
|
|
161
|
+
* const data = await withCache(
|
|
162
|
+
* () => client.request({ method: "frak_getMerchantInformation" }),
|
|
163
|
+
* { cacheKey: "merchantInfo", cacheTime: 30_000 }
|
|
164
|
+
* );
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
declare function withCache<TData>(fn: () => Promise<TData>, {
|
|
168
|
+
cacheKey,
|
|
169
|
+
cacheTime
|
|
170
|
+
}: WithCacheOptions): Promise<TData>;
|
|
171
|
+
/**
|
|
172
|
+
* Get a cache handle for a specific key, useful for manual invalidation.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```ts
|
|
176
|
+
* // Invalidate merchant info cache after a mutation
|
|
177
|
+
* getCache("frak_getMerchantInformation").clear();
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
declare function getCache(cacheKey: string): {
|
|
181
|
+
/** Clear both the pending promise and the cached response */clear: () => void; /** Check if a non-expired response exists */
|
|
182
|
+
has: (cacheTime?: number) => boolean;
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* Clear all cached data (both pending promises and resolved responses).
|
|
186
|
+
* Called automatically when the client is destroyed.
|
|
187
|
+
*/
|
|
188
|
+
declare function clearAllCache(): void;
|
|
189
|
+
//#endregion
|
|
146
190
|
//#region src/utils/clientId.d.ts
|
|
147
191
|
/**
|
|
148
192
|
* Client ID utilities for anonymous tracking
|
|
@@ -415,47 +459,57 @@ declare function createIframe({
|
|
|
415
459
|
*/
|
|
416
460
|
declare function findIframeInOpener(pathname?: string): Window | null;
|
|
417
461
|
//#endregion
|
|
418
|
-
//#region src/utils/
|
|
419
|
-
/**
|
|
420
|
-
* Merchant ID utilities for auto-fetching from backend
|
|
421
|
-
*/
|
|
462
|
+
//#region src/utils/inAppBrowser.d.ts
|
|
422
463
|
/**
|
|
423
|
-
*
|
|
424
|
-
*
|
|
425
|
-
* @param domain - The domain to lookup (defaults to current hostname)
|
|
426
|
-
* @param walletUrl - Optional wallet URL to derive backend URL
|
|
427
|
-
* @returns The merchantId if found, undefined otherwise
|
|
428
|
-
*
|
|
429
|
-
* @example
|
|
430
|
-
* ```ts
|
|
431
|
-
* const merchantId = await fetchMerchantId("shop.example.com");
|
|
432
|
-
* if (merchantId) {
|
|
433
|
-
* // Use merchantId for tracking
|
|
434
|
-
* }
|
|
435
|
-
* ```
|
|
464
|
+
* Whether the current device runs iOS (including iPadOS 13+).
|
|
436
465
|
*/
|
|
437
|
-
declare
|
|
466
|
+
declare const isIOS: boolean;
|
|
438
467
|
/**
|
|
439
|
-
*
|
|
440
|
-
*
|
|
468
|
+
* Whether the current browser is a social media in-app browser
|
|
469
|
+
* (Instagram, Facebook).
|
|
441
470
|
*/
|
|
442
|
-
declare
|
|
471
|
+
declare const isInAppBrowser: boolean;
|
|
443
472
|
/**
|
|
444
|
-
*
|
|
473
|
+
* Redirect to external browser from in-app WebView.
|
|
474
|
+
*
|
|
475
|
+
* - **iOS**: Uses `x-safari-https://` scheme — server-side 302 redirects
|
|
476
|
+
* to custom URL schemes are silently swallowed by WKWebView.
|
|
477
|
+
* Direct `window.location.href` assignment works (confirmed iOS 17+).
|
|
445
478
|
*
|
|
446
|
-
*
|
|
447
|
-
*
|
|
448
|
-
*
|
|
479
|
+
* - **Android**: Uses backend `/common/social` endpoint which returns a PDF
|
|
480
|
+
* Content-Type response, forcing the WebView to hand off to the default browser.
|
|
481
|
+
*
|
|
482
|
+
* @param targetUrl - The URL to open in the external browser
|
|
449
483
|
*/
|
|
450
|
-
declare function
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
484
|
+
declare function redirectToExternalBrowser(targetUrl: string): void;
|
|
485
|
+
//#endregion
|
|
486
|
+
//#region src/utils/sdkConfigStore.d.ts
|
|
487
|
+
declare const GLOBAL_KEY = "__frakSdkConfig";
|
|
488
|
+
declare global {
|
|
489
|
+
interface Window {
|
|
490
|
+
[GLOBAL_KEY]?: SdkResolvedConfig;
|
|
491
|
+
}
|
|
492
|
+
interface WindowEventMap {
|
|
493
|
+
"frak:config": CustomEvent<SdkResolvedConfig>;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
declare function getConfig(): SdkResolvedConfig;
|
|
497
|
+
declare const sdkConfigStore: {
|
|
498
|
+
getConfig: typeof getConfig;
|
|
499
|
+
readonly isResolved: boolean;
|
|
500
|
+
readonly isCacheFresh: boolean;
|
|
501
|
+
setCacheScope(domain: string, lang?: string): void;
|
|
502
|
+
setConfig(config: SdkResolvedConfig): void;
|
|
503
|
+
reset(): void;
|
|
504
|
+
clearCache(): void;
|
|
505
|
+
resolve(domain?: string, walletUrl?: string, lang?: Language): Promise<MerchantConfigResponse | undefined>;
|
|
506
|
+
getMerchantId(): string | undefined;
|
|
507
|
+
resolveMerchantId(domain?: string, walletUrl?: string): Promise<string | undefined>;
|
|
508
|
+
};
|
|
455
509
|
//#endregion
|
|
456
510
|
//#region src/utils/sso.d.ts
|
|
457
511
|
type AppSpecificSsoMetadata = SsoMetadata & {
|
|
458
|
-
name
|
|
512
|
+
name?: string;
|
|
459
513
|
css?: string;
|
|
460
514
|
};
|
|
461
515
|
/**
|
|
@@ -489,7 +543,7 @@ type FullSsoParams = Omit<PrepareSsoParamsType, "metadata"> & {
|
|
|
489
543
|
* // Returns: https://wallet.frak.id/sso?p=<compressed_base64>
|
|
490
544
|
* ```
|
|
491
545
|
*/
|
|
492
|
-
declare function generateSsoUrl(walletUrl: string, params: PrepareSsoParamsType, merchantId: string, name: string, clientId: string, css?: string): string;
|
|
546
|
+
declare function generateSsoUrl(walletUrl: string, params: PrepareSsoParamsType, merchantId: string, name: string | undefined, clientId: string, css?: string): string;
|
|
493
547
|
/**
|
|
494
548
|
* Type of compressed the sso data
|
|
495
549
|
*/
|
|
@@ -501,7 +555,7 @@ type CompressedSsoData = {
|
|
|
501
555
|
l?: "en" | "fr";
|
|
502
556
|
m: string;
|
|
503
557
|
md: {
|
|
504
|
-
n
|
|
558
|
+
n?: string;
|
|
505
559
|
css?: string;
|
|
506
560
|
l?: string;
|
|
507
561
|
h?: string;
|
|
@@ -534,4 +588,4 @@ declare function computeLegacyProductId({
|
|
|
534
588
|
domain?: string;
|
|
535
589
|
}): `0x${string}`;
|
|
536
590
|
//#endregion
|
|
537
|
-
export {
|
|
591
|
+
export { getClientId as A, TrackArrivalParams as B, toAndroidIntentUrl as C, compressJsonToB64 as D, decompressJsonFromB64 as E, LocalesKey as F, KeyProvider as G, UtmParams as H, locales as I, setupClient as L, getCache as M, withCache as N, base64urlDecode as O, getBackendUrl as P, DebugInfoGatherer as R, isFrakDeepLink as S, DEEP_LINK_SCHEME as T, CompressedData as U, TrackArrivalResult as V, HashProtectedData as W, getCurrencyAmountKey as _, CompressedSsoData as a, DeepLinkFallbackOptions as b, sdkConfigStore as c, redirectToExternalBrowser as d, baseIframeProps as f, getSupportedCurrency as g, getSupportedLocale as h, AppSpecificSsoMetadata as i, clearAllCache as j, base64urlEncode as k, isIOS as l, findIframeInOpener as m, FrakEvent as n, FullSsoParams as o, createIframe as p, trackEvent as r, generateSsoUrl as s, computeLegacyProductId as t, isInAppBrowser as u, formatAmount as v, triggerDeepLinkWithFallback as w, isChromiumAndroid as x, FrakContextManager as y, createIFrameFrakClient as z };
|