@portal-hq/web 3.3.4-beta.3 → 3.3.5-alpha

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/src/mpc/index.ts CHANGED
@@ -11,7 +11,7 @@ import type {
11
11
  BackupResponse,
12
12
  Balance,
13
13
  ClientResponse,
14
- EjectArgs,
14
+ EjectArgs as EjectArgs,
15
15
  GenerateArgs,
16
16
  IframeConfigurationOptions,
17
17
  MpcOptions,
@@ -35,9 +35,11 @@ import type {
35
35
  NFTAsset,
36
36
  Asset,
37
37
  BuiltTransaction,
38
+ EjectPrivateKeysArgs,
39
+ EjectPrivateKeysResult,
38
40
  } from '../../types'
39
41
 
40
- const WEB_SDK_VERSION = '3.3.4-beta.3'
42
+ const WEB_SDK_VERSION = '3.3.5-alpha'
41
43
 
42
44
  class Mpc {
43
45
  public iframe?: HTMLIFrameElement
@@ -359,6 +361,41 @@ class Mpc {
359
361
  })
360
362
  }
361
363
 
364
+ public async ejectPrivateKeys(
365
+ data: EjectPrivateKeysArgs,
366
+ ): Promise<EjectPrivateKeysResult> {
367
+ return new Promise((resolve, reject) => {
368
+ const handleEject = (message: MessageEvent<WorkerResult>) => {
369
+ const { type, data: result } = message.data
370
+ const { origin } = message
371
+
372
+ // ignore any broadcast postMessages
373
+ if (origin !== this.getOrigin()) {
374
+ return
375
+ }
376
+
377
+ if (type === 'portal:wasm:ejectPrivateKeysError') {
378
+ // Remove the event listeners
379
+ window.removeEventListener('message', handleEject)
380
+
381
+ reject(new PortalMpcError(result as PortalError))
382
+ } else if (type === 'portal:wasm:ejectPrivateKeysResult') {
383
+ // Remove the event listeners
384
+ window.removeEventListener('message', handleEject)
385
+
386
+ resolve(result as EjectPrivateKeysResult)
387
+ }
388
+ }
389
+
390
+ window.addEventListener('message', handleEject)
391
+
392
+ this.postMessage({
393
+ type: 'portal:wasm:ejectPrivateKeys',
394
+ data,
395
+ })
396
+ })
397
+ }
398
+
362
399
  public async rawSign(curve: PortalCurve, param: string): Promise<string> {
363
400
  return new Promise((resolve, reject) => {
364
401
  const handleRawSign = (event: MessageEvent<WorkerResult>) => {
package/types.d.ts CHANGED
@@ -35,6 +35,11 @@ export interface BackupConfigs {
35
35
  passwordStorage?: PasswordConfig
36
36
  }
37
37
 
38
+ export interface OrgBackupShares {
39
+ SECP256K1: string
40
+ ED25519?: string
41
+ }
42
+
38
43
  export interface PasswordConfig {
39
44
  password: string
40
45
  }
@@ -169,6 +174,10 @@ export interface EIP1559Transaction {
169
174
  }
170
175
 
171
176
  export interface EjectResult {
177
+ SECP256K1: string
178
+ }
179
+
180
+ export interface EjectPrivateKeysResult {
172
181
  ED25519: string
173
182
  SECP256K1: string
174
183
  }
@@ -209,6 +218,10 @@ export interface EjectArgs extends RecoverArgs {
209
218
  organizationBackupShare: string
210
219
  }
211
220
 
221
+ export interface EjectPrivateKeysArgs extends RecoverArgs {
222
+ organizationBackupShares: OrgBackupShares
223
+ }
224
+
212
225
  export interface EjectWorkerArgs extends MpcOperationArgs {
213
226
  clientShare: string
214
227
  organizationBackupShare: string