You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@metamask/ramps-controller

Package Overview
Dependencies
Maintainers
3
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metamask/ramps-controller - npm Package Compare versions

Comparing version
7.1.0
to
8.0.0
+9
-1
CHANGELOG.md

@@ -10,2 +10,9 @@ # Changelog

## [8.0.0]
### Changed
- **BREAKING:** Quote filter param renamed from `provider` to `providers` array in `getQuotes()` and `RampsService.getQuotes()` ([#7892](https://github.com/MetaMask/core/pull/7892))
- **BREAKING:** Make `getWidgetUrl()` async to fetch the actual provider widget URL from the `buyURL` endpoint ([#7881](https://github.com/MetaMask/core/pull/7881))
## [7.1.0]

@@ -138,3 +145,4 @@

[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/ramps-controller@7.1.0...HEAD
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/ramps-controller@8.0.0...HEAD
[8.0.0]: https://github.com/MetaMask/core/compare/@metamask/ramps-controller@7.1.0...@metamask/ramps-controller@8.0.0
[7.1.0]: https://github.com/MetaMask/core/compare/@metamask/ramps-controller@7.0.0...@metamask/ramps-controller@7.1.0

@@ -141,0 +149,0 @@ [7.0.0]: https://github.com/MetaMask/core/compare/@metamask/ramps-controller@6.0.0...@metamask/ramps-controller@7.0.0

+1
-1

@@ -1,1 +0,1 @@

{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAWA,yDAI2B;AAHzB,kHAAA,eAAe,OAAA;AACf,iIAAA,8BAA8B,OAAA;AAC9B,4IAAA,yCAAyC,OAAA;AA2B3C,mDAKwB;AAJtB,4GAAA,YAAY,OAAA;AACZ,gHAAA,gBAAgB,OAAA;AAChB,+GAAA,eAAe,OAAA;AACf,iHAAA,iBAAiB,OAAA;AAenB,mDASwB;AARtB,6GAAA,aAAa,OAAA;AACb,yHAAA,yBAAyB,OAAA;AACzB,8HAAA,8BAA8B,OAAA;AAC9B,8GAAA,cAAc,OAAA;AACd,8GAAA,cAAc,OAAA;AACd,kHAAA,kBAAkB,OAAA;AAClB,kHAAA,kBAAkB,OAAA;AAClB,gHAAA,gBAAgB,OAAA;AAGlB,6CAAoD;AAA3C,kHAAA,qBAAqB,OAAA","sourcesContent":["export type {\n RampsControllerActions,\n RampsControllerEvents,\n RampsControllerGetStateAction,\n RampsControllerMessenger,\n RampsControllerState,\n RampsControllerStateChangeEvent,\n RampsControllerOptions,\n UserRegion,\n ResourceState,\n} from './RampsController';\nexport {\n RampsController,\n getDefaultRampsControllerState,\n RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS,\n} from './RampsController';\nexport type {\n RampsServiceActions,\n RampsServiceEvents,\n RampsServiceMessenger,\n Country,\n State,\n SupportedActions,\n CountryPhone,\n Provider,\n ProviderLink,\n ProviderLogos,\n RampAction,\n PaymentMethod,\n PaymentMethodsResponse,\n Quote,\n QuoteError,\n QuoteSortBy,\n QuoteSortOrder,\n QuoteCryptoTranslation,\n QuoteCustomAction,\n QuotesResponse,\n GetQuotesParams,\n RampsToken,\n TokensResponse,\n} from './RampsService';\nexport {\n RampsService,\n RampsEnvironment,\n RampsApiService,\n RAMPS_SDK_VERSION,\n} from './RampsService';\nexport type {\n RampsServiceGetGeolocationAction,\n RampsServiceGetCountriesAction,\n RampsServiceGetPaymentMethodsAction,\n RampsServiceGetQuotesAction,\n} from './RampsService-method-action-types';\nexport type {\n RequestCache,\n RequestState,\n ExecuteRequestOptions,\n PendingRequest,\n ResourceType,\n} from './RequestCache';\nexport {\n RequestStatus,\n DEFAULT_REQUEST_CACHE_TTL,\n DEFAULT_REQUEST_CACHE_MAX_SIZE,\n createCacheKey,\n isCacheExpired,\n createLoadingState,\n createSuccessState,\n createErrorState,\n} from './RequestCache';\nexport type { RequestSelectorResult } from './selectors';\nexport { createRequestSelector } from './selectors';\n"]}
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAWA,yDAI2B;AAHzB,kHAAA,eAAe,OAAA;AACf,iIAAA,8BAA8B,OAAA;AAC9B,4IAAA,yCAAyC,OAAA;AA6B3C,mDAKwB;AAJtB,4GAAA,YAAY,OAAA;AACZ,gHAAA,gBAAgB,OAAA;AAChB,+GAAA,eAAe,OAAA;AACf,iHAAA,iBAAiB,OAAA;AAgBnB,mDASwB;AARtB,6GAAA,aAAa,OAAA;AACb,yHAAA,yBAAyB,OAAA;AACzB,8HAAA,8BAA8B,OAAA;AAC9B,8GAAA,cAAc,OAAA;AACd,8GAAA,cAAc,OAAA;AACd,kHAAA,kBAAkB,OAAA;AAClB,kHAAA,kBAAkB,OAAA;AAClB,gHAAA,gBAAgB,OAAA;AAGlB,6CAAoD;AAA3C,kHAAA,qBAAqB,OAAA","sourcesContent":["export type {\n RampsControllerActions,\n RampsControllerEvents,\n RampsControllerGetStateAction,\n RampsControllerMessenger,\n RampsControllerState,\n RampsControllerStateChangeEvent,\n RampsControllerOptions,\n UserRegion,\n ResourceState,\n} from './RampsController';\nexport {\n RampsController,\n getDefaultRampsControllerState,\n RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS,\n} from './RampsController';\nexport type {\n RampsServiceActions,\n RampsServiceEvents,\n RampsServiceMessenger,\n Country,\n State,\n SupportedActions,\n CountryPhone,\n Provider,\n ProviderLink,\n ProviderLogos,\n ProviderBrowserType,\n RampAction,\n PaymentMethod,\n PaymentMethodsResponse,\n Quote,\n QuoteError,\n QuoteSortBy,\n QuoteSortOrder,\n QuoteCryptoTranslation,\n QuoteCustomAction,\n QuotesResponse,\n GetQuotesParams,\n RampsToken,\n TokensResponse,\n BuyWidget,\n} from './RampsService';\nexport {\n RampsService,\n RampsEnvironment,\n RampsApiService,\n RAMPS_SDK_VERSION,\n} from './RampsService';\nexport type {\n RampsServiceGetGeolocationAction,\n RampsServiceGetCountriesAction,\n RampsServiceGetPaymentMethodsAction,\n RampsServiceGetQuotesAction,\n RampsServiceGetBuyWidgetUrlAction,\n} from './RampsService-method-action-types';\nexport type {\n RequestCache,\n RequestState,\n ExecuteRequestOptions,\n PendingRequest,\n ResourceType,\n} from './RequestCache';\nexport {\n RequestStatus,\n DEFAULT_REQUEST_CACHE_TTL,\n DEFAULT_REQUEST_CACHE_MAX_SIZE,\n createCacheKey,\n isCacheExpired,\n createLoadingState,\n createSuccessState,\n createErrorState,\n} from './RequestCache';\nexport type { RequestSelectorResult } from './selectors';\nexport { createRequestSelector } from './selectors';\n"]}
export type { RampsControllerActions, RampsControllerEvents, RampsControllerGetStateAction, RampsControllerMessenger, RampsControllerState, RampsControllerStateChangeEvent, RampsControllerOptions, UserRegion, ResourceState, } from "./RampsController.cjs";
export { RampsController, getDefaultRampsControllerState, RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS, } from "./RampsController.cjs";
export type { RampsServiceActions, RampsServiceEvents, RampsServiceMessenger, Country, State, SupportedActions, CountryPhone, Provider, ProviderLink, ProviderLogos, RampAction, PaymentMethod, PaymentMethodsResponse, Quote, QuoteError, QuoteSortBy, QuoteSortOrder, QuoteCryptoTranslation, QuoteCustomAction, QuotesResponse, GetQuotesParams, RampsToken, TokensResponse, } from "./RampsService.cjs";
export type { RampsServiceActions, RampsServiceEvents, RampsServiceMessenger, Country, State, SupportedActions, CountryPhone, Provider, ProviderLink, ProviderLogos, ProviderBrowserType, RampAction, PaymentMethod, PaymentMethodsResponse, Quote, QuoteError, QuoteSortBy, QuoteSortOrder, QuoteCryptoTranslation, QuoteCustomAction, QuotesResponse, GetQuotesParams, RampsToken, TokensResponse, BuyWidget, } from "./RampsService.cjs";
export { RampsService, RampsEnvironment, RampsApiService, RAMPS_SDK_VERSION, } from "./RampsService.cjs";
export type { RampsServiceGetGeolocationAction, RampsServiceGetCountriesAction, RampsServiceGetPaymentMethodsAction, RampsServiceGetQuotesAction, } from "./RampsService-method-action-types.cjs";
export type { RampsServiceGetGeolocationAction, RampsServiceGetCountriesAction, RampsServiceGetPaymentMethodsAction, RampsServiceGetQuotesAction, RampsServiceGetBuyWidgetUrlAction, } from "./RampsService-method-action-types.cjs";
export type { RequestCache, RequestState, ExecuteRequestOptions, PendingRequest, ResourceType, } from "./RequestCache.cjs";

@@ -7,0 +7,0 @@ export { RequestStatus, DEFAULT_REQUEST_CACHE_TTL, DEFAULT_REQUEST_CACHE_MAX_SIZE, createCacheKey, isCacheExpired, createLoadingState, createSuccessState, createErrorState, } from "./RequestCache.cjs";

@@ -1,1 +0,1 @@

{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,6BAA6B,EAC7B,wBAAwB,EACxB,oBAAoB,EACpB,+BAA+B,EAC/B,sBAAsB,EACtB,UAAU,EACV,aAAa,GACd,8BAA0B;AAC3B,OAAO,EACL,eAAe,EACf,8BAA8B,EAC9B,yCAAyC,GAC1C,8BAA0B;AAC3B,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,OAAO,EACP,KAAK,EACL,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,UAAU,EACV,aAAa,EACb,sBAAsB,EACtB,KAAK,EACL,UAAU,EACV,WAAW,EACX,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,UAAU,EACV,cAAc,GACf,2BAAuB;AACxB,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GAClB,2BAAuB;AACxB,YAAY,EACV,gCAAgC,EAChC,8BAA8B,EAC9B,mCAAmC,EACnC,2BAA2B,GAC5B,+CAA2C;AAC5C,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,YAAY,GACb,2BAAuB;AACxB,OAAO,EACL,aAAa,EACb,yBAAyB,EACzB,8BAA8B,EAC9B,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,GACjB,2BAAuB;AACxB,YAAY,EAAE,qBAAqB,EAAE,wBAAoB;AACzD,OAAO,EAAE,qBAAqB,EAAE,wBAAoB"}
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,6BAA6B,EAC7B,wBAAwB,EACxB,oBAAoB,EACpB,+BAA+B,EAC/B,sBAAsB,EACtB,UAAU,EACV,aAAa,GACd,8BAA0B;AAC3B,OAAO,EACL,eAAe,EACf,8BAA8B,EAC9B,yCAAyC,GAC1C,8BAA0B;AAC3B,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,OAAO,EACP,KAAK,EACL,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,UAAU,EACV,aAAa,EACb,sBAAsB,EACtB,KAAK,EACL,UAAU,EACV,WAAW,EACX,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,UAAU,EACV,cAAc,EACd,SAAS,GACV,2BAAuB;AACxB,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GAClB,2BAAuB;AACxB,YAAY,EACV,gCAAgC,EAChC,8BAA8B,EAC9B,mCAAmC,EACnC,2BAA2B,EAC3B,iCAAiC,GAClC,+CAA2C;AAC5C,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,YAAY,GACb,2BAAuB;AACxB,OAAO,EACL,aAAa,EACb,yBAAyB,EACzB,8BAA8B,EAC9B,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,GACjB,2BAAuB;AACxB,YAAY,EAAE,qBAAqB,EAAE,wBAAoB;AACzD,OAAO,EAAE,qBAAqB,EAAE,wBAAoB"}
export type { RampsControllerActions, RampsControllerEvents, RampsControllerGetStateAction, RampsControllerMessenger, RampsControllerState, RampsControllerStateChangeEvent, RampsControllerOptions, UserRegion, ResourceState, } from "./RampsController.mjs";
export { RampsController, getDefaultRampsControllerState, RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS, } from "./RampsController.mjs";
export type { RampsServiceActions, RampsServiceEvents, RampsServiceMessenger, Country, State, SupportedActions, CountryPhone, Provider, ProviderLink, ProviderLogos, RampAction, PaymentMethod, PaymentMethodsResponse, Quote, QuoteError, QuoteSortBy, QuoteSortOrder, QuoteCryptoTranslation, QuoteCustomAction, QuotesResponse, GetQuotesParams, RampsToken, TokensResponse, } from "./RampsService.mjs";
export type { RampsServiceActions, RampsServiceEvents, RampsServiceMessenger, Country, State, SupportedActions, CountryPhone, Provider, ProviderLink, ProviderLogos, ProviderBrowserType, RampAction, PaymentMethod, PaymentMethodsResponse, Quote, QuoteError, QuoteSortBy, QuoteSortOrder, QuoteCryptoTranslation, QuoteCustomAction, QuotesResponse, GetQuotesParams, RampsToken, TokensResponse, BuyWidget, } from "./RampsService.mjs";
export { RampsService, RampsEnvironment, RampsApiService, RAMPS_SDK_VERSION, } from "./RampsService.mjs";
export type { RampsServiceGetGeolocationAction, RampsServiceGetCountriesAction, RampsServiceGetPaymentMethodsAction, RampsServiceGetQuotesAction, } from "./RampsService-method-action-types.mjs";
export type { RampsServiceGetGeolocationAction, RampsServiceGetCountriesAction, RampsServiceGetPaymentMethodsAction, RampsServiceGetQuotesAction, RampsServiceGetBuyWidgetUrlAction, } from "./RampsService-method-action-types.mjs";
export type { RequestCache, RequestState, ExecuteRequestOptions, PendingRequest, ResourceType, } from "./RequestCache.mjs";

@@ -7,0 +7,0 @@ export { RequestStatus, DEFAULT_REQUEST_CACHE_TTL, DEFAULT_REQUEST_CACHE_MAX_SIZE, createCacheKey, isCacheExpired, createLoadingState, createSuccessState, createErrorState, } from "./RequestCache.mjs";

@@ -1,1 +0,1 @@

{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,6BAA6B,EAC7B,wBAAwB,EACxB,oBAAoB,EACpB,+BAA+B,EAC/B,sBAAsB,EACtB,UAAU,EACV,aAAa,GACd,8BAA0B;AAC3B,OAAO,EACL,eAAe,EACf,8BAA8B,EAC9B,yCAAyC,GAC1C,8BAA0B;AAC3B,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,OAAO,EACP,KAAK,EACL,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,UAAU,EACV,aAAa,EACb,sBAAsB,EACtB,KAAK,EACL,UAAU,EACV,WAAW,EACX,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,UAAU,EACV,cAAc,GACf,2BAAuB;AACxB,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GAClB,2BAAuB;AACxB,YAAY,EACV,gCAAgC,EAChC,8BAA8B,EAC9B,mCAAmC,EACnC,2BAA2B,GAC5B,+CAA2C;AAC5C,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,YAAY,GACb,2BAAuB;AACxB,OAAO,EACL,aAAa,EACb,yBAAyB,EACzB,8BAA8B,EAC9B,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,GACjB,2BAAuB;AACxB,YAAY,EAAE,qBAAqB,EAAE,wBAAoB;AACzD,OAAO,EAAE,qBAAqB,EAAE,wBAAoB"}
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,6BAA6B,EAC7B,wBAAwB,EACxB,oBAAoB,EACpB,+BAA+B,EAC/B,sBAAsB,EACtB,UAAU,EACV,aAAa,GACd,8BAA0B;AAC3B,OAAO,EACL,eAAe,EACf,8BAA8B,EAC9B,yCAAyC,GAC1C,8BAA0B;AAC3B,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,OAAO,EACP,KAAK,EACL,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,UAAU,EACV,aAAa,EACb,sBAAsB,EACtB,KAAK,EACL,UAAU,EACV,WAAW,EACX,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,UAAU,EACV,cAAc,EACd,SAAS,GACV,2BAAuB;AACxB,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GAClB,2BAAuB;AACxB,YAAY,EACV,gCAAgC,EAChC,8BAA8B,EAC9B,mCAAmC,EACnC,2BAA2B,EAC3B,iCAAiC,GAClC,+CAA2C;AAC5C,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,YAAY,GACb,2BAAuB;AACxB,OAAO,EACL,aAAa,EACb,yBAAyB,EACzB,8BAA8B,EAC9B,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,GACjB,2BAAuB;AACxB,YAAY,EAAE,qBAAqB,EAAE,wBAAoB;AACzD,OAAO,EAAE,qBAAqB,EAAE,wBAAoB"}

@@ -1,1 +0,1 @@

{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,eAAe,EACf,8BAA8B,EAC9B,yCAAyC,EAC1C,8BAA0B;AA0B3B,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EAClB,2BAAuB;AAcxB,OAAO,EACL,aAAa,EACb,yBAAyB,EACzB,8BAA8B,EAC9B,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EACjB,2BAAuB;AAExB,OAAO,EAAE,qBAAqB,EAAE,wBAAoB","sourcesContent":["export type {\n RampsControllerActions,\n RampsControllerEvents,\n RampsControllerGetStateAction,\n RampsControllerMessenger,\n RampsControllerState,\n RampsControllerStateChangeEvent,\n RampsControllerOptions,\n UserRegion,\n ResourceState,\n} from './RampsController';\nexport {\n RampsController,\n getDefaultRampsControllerState,\n RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS,\n} from './RampsController';\nexport type {\n RampsServiceActions,\n RampsServiceEvents,\n RampsServiceMessenger,\n Country,\n State,\n SupportedActions,\n CountryPhone,\n Provider,\n ProviderLink,\n ProviderLogos,\n RampAction,\n PaymentMethod,\n PaymentMethodsResponse,\n Quote,\n QuoteError,\n QuoteSortBy,\n QuoteSortOrder,\n QuoteCryptoTranslation,\n QuoteCustomAction,\n QuotesResponse,\n GetQuotesParams,\n RampsToken,\n TokensResponse,\n} from './RampsService';\nexport {\n RampsService,\n RampsEnvironment,\n RampsApiService,\n RAMPS_SDK_VERSION,\n} from './RampsService';\nexport type {\n RampsServiceGetGeolocationAction,\n RampsServiceGetCountriesAction,\n RampsServiceGetPaymentMethodsAction,\n RampsServiceGetQuotesAction,\n} from './RampsService-method-action-types';\nexport type {\n RequestCache,\n RequestState,\n ExecuteRequestOptions,\n PendingRequest,\n ResourceType,\n} from './RequestCache';\nexport {\n RequestStatus,\n DEFAULT_REQUEST_CACHE_TTL,\n DEFAULT_REQUEST_CACHE_MAX_SIZE,\n createCacheKey,\n isCacheExpired,\n createLoadingState,\n createSuccessState,\n createErrorState,\n} from './RequestCache';\nexport type { RequestSelectorResult } from './selectors';\nexport { createRequestSelector } from './selectors';\n"]}
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,eAAe,EACf,8BAA8B,EAC9B,yCAAyC,EAC1C,8BAA0B;AA4B3B,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EAClB,2BAAuB;AAexB,OAAO,EACL,aAAa,EACb,yBAAyB,EACzB,8BAA8B,EAC9B,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EACjB,2BAAuB;AAExB,OAAO,EAAE,qBAAqB,EAAE,wBAAoB","sourcesContent":["export type {\n RampsControllerActions,\n RampsControllerEvents,\n RampsControllerGetStateAction,\n RampsControllerMessenger,\n RampsControllerState,\n RampsControllerStateChangeEvent,\n RampsControllerOptions,\n UserRegion,\n ResourceState,\n} from './RampsController';\nexport {\n RampsController,\n getDefaultRampsControllerState,\n RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS,\n} from './RampsController';\nexport type {\n RampsServiceActions,\n RampsServiceEvents,\n RampsServiceMessenger,\n Country,\n State,\n SupportedActions,\n CountryPhone,\n Provider,\n ProviderLink,\n ProviderLogos,\n ProviderBrowserType,\n RampAction,\n PaymentMethod,\n PaymentMethodsResponse,\n Quote,\n QuoteError,\n QuoteSortBy,\n QuoteSortOrder,\n QuoteCryptoTranslation,\n QuoteCustomAction,\n QuotesResponse,\n GetQuotesParams,\n RampsToken,\n TokensResponse,\n BuyWidget,\n} from './RampsService';\nexport {\n RampsService,\n RampsEnvironment,\n RampsApiService,\n RAMPS_SDK_VERSION,\n} from './RampsService';\nexport type {\n RampsServiceGetGeolocationAction,\n RampsServiceGetCountriesAction,\n RampsServiceGetPaymentMethodsAction,\n RampsServiceGetQuotesAction,\n RampsServiceGetBuyWidgetUrlAction,\n} from './RampsService-method-action-types';\nexport type {\n RequestCache,\n RequestState,\n ExecuteRequestOptions,\n PendingRequest,\n ResourceType,\n} from './RequestCache';\nexport {\n RequestStatus,\n DEFAULT_REQUEST_CACHE_TTL,\n DEFAULT_REQUEST_CACHE_MAX_SIZE,\n createCacheKey,\n isCacheExpired,\n createLoadingState,\n createSuccessState,\n createErrorState,\n} from './RequestCache';\nexport type { RequestSelectorResult } from './selectors';\nexport { createRequestSelector } from './selectors';\n"]}

@@ -37,2 +37,3 @@ "use strict";

'RampsService:getQuotes',
'RampsService:getBuyWidgetUrl',
];

@@ -778,3 +779,3 @@ /**

* @param options.paymentMethods - Array of payment method IDs. If not provided, uses paymentMethods from state.
* @param options.provider - Optional provider ID to filter quotes.
* @param options.providers - Optional provider IDs to filter quotes.
* @param options.redirectUrl - Optional redirect URL after order completion.

@@ -791,3 +792,6 @@ * @param options.action - The ramp action type. Defaults to 'buy'.

this.state.paymentMethods.data.map((pm) => pm.id);
const providersToUse = options.providers ??
this.state.providers.data.map((provider) => provider.id);
const action = options.action ?? 'buy';
const assetIdToUse = options.assetId ?? this.state.tokens.selected?.assetId;
if (!regionToUse) {

@@ -799,3 +803,9 @@ throw new Error('Region is required. Either provide a region parameter or ensure userRegion is set in controller state.');

}
if (!paymentMethodsToUse || paymentMethodsToUse.length === 0) {
const normalizedAssetIdForValidation = (assetIdToUse ?? '').trim();
if (normalizedAssetIdForValidation === '') {
throw new Error('assetId is required.');
}
if (!paymentMethodsToUse ||
paymentMethodsToUse.length === 0 ||
paymentMethodsToUse.some((pm) => pm.trim() === '')) {
throw new Error('Payment methods are required. Either provide paymentMethods parameter or ensure paymentMethods are set in controller state.');

@@ -806,5 +816,2 @@ }

}
if (!options.assetId || options.assetId.trim() === '') {
throw new Error('assetId is required.');
}
if (!options.walletAddress || options.walletAddress.trim() === '') {

@@ -815,3 +822,3 @@ throw new Error('walletAddress is required.');

const normalizedFiat = fiatToUse.toLowerCase().trim();
const normalizedAssetId = options.assetId.trim();
const normalizedAssetId = normalizedAssetIdForValidation;
const normalizedWalletAddress = options.walletAddress.trim();

@@ -825,3 +832,3 @@ const cacheKey = (0, RequestCache_1.createCacheKey)('getQuotes', [

[...paymentMethodsToUse].sort().join(','),
options.provider,
[...providersToUse].sort().join(','),
options.redirectUrl,

@@ -837,3 +844,3 @@ action,

paymentMethods: paymentMethodsToUse,
provider: options.provider,
providers: providersToUse,
redirectUrl: options.redirectUrl,

@@ -901,3 +908,3 @@ action,

paymentMethods: [paymentMethod.id],
provider: provider.id,
providers: [provider.id],
forceRefresh: true,

@@ -961,10 +968,22 @@ }).then((response) => {

/**
* Extracts the widget URL from a quote for redirect providers.
* Returns the widget URL if available, or null if the quote doesn't have one.
* Fetches the widget URL from a quote for redirect providers.
* Makes a request to the buyURL endpoint via the RampsService to get the
* actual provider widget URL, using the injected fetch and retry policy.
*
* @param quote - The quote to extract the widget URL from.
* @returns The widget URL string, or null if not available.
* @param quote - The quote to fetch the widget URL from.
* @returns Promise resolving to the widget URL string, or null if not available.
*/
getWidgetUrl(quote) {
return quote.quote?.widgetUrl ?? null;
async getWidgetUrl(quote) {
const buyUrl = quote.quote?.buyURL;
if (!buyUrl) {
return null;
}
try {
const buyWidget = await this.messenger.call('RampsService:getBuyWidgetUrl', buyUrl);
return buyWidget.url ?? null;
}
catch (error) {
console.error('Error fetching widget URL:', error);
return null;
}
}

@@ -1030,4 +1049,3 @@ }

const entry = requests[key];
if (entry &&
entry.status === RequestCache_1.RequestStatus.SUCCESS &&
if (entry?.status === RequestCache_1.RequestStatus.SUCCESS &&
(0, RequestCache_1.isCacheExpired)(entry, ttl)) {

@@ -1034,0 +1052,0 @@ delete requests[key];

@@ -5,3 +5,3 @@ import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";

import type { Country, TokensResponse, Provider, State, RampAction, PaymentMethod, PaymentMethodsResponse, QuotesResponse, Quote, RampsToken, RampsServiceActions } from "./RampsService.cjs";
import type { RampsServiceGetGeolocationAction, RampsServiceGetCountriesAction, RampsServiceGetTokensAction, RampsServiceGetProvidersAction, RampsServiceGetPaymentMethodsAction, RampsServiceGetQuotesAction } from "./RampsService-method-action-types.cjs";
import type { RampsServiceGetGeolocationAction, RampsServiceGetCountriesAction, RampsServiceGetTokensAction, RampsServiceGetProvidersAction, RampsServiceGetPaymentMethodsAction, RampsServiceGetQuotesAction, RampsServiceGetBuyWidgetUrlAction } from "./RampsService-method-action-types.cjs";
import type { RequestCache as RequestCacheType, RequestState, ExecuteRequestOptions } from "./RequestCache.cjs";

@@ -122,3 +122,3 @@ /**

*/
type AllowedActions = RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetTokensAction | RampsServiceGetProvidersAction | RampsServiceGetPaymentMethodsAction | RampsServiceGetQuotesAction;
type AllowedActions = RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetTokensAction | RampsServiceGetProvidersAction | RampsServiceGetPaymentMethodsAction | RampsServiceGetQuotesAction | RampsServiceGetBuyWidgetUrlAction;
/**

@@ -320,3 +320,3 @@ * Published when the state of {@link RampsController} changes.

* @param options.paymentMethods - Array of payment method IDs. If not provided, uses paymentMethods from state.
* @param options.provider - Optional provider ID to filter quotes.
* @param options.providers - Optional provider IDs to filter quotes.
* @param options.redirectUrl - Optional redirect URL after order completion.

@@ -331,7 +331,7 @@ * @param options.action - The ramp action type. Defaults to 'buy'.

fiat?: string;
assetId: string;
assetId?: string;
amount: number;
walletAddress: string;
paymentMethods?: string[];
provider?: string;
providers?: string[];
redirectUrl?: string;

@@ -377,11 +377,12 @@ action?: RampAction;

/**
* Extracts the widget URL from a quote for redirect providers.
* Returns the widget URL if available, or null if the quote doesn't have one.
* Fetches the widget URL from a quote for redirect providers.
* Makes a request to the buyURL endpoint via the RampsService to get the
* actual provider widget URL, using the injected fetch and retry policy.
*
* @param quote - The quote to extract the widget URL from.
* @returns The widget URL string, or null if not available.
* @param quote - The quote to fetch the widget URL from.
* @returns Promise resolving to the widget URL string, or null if not available.
*/
getWidgetUrl(quote: Quote): string | null;
getWidgetUrl(quote: Quote): Promise<string | null>;
}
export {};
//# sourceMappingURL=RampsController.d.cts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"RampsController.d.cts","sourceRoot":"","sources":["../src/RampsController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AA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AM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,IAAI;IA8ER;;;OAGG;IACH,gBAAgB,IAAI,IAAI;IAQxB;;;;OAIG;IACH,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI;IAM3C;;;;OAIG;IACM,OAAO,IAAI,IAAI;IAKxB;;;;;;;OAOG;IACG,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAiBzD"}

@@ -5,3 +5,3 @@ import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";

import type { Country, TokensResponse, Provider, State, RampAction, PaymentMethod, PaymentMethodsResponse, QuotesResponse, Quote, RampsToken, RampsServiceActions } from "./RampsService.mjs";
import type { RampsServiceGetGeolocationAction, RampsServiceGetCountriesAction, RampsServiceGetTokensAction, RampsServiceGetProvidersAction, RampsServiceGetPaymentMethodsAction, RampsServiceGetQuotesAction } from "./RampsService-method-action-types.mjs";
import type { RampsServiceGetGeolocationAction, RampsServiceGetCountriesAction, RampsServiceGetTokensAction, RampsServiceGetProvidersAction, RampsServiceGetPaymentMethodsAction, RampsServiceGetQuotesAction, RampsServiceGetBuyWidgetUrlAction } from "./RampsService-method-action-types.mjs";
import type { RequestCache as RequestCacheType, RequestState, ExecuteRequestOptions } from "./RequestCache.mjs";

@@ -122,3 +122,3 @@ /**

*/
type AllowedActions = RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetTokensAction | RampsServiceGetProvidersAction | RampsServiceGetPaymentMethodsAction | RampsServiceGetQuotesAction;
type AllowedActions = RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetTokensAction | RampsServiceGetProvidersAction | RampsServiceGetPaymentMethodsAction | RampsServiceGetQuotesAction | RampsServiceGetBuyWidgetUrlAction;
/**

@@ -320,3 +320,3 @@ * Published when the state of {@link RampsController} changes.

* @param options.paymentMethods - Array of payment method IDs. If not provided, uses paymentMethods from state.
* @param options.provider - Optional provider ID to filter quotes.
* @param options.providers - Optional provider IDs to filter quotes.
* @param options.redirectUrl - Optional redirect URL after order completion.

@@ -331,7 +331,7 @@ * @param options.action - The ramp action type. Defaults to 'buy'.

fiat?: string;
assetId: string;
assetId?: string;
amount: number;
walletAddress: string;
paymentMethods?: string[];
provider?: string;
providers?: string[];
redirectUrl?: string;

@@ -377,11 +377,12 @@ action?: RampAction;

/**
* Extracts the widget URL from a quote for redirect providers.
* Returns the widget URL if available, or null if the quote doesn't have one.
* Fetches the widget URL from a quote for redirect providers.
* Makes a request to the buyURL endpoint via the RampsService to get the
* actual provider widget URL, using the injected fetch and retry policy.
*
* @param quote - The quote to extract the widget URL from.
* @returns The widget URL string, or null if not available.
* @param quote - The quote to fetch the widget URL from.
* @returns Promise resolving to the widget URL string, or null if not available.
*/
getWidgetUrl(quote: Quote): string | null;
getWidgetUrl(quote: Quote): Promise<string | null>;
}
export {};
//# sourceMappingURL=RampsController.d.mts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"RampsController.d.mts","sourceRoot":"","sources":["../src/RampsController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAGrD,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,QAAQ,EACR,KAAK,EACL,UAAU,EACV,aAAa,EACb,sBAAsB,EACtB,cAAc,EACd,KAAK,EAEL,UAAU,EACV,mBAAmB,EACpB,2BAAuB;AACxB,OAAO,KAAK,EACV,gCAAgC,EAChC,8BAA8B,EAC9B,2BAA2B,EAC3B,8BAA8B,EAC9B,mCAAmC,EACnC,2BAA2B,EAC5B,+CAA2C;AAC5C,OAAO,KAAK,EACV,YAAY,IAAI,gBAAgB,EAChC,YAAY,EACZ,qBAAqB,EAGtB,2BAAuB;AA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AI;IA8ER;;;OAGG;IACH,gBAAgB,IAAI,IAAI;IAQxB;;;;OAIG;IACH,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI;IAM3C;;;;OAIG;IACM,OAAO,IAAI,IAAI;IAKxB;;;;;;OAMG;IACH,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI;CAG1C"}
{"version":3,"file":"RampsController.d.mts","sourceRoot":"","sources":["../src/RampsController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAGrD,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,QAAQ,EACR,KAAK,EACL,UAAU,EACV,aAAa,EACb,sBAAsB,EACtB,cAAc,EACd,KAAK,EACL,UAAU,EACV,mBAAmB,EACpB,2BAAuB;AACxB,OAAO,KAAK,EACV,gCAAgC,EAChC,8BAA8B,EAC9B,2BAA2B,EAC3B,8BAA8B,EAC9B,mCAAmC,EACnC,2BAA2B,EAC3B,iCAAiC,EAClC,+CAA2C;AAC5C,OAAO,KAAK,EACV,YAAY,IAAI,gBAAgB,EAChC,YAAY,EACZ,qBAAqB,EAGtB,2BAAuB;AAcxB;;;;GAIG;AACH,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,yCAAyC,EAAE,SAAS,mBAAmB,CAAC,MAAM,CAAC,EASzF,CAAC;AAUJ;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,aAAa,CAAC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es',
'RampsService:getBuyWidgetUrl',
];

@@ -774,3 +775,3 @@ /**

* @param options.paymentMethods - Array of payment method IDs. If not provided, uses paymentMethods from state.
* @param options.provider - Optional provider ID to filter quotes.
* @param options.providers - Optional provider IDs to filter quotes.
* @param options.redirectUrl - Optional redirect URL after order completion.

@@ -787,3 +788,6 @@ * @param options.action - The ramp action type. Defaults to 'buy'.

this.state.paymentMethods.data.map((pm) => pm.id);
const providersToUse = options.providers ??
this.state.providers.data.map((provider) => provider.id);
const action = options.action ?? 'buy';
const assetIdToUse = options.assetId ?? this.state.tokens.selected?.assetId;
if (!regionToUse) {

@@ -795,3 +799,9 @@ throw new Error('Region is required. Either provide a region parameter or ensure userRegion is set in controller state.');

}
if (!paymentMethodsToUse || paymentMethodsToUse.length === 0) {
const normalizedAssetIdForValidation = (assetIdToUse ?? '').trim();
if (normalizedAssetIdForValidation === '') {
throw new Error('assetId is required.');
}
if (!paymentMethodsToUse ||
paymentMethodsToUse.length === 0 ||
paymentMethodsToUse.some((pm) => pm.trim() === '')) {
throw new Error('Payment methods are required. Either provide paymentMethods parameter or ensure paymentMethods are set in controller state.');

@@ -802,5 +812,2 @@ }

}
if (!options.assetId || options.assetId.trim() === '') {
throw new Error('assetId is required.');
}
if (!options.walletAddress || options.walletAddress.trim() === '') {

@@ -811,3 +818,3 @@ throw new Error('walletAddress is required.');

const normalizedFiat = fiatToUse.toLowerCase().trim();
const normalizedAssetId = options.assetId.trim();
const normalizedAssetId = normalizedAssetIdForValidation;
const normalizedWalletAddress = options.walletAddress.trim();

@@ -821,3 +828,3 @@ const cacheKey = createCacheKey('getQuotes', [

[...paymentMethodsToUse].sort().join(','),
options.provider,
[...providersToUse].sort().join(','),
options.redirectUrl,

@@ -833,3 +840,3 @@ action,

paymentMethods: paymentMethodsToUse,
provider: options.provider,
providers: providersToUse,
redirectUrl: options.redirectUrl,

@@ -897,3 +904,3 @@ action,

paymentMethods: [paymentMethod.id],
provider: provider.id,
providers: [provider.id],
forceRefresh: true,

@@ -957,10 +964,22 @@ }).then((response) => {

/**
* Extracts the widget URL from a quote for redirect providers.
* Returns the widget URL if available, or null if the quote doesn't have one.
* Fetches the widget URL from a quote for redirect providers.
* Makes a request to the buyURL endpoint via the RampsService to get the
* actual provider widget URL, using the injected fetch and retry policy.
*
* @param quote - The quote to extract the widget URL from.
* @returns The widget URL string, or null if not available.
* @param quote - The quote to fetch the widget URL from.
* @returns Promise resolving to the widget URL string, or null if not available.
*/
getWidgetUrl(quote) {
return quote.quote?.widgetUrl ?? null;
async getWidgetUrl(quote) {
const buyUrl = quote.quote?.buyURL;
if (!buyUrl) {
return null;
}
try {
const buyWidget = await this.messenger.call('RampsService:getBuyWidgetUrl', buyUrl);
return buyWidget.url ?? null;
}
catch (error) {
console.error('Error fetching widget URL:', error);
return null;
}
}

@@ -1025,4 +1044,3 @@ }

const entry = requests[key];
if (entry &&
entry.status === RequestStatus.SUCCESS &&
if (entry?.status === RequestStatus.SUCCESS &&
isCacheExpired(entry, ttl)) {

@@ -1029,0 +1047,0 @@ delete requests[key];

@@ -1,1 +0,1 @@

{"version":3,"file":"RampsService-method-action-types.cjs","sourceRoot":"","sources":["../src/RampsService-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated by `scripts/generate-method-action-types.ts`.\n * Do not edit manually.\n */\n\nimport type { RampsService } from './RampsService';\n\n/**\n * Makes a request to the API in order to retrieve the user's geolocation\n * based on their IP address.\n *\n * @returns The user's country/region code (e.g., \"US-UT\" for Utah, USA).\n */\nexport type RampsServiceGetGeolocationAction = {\n type: `RampsService:getGeolocation`;\n handler: RampsService['getGeolocation'];\n};\n\n/**\n * Makes a request to the cached API to retrieve the list of supported countries.\n * The API returns countries with support information for both buy and sell actions.\n * Filters countries based on aggregator support (preserves OnRampSDK logic).\n *\n * @returns An array of countries filtered by aggregator support.\n */\nexport type RampsServiceGetCountriesAction = {\n type: `RampsService:getCountries`;\n handler: RampsService['getCountries'];\n};\n\n/**\n * Fetches the list of available tokens for a given region and action.\n * Supports optional provider filter.\n *\n * @param region - The region code (e.g., \"us\", \"fr\", \"us-ny\").\n * @param action - The ramp action type ('buy' or 'sell').\n * @param options - Optional query parameters for filtering tokens.\n * @param options.provider - Provider ID(s) to filter by.\n * @returns The tokens response containing topTokens and allTokens.\n */\nexport type RampsServiceGetTokensAction = {\n type: `RampsService:getTokens`;\n handler: RampsService['getTokens'];\n};\n\n/**\n * Fetches the list of providers for a given region.\n * Supports optional query filters: provider, crypto, fiat, payments.\n *\n * @param regionCode - The region code (e.g., \"us\", \"fr\", \"us-ny\").\n * @param options - Optional query parameters for filtering providers.\n * @param options.provider - Provider ID(s) to filter by.\n * @param options.crypto - Crypto currency ID(s) to filter by.\n * @param options.fiat - Fiat currency ID(s) to filter by.\n * @param options.payments - Payment method ID(s) to filter by.\n * @returns The providers response containing providers array.\n */\nexport type RampsServiceGetProvidersAction = {\n type: `RampsService:getProviders`;\n handler: RampsService['getProviders'];\n};\n\n/**\n * Fetches the list of payment methods for a given region, asset, and provider.\n *\n * @param options - Query parameters for filtering payment methods.\n * @param options.region - User's region code (e.g., \"us-al\").\n * @param options.fiat - Fiat currency code (e.g., \"usd\").\n * @param options.assetId - CAIP-19 cryptocurrency identifier.\n * @param options.provider - Provider ID path.\n * @returns The payment methods response containing payments array.\n */\nexport type RampsServiceGetPaymentMethodsAction = {\n type: `RampsService:getPaymentMethods`;\n handler: RampsService['getPaymentMethods'];\n};\n\n/**\n * Fetches quotes from all providers for a given set of parameters.\n * Uses the V2 orders API to get quotes for multiple payment methods at once.\n *\n * @param params - The parameters for fetching quotes.\n * @param params.region - User's region code (e.g., \"us\", \"us-ca\").\n * @param params.paymentMethods - Array of payment method IDs.\n * @param params.assetId - CAIP-19 cryptocurrency identifier.\n * @param params.fiat - Fiat currency code (e.g., \"usd\").\n * @param params.amount - The amount (in fiat for buy, crypto for sell).\n * @param params.walletAddress - The destination wallet address.\n * @param params.redirectUrl - Optional redirect URL after order completion.\n * @param params.provider - Optional provider ID to filter quotes.\n * @param params.action - The ramp action type. Defaults to 'buy'.\n * @returns The quotes response containing success, sorted, error, and customActions.\n */\nexport type RampsServiceGetQuotesAction = {\n type: `RampsService:getQuotes`;\n handler: RampsService['getQuotes'];\n};\n\n/**\n * Union of all RampsService action types.\n */\nexport type RampsServiceMethodActions =\n | RampsServiceGetGeolocationAction\n | RampsServiceGetCountriesAction\n | RampsServiceGetTokensAction\n | RampsServiceGetProvidersAction\n | RampsServiceGetPaymentMethodsAction\n | RampsServiceGetQuotesAction;\n"]}
{"version":3,"file":"RampsService-method-action-types.cjs","sourceRoot":"","sources":["../src/RampsService-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated by `scripts/generate-method-action-types.ts`.\n * Do not edit manually.\n */\n\nimport type { RampsService } from './RampsService';\n\n/**\n * Makes a request to the API in order to retrieve the user's geolocation\n * based on their IP address.\n *\n * @returns The user's country/region code (e.g., \"US-UT\" for Utah, USA).\n */\nexport type RampsServiceGetGeolocationAction = {\n type: `RampsService:getGeolocation`;\n handler: RampsService['getGeolocation'];\n};\n\n/**\n * Makes a request to the cached API to retrieve the list of supported countries.\n * The API returns countries with support information for both buy and sell actions.\n * Filters countries based on aggregator support (preserves OnRampSDK logic).\n *\n * @returns An array of countries filtered by aggregator support.\n */\nexport type RampsServiceGetCountriesAction = {\n type: `RampsService:getCountries`;\n handler: RampsService['getCountries'];\n};\n\n/**\n * Fetches the list of available tokens for a given region and action.\n * Supports optional provider filter.\n *\n * @param region - The region code (e.g., \"us\", \"fr\", \"us-ny\").\n * @param action - The ramp action type ('buy' or 'sell').\n * @param options - Optional query parameters for filtering tokens.\n * @param options.provider - Provider ID(s) to filter by.\n * @returns The tokens response containing topTokens and allTokens.\n */\nexport type RampsServiceGetTokensAction = {\n type: `RampsService:getTokens`;\n handler: RampsService['getTokens'];\n};\n\n/**\n * Fetches the list of providers for a given region.\n * Supports optional query filters: provider, crypto, fiat, payments.\n *\n * @param regionCode - The region code (e.g., \"us\", \"fr\", \"us-ny\").\n * @param options - Optional query parameters for filtering providers.\n * @param options.provider - Provider ID(s) to filter by.\n * @param options.crypto - Crypto currency ID(s) to filter by.\n * @param options.fiat - Fiat currency ID(s) to filter by.\n * @param options.payments - Payment method ID(s) to filter by.\n * @returns The providers response containing providers array.\n */\nexport type RampsServiceGetProvidersAction = {\n type: `RampsService:getProviders`;\n handler: RampsService['getProviders'];\n};\n\n/**\n * Fetches the list of payment methods for a given region, asset, and provider.\n *\n * @param options - Query parameters for filtering payment methods.\n * @param options.region - User's region code (e.g., \"us-al\").\n * @param options.fiat - Fiat currency code (e.g., \"usd\").\n * @param options.assetId - CAIP-19 cryptocurrency identifier.\n * @param options.provider - Provider ID path.\n * @returns The payment methods response containing payments array.\n */\nexport type RampsServiceGetPaymentMethodsAction = {\n type: `RampsService:getPaymentMethods`;\n handler: RampsService['getPaymentMethods'];\n};\n\n/**\n * Fetches quotes from all providers for a given set of parameters.\n * Uses the V2 orders API to get quotes for multiple payment methods at once.\n *\n * @param params - The parameters for fetching quotes.\n * @param params.region - User's region code (e.g., \"us\", \"us-ca\").\n * @param params.paymentMethods - Array of payment method IDs.\n * @param params.assetId - CAIP-19 cryptocurrency identifier.\n * @param params.fiat - Fiat currency code (e.g., \"usd\").\n * @param params.amount - The amount (in fiat for buy, crypto for sell).\n * @param params.walletAddress - The destination wallet address.\n * @param params.redirectUrl - Optional redirect URL after order completion.\n * @param params.providers - Optional provider IDs to filter quotes.\n * @param params.action - The ramp action type. Defaults to 'buy'.\n * @returns The quotes response containing success, sorted, error, and customActions.\n */\nexport type RampsServiceGetQuotesAction = {\n type: `RampsService:getQuotes`;\n handler: RampsService['getQuotes'];\n};\n\n/**\n * Fetches the buy widget data from a buy URL endpoint.\n * Makes a request to the buyURL (as provided in a quote) to get the actual\n * provider widget URL, browser type, and order ID.\n *\n * @param buyUrl - The full buy URL endpoint to fetch from.\n * @returns The buy widget data containing the provider widget URL.\n */\nexport type RampsServiceGetBuyWidgetUrlAction = {\n type: `RampsService:getBuyWidgetUrl`;\n handler: RampsService['getBuyWidgetUrl'];\n};\n\n/**\n * Union of all RampsService action types.\n */\nexport type RampsServiceMethodActions =\n | RampsServiceGetGeolocationAction\n | RampsServiceGetCountriesAction\n | RampsServiceGetTokensAction\n | RampsServiceGetProvidersAction\n | RampsServiceGetPaymentMethodsAction\n | RampsServiceGetQuotesAction\n | RampsServiceGetBuyWidgetUrlAction;\n"]}

@@ -83,3 +83,3 @@ /**

* @param params.redirectUrl - Optional redirect URL after order completion.
* @param params.provider - Optional provider ID to filter quotes.
* @param params.providers - Optional provider IDs to filter quotes.
* @param params.action - The ramp action type. Defaults to 'buy'.

@@ -93,5 +93,17 @@ * @returns The quotes response containing success, sorted, error, and customActions.

/**
* Fetches the buy widget data from a buy URL endpoint.
* Makes a request to the buyURL (as provided in a quote) to get the actual
* provider widget URL, browser type, and order ID.
*
* @param buyUrl - The full buy URL endpoint to fetch from.
* @returns The buy widget data containing the provider widget URL.
*/
export type RampsServiceGetBuyWidgetUrlAction = {
type: `RampsService:getBuyWidgetUrl`;
handler: RampsService['getBuyWidgetUrl'];
};
/**
* Union of all RampsService action types.
*/
export type RampsServiceMethodActions = RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetTokensAction | RampsServiceGetProvidersAction | RampsServiceGetPaymentMethodsAction | RampsServiceGetQuotesAction;
export type RampsServiceMethodActions = RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetTokensAction | RampsServiceGetProvidersAction | RampsServiceGetPaymentMethodsAction | RampsServiceGetQuotesAction | RampsServiceGetBuyWidgetUrlAction;
//# sourceMappingURL=RampsService-method-action-types.d.cts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"RampsService-method-action-types.d.cts","sourceRoot":"","sources":["../src/RampsService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,2BAAuB;AAEnD;;;;;GAKG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EAAE,6BAA6B,CAAC;IACpC,OAAO,EAAE,YAAY,CAAC,gBAAgB,CAAC,CAAC;CACzC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,2BAA2B,CAAC;IAClC,OAAO,EAAE,YAAY,CAAC,cAAc,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;CACpC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,2BAA2B,CAAC;IAClC,OAAO,EAAE,YAAY,CAAC,cAAc,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,mCAAmC,GAAG;IAChD,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,YAAY,CAAC,mBAAmB,CAAC,CAAC;CAC5C,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;CACpC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GACjC,gCAAgC,GAChC,8BAA8B,GAC9B,2BAA2B,GAC3B,8BAA8B,GAC9B,mCAAmC,GACnC,2BAA2B,CAAC"}
{"version":3,"file":"RampsService-method-action-types.d.cts","sourceRoot":"","sources":["../src/RampsService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,2BAAuB;AAEnD;;;;;GAKG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EAAE,6BAA6B,CAAC;IACpC,OAAO,EAAE,YAAY,CAAC,gBAAgB,CAAC,CAAC;CACzC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,2BAA2B,CAAC;IAClC,OAAO,EAAE,YAAY,CAAC,cAAc,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;CACpC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,2BAA2B,CAAC;IAClC,OAAO,EAAE,YAAY,CAAC,cAAc,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,mCAAmC,GAAG;IAChD,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,YAAY,CAAC,mBAAmB,CAAC,CAAC;CAC5C,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;CACpC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,YAAY,CAAC,iBAAiB,CAAC,CAAC;CAC1C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GACjC,gCAAgC,GAChC,8BAA8B,GAC9B,2BAA2B,GAC3B,8BAA8B,GAC9B,mCAAmC,GACnC,2BAA2B,GAC3B,iCAAiC,CAAC"}

@@ -83,3 +83,3 @@ /**

* @param params.redirectUrl - Optional redirect URL after order completion.
* @param params.provider - Optional provider ID to filter quotes.
* @param params.providers - Optional provider IDs to filter quotes.
* @param params.action - The ramp action type. Defaults to 'buy'.

@@ -93,5 +93,17 @@ * @returns The quotes response containing success, sorted, error, and customActions.

/**
* Fetches the buy widget data from a buy URL endpoint.
* Makes a request to the buyURL (as provided in a quote) to get the actual
* provider widget URL, browser type, and order ID.
*
* @param buyUrl - The full buy URL endpoint to fetch from.
* @returns The buy widget data containing the provider widget URL.
*/
export type RampsServiceGetBuyWidgetUrlAction = {
type: `RampsService:getBuyWidgetUrl`;
handler: RampsService['getBuyWidgetUrl'];
};
/**
* Union of all RampsService action types.
*/
export type RampsServiceMethodActions = RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetTokensAction | RampsServiceGetProvidersAction | RampsServiceGetPaymentMethodsAction | RampsServiceGetQuotesAction;
export type RampsServiceMethodActions = RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetTokensAction | RampsServiceGetProvidersAction | RampsServiceGetPaymentMethodsAction | RampsServiceGetQuotesAction | RampsServiceGetBuyWidgetUrlAction;
//# sourceMappingURL=RampsService-method-action-types.d.mts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"RampsService-method-action-types.d.mts","sourceRoot":"","sources":["../src/RampsService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,2BAAuB;AAEnD;;;;;GAKG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EAAE,6BAA6B,CAAC;IACpC,OAAO,EAAE,YAAY,CAAC,gBAAgB,CAAC,CAAC;CACzC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,2BAA2B,CAAC;IAClC,OAAO,EAAE,YAAY,CAAC,cAAc,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;CACpC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,2BAA2B,CAAC;IAClC,OAAO,EAAE,YAAY,CAAC,cAAc,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,mCAAmC,GAAG;IAChD,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,YAAY,CAAC,mBAAmB,CAAC,CAAC;CAC5C,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;CACpC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GACjC,gCAAgC,GAChC,8BAA8B,GAC9B,2BAA2B,GAC3B,8BAA8B,GAC9B,mCAAmC,GACnC,2BAA2B,CAAC"}
{"version":3,"file":"RampsService-method-action-types.d.mts","sourceRoot":"","sources":["../src/RampsService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,2BAAuB;AAEnD;;;;;GAKG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EAAE,6BAA6B,CAAC;IACpC,OAAO,EAAE,YAAY,CAAC,gBAAgB,CAAC,CAAC;CACzC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,2BAA2B,CAAC;IAClC,OAAO,EAAE,YAAY,CAAC,cAAc,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;CACpC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,2BAA2B,CAAC;IAClC,OAAO,EAAE,YAAY,CAAC,cAAc,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,mCAAmC,GAAG;IAChD,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,YAAY,CAAC,mBAAmB,CAAC,CAAC;CAC5C,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;CACpC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,YAAY,CAAC,iBAAiB,CAAC,CAAC;CAC1C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GACjC,gCAAgC,GAChC,8BAA8B,GAC9B,2BAA2B,GAC3B,8BAA8B,GAC9B,mCAAmC,GACnC,2BAA2B,GAC3B,iCAAiC,CAAC"}

@@ -1,1 +0,1 @@

{"version":3,"file":"RampsService-method-action-types.mjs","sourceRoot":"","sources":["../src/RampsService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated by `scripts/generate-method-action-types.ts`.\n * Do not edit manually.\n */\n\nimport type { RampsService } from './RampsService';\n\n/**\n * Makes a request to the API in order to retrieve the user's geolocation\n * based on their IP address.\n *\n * @returns The user's country/region code (e.g., \"US-UT\" for Utah, USA).\n */\nexport type RampsServiceGetGeolocationAction = {\n type: `RampsService:getGeolocation`;\n handler: RampsService['getGeolocation'];\n};\n\n/**\n * Makes a request to the cached API to retrieve the list of supported countries.\n * The API returns countries with support information for both buy and sell actions.\n * Filters countries based on aggregator support (preserves OnRampSDK logic).\n *\n * @returns An array of countries filtered by aggregator support.\n */\nexport type RampsServiceGetCountriesAction = {\n type: `RampsService:getCountries`;\n handler: RampsService['getCountries'];\n};\n\n/**\n * Fetches the list of available tokens for a given region and action.\n * Supports optional provider filter.\n *\n * @param region - The region code (e.g., \"us\", \"fr\", \"us-ny\").\n * @param action - The ramp action type ('buy' or 'sell').\n * @param options - Optional query parameters for filtering tokens.\n * @param options.provider - Provider ID(s) to filter by.\n * @returns The tokens response containing topTokens and allTokens.\n */\nexport type RampsServiceGetTokensAction = {\n type: `RampsService:getTokens`;\n handler: RampsService['getTokens'];\n};\n\n/**\n * Fetches the list of providers for a given region.\n * Supports optional query filters: provider, crypto, fiat, payments.\n *\n * @param regionCode - The region code (e.g., \"us\", \"fr\", \"us-ny\").\n * @param options - Optional query parameters for filtering providers.\n * @param options.provider - Provider ID(s) to filter by.\n * @param options.crypto - Crypto currency ID(s) to filter by.\n * @param options.fiat - Fiat currency ID(s) to filter by.\n * @param options.payments - Payment method ID(s) to filter by.\n * @returns The providers response containing providers array.\n */\nexport type RampsServiceGetProvidersAction = {\n type: `RampsService:getProviders`;\n handler: RampsService['getProviders'];\n};\n\n/**\n * Fetches the list of payment methods for a given region, asset, and provider.\n *\n * @param options - Query parameters for filtering payment methods.\n * @param options.region - User's region code (e.g., \"us-al\").\n * @param options.fiat - Fiat currency code (e.g., \"usd\").\n * @param options.assetId - CAIP-19 cryptocurrency identifier.\n * @param options.provider - Provider ID path.\n * @returns The payment methods response containing payments array.\n */\nexport type RampsServiceGetPaymentMethodsAction = {\n type: `RampsService:getPaymentMethods`;\n handler: RampsService['getPaymentMethods'];\n};\n\n/**\n * Fetches quotes from all providers for a given set of parameters.\n * Uses the V2 orders API to get quotes for multiple payment methods at once.\n *\n * @param params - The parameters for fetching quotes.\n * @param params.region - User's region code (e.g., \"us\", \"us-ca\").\n * @param params.paymentMethods - Array of payment method IDs.\n * @param params.assetId - CAIP-19 cryptocurrency identifier.\n * @param params.fiat - Fiat currency code (e.g., \"usd\").\n * @param params.amount - The amount (in fiat for buy, crypto for sell).\n * @param params.walletAddress - The destination wallet address.\n * @param params.redirectUrl - Optional redirect URL after order completion.\n * @param params.provider - Optional provider ID to filter quotes.\n * @param params.action - The ramp action type. Defaults to 'buy'.\n * @returns The quotes response containing success, sorted, error, and customActions.\n */\nexport type RampsServiceGetQuotesAction = {\n type: `RampsService:getQuotes`;\n handler: RampsService['getQuotes'];\n};\n\n/**\n * Union of all RampsService action types.\n */\nexport type RampsServiceMethodActions =\n | RampsServiceGetGeolocationAction\n | RampsServiceGetCountriesAction\n | RampsServiceGetTokensAction\n | RampsServiceGetProvidersAction\n | RampsServiceGetPaymentMethodsAction\n | RampsServiceGetQuotesAction;\n"]}
{"version":3,"file":"RampsService-method-action-types.mjs","sourceRoot":"","sources":["../src/RampsService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated by `scripts/generate-method-action-types.ts`.\n * Do not edit manually.\n */\n\nimport type { RampsService } from './RampsService';\n\n/**\n * Makes a request to the API in order to retrieve the user's geolocation\n * based on their IP address.\n *\n * @returns The user's country/region code (e.g., \"US-UT\" for Utah, USA).\n */\nexport type RampsServiceGetGeolocationAction = {\n type: `RampsService:getGeolocation`;\n handler: RampsService['getGeolocation'];\n};\n\n/**\n * Makes a request to the cached API to retrieve the list of supported countries.\n * The API returns countries with support information for both buy and sell actions.\n * Filters countries based on aggregator support (preserves OnRampSDK logic).\n *\n * @returns An array of countries filtered by aggregator support.\n */\nexport type RampsServiceGetCountriesAction = {\n type: `RampsService:getCountries`;\n handler: RampsService['getCountries'];\n};\n\n/**\n * Fetches the list of available tokens for a given region and action.\n * Supports optional provider filter.\n *\n * @param region - The region code (e.g., \"us\", \"fr\", \"us-ny\").\n * @param action - The ramp action type ('buy' or 'sell').\n * @param options - Optional query parameters for filtering tokens.\n * @param options.provider - Provider ID(s) to filter by.\n * @returns The tokens response containing topTokens and allTokens.\n */\nexport type RampsServiceGetTokensAction = {\n type: `RampsService:getTokens`;\n handler: RampsService['getTokens'];\n};\n\n/**\n * Fetches the list of providers for a given region.\n * Supports optional query filters: provider, crypto, fiat, payments.\n *\n * @param regionCode - The region code (e.g., \"us\", \"fr\", \"us-ny\").\n * @param options - Optional query parameters for filtering providers.\n * @param options.provider - Provider ID(s) to filter by.\n * @param options.crypto - Crypto currency ID(s) to filter by.\n * @param options.fiat - Fiat currency ID(s) to filter by.\n * @param options.payments - Payment method ID(s) to filter by.\n * @returns The providers response containing providers array.\n */\nexport type RampsServiceGetProvidersAction = {\n type: `RampsService:getProviders`;\n handler: RampsService['getProviders'];\n};\n\n/**\n * Fetches the list of payment methods for a given region, asset, and provider.\n *\n * @param options - Query parameters for filtering payment methods.\n * @param options.region - User's region code (e.g., \"us-al\").\n * @param options.fiat - Fiat currency code (e.g., \"usd\").\n * @param options.assetId - CAIP-19 cryptocurrency identifier.\n * @param options.provider - Provider ID path.\n * @returns The payment methods response containing payments array.\n */\nexport type RampsServiceGetPaymentMethodsAction = {\n type: `RampsService:getPaymentMethods`;\n handler: RampsService['getPaymentMethods'];\n};\n\n/**\n * Fetches quotes from all providers for a given set of parameters.\n * Uses the V2 orders API to get quotes for multiple payment methods at once.\n *\n * @param params - The parameters for fetching quotes.\n * @param params.region - User's region code (e.g., \"us\", \"us-ca\").\n * @param params.paymentMethods - Array of payment method IDs.\n * @param params.assetId - CAIP-19 cryptocurrency identifier.\n * @param params.fiat - Fiat currency code (e.g., \"usd\").\n * @param params.amount - The amount (in fiat for buy, crypto for sell).\n * @param params.walletAddress - The destination wallet address.\n * @param params.redirectUrl - Optional redirect URL after order completion.\n * @param params.providers - Optional provider IDs to filter quotes.\n * @param params.action - The ramp action type. Defaults to 'buy'.\n * @returns The quotes response containing success, sorted, error, and customActions.\n */\nexport type RampsServiceGetQuotesAction = {\n type: `RampsService:getQuotes`;\n handler: RampsService['getQuotes'];\n};\n\n/**\n * Fetches the buy widget data from a buy URL endpoint.\n * Makes a request to the buyURL (as provided in a quote) to get the actual\n * provider widget URL, browser type, and order ID.\n *\n * @param buyUrl - The full buy URL endpoint to fetch from.\n * @returns The buy widget data containing the provider widget URL.\n */\nexport type RampsServiceGetBuyWidgetUrlAction = {\n type: `RampsService:getBuyWidgetUrl`;\n handler: RampsService['getBuyWidgetUrl'];\n};\n\n/**\n * Union of all RampsService action types.\n */\nexport type RampsServiceMethodActions =\n | RampsServiceGetGeolocationAction\n | RampsServiceGetCountriesAction\n | RampsServiceGetTokensAction\n | RampsServiceGetProvidersAction\n | RampsServiceGetPaymentMethodsAction\n | RampsServiceGetQuotesAction\n | RampsServiceGetBuyWidgetUrlAction;\n"]}

@@ -58,2 +58,3 @@ "use strict";

'getQuotes',
'getBuyWidgetUrl',
];

@@ -406,3 +407,3 @@ // === SERVICE DEFINITION ===

* @param params.redirectUrl - Optional redirect URL after order completion.
* @param params.provider - Optional provider ID to filter quotes.
* @param params.providers - Optional provider IDs to filter quotes.
* @param params.action - The ramp action type. Defaults to 'buy'.

@@ -428,5 +429,5 @@ * @returns The quotes response containing success, sorted, error, and customActions.

// Add provider filter if specified
if (params.provider) {
url.searchParams.append('providers', params.provider);
}
params.providers?.forEach((provider) => {
url.searchParams.append('providers', provider);
});
// Add redirect URL if specified

@@ -454,2 +455,25 @@ if (params.redirectUrl) {

}
/**
* Fetches the buy widget data from a buy URL endpoint.
* Makes a request to the buyURL (as provided in a quote) to get the actual
* provider widget URL, browser type, and order ID.
*
* @param buyUrl - The full buy URL endpoint to fetch from.
* @returns The buy widget data containing the provider widget URL.
*/
async getBuyWidgetUrl(buyUrl) {
const url = new URL(buyUrl);
__classPrivateFieldGet(this, _RampsService_instances, "m", _RampsService_addCommonParams).call(this, url);
const response = await __classPrivateFieldGet(this, _RampsService_policy, "f").execute(async () => {
const fetchResponse = await __classPrivateFieldGet(this, _RampsService_fetch, "f").call(this, url);
if (!fetchResponse.ok) {
throw new controller_utils_1.HttpError(fetchResponse.status, `Fetching '${url.toString()}' failed with status '${fetchResponse.status}'`);
}
return fetchResponse.json();
});
if (!response || typeof response !== 'object' || !response.url) {
throw new Error('Malformed response received from buy widget URL API');
}
return response;
}
}

@@ -456,0 +480,0 @@ exports.RampsService = RampsService;

@@ -1,1 +0,1 @@

{"version":3,"file":"RampsService.cjs","sourceRoot":"","sources":["../src/RampsService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAIA,iEAA4E;AAI5E,mEAA0C;AAoc1C;;GAEG;AACU,QAAA,iBAAiB,GAAG,OAAO,CAAC;AAOzC,kBAAkB;AAElB;;;GAGG;AACU,QAAA,WAAW,GAAG,cAAc,CAAC;AAE1C;;GAEG;AACH,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,6CAAyB,CAAA;IACzB,uCAAmB,CAAA;IACnB,+CAA2B,CAAA;IAC3B,mCAAe,CAAA;AACjB,CAAC,EALW,gBAAgB,gCAAhB,gBAAgB,QAK3B;AAED;;;GAGG;AACH,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,sCAAmB,CAAA;IACnB,oCAAiB,CAAA;AACnB,CAAC,EAHW,eAAe,+BAAf,eAAe,QAG1B;AAED,oBAAoB;AAEpB,MAAM,yBAAyB,GAAG;IAChC,gBAAgB;IAChB,cAAc;IACd,WAAW;IACX,cAAc;IACd,mBAAmB;IACnB,WAAW;CACH,CAAC;AAgCX,6BAA6B;AAE7B;;;;;;;GAOG;AACH,SAAS,UAAU,CACjB,WAA6B,EAC7B,OAAwB;IAExB,MAAM,KAAK,GAAG,OAAO,KAAK,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;IAElE,QAAQ,WAAW,EAAE,CAAC;QACpB,KAAK,gBAAgB,CAAC,UAAU;YAC9B,OAAO,kBAAkB,KAAK,qBAAqB,CAAC;QACtD,KAAK,gBAAgB,CAAC,OAAO,CAAC;QAC9B,KAAK,gBAAgB,CAAC,WAAW;YAC/B,OAAO,kBAAkB,KAAK,yBAAyB,CAAC;QAC1D,KAAK,gBAAgB,CAAC,KAAK;YACzB,OAAO,u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ttpError } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\n\nimport type { RampsServiceMethodActions } from './RampsService-method-action-types';\nimport packageJson from '../package.json';\n\n/**\n * Represents phone number information for a country.\n */\nexport type CountryPhone = {\n prefix: string;\n placeholder: string;\n template: string;\n};\n\n/**\n * Indicates whether a region supports buy and/or sell actions.\n */\nexport type SupportedActions = {\n /**\n * Whether buy actions are supported.\n */\n buy: boolean;\n /**\n * Whether sell actions are supported.\n */\n sell: boolean;\n};\n\n/**\n * Represents a state/province within a country.\n */\nexport type State = {\n /**\n * State identifier. Can be in path format (e.g., \"/regions/us-ut\") or ISO code format (e.g., \"us-ut\").\n */\n id?: string;\n /**\n * State name.\n */\n name?: string;\n /**\n * ISO state code (e.g., \"UT\", \"NY\").\n */\n stateId?: string;\n /**\n * Whether this state is supported for buy and/or sell ramp actions.\n */\n supported?: SupportedActions;\n /**\n * Whether this state is recommended.\n */\n recommended?: boolean;\n};\n\n/**\n * Represents a provider link.\n */\nexport type ProviderLink = {\n name: string;\n url: string;\n};\n\n/**\n * Represents provider logos.\n */\nexport type ProviderLogos = {\n light: string;\n dark: string;\n height: number;\n width: number;\n};\n\n/**\n * Represents a ramp provider.\n */\nexport type Provider = {\n id: string;\n name: string;\n environmentType: string;\n description: string;\n hqAddress: string;\n links: ProviderLink[];\n logos: ProviderLogos;\n supportedCryptoCurrencies?: Record<string, boolean>;\n supportedFiatCurrencies?: Record<string, boolean>;\n supportedPaymentMethods?: Record<string, boolean>;\n};\n\n/**\n * Represents a payment method for funding a purchase.\n */\nexport type PaymentMethod = {\n /**\n * Canonical payment method ID (e.g., \"/payments/debit-credit-card\").\n */\n id: string;\n /**\n * Payment type identifier (e.g., \"debit-credit-card\", \"bank-transfer\").\n */\n paymentType: string;\n /**\n * User-facing name for the payment method.\n */\n name: string;\n /**\n * Score for sorting payment methods (higher is better).\n */\n score: number;\n /**\n * Icon identifier for the payment method.\n */\n icon: string;\n /**\n * Localized disclaimer text (optional).\n */\n disclaimer?: string;\n /**\n * Delay in minutes (e.g., [5, 10]).\n */\n delay?: number[];\n /**\n * Localized pending order description (optional).\n */\n pendingOrderDescription?: string;\n};\n\n/**\n * Response from the paymentMethods API.\n */\nexport type PaymentMethodsResponse = {\n /**\n * List of available payment methods.\n */\n payments: PaymentMethod[];\n /**\n * Recommended sorting for payment methods.\n */\n sort?: {\n ids: string[];\n sortBy: string;\n };\n};\n\n// === QUOTES TYPES ===\n\n/**\n * Sort criteria for quotes.\n */\nexport type QuoteSortBy = 'price' | 'reliability';\n\n/**\n * Represents crypto translation info for a quote.\n */\nexport type QuoteCryptoTranslation = {\n /**\n * The crypto currency ID.\n */\n id?: string;\n /**\n * The crypto symbol.\n */\n symbol?: string;\n /**\n * The chain ID.\n */\n chainId?: string;\n};\n\n/**\n * Represents an individual quote from a provider.\n */\nexport type Quote = {\n /**\n * The provider ID (e.g., \"/providers/moonpay\").\n */\n provider: string;\n /**\n * The quote details.\n */\n quote: {\n /**\n * The amount the user is paying (in fiat for buy, crypto for sell).\n */\n amountIn: number | string;\n /**\n * The amount the user will receive (in crypto for buy, fiat for sell).\n */\n amountOut: number | string;\n /**\n * The payment method used for this quote.\n */\n paymentMethod: string;\n /**\n * The fiat value of the output amount (for buy actions).\n */\n amountOutInFiat?: number;\n /**\n * The widget URL for redirect providers.\n */\n widgetUrl?: string;\n /**\n * Crypto translation info for display.\n */\n cryptoTranslation?: QuoteCryptoTranslation;\n /**\n * Total fees in the source currency.\n */\n totalFees?: number | string;\n /**\n * Network fees.\n */\n networkFee?: number | string;\n /**\n * Provider fees.\n */\n providerFee?: number | string;\n };\n /**\n * Metadata about the quote.\n */\n metadata?: {\n /**\n * Reliability score for the provider (0-100).\n */\n reliability?: number;\n /**\n * Tags for the quote.\n */\n tags?: {\n /**\n * Whether this is the best rate quote.\n */\n isBestRate?: boolean;\n /**\n * Whether this is the most reliable provider.\n */\n isMostReliable?: boolean;\n };\n };\n};\n\n/**\n * Represents an error from a provider when fetching quotes.\n */\nexport type QuoteError = {\n /**\n * The provider ID that failed.\n */\n provider: string;\n /**\n * Error message.\n */\n error?: string;\n};\n\n/**\n * Sort order information for quotes.\n */\nexport type QuoteSortOrder = {\n /**\n * The sort criteria.\n */\n sortBy: QuoteSortBy;\n /**\n * Provider IDs in sorted order.\n */\n ids: string[];\n};\n\n/**\n * Custom action for a provider (e.g., Apple Pay).\n */\nexport type QuoteCustomAction = {\n /**\n * Buy action details.\n */\n buy: {\n /**\n * Provider ID.\n */\n providerId: string;\n };\n /**\n * Payment method ID this action applies to.\n */\n paymentMethodId: string;\n /**\n * Supported payment method IDs.\n */\n supportedPaymentMethodIds: string[];\n};\n\n/**\n * Response from the quotes API.\n */\nexport type QuotesResponse = {\n /**\n * Successfully retrieved quotes.\n */\n success: Quote[];\n /**\n * Sort orders for the quotes.\n */\n sorted: QuoteSortOrder[];\n /**\n * Errors from providers that failed to return quotes.\n */\n error: QuoteError[];\n /**\n * Custom actions available from providers.\n */\n customActions: QuoteCustomAction[];\n};\n\n/**\n * Parameters for fetching quotes.\n */\nexport type GetQuotesParams = {\n /**\n * The region code (e.g., \"us\", \"us-ca\").\n */\n region: string;\n /**\n * Array of payment method IDs to get quotes for.\n */\n paymentMethods: string[];\n /**\n * The CAIP-19 asset ID (e.g., \"eip155:1/erc20:0x...\").\n */\n assetId: string;\n /**\n * The fiat currency code (e.g., \"usd\").\n */\n fiat: string;\n /**\n * The amount (in fiat for buy, crypto for sell).\n */\n amount: number;\n /**\n * The destination wallet address.\n */\n walletAddress: string;\n /**\n * Optional redirect URL after order completion.\n */\n redirectUrl?: string;\n /**\n * Optional provider ID to filter quotes.\n */\n provider?: string;\n /**\n * The ramp action type. Defaults to 'buy'.\n */\n action?: RampAction;\n};\n\n/**\n * Represents a country returned from the regions/countries API.\n */\nexport type Country = {\n /**\n * ISO-2 country code (e.g., \"US\", \"GB\").\n */\n isoCode: string;\n /**\n * Country identifier. Can be in path format (e.g., \"/regions/us\") or ISO code format.\n * If not provided, defaults to isoCode.\n */\n id?: string;\n /**\n * Country flag emoji or code.\n */\n flag: string;\n /**\n * Country name.\n */\n name: string;\n /**\n * Phone number information.\n */\n phone: CountryPhone;\n /**\n * Default currency code.\n */\n currency: string;\n /**\n * Whether this country is supported for buy and/or sell ramp actions.\n */\n supported: SupportedActions;\n /**\n * Whether this country is recommended.\n */\n recommended?: boolean;\n /**\n * Array of state objects.\n */\n states?: State[];\n /**\n * Default amount for ramps transactions.\n */\n defaultAmount?: number;\n /**\n * Quick amount options for ramps transactions.\n */\n quickAmounts?: number[];\n};\n\n/**\n * Represents a token returned from the regions/{region}/tokens API.\n */\nexport type RampsToken = {\n /**\n * The asset identifier in CAIP-19 format (e.g., \"eip155:1/erc20:0x...\").\n */\n assetId: string;\n /**\n * The chain identifier in CAIP-2 format (e.g., \"eip155:1\").\n */\n chainId: string;\n /**\n * Token name (e.g., \"USD Coin\").\n */\n name: string;\n /**\n * Token symbol (e.g., \"USDC\").\n */\n symbol: string;\n /**\n * Number of decimals for the token.\n */\n decimals: number;\n /**\n * URL to the token icon.\n */\n iconUrl: string;\n /**\n * Whether this token is supported.\n */\n tokenSupported: boolean;\n};\n\n/**\n * Response from the regions/{region}/tokens API.\n */\nexport type TokensResponse = {\n /**\n * Top/popular tokens for the region.\n */\n topTokens: RampsToken[];\n /**\n * All available tokens for the region.\n */\n allTokens: RampsToken[];\n};\n\n/**\n * The SDK version to send with API requests. (backwards-compatibility)\n */\nexport const RAMPS_SDK_VERSION = '2.1.6';\n\n/**\n * The type of ramp action: 'buy' or 'sell'.\n */\nexport type RampAction = 'buy' | 'sell';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link RampsService}, used to namespace the\n * service's actions and events.\n */\nexport const serviceName = 'RampsService';\n\n/**\n * The environment to use for API requests.\n */\nexport enum RampsEnvironment {\n Production = 'production',\n Staging = 'staging',\n Development = 'development',\n Local = 'local',\n}\n\n/**\n * The type of ramps API service.\n * Determines which base URL to use (cache vs standard).\n */\nexport enum RampsApiService {\n Regions = 'regions',\n Orders = 'orders',\n}\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'getGeolocation',\n 'getCountries',\n 'getTokens',\n 'getProviders',\n 'getPaymentMethods',\n 'getQuotes',\n] as const;\n\n/**\n * Actions that {@link RampsService} exposes to other consumers.\n */\nexport type RampsServiceActions = RampsServiceMethodActions;\n\n/**\n * Actions from other messengers that {@link RampsService} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Events that {@link RampsService} exposes to other consumers.\n */\nexport type RampsServiceEvents = never;\n\n/**\n * Events from other messengers that {@link RampsService} subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger which is restricted to actions and events accessed by\n * {@link RampsService}.\n */\nexport type RampsServiceMessenger = Messenger<\n typeof serviceName,\n RampsServiceActions | AllowedActions,\n RampsServiceEvents | AllowedEvents\n>;\n\n// === SERVICE DEFINITION ===\n\n/**\n * Gets the base URL for API requests based on the environment and service type.\n * The Regions service uses a cache URL, while other services use the standard URL.\n *\n * @param environment - The environment to use.\n * @param service - The API service type (determines if cache URL is used).\n * @returns The base URL for API requests.\n */\nfunction getBaseUrl(\n environment: RampsEnvironment,\n service: RampsApiService,\n): string {\n const cache = service === RampsApiService.Regions ? '-cache' : '';\n\n switch (environment) {\n case RampsEnvironment.Production:\n return `https://on-ramp${cache}.api.cx.metamask.io`;\n case RampsEnvironment.Staging:\n case RampsEnvironment.Development:\n return `https://on-ramp${cache}.uat-api.cx.metamask.io`;\n case RampsEnvironment.Local:\n return 'http://localhost:3000';\n default:\n throw new Error(`Invalid environment: ${String(environment)}`);\n }\n}\n\n/**\n * Constructs an API path with a version prefix.\n *\n * @param path - The API endpoint path.\n * @param version - The API version prefix. Defaults to 'v2'.\n * @returns The versioned API path.\n */\nfunction getApiPath(path: string, version: string = 'v2'): string {\n return `${version}/${path}`;\n}\n\n/**\n * This service object is responsible for interacting with the Ramps API.\n *\n * @example\n *\n * ``` ts\n * import { Messenger } from '@metamask/messenger';\n * import type {\n * RampsServiceActions,\n * RampsServiceEvents,\n * } from '@metamask/ramps-controller';\n *\n * const rootMessenger = new Messenger<\n * 'Root',\n * RampsServiceActions\n * RampsServiceEvents\n * >({ namespace: 'Root' });\n * const rampsServiceMessenger = new Messenger<\n * 'RampsService',\n * RampsServiceActions,\n * RampsServiceEvents,\n * typeof rootMessenger,\n * >({\n * namespace: 'RampsService',\n * parent: rootMessenger,\n * });\n * // Instantiate the service to register its actions on the messenger\n * new RampsService({\n * messenger: rampsServiceMessenger,\n * environment: RampsEnvironment.Production,\n * context: 'mobile-ios',\n * fetch,\n * });\n *\n * // Later...\n * // Get the user's geolocation\n * const geolocation = await rootMessenger.call(\n * 'RampsService:getGeolocation',\n * );\n * // ... Do something with the geolocation ...\n * ```\n */\nexport class RampsService {\n /**\n * The name of the service.\n */\n readonly name: typeof serviceName;\n\n /**\n * The messenger suited for this service.\n */\n readonly #messenger: ConstructorParameters<\n typeof RampsService\n >[0]['messenger'];\n\n /**\n * A function that can be used to make an HTTP request.\n */\n readonly #fetch: ConstructorParameters<typeof RampsService>[0]['fetch'];\n\n /**\n * The policy that wraps the request.\n *\n * @see {@link createServicePolicy}\n */\n readonly #policy: ServicePolicy;\n\n /**\n * The environment used for API requests.\n */\n readonly #environment: RampsEnvironment;\n\n /**\n * The context for API requests (e.g., 'mobile-ios', 'mobile-android').\n */\n readonly #context: string;\n\n /**\n * Optional base URL override for local development.\n */\n readonly #baseUrlOverride?: string;\n\n /**\n * Constructs a new RampsService object.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this service.\n * @param args.environment - The environment to use for API requests.\n * @param args.context - The context for API requests (e.g., 'mobile-ios', 'mobile-android').\n * @param args.fetch - A function that can be used to make an HTTP request. If\n * your JavaScript environment supports `fetch` natively, you'll probably want\n * to pass that; otherwise you can pass an equivalent (such as `fetch` via\n * `node-fetch`).\n * @param args.policyOptions - Options to pass to `createServicePolicy`, which\n * is used to wrap each request. See {@link CreateServicePolicyOptions}.\n * @param args.baseUrlOverride - Optional base URL override for local development.\n */\n constructor({\n messenger,\n environment = RampsEnvironment.Staging,\n context,\n fetch: fetchFunction,\n policyOptions = {},\n baseUrlOverride,\n }: {\n messenger: RampsServiceMessenger;\n environment?: RampsEnvironment;\n context: string;\n fetch: typeof fetch;\n policyOptions?: CreateServicePolicyOptions;\n baseUrlOverride?: string;\n }) {\n this.name = serviceName;\n this.#messenger = messenger;\n this.#fetch = fetchFunction;\n this.#policy = createServicePolicy(policyOptions);\n this.#environment = environment;\n this.#context = context;\n this.#baseUrlOverride = baseUrlOverride;\n\n this.#messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Gets the base URL for API requests, respecting the baseUrlOverride if set.\n *\n * @param service - The API service type.\n * @returns The base URL to use.\n */\n #getBaseUrl(service: RampsApiService): string {\n if (this.#baseUrlOverride) {\n return this.#baseUrlOverride;\n }\n return getBaseUrl(this.#environment, service);\n }\n\n /**\n * Registers a handler that will be called after a request returns a non-500\n * response, causing a retry. Primarily useful in tests where timers are being\n * mocked.\n *\n * @param listener - The handler to be called.\n * @returns An object that can be used to unregister the handler. See\n * {@link CockatielEvent}.\n * @see {@link createServicePolicy}\n */\n onRetry(\n listener: Parameters<ServicePolicy['onRetry']>[0],\n ): ReturnType<ServicePolicy['onRetry']> {\n return this.#policy.onRetry(listener);\n }\n\n /**\n * Registers a handler that will be called after a set number of retry rounds\n * prove that requests to the API endpoint consistently return a 5xx response.\n *\n * @param listener - The handler to be called.\n * @returns An object that can be used to unregister the handler. See\n * {@link CockatielEvent}.\n * @see {@link createServicePolicy}\n */\n onBreak(\n listener: Parameters<ServicePolicy['onBreak']>[0],\n ): ReturnType<ServicePolicy['onBreak']> {\n return this.#policy.onBreak(listener);\n }\n\n /**\n * Registers a handler that will be called under one of two circumstances:\n *\n * 1. After a set number of retries prove that requests to the API\n * consistently result in one of the following failures:\n * 1. A connection initiation error\n * 2. A connection reset error\n * 3. A timeout error\n * 4. A non-JSON response\n * 5. A 502, 503, or 504 response\n * 2. After a successful request is made to the API, but the response takes\n * longer than a set duration to return.\n *\n * @param listener - The handler to be called.\n * @returns An object that can be used to unregister the handler. See\n * {@link CockatielEvent}.\n */\n onDegraded(\n listener: Parameters<ServicePolicy['onDegraded']>[0],\n ): ReturnType<ServicePolicy['onDegraded']> {\n return this.#policy.onDegraded(listener);\n }\n\n /**\n * Adds common request parameters to a URL.\n *\n * @param url - The URL to add parameters to.\n * @param action - The ramp action type (optional, not all endpoints require it).\n */\n #addCommonParams(url: URL, action?: RampAction): void {\n if (action) {\n url.searchParams.set('action', action);\n }\n url.searchParams.set('sdk', RAMPS_SDK_VERSION);\n url.searchParams.set('controller', packageJson.version);\n url.searchParams.set('context', this.#context);\n }\n\n /**\n * Makes an API request with retry policy and error handling.\n *\n * @param service - The API service type (determines base URL).\n * @param path - The endpoint path.\n * @param options - Request options.\n * @param options.action - The ramp action type (optional).\n * @param options.responseType - How to parse the response ('json' or 'text').\n * @returns The parsed response data.\n */\n async #request<TResponse>(\n service: RampsApiService,\n path: string,\n options: {\n action?: RampAction;\n responseType: 'json' | 'text';\n },\n ): Promise<TResponse> {\n return this.#policy.execute(async () => {\n const baseUrl = this.#getBaseUrl(service);\n const url = new URL(path, baseUrl);\n this.#addCommonParams(url, options.action);\n\n const response = await this.#fetch(url);\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Fetching '${url.toString()}' failed with status '${response.status}'`,\n );\n }\n\n return options.responseType === 'json'\n ? (response.json() as Promise<TResponse>)\n : (response.text() as Promise<TResponse>);\n });\n }\n\n /**\n * Makes a request to the API in order to retrieve the user's geolocation\n * based on their IP address.\n *\n * @returns The user's country/region code (e.g., \"US-UT\" for Utah, USA).\n */\n async getGeolocation(): Promise<string> {\n const textResponse = await this.#request<string>(\n RampsApiService.Orders,\n 'geolocation',\n { responseType: 'text' },\n );\n\n const trimmedResponse = textResponse.trim();\n if (trimmedResponse.length > 0) {\n return trimmedResponse;\n }\n\n throw new Error('Malformed response received from geolocation API');\n }\n\n /**\n * Makes a request to the cached API to retrieve the list of supported countries.\n * The API returns countries with support information for both buy and sell actions.\n * Filters countries based on aggregator support (preserves OnRampSDK logic).\n *\n * @returns An array of countries filtered by aggregator support.\n */\n async getCountries(): Promise<Country[]> {\n const countries = await this.#request<Country[]>(\n RampsApiService.Regions,\n getApiPath('regions/countries'),\n { responseType: 'json' },\n );\n\n if (!Array.isArray(countries)) {\n throw new Error('Malformed response received from countries API');\n }\n\n return countries.filter((country) => {\n const isCountrySupported =\n country.supported.buy || country.supported.sell;\n\n if (country.states && country.states.length > 0) {\n const hasSupportedState = country.states.some(\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- intentionally using || to treat false as unsupported\n (state) => state.supported?.buy || state.supported?.sell,\n );\n return isCountrySupported || hasSupportedState;\n }\n\n return isCountrySupported;\n });\n }\n\n /**\n * Fetches the list of available tokens for a given region and action.\n * Supports optional provider filter.\n *\n * @param region - The region code (e.g., \"us\", \"fr\", \"us-ny\").\n * @param action - The ramp action type ('buy' or 'sell').\n * @param options - Optional query parameters for filtering tokens.\n * @param options.provider - Provider ID(s) to filter by.\n * @returns The tokens response containing topTokens and allTokens.\n */\n async getTokens(\n region: string,\n action: RampAction = 'buy',\n options?: {\n provider?: string | string[];\n },\n ): Promise<TokensResponse> {\n const normalizedRegion = region.toLowerCase().trim();\n const url = new URL(\n getApiPath(`regions/${normalizedRegion}/topTokens`),\n this.#getBaseUrl(RampsApiService.Regions),\n );\n this.#addCommonParams(url, action);\n\n if (options?.provider) {\n const providerIds = Array.isArray(options.provider)\n ? options.provider\n : [options.provider];\n providerIds.forEach((id) => url.searchParams.append('provider', id));\n }\n\n const response = await this.#policy.execute(async () => {\n const fetchResponse = await this.#fetch(url);\n if (!fetchResponse.ok) {\n throw new HttpError(\n fetchResponse.status,\n `Fetching '${url.toString()}' failed with status '${fetchResponse.status}'`,\n );\n }\n return fetchResponse.json() as Promise<TokensResponse>;\n });\n\n if (!response || typeof response !== 'object') {\n throw new Error('Malformed response received from tokens API');\n }\n\n if (\n !Array.isArray(response.topTokens) ||\n !Array.isArray(response.allTokens)\n ) {\n throw new Error('Malformed response received from tokens API');\n }\n\n return response;\n }\n\n /**\n * Fetches the list of providers for a given region.\n * Supports optional query filters: provider, crypto, fiat, payments.\n *\n * @param regionCode - The region code (e.g., \"us\", \"fr\", \"us-ny\").\n * @param options - Optional query parameters for filtering providers.\n * @param options.provider - Provider ID(s) to filter by.\n * @param options.crypto - Crypto currency ID(s) to filter by.\n * @param options.fiat - Fiat currency ID(s) to filter by.\n * @param options.payments - Payment method ID(s) to filter by.\n * @returns The providers response containing providers array.\n */\n async getProviders(\n regionCode: string,\n options?: {\n provider?: string | string[];\n crypto?: string | string[];\n fiat?: string | string[];\n payments?: string | string[];\n },\n ): Promise<{ providers: Provider[] }> {\n const normalizedRegion = regionCode.toLowerCase().trim();\n const url = new URL(\n getApiPath(`regions/${normalizedRegion}/providers`),\n this.#getBaseUrl(RampsApiService.Regions),\n );\n this.#addCommonParams(url);\n\n if (options?.provider) {\n const providerIds = Array.isArray(options.provider)\n ? options.provider\n : [options.provider];\n providerIds.forEach((id) => url.searchParams.append('provider', id));\n }\n\n if (options?.crypto) {\n const cryptoIds = Array.isArray(options.crypto)\n ? options.crypto\n : [options.crypto];\n cryptoIds.forEach((id) => url.searchParams.append('crypto', id));\n }\n\n if (options?.fiat) {\n const fiatIds = Array.isArray(options.fiat)\n ? options.fiat\n : [options.fiat];\n fiatIds.forEach((id) => url.searchParams.append('fiat', id));\n }\n\n if (options?.payments) {\n const paymentIds = Array.isArray(options.payments)\n ? options.payments\n : [options.payments];\n paymentIds.forEach((id) => url.searchParams.append('payments', id));\n }\n\n const response = await this.#policy.execute(async () => {\n const fetchResponse = await this.#fetch(url);\n if (!fetchResponse.ok) {\n throw new HttpError(\n fetchResponse.status,\n `Fetching '${url.toString()}' failed with status '${fetchResponse.status}'`,\n );\n }\n return fetchResponse.json() as Promise<{ providers: Provider[] }>;\n });\n\n if (!response || typeof response !== 'object') {\n throw new Error('Malformed response received from providers API');\n }\n\n if (!Array.isArray(response.providers)) {\n throw new Error('Malformed response received from providers API');\n }\n\n return response;\n }\n\n /**\n * Fetches the list of payment methods for a given region, asset, and provider.\n *\n * @param options - Query parameters for filtering payment methods.\n * @param options.region - User's region code (e.g., \"us-al\").\n * @param options.fiat - Fiat currency code (e.g., \"usd\").\n * @param options.assetId - CAIP-19 cryptocurrency identifier.\n * @param options.provider - Provider ID path.\n * @returns The payment methods response containing payments array.\n */\n async getPaymentMethods(options: {\n region: string;\n fiat: string;\n assetId: string;\n provider: string;\n }): Promise<PaymentMethodsResponse> {\n const normalizedRegion = options.region.toLowerCase().trim();\n const url = new URL(\n getApiPath(`regions/${normalizedRegion}/payments`),\n this.#getBaseUrl(RampsApiService.Regions),\n );\n this.#addCommonParams(url);\n\n url.searchParams.set('region', options.region.toLowerCase().trim());\n url.searchParams.set('fiat', options.fiat.toLowerCase().trim());\n url.searchParams.set('crypto', options.assetId);\n url.searchParams.set('provider', options.provider);\n\n const response = await this.#policy.execute(async () => {\n const fetchResponse = await this.#fetch(url);\n if (!fetchResponse.ok) {\n throw new HttpError(\n fetchResponse.status,\n `Fetching '${url.toString()}' failed with status '${fetchResponse.status}'`,\n );\n }\n return fetchResponse.json() as Promise<PaymentMethodsResponse>;\n });\n\n if (!response || typeof response !== 'object') {\n throw new Error('Malformed response received from paymentMethods API');\n }\n\n if (!Array.isArray(response.payments)) {\n throw new Error('Malformed response received from paymentMethods API');\n }\n\n return response;\n }\n\n /**\n * Fetches quotes from all providers for a given set of parameters.\n * Uses the V2 orders API to get quotes for multiple payment methods at once.\n *\n * @param params - The parameters for fetching quotes.\n * @param params.region - User's region code (e.g., \"us\", \"us-ca\").\n * @param params.paymentMethods - Array of payment method IDs.\n * @param params.assetId - CAIP-19 cryptocurrency identifier.\n * @param params.fiat - Fiat currency code (e.g., \"usd\").\n * @param params.amount - The amount (in fiat for buy, crypto for sell).\n * @param params.walletAddress - The destination wallet address.\n * @param params.redirectUrl - Optional redirect URL after order completion.\n * @param params.provider - Optional provider ID to filter quotes.\n * @param params.action - The ramp action type. Defaults to 'buy'.\n * @returns The quotes response containing success, sorted, error, and customActions.\n */\n async getQuotes(params: GetQuotesParams): Promise<QuotesResponse> {\n const normalizedRegion = params.region.toLowerCase().trim();\n const normalizedFiat = params.fiat.toLowerCase().trim();\n const action = params.action ?? 'buy';\n\n const url = new URL(\n getApiPath('quotes'),\n getBaseUrl(this.#environment, RampsApiService.Orders),\n );\n this.#addCommonParams(url, action);\n\n // Build region ID in the format expected by the API\n url.searchParams.set('region', normalizedRegion);\n url.searchParams.set('fiat', normalizedFiat);\n url.searchParams.set('crypto', params.assetId);\n url.searchParams.set('amount', String(params.amount));\n url.searchParams.set('walletAddress', params.walletAddress);\n\n // Add payment methods as array parameters\n params.paymentMethods.forEach((paymentMethod) => {\n url.searchParams.append('payments', paymentMethod);\n });\n\n // Add provider filter if specified\n if (params.provider) {\n url.searchParams.append('providers', params.provider);\n }\n\n // Add redirect URL if specified\n if (params.redirectUrl) {\n url.searchParams.set('redirectUrl', params.redirectUrl);\n }\n\n const response = await this.#policy.execute(async () => {\n const fetchResponse = await this.#fetch(url);\n if (!fetchResponse.ok) {\n throw new HttpError(\n fetchResponse.status,\n `Fetching '${url.toString()}' failed with status '${fetchResponse.status}'`,\n );\n }\n return fetchResponse.json() as Promise<QuotesResponse>;\n });\n\n if (!response || typeof response !== 'object') {\n throw new Error('Malformed response received from quotes API');\n }\n\n if (\n !Array.isArray(response.success) ||\n !Array.isArray(response.sorted) ||\n !Array.isArray(response.error) ||\n !Array.isArray(response.customActions)\n ) {\n throw new Error('Malformed response received from quotes API');\n }\n\n return response;\n }\n}\n"]}
{"version":3,"file":"RampsService.cjs","sourceRoot":"","sources":["../src/RampsService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAIA,iEAA4E;AAI5E,mEAA0C;AA4d1C;;GAEG;A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;QACnC,uBAAA,IAAI,8DAAiB,MAArB,IAAI,EAAkB,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAE3C,MAAM,QAAQ,GAAG,MAAM,uBAAA,IAAI,2BAAO,MAAX,IAAI,EAAQ,GAAG,CAAC,CAAC;QACxC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,4BAAS,CACjB,QAAQ,CAAC,MAAM,EACf,aAAa,GAAG,CAAC,QAAQ,EAAE,yBAAyB,QAAQ,CAAC,MAAM,GAAG,CACvE,CAAC;QACJ,CAAC;QAED,OAAO,OAAO,CAAC,YAAY,KAAK,MAAM;YACpC,CAAC,CAAE,QAAQ,CAAC,IAAI,EAAyB;YACzC,CAAC,CAAE,QAAQ,CAAC,IAAI,EAAyB,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type {\n CreateServicePolicyOptions,\n ServicePolicy,\n} from '@metamask/controller-utils';\nimport { createServicePolicy, HttpError } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\n\nimport type { RampsServiceMethodActions } from './RampsService-method-action-types';\nimport packageJson from '../package.json';\n\n/**\n * Represents phone number information for a country.\n */\nexport type CountryPhone = {\n prefix: string;\n placeholder: string;\n template: string;\n};\n\n/**\n * Indicates whether a region supports buy and/or sell actions.\n */\nexport type SupportedActions = {\n /**\n * Whether buy actions are supported.\n */\n buy: boolean;\n /**\n * Whether sell actions are supported.\n */\n sell: boolean;\n};\n\n/**\n * Represents a state/province within a country.\n */\nexport type State = {\n /**\n * State identifier. Can be in path format (e.g., \"/regions/us-ut\") or ISO code format (e.g., \"us-ut\").\n */\n id?: string;\n /**\n * State name.\n */\n name?: string;\n /**\n * ISO state code (e.g., \"UT\", \"NY\").\n */\n stateId?: string;\n /**\n * Whether this state is supported for buy and/or sell ramp actions.\n */\n supported?: SupportedActions;\n /**\n * Whether this state is recommended.\n */\n recommended?: boolean;\n};\n\n/**\n * Represents a provider link.\n */\nexport type ProviderLink = {\n name: string;\n url: string;\n};\n\n/**\n * Represents provider logos.\n */\nexport type ProviderLogos = {\n light: string;\n dark: string;\n height: number;\n width: number;\n};\n\n/**\n * Browser type for provider buy features.\n */\nexport type ProviderBrowserType = 'APP_BROWSER' | 'IN_APP_OS_BROWSER' | null;\n\n/**\n * Represents a ramp provider.\n */\nexport type Provider = {\n id: string;\n name: string;\n environmentType: string;\n description: string;\n hqAddress: string;\n links: ProviderLink[];\n logos: ProviderLogos;\n supportedCryptoCurrencies?: Record<string, boolean>;\n supportedFiatCurrencies?: Record<string, boolean>;\n supportedPaymentMethods?: Record<string, boolean>;\n};\n\n/**\n * Represents a payment method for funding a purchase.\n */\nexport type PaymentMethod = {\n /**\n * Canonical payment method ID (e.g., \"/payments/debit-credit-card\").\n */\n id: string;\n /**\n * Payment type identifier (e.g., \"debit-credit-card\", \"bank-transfer\").\n */\n paymentType: string;\n /**\n * User-facing name for the payment method.\n */\n name: string;\n /**\n * Score for sorting payment methods (higher is better).\n */\n score: number;\n /**\n * Icon identifier for the payment method.\n */\n icon: string;\n /**\n * Localized disclaimer text (optional).\n */\n disclaimer?: string;\n /**\n * Delay in minutes (e.g., [5, 10]).\n */\n delay?: number[];\n /**\n * Localized pending order description (optional).\n */\n pendingOrderDescription?: string;\n};\n\n/**\n * Response from the paymentMethods API.\n */\nexport type PaymentMethodsResponse = {\n /**\n * List of available payment methods.\n */\n payments: PaymentMethod[];\n /**\n * Recommended sorting for payment methods.\n */\n sort?: {\n ids: string[];\n sortBy: string;\n };\n};\n\n// === QUOTES TYPES ===\n\n/**\n * Sort criteria for quotes.\n */\nexport type QuoteSortBy = 'price' | 'reliability';\n\n/**\n * Represents crypto translation info for a quote.\n */\nexport type QuoteCryptoTranslation = {\n /**\n * The crypto currency ID.\n */\n id?: string;\n /**\n * The crypto symbol.\n */\n symbol?: string;\n /**\n * The chain ID.\n */\n chainId?: string;\n};\n\n/**\n * Widget information for executing a buy order.\n */\nexport type BuyWidget = {\n /**\n * The widget URL to open for the user to complete the purchase.\n */\n url: string;\n /**\n * The browser type to use for opening the widget.\n */\n browser?: ProviderBrowserType;\n /**\n * Order ID if already created.\n */\n orderId?: string | null;\n};\n\n/**\n * Represents an individual quote from a provider.\n */\nexport type Quote = {\n /**\n * The provider ID (e.g., \"/providers/moonpay\").\n */\n provider: string;\n /**\n * The quote details.\n */\n quote: {\n /**\n * The amount the user is paying (in fiat for buy, crypto for sell).\n */\n amountIn: number | string;\n /**\n * The amount the user will receive (in crypto for buy, fiat for sell).\n */\n amountOut: number | string;\n /**\n * The payment method used for this quote.\n */\n paymentMethod: string;\n /**\n * The fiat value of the output amount (for buy actions).\n */\n amountOutInFiat?: number;\n /**\n * Crypto translation info for display.\n */\n cryptoTranslation?: QuoteCryptoTranslation;\n /**\n * Total fees in the source currency.\n */\n totalFees?: number | string;\n /**\n * Network fees.\n */\n networkFee?: number | string;\n /**\n * Provider fees.\n */\n providerFee?: number | string;\n /**\n * Buy URL endpoint that returns the actual provider widget URL.\n * This is a MetaMask-hosted endpoint that, when fetched, returns JSON with the provider's widget URL.\n */\n buyURL?: string;\n };\n /**\n * Metadata about the quote.\n */\n metadata?: {\n /**\n * Reliability score for the provider (0-100).\n */\n reliability?: number;\n /**\n * Tags for the quote.\n */\n tags?: {\n /**\n * Whether this is the best rate quote.\n */\n isBestRate?: boolean;\n /**\n * Whether this is the most reliable provider.\n */\n isMostReliable?: boolean;\n };\n };\n};\n\n/**\n * Represents an error from a provider when fetching quotes.\n */\nexport type QuoteError = {\n /**\n * The provider ID that failed.\n */\n provider: string;\n /**\n * Error message.\n */\n error?: string;\n};\n\n/**\n * Sort order information for quotes.\n */\nexport type QuoteSortOrder = {\n /**\n * The sort criteria.\n */\n sortBy: QuoteSortBy;\n /**\n * Provider IDs in sorted order.\n */\n ids: string[];\n};\n\n/**\n * Custom action for a provider (e.g., Apple Pay).\n */\nexport type QuoteCustomAction = {\n /**\n * Buy action details.\n */\n buy: {\n /**\n * Provider ID.\n */\n providerId: string;\n };\n /**\n * Payment method ID this action applies to.\n */\n paymentMethodId: string;\n /**\n * Supported payment method IDs.\n */\n supportedPaymentMethodIds: string[];\n};\n\n/**\n * Response from the quotes API.\n */\nexport type QuotesResponse = {\n /**\n * Successfully retrieved quotes.\n */\n success: Quote[];\n /**\n * Sort orders for the quotes.\n */\n sorted: QuoteSortOrder[];\n /**\n * Errors from providers that failed to return quotes.\n */\n error: QuoteError[];\n /**\n * Custom actions available from providers.\n */\n customActions: QuoteCustomAction[];\n};\n\n/**\n * Parameters for fetching quotes.\n */\nexport type GetQuotesParams = {\n /**\n * The region code (e.g., \"us\", \"us-ca\").\n */\n region: string;\n /**\n * Array of payment method IDs to get quotes for.\n */\n paymentMethods: string[];\n /**\n * The CAIP-19 asset ID (e.g., \"eip155:1/erc20:0x...\").\n */\n assetId: string;\n /**\n * The fiat currency code (e.g., \"usd\").\n */\n fiat: string;\n /**\n * The amount (in fiat for buy, crypto for sell).\n */\n amount: number;\n /**\n * The destination wallet address.\n */\n walletAddress: string;\n /**\n * Optional redirect URL after order completion.\n */\n redirectUrl?: string;\n /**\n * Optional provider IDs to filter quotes.\n */\n providers?: string[];\n /**\n * The ramp action type. Defaults to 'buy'.\n */\n action?: RampAction;\n};\n\n/**\n * Represents a country returned from the regions/countries API.\n */\nexport type Country = {\n /**\n * ISO-2 country code (e.g., \"US\", \"GB\").\n */\n isoCode: string;\n /**\n * Country identifier. Can be in path format (e.g., \"/regions/us\") or ISO code format.\n * If not provided, defaults to isoCode.\n */\n id?: string;\n /**\n * Country flag emoji or code.\n */\n flag: string;\n /**\n * Country name.\n */\n name: string;\n /**\n * Phone number information.\n */\n phone: CountryPhone;\n /**\n * Default currency code.\n */\n currency: string;\n /**\n * Whether this country is supported for buy and/or sell ramp actions.\n */\n supported: SupportedActions;\n /**\n * Whether this country is recommended.\n */\n recommended?: boolean;\n /**\n * Array of state objects.\n */\n states?: State[];\n /**\n * Default amount for ramps transactions.\n */\n defaultAmount?: number;\n /**\n * Quick amount options for ramps transactions.\n */\n quickAmounts?: number[];\n};\n\n/**\n * Represents a token returned from the regions/{region}/tokens API.\n */\nexport type RampsToken = {\n /**\n * The asset identifier in CAIP-19 format (e.g., \"eip155:1/erc20:0x...\").\n */\n assetId: string;\n /**\n * The chain identifier in CAIP-2 format (e.g., \"eip155:1\").\n */\n chainId: string;\n /**\n * Token name (e.g., \"USD Coin\").\n */\n name: string;\n /**\n * Token symbol (e.g., \"USDC\").\n */\n symbol: string;\n /**\n * Number of decimals for the token.\n */\n decimals: number;\n /**\n * URL to the token icon.\n */\n iconUrl: string;\n /**\n * Whether this token is supported.\n */\n tokenSupported: boolean;\n};\n\n/**\n * Response from the regions/{region}/tokens API.\n */\nexport type TokensResponse = {\n /**\n * Top/popular tokens for the region.\n */\n topTokens: RampsToken[];\n /**\n * All available tokens for the region.\n */\n allTokens: RampsToken[];\n};\n\n/**\n * The SDK version to send with API requests. (backwards-compatibility)\n */\nexport const RAMPS_SDK_VERSION = '2.1.6';\n\n/**\n * The type of ramp action: 'buy' or 'sell'.\n */\nexport type RampAction = 'buy' | 'sell';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link RampsService}, used to namespace the\n * service's actions and events.\n */\nexport const serviceName = 'RampsService';\n\n/**\n * The environment to use for API requests.\n */\nexport enum RampsEnvironment {\n Production = 'production',\n Staging = 'staging',\n Development = 'development',\n Local = 'local',\n}\n\n/**\n * The type of ramps API service.\n * Determines which base URL to use (cache vs standard).\n */\nexport enum RampsApiService {\n Regions = 'regions',\n Orders = 'orders',\n}\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'getGeolocation',\n 'getCountries',\n 'getTokens',\n 'getProviders',\n 'getPaymentMethods',\n 'getQuotes',\n 'getBuyWidgetUrl',\n] as const;\n\n/**\n * Actions that {@link RampsService} exposes to other consumers.\n */\nexport type RampsServiceActions = RampsServiceMethodActions;\n\n/**\n * Actions from other messengers that {@link RampsService} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Events that {@link RampsService} exposes to other consumers.\n */\nexport type RampsServiceEvents = never;\n\n/**\n * Events from other messengers that {@link RampsService} subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger which is restricted to actions and events accessed by\n * {@link RampsService}.\n */\nexport type RampsServiceMessenger = Messenger<\n typeof serviceName,\n RampsServiceActions | AllowedActions,\n RampsServiceEvents | AllowedEvents\n>;\n\n// === SERVICE DEFINITION ===\n\n/**\n * Gets the base URL for API requests based on the environment and service type.\n * The Regions service uses a cache URL, while other services use the standard URL.\n *\n * @param environment - The environment to use.\n * @param service - The API service type (determines if cache URL is used).\n * @returns The base URL for API requests.\n */\nfunction getBaseUrl(\n environment: RampsEnvironment,\n service: RampsApiService,\n): string {\n const cache = service === RampsApiService.Regions ? '-cache' : '';\n\n switch (environment) {\n case RampsEnvironment.Production:\n return `https://on-ramp${cache}.api.cx.metamask.io`;\n case RampsEnvironment.Staging:\n case RampsEnvironment.Development:\n return `https://on-ramp${cache}.uat-api.cx.metamask.io`;\n case RampsEnvironment.Local:\n return 'http://localhost:3000';\n default:\n throw new Error(`Invalid environment: ${String(environment)}`);\n }\n}\n\n/**\n * Constructs an API path with a version prefix.\n *\n * @param path - The API endpoint path.\n * @param version - The API version prefix. Defaults to 'v2'.\n * @returns The versioned API path.\n */\nfunction getApiPath(path: string, version: string = 'v2'): string {\n return `${version}/${path}`;\n}\n\n/**\n * This service object is responsible for interacting with the Ramps API.\n *\n * @example\n *\n * ``` ts\n * import { Messenger } from '@metamask/messenger';\n * import type {\n * RampsServiceActions,\n * RampsServiceEvents,\n * } from '@metamask/ramps-controller';\n *\n * const rootMessenger = new Messenger<\n * 'Root',\n * RampsServiceActions\n * RampsServiceEvents\n * >({ namespace: 'Root' });\n * const rampsServiceMessenger = new Messenger<\n * 'RampsService',\n * RampsServiceActions,\n * RampsServiceEvents,\n * typeof rootMessenger,\n * >({\n * namespace: 'RampsService',\n * parent: rootMessenger,\n * });\n * // Instantiate the service to register its actions on the messenger\n * new RampsService({\n * messenger: rampsServiceMessenger,\n * environment: RampsEnvironment.Production,\n * context: 'mobile-ios',\n * fetch,\n * });\n *\n * // Later...\n * // Get the user's geolocation\n * const geolocation = await rootMessenger.call(\n * 'RampsService:getGeolocation',\n * );\n * // ... Do something with the geolocation ...\n * ```\n */\nexport class RampsService {\n /**\n * The name of the service.\n */\n readonly name: typeof serviceName;\n\n /**\n * The messenger suited for this service.\n */\n readonly #messenger: ConstructorParameters<\n typeof RampsService\n >[0]['messenger'];\n\n /**\n * A function that can be used to make an HTTP request.\n */\n readonly #fetch: ConstructorParameters<typeof RampsService>[0]['fetch'];\n\n /**\n * The policy that wraps the request.\n *\n * @see {@link createServicePolicy}\n */\n readonly #policy: ServicePolicy;\n\n /**\n * The environment used for API requests.\n */\n readonly #environment: RampsEnvironment;\n\n /**\n * The context for API requests (e.g., 'mobile-ios', 'mobile-android').\n */\n readonly #context: string;\n\n /**\n * Optional base URL override for local development.\n */\n readonly #baseUrlOverride?: string;\n\n /**\n * Constructs a new RampsService object.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this service.\n * @param args.environment - The environment to use for API requests.\n * @param args.context - The context for API requests (e.g., 'mobile-ios', 'mobile-android').\n * @param args.fetch - A function that can be used to make an HTTP request. If\n * your JavaScript environment supports `fetch` natively, you'll probably want\n * to pass that; otherwise you can pass an equivalent (such as `fetch` via\n * `node-fetch`).\n * @param args.policyOptions - Options to pass to `createServicePolicy`, which\n * is used to wrap each request. See {@link CreateServicePolicyOptions}.\n * @param args.baseUrlOverride - Optional base URL override for local development.\n */\n constructor({\n messenger,\n environment = RampsEnvironment.Staging,\n context,\n fetch: fetchFunction,\n policyOptions = {},\n baseUrlOverride,\n }: {\n messenger: RampsServiceMessenger;\n environment?: RampsEnvironment;\n context: string;\n fetch: typeof fetch;\n policyOptions?: CreateServicePolicyOptions;\n baseUrlOverride?: string;\n }) {\n this.name = serviceName;\n this.#messenger = messenger;\n this.#fetch = fetchFunction;\n this.#policy = createServicePolicy(policyOptions);\n this.#environment = environment;\n this.#context = context;\n this.#baseUrlOverride = baseUrlOverride;\n\n this.#messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Gets the base URL for API requests, respecting the baseUrlOverride if set.\n *\n * @param service - The API service type.\n * @returns The base URL to use.\n */\n #getBaseUrl(service: RampsApiService): string {\n if (this.#baseUrlOverride) {\n return this.#baseUrlOverride;\n }\n return getBaseUrl(this.#environment, service);\n }\n\n /**\n * Registers a handler that will be called after a request returns a non-500\n * response, causing a retry. Primarily useful in tests where timers are being\n * mocked.\n *\n * @param listener - The handler to be called.\n * @returns An object that can be used to unregister the handler. See\n * {@link CockatielEvent}.\n * @see {@link createServicePolicy}\n */\n onRetry(\n listener: Parameters<ServicePolicy['onRetry']>[0],\n ): ReturnType<ServicePolicy['onRetry']> {\n return this.#policy.onRetry(listener);\n }\n\n /**\n * Registers a handler that will be called after a set number of retry rounds\n * prove that requests to the API endpoint consistently return a 5xx response.\n *\n * @param listener - The handler to be called.\n * @returns An object that can be used to unregister the handler. See\n * {@link CockatielEvent}.\n * @see {@link createServicePolicy}\n */\n onBreak(\n listener: Parameters<ServicePolicy['onBreak']>[0],\n ): ReturnType<ServicePolicy['onBreak']> {\n return this.#policy.onBreak(listener);\n }\n\n /**\n * Registers a handler that will be called under one of two circumstances:\n *\n * 1. After a set number of retries prove that requests to the API\n * consistently result in one of the following failures:\n * 1. A connection initiation error\n * 2. A connection reset error\n * 3. A timeout error\n * 4. A non-JSON response\n * 5. A 502, 503, or 504 response\n * 2. After a successful request is made to the API, but the response takes\n * longer than a set duration to return.\n *\n * @param listener - The handler to be called.\n * @returns An object that can be used to unregister the handler. See\n * {@link CockatielEvent}.\n */\n onDegraded(\n listener: Parameters<ServicePolicy['onDegraded']>[0],\n ): ReturnType<ServicePolicy['onDegraded']> {\n return this.#policy.onDegraded(listener);\n }\n\n /**\n * Adds common request parameters to a URL.\n *\n * @param url - The URL to add parameters to.\n * @param action - The ramp action type (optional, not all endpoints require it).\n */\n #addCommonParams(url: URL, action?: RampAction): void {\n if (action) {\n url.searchParams.set('action', action);\n }\n url.searchParams.set('sdk', RAMPS_SDK_VERSION);\n url.searchParams.set('controller', packageJson.version);\n url.searchParams.set('context', this.#context);\n }\n\n /**\n * Makes an API request with retry policy and error handling.\n *\n * @param service - The API service type (determines base URL).\n * @param path - The endpoint path.\n * @param options - Request options.\n * @param options.action - The ramp action type (optional).\n * @param options.responseType - How to parse the response ('json' or 'text').\n * @returns The parsed response data.\n */\n async #request<TResponse>(\n service: RampsApiService,\n path: string,\n options: {\n action?: RampAction;\n responseType: 'json' | 'text';\n },\n ): Promise<TResponse> {\n return this.#policy.execute(async () => {\n const baseUrl = this.#getBaseUrl(service);\n const url = new URL(path, baseUrl);\n this.#addCommonParams(url, options.action);\n\n const response = await this.#fetch(url);\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Fetching '${url.toString()}' failed with status '${response.status}'`,\n );\n }\n\n return options.responseType === 'json'\n ? (response.json() as Promise<TResponse>)\n : (response.text() as Promise<TResponse>);\n });\n }\n\n /**\n * Makes a request to the API in order to retrieve the user's geolocation\n * based on their IP address.\n *\n * @returns The user's country/region code (e.g., \"US-UT\" for Utah, USA).\n */\n async getGeolocation(): Promise<string> {\n const textResponse = await this.#request<string>(\n RampsApiService.Orders,\n 'geolocation',\n { responseType: 'text' },\n );\n\n const trimmedResponse = textResponse.trim();\n if (trimmedResponse.length > 0) {\n return trimmedResponse;\n }\n\n throw new Error('Malformed response received from geolocation API');\n }\n\n /**\n * Makes a request to the cached API to retrieve the list of supported countries.\n * The API returns countries with support information for both buy and sell actions.\n * Filters countries based on aggregator support (preserves OnRampSDK logic).\n *\n * @returns An array of countries filtered by aggregator support.\n */\n async getCountries(): Promise<Country[]> {\n const countries = await this.#request<Country[]>(\n RampsApiService.Regions,\n getApiPath('regions/countries'),\n { responseType: 'json' },\n );\n\n if (!Array.isArray(countries)) {\n throw new Error('Malformed response received from countries API');\n }\n\n return countries.filter((country) => {\n const isCountrySupported =\n country.supported.buy || country.supported.sell;\n\n if (country.states && country.states.length > 0) {\n const hasSupportedState = country.states.some(\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- intentionally using || to treat false as unsupported\n (state) => state.supported?.buy || state.supported?.sell,\n );\n return isCountrySupported || hasSupportedState;\n }\n\n return isCountrySupported;\n });\n }\n\n /**\n * Fetches the list of available tokens for a given region and action.\n * Supports optional provider filter.\n *\n * @param region - The region code (e.g., \"us\", \"fr\", \"us-ny\").\n * @param action - The ramp action type ('buy' or 'sell').\n * @param options - Optional query parameters for filtering tokens.\n * @param options.provider - Provider ID(s) to filter by.\n * @returns The tokens response containing topTokens and allTokens.\n */\n async getTokens(\n region: string,\n action: RampAction = 'buy',\n options?: {\n provider?: string | string[];\n },\n ): Promise<TokensResponse> {\n const normalizedRegion = region.toLowerCase().trim();\n const url = new URL(\n getApiPath(`regions/${normalizedRegion}/topTokens`),\n this.#getBaseUrl(RampsApiService.Regions),\n );\n this.#addCommonParams(url, action);\n\n if (options?.provider) {\n const providerIds = Array.isArray(options.provider)\n ? options.provider\n : [options.provider];\n providerIds.forEach((id) => url.searchParams.append('provider', id));\n }\n\n const response = await this.#policy.execute(async () => {\n const fetchResponse = await this.#fetch(url);\n if (!fetchResponse.ok) {\n throw new HttpError(\n fetchResponse.status,\n `Fetching '${url.toString()}' failed with status '${fetchResponse.status}'`,\n );\n }\n return fetchResponse.json() as Promise<TokensResponse>;\n });\n\n if (!response || typeof response !== 'object') {\n throw new Error('Malformed response received from tokens API');\n }\n\n if (\n !Array.isArray(response.topTokens) ||\n !Array.isArray(response.allTokens)\n ) {\n throw new Error('Malformed response received from tokens API');\n }\n\n return response;\n }\n\n /**\n * Fetches the list of providers for a given region.\n * Supports optional query filters: provider, crypto, fiat, payments.\n *\n * @param regionCode - The region code (e.g., \"us\", \"fr\", \"us-ny\").\n * @param options - Optional query parameters for filtering providers.\n * @param options.provider - Provider ID(s) to filter by.\n * @param options.crypto - Crypto currency ID(s) to filter by.\n * @param options.fiat - Fiat currency ID(s) to filter by.\n * @param options.payments - Payment method ID(s) to filter by.\n * @returns The providers response containing providers array.\n */\n async getProviders(\n regionCode: string,\n options?: {\n provider?: string | string[];\n crypto?: string | string[];\n fiat?: string | string[];\n payments?: string | string[];\n },\n ): Promise<{ providers: Provider[] }> {\n const normalizedRegion = regionCode.toLowerCase().trim();\n const url = new URL(\n getApiPath(`regions/${normalizedRegion}/providers`),\n this.#getBaseUrl(RampsApiService.Regions),\n );\n this.#addCommonParams(url);\n\n if (options?.provider) {\n const providerIds = Array.isArray(options.provider)\n ? options.provider\n : [options.provider];\n providerIds.forEach((id) => url.searchParams.append('provider', id));\n }\n\n if (options?.crypto) {\n const cryptoIds = Array.isArray(options.crypto)\n ? options.crypto\n : [options.crypto];\n cryptoIds.forEach((id) => url.searchParams.append('crypto', id));\n }\n\n if (options?.fiat) {\n const fiatIds = Array.isArray(options.fiat)\n ? options.fiat\n : [options.fiat];\n fiatIds.forEach((id) => url.searchParams.append('fiat', id));\n }\n\n if (options?.payments) {\n const paymentIds = Array.isArray(options.payments)\n ? options.payments\n : [options.payments];\n paymentIds.forEach((id) => url.searchParams.append('payments', id));\n }\n\n const response = await this.#policy.execute(async () => {\n const fetchResponse = await this.#fetch(url);\n if (!fetchResponse.ok) {\n throw new HttpError(\n fetchResponse.status,\n `Fetching '${url.toString()}' failed with status '${fetchResponse.status}'`,\n );\n }\n return fetchResponse.json() as Promise<{ providers: Provider[] }>;\n });\n\n if (!response || typeof response !== 'object') {\n throw new Error('Malformed response received from providers API');\n }\n\n if (!Array.isArray(response.providers)) {\n throw new Error('Malformed response received from providers API');\n }\n\n return response;\n }\n\n /**\n * Fetches the list of payment methods for a given region, asset, and provider.\n *\n * @param options - Query parameters for filtering payment methods.\n * @param options.region - User's region code (e.g., \"us-al\").\n * @param options.fiat - Fiat currency code (e.g., \"usd\").\n * @param options.assetId - CAIP-19 cryptocurrency identifier.\n * @param options.provider - Provider ID path.\n * @returns The payment methods response containing payments array.\n */\n async getPaymentMethods(options: {\n region: string;\n fiat: string;\n assetId: string;\n provider: string;\n }): Promise<PaymentMethodsResponse> {\n const normalizedRegion = options.region.toLowerCase().trim();\n const url = new URL(\n getApiPath(`regions/${normalizedRegion}/payments`),\n this.#getBaseUrl(RampsApiService.Regions),\n );\n this.#addCommonParams(url);\n\n url.searchParams.set('region', options.region.toLowerCase().trim());\n url.searchParams.set('fiat', options.fiat.toLowerCase().trim());\n url.searchParams.set('crypto', options.assetId);\n url.searchParams.set('provider', options.provider);\n\n const response = await this.#policy.execute(async () => {\n const fetchResponse = await this.#fetch(url);\n if (!fetchResponse.ok) {\n throw new HttpError(\n fetchResponse.status,\n `Fetching '${url.toString()}' failed with status '${fetchResponse.status}'`,\n );\n }\n return fetchResponse.json() as Promise<PaymentMethodsResponse>;\n });\n\n if (!response || typeof response !== 'object') {\n throw new Error('Malformed response received from paymentMethods API');\n }\n\n if (!Array.isArray(response.payments)) {\n throw new Error('Malformed response received from paymentMethods API');\n }\n\n return response;\n }\n\n /**\n * Fetches quotes from all providers for a given set of parameters.\n * Uses the V2 orders API to get quotes for multiple payment methods at once.\n *\n * @param params - The parameters for fetching quotes.\n * @param params.region - User's region code (e.g., \"us\", \"us-ca\").\n * @param params.paymentMethods - Array of payment method IDs.\n * @param params.assetId - CAIP-19 cryptocurrency identifier.\n * @param params.fiat - Fiat currency code (e.g., \"usd\").\n * @param params.amount - The amount (in fiat for buy, crypto for sell).\n * @param params.walletAddress - The destination wallet address.\n * @param params.redirectUrl - Optional redirect URL after order completion.\n * @param params.providers - Optional provider IDs to filter quotes.\n * @param params.action - The ramp action type. Defaults to 'buy'.\n * @returns The quotes response containing success, sorted, error, and customActions.\n */\n async getQuotes(params: GetQuotesParams): Promise<QuotesResponse> {\n const normalizedRegion = params.region.toLowerCase().trim();\n const normalizedFiat = params.fiat.toLowerCase().trim();\n const action = params.action ?? 'buy';\n\n const url = new URL(\n getApiPath('quotes'),\n getBaseUrl(this.#environment, RampsApiService.Orders),\n );\n this.#addCommonParams(url, action);\n\n // Build region ID in the format expected by the API\n url.searchParams.set('region', normalizedRegion);\n url.searchParams.set('fiat', normalizedFiat);\n url.searchParams.set('crypto', params.assetId);\n url.searchParams.set('amount', String(params.amount));\n url.searchParams.set('walletAddress', params.walletAddress);\n\n // Add payment methods as array parameters\n params.paymentMethods.forEach((paymentMethod) => {\n url.searchParams.append('payments', paymentMethod);\n });\n\n // Add provider filter if specified\n params.providers?.forEach((provider) => {\n url.searchParams.append('providers', provider);\n });\n\n // Add redirect URL if specified\n if (params.redirectUrl) {\n url.searchParams.set('redirectUrl', params.redirectUrl);\n }\n\n const response = await this.#policy.execute(async () => {\n const fetchResponse = await this.#fetch(url);\n if (!fetchResponse.ok) {\n throw new HttpError(\n fetchResponse.status,\n `Fetching '${url.toString()}' failed with status '${fetchResponse.status}'`,\n );\n }\n return fetchResponse.json() as Promise<QuotesResponse>;\n });\n\n if (!response || typeof response !== 'object') {\n throw new Error('Malformed response received from quotes API');\n }\n\n if (\n !Array.isArray(response.success) ||\n !Array.isArray(response.sorted) ||\n !Array.isArray(response.error) ||\n !Array.isArray(response.customActions)\n ) {\n throw new Error('Malformed response received from quotes API');\n }\n\n return response;\n }\n\n /**\n * Fetches the buy widget data from a buy URL endpoint.\n * Makes a request to the buyURL (as provided in a quote) to get the actual\n * provider widget URL, browser type, and order ID.\n *\n * @param buyUrl - The full buy URL endpoint to fetch from.\n * @returns The buy widget data containing the provider widget URL.\n */\n async getBuyWidgetUrl(buyUrl: string): Promise<BuyWidget> {\n const url = new URL(buyUrl);\n this.#addCommonParams(url);\n\n const response = await this.#policy.execute(async () => {\n const fetchResponse = await this.#fetch(url);\n if (!fetchResponse.ok) {\n throw new HttpError(\n fetchResponse.status,\n `Fetching '${url.toString()}' failed with status '${fetchResponse.status}'`,\n );\n }\n return fetchResponse.json() as Promise<BuyWidget>;\n });\n\n if (!response || typeof response !== 'object' || !response.url) {\n throw new Error('Malformed response received from buy widget URL API');\n }\n\n return response;\n }\n}\n"]}

@@ -67,2 +67,6 @@ import type { CreateServicePolicyOptions, ServicePolicy } from "@metamask/controller-utils";

/**
* Browser type for provider buy features.
*/
export type ProviderBrowserType = 'APP_BROWSER' | 'IN_APP_OS_BROWSER' | null;
/**
* Represents a ramp provider.

@@ -157,2 +161,19 @@ */

/**
* Widget information for executing a buy order.
*/
export type BuyWidget = {
/**
* The widget URL to open for the user to complete the purchase.
*/
url: string;
/**
* The browser type to use for opening the widget.
*/
browser?: ProviderBrowserType;
/**
* Order ID if already created.
*/
orderId?: string | null;
};
/**
* Represents an individual quote from a provider.

@@ -186,6 +207,2 @@ */

/**
* The widget URL for redirect providers.
*/
widgetUrl?: string;
/**
* Crypto translation info for display.

@@ -206,2 +223,7 @@ */

providerFee?: number | string;
/**
* Buy URL endpoint that returns the actual provider widget URL.
* This is a MetaMask-hosted endpoint that, when fetched, returns JSON with the provider's widget URL.
*/
buyURL?: string;
};

@@ -333,5 +355,5 @@ /**

/**
* Optional provider ID to filter quotes.
* Optional provider IDs to filter quotes.
*/
provider?: string;
providers?: string[];
/**

@@ -675,3 +697,3 @@ * The ramp action type. Defaults to 'buy'.

* @param params.redirectUrl - Optional redirect URL after order completion.
* @param params.provider - Optional provider ID to filter quotes.
* @param params.providers - Optional provider IDs to filter quotes.
* @param params.action - The ramp action type. Defaults to 'buy'.

@@ -681,4 +703,13 @@ * @returns The quotes response containing success, sorted, error, and customActions.

getQuotes(params: GetQuotesParams): Promise<QuotesResponse>;
/**
* Fetches the buy widget data from a buy URL endpoint.
* Makes a request to the buyURL (as provided in a quote) to get the actual
* provider widget URL, browser type, and order ID.
*
* @param buyUrl - The full buy URL endpoint to fetch from.
* @returns The buy widget data containing the provider widget URL.
*/
getBuyWidgetUrl(buyUrl: string): Promise<BuyWidget>;
}
export {};
//# sourceMappingURL=RampsService.d.cts.map

@@ -1,1 +0,1 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G,YAAY,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IA2BxC;;;;;;;;;OASG;IACG,SAAS,CACb,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,UAAkB,EAC1B,OAAO,CAAC,EAAE;QACR,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;KAC9B,GACA,OAAO,CAAC,cAAc,CAAC;IAwC1B;;;;;;;;;;;OAWG;IACG,YAAY,CAChB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE;QACR,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAC3B,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QACzB,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;KAC9B,GACA,OAAO,CAAC;QAAE,SAAS,EAAE,QAAQ,EAAE,CAAA;KAAE,CAAC;IA0DrC;;;;;;;;;OASG;IACG,iBAAiB,CAAC,OAAO,EAAE;QAC/B,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAmCnC;;;;;;;;;;;;;;;OAeG;IACG,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC;IA4DjE;;;;;;;OAOG;IACG,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;CAqB1D"}

@@ -67,2 +67,6 @@ import type { CreateServicePolicyOptions, ServicePolicy } from "@metamask/controller-utils";

/**
* Browser type for provider buy features.
*/
export type ProviderBrowserType = 'APP_BROWSER' | 'IN_APP_OS_BROWSER' | null;
/**
* Represents a ramp provider.

@@ -157,2 +161,19 @@ */

/**
* Widget information for executing a buy order.
*/
export type BuyWidget = {
/**
* The widget URL to open for the user to complete the purchase.
*/
url: string;
/**
* The browser type to use for opening the widget.
*/
browser?: ProviderBrowserType;
/**
* Order ID if already created.
*/
orderId?: string | null;
};
/**
* Represents an individual quote from a provider.

@@ -186,6 +207,2 @@ */

/**
* The widget URL for redirect providers.
*/
widgetUrl?: string;
/**
* Crypto translation info for display.

@@ -206,2 +223,7 @@ */

providerFee?: number | string;
/**
* Buy URL endpoint that returns the actual provider widget URL.
* This is a MetaMask-hosted endpoint that, when fetched, returns JSON with the provider's widget URL.
*/
buyURL?: string;
};

@@ -333,5 +355,5 @@ /**

/**
* Optional provider ID to filter quotes.
* Optional provider IDs to filter quotes.
*/
provider?: string;
providers?: string[];
/**

@@ -675,3 +697,3 @@ * The ramp action type. Defaults to 'buy'.

* @param params.redirectUrl - Optional redirect URL after order completion.
* @param params.provider - Optional provider ID to filter quotes.
* @param params.providers - Optional provider IDs to filter quotes.
* @param params.action - The ramp action type. Defaults to 'buy'.

@@ -681,4 +703,13 @@ * @returns The quotes response containing success, sorted, error, and customActions.

getQuotes(params: GetQuotesParams): Promise<QuotesResponse>;
/**
* Fetches the buy widget data from a buy URL endpoint.
* Makes a request to the buyURL (as provided in a quote) to get the actual
* provider widget URL, browser type, and order ID.
*
* @param buyUrl - The full buy URL endpoint to fetch from.
* @returns The buy widget data containing the provider widget URL.
*/
getBuyWidgetUrl(buyUrl: string): Promise<BuyWidget>;
}
export {};
//# sourceMappingURL=RampsService.d.mts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"RampsService.d.mts","sourceRoot":"","sources":["../src/RampsService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,aAAa,EACd,mCAAmC;AAEpC,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD,OAAO,KAAK,EAAE,yBAAyB,EAAE,+CAA2C;AAGpF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;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,MAAM,EAClB,OAAO,CAAC,EAAE;QACR,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAC3B,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QACzB,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;KAC9B,GACA,OAAO,CAAC;QAAE,SAAS,EAAE,QAAQ,EAAE,CAAA;KAAE,CAAC;IA0DrC;;;;;;;;;OASG;IACG,iBAAiB,CAAC,OAAO,EAAE;QAC/B,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAmCnC;;;;;;;;;;;;;;;OAeG;IACG,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC;IA4DjE;;;;;;;OAOG;IACG,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;CAqB1D"}

@@ -52,2 +52,3 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {

'getQuotes',
'getBuyWidgetUrl',
];

@@ -400,3 +401,3 @@ // === SERVICE DEFINITION ===

* @param params.redirectUrl - Optional redirect URL after order completion.
* @param params.provider - Optional provider ID to filter quotes.
* @param params.providers - Optional provider IDs to filter quotes.
* @param params.action - The ramp action type. Defaults to 'buy'.

@@ -422,5 +423,5 @@ * @returns The quotes response containing success, sorted, error, and customActions.

// Add provider filter if specified
if (params.provider) {
url.searchParams.append('providers', params.provider);
}
params.providers?.forEach((provider) => {
url.searchParams.append('providers', provider);
});
// Add redirect URL if specified

@@ -448,2 +449,25 @@ if (params.redirectUrl) {

}
/**
* Fetches the buy widget data from a buy URL endpoint.
* Makes a request to the buyURL (as provided in a quote) to get the actual
* provider widget URL, browser type, and order ID.
*
* @param buyUrl - The full buy URL endpoint to fetch from.
* @returns The buy widget data containing the provider widget URL.
*/
async getBuyWidgetUrl(buyUrl) {
const url = new URL(buyUrl);
__classPrivateFieldGet(this, _RampsService_instances, "m", _RampsService_addCommonParams).call(this, url);
const response = await __classPrivateFieldGet(this, _RampsService_policy, "f").execute(async () => {
const fetchResponse = await __classPrivateFieldGet(this, _RampsService_fetch, "f").call(this, url);
if (!fetchResponse.ok) {
throw new HttpError(fetchResponse.status, `Fetching '${url.toString()}' failed with status '${fetchResponse.status}'`);
}
return fetchResponse.json();
});
if (!response || typeof response !== 'object' || !response.url) {
throw new Error('Malformed response received from buy widget URL API');
}
return response;
}
}

@@ -450,0 +474,0 @@ _a = RampsService, _RampsService_messenger = new WeakMap(), _RampsService_fetch = new WeakMap(), _RampsService_policy = new WeakMap(), _RampsService_environment = new WeakMap(), _RampsService_context = new WeakMap(), _RampsService_baseUrlOverride = new WeakMap(), _RampsService_instances = new WeakSet(), _RampsService_getBaseUrl = function _RampsService_getBaseUrl(service) {

@@ -1,1 +0,1 @@

{"version":3,"file":"RampsService.mjs","sourceRoot":"","sources":["../src/RampsService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,mCAAmC;AAI5E,OAAO,WAAW,8CAAwB;AAoc1C;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAOzC,kBAAkB;AAElB;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,6CAAyB,CAAA;IACzB,uCAAmB,CAAA;IACnB,+CAA2B,CAAA;IAC3B,mCAAe,CAAA;AACjB,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK3B;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,e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AAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACnC,uBAAA,IAAI,8DAAiB,MAArB,IAAI,EAAkB,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAE3C,MAAM,QAAQ,GAAG,MAAM,uBAAA,IAAI,2BAAO,MAAX,IAAI,EAAQ,GAAG,CAAC,CAAC;QACxC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,SAAS,CACjB,QAAQ,CAAC,MAAM,EACf,aAAa,GAAG,CAAC,QAAQ,EAAE,yBAAyB,QAAQ,CAAC,MAAM,GAAG,CACvE,CAAC;QACJ,CAAC;QAED,OAAO,OAAO,CAAC,YAAY,KAAK,MAAM;YACpC,CAAC,CAAE,QAAQ,CAAC,IAAI,EAAyB;YACzC,CAAC,CAAE,QAAQ,CAAC,IAAI,EAAyB,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type {\n CreateServicePolicyOptions,\n ServicePolicy,\n} from '@metamask/controller-utils';\nimport { createServicePolicy, HttpError } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\n\nimport type { RampsServiceMethodActions } from './RampsService-method-action-types';\nimport packageJson from '../package.json';\n\n/**\n * Represents phone number information for a country.\n */\nexport type CountryPhone = {\n prefix: string;\n placeholder: string;\n template: string;\n};\n\n/**\n * Indicates whether a region supports buy and/or sell actions.\n */\nexport type SupportedActions = {\n /**\n * Whether buy actions are supported.\n */\n buy: boolean;\n /**\n * Whether sell actions are supported.\n */\n sell: boolean;\n};\n\n/**\n * Represents a state/province within a country.\n */\nexport type State = {\n /**\n * State identifier. Can be in path format (e.g., \"/regions/us-ut\") or ISO code format (e.g., \"us-ut\").\n */\n id?: string;\n /**\n * State name.\n */\n name?: string;\n /**\n * ISO state code (e.g., \"UT\", \"NY\").\n */\n stateId?: string;\n /**\n * Whether this state is supported for buy and/or sell ramp actions.\n */\n supported?: SupportedActions;\n /**\n * Whether this state is recommended.\n */\n recommended?: boolean;\n};\n\n/**\n * Represents a provider link.\n */\nexport type ProviderLink = {\n name: string;\n url: string;\n};\n\n/**\n * Represents provider logos.\n */\nexport type ProviderLogos = {\n light: string;\n dark: string;\n height: number;\n width: number;\n};\n\n/**\n * Represents a ramp provider.\n */\nexport type Provider = {\n id: string;\n name: string;\n environmentType: string;\n description: string;\n hqAddress: string;\n links: ProviderLink[];\n logos: ProviderLogos;\n supportedCryptoCurrencies?: Record<string, boolean>;\n supportedFiatCurrencies?: Record<string, boolean>;\n supportedPaymentMethods?: Record<string, boolean>;\n};\n\n/**\n * Represents a payment method for funding a purchase.\n */\nexport type PaymentMethod = {\n /**\n * Canonical payment method ID (e.g., \"/payments/debit-credit-card\").\n */\n id: string;\n /**\n * Payment type identifier (e.g., \"debit-credit-card\", \"bank-transfer\").\n */\n paymentType: string;\n /**\n * User-facing name for the payment method.\n */\n name: string;\n /**\n * Score for sorting payment methods (higher is better).\n */\n score: number;\n /**\n * Icon identifier for the payment method.\n */\n icon: string;\n /**\n * Localized disclaimer text (optional).\n */\n disclaimer?: string;\n /**\n * Delay in minutes (e.g., [5, 10]).\n */\n delay?: number[];\n /**\n * Localized pending order description (optional).\n */\n pendingOrderDescription?: string;\n};\n\n/**\n * Response from the paymentMethods API.\n */\nexport type PaymentMethodsResponse = {\n /**\n * List of available payment methods.\n */\n payments: PaymentMethod[];\n /**\n * Recommended sorting for payment methods.\n */\n sort?: {\n ids: string[];\n sortBy: string;\n };\n};\n\n// === QUOTES TYPES ===\n\n/**\n * Sort criteria for quotes.\n */\nexport type QuoteSortBy = 'price' | 'reliability';\n\n/**\n * Represents crypto translation info for a quote.\n */\nexport type QuoteCryptoTranslation = {\n /**\n * The crypto currency ID.\n */\n id?: string;\n /**\n * The crypto symbol.\n */\n symbol?: string;\n /**\n * The chain ID.\n */\n chainId?: string;\n};\n\n/**\n * Represents an individual quote from a provider.\n */\nexport type Quote = {\n /**\n * The provider ID (e.g., \"/providers/moonpay\").\n */\n provider: string;\n /**\n * The quote details.\n */\n quote: {\n /**\n * The amount the user is paying (in fiat for buy, crypto for sell).\n */\n amountIn: number | string;\n /**\n * The amount the user will receive (in crypto for buy, fiat for sell).\n */\n amountOut: number | string;\n /**\n * The payment method used for this quote.\n */\n paymentMethod: string;\n /**\n * The fiat value of the output amount (for buy actions).\n */\n amountOutInFiat?: number;\n /**\n * The widget URL for redirect providers.\n */\n widgetUrl?: string;\n /**\n * Crypto translation info for display.\n */\n cryptoTranslation?: QuoteCryptoTranslation;\n /**\n * Total fees in the source currency.\n */\n totalFees?: number | string;\n /**\n * Network fees.\n */\n networkFee?: number | string;\n /**\n * Provider fees.\n */\n providerFee?: number | string;\n };\n /**\n * Metadata about the quote.\n */\n metadata?: {\n /**\n * Reliability score for the provider (0-100).\n */\n reliability?: number;\n /**\n * Tags for the quote.\n */\n tags?: {\n /**\n * Whether this is the best rate quote.\n */\n isBestRate?: boolean;\n /**\n * Whether this is the most reliable provider.\n */\n isMostReliable?: boolean;\n };\n };\n};\n\n/**\n * Represents an error from a provider when fetching quotes.\n */\nexport type QuoteError = {\n /**\n * The provider ID that failed.\n */\n provider: string;\n /**\n * Error message.\n */\n error?: string;\n};\n\n/**\n * Sort order information for quotes.\n */\nexport type QuoteSortOrder = {\n /**\n * The sort criteria.\n */\n sortBy: QuoteSortBy;\n /**\n * Provider IDs in sorted order.\n */\n ids: string[];\n};\n\n/**\n * Custom action for a provider (e.g., Apple Pay).\n */\nexport type QuoteCustomAction = {\n /**\n * Buy action details.\n */\n buy: {\n /**\n * Provider ID.\n */\n providerId: string;\n };\n /**\n * Payment method ID this action applies to.\n */\n paymentMethodId: string;\n /**\n * Supported payment method IDs.\n */\n supportedPaymentMethodIds: string[];\n};\n\n/**\n * Response from the quotes API.\n */\nexport type QuotesResponse = {\n /**\n * Successfully retrieved quotes.\n */\n success: Quote[];\n /**\n * Sort orders for the quotes.\n */\n sorted: QuoteSortOrder[];\n /**\n * Errors from providers that failed to return quotes.\n */\n error: QuoteError[];\n /**\n * Custom actions available from providers.\n */\n customActions: QuoteCustomAction[];\n};\n\n/**\n * Parameters for fetching quotes.\n */\nexport type GetQuotesParams = {\n /**\n * The region code (e.g., \"us\", \"us-ca\").\n */\n region: string;\n /**\n * Array of payment method IDs to get quotes for.\n */\n paymentMethods: string[];\n /**\n * The CAIP-19 asset ID (e.g., \"eip155:1/erc20:0x...\").\n */\n assetId: string;\n /**\n * The fiat currency code (e.g., \"usd\").\n */\n fiat: string;\n /**\n * The amount (in fiat for buy, crypto for sell).\n */\n amount: number;\n /**\n * The destination wallet address.\n */\n walletAddress: string;\n /**\n * Optional redirect URL after order completion.\n */\n redirectUrl?: string;\n /**\n * Optional provider ID to filter quotes.\n */\n provider?: string;\n /**\n * The ramp action type. Defaults to 'buy'.\n */\n action?: RampAction;\n};\n\n/**\n * Represents a country returned from the regions/countries API.\n */\nexport type Country = {\n /**\n * ISO-2 country code (e.g., \"US\", \"GB\").\n */\n isoCode: string;\n /**\n * Country identifier. Can be in path format (e.g., \"/regions/us\") or ISO code format.\n * If not provided, defaults to isoCode.\n */\n id?: string;\n /**\n * Country flag emoji or code.\n */\n flag: string;\n /**\n * Country name.\n */\n name: string;\n /**\n * Phone number information.\n */\n phone: CountryPhone;\n /**\n * Default currency code.\n */\n currency: string;\n /**\n * Whether this country is supported for buy and/or sell ramp actions.\n */\n supported: SupportedActions;\n /**\n * Whether this country is recommended.\n */\n recommended?: boolean;\n /**\n * Array of state objects.\n */\n states?: State[];\n /**\n * Default amount for ramps transactions.\n */\n defaultAmount?: number;\n /**\n * Quick amount options for ramps transactions.\n */\n quickAmounts?: number[];\n};\n\n/**\n * Represents a token returned from the regions/{region}/tokens API.\n */\nexport type RampsToken = {\n /**\n * The asset identifier in CAIP-19 format (e.g., \"eip155:1/erc20:0x...\").\n */\n assetId: string;\n /**\n * The chain identifier in CAIP-2 format (e.g., \"eip155:1\").\n */\n chainId: string;\n /**\n * Token name (e.g., \"USD Coin\").\n */\n name: string;\n /**\n * Token symbol (e.g., \"USDC\").\n */\n symbol: string;\n /**\n * Number of decimals for the token.\n */\n decimals: number;\n /**\n * URL to the token icon.\n */\n iconUrl: string;\n /**\n * Whether this token is supported.\n */\n tokenSupported: boolean;\n};\n\n/**\n * Response from the regions/{region}/tokens API.\n */\nexport type TokensResponse = {\n /**\n * Top/popular tokens for the region.\n */\n topTokens: RampsToken[];\n /**\n * All available tokens for the region.\n */\n allTokens: RampsToken[];\n};\n\n/**\n * The SDK version to send with API requests. (backwards-compatibility)\n */\nexport const RAMPS_SDK_VERSION = '2.1.6';\n\n/**\n * The type of ramp action: 'buy' or 'sell'.\n */\nexport type RampAction = 'buy' | 'sell';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link RampsService}, used to namespace the\n * service's actions and events.\n */\nexport const serviceName = 'RampsService';\n\n/**\n * The environment to use for API requests.\n */\nexport enum RampsEnvironment {\n Production = 'production',\n Staging = 'staging',\n Development = 'development',\n Local = 'local',\n}\n\n/**\n * The type of ramps API service.\n * Determines which base URL to use (cache vs standard).\n */\nexport enum RampsApiService {\n Regions = 'regions',\n Orders = 'orders',\n}\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'getGeolocation',\n 'getCountries',\n 'getTokens',\n 'getProviders',\n 'getPaymentMethods',\n 'getQuotes',\n] as const;\n\n/**\n * Actions that {@link RampsService} exposes to other consumers.\n */\nexport type RampsServiceActions = RampsServiceMethodActions;\n\n/**\n * Actions from other messengers that {@link RampsService} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Events that {@link RampsService} exposes to other consumers.\n */\nexport type RampsServiceEvents = never;\n\n/**\n * Events from other messengers that {@link RampsService} subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger which is restricted to actions and events accessed by\n * {@link RampsService}.\n */\nexport type RampsServiceMessenger = Messenger<\n typeof serviceName,\n RampsServiceActions | AllowedActions,\n RampsServiceEvents | AllowedEvents\n>;\n\n// === SERVICE DEFINITION ===\n\n/**\n * Gets the base URL for API requests based on the environment and service type.\n * The Regions service uses a cache URL, while other services use the standard URL.\n *\n * @param environment - The environment to use.\n * @param service - The API service type (determines if cache URL is used).\n * @returns The base URL for API requests.\n */\nfunction getBaseUrl(\n environment: RampsEnvironment,\n service: RampsApiService,\n): string {\n const cache = service === RampsApiService.Regions ? '-cache' : '';\n\n switch (environment) {\n case RampsEnvironment.Production:\n return `https://on-ramp${cache}.api.cx.metamask.io`;\n case RampsEnvironment.Staging:\n case RampsEnvironment.Development:\n return `https://on-ramp${cache}.uat-api.cx.metamask.io`;\n case RampsEnvironment.Local:\n return 'http://localhost:3000';\n default:\n throw new Error(`Invalid environment: ${String(environment)}`);\n }\n}\n\n/**\n * Constructs an API path with a version prefix.\n *\n * @param path - The API endpoint path.\n * @param version - The API version prefix. Defaults to 'v2'.\n * @returns The versioned API path.\n */\nfunction getApiPath(path: string, version: string = 'v2'): string {\n return `${version}/${path}`;\n}\n\n/**\n * This service object is responsible for interacting with the Ramps API.\n *\n * @example\n *\n * ``` ts\n * import { Messenger } from '@metamask/messenger';\n * import type {\n * RampsServiceActions,\n * RampsServiceEvents,\n * } from '@metamask/ramps-controller';\n *\n * const rootMessenger = new Messenger<\n * 'Root',\n * RampsServiceActions\n * RampsServiceEvents\n * >({ namespace: 'Root' });\n * const rampsServiceMessenger = new Messenger<\n * 'RampsService',\n * RampsServiceActions,\n * RampsServiceEvents,\n * typeof rootMessenger,\n * >({\n * namespace: 'RampsService',\n * parent: rootMessenger,\n * });\n * // Instantiate the service to register its actions on the messenger\n * new RampsService({\n * messenger: rampsServiceMessenger,\n * environment: RampsEnvironment.Production,\n * context: 'mobile-ios',\n * fetch,\n * });\n *\n * // Later...\n * // Get the user's geolocation\n * const geolocation = await rootMessenger.call(\n * 'RampsService:getGeolocation',\n * );\n * // ... Do something with the geolocation ...\n * ```\n */\nexport class RampsService {\n /**\n * The name of the service.\n */\n readonly name: typeof serviceName;\n\n /**\n * The messenger suited for this service.\n */\n readonly #messenger: ConstructorParameters<\n typeof RampsService\n >[0]['messenger'];\n\n /**\n * A function that can be used to make an HTTP request.\n */\n readonly #fetch: ConstructorParameters<typeof RampsService>[0]['fetch'];\n\n /**\n * The policy that wraps the request.\n *\n * @see {@link createServicePolicy}\n */\n readonly #policy: ServicePolicy;\n\n /**\n * The environment used for API requests.\n */\n readonly #environment: RampsEnvironment;\n\n /**\n * The context for API requests (e.g., 'mobile-ios', 'mobile-android').\n */\n readonly #context: string;\n\n /**\n * Optional base URL override for local development.\n */\n readonly #baseUrlOverride?: string;\n\n /**\n * Constructs a new RampsService object.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this service.\n * @param args.environment - The environment to use for API requests.\n * @param args.context - The context for API requests (e.g., 'mobile-ios', 'mobile-android').\n * @param args.fetch - A function that can be used to make an HTTP request. If\n * your JavaScript environment supports `fetch` natively, you'll probably want\n * to pass that; otherwise you can pass an equivalent (such as `fetch` via\n * `node-fetch`).\n * @param args.policyOptions - Options to pass to `createServicePolicy`, which\n * is used to wrap each request. See {@link CreateServicePolicyOptions}.\n * @param args.baseUrlOverride - Optional base URL override for local development.\n */\n constructor({\n messenger,\n environment = RampsEnvironment.Staging,\n context,\n fetch: fetchFunction,\n policyOptions = {},\n baseUrlOverride,\n }: {\n messenger: RampsServiceMessenger;\n environment?: RampsEnvironment;\n context: string;\n fetch: typeof fetch;\n policyOptions?: CreateServicePolicyOptions;\n baseUrlOverride?: string;\n }) {\n this.name = serviceName;\n this.#messenger = messenger;\n this.#fetch = fetchFunction;\n this.#policy = createServicePolicy(policyOptions);\n this.#environment = environment;\n this.#context = context;\n this.#baseUrlOverride = baseUrlOverride;\n\n this.#messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Gets the base URL for API requests, respecting the baseUrlOverride if set.\n *\n * @param service - The API service type.\n * @returns The base URL to use.\n */\n #getBaseUrl(service: RampsApiService): string {\n if (this.#baseUrlOverride) {\n return this.#baseUrlOverride;\n }\n return getBaseUrl(this.#environment, service);\n }\n\n /**\n * Registers a handler that will be called after a request returns a non-500\n * response, causing a retry. Primarily useful in tests where timers are being\n * mocked.\n *\n * @param listener - The handler to be called.\n * @returns An object that can be used to unregister the handler. See\n * {@link CockatielEvent}.\n * @see {@link createServicePolicy}\n */\n onRetry(\n listener: Parameters<ServicePolicy['onRetry']>[0],\n ): ReturnType<ServicePolicy['onRetry']> {\n return this.#policy.onRetry(listener);\n }\n\n /**\n * Registers a handler that will be called after a set number of retry rounds\n * prove that requests to the API endpoint consistently return a 5xx response.\n *\n * @param listener - The handler to be called.\n * @returns An object that can be used to unregister the handler. See\n * {@link CockatielEvent}.\n * @see {@link createServicePolicy}\n */\n onBreak(\n listener: Parameters<ServicePolicy['onBreak']>[0],\n ): ReturnType<ServicePolicy['onBreak']> {\n return this.#policy.onBreak(listener);\n }\n\n /**\n * Registers a handler that will be called under one of two circumstances:\n *\n * 1. After a set number of retries prove that requests to the API\n * consistently result in one of the following failures:\n * 1. A connection initiation error\n * 2. A connection reset error\n * 3. A timeout error\n * 4. A non-JSON response\n * 5. A 502, 503, or 504 response\n * 2. After a successful request is made to the API, but the response takes\n * longer than a set duration to return.\n *\n * @param listener - The handler to be called.\n * @returns An object that can be used to unregister the handler. See\n * {@link CockatielEvent}.\n */\n onDegraded(\n listener: Parameters<ServicePolicy['onDegraded']>[0],\n ): ReturnType<ServicePolicy['onDegraded']> {\n return this.#policy.onDegraded(listener);\n }\n\n /**\n * Adds common request parameters to a URL.\n *\n * @param url - The URL to add parameters to.\n * @param action - The ramp action type (optional, not all endpoints require it).\n */\n #addCommonParams(url: URL, action?: RampAction): void {\n if (action) {\n url.searchParams.set('action', action);\n }\n url.searchParams.set('sdk', RAMPS_SDK_VERSION);\n url.searchParams.set('controller', packageJson.version);\n url.searchParams.set('context', this.#context);\n }\n\n /**\n * Makes an API request with retry policy and error handling.\n *\n * @param service - The API service type (determines base URL).\n * @param path - The endpoint path.\n * @param options - Request options.\n * @param options.action - The ramp action type (optional).\n * @param options.responseType - How to parse the response ('json' or 'text').\n * @returns The parsed response data.\n */\n async #request<TResponse>(\n service: RampsApiService,\n path: string,\n options: {\n action?: RampAction;\n responseType: 'json' | 'text';\n },\n ): Promise<TResponse> {\n return this.#policy.execute(async () => {\n const baseUrl = this.#getBaseUrl(service);\n const url = new URL(path, baseUrl);\n this.#addCommonParams(url, options.action);\n\n const response = await this.#fetch(url);\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Fetching '${url.toString()}' failed with status '${response.status}'`,\n );\n }\n\n return options.responseType === 'json'\n ? (response.json() as Promise<TResponse>)\n : (response.text() as Promise<TResponse>);\n });\n }\n\n /**\n * Makes a request to the API in order to retrieve the user's geolocation\n * based on their IP address.\n *\n * @returns The user's country/region code (e.g., \"US-UT\" for Utah, USA).\n */\n async getGeolocation(): Promise<string> {\n const textResponse = await this.#request<string>(\n RampsApiService.Orders,\n 'geolocation',\n { responseType: 'text' },\n );\n\n const trimmedResponse = textResponse.trim();\n if (trimmedResponse.length > 0) {\n return trimmedResponse;\n }\n\n throw new Error('Malformed response received from geolocation API');\n }\n\n /**\n * Makes a request to the cached API to retrieve the list of supported countries.\n * The API returns countries with support information for both buy and sell actions.\n * Filters countries based on aggregator support (preserves OnRampSDK logic).\n *\n * @returns An array of countries filtered by aggregator support.\n */\n async getCountries(): Promise<Country[]> {\n const countries = await this.#request<Country[]>(\n RampsApiService.Regions,\n getApiPath('regions/countries'),\n { responseType: 'json' },\n );\n\n if (!Array.isArray(countries)) {\n throw new Error('Malformed response received from countries API');\n }\n\n return countries.filter((country) => {\n const isCountrySupported =\n country.supported.buy || country.supported.sell;\n\n if (country.states && country.states.length > 0) {\n const hasSupportedState = country.states.some(\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- intentionally using || to treat false as unsupported\n (state) => state.supported?.buy || state.supported?.sell,\n );\n return isCountrySupported || hasSupportedState;\n }\n\n return isCountrySupported;\n });\n }\n\n /**\n * Fetches the list of available tokens for a given region and action.\n * Supports optional provider filter.\n *\n * @param region - The region code (e.g., \"us\", \"fr\", \"us-ny\").\n * @param action - The ramp action type ('buy' or 'sell').\n * @param options - Optional query parameters for filtering tokens.\n * @param options.provider - Provider ID(s) to filter by.\n * @returns The tokens response containing topTokens and allTokens.\n */\n async getTokens(\n region: string,\n action: RampAction = 'buy',\n options?: {\n provider?: string | string[];\n },\n ): Promise<TokensResponse> {\n const normalizedRegion = region.toLowerCase().trim();\n const url = new URL(\n getApiPath(`regions/${normalizedRegion}/topTokens`),\n this.#getBaseUrl(RampsApiService.Regions),\n );\n this.#addCommonParams(url, action);\n\n if (options?.provider) {\n const providerIds = Array.isArray(options.provider)\n ? options.provider\n : [options.provider];\n providerIds.forEach((id) => url.searchParams.append('provider', id));\n }\n\n const response = await this.#policy.execute(async () => {\n const fetchResponse = await this.#fetch(url);\n if (!fetchResponse.ok) {\n throw new HttpError(\n fetchResponse.status,\n `Fetching '${url.toString()}' failed with status '${fetchResponse.status}'`,\n );\n }\n return fetchResponse.json() as Promise<TokensResponse>;\n });\n\n if (!response || typeof response !== 'object') {\n throw new Error('Malformed response received from tokens API');\n }\n\n if (\n !Array.isArray(response.topTokens) ||\n !Array.isArray(response.allTokens)\n ) {\n throw new Error('Malformed response received from tokens API');\n }\n\n return response;\n }\n\n /**\n * Fetches the list of providers for a given region.\n * Supports optional query filters: provider, crypto, fiat, payments.\n *\n * @param regionCode - The region code (e.g., \"us\", \"fr\", \"us-ny\").\n * @param options - Optional query parameters for filtering providers.\n * @param options.provider - Provider ID(s) to filter by.\n * @param options.crypto - Crypto currency ID(s) to filter by.\n * @param options.fiat - Fiat currency ID(s) to filter by.\n * @param options.payments - Payment method ID(s) to filter by.\n * @returns The providers response containing providers array.\n */\n async getProviders(\n regionCode: string,\n options?: {\n provider?: string | string[];\n crypto?: string | string[];\n fiat?: string | string[];\n payments?: string | string[];\n },\n ): Promise<{ providers: Provider[] }> {\n const normalizedRegion = regionCode.toLowerCase().trim();\n const url = new URL(\n getApiPath(`regions/${normalizedRegion}/providers`),\n this.#getBaseUrl(RampsApiService.Regions),\n );\n this.#addCommonParams(url);\n\n if (options?.provider) {\n const providerIds = Array.isArray(options.provider)\n ? options.provider\n : [options.provider];\n providerIds.forEach((id) => url.searchParams.append('provider', id));\n }\n\n if (options?.crypto) {\n const cryptoIds = Array.isArray(options.crypto)\n ? options.crypto\n : [options.crypto];\n cryptoIds.forEach((id) => url.searchParams.append('crypto', id));\n }\n\n if (options?.fiat) {\n const fiatIds = Array.isArray(options.fiat)\n ? options.fiat\n : [options.fiat];\n fiatIds.forEach((id) => url.searchParams.append('fiat', id));\n }\n\n if (options?.payments) {\n const paymentIds = Array.isArray(options.payments)\n ? options.payments\n : [options.payments];\n paymentIds.forEach((id) => url.searchParams.append('payments', id));\n }\n\n const response = await this.#policy.execute(async () => {\n const fetchResponse = await this.#fetch(url);\n if (!fetchResponse.ok) {\n throw new HttpError(\n fetchResponse.status,\n `Fetching '${url.toString()}' failed with status '${fetchResponse.status}'`,\n );\n }\n return fetchResponse.json() as Promise<{ providers: Provider[] }>;\n });\n\n if (!response || typeof response !== 'object') {\n throw new Error('Malformed response received from providers API');\n }\n\n if (!Array.isArray(response.providers)) {\n throw new Error('Malformed response received from providers API');\n }\n\n return response;\n }\n\n /**\n * Fetches the list of payment methods for a given region, asset, and provider.\n *\n * @param options - Query parameters for filtering payment methods.\n * @param options.region - User's region code (e.g., \"us-al\").\n * @param options.fiat - Fiat currency code (e.g., \"usd\").\n * @param options.assetId - CAIP-19 cryptocurrency identifier.\n * @param options.provider - Provider ID path.\n * @returns The payment methods response containing payments array.\n */\n async getPaymentMethods(options: {\n region: string;\n fiat: string;\n assetId: string;\n provider: string;\n }): Promise<PaymentMethodsResponse> {\n const normalizedRegion = options.region.toLowerCase().trim();\n const url = new URL(\n getApiPath(`regions/${normalizedRegion}/payments`),\n this.#getBaseUrl(RampsApiService.Regions),\n );\n this.#addCommonParams(url);\n\n url.searchParams.set('region', options.region.toLowerCase().trim());\n url.searchParams.set('fiat', options.fiat.toLowerCase().trim());\n url.searchParams.set('crypto', options.assetId);\n url.searchParams.set('provider', options.provider);\n\n const response = await this.#policy.execute(async () => {\n const fetchResponse = await this.#fetch(url);\n if (!fetchResponse.ok) {\n throw new HttpError(\n fetchResponse.status,\n `Fetching '${url.toString()}' failed with status '${fetchResponse.status}'`,\n );\n }\n return fetchResponse.json() as Promise<PaymentMethodsResponse>;\n });\n\n if (!response || typeof response !== 'object') {\n throw new Error('Malformed response received from paymentMethods API');\n }\n\n if (!Array.isArray(response.payments)) {\n throw new Error('Malformed response received from paymentMethods API');\n }\n\n return response;\n }\n\n /**\n * Fetches quotes from all providers for a given set of parameters.\n * Uses the V2 orders API to get quotes for multiple payment methods at once.\n *\n * @param params - The parameters for fetching quotes.\n * @param params.region - User's region code (e.g., \"us\", \"us-ca\").\n * @param params.paymentMethods - Array of payment method IDs.\n * @param params.assetId - CAIP-19 cryptocurrency identifier.\n * @param params.fiat - Fiat currency code (e.g., \"usd\").\n * @param params.amount - The amount (in fiat for buy, crypto for sell).\n * @param params.walletAddress - The destination wallet address.\n * @param params.redirectUrl - Optional redirect URL after order completion.\n * @param params.provider - Optional provider ID to filter quotes.\n * @param params.action - The ramp action type. Defaults to 'buy'.\n * @returns The quotes response containing success, sorted, error, and customActions.\n */\n async getQuotes(params: GetQuotesParams): Promise<QuotesResponse> {\n const normalizedRegion = params.region.toLowerCase().trim();\n const normalizedFiat = params.fiat.toLowerCase().trim();\n const action = params.action ?? 'buy';\n\n const url = new URL(\n getApiPath('quotes'),\n getBaseUrl(this.#environment, RampsApiService.Orders),\n );\n this.#addCommonParams(url, action);\n\n // Build region ID in the format expected by the API\n url.searchParams.set('region', normalizedRegion);\n url.searchParams.set('fiat', normalizedFiat);\n url.searchParams.set('crypto', params.assetId);\n url.searchParams.set('amount', String(params.amount));\n url.searchParams.set('walletAddress', params.walletAddress);\n\n // Add payment methods as array parameters\n params.paymentMethods.forEach((paymentMethod) => {\n url.searchParams.append('payments', paymentMethod);\n });\n\n // Add provider filter if specified\n if (params.provider) {\n url.searchParams.append('providers', params.provider);\n }\n\n // Add redirect URL if specified\n if (params.redirectUrl) {\n url.searchParams.set('redirectUrl', params.redirectUrl);\n }\n\n const response = await this.#policy.execute(async () => {\n const fetchResponse = await this.#fetch(url);\n if (!fetchResponse.ok) {\n throw new HttpError(\n fetchResponse.status,\n `Fetching '${url.toString()}' failed with status '${fetchResponse.status}'`,\n );\n }\n return fetchResponse.json() as Promise<QuotesResponse>;\n });\n\n if (!response || typeof response !== 'object') {\n throw new Error('Malformed response received from quotes API');\n }\n\n if (\n !Array.isArray(response.success) ||\n !Array.isArray(response.sorted) ||\n !Array.isArray(response.error) ||\n !Array.isArray(response.customActions)\n ) {\n throw new Error('Malformed response received from quotes API');\n }\n\n return response;\n }\n}\n"]}
{"version":3,"file":"RampsService.mjs","sourceRoot":"","sources":["../src/RampsService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,mCAAmC;AAI5E,OAAO,WAAW,8CAAwB;AA4d1C;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAOzC,kBAAkB;AAElB;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,6CAAyB,CAAA;IACzB,uCAAmB,CAAA;IACnB,+CAA2B,CAAA;IAC3B,mCAAe,CAAA;AACjB,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK3B;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,sCAAmB,CAAA;IACnB,oCAAiB,CAAA;AACnB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AAED,oBAAoB;AAEpB,MAAM,yBAAyB,GAAG;IAChC,gBAAgB;IAChB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AAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type {\n CreateServicePolicyOptions,\n ServicePolicy,\n} from '@metamask/controller-utils';\nimport { createServicePolicy, HttpError } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\n\nimport type { RampsServiceMethodActions } from './RampsService-method-action-types';\nimport packageJson from '../package.json';\n\n/**\n * Represents phone number information for a country.\n */\nexport type CountryPhone = {\n prefix: string;\n placeholder: string;\n template: string;\n};\n\n/**\n * Indicates whether a region supports buy and/or sell actions.\n */\nexport type SupportedActions = {\n /**\n * Whether buy actions are supported.\n */\n buy: boolean;\n /**\n * Whether sell actions are supported.\n */\n sell: boolean;\n};\n\n/**\n * Represents a state/province within a country.\n */\nexport type State = {\n /**\n * State identifier. Can be in path format (e.g., \"/regions/us-ut\") or ISO code format (e.g., \"us-ut\").\n */\n id?: string;\n /**\n * State name.\n */\n name?: string;\n /**\n * ISO state code (e.g., \"UT\", \"NY\").\n */\n stateId?: string;\n /**\n * Whether this state is supported for buy and/or sell ramp actions.\n */\n supported?: SupportedActions;\n /**\n * Whether this state is recommended.\n */\n recommended?: boolean;\n};\n\n/**\n * Represents a provider link.\n */\nexport type ProviderLink = {\n name: string;\n url: string;\n};\n\n/**\n * Represents provider logos.\n */\nexport type ProviderLogos = {\n light: string;\n dark: string;\n height: number;\n width: number;\n};\n\n/**\n * Browser type for provider buy features.\n */\nexport type ProviderBrowserType = 'APP_BROWSER' | 'IN_APP_OS_BROWSER' | null;\n\n/**\n * Represents a ramp provider.\n */\nexport type Provider = {\n id: string;\n name: string;\n environmentType: string;\n description: string;\n hqAddress: string;\n links: ProviderLink[];\n logos: ProviderLogos;\n supportedCryptoCurrencies?: Record<string, boolean>;\n supportedFiatCurrencies?: Record<string, boolean>;\n supportedPaymentMethods?: Record<string, boolean>;\n};\n\n/**\n * Represents a payment method for funding a purchase.\n */\nexport type PaymentMethod = {\n /**\n * Canonical payment method ID (e.g., \"/payments/debit-credit-card\").\n */\n id: string;\n /**\n * Payment type identifier (e.g., \"debit-credit-card\", \"bank-transfer\").\n */\n paymentType: string;\n /**\n * User-facing name for the payment method.\n */\n name: string;\n /**\n * Score for sorting payment methods (higher is better).\n */\n score: number;\n /**\n * Icon identifier for the payment method.\n */\n icon: string;\n /**\n * Localized disclaimer text (optional).\n */\n disclaimer?: string;\n /**\n * Delay in minutes (e.g., [5, 10]).\n */\n delay?: number[];\n /**\n * Localized pending order description (optional).\n */\n pendingOrderDescription?: string;\n};\n\n/**\n * Response from the paymentMethods API.\n */\nexport type PaymentMethodsResponse = {\n /**\n * List of available payment methods.\n */\n payments: PaymentMethod[];\n /**\n * Recommended sorting for payment methods.\n */\n sort?: {\n ids: string[];\n sortBy: string;\n };\n};\n\n// === QUOTES TYPES ===\n\n/**\n * Sort criteria for quotes.\n */\nexport type QuoteSortBy = 'price' | 'reliability';\n\n/**\n * Represents crypto translation info for a quote.\n */\nexport type QuoteCryptoTranslation = {\n /**\n * The crypto currency ID.\n */\n id?: string;\n /**\n * The crypto symbol.\n */\n symbol?: string;\n /**\n * The chain ID.\n */\n chainId?: string;\n};\n\n/**\n * Widget information for executing a buy order.\n */\nexport type BuyWidget = {\n /**\n * The widget URL to open for the user to complete the purchase.\n */\n url: string;\n /**\n * The browser type to use for opening the widget.\n */\n browser?: ProviderBrowserType;\n /**\n * Order ID if already created.\n */\n orderId?: string | null;\n};\n\n/**\n * Represents an individual quote from a provider.\n */\nexport type Quote = {\n /**\n * The provider ID (e.g., \"/providers/moonpay\").\n */\n provider: string;\n /**\n * The quote details.\n */\n quote: {\n /**\n * The amount the user is paying (in fiat for buy, crypto for sell).\n */\n amountIn: number | string;\n /**\n * The amount the user will receive (in crypto for buy, fiat for sell).\n */\n amountOut: number | string;\n /**\n * The payment method used for this quote.\n */\n paymentMethod: string;\n /**\n * The fiat value of the output amount (for buy actions).\n */\n amountOutInFiat?: number;\n /**\n * Crypto translation info for display.\n */\n cryptoTranslation?: QuoteCryptoTranslation;\n /**\n * Total fees in the source currency.\n */\n totalFees?: number | string;\n /**\n * Network fees.\n */\n networkFee?: number | string;\n /**\n * Provider fees.\n */\n providerFee?: number | string;\n /**\n * Buy URL endpoint that returns the actual provider widget URL.\n * This is a MetaMask-hosted endpoint that, when fetched, returns JSON with the provider's widget URL.\n */\n buyURL?: string;\n };\n /**\n * Metadata about the quote.\n */\n metadata?: {\n /**\n * Reliability score for the provider (0-100).\n */\n reliability?: number;\n /**\n * Tags for the quote.\n */\n tags?: {\n /**\n * Whether this is the best rate quote.\n */\n isBestRate?: boolean;\n /**\n * Whether this is the most reliable provider.\n */\n isMostReliable?: boolean;\n };\n };\n};\n\n/**\n * Represents an error from a provider when fetching quotes.\n */\nexport type QuoteError = {\n /**\n * The provider ID that failed.\n */\n provider: string;\n /**\n * Error message.\n */\n error?: string;\n};\n\n/**\n * Sort order information for quotes.\n */\nexport type QuoteSortOrder = {\n /**\n * The sort criteria.\n */\n sortBy: QuoteSortBy;\n /**\n * Provider IDs in sorted order.\n */\n ids: string[];\n};\n\n/**\n * Custom action for a provider (e.g., Apple Pay).\n */\nexport type QuoteCustomAction = {\n /**\n * Buy action details.\n */\n buy: {\n /**\n * Provider ID.\n */\n providerId: string;\n };\n /**\n * Payment method ID this action applies to.\n */\n paymentMethodId: string;\n /**\n * Supported payment method IDs.\n */\n supportedPaymentMethodIds: string[];\n};\n\n/**\n * Response from the quotes API.\n */\nexport type QuotesResponse = {\n /**\n * Successfully retrieved quotes.\n */\n success: Quote[];\n /**\n * Sort orders for the quotes.\n */\n sorted: QuoteSortOrder[];\n /**\n * Errors from providers that failed to return quotes.\n */\n error: QuoteError[];\n /**\n * Custom actions available from providers.\n */\n customActions: QuoteCustomAction[];\n};\n\n/**\n * Parameters for fetching quotes.\n */\nexport type GetQuotesParams = {\n /**\n * The region code (e.g., \"us\", \"us-ca\").\n */\n region: string;\n /**\n * Array of payment method IDs to get quotes for.\n */\n paymentMethods: string[];\n /**\n * The CAIP-19 asset ID (e.g., \"eip155:1/erc20:0x...\").\n */\n assetId: string;\n /**\n * The fiat currency code (e.g., \"usd\").\n */\n fiat: string;\n /**\n * The amount (in fiat for buy, crypto for sell).\n */\n amount: number;\n /**\n * The destination wallet address.\n */\n walletAddress: string;\n /**\n * Optional redirect URL after order completion.\n */\n redirectUrl?: string;\n /**\n * Optional provider IDs to filter quotes.\n */\n providers?: string[];\n /**\n * The ramp action type. Defaults to 'buy'.\n */\n action?: RampAction;\n};\n\n/**\n * Represents a country returned from the regions/countries API.\n */\nexport type Country = {\n /**\n * ISO-2 country code (e.g., \"US\", \"GB\").\n */\n isoCode: string;\n /**\n * Country identifier. Can be in path format (e.g., \"/regions/us\") or ISO code format.\n * If not provided, defaults to isoCode.\n */\n id?: string;\n /**\n * Country flag emoji or code.\n */\n flag: string;\n /**\n * Country name.\n */\n name: string;\n /**\n * Phone number information.\n */\n phone: CountryPhone;\n /**\n * Default currency code.\n */\n currency: string;\n /**\n * Whether this country is supported for buy and/or sell ramp actions.\n */\n supported: SupportedActions;\n /**\n * Whether this country is recommended.\n */\n recommended?: boolean;\n /**\n * Array of state objects.\n */\n states?: State[];\n /**\n * Default amount for ramps transactions.\n */\n defaultAmount?: number;\n /**\n * Quick amount options for ramps transactions.\n */\n quickAmounts?: number[];\n};\n\n/**\n * Represents a token returned from the regions/{region}/tokens API.\n */\nexport type RampsToken = {\n /**\n * The asset identifier in CAIP-19 format (e.g., \"eip155:1/erc20:0x...\").\n */\n assetId: string;\n /**\n * The chain identifier in CAIP-2 format (e.g., \"eip155:1\").\n */\n chainId: string;\n /**\n * Token name (e.g., \"USD Coin\").\n */\n name: string;\n /**\n * Token symbol (e.g., \"USDC\").\n */\n symbol: string;\n /**\n * Number of decimals for the token.\n */\n decimals: number;\n /**\n * URL to the token icon.\n */\n iconUrl: string;\n /**\n * Whether this token is supported.\n */\n tokenSupported: boolean;\n};\n\n/**\n * Response from the regions/{region}/tokens API.\n */\nexport type TokensResponse = {\n /**\n * Top/popular tokens for the region.\n */\n topTokens: RampsToken[];\n /**\n * All available tokens for the region.\n */\n allTokens: RampsToken[];\n};\n\n/**\n * The SDK version to send with API requests. (backwards-compatibility)\n */\nexport const RAMPS_SDK_VERSION = '2.1.6';\n\n/**\n * The type of ramp action: 'buy' or 'sell'.\n */\nexport type RampAction = 'buy' | 'sell';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link RampsService}, used to namespace the\n * service's actions and events.\n */\nexport const serviceName = 'RampsService';\n\n/**\n * The environment to use for API requests.\n */\nexport enum RampsEnvironment {\n Production = 'production',\n Staging = 'staging',\n Development = 'development',\n Local = 'local',\n}\n\n/**\n * The type of ramps API service.\n * Determines which base URL to use (cache vs standard).\n */\nexport enum RampsApiService {\n Regions = 'regions',\n Orders = 'orders',\n}\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'getGeolocation',\n 'getCountries',\n 'getTokens',\n 'getProviders',\n 'getPaymentMethods',\n 'getQuotes',\n 'getBuyWidgetUrl',\n] as const;\n\n/**\n * Actions that {@link RampsService} exposes to other consumers.\n */\nexport type RampsServiceActions = RampsServiceMethodActions;\n\n/**\n * Actions from other messengers that {@link RampsService} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Events that {@link RampsService} exposes to other consumers.\n */\nexport type RampsServiceEvents = never;\n\n/**\n * Events from other messengers that {@link RampsService} subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger which is restricted to actions and events accessed by\n * {@link RampsService}.\n */\nexport type RampsServiceMessenger = Messenger<\n typeof serviceName,\n RampsServiceActions | AllowedActions,\n RampsServiceEvents | AllowedEvents\n>;\n\n// === SERVICE DEFINITION ===\n\n/**\n * Gets the base URL for API requests based on the environment and service type.\n * The Regions service uses a cache URL, while other services use the standard URL.\n *\n * @param environment - The environment to use.\n * @param service - The API service type (determines if cache URL is used).\n * @returns The base URL for API requests.\n */\nfunction getBaseUrl(\n environment: RampsEnvironment,\n service: RampsApiService,\n): string {\n const cache = service === RampsApiService.Regions ? '-cache' : '';\n\n switch (environment) {\n case RampsEnvironment.Production:\n return `https://on-ramp${cache}.api.cx.metamask.io`;\n case RampsEnvironment.Staging:\n case RampsEnvironment.Development:\n return `https://on-ramp${cache}.uat-api.cx.metamask.io`;\n case RampsEnvironment.Local:\n return 'http://localhost:3000';\n default:\n throw new Error(`Invalid environment: ${String(environment)}`);\n }\n}\n\n/**\n * Constructs an API path with a version prefix.\n *\n * @param path - The API endpoint path.\n * @param version - The API version prefix. Defaults to 'v2'.\n * @returns The versioned API path.\n */\nfunction getApiPath(path: string, version: string = 'v2'): string {\n return `${version}/${path}`;\n}\n\n/**\n * This service object is responsible for interacting with the Ramps API.\n *\n * @example\n *\n * ``` ts\n * import { Messenger } from '@metamask/messenger';\n * import type {\n * RampsServiceActions,\n * RampsServiceEvents,\n * } from '@metamask/ramps-controller';\n *\n * const rootMessenger = new Messenger<\n * 'Root',\n * RampsServiceActions\n * RampsServiceEvents\n * >({ namespace: 'Root' });\n * const rampsServiceMessenger = new Messenger<\n * 'RampsService',\n * RampsServiceActions,\n * RampsServiceEvents,\n * typeof rootMessenger,\n * >({\n * namespace: 'RampsService',\n * parent: rootMessenger,\n * });\n * // Instantiate the service to register its actions on the messenger\n * new RampsService({\n * messenger: rampsServiceMessenger,\n * environment: RampsEnvironment.Production,\n * context: 'mobile-ios',\n * fetch,\n * });\n *\n * // Later...\n * // Get the user's geolocation\n * const geolocation = await rootMessenger.call(\n * 'RampsService:getGeolocation',\n * );\n * // ... Do something with the geolocation ...\n * ```\n */\nexport class RampsService {\n /**\n * The name of the service.\n */\n readonly name: typeof serviceName;\n\n /**\n * The messenger suited for this service.\n */\n readonly #messenger: ConstructorParameters<\n typeof RampsService\n >[0]['messenger'];\n\n /**\n * A function that can be used to make an HTTP request.\n */\n readonly #fetch: ConstructorParameters<typeof RampsService>[0]['fetch'];\n\n /**\n * The policy that wraps the request.\n *\n * @see {@link createServicePolicy}\n */\n readonly #policy: ServicePolicy;\n\n /**\n * The environment used for API requests.\n */\n readonly #environment: RampsEnvironment;\n\n /**\n * The context for API requests (e.g., 'mobile-ios', 'mobile-android').\n */\n readonly #context: string;\n\n /**\n * Optional base URL override for local development.\n */\n readonly #baseUrlOverride?: string;\n\n /**\n * Constructs a new RampsService object.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this service.\n * @param args.environment - The environment to use for API requests.\n * @param args.context - The context for API requests (e.g., 'mobile-ios', 'mobile-android').\n * @param args.fetch - A function that can be used to make an HTTP request. If\n * your JavaScript environment supports `fetch` natively, you'll probably want\n * to pass that; otherwise you can pass an equivalent (such as `fetch` via\n * `node-fetch`).\n * @param args.policyOptions - Options to pass to `createServicePolicy`, which\n * is used to wrap each request. See {@link CreateServicePolicyOptions}.\n * @param args.baseUrlOverride - Optional base URL override for local development.\n */\n constructor({\n messenger,\n environment = RampsEnvironment.Staging,\n context,\n fetch: fetchFunction,\n policyOptions = {},\n baseUrlOverride,\n }: {\n messenger: RampsServiceMessenger;\n environment?: RampsEnvironment;\n context: string;\n fetch: typeof fetch;\n policyOptions?: CreateServicePolicyOptions;\n baseUrlOverride?: string;\n }) {\n this.name = serviceName;\n this.#messenger = messenger;\n this.#fetch = fetchFunction;\n this.#policy = createServicePolicy(policyOptions);\n this.#environment = environment;\n this.#context = context;\n this.#baseUrlOverride = baseUrlOverride;\n\n this.#messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Gets the base URL for API requests, respecting the baseUrlOverride if set.\n *\n * @param service - The API service type.\n * @returns The base URL to use.\n */\n #getBaseUrl(service: RampsApiService): string {\n if (this.#baseUrlOverride) {\n return this.#baseUrlOverride;\n }\n return getBaseUrl(this.#environment, service);\n }\n\n /**\n * Registers a handler that will be called after a request returns a non-500\n * response, causing a retry. Primarily useful in tests where timers are being\n * mocked.\n *\n * @param listener - The handler to be called.\n * @returns An object that can be used to unregister the handler. See\n * {@link CockatielEvent}.\n * @see {@link createServicePolicy}\n */\n onRetry(\n listener: Parameters<ServicePolicy['onRetry']>[0],\n ): ReturnType<ServicePolicy['onRetry']> {\n return this.#policy.onRetry(listener);\n }\n\n /**\n * Registers a handler that will be called after a set number of retry rounds\n * prove that requests to the API endpoint consistently return a 5xx response.\n *\n * @param listener - The handler to be called.\n * @returns An object that can be used to unregister the handler. See\n * {@link CockatielEvent}.\n * @see {@link createServicePolicy}\n */\n onBreak(\n listener: Parameters<ServicePolicy['onBreak']>[0],\n ): ReturnType<ServicePolicy['onBreak']> {\n return this.#policy.onBreak(listener);\n }\n\n /**\n * Registers a handler that will be called under one of two circumstances:\n *\n * 1. After a set number of retries prove that requests to the API\n * consistently result in one of the following failures:\n * 1. A connection initiation error\n * 2. A connection reset error\n * 3. A timeout error\n * 4. A non-JSON response\n * 5. A 502, 503, or 504 response\n * 2. After a successful request is made to the API, but the response takes\n * longer than a set duration to return.\n *\n * @param listener - The handler to be called.\n * @returns An object that can be used to unregister the handler. See\n * {@link CockatielEvent}.\n */\n onDegraded(\n listener: Parameters<ServicePolicy['onDegraded']>[0],\n ): ReturnType<ServicePolicy['onDegraded']> {\n return this.#policy.onDegraded(listener);\n }\n\n /**\n * Adds common request parameters to a URL.\n *\n * @param url - The URL to add parameters to.\n * @param action - The ramp action type (optional, not all endpoints require it).\n */\n #addCommonParams(url: URL, action?: RampAction): void {\n if (action) {\n url.searchParams.set('action', action);\n }\n url.searchParams.set('sdk', RAMPS_SDK_VERSION);\n url.searchParams.set('controller', packageJson.version);\n url.searchParams.set('context', this.#context);\n }\n\n /**\n * Makes an API request with retry policy and error handling.\n *\n * @param service - The API service type (determines base URL).\n * @param path - The endpoint path.\n * @param options - Request options.\n * @param options.action - The ramp action type (optional).\n * @param options.responseType - How to parse the response ('json' or 'text').\n * @returns The parsed response data.\n */\n async #request<TResponse>(\n service: RampsApiService,\n path: string,\n options: {\n action?: RampAction;\n responseType: 'json' | 'text';\n },\n ): Promise<TResponse> {\n return this.#policy.execute(async () => {\n const baseUrl = this.#getBaseUrl(service);\n const url = new URL(path, baseUrl);\n this.#addCommonParams(url, options.action);\n\n const response = await this.#fetch(url);\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Fetching '${url.toString()}' failed with status '${response.status}'`,\n );\n }\n\n return options.responseType === 'json'\n ? (response.json() as Promise<TResponse>)\n : (response.text() as Promise<TResponse>);\n });\n }\n\n /**\n * Makes a request to the API in order to retrieve the user's geolocation\n * based on their IP address.\n *\n * @returns The user's country/region code (e.g., \"US-UT\" for Utah, USA).\n */\n async getGeolocation(): Promise<string> {\n const textResponse = await this.#request<string>(\n RampsApiService.Orders,\n 'geolocation',\n { responseType: 'text' },\n );\n\n const trimmedResponse = textResponse.trim();\n if (trimmedResponse.length > 0) {\n return trimmedResponse;\n }\n\n throw new Error('Malformed response received from geolocation API');\n }\n\n /**\n * Makes a request to the cached API to retrieve the list of supported countries.\n * The API returns countries with support information for both buy and sell actions.\n * Filters countries based on aggregator support (preserves OnRampSDK logic).\n *\n * @returns An array of countries filtered by aggregator support.\n */\n async getCountries(): Promise<Country[]> {\n const countries = await this.#request<Country[]>(\n RampsApiService.Regions,\n getApiPath('regions/countries'),\n { responseType: 'json' },\n );\n\n if (!Array.isArray(countries)) {\n throw new Error('Malformed response received from countries API');\n }\n\n return countries.filter((country) => {\n const isCountrySupported =\n country.supported.buy || country.supported.sell;\n\n if (country.states && country.states.length > 0) {\n const hasSupportedState = country.states.some(\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- intentionally using || to treat false as unsupported\n (state) => state.supported?.buy || state.supported?.sell,\n );\n return isCountrySupported || hasSupportedState;\n }\n\n return isCountrySupported;\n });\n }\n\n /**\n * Fetches the list of available tokens for a given region and action.\n * Supports optional provider filter.\n *\n * @param region - The region code (e.g., \"us\", \"fr\", \"us-ny\").\n * @param action - The ramp action type ('buy' or 'sell').\n * @param options - Optional query parameters for filtering tokens.\n * @param options.provider - Provider ID(s) to filter by.\n * @returns The tokens response containing topTokens and allTokens.\n */\n async getTokens(\n region: string,\n action: RampAction = 'buy',\n options?: {\n provider?: string | string[];\n },\n ): Promise<TokensResponse> {\n const normalizedRegion = region.toLowerCase().trim();\n const url = new URL(\n getApiPath(`regions/${normalizedRegion}/topTokens`),\n this.#getBaseUrl(RampsApiService.Regions),\n );\n this.#addCommonParams(url, action);\n\n if (options?.provider) {\n const providerIds = Array.isArray(options.provider)\n ? options.provider\n : [options.provider];\n providerIds.forEach((id) => url.searchParams.append('provider', id));\n }\n\n const response = await this.#policy.execute(async () => {\n const fetchResponse = await this.#fetch(url);\n if (!fetchResponse.ok) {\n throw new HttpError(\n fetchResponse.status,\n `Fetching '${url.toString()}' failed with status '${fetchResponse.status}'`,\n );\n }\n return fetchResponse.json() as Promise<TokensResponse>;\n });\n\n if (!response || typeof response !== 'object') {\n throw new Error('Malformed response received from tokens API');\n }\n\n if (\n !Array.isArray(response.topTokens) ||\n !Array.isArray(response.allTokens)\n ) {\n throw new Error('Malformed response received from tokens API');\n }\n\n return response;\n }\n\n /**\n * Fetches the list of providers for a given region.\n * Supports optional query filters: provider, crypto, fiat, payments.\n *\n * @param regionCode - The region code (e.g., \"us\", \"fr\", \"us-ny\").\n * @param options - Optional query parameters for filtering providers.\n * @param options.provider - Provider ID(s) to filter by.\n * @param options.crypto - Crypto currency ID(s) to filter by.\n * @param options.fiat - Fiat currency ID(s) to filter by.\n * @param options.payments - Payment method ID(s) to filter by.\n * @returns The providers response containing providers array.\n */\n async getProviders(\n regionCode: string,\n options?: {\n provider?: string | string[];\n crypto?: string | string[];\n fiat?: string | string[];\n payments?: string | string[];\n },\n ): Promise<{ providers: Provider[] }> {\n const normalizedRegion = regionCode.toLowerCase().trim();\n const url = new URL(\n getApiPath(`regions/${normalizedRegion}/providers`),\n this.#getBaseUrl(RampsApiService.Regions),\n );\n this.#addCommonParams(url);\n\n if (options?.provider) {\n const providerIds = Array.isArray(options.provider)\n ? options.provider\n : [options.provider];\n providerIds.forEach((id) => url.searchParams.append('provider', id));\n }\n\n if (options?.crypto) {\n const cryptoIds = Array.isArray(options.crypto)\n ? options.crypto\n : [options.crypto];\n cryptoIds.forEach((id) => url.searchParams.append('crypto', id));\n }\n\n if (options?.fiat) {\n const fiatIds = Array.isArray(options.fiat)\n ? options.fiat\n : [options.fiat];\n fiatIds.forEach((id) => url.searchParams.append('fiat', id));\n }\n\n if (options?.payments) {\n const paymentIds = Array.isArray(options.payments)\n ? options.payments\n : [options.payments];\n paymentIds.forEach((id) => url.searchParams.append('payments', id));\n }\n\n const response = await this.#policy.execute(async () => {\n const fetchResponse = await this.#fetch(url);\n if (!fetchResponse.ok) {\n throw new HttpError(\n fetchResponse.status,\n `Fetching '${url.toString()}' failed with status '${fetchResponse.status}'`,\n );\n }\n return fetchResponse.json() as Promise<{ providers: Provider[] }>;\n });\n\n if (!response || typeof response !== 'object') {\n throw new Error('Malformed response received from providers API');\n }\n\n if (!Array.isArray(response.providers)) {\n throw new Error('Malformed response received from providers API');\n }\n\n return response;\n }\n\n /**\n * Fetches the list of payment methods for a given region, asset, and provider.\n *\n * @param options - Query parameters for filtering payment methods.\n * @param options.region - User's region code (e.g., \"us-al\").\n * @param options.fiat - Fiat currency code (e.g., \"usd\").\n * @param options.assetId - CAIP-19 cryptocurrency identifier.\n * @param options.provider - Provider ID path.\n * @returns The payment methods response containing payments array.\n */\n async getPaymentMethods(options: {\n region: string;\n fiat: string;\n assetId: string;\n provider: string;\n }): Promise<PaymentMethodsResponse> {\n const normalizedRegion = options.region.toLowerCase().trim();\n const url = new URL(\n getApiPath(`regions/${normalizedRegion}/payments`),\n this.#getBaseUrl(RampsApiService.Regions),\n );\n this.#addCommonParams(url);\n\n url.searchParams.set('region', options.region.toLowerCase().trim());\n url.searchParams.set('fiat', options.fiat.toLowerCase().trim());\n url.searchParams.set('crypto', options.assetId);\n url.searchParams.set('provider', options.provider);\n\n const response = await this.#policy.execute(async () => {\n const fetchResponse = await this.#fetch(url);\n if (!fetchResponse.ok) {\n throw new HttpError(\n fetchResponse.status,\n `Fetching '${url.toString()}' failed with status '${fetchResponse.status}'`,\n );\n }\n return fetchResponse.json() as Promise<PaymentMethodsResponse>;\n });\n\n if (!response || typeof response !== 'object') {\n throw new Error('Malformed response received from paymentMethods API');\n }\n\n if (!Array.isArray(response.payments)) {\n throw new Error('Malformed response received from paymentMethods API');\n }\n\n return response;\n }\n\n /**\n * Fetches quotes from all providers for a given set of parameters.\n * Uses the V2 orders API to get quotes for multiple payment methods at once.\n *\n * @param params - The parameters for fetching quotes.\n * @param params.region - User's region code (e.g., \"us\", \"us-ca\").\n * @param params.paymentMethods - Array of payment method IDs.\n * @param params.assetId - CAIP-19 cryptocurrency identifier.\n * @param params.fiat - Fiat currency code (e.g., \"usd\").\n * @param params.amount - The amount (in fiat for buy, crypto for sell).\n * @param params.walletAddress - The destination wallet address.\n * @param params.redirectUrl - Optional redirect URL after order completion.\n * @param params.providers - Optional provider IDs to filter quotes.\n * @param params.action - The ramp action type. Defaults to 'buy'.\n * @returns The quotes response containing success, sorted, error, and customActions.\n */\n async getQuotes(params: GetQuotesParams): Promise<QuotesResponse> {\n const normalizedRegion = params.region.toLowerCase().trim();\n const normalizedFiat = params.fiat.toLowerCase().trim();\n const action = params.action ?? 'buy';\n\n const url = new URL(\n getApiPath('quotes'),\n getBaseUrl(this.#environment, RampsApiService.Orders),\n );\n this.#addCommonParams(url, action);\n\n // Build region ID in the format expected by the API\n url.searchParams.set('region', normalizedRegion);\n url.searchParams.set('fiat', normalizedFiat);\n url.searchParams.set('crypto', params.assetId);\n url.searchParams.set('amount', String(params.amount));\n url.searchParams.set('walletAddress', params.walletAddress);\n\n // Add payment methods as array parameters\n params.paymentMethods.forEach((paymentMethod) => {\n url.searchParams.append('payments', paymentMethod);\n });\n\n // Add provider filter if specified\n params.providers?.forEach((provider) => {\n url.searchParams.append('providers', provider);\n });\n\n // Add redirect URL if specified\n if (params.redirectUrl) {\n url.searchParams.set('redirectUrl', params.redirectUrl);\n }\n\n const response = await this.#policy.execute(async () => {\n const fetchResponse = await this.#fetch(url);\n if (!fetchResponse.ok) {\n throw new HttpError(\n fetchResponse.status,\n `Fetching '${url.toString()}' failed with status '${fetchResponse.status}'`,\n );\n }\n return fetchResponse.json() as Promise<QuotesResponse>;\n });\n\n if (!response || typeof response !== 'object') {\n throw new Error('Malformed response received from quotes API');\n }\n\n if (\n !Array.isArray(response.success) ||\n !Array.isArray(response.sorted) ||\n !Array.isArray(response.error) ||\n !Array.isArray(response.customActions)\n ) {\n throw new Error('Malformed response received from quotes API');\n }\n\n return response;\n }\n\n /**\n * Fetches the buy widget data from a buy URL endpoint.\n * Makes a request to the buyURL (as provided in a quote) to get the actual\n * provider widget URL, browser type, and order ID.\n *\n * @param buyUrl - The full buy URL endpoint to fetch from.\n * @returns The buy widget data containing the provider widget URL.\n */\n async getBuyWidgetUrl(buyUrl: string): Promise<BuyWidget> {\n const url = new URL(buyUrl);\n this.#addCommonParams(url);\n\n const response = await this.#policy.execute(async () => {\n const fetchResponse = await this.#fetch(url);\n if (!fetchResponse.ok) {\n throw new HttpError(\n fetchResponse.status,\n `Fetching '${url.toString()}' failed with status '${fetchResponse.status}'`,\n );\n }\n return fetchResponse.json() as Promise<BuyWidget>;\n });\n\n if (!response || typeof response !== 'object' || !response.url) {\n throw new Error('Malformed response received from buy widget URL API');\n }\n\n return response;\n }\n}\n"]}
{
"name": "@metamask/ramps-controller",
"version": "7.1.0",
"version": "8.0.0",
"description": "A controller for managing cryptocurrency on/off ramps functionality",

@@ -59,11 +59,10 @@ "keywords": [

"@ts-bridge/cli": "^0.6.4",
"@types/jest": "^27.5.2",
"@types/jest": "^29.5.14",
"@types/sinon": "^9.0.10",
"deepmerge": "^4.2.2",
"isomorphic-fetch": "^3.0.0",
"jest": "^27.5.1",
"jest": "^29.7.0",
"nock": "^13.3.1",
"sinon": "^9.2.4",
"ts-jest": "^27.1.5",
"typedoc": "^0.24.8",
"ts-jest": "^29.2.5",
"typedoc": "^0.25.13",
"typedoc-plugin-missing-exports": "^2.0.0",

@@ -70,0 +69,0 @@ "typescript": "~5.3.3"

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display