MCPcopy
hub / github.com/slopus/happy / readCredentials

Function readCredentials

packages/happy-agent/src/credentials.ts:15–30  ·  view source on GitHub ↗
(config: Config)

Source from the content-addressed store, hash-verified

13};
14
15export function readCredentials(config: Config): Credentials | null {
16 try {
17 const raw = readFileSync(config.credentialPath, 'utf-8');
18 const parsed = JSON.parse(raw) as { token: string; secret: string };
19 if (!parsed.token || !parsed.secret) return null;
20 const secret = decodeBase64(parsed.secret);
21 const contentKeyPair = deriveContentKeyPair(secret);
22 return {
23 token: parsed.token,
24 secret,
25 contentKeyPair,
26 };
27 } catch {
28 return null;
29 }
30}
31
32export function writeCredentials(config: Config, token: string, secret: Uint8Array): void {
33 mkdirSync(dirname(config.credentialPath), { recursive: true, mode: 0o700 });

Callers 4

authStatusFunction · 0.90
auth.test.tsFile · 0.90
requireCredentialsFunction · 0.70

Calls 3

decodeBase64Function · 0.90
deriveContentKeyPairFunction · 0.90
parseMethod · 0.80

Tested by

no test coverage detected