@orkestrel/sea 0.0.14 → 0.0.16
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 +11 -7
- package/dist/src/server/index.cjs +113 -72
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +143 -85
- package/dist/src/server/index.d.ts +143 -85
- package/dist/src/server/index.js +113 -72
- package/dist/src/server/index.js.map +1 -1
- package/package.json +15 -16
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EmitterErrorHandler } from '@orkestrel/emitter';
|
|
2
|
-
import { EmitterHooks } from '@orkestrel/emitter';
|
|
3
|
-
import { EmitterInterface } from '@orkestrel/emitter';
|
|
1
|
+
import type { EmitterErrorHandler } from '@orkestrel/emitter';
|
|
2
|
+
import type { EmitterHooks } from '@orkestrel/emitter';
|
|
3
|
+
import type { EmitterInterface } from '@orkestrel/emitter';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Aligns an ELF note component size to its four-byte boundary.
|
|
@@ -80,7 +80,7 @@ export declare class Asset implements AssetInterface {
|
|
|
80
80
|
* Holds the minimal data needed to create an {@link AssetInterface}.
|
|
81
81
|
*
|
|
82
82
|
* @remarks
|
|
83
|
-
* `key` — the asset's lookup key (
|
|
83
|
+
* `key` — the asset's lookup key (for example `"client.html.br"`).
|
|
84
84
|
* `content` — raw asset bytes.
|
|
85
85
|
* `compressed` — whether `content` is Brotli-compressed. Default: inferred
|
|
86
86
|
* from a `.br` suffix on `key`.
|
|
@@ -153,14 +153,23 @@ export declare type AssetManagerEventMap = {
|
|
|
153
153
|
* Outside SEA, `load()` reads the paths `assets` configures from disk.
|
|
154
154
|
*/
|
|
155
155
|
export declare interface AssetManagerInterface {
|
|
156
|
+
/** Holds the emitter reporting the register, load, clear, and error events. */
|
|
156
157
|
readonly emitter: EmitterInterface<AssetManagerEventMap>;
|
|
158
|
+
/** Holds the number of assets registered so far. */
|
|
157
159
|
readonly count: number;
|
|
160
|
+
/** Looks up one registered asset by key. */
|
|
158
161
|
asset(key: string): AssetInterface | undefined;
|
|
162
|
+
/** Lists every registered asset, in registration order. */
|
|
159
163
|
assets(): readonly AssetInterface[];
|
|
164
|
+
/** Lists every registered asset key, in registration order. */
|
|
160
165
|
keys(): readonly string[];
|
|
166
|
+
/** Registers one asset, or every asset of a list. */
|
|
161
167
|
register(input: AssetInput | readonly AssetInput[]): void;
|
|
168
|
+
/** Loads the configured assets from disk, and registers nothing inside SEA mode. */
|
|
162
169
|
load(): void;
|
|
170
|
+
/** Removes every registered asset without destroying the manager. */
|
|
163
171
|
clear(): void;
|
|
172
|
+
/** Clears every registered asset and tears down the emitter. */
|
|
164
173
|
destroy(): void;
|
|
165
174
|
}
|
|
166
175
|
|
|
@@ -180,7 +189,7 @@ export declare interface AssetManagerOptions {
|
|
|
180
189
|
readonly assets?: Readonly<Record<string, string>>;
|
|
181
190
|
}
|
|
182
191
|
|
|
183
|
-
/** Names the file extension indicating Brotli compression */
|
|
192
|
+
/** Names the file extension indicating Brotli compression, `.br`. */
|
|
184
193
|
export declare const BROTLI_EXTENSION = ".br";
|
|
185
194
|
|
|
186
195
|
/**
|
|
@@ -189,7 +198,7 @@ export declare const BROTLI_EXTENSION = ".br";
|
|
|
189
198
|
* @remarks
|
|
190
199
|
* A pure leaf extracted from the SEA build orchestrator. The `mainFormat`
|
|
191
200
|
* field (`'commonjs' | 'module'`) exists only in Node >= 25.7 — for a `'cjs'`
|
|
192
|
-
* entry (the default) `mainFormat` is
|
|
201
|
+
* entry (the default) `mainFormat` is omitted entirely so the config still
|
|
193
202
|
* builds on older Node hosts where `'commonjs'` is already the implicit
|
|
194
203
|
* default; for an `'esm'` entry `mainFormat: 'module'` is set explicitly
|
|
195
204
|
* (this requires a Node >= 25.7 build host). Node also documents that
|
|
@@ -223,7 +232,7 @@ export declare function buildBlobConfig(entry: SEAEntryOptions, blob: string, as
|
|
|
223
232
|
* (`strncmp(name, "NODE_SEA", 8)`), so `resource` is written in full but
|
|
224
233
|
* only needs to begin with those 8 bytes to be found at runtime.
|
|
225
234
|
*
|
|
226
|
-
* @param resource - Note name (SEA resource identifier,
|
|
235
|
+
* @param resource - Note name (SEA resource identifier, for example `NODE_SEA_BLOB`)
|
|
227
236
|
* @param blobSize - Size in bytes of the SEA blob that will follow the header
|
|
228
237
|
* @returns The note header bytes and the total on-disk size of header + blob
|
|
229
238
|
*
|
|
@@ -238,13 +247,13 @@ export declare function buildELFNoteHeader(resource: string, blobSize: number):
|
|
|
238
247
|
* Builds the `signtool sign` argv for signing a Windows executable.
|
|
239
248
|
*
|
|
240
249
|
* @remarks
|
|
241
|
-
* Requires
|
|
250
|
+
* Requires exactly one certificate source — `sign.file` (a `.pfx`/`.p12`
|
|
242
251
|
* file, paired with `sign.password` when present) XOR `sign.thumbprint` (a
|
|
243
252
|
* certificate already installed in the Windows store). When `sign.timestamp`
|
|
244
253
|
* is set it is parsed with the `URL` constructor and must be an `http:` or
|
|
245
254
|
* `https:` URL. The returned argv is passed directly to `executeShell` — never
|
|
246
255
|
* through a shell — so nothing in `sign` can be interpreted as a flag or
|
|
247
|
-
* injected into a command line. `sign.password` is
|
|
256
|
+
* injected into a command line. `sign.password` is never included in a
|
|
248
257
|
* thrown error's message or `context`.
|
|
249
258
|
*
|
|
250
259
|
* @param sign - Windows signing options
|
|
@@ -325,7 +334,9 @@ export declare function computeSize(original: number, compressed: number): SEACo
|
|
|
325
334
|
export declare function copyRange(source: number, target: number, start: number, length: number, chunk?: number): void;
|
|
326
335
|
|
|
327
336
|
/**
|
|
328
|
-
* Creates a
|
|
337
|
+
* Creates one named asset from a key and a content buffer and returns it as an
|
|
338
|
+
* `AssetInterface`, with `compressed` inferred from the key where the input leaves
|
|
339
|
+
* it unset.
|
|
329
340
|
*
|
|
330
341
|
* @param input - Asset key, content, and optional compression flag
|
|
331
342
|
* @returns a new `AssetInterface`
|
|
@@ -338,7 +349,8 @@ export declare function copyRange(source: number, target: number, start: number,
|
|
|
338
349
|
export declare function createAsset(input: AssetInput): AssetInterface;
|
|
339
350
|
|
|
340
351
|
/**
|
|
341
|
-
* Creates an asset
|
|
352
|
+
* Creates an asset collection and returns it as an `AssetManagerInterface`, already
|
|
353
|
+
* carrying whatever assets the running SEA blob embeds.
|
|
342
354
|
*
|
|
343
355
|
* @param options - Asset manager options (root, event hooks)
|
|
344
356
|
* @returns a new `AssetManagerInterface`
|
|
@@ -352,11 +364,13 @@ export declare function createAsset(input: AssetInput): AssetInterface;
|
|
|
352
364
|
export declare function createAssetManager(options?: AssetManagerOptions): AssetManagerInterface;
|
|
353
365
|
|
|
354
366
|
/**
|
|
355
|
-
* Creates a
|
|
367
|
+
* Creates a resource injector bound to one target executable and returns it as an
|
|
368
|
+
* `InjectorInterface`, with the executable's format already detected from its header.
|
|
356
369
|
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
*
|
|
370
|
+
* @remarks
|
|
371
|
+
* The format detected at construction — PE, ELF, or Mach-O — selects the strategy
|
|
372
|
+
* `inject` takes. Every write runs through pure TypeScript file I/O, so the injector
|
|
373
|
+
* needs no WASM and no external tool.
|
|
360
374
|
*
|
|
361
375
|
* @param options - Injector options
|
|
362
376
|
* @returns a new `InjectorInterface`
|
|
@@ -375,53 +389,65 @@ export declare function createAssetManager(options?: AssetManagerOptions): Asset
|
|
|
375
389
|
export declare function createInjector(options: InjectorOptions): InjectorInterface;
|
|
376
390
|
|
|
377
391
|
/**
|
|
378
|
-
* Creates a
|
|
392
|
+
* Creates a SEA build orchestrator over the given options and returns it as a
|
|
393
|
+
* `SEAInterface`, the published contract a caller holds instead of the `SEA` class.
|
|
379
394
|
*
|
|
380
395
|
* @param options - SEA build options
|
|
381
396
|
* @returns a new `SEAInterface`
|
|
382
397
|
*
|
|
383
|
-
* @example
|
|
398
|
+
* @example Build a single executable
|
|
384
399
|
* ```ts
|
|
400
|
+
* import { createSEA, formatSize } from '@orkestrel/sea'
|
|
401
|
+
*
|
|
385
402
|
* const sea = createSEA({
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
*
|
|
403
|
+
* name: 'myapp',
|
|
404
|
+
* entry: { path: 'dist/server/serve.cjs' },
|
|
405
|
+
* output: 'dist/sea',
|
|
406
|
+
* assets: { 'model.gguf': 'models/model.gguf' },
|
|
407
|
+
* compression: { paths: ['dist/app/browser'], mode: 'text' },
|
|
408
|
+
* windows: { terminal: false },
|
|
409
|
+
* timeout: 30_000,
|
|
391
410
|
* })
|
|
411
|
+
*
|
|
392
412
|
* const result = await sea.execute()
|
|
413
|
+
* process.stdout.write(
|
|
414
|
+
* `${result.executable} ${formatSize(result.size)} ${String(result.duration)}ms\n`,
|
|
415
|
+
* )
|
|
393
416
|
* ```
|
|
394
417
|
*/
|
|
395
418
|
export declare function createSEA(options: SEAOptions): SEAInterface;
|
|
396
419
|
|
|
397
|
-
/** Names the default SEA entry point module format when none is specified */
|
|
420
|
+
/** Names the default SEA entry point module format when none is specified, `cjs`. */
|
|
398
421
|
export declare const DEFAULT_ENTRY_FORMAT: SEAEntryFormat;
|
|
399
422
|
|
|
400
|
-
/** Holds the default Brotli compression quality level
|
|
423
|
+
/** Holds the default Brotli compression quality level, 11, the maximum Brotli accepts. */
|
|
401
424
|
export declare const DEFAULT_SEA_COMPRESSION_QUALITY = 11;
|
|
402
425
|
|
|
403
|
-
/** Holds the ELF 64-bit class identifier */
|
|
426
|
+
/** Holds the ELF 64-bit class identifier, 2. */
|
|
404
427
|
export declare const ELF_CLASS_64 = 2;
|
|
405
428
|
|
|
406
|
-
/** Holds the ELF little-endian data encoding */
|
|
429
|
+
/** Holds the ELF little-endian data encoding, 1. */
|
|
407
430
|
export declare const ELF_DATA_LSB = 1;
|
|
408
431
|
|
|
409
|
-
/**
|
|
432
|
+
/**
|
|
433
|
+
* Holds the ELF magic, 0x7f454c46, the bytes 0x7F `E` `L` `F` read as a 32-bit
|
|
434
|
+
* big-endian value.
|
|
435
|
+
*/
|
|
410
436
|
export declare const ELF_MAGIC = 2135247942;
|
|
411
437
|
|
|
412
|
-
/** Holds the page size an injected ELF segment is aligned to */
|
|
438
|
+
/** Holds the page size an injected ELF segment is aligned to, 0x1000. */
|
|
413
439
|
export declare const ELF_PAGE_SIZE = 4096;
|
|
414
440
|
|
|
415
|
-
/** Holds the ELF segment permission flag marking a segment readable */
|
|
441
|
+
/** Holds the ELF segment permission flag marking a segment readable, 4. */
|
|
416
442
|
export declare const ELF_PF_R = 4;
|
|
417
443
|
|
|
418
|
-
/** Holds the ELF program header type for a loadable segment */
|
|
444
|
+
/** Holds the ELF program header type for a loadable segment, 1. */
|
|
419
445
|
export declare const ELF_PT_LOAD = 1;
|
|
420
446
|
|
|
421
|
-
/** Holds the ELF program header type for a note segment */
|
|
447
|
+
/** Holds the ELF program header type for a note segment, 4. */
|
|
422
448
|
export declare const ELF_PT_NOTE = 4;
|
|
423
449
|
|
|
424
|
-
/** Holds the ELF program header type for the program header table itself */
|
|
450
|
+
/** Holds the ELF program header type for the program header table itself, 6. */
|
|
425
451
|
export declare const ELF_PT_PHDR = 6;
|
|
426
452
|
|
|
427
453
|
/**
|
|
@@ -468,10 +494,10 @@ export declare interface ELFProgramHeader {
|
|
|
468
494
|
* Resolves `path` against `base`, then dereferences both the resolved path
|
|
469
495
|
* and `base` with `realpathSync` and requires the real resolved path to
|
|
470
496
|
* equal the real base or begin with the real base plus a path separator.
|
|
471
|
-
* Dereferencing
|
|
497
|
+
* Dereferencing both sides means a symlinked base itself (for example macOS `/tmp`
|
|
472
498
|
* -> `/private/tmp`) still matches, while a symlink inside the tree that
|
|
473
499
|
* points outside the real base is correctly rejected. A `realpathSync`
|
|
474
|
-
* failure (
|
|
500
|
+
* failure (for example `ENOENT`) is wrapped as a coded `SEAError` rather than
|
|
475
501
|
* leaking the raw Node error.
|
|
476
502
|
*
|
|
477
503
|
* @param base - Absolute path to the containing root
|
|
@@ -503,7 +529,7 @@ export declare function ensureExists(path: string, message: string, code?: SEAEr
|
|
|
503
529
|
*
|
|
504
530
|
* @remarks
|
|
505
531
|
* Rejects an empty key, an absolute path, a key containing a backslash, a
|
|
506
|
-
* Windows drive-relative specifier (
|
|
532
|
+
* Windows drive-relative specifier (for example `'C:foo'`), or any `/`-separated
|
|
507
533
|
* segment equal to `'..'` — all of which could escape the intended asset root.
|
|
508
534
|
*
|
|
509
535
|
* @param key - Asset key to validate
|
|
@@ -524,8 +550,8 @@ export declare function ensureSafeKey(key: string): void;
|
|
|
524
550
|
*
|
|
525
551
|
* @remarks
|
|
526
552
|
* Rejects an empty name, `'.'`, `'..'`, a name containing a `/` or `\`
|
|
527
|
-
* separator, an absolute path, or a Windows drive-relative specifier (
|
|
528
|
-
* `'C:foo'`) — all of which could redirect the output executable outside
|
|
553
|
+
* separator, an absolute path, or a Windows drive-relative specifier (for
|
|
554
|
+
* example `'C:foo'`) — all of which could redirect the output executable outside
|
|
529
555
|
* the intended output directory.
|
|
530
556
|
*
|
|
531
557
|
* @param name - Output executable base name to validate
|
|
@@ -583,7 +609,7 @@ export declare function finalizeExecutable(source: string, target: string): void
|
|
|
583
609
|
* Formats a byte count as a human-readable string.
|
|
584
610
|
*
|
|
585
611
|
* @param bytes - Byte count
|
|
586
|
-
* @returns Formatted string (
|
|
612
|
+
* @returns Formatted string (for example `"1.23 MB"`, `"456 KB"`)
|
|
587
613
|
*/
|
|
588
614
|
export declare function formatSize(bytes: number): string;
|
|
589
615
|
|
|
@@ -649,7 +675,7 @@ export declare interface InjectorMachOOptions {
|
|
|
649
675
|
*
|
|
650
676
|
* @remarks
|
|
651
677
|
* `executable` — absolute path to the target executable.
|
|
652
|
-
* `resource` — resource identifier (
|
|
678
|
+
* `resource` — resource identifier (for example `"NODE_SEA_BLOB"`).
|
|
653
679
|
* `blob` — absolute path to the data file to inject.
|
|
654
680
|
* `fuse` — when set, patches the fuse from `:0` to `:1` after injection.
|
|
655
681
|
* `macho` — Mach-O specific options; `segment` defaults to `"NODE_SEA"`.
|
|
@@ -674,7 +700,7 @@ export declare interface InjectorOptions {
|
|
|
674
700
|
export declare function isCompressible(path: string): boolean;
|
|
675
701
|
|
|
676
702
|
/**
|
|
677
|
-
* Checks
|
|
703
|
+
* Checks whether a value is a valid {@link ExecutableFormat}.
|
|
678
704
|
*
|
|
679
705
|
* @param value - Value to check
|
|
680
706
|
* @returns True if value is `'pe'`, `'elf'`, or `'macho'`; false otherwise
|
|
@@ -688,7 +714,7 @@ export declare function isCompressible(path: string): boolean;
|
|
|
688
714
|
export declare function isExecutableFormat(value: unknown): value is ExecutableFormat;
|
|
689
715
|
|
|
690
716
|
/**
|
|
691
|
-
* Checks
|
|
717
|
+
* Checks whether a file is a Windows PE executable.
|
|
692
718
|
*
|
|
693
719
|
* @param path - Path to the file
|
|
694
720
|
* @returns True if the file has a valid PE signature; false otherwise
|
|
@@ -696,7 +722,7 @@ export declare function isExecutableFormat(value: unknown): value is ExecutableF
|
|
|
696
722
|
export declare function isPEExecutable(path: string): boolean;
|
|
697
723
|
|
|
698
724
|
/**
|
|
699
|
-
* Checks
|
|
725
|
+
* Checks whether the current or named platform is supported for SEA builds.
|
|
700
726
|
*
|
|
701
727
|
* @param platform - Platform identifier to check
|
|
702
728
|
* @returns True if the platform has a known configuration; false otherwise
|
|
@@ -741,10 +767,10 @@ export declare function isSEAError(value: unknown): value is SEAError;
|
|
|
741
767
|
*/
|
|
742
768
|
export declare function isShellError(value: unknown): value is ShellError;
|
|
743
769
|
|
|
744
|
-
/** Holds the Mach-O LC_SEGMENT_64 load command */
|
|
770
|
+
/** Holds the Mach-O `LC_SEGMENT_64` load command, 0x19. */
|
|
745
771
|
export declare const MACHO_LC_SEGMENT_64 = 25;
|
|
746
772
|
|
|
747
|
-
/** Holds the Mach-O 64-bit magic
|
|
773
|
+
/** Holds the Mach-O 64-bit magic, 0xfeedfacf, in little-endian byte order. */
|
|
748
774
|
export declare const MACHO_MAGIC_64 = 4277009103;
|
|
749
775
|
|
|
750
776
|
/**
|
|
@@ -760,7 +786,7 @@ export declare const MACHO_MAGIC_64 = 4277009103;
|
|
|
760
786
|
* outlives the host app and never keeps it alive, and it swallows the async
|
|
761
787
|
* host fault an absent opener binary raises. Only `http:` and `https:` URLs
|
|
762
788
|
* are accepted — any other scheme (including a string that merely looks like a
|
|
763
|
-
* CLI flag,
|
|
789
|
+
* CLI flag, for example `'-e ...'`) fails to parse as an http(s) URL and is rejected
|
|
764
790
|
* before anything is spawned.
|
|
765
791
|
*
|
|
766
792
|
* @param url - Absolute http or https URL to open
|
|
@@ -785,10 +811,11 @@ export declare function patchPESubsystem(path: string, subsystem: number): void;
|
|
|
785
811
|
/**
|
|
786
812
|
* Patches the sentinel fuse in a binary from `:0` to `:1`.
|
|
787
813
|
*
|
|
788
|
-
*
|
|
789
|
-
*
|
|
790
|
-
*
|
|
791
|
-
*
|
|
814
|
+
* @remarks
|
|
815
|
+
* Searches the file in 64 MB chunks with overlap to handle any file size. The fuse
|
|
816
|
+
* signals to the Node.js runtime that a SEA blob is present. The `Injector` class
|
|
817
|
+
* normally applies this patch, and it stays available standalone for a build that
|
|
818
|
+
* injects the PE resource natively instead.
|
|
792
819
|
*
|
|
793
820
|
* @param executable - Absolute path to the executable
|
|
794
821
|
* @param fuse - Sentinel fuse string (without the `:0` suffix)
|
|
@@ -798,43 +825,49 @@ export declare function patchPESubsystem(path: string, subsystem: number): void;
|
|
|
798
825
|
*/
|
|
799
826
|
export declare function patchSentinelFuse(executable: string, fuse: string): void;
|
|
800
827
|
|
|
801
|
-
/** Holds the PE32 optional header magic */
|
|
828
|
+
/** Holds the PE32 optional header magic, 0x10b. */
|
|
802
829
|
export declare const PE32_MAGIC = 267;
|
|
803
830
|
|
|
804
|
-
/** Holds the PE32+
|
|
831
|
+
/** Holds the PE32+ optional header magic, 0x20b, the 64-bit form. */
|
|
805
832
|
export declare const PE32_PLUS_MAGIC = 523;
|
|
806
833
|
|
|
807
|
-
/** Holds the DOS MZ header magic
|
|
834
|
+
/** Holds the DOS MZ header magic, 0x5a4d, the first two bytes of a PE file. */
|
|
808
835
|
export declare const PE_MAGIC = 23117;
|
|
809
836
|
|
|
810
|
-
/** Holds the size of IMAGE_RESOURCE_DATA_ENTRY in bytes */
|
|
837
|
+
/** Holds the size of `IMAGE_RESOURCE_DATA_ENTRY` in bytes, 16. */
|
|
811
838
|
export declare const PE_RESOURCE_DATA_ENTRY_SIZE = 16;
|
|
812
839
|
|
|
813
|
-
/** Holds the size of IMAGE_RESOURCE_DIRECTORY in bytes */
|
|
840
|
+
/** Holds the size of `IMAGE_RESOURCE_DIRECTORY` in bytes, 16. */
|
|
814
841
|
export declare const PE_RESOURCE_DIR_SIZE = 16;
|
|
815
842
|
|
|
816
|
-
/** Holds the size of IMAGE_RESOURCE_DIRECTORY_ENTRY in bytes */
|
|
843
|
+
/** Holds the size of `IMAGE_RESOURCE_DIRECTORY_ENTRY` in bytes, 8. */
|
|
817
844
|
export declare const PE_RESOURCE_ENTRY_SIZE = 8;
|
|
818
845
|
|
|
819
|
-
/**
|
|
846
|
+
/**
|
|
847
|
+
* Holds the high bit mask marking a resource entry as named rather than
|
|
848
|
+
* integer-identified, 0x80000000.
|
|
849
|
+
*/
|
|
820
850
|
export declare const PE_RESOURCE_NAME_FLAG = 2147483648;
|
|
821
851
|
|
|
822
|
-
/**
|
|
852
|
+
/**
|
|
853
|
+
* Holds the high bit mask marking a resource directory entry offset as a
|
|
854
|
+
* subdirectory, 0x80000000.
|
|
855
|
+
*/
|
|
823
856
|
export declare const PE_RESOURCE_SUBDIR_FLAG = 2147483648;
|
|
824
857
|
|
|
825
|
-
/** Holds the PE resource type RT_RCDATA
|
|
858
|
+
/** Holds the PE resource type `RT_RCDATA` for raw data, 10. */
|
|
826
859
|
export declare const PE_RT_RCDATA = 10;
|
|
827
860
|
|
|
828
|
-
/** Marks a section as containing initialized data */
|
|
861
|
+
/** Marks a section as containing initialized data, 0x00000040. */
|
|
829
862
|
export declare const PE_SCN_INITIALIZED_DATA = 64;
|
|
830
863
|
|
|
831
|
-
/** Marks a section as readable */
|
|
864
|
+
/** Marks a section as readable, 0x40000000. */
|
|
832
865
|
export declare const PE_SCN_MEM_READ = 1073741824;
|
|
833
866
|
|
|
834
|
-
/** Holds the PE section header size in bytes */
|
|
867
|
+
/** Holds the PE section header size in bytes, 40. */
|
|
835
868
|
export declare const PE_SECTION_HEADER_SIZE = 40;
|
|
836
869
|
|
|
837
|
-
/** Holds the PE signature,
|
|
870
|
+
/** Holds the PE signature, 0x00004550, the bytes `PE\0\0` read as a 32-bit value. */
|
|
838
871
|
export declare const PE_SIGNATURE = 17744;
|
|
839
872
|
|
|
840
873
|
/**
|
|
@@ -948,7 +981,8 @@ export declare function readU32(fd: number, offset: number): number;
|
|
|
948
981
|
export declare function readU64(fd: number, offset: number): bigint;
|
|
949
982
|
|
|
950
983
|
/**
|
|
951
|
-
* Redacts password arguments from a shell command
|
|
984
|
+
* Redacts password arguments from a shell command, so the command is safe to
|
|
985
|
+
* include in an error message.
|
|
952
986
|
*
|
|
953
987
|
* @param command - Command arguments to redact
|
|
954
988
|
* @returns A copy with values following password flags replaced by a marker
|
|
@@ -996,16 +1030,25 @@ export declare class SEA implements SEAInterface {
|
|
|
996
1030
|
destroy(): void;
|
|
997
1031
|
}
|
|
998
1032
|
|
|
999
|
-
/** Names the SEA blob resource in the executable */
|
|
1033
|
+
/** Names the SEA blob resource in the executable, `NODE_SEA_BLOB`. */
|
|
1000
1034
|
export declare const SEA_BLOB_RESOURCE = "NODE_SEA_BLOB";
|
|
1001
1035
|
|
|
1002
|
-
/**
|
|
1036
|
+
/**
|
|
1037
|
+
* Maps a {@link SEACompressionMode} to its numeric Brotli mode value: `generic`
|
|
1038
|
+
* to 0, `text` to 1, and `font` to 2.
|
|
1039
|
+
*/
|
|
1003
1040
|
export declare const SEA_COMPRESSION_MODE_VALUES: Readonly<Record<SEACompressionMode, number>>;
|
|
1004
1041
|
|
|
1005
|
-
/**
|
|
1042
|
+
/**
|
|
1043
|
+
* Holds the platform-specific SEA build configurations, keyed by
|
|
1044
|
+
* `process.platform` for `win32`, `darwin`, and `linux`.
|
|
1045
|
+
*/
|
|
1006
1046
|
export declare const SEA_PLATFORMS: Readonly<Record<string, SEAPlatform>>;
|
|
1007
1047
|
|
|
1008
|
-
/**
|
|
1048
|
+
/**
|
|
1049
|
+
* Holds the SEA sentinel fuse value embedded in the Node.js binary,
|
|
1050
|
+
* `NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2`.
|
|
1051
|
+
*/
|
|
1009
1052
|
export declare const SEA_SENTINEL_FUSE = "NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2";
|
|
1010
1053
|
|
|
1011
1054
|
/**
|
|
@@ -1152,7 +1195,7 @@ export declare class SEAError extends Error {
|
|
|
1152
1195
|
* `SIGN` — code signing failure.
|
|
1153
1196
|
* `SHELL` — shell command exited non-zero.
|
|
1154
1197
|
* `TIMEOUT` — shell command exceeded its timeout.
|
|
1155
|
-
* `ABORT` — operation aborted
|
|
1198
|
+
* `ABORT` — operation aborted through `AbortSignal`.
|
|
1156
1199
|
* `OUTPUT` — final executable write/finalize failure.
|
|
1157
1200
|
* `STATE` — invalid internal state or argument.
|
|
1158
1201
|
* `BROWSER` — invalid or unsupported URL passed to `openBrowser`.
|
|
@@ -1174,12 +1217,20 @@ export declare type SEAEventMap = {
|
|
|
1174
1217
|
*
|
|
1175
1218
|
* @remarks
|
|
1176
1219
|
* Compresses assets, generates the SEA blob, copies the Node binary,
|
|
1177
|
-
* injects the blob
|
|
1220
|
+
* injects the blob through the built-in Injector, and handles platform-specific signing.
|
|
1178
1221
|
*/
|
|
1179
1222
|
export declare interface SEAInterface {
|
|
1223
|
+
/** Holds the emitter reporting each build stage as it completes. */
|
|
1180
1224
|
readonly emitter: EmitterInterface<SEAEventMap>;
|
|
1225
|
+
/** Holds the phase the build has reached. */
|
|
1181
1226
|
readonly status: SEAStatus;
|
|
1227
|
+
/**
|
|
1228
|
+
* Runs the compress, blob, and assemble stages and returns the build result.
|
|
1229
|
+
*
|
|
1230
|
+
* @throws SEAError with the `SEAErrorCode` of the stage that failed, after `status` becomes `'error'`
|
|
1231
|
+
*/
|
|
1182
1232
|
execute(): Promise<SEAResult>;
|
|
1233
|
+
/** Tears down the emitter. */
|
|
1183
1234
|
destroy(): void;
|
|
1184
1235
|
}
|
|
1185
1236
|
|
|
@@ -1232,7 +1283,7 @@ export declare interface SEAPlatform {
|
|
|
1232
1283
|
* Represents the progress reported while compressing a directory.
|
|
1233
1284
|
*
|
|
1234
1285
|
* @remarks
|
|
1235
|
-
* `path` — absolute path to the file
|
|
1286
|
+
* `path` — absolute path to the file compressed most recently.
|
|
1236
1287
|
* `current` — number of files compressed so far (1-based).
|
|
1237
1288
|
* `total` — total number of compressible files.
|
|
1238
1289
|
*/
|
|
@@ -1247,7 +1298,7 @@ export declare interface SEAProgress {
|
|
|
1247
1298
|
*
|
|
1248
1299
|
* @remarks
|
|
1249
1300
|
* `executable` — absolute path to the output binary.
|
|
1250
|
-
* `platform` — platform identifier (
|
|
1301
|
+
* `platform` — platform identifier (for example `"win32"`, `"darwin"`).
|
|
1251
1302
|
* `size` — file size of the executable in bytes.
|
|
1252
1303
|
* `duration` — build time in milliseconds.
|
|
1253
1304
|
* `compression` — compression manifest when directories were compressed.
|
|
@@ -1297,11 +1348,11 @@ export declare type SEAStatus = 'idle' | 'active' | 'done' | 'error';
|
|
|
1297
1348
|
* valid stdio, so `process.stdout`/`stderr`/`stdin` are detached and console
|
|
1298
1349
|
* output is discarded; use only for windowless apps.
|
|
1299
1350
|
* `sign` — Authenticode signing options. When present, the assembled
|
|
1300
|
-
* executable is signed with `signtool` (and verified) as the
|
|
1351
|
+
* executable is signed with `signtool` (and verified) as the last content
|
|
1301
1352
|
* mutation before the atomic finalize; when absent, the output is unsigned
|
|
1302
1353
|
* and `SEAResult.signed` is `false`.
|
|
1303
1354
|
*
|
|
1304
|
-
* These options apply only when the build
|
|
1355
|
+
* These options apply only when the build host is Windows — there is no
|
|
1305
1356
|
* cross-compilation, so building on a non-Windows host ignores `windows.*`.
|
|
1306
1357
|
*/
|
|
1307
1358
|
export declare interface SEAWindowsOptions {
|
|
@@ -1314,7 +1365,7 @@ export declare interface SEAWindowsOptions {
|
|
|
1314
1365
|
*
|
|
1315
1366
|
* @remarks
|
|
1316
1367
|
* `file` — path to a `.pfx`/`.p12` certificate file (`signtool /f`).
|
|
1317
|
-
* `password` — certificate password (`signtool /p`).
|
|
1368
|
+
* `password` — certificate password (`signtool /p`). Sensitive: never
|
|
1318
1369
|
* logged and never included in a thrown error's message or `context`.
|
|
1319
1370
|
* `thumbprint` — SHA1 thumbprint of a certificate already installed in the
|
|
1320
1371
|
* Windows certificate store (`signtool /sha1`).
|
|
@@ -1322,7 +1373,7 @@ export declare interface SEAWindowsOptions {
|
|
|
1322
1373
|
* `/td <digest>`).
|
|
1323
1374
|
* `digest` — file digest algorithm (`signtool /fd`). Default: `'sha256'`.
|
|
1324
1375
|
*
|
|
1325
|
-
* Exactly
|
|
1376
|
+
* Exactly one of `file` or `thumbprint` must be supplied — they identify two
|
|
1326
1377
|
* different certificate sources and are mutually exclusive. `password`
|
|
1327
1378
|
* pairs with `file` (a store-resident certificate referenced by
|
|
1328
1379
|
* `thumbprint` has no associated password to supply here).
|
|
@@ -1360,7 +1411,10 @@ export declare class ShellError extends SEAError {
|
|
|
1360
1411
|
constructor(message: string, stdout: Buffer, stderr: Buffer);
|
|
1361
1412
|
}
|
|
1362
1413
|
|
|
1363
|
-
/**
|
|
1414
|
+
/**
|
|
1415
|
+
* Lists the file extensions Brotli compression skips, the already-compressed
|
|
1416
|
+
* archive, image, font, and media formats.
|
|
1417
|
+
*/
|
|
1364
1418
|
export declare const SKIP_EXTENSIONS: ReadonlySet<string>;
|
|
1365
1419
|
|
|
1366
1420
|
/**
|
|
@@ -1370,18 +1424,18 @@ export declare const SKIP_EXTENSIONS: ReadonlySet<string>;
|
|
|
1370
1424
|
* @remarks
|
|
1371
1425
|
* If the certificate overlay described by the security directory sits at the
|
|
1372
1426
|
* very end of the file (the common case for `signtool`-signed binaries), the
|
|
1373
|
-
* file is truncated to the certificate's start
|
|
1427
|
+
* file is truncated to the certificate's start first so the overlay bytes are
|
|
1374
1428
|
* discarded rather than left as dead weight for a downstream injector to
|
|
1375
1429
|
* bury mid-file. The directory read is bounds-checked so a malformed or
|
|
1376
|
-
* truncated security directory cannot throw unexpectedly — it is
|
|
1377
|
-
*
|
|
1430
|
+
* truncated security directory cannot throw unexpectedly — it is skipped
|
|
1431
|
+
* and only the directory entry is zeroed.
|
|
1378
1432
|
*
|
|
1379
1433
|
* @param path - Path to the executable
|
|
1380
1434
|
*/
|
|
1381
1435
|
export declare function stripPESignature(path: string): void;
|
|
1382
1436
|
|
|
1383
1437
|
/**
|
|
1384
|
-
* Truncates a
|
|
1438
|
+
* Truncates a NUL-padded binary name field at its first NUL character.
|
|
1385
1439
|
*
|
|
1386
1440
|
* @remarks
|
|
1387
1441
|
* Binary name fields (PE section names, Mach-O segment and section names, ELF
|
|
@@ -1402,14 +1456,14 @@ export declare function stripTrailingNulls(value: string): string;
|
|
|
1402
1456
|
* Fsyncs a directory to durably persist a prior file rename/create within it.
|
|
1403
1457
|
*
|
|
1404
1458
|
* @remarks
|
|
1405
|
-
* A `rename`/`create` is only durable once its
|
|
1459
|
+
* A `rename`/`create` is only durable once its containing directory entry is
|
|
1406
1460
|
* flushed — fsyncing the file itself is not enough. `path` is the directory
|
|
1407
1461
|
* to fsync (callers pass `dirname(target)`, not the file itself). On Windows
|
|
1408
1462
|
* there is no directory file handle to fsync, so this is a no-op there (the
|
|
1409
1463
|
* platform lacks the primitive, not a failure). Some filesystems/platforms
|
|
1410
1464
|
* return a benign errno for a directory fsync attempt (`EINVAL`, `ENOTSUP`,
|
|
1411
1465
|
* `EISDIR`, `EPERM`, `EACCES`) — those are treated as "fsync unsupported
|
|
1412
|
-
* here" and swallowed; anything else (
|
|
1466
|
+
* here" and swallowed; anything else (for example `ENOENT`, meaning the directory
|
|
1413
1467
|
* itself is missing) is a genuine failure and is thrown as a coded `SEAError`.
|
|
1414
1468
|
*
|
|
1415
1469
|
* @param path - Directory path to fsync
|
|
@@ -1424,7 +1478,8 @@ export declare function stripTrailingNulls(value: string): string;
|
|
|
1424
1478
|
export declare function syncDirectory(path: string): void;
|
|
1425
1479
|
|
|
1426
1480
|
/**
|
|
1427
|
-
* Walks a directory recursively and returns
|
|
1481
|
+
* Walks a directory recursively and returns every file path it finds, relative to
|
|
1482
|
+
* the base and skipping symlinks.
|
|
1428
1483
|
*
|
|
1429
1484
|
* @param directory - Directory to walk
|
|
1430
1485
|
* @param base - Base directory for relative path calculation
|
|
@@ -1432,10 +1487,13 @@ export declare function syncDirectory(path: string): void;
|
|
|
1432
1487
|
*/
|
|
1433
1488
|
export declare function walkDirectory(directory: string, base?: string): readonly string[];
|
|
1434
1489
|
|
|
1435
|
-
/** Holds the Windows PE subsystem value for a console application */
|
|
1490
|
+
/** Holds the Windows PE subsystem value for a console application, 3. */
|
|
1436
1491
|
export declare const WINDOWS_SUBSYSTEM_CONSOLE = 3;
|
|
1437
1492
|
|
|
1438
|
-
/**
|
|
1493
|
+
/**
|
|
1494
|
+
* Holds the Windows PE subsystem value for a GUI application, 2, which launches
|
|
1495
|
+
* without a terminal window.
|
|
1496
|
+
*/
|
|
1439
1497
|
export declare const WINDOWS_SUBSYSTEM_GUI = 2;
|
|
1440
1498
|
|
|
1441
1499
|
/**
|