cidaas-javascript-sdk 4.2.4 → 4.3.0

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +18 -3
  2. package/README.md +3 -0
  3. package/dist/authentication/{index.d.ts → Authentication.d.ts} +2 -2
  4. package/dist/authentication/{index.js → Authentication.js} +2 -9
  5. package/dist/common/Common.model.d.ts +37 -0
  6. package/dist/common/Common.model.js +26 -0
  7. package/dist/{web-auth → common}/Helper.d.ts +6 -6
  8. package/dist/{web-auth → common}/Helper.js +10 -10
  9. package/dist/common/JwtHelper.d.ts +8 -0
  10. package/dist/{web-auth → common}/JwtHelper.js +8 -8
  11. package/dist/common/User.model.d.ts +134 -0
  12. package/dist/common/User.model.js +2 -0
  13. package/dist/consent-service/ConsentService.d.ts +96 -0
  14. package/dist/consent-service/ConsentService.js +127 -0
  15. package/dist/consent-service/ConsentService.model.d.ts +102 -0
  16. package/dist/consent-service/ConsentService.model.js +2 -0
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/login-service/LoginService.d.ts +143 -0
  20. package/dist/login-service/LoginService.js +247 -0
  21. package/dist/login-service/LoginService.model.d.ts +138 -0
  22. package/dist/login-service/LoginService.model.js +13 -0
  23. package/dist/token-service/TokenService.d.ts +139 -0
  24. package/dist/token-service/TokenService.js +242 -0
  25. package/dist/token-service/TokenService.model.d.ts +149 -0
  26. package/dist/token-service/TokenService.model.js +43 -0
  27. package/dist/user-service/UserService.d.ts +317 -0
  28. package/dist/user-service/UserService.js +451 -0
  29. package/dist/user-service/UserService.model.d.ts +142 -0
  30. package/dist/user-service/UserService.model.js +10 -0
  31. package/dist/verification-service/VerificationService.d.ts +218 -0
  32. package/dist/verification-service/VerificationService.js +288 -0
  33. package/dist/verification-service/VerificationService.model.d.ts +158 -0
  34. package/dist/verification-service/VerificationService.model.js +2 -0
  35. package/dist/web-auth/WebAuth.d.ts +110 -177
  36. package/dist/web-auth/WebAuth.js +120 -150
  37. package/dist/web-auth/webauth.model.d.ts +50 -0
  38. package/dist/web-auth/webauth.model.js +2 -0
  39. package/package.json +1 -1
  40. package/dist/web-auth/ConsentService.d.ts +0 -123
  41. package/dist/web-auth/ConsentService.js +0 -136
  42. package/dist/web-auth/Entities.d.ts +0 -516
  43. package/dist/web-auth/Entities.js +0 -69
  44. package/dist/web-auth/JwtHelper.d.ts +0 -7
  45. package/dist/web-auth/LoginService.d.ts +0 -165
  46. package/dist/web-auth/LoginService.js +0 -246
  47. package/dist/web-auth/TokenService.d.ts +0 -143
  48. package/dist/web-auth/TokenService.js +0 -249
  49. package/dist/web-auth/UserService.d.ts +0 -345
  50. package/dist/web-auth/UserService.js +0 -471
  51. package/dist/web-auth/VerificationService.d.ts +0 -224
  52. package/dist/web-auth/VerificationService.js +0 -278
  53. /package/dist/authentication/{authentication.model.d.ts → Authentication.model.d.ts} +0 -0
  54. /package/dist/authentication/{authentication.model.js → Authentication.model.js} +0 -0
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.revokeClaimConsent = exports.acceptClaimConsent = exports.acceptScopeConsent = exports.getConsentVersionDetails = exports.acceptConsent = exports.getConsentDetails = void 0;
4
+ const Helper_1 = require("../common/Helper");
5
+ /**
6
+ * To get consent details , call **getConsentDetails()**.
7
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/858fbeb51c62b-find-consent-info for more details.
8
+ * @example
9
+ * ```js
10
+ * this.cidaas.getConsentDetails({
11
+ * consent_id: 'consent id',
12
+ * consent_version_id: 'consent version id',
13
+ * sub: 'masked sub'
14
+ * })
15
+ * .then(function (response) {
16
+ * // type your code here
17
+ * })
18
+ * .catch(function (ex) {
19
+ * // your failure code here
20
+ * });
21
+ * ```
22
+ */
23
+ function getConsentDetails(options) {
24
+ const _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/v2/consent/usage/public/info";
25
+ return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST");
26
+ }
27
+ exports.getConsentDetails = getConsentDetails;
28
+ /**
29
+ * To accept consent, call **acceptConsent()**.
30
+ * @example
31
+ * ```js
32
+ * this.cidaas.acceptConsent({
33
+ * client_id: 'your client id',
34
+ * consent_id: 'consent id',
35
+ * consent_version: 'consent version id',
36
+ * sub: 'masked sub'
37
+ * }).then((response) => {
38
+ * // the response will give you details of accepted consent.
39
+ * }).catch((err) => {
40
+ * // your failure code here
41
+ * });
42
+ * ```
43
+ */
44
+ function acceptConsent(options) {
45
+ const _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/v2/consent/usage/accept";
46
+ return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST");
47
+ }
48
+ exports.acceptConsent = acceptConsent;
49
+ /**
50
+ * To get version details of consent, call **getConsentVersionDetails()**.
51
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/7e24ac2113315-get-consent-version-details for more details.
52
+ * @example
53
+ * ```js
54
+ * this.cidaas.getConsentVersionDetails({
55
+ * consentid: 'your consent id',
56
+ * locale: 'browser accept language or custom language',
57
+ * access_token: 'your access token',
58
+ * }).then((response) => {
59
+ * // type your code here
60
+ * }).catch((err) => {
61
+ * // your failure code here
62
+ * });
63
+ * ```
64
+ */
65
+ function getConsentVersionDetails(options) {
66
+ let _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/v2/consent/versions/details/" + options.consentid;
67
+ if (options.locale) {
68
+ _serviceURL += "?locale=" + options.locale;
69
+ }
70
+ // BREAKING TODO: remove access token as it is not needed to get consent version details
71
+ return Helper_1.Helper.createHttpPromise(undefined, _serviceURL, false, "GET", options.access_token);
72
+ }
73
+ exports.getConsentVersionDetails = getConsentVersionDetails;
74
+ /**
75
+ * To accept scope consent, call **acceptScopeConsent()**.
76
+ * @example
77
+ * ```js
78
+ * this.cidaas.acceptScopeConsent({
79
+ * client_id: 'your client id',
80
+ * sub: 'masked sub',
81
+ * scopes: [your scope consents]
82
+ * });
83
+ * ```
84
+ */
85
+ function acceptScopeConsent(options) {
86
+ const _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/consent/scope/accept";
87
+ return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST");
88
+ }
89
+ exports.acceptScopeConsent = acceptScopeConsent;
90
+ /**
91
+ * To accept claim consent, call **acceptClaimConsent()**.
92
+ * @example
93
+ * ```js
94
+ * this.cidaas.acceptClaimConsent({
95
+ * client_id: 'your client id',
96
+ * sub: 'masked sub',
97
+ * accepted_claims: [your claim consents]
98
+ * });
99
+ * ```
100
+ */
101
+ function acceptClaimConsent(options) {
102
+ const _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/consent/claim/accept";
103
+ return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST");
104
+ }
105
+ exports.acceptClaimConsent = acceptClaimConsent;
106
+ /**
107
+ * To revoke claim consent, call **revokeClaimConsent()**.
108
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/9ae62e98842fe-revoke-user-consent-claim for more details.
109
+ * @example
110
+ * ```js
111
+ * this.cidaas.revokeClaimConsent({
112
+ * access_token: 'your access token',
113
+ * client_id: 'your client id',
114
+ * sub: 'masked sub'
115
+ * revoked_claims: [your claim consents]
116
+ * }).then((response) => {
117
+ * // the response will give you revoked claim consent.
118
+ * }).catch((err) => {
119
+ * // your failure code here
120
+ * });
121
+ * ```
122
+ */
123
+ function revokeClaimConsent(options) {
124
+ const _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/consent/claim/revoke";
125
+ return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST", options.access_token);
126
+ }
127
+ exports.revokeClaimConsent = revokeClaimConsent;
@@ -0,0 +1,102 @@
1
+ export interface GetConsentDetailsRequest {
2
+ /** Unique identifier for consent to be accepted */
3
+ consent_id: string;
4
+ /** Unique identifier for version of the consent to be accepted */
5
+ consent_version_id: string;
6
+ /**
7
+ * Masked sub (id of user), who will accept the consent.
8
+ * Either sub or q have to be provided, depends on what is given from the query parameter.
9
+ * */
10
+ sub?: string;
11
+ /**
12
+ * Masked sub (id of user), who will accept the consent.
13
+ * Either sub or q have to be provided, depends on what is given from the query parameter.
14
+ * */
15
+ q?: string;
16
+ }
17
+ export interface AcceptConsentRequest {
18
+ /** Unique identifier of client app, can be found in app setting under admin ui */
19
+ client_id: string;
20
+ /** Unique identifier for consent to be accepted */
21
+ consent_id: string;
22
+ /** Unique identifier for version of the consent to be accepted */
23
+ consent_version_id: string;
24
+ /**
25
+ * Masked sub (id of user), who will accept the consent.
26
+ * Either sub or q have to be provided, depends on what is given from the query parameter.
27
+ * */
28
+ sub?: string;
29
+ /**
30
+ * Masked sub (id of user), who will accept the consent.
31
+ * Either sub or q have to be provided, depends on what is given from the query parameter.
32
+ * */
33
+ q?: string;
34
+ /** Scopes are list of functional definition. Required to be passed on scope consent (Ex: email, profile, openid) */
35
+ scopes?: string[];
36
+ /** Consent url for user to accept terms or privacy policy */
37
+ url?: string;
38
+ /** Unique name of field. Required to be passed when consent is field consent */
39
+ field_key?: string;
40
+ /** List of field_keys which has been accepted */
41
+ accepted_fields?: string[];
42
+ /** Sub of user, which will accept the consent */
43
+ accepted_by?: string;
44
+ /** True if consent is optional and not accepted in consent accept page */
45
+ skipped?: boolean;
46
+ /** Describe how the consent acceptance is triggered. E.g. "register", "login" */
47
+ action_type?: string;
48
+ /** Unique identifier for action, which trigger consent acceptance */
49
+ action_id?: string;
50
+ /** True, if consent has been revoked */
51
+ revoked?: boolean;
52
+ }
53
+ export interface GetConsentVersionDetailsRequest {
54
+ /** Unique identifier for requested consent */
55
+ consentid: string;
56
+ /** Response language, which is configured in cidaas admin ui */
57
+ locale?: string;
58
+ /** DEPRECATED: Access Token is not needed for Getting ConsentVersionDetailsRequest in the current cidaas service. It will be removed in the next Major release */
59
+ access_token?: string;
60
+ }
61
+ export interface AcceptScopeConsentRequest {
62
+ /** Unique identifier of client app, can be found in app setting under admin ui */
63
+ client_id: string;
64
+ /**
65
+ * Masked sub (id of user), who will accept the consent.
66
+ * Either sub or q have to be provided, depends on what is given from the query parameter.
67
+ * */
68
+ sub?: string;
69
+ /**
70
+ * Masked sub (id of user), who will accept the consent.
71
+ * Either sub or q have to be provided, depends on what is given from the query parameter.
72
+ * */
73
+ q?: string;
74
+ /** List of scopes, which is included in the scope consent to be accepted */
75
+ scopes: string[];
76
+ }
77
+ export interface AcceptClaimConsentRequest {
78
+ /** Unique identifier of client app, can be found in app setting under admin ui */
79
+ client_id: string;
80
+ /**
81
+ * Masked sub (id of user), who will accept the consent.
82
+ * Either sub or q have to be provided, depends on what is given from the query parameter.
83
+ * */
84
+ sub?: string;
85
+ /**
86
+ * Masked sub (id of user), who will accept the consent.
87
+ * Either sub or q have to be provided, depends on what is given from the query parameter.
88
+ * */
89
+ q?: string;
90
+ /** List of claims, which is included in the claim consent to be accepted */
91
+ accepted_claims: string[];
92
+ }
93
+ export interface RevokeClaimConsentRequest {
94
+ /** Access token needed to authorized api call */
95
+ access_token: string;
96
+ /** Unique identifier of client app, can be found in app setting under admin ui */
97
+ client_id: string;
98
+ /** sub (id of user), who will revoke the consent */
99
+ sub: string;
100
+ /** List of claims, which is included in the claim consent to be revoked */
101
+ revoked_claims: string[];
102
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { WebAuth } from "./web-auth/WebAuth";
2
- export * from './authentication';
2
+ export * from './authentication/Authentication';
3
3
  export { WebAuth };
package/dist/index.js CHANGED
@@ -17,4 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.WebAuth = void 0;
18
18
  const WebAuth_1 = require("./web-auth/WebAuth");
19
19
  Object.defineProperty(exports, "WebAuth", { enumerable: true, get: function () { return WebAuth_1.WebAuth; } });
20
- __exportStar(require("./authentication"), exports);
20
+ __exportStar(require("./authentication/Authentication"), exports);
@@ -0,0 +1,143 @@
1
+ import { LoginPrecheckRequest } from "../common/Common.model";
2
+ import { FirstTimeChangePasswordRequest, LoginAfterRegisterRequest, LoginWithCredentialsRequest, MfaContinueRequest, PasswordlessLoginRequest, ProgressiveRegistrationHeader, SocialProviderPathParameter, SocialProviderQueryParameter } from "./LoginService.model";
3
+ import { CidaasUser } from "../common/User.model";
4
+ /**
5
+ * To login with your credentials, call **loginWithCredentials()**. After successful login, this will redirect you to the redirect_url that you mentioned earlier while initialising the sdk.
6
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/5gphdk6vapp56-classic-login#call-login-api for more details.
7
+ * @example
8
+ * ```js
9
+ * cidaas.loginWithCredentials({
10
+ * username: 'xxxx@gmail.com',
11
+ * username_type: 'email',
12
+ * password: '123456',
13
+ * requestId: 'your requestId',
14
+ * });
15
+ * ```
16
+ */
17
+ export declare function loginWithCredentials(options: LoginWithCredentialsRequest): void;
18
+ /**
19
+ * To login with social providers, call **loginWithSocial()**. This will redirect you to the facebook login page.
20
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/9mi5uqxhqlsm5-social-login#call-social-login-api for more details
21
+ * @example
22
+ * ```js
23
+ * cidaas.loginWithSocial({
24
+ * provider: 'facebook',
25
+ * requestId: 'your requestId',
26
+ * });
27
+ * ```
28
+ */
29
+ export declare function loginWithSocial(options: SocialProviderPathParameter, queryParams?: SocialProviderQueryParameter): void;
30
+ /**
31
+ * To register with social providers, call **registerWithSocial()**. This will redirect you to the facebook login page.
32
+ * @example
33
+ * Note: giving the queryParams is not required.
34
+ * ```js
35
+ * queryParams = {
36
+ * dc: 'dc',
37
+ * device_fp: 'device_fp'
38
+ * }
39
+ * cidaas.registerWithSocial({
40
+ * provider: 'facebook',
41
+ * requestId: 'your requestId',
42
+ * }, queryParams);
43
+ * ```
44
+ */
45
+ export declare function registerWithSocial(options: SocialProviderPathParameter, queryParams?: SocialProviderQueryParameter): void;
46
+ /**
47
+ * To authenticate without using password, call **passwordlessLogin()**.
48
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/k1lwsraxk0rjc-login-passwordless-request for more details.
49
+ * @example
50
+ * ```js
51
+ * cidaas.passwordlessLogin({
52
+ * requestId: 'your requestId',
53
+ * sub: 'your user sub',
54
+ * statusId: 'status id from authenticateMFA()'
55
+ * verificationType: 'your verificationType. e.g. VerificationType.EMAIL'
56
+ * });
57
+ * ```
58
+ */
59
+ export declare function passwordlessLogin(options: PasswordlessLoginRequest): void;
60
+ /**
61
+ * To continue after Consent acceptance, call **consentContinue()**.
62
+ * @example
63
+ * ```js
64
+ * cidaas.consentContinue({
65
+ * track_id: 'your track id'
66
+ * });
67
+ * ```
68
+ */
69
+ export declare function consentContinue(options: LoginPrecheckRequest): void;
70
+ /**
71
+ * To continue after MFA completion, call **mfaContinue()**.
72
+ * options: PhysicalVerificationLoginRequest is not needed anymore. It is now DEPRECATED and will be removed in the next major release
73
+ *
74
+ * @example
75
+ * ```js
76
+ * cidaas.mfaContinue({
77
+ * track_id: 'your track id'
78
+ * });
79
+ * ```
80
+ */
81
+ export declare function mfaContinue(options: MfaContinueRequest): void;
82
+ /**
83
+ * to handle changing password by first login attempt after registration, call **firstTimeChangePassword()**.
84
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/fd8f478d96f58-continue-authentication-flow-after-prechecks for more details.
85
+ * @example
86
+ * ```js
87
+ * cidaas.firstTimeChangePassword({
88
+ * sub: 'your sub',
89
+ * old_password: 'your old password',
90
+ * new_password: 'your new password',
91
+ * confirm_password: 'your new password',
92
+ * loginSettingsId: 'loginSettingsId'
93
+ * });
94
+ * ```
95
+ */
96
+ export declare function firstTimeChangePassword(options: FirstTimeChangePasswordRequest): void;
97
+ /**
98
+ * For progressive registration, call **progressiveRegistration()**. While logging in If the API returns 417 with the error message MissingRequiredFields, call the **getMissingFields** to get the list of missing fileds and proceed with progressive registration. In the sample request only the required fields are added, however you must provide the missing fields along with the required fields.
99
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/l7sknp2pytryr-progressive-registration for more details.
100
+ * @example
101
+ * ```js
102
+ * const options = {
103
+ * sub: 'your sub',
104
+ * }
105
+ * const headers = {
106
+ * trackId: 'the track id received while logging in',
107
+ * requestId: 'request id of the session',
108
+ * acceptlanguage: 'your locale/browser locale (OPTIONAL)',
109
+ * }
110
+ * cidaas.progressiveRegistration(options, headers)
111
+ * .then(function(response) {
112
+ * // type your code here
113
+ * })
114
+ * .catch(function (ex) {
115
+ * // your failure code here
116
+ * });
117
+ * ```
118
+ */
119
+ export declare function progressiveRegistration(options: CidaasUser, headers: ProgressiveRegistrationHeader): Promise<any>;
120
+ /**
121
+ * To automatically do user login after successful registration, call **loginAfterRegister()**. Make sure to turn on "auto login after register" switch on the admin ui to activate loginAfterRegister flow.
122
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/qwwamc2f378wi-auto-login-after-register for more details.
123
+ * @example
124
+ * ```js
125
+ * cidaas.loginAfterRegister({
126
+ * device_id: 'your device id',
127
+ * dc: 'device capacity'
128
+ * rememberMe: false,
129
+ * trackId: 'your track id',
130
+ * device_fp: 'device fingerprint'
131
+ * });
132
+ * ```
133
+ */
134
+ export declare function loginAfterRegister(options: LoginAfterRegisterRequest): void;
135
+ /**
136
+ * To do guest login after activating the feature from admin ui, call **actionGuestLogin()**
137
+ * Please refer to https://docs.cidaas.com/docs/cidaas-iam/95fd8492a64fe-guest-login for more details
138
+ * @example
139
+ * ```js
140
+ * cidaas.actionGuestLogin('your request id');
141
+ * ```
142
+ */
143
+ export declare function actionGuestLogin(requestId: string): void;
@@ -0,0 +1,247 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.actionGuestLogin = exports.loginAfterRegister = exports.progressiveRegistration = exports.firstTimeChangePassword = exports.mfaContinue = exports.consentContinue = exports.passwordlessLogin = exports.registerWithSocial = exports.loginWithSocial = exports.loginWithCredentials = void 0;
4
+ const Helper_1 = require("../common/Helper");
5
+ /**
6
+ * To login with your credentials, call **loginWithCredentials()**. After successful login, this will redirect you to the redirect_url that you mentioned earlier while initialising the sdk.
7
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/5gphdk6vapp56-classic-login#call-login-api for more details.
8
+ * @example
9
+ * ```js
10
+ * cidaas.loginWithCredentials({
11
+ * username: 'xxxx@gmail.com',
12
+ * username_type: 'email',
13
+ * password: '123456',
14
+ * requestId: 'your requestId',
15
+ * });
16
+ * ```
17
+ */
18
+ function loginWithCredentials(options) {
19
+ try {
20
+ const url = window.webAuthSettings.authority + "/login-srv/login";
21
+ const form = Helper_1.Helper.createForm(url, options);
22
+ document.body.appendChild(form);
23
+ form.submit();
24
+ }
25
+ catch (ex) {
26
+ throw new Helper_1.CustomException(String(ex), 417);
27
+ }
28
+ }
29
+ exports.loginWithCredentials = loginWithCredentials;
30
+ /**
31
+ * To login with social providers, call **loginWithSocial()**. This will redirect you to the facebook login page.
32
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/9mi5uqxhqlsm5-social-login#call-social-login-api for more details
33
+ * @example
34
+ * ```js
35
+ * cidaas.loginWithSocial({
36
+ * provider: 'facebook',
37
+ * requestId: 'your requestId',
38
+ * });
39
+ * ```
40
+ */
41
+ function loginWithSocial(options, queryParams) {
42
+ try {
43
+ let _serviceURL = window.webAuthSettings.authority + "/login-srv/social/login/" + options.provider.toLowerCase() + "/" + options.requestId;
44
+ if (queryParams && queryParams.dc && queryParams.device_fp) {
45
+ _serviceURL = _serviceURL + "?dc=" + queryParams.dc + "&device_fp=" + queryParams.device_fp;
46
+ }
47
+ window.location.href = _serviceURL;
48
+ }
49
+ catch (ex) {
50
+ console.log(ex);
51
+ }
52
+ }
53
+ exports.loginWithSocial = loginWithSocial;
54
+ /**
55
+ * To register with social providers, call **registerWithSocial()**. This will redirect you to the facebook login page.
56
+ * @example
57
+ * Note: giving the queryParams is not required.
58
+ * ```js
59
+ * queryParams = {
60
+ * dc: 'dc',
61
+ * device_fp: 'device_fp'
62
+ * }
63
+ * cidaas.registerWithSocial({
64
+ * provider: 'facebook',
65
+ * requestId: 'your requestId',
66
+ * }, queryParams);
67
+ * ```
68
+ */
69
+ function registerWithSocial(options, queryParams) {
70
+ try {
71
+ let _serviceURL = window.webAuthSettings.authority + "/login-srv/social/register/" + options.provider.toLowerCase() + "/" + options.requestId;
72
+ if (queryParams && queryParams.dc && queryParams.device_fp) {
73
+ _serviceURL = _serviceURL + "?dc=" + queryParams.dc + "&device_fp=" + queryParams.device_fp;
74
+ }
75
+ window.location.href = _serviceURL;
76
+ }
77
+ catch (ex) {
78
+ console.log(ex);
79
+ }
80
+ }
81
+ exports.registerWithSocial = registerWithSocial;
82
+ /**
83
+ * To authenticate without using password, call **passwordlessLogin()**.
84
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/k1lwsraxk0rjc-login-passwordless-request for more details.
85
+ * @example
86
+ * ```js
87
+ * cidaas.passwordlessLogin({
88
+ * requestId: 'your requestId',
89
+ * sub: 'your user sub',
90
+ * statusId: 'status id from authenticateMFA()'
91
+ * verificationType: 'your verificationType. e.g. VerificationType.EMAIL'
92
+ * });
93
+ * ```
94
+ */
95
+ function passwordlessLogin(options) {
96
+ try {
97
+ const url = window.webAuthSettings.authority + "/login-srv/verification/login";
98
+ const form = Helper_1.Helper.createForm(url, options);
99
+ document.body.appendChild(form);
100
+ form.submit();
101
+ }
102
+ catch (ex) {
103
+ throw new Helper_1.CustomException(String(ex), 417);
104
+ }
105
+ }
106
+ exports.passwordlessLogin = passwordlessLogin;
107
+ /**
108
+ * To continue after Consent acceptance, call **consentContinue()**.
109
+ * @example
110
+ * ```js
111
+ * cidaas.consentContinue({
112
+ * track_id: 'your track id'
113
+ * });
114
+ * ```
115
+ */
116
+ function consentContinue(options) {
117
+ try {
118
+ const url = window.webAuthSettings.authority + "/login-srv/precheck/continue/" + options.track_id;
119
+ const form = Helper_1.Helper.createForm(url, options);
120
+ document.body.appendChild(form);
121
+ form.submit();
122
+ }
123
+ catch (ex) {
124
+ throw new Helper_1.CustomException(String(ex), 417);
125
+ }
126
+ }
127
+ exports.consentContinue = consentContinue;
128
+ /**
129
+ * To continue after MFA completion, call **mfaContinue()**.
130
+ * options: PhysicalVerificationLoginRequest is not needed anymore. It is now DEPRECATED and will be removed in the next major release
131
+ *
132
+ * @example
133
+ * ```js
134
+ * cidaas.mfaContinue({
135
+ * track_id: 'your track id'
136
+ * });
137
+ * ```
138
+ */
139
+ function mfaContinue(options) {
140
+ try {
141
+ const url = window.webAuthSettings.authority + "/login-srv/precheck/continue/" + options.track_id;
142
+ const form = Helper_1.Helper.createForm(url, options);
143
+ document.body.appendChild(form);
144
+ form.submit();
145
+ }
146
+ catch (ex) {
147
+ throw new Helper_1.CustomException(String(ex), 417);
148
+ }
149
+ }
150
+ exports.mfaContinue = mfaContinue;
151
+ /**
152
+ * to handle changing password by first login attempt after registration, call **firstTimeChangePassword()**.
153
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/fd8f478d96f58-continue-authentication-flow-after-prechecks for more details.
154
+ * @example
155
+ * ```js
156
+ * cidaas.firstTimeChangePassword({
157
+ * sub: 'your sub',
158
+ * old_password: 'your old password',
159
+ * new_password: 'your new password',
160
+ * confirm_password: 'your new password',
161
+ * loginSettingsId: 'loginSettingsId'
162
+ * });
163
+ * ```
164
+ */
165
+ // BREAKING TODO: separate path parameter trackId (from LoginPrecheckRequest) from payload FirstTimeChangePasswordRequest in model
166
+ function firstTimeChangePassword(options) {
167
+ try {
168
+ // BREAKING TODO: use trackId instead of loginSettingsId for precheck
169
+ const url = window.webAuthSettings.authority + "/login-srv/precheck/continue/" + options.loginSettingsId;
170
+ const form = Helper_1.Helper.createForm(url, options);
171
+ document.body.appendChild(form);
172
+ form.submit();
173
+ }
174
+ catch (ex) {
175
+ throw new Helper_1.CustomException(String(ex), 417);
176
+ }
177
+ }
178
+ exports.firstTimeChangePassword = firstTimeChangePassword;
179
+ /**
180
+ * For progressive registration, call **progressiveRegistration()**. While logging in If the API returns 417 with the error message MissingRequiredFields, call the **getMissingFields** to get the list of missing fileds and proceed with progressive registration. In the sample request only the required fields are added, however you must provide the missing fields along with the required fields.
181
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/l7sknp2pytryr-progressive-registration for more details.
182
+ * @example
183
+ * ```js
184
+ * const options = {
185
+ * sub: 'your sub',
186
+ * }
187
+ * const headers = {
188
+ * trackId: 'the track id received while logging in',
189
+ * requestId: 'request id of the session',
190
+ * acceptlanguage: 'your locale/browser locale (OPTIONAL)',
191
+ * }
192
+ * cidaas.progressiveRegistration(options, headers)
193
+ * .then(function(response) {
194
+ * // type your code here
195
+ * })
196
+ * .catch(function (ex) {
197
+ * // your failure code here
198
+ * });
199
+ * ```
200
+ */
201
+ function progressiveRegistration(options, headers) {
202
+ const serviceURL = window.webAuthSettings.authority + "/login-srv/progressive/update/user";
203
+ return Helper_1.Helper.createHttpPromise(options, serviceURL, undefined, "POST", undefined, headers);
204
+ }
205
+ exports.progressiveRegistration = progressiveRegistration;
206
+ /**
207
+ * To automatically do user login after successful registration, call **loginAfterRegister()**. Make sure to turn on "auto login after register" switch on the admin ui to activate loginAfterRegister flow.
208
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/qwwamc2f378wi-auto-login-after-register for more details.
209
+ * @example
210
+ * ```js
211
+ * cidaas.loginAfterRegister({
212
+ * device_id: 'your device id',
213
+ * dc: 'device capacity'
214
+ * rememberMe: false,
215
+ * trackId: 'your track id',
216
+ * device_fp: 'device fingerprint'
217
+ * });
218
+ * ```
219
+ */
220
+ function loginAfterRegister(options) {
221
+ try {
222
+ const url = window.webAuthSettings.authority + "/login-srv/login/handle/afterregister/" + options.trackId;
223
+ const form = Helper_1.Helper.createForm(url, options);
224
+ document.body.appendChild(form);
225
+ form.submit();
226
+ }
227
+ catch (ex) {
228
+ throw new Helper_1.CustomException(String(ex), 417);
229
+ }
230
+ }
231
+ exports.loginAfterRegister = loginAfterRegister;
232
+ /**
233
+ * To do guest login after activating the feature from admin ui, call **actionGuestLogin()**
234
+ * Please refer to https://docs.cidaas.com/docs/cidaas-iam/95fd8492a64fe-guest-login for more details
235
+ * @example
236
+ * ```js
237
+ * cidaas.actionGuestLogin('your request id');
238
+ * ```
239
+ */
240
+ function actionGuestLogin(requestId) {
241
+ const url = window.webAuthSettings.authority + '/login-srv/login/guest/' + requestId;
242
+ const loginFormElement = document.getElementsByName('guestLoginForm')[0];
243
+ loginFormElement.action = url;
244
+ loginFormElement.method = 'post';
245
+ loginFormElement.submit();
246
+ }
247
+ exports.actionGuestLogin = actionGuestLogin;