PlainApp
API-referentie

GraphQL voor gasten

Versleutelde toegang via een deellink.

key = Base64UrlDecode(shared_token)shared_token uit de deellink; c-id = shareId

Client
https://<host>:<port>/guest_graphql
Server

POST /guest_graphql

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

HTTP · binary

JSON({ requestId, query, variables })

requestId is UUIDv7 en bevat de aanvraagtijd. variables, operationName en extensions zijn optioneel.

XChaCha20-Poly1305 · Beweeg over een veld of tik erop
1 / 2

Replaybeveiliging

requestId = UUIDv7()JSON { requestId, query, variables } → authenticated encryption
↓ POST /guest_graphql
Authenticeren en ontsleutelenshareId → shared_token✕ → Weigeren
↓
UUIDv7-tijd controleren|serverTime − requestId timestamp| ≤ 60 s✕ → Weigeren
↓
requestId vóór uitvoering opslaanSQLite: guest + shareId + requestId
✓ ↓GraphQL uitvoeren
✕ ↓Hergebruikte requestId weigeren
Bibliotheekaanroepen

Desktopfragmenten. Dezelfde graphqlRequestPayload-helper maakt een UUIDv7-requestId; er wordt geen afzonderlijk tijdstempel of herhalingsnonce verstuurd.

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: inactieve gedeelde bron of externe toegang uitgeschakeld. 401: ontsleuteling mislukt. 400: onjuist gevormde, verlopen of herhaalde aanvraag.

Typedefinities

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
}