Skip to content

hckhanh/google-safe-browsing

Repository files navigation

google-safe-browsing JSR

Quality Gate Status

A JavaScript client for Google Safe Browsing API

Features

  • Zero dependencies
  • Built-in support for Edge runtime
  • Typesafe with TypeScript
  • Supports some common cases
  • Fully documented

APIs

threatMatches.find

Finds the threat entries that match the Safe Browsing lists.

import { GoogleSafeBrowsing } from '@hckhanh/google-safe-browsing'

const client = new GoogleSafeBrowsing('apiKey')

const result = await client.findThreatMatches({
  client: {
    clientId: 'uniqueClientId',
    clientVersion: '1.0.0',
  },
  threatInfo: {
    threatTypes: ['MALWARE', 'SOCIAL_ENGINEERING'],
    platformTypes: ['ALL_PLATFORMS'],
    threatEntryTypes: ['URL'],
    threatEntries: [
      { url: 'http://malware.testing.google.test/testing/malware/' },
    ],
  },
})

const hasRisk = result.matches !== undefined && result.matches.length > 0

Release Notes

You can go to the Releases page to see the release notes.

Note

Enables client applications to check web resources (most commonly URLs) against Google-generated lists of unsafe web resources. The Safe Browsing APIs are for non-commercial use only. If you need to use APIs to detect malicious URLs for commercial purposes – meaning “for sale or revenue-generating purposes” – please refer to the Web Risk API.