API संदर्भ

अतिथि GraphQL

शेयर लिंक से एन्क्रिप्ट की गई पहुँच।

key = Base64UrlDecode(shared_token)साझा लिंक से shared_token; c-id = shareId

क्लाइंट
https://<host>:<port>/guest_graphql
सर्वर

POST /guest_graphql

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

HTTP · binary

JSON({ requestId, query, variables })

requestId, UUIDv7 है और अनुरोध का समय शामिल करता है। variables, operationName और extensions वैकल्पिक हैं।

XChaCha20-Poly1305 · फ़ील्ड पर होवर या टैप करें
1 / 2

रीप्ले से सुरक्षा

requestId = UUIDv7()JSON { requestId, query, variables } → authenticated encryption
↓ POST /guest_graphql
प्रमाणित करें और डिक्रिप्ट करेंshareId → shared_token✕ → अस्वीकार करें
↓
UUIDv7 का समय जाँचें|serverTime − requestId timestamp| ≤ 60 s✕ → अस्वीकार करें
↓
चलाने से पहले requestId दर्ज करेंSQLite: guest + shareId + requestId
✓ ↓GraphQL चलाएँ
✕ ↓दोबारा इस्तेमाल किए गए requestId को अस्वीकार करें
लाइब्रेरी कॉल

डेस्कटॉप अंश। वही graphqlRequestPayload सहायक UUIDv7 requestId बनाता है; अलग टाइमस्टैम्प या रीप्ले nonce नहीं भेजा जाता।

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: साझा निष्क्रिय है या रिमोट एक्सेस बंद है। 401: डिक्रिप्शन विफल। 400: गलत प्रारूप, समयसीमा समाप्त या दोहराया अनुरोध।

प्रकार परिभाषाएँ

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
}