@hardkas/accounts 0.8.18-alpha → 0.8.20-alpha
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.js +23 -3
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -52,6 +52,17 @@ function loadRealAccountStoreSync(options) {
|
|
|
52
52
|
try {
|
|
53
53
|
const data = fs.readFileSync(filePath, "utf-8");
|
|
54
54
|
const store = JSON.parse(data);
|
|
55
|
+
for (const a of store.accounts) {
|
|
56
|
+
if ("privateKey" in a && a.privateKey !== void 0) {
|
|
57
|
+
if (a.privateKey === null || a.privateKey === "" || a.privateKey === "[object Object]" || typeof a.privateKey === "object" || typeof a.privateKey === "string" && a.privateKey.includes("__wbg_ptr") || typeof a.privateKey === "object" && "__wbg_ptr" in a.privateKey) {
|
|
58
|
+
const err = new Error(
|
|
59
|
+
"CORRUPTED_PRIVATE_KEY_SERIALIZATION: This account was generated by a broken alpha and must be regenerated. The private key was not recoverably stored."
|
|
60
|
+
);
|
|
61
|
+
err.code = "CORRUPTED_PRIVATE_KEY_SERIALIZATION";
|
|
62
|
+
throw err;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
55
66
|
const plaintextAccounts = store.accounts.filter((a) => a.privateKey);
|
|
56
67
|
if (plaintextAccounts.length > 0) {
|
|
57
68
|
const names = plaintextAccounts.map((a) => a.name).join(", ");
|
|
@@ -899,6 +910,11 @@ var KaspaWasmPrivateKeySigner = class {
|
|
|
899
910
|
err.code = "DEV_ACCOUNT_KEY_UNAVAILABLE";
|
|
900
911
|
throw err;
|
|
901
912
|
}
|
|
913
|
+
if (typeof pkValue !== "string" || pkValue.trim() === "" || !/^[0-9a-fA-F]{64}$/.test(pkValue)) {
|
|
914
|
+
const err = new Error("INVALID_PRIVATE_KEY_MATERIAL: Private key must be a valid 64-character hex string.");
|
|
915
|
+
err.code = "INVALID_PRIVATE_KEY_MATERIAL";
|
|
916
|
+
throw err;
|
|
917
|
+
}
|
|
902
918
|
try {
|
|
903
919
|
const privateKey = new sdk.PrivateKey(pkValue);
|
|
904
920
|
const utxos = plan.inputs.map((u) => {
|
|
@@ -1099,8 +1115,9 @@ var KaspaSdkKeyGenerator = class {
|
|
|
1099
1115
|
try {
|
|
1100
1116
|
return await rawLoader();
|
|
1101
1117
|
} catch (e) {
|
|
1118
|
+
const String2 = globalThis.String;
|
|
1102
1119
|
const err = new Error(
|
|
1103
|
-
"WALLET_BACKEND_UNAVAILABLE: Kaspa cryptography adapter missing. Real account generation requires WASM execution.\nUse 'hardkas accounts real import' to add a test fixture manually for now."
|
|
1120
|
+
"WALLET_BACKEND_UNAVAILABLE: Kaspa cryptography adapter missing. Real account generation requires WASM execution.\nError details: " + String2(e) + "\nUse 'hardkas accounts real import' to add a test fixture manually for now."
|
|
1104
1121
|
);
|
|
1105
1122
|
err.code = "WALLET_BACKEND_UNAVAILABLE";
|
|
1106
1123
|
throw err;
|
|
@@ -1118,8 +1135,11 @@ var KaspaSdkKeyGenerator = class {
|
|
|
1118
1135
|
const privKey = new sdk.PrivateKey(hex);
|
|
1119
1136
|
const kp = privKey.toKeypair();
|
|
1120
1137
|
const address = kp.toAddress(network).toString();
|
|
1121
|
-
const privateKeyStr = kp.privateKey;
|
|
1122
|
-
const publicKeyStr = kp.publicKey;
|
|
1138
|
+
const privateKeyStr = typeof kp.privateKey === "object" ? hex : kp.privateKey;
|
|
1139
|
+
const publicKeyStr = typeof kp.publicKey === "object" ? kp.publicKey.toString() : kp.publicKey;
|
|
1140
|
+
if (typeof privateKeyStr !== "string" || !/^[0-9a-f]{64}$/i.test(privateKeyStr)) {
|
|
1141
|
+
throw new Error("Generated private key is not a valid 64-character hex string.");
|
|
1142
|
+
}
|
|
1123
1143
|
return {
|
|
1124
1144
|
address,
|
|
1125
1145
|
publicKey: publicKeyStr,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hardkas/accounts",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.20-alpha",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"hash-wasm": "^4.12.0",
|
|
21
21
|
"kaspa-wasm": "0.13.0",
|
|
22
|
-
"@hardkas/config": "0.8.
|
|
23
|
-
"@hardkas/
|
|
24
|
-
"@hardkas/
|
|
25
|
-
"@hardkas/localnet": "0.8.
|
|
22
|
+
"@hardkas/config": "0.8.20-alpha",
|
|
23
|
+
"@hardkas/artifacts": "0.8.20-alpha",
|
|
24
|
+
"@hardkas/core": "0.8.20-alpha",
|
|
25
|
+
"@hardkas/localnet": "0.8.20-alpha"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"tsup": "^8.3.5",
|