@frontegg/rest-api 3.0.131 → 3.0.133

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/auth/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export declare function generateLoginResponse(loginResponse: ILoginResponse): Pr
9
9
  export declare function generateLoginResponseV2(loginResponse: ILoginResponse): Promise<ILoginResponseV2>;
10
10
  export declare function generateLoginResponseV3(loginResponse: ILoginResponse): Promise<ILoginResponseV3>;
11
11
  export declare function generateLoginResponseFromOAuthResponse(oauthResponse: IOAuthTokenResponse): Promise<ILoginResponse>;
12
+ export declare function generateLoginResponseFromOAuthResponseV2(oauthResponse: IOAuthTokenResponse): Promise<ILoginResponseV3>;
12
13
  /**
13
14
  * Check if requested email address has sso configuration
14
15
  * If true, this function will return the sso address to navigate to
@@ -42,6 +43,17 @@ export declare function oidcPostLogin(body: IOidcPostLogin): Promise<ILoginRespo
42
43
  * @throw exception if login failed
43
44
  */
44
45
  export declare function login(body: ILogin): Promise<ILoginResponse>;
46
+ /**
47
+ * login with username and password.
48
+ * if the user has two factor authentication
49
+ * the server will return mfaToken with mfaRequired: true,
50
+ * and then ``loginWithMfa`` should be called with the mfaToken and and generated code
51
+ * else, the server will accessToken and refreshToken.
52
+ * the refresh should be used to renew your access token by calling ``refreshToken``
53
+ *
54
+ * @throw exception if login failed
55
+ */
56
+ export declare function loginv2(body: ILogin): Promise<ILoginResponseV3>;
45
57
  /**
46
58
  * after login succeeded with mfaRequired token response, this function should be called
47
59
  * with the mfaToken and the generated code from your authenticator app.
@@ -49,6 +61,13 @@ export declare function login(body: ILogin): Promise<ILoginResponse>;
49
61
  * @throw exception if generated code or mfaToken are incorrect
50
62
  */
51
63
  export declare function loginWithMfa(body: ILoginWithMfa): Promise<ILoginResponse>;
64
+ /**
65
+ * after login succeeded with mfaRequired token response, this function should be called
66
+ * with the mfaToken and the generated code from your authenticator app.
67
+ *
68
+ * @throw exception if generated code or mfaToken are incorrect
69
+ */
70
+ export declare function loginWithMfaV2(body: ILoginWithMfa): Promise<ILoginResponseV3>;
52
71
  /**
53
72
  * activating account should be called after registering new user of deactivate account
54
73
  * ``activateAccount`` should contains userId and the token that has been sent to the user after activation requested.
@@ -56,6 +75,13 @@ export declare function loginWithMfa(body: ILoginWithMfa): Promise<ILoginRespons
56
75
  * @throws exception if activation failed
57
76
  */
58
77
  export declare function activateAccount(body: IActivateAccount): Promise<void>;
78
+ /**
79
+ * activating account should be called after registering new user of deactivate account
80
+ * ``activateAccount`` should contains userId and the token that has been sent to the user after activation requested.
81
+ *
82
+ * @throws exception if activation failed
83
+ */
84
+ export declare function activateAccountV2(body: IActivateAccount): Promise<ILoginResponseV3>;
59
85
  /**
60
86
  * get account activation configuration.
61
87
  */
