nodecommons-esm-security 0.0.7 → 0.0.8

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.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { commonsHashMd5, commonsHashSha1, commonsHashSha256, commonsHashRandomMd5, commonsHashRandomSha1, commonsHashRandomSha256 } from './helpers/commons-hash.mjs';
1
+ import { CommonsUserSessionService } from './services/commons-user-session.service.mjs';
2
2
  import { CommonsSimpleSinglePwSessionService } from './services/commons-simple-single-pw-session.service.mjs';
3
- import { CommonsSessionService } from './services/commons-session.service.mjs';
4
3
  import { CommonsUserPwHashSessionService } from './services/commons-user-pw-hash-session.service.mjs';
5
- import { CommonsUserSessionService } from './services/commons-user-session.service.mjs';
4
+ import { CommonsSessionService } from './services/commons-session.service.mjs';
5
+ import { commonsHashMd5, commonsHashSha1, commonsHashSha256, commonsHashRandomMd5, commonsHashRandomSha1, commonsHashRandomSha256 } from './helpers/commons-hash.mjs';
6
6
  import { ICommonsUserPwHash, isICommonsUserPwHash } from './interfaces/icommons-user-pw-hash.mjs';
7
- export { commonsHashMd5, commonsHashSha1, commonsHashSha256, commonsHashRandomMd5, commonsHashRandomSha1, commonsHashRandomSha256, CommonsSimpleSinglePwSessionService, CommonsSessionService, CommonsUserPwHashSessionService, CommonsUserSessionService, ICommonsUserPwHash, isICommonsUserPwHash };
7
+ export { CommonsUserSessionService, CommonsSimpleSinglePwSessionService, CommonsUserPwHashSessionService, CommonsSessionService, commonsHashMd5, commonsHashSha1, commonsHashSha256, commonsHashRandomMd5, commonsHashRandomSha1, commonsHashRandomSha256, ICommonsUserPwHash, isICommonsUserPwHash };
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import { commonsHashMd5, commonsHashSha1, commonsHashSha256, commonsHashRandomMd5, commonsHashRandomSha1, commonsHashRandomSha256 } from './helpers/commons-hash.mjs';
1
+ import { CommonsUserSessionService } from './services/commons-user-session.service.mjs';
2
2
  import { CommonsSimpleSinglePwSessionService } from './services/commons-simple-single-pw-session.service.mjs';
3
- import { CommonsSessionService } from './services/commons-session.service.mjs';
4
3
  import { CommonsUserPwHashSessionService } from './services/commons-user-pw-hash-session.service.mjs';
5
- import { CommonsUserSessionService } from './services/commons-user-session.service.mjs';
4
+ import { CommonsSessionService } from './services/commons-session.service.mjs';
5
+ import { commonsHashMd5, commonsHashSha1, commonsHashSha256, commonsHashRandomMd5, commonsHashRandomSha1, commonsHashRandomSha256 } from './helpers/commons-hash.mjs';
6
6
  import { isICommonsUserPwHash } from './interfaces/icommons-user-pw-hash.mjs';
7
- export { commonsHashMd5, commonsHashSha1, commonsHashSha256, commonsHashRandomMd5, commonsHashRandomSha1, commonsHashRandomSha256, CommonsSimpleSinglePwSessionService, CommonsSessionService, CommonsUserPwHashSessionService, CommonsUserSessionService, isICommonsUserPwHash };
7
+ export { CommonsUserSessionService, CommonsSimpleSinglePwSessionService, CommonsUserPwHashSessionService, CommonsSessionService, commonsHashMd5, commonsHashSha1, commonsHashSha256, commonsHashRandomMd5, commonsHashRandomSha1, commonsHashRandomSha256, isICommonsUserPwHash };
8
8
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,mCAAmC,EAAE,MAAM,yDAAyD,CAAC;AAC9G,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,+BAA+B,EAAE,MAAM,qDAAqD,CAAC;AACtG,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACxF,OAAO,EAAsB,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAClG,OAAO,EACN,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,mCAAmC,EACnC,qBAAqB,EACrB,+BAA+B,EAC/B,yBAAyB,EAEzB,oBAAoB,EACpB,CAAC"}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACxF,OAAO,EAAE,mCAAmC,EAAE,MAAM,yDAAyD,CAAC;AAC9G,OAAO,EAAE,+BAA+B,EAAE,MAAM,qDAAqD,CAAC;AACtG,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EACL,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAsB,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAClG,OAAO,EACN,yBAAyB,EACzB,mCAAmC,EACnC,+BAA+B,EAC/B,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EAEvB,oBAAoB,EACpB,CAAC"}
@@ -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
- constructor(pepper, allowMultipleSessionsForSameUser = false) {
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
- this.pepper || '',
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;IAEpG;IADV,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,MAAM,UAAU,GAAa;YAC3B,IAAI;YACJ,IAAI,CAAC,MAAM,IAAI,EAAE;YACjB,EAAE;SACH,CAAC;QAEF,OAAO,iBAAiB,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/C,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"}
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.7",
3
+ "version": "0.0.8",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "tsc": "./node_modules/typescript/bin/tsc",