@portal-hq/web 0.1.0 → 0.1.2-rcf

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.
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.BackupMethods = exports.MpcStatuses = exports.MpcErrorCodes = exports.MpcError = void 0;
15
+ exports.GetTransactionsOrder = exports.BackupMethods = exports.MpcStatuses = exports.MpcErrorCodes = exports.MpcError = void 0;
16
16
  const mpc_1 = __importDefault(require("./mpc"));
17
17
  const provider_1 = __importDefault(require("./provider"));
18
18
  class Portal {
@@ -20,7 +20,7 @@ class Portal {
20
20
  // Required
21
21
  gatewayConfig,
22
22
  // Optional
23
- apiKey, authToken, authUrl, autoApprove = false, chainId = 1, gdrive, host = 'web.portalhq.io', mpcVersion = 'v5', featureFlags = {
23
+ apiKey, authToken, authUrl, autoApprove = false, chainId = 1, gdrive, passkey, host = 'web.portalhq.io', mpcVersion = 'v6', featureFlags = {
24
24
  optimized: false,
25
25
  }, }) {
26
26
  this.ready = false;
@@ -38,6 +38,9 @@ class Portal {
38
38
  if (gdrive) {
39
39
  this.gDriveConfig = gdrive;
40
40
  }
41
+ else if (passkey) {
42
+ this.passkeyConfig = passkey;
43
+ }
41
44
  this.mpc = new mpc_1.default({
42
45
  portal: this,
43
46
  });
@@ -117,7 +120,7 @@ class Portal {
117
120
  return cipherText;
118
121
  });
119
122
  }
120
- recoverWallet(cipherText, backupMethod, backupConfigs, progress = () => {
123
+ recoverWallet(cipherText, backupMethod, backupConfigs = {}, progress = () => {
121
124
  // Noop
122
125
  }) {
123
126
  return __awaiter(this, void 0, void 0, function* () {
@@ -129,6 +132,7 @@ class Portal {
129
132
  mpcVersion: this.mpcVersion,
130
133
  featureFlags: this.featureFlags,
131
134
  }, progress);
135
+ this.address = address;
132
136
  return address;
133
137
  });
134
138
  }
@@ -281,6 +285,18 @@ class Portal {
281
285
  return (_a = this.mpc) === null || _a === void 0 ? void 0 : _a.getNFTs();
282
286
  });
283
287
  }
