@hardkas/accounts 0.12.0-rc.21 → 0.12.0-rc.23

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.
@@ -2,7 +2,7 @@ import {
2
2
  LazyAccountAuthorizer,
3
3
  PrivateKeyAuthorizer,
4
4
  StaticSignatureScriptAuthorizer
5
- } from "./chunk-E73SSWAX.js";
5
+ } from "./chunk-PKDTLCCQ.js";
6
6
  export {
7
7
  LazyAccountAuthorizer,
8
8
  PrivateKeyAuthorizer,
@@ -7,12 +7,39 @@ import { CrossWorldAccountCollisionError, AccountNetworkMismatchError } from "@h
7
7
  // src/real-accounts.ts
8
8
  import fs from "fs";
9
9
  import path from "path";
10
+ import util from "util";
10
11
  import { writeFileAtomicSync } from "@hardkas/core";
11
12
  import {
12
13
  HARDKAS_VERSION,
13
14
  ARTIFACT_SCHEMAS,
14
15
  ARTIFACT_VERSION
15
16
  } from "@hardkas/artifacts";
17
+ var ACCOUNT_SECRET_FIELDS = /* @__PURE__ */ new Set([
18
+ "privateKey",
19
+ "privateKeyEnv",
20
+ "keystoreRef"
21
+ ]);
22
+ function redactAccountForLog(a) {
23
+ const out = {};
24
+ for (const k of Object.keys(a)) {
25
+ out[k] = ACCOUNT_SECRET_FIELDS.has(k) && a[k] !== void 0 ? "[REDACTED]" : a[k];
26
+ }
27
+ return out;
28
+ }
29
+ function attachInspectRedactor(obj) {
30
+ try {
31
+ Object.defineProperty(obj, util.inspect.custom, {
32
+ value(_depth, _opts, inspect) {
33
+ return inspect(redactAccountForLog(this), _opts);
34
+ },
35
+ enumerable: false,
36
+ configurable: true,
37
+ writable: true
38
+ });
39
+ } catch {
40
+ }
41
+ return obj;
42
+ }
16
43
  function getDefaultRealAccountsPath(cwd) {
17
44
  const root = cwd ?? process.cwd();
18
45
  return path.join(root, ".hardkas", "accounts.real.json");
@@ -62,6 +89,9 @@ function loadRealAccountStoreSync(options) {
62
89
  `
63
90
  );
64
91
  }
92
+ for (const a of store.accounts) {
93
+ attachInspectRedactor(a);
94
+ }
65
95
  return store;
66
96
  } catch (e) {
67
97
  throw new Error(
@@ -403,7 +433,6 @@ function listHardkasAccounts(config, executionTarget) {
403
433
  const existing = accounts.get(name);
404
434
  const configKind = accConfig.kind === "simulated" ? "synthetic" : accConfig.kind;
405
435
  if (existing && existing.kind !== configKind) {
406
- console.error(`COLLISION DETECTED for ${name}. existing:`, existing, `configKind:`, configKind);
407
436
  throw new CrossWorldAccountCollisionError({ accountId: name, worlds: [existing.kind, configKind] });
408
437
  }
409
438
  accounts.set(name, {
@@ -414,7 +443,9 @@ function listHardkasAccounts(config, executionTarget) {
414
443
  });
415
444
  }
416
445
  }
417
- return Array.from(accounts.values());
446
+ const list = Array.from(accounts.values());
447
+ for (const a of list) attachInspectRedactor(a);
448
+ return list;
418
449
  }
419
450
  async function resolveHardkasAccountAddress(accountOrAddress, config, context = "L1") {
420
451
  if (accountOrAddress.startsWith("kaspa:") || accountOrAddress.startsWith("kaspatest:") || accountOrAddress.startsWith("kaspasim:")) {
@@ -489,6 +520,8 @@ function describeAccount(account) {
489
520
  }
490
521
 
491
522
  export {
523
+ redactAccountForLog,
524
+ attachInspectRedactor,
492
525
  getDefaultRealAccountsPath,
493
526
  createEmptyRealAccountStore,
494
527
  loadRealAccountStoreSync,
@@ -62,7 +62,7 @@ var LazyAccountAuthorizer = class {
62
62
  accountName;
63
63
  workspaceRoot;
64
64
  async authorize(context) {
65
- const { resolveHardkasAccount } = await import("./resolve-KMMTZWC3.js");
65
+ const { resolveHardkasAccount } = await import("./resolve-FO4P46YC.js");
66
66
  const account = await resolveHardkasAccount({
67
67
  nameOrAddress: this.accountName,
68
68
  config: { cwd: this.workspaceRoot }
@@ -74,7 +74,7 @@ var LazyAccountAuthorizer = class {
74
74
  if (!pkValue && account.keystorePath) {
75
75
  try {
76
76
  const { KeystoreManager } = await import("./keystore-CMWEKGBF.js");
77
- const { DEV_ACCOUNTS_PASSWORD } = await import("./dev-accounts-BSWPKAAE.js");
77
+ const { DEV_ACCOUNTS_PASSWORD } = await import("./dev-accounts-JTJKQAPV.js");
78
78
  const keystore = await KeystoreManager.loadEncryptedKeystore(account.keystorePath);
79
79
  const unlock = await KeystoreManager.decryptEncryptedKeystore(keystore, DEV_ACCOUNTS_PASSWORD);
80
80
  if (unlock.success && unlock.payload) {
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-BNF566PS.js";
7
7
  import {
8
8
  resolveHardkasAccount
9
- } from "./chunk-7KKJXU73.js";
9
+ } from "./chunk-2UQTGGML.js";
10
10
  import {
11
11
  KeystoreManager
12
12
  } from "./chunk-YLG2NIAU.js";
@@ -18,7 +18,7 @@ import crypto from "crypto";
18
18
  import { deterministicCompare, getNetworkPrefix as getNetworkPrefix2 } from "@hardkas/core";
19
19
 
20
20
  // src/kaspa-wasm-signer.ts
21
- import { calculateContentHash } from "@hardkas/artifacts";
21
+ import { recomputeDeclaredContentHash } from "@hardkas/artifacts";
22
22
  import { getNetworkPrefix } from "@hardkas/core";
23
23
 
24
24
  // src/wasm-transaction.ts
@@ -133,7 +133,7 @@ var KaspaWasmPrivateKeySigner = class {
133
133
  if (!pkValue && account.keystorePath) {
134
134
  try {
135
135
  const KeystoreManager2 = (await import("./keystore-CMWEKGBF.js")).KeystoreManager;
136
- const DEV_ACCOUNTS_PASSWORD2 = (await import("./dev-accounts-BSWPKAAE.js")).DEV_ACCOUNTS_PASSWORD;
136
+ const DEV_ACCOUNTS_PASSWORD2 = (await import("./dev-accounts-JTJKQAPV.js")).DEV_ACCOUNTS_PASSWORD;
137
137
  const keystore = await KeystoreManager2.loadEncryptedKeystore(account.keystorePath);
138
138
  const unlock = await KeystoreManager2.decryptEncryptedKeystore(keystore, DEV_ACCOUNTS_PASSWORD2);
139
139
  if (unlock.success && unlock.payload) {
@@ -153,7 +153,7 @@ var KaspaWasmPrivateKeySigner = class {
153
153
  throw err;
154
154
  }
155
155
  const expectedAddress = new sdk.PrivateKey(pkValue).toKeypair().toAddress(getNetworkPrefix(plan.networkId || "simnet")).toString();
156
- const { PrivateKeyAuthorizer } = await import("./authorizers-CP222OTW.js");
156
+ const { PrivateKeyAuthorizer } = await import("./authorizers-YESBCCTJ.js");
157
157
  const sourceInputs = plan.inputs || plan.selectedUtxos || [];
158
158
  for (let i = 0; i < numInputs; i++) {
159
159
  if (!authorizers[i]) {
@@ -313,7 +313,7 @@ var KaspaWasmPrivateKeySigner = class {
313
313
  txId: signedTx.id,
314
314
  signature: {
315
315
  // We use the txid as the signature identifier in the artifact
316
- value: signedTx.id || calculateContentHash(plan)
316
+ value: signedTx.id || plan.contentHash || recomputeDeclaredContentHash(plan)
317
317
  }
318
318
  };
319
319
  } catch (error) {
@@ -344,6 +344,7 @@ async function ensureDevAccounts(workspaceDir) {
344
344
  await getOrCreateDevAccount(workspaceDir, 1, "bob");
345
345
  await getOrCreateDevAccount(workspaceDir, 2, "carol");
346
346
  await getOrCreateDevAccount(workspaceDir, 3, "dave");
347
+ await getOrCreateDevAccount(workspaceDir, 4, "erin");
347
348
  }
348
349
  async function getOrCreateDevAccount(workspaceDir, index, alias) {
349
350
  const devAccountsDir = path.join(workspaceDir, ".hardkas", "dev-accounts");
@@ -4,10 +4,10 @@ import {
4
4
  ensureDevAccounts,
5
5
  getOrCreateDevAccount,
6
6
  listDevAccountsSync
7
- } from "./chunk-CELVD4YG.js";
7
+ } from "./chunk-Q22JFUWC.js";
8
8
  import "./chunk-GM2BY4VS.js";
9
9
  import "./chunk-BNF566PS.js";
10
- import "./chunk-7KKJXU73.js";
10
+ import "./chunk-2UQTGGML.js";
11
11
  import "./chunk-YLG2NIAU.js";
12
12
  export {
13
13
  DEV_ACCOUNTS_PASSWORD,
package/dist/index.d.ts CHANGED
@@ -127,7 +127,7 @@ interface SignTxPlanResult {
127
127
  signerAddress: string;
128
128
  txId?: string;
129
129
  signedTransaction: {
130
- format: "hex" | "simulated" | "unknown";
130
+ format: "hex" | "synthetic-authorization" | "unknown";
131
131
  payload: string;
132
132
  };
133
133
  signature?: {
@@ -626,6 +626,18 @@ declare function assertSigningNetworkAllowed(input: {
626
626
  allowMainnet?: boolean | undefined;
627
627
  }): void;
628
628
 
629
+ /**
630
+ * Returns a shallow clone of an account with secret-bearing fields replaced by "[REDACTED]".
631
+ * Preserves `name`, `address`, `publicKey`, `createdAt`, and any other non-secret metadata.
632
+ */
633
+ declare function redactAccountForLog<T extends Record<string, unknown>>(a: T): T;
634
+ /**
635
+ * Attaches a self-redacting `util.inspect.custom` handler so `console.log(account)`
636
+ * and Node's default error formatter never surface secrets. `JSON.stringify` is
637
+ * NOT affected — the disk-write path in `saveRealAccountStore` still round-trips
638
+ * the raw store, which is why disk permissions are enforced to 0o600.
639
+ */
640
+ declare function attachInspectRedactor<T extends object>(obj: T): T;
629
641
  interface RealAccountStore extends HardkasArtifactBase {
630
642
  readonly schema: "hardkas.realAccountStore.v1";
631
643
  readonly networkId: NetworkId;
@@ -913,4 +925,4 @@ declare class WalletStateStoreJson {
913
925
  nextChangeIndex(walletId: string): number;
914
926
  }
915
927
 
916
- export { AddressManager, type BalancedOutput, type ChainType, type CovenantFundingInput, type CovenantGenesisRequest, type CovenantTransactionResult, type CovenantTransitionRequest, type CovenantUtxo, type CreateKaspaWalletOptions, DEV_ACCOUNTS_PASSWORD, type DeriveRequest, type DerivedAddress, type EncryptedKeystoreV2, type EvmExportResult, type GeneratedKaspaDevAccount, type HardkasAccount, type HardkasAccountKind, type HardkasBaseAccount, type HardkasEvmPrivateKeyAccount, type HardkasExternalWalletAccount, type HardkasKaspaAccount, type HardkasSigner, type HardkasSignerKind, type HardkasSyntheticAccount, type HardkasTxPlanSigner, type HelperDeriveRequest, type InputAuthorization, type KaspaKeyGenerator, KaspaSdkKeyGenerator, type KaspaSdkKeyGeneratorOptions, KaspaSdkRealTxSigner, type KaspaSdkRealTxSignerOptions, type KaspaSigningBackendStatus, KaspaWasmPrivateKeySigner, type KaspaWasmSignerOptions, type KeystoreCipherParams, type KeystoreKdfParams, KeystoreManager, type KeystorePayload, type KeystoreUnlockResult, LazyAccountAuthorizer, type NetworkType, type PathRequest, PrivateKeyAuthorizer, type RealAccountStore, type RealDevAccount, type RealTxSigner, type RealTxSigningInput, type RealTxSigningResult, SILVER_SPEND_DRAFT_SCHEMA, type ScriptFundingRequest, type ScriptFundingResult, type ScriptOutput, type SignTxPlanInput, type SignTxPlanResult, type SilverContractUtxo, type SilverDraftArg, type SilverSignatureArg, type SilverSignerSlot, type SilverSpendArg, type SilverSpendDraft, type SilverSpendDraftRequest, type SilverSpendResult, type SilverSweepRequest, SimulatedSigner, StaticSignatureScriptAuthorizer, type TxInputAuthorizationContext, type TxInputAuthorizer, UnsupportedKaspaKeyGenerator, UnsupportedRealKaspaSigner, UnsupportedRealTxSigner, type WalletArtifact, type WalletClaims, type WalletCreateRequest, type WalletImportRequest, WalletManager, WalletManagerImpl, type WalletMetadata, type WalletState, WalletStateStoreJson, type WalletStateStoreOptions, type WasmInputSigner, type WasmProviderConfig, type WasmUtxoEntrySource, type WasmUtxoInput, appendToKeystoreJson, assertAccountCompatible, assertSigningNetworkAllowed, assertValueConservation, buildCovenantGenesis, buildCovenantTransition, buildScriptFunding, buildSilverSweep, createBalancedTransaction, createDevSigner, createEmptyRealAccountStore, createLocalKaspaWallet, createScriptTransaction, describeAccount, detectCapabilities, ensureDevAccounts, finalizeSilverSpend, getDefaultRealAccountsPath, getKaspaSigningBackendStatus, getOrCreateDevAccount, getRealDevAccount, getRequiredEnv, importRealDevAccount, listDevAccountsSync, listHardkasAccounts, listRealDevAccounts, loadKaspaWasm, loadKaspaWasmSync, loadOrCreateRealAccountStore, loadRealAccountStore, loadRealAccountStoreSync, planOutputsWithChange, prepareEvmAccountExport, prepareSilverSpend, removeRealDevAccount, resolveHardkasAccount, resolveHardkasAccountAddress, resolveRealAccountOrAddress, saveRealAccountStore, signSilverSpend, signTxPlanArtifact, toWasmScriptPublicKey, validateAccountName, validateAddressNetwork, validateAddressPrefix, withKeystoreLock };
928
+ export { AddressManager, type BalancedOutput, type ChainType, type CovenantFundingInput, type CovenantGenesisRequest, type CovenantTransactionResult, type CovenantTransitionRequest, type CovenantUtxo, type CreateKaspaWalletOptions, DEV_ACCOUNTS_PASSWORD, type DeriveRequest, type DerivedAddress, type EncryptedKeystoreV2, type EvmExportResult, type GeneratedKaspaDevAccount, type HardkasAccount, type HardkasAccountKind, type HardkasBaseAccount, type HardkasEvmPrivateKeyAccount, type HardkasExternalWalletAccount, type HardkasKaspaAccount, type HardkasSigner, type HardkasSignerKind, type HardkasSyntheticAccount, type HardkasTxPlanSigner, type HelperDeriveRequest, type InputAuthorization, type KaspaKeyGenerator, KaspaSdkKeyGenerator, type KaspaSdkKeyGeneratorOptions, KaspaSdkRealTxSigner, type KaspaSdkRealTxSignerOptions, type KaspaSigningBackendStatus, KaspaWasmPrivateKeySigner, type KaspaWasmSignerOptions, type KeystoreCipherParams, type KeystoreKdfParams, KeystoreManager, type KeystorePayload, type KeystoreUnlockResult, LazyAccountAuthorizer, type NetworkType, type PathRequest, PrivateKeyAuthorizer, type RealAccountStore, type RealDevAccount, type RealTxSigner, type RealTxSigningInput, type RealTxSigningResult, SILVER_SPEND_DRAFT_SCHEMA, type ScriptFundingRequest, type ScriptFundingResult, type ScriptOutput, type SignTxPlanInput, type SignTxPlanResult, type SilverContractUtxo, type SilverDraftArg, type SilverSignatureArg, type SilverSignerSlot, type SilverSpendArg, type SilverSpendDraft, type SilverSpendDraftRequest, type SilverSpendResult, type SilverSweepRequest, SimulatedSigner, StaticSignatureScriptAuthorizer, type TxInputAuthorizationContext, type TxInputAuthorizer, UnsupportedKaspaKeyGenerator, UnsupportedRealKaspaSigner, UnsupportedRealTxSigner, type WalletArtifact, type WalletClaims, type WalletCreateRequest, type WalletImportRequest, WalletManager, WalletManagerImpl, type WalletMetadata, type WalletState, WalletStateStoreJson, type WalletStateStoreOptions, type WasmInputSigner, type WasmProviderConfig, type WasmUtxoEntrySource, type WasmUtxoInput, appendToKeystoreJson, assertAccountCompatible, assertSigningNetworkAllowed, assertValueConservation, attachInspectRedactor, buildCovenantGenesis, buildCovenantTransition, buildScriptFunding, buildSilverSweep, createBalancedTransaction, createDevSigner, createEmptyRealAccountStore, createLocalKaspaWallet, createScriptTransaction, describeAccount, detectCapabilities, ensureDevAccounts, finalizeSilverSpend, getDefaultRealAccountsPath, getKaspaSigningBackendStatus, getOrCreateDevAccount, getRealDevAccount, getRequiredEnv, importRealDevAccount, listDevAccountsSync, listHardkasAccounts, listRealDevAccounts, loadKaspaWasm, loadKaspaWasmSync, loadOrCreateRealAccountStore, loadRealAccountStore, loadRealAccountStoreSync, planOutputsWithChange, prepareEvmAccountExport, prepareSilverSpend, redactAccountForLog, removeRealDevAccount, resolveHardkasAccount, resolveHardkasAccountAddress, resolveRealAccountOrAddress, saveRealAccountStore, signSilverSpend, signTxPlanArtifact, toWasmScriptPublicKey, validateAccountName, validateAddressNetwork, validateAddressPrefix, withKeystoreLock };
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  listDevAccountsSync,
12
12
  planOutputsWithChange,
13
13
  toWasmScriptPublicKey
14
- } from "./chunk-CELVD4YG.js";
14
+ } from "./chunk-Q22JFUWC.js";
15
15
  import {
16
16
  parseWasmTxToRpc
17
17
  } from "./chunk-GM2BY4VS.js";
@@ -23,6 +23,7 @@ import {
23
23
  } from "./chunk-BNF566PS.js";
24
24
  import {
25
25
  assertAccountCompatible,
26
+ attachInspectRedactor,
26
27
  createEmptyRealAccountStore,
27
28
  describeAccount,
28
29
  getDefaultRealAccountsPath,
@@ -33,6 +34,7 @@ import {
33
34
  loadOrCreateRealAccountStore,
34
35
  loadRealAccountStore,
35
36
  loadRealAccountStoreSync,
37
+ redactAccountForLog,
36
38
  removeRealDevAccount,
37
39
  resolveHardkasAccount,
38
40
  resolveHardkasAccountAddress,
@@ -41,7 +43,7 @@ import {
41
43
  validateAccountName,
42
44
  validateAddressNetwork,
43
45
  validateAddressPrefix
44
- } from "./chunk-7KKJXU73.js";
46
+ } from "./chunk-2UQTGGML.js";
45
47
  import {
46
48
  KeystoreManager
47
49
  } from "./chunk-YLG2NIAU.js";
@@ -49,7 +51,7 @@ import {
49
51
  LazyAccountAuthorizer,
50
52
  PrivateKeyAuthorizer,
51
53
  StaticSignatureScriptAuthorizer
52
- } from "./chunk-E73SSWAX.js";
54
+ } from "./chunk-PKDTLCCQ.js";
53
55
 
54
56
  // src/simulated.ts
55
57
  var SimulatedSigner = class {
@@ -130,6 +132,7 @@ function getRequiredEnv(name) {
130
132
  import {
131
133
  createSimulatedSignedTxArtifact,
132
134
  calculateContentHash,
135
+ CURRENT_HASH_VERSION,
133
136
  HARDKAS_VERSION,
134
137
  createLineageTransition
135
138
  } from "@hardkas/artifacts";
@@ -165,7 +168,7 @@ async function signTxPlanArtifact(input) {
165
168
  if (planArtifact.mode === "simulator") {
166
169
  return createSimulatedSignedTxArtifact(
167
170
  planArtifact,
168
- `simulated-signed-tx:${planArtifact.planId}`,
171
+ account ?? planArtifact.from.address,
169
172
  systemRuntimeContext
170
173
  );
171
174
  }
@@ -203,6 +206,7 @@ async function signTxPlanArtifact(input) {
203
206
  schema: "hardkas.signedTx",
204
207
  hardkasVersion: HARDKAS_VERSION,
205
208
  version: "1.0.0-alpha",
209
+ hashVersion: CURRENT_HASH_VERSION,
206
210
  status: "signed",
207
211
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
208
212
  txId: result.txId || "",
@@ -225,7 +229,7 @@ async function signTxPlanArtifact(input) {
225
229
  ...planArtifact.networkProfileRef ? { networkProfileRef: planArtifact.networkProfileRef } : {},
226
230
  ...planArtifact.assumptionRef ? { assumptionRef: planArtifact.assumptionRef } : {}
227
231
  };
228
- const contentHash = calculateContentHash(artifact);
232
+ const contentHash = calculateContentHash(artifact, CURRENT_HASH_VERSION);
229
233
  artifact.signedId = `signed-${contentHash.slice(0, 16)}`;
230
234
  artifact.contentHash = contentHash;
231
235
  if (artifact.lineage) {
@@ -1244,6 +1248,7 @@ export {
1244
1248
  assertAccountCompatible,
1245
1249
  assertSigningNetworkAllowed,
1246
1250
  assertValueConservation,
1251
+ attachInspectRedactor,
1247
1252
  buildCovenantGenesis,
1248
1253
  buildCovenantTransition,
1249
1254
  buildScriptFunding,
@@ -1275,6 +1280,7 @@ export {
1275
1280
  planOutputsWithChange,
1276
1281
  prepareEvmAccountExport,
1277
1282
  prepareSilverSpend,
1283
+ redactAccountForLog,
1278
1284
  removeRealDevAccount,
1279
1285
  resolveHardkasAccount,
1280
1286
  resolveHardkasAccountAddress,
@@ -4,7 +4,7 @@ import {
4
4
  listHardkasAccounts,
5
5
  resolveHardkasAccount,
6
6
  resolveHardkasAccountAddress
7
- } from "./chunk-7KKJXU73.js";
7
+ } from "./chunk-2UQTGGML.js";
8
8
  export {
9
9
  assertAccountCompatible,
10
10
  describeAccount,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hardkas/accounts",
3
- "version": "0.12.0-rc.21",
3
+ "version": "0.12.0-rc.23",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -23,11 +23,11 @@
23
23
  ],
24
24
  "dependencies": {
25
25
  "hash-wasm": "^4.12.0",
26
- "@hardkas/artifacts": "0.12.0-rc.21",
27
- "@hardkas/config": "0.12.0-rc.21",
28
- "@hardkas/core": "0.12.0-rc.21",
29
- "@hardkas/localnet": "0.12.0-rc.21",
30
- "@hardkas/tx-builder": "0.12.0-rc.21"
26
+ "@hardkas/core": "0.12.0-rc.23",
27
+ "@hardkas/artifacts": "0.12.0-rc.23",
28
+ "@hardkas/tx-builder": "0.12.0-rc.23",
29
+ "@hardkas/config": "0.12.0-rc.23",
30
+ "@hardkas/localnet": "0.12.0-rc.23"
31
31
  },
32
32
  "devDependencies": {
33
33
  "tsup": "^8.3.5",