@coinflowlabs/angular 1.10.0 → 1.12.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,16 @@ This library was generated with [Angular CLI](https://github.com/angular/angular
4
4
 
5
5
  # Changelog
6
6
 
7
+ ## 1.11.0
8
+
9
+ - Added `cardBackground` to `MerchantTheme` to control the inner card-entry surface independently of the outer canvas `background`
10
+ - Added `placeholderColor` to `MerchantTheme` to control placeholder text color in card form inputs
11
+ - Fixed the card brand icon being hidden when the card form reflows to a stacked two-row layout at narrow widths
12
+
13
+ ## 1.10.0
14
+
15
+ - Fixed an issue with vertical spacing when resizing the page
16
+
7
17
  ## 1.8.0
8
18
 
9
19
  - New `CoinflowCardForm` component — simple card input with a single `tokenize()` call and full theme support
@@ -70,7 +70,10 @@ var PaymentMethods;
70
70
  PaymentMethods["crypto"] = "crypto";
71
71
  PaymentMethods["wire"] = "wire";
72
72
  PaymentMethods["cashApp"] = "cashApp";
73
- PaymentMethods["rain"] = "rain";
73
+ PaymentMethods["apa"] = "apa";
74
+ PaymentMethods["paypal"] = "paypal";
75
+ PaymentMethods["venmo"] = "venmo";
76
+ PaymentMethods["interac"] = "interac";
74
77
  })(PaymentMethods || (PaymentMethods = {}));
75
78
  const paymentMethodLabels = {
76
79
  [PaymentMethods.card]: 'Card',
@@ -85,7 +88,10 @@ const paymentMethodLabels = {
85
88
  [PaymentMethods.crypto]: 'Crypto',
86
89
  [PaymentMethods.wire]: 'Wire Transfer',
87
90
  [PaymentMethods.cashApp]: 'CashApp',
88
- [PaymentMethods.rain]: 'Rain',
91
+ [PaymentMethods.apa]: 'APA',
92
+ [PaymentMethods.paypal]: 'PayPal',
93
+ [PaymentMethods.venmo]: 'Venmo',
94
+ [PaymentMethods.interac]: 'Interac',
89
95
  };
90
96
  var CardType;
91
97
  (function (CardType) {
@@ -551,7 +557,7 @@ class CoinflowUtils {
551
557
  return 'http://localhost:5000';
552
558
  return `https://api-${env}.coinflow.cash`;
553
559
  }
554
- 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, baseUrl, }) {
560
+ 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, }) {
555
561
  const prefix = routePrefix
556
562
  ? `/${routePrefix}/${blockchain}`
557
563
  : `/${blockchain}`;
@@ -663,6 +669,8 @@ class CoinflowUtils {
663
669
  url.searchParams.append('origins', LZString.compressToEncodedURIComponent(JSON.stringify(origins)));
664
670
  if (allowedPaymentMethods)
665
671
  url.searchParams.append('allowedPaymentMethods', allowedPaymentMethods.join(','));
672
+ if (depositAmounts)
673
+ url.searchParams.append('depositAmounts', depositAmounts.join(','));
666
674
  if (threeDsChallengePreference)
667
675
  url.searchParams.append('threeDsChallengePreference', threeDsChallengePreference);
668
676
  if (destinationAuthKey)
@@ -841,6 +849,7 @@ var IFrameMessageMethods;
841
849
  IFrameMessageMethods["Loaded"] = "loaded";
842
850
  IFrameMessageMethods["AccountLinked"] = "accountLinked";
843
851
  IFrameMessageMethods["Redirect"] = "redirect";
852
+ IFrameMessageMethods["Overlay"] = "overlay";
844
853
  })(IFrameMessageMethods || (IFrameMessageMethods = {}));
845
854
  function getWalletPubkey(input) {
846
855
  let wallet;
@@ -907,6 +916,11 @@ function handleIFrameMessage(rawMessage, handlers, handleHeightChangeId) {
907
916
  case IFrameMessageMethods.Redirect:
908
917
  window.open(data, '_blank');
909
918
  return;
919
+ case IFrameMessageMethods.Overlay:
920
+ if (!handlers.handleOverlay)
921
+ return;
922
+ handlers.handleOverlay(data);
923
+ return;
910
924
  }
911
925
  console.warn(`Didn't expect to get here, handleIFrameMessage method:${method} is not one of ${Object.values(IFrameMessageMethods)}`);
912
926
  }
@@ -1320,13 +1334,139 @@ function getProtectionSessionId() {
1320
1334
  return cachedSessionId;
1321
1335
  }
1322
1336
 
