@metamask/ramps-controller 20.1.0 → 20.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/dist/NeoBankService-method-action-types.cjs +7 -0
  3. package/dist/NeoBankService-method-action-types.cjs.map +1 -0
  4. package/dist/NeoBankService-method-action-types.d.cts +126 -0
  5. package/dist/NeoBankService-method-action-types.d.cts.map +1 -0
  6. package/dist/NeoBankService-method-action-types.d.mts +126 -0
  7. package/dist/NeoBankService-method-action-types.d.mts.map +1 -0
  8. package/dist/NeoBankService-method-action-types.mjs +6 -0
  9. package/dist/NeoBankService-method-action-types.mjs.map +1 -0
  10. package/dist/NeoBankService.cjs +387 -0
  11. package/dist/NeoBankService.cjs.map +1 -0
  12. package/dist/NeoBankService.d.cts +191 -0
  13. package/dist/NeoBankService.d.cts.map +1 -0
  14. package/dist/NeoBankService.d.mts +191 -0
  15. package/dist/NeoBankService.d.mts.map +1 -0
  16. package/dist/NeoBankService.mjs +379 -0
  17. package/dist/NeoBankService.mjs.map +1 -0
  18. package/dist/RampsController-method-action-types.cjs.map +1 -1
  19. package/dist/RampsController-method-action-types.d.cts +91 -1
  20. package/dist/RampsController-method-action-types.d.cts.map +1 -1
  21. package/dist/RampsController-method-action-types.d.mts +91 -1
  22. package/dist/RampsController-method-action-types.d.mts.map +1 -1
  23. package/dist/RampsController-method-action-types.mjs.map +1 -1
  24. package/dist/RampsController.cjs +372 -2
  25. package/dist/RampsController.cjs.map +1 -1
  26. package/dist/RampsController.d.cts +152 -5
  27. package/dist/RampsController.d.cts.map +1 -1
  28. package/dist/RampsController.d.mts +152 -5
  29. package/dist/RampsController.d.mts.map +1 -1
  30. package/dist/RampsController.mjs +371 -1
  31. package/dist/RampsController.mjs.map +1 -1
  32. package/dist/RampsService.cjs +14 -3
  33. package/dist/RampsService.cjs.map +1 -1
  34. package/dist/RampsService.d.cts +5 -1
  35. package/dist/RampsService.d.cts.map +1 -1
  36. package/dist/RampsService.d.mts +5 -1
  37. package/dist/RampsService.d.mts.map +1 -1
  38. package/dist/RampsService.mjs +14 -3
  39. package/dist/RampsService.mjs.map +1 -1
  40. package/dist/TransakService.cjs +15 -3
  41. package/dist/TransakService.cjs.map +1 -1
  42. package/dist/TransakService.d.cts +3 -1
  43. package/dist/TransakService.d.cts.map +1 -1
  44. package/dist/TransakService.d.mts +3 -1
  45. package/dist/TransakService.d.mts.map +1 -1
  46. package/dist/TransakService.mjs +15 -3
  47. package/dist/TransakService.mjs.map +1 -1
  48. package/dist/autoramp-types.cjs +3 -0
  49. package/dist/autoramp-types.cjs.map +1 -0
  50. package/dist/autoramp-types.d.cts +22 -0
  51. package/dist/autoramp-types.d.cts.map +1 -0
  52. package/dist/autoramp-types.d.mts +22 -0
  53. package/dist/autoramp-types.d.mts.map +1 -0
  54. package/dist/autoramp-types.mjs +2 -0
  55. package/dist/autoramp-types.mjs.map +1 -0
  56. package/dist/autorampAccount.cjs +155 -0
  57. package/dist/autorampAccount.cjs.map +1 -0
  58. package/dist/autorampAccount.d.cts +126 -0
  59. package/dist/autorampAccount.d.cts.map +1 -0
  60. package/dist/autorampAccount.d.mts +126 -0
  61. package/dist/autorampAccount.d.mts.map +1 -0
  62. package/dist/autorampAccount.mjs +147 -0
  63. package/dist/autorampAccount.mjs.map +1 -0
  64. package/dist/client-identity.cjs +28 -0
  65. package/dist/client-identity.cjs.map +1 -0
  66. package/dist/client-identity.d.cts +24 -0
  67. package/dist/client-identity.d.cts.map +1 -0
  68. package/dist/client-identity.d.mts +24 -0
  69. package/dist/client-identity.d.mts.map +1 -0
  70. package/dist/client-identity.mjs +24 -0
  71. package/dist/client-identity.mjs.map +1 -0
  72. package/dist/index.cjs +24 -1
  73. package/dist/index.cjs.map +1 -1
  74. package/dist/index.d.cts +14 -3
  75. package/dist/index.d.cts.map +1 -1
  76. package/dist/index.d.mts +14 -3
  77. package/dist/index.d.mts.map +1 -1
  78. package/dist/index.mjs +6 -1
  79. package/dist/index.mjs.map +1 -1
  80. package/dist/ownership-message.cjs +26 -0
  81. package/dist/ownership-message.cjs.map +1 -0
  82. package/dist/ownership-message.d.cts +22 -0
  83. package/dist/ownership-message.d.cts.map +1 -0
  84. package/dist/ownership-message.d.mts +22 -0
  85. package/dist/ownership-message.d.mts.map +1 -0
  86. package/dist/ownership-message.mjs +22 -0
  87. package/dist/ownership-message.mjs.map +1 -0
  88. package/dist/wallet-registration-machine.cjs +144 -0
  89. package/dist/wallet-registration-machine.cjs.map +1 -0
  90. package/dist/wallet-registration-machine.d.cts +81 -0
  91. package/dist/wallet-registration-machine.d.cts.map +1 -0
  92. package/dist/wallet-registration-machine.d.mts +81 -0
  93. package/dist/wallet-registration-machine.d.mts.map +1 -0
  94. package/dist/wallet-registration-machine.mjs +139 -0
  95. package/dist/wallet-registration-machine.mjs.map +1 -0
  96. package/dist/wallet-registration-service.cjs +351 -0
  97. package/dist/wallet-registration-service.cjs.map +1 -0
  98. package/dist/wallet-registration-service.d.cts +144 -0
  99. package/dist/wallet-registration-service.d.cts.map +1 -0
  100. package/dist/wallet-registration-service.d.mts +144 -0
  101. package/dist/wallet-registration-service.d.mts.map +1 -0
  102. package/dist/wallet-registration-service.mjs +344 -0
  103. package/dist/wallet-registration-service.mjs.map +1 -0
  104. package/package.json +3 -3
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Local + remote models for MoonPay Enterprise autoramp accounts.
3
+ * Separate from {@link RampsOrder}: autoramps are standing routes; orders are payments.
4
+ */
5
+ import type { AutorampDepositRailsSummary, AutorampRemoteSnapshot } from "./autoramp-types.cjs";
6
+ export type { AutorampDepositRailsSummary, AutorampRemoteSnapshot, } from "./autoramp-types.cjs";
7
+ /**
8
+ * Autoramp lifecycle statuses from MoonPay Enterprise.
9
+ *
10
+ * @see https://dev.enterprise.moonpay.com/autoramp-status
11
+ */
12
+ export declare enum AutorampStatus {
13
+ Created = "Created",
14
+ Authorized = "Authorized",
15
+ EditPending = "EditPending",
16
+ DepositAccountAdded = "DepositAccountAdded",
17
+ Approved = "Approved",
18
+ Rejected = "Rejected",
19
+ Cancelled = "Cancelled"
20
+ }
21
+ /**
22
+ * Local controller representation of an autoramp account.
23
+ */
24
+ export type AutorampAccount = {
25
+ /** MoonPay autoramp id. */
26
+ id: string;
27
+ /** MoonPay customer id. */
28
+ customerId: string;
29
+ /** Destination wallet address associated with this autoramp. */
30
+ walletAddress: string;
31
+ /** Latest status from MoonPay (source of truth after refresh). */
32
+ status: AutorampStatus;
33
+ /**
34
+ * Status observed before the most recent remote apply.
35
+ * Used for transition UX / analytics (e.g. Authorized → Approved).
36
+ */
37
+ lastSeenStatus: AutorampStatus;
38
+ /**
39
+ * Last status for which the UI already showed a notification.
40
+ * Prevents duplicate toasts across refresh and push.
41
+ */
42
+ notifiedForStatus?: AutorampStatus;
43
+ /** Epoch ms of the last local update from remote or push. */
44
+ updatedAt: number;
45
+ /** Optional non-PII deposit readiness cache. */
46
+ depositRailsSummary?: AutorampDepositRailsSummary;
47
+ };
48
+ /**
49
+ * Controller-facing payload for creating an autoramp.
50
+ *
51
+ * Mirrors the MoonPay `POST /api/autoramps` body that
52
+ * {@link NeoBankService.createAutoramp} forwards opaquely, minus `customer_id`:
53
+ * `RampsController.createAutoramp` injects the vendor customer id resolved from
54
+ * Profile Sync, so callers never supply (or need to know) it.
55
+ */
56
+ export type CreateAutorampRequest = Record<string, unknown>;
57
+ /**
58
+ * Result of applying a remote autoramp snapshot onto local state.
59
+ */
60
+ export type ApplyAutorampRemoteStatusResult = {
61
+ account: AutorampAccount;
62
+ previousStatus: AutorampStatus;
63
+ statusChanged: boolean;
64
+ /** True when status changed and UI has not yet notified for the new status. */
65
+ shouldNotify: boolean;
66
+ };
67
+ /**
68
+ * Terminal autoramp statuses — no further lifecycle progress expected.
69
+ */
70
+ export declare const TERMINAL_AUTORAMP_STATUSES: ReadonlySet<AutorampStatus>;
71
+ /**
72
+ * Statuses that commonly warrant user-visible transition UX (toast / banner).
73
+ */
74
+ export declare const NOTABLE_AUTORAMP_STATUSES: ReadonlySet<AutorampStatus>;
75
+ /**
76
+ * Whether an autoramp status is terminal.
77
+ *
78
+ * @param status - Status to test.
79
+ * @returns Whether the status is terminal.
80
+ */
81
+ export declare function isTerminalAutorampStatus(status: AutorampStatus): boolean;
82
+ /**
83
+ * Normalize a remote status string into {@link AutorampStatus}.
84
+ * Unknown values fall back to {@link AutorampStatus.Created}.
85
+ *
86
+ * @param status - Remote status string.
87
+ * @returns A known {@link AutorampStatus}.
88
+ */
89
+ export declare function normalizeAutorampStatus(status: AutorampStatus | string): AutorampStatus;
90
+ /**
91
+ * Build a new local autoramp account from create/response fields.
92
+ *
93
+ * @param input - Required identity + status fields.
94
+ * @param input.id - MoonPay autoramp id.
95
+ * @param input.customerId - MoonPay customer id.
96
+ * @param input.walletAddress - Destination wallet address.
97
+ * @param input.status - Optional remote status (defaults to Authorized).
98
+ * @param input.depositRailsSummary - Optional non-PII deposit readiness cache.
99
+ * @param input.updatedAt - Optional epoch ms timestamp (defaults to now).
100
+ * @returns A new {@link AutorampAccount}.
101
+ */
102
+ export declare function createAutorampAccount(input: {
103
+ id: string;
104
+ customerId: string;
105
+ walletAddress: string;
106
+ status?: AutorampStatus | string;
107
+ depositRailsSummary?: AutorampDepositRailsSummary;
108
+ updatedAt?: number;
109
+ }): AutorampAccount;
110
+ /**
111
+ * Apply a remote autoramp snapshot onto a local account for transition detection.
112
+ * Pure helper — shared by refresh-on-load and websocket push paths.
113
+ *
114
+ * @param local - Current local account (or null when first upserting from remote).
115
+ * @param remote - Remote snapshot (MoonPay GET or push).
116
+ * @returns Updated account plus change / notify flags.
117
+ */
118
+ export declare function applyAutorampRemoteStatus(local: AutorampAccount | null, remote: AutorampRemoteSnapshot): ApplyAutorampRemoteStatusResult;
119
+ /**
120
+ * Mark that the UI has notified for the account's current status.
121
+ *
122
+ * @param account - Account to update.
123
+ * @returns Account with `notifiedForStatus` set to current status.
124
+ */
125
+ export declare function markAutorampNotified(account: AutorampAccount): AutorampAccount;
126
+ //# sourceMappingURL=autorampAccount.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autorampAccount.d.cts","sourceRoot":"","sources":["../src/autorampAccount.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,2BAA2B,EAC3B,sBAAsB,EACvB,6BAA4B;AAE7B,YAAY,EACV,2BAA2B,EAC3B,sBAAsB,GACvB,6BAA4B;AAE7B;;;;GAIG;AACH,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,WAAW,gBAAgB;IAC3B,mBAAmB,wBAAwB;IAC3C,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,SAAS,cAAc;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,2BAA2B;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,aAAa,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,MAAM,EAAE,cAAc,CAAC;IACvB;;;OAGG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,cAAc,CAAC;IACnC,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,mBAAmB,CAAC,EAAE,2BAA2B,CAAC;CACnD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,OAAO,EAAE,eAAe,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;IAC/B,aAAa,EAAE,OAAO,CAAC;IACvB,+EAA+E;IAC/E,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,WAAW,CAAC,cAAc,CAGjE,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,WAAW,CAAC,cAAc,CAIhE,CAAC;AAEH;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAExE;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,cAAc,GAAG,MAAM,GAC9B,cAAc,CAKhB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IACjC,mBAAmB,CAAC,EAAE,2BAA2B,CAAC;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,eAAe,CAalB;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,eAAe,GAAG,IAAI,EAC7B,MAAM,EAAE,sBAAsB,GAC7B,+BAA+B,CAqDjC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,eAAe,GACvB,eAAe,CAKjB"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Local + remote models for MoonPay Enterprise autoramp accounts.
3
+ * Separate from {@link RampsOrder}: autoramps are standing routes; orders are payments.
4
+ */
5
+ import type { AutorampDepositRailsSummary, AutorampRemoteSnapshot } from "./autoramp-types.mjs";
6
+ export type { AutorampDepositRailsSummary, AutorampRemoteSnapshot, } from "./autoramp-types.mjs";
7
+ /**
8
+ * Autoramp lifecycle statuses from MoonPay Enterprise.
9
+ *
10
+ * @see https://dev.enterprise.moonpay.com/autoramp-status
11
+ */
12
+ export declare enum AutorampStatus {
13
+ Created = "Created",
14
+ Authorized = "Authorized",
15
+ EditPending = "EditPending",
16
+ DepositAccountAdded = "DepositAccountAdded",
17
+ Approved = "Approved",
18
+ Rejected = "Rejected",
19
+ Cancelled = "Cancelled"
20
+ }
21
+ /**
22
+ * Local controller representation of an autoramp account.
23
+ */
24
+ export type AutorampAccount = {
25
+ /** MoonPay autoramp id. */
26
+ id: string;
27
+ /** MoonPay customer id. */
28
+ customerId: string;
29
+ /** Destination wallet address associated with this autoramp. */
30
+ walletAddress: string;
31
+ /** Latest status from MoonPay (source of truth after refresh). */
32
+ status: AutorampStatus;
33
+ /**
34
+ * Status observed before the most recent remote apply.
35
+ * Used for transition UX / analytics (e.g. Authorized → Approved).
36
+ */
37
+ lastSeenStatus: AutorampStatus;
38
+ /**
39
+ * Last status for which the UI already showed a notification.
40
+ * Prevents duplicate toasts across refresh and push.
41
+ */
42
+ notifiedForStatus?: AutorampStatus;
43
+ /** Epoch ms of the last local update from remote or push. */
44
+ updatedAt: number;
45
+ /** Optional non-PII deposit readiness cache. */
46
+ depositRailsSummary?: AutorampDepositRailsSummary;
47
+ };
48
+ /**
49
+ * Controller-facing payload for creating an autoramp.
50
+ *
51
+ * Mirrors the MoonPay `POST /api/autoramps` body that
52
+ * {@link NeoBankService.createAutoramp} forwards opaquely, minus `customer_id`:
53
+ * `RampsController.createAutoramp` injects the vendor customer id resolved from
54
+ * Profile Sync, so callers never supply (or need to know) it.
55
+ */
56
+ export type CreateAutorampRequest = Record<string, unknown>;
57
+ /**
58
+ * Result of applying a remote autoramp snapshot onto local state.
59
+ */
60
+ export type ApplyAutorampRemoteStatusResult = {
61
+ account: AutorampAccount;
62
+ previousStatus: AutorampStatus;
63
+ statusChanged: boolean;
64
+ /** True when status changed and UI has not yet notified for the new status. */
65
+ shouldNotify: boolean;
66
+ };
67
+ /**
68
+ * Terminal autoramp statuses — no further lifecycle progress expected.
69
+ */
70
+ export declare const TERMINAL_AUTORAMP_STATUSES: ReadonlySet<AutorampStatus>;
71
+ /**
72
+ * Statuses that commonly warrant user-visible transition UX (toast / banner).
73
+ */
74
+ export declare const NOTABLE_AUTORAMP_STATUSES: ReadonlySet<AutorampStatus>;
75
+ /**
76
+ * Whether an autoramp status is terminal.
77
+ *
78
+ * @param status - Status to test.
79
+ * @returns Whether the status is terminal.
80
+ */
81
+ export declare function isTerminalAutorampStatus(status: AutorampStatus): boolean;
82
+ /**
83
+ * Normalize a remote status string into {@link AutorampStatus}.
84
+ * Unknown values fall back to {@link AutorampStatus.Created}.
85
+ *
86
+ * @param status - Remote status string.
87
+ * @returns A known {@link AutorampStatus}.
88
+ */
89
+ export declare function normalizeAutorampStatus(status: AutorampStatus | string): AutorampStatus;
90
+ /**
91
+ * Build a new local autoramp account from create/response fields.
92
+ *
93
+ * @param input - Required identity + status fields.
94
+ * @param input.id - MoonPay autoramp id.
95
+ * @param input.customerId - MoonPay customer id.
96
+ * @param input.walletAddress - Destination wallet address.
97
+ * @param input.status - Optional remote status (defaults to Authorized).
98
+ * @param input.depositRailsSummary - Optional non-PII deposit readiness cache.
99
+ * @param input.updatedAt - Optional epoch ms timestamp (defaults to now).
100
+ * @returns A new {@link AutorampAccount}.
101
+ */
102
+ export declare function createAutorampAccount(input: {
103
+ id: string;
104
+ customerId: string;
105
+ walletAddress: string;
106
+ status?: AutorampStatus | string;
107
+ depositRailsSummary?: AutorampDepositRailsSummary;
108
+ updatedAt?: number;
109
+ }): AutorampAccount;
110
+ /**
111
+ * Apply a remote autoramp snapshot onto a local account for transition detection.
112
+ * Pure helper — shared by refresh-on-load and websocket push paths.
113
+ *
114
+ * @param local - Current local account (or null when first upserting from remote).
115
+ * @param remote - Remote snapshot (MoonPay GET or push).
116
+ * @returns Updated account plus change / notify flags.
117
+ */
118
+ export declare function applyAutorampRemoteStatus(local: AutorampAccount | null, remote: AutorampRemoteSnapshot): ApplyAutorampRemoteStatusResult;
119
+ /**
120
+ * Mark that the UI has notified for the account's current status.
121
+ *
122
+ * @param account - Account to update.
123
+ * @returns Account with `notifiedForStatus` set to current status.
124
+ */
125
+ export declare function markAutorampNotified(account: AutorampAccount): AutorampAccount;
126
+ //# sourceMappingURL=autorampAccount.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autorampAccount.d.mts","sourceRoot":"","sources":["../src/autorampAccount.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,2BAA2B,EAC3B,sBAAsB,EACvB,6BAA4B;AAE7B,YAAY,EACV,2BAA2B,EAC3B,sBAAsB,GACvB,6BAA4B;AAE7B;;;;GAIG;AACH,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,WAAW,gBAAgB;IAC3B,mBAAmB,wBAAwB;IAC3C,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,SAAS,cAAc;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,2BAA2B;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,aAAa,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,MAAM,EAAE,cAAc,CAAC;IACvB;;;OAGG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,cAAc,CAAC;IACnC,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,mBAAmB,CAAC,EAAE,2BAA2B,CAAC;CACnD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,OAAO,EAAE,eAAe,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;IAC/B,aAAa,EAAE,OAAO,CAAC;IACvB,+EAA+E;IAC/E,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,WAAW,CAAC,cAAc,CAGjE,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,WAAW,CAAC,cAAc,CAIhE,CAAC;AAEH;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAExE;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,cAAc,GAAG,MAAM,GAC9B,cAAc,CAKhB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IACjC,mBAAmB,CAAC,EAAE,2BAA2B,CAAC;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,eAAe,CAalB;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,eAAe,GAAG,IAAI,EAC7B,MAAM,EAAE,sBAAsB,GAC7B,+BAA+B,CAqDjC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,eAAe,GACvB,eAAe,CAKjB"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Local + remote models for MoonPay Enterprise autoramp accounts.
3
+ * Separate from {@link RampsOrder}: autoramps are standing routes; orders are payments.
4
+ */
5
+ /**
6
+ * Autoramp lifecycle statuses from MoonPay Enterprise.
7
+ *
8
+ * @see https://dev.enterprise.moonpay.com/autoramp-status
9
+ */
10
+ export var AutorampStatus;
11
+ (function (AutorampStatus) {
12
+ AutorampStatus["Created"] = "Created";
13
+ AutorampStatus["Authorized"] = "Authorized";
14
+ AutorampStatus["EditPending"] = "EditPending";
15
+ AutorampStatus["DepositAccountAdded"] = "DepositAccountAdded";
16
+ AutorampStatus["Approved"] = "Approved";
17
+ AutorampStatus["Rejected"] = "Rejected";
18
+ AutorampStatus["Cancelled"] = "Cancelled";
19
+ })(AutorampStatus || (AutorampStatus = {}));
20
+ /**
21
+ * Terminal autoramp statuses — no further lifecycle progress expected.
22
+ */
23
+ export const TERMINAL_AUTORAMP_STATUSES = new Set([
24
+ AutorampStatus.Rejected,
25
+ AutorampStatus.Cancelled,
26
+ ]);
27
+ /**
28
+ * Statuses that commonly warrant user-visible transition UX (toast / banner).
29
+ */
30
+ export const NOTABLE_AUTORAMP_STATUSES = new Set([
31
+ AutorampStatus.Approved,
32
+ AutorampStatus.Rejected,
33
+ AutorampStatus.Cancelled,
34
+ ]);
35
+ /**
36
+ * Whether an autoramp status is terminal.
37
+ *
38
+ * @param status - Status to test.
39
+ * @returns Whether the status is terminal.
40
+ */
41
+ export function isTerminalAutorampStatus(status) {
42
+ return TERMINAL_AUTORAMP_STATUSES.has(status);
43
+ }
44
+ /**
45
+ * Normalize a remote status string into {@link AutorampStatus}.
46
+ * Unknown values fall back to {@link AutorampStatus.Created}.
47
+ *
48
+ * @param status - Remote status string.
49
+ * @returns A known {@link AutorampStatus}.
50
+ */
51
+ export function normalizeAutorampStatus(status) {
52
+ if (Object.values(AutorampStatus).includes(status)) {
53
+ return status;
54
+ }
55
+ return AutorampStatus.Created;
56
+ }
57
+ /**
58
+ * Build a new local autoramp account from create/response fields.
59
+ *
60
+ * @param input - Required identity + status fields.
61
+ * @param input.id - MoonPay autoramp id.
62
+ * @param input.customerId - MoonPay customer id.
63
+ * @param input.walletAddress - Destination wallet address.
64
+ * @param input.status - Optional remote status (defaults to Authorized).
65
+ * @param input.depositRailsSummary - Optional non-PII deposit readiness cache.
66
+ * @param input.updatedAt - Optional epoch ms timestamp (defaults to now).
67
+ * @returns A new {@link AutorampAccount}.
68
+ */
69
+ export function createAutorampAccount(input) {
70
+ const status = normalizeAutorampStatus(input.status ?? AutorampStatus.Authorized);
71
+ return {
72
+ id: input.id,
73
+ customerId: input.customerId,
74
+ walletAddress: input.walletAddress,
75
+ status,
76
+ lastSeenStatus: status,
77
+ updatedAt: input.updatedAt ?? Date.now(),
78
+ depositRailsSummary: input.depositRailsSummary,
79
+ };
80
+ }
81
+ /**
82
+ * Apply a remote autoramp snapshot onto a local account for transition detection.
83
+ * Pure helper — shared by refresh-on-load and websocket push paths.
84
+ *
85
+ * @param local - Current local account (or null when first upserting from remote).
86
+ * @param remote - Remote snapshot (MoonPay GET or push).
87
+ * @returns Updated account plus change / notify flags.
88
+ */
89
+ export function applyAutorampRemoteStatus(local, remote) {
90
+ const remoteStatus = normalizeAutorampStatus(remote.status);
91
+ if (!local) {
92
+ const account = createAutorampAccount({
93
+ id: remote.id,
94
+ customerId: remote.customerId ?? '',
95
+ walletAddress: remote.walletAddress ?? '',
96
+ status: remoteStatus,
97
+ depositRailsSummary: remote.depositRailsSummary,
98
+ });
99
+ return {
100
+ account,
101
+ previousStatus: remoteStatus,
102
+ statusChanged: false,
103
+ shouldNotify: false,
104
+ };
105
+ }
106
+ const previousStatus = local.status;
107
+ const statusChanged = previousStatus !== remoteStatus;
108
+ const shouldNotify = statusChanged &&
109
+ local.notifiedForStatus !== remoteStatus &&
110
+ NOTABLE_AUTORAMP_STATUSES.has(remoteStatus);
111
+ const account = {
112
+ ...local,
113
+ id: remote.id,
114
+ // A blank remote identity field means "not supplied", not "cleared": the
115
+ // proxy omits or empties these on partial status pushes, so keep the local
116
+ // value rather than wiping it.
117
+ customerId: remote.customerId !== undefined && remote.customerId.length > 0
118
+ ? remote.customerId
119
+ : local.customerId,
120
+ walletAddress: remote.walletAddress !== undefined && remote.walletAddress.length > 0
121
+ ? remote.walletAddress
122
+ : local.walletAddress,
123
+ status: remoteStatus,
124
+ lastSeenStatus: previousStatus,
125
+ updatedAt: Date.now(),
126
+ depositRailsSummary: remote.depositRailsSummary ?? local.depositRailsSummary,
127
+ };
128
+ return {
129
+ account,
130
+ previousStatus,
131
+ statusChanged,
132
+ shouldNotify,
133
+ };
134
+ }
135
+ /**
136
+ * Mark that the UI has notified for the account's current status.
137
+ *
138
+ * @param account - Account to update.
139
+ * @returns Account with `notifiedForStatus` set to current status.
140
+ */
141
+ export function markAutorampNotified(account) {
142
+ return {
143
+ ...account,
144
+ notifiedForStatus: account.status,
145
+ };
146
+ }
147
+ //# sourceMappingURL=autorampAccount.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autorampAccount.mjs","sourceRoot":"","sources":["../src/autorampAccount.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * Local + remote models for MoonPay Enterprise autoramp accounts.\n * Separate from {@link RampsOrder}: autoramps are standing routes; orders are payments.\n */\n\nimport type {\n AutorampDepositRailsSummary,\n AutorampRemoteSnapshot,\n} from './autoramp-types.js';\n\nexport type {\n AutorampDepositRailsSummary,\n AutorampRemoteSnapshot,\n} from './autoramp-types.js';\n\n/**\n * Autoramp lifecycle statuses from MoonPay Enterprise.\n *\n * @see https://dev.enterprise.moonpay.com/autoramp-status\n */\nexport enum AutorampStatus {\n Created = 'Created',\n Authorized = 'Authorized',\n EditPending = 'EditPending',\n DepositAccountAdded = 'DepositAccountAdded',\n Approved = 'Approved',\n Rejected = 'Rejected',\n Cancelled = 'Cancelled',\n}\n\n/**\n * Local controller representation of an autoramp account.\n */\nexport type AutorampAccount = {\n /** MoonPay autoramp id. */\n id: string;\n /** MoonPay customer id. */\n customerId: string;\n /** Destination wallet address associated with this autoramp. */\n walletAddress: string;\n /** Latest status from MoonPay (source of truth after refresh). */\n status: AutorampStatus;\n /**\n * Status observed before the most recent remote apply.\n * Used for transition UX / analytics (e.g. Authorized → Approved).\n */\n lastSeenStatus: AutorampStatus;\n /**\n * Last status for which the UI already showed a notification.\n * Prevents duplicate toasts across refresh and push.\n */\n notifiedForStatus?: AutorampStatus;\n /** Epoch ms of the last local update from remote or push. */\n updatedAt: number;\n /** Optional non-PII deposit readiness cache. */\n depositRailsSummary?: AutorampDepositRailsSummary;\n};\n\n/**\n * Controller-facing payload for creating an autoramp.\n *\n * Mirrors the MoonPay `POST /api/autoramps` body that\n * {@link NeoBankService.createAutoramp} forwards opaquely, minus `customer_id`:\n * `RampsController.createAutoramp` injects the vendor customer id resolved from\n * Profile Sync, so callers never supply (or need to know) it.\n */\nexport type CreateAutorampRequest = Record<string, unknown>;\n\n/**\n * Result of applying a remote autoramp snapshot onto local state.\n */\nexport type ApplyAutorampRemoteStatusResult = {\n account: AutorampAccount;\n previousStatus: AutorampStatus;\n statusChanged: boolean;\n /** True when status changed and UI has not yet notified for the new status. */\n shouldNotify: boolean;\n};\n\n/**\n * Terminal autoramp statuses — no further lifecycle progress expected.\n */\nexport const TERMINAL_AUTORAMP_STATUSES: ReadonlySet<AutorampStatus> = new Set([\n AutorampStatus.Rejected,\n AutorampStatus.Cancelled,\n]);\n\n/**\n * Statuses that commonly warrant user-visible transition UX (toast / banner).\n */\nexport const NOTABLE_AUTORAMP_STATUSES: ReadonlySet<AutorampStatus> = new Set([\n AutorampStatus.Approved,\n AutorampStatus.Rejected,\n AutorampStatus.Cancelled,\n]);\n\n/**\n * Whether an autoramp status is terminal.\n *\n * @param status - Status to test.\n * @returns Whether the status is terminal.\n */\nexport function isTerminalAutorampStatus(status: AutorampStatus): boolean {\n return TERMINAL_AUTORAMP_STATUSES.has(status);\n}\n\n/**\n * Normalize a remote status string into {@link AutorampStatus}.\n * Unknown values fall back to {@link AutorampStatus.Created}.\n *\n * @param status - Remote status string.\n * @returns A known {@link AutorampStatus}.\n */\nexport function normalizeAutorampStatus(\n status: AutorampStatus | string,\n): AutorampStatus {\n if (Object.values(AutorampStatus).includes(status as AutorampStatus)) {\n return status as AutorampStatus;\n }\n return AutorampStatus.Created;\n}\n\n/**\n * Build a new local autoramp account from create/response fields.\n *\n * @param input - Required identity + status fields.\n * @param input.id - MoonPay autoramp id.\n * @param input.customerId - MoonPay customer id.\n * @param input.walletAddress - Destination wallet address.\n * @param input.status - Optional remote status (defaults to Authorized).\n * @param input.depositRailsSummary - Optional non-PII deposit readiness cache.\n * @param input.updatedAt - Optional epoch ms timestamp (defaults to now).\n * @returns A new {@link AutorampAccount}.\n */\nexport function createAutorampAccount(input: {\n id: string;\n customerId: string;\n walletAddress: string;\n status?: AutorampStatus | string;\n depositRailsSummary?: AutorampDepositRailsSummary;\n updatedAt?: number;\n}): AutorampAccount {\n const status = normalizeAutorampStatus(\n input.status ?? AutorampStatus.Authorized,\n );\n return {\n id: input.id,\n customerId: input.customerId,\n walletAddress: input.walletAddress,\n status,\n lastSeenStatus: status,\n updatedAt: input.updatedAt ?? Date.now(),\n depositRailsSummary: input.depositRailsSummary,\n };\n}\n\n/**\n * Apply a remote autoramp snapshot onto a local account for transition detection.\n * Pure helper — shared by refresh-on-load and websocket push paths.\n *\n * @param local - Current local account (or null when first upserting from remote).\n * @param remote - Remote snapshot (MoonPay GET or push).\n * @returns Updated account plus change / notify flags.\n */\nexport function applyAutorampRemoteStatus(\n local: AutorampAccount | null,\n remote: AutorampRemoteSnapshot,\n): ApplyAutorampRemoteStatusResult {\n const remoteStatus = normalizeAutorampStatus(remote.status);\n\n if (!local) {\n const account = createAutorampAccount({\n id: remote.id,\n customerId: remote.customerId ?? '',\n walletAddress: remote.walletAddress ?? '',\n status: remoteStatus,\n depositRailsSummary: remote.depositRailsSummary,\n });\n return {\n account,\n previousStatus: remoteStatus,\n statusChanged: false,\n shouldNotify: false,\n };\n }\n\n const previousStatus = local.status;\n const statusChanged = previousStatus !== remoteStatus;\n const shouldNotify =\n statusChanged &&\n local.notifiedForStatus !== remoteStatus &&\n NOTABLE_AUTORAMP_STATUSES.has(remoteStatus);\n\n const account: AutorampAccount = {\n ...local,\n id: remote.id,\n // A blank remote identity field means \"not supplied\", not \"cleared\": the\n // proxy omits or empties these on partial status pushes, so keep the local\n // value rather than wiping it.\n customerId:\n remote.customerId !== undefined && remote.customerId.length > 0\n ? remote.customerId\n : local.customerId,\n walletAddress:\n remote.walletAddress !== undefined && remote.walletAddress.length > 0\n ? remote.walletAddress\n : local.walletAddress,\n status: remoteStatus,\n lastSeenStatus: previousStatus,\n updatedAt: Date.now(),\n depositRailsSummary:\n remote.depositRailsSummary ?? local.depositRailsSummary,\n };\n\n return {\n account,\n previousStatus,\n statusChanged,\n shouldNotify,\n };\n}\n\n/**\n * Mark that the UI has notified for the account's current status.\n *\n * @param account - Account to update.\n * @returns Account with `notifiedForStatus` set to current status.\n */\nexport function markAutorampNotified(\n account: AutorampAccount,\n): AutorampAccount {\n return {\n ...account,\n notifiedForStatus: account.status,\n };\n}\n"]}
@@ -0,0 +1,28 @@
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
@@ -0,0 +1 @@
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"]}
@@ -0,0 +1,24 @@
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.cts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,24 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Query-param names for the client identity, sent on every on-ramp API
3
+ * request. Identity travels in the URL (not headers) because the on-ramp CDN
4
+ * cache key is the URL — the API's version-gated feature flags evaluate these
5
+ * params so cached responses always match the requesting cohort.
6
+ */
7
+ export const RAMPS_CLIENT_PRODUCT_PARAM = 'clientProduct';
8
+ export const RAMPS_CLIENT_VERSION_PARAM = 'clientVersion';
9
+ /**
10
+ * Appends the identity as query params (CDN cache-key friendly), omitting
11
+ * empty values. See {@link RAMPS_CLIENT_PRODUCT_PARAM}.
12
+ *
13
+ * @param url - URL to mutate.
14
+ * @param identity - Optional product and version.
15
+ */
16
+ export function addRampsClientIdentityParams(url, identity) {
17
+ if (identity.clientProduct) {
18
+ url.searchParams.set(RAMPS_CLIENT_PRODUCT_PARAM, identity.clientProduct);
19
+ }
20
+ if (identity.clientVersion) {
21
+ url.searchParams.set(RAMPS_CLIENT_VERSION_PARAM, identity.clientVersion);
22
+ }
23
+ }
24
+ //# sourceMappingURL=client-identity.mjs.map
@@ -0,0 +1 @@
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"]}
package/dist/index.cjs CHANGED
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isTransakPhoneRegisteredError = exports.getTransakApiMessage = exports.TransakOrderIdTransformer = exports.TransakEnvironment = exports.TransakService = exports.TransakApiError = exports.normalizeToTypedError = exports.extractExplicitTypedError = exports.getErrorMessage = exports.isTerminalOrderStatus = exports.TERMINAL_ORDER_STATUSES = exports.isInAppOnlyQuote = exports.isCustomActionQuote = exports.isExternalBrowserQuote = exports.isFiatDepositAvailable = exports.regionHasProviderForAsset = exports.getProvidersServingAsset = exports.providerServesAsset = exports.normalizeRampsAssetId = exports.isHeadlessAllProvidersEnabled = exports.getHeadlessProviderAllowlist = exports.MONEY_HEADLESS_ALL_PROVIDERS_FLAG_KEY = exports.HEADLESS_ALL_PROVIDERS_FEATURE_VERSION = exports.createRequestSelector = exports.RAMPS_ERROR_CODES = exports.createErrorState = exports.createSuccessState = exports.createLoadingState = exports.isCacheExpired = exports.createCacheKey = exports.DEFAULT_REQUEST_CACHE_MAX_SIZE = exports.DEFAULT_REQUEST_CACHE_TTL = exports.RequestStatus = exports.getDefaultRedirectCallbackUrl = exports.RAMPS_SDK_VERSION = exports.RampsOrderStatus = exports.RampsApiService = exports.RampsEnvironment = exports.RampsService = exports.RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS = exports.getInternalOrderCode = exports.getDefaultRampsControllerState = exports.RampsController = void 0;
3
+ exports.NOTABLE_AUTORAMP_STATUSES = exports.TERMINAL_AUTORAMP_STATUSES = exports.AutorampStatus = exports.isTransakPhoneRegisteredError = exports.getTransakApiMessage = exports.TransakOrderIdTransformer = exports.TransakEnvironment = exports.TransakService = exports.TransakApiError = exports.normalizeToTypedError = exports.extractExplicitTypedError = exports.getErrorMessage = exports.isTerminalOrderStatus = exports.TERMINAL_ORDER_STATUSES = exports.isInAppOnlyQuote = exports.isCustomActionQuote = exports.isExternalBrowserQuote = exports.isFiatDepositAvailable = exports.regionHasProviderForAsset = exports.getProvidersServingAsset = exports.providerServesAsset = exports.normalizeRampsAssetId = exports.isHeadlessAllProvidersEnabled = exports.getHeadlessProviderAllowlist = exports.MONEY_HEADLESS_ALL_PROVIDERS_FLAG_KEY = exports.HEADLESS_ALL_PROVIDERS_FEATURE_VERSION = exports.createRequestSelector = exports.RAMPS_ERROR_CODES = exports.createErrorState = exports.createSuccessState = exports.createLoadingState = exports.isCacheExpired = exports.createCacheKey = exports.DEFAULT_REQUEST_CACHE_MAX_SIZE = exports.DEFAULT_REQUEST_CACHE_TTL = exports.RequestStatus = exports.RAMPS_CLIENT_VERSION_PARAM = exports.RAMPS_CLIENT_PRODUCT_PARAM = exports.addRampsClientIdentityParams = exports.getDefaultRedirectCallbackUrl = exports.RAMPS_SDK_VERSION = exports.RampsOrderStatus = exports.RampsApiService = exports.RampsEnvironment = exports.RampsService = exports.RAMPS_CONTROLLER_REQUIRED_CONTROLLER_ACTIONS = exports.RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS = exports.getInternalOrderCode = exports.getDefaultRampsControllerState = exports.RampsController = void 0;
4
+ exports.WalletRegistrationError = exports.mapNeoBankAutorampToRemoteSnapshot = exports.neoBankServiceName = exports.NeoBankService = exports.buildOwnershipMessage = exports.markAutorampNotified = exports.applyAutorampRemoteStatus = exports.createAutorampAccount = exports.normalizeAutorampStatus = exports.isTerminalAutorampStatus = void 0;
4
5
  var RampsController_js_1 = require("./RampsController.cjs");
