@ledgerhq/revault-api 1.50.0 → 1.52.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, Z as TransactionData, J as Challenge, c as AccountResponse, G as GroupResponse, U as UserResponse, x as VaultRequestResponse, W as WhitelistResponse } from './app-types-CoSpdjR8.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
@@ -3848,14 +3837,21 @@ var zRequestReviewStep = z.object({
3848
3837
  quorum: z.int().min(1).meta({ description: "Quorum for the review step" })
3849
3838
  });
3850
3839
  var zRequestReviewSteps = z.array(zRequestReviewStep);
3851
- var zEntityName = z14.string().min(1).max(19).meta({ description: "Entity name" });
3852
- var zCreateEntityRequestData = z14.object({
3853
- name: zEntityName,
3854
- accountIds: z14.array(z14.string()).meta({ description: "List of Account IDs" }),
3855
- memberIds: z14.array(z14.string()).meta({ description: "List of User IDs" })
3840
+ z.object({
3841
+ available: z.boolean().meta({ description: "Whether the name is available" }),
3842
+ reason: z.string().optional().meta({ description: "Reason the name is unavailable" })
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
3856
3854
  });
3857
- var zEditEntityRequestData = zCreateEntityRequestData;
3858
- var zRevokeEntityRequestData = z14.object({});
3859
3855
  var zGroupName = z14.string().min(1).max(19).meta({ description: "Group name" });
3860
3856
  var zCreateGroupRequestData = z14.object({
3861
3857
  name: zGroupName,
@@ -3867,6 +3863,14 @@ var zEditGroupRequestData = z14.object({
3867
3863
  description: z14.string().nullable().meta({ description: "Group description" }),
3868
3864
  members: z14.array(z14.string()).meta({ description: "List of group members ids" })
3869
3865
  });
3866
+ var zEntityName = z14.string().min(1).max(19).meta({ description: "Entity name" });
3867
+ var zCreateEntityRequestData = z14.object({
3868
+ name: zEntityName,
3869
+ accountIds: z14.array(z14.string()).meta({ description: "List of Account IDs" }),
3870
+ memberIds: z14.array(z14.string()).meta({ description: "List of User IDs" })
3871
+ });
3872
+ var zEditEntityRequestData = zCreateEntityRequestData;
3873
+ var zRevokeEntityRequestData = z14.object({});
3870
3874
  var zApiKeyName = z14.string().min(1).max(19).meta({ description: "API key name" });
3871
3875
  var zCreateApiKeyRequestData = z14.object({
3872
3876
  name: zApiKeyName,
@@ -4038,8 +4042,7 @@ var zVaultRequestCommonMixin = z14.object({
4038
4042
  createdById: z14.string().meta({ description: "ID of the user who created the request" }),
4039
4043
  // `inflight` is fetched from ONGOING RequestSaga
4040
4044
  inflight: z14.object({
4041
- lastError: z14.string().nullable().meta({ description: "Error message from the last failure" }),
4042
- 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" }),
4043
4046
  retryAfter: z14.coerce.date().meta({ description: "Date after which next retry is scheduled" })
4044
4047
  }).optional().meta({ description: "Extra information if the request is currently being processed" })
4045
4048
  });
@@ -4140,18 +4143,34 @@ z14.object({
4140
4143
  z14.object({
4141
4144
  taskId: z14.string().meta({ description: "Task ID" })
4142
4145
  });
4146
+ var zObjectType = z14.enum(["Account", "Group", "Whitelist", "Policy"]);
4147
+ z14.object({
4148
+ objectType: zObjectType.meta({ description: "Type of object to check name for" }),
4149
+ name: z14.string().min(1).meta({ description: "Name to check availability for" }),
4150
+ excludeId: z14.string().optional().meta({ description: "Optional ID to exclude (for edit scenarios)" })
4151
+ });
4143
4152
 
4144
4153
  // src/requests/app-utils/index.ts
4145
- 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
+ }
4146
4164
  const serialized = {
4147
- ...request,
4148
- legacyId: request.gateId
4165
+ ...omit(request, ["sagas"]),
4166
+ legacyId: request.gateId,
4167
+ inflight
4149
4168
  };
4150
4169
  let patched = zVaultRequestResponse.parse(serialized);
4151
4170
  patched = patchRequestExpiredAt(patched);
4152
4171
  patched = patchTezosRequestData(patched);
4153
4172
  return patched;
4154
- }
4173
+ };
4155
4174
  var zWhitelistAddressResponse = z14.object({
4156
4175
  name: z14.string().min(1).max(50).meta({ description: "Address name" }),
4157
4176
  currency: zCurrencyString.meta({ description: "Address currency" }),
@@ -4181,8 +4200,7 @@ var serializeWhitelist = (whitelist) => {
4181
4200
  // src/__fakes__/responses.ts
4182
4201
  function genVaultRequestResponse(opts, reviews = []) {
4183
4202
  const request = genVaultRequest(opts);
4184
- const requestWithReviews = { ...request, reviews };
4185
- return serializeVaultRequest(requestWithReviews);
4203
+ return serializeVaultRequest({ ...request, reviews, sagas: [] });
4186
4204
  }
4187
4205
  function genAccountResponse(overrides) {
4188
4206
  const dbAccount = genAccount(overrides);