@20syldev/api 4.8.0 → 4.9.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.
Files changed (109) hide show
  1. package/README.md +84 -47
  2. package/package.json +2 -1
  3. package/.github/FUNDING.yml +0 -1
  4. package/.prettierrc +0 -7
  5. package/eslint.config.js +0 -24
  6. package/robots.txt +0 -74
  7. package/src/app.ts +0 -53
  8. package/src/config/env.ts +0 -87
  9. package/src/config/plans.ts +0 -61
  10. package/src/config/versions.ts +0 -121
  11. package/src/constants.ts +0 -61
  12. package/src/favicon.ico +0 -0
  13. package/src/middleware/cors.ts +0 -23
  14. package/src/middleware/error.ts +0 -16
  15. package/src/middleware/json.ts +0 -9
  16. package/src/middleware/logger.ts +0 -32
  17. package/src/middleware/ratelimit.ts +0 -89
  18. package/src/middleware/version.ts +0 -40
  19. package/src/modules/v3/algorithms.js +0 -218
  20. package/src/modules/v3/captcha.js +0 -60
  21. package/src/modules/v3/chat.js +0 -111
  22. package/src/modules/v3/color.js +0 -60
  23. package/src/modules/v3/convert.js +0 -39
  24. package/src/modules/v3/domain.js +0 -86
  25. package/src/modules/v3/hash.js +0 -16
  26. package/src/modules/v3/hyperplanning.js +0 -56
  27. package/src/modules/v3/levenshtein.js +0 -46
  28. package/src/modules/v3/personal.js +0 -139
  29. package/src/modules/v3/qrcode.js +0 -20
  30. package/src/modules/v3/tic_tac_toe.js +0 -242
  31. package/src/modules/v3/time.js +0 -98
  32. package/src/modules/v3/token.js +0 -54
  33. package/src/modules/v3/username.js +0 -94
  34. package/src/modules/v3/utils.js +0 -77
  35. package/src/modules/v3.js +0 -15
  36. package/src/modules/v4/address.ts +0 -412
  37. package/src/modules/v4/agent.ts +0 -104
  38. package/src/modules/v4/algorithms.ts +0 -276
  39. package/src/modules/v4/captcha.ts +0 -114
  40. package/src/modules/v4/chat.ts +0 -130
  41. package/src/modules/v4/color.ts +0 -75
  42. package/src/modules/v4/convert.ts +0 -127
  43. package/src/modules/v4/cron.ts +0 -221
  44. package/src/modules/v4/dice.ts +0 -46
  45. package/src/modules/v4/domain.ts +0 -86
  46. package/src/modules/v4/encode.ts +0 -241
  47. package/src/modules/v4/geo.ts +0 -64
  48. package/src/modules/v4/hash.ts +0 -32
  49. package/src/modules/v4/hyperplanning.ts +0 -93
  50. package/src/modules/v4/ip.ts +0 -134
  51. package/src/modules/v4/levenshtein.ts +0 -46
  52. package/src/modules/v4/palette.ts +0 -71
  53. package/src/modules/v4/password.ts +0 -379
  54. package/src/modules/v4/personal.ts +0 -140
  55. package/src/modules/v4/placeholder.ts +0 -197
  56. package/src/modules/v4/qrcode.ts +0 -121
  57. package/src/modules/v4/regex.ts +0 -67
  58. package/src/modules/v4/statistics.ts +0 -62
  59. package/src/modules/v4/text.ts +0 -330
  60. package/src/modules/v4/tic_tac_toe.ts +0 -264
  61. package/src/modules/v4/time.ts +0 -149
  62. package/src/modules/v4/token.ts +0 -53
  63. package/src/modules/v4/username.ts +0 -94
  64. package/src/modules/v4/validate.ts +0 -76
  65. package/src/modules/v4.ts +0 -29
  66. package/src/routes/delete.ts +0 -72
  67. package/src/routes/get.ts +0 -856
  68. package/src/routes/index.ts +0 -59
  69. package/src/routes/patch.ts +0 -45
  70. package/src/routes/post.ts +0 -209
  71. package/src/storage/index.ts +0 -16
  72. package/src/types/express.d.ts +0 -17
  73. package/src/types/storage.ts +0 -48
  74. package/src/utils/colors.ts +0 -91
  75. package/src/utils/helpers.ts +0 -90
  76. package/src/utils/response.ts +0 -28
  77. package/tests/integration/api.test.ts +0 -772
  78. package/tests/tsconfig.json +0 -3
  79. package/tests/unit/address.test.ts +0 -84
  80. package/tests/unit/agent.test.ts +0 -113
  81. package/tests/unit/algorithms.test.ts +0 -121
  82. package/tests/unit/captcha.test.ts +0 -62
  83. package/tests/unit/chat.test.ts +0 -54
  84. package/tests/unit/color.test.ts +0 -54
  85. package/tests/unit/convert.test.ts +0 -68
  86. package/tests/unit/cron.test.ts +0 -110
  87. package/tests/unit/dice.test.ts +0 -58
  88. package/tests/unit/domain.test.ts +0 -48
  89. package/tests/unit/encode.test.ts +0 -109
  90. package/tests/unit/geo.test.ts +0 -46
  91. package/tests/unit/hash.test.ts +0 -45
  92. package/tests/unit/hyperplanning.test.ts +0 -97
  93. package/tests/unit/ip.test.ts +0 -140
  94. package/tests/unit/levenshtein.test.ts +0 -35
  95. package/tests/unit/palette.test.ts +0 -54
  96. package/tests/unit/password.test.ts +0 -86
  97. package/tests/unit/personal.test.ts +0 -66
  98. package/tests/unit/placeholder.test.ts +0 -58
  99. package/tests/unit/qrcode.test.ts +0 -83
  100. package/tests/unit/regex.test.ts +0 -95
  101. package/tests/unit/statistics.test.ts +0 -58
  102. package/tests/unit/text.test.ts +0 -108
  103. package/tests/unit/tic_tac_toe.test.ts +0 -56
  104. package/tests/unit/time.test.ts +0 -115
  105. package/tests/unit/token.test.ts +0 -62
  106. package/tests/unit/username.test.ts +0 -35
  107. package/tests/unit/validate.test.ts +0 -72
  108. package/tsconfig.json +0 -17
  109. package/tsconfig.test.json +0 -9