5
6
  Object.defineProperty(exports, "RampsController", { enumerable: true, get: function () { return RampsController_js_1.RampsController; } });
6
7
  Object.defineProperty(exports, "getDefaultRampsControllerState", { enumerable: true, get: function () { return RampsController_js_1.getDefaultRampsControllerState; } });
7
8
  Object.defineProperty(exports, "getInternalOrderCode", { enumerable: true, get: function () { return RampsController_js_1.getInternalOrderCode; } });
8
9
  Object.defineProperty(exports, "RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS", { enumerable: true, get: function () { return RampsController_js_1.RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS; } });
10
+ Object.defineProperty(exports, "RAMPS_CONTROLLER_REQUIRED_CONTROLLER_ACTIONS", { enumerable: true, get: function () { return RampsController_js_1.RAMPS_CONTROLLER_REQUIRED_CONTROLLER_ACTIONS; } });
9
11
  var RampsService_js_1 = require("./RampsService.cjs");
10
12
  Object.defineProperty(exports, "RampsService", { enumerable: true, get: function () { return RampsService_js_1.RampsService; } });
11
13
  Object.defineProperty(exports, "RampsEnvironment", { enumerable: true, get: function () { return RampsService_js_1.RampsEnvironment; } });
@@ -13,6 +15,10 @@ Object.defineProperty(exports, "RampsApiService", { enumerable: true, get: funct
13
15
  Object.defineProperty(exports, "RampsOrderStatus", { enumerable: true, get: function () { return RampsService_js_1.RampsOrderStatus; } });
14
16
  Object.defineProperty(exports, "RAMPS_SDK_VERSION", { enumerable: true, get: function () { return RampsService_js_1.RAMPS_SDK_VERSION; } });
15
17
  Object.defineProperty(exports, "getDefaultRedirectCallbackUrl", { enumerable: true, get: function () { return RampsService_js_1.getDefaultRedirectCallbackUrl; } });
18
+ var client_identity_js_1 = require("./client-identity.cjs");
19
+ Object.defineProperty(exports, "addRampsClientIdentityParams", { enumerable: true, get: function () { return client_identity_js_1.addRampsClientIdentityParams; } });
20
+ Object.defineProperty(exports, "RAMPS_CLIENT_PRODUCT_PARAM", { enumerable: true, get: function () { return client_identity_js_1.RAMPS_CLIENT_PRODUCT_PARAM; } });
21
+ Object.defineProperty(exports, "RAMPS_CLIENT_VERSION_PARAM", { enumerable: true, get: function () { return client_identity_js_1.RAMPS_CLIENT_VERSION_PARAM; } });
16
22
  var RequestCache_js_1 = require("./RequestCache.cjs");
17
23
  Object.defineProperty(exports, "RequestStatus", { enumerable: true, get: function () { return RequestCache_js_1.RequestStatus; } });
18
24
  Object.defineProperty(exports, "DEFAULT_REQUEST_CACHE_TTL", { enumerable: true, get: function () { return RequestCache_js_1.DEFAULT_REQUEST_CACHE_TTL; } });
@@ -56,4 +62,21 @@ Object.defineProperty(exports, "TransakOrderIdTransformer", { enumerable: true,
56
62
  var transakApiErrorUtils_js_1 = require("./transakApiErrorUtils.cjs");
57
63
  Object.defineProperty(exports, "getTransakApiMessage", { enumerable: true, get: function () { return transakApiErrorUtils_js_1.getTransakApiMessage; } });
58
64
  Object.defineProperty(exports, "isTransakPhoneRegisteredError", { enumerable: true, get: function () { return transakApiErrorUtils_js_1.isTransakPhoneRegisteredError; } });
65
+ var autorampAccount_js_1 = require("./autorampAccount.cjs");
66
+ Object.defineProperty(exports, "AutorampStatus", { enumerable: true, get: function () { return autorampAccount_js_1.AutorampStatus; } });
67
+ Object.defineProperty(exports, "TERMINAL_AUTORAMP_STATUSES", { enumerable: true, get: function () { return autorampAccount_js_1.TERMINAL_AUTORAMP_STATUSES; } });
68
+ Object.defineProperty(exports, "NOTABLE_AUTORAMP_STATUSES", { enumerable: true, get: function () { return autorampAccount_js_1.NOTABLE_AUTORAMP_STATUSES; } });
69
+ Object.defineProperty(exports, "isTerminalAutorampStatus", { enumerable: true, get: function () { return autorampAccount_js_1.isTerminalAutorampStatus; } });
70
+ Object.defineProperty(exports, "normalizeAutorampStatus", { enumerable: true, get: function () { return autorampAccount_js_1.normalizeAutorampStatus; } });
71
+ Object.defineProperty(exports, "createAutorampAccount", { enumerable: true, get: function () { return autorampAccount_js_1.createAutorampAccount; } });
72
+ Object.defineProperty(exports, "applyAutorampRemoteStatus", { enumerable: true, get: function () { return autorampAccount_js_1.applyAutorampRemoteStatus; } });
73
+ Object.defineProperty(exports, "markAutorampNotified", { enumerable: true, get: function () { return autorampAccount_js_1.markAutorampNotified; } });
74
+ var ownership_message_js_1 = require("./ownership-message.cjs");
75
+ Object.defineProperty(exports, "buildOwnershipMessage", { enumerable: true, get: function () { return ownership_message_js_1.buildOwnershipMessage; } });
76
+ var NeoBankService_js_1 = require("./NeoBankService.cjs");
77
+ Object.defineProperty(exports, "NeoBankService", { enumerable: true, get: function () { return NeoBankService_js_1.NeoBankService; } });
78
+ Object.defineProperty(exports, "neoBankServiceName", { enumerable: true, get: function () { return NeoBankService_js_1.serviceName; } });
79
+ Object.defineProperty(exports, "mapNeoBankAutorampToRemoteSnapshot", { enumerable: true, get: function () { return NeoBankService_js_1.mapNeoBankAutorampToRemoteSnapshot; } });
80
+ var wallet_registration_service_js_1 = require("./wallet-registration-service.cjs");
81
+ Object.defineProperty(exports, "WalletRegistrationError", { enumerable: true, get: function () { return wallet_registration_service_js_1.WalletRegistrationError; } });
59
82
  //# sourceMappingURL=index.cjs.map