This page covers a complete Node.js client that connects to the keychain-auth daemon over Unix domain sockets on macOS and Linux, and Windows Named Pipes on Windows. You will learn how to detect the correct socket path at runtime, useDocumentation Index
Fetch the complete documentation index at: https://theseventeen-2abbdf80.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
net.createConnection for both transports, parse newline-delimited responses from a streaming buffer, and structure batch write and prefix read requests using async/await.
Full client implementation
The following is a complete Node.js client you can drop into a.js file and require or import the KeychainAuthClient class from your integration code.
Key sections explained
Platform detection for socket path
The constructor sets On Windows the path is the Named Pipe
this.socketPath based on process.platform before any connection is made:\\.\pipe\keychain-auth. On macOS the socket is in ~/Library/Application Support/keychain-auth/. On Linux it uses $XDG_RUNTIME_DIR/keychain-auth/ (fallback: ~/.cache/keychain-auth/).net.createConnection usage
net.createConnection accepts both Unix socket paths and Windows Named Pipe paths transparently. On Unix it creates a SOCK_STREAM socket; on Windows it opens the Named Pipe. No platform-specific branching is needed at the connection call site.connect callback fires once the connection is fully established. The 'error' event fires if the socket path does not exist or the daemon is not accepting connections.Newline-delimited response parsing with buffer
Node.js streams deliver data in arbitrary chunks. The client accumulates incoming bytes in a string buffer and only processes a response once a After finding the newline the listener is removed immediately with
\n is detected:removeListener. This is important for a long-lived connection where multiple sequential requests are made: without removing the handler, a second onData listener registered for the next request would also fire on data intended for a prior request’s handler.Promise-based request/response pattern
sendRequest wraps the event-driven socket API in a Promise, giving callers a clean async/await interface:Error whose message includes the daemon’s reason code on failure.Batch write and prefix read examples
A batch write sends multiple targets and values in one request. The A prefix read uses Your binary’s policy must have
targets and values arrays must be the same length:"match": "prefix" and a trailing-slash target to retrieve all secrets under a namespace in a single round trip. The daemon returns an array of { target, value } objects for every key that matches the prefix:can_search: true for prefix reads to be authorized, since the daemon enumerates keys server-side to resolve the prefix.