eservices-core 1.0.345 → 1.0.346

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.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * eservices-core v1.0.345
2
+ * eservices-core v1.0.346
3
3
  * (c) 2022 ESERVICES
4
4
  */
5
5
  'use strict';
@@ -4703,6 +4703,9 @@ class authService {
4703
4703
  Object.values(data.errors).map(a => a[0]) : null;
4704
4704
  throw CoreError.AuthServiceError(data.title, details);
4705
4705
  }
4706
+ /**
4707
+ * @deprecated
4708
+ * */
4706
4709
  static login(values) {
4707
4710
  return Request(configuration.identityServerURL + "/api/Authenticate/Login", {
4708
4711
  method: "POST",
@@ -4764,7 +4767,51 @@ class authService {
4764
4767
  .catch(authService.parseError)
4765
4768
  .then(authService.parseProcessAnswer);
4766
4769
  }
4767
- }
4770
+ static startLoginProcess(values) {
4771
+ return authService.requestStepLoginProcess('StartLogin', values);
4772
+ }
4773
+ static loginWithPassword(values) {
4774
+ return authService.requestStepLoginProcess('LoginWithPassword', values);
4775
+ }
4776
+ static loginWithOtpCode(values) {
4777
+ return authService.requestStepLoginProcess('LoginWithOtpCode', values);
4778
+ }
4779
+ /**
4780
+ * @description Method for step-to-step login process
4781
+ * @return {ILoginAnswer} answer
4782
+ * */
4783
+ static requestStepLoginProcess(name, values) {
4784
+ return Request(`${configuration.identityServerURL}/api/Authenticate/${name}`, {
4785
+ method: 'POST',
4786
+ headers: {
4787
+ 'Content-Type': 'application/json',
4788
+ },
4789
+ credentials: 'include',
4790
+ body: JSON.stringify(values)
4791
+ })
4792
+ .catch(authService.parseError)
4793
+ .then(authService.parseLoginProcessAnswer);
4794
+ }
4795
+ static parseLoginProcessAnswer(answer) {
4796
+ if (answer.statusCode >= 4)
4797
+ throw CoreError.UndefinedError(answer.statusName);
4798
+ return answer;
4799
+ }
4800
+ }
4801
+ var LoginStatus;
4802
+ (function (LoginStatus) {
4803
+ LoginStatus[LoginStatus["Created"] = 0] = "Created";
4804
+ LoginStatus[LoginStatus["PasswordRequired"] = 1] = "PasswordRequired";
4805
+ LoginStatus[LoginStatus["OtpCodeRequrid"] = 2] = "OtpCodeRequrid";
4806
+ LoginStatus[LoginStatus["Authenticated"] = 3] = "Authenticated";
4807
+ LoginStatus[LoginStatus["UserNotFound"] = 4] = "UserNotFound";
4808
+ LoginStatus[LoginStatus["PasswordIncorrect"] = 5] = "PasswordIncorrect";
4809
+ LoginStatus[LoginStatus["OtpCodeIncorrect"] = 6] = "OtpCodeIncorrect";
4810
+ LoginStatus[LoginStatus["ApplicationNotSupported"] = 7] = "ApplicationNotSupported";
4811
+ LoginStatus[LoginStatus["OtpCodeExpired"] = 8] = "OtpCodeExpired";
4812
+ LoginStatus[LoginStatus["TokenIncorrect"] = 9] = "TokenIncorrect";
4813
+ LoginStatus[LoginStatus["Unauthorized"] = 10] = "Unauthorized";
4814
+ })(LoginStatus || (LoginStatus = {}));
4768
4815
 
4769
4816
  class ActionService {
4770
4817
  static url() {
@@ -14,6 +14,9 @@ interface ResponseInterface {
14
14
  }
15
15
  export default class authService {
16
16
  static parseError(data: ResponseInterface): void;
17
+ /**
18
+ * @deprecated
19
+ * */
17
20
  static login(values: LoginValues): Promise<any>;
18
21
  /**
19
22
  * @deprecated
@@ -29,6 +32,36 @@ export default class authService {
29
32
  * steps.
30
33
  * */
31
34
  static requestStepRegistrationProcess(name: string, values: any): Promise<IRegistrationAnswer>;
35
+ static startLoginProcess(values: any): Promise<ILoginAnswer>;
36
+ static loginWithPassword(values: any): Promise<ILoginAnswer>;
37
+ static loginWithOtpCode(values: any): Promise<ILoginAnswer>;
38
+ /**
39
+ * @description Method for step-to-step login process
40
+ * @return {ILoginAnswer} answer
41
+ * */
42
+ static requestStepLoginProcess(name: string, values: any): Promise<ILoginAnswer>;
43
+ static parseLoginProcessAnswer(answer: ILoginAnswer): ILoginAnswer;
44
+ }
45
+ interface ILoginAnswer {
46
+ maskedPhoneNumber: string;
47
+ otpPrefix: string;
48
+ token: string;
49
+ statusName: keyof LoginStatus;
50
+ statusCode: number;
51
+ username: string;
52
+ }
53
+ declare enum LoginStatus {
54
+ Created = 0,
55
+ PasswordRequired = 1,
56
+ OtpCodeRequrid = 2,
57
+ Authenticated = 3,
58
+ UserNotFound = 4,
59
+ PasswordIncorrect = 5,
60
+ OtpCodeIncorrect = 6,
61
+ ApplicationNotSupported = 7,
62
+ OtpCodeExpired = 8,
63
+ TokenIncorrect = 9,
64
+ Unauthorized = 10
32
65
  }
33
66
  interface IRegistrationAnswer {
34
67
  appName: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eservices-core",
3
- "version": "1.0.345",
3
+ "version": "1.0.346",
4
4
  "description": "----",
5
5
  "author": "",
6
6
  "scripts": {