@bringweb3/chrome-extension-kit (英语)
说明
@bringweb3/chrome-extension-kit为Chrome扩展钱包添加加密取款功能提供了一个强大的预配置框架. 这个SDK是为了无缝集成而设计的,一旦添加到钱包中,它就自主地处理从在线购买中获取的加密现金回放的整个周期.
SDK 软件
这个SDK由一组JavaScript文件组成,可以将加密钱包整合到他们的Chrome扩展钱包中. 这种整合有利于无缝地添加现金回放功能,使得钱包用户可以在日常网上购物中获得加密现金回放. 当用户访问支持在线零售商网站时,Crypto Cashback系统根据用户的位置和网站的相关性确定现金回馈报价的资格. 如果是一个支持的商贩/零售商,用户将能够激活报价,并在购买时获得加密现金回购.
现金回收科
整合还包括钱包中一个专门的Cashback科,由Bring团队根据你的SDK建造. 请提供 SDK ,以使用户能够将其数字钱包连接到 带上。 。 。 . 一旦整合, 带上 将专门与现金回收科联系。 您可以在您的应用程序中浮出这个链接,让用户快速,无缝地访问他们的个性化奖励和状态仪表板.
先决条件
- 节点.js 14
- 带有必要权限的 Chrome 扩展显示 QQ V2
- 从 带上
- 提供钱包的特定标志
安装
软件包
使用 npm :
$ npm install @bringweb3/chrome-extension-kit
使用线条 :
$ yarn add @bringweb3/chrome-extension-kit
使用 pnpm :
$ pnpm add @bringweb3/chrome-extension-kit
声明
将此配置包含在您的内部 manifest.json 文件 :
"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://*/*"
]
导入
软件包安装后,您可以使用 import 或者说 require 办法:
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');
示例
背景情况.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',
})
自办门户网站
如果您在自己的域上主机“带路”门户,该域必须被允许与
sDK号 允许入境的条件是: /domains 反应——送出基地
域名( 例如). partner.com,覆盖 rewards.partner.com)并会相加. 匹配
在主机上,所以这个办法和路径不重要,但一个端口确实如此:一个传送门在一个
非默认端口必须与它一起列出(例如:. http://localhost:5173) (中文(简体) ). 没有什么可设置的
扩展.
内容脚本.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>',
});
转折设置
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
联系我们
更多信息: 联系我们
