コンテンツにスキップ

ワンタイムコードを結果と交換する

POST
/exchange
async with session.post(
"https://cyan.qelvorn.xyz/api/auth/exchange",
headers={
"Authorization": "Bearer cyt_…",
"Content-Type": "application/json",
},
json={"code": code},
) as resp:
data = await resp.json()
# data は SignedResult ({"ok": true, "result": ..., "signature": ..., "alg": "HS256"})

Code 方式で受け取ったワンタイムコードを署名付き結果と交換する。コードは一度だけ使える。結果の signature は署名鍵で検証すること(仕様書 §5.4)。スコープ: results。

コード交換のリクエスト

Media typeapplication/json
object
code
required

セッション作成時に利用者のブラウザ経由で受け取ったワンタイムコード

string
>= 1 characters <= 256 characters

Example generated

{
"code": "example"
}

署名付き結果。

Media typeapplication/json
object
ok
required
boolean
result
required

認証結果。開示ティアで返る項目が違う

Any of:
object
v
required

ペイロードのバージョン

number
Allowed values: 1
result_id
required

結果 ID

string
client_id
required

アプリの client_id(cy_…)

string
guild_id
required

認証したサーバーの Discord ID

string
/^\d{17,20}$/
user_id
required

認証した利用者の Discord ID

string
/^\d{17,20}$/
decision_mode
required

最終判断の担当。client の場合は Cyan の判断は推奨にとどまる

string
Allowed values: cyan client
status
required

認証の成否。attested は client 担当の照合が成立した状態

string
Allowed values: success failed attested
verified
required

認証が検証済みか。判定できない場合は null

boolean | null
identity
required

同一性の確立状況

object
established
required

利用者の同一性が確立できたか

boolean
mode
required

同一性の確立を担当した側

string
Allowed values: cyan client
assurance
required

同一性の保証レベル

string
Allowed values: cyan-verified client-verified
failure_code
required

同一性確立に失敗した場合の理由コード。成功時は null

string | null
cyan_recommendation
required

Cyan の推奨判断。decision_mode: client でも返る

string
Allowed values: accept review deny
band
required

リスクスコアの帯域。リスク評価が行われなかった場合は null

string | null
Allowed values: low medium high critical
risk_score
required

リスクスコア。リスク評価が行われなかった場合は null

number | null
alert_level
required

サーバー状況の警戒レベル。リスク評価が行われなかった場合は null

string | null
error_code
required

失敗した場合の理由コード。成功時は null

string | null
disclosure
required

開示の範囲

object
tier
required

この結果に適用された開示ティア

string
Allowed values: standard
items
required

実際に開示した項目の一覧

Array<string>
Allowed values: score_breakdown ip_summary ip_address device_match bot_check account_age global_blacklist client_lists cluster_summary cluster_accounts credit env_signals auth_history member_guilds
features
required

機能ごとの実施主体。開示承認がないアプリでは null

object
botCheck
required

Bot チェックの実施主体

string
Allowed values: cyan client disabled
identity
required

ユーザー照合の実施主体

string
Allowed values: cyan client disabled
devicePair
required

端末ペア検知の実施主体

string
Allowed values: cyan client disabled
pow
required

PoW チャレンジの実施主体

string
Allowed values: cyan client disabled
envSignals
required

環境シグナルの実施主体

string
Allowed values: cyan client disabled
subAccount
required

複垢検知の実施主体

string
Allowed values: cyan client disabled
creditLedger
required

信用台帳の実施主体

string
Allowed values: cyan client disabled
globalBlacklist
required

全体ブラックリストの実施主体

string
Allowed values: cyan client disabled
list_check
required

クライアントリスト(ブラック/ホワイト)の判定要約。リスト機能が無効な場合は null

object
black
required

ブラックリストの判定要約

object
enabled
required

リスト機能が有効か

boolean
judgedAt
required

判定場所。‘cyan’ = Cyan が判定した / ‘client’ = クライアント側判定のため Cyan は判定しない / null = 無効で判定なし

