@metamask/ramps-controller 16.0.0 → 17.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.
Files changed (90) hide show
  1. package/CHANGELOG.md +34 -1
  2. package/dist/RampsController-method-action-types.cjs.map +1 -1
  3. package/dist/RampsController-method-action-types.d.cts +15 -1
  4. package/dist/RampsController-method-action-types.d.cts.map +1 -1
  5. package/dist/RampsController-method-action-types.d.mts +15 -1
  6. package/dist/RampsController-method-action-types.d.mts.map +1 -1
  7. package/dist/RampsController-method-action-types.mjs.map +1 -1
  8. package/dist/RampsController.cjs +90 -97
  9. package/dist/RampsController.cjs.map +1 -1
  10. package/dist/RampsController.d.cts +22 -28
  11. package/dist/RampsController.d.cts.map +1 -1
  12. package/dist/RampsController.d.mts +22 -28
  13. package/dist/RampsController.d.mts.map +1 -1
  14. package/dist/RampsController.mjs +63 -70
  15. package/dist/RampsController.mjs.map +1 -1
  16. package/dist/RampsService-method-action-types.cjs.map +1 -1
  17. package/dist/RampsService-method-action-types.d.cts.map +1 -1
  18. package/dist/RampsService-method-action-types.d.mts.map +1 -1
  19. package/dist/RampsService-method-action-types.mjs.map +1 -1
  20. package/dist/RampsService.cjs.map +1 -1
  21. package/dist/RampsService.d.cts.map +1 -1
  22. package/dist/RampsService.d.mts.map +1 -1
  23. package/dist/RampsService.mjs.map +1 -1
  24. package/dist/RequestCache.cjs.map +1 -1
  25. package/dist/RequestCache.d.cts.map +1 -1
  26. package/dist/RequestCache.d.mts.map +1 -1
  27. package/dist/RequestCache.mjs.map +1 -1
  28. package/dist/TransakService-method-action-types.cjs.map +1 -1
  29. package/dist/TransakService-method-action-types.d.cts +35 -1
  30. package/dist/TransakService-method-action-types.d.cts.map +1 -1
  31. package/dist/TransakService-method-action-types.d.mts +35 -1
  32. package/dist/TransakService-method-action-types.d.mts.map +1 -1
  33. package/dist/TransakService-method-action-types.mjs.map +1 -1
  34. package/dist/TransakService.cjs +128 -12
  35. package/dist/TransakService.cjs.map +1 -1
  36. package/dist/TransakService.d.cts +41 -3
  37. package/dist/TransakService.d.cts.map +1 -1
  38. package/dist/TransakService.d.mts +41 -3
  39. package/dist/TransakService.d.mts.map +1 -1
  40. package/dist/TransakService.mjs +123 -10
  41. package/dist/TransakService.mjs.map +1 -1
  42. package/dist/errorNormalization.cjs +84 -0
  43. package/dist/errorNormalization.cjs.map +1 -0
  44. package/dist/errorNormalization.d.cts +56 -0
  45. package/dist/errorNormalization.d.cts.map +1 -0
  46. package/dist/errorNormalization.d.mts +56 -0
  47. package/dist/errorNormalization.d.mts.map +1 -0
  48. package/dist/errorNormalization.mjs +78 -0
  49. package/dist/errorNormalization.mjs.map +1 -0
  50. package/dist/featureFlags.cjs +39 -0
  51. package/dist/featureFlags.cjs.map +1 -0
  52. package/dist/featureFlags.d.cts +40 -0
  53. package/dist/featureFlags.d.cts.map +1 -0
  54. package/dist/featureFlags.d.mts +40 -0
  55. package/dist/featureFlags.d.mts.map +1 -0
  56. package/dist/featureFlags.mjs +35 -0
  57. package/dist/featureFlags.mjs.map +1 -0
  58. package/dist/index.cjs +49 -33
  59. package/dist/index.cjs.map +1 -1
  60. package/dist/index.d.cts +8 -2
  61. package/dist/index.d.cts.map +1 -1
  62. package/dist/index.d.mts +8 -2
  63. package/dist/index.d.mts.map +1 -1
  64. package/dist/index.mjs +4 -0
  65. package/dist/index.mjs.map +1 -1
  66. package/dist/providerAvailability.cjs +103 -0
  67. package/dist/providerAvailability.cjs.map +1 -0
  68. package/dist/providerAvailability.d.cts +76 -0
  69. package/dist/providerAvailability.d.cts.map +1 -0
  70. package/dist/providerAvailability.d.mts +76 -0
  71. package/dist/providerAvailability.d.mts.map +1 -0
  72. package/dist/providerAvailability.mjs +96 -0
  73. package/dist/providerAvailability.mjs.map +1 -0
  74. package/dist/quoteClassification.cjs +44 -0
  75. package/dist/quoteClassification.cjs.map +1 -0
  76. package/dist/quoteClassification.d.cts +33 -0
  77. package/dist/quoteClassification.d.cts.map +1 -0
  78. package/dist/quoteClassification.d.mts +33 -0
  79. package/dist/quoteClassification.d.mts.map +1 -0
  80. package/dist/quoteClassification.mjs +38 -0
  81. package/dist/quoteClassification.mjs.map +1 -0
  82. package/dist/selectors.cjs +3 -3
  83. package/dist/selectors.cjs.map +1 -1
  84. package/dist/selectors.d.cts.map +1 -1
  85. package/dist/selectors.d.mts.map +1 -1
  86. package/dist/selectors.mjs.map +1 -1
  87. package/dist/transakApiErrorUtils.cjs +5 -5
  88. package/dist/transakApiErrorUtils.cjs.map +1 -1
  89. package/dist/transakApiErrorUtils.mjs.map +1 -1
  90. package/package.json +10 -7
