@ledgerhq/revault-api 1.51.0 → 1.53.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/lib/fakes.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as AssetResponse, a1 as TransactionData, L as Challenge, c as AccountResponse, G as GroupResponse, U as UserResponse, x as VaultRequestResponse, _ as WhitelistResponse } from './app-types-C_8ozawx.mjs';
2
- import { Group, User, RequestType, VaultRequestReview, VaultRequest, Account, Whitelist } from '@prisma/client';
1
+ import { A as AssetResponse, a1 as TransactionData, C as Challenge, c as AccountResponse, G as GroupResponse, U as UserResponse, m as VaultRequestResponse, W as WhitelistResponse } from './app-types-C-ZVHyaT.mjs';
2
+ import { Group, User, RequestType, VaultRequest, VaultRequestReview, Account, Whitelist } from '@prisma/client';
3
3
  import z__default from 'zod';
4
4
 
5
5
  /**
package/lib/fakes.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  import { __export } from './chunk-J5LGTIGS.mjs';
2
2
  import { faker } from '@faker-js/faker';
3
- import { ChallengeType, PsdModel, UserRole, UserRegistrationState, AllowedAction, AdminPermission, RequestType, AccountGovernanceType, ActivationStatus, AccountType, MessageType, WhitelistType, UserDeviceType, RequestReviewStatus, RequestState, GateAccountType, GateUserType } from '@prisma/client';
3
+ import { ChallengeType, PsdModel, UserRole, UserRegistrationState, AllowedAction, AdminPermission, RequestType, AccountGovernanceType, ActivationStatus, AccountType, MessageType, WhitelistType, UserDeviceType, RequestReviewStatus, RequestState, RequestSagaStatus, GateAccountType, GateUserType } from '@prisma/client';
4
4
  import { match, P } from 'ts-pattern';
5
5
  import z14, { z } from 'zod';
6
6
  import invariant5 from 'invariant';
7
7
  import 'axios';
8
- import { omit, times, get, isPlainObject } from 'lodash-es';
8
+ import { omit, times, pick, get, isPlainObject } from 'lodash-es';
9
9
  import elliptic from 'elliptic';
10
10
 
11
11
  var zHexString = z.string().regex(/^[0-9a-fA-F]+$/);
@@ -3817,17 +3817,6 @@ var patchTezosRequestData = (data) => {
3817
3817
  }
3818
3818
  return data;
3819
3819
  };
3820
- var zSciConfigData = z14.object({
3821
- dapps: z14.array(z14.string()).nullable().meta({ description: "Allowed DApps, null allows all" }),
3822
- customContractCallEnabled: z14.boolean().meta({ description: "Allow non-DApp SCI" })
3823
- });
3824
- var zCreateSciConfigRequestData = z14.object({
3825
- account: z14.string().meta({ description: "Account UUID" }),
3826
- config: zSciConfigData
3827
- });
3828
- var zEditSciConfigRequestData = z14.object({
3829
- config: zSciConfigData
3830
- });
3831
3820
  var zSoftChallenge = z.object({
3832
3821
  challengeType: z.literal(ChallengeType.SOFT)
3833
3822
  // soft approval with no challenge to sign
@@ -3852,6 +3841,17 @@ z.object({
3852
3841
  available: z.boolean().meta({ description: "Whether the name is available" }),
3853
3842
  reason: z.string().optional().meta({ description: "Reason the name is unavailable" })
3854
3843
  });
3844
+ var zSciConfigData = z14.object({
3845
+ dapps: z14.array(z14.string()).nullable().meta({ description: "Allowed DApps, null allows all" }),
3846
+ customContractCallEnabled: z14.boolean().meta({ description: "Allow non-DApp SCI" })
3847
+ });
3848
+ var zCreateSciConfigRequestData = z14.object({
3849
+ account: z14.string().meta({ description: "Account UUID" }),
3850
+ config: zSciConfigData
3851
+ });
3852
+ var zEditSciConfigRequestData = z14.object({
3853
+ config: zSciConfigData
3854
+ });
3855
3855
  var zGroupName = z14.string().min(1).max(19).meta({ description: "Group name" });
3856
3856
  var zCreateGroupRequestData = z14.object({
3857
3857
  name: zGroupName,
@@ -4042,8 +4042,7 @@ var zVaultRequestCommonMixin = z14.object({
4042
4042
  createdById: z14.string().meta({ description: "ID of the user who created the request" }),
4043
4043
  // `inflight` is fetched from ONGOING RequestSaga
4044
4044
  inflight: z14.object({
4045
- lastError: z14.string().nullable().meta({ description: "Error message from the last failure" }),
4046
- numFailed: z14.number().int().meta({ description: "Number of failures so far" }),
4045
+ completionState: z14.enum(RequestState).nullable().meta({ description: "Target state after execution is complete" }),
4047
4046
  retryAfter: z14.coerce.date().meta({ description: "Date after which next retry is scheduled" })
4048
4047
  }).optional().meta({ description: "Extra information if the request is currently being processed" })
4049
4048
  });
@@ -4152,16 +4151,26 @@ z14.object({
4152
4151
  });
4153
4152
 
4154
4153
  // src/requests/app-utils/index.ts
4155
- function serializeVaultRequest(request) {
4154
+ var serializeVaultRequest = (request) => {
4155
+ let inflight;
4156
+ if (request.sagas.length > 0) {
4157
+ invariant5(request.sagas.length === 1, "Request should have at most 1 ongoing Saga");
4158
+ const ongoingSaga = request.sagas[0];
4159
+ invariant5(ongoingSaga.status === RequestSagaStatus.ONGOING, "RequestSaga must be ONGOING");
4160
+ inflight = pick(ongoingSaga, ["completionState", "retryAfter"]);
4161
+ } else {
4162
+ inflight = void 0;
4163
+ }
4156
4164
  const serialized = {
4157
- ...request,
4158
- legacyId: request.gateId
4165
+ ...omit(request, ["sagas"]),
4166
+ legacyId: request.gateId,
4167
+ inflight
4159
4168
  };
4160
4169
  let patched = zVaultRequestResponse.parse(serialized);
4161
4170
  patched = patchRequestExpiredAt(patched);
4162
4171
  patched = patchTezosRequestData(patched);
4163
4172
  return patched;
4164
- }
4173
+ };
4165
4174
  var zWhitelistAddressResponse = z14.object({
4166
4175
  name: z14.string().min(1).max(50).meta({ description: "Address name" }),
4167
4176
  currency: zCurrencyString.meta({ description: "Address currency" }),
@@ -4191,8 +4200,7 @@ var serializeWhitelist = (whitelist) => {
4191
4200
  // src/__fakes__/responses.ts
4192
4201
  function genVaultRequestResponse(opts, reviews = []) {
4193
4202
  const request = genVaultRequest(opts);
4194
- const requestWithReviews = { ...request, reviews };
4195
- return serializeVaultRequest(requestWithReviews);
4203
+ return serializeVaultRequest({ ...request, reviews, sagas: [] });
4196
4204
  }
4197
4205
  function genAccountResponse(overrides) {
4198
4206
  const dbAccount = genAccount(overrides);