JavaScript SDK
OpenBait JavaScript SDK を Web サイトに統合する
OpenBait JavaScript SDK を使用すると、フロントエンドでユーザーがフィッシングページにアクセスしていないかを検出し、保護措置を実行できます。
Install
npm でインストール:
npm install @openbait/sdkCDN を利用する場合:
<script src="https://cdn.openbait.com/sdk/v1/openbait.min.js"></script>Basic Usage
import { OpenBait } from '@openbait/sdk'
const openbait = new OpenBait({
apiKey: 'your_api_key',
domain: 'example.com'
})
// Initialize detection
openbait.init()
// Listen for detection results
openbait.on('phishing_detected', (result) => {
console.log('Phishing risk detected:', result)
// Show warning or block form submission
})Options
| Option | Type | Default | 説明 |
|---|---|---|---|
apiKey | string | — | API Key |
domain | string | — | 保護対象ドメイン |
checkInterval | number | 5000 | 検出間隔(ms) |
showWarning | boolean | true | ビルトイン警告の表示 |
Events
| Event | 説明 |
|---|---|
phishing_detected | フィッシングリスクを検出 |
safe | ページは安全 |
error | 検出エラー |
Advanced Usage
カスタム警告 UI
openbait.on('phishing_detected', (result) => {
// Disable built-in warning
openbait.config.showWarning = false
// Show your custom warning
showCustomWarning(result)
})フォーム送信のブロック
document.querySelector('form').addEventListener('submit', async (e) => {
e.preventDefault()
const isSafe = await openbait.check()
if (isSafe) {
e.target.submit()
} else {
alert('Security risk detected. Please verify you are on the correct site.')
}
})