Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Update identity model import location (#2279)

Leendert de Borstc1684ac02faf
diff --git a/apps/browser-extension/src/utils/dist/core/models/identity/index.d.ts b/apps/browser-extension/src/utils/dist/core/models/identity/index.d.ts
new file mode 100644
index 000000000..6c9e9ff3e
--- /dev/null
+++ b/apps/browser-extension/src/utils/dist/core/models/identity/index.d.ts
@@ -0,0 +1,42 @@
+/**
+ * Gender values used by generated identities and alias persona fields.
+ * Matches the string values produced by the Rust core identity generator.
+ */
+declare enum Gender {
+ Male = "Male",
+ Female = "Female",
+ Other = "Other"
+}
+
+/**
+ * A generated identity as returned by the Rust core identity generator
+ * (JSON with camelCase fields).
+ */
+type Identity = {
+ firstName: string;
+ lastName: string;
+ gender: Gender | string;
+ /** Birth date in yyyy-MM-dd format. */
+ birthDate: string;
+ emailPrefix: string;
+ /** Username derived from the name and birth year (alphanumeric only). */
+ nickName: string;
+};
+
+/**
+ * Helper utilities for working with identity birth dates in the client UIs.
+ */
+declare class IdentityHelperUtils {
+ /**
+ * Normalize a birth date to the standard format: "yyyy-MM-dd".
+ * Handles various input formats including ISO strings with time components.
+ * Returns empty string for invalid/empty dates.
+ */
+ static normalizeBirthDate(input: string | undefined): string;
+ /**
+ * Check if a birth date is valid.
+ */
+ static isValidBirthDate(input: string | undefined): boolean;
+}
+
+export { Gender, type Identity, IdentityHelperUtils };
diff --git a/apps/browser-extension/src/utils/dist/core/models/identity/index.js b/apps/browser-extension/src/utils/dist/core/models/identity/index.js
new file mode 100644
index 000000000..60524e3fd
--- /dev/null
+++ b/apps/browser-extension/src/utils/dist/core/models/identity/index.js
@@ -0,0 +1,58 @@
+// <auto-generated>
+// This file was automatically generated. Do not edit manually.
+
+
+// src/identity/Gender.ts
+var Gender = /* @__PURE__ */ ((Gender2) => {
+ Gender2["Male"] = "Male";
+ Gender2["Female"] = "Female";
+ Gender2["Other"] = "Other";
+ return Gender2;
+})(Gender || {});
+
+// src/identity/IdentityHelperUtils.ts
+var IdentityHelperUtils = class {
+ /**
+ * Normalize a birth date to the standard format: "yyyy-MM-dd".
+ * Handles various input formats including ISO strings with time components.
+ * Returns empty string for invalid/empty dates.
+ */
+ static normalizeBirthDate(input) {
+ if (!input || input.trim() === "" || input.startsWith("0001-01-01")) {
+ return "";
+ }
+ const trimmed = input.trim();
+ const match = trimmed.match(/^(\d{4})-(\d{2})-(\d{2})/);
+ if (match) {
+ const [, y, m, d] = match;
+ return `${y}-${m}-${d}`;
+ }
+ const parsedDate = new Date(trimmed);
+ if (!isNaN(parsedDate.getTime())) {
+ const year = parsedDate.getFullYear().toString().padStart(4, "0");
+ const month = (parsedDate.getMonth() + 1).toString().padStart(2, "0");
+ const day = parsedDate.getDate().toString().padStart(2, "0");
+ return `${year}-${month}-${day}`;
+ }
+ return "";
+ }
+ /**
+ * Check if a birth date is valid.
+ */
+ static isValidBirthDate(input) {
+ if (!input || input.trim() === "") {
+ return false;
+ }
+ if (input.startsWith("0001-01-01")) {
+ return false;
+ }
+ const date = new Date(input);
+ if (isNaN(date.getTime())) {
+ return false;
+ }
+ const yearValid = date.getFullYear() > 1 && date.getFullYear() < 9999;
+ return yearValid;
+ }
+};
+
+export { Gender, IdentityHelperUtils };
diff --git a/apps/browser-extension/src/utils/formDetector/FormFiller.ts b/apps/browser-extension/src/utils/formDetector/FormFiller.ts
index 0dd9359db..2739f275d 100644
--- a/apps/browser-extension/src/utils/formDetector/FormFiller.ts
+++ b/apps/browser-extension/src/utils/formDetector/FormFiller.ts
@@ -1,4 +1,4 @@
-import { Gender, IdentityHelperUtils } from "@/utils/dist/core/identity-generator";
+import { Gender, IdentityHelperUtils } from "@/utils/dist/core/models/identity";
import type { Credential } from "@/utils/dist/core/models/vault";
import { CombinedDateOptionPatterns, CombinedGenderOptionPatterns } from "@/utils/formDetector/FieldPatterns";
import { FormFields } from "@/utils/formDetector/types/FormFields";
diff --git a/apps/browser-extension/src/utils/formDetector/__tests__/TestUtils.ts b/apps/browser-extension/src/utils/formDetector/__tests__/TestUtils.ts
index 5a950f368..3dd11ecf6 100644
--- a/apps/browser-extension/src/utils/formDetector/__tests__/TestUtils.ts
+++ b/apps/browser-extension/src/utils/formDetector/__tests__/TestUtils.ts
@@ -4,7 +4,7 @@ import { join } from 'path';
import { JSDOM, DOMWindow } from 'jsdom';
import { it, expect, vi } from 'vitest';
-import { Gender } from '@/utils/dist/core/identity-generator';
+import { Gender } from '@/utils/dist/core/models/identity';
import type { Credential } from '@/utils/dist/core/models/vault';
import { FormDetector } from '@/utils/formDetector/FormDetector';
import { FormFields } from '@/utils/formDetector/types/FormFields';