@portal-hq/web 0.1.3-rcd → 1.0.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.
@@ -20,7 +20,7 @@ class Portal {
20
20
  // Required
21
21
  gatewayConfig,
22
22
  // Optional
23
- apiKey, authToken, authUrl, autoApprove = false, chainId = 1, gdrive, passkey, 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,7 +38,7 @@ class Portal {
38
38
  if (gdrive) {
39
39
  this.gDriveConfig = gdrive;
40
40
  }
41
- else if (passkey) {
41
+ if (passkey) {
42
42
  this.passkeyConfig = passkey;
43
43
  }
44
44
  this.mpc = new mpc_1.default({
@@ -285,6 +285,18 @@ class Portal {
285
285
  return (_a = this.mpc) === null || _a === void 0 ? void 0 : _a.getNFTs();
286
286
  });
287
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
+ }
288
300
  getTransactions(limit, offset, order, chainId) {
289
301
  var _a;
290
302
  return __awaiter(this, void 0, void 0, function* () {
@@ -315,10 +327,10 @@ class Portal {
315
327
  /*******************************
316
328
  * Wallet Safeguarding Methods
317
329
  *******************************/
318
- storedClientBackupShare(status) {
330
+ storedClientBackupShare(success, backupMethod) {
319
331
  var _a;
320
332
  return __awaiter(this, void 0, void 0, function* () {
321
- 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));
322
334
  });
323
335
  }
324
336
  /****************************
@@ -379,6 +391,7 @@ var BackupMethods;
379
391
  BackupMethods["gdrive"] = "GDRIVE";
380
392
  BackupMethods["password"] = "PASSWORD";
381
393
  BackupMethods["passkey"] = "PASSKEY";
394
+ BackupMethods["unknown"] = "UNKNOWN";
382
395
  })(BackupMethods = exports.BackupMethods || (exports.BackupMethods = {}));
383
396
  var GetTransactionsOrder;
384
397
  (function (GetTransactionsOrder) {
@@ -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.3-rcd';
15
+ const WEB_SDK_VERSION = '1.0.0';
16
16
  class Mpc {
17
17
  constructor({ portal }) {
18
18
  this.configureIframe = () => {
@@ -618,7 +618,7 @@ class Mpc {
618
618
  });
619
619
  });
620
620
  }
621
- storedClientBackupShare(success) {
621
+ storedClientBackupShare(success, backupMethod) {
622
622
  return new Promise((resolve, reject) => {
623
623
  const handleStoredClientBackupShare = (event) => {
624
624
  const { type, data } = event.data;
@@ -645,7 +645,76 @@ class Mpc {
645
645
  // Send the request to the iframe
646
646
  this.postMessage({
647
647
  type: 'portal:storedClientBackupShare',
648
- 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
+ });
649
718
  });
650
719
  });
651
720
  }
@@ -666,7 +735,6 @@ class Mpc {
666
735
  iframe.width = '0';
667
736
  iframe.src = source;
668
737
  iframe.addEventListener('load', this.configureIframe);
669
- iframe.setAttribute('allow', 'publickey-credentials-get');
670
738
  document.body.appendChild(iframe);
671
739
  this.iframe = iframe;
672
740
  }
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, passkey, 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,7 +32,7 @@ class Portal {
32
32
  if (gdrive) {
33
33
  this.gDriveConfig = gdrive;
34
34
  }
35
- else if (passkey) {
35
+ if (passkey) {
36
36
  this.passkeyConfig = passkey;
37
37
  }
38
38
  this.mpc = new Mpc({
@@ -279,6 +279,18 @@ class Portal {
279
279
  return (_a = this.mpc) === null || _a === void 0 ? void 0 : _a.getNFTs();
280
280
  });
281
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
+ }
282
294
  getTransactions(limit, offset, order, chainId) {
283
295
  var _a;
284
296
  return __awaiter(this, void 0, void 0, function* () {
@@ -309,10 +321,10 @@ class Portal {
309
321
  /*******************************
310
322
  * Wallet Safeguarding Methods
311
323
  *******************************/
312
- storedClientBackupShare(status) {
324
+ storedClientBackupShare(success, backupMethod) {
313
325
  var _a;
314
326
  return __awaiter(this, void 0, void 0, function* () {
315
- 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));
316
328
  });
317
329
  }
318
330
  /****************************
@@ -371,6 +383,7 @@ export var BackupMethods;
371
383
  BackupMethods["gdrive"] = "GDRIVE";
372
384
  BackupMethods["password"] = "PASSWORD";
373
385
  BackupMethods["passkey"] = "PASSKEY";
386
+ BackupMethods["unknown"] = "UNKNOWN";
374
387
  })(BackupMethods || (BackupMethods = {}));
375
388
  export var GetTransactionsOrder;
376
389
  (function (GetTransactionsOrder) {
@@ -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.3-rcd';
12
+ const WEB_SDK_VERSION = '1.0.0';
13
13
  class Mpc {
14
14
  constructor({ portal }) {
15
15
  this.configureIframe = () => {
@@ -615,7 +615,7 @@ class Mpc {
615
615
  });
616
616
  });
617
617
  }
618
- storedClientBackupShare(success) {
618
+ storedClientBackupShare(success, backupMethod) {
619
619
  return new Promise((resolve, reject) => {
620
620
  const handleStoredClientBackupShare = (event) => {
621
621
  const { type, data } = event.data;
@@ -642,7 +642,76 @@ class Mpc {
642
642
  // Send the request to the iframe
643
643
  this.postMessage({
644
644
  type: 'portal:storedClientBackupShare',
645
- 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
+ });
646
715
  });
647
716
  });
648
717
  }
@@ -663,7 +732,6 @@ class Mpc {
663
732
  iframe.width = '0';
664
733
  iframe.src = source;
665
734
  iframe.addEventListener('load', this.configureIframe);
666
- iframe.setAttribute('allow', 'publickey-credentials-get');
667
735
  document.body.appendChild(iframe);
668
736
  this.iframe = iframe;
669
737
  }
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.3-rcd",
6
+ "version": "1.0.0",
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,5 +1,6 @@
1
1
  import type {
2
2
  BackupConfigs,
3
+ BackupSharePairMetadata,
3
4
  Balance,
4
5
  ClientWithCustodianData,
5
6
  EthereumTransaction,
@@ -7,11 +8,12 @@ import type {
7
8
  GDriveConfig,
8
9
  GatewayLike,
9
10
  NFT,
10
- PortalOptions,
11
11
  PasskeyConfig,
12
+ PortalOptions,
12
13
  ProgressCallback,
13
14
  QuoteArgs,
14
15
  QuoteResponse,
16
+ SigningSharePairMetadata,
15
17
  SimulateTransactionParam,
16
18
  SimulatedTransaction,
17
19
  Transaction,
@@ -53,7 +55,7 @@ class Portal {
53
55
  gdrive,
54
56
  passkey,
55
57
  host = 'web.portalhq.io',
56
- mpcVersion = 'v5',
58
+ mpcVersion = 'v6',
57
59
  featureFlags = {
58
60
  optimized: false,
59
61
  },
@@ -70,7 +72,8 @@ class Portal {
70
72
 
71
73
  if (gdrive) {
72
74
  this.gDriveConfig = gdrive
73
- } else if (passkey) {
75
+ }
76
+ if (passkey) {
74
77
  this.passkeyConfig = passkey
75
78
  }
76
79
 
@@ -359,6 +362,14 @@ class Portal {
359
362
  return this.mpc?.getNFTs()
360
363
  }
361
364
 
365
+ public async getBackupShareMetadata(): Promise<BackupSharePairMetadata[]> {
366
+ return this.mpc?.getBackupShareMetadata()
367
+ }
368
+
369
+ public async getSigningShareMetadata(): Promise<SigningSharePairMetadata[]> {
370
+ return this.mpc?.getSigningShareMetadata()
371
+ }
372
+
362
373
  public async getTransactions(
363
374
  limit?: number,
364
375
  offset?: number,
@@ -393,8 +404,11 @@ class Portal {
393
404
  * Wallet Safeguarding Methods
394
405
  *******************************/
395
406
 
396
- public async storedClientBackupShare(status: boolean): Promise<void> {
397
- return await this.mpc?.storedClientBackupShare(status)
407
+ public async storedClientBackupShare(
408
+ success: boolean,
409
+ backupMethod: BackupMethods,
410
+ ): Promise<void> {
411
+ return await this.mpc?.storedClientBackupShare(success, backupMethod)
398
412
  }
399
413
 
400
414
  /****************************
@@ -474,6 +488,7 @@ export enum BackupMethods {
474
488
  gdrive = 'GDRIVE',
475
489
  password = 'PASSWORD',
476
490
  passkey = 'PASSKEY',
491
+ unknown = 'UNKNOWN',
477
492
  }
478
493
 
479
494
  export enum GetTransactionsOrder {
package/src/mpc/index.ts CHANGED
@@ -3,6 +3,7 @@ import { PortalMpcError } from './errors'
3
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,
@@ -18,13 +19,14 @@ import type {
18
19
  QuoteResponse,
19
20
  RecoverArgs,
20
21
  SignArgs,
22
+ SigningSharePairMetadata,
21
23
  SimulateTransactionParam,
22
24
  SimulatedTransaction,
23
25
  Transaction,
24
26
  WorkerResult,
25
27
  } from '../../types'
26
28
 
27
- const WEB_SDK_VERSION = '0.1.3-rcd'
29
+ const WEB_SDK_VERSION = '1.0.0'
28
30
 
29
31
  class Mpc {
30
32
  public iframe?: HTMLIFrameElement
@@ -725,7 +727,10 @@ class Mpc {
725
727
  })
726
728
  }
727
729
 
728
- public storedClientBackupShare(success: boolean): Promise<void> {
730
+ public storedClientBackupShare(
731
+ success: boolean,
732
+ backupMethod: BackupMethods,
733
+ ): Promise<void> {
729
734
  return new Promise((resolve, reject) => {
730
735
  const handleStoredClientBackupShare = (
731
736
  event: MessageEvent<WorkerResult>,
@@ -759,7 +764,88 @@ class Mpc {
759
764
  // Send the request to the iframe
760
765
  this.postMessage({
761
766
  type: 'portal:storedClientBackupShare',
762
- 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: {},
763
849
  })
764
850
  })
765
851
  }
@@ -783,7 +869,6 @@ class Mpc {
783
869
  iframe.width = '0'
784
870
  iframe.src = source
785
871
  iframe.addEventListener('load', this.configureIframe)
786
- iframe.setAttribute('allow', 'publickey-credentials-get')
787
872
  document.body.appendChild(iframe)
788
873
 
789
874
  this.iframe = iframe
package/types.d.ts CHANGED
@@ -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
  }