@metamask-previews/ramps-controller 8.0.0-preview-33dbba4f3 → 8.0.0-preview-a196307b6

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 (40) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/dist/RampsController.cjs +444 -4
  3. package/dist/RampsController.cjs.map +1 -1
  4. package/dist/RampsController.d.cts +231 -3
  5. package/dist/RampsController.d.cts.map +1 -1
  6. package/dist/RampsController.d.mts +231 -3
  7. package/dist/RampsController.d.mts.map +1 -1
  8. package/dist/RampsController.mjs +444 -4
  9. package/dist/RampsController.mjs.map +1 -1
  10. package/dist/RampsService.cjs.map +1 -1
  11. package/dist/RampsService.d.cts +4 -0
  12. package/dist/RampsService.d.cts.map +1 -1
  13. package/dist/RampsService.d.mts +4 -0
  14. package/dist/RampsService.d.mts.map +1 -1
  15. package/dist/RampsService.mjs.map +1 -1
  16. package/dist/TransakService-method-action-types.cjs +7 -0
  17. package/dist/TransakService-method-action-types.cjs.map +1 -0
  18. package/dist/TransakService-method-action-types.d.cts +106 -0
  19. package/dist/TransakService-method-action-types.d.cts.map +1 -0
  20. package/dist/TransakService-method-action-types.d.mts +106 -0
  21. package/dist/TransakService-method-action-types.d.mts.map +1 -0
  22. package/dist/TransakService-method-action-types.mjs +6 -0
  23. package/dist/TransakService-method-action-types.mjs.map +1 -0
  24. package/dist/TransakService.cjs +588 -0
  25. package/dist/TransakService.cjs.map +1 -0
  26. package/dist/TransakService.d.cts +329 -0
  27. package/dist/TransakService.d.cts.map +1 -0
  28. package/dist/TransakService.d.mts +329 -0
  29. package/dist/TransakService.d.mts.map +1 -0
  30. package/dist/TransakService.mjs +582 -0
  31. package/dist/TransakService.mjs.map +1 -0
  32. package/dist/index.cjs +6 -1
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.cts +4 -1
  35. package/dist/index.d.cts.map +1 -1
  36. package/dist/index.d.mts +4 -1
  37. package/dist/index.d.mts.map +1 -1
  38. package/dist/index.mjs +1 -0
  39. package/dist/index.mjs.map +1 -1
  40. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
10
10
  ### Added
11
11
 
