Add build script for shared modules (#771)

This commit is contained in:
Leendert de Borst
2025-04-30 23:10:44 +02:00
parent 048e6f8d2a
commit 7ae8655c2d
44 changed files with 12506 additions and 4233 deletions

3
shared/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
**/dist
**/node_modules
**/*.tsbuildinfo

View File

@@ -1,117 +0,0 @@
declare enum Gender {
Male = "Male",
Female = "Female",
Other = "Other"
}
/**
* Identity.
*/
type Identity = {
firstName: string;
lastName: string;
gender: Gender;
birthDate: Date;
emailPrefix: string;
nickName: string;
};
/**
* Generate a username or email prefix.
*/
declare class UsernameEmailGenerator {
private static readonly MIN_LENGTH;
private static readonly MAX_LENGTH;
private readonly symbols;
/**
* Generate a username based on an identity.
*/
generateUsername(identity: Identity): string;
/**
* Generate an email prefix based on an identity.
*/
generateEmailPrefix(identity: Identity): string;
/**
* Sanitize an email prefix.
*/
private sanitizeEmailPrefix;
/**
* Get a random symbol.
*/
private getRandomSymbol;
/**
* Generate a random string.
*/
private generateRandomString;
/**
* Generate a secure random integer between 0 (inclusive) and max (exclusive)
*/
private getSecureRandom;
}
interface IIdentityGenerator {
generateRandomIdentity(): Promise<Identity>;
}
/**
* Base identity generator.
*/
declare abstract class BaseIdentityGenerator implements IIdentityGenerator {
protected firstNamesMale: string[];
protected firstNamesFemale: string[];
protected lastNames: string[];
private readonly random;
/**
* Constructor.
*/
constructor();
protected abstract getFirstNamesMaleJson(): string[];
protected abstract getFirstNamesFemaleJson(): string[];
protected abstract getLastNamesJson(): string[];
/**
* Generate a random date of birth.
*/
protected generateRandomDateOfBirth(): Date;
/**
* Generate a random identity.
*/
generateRandomIdentity(): Promise<Identity>;
}
/**
* Identity generator for English language using English word dictionaries.
*/
declare class IdentityGeneratorEn extends BaseIdentityGenerator {
/**
* Get the male first names.
*/
protected getFirstNamesMaleJson(): string[];
/**
* Get the female first names.
*/
protected getFirstNamesFemaleJson(): string[];
/**
* Get the last names.
*/
protected getLastNamesJson(): string[];
}
/**
* Identity generator for Dutch language using Dutch word dictionaries.
*/
declare class IdentityGeneratorNl extends BaseIdentityGenerator {
/**
* Get the male first names.
*/
protected getFirstNamesMaleJson(): string[];
/**
* Get the female first names.
*/
protected getFirstNamesFemaleJson(): string[];
/**
* Get the last names.
*/
protected getLastNamesJson(): string[];
}
export { Gender, type Identity, IdentityGeneratorEn, IdentityGeneratorNl, UsernameEmailGenerator };

View File

@@ -1,117 +0,0 @@
declare enum Gender {
Male = "Male",
Female = "Female",
Other = "Other"
}
/**
* Identity.
*/
type Identity = {
firstName: string;
lastName: string;
gender: Gender;
birthDate: Date;
emailPrefix: string;
nickName: string;
};
/**
* Generate a username or email prefix.
*/
declare class UsernameEmailGenerator {
private static readonly MIN_LENGTH;
private static readonly MAX_LENGTH;
private readonly symbols;
/**
* Generate a username based on an identity.
*/
generateUsername(identity: Identity): string;
/**
* Generate an email prefix based on an identity.
*/
generateEmailPrefix(identity: Identity): string;
/**
* Sanitize an email prefix.
*/
private sanitizeEmailPrefix;
/**
* Get a random symbol.
*/
private getRandomSymbol;
/**
* Generate a random string.
*/
private generateRandomString;
/**
* Generate a secure random integer between 0 (inclusive) and max (exclusive)
*/
private getSecureRandom;
}
interface IIdentityGenerator {
generateRandomIdentity(): Promise<Identity>;
}
/**
* Base identity generator.
*/
declare abstract class BaseIdentityGenerator implements IIdentityGenerator {
protected firstNamesMale: string[];
protected firstNamesFemale: string[];
protected lastNames: string[];
private readonly random;
/**
* Constructor.
*/
constructor();
protected abstract getFirstNamesMaleJson(): string[];
protected abstract getFirstNamesFemaleJson(): string[];
protected abstract getLastNamesJson(): string[];
/**
* Generate a random date of birth.
*/
protected generateRandomDateOfBirth(): Date;
/**
* Generate a random identity.
*/
generateRandomIdentity(): Promise<Identity>;
}
/**
* Identity generator for English language using English word dictionaries.
*/
declare class IdentityGeneratorEn extends BaseIdentityGenerator {
/**
* Get the male first names.
*/
protected getFirstNamesMaleJson(): string[];
/**
* Get the female first names.
*/
protected getFirstNamesFemaleJson(): string[];
/**
* Get the last names.
*/
protected getLastNamesJson(): string[];
}
/**
* Identity generator for Dutch language using Dutch word dictionaries.
*/
declare class IdentityGeneratorNl extends BaseIdentityGenerator {
/**
* Get the male first names.
*/
protected getFirstNamesMaleJson(): string[];
/**
* Get the female first names.
*/
protected getFirstNamesFemaleJson(): string[];
/**
* Get the last names.
*/
protected getLastNamesJson(): string[];
}
export { Gender, type Identity, IdentityGeneratorEn, IdentityGeneratorNl, UsernameEmailGenerator };

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,113 +0,0 @@
/**
* Settings for password generation stored in SQLite database settings table as string.
*/
type PasswordSettings = {
/**
* The length of the password.
*/
Length: number;
/**
* Whether to use lowercase letters.
*/
UseLowercase: boolean;
/**
* Whether to use uppercase letters.
*/
UseUppercase: boolean;
/**
* Whether to use numbers.
*/
UseNumbers: boolean;
/**
* Whether to use special characters.
*/
UseSpecialChars: boolean;
/**
* Whether to use non-ambiguous characters.
*/
UseNonAmbiguousChars: boolean;
};
/**
* Generate a random password.
*/
declare class PasswordGenerator {
private readonly lowercaseChars;
private readonly uppercaseChars;
private readonly numberChars;
private readonly specialChars;
private readonly ambiguousChars;
private length;
private useLowercase;
private useUppercase;
private useNumbers;
private useSpecial;
private useNonAmbiguous;
/**
* Create a new instance of PasswordGenerator.
* @param settings Optional password settings to initialize with.
*/
constructor(settings?: PasswordSettings);
/**
* Apply password settings to this generator.
*/
applySettings(settings: PasswordSettings): this;
/**
* Set the length of the password.
*/
setLength(length: number): this;
/**
* Set if lowercase letters should be used.
*/
useLowercaseLetters(use: boolean): this;
/**
* Set if uppercase letters should be used.
*/
useUppercaseLetters(use: boolean): this;
/**
* Set if numeric characters should be used.
*/
useNumericCharacters(use: boolean): this;
/**
* Set if special characters should be used.
*/
useSpecialCharacters(use: boolean): this;
/**
* Set if only non-ambiguous characters should be used.
*/
useNonAmbiguousCharacters(use: boolean): this;
/**
* Get a random index from the crypto module.
*/
private getUnbiasedRandomIndex;
/**
* Generate a random password.
*/
generateRandomPassword(): string;
/**
* Build character set based on selected options.
*/
private buildCharacterSet;
/**
* Remove ambiguous characters from a character set.
*/
private removeAmbiguousCharacters;
/**
* Generate initial random password.
*/
private generateInitialPassword;
/**
* Ensure the generated password meets all specified requirements.
*/
private ensureRequirements;
/**
* Get a character set with ambiguous characters removed if needed.
*/
private getSafeCharacterSet;
/**
* Add a character from the given set at a random position in the password.
*/
private addCharacterFromSet;
}
export { PasswordGenerator, type PasswordSettings };

View File

@@ -1,113 +0,0 @@
/**
* Settings for password generation stored in SQLite database settings table as string.
*/
type PasswordSettings = {
/**
* The length of the password.
*/
Length: number;
/**
* Whether to use lowercase letters.
*/
UseLowercase: boolean;
/**
* Whether to use uppercase letters.
*/
UseUppercase: boolean;
/**
* Whether to use numbers.
*/
UseNumbers: boolean;
/**
* Whether to use special characters.
*/
UseSpecialChars: boolean;
/**
* Whether to use non-ambiguous characters.
*/
UseNonAmbiguousChars: boolean;
};
/**
* Generate a random password.
*/
declare class PasswordGenerator {
private readonly lowercaseChars;
private readonly uppercaseChars;
private readonly numberChars;
private readonly specialChars;
private readonly ambiguousChars;
private length;
private useLowercase;
private useUppercase;
private useNumbers;
private useSpecial;
private useNonAmbiguous;
/**
* Create a new instance of PasswordGenerator.
* @param settings Optional password settings to initialize with.
*/
constructor(settings?: PasswordSettings);
/**
* Apply password settings to this generator.
*/
applySettings(settings: PasswordSettings): this;
/**
* Set the length of the password.
*/
setLength(length: number): this;
/**
* Set if lowercase letters should be used.
*/
useLowercaseLetters(use: boolean): this;
/**
* Set if uppercase letters should be used.
*/
useUppercaseLetters(use: boolean): this;
/**
* Set if numeric characters should be used.
*/
useNumericCharacters(use: boolean): this;
/**
* Set if special characters should be used.
*/
useSpecialCharacters(use: boolean): this;
/**
* Set if only non-ambiguous characters should be used.
*/
useNonAmbiguousCharacters(use: boolean): this;
/**
* Get a random index from the crypto module.
*/
private getUnbiasedRandomIndex;
/**
* Generate a random password.
*/
generateRandomPassword(): string;
/**
* Build character set based on selected options.
*/
private buildCharacterSet;
/**
* Remove ambiguous characters from a character set.
*/
private removeAmbiguousCharacters;
/**
* Generate initial random password.
*/
private generateInitialPassword;
/**
* Ensure the generated password meets all specified requirements.
*/
private ensureRequirements;
/**
* Get a character set with ambiguous characters removed if needed.
*/
private getSafeCharacterSet;
/**
* Add a character from the given set at a random position in the password.
*/
private addCharacterFromSet;
}
export { PasswordGenerator, type PasswordSettings };

View File

@@ -1,237 +0,0 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var index_exports = {};
__export(index_exports, {
PasswordGenerator: () => PasswordGenerator
});
module.exports = __toCommonJS(index_exports);
// src/utils/PasswordGenerator.ts
var PasswordGenerator = class {
/**
* Create a new instance of PasswordGenerator.
* @param settings Optional password settings to initialize with.
*/
constructor(settings) {
this.lowercaseChars = "abcdefghijklmnopqrstuvwxyz";
this.uppercaseChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
this.numberChars = "0123456789";
this.specialChars = "!@#$%^&*()_+-=[]{}|;:,.<>?";
this.ambiguousChars = "Il1O0";
this.length = 18;
this.useLowercase = true;
this.useUppercase = true;
this.useNumbers = true;
this.useSpecial = true;
this.useNonAmbiguous = false;
if (settings) {
this.applySettings(settings);
}
}
/**
* Apply password settings to this generator.
*/
applySettings(settings) {
this.length = settings.Length;
this.useLowercase = settings.UseLowercase;
this.useUppercase = settings.UseUppercase;
this.useNumbers = settings.UseNumbers;
this.useSpecial = settings.UseSpecialChars;
this.useNonAmbiguous = settings.UseNonAmbiguousChars;
return this;
}
/**
* Set the length of the password.
*/
setLength(length) {
this.length = length;
return this;
}
/**
* Set if lowercase letters should be used.
*/
useLowercaseLetters(use) {
this.useLowercase = use;
return this;
}
/**
* Set if uppercase letters should be used.
*/
useUppercaseLetters(use) {
this.useUppercase = use;
return this;
}
/**
* Set if numeric characters should be used.
*/
useNumericCharacters(use) {
this.useNumbers = use;
return this;
}
/**
* Set if special characters should be used.
*/
useSpecialCharacters(use) {
this.useSpecial = use;
return this;
}
/**
* Set if only non-ambiguous characters should be used.
*/
useNonAmbiguousCharacters(use) {
this.useNonAmbiguous = use;
return this;
}
/**
* Get a random index from the crypto module.
*/
getUnbiasedRandomIndex(max) {
const limit = Math.floor(2 ** 32 / max) * max;
while (true) {
const array = new Uint32Array(1);
crypto.getRandomValues(array);
const value = array[0];
if (value < limit) {
return value % max;
}
}
}
/**
* Generate a random password.
*/
generateRandomPassword() {
const chars = this.buildCharacterSet();
let password = this.generateInitialPassword(chars);
password = this.ensureRequirements(password);
return password;
}
/**
* Build character set based on selected options.
*/
buildCharacterSet() {
let chars = "";
if (this.useLowercase) {
chars += this.lowercaseChars;
}
if (this.useUppercase) {
chars += this.uppercaseChars;
}
if (this.useNumbers) {
chars += this.numberChars;
}
if (this.useSpecial) {
chars += this.specialChars;
}
if (chars.length === 0) {
chars = this.lowercaseChars;
}
if (this.useNonAmbiguous) {
chars = this.removeAmbiguousCharacters(chars);
}
return chars;
}
/**
* Remove ambiguous characters from a character set.
*/
removeAmbiguousCharacters(chars) {
for (const ambChar of this.ambiguousChars) {
chars = chars.replace(ambChar, "");
}
return chars;
}
/**
* Generate initial random password.
*/
generateInitialPassword(chars) {
let password = "";
for (let i = 0; i < this.length; i++) {
password += chars[this.getUnbiasedRandomIndex(chars.length)];
}
return password;
}
/**
* Ensure the generated password meets all specified requirements.
*/
ensureRequirements(password) {
if (this.useLowercase && !/[a-z]/.exec(password)) {
password = this.addCharacterFromSet(
password,
this.getSafeCharacterSet(this.lowercaseChars, true)
);
}
if (this.useUppercase && !/[A-Z]/.exec(password)) {
password = this.addCharacterFromSet(
password,
this.getSafeCharacterSet(this.uppercaseChars, true)
);
}
if (this.useNumbers && !/\d/.exec(password)) {
password = this.addCharacterFromSet(
password,
this.getSafeCharacterSet(this.numberChars, false)
);
}
if (this.useSpecial && !/[!@#$%^&*()_+\-=[\]{}|;:,.<>?]/.exec(password)) {
password = this.addCharacterFromSet(
password,
this.specialChars
);
}
return password;
}
/**
* Get a character set with ambiguous characters removed if needed.
*/
getSafeCharacterSet(charSet, isAlpha) {
if (!this.useNonAmbiguous) {
return charSet;
}
let safeSet = charSet;
for (const ambChar of this.ambiguousChars) {
if (!isAlpha && !/\d/.test(ambChar)) {
continue;
}
let charToRemove = ambChar;
if (isAlpha) {
if (charSet === this.lowercaseChars) {
charToRemove = ambChar.toLowerCase();
} else {
charToRemove = ambChar.toUpperCase();
}
}
safeSet = safeSet.replace(charToRemove, "");
}
return safeSet;
}
/**
* Add a character from the given set at a random position in the password.
*/
addCharacterFromSet(password, charSet) {
const pos = this.getUnbiasedRandomIndex(this.length);
const char = charSet[this.getUnbiasedRandomIndex(charSet.length)];
return password.substring(0, pos) + char + password.substring(pos + 1);
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
PasswordGenerator
});
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -1,210 +0,0 @@
// src/utils/PasswordGenerator.ts
var PasswordGenerator = class {
/**
* Create a new instance of PasswordGenerator.
* @param settings Optional password settings to initialize with.
*/
constructor(settings) {
this.lowercaseChars = "abcdefghijklmnopqrstuvwxyz";
this.uppercaseChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
this.numberChars = "0123456789";
this.specialChars = "!@#$%^&*()_+-=[]{}|;:,.<>?";
this.ambiguousChars = "Il1O0";
this.length = 18;
this.useLowercase = true;
this.useUppercase = true;
this.useNumbers = true;
this.useSpecial = true;
this.useNonAmbiguous = false;
if (settings) {
this.applySettings(settings);
}
}
/**
* Apply password settings to this generator.
*/
applySettings(settings) {
this.length = settings.Length;
this.useLowercase = settings.UseLowercase;
this.useUppercase = settings.UseUppercase;
this.useNumbers = settings.UseNumbers;
this.useSpecial = settings.UseSpecialChars;
this.useNonAmbiguous = settings.UseNonAmbiguousChars;
return this;
}
/**
* Set the length of the password.
*/
setLength(length) {
this.length = length;
return this;
}
/**
* Set if lowercase letters should be used.
*/
useLowercaseLetters(use) {
this.useLowercase = use;
return this;
}
/**
* Set if uppercase letters should be used.
*/
useUppercaseLetters(use) {
this.useUppercase = use;
return this;
}
/**
* Set if numeric characters should be used.
*/
useNumericCharacters(use) {
this.useNumbers = use;
return this;
}
/**
* Set if special characters should be used.
*/
useSpecialCharacters(use) {
this.useSpecial = use;
return this;
}
/**
* Set if only non-ambiguous characters should be used.
*/
useNonAmbiguousCharacters(use) {
this.useNonAmbiguous = use;
return this;
}
/**
* Get a random index from the crypto module.
*/
getUnbiasedRandomIndex(max) {
const limit = Math.floor(2 ** 32 / max) * max;
while (true) {
const array = new Uint32Array(1);
crypto.getRandomValues(array);
const value = array[0];
if (value < limit) {
return value % max;
}
}
}
/**
* Generate a random password.
*/
generateRandomPassword() {
const chars = this.buildCharacterSet();
let password = this.generateInitialPassword(chars);
password = this.ensureRequirements(password);
return password;
}
/**
* Build character set based on selected options.
*/
buildCharacterSet() {
let chars = "";
if (this.useLowercase) {
chars += this.lowercaseChars;
}
if (this.useUppercase) {
chars += this.uppercaseChars;
}
if (this.useNumbers) {
chars += this.numberChars;
}
if (this.useSpecial) {
chars += this.specialChars;
}
if (chars.length === 0) {
chars = this.lowercaseChars;
}
if (this.useNonAmbiguous) {
chars = this.removeAmbiguousCharacters(chars);
}
return chars;
}
/**
* Remove ambiguous characters from a character set.
*/
removeAmbiguousCharacters(chars) {
for (const ambChar of this.ambiguousChars) {
chars = chars.replace(ambChar, "");
}
return chars;
}
/**
* Generate initial random password.
*/
generateInitialPassword(chars) {
let password = "";
for (let i = 0; i < this.length; i++) {
password += chars[this.getUnbiasedRandomIndex(chars.length)];
}
return password;
}
/**
* Ensure the generated password meets all specified requirements.
*/
ensureRequirements(password) {
if (this.useLowercase && !/[a-z]/.exec(password)) {
password = this.addCharacterFromSet(
password,
this.getSafeCharacterSet(this.lowercaseChars, true)
);
}
if (this.useUppercase && !/[A-Z]/.exec(password)) {
password = this.addCharacterFromSet(
password,
this.getSafeCharacterSet(this.uppercaseChars, true)
);
}
if (this.useNumbers && !/\d/.exec(password)) {
password = this.addCharacterFromSet(
password,
this.getSafeCharacterSet(this.numberChars, false)
);
}
if (this.useSpecial && !/[!@#$%^&*()_+\-=[\]{}|;:,.<>?]/.exec(password)) {
password = this.addCharacterFromSet(
password,
this.specialChars
);
}
return password;
}
/**
* Get a character set with ambiguous characters removed if needed.
*/
getSafeCharacterSet(charSet, isAlpha) {
if (!this.useNonAmbiguous) {
return charSet;
}
let safeSet = charSet;
for (const ambChar of this.ambiguousChars) {
if (!isAlpha && !/\d/.test(ambChar)) {
continue;
}
let charToRemove = ambChar;
if (isAlpha) {
if (charSet === this.lowercaseChars) {
charToRemove = ambChar.toLowerCase();
} else {
charToRemove = ambChar.toUpperCase();
}
}
safeSet = safeSet.replace(charToRemove, "");
}
return safeSet;
}
/**
* Add a character from the given set at a random position in the password.
*/
addCharacterFromSet(password, charSet) {
const pos = this.getUnbiasedRandomIndex(this.length);
const char = charSet[this.getUnbiasedRandomIndex(charSet.length)];
return password.substring(0, pos) + char + password.substring(pos + 1);
}
};
export {
PasswordGenerator
};
//# sourceMappingURL=index.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -8,13 +8,13 @@ PACKAGES_DIR="./"
# Define output targets for each package
IDENTITY_TARGETS=(
"./apps/mobile-app/shared/identity-generator"
"./apps/browser-extension/src/shared/identity-generator"
#"../apps/mobile-app/shared/identity-generator"
"../apps/browser-extension/src/utils/shared/identity-generator"
)
PASSWORD_TARGETS=(
"./apps/mobile-app/shared/password-generator"
"./apps/browser-extension/src/shared/password-generator"
#"../apps/mobile-app/shared/password-generator"
"../apps/browser-extension/src/utils/shared/password-generator"
)
# Build and distribute a package
@@ -29,7 +29,7 @@ build_and_copy() {
(cd "$package_path" && npm install && npm run build)
local dist_path="$package_path/dist"
local files_to_copy=("index.js" "index.mjs" "index.d.ts")
local files_to_copy=("index.js" "index.mjs" "index.d.ts" "index.js.map" "index.mjs" "index.mjs.map")
for target in "${targets[@]}"; do
echo "📂 Copying $package_name$target"
@@ -56,7 +56,7 @@ EOF
}
# Run build + copy for each module
build_and_copy "av-identity-generator" "${IDENTITY_TARGETS[@]}"
build_and_copy "av-password-generator" "${PASSWORD_TARGETS[@]}"
build_and_copy "identity-generator" "${IDENTITY_TARGETS[@]}"
build_and_copy "password-generator" "${PASSWORD_TARGETS[@]}"
echo "✅ All builds, copies, and readme updates completed."

View File

@@ -0,0 +1,114 @@
import js from "@eslint/js";
import tsParser from "@typescript-eslint/parser";
import tsPlugin from "@typescript-eslint/eslint-plugin";
import importPlugin from "eslint-plugin-import";
import jsdocPlugin from "eslint-plugin-jsdoc";
import globals from 'globals';
export default [
{
ignores: [
"dist/**",
"node_modules/**",
]
},
js.configs.recommended,
{
files: ["src/**/*.{ts,tsx}"],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaFeatures: { jsx: true },
ecmaVersion: "latest",
sourceType: "module",
project: "./tsconfig.json",
tsconfigRootDir: ".",
},
},
plugins: {
"@typescript-eslint": tsPlugin,
"import": importPlugin,
"jsdoc": jsdocPlugin,
},
rules: {
...tsPlugin.configs.recommended.rules,
"curly": ["error", "all"],
"brace-style": ["error", "1tbs", { "allowSingleLine": false }],
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/prefer-nullish-coalescing": ["error", {
"ignoreTernaryTests": false,
"ignoreConditionalTests": false,
"ignoreMixedLogicalExpressions": false
}],
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-unused-vars": ["error", {
"vars": "all",
"args": "after-used",
"ignoreRestSiblings": true,
"varsIgnorePattern": "^_",
"argsIgnorePattern": "^_"
}],
"indent": ["error", 2, {
"SwitchCase": 1,
"VariableDeclarator": 1,
"outerIIFEBody": 1,
"MemberExpression": 1,
"FunctionDeclaration": { "parameters": 1, "body": 1 },
"FunctionExpression": { "parameters": 1, "body": 1 },
"CallExpression": { "arguments": 1 },
"ArrayExpression": 1,
"ObjectExpression": 1,
"ImportDeclaration": 1,
"flatTernaryExpressions": false,
"ignoreComments": false
}],
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 1, "maxBOF": 0 }],
"no-console": ["error", { allow: ["warn", "error", "info", "debug"] }],
"jsdoc/require-jsdoc": ["error", {
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": true,
"ArrowFunctionExpression": true,
"FunctionExpression": true
}
}],
"jsdoc/require-description": ["error", {
"contexts": [
"FunctionDeclaration",
"MethodDefinition",
"ClassDeclaration",
"ArrowFunctionExpression",
"FunctionExpression"
]
}],
"spaced-comment": ["error", "always"],
"multiline-comment-style": ["error", "starred-block"],
"@typescript-eslint/explicit-member-accessibility": ["error"],
"@typescript-eslint/explicit-function-return-type": ["error"],
"@typescript-eslint/typedef": ["error"],
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "interface",
"format": ["PascalCase"],
"prefix": ["I"]
},
{
"selector": "class",
"format": ["PascalCase"]
}
],
}
},
{
languageOptions: {
globals: {
...globals.browser,
...globals.node,
NodeJS: true,
chrome: 'readonly',
}
}
}
];

