@connect-xyz/withdraw-js

中文文档
0.54.13发布于 2026/11/04MITTypeScriptES Module零依赖近 30 天下载 2045

一个JavaScript SDK,可以使前端应用与Connect rescreen产品无缝地相接.

中文使用文档
文档目录19 节
  1. 安装
  2. 国家预防机制(建议)
  3. 维娅 CDN
  4. 开始
  5. 1. 导入退出模块
  6. 1.1 通过CDN导入
  7. 2. 将退出模块初始化到您的 App
  8. API 参考
  9. 撤销部件道具
  10. 构造器
  11. 方法
  12. 回调函数
  13. 错误
  14. 关闭
  15. 退出时
  16. 活动
  17. 已登录
  18. 浏览器支持
  19. 更多信息与支持

@ 连接- xyz/ 退出- js

一个JavaScript SDK,可以使前端应用与Connect rescreen产品无缝地相接.

连接退出为终端用户提取资金提供了一个安全的途径. 学多一点 连接撤回文档。 。 。 .

安装

npm install @connect-xyz/withdraw-js
import { Withdraw } from '@connect-xyz/withdraw-js';

维娅 CDN

您可以导入索引文件中的脚本并使用其提供的撤销类 .

<script
  type="module"
  src="https://sdk.connect.xyz/withdraw-web/index.js"
></script>

或者你可以直接导入你的javascript代码.

import { Withdraw } from 'https://sdk.connect.xyz/withdraw-web/index.js';

开始

遵循这些简单的步骤, 将 Connect 撤回整合到您的前端应用程序 :

1. 导入退出模块

import { Withdraw } from '@connect-xyz/withdraw-js';

1.1 通过CDN导入

import { Withdraw } from 'https://sdk.connect.xyz/withdraw-web/index.js';

2. 将退出模块初始化到您的 App

// Create a Withdraw instance with configuration
const withdraw = new Withdraw({
  jwt: 'your-jwt-token',
  env: 'production', // or 'sandbox'
  onError: ({ errorCode, reason }) => {
    console.error('Withdraw error:', errorCode, 'Reason:', reason);
  },
  onClose: () => {
    console.log('Withdraw widget closed');
  },
  onWithdrawal: ({ data }) => {
    console.log('Withdrawal completed:', data);
  },
  onEvent: ({ type, data }) => {
    console.log('Event received:', type, data);
  },
  onLoaded: () => {
    console.log('Withdraw widget loaded and ready');
  },
});

// Render the widget to a container element
const container = document.getElementById('withdraw-container');
await withdraw.render(container);

// Update configuration dynamically
withdraw.updateConfig({
  jwt: 'new-jwt-token',
  onError: newErrorHandler,
});

// Check if rendered
if (withdraw.isRendered()) {
  console.log('Widget is active');
}

// Clean up when done
withdraw.destroy();

API 参考

撤销部件道具

Prop类型需求默认说明
jwtstring对- 说吧用 Connect 撤回认证的 JWT 令牌
env"production" | "sandbox"没有"production"目标环境
theme"auto" | "light" | "dark"没有"auto"界面的主题模式
onError({ errorCode, reason }) => void没有- 说吧调用错误事件
onClose() => void没有- 说吧部件关闭时召回
onWithdrawal({ data }) => void没有- 说吧撤回请求完成
onEvent({ type, data }) => void没有- 说吧召回一般活动
onLoaded() => void没有- 说吧部件装入并准备就绪时召回

构造器

new Withdraw(config: WithdrawConfig)

使用提供的配置创建新的撤回实例.

参数

  • config (退出) Config : 配置对象
    • jwt (字符串,需要):JWT认证标志
    • env (字符串,可选):环境 - “ 生产” (默认) 或“ 散装箱”
    • theme (弦,可选): 主题模式 - “ 自动” (默认)、 “ 光” 或 “ 暗”
    • onError (职能,可选): 回调错误
    • onClose (职能,可选): 关闭回调
    • onWithdrawal (职能,可选): 撤回调用
    • onEvent (职能,可选): 一般事件召回
    • onLoaded (职能,可选): 装入部件并准备就绪时召回

方法

render(container: HTMLElement): Promise<void>

将撤销部件带入指定的容器元素.

await withdraw.render(document.getElementById('withdraw-container'));

updateConfig(config: Partial<WithdrawConfig>): void

更新已渲染部件的配置.

withdraw.updateConfig({
  jwt: 'new-token',
  onError: newErrorHandler,
});

destroy(): void

从 DOM 中删除部件并清理资源.

withdraw.destroy();

isRendered(): boolean

返回当前部件是否已打开 .

if (withdraw.isRendered()) {
  // Widget is active
}

getConfig(): WithdrawConfig

返回当前配置的副本.

const config = withdraw.getConfig();
console.log('Current JWT:', config.jwt);

回调函数

关于召回事件及其有效载荷的详情,见 撤销 SDK 回调文档。 。 。 .

错误

当撤消部件出错时调用 .

onError: ({ errorCode, reason }) => {
  // errorCode: Error code
  // reason: Human-readable error description
};

关闭

当用户关闭撤回部件时调用 .

onClose: () => {
  // Handle close event
};

退出时

退出完成后调用.

onWithdrawal: ({ data }) => {
  // data: Object containing withdrawal details
};

活动

从撤消部件中调用一般事件 .

onEvent: ({ type, data }) => {
  // type: Event type string
  // data: Event-specific data object
};

已登录

当撤回部件已全部装入并准备好用户交互时调用 。 此调用在部件初始化后显示装入状态或执行动作时有用 .

onLoaded: () => {
  // Widget is fully loaded and ready
};

浏览器支持

  • 克罗梅/第90号+
  • Firefox 88+ (英语)
  • 萨法里14+
  • 所有有 Web 组件支持的现代浏览器

更多信息与支持

关于Connect撤回的全面文件或支持,请访问 页 次。 。 。 .

版本与发布记录

@connect-xyz/withdraw-js 共发布 90 个版本,首次发布于 2025/12/23;过去 12 个月发布了 90 个版本。

版本发布日期距今
0.54.13latest2026/11/049 天前
0.54.122026/10/3014 天前
0.54.112026/10/2717 天前
0.54.102026/10/2618 天前
0.54.92026/10/2421 天前
0.54.82026/10/2322 天前

关于 @connect-xyz/withdraw-js 的常见问题

@connect-xyz/withdraw-js 是什么?

一个JavaScript SDK,可以使前端应用与Connect rescreen产品无缝地相接.

如何安装 @connect-xyz/withdraw-js?

在项目目录运行 npm install @connect-xyz/withdraw-js,或使用 pnpm add / yarn add / bun add。

@connect-xyz/withdraw-js 支持 TypeScript 吗?

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

@connect-xyz/withdraw-js 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@connect-xyz/withdraw-js 可以商用吗?

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

@connect-xyz/withdraw-js 的下载量有多少?

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

@connect-xyz/withdraw-js 还在维护吗?

最新版本 0.54.13 发布于 2026/11/04(9 天前);至今共发布 90 个版本,其中过去 12 个月发布了 90 个;首次发布于 2025/12/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。