@coinflowlabs/angular 1.14.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.
|
@@ -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,7 @@ var IFrameMessageMethods;
|
|
|
860
888
|
IFrameMessageMethods["InputValid"] = "inputValid";
|
|
861
889
|
IFrameMessageMethods["Loaded"] = "loaded";
|
|
862
890
|
IFrameMessageMethods["AccountLinked"] = "accountLinked";
|
|
891
|
+
IFrameMessageMethods["AccountNotLinked"] = "accountNotLinked";
|
|
863
892
|
IFrameMessageMethods["Redirect"] = "redirect";
|
|
864
893
|
IFrameMessageMethods["Overlay"] = "overlay";
|
|
865
894
|
IFrameMessageMethods["UpdateSubtotal"] = "updateSubtotal";
|
|
@@ -935,6 +964,14 @@ function handleIFrameMessage(rawMessage, handlers, handleHeightChangeId) {
|
|
|
935
964
|
case IFrameMessageMethods.Loaded:
|
|
936
965
|
return;
|
|
937
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);
|
|
938
975
|
return;
|
|
939
976
|
case IFrameMessageMethods.Redirect:
|
|
940
977
|
window.open(data, '_blank');
|
|
@@ -977,9 +1014,11 @@ function getHandlers(props) {
|
|
|
977
1014
|
onAuthDeclined: props.onAuthDeclined,
|
|
978
1015
|
onInputError: props.onInputError,
|
|
979
1016
|
onInputValid: props.onInputValid,
|
|
1017
|
+
onAccountLinked: props.onAccountLinked,
|
|
1018
|
+
onAccountNotLinked: props.onAccountNotLinked,
|
|
980
1019
|
};
|
|
981
1020
|
}
|
|
982
|
-
|
|
1021
|
+
const walletHandlers = CoinflowUtils.byBlockchain(chain, {
|
|
983
1022
|
solana: () => getSolanaWalletHandlers({
|
|
984
1023
|
wallet: wallet,
|
|
985
1024
|
onSuccess: props.onSuccess,
|
|
@@ -1038,6 +1077,11 @@ function getHandlers(props) {
|
|
|
1038
1077
|
}),
|
|
1039
1078
|
user: () => getSessionKeyHandlers(props),
|
|
1040
1079
|
})();
|
|
1080
|
+
return {
|
|
1081
|
+
...walletHandlers,
|
|
1082
|
+
onAccountLinked: props.onAccountLinked,
|
|
1083
|
+
onAccountNotLinked: props.onAccountNotLinked,
|
|
1084
|
+
};
|
|
1041
1085
|
}
|
|
1042
1086
|
function getSolanaWalletHandlers({ wallet, onSuccess, onAuthDeclined, onInputError, onInputValid, }) {
|
|
1043
1087
|
return {
|
|
@@ -2042,6 +2086,46 @@ function canReuseLinkToken({ cached, country, }) {
|
|
|
2042
2086
|
return cached.country === country;
|
|
2043
2087
|
}
|
|
2044
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
|
+
|
|
2045
2129
|
class CoinflowIFrameComponent {
|
|
2046
2130
|
constructor(sanitizer) {
|
|
2047
2131
|
this.sanitizer = sanitizer;
|
|
@@ -2054,7 +2138,11 @@ class CoinflowIFrameComponent {
|
|
|
2054
2138
|
this.sanitizer.bypassSecurityTrustResourceUrl(coinflowUrl);
|
|
2055
2139
|
}
|
|
2056
2140
|
onPostMessage(event) {
|
|
2057
|
-
|
|
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)
|
|
2058
2146
|
return;
|
|
2059
2147
|
this.messageEvent.emit(event);
|
|
2060
2148
|
if (this.waitForLoadedMessage) {
|
|
@@ -3160,5 +3248,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.10", ngImpo
|
|
|
3160
3248
|
* Generated bundle index. Do not edit.
|
|
3161
3249
|
*/
|
|
3162
3250
|
|
|
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 };
|
|
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 };
|
|
3164
3252
|
//# sourceMappingURL=coinflowlabs-angular.mjs.map
|