@naturalcycles/nodejs-lib 13.37.1 → 13.38.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.
package/dist/index.d.ts CHANGED
@@ -75,5 +75,6 @@ export * from './validation/joi/joi.model';
75
75
  export * from './validation/joi/joi.shared.schemas';
76
76
  export * from './validation/joi/joi.validation.error';
77
77
  export * from './validation/joi/joi.validation.util';
78
+ export type { StringSchema } from './validation/joi/string.extensions';
78
79
  export type { AlternativesSchema, AnySchema, ArraySchema, BinarySchema, BooleanSchema, DateSchema, FastGlobOptions, FunctionSchema, GlobbyOptions, ObjectSchema, ValidationErrorItem, };
79
80
  export { Ajv, fastGlob, globby };
@@ -27,3 +27,10 @@ export declare function stringIdBase64(size?: number): string;
27
27
  * Base64url always produces strings without a padding character `=`, by design.
28
28
  */
29
29
  export declare function stringIdBase64Url(size?: number): string;
30
+ /**
31
+ * Generate cryptographically-secure string id with non-ambiguous characters only,
32
+ * e.g. missing O and 0, I and 1 and l etc.
33
+ *
34
+ * Default length is 16.
35
+ */
36
+ export declare function stringIdNonAmbiguous(size?: number): string;
@@ -4,6 +4,7 @@ exports.stringIdBase62 = void 0;
4
4
  exports.stringId = stringId;
5
5
  exports.stringIdBase64 = stringIdBase64;
6
6
  exports.stringIdBase64Url = stringIdBase64Url;
7
+ exports.stringIdNonAmbiguous = stringIdNonAmbiguous;
7
8
  const tslib_1 = require("tslib");
8
9
  const node_crypto_1 = tslib_1.__importDefault(require("node:crypto"));
9
10
  const nanoid_1 = require("./nanoid");
@@ -42,3 +43,12 @@ function stringIdBase64(size = 16) {
42
43
  function stringIdBase64Url(size = 16) {
43
44
  return node_crypto_1.default.randomBytes(size * 0.75).toString('base64url');
44
45
  }
46
+ /**
47
+ * Generate cryptographically-secure string id with non-ambiguous characters only,
48
+ * e.g. missing O and 0, I and 1 and l etc.
49
+ *
50
+ * Default length is 16.
51
+ */
52
+ function stringIdNonAmbiguous(size = 16) {
53
+ return stringId(size, nanoid_1.ALPHABET_NONAMBIGUOUS);
54
+ }
@@ -1,3 +1,4 @@
1
+ export declare const ALPHABET_NONAMBIGUOUS = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ";
1
2
  export declare const ALPHABET_NUMBER = "0123456789";
2
3
  export declare const ALPHABET_LOWERCASE = "abcdefghijklmnopqrstuvwxyz";
3
4
  export declare const ALPHABET_UPPERCASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
@@ -6,11 +6,12 @@ https://github.com/ai/nanoid/
6
6
 
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.ALPHABET_BASE64_URL = exports.ALPHABET_BASE64 = exports.ALPHABET_ALPHANUMERIC = exports.ALPHABET_ALPHANUMERIC_UPPERCASE = exports.ALPHABET_ALPHANUMERIC_LOWERCASE = exports.ALPHABET_UPPERCASE = exports.ALPHABET_LOWERCASE = exports.ALPHABET_NUMBER = void 0;
9
+ exports.ALPHABET_BASE64_URL = exports.ALPHABET_BASE64 = exports.ALPHABET_ALPHANUMERIC = exports.ALPHABET_ALPHANUMERIC_UPPERCASE = exports.ALPHABET_ALPHANUMERIC_LOWERCASE = exports.ALPHABET_UPPERCASE = exports.ALPHABET_LOWERCASE = exports.ALPHABET_NUMBER = exports.ALPHABET_NONAMBIGUOUS = void 0;
10
10
  exports.nanoIdCustomAlphabet = nanoIdCustomAlphabet;
11
11
  exports.nanoid = nanoid;
12
12
  /* eslint-disable */
13
13
  const node_crypto_1 = require("node:crypto");
14
+ exports.ALPHABET_NONAMBIGUOUS = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ';
14
15
  exports.ALPHABET_NUMBER = '0123456789';
15
16
  exports.ALPHABET_LOWERCASE = 'abcdefghijklmnopqrstuvwxyz';
16
17
  exports.ALPHABET_UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
@@ -11,7 +11,7 @@ export declare const numberSchemaTyped: <T>() => NumberSchema<T>;
11
11
  export declare const integerSchema: NumberSchema<number>;
12
12
  export declare const percentageSchema: NumberSchema<number>;
13
13
  export declare const dateStringSchema: StringSchema<import("@naturalcycles/js-lib").IsoDate>;
14
- export declare const binarySchema: import("joi").BinarySchema<Buffer>;
14
+ export declare const binarySchema: import("joi").BinarySchema<Buffer<ArrayBufferLike>>;
15
15
  export declare const dateObjectSchema: ObjectSchema<any>;
16
16
  export declare const dateIntervalStringSchema: StringSchema<string>;
17
17
  export declare const DATE_TIME_STRING_REGEX: RegExp;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
- "version": "13.37.1",
3
+ "version": "13.38.0",
4
4
  "scripts": {
5
5
  "prepare": "husky",
6
6
  "build": "dev-lib build",
@@ -22,7 +22,6 @@
22
22
  "@naturalcycles/js-lib": "^14.244.0",
23
23
  "@types/js-yaml": "^4.0.9",
24
24
  "@types/jsonwebtoken": "^9.0.0",
25
- "@types/through2-concurrent": "^2.0.0",
26
25
  "ajv": "^8.6.2",
27
26
  "ajv-formats": "^3.0.1",
28
27
  "ajv-keywords": "^5.0.0",
@@ -42,6 +41,7 @@
42
41
  "@naturalcycles/bench-lib": "^3.0.0",
43
42
  "@naturalcycles/dev-lib": "^15.0.3",
44
43
  "@types/node": "^22.1.0",
44
+ "@types/through2-concurrent": "^2.0.0",
45
45
  "@types/yargs": "^16.0.0",
46
46
  "jest": "^29.0.0"
47
47
  },
@@ -73,7 +73,7 @@
73
73
  "url": "https://github.com/NaturalCycles/nodejs-lib"
74
74
  },