288
+ getBackupShareMetadata() {
289
+ var _a;
290
+ return __awaiter(this, void 0, void 0, function* () {
291
+ return (_a = this.mpc) === null || _a === void 0 ? void 0 : _a.getBackupShareMetadata();
292
+ });
293
+ }
294
+ getSigningShareMetadata() {
295
+ var _a;
296
+ return __awaiter(this, void 0, void 0, function* () {
297
+ return (_a = this.mpc) === null || _a === void 0 ? void 0 : _a.getSigningShareMetadata();
298
+ });
299
+ }
284
300
  getTransactions(limit, offset, order, chainId) {
285
301
  var _a;
286
302
  return __awaiter(this, void 0, void 0, function* () {
@@ -311,10 +327,10 @@ class Portal {
311
327
  /*******************************
312
328
  * Wallet Safeguarding Methods
313
329
  *******************************/
314
- storedClientBackupShare(status) {
330
+ storedClientBackupShare(success, backupMethod) {
315
331
  var _a;
316
332
  return __awaiter(this, void 0, void 0, function* () {
317
- return yield ((_a = this.mpc) === null || _a === void 0 ? void 0 : _a.storedClientBackupShare(status));
333
+ return yield ((_a = this.mpc) === null || _a === void 0 ? void 0 : _a.storedClientBackupShare(success, backupMethod));
318
334
  });
319
335
  }
320
336
  /****************************
@@ -374,5 +390,12 @@ var BackupMethods;
374
390
  (function (BackupMethods) {
375
391
  BackupMethods["gdrive"] = "GDRIVE";
376
392
  BackupMethods["password"] = "PASSWORD";
393
+ BackupMethods["passkey"] = "PASSKEY";
394
+ BackupMethods["unknown"] = "UNKNOWN";
377
395
  })(BackupMethods = exports.BackupMethods || (exports.BackupMethods = {}));
396
+ var GetTransactionsOrder;
397
+ (function (GetTransactionsOrder) {
398
+ GetTransactionsOrder["ASC"] = "asc";
399
+ GetTransactionsOrder["DESC"] = "desc";
400
+ })(GetTransactionsOrder = exports.GetTransactionsOrder || (exports.GetTransactionsOrder = {}));
378
401
  exports.default = Portal;
@@ -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 = '0.1.0';
15
+ const WEB_SDK_VERSION = '0.1.2-rcf';
16
16
  class Mpc {
17
17
  constructor({ portal }) {
18
18
  this.configureIframe = () => {
@@ -23,6 +23,7 @@ class Mpc {
23
23
  autoApprove: this.portal.autoApprove,
24
24
  chainId: this.portal.chainId,
25
25
  gdrive: this.portal.gDriveConfig,
26
+ passkey: this.portal.passkeyConfig,
26
27
  host: this.portal.host,
27
28
  rpcUrl: this.portal.getRpcUrl(),
28
29
  featureFlags: this.portal.featureFlags,
@@ -617,7 +618,7 @@ class Mpc {
617
618
  });
618
619
  });
619
620
  }
620
- storedClientBackupShare(success) {
621
+ storedClientBackupShare(success, backupMethod) {
621
622
  return new Promise((resolve, reject) => {
622
623
  const handleStoredClientBackupShare = (event) => {
623
624
  const { type, data } = event.data;
@@ -644,7 +645,76 @@ class Mpc {
644
645
  // Send the request to the iframe
645
646
  this.postMessage({
646
647
  type: 'portal:storedClientBackupShare',
647
- data: success,
648
+ data: {
649
+ success,
650
+ backupMethod,
651
+ },
652
+ });
653
+ });
654
+ }
655
+ getBackupShareMetadata() {
656
+ return __awaiter(this, void 0, void 0, function* () {
657
+ return new Promise((resolve, reject) => {
658
+ const handleGetBackupShareMetadata = (event) => {
659
+ const { type, data } = event.data;
660
+ const { origin } = event;
661
+ // ignore any broadcast postMessages
662
+ if (origin !== this.getOrigin()) {
663
+ return;
664
+ }
665
+ if (type === 'portal:getBackupShareMetadataError') {
666
+ // Remove the event listener
667
+ window.removeEventListener('message', handleGetBackupShareMetadata);
668
+ // Reject the promise with the error
669
+ return reject(new errors_1.PortalMpcError(data));
670
+ }
671
+ else if (type === 'portal:getBackupShareMetadataResult') {
672
+ // Remove the event listener
673
+ window.removeEventListener('message', handleGetBackupShareMetadata);
674
+ // Resolve the promise with the result
675
+ resolve(data);
676
+ }
677
+ };
678
+ // Bind the function to the message event
679
+ window.addEventListener('message', handleGetBackupShareMetadata);
680
+ // Send the request to the iframe
681
+ this.postMessage({
682
+ type: 'portal:getBackupShareMetadata',
683
+ data: {},
684
+ });
685
+ });
686
+ });
687
+ }
688
+ getSigningShareMetadata() {
689
+ return __awaiter(this, void 0, void 0, function* () {
690
+ return new Promise((resolve, reject) => {
691
+ const handleGetSigningShareMetadata = (event) => {
692
+ const { type, data } = event.data;
693
+ const { origin } = event;
694
+ // ignore any broadcast postMessages
695
+ if (origin !== this.getOrigin()) {
696
+ return;
697
+ }
698
+ if (type === 'portal:getSigningShareMetadataError') {
699
+ // Remove the event listener
700
+ window.removeEventListener('message', handleGetSigningShareMetadata);
701
+ // Reject the promise with the error
702
+ return reject(new errors_1.PortalMpcError(data));
703
+ }
704
+ else if (type === 'portal:getSigningShareMetadataResult') {
705
+ // Remove the event listener
706
+ window.removeEventListener('message', handleGetSigningShareMetadata);
707
+ // Resolve the promise with the result
708
+ resolve(data);
709
+ }
710
+ };
711
+ // Bind the function to the message event
712
+ window.addEventListener('message', handleGetSigningShareMetadata);
713
+ // Send the request to the iframe
714
+ this.postMessage({
715
+ type: 'portal:getSigningShareMetadata',
716
+ data: {},
717
+ });
648
718
  });
649
719
  });
650
720
  }
package/lib/esm/index.js CHANGED
@@ -14,7 +14,7 @@ class Portal {
14
14
  // Required
15
15
  gatewayConfig,
16
16
  // Optional
17
- apiKey, authToken, authUrl, autoApprove = false, chainId = 1, gdrive, host = 'web.portalhq.io', mpcVersion = 'v5', featureFlags = {
17
+ apiKey, authToken, authUrl, autoApprove = false, chainId = 1, gdrive, passkey, host = 'web.portalhq.io', mpcVersion = 'v6', featureFlags = {
18
18
  optimized: false,
19
19
  }, }) {
20
20
  this.ready = false;
@@ -32,6 +32,9 @@ class Portal {
32
32
  if (gdrive) {
33
33
  this.gDriveConfig = gdrive;
34
34
  }
35
+ else if (passkey) {
36
+ this.passkeyConfig = passkey;
37
+ }
35
38
  this.mpc = new Mpc({
36
39
  portal: this,
37
40
  });
@@ -111,7 +114,7 @@ class Portal {
111
114
  return cipherText;
112
115
  });
113
116
  }
114
- recoverWallet(cipherText, backupMethod, backupConfigs, progress = () => {
117
+ recoverWallet(cipherText, backupMethod, backupConfigs = {}, progress = () => {
115
118
  // Noop
116
119
  }) {
117
120
  return __awaiter(this, void 0, void 0, function* () {
@@ -123,6 +126,7 @@ class Portal {
123
126
  mpcVersion: this.mpcVersion,
124
127
  featureFlags: this.featureFlags,
125
128
  }, progress);
129
+ this.address = address;
126
130
  return address;
127
131
  });
128
132
  }
@@ -275,6 +279,18 @@ class Portal {
275
279
  return (_a = this.mpc) === null || _a === void 0 ? void 0 : _a.getNFTs();
276
280
  });
277
281
  }
282
+ getBackupShareMetadata() {
283
+ var _a;
284
+ return __awaiter(this, void 0, void 0, function* () {
285
+ return (_a = this.mpc) === null || _a === void 0 ? void 0 : _a.getBackupShareMetadata();
286
+ });
287
+ }
288
+ getSigningShareMetadata() {
289
+ var _a;
290
+ return __awaiter(this, void 0, void 0, function* () {
291
+ return (_a = this.mpc) === null || _a === void 0 ? void 0 : _a.getSigningShareMetadata();
292
+ });
293
+ }
278
294
  getTransactions(limit, offset, order, chainId) {
279
295
  var _a;
280
296
  return __awaiter(this, void 0, void 0, function* () {
@@ -305,10 +321,10 @@ class Portal {
305
321
  /*******************************
306
322
  * Wallet Safeguarding Methods
307
323
  *******************************/
308
- storedClientBackupShare(status) {
324
+ storedClientBackupShare(success, backupMethod) {
309
325
  var _a;
310
326
  return __awaiter(this, void 0, void 0, function* () {
311
- return yield ((_a = this.mpc) === null || _a === void 0 ? void 0 : _a.storedClientBackupShare(status));
327
+ return yield ((_a = this.mpc) === null || _a === void 0 ? void 0 : _a.storedClientBackupShare(success, backupMethod));
312
328
  });
313
329
  }
314
330
  /****************************
@@ -366,5 +382,12 @@ export var BackupMethods;
366
382
  (function (BackupMethods) {
367
383
  BackupMethods["gdrive"] = "GDRIVE";
368
384
  BackupMethods["password"] = "PASSWORD";
385
+ BackupMethods["passkey"] = "PASSKEY";
386
+ BackupMethods["unknown"] = "UNKNOWN";
369
387
  })(BackupMethods || (BackupMethods = {}));
388
+ export var GetTransactionsOrder;
389
+ (function (GetTransactionsOrder) {
390
+ GetTransactionsOrder["ASC"] = "asc";
391
+ GetTransactionsOrder["DESC"] = "desc";
392
+ })(GetTransactionsOrder || (GetTransactionsOrder = {}));
370
393
  export default Portal;
@@ -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 = '0.1.0';
12
+ const WEB_SDK_VERSION = '0.1.2-rcf';
13
13
  class Mpc {
14
14
  constructor({ portal }) {
15
15
  this.configureIframe = () => {
@@ -20,6 +20,7 @@ class Mpc {
20
20
  autoApprove: this.portal.autoApprove,
21
21
  chainId: this.portal.chainId,
22
22
  gdrive: this.portal.gDriveConfig,
23
+ passkey: this.portal.passkeyConfig,
23
24
  host: this.portal.host,
24
25
  rpcUrl: this.portal.getRpcUrl(),
25
26
  featureFlags: this.portal.featureFlags,
@@ -614,7 +615,7 @@ class Mpc {
614
615
  });
615
616
  });
616
617
  }
617
- storedClientBackupShare(success) {
618
+ storedClientBackupShare(success, backupMethod) {
618
619
  return new Promise((resolve, reject) => {
619
620
  const handleStoredClientBackupShare = (event) => {
620
621
  const { type, data } = event.data;
@@ -641,7 +642,76 @@ class Mpc {
641
642
  // Send the request to the iframe
642
643
  this.postMessage({
643
644
  type: 'portal:storedClientBackupShare',
644
- data: success,
645
+ data: {
646
+ success,
647
+ backupMethod,
648
+ },
649
+ });
650
+ });
651
+ }
652
+ getBackupShareMetadata() {
653
+ return __awaiter(this, void 0, void 0, function* () {
654
+ return new Promise((resolve, reject) => {
655
+ const handleGetBackupShareMetadata = (event) => {
656
+ const { type, data } = event.data;
657
+ const { origin } = event;
658
+ // ignore any broadcast postMessages
659
+ if (origin !== this.getOrigin()) {
660
+ return;
661
+ }
662
+ if (type === 'portal:getBackupShareMetadataError') {
663
+ // Remove the event listener
664
+ window.removeEventListener('message', handleGetBackupShareMetadata);
665
+ // Reject the promise with the error
666
+ return reject(new PortalMpcError(data));
667
+ }
668
+ else if (type === 'portal:getBackupShareMetadataResult') {
669
+ // Remove the event listener
670
+ window.removeEventListener('message', handleGetBackupShareMetadata);
671
+ // Resolve the promise with the result
672
+ resolve(data);
673
+ }
674
+ };
675
+ // Bind the function to the message event
676
+ window.addEventListener('message', handleGetBackupShareMetadata);
677
+ // Send the request to the iframe
678
+ this.postMessage({
679
+ type: 'portal:getBackupShareMetadata',
680
+ data: {},
681
+ });
682
+ });
683
+ });
684
+ }
685
+ getSigningShareMetadata() {
686
+ return __awaiter(this, void 0, void 0, function* () {
687
+ return new Promise((resolve, reject) => {
688
+ const handleGetSigningShareMetadata = (event) => {
689
+ const { type, data } = event.data;
690
+ const { origin } = event;
691
+ // ignore any broadcast postMessages
692
+ if (origin !== this.getOrigin()) {
693
+ return;
694
+ }
695
+ if (type === 'portal:getSigningShareMetadataError') {
696
+ // Remove the event listener
697
+ window.removeEventListener('message', handleGetSigningShareMetadata);
698
+ // Reject the promise with the error
699
+ return reject(new PortalMpcError(data));
700
+ }
701
+ else if (type === 'portal:getSigningShareMetadataResult') {
702
+ // Remove the event listener
703
+ window.removeEventListener('message', handleGetSigningShareMetadata);
704
+ // Resolve the promise with the result
705
+ resolve(data);
706
+ }
707
+ };
708
+ // Bind the function to the message event
709
+ window.addEventListener('message', handleGetSigningShareMetadata);
710
+ // Send the request to the iframe
711
+ this.postMessage({
712
+ type: 'portal:getSigningShareMetadata',
713
+ data: {},
714
+ });
645
715
  });
646
716
  });
647
717
  }
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": "0.1.0",
6
+ "version": "0.1.2-rcf",
7
7
  "license": "MIT",
8
8
  "main": "lib/commonjs/index",
9
9
  "module": "lib/esm/index",
@@ -46,4 +46,4 @@
46
46
  "webpack": "^5.87.0",
47
47
  "webpack-cli": "^5.1.4"
48
48
  }
49
- }
49
+ }
package/src/index.ts CHANGED
@@ -1,17 +1,19 @@
1
1
  import type {
2
2
  BackupConfigs,
3
+ BackupSharePairMetadata,
3
4
  Balance,
4
5
  ClientWithCustodianData,
5
6
  EthereumTransaction,
6
7
  FeatureFlags,
7
8
  GDriveConfig,
8
9
  GatewayLike,
9
- GetTransactionsOrder,
10
10
  NFT,
11
+ PasskeyConfig,
11
12
  PortalOptions,
12
13
  ProgressCallback,
13
14
  QuoteArgs,
14
15
  QuoteResponse,
16
+ SigningSharePairMetadata,
15
17
  SimulateTransactionParam,
16
18
  SimulatedTransaction,
17
19
  Transaction,
@@ -28,6 +30,7 @@ class Portal {
28
30
  public autoApprove: boolean
29
31
  public chainId: number
30
32
  public gDriveConfig?: GDriveConfig
33
+ public passkeyConfig?: PasskeyConfig
31
34
  public host: string
32
35
  public mpc: Mpc
33
36
  public mpcVersion: string
@@ -50,8 +53,9 @@ class Portal {
50
53
  autoApprove = false,
51
54
  chainId = 1,
52
55
  gdrive,
56
+ passkey,
53
57
  host = 'web.portalhq.io',
54
- mpcVersion = 'v5',
58
+ mpcVersion = 'v6',
55
59
  featureFlags = {
56
60
  optimized: false,
57
61
  },
@@ -68,6 +72,8 @@ class Portal {
68
72
 
69
73
  if (gdrive) {
70
74
  this.gDriveConfig = gdrive
75
+ } else if (passkey) {
76
+ this.passkeyConfig = passkey
71
77
  }
72
78
 
73
79
  this.mpc = new Mpc({
@@ -176,7 +182,7 @@ class Portal {
176
182
  public async recoverWallet(
177
183
  cipherText: string,
178
184
  backupMethod: BackupMethods,
179
- backupConfigs: BackupConfigs,
185
+ backupConfigs: BackupConfigs = {},
180
186
  progress: ProgressCallback = () => {
181
187
  // Noop
182
188
  },
@@ -193,6 +199,8 @@ class Portal {
193
199
  progress,
194
200
  )
195
201
 
202
+ this.address = address
203
+
196
204
  return address
197
205
  }
198
206
 
@@ -245,18 +253,16 @@ class Portal {
245
253
  if (orgBackupShare === '') {
246
254
  throw new Error('orgBackupShare cannot be empty string.')
247
255
  }
248
-
249
- const privateKey = await this.mpc.eject(
250
- {
251
- cipherText: clientBackupCiphertext,
252
- backupMethod,
253
- backupConfigs,
254
- organizationBackupShare: orgBackupShare,
255
- host: this.host,
256
- mpcVersion: this.mpcVersion,
257
- featureFlags: this.featureFlags,
258
- }
259
- )
256
+
257
+ const privateKey = await this.mpc.eject({
258
+ cipherText: clientBackupCiphertext,
259
+ backupMethod,
260
+ backupConfigs,
261
+ organizationBackupShare: orgBackupShare,
262
+ host: this.host,
263
+ mpcVersion: this.mpcVersion,
264
+ featureFlags: this.featureFlags,
265
+ })
260
266
 
261
267
  return privateKey
262
268
  }
@@ -355,6 +361,14 @@ class Portal {
355
361
  return this.mpc?.getNFTs()
356
362
  }
357
363
 
364
+ public async getBackupShareMetadata(): Promise<BackupSharePairMetadata[]> {
365
+ return this.mpc?.getBackupShareMetadata()
366
+ }
367
+
368
+ public async getSigningShareMetadata(): Promise<SigningSharePairMetadata[]> {
369
+ return this.mpc?.getSigningShareMetadata()
370
+ }
371
+
358
372
  public async getTransactions(
359
373
  limit?: number,
360
374
  offset?: number,
@@ -389,8 +403,11 @@ class Portal {
389
403
  * Wallet Safeguarding Methods
390
404
  *******************************/
391
405
 
392
- public async storedClientBackupShare(status: boolean): Promise<void> {
393
- return await this.mpc?.storedClientBackupShare(status)
406
+ public async storedClientBackupShare(
407
+ success: boolean,
408
+ backupMethod: BackupMethods,
409
+ ): Promise<void> {
410
+ return await this.mpc?.storedClientBackupShare(success, backupMethod)
394
411
  }
395
412
 
396
413
  /****************************
@@ -469,6 +486,13 @@ export enum MpcStatuses {
469
486
  export enum BackupMethods {
470
487
  gdrive = 'GDRIVE',
471
488
  password = 'PASSWORD',
489
+ passkey = 'PASSKEY',
490
+ unknown = 'UNKNOWN',
491
+ }
492
+
493
+ export enum GetTransactionsOrder {
494
+ ASC = 'asc',
495
+ DESC = 'desc',
472
496
  }
473
497
 
474
498
  export default Portal
package/src/mpc/index.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { PortalMpcError } from './errors'
2
2
 
3
- import Portal, { BackupMethods } from '../index'
3
+ import Portal, { BackupMethods, GetTransactionsOrder } from '../index'
4
4
  import type {
5
5
  BackupArgs,
6
+ BackupSharePairMetadata,
6
7
  Balance,
7
8
  ClientWithCustodianData,
8
9
  EjectArgs,
9
10
  GenerateArgs,
10
- GetTransactionsOrder,
11
11
  IframeConfigurationOptions,
12
12
  LegacyRecoverArgs,
13
13
  MpcOptions,
@@ -19,13 +19,14 @@ import type {
19
19
  QuoteResponse,
20
20
  RecoverArgs,
21
21
  SignArgs,
22
+ SigningSharePairMetadata,
22
23
  SimulateTransactionParam,
23
24
  SimulatedTransaction,
24
25
  Transaction,
25
26
  WorkerResult,
26
27
  } from '../../types'
27
28
 
28
- const WEB_SDK_VERSION = '0.1.0'
29
+ const WEB_SDK_VERSION = '0.1.2-rcf'
29
30
 
30
31
  class Mpc {
31
32
  public iframe?: HTMLIFrameElement
@@ -295,10 +296,7 @@ class Mpc {
295
296
  })
296
297
  }
297
298
 
298
-
299
- public async eject(
300
- data: EjectArgs,
301
- ): Promise<string> {
299
+ public async eject(data: EjectArgs): Promise<string> {
302
300
  return new Promise((resolve, reject) => {
303
301
  const handleEject = (message: MessageEvent<WorkerResult>) => {
304
302
  const { type, data } = message.data
@@ -729,7 +727,10 @@ class Mpc {
729
727
  })
730
728
  }
731
729
 
732
- public storedClientBackupShare(success: boolean): Promise<void> {
730
+ public storedClientBackupShare(
731
+ success: boolean,
732
+ backupMethod: BackupMethods,
733
+ ): Promise<void> {
733
734
  return new Promise((resolve, reject) => {
734
735
  const handleStoredClientBackupShare = (
735
736
  event: MessageEvent<WorkerResult>,
@@ -763,7 +764,88 @@ class Mpc {
763
764
  // Send the request to the iframe
764
765
  this.postMessage({
765
766
  type: 'portal:storedClientBackupShare',
766
- data: success,
767
+ data: {
768
+ success,
769
+ backupMethod,
770
+ },
771
+ })
772
+ })
773
+ }
774
+
775
+ public async getBackupShareMetadata(): Promise<BackupSharePairMetadata[]> {
776
+ return new Promise((resolve, reject) => {
777
+ const handleGetBackupShareMetadata = (
778
+ event: MessageEvent<WorkerResult>,
779
+ ) => {
780
+ const { type, data } = event.data
781
+ const { origin } = event
782
+
783
+ // ignore any broadcast postMessages
784
+ if (origin !== this.getOrigin()) {
785
+ return
786
+ }
787
+
788
+ if (type === 'portal:getBackupShareMetadataError') {
789
+ // Remove the event listener
790
+ window.removeEventListener('message', handleGetBackupShareMetadata)
791
+
792
+ // Reject the promise with the error
793
+ return reject(new PortalMpcError(data as PortalError))
794
+ } else if (type === 'portal:getBackupShareMetadataResult') {
795
+ // Remove the event listener
796
+ window.removeEventListener('message', handleGetBackupShareMetadata)
797
+
798
+ // Resolve the promise with the result
799
+ resolve(data as BackupSharePairMetadata[])
800
+ }
801
+ }
802
+
803
+ // Bind the function to the message event
804
+ window.addEventListener('message', handleGetBackupShareMetadata)
805
+
806
+ // Send the request to the iframe
807
+ this.postMessage({
808
+ type: 'portal:getBackupShareMetadata',
809
+ data: {},
810
+ })
811
+ })
812
+ }
813
+
814
+ public async getSigningShareMetadata(): Promise<SigningSharePairMetadata[]> {
815
+ return new Promise((resolve, reject) => {
816
+ const handleGetSigningShareMetadata = (
817
+ event: MessageEvent<WorkerResult>,
818
+ ) => {
819
+ const { type, data } = event.data
820
+ const { origin } = event
821
+
822
+ // ignore any broadcast postMessages
823
+ if (origin !== this.getOrigin()) {
824
+ return
825
+ }
826
+
827
+ if (type === 'portal:getSigningShareMetadataError') {
828
+ // Remove the event listener
829
+ window.removeEventListener('message', handleGetSigningShareMetadata)
830
+
831
+ // Reject the promise with the error
832
+ return reject(new PortalMpcError(data as PortalError))
833
+ } else if (type === 'portal:getSigningShareMetadataResult') {
834
+ // Remove the event listener
835
+ window.removeEventListener('message', handleGetSigningShareMetadata)
836
+
837
+ // Resolve the promise with the result
838
+ resolve(data as SigningSharePairMetadata[])
839
+ }
840
+ }
841
+
842
+ // Bind the function to the message event
843
+ window.addEventListener('message', handleGetSigningShareMetadata)
844
+
845
+ // Send the request to the iframe
846
+ this.postMessage({
847
+ type: 'portal:getSigningShareMetadata',
848
+ data: {},
767
849
  })
768
850
  })
769
851
  }
@@ -787,7 +869,6 @@ class Mpc {
787
869
  iframe.width = '0'
788
870
  iframe.src = source
789
871
  iframe.addEventListener('load', this.configureIframe)
790
-
791
872
  document.body.appendChild(iframe)
792
873
 
793
874
  this.iframe = iframe
@@ -801,6 +882,7 @@ class Mpc {
801
882
  autoApprove: this.portal.autoApprove,
802
883
  chainId: this.portal.chainId,
803
884
  gdrive: this.portal.gDriveConfig,
885
+ passkey: this.portal.passkeyConfig,
804
886
  host: this.portal.host,
805
887
  rpcUrl: this.portal.getRpcUrl(),
806
888
  featureFlags: this.portal.featureFlags,
package/types.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { MpcErrorCodes } from './src/mpc/errors'
3
3
 
4
4
  import Api from '../iframe/core/api'
5
5
  import GDriveStorage from '../iframe/core/storage/gdrive'
6
+ import PasskeyStorage from '../iframe/core/storage/passkey'
6
7
  import Portal from './src/index'
7
8
  import Provider from './src/provider'
8
9
 
@@ -18,7 +19,6 @@ export type MessageData =
18
19
  | SignArgs
19
20
  export type ProgressCallback = (status: MpcStatus) => void | Promise<void>
20
21
  export type ValidRpcErrorCodes = 4001 | 4100 | 4200 | 4900 | 4901
21
-
22
22
  // Interfaces
23
23
 
24
24
  export interface FeatureFlags {
@@ -39,6 +39,19 @@ export interface BackupConfigs {
39
39
  passwordStorage?: PasswordConfig
40
40
  }
41
41
 
42
+ export interface BackupSharePairMetadata {
43
+ backupMethod: BackupMethods
44
+ createdAt: string
45
+ id: string
46
+ status: 'completed' | 'incomplete'
47
+ }
48
+
49
+ export interface SigningSharePairMetadata {
50
+ createdAt: string
51
+ id: string
52
+ status: 'completed' | 'incomplete'
53
+ }
54
+
42
55
  export interface PasswordConfig {
43
56
  password: string
44
57
  }
@@ -178,6 +191,22 @@ export interface GDriveStorageOptions {
178
191
 
179
192
  export type GenerateArgs = MpcOperationArgs
180
193
 
194
+ export interface PasskeyConfig {
195
+ relyingParty?: string = 'portalhq.io'
196
+ relyingPartyOrigins?: [string] = ['https://web.portalhq.io']
197
+ webAuthnHost?: string = 'backup.web.portalhq.io'
198
+ }
199
+ export interface PasskeyStorageOptions {
200
+ portal: IPortal
201
+ relyingParty?: string = 'portalhq.io'
202
+ relyingPartyOrigins?: [string] = ['https://web.portalhq.io']
203
+ webAuthnHost?: string = 'backup.web.portalhq.io'
204
+ authOrigin?: string = 'web.portalhq.io'
205
+ }
206
+ export interface PasskeyStatusResponse {
207
+ status: PasskeyStatus
208
+ }
209
+
181
210
  export interface GenerateData {
182
211
  address: string
183
212
  dkgResult: DkgData
@@ -199,6 +228,7 @@ export interface IframeConfigurationOptions {
199
228
  chainId: number
200
229
  featureFlags?: FeatureFlags
201
230
  gdrive?: GDriveConfig
231
+ passkey?: PasskeyConfig
202
232
  host: string
203
233
  rpcUrl: string
204
234
 
@@ -293,6 +323,7 @@ export interface PortalOptions {
293
323
  autoApprove?: boolean
294
324
  chainId?: number
295
325
  gdrive?: GDriveConfig
326
+ passkey?: PasskeyConfig
296
327
  host?: string
297
328
  keychain?: KeychainAdapter
298
329
  mpcVersion?: string
@@ -438,11 +469,6 @@ export interface SimulatedTransaction {
438
469
  requestError?: SimulatedTransactionError
439
470
  }
440
471
 
441
- export enum GetTransactionsOrder {
442
- ASC = 'asc',
443
- DESC = 'desc',
444
- }
445
-
446
472
  export interface Transaction {
447
473
  asset: string
448
474
  blockNum: string