(secret: Uint8Array)
| 10 | * Authenticate with the server and obtain an auth token |
| 11 | */ |
| 12 | export 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 |
nothing calls this directly
no test coverage detected