@jeffusion/bungee-types 5.1.3 → 5.1.5

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.
@@ -208,8 +208,30 @@ async function secureTarget(targetPath, options, mustExist) {
208
208
  fail('race', 'metadata file was detached by rename');
209
209
  if (platform !== 'win32' && typeof process.geteuid === 'function' && item.uid !== process.geteuid())
210
210
  fail('owner', 'metadata owner is invalid');
211
- if (platform === 'win32')
212
- await ensureWindowsAcl(target, options.windowsAcl ?? defaultWindowsAclAdapter(), 'file', options);
211
+ if (platform === 'win32') {
212
+ try {
213
+ await ensureWindowsAcl(target, options.windowsAcl ?? defaultWindowsAclAdapter(), 'file', options);
214
+ }
215
+ catch (error) {
216
+ if (error instanceof DaemonFileError && error.code === 'acl') {
217
+ // Shutdown may unlink or replace metadata while PowerShell is inspecting it.
218
+ // Recheck locally; an unchanged file must still surface its ACL failure.
219
+ let current;
220
+ try {
221
+ current = await lstat(target);
222
+ }
223
+ catch (inspectionError) {
224
+ if (inspectionError.code === 'ENOENT')
225
+ throw inspectionError;
226
+ throw error;
227
+ }
228
+ if (!sameIdentity(identity(item), identity(current))) {
229
+ fail('race', 'metadata file changed during Windows ACL inspection', error);
230
+ }
231
+ }
232
+ throw error;
233
+ }
234
+ }
213
235
  testStage(options, 'target_realpath');
214
236
  const canonical = await realpath(target);
215
237
  if (!contained(canonicalRoot, canonical, platform)) {
@@ -439,10 +461,14 @@ export function formatDaemonFileAclError(error) {
439
461
  const operation = WINDOWS_ACL_OPERATIONS.has(diagnostic.operation) ? diagnostic.operation : 'unknown';
440
462
  const outcome = WINDOWS_ACL_OUTCOMES.has(diagnostic.outcome) ? diagnostic.outcome : 'unknown';
441
463
  const lastPhase = diagnostic.last_phase === null ? 'null' : WINDOWS_ACL_PHASES.has(diagnostic.last_phase) ? diagnostic.last_phase : 'unknown';
464
+ const targetKind = diagnostic.target_kind !== null && WINDOWS_ACL_TARGET_KINDS.has(diagnostic.target_kind) ? diagnostic.target_kind : 'unknown';
465
+ const exitCode = diagnostic.exit_code === null ? 'null'
466
+ : Number.isSafeInteger(diagnostic.exit_code) && Math.abs(diagnostic.exit_code) <= 2147483647 ? diagnostic.exit_code : 'unknown';
442
467
  return `acl_operation=${operation} outcome=${outcome}`
443
468
  + ` last_phase=${lastPhase} kill_returned_true=${diagnostic.kill_returned_true === true}`
444
469
  + ` spawn_event=${diagnostic.spawn_event === true} exit_event=${diagnostic.exit_event === true}`
445
- + ` close_event=${diagnostic.close_event === true}`;
470
+ + ` close_event=${diagnostic.close_event === true}`
471
+ + ` target_kind=${targetKind} exit_code=${exitCode}`;
446
472
  }
447
473
  function boundedElapsed(startedAt, deadlineMs) {
448
474
  return Math.min(deadlineMs, Math.max(0, Date.now() - startedAt));
@@ -465,6 +491,8 @@ function processDiagnostic(operation, startedAt, phase, environment, deadlineMs,
465
491
  outcome: result.outcome,
466
492
  elapsed_ms: boundedElapsed(startedAt, deadlineMs),
467
493
  exit_code: typeof result.exitCode === 'number' ? result.exitCode : null,
494
+ target_kind: environment.BUNGEE_DAEMON_ACL_KIND === 'directory' || environment.BUNGEE_DAEMON_ACL_KIND === 'file'
495
+ ? environment.BUNGEE_DAEMON_ACL_KIND : null,
468
496
  signal: allowedSignal(result.signal ?? null),
469
497
  spawn_event: result.spawnEvent,
470
498
  exit_event: result.exitEvent,
@@ -712,7 +740,8 @@ export function __testCreateDaemonFileAclError(overrides = {}) {
712
740
  ? overrides.last_phase : 'forged_phase';
713
741
  const diagnostic = {
714
742
  operation, outcome, elapsed_ms: typeof overrides.elapsed_ms === 'number' ? overrides.elapsed_ms : 1,
715
- exit_code: typeof overrides.exit_code === 'number' ? overrides.exit_code : 17,
743
+ exit_code: Object.prototype.hasOwnProperty.call(overrides, 'exit_code') ? overrides.exit_code : 17,
744
+ target_kind: overrides.target_kind ?? null,
716
745
  signal: typeof overrides.signal === 'string' && WINDOWS_ACL_SIGNALS.has(overrides.signal) ? overrides.signal : null,
717
746
  spawn_event: overrides.spawn_event === true,
718
747
  exit_event: overrides.exit_event === true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jeffusion/bungee-types",
3
- "version": "5.1.3",
3
+ "version": "5.1.5",
4
4
  "description": "TypeScript type definitions for Bungee",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",