@openclaw/crabline 0.1.15 → 0.1.17

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.
Files changed (34) hide show
  1. package/dist/src/index.d.ts +2 -2
  2. package/dist/src/index.js +1 -1
  3. package/dist/src/index.js.map +1 -1
  4. package/dist/src/openclaw/bridges/discord.js +3 -2
  5. package/dist/src/openclaw/bridges/discord.js.map +1 -1
  6. package/dist/src/openclaw/bridges/matrix.js +3 -2
  7. package/dist/src/openclaw/bridges/matrix.js.map +1 -1
  8. package/dist/src/openclaw/bridges/mattermost.js +5 -9
  9. package/dist/src/openclaw/bridges/mattermost.js.map +1 -1
  10. package/dist/src/openclaw/bridges/signal.js +3 -2
  11. package/dist/src/openclaw/bridges/signal.js.map +1 -1
  12. package/dist/src/openclaw/bridges/slack.js +3 -2
  13. package/dist/src/openclaw/bridges/slack.js.map +1 -1
  14. package/dist/src/openclaw/bridges/telegram.js +5 -6
  15. package/dist/src/openclaw/bridges/telegram.js.map +1 -1
  16. package/dist/src/openclaw/bridges/whatsapp.js +24 -3
  17. package/dist/src/openclaw/bridges/whatsapp.js.map +1 -1
  18. package/dist/src/openclaw/bridges/zalo.js +3 -2
  19. package/dist/src/openclaw/bridges/zalo.js.map +1 -1
  20. package/dist/src/openclaw/private-file.js +16 -6
  21. package/dist/src/openclaw/private-file.js.map +1 -1
  22. package/dist/src/openclaw/shared.d.ts +31 -3
  23. package/dist/src/openclaw/shared.js +22 -3
  24. package/dist/src/openclaw/shared.js.map +1 -1
  25. package/dist/src/openclaw.d.ts +8 -2
  26. package/dist/src/openclaw.js +29 -11
  27. package/dist/src/openclaw.js.map +1 -1
  28. package/dist/src/servers/whatsapp-baileys-websocket.d.ts +15 -0
  29. package/dist/src/servers/whatsapp-baileys-websocket.js +31 -1
  30. package/dist/src/servers/whatsapp-baileys-websocket.js.map +1 -1
  31. package/dist/src/servers/whatsapp.js +178 -13
  32. package/dist/src/servers/whatsapp.js.map +1 -1
  33. package/docs/channel-setup.md +51 -0
  34. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"private-file.js","sourceRoot":"","sources":["../../../src/openclaw/private-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,YAAY,EAAoB,MAAM,SAAS,CAAC;AACnF,OAAO,EAAE,EAAE,EAAmB,MAAM,kBAAkB,CAAC;AACvD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACL,iCAAiC,IAAI,yCAAyC,EAC9E,uCAAuC,IAAI,+CAA+C,GAC3F,MAAM,4BAA4B,CAAC;AAEpC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAC1C,MAAM,8BAA8B,GAAG,MAAM,CAAC;AAE9C,MAAM,qCAAqC,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4MvD,CAAC;AAEF,MAAM,8CAA8C,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2ChE,CAAC;AAEF,MAAM,yCAAyC,GAAG,M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Y,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;YAC9E,MAAM,cAAc,GAAG,IAAI,cAAc,CACvC,CAAC,YAAY,EAAE,GAAG,aAAa,CAAC,EAChC,GAAG,cAAc,8CAA8C,CAChE,CAAC;YACF,cAAc,CAAC,KAAK,GAAG,YAAY,CAAC;YACpC,MAAM,WAAW,GACf,OAAO,YAAY,KAAK,QAAQ,IAAI,YAAY,KAAK,IAAI;gBACvD,CAAC,CAAE,YAAsC,CAAC,IAAI;gBAC9C,CAAC,CAAC,SAAS,CAAC;YAChB,IAAI,WAAW,EAAE,CAAC;gBAChB,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;YACvD,CAAC;YACD,MAAM,cAAc,CAAC;QACvB,CAAC;QACD,MAAM,YAAY,CAAC;IACrB,CAAC;IACD,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,MAAM,aAAa,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC;IACD,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,cAAc,CAAC,aAAa,EAAE,oDAAoD,CAAC,CAAC;IAChG,CAAC;AACH,CAAC","sourcesContent":["import { execFile, spawnSync } from \"node:child_process\";\nimport { createHash, randomUUID } from \"node:crypto\";\nimport { constants as fsConstants, readFileSync, type BigIntStats } from \"node:fs\";\nimport fs, { type FileHandle } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { performance } from \"node:perf_hooks\";\nimport { setTimeout as delay } from \"node:timers/promises\";\nimport { promisify } from \"node:util\";\nimport {\n applyOwnerOnlyWindowsDirectoryAcl as applyOwnerOnlyWindowsDirectoryAclByHandle,\n createOwnerOnlyWindowsDirectoryAncestry as createOwnerOnlyWindowsDirectoryAncestryByHandle,\n} from \"../platform/windows-acl.js\";\n\nconst execFileAsync = promisify(execFile);\nconst WINDOWS_ACL_COMMAND_TIMEOUT_MS = 15_000;\n\nconst WINDOWS_CREATE_OWNER_ONLY_FILE_SCRIPT = String.raw`\n$ErrorActionPreference = \"Stop\"\n$filePath = $env:CRABLINE_PRIVATE_FILE_PATH\nif ([string]::IsNullOrWhiteSpace($filePath)) {\n throw \"CRABLINE_PRIVATE_FILE_PATH is required.\"\n}\n\nAdd-Type -TypeDefinition @\"\nusing System;\nusing System.ComponentModel;\nusing System.Runtime.InteropServices;\nusing Microsoft.Win32.SafeHandles;\n\npublic static class CrablinePrivateFileIdentity\n{\n private const int FileInternalInformationClass = 6;\n private const int FileFsVolumeInformationClass = 1;\n private const int FileDispositionInfoClass = 4;\n\n [StructLayout(LayoutKind.Sequential)]\n private struct IoStatusBlock\n {\n public IntPtr Status;\n public UIntPtr Information;\n }\n\n [StructLayout(LayoutKind.Sequential)]\n private struct FileInternalInformation\n {\n public long IndexNumber;\n }\n\n [StructLayout(LayoutKind.Sequential)]\n private struct FileDispositionInfo\n {\n [MarshalAs(UnmanagedType.Bool)]\n public bool DeleteFile;\n }\n\n [DllImport(\"ntdll.dll\")]\n private static extern int NtQueryInformationFile(\n SafeFileHandle file,\n out IoStatusBlock ioStatus,\n out FileInternalInformation fileInformation,\n uint length,\n int fileInformationClass\n );\n\n [DllImport(\"ntdll.dll\")]\n private static extern int NtQueryVolumeInformationFile(\n SafeFileHandle file,\n out IoStatusBlock ioStatus,\n [Out] byte[] volumeInformation,\n uint length,\n int volumeInformationClass\n );\n\n [DllImport(\"kernel32.dll\", SetLastError = true)]\n [return: MarshalAs(UnmanagedType.Bool)]\n private static extern bool SetFileInformationByHandle(\n SafeFileHandle file,\n int informationClass,\n ref FileDispositionInfo information,\n uint bufferSize\n );\n\n [DllImport(\"ntdll.dll\")]\n private static extern uint RtlNtStatusToDosError(int status);\n\n private static void ThrowIfFailed(int status)\n {\n if (status != 0) {\n throw new Win32Exception(\n unchecked((int)RtlNtStatusToDosError(status))\n );\n }\n }\n\n public static string Read(SafeFileHandle file)\n {\n IoStatusBlock ioStatus;\n FileInternalInformation fileInfo;\n int status = NtQueryInformationFile(\n file,\n out ioStatus,\n out fileInfo,\n (uint)Marshal.SizeOf(typeof(FileInternalInformation)),\n FileInternalInformationClass\n );\n ThrowIfFailed(status);\n\n byte[] volumeInfo = new byte[1024];\n status = NtQueryVolumeInformationFile(\n file,\n out ioStatus,\n volumeInfo,\n (uint)volumeInfo.Length,\n FileFsVolumeInformationClass\n );\n ThrowIfFailed(status);\n\n uint device = BitConverter.ToUInt32(volumeInfo, 8);\n ulong inode = unchecked((ulong)fileInfo.IndexNumber);\n return device.ToString(\n System.Globalization.CultureInfo.InvariantCulture\n ) + \":\" + inode.ToString(\n System.Globalization.CultureInfo.InvariantCulture\n );\n }\n\n public static void MarkDelete(SafeFileHandle file)\n {\n FileDispositionInfo disposition = new FileDispositionInfo {\n DeleteFile = true\n };\n if (!SetFileInformationByHandle(\n file,\n FileDispositionInfoClass,\n ref disposition,\n (uint)Marshal.SizeOf(typeof(FileDispositionInfo))\n )) {\n throw new Win32Exception(Marshal.GetLastWin32Error());\n }\n }\n}\n\"@\n\n$identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()\n$sid = $identity.User\nif ($null -eq $sid) {\n throw \"Could not resolve the current Windows user SID.\"\n}\n\n$acl = [System.Security.AccessControl.FileSecurity]::new()\n$acl.SetOwner($sid)\n$acl.SetAccessRuleProtection($true, $false)\n$rule = [System.Security.AccessControl.FileSystemAccessRule]::new(\n $sid,\n [System.Security.AccessControl.FileSystemRights]::FullControl,\n [System.Security.AccessControl.AccessControlType]::Allow\n)\n$acl.SetAccessRule($rule)\n\n$rights = (\n [System.Security.AccessControl.FileSystemRights]::Read -bor\n [System.Security.AccessControl.FileSystemRights]::Write -bor\n [System.Security.AccessControl.FileSystemRights]::ReadPermissions -bor\n [System.Security.AccessControl.FileSystemRights]::Delete\n)\n$stream = [System.IO.FileStream]::new(\n $filePath,\n [System.IO.FileMode]::CreateNew,\n $rights,\n [System.IO.FileShare]::ReadWrite,\n 4096,\n [System.IO.FileOptions]::None,\n $acl\n)\ntry {\n $actual = $stream.GetAccessControl()\n $ownerSid = $actual.GetOwner([System.Security.Principal.SecurityIdentifier])\n $rules = @($actual.GetAccessRules(\n $true,\n $true,\n [System.Security.Principal.SecurityIdentifier]\n ))\n if (-not $actual.AreAccessRulesProtected) {\n throw \"Private file DACL still inherits permissions.\"\n }\n if ($ownerSid.Value -ne $sid.Value) {\n throw \"Private file owner SID does not match the current user.\"\n }\n if ($rules.Count -ne 1) {\n throw \"Private file DACL must contain exactly one access rule.\"\n }\n $actualRule = $rules[0]\n if (\n $actualRule.IsInherited -or\n $actualRule.IdentityReference.Value -ne $sid.Value -or\n $actualRule.AccessControlType -ne [System.Security.AccessControl.AccessControlType]::Allow -or\n (($actualRule.FileSystemRights -band [System.Security.AccessControl.FileSystemRights]::FullControl) -ne [System.Security.AccessControl.FileSystemRights]::FullControl)\n ) {\n throw \"Private file DACL is not owner-only full control.\"\n }\n [Console]::Out.Write(\n [CrablinePrivateFileIdentity]::Read($stream.SafeFileHandle)\n )\n} catch {\n $primaryError = $_.Exception\n try {\n [CrablinePrivateFileIdentity]::MarkDelete($stream.SafeFileHandle)\n } catch {\n $aggregateErrors = [System.Collections.Generic.List[System.Exception]]::new()\n $aggregateErrors.Add($primaryError)\n $aggregateErrors.Add($_.Exception)\n throw [System.AggregateException]::new(\n \"Private file creation and handle-bound cleanup failed.\",\n $aggregateErrors\n )\n }\n throw $primaryError\n} finally {\n $stream.Dispose()\n}\n`;\n\nconst WINDOWS_VERIFY_OWNER_ONLY_DIRECTORY_ACL_SCRIPT = String.raw`\n$ErrorActionPreference = \"Stop\"\n$directoryPath = $env:CRABLINE_PRIVATE_DIRECTORY_PATH\nif ([string]::IsNullOrWhiteSpace($directoryPath)) {\n throw \"CRABLINE_PRIVATE_DIRECTORY_PATH is required.\"\n}\n\n$identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()\n$sid = $identity.User\nif ($null -eq $sid) {\n throw \"Could not resolve the current Windows user SID.\"\n}\n\n$actual = Get-Acl -LiteralPath $directoryPath\n$ownerSid = $actual.GetOwner([System.Security.Principal.SecurityIdentifier])\n$rules = @($actual.GetAccessRules(\n $true,\n $true,\n [System.Security.Principal.SecurityIdentifier]\n))\n$requiredInheritance = (\n [System.Security.AccessControl.InheritanceFlags]::ContainerInherit -bor\n [System.Security.AccessControl.InheritanceFlags]::ObjectInherit\n)\nif (-not $actual.AreAccessRulesProtected) {\n throw \"Private directory DACL still inherits permissions.\"\n}\nif ($ownerSid.Value -ne $sid.Value) {\n throw \"Private directory owner SID does not match the current user.\"\n}\nif ($rules.Count -ne 1) {\n throw \"Private directory DACL must contain exactly one access rule.\"\n}\n$actualRule = $rules[0]\nif (\n $actualRule.IsInherited -or\n $actualRule.IdentityReference.Value -ne $sid.Value -or\n $actualRule.AccessControlType -ne [System.Security.AccessControl.AccessControlType]::Allow -or\n (($actualRule.FileSystemRights -band [System.Security.AccessControl.FileSystemRights]::FullControl) -ne [System.Security.AccessControl.FileSystemRights]::FullControl) -or\n (($actualRule.InheritanceFlags -band $requiredInheritance) -ne $requiredInheritance)\n) {\n throw \"Private directory DACL is not owner-only inheritable full control.\"\n}\n`;\n\nconst WINDOWS_VERIFY_OWNER_ONLY_FILE_ACL_SCRIPT = String.raw`\n$ErrorActionPreference = \"Stop\"\n$filePath = $env:CRABLINE_PRIVATE_FILE_PATH\nif ([string]::IsNullOrWhiteSpace($filePath)) {\n throw \"CRABLINE_PRIVATE_FILE_PATH is required.\"\n}\n\n$identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()\n$sid = $identity.User\nif ($null -eq $sid) {\n throw \"Could not resolve the current Windows user SID.\"\n}\n\n$actual = Get-Acl -LiteralPath $filePath\n$ownerSid = $actual.GetOwner([System.Security.Principal.SecurityIdentifier])\n$rules = @($actual.GetAccessRules(\n $true,\n $true,\n [System.Security.Principal.SecurityIdentifier]\n))\nif (-not $actual.AreAccessRulesProtected) {\n throw \"Private file DACL still inherits permissions.\"\n}\nif ($ownerSid.Value -ne $sid.Value) {\n throw \"Private file owner SID does not match the current user.\"\n}\nif ($rules.Count -ne 1) {\n throw \"Private file DACL must contain exactly one access rule.\"\n}\n$actualRule = $rules[0]\nif (\n $actualRule.IsInherited -or\n $actualRule.IdentityReference.Value -ne $sid.Value -or\n $actualRule.AccessControlType -ne [System.Security.AccessControl.AccessControlType]::Allow -or\n (($actualRule.FileSystemRights -band [System.Security.AccessControl.FileSystemRights]::FullControl) -ne [System.Security.AccessControl.FileSystemRights]::FullControl)\n) {\n throw \"Private file DACL is not owner-only full control.\"\n}\n`;\n\nconst WINDOWS_VERIFY_SAFE_DIRECTORY_ENTRY_PARENT_SCRIPT = String.raw`\n$ErrorActionPreference = \"Stop\"\n$directoryPath = $env:CRABLINE_PRIVATE_DIRECTORY_PATH\nif ([string]::IsNullOrWhiteSpace($directoryPath)) {\n throw \"CRABLINE_PRIVATE_DIRECTORY_PATH is required.\"\n}\n\n$identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()\n$sid = $identity.User\nif ($null -eq $sid) {\n throw \"Could not resolve the current Windows user SID.\"\n}\n\n$trustedSids = @(\n $sid.Value,\n \"S-1-5-18\",\n \"S-1-5-32-544\",\n \"S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464\"\n)\n$ancestorReplacementRights = (\n [System.Security.AccessControl.FileSystemRights]::DeleteSubdirectoriesAndFiles -bor\n [System.Security.AccessControl.FileSystemRights]::Delete -bor\n [System.Security.AccessControl.FileSystemRights]::ChangePermissions -bor\n [System.Security.AccessControl.FileSystemRights]::TakeOwnership\n)\n$ancestorReplacementMask = [BitConverter]::ToUInt32(\n [BitConverter]::GetBytes([int32]$ancestorReplacementRights),\n 0\n)\n$genericAll = [uint32]0x10000000\n$inheritOnly = [System.Security.AccessControl.PropagationFlags]::InheritOnly\n\n$actual = Get-Acl -LiteralPath $directoryPath\n$rawDescriptor = [System.Security.AccessControl.RawSecurityDescriptor]::new(\n $actual.GetSecurityDescriptorBinaryForm(),\n 0\n)\nif (\n (($rawDescriptor.ControlFlags -band\n [System.Security.AccessControl.ControlFlags]::DiscretionaryAclPresent) -eq 0) -or\n $null -eq $rawDescriptor.DiscretionaryAcl\n) {\n throw \"Directory has an absent or null DACL in private mutation ancestry.\"\n}\n$ownerSid = $actual.GetOwner([System.Security.Principal.SecurityIdentifier])\nif ($trustedSids -notcontains $ownerSid.Value) {\n throw \"Directory owner is not trusted for private mutation ancestry.\"\n}\n$rules = @($actual.GetAccessRules(\n $true,\n $true,\n [System.Security.Principal.SecurityIdentifier]\n))\nforeach ($rule in $rules) {\n $ruleAccessMask = [BitConverter]::ToUInt32(\n [BitConverter]::GetBytes([int32]$rule.FileSystemRights),\n 0\n )\n $appliesToDirectory = ($rule.PropagationFlags -band $inheritOnly) -eq 0\n if (\n $appliesToDirectory -and\n $rule.AccessControlType -eq [System.Security.AccessControl.AccessControlType]::Allow -and\n $trustedSids -notcontains $rule.IdentityReference.Value -and\n ($ruleAccessMask -band ($ancestorReplacementMask -bor $genericAll)) -ne 0\n ) {\n throw \"Directory grants child-deletion rights to an untrusted principal.\"\n }\n}\n`;\n\nconst WINDOWS_VERIFY_SAFE_DIRECTORY_MUTATION_BOUNDARY_SCRIPT = String.raw`\n$ErrorActionPreference = \"Stop\"\n$directoryPath = $env:CRABLINE_PRIVATE_DIRECTORY_PATH\nif ([string]::IsNullOrWhiteSpace($directoryPath)) {\n throw \"CRABLINE_PRIVATE_DIRECTORY_PATH is required.\"\n}\n\n$identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()\n$sid = $identity.User\nif ($null -eq $sid) {\n throw \"Could not resolve the current Windows user SID.\"\n}\n\n$trustedSids = @(\n $sid.Value,\n \"S-1-5-18\",\n \"S-1-5-32-544\",\n \"S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464\"\n)\n$mutationRights = (\n [System.Security.AccessControl.FileSystemRights]::WriteData -bor\n [System.Security.AccessControl.FileSystemRights]::AppendData -bor\n [System.Security.AccessControl.FileSystemRights]::WriteExtendedAttributes -bor\n [System.Security.AccessControl.FileSystemRights]::WriteAttributes -bor\n [System.Security.AccessControl.FileSystemRights]::Delete -bor\n [System.Security.AccessControl.FileSystemRights]::DeleteSubdirectoriesAndFiles -bor\n [System.Security.AccessControl.FileSystemRights]::ChangePermissions -bor\n [System.Security.AccessControl.FileSystemRights]::TakeOwnership\n)\n$genericMutationRights = [uint32]0x50000000\n$inheritOnly = [System.Security.AccessControl.PropagationFlags]::InheritOnly\n$mutationAccessMask = [BitConverter]::ToUInt32(\n [BitConverter]::GetBytes([int32]$mutationRights),\n 0\n)\n\n$actual = Get-Acl -LiteralPath $directoryPath\n$rawDescriptor = [System.Security.AccessControl.RawSecurityDescriptor]::new(\n $actual.GetSecurityDescriptorBinaryForm(),\n 0\n)\nif (\n (($rawDescriptor.ControlFlags -band\n [System.Security.AccessControl.ControlFlags]::DiscretionaryAclPresent) -eq 0) -or\n $null -eq $rawDescriptor.DiscretionaryAcl\n) {\n throw \"Directory has an absent or null DACL in private mutation ancestry.\"\n}\n$ownerSid = $actual.GetOwner([System.Security.Principal.SecurityIdentifier])\nif ($trustedSids -notcontains $ownerSid.Value) {\n throw \"Directory owner is not trusted for private mutation ancestry.\"\n}\n$rules = @($actual.GetAccessRules(\n $true,\n $true,\n [System.Security.Principal.SecurityIdentifier]\n))\nforeach ($rule in $rules) {\n $ruleAccessMask = [BitConverter]::ToUInt32(\n [BitConverter]::GetBytes([int32]$rule.FileSystemRights),\n 0\n )\n $appliesToDirectory = ($rule.PropagationFlags -band $inheritOnly) -eq 0\n if (\n $appliesToDirectory -and\n $rule.AccessControlType -eq [System.Security.AccessControl.AccessControlType]::Allow -and\n $trustedSids -notcontains $rule.IdentityReference.Value -and\n ($ruleAccessMask -band ($mutationAccessMask -bor $genericMutationRights)) -ne 0\n ) {\n throw \"Directory grants mutation rights to an untrusted principal.\"\n }\n}\n`;\n\nexport type WindowsAclRunner = (\n command: string,\n args: string[],\n options: {\n env: NodeJS.ProcessEnv;\n killSignal: NodeJS.Signals;\n timeout: number;\n windowsHide: boolean;\n },\n) => Promise<string>;\n\nconst runWindowsAclCommand: WindowsAclRunner = async (command, args, options) => {\n const result = await execFileAsync(command, args, { ...options, encoding: \"utf8\" });\n return result.stdout;\n};\n\nexport function resolveWindowsPowerShellPath(systemRoot: string | null | undefined): string {\n const normalizedRoot = systemRoot?.trim() ? path.win32.normalize(systemRoot.trim()) : undefined;\n if (!normalizedRoot || !/^[A-Za-z]:\\\\/.test(normalizedRoot)) {\n throw new Error(\"SystemRoot must be an absolute local Windows path.\");\n }\n return path.win32.join(normalizedRoot, \"System32\", \"WindowsPowerShell\", \"v1.0\", \"powershell.exe\");\n}\n\nexport async function createOwnerOnlyWindowsFile(\n filePath: string,\n run: WindowsAclRunner = runWindowsAclCommand,\n systemRoot: string | null | undefined = process.env.SystemRoot,\n): Promise<FileIdentity> {\n try {\n const powershellPath = resolveWindowsPowerShellPath(systemRoot);\n const output = await run(\n powershellPath,\n [\n \"-NoLogo\",\n \"-NoProfile\",\n \"-NonInteractive\",\n \"-Command\",\n WINDOWS_CREATE_OWNER_ONLY_FILE_SCRIPT,\n ],\n {\n env: {\n ...process.env,\n CRABLINE_PRIVATE_FILE_PATH: path.resolve(filePath),\n },\n killSignal: \"SIGKILL\",\n timeout: WINDOWS_ACL_COMMAND_TIMEOUT_MS,\n windowsHide: true,\n },\n );\n const match = /^(\\d+):(\\d+)$/u.exec(output.trim());\n if (!match) {\n throw new Error(\"Windows did not return a stable private file identity.\");\n }\n const identity = {\n device: BigInt(match[1]!),\n inode: BigInt(match[2]!),\n };\n if (identity.inode <= 0n) {\n throw new Error(\"Windows did not return a stable private file identity.\");\n }\n return identity;\n } catch (error) {\n throw new Error(\n \"Could not atomically create and verify an owner-only Windows private file; Windows PowerShell ACL support is required.\",\n { cause: error },\n );\n }\n}\n\nexport async function applyOwnerOnlyWindowsDirectoryAcl(\n directoryPath: string,\n run: WindowsAclRunner = runWindowsAclCommand,\n systemRoot: string | null | undefined = process.env.SystemRoot,\n): Promise<void> {\n await applyOwnerOnlyWindowsDirectoryAclByHandle(directoryPath, run, systemRoot);\n}\n\nexport async function createOwnerOnlyWindowsDirectoryAncestry(\n directoryPath: string,\n run: WindowsAclRunner = runWindowsAclCommand,\n systemRoot: string | null | undefined = process.env.SystemRoot,\n): Promise<string | undefined> {\n try {\n return await createOwnerOnlyWindowsDirectoryAncestryByHandle(directoryPath, run, systemRoot);\n } catch (error) {\n throw new Error(\n \"Could not atomically create and verify owner-only Windows private directory ancestry; Windows PowerShell security descriptor support is required.\",\n { cause: error },\n );\n }\n}\n\nexport async function verifyOwnerOnlyWindowsDirectoryAcl(\n directoryPath: string,\n run: WindowsAclRunner = runWindowsAclCommand,\n systemRoot: string | null | undefined = process.env.SystemRoot,\n): Promise<void> {\n try {\n const powershellPath = resolveWindowsPowerShellPath(systemRoot);\n await run(\n powershellPath,\n [\n \"-NoLogo\",\n \"-NoProfile\",\n \"-NonInteractive\",\n \"-Command\",\n WINDOWS_VERIFY_OWNER_ONLY_DIRECTORY_ACL_SCRIPT,\n ],\n {\n env: {\n ...process.env,\n CRABLINE_PRIVATE_DIRECTORY_PATH: path.resolve(directoryPath),\n },\n killSignal: \"SIGKILL\",\n timeout: WINDOWS_ACL_COMMAND_TIMEOUT_MS,\n windowsHide: true,\n },\n );\n } catch (error) {\n throw new Error(\"Private mutation parent must have an owner-only protected Windows ACL.\", {\n cause: error,\n });\n }\n}\n\nexport async function verifyOwnerOnlyWindowsFileAcl(\n filePath: string,\n run: WindowsAclRunner = runWindowsAclCommand,\n systemRoot: string | null | undefined = process.env.SystemRoot,\n): Promise<void> {\n try {\n const powershellPath = resolveWindowsPowerShellPath(systemRoot);\n await run(\n powershellPath,\n [\n \"-NoLogo\",\n \"-NoProfile\",\n \"-NonInteractive\",\n \"-Command\",\n WINDOWS_VERIFY_OWNER_ONLY_FILE_ACL_SCRIPT,\n ],\n {\n env: {\n ...process.env,\n CRABLINE_PRIVATE_FILE_PATH: path.resolve(filePath),\n },\n killSignal: \"SIGKILL\",\n timeout: WINDOWS_ACL_COMMAND_TIMEOUT_MS,\n windowsHide: true,\n },\n );\n } catch (error) {\n throw new Error(\"Private mutation claim must have an owner-only protected Windows ACL.\", {\n cause: error,\n });\n }\n}\n\nexport async function verifySafeWindowsDirectoryEntryParent(\n directoryPath: string,\n run: WindowsAclRunner = runWindowsAclCommand,\n systemRoot: string | null | undefined = process.env.SystemRoot,\n): Promise<void> {\n try {\n const powershellPath = resolveWindowsPowerShellPath(systemRoot);\n await run(\n powershellPath,\n [\n \"-NoLogo\",\n \"-NoProfile\",\n \"-NonInteractive\",\n \"-Command\",\n WINDOWS_VERIFY_SAFE_DIRECTORY_ENTRY_PARENT_SCRIPT,\n ],\n {\n env: {\n ...process.env,\n CRABLINE_PRIVATE_DIRECTORY_PATH: path.resolve(directoryPath),\n },\n killSignal: \"SIGKILL\",\n timeout: WINDOWS_ACL_COMMAND_TIMEOUT_MS,\n windowsHide: true,\n },\n );\n } catch (error) {\n throw new Error(\"Private mutation boundary has a replaceable Windows ancestor.\", {\n cause: error,\n });\n }\n}\n\nexport async function verifySafeWindowsDirectoryMutationBoundary(\n directoryPath: string,\n run: WindowsAclRunner = runWindowsAclCommand,\n systemRoot: string | null | undefined = process.env.SystemRoot,\n): Promise<void> {\n try {\n const powershellPath = resolveWindowsPowerShellPath(systemRoot);\n await run(\n powershellPath,\n [\n \"-NoLogo\",\n \"-NoProfile\",\n \"-NonInteractive\",\n \"-Command\",\n WINDOWS_VERIFY_SAFE_DIRECTORY_MUTATION_BOUNDARY_SCRIPT,\n ],\n {\n env: {\n ...process.env,\n CRABLINE_PRIVATE_DIRECTORY_PATH: path.resolve(directoryPath),\n },\n killSignal: \"SIGKILL\",\n timeout: WINDOWS_ACL_COMMAND_TIMEOUT_MS,\n windowsHide: true,\n },\n );\n } catch (error) {\n throw new Error(\"Private mutation ancestry has an unsafe Windows ACL.\", {\n cause: error,\n });\n }\n}\n\ntype FileIdentity = {\n device: bigint;\n inode: bigint;\n};\n\nfunction assertSameFileIdentity(actual: FileIdentity, expected: FileIdentity): void {\n if (actual.device !== expected.device || actual.inode !== expected.inode) {\n throw new Error(\"Private file path identity changed during publication.\");\n }\n}\n\nasync function readHandleIdentity(handle: FileHandle): Promise<FileIdentity> {\n const stats = await handle.stat({ bigint: true });\n if (stats.ino <= 0n) {\n throw new Error(\"The filesystem did not provide a stable private file identity.\");\n }\n return {\n device: stats.dev,\n inode: stats.ino,\n };\n}\n\nasync function assertPathIdentity(filePath: string, expected: FileIdentity): Promise<void> {\n try {\n const stats = await fs.lstat(filePath, { bigint: true });\n if (\n stats.isFile() &&\n stats.nlink === 1n &&\n stats.dev === expected.device &&\n stats.ino === expected.inode\n ) {\n return;\n }\n } catch (error) {\n throw new Error(\"Private file path identity changed during publication.\", { cause: error });\n }\n throw new Error(\"Private file path identity changed during publication.\");\n}\n\nasync function pathHasFileIdentity(filePath: string, expected: FileIdentity): Promise<boolean> {\n try {\n const stats = await fs.lstat(filePath, { bigint: true });\n return (\n stats.isFile() &&\n stats.nlink === 1n &&\n stats.dev === expected.device &&\n stats.ino === expected.inode\n );\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n return false;\n }\n throw error;\n }\n}\n\ntype DirectoryIdentity = {\n device: bigint;\n inode: bigint;\n userId: bigint;\n};\n\nasync function readDirectoryHandleIdentity(handle: FileHandle): Promise<DirectoryIdentity> {\n const stats = await handle.stat({ bigint: true });\n if (!stats.isDirectory() || stats.ino <= 0n) {\n throw new Error(\"The filesystem did not provide a stable private directory identity.\");\n }\n return {\n device: stats.dev,\n inode: stats.ino,\n userId: stats.uid,\n };\n}\n\nasync function assertDirectoryPathIdentity(\n directoryPath: string,\n expected: DirectoryIdentity,\n): Promise<void> {\n try {\n const stats = await fs.lstat(directoryPath, { bigint: true });\n if (stats.isDirectory() && stats.dev === expected.device && stats.ino === expected.inode) {\n return;\n }\n } catch (error) {\n throw new Error(\"Private directory path identity changed during publication.\", {\n cause: error,\n });\n }\n throw new Error(\"Private directory path identity changed during publication.\");\n}\n\nexport type SecuredPrivateDirectory = {\n assertIdentityAt(directoryPath?: string): Promise<void>;\n directoryPath: string;\n};\n\nexport async function captureDirectoryIdentity(\n directoryPath: string,\n): Promise<SecuredPrivateDirectory> {\n const handle = await fs.open(directoryPath, \"r\");\n try {\n const identity = await readDirectoryHandleIdentity(handle);\n const secured: SecuredPrivateDirectory = {\n async assertIdentityAt(currentPath = directoryPath) {\n await assertDirectoryPathIdentity(currentPath, identity);\n },\n directoryPath,\n };\n await secured.assertIdentityAt();\n return secured;\n } finally {\n await handle.close();\n }\n}\n\nexport async function syncParentDirectory(\n filePath: string,\n platform: NodeJS.Platform = process.platform,\n): Promise<void> {\n if (platform === \"win32\") {\n return;\n }\n const handle = await fs.open(path.dirname(filePath), \"r\");\n try {\n await handle.sync();\n } finally {\n await handle.close();\n }\n}\n\nasync function syncParentAtAccessibleBoundary(\n filePath: string,\n syncParent: (filePath: string, platform?: NodeJS.Platform) => Promise<void>,\n platform?: NodeJS.Platform,\n): Promise<boolean> {\n try {\n await syncParent(filePath, platform);\n return true;\n } catch (error) {\n const code = (error as NodeJS.ErrnoException).code;\n if (code === \"EACCES\" || code === \"EPERM\") {\n return false;\n }\n throw error;\n }\n}\n\nasync function syncPathAncestry(\n filePath: string,\n syncParent: (filePath: string, platform?: NodeJS.Platform) => Promise<void>,\n platform?: NodeJS.Platform,\n firstCreatedDirectory?: string,\n): Promise<void> {\n const resolvedFilePath = path.resolve(filePath);\n let currentPath = resolvedFilePath;\n const syncThroughPath =\n firstCreatedDirectory === undefined ? undefined : path.resolve(firstCreatedDirectory);\n for (;;) {\n const mandatory = syncThroughPath !== undefined || currentPath === resolvedFilePath;\n if (mandatory) {\n await syncParent(currentPath, platform);\n } else if (!(await syncParentAtAccessibleBoundary(currentPath, syncParent, platform))) {\n return;\n }\n if (currentPath === syncThroughPath) {\n return;\n }\n const parentPath = path.dirname(currentPath);\n if (path.dirname(parentPath) === parentPath) {\n return;\n }\n currentPath = parentPath;\n }\n}\n\nasync function darwinDirectoryHasExtendedAcl(directoryPath: string): Promise<boolean> {\n if (process.platform !== \"darwin\") {\n return false;\n }\n let output: string;\n try {\n const result = await execFileAsync(\"/bin/ls\", [\"-lde\", directoryPath], {\n encoding: \"utf8\",\n env: { ...process.env, LC_ALL: \"C\" },\n maxBuffer: 64 * 1024,\n });\n output = result.stdout;\n } catch (error) {\n throw new Error(\"Could not verify the private directory macOS ACL.\", { cause: error });\n }\n const mode = output.trimStart().split(/\\s+/u, 1)[0] ?? \"\";\n return mode.includes(\"+\");\n}\n\nasync function assertDarwinDirectoryHasNoExtendedAcl(directoryPath: string): Promise<void> {\n if (await darwinDirectoryHasExtendedAcl(directoryPath)) {\n throw new Error(\"Private directory must not have a macOS extended ACL.\");\n }\n}\n\nasync function removeDarwinExtendedAcl(directoryPath: string): Promise<void> {\n if (process.platform !== \"darwin\") {\n return;\n }\n try {\n await execFileAsync(\"/bin/chmod\", [\"-N\", directoryPath], {\n encoding: \"utf8\",\n env: { ...process.env, LC_ALL: \"C\" },\n maxBuffer: 64 * 1024,\n });\n } catch (error) {\n throw new Error(\"Could not remove the legacy private directory macOS ACL.\", {\n cause: error,\n });\n }\n}\n\nasync function nearestExistingDirectory(directoryPath: string): Promise<string> {\n let currentPath = path.resolve(directoryPath);\n for (;;) {\n try {\n const stats = await fs.lstat(currentPath);\n if (!stats.isDirectory()) {\n throw new Error(\"Private directory ancestry contains a non-directory entry.\");\n }\n return currentPath;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw error;\n }\n }\n const parentPath = path.dirname(currentPath);\n if (parentPath === currentPath) {\n throw new Error(\"Private directory ancestry has no existing parent.\");\n }\n currentPath = parentPath;\n }\n}\n\nasync function assertDarwinCreatedAncestryHasNoExtendedAcl(\n firstCreatedDirectory: string | undefined,\n finalDirectory: string,\n): Promise<void> {\n if (process.platform !== \"darwin\" || firstCreatedDirectory === undefined) {\n return;\n }\n const firstCreatedPath = path.resolve(firstCreatedDirectory);\n let currentPath = path.resolve(finalDirectory);\n const createdPaths: string[] = [];\n for (;;) {\n createdPaths.push(currentPath);\n if (currentPath === firstCreatedPath) {\n break;\n }\n const parentPath = path.dirname(currentPath);\n if (parentPath === currentPath) {\n throw new Error(\"Private directory ancestry creation boundary is invalid.\");\n }\n currentPath = parentPath;\n }\n for (const createdPath of createdPaths.reverse()) {\n await assertDarwinDirectoryHasNoExtendedAcl(createdPath);\n }\n}\n\nasync function captureSingleSafePrivateMutationBoundary(\n directoryPath: string,\n platform: NodeJS.Platform,\n stickyTargetOwnedByCurrentUser: boolean,\n): Promise<SecuredPrivateDirectory> {\n if (platform === \"win32\" && process.platform === \"win32\") {\n await verifySafeWindowsDirectoryMutationBoundary(directoryPath);\n return await captureDirectoryIdentity(directoryPath);\n }\n\n const currentUserId = process.geteuid?.();\n if (currentUserId === undefined || !Number.isSafeInteger(currentUserId) || currentUserId < 0) {\n throw new Error(\"Could not resolve the current POSIX user for private mutation.\");\n }\n const stats = await fs.lstat(directoryPath, { bigint: true });\n if (!stats.isDirectory()) {\n throw new Error(\"Private mutation boundary is not a directory.\");\n }\n const writableByAnotherPrincipal = (stats.mode & 0o022n) !== 0n;\n const trustedOwner = stats.uid === BigInt(currentUserId) || stats.uid === 0n;\n if (!trustedOwner) {\n throw new Error(\"Private mutation boundary is not owned by the current POSIX user or root.\");\n }\n const protectedByStickyOwnership =\n trustedOwner && (stats.mode & 0o1000n) !== 0n && stickyTargetOwnedByCurrentUser;\n if (writableByAnotherPrincipal && !protectedByStickyOwnership) {\n throw new Error(\"Private mutation boundary is writable by another POSIX principal.\");\n }\n await assertDarwinDirectoryHasNoExtendedAcl(directoryPath);\n return await captureDirectoryIdentity(directoryPath);\n}\n\nasync function captureSafePrivateMutationBoundary(\n directoryPath: string,\n platform: NodeJS.Platform,\n stickyTargetOwnedByCurrentUser: boolean,\n): Promise<SecuredPrivateDirectory> {\n const resolvedBoundaryPath = path.resolve(directoryPath);\n const boundary = await captureSingleSafePrivateMutationBoundary(\n resolvedBoundaryPath,\n platform,\n stickyTargetOwnedByCurrentUser,\n );\n return await capturePrivateMutationPathAncestry(resolvedBoundaryPath, platform, boundary);\n}\n\nasync function capturePrivateMutationPathAncestry(\n directoryPath: string,\n platform: NodeJS.Platform,\n boundary?: SecuredPrivateDirectory,\n): Promise<SecuredPrivateDirectory> {\n const resolvedBoundaryPath = path.resolve(directoryPath);\n const capturedBoundary = boundary ?? (await captureDirectoryIdentity(resolvedBoundaryPath));\n const ancestors: SecuredPrivateDirectory[] = [];\n let childPath = await fs.realpath(resolvedBoundaryPath);\n for (;;) {\n const parentPath = path.dirname(childPath);\n if (parentPath === childPath) {\n break;\n }\n if (platform === \"win32\" && process.platform === \"win32\") {\n await verifySafeWindowsDirectoryEntryParent(parentPath);\n ancestors.push(await captureDirectoryIdentity(parentPath));\n } else {\n const childStats = await fs.lstat(childPath, { bigint: true });\n const currentUserId = process.geteuid?.();\n const childOwnedByTrustedPrincipal =\n currentUserId !== undefined &&\n (childStats.uid === BigInt(currentUserId) || childStats.uid === 0n);\n ancestors.push(\n await captureSingleSafePrivateMutationBoundary(\n parentPath,\n platform,\n childOwnedByTrustedPrincipal,\n ),\n );\n }\n childPath = parentPath;\n }\n return {\n async assertIdentityAt(currentPath = resolvedBoundaryPath) {\n for (const ancestor of [...ancestors].reverse()) {\n await ancestor.assertIdentityAt();\n }\n await capturedBoundary.assertIdentityAt(currentPath);\n },\n directoryPath: resolvedBoundaryPath,\n };\n}\n\nasync function captureSafePrivateDirectoryMutationParent(\n currentPath: string,\n platform: NodeJS.Platform,\n): Promise<SecuredPrivateDirectory> {\n if (platform === \"win32\" && process.platform === \"win32\") {\n return await captureSafePrivateMutationBoundary(path.dirname(currentPath), platform, true);\n }\n const currentUserId = process.geteuid?.();\n const targetStats = await fs.lstat(currentPath, { bigint: true });\n return await captureSafePrivateMutationBoundary(\n path.dirname(currentPath),\n platform,\n currentUserId !== undefined &&\n targetStats.isDirectory() &&\n targetStats.uid === BigInt(currentUserId),\n );\n}\n\nexport async function removeSecuredPrivateDirectory(\n secured: SecuredPrivateDirectory,\n currentPath = secured.directoryPath,\n quarantineBaseName = path.basename(currentPath),\n options: {\n beforeRecursiveRemove?: (quarantinePath: string) => Promise<void>;\n beforeRename?: (currentPath: string) => Promise<void>;\n claimRuntime?: PrivateMutationClaimRuntime;\n createWindowsFile?: (filePath: string) => Promise<FileIdentity>;\n platform?: NodeJS.Platform;\n removeDirectory?: (quarantinePath: string) => Promise<void>;\n syncParent?: (filePath: string, platform?: NodeJS.Platform) => Promise<void>;\n } = {},\n): Promise<void> {\n if (path.basename(quarantineBaseName) !== quarantineBaseName || quarantineBaseName.length === 0) {\n throw new Error(\"Private directory quarantine basename is malformed.\");\n }\n const quarantinePath = path.join(\n path.dirname(currentPath),\n `.${quarantineBaseName}.${process.pid}.${randomUUID()}.remove`,\n );\n const platform = options.platform ?? process.platform;\n const parent = await captureSafePrivateDirectoryMutationParent(currentPath, platform);\n const claimParent: SecuredPrivateDirectory = {\n assertIdentityAt: (candidatePath = currentPath) => secured.assertIdentityAt(candidatePath),\n directoryPath: currentPath,\n };\n const claim = await acquirePrivateMutationClaimChain(claimParent, {\n ...(options.claimRuntime ? { runtime: options.claimRuntime } : {}),\n ...(options.createWindowsFile ? { createWindowsFile: options.createWindowsFile } : {}),\n ...(options.platform ? { platform: options.platform } : {}),\n });\n let removalFailed = false;\n let primaryError: unknown;\n try {\n await parent.assertIdentityAt();\n await claim.assertOwned();\n await secured.assertIdentityAt(currentPath);\n await options.beforeRename?.(currentPath);\n await parent.assertIdentityAt();\n await claim.assertOwned();\n await secured.assertIdentityAt(currentPath);\n await fs.rename(currentPath, quarantinePath);\n await parent.assertIdentityAt();\n await secured.assertIdentityAt(quarantinePath);\n await claim.relocateParent(quarantinePath);\n await claim.assertOwned();\n const syncParent = options.syncParent ?? syncParentDirectory;\n await syncParent(quarantinePath, options.platform);\n await options.beforeRecursiveRemove?.(quarantinePath);\n await parent.assertIdentityAt();\n await claim.assertOwned();\n await secured.assertIdentityAt(quarantinePath);\n await claim.prepareContainerRemoval();\n await (\n options.removeDirectory ??\n ((candidatePath: string) => fs.rm(candidatePath, { force: true, recursive: true }))\n )(quarantinePath);\n await claim.completeContainerRemoval();\n await parent.assertIdentityAt();\n await syncParent(quarantinePath, options.platform);\n } catch (error) {\n removalFailed = true;\n primaryError = error;\n }\n\n try {\n await claim.release();\n } catch (releaseError) {\n if (removalFailed) {\n const aggregateError = new AggregateError(\n [primaryError, releaseError],\n \"Private directory removal failed and its mutation claim could not be released.\",\n );\n aggregateError.cause = primaryError;\n throw aggregateError;\n }\n throw releaseError;\n }\n if (removalFailed) {\n throw primaryError;\n }\n}\n\nexport async function securePrivateDirectory(\n directoryPath: string,\n options: {\n createWindowsDirectories?: (directoryPath: string) => Promise<string | undefined>;\n currentUserId?: number;\n markMutationRoot?: boolean;\n platform?: NodeJS.Platform;\n secureWindowsDirectory?: (directoryPath: string) => Promise<void>;\n syncDirectory?: () => Promise<void>;\n syncParent?: (filePath: string, platform?: NodeJS.Platform) => Promise<void>;\n } = {},\n): Promise<SecuredPrivateDirectory> {\n const platform = options.platform ?? process.platform;\n let created = false;\n let createdAtomically = false;\n if (platform === \"win32\") {\n try {\n await fs.lstat(directoryPath);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw error;\n }\n const createWindowsDirectories =\n options.createWindowsDirectories ??\n (process.platform === \"win32\" || options.secureWindowsDirectory === undefined\n ? createOwnerOnlyWindowsDirectoryAncestry\n : async (candidatePath: string) => {\n await fs.mkdir(candidatePath);\n return candidatePath;\n });\n const firstCreatedDirectory = await createWindowsDirectories(directoryPath);\n if (firstCreatedDirectory === undefined) {\n throw new Error(\"Windows private directory creation did not create the requested path.\", {\n cause: error,\n });\n }\n created = true;\n createdAtomically =\n options.createWindowsDirectories !== undefined || process.platform === \"win32\";\n }\n } else {\n let existed = false;\n try {\n await fs.lstat(directoryPath);\n existed = true;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw error;\n }\n }\n if (!existed) {\n await assertDarwinDirectoryHasNoExtendedAcl(path.dirname(directoryPath));\n }\n try {\n await fs.mkdir(directoryPath, { mode: 0o700 });\n created = true;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") {\n throw error;\n }\n }\n }\n\n const handle = await fs.open(directoryPath, \"r\");\n let handleOpen = true;\n const closeHandle = async () => {\n if (!handleOpen) {\n return;\n }\n handleOpen = false;\n await handle.close();\n };\n let identity: DirectoryIdentity;\n try {\n identity = await readDirectoryHandleIdentity(handle);\n } catch (error) {\n try {\n await closeHandle();\n } catch (closeError) {\n const aggregateError = new AggregateError(\n [error, closeError],\n \"Private directory identity verification failed and its handle could not be closed.\",\n );\n aggregateError.cause = error;\n throw aggregateError;\n }\n throw error;\n }\n const secured: SecuredPrivateDirectory = {\n async assertIdentityAt(currentPath = directoryPath) {\n await assertDirectoryPathIdentity(currentPath, identity);\n },\n directoryPath,\n };\n try {\n await secured.assertIdentityAt();\n if (platform === \"win32\") {\n if (!createdAtomically) {\n await (options.secureWindowsDirectory ?? applyOwnerOnlyWindowsDirectoryAcl)(directoryPath);\n }\n if (process.platform !== \"win32\") {\n await handle.chmod(0o700);\n }\n } else {\n const currentUserId = options.currentUserId ?? process.geteuid?.();\n if (\n currentUserId === undefined ||\n !Number.isSafeInteger(currentUserId) ||\n currentUserId < 0 ||\n identity.userId !== BigInt(currentUserId)\n ) {\n throw new Error(\"Private directory must be owned by the current POSIX user.\");\n }\n if (!created) {\n await removeDarwinExtendedAcl(directoryPath);\n }\n const currentStats = await handle.stat({ bigint: true });\n const mutationRootMode =\n options.markMutationRoot === false ? currentStats.mode & 0o1000n : 0o1000n;\n await handle.chmod(Number(0o700n | mutationRootMode));\n await assertDarwinDirectoryHasNoExtendedAcl(directoryPath);\n await (options.syncDirectory ?? (() => handle.sync()))();\n }\n await secured.assertIdentityAt();\n const syncParent = options.syncParent ?? syncParentDirectory;\n if (created) {\n await syncParent(directoryPath, options.platform);\n } else {\n await syncParentAtAccessibleBoundary(directoryPath, syncParent, options.platform);\n }\n } catch (error) {\n let primaryError = error;\n try {\n await closeHandle();\n } catch (closeError) {\n const aggregateError = new AggregateError(\n [error, closeError],\n \"Private directory securing failed and its verification handle could not be closed.\",\n );\n aggregateError.cause = error;\n primaryError = aggregateError;\n }\n if (created) {\n try {\n await removeSecuredPrivateDirectory(secured);\n } catch (cleanupError) {\n const aggregateError = new AggregateError(\n [primaryError, cleanupError],\n `Private directory securing failed and rollback cleanup also failed: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n aggregateError.cause = primaryError;\n throw aggregateError;\n }\n }\n throw primaryError;\n } finally {\n await closeHandle();\n }\n\n return secured;\n}\n\ntype PrivateMutationClaim = {\n assertOwned(): Promise<void>;\n completeContainerRemoval(): Promise<void>;\n prepareContainerRemoval(): Promise<void>;\n relocateParent(directoryPath: string): Promise<void>;\n release(): Promise<void>;\n};\n\ntype PrivateMutationClaimWaitOptions = {\n now?: () => number;\n retryDelayMs?: number;\n signal?: AbortSignal;\n sleep?: (delayMs: number, signal?: AbortSignal) => Promise<void>;\n timeoutMs?: number;\n};\n\ntype PreparedPrivateMutationClaimWait = {\n now: () => number;\n retryDelayMs: number;\n signal?: AbortSignal;\n sleep: (delayMs: number, signal?: AbortSignal) => Promise<void>;\n timeoutMs: number;\n};\n\nexport type PrivateMutationClaimRuntime = {\n getProcessIdentity(pid: number): string | null;\n isProcessAlive(pid: number): boolean;\n ownerId: string;\n pid: number;\n processIdentity?: string;\n processStartedAtMs: number;\n};\n\ntype PrivateMutationClaimOwner = {\n ownerId: string;\n pid: number;\n processIdentity?: string;\n processStartedAtMs: number;\n};\n\nconst PRIVATE_MUTATION_CLAIM_ROOT_FILE = \".crabline-private-mutation.claim\";\nconst PRIVATE_MUTATION_CLAIM_OWNER_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/u;\nconst PRIVATE_MUTATION_CLAIM_METADATA_MAX_BYTES = 4096;\nconst PRIVATE_MUTATION_RESERVED_BASENAME_PATTERN = /^\\.crabline-private-mutation(?:\\.|$)/iu;\nconst PRIVATE_MUTATION_CLAIM_WAIT_TIMEOUT_MS = 60_000;\nconst PRIVATE_MUTATION_CLAIM_RETRY_DELAY_MS = 50;\n\nfunction preparePrivateMutationClaimWait(\n options: PrivateMutationClaimWaitOptions,\n): PreparedPrivateMutationClaimWait {\n const timeoutMs = options.timeoutMs ?? PRIVATE_MUTATION_CLAIM_WAIT_TIMEOUT_MS;\n const retryDelayMs = options.retryDelayMs ?? PRIVATE_MUTATION_CLAIM_RETRY_DELAY_MS;\n if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 0) {\n throw new Error(\"Private mutation claim wait timeout must be a non-negative safe integer.\");\n }\n if (!Number.isSafeInteger(retryDelayMs) || retryDelayMs <= 0) {\n throw new Error(\"Private mutation claim retry delay must be a positive safe integer.\");\n }\n const now = options.now ?? performance.now.bind(performance);\n const sleep =\n options.sleep ??\n ((delayMs: number, signal?: AbortSignal) => delay(delayMs, undefined, { signal }));\n if (typeof now !== \"function\" || typeof sleep !== \"function\") {\n throw new Error(\"Private mutation claim wait callbacks must be functions.\");\n }\n if (options.signal !== undefined && typeof options.signal.throwIfAborted !== \"function\") {\n throw new Error(\"Private mutation claim wait signal is invalid.\");\n }\n options.signal?.throwIfAborted();\n if (!Number.isFinite(now())) {\n throw new Error(\"Private mutation claim wait clock is invalid.\");\n }\n return {\n now,\n retryDelayMs,\n ...(options.signal ? { signal: options.signal } : {}),\n sleep,\n timeoutMs,\n };\n}\n\nfunction assertNotReservedPrivateMutationPath(targetPath: string): void {\n if (PRIVATE_MUTATION_RESERVED_BASENAME_PATTERN.test(path.basename(targetPath))) {\n throw new Error(\"Private path uses Crabline's reserved mutation claim namespace.\");\n }\n}\n\nfunction isProcessAlive(pid: number): boolean {\n if (!Number.isSafeInteger(pid) || pid <= 0) {\n return false;\n }\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n return (error as NodeJS.ErrnoException).code === \"EPERM\";\n }\n}\n\nfunction processIdentityFromLinuxStat(value: string, bootId: string): string | null {\n const normalizedBootId = bootId.trim();\n if (!/^[0-9a-f-]{16,64}$/iu.test(normalizedBootId)) {\n return null;\n }\n const commandEnd = value.lastIndexOf(\") \");\n if (commandEnd < 0) {\n return null;\n }\n const fields = value\n .slice(commandEnd + 2)\n .trim()\n .split(/\\s+/u);\n const startTicks = fields[19];\n return startTicks && /^\\d+$/u.test(startTicks) ? `linux:${normalizedBootId}:${startTicks}` : null;\n}\n\nfunction processIdentityFromDarwin(processDetails: string, bootTime: string): string | null {\n const bootMatch = /\\bsec = (\\d+), usec = (\\d+)\\b/u.exec(bootTime);\n const launchMatch =\n /^Launch Time:\\s*(\\d{4})-(\\d{2})-(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2})\\.(\\d{3,6}) ([+-])(\\d{2})(\\d{2})$/mu.exec(\n processDetails,\n );\n if (!bootMatch || !launchMatch) {\n return null;\n }\n const [, year, month, day, hour, minute, second, fraction, sign, offsetHour, offsetMinute] =\n launchMatch as RegExpExecArray &\n [string, string, string, string, string, string, string, string, string, string, string];\n const offsetMs =\n (Number(offsetHour) * 60 + Number(offsetMinute)) * 60_000 * (sign === \"+\" ? 1 : -1);\n const fractionMicros = Number(fraction.padEnd(6, \"0\"));\n const utcMilliseconds =\n Date.UTC(\n Number(year),\n Number(month) - 1,\n Number(day),\n Number(hour),\n Number(minute),\n Number(second),\n Math.floor(fractionMicros / 1_000),\n ) - offsetMs;\n if (!Number.isSafeInteger(utcMilliseconds) || utcMilliseconds <= 0) {\n return null;\n }\n const startedAtMicros = BigInt(utcMilliseconds) * 1_000n + BigInt(fractionMicros % 1_000);\n return `darwin:${bootMatch[1]}.${bootMatch[2]}:us:${startedAtMicros}`;\n}\n\nfunction getProcessIdentity(pid: number): string | null {\n if (!Number.isSafeInteger(pid) || pid <= 0) {\n return null;\n }\n if (process.platform === \"linux\") {\n try {\n return processIdentityFromLinuxStat(\n readFileSync(`/proc/${pid}/stat`, \"utf8\"),\n readFileSync(\"/proc/sys/kernel/random/boot_id\", \"utf8\"),\n );\n } catch {\n return null;\n }\n }\n if (process.platform === \"darwin\") {\n const options = {\n encoding: \"utf8\" as const,\n env: { ...process.env, LC_ALL: \"C\", TZ: \"UTC\" },\n maxBuffer: 512 * 1024,\n timeout: 3_000,\n };\n const bootTime = spawnSync(\"/usr/sbin/sysctl\", [\"-n\", \"kern.boottime\"], options);\n const processDetails = spawnSync(\"/usr/bin/vmmap\", [\"-summary\", String(pid)], options);\n return bootTime.status === 0 && processDetails.status === 0\n ? processIdentityFromDarwin(processDetails.stdout, bootTime.stdout)\n : null;\n }\n if (process.platform !== \"win32\") {\n return null;\n }\n let powershellPath: string;\n try {\n powershellPath = resolveWindowsPowerShellPath(process.env.SystemRoot);\n } catch {\n return null;\n }\n const result = spawnSync(\n powershellPath,\n [\n \"-NoProfile\",\n \"-NonInteractive\",\n \"-Command\",\n `(Get-Process -Id ${pid} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks.ToString()`,\n ],\n { encoding: \"utf8\", timeout: 1_000, windowsHide: true },\n );\n const ticks = result.status === 0 ? result.stdout.trim() : \"\";\n return /^\\d+$/u.test(ticks) ? `windows:${ticks}` : null;\n}\n\nlet cachedCurrentProcessIdentity: string | null | undefined;\n\nfunction defaultPrivateMutationClaimRuntime(): PrivateMutationClaimRuntime {\n if (cachedCurrentProcessIdentity === undefined) {\n cachedCurrentProcessIdentity = getProcessIdentity(process.pid);\n }\n return {\n getProcessIdentity,\n isProcessAlive,\n ownerId: randomUUID(),\n pid: process.pid,\n ...(cachedCurrentProcessIdentity ? { processIdentity: cachedCurrentProcessIdentity } : {}),\n processStartedAtMs: Math.floor(performance.timeOrigin),\n };\n}\n\nfunction parsePrivateMutationClaimOwner(contents: string): PrivateMutationClaimOwner {\n let owner: Partial<PrivateMutationClaimOwner>;\n try {\n owner = JSON.parse(contents) as Partial<PrivateMutationClaimOwner>;\n } catch (error) {\n throw new Error(\"Private path mutation claim owner metadata is malformed.\", { cause: error });\n }\n if (\n !Number.isSafeInteger(owner.pid) ||\n Number(owner.pid) <= 0 ||\n typeof owner.ownerId !== \"string\" ||\n !PRIVATE_MUTATION_CLAIM_OWNER_ID_PATTERN.test(owner.ownerId) ||\n !Number.isSafeInteger(owner.processStartedAtMs) ||\n Number(owner.processStartedAtMs) <= 0 ||\n (owner.processIdentity !== undefined &&\n (typeof owner.processIdentity !== \"string\" ||\n owner.processIdentity.length === 0 ||\n owner.processIdentity.length > 256))\n ) {\n throw new Error(\"Private path mutation claim owner metadata is malformed.\");\n }\n return owner as PrivateMutationClaimOwner;\n}\n\nasync function assertClaimPathIdentity(\n claimPath: string,\n expected: FileIdentity,\n expectedLinkCount?: bigint,\n): Promise<void> {\n try {\n const stats = await fs.lstat(claimPath, { bigint: true });\n if (\n stats.isFile() &&\n (expectedLinkCount === undefined ? stats.nlink >= 1n : stats.nlink === expectedLinkCount) &&\n stats.dev === expected.device &&\n stats.ino === expected.inode\n ) {\n return;\n }\n } catch (error) {\n throw new Error(\"Private path mutation claim identity changed.\", { cause: error });\n }\n throw new Error(\"Private path mutation claim identity changed.\");\n}\n\ntype PrivateMutationClaimRecord = {\n contents: string;\n identity: FileIdentity;\n owner: PrivateMutationClaimOwner;\n};\n\nfunction assertOwnerOnlyPosixMutationClaim(stats: BigIntStats, kind: \"directory\" | \"file\"): void {\n const currentUserId = process.geteuid?.();\n if (currentUserId === undefined || !Number.isSafeInteger(currentUserId) || currentUserId < 0) {\n throw new Error(\"Could not resolve the current POSIX user for private mutation claims.\");\n }\n if (stats.uid !== BigInt(currentUserId) || (stats.mode & 0o077n) !== 0n) {\n throw new Error(`Private mutation claim ${kind} must be owner-only.`);\n }\n}\n\nasync function readPrivateMutationClaim(\n claimPath: string,\n): Promise<PrivateMutationClaimRecord | null> {\n let handle: FileHandle | undefined;\n try {\n handle = await fs.open(\n claimPath,\n process.platform === \"win32\"\n ? \"r\"\n : fsConstants.O_RDONLY | fsConstants.O_NONBLOCK | fsConstants.O_NOFOLLOW,\n );\n const stats = await handle.stat({ bigint: true });\n if (\n !stats.isFile() ||\n stats.ino <= 0n ||\n stats.size <= 0n ||\n stats.size > BigInt(PRIVATE_MUTATION_CLAIM_METADATA_MAX_BYTES)\n ) {\n throw new Error(\"Private path mutation claim metadata size is invalid.\");\n }\n if (process.platform === \"win32\") {\n await verifyOwnerOnlyWindowsFileAcl(claimPath);\n } else {\n assertOwnerOnlyPosixMutationClaim(stats, \"file\");\n }\n const identity = { device: stats.dev, inode: stats.ino };\n const buffer = Buffer.alloc(Number(stats.size));\n let offset = 0;\n while (offset < buffer.length) {\n const { bytesRead } = await handle.read(buffer, offset, buffer.length - offset, offset);\n if (bytesRead === 0) {\n throw new Error(\"Private path mutation claim metadata was truncated while reading.\");\n }\n offset += bytesRead;\n }\n const finalStats = await handle.stat({ bigint: true });\n if (process.platform === \"win32\") {\n await verifyOwnerOnlyWindowsFileAcl(claimPath);\n } else {\n assertOwnerOnlyPosixMutationClaim(finalStats, \"file\");\n }\n if (\n !finalStats.isFile() ||\n finalStats.dev !== stats.dev ||\n finalStats.ino !== stats.ino ||\n finalStats.size !== stats.size\n ) {\n throw new Error(\"Private path mutation claim metadata changed while reading.\");\n }\n const contents = buffer.toString(\"utf8\");\n const owner = parsePrivateMutationClaimOwner(contents);\n await assertClaimPathIdentity(claimPath, identity);\n return { contents, identity, owner };\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n return null;\n }\n throw error;\n } finally {\n await handle?.close();\n }\n}\n\nfunction nextPrivateMutationClaimPath(parentDirectory: string, ownerContents: string): string {\n const digest = createHash(\"sha256\").update(ownerContents).digest(\"hex\");\n return path.join(parentDirectory, `.crabline-private-mutation.${digest}.claim`);\n}\n\nasync function removeStalePrivateMutationClaimAliases(\n parentDirectory: string,\n staleClaims: Array<PrivateMutationClaimRecord & { claimPath: string }>,\n currentClaimPath: string,\n): Promise<void> {\n const staleIdentities = new Set(\n staleClaims.map(({ identity }) => `${identity.device}:${identity.inode}`),\n );\n for (const entry of await fs.readdir(parentDirectory)) {\n if (!PRIVATE_MUTATION_RESERVED_BASENAME_PATTERN.test(entry)) {\n continue;\n }\n const entryPath = path.join(parentDirectory, entry);\n if (entryPath === currentClaimPath) {\n continue;\n }\n let stats;\n try {\n stats = await fs.lstat(entryPath, { bigint: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n continue;\n }\n throw error;\n }\n if (stats.isFile() && staleIdentities.has(`${stats.dev}:${stats.ino}`)) {\n await fs.unlink(entryPath);\n }\n }\n}\n\nclass UnsupportedPrivateMutationHardLinkError extends Error {\n constructor(cause: unknown) {\n super(\"Private mutation claims require a non-hard-link fallback.\", { cause });\n }\n}\n\nclass ActivePrivateMutationClaimError extends Error {\n constructor(cause: unknown) {\n super(\"Private path mutation is already claimed.\", { cause });\n }\n}\n\nfunction isUnsupportedHardLinkError(error: unknown): boolean {\n const code = (error as NodeJS.ErrnoException).code;\n return code === \"EPERM\" || code === \"ENOTSUP\" || code === \"EOPNOTSUPP\" || code === \"ENOSYS\";\n}\n\nasync function acquireHardLinkPrivateMutationClaim(\n parent: SecuredPrivateDirectory,\n options: {\n createWindowsFile?: (filePath: string) => Promise<FileIdentity>;\n platform?: NodeJS.Platform;\n runtime?: PrivateMutationClaimRuntime;\n },\n): Promise<PrivateMutationClaim> {\n const platform = options.platform ?? process.platform;\n const runtime = options.runtime ?? defaultPrivateMutationClaimRuntime();\n if (\n !Number.isSafeInteger(runtime.pid) ||\n runtime.pid <= 0 ||\n !PRIVATE_MUTATION_CLAIM_OWNER_ID_PATTERN.test(runtime.ownerId) ||\n !Number.isSafeInteger(runtime.processStartedAtMs) ||\n runtime.processStartedAtMs <= 0 ||\n (runtime.processIdentity !== undefined &&\n (runtime.processIdentity.length === 0 || runtime.processIdentity.length > 256))\n ) {\n throw new Error(\"Private path mutation claim runtime is invalid.\");\n }\n if (\n !Number.isSafeInteger(runtime.pid) ||\n runtime.pid <= 0 ||\n !PRIVATE_MUTATION_CLAIM_OWNER_ID_PATTERN.test(runtime.ownerId) ||\n !Number.isSafeInteger(runtime.processStartedAtMs) ||\n runtime.processStartedAtMs <= 0 ||\n (runtime.processIdentity !== undefined &&\n (runtime.processIdentity.length === 0 || runtime.processIdentity.length > 256))\n ) {\n throw new Error(\"Private path mutation claim runtime is invalid.\");\n }\n const ownerContents = `${JSON.stringify({\n ownerId: runtime.ownerId,\n pid: runtime.pid,\n ...(runtime.processIdentity ? { processIdentity: runtime.processIdentity } : {}),\n processStartedAtMs: runtime.processStartedAtMs,\n } satisfies PrivateMutationClaimOwner)}\\n`;\n const rootClaimPath = path.join(parent.directoryPath, PRIVATE_MUTATION_CLAIM_ROOT_FILE);\n const candidatePath = `${rootClaimPath}.${runtime.pid}.${randomUUID()}.candidate`;\n let handle: FileHandle | undefined;\n let identity: FileIdentity | undefined;\n const linkedClaimPaths = new Set<string>();\n try {\n if (platform === \"win32\" && process.platform === \"win32\") {\n const createdIdentity = await (options.createWindowsFile ?? createOwnerOnlyWindowsFile)(\n candidatePath,\n );\n handle = await fs.open(candidatePath, \"r+\");\n identity = await readHandleIdentity(handle);\n assertSameFileIdentity(identity, createdIdentity);\n } else {\n handle = await fs.open(candidatePath, \"wx+\", 0o600);\n identity = await readHandleIdentity(handle);\n await handle.chmod(0o600);\n }\n await handle.writeFile(ownerContents, \"utf8\");\n await handle.sync();\n await assertClaimPathIdentity(candidatePath, identity, 1n);\n\n let claimPath = rootClaimPath;\n const visitedClaimPaths = new Set<string>();\n const staleClaims: Array<PrivateMutationClaimRecord & { claimPath: string }> = [];\n for (;;) {\n if (visitedClaimPaths.has(claimPath)) {\n throw new Error(\"Private path mutation claim chain contains a cycle.\");\n }\n visitedClaimPaths.add(claimPath);\n try {\n await fs.link(candidatePath, claimPath);\n linkedClaimPaths.add(claimPath);\n } catch (error) {\n if (isUnsupportedHardLinkError(error)) {\n throw new UnsupportedPrivateMutationHardLinkError(error);\n }\n if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") {\n throw error;\n }\n await parent.assertIdentityAt();\n const observed = await readPrivateMutationClaim(claimPath);\n if (observed === null) {\n claimPath = rootClaimPath;\n visitedClaimPaths.clear();\n staleClaims.length = 0;\n continue;\n }\n if (runtime.isProcessAlive(observed.owner.pid)) {\n if (\n observed.owner.pid === runtime.pid &&\n observed.owner.processStartedAtMs === runtime.processStartedAtMs\n ) {\n throw new ActivePrivateMutationClaimError(error);\n } else if (observed.owner.pid !== runtime.pid) {\n if (observed.owner.processIdentity === undefined) {\n throw new ActivePrivateMutationClaimError(error);\n }\n const actualIdentity = runtime.getProcessIdentity(observed.owner.pid);\n if (actualIdentity === null || actualIdentity === observed.owner.processIdentity) {\n throw new ActivePrivateMutationClaimError(error);\n }\n }\n }\n const revalidated = await readPrivateMutationClaim(claimPath);\n if (\n revalidated === null ||\n revalidated.identity.device !== observed.identity.device ||\n revalidated.identity.inode !== observed.identity.inode ||\n revalidated.contents !== observed.contents\n ) {\n claimPath = rootClaimPath;\n visitedClaimPaths.clear();\n staleClaims.length = 0;\n continue;\n }\n const duplicateIdentity = staleClaims.find(\n ({ identity: staleIdentity }) =>\n staleIdentity.device === revalidated.identity.device &&\n staleIdentity.inode === revalidated.identity.inode,\n );\n if (duplicateIdentity !== undefined) {\n await parent.assertIdentityAt();\n await assertClaimPathIdentity(claimPath, revalidated.identity);\n await fs.unlink(claimPath);\n await syncParentDirectory(claimPath, options.platform);\n claimPath = rootClaimPath;\n visitedClaimPaths.clear();\n staleClaims.length = 0;\n continue;\n }\n staleClaims.push({ claimPath, ...revalidated });\n claimPath = nextPrivateMutationClaimPath(parent.directoryPath, revalidated.contents);\n continue;\n }\n\n await assertClaimPathIdentity(candidatePath, identity, 2n);\n await assertClaimPathIdentity(claimPath, identity, 2n);\n if (staleClaims.length > 0) {\n const staleRoot = await readPrivateMutationClaim(rootClaimPath);\n const expectedRoot = staleClaims[0]!;\n if (\n staleRoot === null ||\n staleRoot.identity.device !== expectedRoot.identity.device ||\n staleRoot.identity.inode !== expectedRoot.identity.inode ||\n staleRoot.contents !== expectedRoot.contents\n ) {\n throw new Error(\"Private path mutation claim root changed during recovery.\");\n }\n await fs.rename(candidatePath, rootClaimPath);\n linkedClaimPaths.add(rootClaimPath);\n await assertClaimPathIdentity(rootClaimPath, identity, 2n);\n await assertClaimPathIdentity(claimPath, identity, 2n);\n await fs.unlink(claimPath);\n linkedClaimPaths.delete(claimPath);\n claimPath = rootClaimPath;\n await assertClaimPathIdentity(claimPath, identity, 1n);\n await removeStalePrivateMutationClaimAliases(parent.directoryPath, staleClaims, claimPath);\n } else {\n await fs.unlink(candidatePath);\n }\n await assertClaimPathIdentity(claimPath, identity, 1n);\n await parent.assertIdentityAt();\n await syncParentDirectory(claimPath, options.platform);\n linkedClaimPaths.clear();\n\n let released = false;\n const claimHandle = handle;\n let claimHandleOpen = true;\n let ownedClaimPath = claimPath;\n let ownedParentPath = parent.directoryPath;\n const claimIdentity = identity;\n const closeClaimHandle = async () => {\n if (!claimHandleOpen) {\n return;\n }\n claimHandleOpen = false;\n await claimHandle.close();\n };\n const assertOwned = async () => {\n await parent.assertIdentityAt(ownedParentPath);\n await assertClaimPathIdentity(ownedClaimPath, claimIdentity, 1n);\n const observed = await readPrivateMutationClaim(ownedClaimPath);\n if (\n observed === null ||\n observed.identity.device !== claimIdentity.device ||\n observed.identity.inode !== claimIdentity.inode ||\n observed.contents !== ownerContents\n ) {\n throw new Error(\"Private path mutation claim owner metadata changed.\");\n }\n };\n return {\n assertOwned,\n async completeContainerRemoval() {\n if (released) {\n return;\n }\n let completionError: unknown;\n try {\n await fs.lstat(ownedParentPath);\n completionError = new Error(\n \"Private directory path still exists after recursive removal.\",\n );\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n completionError = error;\n }\n }\n try {\n await closeClaimHandle();\n } catch (closeError) {\n if (completionError !== undefined) {\n const aggregateError = new AggregateError(\n [completionError, closeError],\n \"Private directory removal verification failed and its claim handle could not be closed.\",\n );\n aggregateError.cause = completionError;\n throw aggregateError;\n }\n throw closeError;\n }\n if (completionError !== undefined) {\n throw completionError;\n }\n released = true;\n },\n async prepareContainerRemoval() {\n if (released) {\n throw new Error(\"Private path mutation claim has already been released.\");\n }\n await assertOwned();\n await closeClaimHandle();\n await assertOwned();\n },\n async relocateParent(directoryPath: string) {\n if (released) {\n throw new Error(\"Private path mutation claim has already been released.\");\n }\n const relocatedClaimPath = path.join(directoryPath, path.basename(ownedClaimPath));\n await parent.assertIdentityAt(directoryPath);\n const observed = await readPrivateMutationClaim(relocatedClaimPath);\n if (\n observed === null ||\n observed.identity.device !== claimIdentity.device ||\n observed.identity.inode !== claimIdentity.inode ||\n observed.contents !== ownerContents\n ) {\n throw new Error(\"Private path mutation claim identity changed during relocation.\");\n }\n ownedParentPath = directoryPath;\n ownedClaimPath = relocatedClaimPath;\n },\n async release() {\n if (released) {\n return;\n }\n const releasePath = `${ownedClaimPath}.${randomUUID()}.release`;\n let releaseError: unknown;\n try {\n await assertOwned();\n await fs.rename(ownedClaimPath, releasePath);\n await assertClaimPathIdentity(releasePath, claimIdentity, 1n);\n if ((await fs.readFile(releasePath, \"utf8\")) !== ownerContents) {\n throw new Error(\"Private path mutation claim owner metadata changed.\");\n }\n await fs.unlink(releasePath);\n released = true;\n await parent.assertIdentityAt(ownedParentPath);\n await syncParentDirectory(ownedClaimPath, options.platform);\n } catch (error) {\n releaseError = error;\n }\n try {\n await closeClaimHandle();\n } catch (closeError) {\n if (releaseError !== undefined) {\n const aggregateError = new AggregateError(\n [releaseError, closeError],\n \"Private path mutation claim release failed and its handle could not be closed.\",\n );\n aggregateError.cause = releaseError;\n throw aggregateError;\n }\n throw closeError;\n }\n if (releaseError !== undefined) {\n throw releaseError;\n }\n },\n };\n }\n } catch (error) {\n const cleanupErrors: unknown[] = [];\n if (identity !== undefined) {\n for (const linkedClaimPath of linkedClaimPaths) {\n try {\n await assertClaimPathIdentity(linkedClaimPath, identity);\n await fs.unlink(linkedClaimPath);\n await syncParentDirectory(linkedClaimPath, options.platform);\n } catch (cleanupError) {\n cleanupErrors.push(cleanupError);\n }\n }\n }\n try {\n await handle?.close();\n } catch (closeError) {\n cleanupErrors.push(closeError);\n }\n try {\n await fs.rm(candidatePath, { force: true });\n } catch (cleanupError) {\n cleanupErrors.push(cleanupError);\n }\n if (cleanupErrors.length > 0) {\n const aggregateError = new AggregateError(\n [error, ...cleanupErrors],\n \"Private path mutation claim acquisition failed and rollback cleanup also failed.\",\n );\n aggregateError.cause = error;\n throw aggregateError;\n }\n throw error;\n }\n}\n\nconst PRIVATE_MUTATION_DIRECTORY_OWNER_FILE = \"owner.json\";\n\ntype PrivateMutationDirectoryClaimRecord = {\n identity: FileIdentity;\n metadata: PrivateMutationClaimRecord;\n};\n\nfunction samePrivateMutationDirectoryClaim(\n actual: PrivateMutationDirectoryClaimRecord,\n expected: PrivateMutationDirectoryClaimRecord,\n): boolean {\n return (\n actual.identity.device === expected.identity.device &&\n actual.identity.inode === expected.identity.inode &&\n actual.metadata.contents === expected.metadata.contents\n );\n}\n\nasync function readPrivateMutationDirectoryClaim(\n claimPath: string,\n): Promise<PrivateMutationDirectoryClaimRecord | null> {\n let stats;\n try {\n stats = await fs.lstat(claimPath, { bigint: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n return null;\n }\n throw error;\n }\n if (!stats.isDirectory() || stats.ino <= 0n) {\n throw new Error(\"Private mutation directory claim is malformed.\");\n }\n if (process.platform === \"win32\") {\n await verifyOwnerOnlyWindowsDirectoryAcl(claimPath);\n } else {\n assertOwnerOnlyPosixMutationClaim(stats, \"directory\");\n }\n const metadata = await readPrivateMutationClaim(\n path.join(claimPath, PRIVATE_MUTATION_DIRECTORY_OWNER_FILE),\n );\n if (metadata === null) {\n throw new Error(\"Private mutation directory claim is missing owner metadata.\");\n }\n const finalStats = await fs.lstat(claimPath, { bigint: true });\n if (process.platform === \"win32\") {\n await verifyOwnerOnlyWindowsDirectoryAcl(claimPath);\n } else {\n assertOwnerOnlyPosixMutationClaim(finalStats, \"directory\");\n }\n if (!finalStats.isDirectory() || finalStats.dev !== stats.dev || finalStats.ino !== stats.ino) {\n throw new Error(\"Private mutation directory claim identity changed.\");\n }\n return {\n identity: { device: stats.dev, inode: stats.ino },\n metadata,\n };\n}\n\nfunction privateMutationClaimOwnerIsActive(\n owner: PrivateMutationClaimOwner,\n runtime: PrivateMutationClaimRuntime,\n): boolean {\n if (!runtime.isProcessAlive(owner.pid)) {\n return false;\n }\n if (owner.pid === runtime.pid && owner.processStartedAtMs === runtime.processStartedAtMs) {\n return true;\n }\n if (owner.pid === runtime.pid) {\n return false;\n }\n if (owner.processIdentity === undefined) {\n return true;\n }\n const actualIdentity = runtime.getProcessIdentity(owner.pid);\n return actualIdentity === null || actualIdentity === owner.processIdentity;\n}\n\nasync function createPrivateMutationClaimDirectory(\n directoryPath: string,\n ownerContents: string,\n options: {\n createWindowsFile?: (filePath: string) => Promise<FileIdentity>;\n platform: NodeJS.Platform;\n },\n): Promise<void> {\n if (options.platform === \"win32\" && process.platform === \"win32\") {\n const firstCreated = await createOwnerOnlyWindowsDirectoryAncestry(directoryPath);\n if (firstCreated === undefined) {\n throw new Error(\"Windows mutation claim directory creation did not create its path.\");\n }\n } else {\n await fs.mkdir(directoryPath, { mode: 0o700 });\n await fs.chmod(directoryPath, 0o700);\n }\n const metadataPath = path.join(directoryPath, PRIVATE_MUTATION_DIRECTORY_OWNER_FILE);\n let handle: FileHandle | undefined;\n try {\n if (options.platform === \"win32\" && process.platform === \"win32\") {\n await (options.createWindowsFile ?? createOwnerOnlyWindowsFile)(metadataPath);\n handle = await fs.open(metadataPath, \"r+\");\n } else {\n handle = await fs.open(metadataPath, \"wx+\", 0o600);\n await handle.chmod(0o600);\n }\n await handle.writeFile(ownerContents, \"utf8\");\n await handle.sync();\n } finally {\n await handle?.close();\n }\n await syncParentDirectory(metadataPath, options.platform);\n}\n\nasync function removeInstalledPrivateMutationDirectoryClaim(\n claimPath: string,\n expectedIdentity: FileIdentity,\n ownerContents: string,\n rootClaimPath: string,\n platform: NodeJS.Platform,\n): Promise<void> {\n const observed = await readPrivateMutationDirectoryClaim(claimPath);\n if (\n observed === null ||\n observed.identity.device !== expectedIdentity.device ||\n observed.identity.inode !== expectedIdentity.inode ||\n observed.metadata.contents !== ownerContents\n ) {\n throw new Error(\"Private mutation directory claim changed before rollback.\");\n }\n const rollbackPath = `${rootClaimPath}.${randomUUID()}.rollback-dir`;\n await fs.rename(claimPath, rollbackPath);\n const moved = await readPrivateMutationDirectoryClaim(rollbackPath);\n if (\n moved === null ||\n moved.identity.device !== expectedIdentity.device ||\n moved.identity.inode !== expectedIdentity.inode ||\n moved.metadata.contents !== ownerContents\n ) {\n throw new Error(\"Private mutation directory claim changed during rollback.\");\n }\n await fs.rm(rollbackPath, { force: true, recursive: true });\n await syncParentDirectory(claimPath, platform);\n}\n\nasync function acquireDirectoryPrivateMutationClaim(\n parent: SecuredPrivateDirectory,\n options: {\n createWindowsFile?: (filePath: string) => Promise<FileIdentity>;\n platform?: NodeJS.Platform;\n runtime?: PrivateMutationClaimRuntime;\n },\n): Promise<PrivateMutationClaim> {\n const platform = options.platform ?? process.platform;\n const runtime = options.runtime ?? defaultPrivateMutationClaimRuntime();\n const ownerContents = `${JSON.stringify({\n ownerId: runtime.ownerId,\n pid: runtime.pid,\n ...(runtime.processIdentity ? { processIdentity: runtime.processIdentity } : {}),\n processStartedAtMs: runtime.processStartedAtMs,\n } satisfies PrivateMutationClaimOwner)}\\n`;\n parsePrivateMutationClaimOwner(ownerContents);\n const rootClaimPath = path.join(parent.directoryPath, PRIVATE_MUTATION_CLAIM_ROOT_FILE);\n const candidatePath = `${rootClaimPath}.${runtime.pid}.${randomUUID()}.candidate-dir`;\n const createCandidate = async () => {\n await createPrivateMutationClaimDirectory(candidatePath, ownerContents, {\n ...(options.createWindowsFile ? { createWindowsFile: options.createWindowsFile } : {}),\n platform,\n });\n const candidate = await readPrivateMutationDirectoryClaim(candidatePath);\n if (candidate === null || candidate.metadata.contents !== ownerContents) {\n throw new Error(\"Private mutation directory claim candidate could not be verified.\");\n }\n return candidate;\n };\n let candidate: Awaited<ReturnType<typeof createCandidate>> | undefined;\n let claimPath = rootClaimPath;\n let installedClaimPath: string | undefined;\n let expectedRootClaim: PrivateMutationDirectoryClaimRecord | undefined;\n try {\n candidate = await createCandidate();\n for (;;) {\n try {\n await fs.rename(candidatePath, claimPath);\n installedClaimPath = claimPath;\n } catch (error) {\n const observed = await readPrivateMutationDirectoryClaim(claimPath);\n if (observed === null) {\n throw error;\n }\n if (privateMutationClaimOwnerIsActive(observed.metadata.owner, runtime)) {\n throw new ActivePrivateMutationClaimError(error);\n }\n await parent.assertIdentityAt();\n const revalidated = await readPrivateMutationDirectoryClaim(claimPath);\n if (\n revalidated === null ||\n revalidated.identity.device !== observed.identity.device ||\n revalidated.identity.inode !== observed.identity.inode ||\n revalidated.metadata.contents !== observed.metadata.contents\n ) {\n continue;\n }\n if (claimPath === rootClaimPath) {\n expectedRootClaim = revalidated;\n } else {\n const revalidatedRoot = await readPrivateMutationDirectoryClaim(rootClaimPath);\n if (\n expectedRootClaim === undefined ||\n revalidatedRoot === null ||\n !samePrivateMutationDirectoryClaim(revalidatedRoot, expectedRootClaim)\n ) {\n claimPath = rootClaimPath;\n expectedRootClaim = undefined;\n continue;\n }\n }\n claimPath = path.join(claimPath, \".next\");\n continue;\n }\n const claimed = await readPrivateMutationDirectoryClaim(claimPath);\n if (\n claimed === null ||\n claimed.identity.device !== candidate.identity.device ||\n claimed.identity.inode !== candidate.identity.inode ||\n claimed.metadata.contents !== ownerContents\n ) {\n throw new Error(\"Private mutation directory claim ownership could not be verified.\");\n }\n if (claimPath !== rootClaimPath) {\n const revalidatedRoot = await readPrivateMutationDirectoryClaim(rootClaimPath);\n if (\n expectedRootClaim === undefined ||\n revalidatedRoot === null ||\n !samePrivateMutationDirectoryClaim(revalidatedRoot, expectedRootClaim)\n ) {\n await removeInstalledPrivateMutationDirectoryClaim(\n claimPath,\n candidate.identity,\n ownerContents,\n rootClaimPath,\n platform,\n );\n installedClaimPath = undefined;\n candidate = await createCandidate();\n claimPath = rootClaimPath;\n expectedRootClaim = undefined;\n continue;\n }\n const terminalRelativePath = path.relative(rootClaimPath, claimPath);\n const staleTreePath = `${rootClaimPath}.${randomUUID()}.stale-dir`;\n await parent.assertIdentityAt();\n await fs.rename(rootClaimPath, staleTreePath);\n const relocatedClaimPath = path.join(staleTreePath, terminalRelativePath);\n installedClaimPath = relocatedClaimPath;\n const [movedRoot, movedClaim] = await Promise.all([\n readPrivateMutationDirectoryClaim(staleTreePath),\n readPrivateMutationDirectoryClaim(relocatedClaimPath),\n ]);\n if (\n movedRoot === null ||\n !samePrivateMutationDirectoryClaim(movedRoot, revalidatedRoot) ||\n movedClaim === null ||\n movedClaim.identity.device !== candidate.identity.device ||\n movedClaim.identity.inode !== candidate.identity.inode ||\n movedClaim.metadata.contents !== ownerContents\n ) {\n const compactionError = new Error(\n \"Private mutation directory claim changed during compaction.\",\n );\n try {\n await fs.rename(staleTreePath, rootClaimPath);\n installedClaimPath = claimPath;\n } catch (rollbackError) {\n const aggregateError = new AggregateError(\n [compactionError, rollbackError],\n \"Private mutation directory claim compaction failed and its stale tree could not be restored.\",\n );\n aggregateError.cause = compactionError;\n throw aggregateError;\n }\n throw compactionError;\n }\n try {\n await fs.rename(relocatedClaimPath, rootClaimPath);\n } catch (error) {\n const code = (error as NodeJS.ErrnoException).code;\n if (code !== \"EEXIST\" && code !== \"ENOTEMPTY\") {\n try {\n await fs.rename(staleTreePath, rootClaimPath);\n installedClaimPath = claimPath;\n } catch (rollbackError) {\n const aggregateError = new AggregateError(\n [error, rollbackError],\n \"Private mutation directory claim compaction failed and its stale tree could not be restored.\",\n );\n aggregateError.cause = error;\n throw aggregateError;\n }\n throw error;\n }\n const retainedClaim = await readPrivateMutationDirectoryClaim(relocatedClaimPath);\n if (\n retainedClaim === null ||\n retainedClaim.identity.device !== candidate.identity.device ||\n retainedClaim.identity.inode !== candidate.identity.inode ||\n retainedClaim.metadata.contents !== ownerContents\n ) {\n throw new Error(\"Private mutation directory claim changed during compaction.\", {\n cause: error,\n });\n }\n await fs.rm(staleTreePath, { force: true, recursive: true });\n await syncParentDirectory(rootClaimPath, platform);\n installedClaimPath = undefined;\n candidate = await createCandidate();\n claimPath = rootClaimPath;\n expectedRootClaim = undefined;\n continue;\n }\n installedClaimPath = rootClaimPath;\n const promotedClaim = await readPrivateMutationDirectoryClaim(rootClaimPath);\n if (\n promotedClaim === null ||\n promotedClaim.identity.device !== candidate.identity.device ||\n promotedClaim.identity.inode !== candidate.identity.inode ||\n promotedClaim.metadata.contents !== ownerContents\n ) {\n throw new Error(\"Private mutation directory claim changed during compaction.\");\n }\n await fs.rm(staleTreePath, { force: true, recursive: true });\n await syncParentDirectory(rootClaimPath, platform);\n claimPath = rootClaimPath;\n expectedRootClaim = undefined;\n }\n break;\n }\n\n const [rootClaim, claimed] = await Promise.all([\n readPrivateMutationDirectoryClaim(rootClaimPath),\n readPrivateMutationDirectoryClaim(claimPath),\n ]);\n if (rootClaim === null) {\n throw new Error(\"Private mutation directory claim root disappeared.\");\n }\n if (\n claimed === null ||\n claimed.identity.device !== candidate.identity.device ||\n claimed.identity.inode !== candidate.identity.inode ||\n claimed.metadata.contents !== ownerContents\n ) {\n throw new Error(\"Private mutation directory claim ownership could not be verified.\");\n }\n if (\n claimPath !== rootClaimPath &&\n (expectedRootClaim === undefined ||\n !samePrivateMutationDirectoryClaim(rootClaim, expectedRootClaim))\n ) {\n throw new Error(\"Private mutation directory claim root changed during acquisition.\");\n }\n const terminalRelativePath = path.relative(rootClaimPath, claimPath);\n await parent.assertIdentityAt();\n await syncParentDirectory(claimPath, platform);\n\n let released = false;\n let claimedParentPath = parent.directoryPath;\n let ownedRootClaimPath = rootClaimPath;\n let ownedClaimPath = claimPath;\n const assertOwned = async () => {\n await parent.assertIdentityAt(claimedParentPath);\n const [observedRoot, observed] = await Promise.all([\n readPrivateMutationDirectoryClaim(ownedRootClaimPath),\n readPrivateMutationDirectoryClaim(ownedClaimPath),\n ]);\n if (\n observedRoot === null ||\n !samePrivateMutationDirectoryClaim(observedRoot, rootClaim) ||\n observed === null ||\n observed.identity.device !== claimed.identity.device ||\n observed.identity.inode !== claimed.identity.inode ||\n observed.metadata.contents !== ownerContents\n ) {\n throw new Error(\"Private mutation directory claim owner changed.\");\n }\n };\n return {\n assertOwned,\n async completeContainerRemoval() {\n if (released) {\n return;\n }\n try {\n await fs.lstat(claimedParentPath);\n throw new Error(\"Private directory path still exists after recursive removal.\");\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw error;\n }\n }\n released = true;\n },\n async prepareContainerRemoval() {\n await assertOwned();\n },\n async relocateParent(directoryPath: string) {\n const relocatedRootClaimPath = path.join(directoryPath, path.basename(ownedRootClaimPath));\n const relocatedClaimPath = path.join(relocatedRootClaimPath, terminalRelativePath);\n await parent.assertIdentityAt(directoryPath);\n const [observedRoot, observed] = await Promise.all([\n readPrivateMutationDirectoryClaim(relocatedRootClaimPath),\n readPrivateMutationDirectoryClaim(relocatedClaimPath),\n ]);\n if (\n observedRoot === null ||\n !samePrivateMutationDirectoryClaim(observedRoot, rootClaim) ||\n observed === null ||\n observed.identity.device !== claimed.identity.device ||\n observed.identity.inode !== claimed.identity.inode ||\n observed.metadata.contents !== ownerContents\n ) {\n throw new Error(\"Private mutation directory claim changed during relocation.\");\n }\n claimedParentPath = directoryPath;\n ownedRootClaimPath = relocatedRootClaimPath;\n ownedClaimPath = relocatedClaimPath;\n },\n async release() {\n if (released) {\n return;\n }\n await assertOwned();\n const releasePath = `${ownedRootClaimPath}.${randomUUID()}.release-dir`;\n await fs.rename(ownedRootClaimPath, releasePath);\n const [movedRoot, moved] = await Promise.all([\n readPrivateMutationDirectoryClaim(releasePath),\n readPrivateMutationDirectoryClaim(path.join(releasePath, terminalRelativePath)),\n ]);\n if (\n movedRoot === null ||\n !samePrivateMutationDirectoryClaim(movedRoot, rootClaim) ||\n moved === null ||\n moved.identity.device !== claimed.identity.device ||\n moved.identity.inode !== claimed.identity.inode ||\n moved.metadata.contents !== ownerContents\n ) {\n throw new Error(\"Private mutation directory claim changed during release.\");\n }\n await fs.rm(releasePath, { force: true, recursive: true });\n released = true;\n await parent.assertIdentityAt(claimedParentPath);\n await syncParentDirectory(ownedRootClaimPath, platform);\n },\n };\n } catch (error) {\n const cleanupErrors: unknown[] = [];\n if (installedClaimPath !== undefined && candidate !== undefined) {\n try {\n await removeInstalledPrivateMutationDirectoryClaim(\n installedClaimPath,\n candidate.identity,\n ownerContents,\n rootClaimPath,\n platform,\n );\n } catch (cleanupError) {\n cleanupErrors.push(cleanupError);\n }\n }\n if (cleanupErrors.length > 0) {\n const aggregateError = new AggregateError(\n [error, ...cleanupErrors],\n \"Private mutation directory claim acquisition failed and rollback cleanup also failed.\",\n );\n aggregateError.cause = error;\n throw aggregateError;\n }\n throw error;\n } finally {\n await fs.rm(candidatePath, { force: true, recursive: true });\n }\n}\n\nasync function acquirePrivateMutationClaim(\n parent: SecuredPrivateDirectory,\n options: {\n createWindowsFile?: (filePath: string) => Promise<FileIdentity>;\n platform?: NodeJS.Platform;\n runtime?: PrivateMutationClaimRuntime;\n },\n): Promise<PrivateMutationClaim> {\n const rootClaimPath = path.join(parent.directoryPath, PRIVATE_MUTATION_CLAIM_ROOT_FILE);\n try {\n const stats = await fs.lstat(rootClaimPath);\n if (stats.isDirectory()) {\n return await acquireDirectoryPrivateMutationClaim(parent, options);\n }\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw error;\n }\n }\n try {\n return await acquireHardLinkPrivateMutationClaim(parent, options);\n } catch (error) {\n let directoryClaimExists = false;\n try {\n directoryClaimExists = (await fs.lstat(rootClaimPath)).isDirectory();\n } catch {}\n if (!(error instanceof UnsupportedPrivateMutationHardLinkError) && !directoryClaimExists) {\n throw error;\n }\n return await acquireDirectoryPrivateMutationClaim(parent, options);\n }\n}\n\nasync function captureOwnerOnlyPrivateClaimAncestor(\n directoryPath: string,\n platform: NodeJS.Platform,\n): Promise<{ directory: SecuredPrivateDirectory; mutationRoot: boolean } | null> {\n if (platform === \"win32\" && process.platform === \"win32\") {\n try {\n await verifyOwnerOnlyWindowsDirectoryAcl(directoryPath);\n } catch {\n return null;\n }\n return {\n directory: await captureDirectoryIdentity(directoryPath),\n mutationRoot: false,\n };\n }\n\n const currentUserId = process.geteuid?.();\n if (currentUserId === undefined || !Number.isSafeInteger(currentUserId) || currentUserId < 0) {\n throw new Error(\"Could not resolve the current POSIX user for private mutation claims.\");\n }\n const stats = await fs.lstat(directoryPath, { bigint: true });\n if (!stats.isDirectory()) {\n throw new Error(\"Private mutation claim ancestry contains a non-directory entry.\");\n }\n if (\n stats.uid !== BigInt(currentUserId) ||\n (stats.mode & 0o022n) !== 0n ||\n (await darwinDirectoryHasExtendedAcl(directoryPath))\n ) {\n return null;\n }\n return {\n directory: await captureDirectoryIdentity(directoryPath),\n mutationRoot: (stats.mode & 0o1000n) !== 0n,\n };\n}\n\nasync function ownerOnlyPrivateClaimAncestry(\n leaf: SecuredPrivateDirectory,\n platform: NodeJS.Platform,\n): Promise<SecuredPrivateDirectory[]> {\n const ancestry = [leaf];\n let highestMutationRootIndex =\n platform !== \"win32\" &&\n process.platform !== \"win32\" &&\n ((await fs.lstat(leaf.directoryPath, { bigint: true })).mode & 0o1000n) !== 0n\n ? 0\n : -1;\n let directoryPath = path.dirname(leaf.directoryPath);\n while (directoryPath !== path.dirname(directoryPath)) {\n const ancestor = await captureOwnerOnlyPrivateClaimAncestor(directoryPath, platform);\n if (ancestor === null) {\n break;\n }\n ancestry.push(ancestor.directory);\n if (ancestor.mutationRoot) {\n highestMutationRootIndex = ancestry.length - 1;\n }\n directoryPath = path.dirname(directoryPath);\n }\n if (platform !== \"win32\" && process.platform !== \"win32\") {\n return highestMutationRootIndex < 0 ? [leaf] : ancestry.slice(0, highestMutationRootIndex + 1);\n }\n return ancestry;\n}\n\nasync function acquirePrivateMutationClaimChain(\n leaf: SecuredPrivateDirectory,\n options: {\n createWindowsFile?: (filePath: string) => Promise<FileIdentity>;\n platform?: NodeJS.Platform;\n runtime?: PrivateMutationClaimRuntime;\n },\n): Promise<PrivateMutationClaim> {\n const platform = options.platform ?? process.platform;\n const ancestry = await ownerOnlyPrivateClaimAncestry(leaf, platform);\n const outerBoundary = await captureSafePrivateDirectoryMutationParent(\n ancestry.at(-1)!.directoryPath,\n platform,\n );\n const claims: PrivateMutationClaim[] = [];\n let leafClaim: PrivateMutationClaim | undefined;\n try {\n for (const directory of ancestry) {\n const claim = await acquirePrivateMutationClaim(directory, options);\n claims.push(claim);\n if (directory === leaf) {\n leafClaim = claim;\n }\n }\n } catch (error) {\n const cleanupErrors: unknown[] = [];\n for (const claim of claims.reverse()) {\n try {\n await claim.release();\n } catch (cleanupError) {\n cleanupErrors.push(cleanupError);\n }\n }\n if (cleanupErrors.length > 0) {\n const aggregateError = new AggregateError(\n [error, ...cleanupErrors],\n \"Private mutation claim-chain acquisition failed and rollback cleanup also failed.\",\n );\n aggregateError.cause = error;\n throw aggregateError;\n }\n throw error;\n }\n\n let released = false;\n let leafRemoved = false;\n const releaseClaims = async (claimsToRelease: PrivateMutationClaim[]) => {\n const releaseErrors: unknown[] = [];\n for (const claim of claimsToRelease) {\n try {\n await claim.release();\n } catch (error) {\n releaseErrors.push(error);\n }\n }\n if (releaseErrors.length === 1) {\n throw releaseErrors[0];\n }\n if (releaseErrors.length > 1) {\n throw new AggregateError(releaseErrors, \"Private mutation claim-chain release failed.\");\n }\n };\n return {\n async assertOwned() {\n await outerBoundary.assertIdentityAt();\n for (const claim of claims) {\n await claim.assertOwned();\n }\n },\n async completeContainerRemoval() {\n if (released) {\n return;\n }\n if (leafClaim === undefined) {\n throw new Error(\"Private directory removal did not acquire its leaf mutation claim.\");\n }\n let primaryError: unknown;\n try {\n await leafClaim.completeContainerRemoval();\n leafRemoved = true;\n } catch (error) {\n primaryError = error;\n }\n try {\n await releaseClaims(claims.slice(1).reverse());\n } catch (releaseError) {\n if (primaryError !== undefined) {\n const aggregateError = new AggregateError(\n [primaryError, releaseError],\n \"Private directory removal completion and ancestor claim release both failed.\",\n );\n aggregateError.cause = primaryError;\n throw aggregateError;\n }\n throw releaseError;\n }\n if (primaryError !== undefined) {\n throw primaryError;\n }\n released = true;\n },\n async prepareContainerRemoval() {\n if (leafClaim === undefined) {\n throw new Error(\"Private directory removal did not acquire its leaf mutation claim.\");\n }\n await leafClaim.prepareContainerRemoval();\n },\n async relocateParent(directoryPath: string) {\n if (leafClaim === undefined) {\n throw new Error(\"Private directory removal did not acquire its leaf mutation claim.\");\n }\n await leafClaim.relocateParent(directoryPath);\n },\n async release() {\n if (released) {\n return;\n }\n await releaseClaims(leafRemoved ? claims.slice(1).reverse() : [...claims].reverse());\n released = true;\n },\n };\n}\n\nfunction privateMutationClaimTimeoutError(timeoutMs: number, cause: unknown): Error {\n return Object.assign(\n new Error(`Timed out after ${timeoutMs}ms waiting for a private mutation claim.`, { cause }),\n { code: \"ETIMEDOUT\" },\n );\n}\n\nasync function releaseClaimAfterWaitFailure(\n claim: PrivateMutationClaim,\n error: unknown,\n): Promise<never> {\n try {\n await claim.release();\n } catch (releaseError) {\n const aggregateError = new AggregateError(\n [error, releaseError],\n \"Private mutation claim wait failed and its acquired claim could not be released.\",\n );\n aggregateError.cause = error;\n throw aggregateError;\n }\n throw error;\n}\n\nasync function acquirePrivateMutationClaimWithWait(\n acquire: () => Promise<PrivateMutationClaim>,\n wait?: PreparedPrivateMutationClaimWait,\n): Promise<PrivateMutationClaim> {\n if (wait === undefined) {\n return await acquire();\n }\n const deadlineMs = wait.now() + wait.timeoutMs;\n let lastContentionError: ActivePrivateMutationClaimError | undefined;\n for (;;) {\n wait.signal?.throwIfAborted();\n let claim: PrivateMutationClaim;\n try {\n claim = await acquire();\n } catch (error) {\n if (!(error instanceof ActivePrivateMutationClaimError) || wait.timeoutMs === 0) {\n throw error;\n }\n lastContentionError = error;\n const remainingMs = deadlineMs - wait.now();\n if (remainingMs <= 0) {\n throw privateMutationClaimTimeoutError(wait.timeoutMs, error);\n }\n await wait.sleep(Math.min(wait.retryDelayMs, remainingMs), wait.signal);\n continue;\n }\n try {\n wait.signal?.throwIfAborted();\n if (lastContentionError && wait.now() >= deadlineMs) {\n throw privateMutationClaimTimeoutError(wait.timeoutMs, lastContentionError);\n }\n } catch (error) {\n return await releaseClaimAfterWaitFailure(claim, error);\n }\n return claim;\n }\n}\n\nasync function secureOwnerOnlyMutationParent(\n directoryPath: string,\n): Promise<SecuredPrivateDirectory> {\n return await securePrivateDirectory(directoryPath, {\n markMutationRoot: false,\n platform: process.platform,\n });\n}\n\nexport async function publishPrivateFileAtomically(\n filePath: string,\n contents: string,\n options: {\n afterRename?: (filePath: string) => Promise<void>;\n beforeCommitRename?: (temporaryPath: string) => Promise<void>;\n beforeRename?: (temporaryPath: string) => Promise<void>;\n claimRuntime?: PrivateMutationClaimRuntime;\n claimWait?: PrivateMutationClaimWaitOptions;\n createWindowsFile?: (temporaryPath: string) => Promise<FileIdentity>;\n createWindowsDirectories?: (directoryPath: string) => Promise<string | undefined>;\n platform?: NodeJS.Platform;\n removeTemporaryFile?: (temporaryPath: string) => Promise<void>;\n secureWindowsFile?: (temporaryPath: string) => Promise<void>;\n syncParent?: (filePath: string, platform?: NodeJS.Platform) => Promise<void>;\n } = {},\n): Promise<void> {\n assertNotReservedPrivateMutationPath(filePath);\n const claimWait = preparePrivateMutationClaimWait(options.claimWait ?? {});\n const temporaryPath = path.join(\n path.dirname(filePath),\n `.${path.basename(filePath)}.${process.pid}.${randomUUID()}.tmp`,\n );\n const parentDirectory = path.resolve(path.dirname(filePath));\n const platform = options.platform ?? process.platform;\n let parentExists = false;\n try {\n const parentStats = await fs.lstat(parentDirectory);\n if (!parentStats.isDirectory()) {\n throw new Error(\"Private publication parent is not a directory.\");\n }\n parentExists = true;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw error;\n }\n }\n const creationBoundary = parentExists\n ? undefined\n : await captureSafePrivateMutationBoundary(\n await nearestExistingDirectory(parentDirectory),\n platform,\n true,\n );\n const migrationBoundary = parentExists\n ? await capturePrivateMutationPathAncestry(parentDirectory, platform)\n : undefined;\n const firstCreatedDirectory =\n platform === \"win32\"\n ? parentExists\n ? undefined\n : await (options.createWindowsDirectories ?? createOwnerOnlyWindowsDirectoryAncestry)(\n parentDirectory,\n )\n : await fs.mkdir(parentDirectory, { recursive: true, mode: 0o700 });\n await creationBoundary?.assertIdentityAt();\n await assertDarwinCreatedAncestryHasNoExtendedAcl(firstCreatedDirectory, parentDirectory);\n if (firstCreatedDirectory !== undefined && platform !== \"win32\") {\n await securePrivateDirectory(firstCreatedDirectory, {\n markMutationRoot: true,\n platform,\n });\n }\n await migrationBoundary?.assertIdentityAt();\n const parent = await secureOwnerOnlyMutationParent(parentDirectory);\n await migrationBoundary?.assertIdentityAt();\n const claimOptions = {\n ...(options.claimRuntime ? { runtime: options.claimRuntime } : {}),\n ...(options.createWindowsFile ? { createWindowsFile: options.createWindowsFile } : {}),\n ...(options.platform ? { platform: options.platform } : {}),\n };\n // The full ancestry fence stays held for the temporary file's lifetime so supported removals\n // cannot quarantine a secret. Active publishers wait here without serializing their whole flow.\n const claim = await acquirePrivateMutationClaimWithWait(\n () => acquirePrivateMutationClaimChain(parent, claimOptions),\n claimWait,\n );\n let handle: FileHandle | undefined;\n let identity: FileIdentity | undefined;\n let publicationFailed = false;\n let primaryError: unknown;\n try {\n if (platform === \"win32\" && options.secureWindowsFile === undefined) {\n const createdIdentity = await (options.createWindowsFile ?? createOwnerOnlyWindowsFile)(\n temporaryPath,\n );\n identity = createdIdentity;\n handle = await fs.open(temporaryPath, \"r+\");\n const openedIdentity = await readHandleIdentity(handle);\n assertSameFileIdentity(openedIdentity, createdIdentity);\n } else {\n handle = await fs.open(temporaryPath, \"wx+\", 0o600);\n identity = await readHandleIdentity(handle);\n if (platform === \"win32\") {\n await options.secureWindowsFile!(temporaryPath);\n } else {\n await handle.chmod(0o600);\n }\n }\n\n await assertPathIdentity(temporaryPath, identity);\n await handle.writeFile(contents, \"utf8\");\n await handle.sync();\n await assertPathIdentity(temporaryPath, identity);\n await options.beforeRename?.(temporaryPath);\n await parent.assertIdentityAt();\n await claim.assertOwned();\n await assertPathIdentity(temporaryPath, identity);\n await options.beforeCommitRename?.(temporaryPath);\n await parent.assertIdentityAt();\n await claim.assertOwned();\n await assertPathIdentity(temporaryPath, identity);\n // Node has no portable renameat API. The owner-only parent and parent-wide claim chain fence\n // every supported same-user writer while these path identities are revalidated.\n await fs.rename(temporaryPath, filePath);\n await parent.assertIdentityAt();\n await claim.assertOwned();\n await syncPathAncestry(\n filePath,\n options.syncParent ?? syncParentDirectory,\n options.platform,\n firstCreatedDirectory,\n );\n await options.afterRename?.(filePath);\n await parent.assertIdentityAt();\n await claim.assertOwned();\n await assertPathIdentity(filePath, identity);\n } catch (error) {\n publicationFailed = true;\n primaryError = error;\n }\n\n const cleanupErrors: unknown[] = [];\n try {\n await handle?.close();\n } catch (error) {\n cleanupErrors.push(error);\n }\n try {\n if (identity !== undefined && (await pathHasFileIdentity(temporaryPath, identity))) {\n await (\n options.removeTemporaryFile ??\n ((candidatePath: string) => fs.rm(candidatePath, { force: true }))\n )(temporaryPath);\n }\n } catch (error) {\n cleanupErrors.push(error);\n }\n try {\n await claim.release();\n } catch (error) {\n cleanupErrors.push(error);\n }\n\n if (publicationFailed) {\n if (cleanupErrors.length > 0) {\n const primaryMessage =\n primaryError instanceof Error ? primaryError.message : String(primaryError);\n const aggregateError = new AggregateError(\n [primaryError, ...cleanupErrors],\n `${primaryMessage} Private temporary file cleanup also failed.`,\n );\n aggregateError.cause = primaryError;\n const primaryCode =\n typeof primaryError === \"object\" && primaryError !== null\n ? (primaryError as NodeJS.ErrnoException).code\n : undefined;\n if (primaryCode) {\n Object.assign(aggregateError, { code: primaryCode });\n }\n throw aggregateError;\n }\n throw primaryError;\n }\n if (cleanupErrors.length === 1) {\n throw cleanupErrors[0];\n }\n if (cleanupErrors.length > 1) {\n throw new AggregateError(cleanupErrors, \"Private temporary file publication cleanup failed.\");\n }\n}\n"]}
1
+ {"version":3,"file":"private-file.js","sourceRoot":"","sources":["../../../src/openclaw/private-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,YAAY,EAAoB,MAAM,SAAS,CAAC;AACnF,OAAO,EAAE,EAAE,EAAmB,MAAM,kBAAkB,CAAC;AACvD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACL,iCAAiC,IAAI,yCAAyC,EAC9E,uCAAuC,IAAI,+CAA+C,GAC3F,MAAM,4BAA4B,CAAC;AAEpC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAC1C,MAAM,8BAA8B,GAAG,MAAM,CAAC;AAE9C,MAAM,qCAAqC,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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D,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,MAAM,aAAa,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC;IACD,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,cAAc,CAAC,aAAa,EAAE,oDAAoD,CAAC,CAAC;IAChG,CAAC;AACH,CAAC","sourcesContent":["import { execFile, spawnSync } from \"node:child_process\";\nimport { createHash, randomUUID } from \"node:crypto\";\nimport { constants as fsConstants, readFileSync, type BigIntStats } from \"node:fs\";\nimport fs, { type FileHandle } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { performance } from \"node:perf_hooks\";\nimport { setTimeout as delay } from \"node:timers/promises\";\nimport { promisify } from \"node:util\";\nimport {\n applyOwnerOnlyWindowsDirectoryAcl as applyOwnerOnlyWindowsDirectoryAclByHandle,\n createOwnerOnlyWindowsDirectoryAncestry as createOwnerOnlyWindowsDirectoryAncestryByHandle,\n} from \"../platform/windows-acl.js\";\n\nconst execFileAsync = promisify(execFile);\nconst WINDOWS_ACL_COMMAND_TIMEOUT_MS = 15_000;\n\nconst WINDOWS_CREATE_OWNER_ONLY_FILE_SCRIPT = String.raw`\n$ErrorActionPreference = \"Stop\"\n$filePath = $env:CRABLINE_PRIVATE_FILE_PATH\nif ([string]::IsNullOrWhiteSpace($filePath)) {\n throw \"CRABLINE_PRIVATE_FILE_PATH is required.\"\n}\n\nAdd-Type -TypeDefinition @\"\nusing System;\nusing System.ComponentModel;\nusing System.Runtime.InteropServices;\nusing Microsoft.Win32.SafeHandles;\n\npublic static class CrablinePrivateFileIdentity\n{\n private const int FileInternalInformationClass = 6;\n private const int FileFsVolumeInformationClass = 1;\n private const int FileDispositionInfoClass = 4;\n\n [StructLayout(LayoutKind.Sequential)]\n private struct IoStatusBlock\n {\n public IntPtr Status;\n public UIntPtr Information;\n }\n\n [StructLayout(LayoutKind.Sequential)]\n private struct FileInternalInformation\n {\n public long IndexNumber;\n }\n\n [StructLayout(LayoutKind.Sequential)]\n private struct FileDispositionInfo\n {\n [MarshalAs(UnmanagedType.Bool)]\n public bool DeleteFile;\n }\n\n [DllImport(\"ntdll.dll\")]\n private static extern int NtQueryInformationFile(\n SafeFileHandle file,\n out IoStatusBlock ioStatus,\n out FileInternalInformation fileInformation,\n uint length,\n int fileInformationClass\n );\n\n [DllImport(\"ntdll.dll\")]\n private static extern int NtQueryVolumeInformationFile(\n SafeFileHandle file,\n out IoStatusBlock ioStatus,\n [Out] byte[] volumeInformation,\n uint length,\n int volumeInformationClass\n );\n\n [DllImport(\"kernel32.dll\", SetLastError = true)]\n [return: MarshalAs(UnmanagedType.Bool)]\n private static extern bool SetFileInformationByHandle(\n SafeFileHandle file,\n int informationClass,\n ref FileDispositionInfo information,\n uint bufferSize\n );\n\n [DllImport(\"ntdll.dll\")]\n private static extern uint RtlNtStatusToDosError(int status);\n\n private static void ThrowIfFailed(int status)\n {\n if (status != 0) {\n throw new Win32Exception(\n unchecked((int)RtlNtStatusToDosError(status))\n );\n }\n }\n\n public static string Read(SafeFileHandle file)\n {\n IoStatusBlock ioStatus;\n FileInternalInformation fileInfo;\n int status = NtQueryInformationFile(\n file,\n out ioStatus,\n out fileInfo,\n (uint)Marshal.SizeOf(typeof(FileInternalInformation)),\n FileInternalInformationClass\n );\n ThrowIfFailed(status);\n\n byte[] volumeInfo = new byte[1024];\n status = NtQueryVolumeInformationFile(\n file,\n out ioStatus,\n volumeInfo,\n (uint)volumeInfo.Length,\n FileFsVolumeInformationClass\n );\n ThrowIfFailed(status);\n\n uint device = BitConverter.ToUInt32(volumeInfo, 8);\n ulong inode = unchecked((ulong)fileInfo.IndexNumber);\n return device.ToString(\n System.Globalization.CultureInfo.InvariantCulture\n ) + \":\" + inode.ToString(\n System.Globalization.CultureInfo.InvariantCulture\n );\n }\n\n public static void MarkDelete(SafeFileHandle file)\n {\n FileDispositionInfo disposition = new FileDispositionInfo {\n DeleteFile = true\n };\n if (!SetFileInformationByHandle(\n file,\n FileDispositionInfoClass,\n ref disposition,\n (uint)Marshal.SizeOf(typeof(FileDispositionInfo))\n )) {\n throw new Win32Exception(Marshal.GetLastWin32Error());\n }\n }\n}\n\"@\n\n$identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()\n$sid = $identity.User\nif ($null -eq $sid) {\n throw \"Could not resolve the current Windows user SID.\"\n}\n\n$acl = [System.Security.AccessControl.FileSecurity]::new()\n$acl.SetOwner($sid)\n$acl.SetAccessRuleProtection($true, $false)\n$rule = [System.Security.AccessControl.FileSystemAccessRule]::new(\n $sid,\n [System.Security.AccessControl.FileSystemRights]::FullControl,\n [System.Security.AccessControl.AccessControlType]::Allow\n)\n$acl.SetAccessRule($rule)\n\n$rights = (\n [System.Security.AccessControl.FileSystemRights]::Read -bor\n [System.Security.AccessControl.FileSystemRights]::Write -bor\n [System.Security.AccessControl.FileSystemRights]::ReadPermissions -bor\n [System.Security.AccessControl.FileSystemRights]::Delete\n)\n$stream = [System.IO.FileStream]::new(\n $filePath,\n [System.IO.FileMode]::CreateNew,\n $rights,\n [System.IO.FileShare]::ReadWrite,\n 4096,\n [System.IO.FileOptions]::None,\n $acl\n)\ntry {\n $actual = $stream.GetAccessControl()\n $ownerSid = $actual.GetOwner([System.Security.Principal.SecurityIdentifier])\n $rules = @($actual.GetAccessRules(\n $true,\n $true,\n [System.Security.Principal.SecurityIdentifier]\n ))\n if (-not $actual.AreAccessRulesProtected) {\n throw \"Private file DACL still inherits permissions.\"\n }\n if ($ownerSid.Value -ne $sid.Value) {\n throw \"Private file owner SID does not match the current user.\"\n }\n if ($rules.Count -ne 1) {\n throw \"Private file DACL must contain exactly one access rule.\"\n }\n $actualRule = $rules[0]\n if (\n $actualRule.IsInherited -or\n $actualRule.IdentityReference.Value -ne $sid.Value -or\n $actualRule.AccessControlType -ne [System.Security.AccessControl.AccessControlType]::Allow -or\n (($actualRule.FileSystemRights -band [System.Security.AccessControl.FileSystemRights]::FullControl) -ne [System.Security.AccessControl.FileSystemRights]::FullControl)\n ) {\n throw \"Private file DACL is not owner-only full control.\"\n }\n [Console]::Out.Write(\n [CrablinePrivateFileIdentity]::Read($stream.SafeFileHandle)\n )\n} catch {\n $primaryError = $_.Exception\n try {\n [CrablinePrivateFileIdentity]::MarkDelete($stream.SafeFileHandle)\n } catch {\n $aggregateErrors = [System.Collections.Generic.List[System.Exception]]::new()\n $aggregateErrors.Add($primaryError)\n $aggregateErrors.Add($_.Exception)\n throw [System.AggregateException]::new(\n \"Private file creation and handle-bound cleanup failed.\",\n $aggregateErrors\n )\n }\n throw $primaryError\n} finally {\n $stream.Dispose()\n}\n`;\n\nconst WINDOWS_VERIFY_OWNER_ONLY_DIRECTORY_ACL_SCRIPT = String.raw`\n$ErrorActionPreference = \"Stop\"\n$directoryPath = $env:CRABLINE_PRIVATE_DIRECTORY_PATH\nif ([string]::IsNullOrWhiteSpace($directoryPath)) {\n throw \"CRABLINE_PRIVATE_DIRECTORY_PATH is required.\"\n}\n\n$identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()\n$sid = $identity.User\nif ($null -eq $sid) {\n throw \"Could not resolve the current Windows user SID.\"\n}\n\n$actual = Get-Acl -LiteralPath $directoryPath\n$ownerSid = $actual.GetOwner([System.Security.Principal.SecurityIdentifier])\n$rules = @($actual.GetAccessRules(\n $true,\n $true,\n [System.Security.Principal.SecurityIdentifier]\n))\n$requiredInheritance = (\n [System.Security.AccessControl.InheritanceFlags]::ContainerInherit -bor\n [System.Security.AccessControl.InheritanceFlags]::ObjectInherit\n)\nif (-not $actual.AreAccessRulesProtected) {\n throw \"Private directory DACL still inherits permissions.\"\n}\nif ($ownerSid.Value -ne $sid.Value) {\n throw \"Private directory owner SID does not match the current user.\"\n}\nif ($rules.Count -ne 1) {\n throw \"Private directory DACL must contain exactly one access rule.\"\n}\n$actualRule = $rules[0]\nif (\n $actualRule.IsInherited -or\n $actualRule.IdentityReference.Value -ne $sid.Value -or\n $actualRule.AccessControlType -ne [System.Security.AccessControl.AccessControlType]::Allow -or\n (($actualRule.FileSystemRights -band [System.Security.AccessControl.FileSystemRights]::FullControl) -ne [System.Security.AccessControl.FileSystemRights]::FullControl) -or\n (($actualRule.InheritanceFlags -band $requiredInheritance) -ne $requiredInheritance)\n) {\n throw \"Private directory DACL is not owner-only inheritable full control.\"\n}\n`;\n\nconst WINDOWS_VERIFY_OWNER_ONLY_FILE_ACL_SCRIPT = String.raw`\n$ErrorActionPreference = \"Stop\"\n$filePath = $env:CRABLINE_PRIVATE_FILE_PATH\nif ([string]::IsNullOrWhiteSpace($filePath)) {\n throw \"CRABLINE_PRIVATE_FILE_PATH is required.\"\n}\n\n$identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()\n$sid = $identity.User\nif ($null -eq $sid) {\n throw \"Could not resolve the current Windows user SID.\"\n}\n\n$actual = Get-Acl -LiteralPath $filePath\n$ownerSid = $actual.GetOwner([System.Security.Principal.SecurityIdentifier])\n$rules = @($actual.GetAccessRules(\n $true,\n $true,\n [System.Security.Principal.SecurityIdentifier]\n))\nif (-not $actual.AreAccessRulesProtected) {\n throw \"Private file DACL still inherits permissions.\"\n}\nif ($ownerSid.Value -ne $sid.Value) {\n throw \"Private file owner SID does not match the current user.\"\n}\nif ($rules.Count -ne 1) {\n throw \"Private file DACL must contain exactly one access rule.\"\n}\n$actualRule = $rules[0]\nif (\n $actualRule.IsInherited -or\n $actualRule.IdentityReference.Value -ne $sid.Value -or\n $actualRule.AccessControlType -ne [System.Security.AccessControl.AccessControlType]::Allow -or\n (($actualRule.FileSystemRights -band [System.Security.AccessControl.FileSystemRights]::FullControl) -ne [System.Security.AccessControl.FileSystemRights]::FullControl)\n) {\n throw \"Private file DACL is not owner-only full control.\"\n}\n`;\n\nconst WINDOWS_VERIFY_SAFE_DIRECTORY_ENTRY_PARENT_SCRIPT = String.raw`\n$ErrorActionPreference = \"Stop\"\n$directoryPath = $env:CRABLINE_PRIVATE_DIRECTORY_PATH\nif ([string]::IsNullOrWhiteSpace($directoryPath)) {\n throw \"CRABLINE_PRIVATE_DIRECTORY_PATH is required.\"\n}\n\n$identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()\n$sid = $identity.User\nif ($null -eq $sid) {\n throw \"Could not resolve the current Windows user SID.\"\n}\n\n$trustedSids = @(\n $sid.Value,\n \"S-1-5-18\",\n \"S-1-5-32-544\",\n \"S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464\"\n)\n$ancestorReplacementRights = (\n [System.Security.AccessControl.FileSystemRights]::DeleteSubdirectoriesAndFiles -bor\n [System.Security.AccessControl.FileSystemRights]::Delete -bor\n [System.Security.AccessControl.FileSystemRights]::ChangePermissions -bor\n [System.Security.AccessControl.FileSystemRights]::TakeOwnership\n)\n$ancestorReplacementMask = [BitConverter]::ToUInt32(\n [BitConverter]::GetBytes([int32]$ancestorReplacementRights),\n 0\n)\n$genericAll = [uint32]0x10000000\n$inheritOnly = [System.Security.AccessControl.PropagationFlags]::InheritOnly\n\n$actual = Get-Acl -LiteralPath $directoryPath\n$rawDescriptor = [System.Security.AccessControl.RawSecurityDescriptor]::new(\n $actual.GetSecurityDescriptorBinaryForm(),\n 0\n)\nif (\n (($rawDescriptor.ControlFlags -band\n [System.Security.AccessControl.ControlFlags]::DiscretionaryAclPresent) -eq 0) -or\n $null -eq $rawDescriptor.DiscretionaryAcl\n) {\n throw \"Directory has an absent or null DACL in private mutation ancestry.\"\n}\n$ownerSid = $actual.GetOwner([System.Security.Principal.SecurityIdentifier])\nif ($trustedSids -notcontains $ownerSid.Value) {\n throw \"Directory owner is not trusted for private mutation ancestry.\"\n}\n$rules = @($actual.GetAccessRules(\n $true,\n $true,\n [System.Security.Principal.SecurityIdentifier]\n))\nforeach ($rule in $rules) {\n $ruleAccessMask = [BitConverter]::ToUInt32(\n [BitConverter]::GetBytes([int32]$rule.FileSystemRights),\n 0\n )\n $appliesToDirectory = ($rule.PropagationFlags -band $inheritOnly) -eq 0\n if (\n $appliesToDirectory -and\n $rule.AccessControlType -eq [System.Security.AccessControl.AccessControlType]::Allow -and\n $trustedSids -notcontains $rule.IdentityReference.Value -and\n ($ruleAccessMask -band ($ancestorReplacementMask -bor $genericAll)) -ne 0\n ) {\n throw \"Directory grants child-deletion rights to an untrusted principal.\"\n }\n}\n`;\n\nconst WINDOWS_VERIFY_SAFE_DIRECTORY_MUTATION_BOUNDARY_SCRIPT = String.raw`\n$ErrorActionPreference = \"Stop\"\n$directoryPath = $env:CRABLINE_PRIVATE_DIRECTORY_PATH\nif ([string]::IsNullOrWhiteSpace($directoryPath)) {\n throw \"CRABLINE_PRIVATE_DIRECTORY_PATH is required.\"\n}\n\n$identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()\n$sid = $identity.User\nif ($null -eq $sid) {\n throw \"Could not resolve the current Windows user SID.\"\n}\n\n$trustedSids = @(\n $sid.Value,\n \"S-1-5-18\",\n \"S-1-5-32-544\",\n \"S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464\"\n)\n$mutationRights = (\n [System.Security.AccessControl.FileSystemRights]::WriteData -bor\n [System.Security.AccessControl.FileSystemRights]::AppendData -bor\n [System.Security.AccessControl.FileSystemRights]::WriteExtendedAttributes -bor\n [System.Security.AccessControl.FileSystemRights]::WriteAttributes -bor\n [System.Security.AccessControl.FileSystemRights]::Delete -bor\n [System.Security.AccessControl.FileSystemRights]::DeleteSubdirectoriesAndFiles -bor\n [System.Security.AccessControl.FileSystemRights]::ChangePermissions -bor\n [System.Security.AccessControl.FileSystemRights]::TakeOwnership\n)\n$genericMutationRights = [uint32]0x50000000\n$inheritOnly = [System.Security.AccessControl.PropagationFlags]::InheritOnly\n$mutationAccessMask = [BitConverter]::ToUInt32(\n [BitConverter]::GetBytes([int32]$mutationRights),\n 0\n)\n\n$actual = Get-Acl -LiteralPath $directoryPath\n$rawDescriptor = [System.Security.AccessControl.RawSecurityDescriptor]::new(\n $actual.GetSecurityDescriptorBinaryForm(),\n 0\n)\nif (\n (($rawDescriptor.ControlFlags -band\n [System.Security.AccessControl.ControlFlags]::DiscretionaryAclPresent) -eq 0) -or\n $null -eq $rawDescriptor.DiscretionaryAcl\n) {\n throw \"Directory has an absent or null DACL in private mutation ancestry.\"\n}\n$ownerSid = $actual.GetOwner([System.Security.Principal.SecurityIdentifier])\nif ($trustedSids -notcontains $ownerSid.Value) {\n throw \"Directory owner is not trusted for private mutation ancestry.\"\n}\n$rules = @($actual.GetAccessRules(\n $true,\n $true,\n [System.Security.Principal.SecurityIdentifier]\n))\nforeach ($rule in $rules) {\n $ruleAccessMask = [BitConverter]::ToUInt32(\n [BitConverter]::GetBytes([int32]$rule.FileSystemRights),\n 0\n )\n $appliesToDirectory = ($rule.PropagationFlags -band $inheritOnly) -eq 0\n if (\n $appliesToDirectory -and\n $rule.AccessControlType -eq [System.Security.AccessControl.AccessControlType]::Allow -and\n $trustedSids -notcontains $rule.IdentityReference.Value -and\n ($ruleAccessMask -band ($mutationAccessMask -bor $genericMutationRights)) -ne 0\n ) {\n throw \"Directory grants mutation rights to an untrusted principal.\"\n }\n}\n`;\n\nexport type WindowsAclRunner = (\n command: string,\n args: string[],\n options: {\n env: NodeJS.ProcessEnv;\n killSignal: NodeJS.Signals;\n timeout: number;\n windowsHide: boolean;\n },\n) => Promise<string>;\n\nconst runWindowsAclCommand: WindowsAclRunner = async (command, args, options) => {\n const result = await execFileAsync(command, args, { ...options, encoding: \"utf8\" });\n return result.stdout;\n};\n\nexport function resolveWindowsPowerShellPath(systemRoot: string | null | undefined): string {\n const normalizedRoot = systemRoot?.trim() ? path.win32.normalize(systemRoot.trim()) : undefined;\n if (!normalizedRoot || !/^[A-Za-z]:\\\\/.test(normalizedRoot)) {\n throw new Error(\"SystemRoot must be an absolute local Windows path.\");\n }\n return path.win32.join(normalizedRoot, \"System32\", \"WindowsPowerShell\", \"v1.0\", \"powershell.exe\");\n}\n\nexport async function createOwnerOnlyWindowsFile(\n filePath: string,\n run: WindowsAclRunner = runWindowsAclCommand,\n systemRoot: string | null | undefined = process.env.SystemRoot,\n): Promise<FileIdentity> {\n try {\n const powershellPath = resolveWindowsPowerShellPath(systemRoot);\n const output = await run(\n powershellPath,\n [\n \"-NoLogo\",\n \"-NoProfile\",\n \"-NonInteractive\",\n \"-Command\",\n WINDOWS_CREATE_OWNER_ONLY_FILE_SCRIPT,\n ],\n {\n env: {\n ...process.env,\n CRABLINE_PRIVATE_FILE_PATH: path.resolve(filePath),\n },\n killSignal: \"SIGKILL\",\n timeout: WINDOWS_ACL_COMMAND_TIMEOUT_MS,\n windowsHide: true,\n },\n );\n const match = /^(\\d+):(\\d+)$/u.exec(output.trim());\n if (!match) {\n throw new Error(\"Windows did not return a stable private file identity.\");\n }\n const identity = {\n device: BigInt(match[1]!),\n inode: BigInt(match[2]!),\n };\n if (identity.inode <= 0n) {\n throw new Error(\"Windows did not return a stable private file identity.\");\n }\n return identity;\n } catch (error) {\n throw new Error(\n \"Could not atomically create and verify an owner-only Windows private file; Windows PowerShell ACL support is required.\",\n { cause: error },\n );\n }\n}\n\nexport async function applyOwnerOnlyWindowsDirectoryAcl(\n directoryPath: string,\n run: WindowsAclRunner = runWindowsAclCommand,\n systemRoot: string | null | undefined = process.env.SystemRoot,\n): Promise<void> {\n await applyOwnerOnlyWindowsDirectoryAclByHandle(directoryPath, run, systemRoot);\n}\n\nexport async function createOwnerOnlyWindowsDirectoryAncestry(\n directoryPath: string,\n run: WindowsAclRunner = runWindowsAclCommand,\n systemRoot: string | null | undefined = process.env.SystemRoot,\n): Promise<string | undefined> {\n try {\n return await createOwnerOnlyWindowsDirectoryAncestryByHandle(directoryPath, run, systemRoot);\n } catch (error) {\n throw new Error(\n \"Could not atomically create and verify owner-only Windows private directory ancestry; Windows PowerShell security descriptor support is required.\",\n { cause: error },\n );\n }\n}\n\nexport async function verifyOwnerOnlyWindowsDirectoryAcl(\n directoryPath: string,\n run: WindowsAclRunner = runWindowsAclCommand,\n systemRoot: string | null | undefined = process.env.SystemRoot,\n): Promise<void> {\n try {\n const powershellPath = resolveWindowsPowerShellPath(systemRoot);\n await run(\n powershellPath,\n [\n \"-NoLogo\",\n \"-NoProfile\",\n \"-NonInteractive\",\n \"-Command\",\n WINDOWS_VERIFY_OWNER_ONLY_DIRECTORY_ACL_SCRIPT,\n ],\n {\n env: {\n ...process.env,\n CRABLINE_PRIVATE_DIRECTORY_PATH: path.resolve(directoryPath),\n },\n killSignal: \"SIGKILL\",\n timeout: WINDOWS_ACL_COMMAND_TIMEOUT_MS,\n windowsHide: true,\n },\n );\n } catch (error) {\n throw new Error(\"Private mutation parent must have an owner-only protected Windows ACL.\", {\n cause: error,\n });\n }\n}\n\nexport async function verifyOwnerOnlyWindowsFileAcl(\n filePath: string,\n run: WindowsAclRunner = runWindowsAclCommand,\n systemRoot: string | null | undefined = process.env.SystemRoot,\n): Promise<void> {\n try {\n const powershellPath = resolveWindowsPowerShellPath(systemRoot);\n await run(\n powershellPath,\n [\n \"-NoLogo\",\n \"-NoProfile\",\n \"-NonInteractive\",\n \"-Command\",\n WINDOWS_VERIFY_OWNER_ONLY_FILE_ACL_SCRIPT,\n ],\n {\n env: {\n ...process.env,\n CRABLINE_PRIVATE_FILE_PATH: path.resolve(filePath),\n },\n killSignal: \"SIGKILL\",\n timeout: WINDOWS_ACL_COMMAND_TIMEOUT_MS,\n windowsHide: true,\n },\n );\n } catch (error) {\n throw new Error(\"Private mutation claim must have an owner-only protected Windows ACL.\", {\n cause: error,\n });\n }\n}\n\nexport async function verifySafeWindowsDirectoryEntryParent(\n directoryPath: string,\n run: WindowsAclRunner = runWindowsAclCommand,\n systemRoot: string | null | undefined = process.env.SystemRoot,\n): Promise<void> {\n try {\n const powershellPath = resolveWindowsPowerShellPath(systemRoot);\n await run(\n powershellPath,\n [\n \"-NoLogo\",\n \"-NoProfile\",\n \"-NonInteractive\",\n \"-Command\",\n WINDOWS_VERIFY_SAFE_DIRECTORY_ENTRY_PARENT_SCRIPT,\n ],\n {\n env: {\n ...process.env,\n CRABLINE_PRIVATE_DIRECTORY_PATH: path.resolve(directoryPath),\n },\n killSignal: \"SIGKILL\",\n timeout: WINDOWS_ACL_COMMAND_TIMEOUT_MS,\n windowsHide: true,\n },\n );\n } catch (error) {\n throw new Error(\"Private mutation boundary has a replaceable Windows ancestor.\", {\n cause: error,\n });\n }\n}\n\nexport async function verifySafeWindowsDirectoryMutationBoundary(\n directoryPath: string,\n run: WindowsAclRunner = runWindowsAclCommand,\n systemRoot: string | null | undefined = process.env.SystemRoot,\n): Promise<void> {\n try {\n const powershellPath = resolveWindowsPowerShellPath(systemRoot);\n await run(\n powershellPath,\n [\n \"-NoLogo\",\n \"-NoProfile\",\n \"-NonInteractive\",\n \"-Command\",\n WINDOWS_VERIFY_SAFE_DIRECTORY_MUTATION_BOUNDARY_SCRIPT,\n ],\n {\n env: {\n ...process.env,\n CRABLINE_PRIVATE_DIRECTORY_PATH: path.resolve(directoryPath),\n },\n killSignal: \"SIGKILL\",\n timeout: WINDOWS_ACL_COMMAND_TIMEOUT_MS,\n windowsHide: true,\n },\n );\n } catch (error) {\n throw new Error(\"Private mutation ancestry has an unsafe Windows ACL.\", {\n cause: error,\n });\n }\n}\n\ntype FileIdentity = {\n device: bigint;\n inode: bigint;\n};\n\nfunction assertSameFileIdentity(actual: FileIdentity, expected: FileIdentity): void {\n if (actual.device !== expected.device || actual.inode !== expected.inode) {\n throw new Error(\"Private file path identity changed during publication.\");\n }\n}\n\nasync function readHandleIdentity(handle: FileHandle): Promise<FileIdentity> {\n const stats = await handle.stat({ bigint: true });\n if (stats.ino <= 0n) {\n throw new Error(\"The filesystem did not provide a stable private file identity.\");\n }\n return {\n device: stats.dev,\n inode: stats.ino,\n };\n}\n\nasync function assertPathIdentity(filePath: string, expected: FileIdentity): Promise<void> {\n try {\n const stats = await fs.lstat(filePath, { bigint: true });\n if (\n stats.isFile() &&\n stats.nlink === 1n &&\n stats.dev === expected.device &&\n stats.ino === expected.inode\n ) {\n return;\n }\n } catch (error) {\n throw new Error(\"Private file path identity changed during publication.\", { cause: error });\n }\n throw new Error(\"Private file path identity changed during publication.\");\n}\n\nasync function pathHasFileIdentity(filePath: string, expected: FileIdentity): Promise<boolean> {\n try {\n const stats = await fs.lstat(filePath, { bigint: true });\n return (\n stats.isFile() &&\n stats.nlink === 1n &&\n stats.dev === expected.device &&\n stats.ino === expected.inode\n );\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n return false;\n }\n throw error;\n }\n}\n\ntype DirectoryIdentity = {\n device: bigint;\n inode: bigint;\n userId: bigint;\n};\n\nasync function readDirectoryHandleIdentity(handle: FileHandle): Promise<DirectoryIdentity> {\n const stats = await handle.stat({ bigint: true });\n if (!stats.isDirectory() || stats.ino <= 0n) {\n throw new Error(\"The filesystem did not provide a stable private directory identity.\");\n }\n return {\n device: stats.dev,\n inode: stats.ino,\n userId: stats.uid,\n };\n}\n\nasync function assertDirectoryPathIdentity(\n directoryPath: string,\n expected: DirectoryIdentity,\n): Promise<void> {\n try {\n const stats = await fs.lstat(directoryPath, { bigint: true });\n if (stats.isDirectory() && stats.dev === expected.device && stats.ino === expected.inode) {\n return;\n }\n } catch (error) {\n throw new Error(\"Private directory path identity changed during publication.\", {\n cause: error,\n });\n }\n throw new Error(\"Private directory path identity changed during publication.\");\n}\n\nexport type SecuredPrivateDirectory = {\n assertIdentityAt(directoryPath?: string): Promise<void>;\n directoryPath: string;\n};\n\nexport async function captureDirectoryIdentity(\n directoryPath: string,\n): Promise<SecuredPrivateDirectory> {\n const handle = await fs.open(directoryPath, \"r\");\n try {\n const identity = await readDirectoryHandleIdentity(handle);\n const secured: SecuredPrivateDirectory = {\n async assertIdentityAt(currentPath = directoryPath) {\n await assertDirectoryPathIdentity(currentPath, identity);\n },\n directoryPath,\n };\n await secured.assertIdentityAt();\n return secured;\n } finally {\n await handle.close();\n }\n}\n\nexport async function syncParentDirectory(\n filePath: string,\n platform: NodeJS.Platform = process.platform,\n): Promise<void> {\n if (platform === \"win32\") {\n return;\n }\n const handle = await fs.open(path.dirname(filePath), \"r\");\n try {\n await handle.sync();\n } finally {\n await handle.close();\n }\n}\n\nasync function syncParentAtAccessibleBoundary(\n filePath: string,\n syncParent: (filePath: string, platform?: NodeJS.Platform) => Promise<void>,\n platform?: NodeJS.Platform,\n): Promise<boolean> {\n try {\n await syncParent(filePath, platform);\n return true;\n } catch (error) {\n const code = (error as NodeJS.ErrnoException).code;\n if (code === \"EACCES\" || code === \"EPERM\") {\n return false;\n }\n throw error;\n }\n}\n\nasync function syncPathAncestry(\n filePath: string,\n syncParent: (filePath: string, platform?: NodeJS.Platform) => Promise<void>,\n platform?: NodeJS.Platform,\n firstCreatedDirectory?: string,\n): Promise<void> {\n const resolvedFilePath = path.resolve(filePath);\n let currentPath = resolvedFilePath;\n const syncThroughPath =\n firstCreatedDirectory === undefined ? undefined : path.resolve(firstCreatedDirectory);\n for (;;) {\n const mandatory = syncThroughPath !== undefined || currentPath === resolvedFilePath;\n if (mandatory) {\n await syncParent(currentPath, platform);\n } else if (!(await syncParentAtAccessibleBoundary(currentPath, syncParent, platform))) {\n return;\n }\n if (currentPath === syncThroughPath) {\n return;\n }\n const parentPath = path.dirname(currentPath);\n if (path.dirname(parentPath) === parentPath) {\n return;\n }\n currentPath = parentPath;\n }\n}\n\nasync function darwinDirectoryHasExtendedAcl(directoryPath: string): Promise<boolean> {\n if (process.platform !== \"darwin\") {\n return false;\n }\n let output: string;\n try {\n const result = await execFileAsync(\"/bin/ls\", [\"-lde\", directoryPath], {\n encoding: \"utf8\",\n env: { ...process.env, LC_ALL: \"C\" },\n maxBuffer: 64 * 1024,\n });\n output = result.stdout;\n } catch (error) {\n throw new Error(\"Could not verify the private directory macOS ACL.\", { cause: error });\n }\n const mode = output.trimStart().split(/\\s+/u, 1)[0] ?? \"\";\n return mode.includes(\"+\");\n}\n\nasync function assertDarwinDirectoryHasNoExtendedAcl(directoryPath: string): Promise<void> {\n if (await darwinDirectoryHasExtendedAcl(directoryPath)) {\n throw new Error(\"Private directory must not have a macOS extended ACL.\");\n }\n}\n\nasync function removeDarwinExtendedAcl(directoryPath: string): Promise<void> {\n if (process.platform !== \"darwin\") {\n return;\n }\n try {\n await execFileAsync(\"/bin/chmod\", [\"-N\", directoryPath], {\n encoding: \"utf8\",\n env: { ...process.env, LC_ALL: \"C\" },\n maxBuffer: 64 * 1024,\n });\n } catch (error) {\n throw new Error(\"Could not remove the legacy private directory macOS ACL.\", {\n cause: error,\n });\n }\n}\n\nasync function nearestExistingDirectory(directoryPath: string): Promise<string> {\n let currentPath = path.resolve(directoryPath);\n for (;;) {\n try {\n const stats = await fs.lstat(currentPath);\n if (!stats.isDirectory()) {\n throw new Error(\"Private directory ancestry contains a non-directory entry.\");\n }\n return currentPath;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw error;\n }\n }\n const parentPath = path.dirname(currentPath);\n if (parentPath === currentPath) {\n throw new Error(\"Private directory ancestry has no existing parent.\");\n }\n currentPath = parentPath;\n }\n}\n\nasync function assertDarwinCreatedAncestryHasNoExtendedAcl(\n firstCreatedDirectory: string | undefined,\n finalDirectory: string,\n): Promise<void> {\n if (process.platform !== \"darwin\" || firstCreatedDirectory === undefined) {\n return;\n }\n const firstCreatedPath = path.resolve(firstCreatedDirectory);\n let currentPath = path.resolve(finalDirectory);\n const createdPaths: string[] = [];\n for (;;) {\n createdPaths.push(currentPath);\n if (currentPath === firstCreatedPath) {\n break;\n }\n const parentPath = path.dirname(currentPath);\n if (parentPath === currentPath) {\n throw new Error(\"Private directory ancestry creation boundary is invalid.\");\n }\n currentPath = parentPath;\n }\n for (const createdPath of createdPaths.reverse()) {\n await assertDarwinDirectoryHasNoExtendedAcl(createdPath);\n }\n}\n\nasync function captureSingleSafePrivateMutationBoundary(\n directoryPath: string,\n platform: NodeJS.Platform,\n stickyTargetOwnedByCurrentUser: boolean,\n): Promise<SecuredPrivateDirectory> {\n if (platform === \"win32\" && process.platform === \"win32\") {\n await verifySafeWindowsDirectoryMutationBoundary(directoryPath);\n return await captureDirectoryIdentity(directoryPath);\n }\n\n const currentUserId = process.geteuid?.();\n if (currentUserId === undefined || !Number.isSafeInteger(currentUserId) || currentUserId < 0) {\n throw new Error(\"Could not resolve the current POSIX user for private mutation.\");\n }\n const stats = await fs.lstat(directoryPath, { bigint: true });\n if (!stats.isDirectory()) {\n throw new Error(\"Private mutation boundary is not a directory.\");\n }\n const writableByAnotherPrincipal = (stats.mode & 0o022n) !== 0n;\n const trustedOwner = stats.uid === BigInt(currentUserId) || stats.uid === 0n;\n if (!trustedOwner) {\n throw new Error(\"Private mutation boundary is not owned by the current POSIX user or root.\");\n }\n const protectedByStickyOwnership =\n trustedOwner && (stats.mode & 0o1000n) !== 0n && stickyTargetOwnedByCurrentUser;\n if (writableByAnotherPrincipal && !protectedByStickyOwnership) {\n throw new Error(\"Private mutation boundary is writable by another POSIX principal.\");\n }\n await assertDarwinDirectoryHasNoExtendedAcl(directoryPath);\n return await captureDirectoryIdentity(directoryPath);\n}\n\nasync function captureSafePrivateMutationBoundary(\n directoryPath: string,\n platform: NodeJS.Platform,\n stickyTargetOwnedByCurrentUser: boolean,\n): Promise<SecuredPrivateDirectory> {\n const resolvedBoundaryPath = path.resolve(directoryPath);\n const boundary = await captureSingleSafePrivateMutationBoundary(\n resolvedBoundaryPath,\n platform,\n stickyTargetOwnedByCurrentUser,\n );\n return await capturePrivateMutationPathAncestry(resolvedBoundaryPath, platform, boundary);\n}\n\nasync function capturePrivateMutationPathAncestry(\n directoryPath: string,\n platform: NodeJS.Platform,\n boundary?: SecuredPrivateDirectory,\n): Promise<SecuredPrivateDirectory> {\n const resolvedBoundaryPath = path.resolve(directoryPath);\n const capturedBoundary = boundary ?? (await captureDirectoryIdentity(resolvedBoundaryPath));\n const ancestors: SecuredPrivateDirectory[] = [];\n let childPath = await fs.realpath(resolvedBoundaryPath);\n for (;;) {\n const parentPath = path.dirname(childPath);\n if (parentPath === childPath) {\n break;\n }\n if (platform === \"win32\" && process.platform === \"win32\") {\n await verifySafeWindowsDirectoryEntryParent(parentPath);\n ancestors.push(await captureDirectoryIdentity(parentPath));\n } else {\n const childStats = await fs.lstat(childPath, { bigint: true });\n const currentUserId = process.geteuid?.();\n const childOwnedByTrustedPrincipal =\n currentUserId !== undefined &&\n (childStats.uid === BigInt(currentUserId) || childStats.uid === 0n);\n ancestors.push(\n await captureSingleSafePrivateMutationBoundary(\n parentPath,\n platform,\n childOwnedByTrustedPrincipal,\n ),\n );\n }\n childPath = parentPath;\n }\n return {\n async assertIdentityAt(currentPath = resolvedBoundaryPath) {\n for (const ancestor of [...ancestors].reverse()) {\n await ancestor.assertIdentityAt();\n }\n await capturedBoundary.assertIdentityAt(currentPath);\n },\n directoryPath: resolvedBoundaryPath,\n };\n}\n\nasync function captureSafePrivateDirectoryMutationParent(\n currentPath: string,\n platform: NodeJS.Platform,\n): Promise<SecuredPrivateDirectory> {\n if (platform === \"win32\" && process.platform === \"win32\") {\n return await captureSafePrivateMutationBoundary(path.dirname(currentPath), platform, true);\n }\n const currentUserId = process.geteuid?.();\n const targetStats = await fs.lstat(currentPath, { bigint: true });\n return await captureSafePrivateMutationBoundary(\n path.dirname(currentPath),\n platform,\n currentUserId !== undefined &&\n targetStats.isDirectory() &&\n targetStats.uid === BigInt(currentUserId),\n );\n}\n\nexport async function removeSecuredPrivateDirectory(\n secured: SecuredPrivateDirectory,\n currentPath = secured.directoryPath,\n quarantineBaseName = path.basename(currentPath),\n options: {\n beforeRecursiveRemove?: (quarantinePath: string) => Promise<void>;\n beforeRename?: (currentPath: string) => Promise<void>;\n claimRuntime?: PrivateMutationClaimRuntime;\n createWindowsFile?: (filePath: string) => Promise<FileIdentity>;\n platform?: NodeJS.Platform;\n removeDirectory?: (quarantinePath: string) => Promise<void>;\n syncParent?: (filePath: string, platform?: NodeJS.Platform) => Promise<void>;\n } = {},\n): Promise<void> {\n if (path.basename(quarantineBaseName) !== quarantineBaseName || quarantineBaseName.length === 0) {\n throw new Error(\"Private directory quarantine basename is malformed.\");\n }\n const quarantinePath = path.join(\n path.dirname(currentPath),\n `.${quarantineBaseName}.${process.pid}.${randomUUID()}.remove`,\n );\n const platform = options.platform ?? process.platform;\n const parent = await captureSafePrivateDirectoryMutationParent(currentPath, platform);\n const claimParent: SecuredPrivateDirectory = {\n assertIdentityAt: (candidatePath = currentPath) => secured.assertIdentityAt(candidatePath),\n directoryPath: currentPath,\n };\n const claim = await acquirePrivateMutationClaimChain(claimParent, {\n ...(options.claimRuntime ? { runtime: options.claimRuntime } : {}),\n ...(options.createWindowsFile ? { createWindowsFile: options.createWindowsFile } : {}),\n ...(options.platform ? { platform: options.platform } : {}),\n });\n let removalFailed = false;\n let primaryError: unknown;\n try {\n await parent.assertIdentityAt();\n await claim.assertOwned();\n await secured.assertIdentityAt(currentPath);\n await options.beforeRename?.(currentPath);\n await parent.assertIdentityAt();\n await claim.assertOwned();\n await secured.assertIdentityAt(currentPath);\n await fs.rename(currentPath, quarantinePath);\n await parent.assertIdentityAt();\n await secured.assertIdentityAt(quarantinePath);\n await claim.relocateParent(quarantinePath);\n await claim.assertOwned();\n const syncParent = options.syncParent ?? syncParentDirectory;\n await syncParent(quarantinePath, options.platform);\n await options.beforeRecursiveRemove?.(quarantinePath);\n await parent.assertIdentityAt();\n await claim.assertOwned();\n await secured.assertIdentityAt(quarantinePath);\n await claim.prepareContainerRemoval();\n await (\n options.removeDirectory ??\n ((candidatePath: string) => fs.rm(candidatePath, { force: true, recursive: true }))\n )(quarantinePath);\n await claim.completeContainerRemoval();\n await parent.assertIdentityAt();\n await syncParent(quarantinePath, options.platform);\n } catch (error) {\n removalFailed = true;\n primaryError = error;\n }\n\n try {\n await claim.release();\n } catch (releaseError) {\n if (removalFailed) {\n const aggregateError = new AggregateError(\n [primaryError, releaseError],\n \"Private directory removal failed and its mutation claim could not be released.\",\n );\n aggregateError.cause = primaryError;\n throw aggregateError;\n }\n throw releaseError;\n }\n if (removalFailed) {\n throw primaryError;\n }\n}\n\nexport async function securePrivateDirectory(\n directoryPath: string,\n options: {\n createWindowsDirectories?: (directoryPath: string) => Promise<string | undefined>;\n currentUserId?: number;\n markMutationRoot?: boolean;\n platform?: NodeJS.Platform;\n secureWindowsDirectory?: (directoryPath: string) => Promise<void>;\n syncDirectory?: () => Promise<void>;\n syncParent?: (filePath: string, platform?: NodeJS.Platform) => Promise<void>;\n } = {},\n): Promise<SecuredPrivateDirectory> {\n const platform = options.platform ?? process.platform;\n let created = false;\n let createdAtomically = false;\n if (platform === \"win32\") {\n try {\n await fs.lstat(directoryPath);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw error;\n }\n const createWindowsDirectories =\n options.createWindowsDirectories ??\n (process.platform === \"win32\" || options.secureWindowsDirectory === undefined\n ? createOwnerOnlyWindowsDirectoryAncestry\n : async (candidatePath: string) => {\n await fs.mkdir(candidatePath);\n return candidatePath;\n });\n const firstCreatedDirectory = await createWindowsDirectories(directoryPath);\n if (firstCreatedDirectory === undefined) {\n throw new Error(\"Windows private directory creation did not create the requested path.\", {\n cause: error,\n });\n }\n created = true;\n createdAtomically =\n options.createWindowsDirectories !== undefined || process.platform === \"win32\";\n }\n } else {\n let existed = false;\n try {\n await fs.lstat(directoryPath);\n existed = true;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw error;\n }\n }\n if (!existed) {\n await assertDarwinDirectoryHasNoExtendedAcl(path.dirname(directoryPath));\n }\n try {\n await fs.mkdir(directoryPath, { mode: 0o700 });\n created = true;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") {\n throw error;\n }\n }\n }\n\n const handle = await fs.open(directoryPath, \"r\");\n let handleOpen = true;\n const closeHandle = async () => {\n if (!handleOpen) {\n return;\n }\n handleOpen = false;\n await handle.close();\n };\n let identity: DirectoryIdentity;\n try {\n identity = await readDirectoryHandleIdentity(handle);\n } catch (error) {\n try {\n await closeHandle();\n } catch (closeError) {\n const aggregateError = new AggregateError(\n [error, closeError],\n \"Private directory identity verification failed and its handle could not be closed.\",\n );\n aggregateError.cause = error;\n throw aggregateError;\n }\n throw error;\n }\n const secured: SecuredPrivateDirectory = {\n async assertIdentityAt(currentPath = directoryPath) {\n await assertDirectoryPathIdentity(currentPath, identity);\n },\n directoryPath,\n };\n try {\n await secured.assertIdentityAt();\n if (platform === \"win32\") {\n if (!createdAtomically) {\n await (options.secureWindowsDirectory ?? applyOwnerOnlyWindowsDirectoryAcl)(directoryPath);\n }\n if (process.platform !== \"win32\") {\n await handle.chmod(0o700);\n }\n } else {\n const currentUserId = options.currentUserId ?? process.geteuid?.();\n if (\n currentUserId === undefined ||\n !Number.isSafeInteger(currentUserId) ||\n currentUserId < 0 ||\n identity.userId !== BigInt(currentUserId)\n ) {\n throw new Error(\"Private directory must be owned by the current POSIX user.\");\n }\n if (!created) {\n await removeDarwinExtendedAcl(directoryPath);\n }\n const currentStats = await handle.stat({ bigint: true });\n const mutationRootMode =\n options.markMutationRoot === false ? currentStats.mode & 0o1000n : 0o1000n;\n await handle.chmod(Number(0o700n | mutationRootMode));\n await assertDarwinDirectoryHasNoExtendedAcl(directoryPath);\n await (options.syncDirectory ?? (() => handle.sync()))();\n }\n await secured.assertIdentityAt();\n const syncParent = options.syncParent ?? syncParentDirectory;\n if (created) {\n await syncParent(directoryPath, options.platform);\n } else {\n await syncParentAtAccessibleBoundary(directoryPath, syncParent, options.platform);\n }\n } catch (error) {\n let primaryError = error;\n try {\n await closeHandle();\n } catch (closeError) {\n const aggregateError = new AggregateError(\n [error, closeError],\n \"Private directory securing failed and its verification handle could not be closed.\",\n );\n aggregateError.cause = error;\n primaryError = aggregateError;\n }\n if (created) {\n try {\n await removeSecuredPrivateDirectory(secured);\n } catch (cleanupError) {\n const aggregateError = new AggregateError(\n [primaryError, cleanupError],\n `Private directory securing failed and rollback cleanup also failed: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n aggregateError.cause = primaryError;\n throw aggregateError;\n }\n }\n throw primaryError;\n } finally {\n await closeHandle();\n }\n\n return secured;\n}\n\ntype PrivateMutationClaim = {\n assertOwned(): Promise<void>;\n completeContainerRemoval(): Promise<void>;\n prepareContainerRemoval(): Promise<void>;\n relocateParent(directoryPath: string): Promise<void>;\n release(): Promise<void>;\n};\n\ntype PrivateMutationClaimWaitOptions = {\n now?: () => number;\n retryDelayMs?: number;\n signal?: AbortSignal;\n sleep?: (delayMs: number, signal?: AbortSignal) => Promise<void>;\n timeoutMs?: number;\n};\n\ntype PreparedPrivateMutationClaimWait = {\n now: () => number;\n retryDelayMs: number;\n signal?: AbortSignal;\n sleep: (delayMs: number, signal?: AbortSignal) => Promise<void>;\n timeoutMs: number;\n};\n\nexport type PrivateMutationClaimRuntime = {\n getProcessIdentity(pid: number): string | null;\n isProcessAlive(pid: number): boolean;\n ownerId: string;\n pid: number;\n processIdentity?: string;\n processStartedAtMs: number;\n};\n\ntype PrivateMutationClaimOwner = {\n ownerId: string;\n pid: number;\n processIdentity?: string;\n processStartedAtMs: number;\n};\n\nconst PRIVATE_MUTATION_CLAIM_ROOT_FILE = \".crabline-private-mutation.claim\";\nconst PRIVATE_MUTATION_CLAIM_OWNER_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/u;\nconst PRIVATE_MUTATION_CLAIM_METADATA_MAX_BYTES = 4096;\nconst PRIVATE_MUTATION_RESERVED_BASENAME_PATTERN = /^\\.crabline-private-mutation(?:\\.|$)/iu;\nconst PRIVATE_MUTATION_CLAIM_WAIT_TIMEOUT_MS = 60_000;\nconst PRIVATE_MUTATION_CLAIM_RETRY_DELAY_MS = 50;\n\nfunction preparePrivateMutationClaimWait(\n options: PrivateMutationClaimWaitOptions,\n): PreparedPrivateMutationClaimWait {\n const timeoutMs = options.timeoutMs ?? PRIVATE_MUTATION_CLAIM_WAIT_TIMEOUT_MS;\n const retryDelayMs = options.retryDelayMs ?? PRIVATE_MUTATION_CLAIM_RETRY_DELAY_MS;\n if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 0) {\n throw new Error(\"Private mutation claim wait timeout must be a non-negative safe integer.\");\n }\n if (!Number.isSafeInteger(retryDelayMs) || retryDelayMs <= 0) {\n throw new Error(\"Private mutation claim retry delay must be a positive safe integer.\");\n }\n const now = options.now ?? performance.now.bind(performance);\n const sleep =\n options.sleep ??\n ((delayMs: number, signal?: AbortSignal) => delay(delayMs, undefined, { signal }));\n if (typeof now !== \"function\" || typeof sleep !== \"function\") {\n throw new Error(\"Private mutation claim wait callbacks must be functions.\");\n }\n if (options.signal !== undefined && typeof options.signal.throwIfAborted !== \"function\") {\n throw new Error(\"Private mutation claim wait signal is invalid.\");\n }\n options.signal?.throwIfAborted();\n if (!Number.isFinite(now())) {\n throw new Error(\"Private mutation claim wait clock is invalid.\");\n }\n return {\n now,\n retryDelayMs,\n ...(options.signal ? { signal: options.signal } : {}),\n sleep,\n timeoutMs,\n };\n}\n\nfunction assertNotReservedPrivateMutationPath(targetPath: string): void {\n if (PRIVATE_MUTATION_RESERVED_BASENAME_PATTERN.test(path.basename(targetPath))) {\n throw new Error(\"Private path uses Crabline's reserved mutation claim namespace.\");\n }\n}\n\nfunction isProcessAlive(pid: number): boolean {\n if (!Number.isSafeInteger(pid) || pid <= 0) {\n return false;\n }\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n return (error as NodeJS.ErrnoException).code === \"EPERM\";\n }\n}\n\nfunction processIdentityFromLinuxStat(value: string, bootId: string): string | null {\n const normalizedBootId = bootId.trim();\n if (!/^[0-9a-f-]{16,64}$/iu.test(normalizedBootId)) {\n return null;\n }\n const commandEnd = value.lastIndexOf(\") \");\n if (commandEnd < 0) {\n return null;\n }\n const fields = value\n .slice(commandEnd + 2)\n .trim()\n .split(/\\s+/u);\n const startTicks = fields[19];\n return startTicks && /^\\d+$/u.test(startTicks) ? `linux:${normalizedBootId}:${startTicks}` : null;\n}\n\nfunction processIdentityFromDarwin(processDetails: string, bootTime: string): string | null {\n const bootMatch = /\\bsec = (\\d+), usec = (\\d+)\\b/u.exec(bootTime);\n const launchMatch =\n /^Launch Time:\\s*(\\d{4})-(\\d{2})-(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2})\\.(\\d{3,6}) ([+-])(\\d{2})(\\d{2})$/mu.exec(\n processDetails,\n );\n if (!bootMatch || !launchMatch) {\n return null;\n }\n const [, year, month, day, hour, minute, second, fraction, sign, offsetHour, offsetMinute] =\n launchMatch as RegExpExecArray &\n [string, string, string, string, string, string, string, string, string, string, string];\n const offsetMs =\n (Number(offsetHour) * 60 + Number(offsetMinute)) * 60_000 * (sign === \"+\" ? 1 : -1);\n const fractionMicros = Number(fraction.padEnd(6, \"0\"));\n const utcMilliseconds =\n Date.UTC(\n Number(year),\n Number(month) - 1,\n Number(day),\n Number(hour),\n Number(minute),\n Number(second),\n Math.floor(fractionMicros / 1_000),\n ) - offsetMs;\n if (!Number.isSafeInteger(utcMilliseconds) || utcMilliseconds <= 0) {\n return null;\n }\n const startedAtMicros = BigInt(utcMilliseconds) * 1_000n + BigInt(fractionMicros % 1_000);\n return `darwin:${bootMatch[1]}.${bootMatch[2]}:us:${startedAtMicros}`;\n}\n\nfunction getProcessIdentity(pid: number): string | null {\n if (!Number.isSafeInteger(pid) || pid <= 0) {\n return null;\n }\n if (process.platform === \"linux\") {\n try {\n return processIdentityFromLinuxStat(\n readFileSync(`/proc/${pid}/stat`, \"utf8\"),\n readFileSync(\"/proc/sys/kernel/random/boot_id\", \"utf8\"),\n );\n } catch {\n return null;\n }\n }\n if (process.platform === \"darwin\") {\n const options = {\n encoding: \"utf8\" as const,\n env: { ...process.env, LC_ALL: \"C\", TZ: \"UTC\" },\n maxBuffer: 512 * 1024,\n timeout: 3_000,\n };\n const bootTime = spawnSync(\"/usr/sbin/sysctl\", [\"-n\", \"kern.boottime\"], options);\n const processDetails = spawnSync(\"/usr/bin/vmmap\", [\"-summary\", String(pid)], options);\n return bootTime.status === 0 && processDetails.status === 0\n ? processIdentityFromDarwin(processDetails.stdout, bootTime.stdout)\n : null;\n }\n if (process.platform !== \"win32\") {\n return null;\n }\n let powershellPath: string;\n try {\n powershellPath = resolveWindowsPowerShellPath(process.env.SystemRoot);\n } catch {\n return null;\n }\n const result = spawnSync(\n powershellPath,\n [\n \"-NoProfile\",\n \"-NonInteractive\",\n \"-Command\",\n `(Get-Process -Id ${pid} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks.ToString()`,\n ],\n { encoding: \"utf8\", timeout: 1_000, windowsHide: true },\n );\n const ticks = result.status === 0 ? result.stdout.trim() : \"\";\n return /^\\d+$/u.test(ticks) ? `windows:${ticks}` : null;\n}\n\nlet cachedCurrentProcessIdentity: string | null | undefined;\n\nfunction defaultPrivateMutationClaimRuntime(): PrivateMutationClaimRuntime {\n if (cachedCurrentProcessIdentity === undefined) {\n cachedCurrentProcessIdentity = getProcessIdentity(process.pid);\n }\n return {\n getProcessIdentity,\n isProcessAlive,\n ownerId: randomUUID(),\n pid: process.pid,\n ...(cachedCurrentProcessIdentity ? { processIdentity: cachedCurrentProcessIdentity } : {}),\n processStartedAtMs: Math.floor(performance.timeOrigin),\n };\n}\n\nfunction parsePrivateMutationClaimOwner(contents: string): PrivateMutationClaimOwner {\n let owner: Partial<PrivateMutationClaimOwner>;\n try {\n owner = JSON.parse(contents) as Partial<PrivateMutationClaimOwner>;\n } catch (error) {\n throw new Error(\"Private path mutation claim owner metadata is malformed.\", { cause: error });\n }\n if (\n !Number.isSafeInteger(owner.pid) ||\n Number(owner.pid) <= 0 ||\n typeof owner.ownerId !== \"string\" ||\n !PRIVATE_MUTATION_CLAIM_OWNER_ID_PATTERN.test(owner.ownerId) ||\n !Number.isSafeInteger(owner.processStartedAtMs) ||\n Number(owner.processStartedAtMs) <= 0 ||\n (owner.processIdentity !== undefined &&\n (typeof owner.processIdentity !== \"string\" ||\n owner.processIdentity.length === 0 ||\n owner.processIdentity.length > 256))\n ) {\n throw new Error(\"Private path mutation claim owner metadata is malformed.\");\n }\n return owner as PrivateMutationClaimOwner;\n}\n\nasync function claimPathHasIdentity(\n claimPath: string,\n expected: FileIdentity,\n expectedLinkCount?: bigint,\n): Promise<boolean> {\n try {\n const stats = await fs.lstat(claimPath, { bigint: true });\n return (\n stats.isFile() &&\n (expectedLinkCount === undefined ? stats.nlink >= 1n : stats.nlink === expectedLinkCount) &&\n stats.dev === expected.device &&\n stats.ino === expected.inode\n );\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n return false;\n }\n throw new Error(\"Private path mutation claim identity changed.\", { cause: error });\n }\n}\n\nasync function assertClaimPathIdentity(\n claimPath: string,\n expected: FileIdentity,\n expectedLinkCount?: bigint,\n): Promise<void> {\n if (await claimPathHasIdentity(claimPath, expected, expectedLinkCount)) {\n return;\n }\n throw new Error(\"Private path mutation claim identity changed.\");\n}\n\ntype PrivateMutationClaimRecord = {\n contents: string;\n identity: FileIdentity;\n owner: PrivateMutationClaimOwner;\n};\n\nfunction assertOwnerOnlyPosixMutationClaim(stats: BigIntStats, kind: \"directory\" | \"file\"): void {\n const currentUserId = process.geteuid?.();\n if (currentUserId === undefined || !Number.isSafeInteger(currentUserId) || currentUserId < 0) {\n throw new Error(\"Could not resolve the current POSIX user for private mutation claims.\");\n }\n if (stats.uid !== BigInt(currentUserId) || (stats.mode & 0o077n) !== 0n) {\n throw new Error(`Private mutation claim ${kind} must be owner-only.`);\n }\n}\n\nasync function readPrivateMutationClaim(\n claimPath: string,\n): Promise<PrivateMutationClaimRecord | null> {\n let handle: FileHandle | undefined;\n try {\n handle = await fs.open(\n claimPath,\n process.platform === \"win32\"\n ? \"r\"\n : fsConstants.O_RDONLY | fsConstants.O_NONBLOCK | fsConstants.O_NOFOLLOW,\n );\n const stats = await handle.stat({ bigint: true });\n if (\n !stats.isFile() ||\n stats.ino <= 0n ||\n stats.size <= 0n ||\n stats.size > BigInt(PRIVATE_MUTATION_CLAIM_METADATA_MAX_BYTES)\n ) {\n throw new Error(\"Private path mutation claim metadata size is invalid.\");\n }\n if (process.platform === \"win32\") {\n await verifyOwnerOnlyWindowsFileAcl(claimPath);\n } else {\n assertOwnerOnlyPosixMutationClaim(stats, \"file\");\n }\n const identity = { device: stats.dev, inode: stats.ino };\n const buffer = Buffer.alloc(Number(stats.size));\n let offset = 0;\n while (offset < buffer.length) {\n const { bytesRead } = await handle.read(buffer, offset, buffer.length - offset, offset);\n if (bytesRead === 0) {\n throw new Error(\"Private path mutation claim metadata was truncated while reading.\");\n }\n offset += bytesRead;\n }\n const finalStats = await handle.stat({ bigint: true });\n if (process.platform === \"win32\") {\n await verifyOwnerOnlyWindowsFileAcl(claimPath);\n } else {\n assertOwnerOnlyPosixMutationClaim(finalStats, \"file\");\n }\n if (\n !finalStats.isFile() ||\n finalStats.dev !== stats.dev ||\n finalStats.ino !== stats.ino ||\n finalStats.size !== stats.size\n ) {\n throw new Error(\"Private path mutation claim metadata changed while reading.\");\n }\n const contents = buffer.toString(\"utf8\");\n const owner = parsePrivateMutationClaimOwner(contents);\n // A live owner may release or replace this pathname after our handle opens.\n // The open handle is safe, but its metadata is no longer the active claim.\n if (!(await claimPathHasIdentity(claimPath, identity))) {\n return null;\n }\n return { contents, identity, owner };\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n return null;\n }\n throw error;\n } finally {\n await handle?.close();\n }\n}\n\nfunction nextPrivateMutationClaimPath(parentDirectory: string, ownerContents: string): string {\n const digest = createHash(\"sha256\").update(ownerContents).digest(\"hex\");\n return path.join(parentDirectory, `.crabline-private-mutation.${digest}.claim`);\n}\n\nasync function removeStalePrivateMutationClaimAliases(\n parentDirectory: string,\n staleClaims: Array<PrivateMutationClaimRecord & { claimPath: string }>,\n currentClaimPath: string,\n): Promise<void> {\n const staleIdentities = new Set(\n staleClaims.map(({ identity }) => `${identity.device}:${identity.inode}`),\n );\n for (const entry of await fs.readdir(parentDirectory)) {\n if (!PRIVATE_MUTATION_RESERVED_BASENAME_PATTERN.test(entry)) {\n continue;\n }\n const entryPath = path.join(parentDirectory, entry);\n if (entryPath === currentClaimPath) {\n continue;\n }\n let stats;\n try {\n stats = await fs.lstat(entryPath, { bigint: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n continue;\n }\n throw error;\n }\n if (stats.isFile() && staleIdentities.has(`${stats.dev}:${stats.ino}`)) {\n await fs.unlink(entryPath);\n }\n }\n}\n\nclass UnsupportedPrivateMutationHardLinkError extends Error {\n constructor(cause: unknown) {\n super(\"Private mutation claims require a non-hard-link fallback.\", { cause });\n }\n}\n\nclass ActivePrivateMutationClaimError extends Error {\n constructor(cause: unknown) {\n super(\"Private path mutation is already claimed.\", { cause });\n }\n}\n\nfunction isUnsupportedHardLinkError(error: unknown): boolean {\n const code = (error as NodeJS.ErrnoException).code;\n return code === \"EPERM\" || code === \"ENOTSUP\" || code === \"EOPNOTSUPP\" || code === \"ENOSYS\";\n}\n\nasync function acquireHardLinkPrivateMutationClaim(\n parent: SecuredPrivateDirectory,\n options: {\n createWindowsFile?: (filePath: string) => Promise<FileIdentity>;\n platform?: NodeJS.Platform;\n runtime?: PrivateMutationClaimRuntime;\n },\n): Promise<PrivateMutationClaim> {\n const platform = options.platform ?? process.platform;\n const runtime = options.runtime ?? defaultPrivateMutationClaimRuntime();\n if (\n !Number.isSafeInteger(runtime.pid) ||\n runtime.pid <= 0 ||\n !PRIVATE_MUTATION_CLAIM_OWNER_ID_PATTERN.test(runtime.ownerId) ||\n !Number.isSafeInteger(runtime.processStartedAtMs) ||\n runtime.processStartedAtMs <= 0 ||\n (runtime.processIdentity !== undefined &&\n (runtime.processIdentity.length === 0 || runtime.processIdentity.length > 256))\n ) {\n throw new Error(\"Private path mutation claim runtime is invalid.\");\n }\n if (\n !Number.isSafeInteger(runtime.pid) ||\n runtime.pid <= 0 ||\n !PRIVATE_MUTATION_CLAIM_OWNER_ID_PATTERN.test(runtime.ownerId) ||\n !Number.isSafeInteger(runtime.processStartedAtMs) ||\n runtime.processStartedAtMs <= 0 ||\n (runtime.processIdentity !== undefined &&\n (runtime.processIdentity.length === 0 || runtime.processIdentity.length > 256))\n ) {\n throw new Error(\"Private path mutation claim runtime is invalid.\");\n }\n const ownerContents = `${JSON.stringify({\n ownerId: runtime.ownerId,\n pid: runtime.pid,\n ...(runtime.processIdentity ? { processIdentity: runtime.processIdentity } : {}),\n processStartedAtMs: runtime.processStartedAtMs,\n } satisfies PrivateMutationClaimOwner)}\\n`;\n const rootClaimPath = path.join(parent.directoryPath, PRIVATE_MUTATION_CLAIM_ROOT_FILE);\n const candidatePath = `${rootClaimPath}.${runtime.pid}.${randomUUID()}.candidate`;\n let handle: FileHandle | undefined;\n let identity: FileIdentity | undefined;\n const linkedClaimPaths = new Set<string>();\n try {\n if (platform === \"win32\" && process.platform === \"win32\") {\n const createdIdentity = await (options.createWindowsFile ?? createOwnerOnlyWindowsFile)(\n candidatePath,\n );\n handle = await fs.open(candidatePath, \"r+\");\n identity = await readHandleIdentity(handle);\n assertSameFileIdentity(identity, createdIdentity);\n } else {\n handle = await fs.open(candidatePath, \"wx+\", 0o600);\n identity = await readHandleIdentity(handle);\n await handle.chmod(0o600);\n }\n await handle.writeFile(ownerContents, \"utf8\");\n await handle.sync();\n await assertClaimPathIdentity(candidatePath, identity, 1n);\n\n let claimPath = rootClaimPath;\n const visitedClaimPaths = new Set<string>();\n const staleClaims: Array<PrivateMutationClaimRecord & { claimPath: string }> = [];\n for (;;) {\n if (visitedClaimPaths.has(claimPath)) {\n throw new Error(\"Private path mutation claim chain contains a cycle.\");\n }\n visitedClaimPaths.add(claimPath);\n try {\n await fs.link(candidatePath, claimPath);\n linkedClaimPaths.add(claimPath);\n } catch (error) {\n if (isUnsupportedHardLinkError(error)) {\n throw new UnsupportedPrivateMutationHardLinkError(error);\n }\n if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") {\n throw error;\n }\n await parent.assertIdentityAt();\n const observed = await readPrivateMutationClaim(claimPath);\n if (observed === null) {\n claimPath = rootClaimPath;\n visitedClaimPaths.clear();\n staleClaims.length = 0;\n continue;\n }\n if (runtime.isProcessAlive(observed.owner.pid)) {\n if (\n observed.owner.pid === runtime.pid &&\n observed.owner.processStartedAtMs === runtime.processStartedAtMs\n ) {\n throw new ActivePrivateMutationClaimError(error);\n } else if (observed.owner.pid !== runtime.pid) {\n if (observed.owner.processIdentity === undefined) {\n throw new ActivePrivateMutationClaimError(error);\n }\n const actualIdentity = runtime.getProcessIdentity(observed.owner.pid);\n if (actualIdentity === null || actualIdentity === observed.owner.processIdentity) {\n throw new ActivePrivateMutationClaimError(error);\n }\n }\n }\n const revalidated = await readPrivateMutationClaim(claimPath);\n if (\n revalidated === null ||\n revalidated.identity.device !== observed.identity.device ||\n revalidated.identity.inode !== observed.identity.inode ||\n revalidated.contents !== observed.contents\n ) {\n claimPath = rootClaimPath;\n visitedClaimPaths.clear();\n staleClaims.length = 0;\n continue;\n }\n const duplicateIdentity = staleClaims.find(\n ({ identity: staleIdentity }) =>\n staleIdentity.device === revalidated.identity.device &&\n staleIdentity.inode === revalidated.identity.inode,\n );\n if (duplicateIdentity !== undefined) {\n await parent.assertIdentityAt();\n await assertClaimPathIdentity(claimPath, revalidated.identity);\n await fs.unlink(claimPath);\n await syncParentDirectory(claimPath, options.platform);\n claimPath = rootClaimPath;\n visitedClaimPaths.clear();\n staleClaims.length = 0;\n continue;\n }\n staleClaims.push({ claimPath, ...revalidated });\n claimPath = nextPrivateMutationClaimPath(parent.directoryPath, revalidated.contents);\n continue;\n }\n\n await assertClaimPathIdentity(candidatePath, identity, 2n);\n await assertClaimPathIdentity(claimPath, identity, 2n);\n if (staleClaims.length > 0) {\n const staleRoot = await readPrivateMutationClaim(rootClaimPath);\n const expectedRoot = staleClaims[0]!;\n if (\n staleRoot === null ||\n staleRoot.identity.device !== expectedRoot.identity.device ||\n staleRoot.identity.inode !== expectedRoot.identity.inode ||\n staleRoot.contents !== expectedRoot.contents\n ) {\n throw new Error(\"Private path mutation claim root changed during recovery.\");\n }\n await fs.rename(candidatePath, rootClaimPath);\n linkedClaimPaths.add(rootClaimPath);\n await assertClaimPathIdentity(rootClaimPath, identity, 2n);\n await assertClaimPathIdentity(claimPath, identity, 2n);\n await fs.unlink(claimPath);\n linkedClaimPaths.delete(claimPath);\n claimPath = rootClaimPath;\n await assertClaimPathIdentity(claimPath, identity, 1n);\n await removeStalePrivateMutationClaimAliases(parent.directoryPath, staleClaims, claimPath);\n } else {\n await fs.unlink(candidatePath);\n }\n await assertClaimPathIdentity(claimPath, identity, 1n);\n await parent.assertIdentityAt();\n await syncParentDirectory(claimPath, options.platform);\n linkedClaimPaths.clear();\n\n let released = false;\n const claimHandle = handle;\n let claimHandleOpen = true;\n let ownedClaimPath = claimPath;\n let ownedParentPath = parent.directoryPath;\n const claimIdentity = identity;\n const closeClaimHandle = async () => {\n if (!claimHandleOpen) {\n return;\n }\n claimHandleOpen = false;\n await claimHandle.close();\n };\n const assertOwned = async () => {\n await parent.assertIdentityAt(ownedParentPath);\n await assertClaimPathIdentity(ownedClaimPath, claimIdentity, 1n);\n const observed = await readPrivateMutationClaim(ownedClaimPath);\n if (\n observed === null ||\n observed.identity.device !== claimIdentity.device ||\n observed.identity.inode !== claimIdentity.inode ||\n observed.contents !== ownerContents\n ) {\n throw new Error(\"Private path mutation claim owner metadata changed.\");\n }\n };\n return {\n assertOwned,\n async completeContainerRemoval() {\n if (released) {\n return;\n }\n let completionError: unknown;\n try {\n await fs.lstat(ownedParentPath);\n completionError = new Error(\n \"Private directory path still exists after recursive removal.\",\n );\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n completionError = error;\n }\n }\n try {\n await closeClaimHandle();\n } catch (closeError) {\n if (completionError !== undefined) {\n const aggregateError = new AggregateError(\n [completionError, closeError],\n \"Private directory removal verification failed and its claim handle could not be closed.\",\n );\n aggregateError.cause = completionError;\n throw aggregateError;\n }\n throw closeError;\n }\n if (completionError !== undefined) {\n throw completionError;\n }\n released = true;\n },\n async prepareContainerRemoval() {\n if (released) {\n throw new Error(\"Private path mutation claim has already been released.\");\n }\n await assertOwned();\n await closeClaimHandle();\n await assertOwned();\n },\n async relocateParent(directoryPath: string) {\n if (released) {\n throw new Error(\"Private path mutation claim has already been released.\");\n }\n const relocatedClaimPath = path.join(directoryPath, path.basename(ownedClaimPath));\n await parent.assertIdentityAt(directoryPath);\n const observed = await readPrivateMutationClaim(relocatedClaimPath);\n if (\n observed === null ||\n observed.identity.device !== claimIdentity.device ||\n observed.identity.inode !== claimIdentity.inode ||\n observed.contents !== ownerContents\n ) {\n throw new Error(\"Private path mutation claim identity changed during relocation.\");\n }\n ownedParentPath = directoryPath;\n ownedClaimPath = relocatedClaimPath;\n },\n async release() {\n if (released) {\n return;\n }\n const releasePath = `${ownedClaimPath}.${randomUUID()}.release`;\n let releaseError: unknown;\n try {\n await assertOwned();\n await fs.rename(ownedClaimPath, releasePath);\n await assertClaimPathIdentity(releasePath, claimIdentity, 1n);\n if ((await fs.readFile(releasePath, \"utf8\")) !== ownerContents) {\n throw new Error(\"Private path mutation claim owner metadata changed.\");\n }\n await fs.unlink(releasePath);\n released = true;\n await parent.assertIdentityAt(ownedParentPath);\n await syncParentDirectory(ownedClaimPath, options.platform);\n } catch (error) {\n releaseError = error;\n }\n try {\n await closeClaimHandle();\n } catch (closeError) {\n if (releaseError !== undefined) {\n const aggregateError = new AggregateError(\n [releaseError, closeError],\n \"Private path mutation claim release failed and its handle could not be closed.\",\n );\n aggregateError.cause = releaseError;\n throw aggregateError;\n }\n throw closeError;\n }\n if (releaseError !== undefined) {\n throw releaseError;\n }\n },\n };\n }\n } catch (error) {\n const cleanupErrors: unknown[] = [];\n if (identity !== undefined) {\n for (const linkedClaimPath of linkedClaimPaths) {\n try {\n await assertClaimPathIdentity(linkedClaimPath, identity);\n await fs.unlink(linkedClaimPath);\n await syncParentDirectory(linkedClaimPath, options.platform);\n } catch (cleanupError) {\n cleanupErrors.push(cleanupError);\n }\n }\n }\n try {\n await handle?.close();\n } catch (closeError) {\n cleanupErrors.push(closeError);\n }\n try {\n await fs.rm(candidatePath, { force: true });\n } catch (cleanupError) {\n cleanupErrors.push(cleanupError);\n }\n if (cleanupErrors.length > 0) {\n const aggregateError = new AggregateError(\n [error, ...cleanupErrors],\n \"Private path mutation claim acquisition failed and rollback cleanup also failed.\",\n );\n aggregateError.cause = error;\n throw aggregateError;\n }\n throw error;\n }\n}\n\nconst PRIVATE_MUTATION_DIRECTORY_OWNER_FILE = \"owner.json\";\n\ntype PrivateMutationDirectoryClaimRecord = {\n identity: FileIdentity;\n metadata: PrivateMutationClaimRecord;\n};\n\nfunction samePrivateMutationDirectoryClaim(\n actual: PrivateMutationDirectoryClaimRecord,\n expected: PrivateMutationDirectoryClaimRecord,\n): boolean {\n return (\n actual.identity.device === expected.identity.device &&\n actual.identity.inode === expected.identity.inode &&\n actual.metadata.contents === expected.metadata.contents\n );\n}\n\nasync function readPrivateMutationDirectoryClaim(\n claimPath: string,\n): Promise<PrivateMutationDirectoryClaimRecord | null> {\n let stats;\n try {\n stats = await fs.lstat(claimPath, { bigint: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n return null;\n }\n throw error;\n }\n if (!stats.isDirectory() || stats.ino <= 0n) {\n throw new Error(\"Private mutation directory claim is malformed.\");\n }\n if (process.platform === \"win32\") {\n await verifyOwnerOnlyWindowsDirectoryAcl(claimPath);\n } else {\n assertOwnerOnlyPosixMutationClaim(stats, \"directory\");\n }\n const metadata = await readPrivateMutationClaim(\n path.join(claimPath, PRIVATE_MUTATION_DIRECTORY_OWNER_FILE),\n );\n if (metadata === null) {\n throw new Error(\"Private mutation directory claim is missing owner metadata.\");\n }\n const finalStats = await fs.lstat(claimPath, { bigint: true });\n if (process.platform === \"win32\") {\n await verifyOwnerOnlyWindowsDirectoryAcl(claimPath);\n } else {\n assertOwnerOnlyPosixMutationClaim(finalStats, \"directory\");\n }\n if (!finalStats.isDirectory() || finalStats.dev !== stats.dev || finalStats.ino !== stats.ino) {\n throw new Error(\"Private mutation directory claim identity changed.\");\n }\n return {\n identity: { device: stats.dev, inode: stats.ino },\n metadata,\n };\n}\n\nfunction privateMutationClaimOwnerIsActive(\n owner: PrivateMutationClaimOwner,\n runtime: PrivateMutationClaimRuntime,\n): boolean {\n if (!runtime.isProcessAlive(owner.pid)) {\n return false;\n }\n if (owner.pid === runtime.pid && owner.processStartedAtMs === runtime.processStartedAtMs) {\n return true;\n }\n if (owner.pid === runtime.pid) {\n return false;\n }\n if (owner.processIdentity === undefined) {\n return true;\n }\n const actualIdentity = runtime.getProcessIdentity(owner.pid);\n return actualIdentity === null || actualIdentity === owner.processIdentity;\n}\n\nasync function createPrivateMutationClaimDirectory(\n directoryPath: string,\n ownerContents: string,\n options: {\n createWindowsFile?: (filePath: string) => Promise<FileIdentity>;\n platform: NodeJS.Platform;\n },\n): Promise<void> {\n if (options.platform === \"win32\" && process.platform === \"win32\") {\n const firstCreated = await createOwnerOnlyWindowsDirectoryAncestry(directoryPath);\n if (firstCreated === undefined) {\n throw new Error(\"Windows mutation claim directory creation did not create its path.\");\n }\n } else {\n await fs.mkdir(directoryPath, { mode: 0o700 });\n await fs.chmod(directoryPath, 0o700);\n }\n const metadataPath = path.join(directoryPath, PRIVATE_MUTATION_DIRECTORY_OWNER_FILE);\n let handle: FileHandle | undefined;\n try {\n if (options.platform === \"win32\" && process.platform === \"win32\") {\n await (options.createWindowsFile ?? createOwnerOnlyWindowsFile)(metadataPath);\n handle = await fs.open(metadataPath, \"r+\");\n } else {\n handle = await fs.open(metadataPath, \"wx+\", 0o600);\n await handle.chmod(0o600);\n }\n await handle.writeFile(ownerContents, \"utf8\");\n await handle.sync();\n } finally {\n await handle?.close();\n }\n await syncParentDirectory(metadataPath, options.platform);\n}\n\nasync function removeInstalledPrivateMutationDirectoryClaim(\n claimPath: string,\n expectedIdentity: FileIdentity,\n ownerContents: string,\n rootClaimPath: string,\n platform: NodeJS.Platform,\n): Promise<void> {\n const observed = await readPrivateMutationDirectoryClaim(claimPath);\n if (\n observed === null ||\n observed.identity.device !== expectedIdentity.device ||\n observed.identity.inode !== expectedIdentity.inode ||\n observed.metadata.contents !== ownerContents\n ) {\n throw new Error(\"Private mutation directory claim changed before rollback.\");\n }\n const rollbackPath = `${rootClaimPath}.${randomUUID()}.rollback-dir`;\n await fs.rename(claimPath, rollbackPath);\n const moved = await readPrivateMutationDirectoryClaim(rollbackPath);\n if (\n moved === null ||\n moved.identity.device !== expectedIdentity.device ||\n moved.identity.inode !== expectedIdentity.inode ||\n moved.metadata.contents !== ownerContents\n ) {\n throw new Error(\"Private mutation directory claim changed during rollback.\");\n }\n await fs.rm(rollbackPath, { force: true, recursive: true });\n await syncParentDirectory(claimPath, platform);\n}\n\nasync function acquireDirectoryPrivateMutationClaim(\n parent: SecuredPrivateDirectory,\n options: {\n createWindowsFile?: (filePath: string) => Promise<FileIdentity>;\n platform?: NodeJS.Platform;\n runtime?: PrivateMutationClaimRuntime;\n },\n): Promise<PrivateMutationClaim> {\n const platform = options.platform ?? process.platform;\n const runtime = options.runtime ?? defaultPrivateMutationClaimRuntime();\n const ownerContents = `${JSON.stringify({\n ownerId: runtime.ownerId,\n pid: runtime.pid,\n ...(runtime.processIdentity ? { processIdentity: runtime.processIdentity } : {}),\n processStartedAtMs: runtime.processStartedAtMs,\n } satisfies PrivateMutationClaimOwner)}\\n`;\n parsePrivateMutationClaimOwner(ownerContents);\n const rootClaimPath = path.join(parent.directoryPath, PRIVATE_MUTATION_CLAIM_ROOT_FILE);\n const candidatePath = `${rootClaimPath}.${runtime.pid}.${randomUUID()}.candidate-dir`;\n const createCandidate = async () => {\n await createPrivateMutationClaimDirectory(candidatePath, ownerContents, {\n ...(options.createWindowsFile ? { createWindowsFile: options.createWindowsFile } : {}),\n platform,\n });\n const candidate = await readPrivateMutationDirectoryClaim(candidatePath);\n if (candidate === null || candidate.metadata.contents !== ownerContents) {\n throw new Error(\"Private mutation directory claim candidate could not be verified.\");\n }\n return candidate;\n };\n let candidate: Awaited<ReturnType<typeof createCandidate>> | undefined;\n let claimPath = rootClaimPath;\n let installedClaimPath: string | undefined;\n let expectedRootClaim: PrivateMutationDirectoryClaimRecord | undefined;\n try {\n candidate = await createCandidate();\n for (;;) {\n try {\n await fs.rename(candidatePath, claimPath);\n installedClaimPath = claimPath;\n } catch (error) {\n const observed = await readPrivateMutationDirectoryClaim(claimPath);\n if (observed === null) {\n throw error;\n }\n if (privateMutationClaimOwnerIsActive(observed.metadata.owner, runtime)) {\n throw new ActivePrivateMutationClaimError(error);\n }\n await parent.assertIdentityAt();\n const revalidated = await readPrivateMutationDirectoryClaim(claimPath);\n if (\n revalidated === null ||\n revalidated.identity.device !== observed.identity.device ||\n revalidated.identity.inode !== observed.identity.inode ||\n revalidated.metadata.contents !== observed.metadata.contents\n ) {\n continue;\n }\n if (claimPath === rootClaimPath) {\n expectedRootClaim = revalidated;\n } else {\n const revalidatedRoot = await readPrivateMutationDirectoryClaim(rootClaimPath);\n if (\n expectedRootClaim === undefined ||\n revalidatedRoot === null ||\n !samePrivateMutationDirectoryClaim(revalidatedRoot, expectedRootClaim)\n ) {\n claimPath = rootClaimPath;\n expectedRootClaim = undefined;\n continue;\n }\n }\n claimPath = path.join(claimPath, \".next\");\n continue;\n }\n const claimed = await readPrivateMutationDirectoryClaim(claimPath);\n if (\n claimed === null ||\n claimed.identity.device !== candidate.identity.device ||\n claimed.identity.inode !== candidate.identity.inode ||\n claimed.metadata.contents !== ownerContents\n ) {\n throw new Error(\"Private mutation directory claim ownership could not be verified.\");\n }\n if (claimPath !== rootClaimPath) {\n const revalidatedRoot = await readPrivateMutationDirectoryClaim(rootClaimPath);\n if (\n expectedRootClaim === undefined ||\n revalidatedRoot === null ||\n !samePrivateMutationDirectoryClaim(revalidatedRoot, expectedRootClaim)\n ) {\n await removeInstalledPrivateMutationDirectoryClaim(\n claimPath,\n candidate.identity,\n ownerContents,\n rootClaimPath,\n platform,\n );\n installedClaimPath = undefined;\n candidate = await createCandidate();\n claimPath = rootClaimPath;\n expectedRootClaim = undefined;\n continue;\n }\n const terminalRelativePath = path.relative(rootClaimPath, claimPath);\n const staleTreePath = `${rootClaimPath}.${randomUUID()}.stale-dir`;\n await parent.assertIdentityAt();\n await fs.rename(rootClaimPath, staleTreePath);\n const relocatedClaimPath = path.join(staleTreePath, terminalRelativePath);\n installedClaimPath = relocatedClaimPath;\n const [movedRoot, movedClaim] = await Promise.all([\n readPrivateMutationDirectoryClaim(staleTreePath),\n readPrivateMutationDirectoryClaim(relocatedClaimPath),\n ]);\n if (\n movedRoot === null ||\n !samePrivateMutationDirectoryClaim(movedRoot, revalidatedRoot) ||\n movedClaim === null ||\n movedClaim.identity.device !== candidate.identity.device ||\n movedClaim.identity.inode !== candidate.identity.inode ||\n movedClaim.metadata.contents !== ownerContents\n ) {\n const compactionError = new Error(\n \"Private mutation directory claim changed during compaction.\",\n );\n try {\n await fs.rename(staleTreePath, rootClaimPath);\n installedClaimPath = claimPath;\n } catch (rollbackError) {\n const aggregateError = new AggregateError(\n [compactionError, rollbackError],\n \"Private mutation directory claim compaction failed and its stale tree could not be restored.\",\n );\n aggregateError.cause = compactionError;\n throw aggregateError;\n }\n throw compactionError;\n }\n try {\n await fs.rename(relocatedClaimPath, rootClaimPath);\n } catch (error) {\n const code = (error as NodeJS.ErrnoException).code;\n if (code !== \"EEXIST\" && code !== \"ENOTEMPTY\") {\n try {\n await fs.rename(staleTreePath, rootClaimPath);\n installedClaimPath = claimPath;\n } catch (rollbackError) {\n const aggregateError = new AggregateError(\n [error, rollbackError],\n \"Private mutation directory claim compaction failed and its stale tree could not be restored.\",\n );\n aggregateError.cause = error;\n throw aggregateError;\n }\n throw error;\n }\n const retainedClaim = await readPrivateMutationDirectoryClaim(relocatedClaimPath);\n if (\n retainedClaim === null ||\n retainedClaim.identity.device !== candidate.identity.device ||\n retainedClaim.identity.inode !== candidate.identity.inode ||\n retainedClaim.metadata.contents !== ownerContents\n ) {\n throw new Error(\"Private mutation directory claim changed during compaction.\", {\n cause: error,\n });\n }\n await fs.rm(staleTreePath, { force: true, recursive: true });\n await syncParentDirectory(rootClaimPath, platform);\n installedClaimPath = undefined;\n candidate = await createCandidate();\n claimPath = rootClaimPath;\n expectedRootClaim = undefined;\n continue;\n }\n installedClaimPath = rootClaimPath;\n const promotedClaim = await readPrivateMutationDirectoryClaim(rootClaimPath);\n if (\n promotedClaim === null ||\n promotedClaim.identity.device !== candidate.identity.device ||\n promotedClaim.identity.inode !== candidate.identity.inode ||\n promotedClaim.metadata.contents !== ownerContents\n ) {\n throw new Error(\"Private mutation directory claim changed during compaction.\");\n }\n await fs.rm(staleTreePath, { force: true, recursive: true });\n await syncParentDirectory(rootClaimPath, platform);\n claimPath = rootClaimPath;\n expectedRootClaim = undefined;\n }\n break;\n }\n\n const [rootClaim, claimed] = await Promise.all([\n readPrivateMutationDirectoryClaim(rootClaimPath),\n readPrivateMutationDirectoryClaim(claimPath),\n ]);\n if (rootClaim === null) {\n throw new Error(\"Private mutation directory claim root disappeared.\");\n }\n if (\n claimed === null ||\n claimed.identity.device !== candidate.identity.device ||\n claimed.identity.inode !== candidate.identity.inode ||\n claimed.metadata.contents !== ownerContents\n ) {\n throw new Error(\"Private mutation directory claim ownership could not be verified.\");\n }\n if (\n claimPath !== rootClaimPath &&\n (expectedRootClaim === undefined ||\n !samePrivateMutationDirectoryClaim(rootClaim, expectedRootClaim))\n ) {\n throw new Error(\"Private mutation directory claim root changed during acquisition.\");\n }\n const terminalRelativePath = path.relative(rootClaimPath, claimPath);\n await parent.assertIdentityAt();\n await syncParentDirectory(claimPath, platform);\n\n let released = false;\n let claimedParentPath = parent.directoryPath;\n let ownedRootClaimPath = rootClaimPath;\n let ownedClaimPath = claimPath;\n const assertOwned = async () => {\n await parent.assertIdentityAt(claimedParentPath);\n const [observedRoot, observed] = await Promise.all([\n readPrivateMutationDirectoryClaim(ownedRootClaimPath),\n readPrivateMutationDirectoryClaim(ownedClaimPath),\n ]);\n if (\n observedRoot === null ||\n !samePrivateMutationDirectoryClaim(observedRoot, rootClaim) ||\n observed === null ||\n observed.identity.device !== claimed.identity.device ||\n observed.identity.inode !== claimed.identity.inode ||\n observed.metadata.contents !== ownerContents\n ) {\n throw new Error(\"Private mutation directory claim owner changed.\");\n }\n };\n return {\n assertOwned,\n async completeContainerRemoval() {\n if (released) {\n return;\n }\n try {\n await fs.lstat(claimedParentPath);\n throw new Error(\"Private directory path still exists after recursive removal.\");\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw error;\n }\n }\n released = true;\n },\n async prepareContainerRemoval() {\n await assertOwned();\n },\n async relocateParent(directoryPath: string) {\n const relocatedRootClaimPath = path.join(directoryPath, path.basename(ownedRootClaimPath));\n const relocatedClaimPath = path.join(relocatedRootClaimPath, terminalRelativePath);\n await parent.assertIdentityAt(directoryPath);\n const [observedRoot, observed] = await Promise.all([\n readPrivateMutationDirectoryClaim(relocatedRootClaimPath),\n readPrivateMutationDirectoryClaim(relocatedClaimPath),\n ]);\n if (\n observedRoot === null ||\n !samePrivateMutationDirectoryClaim(observedRoot, rootClaim) ||\n observed === null ||\n observed.identity.device !== claimed.identity.device ||\n observed.identity.inode !== claimed.identity.inode ||\n observed.metadata.contents !== ownerContents\n ) {\n throw new Error(\"Private mutation directory claim changed during relocation.\");\n }\n claimedParentPath = directoryPath;\n ownedRootClaimPath = relocatedRootClaimPath;\n ownedClaimPath = relocatedClaimPath;\n },\n async release() {\n if (released) {\n return;\n }\n await assertOwned();\n const releasePath = `${ownedRootClaimPath}.${randomUUID()}.release-dir`;\n await fs.rename(ownedRootClaimPath, releasePath);\n const [movedRoot, moved] = await Promise.all([\n readPrivateMutationDirectoryClaim(releasePath),\n readPrivateMutationDirectoryClaim(path.join(releasePath, terminalRelativePath)),\n ]);\n if (\n movedRoot === null ||\n !samePrivateMutationDirectoryClaim(movedRoot, rootClaim) ||\n moved === null ||\n moved.identity.device !== claimed.identity.device ||\n moved.identity.inode !== claimed.identity.inode ||\n moved.metadata.contents !== ownerContents\n ) {\n throw new Error(\"Private mutation directory claim changed during release.\");\n }\n await fs.rm(releasePath, { force: true, recursive: true });\n released = true;\n await parent.assertIdentityAt(claimedParentPath);\n await syncParentDirectory(ownedRootClaimPath, platform);\n },\n };\n } catch (error) {\n const cleanupErrors: unknown[] = [];\n if (installedClaimPath !== undefined && candidate !== undefined) {\n try {\n await removeInstalledPrivateMutationDirectoryClaim(\n installedClaimPath,\n candidate.identity,\n ownerContents,\n rootClaimPath,\n platform,\n );\n } catch (cleanupError) {\n cleanupErrors.push(cleanupError);\n }\n }\n if (cleanupErrors.length > 0) {\n const aggregateError = new AggregateError(\n [error, ...cleanupErrors],\n \"Private mutation directory claim acquisition failed and rollback cleanup also failed.\",\n );\n aggregateError.cause = error;\n throw aggregateError;\n }\n throw error;\n } finally {\n await fs.rm(candidatePath, { force: true, recursive: true });\n }\n}\n\nasync function acquirePrivateMutationClaim(\n parent: SecuredPrivateDirectory,\n options: {\n createWindowsFile?: (filePath: string) => Promise<FileIdentity>;\n platform?: NodeJS.Platform;\n runtime?: PrivateMutationClaimRuntime;\n },\n): Promise<PrivateMutationClaim> {\n const rootClaimPath = path.join(parent.directoryPath, PRIVATE_MUTATION_CLAIM_ROOT_FILE);\n try {\n const stats = await fs.lstat(rootClaimPath);\n if (stats.isDirectory()) {\n return await acquireDirectoryPrivateMutationClaim(parent, options);\n }\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw error;\n }\n }\n try {\n return await acquireHardLinkPrivateMutationClaim(parent, options);\n } catch (error) {\n let directoryClaimExists = false;\n try {\n directoryClaimExists = (await fs.lstat(rootClaimPath)).isDirectory();\n } catch {}\n if (!(error instanceof UnsupportedPrivateMutationHardLinkError) && !directoryClaimExists) {\n throw error;\n }\n return await acquireDirectoryPrivateMutationClaim(parent, options);\n }\n}\n\nasync function captureOwnerOnlyPrivateClaimAncestor(\n directoryPath: string,\n platform: NodeJS.Platform,\n): Promise<{ directory: SecuredPrivateDirectory; mutationRoot: boolean } | null> {\n if (platform === \"win32\" && process.platform === \"win32\") {\n try {\n await verifyOwnerOnlyWindowsDirectoryAcl(directoryPath);\n } catch {\n return null;\n }\n return {\n directory: await captureDirectoryIdentity(directoryPath),\n mutationRoot: false,\n };\n }\n\n const currentUserId = process.geteuid?.();\n if (currentUserId === undefined || !Number.isSafeInteger(currentUserId) || currentUserId < 0) {\n throw new Error(\"Could not resolve the current POSIX user for private mutation claims.\");\n }\n const stats = await fs.lstat(directoryPath, { bigint: true });\n if (!stats.isDirectory()) {\n throw new Error(\"Private mutation claim ancestry contains a non-directory entry.\");\n }\n if (\n stats.uid !== BigInt(currentUserId) ||\n (stats.mode & 0o022n) !== 0n ||\n (await darwinDirectoryHasExtendedAcl(directoryPath))\n ) {\n return null;\n }\n return {\n directory: await captureDirectoryIdentity(directoryPath),\n mutationRoot: (stats.mode & 0o1000n) !== 0n,\n };\n}\n\nasync function ownerOnlyPrivateClaimAncestry(\n leaf: SecuredPrivateDirectory,\n platform: NodeJS.Platform,\n): Promise<SecuredPrivateDirectory[]> {\n const ancestry = [leaf];\n let highestMutationRootIndex =\n platform !== \"win32\" &&\n process.platform !== \"win32\" &&\n ((await fs.lstat(leaf.directoryPath, { bigint: true })).mode & 0o1000n) !== 0n\n ? 0\n : -1;\n let directoryPath = path.dirname(leaf.directoryPath);\n while (directoryPath !== path.dirname(directoryPath)) {\n const ancestor = await captureOwnerOnlyPrivateClaimAncestor(directoryPath, platform);\n if (ancestor === null) {\n break;\n }\n ancestry.push(ancestor.directory);\n if (ancestor.mutationRoot) {\n highestMutationRootIndex = ancestry.length - 1;\n }\n directoryPath = path.dirname(directoryPath);\n }\n if (platform !== \"win32\" && process.platform !== \"win32\") {\n return highestMutationRootIndex < 0 ? [leaf] : ancestry.slice(0, highestMutationRootIndex + 1);\n }\n return ancestry;\n}\n\nasync function acquirePrivateMutationClaimChain(\n leaf: SecuredPrivateDirectory,\n options: {\n createWindowsFile?: (filePath: string) => Promise<FileIdentity>;\n platform?: NodeJS.Platform;\n runtime?: PrivateMutationClaimRuntime;\n },\n): Promise<PrivateMutationClaim> {\n const platform = options.platform ?? process.platform;\n const ancestry = await ownerOnlyPrivateClaimAncestry(leaf, platform);\n const outerBoundary = await captureSafePrivateDirectoryMutationParent(\n ancestry.at(-1)!.directoryPath,\n platform,\n );\n const claims: PrivateMutationClaim[] = [];\n let leafClaim: PrivateMutationClaim | undefined;\n try {\n for (const directory of ancestry) {\n const claim = await acquirePrivateMutationClaim(directory, options);\n claims.push(claim);\n if (directory === leaf) {\n leafClaim = claim;\n }\n }\n } catch (error) {\n const cleanupErrors: unknown[] = [];\n for (const claim of claims.reverse()) {\n try {\n await claim.release();\n } catch (cleanupError) {\n cleanupErrors.push(cleanupError);\n }\n }\n if (cleanupErrors.length > 0) {\n const aggregateError = new AggregateError(\n [error, ...cleanupErrors],\n \"Private mutation claim-chain acquisition failed and rollback cleanup also failed.\",\n );\n aggregateError.cause = error;\n throw aggregateError;\n }\n throw error;\n }\n\n let released = false;\n let leafRemoved = false;\n const releaseClaims = async (claimsToRelease: PrivateMutationClaim[]) => {\n const releaseErrors: unknown[] = [];\n for (const claim of claimsToRelease) {\n try {\n await claim.release();\n } catch (error) {\n releaseErrors.push(error);\n }\n }\n if (releaseErrors.length === 1) {\n throw releaseErrors[0];\n }\n if (releaseErrors.length > 1) {\n throw new AggregateError(releaseErrors, \"Private mutation claim-chain release failed.\");\n }\n };\n return {\n async assertOwned() {\n await outerBoundary.assertIdentityAt();\n for (const claim of claims) {\n await claim.assertOwned();\n }\n },\n async completeContainerRemoval() {\n if (released) {\n return;\n }\n if (leafClaim === undefined) {\n throw new Error(\"Private directory removal did not acquire its leaf mutation claim.\");\n }\n let primaryError: unknown;\n try {\n await leafClaim.completeContainerRemoval();\n leafRemoved = true;\n } catch (error) {\n primaryError = error;\n }\n try {\n await releaseClaims(claims.slice(1).reverse());\n } catch (releaseError) {\n if (primaryError !== undefined) {\n const aggregateError = new AggregateError(\n [primaryError, releaseError],\n \"Private directory removal completion and ancestor claim release both failed.\",\n );\n aggregateError.cause = primaryError;\n throw aggregateError;\n }\n throw releaseError;\n }\n if (primaryError !== undefined) {\n throw primaryError;\n }\n released = true;\n },\n async prepareContainerRemoval() {\n if (leafClaim === undefined) {\n throw new Error(\"Private directory removal did not acquire its leaf mutation claim.\");\n }\n await leafClaim.prepareContainerRemoval();\n },\n async relocateParent(directoryPath: string) {\n if (leafClaim === undefined) {\n throw new Error(\"Private directory removal did not acquire its leaf mutation claim.\");\n }\n await leafClaim.relocateParent(directoryPath);\n },\n async release() {\n if (released) {\n return;\n }\n await releaseClaims(leafRemoved ? claims.slice(1).reverse() : [...claims].reverse());\n released = true;\n },\n };\n}\n\nfunction privateMutationClaimTimeoutError(timeoutMs: number, cause: unknown): Error {\n return Object.assign(\n new Error(`Timed out after ${timeoutMs}ms waiting for a private mutation claim.`, { cause }),\n { code: \"ETIMEDOUT\" },\n );\n}\n\nasync function releaseClaimAfterWaitFailure(\n claim: PrivateMutationClaim,\n error: unknown,\n): Promise<never> {\n try {\n await claim.release();\n } catch (releaseError) {\n const aggregateError = new AggregateError(\n [error, releaseError],\n \"Private mutation claim wait failed and its acquired claim could not be released.\",\n );\n aggregateError.cause = error;\n throw aggregateError;\n }\n throw error;\n}\n\nasync function acquirePrivateMutationClaimWithWait(\n acquire: () => Promise<PrivateMutationClaim>,\n wait?: PreparedPrivateMutationClaimWait,\n): Promise<PrivateMutationClaim> {\n if (wait === undefined) {\n return await acquire();\n }\n const deadlineMs = wait.now() + wait.timeoutMs;\n let lastContentionError: ActivePrivateMutationClaimError | undefined;\n for (;;) {\n wait.signal?.throwIfAborted();\n let claim: PrivateMutationClaim;\n try {\n claim = await acquire();\n } catch (error) {\n if (!(error instanceof ActivePrivateMutationClaimError) || wait.timeoutMs === 0) {\n throw error;\n }\n lastContentionError = error;\n const remainingMs = deadlineMs - wait.now();\n if (remainingMs <= 0) {\n throw privateMutationClaimTimeoutError(wait.timeoutMs, error);\n }\n await wait.sleep(Math.min(wait.retryDelayMs, remainingMs), wait.signal);\n continue;\n }\n try {\n wait.signal?.throwIfAborted();\n if (lastContentionError && wait.now() >= deadlineMs) {\n throw privateMutationClaimTimeoutError(wait.timeoutMs, lastContentionError);\n }\n } catch (error) {\n return await releaseClaimAfterWaitFailure(claim, error);\n }\n return claim;\n }\n}\n\nasync function secureOwnerOnlyMutationParent(\n directoryPath: string,\n): Promise<SecuredPrivateDirectory> {\n return await securePrivateDirectory(directoryPath, {\n markMutationRoot: false,\n platform: process.platform,\n });\n}\n\nexport async function publishPrivateFileAtomically(\n filePath: string,\n contents: string,\n options: {\n afterRename?: (filePath: string) => Promise<void>;\n beforeCommitRename?: (temporaryPath: string) => Promise<void>;\n beforeRename?: (temporaryPath: string) => Promise<void>;\n claimRuntime?: PrivateMutationClaimRuntime;\n claimWait?: PrivateMutationClaimWaitOptions;\n createWindowsFile?: (temporaryPath: string) => Promise<FileIdentity>;\n createWindowsDirectories?: (directoryPath: string) => Promise<string | undefined>;\n platform?: NodeJS.Platform;\n removeTemporaryFile?: (temporaryPath: string) => Promise<void>;\n secureWindowsFile?: (temporaryPath: string) => Promise<void>;\n syncParent?: (filePath: string, platform?: NodeJS.Platform) => Promise<void>;\n } = {},\n): Promise<void> {\n assertNotReservedPrivateMutationPath(filePath);\n const claimWait = preparePrivateMutationClaimWait(options.claimWait ?? {});\n const temporaryPath = path.join(\n path.dirname(filePath),\n `.${path.basename(filePath)}.${process.pid}.${randomUUID()}.tmp`,\n );\n const parentDirectory = path.resolve(path.dirname(filePath));\n const platform = options.platform ?? process.platform;\n let parentExists = false;\n try {\n const parentStats = await fs.lstat(parentDirectory);\n if (!parentStats.isDirectory()) {\n throw new Error(\"Private publication parent is not a directory.\");\n }\n parentExists = true;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw error;\n }\n }\n const creationBoundary = parentExists\n ? undefined\n : await captureSafePrivateMutationBoundary(\n await nearestExistingDirectory(parentDirectory),\n platform,\n true,\n );\n const migrationBoundary = parentExists\n ? await capturePrivateMutationPathAncestry(parentDirectory, platform)\n : undefined;\n const firstCreatedDirectory =\n platform === \"win32\"\n ? parentExists\n ? undefined\n : await (options.createWindowsDirectories ?? createOwnerOnlyWindowsDirectoryAncestry)(\n parentDirectory,\n )\n : await fs.mkdir(parentDirectory, { recursive: true, mode: 0o700 });\n await creationBoundary?.assertIdentityAt();\n await assertDarwinCreatedAncestryHasNoExtendedAcl(firstCreatedDirectory, parentDirectory);\n if (firstCreatedDirectory !== undefined && platform !== \"win32\") {\n await securePrivateDirectory(firstCreatedDirectory, {\n markMutationRoot: true,\n platform,\n });\n }\n await migrationBoundary?.assertIdentityAt();\n const parent = await secureOwnerOnlyMutationParent(parentDirectory);\n await migrationBoundary?.assertIdentityAt();\n const claimOptions = {\n ...(options.claimRuntime ? { runtime: options.claimRuntime } : {}),\n ...(options.createWindowsFile ? { createWindowsFile: options.createWindowsFile } : {}),\n ...(options.platform ? { platform: options.platform } : {}),\n };\n // The full ancestry fence stays held for the temporary file's lifetime so supported removals\n // cannot quarantine a secret. Active publishers wait here without serializing their whole flow.\n const claim = await acquirePrivateMutationClaimWithWait(\n () => acquirePrivateMutationClaimChain(parent, claimOptions),\n claimWait,\n );\n let handle: FileHandle | undefined;\n let identity: FileIdentity | undefined;\n let publicationFailed = false;\n let primaryError: unknown;\n try {\n if (platform === \"win32\" && options.secureWindowsFile === undefined) {\n const createdIdentity = await (options.createWindowsFile ?? createOwnerOnlyWindowsFile)(\n temporaryPath,\n );\n identity = createdIdentity;\n handle = await fs.open(temporaryPath, \"r+\");\n const openedIdentity = await readHandleIdentity(handle);\n assertSameFileIdentity(openedIdentity, createdIdentity);\n } else {\n handle = await fs.open(temporaryPath, \"wx+\", 0o600);\n identity = await readHandleIdentity(handle);\n if (platform === \"win32\") {\n await options.secureWindowsFile!(temporaryPath);\n } else {\n await handle.chmod(0o600);\n }\n }\n\n await assertPathIdentity(temporaryPath, identity);\n await handle.writeFile(contents, \"utf8\");\n await handle.sync();\n await assertPathIdentity(temporaryPath, identity);\n await options.beforeRename?.(temporaryPath);\n await parent.assertIdentityAt();\n await claim.assertOwned();\n await assertPathIdentity(temporaryPath, identity);\n await options.beforeCommitRename?.(temporaryPath);\n await parent.assertIdentityAt();\n await claim.assertOwned();\n await assertPathIdentity(temporaryPath, identity);\n // Node has no portable renameat API. The owner-only parent and parent-wide claim chain fence\n // every supported same-user writer while these path identities are revalidated.\n await fs.rename(temporaryPath, filePath);\n await parent.assertIdentityAt();\n await claim.assertOwned();\n await syncPathAncestry(\n filePath,\n options.syncParent ?? syncParentDirectory,\n options.platform,\n firstCreatedDirectory,\n );\n await options.afterRename?.(filePath);\n await parent.assertIdentityAt();\n await claim.assertOwned();\n await assertPathIdentity(filePath, identity);\n } catch (error) {\n publicationFailed = true;\n primaryError = error;\n }\n\n const cleanupErrors: unknown[] = [];\n try {\n await handle?.close();\n } catch (error) {\n cleanupErrors.push(error);\n }\n try {\n if (identity !== undefined && (await pathHasFileIdentity(temporaryPath, identity))) {\n await (\n options.removeTemporaryFile ??\n ((candidatePath: string) => fs.rm(candidatePath, { force: true }))\n )(temporaryPath);\n }\n } catch (error) {\n cleanupErrors.push(error);\n }\n try {\n await claim.release();\n } catch (error) {\n cleanupErrors.push(error);\n }\n\n if (publicationFailed) {\n if (cleanupErrors.length > 0) {\n const primaryMessage =\n primaryError instanceof Error ? primaryError.message : String(primaryError);\n const aggregateError = new AggregateError(\n [primaryError, ...cleanupErrors],\n `${primaryMessage} Private temporary file cleanup also failed.`,\n );\n aggregateError.cause = primaryError;\n const primaryCode =\n typeof primaryError === \"object\" && primaryError !== null\n ? (primaryError as NodeJS.ErrnoException).code\n : undefined;\n if (primaryCode) {\n Object.assign(aggregateError, { code: primaryCode });\n }\n throw aggregateError;\n }\n throw primaryError;\n }\n if (cleanupErrors.length === 1) {\n throw cleanupErrors[0];\n }\n if (cleanupErrors.length > 1) {\n throw new AggregateError(cleanupErrors, \"Private temporary file publication cleanup failed.\");\n }\n}\n"]}