@mysten/signers 1.0.1 → 1.0.4
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 +43 -0
- package/README.md +1 -1
- package/dist/aws/index.d.mts +1 -3
- package/dist/aws/index.mjs +2 -2
- package/dist/gcp/index.d.mts +1 -2
- package/dist/gcp/index.mjs +2 -2
- package/dist/ledger/index.d.mts +1 -74
- package/dist/ledger/index.mjs +2 -109
- package/dist/webcrypto/index.d.mts +1 -32
- package/dist/webcrypto/index.mjs +2 -69
- package/package.json +9 -19
- package/src/aws/index.ts +1 -6
- package/src/gcp/index.ts +1 -6
- package/src/ledger/index.ts +1 -160
- package/src/webcrypto/index.ts +1 -108
- package/dist/aws/aws-client.d.mts +0 -48
- package/dist/aws/aws-client.d.mts.map +0 -1
- package/dist/aws/aws-client.mjs +0 -46
- package/dist/aws/aws-client.mjs.map +0 -1
- package/dist/aws/aws-kms-signer.d.mts +0 -63
- package/dist/aws/aws-kms-signer.d.mts.map +0 -1
- package/dist/aws/aws-kms-signer.mjs +0 -78
- package/dist/aws/aws-kms-signer.mjs.map +0 -1
- package/dist/aws/aws4fetch.d.mts +0 -62
- package/dist/aws/aws4fetch.d.mts.map +0 -1
- package/dist/aws/aws4fetch.mjs +0 -313
- package/dist/aws/aws4fetch.mjs.map +0 -1
- package/dist/gcp/gcp-kms-client.d.mts +0 -71
- package/dist/gcp/gcp-kms-client.d.mts.map +0 -1
- package/dist/gcp/gcp-kms-client.mjs +0 -104
- package/dist/gcp/gcp-kms-client.mjs.map +0 -1
- package/dist/ledger/index.d.mts.map +0 -1
- package/dist/ledger/index.mjs.map +0 -1
- package/dist/ledger/objects.d.mts +0 -10
- package/dist/ledger/objects.d.mts.map +0 -1
- package/dist/ledger/objects.mjs +0 -16
- package/dist/ledger/objects.mjs.map +0 -1
- package/dist/utils/utils.mjs +0 -71
- package/dist/utils/utils.mjs.map +0 -1
- package/dist/webcrypto/index.d.mts.map +0 -1
- package/dist/webcrypto/index.mjs.map +0 -1
- package/src/aws/aws-client.ts +0 -107
- package/src/aws/aws-kms-signer.ts +0 -102
- package/src/aws/aws4fetch.ts +0 -502
- package/src/gcp/gcp-kms-client.ts +0 -156
- package/src/ledger/objects.ts +0 -32
- package/src/utils/utils.ts +0 -127
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
# @mysten/signers
|
|
2
2
|
|
|
3
|
+
## 1.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9e067cf: Validate the new per-package release flow end-to-end across every public @mysten package.
|
|
8
|
+
No functional changes — empty patch bump to force the orchestrator to dispatch every
|
|
9
|
+
release-<pkg>.yml workflow with `dry_run=false` so each package publishes via OIDC trusted
|
|
10
|
+
publishing.
|
|
11
|
+
- Updated dependencies [9e067cf]
|
|
12
|
+
- @mysten/aws-kms-signer@0.1.1
|
|
13
|
+
- @mysten/gcp-kms-signer@0.1.1
|
|
14
|
+
- @mysten/ledger-signer@0.1.1
|
|
15
|
+
- @mysten/sui@2.16.1
|
|
16
|
+
- @mysten/webcrypto-signer@0.1.1
|
|
17
|
+
|
|
18
|
+
## 1.0.3
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- 75a32c1: Internal refactor: each backend now lives in its own package (`@mysten/aws-kms-signer`,
|
|
23
|
+
`@mysten/gcp-kms-signer`, `@mysten/ledger-signer`, `@mysten/webcrypto-signer`). The
|
|
24
|
+
`@mysten/signers/{aws,gcp,ledger,webcrypto}` subpaths now re-export from the new packages — no
|
|
25
|
+
public API change. To shrink your dependency tree, switch to importing from the per-backend
|
|
26
|
+
package directly.
|
|
27
|
+
- Updated dependencies [75a32c1]
|
|
28
|
+
- Updated dependencies [75a32c1]
|
|
29
|
+
- Updated dependencies [75a32c1]
|
|
30
|
+
- Updated dependencies [75a32c1]
|
|
31
|
+
- @mysten/aws-kms-signer@0.1.0
|
|
32
|
+
- @mysten/gcp-kms-signer@0.1.0
|
|
33
|
+
- @mysten/ledger-signer@0.1.0
|
|
34
|
+
- @mysten/webcrypto-signer@0.1.0
|
|
35
|
+
|
|
36
|
+
## 1.0.2
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- Updated dependencies [78a577b]
|
|
41
|
+
- Updated dependencies [ef90be0]
|
|
42
|
+
- Updated dependencies [2ee1a2a]
|
|
43
|
+
- @mysten/sui@2.10.0
|
|
44
|
+
- @mysten/ledgerjs-hw-app-sui@0.8.0
|
|
45
|
+
|
|
3
46
|
## 1.0.1
|
|
4
47
|
|
|
5
48
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -195,7 +195,7 @@ console.log(signer.toSuiAddress());
|
|
|
195
195
|
|
|
196
196
|
// Define a test transaction:
|
|
197
197
|
const testTransaction = new Transaction();
|
|
198
|
-
const transactionBytes = await testTransaction.build();
|
|
198
|
+
const transactionBytes = await testTransaction.build({ client: suiClient });
|
|
199
199
|
|
|
200
200
|
// Sign a test transaction:
|
|
201
201
|
const { signature } = await signer.signTransaction(transactionBytes);
|
package/dist/aws/index.d.mts
CHANGED
package/dist/aws/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
export * from "@mysten/aws-kms-signer"
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { };
|
package/dist/gcp/index.d.mts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { GcpKmsSigner, type GcpKmsSignerOptions };
|
|
1
|
+
export * from "@mysten/gcp-kms-signer";
|
package/dist/gcp/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
export * from "@mysten/gcp-kms-signer"
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { };
|
package/dist/ledger/index.d.mts
CHANGED
|
@@ -1,74 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { SignatureWithBytes, Signer } from "@mysten/sui/cryptography";
|
|
3
|
-
import { Ed25519PublicKey } from "@mysten/sui/keypairs/ed25519";
|
|
4
|
-
import SuiLedgerClient, { Resolution } from "@mysten/ledgerjs-hw-app-sui";
|
|
5
|
-
import { ClientWithCoreApi } from "@mysten/sui/client";
|
|
6
|
-
|
|
7
|
-
//#region src/ledger/index.d.ts
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Configuration options for initializing the LedgerSigner.
|
|
11
|
-
*/
|
|
12
|
-
interface LedgerSignerOptions {
|
|
13
|
-
publicKey: Ed25519PublicKey;
|
|
14
|
-
derivationPath: string;
|
|
15
|
-
ledgerClient: SuiLedgerClient;
|
|
16
|
-
suiClient: ClientWithCoreApi;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Ledger integrates with the Sui blockchain to provide signing capabilities using Ledger devices.
|
|
20
|
-
*/
|
|
21
|
-
declare class LedgerSigner extends Signer {
|
|
22
|
-
#private;
|
|
23
|
-
/**
|
|
24
|
-
* Creates an instance of LedgerSigner. It's expected to call the static `fromDerivationPath` method to create an instance.
|
|
25
|
-
* @example
|
|
26
|
-
* ```
|
|
27
|
-
* const signer = await LedgerSigner.fromDerivationPath(derivationPath, options);
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
constructor({
|
|
31
|
-
publicKey,
|
|
32
|
-
derivationPath,
|
|
33
|
-
ledgerClient,
|
|
34
|
-
suiClient
|
|
35
|
-
}: LedgerSignerOptions);
|
|
36
|
-
/**
|
|
37
|
-
* Retrieves the key scheme used by this signer.
|
|
38
|
-
*/
|
|
39
|
-
getKeyScheme(): "ED25519";
|
|
40
|
-
/**
|
|
41
|
-
* Retrieves the public key associated with this signer.
|
|
42
|
-
* @returns The Ed25519PublicKey instance.
|
|
43
|
-
*/
|
|
44
|
-
getPublicKey(): Ed25519PublicKey;
|
|
45
|
-
/**
|
|
46
|
-
* Signs the provided transaction bytes.
|
|
47
|
-
* @returns The signed transaction bytes and signature.
|
|
48
|
-
*/
|
|
49
|
-
signTransaction(bytes: Uint8Array, bcsObjects?: Uint8Array[], resolution?: Resolution): Promise<SignatureWithBytes>;
|
|
50
|
-
/**
|
|
51
|
-
* Signs the provided personal message.
|
|
52
|
-
* @returns The signed message bytes and signature.
|
|
53
|
-
*/
|
|
54
|
-
signPersonalMessage(bytes: Uint8Array): Promise<SignatureWithBytes>;
|
|
55
|
-
/**
|
|
56
|
-
* Prepares the signer by fetching and setting the public key from a Ledger device.
|
|
57
|
-
* It is recommended to initialize an `LedgerSigner` instance using this function.
|
|
58
|
-
* @returns A promise that resolves once a `LedgerSigner` instance is prepared (public key is set).
|
|
59
|
-
*/
|
|
60
|
-
static fromDerivationPath(derivationPath: string, ledgerClient: SuiLedgerClient, suiClient: ClientWithCoreApi): Promise<LedgerSigner>;
|
|
61
|
-
/**
|
|
62
|
-
* Generic signing is not supported by Ledger.
|
|
63
|
-
* @throws Always throws an error indicating generic signing is unsupported.
|
|
64
|
-
*/
|
|
65
|
-
sign(): never;
|
|
66
|
-
/**
|
|
67
|
-
* Generic signing is not supported by Ledger.
|
|
68
|
-
* @throws Always throws an error indicating generic signing is unsupported.
|
|
69
|
-
*/
|
|
70
|
-
signWithIntent(): never;
|
|
71
|
-
}
|
|
72
|
-
//#endregion
|
|
73
|
-
export { LedgerSigner, LedgerSignerOptions, getInputObjects };
|
|
74
|
-
//# sourceMappingURL=index.d.mts.map
|
|
1
|
+
export * from "@mysten/ledger-signer";
|
package/dist/ledger/index.mjs
CHANGED
|
@@ -1,110 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import { Signer, messageWithIntent, toSerializedSignature } from "@mysten/sui/cryptography";
|
|
3
|
-
import { toBase64 } from "@mysten/sui/utils";
|
|
4
|
-
import { Ed25519PublicKey } from "@mysten/sui/keypairs/ed25519";
|
|
5
|
-
import { Transaction } from "@mysten/sui/transactions";
|
|
6
|
-
import { bcs } from "@mysten/sui/bcs";
|
|
1
|
+
export * from "@mysten/ledger-signer"
|
|
7
2
|
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Ledger integrates with the Sui blockchain to provide signing capabilities using Ledger devices.
|
|
11
|
-
*/
|
|
12
|
-
var LedgerSigner = class LedgerSigner extends Signer {
|
|
13
|
-
#derivationPath;
|
|
14
|
-
#publicKey;
|
|
15
|
-
#ledgerClient;
|
|
16
|
-
#suiClient;
|
|
17
|
-
/**
|
|
18
|
-
* Creates an instance of LedgerSigner. It's expected to call the static `fromDerivationPath` method to create an instance.
|
|
19
|
-
* @example
|
|
20
|
-
* ```
|
|
21
|
-
* const signer = await LedgerSigner.fromDerivationPath(derivationPath, options);
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
constructor({ publicKey, derivationPath, ledgerClient, suiClient }) {
|
|
25
|
-
super();
|
|
26
|
-
this.#publicKey = publicKey;
|
|
27
|
-
this.#derivationPath = derivationPath;
|
|
28
|
-
this.#ledgerClient = ledgerClient;
|
|
29
|
-
this.#suiClient = suiClient;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Retrieves the key scheme used by this signer.
|
|
33
|
-
*/
|
|
34
|
-
getKeyScheme() {
|
|
35
|
-
return "ED25519";
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Retrieves the public key associated with this signer.
|
|
39
|
-
* @returns The Ed25519PublicKey instance.
|
|
40
|
-
*/
|
|
41
|
-
getPublicKey() {
|
|
42
|
-
return this.#publicKey;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Signs the provided transaction bytes.
|
|
46
|
-
* @returns The signed transaction bytes and signature.
|
|
47
|
-
*/
|
|
48
|
-
async signTransaction(bytes, bcsObjects, resolution) {
|
|
49
|
-
const transactionOptions = bcsObjects ? { bcsObjects } : await getInputObjects(Transaction.from(bytes), this.#suiClient).catch(() => ({ bcsObjects: [] }));
|
|
50
|
-
const intentMessage = messageWithIntent("TransactionData", bytes);
|
|
51
|
-
const { signature } = await this.#ledgerClient.signTransaction(this.#derivationPath, intentMessage, transactionOptions, resolution);
|
|
52
|
-
return {
|
|
53
|
-
bytes: toBase64(bytes),
|
|
54
|
-
signature: toSerializedSignature({
|
|
55
|
-
signature,
|
|
56
|
-
signatureScheme: this.getKeyScheme(),
|
|
57
|
-
publicKey: this.#publicKey
|
|
58
|
-
})
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Signs the provided personal message.
|
|
63
|
-
* @returns The signed message bytes and signature.
|
|
64
|
-
*/
|
|
65
|
-
async signPersonalMessage(bytes) {
|
|
66
|
-
const intentMessage = messageWithIntent("PersonalMessage", bcs.byteVector().serialize(bytes).toBytes());
|
|
67
|
-
const { signature } = await this.#ledgerClient.signTransaction(this.#derivationPath, intentMessage);
|
|
68
|
-
return {
|
|
69
|
-
bytes: toBase64(bytes),
|
|
70
|
-
signature: toSerializedSignature({
|
|
71
|
-
signature,
|
|
72
|
-
signatureScheme: this.getKeyScheme(),
|
|
73
|
-
publicKey: this.#publicKey
|
|
74
|
-
})
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Prepares the signer by fetching and setting the public key from a Ledger device.
|
|
79
|
-
* It is recommended to initialize an `LedgerSigner` instance using this function.
|
|
80
|
-
* @returns A promise that resolves once a `LedgerSigner` instance is prepared (public key is set).
|
|
81
|
-
*/
|
|
82
|
-
static async fromDerivationPath(derivationPath, ledgerClient, suiClient) {
|
|
83
|
-
const { publicKey } = await ledgerClient.getPublicKey(derivationPath);
|
|
84
|
-
if (!publicKey) throw new Error("Failed to get public key from Ledger.");
|
|
85
|
-
return new LedgerSigner({
|
|
86
|
-
derivationPath,
|
|
87
|
-
publicKey: new Ed25519PublicKey(publicKey),
|
|
88
|
-
ledgerClient,
|
|
89
|
-
suiClient
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Generic signing is not supported by Ledger.
|
|
94
|
-
* @throws Always throws an error indicating generic signing is unsupported.
|
|
95
|
-
*/
|
|
96
|
-
sign() {
|
|
97
|
-
throw new Error("Ledger Signer does not support generic signing.");
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Generic signing is not supported by Ledger.
|
|
101
|
-
* @throws Always throws an error indicating generic signing is unsupported.
|
|
102
|
-
*/
|
|
103
|
-
signWithIntent() {
|
|
104
|
-
throw new Error("Ledger Signer does not support generic signing.");
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
//#endregion
|
|
109
|
-
export { LedgerSigner, getInputObjects };
|
|
110
|
-
//# sourceMappingURL=index.mjs.map
|
|
3
|
+
export { };
|
|
@@ -1,32 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { Secp256r1PublicKey } from "@mysten/sui/keypairs/secp256r1";
|
|
3
|
-
|
|
4
|
-
//#region src/webcrypto/index.d.ts
|
|
5
|
-
interface ExportedWebCryptoKeypair {
|
|
6
|
-
privateKey: CryptoKey;
|
|
7
|
-
publicKey: Uint8Array<ArrayBuffer>;
|
|
8
|
-
}
|
|
9
|
-
declare class WebCryptoSigner extends Signer {
|
|
10
|
-
#private;
|
|
11
|
-
privateKey: CryptoKey;
|
|
12
|
-
static generate({
|
|
13
|
-
extractable
|
|
14
|
-
}?: {
|
|
15
|
-
extractable?: boolean;
|
|
16
|
-
}): Promise<WebCryptoSigner>;
|
|
17
|
-
/**
|
|
18
|
-
* Imports a keypair using the value returned by `export()`.
|
|
19
|
-
*/
|
|
20
|
-
static import(data: ExportedWebCryptoKeypair): WebCryptoSigner;
|
|
21
|
-
getKeyScheme(): SignatureScheme;
|
|
22
|
-
constructor(privateKey: CryptoKey, publicKey: Uint8Array);
|
|
23
|
-
/**
|
|
24
|
-
* Exports the keypair so that it can be stored in IndexedDB.
|
|
25
|
-
*/
|
|
26
|
-
export(): ExportedWebCryptoKeypair;
|
|
27
|
-
getPublicKey(): Secp256r1PublicKey;
|
|
28
|
-
sign(bytes: Uint8Array): Promise<Uint8Array<ArrayBuffer>>;
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
31
|
-
export { ExportedWebCryptoKeypair, WebCryptoSigner };
|
|
32
|
-
//# sourceMappingURL=index.d.mts.map
|
|
1
|
+
export * from "@mysten/webcrypto-signer";
|
package/dist/webcrypto/index.mjs
CHANGED
|
@@ -1,70 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import { p256 } from "@noble/curves/nist.js";
|
|
3
|
-
import { Secp256r1PublicKey } from "@mysten/sui/keypairs/secp256r1";
|
|
1
|
+
export * from "@mysten/webcrypto-signer"
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
function getCompressedPublicKey(publicKey) {
|
|
7
|
-
const rawBytes = new Uint8Array(publicKey);
|
|
8
|
-
const x = rawBytes.slice(1, 33);
|
|
9
|
-
const prefix = (rawBytes.slice(33, 65)[31] & 1) === 0 ? 2 : 3;
|
|
10
|
-
const compressed = new Uint8Array(Secp256r1PublicKey.SIZE);
|
|
11
|
-
compressed[0] = prefix;
|
|
12
|
-
compressed.set(x, 1);
|
|
13
|
-
return compressed;
|
|
14
|
-
}
|
|
15
|
-
var WebCryptoSigner = class WebCryptoSigner extends Signer {
|
|
16
|
-
#publicKey;
|
|
17
|
-
static async generate({ extractable = false } = {}) {
|
|
18
|
-
const keypair = await globalThis.crypto.subtle.generateKey({
|
|
19
|
-
name: "ECDSA",
|
|
20
|
-
namedCurve: "P-256"
|
|
21
|
-
}, extractable, ["sign", "verify"]);
|
|
22
|
-
const publicKey = await globalThis.crypto.subtle.exportKey("raw", keypair.publicKey);
|
|
23
|
-
return new WebCryptoSigner(keypair.privateKey, getCompressedPublicKey(new Uint8Array(publicKey)));
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Imports a keypair using the value returned by `export()`.
|
|
27
|
-
*/
|
|
28
|
-
static import(data) {
|
|
29
|
-
return new WebCryptoSigner(data.privateKey, data.publicKey);
|
|
30
|
-
}
|
|
31
|
-
getKeyScheme() {
|
|
32
|
-
return "Secp256r1";
|
|
33
|
-
}
|
|
34
|
-
constructor(privateKey, publicKey) {
|
|
35
|
-
super();
|
|
36
|
-
this.privateKey = privateKey;
|
|
37
|
-
this.#publicKey = new Secp256r1PublicKey(publicKey);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Exports the keypair so that it can be stored in IndexedDB.
|
|
41
|
-
*/
|
|
42
|
-
export() {
|
|
43
|
-
const exportedKeypair = {
|
|
44
|
-
privateKey: this.privateKey,
|
|
45
|
-
publicKey: this.#publicKey.toRawBytes()
|
|
46
|
-
};
|
|
47
|
-
Object.defineProperty(exportedKeypair, "toJSON", {
|
|
48
|
-
enumerable: false,
|
|
49
|
-
value: () => {
|
|
50
|
-
throw new Error("The exported keypair must not be serialized. It must be stored in IndexedDB directly.");
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
return exportedKeypair;
|
|
54
|
-
}
|
|
55
|
-
getPublicKey() {
|
|
56
|
-
return this.#publicKey;
|
|
57
|
-
}
|
|
58
|
-
async sign(bytes) {
|
|
59
|
-
const rawSignature = await globalThis.crypto.subtle.sign({
|
|
60
|
-
name: "ECDSA",
|
|
61
|
-
hash: "SHA-256"
|
|
62
|
-
}, this.privateKey, bytes);
|
|
63
|
-
const signature = p256.Signature.fromBytes(new Uint8Array(rawSignature));
|
|
64
|
-
return (signature.hasHighS() ? new p256.Signature(signature.r, p256.Point.Fn.neg(signature.s)) : signature).toBytes("compact");
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
//#endregion
|
|
69
|
-
export { WebCryptoSigner };
|
|
70
|
-
//# sourceMappingURL=index.mjs.map
|
|
3
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mysten/signers",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "A collection of signers for various providers",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Mysten Labs <build@mystenlabs.com>",
|
|
@@ -32,13 +32,8 @@
|
|
|
32
32
|
"CHANGELOG.md",
|
|
33
33
|
"LICENSE",
|
|
34
34
|
"README.md",
|
|
35
|
-
"aws",
|
|
36
35
|
"dist",
|
|
37
|
-
"
|
|
38
|
-
"ledger",
|
|
39
|
-
"src",
|
|
40
|
-
"src",
|
|
41
|
-
"webcrypto"
|
|
36
|
+
"src"
|
|
42
37
|
],
|
|
43
38
|
"repository": {
|
|
44
39
|
"type": "git",
|
|
@@ -50,23 +45,19 @@
|
|
|
50
45
|
"homepage": "https://github.com/MystenLabs/ts-sdks/tree/main/packages/signers#readme",
|
|
51
46
|
"devDependencies": {
|
|
52
47
|
"@types/node": "^25.0.8",
|
|
53
|
-
"
|
|
54
|
-
"typescript": "^5.9.3",
|
|
55
|
-
"vitest": "^4.0.17",
|
|
56
|
-
"@mysten/sui": "^2.3.2"
|
|
48
|
+
"typescript": "^5.9.3"
|
|
57
49
|
},
|
|
58
50
|
"dependencies": {
|
|
59
|
-
"@
|
|
60
|
-
"@
|
|
61
|
-
"@
|
|
62
|
-
"
|
|
63
|
-
"@mysten/ledgerjs-hw-app-sui": "^0.7.1"
|
|
51
|
+
"@mysten/aws-kms-signer": "^0.1.1",
|
|
52
|
+
"@mysten/gcp-kms-signer": "^0.1.1",
|
|
53
|
+
"@mysten/ledger-signer": "^0.1.1",
|
|
54
|
+
"@mysten/webcrypto-signer": "^0.1.1"
|
|
64
55
|
},
|
|
65
56
|
"engines": {
|
|
66
57
|
"node": ">=22"
|
|
67
58
|
},
|
|
68
59
|
"peerDependencies": {
|
|
69
|
-
"@mysten/sui": "^2.
|
|
60
|
+
"@mysten/sui": "^2.16.1"
|
|
70
61
|
},
|
|
71
62
|
"scripts": {
|
|
72
63
|
"clean": "rm -rf tsconfig.tsbuildinfo ./dist",
|
|
@@ -76,7 +67,6 @@
|
|
|
76
67
|
"oxlint:check": "oxlint .",
|
|
77
68
|
"oxlint:fix": "oxlint --fix",
|
|
78
69
|
"lint": "pnpm run oxlint:check && pnpm run prettier:check",
|
|
79
|
-
"lint:fix": "pnpm run oxlint:fix && pnpm run prettier:fix"
|
|
80
|
-
"test": "vitest run"
|
|
70
|
+
"lint:fix": "pnpm run oxlint:fix && pnpm run prettier:fix"
|
|
81
71
|
}
|
|
82
72
|
}
|
package/src/aws/index.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
// Copyright (c) Mysten Labs, Inc.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import type { AwsClientOptions } from './aws-client.js';
|
|
4
|
-
import type { AwsKmsSignerOptions } from './aws-kms-signer.js';
|
|
5
|
-
import { AwsKmsSigner } from './aws-kms-signer.js';
|
|
6
3
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
export type { AwsKmsSignerOptions, AwsClientOptions };
|
|
4
|
+
export * from '@mysten/aws-kms-signer';
|
package/src/gcp/index.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
// Copyright (c) Mysten Labs, Inc.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
import { GcpKmsSigner } from './gcp-kms-client.js';
|
|
6
|
-
|
|
7
|
-
export { GcpKmsSigner };
|
|
8
|
-
|
|
9
|
-
export type { GcpKmsSignerOptions };
|
|
4
|
+
export * from '@mysten/gcp-kms-signer';
|
package/src/ledger/index.ts
CHANGED
|
@@ -1,163 +1,4 @@
|
|
|
1
1
|
// Copyright (c) Mysten Labs, Inc.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
import type { ClientWithCoreApi } from '@mysten/sui/client';
|
|
6
|
-
import type { SignatureWithBytes } from '@mysten/sui/cryptography';
|
|
7
|
-
import { messageWithIntent, Signer, toSerializedSignature } from '@mysten/sui/cryptography';
|
|
8
|
-
import { Ed25519PublicKey } from '@mysten/sui/keypairs/ed25519';
|
|
9
|
-
import { Transaction } from '@mysten/sui/transactions';
|
|
10
|
-
import { toBase64 } from '@mysten/sui/utils';
|
|
11
|
-
|
|
12
|
-
import { bcs } from '@mysten/sui/bcs';
|
|
13
|
-
import { getInputObjects } from './objects.js';
|
|
14
|
-
import type { Resolution } from '@mysten/ledgerjs-hw-app-sui';
|
|
15
|
-
|
|
16
|
-
export { getInputObjects } from './objects.js';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Configuration options for initializing the LedgerSigner.
|
|
20
|
-
*/
|
|
21
|
-
export interface LedgerSignerOptions {
|
|
22
|
-
publicKey: Ed25519PublicKey;
|
|
23
|
-
derivationPath: string;
|
|
24
|
-
ledgerClient: SuiLedgerClient;
|
|
25
|
-
suiClient: ClientWithCoreApi;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Ledger integrates with the Sui blockchain to provide signing capabilities using Ledger devices.
|
|
30
|
-
*/
|
|
31
|
-
export class LedgerSigner extends Signer {
|
|
32
|
-
#derivationPath: string;
|
|
33
|
-
#publicKey: Ed25519PublicKey;
|
|
34
|
-
#ledgerClient: SuiLedgerClient;
|
|
35
|
-
#suiClient: ClientWithCoreApi;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Creates an instance of LedgerSigner. It's expected to call the static `fromDerivationPath` method to create an instance.
|
|
39
|
-
* @example
|
|
40
|
-
* ```
|
|
41
|
-
* const signer = await LedgerSigner.fromDerivationPath(derivationPath, options);
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
constructor({ publicKey, derivationPath, ledgerClient, suiClient }: LedgerSignerOptions) {
|
|
45
|
-
super();
|
|
46
|
-
this.#publicKey = publicKey;
|
|
47
|
-
this.#derivationPath = derivationPath;
|
|
48
|
-
this.#ledgerClient = ledgerClient;
|
|
49
|
-
this.#suiClient = suiClient;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Retrieves the key scheme used by this signer.
|
|
54
|
-
*/
|
|
55
|
-
override getKeyScheme() {
|
|
56
|
-
return 'ED25519' as const;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Retrieves the public key associated with this signer.
|
|
61
|
-
* @returns The Ed25519PublicKey instance.
|
|
62
|
-
*/
|
|
63
|
-
override getPublicKey() {
|
|
64
|
-
return this.#publicKey;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Signs the provided transaction bytes.
|
|
69
|
-
* @returns The signed transaction bytes and signature.
|
|
70
|
-
*/
|
|
71
|
-
override async signTransaction(
|
|
72
|
-
bytes: Uint8Array,
|
|
73
|
-
bcsObjects?: Uint8Array[],
|
|
74
|
-
resolution?: Resolution,
|
|
75
|
-
): Promise<SignatureWithBytes> {
|
|
76
|
-
const transactionOptions = bcsObjects
|
|
77
|
-
? { bcsObjects }
|
|
78
|
-
: await getInputObjects(Transaction.from(bytes), this.#suiClient).catch(() => ({
|
|
79
|
-
// Fail gracefully so network errors or serialization issues don't break transaction signing:
|
|
80
|
-
bcsObjects: [],
|
|
81
|
-
}));
|
|
82
|
-
|
|
83
|
-
const intentMessage = messageWithIntent('TransactionData', bytes);
|
|
84
|
-
const { signature } = await this.#ledgerClient.signTransaction(
|
|
85
|
-
this.#derivationPath,
|
|
86
|
-
intentMessage,
|
|
87
|
-
transactionOptions,
|
|
88
|
-
resolution,
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
return {
|
|
92
|
-
bytes: toBase64(bytes),
|
|
93
|
-
signature: toSerializedSignature({
|
|
94
|
-
signature,
|
|
95
|
-
signatureScheme: this.getKeyScheme(),
|
|
96
|
-
publicKey: this.#publicKey,
|
|
97
|
-
}),
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Signs the provided personal message.
|
|
103
|
-
* @returns The signed message bytes and signature.
|
|
104
|
-
*/
|
|
105
|
-
override async signPersonalMessage(bytes: Uint8Array): Promise<SignatureWithBytes> {
|
|
106
|
-
const intentMessage = messageWithIntent(
|
|
107
|
-
'PersonalMessage',
|
|
108
|
-
bcs.byteVector().serialize(bytes).toBytes(),
|
|
109
|
-
);
|
|
110
|
-
const { signature } = await this.#ledgerClient.signTransaction(
|
|
111
|
-
this.#derivationPath,
|
|
112
|
-
intentMessage,
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
return {
|
|
116
|
-
bytes: toBase64(bytes),
|
|
117
|
-
signature: toSerializedSignature({
|
|
118
|
-
signature,
|
|
119
|
-
signatureScheme: this.getKeyScheme(),
|
|
120
|
-
publicKey: this.#publicKey,
|
|
121
|
-
}),
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Prepares the signer by fetching and setting the public key from a Ledger device.
|
|
127
|
-
* It is recommended to initialize an `LedgerSigner` instance using this function.
|
|
128
|
-
* @returns A promise that resolves once a `LedgerSigner` instance is prepared (public key is set).
|
|
129
|
-
*/
|
|
130
|
-
static async fromDerivationPath(
|
|
131
|
-
derivationPath: string,
|
|
132
|
-
ledgerClient: SuiLedgerClient,
|
|
133
|
-
suiClient: ClientWithCoreApi,
|
|
134
|
-
) {
|
|
135
|
-
const { publicKey } = await ledgerClient.getPublicKey(derivationPath);
|
|
136
|
-
if (!publicKey) {
|
|
137
|
-
throw new Error('Failed to get public key from Ledger.');
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return new LedgerSigner({
|
|
141
|
-
derivationPath,
|
|
142
|
-
publicKey: new Ed25519PublicKey(publicKey),
|
|
143
|
-
ledgerClient,
|
|
144
|
-
suiClient,
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Generic signing is not supported by Ledger.
|
|
150
|
-
* @throws Always throws an error indicating generic signing is unsupported.
|
|
151
|
-
*/
|
|
152
|
-
override sign(): never {
|
|
153
|
-
throw new Error('Ledger Signer does not support generic signing.');
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Generic signing is not supported by Ledger.
|
|
158
|
-
* @throws Always throws an error indicating generic signing is unsupported.
|
|
159
|
-
*/
|
|
160
|
-
override signWithIntent(): never {
|
|
161
|
-
throw new Error('Ledger Signer does not support generic signing.');
|
|
162
|
-
}
|
|
163
|
-
}
|
|
4
|
+
export * from '@mysten/ledger-signer';
|