Skip to main content

Built and signed on GitHub Actions

A JavaScript client for Google Safe Browsing API

This package works with Cloudflare Workers, Node.js, Deno, Bun
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
JSR Score
100%
Published
5 months ago (2.0.1)

google-safe-browsing

JSR Codacy Badge

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.

Built and signed on
GitHub Actions
View transparency log

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@hckhanh/google-safe-browsing

Import symbol

import * as google_safe_browsing from "@hckhanh/google-safe-browsing";
or

Import directly with a jsr specifier

import * as google_safe_browsing from "jsr:@hckhanh/google-safe-browsing";

Add Package

pnpm i jsr:@hckhanh/google-safe-browsing
or (using pnpm 10.8 or older)
pnpm dlx jsr add @hckhanh/google-safe-browsing

Import symbol

import * as google_safe_browsing from "@hckhanh/google-safe-browsing";

Add Package

yarn add jsr:@hckhanh/google-safe-browsing
or (using Yarn 4.8 or older)
yarn dlx jsr add @hckhanh/google-safe-browsing

Import symbol

import * as google_safe_browsing from "@hckhanh/google-safe-browsing";

Add Package

npx jsr add @hckhanh/google-safe-browsing

Import symbol

import * as google_safe_browsing from "@hckhanh/google-safe-browsing";

Add Package

bunx jsr add @hckhanh/google-safe-browsing

Import symbol

import * as google_safe_browsing from "@hckhanh/google-safe-browsing";