npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@polyv/request-plugin-aes-decrypt

v2.8.1

Published

用途:AES 解密插件,用于对服务端返回的加密数据进行解密处理。

Readme

AESDecryptRequestPlugin

用途:AES 解密插件,用于对服务端返回的加密数据进行解密处理。

实例化参数

| 参数名 | 用途 | 类型 | 默认值 | | ----------------- | ------------------ | -------------------- | --------------------------------- | | decryptKeys | 解密密钥信息 | AESKeyInfo | - | | decryptPosition | 解密位置 | AESDecryptPosition | AESDecryptPosition.ResponseData | | getDecryptInfo | 获取解密信息的方法 | function | - |

请求选项

| 参数名 | 用途 | 类型 | 默认值 | | ---------------- | ----------------- | ---------------- | ------- | | useAESDecrypt | 是否使用 AES 解密 | boolean | false | | aesDecryptInfo | AES 解密信息 | AESDecryptInfo | - |

解密密钥信息类型

AESKeyInfo 类型如下:

| 参数名 | 用途 | 类型 | 默认值 | | ------ | ---------------- | -------- | ------ | | sign | 解密签名(密钥) | string | - | | iv | 解密偏移量 | string | - |

解密位置枚举

AESDecryptPosition 枚举如下:

| 枚举值 | 描述 | | ---------------------------------- | ------------------------ | | AESDecryptPosition.WholeResponse | 解密整个响应数据 | | AESDecryptPosition.ResponseData | 仅解密响应中的 data 字段 |

使用方式

import { PolyvRequest } from '@polyv/request-core';
import { AESDecryptRequestPlugin, AESDecryptPosition } from '@polyv/request-plugin-aes-decrypt';

// 基础用法:使用固定的解密密钥
const requester = new PolyvRequest({
  requestPlugins: [
    new AESDecryptRequestPlugin({
      decryptKeys: {
        sign: 'yourDecryptKey',
        iv: 'yourDecryptIV',
      },
    }),
  ],
});

// 配置解密位置
const requester = new PolyvRequest({
  requestPlugins: [
    new AESDecryptRequestPlugin({
      decryptKeys: {
        sign: 'yourDecryptKey',
        iv: 'yourDecryptIV',
      },
      decryptPosition: AESDecryptPosition.WholeResponse,
    }),
  ],
});

// 使用 getDecryptInfo 方法动态获取解密信息
const requester = new PolyvRequest({
  requestPlugins: [
    new AESDecryptRequestPlugin({
      getDecryptInfo: async options => {
        // 可以根据 options 中的信息动态获取解密密钥
        return {
          decryptKeys: {
            sign: 'dynamicDecryptKey',
            iv: 'dynamicDecryptIV',
          },
          decryptPosition: AESDecryptPosition.ResponseData,
        };
      },
    }),
  ],
});

// 在某个请求中启用 AES 解密
requester.get(
  '/api/data',
  {},
  {
    useAESDecrypt: true,
  },
);

// 在某个请求中使用特定的解密信息
requester.get(
  '/api/data',
  {},
  {
    useAESDecrypt: true,
    aesDecryptInfo: {
      decryptKeys: {
        sign: 'specificKey',
        iv: 'specificIV',
      },
      decryptPosition: AESDecryptPosition.WholeResponse,
    },
  },
);

解密处理逻辑

  1. 插件默认不启用,需要在请求选项中设置 useAESDecrypt: true 或全局配置启用
  2. 解密信息的优先级为:请求选项中的 aesDecryptInfo > getDecryptInfo 方法返回的信息 > 初始化时提供的配置
  3. 根据 decryptPosition 的设置,可以选择解密整个响应数据或只解密响应中的 data 字段
  4. 解密后,如果解密结果是有效的 JSON 字符串,会自动解析为 JavaScript 对象