@portal-hq/web 3.1.0 → 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.
@@ -155,13 +155,19 @@ class Portal {
155
155
  return this.recoverWallet(cipherText, backupMethod, backupConfigs, progress);
156
156
  });
157
157
  }
158
- eject(clientBackupCipherText, backupMethod, backupConfigs, orgBackupShare) {
158
+ eject(backupMethod, backupConfigs, orgBackupShare = '', clientBackupCipherText = '') {
159
159
  return __awaiter(this, void 0, void 0, function* () {
160
- if (clientBackupCipherText === '') {
161
- 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.');
162
163
  }
163
- if (orgBackupShare === '') {
164
- 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
+ }
165
171
  }
166
172
  const { SECP256K1, ED25519 } = yield this.mpc.eject({
167
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.1.0';
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
@@ -149,13 +149,19 @@ class Portal {
149
149
  return this.recoverWallet(cipherText, backupMethod, backupConfigs, progress);
150
150
  });
151
151
  }
152
- eject(clientBackupCipherText, backupMethod, backupConfigs, orgBackupShare) {
152
+ eject(backupMethod, backupConfigs, orgBackupShare = '', clientBackupCipherText = '') {
153
153
  return __awaiter(this, void 0, void 0, function* () {
154
- if (clientBackupCipherText === '') {
155
- 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.');
156
157
  }
157
- if (orgBackupShare === '') {
158
- 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
+ }
159
165
  }
160
166
  const { SECP256K1, ED25519 } = yield this.mpc.eject({
161
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.1.0';
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.1.0",
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
@@ -224,17 +224,23 @@ class Portal {
224
224
  }
225
225
 
226
226
  public async eject(
227
- clientBackupCipherText: string,
228
227
  backupMethod: BackupMethods,
229
228
  backupConfigs: BackupConfigs,
230
- orgBackupShare: string,
229
+ orgBackupShare: string = '',
230
+ clientBackupCipherText: string = '',
231
231
  ): Promise<EjectResult> {
232
- if (clientBackupCipherText === '') {
233
- 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.')
234
235
  }
235
236
 
236
- if (orgBackupShare === '') {
237
- 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
+ }
238
244
  }
239
245
 
240
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.1.0'
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
@@ -78,6 +78,7 @@ export interface ClientResponse {
78
78
  address: string
79
79
  backupStatus?: string | null
80
80
  custodian: ClientResponseCustodian
81
+ environment: ClientResponseEnvironment
81
82
  ejectedAt: string | null
82
83
  isAccountAbstracted: boolean
83
84
  metadata: ClientResponseMetadata
@@ -88,6 +89,13 @@ interface ClientResponseCustodian {
88
89
  id: string
89
90
  name: string
90
91
  }
92
+
93
+ interface ClientResponseEnvironment {
94
+ id: string
95
+ name: string
96
+ backupWithPortalEnabled: boolean
97
+ }
98
+
91
99
  interface ClientResponseMetadata {
92
100
  namespaces: ClientNamespaceMetadata
93
101
  }
@@ -102,12 +110,17 @@ interface ClientResponseSharePair {
102
110
  status: SharePairStatus
103
111
  }
104
112
 
113
+ interface ClientResponseBackupSharePair extends ClientResponseSharePair {
114
+ backupMethod: BackupMethods
115
+ }
116
+
105
117
  export interface ClientResponseWallet {
106
118
  id: string
107
119
  createdAt: string
108
120
 
109
- backupSharePairs: ClientResponseSharePair[]
121
+ backupSharePairs: ClientResponseBackupSharePair[]
110
122
  curve: WalletCurve
123
+ ejectableUntil?: string
111
124
  publicKey: string
112
125
  signingSharePairs: ClientResponseShairPair[]
113
126
  }