--- title: Web SDK --- # Web SDK Web SDKはすべてのモダンブラウザをサポートし、複数の統合方法を提供します。 ::: tip 30 秒で動作を確認 [demo-v1.captcha.la](https://demo-v1.captcha.la) — 純粋な HTML + PHP、MIT ライセンス、全ページでソース表示可能。 - [popup.html](https://demo-v1.captcha.la/popup.html) — ポップアップモード - [float.html](https://demo-v1.captcha.la/float.html) — フローティング - [bind.html](https://demo-v1.captcha.la/bind.html) — ボタンにバインド - [inline.html](https://demo-v1.captcha.la/inline.html) — インライン埋め込み - [server-token.html](https://demo-v1.captcha.la/server-token.html) — サーバー発行トークン(リプレイ防止) ::: ## クイックスタート ```html ``` ## インストール ### CDN ```html ``` ### NPM ```bash npm install captchala # or framework wrappers npm install @captcha-la/vue npm install @captcha-la/react ``` ```js import Captchala from 'captchala'; import 'captchala/dist/captchala.css'; ``` ## モード一覧 ### ポップアップモード ```js Captchala.init({ appKey: 'YOUR_APP_KEY', product: 'popup', action: 'login' }) .bindTo('#login-btn') .onSuccess(res => sendToBackend(res.token)); ``` ### フロートモード ```js Captchala.init({ appKey: 'YOUR_APP_KEY', product: 'float', action: 'browse' }) .appendTo('#captcha-container') .onSuccess(res => sendToBackend(res.token)); ``` ### バインドモード ```js Captchala.init({ appKey: 'YOUR_APP_KEY', product: 'bind', action: 'login' }) .bindTo('#submit-button') .onSuccess(res => submitForm(res.token)); // fires only after challenge passes ``` ### 埋め込みモード ```js Captchala.init({ appKey: 'YOUR_APP_KEY', product: 'embed', action: 'register' }) .appendTo('#captcha-container') .onSuccess(res => sendToBackend(res.token)); ``` ## よく使うオプション | パラメータ | 型 | デフォルト | 説明 | | --- | --- | --- | --- | | `appKey` | string | — | App Key(必須) | | `product` | string | `popup` | 表示モード:popup | float | embed | bind | | `action` | string | `default` | ビジネスシーン | | `lang` | string | `en` | 対応言語:zh-CN / zh-TW / en / ja / ko / ms / vi / id | | `serverToken` | string | — | サーバー発行のワンタイムトークン(sct_xxx)。本番環境では強く推奨 | | `onServerTokenExpired` | `() => Promise` | — | serverToken 期限切れ時に呼ばれ、新しいトークンを返して SDK が検証を継続できるようにする | | `enableVoice` | boolean | `true` | 音声キャプチャ入口を表示するかどうか(視覚障害者向けアクセシビリティ対応) | ## サーバー側検証 After `onSuccess`, send `res.token` (prefix `pt_`) to your own backend, then validate it server-side: ```bash POST https://apiv1.captcha.la/v1/validate X-App-Key: YOUR_APP_KEY X-App-Secret: YOUR_APP_SECRET Content-Type: application/json { "pass_token": "" } ``` 完全な検証エンドポイントは [API リファレンス](./api-reference) を参照。