@coinflowlabs/angular 2.0.1-0 → 3.1.0

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 CHANGED
@@ -4,6 +4,11 @@ This library was generated with [Angular CLI](https://github.com/angular/angular
4
4
 
5
5
  # Changelog
6
6
 
7
+ ## 3.0.0
8
+
9
+ - **Breaking:** Remove Stellar support: `blockchain: 'stellar'` and the `StellarWallet`, `CoinflowStellarPurchaseProps` and `CoinflowStellarHistoryProps` types. Coinflow no longer processes Stellar payments.
10
+ - Deprecate the `type: 'returned'` EVM redeem. The API now rejects it; use `SafeMintRedeem`, `KnownTokenIdRedeem` or `NormalRedeem`.
11
+
7
12
  ## 2.0.0
8
13
 
9
14
  - **Breaking:** Removed the deprecated legacy card form components: `CoinflowCardNumberInput` (`lib-coinflow-card-number-input`), `CoinflowCardNumberOnlyInput` (`lib-coinflow-card-number-only-input`), `CoinflowCvvInputComponent` (`lib-coinflow-cvv-input`) and `CoinflowCvvOnlyInputComponent` (`lib-coinflow-cvv-only-input`). Use `CoinflowCardFormV2` instead.
@@ -115,6 +115,11 @@ var CardType;
115
115
  CardType["DISCOVER"] = "DISC";
116
116
  })(CardType || (CardType = {}));
117
117
  const RN_REDIRECT_MESSAGE_NAME = 'rnredirect'; // DO NOT CHANGE
118
+ var RedirectFlow;
119
+ (function (RedirectFlow) {
120
+ RedirectFlow["Venmo"] = "venmo";
121
+ RedirectFlow["Plaid"] = "plaid";
122
+ })(RedirectFlow || (RedirectFlow = {}));
118
123
 
119
124
  // This works in angular, but not react
120
125
  // let web3: typeof import('@solana/web3.js') | undefined;
