@portal-hq/utils 4.1.0 → 4.1.1

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.
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.convertLocalToCrypto = exports.convertCryptoToLocal = exports.convert = void 0;
13
13
  const countries_1 = require("./countries");
14
- const convert = (value, from = 'ETH', countryCode) => __awaiter(void 0, void 0, void 0, function* () {
14
+ const convert = (value_1, ...args_1) => __awaiter(void 0, [value_1, ...args_1], void 0, function* (value, from = 'ETH', countryCode) {
15
15
  const country = countries_1.countryCodes[countryCode || 'US'];
16
16
  if (!country) {
17
17
  throw new Error(`Unable to find country name for country code: ${countryCode}.`);
@@ -27,7 +27,7 @@ const convert = (value, from = 'ETH', countryCode) => __awaiter(void 0, void 0,
27
27
  return convertedValue;
28
28
  });
29
29
  exports.convert = convert;
30
- const convertCryptoToLocal = (value, from = 'ETH', countryCode) => __awaiter(void 0, void 0, void 0, function* () {
30
+ const convertCryptoToLocal = (value_1, ...args_1) => __awaiter(void 0, [value_1, ...args_1], void 0, function* (value, from = 'ETH', countryCode) {
31
31
  const country = countries_1.countryCodes[countryCode || 'US'];
32
32
  if (!country) {
33
33
  throw new Error(`Unable to find country name for country code: ${countryCode}.`);
@@ -43,7 +43,7 @@ const convertCryptoToLocal = (value, from = 'ETH', countryCode) => __awaiter(voi
43
43
  return convertedValue;
44
44
  });
45
45
  exports.convertCryptoToLocal = convertCryptoToLocal;
46
- const convertLocalToCrypto = (value, to = 'ETH', countryCode) => __awaiter(void 0, void 0, void 0, function* () {
46
+ const convertLocalToCrypto = (value_1, ...args_1) => __awaiter(void 0, [value_1, ...args_1], void 0, function* (value, to = 'ETH', countryCode) {
47
47
  const country = countries_1.countryCodes[countryCode || 'US'];
48
48
  if (!country) {
49
49
  throw new Error(`Unable to find country name for country code: ${countryCode}.`);
@@ -60,7 +60,7 @@ var MpcStatuses;
60
60
  MpcStatuses["RecoveringBackupShare"] = "Recovering backup share";
61
61
  MpcStatuses["RecoveringSigningShare"] = "Recovering signing share";
62
62
  MpcStatuses["StoringShare"] = "Storing share";
63
- })(MpcStatuses = exports.MpcStatuses || (exports.MpcStatuses = {}));
63
+ })(MpcStatuses || (exports.MpcStatuses = MpcStatuses = {}));
64
64
  class Storage {
65
65
  delete() {
66
66
  throw new Error('[Portal] Storage method delete cannot be called directly. Please extend Storage.');
@@ -62,7 +62,7 @@ var PortalErrorCodes;
62
62
  PortalErrorCodes[PortalErrorCodes["FailedToDecodeCipherHexString"] = 405] = "FailedToDecodeCipherHexString";
63
63
  PortalErrorCodes[PortalErrorCodes["FailedToGetNonceSize"] = 406] = "FailedToGetNonceSize";
64
64
  PortalErrorCodes[PortalErrorCodes["FailedToDecryptCipher"] = 407] = "FailedToDecryptCipher";
65
- })(PortalErrorCodes = exports.PortalErrorCodes || (exports.PortalErrorCodes = {}));
65
+ })(PortalErrorCodes || (exports.PortalErrorCodes = PortalErrorCodes = {}));
66
66
  exports.PortalErrorCodeTypes = {
67
67
  MpcErrors: Array.from({ length: 100 }, (_, i) => i + 100),
68
68
  NetworkErrors: Array.from({ length: 100 }, (_, i) => i + 200),
@@ -8,7 +8,7 @@ var RpcErrorCodes;
8
8
  RpcErrorCodes[RpcErrorCodes["UnsupportedMethod"] = 4200] = "UnsupportedMethod";
9
9
  RpcErrorCodes[RpcErrorCodes["Disconnected"] = 4900] = "Disconnected";
10
10
  RpcErrorCodes[RpcErrorCodes["ChainDisconnected"] = 4901] = "ChainDisconnected";
11
- })(RpcErrorCodes = exports.RpcErrorCodes || (exports.RpcErrorCodes = {}));
11
+ })(RpcErrorCodes || (exports.RpcErrorCodes = RpcErrorCodes = {}));
12
12
  const providerErrors = {
13
13
  4001: {
14
14
  name: 'User Rejected Request',
@@ -11,6 +11,7 @@ var Events;
11
11
  Events["GetBackupShareMetadata"] = "Get Backup Share Metadata";
12
12
  Events["GetBalances"] = "Get Balances";
13
13
  Events["GetClient"] = "Get Client";
14
+ Events["GetClientCipherText"] = "Get Client Cipher Text";
14
15
  Events["GetEnabledDapps"] = "Get Enabled Dapps";
15
16
  Events["GetNFTs"] = "Get NFTs";
16
17
  Events["GetNetworks"] = "Get Networks";
@@ -18,7 +19,9 @@ var Events;
18
19
  Events["GetSigningShareMetadata"] = "Get Signing Share Metadata";
19
20
  Events["GetSources"] = "Get Sources";
20
21
  Events["GetTransactions"] = "Get Transactions";
22
+ Events["PrepareClientEject"] = "Prepare Client Eject";
21
23
  Events["SimulateTransaction"] = "Simulate Transaction";
24
+ Events["StoreClientCipherText"] = "Store Client Cipher Text";
22
25
  Events["StoredClientBackupShare"] = "Stored Client Backup Share";
23
26
  Events["StoredClientBackupShareKey"] = "Stored Client Backup Share Key";
24
27
  Events["StoredClientSigningShare"] = "Stored Client Signing Share";
@@ -1 +1 @@
1
- { "version": "4.1.0" }
1
+ { "version": "4.1.1" }
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { countryCodes, currencyCodes } from './countries';
11
- export const convert = (value, from = 'ETH', countryCode) => __awaiter(void 0, void 0, void 0, function* () {
11
+ export const convert = (value_1, ...args_1) => __awaiter(void 0, [value_1, ...args_1], void 0, function* (value, from = 'ETH', countryCode) {
12
12
  const country = countryCodes[countryCode || 'US'];
13
13
  if (!country) {
14
14
  throw new Error(`Unable to find country name for country code: ${countryCode}.`);
@@ -23,7 +23,7 @@ export const convert = (value, from = 'ETH', countryCode) => __awaiter(void 0, v
23
23
  const convertedValue = Math.round((value / (1 / data[to]) + Number.EPSILON) * 10000) / 10000;
24
24
  return convertedValue;
25
25
  });
26
- export const convertCryptoToLocal = (value, from = 'ETH', countryCode) => __awaiter(void 0, void 0, void 0, function* () {
26
+ export const convertCryptoToLocal = (value_1, ...args_1) => __awaiter(void 0, [value_1, ...args_1], void 0, function* (value, from = 'ETH', countryCode) {
27
27
  const country = countryCodes[countryCode || 'US'];
28
28
  if (!country) {
29
29
  throw new Error(`Unable to find country name for country code: ${countryCode}.`);
@@ -38,7 +38,7 @@ export const convertCryptoToLocal = (value, from = 'ETH', countryCode) => __awai
38
38
  const convertedValue = Math.round(value * data[to] * 10000) / 10000;
39
39
  return convertedValue;
40
40
  });
41
- export const convertLocalToCrypto = (value, to = 'ETH', countryCode) => __awaiter(void 0, void 0, void 0, function* () {
41
+ export const convertLocalToCrypto = (value_1, ...args_1) => __awaiter(void 0, [value_1, ...args_1], void 0, function* (value, to = 'ETH', countryCode) {
42
42
  const country = countryCodes[countryCode || 'US'];
43
43
  if (!country) {
44
44
  throw new Error(`Unable to find country name for country code: ${countryCode}.`);
@@ -9,6 +9,7 @@ var Events;
9
9
  Events["GetBackupShareMetadata"] = "Get Backup Share Metadata";
10
10
  Events["GetBalances"] = "Get Balances";
11
11
  Events["GetClient"] = "Get Client";
12
+ Events["GetClientCipherText"] = "Get Client Cipher Text";
12
13
  Events["GetEnabledDapps"] = "Get Enabled Dapps";
13
14
  Events["GetNFTs"] = "Get NFTs";
14
15
  Events["GetNetworks"] = "Get Networks";
@@ -16,7 +17,9 @@ var Events;
16
17
  Events["GetSigningShareMetadata"] = "Get Signing Share Metadata";
17
18
  Events["GetSources"] = "Get Sources";
18
19
  Events["GetTransactions"] = "Get Transactions";
20
+ Events["PrepareClientEject"] = "Prepare Client Eject";
19
21
  Events["SimulateTransaction"] = "Simulate Transaction";
22
+ Events["StoreClientCipherText"] = "Store Client Cipher Text";
20
23
  Events["StoredClientBackupShare"] = "Stored Client Backup Share";
21
24
  Events["StoredClientBackupShareKey"] = "Stored Client Backup Share Key";
22
25
  Events["StoredClientSigningShare"] = "Stored Client Signing Share";
@@ -1 +1 @@
1
- { "version": "4.1.0" }
1
+ { "version": "4.1.1" }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portal-hq/utils",
3
- "version": "4.1.0",
3
+ "version": "4.1.1",
4
4
  "main": "lib/commonjs/index",
5
5
  "module": "lib/esm/index",
6
6
  "source": "src/index",
@@ -26,5 +26,5 @@
26
26
  "ts-jest": "^29.0.3",
27
27
  "typescript": "^4.8.4"
28
28
  },
29
- "gitHead": "d53139e2dae6d0ede12d647ae4d11f4915b896f1"
29
+ "gitHead": "3c03bd4a6573b23865f655856cd0161706f3f30d"
30
30
  }
@@ -26,6 +26,7 @@ import type {
26
26
  } from '../../types'
27
27
  import PortalRequests from '../PortalRequests'
28
28
  import { HttpRequester } from '../requesters'
29
+ import { BackupMethodsUpperCase } from '@portal-hq/core/src/mpc'
29
30
 
30
31
  export type EventHandler = (data: any) => void
31
32
 
@@ -55,7 +56,6 @@ export interface IPortalApi {
55
56
  apiKey: string
56
57
  apiUrl: string
57
58
  requests: HttpRequester
58
-
59
59
  buildTransaction(
60
60
  to: string,
61
61
  token: string,
@@ -65,6 +65,7 @@ export interface IPortalApi {
65
65
  getBackupSharesMetadata(chainId?: string): Promise<BackupSharePairMetadata[]>
66
66
  getBalances(chainId?: string): Promise<Balance[]>
67
67
  getClient(): Promise<ClientResponse>
68
+ getClientCipherText(backupSharePairId: string): Promise<string>
68
69
  getEnabledDapps(): Promise<Dapp[]>
69
70
  getNFTs(chainId?: string): Promise<NFT[]>
70
71
  getNetworks(): Promise<Network[]>
@@ -83,11 +84,19 @@ export interface IPortalApi {
83
84
  offset?: number,
84
85
  order?: GetTransactionsOrder,
85
86
  ): Promise<Transaction[]>
87
+ prepareClientEject(
88
+ walletId: string,
89
+ backupMethod: BackupMethodsUpperCase,
90
+ ): Promise<string>
86
91
  identify(traits?: Record<string, any>): Promise<{ success: boolean }>
87
92
  simulateTransaction(
88
93
  params: SimulateTransactionParam,
89
94
  chainId?: string,
90
95
  ): Promise<SimulatedTransaction>
96
+ storeClientCipherText(
97
+ backupSharePairId: string,
98
+ cipherText: string,
99
+ ): Promise<boolean>
91
100
  storedClientSigningShares(signingSharePairIds: string[]): Promise<void>
92
101
  storedClientBackupShares(backupSharePairIds: string[]): Promise<void>
93
102
  storedClientBackupSharesKey(backupSharePairIds: string[]): Promise<void>
@@ -9,6 +9,7 @@ enum Events {
9
9
  GetBackupShareMetadata = 'Get Backup Share Metadata',
10
10
  GetBalances = 'Get Balances',
11
11
  GetClient = 'Get Client',
12
+ GetClientCipherText = 'Get Client Cipher Text',
12
13
  GetEnabledDapps = 'Get Enabled Dapps',
13
14
  GetNFTs = 'Get NFTs',
14
15
  GetNetworks = 'Get Networks',
@@ -16,7 +17,9 @@ enum Events {
16
17
  GetSigningShareMetadata = 'Get Signing Share Metadata',
17
18
  GetSources = 'Get Sources',
18
19
  GetTransactions = 'Get Transactions',
20
+ PrepareClientEject = 'Prepare Client Eject',
19
21
  SimulateTransaction = 'Simulate Transaction',
22
+ StoreClientCipherText = 'Store Client Cipher Text',
20
23
  StoredClientBackupShare = 'Stored Client Backup Share',
21
24
  StoredClientBackupShareKey = 'Stored Client Backup Share Key',
22
25
  StoredClientSigningShare = 'Stored Client Signing Share',
@@ -1 +1 @@
1
- { "version": "4.1.0" }
1
+ { "version": "4.1.1" }
package/types.d.ts CHANGED
@@ -46,6 +46,7 @@ interface ClientResponseCustodian {
46
46
  interface ClientResponseEnvironment {
47
47
  id: string
48
48
  name: string
49
+ backupWithPortalEnabled?: boolean
49
50
  }
50
51
 
51
52
  interface ClientResponseMetadata {