PlainApp
Referência da API

GraphQL para convidados

Acesso criptografado por um link de compartilhamento.

key = Base64UrlDecode(shared_token)shared_token da ligação de partilha; c-id = shareId

Cliente
https://<host>:<port>/guest_graphql
Servidor

POST /guest_graphql

c-id: 01a1cd7b-b900-7331-9331-313131313131

HTTP · binary

JSON({ requestId, query, variables })

requestId é UUIDv7 e contém a hora do pedido. variables, operationName e extensions são opcionais.

XChaCha20-Poly1305 · Passar o cursor ou tocar num campo
1 / 2

Proteção contra repetição

requestId = UUIDv7()JSON { requestId, query, variables } → authenticated encryption
↓ POST /guest_graphql
Autenticar e descriptografarshareId → shared_token✕ → Rejeitar
↓
Validar o horário do UUIDv7|serverTime − requestId timestamp| ≤ 60 s✕ → Rejeitar
↓
Registrar requestId antes da execuçãoSQLite: guest + shareId + requestId
✓ ↓Executar GraphQL
✕ ↓Rejeitar requestId reutilizado
Chamadas à biblioteca

Excertos de ambiente de trabalho. O mesmo auxiliar graphqlRequestPayload cria requestId UUIDv7; não é enviada uma marca temporal nem um nonce antirrepetição separado.

typescript
// plain-desktop/src/lib/api/guest.ts
const payload = graphqlRequestPayload(query, variables)
const requestBody = chachaEncrypt(key, payload, httpRequestAad('/guest_graphql'))
const response = await httpRequest(url, {
  method: 'POST', headers: { 'c-id': shareId }, 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 403: partilha inativa ou acesso remoto desativado. 401: falha de decifragem. 400: pedido malformado, expirado ou repetido.

Definições de Tipo

graphql
scalar Instant

scalar Long

type Query {
	sharedInfo(relativePath: String, password: String): SharedInfo!
}

type SharedFile {
	name: String!
	relativePath: String!
	isDir: Boolean!
	size: Long!
	mimeType: String!
	hasThumb: Boolean!
	createdAt: Instant
	updatedAt: Instant!
}

type SharedInfo {
	name: String!
	readOnly: Boolean!
	requiresPassword: Boolean!
	expiresAt: Instant
	urlToken: String!
	entries: [SharedFile!]!
}

"""
Directs the executor to include this field or fragment only when the `if` argument is true.
"""
directive @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
"""
Directs the executor to skip this field or fragment when the `if` argument is true.
"""
directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
schema {
	query: Query
}