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
}