@@ -239,6 +265,11 @@ export declare function preEnrollMFAAuthenticatorAppForLogin(body: IPreEnrollMFA
239
265
  * with the generated code in the Authenticator App
240
266
  */
241
267
  export declare function enrollMFAAuthenticatorAppForLogin(body: IEnrollMFAAuthenticatorApp): Promise<ILoginResponse>;
268
+ /**
269
+ * after pre enroll with authenticator app, enroll authenticator app function should be called
270
+ * with the generated code in the Authenticator App
271
+ */
272
+ export declare function enrollMFAAuthenticatorAppForLoginV2(body: IEnrollMFAAuthenticatorApp): Promise<ILoginResponseV3>;
242
273
  /**
243
274
  * after login succeeded with mfaRequired token response, this function should be called
244
275
  * with the selected authenticator app id, mfaToken and the generated code from your authenticator app.
@@ -254,6 +285,11 @@ export declare function preVerifyMFAEmailCode(body: IPreVerifyMFA): Promise<IPre
254
285
  * with the otcToken and the code that has been sent to the email
255
286
  */
256
287
  export declare function verifyMFAEmailCode(body: IVerifyMFAEmailCode): Promise<ILoginResponse>;
288
+ /**
289
+ * after pre verify with Email Code, verify Email Code function should be called
290
+ * with the otcToken and the code that has been sent to the email
291
+ */
292
+ export declare function verifyMFAEmailCodeV2(body: IVerifyMFAEmailCode): Promise<ILoginResponseV3>;
257
293
  /**
258
294
  * pre enroll Multi-Factor to use with SMS
259
295
  * the server returns otcToken that should be sent to the enroll function with the code that was sent to
@@ -265,6 +301,11 @@ export declare function preEnrollMFASMSForLogin(body: IPreEnrollMFASMS): Promise
265
301
  * with the otcToken and the code that has been sent to the phone number that was requested
266
302
  */
267
303
  export declare function enrollMFASMSForLogin(body: IEnrollMFASMS): Promise<ILoginResponse>;
304
+ /**
305
+ * after pre enroll with SMS, enroll SMS function should be called
306
+ * with the otcToken and the code that has been sent to the phone number that was requested
307
+ */
308
+ export declare function enrollMFASMSForLoginV2(body: IEnrollMFASMS): Promise<ILoginResponseV3>;
268
309
  /**
269
310
  * after login succeeded with mfaRequired token response, if the user asked to use SMS as MFA
270
311
  * this function should be called with the selected device id and mfaToken
@@ -275,6 +316,11 @@ export declare function preVerifyMFASMSForLogin(deviceId: string, body: IPreVeri
275
316
  * that has been sent to the selected device.
276
317
  */
277
318
  export declare function verifyMFASMSForLogin(deviceId: string, body: IVerifyMFASMS): Promise<ILoginResponse>;
319
+ /**
320
+ * after pre verify with SMS, this function should be called with otcToken, mfaToken and the code
321
+ * that has been sent to the selected device.
322
+ */
323
+ export declare function verifyMFASMSForLoginV2(deviceId: string, body: IVerifyMFASMS): Promise<ILoginResponseV3>;
278
324
  /**
279
325
  * pre enroll Multi-Factor to use with WebAuthn
280
326
  * the server returns attestation object
@@ -286,6 +332,11 @@ export declare function preEnrollMFAWebAuthnForLogin(body: IPreEnrollMFA): Promi
286
332
  * with the webauthnToken and the attestation object response
287
333
  */
288
334
  export declare function enrollMFAWebAuthnForLogin(body: IEnrollMFAWebAuthn): Promise<ILoginResponse>;
335
+ /**
336
+ * after pre enroll with WebAuthn, enroll WebAuthn function should be called
337
+ * with the webauthnToken and the attestation object response
338
+ */
339
+ export declare function enrollMFAWebAuthnForLoginV2(body: IEnrollMFAWebAuthn): Promise<ILoginResponseV3>;
289
340
  /**
290
341
  * after login succeeded with mfaRequired token response, if the user asked to use WebAuthn as MFA
291
342
  * this function should be called with the selected device id and mfaToken.
@@ -379,10 +430,17 @@ export declare function getSSOPublicConfiguration(): Promise<ISSOPublicConfigura
379
430
  */
380
431
  export declare function getSocialLoginProviders(): Promise<ISocialLoginProviderConfiguration[]>;
381
432
  /**
433
+ * ##### Public route
382
434
  * Get social logins providers configurations V2 supports dev credentials as well
383
435
  * @return array of providers configurations
384
436
  */
385
437
  export declare function getSocialLoginProvidersV2(): Promise<ISocialLoginProviderConfigurationV2[]>;
438
+ /**
439
+ * ##### Authenticated route
440
+ * Get social logins providers configurations V2 supports dev credentials as well
441
+ * @return array of providers configurations
442
+ */
443
+ export declare function getSocialLoginProvidersV2ForAuthenticatedUser(): Promise<ISocialLoginProviderConfigurationV2[]>;
386
444
  /**
387
445
  * Get social logins custom providers configurations
388
446
  * @return array of custom providers configurations
@@ -496,6 +554,7 @@ export declare function checkIfAllowToRememberMfaDevice(mfaToken: string): Promi
496
554
  * Passwordless prelogin authentication
497
555
  */
498
556
  export declare function passwordlessPreLogin({ type, ...body }: IPasswordlessPreLogin): Promise<void>;
557
+ export declare function passwordlessPostLoginV2({ type, ...body }: IPasswordlessPostLogin): Promise<ILoginResponseV3>;
499
558
  export declare function passwordlessPostLogin({ type, ...body }: IPasswordlessPostLogin): Promise<ILoginResponse>;
500
559
  /**
501
560
  * Check if tenant invitation token is valid
@@ -600,6 +659,8 @@ export declare function preLoginV2(body: IPreLogin): Promise<IPreLoginWithIdpTyp
600
659
  * with code and state
601
660
  */
602
661
  export declare function oidcPostLoginV2(body: IOidcPostLoginV2): Promise<ILoginResponse>;
662
+ export declare function exchangeOAuthTokensV2(body: IExchangeOAuthTokens): Promise<ILoginResponseV3>;
663
+ export declare function silentOAuthRefreshTokenV2(): Promise<ILoginResponseV3>;
603
664
  export declare function exchangeOAuthTokens(body: IExchangeOAuthTokens): Promise<ILoginResponse>;
604
665
  export declare function silentOAuthRefreshToken(): Promise<ILoginResponse>;
605
666
  /**
@@ -632,6 +693,10 @@ export declare function webAuthnPreLogin(body: IWebAuthnPreLogin): Promise<IWebA
632
693
  * webauthn postlogin should be called after the user used his authenticator (device/android/usb key) in order to login
633
694
  */
634
695
  export declare function webAuthnPostLogin(body: IWebAuthnPostLogin): Promise<ILoginResponse>;
696
+ /**
697
+ * webauthn postlogin should be called after the user used his authenticator (device/android/usb key) in order to login
698
+ */
699
+ export declare function webAuthnPostLoginV2(body: IWebAuthnPostLogin): Promise<ILoginResponseV3>;
635
700
  /**
636
701
  * webauthn create new device should be called once the user wants to add new device as authenticator
637
702
  */
@@ -649,9 +714,15 @@ export declare function deleteWebAuthnDevice(deviceId: string): Promise<void>;
649
714
  */
650
715
  export declare function verifyNewDeviceSession(body: IVerifyNewWebAuthnDevice): Promise<void>;
651
716
  /**
717
+ * ##### Public route
652
718
  * Get public vendor auth strategies public configuration
653
719
  */
654
720
  export declare function getVendorPublicAuthStrategiesConfig(): Promise<IAuthStrategiesConfig>;
721
+ /**
722
+ * ##### Authenticated route
723
+ * Get public vendor auth strategies public configuration
724
+ */
725
+ export declare function getPublicAuthStrategiesConfigForAuthenticatedUser(): Promise<IAuthStrategiesConfig>;
655
726
  /**
656
727
  * Get vendor mfa strategies configuration
657
728
  */
package/auth/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  const _excluded = ["type"],
4
- _excluded2 = ["type"];
4
+ _excluded2 = ["type"],
5
+ _excluded3 = ["type"];
5
6
  import { getTenants } from "../tenants";
6
7
  export * from "./secutiry-poilicy";
7
8
  export * from "./enums";
@@ -79,6 +80,26 @@ export async function generateLoginResponseFromOAuthResponse(oauthResponse) {
79
80
  ContextHolder.setUser(user);
80
81
  return user;
81
82
  }
83
+ export async function generateLoginResponseFromOAuthResponseV2(oauthResponse) {
84
+ ContextHolder.setAccessToken(oauthResponse.id_token);
85
+ const [me, currentUserTenants] = await Promise.all([Get(`${urls.identity.users.v2}/me`), getCurrentUserTenantsV3()]);
86
+ const decodedContent = oauthResponse.id_token ? jwtDecode(oauthResponse.id_token) : {};
87
+
88
+ const user = _extends({
89
+ mfaRequired: false,
90
+ accessToken: oauthResponse.id_token,
91
+ refreshToken: oauthResponse.refresh_token
92
+ }, decodedContent, me, {
93
+ expiresIn: oauthResponse.expires_in || 300
94
+ });
95
+
96
+ ContextHolder.setUser(user);
97
+ return {
98
+ user,
99
+ tenants: currentUserTenants.tenants,
100
+ activeTenant: currentUserTenants.activeTenant
101
+ };
102
+ }
82
103
  export async function preLogin(body) {
83
104
  try {
84
105
  const {
@@ -104,13 +125,25 @@ export async function login(body) {
104
125
  const data = await Post(`${urls.identity.auth.v1}/user`, body);
105
126
  return generateLoginResponse(data);
106
127
  }
128
+ export async function loginv2(body) {
129
+ const data = await Post(`${urls.identity.auth.v1}/user`, body);
130
+ return generateLoginResponseV3(data);
131
+ }
107
132
  export async function loginWithMfa(body) {
108
133
  const data = await Post(`${urls.identity.auth.v1}/user/mfa/verify`, body);
109
134
  return generateLoginResponse(data);
110
135
  }
136
+ export async function loginWithMfaV2(body) {
137
+ const data = await Post(`${urls.identity.auth.v1}/user/mfa/verify`, body);
138
+ return generateLoginResponseV3(data);
139
+ }
111
140
  export async function activateAccount(body) {
112
141
  return Post(`${urls.identity.users.v1}/activate`, body);
113
142
  }
143
+ export async function activateAccountV2(body) {
144
+ const data = await Post(`${urls.identity.users.v1}/activate`, body);
145
+ return generateLoginResponseV3(data);
146
+ }
114
147
  export async function getActivateAccountStrategy(params) {
115
148
  return Get(`${urls.identity.users.v1}/activate/strategy`, params);
116
149
  }
@@ -204,6 +237,10 @@ export async function preEnrollMFAAuthenticatorAppForLogin(body) {
204
237
  export async function enrollMFAAuthenticatorAppForLogin(body) {
205
238
  return Post(`${urls.identity.auth.v1}/user/mfa/authenticator/enroll/verify`, body);
206
239
  }
240
+ export async function enrollMFAAuthenticatorAppForLoginV2(body) {
241
+ const data = await Post(`${urls.identity.auth.v1}/user/mfa/authenticator/enroll/verify`, body);
242
+ return generateLoginResponseV3(data);
243
+ }
207
244
  export async function verifyMFAAuthenticatorAppForLogin(deviceId, body) {
208
245
  return Post(`${urls.identity.auth.v1}/user/mfa/authenticator/${deviceId}/verify`, body);
209
246
  }
@@ -213,24 +250,40 @@ export async function preVerifyMFAEmailCode(body) {
213
250
  export async function verifyMFAEmailCode(body) {
214
251
  return Post(`${urls.identity.auth.v1}/user/mfa/emailcode/verify`, body);
215
252
  }
253
+ export async function verifyMFAEmailCodeV2(body) {
254
+ const data = await Post(`${urls.identity.auth.v1}/user/mfa/emailcode/verify`, body);
255
+ return generateLoginResponseV3(data);
256
+ }
216
257
  export async function preEnrollMFASMSForLogin(body) {
217
258
  return Post(`${urls.identity.auth.v1}/user/mfa/sms/enroll`, body);
218
259
  }
219
260
  export async function enrollMFASMSForLogin(body) {
220
261
  return Post(`${urls.identity.auth.v1}/user/mfa/sms/enroll/verify`, body);
221
262
  }
263
+ export async function enrollMFASMSForLoginV2(body) {
264
+ const data = await Post(`${urls.identity.auth.v1}/user/mfa/sms/enroll/verify`, body);
265
+ return generateLoginResponseV3(data);
266
+ }
222
267
  export async function preVerifyMFASMSForLogin(deviceId, body) {
223
268
  return Post(`${urls.identity.auth.v1}/user/mfa/sms/${deviceId}`, body);
224
269
  }
225
270
  export async function verifyMFASMSForLogin(deviceId, body) {
226
271
  return Post(`${urls.identity.auth.v1}/user/mfa/sms/${deviceId}/verify`, body);
227
272
  }
273
+ export async function verifyMFASMSForLoginV2(deviceId, body) {
274
+ const data = await Post(`${urls.identity.auth.v1}/user/mfa/sms/${deviceId}/verify`, body);
275
+ return generateLoginResponseV3(data);
276
+ }
228
277
  export async function preEnrollMFAWebAuthnForLogin(body) {
229
278
  return Post(`${urls.identity.auth.v1}/user/mfa/webauthn/enroll`, body);
230
279
  }
231
280
  export async function enrollMFAWebAuthnForLogin(body) {
232
281
  return Post(`${urls.identity.auth.v1}/user/mfa/webauthn/enroll/verify`, body);
233
282
  }
283
+ export async function enrollMFAWebAuthnForLoginV2(body) {
284
+ const data = await Post(`${urls.identity.auth.v1}/user/mfa/webauthn/enroll/verify`, body);
285
+ return generateLoginResponseV3(data);
286
+ }
234
287
  export async function preVerifyMFAWebAuthnForLogin(deviceId, body) {
235
288
  return Post(`${urls.identity.auth.v1}/user/mfa/webauthn/${deviceId}`, body);
236
289
  }
@@ -301,6 +354,9 @@ export async function getSocialLoginProviders() {
301
354
  export async function getSocialLoginProvidersV2() {
302
355
  return Get(urls.identity.sso.v2);
303
356
  }
357
+ export async function getSocialLoginProvidersV2ForAuthenticatedUser() {
358
+ return Get(`${urls.identity.sso.v2}/authenticated`);
359
+ }
304
360
  export async function getCustomSocialLoginProvidersV1() {
305
361
  return Get(urls.identity.sso.custom.v1);
306
362
  }
@@ -353,13 +409,26 @@ export async function signUpUser(body) {
353
409
  userId,
354
410
  tenantId
355
411
  } = await Post(`${urls.identity.users.v1}/signUp`, body);
356
- const loginResponse = !shouldActivate && authResponse ? await generateLoginResponse(authResponse) : undefined;
357
- return {
412
+ const response = {
358
413
  shouldActivate,
359
- user: loginResponse,
360
414
  userId,
361
415
  tenantId
362
416
  };
417
+
418
+ if (!shouldActivate && authResponse) {
419
+ const {
420
+ user,
421
+ tenants,
422
+ activeTenant
423
+ } = await generateLoginResponseV3(authResponse);
424
+ return _extends({}, response, {
425
+ user,
426
+ tenants,
427
+ activeTenant
428
+ });
429
+ }
430
+
431
+ return response;
363
432
  }
364
433
  export async function getCurrentUserSessions() {
365
434
  return Get(urls.identity.users.sessions.currentUser.v1);
@@ -446,12 +515,21 @@ export async function passwordlessPreLogin(_ref) {
446
515
 
447
516
  return Post(`${urls.identity.auth.v1}/passwordless/${type.toLocaleLowerCase()}/prelogin`, body);
448
517
  }
449
- export async function passwordlessPostLogin(_ref2) {
518
+ export async function passwordlessPostLoginV2(_ref2) {
450
519
  let {
451
520
  type
452
521
  } = _ref2,
453
522
  body = _objectWithoutPropertiesLoose(_ref2, _excluded2);
454
523
 
524
+ const data = await Post(`${urls.identity.auth.v1}/passwordless/${type.toLocaleLowerCase()}/postlogin`, body);
525
+ return generateLoginResponseV3(data);
526
+ }
527
+ export async function passwordlessPostLogin(_ref3) {
528
+ let {
529
+ type
530
+ } = _ref3,
531
+ body = _objectWithoutPropertiesLoose(_ref3, _excluded3);
532
+
455
533
  return Post(`${urls.identity.auth.v1}/passwordless/${type.toLocaleLowerCase()}/postlogin`, body);
456
534
  }
457
535
  export async function verifyInviteToken({
@@ -520,6 +598,14 @@ export async function oidcPostLoginV2(body) {
520
598
  const data = await Post(`${urls.identity.auth.v2}/user/oidc/postlogin`, body);
521
599
  return generateLoginResponse(data);
522
600
  }
601
+ export async function exchangeOAuthTokensV2(body) {
602
+ const data = await Post(`${urls.oauth.v1}/token`, body);
603
+ return generateLoginResponseFromOAuthResponseV2(data);
604
+ }
605
+ export async function silentOAuthRefreshTokenV2() {
606
+ const data = await Post(`${urls.oauth.v1}/authorize/silent`);
607
+ return generateLoginResponseFromOAuthResponseV2(data);
608
+ }
523
609
  export async function exchangeOAuthTokens(body) {
524
610
  const data = await Post(`${urls.oauth.v1}/token`, body);
525
611
  return generateLoginResponseFromOAuthResponse(data);
@@ -549,6 +635,10 @@ export async function webAuthnPreLogin(body) {
549
635
  export async function webAuthnPostLogin(body) {
550
636
  return Post(`${urls.identity.auth.v1}/webauthn/postlogin`, body);
551
637
  }
638
+ export async function webAuthnPostLoginV2(body) {
639
+ const data = await Post(`${urls.identity.auth.v1}/webauthn/postlogin`, body);
640
+ return generateLoginResponseV3(data);
641
+ }
552
642
  export async function webAuthnCreateNewDeviceSession() {
553
643
  return Post(urls.identity.webAuthnDevices.v1);
554
644
  }
@@ -564,6 +654,9 @@ export async function verifyNewDeviceSession(body) {
564
654
  export async function getVendorPublicAuthStrategiesConfig() {
565
655
  return Get(`${urls.identity.configurations.v1}/auth/strategies/public`);
566
656
  }
657
+ export async function getPublicAuthStrategiesConfigForAuthenticatedUser() {
658
+ return Get(`${urls.identity.configurations.v1}/auth/strategies`);
659
+ }
567
660
  export async function getMFAStrategiesConfig() {
568
661
  return Get(`${urls.identity.configurations.v1}/mfa/strategies`);
569
662
  }
@@ -219,6 +219,8 @@ export interface ISignUpResponse {
219
219
  user?: ILoginResponse;
220
220
  userId?: string;
221
221
  tenantId?: string;
222
+ tenants?: ITenantsResponse[];
223
+ activeTenant?: ITenantsResponse;
222
224
  }
223
225
  export interface ISessionResponse {
224
226
  id: string;
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v3.0.131
1
+ /** @license Frontegg v3.0.133
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -10,13 +10,17 @@ var _exportNames = {
10
10
  generateLoginResponseV2: true,
11
11
  generateLoginResponseV3: true,
12
12
  generateLoginResponseFromOAuthResponse: true,
13
+ generateLoginResponseFromOAuthResponseV2: true,
13
14
  preLogin: true,
14
15
  preLoginWithIdpType: true,
15
16
  postLogin: true,
16
17
  oidcPostLogin: true,
17
18
  login: true,
19
+ loginv2: true,
18
20
  loginWithMfa: true,
21
+ loginWithMfaV2: true,
19
22
  activateAccount: true,
23
+ activateAccountV2: true,
20
24
  getActivateAccountStrategy: true,
21
25
  resendActivationEmail: true,
22
26
  resendInvitationEmail: true,
@@ -47,15 +51,20 @@ var _exportNames = {
47
51
  getMFADevices: true,
48
52
  preEnrollMFAAuthenticatorAppForLogin: true,
49
53
  enrollMFAAuthenticatorAppForLogin: true,
54
+ enrollMFAAuthenticatorAppForLoginV2: true,
50
55
  verifyMFAAuthenticatorAppForLogin: true,
51
56
  preVerifyMFAEmailCode: true,
52
57
  verifyMFAEmailCode: true,
58
+ verifyMFAEmailCodeV2: true,
53
59
  preEnrollMFASMSForLogin: true,
54
60
  enrollMFASMSForLogin: true,
61
+ enrollMFASMSForLoginV2: true,
55
62
  preVerifyMFASMSForLogin: true,
56
63
  verifyMFASMSForLogin: true,
64
+ verifyMFASMSForLoginV2: true,
57
65
  preEnrollMFAWebAuthnForLogin: true,
58
66
  enrollMFAWebAuthnForLogin: true,
67
+ enrollMFAWebAuthnForLoginV2: true,
59
68
  preVerifyMFAWebAuthnForLogin: true,
60
69
  verifyMFAWebAuthnForLogin: true,
61
70
  getSamlConfiguration: true,
@@ -73,6 +82,7 @@ var _exportNames = {
73
82
  getSSOPublicConfiguration: true,
74
83
  getSocialLoginProviders: true,
75
84
  getSocialLoginProvidersV2: true,
85
+ getSocialLoginProvidersV2ForAuthenticatedUser: true,
76
86
  getCustomSocialLoginProvidersV1: true,
77
87
  loginViaSocialLogin: true,
78
88
  getVendorConfig: true,
@@ -99,6 +109,7 @@ var _exportNames = {
99
109
  getUserById: true,
100
110
  checkIfAllowToRememberMfaDevice: true,
101
111
  passwordlessPreLogin: true,
112
+ passwordlessPostLoginV2: true,
102
113
  passwordlessPostLogin: true,
103
114
  verifyInviteToken: true,
104
115
  getSSOConfigurations: true,
@@ -118,6 +129,8 @@ var _exportNames = {
118
129
  getSSOGroups: true,
119
130
  preLoginV2: true,
120
131
  oidcPostLoginV2: true,
132
+ exchangeOAuthTokensV2: true,
133
+ silentOAuthRefreshTokenV2: true,
121
134
  exchangeOAuthTokens: true,
122
135
  silentOAuthRefreshToken: true,
123
136
  resetPhoneNumber: true,
@@ -127,16 +140,19 @@ var _exportNames = {
127
140
  changePhoneNumber: true,
128
141
  webAuthnPreLogin: true,
129
142
  webAuthnPostLogin: true,
143
+ webAuthnPostLoginV2: true,
130
144
  webAuthnCreateNewDeviceSession: true,
131
145
  getWebAuthnDevices: true,
132
146
  deleteWebAuthnDevice: true,
133
147
  verifyNewDeviceSession: true,
134
148
  getVendorPublicAuthStrategiesConfig: true,
149
+ getPublicAuthStrategiesConfigForAuthenticatedUser: true,
135
150
  getMFAStrategiesConfig: true
136
151
  };
137
152
  exports.OAuthLogout = OAuthLogout;
138
153
  exports.acceptInvitation = acceptInvitation;
139
154
  exports.activateAccount = activateAccount;
155
+ exports.activateAccountV2 = activateAccountV2;
140
156
  exports.changePhoneNumber = changePhoneNumber;
141
157
  exports.changePhoneNumberWithVerification = changePhoneNumberWithVerification;
142
158
  exports.checkIfAllowToRememberMfaDevice = checkIfAllowToRememberMfaDevice;
@@ -165,15 +181,20 @@ exports.disableMFAWebAuthn = disableMFAWebAuthn;
165
181
  exports.disableMfa = disableMfa;
166
182
  exports.enrollMFAAuthenticatorApp = enrollMFAAuthenticatorApp;
167
183
  exports.enrollMFAAuthenticatorAppForLogin = enrollMFAAuthenticatorAppForLogin;
184
+ exports.enrollMFAAuthenticatorAppForLoginV2 = enrollMFAAuthenticatorAppForLoginV2;
168
185
  exports.enrollMFASMS = enrollMFASMS;
169
186
  exports.enrollMFASMSForLogin = enrollMFASMSForLogin;
187
+ exports.enrollMFASMSForLoginV2 = enrollMFASMSForLoginV2;
170
188
  exports.enrollMFAWebAuthn = enrollMFAWebAuthn;
171
189
  exports.enrollMFAWebAuthnForLogin = enrollMFAWebAuthnForLogin;
190
+ exports.enrollMFAWebAuthnForLoginV2 = enrollMFAWebAuthnForLoginV2;
172
191
  exports.enrollMfa = enrollMfa;
173
192
  exports.exchangeOAuthTokens = exchangeOAuthTokens;
193
+ exports.exchangeOAuthTokensV2 = exchangeOAuthTokensV2;
174
194
  exports.forgotPassword = forgotPassword;
175
195
  exports.generateLoginResponse = generateLoginResponse;
176
196
  exports.generateLoginResponseFromOAuthResponse = generateLoginResponseFromOAuthResponse;
197
+ exports.generateLoginResponseFromOAuthResponseV2 = generateLoginResponseFromOAuthResponseV2;
177
198
  exports.generateLoginResponseV2 = generateLoginResponseV2;
178
199
  exports.generateLoginResponseV3 = generateLoginResponseV3;
179
200
  exports.getActivateAccountStrategy = getActivateAccountStrategy;
@@ -183,6 +204,7 @@ exports.getCustomSocialLoginProvidersV1 = getCustomSocialLoginProvidersV1;
183
204
  exports.getMFADevices = getMFADevices;
184
205
  exports.getMFAStrategiesConfig = getMFAStrategiesConfig;
185
206
  exports.getOidcConfiguration = getOidcConfiguration;
207
+ exports.getPublicAuthStrategiesConfigForAuthenticatedUser = getPublicAuthStrategiesConfigForAuthenticatedUser;
186
208
  exports.getSSOConfigurations = getSSOConfigurations;
187
209
  exports.getSSODefaultRoles = getSSODefaultRoles;
188
210
  exports.getSSOGroups = getSSOGroups;
@@ -194,6 +216,7 @@ exports.getSamlVendorConfiguration = getSamlVendorConfiguration;
194
216
  exports.getSessionConfigurations = getSessionConfigurations;
195
217
  exports.getSocialLoginProviders = getSocialLoginProviders;
196
218
  exports.getSocialLoginProvidersV2 = getSocialLoginProvidersV2;
219
+ exports.getSocialLoginProvidersV2ForAuthenticatedUser = getSocialLoginProvidersV2ForAuthenticatedUser;
197
220
  exports.getTenantAccessTokensData = getTenantAccessTokensData;
198
221
  exports.getTenantApiTokensData = getTenantApiTokensData;
199
222
  exports.getUserAccessTokensData = getUserAccessTokensData;
@@ -206,10 +229,13 @@ exports.loadPasswordConfig = loadPasswordConfig;
206
229
  exports.login = login;
207
230
  exports.loginViaSocialLogin = loginViaSocialLogin;
208
231
  exports.loginWithMfa = loginWithMfa;
232
+ exports.loginWithMfaV2 = loginWithMfaV2;
233
+ exports.loginv2 = loginv2;
209
234
  exports.logout = logout;
210
235
  exports.oidcPostLogin = oidcPostLogin;
211
236
  exports.oidcPostLoginV2 = oidcPostLoginV2;
212
237
  exports.passwordlessPostLogin = passwordlessPostLogin;
238
+ exports.passwordlessPostLoginV2 = passwordlessPostLoginV2;
213
239
  exports.passwordlessPreLogin = passwordlessPreLogin;
214
240
  exports.postLogin = postLogin;
215
241
  exports.preDisableMFASMS = preDisableMFASMS;
@@ -238,6 +264,7 @@ exports.revokeSessionsForUser = revokeSessionsForUser;
238
264
  exports.setSSODefaultRoles = setSSODefaultRoles;
239
265
  exports.signUpUser = signUpUser;
240
266
  exports.silentOAuthRefreshToken = silentOAuthRefreshToken;
267
+ exports.silentOAuthRefreshTokenV2 = silentOAuthRefreshTokenV2;
241
268
  exports.updateSSOConfiguration = updateSSOConfiguration;
242
269
  exports.updateSSOConfigurationByMetadata = updateSSOConfigurationByMetadata;
243
270
  exports.updateSSOGroup = updateSSOGroup;
@@ -253,13 +280,16 @@ exports.verifyChangePhoneNumber = verifyChangePhoneNumber;
253
280
  exports.verifyInviteToken = verifyInviteToken;
254
281
  exports.verifyMFAAuthenticatorAppForLogin = verifyMFAAuthenticatorAppForLogin;
255
282
  exports.verifyMFAEmailCode = verifyMFAEmailCode;
283
+ exports.verifyMFAEmailCodeV2 = verifyMFAEmailCodeV2;
256
284
  exports.verifyMFASMSForLogin = verifyMFASMSForLogin;
285
+ exports.verifyMFASMSForLoginV2 = verifyMFASMSForLoginV2;
257
286
  exports.verifyMFAWebAuthnForLogin = verifyMFAWebAuthnForLogin;
258
287
  exports.verifyMfa = verifyMfa;
259
288
  exports.verifyNewDeviceSession = verifyNewDeviceSession;
260
289
  exports.verifyResetPhoneNumber = verifyResetPhoneNumber;
261
290
  exports.webAuthnCreateNewDeviceSession = webAuthnCreateNewDeviceSession;
262
291
  exports.webAuthnPostLogin = webAuthnPostLogin;
292
+ exports.webAuthnPostLoginV2 = webAuthnPostLoginV2;
263
293
  exports.webAuthnPreLogin = webAuthnPreLogin;
264
294
 
265
295
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
@@ -307,7 +337,8 @@ var _jwt = require("../jwt");
307
337
  var _users = require("../users");
308
338
 
309
339
  const _excluded = ["type"],
310
- _excluded2 = ["type"];
340
+ _excluded2 = ["type"],
341
+ _excluded3 = ["type"];
311
342
 
312
343
  async function generateLoginResponse(loginResponse) {
313
344
  if (!loginResponse.accessToken) {
@@ -386,6 +417,28 @@ async function generateLoginResponseFromOAuthResponse(oauthResponse) {
386
417
  return user;
387
418
  }
388
419
 
420
+ async function generateLoginResponseFromOAuthResponseV2(oauthResponse) {
421
+ _ContextHolder.ContextHolder.setAccessToken(oauthResponse.id_token);
422
+
423
+ const [me, currentUserTenants] = await Promise.all([(0, _fetch.Get)(`${_constants.urls.identity.users.v2}/me`), (0, _users.getCurrentUserTenantsV3)()]);
424
+ const decodedContent = oauthResponse.id_token ? (0, _jwt.jwtDecode)(oauthResponse.id_token) : {};
425
+ const user = (0, _extends2.default)({
426
+ mfaRequired: false,
427
+ accessToken: oauthResponse.id_token,
428
+ refreshToken: oauthResponse.refresh_token
429
+ }, decodedContent, me, {
430
+ expiresIn: oauthResponse.expires_in || 300
431
+ });
432
+
433
+ _ContextHolder.ContextHolder.setUser(user);
434
+
435
+ return {
436
+ user,
437
+ tenants: currentUserTenants.tenants,
438
+ activeTenant: currentUserTenants.activeTenant
439
+ };
440
+ }
441
+
389
442
  async function preLogin(body) {
390
443
  try {
391
444
  const {
@@ -416,15 +469,30 @@ async function login(body) {
416
469
  return generateLoginResponse(data);
417
470
  }
418
471
 
472
+ async function loginv2(body) {
473
+ const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user`, body);
474
+ return generateLoginResponseV3(data);
475
+ }
476
+
419
477
  async function loginWithMfa(body) {
420
478
  const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/verify`, body);
421
479
  return generateLoginResponse(data);
422
480
  }
423
481
 
482
+ async function loginWithMfaV2(body) {
483
+ const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/verify`, body);
484
+ return generateLoginResponseV3(data);
485
+ }
486
+
424
487
  async function activateAccount(body) {
425
488
  return (0, _fetch.Post)(`${_constants.urls.identity.users.v1}/activate`, body);
426
489
  }
427
490
 
491
+ async function activateAccountV2(body) {
492
+ const data = await (0, _fetch.Post)(`${_constants.urls.identity.users.v1}/activate`, body);
493
+ return generateLoginResponseV3(data);
494
+ }
495
+
428
496
  async function getActivateAccountStrategy(params) {
429
497
  return (0, _fetch.Get)(`${_constants.urls.identity.users.v1}/activate/strategy`, params);
430
498
  }
@@ -548,6 +616,11 @@ async function enrollMFAAuthenticatorAppForLogin(body) {
548
616
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/authenticator/enroll/verify`, body);
549
617
  }
550
618
 
619
+ async function enrollMFAAuthenticatorAppForLoginV2(body) {
620
+ const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/authenticator/enroll/verify`, body);
621
+ return generateLoginResponseV3(data);
622
+ }
623
+
551
624
  async function verifyMFAAuthenticatorAppForLogin(deviceId, body) {
552
625
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/authenticator/${deviceId}/verify`, body);
553
626
  }
@@ -560,6 +633,11 @@ async function verifyMFAEmailCode(body) {
560
633
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/emailcode/verify`, body);
561
634
  }
562
635
 
636
+ async function verifyMFAEmailCodeV2(body) {
637
+ const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/emailcode/verify`, body);
638
+ return generateLoginResponseV3(data);
639
+ }
640
+
563
641
  async function preEnrollMFASMSForLogin(body) {
564
642
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/sms/enroll`, body);
565
643
  }
@@ -568,6 +646,11 @@ async function enrollMFASMSForLogin(body) {
568
646
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/sms/enroll/verify`, body);
569
647
  }
570
648
 
649
+ async function enrollMFASMSForLoginV2(body) {
650
+ const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/sms/enroll/verify`, body);
651
+ return generateLoginResponseV3(data);
652
+ }
653
+
571
654
  async function preVerifyMFASMSForLogin(deviceId, body) {
572
655
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/sms/${deviceId}`, body);
573
656
  }
@@ -576,6 +659,11 @@ async function verifyMFASMSForLogin(deviceId, body) {
576
659
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/sms/${deviceId}/verify`, body);
577
660
  }
578
661
 
662
+ async function verifyMFASMSForLoginV2(deviceId, body) {
663
+ const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/sms/${deviceId}/verify`, body);
664
+ return generateLoginResponseV3(data);
665
+ }
666
+
579
667
  async function preEnrollMFAWebAuthnForLogin(body) {
580
668
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/webauthn/enroll`, body);
581
669
  }
@@ -584,6 +672,11 @@ async function enrollMFAWebAuthnForLogin(body) {
584
672
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/webauthn/enroll/verify`, body);
585
673
  }
586
674
 
675
+ async function enrollMFAWebAuthnForLoginV2(body) {
676
+ const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/webauthn/enroll/verify`, body);
677
+ return generateLoginResponseV3(data);
678
+ }
679
+
587
680
  async function preVerifyMFAWebAuthnForLogin(deviceId, body) {
588
681
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/webauthn/${deviceId}`, body);
589
682
  }
@@ -671,6 +764,10 @@ async function getSocialLoginProvidersV2() {
671
764
  return (0, _fetch.Get)(_constants.urls.identity.sso.v2);
672
765
  }
673
766
 
767
+ async function getSocialLoginProvidersV2ForAuthenticatedUser() {
768
+ return (0, _fetch.Get)(`${_constants.urls.identity.sso.v2}/authenticated`);
769
+ }
770
+
674
771
  async function getCustomSocialLoginProvidersV1() {
675
772
  return (0, _fetch.Get)(_constants.urls.identity.sso.custom.v1);
676
773
  }
@@ -726,13 +823,26 @@ async function signUpUser(body) {
726
823
  userId,
727
824
  tenantId
728
825
  } = await (0, _fetch.Post)(`${_constants.urls.identity.users.v1}/signUp`, body);
729
- const loginResponse = !shouldActivate && authResponse ? await generateLoginResponse(authResponse) : undefined;
730
- return {
826
+ const response = {
731
827
  shouldActivate,
732
- user: loginResponse,
733
828
  userId,
734
829
  tenantId
735
830
  };
831
+
832
+ if (!shouldActivate && authResponse) {
833
+ const {
834
+ user,
835
+ tenants,
836
+ activeTenant
837
+ } = await generateLoginResponseV3(authResponse);
838
+ return (0, _extends2.default)({}, response, {
839
+ user,
840
+ tenants,
841
+ activeTenant
842
+ });
843
+ }
844
+
845
+ return response;
736
846
  }
737
847
 
738
848
  async function getCurrentUserSessions() {
@@ -841,11 +951,20 @@ async function passwordlessPreLogin(_ref) {
841
951
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/passwordless/${type.toLocaleLowerCase()}/prelogin`, body);
842
952
  }
843
953
 
844
- async function passwordlessPostLogin(_ref2) {
954
+ async function passwordlessPostLoginV2(_ref2) {
845
955
  let {
846
956
  type
847
957
  } = _ref2,
848
958
  body = (0, _objectWithoutPropertiesLoose2.default)(_ref2, _excluded2);
959
+ const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/passwordless/${type.toLocaleLowerCase()}/postlogin`, body);
960
+ return generateLoginResponseV3(data);
961
+ }
962
+
963
+ async function passwordlessPostLogin(_ref3) {
964
+ let {
965
+ type
966
+ } = _ref3,
967
+ body = (0, _objectWithoutPropertiesLoose2.default)(_ref3, _excluded3);
849
968
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/passwordless/${type.toLocaleLowerCase()}/postlogin`, body);
850
969
  }
851
970
 
@@ -933,6 +1052,16 @@ async function oidcPostLoginV2(body) {
933
1052
  return generateLoginResponse(data);
934
1053
  }
935
1054
 
1055
+ async function exchangeOAuthTokensV2(body) {
1056
+ const data = await (0, _fetch.Post)(`${_constants.urls.oauth.v1}/token`, body);
1057
+ return generateLoginResponseFromOAuthResponseV2(data);
1058
+ }
1059
+
1060
+ async function silentOAuthRefreshTokenV2() {
1061
+ const data = await (0, _fetch.Post)(`${_constants.urls.oauth.v1}/authorize/silent`);
1062
+ return generateLoginResponseFromOAuthResponseV2(data);
1063
+ }
1064
+
936
1065
  async function exchangeOAuthTokens(body) {
937
1066
  const data = await (0, _fetch.Post)(`${_constants.urls.oauth.v1}/token`, body);
938
1067
  return generateLoginResponseFromOAuthResponse(data);
@@ -971,6 +1100,11 @@ async function webAuthnPostLogin(body) {
971
1100
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/webauthn/postlogin`, body);
972
1101
  }
973
1102
 
1103
+ async function webAuthnPostLoginV2(body) {
1104
+ const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/webauthn/postlogin`, body);
1105
+ return generateLoginResponseV3(data);
1106
+ }
1107
+
974
1108
  async function webAuthnCreateNewDeviceSession() {
975
1109
  return (0, _fetch.Post)(_constants.urls.identity.webAuthnDevices.v1);
976
1110
  }
@@ -991,6 +1125,10 @@ async function getVendorPublicAuthStrategiesConfig() {
991
1125
  return (0, _fetch.Get)(`${_constants.urls.identity.configurations.v1}/auth/strategies/public`);
992
1126
  }
993
1127
 
1128
+ async function getPublicAuthStrategiesConfigForAuthenticatedUser() {
1129
+ return (0, _fetch.Get)(`${_constants.urls.identity.configurations.v1}/auth/strategies`);
1130
+ }
1131
+
994
1132
  async function getMFAStrategiesConfig() {
995
1133
  return (0, _fetch.Get)(`${_constants.urls.identity.configurations.v1}/mfa/strategies`);
996
1134
  }
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v3.0.131
1
+ /** @license Frontegg v3.0.133
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontegg/rest-api",
3
- "version": "3.0.131",
3
+ "version": "3.0.133",
4
4
  "main": "./node/index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {