movehat 0.2.1 → 0.2.2
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/__tests__/deployContract.test.js +56 -47
- package/dist/__tests__/deployContract.test.js.map +1 -1
- package/dist/__tests__/exports.test.d.ts +2 -0
- package/dist/__tests__/exports.test.d.ts.map +1 -0
- package/dist/__tests__/exports.test.js +30 -0
- package/dist/__tests__/exports.test.js.map +1 -0
- package/dist/__tests__/fixtures/sigint-deploy-harness.d.ts +4 -3
- package/dist/__tests__/fixtures/sigint-deploy-harness.d.ts.map +1 -1
- package/dist/__tests__/fixtures/sigint-deploy-harness.js +8 -7
- package/dist/__tests__/fixtures/sigint-deploy-harness.js.map +1 -1
- package/dist/__tests__/fork/api.test.js +5 -0
- package/dist/__tests__/fork/api.test.js.map +1 -1
- package/dist/__tests__/fork/api.timeout.test.d.ts +2 -0
- package/dist/__tests__/fork/api.timeout.test.d.ts.map +1 -0
- package/dist/__tests__/fork/api.timeout.test.js +98 -0
- package/dist/__tests__/fork/api.timeout.test.js.map +1 -0
- package/dist/commands/__tests__/compile.toml-mutation.test.d.ts +2 -0
- package/dist/commands/__tests__/compile.toml-mutation.test.d.ts.map +1 -0
- package/dist/commands/__tests__/compile.toml-mutation.test.js +69 -0
- package/dist/commands/__tests__/compile.toml-mutation.test.js.map +1 -0
- package/dist/commands/__tests__/init.test.js +73 -11
- package/dist/commands/__tests__/init.test.js.map +1 -1
- package/dist/commands/init.d.ts +22 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +55 -6
- package/dist/commands/init.js.map +1 -1
- package/dist/core/AccountManager.d.ts.map +1 -1
- package/dist/core/AccountManager.js +14 -2
- package/dist/core/AccountManager.js.map +1 -1
- package/dist/core/Publisher.d.ts.map +1 -1
- package/dist/core/Publisher.js +52 -68
- package/dist/core/Publisher.js.map +1 -1
- package/dist/core/__tests__/AccountManager.global-state.test.d.ts +2 -0
- package/dist/core/__tests__/AccountManager.global-state.test.d.ts.map +1 -0
- package/dist/core/__tests__/AccountManager.global-state.test.js +69 -0
- package/dist/core/__tests__/AccountManager.global-state.test.js.map +1 -0
- package/dist/core/__tests__/movementProfile.test.d.ts +2 -0
- package/dist/core/__tests__/movementProfile.test.d.ts.map +1 -0
- package/dist/core/__tests__/movementProfile.test.js +112 -0
- package/dist/core/__tests__/movementProfile.test.js.map +1 -0
- package/dist/core/config.js +6 -5
- package/dist/core/config.js.map +1 -1
- package/dist/core/movementProfile.d.ts +55 -22
- package/dist/core/movementProfile.d.ts.map +1 -1
- package/dist/core/movementProfile.js +77 -99
- package/dist/core/movementProfile.js.map +1 -1
- package/dist/fork/__tests__/server.cors.test.d.ts +2 -0
- package/dist/fork/__tests__/server.cors.test.d.ts.map +1 -0
- package/dist/fork/__tests__/server.cors.test.js +79 -0
- package/dist/fork/__tests__/server.cors.test.js.map +1 -0
- package/dist/fork/api.d.ts +9 -1
- package/dist/fork/api.d.ts.map +1 -1
- package/dist/fork/api.js +37 -7
- package/dist/fork/api.js.map +1 -1
- package/dist/fork/server.d.ts +20 -1
- package/dist/fork/server.d.ts.map +1 -1
- package/dist/fork/server.js +19 -9
- package/dist/fork/server.js.map +1 -1
- package/dist/harness/Harness.d.ts +6 -2
- package/dist/harness/Harness.d.ts.map +1 -1
- package/dist/harness/Harness.js +8 -2
- package/dist/harness/Harness.js.map +1 -1
- package/dist/harness/codeObject.d.ts.map +1 -1
- package/dist/harness/codeObject.js +30 -33
- package/dist/harness/codeObject.js.map +1 -1
- package/dist/harness/script.d.ts +3 -3
- package/dist/harness/script.d.ts.map +1 -1
- package/dist/harness/script.js +33 -29
- package/dist/harness/script.js.map +1 -1
- package/dist/helpers/__tests__/setupLocalTesting.fork-network.test.d.ts +2 -0
- package/dist/helpers/__tests__/setupLocalTesting.fork-network.test.d.ts.map +1 -0
- package/dist/helpers/__tests__/setupLocalTesting.fork-network.test.js +172 -0
- package/dist/helpers/__tests__/setupLocalTesting.fork-network.test.js.map +1 -0
- package/dist/helpers/setupLocalTesting.d.ts.map +1 -1
- package/dist/helpers/setupLocalTesting.js +28 -2
- package/dist/helpers/setupLocalTesting.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/node/LocalNodeManager.d.ts +8 -0
- package/dist/node/LocalNodeManager.d.ts.map +1 -1
- package/dist/node/LocalNodeManager.js +10 -1
- package/dist/node/LocalNodeManager.js.map +1 -1
- package/dist/node/__tests__/LocalNodeManager.api-port.test.d.ts +2 -0
- package/dist/node/__tests__/LocalNodeManager.api-port.test.d.ts.map +1 -0
- package/dist/node/__tests__/LocalNodeManager.api-port.test.js +55 -0
- package/dist/node/__tests__/LocalNodeManager.api-port.test.js.map +1 -0
- package/dist/node/__tests__/LocalNodeManager.test.js +4 -3
- package/dist/node/__tests__/LocalNodeManager.test.js.map +1 -1
- package/dist/templates/move/Move.toml +1 -1
- package/dist/templates/move/sources/Counter.move +31 -4
- package/dist/templates/scripts/deploy-counter.ts +10 -0
- package/dist/types/config.d.ts +8 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/__tests__/childProcessAdapter.maxBuffer.test.d.ts +2 -0
- package/dist/utils/__tests__/childProcessAdapter.maxBuffer.test.d.ts.map +1 -0
- package/dist/utils/__tests__/childProcessAdapter.maxBuffer.test.js +43 -0
- package/dist/utils/__tests__/childProcessAdapter.maxBuffer.test.js.map +1 -0
- package/dist/utils/childProcessAdapter.d.ts +7 -0
- package/dist/utils/childProcessAdapter.d.ts.map +1 -1
- package/dist/utils/childProcessAdapter.js +20 -2
- package/dist/utils/childProcessAdapter.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/deployContract.test.ts +59 -50
- package/src/__tests__/exports.test.ts +32 -0
- package/src/__tests__/fixtures/sigint-deploy-harness.ts +8 -7
- package/src/__tests__/fork/api.test.ts +5 -0
- package/src/__tests__/fork/api.timeout.test.ts +150 -0
- package/src/commands/__tests__/compile.toml-mutation.test.ts +77 -0
- package/src/commands/__tests__/init.test.ts +96 -11
- package/src/commands/init.ts +77 -6
- package/src/core/AccountManager.ts +18 -1
- package/src/core/Publisher.ts +58 -77
- package/src/core/__tests__/AccountManager.global-state.test.ts +83 -0
- package/src/core/__tests__/movementProfile.test.ts +131 -0
- package/src/core/config.ts +9 -5
- package/src/core/movementProfile.ts +75 -127
- package/src/fork/__tests__/server.cors.test.ts +101 -0
- package/src/fork/api.ts +69 -10
- package/src/fork/server.ts +38 -9
- package/src/harness/Harness.ts +11 -2
- package/src/harness/codeObject.ts +37 -43
- package/src/harness/script.ts +40 -39
- package/src/helpers/__tests__/setupLocalTesting.fork-network.test.ts +212 -0
- package/src/helpers/setupLocalTesting.ts +36 -2
- package/src/index.ts +9 -1
- package/src/node/LocalNodeManager.ts +24 -2
- package/src/node/__tests__/LocalNodeManager.api-port.test.ts +62 -0
- package/src/node/__tests__/LocalNodeManager.test.ts +4 -3
- package/src/templates/move/Move.toml +1 -1
- package/src/templates/move/sources/Counter.move +31 -4
- package/src/templates/scripts/deploy-counter.ts +10 -0
- package/src/types/config.ts +8 -1
- package/src/utils/__tests__/childProcessAdapter.maxBuffer.test.ts +51 -0
- package/src/utils/childProcessAdapter.ts +32 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Publisher.js","sourceRoot":"","sources":["../../src/core/Publisher.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Publisher.js","sourceRoot":"","sources":["../../src/core/Publisher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,UAAU,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EACL,cAAc,EACd,cAAc,EAEd,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,0BA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AC;gBACtE,MAAM,CAAC,KAAK,CAAC,6BAA6B,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;YAC3D,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountManager.global-state.test.d.ts","sourceRoot":"","sources":["../../../src/core/__tests__/AccountManager.global-state.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
2
|
+
import { existsSync, mkdtempSync, rmSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { AccountManager } from "../AccountManager.js";
|
|
6
|
+
/**
|
|
7
|
+
* F8 — Document the two known limitations of `AccountManager`:
|
|
8
|
+
*
|
|
9
|
+
* (a) State is class-static. Two harness "sessions" in the same
|
|
10
|
+
* process share the pool, the labelMap, and the private-key
|
|
11
|
+
* map. A label re-used across sessions overwrites the entry.
|
|
12
|
+
* This is intentional per `Harness.ts:39-42` ("Two Harness
|
|
13
|
+
* instances in the same process share account labels"). This
|
|
14
|
+
* test captures the contract so a future refactor cannot
|
|
15
|
+
* silently change it.
|
|
16
|
+
*
|
|
17
|
+
* (b) `defaultPoolPath = join(process.cwd(), ".movehat", "accounts")`
|
|
18
|
+
* is evaluated when the module is first imported, NOT lazily on
|
|
19
|
+
* each call. Changing `process.cwd()` after import does not move
|
|
20
|
+
* the save destination. Callers needing per-test isolation must
|
|
21
|
+
* pass an explicit `poolPath` argument.
|
|
22
|
+
*/
|
|
23
|
+
describe("F8 — AccountManager static state and import-time cwd capture", () => {
|
|
24
|
+
let cwdBackup;
|
|
25
|
+
let tmpDir;
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
AccountManager.clearPool();
|
|
28
|
+
cwdBackup = process.cwd();
|
|
29
|
+
tmpDir = mkdtempSync(join(tmpdir(), "movehat-f8-"));
|
|
30
|
+
});
|
|
31
|
+
afterEach(() => {
|
|
32
|
+
AccountManager.clearPool();
|
|
33
|
+
if (process.cwd() !== cwdBackup) {
|
|
34
|
+
process.chdir(cwdBackup);
|
|
35
|
+
}
|
|
36
|
+
rmSync(tmpDir, { recursive: true, force: true });
|
|
37
|
+
});
|
|
38
|
+
it("(a) re-creating an account with an existing label overwrites the labelMap entry", () => {
|
|
39
|
+
const first = AccountManager.createAccount("alice");
|
|
40
|
+
const second = AccountManager.createAccount("alice");
|
|
41
|
+
expect(second.accountAddress.toString()).not.toBe(first.accountAddress.toString());
|
|
42
|
+
const lookup = AccountManager.getAccountByLabel("alice");
|
|
43
|
+
expect(lookup).toBeDefined();
|
|
44
|
+
expect(lookup.accountAddress.toString()).toBe(second.accountAddress.toString());
|
|
45
|
+
// The first account is still in the pool (keyed by address), only
|
|
46
|
+
// the label binding moved. A second harness session that creates
|
|
47
|
+
// its own "alice" will silently shadow the first — this is the
|
|
48
|
+
// documented Harness limitation. exportPrivateKeys reflects the
|
|
49
|
+
// current label binding (i.e. the second account).
|
|
50
|
+
const exportedKeys = AccountManager.exportPrivateKeys(["alice"]);
|
|
51
|
+
expect(exportedKeys.alice).toBeTypeOf("string");
|
|
52
|
+
expect(exportedKeys.alice.length).toBeGreaterThan(0);
|
|
53
|
+
});
|
|
54
|
+
it("(b) saveAccountPool ignores a process.chdir after import; defaults to the import-time cwd", () => {
|
|
55
|
+
AccountManager.createAccount("bob");
|
|
56
|
+
process.chdir(tmpDir);
|
|
57
|
+
// No path argument → uses defaultPoolPath, which was set at module
|
|
58
|
+
// load time before this chdir.
|
|
59
|
+
AccountManager.saveAccountPool();
|
|
60
|
+
// The pool file must NOT appear under the freshly-chdir'd cwd.
|
|
61
|
+
const expectedAtNewCwd = join(tmpDir, ".movehat", "accounts", "test-pool.json");
|
|
62
|
+
expect(existsSync(expectedAtNewCwd)).toBe(false);
|
|
63
|
+
// Sanity check: explicit poolPath does land where the caller asked.
|
|
64
|
+
const explicit = join(tmpDir, "explicit");
|
|
65
|
+
AccountManager.saveAccountPool(explicit);
|
|
66
|
+
expect(existsSync(join(explicit, "test-pool.json"))).toBe(true);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=AccountManager.global-state.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountManager.global-state.test.js","sourceRoot":"","sources":["../../../src/core/__tests__/AccountManager.global-state.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;;;;;;;;;;;;;;GAgBG;AAEH,QAAQ,CAAC,8DAA8D,EAAE,GAAG,EAAE;IAC5E,IAAI,SAAiB,CAAC;IACtB,IAAI,MAAc,CAAC;IAEnB,UAAU,CAAC,GAAG,EAAE;QACd,cAAc,CAAC,SAAS,EAAE,CAAC;QAC3B,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAC1B,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,cAAc,CAAC,SAAS,EAAE,CAAC;QAC3B,IAAI,OAAO,CAAC,GAAG,EAAE,KAAK,SAAS,EAAE,CAAC;YAChC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAC3B,CAAC;QACD,MAAM,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAA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,GAAG,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC;QAChF,MAAM,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEjD,oEAAoE;QACpE,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAC1C,cAAc,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QACzC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"movementProfile.test.d.ts","sourceRoot":"","sources":["../../../src/core/__tests__/movementProfile.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
2
|
+
import { chmodSync, existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync, } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { removeKeyFile, removeKeyFileSyncBestEffort, writeTempKeyFile, } from "../movementProfile.js";
|
|
6
|
+
/**
|
|
7
|
+
* Unit tests for the two distinct cleanup helpers in movementProfile:
|
|
8
|
+
*
|
|
9
|
+
* - `removeKeyFileSyncBestEffort`: for SIGINT/SIGTERM handlers where
|
|
10
|
+
* the event loop is dead. Never throws, never logs, always returns
|
|
11
|
+
* void. We only test that it doesn't throw.
|
|
12
|
+
*
|
|
13
|
+
* - `removeKeyFile`: for normal `finally` cleanup paths. Returns
|
|
14
|
+
* `null` when the file is gone (removed OR already absent — both
|
|
15
|
+
* are benign), and returns an `Error` only when the file STILL
|
|
16
|
+
* exists on disk after the unlink attempt failed. The Error path
|
|
17
|
+
* is exactly the case the caller must surface as a warning,
|
|
18
|
+
* because a private-key temp file would otherwise persist
|
|
19
|
+
* silently.
|
|
20
|
+
*/
|
|
21
|
+
describe("movementProfile cleanup helpers", () => {
|
|
22
|
+
let scratchDir;
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
scratchDir = mkdtempSync(join(tmpdir(), "movehat-profile-test-"));
|
|
25
|
+
});
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
if (existsSync(scratchDir)) {
|
|
28
|
+
// Force chmod in case a test left it un-removable, then rmSync.
|
|
29
|
+
try {
|
|
30
|
+
chmodSync(scratchDir, 0o700);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
/* best-effort */
|
|
34
|
+
}
|
|
35
|
+
rmSync(scratchDir, { recursive: true, force: true });
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
describe("writeTempKeyFile", () => {
|
|
39
|
+
it("creates a 0o600 file in os.tmpdir() with the key as contents", () => {
|
|
40
|
+
const path = writeTempKeyFile("ed25519-priv-0x" + "a".repeat(64));
|
|
41
|
+
try {
|
|
42
|
+
expect(path.startsWith(tmpdir())).toBe(true);
|
|
43
|
+
expect(path).toMatch(/movehat-key-/);
|
|
44
|
+
expect(existsSync(path)).toBe(true);
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
if (existsSync(path))
|
|
48
|
+
rmSync(path);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
describe("removeKeyFileSyncBestEffort", () => {
|
|
53
|
+
it("removes an existing file", () => {
|
|
54
|
+
const path = join(scratchDir, "key");
|
|
55
|
+
writeFileSync(path, "x", { mode: 0o600 });
|
|
56
|
+
removeKeyFileSyncBestEffort(path);
|
|
57
|
+
expect(existsSync(path)).toBe(false);
|
|
58
|
+
});
|
|
59
|
+
it("does not throw when the file is already gone", () => {
|
|
60
|
+
const path = join(scratchDir, "never-existed");
|
|
61
|
+
expect(() => removeKeyFileSyncBestEffort(path)).not.toThrow();
|
|
62
|
+
});
|
|
63
|
+
it("does not throw when the path is a non-empty directory (would fail in stricter callers)", () => {
|
|
64
|
+
const dirPath = join(scratchDir, "i-am-a-directory");
|
|
65
|
+
mkdirSync(dirPath);
|
|
66
|
+
writeFileSync(join(dirPath, "child"), "x");
|
|
67
|
+
expect(() => removeKeyFileSyncBestEffort(dirPath)).not.toThrow();
|
|
68
|
+
// The dir still exists — best-effort doesn't fight EISDIR.
|
|
69
|
+
expect(existsSync(dirPath)).toBe(true);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
describe("removeKeyFile", () => {
|
|
73
|
+
it("returns null when the file is removed cleanly", () => {
|
|
74
|
+
const path = join(scratchDir, "key-to-remove");
|
|
75
|
+
writeFileSync(path, "x", { mode: 0o600 });
|
|
76
|
+
const err = removeKeyFile(path);
|
|
77
|
+
expect(err).toBeNull();
|
|
78
|
+
expect(existsSync(path)).toBe(false);
|
|
79
|
+
});
|
|
80
|
+
it("returns null when the file was already gone (ENOENT is benign)", () => {
|
|
81
|
+
const path = join(scratchDir, "never-existed");
|
|
82
|
+
const err = removeKeyFile(path);
|
|
83
|
+
expect(err).toBeNull();
|
|
84
|
+
});
|
|
85
|
+
it("returns null when the file disappears between the unlink attempt and the existsSync check (race)", () => {
|
|
86
|
+
// Hard to provoke a real race deterministically. The contract is
|
|
87
|
+
// documented; the previous test covers the ENOENT short-circuit
|
|
88
|
+
// which is the common race outcome.
|
|
89
|
+
const path = join(scratchDir, "raced");
|
|
90
|
+
const err = removeKeyFile(path);
|
|
91
|
+
expect(err).toBeNull();
|
|
92
|
+
});
|
|
93
|
+
it("returns an Error when the path is a directory AND still exists post-attempt", () => {
|
|
94
|
+
// unlinkSync on a directory throws EISDIR (or EPERM on some
|
|
95
|
+
// platforms). existsSync afterwards still returns true, so this
|
|
96
|
+
// is the "preocupante" path the caller must surface as a warning
|
|
97
|
+
// — the file (here, a directory occupying the key-file path) is
|
|
98
|
+
// still on disk.
|
|
99
|
+
const dirPath = join(scratchDir, "key-but-actually-a-dir");
|
|
100
|
+
mkdirSync(dirPath);
|
|
101
|
+
writeFileSync(join(dirPath, "child"), "x"); // make sure it's not empty
|
|
102
|
+
const err = removeKeyFile(dirPath);
|
|
103
|
+
expect(err).not.toBeNull();
|
|
104
|
+
expect(err).toBeInstanceOf(Error);
|
|
105
|
+
// Error code is platform-dependent (EISDIR on linux, EPERM on
|
|
106
|
+
// macos), so just assert we got something Error-shaped.
|
|
107
|
+
expect(err.code).toMatch(/^E/);
|
|
108
|
+
expect(existsSync(dirPath)).toBe(true);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
//# sourceMappingURL=movementProfile.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"movementProfile.test.js","sourceRoot":"","sources":["../../../src/core/__tests__/movementProfile.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,WAAW,EACX,MAAM,EACN,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,aAAa,EACb,2BAA2B,EAC3B,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;;;;;;GAcG;AAEH,QAAQ,CAAC,iCAAiC,EAAE,GAAG,EAAE;IAC/C,IAAI,UAAkB,CAAC;IAEvB,UAAU,CAAC,GAAG,EAAE;QACd,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,uBAAuB,CAAC,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,UAA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C,IAAI,CAAC,IAAI,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/core/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { pathToFileURL } from "url";
|
|
2
2
|
import { join } from "path";
|
|
3
3
|
import { existsSync, statSync } from "fs";
|
|
4
|
-
import { Account, Ed25519PrivateKey } from "@aptos-labs/ts-sdk";
|
|
4
|
+
import { Account, Ed25519PrivateKey, PrivateKey, PrivateKeyVariants } from "@aptos-labs/ts-sdk";
|
|
5
5
|
// Keyed by resolved absolute path. One entry per config file the process
|
|
6
6
|
// has loaded. Closes #62 — the previous `?t=Date.now()` cache-bust
|
|
7
7
|
// created a fresh Node loader module per call.
|
|
@@ -213,11 +213,12 @@ function deriveAccountAddress(privateKeyHex) {
|
|
|
213
213
|
if (!privateKeyHex)
|
|
214
214
|
return "";
|
|
215
215
|
try {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
216
|
+
// Format into AIP-80 shape so the SDK doesn't emit a deprecation
|
|
217
|
+
// warning on each derivation. `formatPrivateKey` is idempotent for
|
|
218
|
+
// already-prefixed inputs.
|
|
219
|
+
const formatted = PrivateKey.formatPrivateKey(privateKeyHex, PrivateKeyVariants.Ed25519);
|
|
219
220
|
const account = Account.fromPrivateKey({
|
|
220
|
-
privateKey: new Ed25519PrivateKey(
|
|
221
|
+
privateKey: new Ed25519PrivateKey(formatted),
|
|
221
222
|
});
|
|
222
223
|
return account.accountAddress.toString();
|
|
223
224
|
}
|
package/dist/core/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,QAAQ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,IAAI,CAAC;QACH,iEAAiE;QACjE,mEAAmE;QACnE,2BAA2B;QAC3B,MAAM,SAAS,GAAG,UAAU,CAAC,gBAAgB,CAC3C,aAAa,EACb,kBAAkB,CAAC,OAAO,CAC3B,CAAC;QACF,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC;YACrC,UAAU,EAAE,IAAI,iBAAiB,CAAC,SAAS,CAAC;SAC7C,CAAC,CAAC;QACH,OAAO,OAAO,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;IAC3C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,wEAAwE;QACxE,sEAAsE;QACtE,2DAA2D;QAC3D,OAAO,CAAC,IAAI,CACV,6EACG,GAAa,CAAC,OACjB,2HAA2H,CAC5H,CAAC;QACF,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -1,31 +1,64 @@
|
|
|
1
|
-
export declare function withYamlLock<T>(fn: () => Promise<T>): Promise<T>;
|
|
2
|
-
export interface ProfileData {
|
|
3
|
-
private_key: string;
|
|
4
|
-
public_key: string;
|
|
5
|
-
account: string;
|
|
6
|
-
rest_url: string;
|
|
7
|
-
}
|
|
8
|
-
/** Add the deploy's profile to ~/.aptos/config.yaml. Creates the file if absent. */
|
|
9
|
-
export declare function addProfile(configPath: string, name: string, data: ProfileData): Promise<void>;
|
|
10
1
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
2
|
+
* Per-deploy private-key file management and SIGINT/SIGTERM cleanup
|
|
3
|
+
* infrastructure shared across the Movement CLI invocations (`move
|
|
4
|
+
* publish`, `move deploy-object`, `move upgrade-object`, `move
|
|
5
|
+
* run-script`).
|
|
6
|
+
*
|
|
7
|
+
* **Why a temp key file rather than the CLI's profile yaml?** The
|
|
8
|
+
* Movement CLI's `--profile <name>` flag requires a config.yaml to
|
|
9
|
+
* exist in the working directory (older Movement CLI variants look
|
|
10
|
+
* for `<cwd>/.aptos/config.yaml`; newer variants look for
|
|
11
|
+
* `<cwd>/.movement/config.yaml`). On fresh user installs neither
|
|
12
|
+
* directory exists, and the CLI errors out before it would otherwise
|
|
13
|
+
* fall back to `~/.aptos/config.yaml`. Writing to a temp file and
|
|
14
|
+
* passing `--private-key-file <path> --sender-account <addr>`
|
|
15
|
+
* directly avoids the entire profile-yaml lookup chain — no CWD
|
|
16
|
+
* dependency, no CLI-variant dependency.
|
|
17
|
+
*
|
|
18
|
+
* The same SIGINT-safe cleanup pattern applies as the old profile
|
|
19
|
+
* flow: the temp key file persists private key material on disk and
|
|
20
|
+
* MUST be removed before process exit even on abnormal termination.
|
|
21
|
+
*
|
|
22
|
+
* @internal — not exported from `src/index.ts`.
|
|
15
23
|
*/
|
|
16
|
-
export declare function removeProfile(configPath: string, name: string): Promise<void>;
|
|
17
24
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
25
|
+
* Write the private key to a `mode 0o600` file in the system temp
|
|
26
|
+
* directory and return the path. The filename is UUID-suffixed so
|
|
27
|
+
* concurrent deploys don't collide.
|
|
28
|
+
*
|
|
29
|
+
* The key string is written verbatim — callers should format to
|
|
30
|
+
* AIP-80 before calling (see `PrivateKey.formatPrivateKey` from
|
|
31
|
+
* `@aptos-labs/ts-sdk`).
|
|
23
32
|
*/
|
|
24
|
-
export declare function
|
|
33
|
+
export declare function writeTempKeyFile(privateKey: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Sync unlink for SIGINT/SIGTERM handlers — never throws, never logs.
|
|
36
|
+
* The event loop is dead by the time this runs; observability isn't
|
|
37
|
+
* possible. Worst case: a stale 0o600 temp file in `os.tmpdir()`
|
|
38
|
+
* that the OS reaps eventually.
|
|
39
|
+
*
|
|
40
|
+
* **Do not use this from a normal `finally` cleanup path** — failures
|
|
41
|
+
* become invisible there, hiding the case where a private-key temp
|
|
42
|
+
* file persists on disk after a deploy. Use {@link removeKeyFile}
|
|
43
|
+
* instead for those paths.
|
|
44
|
+
*/
|
|
45
|
+
export declare function removeKeyFileSyncBestEffort(path: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* Sync unlink for the normal cleanup path (a `finally` block after the
|
|
48
|
+
* Movement CLI invocation returns). Returns `null` on success — either
|
|
49
|
+
* the file was removed, or it was already gone (ENOENT is treated as
|
|
50
|
+
* benign success). Returns an `Error` only when the file **still
|
|
51
|
+
* exists on disk** after the unlink attempt failed (EPERM, EACCES,
|
|
52
|
+
* EBUSY, EISDIR if the path collided with a directory, etc.).
|
|
53
|
+
*
|
|
54
|
+
* Callers SHOULD `logger.warning` when a non-null Error is returned —
|
|
55
|
+
* a private-key temp file would otherwise persist silently.
|
|
56
|
+
*/
|
|
57
|
+
export declare function removeKeyFile(path: string): Error | null;
|
|
25
58
|
/**
|
|
26
59
|
* Process-level signal handling. A single registered handler iterates
|
|
27
|
-
* the per-deploy cleanup callbacks.
|
|
28
|
-
* concurrent deploys share the same parent
|
|
60
|
+
* the per-deploy cleanup callbacks. Installed once per process because
|
|
61
|
+
* multiple concurrent deploys share the same parent — installing per
|
|
29
62
|
* deploy would re-add the listener and exceed Node's max-listeners
|
|
30
63
|
* warning threshold under heavy parallelism.
|
|
31
64
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"movementProfile.d.ts","sourceRoot":"","sources":["../../src/core/movementProfile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"movementProfile.d.ts","sourceRoot":"","sources":["../../src/core/movementProfile.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAS3D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAM9D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAcxD;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,YAAiB,IAAI,CAAG,CAAC;AAGtD,wBAAgB,mBAAmB,IAAI,IAAI,CAqB1C"}
|
|
@@ -1,123 +1,101 @@
|
|
|
1
|
-
import { chmodSync, existsSync,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { chmodSync, existsSync, unlinkSync, writeFileSync } from "fs";
|
|
2
|
+
import { tmpdir } from "os";
|
|
3
|
+
import { join } from "path";
|
|
4
4
|
import { randomUUID } from "crypto";
|
|
5
|
-
import * as yaml from "js-yaml";
|
|
6
5
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Per-deploy private-key file management and SIGINT/SIGTERM cleanup
|
|
7
|
+
* infrastructure shared across the Movement CLI invocations (`move
|
|
8
|
+
* publish`, `move deploy-object`, `move upgrade-object`, `move
|
|
9
|
+
* run-script`).
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* **Why a temp key file rather than the CLI's profile yaml?** The
|
|
12
|
+
* Movement CLI's `--profile <name>` flag requires a config.yaml to
|
|
13
|
+
* exist in the working directory (older Movement CLI variants look
|
|
14
|
+
* for `<cwd>/.aptos/config.yaml`; newer variants look for
|
|
15
|
+
* `<cwd>/.movement/config.yaml`). On fresh user installs neither
|
|
16
|
+
* directory exists, and the CLI errors out before it would otherwise
|
|
17
|
+
* fall back to `~/.aptos/config.yaml`. Writing to a temp file and
|
|
18
|
+
* passing `--private-key-file <path> --sender-account <addr>`
|
|
19
|
+
* directly avoids the entire profile-yaml lookup chain — no CWD
|
|
20
|
+
* dependency, no CLI-variant dependency.
|
|
21
|
+
*
|
|
22
|
+
* The same SIGINT-safe cleanup pattern applies as the old profile
|
|
23
|
+
* flow: the temp key file persists private key material on disk and
|
|
24
|
+
* MUST be removed before process exit even on abnormal termination.
|
|
14
25
|
*
|
|
15
26
|
* @internal — not exported from `src/index.ts`.
|
|
16
27
|
*/
|
|
17
28
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
29
|
+
* Write the private key to a `mode 0o600` file in the system temp
|
|
30
|
+
* directory and return the path. The filename is UUID-suffixed so
|
|
31
|
+
* concurrent deploys don't collide.
|
|
32
|
+
*
|
|
33
|
+
* The key string is written verbatim — callers should format to
|
|
34
|
+
* AIP-80 before calling (see `PrivateKey.formatPrivateKey` from
|
|
35
|
+
* `@aptos-labs/ts-sdk`).
|
|
21
36
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
37
|
+
export function writeTempKeyFile(privateKey) {
|
|
38
|
+
const path = join(tmpdir(), `movehat-key-${randomUUID()}`);
|
|
39
|
+
// mode in the open() call may be filtered by the process umask
|
|
40
|
+
// (typically 0o022 → resulting perms 0o644). chmod after write
|
|
41
|
+
// is defense in depth so the file can never be observable as
|
|
42
|
+
// group-/world-readable while it carries the private key.
|
|
43
|
+
writeFileSync(path, privateKey, { mode: 0o600 });
|
|
44
|
+
chmodSync(path, 0o600);
|
|
45
|
+
return path;
|
|
30
46
|
}
|
|
31
47
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
48
|
+
* Sync unlink for SIGINT/SIGTERM handlers — never throws, never logs.
|
|
49
|
+
* The event loop is dead by the time this runs; observability isn't
|
|
50
|
+
* possible. Worst case: a stale 0o600 temp file in `os.tmpdir()`
|
|
51
|
+
* that the OS reaps eventually.
|
|
52
|
+
*
|
|
53
|
+
* **Do not use this from a normal `finally` cleanup path** — failures
|
|
54
|
+
* become invisible there, hiding the case where a private-key temp
|
|
55
|
+
* file persists on disk after a deploy. Use {@link removeKeyFile}
|
|
56
|
+
* instead for those paths.
|
|
36
57
|
*/
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
chmodSync(tmpPath, 0o600); // defense in depth in case umask filtered the open mode
|
|
41
|
-
renameSync(tmpPath, path);
|
|
42
|
-
}
|
|
43
|
-
/** Add the deploy's profile to ~/.aptos/config.yaml. Creates the file if absent. */
|
|
44
|
-
export async function addProfile(configPath, name, data) {
|
|
45
|
-
const configDir = dirname(configPath);
|
|
46
|
-
if (!existsSync(configDir)) {
|
|
47
|
-
mkdirSync(configDir, { recursive: true, mode: 0o700 });
|
|
48
|
-
}
|
|
49
|
-
let yamlObj = {};
|
|
50
|
-
if (existsSync(configPath)) {
|
|
51
|
-
const raw = await readFile(configPath, "utf-8");
|
|
52
|
-
yamlObj = yaml.load(raw) || {};
|
|
58
|
+
export function removeKeyFileSyncBestEffort(path) {
|
|
59
|
+
try {
|
|
60
|
+
unlinkSync(path);
|
|
53
61
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
yamlObj.profiles[name] = data;
|
|
57
|
-
atomicWriteYaml(configPath, yaml.dump(yamlObj));
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Remove the deploy's profile from ~/.aptos/config.yaml. Idempotent —
|
|
61
|
-
* a missing file or missing profile is a no-op. If removal leaves the
|
|
62
|
-
* yaml with only an empty `profiles:` block, the whole file is unlinked
|
|
63
|
-
* to preserve the "didn't exist before" semantic for the first-ever deploy.
|
|
64
|
-
*/
|
|
65
|
-
export async function removeProfile(configPath, name) {
|
|
66
|
-
if (!existsSync(configPath))
|
|
67
|
-
return;
|
|
68
|
-
const raw = await readFile(configPath, "utf-8");
|
|
69
|
-
const yamlObj = yaml.load(raw) || {};
|
|
70
|
-
if (!yamlObj.profiles || !(name in yamlObj.profiles))
|
|
71
|
-
return;
|
|
72
|
-
delete yamlObj.profiles[name];
|
|
73
|
-
const profilesEmpty = Object.keys(yamlObj.profiles).length === 0;
|
|
74
|
-
const onlyProfilesKey = Object.keys(yamlObj).length === 1 && "profiles" in yamlObj;
|
|
75
|
-
if (profilesEmpty && onlyProfilesKey) {
|
|
76
|
-
// We created this file fresh; remove it.
|
|
77
|
-
try {
|
|
78
|
-
unlinkSync(configPath);
|
|
79
|
-
}
|
|
80
|
-
catch {
|
|
81
|
-
// best-effort
|
|
82
|
-
}
|
|
83
|
-
return;
|
|
62
|
+
catch {
|
|
63
|
+
// event loop dead — best-effort
|
|
84
64
|
}
|
|
85
|
-
atomicWriteYaml(configPath, yaml.dump(yamlObj));
|
|
86
65
|
}
|
|
87
66
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
67
|
+
* Sync unlink for the normal cleanup path (a `finally` block after the
|
|
68
|
+
* Movement CLI invocation returns). Returns `null` on success — either
|
|
69
|
+
* the file was removed, or it was already gone (ENOENT is treated as
|
|
70
|
+
* benign success). Returns an `Error` only when the file **still
|
|
71
|
+
* exists on disk** after the unlink attempt failed (EPERM, EACCES,
|
|
72
|
+
* EBUSY, EISDIR if the path collided with a directory, etc.).
|
|
73
|
+
*
|
|
74
|
+
* Callers SHOULD `logger.warning` when a non-null Error is returned —
|
|
75
|
+
* a private-key temp file would otherwise persist silently.
|
|
93
76
|
*/
|
|
94
|
-
export function
|
|
77
|
+
export function removeKeyFile(path) {
|
|
95
78
|
try {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const raw = readFileSync(configPath, "utf-8");
|
|
99
|
-
const yamlObj = yaml.load(raw) || {};
|
|
100
|
-
if (!yamlObj.profiles || !(name in yamlObj.profiles))
|
|
101
|
-
return;
|
|
102
|
-
delete yamlObj.profiles[name];
|
|
103
|
-
const profilesEmpty = Object.keys(yamlObj.profiles).length === 0;
|
|
104
|
-
const onlyProfilesKey = Object.keys(yamlObj).length === 1 && "profiles" in yamlObj;
|
|
105
|
-
if (profilesEmpty && onlyProfilesKey) {
|
|
106
|
-
unlinkSync(configPath);
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
atomicWriteYaml(configPath, yaml.dump(yamlObj));
|
|
79
|
+
unlinkSync(path);
|
|
80
|
+
return null;
|
|
110
81
|
}
|
|
111
|
-
catch {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
82
|
+
catch (err) {
|
|
83
|
+
const code = err.code;
|
|
84
|
+
if (code === "ENOENT")
|
|
85
|
+
return null;
|
|
86
|
+
// The unlink call failed but verify the file actually still exists
|
|
87
|
+
// before declaring this preocupante — some races (parallel cleanup,
|
|
88
|
+
// tmpdir reaper) can race with us and the file may already be gone
|
|
89
|
+
// despite the syscall reporting an unexpected error.
|
|
90
|
+
if (!existsSync(path))
|
|
91
|
+
return null;
|
|
92
|
+
return err instanceof Error ? err : new Error(String(err));
|
|
115
93
|
}
|
|
116
94
|
}
|
|
117
95
|
/**
|
|
118
96
|
* Process-level signal handling. A single registered handler iterates
|
|
119
|
-
* the per-deploy cleanup callbacks.
|
|
120
|
-
* concurrent deploys share the same parent
|
|
97
|
+
* the per-deploy cleanup callbacks. Installed once per process because
|
|
98
|
+
* multiple concurrent deploys share the same parent — installing per
|
|
121
99
|
* deploy would re-add the listener and exceed Node's max-listeners
|
|
122
100
|
* warning threshold under heavy parallelism.
|
|
123
101
|
*/
|
|
@@ -128,7 +106,7 @@ export function ensureSignalHandler() {
|
|
|
128
106
|
return;
|
|
129
107
|
signalHandlerInstalled = true;
|
|
130
108
|
const handler = (sig) => {
|
|
131
|
-
// Synchronous cleanup of every active deploy's
|
|
109
|
+
// Synchronous cleanup of every active deploy's resources.
|
|
132
110
|
for (const cb of [...cleanupCallbacks]) {
|
|
133
111
|
try {
|
|
134
112
|
cb();
|