75
75
  "engines": {
76
- "node": ">=20.13.0"
76
+ "node": ">=22.10.0"
77
77
  },
78
78
  "description": "Standard library for Node.js",
79
79
  "author": "Natural Cycles Team",
package/src/index.ts CHANGED
@@ -85,6 +85,7 @@ export * from './validation/joi/joi.model'
85
85
  export * from './validation/joi/joi.shared.schemas'
86
86
  export * from './validation/joi/joi.validation.error'
87
87
  export * from './validation/joi/joi.validation.util'
88
+ export type { StringSchema } from './validation/joi/string.extensions'
88
89
 
89
90
  export type {
90
91
  AlternativesSchema,
@@ -2,6 +2,7 @@ import crypto from 'node:crypto'
2
2
  import {
3
3
  ALPHABET_ALPHANUMERIC,
4
4
  ALPHABET_ALPHANUMERIC_LOWERCASE,
5
+ ALPHABET_NONAMBIGUOUS,
5
6
  nanoIdCustomAlphabet,
6
7
  } from './nanoid'
7
8
 
@@ -43,3 +44,13 @@ export function stringIdBase64(size = 16): string {
43
44
  export function stringIdBase64Url(size = 16): string {
44
45
  return crypto.randomBytes(size * 0.75).toString('base64url')
45
46
  }
47
+
48
+ /**
49
+ * Generate cryptographically-secure string id with non-ambiguous characters only,
50
+ * e.g. missing O and 0, I and 1 and l etc.
51
+ *
52
+ * Default length is 16.
53
+ */
54
+ export function stringIdNonAmbiguous(size = 16): string {
55
+ return stringId(size, ALPHABET_NONAMBIGUOUS)
56
+ }
@@ -11,6 +11,7 @@ import { randomFillSync } from 'node:crypto'
11
11
 
12
12
  type RandomFn = (bytes: number) => Buffer
13
13
 
14
+ export const ALPHABET_NONAMBIGUOUS = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ'
14
15
  export const ALPHABET_NUMBER = '0123456789'
15
16
  export const ALPHABET_LOWERCASE = 'abcdefghijklmnopqrstuvwxyz'
16
17
  export const ALPHABET_UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'