@metamask/ramps-controller 20.2.0 → 21.0.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 +30 -1
- package/dist/NeoBankService-method-action-types.d.ts +126 -0
- package/dist/NeoBankService-method-action-types.d.ts.map +1 -0
- package/dist/{TransakService-method-action-types.mjs → NeoBankService-method-action-types.js} +1 -1
- package/dist/NeoBankService-method-action-types.js.map +1 -0
- package/dist/NeoBankService.d.ts +191 -0
- package/dist/NeoBankService.d.ts.map +1 -0
- package/dist/NeoBankService.js +380 -0
- package/dist/NeoBankService.js.map +1 -0
- package/dist/{RampsController-method-action-types.d.mts → RampsController-method-action-types.d.ts} +93 -3
- package/dist/RampsController-method-action-types.d.ts.map +1 -0
- package/dist/{RampsController-method-action-types.mjs → RampsController-method-action-types.js} +1 -1
- package/dist/RampsController-method-action-types.js.map +1 -0
- package/dist/{RampsController.d.cts → RampsController.d.ts} +164 -17
- package/dist/RampsController.d.ts.map +1 -0
- package/dist/{RampsController.mjs → RampsController.js} +1064 -582
- package/dist/RampsController.js.map +1 -0
- package/dist/{RampsService-method-action-types.d.cts → RampsService-method-action-types.d.ts} +2 -2
- package/dist/RampsService-method-action-types.d.ts.map +1 -0
- package/dist/{RampsService-method-action-types.mjs → RampsService-method-action-types.js} +1 -1
- package/dist/RampsService-method-action-types.js.map +1 -0
- package/dist/{RampsService.d.mts → RampsService.d.ts} +5 -5
- package/dist/RampsService.d.ts.map +1 -0
- package/dist/{RampsService.mjs → RampsService.js} +159 -147
- package/dist/RampsService.js.map +1 -0
- package/dist/{RequestCache.d.cts → RequestCache.d.ts} +3 -3
- package/dist/RequestCache.d.ts.map +1 -0
- package/dist/{RequestCache.mjs → RequestCache.js} +1 -1
- package/dist/RequestCache.js.map +1 -0
- package/dist/{TransakService-method-action-types.d.cts → TransakService-method-action-types.d.ts} +2 -2
- package/dist/TransakService-method-action-types.d.ts.map +1 -0
- package/dist/TransakService-method-action-types.js +6 -0
- package/dist/TransakService-method-action-types.js.map +1 -0
- package/dist/{TransakService.d.mts → TransakService.d.ts} +6 -6
- package/dist/TransakService.d.ts.map +1 -0
- package/dist/TransakService.js +746 -0
- package/dist/TransakService.js.map +1 -0
- package/dist/autoramp-types.d.ts +22 -0
- package/dist/autoramp-types.d.ts.map +1 -0
- package/dist/autoramp-types.js +2 -0
- package/dist/autoramp-types.js.map +1 -0
- package/dist/autorampAccount.d.ts +126 -0
- package/dist/autorampAccount.d.ts.map +1 -0
- package/dist/autorampAccount.js +147 -0
- package/dist/autorampAccount.js.map +1 -0
- package/dist/{client-identity.d.cts → client-identity.d.ts} +1 -1
- package/dist/client-identity.d.ts.map +1 -0
- package/dist/{client-identity.mjs → client-identity.js} +1 -1
- package/dist/client-identity.js.map +1 -0
- package/dist/{errorNormalization.d.mts → errorNormalization.d.ts} +1 -1
- package/dist/errorNormalization.d.ts.map +1 -0
- package/dist/{errorNormalization.mjs → errorNormalization.js} +1 -1
- package/dist/errorNormalization.js.map +1 -0
- package/dist/{featureFlags.d.mts → featureFlags.d.ts} +2 -2
- package/dist/featureFlags.d.ts.map +1 -0
- package/dist/{featureFlags.mjs → featureFlags.js} +1 -1
- package/dist/featureFlags.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/{orderStatus.d.mts → orderStatus.d.ts} +2 -2
- package/dist/orderStatus.d.ts.map +1 -0
- package/dist/{orderStatus.mjs → orderStatus.js} +2 -2
- package/dist/orderStatus.js.map +1 -0
- package/dist/ownership-message.d.ts +22 -0
- package/dist/ownership-message.d.ts.map +1 -0
- package/dist/ownership-message.js +22 -0
- package/dist/ownership-message.js.map +1 -0
- package/dist/{paymentMethodMerge.d.cts → paymentMethodMerge.d.ts} +2 -2
- package/dist/paymentMethodMerge.d.ts.map +1 -0
- package/dist/{paymentMethodMerge.mjs → paymentMethodMerge.js} +1 -1
- package/dist/paymentMethodMerge.js.map +1 -0
- package/dist/{providerAvailability.d.mts → providerAvailability.d.ts} +2 -2
- package/dist/providerAvailability.d.ts.map +1 -0
- package/dist/{providerAvailability.mjs → providerAvailability.js} +1 -1
- package/dist/providerAvailability.js.map +1 -0
- package/dist/{quoteClassification.d.cts → quoteClassification.d.ts} +2 -2
- package/dist/quoteClassification.d.ts.map +1 -0
- package/dist/{quoteClassification.mjs → quoteClassification.js} +1 -1
- package/dist/quoteClassification.js.map +1 -0
- package/dist/{rampsErrorCodes.d.cts → rampsErrorCodes.d.ts} +2 -2
- package/dist/rampsErrorCodes.d.ts.map +1 -0
- package/dist/{rampsErrorCodes.mjs → rampsErrorCodes.js} +1 -1
- package/dist/rampsErrorCodes.js.map +1 -0
- package/dist/{selectors.d.mts → selectors.d.ts} +3 -3
- package/dist/selectors.d.ts.map +1 -0
- package/dist/{selectors.mjs → selectors.js} +2 -2
- package/dist/selectors.js.map +1 -0
- package/dist/{transakApiErrorUtils.d.cts → transakApiErrorUtils.d.ts} +1 -1
- package/dist/transakApiErrorUtils.d.ts.map +1 -0
- package/dist/{transakApiErrorUtils.mjs → transakApiErrorUtils.js} +3 -3
- package/dist/transakApiErrorUtils.js.map +1 -0
- package/dist/{transakErrorCodes.d.cts → transakErrorCodes.d.ts} +3 -3
- package/dist/transakErrorCodes.d.ts.map +1 -0
- package/dist/{transakErrorCodes.mjs → transakErrorCodes.js} +1 -1
- package/dist/transakErrorCodes.js.map +1 -0
- package/dist/wallet-registration-machine.d.ts +81 -0
- package/dist/wallet-registration-machine.d.ts.map +1 -0
- package/dist/wallet-registration-machine.js +139 -0
- package/dist/wallet-registration-machine.js.map +1 -0
- package/dist/wallet-registration-service.d.ts +144 -0
- package/dist/wallet-registration-service.d.ts.map +1 -0
- package/dist/wallet-registration-service.js +335 -0
- package/dist/wallet-registration-service.js.map +1 -0
- package/package.json +17 -21
- package/dist/RampsController-method-action-types.cjs +0 -7
- package/dist/RampsController-method-action-types.cjs.map +0 -1
- package/dist/RampsController-method-action-types.d.cts +0 -668
- package/dist/RampsController-method-action-types.d.cts.map +0 -1
- package/dist/RampsController-method-action-types.d.mts.map +0 -1
- package/dist/RampsController-method-action-types.mjs.map +0 -1
- package/dist/RampsController.cjs +0 -2429
- package/dist/RampsController.cjs.map +0 -1
- package/dist/RampsController.d.cts.map +0 -1
- package/dist/RampsController.d.mts +0 -821
- package/dist/RampsController.d.mts.map +0 -1
- package/dist/RampsController.mjs.map +0 -1
- package/dist/RampsService-method-action-types.cjs +0 -7
- package/dist/RampsService-method-action-types.cjs.map +0 -1
- package/dist/RampsService-method-action-types.d.cts.map +0 -1
- package/dist/RampsService-method-action-types.d.mts +0 -171
- package/dist/RampsService-method-action-types.d.mts.map +0 -1
- package/dist/RampsService-method-action-types.mjs.map +0 -1
- package/dist/RampsService.cjs +0 -708
- package/dist/RampsService.cjs.map +0 -1
- package/dist/RampsService.d.cts +0 -944
- package/dist/RampsService.d.cts.map +0 -1
- package/dist/RampsService.d.mts.map +0 -1
- package/dist/RampsService.mjs.map +0 -1
- package/dist/RequestCache.cjs +0 -103
- package/dist/RequestCache.cjs.map +0 -1
- package/dist/RequestCache.d.cts.map +0 -1
- package/dist/RequestCache.d.mts +0 -110
- package/dist/RequestCache.d.mts.map +0 -1
- package/dist/RequestCache.mjs.map +0 -1
- package/dist/TransakService-method-action-types.cjs +0 -7
- package/dist/TransakService-method-action-types.cjs.map +0 -1
- package/dist/TransakService-method-action-types.d.cts.map +0 -1
- package/dist/TransakService-method-action-types.d.mts +0 -140
- package/dist/TransakService-method-action-types.d.mts.map +0 -1
- package/dist/TransakService-method-action-types.mjs.map +0 -1
- package/dist/TransakService.cjs +0 -743
- package/dist/TransakService.cjs.map +0 -1
- package/dist/TransakService.d.cts +0 -370
- package/dist/TransakService.d.cts.map +0 -1
- package/dist/TransakService.d.mts.map +0 -1
- package/dist/TransakService.mjs +0 -734
- package/dist/TransakService.mjs.map +0 -1
- package/dist/client-identity.cjs +0 -28
- package/dist/client-identity.cjs.map +0 -1
- package/dist/client-identity.d.cts.map +0 -1
- package/dist/client-identity.d.mts +0 -24
- package/dist/client-identity.d.mts.map +0 -1
- package/dist/client-identity.mjs.map +0 -1
- package/dist/errorNormalization.cjs +0 -84
- package/dist/errorNormalization.cjs.map +0 -1
- package/dist/errorNormalization.d.cts +0 -56
- package/dist/errorNormalization.d.cts.map +0 -1
- package/dist/errorNormalization.d.mts.map +0 -1
- package/dist/errorNormalization.mjs.map +0 -1
- package/dist/featureFlags.cjs +0 -144
- package/dist/featureFlags.cjs.map +0 -1
- package/dist/featureFlags.d.cts +0 -82
- package/dist/featureFlags.d.cts.map +0 -1
- package/dist/featureFlags.d.mts.map +0 -1
- package/dist/featureFlags.mjs.map +0 -1
- package/dist/index.cjs +0 -63
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -26
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts +0 -26
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -14
- package/dist/index.mjs.map +0 -1
- package/dist/orderStatus.cjs +0 -34
- package/dist/orderStatus.cjs.map +0 -1
- package/dist/orderStatus.d.cts +0 -18
- package/dist/orderStatus.d.cts.map +0 -1
- package/dist/orderStatus.d.mts.map +0 -1
- package/dist/orderStatus.mjs.map +0 -1
- package/dist/paymentMethodMerge.cjs +0 -51
- package/dist/paymentMethodMerge.cjs.map +0 -1
- package/dist/paymentMethodMerge.d.cts.map +0 -1
- package/dist/paymentMethodMerge.d.mts +0 -26
- package/dist/paymentMethodMerge.d.mts.map +0 -1
- package/dist/paymentMethodMerge.mjs.map +0 -1
- package/dist/providerAvailability.cjs +0 -134
- package/dist/providerAvailability.cjs.map +0 -1
- package/dist/providerAvailability.d.cts +0 -101
- package/dist/providerAvailability.d.cts.map +0 -1
- package/dist/providerAvailability.d.mts.map +0 -1
- package/dist/providerAvailability.mjs.map +0 -1
- package/dist/quoteClassification.cjs +0 -44
- package/dist/quoteClassification.cjs.map +0 -1
- package/dist/quoteClassification.d.cts.map +0 -1
- package/dist/quoteClassification.d.mts +0 -33
- package/dist/quoteClassification.d.mts.map +0 -1
- package/dist/quoteClassification.mjs.map +0 -1
- package/dist/rampsErrorCodes.cjs +0 -11
- package/dist/rampsErrorCodes.cjs.map +0 -1
- package/dist/rampsErrorCodes.d.cts.map +0 -1
- package/dist/rampsErrorCodes.d.mts +0 -9
- package/dist/rampsErrorCodes.d.mts.map +0 -1
- package/dist/rampsErrorCodes.mjs.map +0 -1
- package/dist/selectors.cjs +0 -85
- package/dist/selectors.cjs.map +0 -1
- package/dist/selectors.d.cts +0 -78
- package/dist/selectors.d.cts.map +0 -1
- package/dist/selectors.d.mts.map +0 -1
- package/dist/selectors.mjs.map +0 -1
- package/dist/transakApiErrorUtils.cjs +0 -15
- package/dist/transakApiErrorUtils.cjs.map +0 -1
- package/dist/transakApiErrorUtils.d.cts.map +0 -1
- package/dist/transakApiErrorUtils.d.mts +0 -3
- package/dist/transakApiErrorUtils.d.mts.map +0 -1
- package/dist/transakApiErrorUtils.mjs.map +0 -1
- package/dist/transakErrorCodes.cjs +0 -14
- package/dist/transakErrorCodes.cjs.map +0 -1
- package/dist/transakErrorCodes.d.cts.map +0 -1
- package/dist/transakErrorCodes.d.mts +0 -12
- package/dist/transakErrorCodes.d.mts.map +0 -1
- package/dist/transakErrorCodes.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TransakService.mjs","sourceRoot":"","sources":["../src/TransakService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,mCAAmC;AAI5E,OAAO,WAAW,8CAAwB;AAE1C,OAAO,EAAE,4BAA4B,EAAE,8BAA6B;AACpE,OAAO,EAAE,iBAAiB,EAAE,2BAA0B;AACtD,OAAO,EAAE,mBAAmB,EAAE,gCAA+B;AA+P7D,sBAAsB;AAEtB,MAAM,CAAN,IAAY,kBAIX;AAJD,WAAY,kBAAk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C;IACvD,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,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';\nimport type { AuthenticationController } from '@metamask/profile-sync-controller';\n\nimport packageJson from '../package.json';\nimport type { RampsClientIdentity } from './client-identity.js';\nimport { addRampsClientIdentityParams } from './client-identity.js';\nimport { RAMPS_SDK_VERSION } from './RampsService.js';\nimport { TRANSAK_ERROR_CODES } from './transakErrorCodes.js';\nimport type { TransakServiceMethodActions } from './TransakService-method-action-types.js';\n\n// === TYPES ===\n\nexport type TransakAccessToken = {\n accessToken: string;\n ttl: number;\n created: Date;\n};\n\nexport type TransakUserDetails = {\n id: string;\n firstName: string;\n lastName: string;\n email: string;\n mobileNumber: string;\n status: string;\n dob: string;\n kyc: TransakUserDetailsKycDetails;\n address: TransakUserDetailsAddress;\n createdAt: string;\n};\n\nexport type TransakUserDetailsAddress = {\n addressLine1: string;\n addressLine2: string;\n state: string;\n city: string;\n postCode: string;\n country: string;\n countryCode: string;\n};\n\nexport type TransakUserDetailsKycDetails = {\n status: string;\n type: string;\n attempts: TransakUserDetailsKycAttempt[];\n highestApprovedKYCType: string | null;\n kycMarkedBy: string | null;\n kycResult: string | null;\n rejectionDetails: TransakUserDetailsKycAttemptRejectionDetails | null;\n userId: string;\n workFlowRunId: string;\n};\n\nexport type TransakUserDetailsKycAttempt = {\n artifacts: { key: string; value: string }[];\n metadata: {\n transaction: {\n kycVendorId: string;\n scanReference: string;\n workflowId: string;\n };\n };\n rejectionDetails: TransakUserDetailsKycAttemptRejectionDetails;\n result: string;\n sessionId: string;\n};\n\nexport type TransakUserDetailsKycAttemptRejectionDetails = {\n archetype: string;\n reason: string;\n reasonCode: string;\n};\n\nexport type TransakBuyQuote = {\n quoteId: string;\n conversionPrice: number;\n marketConversionPrice: number;\n slippage: number;\n fiatCurrency: string;\n cryptoCurrency: string;\n paymentMethod: string;\n fiatAmount: number;\n cryptoAmount: number;\n isBuyOrSell: string;\n network: string;\n feeDecimal: number;\n totalFee: number;\n feeBreakdown: { [prop: string]: string | number | boolean | null }[];\n nonce: number;\n cryptoLiquidityProvider: string;\n notes: { [prop: string]: string | number | boolean | null }[];\n};\n\nexport type TransakKycRequirement = {\n status:\n | 'NOT_SUBMITTED'\n | 'APPROVED'\n | 'ADDITIONAL_FORMS_REQUIRED'\n | 'SUBMITTED';\n kycType: string;\n isAllowedToPlaceOrder: boolean;\n};\n\nexport type TransakAdditionalRequirement = {\n type: string;\n metadata?: {\n options: string[];\n documentProofOptions: string[];\n expiresAt: string;\n kycUrl: string;\n workFlowRunId: string;\n };\n};\n\nexport type TransakAdditionalRequirementsResponse = {\n formsRequired: TransakAdditionalRequirement[];\n};\n\nexport type TransakOttResponse = {\n ott: string;\n};\n\nexport type TransakOrderPaymentMethod = {\n fiatCurrency: string;\n paymentMethod: string;\n fields: { name: string; id: string; value: string }[];\n};\n\nexport type TransakDepositNetwork = {\n name: string;\n chainId: string;\n};\n\nexport type TransakDepositCryptoCurrency = {\n assetId: string;\n name: string;\n chainId: string;\n decimals: number;\n iconUrl: string;\n symbol: string;\n};\n\nexport type TransakDepositPaymentMethod = {\n id: string;\n name: string;\n shortName?: string;\n duration: string;\n icon: string;\n iconColor?: { light: string; dark: string };\n isManualBankTransfer?: boolean;\n};\n\nexport type TransakDepositRegion = {\n isoCode: string;\n flag: string;\n name: string;\n phone: { prefix: string; placeholder: string; template: string };\n currency: string;\n supported: boolean;\n recommended?: boolean;\n geolocated?: boolean;\n};\n\nexport type TransakDepositOrder = {\n id: string;\n provider: string;\n cryptoAmount: number | string;\n fiatAmount: number;\n cryptoCurrency: TransakDepositCryptoCurrency;\n fiatCurrency: string;\n providerOrderId: string;\n providerOrderLink: string;\n createdAt: number;\n paymentMethod: TransakDepositPaymentMethod;\n totalFeesFiat: number;\n txHash: string;\n walletAddress: string;\n status: string;\n network: TransakDepositNetwork;\n timeDescriptionPending: string;\n fiatAmountInUsd: number;\n feesInUsd: number;\n region: TransakDepositRegion;\n orderType: 'DEPOSIT';\n exchangeRate?: number;\n statusDescription?: string;\n paymentDetails: TransakOrderPaymentMethod[];\n partnerFees?: number;\n networkFees?: number;\n};\n\nexport type TransakOrder = {\n orderId: string;\n partnerUserId: string;\n status: string;\n isBuyOrSell: string;\n fiatCurrency: string;\n cryptoCurrency: string;\n network: string;\n walletAddress: string;\n quoteId: string;\n fiatAmount: number;\n fiatAmountInUsd: number;\n amountPaid: number;\n cryptoAmount: number;\n conversionPrice: number;\n totalFeeInFiat: number;\n paymentDetails: TransakOrderPaymentMethod[];\n txHash: string;\n transationLink: string | null;\n createdAt: string;\n updatedAt: string;\n completedAt: string;\n};\n\nexport type TransakQuoteTranslation = {\n region: string;\n paymentMethod: string | undefined;\n cryptoCurrency: string;\n network: string;\n fiatCurrency: string;\n};\n\nexport type TransakTranslationRequest = {\n regionId?: string;\n cryptoCurrencyId?: string;\n chainId?: string;\n fiatCurrencyId?: string;\n paymentMethod?: string;\n};\n\nexport type TransakUserLimits = {\n limits: { '1': number; '30': number; '365': number };\n spent: { '1': number; '30': number; '365': number };\n remaining: { '1': number; '30': number; '365': number };\n exceeded: { '1': boolean; '30': boolean; '365': boolean };\n shortage: Record<string, number>;\n};\n\nexport type PatchUserRequestBody = Partial<{\n personalDetails: Partial<{\n firstName: string;\n lastName: string;\n mobileNumber: string;\n dob: string;\n }>;\n addressDetails: Partial<{\n addressLine1: string;\n addressLine2: string;\n state: string;\n city: string;\n postCode: string;\n countryCode: string;\n }>;\n}>;\n\nexport type TransakIdProofStatus = {\n status: 'NOT_SUBMITTED' | 'SUBMITTED';\n kycType: string;\n randomLogIdentifier: string;\n};\n\n// === ENVIRONMENT ===\n\nexport enum TransakEnvironment {\n Production = 'production',\n Staging = 'staging',\n Development = 'development',\n}\n\nenum TransakApiProviders {\n TransakNative = 'transak-native',\n TransakNativeStaging = 'transak-native-staging',\n}\n\n// === ORDER ID UTILITIES ===\n\nexport class TransakOrderIdTransformer {\n static depositOrderIdToTransakOrderId(depositOrderId: string): string {\n const parts = depositOrderId.split('/');\n return parts[parts.length - 1];\n }\n\n static transakOrderIdToDepositOrderId(\n transakOrderId: string,\n environment: TransakEnvironment,\n ): string {\n const provider =\n environment === TransakEnvironment.Production\n ? 'transak-native'\n : 'transak-native-staging';\n return `/providers/${provider}/orders/${transakOrderId}`;\n }\n\n static isDepositOrderId(orderId: string): boolean {\n return orderId.startsWith('/providers/');\n }\n\n static extractTransakOrderId(orderId: string): string {\n return this.isDepositOrderId(orderId)\n ? this.depositOrderIdToTransakOrderId(orderId)\n : orderId;\n }\n}\n\n// === MESSENGER ===\n\nconst serviceName = 'TransakService';\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'setApiKey',\n 'setAccessToken',\n 'clearAccessToken',\n 'sendUserOtp',\n 'verifyUserOtp',\n 'logout',\n 'getUserDetails',\n 'getBuyQuote',\n 'getKycRequirement',\n 'getAdditionalRequirements',\n 'createOrder',\n 'getOrder',\n 'getUserLimits',\n 'requestOtt',\n 'generatePaymentWidgetUrl',\n 'createWidgetUrl',\n 'submitPurposeOfUsageForm',\n 'patchUser',\n 'submitSsnDetails',\n 'confirmPayment',\n 'getTranslation',\n 'getIdProofStatus',\n 'cancelOrder',\n 'cancelAllActiveOrders',\n 'getActiveOrders',\n] as const;\n\nexport type TransakServiceActions = TransakServiceMethodActions;\n\n/**\n * Actions from other messengers that {@link TransakService} calls.\n */\ntype AllowedActions =\n AuthenticationController.AuthenticationControllerGetBearerTokenAction;\n\nexport type TransakServiceEvents = never;\n\ntype AllowedEvents = never;\n\nexport type TransakServiceMessenger = Messenger<\n typeof serviceName,\n TransakServiceActions | AllowedActions,\n TransakServiceEvents | AllowedEvents\n>;\n\n// === HELPER FUNCTIONS ===\n\n/**\n * Maps ramps API payment method IDs (e.g., \"/payments/debit-credit-card\")\n * to the deposit-format IDs expected by the translation endpoint\n * (e.g., \"credit_debit_card\").\n *\n * The translation endpoint only understands the deposit-format IDs.\n * Canonical IDs may arrive either with the \"/payments/\" prefix\n * (e.g., \"/payments/apple-pay\") or without it (e.g., \"apple-pay\"), so both\n * forms are accepted. If no mapping exists, the input is returned as-is (it\n * may already be in the deposit format).\n */\nconst RAMPS_TO_DEPOSIT_PAYMENT_METHOD: Record<string, string> = {\n '/payments/debit-credit-card': 'credit_debit_card',\n '/payments/apple-pay': 'apple_pay',\n '/payments/google-pay': 'google_pay',\n '/payments/sepa-bank-transfer': 'sepa_bank_transfer',\n '/payments/wire-transfer': 'wire_transfer',\n '/payments/gbp-bank-transfer': 'gbp_bank_transfer',\n};\n\nconst PAYMENTS_PREFIX = '/payments/';\n\nfunction normalizePaymentMethodForTranslation(\n paymentMethod: string | undefined,\n): string | undefined {\n if (!paymentMethod) {\n return undefined;\n }\n const prefixed = paymentMethod.startsWith(PAYMENTS_PREFIX)\n ? paymentMethod\n : `${PAYMENTS_PREFIX}${paymentMethod}`;\n return (\n RAMPS_TO_DEPOSIT_PAYMENT_METHOD[paymentMethod] ??\n RAMPS_TO_DEPOSIT_PAYMENT_METHOD[prefixed] ??\n paymentMethod\n );\n}\n\nfunction getTransakApiBaseUrl(environment: TransakEnvironment): string {\n switch (environment) {\n case TransakEnvironment.Production:\n return 'https://api-gateway.transak.com';\n // Transak has no dev environment; development uses their staging gateway.\n case TransakEnvironment.Staging:\n case TransakEnvironment.Development:\n return 'https://api-gateway-stg.transak.com';\n default:\n throw new Error(`Invalid Transak environment: ${String(environment)}`);\n }\n}\n\nfunction getRampsBaseUrl(environment: TransakEnvironment): string {\n switch (environment) {\n case TransakEnvironment.Production:\n return 'https://on-ramp.api.cx.metamask.io';\n case TransakEnvironment.Staging:\n return 'https://on-ramp.uat-api.cx.metamask.io';\n case TransakEnvironment.Development:\n return 'https://on-ramp.dev-api.cx.metamask.io';\n default:\n throw new Error(`Invalid Transak environment: ${String(environment)}`);\n }\n}\n\nfunction getRampsProviderPath(environment: TransakEnvironment): string {\n // The dev ramps API registers the same `transak-native-staging` provider\n // id as UAT; only production uses `transak-native`.\n const providerId =\n environment === TransakEnvironment.Production\n ? TransakApiProviders.TransakNative\n : TransakApiProviders.TransakNativeStaging;\n return `/providers/${providerId}`;\n}\n\nfunction getPaymentWidgetBaseUrl(environment: TransakEnvironment): string {\n switch (environment) {\n case TransakEnvironment.Production:\n return 'https://global.transak.com';\n // Transak has no dev environment; development uses their staging widget.\n case TransakEnvironment.Staging:\n case TransakEnvironment.Development:\n return 'https://global-stg.transak.com';\n default:\n throw new Error(`Invalid Transak environment: ${String(environment)}`);\n }\n}\n\n/**\n * Transak requires `referrerDomain` in `widgetParams` alongside the partner\n * API key (which the ramps API proxy injects server-side). Identifies the\n * MetaMask client to Transak. Default when the client does not pass a\n * `referrerDomain` constructor option (e.g. the mobile app passes its\n * package name / bundle id).\n */\nconst TRANSAK_REFERRER_DOMAIN = 'metamask.io';\n\n// === TRANSAK API ERROR ===\n\nexport class TransakApiError extends HttpError {\n readonly errorCode: string | undefined;\n\n readonly apiMessage: string | undefined;\n\n constructor(\n status: number,\n message: string,\n errorCode?: string,\n apiMessage?: string,\n ) {\n super(status, message);\n this.errorCode = errorCode;\n this.apiMessage = apiMessage;\n }\n}\n\n// === SERVICE DEFINITION ===\n\nexport class TransakService {\n readonly name: typeof serviceName;\n\n readonly #messenger: TransakServiceMessenger;\n\n readonly #fetch: typeof fetch;\n\n readonly #policy: ServicePolicy;\n\n readonly #noRetryPolicy: ServicePolicy;\n\n readonly #environment: TransakEnvironment;\n\n readonly #context: string;\n\n readonly #orderRetryDelayMs: number;\n\n #apiKey: string | null = null;\n\n #accessToken: TransakAccessToken | null = null;\n\n /**\n * Optional ramps API base URL override for local development (mirrors\n * `RampsService`'s `baseUrlOverride`). Applies to the requests this service\n * sends to the ramps API (orders, widget-url proxy), not to direct Transak\n * API calls.\n */\n readonly #rampsApiBaseUrlOverride?: string;\n\n /**\n * Identifies the client to Transak in `widgetParams` (e.g. the mobile app's\n * package name / bundle id). Defaults to `metamask.io`.\n */\n readonly #referrerDomain: string;\n\n readonly #clientIdentity: RampsClientIdentity;\n\n constructor({\n messenger,\n environment = TransakEnvironment.Staging,\n context,\n fetch: fetchFunction,\n apiKey,\n policyOptions = {},\n orderRetryDelayMs = 2000,\n rampsApiBaseUrlOverride,\n referrerDomain = TRANSAK_REFERRER_DOMAIN,\n clientProduct,\n clientVersion,\n }: {\n messenger: TransakServiceMessenger;\n environment?: TransakEnvironment;\n context: string;\n fetch: typeof fetch;\n apiKey?: string;\n policyOptions?: CreateServicePolicyOptions;\n orderRetryDelayMs?: number;\n rampsApiBaseUrlOverride?: string;\n referrerDomain?: string;\n clientProduct?: string;\n clientVersion?: string;\n }) {\n this.name = serviceName;\n this.#messenger = messenger;\n this.#fetch = fetchFunction;\n this.#policy = createServicePolicy(policyOptions);\n this.#noRetryPolicy = createServicePolicy({\n ...policyOptions,\n maxRetries: 0,\n });\n this.#environment = environment;\n this.#context = context;\n this.#apiKey = apiKey ?? null;\n this.#orderRetryDelayMs = orderRetryDelayMs;\n this.#rampsApiBaseUrlOverride = rampsApiBaseUrlOverride;\n this.#referrerDomain = referrerDomain;\n this.#clientIdentity = {\n clientProduct,\n clientVersion,\n };\n\n this.#messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n setApiKey(apiKey: string): void {\n this.#apiKey = apiKey;\n }\n\n getApiKey(): string | null {\n return this.#apiKey;\n }\n\n #ensureApiKey(): string {\n if (!this.#apiKey) {\n throw new Error('Transak API key is required but not set.');\n }\n return this.#apiKey;\n }\n\n setAccessToken(token: TransakAccessToken): void {\n this.#accessToken = token;\n }\n\n getAccessToken(): TransakAccessToken | null {\n return this.#accessToken;\n }\n\n clearAccessToken(): void {\n this.#accessToken = null;\n }\n\n #ensureAccessToken(): void {\n if (!this.#accessToken?.accessToken) {\n throw new HttpError(\n 401,\n 'Authentication required. Please log in to continue.',\n );\n }\n\n const createdTime = new Date(this.#accessToken.created).getTime();\n const tokenAgeMs = Date.now() - createdTime;\n if (tokenAgeMs > this.#accessToken.ttl * 1000) {\n this.clearAccessToken();\n throw new HttpError(\n 401,\n 'Authentication token has expired. Please log in again.',\n );\n }\n }\n\n #getHeaders(): Record<string, string> {\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n };\n if (this.#accessToken?.accessToken) {\n headers.authorization = this.#accessToken.accessToken;\n }\n return headers;\n }\n\n async #throwTransakApiError(\n fetchResponse: Response,\n url: URL,\n ): Promise<never> {\n let errorBody = '';\n let errorCode: string | undefined;\n let apiMessage: string | undefined;\n try {\n errorBody = await fetchResponse.text();\n const parsed = JSON.parse(errorBody) as {\n error?: {\n code?: string;\n errorCode?: string | number;\n message?: string;\n };\n };\n errorCode =\n parsed?.error?.code ??\n (parsed?.error?.errorCode !== null &&\n parsed?.error?.errorCode !== undefined\n ? String(parsed.error.errorCode)\n : undefined);\n apiMessage =\n typeof parsed?.error?.message === 'string'\n ? parsed.error.message\n : undefined;\n } catch {\n // ignore body read/parse failures\n }\n throw new TransakApiError(\n fetchResponse.status,\n `Fetching '${url.toString()}' failed with status '${fetchResponse.status}'${errorBody ? `: ${errorBody}` : ''}`,\n errorCode,\n apiMessage,\n );\n }\n\n async #transakGet<ResponseType>(\n path: string,\n params?: Record<string, string>,\n ): Promise<ResponseType> {\n const baseUrl = getTransakApiBaseUrl(this.#environment);\n const url = new URL(path, baseUrl);\n\n if (params) {\n for (const [key, value] of Object.entries(params)) {\n if (value !== null && value !== undefined) {\n url.searchParams.set(key, value);\n }\n }\n }\n\n const apiKey = this.#ensureApiKey();\n url.searchParams.set('apiKey', apiKey);\n\n const response = await this.#policy.execute(async () => {\n const fetchResponse = await this.#fetch(url.toString(), {\n method: 'GET',\n headers: this.#getHeaders(),\n });\n if (!fetchResponse.ok) {\n await this.#throwTransakApiError(fetchResponse, url);\n }\n return fetchResponse.json() as Promise<{ data: ResponseType }>;\n });\n\n return response.data;\n }\n\n async #transakPost<ResponseType>(\n path: string,\n body?: Record<string, unknown>,\n options: { policy?: ServicePolicy } = {},\n ): Promise<ResponseType> {\n const apiKey = this.#ensureApiKey();\n const baseUrl = getTransakApiBaseUrl(this.#environment);\n const url = new URL(path, baseUrl);\n\n const requestBody = {\n ...(body ?? {}),\n apiKey,\n };\n\n const policy = options.policy ?? this.#policy;\n\n const response = await policy.execute(async () => {\n const fetchResponse = await this.#fetch(url.toString(), {\n method: 'POST',\n headers: this.#getHeaders(),\n body: JSON.stringify(requestBody),\n });\n if (!fetchResponse.ok) {\n await this.#throwTransakApiError(fetchResponse, url);\n }\n return fetchResponse.json() as Promise<{ data: ResponseType }>;\n });\n\n return response.data;\n }\n\n async #transakPatch<ResponseType>(\n path: string,\n body: Record<string, unknown>,\n ): Promise<ResponseType> {\n const apiKey = this.#ensureApiKey();\n const baseUrl = getTransakApiBaseUrl(this.#environment);\n const url = new URL(path, baseUrl);\n url.searchParams.set('apiKey', apiKey);\n\n const response = await this.#policy.execute(async () => {\n const fetchResponse = await this.#fetch(url.toString(), {\n method: 'PATCH',\n headers: this.#getHeaders(),\n body: JSON.stringify(body),\n });\n if (!fetchResponse.ok) {\n await this.#throwTransakApiError(fetchResponse, url);\n }\n return fetchResponse.json() as Promise<{ data: ResponseType }>;\n });\n\n return response.data;\n }\n\n async #transakDelete(\n path: string,\n params?: Record<string, string>,\n ): Promise<void> {\n const apiKey = this.#ensureApiKey();\n const baseUrl = getTransakApiBaseUrl(this.#environment);\n const url = new URL(path, baseUrl);\n url.searchParams.set('apiKey', apiKey);\n\n if (params) {\n for (const [key, value] of Object.entries(params)) {\n if (value !== null && value !== undefined) {\n url.searchParams.set(key, value);\n }\n }\n }\n\n await this.#policy.execute(async () => {\n const fetchResponse = await this.#fetch(url.toString(), {\n method: 'DELETE',\n headers: this.#getHeaders(),\n });\n if (!fetchResponse.ok) {\n await this.#throwTransakApiError(fetchResponse, url);\n }\n });\n }\n\n /**\n * Gets the ramps API base URL, respecting the local-development override\n * when set (same semantics as `RampsService`'s `baseUrlOverride`).\n *\n * @returns The ramps API base URL to use.\n */\n #getRampsApiBaseUrl(): string {\n return this.#rampsApiBaseUrlOverride ?? getRampsBaseUrl(this.#environment);\n }\n\n /**\n * Adds the common request parameters to a ramps API proxy URL, mirroring\n * `RampsService`'s `#addCommonParams`.\n *\n * @param url - The URL to add parameters to.\n */\n #addRampsCommonParams(url: URL): void {\n url.searchParams.set('action', 'deposit');\n url.searchParams.set('sdk', RAMPS_SDK_VERSION);\n url.searchParams.set('controller', packageJson.version);\n url.searchParams.set('context', this.#context);\n // In the query string (not headers) so CDN-cached responses vary per\n // client product / version.\n addRampsClientIdentityParams(url, this.#clientIdentity);\n }\n\n async #ordersApiGet<ResponseType>(\n path: string,\n params?: Record<string, string>,\n ): Promise<ResponseType> {\n const baseUrl = this.#getRampsApiBaseUrl();\n const providerPath = getRampsProviderPath(this.#environment);\n const url = new URL(`${providerPath}${path}`, baseUrl);\n\n url.searchParams.set('action', 'deposit');\n url.searchParams.set('context', this.#context);\n // In the query string (not headers) so CDN-cached responses vary per\n // client product / version.\n addRampsClientIdentityParams(url, this.#clientIdentity);\n\n if (params) {\n for (const [key, value] of Object.entries(params)) {\n if (value !== null && value !== undefined) {\n url.searchParams.set(key, value);\n }\n }\n }\n\n const response = await this.#policy.execute(async () => {\n const fetchResponse = await this.#fetch(url.toString(), {\n method: 'GET',\n headers: { Accept: 'application/json' },\n });\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<ResponseType>;\n });\n\n return response;\n }\n\n // === PUBLIC API METHODS ===\n\n async sendUserOtp(email: string): Promise<{\n isTncAccepted: boolean;\n stateToken: string;\n email: string;\n expiresIn: number;\n }> {\n const result = await this.#transakPost<{\n isTncAccepted: boolean;\n stateToken: string;\n email: string;\n expiresIn: number;\n }>('/api/v2/auth/login', { email });\n return result;\n }\n\n async verifyUserOtp(\n email: string,\n verificationCode: string,\n stateToken: string,\n ): Promise<TransakAccessToken> {\n const responseData = await this.#transakPost<{\n accessToken: string;\n ttl: number;\n created: string;\n }>(\n '/api/v2/auth/verify',\n {\n email,\n otp: verificationCode,\n stateToken,\n },\n { policy: this.#noRetryPolicy },\n );\n\n const accessToken: TransakAccessToken = {\n accessToken: responseData.accessToken,\n ttl: responseData.ttl,\n created: new Date(responseData.created),\n };\n\n this.setAccessToken(accessToken);\n return accessToken;\n }\n\n async logout(): Promise<string> {\n this.#ensureAccessToken();\n try {\n const result = await this.#transakPost<string>('/api/v1/auth/logout');\n this.clearAccessToken();\n return result;\n } catch (error) {\n if (error instanceof HttpError && error.httpStatus === 401) {\n this.clearAccessToken();\n return 'user was already logged out';\n }\n throw error;\n }\n }\n\n async getUserDetails(): Promise<TransakUserDetails> {\n this.#ensureAccessToken();\n return this.#transakGet<TransakUserDetails>('/api/v2/user/');\n }\n\n async getBuyQuote(\n genericFiatCurrency: string,\n genericCryptoCurrency: string,\n genericNetwork: string,\n genericPaymentMethod: string,\n fiatAmount: string,\n ): Promise<TransakBuyQuote> {\n const normalizedPaymentMethod = normalizePaymentMethodForTranslation(\n genericPaymentMethod || undefined,\n );\n const translationRequest = {\n cryptoCurrencyId: genericCryptoCurrency,\n chainId: genericNetwork,\n fiatCurrencyId: genericFiatCurrency,\n paymentMethod: normalizedPaymentMethod,\n };\n\n const translation = await this.getTranslation(translationRequest);\n\n const params: Record<string, string> = {\n fiatCurrency: translation.fiatCurrency,\n cryptoCurrency: translation.cryptoCurrency,\n isBuyOrSell: 'BUY',\n network: translation.network,\n fiatAmount,\n isFeeExcludedFromFiat: 'true',\n };\n\n if (translation.paymentMethod) {\n params.paymentMethod = translation.paymentMethod;\n }\n\n return this.#transakGet<TransakBuyQuote>('/api/v2/lookup/quotes', params);\n }\n\n async getKycRequirement(quoteId: string): Promise<TransakKycRequirement> {\n this.#ensureAccessToken();\n const result = await this.#transakGet<TransakKycRequirement>(\n '/api/v2/kyc/requirement',\n {\n 'metadata[quoteId]': quoteId,\n },\n );\n return result;\n }\n\n async getAdditionalRequirements(\n quoteId: string,\n ): Promise<TransakAdditionalRequirementsResponse> {\n this.#ensureAccessToken();\n return this.#transakGet<TransakAdditionalRequirementsResponse>(\n '/api/v2/kyc/additional-requirements',\n { 'metadata[quoteId]': quoteId },\n );\n }\n\n async createOrder(\n quoteId: string,\n walletAddress: string,\n paymentMethodId: string,\n ): Promise<TransakDepositOrder> {\n this.#ensureAccessToken();\n\n const normalizedPaymentMethod =\n normalizePaymentMethodForTranslation(paymentMethodId);\n const translation = await this.getTranslation({\n paymentMethod: normalizedPaymentMethod,\n });\n\n const paymentInstrumentId =\n translation.paymentMethod ?? normalizedPaymentMethod;\n\n try {\n const transakOrder = await this.#transakPost<TransakOrder>(\n '/api/v2/orders',\n {\n quoteId,\n walletAddress,\n paymentInstrumentId,\n },\n );\n\n const depositOrderId =\n TransakOrderIdTransformer.transakOrderIdToDepositOrderId(\n transakOrder.orderId,\n this.#environment,\n );\n\n return this.getOrder(\n depositOrderId,\n transakOrder.walletAddress,\n transakOrder.paymentDetails,\n );\n } catch (error) {\n if (\n error instanceof TransakApiError &&\n error.httpStatus === 409 &&\n error.errorCode === TRANSAK_ERROR_CODES.ORDER_EXISTS\n ) {\n await this.cancelAllActiveOrders();\n await new Promise((resolve) =>\n setTimeout(resolve, this.#orderRetryDelayMs),\n );\n\n const retryOrder = await this.#transakPost<TransakOrder>(\n '/api/v2/orders',\n {\n quoteId,\n walletAddress,\n paymentInstrumentId,\n },\n );\n\n const retryDepositOrderId =\n TransakOrderIdTransformer.transakOrderIdToDepositOrderId(\n retryOrder.orderId,\n this.#environment,\n );\n\n return this.getOrder(\n retryDepositOrderId,\n retryOrder.walletAddress,\n retryOrder.paymentDetails,\n );\n }\n throw error;\n }\n }\n\n async getOrder(\n orderId: string,\n wallet: string,\n paymentDetails?: TransakOrderPaymentMethod[],\n ): Promise<TransakDepositOrder> {\n let depositOrderId: string;\n if (TransakOrderIdTransformer.isDepositOrderId(orderId)) {\n depositOrderId = orderId;\n } else {\n depositOrderId = TransakOrderIdTransformer.transakOrderIdToDepositOrderId(\n orderId,\n this.#environment,\n );\n }\n\n const transakOrderId =\n TransakOrderIdTransformer.extractTransakOrderId(depositOrderId);\n\n const order = await this.#ordersApiGet<TransakDepositOrder>(\n `/orders/${transakOrderId}`,\n { wallet },\n );\n\n const orderWithId = {\n ...order,\n id: depositOrderId,\n orderType: 'DEPOSIT' as const,\n };\n\n if (paymentDetails && paymentDetails.length > 0) {\n return { ...orderWithId, paymentDetails };\n }\n\n if (this.#accessToken?.accessToken) {\n try {\n const transakOrder = await this.#transakGet<TransakOrder>(\n `/api/v2/orders/${transakOrderId}`,\n );\n return { ...orderWithId, paymentDetails: transakOrder.paymentDetails };\n } catch {\n return orderWithId;\n }\n }\n\n return orderWithId;\n }\n\n async getUserLimits(\n fiatCurrency: string,\n paymentMethod: string,\n kycType: string,\n ): Promise<TransakUserLimits> {\n this.#ensureAccessToken();\n\n const translation = await this.getTranslation({\n paymentMethod: normalizePaymentMethodForTranslation(paymentMethod),\n });\n\n const params: Record<string, string> = {\n isBuyOrSell: 'BUY',\n kycType,\n fiatCurrency,\n };\n\n if (translation.paymentMethod) {\n params.paymentCategory = translation.paymentMethod;\n }\n\n return this.#transakGet<TransakUserLimits>(\n '/api/v2/orders/user-limit',\n params,\n );\n }\n\n /**\n * @deprecated Use {@link createWidgetUrl} instead. The OTT flow requires the\n * partner API key on the client and Transak is deprecating `request-ott`.\n * @returns The one-time token response.\n */\n async requestOtt(): Promise<TransakOttResponse> {\n this.#ensureAccessToken();\n const result = await this.#transakPost<TransakOttResponse>(\n '/api/v2/auth/request-ott',\n );\n return result;\n }\n\n /**\n * @deprecated Use {@link createWidgetUrl} instead. This builds the widget\n * URL client-side and embeds the partner API key in it.\n * @param ottToken - The one-time token for widget authentication.\n * @param quote - The buy quote to pre-fill in the widget.\n * @param walletAddress - The destination wallet address.\n * @param extraParams - Optional additional URL parameters.\n * @returns The fully constructed widget URL string.\n */\n generatePaymentWidgetUrl(\n ottToken: string,\n quote: TransakBuyQuote,\n walletAddress: string,\n extraParams?: Record<string, string>,\n ): string {\n const apiKey = this.#ensureApiKey();\n const widgetBaseUrl = getPaymentWidgetBaseUrl(this.#environment);\n\n const defaultParams: Record<string, string> = {\n apiKey,\n ott: ottToken,\n fiatCurrency: quote.fiatCurrency,\n cryptoCurrencyCode: quote.cryptoCurrency,\n productsAvailed: 'BUY',\n fiatAmount: quote.fiatAmount.toString(),\n network: quote.network,\n hideExchangeScreen: 'true',\n walletAddress,\n disableWalletAddressForm: 'true',\n paymentMethod: quote.paymentMethod,\n redirectURL:\n 'https://on-ramp-content.api.cx.metamask.io/regions/fake-callback',\n hideMenu: 'true',\n };\n\n const params = new URLSearchParams({\n ...defaultParams,\n ...extraParams,\n });\n\n const widgetUrl = new URL(widgetBaseUrl);\n widgetUrl.search = params.toString();\n return widgetUrl.toString();\n }\n\n /**\n * Creates a Transak payment widget URL through the ramps API proxy\n * (`POST {rampsBaseUrl}/providers/{providerId}/widget-url`). The proxy\n * injects the partner API key and derives the user IP server-side, so\n * neither leaves the backend. Replaces the OTT flow ({@link requestOtt} +\n * {@link generatePaymentWidgetUrl}).\n *\n * Requires both a Transak access token (user must be logged in to Transak)\n * and a MetaMask bearer token from `AuthenticationController`.\n *\n * @param quote - The buy quote to pre-fill in the widget.\n * @param walletAddress - The destination wallet address.\n * @param extraParams - Optional additional widget parameters (e.g. theming).\n * Keys must be on the proxy's allowlist or the request is rejected.\n * @returns The single-use widget URL (expires after 5 minutes).\n */\n async createWidgetUrl(\n quote: TransakBuyQuote,\n walletAddress: string,\n extraParams?: Record<string, string>,\n ): Promise<string> {\n this.#ensureAccessToken();\n const bearerToken = await this.#messenger.call(\n 'AuthenticationController:getBearerToken',\n );\n\n const baseUrl = this.#getRampsApiBaseUrl();\n const providerPath = getRampsProviderPath(this.#environment);\n const url = new URL(`${providerPath}/widget-url`, baseUrl);\n\n this.#addRampsCommonParams(url);\n\n const widgetParams: Record<string, string | number> = {\n referrerDomain: this.#referrerDomain,\n fiatCurrency: quote.fiatCurrency,\n cryptoCurrencyCode: quote.cryptoCurrency,\n fiatAmount: quote.fiatAmount,\n network: quote.network,\n paymentMethod: quote.paymentMethod,\n walletAddress,\n hideExchangeScreen: 'true',\n disableWalletAddressEdit: 'true',\n hideMenu: 'true',\n redirectURL:\n 'https://on-ramp-content.api.cx.metamask.io/regions/fake-callback',\n ...extraParams,\n };\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n };\n if (this.#accessToken?.accessToken) {\n headers['x-transak-access-token'] = this.#accessToken.accessToken;\n }\n\n const response = await this.#policy.execute(async () => {\n const fetchResponse = await this.#fetch(url.toString(), {\n method: 'POST',\n headers,\n body: JSON.stringify({ widgetParams }),\n });\n if (!fetchResponse.ok) {\n await this.#throwTransakApiError(fetchResponse, url);\n }\n return fetchResponse.json() as Promise<{ widgetUrl: string }>;\n });\n\n return response.widgetUrl;\n }\n\n async submitPurposeOfUsageForm(purpose: string[]): Promise<void> {\n this.#ensureAccessToken();\n await this.#transakPost('/api/v2/kyc/purpose-of-usage', {\n purposeList: purpose,\n });\n }\n\n async patchUser(data: PatchUserRequestBody): Promise<unknown> {\n this.#ensureAccessToken();\n return this.#transakPatch(\n '/api/v2/kyc/user',\n data as Record<string, unknown>,\n );\n }\n\n async submitSsnDetails(ssn: string, quoteId: string): Promise<unknown> {\n this.#ensureAccessToken();\n return this.#transakPost('/api/v2/kyc/ssn', { ssn, quoteId });\n }\n\n async confirmPayment(\n orderId: string,\n paymentMethodId: string,\n ): Promise<{ success: boolean }> {\n this.#ensureAccessToken();\n\n const normalizedPaymentMethod =\n normalizePaymentMethodForTranslation(paymentMethodId);\n const translation = await this.getTranslation({\n paymentMethod: normalizedPaymentMethod,\n });\n\n const transakOrderId =\n TransakOrderIdTransformer.extractTransakOrderId(orderId);\n\n return this.#transakPost<{ success: boolean }>(\n '/api/v2/orders/payment-confirmation',\n {\n orderId: transakOrderId,\n paymentMethod: translation.paymentMethod ?? normalizedPaymentMethod,\n },\n );\n }\n\n async getTranslation(\n translationRequest: TransakTranslationRequest,\n ): Promise<TransakQuoteTranslation> {\n const baseUrl = getRampsBaseUrl(this.#environment);\n const providerPath = getRampsProviderPath(this.#environment);\n const url = new URL(`${providerPath}/native/translate`, baseUrl);\n\n url.searchParams.set('action', 'deposit');\n url.searchParams.set('context', this.#context);\n\n const normalizedRequest = {\n ...translationRequest,\n paymentMethod: normalizePaymentMethodForTranslation(\n translationRequest.paymentMethod,\n ),\n };\n\n for (const [key, value] of Object.entries(normalizedRequest)) {\n if (value !== undefined) {\n url.searchParams.set(key, value);\n }\n }\n\n const response = await this.#policy.execute(async () => {\n const fetchResponse = await this.#fetch(url.toString(), {\n method: 'GET',\n headers: { Accept: 'application/json' },\n });\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<TransakQuoteTranslation>;\n });\n\n return response;\n }\n\n async getIdProofStatus(workFlowRunId: string): Promise<TransakIdProofStatus> {\n this.#ensureAccessToken();\n return this.#transakGet<TransakIdProofStatus>(\n '/api/v2/kyc/id-proof-status',\n { workFlowRunId },\n );\n }\n\n async cancelOrder(depositOrderId: string): Promise<void> {\n this.#ensureAccessToken();\n const transakOrderId =\n TransakOrderIdTransformer.extractTransakOrderId(depositOrderId);\n await this.#transakDelete(`/api/v2/orders/${transakOrderId}`, {\n cancelReason: 'Creating new order',\n });\n }\n\n async cancelAllActiveOrders(): Promise<Error[]> {\n this.#ensureAccessToken();\n const activeOrders = await this.getActiveOrders();\n const errors: Error[] = [];\n\n await Promise.all(\n activeOrders.map(async (order) => {\n try {\n const depositOrderId =\n TransakOrderIdTransformer.transakOrderIdToDepositOrderId(\n order.orderId,\n this.#environment,\n );\n await this.cancelOrder(depositOrderId);\n } catch (error) {\n errors.push(\n error instanceof Error ? error : new Error(String(error)),\n );\n }\n }),\n );\n\n return errors;\n }\n\n async getActiveOrders(): Promise<TransakOrder[]> {\n this.#ensureAccessToken();\n return this.#transakGet<TransakOrder[]>('/api/v2/active-orders');\n }\n}\n"]}
|
package/dist/client-identity.cjs
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addRampsClientIdentityParams = exports.RAMPS_CLIENT_VERSION_PARAM = exports.RAMPS_CLIENT_PRODUCT_PARAM = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Query-param names for the client identity, sent on every on-ramp API
|
|
6
|
-
* request. Identity travels in the URL (not headers) because the on-ramp CDN
|
|
7
|
-
* cache key is the URL — the API's version-gated feature flags evaluate these
|
|
8
|
-
* params so cached responses always match the requesting cohort.
|
|
9
|
-
*/
|
|
10
|
-
exports.RAMPS_CLIENT_PRODUCT_PARAM = 'clientProduct';
|
|
11
|
-
exports.RAMPS_CLIENT_VERSION_PARAM = 'clientVersion';
|
|
12
|
-
/**
|
|
13
|
-
* Appends the identity as query params (CDN cache-key friendly), omitting
|
|
14
|
-
* empty values. See {@link RAMPS_CLIENT_PRODUCT_PARAM}.
|
|
15
|
-
*
|
|
16
|
-
* @param url - URL to mutate.
|
|
17
|
-
* @param identity - Optional product and version.
|
|
18
|
-
*/
|
|
19
|
-
function addRampsClientIdentityParams(url, identity) {
|
|
20
|
-
if (identity.clientProduct) {
|
|
21
|
-
url.searchParams.set(exports.RAMPS_CLIENT_PRODUCT_PARAM, identity.clientProduct);
|
|
22
|
-
}
|
|
23
|
-
if (identity.clientVersion) {
|
|
24
|
-
url.searchParams.set(exports.RAMPS_CLIENT_VERSION_PARAM, identity.clientVersion);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.addRampsClientIdentityParams = addRampsClientIdentityParams;
|
|
28
|
-
//# sourceMappingURL=client-identity.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-identity.cjs","sourceRoot":"","sources":["../src/client-identity.ts"],"names":[],"mappings":";;;AAQA;;;;;GAKG;AACU,QAAA,0BAA0B,GAAG,eAAe,CAAC;AAC7C,QAAA,0BAA0B,GAAG,eAAe,CAAC;AAE1D;;;;;;GAMG;AACH,SAAgB,4BAA4B,CAC1C,GAAQ,EACR,QAA6B;IAE7B,IAAI,QAAQ,CAAC,aAAa,EAAE,CAAC;QAC3B,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,kCAA0B,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;IAC3E,CAAC;IACD,IAAI,QAAQ,CAAC,aAAa,EAAE,CAAC;QAC3B,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,kCAA0B,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC;AAVD,oEAUC","sourcesContent":["/** Host-supplied MetaMask client identity. All fields optional. */\nexport type RampsClientIdentity = {\n /** Product id, e.g. `metamask-mobile` or `metamask-extension`. */\n clientProduct?: string;\n /** App SemVer, e.g. `8.9.0` (not the ramps-controller package version). */\n clientVersion?: string;\n};\n\n/**\n * Query-param names for the client identity, sent on every on-ramp API\n * request. Identity travels in the URL (not headers) because the on-ramp CDN\n * cache key is the URL — the API's version-gated feature flags evaluate these\n * params so cached responses always match the requesting cohort.\n */\nexport const RAMPS_CLIENT_PRODUCT_PARAM = 'clientProduct';\nexport const RAMPS_CLIENT_VERSION_PARAM = 'clientVersion';\n\n/**\n * Appends the identity as query params (CDN cache-key friendly), omitting\n * empty values. See {@link RAMPS_CLIENT_PRODUCT_PARAM}.\n *\n * @param url - URL to mutate.\n * @param identity - Optional product and version.\n */\nexport function addRampsClientIdentityParams(\n url: URL,\n identity: RampsClientIdentity,\n): void {\n if (identity.clientProduct) {\n url.searchParams.set(RAMPS_CLIENT_PRODUCT_PARAM, identity.clientProduct);\n }\n if (identity.clientVersion) {\n url.searchParams.set(RAMPS_CLIENT_VERSION_PARAM, identity.clientVersion);\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-identity.d.cts","sourceRoot":"","sources":["../src/client-identity.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,MAAM,MAAM,mBAAmB,GAAG;IAChC,kEAAkE;IAClE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2EAA2E;IAC3E,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,kBAAkB,CAAC;AAC1D,eAAO,MAAM,0BAA0B,kBAAkB,CAAC;AAE1D;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,mBAAmB,GAC5B,IAAI,CAON"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/** Host-supplied MetaMask client identity. All fields optional. */
|
|
2
|
-
export type RampsClientIdentity = {
|
|
3
|
-
/** Product id, e.g. `metamask-mobile` or `metamask-extension`. */
|
|
4
|
-
clientProduct?: string;
|
|
5
|
-
/** App SemVer, e.g. `8.9.0` (not the ramps-controller package version). */
|
|
6
|
-
clientVersion?: string;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Query-param names for the client identity, sent on every on-ramp API
|
|
10
|
-
* request. Identity travels in the URL (not headers) because the on-ramp CDN
|
|
11
|
-
* cache key is the URL — the API's version-gated feature flags evaluate these
|
|
12
|
-
* params so cached responses always match the requesting cohort.
|
|
13
|
-
*/
|
|
14
|
-
export declare const RAMPS_CLIENT_PRODUCT_PARAM = "clientProduct";
|
|
15
|
-
export declare const RAMPS_CLIENT_VERSION_PARAM = "clientVersion";
|
|
16
|
-
/**
|
|
17
|
-
* Appends the identity as query params (CDN cache-key friendly), omitting
|
|
18
|
-
* empty values. See {@link RAMPS_CLIENT_PRODUCT_PARAM}.
|
|
19
|
-
*
|
|
20
|
-
* @param url - URL to mutate.
|
|
21
|
-
* @param identity - Optional product and version.
|
|
22
|
-
*/
|
|
23
|
-
export declare function addRampsClientIdentityParams(url: URL, identity: RampsClientIdentity): void;
|
|
24
|
-
//# sourceMappingURL=client-identity.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-identity.d.mts","sourceRoot":"","sources":["../src/client-identity.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,MAAM,MAAM,mBAAmB,GAAG;IAChC,kEAAkE;IAClE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2EAA2E;IAC3E,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,kBAAkB,CAAC;AAC1D,eAAO,MAAM,0BAA0B,kBAAkB,CAAC;AAE1D;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,mBAAmB,GAC5B,IAAI,CAON"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-identity.mjs","sourceRoot":"","sources":["../src/client-identity.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,eAAe,CAAC;AAC1D,MAAM,CAAC,MAAM,0BAA0B,GAAG,eAAe,CAAC;AAE1D;;;;;;GAMG;AACH,MAAM,UAAU,4BAA4B,CAC1C,GAAQ,EACR,QAA6B;IAE7B,IAAI,QAAQ,CAAC,aAAa,EAAE,CAAC;QAC3B,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,0BAA0B,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;IAC3E,CAAC;IACD,IAAI,QAAQ,CAAC,aAAa,EAAE,CAAC;QAC3B,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,0BAA0B,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC","sourcesContent":["/** Host-supplied MetaMask client identity. All fields optional. */\nexport type RampsClientIdentity = {\n /** Product id, e.g. `metamask-mobile` or `metamask-extension`. */\n clientProduct?: string;\n /** App SemVer, e.g. `8.9.0` (not the ramps-controller package version). */\n clientVersion?: string;\n};\n\n/**\n * Query-param names for the client identity, sent on every on-ramp API\n * request. Identity travels in the URL (not headers) because the on-ramp CDN\n * cache key is the URL — the API's version-gated feature flags evaluate these\n * params so cached responses always match the requesting cohort.\n */\nexport const RAMPS_CLIENT_PRODUCT_PARAM = 'clientProduct';\nexport const RAMPS_CLIENT_VERSION_PARAM = 'clientVersion';\n\n/**\n * Appends the identity as query params (CDN cache-key friendly), omitting\n * empty values. See {@link RAMPS_CLIENT_PRODUCT_PARAM}.\n *\n * @param url - URL to mutate.\n * @param identity - Optional product and version.\n */\nexport function addRampsClientIdentityParams(\n url: URL,\n identity: RampsClientIdentity,\n): void {\n if (identity.clientProduct) {\n url.searchParams.set(RAMPS_CLIENT_PRODUCT_PARAM, identity.clientProduct);\n }\n if (identity.clientVersion) {\n url.searchParams.set(RAMPS_CLIENT_VERSION_PARAM, identity.clientVersion);\n }\n}\n"]}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeToTypedError = exports.extractExplicitTypedError = exports.getErrorMessage = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Type guard for a non-null object.
|
|
6
|
-
*
|
|
7
|
-
* @param value - The value to test.
|
|
8
|
-
* @returns Whether the value is a record.
|
|
9
|
-
*/
|
|
10
|
-
function isRecord(value) {
|
|
11
|
-
return typeof value === 'object' && value !== null;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Best-effort human-readable message from an arbitrary thrown/native value.
|
|
15
|
-
*
|
|
16
|
-
* @param error - The caught value.
|
|
17
|
-
* @returns The message, or `undefined` when none can be derived.
|
|
18
|
-
*/
|
|
19
|
-
function getErrorMessage(error) {
|
|
20
|
-
if (error instanceof Error) {
|
|
21
|
-
return error.message;
|
|
22
|
-
}
|
|
23
|
-
if (isRecord(error) && typeof error.message === 'string') {
|
|
24
|
-
return error.message;
|
|
25
|
-
}
|
|
26
|
-
if (typeof error === 'string') {
|
|
27
|
-
return error;
|
|
28
|
-
}
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
|
-
exports.getErrorMessage = getErrorMessage;
|
|
32
|
-
/**
|
|
33
|
-
* Extracts a caller-recognised typed error from an arbitrary thrown/native
|
|
34
|
-
* value, when the value carries an explicit, valid code on one of the given
|
|
35
|
-
* properties. Pure: performs no side effects and applies no fallback, so
|
|
36
|
-
* callers keep full control over precedence (e.g. domain-specific special
|
|
37
|
-
* cases) and the fallback code.
|
|
38
|
-
*
|
|
39
|
-
* @param error - The caught value.
|
|
40
|
-
* @param options - The options.
|
|
41
|
-
* @param options.isValidCode - Type guard identifying a recognised code.
|
|
42
|
-
* @param options.codeProperties - Property names to read a code from, in
|
|
43
|
-
* precedence order. Defaults to `['code']`.
|
|
44
|
-
* @returns The typed error when an explicit valid code is present, else
|
|
45
|
-
* `undefined`.
|
|
46
|
-
*/
|
|
47
|
-
function extractExplicitTypedError(error, { isValidCode, codeProperties = ['code'], }) {
|
|
48
|
-
if (!isRecord(error)) {
|
|
49
|
-
return undefined;
|
|
50
|
-
}
|
|
51
|
-
for (const property of codeProperties) {
|
|
52
|
-
const candidate = error[property];
|
|
53
|
-
if (isValidCode(candidate)) {
|
|
54
|
-
return {
|
|
55
|
-
code: candidate,
|
|
56
|
-
message: getErrorMessage(error),
|
|
57
|
-
details: isRecord(error.details) ? error.details : undefined,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
63
|
-
exports.extractExplicitTypedError = extractExplicitTypedError;
|
|
64
|
-
/**
|
|
65
|
-
* Normalises an arbitrary thrown/native value into a {@link TypedError}, using
|
|
66
|
-
* the caller's recognised codes and falling back to `fallbackCode` when no
|
|
67
|
-
* explicit valid code is present. Pure.
|
|
68
|
-
*
|
|
69
|
-
* @param error - The caught value.
|
|
70
|
-
* @param options - The options.
|
|
71
|
-
* @param options.isValidCode - Type guard identifying a recognised code.
|
|
72
|
-
* @param options.fallbackCode - Code used when no explicit valid code is found.
|
|
73
|
-
* @param options.codeProperties - Property names to read a code from, in
|
|
74
|
-
* precedence order. Defaults to `['code']`.
|
|
75
|
-
* @returns The typed error.
|
|
76
|
-
*/
|
|
77
|
-
function normalizeToTypedError(error, { isValidCode, fallbackCode, codeProperties, }) {
|
|
78
|
-
return (extractExplicitTypedError(error, { isValidCode, codeProperties }) ?? {
|
|
79
|
-
code: fallbackCode,
|
|
80
|
-
message: getErrorMessage(error),
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
exports.normalizeToTypedError = normalizeToTypedError;
|
|
84
|
-
//# sourceMappingURL=errorNormalization.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errorNormalization.cjs","sourceRoot":"","sources":["../src/errorNormalization.ts"],"names":[],"mappings":";;;AAYA;;;;;GAKG;AACH,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAED;;;;;GAKG;AACH,SAAgB,eAAe,CAAC,KAAc;IAC5C,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IACD,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QACzD,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAXD,0CAWC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,yBAAyB,CACvC,KAAc,EACd,EACE,WAAW,EACX,cAAc,GAAG,CAAC,MAAM,CAAC,GAI1B;IAED,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,KAAK,MAAM,QAAQ,IAAI,cAAc,EAAE,CAAC;QACtC,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;QAClC,IAAI,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3B,OAAO;gBACL,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,eAAe,CAAC,KAAK,CAAC;gBAC/B,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;aAC7D,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAxBD,8DAwBC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,qBAAqB,CACnC,KAAc,EACd,EACE,WAAW,EACX,YAAY,EACZ,cAAc,GAKf;IAED,OAAO,CACL,yBAAyB,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC,IAAI;QACnE,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,eAAe,CAAC,KAAK,CAAC;KAChC,CACF,CAAC;AACJ,CAAC;AAlBD,sDAkBC","sourcesContent":["/**\n * A typed error surface: a stable code plus an optional human message and\n * structured details. Consumers parameterise `Code` with their own error-code\n * union (e.g. headless-buy codes) so the taxonomy stays with the consumer while\n * the pure extraction below is shared.\n */\nexport type TypedError<Code extends string> = {\n code: Code;\n message?: string;\n details?: Record<string, unknown>;\n};\n\n/**\n * Type guard for a non-null object.\n *\n * @param value - The value to test.\n * @returns Whether the value is a record.\n */\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\n/**\n * Best-effort human-readable message from an arbitrary thrown/native value.\n *\n * @param error - The caught value.\n * @returns The message, or `undefined` when none can be derived.\n */\nexport function getErrorMessage(error: unknown): string | undefined {\n if (error instanceof Error) {\n return error.message;\n }\n if (isRecord(error) && typeof error.message === 'string') {\n return error.message;\n }\n if (typeof error === 'string') {\n return error;\n }\n return undefined;\n}\n\n/**\n * Extracts a caller-recognised typed error from an arbitrary thrown/native\n * value, when the value carries an explicit, valid code on one of the given\n * properties. Pure: performs no side effects and applies no fallback, so\n * callers keep full control over precedence (e.g. domain-specific special\n * cases) and the fallback code.\n *\n * @param error - The caught value.\n * @param options - The options.\n * @param options.isValidCode - Type guard identifying a recognised code.\n * @param options.codeProperties - Property names to read a code from, in\n * precedence order. Defaults to `['code']`.\n * @returns The typed error when an explicit valid code is present, else\n * `undefined`.\n */\nexport function extractExplicitTypedError<Code extends string>(\n error: unknown,\n {\n isValidCode,\n codeProperties = ['code'],\n }: {\n isValidCode: (value: unknown) => value is Code;\n codeProperties?: string[];\n },\n): TypedError<Code> | undefined {\n if (!isRecord(error)) {\n return undefined;\n }\n for (const property of codeProperties) {\n const candidate = error[property];\n if (isValidCode(candidate)) {\n return {\n code: candidate,\n message: getErrorMessage(error),\n details: isRecord(error.details) ? error.details : undefined,\n };\n }\n }\n return undefined;\n}\n\n/**\n * Normalises an arbitrary thrown/native value into a {@link TypedError}, using\n * the caller's recognised codes and falling back to `fallbackCode` when no\n * explicit valid code is present. Pure.\n *\n * @param error - The caught value.\n * @param options - The options.\n * @param options.isValidCode - Type guard identifying a recognised code.\n * @param options.fallbackCode - Code used when no explicit valid code is found.\n * @param options.codeProperties - Property names to read a code from, in\n * precedence order. Defaults to `['code']`.\n * @returns The typed error.\n */\nexport function normalizeToTypedError<Code extends string>(\n error: unknown,\n {\n isValidCode,\n fallbackCode,\n codeProperties,\n }: {\n isValidCode: (value: unknown) => value is Code;\n fallbackCode: Code;\n codeProperties?: string[];\n },\n): TypedError<Code> {\n return (\n extractExplicitTypedError(error, { isValidCode, codeProperties }) ?? {\n code: fallbackCode,\n message: getErrorMessage(error),\n }\n );\n}\n"]}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A typed error surface: a stable code plus an optional human message and
|
|
3
|
-
* structured details. Consumers parameterise `Code` with their own error-code
|
|
4
|
-
* union (e.g. headless-buy codes) so the taxonomy stays with the consumer while
|
|
5
|
-
* the pure extraction below is shared.
|
|
6
|
-
*/
|
|
7
|
-
export type TypedError<Code extends string> = {
|
|
8
|
-
code: Code;
|
|
9
|
-
message?: string;
|
|
10
|
-
details?: Record<string, unknown>;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Best-effort human-readable message from an arbitrary thrown/native value.
|
|
14
|
-
*
|
|
15
|
-
* @param error - The caught value.
|
|
16
|
-
* @returns The message, or `undefined` when none can be derived.
|
|
17
|
-
*/
|
|
18
|
-
export declare function getErrorMessage(error: unknown): string | undefined;
|
|
19
|
-
/**
|
|
20
|
-
* Extracts a caller-recognised typed error from an arbitrary thrown/native
|
|
21
|
-
* value, when the value carries an explicit, valid code on one of the given
|
|
22
|
-
* properties. Pure: performs no side effects and applies no fallback, so
|
|
23
|
-
* callers keep full control over precedence (e.g. domain-specific special
|
|
24
|
-
* cases) and the fallback code.
|
|
25
|
-
*
|
|
26
|
-
* @param error - The caught value.
|
|
27
|
-
* @param options - The options.
|
|
28
|
-
* @param options.isValidCode - Type guard identifying a recognised code.
|
|
29
|
-
* @param options.codeProperties - Property names to read a code from, in
|
|
30
|
-
* precedence order. Defaults to `['code']`.
|
|
31
|
-
* @returns The typed error when an explicit valid code is present, else
|
|
32
|
-
* `undefined`.
|
|
33
|
-
*/
|
|
34
|
-
export declare function extractExplicitTypedError<Code extends string>(error: unknown, { isValidCode, codeProperties, }: {
|
|
35
|
-
isValidCode: (value: unknown) => value is Code;
|
|
36
|
-
codeProperties?: string[];
|
|
37
|
-
}): TypedError<Code> | undefined;
|
|
38
|
-
/**
|
|
39
|
-
* Normalises an arbitrary thrown/native value into a {@link TypedError}, using
|
|
40
|
-
* the caller's recognised codes and falling back to `fallbackCode` when no
|
|
41
|
-
* explicit valid code is present. Pure.
|
|
42
|
-
*
|
|
43
|
-
* @param error - The caught value.
|
|
44
|
-
* @param options - The options.
|
|
45
|
-
* @param options.isValidCode - Type guard identifying a recognised code.
|
|
46
|
-
* @param options.fallbackCode - Code used when no explicit valid code is found.
|
|
47
|
-
* @param options.codeProperties - Property names to read a code from, in
|
|
48
|
-
* precedence order. Defaults to `['code']`.
|
|
49
|
-
* @returns The typed error.
|
|
50
|
-
*/
|
|
51
|
-
export declare function normalizeToTypedError<Code extends string>(error: unknown, { isValidCode, fallbackCode, codeProperties, }: {
|
|
52
|
-
isValidCode: (value: unknown) => value is Code;
|
|
53
|
-
fallbackCode: Code;
|
|
54
|
-
codeProperties?: string[];
|
|
55
|
-
}): TypedError<Code>;
|
|
56
|
-
//# sourceMappingURL=errorNormalization.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errorNormalization.d.cts","sourceRoot":"","sources":["../src/errorNormalization.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,UAAU,CAAC,IAAI,SAAS,MAAM,IAAI;IAC5C,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC;AAYF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAWlE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,SAAS,MAAM,EAC3D,KAAK,EAAE,OAAO,EACd,E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,IAAI,cAAc,EAAE,CAAC;QACtC,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;QAClC,IAAI,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3B,OAAO;gBACL,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,eAAe,CAAC,KAAK,CAAC;gBAC/B,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;aAC7D,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAc,EACd,EACE,WAAW,EACX,YAAY,EACZ,cAAc,GAKf;IAED,OAAO,CACL,yBAAyB,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC,IAAI;QACnE,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,eAAe,CAAC,KAAK,CAAC;KAChC,CACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * A typed error surface: a stable code plus an optional human message and\n * structured details. Consumers parameterise `Code` with their own error-code\n * union (e.g. headless-buy codes) so the taxonomy stays with the consumer while\n * the pure extraction below is shared.\n */\nexport type TypedError<Code extends string> = {\n code: Code;\n message?: string;\n details?: Record<string, unknown>;\n};\n\n/**\n * Type guard for a non-null object.\n *\n * @param value - The value to test.\n * @returns Whether the value is a record.\n */\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\n/**\n * Best-effort human-readable message from an arbitrary thrown/native value.\n *\n * @param error - The caught value.\n * @returns The message, or `undefined` when none can be derived.\n */\nexport function getErrorMessage(error: unknown): string | undefined {\n if (error instanceof Error) {\n return error.message;\n }\n if (isRecord(error) && typeof error.message === 'string') {\n return error.message;\n }\n if (typeof error === 'string') {\n return error;\n }\n return undefined;\n}\n\n/**\n * Extracts a caller-recognised typed error from an arbitrary thrown/native\n * value, when the value carries an explicit, valid code on one of the given\n * properties. Pure: performs no side effects and applies no fallback, so\n * callers keep full control over precedence (e.g. domain-specific special\n * cases) and the fallback code.\n *\n * @param error - The caught value.\n * @param options - The options.\n * @param options.isValidCode - Type guard identifying a recognised code.\n * @param options.codeProperties - Property names to read a code from, in\n * precedence order. Defaults to `['code']`.\n * @returns The typed error when an explicit valid code is present, else\n * `undefined`.\n */\nexport function extractExplicitTypedError<Code extends string>(\n error: unknown,\n {\n isValidCode,\n codeProperties = ['code'],\n }: {\n isValidCode: (value: unknown) => value is Code;\n codeProperties?: string[];\n },\n): TypedError<Code> | undefined {\n if (!isRecord(error)) {\n return undefined;\n }\n for (const property of codeProperties) {\n const candidate = error[property];\n if (isValidCode(candidate)) {\n return {\n code: candidate,\n message: getErrorMessage(error),\n details: isRecord(error.details) ? error.details : undefined,\n };\n }\n }\n return undefined;\n}\n\n/**\n * Normalises an arbitrary thrown/native value into a {@link TypedError}, using\n * the caller's recognised codes and falling back to `fallbackCode` when no\n * explicit valid code is present. Pure.\n *\n * @param error - The caught value.\n * @param options - The options.\n * @param options.isValidCode - Type guard identifying a recognised code.\n * @param options.fallbackCode - Code used when no explicit valid code is found.\n * @param options.codeProperties - Property names to read a code from, in\n * precedence order. Defaults to `['code']`.\n * @returns The typed error.\n */\nexport function normalizeToTypedError<Code extends string>(\n error: unknown,\n {\n isValidCode,\n fallbackCode,\n codeProperties,\n }: {\n isValidCode: (value: unknown) => value is Code;\n fallbackCode: Code;\n codeProperties?: string[];\n },\n): TypedError<Code> {\n return (\n extractExplicitTypedError(error, { isValidCode, codeProperties }) ?? {\n code: fallbackCode,\n message: getErrorMessage(error),\n }\n );\n}\n"]}
|
package/dist/featureFlags.cjs
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeHeadlessProviderId = exports.getHeadlessProviderAllowlist = exports.isHeadlessAllProvidersEnabled = exports.HEADLESS_ALL_PROVIDERS_FEATURE_VERSION = exports.MONEY_HEADLESS_ALL_PROVIDERS_FLAG_KEY = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Remote (LaunchDarkly) feature flag key for the Headless Buy all-providers
|
|
6
|
-
* expansion. Accepts two value forms:
|
|
7
|
-
*
|
|
8
|
-
* - The literal boolean `true` widens the headless fiat quote path to every
|
|
9
|
-
* provider class (native, in-app WebView aggregator, and external-browser /
|
|
10
|
-
* custom-action) with no provider restriction.
|
|
11
|
-
* - An object payload `{ enabled: true, featureVersion: "1", providerIds?: string[] }`
|
|
12
|
-
* widens the same way, and additionally restricts the widened quote pick to
|
|
13
|
-
* the listed provider ids (see {@link getHeadlessProviderAllowlist}).
|
|
14
|
-
*
|
|
15
|
-
* `false`, a missing flag, or any other value keeps the native-only default.
|
|
16
|
-
* Clients that only understand the boolean form coerce the object payload to
|
|
17
|
-
* "disabled" (native-only), so serving the object form can never turn the
|
|
18
|
-
* feature on for a client that cannot parse it. Exported so the flag registry
|
|
19
|
-
* and every consumer stay in sync on the exact key string.
|
|
20
|
-
*/
|
|
21
|
-
exports.MONEY_HEADLESS_ALL_PROVIDERS_FLAG_KEY = 'moneyHeadlessAllProviders';
|
|
22
|
-
/**
|
|
23
|
-
* Contract version of the object payload. An enabled payload whose
|
|
24
|
-
* `featureVersion` differs (or is absent) fails closed, so the payload's
|
|
25
|
-
* meaning can change in a future client without old clients misreading it.
|
|
26
|
-
* Mirrors the platform pattern used by `assetsUnifyState`.
|
|
27
|
-
*/
|
|
28
|
-
exports.HEADLESS_ALL_PROVIDERS_FEATURE_VERSION = '1';
|
|
29
|
-
/**
|
|
30
|
-
* Resolves the flag value with `localOverrides` (written by dev-only override
|
|
31
|
-
* screens) merged over `remoteFeatureFlags`, because not every published
|
|
32
|
-
* `RemoteFeatureFlagController` version folds overrides into
|
|
33
|
-
* `remoteFeatureFlags` state; when a version already does, the merge is a
|
|
34
|
-
* no-op.
|
|
35
|
-
*
|
|
36
|
-
* @param remoteFeatureFlagState - `RemoteFeatureFlagController` state (or the
|
|
37
|
-
* relevant subset of it).
|
|
38
|
-
* @returns The merged flag value, or `undefined` when absent.
|
|
39
|
-
*/
|
|
40
|
-
function resolveFlagValue(remoteFeatureFlagState) {
|
|
41
|
-
const flags = {
|
|
42
|
-
...(remoteFeatureFlagState?.remoteFeatureFlags ?? {}),
|
|
43
|
-
...(remoteFeatureFlagState?.localOverrides ?? {}),
|
|
44
|
-
};
|
|
45
|
-
return flags[exports.MONEY_HEADLESS_ALL_PROVIDERS_FLAG_KEY];
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Whether a flag value is the object payload form: a plain object (not an
|
|
49
|
-
* array) whose `enabled` is the literal boolean `true`. Anything else,
|
|
50
|
-
* including `{ enabled: false }` and objects without `enabled`, is not an
|
|
51
|
-
* enabled payload, so the flag fails closed.
|
|
52
|
-
*
|
|
53
|
-
* @param value - The merged flag value.
|
|
54
|
-
* @returns Whether the value is an enabled object payload.
|
|
55
|
-
*/
|
|
56
|
-
function isEnabledPayload(value) {
|
|
57
|
-
return (typeof value === 'object' &&
|
|
58
|
-
value !== null &&
|
|
59
|
-
!Array.isArray(value) &&
|
|
60
|
-
value.enabled === true &&
|
|
61
|
-
value.featureVersion === exports.HEADLESS_ALL_PROVIDERS_FEATURE_VERSION);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Coerces a payload field into a provider-id list: keeps only string entries,
|
|
65
|
-
* trims them, and drops empties. An empty or malformed level is treated as
|
|
66
|
-
* "not provided" so resolution falls through to the next level rather than
|
|
67
|
-
* restricting to nothing; to force "nothing eligible" list a nonexistent id.
|
|
68
|
-
*
|
|
69
|
-
* @param value - The candidate `providerIds` / surface entry value.
|
|
70
|
-
* @returns The non-empty coerced list, or `undefined`.
|
|
71
|
-
*/
|
|
72
|
-
function coerceProviderIdList(value) {
|
|
73
|
-
if (!Array.isArray(value)) {
|
|
74
|
-
return undefined;
|
|
75
|
-
}
|
|
76
|
-
const ids = value
|
|
77
|
-
.filter((entry) => typeof entry === 'string')
|
|
78
|
-
.map((entry) => entry.trim())
|
|
79
|
-
.filter((entry) => entry !== '');
|
|
80
|
-
return ids.length > 0 ? ids : undefined;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Whether the Headless Buy all-providers feature flag is enabled.
|
|
84
|
-
*
|
|
85
|
-
* Owns the key lookup and coercion for {@link MONEY_HEADLESS_ALL_PROVIDERS_FLAG_KEY}
|
|
86
|
-
* so the controller's quote widening and UI availability gates resolve the
|
|
87
|
-
* flag identically. `localOverrides` are merged over `remoteFeatureFlags`
|
|
88
|
-
* (see {@link resolveFlagValue}). Coerces defensively: only the literal
|
|
89
|
-
* boolean `true` or an object payload whose `enabled` is the literal `true`
|
|
90
|
-
* enables; any other value (missing, string, number, array, `{ enabled:
|
|
91
|
-
* false }`) resolves to `false`.
|
|
92
|
-
*
|
|
93
|
-
* @param remoteFeatureFlagState - `RemoteFeatureFlagController` state (or the
|
|
94
|
-
* relevant subset of it). May be `null`/`undefined` before the controller is
|
|
95
|
-
* initialized.
|
|
96
|
-
* @returns Whether all provider classes are enabled for the headless fiat
|
|
97
|
-
* quote path.
|
|
98
|
-
*/
|
|
99
|
-
function isHeadlessAllProvidersEnabled(remoteFeatureFlagState) {
|
|
100
|
-
const value = resolveFlagValue(remoteFeatureFlagState);
|
|
101
|
-
return value === true || isEnabledPayload(value);
|
|
102
|
-
}
|
|
103
|
-
exports.isHeadlessAllProvidersEnabled = isHeadlessAllProvidersEnabled;
|
|
104
|
-
/**
|
|
105
|
-
* The provider-id allowlist carried by the flag's object payload, or
|
|
106
|
-
* `undefined` when the widened pick should not be restricted.
|
|
107
|
-
*
|
|
108
|
-
* Returns the payload's top-level `providerIds` when non-empty and valid, or
|
|
109
|
-
* `undefined` (no restriction). The boolean `true` form, a disabled or
|
|
110
|
-
* malformed payload, and empty or all-invalid lists all resolve to
|
|
111
|
-
* `undefined`; unknown keys and non-string entries are ignored.
|
|
112
|
-
*
|
|
113
|
-
* @param remoteFeatureFlagState - `RemoteFeatureFlagController` state (or the
|
|
114
|
-
* relevant subset of it). May be `null`/`undefined` before the controller is
|
|
115
|
-
* initialized.
|
|
116
|
-
* @returns The provider ids the widened pick is restricted to, or `undefined`
|
|
117
|
-
* for no restriction.
|
|
118
|
-
*/
|
|
119
|
-
function getHeadlessProviderAllowlist(remoteFeatureFlagState) {
|
|
120
|
-
const value = resolveFlagValue(remoteFeatureFlagState);
|
|
121
|
-
if (!isEnabledPayload(value)) {
|
|
122
|
-
return undefined;
|
|
123
|
-
}
|
|
124
|
-
return coerceProviderIdList(value.providerIds);
|
|
125
|
-
}
|
|
126
|
-
exports.getHeadlessProviderAllowlist = getHeadlessProviderAllowlist;
|
|
127
|
-
/**
|
|
128
|
-
* Normalizes a provider id for allowlist matching only: trims, strips the
|
|
129
|
-
* canonical `/providers/` path prefix, and lowercases, so `/providers/moonpay`
|
|
130
|
-
* and `moonpay` match each other. Quote and catalog provider ids are matched
|
|
131
|
-
* as-is everywhere else; this exists solely so LaunchDarkly payload authors
|
|
132
|
-
* can use either id form. Not exported from the package index.
|
|
133
|
-
*
|
|
134
|
-
* @param id - A provider id in either the prefixed or bare form.
|
|
135
|
-
* @returns The normalized id used for allowlist comparison.
|
|
136
|
-
*/
|
|
137
|
-
function normalizeHeadlessProviderId(id) {
|
|
138
|
-
return id
|
|
139
|
-
.trim()
|
|
140
|
-
.replace(/^\/providers\//u, '')
|
|
141
|
-
.toLowerCase();
|
|
142
|
-
}
|
|
143
|
-
exports.normalizeHeadlessProviderId = normalizeHeadlessProviderId;
|
|
144
|
-
//# sourceMappingURL=featureFlags.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"featureFlags.cjs","sourceRoot":"","sources":["../src/featureFlags.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;;;;GAgBG;AACU,QAAA,qCA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G,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;IACvD,OAAO,KAAK,KAAK,IAAI,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC;AACnD,CAAC;AALD,sEAKC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,4BAA4B,CAC1C,sBAAqE;IAErE,MAAM,KAAK,GAAG,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;IACvD,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,oBAAoB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AACjD,CAAC;AARD,oEAQC;AAED;;;;;;;;;GASG;AACH,SAAgB,2BAA2B,CAAC,EAAU;IACpD,OAAO,EAAE;SACN,IAAI,EAAE;SACN,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC;SAC9B,WAAW,EAAE,CAAC;AACnB,CAAC;AALD,kEAKC","sourcesContent":["import type { FeatureFlags } from '@metamask/remote-feature-flag-controller';\nimport type { Json } from '@metamask/utils';\n\n/**\n * Remote (LaunchDarkly) feature flag key for the Headless Buy all-providers\n * expansion. Accepts two value forms:\n *\n * - The literal boolean `true` widens the headless fiat quote path to every\n * provider class (native, in-app WebView aggregator, and external-browser /\n * custom-action) with no provider restriction.\n * - An object payload `{ enabled: true, featureVersion: \"1\", providerIds?: string[] }`\n * widens the same way, and additionally restricts the widened quote pick to\n * the listed provider ids (see {@link getHeadlessProviderAllowlist}).\n *\n * `false`, a missing flag, or any other value keeps the native-only default.\n * Clients that only understand the boolean form coerce the object payload to\n * \"disabled\" (native-only), so serving the object form can never turn the\n * feature on for a client that cannot parse it. Exported so the flag registry\n * and every consumer stay in sync on the exact key string.\n */\nexport const MONEY_HEADLESS_ALL_PROVIDERS_FLAG_KEY =\n 'moneyHeadlessAllProviders';\n\n/**\n * Contract version of the object payload. An enabled payload whose\n * `featureVersion` differs (or is absent) fails closed, so the payload's\n * meaning can change in a future client without old clients misreading it.\n * Mirrors the platform pattern used by `assetsUnifyState`.\n */\nexport const HEADLESS_ALL_PROVIDERS_FEATURE_VERSION = '1';\n\n/**\n * The subset of `RemoteFeatureFlagController` state that\n * {@link isHeadlessAllProvidersEnabled} reads. Structural so consumers can\n * pass the whole controller state (or `undefined` before initialization)\n * without depending on a specific controller version.\n */\nexport type HeadlessFeatureFlagsLookup = {\n remoteFeatureFlags?: FeatureFlags;\n localOverrides?: FeatureFlags;\n};\n\n/**\n * Resolves the flag value with `localOverrides` (written by dev-only override\n * screens) merged over `remoteFeatureFlags`, because not every published\n * `RemoteFeatureFlagController` version folds overrides into\n * `remoteFeatureFlags` state; when a version already does, the merge is a\n * no-op.\n *\n * @param remoteFeatureFlagState - `RemoteFeatureFlagController` state (or the\n * relevant subset of it).\n * @returns The merged flag value, or `undefined` when absent.\n */\nfunction resolveFlagValue(\n remoteFeatureFlagState: HeadlessFeatureFlagsLookup | null | undefined,\n): Json | undefined {\n const flags: FeatureFlags = {\n ...(remoteFeatureFlagState?.remoteFeatureFlags ?? {}),\n ...(remoteFeatureFlagState?.localOverrides ?? {}),\n };\n return flags[MONEY_HEADLESS_ALL_PROVIDERS_FLAG_KEY];\n}\n\n/**\n * Whether a flag value is the object payload form: a plain object (not an\n * array) whose `enabled` is the literal boolean `true`. Anything else,\n * including `{ enabled: false }` and objects without `enabled`, is not an\n * enabled payload, so the flag fails closed.\n *\n * @param value - The merged flag value.\n * @returns Whether the value is an enabled object payload.\n */\nfunction isEnabledPayload(value: Json | undefined): value is {\n [key: string]: Json;\n} {\n return (\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value) &&\n value.enabled === true &&\n value.featureVersion === HEADLESS_ALL_PROVIDERS_FEATURE_VERSION\n );\n}\n\n/**\n * Coerces a payload field into a provider-id list: keeps only string entries,\n * trims them, and drops empties. An empty or malformed level is treated as\n * \"not provided\" so resolution falls through to the next level rather than\n * restricting to nothing; to force \"nothing eligible\" list a nonexistent id.\n *\n * @param value - The candidate `providerIds` / surface entry value.\n * @returns The non-empty coerced list, or `undefined`.\n */\nfunction coerceProviderIdList(value: Json | undefined): string[] | undefined {\n if (!Array.isArray(value)) {\n return undefined;\n }\n const ids = value\n .filter((entry): entry is string => typeof entry === 'string')\n .map((entry) => entry.trim())\n .filter((entry) => entry !== '');\n return ids.length > 0 ? ids : undefined;\n}\n\n/**\n * Whether the Headless Buy all-providers feature flag is enabled.\n *\n * Owns the key lookup and coercion for {@link MONEY_HEADLESS_ALL_PROVIDERS_FLAG_KEY}\n * so the controller's quote widening and UI availability gates resolve the\n * flag identically. `localOverrides` are merged over `remoteFeatureFlags`\n * (see {@link resolveFlagValue}). Coerces defensively: only the literal\n * boolean `true` or an object payload whose `enabled` is the literal `true`\n * enables; any other value (missing, string, number, array, `{ enabled:\n * false }`) resolves to `false`.\n *\n * @param remoteFeatureFlagState - `RemoteFeatureFlagController` state (or the\n * relevant subset of it). May be `null`/`undefined` before the controller is\n * initialized.\n * @returns Whether all provider classes are enabled for the headless fiat\n * quote path.\n */\nexport function isHeadlessAllProvidersEnabled(\n remoteFeatureFlagState: HeadlessFeatureFlagsLookup | null | undefined,\n): boolean {\n const value = resolveFlagValue(remoteFeatureFlagState);\n return value === true || isEnabledPayload(value);\n}\n\n/**\n * The provider-id allowlist carried by the flag's object payload, or\n * `undefined` when the widened pick should not be restricted.\n *\n * Returns the payload's top-level `providerIds` when non-empty and valid, or\n * `undefined` (no restriction). The boolean `true` form, a disabled or\n * malformed payload, and empty or all-invalid lists all resolve to\n * `undefined`; unknown keys and non-string entries are ignored.\n *\n * @param remoteFeatureFlagState - `RemoteFeatureFlagController` state (or the\n * relevant subset of it). May be `null`/`undefined` before the controller is\n * initialized.\n * @returns The provider ids the widened pick is restricted to, or `undefined`\n * for no restriction.\n */\nexport function getHeadlessProviderAllowlist(\n remoteFeatureFlagState: HeadlessFeatureFlagsLookup | null | undefined,\n): string[] | undefined {\n const value = resolveFlagValue(remoteFeatureFlagState);\n if (!isEnabledPayload(value)) {\n return undefined;\n }\n return coerceProviderIdList(value.providerIds);\n}\n\n/**\n * Normalizes a provider id for allowlist matching only: trims, strips the\n * canonical `/providers/` path prefix, and lowercases, so `/providers/moonpay`\n * and `moonpay` match each other. Quote and catalog provider ids are matched\n * as-is everywhere else; this exists solely so LaunchDarkly payload authors\n * can use either id form. Not exported from the package index.\n *\n * @param id - A provider id in either the prefixed or bare form.\n * @returns The normalized id used for allowlist comparison.\n */\nexport function normalizeHeadlessProviderId(id: string): string {\n return id\n .trim()\n .replace(/^\\/providers\\//u, '')\n .toLowerCase();\n}\n"]}
|