@cloudpss/crypto 0.5.30 → 0.5.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,4 +6,20 @@ export declare function isEncrypted(data: BinaryData): boolean;
6
6
  * @throws {TypeError} 如果数据不是有效的加密数据
7
7
  */
8
8
  export declare function extractAad(data: BinaryData): Uint8Array | undefined;
9
- export declare const encrypt: (data: BinaryData, passphrase: string) => Promise<Uint8Array>, decrypt: (data: BinaryData, passphrase: string) => Promise<Uint8Array>, encryptAad: (data: BinaryData, aad: BinaryData | undefined, passphrase: string) => Promise<Uint8Array>;
9
+ export declare const
10
+ /**
11
+ * 加密数据
12
+ * @throws {TypeError} 如果密码无效
13
+ */
14
+ encrypt: (data: BinaryData, passphrase: string) => Promise<Uint8Array>,
15
+ /**
16
+ * 加密数据,包含不加密的附加数据
17
+ * @throws {TypeError} 如果密码无效
18
+ */
19
+ encryptAad: (data: BinaryData, aad: BinaryData | undefined, passphrase: string) => Promise<Uint8Array>,
20
+ /**
21
+ * 解密数据
22
+ * @throws {TypeError} 如果数据不是有效的加密数据
23
+ * @throws {TypeError} 如果密码无效
24
+ */
25
+ decrypt: (data: BinaryData, passphrase: string) => Promise<Uint8Array>;
@@ -20,6 +20,24 @@ export function extractAad(data) {
20
20
  return undefined;
21
21
  return aad;
22
22
  }
23
+ export const {
24
+ /**
25
+ * 加密数据
26
+ * @throws {TypeError} 如果密码无效
27
+ */
28
+ // eslint-disable-next-line @typescript-eslint/unbound-method
29
+ encrypt,
30
+ /**
31
+ * 加密数据,包含不加密的附加数据
32
+ * @throws {TypeError} 如果密码无效
33
+ */
34
+ // eslint-disable-next-line @typescript-eslint/unbound-method
35
+ encryptAad,
36
+ /**
37
+ * 解密数据
38
+ * @throws {TypeError} 如果数据不是有效的加密数据
39
+ * @throws {TypeError} 如果密码无效
40
+ */
23
41
  // eslint-disable-next-line @typescript-eslint/unbound-method
24
- export const { encrypt, decrypt, encryptAad } = createModule(impl);
42
+ decrypt, } = createModule(impl);
25
43
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/encryption/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,0BAA0B;AAC1B,MAAM,UAAU,WAAW,CAAC,IAAgB;IACxC,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;AACxC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,IAAgB;IACvC,MAAM,SAAS,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,SAAS,CAAC,wBAAwB,CAAC,CAAC;IAClD,CAAC;IACD,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;IAC1B,IAAI,CAAC,GAAG,CAAC,UAAU;QAAE,OAAO,SAAS,CAAC;IACtC,OAAO,GAAG,CAAC;AACf,CAAC;AAED,6DAA6D;AAC7D,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/encryption/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,0BAA0B;AAC1B,MAAM,UAAU,WAAW,CAAC,IAAgB;IACxC,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;AACxC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,IAAgB;IACvC,MAAM,SAAS,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,SAAS,CAAC,wBAAwB,CAAC,CAAC;IAClD,CAAC;IACD,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;IAC1B,IAAI,CAAC,GAAG,CAAC,UAAU;QAAE,OAAO,SAAS,CAAC;IACtC,OAAO,GAAG,CAAC;AACf,CAAC;AAED,MAAM,CAAC,MAAM;AACT;;;GAGG;AACH,6DAA6D;AAC7D,OAAO;AACP;;;GAGG;AACH,6DAA6D;AAC7D,UAAU;AACV;;;;GAIG;AACH,6DAA6D;AAC7D,OAAO,GACV,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC"}
package/lib/wasm.js CHANGED
@@ -5,8 +5,7 @@ var __export = (target, all) => {
5
5
  };
6
6
  var __toBinary = /* @__PURE__ */ (() => {
7
7
  var table = new Uint8Array(128);
8
- for (var i = 0; i < 64; i++)
9
- table[i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i * 4 - 205] = i;
8
+ for (var i = 0; i < 64; i++) table[i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i * 4 - 205] = i;
10
9
  return (base64) => {
11
10
  var n = base64.length, bytes = new Uint8Array((n - (base64[n - 1] == "=") - (base64[n - 2] == "=")) * 3 / 4 | 0);
12
11
  for (var i2 = 0, j = 0; i2 < n; ) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudpss/crypto",
3
- "version": "0.5.30",
3
+ "version": "0.5.31",
4
4
  "author": "CloudPSS",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -16,9 +16,8 @@
16
16
  },
17
17
  "#lib-wasm": "./lib/wasm.js"
18
18
  },
19
- "dependencies": {},
20
19
  "devDependencies": {
21
- "esbuild": "^0.20.2",
20
+ "esbuild": "^0.21.3",
22
21
  "esbuild-plugin-wasm": "^1.1.0"
23
22
  },
24
23
  "scripts": {
@@ -23,5 +23,24 @@ export function extractAad(data: BinaryData): Uint8Array | undefined {
23
23
  return aad;
24
24
  }
25
25
 
26
- // eslint-disable-next-line @typescript-eslint/unbound-method
27
- export const { encrypt, decrypt, encryptAad } = createModule(impl);
26
+ export const {
27
+ /**
28
+ * 加密数据
29
+ * @throws {TypeError} 如果密码无效
30
+ */
31
+ // eslint-disable-next-line @typescript-eslint/unbound-method
32
+ encrypt,
33
+ /**
34
+ * 加密数据,包含不加密的附加数据
35
+ * @throws {TypeError} 如果密码无效
36
+ */
37
+ // eslint-disable-next-line @typescript-eslint/unbound-method
38
+ encryptAad,
39
+ /**
40
+ * 解密数据
41
+ * @throws {TypeError} 如果数据不是有效的加密数据
42
+ * @throws {TypeError} 如果密码无效
43
+ */
44
+ // eslint-disable-next-line @typescript-eslint/unbound-method
45
+ decrypt,
46
+ } = createModule(impl);