@coinflowlabs/angular 1.13.0 → 1.15.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.
@@ -26,6 +26,11 @@ var WithdrawSpeed;
26
26
  WithdrawSpeed["PAYPAL"] = "paypal";
27
27
  WithdrawSpeed["WIRE"] = "wire";
28
28
  WithdrawSpeed["INTERAC"] = "interac";
29
+ WithdrawSpeed["SWIFT"] = "swift";
30
+ // On-chain payout to an end user via a merchant DESTRUCTIVE API key. Not a
31
+ // fiat rail: never routed to payout providers and never offered from saved
32
+ // purse accounts.
33
+ WithdrawSpeed["CRYPTO"] = "crypto";
29
34
  })(WithdrawSpeed || (WithdrawSpeed = {}));
30
35
  var SettlementType;
31
36
  (function (SettlementType) {
@@ -551,6 +556,24 @@ class CoinflowUtils {
551
556
  return 'http://localhost:3003';
552
557
  return `https://app-${env}.coinflow.cash`;
553
558
  }
559
+ static isCoinflowMessageOrigin({ url, fallbackUrl, env, }) {
560
+ const resolved = url || fallbackUrl;
561
+ if (!resolved)
562
+ return false;
563
+ let hostname;
564
+ try {
565
+ hostname = new URL(resolved).hostname;
566
+ }
567
+ catch {
568
+ return false;
569
+ }
570
+ if (env === 'local')
571
+ return hostname === 'localhost';
572
+ // @ts-expect-error ngrok is a test-only env not in CoinflowEnvs
573
+ if (env === 'ngrok')
574
+ return hostname === 'coinflow.ngrok.app';
575
+ return hostname === 'coinflow.cash' || hostname.endsWith('.coinflow.cash');
576
+ }
554
577
  static getCoinflowApiUrl(env) {
555
578
  if (!env || env === 'prod')
556
579
  return 'https://api.coinflow.cash';
@@ -558,13 +581,15 @@ class CoinflowUtils {
558
581
  return 'http://localhost:5000';
559
582
  return `https://api-${env}.coinflow.cash`;
560
583
  }
561
- static getCoinflowUrl({ walletPubkey, sessionKey, route, routePrefix, env, subtotal, presentment, transaction, blockchain = 'solana', webhookInfo, email, loaderBackground, handleHeightChangeId, bankAccountLinkRedirect, additionalWallets, chargebackProtectionData, chargebackProtectionAccountType, merchantCss, color, rent, lockDefaultToken, tokens, planCode, disableApplePay, disableGooglePay, customerInfo, settlementType, lockAmount, nativeSolToConvert, theme, usePermit, transactionSigner, authOnly, deviceId, jwtToken, origins, threeDsChallengePreference, supportEmail, destinationAuthKey, allowedPaymentMethods, accountFundingTransaction, partialUsdcChecked, redemptionCheck, allowedWithdrawSpeeds, isZeroAuthorization, zeroAuthorizationConfig, userLocation, depositAmounts, baseUrl, }) {
584
+ 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, accountFundingTransaction, partialUsdcChecked, redemptionCheck, allowedWithdrawSpeeds, isZeroAuthorization, zeroAuthorizationConfig, userLocation, appReturnUrl, depositAmounts, ownerOverride, bridgeId, bankLinkOnly, baseUrl, }) {
562
585
  const prefix = routePrefix
563
586
  ? `/${routePrefix}/${blockchain}`
564
587
  : `/${blockchain}`;
565
588
  const url = new URL(prefix + route, baseUrl ?? CoinflowUtils.getCoinflowBaseUrl(env));
566
589
  if (walletPubkey)
567
590
  url.searchParams.append('pubkey', walletPubkey);
591
+ if (ownerOverride)
592
+ url.searchParams.append('ownerOverride', ownerOverride);
568
593
  if (sessionKey)
569
594
  url.searchParams.append('sessionKey', sessionKey);
570
595
  if (transaction) {
@@ -585,6 +610,10 @@ class CoinflowUtils {
585
610
  url.searchParams.append('amount', subtotal.amount.toString());
586
611
  }
587
612
  }
613
+ if (useNativeSubtotal)
614
+ url.searchParams.append('useNativeSubtotal', 'true');
615
+ if (bridgeId)
616
+ url.searchParams.append('bridgeId', bridgeId);
588
617
  if (presentment)
589
618
  url.searchParams.append('presentment', presentment);
590
619
  if (webhookInfo) {
@@ -613,6 +642,8 @@ class CoinflowUtils {
613
642
  if (bankAccountLinkRedirect) {
614
643
  url.searchParams.append('bankAccountLinkRedirect', bankAccountLinkRedirect);
615
644
  }
645
+ if (bankLinkOnly)
646
+ url.searchParams.append('bankLinkOnly', 'true');
616
647
  if (additionalWallets)
617
648
  url.searchParams.append('additionalWallets', LZString.compressToEncodedURIComponent(JSON.stringify(additionalWallets)));
618
649
  if (chargebackProtectionData)
@@ -647,6 +678,10 @@ class CoinflowUtils {
647
678
  url.searchParams.append('disableGooglePay', 'true');
648
679
  if (settlementType)
649
680
  url.searchParams.append('settlementType', settlementType);
681
+ // A purchase subtotal priced in tokens already set `amount`; don't append a
682
+ // second one, since URLSearchParams would keep both.
683
+ if (amount !== undefined && !url.searchParams.has('amount'))
684
+ url.searchParams.append('amount', amount.toString());
650
685
  if (lockAmount)
651
686
  url.searchParams.append('lockAmount', 'true');
652
687
  if (usePermit === false)
@@ -684,6 +719,8 @@ class CoinflowUtils {
684
719
  url.searchParams.append('lat', userLocation.lat.toString());
685
720
  url.searchParams.append('lng', userLocation.lng.toString());
686
721
  }
722
+ if (appReturnUrl)
723
+ url.searchParams.append('appReturnUrl', appReturnUrl);
687
724
  return url.toString();
688
725
  }
689
726
  static getCoinflowIntentsUrl({ baseUrl, route, color, theme, env, origins, deviceId, merchantCss, loaderBackground, handleHeightChangeId, }) {
@@ -847,10 +884,14 @@ var IFrameMessageMethods;
847
884
  IFrameMessageMethods["HeightChange"] = "heightChange";
848
885
  IFrameMessageMethods["Success"] = "success";
849
886
  IFrameMessageMethods["AuthDeclined"] = "authDeclined";
887
+ IFrameMessageMethods["InputError"] = "inputError";
888
+ IFrameMessageMethods["InputValid"] = "inputValid";
850
889
  IFrameMessageMethods["Loaded"] = "loaded";
851
890
  IFrameMessageMethods["AccountLinked"] = "accountLinked";
891
+ IFrameMessageMethods["AccountNotLinked"] = "accountNotLinked";
852
892
  IFrameMessageMethods["Redirect"] = "redirect";
853
893
  IFrameMessageMethods["Overlay"] = "overlay";
894
+ IFrameMessageMethods["UpdateSubtotal"] = "updateSubtotal";
854
895
  })(IFrameMessageMethods || (IFrameMessageMethods = {}));
855
896
  function getWalletPubkey(input) {
856
897
  let wallet;
@@ -910,9 +951,27 @@ function handleIFrameMessage(rawMessage, handlers, handleHeightChangeId) {
910
951
  return;
911
952
  handlers.onAuthDeclined(walletCall.info);
912
953
  return;
954
+ case IFrameMessageMethods.InputError:
955
+ if (!handlers.onInputError)
956
+ return;
957
+ handlers.onInputError(walletCall.info);
958
+ return;
959
+ case IFrameMessageMethods.InputValid:
960
+ if (!handlers.onInputValid)
961
+ return;
962
+ handlers.onInputValid(walletCall.info);
963
+ return;
913
964
  case IFrameMessageMethods.Loaded:
914
965
  return;
915
966
  case IFrameMessageMethods.AccountLinked:
967
+ if (!handlers.onAccountLinked)
968
+ return;
969
+ handlers.onAccountLinked(walletCall.info);
970
+ return;
971
+ case IFrameMessageMethods.AccountNotLinked:
972
+ if (!handlers.onAccountNotLinked)
973
+ return;
974
+ handlers.onAccountNotLinked(walletCall.info);
916
975
  return;
917
976
  case IFrameMessageMethods.Redirect:
918
977
  window.open(data, '_blank');
@@ -953,53 +1012,78 @@ function getHandlers(props) {
953
1012
  },
954
1013
  onSuccess: props.onSuccess,
955
1014
  onAuthDeclined: props.onAuthDeclined,
1015
+ onInputError: props.onInputError,
1016
+ onInputValid: props.onInputValid,
1017
+ onAccountLinked: props.onAccountLinked,
1018
+ onAccountNotLinked: props.onAccountNotLinked,
956
1019
  };
957
1020
  }
958
- return CoinflowUtils.byBlockchain(chain, {
1021
+ const walletHandlers = CoinflowUtils.byBlockchain(chain, {
959
1022
  solana: () => getSolanaWalletHandlers({
960
1023
  wallet: wallet,
961
1024
  onSuccess: props.onSuccess,
962
1025
  onAuthDeclined: props.onAuthDeclined,
1026
+ onInputError: props.onInputError,
1027
+ onInputValid: props.onInputValid,
963
1028
  }),
964
1029
  eth: () => getEvmWalletHandlers({
965
1030
  wallet: wallet,
966
1031
  onSuccess: props.onSuccess,
967
1032
  onAuthDeclined: props.onAuthDeclined,
1033
+ onInputError: props.onInputError,
1034
+ onInputValid: props.onInputValid,
968
1035
  }),
969
1036
  polygon: () => getEvmWalletHandlers({
970
1037
  wallet: wallet,
971
1038
  onSuccess: props.onSuccess,
972
1039
  onAuthDeclined: props.onAuthDeclined,
1040
+ onInputError: props.onInputError,
1041
+ onInputValid: props.onInputValid,
973
1042
  }),
974
1043
  base: () => getEvmWalletHandlers({
975
1044
  wallet: wallet,
976
1045
  onSuccess: props.onSuccess,
977
1046
  onAuthDeclined: props.onAuthDeclined,
1047
+ onInputError: props.onInputError,
1048
+ onInputValid: props.onInputValid,
978
1049
  }),
979
1050
  arbitrum: () => getEvmWalletHandlers({
980
1051
  wallet: wallet,
981
1052
  onSuccess: props.onSuccess,
982
1053
  onAuthDeclined: props.onAuthDeclined,
1054
+ onInputError: props.onInputError,
1055
+ onInputValid: props.onInputValid,
983
1056
  }),
984
1057
  stellar: () => getStellarWalletHandlers({
985
1058
  wallet: wallet,
986
1059
  onSuccess: props.onSuccess,
987
1060
  onAuthDeclined: props.onAuthDeclined,
1061
+ onInputError: props.onInputError,
1062
+ onInputValid: props.onInputValid,
988
1063
  }),
989
1064
  monad: () => getEvmWalletHandlers({
990
1065
  wallet: wallet,
991
1066
  onSuccess: props.onSuccess,
992
1067
  onAuthDeclined: props.onAuthDeclined,
1068
+ onInputError: props.onInputError,
1069
+ onInputValid: props.onInputValid,
993
1070
  }),
994
1071
  tempo: () => getEvmWalletHandlers({
995
1072
  wallet: wallet,
996
1073
  onSuccess: props.onSuccess,
997
1074
  onAuthDeclined: props.onAuthDeclined,
1075
+ onInputError: props.onInputError,
1076
+ onInputValid: props.onInputValid,
998
1077
  }),
999
1078
  user: () => getSessionKeyHandlers(props),
1000
1079
  })();
1080
+ return {
1081
+ ...walletHandlers,
1082
+ onAccountLinked: props.onAccountLinked,
1083
+ onAccountNotLinked: props.onAccountNotLinked,
1084
+ };
1001
1085
  }
1002
- function getSolanaWalletHandlers({ wallet, onSuccess, onAuthDeclined, }) {
1086
+ function getSolanaWalletHandlers({ wallet, onSuccess, onAuthDeclined, onInputError, onInputValid, }) {
1003
1087
  return {
1004
1088
  handleSendTransaction: async (transaction) => {
1005
1089
  const tx = getSolanaTransaction(transaction);
@@ -1031,6 +1115,8 @@ function getSolanaWalletHandlers({ wallet, onSuccess, onAuthDeclined, }) {
1031
1115
  },
1032
1116
  onSuccess,
1033
1117
  onAuthDeclined,
1118
+ onInputError,
1119
+ onInputValid,
1034
1120
  };
1035
1121
  }
1036
1122
  function getSolanaTransaction(data) {
@@ -1044,7 +1130,7 @@ function getSolanaTransaction(data) {
1044
1130
  return web3.Transaction.from(parsedUInt8Array);
1045
1131
  return vtx;
1046
1132
  }
1047
- function getEvmWalletHandlers({ wallet, onSuccess, onAuthDeclined, }) {
1133
+ function getEvmWalletHandlers({ wallet, onSuccess, onAuthDeclined, onInputError, onInputValid, }) {
1048
1134
  return {
1049
1135
  handleSendTransaction: async (transaction) => {
1050
1136
  const tx = JSON.parse(Buffer.from(transaction, 'base64').toString());
@@ -1056,9 +1142,11 @@ function getEvmWalletHandlers({ wallet, onSuccess, onAuthDeclined, }) {
1056
1142
  },
1057
1143
  onSuccess,
1058
1144
  onAuthDeclined,
1145
+ onInputError,
1146
+ onInputValid,
1059
1147
  };
1060
1148
  }
1061
- function getStellarWalletHandlers({ wallet, onSuccess, onAuthDeclined, }) {
1149
+ function getStellarWalletHandlers({ wallet, onSuccess, onAuthDeclined, onInputError, onInputValid, }) {
1062
1150
  return {
1063
1151
  handleSendTransaction: async (transaction) => {
1064
1152
  // transaction is unsigned base64 XDR
@@ -1081,15 +1169,19 @@ function getStellarWalletHandlers({ wallet, onSuccess, onAuthDeclined, }) {
1081
1169
  },
1082
1170
  onSuccess,
1083
1171
  onAuthDeclined,
1172
+ onInputError,
1173
+ onInputValid,
1084
1174
  };
1085
1175
  }
1086
- function getSessionKeyHandlers({ onSuccess, onAuthDeclined, }) {
1176
+ function getSessionKeyHandlers({ onSuccess, onAuthDeclined, onInputError, onInputValid, }) {
1087
1177
  return {
1088
1178
  handleSendTransaction: async () => {
1089
1179
  return Promise.resolve('');
1090
1180
  },
1091
1181
  onSuccess,
1092
1182
  onAuthDeclined,
1183
+ onInputError,
1184
+ onInputValid,
1093
1185
  };
1094
1186
  }
1095
1187
 
@@ -1631,6 +1723,56 @@ function getSkeletonColors(theme) {
1631
1723
  return luminance < 0.5 ? DARK_SURFACE_COLORS : LIGHT_SURFACE_COLORS;
1632
1724
  }
1633
1725
 
1726
+ const CARD_FIELD_ERROR_MESSAGES = {
1727
+ cardNumber: 'Card number is invalid. Please double check information.',
1728
+ expiration: 'Expiration is invalid. Please double check information.',
1729
+ cvv: 'CVV is invalid. Please double check information.',
1730
+ cvvEmpty: 'Please enter your CVV to proceed.',
1731
+ };
1732
+ function getCardFieldValidationError({ cardError, expirationError, cvvError, cvvEmpty, isCvvOnly, }) {
1733
+ if (cardError)
1734
+ return {
1735
+ field: 'card-number',
1736
+ message: CARD_FIELD_ERROR_MESSAGES.cardNumber,
1737
+ };
1738
+ if (expirationError)
1739
+ return {
1740
+ field: 'expiration',
1741
+ message: CARD_FIELD_ERROR_MESSAGES.expiration,
1742
+ };
1743
+ if (!cvvError)
1744
+ return null;
1745
+ if (isCvvOnly && cvvEmpty)
1746
+ return { field: 'cvv', message: CARD_FIELD_ERROR_MESSAGES.cvvEmpty };
1747
+ return { field: 'cvv', message: CARD_FIELD_ERROR_MESSAGES.cvv };
1748
+ }
1749
+ /**
1750
+ * Derives which messages to emit for a transition between two validation
1751
+ * states, so the parent hears about each change exactly once.
1752
+ *
1753
+ * Nothing is emitted while the state is unchanged (including the pristine
1754
+ * state, where both sides are null), so a field that is never invalid stays
1755
+ * silent and a visible error is not re-sent on every render.
1756
+ *
1757
+ * Only one error is displayed at a time (see getCardFieldValidationError's
1758
+ * precedence), so when the displayed error moves to a different field the
1759
+ * previous field has necessarily become valid and gets its own clear event.
1760
+ */
1761
+ function getCardFieldInputEvents({ previous, current, }) {
1762
+ if (!current)
1763
+ return previous ? [{ kind: 'valid', info: { field: previous.field } }] : [];
1764
+ if (!previous)
1765
+ return [{ kind: 'error', info: current }];
1766
+ if (previous.field === current.field)
1767
+ return previous.message === current.message
1768
+ ? []
1769
+ : [{ kind: 'error', info: current }];
1770
+ return [
1771
+ { kind: 'valid', info: { field: previous.field } },
1772
+ { kind: 'error', info: current },
1773
+ ];
1774
+ }
1775
+
1634
1776
  /* generated using openapi-typescript-codegen -- do no edit */
1635
1777
  /* istanbul ignore file */
1636
1778
  /* tslint:disable */
@@ -1903,6 +2045,87 @@ async function initCoinflowProtection({ coinflowEnv, merchantId, }) {
1903
2045
  }
1904
2046
  }
1905
2047
 
2048
+ function serializeCachedLinkToken(cached) {
2049
+ return JSON.stringify(cached);
2050
+ }
2051
+ /**
2052
+ * Reads a cache entry, tolerating the bare-token strings written before the
2053
+ * country was recorded. Those have unknown provenance, so they come back with
2054
+ * no country and `canReuseLinkToken` will refuse them for a specific rail.
2055
+ */
2056
+ function parseCachedLinkToken(raw) {
2057
+ if (!raw)
2058
+ return null;
2059
+ try {
2060
+ const parsed = JSON.parse(raw);
2061
+ if (typeof parsed?.token !== 'string' || !parsed.token)
2062
+ return null;
2063
+ return {
2064
+ token: parsed.token,
2065
+ country: typeof parsed.country === 'string' ? parsed.country : undefined,
2066
+ };
2067
+ }
2068
+ catch {
2069
+ // Legacy entry: the raw token with no recorded country.
2070
+ return { token: raw };
2071
+ }
2072
+ }
2073
+ /**
2074
+ * True when a cached token may be handed to a session for `country`.
2075
+ *
2076
+ * A caller that names a country needs a token minted for that same country;
2077
+ * anything else (a different rail, or an entry whose rail we never recorded)
2078
+ * has to be re-minted. A caller that names no country takes what is cached,
2079
+ * which is what the OAuth leg does when resuming a session already in flight.
2080
+ */
2081
+ function canReuseLinkToken({ cached, country, }) {
2082
+ if (!cached)
2083
+ return false;
2084
+ if (!country)
2085
+ return true;
2086
+ return cached.country === country;
2087
+ }
2088
+
2089
+ const BANK_LINK_STATUS_PARAM = 'bankLinkStatus';
2090
+ /**
2091
+ * Query parameters a standalone bank-link session appends to the merchant's
2092
+ * `callbackUrl`.
2093
+ *
2094
+ * The return leg carries no secret — only the outcome. The linked accounts and
2095
+ * their tokens are read from Get Customer, which is authenticated, so a
2096
+ * payment-instrument token never rides a merchant-supplied redirect. The same
2097
+ * invariant lets the shared redirect validator allow native-app deep links
2098
+ * without a whitelist, so nothing may be added here.
2099
+ */
2100
+ function bankLinkCallbackParams({ status, }) {
2101
+ return { [BANK_LINK_STATUS_PARAM]: status };
2102
+ }
2103
+ /**
2104
+ * Picks the completion behaviour for a finished bank link.
2105
+ *
2106
+ * `bankLinkOnly` wins over everything: the page was opened purely to link an
2107
+ * account, so there is nowhere to send the customer afterwards.
2108
+ */
2109
+ function resolveBankLinkCompletion({ bankLinkOnly, hasCallbackRedirect, isReactNativeLink, }) {
2110
+ if (bankLinkOnly)
2111
+ return 'emit';
2112
+ if (hasCallbackRedirect)
2113
+ return 'redirect';
2114
+ if (isReactNativeLink)
2115
+ return 'returnToApp';
2116
+ return 'returnToCheckout';
2117
+ }
2118
+ /**
2119
+ * How long the embedded flow holds the page blank before revealing the linked
2120
+ * state.
2121
+ *
2122
+ * A merchant who unmounts <CoinflowBankLink> on the accountLinked event should
2123
+ * never flash Coinflow's confirmation at their user, and a merchant who leaves
2124
+ * it mounted should not be left looking at nothing. Long enough to cover the
2125
+ * message hop and unmount, short enough not to read as a hang.
2126
+ */
2127
+ const BANK_LINK_REVEAL_DELAY_MS = 500;
2128
+
1906
2129
  class CoinflowIFrameComponent {
1907
2130
  constructor(sanitizer) {
1908
2131
  this.sanitizer = sanitizer;
@@ -1915,7 +2138,11 @@ class CoinflowIFrameComponent {
1915
2138
  this.sanitizer.bypassSecurityTrustResourceUrl(coinflowUrl);
1916
2139
  }
1917
2140
  onPostMessage(event) {
1918
- if (!event.origin.includes(CoinflowUtils.getCoinflowBaseUrl(this.iframeProps.env)))
2141
+ const expectedOrigin = new URL(CoinflowUtils.getCoinflowBaseUrl(this.iframeProps.env)).origin;
2142
+ if (event.origin !== expectedOrigin)
2143
+ return;
2144
+ // Only honor messages from this instance's own iframe.
2145
+ if (event.source !== this.iframe?.nativeElement?.contentWindow)
1919
2146
  return;
1920
2147
  this.messageEvent.emit(event);
1921
2148
  if (this.waitForLoadedMessage) {
@@ -2489,6 +2716,12 @@ class CoinflowCardForm {
2489
2716
  this.iframeHeight = parsedHeight;
2490
2717
  }
2491
2718
  }
2719
+ else if (parsed.method === IFrameMessageMethods.InputError) {
2720
+ void this.args.onInputError?.(parsed.info);
2721
+ }
2722
+ else if (parsed.method === IFrameMessageMethods.InputValid) {
2723
+ void this.args.onInputValid?.(parsed.info);
2724
+ }
2492
2725
  }
2493
2726
  catch {
2494
2727
  // not JSON
@@ -2619,6 +2852,10 @@ class CoinflowMobileWalletButtonComponent {
2619
2852
  constructor() {
2620
2853
  this.opacity = 0.8;
2621
2854
  this.display = 'flex';
2855
+ // The subtotal is pinned to its initial value in the iframe URL (built once
2856
+ // in ngOnInit) so amount changes don't force a reload. Updates are instead
2857
+ // sent to the running iframe via postMessage once it has loaded.
2858
+ this.loaded = false;
2622
2859
  }
2623
2860
  handleMessage({ data }) {
2624
2861
  try {
@@ -2633,11 +2870,38 @@ class CoinflowMobileWalletButtonComponent {
2633
2870
  setTimeout(() => {
2634
2871
  this.display = 'none';
2635
2872
  }, 2000);
2873
+ this.loaded = true;
2874
+ if (this.pendingSubtotal) {
2875
+ const pendingSubtotal = this.pendingSubtotal;
2876
+ this.pendingSubtotal = undefined;
2877
+ this.sendSubtotalUpdate(pendingSubtotal);
2878
+ }
2636
2879
  }
2637
2880
  }
2638
2881
  catch (e) { }
2639
2882
  }
2883
+ ngOnChanges(changes) {
2884
+ const purchasePropsChange = changes['purchaseProps'];
2885
+ if (!purchasePropsChange || purchasePropsChange.firstChange)
2886
+ return;
2887
+ const subtotal = purchasePropsChange.currentValue?.subtotal;
2888
+ if (!subtotal)
2889
+ return;
2890
+ this.sendSubtotalUpdate(subtotal);
2891
+ }
2892
+ sendSubtotalUpdate(subtotal) {
2893
+ if (!this.loaded) {
2894
+ this.pendingSubtotal = subtotal;
2895
+ return;
2896
+ }
2897
+ const serializedSubtotal = JSON.stringify(subtotal);
2898
+ if (this.lastSentSubtotal === serializedSubtotal)
2899
+ return;
2900
+ this.lastSentSubtotal = serializedSubtotal;
2901
+ this.iframeComponent?.sendMessage(`${IFrameMessageMethods.UpdateSubtotal}:${serializedSubtotal}`);
2902
+ }
2640
2903
  ngOnInit() {
2904
+ this.lastSentSubtotal = JSON.stringify(this.purchaseProps?.subtotal);
2641
2905
  const walletPubkey = getWalletPubkey(this.purchaseProps);
2642
2906
  this.messageHandlers = getHandlers(this.purchaseProps);
2643
2907
  this.messageHandlers.handleHeightChange =
@@ -2653,7 +2917,7 @@ class CoinflowMobileWalletButtonComponent {
2653
2917
  };
2654
2918
  }
2655
2919
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.10", ngImport: i0, type: CoinflowMobileWalletButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
2656
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.10", type: CoinflowMobileWalletButtonComponent, isStandalone: true, selector: "lib-coinflow-mobile-wallet-button", inputs: { purchaseProps: "purchaseProps", route: "route", overlayDisplayOverride: "overlayDisplayOverride", alignItems: "alignItems" }, ngImport: i0, template: ` <div style="position: relative; height: 100%;">
2920
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.10", type: CoinflowMobileWalletButtonComponent, isStandalone: true, selector: "lib-coinflow-mobile-wallet-button", inputs: { purchaseProps: "purchaseProps", route: "route", overlayDisplayOverride: "overlayDisplayOverride", alignItems: "alignItems" }, viewQueries: [{ propertyName: "iframeComponent", first: true, predicate: CoinflowIFrameComponent, descendants: true }], usesOnChanges: true, ngImport: i0, template: ` <div style="position: relative; height: 100%;">
2657
2921
  <div
2658
2922
  [style.background-color]="purchaseProps.color"
2659
2923
  [style.display]="overlayDisplayOverride ?? display"
@@ -2711,6 +2975,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.10", ngImpo
2711
2975
  type: Input
2712
2976
  }], alignItems: [{
2713
2977
  type: Input
2978
+ }], iframeComponent: [{
2979
+ type: ViewChild,
2980
+ args: [CoinflowIFrameComponent]
2714
2981
  }] } });
2715
2982
 
2716
2983
  class CoinflowApplePayButtonComponent {
@@ -2981,5 +3248,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.10", ngImpo
2981
3248
  * Generated bundle index. Do not edit.
2982
3249
  */
2983
3250
 
2984
- export { 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_TYPE_MAPPING, COMPACT_SKELETON_HEIGHT_PX, CardType, ChargebackProtectionAccountType, CoinflowApplePayButtonComponent, CoinflowCardForm, CoinflowCardFormV2, CoinflowCardNumberInput, CoinflowCardNumberOnlyInput, CoinflowCvvInputComponent, CoinflowCvvOnlyInputComponent, 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, TokenExCardNumberIframeId, TokenExCvvContainerID, WithdrawCategory, WithdrawCurrencies, WithdrawSpeed, awaitForterToken, buildCardEntryGridCss, buildCardEntryLayout, buildSkeletonCss, captureForterToken, doInitializeCvvOnlyTokenExIframe, doInitializeTokenExCardOnlyIframe, doInitializeTokenExIframe, getCoinflowProtectionHeaders, getCoinflowPurchaseHeaders, getCurrencyDecimals, getCustomerName, getForterToken, getHandlers, getIframeConfig, getSkeletonColors, getSkeletonGridClass, getSkeletonGridTemplate, getWalletPubkey, guessSkeletonHeightPx, handleIFrameMessage, initCoinflowProtection, invertRate, isBankingCurrency, isTypedCurrencyCents, isWithdrawCurrency, isZeroAuthSavedPaymentMethods, isZeroAuthVerifyCard, nftCartItem, paymentMethodLabels, recordFrontendError, setTokenExScriptTag, shouldStackSkeleton };
3251
+ 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, CARD_TYPE_MAPPING, COMPACT_SKELETON_HEIGHT_PX, CardType, ChargebackProtectionAccountType, CoinflowApplePayButtonComponent, CoinflowCardForm, CoinflowCardFormV2, CoinflowCardNumberInput, CoinflowCardNumberOnlyInput, CoinflowCvvInputComponent, CoinflowCvvOnlyInputComponent, 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, TokenExCardNumberIframeId, TokenExCvvContainerID, WithdrawCategory, WithdrawCurrencies, WithdrawSpeed, awaitForterToken, bankLinkCallbackParams, buildCardEntryGridCss, buildCardEntryLayout, buildSkeletonCss, canReuseLinkToken, captureForterToken, doInitializeCvvOnlyTokenExIframe, doInitializeTokenExCardOnlyIframe, doInitializeTokenExIframe, getCardFieldInputEvents, getCardFieldValidationError, getCoinflowProtectionHeaders, getCoinflowPurchaseHeaders, getCurrencyDecimals, getCustomerName, getForterToken, getHandlers, getIframeConfig, getSkeletonColors, getSkeletonGridClass, getSkeletonGridTemplate, getWalletPubkey, guessSkeletonHeightPx, handleIFrameMessage, initCoinflowProtection, invertRate, isBankingCurrency, isTypedCurrencyCents, isWithdrawCurrency, isZeroAuthSavedPaymentMethods, isZeroAuthVerifyCard, nftCartItem, parseCachedLinkToken, paymentMethodLabels, recordFrontendError, resolveBankLinkCompletion, serializeCachedLinkToken, setTokenExScriptTag, shouldStackSkeleton };
2985
3252
  //# sourceMappingURL=coinflowlabs-angular.mjs.map