@cloudpss/crypto 0.6.0-alpha.8 → 0.6.0-alpha.9

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.
@@ -11,16 +11,16 @@ export declare const
11
11
  * 加密数据
12
12
  * @throws {TypeError} 如果密码无效
13
13
  */
14
- encrypt: (data: BufferSource, passphrase: string) => Promise<Uint8Array>,
14
+ encrypt: (data: BufferSource, passphrase: string) => Promise<Uint8Array<ArrayBuffer>>,
15
15
  /**
16
16
  * 加密数据,包含不加密的附加数据
17
17
  * @throws {TypeError} 如果密码无效
18
18
  */
19
- encryptAad: (data: BufferSource, aad: BufferSource | undefined, passphrase: string) => Promise<Uint8Array>,
19
+ encryptAad: (data: BufferSource, aad: BufferSource | undefined, passphrase: string) => Promise<Uint8Array<ArrayBuffer>>,
20
20
  /**
21
21
  * 解密数据
22
22
  * @throws {TypeError} 如果数据不是有效的加密数据
23
23
  * @throws {TypeError} 如果密码无效
24
24
  */
25
- decrypt: (data: BufferSource, passphrase: string) => Promise<Uint8Array>;
25
+ decrypt: (data: BufferSource, passphrase: string) => Promise<Uint8Array<ArrayBuffer>>;
26
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/encryption/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,0BAA0B;AAC1B,wBAAgB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAEvD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,UAAU,GAAG,SAAS,CAQrE;AAED,eAAO;AACH;;;GAGG;AAEH,OAAO;AACP;;;GAGG;AAEH,UAAU;AACV;;;;GAIG;AAEH,OAAO,iEACW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/encryption/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,0BAA0B;AAC1B,wBAAgB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAEvD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,UAAU,GAAG,SAAS,CAQrE;AAED,eAAO;AACH;;;GAGG;AAEH,OAAO;AACP;;;GAGG;AAEH,UAAU;AACV;;;;GAIG;AAEH,OAAO,8EACW,CAAC"}
@@ -4,18 +4,18 @@ interface Module {
4
4
  * 加密数据
5
5
  * @throws {TypeError} 如果密码无效
6
6
  */
7
- encrypt(data: BufferSource, passphrase: string): Promise<Uint8Array>;
7
+ encrypt(data: BufferSource, passphrase: string): Promise<Uint8Array<ArrayBuffer>>;
8
8
  /**
9
9
  * 加密数据,包含不加密的附加数据
10
10
  * @throws {TypeError} 如果密码无效
11
11
  */
12
- encryptAad(data: BufferSource, aad: BufferSource | undefined, passphrase: string): Promise<Uint8Array>;
12
+ encryptAad(data: BufferSource, aad: BufferSource | undefined, passphrase: string): Promise<Uint8Array<ArrayBuffer>>;
13
13
  /**
14
14
  * 解密数据
15
15
  * @throws {TypeError} 如果数据不是有效的加密数据
16
16
  * @throws {TypeError} 如果密码无效
17
17
  */
18
- decrypt(data: BufferSource, passphrase: string): Promise<Uint8Array>;
18
+ decrypt(data: BufferSource, passphrase: string): Promise<Uint8Array<ArrayBuffer>>;
19
19
  }
20
20
  /** 创建模块 */
21
21
  export declare function createModule(impl: typeof import('#encryption') | typeof import('./wasm.js')): Module;
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/encryption/module.ts"],"names":[],"mappings":"AAsBA,SAAS;AACT,UAAU,MAAM;IACZ;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACrE;;;OAGG;IACH,UAAU,CAAC,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,GAAG,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACvG;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACxE;AAED,WAAW;AACX,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,aAAa,CAAC,GAAG,cAAc,WAAW,CAAC,GAAG,MAAM,CAkDpG"}
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/encryption/module.ts"],"names":[],"mappings":"AAsBA,SAAS;AACT,UAAU,MAAM;IACZ;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;IAClF;;;OAGG;IACH,UAAU,CAAC,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,GAAG,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;IACpH;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;CACrF;AAED,WAAW;AACX,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,aAAa,CAAC,GAAG,cAAc,WAAW,CAAC,GAAG,MAAM,CAkDpG"}
package/lib/wasm_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudpss/crypto",
3
- "version": "0.6.0-alpha.8",
3
+ "version": "0.6.0-alpha.9",
4
4
  "author": "CloudPSS",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -26,18 +26,18 @@ interface Module {
26
26
  * 加密数据
27
27
  * @throws {TypeError} 如果密码无效
28
28
  */
29
- encrypt(data: BufferSource, passphrase: string): Promise<Uint8Array>;
29
+ encrypt(data: BufferSource, passphrase: string): Promise<Uint8Array<ArrayBuffer>>;
30
30
  /**
31
31
  * 加密数据,包含不加密的附加数据
32
32
  * @throws {TypeError} 如果密码无效
33
33
  */
34
- encryptAad(data: BufferSource, aad: BufferSource | undefined, passphrase: string): Promise<Uint8Array>;
34
+ encryptAad(data: BufferSource, aad: BufferSource | undefined, passphrase: string): Promise<Uint8Array<ArrayBuffer>>;
35
35
  /**
36
36
  * 解密数据
37
37
  * @throws {TypeError} 如果数据不是有效的加密数据
38
38
  * @throws {TypeError} 如果密码无效
39
39
  */
40
- decrypt(data: BufferSource, passphrase: string): Promise<Uint8Array>;
40
+ decrypt(data: BufferSource, passphrase: string): Promise<Uint8Array<ArrayBuffer>>;
41
41
  }
42
42
 
43
43
  /** 创建模块 */
@@ -97,14 +97,13 @@ describe('Encryption root export', () => {
97
97
 
98
98
  /**
99
99
  * 检查实现模块
100
- * @param {any} module wrapped module
101
100
  */
102
- function checkModule(module) {
101
+ function checkModule(module: { encrypt: typeof encrypt; decrypt: typeof decrypt; encryptAad: typeof encryptAad }) {
103
102
  it('has correct exports', () => {
104
103
  expect(module).toMatchObject({
105
- encrypt: expect.any(Function),
106
- decrypt: expect.any(Function),
107
- encryptAad: expect.any(Function),
104
+ encrypt: expect.any(Function) as unknown,
105
+ decrypt: expect.any(Function) as unknown,
106
+ encryptAad: expect.any(Function) as unknown,
108
107
  });
109
108
  });
110
109
 
@@ -148,10 +147,11 @@ function checkModule(module) {
148
147
 
149
148
  /**
150
149
  * 检查实现
151
- * @param {Function} encrypt encrypt
152
- * @param {Function} decrypt decrypt
153
150
  */
154
- function checkImplEncryption(encrypt, decrypt) {
151
+ function checkImplEncryption(
152
+ encrypt: typeof webImpl.encrypt | typeof wasmImpl.encrypt | typeof nodeImpl.encrypt,
153
+ decrypt: typeof webImpl.decrypt | typeof wasmImpl.decrypt | typeof nodeImpl.decrypt,
154
+ ) {
155
155
  it.each(data)(
156
156
  `$type[$length] ($tag)`,
157
157
  async ({ raw }) => {
@@ -185,6 +185,7 @@ function checkImplEncryption(encrypt, decrypt) {
185
185
 
186
186
  await expect(async () => {
187
187
  await decrypt(
188
+ // @ts-expect-error no aad
188
189
  {
189
190
  nonce: encrypted.nonce,
190
191
  data: encrypted.data,