( socket: string, token: string, )
| 241 | } |
| 242 | |
| 243 | async function writeCapabilityFile( |
| 244 | socket: string, |
| 245 | token: string, |
| 246 | ): Promise<void> { |
| 247 | const dir = getCapabilityDir() |
| 248 | await assertPrivateCapabilityDir(dir) |
| 249 | const target = getCapabilityPath(socket) |
| 250 | const temp = `${target}.${process.pid}.${randomBytes(8).toString('hex')}.tmp` |
| 251 | try { |
| 252 | await writePrivateFileExclusive( |
| 253 | temp, |
| 254 | jsonStringify({ socketPath: socket, authToken: token }), |
| 255 | ) |
| 256 | await rename(temp, target) |
| 257 | } catch (error) { |
| 258 | try { |
| 259 | await unlink(temp) |
| 260 | } catch { |
| 261 | // Temp file may not exist if exclusive creation failed. |
| 262 | } |
| 263 | throw error |
| 264 | } |
| 265 | capabilityFilePath = target |
| 266 | } |
| 267 | |
| 268 | export async function readUdsCapabilityToken( |
| 269 | socket: string, |
no test coverage detected