MCPcopy Create free account
hub / github.com/ConsortiumAI/Consortium / authGetToken

Function authGetToken

packages/consortium-cli/src/api/auth.ts:12–26  ·  view source on GitHub ↗
(secret: Uint8Array)

Source from the content-addressed store, hash-verified

10 * Authenticate with the server and obtain an auth token
11 */
12export async function authGetToken(secret: Uint8Array): Promise<string> {
13 const { challenge, publicKey, signature } = authChallenge(secret);
14
15 const response = await axios.post(`${configuration.serverUrl}/v1/auth`, {
16 challenge: encodeBase64(challenge),
17 publicKey: encodeBase64(publicKey),
18 signature: encodeBase64(signature)
19 });
20
21 if (!response.data.success || !response.data.token) {
22 throw new Error('Authentication failed');
23 }
24
25 return response.data.token;
26}
27
28/**
29 * Generate a URL for the mobile app to connect to the server

Callers

nothing calls this directly

Calls 2

authChallengeFunction · 0.90
encodeBase64Function · 0.90

Tested by

no test coverage detected