@metamask/ramps-controller 6.0.0 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -12
- package/dist/RampsController.cjs +145 -5
- package/dist/RampsController.cjs.map +1 -1
- package/dist/RampsController.d.cts +37 -2
- package/dist/RampsController.d.cts.map +1 -1
- package/dist/RampsController.d.mts +37 -2
- package/dist/RampsController.d.mts.map +1 -1
- package/dist/RampsController.mjs +145 -5
- package/dist/RampsController.mjs.map +1 -1
- package/dist/RampsService.cjs +1 -1
- package/dist/RampsService.cjs.map +1 -1
- package/dist/RampsService.d.cts +2 -2
- package/dist/RampsService.d.cts.map +1 -1
- package/dist/RampsService.d.mts +2 -2
- package/dist/RampsService.d.mts.map +1 -1
- package/dist/RampsService.mjs +1 -1
- package/dist/RampsService.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
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,c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AAA,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 * 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 * Human-readable delay description (e.g., \"5 to 10 minutes.\").\n */\n delay?: string;\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('orders/all/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"]}
|
|
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,C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,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"]}
|
package/dist/RampsService.d.cts
CHANGED
|
@@ -107,9 +107,9 @@ export type PaymentMethod = {
|
|
|
107
107
|
*/
|
|
108
108
|
disclaimer?: string;
|
|
109
109
|
/**
|
|
110
|
-
*
|
|
110
|
+
* Delay in minutes (e.g., [5, 10]).
|
|
111
111
|
*/
|
|
112
|
-
delay?:
|
|
112
|
+
delay?: number[];
|
|
113
113
|
/**
|
|
114
114
|
* Localized pending order description (optional).
|
|
115
115
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RampsService.d.cts","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;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IACH,GAAG,EAAE,OAAO,CAAC;IACb;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B;;O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ACG,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;CA2DlE"}
|
package/dist/RampsService.d.mts
CHANGED
|
@@ -107,9 +107,9 @@ export type PaymentMethod = {
|
|
|
107
107
|
*/
|
|
108
108
|
disclaimer?: string;
|
|
109
109
|
/**
|
|
110
|
-
*
|
|
110
|
+
* Delay in minutes (e.g., [5, 10]).
|
|
111
111
|
*/
|
|
112
|
-
delay?:
|
|
112
|
+
delay?: number[];
|
|
113
113
|
/**
|
|
114
114
|
* Localized pending order description (optional).
|
|
115
115
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RampsService.d.mts","sourceRoot":"","sources":["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Q,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;CA2DlE"}
|
package/dist/RampsService.mjs
CHANGED
|
@@ -404,7 +404,7 @@ export class RampsService {
|
|
|
404
404
|
const normalizedRegion = params.region.toLowerCase().trim();
|
|
405
405
|
const normalizedFiat = params.fiat.toLowerCase().trim();
|
|
406
406
|
const action = params.action ?? 'buy';
|
|
407
|
-
const url = new URL(getApiPath('
|
|
407
|
+
const url = new URL(getApiPath('quotes'), getBaseUrl(__classPrivateFieldGet(this, _RampsService_environment, "f"), RampsApiService.Orders));
|
|
408
408
|
__classPrivateFieldGet(this, _RampsService_instances, "m", _RampsService_addCommonParams).call(this, url, action);
|
|
409
409
|
// Build region ID in the format expected by the API
|
|
410
410
|
url.searchParams.set('region', normalizedRegion);
|
|
@@ -1 +1 @@
|
|
|
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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;QACrC,MAAM,OAAO,GAAG,uBAAA,IAAI,yDAAY,MAAhB,IAAI,EAAa,OAAO,CAAC,CAAC;QAC1C,MAAM,GAAG,GAAG,IAAI,GAAG,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 * Human-readable delay description (e.g., \"5 to 10 minutes.\").\n */\n delay?: string;\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('orders/all/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"]}
|
|
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,eAGX;AAHD,WAAY,eAAe;IAC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AO,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"]}
|