MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / writeStore

Function writeStore

packages/cli/src/auth/store.ts:145–157  ·  view source on GitHub ↗
(credentials: Credentials, path = credentialPath())

Source from the content-addressed store, hash-verified

143}
144
145export async function writeStore(credentials: Credentials, path = credentialPath()): Promise<void> {
146 await ensureDir(dirname(path));
147 const body = JSON.stringify(serializeCredentials(credentials), null, 2);
148 const tmp = `${path}.${process.pid}.${Date.now()}.tmp`;
149 await fs.writeFile(tmp, `${body}\n`, { mode: FILE_MODE, encoding: "utf8" });
150 // `mode` on `writeFile` is masked by umask and only applies on file
151 // creation — explicit chmod is the only reliable way to land on 0600.
152 // `rename` moves the (already-0600) tmp inode over the destination,
153 // so the final file carries the tmp's mode; no post-rename chmod
154 // needed even when overwriting a looser-permissioned file.
155 await fs.chmod(tmp, FILE_MODE);
156 await fs.rename(tmp, path);
157}
158
159export async function deleteStore(path = credentialPath()): Promise<void> {
160 try {

Callers 12

persistOAuthFunction · 0.85
oauth.test.tsFile · 0.85
saveUserInfoFunction · 0.85
clearUserInfoFunction · 0.85
clearOAuthFunction · 0.85
resolver.test.tsFile · 0.85
user.test.tsFile · 0.85
store.test.tsFile · 0.85
login.test.tsFile · 0.85
runApiKeyLoginFunction · 0.85
rollbackFunction · 0.85

Calls 4

credentialPathFunction · 0.85
serializeCredentialsFunction · 0.85
nowMethod · 0.80
ensureDirFunction · 0.70

Tested by

no test coverage detected