@typekcz-nocobase-plugins/plugin-oidc-plus 1.0.3 → 1.0.4

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.
Files changed (77) hide show
  1. package/dist/client/index.js +1 -1
  2. package/dist/externalVersion.js +9 -9
  3. package/package.json +1 -1
  4. package/src/client/OIDCButton.tsx +70 -0
  5. package/src/client/Options.tsx +359 -0
  6. package/src/client/index.tsx +19 -0
  7. package/src/client/locale/index.ts +18 -0
  8. package/src/constants.ts +7 -0
  9. package/src/index.ts +2 -0
  10. package/src/locale/en-US.json +40 -0
  11. package/src/locale/es-ES.json +25 -0
  12. package/src/locale/fr-FR.json +21 -0
  13. package/src/locale/ko_KR.json +28 -0
  14. package/src/locale/pt-BR.json +21 -0
  15. package/src/locale/zh-CN.json +28 -0
  16. package/src/server/__tests__/oidc.test.ts +283 -0
  17. package/src/server/actions/getAuthUrl.ts +25 -0
  18. package/src/server/actions/redirect.ts +32 -0
  19. package/src/server/index.ts +1 -0
  20. package/src/server/oidc-auth.ts +169 -0
  21. package/src/server/plugin.ts +63 -0
  22. package/src/swagger/index.ts +157 -0
  23. package/dist/node_modules/nanoid/.devcontainer.json +0 -23
  24. package/dist/node_modules/nanoid/LICENSE +0 -20
  25. package/dist/node_modules/nanoid/async/index.browser.cjs +0 -69
  26. package/dist/node_modules/nanoid/async/index.browser.js +0 -69
  27. package/dist/node_modules/nanoid/async/index.cjs +0 -71
  28. package/dist/node_modules/nanoid/async/index.d.ts +0 -56
  29. package/dist/node_modules/nanoid/async/index.js +0 -71
  30. package/dist/node_modules/nanoid/async/index.native.js +0 -57
  31. package/dist/node_modules/nanoid/async/package.json +0 -12
  32. package/dist/node_modules/nanoid/bin/nanoid.cjs +0 -55
  33. package/dist/node_modules/nanoid/index.browser.cjs +0 -72
  34. package/dist/node_modules/nanoid/index.browser.js +0 -72
  35. package/dist/node_modules/nanoid/index.cjs +0 -1
  36. package/dist/node_modules/nanoid/index.d.cts +0 -91
  37. package/dist/node_modules/nanoid/index.d.ts +0 -91
  38. package/dist/node_modules/nanoid/index.js +0 -85
  39. package/dist/node_modules/nanoid/nanoid.js +0 -1
  40. package/dist/node_modules/nanoid/non-secure/index.cjs +0 -34
  41. package/dist/node_modules/nanoid/non-secure/index.d.ts +0 -33
  42. package/dist/node_modules/nanoid/non-secure/index.js +0 -34
  43. package/dist/node_modules/nanoid/non-secure/package.json +0 -6
  44. package/dist/node_modules/nanoid/package.json +0 -1
  45. package/dist/node_modules/nanoid/url-alphabet/index.cjs +0 -7
  46. package/dist/node_modules/nanoid/url-alphabet/index.js +0 -7
  47. package/dist/node_modules/nanoid/url-alphabet/package.json +0 -6
  48. package/dist/node_modules/openid-client/lib/client.js +0 -1884
  49. package/dist/node_modules/openid-client/lib/device_flow_handle.js +0 -125
  50. package/dist/node_modules/openid-client/lib/errors.js +0 -55
  51. package/dist/node_modules/openid-client/lib/helpers/assert.js +0 -24
  52. package/dist/node_modules/openid-client/lib/helpers/base64url.js +0 -13
  53. package/dist/node_modules/openid-client/lib/helpers/client.js +0 -208
  54. package/dist/node_modules/openid-client/lib/helpers/consts.js +0 -7
  55. package/dist/node_modules/openid-client/lib/helpers/decode_jwt.js +0 -27
  56. package/dist/node_modules/openid-client/lib/helpers/deep_clone.js +0 -1
  57. package/dist/node_modules/openid-client/lib/helpers/defaults.js +0 -27
  58. package/dist/node_modules/openid-client/lib/helpers/generators.js +0 -14
  59. package/dist/node_modules/openid-client/lib/helpers/is_key_object.js +0 -4
  60. package/dist/node_modules/openid-client/lib/helpers/is_plain_object.js +0 -1
  61. package/dist/node_modules/openid-client/lib/helpers/issuer.js +0 -111
  62. package/dist/node_modules/openid-client/lib/helpers/keystore.js +0 -298
  63. package/dist/node_modules/openid-client/lib/helpers/merge.js +0 -24
  64. package/dist/node_modules/openid-client/lib/helpers/pick.js +0 -9
  65. package/dist/node_modules/openid-client/lib/helpers/process_response.js +0 -71
  66. package/dist/node_modules/openid-client/lib/helpers/request.js +0 -200
  67. package/dist/node_modules/openid-client/lib/helpers/unix_timestamp.js +0 -1
  68. package/dist/node_modules/openid-client/lib/helpers/weak_cache.js +0 -1
  69. package/dist/node_modules/openid-client/lib/helpers/webfinger_normalize.js +0 -71
  70. package/dist/node_modules/openid-client/lib/helpers/www_authenticate_parser.js +0 -14
  71. package/dist/node_modules/openid-client/lib/index.js +0 -1
  72. package/dist/node_modules/openid-client/lib/issuer.js +0 -192
  73. package/dist/node_modules/openid-client/lib/issuer_registry.js +0 -3
  74. package/dist/node_modules/openid-client/lib/passport_strategy.js +0 -205
  75. package/dist/node_modules/openid-client/lib/token_set.js +0 -35
  76. package/dist/node_modules/openid-client/package.json +0 -1
  77. package/dist/node_modules/openid-client/types/index.d.ts +0 -623
