@edge-csrf/core

中文文档
2.5.3-cloudflare-rc1发布于 2024/11/21MITTypeScriptESM + CJS零依赖近 30 天下载 1.7万

边缘- CSRF 核心 API

此软件包已被标记为弃用

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

中文使用文档

核心 API

这是Edge-CSRF低级API的文档.

安装

npm install @edge-csrf/core
# or
pnpm add @edge-csrf/core
# or
yarn add @edge-csrf/core

文档

兹将下列方法命名为出口: @edge-csrf/core 模块 :

createSecret(length) - Create new secret (cryptographically secure)

  * @param {int} length - Byte length of secret
  * @returns {Uint8Array} - The secret

createToken(secret, saltByteLength) - Create new CSRF token (cryptographically insecure
                                      salt hashed with secret)

  * @param {Uint8Array} secret - The secret
  * @param {int} saltByteLength - Salt length in number of bytes
  * @returns {Promise<Uint8Array>} - A promise returning the token in Uint8Array format

getTokenString(request) - Get the CSRF token from the request

  * @param {Request} request - The request object
  * @returns {Promise<string>} - A promise returning the token in string format

verifyToken(token, secret) - Verify the CSRF token and secret obtained from the request

  * @param {Uint8Array} token - The CSRF token
  * @param {Uint8Array} secret - The CSRF secret
  * @returns {Promise<boolean>} - A promise returning result of verification

utoa(input) - Encode Uint8Array as base64 string

  * @param {Uint8Array} input - The data to be converted from Uint8Array to base64
  * @returns {string} The base64 encoded string

atou(input) - Decode base64 string into Uint8Array

  * @param {string} input - The data to be converted from base64 to Uint8Array
  * @returns {Uint8Array} - The Uint8Array representing the input string

说明:如果你使用这些方法,你可能正在研究一个自定义框架集成. 如果有的话,请考虑向这个项目捐款!

版本与发布记录

@edge-csrf/core 共发布 23 个版本,首次发布于 2024/04/20;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.5.3-cloudflare-rc1latest2024/11/212 年前
2.5.2-rc12024/11/212 年前
2.5.22024/10/252 年前
2.5.12024/10/232 年前
2.5.02024/09/222 年前
2.4.02024/09/222 年前

关于 @edge-csrf/core 的常见问题

@edge-csrf/core 是什么?

边缘- CSRF 核心 API注意:该包已被作者标记为弃用——Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

如何安装 @edge-csrf/core?

在项目目录运行 npm install @edge-csrf/core,或使用 pnpm add / yarn add / bun add。

@edge-csrf/core 支持 TypeScript 吗?

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

@edge-csrf/core 支持 ESM 还是 CommonJS?

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

@edge-csrf/core 可以商用吗?

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

@edge-csrf/core 的下载量有多少?

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

@edge-csrf/core 还在维护吗?

最新版本 2.5.3-cloudflare-rc1 发布于 2024/11/21(2 年前);至今共发布 23 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/04/20。作者已将其标记为弃用,新项目建议寻找替代方案。