Main GraphQL HTTP
Encrypted requests for a signed-in session.
key = Base64Decode(session.token)Authenticated session; c-id = clientId
https://<host>:<port>/graphqlPOST /graphql
c-id: 706c6169-3b80-8f42-9a61-4e312e54d001
JSON({ requestId, query, variables })
requestId is UUIDv7 and contains the request time. variables, operationName and extensions are optional.
Use a fresh UUIDv7 requestId for every request. Its time must be within ±30 minutes of the server. UUID values are deduplicated in memory.
Replay protection
requestId = UUIDv7()JSON { requestId, query, variables } → authenticated encryptionsession.token✕ → Reject|serverTime − requestId timestamp| ≤ 30 min✕ → Rejectsession → request-ID setLibrary calls
Desktop excerpts. graphqlRequestPayload creates UUIDv7 requestId. Encrypt JSON with AAD binding HTTP_REQUEST, POST and the logical endpoint, then validate response binding.
// plain-desktop/src/lib/api/gql-client.ts
const payload = graphqlRequestPayload(query, variables)
const requestBody = chachaEncrypt(key, payload, httpRequestAad('/graphql'))
const response = await httpRequest(url, {
method: 'POST', headers: { 'c-id': clientId }, body: requestBody
})
if (!response.ok) throw new Error(String(response.status))
const bytes = new Uint8Array(await response.arrayBuffer())
const result = JSON.parse(decryptGraphqlResponse(key, requestBody, bytes))
// Feature error codes are carried in extensions.code; message is diagnostic text.
if (result.errors?.length) throw GqlError.fromGraphql(result.errors[0])HTTP 401: missing or invalid session. A saved session key survives restart; revocation or replacement invalidates it. HTTP 400: malformed, stale or repeated requestId. HTTP 429: replay cache full.