@coinflowlabs/angular 1.14.0 → 1.15.1

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.
@@ -27,6 +27,10 @@ var WithdrawSpeed;
27
27
  WithdrawSpeed["WIRE"] = "wire";
28
28
  WithdrawSpeed["INTERAC"] = "interac";
29
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";
30
34
  })(WithdrawSpeed || (WithdrawSpeed = {}));
31
35
  var SettlementType;
32
36
  (function (SettlementType) {
@@ -552,6 +556,24 @@ class CoinflowUtils {
552
556
  return 'http://localhost:3003';
553
557
  return `https://app-${env}.coinflow.cash`;
554
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
+ }
555
577
  static getCoinflowApiUrl(env) {
556
578
  if (!env || env === 'prod')
557
579
  return 'https://api.coinflow.cash';
@@ -559,7 +581,7 @@ class CoinflowUtils {
559
581
  return 'http://localhost:5000';
560
582
  return `https://api-${env}.coinflow.cash`;
561
583
  }
562
- 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, lockAmount, nativeSolToConvert, theme, usePermit, transactionSigner, authOnly, deviceId, jwtToken, origins, threeDsChallengePreference, supportEmail, destinationAuthKey, allowedPaymentMethods, accountFundingTransaction, partialUsdcChecked, redemptionCheck, allowedWithdrawSpeeds, isZeroAuthorization, zeroAuthorizationConfig, userLocation, appReturnUrl, depositAmounts, ownerOverride, bridgeId, 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, }) {
563
585
  const prefix = routePrefix
564
586
  ? `/${routePrefix}/${blockchain}`
565
587
  : `/${blockchain}`;
@@ -620,6 +642,8 @@ class CoinflowUtils {
620
642
  if (bankAccountLinkRedirect) {
621
643
  url.searchParams.append('bankAccountLinkRedirect', bankAccountLinkRedirect);
622
644
  }
645
+ if (bankLinkOnly)
646
+ url.searchParams.append('bankLinkOnly', 'true');
623
647
  if (additionalWallets)
624
648
  url.searchParams.append('additionalWallets', LZString.compressToEncodedURIComponent(JSON.stringify(additionalWallets)));
625
649
  if (chargebackProtectionData)
@@ -654,6 +678,10 @@ class CoinflowUtils {
654
678
  url.searchParams.append('disableGooglePay', 'true');
655
679
  if (settlementType)
656
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());
657
685
  if (lockAmount)
658
686
  url.searchParams.append('lockAmount', 'true');
659
687
  if (usePermit === false)
@@ -860,6 +888,8 @@ var IFrameMessageMethods;
860
888
  IFrameMessageMethods["InputValid"] = "inputValid";
861
889
  IFrameMessageMethods["Loaded"] = "loaded";
862
890
  IFrameMessageMethods["AccountLinked"] = "accountLinked";
891
+ IFrameMessageMethods["AccountNotLinked"] = "accountNotLinked";
892
+ IFrameMessageMethods["AccountLinkError"] = "accountLinkError";
863
893
  IFrameMessageMethods["Redirect"] = "redirect";
864
894
  IFrameMessageMethods["Overlay"] = "overlay";
865
895
  IFrameMessageMethods["UpdateSubtotal"] = "updateSubtotal";
@@ -935,6 +965,19 @@ function handleIFrameMessage(rawMessage, handlers, handleHeightChangeId) {
935
965
  case IFrameMessageMethods.Loaded:
936
966
  return;
937
967
  case IFrameMessageMethods.AccountLinked:
968
+ if (!handlers.onAccountLinked)
969
+ return;
970
+ handlers.onAccountLinked(walletCall.info);
971
+ return;
972
+ case IFrameMessageMethods.AccountNotLinked:
973
+ if (!handlers.onAccountNotLinked)
974
+ return;
975
+ handlers.onAccountNotLinked(walletCall.info);
976
+ return;
977
+ case IFrameMessageMethods.AccountLinkError:
978
+ if (!handlers.onAccountLinkError)
979
+ return;
980
+ handlers.onAccountLinkError(walletCall.info);
938
981
  return;
939
982
  case IFrameMessageMethods.Redirect:
940
983
  window.open(data, '_blank');
@@ -977,9 +1020,12 @@ function getHandlers(props) {
977
1020
  onAuthDeclined: props.onAuthDeclined,
978
1021
  onInputError: props.onInputError,
979
1022
  onInputValid: props.onInputValid,
1023
+ onAccountLinked: props.onAccountLinked,
1024
+ onAccountNotLinked: props.onAccountNotLinked,
1025
+ onAccountLinkError: props.onAccountLinkError,
980
1026
  };
981
1027
  }
982
- return CoinflowUtils.byBlockchain(chain, {
1028
+ const walletHandlers = CoinflowUtils.byBlockchain(chain, {
983
1029
  solana: () => getSolanaWalletHandlers({
984
1030
  wallet: wallet,
985
1031
  onSuccess: props.onSuccess,
@@ -1038,6 +1084,12 @@ function getHandlers(props) {
1038
1084
  }),
1039
1085
  user: () => getSessionKeyHandlers(props),
1040
1086
  })();
1087
+ return {
1088
+ ...walletHandlers,
1089
+ onAccountLinked: props.onAccountLinked,
1090
+ onAccountNotLinked: props.onAccountNotLinked,
1091
+ onAccountLinkError: props.onAccountLinkError,
1092
+ };
1041
1093
  }
1042
1094
  function getSolanaWalletHandlers({ wallet, onSuccess, onAuthDeclined, onInputError, onInputValid, }) {
1043
1095
  return {
@@ -2042,6 +2094,46 @@ function canReuseLinkToken({ cached, country, }) {
2042
2094
  return cached.country === country;
2043
2095
  }
2044
2096
 
2097
+ const BANK_LINK_STATUS_PARAM = 'bankLinkStatus';
2098
+ /**
2099
+ * Query parameters a standalone bank-link session appends to the merchant's
2100
+ * `callbackUrl`.
2101
+ *
2102
+ * The return leg carries no secret — only the outcome. The linked accounts and
2103
+ * their tokens are read from Get Customer, which is authenticated, so a
2104
+ * payment-instrument token never rides a merchant-supplied redirect. The same
2105
+ * invariant lets the shared redirect validator allow native-app deep links
2106
+ * without a whitelist, so nothing may be added here.
2107
+ */
2108
+ function bankLinkCallbackParams({ status, }) {
2109
+ return { [BANK_LINK_STATUS_PARAM]: status };
2110
+ }
2111
+ /**
2112
+ * Picks the completion behaviour for a finished bank link.
2113
+ *
2114
+ * `bankLinkOnly` wins over everything: the page was opened purely to link an
2115
+ * account, so there is nowhere to send the customer afterwards.
2116
+ */
2117
+ function resolveBankLinkCompletion({ bankLinkOnly, hasCallbackRedirect, isReactNativeLink, }) {
2118
+ if (bankLinkOnly)
2119
+ return 'emit';
2120
+ if (hasCallbackRedirect)
2121
+ return 'redirect';
2122
+ if (isReactNativeLink)
2123
+ return 'returnToApp';
2124
+ return 'returnToCheckout';
2125
+ }
2126
+ /**
2127
+ * How long the embedded flow holds the page blank before revealing the linked
2128
+ * state.
2129
+ *
2130
+ * A merchant who unmounts <CoinflowBankLink> on the accountLinked event should
2131
+ * never flash Coinflow's confirmation at their user, and a merchant who leaves
2132
+ * it mounted should not be left looking at nothing. Long enough to cover the
2133
+ * message hop and unmount, short enough not to read as a hang.
2134
+ */
2135
+ const BANK_LINK_REVEAL_DELAY_MS = 500;
2136
+
2045
2137
  class CoinflowIFrameComponent {
2046
2138
  constructor(sanitizer) {
2047
2139
  this.sanitizer = sanitizer;
@@ -2054,7 +2146,11 @@ class CoinflowIFrameComponent {
2054
2146
  this.sanitizer.bypassSecurityTrustResourceUrl(coinflowUrl);
2055
2147
  }
2056
2148
  onPostMessage(event) {
2057
- if (!event.origin.includes(CoinflowUtils.getCoinflowBaseUrl(this.iframeProps.env)))
2149
+ const expectedOrigin = new URL(CoinflowUtils.getCoinflowBaseUrl(this.iframeProps.env)).origin;
2150
+ if (event.origin !== expectedOrigin)
2151
+ return;
2152
+ // Only honor messages from this instance's own iframe.
2153
+ if (event.source !== this.iframe?.nativeElement?.contentWindow)
2058
2154
  return;
2059
2155
  this.messageEvent.emit(event);
2060
2156
  if (this.waitForLoadedMessage) {
@@ -3160,5 +3256,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.10", ngImpo
3160
3256
  * Generated bundle index. Do not edit.
3161
3257
  */
3162
3258
 
3163
- 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_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, 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, serializeCachedLinkToken, setTokenExScriptTag, shouldStackSkeleton };
3259
+ 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 };
3164
3260
  //# sourceMappingURL=coinflowlabs-angular.mjs.map