@mysten/signers 0.1.14 → 0.1.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mysten/signers",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "A collection of KMS signers for various cloud providers",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Mysten Labs <build@mystenlabs.com>",
@@ -49,6 +49,9 @@ export class WebCryptoSigner extends Signer {
49
49
  );
50
50
  }
51
51
 
52
+ /**
53
+ * Imports a keypair using the value returned by `export()`.
54
+ */
52
55
  static import(data: ExportedWebCryptoKeypair) {
53
56
  return new WebCryptoSigner(data.privateKey, data.publicKey);
54
57
  }
@@ -63,13 +66,25 @@ export class WebCryptoSigner extends Signer {
63
66
  this.#publicKey = new Secp256r1PublicKey(publicKey);
64
67
  }
65
68
 
66
- // Exports the keypair to store in IndexedDB.
69
+ /**
70
+ * Exports the keypair so that it can be stored in IndexedDB.
71
+ */
67
72
  export(): ExportedWebCryptoKeypair {
68
- // TODO: Should we add something like `toJSON` on this so that if you attempt to serialize it throws?
69
- return {
73
+ const exportedKeypair = {
70
74
  privateKey: this.privateKey,
71
75
  publicKey: this.#publicKey.toRawBytes(),
72
76
  };
77
+
78
+ Object.defineProperty(exportedKeypair, 'toJSON', {
79
+ enumerable: false,
80
+ value: () => {
81
+ throw new Error(
82
+ 'The exported keypair must not be serialized. It must be stored in IndexedDB directly.',
83
+ );
84
+ },
85
+ });
86
+
87
+ return exportedKeypair;
73
88
  }
74
89
 
75
90
  getPublicKey() {