@hardkas/accounts 0.8.19-alpha → 0.9.0-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 +21 -2
- 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) => {
|
|
@@ -1118,8 +1134,11 @@ var KaspaSdkKeyGenerator = class {
|
|
|
1118
1134
|
const privKey = new sdk.PrivateKey(hex);
|
|
1119
1135
|
const kp = privKey.toKeypair();
|
|
1120
1136
|
const address = kp.toAddress(network).toString();
|
|
1121
|
-
const privateKeyStr = kp.privateKey;
|
|
1122
|
-
const publicKeyStr = kp.publicKey;
|
|
1137
|
+
const privateKeyStr = typeof kp.privateKey === "object" ? hex : kp.privateKey;
|
|
1138
|
+
const publicKeyStr = typeof kp.publicKey === "object" ? kp.publicKey.toString() : kp.publicKey;
|
|
1139
|
+
if (typeof privateKeyStr !== "string" || !/^[0-9a-f]{64}$/i.test(privateKeyStr)) {
|
|
1140
|
+
throw new Error("Generated private key is not a valid 64-character hex string.");
|
|
1141
|
+
}
|
|
1123
1142
|
return {
|
|
1124
1143
|
address,
|
|
1125
1144
|
publicKey: publicKeyStr,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hardkas/accounts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0-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/
|
|
23
|
-
"@hardkas/
|
|
24
|
-
"@hardkas/core": "0.
|
|
25
|
-
"@hardkas/localnet": "0.
|
|
22
|
+
"@hardkas/artifacts": "0.9.0-alpha",
|
|
23
|
+
"@hardkas/config": "0.9.0-alpha",
|
|
24
|
+
"@hardkas/core": "0.9.0-alpha",
|
|
25
|
+
"@hardkas/localnet": "0.9.0-alpha"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"tsup": "^8.3.5",
|