@cogcoin/client 1.1.6 → 1.1.8
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 +2 -2
- package/dist/bitcoind/indexer-daemon.js +29 -79
- package/dist/bitcoind/managed-runtime/bitcoind-runtime.d.ts +20 -0
- package/dist/bitcoind/managed-runtime/bitcoind-runtime.js +74 -0
- package/dist/bitcoind/managed-runtime/bitcoind-status.d.ts +11 -0
- package/dist/bitcoind/managed-runtime/bitcoind-status.js +44 -0
- package/dist/bitcoind/managed-runtime/indexer-runtime.d.ts +15 -0
- package/dist/bitcoind/managed-runtime/indexer-runtime.js +82 -0
- package/dist/bitcoind/managed-runtime/types.d.ts +40 -0
- package/dist/bitcoind/node.d.ts +2 -2
- package/dist/bitcoind/node.js +2 -2
- package/dist/bitcoind/rpc.d.ts +2 -1
- package/dist/bitcoind/rpc.js +53 -3
- package/dist/bitcoind/service.js +47 -127
- package/dist/cli/command-registry.d.ts +1 -1
- package/dist/cli/command-registry.js +2 -64
- package/dist/cli/commands/client-admin.js +3 -18
- package/dist/cli/commands/mining-runtime.js +4 -60
- package/dist/cli/commands/wallet-admin.js +6 -6
- package/dist/cli/context.js +1 -3
- package/dist/cli/mining-json.d.ts +1 -22
- package/dist/cli/mining-json.js +0 -23
- package/dist/cli/output.js +16 -2
- package/dist/cli/parse.js +0 -2
- package/dist/cli/preview-json.d.ts +1 -22
- package/dist/cli/preview-json.js +0 -19
- package/dist/cli/types.d.ts +1 -3
- package/dist/cli/wallet-format.js +1 -1
- package/dist/cli/workflow-hints.d.ts +1 -2
- package/dist/cli/workflow-hints.js +5 -8
- package/dist/wallet/lifecycle/context.js +0 -1
- package/dist/wallet/lifecycle/repair-mining.d.ts +1 -5
- package/dist/wallet/lifecycle/repair-mining.js +5 -39
- package/dist/wallet/lifecycle/repair.js +0 -3
- package/dist/wallet/lifecycle/setup.js +10 -8
- package/dist/wallet/lifecycle/types.d.ts +1 -4
- package/dist/wallet/managed-core-wallet.d.ts +2 -0
- package/dist/wallet/managed-core-wallet.js +27 -1
- package/dist/wallet/mining/candidate.d.ts +1 -0
- package/dist/wallet/mining/candidate.js +38 -6
- package/dist/wallet/mining/competitiveness.d.ts +1 -0
- package/dist/wallet/mining/competitiveness.js +6 -0
- package/dist/wallet/mining/cycle.d.ts +2 -0
- package/dist/wallet/mining/cycle.js +14 -4
- package/dist/wallet/mining/engine-state.js +10 -0
- package/dist/wallet/mining/engine-types.d.ts +1 -0
- package/dist/wallet/mining/index.d.ts +1 -1
- package/dist/wallet/mining/index.js +1 -1
- package/dist/wallet/mining/publish.d.ts +3 -0
- package/dist/wallet/mining/publish.js +78 -6
- package/dist/wallet/mining/runner.d.ts +0 -32
- package/dist/wallet/mining/runner.js +59 -104
- package/dist/wallet/mining/stop.d.ts +7 -0
- package/dist/wallet/mining/stop.js +23 -0
- package/dist/wallet/mining/supervisor.d.ts +2 -36
- package/dist/wallet/mining/supervisor.js +139 -246
- package/dist/wallet/mining/visualizer-sync.js +79 -15
- package/dist/wallet/read/context.d.ts +1 -5
- package/dist/wallet/read/context.js +21 -205
- package/dist/wallet/read/managed-services.d.ts +33 -0
- package/dist/wallet/read/managed-services.js +222 -0
- package/dist/wallet/reset/artifacts.d.ts +16 -0
- package/dist/wallet/reset/artifacts.js +141 -0
- package/dist/wallet/reset/execution.d.ts +38 -0
- package/dist/wallet/reset/execution.js +458 -0
- package/dist/wallet/reset/preflight.d.ts +7 -0
- package/dist/wallet/reset/preflight.js +116 -0
- package/dist/wallet/reset/preview.d.ts +2 -0
- package/dist/wallet/reset/preview.js +50 -0
- package/dist/wallet/reset/process-cleanup.d.ts +12 -0
- package/dist/wallet/reset/process-cleanup.js +179 -0
- package/dist/wallet/reset/types.d.ts +189 -0
- package/dist/wallet/reset/types.js +1 -0
- package/dist/wallet/reset.d.ts +4 -119
- package/dist/wallet/reset.js +4 -882
- package/dist/wallet/state/client-password/bootstrap.d.ts +2 -0
- package/dist/wallet/state/client-password/bootstrap.js +3 -0
- package/dist/wallet/state/client-password/context.d.ts +10 -0
- package/dist/wallet/state/client-password/context.js +46 -0
- package/dist/wallet/state/client-password/crypto.d.ts +34 -0
- package/dist/wallet/state/client-password/crypto.js +117 -0
- package/dist/wallet/state/client-password/files.d.ts +10 -0
- package/dist/wallet/state/client-password/files.js +109 -0
- package/dist/wallet/state/client-password/legacy-cleanup.d.ts +11 -0
- package/dist/wallet/state/client-password/legacy-cleanup.js +338 -0
- package/dist/wallet/state/client-password/messages.d.ts +3 -0
- package/dist/wallet/state/client-password/messages.js +9 -0
- package/dist/wallet/state/client-password/migration.d.ts +4 -0
- package/dist/wallet/state/client-password/migration.js +32 -0
- package/dist/wallet/state/client-password/prompts.d.ts +12 -0
- package/dist/wallet/state/client-password/prompts.js +79 -0
- package/dist/wallet/state/client-password/protected-secrets.d.ts +13 -0
- package/dist/wallet/state/client-password/protected-secrets.js +90 -0
- package/dist/wallet/state/client-password/readiness.d.ts +4 -0
- package/dist/wallet/state/client-password/readiness.js +48 -0
- package/dist/wallet/state/client-password/references.d.ts +1 -0
- package/dist/wallet/state/client-password/references.js +56 -0
- package/dist/wallet/state/client-password/rotation.d.ts +6 -0
- package/dist/wallet/state/client-password/rotation.js +98 -0
- package/dist/wallet/state/client-password/session-policy.d.ts +6 -0
- package/dist/wallet/state/client-password/session-policy.js +28 -0
- package/dist/wallet/state/client-password/session.d.ts +19 -0
- package/dist/wallet/state/client-password/session.js +170 -0
- package/dist/wallet/state/client-password/setup.d.ts +8 -0
- package/dist/wallet/state/client-password/setup.js +49 -0
- package/dist/wallet/state/client-password/types.d.ts +82 -0
- package/dist/wallet/state/client-password/types.js +5 -0
- package/dist/wallet/state/client-password.d.ts +7 -38
- package/dist/wallet/state/client-password.js +52 -937
- package/dist/wallet/tx/anchor.js +123 -216
- package/dist/wallet/tx/cog.js +294 -489
- package/dist/wallet/tx/common.d.ts +2 -0
- package/dist/wallet/tx/common.js +2 -0
- package/dist/wallet/tx/domain-admin.js +111 -220
- package/dist/wallet/tx/domain-market.js +401 -681
- package/dist/wallet/tx/executor.d.ts +176 -0
- package/dist/wallet/tx/executor.js +302 -0
- package/dist/wallet/tx/field.js +109 -215
- package/dist/wallet/tx/register.js +158 -269
- package/dist/wallet/tx/reputation.js +120 -227
- package/package.json +1 -1
- package/dist/wallet/mining/worker-main.d.ts +0 -1
- package/dist/wallet/mining/worker-main.js +0 -17
- package/dist/wallet/state/client-password-agent.d.ts +0 -1
- package/dist/wallet/state/client-password-agent.js +0 -211
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { createWrappedSecretEnvelope, decryptWrappedSecretEnvelope, zeroizeBuffer, } from "./crypto.js";
|
|
2
|
+
import { promptForVerifiedClientPassword } from "./prompts.js";
|
|
3
|
+
import { resolveClientPasswordPromptSessionPolicy, resolveClientPasswordSessionUnlockUntilUnixMs, } from "./session-policy.js";
|
|
4
|
+
const activeSessions = new Map();
|
|
5
|
+
let processCleanupRegistered = false;
|
|
6
|
+
function resolveSessionCacheKey(context) {
|
|
7
|
+
return `${context.platform}\n${context.stateRoot}\n${context.directoryPath}\n${context.passwordStatePath}`;
|
|
8
|
+
}
|
|
9
|
+
function clearExpiryTimer(session) {
|
|
10
|
+
if (session.expiryTimer !== null) {
|
|
11
|
+
clearTimeout(session.expiryTimer);
|
|
12
|
+
session.expiryTimer = null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function destroySession(session) {
|
|
16
|
+
if (session === undefined) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
clearExpiryTimer(session);
|
|
20
|
+
zeroizeBuffer(session.derivedKey);
|
|
21
|
+
}
|
|
22
|
+
function clearSessionByKey(cacheKey) {
|
|
23
|
+
const existing = activeSessions.get(cacheKey);
|
|
24
|
+
if (existing === undefined) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
activeSessions.delete(cacheKey);
|
|
28
|
+
destroySession(existing);
|
|
29
|
+
}
|
|
30
|
+
function scheduleSessionExpiry(cacheKey, session) {
|
|
31
|
+
clearExpiryTimer(session);
|
|
32
|
+
if (session.unlockUntilUnixMs === null) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const remainingMs = Math.max(0, session.unlockUntilUnixMs - Date.now());
|
|
36
|
+
session.expiryTimer = setTimeout(() => {
|
|
37
|
+
clearSessionByKey(cacheKey);
|
|
38
|
+
}, remainingMs);
|
|
39
|
+
session.expiryTimer.unref();
|
|
40
|
+
}
|
|
41
|
+
export function destroyAllClientPasswordSessionsResolved() {
|
|
42
|
+
for (const session of activeSessions.values()) {
|
|
43
|
+
destroySession(session);
|
|
44
|
+
}
|
|
45
|
+
activeSessions.clear();
|
|
46
|
+
}
|
|
47
|
+
function registerProcessCleanup() {
|
|
48
|
+
if (processCleanupRegistered) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
processCleanupRegistered = true;
|
|
52
|
+
process.once("exit", () => {
|
|
53
|
+
destroyAllClientPasswordSessionsResolved();
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function getActiveSession(context) {
|
|
57
|
+
const cacheKey = resolveSessionCacheKey(context);
|
|
58
|
+
const session = activeSessions.get(cacheKey);
|
|
59
|
+
if (session === undefined) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
if (session.unlockUntilUnixMs !== null && session.unlockUntilUnixMs <= Date.now()) {
|
|
63
|
+
clearSessionByKey(cacheKey);
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
return session;
|
|
67
|
+
}
|
|
68
|
+
function putActiveSession(options) {
|
|
69
|
+
registerProcessCleanup();
|
|
70
|
+
const cacheKey = resolveSessionCacheKey(options);
|
|
71
|
+
clearSessionByKey(cacheKey);
|
|
72
|
+
if (options.unlockUntilUnixMs !== null && options.unlockUntilUnixMs <= Date.now()) {
|
|
73
|
+
return {
|
|
74
|
+
unlocked: false,
|
|
75
|
+
unlockUntilUnixMs: null,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
const session = {
|
|
79
|
+
derivedKey: Buffer.from(options.derivedKey),
|
|
80
|
+
unlockUntilUnixMs: options.unlockUntilUnixMs,
|
|
81
|
+
expiryTimer: null,
|
|
82
|
+
};
|
|
83
|
+
activeSessions.set(cacheKey, session);
|
|
84
|
+
scheduleSessionExpiry(cacheKey, session);
|
|
85
|
+
return {
|
|
86
|
+
unlocked: true,
|
|
87
|
+
unlockUntilUnixMs: session.unlockUntilUnixMs,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export async function readClientPasswordSessionStatusResolved(context) {
|
|
91
|
+
const session = getActiveSession(context);
|
|
92
|
+
return {
|
|
93
|
+
unlocked: session !== null,
|
|
94
|
+
unlockUntilUnixMs: session?.unlockUntilUnixMs ?? null,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export async function lockClientPasswordSessionResolved(context) {
|
|
98
|
+
clearSessionByKey(resolveSessionCacheKey(context));
|
|
99
|
+
return {
|
|
100
|
+
unlocked: false,
|
|
101
|
+
unlockUntilUnixMs: null,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export async function startClientPasswordSessionResolved(options) {
|
|
105
|
+
return await startClientPasswordSessionWithExpiryResolved({
|
|
106
|
+
...options,
|
|
107
|
+
unlockUntilUnixMs: resolveClientPasswordSessionUnlockUntilUnixMs(options.sessionPolicy),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
export async function startClientPasswordSessionWithExpiryResolved(options) {
|
|
111
|
+
try {
|
|
112
|
+
return putActiveSession(options);
|
|
113
|
+
}
|
|
114
|
+
finally {
|
|
115
|
+
zeroizeBuffer(options.derivedKey);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async function refreshClientPasswordSessionResolved(context) {
|
|
119
|
+
const session = getActiveSession(context);
|
|
120
|
+
if (session === null) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
session.unlockUntilUnixMs = context.unlockUntilUnixMs;
|
|
124
|
+
scheduleSessionExpiry(resolveSessionCacheKey(context), session);
|
|
125
|
+
return await readClientPasswordSessionStatusResolved(context);
|
|
126
|
+
}
|
|
127
|
+
async function unlockClientPasswordSessionWithPromptResolved(options) {
|
|
128
|
+
const derivedKey = await promptForVerifiedClientPassword({
|
|
129
|
+
context: options.context,
|
|
130
|
+
prompt: options.prompt,
|
|
131
|
+
promptMessage: "Client password: ",
|
|
132
|
+
ttyErrorCode: "wallet_client_password_unlock_requires_tty",
|
|
133
|
+
});
|
|
134
|
+
return await startClientPasswordSessionResolved({
|
|
135
|
+
...options.context,
|
|
136
|
+
derivedKey,
|
|
137
|
+
sessionPolicy: resolveClientPasswordPromptSessionPolicy(options.prompt),
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
export async function unlockClientPasswordSessionResolved(options) {
|
|
141
|
+
const sessionPolicy = resolveClientPasswordPromptSessionPolicy(options.prompt);
|
|
142
|
+
const currentStatus = await readClientPasswordSessionStatusResolved(options.context);
|
|
143
|
+
if (currentStatus.unlocked) {
|
|
144
|
+
const refreshed = await refreshClientPasswordSessionResolved({
|
|
145
|
+
...options.context,
|
|
146
|
+
unlockUntilUnixMs: resolveClientPasswordSessionUnlockUntilUnixMs(sessionPolicy),
|
|
147
|
+
});
|
|
148
|
+
if (refreshed !== null) {
|
|
149
|
+
return refreshed;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (!options.prompt.isInteractive) {
|
|
153
|
+
throw new Error("wallet_client_password_unlock_requires_tty");
|
|
154
|
+
}
|
|
155
|
+
return await unlockClientPasswordSessionWithPromptResolved(options);
|
|
156
|
+
}
|
|
157
|
+
export function decryptClientProtectedSecretWithSessionResolved(context, envelope) {
|
|
158
|
+
const session = getActiveSession(context);
|
|
159
|
+
if (session === null) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
return new Uint8Array(decryptWrappedSecretEnvelope(envelope, session.derivedKey));
|
|
163
|
+
}
|
|
164
|
+
export function encryptClientProtectedSecretWithSessionResolved(context, secret) {
|
|
165
|
+
const session = getActiveSession(context);
|
|
166
|
+
if (session === null) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
return createWrappedSecretEnvelope(secret, session.derivedKey);
|
|
170
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ClientPasswordPrompt, ClientPasswordResolvedContext, ClientPasswordSessionStatus, ClientPasswordSetupAction } from "./types.js";
|
|
2
|
+
export declare function ensureClientPasswordConfiguredResolved(options: {
|
|
3
|
+
context: ClientPasswordResolvedContext;
|
|
4
|
+
prompt: ClientPasswordPrompt;
|
|
5
|
+
}): Promise<{
|
|
6
|
+
action: ClientPasswordSetupAction;
|
|
7
|
+
session: ClientPasswordSessionStatus;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { mkdir } from "node:fs/promises";
|
|
2
|
+
import { createClientPasswordState, zeroizeBuffer, } from "./crypto.js";
|
|
3
|
+
import { writeClientPasswordState } from "./files.js";
|
|
4
|
+
import { migrateReferencedSecrets } from "./migration.js";
|
|
5
|
+
import { promptForNewPassword } from "./prompts.js";
|
|
6
|
+
import { inspectClientPasswordReadinessResolved } from "./readiness.js";
|
|
7
|
+
import { resolveClientPasswordPromptSessionPolicy } from "./session-policy.js";
|
|
8
|
+
import { finalizePendingClientPasswordRotationIfNeeded } from "./rotation.js";
|
|
9
|
+
import { startClientPasswordSessionResolved } from "./session.js";
|
|
10
|
+
import { readClientPasswordSessionStatusResolved } from "./session.js";
|
|
11
|
+
export async function ensureClientPasswordConfiguredResolved(options) {
|
|
12
|
+
await finalizePendingClientPasswordRotationIfNeeded(options.context);
|
|
13
|
+
const readiness = await inspectClientPasswordReadinessResolved(options.context);
|
|
14
|
+
if (readiness === "ready") {
|
|
15
|
+
return {
|
|
16
|
+
action: "already-configured",
|
|
17
|
+
session: await readClientPasswordSessionStatusResolved(options.context),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const setup = await promptForNewPassword(options.prompt);
|
|
21
|
+
let derivedKey = null;
|
|
22
|
+
try {
|
|
23
|
+
const created = await createClientPasswordState({
|
|
24
|
+
passwordBytes: setup.passwordBytes,
|
|
25
|
+
passwordHint: setup.passwordHint,
|
|
26
|
+
});
|
|
27
|
+
derivedKey = created.derivedKey;
|
|
28
|
+
await mkdir(options.context.directoryPath, { recursive: true, mode: 0o700 });
|
|
29
|
+
await writeClientPasswordState(options.context.passwordStatePath, created.state);
|
|
30
|
+
const migrated = await migrateReferencedSecrets({
|
|
31
|
+
...options.context,
|
|
32
|
+
derivedKey,
|
|
33
|
+
});
|
|
34
|
+
const session = await startClientPasswordSessionResolved({
|
|
35
|
+
...options.context,
|
|
36
|
+
derivedKey,
|
|
37
|
+
sessionPolicy: resolveClientPasswordPromptSessionPolicy(options.prompt),
|
|
38
|
+
});
|
|
39
|
+
derivedKey = null;
|
|
40
|
+
return {
|
|
41
|
+
action: migrated || readiness === "migration-required" ? "migrated" : "created",
|
|
42
|
+
session,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
zeroizeBuffer(setup.passwordBytes);
|
|
47
|
+
zeroizeBuffer(derivedKey);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export declare const CLIENT_PASSWORD_STATE_FORMAT = "cogcoin-client-password";
|
|
2
|
+
export declare const CLIENT_PASSWORD_ROTATION_JOURNAL_FORMAT = "cogcoin-client-password-rotation";
|
|
3
|
+
export declare const CLIENT_PASSWORD_VERIFIER_FORMAT = "cogcoin-client-password-verifier";
|
|
4
|
+
export declare const LOCAL_SECRET_ENVELOPE_FORMAT = "cogcoin-local-wallet-secret";
|
|
5
|
+
export declare const CLIENT_PASSWORD_VERIFIER_TEXT = "cogcoin-client-password-verifier-v1";
|
|
6
|
+
export type ClientPasswordReadiness = "ready" | "setup-required" | "migration-required";
|
|
7
|
+
export type ClientPasswordSetupAction = "created" | "migrated" | "already-configured";
|
|
8
|
+
export interface ClientPasswordPrompt {
|
|
9
|
+
readonly isInteractive: boolean;
|
|
10
|
+
writeLine(message: string): void;
|
|
11
|
+
prompt(message: string): Promise<string>;
|
|
12
|
+
promptHidden?(message: string): Promise<string>;
|
|
13
|
+
}
|
|
14
|
+
export interface ClientPasswordSessionStatus {
|
|
15
|
+
unlocked: boolean;
|
|
16
|
+
unlockUntilUnixMs: number | null;
|
|
17
|
+
}
|
|
18
|
+
export interface ClientPasswordLegacyKeychainReader {
|
|
19
|
+
loadSecret(keyId: string): Promise<Uint8Array>;
|
|
20
|
+
}
|
|
21
|
+
export interface ClientPasswordStorageOptions {
|
|
22
|
+
platform: NodeJS.Platform;
|
|
23
|
+
stateRoot: string;
|
|
24
|
+
runtimeRoot: string;
|
|
25
|
+
directoryPath: string;
|
|
26
|
+
runtimeErrorCode: string;
|
|
27
|
+
legacyMacKeychainReader?: ClientPasswordLegacyKeychainReader | null;
|
|
28
|
+
}
|
|
29
|
+
export interface ClientPasswordResolvedContext extends ClientPasswordStorageOptions {
|
|
30
|
+
legacyMacKeychainReader?: ClientPasswordLegacyKeychainReader | null;
|
|
31
|
+
passwordStatePath: string;
|
|
32
|
+
rotationJournalPath: string;
|
|
33
|
+
}
|
|
34
|
+
export interface ClientPasswordStateV1 {
|
|
35
|
+
format: typeof CLIENT_PASSWORD_STATE_FORMAT;
|
|
36
|
+
version: 1;
|
|
37
|
+
passwordHint: string;
|
|
38
|
+
kdf: {
|
|
39
|
+
name: "argon2id";
|
|
40
|
+
memoryKib: number;
|
|
41
|
+
iterations: number;
|
|
42
|
+
parallelism: number;
|
|
43
|
+
salt: string;
|
|
44
|
+
};
|
|
45
|
+
verifier: {
|
|
46
|
+
cipher: "aes-256-gcm";
|
|
47
|
+
nonce: string;
|
|
48
|
+
tag: string;
|
|
49
|
+
ciphertext: string;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export interface WrappedSecretEnvelopeV1 {
|
|
53
|
+
format: typeof LOCAL_SECRET_ENVELOPE_FORMAT;
|
|
54
|
+
version: 1;
|
|
55
|
+
cipher: "aes-256-gcm";
|
|
56
|
+
wrappedBy: "client-password";
|
|
57
|
+
nonce: string;
|
|
58
|
+
tag: string;
|
|
59
|
+
ciphertext: string;
|
|
60
|
+
}
|
|
61
|
+
export interface ClientPasswordRotationJournalV1 {
|
|
62
|
+
format: typeof CLIENT_PASSWORD_ROTATION_JOURNAL_FORMAT;
|
|
63
|
+
version: 1;
|
|
64
|
+
nextState: ClientPasswordStateV1;
|
|
65
|
+
secrets: Array<{
|
|
66
|
+
keyId: string;
|
|
67
|
+
envelope: WrappedSecretEnvelopeV1;
|
|
68
|
+
}>;
|
|
69
|
+
}
|
|
70
|
+
export interface ClientPasswordAgentBootstrapState {
|
|
71
|
+
unlockUntilUnixMs: number;
|
|
72
|
+
derivedKeyBase64: string;
|
|
73
|
+
}
|
|
74
|
+
export type LocalSecretFile = {
|
|
75
|
+
state: "missing";
|
|
76
|
+
} | {
|
|
77
|
+
state: "raw";
|
|
78
|
+
secret: Uint8Array;
|
|
79
|
+
} | {
|
|
80
|
+
state: "wrapped";
|
|
81
|
+
envelope: WrappedSecretEnvelopeV1;
|
|
82
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export const CLIENT_PASSWORD_STATE_FORMAT = "cogcoin-client-password";
|
|
2
|
+
export const CLIENT_PASSWORD_ROTATION_JOURNAL_FORMAT = "cogcoin-client-password-rotation";
|
|
3
|
+
export const CLIENT_PASSWORD_VERIFIER_FORMAT = "cogcoin-client-password-verifier";
|
|
4
|
+
export const LOCAL_SECRET_ENVELOPE_FORMAT = "cogcoin-local-wallet-secret";
|
|
5
|
+
export const CLIENT_PASSWORD_VERIFIER_TEXT = "cogcoin-client-password-verifier-v1";
|
|
@@ -1,27 +1,10 @@
|
|
|
1
|
-
export
|
|
2
|
-
export type ClientPasswordReadiness
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
promptHidden?(message: string): Promise<string>;
|
|
9
|
-
}
|
|
10
|
-
export interface ClientPasswordSessionStatus {
|
|
11
|
-
unlocked: boolean;
|
|
12
|
-
unlockUntilUnixMs: number | null;
|
|
13
|
-
}
|
|
14
|
-
export interface ClientPasswordStorageOptions {
|
|
15
|
-
platform: NodeJS.Platform;
|
|
16
|
-
stateRoot: string;
|
|
17
|
-
runtimeRoot: string;
|
|
18
|
-
directoryPath: string;
|
|
19
|
-
runtimeErrorCode: string;
|
|
20
|
-
legacyMacKeychainReader?: {
|
|
21
|
-
loadSecret(keyId: string): Promise<Uint8Array>;
|
|
22
|
-
} | null;
|
|
23
|
-
}
|
|
24
|
-
export declare function resolveLocalSecretFilePath(directoryPath: string, keyId: string): string;
|
|
1
|
+
export { CLIENT_PASSWORD_SETUP_AUTO_UNLOCK_SECONDS } from "./client-password/crypto.js";
|
|
2
|
+
export type { ClientPasswordPrompt, ClientPasswordReadiness, ClientPasswordSessionStatus, ClientPasswordSetupAction, ClientPasswordStorageOptions, } from "./client-password/types.js";
|
|
3
|
+
export { resolveLocalSecretFilePath, createLegacyKeychainServiceName, } from "./client-password/context.js";
|
|
4
|
+
export { createAgentBootstrapState } from "./client-password/bootstrap.js";
|
|
5
|
+
export { describeClientPasswordLockedMessage, describeClientPasswordMigrationMessage, describeClientPasswordSetupMessage, } from "./client-password/messages.js";
|
|
6
|
+
export { listLocalSecretFilesForTesting } from "./client-password/files.js";
|
|
7
|
+
import type { ClientPasswordPrompt, ClientPasswordReadiness, ClientPasswordSessionStatus, ClientPasswordSetupAction, ClientPasswordStorageOptions } from "./client-password/types.js";
|
|
25
8
|
export declare function inspectClientPasswordReadiness(options: ClientPasswordStorageOptions): Promise<ClientPasswordReadiness>;
|
|
26
9
|
export declare function readClientPasswordSessionStatus(options: ClientPasswordStorageOptions): Promise<ClientPasswordSessionStatus>;
|
|
27
10
|
export declare function lockClientPasswordSession(options: ClientPasswordStorageOptions): Promise<ClientPasswordSessionStatus>;
|
|
@@ -49,17 +32,3 @@ export declare function unlockClientPasswordSession(options: ClientPasswordStora
|
|
|
49
32
|
export declare function changeClientPassword(options: ClientPasswordStorageOptions & {
|
|
50
33
|
prompt: ClientPasswordPrompt;
|
|
51
34
|
}): Promise<ClientPasswordSessionStatus>;
|
|
52
|
-
export declare function createLegacyKeychainServiceName(): string;
|
|
53
|
-
export declare function createAgentBootstrapState(options: {
|
|
54
|
-
unlockUntilUnixMs: number;
|
|
55
|
-
derivedKeyBase64: string;
|
|
56
|
-
}): {
|
|
57
|
-
unlockUntilUnixMs: number;
|
|
58
|
-
derivedKeyBase64: string;
|
|
59
|
-
};
|
|
60
|
-
export declare function describeClientPasswordLockedMessage(): string;
|
|
61
|
-
export declare function describeClientPasswordSetupMessage(): string;
|
|
62
|
-
export declare function describeClientPasswordMigrationMessage(): string;
|
|
63
|
-
export declare function listLocalSecretFilesForTesting(options: {
|
|
64
|
-
directoryPath: string;
|
|
65
|
-
}): Promise<string[]>;
|