@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/CHANGELOG.md +6 -0
- package/dist/cjs/webcrypto/index.d.ts +6 -0
- package/dist/cjs/webcrypto/index.js +16 -2
- package/dist/cjs/webcrypto/index.js.map +2 -2
- package/dist/esm/webcrypto/index.d.ts +6 -0
- package/dist/esm/webcrypto/index.js +16 -2
- package/dist/esm/webcrypto/index.js.map +2 -2
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/webcrypto/index.ts +18 -3
package/package.json
CHANGED
package/src/webcrypto/index.ts
CHANGED
|
@@ -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
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Exports the keypair so that it can be stored in IndexedDB.
|
|
71
|
+
*/
|
|
67
72
|
export(): ExportedWebCryptoKeypair {
|
|
68
|
-
|
|
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() {
|