12
12
  - Add `widgetUrl` resource state that automatically fetches and stores the buy widget URL whenever the selected quote changes ([#7920](https://github.com/MetaMask/core/pull/7920))
13
+ - Add `TransakService` for native Transak deposit flow with OTP auth, KYC, quoting, order lifecycle, and payment widget URL generation ([#7922](https://github.com/MetaMask/core/pull/7922))
14
+ - Add `nativeProviders.transak` state slice and controller convenience methods for driving the Transak native deposit flow ([#7922](https://github.com/MetaMask/core/pull/7922))
13
15
 
14
16
  ### Changed
15
17
 
@@ -10,7 +10,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
10
10
  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");
11
11
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
12
12
  };
13
- var _RampsController_instances, _RampsController_requestCacheTTL, _RampsController_requestCacheMaxSize, _RampsController_pendingRequests, _RampsController_pendingResourceCount, _RampsController_quotePollingInterval, _RampsController_quotePollingOptions, _RampsController_clearPendingResourceCountForDependentResources, _RampsController_abortDependentRequests, _RampsController_mutateRequests, _RampsController_removeRequestState, _RampsController_cleanupState, _RampsController_fireAndForget, _RampsController_restartPollingIfActive, _RampsController_requireRegion, _RampsController_isRegionCurrent, _RampsController_isTokenCurrent, _RampsController_isProviderCurrent, _RampsController_updateResourceField, _RampsController_setResourceLoading, _RampsController_setResourceError, _RampsController_updateRequestState, _RampsController_syncWidgetUrl;
13
+ var _RampsController_instances, _RampsController_requestCacheTTL, _RampsController_requestCacheMaxSize, _RampsController_pendingRequests, _RampsController_pendingResourceCount, _RampsController_quotePollingInterval, _RampsController_quotePollingOptions, _RampsController_clearPendingResourceCountForDependentResources, _RampsController_abortDependentRequests, _RampsController_mutateRequests, _RampsController_removeRequestState, _RampsController_cleanupState, _RampsController_fireAndForget, _RampsController_restartPollingIfActive, _RampsController_requireRegion, _RampsController_isRegionCurrent, _RampsController_isTokenCurrent, _RampsController_isProviderCurrent, _RampsController_updateResourceField, _RampsController_setResourceLoading, _RampsController_setResourceError, _RampsController_updateRequestState, _RampsController_syncWidgetUrl, _RampsController_syncTransakAuthOnError;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.RampsController = exports.getDefaultRampsControllerState = exports.RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS = exports.controllerName = void 0;
16
16
  const base_controller_1 = require("@metamask/base-controller");
@@ -35,6 +35,30 @@ exports.RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS = [
35
35
  'RampsService:getPaymentMethods',
36
36
  'RampsService:getQuotes',
37
37
  'RampsService:getBuyWidgetUrl',
38
+ 'TransakService:setApiKey',
39
+ 'TransakService:setAccessToken',
40
+ 'TransakService:clearAccessToken',
41
+ 'TransakService:sendUserOtp',
42
+ 'TransakService:verifyUserOtp',
43
+ 'TransakService:logout',
44
+ 'TransakService:getUserDetails',
45
+ 'TransakService:getBuyQuote',
46
+ 'TransakService:getKycRequirement',
47
+ 'TransakService:getAdditionalRequirements',
48
+ 'TransakService:createOrder',
49
+ 'TransakService:getOrder',
50
+ 'TransakService:getUserLimits',
51
+ 'TransakService:requestOtt',
52
+ 'TransakService:generatePaymentWidgetUrl',
53
+ 'TransakService:submitPurposeOfUsageForm',
54
+ 'TransakService:patchUser',
55
+ 'TransakService:submitSsnDetails',
56
+ 'TransakService:confirmPayment',
57
+ 'TransakService:getTranslation',
58
+ 'TransakService:getIdProofStatus',
59
+ 'TransakService:cancelOrder',
60
+ 'TransakService:cancelAllActiveOrders',
61
+ 'TransakService:getActiveOrders',
38
62
  ];
39
63
  /**
40
64
  * Default TTL for quotes requests (15 seconds).
@@ -93,6 +117,12 @@ const rampsControllerMetadata = {
93
117
  includeInStateLogs: false,
94
118
  usedInUi: true,
95
119
  },
120
+ nativeProviders: {
121
+ persist: false,
122
+ includeInDebugSnapshot: true,
123
+ includeInStateLogs: false,
124
+ usedInUi: true,
125
+ },
96
126
  };
97
127
  /**
98
128
  * Creates a default resource state object.
@@ -129,6 +159,14 @@ function getDefaultRampsControllerState() {
129
159
  quotes: createDefaultResourceState(null, null),
130
160
  widgetUrl: createDefaultResourceState(null),
131
161
  requests: {},
162
+ nativeProviders: {
163
+ transak: {
164
+ isAuthenticated: false,
165
+ userDetails: createDefaultResourceState(null),
166
+ buyQuote: createDefaultResourceState(null),
167
+ kycRequirement: createDefaultResourceState(null),
168
+ },
169
+ },
132
170
  };
133
171
  }
134
172
  exports.getDefaultRampsControllerState = getDefaultRampsControllerState;
@@ -872,11 +910,14 @@ class RampsController extends base_controller_1.BaseController {
872
910
  * If the response contains exactly one quote, it is auto-selected.
873
911
  * If multiple quotes are returned, the existing selection is preserved if still valid.
874
912
  *
913
+ * Returns early (no-op) if the selected payment method is not yet set,
914
+ * allowing callers to invoke this before payment-method selection is finalized.
915
+ *
875
916
  * @param options - Parameters for fetching quotes.
876
917
  * @param options.walletAddress - The destination wallet address.
877
918
  * @param options.amount - The amount (in fiat for buy, crypto for sell).
878
919
  * @param options.redirectUrl - Optional redirect URL after order completion.
879
- * @throws If required dependencies (region, token, provider, payment method) are not set.
920
+ * @throws If required dependencies (region, token, provider) are not set.
880
921
  */
881
922
  startQuotePolling(options) {
882
923
  __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_requireRegion).call(this);
@@ -986,11 +1027,404 @@ class RampsController extends base_controller_1.BaseController {
986
1027
  const buyWidget = await this.messenger.call('RampsService:getBuyWidgetUrl', buyUrl);
987
1028
  return buyWidget.url ?? null;
988
1029
  }
989
- catch (error) {
990
- console.error('Error fetching widget URL:', error);
1030
+ catch {
991
1031
  return null;
992
1032
  }
993
1033
  }
1034
+ /**
1035
+ * Sets the Transak API key used for all Transak API requests.
1036
+ *
1037
+ * @param apiKey - The Transak API key.
1038
+ */
1039
+ transakSetApiKey(apiKey) {
1040
+ this.messenger.call('TransakService:setApiKey', apiKey);
1041
+ }
1042
+ /**
1043
+ * Sets the Transak access token and marks the user as authenticated.
1044
+ *
1045
+ * @param token - The access token received from Transak auth.
1046
+ */
1047
+ transakSetAccessToken(token) {
1048
+ this.messenger.call('TransakService:setAccessToken', token);
1049
+ this.transakSetAuthenticated(true);
1050
+ }
1051
+ /**
1052
+ * Clears the Transak access token and marks the user as unauthenticated.
1053
+ */
1054
+ transakClearAccessToken() {
1055
+ this.messenger.call('TransakService:clearAccessToken');
1056
+ this.transakSetAuthenticated(false);
1057
+ }
1058
+ /**
1059
+ * Updates the Transak authentication flag in controller state.
1060
+ *
1061
+ * @param isAuthenticated - Whether the user is authenticated with Transak.
1062
+ */
1063
+ transakSetAuthenticated(isAuthenticated) {
1064
+ this.update((state) => {
1065
+ state.nativeProviders.transak.isAuthenticated = isAuthenticated;
1066
+ });
1067
+ }
1068
+ /**
1069
+ * Resets all Transak state back to defaults (unauthenticated, no data).
1070
+ */
1071
+ transakResetState() {
1072
+ this.messenger.call('TransakService:clearAccessToken');
1073
+ this.update((state) => {
1074
+ state.nativeProviders.transak =
1075
+ getDefaultRampsControllerState().nativeProviders.transak;
1076
+ });
1077
+ }
1078
+ /**
1079
+ * Sends a one-time password to the user's email for Transak authentication.
1080
+ *
1081
+ * @param email - The user's email address.
1082
+ * @returns The OTP response containing a state token for verification.
1083
+ */
1084
+ async transakSendUserOtp(email) {
1085
+ return this.messenger.call('TransakService:sendUserOtp', email);
1086
+ }
1087
+ /**
1088
+ * Verifies a one-time password and authenticates the user with Transak.
1089
+ * Updates the controller's authentication state on success.
1090
+ *
1091
+ * @param email - The user's email address.
1092
+ * @param verificationCode - The OTP code entered by the user.
1093
+ * @param stateToken - The state token from the sendUserOtp response.
1094
+ * @returns The access token for subsequent authenticated requests.
1095
+ */
1096
+ async transakVerifyUserOtp(email, verificationCode, stateToken) {
1097
+ const token = await this.messenger.call('TransakService:verifyUserOtp', email, verificationCode, stateToken);
1098
+ this.transakSetAuthenticated(true);
1099
+ return token;
1100
+ }
1101
+ /**
1102
+ * Logs the user out of Transak. Clears authentication state and user details
1103
+ * regardless of whether the API call succeeds or fails.
1104
+ *
1105
+ * @returns A message indicating the logout result.
1106
+ */
1107
+ async transakLogout() {
1108
+ try {
1109
+ const result = await this.messenger.call('TransakService:logout');
1110
+ return result;
1111
+ }
1112
+ finally {
1113
+ this.transakClearAccessToken();
1114
+ this.update((state) => {
1115
+ state.nativeProviders.transak.userDetails.data = null;
1116
+ });
1117
+ }
1118
+ }
1119
+ /**
1120
+ * Fetches the authenticated user's details from Transak.
1121
+ * Updates the userDetails resource state with loading/success/error states.
1122
+ *
1123
+ * @returns The user's profile and KYC details.
1124
+ */
1125
+ async transakGetUserDetails() {
1126
+ this.update((state) => {
1127
+ state.nativeProviders.transak.userDetails.isLoading = true;
1128
+ state.nativeProviders.transak.userDetails.error = null;
1129
+ });
1130
+ try {
1131
+ const details = await this.messenger.call('TransakService:getUserDetails');
1132
+ this.update((state) => {
1133
+ state.nativeProviders.transak.userDetails.data = details;
1134
+ state.nativeProviders.transak.userDetails.isLoading = false;
1135
+ });
1136
+ return details;
1137
+ }
1138
+ catch (error) {
1139
+ __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
1140
+ const errorMessage = error?.message ?? 'Unknown error';
1141
+ this.update((state) => {
1142
+ state.nativeProviders.transak.userDetails.isLoading = false;
1143
+ state.nativeProviders.transak.userDetails.error = errorMessage;
1144
+ });
1145
+ throw error;
1146
+ }
1147
+ }
1148
+ /**
1149
+ * Fetches a buy quote from Transak for the given parameters.
1150
+ * Updates the buyQuote resource state with loading/success/error states.
1151
+ *
1152
+ * @param fiatCurrency - The fiat currency code (e.g., "USD").
1153
+ * @param cryptoCurrency - The cryptocurrency identifier.
1154
+ * @param network - The blockchain network identifier.
1155
+ * @param paymentMethod - The payment method identifier.
1156
+ * @param fiatAmount - The fiat amount as a string.
1157
+ * @returns The buy quote with pricing and fee details.
1158
+ */
1159
+ async transakGetBuyQuote(fiatCurrency, cryptoCurrency, network, paymentMethod, fiatAmount) {
1160
+ this.update((state) => {
1161
+ state.nativeProviders.transak.buyQuote.isLoading = true;
1162
+ state.nativeProviders.transak.buyQuote.error = null;
1163
+ });
1164
+ try {
1165
+ const quote = await this.messenger.call('TransakService:getBuyQuote', fiatCurrency, cryptoCurrency, network, paymentMethod, fiatAmount);
1166
+ this.update((state) => {
1167
+ state.nativeProviders.transak.buyQuote.data = quote;
1168
+ state.nativeProviders.transak.buyQuote.isLoading = false;
1169
+ });
1170
+ return quote;
1171
+ }
1172
+ catch (error) {
1173
+ const errorMessage = error?.message ?? 'Unknown error';
1174
+ this.update((state) => {
1175
+ state.nativeProviders.transak.buyQuote.isLoading = false;
1176
+ state.nativeProviders.transak.buyQuote.error = errorMessage;
1177
+ });
1178
+ throw error;
1179
+ }
1180
+ }
1181
+ /**
1182
+ * Fetches the KYC requirement for a given quote.
1183
+ * Updates the kycRequirement resource state with loading/success/error states.
1184
+ *
1185
+ * @param quoteId - The quote ID to check KYC requirements for.
1186
+ * @returns The KYC requirement status and whether the user can place an order.
1187
+ */
1188
+ async transakGetKycRequirement(quoteId) {
1189
+ this.update((state) => {
1190
+ state.nativeProviders.transak.kycRequirement.isLoading = true;
1191
+ state.nativeProviders.transak.kycRequirement.error = null;
1192
+ });
1193
+ try {
1194
+ const requirement = await this.messenger.call('TransakService:getKycRequirement', quoteId);
1195
+ this.update((state) => {
1196
+ state.nativeProviders.transak.kycRequirement.data = requirement;
1197
+ state.nativeProviders.transak.kycRequirement.isLoading = false;
1198
+ });
1199
+ return requirement;
1200
+ }
1201
+ catch (error) {
1202
+ __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
1203
+ const errorMessage = error?.message ?? 'Unknown error';
1204
+ this.update((state) => {
1205
+ state.nativeProviders.transak.kycRequirement.isLoading = false;
1206
+ state.nativeProviders.transak.kycRequirement.error = errorMessage;
1207
+ });
1208
+ throw error;
1209
+ }
1210
+ }
1211
+ /**
1212
+ * Fetches additional KYC requirements (e.g., ID proof, address proof) for a quote.
1213
+ *
1214
+ * @param quoteId - The quote ID to check additional requirements for.
1215
+ * @returns The list of additional forms required.
1216
+ */
1217
+ async transakGetAdditionalRequirements(quoteId) {
1218
+ try {
1219
+ return await this.messenger.call('TransakService:getAdditionalRequirements', quoteId);
1220
+ }
1221
+ catch (error) {
1222
+ __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
1223
+ throw error;
1224
+ }
1225
+ }
1226
+ /**
1227
+ * Creates a new order on Transak. If an existing order conflicts (HTTP 409),
1228
+ * active orders are cancelled and the creation is retried.
1229
+ *
1230
+ * @param quoteId - The quote ID to create an order from.
1231
+ * @param walletAddress - The destination wallet address.
1232
+ * @param paymentMethodId - The payment method to use.
1233
+ * @returns The created deposit order.
1234
+ */
1235
+ async transakCreateOrder(quoteId, walletAddress, paymentMethodId) {
1236
+ try {
1237
+ return await this.messenger.call('TransakService:createOrder', quoteId, walletAddress, paymentMethodId);
1238
+ }
1239
+ catch (error) {
1240
+ __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
1241
+ throw error;
1242
+ }
1243
+ }
1244
+ /**
1245
+ * Fetches an existing order from Transak by order ID.
1246
+ *
1247
+ * @param orderId - The order ID (deposit format or raw Transak format).
1248
+ * @param wallet - The wallet address associated with the order.
1249
+ * @param paymentDetails - Optional payment details to attach to the order.
1250
+ * @returns The deposit order details.
1251
+ */
1252
+ async transakGetOrder(orderId, wallet, paymentDetails) {
1253
+ return this.messenger.call('TransakService:getOrder', orderId, wallet, paymentDetails);
1254
+ }
1255
+ /**
1256
+ * Fetches the user's spending limits for a given currency and payment method.
1257
+ *
1258
+ * @param fiatCurrency - The fiat currency code.
1259
+ * @param paymentMethod - The payment method identifier.
1260
+ * @param kycType - The KYC level type.
1261
+ * @returns The user's limits, spending, and remaining amounts.
1262
+ */
1263
+ async transakGetUserLimits(fiatCurrency, paymentMethod, kycType) {
1264
+ try {
1265
+ return await this.messenger.call('TransakService:getUserLimits', fiatCurrency, paymentMethod, kycType);
1266
+ }
1267
+ catch (error) {
1268
+ __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
1269
+ throw error;
1270
+ }
1271
+ }
1272
+ /**
1273
+ * Requests a one-time token (OTT) for the Transak payment widget.
1274
+ *
1275
+ * @returns The OTT response containing the token.
1276
+ */
1277
+ async transakRequestOtt() {
1278
+ try {
1279
+ return await this.messenger.call('TransakService:requestOtt');
1280
+ }
1281
+ catch (error) {
1282
+ __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
1283
+ throw error;
1284
+ }
1285
+ }
1286
+ /**
1287
+ * Generates a URL for the Transak payment widget with pre-filled parameters.
1288
+ *
1289
+ * @param ottToken - The one-time token for widget authentication.
1290
+ * @param quote - The buy quote to pre-fill in the widget.
1291
+ * @param walletAddress - The destination wallet address.
1292
+ * @param extraParams - Optional additional URL parameters.
1293
+ * @returns The fully constructed widget URL string.
1294
+ */
1295
+ transakGeneratePaymentWidgetUrl(ottToken, quote, walletAddress, extraParams) {
1296
+ return this.messenger.call('TransakService:generatePaymentWidgetUrl', ottToken, quote, walletAddress, extraParams);
1297
+ }
1298
+ /**
1299
+ * Submits the user's purpose of usage form for KYC compliance.
1300
+ *
1301
+ * @param purpose - Array of purpose strings selected by the user.
1302
+ * @returns A promise that resolves when the form is submitted.
1303
+ */
1304
+ async transakSubmitPurposeOfUsageForm(purpose) {
1305
+ try {
1306
+ return await this.messenger.call('TransakService:submitPurposeOfUsageForm', purpose);
1307
+ }
1308
+ catch (error) {
1309
+ __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
1310
+ throw error;
1311
+ }
1312
+ }
1313
+ /**
1314
+ * Updates the user's personal or address details on Transak.
1315
+ *
1316
+ * @param data - The user data fields to update.
1317
+ * @returns The API response data.
1318
+ */
1319
+ async transakPatchUser(data) {
1320
+ try {
1321
+ return await this.messenger.call('TransakService:patchUser', data);
1322
+ }
1323
+ catch (error) {
1324
+ __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
1325
+ throw error;
1326
+ }
1327
+ }
1328
+ /**
1329
+ * Submits the user's SSN for identity verification.
1330
+ *
1331
+ * @param ssn - The Social Security Number.
1332
+ * @param quoteId - The quote ID associated with the order requiring SSN.
1333
+ * @returns The API response data.
1334
+ */
1335
+ async transakSubmitSsnDetails(ssn, quoteId) {
1336
+ try {
1337
+ return await this.messenger.call('TransakService:submitSsnDetails', ssn, quoteId);
1338
+ }
1339
+ catch (error) {
1340
+ __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
1341
+ throw error;
1342
+ }
1343
+ }
1344
+ /**
1345
+ * Confirms payment for an order after the user has completed payment.
1346
+ *
1347
+ * @param orderId - The order ID to confirm payment for.
1348
+ * @param paymentMethodId - The payment method used.
1349
+ * @returns Whether the payment confirmation was successful.
1350
+ */
1351
+ async transakConfirmPayment(orderId, paymentMethodId) {
1352
+ try {
1353
+ return await this.messenger.call('TransakService:confirmPayment', orderId, paymentMethodId);
1354
+ }
1355
+ catch (error) {
1356
+ __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
1357
+ throw error;
1358
+ }
1359
+ }
1360
+ /**
1361
+ * Translates generic ramps identifiers to Transak-specific identifiers.
1362
+ *
1363
+ * @param request - The translation request with optional identifiers to translate.
1364
+ * @returns The translated Transak-specific identifiers.
1365
+ */
1366
+ async transakGetTranslation(request) {
1367
+ return this.messenger.call('TransakService:getTranslation', request);
1368
+ }
1369
+ /**
1370
+ * Checks the status of an ID proof submission for KYC.
1371
+ *
1372
+ * @param workFlowRunId - The workflow run ID to check status for.
1373
+ * @returns The current ID proof status.
1374
+ */
1375
+ async transakGetIdProofStatus(workFlowRunId) {
1376
+ try {
1377
+ return await this.messenger.call('TransakService:getIdProofStatus', workFlowRunId);
1378
+ }
1379
+ catch (error) {
1380
+ __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
1381
+ throw error;
1382
+ }
1383
+ }
1384
+ /**
1385
+ * Cancels a specific Transak order.
1386
+ *
1387
+ * @param depositOrderId - The deposit order ID to cancel.
1388
+ * @returns A promise that resolves when the order is cancelled.
1389
+ */
1390
+ async transakCancelOrder(depositOrderId) {
1391
+ try {
1392
+ return await this.messenger.call('TransakService:cancelOrder', depositOrderId);
1393
+ }
1394
+ catch (error) {
1395
+ __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
1396
+ throw error;
1397
+ }
1398
+ }
1399
+ /**
1400
+ * Cancels all active Transak orders. Individual cancellation failures
1401
+ * are collected and returned rather than thrown.
1402
+ *
1403
+ * @returns An array of errors from any failed cancellations (empty if all succeeded).
1404
+ */
1405
+ async transakCancelAllActiveOrders() {
1406
+ try {
1407
+ return await this.messenger.call('TransakService:cancelAllActiveOrders');
1408
+ }
1409
+ catch (error) {
1410
+ __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
1411
+ throw error;
1412
+ }
1413
+ }
1414
+ /**
1415
+ * Fetches all active Transak orders for the authenticated user.
1416
+ *
1417
+ * @returns The list of active orders.
1418
+ */
1419
+ async transakGetActiveOrders() {
1420
+ try {
1421
+ return await this.messenger.call('TransakService:getActiveOrders');
1422
+ }
1423
+ catch (error) {
1424
+ __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
1425
+ throw error;
1426
+ }
1427
+ }
994
1428
  }
995
1429
  exports.RampsController = RampsController;
996
1430
  _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheMaxSize = new WeakMap(), _RampsController_pendingRequests = new WeakMap(), _RampsController_pendingResourceCount = new WeakMap(), _RampsController_quotePollingInterval = new WeakMap(), _RampsController_quotePollingOptions = new WeakMap(), _RampsController_instances = new WeakSet(), _RampsController_clearPendingResourceCountForDependentResources = function _RampsController_clearPendingResourceCountForDependentResources() {
@@ -1122,5 +1556,11 @@ _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheM
1122
1556
  : 'Failed to fetch widget URL';
1123
1557
  });
1124
1558
  }));
1559
+ }, _RampsController_syncTransakAuthOnError = function _RampsController_syncTransakAuthOnError(error) {
1560
+ if (error instanceof Error &&
1561
+ 'httpStatus' in error &&
1562
+ error.httpStatus === 401) {
1563
+ this.transakSetAuthenticated(false);
1564
+ }
1125
1565
  };
1126
1566
  //# sourceMappingURL=RampsController.cjs.map