@punks/backend-entity-manager 0.0.32 → 0.0.33

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.
@@ -4,13 +4,7 @@ export declare class AuthActions {
4
4
  private readonly auth;
5
5
  constructor(auth: AuthenticationService);
6
6
  login(data: UserLoginRequest): Promise<import("../../../../extensions/authentication/handlers/user-login/types").UserLoginResult>;
7
- register(data: UserRegisterRequest): Promise<{
8
- success: boolean;
9
- error: import("../../../../extensions").UserRegistrationError;
10
- } | {
11
- success: boolean;
12
- error?: undefined;
13
- }>;
7
+ register(data: UserRegisterRequest): Promise<import("../../../../extensions/authentication/handlers/user-register/types").UserRegistrationResult>;
14
8
  passwordReset(data: UserPasswordResetRequest): Promise<import("../../../../extensions/authentication/handlers/user-password-reset-request/types").UserPasswordResetRequestResult>;
15
9
  passwordResetComplete(data: UserPasswordResetCompleteRequest): Promise<void>;
16
10
  userVerifyRequest(data: UserEmailVerifyRequest): Promise<import("../../../../extensions/authentication/handlers/user-verify-request/types").UserVerifyResetRequestResult>;
@@ -2,22 +2,15 @@ import { IUserContext } from "../../abstractions";
2
2
  import { EmailService } from "../../../../services";
3
3
  import { AuthenticationServicesResolver } from "../../resolver";
4
4
  import { JwtProvider } from "../../providers/jwt";
5
- import { UserRegistrationError } from "../../types";
6
5
  import { PasswordHashingProvider } from "../../providers/password-hasher";
7
- import { UserRegistrationInput } from "./types";
6
+ import { UserRegistrationInput, UserRegistrationResult } from "./types";
8
7
  export declare class UserRegistrationHandler {
9
8
  private readonly services;
10
9
  private readonly passwordHashingProvider;
11
10
  private readonly emailService;
12
11
  private readonly jwtProvider;
13
12
  constructor(services: AuthenticationServicesResolver, passwordHashingProvider: PasswordHashingProvider, emailService: EmailService, jwtProvider: JwtProvider);
14
- execute<TUserRegistrationInfo, TContext extends IUserContext>(input: UserRegistrationInput<TUserRegistrationInfo, TContext>): Promise<{
15
- success: boolean;
16
- error: UserRegistrationError;
17
- } | {
18
- success: boolean;
19
- error?: undefined;
20
- }>;
13
+ execute<TUserRegistrationInfo, TContext extends IUserContext>(input: UserRegistrationInput<TUserRegistrationInfo, TContext>): Promise<UserRegistrationResult>;
21
14
  private createPasswordHash;
22
15
  private sendRegistrationEmail;
23
16
  private generateEmailVerifyToken;
@@ -11,14 +11,14 @@ import { UserTokenVerifyHandler } from "../../handlers/user-token-verify";
11
11
  import { UserVerifyRequestHandler } from "../../handlers/user-verify-request";
12
12
  import { UserDisableInput } from "../../handlers/user-disable/types";
13
13
  import { UserEnableInput } from "../../handlers/user-enable/types";
14
- import { UserLoginInput } from "../../handlers/user-login/types";
14
+ import { UserLoginInput, UserLoginResult } from "../../handlers/user-login/types";
15
15
  import { UserPasswordChangeInput } from "../../handlers/user-password-change/types";
16
16
  import { UserPasswordResetCompleteInput } from "../../handlers/user-password-reset-complete/types";
17
- import { UserPasswordResetRequestInput } from "../../handlers/user-password-reset-request/types";
18
- import { UserRegistrationInput } from "../../handlers/user-register/types";
19
- import { UserTokenVerifyInput } from "../../handlers/user-token-verify/types";
17
+ import { UserPasswordResetRequestInput, UserPasswordResetRequestResult } from "../../handlers/user-password-reset-request/types";
18
+ import { UserRegistrationInput, UserRegistrationResult } from "../../handlers/user-register/types";
19
+ import { UserTokenVerifyInput, UserTokenVerifyResult } from "../../handlers/user-token-verify/types";
20
20
  import { UserVerifyCompleteInput } from "../../handlers/user-verify-complete/types";
21
- import { UserVerifyRequestInput } from "../../handlers/user-verify-request/types";
21
+ import { UserVerifyRequestInput, UserVerifyResetRequestResult } from "../../handlers/user-verify-request/types";
22
22
  export declare class AuthenticationService implements IAuthenticationService {
23
23
  private readonly userDisableHandler;
24
24
  private readonly userEnableHandler;
@@ -33,18 +33,12 @@ export declare class AuthenticationService implements IAuthenticationService {
33
33
  constructor(userDisableHandler: UserDisableHandler, userEnableHandler: UserEnableHandler, userLoginHandler: UserLoginHandler, userPasswordChangeHandler: UserPasswordChangeHandler, userPasswordResetFinalizeHandler: UserPasswordResetCompleteHandler, userPasswordResetRequestHandler: UserPasswordResetRequestHandler, userRegistrationHandler: UserRegistrationHandler, userTokenVerifyHandler: UserTokenVerifyHandler, userVerifyRequestHandler: UserVerifyRequestHandler, userVerifyCompleteHandler: UserVerifyCompleteHandler);
34
34
  userDisable(input: UserDisableInput): Promise<void>;
35
35
  userEnable(input: UserEnableInput): Promise<void>;
36
- userLogin<TUserContext extends IUserContext>(input: UserLoginInput<TUserContext>): Promise<import("../../handlers/user-login/types").UserLoginResult>;
36
+ userLogin<TUserContext extends IUserContext>(input: UserLoginInput<TUserContext>): Promise<UserLoginResult>;
37
37
  userPasswordChange(input: UserPasswordChangeInput): Promise<void>;
38
38
  userPasswordResetFinalize(input: UserPasswordResetCompleteInput): Promise<void>;
39
- userPasswordResetRequest<TUserContext extends IUserContext>(input: UserPasswordResetRequestInput<TUserContext>): Promise<import("../../handlers/user-password-reset-request/types").UserPasswordResetRequestResult>;
40
- userRegister<TUserRegistrationInfo, TUserContext extends IUserContext>(input: UserRegistrationInput<TUserRegistrationInfo, TUserContext>): Promise<{
41
- success: boolean;
42
- error: import("../..").UserRegistrationError;
43
- } | {
44
- success: boolean;
45
- error?: undefined;
46
- }>;
47
- userVerifyRequest<TUserContext extends IUserContext>(input: UserVerifyRequestInput<TUserContext>): Promise<import("../../handlers/user-verify-request/types").UserVerifyResetRequestResult>;
39
+ userPasswordResetRequest<TUserContext extends IUserContext>(input: UserPasswordResetRequestInput<TUserContext>): Promise<UserPasswordResetRequestResult>;
40
+ userRegister<TUserRegistrationInfo, TUserContext extends IUserContext>(input: UserRegistrationInput<TUserRegistrationInfo, TUserContext>): Promise<UserRegistrationResult>;
41
+ userVerifyRequest<TUserContext extends IUserContext>(input: UserVerifyRequestInput<TUserContext>): Promise<UserVerifyResetRequestResult>;
48
42
  userVerifyComplete(input: UserVerifyCompleteInput): Promise<void>;
49
- userTokenVerify<TUserContext extends IUserContext>(input: UserTokenVerifyInput): Promise<import("../../handlers/user-token-verify/types").UserTokenVerifyResult<TUserContext>>;
43
+ userTokenVerify<TUserContext extends IUserContext>(input: UserTokenVerifyInput): Promise<UserTokenVerifyResult<TUserContext>>;
50
44
  }
package/dist/index.d.ts CHANGED
@@ -770,50 +770,6 @@ declare class OperationTokenMismatchError extends AuthenticationError {
770
770
  constructor(message: string);
771
771
  }
772
772
 
773
- interface UserTokenVerifyResult<TUserContext extends IUserContext> {
774
- isValid: boolean;
775
- data: IUserTokenData<TUserContext>;
776
- }
777
- interface UserTokenVerifyInput {
778
- token: string;
779
- }
780
-
781
- interface UserVerifyRequestInput<TUserContext extends IUserContext> {
782
- email: string;
783
- callback: CallbackTemplate$2;
784
- context?: TUserContext;
785
- }
786
- interface UserVerifyResetRequestResult {
787
- success: boolean;
788
- }
789
- type CallbackTemplate$2 = {
790
- urlTemplate: string;
791
- tokenPlaceholder: string;
792
- };
793
-
794
- type CallbackTemplate$1 = {
795
- urlTemplate: string;
796
- tokenPlaceholder: string;
797
- };
798
- interface UserPasswordResetRequestInput<TUserContext extends IUserContext> {
799
- email: string;
800
- callback: CallbackTemplate$1;
801
- context?: TUserContext;
802
- }
803
- interface UserPasswordResetRequestResult {
804
- success: boolean;
805
- }
806
-
807
- interface UserLoginInput<TUserContext extends IUserContext> {
808
- userName: string;
809
- password: string;
810
- context?: TUserContext;
811
- }
812
- interface UserLoginResult {
813
- token?: string;
814
- success: boolean;
815
- }
816
-
817
773
  declare class AppSessionService {
818
774
  getValue<T>(key: string): T;
819
775
  setValue<T>(key: string, value: T): void;
@@ -857,6 +813,23 @@ declare class JwtProvider {
857
813
  verify<T extends object>(token: string): Promise<T>;
858
814
  }
859
815
 
816
+ declare class PasswordHashingProvider {
817
+ private readonly hashing;
818
+ constructor(hashing: AppHashingService);
819
+ hashPassword(input: {
820
+ password: string;
821
+ userId: string;
822
+ }): Promise<string>;
823
+ verifyPassword(input: {
824
+ password: string;
825
+ userId: string;
826
+ hash: string;
827
+ }): Promise<{
828
+ isMatching: boolean;
829
+ }>;
830
+ private buildUserSalt;
831
+ }
832
+
860
833
  interface AuthenticationModuleSettings {
861
834
  passwordSalt: string;
862
835
  jwtSecret: string;
@@ -875,24 +848,7 @@ declare enum UserRegistrationError {
875
848
  UserAlreadyExists = 0
876
849
  }
877
850
 
878
- declare class PasswordHashingProvider {
879
- private readonly hashing;
880
- constructor(hashing: AppHashingService);
881
- hashPassword(input: {
882
- password: string;
883
- userId: string;
884
- }): Promise<string>;
885
- verifyPassword(input: {
886
- password: string;
887
- userId: string;
888
- hash: string;
889
- }): Promise<{
890
- isMatching: boolean;
891
- }>;
892
- private buildUserSalt;
893
- }
894
-
895
- type CallbackTemplate = {
851
+ type CallbackTemplate$2 = {
896
852
  urlTemplate: string;
897
853
  tokenPlaceholder: string;
898
854
  };
@@ -900,9 +856,13 @@ interface UserRegistrationInput<TUserRegistrationInfo, TUserContext extends IUse
900
856
  email: string;
901
857
  password: string;
902
858
  registrationInfo: TUserRegistrationInfo;
903
- callback: CallbackTemplate;
859
+ callback: CallbackTemplate$2;
904
860
  context?: TUserContext;
905
861
  }
862
+ interface UserRegistrationResult {
863
+ success: boolean;
864
+ error?: UserRegistrationError;
865
+ }
906
866
 
907
867
  declare class UserRegistrationHandler {
908
868
  private readonly services;
@@ -910,13 +870,7 @@ declare class UserRegistrationHandler {
910
870
  private readonly emailService;
911
871
  private readonly jwtProvider;
912
872
  constructor(services: AuthenticationServicesResolver, passwordHashingProvider: PasswordHashingProvider, emailService: EmailService, jwtProvider: JwtProvider);
913
- execute<TUserRegistrationInfo, TContext extends IUserContext>(input: UserRegistrationInput<TUserRegistrationInfo, TContext>): Promise<{
914
- success: boolean;
915
- error: UserRegistrationError;
916
- } | {
917
- success: boolean;
918
- error?: undefined;
919
- }>;
873
+ execute<TUserRegistrationInfo, TContext extends IUserContext>(input: UserRegistrationInput<TUserRegistrationInfo, TContext>): Promise<UserRegistrationResult>;
920
874
  private createPasswordHash;
921
875
  private sendRegistrationEmail;
922
876
  private generateEmailVerifyToken;
@@ -944,6 +898,16 @@ declare class UserEnableHandler {
944
898
  execute(input: UserEnableInput): Promise<void>;
945
899
  }
946
900
 
901
+ interface UserLoginInput<TUserContext extends IUserContext> {
902
+ userName: string;
903
+ password: string;
904
+ context?: TUserContext;
905
+ }
906
+ interface UserLoginResult {
907
+ token?: string;
908
+ success: boolean;
909
+ }
910
+
947
911
  declare class UserLoginHandler {
948
912
  private readonly services;
949
913
  private readonly passwordHashingProvider;
@@ -984,6 +948,19 @@ declare class UserPasswordResetCompleteHandler {
984
948
  private getUser;
985
949
  }
986
950
 
951
+ type CallbackTemplate$1 = {
952
+ urlTemplate: string;
953
+ tokenPlaceholder: string;
954
+ };
955
+ interface UserPasswordResetRequestInput<TUserContext extends IUserContext> {
956
+ email: string;
957
+ callback: CallbackTemplate$1;
958
+ context?: TUserContext;
959
+ }
960
+ interface UserPasswordResetRequestResult {
961
+ success: boolean;
962
+ }
963
+
987
964
  declare class UserPasswordResetRequestHandler {
988
965
  private readonly services;
989
966
  private readonly emailService;
@@ -1009,6 +986,14 @@ declare class UserVerifyCompleteHandler {
1009
986
  private getUser;
1010
987
  }
1011
988
 
989
+ interface UserTokenVerifyResult<TUserContext extends IUserContext> {
990
+ isValid: boolean;
991
+ data: IUserTokenData<TUserContext>;
992
+ }
993
+ interface UserTokenVerifyInput {
994
+ token: string;
995
+ }
996
+
1012
997
  declare class UserTokenVerifyHandler {
1013
998
  private readonly jwtProvider;
1014
999
  constructor(jwtProvider: JwtProvider);
@@ -1016,6 +1001,19 @@ declare class UserTokenVerifyHandler {
1016
1001
  private decodeUserJwtToken;
1017
1002
  }
1018
1003
 
1004
+ interface UserVerifyRequestInput<TUserContext extends IUserContext> {
1005
+ email: string;
1006
+ callback: CallbackTemplate;
1007
+ context?: TUserContext;
1008
+ }
1009
+ interface UserVerifyResetRequestResult {
1010
+ success: boolean;
1011
+ }
1012
+ type CallbackTemplate = {
1013
+ urlTemplate: string;
1014
+ tokenPlaceholder: string;
1015
+ };
1016
+
1019
1017
  declare class UserVerifyRequestHandler {
1020
1018
  private readonly services;
1021
1019
  private readonly emailService;
@@ -1045,13 +1043,7 @@ declare class AuthenticationService implements IAuthenticationService {
1045
1043
  userPasswordChange(input: UserPasswordChangeInput): Promise<void>;
1046
1044
  userPasswordResetFinalize(input: UserPasswordResetCompleteInput): Promise<void>;
1047
1045
  userPasswordResetRequest<TUserContext extends IUserContext>(input: UserPasswordResetRequestInput<TUserContext>): Promise<UserPasswordResetRequestResult>;
1048
- userRegister<TUserRegistrationInfo, TUserContext extends IUserContext>(input: UserRegistrationInput<TUserRegistrationInfo, TUserContext>): Promise<{
1049
- success: boolean;
1050
- error: UserRegistrationError;
1051
- } | {
1052
- success: boolean;
1053
- error?: undefined;
1054
- }>;
1046
+ userRegister<TUserRegistrationInfo, TUserContext extends IUserContext>(input: UserRegistrationInput<TUserRegistrationInfo, TUserContext>): Promise<UserRegistrationResult>;
1055
1047
  userVerifyRequest<TUserContext extends IUserContext>(input: UserVerifyRequestInput<TUserContext>): Promise<UserVerifyResetRequestResult>;
1056
1048
  userVerifyComplete(input: UserVerifyCompleteInput): Promise<void>;
1057
1049
  userTokenVerify<TUserContext extends IUserContext>(input: UserTokenVerifyInput): Promise<UserTokenVerifyResult<TUserContext>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@punks/backend-entity-manager",
3
- "version": "0.0.32",
3
+ "version": "0.0.33",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",