@metamask/ramps-controller 20.3.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 +17 -1
- package/dist/{NeoBankService-method-action-types.d.mts → NeoBankService-method-action-types.d.ts} +2 -2
- package/dist/NeoBankService-method-action-types.d.ts.map +1 -0
- package/dist/{NeoBankService-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.cts → NeoBankService.d.ts} +8 -8
- 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} +2 -2
- package/dist/RampsController-method-action-types.d.ts.map +1 -0
- package/dist/{TransakService-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} +19 -19
- package/dist/RampsController.d.ts.map +1 -0
- package/dist/{RampsController.mjs → RampsController.js} +725 -613
- 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.mts → 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/{RampsController-method-action-types.mjs → TransakService-method-action-types.js} +1 -1
- package/dist/TransakService-method-action-types.js.map +1 -0
- package/dist/{TransakService.d.cts → 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.cts → autoramp-types.d.ts} +1 -1
- 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.mts → autorampAccount.d.ts} +3 -3
- package/dist/autorampAccount.d.ts.map +1 -0
- package/dist/{autorampAccount.mjs → autorampAccount.js} +1 -1
- package/dist/autorampAccount.js.map +1 -0
- package/dist/{client-identity.d.mts → 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.mts → index.d.ts} +35 -35
- 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.cts → ownership-message.d.ts} +1 -1
- package/dist/ownership-message.d.ts.map +1 -0
- package/dist/{ownership-message.mjs → ownership-message.js} +1 -1
- 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.cts → 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.cts → wallet-registration-machine.d.ts} +1 -1
- package/dist/wallet-registration-machine.d.ts.map +1 -0
- package/dist/{wallet-registration-machine.mjs → wallet-registration-machine.js} +1 -1
- package/dist/wallet-registration-machine.js.map +1 -0
- package/dist/{wallet-registration-service.d.cts → wallet-registration-service.d.ts} +1 -1
- package/dist/wallet-registration-service.d.ts.map +1 -0
- package/dist/{wallet-registration-service.mjs → wallet-registration-service.js} +60 -69
- package/dist/wallet-registration-service.js.map +1 -0
- package/package.json +17 -21
- package/dist/NeoBankService-method-action-types.cjs +0 -7
- package/dist/NeoBankService-method-action-types.cjs.map +0 -1
- package/dist/NeoBankService-method-action-types.d.cts +0 -126
- package/dist/NeoBankService-method-action-types.d.cts.map +0 -1
- package/dist/NeoBankService-method-action-types.d.mts.map +0 -1
- package/dist/NeoBankService-method-action-types.mjs.map +0 -1
- package/dist/NeoBankService.cjs +0 -387
- package/dist/NeoBankService.cjs.map +0 -1
- package/dist/NeoBankService.d.cts.map +0 -1
- package/dist/NeoBankService.d.mts +0 -191
- package/dist/NeoBankService.d.mts.map +0 -1
- package/dist/NeoBankService.mjs +0 -379
- package/dist/NeoBankService.mjs.map +0 -1
- 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 -758
- 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 -2799
- package/dist/RampsController.cjs.map +0 -1
- package/dist/RampsController.d.cts.map +0 -1
- package/dist/RampsController.d.mts +0 -968
- 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 +0 -110
- package/dist/RequestCache.d.cts.map +0 -1
- 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.map +0 -1
- package/dist/TransakService.d.mts +0 -370
- package/dist/TransakService.d.mts.map +0 -1
- package/dist/TransakService.mjs +0 -734
- package/dist/TransakService.mjs.map +0 -1
- package/dist/autoramp-types.cjs +0 -3
- package/dist/autoramp-types.cjs.map +0 -1
- package/dist/autoramp-types.d.cts.map +0 -1
- package/dist/autoramp-types.d.mts +0 -22
- package/dist/autoramp-types.d.mts.map +0 -1
- package/dist/autoramp-types.mjs +0 -2
- package/dist/autoramp-types.mjs.map +0 -1
- package/dist/autorampAccount.cjs +0 -155
- package/dist/autorampAccount.cjs.map +0 -1
- package/dist/autorampAccount.d.cts +0 -126
- package/dist/autorampAccount.d.cts.map +0 -1
- package/dist/autorampAccount.d.mts.map +0 -1
- package/dist/autorampAccount.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 +0 -24
- package/dist/client-identity.d.cts.map +0 -1
- 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 -82
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -35
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -18
- 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/ownership-message.cjs +0 -26
- package/dist/ownership-message.cjs.map +0 -1
- package/dist/ownership-message.d.cts.map +0 -1
- package/dist/ownership-message.d.mts +0 -22
- package/dist/ownership-message.d.mts.map +0 -1
- package/dist/ownership-message.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.map +0 -1
- package/dist/providerAvailability.d.mts +0 -101
- 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
- package/dist/wallet-registration-machine.cjs +0 -144
- package/dist/wallet-registration-machine.cjs.map +0 -1
- package/dist/wallet-registration-machine.d.cts.map +0 -1
- package/dist/wallet-registration-machine.d.mts +0 -81
- package/dist/wallet-registration-machine.d.mts.map +0 -1
- package/dist/wallet-registration-machine.mjs.map +0 -1
- package/dist/wallet-registration-service.cjs +0 -351
- package/dist/wallet-registration-service.cjs.map +0 -1
- package/dist/wallet-registration-service.d.cts.map +0 -1
- package/dist/wallet-registration-service.d.mts +0 -144
- package/dist/wallet-registration-service.d.mts.map +0 -1
- package/dist/wallet-registration-service.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paymentMethodMerge.js","sourceRoot":"","sources":["../src/paymentMethodMerge.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAwB,EACxB,YAAoC;IAEpC,KAAK,MAAM,EAAE,IAAI,YAAY,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC1E,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,KAAwB;IAExB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,GAAG,EAAyB,CAAC;IAE9C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,KAAK,MAAM,MAAM,IAAI,IAAI,EAAE,CAAC;YAC1B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;gBACzB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import type { PaymentMethod } from './RampsService.js';\n\n/**\n * Merges payment-method lists from multiple providers into one list keyed by\n * canonical payment method `id`.\n *\n * First seen wins on collision. Payment metadata is provider-invariant: the\n * API serves it from a per-region catalog and the `provider` query narrows\n * that catalog by id-set membership without rewriting fields, so colliding\n * entries carry identical values.\n *\n * Encounter order of first-seen ids is preserved (provider fan-out order).\n *\n * @param lists - Payment method arrays in provider contribution order.\n * @returns Deduped payment methods.\n */\n/**\n * Picks the payment method to select: the first `preferredIds` entry still\n * present in `methods`, otherwise the first method.\n *\n * @param methods - Candidate payment methods, in display order.\n * @param preferredIds - Preferred ids in priority order; falsy ids are skipped.\n * @returns The selection, or null when `methods` is empty.\n */\nexport function pickPaymentMethod(\n methods: PaymentMethod[],\n preferredIds: (string | undefined)[],\n): PaymentMethod | null {\n for (const id of preferredIds) {\n const match = id ? methods.find((method) => method.id === id) : undefined;\n if (match) {\n return match;\n }\n }\n return methods[0] ?? null;\n}\n\nexport function mergePaymentMethodsById(\n lists: PaymentMethod[][],\n): PaymentMethod[] {\n if (lists.length === 1) {\n return lists[0];\n }\n\n const byId = new Map<string, PaymentMethod>();\n\n for (const list of lists) {\n for (const method of list) {\n if (!byId.has(method.id)) {\n byId.set(method.id, { ...method });\n }\n }\n }\n\n return [...byId.values()];\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Provider } from
|
|
1
|
+
import type { Provider } from './RampsService.js';
|
|
2
2
|
/**
|
|
3
3
|
* Canonicalizes a CAIP-19 asset id for comparison against Ramps API values.
|
|
4
4
|
*
|
|
@@ -98,4 +98,4 @@ export declare function isFiatDepositAvailable({ providers, selectedProvider, al
|
|
|
98
98
|
selectedProvider?: Provider | null;
|
|
99
99
|
allProvidersEnabled: boolean;
|
|
100
100
|
}): boolean;
|
|
101
|
-
//# sourceMappingURL=providerAvailability.d.
|
|
101
|
+
//# sourceMappingURL=providerAvailability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providerAvailability.d.ts","sourceRoot":"","sources":["../src/providerAvailability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAK7D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,GACd,OAAO,CAST;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,QAAQ,EAAE,EACrB,OAAO,EAAE,MAAM,GACd,QAAQ,EAAE,CAEZ;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,yBAAyB,CAAC,EACxC,SAAS,EACT,OAAO,EACP,mBAAmB,GACpB,EAAE;IACD,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB,EAAE,OAAO,CAAC;CAC9B,GAAG,OAAO,CAYV;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,SAAS,EACT,gBAAgB,EAChB,mBAAmB,GACpB,EAAE;IACD,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,gBAAgB,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IACnC,mBAAmB,EAAE,OAAO,CAAC;CAC9B,GAAG,OAAO,CAQV"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providerAvailability.js","sourceRoot":"","sources":["../src/providerAvailability.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAe;IACnD,MAAM,cAAc,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IACtC,OAAO,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC;QACtC,CAAC,CAAC,cAAc,CAAC,WAAW,EAAE;QAC9B,CAAC,CAAC,cAAc,CAAC;AACrB,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,mBAAmB,CACjC,QAAkB,EAClB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AAgB,EAAE,IAAI,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import type { Provider } from './RampsService.js';\n\n/**\n * Canonicalizes a CAIP-19 asset id for comparison against Ramps API values.\n *\n * CAIP-19 does not constrain the case of the asset reference, and the Ramps API\n * is not consistent about it. Every `eip155` key in `regions/{region}/providers`\n * `supportedCryptoCurrencies` is lowercase, while `regions/{region}/topTokens`\n * returns four mainnet `assetId` values EIP-55 checksummed (USDT, USDC, WBTC,\n * LINK) in both its `topTokens` and `allTokens` lists, with no lowercase\n * duplicate. Callers also supply checksummed ids of their own from other\n * controllers, so the two sides of a comparison can disagree on case for the\n * same asset.\n *\n * Non-EVM references are case-sensitive (Solana base58, Tron base58, bitcoin\n * bech32), so lowercasing is restricted to `eip155` rather than applied to the\n * whole string. This is a tightening: for EVM ids a plain `toLowerCase()` on\n * both sides already matched. Current API data carries non-EVM ids in identical\n * case on both endpoints, so the passthrough guards against future drift rather\n * than fixing an observed mismatch.\n *\n * The namespace itself is matched case-insensitively, so an `EIP155:` prefix\n * is treated as EVM even though CAIP-19 defines namespaces as lowercase.\n *\n * @param assetId - CAIP-19 asset id, in either case form.\n * @returns The asset id in the form the Ramps API uses.\n */\nexport function normalizeRampsAssetId(assetId: string): string {\n const trimmedAssetId = assetId.trim();\n return /^eip155:/iu.test(trimmedAssetId)\n ? trimmedAssetId.toLowerCase()\n : trimmedAssetId;\n}\n\n/**\n * Whether a provider serves the given deposit asset.\n *\n * Mirrors the region-provider matching the controller performs internally: a\n * provider serves the asset when its `supportedCryptoCurrencies` map (keyed by\n * CAIP-19 asset id) contains the asset id. Both sides are canonicalized with\n * {@link normalizeRampsAssetId}, so EVM ids match regardless of checksum\n * casing while non-EVM references stay case-sensitive. A provider without a\n * `supportedCryptoCurrencies` map is treated as not serving the asset.\n *\n * @param provider - The provider to test.\n * @param assetId - CAIP-19 asset id of the deposit asset.\n * @returns Whether the provider serves the asset.\n */\nexport function providerServesAsset(\n provider: Provider,\n assetId: string,\n): boolean {\n const map = provider?.supportedCryptoCurrencies;\n if (!map) {\n return false;\n }\n const target = normalizeRampsAssetId(assetId);\n return Object.keys(map).some(\n (key) => normalizeRampsAssetId(key) === target && map[key],\n );\n}\n\n/**\n * Filters a provider list down to those serving the given deposit asset.\n *\n * @param providers - The providers to filter.\n * @param assetId - CAIP-19 asset id of the deposit asset.\n * @returns The subset of providers serving the asset.\n */\nexport function getProvidersServingAsset(\n providers: Provider[],\n assetId: string,\n): Provider[] {\n return providers.filter((provider) => providerServesAsset(provider, assetId));\n}\n\n/**\n * Whether a region offers a usable on-ramp provider that serves the given\n * deposit asset, under the all-providers feature flag. This is the pure,\n * asset-aware region gate shared between the controller and headless-buy\n * consumers so the two never disagree about eligibility.\n *\n * With `allProvidersEnabled` false the gate is native-only: the region must\n * offer a native provider (e.g. Transak Native) that serves the asset. With\n * `allProvidersEnabled` true the region is supported when any provider\n * (native or aggregator) serves the asset; the controller's flag-aware\n * `getQuotes` performs the precise provider selection at quote time. Fails\n * closed: an empty or missing `assetId` returns `false`.\n *\n * @param options - The options.\n * @param options.providers - The region's providers (native and aggregator).\n * @param options.assetId - CAIP-19 asset id of the deposit asset.\n * @param options.allProvidersEnabled - Whether the all-providers feature flag\n * is enabled (see `isHeadlessAllProvidersEnabled`).\n * @returns Whether the region has a provider serving the asset.\n */\nexport function regionHasProviderForAsset({\n providers,\n assetId,\n allProvidersEnabled,\n}: {\n providers: Provider[];\n assetId: string;\n allProvidersEnabled: boolean;\n}): boolean {\n if (!assetId) {\n return false;\n }\n const serving = getProvidersServingAsset(providers, assetId);\n if (serving.some((provider) => provider.type === 'native')) {\n return true;\n }\n if (!allProvidersEnabled) {\n return false;\n }\n return serving.length > 0;\n}\n\n/**\n * Whether headless fiat deposit is available for the current region, under\n * the all-providers feature flag. Flag-aware and independent of which single\n * provider is currently selected once widened, so the availability gate\n * cannot disagree with the controller's own flag-aware provider pick.\n *\n * With `allProvidersEnabled` false the check keeps the native-only behaviour:\n * a native provider must be the currently selected (preferred) one, since the\n * controller resolves the selected provider first and an aggregator preferred\n * provider would otherwise run a non-native deposit. With\n * `allProvidersEnabled` true the flow is available whenever the region has\n * any provider.\n *\n * @param options - The options.\n * @param options.providers - The region's providers.\n * @param options.selectedProvider - The currently selected provider, if any.\n * @param options.allProvidersEnabled - Whether the all-providers feature flag\n * is enabled (see `isHeadlessAllProvidersEnabled`).\n * @returns Whether headless fiat deposit is available.\n */\nexport function isFiatDepositAvailable({\n providers,\n selectedProvider,\n allProvidersEnabled,\n}: {\n providers: Provider[];\n selectedProvider?: Provider | null;\n allProvidersEnabled: boolean;\n}): boolean {\n if (selectedProvider?.type === 'native') {\n return true;\n }\n if (!allProvidersEnabled) {\n return false;\n }\n return providers.length > 0;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Quote } from
|
|
1
|
+
import type { Quote } from './RampsService.js';
|
|
2
2
|
/**
|
|
3
3
|
* Whether a quote's checkout runs in an external / system browser rather than
|
|
4
4
|
* an in-app WebView. Decided by the per-quote `buyWidget.browser` hint from the
|
|
@@ -30,4 +30,4 @@ export declare function isCustomActionQuote(quote: Quote): boolean;
|
|
|
30
30
|
* @returns Whether the quote is an in-app WebView quote.
|
|
31
31
|
*/
|
|
32
32
|
export declare function isInAppOnlyQuote(quote: Quote): boolean;
|
|
33
|
-
//# sourceMappingURL=quoteClassification.d.
|
|
33
|
+
//# sourceMappingURL=quoteClassification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quoteClassification.d.ts","sourceRoot":"","sources":["../src/quoteClassification.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAE5D;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAEzD;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAEtD"}
|
|
@@ -35,4 +35,4 @@ export function isCustomActionQuote(quote) {
|
|
|
35
35
|
export function isInAppOnlyQuote(quote) {
|
|
36
36
|
return !isCustomActionQuote(quote) && !isExternalBrowserQuote(quote);
|
|
37
37
|
}
|
|
38
|
-
//# sourceMappingURL=quoteClassification.
|
|
38
|
+
//# sourceMappingURL=quoteClassification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quoteClassification.js","sourceRoot":"","sources":["../src/quoteClassification.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAY;IACjD,OAAO,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,KAAK,mBAAmB,CAAC;AACjE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAY;IAC9C,OAAQ,KAAK,CAAC,KAAsC,EAAE,cAAc,KAAK,IAAI,CAAC;AAChF,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAY;IAC3C,OAAO,CAAC,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import type { Quote } from './RampsService.js';\n\n/**\n * Whether a quote's checkout runs in an external / system browser rather than\n * an in-app WebView. Decided by the per-quote `buyWidget.browser` hint from the\n * quotes API. When the hint is absent the quote is treated as in-app (the\n * caller is responsible for the in-app WebView fail-safe).\n *\n * This is the pure classification only: it deliberately knows nothing about\n * host redirect URLs or deeplink schemes, which stay in the consuming client.\n *\n * @param quote - The quote to classify.\n * @returns Whether the quote uses an external browser.\n */\nexport function isExternalBrowserQuote(quote: Quote): boolean {\n return quote.quote?.buyWidget?.browser === 'IN_APP_OS_BROWSER';\n}\n\n/**\n * Whether a quote is a custom-action (\"checkout outside of MetaMask\") quote,\n * e.g. PayPal or Robinhood. Reads the inline `isCustomAction` flag, which the\n * wire may carry even though it is absent from the published `Quote` type.\n *\n * @param quote - The quote to classify.\n * @returns Whether the quote is a custom-action quote.\n */\nexport function isCustomActionQuote(quote: Quote): boolean {\n return (quote.quote as { isCustomAction?: boolean })?.isCustomAction === true;\n}\n\n/**\n * Whether a quote continues inside an in-app WebView, i.e. it is neither a\n * custom-action quote nor an external-browser quote. This is the Phase 1\n * in-app-only inclusion test.\n *\n * @param quote - The quote to classify.\n * @returns Whether the quote is an in-app WebView quote.\n */\nexport function isInAppOnlyQuote(quote: Quote): boolean {\n return !isCustomActionQuote(quote) && !isExternalBrowserQuote(quote);\n}\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* These codes are returned to the UI layer for translation.
|
|
4
4
|
*/
|
|
5
5
|
export declare const RAMPS_ERROR_CODES: {
|
|
6
|
-
readonly CIRCUIT_BREAKER_OPEN:
|
|
6
|
+
readonly CIRCUIT_BREAKER_OPEN: 'CIRCUIT_BREAKER_OPEN';
|
|
7
7
|
};
|
|
8
8
|
export type RampsErrorCode = (typeof RAMPS_ERROR_CODES)[keyof typeof RAMPS_ERROR_CODES];
|
|
9
|
-
//# sourceMappingURL=rampsErrorCodes.d.
|
|
9
|
+
//# sourceMappingURL=rampsErrorCodes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rampsErrorCodes.d.ts","sourceRoot":"","sources":["../src/rampsErrorCodes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,iBAAiB;aAC5B,oBAAoB,EAAE,sBAAsB;CACpC,CAAC;AAEX,MAAM,MAAM,cAAc,GACxB,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rampsErrorCodes.js","sourceRoot":"","sources":["../src/rampsErrorCodes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,oBAAoB,EAAE,sBAAsB;CACpC,CAAC","sourcesContent":["/**\n * Error codes for RampsController.\n * These codes are returned to the UI layer for translation.\n */\nexport const RAMPS_ERROR_CODES = {\n CIRCUIT_BREAKER_OPEN: 'CIRCUIT_BREAKER_OPEN',\n} as const;\n\nexport type RampsErrorCode =\n (typeof RAMPS_ERROR_CODES)[keyof typeof RAMPS_ERROR_CODES];\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { RampsControllerState } from
|
|
2
|
-
import type { RampsErrorCode } from
|
|
1
|
+
import type { RampsControllerState } from './RampsController.js';
|
|
2
|
+
import type { RampsErrorCode } from './rampsErrorCodes.js';
|
|
3
3
|
/**
|
|
4
4
|
* Result shape returned by request selectors.
|
|
5
5
|
*
|
|
@@ -75,4 +75,4 @@ export type RequestSelectorResult<TData> = {
|
|
|
75
75
|
* ```
|
|
76
76
|
*/
|
|
77
77
|
export declare function createRequestSelector<TRootState, TData>(getState: (rootState: TRootState) => RampsControllerState | undefined, method: string, params: unknown[]): (state: TRootState) => RequestSelectorResult<TData>;
|
|
78
|
-
//# sourceMappingURL=selectors.d.
|
|
78
|
+
//# sourceMappingURL=selectors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAI3D;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,CAAC,KAAK,IAAI;IACzC,+EAA+E;IAC/E,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;IACnB,oDAAoD;IACpD,UAAU,EAAE,OAAO,CAAC;IACpB,uFAAuF;IACvF,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CAClC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,KAAK,EACrD,QAAQ,EAAE,CAAC,SAAS,EAAE,UAAU,KAAK,oBAAoB,GAAG,SAAS,EACrE,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,EAAE,GAChB,CAAC,KAAK,EAAE,UAAU,KAAK,qBAAqB,CAAC,KAAK,CAAC,CA4BrD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RequestStatus, createCacheKey } from
|
|
1
|
+
import { RequestStatus, createCacheKey } from './RequestCache.js';
|
|
2
2
|
/**
|
|
3
3
|
* Creates a memoized selector for a controller method's request state.
|
|
4
4
|
*
|
|
@@ -78,4 +78,4 @@ export function createRequestSelector(getState, method, params) {
|
|
|
78
78
|
return lastResult;
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
|
-
//# sourceMappingURL=selectors.
|
|
81
|
+
//# sourceMappingURL=selectors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectors.js","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAoBlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAqE,EACrE,MAAc,EACd,MAAiB;IAEjB,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEhD,IAAI,WAAqC,CAAC;IAC1C,IAAI,UAAU,GAAwC,IAAI,CAAC;IAE3D,OAAO,CAAC,KAAiB,EAAgC,EAAE;QACzD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC;QAEtD,IAAI,OAAO,KAAK,WAAW,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;YACnD,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,WAAW,GAAG,OAAO,CAAC;QACtB,MAAM,UAAU,GAAiC;YAC/C,IAAI,EAAG,OAAO,EAAE,IAAc,IAAI,IAAI;YACtC,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,aAAa,CAAC,OAAO;YACrD,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,IAAI;SAC9B,CAAC;QAEF,IAAI,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,UAAU,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACzC,CAAC;QAED,UAAU,GAAG,UAAU,CAAC;QAExB,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { RampsControllerState } from './RampsController.js';\nimport type { RampsErrorCode } from './rampsErrorCodes.js';\nimport type { RequestState } from './RequestCache.js';\nimport { RequestStatus, createCacheKey } from './RequestCache.js';\n\n/**\n * Result shape returned by request selectors.\n *\n * This object is memoized - the same reference is returned when the underlying\n * request state hasn't changed, making it safe to use with React Redux's\n * `useSelector` without `shallowEqual`.\n */\nexport type RequestSelectorResult<TData> = {\n /** The data returned by the request, or null if not yet loaded or on error. */\n data: TData | null;\n /** Whether the request is currently in progress. */\n isFetching: boolean;\n /** Error message if the request failed, or null if successful or not yet attempted. */\n error: string | null;\n /** Stable error key for client-side localization, if available. */\n errorKey?: RampsErrorCode | null;\n};\n\n/**\n * Creates a memoized selector for a controller method's request state.\n *\n * This selector tracks the loading, error, and data state for a specific\n * controller method call. It's optimized for use with React Redux's `useSelector`\n * hook - the selector returns the same object reference when the underlying\n * request state hasn't changed, so no `shallowEqual` is needed.\n *\n * The selector uses reference equality on the request object itself, so it\n * works correctly with arrays and objects without expensive deep equality checks.\n *\n * @param getState - Function that extracts RampsControllerState from the root state.\n * Typically a reselect selector like `selectRampsControllerState`.\n * @param method - The controller method name (e.g., 'updateUserRegion').\n * @param params - The parameters passed to the method, used to generate the cache key.\n * Must match the params used when calling the controller method.\n * @returns A selector function that returns `{ data, isFetching, error }`.\n *\n * @example\n * ```ts\n * // In selectors file - create once at module level\n * import { createRequestSelector } from '@metamask/ramps-controller';\n * import { createSelector } from 'reselect';\n *\n * const selectRampsControllerState = createSelector(\n * (state: RootState) => state.engine.backgroundState.RampsController,\n * (rampsControllerState) => rampsControllerState,\n * );\n *\n * export const selectUserRegionRequest = createRequestSelector<\n * RootState,\n * string\n * >(selectRampsControllerState, 'updateUserRegion', []);\n *\n * // In hook - use directly with useSelector, no shallowEqual needed\n * export function useRampsUserRegion() {\n * const { isFetching, error } = useSelector(selectUserRegionRequest);\n * // ... rest of hook\n * }\n * ```\n *\n * @example\n * ```ts\n * // For methods with parameters\n * export const selectCryptoCurrenciesRequest = (region: string) =>\n * createRequestSelector<RootState, CryptoCurrency[]>(\n * selectRampsControllerState,\n * 'getCryptoCurrencies',\n * [region],\n * );\n *\n * // In component\n * const { data, isFetching, error } = useSelector(\n * selectCryptoCurrenciesRequest('US')\n * );\n * ```\n */\nexport function createRequestSelector<TRootState, TData>(\n getState: (rootState: TRootState) => RampsControllerState | undefined,\n method: string,\n params: unknown[],\n): (state: TRootState) => RequestSelectorResult<TData> {\n const cacheKey = createCacheKey(method, params);\n\n let lastRequest: RequestState | undefined;\n let lastResult: RequestSelectorResult<TData> | null = null;\n\n return (state: TRootState): RequestSelectorResult<TData> => {\n const request = getState(state)?.requests?.[cacheKey];\n\n if (request === lastRequest && lastResult !== null) {\n return lastResult;\n }\n\n lastRequest = request;\n const nextResult: RequestSelectorResult<TData> = {\n data: (request?.data as TData) ?? null,\n isFetching: request?.status === RequestStatus.LOADING,\n error: request?.error ?? null,\n };\n\n if (request?.errorKey) {\n nextResult.errorKey = request.errorKey;\n }\n\n lastResult = nextResult;\n\n return lastResult;\n };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transakApiErrorUtils.d.ts","sourceRoot":"","sources":["../src/transakApiErrorUtils.ts"],"names":[],"mappings":"AAGA,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAEvE;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAKrE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TRANSAK_ERROR_CODES } from
|
|
2
|
-
import { TransakApiError } from
|
|
1
|
+
import { TRANSAK_ERROR_CODES } from './transakErrorCodes.js';
|
|
2
|
+
import { TransakApiError } from './TransakService.js';
|
|
3
3
|
export function getTransakApiMessage(error) {
|
|
4
4
|
return error instanceof TransakApiError ? error.apiMessage : undefined;
|
|
5
5
|
}
|
|
@@ -7,4 +7,4 @@ export function isTransakPhoneRegisteredError(error) {
|
|
|
7
7
|
return (error instanceof TransakApiError &&
|
|
8
8
|
error.errorCode === TRANSAK_ERROR_CODES.PHONE_ALREADY_REGISTERED);
|
|
9
9
|
}
|
|
10
|
-
//# sourceMappingURL=transakApiErrorUtils.
|
|
10
|
+
//# sourceMappingURL=transakApiErrorUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transakApiErrorUtils.js","sourceRoot":"","sources":["../src/transakApiErrorUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,OAAO,KAAK,YAAY,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,KAAc;IAC1D,OAAO,CACL,KAAK,YAAY,eAAe;QAChC,KAAK,CAAC,SAAS,KAAK,mBAAmB,CAAC,wBAAwB,CACjE,CAAC;AACJ,CAAC","sourcesContent":["import { TRANSAK_ERROR_CODES } from './transakErrorCodes.js';\nimport { TransakApiError } from './TransakService.js';\n\nexport function getTransakApiMessage(error: unknown): string | undefined {\n return error instanceof TransakApiError ? error.apiMessage : undefined;\n}\n\nexport function isTransakPhoneRegisteredError(error: unknown): boolean {\n return (\n error instanceof TransakApiError &&\n error.errorCode === TRANSAK_ERROR_CODES.PHONE_ALREADY_REGISTERED\n );\n}\n"]}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* codes when parsing API responses.
|
|
6
6
|
*/
|
|
7
7
|
export declare const TRANSAK_ERROR_CODES: {
|
|
8
|
-
readonly ORDER_EXISTS:
|
|
9
|
-
readonly PHONE_ALREADY_REGISTERED:
|
|
8
|
+
readonly ORDER_EXISTS: '4005';
|
|
9
|
+
readonly PHONE_ALREADY_REGISTERED: '2020';
|
|
10
10
|
};
|
|
11
11
|
export type TransakErrorCode = (typeof TRANSAK_ERROR_CODES)[keyof typeof TRANSAK_ERROR_CODES];
|
|
12
|
-
//# sourceMappingURL=transakErrorCodes.d.
|
|
12
|
+
//# sourceMappingURL=transakErrorCodes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transakErrorCodes.d.ts","sourceRoot":"","sources":["../src/transakErrorCodes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB;aAC9B,YAAY,EAAE,MAAM;aACpB,wBAAwB,EAAE,MAAM;CACxB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAC1B,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transakErrorCodes.js","sourceRoot":"","sources":["../src/transakErrorCodes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,YAAY,EAAE,MAAM;IACpB,wBAAwB,EAAE,MAAM;CACxB,CAAC","sourcesContent":["/**\n * Known Transak API error codes surfaced by {@link TransakApiError}.\n *\n * Values are normalized to strings because TransakService stringifies numeric\n * codes when parsing API responses.\n */\nexport const TRANSAK_ERROR_CODES = {\n ORDER_EXISTS: '4005',\n PHONE_ALREADY_REGISTERED: '2020',\n} as const;\n\nexport type TransakErrorCode =\n (typeof TRANSAK_ERROR_CODES)[keyof typeof TRANSAK_ERROR_CODES];\n"]}
|
|
@@ -78,4 +78,4 @@ export declare function createInitialState(maxAttempts?: number): WalletRegistra
|
|
|
78
78
|
* @returns The next state (or the same state for unhandled events).
|
|
79
79
|
*/
|
|
80
80
|
export declare function transition(state: WalletRegistrationState, event: WalletRegistrationEvent): WalletRegistrationState;
|
|
81
|
-
//# sourceMappingURL=wallet-registration-machine.d.
|
|
81
|
+
//# sourceMappingURL=wallet-registration-machine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-registration-machine.d.ts","sourceRoot":"","sources":["../src/wallet-registration-machine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,uCAAuC;AACvC,MAAM,MAAM,wBAAwB,GAChC,MAAM,GACN,WAAW,GACX,gBAAgB,GAChB,SAAS,GACT,YAAY,GACZ,iBAAiB,GACjB,gBAAgB,GAChB,mBAAmB,GACnB,YAAY,GACZ,mBAAmB,GACnB,oBAAoB,GACpB,iBAAiB,GACjB,gBAAgB,GAChB,WAAW,CAAC;AAEhB,kDAAkD;AAClD,MAAM,MAAM,yBAAy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AgB,UAAU,CACxB,KAAK,EAAE,uBAAuB,EAC9B,KAAK,EAAE,uBAAuB,GAC7B,uBAAuB,CAGzB"}
|
|
@@ -136,4 +136,4 @@ export function transition(state, event) {
|
|
|
136
136
|
const handler = TABLE[state.status]?.[event.type];
|
|
137
137
|
return handler ? handler(state, event) : state;
|
|
138
138
|
}
|
|
139
|
-
//# sourceMappingURL=wallet-registration-machine.
|
|
139
|
+
//# sourceMappingURL=wallet-registration-machine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-registration-machine.js","sourceRoot":"","sources":["../src/wallet-registration-machine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA4DH,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAE/B;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,WAAW,GAAW,oBAAoB;IAE1C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,CAAC;AACnE,CAAC;AAED;;;;;GAKG;AACH,SAAS,IAAI,CAAC,MAAgC;IAC5C,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;AACzD,CAAC;AAED;;;;;;GAMG;AACH,SAAS,KAAK,CAAC,MAAgC;IAC7C,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACjB,MAAM;QACN,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE;KAC3C,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,SAAS,GAAY,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACrC,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,OAAO,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;KACnB;CACF,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CACxB,KAA8B,EAC9B,KAA8B;IAE9B,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClD,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACjD,CAAC","sourcesContent":["/**\n * Pure, hand-rolled finite state machine for the MoonPay Iron self-hosted\n * wallet registration signing step. It follows the FSM convention used\n * elsewhere in `core` (no XState dependency): a single pure `transition`\n * reducer plus a data-driven transition table.\n *\n * Side effects (server lookups, signing, POSTing) live in the interpreter that\n * drives this machine; every effect result is fed back in as an event, so the\n * machine itself stays deterministic and trivially testable.\n */\n\n/** Every state in the signing step. */\nexport type WalletRegistrationStatus =\n | 'idle'\n | 'preparing'\n | 'awaitingUnlock'\n | 'signing'\n | 'submitting'\n | 'disambiguate409'\n | 'checkThenRetry'\n | 'lookupUnavailable'\n | 'registered'\n | 'alreadyRegistered'\n | 'registeredDisabled'\n | 'failedRetryable'\n | 'failedTerminal'\n | 'cancelled';\n\n/** Machine context carried across transitions. */\nexport type WalletRegistrationContext = {\n /** Number of sign attempts made so far (used for the retry ceiling). */\n attempts: number;\n /** Maximum number of sign attempts before a retryable failure is surfaced. */\n maxAttempts: number;\n};\n\nexport type WalletRegistrationState = {\n status: WalletRegistrationStatus;\n context: WalletRegistrationContext;\n};\n\n/** Events the interpreter dispatches into the machine. */\nexport type WalletRegistrationEvent =\n | { type: 'START' }\n | { type: 'WALLET_LOCKED' }\n | { type: 'WALLET_UNLOCKED' }\n | { type: 'LOOKUP_ACTIVE' }\n | { type: 'LOOKUP_DISABLED' }\n | { type: 'LOOKUP_ABSENT' }\n | { type: 'LOOKUP_FAILED' }\n | { type: 'SIGN_OK' }\n | { type: 'SIGN_REJECTED' }\n | { type: 'SIGN_FAILED'; retryable: boolean }\n | { type: 'SUBMIT_OK' }\n | { type: 'SUBMIT_CONFLICT' }\n | { type: 'SUBMIT_TRANSIENT' }\n | { type: 'SUBMIT_VALIDATION'; utcRollover: boolean }\n | { type: 'SUBMIT_TERMINAL' }\n | { type: 'SUBMIT_RATE_LIMITED' }\n | { type: 'RETRY' }\n | { type: 'CANCEL' };\n\ntype EventType = WalletRegistrationEvent['type'];\n\ntype Handler = (\n state: WalletRegistrationState,\n event: WalletRegistrationEvent,\n) => WalletRegistrationState;\n\nconst DEFAULT_MAX_ATTEMPTS = 3;\n\n/**\n * Creates the initial idle state.\n *\n * @param maxAttempts - Optional retry ceiling for sign attempts.\n * @returns A fresh idle machine state.\n */\nexport function createInitialState(\n maxAttempts: number = DEFAULT_MAX_ATTEMPTS,\n): WalletRegistrationState {\n return { status: 'idle', context: { attempts: 0, maxAttempts } };\n}\n\n/**\n * Builds a handler that moves to a status while preserving context.\n *\n * @param status - Target status.\n * @returns A handler transitioning to `status`.\n */\nfunction keep(status: WalletRegistrationStatus): Handler {\n return (state) => ({ status, context: state.context });\n}\n\n/**\n * Builds a handler that moves to a status and resets the retry context. Used\n * when the user (or app resume) starts a fresh attempt from scratch.\n *\n * @param status - Target status.\n * @returns A handler transitioning to `status` with reset context.\n */\nfunction reset(status: WalletRegistrationStatus): Handler {\n return (state) => ({\n status,\n context: { ...state.context, attempts: 0 },\n });\n}\n\n/**\n * Moves to `signing` and counts this as a new sign attempt.\n *\n * @param state - Current state.\n * @returns The `signing` state with an incremented attempt count.\n */\nconst toSigning: Handler = (state) => ({\n status: 'signing',\n context: { ...state.context, attempts: state.context.attempts + 1 },\n});\n\nconst toPreparing = reset('preparing');\nconst toAlreadyRegistered = keep('alreadyRegistered');\nconst toRegisteredDisabled = keep('registeredDisabled');\nconst toLookupUnavailable = keep('lookupUnavailable');\nconst toCancelled = keep('cancelled');\n\nconst signFailed: Handler = (state, event) => {\n const { retryable } = event as Extract<\n WalletRegistrationEvent,\n { type: 'SIGN_FAILED' }\n >;\n return retryable\n ? keep('failedRetryable')(state, event)\n : keep('failedTerminal')(state, event);\n};\n\nconst submitValidation: Handler = (state, event) => {\n const { utcRollover } = event as Extract<\n WalletRegistrationEvent,\n { type: 'SUBMIT_VALIDATION' }\n >;\n return utcRollover && state.context.attempts < state.context.maxAttempts\n ? toSigning(state, event)\n : keep('failedTerminal')(state, event);\n};\n\nconst checkThenRetryAbsent: Handler = (state, event) =>\n state.context.attempts < state.context.maxAttempts\n ? toSigning(state, event)\n : keep('failedRetryable')(state, event);\n\nconst TABLE: Partial<\n Record<WalletRegistrationStatus, Partial<Record<EventType, Handler>>>\n> = {\n idle: {\n START: toPreparing,\n },\n preparing: {\n LOOKUP_ACTIVE: toAlreadyRegistered,\n LOOKUP_DISABLED: toRegisteredDisabled,\n LOOKUP_ABSENT: toSigning,\n LOOKUP_FAILED: toLookupUnavailable,\n },\n awaitingUnlock: {\n WALLET_UNLOCKED: keep('signing'),\n },\n signing: {\n SIGN_OK: keep('submitting'),\n SIGN_REJECTED: toCancelled,\n SIGN_FAILED: signFailed,\n WALLET_LOCKED: keep('awaitingUnlock'),\n CANCEL: toCancelled,\n },\n submitting: {\n SUBMIT_OK: keep('registered'),\n SUBMIT_CONFLICT: keep('disambiguate409'),\n SUBMIT_TRANSIENT: keep('checkThenRetry'),\n SUBMIT_VALIDATION: submitValidation,\n SUBMIT_TERMINAL: keep('failedTerminal'),\n SUBMIT_RATE_LIMITED: keep('failedRetryable'),\n CANCEL: toCancelled,\n },\n disambiguate409: {\n LOOKUP_ACTIVE: toAlreadyRegistered,\n LOOKUP_DISABLED: toRegisteredDisabled,\n LOOKUP_ABSENT: keep('failedRetryable'),\n LOOKUP_FAILED: toLookupUnavailable,\n CANCEL: toCancelled,\n },\n checkThenRetry: {\n LOOKUP_ACTIVE: toAlreadyRegistered,\n LOOKUP_DISABLED: toRegisteredDisabled,\n LOOKUP_ABSENT: checkThenRetryAbsent,\n LOOKUP_FAILED: toLookupUnavailable,\n CANCEL: toCancelled,\n },\n failedRetryable: {\n RETRY: toPreparing,\n },\n lookupUnavailable: {\n RETRY: toPreparing,\n },\n cancelled: {\n RETRY: toPreparing,\n },\n};\n\n/**\n * Pure transition reducer. Unhandled (state, event) pairs are no-ops, which is\n * how the machine enforces \"one in-flight operation\" (a second `START` while\n * busy is ignored) and how terminal states stay put.\n *\n * @param state - Current machine state.\n * @param event - Event to apply.\n * @returns The next state (or the same state for unhandled events).\n */\nexport function transition(\n state: WalletRegistrationState,\n event: WalletRegistrationEvent,\n): WalletRegistrationState {\n const handler = TABLE[state.status]?.[event.type];\n return handler ? handler(state, event) : state;\n}\n"]}
|
|
@@ -141,4 +141,4 @@ export declare class WalletRegistrationService {
|
|
|
141
141
|
registerSelfHostedWallet(request: RegisterSelfHostedWalletRequest): Promise<RegistrationOutcome>;
|
|
142
142
|
}
|
|
143
143
|
export {};
|
|
144
|
-
//# sourceMappingURL=wallet-registration-service.d.
|
|
144
|
+
//# sourceMappingURL=wallet-registration-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-registration-service.d.ts","sourceRoot":"","sources":["../src/wallet-registration-service.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC;AAEjC,kEAAkE;AAClE,MAAM,MAAM,sBAAsB,GAAG;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,kFAAkF;AAClF,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,YAAY,EAAE,sBAAsB,CAAA;CAAE,GACxD;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,YAAY,EAAE,sBAAsB,CAAA;CAAE,GAC1D;IAAE,I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E,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,uCAAuC;AACvC,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,YAAY,CAAC;IACnB,YAAY,EAAE,sBAAsB,CAAC;CACtC,CAAC;AAqCF;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAQ7C;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAoBpD;AAED;;;;GAIG;AACH,qBAAa,yBAAyB;;IASpC,YAAY,OAAO,EAAE,gCAAgC,EAKpD;IAED;;;;;;OAMG;IACG,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,CA0C5C;IAED;;;;;;;;;;OAUG;IACG,qBAAqB,CACzB,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,kBAAkB,CAAC,CAwE7B;IAED;;;;;;;;;;OAUG;IACG,wBAAwB,CAC5B,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,mBAAmB,CAAC,CA6D9B;CA0CF"}
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
|
-
var _WalletRegistrationService_instances, _WalletRegistrationService_fetch, _WalletRegistrationService_baseUrl, _WalletRegistrationService_getAuthToken, _WalletRegistrationService_getExternalId, _WalletRegistrationService_toHttpError, _WalletRegistrationService_toRegistration;
|
|
13
1
|
/** Typed error carrying enough context for state transitions. */
|
|
14
2
|
export class WalletRegistrationError extends Error {
|
|
3
|
+
kind;
|
|
4
|
+
httpStatus;
|
|
5
|
+
body;
|
|
15
6
|
constructor(kind, options) {
|
|
16
7
|
super(options.message ?? `wallet registration failed: ${kind}`);
|
|
17
8
|
this.name = 'WalletRegistrationError';
|
|
@@ -102,16 +93,15 @@ export function extractErrorBody(raw) {
|
|
|
102
93
|
* API key never ships in the client.
|
|
103
94
|
*/
|
|
104
95
|
export class WalletRegistrationService {
|
|
96
|
+
#fetch;
|
|
97
|
+
#baseUrl;
|
|
98
|
+
#getAuthToken;
|
|
99
|
+
#getExternalId;
|
|
105
100
|
constructor(options) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
_WalletRegistrationService_getExternalId.set(this, void 0);
|
|
111
|
-
__classPrivateFieldSet(this, _WalletRegistrationService_fetch, options.fetch, "f");
|
|
112
|
-
__classPrivateFieldSet(this, _WalletRegistrationService_baseUrl, options.baseUrl.replace(/\/$/u, ''), "f");
|
|
113
|
-
__classPrivateFieldSet(this, _WalletRegistrationService_getAuthToken, options.getAuthToken, "f");
|
|
114
|
-
__classPrivateFieldSet(this, _WalletRegistrationService_getExternalId, options.getExternalId, "f");
|
|
101
|
+
this.#fetch = options.fetch;
|
|
102
|
+
this.#baseUrl = options.baseUrl.replace(/\/$/u, '');
|
|
103
|
+
this.#getAuthToken = options.getAuthToken;
|
|
104
|
+
this.#getExternalId = options.getExternalId;
|
|
115
105
|
}
|
|
116
106
|
/**
|
|
117
107
|
* Resolves Iron's internal customer id via
|
|
@@ -122,15 +112,15 @@ export class WalletRegistrationService {
|
|
|
122
112
|
*/
|
|
123
113
|
async getMoonpayCustomerId() {
|
|
124
114
|
const [token, externalId] = await Promise.all([
|
|
125
|
-
|
|
126
|
-
|
|
115
|
+
this.#getAuthToken(),
|
|
116
|
+
this.#getExternalId(),
|
|
127
117
|
]);
|
|
128
118
|
if (!externalId) {
|
|
129
119
|
throw new WalletRegistrationError('malformedResponse', {
|
|
130
120
|
message: 'MetaMask external id (canonical profile id) is empty',
|
|
131
121
|
});
|
|
132
122
|
}
|
|
133
|
-
const response = await
|
|
123
|
+
const response = await this.#fetch(`${this.#baseUrl}/neobank/customers/${encodeURIComponent(externalId)}/external`, {
|
|
134
124
|
method: 'GET',
|
|
135
125
|
headers: {
|
|
136
126
|
accept: 'application/json',
|
|
@@ -138,7 +128,7 @@ export class WalletRegistrationService {
|
|
|
138
128
|
},
|
|
139
129
|
});
|
|
140
130
|
if (!response.ok) {
|
|
141
|
-
throw await
|
|
131
|
+
throw await this.#toHttpError(response);
|
|
142
132
|
}
|
|
143
133
|
let payload;
|
|
144
134
|
try {
|
|
@@ -172,10 +162,10 @@ export class WalletRegistrationService {
|
|
|
172
162
|
const { customerId, address, blockchain } = request;
|
|
173
163
|
let response;
|
|
174
164
|
try {
|
|
175
|
-
const token = await
|
|
176
|
-
const url = new URL(`${
|
|
165
|
+
const token = await this.#getAuthToken();
|
|
166
|
+
const url = new URL(`${this.#baseUrl}/neobank/addresses/crypto/${encodeURIComponent(customerId)}`);
|
|
177
167
|
url.searchParams.set('filter', 'SelfHosted');
|
|
178
|
-
response = await
|
|
168
|
+
response = await this.#fetch(url.toString(), {
|
|
179
169
|
method: 'GET',
|
|
180
170
|
headers: {
|
|
181
171
|
accept: 'application/json',
|
|
@@ -229,7 +219,7 @@ export class WalletRegistrationService {
|
|
|
229
219
|
if (!match) {
|
|
230
220
|
return { type: 'absent' };
|
|
231
221
|
}
|
|
232
|
-
const registration =
|
|
222
|
+
const registration = this.#toRegistration(match);
|
|
233
223
|
return registration.disabled
|
|
234
224
|
? { type: 'disabled', registration }
|
|
235
225
|
: { type: 'active', registration };
|
|
@@ -249,8 +239,8 @@ export class WalletRegistrationService {
|
|
|
249
239
|
const idempotencyKey = request.idempotencyKey ?? createIdempotencyKey();
|
|
250
240
|
let response;
|
|
251
241
|
try {
|
|
252
|
-
const token = await
|
|
253
|
-
response = await
|
|
242
|
+
const token = await this.#getAuthToken();
|
|
243
|
+
response = await this.#fetch(`${this.#baseUrl}/neobank/addresses/crypto/selfhosted`, {
|
|
254
244
|
method: 'POST',
|
|
255
245
|
headers: {
|
|
256
246
|
accept: 'application/json',
|
|
@@ -274,7 +264,7 @@ export class WalletRegistrationService {
|
|
|
274
264
|
});
|
|
275
265
|
}
|
|
276
266
|
if (!response.ok) {
|
|
277
|
-
throw await
|
|
267
|
+
throw await this.#toHttpError(response);
|
|
278
268
|
}
|
|
279
269
|
let payload;
|
|
280
270
|
try {
|
|
@@ -302,43 +292,44 @@ export class WalletRegistrationService {
|
|
|
302
292
|
},
|
|
303
293
|
};
|
|
304
294
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
message: body || undefined,
|
|
324
|
-
});
|
|
325
|
-
}, _WalletRegistrationService_toRegistration = function _WalletRegistrationService_toRegistration(record) {
|
|
326
|
-
if (typeof record.id !== 'string' || record.id.length === 0) {
|
|
327
|
-
throw new WalletRegistrationError('malformedResponse', {
|
|
328
|
-
message: 'registered address missing id',
|
|
295
|
+
async #toHttpError(response) {
|
|
296
|
+
let raw = '';
|
|
297
|
+
try {
|
|
298
|
+
raw = await response.text();
|
|
299
|
+
}
|
|
300
|
+
catch {
|
|
301
|
+
return new WalletRegistrationError('malformedResponse', {
|
|
302
|
+
httpStatus: response.status,
|
|
303
|
+
message: 'error body could not be read',
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
const { status } = response;
|
|
307
|
+
const kind = mapStatusToKind(status);
|
|
308
|
+
const body = extractErrorBody(raw);
|
|
309
|
+
return new WalletRegistrationError(kind, {
|
|
310
|
+
httpStatus: status,
|
|
311
|
+
body,
|
|
312
|
+
message: body || undefined,
|
|
329
313
|
});
|
|
330
314
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
315
|
+
#toRegistration(record) {
|
|
316
|
+
if (typeof record.id !== 'string' || record.id.length === 0) {
|
|
317
|
+
throw new WalletRegistrationError('malformedResponse', {
|
|
318
|
+
message: 'registered address missing id',
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
if (typeof record.wallet_address !== 'string') {
|
|
322
|
+
throw new WalletRegistrationError('malformedResponse', {
|
|
323
|
+
message: 'registered address missing wallet_address',
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
return {
|
|
327
|
+
id: record.id,
|
|
328
|
+
address: record.wallet_address,
|
|
329
|
+
blockchain: 'Monad',
|
|
330
|
+
disabled: Boolean(record.disabled),
|
|
331
|
+
isSelf: Boolean(record.is_self),
|
|
332
|
+
};
|
|
335
333
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
address: record.wallet_address,
|
|
339
|
-
blockchain: 'Monad',
|
|
340
|
-
disabled: Boolean(record.disabled),
|
|
341
|
-
isSelf: Boolean(record.is_self),
|
|
342
|
-
};
|
|
343
|
-
};
|
|
344
|
-
//# sourceMappingURL=wallet-registration-service.mjs.map
|
|
334
|
+
}
|
|
335
|
+
//# sourceMappingURL=wallet-registration-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-registration-service.js","sourceRoot":"","sources":["../src/wallet-registration-service.ts"],"names":[],"mappings":"AAmDA,iEAAiE;AACjE,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACvC,IAAI,CAA8B;IAElC,UAAU,CAAU;IAEpB,IAAI,CAAU;IAEvB,YACE,IAAiC,EACjC,OAIC;QAED,KAAK,CAAC,OAAO,CAAC,OAAO,IAAI,+BAA+B,IAAI,EAAE,CAAC,CAAC;QAChE,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;CACF;AA0CD;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,OAAe;IACvC,OAAO,OAAO,CAAC,WAAW,EAAE,CAAC;AAC/B,CAAC;AAED;;;;;GAKG;AACH,SAAS,eAAe,CAAC,MAAc;IACrC,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,GAAG;YACN,OAAO,YAAY,CAAC;QACtB,KAAK,GAAG;YACN,OAAO,cAAc,CAAC;QACxB,KAAK,GAAG;YACN,OAAO,WAAW,CAAC;QACrB,KAAK,GAAG;YACN,OAAO,UAAU,CAAC;QACpB,KAAK,GAAG;YACN,OAAO,UAAU,CAAC;QACpB,KAAK,GAAG;YACN,OAAO,aAAa,CAAC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AC3B,OAAO,EAAE,8BAA8B;aACxC,CAAC,CAAC;QACL,CAAC;QAED,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC;QAC5B,MAAM,IAAI,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QACrC,MAAM,IAAI,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;QACnC,OAAO,IAAI,uBAAuB,CAAC,IAAI,EAAE;YACvC,UAAU,EAAE,MAAM;YAClB,IAAI;YACJ,OAAO,EAAE,IAAI,IAAI,SAAS;SAC3B,CAAC,CAAC;IACL,CAAC;IAED,eAAe,CAAC,MAA+B;QAC7C,IAAI,OAAO,MAAM,CAAC,EAAE,KAAK,QAAQ,IAAI,MAAM,CAAC,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5D,MAAM,IAAI,uBAAuB,CAAC,mBAAmB,EAAE;gBACrD,OAAO,EAAE,+BAA+B;aACzC,CAAC,CAAC;QACL,CAAC;QACD,IAAI,OAAO,MAAM,CAAC,cAAc,KAAK,QAAQ,EAAE,CAAC;YAC9C,MAAM,IAAI,uBAAuB,CAAC,mBAAmB,EAAE;gBACrD,OAAO,EAAE,2CAA2C;aACrD,CAAC,CAAC;QACL,CAAC;QACD,OAAO;YACL,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,OAAO,EAAE,MAAM,CAAC,cAAc;YAC9B,UAAU,EAAE,OAAO;YACnB,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;YAClC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;SAChC,CAAC;IACJ,CAAC;CACF","sourcesContent":["/** The only blockchain supported by the Money Account POC. */\nexport type Blockchain = 'Monad';\n\n/** Normalized view of a single registered self-hosted address. */\nexport type SelfHostedRegistration = {\n id: string;\n address: string;\n blockchain: Blockchain;\n disabled: boolean;\n isSelf: boolean;\n};\n\n/** Result of reconciling a wallet against the customer's registered addresses. */\nexport type RegistrationStatus =\n | { type: 'active'; registration: SelfHostedRegistration }\n | { type: 'disabled'; registration: SelfHostedRegistration }\n | { type: 'absent' };\n\n/**\n * Discriminated error kinds surfaced to the state machine. Every non-success\n * path maps to exactly one of these so the machine can decide deterministically.\n */\nexport type WalletRegistrationErrorKind =\n | 'validation'\n | 'unauthorized'\n | 'forbidden'\n | 'notFound'\n | 'conflict'\n | 'rateLimited'\n | 'transient'\n | 'lookupUnavailable'\n | 'malformedResponse';\n\n/** Minimal HTTP response shape, so the service is environment-agnostic. */\ntype HttpResponse = {\n ok: boolean;\n status: number;\n json: () => Promise<unknown>;\n text: () => Promise<string>;\n};\n\n/** Minimal `fetch`-like function the service depends on. */\ntype FetchLike = (\n url: string,\n init?: {\n method?: string;\n headers?: Record<string, string>;\n body?: string;\n },\n) => Promise<HttpResponse>;\n\n/** Typed error carrying enough context for state transitions. */\nexport class WalletRegistrationError extends Error {\n readonly kind: WalletRegistrationErrorKind;\n\n readonly httpStatus?: number;\n\n readonly body?: string;\n\n constructor(\n kind: WalletRegistrationErrorKind,\n options: {\n message?: string;\n httpStatus?: number;\n body?: string;\n },\n ) {\n super(options.message ?? `wallet registration failed: ${kind}`);\n this.name = 'WalletRegistrationError';\n this.kind = kind;\n this.httpStatus = options.httpStatus;\n this.body = options.body;\n }\n}\n\nexport type WalletRegistrationServiceOptions = {\n fetch: FetchLike;\n /**\n * Base URL of the Money Movement neobank-proxy host\n * (e.g. `https://on-ramp.dev-api.cx.metamask.io`). Paths are under `/neobank`.\n */\n baseUrl: string;\n getAuthToken: () => Promise<string>;\n /**\n * MetaMask profile / partner external id used as MoonPay `external_id`\n * (typically `AuthenticationController:getSessionProfile().canonicalProfileId`).\n */\n getExternalId: () => Promise<string>;\n};\n\nexport type GetRegistrationStatusRequest = {\n customerId: string;\n address: string;\n blockchain: Blockchain;\n};\n\nexport type RegisterSelfHostedWalletRequest = {\n customerId: string;\n address: string;\n blockchain: Blockchain;\n message: string;\n signature: string;\n /**\n * Stable key reused across retries of the same ownership proof. Generated\n * when omitted.\n */\n idempotencyKey?: string;\n};\n\n/** Successful registration outcome. */\nexport type RegistrationOutcome = {\n type: 'registered';\n registration: SelfHostedRegistration;\n};\n\n/**\n * Normalizes a Monad EVM address for case-insensitive comparison.\n *\n * @param address - Raw address string.\n * @returns The comparison key for the address.\n */\nfunction normalizeAddress(address: string): string {\n return address.toLowerCase();\n}\n\n/**\n * Maps an HTTP status to the typed error kind the state machine reacts to.\n *\n * @param status - HTTP status code from the proxy/Iron response.\n * @returns The corresponding error kind.\n */\nfunction mapStatusToKind(status: number): WalletRegistrationErrorKind {\n switch (status) {\n case 400:\n return 'validation';\n case 401:\n return 'unauthorized';\n case 403:\n return 'forbidden';\n case 404:\n return 'notFound';\n case 409:\n return 'conflict';\n case 429:\n return 'rateLimited';\n default:\n return status >= 500 ? 'transient' : 'validation';\n }\n}\n\n/**\n * Builds a client-side Idempotency-Key for MoonPay POSTs. Prefer a stable\n * caller-supplied key across retries of the same proof.\n *\n * @returns A random UUID when available, otherwise a timestamped fallback.\n */\nexport function createIdempotencyKey(): string {\n const cryptoObj = globalThis.crypto as\n | { randomUUID?: () => string }\n | undefined;\n if (typeof cryptoObj?.randomUUID === 'function') {\n return cryptoObj.randomUUID();\n }\n return `wallet-reg-${Date.now()}-${Math.random().toString(16).slice(2)}`;\n}\n\n/**\n * Extracts a human-readable error body from a transparent neobank-proxy\n * response. Upstream may return a plain string or a JSON value; both are\n * mirrored 1:1 (no `{ code: 'iron_error' }` envelope).\n *\n * @param raw - Raw response text.\n * @returns Normalized body string for {@link WalletRegistrationError}.\n */\nexport function extractErrorBody(raw: string): string {\n const trimmed = raw.trim();\n if (!trimmed) {\n return raw;\n }\n try {\n const parsed: unknown = JSON.parse(trimmed);\n if (typeof parsed === 'string') {\n return parsed;\n }\n if (parsed && typeof parsed === 'object') {\n const { message } = parsed as { message?: unknown };\n if (typeof message === 'string') {\n return message;\n }\n }\n return trimmed;\n } catch {\n return trimmed;\n }\n}\n\n/**\n * Data service that talks to the Money Movement neobank-proxy for MoonPay Iron\n * self-hosted wallet registration. It never calls Iron directly, so the Iron\n * API key never ships in the client.\n */\nexport class WalletRegistrationService {\n readonly #fetch: FetchLike;\n\n readonly #baseUrl: string;\n\n readonly #getAuthToken: () => Promise<string>;\n\n readonly #getExternalId: () => Promise<string>;\n\n constructor(options: WalletRegistrationServiceOptions) {\n this.#fetch = options.fetch;\n this.#baseUrl = options.baseUrl.replace(/\\/$/u, '');\n this.#getAuthToken = options.getAuthToken;\n this.#getExternalId = options.getExternalId;\n }\n\n /**\n * Resolves Iron's internal customer id via\n * `GET /neobank/customers/{external_id}/external`, using the MetaMask\n * profile/canonical id as `external_id`.\n *\n * @returns Iron's internal customer id.\n */\n async getMoonpayCustomerId(): Promise<string> {\n const [token, externalId] = await Promise.all([\n this.#getAuthToken(),\n this.#getExternalId(),\n ]);\n if (!externalId) {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'MetaMask external id (canonical profile id) is empty',\n });\n }\n\n const response = await this.#fetch(\n `${this.#baseUrl}/neobank/customers/${encodeURIComponent(externalId)}/external`,\n {\n method: 'GET',\n headers: {\n accept: 'application/json',\n authorization: `Bearer ${token}`,\n },\n },\n );\n\n if (!response.ok) {\n throw await this.#toHttpError(response);\n }\n\n let payload: unknown;\n try {\n payload = await response.json();\n } catch {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'MoonPay customer body was not valid JSON',\n });\n }\n\n const { id } = payload as { id?: unknown };\n if (typeof id !== 'string' || id.length === 0) {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'MoonPay customer body missing id',\n });\n }\n return id;\n }\n\n /**\n * Reconciles a wallet against the customer's registered self-hosted addresses\n * via `GET /neobank/addresses/crypto/{customer_id}?filter=SelfHosted`.\n * Upstream returns all self-hosted chains; Monad filtering stays client-side\n * for the POC. Transport failures are reported as `lookupUnavailable`;\n * malformed successful responses are reported as `malformedResponse`.\n * Neither is downgraded to `absent`.\n *\n * @param request - Customer id and Monad address to reconcile.\n * @returns The active / disabled / absent status for the address.\n */\n async getRegistrationStatus(\n request: GetRegistrationStatusRequest,\n ): Promise<RegistrationStatus> {\n const { customerId, address, blockchain } = request;\n\n let response: HttpResponse;\n try {\n const token = await this.#getAuthToken();\n const url = new URL(\n `${this.#baseUrl}/neobank/addresses/crypto/${encodeURIComponent(customerId)}`,\n );\n url.searchParams.set('filter', 'SelfHosted');\n response = await this.#fetch(url.toString(), {\n method: 'GET',\n headers: {\n accept: 'application/json',\n authorization: `Bearer ${token}`,\n },\n });\n } catch (error) {\n throw new WalletRegistrationError('lookupUnavailable', {\n message: 'self-hosted address lookup failed',\n body: error instanceof Error ? error.message : undefined,\n });\n }\n\n if (!response.ok) {\n let body: string;\n try {\n body = extractErrorBody(await response.text());\n } catch (error) {\n body = error instanceof Error ? error.message : '';\n }\n throw new WalletRegistrationError('lookupUnavailable', {\n httpStatus: response.status,\n body,\n });\n }\n\n let payload: unknown;\n try {\n payload = await response.json();\n } catch {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'self-hosted address list body was not valid JSON',\n });\n }\n if (!Array.isArray(payload)) {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'expected an array of registered addresses',\n });\n }\n\n const target = normalizeAddress(address);\n const match = payload.find((entry) => {\n const record = entry as Record<string, unknown>;\n const walletAddress = record.wallet_address;\n if (typeof walletAddress !== 'string') {\n return false;\n }\n return (\n normalizeAddress(walletAddress) === target &&\n record.blockchain === blockchain\n );\n }) as Record<string, unknown> | undefined;\n\n if (!match) {\n return { type: 'absent' };\n }\n\n const registration = this.#toRegistration(match);\n return registration.disabled\n ? { type: 'disabled', registration }\n : { type: 'active', registration };\n }\n\n /**\n * Registers a self-hosted wallet through neobank-proxy\n * `POST /neobank/addresses/crypto/selfhosted`. The client supplies\n * `customer_id` and an `Idempotency-Key` (generated when omitted). Every\n * non-2xx response is mapped to a typed error; `409` is deliberately\n * surfaced as an ambiguous `conflict` that the caller must reconcile with a\n * follow-up status lookup.\n *\n * @param request - Customer id, address, blockchain, message, and signature.\n * @returns The registered outcome on success.\n */\n async registerSelfHostedWallet(\n request: RegisterSelfHostedWalletRequest,\n ): Promise<RegistrationOutcome> {\n const idempotencyKey = request.idempotencyKey ?? createIdempotencyKey();\n let response: HttpResponse;\n try {\n const token = await this.#getAuthToken();\n response = await this.#fetch(\n `${this.#baseUrl}/neobank/addresses/crypto/selfhosted`,\n {\n method: 'POST',\n headers: {\n accept: 'application/json',\n 'content-type': 'application/json',\n authorization: `Bearer ${token}`,\n 'Idempotency-Key': idempotencyKey,\n },\n body: JSON.stringify({\n customer_id: request.customerId,\n address: request.address,\n blockchain: request.blockchain,\n message: request.message,\n signature: request.signature,\n }),\n },\n );\n } catch (error) {\n throw new WalletRegistrationError('transient', {\n message: 'self-hosted registration request failed',\n body: error instanceof Error ? error.message : undefined,\n });\n }\n\n if (!response.ok) {\n throw await this.#toHttpError(response);\n }\n\n let payload: unknown;\n try {\n payload = await response.json();\n } catch {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'registration success body was not valid JSON',\n });\n }\n\n const record = payload as Record<string, unknown>;\n if (typeof record.id !== 'string' || typeof record.address !== 'string') {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'registration success body missing id/address',\n });\n }\n\n return {\n type: 'registered',\n registration: {\n id: record.id,\n address: record.address,\n blockchain: request.blockchain,\n disabled: Boolean(record.disabled),\n isSelf: true,\n },\n };\n }\n\n async #toHttpError(response: HttpResponse): Promise<WalletRegistrationError> {\n let raw = '';\n try {\n raw = await response.text();\n } catch {\n return new WalletRegistrationError('malformedResponse', {\n httpStatus: response.status,\n message: 'error body could not be read',\n });\n }\n\n const { status } = response;\n const kind = mapStatusToKind(status);\n const body = extractErrorBody(raw);\n return new WalletRegistrationError(kind, {\n httpStatus: status,\n body,\n message: body || undefined,\n });\n }\n\n #toRegistration(record: Record<string, unknown>): SelfHostedRegistration {\n if (typeof record.id !== 'string' || record.id.length === 0) {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'registered address missing id',\n });\n }\n if (typeof record.wallet_address !== 'string') {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'registered address missing wallet_address',\n });\n }\n return {\n id: record.id,\n address: record.wallet_address,\n blockchain: 'Monad',\n disabled: Boolean(record.disabled),\n isSelf: Boolean(record.is_self),\n };\n }\n}\n"]}
|