@@ -10,14 +10,16 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
11
11
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
12
12
  };
13
- var _RampsController_instances, _RampsController_requestCacheTTL, _RampsController_requestCacheMaxSize, _RampsController_getProviderScope, _RampsController_getDefaultRedirectUrl, _RampsController_pendingRequests, _RampsController_pendingResourceCount, _RampsController_pendingResourceGeneration, _RampsController_orderPollingMeta, _RampsController_orderPollingTimer, _RampsController_isPolling, _RampsController_initPromise, _RampsController_clearPendingResourceCountForDependentResources, _RampsController_abortDependentRequests, _RampsController_mutateRequests, _RampsController_removeRequestState, _RampsController_cleanupState, _RampsController_requireRegion, _RampsController_isRegionCurrent, _RampsController_isTokenCurrent, _RampsController_isProviderCurrent, _RampsController_updateResourceField, _RampsController_setResourceLoading, _RampsController_setResourceError, _RampsController_updateRequestState, _RampsController_runInit, _RampsController_syncUserRegionFromCountriesCatalog, _RampsController_pickInAppQuote, _RampsController_getSupportingProvidersForRegion, _RampsController_filterProviderIdsBySupport, _RampsController_resolveProviderIdsForQuote, _RampsController_getPreferredProviderIdsFromOrders, _RampsController_refreshOrder, _RampsController_pollPendingOrders, _RampsController_syncTransakAuthOnError, _RampsController_getNormalizedTransakError;
13
+ var _RampsController_instances, _RampsController_requestCacheTTL, _RampsController_requestCacheMaxSize, _RampsController_getDefaultRedirectUrl, _RampsController_pendingRequests, _RampsController_pendingResourceCount, _RampsController_pendingResourceGeneration, _RampsController_orderPollingMeta, _RampsController_orderPollingTimer, _RampsController_isPolling, _RampsController_initPromise, _RampsController_clearPendingResourceCountForDependentResources, _RampsController_abortDependentRequests, _RampsController_isAllProvidersEnabled, _RampsController_mutateRequests, _RampsController_removeRequestState, _RampsController_cleanupState, _RampsController_requireRegion, _RampsController_isRegionCurrent, _RampsController_isTokenCurrent, _RampsController_isProviderCurrent, _RampsController_updateResourceField, _RampsController_setResourceLoading, _RampsController_setResourceError, _RampsController_updateRequestState, _RampsController_runInit, _RampsController_syncUserRegionFromCountriesCatalog, _RampsController_pickWidenedQuote, _RampsController_getSupportingProvidersForRegion, _RampsController_filterProviderIdsBySupport, _RampsController_resolveProviderIdsForQuote, _RampsController_getPreferredProviderIdsFromOrders, _RampsController_refreshOrder, _RampsController_pollPendingOrders, _RampsController_syncTransakAuthOnError, _RampsController_getNormalizedTransakError;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.RampsController = exports.getInternalOrderCode = exports.getDefaultRampsControllerState = exports.RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS = exports.controllerName = void 0;
16
16
  const base_controller_1 = require("@metamask/base-controller");
17
17
  const controller_utils_1 = require("@metamask/controller-utils");
18
- const rampsErrorCodes_1 = require("./rampsErrorCodes.cjs");
19
- const RampsService_1 = require("./RampsService.cjs");
20
- const RequestCache_1 = require("./RequestCache.cjs");
18
+ const featureFlags_js_1 = require("./featureFlags.cjs");
19
+ const providerAvailability_js_1 = require("./providerAvailability.cjs");
20
+ const rampsErrorCodes_js_1 = require("./rampsErrorCodes.cjs");
21
+ const RampsService_js_1 = require("./RampsService.cjs");
22
+ const RequestCache_js_1 = require("./RequestCache.cjs");
21
23
  // === GENERAL ===