@@ -485,6 +490,7 @@ const ZeroDecimalCurrencies = new Set([
485
490
  Currency.ISK,
486
491
  Currency.JPY,
487
492
  Currency.KMF,
493
+ Currency.KRW,
488
494
  Currency.PYG,
489
495
  Currency.RWF,
490
496
  Currency.UGX,
@@ -589,7 +595,7 @@ class CoinflowUtils {
589
595
  return 'http://localhost:5000';
590
596
  return `https://api-${env}.coinflow.cash`;
591
597
  }
592
- static getCoinflowUrl({ walletPubkey, sessionKey, route, routePrefix, env, subtotal, useNativeSubtotal, presentment, transaction, blockchain = 'solana', webhookInfo, email, loaderBackground, handleHeightChangeId, bankAccountLinkRedirect, additionalWallets, chargebackProtectionData, chargebackProtectionAccountType, merchantCss, color, rent, lockDefaultToken, tokens, planCode, disableApplePay, disableGooglePay, customerInfo, settlementType, amount, lockAmount, nativeSolToConvert, theme, usePermit, transactionSigner, authOnly, deviceId, jwtToken, origins, threeDsChallengePreference, supportEmail, destinationAuthKey, allowedPaymentMethods, allowedCardFunding, accountFundingTransaction, partialUsdcChecked, allowedWithdrawSpeeds, isZeroAuthorization, zeroAuthorizationConfig, userLocation, appReturnUrl, depositAmounts, ownerOverride, bridgeId, bankLinkOnly, baseUrl, }) {
598
+ static getCoinflowUrl({ walletPubkey, sessionKey, route, routePrefix, env, subtotal, useNativeSubtotal, presentment, inlineCryptoCheckout, transaction, blockchain = 'solana', webhookInfo, email, loaderBackground, handleHeightChangeId, bankAccountLinkRedirect, additionalWallets, chargebackProtectionData, chargebackProtectionAccountType, merchantCss, color, rent, lockDefaultToken, tokens, planCode, disableApplePay, disableGooglePay, customerInfo, settlementType, amount, lockAmount, nativeSolToConvert, theme, usePermit, transactionSigner, authOnly, deviceId, jwtToken, origins, threeDsChallengePreference, supportEmail, destinationAuthKey, allowedPaymentMethods, allowedCardFunding, accountFundingTransaction, partialUsdcChecked, allowedWithdrawSpeeds, isZeroAuthorization, zeroAuthorizationConfig, userLocation, appReturnUrl, depositAmounts, ownerOverride, bridgeId, bankLinkOnly, baseUrl, }) {
593
599
  const prefix = routePrefix
594
600
  ? `/${routePrefix}/${blockchain}`
595
601
  : `/${blockchain}`;
@@ -624,6 +630,8 @@ class CoinflowUtils {
624
630
  url.searchParams.append('bridgeId', bridgeId);
625
631
  if (presentment)
626
632
  url.searchParams.append('presentment', presentment);
633
+ if (inlineCryptoCheckout !== undefined)
634
+ url.searchParams.append('inlineCryptoCheckout', String(inlineCryptoCheckout));
627
635
  if (webhookInfo) {
628
636
  url.searchParams.append('webhookInfo', LZString.compressToEncodedURIComponent(JSON.stringify(webhookInfo)));
629
637
  }
@@ -759,6 +767,11 @@ class CoinflowUtils {
759
767
  }
760
768
  return url.toString();
761
769
  }
770
+ static getPurchaseRoute({ merchantId, checkoutVersion, }) {
771
+ if (checkoutVersion === 'v3')
772
+ return { route: `/purchase/${merchantId}`, routePrefix: 'v3' };
773
+ return { route: `/purchase-v2/${merchantId}` };
774
+ }
762
775
  static getTransaction(props) {
763
776
  if (!props.blockchain)
764
777
  return undefined;
@@ -892,6 +905,15 @@ var IFrameMessageMethods;
892
905
  IFrameMessageMethods["Overlay"] = "overlay";
893
906
  IFrameMessageMethods["UpdateSubtotal"] = "updateSubtotal";
894
907
  })(IFrameMessageMethods || (IFrameMessageMethods = {}));
908
+ var HostMessageMethods;
909
+ (function (HostMessageMethods) {
910
+ HostMessageMethods["OverlayOffset"] = "overlayOffset";
911
+ })(HostMessageMethods || (HostMessageMethods = {}));
912
+ var OverlayState;
913
+ (function (OverlayState) {
914
+ OverlayState["Open"] = "open";
915
+ OverlayState["Close"] = "close";
916
+ })(OverlayState || (OverlayState = {}));
895
917
  function getWalletPubkey(input) {
896
918
  let wallet;
897
919
  if ('signer' in input &&
@@ -1646,7 +1668,7 @@ function getProtectionSessionId() {
1646
1668
  }
1647
1669
 
1648
1670
  const FORTER_COOKIE_NAME = 'forterToken';
1649
- // Defense-in-depth: the attacker-influenceable cookie is later sent as the `x-forter-token` header / Forter `forterTokenCookie`; since tokens are opaque, long, uncontrolled-alphabet strings, don't use a narrow allowlist — just bound the length and reject control / CR / LF chars that could enable header injection.
1671
+ // Defense-in-depth: the attacker-influenceable cookie is later sent as the `purchaseToken` in the `x-device-id` header / Forter `forterTokenCookie`; since tokens are opaque, long, uncontrolled-alphabet strings, don't use a narrow allowlist — just bound the length and reject control / CR / LF chars that could enable header injection.
1650
1672
  const MAX_FORTER_TOKEN_LENGTH = 1024;
1651
1673
  // eslint-disable-next-line no-control-regex
1652
1674
  const FORTER_TOKEN_UNSAFE_PATTERN = /[\x00-\x1F\x7F]/;
@@ -1748,7 +1770,7 @@ function logForterTokenMissing() {
1748
1770
  : [];
1749
1771
  console.warn('[forter] token never surfaced after init.', 'cookieNames:', cookieNames, 'forterGlobals:', forterGlobals);
1750
1772
  }
1751
- // Resolve once a Forter token is available, or after `timeoutMs` if it never surfaces: Forter issues its device token asynchronously (~1s after the SDK loads, via `ftr:tokenReady` / forterToken cookie), so a fast charge — notably saved-card / "1-click" purchases — can read getForterToken() before it exists and send an empty x-forter-token, so await this at charge time to populate the header; fail-open by resolving to whatever getForterToken() returns at the deadline (possibly null) rather than blocking the purchase, and return immediately when a token is already cached so it adds no latency in the common case.
1773
+ // Resolve once a Forter token is available, or after `timeoutMs` if it never surfaces: Forter issues its device token asynchronously (~1s after the SDK loads, via `ftr:tokenReady` / forterToken cookie), so a fast charge — notably saved-card / "1-click" purchases — can read getForterToken() before it exists and send no purchaseToken in x-device-id, so await this at charge time to populate the header; fail-open by resolving to whatever getForterToken() returns at the deadline (possibly null) rather than blocking the purchase, and return immediately when a token is already cached so it adds no latency in the common case.
1752
1774
  async function awaitForterToken({ timeoutMs = 2_000, intervalMs = 100, } = {}) {
1753
1775
  const existing = getForterToken();
1754
1776
  if (existing)
@@ -1769,32 +1791,6 @@ async function awaitForterToken({ timeoutMs = 2_000, intervalMs = 100, } = {}) {
1769
1791
  });
1770
1792
  }
1771
1793
 
1772
- const DEVICE_ID_HEADER = 'x-device-id';
1773
- const SESSION_ID_HEADER = 'x-session-id';
1774
- const REFERRER_HEADER = 'x-coinflow-referrer';
1775
- const FORTER_TOKEN_HEADER = 'x-forter-token';
1776
- function getCoinflowProtectionHeaders() {
1777
- return {
1778
- [DEVICE_ID_HEADER]: getNSureDeviceId(),
1779
- [SESSION_ID_HEADER]: getProtectionSessionId(),
1780
- [FORTER_TOKEN_HEADER]: getForterToken(),
1781
- };
1782
- }
1783
- function getReferrer() {
1784
- try {
1785
- return document.referrer || null;
1786
- }
1787
- catch {
1788
- return null;
1789
- }
1790
- }
1791
- function getCoinflowPurchaseHeaders() {
1792
- return {
1793
- ...getCoinflowProtectionHeaders(),
1794
- [REFERRER_HEADER]: getReferrer(),
1795
- };
1796
- }
1797
-
1798
1794
  // Wire format of the fraud SDKs' `x-device-id` header: base64url(JSON {v, deviceId, sessionId,
1799
1795
  // purchaseToken}), unpadded. The iOS / Android / React Native / Flutter SDKs encode it
1800
1796
  // independently and must match the golden vector in this package's tests.
@@ -1828,6 +1824,82 @@ class CoinflowFraudProtectionHeader {
1828
1824
  }
1829
1825
  }
1830
1826
 
1827
+ const DEVICE_ID_HEADER = 'x-device-id';
1828
+ const REFERRER_HEADER = 'x-coinflow-referrer';
1829
+ // Per-provider headers. The web SDKs pack every token into `x-device-id`; React Native and older
1830
+ // integrations still send these, and the API reads them as a fallback.
1831
+ const SESSION_ID_HEADER = 'x-session-id';
1832
+ const FORTER_TOKEN_HEADER = 'x-forter-token';
1833
+ class CoinflowPurchaseHeaders {
1834
+ static withReferrer(protectionHeaders) {
1835
+ return {
1836
+ ...protectionHeaders,
1837
+ [REFERRER_HEADER]: this.getReferrer(),
1838
+ };
1839
+ }
1840
+ static getReferrer() {
1841
+ try {
1842
+ return document.referrer || null;
1843
+ }
1844
+ catch {
1845
+ return null;
1846
+ }
1847
+ }
1848
+ }
1849
+
1850
+ function getCoinflowProtectionHeaders() {
1851
+ return {
1852
+ [DEVICE_ID_HEADER]: CoinflowFraudProtectionHeader.encode({
1853
+ deviceId: getNSureDeviceId(),
1854
+ sessionId: getProtectionSessionId(),
1855
+ purchaseToken: getForterToken(),
1856
+ }),
1857
+ };
1858
+ }
1859
+ function getCoinflowPurchaseHeaders() {
1860
+ return CoinflowPurchaseHeaders.withReferrer(getCoinflowProtectionHeaders());
1861
+ }
1862
+
1863
+ // Vendor Forter device-fingerprinting snippet, generated by the Forter dashboard and kept
1864
+ // verbatim; only the site id is parameterized.
1865
+ const FORTER_SCRIPT_ID = 'ftr__snippet';
1866
+ // The minified snippet body (everything after its own `var siteId = ...` declaration), left exactly as Forter ships it.
1867
+ const FORTER_SNIPPET_BODY = 'function t(t,e){for(var n=t.split(""),r=0;r<n.length;++r)n[r]=String.fromCharCode(n[r].charCodeAt(0)+e);return n.join("")}function e(e){return t(e,-_).replace(/%SN%/g,siteId)}function n(t){try{if("number"==typeof t&&window.location&&window.location.pathname){for(var e=window.location.pathname.split("/"),n=[],r=0;r<=Math.min(e.length-1,Math.abs(t));r++)n.push(e[r]);return n.join("/")||"/"}}catch(t){}return"/"}function r(){var t="no"+"op"+"fn",e="g"+"a",n="n"+"ame";return window[e]&&window[e][n]===t}function o(){return!(!navigator.brave||"function"!=typeof navigator.brave.isBrave)}function i(){return document.currentScript&&document.currentScript.src}function a(t){try{$.ex=t,r()&&-1===$.ex.indexOf(z.uB)&&($.ex+=z.uB),o()&&-1===$.ex.indexOf(z.uBr)&&($.ex+=z.uBr),i()&&-1===$.ex.indexOf(z.nIL)&&($.ex+=z.nIL),window.ftr__snp_cwc||($.ex+=z.s),H($)}catch(t){}}function c(t,e){function n(i){try{i.blockedURI===t&&i.disposition===o&&(e(),document.removeEventListener(r,n))}catch(t){document.removeEventListener(r,n)}}var r="securitypolicyviolation",o="enforce";document.addEventListener(r,n),setTimeout(function(){document.removeEventListener(r,n)},2*60*1e3)}function f(t,e,n,r){var o=!1;t="https://"+t,c(t,function(){r(!0),o=!0});var i=document.createElement("script");if(i.onerror=function(){if(!o)try{r(!1),o=!0}catch(t){}},i.onload=n,i.type="text/javascript",i.id="ftr__script",i.async=!0,i.src=t,window.ftr__config&&window.ftr__config.m&&!0===window.ftr__config.m.ptb&&document.body)document.body.appendChild(i);else{var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(i,a)}}function u(){setTimeout(l,B,z.uDF)}function s(t,e,n,r){var o=!1,i=new XMLHttpRequest;if(c("https:"+t,function(){n(new Error("CSP Violation"),!0),o=!0}),"//"===t.slice(0,2)&&(t="https:"+t),"withCredentials"in i)i.open("GET",t,!0);else{if("undefined"==typeof XDomainRequest)return;i=new XDomainRequest,i.open("GET",t)}Object.keys(r).forEach(function(t){i.setRequestHeader(t,r[t])}),i.onload=function(){"function"==typeof e&&e(i)},i.onerror=function(t){if("function"==typeof n&&!o)try{n(t,!1),o=!0}catch(t){}},i.onprogress=function(){},i.ontimeout=function(){"function"==typeof n&&n("tim"+"eo"+"ut",!1)},setTimeout(function(){i.send()},0)}function d(t,siteId,e){function n(t){var e=t.toString(16);return e.length%2?"0"+e:e}function r(t){if(t<=0)return"";for(var e="0123456789abcdef",n="",r=0;r<t;r++)n+=e[Math.floor(Math.random()*e.length)];return n}function o(t){for(var e="",r=0;r<t.length;r++)e+=n(t.charCodeAt(r));return e}function i(t){for(var e=t.split(""),n=0;n<e.length;++n)e[n]=String.fromCharCode(255^e[n].charCodeAt(0));return e.join("")}e=e?"1":"0";var a=[];return a.push(t),a.push(siteId),a.push(e),function(t){var e=40,n="";return t.length<e/2&&(n=","+r(e/2-t.length-1)),o(i(t+n))}(a.join(","))}function h(){function t(){M&&setTimeout(l,B,z.dUAL)}function e(t,e){M=e?"F"+"T"+"R"+"A"+"U"+"C":"F"+"T"+"R"+"A"+"U",setTimeout(l,B,z.uAS)}window.ftr__fdad(t,e)}function w(){function t(){M&&setTimeout(l,B,z.uDAD)}function e(t,e){M=e?"F"+"T"+"R"+"A"+"U"+"C":"F"+"T"+"R"+"A"+"U",setTimeout(l,B,z.uDS)}window.ftr__radd(t,e)}function l(t){function e(){for(var t=0;t<=z.tmosSecs.length;t++)clearTimeout(et[t])}function n(){try{e(),a(t+z.uS)}catch(t){}}function r(n){try{e(),$.td=1*new Date-$.ts,a(n?t+z.uF+z.cP:t+z.uF),t===z.uFP&&u(),t===z.uDF&&(j?w():h()),t!==z.uAS&&t!==z.dUAL||j||w(),t!==z.uDS&&t!==z.uDAD||j&&h()}catch(t){a(z.eUoe)}}try{!function(t){for(var e=0;e<=z.tmosSecs.length;e++)e===z.tmosSecs.length?et[e]=setTimeout(r,1e3*z.tmosSecs[e-1]+1e3):et[e]=setTimeout(a,1e3*z.tmosSecs[e],t+z.tmos[e])}(t);var o;switch(t){case z.uFP:o=N;break;case z.uDF:o=I;break;default:o=M}if(!o)return;if(o==="F"+"T"+"R"+"A"+"U"+"C")return void r(!0);if(o==="F"+"T"+"R"+"A"+"U")return void r(!1);f(o,void 0,n,r)}catch(e){a(t+z.eTlu)}}var g="22g5iz6v:uihsv}w1forxgiurqw1qhw2vwdwxv",v="fort",p="erTo",m="ken",_=3;window.ftr__config={m:merchantConfig,s:"31",si:siteId};var y=!1,U=!1,T,x,A=v+p+m,S=400*24*60,D,C=10;D={write:function(t,e,r,o){void 0===o&&(o=!0);var i=0;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.ckDepth&&(i=window.ftr__config.m.ckDepth);var a,c,f=n(i);if(r?(a=new Date,a.setTime(a.getTime()+60*r*1e3),c="; expires="+a.toGMTString()):c="",!o)return void(document.cookie=escape(t)+"="+escape(e)+c+"; path="+f);for(var u=1,s=document.domain.split("."),d=C,h=!0;h&&s.length>=u&&d>0;){var w=s.slice(-u).join(".");document.cookie=escape(t)+"="+escape(e)+c+"; path="+f+"; domain="+w;var l=D.read(t);null!=l&&l==e||(w="."+w,document.cookie=escape(t)+"="+escape(e)+c+"; path="+f+"; domain="+w),h=-1===document.cookie.indexOf(t+"="+e),u++,d--}},read:function(t){var e=null;try{for(var n=escape(t)+"=",r=document.cookie.split(";"),o=32,i=0;i<r.length;i++){for(var a=r[i];a.charCodeAt(0)===o;)a=a.substring(1,a.length);0===a.indexOf(n)&&(e=unescape(a.substring(n.length,a.length)))}}finally{return e}}};var R=window.ftr__config.s;R+="ck";var L=function(t){var e=!1,n=null,r=function(){try{if(!n||!e)return;n.remove&&"function"==typeof n.remove?n.remove():document.head.removeChild(n),e=!1}catch(t){}};document.head&&(!function(){n=document.createElement("link"),n.setAttribute("rel","pre"+"con"+"nect"),n.setAttribute("cros"+"sori"+"gin","anonymous"),n.onload=r,n.onerror=r,n.setAttribute("href",t),document.head.appendChild(n),e=!0}(),setTimeout(r,3e3))},E=e(g||"22g5iz6v:uihsv}w1forxgiurqw1qhw2vwdwxv"),q=t("[0Uhtxhvw0LG",-_),b=t("[0Fruuhodwlrq0LG",-_),P=t("Li0Qrqh0Pdwfk",-_),k=e("dss1vlwhshuirupdqfhwhvw1qhw"),F=e("2241414142gqv0txhu|"),M,O="fgq71iruwhu1frp",I,V;I=e("(VQ(1"+O+"2vq2(VQ(2vfulsw1mv"),V=e("(VQ(1"+O+"2vqV2(VQ(2vfulsw1mv");var N;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.fpi&&(N=e("fgq71")+window.ftr__config.m.fpi+e("2vq2(VQ(2vfulsw1mv"));var j=!1;j=!1;var B=10;window.ftr__startScriptLoad=1*new Date;var G=function(t){var e="ft"+"r:tok"+"enR"+"eady";window.ftr__tt&&clearTimeout(window.ftr__tt),window.ftr__tt=setTimeout(function(){try{delete window.ftr__tt,t+="_tt";var n=document.createEvent("Event");n.initEvent(e,!1,!1),n.detail=t,document.dispatchEvent(n)}catch(t){}},1e3)},H=function(t){var e=function(t){return t||""},n=e(t.id)+"_"+e(t.ts)+"_"+e(t.td)+"_"+e(t.ex)+"_"+e(R),r=S;!isNaN(window.ftr__config.m.ckTTL)&&window.ftr__config.m.ckTTL&&(r=window.ftr__config.m.ckTTL),D.write(A,n,r,!0),G(n),window.ftr__gt=n},X=function(){var t=D.read(A)||"",e=t.split("_"),n=function(t){return e[t]||void 0};return{id:n(0),ts:n(1),td:n(2),ex:n(3),vr:n(4)}},Q=function(){for(var t={},e="fgu",n=[],r=0;r<256;r++)n[r]=(r<16?"0":"")+r.toString(16);var o=function(t,e,r,o,i){var a=i?"-":"";return n[255&t]+n[t>>8&255]+n[t>>16&255]+n[t>>24&255]+a+n[255&e]+n[e>>8&255]+a+n[e>>16&15|64]+n[e>>24&255]+a+n[63&r|128]+n[r>>8&255]+a+n[r>>16&255]+n[r>>24&255]+n[255&o]+n[o>>8&255]+n[o>>16&255]+n[o>>24&255]},i=function(){if(window.Uint32Array&&window.crypto&&window.crypto.getRandomValues){var t=new window.Uint32Array(4);return window.crypto.getRandomValues(t),{d0:t[0],d1:t[1],d2:t[2],d3:t[3]}}return{d0:4294967296*Math.random()>>>0,d1:4294967296*Math.random()>>>0,d2:4294967296*Math.random()>>>0,d3:4294967296*Math.random()>>>0}},a=function(){var t="",e=function(t,e){for(var n="",r=t;r>0;--r)n+=e.charAt(1e3*Math.random()%e.length);return n};return t+=e(2,"0123456789"),t+=e(1,"123456789"),t+=e(8,"0123456789")};return t.safeGenerateNoDash=function(){try{var t=i();return o(t.d0,t.d1,t.d2,t.d3,!1)}catch(t){try{return e+a()}catch(t){}}},t.isValidNumericalToken=function(t){return t&&t.toString().length<=11&&t.length>=9&&parseInt(t,10).toString().length<=11&&parseInt(t,10).toString().length>=9},t.isValidUUIDToken=function(t){return t&&32===t.toString().length&&/^[a-z0-9]+$/.test(t)},t.isValidFGUToken=function(t){return 0==t.indexOf(e)&&t.length>=12},t}(),z={uDF:"UDF",dUAL:"dUAL",uAS:"UAS",uDS:"UDS",uDAD:"UDAD",uFP:"UFP",mLd:"1",eTlu:"2",eUoe:"3",uS:"4",uF:"9",tmos:["T5","T10","T15"],tmosSecs:[5,10,15],bIR:"43",uB:"u",uBr:"b",cP:"c",nIL:"i",s:"s"};try{var $=X();try{$.id&&(Q.isValidNumericalToken($.id)||Q.isValidUUIDToken($.id)||Q.isValidFGUToken($.id))?window.ftr__ncd=!1:($.id=Q.safeGenerateNoDash(),window.ftr__ncd=!0),$.ts=window.ftr__startScriptLoad,H($),window.ftr__snp_cwc=!!D.read(A),window.ftr__snp_cwc||(I=V);for(var J="for"+"ter"+".co"+"m",K="ht"+"tps://c"+"dn9."+J,W="ht"+"tps://"+$.id+"-"+siteId+".cd"+"n."+J,Y="http"+"s://cd"+"n3."+J,Z=[K,W,Y],tt=0;tt<Z.length;tt++)L(Z[tt]);var et=new Array(z.tmosSecs.length);window.ftr__fdad=function(e,n){if(y)return window.ftr__altd2=x,void e();y=!0;var r={};r[P]=d(window.ftr__config.s,siteId,window.ftr__config.m.csp),s(E,function(n){try{var r=n.getAllResponseHeaders().toLowerCase();if(r.indexOf(b.toLowerCase())>=0){var o=n.getResponseHeader(b);x=window.ftr__altd2=t(atob(o),-_-1)}if(r.indexOf(q.toLowerCase())<0)return;var i=n.getResponseHeader(q),a=t(atob(i),-_-1);if(a){var c=a.split(":");if(c&&2===c.length){for(var f=c[0],u=c[1],s="",d=0,h=0;d<20;++d)s+=d%3>0&&h<12?siteId.charAt(h++):$.id.charAt(d);var w=u.split(",");if(w.length>1){var l=w[0],g=w[1];M=f+"/"+l+"."+s+"."+g}}}e()}catch(t){}},function(t,e){n&&n(t,e)},r)},window.ftr__radd=function(t,e){function n(e){try{var n=e.response,r=function(t){function e(t,n,i){try{if(i>=r)return{name:"",nextOffsetToProcess:n,error:"Max pointer dereference depth exceeded"};for(var a=[],c=n,f=t.getUint8(c),u=0;u<o;){if(u++,192==(192&f)){var s=(63&f)<<8|t.getUint8(c+1),d=e(t,s,i+1);if(d.error)return d;var h=d.name;return a.push(h),{name:a.join("."),nextOffsetToProcess:c+2}}if(!(f>0)){if(0!==f)return{name:"",nextOffsetToProcess:c,error:"Unexpected length at the end of name: "+f.toString()};return{name:a.join("."),nextOffsetToProcess:c+1}}for(var w="",l=1;l<=f;l++)w+=String.fromCharCode(t.getUint8(c+l));a.push(w),c+=f+1,f=t.getUint8(c)}return{name:"",nextOffsetToProcess:c,error:"Max iterations exceeded"}}catch(t){return{name:"",nextOffsetToProcess:n,error:"Unexpected error while parsing response: "+t.toString()}}}var n,r=4,o=100,i=16,a=new DataView(t),c=a.getUint16(0),f=a.getUint16(2),u=a.getUint16(4),s=a.getUint16(6),d=a.getUint16(8),h=a.getUint16(10),w=12,l=[],g=0;for(g=0;g<u;g++){if(n=e(a,w,0),n.error)throw new Error(n.error);if(w=n.nextOffsetToProcess,!Number.isInteger(w))throw new Error("invalid returned offset");var v=n.name,p=a.getUint16(w);w+=2;var m=a.getUint16(w);w+=2,l.push({qname:v,qtype:p,qclass:m})}var _=[];for(g=0;g<s;g++){if(n=e(a,w,0),n.error)throw new Error(n.error);if(w=n.nextOffsetToProcess,!Number.isInteger(w))throw new Error("invalid returned offset");var y=n.name,U=a.getUint16(w);if(U!==i)throw new Error("Unexpected record type: "+U.toString());w+=2;var T=a.getUint16(w);w+=2;var x=a.getUint32(w);w+=4;var A=a.getUint16(w);w+=2;for(var S="",D=w,C=0;D<w+A&&C<o;){C++;var R=a.getUint8(D);D+=1;S+=(new TextDecoder).decode(t.slice(D,D+R)),D+=R}if(C>=o)throw new Error("Max iterations exceeded while reading TXT data");w+=A,_.push({name:y,type:U,class:T,ttl:x,data:S})}return{transactionId:c,flags:f,questionCount:u,answerCount:s,authorityCount:d,additionalCount:h,questions:l,answers:_}}(n);if(!r)throw new Error("Error parsing DNS response");if(!("answers"in r))throw new Error("Unexpected response");var o=r.answers;if(0===o.length)throw new Error("No answers found");var i=o[0].data;i=i.replace(/^"(.*)"$/,"$1");var a=function(t){var e=40,n=32,r=126;try{for(var o=atob(t),i="",a=0;a<o.length;a++)i+=function(t){var o=t.charCodeAt(0),i=o-e;return i<n&&(i=r-(n-i)+1),String.fromCharCode(i)}(o[a]);return atob(i)}catch(t){return}}(i);if(!a)throw new Error("failed to decode the value");var c=function(t){var e="_"+"D"+"L"+"M"+"_",n=t.split(e);if(!(n.length<2)){var r=n[0],o=n[1];if(!(r.split(".").length-1<1))return{jURL:r,eURL:o}}}(a);if(!c)throw new Error("failed to parse the value");var f=c.jURL,u=c.eURL;M=function(t){for(var e="",n=0,r=0;n<20;++n)e+=n%3>0&&r<12?siteId.charAt(r++):$.id.charAt(n);return t.replace("/PRM1","").replace("/PRM2","/main.").replace("/PRM3",e).replace("/PRM4",".js")}(f),T=window.ftr__altd3=u,t()}catch(t){}}function r(t,n){e&&e(t,n)}if(U)return window.ftr__altd3=T,void t();window.ftr__config.m.dr==="N"+"D"+"R"&&e(new Error("N"+"D"+"R"),!1),F&&k||e(new Error("D"+"P"+"P"),!1),U=!0;try{var o=function(t){for(var e=new Uint8Array([0,0]),n=new Uint8Array([1,0]),r=new Uint8Array([0,1]),o=new Uint8Array([0,0]),i=new Uint8Array([0,0]),a=new Uint8Array([0,0]),c=t.split("."),f=[],u=0;u<c.length;u++){var s=c[u];f.push(s.length);for(var d=0;d<s.length;d++)f.push(s.charCodeAt(d))}f.push(0);var h=16,w=new Uint8Array([0,h]),l=new Uint8Array([0,1]),g=new Uint8Array(e.length+n.length+r.length+o.length+i.length+a.length+f.length+w.length+l.length);return g.set(e,0),g.set(n,e.length),g.set(r,e.length+n.length),g.set(o,e.length+n.length+r.length),g.set(i,e.length+n.length+r.length+o.length),g.set(a,e.length+n.length+r.length+o.length+i.length),g.set(f,e.length+n.length+r.length+o.length+i.length+a.length),g.set(w,e.length+n.length+r.length+o.length+i.length+a.length+f.length),g.set(l,e.length+n.length+r.length+o.length+i.length+a.length+f.length+w.length),g}(k);!function(t,e,n,r,o){var i=!1,a=new XMLHttpRequest;if(c("https:"+t,function(){o(new Error("CSP Violation"),!0),i=!0}),"//"===t.slice(0,2)&&(t="https:"+t),"withCredentials"in a)a.open("POST",t,!0);else{if("undefined"==typeof XDomainRequest)return;a=new XDomainRequest,a.open("POST",t)}a.responseType="arraybuffer",a.setRequestHeader("Content-Type",e),a.onload=function(){"function"==typeof r&&r(a)},a.onerror=function(t){if("function"==typeof o&&!i)try{o(t,!1),i=!0}catch(t){}},a.onprogress=function(){},a.ontimeout=function(){"function"==typeof o&&o("tim"+"eo"+"ut",!1)},setTimeout(function(){a.send(n)},0)}(F,"application/dns-message",o,n,r)}catch(t){e(t,!1)}};var nt=N?z.uFP:z.uDF;setTimeout(l,B,nt)}catch(t){a(z.mLd)}}catch(t){}})();';
1868
+ class ForterSnippet {
1869
+ // Public values: they ship in the snippet on every page that loads it.
1870
+ static { this.siteIds = {
1871
+ prod: 'eb77dd3f5be4',
1872
+ staging: '550084f08541',
1873
+ sandbox: '550084f08541',
1874
+ local: '550084f08541',
1875
+ }; }
1876
+ static siteIdFor(env) {
1877
+ return this.siteIds[env];
1878
+ }
1879
+ // Injects the snippet once; no-ops on the server, without a site id, or if Forter is already on the
1880
+ // page (ours, or the merchant's own integration, whose `ftr__config` and cookie ours would overwrite).
1881
+ static load(siteId) {
1882
+ if (typeof document === 'undefined')
1883
+ return;
1884
+ if (!siteId)
1885
+ return;
1886
+ if (document.getElementById(FORTER_SCRIPT_ID))
1887
+ return;
1888
+ if (window.ftr__config)
1889
+ return;
1890
+ const script = document.createElement('script');
1891
+ script.type = 'text/javascript';
1892
+ script.id = FORTER_SCRIPT_ID;
1893
+ script.text = [
1894
+ '(function () {',
1895
+ ' var merchantConfig = {csp: false};',
1896
+ ' var siteId = ' + JSON.stringify(siteId) + ';',
1897
+ FORTER_SNIPPET_BODY,
1898
+ ].join('\n');
1899
+ (document.head || document.documentElement).appendChild(script);
1900
+ }
1901
+ }
1902
+
1831
1903
  const NSURE_APP_ID = '9JBW2RHC7JNJN8ZQ';
1832
1904
  const PROTECTION_SESSION_PROJECT_IDS = {
1833
1905
  prod: '315da543-c486-435a-aa21-53844c469822',
@@ -1835,6 +1907,8 @@ const PROTECTION_SESSION_PROJECT_IDS = {
1835
1907
  };
1836
1908
  async function initCoinflowProtection({ coinflowEnv, merchantId, }) {
1837
1909
  const env = coinflowEnv === 'prod' ? 'prod' : 'sandbox';
1910
+ ForterSnippet.load(ForterSnippet.siteIdFor(coinflowEnv));
1911
+ captureForterToken();
1838
1912
  const hasUrlDeviceId = typeof window !== 'undefined' &&
1839
1913
  new URLSearchParams(window.location.search).has('deviceId');
1840
1914
  if (!hasUrlDeviceId) {
@@ -2079,7 +2153,7 @@ class CoinflowPurchaseComponent {
2079
2153
  this.iframeProps = {
2080
2154
  ...this.purchaseProps,
2081
2155
  walletPubkey,
2082
- route: `/purchase-v2/${this.purchaseProps?.merchantId}`,
2156
+ ...CoinflowUtils.getPurchaseRoute(this.purchaseProps),
2083
2157
  transaction: CoinflowUtils.getTransaction(this.purchaseProps),
2084
2158
  handleHeightChangeId,
2085
2159
  };
@@ -2114,8 +2188,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImpo
2114
2188
  }] });
2115
2189
 
2116
2190
  class CoinflowPurchaseProtectionComponent {
2191
+ // A merchantId bound asynchronously is often undefined on the first change.
2192
+ ngOnChanges() {
2193
+ if (!this.merchantId)
2194
+ return;
2195
+ initCoinflowProtection({
2196
+ coinflowEnv: this.coinflowEnv,
2197
+ merchantId: this.merchantId,
2198
+ }).catch(e => console.error('Failed to initialize Coinflow purchase protection:', e));
2199
+ }
2117
2200
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: CoinflowPurchaseProtectionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
2118
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.25", type: CoinflowPurchaseProtectionComponent, isStandalone: true, selector: "lib-coinflow-purchase-protection", ngImport: i0, template: ' <p>coinflow-purchase-protection works!</p> ', isInline: true }); }
2201
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.25", type: CoinflowPurchaseProtectionComponent, isStandalone: true, selector: "lib-coinflow-purchase-protection", inputs: { coinflowEnv: "coinflowEnv", merchantId: "merchantId" }, usesOnChanges: true, ngImport: i0, template: '', isInline: true }); }
2119
2202
  }
2120
2203
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: CoinflowPurchaseProtectionComponent, decorators: [{
2121
2204
  type: Component,
@@ -2123,9 +2206,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImpo
2123
2206
  selector: 'lib-coinflow-purchase-protection',
2124
2207
  standalone: true,
2125
2208
  imports: [],
2126
- template: ' <p>coinflow-purchase-protection works!</p> ',
2209
+ template: '',
2127
2210
  }]
2128
- }] });
2211
+ }], propDecorators: { coinflowEnv: [{
2212
+ type: Input
2213
+ }], merchantId: [{
2214
+ type: Input
2215
+ }] } });
2129
2216
 
