@ledgerhq/revault-api 1.43.2 → 1.45.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,4 +1,4 @@
1
- import { A as AssetResponse, Y as TransactionData, I as Challenge, c as AccountResponse, G as GroupResponse, U as UserResponse, x as VaultRequestResponse, W as WhitelistResponse } from './app-types-TiTgl5lF.mjs';
1
+ import { A as AssetResponse, Y as TransactionData, I as Challenge, c as AccountResponse, G as GroupResponse, U as UserResponse, x as VaultRequestResponse, W as WhitelistResponse } from './app-types-DvxHpGGY.mjs';
2
2
  import { Group, User, RequestType, VaultRequestReview, VaultRequest, Account, Whitelist } from '@prisma/client';
3
3
  import z__default from 'zod';
4
4
 
@@ -39,6 +39,7 @@ declare const zCreateTransactionRequestData: z__default.ZodObject<{
39
39
  transferProposal: z__default.ZodObject<{
40
40
  amount: z__default.ZodString;
41
41
  contractId: z__default.ZodString;
42
+ instrumentAdmin: z__default.ZodString;
42
43
  instrumentId: z__default.ZodString;
43
44
  expiresAtMicros: z__default.ZodNumber;
44
45
  memo: z__default.ZodNullable<z__default.ZodString>;
@@ -52,6 +53,7 @@ declare const zCreateTransactionRequestData: z__default.ZodObject<{
52
53
  transferProposal: z__default.ZodObject<{
53
54
  amount: z__default.ZodString;
54
55
  contractId: z__default.ZodString;
56
+ instrumentAdmin: z__default.ZodString;
55
57
  instrumentId: z__default.ZodString;
56
58
  expiresAtMicros: z__default.ZodNumber;
57
59
  memo: z__default.ZodNullable<z__default.ZodString>;
@@ -461,15 +463,19 @@ declare const zCreateTransactionRequestData: z__default.ZodObject<{
461
463
  maxFee: z__default.ZodNullable<z__default.ZodString>;
462
464
  recipient: z__default.ZodString;
463
465
  type: z__default.ZodLiteral<"STELLAR_LIKE_SEND">;
464
- memo: z__default.ZodNullable<z__default.ZodUnion<readonly [z__default.ZodObject<{
465
- MEMO_TEXT: z__default.ZodString;
466
+ memo: z__default.ZodNullable<z__default.ZodDiscriminatedUnion<[z__default.ZodObject<{
467
+ type: z__default.ZodLiteral<"MEMO_TEXT">;
468
+ value: z__default.ZodString;
466
469
  }, z__default.core.$strip>, z__default.ZodObject<{
467
- MEMO_ID: z__default.ZodString;
470
+ type: z__default.ZodLiteral<"MEMO_ID">;
471
+ value: z__default.ZodString;
468
472
  }, z__default.core.$strip>, z__default.ZodObject<{
469
- MEMO_HASH: z__default.ZodString;
473
+ type: z__default.ZodLiteral<"MEMO_HASH">;
474
+ value: z__default.ZodString;
470
475
  }, z__default.core.$strip>, z__default.ZodObject<{
471
- MEMO_RETURN: z__default.ZodString;
472
- }, z__default.core.$strip>]>>;
476
+ type: z__default.ZodLiteral<"MEMO_RETURN">;
477
+ value: z__default.ZodString;
478
+ }, z__default.core.$strip>], "type">>;
473
479
  feeStrategy: z__default.ZodObject<{
474
480
  type: z__default.ZodEnum<{
475
481
  SLOW: "SLOW";
@@ -972,15 +978,19 @@ declare const zTradelinkCreateSettlementRequestData: z__default.ZodObject<{
972
978
  maxFee: z__default.ZodNullable<z__default.ZodString>;
973
979
  recipient: z__default.ZodString;
974
980
  type: z__default.ZodLiteral<"STELLAR_LIKE_SEND">;
975
- memo: z__default.ZodNullable<z__default.ZodUnion<readonly [z__default.ZodObject<{
976
- MEMO_TEXT: z__default.ZodString;
981
+ memo: z__default.ZodNullable<z__default.ZodDiscriminatedUnion<[z__default.ZodObject<{
982
+ type: z__default.ZodLiteral<"MEMO_TEXT">;
983
+ value: z__default.ZodString;
977
984
  }, z__default.core.$strip>, z__default.ZodObject<{
978
- MEMO_ID: z__default.ZodString;
985
+ type: z__default.ZodLiteral<"MEMO_ID">;
986
+ value: z__default.ZodString;
979
987
  }, z__default.core.$strip>, z__default.ZodObject<{
980
- MEMO_HASH: z__default.ZodString;
988
+ type: z__default.ZodLiteral<"MEMO_HASH">;
989
+ value: z__default.ZodString;
981
990
  }, z__default.core.$strip>, z__default.ZodObject<{
982
- MEMO_RETURN: z__default.ZodString;
983
- }, z__default.core.$strip>]>>;
991
+ type: z__default.ZodLiteral<"MEMO_RETURN">;
992
+ value: z__default.ZodString;
993
+ }, z__default.core.$strip>], "type">>;
984
994
  feeStrategy: z__default.ZodObject<{
985
995
  type: z__default.ZodEnum<{
986
996
  SLOW: "SLOW";
@@ -1138,15 +1148,19 @@ declare const zTradelinkWithdrawRequestData: z__default.ZodObject<{
1138
1148
  maxFee: z__default.ZodNullable<z__default.ZodString>;
1139
1149
  recipient: z__default.ZodString;
1140
1150
  type: z__default.ZodLiteral<"STELLAR_LIKE_SEND">;
1141
- memo: z__default.ZodNullable<z__default.ZodUnion<readonly [z__default.ZodObject<{
1142
- MEMO_TEXT: z__default.ZodString;
1151
+ memo: z__default.ZodNullable<z__default.ZodDiscriminatedUnion<[z__default.ZodObject<{
1152
+ type: z__default.ZodLiteral<"MEMO_TEXT">;
1153
+ value: z__default.ZodString;
1143
1154
  }, z__default.core.$strip>, z__default.ZodObject<{
1144
- MEMO_ID: z__default.ZodString;
1155
+ type: z__default.ZodLiteral<"MEMO_ID">;
1156
+ value: z__default.ZodString;
1145
1157
  }, z__default.core.$strip>, z__default.ZodObject<{
1146
- MEMO_HASH: z__default.ZodString;
1158
+ type: z__default.ZodLiteral<"MEMO_HASH">;
1159
+ value: z__default.ZodString;
1147
1160
  }, z__default.core.$strip>, z__default.ZodObject<{
1148
- MEMO_RETURN: z__default.ZodString;
1149
- }, z__default.core.$strip>]>>;
1161
+ type: z__default.ZodLiteral<"MEMO_RETURN">;
1162
+ value: z__default.ZodString;
1163
+ }, z__default.core.$strip>], "type">>;
1150
1164
  feeStrategy: z__default.ZodObject<{
1151
1165
  type: z__default.ZodEnum<{
1152
1166
  SLOW: "SLOW";
@@ -1299,15 +1313,19 @@ declare const zTradelinkArbitrationRequestData: z__default.ZodObject<{
1299
1313
  maxFee: z__default.ZodNullable<z__default.ZodString>;
1300
1314
  recipient: z__default.ZodString;
1301
1315
  type: z__default.ZodLiteral<"STELLAR_LIKE_SEND">;
1302
- memo: z__default.ZodNullable<z__default.ZodUnion<readonly [z__default.ZodObject<{
1303
- MEMO_TEXT: z__default.ZodString;
1316
+ memo: z__default.ZodNullable<z__default.ZodDiscriminatedUnion<[z__default.ZodObject<{
1317
+ type: z__default.ZodLiteral<"MEMO_TEXT">;
1318
+ value: z__default.ZodString;
1304
1319
  }, z__default.core.$strip>, z__default.ZodObject<{
1305
- MEMO_ID: z__default.ZodString;
1320
+ type: z__default.ZodLiteral<"MEMO_ID">;
1321
+ value: z__default.ZodString;
1306
1322
  }, z__default.core.$strip>, z__default.ZodObject<{
1307
- MEMO_HASH: z__default.ZodString;
1323
+ type: z__default.ZodLiteral<"MEMO_HASH">;
1324
+ value: z__default.ZodString;
1308
1325
  }, z__default.core.$strip>, z__default.ZodObject<{
1309
- MEMO_RETURN: z__default.ZodString;
1310
- }, z__default.core.$strip>]>>;
1326
+ type: z__default.ZodLiteral<"MEMO_RETURN">;
1327
+ value: z__default.ZodString;
1328
+ }, z__default.core.$strip>], "type">>;
1311
1329
  feeStrategy: z__default.ZodObject<{
1312
1330
  type: z__default.ZodEnum<{
1313
1331
  SLOW: "SLOW";
package/lib/fakes.mjs CHANGED
@@ -4,7 +4,7 @@ import { ChallengeType, PsdModel, UserRole, UserRegistrationState, AllowedAction
4
4
  import { match, P } from 'ts-pattern';
5
5
  import z14, { z } from 'zod';
6
6
  import invariant8 from 'invariant';
7
- import { ec } from 'elliptic';
7
+ import elliptic from 'elliptic';
8
8
  import { omit, times, get, isPlainObject } from 'lodash-es';
9
9
  import 'axios';
10
10
 
@@ -125,6 +125,7 @@ var BITCOIN_SPEC = {
125
125
  var zCantonTransferProposal = z14.object({
126
126
  amount: zUnsignedIntString.meta({ description: "Transfer amount" }),
127
127
  contractId: z14.string().meta({ description: "ID of the transfer-proposal contract" }),
128
+ instrumentAdmin: z14.string().meta({ description: "Issuer of the instrument being transferred" }),
128
129
  instrumentId: z14.string().meta({ description: "ID of the instrument being transferred" }),
129
130
  expiresAtMicros: z14.number().int().meta({ description: "Expiration timestamp in microseconds" }),
130
131
  memo: z14.string().nullable().meta({ description: "Optional note attached to the proposal" }),
@@ -458,7 +459,8 @@ var GENERIC_SPEC = {
458
459
  zStakingFields: z14.never()};
459
460
  var zHederaLikeAssetFields = z14.object({
460
461
  type: z14.literal(NetworkFamily.HEDERA_LIKE).meta({ description: "Account type" }),
461
- address: z14.string().nullable().meta({ description: "Account address" })
462
+ address: z14.string().nullable().meta({ description: "Account address" }),
463
+ isActivated: z14.boolean().meta({ description: "Indicates if the account is activated" })
462
464
  }).meta({ description: "Hedera-like" });
463
465
  var zHederaLikeEstimatedFees = z14.object({
464
466
  type: z14.literal(NetworkFamily.HEDERA_LIKE),
@@ -948,16 +950,22 @@ var zStellarLikeEstimatedFees = z14.object({
948
950
  fee: zIntString
949
951
  }).meta({ description: "Stellar-like fees" });
950
952
  var zStellarLikeTransactionType = z14.enum(["STELLAR_LIKE_SEND", "STELLAR_LIKE_RECEIVE"]).meta({ description: "Stellar-like transaction type" });
951
- var zStellarMemo = z14.union([
953
+ var zStellarMemo = z14.discriminatedUnion("type", [
952
954
  z14.object({
953
- MEMO_TEXT: z14.string().max(28).meta({ description: "Text memo (at most a 28 bytes string)" })
955
+ type: z14.literal("MEMO_TEXT"),
956
+ value: z14.string().max(28).meta({ description: "Text memo (at most a 28 bytes string)" })
954
957
  }).meta({ description: "Text memo" }),
955
- z14.object({ MEMO_ID: zIntString.meta({ description: "Id memo (unsigned 64 bits integer)" }) }).meta({ description: "Id memo" }),
956
958
  z14.object({
957
- MEMO_HASH: z14.string().max(128).regex(/^[a-fA-F0-9]+$/).meta({ description: "Transaction hash memo (64 bytes hexadecimal string)" })
959
+ type: z14.literal("MEMO_ID"),
960
+ value: zIntString.meta({ description: "Id memo (unsigned 64 bits integer)" })
961
+ }).meta({ description: "Id memo" }),
962
+ z14.object({
963
+ type: z14.literal("MEMO_HASH"),
964
+ value: z14.string().max(128).regex(/^[a-fA-F0-9]+$/).meta({ description: "Transaction hash memo (64 bytes hexadecimal string)" })
958
965
  }).meta({ description: "Hash memo" }),
959
966
  z14.object({
960
- MEMO_RETURN: z14.string().max(128).regex(/^[a-fA-F0-9]+$/).meta({
967
+ type: z14.literal("MEMO_RETURN"),
968
+ value: z14.string().max(128).regex(/^[a-fA-F0-9]+$/).meta({
961
969
  description: "A 64 bytes hexadecimal string intended to be interpreted as the hash of the transaction the sender is refunding."
962
970
  })
963
971
  }).meta({ description: "Return memo" })
@@ -1356,9 +1364,10 @@ function unreachable(value) {
1356
1364
  }
1357
1365
 
1358
1366
  // src/__fakes__/faker-utils.ts
1367
+ var { ec: EC } = elliptic;
1359
1368
  var fakeUniqueName = (length = 20) => faker.string.alphanumeric({ length, casing: "lower" });
1360
1369
  var fakeHexString = (length, casing = "upper") => faker.string.hexadecimal({ prefix: "", casing, length });
1361
- var fakePubKey = () => new ec("p256").genKeyPair().getPublic(false, "hex");
1370
+ var fakePubKey = () => new EC("p256").genKeyPair().getPublic(false, "hex");
1362
1371
  var fakeDeviceUserId = () => faker.string.hexadecimal({ prefix: "", casing: "upper", length: 16 });
1363
1372
  var fakeIntegerId = () => faker.number.int({ min: 1, max: 2e9 });
1364
1373
  var fakeGateId = fakeIntegerId;
@@ -1386,6 +1395,19 @@ var fakeCantonAddress = (role) => `${role}-${faker.lorem.word()}::${fakeHexStrin
1386
1395
  var fakeCantonPartyId = () => fakeCantonAddress("party");
1387
1396
  var fakeCantonContractId = () => fakeHexString(138, "lower");
1388
1397
  var fakeCantonInstrumentId = () => fakeHexString(10, "lower");
1398
+ var fakeCantonTransferProposal = (opts) => {
1399
+ return {
1400
+ amount: faker.number.bigInt().toString(),
1401
+ contractId: fakeCantonContractId(),
1402
+ instrumentAdmin: fakeCantonPartyId(),
1403
+ instrumentId: fakeCantonInstrumentId(),
1404
+ expiresAtMicros: faker.number.int(),
1405
+ memo: faker.lorem.sentence(),
1406
+ sender: fakeCantonPartyId(),
1407
+ recipient: fakeCantonPartyId(),
1408
+ ...opts
1409
+ };
1410
+ };
1389
1411
  var injectSyncId = (obj) => {
1390
1412
  let { syncId } = obj;
1391
1413
  if (syncId === void 0) {
@@ -1933,10 +1955,16 @@ var genStellarLikeSendData = (txType) => {
1933
1955
  maxFee: faker.number.bigInt({ min: 1 }).toString(),
1934
1956
  recipient: faker.string.alphanumeric({ length: 30 }),
1935
1957
  memo: faker.helpers.arrayElement([
1936
- { MEMO_ID: faker.number.bigInt({ min: 0 }).toString() },
1937
- { MEMO_TEXT: faker.word.conjunction(28) },
1938
- { MEMO_HASH: faker.string.hexadecimal({ prefix: "", casing: "lower", length: 64 }) },
1939
- { MEMO_RETURN: faker.string.hexadecimal({ prefix: "", casing: "lower", length: 64 }) },
1958
+ { type: "MEMO_ID", value: faker.number.bigInt({ min: 0 }).toString() },
1959
+ { type: "MEMO_TEXT", value: faker.word.conjunction(28) },
1960
+ {
1961
+ type: "MEMO_HASH",
1962
+ value: faker.string.hexadecimal({ prefix: "", casing: "lower", length: 64 })
1963
+ },
1964
+ {
1965
+ type: "MEMO_RETURN",
1966
+ value: faker.string.hexadecimal({ prefix: "", casing: "lower", length: 64 })
1967
+ },
1940
1968
  null
1941
1969
  ]),
1942
1970
  feeStrategy: {
@@ -1989,15 +2017,6 @@ var genTronLikeTxData = (txType) => {
1989
2017
  }
1990
2018
  };
1991
2019
  };
1992
- var genCantonTransferProposal = () => ({
1993
- amount: faker.number.bigInt({ min: 0 }).toString(),
1994
- contractId: fakeCantonContractId(),
1995
- instrumentId: fakeCantonInstrumentId(),
1996
- expiresAtMicros: faker.date.future().getTime() * 1e3,
1997
- memo: faker.lorem.sentence(),
1998
- sender: fakeCantonPartyId(),
1999
- recipient: fakeCantonPartyId()
2000
- });
2001
2020
  var genCantonLikeTxData = (txType) => {
2002
2021
  switch (txType) {
2003
2022
  case "CANTON_LIKE_SEND":
@@ -2012,14 +2031,14 @@ var genCantonLikeTxData = (txType) => {
2012
2031
  return {
2013
2032
  type: txType,
2014
2033
  currency: "canton_network",
2015
- transferProposal: genCantonTransferProposal(),
2034
+ transferProposal: fakeCantonTransferProposal(),
2016
2035
  reason: faker.lorem.sentence()
2017
2036
  };
2018
2037
  case "CANTON_LIKE_RECEIVE":
2019
2038
  return {
2020
2039
  type: txType,
2021
2040
  currency: "canton_network",
2022
- transferProposal: genCantonTransferProposal(),
2041
+ transferProposal: fakeCantonTransferProposal(),
2023
2042
  verdict: "ACCEPT",
2024
2043
  reason: faker.lorem.sentence()
2025
2044
  };
@@ -2183,43 +2202,43 @@ var shouldHaveTargetHsmId = (request) => {
2183
2202
  return true;
2184
2203
  }
2185
2204
  };
2186
- var shouldHaveTargetId = (request) => {
2187
- switch (request.type) {
2205
+ var shouldHaveTargetId = (type) => {
2206
+ switch (type) {
2188
2207
  case RequestType.CREATE_API_KEY:
2189
2208
  case RequestType.EDIT_API_KEY:
2190
2209
  case RequestType.REVOKE_API_KEY:
2191
2210
  return false;
2192
2211
  case RequestType.CREATE_TRANSACTION:
2212
+ // TODO: move to True when we resolved the MetaTransaction id being an int
2193
2213
  case RequestType.SIGN_DIGESTS:
2194
2214
  return false;
2195
2215
  case RequestType.UPDATE_QUORUM:
2196
2216
  case RequestType.CREATE_PSD_USER:
2197
2217
  case RequestType.CREATE_API_USER:
2218
+ case RequestType.CREATE_SCICONFIG:
2198
2219
  case RequestType.CREATE_ACCOUNT:
2199
- case RequestType.CREATE_GROUP:
2200
- case RequestType.CREATE_WHITELIST:
2220
+ case RequestType.CREATE_API_USER_ACCESS:
2201
2221
  case RequestType.CREATE_ENTITY:
2202
- case RequestType.CREATE_SCICONFIG:
2222
+ case RequestType.CREATE_GROUP:
2203
2223
  case RequestType.CREATE_POLICY:
2204
- case RequestType.SIGN_MESSAGE:
2205
- case RequestType.TRADELINK_CREATE_CUSTODIAN:
2206
- case RequestType.TRADELINK_CREATE_EXCHANGE:
2207
- case RequestType.TRADELINK_CREATE_ASSET_MANAGER:
2208
- return request.state === RequestState.EXECUTED;
2224
+ case RequestType.CREATE_WHITELIST:
2209
2225
  case RequestType.EDIT_WORKSPACE_RULE:
2210
2226
  case RequestType.EDIT_ACCOUNT:
2211
- case RequestType.TRADELINK_ACTIVATE_ACCOUNT:
2212
2227
  case RequestType.EDIT_TOKEN_RULE:
2213
2228
  // EDIT_TOKEN_RULE targetId is the parent account which must always exist, even when creating new token rule.
2214
2229
  case RequestType.EDIT_GROUP:
2215
- case RequestType.REVOKE_GROUP:
2216
- case RequestType.EDIT_WHITELIST:
2217
2230
  case RequestType.EDIT_ENTITY:
2218
- case RequestType.REVOKE_ENTITY:
2219
- case RequestType.CREATE_API_USER_ACCESS:
2220
- case RequestType.REVOKE_USER:
2221
2231
  case RequestType.EDIT_SCICONFIG:
2222
2232
  case RequestType.EDIT_POLICY:
2233
+ case RequestType.EDIT_WHITELIST:
2234
+ case RequestType.REVOKE_ENTITY:
2235
+ case RequestType.REVOKE_GROUP:
2236
+ case RequestType.REVOKE_USER:
2237
+ case RequestType.SIGN_MESSAGE:
2238
+ case RequestType.TRADELINK_ACTIVATE_ACCOUNT:
2239
+ case RequestType.TRADELINK_CREATE_ASSET_MANAGER:
2240
+ case RequestType.TRADELINK_CREATE_CUSTODIAN:
2241
+ case RequestType.TRADELINK_CREATE_EXCHANGE:
2223
2242
  case RequestType.TRADELINK_EDIT_CUSTODIAN:
2224
2243
  case RequestType.TRADELINK_EDIT_EXCHANGE:
2225
2244
  case RequestType.TRADELINK_EDIT_ASSET_MANAGER:
@@ -2598,7 +2617,7 @@ var genRequestReviewSteps = (numSteps) => times(1, () => ({ stageName: "default"
2598
2617
  var genVaultRequest = (opts) => {
2599
2618
  const { type, state = RequestState.PENDING_APPROVAL, data, ...custom } = opts;
2600
2619
  const targetHsmId = shouldHaveTargetHsmId({ type, state }) ? type === RequestType.CREATE_PSD_USER ? fakePubKey() : fakeHsmObjectId() : null;
2601
- const targetId = shouldHaveTargetId({ type, state }) ? faker.string.uuid() : null;
2620
+ const targetId = shouldHaveTargetId(type) ? faker.string.uuid() : null;
2602
2621
  return injectSyncId({
2603
2622
  id: faker.string.uuid(),
2604
2623
  workspaceName: fakeWorkspaceName(),
@@ -2870,8 +2889,7 @@ var zUserRegistrationCreateInput = z.object({
2870
2889
  zUserRegistrationCreateInput.extend({
2871
2890
  id: z.string().meta({ description: "User registration ID" }),
2872
2891
  workspaceName: z.string().meta({ description: "Workspace name" }),
2873
- state: z.enum(UserRegistrationState).meta({ description: "User registration state" }),
2874
- isLocked: z.boolean().meta({ description: "Whether the registration is locked by a request" })
2892
+ state: z.enum(UserRegistrationState).meta({ description: "User registration state" })
2875
2893
  });
2876
2894
 
2877
2895
  // src/users/request-data.ts
@@ -3294,10 +3312,7 @@ z14.enum([
3294
3312
  var zRawSigningLiveData = zCommonLiveData.extend({
3295
3313
  type: z14.literal(AccountType.RAW_SIGNING).meta({ description: "Account type" })
3296
3314
  }).meta({ description: "Raw signing account" });
3297
- z14.discriminatedUnion("type", [
3298
- zRawSigningLiveData,
3299
- ...zAccountLiveData.options
3300
- ]);
3315
+ z14.discriminatedUnion("type", [zRawSigningLiveData, ...zAccountLiveData.options]).meta({ description: "Account live data", id: "AccountLiveDataResponse" });
3301
3316
  z14.object({
3302
3317
  address: z14.string().meta({ description: "Address" }),
3303
3318
  derivationPath: z14.string().nullable().meta({ description: "Derivation path" })
@@ -3596,7 +3611,8 @@ var getAccountAssetFields = (account) => {
3596
3611
  case AccountType.HEDERA_LIKE:
3597
3612
  return {
3598
3613
  type: account.type,
3599
- address: account.address
3614
+ address: account.address,
3615
+ isActivated: account.lesWalletId !== null
3600
3616
  };
3601
3617
  /* v8 ignore next -- @preserve */
3602
3618
  default: