@anywalletkit/wallet-ton 0.4.0 → 0.5.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.
- package/dist/index.cjs +15 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +15 -8
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -1191,13 +1191,20 @@ var WalletAccountTon = class _WalletAccountTon extends WalletAccountReadOnlyTon
|
|
|
1191
1191
|
needsNetwork = true;
|
|
1192
1192
|
/** Derivation path, `ton-mnemonic`, or `external`. */
|
|
1193
1193
|
path;
|
|
1194
|
-
/**
|
|
1195
|
-
|
|
1194
|
+
/**
|
|
1195
|
+
* The signer that holds the key, in a private field: not a property of the account, so no code
|
|
1196
|
+
* the account is handed to (a protocol module, a logger) can reach it and sign around the
|
|
1197
|
+
* account's checks (audit 2026-10-29 A1).
|
|
1198
|
+
*/
|
|
1199
|
+
#signer;
|
|
1200
|
+
/** What holds the key: `seed`, `key` (one imported key) or `external`. */
|
|
1201
|
+
signerKind;
|
|
1196
1202
|
_readOnly;
|
|
1197
1203
|
/** `publicKey` is the signer's 32-byte ed25519 key; the V5R1 address derives from it synchronously. */
|
|
1198
1204
|
constructor(signer, publicKey, path, config = {}) {
|
|
1199
1205
|
super(publicKey, config);
|
|
1200
|
-
this
|
|
1206
|
+
this.#signer = (0, import_core9.requireCurve)(signer, "ed25519");
|
|
1207
|
+
this.signerKind = this.#signer.kind;
|
|
1201
1208
|
this.path = path;
|
|
1202
1209
|
}
|
|
1203
1210
|
/** Back-compat: wrap a raw derived key in a {@link LocalSigner} (the account takes ownership; it cannot derive). */
|
|
@@ -1220,7 +1227,7 @@ var WalletAccountTon = class _WalletAccountTon extends WalletAccountReadOnlyTon
|
|
|
1220
1227
|
async sign(message) {
|
|
1221
1228
|
const bytes = typeof message === "string" ? new TextEncoder().encode(message) : message;
|
|
1222
1229
|
if (bytes.length === 32 || carriesKey(bytes, this.publicKey)) throw new MessageIsTransactionError();
|
|
1223
|
-
return toHex(await this
|
|
1230
|
+
return toHex(await this.#signer.sign(bytes, { scheme: "ed25519", context: "ton-message" }));
|
|
1224
1231
|
}
|
|
1225
1232
|
/**
|
|
1226
1233
|
* TON Connect `ton_proof` for this wallet's address: the `proof` object of the connect reply. The
|
|
@@ -1229,7 +1236,7 @@ var WalletAccountTon = class _WalletAccountTon extends WalletAccountReadOnlyTon
|
|
|
1229
1236
|
*/
|
|
1230
1237
|
async signTonProof(request) {
|
|
1231
1238
|
const digest = tonProofDigest(this._address, request);
|
|
1232
|
-
const signature = await this
|
|
1239
|
+
const signature = await this.#signer.sign(digest, { scheme: "ed25519", context: "ton-proof" });
|
|
1233
1240
|
return {
|
|
1234
1241
|
timestamp: request.timestamp,
|
|
1235
1242
|
domain: { lengthBytes: new TextEncoder().encode(request.domain).length, value: request.domain },
|
|
@@ -1240,7 +1247,7 @@ var WalletAccountTon = class _WalletAccountTon extends WalletAccountReadOnlyTon
|
|
|
1240
1247
|
/** TON Connect `signData` (text / binary) for this wallet's address: the reply the dApp gets. */
|
|
1241
1248
|
async signTonConnectData(request) {
|
|
1242
1249
|
const digest = tonSignDataDigest(this._address, request);
|
|
1243
|
-
const signature = await this
|
|
1250
|
+
const signature = await this.#signer.sign(digest, { scheme: "ed25519", context: "ton-sign-data" });
|
|
1244
1251
|
return {
|
|
1245
1252
|
signature: import_buffer6.Buffer.from(signature).toString("base64"),
|
|
1246
1253
|
address: this._address.toRawString(),
|
|
@@ -1279,7 +1286,7 @@ var WalletAccountTon = class _WalletAccountTon extends WalletAccountReadOnlyTon
|
|
|
1279
1286
|
}
|
|
1280
1287
|
const { signing } = await this.signingCell(messages);
|
|
1281
1288
|
const fee = await this.preflight(v5r1PackUnsigned(signing), limit, op, want);
|
|
1282
|
-
const signature = await this
|
|
1289
|
+
const signature = await this.#signer.sign(new Uint8Array(signing.hash()), { scheme: "ed25519", context: "ton-external" });
|
|
1283
1290
|
return { body: v5r1PackSigned(signing, signature), fee };
|
|
1284
1291
|
}
|
|
1285
1292
|
async preflight(body, limit, op, expectedTonOut) {
|
|
@@ -1343,7 +1350,7 @@ var WalletAccountTon = class _WalletAccountTon extends WalletAccountReadOnlyTon
|
|
|
1343
1350
|
}
|
|
1344
1351
|
/** Disposes the signer: a local key is zeroized, an external one is released. */
|
|
1345
1352
|
dispose() {
|
|
1346
|
-
this
|
|
1353
|
+
this.#signer.dispose();
|
|
1347
1354
|
}
|
|
1348
1355
|
};
|
|
1349
1356
|
|