Skip to content

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

Use shared date util for min date check in browser extension (#834)

Leendert de Borst3d3522a262a4
diff --git a/apps/browser-extension/src/utils/formDetector/FormFiller.ts b/apps/browser-extension/src/utils/formDetector/FormFiller.ts
index 790f8b980..2314ade45 100644
--- a/apps/browser-extension/src/utils/formDetector/FormFiller.ts
+++ b/apps/browser-extension/src/utils/formDetector/FormFiller.ts
@@ -1,7 +1,7 @@
import { Credential } from "@/utils/types/Credential";
import { FormFields } from "@/utils/formDetector/types/FormFields";
import { CombinedDateOptionPatterns, CombinedGenderOptionPatterns } from "@/utils/formDetector/FieldPatterns";
-import { Gender } from "@/utils/shared/identity-generator";
+import { Gender, IdentityHelperUtils } from "@/utils/shared/identity-generator";
/**
* Class to fill the fields of a form with the given credential.
*/
@@ -118,7 +118,7 @@ export class FormFiller {
*/
private fillBirthdateFields(credential: Credential): void {
// TODO: when birth date is made optional in datamodel, we can remove this mindate check here.
- if (!credential.Alias.BirthDate || credential.Alias.BirthDate.startsWith('0001-01-01')) {
+ if (!IdentityHelperUtils.isValidBirthDate(credential.Alias.BirthDate)) {
return;
}
diff --git a/apps/browser-extension/src/utils/shared/identity-generator/index.js b/apps/browser-extension/src/utils/shared/identity-generator/index.js
index e1c3fa169..b2d9c662f 100644
--- a/apps/browser-extension/src/utils/shared/identity-generator/index.js
+++ b/apps/browser-extension/src/utils/shared/identity-generator/index.js
@@ -1701,6 +1701,9 @@ var IdentityHelperUtils = class {
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;
diff --git a/apps/browser-extension/src/utils/shared/identity-generator/index.mjs b/apps/browser-extension/src/utils/shared/identity-generator/index.mjs
index 2a6d2dd3b..6675da168 100644
--- a/apps/browser-extension/src/utils/shared/identity-generator/index.mjs
+++ b/apps/browser-extension/src/utils/shared/identity-generator/index.mjs
@@ -1670,6 +1670,9 @@ var IdentityHelperUtils = class {
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;
diff --git a/apps/mobile-app/utils/shared/identity-generator/index.js b/apps/mobile-app/utils/shared/identity-generator/index.js
index e1c3fa169..b2d9c662f 100644
--- a/apps/mobile-app/utils/shared/identity-generator/index.js
+++ b/apps/mobile-app/utils/shared/identity-generator/index.js
@@ -1701,6 +1701,9 @@ var IdentityHelperUtils = class {
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;
diff --git a/apps/mobile-app/utils/shared/identity-generator/index.mjs b/apps/mobile-app/utils/shared/identity-generator/index.mjs
index 2a6d2dd3b..6675da168 100644
--- a/apps/mobile-app/utils/shared/identity-generator/index.mjs
+++ b/apps/mobile-app/utils/shared/identity-generator/index.mjs
@@ -1670,6 +1670,9 @@ var IdentityHelperUtils = class {
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;
diff --git a/shared/identity-generator/src/utils/IdentityHelperUtils.ts b/shared/identity-generator/src/utils/IdentityHelperUtils.ts
index d43d588b8..2ae3e25dd 100644
--- a/shared/identity-generator/src/utils/IdentityHelperUtils.ts
+++ b/shared/identity-generator/src/utils/IdentityHelperUtils.ts
@@ -48,6 +48,10 @@ export class IdentityHelperUtils {
return false;
}
+ if (input.startsWith('0001-01-01')) {
+ return false;
+ }
+
const date = new Date(input);
// Check if the date is valid