2130
2217
  class CoinflowWithdrawComponent {
2131
2218
  ngOnInit() {
@@ -2847,5 +2934,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImpo
2847
2934
  * Generated bundle index. Do not edit.
2848
2935
  */
2849
2936
 
2850
- export { BANK_LINK_REVEAL_DELAY_MS, BANK_LINK_STATUS_PARAM, BankingCurrencies, CARD_ENTRY_BORDER_PX, CARD_ENTRY_DIVIDER_PX, CARD_ENTRY_MARGIN_PX, CARD_ENTRY_MIN_WIDTHS, CARD_ENTRY_ROW_HEIGHT, CARD_ENTRY_ROW_HEIGHT_PX, CARD_ENTRY_SLOT_GAP_PX, CARD_FIELD_ERROR_MESSAGES, COMPACT_SKELETON_HEIGHT_PX, CardFunding, CardType, ChargebackProtectionAccountType, CoinflowApplePayButtonComponent, CoinflowCardForm, CoinflowCardFormV2, CoinflowFraudProtectionHeader, CoinflowGooglePayButtonComponent, CoinflowIFrameComponent, CoinflowPurchaseComponent, CoinflowPurchaseHistoryComponent, CoinflowPurchaseProtectionComponent, CoinflowUtils, CoinflowWithdrawComponent, CoinflowWithdrawHistoryComponent, Currency, CurrencyToISO4217, DEVICE_ID_HEADER, EventBus, FORTER_TOKEN_HEADER, IFrameMessageMethods, INLINE_SKELETON_HEIGHT_PX, MerchantStyle, PaymentMethods, REFERRER_HEADER, RN_REDIRECT_MESSAGE_NAME, SESSION_ID_HEADER, SKELETON_BOX_STYLE, SKELETON_FADE_MS, SKELETON_LAYOUTS, SKELETON_PULSE_ANIMATION_NAME, SKELETON_ROOT_PADDING_PX, SettlementType, ThreeDsChallengePreference, WithdrawCategory, WithdrawCurrencies, WithdrawSpeed, awaitForterToken, bankLinkCallbackParams, buildCardEntryGridCss, buildCardEntryLayout, buildSkeletonCss, canReuseLinkToken, captureForterToken, getCardFieldInputEvents, getCardFieldValidationError, getCoinflowProtectionHeaders, getCoinflowPurchaseHeaders, getCurrencyDecimals, getCustomerName, getForterToken, getHandlers, getSkeletonColors, getSkeletonGridClass, getSkeletonGridTemplate, getWalletPubkey, guessSkeletonHeightPx, handleIFrameMessage, initCoinflowProtection, invertRate, isBankingCurrency, isTypedCurrencyCents, isWithdrawCurrency, isZeroAuthSavedPaymentMethods, isZeroAuthVerifyCard, nftCartItem, parseCachedLinkToken, paymentMethodLabels, recordFrontendError, resolveBankLinkCompletion, serializeCachedLinkToken, shouldStackSkeleton };
2937
+ export { BANK_LINK_REVEAL_DELAY_MS, BANK_LINK_STATUS_PARAM, BankingCurrencies, CARD_ENTRY_BORDER_PX, CARD_ENTRY_DIVIDER_PX, CARD_ENTRY_MARGIN_PX, CARD_ENTRY_MIN_WIDTHS, CARD_ENTRY_ROW_HEIGHT, CARD_ENTRY_ROW_HEIGHT_PX, CARD_ENTRY_SLOT_GAP_PX, CARD_FIELD_ERROR_MESSAGES, COMPACT_SKELETON_HEIGHT_PX, CardFunding, CardType, ChargebackProtectionAccountType, CoinflowApplePayButtonComponent, CoinflowCardForm, CoinflowCardFormV2, CoinflowFraudProtectionHeader, CoinflowGooglePayButtonComponent, CoinflowIFrameComponent, CoinflowPurchaseComponent, CoinflowPurchaseHistoryComponent, CoinflowPurchaseProtectionComponent, CoinflowUtils, CoinflowWithdrawComponent, CoinflowWithdrawHistoryComponent, Currency, CurrencyToISO4217, DEVICE_ID_HEADER, EventBus, FORTER_TOKEN_HEADER, ForterSnippet, HostMessageMethods, IFrameMessageMethods, INLINE_SKELETON_HEIGHT_PX, MerchantStyle, OverlayState, PaymentMethods, REFERRER_HEADER, RN_REDIRECT_MESSAGE_NAME, RedirectFlow, SESSION_ID_HEADER, SKELETON_BOX_STYLE, SKELETON_FADE_MS, SKELETON_LAYOUTS, SKELETON_PULSE_ANIMATION_NAME, SKELETON_ROOT_PADDING_PX, SettlementType, ThreeDsChallengePreference, WithdrawCategory, WithdrawCurrencies, WithdrawSpeed, awaitForterToken, bankLinkCallbackParams, buildCardEntryGridCss, buildCardEntryLayout, buildSkeletonCss, canReuseLinkToken, captureForterToken, getCardFieldInputEvents, getCardFieldValidationError, getCoinflowProtectionHeaders, getCoinflowPurchaseHeaders, getCurrencyDecimals, getCustomerName, getForterToken, getHandlers, getSkeletonColors, getSkeletonGridClass, getSkeletonGridTemplate, getWalletPubkey, guessSkeletonHeightPx, handleIFrameMessage, initCoinflowProtection, invertRate, isBankingCurrency, isTypedCurrencyCents, isWithdrawCurrency, isZeroAuthSavedPaymentMethods, isZeroAuthVerifyCard, nftCartItem, parseCachedLinkToken, paymentMethodLabels, recordFrontendError, resolveBankLinkCompletion, serializeCachedLinkToken, shouldStackSkeleton };
2851
2938
  //# sourceMappingURL=coinflowlabs-angular.mjs.map