1337
+ const FORTER_COOKIE_NAME = 'forterToken';
1338
+ // 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.
1339
+ const MAX_FORTER_TOKEN_LENGTH = 1024;
1340
+ // eslint-disable-next-line no-control-regex
1341
+ const FORTER_TOKEN_UNSAFE_PATTERN = /[\x00-\x1F\x7F]/;
1342
+ // Forter sets the `forterToken` cookie asynchronously and some WebViews (notably React Native) only surface it transiently/late, so a just-in-time checkout read often comes back empty even when nSure and Verisoul succeed; cache and prefer the captured token (see captureForterToken) as Verisoul does, and keep it current latest-wins since Forter re-emits a more complete token after its handshake (later `ftr:tokenReady` events overwrite it and the cookie poll keeps refreshing) rather than freezing on the first partial token.
1343
+ let cachedForterToken = null;
1344
+ // Whether `cachedForterToken` came from the authoritative `ftr:tokenReady` event, the reliable source in cross-origin iframes / WebViews where the cookie is partitioned or stale, so a cookie read must never clobber an event-sourced value.
1345
+ let cachedFromEvent = false;
1346
+ // Ensures only one cookie-poll loop runs at a time (captureForterToken can be called from several mounted protection components).
1347
+ let pollActive = false;
1348
+ function sanitizeForterToken(raw) {
1349
+ if (!raw)
1350
+ return null;
1351
+ let token = raw;
1352
+ try {
1353
+ token = decodeURIComponent(raw);
1354
+ }
1355
+ catch {
1356
+ // keep raw if it isn't valid percent-encoding
1357
+ }
1358
+ if (!token)
1359
+ return null;
1360
+ if (token.length > MAX_FORTER_TOKEN_LENGTH)
1361
+ return null;
1362
+ if (FORTER_TOKEN_UNSAFE_PATTERN.test(token))
1363
+ return null;
1364
+ return token;
1365
+ }
1366
+ // Reads the Forter cookie. Matches `forterToken` exactly, then falls back to any `*forter*token*` cookie name in case Forter changes/prefixes it.
1367
+ function readForterCookie() {
1368
+ if (typeof document === 'undefined' || !document.cookie)
1369
+ return null;
1370
+ let fallback = null;
1371
+ for (const part of document.cookie.split(';')) {
1372
+ const eq = part.indexOf('=');
1373
+ if (eq === -1)
1374
+ continue;
1375
+ const name = part.slice(0, eq).trim();
1376
+ const value = part.slice(eq + 1);
1377
+ if (name === FORTER_COOKIE_NAME)
1378
+ return value;
1379
+ const lower = name.toLowerCase();
1380
+ if (lower.includes('forter') && lower.includes('token'))
1381
+ fallback = value;
1382
+ }
1383
+ return fallback;
1384
+ }
1385
+ function getForterToken() {
1386
+ return cachedForterToken ?? sanitizeForterToken(readForterCookie());
1387
+ }
1388
+ // Forter dispatches `ftr:tokenReady` on `document` with the token in `event.detail` once computed; this is cookie-INDEPENDENT and so the reliable source in cross-origin iframes / WebViews where the forterToken cookie is partitioned/blocked (the cookie still works as a fallback on web).
1389
+ const FORTER_TOKEN_READY_EVENT = 'ftr:tokenReady';
1390
+ function handleForterTokenReady(event) {
1391
+ const detail = event.detail;
1392
+ const token = typeof detail === 'string' ? sanitizeForterToken(detail) : null;
1393
+ if (!token)
1394
+ return;
1395
+ // Latest-wins: stay subscribed so each re-emission overwrites the cache with the newer, more complete token (see note on cachedForterToken).
1396
+ cachedForterToken = token;
1397
+ cachedFromEvent = true;
1398
+ }
1399
+ // Capture and cache the Forter token shortly after the SDK script is injected so it is available to getForterToken() by checkout time: primary source is the `ftr:tokenReady` event and the cookie is polled as a fallback, and if neither surfaces log a diagnostic (cookie names + Forter globals only — never values) to reveal whether the SDK exposes the token at all in this context.
1400
+ function captureForterToken({ timeoutMs = 15_000, intervalMs = 250, } = {}) {
1401
+ if (typeof window === 'undefined')
1402
+ return;
1403
+ // Stay subscribed for the page lifetime so every `ftr:tokenReady` overwrites the cache (latest-wins); addEventListener dedupes the same handler, so calling this from multiple mounts registers it only once.
1404
+ if (typeof document !== 'undefined') {
1405
+ document.addEventListener(FORTER_TOKEN_READY_EVENT, handleForterTokenReady);
1406
+ }
1407
+ if (pollActive)
1408
+ return;
1409
+ pollActive = true;
1410
+ const start = Date.now();
1411
+ const tick = () => {
1412
+ // Keep refreshing from the cookie (latest-wins among cookie reads) until the window closes, but never clobber an event-sourced token — the event is authoritative where the cookie is partitioned / stale.
1413
+ if (!cachedFromEvent) {
1414
+ const token = sanitizeForterToken(readForterCookie());
1415
+ if (token)
1416
+ cachedForterToken = token;
1417
+ }
1418
+ if (Date.now() - start >= timeoutMs) {
1419
+ pollActive = false;
1420
+ if (!cachedForterToken)
1421
+ logForterTokenMissing();
1422
+ return;
1423
+ }
1424
+ window.setTimeout(tick, intervalMs);
1425
+ };
1426
+ tick();
1427
+ }
1428
+ function logForterTokenMissing() {
1429
+ if (typeof document === 'undefined')
1430
+ return;
1431
+ const cookieNames = (document.cookie || '')
1432
+ .split(';')
1433
+ .map(part => part.split('=')[0].trim())
1434
+ .filter(Boolean);
1435
+ const forterGlobals = typeof window !== 'undefined'
1436
+ ? Object.keys(window).filter(key => /ftr|forter/i.test(key))
1437
+ : [];
1438
+ console.warn('[forter] token never surfaced after init.', 'cookieNames:', cookieNames, 'forterGlobals:', forterGlobals);
1439
+ }
1440
+ // 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.
1441
+ async function awaitForterToken({ timeoutMs = 2_000, intervalMs = 100, } = {}) {
1442
+ const existing = getForterToken();
1443
+ if (existing)
1444
+ return existing;
1445
+ if (typeof window === 'undefined')
1446
+ return null;
1447
+ return new Promise(resolve => {
1448
+ const start = Date.now();
1449
+ const poll = () => {
1450
+ const token = getForterToken();
1451
+ if (token)
1452
+ return resolve(token);
1453
+ if (Date.now() - start >= timeoutMs)
1454
+ return resolve(getForterToken());
1455
+ window.setTimeout(poll, intervalMs);
1456
+ };
1457
+ window.setTimeout(poll, intervalMs);
1458
+ });
1459
+ }
1460
+
1323
1461
  const DEVICE_ID_HEADER = 'x-device-id';