22
24
  /**
23
25
  * The name of the {@link RampsController}, used to namespace the
@@ -55,6 +57,7 @@ exports.RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS = [
55
57
  'TransakService:getUserLimits',
56
58
  'TransakService:requestOtt',
57
59
  'TransakService:generatePaymentWidgetUrl',
60
+ 'TransakService:createWidgetUrl',
58
61
  'TransakService:submitPurposeOfUsageForm',
59
62
  'TransakService:patchUser',
60
63
  'TransakService:submitSsnDetails',
@@ -83,7 +86,7 @@ function hasHttpStatus(error) {
83
86
  function getRampsErrorInfo(error) {
84
87
  if (error instanceof controller_utils_1.BrokenCircuitError && hasStringMessage(error)) {
85
88
  return {
86
- errorKey: rampsErrorCodes_1.RAMPS_ERROR_CODES.CIRCUIT_BREAKER_OPEN,
89
+ errorKey: rampsErrorCodes_js_1.RAMPS_ERROR_CODES.CIRCUIT_BREAKER_OPEN,
87
90
  message: error.message,
88
91
  };
89
92
  }
@@ -96,7 +99,7 @@ function getRampsErrorInfo(error) {
96
99
  }
97
100
  if (rawMessage?.includes(CIRCUIT_BREAKER_OPEN_ERROR)) {
98
101
  return {
99
- errorKey: rampsErrorCodes_1.RAMPS_ERROR_CODES.CIRCUIT_BREAKER_OPEN,
102
+ errorKey: rampsErrorCodes_js_1.RAMPS_ERROR_CODES.CIRCUIT_BREAKER_OPEN,
100
103
  message: rawMessage,
101
104
  };
102
105
  }
@@ -352,16 +355,16 @@ function getInternalOrderCode(orderOrId) {
352
355
  exports.getInternalOrderCode = getInternalOrderCode;
353
356
  // === ORDER POLLING CONSTANTS ===
354
357
  const TERMINAL_ORDER_STATUSES = new Set([
355
- RampsService_1.RampsOrderStatus.Completed,
356
- RampsService_1.RampsOrderStatus.Failed,
357
- RampsService_1.RampsOrderStatus.Cancelled,
358
- RampsService_1.RampsOrderStatus.IdExpired,
358
+ RampsService_js_1.RampsOrderStatus.Completed,
359
+ RampsService_js_1.RampsOrderStatus.Failed,
360
+ RampsService_js_1.RampsOrderStatus.Cancelled,
361
+ RampsService_js_1.RampsOrderStatus.IdExpired,
359
362
  ]);
360
363
  const PENDING_ORDER_STATUSES = new Set([
361
- RampsService_1.RampsOrderStatus.Pending,
362
- RampsService_1.RampsOrderStatus.Created,
363
- RampsService_1.RampsOrderStatus.Unknown,
364
- RampsService_1.RampsOrderStatus.Precreated,
364
+ RampsService_js_1.RampsOrderStatus.Pending,
365
+ RampsService_js_1.RampsOrderStatus.Created,
366
+ RampsService_js_1.RampsOrderStatus.Unknown,
367
+ RampsService_js_1.RampsOrderStatus.Precreated,
365
368
  ]);
366
369
  const DEFAULT_POLLING_INTERVAL_MS = 30000;
367
370
  const MAX_ERROR_COUNT = 5;
@@ -405,6 +408,7 @@ const MESSENGER_EXPOSED_METHODS = [
405
408
  'transakGetUserLimits',
406
409
  'transakRequestOtt',
407
410
  'transakGeneratePaymentWidgetUrl',
411
+ 'transakCreateWidgetUrl',
408
412
  'transakSubmitPurposeOfUsageForm',
409
413
  'transakPatchUser',
410
414
  'transakSubmitSsnDetails',
@@ -437,13 +441,11 @@ class RampsController extends base_controller_1.BaseController {
437
441
  * controller. Missing properties will be filled in with defaults.
438
442
  * @param args.requestCacheTTL - Time to live for cached requests in milliseconds.
439
443
  * @param args.requestCacheMaxSize - Maximum number of entries in the request cache.
440
- * @param args.getProviderScope - Optional callback returning the current
441
- * provider-class scope for fiat quote widening. Defaults to `off`.
442
444
  * @param args.getDefaultRedirectUrl - Optional callback returning the default
443
- * redirect URL used for the widened in-app quote fetch when the caller omits
445
+ * redirect URL used for the widened quote fetch when the caller omits
444
446
  * `redirectUrl`. Defaults to a callback returning `undefined`.
445
447
  */
