@portal-hq/web 3.2.1 → 3.2.3

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 @@ 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.2.1';
15
+ const WEB_SDK_VERSION = '3.2.3';
16
16
  class Mpc {
17
17
  constructor({ portal }) {
18
18
  this.configureIframe = () => {
@@ -721,6 +721,72 @@ class Mpc {
721
721
  });
722
722
  });
723
723
  }
724
+ formatShares(shares) {
725
+ return __awaiter(this, void 0, void 0, function* () {
726
+ return new Promise((resolve, reject) => {
727
+ const handleFormatShares = (event) => {
728
+ const { type, data: result } = event.data;
729
+ const { origin } = event;
730
+ // ignore any broadcast postMessages
731
+ if (origin !== this.getOrigin()) {
732
+ return;
733
+ }
734
+ if (type === 'portal:wasm:formatSharesError') {
735
+ // Remove the event listener
736
+ window.removeEventListener('message', handleFormatShares);
737
+ // Reject the promise with the error
738
+ return reject(new errors_1.PortalMpcError(result));
739
+ }
740
+ else if (type === 'portal:wasm:formatSharesResult') {
741
+ // Remove the event listener
742
+ window.removeEventListener('message', handleFormatShares);
743
+ // Resolve the promise with the result
744
+ resolve(result);
745
+ }
746
+ };
747
+ // Bind the function to the message event
748
+ window.addEventListener('message', handleFormatShares);
749
+ // Send the request to the iframe
750
+ this.postMessage({
751
+ type: 'portal:wasm:formatShares',
752
+ data: shares,
753
+ });
754
+ });
755
+ });
756
+ }
757
+ getCustodianIdClientIdHashes(data) {
758
+ return __awaiter(this, void 0, void 0, function* () {
759
+ return new Promise((resolve, reject) => {
760
+ const handleGetHashes = (event) => {
761
+ const { type, data: result } = event.data;
762
+ const { origin } = event;
763
+ // ignore any broadcast postMessages
764
+ if (origin !== this.getOrigin()) {
765
+ return;
766
+ }
767
+ if (type === 'portal:wasm:getCustodianIdClientIdHashesError') {
768
+ // Remove the event listener
769
+ window.removeEventListener('message', handleGetHashes);
770
+ // Reject the promise with the error
771
+ return reject(new errors_1.PortalMpcError(result));
772
+ }
773
+ else if (type === 'portal:wasm:getCustodianIdClientIdHashesResult') {
774
+ // Remove the event listener
775
+ window.removeEventListener('message', handleGetHashes);
776
+ // Resolve the promise with the result
777
+ resolve(result);
778
+ }
779
+ };
780
+ // Bind the function to the message event
781
+ window.addEventListener('message', handleGetHashes);
782
+ // Send the request to the iframe
783
+ this.postMessage({
784
+ type: 'portal:wasm:getCustodianIdClientIdHashes',
785
+ data,
786
+ });
787
+ });
788
+ });
789
+ }
724
790
  /***************************
725
791
  * Private Methods
726
792
  ***************************/
@@ -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.2.1';
12
+ const WEB_SDK_VERSION = '3.2.3';
13
13
  class Mpc {
14
14
  constructor({ portal }) {
15
15
  this.configureIframe = () => {
@@ -718,6 +718,72 @@ class Mpc {
718
718
  });
719
719
  });
720
720
  }
721
+ formatShares(shares) {
722
+ return __awaiter(this, void 0, void 0, function* () {
723
+ return new Promise((resolve, reject) => {
724
+ const handleFormatShares = (event) => {
725
+ const { type, data: result } = event.data;
726
+ const { origin } = event;
727
+ // ignore any broadcast postMessages
728
+ if (origin !== this.getOrigin()) {
729
+ return;
730
+ }
731
+ if (type === 'portal:wasm:formatSharesError') {
732
+ // Remove the event listener
733
+ window.removeEventListener('message', handleFormatShares);
734
+ // Reject the promise with the error
735
+ return reject(new PortalMpcError(result));
736
+ }
737
+ else if (type === 'portal:wasm:formatSharesResult') {
738
+ // Remove the event listener
739
+ window.removeEventListener('message', handleFormatShares);
740
+ // Resolve the promise with the result
741
+ resolve(result);
742
+ }
743
+ };
744
+ // Bind the function to the message event
745
+ window.addEventListener('message', handleFormatShares);
746
+ // Send the request to the iframe
747
+ this.postMessage({
748
+ type: 'portal:wasm:formatShares',
749
+ data: shares,
750
+ });
751
+ });
752
+ });
753
+ }
754
+ getCustodianIdClientIdHashes(data) {
755
+ return __awaiter(this, void 0, void 0, function* () {
756
+ return new Promise((resolve, reject) => {
757
+ const handleGetHashes = (event) => {
758
+ const { type, data: result } = event.data;
759
+ const { origin } = event;
760
+ // ignore any broadcast postMessages
761
+ if (origin !== this.getOrigin()) {
762
+ return;
763
+ }
764
+ if (type === 'portal:wasm:getCustodianIdClientIdHashesError') {
765
+ // Remove the event listener
766
+ window.removeEventListener('message', handleGetHashes);
767
+ // Reject the promise with the error
768
+ return reject(new PortalMpcError(result));
769
+ }
770
+ else if (type === 'portal:wasm:getCustodianIdClientIdHashesResult') {
771
+ // Remove the event listener
772
+ window.removeEventListener('message', handleGetHashes);
773
+ // Resolve the promise with the result
774
+ resolve(result);
775
+ }
776
+ };
777
+ // Bind the function to the message event
778
+ window.addEventListener('message', handleGetHashes);
779
+ // Send the request to the iframe
780
+ this.postMessage({
781
+ type: 'portal:wasm:getCustodianIdClientIdHashes',
782
+ data,
783
+ });
784
+ });
785
+ });
786
+ }
721
787
  /***************************
722
788
  * Private Methods
723
789
  ***************************/
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.2.1",
6
+ "version": "3.2.3",
7
7
  "license": "MIT",
