@loro-dev/loro-repo-engine 0.2.0-next.0 → 0.2.0-next.1

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 CHANGED
@@ -347,6 +347,37 @@ Executes the embedded `loro-repo` CLI synchronously in the current process (`arg
347
347
  - `1`: runtime or I/O error (including `ENGINE_BUSY` if another daemon already locks `--data-dir`)
348
348
  - `2`: invalid CLI usage or bad flags
349
349
 
350
+ ### Host process helpers: `closeInheritedDescriptors()` and `hardenHostProcess()`
351
+
352
+ ```ts
353
+ export function closeInheritedDescriptors(): number;
354
+ export function hardenHostProcess(): HostHardening;
355
+ export interface HostHardening {
356
+ coreDumpsDisabled: boolean; // RLIMIT_CORE is 0 (soft and hard)
357
+ dumpableCleared: boolean; // Linux: PR_SET_DUMPABLE is 0
358
+ platform: string; // process.platform-style name
359
+ limitations: string[]; // what this platform does not cover
360
+ }
361
+ ```
362
+
363
+ A dedicated process that hosts the engine holds epoch keys and writer seeds in memory. Call
364
+ both first thing in that process, in this order:
365
+
366
+ 1. `closeInheritedDescriptors()` closes every descriptor above stderr that it inherited
367
+ without close-on-exec, so a short-lived launcher's pipes do not stay open. It returns how
368
+ many it closed; off Unix it closes nothing.
369
+ 2. `hardenHostProcess()` keeps key material out of crash artifacts:
370
+
371
+ | Platform | Applied | `limitations` |
372
+ | --- | --- | --- |
373
+ | Linux | `setrlimit(RLIMIT_CORE, 0)` and `prctl(PR_SET_DUMPABLE, 0)`: no core file, and same-user processes can neither `ptrace` it nor read its memory through `/proc` | none |
374
+ | macOS | `setrlimit(RLIMIT_CORE, 0)` | no `PR_SET_DUMPABLE` equivalent; same-user debugger attach is governed by SIP and code signing, not by this call; ReportCrash reports carry stacks and registers, not memory |
375
+ | Windows | nothing in-process | Windows Error Reporting may write a dump; disable WER `LocalDumps` for the host executable |
376
+
377
+ Each item is re-read after it is applied, so the result reports what is actually in
378
+ effect. The call is idempotent and never throws. Run it after
379
+ `closeInheritedDescriptors()`, which lists `/dev/fd`.
380
+
350
381
  ### Error Contract
351
382
 
352
383
  | Condition | Thrown Error / Prefix | Caller Action |
package/index.d.ts CHANGED
@@ -126,6 +126,27 @@ export declare function runCli(args: string[]): number;
126
126
  */
127
127
  export declare function closeInheritedDescriptors(): number;
128
128
 
129
+ /** What `hardenHostProcess` put into effect, each item verified after it was applied. */
130
+ export interface HostHardening {
131
+ /** The core-file limit is 0 (soft and hard): a crash writes no core with key material. */
132
+ coreDumpsDisabled: boolean;
133
+ /** Linux only: not dumpable, so same-user processes cannot ptrace it or read its memory. */
134
+ dumpableCleared: boolean;
135
+ /** `process.platform`-style name of the platform the measures were applied on. */
136
+ platform: string;
137
+ /** What this platform does not cover. */
138
+ limitations: string[];
139
+ }
140
+
141
+ /**
142
+ * Hardens a process that holds key material, such as a dedicated engine host:
143
+ * `setrlimit(RLIMIT_CORE, 0)` on Unix and, on Linux, `prctl(PR_SET_DUMPABLE, 0)`.
144
+ * macOS gets the core limit only; Windows gets nothing in-process (see
145
+ * `limitations`). Call it once, early, after `closeInheritedDescriptors()`.
146
+ * Idempotent; never throws.
147
+ */
148
+ export declare function hardenHostProcess(): HostHardening;
149
+
129
150
  /** Engine-provided request; pass bytes through without re-encoding or wrapping LSCE. */
130
151
  export interface ContentSealRequest {
131
152
  namespace: string;
package/index.js CHANGED
@@ -34,8 +34,15 @@ function load() {
34
34
  return require(`@loro-dev/loro-repo-engine-${suffix}`);
35
35
  }
36
36
 
37
- const { Engine, ContentKeyring, startEngine, engineVersion, runCli, closeInheritedDescriptors } =
38
- load();
37
+ const {
38
+ Engine,
39
+ ContentKeyring,
40
+ startEngine,
41
+ engineVersion,
42
+ runCli,
43
+ closeInheritedDescriptors,
44
+ hardenHostProcess,
45
+ } = load();
39
46
  module.exports = {
40
47
  Engine,
41
48
  ContentKeyring,
@@ -43,4 +50,5 @@ module.exports = {
43
50
  engineVersion,
44
51
  runCli,
45
52
  closeInheritedDescriptors,
53
+ hardenHostProcess,
46
54
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loro-dev/loro-repo-engine",
3
- "version": "0.2.0-next.0",
3
+ "version": "0.2.0-next.1",
4
4
  "description": "The loro-repo engine, prebuilt as a Node-API addon. Source is not public (D3).",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {
@@ -32,12 +32,12 @@
32
32
  ]
33
33
  },
34
34
  "optionalDependencies": {
35
- "@loro-dev/loro-repo-engine-darwin-arm64": "0.2.0-next.0",
36
- "@loro-dev/loro-repo-engine-darwin-x64": "0.2.0-next.0",
37
- "@loro-dev/loro-repo-engine-linux-x64-gnu": "0.2.0-next.0",
38
- "@loro-dev/loro-repo-engine-linux-arm64-gnu": "0.2.0-next.0",
39
- "@loro-dev/loro-repo-engine-win32-x64-msvc": "0.2.0-next.0",
40
- "@loro-dev/loro-repo-engine-win32-arm64-msvc": "0.2.0-next.0"
35
+ "@loro-dev/loro-repo-engine-darwin-arm64": "0.2.0-next.1",
36
+ "@loro-dev/loro-repo-engine-darwin-x64": "0.2.0-next.1",
37
+ "@loro-dev/loro-repo-engine-linux-x64-gnu": "0.2.0-next.1",
38
+ "@loro-dev/loro-repo-engine-linux-arm64-gnu": "0.2.0-next.1",
39
+ "@loro-dev/loro-repo-engine-win32-x64-msvc": "0.2.0-next.1",
40
+ "@loro-dev/loro-repo-engine-win32-arm64-msvc": "0.2.0-next.1"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@napi-rs/cli": "^3.10.0"