@bringweb3/chrome-extension-kit

中文文档
1.9.0发布于 2026/09/17MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 2844

Crypto cashback integration kit for crypto outlets extension

原始使用文档
文档目录14 节
  1. Description
  2. SDK
  3. Cashback Section
  4. Prerequisites
  5. Installing
  6. Package
  7. Manifest
  8. Importing
  9. Example
  10. background.js
  11. Self-hosted portal
  12. contentScript.js
  13. Turnoff settings
  14. Contact us

@bringweb3/chrome-extension-kit

Description

The @bringweb3/chrome-extension-kit provides a robust, pre-configured framework for adding crypto cashback functionality to Chrome extension wallets. This SDK is designed for seamless integration and once added to the wallet, it autonomously handles the full cycle of the crypto cashback from online purchases.

SDK

This SDK consists of a set of JavaScript files that crypto wallets can integrate into their Chrome extension wallets. This integration facilitates a seamless addition of cashback features, allowing wallet users to earn crypto cashback on everyday shopping online. When a user visits supported online retailer websites, the Crypto Cashback system determines eligibility for cashback offers based on the user's location and the website's relevance. If it is a supported merchant/retailer, the user will be able to activate the offer and receive crypto cashback on their purchases.

Cashback Section

The integration also includes a dedicated Cashback Section in the wallet that is built by the Bring team based on your SDK. Please provide the SDK to enable users to connect their digital wallets to Bring. Once integrated, Bring will provide a dedicated link to the Cashback Section. You can surface this link within your app to give users quick, seamless access to their personalized rewards and status dashboard.

Prerequisites

  • Node.js >= 14
  • Chrome extension manifest >= V2 with required permissions
  • Obtain an identifier key from Bring
  • Provide a specific logo for your wallet

Installing

Package

Using npm:

$ npm install @bringweb3/chrome-extension-kit

Using yarn:

$ yarn add @bringweb3/chrome-extension-kit

Using pnpm:

$ pnpm add @bringweb3/chrome-extension-kit

Manifest

Include this configuration inside your manifest.json file:

  "permissions": [
    "storage",
    "tabs",
    "webNavigation",
    "webRequest"
  ],
  "content_scripts": [
    {
      "matches": [
        "<all_urls>"
      ],
      "js": [
        "contentScript.js" // The name of the file importing the bringContentScriptInit
      ],
      "all_frames": true
    }
  ],
  "host_permissions": [
    "http://*/*",
    "https://*/*"
  ]

Importing

Once the package is installed, you can import the library using import or require approach:

import { bringInitBackground } from '@bringweb3/chrome-extension-kit';
import { bringInitContentScript } from '@bringweb3/chrome-extension-kit';
const { bringInitBackground } = require('@bringweb3/chrome-extension-kit');
const { bringInitContentScript } = require('@bringweb3/chrome-extension-kit');

Example

background.js


import { bringInitBackground } from '@bringweb3/chrome-extension-kit';

bringInitBackground({
    // ── MANDATORY ────────────────────────
    // identifier key obtained from Bring
    identifier: process.env.PLATFORM_IDENTIFIER,
    apiEndpoint: 'sandbox', // 'sandbox' | 'prod'

    // ── OPTIONAL ─────────────────────────
    // relative path to your Cashback Dashboard inside the extension
    cashbackPagePath: '/wallet/cashback',
    /* Route every Bring API call through your own backend instead of api.bringweb3.io.
       This is the full endpoint — Bring's host and paths are not appended, so every
       request goes to exactly this URL and your backend decides where it goes next.
       Use https: the requests carry your identifier and the user's wallet address.
       A value that isn't a valid URL throws at init. Omit it to use Bring's API directly. */
    baseUrl: 'https://api.partner.com/bring',
})

Self-hosted portal

If you host the Bring portal on your own domain, that domain has to be allowed to talk to the SDK. The allowlist is served by Bring in the /domains response — send us the base domain (e.g. partner.com, which covers rewards.partner.com) and we'll add it. Matching is on the host, so the scheme and the path don't matter, but a port does: a portal on a non-default port has to be listed with it (e.g. http://localhost:5173). Nothing to set in the extension.

contentScript.js

import { bringInitContentScript } from "@bringweb3/chrome-extension-kit";

bringInitContentScript({
    // ── MANDATORY ────────────────────────
    // Async function that returns the current user's wallet address
    getWalletAddress: async () => ...,
    // function that prompts the user to log in
    promptLogin: () => {...},

    // ── MANDATORY (pick one) ────────────
    // An optional list of custom events that dispatched when the user's wallet address had changed
    // Don't add it if you are using walletAddressUpdateCallback
    walletAddressListeners: ["customEvent:addressChanged"],
    // An optional function that runs when the user's wallet address had changed and execute the callback
    // Don't add it if you are using walletAddressListeners
    walletAddressUpdateCallback: (callback) => {...},

    // ── OPTIONAL ─────────────────────────
    // 'lower' | 'upper' (defaults to 'lower')
    text: 'lower',
    // 'light' | 'dark' (defaults to 'light')
    theme: 'light',
    // show a switch-wallet button (requires a wallet-change UI)
    switchWallet: true,
    /* needed if you want to host the style file on your own servers.
    styleUrl examples:
      - Single theme: https://media.bringweb3.io/examples/style/theme-single.json
      - Dark & light: https://media.bringweb3.io/examples/style/theme-dual.json
      If not provided (recommended), Bring will host the style. */
    styleUrl: 'https://<your-domain>',
});

Turnoff settings

import { getTurnOff, setTurnOff } from "@bringweb3/chrome-extension-kit";

// Get state example
const current = await getTurnOff()
console.log(current) // true | false

// Set state example
const res = await setTurnOff(true)
console.log(res.isTurnedOff) // true

Contact us

For more information: contact us

版本与发布记录

@bringweb3/chrome-extension-kit 共发布 69 个版本,首次发布于 2024/08/20;过去 12 个月发布了 8 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.9.0latest2026/09/171 个月前
1.8.02026/08/112 个月前
1.7.02026/05/245 个月前
1.6.42026/04/166 个月前
1.6.32026/04/037 个月前
1.6.22026/03/167 个月前

关于 @bringweb3/chrome-extension-kit 的常见问题

@bringweb3/chrome-extension-kit 是什么?

Crypto cashback integration kit for crypto outlets extension

如何安装 @bringweb3/chrome-extension-kit?

在项目目录运行 npm install @bringweb3/chrome-extension-kit,或使用 pnpm add / yarn add / bun add。

@bringweb3/chrome-extension-kit 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bringweb3/chrome-extension-kit 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@bringweb3/chrome-extension-kit 可以商用吗?

@bringweb3/chrome-extension-kit 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bringweb3/chrome-extension-kit 的下载量有多少?

根据 npm 官方下载统计,@bringweb3/chrome-extension-kit 在 2026/10/09 – 2026/11/07 这 30 天内被下载 2,844 次,日均约 95 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bringweb3/chrome-extension-kit 还在维护吗?

最新版本 1.9.0 发布于 2026/09/17(1 个月前);至今共发布 69 个版本,其中过去 12 个月发布了 8 个;首次发布于 2024/08/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。