mirror of
https://github.com/aliasvault/aliasvault.git
synced 2026-05-19 13:57:18 -04:00
Refactor to use new factory methods for identity and password generators (#896)
This commit is contained in:
committed by
Leendert de Borst
parent
bc6479bf5e
commit
4c7bef2a5a
@@ -2,12 +2,11 @@ import { storage } from '#imports';
|
||||
import { sendMessage } from 'webext-bridge/content-script';
|
||||
import { fillCredential } from '@/entrypoints/contentScript/Form';
|
||||
import { filterCredentials } from '@/entrypoints/contentScript/Filter';
|
||||
import { IdentityGeneratorEn, IdentityGeneratorNl } from '@/utils/shared/identity-generator';
|
||||
import { PasswordGenerator } from '@/utils/shared/password-generator';
|
||||
import { CreateIdentityGenerator } from '@/utils/shared/identity-generator';
|
||||
import { CreatePasswordGenerator, PasswordGenerator } from '@/utils/shared/password-generator';
|
||||
import { CredentialsResponse } from '@/utils/types/messaging/CredentialsResponse';
|
||||
import { PasswordSettingsResponse } from '@/utils/types/messaging/PasswordSettingsResponse';
|
||||
import { SqliteClient } from '@/utils/SqliteClient';
|
||||
import { BaseIdentityGenerator } from '@/utils/shared/identity-generator';
|
||||
import { StringResponse } from '@/utils/types/messaging/StringResponse';
|
||||
import { FormDetector } from '@/utils/formDetector/FormDetector';
|
||||
import { Credential } from '@/utils/types/Credential';
|
||||
@@ -243,23 +242,21 @@ export function createAutofillPopup(input: HTMLInputElement, credentials: Creden
|
||||
} else {
|
||||
// Generate new random identity using identity generator.
|
||||
const identityLanguage = await sendMessage('GET_DEFAULT_IDENTITY_LANGUAGE', {}, 'background') as StringResponse;
|
||||
let identityGenerator: BaseIdentityGenerator;
|
||||
switch (identityLanguage.value) {
|
||||
case 'nl':
|
||||
identityGenerator = new IdentityGeneratorNl();
|
||||
break;
|
||||
case 'en':
|
||||
default:
|
||||
identityGenerator = new IdentityGeneratorEn();
|
||||
break;
|
||||
}
|
||||
const identityGenerator = CreateIdentityGenerator(identityLanguage.value ?? 'en');
|
||||
const identity = identityGenerator.generateRandomIdentity();
|
||||
|
||||
// Get password settings from background
|
||||
const passwordSettingsResponse = await sendMessage('GET_PASSWORD_SETTINGS', {}, 'background') as PasswordSettingsResponse;
|
||||
|
||||
// Initialize password generator with the retrieved settings
|
||||
const passwordGenerator = new PasswordGenerator(passwordSettingsResponse.settings);
|
||||
const passwordGenerator = CreatePasswordGenerator(passwordSettingsResponse.settings ?? {
|
||||
Length: 12,
|
||||
UseLowercase: true,
|
||||
UseUppercase: true,
|
||||
UseNumbers: true,
|
||||
UseSpecialChars: true,
|
||||
UseNonAmbiguousChars: true
|
||||
});
|
||||
const password = passwordGenerator.generateRandomPassword();
|
||||
|
||||
// Extract favicon from page and get the bytes
|
||||
@@ -946,6 +943,22 @@ export async function createAliasCreationPopup(suggestedNames: string[], rootCon
|
||||
}
|
||||
});
|
||||
|
||||
// Get password settings from background
|
||||
let passwordGenerator: PasswordGenerator;
|
||||
sendMessage('GET_PASSWORD_SETTINGS', {}, 'background').then((response) => {
|
||||
const passwordSettingsResponse = response as PasswordSettingsResponse;
|
||||
passwordGenerator = CreatePasswordGenerator(passwordSettingsResponse.settings ?? {
|
||||
Length: 12,
|
||||
UseLowercase: true,
|
||||
UseUppercase: true,
|
||||
UseNumbers: true,
|
||||
UseSpecialChars: true,
|
||||
UseNonAmbiguousChars: true
|
||||
});
|
||||
// Generate initial password after settings are loaded
|
||||
passwordGenerator.generateRandomPassword();
|
||||
});
|
||||
|
||||
/**
|
||||
* Generate and set password.
|
||||
*/
|
||||
@@ -960,15 +973,6 @@ export async function createAliasCreationPopup(suggestedNames: string[], rootCon
|
||||
updateVisibilityIcon(true);
|
||||
};
|
||||
|
||||
// Get password settings from background
|
||||
let passwordGenerator: PasswordGenerator;
|
||||
sendMessage('GET_PASSWORD_SETTINGS', {}, 'background').then((response) => {
|
||||
const passwordSettingsResponse = response as PasswordSettingsResponse;
|
||||
passwordGenerator = new PasswordGenerator(passwordSettingsResponse.settings);
|
||||
// Generate initial password after settings are loaded
|
||||
generatePassword();
|
||||
});
|
||||
|
||||
// Handle regenerate button click
|
||||
regenerateBtn.addEventListener('click', generatePassword);
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ interface IIdentityGenerator {
|
||||
/**
|
||||
* Base identity generator.
|
||||
*/
|
||||
declare abstract class BaseIdentityGenerator implements IIdentityGenerator {
|
||||
declare abstract class IdentityGenerator implements IIdentityGenerator {
|
||||
protected firstNamesMale: string[];
|
||||
protected firstNamesFemale: string[];
|
||||
protected lastNames: string[];
|
||||
@@ -81,7 +81,7 @@ declare abstract class BaseIdentityGenerator implements IIdentityGenerator {
|
||||
/**
|
||||
* Identity generator for English language using English word dictionaries.
|
||||
*/
|
||||
declare class IdentityGeneratorEn extends BaseIdentityGenerator {
|
||||
declare class IdentityGeneratorEn extends IdentityGenerator {
|
||||
/**
|
||||
* Get the male first names.
|
||||
*/
|
||||
@@ -99,7 +99,7 @@ declare class IdentityGeneratorEn extends BaseIdentityGenerator {
|
||||
/**
|
||||
* Identity generator for Dutch language using Dutch word dictionaries.
|
||||
*/
|
||||
declare class IdentityGeneratorNl extends BaseIdentityGenerator {
|
||||
declare class IdentityGeneratorNl extends IdentityGenerator {
|
||||
/**
|
||||
* Get the male first names.
|
||||
*/
|
||||
@@ -137,6 +137,6 @@ declare class IdentityHelperUtils {
|
||||
* @param language - The language to use for generating the identity (e.g. "en", "nl").
|
||||
* @returns A new identity generator instance.
|
||||
*/
|
||||
declare const createGenerator: (language: string) => IIdentityGenerator;
|
||||
declare const CreateIdentityGenerator: (language: string) => IIdentityGenerator;
|
||||
|
||||
export { BaseIdentityGenerator, Gender, type Identity, IdentityGeneratorEn, IdentityGeneratorNl, IdentityHelperUtils, UsernameEmailGenerator, createGenerator };
|
||||
export { CreateIdentityGenerator, Gender, type Identity, IdentityGenerator, IdentityGeneratorEn, IdentityGeneratorNl, IdentityHelperUtils, UsernameEmailGenerator };
|
||||
|
||||
@@ -23,13 +23,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
||||
// src/index.ts
|
||||
var index_exports = {};
|
||||
__export(index_exports, {
|
||||
BaseIdentityGenerator: () => BaseIdentityGenerator,
|
||||
CreateIdentityGenerator: () => CreateIdentityGenerator,
|
||||
Gender: () => Gender,
|
||||
IdentityGenerator: () => IdentityGenerator,
|
||||
IdentityGeneratorEn: () => IdentityGeneratorEn,
|
||||
IdentityGeneratorNl: () => IdentityGeneratorNl,
|
||||
IdentityHelperUtils: () => IdentityHelperUtils,
|
||||
UsernameEmailGenerator: () => UsernameEmailGenerator,
|
||||
createGenerator: () => createGenerator
|
||||
UsernameEmailGenerator: () => UsernameEmailGenerator
|
||||
});
|
||||
module.exports = __toCommonJS(index_exports);
|
||||
|
||||
@@ -139,8 +139,8 @@ var Gender = /* @__PURE__ */ ((Gender2) => {
|
||||
return Gender2;
|
||||
})(Gender || {});
|
||||
|
||||
// src/implementations/base/BaseIdentityGenerator.ts
|
||||
var BaseIdentityGenerator = class {
|
||||
// src/implementations/base/IdentityGenerator.ts
|
||||
var IdentityGenerator = class {
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
@@ -983,7 +983,7 @@ var lastnames_default = [
|
||||
];
|
||||
|
||||
// src/implementations/IdentityGeneratorEn.ts
|
||||
var IdentityGeneratorEn = class extends BaseIdentityGenerator {
|
||||
var IdentityGeneratorEn = class extends IdentityGenerator {
|
||||
/**
|
||||
* Get the male first names.
|
||||
*/
|
||||
@@ -1647,7 +1647,7 @@ var lastnames_default2 = [
|
||||
];
|
||||
|
||||
// src/implementations/IdentityGeneratorNl.ts
|
||||
var IdentityGeneratorNl = class extends BaseIdentityGenerator {
|
||||
var IdentityGeneratorNl = class extends IdentityGenerator {
|
||||
/**
|
||||
* Get the male first names.
|
||||
*/
|
||||
@@ -1718,7 +1718,7 @@ var IdentityHelperUtils = class {
|
||||
};
|
||||
|
||||
// src/factories/IdentityGeneratorFactory.ts
|
||||
var createGenerator = (language) => {
|
||||
var CreateIdentityGenerator = (language) => {
|
||||
switch (language) {
|
||||
case "en":
|
||||
return new IdentityGeneratorEn();
|
||||
@@ -1729,12 +1729,12 @@ var createGenerator = (language) => {
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
BaseIdentityGenerator,
|
||||
CreateIdentityGenerator,
|
||||
Gender,
|
||||
IdentityGenerator,
|
||||
IdentityGeneratorEn,
|
||||
IdentityGeneratorNl,
|
||||
IdentityHelperUtils,
|
||||
UsernameEmailGenerator,
|
||||
createGenerator
|
||||
UsernameEmailGenerator
|
||||
});
|
||||
//# sourceMappingURL=index.js.map
|
||||
@@ -108,8 +108,8 @@ var Gender = /* @__PURE__ */ ((Gender2) => {
|
||||
return Gender2;
|
||||
})(Gender || {});
|
||||
|
||||
// src/implementations/base/BaseIdentityGenerator.ts
|
||||
var BaseIdentityGenerator = class {
|
||||
// src/implementations/base/IdentityGenerator.ts
|
||||
var IdentityGenerator = class {
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
@@ -952,7 +952,7 @@ var lastnames_default = [
|
||||
];
|
||||
|
||||
// src/implementations/IdentityGeneratorEn.ts
|
||||
var IdentityGeneratorEn = class extends BaseIdentityGenerator {
|
||||
var IdentityGeneratorEn = class extends IdentityGenerator {
|
||||
/**
|
||||
* Get the male first names.
|
||||
*/
|
||||
@@ -1616,7 +1616,7 @@ var lastnames_default2 = [
|
||||
];
|
||||
|
||||
// src/implementations/IdentityGeneratorNl.ts
|
||||
var IdentityGeneratorNl = class extends BaseIdentityGenerator {
|
||||
var IdentityGeneratorNl = class extends IdentityGenerator {
|
||||
/**
|
||||
* Get the male first names.
|
||||
*/
|
||||
@@ -1687,7 +1687,7 @@ var IdentityHelperUtils = class {
|
||||
};
|
||||
|
||||
// src/factories/IdentityGeneratorFactory.ts
|
||||
var createGenerator = (language) => {
|
||||
var CreateIdentityGenerator = (language) => {
|
||||
switch (language) {
|
||||
case "en":
|
||||
return new IdentityGeneratorEn();
|
||||
@@ -1697,12 +1697,12 @@ var createGenerator = (language) => {
|
||||
throw new Error(`Unsupported language: ${language}`);
|
||||
};
|
||||
export {
|
||||
BaseIdentityGenerator,
|
||||
CreateIdentityGenerator,
|
||||
Gender,
|
||||
IdentityGenerator,
|
||||
IdentityGeneratorEn,
|
||||
IdentityGeneratorNl,
|
||||
IdentityHelperUtils,
|
||||
UsernameEmailGenerator,
|
||||
createGenerator
|
||||
UsernameEmailGenerator
|
||||
};
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
@@ -115,6 +115,6 @@ declare class PasswordGenerator {
|
||||
* @param settings - The settings for the password generator.
|
||||
* @returns A new password generator instance.
|
||||
*/
|
||||
declare const createPasswordGenerator: (settings: PasswordSettings) => PasswordGenerator;
|
||||
declare const CreatePasswordGenerator: (settings: PasswordSettings) => PasswordGenerator;
|
||||
|
||||
export { PasswordGenerator, type PasswordSettings, createPasswordGenerator };
|
||||
export { CreatePasswordGenerator, PasswordGenerator, type PasswordSettings };
|
||||
|
||||
@@ -23,8 +23,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
||||
// src/index.ts
|
||||
var index_exports = {};
|
||||
__export(index_exports, {
|
||||
PasswordGenerator: () => PasswordGenerator,
|
||||
createPasswordGenerator: () => createPasswordGenerator
|
||||
CreatePasswordGenerator: () => CreatePasswordGenerator,
|
||||
PasswordGenerator: () => PasswordGenerator
|
||||
});
|
||||
module.exports = __toCommonJS(index_exports);
|
||||
|
||||
@@ -236,12 +236,12 @@ var PasswordGenerator = class {
|
||||
};
|
||||
|
||||
// src/factories/PasswordGeneratorFactory.ts
|
||||
var createPasswordGenerator = (settings) => {
|
||||
var CreatePasswordGenerator = (settings) => {
|
||||
return new PasswordGenerator(settings);
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
PasswordGenerator,
|
||||
createPasswordGenerator
|
||||
CreatePasswordGenerator,
|
||||
PasswordGenerator
|
||||
});
|
||||
//# sourceMappingURL=index.js.map
|
||||
@@ -210,11 +210,11 @@ var PasswordGenerator = class {
|
||||
};
|
||||
|
||||
// src/factories/PasswordGeneratorFactory.ts
|
||||
var createPasswordGenerator = (settings) => {
|
||||
var CreatePasswordGenerator = (settings) => {
|
||||
return new PasswordGenerator(settings);
|
||||
};
|
||||
export {
|
||||
PasswordGenerator,
|
||||
createPasswordGenerator
|
||||
CreatePasswordGenerator,
|
||||
PasswordGenerator
|
||||
};
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
@@ -17,8 +17,8 @@ import emitter from '@/utils/EventEmitter';
|
||||
import { FaviconExtractModel } from '@/utils/types/webapi/FaviconExtractModel';
|
||||
import { AliasVaultToast } from '@/components/Toast';
|
||||
import { useVaultMutate } from '@/hooks/useVaultMutate';
|
||||
import { IdentityGeneratorEn, IdentityGeneratorNl, IdentityHelperUtils, BaseIdentityGenerator } from '@/utils/shared/identity-generator';
|
||||
import { PasswordGenerator } from '@/utils/shared/password-generator';
|
||||
import { CreateIdentityGenerator, IdentityHelperUtils, IIdentityGenerator } from '@/utils/shared/identity-generator';
|
||||
import { CreatePasswordGenerator, PasswordGenerator } from '@/utils/shared/password-generator';
|
||||
import { ValidatedFormField, ValidatedFormFieldRef } from '@/components/form/ValidatedFormField';
|
||||
import { credentialSchema } from '@/utils/ValidationSchema';
|
||||
import LoadingOverlay from '@/components/LoadingOverlay';
|
||||
@@ -133,29 +133,18 @@ export default function AddEditCredentialScreen() : React.ReactNode {
|
||||
|
||||
/**
|
||||
* Initialize the identity and password generators with settings from user's vault.
|
||||
* @returns {identityGenerator: BaseIdentityGenerator, passwordGenerator: PasswordGenerator}
|
||||
* @returns {identityGenerator: IIdentityGenerator, passwordGenerator: PasswordGenerator}
|
||||
*/
|
||||
const initializeGenerators = useCallback(async () : Promise<{ identityGenerator: BaseIdentityGenerator, passwordGenerator: PasswordGenerator }> => {
|
||||
const initializeGenerators = useCallback(async () : Promise<{ identityGenerator: IIdentityGenerator, passwordGenerator: PasswordGenerator }> => {
|
||||
// Get default identity language from database
|
||||
const identityLanguage = await dbContext.sqliteClient!.getDefaultIdentityLanguage();
|
||||
|
||||
// Initialize identity generator based on language
|
||||
let identityGenerator: BaseIdentityGenerator;
|
||||
switch (identityLanguage) {
|
||||
case 'nl':
|
||||
identityGenerator = new IdentityGeneratorNl();
|
||||
break;
|
||||
case 'en':
|
||||
default:
|
||||
identityGenerator = new IdentityGeneratorEn();
|
||||
break;
|
||||
}
|
||||
const identityGenerator = CreateIdentityGenerator(identityLanguage);
|
||||
|
||||
// Get password settings from database
|
||||
// Initialize password generator with settings from vault
|
||||
const passwordSettings = await dbContext.sqliteClient!.getPasswordSettings();
|
||||
|
||||
// Initialize password generator with settings
|
||||
const passwordGenerator = new PasswordGenerator(passwordSettings);
|
||||
const passwordGenerator = CreatePasswordGenerator(passwordSettings);
|
||||
|
||||
return { identityGenerator, passwordGenerator };
|
||||
}, [dbContext.sqliteClient]);
|
||||
|
||||
@@ -56,7 +56,7 @@ interface IIdentityGenerator {
|
||||
/**
|
||||
* Base identity generator.
|
||||
*/
|
||||
declare abstract class BaseIdentityGenerator implements IIdentityGenerator {
|
||||
declare abstract class IdentityGenerator implements IIdentityGenerator {
|
||||
protected firstNamesMale: string[];
|
||||
protected firstNamesFemale: string[];
|
||||
protected lastNames: string[];
|
||||
@@ -81,7 +81,7 @@ declare abstract class BaseIdentityGenerator implements IIdentityGenerator {
|
||||
/**
|
||||
* Identity generator for English language using English word dictionaries.
|
||||
*/
|
||||
declare class IdentityGeneratorEn extends BaseIdentityGenerator {
|
||||
declare class IdentityGeneratorEn extends IdentityGenerator {
|
||||
/**
|
||||
* Get the male first names.
|
||||
*/
|
||||
@@ -99,7 +99,7 @@ declare class IdentityGeneratorEn extends BaseIdentityGenerator {
|
||||
/**
|
||||
* Identity generator for Dutch language using Dutch word dictionaries.
|
||||
*/
|
||||
declare class IdentityGeneratorNl extends BaseIdentityGenerator {
|
||||
declare class IdentityGeneratorNl extends IdentityGenerator {
|
||||
/**
|
||||
* Get the male first names.
|
||||
*/
|
||||
@@ -137,6 +137,6 @@ declare class IdentityHelperUtils {
|
||||
* @param language - The language to use for generating the identity (e.g. "en", "nl").
|
||||
* @returns A new identity generator instance.
|
||||
*/
|
||||
declare const createGenerator: (language: string) => IIdentityGenerator;
|
||||
declare const CreateIdentityGenerator: (language: string) => IIdentityGenerator;
|
||||
|
||||
export { BaseIdentityGenerator, Gender, type Identity, IdentityGeneratorEn, IdentityGeneratorNl, IdentityHelperUtils, UsernameEmailGenerator, createGenerator };
|
||||
export { CreateIdentityGenerator, Gender, type Identity, IdentityGenerator, IdentityGeneratorEn, IdentityGeneratorNl, IdentityHelperUtils, UsernameEmailGenerator };
|
||||
|
||||
@@ -23,13 +23,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
||||
// src/index.ts
|
||||
var index_exports = {};
|
||||
__export(index_exports, {
|
||||
BaseIdentityGenerator: () => BaseIdentityGenerator,
|
||||
CreateIdentityGenerator: () => CreateIdentityGenerator,
|
||||
Gender: () => Gender,
|
||||
IdentityGenerator: () => IdentityGenerator,
|
||||
IdentityGeneratorEn: () => IdentityGeneratorEn,
|
||||
IdentityGeneratorNl: () => IdentityGeneratorNl,
|
||||
IdentityHelperUtils: () => IdentityHelperUtils,
|
||||
UsernameEmailGenerator: () => UsernameEmailGenerator,
|
||||
createGenerator: () => createGenerator
|
||||
UsernameEmailGenerator: () => UsernameEmailGenerator
|
||||
});
|
||||
module.exports = __toCommonJS(index_exports);
|
||||
|
||||
@@ -139,8 +139,8 @@ var Gender = /* @__PURE__ */ ((Gender2) => {
|
||||
return Gender2;
|
||||
})(Gender || {});
|
||||
|
||||
// src/implementations/base/BaseIdentityGenerator.ts
|
||||
var BaseIdentityGenerator = class {
|
||||
// src/implementations/base/IdentityGenerator.ts
|
||||
var IdentityGenerator = class {
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
@@ -983,7 +983,7 @@ var lastnames_default = [
|
||||
];
|
||||
|
||||
// src/implementations/IdentityGeneratorEn.ts
|
||||
var IdentityGeneratorEn = class extends BaseIdentityGenerator {
|
||||
var IdentityGeneratorEn = class extends IdentityGenerator {
|
||||
/**
|
||||
* Get the male first names.
|
||||
*/
|
||||
@@ -1647,7 +1647,7 @@ var lastnames_default2 = [
|
||||
];
|
||||
|
||||
// src/implementations/IdentityGeneratorNl.ts
|
||||
var IdentityGeneratorNl = class extends BaseIdentityGenerator {
|
||||
var IdentityGeneratorNl = class extends IdentityGenerator {
|
||||
/**
|
||||
* Get the male first names.
|
||||
*/
|
||||
@@ -1718,7 +1718,7 @@ var IdentityHelperUtils = class {
|
||||
};
|
||||
|
||||
// src/factories/IdentityGeneratorFactory.ts
|
||||
var createGenerator = (language) => {
|
||||
var CreateIdentityGenerator = (language) => {
|
||||
switch (language) {
|
||||
case "en":
|
||||
return new IdentityGeneratorEn();
|
||||
@@ -1729,12 +1729,12 @@ var createGenerator = (language) => {
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
BaseIdentityGenerator,
|
||||
CreateIdentityGenerator,
|
||||
Gender,
|
||||
IdentityGenerator,
|
||||
IdentityGeneratorEn,
|
||||
IdentityGeneratorNl,
|
||||
IdentityHelperUtils,
|
||||
UsernameEmailGenerator,
|
||||
createGenerator
|
||||
UsernameEmailGenerator
|
||||
});
|
||||
//# sourceMappingURL=index.js.map
|
||||
@@ -108,8 +108,8 @@ var Gender = /* @__PURE__ */ ((Gender2) => {
|
||||
return Gender2;
|
||||
})(Gender || {});
|
||||
|
||||
// src/implementations/base/BaseIdentityGenerator.ts
|
||||
var BaseIdentityGenerator = class {
|
||||
// src/implementations/base/IdentityGenerator.ts
|
||||
var IdentityGenerator = class {
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
@@ -952,7 +952,7 @@ var lastnames_default = [
|
||||
];
|
||||
|
||||
// src/implementations/IdentityGeneratorEn.ts
|
||||
var IdentityGeneratorEn = class extends BaseIdentityGenerator {
|
||||
var IdentityGeneratorEn = class extends IdentityGenerator {
|
||||
/**
|
||||
* Get the male first names.
|
||||
*/
|
||||
@@ -1616,7 +1616,7 @@ var lastnames_default2 = [
|
||||
];
|
||||
|
||||
// src/implementations/IdentityGeneratorNl.ts
|
||||
var IdentityGeneratorNl = class extends BaseIdentityGenerator {
|
||||
var IdentityGeneratorNl = class extends IdentityGenerator {
|
||||
/**
|
||||
* Get the male first names.
|
||||
*/
|
||||
@@ -1687,7 +1687,7 @@ var IdentityHelperUtils = class {
|
||||
};
|
||||
|
||||
// src/factories/IdentityGeneratorFactory.ts
|
||||
var createGenerator = (language) => {
|
||||
var CreateIdentityGenerator = (language) => {
|
||||
switch (language) {
|
||||
case "en":
|
||||
return new IdentityGeneratorEn();
|
||||
@@ -1697,12 +1697,12 @@ var createGenerator = (language) => {
|
||||
throw new Error(`Unsupported language: ${language}`);
|
||||
};
|
||||
export {
|
||||
BaseIdentityGenerator,
|
||||
CreateIdentityGenerator,
|
||||
Gender,
|
||||
IdentityGenerator,
|
||||
IdentityGeneratorEn,
|
||||
IdentityGeneratorNl,
|
||||
IdentityHelperUtils,
|
||||
UsernameEmailGenerator,
|
||||
createGenerator
|
||||
UsernameEmailGenerator
|
||||
};
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
@@ -115,6 +115,6 @@ declare class PasswordGenerator {
|
||||
* @param settings - The settings for the password generator.
|
||||
* @returns A new password generator instance.
|
||||
*/
|
||||
declare const createPasswordGenerator: (settings: PasswordSettings) => PasswordGenerator;
|
||||
declare const CreatePasswordGenerator: (settings: PasswordSettings) => PasswordGenerator;
|
||||
|
||||
export { PasswordGenerator, type PasswordSettings, createPasswordGenerator };
|
||||
export { CreatePasswordGenerator, PasswordGenerator, type PasswordSettings };
|
||||
|
||||
@@ -23,8 +23,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
||||
// src/index.ts
|
||||
var index_exports = {};
|
||||
__export(index_exports, {
|
||||
PasswordGenerator: () => PasswordGenerator,
|
||||
createPasswordGenerator: () => createPasswordGenerator
|
||||
CreatePasswordGenerator: () => CreatePasswordGenerator,
|
||||
PasswordGenerator: () => PasswordGenerator
|
||||
});
|
||||
module.exports = __toCommonJS(index_exports);
|
||||
|
||||
@@ -236,12 +236,12 @@ var PasswordGenerator = class {
|
||||
};
|
||||
|
||||
// src/factories/PasswordGeneratorFactory.ts
|
||||
var createPasswordGenerator = (settings) => {
|
||||
var CreatePasswordGenerator = (settings) => {
|
||||
return new PasswordGenerator(settings);
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
PasswordGenerator,
|
||||
createPasswordGenerator
|
||||
CreatePasswordGenerator,
|
||||
PasswordGenerator
|
||||
});
|
||||
//# sourceMappingURL=index.js.map
|
||||
@@ -210,11 +210,11 @@ var PasswordGenerator = class {
|
||||
};
|
||||
|
||||
// src/factories/PasswordGeneratorFactory.ts
|
||||
var createPasswordGenerator = (settings) => {
|
||||
var CreatePasswordGenerator = (settings) => {
|
||||
return new PasswordGenerator(settings);
|
||||
};
|
||||
export {
|
||||
PasswordGenerator,
|
||||
createPasswordGenerator
|
||||
CreatePasswordGenerator,
|
||||
PasswordGenerator
|
||||
};
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
@@ -305,7 +305,7 @@ public sealed class JsInteropService(IJSRuntime jsRuntime)
|
||||
}
|
||||
}
|
||||
|
||||
var generatorInstance = await _identityGeneratorModule.InvokeAsync<IJSObjectReference>("createGenerator", language);
|
||||
var generatorInstance = await _identityGeneratorModule.InvokeAsync<IJSObjectReference>("CreateIdentityGenerator", language);
|
||||
var result = await generatorInstance.InvokeAsync<IdentityGeneratorResult>("generateRandomIdentity");
|
||||
|
||||
return result;
|
||||
@@ -335,7 +335,7 @@ public sealed class JsInteropService(IJSRuntime jsRuntime)
|
||||
}
|
||||
}
|
||||
|
||||
var generatorInstance = await _passwordGeneratorModule.InvokeAsync<IJSObjectReference>("createPasswordGenerator", settings);
|
||||
var generatorInstance = await _passwordGeneratorModule.InvokeAsync<IJSObjectReference>("CreatePasswordGenerator", settings);
|
||||
|
||||
var result = await generatorInstance.InvokeAsync<string>("generateRandomPassword");
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ interface IIdentityGenerator {
|
||||
/**
|
||||
* Base identity generator.
|
||||
*/
|
||||
declare abstract class BaseIdentityGenerator implements IIdentityGenerator {
|
||||
declare abstract class IdentityGenerator implements IIdentityGenerator {
|
||||
protected firstNamesMale: string[];
|
||||
protected firstNamesFemale: string[];
|
||||
protected lastNames: string[];
|
||||
@@ -81,7 +81,7 @@ declare abstract class BaseIdentityGenerator implements IIdentityGenerator {
|
||||
/**
|
||||
* Identity generator for English language using English word dictionaries.
|
||||
*/
|
||||
declare class IdentityGeneratorEn extends BaseIdentityGenerator {
|
||||
declare class IdentityGeneratorEn extends IdentityGenerator {
|
||||
/**
|
||||
* Get the male first names.
|
||||
*/
|
||||
@@ -99,7 +99,7 @@ declare class IdentityGeneratorEn extends BaseIdentityGenerator {
|
||||
/**
|
||||
* Identity generator for Dutch language using Dutch word dictionaries.
|
||||
*/
|
||||
declare class IdentityGeneratorNl extends BaseIdentityGenerator {
|
||||
declare class IdentityGeneratorNl extends IdentityGenerator {
|
||||
/**
|
||||
* Get the male first names.
|
||||
*/
|
||||
@@ -137,6 +137,6 @@ declare class IdentityHelperUtils {
|
||||
* @param language - The language to use for generating the identity (e.g. "en", "nl").
|
||||
* @returns A new identity generator instance.
|
||||
*/
|
||||
declare const createGenerator: (language: string) => IIdentityGenerator;
|
||||
declare const CreateIdentityGenerator: (language: string) => IIdentityGenerator;
|
||||
|
||||
export { BaseIdentityGenerator, Gender, type Identity, IdentityGeneratorEn, IdentityGeneratorNl, IdentityHelperUtils, UsernameEmailGenerator, createGenerator };
|
||||
export { CreateIdentityGenerator, Gender, type Identity, IdentityGenerator, IdentityGeneratorEn, IdentityGeneratorNl, IdentityHelperUtils, UsernameEmailGenerator };
|
||||
|
||||
@@ -23,13 +23,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
||||
// src/index.ts
|
||||
var index_exports = {};
|
||||
__export(index_exports, {
|
||||
BaseIdentityGenerator: () => BaseIdentityGenerator,
|
||||
CreateIdentityGenerator: () => CreateIdentityGenerator,
|
||||
Gender: () => Gender,
|
||||
IdentityGenerator: () => IdentityGenerator,
|
||||
IdentityGeneratorEn: () => IdentityGeneratorEn,
|
||||
IdentityGeneratorNl: () => IdentityGeneratorNl,
|
||||
IdentityHelperUtils: () => IdentityHelperUtils,
|
||||
UsernameEmailGenerator: () => UsernameEmailGenerator,
|
||||
createGenerator: () => createGenerator
|
||||
UsernameEmailGenerator: () => UsernameEmailGenerator
|
||||
});
|
||||
module.exports = __toCommonJS(index_exports);
|
||||
|
||||
@@ -139,8 +139,8 @@ var Gender = /* @__PURE__ */ ((Gender2) => {
|
||||
return Gender2;
|
||||
})(Gender || {});
|
||||
|
||||
// src/implementations/base/BaseIdentityGenerator.ts
|
||||
var BaseIdentityGenerator = class {
|
||||
// src/implementations/base/IdentityGenerator.ts
|
||||
var IdentityGenerator = class {
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
@@ -983,7 +983,7 @@ var lastnames_default = [
|
||||
];
|
||||
|
||||
// src/implementations/IdentityGeneratorEn.ts
|
||||
var IdentityGeneratorEn = class extends BaseIdentityGenerator {
|
||||
var IdentityGeneratorEn = class extends IdentityGenerator {
|
||||
/**
|
||||
* Get the male first names.
|
||||
*/
|
||||
@@ -1647,7 +1647,7 @@ var lastnames_default2 = [
|
||||
];
|
||||
|
||||
// src/implementations/IdentityGeneratorNl.ts
|
||||
var IdentityGeneratorNl = class extends BaseIdentityGenerator {
|
||||
var IdentityGeneratorNl = class extends IdentityGenerator {
|
||||
/**
|
||||
* Get the male first names.
|
||||
*/
|
||||
@@ -1718,7 +1718,7 @@ var IdentityHelperUtils = class {
|
||||
};
|
||||
|
||||
// src/factories/IdentityGeneratorFactory.ts
|
||||
var createGenerator = (language) => {
|
||||
var CreateIdentityGenerator = (language) => {
|
||||
switch (language) {
|
||||
case "en":
|
||||
return new IdentityGeneratorEn();
|
||||
@@ -1729,12 +1729,12 @@ var createGenerator = (language) => {
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
BaseIdentityGenerator,
|
||||
CreateIdentityGenerator,
|
||||
Gender,
|
||||
IdentityGenerator,
|
||||
IdentityGeneratorEn,
|
||||
IdentityGeneratorNl,
|
||||
IdentityHelperUtils,
|
||||
UsernameEmailGenerator,
|
||||
createGenerator
|
||||
UsernameEmailGenerator
|
||||
});
|
||||
//# sourceMappingURL=index.js.map
|
||||
@@ -108,8 +108,8 @@ var Gender = /* @__PURE__ */ ((Gender2) => {
|
||||
return Gender2;
|
||||
})(Gender || {});
|
||||
|
||||
// src/implementations/base/BaseIdentityGenerator.ts
|
||||
var BaseIdentityGenerator = class {
|
||||
// src/implementations/base/IdentityGenerator.ts
|
||||
var IdentityGenerator = class {
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
@@ -952,7 +952,7 @@ var lastnames_default = [
|
||||
];
|
||||
|
||||
// src/implementations/IdentityGeneratorEn.ts
|
||||
var IdentityGeneratorEn = class extends BaseIdentityGenerator {
|
||||
var IdentityGeneratorEn = class extends IdentityGenerator {
|
||||
/**
|
||||
* Get the male first names.
|
||||
*/
|
||||
@@ -1616,7 +1616,7 @@ var lastnames_default2 = [
|
||||
];
|
||||
|
||||
// src/implementations/IdentityGeneratorNl.ts
|
||||
var IdentityGeneratorNl = class extends BaseIdentityGenerator {
|
||||
var IdentityGeneratorNl = class extends IdentityGenerator {
|
||||
/**
|
||||
* Get the male first names.
|
||||
*/
|
||||
@@ -1687,7 +1687,7 @@ var IdentityHelperUtils = class {
|
||||
};
|
||||
|
||||
// src/factories/IdentityGeneratorFactory.ts
|
||||
var createGenerator = (language) => {
|
||||
var CreateIdentityGenerator = (language) => {
|
||||
switch (language) {
|
||||
case "en":
|
||||
return new IdentityGeneratorEn();
|
||||
@@ -1697,12 +1697,12 @@ var createGenerator = (language) => {
|
||||
throw new Error(`Unsupported language: ${language}`);
|
||||
};
|
||||
export {
|
||||
BaseIdentityGenerator,
|
||||
CreateIdentityGenerator,
|
||||
Gender,
|
||||
IdentityGenerator,
|
||||
IdentityGeneratorEn,
|
||||
IdentityGeneratorNl,
|
||||
IdentityHelperUtils,
|
||||
UsernameEmailGenerator,
|
||||
createGenerator
|
||||
UsernameEmailGenerator
|
||||
};
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
@@ -115,6 +115,6 @@ declare class PasswordGenerator {
|
||||
* @param settings - The settings for the password generator.
|
||||
* @returns A new password generator instance.
|
||||
*/
|
||||
declare const createPasswordGenerator: (settings: PasswordSettings) => PasswordGenerator;
|
||||
declare const CreatePasswordGenerator: (settings: PasswordSettings) => PasswordGenerator;
|
||||
|
||||
export { PasswordGenerator, type PasswordSettings, createPasswordGenerator };
|
||||
export { CreatePasswordGenerator, PasswordGenerator, type PasswordSettings };
|
||||
|
||||
@@ -23,8 +23,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
||||
// src/index.ts
|
||||
var index_exports = {};
|
||||
__export(index_exports, {
|
||||
PasswordGenerator: () => PasswordGenerator,
|
||||
createPasswordGenerator: () => createPasswordGenerator
|
||||
CreatePasswordGenerator: () => CreatePasswordGenerator,
|
||||
PasswordGenerator: () => PasswordGenerator
|
||||
});
|
||||
module.exports = __toCommonJS(index_exports);
|
||||
|
||||
@@ -236,12 +236,12 @@ var PasswordGenerator = class {
|
||||
};
|
||||
|
||||
// src/factories/PasswordGeneratorFactory.ts
|
||||
var createPasswordGenerator = (settings) => {
|
||||
var CreatePasswordGenerator = (settings) => {
|
||||
return new PasswordGenerator(settings);
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
PasswordGenerator,
|
||||
createPasswordGenerator
|
||||
CreatePasswordGenerator,
|
||||
PasswordGenerator
|
||||
});
|
||||
//# sourceMappingURL=index.js.map
|
||||
@@ -210,11 +210,11 @@ var PasswordGenerator = class {
|
||||
};
|
||||
|
||||
// src/factories/PasswordGeneratorFactory.ts
|
||||
var createPasswordGenerator = (settings) => {
|
||||
var CreatePasswordGenerator = (settings) => {
|
||||
return new PasswordGenerator(settings);
|
||||
};
|
||||
export {
|
||||
PasswordGenerator,
|
||||
createPasswordGenerator
|
||||
CreatePasswordGenerator,
|
||||
PasswordGenerator
|
||||
};
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
@@ -7,7 +7,7 @@ import { IIdentityGenerator } from "src/interfaces/IIdentityGenerator";
|
||||
* @param language - The language to use for generating the identity (e.g. "en", "nl").
|
||||
* @returns A new identity generator instance.
|
||||
*/
|
||||
export const createGenerator = (language: string): IIdentityGenerator => {
|
||||
export const CreateIdentityGenerator = (language: string): IIdentityGenerator => {
|
||||
switch (language) {
|
||||
case 'en':
|
||||
return new IdentityGeneratorEn();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseIdentityGenerator } from "./base/BaseIdentityGenerator";
|
||||
import { IdentityGenerator } from "./base/IdentityGenerator";
|
||||
import maleNames from '../dictionaries/en/firstnames_male';
|
||||
import femaleNames from '../dictionaries/en/firstnames_female';
|
||||
import lastNames from '../dictionaries/en/lastnames';
|
||||
@@ -6,7 +6,7 @@ import lastNames from '../dictionaries/en/lastnames';
|
||||
/**
|
||||
* Identity generator for English language using English word dictionaries.
|
||||
*/
|
||||
export class IdentityGeneratorEn extends BaseIdentityGenerator {
|
||||
export class IdentityGeneratorEn extends IdentityGenerator {
|
||||
/**
|
||||
* Get the male first names.
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseIdentityGenerator } from "./base/BaseIdentityGenerator";
|
||||
import { IdentityGenerator } from "./base/IdentityGenerator";
|
||||
import maleNames from '../dictionaries/nl/firstnames_male';
|
||||
import femaleNames from '../dictionaries/nl/firstnames_female';
|
||||
import lastNames from '../dictionaries/nl/lastnames';
|
||||
@@ -6,7 +6,7 @@ import lastNames from '../dictionaries/nl/lastnames';
|
||||
/**
|
||||
* Identity generator for Dutch language using Dutch word dictionaries.
|
||||
*/
|
||||
export class IdentityGeneratorNl extends BaseIdentityGenerator {
|
||||
export class IdentityGeneratorNl extends IdentityGenerator {
|
||||
/**
|
||||
* Get the male first names.
|
||||
*/
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Identity } from '../../types/Identity';
|
||||
/**
|
||||
* Base identity generator.
|
||||
*/
|
||||
export abstract class BaseIdentityGenerator implements IIdentityGenerator {
|
||||
export abstract class IdentityGenerator implements IIdentityGenerator {
|
||||
protected firstNamesMale: string[] = [];
|
||||
protected firstNamesFemale: string[] = [];
|
||||
protected lastNames: string[] = [];
|
||||
@@ -3,6 +3,6 @@ export * from './types/Identity';
|
||||
export * from './types/Gender';
|
||||
export * from './implementations/IdentityGeneratorEn';
|
||||
export * from './implementations/IdentityGeneratorNl';
|
||||
export * from './implementations/base/BaseIdentityGenerator';
|
||||
export * from './implementations/base/IdentityGenerator';
|
||||
export * from './utils/IdentityHelperUtils';
|
||||
export * from './factories/IdentityGeneratorFactory';
|
||||
|
||||
@@ -6,6 +6,6 @@ import { PasswordGenerator } from "src/utils/PasswordGenerator";
|
||||
* @param settings - The settings for the password generator.
|
||||
* @returns A new password generator instance.
|
||||
*/
|
||||
export const createPasswordGenerator = (settings: PasswordSettings): PasswordGenerator => {
|
||||
export const CreatePasswordGenerator = (settings: PasswordSettings): PasswordGenerator => {
|
||||
return new PasswordGenerator(settings);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user