nodecommons-esm-security 0.0.7 → 0.0.9
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.
|
@@ -3,6 +3,7 @@ import { ICommonsUserPwHash } from '../interfaces/icommons-user-pw-hash.mjs';
|
|
|
3
3
|
import { CommonsUserSessionService } from './commons-user-session.service.mjs';
|
|
4
4
|
export declare class CommonsUserPwHashSessionService<T extends ICommonsUserPwHash> extends CommonsUserSessionService<T> {
|
|
5
5
|
private pepper?;
|
|
6
|
+
static generateSaltAndPepperPwHash(pw: string, salt: string, pepper?: string): string;
|
|
6
7
|
constructor(pepper?: string | undefined, allowMultipleSessionsForSameUser?: boolean);
|
|
7
8
|
generatePwHash(pw: string, salt: string): string;
|
|
8
9
|
authenticateWithPwHash(user: T, pw: string): ICommonsSession<T> | undefined;
|
|
@@ -2,18 +2,21 @@ import { commonsHashSha256 } from '../helpers/commons-hash.mjs';
|
|
|
2
2
|
import { CommonsUserSessionService } from './commons-user-session.service.mjs';
|
|
3
3
|
export class CommonsUserPwHashSessionService extends CommonsUserSessionService {
|
|
4
4
|
pepper;
|
|
5
|
-
|
|
6
|
-
super(allowMultipleSessionsForSameUser);
|
|
7
|
-
this.pepper = pepper;
|
|
8
|
-
}
|
|
9
|
-
generatePwHash(pw, salt) {
|
|
5
|
+
static generateSaltAndPepperPwHash(pw, salt, pepper) {
|
|
10
6
|
const components = [
|
|
11
7
|
salt,
|
|
12
|
-
|
|
8
|
+
pepper || '',
|
|
13
9
|
pw
|
|
14
10
|
];
|
|
15
11
|
return commonsHashSha256(components.join(''));
|
|
16
12
|
}
|
|
13
|
+
constructor(pepper, allowMultipleSessionsForSameUser = false) {
|
|
14
|
+
super(allowMultipleSessionsForSameUser);
|
|
15
|
+
this.pepper = pepper;
|
|
16
|
+
}
|
|
17
|
+
generatePwHash(pw, salt) {
|
|
18
|
+
return CommonsUserPwHashSessionService.generateSaltAndPepperPwHash(pw, salt, this.pepper);
|
|
19
|
+
}
|
|
17
20
|
authenticateWithPwHash(user, pw) {
|
|
18
21
|
const compare = this.generatePwHash(pw, user.salt);
|
|
19
22
|
if (user.pwHash !== compare) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commons-user-pw-hash-session.service.mjs","sourceRoot":"","sources":["../../src/services/commons-user-pw-hash-session.service.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAIhE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAE/E,MAAM,OAAO,+BAA8D,SAAQ,yBAA4B;
|
|
1
|
+
{"version":3,"file":"commons-user-pw-hash-session.service.mjs","sourceRoot":"","sources":["../../src/services/commons-user-pw-hash-session.service.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAIhE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAE/E,MAAM,OAAO,+BAA8D,SAAQ,yBAA4B;IAgBpG;IAfH,MAAM,CAAC,2BAA2B,CACvC,EAAU,EACV,IAAY,EACZ,MAAe;QAEhB,MAAM,UAAU,GAAa;YAC3B,IAAI;YACJ,MAAM,IAAI,EAAE;YACZ,EAAE;SACH,CAAC;QAEF,OAAO,iBAAiB,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED,YACU,MAAe,EACvB,mCAA4C,KAAK;QAElD,KAAK,CAAC,gCAAgC,CAAC,CAAC;QAH/B,WAAM,GAAN,MAAM,CAAS;IAIzB,CAAC;IAEM,cAAc,CAAC,EAAU,EAAE,IAAY;QAC7C,OAAO,+BAA+B,CAAC,2BAA2B,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3F,CAAC;IAEM,sBAAsB,CAAC,IAAO,EAAE,EAAU;QAChD,MAAM,OAAO,GAAW,IAAI,CAAC,cAAc,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAE3D,IAAI,IAAI,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;YAC7B,6DAA6D;YAC7D,OAAO,SAAS,CAAC;QAClB,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;CACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodecommons-esm-security",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"tsc": "./node_modules/typescript/bin/tsc",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dist/**/*"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"tscommons-esm-core": "^0.0
|
|
30
|
-
"tscommons-esm-session": "^0.0.
|
|
29
|
+
"tscommons-esm-core": "^0.1.0",
|
|
30
|
+
"tscommons-esm-session": "^0.0.8"
|
|
31
31
|
}
|
|
32
32
|
}
|