1324
1462
  const SESSION_ID_HEADER = 'x-session-id';
1325
1463
  const REFERRER_HEADER = 'x-coinflow-referrer';
1464
+ const FORTER_TOKEN_HEADER = 'x-forter-token';
1326
1465
  function getCoinflowProtectionHeaders() {
1327
1466
  return {
1328
1467
  [DEVICE_ID_HEADER]: getNSureDeviceId(),
1329
1468
  [SESSION_ID_HEADER]: getProtectionSessionId(),
1469
+ [FORTER_TOKEN_HEADER]: getForterToken(),
1330
1470
  };
1331
1471
  }
1332
1472
  function getReferrer() {
@@ -2337,5 +2477,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.10", ngImpo
2337
2477
  * Generated bundle index. Do not edit.
2338
2478
  */
2339
2479
 
2340
- export { BankingCurrencies, CARD_TYPE_MAPPING, CardType, ChargebackProtectionAccountType, CoinflowApplePayButtonComponent, CoinflowCardForm, CoinflowCardFormV2, CoinflowCardNumberInput, CoinflowCardNumberOnlyInput, CoinflowCvvInputComponent, CoinflowCvvOnlyInputComponent, CoinflowGooglePayButtonComponent, CoinflowIFrameComponent, CoinflowPurchaseComponent, CoinflowPurchaseHistoryComponent, CoinflowPurchaseProtectionComponent, CoinflowUtils, CoinflowWithdrawComponent, CoinflowWithdrawHistoryComponent, Currency, CurrencyToISO4217, DEVICE_ID_HEADER, EventBus, IFrameMessageMethods, MerchantStyle, PaymentMethods, REFERRER_HEADER, RN_REDIRECT_MESSAGE_NAME, SESSION_ID_HEADER, SettlementType, ThreeDsChallengePreference, TokenExCardNumberIframeId, TokenExCvvContainerID, WithdrawCategory, WithdrawCurrencies, WithdrawSpeed, doInitializeCvvOnlyTokenExIframe, doInitializeTokenExCardOnlyIframe, doInitializeTokenExIframe, getCoinflowProtectionHeaders, getCoinflowPurchaseHeaders, getCurrencyDecimals, getCustomerName, getHandlers, getIframeConfig, getWalletPubkey, handleIFrameMessage, initCoinflowProtection, invertRate, isBankingCurrency, isTypedCurrencyCents, isWithdrawCurrency, isZeroAuthSavedPaymentMethods, isZeroAuthVerifyCard, nftCartItem, paymentMethodLabels, recordFrontendError, setTokenExScriptTag };
2480
+ export { BankingCurrencies, CARD_TYPE_MAPPING, 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, MerchantStyle, PaymentMethods, REFERRER_HEADER, RN_REDIRECT_MESSAGE_NAME, SESSION_ID_HEADER, SettlementType, ThreeDsChallengePreference, TokenExCardNumberIframeId, TokenExCvvContainerID, WithdrawCategory, WithdrawCurrencies, WithdrawSpeed, awaitForterToken, captureForterToken, doInitializeCvvOnlyTokenExIframe, doInitializeTokenExCardOnlyIframe, doInitializeTokenExIframe, getCoinflowProtectionHeaders, getCoinflowPurchaseHeaders, getCurrencyDecimals, getCustomerName, getForterToken, getHandlers, getIframeConfig, getWalletPubkey, handleIFrameMessage, initCoinflowProtection, invertRate, isBankingCurrency, isTypedCurrencyCents, isWithdrawCurrency, isZeroAuthSavedPaymentMethods, isZeroAuthVerifyCard, nftCartItem, paymentMethodLabels, recordFrontendError, setTokenExScriptTag };
2341
2481
  //# sourceMappingURL=coinflowlabs-angular.mjs.map