@cogcoin/client 0.5.1 → 0.5.3
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/README.md +6 -2
- package/dist/app-paths.d.ts +1 -0
- package/dist/app-paths.js +2 -0
- package/dist/bitcoind/client/follow-loop.d.ts +3 -4
- package/dist/bitcoind/client/follow-loop.js +16 -2
- package/dist/bitcoind/client/internal-types.d.ts +10 -2
- package/dist/bitcoind/client/managed-client.js +1 -1
- package/dist/cli/output.js +1 -1
- package/dist/cli/parse.d.ts +1 -1
- package/dist/cli/parse.js +4 -4
- package/dist/wallet/descriptor-normalization.d.ts +42 -0
- package/dist/wallet/descriptor-normalization.js +108 -0
- package/dist/wallet/lifecycle.d.ts +14 -0
- package/dist/wallet/lifecycle.js +168 -36
- package/dist/wallet/mining/control.js +4 -4
- package/dist/wallet/mining/runner.js +2 -2
- package/dist/wallet/read/context.d.ts +3 -0
- package/dist/wallet/read/context.js +120 -23
- package/dist/wallet/runtime.d.ts +1 -0
- package/dist/wallet/runtime.js +1 -0
- package/dist/wallet/state/crypto.js +12 -24
- package/dist/wallet/state/explicit-lock.d.ts +4 -0
- package/dist/wallet/state/explicit-lock.js +19 -0
- package/dist/wallet/tx/anchor.js +1 -0
- package/dist/wallet/tx/cog.js +3 -0
- package/dist/wallet/tx/domain-admin.js +1 -0
- package/dist/wallet/tx/domain-market.js +3 -0
- package/dist/wallet/tx/field.js +2 -0
- package/dist/wallet/tx/register.js +1 -0
- package/dist/wallet/tx/reputation.js +1 -0
- package/dist/wallet/types.d.ts +5 -0
- package/package.json +3 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { argon2id } from "hash-wasm";
|
|
2
|
+
import { createCipheriv, createDecipheriv, randomBytes, } from "node:crypto";
|
|
3
3
|
const DEFAULT_ARGON2_MEMORY_KIB = 65_536;
|
|
4
4
|
const DEFAULT_ARGON2_ITERATIONS = 3;
|
|
5
5
|
const DEFAULT_ARGON2_PARALLELISM = 1;
|
|
@@ -7,12 +7,6 @@ const DERIVED_KEY_LENGTH = 32;
|
|
|
7
7
|
const GCM_NONCE_BYTES = 12;
|
|
8
8
|
const ARGON2_SALT_BYTES = 16;
|
|
9
9
|
const BIGINT_JSON_TAG = "$cogcoinBigInt";
|
|
10
|
-
function requireArgon2() {
|
|
11
|
-
if (typeof crypto.argon2 !== "function") {
|
|
12
|
-
throw new Error("Node.js 24.7.0 or newer is required because node:crypto argon2 is unavailable.");
|
|
13
|
-
}
|
|
14
|
-
return crypto.argon2;
|
|
15
|
-
}
|
|
16
10
|
function jsonReplacer(_key, value) {
|
|
17
11
|
if (typeof value === "bigint") {
|
|
18
12
|
return {
|
|
@@ -30,23 +24,17 @@ function jsonReviver(_key, value) {
|
|
|
30
24
|
}
|
|
31
25
|
return value;
|
|
32
26
|
}
|
|
33
|
-
function deriveArgon2Key(message, nonce, memoryKib, iterations, parallelism) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}, (error, derivedKey) => {
|
|
43
|
-
if (error) {
|
|
44
|
-
reject(error);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
resolve(Buffer.from(derivedKey));
|
|
48
|
-
});
|
|
27
|
+
async function deriveArgon2Key(message, nonce, memoryKib, iterations, parallelism) {
|
|
28
|
+
const derivedKey = await argon2id({
|
|
29
|
+
password: message,
|
|
30
|
+
salt: nonce,
|
|
31
|
+
memorySize: memoryKib,
|
|
32
|
+
iterations,
|
|
33
|
+
parallelism,
|
|
34
|
+
hashLength: DERIVED_KEY_LENGTH,
|
|
35
|
+
outputType: "binary",
|
|
49
36
|
});
|
|
37
|
+
return Buffer.from(derivedKey);
|
|
50
38
|
}
|
|
51
39
|
export async function deriveKeyFromPassphrase(passphrase, options = {}) {
|
|
52
40
|
const salt = Buffer.from(options.salt ?? randomBytes(ARGON2_SALT_BYTES));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WalletExplicitLockStateV1 } from "../types.js";
|
|
2
|
+
export declare function loadWalletExplicitLock(lockPath: string): Promise<WalletExplicitLockStateV1 | null>;
|
|
3
|
+
export declare function saveWalletExplicitLock(lockPath: string, state: WalletExplicitLockStateV1): Promise<void>;
|
|
4
|
+
export declare function clearWalletExplicitLock(lockPath: string): Promise<void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { readFile, rm } from "node:fs/promises";
|
|
2
|
+
import { writeJsonFileAtomic } from "../fs/atomic.js";
|
|
3
|
+
export async function loadWalletExplicitLock(lockPath) {
|
|
4
|
+
try {
|
|
5
|
+
return JSON.parse(await readFile(lockPath, "utf8"));
|
|
6
|
+
}
|
|
7
|
+
catch (error) {
|
|
8
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
throw error;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export async function saveWalletExplicitLock(lockPath, state) {
|
|
15
|
+
await writeJsonFileAtomic(lockPath, state, { mode: 0o600 });
|
|
16
|
+
}
|
|
17
|
+
export async function clearWalletExplicitLock(lockPath) {
|
|
18
|
+
await rm(lockPath, { force: true });
|
|
19
|
+
}
|
package/dist/wallet/tx/anchor.js
CHANGED
package/dist/wallet/tx/cog.js
CHANGED
|
@@ -623,6 +623,7 @@ export async function sendCog(options) {
|
|
|
623
623
|
dataDir: options.dataDir,
|
|
624
624
|
databasePath: options.databasePath,
|
|
625
625
|
secretProvider: provider,
|
|
626
|
+
walletControlLockHeld: true,
|
|
626
627
|
paths,
|
|
627
628
|
});
|
|
628
629
|
try {
|
|
@@ -763,6 +764,7 @@ export async function lockCogToDomain(options) {
|
|
|
763
764
|
dataDir: options.dataDir,
|
|
764
765
|
databasePath: options.databasePath,
|
|
765
766
|
secretProvider: provider,
|
|
767
|
+
walletControlLockHeld: true,
|
|
766
768
|
paths,
|
|
767
769
|
});
|
|
768
770
|
try {
|
|
@@ -918,6 +920,7 @@ async function runClaimLikeMutation(options, reclaim) {
|
|
|
918
920
|
dataDir: options.dataDir,
|
|
919
921
|
databasePath: options.databasePath,
|
|
920
922
|
secretProvider: provider,
|
|
923
|
+
walletControlLockHeld: true,
|
|
921
924
|
paths,
|
|
922
925
|
});
|
|
923
926
|
try {
|
|
@@ -683,6 +683,7 @@ export async function transferDomain(options) {
|
|
|
683
683
|
dataDir: options.dataDir,
|
|
684
684
|
databasePath: options.databasePath,
|
|
685
685
|
secretProvider: provider,
|
|
686
|
+
walletControlLockHeld: true,
|
|
686
687
|
paths,
|
|
687
688
|
});
|
|
688
689
|
try {
|
|
@@ -916,6 +917,7 @@ async function runSellMutation(options) {
|
|
|
916
917
|
dataDir: options.dataDir,
|
|
917
918
|
databasePath: options.databasePath,
|
|
918
919
|
secretProvider: provider,
|
|
920
|
+
walletControlLockHeld: true,
|
|
919
921
|
paths,
|
|
920
922
|
});
|
|
921
923
|
try {
|
|
@@ -1143,6 +1145,7 @@ export async function buyDomain(options) {
|
|
|
1143
1145
|
dataDir: options.dataDir,
|
|
1144
1146
|
databasePath: options.databasePath,
|
|
1145
1147
|
secretProvider: provider,
|
|
1148
|
+
walletControlLockHeld: true,
|
|
1146
1149
|
paths,
|
|
1147
1150
|
});
|
|
1148
1151
|
try {
|
package/dist/wallet/tx/field.js
CHANGED
|
@@ -1267,6 +1267,7 @@ async function submitStandaloneFieldMutation(options) {
|
|
|
1267
1267
|
dataDir: options.dataDir,
|
|
1268
1268
|
databasePath: options.databasePath,
|
|
1269
1269
|
secretProvider: provider,
|
|
1270
|
+
walletControlLockHeld: true,
|
|
1270
1271
|
paths,
|
|
1271
1272
|
});
|
|
1272
1273
|
try {
|
|
@@ -1418,6 +1419,7 @@ async function submitFieldCreateFamily(options) {
|
|
|
1418
1419
|
dataDir: options.dataDir,
|
|
1419
1420
|
databasePath: options.databasePath,
|
|
1420
1421
|
secretProvider: provider,
|
|
1422
|
+
walletControlLockHeld: true,
|
|
1421
1423
|
paths,
|
|
1422
1424
|
});
|
|
1423
1425
|
try {
|
package/dist/wallet/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cogcoin/client",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "Store-backed Cogcoin client with wallet flows, SQLite persistence, and managed Bitcoin Core integration.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
8
|
-
"node": ">=
|
|
8
|
+
"node": ">=22.0.0"
|
|
9
9
|
},
|
|
10
10
|
"homepage": "https://cogcoin.org",
|
|
11
11
|
"repository": {
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"@scure/bip32": "^2.0.1",
|
|
69
69
|
"@scure/bip39": "^2.0.1",
|
|
70
70
|
"better-sqlite3": "12.8.0",
|
|
71
|
+
"hash-wasm": "^4.12.0",
|
|
71
72
|
"zeromq": "6.5.0"
|
|
72
73
|
},
|
|
73
74
|
"devDependencies": {
|