@basis-theory/3ds-web

中文文档
1.8.0发布于 2025/02/06Apache-2.0TypeScriptESM + CJS零依赖近 30 天下载 3215

[!CAUTION] > This SDK has been deprecated. > > Our new SDK can be found at https://github.com/Basis-Theory/web-threeds > > See our documentation site for more information. https://developers.basistheory.com/docs/sdks/web/3ds

原始使用文档
文档目录9 节
  1. Overview
  2. Methods
  3. createSession
  4. startChallenge
  5. Usage Examples
  6. Creating a 3DS Session
  7. Start Challenge
  8. Configuration Options
  9. Challenge Request

3DS-Web

[!CAUTION] This SDK has been deprecated.

Our new SDK can be found at https://github.com/Basis-Theory/web-threeds

See our documentation site for more information. https://developers.basistheory.com/docs/sdks/web/3ds

Overview

The 3DS-Web SDK is a JavaScript/TypeScript library designed to simplify the implementation of 3DS (3D Secure) authentication processes in web applications. It provides a streamlined interface for handling both the session creation and challenge steps of the 3DS process.

The 3DS-Web SDK exposes two main methods: createSession and startChallenge. These methods facilitate the initiation and handling of 3DS sessions and challenges.

Methods

createSession

createSession({ pan }: Create3dsSessionRequest): Promise<Create3dsSessionResponse>

This method initiates a 3DS session by making a request to the server with the provided PAN (Primary Account Number). It returns a promise that resolves to a Create3dsSessionResponse object containing session details.

startChallenge

startChallenge(options: ThreeDSChallengeRequest): Promise<void>

This method starts a 3DS challenge by making a request to the ACS (Access Control Server) with the necessary parameters. It handles the challenge process and returns a promise.

Usage Examples

Creating a 3DS Session

import { BasisTheory3ds } from '3ds-web';

const apiKey = 'your_api_key';
const { createSession } = BasisTheory3ds(apiKey);

const session = await createSession({
  pan: '<BASIS_THEORY_TOKEN_ID>',
});

Start Challenge

import { BasisTheory3ds } from '3ds-web';

const apiKey = 'your_api_key';
const { startChallenge } = BasisTheory3ds(apiKey);

await startChallenge({
  sessionId: 'session_id',
  acsTransactionId: 'acs_transaction_id',
  acsChallengeUrl: 'acs_challenge_url',
  threeDSVersion: '2.2.0',
  windowSize: '05', // Optional, defaults to 'THREE'
});

Configuration Options

Challenge Request

challengeContainerOptions allows you to customize the id property of the 3DS challenge container so you can target it and apply styling using CSS. It enables precise positioning of the 3DS challenge interface within your app's layout.

const { startChallenge } = BasisTheory3ds(apiKey, {
  challengeConfigurationOptions: {
    id: 'customId',
  },
});

版本与发布记录

@basis-theory/3ds-web 共发布 34 个版本,首次发布于 2024/02/15;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.8.0latest2025/02/061.7 年前
1.6.12025/02/011.8 年前
1.6.02025/01/091.8 年前
1.5.02024/12/241.9 年前
1.4.12024/12/101.9 年前
1.3.02024/10/222 年前

其他发布通道:master → 1.0.2。

关于 @basis-theory/3ds-web 的常见问题

@basis-theory/3ds-web 是什么?

[!CAUTION] > This SDK has been deprecated. > > Our new SDK can be found at https://github.com/Basis-Theory/web-threeds > > See our documentation site for more information. https://developers.basistheory.com/docs/sdks/web/3ds

如何安装 @basis-theory/3ds-web?

在项目目录运行 npm install @basis-theory/3ds-web,或使用 pnpm add / yarn add / bun add。

@basis-theory/3ds-web 支持 TypeScript 吗?

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

@basis-theory/3ds-web 支持 ESM 还是 CommonJS?

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

@basis-theory/3ds-web 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.x。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@basis-theory/3ds-web 可以商用吗?

@basis-theory/3ds-web 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@basis-theory/3ds-web 的下载量有多少?

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

@basis-theory/3ds-web 还在维护吗?

最新版本 1.8.0 发布于 2025/02/06(1.7 年前);至今共发布 34 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/02/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。