@naturalcycles/nodejs-lib 15.14.0 → 15.16.0

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.
@@ -24,9 +24,7 @@ export class JWTService {
24
24
  }
25
25
  sign(payload, schema, opt = {}) {
26
26
  _assert(this.cfg.privateKey, 'JWTService: privateKey is required to be able to verify, but not provided');
27
- schema?.validate(payload, {
28
- mutateInput: true,
29
- });
27
+ schema?.validate(payload);
30
28
  return jsonwebtoken.sign(payload, this.cfg.privateKey, {
31
29
  algorithm: this.cfg.algorithm,
32
30
  noTimestamp: true,
@@ -42,9 +40,7 @@ export class JWTService {
42
40
  ...this.cfg.verifyOptions,
43
41
  ...opt,
44
42
  });
45
- schema?.validate(data, {
46
- mutateInput: true,
47
- });
43
+ schema?.validate(data);
48
44
  return data;
49
45
  }
50
46
  catch (err) {
@@ -63,9 +59,7 @@ export class JWTService {
63
59
  _assert(data?.payload, 'invalid token, decoded value is empty', {
64
60
  ...this.cfg.errorData,
65
61
  });
66
- schema?.validate(data.payload, {
67
- mutateInput: true,
68
- });
62
+ schema?.validate(data.payload);
69
63
  return data;
70
64
  }
71
65
  }
@@ -3,23 +3,23 @@ import type { ZlibOptions } from 'node:zlib';
3
3
  * deflateBuffer uses `deflate`.
4
4
  * It's 9 bytes shorter than `gzip`.
5
5
  */
6
- export declare function deflateBuffer(buf: Buffer, options?: ZlibOptions): Promise<Buffer>;
7
- export declare function inflateBuffer(buf: Buffer, options?: ZlibOptions): Promise<Buffer>;
6
+ export declare function deflateBuffer(buf: Buffer, options?: ZlibOptions): Promise<Buffer<ArrayBuffer>>;
7
+ export declare function inflateBuffer(buf: Buffer, options?: ZlibOptions): Promise<Buffer<ArrayBuffer>>;
8
8
  /**
9
9
  * deflateString uses `deflate`.
10
10
  * It's 9 bytes shorter than `gzip`.
11
11
  */
12
- export declare function deflateString(s: string, options?: ZlibOptions): Promise<Buffer>;
12
+ export declare function deflateString(s: string, options?: ZlibOptions): Promise<Buffer<ArrayBuffer>>;
13
13
  export declare function inflateToString(buf: Buffer, options?: ZlibOptions): Promise<string>;
14
14
  /**
15
15
  * gzipBuffer uses `gzip`
16
16
  * It's 9 bytes longer than `deflate`.
17
17
  */
18
- export declare function gzipBuffer(buf: Buffer, options?: ZlibOptions): Promise<Buffer>;
19
- export declare function gunzipBuffer(buf: Buffer, options?: ZlibOptions): Promise<Buffer>;
18
+ export declare function gzipBuffer(buf: Buffer, options?: ZlibOptions): Promise<Buffer<ArrayBuffer>>;
19
+ export declare function gunzipBuffer(buf: Buffer, options?: ZlibOptions): Promise<Buffer<ArrayBuffer>>;
20
20
  /**
21
21
  * gzipString uses `gzip`.
22
22
  * It's 9 bytes longer than `deflate`.
23
23
  */
24
- export declare function gzipString(s: string, options?: ZlibOptions): Promise<Buffer>;
24
+ export declare function gzipString(s: string, options?: ZlibOptions): Promise<Buffer<ArrayBuffer>>;
25
25
  export declare function gunzipToString(buf: Buffer, options?: ZlibOptions): Promise<string>;
@@ -9,10 +9,10 @@ const gunzip = promisify(zlib.gunzip.bind(zlib));
9
9
  * It's 9 bytes shorter than `gzip`.
10
10
  */
11
11
  export async function deflateBuffer(buf, options = {}) {
12
- return await deflate(buf, options);
12
+ return (await deflate(buf, options));
13
13
  }
14
14
  export async function inflateBuffer(buf, options = {}) {
15
- return await inflate(buf, options);
15
+ return (await inflate(buf, options));
16
16
  }
17
17
  /**
18
18
  * deflateString uses `deflate`.
@@ -29,10 +29,10 @@ export async function inflateToString(buf, options) {
29
29
  * It's 9 bytes longer than `deflate`.
30
30
  */
31
31
  export async function gzipBuffer(buf, options = {}) {
32
- return await gzip(buf, options);
32
+ return (await gzip(buf, options));
33
33
  }
34
34
  export async function gunzipBuffer(buf, options = {}) {
35
- return await gunzip(buf, options);
35
+ return (await gunzip(buf, options));
36
36
  }
37
37
  /**
38
38
  * gzipString uses `gzip`.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
3
  "type": "module",
4
- "version": "15.14.0",
4
+ "version": "15.16.0",
5
5
  "dependencies": {
6
6
  "@naturalcycles/js-lib": "^15",
7
7
  "@types/js-yaml": "^4",
@@ -12,7 +12,7 @@
12
12
  "ajv-keywords": "^5",
13
13
  "chalk": "^5",
14
14
  "dotenv": "^17",
15
- "joi": "^17",
15
+ "joi": "^18",
16
16
  "js-yaml": "^4",
17
17
  "jsonwebtoken": "^9",
18
18
  "lru-cache": "^11",
@@ -69,9 +69,7 @@ export class JWTService {
69
69
  'JWTService: privateKey is required to be able to verify, but not provided',
70
70
  )
71
71
 
72
- schema?.validate(payload, {
73
- mutateInput: true,
74
- })
72
+ schema?.validate(payload)
75
73
 
76
74
  return jsonwebtoken.sign(payload, this.cfg.privateKey, {
77
75
  algorithm: this.cfg.algorithm,
@@ -99,9 +97,7 @@ export class JWTService {
99
97
  ...opt,
100
98
  }) as T
101
99
 
102
- schema?.validate(data, {
103
- mutateInput: true,
104
- })
100
+ schema?.validate(data)
105
101
 
106
102
  return data
107
103
  } catch (err) {
@@ -134,9 +130,7 @@ export class JWTService {
134
130
  ...this.cfg.errorData,
135
131
  })
136
132
 
137
- schema?.validate(data.payload, {
138
- mutateInput: true,
139
- })
133
+ schema?.validate(data.payload)
140
134
 
141
135
  return data
142
136
  }
@@ -11,19 +11,28 @@ const gunzip = promisify(zlib.gunzip.bind(zlib))
11
11
  * deflateBuffer uses `deflate`.
12
12
  * It's 9 bytes shorter than `gzip`.
13
13
  */
14
- export async function deflateBuffer(buf: Buffer, options: ZlibOptions = {}): Promise<Buffer> {
15
- return await deflate(buf, options)
14
+ export async function deflateBuffer(
15
+ buf: Buffer,
16
+ options: ZlibOptions = {},
17
+ ): Promise<Buffer<ArrayBuffer>> {
18
+ return (await deflate(buf, options)) as Buffer<ArrayBuffer>
16
19
  }
17
20
 
18
- export async function inflateBuffer(buf: Buffer, options: ZlibOptions = {}): Promise<Buffer> {
19
- return await inflate(buf, options)
21
+ export async function inflateBuffer(
22
+ buf: Buffer,
23
+ options: ZlibOptions = {},
24
+ ): Promise<Buffer<ArrayBuffer>> {
25
+ return (await inflate(buf, options)) as Buffer<ArrayBuffer>
20
26
  }
21
27
 
22
28
  /**
23
29
  * deflateString uses `deflate`.
24
30
  * It's 9 bytes shorter than `gzip`.
25
31
  */
26
- export async function deflateString(s: string, options?: ZlibOptions): Promise<Buffer> {
32
+ export async function deflateString(
33
+ s: string,
34
+ options?: ZlibOptions,
35
+ ): Promise<Buffer<ArrayBuffer>> {
27
36
  return await deflateBuffer(Buffer.from(s), options)
28
37
  }
29
38
 
@@ -35,19 +44,25 @@ export async function inflateToString(buf: Buffer, options?: ZlibOptions): Promi
35
44
  * gzipBuffer uses `gzip`
36
45
  * It's 9 bytes longer than `deflate`.
37
46
  */
38
- export async function gzipBuffer(buf: Buffer, options: ZlibOptions = {}): Promise<Buffer> {
39
- return await gzip(buf, options)
47
+ export async function gzipBuffer(
48
+ buf: Buffer,
49
+ options: ZlibOptions = {},
50
+ ): Promise<Buffer<ArrayBuffer>> {
51
+ return (await gzip(buf, options)) as Buffer<ArrayBuffer>
40
52
  }
41
53
 
42
- export async function gunzipBuffer(buf: Buffer, options: ZlibOptions = {}): Promise<Buffer> {
43
- return await gunzip(buf, options)
54
+ export async function gunzipBuffer(
55
+ buf: Buffer,
56
+ options: ZlibOptions = {},
57
+ ): Promise<Buffer<ArrayBuffer>> {
58
+ return (await gunzip(buf, options)) as Buffer<ArrayBuffer>
44
59
  }
45
60
 
46
61
  /**
47
62
  * gzipString uses `gzip`.
48
63
  * It's 9 bytes longer than `deflate`.
49
64
  */
50
- export async function gzipString(s: string, options?: ZlibOptions): Promise<Buffer> {
65
+ export async function gzipString(s: string, options?: ZlibOptions): Promise<Buffer<ArrayBuffer>> {
51
66
  return await gzipBuffer(Buffer.from(s), options)
52
67
  }
53
68