6127
shared/identity-generator/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -5,7 +5,12 @@
"types": "dist/index.d.ts",
"scripts": {
"build": "tsup",
"clean": "rm -rf dist"
"clean": "rm -rf dist",
"test": "vitest",
"test:coverage": "vitest run --coverage",
"lint": "eslint src",
"lint:custom": "eslint",
"lint:fix": "eslint src --fix"
},
"files": [
"dist"

View File

@@ -2,4 +2,5 @@ export * from './utils/UsernameEmailGenerator';
export * from './types/Identity';
export * from './types/Gender';
export * from './implementations/IdentityGeneratorEn';
export * from './implementations/IdentityGeneratorNl';
export * from './implementations/IdentityGeneratorNl';
export * from './implementations/base/BaseIdentityGenerator';

View File

@@ -0,0 +1,114 @@
import js from "@eslint/js";
import tsParser from "@typescript-eslint/parser";
import tsPlugin from "@typescript-eslint/eslint-plugin";
import importPlugin from "eslint-plugin-import";
import jsdocPlugin from "eslint-plugin-jsdoc";
import globals from 'globals';
export default [
{
ignores: [
"dist/**",
"node_modules/**",
]
},
js.configs.recommended,
{
files: ["src/**/*.{ts,tsx}"],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaFeatures: { jsx: true },
ecmaVersion: "latest",
sourceType: "module",
project: "./tsconfig.json",
tsconfigRootDir: ".",
},
},
plugins: {
"@typescript-eslint": tsPlugin,
"import": importPlugin,
"jsdoc": jsdocPlugin,
},
rules: {
...tsPlugin.configs.recommended.rules,
"curly": ["error", "all"],
"brace-style": ["error", "1tbs", { "allowSingleLine": false }],
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/prefer-nullish-coalescing": ["error", {
"ignoreTernaryTests": false,
"ignoreConditionalTests": false,
"ignoreMixedLogicalExpressions": false
}],
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-unused-vars": ["error", {
"vars": "all",
"args": "after-used",
"ignoreRestSiblings": true,
"varsIgnorePattern": "^_",
"argsIgnorePattern": "^_"
}],
"indent": ["error", 2, {
"SwitchCase": 1,
"VariableDeclarator": 1,
"outerIIFEBody": 1,
"MemberExpression": 1,
"FunctionDeclaration": { "parameters": 1, "body": 1 },
"FunctionExpression": { "parameters": 1, "body": 1 },
"CallExpression": { "arguments": 1 },
"ArrayExpression": 1,
"ObjectExpression": 1,
"ImportDeclaration": 1,
"flatTernaryExpressions": false,
"ignoreComments": false
}],
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 1, "maxBOF": 0 }],
"no-console": ["error", { allow: ["warn", "error", "info", "debug"] }],
"jsdoc/require-jsdoc": ["error", {
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": true,
"ArrowFunctionExpression": true,
"FunctionExpression": true
}
}],
"jsdoc/require-description": ["error", {
"contexts": [
"FunctionDeclaration",
"MethodDefinition",
"ClassDeclaration",
"ArrowFunctionExpression",
"FunctionExpression"
]
}],
"spaced-comment": ["error", "always"],
"multiline-comment-style": ["error", "starred-block"],
"@typescript-eslint/explicit-member-accessibility": ["error"],
"@typescript-eslint/explicit-function-return-type": ["error"],
"@typescript-eslint/typedef": ["error"],
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "interface",
"format": ["PascalCase"],
"prefix": ["I"]
},
{
"selector": "class",
"format": ["PascalCase"]
}
],
}
},
{
languageOptions: {
globals: {
...globals.browser,
...globals.node,
NodeJS: true,
chrome: 'readonly',
}
}
}
];

6127
shared/password-generator/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -5,7 +5,12 @@
"types": "dist/index.d.ts",
"scripts": {
"build": "tsup",
"clean": "rm -rf dist"
"clean": "rm -rf dist",
"test": "vitest",
"test:coverage": "vitest run --coverage",
"lint": "eslint src",
"lint:custom": "eslint",
"lint:fix": "eslint src --fix"
},
"files": [
"dist"