446
- constructor({ messenger, state = {}, requestCacheTTL = RequestCache_1.DEFAULT_REQUEST_CACHE_TTL, requestCacheMaxSize = RequestCache_1.DEFAULT_REQUEST_CACHE_MAX_SIZE, getProviderScope, getDefaultRedirectUrl, }) {
448
+ constructor({ messenger, state = {}, requestCacheTTL = RequestCache_js_1.DEFAULT_REQUEST_CACHE_TTL, requestCacheMaxSize = RequestCache_js_1.DEFAULT_REQUEST_CACHE_MAX_SIZE, getDefaultRedirectUrl, }) {
447
449
  super({
448
450
  messenger,
449
451
  metadata: rampsControllerMetadata,
@@ -465,12 +467,7 @@ class RampsController extends base_controller_1.BaseController {
465
467
  */
466
468
  _RampsController_requestCacheMaxSize.set(this, void 0);
467
469
  /**
468
- * Resolves the current provider-class scope for fiat quote widening. Defaults
469
- * to `() => 'off'` (native-only) when no callback is injected.
470
- */
471
- _RampsController_getProviderScope.set(this, void 0);
472
- /**
473
- * Resolves the default redirect URL for the widened in-app quote fetch when
470
+ * Resolves the default redirect URL for the widened quote fetch when
474
471
  * the caller omits `redirectUrl`. Defaults to `() => undefined` when no
475
472
  * callback is injected.
476
473
  */
@@ -496,7 +493,6 @@ class RampsController extends base_controller_1.BaseController {
496
493
  _RampsController_initPromise.set(this, null);
497
494
  __classPrivateFieldSet(this, _RampsController_requestCacheTTL, requestCacheTTL, "f");
498
495
  __classPrivateFieldSet(this, _RampsController_requestCacheMaxSize, requestCacheMaxSize, "f");
499
- __classPrivateFieldSet(this, _RampsController_getProviderScope, getProviderScope ?? (() => 'off'), "f");
500
496
  __classPrivateFieldSet(this, _RampsController_getDefaultRedirectUrl, getDefaultRedirectUrl ?? (() => undefined), "f");
501
497
  this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
502
498
  }
@@ -538,7 +534,7 @@ class RampsController extends base_controller_1.BaseController {
538
534
  // If cache is not expired, return the cached data
539
535
  if (!options?.forceRefresh) {
540
536
  const cached = this.state.requests[cacheKey];
541
- if (cached && !(0, RequestCache_1.isCacheExpired)(cached, ttl)) {
537
+ if (cached && !(0, RequestCache_js_1.isCacheExpired)(cached, ttl)) {
542
538
  return cached.data;
543
539
  }
544
540
  }
@@ -551,7 +547,7 @@ class RampsController extends base_controller_1.BaseController {
551
547
  ? (__classPrivateFieldGet(this, _RampsController_pendingResourceGeneration, "f").get(resourceType) ?? 0)
552
548
  : undefined;
553
549
  // Update state to loading
554
- __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_updateRequestState).call(this, cacheKey, (0, RequestCache_1.createLoadingState)());
550
+ __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_updateRequestState).call(this, cacheKey, (0, RequestCache_js_1.createLoadingState)());
555
551
  // Set resource-level loading state (only on cache miss). Ref-count so concurrent
556
552
  // requests for the same resource type (different cache keys) keep isLoading true.
557
553
  if (resourceType) {
@@ -568,7 +564,7 @@ class RampsController extends base_controller_1.BaseController {
568
564
  if (abortController.signal.aborted) {
569
565
  throw new Error('Request was aborted');
570
566
  }
571
- __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_updateRequestState).call(this, cacheKey, (0, RequestCache_1.createSuccessState)(data, lastFetchedAt));
567
+ __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_updateRequestState).call(this, cacheKey, (0, RequestCache_js_1.createSuccessState)(data, lastFetchedAt));
572
568
  if (resourceType) {
573
569
  const isCurrent = !options?.isResultCurrent || options.isResultCurrent();
574
570
  if (isCurrent) {
@@ -582,7 +578,7 @@ class RampsController extends base_controller_1.BaseController {
582
578
  throw error;
583
579
  }
584
580
  const { errorInfo, normalizedError } = getNormalizedRampsError(error);
585
- __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_updateRequestState).call(this, cacheKey, (0, RequestCache_1.createErrorState)(errorInfo.message, lastFetchedAt, errorInfo.errorKey));
581
+ __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_updateRequestState).call(this, cacheKey, (0, RequestCache_js_1.createErrorState)(errorInfo.message, lastFetchedAt, errorInfo.errorKey));
586
582
  if (resourceType) {
587
583
  const isCurrent = !options?.isResultCurrent || options.isResultCurrent();
588
584
  if (isCurrent) {
@@ -768,7 +764,7 @@ class RampsController extends base_controller_1.BaseController {
768
764
  * @returns An array of countries.
769
765
  */
770
766
  async getCountries(options) {
771
- const cacheKey = (0, RequestCache_1.createCacheKey)('getCountries', []);
767
+ const cacheKey = (0, RequestCache_js_1.createCacheKey)('getCountries', []);
772
768
  const countries = await this.executeRequest(cacheKey, async () => {
773
769
  return this.messenger.call('RampsService:getCountries');
774
770
  }, { ...options, resourceType: 'countries' });
@@ -791,7 +787,7 @@ class RampsController extends base_controller_1.BaseController {
791
787
  async getTokens(region, action = 'buy', options) {
792
788
  const regionToUse = region ?? __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_requireRegion).call(this);
793
789
  const normalizedRegion = regionToUse.toLowerCase().trim();
794
- const cacheKey = (0, RequestCache_1.createCacheKey)('getTokens', [
790
+ const cacheKey = (0, RequestCache_js_1.createCacheKey)('getTokens', [
795
791
  normalizedRegion,
796
792
  action,
797
793
  options?.provider,
@@ -856,7 +852,7 @@ class RampsController extends base_controller_1.BaseController {
856
852
  async getProviders(region, options) {
857
853
  const regionToUse = region ?? __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_requireRegion).call(this);
858
854
  const normalizedRegion = regionToUse.toLowerCase().trim();
859
- const cacheKey = (0, RequestCache_1.createCacheKey)('getProviders', [
855
+ const cacheKey = (0, RequestCache_js_1.createCacheKey)('getProviders', [
860
856
  normalizedRegion,
861
857
  options?.provider,
862
858
  options?.crypto,
@@ -896,7 +892,7 @@ class RampsController extends base_controller_1.BaseController {
896
892
  const assetIdToUse = options?.assetId ?? this.state.tokens.selected?.assetId ?? '';
897
893
  const providerToUse = options?.provider ?? this.state.providers.selected?.id ?? '';
898
894
  const normalizedRegion = regionCode.toLowerCase().trim();
899
- const cacheKey = (0, RequestCache_1.createCacheKey)('getPaymentMethods', [
895
+ const cacheKey = (0, RequestCache_js_1.createCacheKey)('getPaymentMethods', [
900
896
  normalizedRegion,
901
897
  assetIdToUse,
902
898
  providerToUse,
@@ -1012,19 +1008,17 @@ class RampsController extends base_controller_1.BaseController {
1012
1008
  if (normalizedAssetIdForValidation === '') {
1013
1009
  throw new Error('assetId is required.');
1014
1010
  }
1015
- // When a non-`off` provider scope is active, widen the native-only
1016
- // auto-selection path to every supporting provider and pick the best in-app
1017
- // quote from the results (in-app vs external is only knowable per-quote via
1018
- // `buyWidget.browser`). Only the auto-select/restrict path that MM Pay's
1011
+ // When the all-providers feature flag is enabled, widen the native-only
1012
+ // auto-selection path to every supporting provider and pick the best
1013
+ // quote from the results. Only the auto-select/restrict path that MM Pay's
1019
1014
  // `getRampsQuote` uses is affected; explicit-`providers` callers and the
1020
- // plain all-provider path are untouched.
1021
- const providerScope = __classPrivateFieldGet(this, _RampsController_getProviderScope, "f").call(this);
1022
- const widenToInAppProviders = providerScope !== 'off' &&
1023
- !options.providers &&
1015
+ // plain all-provider path are untouched (and never read the flag).
1016
+ const wantsAutoSelection = !options.providers &&
1024
1017
  (options.autoSelectProvider === true ||
1025
1018
  options.restrictToKnownOrNativeProviders === true);
1019
+ const widenToAllProviders = wantsAutoSelection && __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_isAllProvidersEnabled).call(this);
1026
1020
  let providersToUse;
1027
- let inAppProviderCatalog = this.state.providers.data;
1021
+ let widenedProviderCatalog = this.state.providers.data;
1028
1022
  if (options.providers) {
1029
1023
  providersToUse = options.restrictToKnownOrNativeProviders
1030
1024
  ? await __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_filterProviderIdsBySupport).call(this, {
@@ -1034,7 +1028,7 @@ class RampsController extends base_controller_1.BaseController {
1034
1028
  })
1035
1029
  : options.providers;
1036
1030
  }
1037
- else if (widenToInAppProviders) {
1031
+ else if (widenToAllProviders) {
1038
1032
  // `#getSupportingProvidersForRegion` also hydrates the provider catalog
1039
1033
  // when controller state is empty, so all-provider quoting cannot silently
1040
1034
  // return zero providers here.
@@ -1042,7 +1036,7 @@ class RampsController extends base_controller_1.BaseController {
1042
1036
  assetId: normalizedAssetIdForValidation,
1043
1037
  region: regionToUse,
1044
1038
  });
1045
- inAppProviderCatalog = supporting;
1039
+ widenedProviderCatalog = supporting;
1046
1040
  providersToUse = supporting.map((provider) => provider.id);
1047
1041
  }
1048
1042
  else if (options.autoSelectProvider ||
@@ -1074,12 +1068,12 @@ class RampsController extends base_controller_1.BaseController {
1074
1068
  // Under headless-buy gating, an empty resolved provider list means no
1075
1069
  // eligible (native/supporting) provider exists. Return an empty response
1076
1070
  // rather than passing `[]` to the service, which omits the provider filter
1077
- // and would quote every provider. This also guards the widened in-app path:
1071
+ // and would quote every provider. This also guards the widened path:
1078
1072
  // a caller may trigger widening with `autoSelectProvider` alone (no
1079
1073
  // `restrictToKnownOrNativeProviders`), and an empty supporting set must not
1080
1074
  // fall through to unfiltered quotes from providers that do not support the
1081
1075
  // asset.
1082
- if ((options.restrictToKnownOrNativeProviders || widenToInAppProviders) &&
1076
+ if ((options.restrictToKnownOrNativeProviders || widenToAllProviders) &&
1083
1077
  providersToUse.length === 0) {
1084
1078
  return { success: [], sorted: [], error: [], customActions: [] };
1085
1079
  }
@@ -1088,12 +1082,13 @@ class RampsController extends base_controller_1.BaseController {
1088
1082
  const normalizedAssetId = normalizedAssetIdForValidation;
1089
1083
  const normalizedWalletAddress = options.walletAddress.trim();
1090
1084
  // The quotes API only embeds a `buyURL`/`buyWidget` when a `redirectUrl` is
1091
- // present, so on the widened in-app path (where MM Pay omits one) supply the
1085
+ // present, so on the widened path (where MM Pay omits one) supply the
1092
1086
  // injected default so aggregator quotes carry a usable widget URL. An
1093
- // explicit caller `redirectUrl` always wins, and scope `off` never injects.
1087
+ // explicit caller `redirectUrl` always wins, and the native-only path
1088
+ // (flag off) never injects.
1094
1089
  const effectiveRedirectUrl = options.redirectUrl ??
1095
- (widenToInAppProviders ? __classPrivateFieldGet(this, _RampsController_getDefaultRedirectUrl, "f").call(this) : undefined);
1096
- const cacheKey = (0, RequestCache_1.createCacheKey)('getQuotes', [
1090
+ (widenToAllProviders ? __classPrivateFieldGet(this, _RampsController_getDefaultRedirectUrl, "f").call(this) : undefined);
1091
+ const cacheKey = (0, RequestCache_js_1.createCacheKey)('getQuotes', [
1097
1092
  normalizedRegion,
1098
1093
  normalizedFiat,
1099
1094
  normalizedAssetId,
@@ -1121,22 +1116,21 @@ class RampsController extends base_controller_1.BaseController {
1121
1116
  forceRefresh: options.forceRefresh,
1122
1117
  ttl: options.ttl ?? DEFAULT_QUOTES_TTL,
1123
1118
  });
1124
- if (!widenToInAppProviders) {
1119
+ if (!widenToAllProviders) {
1125
1120
  return response;
1126
1121
  }
1127
- // Reduce the widened multi-provider result to the single best in-app quote
1122
+ // Reduce the widened multi-provider result to the single best quote
1128
1123
  // and place it at `success[0]`, since single-pick consumers
1129
1124
  // (`getRampsQuote` -> `success?.[0]`) rely on index 0 while `success[]`
1130
1125
  // order is server-defined rather than ranked.
1131
- const selectedQuote = __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_pickInAppQuote).call(this, response, {
1132
- scope: providerScope,
1126
+ const selectedQuote = __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_pickWidenedQuote).call(this, response, {
1133
1127
  amount: options.amount,
1134
1128
  fiat: normalizedFiat,
1135
- providers: inAppProviderCatalog,
1129
+ providers: widenedProviderCatalog,
1136
1130
  });
1137
1131
  if (!selectedQuote) {
1138
- // No usable in-app quote: surface "no quote" rather than leaking an
1139
- // external/custom quote to the single-pick consumer.
1132
+ // No quote fits the published provider limits: surface "no quote"
1133
+ // rather than handing the single-pick consumer an out-of-limits quote.
1140
1134
  return {
1141
1135
  success: [],
1142
1136
  sorted: response.sorted,
@@ -1271,7 +1265,7 @@ class RampsController extends base_controller_1.BaseController {
1271
1265
  logos: { light: '', dark: '', height: 0, width: 0 },
1272
1266
  },
1273
1267
  walletAddress,
1274
- status: RampsService_1.RampsOrderStatus.Precreated,
1268
+ status: RampsService_js_1.RampsOrderStatus.Precreated,
1275
1269
  orderType: 'buy',
1276
1270
  createdAt: Date.now(),
1277
1271
  isOnlyLink: false,
@@ -1629,6 +1623,25 @@ class RampsController extends base_controller_1.BaseController {
1629
1623
  transakGeneratePaymentWidgetUrl(ottToken, quote, walletAddress, extraParams) {
1630
1624
  return this.messenger.call('TransakService:generatePaymentWidgetUrl', ottToken, quote, walletAddress, extraParams);
1631
1625
  }
1626
+ /**
1627
+ * Creates a Transak payment widget URL via the ramps API proxy, which
1628
+ * injects the partner API key server-side. Replaces the OTT flow
1629
+ * ({@link transakRequestOtt} + {@link transakGeneratePaymentWidgetUrl}).
1630
+ *
1631
+ * @param quote - The buy quote to pre-fill in the widget.
1632
+ * @param walletAddress - The destination wallet address.
1633
+ * @param extraParams - Optional additional widget parameters (e.g. theming).
1634
+ * @returns The single-use widget URL.
1635
+ */
1636
+ async transakCreateWidgetUrl(quote, walletAddress, extraParams) {
1637
+ try {
1638
+ return await this.messenger.call('TransakService:createWidgetUrl', quote, walletAddress, extraParams);
1639
+ }
1640
+ catch (error) {
1641
+ throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
1642
+ .normalizedError;
1643
+ }
1644
+ }
1632
1645
  /**
1633
1646
  * Submits the user's purpose of usage form for KYC compliance.
1634
1647
  *
@@ -1766,7 +1779,7 @@ class RampsController extends base_controller_1.BaseController {
1766
1779
  }
1767
1780
  }
1768
1781
  exports.RampsController = RampsController;
1769
- _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheMaxSize = new WeakMap(), _RampsController_getProviderScope = new WeakMap(), _RampsController_getDefaultRedirectUrl = new WeakMap(), _RampsController_pendingRequests = new WeakMap(), _RampsController_pendingResourceCount = new WeakMap(), _RampsController_pendingResourceGeneration = new WeakMap(), _RampsController_orderPollingMeta = new WeakMap(), _RampsController_orderPollingTimer = new WeakMap(), _RampsController_isPolling = new WeakMap(), _RampsController_initPromise = new WeakMap(), _RampsController_instances = new WeakSet(), _RampsController_clearPendingResourceCountForDependentResources = function _RampsController_clearPendingResourceCountForDependentResources() {
1782
+ _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheMaxSize = new WeakMap(), _RampsController_getDefaultRedirectUrl = new WeakMap(), _RampsController_pendingRequests = new WeakMap(), _RampsController_pendingResourceCount = new WeakMap(), _RampsController_pendingResourceGeneration = new WeakMap(), _RampsController_orderPollingMeta = new WeakMap(), _RampsController_orderPollingTimer = new WeakMap(), _RampsController_isPolling = new WeakMap(), _RampsController_initPromise = new WeakMap(), _RampsController_instances = new WeakSet(), _RampsController_clearPendingResourceCountForDependentResources = function _RampsController_clearPendingResourceCountForDependentResources() {
1770
1783
  for (const resourceType of DEPENDENT_RESOURCE_KEYS) {
1771
1784
  __classPrivateFieldGet(this, _RampsController_pendingResourceCount, "f").delete(resourceType);
1772
1785
  const generation = __classPrivateFieldGet(this, _RampsController_pendingResourceGeneration, "f").get(resourceType) ?? 0;
@@ -1781,6 +1794,14 @@ _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheM
1781
1794
  __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_removeRequestState).call(this, cacheKey);
1782
1795
  }
1783
1796
  }
1797
+ }, _RampsController_isAllProvidersEnabled = function _RampsController_isAllProvidersEnabled() {
1798
+ try {
1799
+ const remoteFeatureFlagState = this.messenger.call('RemoteFeatureFlagController:getState');
1800
+ return (0, featureFlags_js_1.isHeadlessAllProvidersEnabled)(remoteFeatureFlagState);
1801
+ }
1802
+ catch {
1803
+ return false;
1804
+ }
1784
1805
  }, _RampsController_mutateRequests = function _RampsController_mutateRequests(fn) {
1785
1806
  this.update((state) => {
1786
1807
  const requests = state.requests;
@@ -1830,8 +1851,8 @@ _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheM
1830
1851
  const keys = Object.keys(requests);
1831
1852
  for (const key of keys) {
1832
1853
  const entry = requests[key];
1833
- if (entry?.status === RequestCache_1.RequestStatus.SUCCESS &&
1834
- (0, RequestCache_1.isCacheExpired)(entry, ttl)) {
1854
+ if (entry?.status === RequestCache_js_1.RequestStatus.SUCCESS &&
1855
+ (0, RequestCache_js_1.isCacheExpired)(entry, ttl)) {
1835
1856
  delete requests[key];
1836
1857
  }
1837
1858
  }
@@ -1892,9 +1913,8 @@ _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheM
1892
1913
  this.update((state) => {
1893
1914
  state.userRegion = userRegion;
1894
1915
  });
1895
- }, _RampsController_pickInAppQuote = function _RampsController_pickInAppQuote(response, { scope, amount, fiat, providers, }) {
1916
+ }, _RampsController_pickWidenedQuote = function _RampsController_pickWidenedQuote(response, { amount, fiat, providers, }) {
1896
1917
  const providerByCode = new Map(providers.map((provider) => [provider.id, provider]));
1897
- const customActionProviderCodes = new Set(response.customActions.map((action) => action.buy.providerId));
1898
1918
  const fitsProviderLimits = (quote) => {
1899
1919
  const provider = providerByCode.get(quote.provider);
1900
1920
  const limit = provider?.limits?.fiat?.[fiat]?.[quote.quote.paymentMethod];
@@ -1905,26 +1925,7 @@ _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheM
1905
1925
  }
1906
1926
  return amount >= limit.minAmount && amount <= limit.maxAmount;
1907
1927
  };
1908
- const isEligible = (quote) => {
1909
- // `all` (Phase 2) skips the in-app-only exclusions; both scopes still
1910
- // enforce provider limits up front.
1911
- if (scope !== 'all') {
1912
- const providerCode = quote.provider;
1913
- if (customActionProviderCodes.has(providerCode)) {
1914
- return false;
1915
- }
1916
- // Defensive: the wire may carry an inline `isCustomAction` flag that is
1917
- // absent from the published `Quote` type.
1918
- if (quote.quote.isCustomAction === true) {
1919
- return false;
1920
- }
1921
- if (quote.quote.buyWidget?.browser === 'IN_APP_OS_BROWSER') {
1922
- return false;
1923
- }
1924
- }
1925
- return fitsProviderLimits(quote);
1926
- };
1927
- const candidates = response.success.filter(isEligible);
1928
+ const candidates = response.success.filter(fitsProviderLimits);
1928
1929
  if (candidates.length === 0) {
1929
1930
  return undefined;
1930
1931
  }
@@ -1969,18 +1970,10 @@ async function _RampsController_getSupportingProvidersForRegion({ assetId, regio
1969
1970
  else {
1970
1971
  ({ providers } = await this.getProviders(normalizedRegion));
1971
1972
  }
1972
- // EVM CAIP-19 asset IDs may arrive checksummed or lowercased, and the
1973
- // providers API returns both forms, so match case-insensitively on both
1974
- // sides. Only the lowercased forms are compared (the original IDs are never
1975
- // returned), so case-sensitive non-EVM asset IDs are not corrupted.
1976
- const normalizedAssetId = assetId.toLowerCase();
1977
- const supporting = providers.filter((provider) => {
1978
- const map = provider?.supportedCryptoCurrencies;
1979
- if (!map) {
1980
- return false;
1981
- }
1982
- return Object.keys(map).some((key) => key.toLowerCase() === normalizedAssetId);
1983
- });
1973
+ // Case-insensitive CAIP-19 matching is shared with headless-buy consumers
1974
+ // via `getProvidersServingAsset`, so the controller and the UI region gate
1975
+ // cannot disagree about which providers serve the asset.
1976
+ const supporting = (0, providerAvailability_js_1.getProvidersServingAsset)(providers, assetId);
1984
1977
  return { supporting, all: providers };
1985
1978
  }, _RampsController_filterProviderIdsBySupport =
1986
1979
  /**
@@ -2073,7 +2066,7 @@ async function _RampsController_resolveProviderIdsForQuote({ assetId, region, pr
2073
2066
  }, _RampsController_getPreferredProviderIdsFromOrders = function _RampsController_getPreferredProviderIdsFromOrders() {
2074
2067
  const orderedIds = [];
2075
2068
  const completedOrders = this.state.orders
2076
- .filter((order) => order.status === RampsService_1.RampsOrderStatus.Completed && order.provider?.id)
2069
+ .filter((order) => order.status === RampsService_js_1.RampsOrderStatus.Completed && order.provider?.id)
2077
2070
  .sort((orderA, orderB) => orderB.createdAt - orderA.createdAt);
2078
2071
  for (const order of completedOrders) {
2079
2072
  const id = order.provider?.id;
@@ -2101,7 +2094,7 @@ async function _RampsController_refreshOrder(order) {
2101
2094
  lastTimeFetched: 0,
2102
2095
  errorCount: 0,
2103
2096
  };
2104
- if (updatedOrder.status === RampsService_1.RampsOrderStatus.Unknown) {
2097
+ if (updatedOrder.status === RampsService_js_1.RampsOrderStatus.Unknown) {
2105
2098
  meta.errorCount = Math.min(meta.errorCount + 1, MAX_ERROR_COUNT);
2106
2099
  }
2107
2100
  else {