8
8
  "main": "lib/commonjs/index",
9
9
  "module": "lib/esm/index",
@@ -43,7 +43,7 @@
43
43
  "ts-loader": "^9.4.3",
44
44
  "ts-node": "^10.9.1",
45
45
  "typescript": "^4.8.4",
46
- "webpack": "^5.87.0",
46
+ "webpack": "^5.94.0",
47
47
  "webpack-cli": "^5.1.4"
48
48
  },
49
49
  "dependencies": {
package/src/mpc/index.ts CHANGED
@@ -30,7 +30,7 @@ import type {
30
30
  EjectResult,
31
31
  } from '../../types'
32
32
 
33
- const WEB_SDK_VERSION = '3.2.1'
33
+ const WEB_SDK_VERSION = '3.2.3'
34
34
 
35
35
  class Mpc {
36
36
  public iframe?: HTMLIFrameElement
@@ -858,6 +858,80 @@ class Mpc {
858
858
  })
859
859
  }
860
860
 
861
+ public async formatShares(shares: string): Promise<string> {
862
+ return new Promise((resolve, reject) => {
863
+ const handleFormatShares = (event: MessageEvent<WorkerResult>) => {
864
+ const { type, data: result } = event.data
865
+ const { origin } = event
866
+
867
+ // ignore any broadcast postMessages
868
+ if (origin !== this.getOrigin()) {
869
+ return
870
+ }
871
+
872
+ if (type === 'portal:wasm:formatSharesError') {
873
+ // Remove the event listener
874
+ window.removeEventListener('message', handleFormatShares)
875
+
876
+ // Reject the promise with the error
877
+ return reject(new PortalMpcError(result as PortalError))
878
+ } else if (type === 'portal:wasm:formatSharesResult') {
879
+ // Remove the event listener
880
+ window.removeEventListener('message', handleFormatShares)
881
+
882
+ // Resolve the promise with the result
883
+ resolve(result as string)
884
+ }
885
+ }
886
+
887
+ // Bind the function to the message event
888
+ window.addEventListener('message', handleFormatShares)
889
+
890
+ // Send the request to the iframe
891
+ this.postMessage({
892
+ type: 'portal:wasm:formatShares',
893
+ data: shares,
894
+ })
895
+ })
896
+ }
897
+
898
+ public async getCustodianIdClientIdHashes(data: any): Promise<string> {
899
+ return new Promise((resolve, reject) => {
900
+ const handleGetHashes = (event: MessageEvent<WorkerResult>) => {
901
+ const { type, data: result } = event.data
902
+ const { origin } = event
903
+
904
+ // ignore any broadcast postMessages
905
+ if (origin !== this.getOrigin()) {
906
+ return
907
+ }
908
+
909
+ if (type === 'portal:wasm:getCustodianIdClientIdHashesError') {
910
+ // Remove the event listener
911
+ window.removeEventListener('message', handleGetHashes)
912
+
913
+ // Reject the promise with the error
914
+ return reject(new PortalMpcError(result as PortalError))
915
+ } else if (type === 'portal:wasm:getCustodianIdClientIdHashesResult') {
916
+ // Remove the event listener
917
+ window.removeEventListener('message', handleGetHashes)
918
+
919
+ // Resolve the promise with the result
920
+ resolve(result as string)
921
+ }
922
+ }
923
+
924
+ // Bind the function to the message event
925
+ window.addEventListener('message', handleGetHashes)
926
+
927
+ // Send the request to the iframe
928
+ this.postMessage({
929
+ type: 'portal:wasm:getCustodianIdClientIdHashes',
930
+ data,
931
+ })
932
+ })
933
+ }
934
+
861
935
  /***************************
862
936
  * Private Methods
863
937
  ***************************/