@@ -1,55 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- let { nanoid, customAlphabet } = require('..')
4
-
5
- function print(msg) {
6
- process.stdout.write(msg + '\n')
7
- }
8
-
9
- function error(msg) {
10
- process.stderr.write(msg + '\n')
11
- process.exit(1)
12
- }
13
-
14
- if (process.argv.includes('--help') || process.argv.includes('-h')) {
15
- print(`
16
- Usage
17
- $ nanoid [options]
18
-
19
- Options
20
- -s, --size Generated ID size
21
- -a, --alphabet Alphabet to use
22
- -h, --help Show this help
23
-
24
- Examples
25
- $ nanoid --s 15
26
- S9sBF77U6sDB8Yg
27
-
28
- $ nanoid --size 10 --alphabet abc
29
- bcabababca`)
30
- process.exit()
31
- }
32
-
33
- let alphabet, size
34
- for (let i = 2; i < process.argv.length; i++) {
35
- let arg = process.argv[i]
36
- if (arg === '--size' || arg === '-s') {
37
- size = Number(process.argv[i + 1])
38
- i += 1
39
- if (Number.isNaN(size) || size <= 0) {
40
- error('Size must be positive integer')
41
- }
42
- } else if (arg === '--alphabet' || arg === '-a') {
43
- alphabet = process.argv[i + 1]
44
- i += 1
45
- } else {
46
- error('Unknown argument ' + arg)
47
- }
48
- }
49
-
50
- if (alphabet) {
51
- let customNanoid = customAlphabet(alphabet, size)
52
- print(customNanoid())
53
- } else {
54
- print(nanoid(size))
55
- }
@@ -1,72 +0,0 @@
1
- // This file replaces `index.js` in bundlers like webpack or Rollup,
2
- // according to `browser` config in `package.json`.
3
-
4
- let { urlAlphabet } = require('./url-alphabet/index.cjs')
5
-
6
- let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))
7
-
8
- let customRandom = (alphabet, defaultSize, getRandom) => {
9
- // First, a bitmask is necessary to generate the ID. The bitmask makes bytes
10
- // values closer to the alphabet size. The bitmask calculates the closest
11
- // `2^31 - 1` number, which exceeds the alphabet size.
12
- // For example, the bitmask for the alphabet size 30 is 31 (00011111).
13
- // `Math.clz32` is not used, because it is not available in browsers.
14
- let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
15
- // Though, the bitmask solution is not perfect since the bytes exceeding
16
- // the alphabet size are refused. Therefore, to reliably generate the ID,
17
- // the random bytes redundancy has to be satisfied.
18
-
19
- // Note: every hardware random generator call is performance expensive,
20
- // because the system call for entropy collection takes a lot of time.
21
- // So, to avoid additional system calls, extra bytes are requested in advance.
22
-
23
- // Next, a step determines how many random bytes to generate.
24
- // The number of random bytes gets decided upon the ID size, mask,
25
- // alphabet size, and magic number 1.6 (using 1.6 peaks at performance
26
- // according to benchmarks).
27
-
28
- // `-~f => Math.ceil(f)` if f is a float
29
- // `-~i => i + 1` if i is an integer
30
- let step = -~((1.6 * mask * defaultSize) / alphabet.length)
31
-
32
- return (size = defaultSize) => {
33
- let id = ''
34
- while (true) {
35
- let bytes = getRandom(step)
36
- // A compact alternative for `for (var i = 0; i < step; i++)`.
37
- let j = step | 0
38
- while (j--) {
39
- // Adding `|| ''` refuses a random byte that exceeds the alphabet size.
40
- id += alphabet[bytes[j] & mask] || ''
41
- if (id.length === size) return id
42
- }
43
- }
44
- }
45
- }
46
-
47
- let customAlphabet = (alphabet, size = 21) =>
48
- customRandom(alphabet, size, random)
49
-
50
- let nanoid = (size = 21) =>
51
- crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
52
- // It is incorrect to use bytes exceeding the alphabet size.
53
- // The following mask reduces the random byte in the 0-255 value
54
- // range to the 0-63 value range. Therefore, adding hacks, such
55
- // as empty string fallback or magic numbers, is unneccessary because
56
- // the bitmask trims bytes down to the alphabet size.
57
- byte &= 63
58
- if (byte < 36) {
59
- // `0-9a-z`
60
- id += byte.toString(36)
61
- } else if (byte < 62) {
62
- // `A-Z`
63
- id += (byte - 26).toString(36).toUpperCase()
64
- } else if (byte > 62) {
65
- id += '-'
66
- } else {
67
- id += '_'
68
- }
69
- return id
70
- }, '')
71
-
72
- module.exports = { nanoid, customAlphabet, customRandom, urlAlphabet, random }
@@ -1,72 +0,0 @@
1
- // This file replaces `index.js` in bundlers like webpack or Rollup,
2
- // according to `browser` config in `package.json`.
3
-
4
- import { urlAlphabet } from './url-alphabet/index.js'
5
-
6
- let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))
7
-
8
- let customRandom = (alphabet, defaultSize, getRandom) => {
9
- // First, a bitmask is necessary to generate the ID. The bitmask makes bytes
10
- // values closer to the alphabet size. The bitmask calculates the closest
11
- // `2^31 - 1` number, which exceeds the alphabet size.
12
- // For example, the bitmask for the alphabet size 30 is 31 (00011111).
13
- // `Math.clz32` is not used, because it is not available in browsers.
14
- let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
15
- // Though, the bitmask solution is not perfect since the bytes exceeding
16
- // the alphabet size are refused. Therefore, to reliably generate the ID,
17
- // the random bytes redundancy has to be satisfied.
18
-
19
- // Note: every hardware random generator call is performance expensive,
20
- // because the system call for entropy collection takes a lot of time.
21
- // So, to avoid additional system calls, extra bytes are requested in advance.
22
-
23
- // Next, a step determines how many random bytes to generate.
24
- // The number of random bytes gets decided upon the ID size, mask,
25
- // alphabet size, and magic number 1.6 (using 1.6 peaks at performance
26
- // according to benchmarks).
27
-
28
- // `-~f => Math.ceil(f)` if f is a float
29
- // `-~i => i + 1` if i is an integer
30
- let step = -~((1.6 * mask * defaultSize) / alphabet.length)
31
-
32
- return (size = defaultSize) => {
33
- let id = ''
34
- while (true) {
35
- let bytes = getRandom(step)
36
- // A compact alternative for `for (var i = 0; i < step; i++)`.
37
- let j = step | 0
38
- while (j--) {
39
- // Adding `|| ''` refuses a random byte that exceeds the alphabet size.
40
- id += alphabet[bytes[j] & mask] || ''
41
- if (id.length === size) return id
42
- }
43
- }
44
- }
45
- }
46
-
47
- let customAlphabet = (alphabet, size = 21) =>
48
- customRandom(alphabet, size, random)
49
-
50
- let nanoid = (size = 21) =>
51
- crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
52
- // It is incorrect to use bytes exceeding the alphabet size.
53
- // The following mask reduces the random byte in the 0-255 value
54
- // range to the 0-63 value range. Therefore, adding hacks, such
55
- // as empty string fallback or magic numbers, is unneccessary because
56
- // the bitmask trims bytes down to the alphabet size.
57
- byte &= 63
58
- if (byte < 36) {
59
- // `0-9a-z`
60
- id += byte.toString(36)
61
- } else if (byte < 62) {
62
- // `A-Z`
63
- id += (byte - 26).toString(36).toUpperCase()
64
- } else if (byte > 62) {
65
- id += '-'
66
- } else {
67
- id += '_'
68
- }
69
- return id
70
- }, '')
71
-
72
- export { nanoid, customAlphabet, customRandom, urlAlphabet, random }
@@ -1 +0,0 @@
1
- (function(){var e={113:function(e){"use strict";e.exports=require("crypto")},775:function(e,t,r){let l=r(113);let{urlAlphabet:n}=r(265);const a=128;let u,i;let fillPool=e=>{if(!u||u.length<e){u=Buffer.allocUnsafe(e*a);l.randomFillSync(u);i=0}else if(i+e>u.length){l.randomFillSync(u);i=0}i+=e};let random=e=>{fillPool(e|=0);return u.subarray(i-e,i)};let customRandom=(e,t,r)=>{let l=(2<<31-Math.clz32(e.length-1|1))-1;let n=Math.ceil(1.6*l*t/e.length);return(a=t)=>{let u="";while(true){let t=r(n);let i=n;while(i--){u+=e[t[i]&l]||"";if(u.length===a)return u}}}};let customAlphabet=(e,t=21)=>customRandom(e,t,random);let nanoid=(e=21)=>{fillPool(e|=0);let t="";for(let r=i-e;r<i;r++){t+=n[u[r]&63]}return t};e.exports={nanoid:nanoid,customAlphabet:customAlphabet,customRandom:customRandom,urlAlphabet:n,random:random}},265:function(e){let t="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";e.exports={urlAlphabet:t}}};var t={};function __nccwpck_require__(r){var l=t[r];if(l!==undefined){return l.exports}var n=t[r]={exports:{}};var a=true;try{e[r](n,n.exports,__nccwpck_require__);a=false}finally{if(a)delete t[r]}return n.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r=__nccwpck_require__(775);module.exports=r})();
@@ -1,91 +0,0 @@
1
- /**
2
- * Generate secure URL-friendly unique ID.
3
- *
4
- * By default, the ID will have 21 symbols to have a collision probability
5
- * similar to UUID v4.
6
- *
7
- * ```js
8
- * import { nanoid } from 'nanoid'
9
- * model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"
10
- * ```
11
- *
12
- * @param size Size of the ID. The default size is 21.
13
- * @returns A random string.
14
- */
15
- export function nanoid(size?: number): string
16
-
17
- /**
18
- * Generate secure unique ID with custom alphabet.
19
- *
20
- * Alphabet must contain 256 symbols or less. Otherwise, the generator
21
- * will not be secure.
22
- *
23
- * @param alphabet Alphabet used to generate the ID.
24
- * @param defaultSize Size of the ID. The default size is 21.
25
- * @returns A random string generator.
26
- *
27
- * ```js
28
- * const { customAlphabet } = require('nanoid')
29
- * const nanoid = customAlphabet('0123456789абвгдеё', 5)
30
- * nanoid() //=> "8ё56а"
31
- * ```
32
- */
33
- export function customAlphabet(
34
- alphabet: string,
35
- defaultSize?: number
36
- ): (size?: number) => string
37
-
38
- /**
39
- * Generate unique ID with custom random generator and alphabet.
40
- *
41
- * Alphabet must contain 256 symbols or less. Otherwise, the generator
42
- * will not be secure.
43
- *
44
- * ```js
45
- * import { customRandom } from 'nanoid/format'
46
- *
47
- * const nanoid = customRandom('abcdef', 5, size => {
48
- * const random = []
49
- * for (let i = 0; i < size; i++) {
50
- * random.push(randomByte())
51
- * }
52
- * return random
53
- * })
54
- *
55
- * nanoid() //=> "fbaef"
56
- * ```
57
- *
58
- * @param alphabet Alphabet used to generate a random string.
59
- * @param size Size of the random string.
60
- * @param random A random bytes generator.
61
- * @returns A random string generator.
62
- */
63
- export function customRandom(
64
- alphabet: string,
65
- size: number,
66
- random: (bytes: number) => Uint8Array
67
- ): () => string
68
-
69
- /**
70
- * URL safe symbols.
71
- *
72
- * ```js
73
- * import { urlAlphabet } from 'nanoid'
74
- * const nanoid = customAlphabet(urlAlphabet, 10)
75
- * nanoid() //=> "Uakgb_J5m9"
76
- * ```
77
- */
78
- export const urlAlphabet: string
79
-
80
- /**
81
- * Generate an array of random bytes collected from hardware noise.
82
- *
83
- * ```js
84
- * import { customRandom, random } from 'nanoid'
85
- * const nanoid = customRandom("abcdef", 5, random)
86
- * ```
87
- *
88
- * @param bytes Size of the array.
89
- * @returns An array of random bytes.
90
- */
91
- export function random(bytes: number): Uint8Array
@@ -1,91 +0,0 @@
1
- /**
2
- * Generate secure URL-friendly unique ID.
3
- *
4
- * By default, the ID will have 21 symbols to have a collision probability
5
- * similar to UUID v4.
6
- *
7
- * ```js
8
- * import { nanoid } from 'nanoid'
9
- * model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"
10
- * ```
11
- *
12
- * @param size Size of the ID. The default size is 21.
13
- * @returns A random string.
14
- */
15
- export function nanoid(size?: number): string
16
-
17
- /**
18
- * Generate secure unique ID with custom alphabet.
19
- *
20
- * Alphabet must contain 256 symbols or less. Otherwise, the generator
21
- * will not be secure.
22
- *
23
- * @param alphabet Alphabet used to generate the ID.
24
- * @param defaultSize Size of the ID. The default size is 21.
25
- * @returns A random string generator.
26
- *
27
- * ```js
28
- * const { customAlphabet } = require('nanoid')
29
- * const nanoid = customAlphabet('0123456789абвгдеё', 5)
30
- * nanoid() //=> "8ё56а"
31
- * ```
32
- */
33
- export function customAlphabet(
34
- alphabet: string,
35
- defaultSize?: number
36
- ): (size?: number) => string
37
-
38
- /**
39
- * Generate unique ID with custom random generator and alphabet.
40
- *
41
- * Alphabet must contain 256 symbols or less. Otherwise, the generator
42
- * will not be secure.
43
- *
44
- * ```js
45
- * import { customRandom } from 'nanoid/format'
46
- *
47
- * const nanoid = customRandom('abcdef', 5, size => {
48
- * const random = []
49
- * for (let i = 0; i < size; i++) {
50
- * random.push(randomByte())
51
- * }
52
- * return random
53
- * })
54
- *
55
- * nanoid() //=> "fbaef"
56
- * ```
57
- *
58
- * @param alphabet Alphabet used to generate a random string.
59
- * @param size Size of the random string.
60
- * @param random A random bytes generator.
61
- * @returns A random string generator.
62
- */
63
- export function customRandom(
64
- alphabet: string,
65
- size: number,
66
- random: (bytes: number) => Uint8Array
67
- ): () => string
68
-
69
- /**
70
- * URL safe symbols.
71
- *
72
- * ```js
73
- * import { urlAlphabet } from 'nanoid'
74
- * const nanoid = customAlphabet(urlAlphabet, 10)
75
- * nanoid() //=> "Uakgb_J5m9"
76
- * ```
77
- */
78
- export const urlAlphabet: string
79
-
80
- /**
81
- * Generate an array of random bytes collected from hardware noise.
82
- *
83
- * ```js
84
- * import { customRandom, random } from 'nanoid'
85
- * const nanoid = customRandom("abcdef", 5, random)
86
- * ```
87
- *
88
- * @param bytes Size of the array.
89
- * @returns An array of random bytes.
90
- */
91
- export function random(bytes: number): Uint8Array
@@ -1,85 +0,0 @@
1
- import crypto from 'crypto'
2
-
3
- import { urlAlphabet } from './url-alphabet/index.js'
4
-
5
- // It is best to make fewer, larger requests to the crypto module to
6
- // avoid system call overhead. So, random numbers are generated in a
7
- // pool. The pool is a Buffer that is larger than the initial random
8
- // request size by this multiplier. The pool is enlarged if subsequent
9
- // requests exceed the maximum buffer size.
10
- const POOL_SIZE_MULTIPLIER = 128
11
- let pool, poolOffset
12
-
13
- let fillPool = bytes => {
14
- if (!pool || pool.length < bytes) {
15
- pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER)
16
- crypto.randomFillSync(pool)
17
- poolOffset = 0
18
- } else if (poolOffset + bytes > pool.length) {
19
- crypto.randomFillSync(pool)
20
- poolOffset = 0
21
- }
22
- poolOffset += bytes
23
- }
24
-
25
- let random = bytes => {
26
- // `|=` convert `bytes` to number to prevent `valueOf` abusing and pool pollution
27
- fillPool((bytes |= 0))
28
- return pool.subarray(poolOffset - bytes, poolOffset)
29
- }
30
-
31
- let customRandom = (alphabet, defaultSize, getRandom) => {
32
- // First, a bitmask is necessary to generate the ID. The bitmask makes bytes
33
- // values closer to the alphabet size. The bitmask calculates the closest
34
- // `2^31 - 1` number, which exceeds the alphabet size.
35
- // For example, the bitmask for the alphabet size 30 is 31 (00011111).
36
- let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
37
- // Though, the bitmask solution is not perfect since the bytes exceeding
38
- // the alphabet size are refused. Therefore, to reliably generate the ID,
39
- // the random bytes redundancy has to be satisfied.
40
-
41
- // Note: every hardware random generator call is performance expensive,
42
- // because the system call for entropy collection takes a lot of time.
43
- // So, to avoid additional system calls, extra bytes are requested in advance.
44
-
45
- // Next, a step determines how many random bytes to generate.
46
- // The number of random bytes gets decided upon the ID size, mask,
47
- // alphabet size, and magic number 1.6 (using 1.6 peaks at performance
48
- // according to benchmarks).
49
- let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
50
-
51
- return (size = defaultSize) => {
52
- let id = ''
53
- while (true) {
54
- let bytes = getRandom(step)
55
- // A compact alternative for `for (let i = 0; i < step; i++)`.
56
- let i = step
57
- while (i--) {
58
- // Adding `|| ''` refuses a random byte that exceeds the alphabet size.
59
- id += alphabet[bytes[i] & mask] || ''
60
- if (id.length === size) return id
61
- }
62
- }
63
- }
64
- }
65
-
66
- let customAlphabet = (alphabet, size = 21) =>
67
- customRandom(alphabet, size, random)
68
-
69
- let nanoid = (size = 21) => {
70
- // `|=` convert `size` to number to prevent `valueOf` abusing and pool pollution
71
- fillPool((size |= 0))
72
- let id = ''
73
- // We are reading directly from the random pool to avoid creating new array
74
- for (let i = poolOffset - size; i < poolOffset; i++) {
75
- // It is incorrect to use bytes exceeding the alphabet size.
76
- // The following mask reduces the random byte in the 0-255 value
77
- // range to the 0-63 value range. Therefore, adding hacks, such
78
- // as empty string fallback or magic numbers, is unneccessary because
79
- // the bitmask trims bytes down to the alphabet size.
80
- id += urlAlphabet[pool[i] & 63]
81
- }
82
- return id
83
- }
84
-
85
- export { nanoid, customAlphabet, customRandom, urlAlphabet, random }
@@ -1 +0,0 @@
1
- export let nanoid=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce(((t,e)=>t+=(e&=63)<36?e.toString(36):e<62?(e-26).toString(36).toUpperCase():e<63?"_":"-"),"");
@@ -1,34 +0,0 @@
1
- // This alphabet uses `A-Za-z0-9_-` symbols.
2
- // The order of characters is optimized for better gzip and brotli compression.
3
- // References to the same file (works both for gzip and brotli):
4
- // `'use`, `andom`, and `rict'`
5
- // References to the brotli default dictionary:
6
- // `-26T`, `1983`, `40px`, `75px`, `bush`, `jack`, `mind`, `very`, and `wolf`
7
- let urlAlphabet =
8
- 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
9
-
10
- let customAlphabet = (alphabet, defaultSize = 21) => {
11
- return (size = defaultSize) => {
12
- let id = ''
13
- // A compact alternative for `for (var i = 0; i < step; i++)`.
14
- let i = size | 0
15
- while (i--) {
16
- // `| 0` is more compact and faster than `Math.floor()`.
17
- id += alphabet[(Math.random() * alphabet.length) | 0]
18
- }
19
- return id
20
- }
21
- }
22
-
23
- let nanoid = (size = 21) => {
24
- let id = ''
25
- // A compact alternative for `for (var i = 0; i < step; i++)`.
26
- let i = size | 0
27
- while (i--) {
28
- // `| 0` is more compact and faster than `Math.floor()`.
29
- id += urlAlphabet[(Math.random() * 64) | 0]
30
- }
31
- return id
32
- }
33
-
34
- module.exports = { nanoid, customAlphabet }
@@ -1,33 +0,0 @@
1
- /**
2
- * Generate URL-friendly unique ID. This method uses the non-secure
3
- * predictable random generator with bigger collision probability.
4
- *
5
- * ```js
6
- * import { nanoid } from 'nanoid/non-secure'
7
- * model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"
8
- * ```
9
- *
10
- * @param size Size of the ID. The default size is 21.
11
- * @returns A random string.
12
- */
13
- export function nanoid(size?: number): string
14
-
15
- /**
16
- * Generate a unique ID based on a custom alphabet.
17
- * This method uses the non-secure predictable random generator
18
- * with bigger collision probability.
19
- *
20
- * @param alphabet Alphabet used to generate the ID.
21
- * @param defaultSize Size of the ID. The default size is 21.
22
- * @returns A random string generator.
23
- *
24
- * ```js
25
- * import { customAlphabet } from 'nanoid/non-secure'
26
- * const nanoid = customAlphabet('0123456789абвгдеё', 5)
27
- * model.id = //=> "8ё56а"
28
- * ```
29
- */
30
- export function customAlphabet(
31
- alphabet: string,
32
- defaultSize?: number
33
- ): (size?: number) => string
@@ -1,34 +0,0 @@
1
- // This alphabet uses `A-Za-z0-9_-` symbols.
2
- // The order of characters is optimized for better gzip and brotli compression.
3
- // References to the same file (works both for gzip and brotli):
4
- // `'use`, `andom`, and `rict'`
5
- // References to the brotli default dictionary:
6
- // `-26T`, `1983`, `40px`, `75px`, `bush`, `jack`, `mind`, `very`, and `wolf`
7
- let urlAlphabet =
8
- 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
9
-
10
- let customAlphabet = (alphabet, defaultSize = 21) => {
11
- return (size = defaultSize) => {
12
- let id = ''
13
- // A compact alternative for `for (var i = 0; i < step; i++)`.
14
- let i = size | 0
15
- while (i--) {
16
- // `| 0` is more compact and faster than `Math.floor()`.
17
- id += alphabet[(Math.random() * alphabet.length) | 0]
18
- }
19
- return id
20
- }
21
- }
22
-
23
- let nanoid = (size = 21) => {
24
- let id = ''
25
- // A compact alternative for `for (var i = 0; i < step; i++)`.
26
- let i = size | 0
27
- while (i--) {
28
- // `| 0` is more compact and faster than `Math.floor()`.
29
- id += urlAlphabet[(Math.random() * 64) | 0]
30
- }
31
- return id
32
- }
33
-
34
- export { nanoid, customAlphabet }
@@ -1,6 +0,0 @@
1
- {
2
- "type": "module",
3
- "main": "index.cjs",
4
- "module": "index.js",
5
- "react-native": "index.js"
6
- }
@@ -1 +0,0 @@
1
- {"name":"nanoid","version":"3.3.8","description":"A tiny (116 bytes), secure URL-friendly unique string ID generator","keywords":["uuid","random","id","url"],"engines":{"node":"^10 || ^12 || ^13.7 || ^14 || >=15.0.1"},"funding":[{"type":"github","url":"https://github.com/sponsors/ai"}],"author":"Andrey Sitnik <andrey@sitnik.ru>","license":"MIT","repository":"ai/nanoid","browser":{"./index.js":"./index.browser.js","./async/index.js":"./async/index.browser.js","./async/index.cjs":"./async/index.browser.cjs","./index.cjs":"./index.browser.cjs"},"react-native":"index.js","bin":"./bin/nanoid.cjs","sideEffects":false,"types":"./index.d.ts","type":"module","main":"index.cjs","module":"index.js","exports":{".":{"browser":"./index.browser.js","require":{"types":"./index.d.cts","default":"./index.cjs"},"import":{"types":"./index.d.ts","default":"./index.js"},"default":"./index.js"},"./package.json":"./package.json","./async/package.json":"./async/package.json","./async":{"browser":"./async/index.browser.js","require":{"types":"./index.d.cts","default":"./async/index.cjs"},"import":{"types":"./index.d.ts","default":"./async/index.js"},"default":"./async/index.js"},"./non-secure/package.json":"./non-secure/package.json","./non-secure":{"require":{"types":"./index.d.cts","default":"./non-secure/index.cjs"},"import":{"types":"./index.d.ts","default":"./non-secure/index.js"},"default":"./non-secure/index.js"},"./url-alphabet/package.json":"./url-alphabet/package.json","./url-alphabet":{"require":{"types":"./index.d.cts","default":"./url-alphabet/index.cjs"},"import":{"types":"./index.d.ts","default":"./url-alphabet/index.js"},"default":"./url-alphabet/index.js"}},"_lastModified":"2025-03-05T12:36:57.578Z"}
@@ -1,7 +0,0 @@
1
- // This alphabet uses `A-Za-z0-9_-` symbols.
2
- // The order of characters is optimized for better gzip and brotli compression.
3
- // Same as in non-secure/index.js
4
- let urlAlphabet =
5
- 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
6
-
7
- module.exports = { urlAlphabet }
@@ -1,7 +0,0 @@
1
- // This alphabet uses `A-Za-z0-9_-` symbols.
2
- // The order of characters is optimized for better gzip and brotli compression.
3
- // Same as in non-secure/index.js
4
- let urlAlphabet =
5
- 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
6
-
7
- export { urlAlphabet }
@@ -1,6 +0,0 @@
1
- {
2
- "type": "module",
3
- "main": "index.cjs",
4
- "module": "index.js",
5
- "react-native": "index.js"
6
- }