string | null
Allowed values: cyan client
source
required

Cyan 判定の根拠。‘stored’ = Cyan 保持型(DB の登録) / ‘presented’ = Bot 保持型(セッションごとに提示) / null = Cyan 判定ではない

string | null
Allowed values: stored presented
hit
required

Cyan が判定した場合の該当有無。判定していない場合は null

boolean | null
white
required

ホワイトリストの判定要約

object
enabled
required

リスト機能が有効か

boolean
judgedAt
required

判定場所。‘cyan’ = Cyan が判定した / ‘client’ = クライアント側判定のため Cyan は判定しない / null = 無効で判定なし

string | null
Allowed values: cyan client
source
required

Cyan 判定の根拠。‘stored’ = Cyan 保持型(DB の登録) / ‘presented’ = Bot 保持型(セッションごとに提示) / null = Cyan 判定ではない

string | null
Allowed values: stored presented
hit
required

Cyan が判定した場合の該当有無。判定していない場合は null

boolean | null
effective
required

有効な判定。どちらにも該当しない場合は null

string | null
Allowed values: black white
whitelistExemptScope
required

ホワイトリストによる免除範囲。免除なしの場合は null

string | null
Allowed values: all signals
state
required

セッション作成時に渡した state(そのまま返る)

string | null
request_id
required

リクエスト ID

string | null
identity_mode
required

ユーザー照合の担当

string
Allowed values: cyan client
identity_assurance
required

同一性の保証レベル

string
Allowed values: cyan-verified client-verified
completed_at
required

認証が完了した時刻

integer
signals
required

Standard では内訳を返さない。detailed 以上の承認が必要

null
signature
required

結果の HMAC 署名。署名鍵で検証すること(仕様書 §5.4)

string
alg
required

署名アルゴリズム

string
Allowed values: HS256

Example

{
"ok": true,
"result": {
"v": 1,
"decision_mode": "cyan",
"status": "success",
"identity": {
"mode": "cyan",
"assurance": "cyan-verified"
},
"cyan_recommendation": "accept",
"band": "low",
"disclosure": {
"tier": "standard",
"items": [
"score_breakdown"
]
},
"features": {
"botCheck": "cyan",
"identity": "cyan",
"devicePair": "cyan",
"pow": "cyan",
"envSignals": "cyan",
"subAccount": "cyan",
"creditLedger": "cyan",
"globalBlacklist": "cyan"
},
"list_check": {
"black": {
"judgedAt": "cyan",
"source": "stored"
},
"white": {
"judgedAt": "cyan",
"source": "stored"
},
"effective": "black",
"whitelistExemptScope": "all"
},
"identity_mode": "cyan",
"identity_assurance": "cyan-verified"
},
"alg": "HS256"
}

リクエスト不正・コード無効・使用済み・期限切れ。

Media typeapplication/json
object
ok
required
boolean
code
required

エラーコード

string
Allowed values: invalid_request invalid_code code_already_used code_expired

Example

{
"ok": false,
"code": "invalid_request"
}

トークンがない・無効(invalid_token)。

Media typeapplication/json
object
ok
required
boolean
code
required

エラーコード

string
Allowed values: invalid_token

Example

{
"ok": false,
"code": "invalid_token"
}

スコープ不足・アプリ未承認・失効・停止。

Media typeapplication/json
object
ok
required
boolean
code
required

エラーコード

string
Allowed values: insufficient_scope client_not_approved client_revoked client_suspended

Example

{
"ok": false,
"code": "insufficient_scope"
}

レート制限。Retry-After ヘッダー(秒)も返す。

Media typeapplication/json
object
ok
required
boolean
code
required

エラーコード

string
Allowed values: rate_limited
layer
required

制限が掛かった層。Retry-After ヘッダー(秒)も参照すること

string
Allowed values: token app_kind app_total owner target_user

Example

{
"ok": false,
"code": "rate_limited",
"layer": "token"
}