@@ -1,379 +0,0 @@
1
- import { randomInt } from 'crypto';
2
-
3
- import { MAX_PASSWORD_COUNT, MAX_PASSWORD_LENGTH, MIN_PASSWORD_LENGTH } from '../../constants.js';
4
-
5
- const UPPER = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
6
- const LOWER = 'abcdefghijklmnopqrstuvwxyz';
7
- const DIGITS = '0123456789';
8
- const SYMBOLS = '!@#$%^&*()-_=+[]{}|;:,.<>?';
9
-
10
- const WORDLIST = [
11
- 'apple',
12
- 'brave',
13
- 'chair',
14
- 'dance',
15
- 'eagle',
16
- 'fancy',
17
- 'grace',
18
- 'house',
19
- 'ivory',
20
- 'joker',
21
- 'kneel',
22
- 'lemon',
23
- 'maple',
24
- 'noble',
25
- 'ocean',
26
- 'piano',
27
- 'queen',
28
- 'river',
29
- 'stone',
30
- 'tiger',
31
- 'ultra',
32
- 'vivid',
33
- 'waste',
34
- 'xenon',
35
- 'yacht',
36
- 'zebra',
37
- 'amber',
38
- 'blaze',
39
- 'coral',
40
- 'drift',
41
- 'ember',
42
- 'flora',
43
- 'globe',
44
- 'haven',
45
- 'input',
46
- 'jumpy',
47
- 'karma',
48
- 'lunar',
49
- 'magic',
50
- 'night',
51
- 'optic',
52
- 'proxy',
53
- 'quirk',
54
- 'radar',
55
- 'solar',
56
- 'trace',
57
- 'umbra',
58
- 'vapor',
59
- 'witch',
60
- 'xylem',
61
- 'yield',
62
- 'zippy',
63
- 'alpha',
64
- 'brisk',
65
- 'crane',
66
- 'depth',
67
- 'event',
68
- 'frost',
69
- 'grime',
70
- 'harsh',
71
- 'index',
72
- 'joint',
73
- 'knack',
74
- 'level',
75
- 'minus',
76
- 'nerve',
77
- 'onset',
78
- 'phase',
79
- 'quest',
80
- 'ratio',
81
- 'scope',
82
- 'trend',
83
- 'union',
84
- 'valve',
85
- 'weary',
86
- 'young',
87
- 'blunt',
88
- 'clean',
89
- 'drive',
90
- 'earth',
91
- 'fiber',
92
- 'grain',
93
- 'grind',
94
- 'horse',
95
- 'ideal',
96
- 'issue',
97
- 'judge',
98
- 'juice',
99
- 'knave',
100
- 'large',
101
- 'laser',
102
- 'light',
103
- 'limit',
104
- 'media',
105
- 'merit',
106
- 'metal',
107
- 'model',
108
- 'money',
109
- 'month',
110
- 'motor',
111
- 'mount',
112
- 'music',
113
- 'nerve',
114
- 'noise',
115
- 'north',
116
- 'noted',
117
- 'novel',
118
- 'nurse',
119
- 'oasis',
120
- 'offer',
121
- 'olive',
122
- 'omega',
123
- 'other',
124
- 'outer',
125
- 'owner',
126
- 'oxide',
127
- 'ozone',
128
- 'paint',
129
- 'panel',
130
- 'paper',
131
- 'patch',
132
- 'pause',
133
- 'peace',
134
- 'pearl',
135
- 'pedal',
136
- 'plain',
137
- 'plank',
138
- 'plant',
139
- 'plate',
140
- 'plaza',
141
- 'pluck',
142
- 'plumb',
143
- 'plume',
144
- 'plunge',
145
- 'point',
146
- 'polar',
147
- 'power',
148
- 'press',
149
- 'pride',
150
- 'prime',
151
- 'print',
152
- 'prism',
153
- 'prize',
154
- 'probe',
155
- 'prone',
156
- 'proof',
157
- 'prose',
158
- 'proud',
159
- 'prove',
160
- 'prowl',
161
- 'pulse',
162
- 'punch',
163
- 'pupil',
164
- 'purge',
165
- 'swift',
166
- 'sword',
167
- 'table',
168
- 'taint',
169
- 'tally',
170
- 'taste',
171
- 'teach',
172
- 'teeth',
173
- 'tempo',
174
- 'tense',
175
- 'tenth',
176
- 'terms',
177
- 'terra',
178
- 'thick',
179
- 'thing',
180
- 'think',
181
- 'thorn',
182
- 'three',
183
- 'throw',
184
- 'thumb',
185
- 'tidal',
186
- 'tight',
187
- 'tilde',
188
- 'timer',
189
- 'title',
190
- 'token',
191
- 'torch',
192
- 'total',
193
- 'touch',
194
- 'tough',
195
- 'tower',
196
- 'track',
197
- 'trade',
198
- 'trail',
199
- 'train',
200
- 'trait',
201
- 'tramp',
202
- 'tread',
203
- 'treat',
204
- 'trees',
205
- 'trial',
206
- 'tribe',
207
- 'trick',
208
- 'tried',
209
- 'troop',
210
- 'trove',
211
- 'truce',
212
- 'truck',
213
- 'truly',
214
- 'trunk',
215
- 'truth',
216
- 'tulip',
217
- 'tumor',
218
- 'tuner',
219
- 'tunic',
220
- 'tweak',
221
- 'twice',
222
- 'twirl',
223
- 'twist',
224
- 'typed',
225
- 'under',
226
- 'unify',
227
- 'unite',
228
- 'unity',
229
- 'until',
230
- 'upper',
231
- 'upset',
232
- 'urban',
233
- 'usage',
234
- 'valid',
235
- 'value',
236
- 'visor',
237
- 'vital',
238
- 'vivid',
239
- 'vocab',
240
- 'vocal',
241
- 'voice',
242
- 'voter',
243
- 'vault',
244
- 'venue',
245
- 'verse',
246
- 'watch',
247
- 'water',
248
- 'weave',
249
- 'wedge',
250
- 'weird',
251
- 'wheel',
252
- 'where',
253
- 'which',
254
- 'while',
255
- 'white',
256
- 'whole',
257
- 'wider',
258
- 'windy',
259
- 'wired',
260
- 'world',
261
- 'worse',
262
- 'worth',
263
- 'would',
264
- 'wound',
265
- 'write',
266
- 'wrong',
267
- 'wrote',
268
- 'years',
269
- 'yield',
270
- 'yours',
271
- ];
272
-
273
- export interface PasswordResult {
274
- passwords: string[];
275
- type: string;
276
- length: number;
277
- strength: string;
278
- entropy: number;
279
- }
280
-
281
- function computeStrength(entropy: number): string {
282
- if (entropy < 40) return 'weak';
283
- if (entropy < 60) return 'moderate';
284
- if (entropy < 80) return 'strong';
285
- return 'very_strong';
286
- }
287
-
288
- function generateRandom(length: number, charset: string): string {
289
- return Array.from({ length }, () => charset[randomInt(charset.length)]).join('');
290
- }
291
-
292
- function generatePassphrase(wordCount: number, separator: string): string {
293
- return Array.from({ length: wordCount }, () => WORDLIST[randomInt(WORDLIST.length)]).join(separator);
294
- }
295
-
296
- /**
297
- * Generates one or more passwords using random characters or passphrase mode.
298
- *
299
- * @param type - Generation mode: "random" or "passphrase"
300
- * @param length - Password length for random mode (8–128), or word count for passphrase mode (3–10)
301
- * @param options - Character set options: uppercase, lowercase, digits, symbols, exclude, count, separator
302
- * @returns Generated passwords with type, length, strength and entropy
303
- * @throws Error if no charset is active, length is out of range, or count exceeds the maximum
304
- */
305
- export default function password(
306
- type: string = 'random',
307
- length: number = 16,
308
- options: {
309
- uppercase?: boolean;
310
- lowercase?: boolean;
311
- digits?: boolean;
312
- symbols?: boolean;
313
- exclude?: string;
314
- count?: number;
315
- separator?: string;
316
- } = {},
317
- ): PasswordResult {
318
- const {
319
- uppercase = true,
320
- lowercase = true,
321
- digits = true,
322
- symbols = false,
323
- exclude = '',
324
- count = 1,
325
- separator = '-',
326
- } = options;
327
-
328
- if (count < 1 || count > MAX_PASSWORD_COUNT) {
329
- throw new Error(`Count must be between 1 and ${MAX_PASSWORD_COUNT}`);
330
- }
331
-
332
- if (type === 'passphrase') {
333
- const wordCount = Math.max(3, Math.min(10, length));
334
- const entropy = Math.log2(Math.pow(WORDLIST.length, wordCount));
335
- const passwords = Array.from({ length: count }, () => generatePassphrase(wordCount, separator));
336
- return {
337
- passwords,
338
- type: 'passphrase',
339
- length: wordCount,
340
- strength: computeStrength(entropy),
341
- entropy: Math.round(entropy * 10) / 10,
342
- };
343
- }
344
-
345
- if (type !== 'random') {
346
- throw new Error('Type must be "random" or "passphrase"');
347
- }
348
-
349
- if (isNaN(length) || length < MIN_PASSWORD_LENGTH || length > MAX_PASSWORD_LENGTH) {
350
- throw new Error(`Length must be between ${MIN_PASSWORD_LENGTH} and ${MAX_PASSWORD_LENGTH}`);
351
- }
352
-
353
- let charset = '';
354
- if (uppercase) charset += UPPER;
355
- if (lowercase) charset += LOWER;
356
- if (digits) charset += DIGITS;
357
- if (symbols) charset += SYMBOLS;
358
-
359
- if (exclude) {
360
- for (const char of exclude) {
361
- charset = charset.replaceAll(char, '');
362
- }
363
- }
364
-
365
- if (charset.length === 0) {
366
- throw new Error('At least one character set must be enabled');
367
- }
368
-
369
- const entropy = Math.log2(Math.pow(charset.length, length));
370
- const passwords = Array.from({ length: count }, () => generateRandom(length, charset));
371
-
372
- return {
373
- passwords,
374
- type: 'random',
375
- length,
376
- strength: computeStrength(entropy),
377
- entropy: Math.round(entropy * 10) / 10,
378
- };
379
- }
@@ -1,140 +0,0 @@
1
- import { random, randomNumber } from '../../utils/helpers.js';
2
- import addressFn from './address.js';
3
-
4
- interface Person {
5
- name: string;
6
- social: string;
7
- email: string;
8
- country: string;
9
- }
10
-
11
- interface CountryInfo {
12
- tel: string;
13
- code: string;
14
- lang: string;
15
- }
16
-
17
- /**
18
- * Generates a fictional personal profile with realistic demographic and contact data.
19
- *
20
- * @returns Object containing name, email, phone, address, job, hobbies, and other personal attributes
21
- */
22
- export default function personal(): Record<string, unknown> {
23
- const people: Person[] = [
24
- { name: 'John Doe', social: 'john_doe', email: 'john@example.com', country: 'US' },
25
- { name: 'Jane Martin', social: 'jane_martin', email: 'jane@example.com', country: 'FR' },
26
- { name: 'Michael Johnson', social: 'mike_johnson', email: 'michael@example.com', country: 'UK' },
27
- { name: 'Emily Davis', social: 'emily_davis', email: 'emily@example.com', country: 'ES' },
28
- { name: 'Alexis Barbos', social: 'alexis_barbos', email: 'alexis@example.com', country: 'DE' },
29
- { name: 'Sarah Williams', social: 'sarah_williams', email: 'sarah@example.com', country: 'IT' },
30
- { name: 'Daniel Brown', social: 'daniel_brown', email: 'daniel@example.com', country: 'JP' },
31
- { name: 'Sophia Wilson', social: 'sophia_wilson', email: 'sophia@example.com', country: 'BR' },
32
- { name: 'James Taylor', social: 'james_taylor', email: 'james@example.com', country: 'CA' },
33
- { name: 'Olivia Thomas', social: 'olivia_thomas', email: 'olivia@example.com', country: 'AU' },
34
- ];
35
-
36
- const countries: Record<string, CountryInfo> = {
37
- US: { tel: '123-456-7890', code: '1', lang: 'English' },
38
- FR: { tel: '06 78 90 12 34', code: '33', lang: 'French' },
39
- UK: { tel: '7911 123456', code: '44', lang: 'English' },
40
- ES: { tel: '678 901 234', code: '34', lang: 'Spanish' },
41
- DE: { tel: '163 555 1584', code: '49', lang: 'German' },
42
- IT: { tel: '345 678 9012', code: '39', lang: 'Italian' },
43
- JP: { tel: '080-1234-5678', code: '81', lang: 'Japanese' },
44
- BR: { tel: '(11) 98765-4321', code: '55', lang: 'Portuguese' },
45
- CA: { tel: '416-123-4567', code: '1', lang: 'English' },
46
- AU: { tel: '0412 345 678', code: '61', lang: 'English' },
47
- };
48
-
49
- const jobs = ['Writer', 'Artist', 'Musician', 'Explorer', 'Scientist', 'Engineer', 'Athlete', 'Doctor'];
50
- const hobbies = ['Reading', 'Traveling', 'Gaming', 'Cooking', 'Fitness', 'Music', 'Photography', 'Writing'];
51
- const card = Array.from({ length: 4 }, () => randomNumber(1000, 9999)).join(' ');
52
- const cvc = randomNumber(100, 999);
53
- const expiration = `${String(randomNumber(1, 12)).padStart(2, '0')}/${(new Date().getFullYear() + randomNumber(0, 3)).toString().slice(-2)}`;
54
-
55
- const person = random(people);
56
- const social = person.social;
57
- const country = person.country;
58
- const countryCodes: Record<string, string> = { US: 'us', FR: 'fr', UK: 'uk', ES: 'es', DE: 'de' };
59
- const addrCountry = countryCodes[country] ?? 'us';
60
- const countryInfo = countries[country]!;
61
- const phone = countryInfo.tel;
62
- const lang = countryInfo.lang;
63
-
64
- const age = randomNumber(18, 67);
65
- const birthday = new Date(Date.now() - randomNumber(18, 67) * 365.25 * 24 * 60 * 60 * 1000).toISOString();
66
-
67
- const emergencyContacts: { name: string; relationship: string; phone: string }[] = [];
68
- const yearIncome = randomNumber(20000, 100000);
69
- const subscriptions: string[] = [];
70
- const pets: string[] = [];
71
- const vehicles: string[] = [];
72
- let civilStatus = 'Single';
73
- let children = 0;
74
-
75
- if (age >= 21 && Math.random() > 0.7) civilStatus = 'Married';
76
- if (civilStatus === 'Married' && age >= 25) children = randomNumber(0, 3);
77
-
78
- while (emergencyContacts.length < randomNumber(1, 3)) {
79
- let emergencyContact = random(people);
80
- while (
81
- emergencyContact.email === person.email ||
82
- emergencyContacts.some((e) => e.name === emergencyContact.name)
83
- ) {
84
- emergencyContact = random(people);
85
- }
86
- const emergencyPhone = `${randomNumber(100, 999)}-${randomNumber(100, 999)}-${randomNumber(1000, 9999)}`;
87
- emergencyContacts.push({
88
- name: emergencyContact.name,
89
- relationship: random(['Spouse', 'Parent', 'Sibling', 'Friend']),
90
- phone: `+${countryInfo.code} ${emergencyPhone}`,
91
- });
92
- }
93
-
94
- while (subscriptions.length < randomNumber(1, 3)) {
95
- const subscription = random(['Netflix', 'Spotify', 'Amazon Prime', 'Disney+', 'Hulu']);
96
- if (!subscriptions.includes(subscription)) subscriptions.push(subscription);
97
- }
98
-
99
- while (pets.length < randomNumber(1, 3)) {
100
- const pet = random(['Dog', 'Cat', 'Fish', 'Bird', 'None']);
101
- if (!pets.includes(pet)) pets.push(pet);
102
- }
103
-
104
- while (vehicles.length < randomNumber(1, 3)) {
105
- const vehicle = random(['Car', 'Bike', 'Motorcycle', 'Bus', 'None']);
106
- if (!vehicles.includes(vehicle)) vehicles.push(vehicle);
107
- }
108
-
109
- return {
110
- name: person.name,
111
- email: person.email,
112
- localisation: country,
113
- phone: `+${countryInfo.code} ${phone}`,
114
- job: random(jobs),
115
- hobbies: random(hobbies),
116
- language: lang,
117
- card,
118
- cvc,
119
- expiration,
120
- address: addressFn(addrCountry).addresses[0]!,
121
- birthday,
122
- civil_status: civilStatus,
123
- children,
124
- vehicle: vehicles,
125
- social_profiles: {
126
- twitter: `@${social}`,
127
- facebook: `facebook.com/${social}`,
128
- linkedin: `linkedin.com/in/${social}`,
129
- instagram: `instagram.com/${social}`,
130
- },
131
- year_income: `${yearIncome} USD/year`,
132
- month_income: `${(yearIncome / 12).toFixed(2)} USD/month`,
133
- education: random(['High School', "Bachelor's", "Master's", 'PhD']),
134
- work_experience: `${randomNumber(0, 20)} years`,
135
- health_status: random(['Healthy', 'Minor Issues', 'Chronic Conditions']),
136
- emergency_contacts: emergencyContacts,
137
- subscriptions,
138
- pets,
139
- };
140
- }