@overlordai/validation 1.0.54
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.
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/password.d.ts +14 -0
- package/dist/password.d.ts.map +1 -0
- package/dist/password.js +26 -0
- package/dist/password.js.map +1 -0
- package/package.json +17 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,YAAY,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validatePassword = void 0;
|
|
4
|
+
var password_js_1 = require("./password.js");
|
|
5
|
+
Object.defineProperty(exports, "validatePassword", { enumerable: true, get: function () { return password_js_1.validatePassword; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6CAAiD;AAAxC,+GAAA,gBAAgB,OAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Translation keys returned by validatePassword. */
|
|
2
|
+
export type PasswordValidationError = 'admin.password_length_error' | 'admin.password_complexity_error';
|
|
3
|
+
/**
|
|
4
|
+
* Validate a password against the project's password policy.
|
|
5
|
+
*
|
|
6
|
+
* Rules:
|
|
7
|
+
* - Length: 10–20 characters
|
|
8
|
+
* - Must contain at least one letter, one digit, and one special character
|
|
9
|
+
*
|
|
10
|
+
* Returns `null` when the password is valid, or a translation key
|
|
11
|
+
* describing the first violated rule.
|
|
12
|
+
*/
|
|
13
|
+
export declare function validatePassword(password: string): PasswordValidationError | null;
|
|
14
|
+
//# sourceMappingURL=password.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password.d.ts","sourceRoot":"","sources":["../src/password.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,MAAM,MAAM,uBAAuB,GAC/B,6BAA6B,GAC7B,iCAAiC,CAAC;AAEtC;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,uBAAuB,GAAG,IAAI,CAajF"}
|
package/dist/password.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validatePassword = validatePassword;
|
|
4
|
+
/**
|
|
5
|
+
* Validate a password against the project's password policy.
|
|
6
|
+
*
|
|
7
|
+
* Rules:
|
|
8
|
+
* - Length: 10–20 characters
|
|
9
|
+
* - Must contain at least one letter, one digit, and one special character
|
|
10
|
+
*
|
|
11
|
+
* Returns `null` when the password is valid, or a translation key
|
|
12
|
+
* describing the first violated rule.
|
|
13
|
+
*/
|
|
14
|
+
function validatePassword(password) {
|
|
15
|
+
if (password.length < 10 || password.length > 20) {
|
|
16
|
+
return 'admin.password_length_error';
|
|
17
|
+
}
|
|
18
|
+
const hasLetter = /[a-zA-Z]/.test(password);
|
|
19
|
+
const hasDigit = /\d/.test(password);
|
|
20
|
+
const hasSpecial = /[^a-zA-Z0-9]/.test(password);
|
|
21
|
+
if (!hasLetter || !hasDigit || !hasSpecial) {
|
|
22
|
+
return 'admin.password_complexity_error';
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=password.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password.js","sourceRoot":"","sources":["../src/password.ts"],"names":[],"mappings":";;AAeA,4CAaC;AAvBD;;;;;;;;;GASG;AACH,SAAgB,gBAAgB,CAAC,QAAgB;IAC/C,IAAI,QAAQ,CAAC,MAAM,GAAG,EAAE,IAAI,QAAQ,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QACjD,OAAO,6BAA6B,CAAC;IACvC,CAAC;IAED,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrC,MAAM,UAAU,GAAG,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjD,IAAI,CAAC,SAAS,IAAI,CAAC,QAAQ,IAAI,CAAC,UAAU,EAAE,CAAC;QAC3C,OAAO,iCAAiC,CAAC;IAC3C,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@overlordai/validation",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "1.0.54",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": ["dist"],
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"test": "vitest run",
|
|
12
|
+
"lint": "tsc --noEmit"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"vitest": "^4.0.18"
|
|
16
|
+
}
|
|
17
|
+
}
|