@portal-hq/web 3.0.2 → 3.2.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.
@@ -21,9 +21,7 @@ class Portal {
21
21
  // Required
22
22
  rpcConfig,
23
23
  // Optional
24
- apiKey, authToken, authUrl, autoApprove = false, gdrive, passkey, host = 'web.portalhq.io', mpcVersion = 'v6', mpcHost = 'mpc-client.portalhq.io', featureFlags = {
25
- optimized: false,
26
- }, }) {
24
+ apiKey, authToken, authUrl, autoApprove = false, gdrive, passkey, host = 'web.portalhq.io', mpcVersion = 'v6', mpcHost = 'mpc-client.portalhq.io', featureFlags = {}, }) {
27
25
  this.ready = false;
28
26
  this.errorCallbacks = [];
29
27
  this.readyCallbacks = [];
@@ -157,13 +155,19 @@ class Portal {
157
155
  return this.recoverWallet(cipherText, backupMethod, backupConfigs, progress);
158
156
  });
159
157
  }
160
- eject(clientBackupCipherText, backupMethod, backupConfigs, orgBackupShare) {
158
+ eject(backupMethod, backupConfigs, orgBackupShare = '', clientBackupCipherText = '') {
161
159
  return __awaiter(this, void 0, void 0, function* () {
162
- if (clientBackupCipherText === '') {
163
- throw new Error('clientBackupCipherText cannot be empty string.');
160
+ const client = yield this.mpc.getClient();
161
+ if (!client) {
162
+ throw new Error('Client not found.');
164
163
  }
165
- if (orgBackupShare === '') {
166
- throw new Error('orgBackupShare cannot be empty string.');
164
+ if (!client.environment.backupWithPortalEnabled) {
165
+ if (clientBackupCipherText === '') {
166
+ throw new Error('clientBackupCipherText cannot be empty string.');
167
+ }
168
+ if (orgBackupShare === '') {
169
+ throw new Error('orgBackupShare cannot be empty string.');
170
+ }
167
171
  }
168
172
  const { SECP256K1, ED25519 } = yield this.mpc.eject({
169
173
  cipherText: clientBackupCipherText,
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MpcErrorCodes = exports.MpcError = void 0;
13
13
  const errors_1 = require("./errors");
14
14
  const index_1 = require("../index");
15
- const WEB_SDK_VERSION = '3.0.2';
15
+ const WEB_SDK_VERSION = '3.2.0';
16
16
  class Mpc {
17
17
  constructor({ portal }) {
18
18
  this.configureIframe = () => {
package/lib/esm/index.js CHANGED
@@ -15,9 +15,7 @@ class Portal {
15
15
  // Required
16
16
  rpcConfig,
17
17
  // Optional
18
- apiKey, authToken, authUrl, autoApprove = false, gdrive, passkey, host = 'web.portalhq.io', mpcVersion = 'v6', mpcHost = 'mpc-client.portalhq.io', featureFlags = {
19
- optimized: false,
20
- }, }) {
18
+ apiKey, authToken, authUrl, autoApprove = false, gdrive, passkey, host = 'web.portalhq.io', mpcVersion = 'v6', mpcHost = 'mpc-client.portalhq.io', featureFlags = {}, }) {
21
19
  this.ready = false;
22
20
  this.errorCallbacks = [];
23
21
  this.readyCallbacks = [];
@@ -151,13 +149,19 @@ class Portal {
151
149
  return this.recoverWallet(cipherText, backupMethod, backupConfigs, progress);
152
150
  });
153
151
  }
154
- eject(clientBackupCipherText, backupMethod, backupConfigs, orgBackupShare) {
152
+ eject(backupMethod, backupConfigs, orgBackupShare = '', clientBackupCipherText = '') {
155
153
  return __awaiter(this, void 0, void 0, function* () {
156
- if (clientBackupCipherText === '') {
157
- throw new Error('clientBackupCipherText cannot be empty string.');
154
+ const client = yield this.mpc.getClient();
155
+ if (!client) {
156
+ throw new Error('Client not found.');
158
157
  }
159
- if (orgBackupShare === '') {
160
- throw new Error('orgBackupShare cannot be empty string.');
158
+ if (!client.environment.backupWithPortalEnabled) {
159
+ if (clientBackupCipherText === '') {
160
+ throw new Error('clientBackupCipherText cannot be empty string.');
161
+ }
162
+ if (orgBackupShare === '') {
163
+ throw new Error('orgBackupShare cannot be empty string.');
164
+ }
161
165
  }
162
166
  const { SECP256K1, ED25519 } = yield this.mpc.eject({
163
167
  cipherText: clientBackupCipherText,
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { PortalMpcError } from './errors';
11
11
  import { BackupMethods } from '../index';
12
- const WEB_SDK_VERSION = '3.0.2';
12
+ const WEB_SDK_VERSION = '3.2.0';
13
13
  class Mpc {
14
14
  constructor({ portal }) {
15
15
  this.configureIframe = () => {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Portal MPC Support for Web",
4
4
  "author": "Portal Labs, Inc.",
5
5
  "homepage": "https://portalhq.io/",
6
- "version": "3.0.2",
6
+ "version": "3.2.0",
7
7
  "license": "MIT",
8
8
  "main": "lib/commonjs/index",
9
9
  "module": "lib/esm/index",
package/src/index.ts CHANGED
@@ -65,9 +65,7 @@ class Portal {
65
65
  host = 'web.portalhq.io',
66
66
  mpcVersion = 'v6',
67
67
  mpcHost = 'mpc-client.portalhq.io',
68
- featureFlags = {
69
- optimized: false,
70
- },
68
+ featureFlags = {},
71
69
  }: PortalOptions) {
72
70
  this.apiKey = apiKey
73
71
  this.authToken = authToken
@@ -226,17 +224,23 @@ class Portal {
226
224
  }
227
225
 
228
226
  public async eject(
229
- clientBackupCipherText: string,
230
227
  backupMethod: BackupMethods,
231
228
  backupConfigs: BackupConfigs,
232
- orgBackupShare: string,
229
+ orgBackupShare: string = '',
230
+ clientBackupCipherText: string = '',
233
231
  ): Promise<EjectResult> {
234
- if (clientBackupCipherText === '') {
235
- throw new Error('clientBackupCipherText cannot be empty string.')
232
+ const client = await this.mpc.getClient()
233
+ if (!client) {
234
+ throw new Error('Client not found.')
236
235
  }
237
236
 
238
- if (orgBackupShare === '') {
239
- throw new Error('orgBackupShare cannot be empty string.')
237
+ if (!client.environment.backupWithPortalEnabled) {
238
+ if (clientBackupCipherText === '') {
239
+ throw new Error('clientBackupCipherText cannot be empty string.')
240
+ }
241
+ if (orgBackupShare === '') {
242
+ throw new Error('orgBackupShare cannot be empty string.')
243
+ }
240
244
  }
241
245
 
242
246
  const { SECP256K1, ED25519 } = await this.mpc.eject({
package/src/mpc/index.ts CHANGED
@@ -26,7 +26,7 @@ import type {
26
26
  EjectResult,
27
27
  } from '../../types'
28
28
 
29
- const WEB_SDK_VERSION = '3.0.2'
29
+ const WEB_SDK_VERSION = '3.2.0'
30
30
 
31
31
  class Mpc {
32
32
  public iframe?: HTMLIFrameElement
package/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { type DkgData, PortalError } from '@portal-hq/utils'
2
2
  import type { MpcErrorCodes } from './src/mpc/errors'
3
3
 
4
- import Portal from './src/index'
4
+ import Portal, { BackupMethods } from './src/index'
5
5
 
6
6
  export type EventHandler = (event: Event<any>) => void | Promise<void>
7
7
  export type EthereumTransaction = EIP1559Transaction | LegacyTransaction
@@ -18,7 +18,6 @@ export type ValidRpcErrorCodes = 4001 | 4100 | 4200 | 4900 | 4901
18
18
 
19
19
  export interface FeatureFlags {
20
20
  isMultiBackupEnabled?: boolean
21
- optimized: boolean = false
22
21
  }
23
22
 
24
23
  export interface AddressResult {
@@ -79,6 +78,7 @@ export interface ClientResponse {
79
78
  address: string
80
79
  backupStatus?: string | null
81
80
  custodian: ClientResponseCustodian
81
+ environment: ClientResponseEnvironment
82
82
  ejectedAt: string | null
83
83
  isAccountAbstracted: boolean
84
84
  metadata: ClientResponseMetadata
@@ -89,6 +89,13 @@ interface ClientResponseCustodian {
89
89
  id: string
90
90
  name: string
91
91
  }
92
+
93
+ interface ClientResponseEnvironment {
94
+ id: string
95
+ name: string
96
+ backupWithPortalEnabled: boolean
97
+ }
98
+
92
99
  interface ClientResponseMetadata {
93
100
  namespaces: ClientNamespaceMetadata
94
101
  }
@@ -103,12 +110,17 @@ interface ClientResponseSharePair {
103
110
  status: SharePairStatus
104
111
  }
105
112
 
113
+ interface ClientResponseBackupSharePair extends ClientResponseSharePair {
114
+ backupMethod: BackupMethods
115
+ }
116
+
106
117
  export interface ClientResponseWallet {
107
118
  id: string
108
119
  createdAt: string
109
120
 
110
- backupSharePairs: ClientResponseSharePair[]
121
+ backupSharePairs: ClientResponseBackupSharePair[]
111
122
  curve: WalletCurve
123
+ ejectableUntil?: string
112
124
  publicKey: string
113
125
  signingSharePairs: ClientResponseShairPair[]
114
126
  }