修改后台权限

This commit is contained in:
yoyuzh
2026-03-24 14:30:59 +08:00
parent 00f902f475
commit b2d9db7be9
9310 changed files with 1246063 additions and 48 deletions

21
node_modules/@ecies/ciphers/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019-2025 Weiliang Li
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

71
node_modules/@ecies/ciphers/README.md generated vendored Normal file
View File

@@ -0,0 +1,71 @@
# @ecies/ciphers
[![License](https://img.shields.io/github/license/ecies/js-ciphers.svg)](https://github.com/ecies/js-ciphers)
[![NPM Package](https://img.shields.io/npm/v/@ecies/ciphers.svg)](https://www.npmjs.com/package/@ecies/ciphers)
[![NPM Downloads](https://img.shields.io/npm/dm/@ecies/ciphers)](https://npm-stat.link/@ecies/ciphers)
[![Install size](https://packagephobia.com/badge?p=@ecies/ciphers)](https://packagephobia.com/result?p=@ecies/ciphers)
[![CI](https://img.shields.io/github/actions/workflow/status/ecies/js-ciphers/ci.yml)](https://github.com/ecies/js-ciphers/actions)
[![Codecov](https://img.shields.io/codecov/c/github/ecies/js-ciphers.svg)](https://codecov.io/gh/ecies/js-ciphers)
Node/Pure JavaScript symmetric ciphers adapter.
If native implementations are available on some platforms (e.g. node, deno, bun), it'll use [`node:crypto`](https://nodejs.org/api/crypto.html#cryptocreatecipherivalgorithm-key-iv-options) for efficiency.
Otherwise (e.g. browser, react native), it'll use [`@noble/ciphers`](https://github.com/paulmillr/noble-ciphers) for compatibility.
| | aes | chacha |
| ------------ | ---------------- | ---------------- |
| Node | `node:crypto` ⚡ | `node:crypto` ⚡ |
| Bun | `node:crypto` ⚡ | `@noble/ciphers` |
| Deno | `node:crypto` ⚡ | `@noble/ciphers` |
| Browser | `@noble/ciphers` | `@noble/ciphers` |
| React Native | `@noble/ciphers` | `@noble/ciphers` |
> [!NOTE]
> You may need to polyfill [`crypto.getRandomValues`](https://github.com/LinusU/react-native-get-random-values) for React Native.
>
> There are some limitations, see [Known limitations](#known-limitations) below.
>
> This library is tree-shakeable, unused code will be excluded by bundlers.
Check the [example](./example/) folder for more usages.
## Quick start
```js
// example/quick-start.js
import { aes256gcm } from "@ecies/ciphers/aes";
import { randomBytes } from "@noble/ciphers/webcrypto";
const TEXT = "hello world🌍!";
const encoder = new TextEncoder();
const decoder = new TextDecoder();
const msg = encoder.encode(TEXT);
const key = randomBytes();
const nonce = randomBytes(16);
const cipher = aes256gcm(key, nonce);
console.log("decrypted:", decoder.decode(cipher.decrypt(cipher.encrypt(msg))));
```
The API follows `@noble/ciphers`'s API for ease of use, you can check their [examples](https://github.com/paulmillr/noble-ciphers#examples) as well.
## Supported ciphers
- `aes-256-gcm`
- Both 16 bytes and 12 bytes nonce are supported.
- `aes-256-cbc`
- **Only for legacy applications**. You should use `xchacha20-poly1305` or `aes-256-gcm` as possible.
- Nonce is always 16 bytes.
- `chacha20-poly1305`
- Nonce is always 12 bytes.
- `xchacha20-poly1305`
- Nonce is always 24 bytes.
If key is fixed and nonce is less than 16 bytes, **avoid randomly generated nonce**.
## Known limitations
- `xchacha20-poly1305` is implemented with pure JS [`hchacha20`](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha#section-2.2) function and `node:crypto`'s `chacha20-poly1305` on node.
- Currently (Nov 2025), `node:crypto`'s `chacha20-poly1305` is neither supported on [deno](https://github.com/denoland/deno/issues/28411) nor [bun](https://github.com/oven-sh/bun/issues/8072), `@noble/ciphers`'s implementation is used on both platforms instead.
- Some old versions of `deno` [did not support](https://github.com/denoland/deno/discussions/17964#discussioncomment-10917259) **indirect** conditional exports. If you used this library to build another library, client code of your library might have fell back to the `node:crypto` implementation and would not work properly, specifically `aes-256-gcm` (16 bytes nonce) and `chacha20-poly1305`. If you found such a problem, upgrade deno and run with `--conditions deno` (>=2.4.0) or `--unstable-node-conditions deno`(>=2.3.6,<2.4.0).

9
node_modules/@ecies/ciphers/dist/_node/compat.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import { type Cipher } from "@noble/ciphers/utils";
/**
* make `node:crypto`'s ciphers compatible with `@noble/ciphers`.
*
* `Cipher`'s interface is the same for both `aes-256-gcm` and `chacha20-poly1305`,
* albeit the latter is one of `CipherCCMTypes`.
* Interestingly, whether to set `plaintextLength` or not, or which value to set, has no actual effect.
*/
export declare const _compat: (algorithm: "aes-256-gcm" | "aes-256-cbc" | "chacha20-poly1305", key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => Cipher;

55
node_modules/@ecies/ciphers/dist/_node/compat.js generated vendored Normal file
View File

@@ -0,0 +1,55 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports._compat = void 0;
// biome-ignore-all lint/suspicious/noExplicitAny: hide type error
var node_crypto_1 = require("node:crypto");
var utils_1 = require("@noble/ciphers/utils");
var AEAD_TAG_LENGTH = 16;
// @ts-expect-error: only necessary for deno
var IS_DENO = globalThis.Deno !== undefined;
/**
* make `node:crypto`'s ciphers compatible with `@noble/ciphers`.
*
* `Cipher`'s interface is the same for both `aes-256-gcm` and `chacha20-poly1305`,
* albeit the latter is one of `CipherCCMTypes`.
* Interestingly, whether to set `plaintextLength` or not, or which value to set, has no actual effect.
*/
var _compat = function (algorithm, key, nonce, AAD) {
var isAEAD = algorithm === "aes-256-gcm" || algorithm === "chacha20-poly1305";
var authTagLength = isAEAD ? AEAD_TAG_LENGTH : 0;
// authTagLength is necessary for `chacha20-poly1305` before Node v16.17
var options = isAEAD ? { authTagLength: authTagLength } : undefined;
var encrypt = function (plainText) {
var cipher = (0, node_crypto_1.createCipheriv)(algorithm, key, nonce, options);
if (isAEAD && AAD !== undefined) {
cipher.setAAD(AAD);
}
var updated = cipher.update(plainText);
var finalized = cipher.final();
var tag = isAEAD ? cipher.getAuthTag() : new Uint8Array(0);
return (0, utils_1.concatBytes)(updated, finalized, tag);
};
var decrypt = function (cipherText) {
var rawCipherText = cipherText.subarray(0, cipherText.length - authTagLength);
var tag = cipherText.subarray(cipherText.length - authTagLength);
var decipher = (0, node_crypto_1.createDecipheriv)(algorithm, key, nonce, options);
if (isAEAD) {
if (AAD !== undefined) {
decipher.setAAD(AAD);
}
decipher.setAuthTag(tag);
}
/* v8 ignore if -- @preserve */
if (!isAEAD && IS_DENO) {
decipher.setAutoPadding(false); // See: https://github.com/denoland/deno/issues/28381
}
var updated = decipher.update(rawCipherText);
var finalized = decipher.final();
return (0, utils_1.concatBytes)(updated, finalized);
};
return {
encrypt: encrypt,
decrypt: decrypt,
};
};
exports._compat = _compat;

4
node_modules/@ecies/ciphers/dist/_node/hchacha.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
/**
* Copied from `@noble/ciphers/chacha`
*/
export declare const _hchacha20: (s: Uint32Array, k: Uint32Array, i: Uint32Array, o32: Uint32Array) => void;

90
node_modules/@ecies/ciphers/dist/_node/hchacha.js generated vendored Normal file
View File

@@ -0,0 +1,90 @@
"use strict";
// biome-ignore-all format lint: copied code
// prettier-ignore
Object.defineProperty(exports, "__esModule", { value: true });
exports._hchacha20 = void 0;
/**
* Copied from `@noble/ciphers/chacha`
*/
var _hchacha20 = function (s, k, i, o32) {
var x00 = s[0], x01 = s[1], x02 = s[2], x03 = s[3], x04 = k[0], x05 = k[1], x06 = k[2], x07 = k[3], x08 = k[4], x09 = k[5], x10 = k[6], x11 = k[7], x12 = i[0], x13 = i[1], x14 = i[2], x15 = i[3];
for (var r = 0; r < 20; r += 2) {
x00 = (x00 + x04) | 0;
x12 = rotl(x12 ^ x00, 16);
x08 = (x08 + x12) | 0;
x04 = rotl(x04 ^ x08, 12);
x00 = (x00 + x04) | 0;
x12 = rotl(x12 ^ x00, 8);
x08 = (x08 + x12) | 0;
x04 = rotl(x04 ^ x08, 7);
x01 = (x01 + x05) | 0;
x13 = rotl(x13 ^ x01, 16);
x09 = (x09 + x13) | 0;
x05 = rotl(x05 ^ x09, 12);
x01 = (x01 + x05) | 0;
x13 = rotl(x13 ^ x01, 8);
x09 = (x09 + x13) | 0;
x05 = rotl(x05 ^ x09, 7);
x02 = (x02 + x06) | 0;
x14 = rotl(x14 ^ x02, 16);
x10 = (x10 + x14) | 0;
x06 = rotl(x06 ^ x10, 12);
x02 = (x02 + x06) | 0;
x14 = rotl(x14 ^ x02, 8);
x10 = (x10 + x14) | 0;
x06 = rotl(x06 ^ x10, 7);
x03 = (x03 + x07) | 0;
x15 = rotl(x15 ^ x03, 16);
x11 = (x11 + x15) | 0;
x07 = rotl(x07 ^ x11, 12);
x03 = (x03 + x07) | 0;
x15 = rotl(x15 ^ x03, 8);
x11 = (x11 + x15) | 0;
x07 = rotl(x07 ^ x11, 7);
x00 = (x00 + x05) | 0;
x15 = rotl(x15 ^ x00, 16);
x10 = (x10 + x15) | 0;
x05 = rotl(x05 ^ x10, 12);
x00 = (x00 + x05) | 0;
x15 = rotl(x15 ^ x00, 8);
x10 = (x10 + x15) | 0;
x05 = rotl(x05 ^ x10, 7);
x01 = (x01 + x06) | 0;
x12 = rotl(x12 ^ x01, 16);
x11 = (x11 + x12) | 0;
x06 = rotl(x06 ^ x11, 12);
x01 = (x01 + x06) | 0;
x12 = rotl(x12 ^ x01, 8);
x11 = (x11 + x12) | 0;
x06 = rotl(x06 ^ x11, 7);
x02 = (x02 + x07) | 0;
x13 = rotl(x13 ^ x02, 16);
x08 = (x08 + x13) | 0;
x07 = rotl(x07 ^ x08, 12);
x02 = (x02 + x07) | 0;
x13 = rotl(x13 ^ x02, 8);
x08 = (x08 + x13) | 0;
x07 = rotl(x07 ^ x08, 7);
x03 = (x03 + x04) | 0;
x14 = rotl(x14 ^ x03, 16);
x09 = (x09 + x14) | 0;
x04 = rotl(x04 ^ x09, 12);
x03 = (x03 + x04) | 0;
x14 = rotl(x14 ^ x03, 8);
x09 = (x09 + x14) | 0;
x04 = rotl(x04 ^ x09, 7);
}
var oi = 0;
o32[oi++] = x00;
o32[oi++] = x01;
o32[oi++] = x02;
o32[oi++] = x03;
o32[oi++] = x12;
o32[oi++] = x13;
o32[oi++] = x14;
o32[oi++] = x15;
};
exports._hchacha20 = _hchacha20;
var rotl = function (a, b) {
return (a << b) | (a >>> (32 - b));
};

3
node_modules/@ecies/ciphers/dist/aes/noble.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import type { Cipher } from "@noble/ciphers/utils";
export declare const aes256gcm: (key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => Cipher;
export declare const aes256cbc: (key: Uint8Array, nonce: Uint8Array, _AAD?: Uint8Array) => Cipher;

12
node_modules/@ecies/ciphers/dist/aes/noble.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.aes256cbc = exports.aes256gcm = void 0;
var aes_1 = require("@noble/ciphers/aes");
var aes256gcm = function (key, nonce, AAD) {
return (0, aes_1.gcm)(key, nonce, AAD);
};
exports.aes256gcm = aes256gcm;
var aes256cbc = function (key, nonce, _AAD) {
return (0, aes_1.cbc)(key, nonce);
};
exports.aes256cbc = aes256cbc;

3
node_modules/@ecies/ciphers/dist/aes/node.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import type { Cipher } from "@noble/ciphers/utils";
export declare const aes256gcm: (key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => Cipher;
export declare const aes256cbc: (key: Uint8Array, nonce: Uint8Array, _AAD?: Uint8Array) => Cipher;

12
node_modules/@ecies/ciphers/dist/aes/node.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.aes256cbc = exports.aes256gcm = void 0;
var compat_js_1 = require("../_node/compat.js");
var aes256gcm = function (key, nonce, AAD) {
return (0, compat_js_1._compat)("aes-256-gcm", key, nonce, AAD);
};
exports.aes256gcm = aes256gcm;
var aes256cbc = function (key, nonce, _AAD) {
return (0, compat_js_1._compat)("aes-256-cbc", key, nonce);
};
exports.aes256cbc = aes256cbc;

3
node_modules/@ecies/ciphers/dist/chacha/noble.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import type { Cipher } from "@noble/ciphers/utils";
export declare const xchacha20: (key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => Cipher;
export declare const chacha20: (key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => Cipher;

12
node_modules/@ecies/ciphers/dist/chacha/noble.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.chacha20 = exports.xchacha20 = void 0;
var chacha_1 = require("@noble/ciphers/chacha");
var xchacha20 = function (key, nonce, AAD) {
return (0, chacha_1.xchacha20poly1305)(key, nonce, AAD);
};
exports.xchacha20 = xchacha20;
var chacha20 = function (key, nonce, AAD) {
return (0, chacha_1.chacha20poly1305)(key, nonce, AAD);
};
exports.chacha20 = chacha20;

3
node_modules/@ecies/ciphers/dist/chacha/node.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import { type Cipher } from "@noble/ciphers/utils";
export declare const xchacha20: (key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => Cipher;
export declare const chacha20: (key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => Cipher;

26
node_modules/@ecies/ciphers/dist/chacha/node.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.chacha20 = exports.xchacha20 = void 0;
var utils_1 = require("@noble/ciphers/utils");
var compat_js_1 = require("../_node/compat.js");
var hchacha_js_1 = require("../_node/hchacha.js");
var xchacha20 = function (key, nonce, AAD) {
if (nonce.length !== 24) {
throw new Error("xchacha20's nonce must be 24 bytes");
}
var constants = new Uint32Array([0x61707865, 0x3320646e, 0x79622d32, 0x6b206574]); // "expand 32-byte k"
var subKey = new Uint32Array(8);
(0, hchacha_js_1._hchacha20)(constants, (0, utils_1.u32)(key), (0, utils_1.u32)(nonce.subarray(0, 16)), subKey);
var subNonce = new Uint8Array(12);
subNonce.set([0, 0, 0, 0]);
subNonce.set(nonce.subarray(16), 4);
return (0, compat_js_1._compat)("chacha20-poly1305", (0, utils_1.u8)(subKey), subNonce, AAD);
};
exports.xchacha20 = xchacha20;
var chacha20 = function (key, nonce, AAD) {
if (nonce.length !== 12) {
throw new Error("chacha20's nonce must be 12 bytes");
}
return (0, compat_js_1._compat)("chacha20-poly1305", key, nonce, AAD);
};
exports.chacha20 = chacha20;

1
node_modules/@ecies/ciphers/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

3
node_modules/@ecies/ciphers/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
throw new Error("There is no entry-point in @ecies/ciphers. Check README.md for usage.");

76
node_modules/@ecies/ciphers/package.json generated vendored Normal file
View File

@@ -0,0 +1,76 @@
{
"name": "@ecies/ciphers",
"description": "Node/Pure JavaScript symmetric ciphers adapter",
"license": "MIT",
"author": {
"name": "Weiliang Li",
"email": "to.be.impressive@gmail.com",
"url": "https://github.com/kigawas"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ecies/js-ciphers.git"
},
"version": "0.2.5",
"engines": {
"node": ">=16",
"bun": ">=1",
"deno": ">=2"
},
"keywords": [
"cryptography",
"cipher",
"aes",
"chacha",
"chacha20",
"chacha20poly1305",
"xchacha20",
"xchacha20poly1305"
],
"files": [
"dist"
],
"main": "dist/index.js",
"exports": {
".": null,
"./aes": {
"types": "./dist/aes/node.d.ts",
"browser": "./dist/aes/noble.js",
"react-native": "./dist/aes/noble.js",
"deno": "./dist/aes/node.js",
"bun": "./dist/aes/node.js",
"default": "./dist/aes/node.js"
},
"./chacha": {
"types": "./dist/chacha/node.d.ts",
"browser": "./dist/chacha/noble.js",
"react-native": "./dist/chacha/noble.js",
"deno": "./dist/chacha/noble.js",
"bun": "./dist/chacha/noble.js",
"default": "./dist/chacha/node.js"
}
},
"scripts": {
"check": "biome check",
"check:fix": "biome check --fix",
"build": "npx tsc",
"test": "vitest",
"test:browser": "cd tests-browser && pnpm test"
},
"peerDependencies": {
"@noble/ciphers": "^1.0.0"
},
"devDependencies": {
"@biomejs/biome": "2.3.2",
"@types/node": "^24.10.0",
"@vitest/coverage-v8": "^4.0.6",
"typescript": "^5.9.3",
"vitest": "^4.0.6"
},
"pnpm": {
"onlyBuiltDependencies": [
"esbuild"
]
},
"packageManager": "pnpm@10.20.0+sha512.cf9998222162dd85864d0a8102e7892e7ba4ceadebbf5a31f9c2fce48dfce317a9c53b9f6464d1ef9042cba2e02ae02a9f7c143a2b438cd93c91840f0192b9dd"
}