@frontegg/rest-api 3.0.132 → 3.0.134

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.
@@ -296,6 +347,11 @@ export declare function preVerifyMFAWebAuthnForLogin(deviceId: string, body: IPr
296
347
  * and the assertion response.
297
348
  */
298
349
  export declare function verifyMFAWebAuthnForLogin(deviceId: string, body: IVerifyMFAWebAuthn): Promise<ILoginResponse>;
350
+ /**
351
+ * after pre verify with WebAuthn, this function should be called with webauthnTokenToken, mfaToken
352
+ * and the assertion response.
353
+ */
354
+ export declare function verifyMFAWebAuthnForLoginV2(deviceId: string, body: IVerifyMFAWebAuthn): Promise<ILoginResponseV3>;
299
355
  /**
300
356
  * SSO Configurations
301
357
  */
@@ -503,6 +559,7 @@ export declare function checkIfAllowToRememberMfaDevice(mfaToken: string): Promi
503
559
  * Passwordless prelogin authentication
504
560
  */
505
561
  export declare function passwordlessPreLogin({ type, ...body }: IPasswordlessPreLogin): Promise<void>;
562
+ export declare function passwordlessPostLoginV2({ type, ...body }: IPasswordlessPostLogin): Promise<ILoginResponseV3>;
506
563
  export declare function passwordlessPostLogin({ type, ...body }: IPasswordlessPostLogin): Promise<ILoginResponse>;
507
564
  /**
508
565
  * Check if tenant invitation token is valid
@@ -607,6 +664,8 @@ export declare function preLoginV2(body: IPreLogin): Promise<IPreLoginWithIdpTyp
607
664
  * with code and state
608
665
  */
609
666
  export declare function oidcPostLoginV2(body: IOidcPostLoginV2): Promise<ILoginResponse>;
667
+ export declare function exchangeOAuthTokensV2(body: IExchangeOAuthTokens): Promise<ILoginResponseV3>;
668
+ export declare function silentOAuthRefreshTokenV2(): Promise<ILoginResponseV3>;
610
669
  export declare function exchangeOAuthTokens(body: IExchangeOAuthTokens): Promise<ILoginResponse>;
611
670
  export declare function silentOAuthRefreshToken(): Promise<ILoginResponse>;
612
671
  /**
@@ -639,6 +698,10 @@ export declare function webAuthnPreLogin(body: IWebAuthnPreLogin): Promise<IWebA
639
698
  * webauthn postlogin should be called after the user used his authenticator (device/android/usb key) in order to login
640
699
  */
641
700
  export declare function webAuthnPostLogin(body: IWebAuthnPostLogin): Promise<ILoginResponse>;
701
+ /**
702
+ * webauthn postlogin should be called after the user used his authenticator (device/android/usb key) in order to login
703
+ */
704
+ export declare function webAuthnPostLoginV2(body: IWebAuthnPostLogin): Promise<ILoginResponseV3>;
642
705
  /**
643
706
  * webauthn create new device should be called once the user wants to add new device as authenticator
644
707
  */
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,30 +250,50 @@ 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
  }
237
290
  export async function verifyMFAWebAuthnForLogin(deviceId, body) {
238
291
  return Post(`${urls.identity.auth.v1}/user/mfa/webauthn/${deviceId}/verify`, body);
239
292
  }
293
+ export async function verifyMFAWebAuthnForLoginV2(deviceId, body) {
294
+ const data = await Post(`${urls.identity.auth.v1}/user/mfa/webauthn/${deviceId}/verify`, body);
295
+ return generateLoginResponseV3(data);
296
+ }
240
297
  export async function getSamlConfiguration() {
241
298
  return Get(`${urls.team.sso.v1}/saml/configurations`);
242
299
  }
@@ -356,13 +413,26 @@ export async function signUpUser(body) {
356
413
  userId,
357
414
  tenantId
358
415
  } = await Post(`${urls.identity.users.v1}/signUp`, body);
359
- const loginResponse = !shouldActivate && authResponse ? await generateLoginResponse(authResponse) : undefined;
360
- return {
416
+ const response = {
361
417
  shouldActivate,
362
- user: loginResponse,
363
418
  userId,
364
419
  tenantId
365
420
  };
421
+
422
+ if (!shouldActivate && authResponse) {
423
+ const {
424
+ user,
425
+ tenants,
426
+ activeTenant
427
+ } = await generateLoginResponseV3(authResponse);
428
+ return _extends({}, response, {
429
+ user,
430
+ tenants,
431
+ activeTenant
432
+ });
433
+ }
434
+
435
+ return response;
366
436
  }
367
437
  export async function getCurrentUserSessions() {
368
438
  return Get(urls.identity.users.sessions.currentUser.v1);
@@ -449,12 +519,21 @@ export async function passwordlessPreLogin(_ref) {
449
519
 
450
520
  return Post(`${urls.identity.auth.v1}/passwordless/${type.toLocaleLowerCase()}/prelogin`, body);
451
521
  }
452
- export async function passwordlessPostLogin(_ref2) {
522
+ export async function passwordlessPostLoginV2(_ref2) {
453
523
  let {
454
524
  type
455
525
  } = _ref2,
456
526
  body = _objectWithoutPropertiesLoose(_ref2, _excluded2);
457
527
 
528
+ const data = await Post(`${urls.identity.auth.v1}/passwordless/${type.toLocaleLowerCase()}/postlogin`, body);
529
+ return generateLoginResponseV3(data);
530
+ }
531
+ export async function passwordlessPostLogin(_ref3) {
532
+ let {
533
+ type
534
+ } = _ref3,
535
+ body = _objectWithoutPropertiesLoose(_ref3, _excluded3);
536
+
458
537
  return Post(`${urls.identity.auth.v1}/passwordless/${type.toLocaleLowerCase()}/postlogin`, body);
459
538
  }
460
539
  export async function verifyInviteToken({
@@ -523,6 +602,14 @@ export async function oidcPostLoginV2(body) {
523
602
  const data = await Post(`${urls.identity.auth.v2}/user/oidc/postlogin`, body);
524
603
  return generateLoginResponse(data);
525
604
  }
605
+ export async function exchangeOAuthTokensV2(body) {
606
+ const data = await Post(`${urls.oauth.v1}/token`, body);
607
+ return generateLoginResponseFromOAuthResponseV2(data);
608
+ }
609
+ export async function silentOAuthRefreshTokenV2() {
610
+ const data = await Post(`${urls.oauth.v1}/authorize/silent`);
611
+ return generateLoginResponseFromOAuthResponseV2(data);
612
+ }
526
613
  export async function exchangeOAuthTokens(body) {
527
614
  const data = await Post(`${urls.oauth.v1}/token`, body);
528
615
  return generateLoginResponseFromOAuthResponse(data);
@@ -552,6 +639,10 @@ export async function webAuthnPreLogin(body) {
552
639
  export async function webAuthnPostLogin(body) {
553
640
  return Post(`${urls.identity.auth.v1}/webauthn/postlogin`, body);
554
641
  }
642
+ export async function webAuthnPostLoginV2(body) {
643
+ const data = await Post(`${urls.identity.auth.v1}/webauthn/postlogin`, body);
644
+ return generateLoginResponseV3(data);
645
+ }
555
646
  export async function webAuthnCreateNewDeviceSession() {
556
647
  return Post(urls.identity.webAuthnDevices.v1);
557
648
  }
@@ -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.132
1
+ /** @license Frontegg v3.0.134
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,17 +51,23 @@ 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,
70
+ verifyMFAWebAuthnForLoginV2: true,
61
71
  getSamlConfiguration: true,
62
72
  updateSamlConfiguration: true,
63
73
  getSamlVendorConfiguration: true,
@@ -100,6 +110,7 @@ var _exportNames = {
100
110
  getUserById: true,
101
111
  checkIfAllowToRememberMfaDevice: true,
102
112
  passwordlessPreLogin: true,
113
+ passwordlessPostLoginV2: true,
103
114
  passwordlessPostLogin: true,
104
115
  verifyInviteToken: true,
105
116
  getSSOConfigurations: true,
@@ -119,6 +130,8 @@ var _exportNames = {
119
130
  getSSOGroups: true,
120
131
  preLoginV2: true,
121
132
  oidcPostLoginV2: true,
133
+ exchangeOAuthTokensV2: true,
134
+ silentOAuthRefreshTokenV2: true,
122
135
  exchangeOAuthTokens: true,
123
136
  silentOAuthRefreshToken: true,
124
137
  resetPhoneNumber: true,
@@ -128,6 +141,7 @@ var _exportNames = {
128
141
  changePhoneNumber: true,
129
142
  webAuthnPreLogin: true,
130
143
  webAuthnPostLogin: true,
144
+ webAuthnPostLoginV2: true,
131
145
  webAuthnCreateNewDeviceSession: true,
132
146
  getWebAuthnDevices: true,
133
147
  deleteWebAuthnDevice: true,
@@ -139,6 +153,7 @@ var _exportNames = {
139
153
  exports.OAuthLogout = OAuthLogout;
140
154
  exports.acceptInvitation = acceptInvitation;
141
155
  exports.activateAccount = activateAccount;
156
+ exports.activateAccountV2 = activateAccountV2;
142
157
  exports.changePhoneNumber = changePhoneNumber;
143
158
  exports.changePhoneNumberWithVerification = changePhoneNumberWithVerification;
144
159
  exports.checkIfAllowToRememberMfaDevice = checkIfAllowToRememberMfaDevice;
@@ -167,15 +182,20 @@ exports.disableMFAWebAuthn = disableMFAWebAuthn;
167
182
  exports.disableMfa = disableMfa;
168
183
  exports.enrollMFAAuthenticatorApp = enrollMFAAuthenticatorApp;
169
184
  exports.enrollMFAAuthenticatorAppForLogin = enrollMFAAuthenticatorAppForLogin;
185
+ exports.enrollMFAAuthenticatorAppForLoginV2 = enrollMFAAuthenticatorAppForLoginV2;
170
186
  exports.enrollMFASMS = enrollMFASMS;
171
187
  exports.enrollMFASMSForLogin = enrollMFASMSForLogin;
188
+ exports.enrollMFASMSForLoginV2 = enrollMFASMSForLoginV2;
172
189
  exports.enrollMFAWebAuthn = enrollMFAWebAuthn;
173
190
  exports.enrollMFAWebAuthnForLogin = enrollMFAWebAuthnForLogin;
191
+ exports.enrollMFAWebAuthnForLoginV2 = enrollMFAWebAuthnForLoginV2;
174
192
  exports.enrollMfa = enrollMfa;
175
193
  exports.exchangeOAuthTokens = exchangeOAuthTokens;
194
+ exports.exchangeOAuthTokensV2 = exchangeOAuthTokensV2;
176
195
  exports.forgotPassword = forgotPassword;
177
196
  exports.generateLoginResponse = generateLoginResponse;
178
197
  exports.generateLoginResponseFromOAuthResponse = generateLoginResponseFromOAuthResponse;
198
+ exports.generateLoginResponseFromOAuthResponseV2 = generateLoginResponseFromOAuthResponseV2;
179
199
  exports.generateLoginResponseV2 = generateLoginResponseV2;
180
200
  exports.generateLoginResponseV3 = generateLoginResponseV3;
181
201
  exports.getActivateAccountStrategy = getActivateAccountStrategy;
@@ -210,10 +230,13 @@ exports.loadPasswordConfig = loadPasswordConfig;
210
230
  exports.login = login;
211
231
  exports.loginViaSocialLogin = loginViaSocialLogin;
212
232
  exports.loginWithMfa = loginWithMfa;
233
+ exports.loginWithMfaV2 = loginWithMfaV2;
234
+ exports.loginv2 = loginv2;
213
235
  exports.logout = logout;
214
236
  exports.oidcPostLogin = oidcPostLogin;
215
237
  exports.oidcPostLoginV2 = oidcPostLoginV2;
216
238
  exports.passwordlessPostLogin = passwordlessPostLogin;
239
+ exports.passwordlessPostLoginV2 = passwordlessPostLoginV2;
217
240
  exports.passwordlessPreLogin = passwordlessPreLogin;
218
241
  exports.postLogin = postLogin;
219
242
  exports.preDisableMFASMS = preDisableMFASMS;
@@ -242,6 +265,7 @@ exports.revokeSessionsForUser = revokeSessionsForUser;
242
265
  exports.setSSODefaultRoles = setSSODefaultRoles;
243
266
  exports.signUpUser = signUpUser;
244
267
  exports.silentOAuthRefreshToken = silentOAuthRefreshToken;
268
+ exports.silentOAuthRefreshTokenV2 = silentOAuthRefreshTokenV2;
245
269
  exports.updateSSOConfiguration = updateSSOConfiguration;
246
270
  exports.updateSSOConfigurationByMetadata = updateSSOConfigurationByMetadata;
247
271
  exports.updateSSOGroup = updateSSOGroup;
@@ -257,13 +281,17 @@ exports.verifyChangePhoneNumber = verifyChangePhoneNumber;
257
281
  exports.verifyInviteToken = verifyInviteToken;
258
282
  exports.verifyMFAAuthenticatorAppForLogin = verifyMFAAuthenticatorAppForLogin;
259
283
  exports.verifyMFAEmailCode = verifyMFAEmailCode;
284
+ exports.verifyMFAEmailCodeV2 = verifyMFAEmailCodeV2;
260
285
  exports.verifyMFASMSForLogin = verifyMFASMSForLogin;
286
+ exports.verifyMFASMSForLoginV2 = verifyMFASMSForLoginV2;
261
287
  exports.verifyMFAWebAuthnForLogin = verifyMFAWebAuthnForLogin;
288
+ exports.verifyMFAWebAuthnForLoginV2 = verifyMFAWebAuthnForLoginV2;
262
289
  exports.verifyMfa = verifyMfa;
263
290
  exports.verifyNewDeviceSession = verifyNewDeviceSession;
264
291
  exports.verifyResetPhoneNumber = verifyResetPhoneNumber;
265
292
  exports.webAuthnCreateNewDeviceSession = webAuthnCreateNewDeviceSession;
266
293
  exports.webAuthnPostLogin = webAuthnPostLogin;
294
+ exports.webAuthnPostLoginV2 = webAuthnPostLoginV2;
267
295
  exports.webAuthnPreLogin = webAuthnPreLogin;
268
296
 
269
297
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
@@ -311,7 +339,8 @@ var _jwt = require("../jwt");
311
339
  var _users = require("../users");
312
340
 
313
341
  const _excluded = ["type"],
314
- _excluded2 = ["type"];
342
+ _excluded2 = ["type"],
343
+ _excluded3 = ["type"];
315
344
 
316
345
  async function generateLoginResponse(loginResponse) {
317
346
  if (!loginResponse.accessToken) {
@@ -390,6 +419,28 @@ async function generateLoginResponseFromOAuthResponse(oauthResponse) {
390
419
  return user;
391
420
  }
392
421
 
422
+ async function generateLoginResponseFromOAuthResponseV2(oauthResponse) {
423
+ _ContextHolder.ContextHolder.setAccessToken(oauthResponse.id_token);
424
+
425
+ const [me, currentUserTenants] = await Promise.all([(0, _fetch.Get)(`${_constants.urls.identity.users.v2}/me`), (0, _users.getCurrentUserTenantsV3)()]);
426
+ const decodedContent = oauthResponse.id_token ? (0, _jwt.jwtDecode)(oauthResponse.id_token) : {};
427
+ const user = (0, _extends2.default)({
428
+ mfaRequired: false,
429
+ accessToken: oauthResponse.id_token,
430
+ refreshToken: oauthResponse.refresh_token
431
+ }, decodedContent, me, {
432
+ expiresIn: oauthResponse.expires_in || 300
433
+ });
434
+
435
+ _ContextHolder.ContextHolder.setUser(user);
436
+
437
+ return {
438
+ user,
439
+ tenants: currentUserTenants.tenants,
440
+ activeTenant: currentUserTenants.activeTenant
441
+ };
442
+ }
443
+
393
444
  async function preLogin(body) {
394
445
  try {
395
446
  const {
@@ -420,15 +471,30 @@ async function login(body) {
420
471
  return generateLoginResponse(data);
421
472
  }
422
473
 
474
+ async function loginv2(body) {
475
+ const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user`, body);
476
+ return generateLoginResponseV3(data);
477
+ }
478
+
423
479
  async function loginWithMfa(body) {
424
480
  const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/verify`, body);
425
481
  return generateLoginResponse(data);
426
482
  }
427
483
 
484
+ async function loginWithMfaV2(body) {
485
+ const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/verify`, body);
486
+ return generateLoginResponseV3(data);
487
+ }
488
+
428
489
  async function activateAccount(body) {
429
490
  return (0, _fetch.Post)(`${_constants.urls.identity.users.v1}/activate`, body);
430
491
  }
431
492
 
493
+ async function activateAccountV2(body) {
494
+ const data = await (0, _fetch.Post)(`${_constants.urls.identity.users.v1}/activate`, body);
495
+ return generateLoginResponseV3(data);
496
+ }
497
+
432
498
  async function getActivateAccountStrategy(params) {
433
499
  return (0, _fetch.Get)(`${_constants.urls.identity.users.v1}/activate/strategy`, params);
434
500
  }
@@ -552,6 +618,11 @@ async function enrollMFAAuthenticatorAppForLogin(body) {
552
618
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/authenticator/enroll/verify`, body);
553
619
  }
554
620
 
621
+ async function enrollMFAAuthenticatorAppForLoginV2(body) {
622
+ const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/authenticator/enroll/verify`, body);
623
+ return generateLoginResponseV3(data);
624
+ }
625
+
555
626
  async function verifyMFAAuthenticatorAppForLogin(deviceId, body) {
556
627
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/authenticator/${deviceId}/verify`, body);
557
628
  }
@@ -564,6 +635,11 @@ async function verifyMFAEmailCode(body) {
564
635
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/emailcode/verify`, body);
565
636
  }
566
637
 
638
+ async function verifyMFAEmailCodeV2(body) {
639
+ const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/emailcode/verify`, body);
640
+ return generateLoginResponseV3(data);
641
+ }
642
+
567
643
  async function preEnrollMFASMSForLogin(body) {
568
644
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/sms/enroll`, body);
569
645
  }
@@ -572,6 +648,11 @@ async function enrollMFASMSForLogin(body) {
572
648
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/sms/enroll/verify`, body);
573
649
  }
574
650
 
651
+ async function enrollMFASMSForLoginV2(body) {
652
+ const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/sms/enroll/verify`, body);
653
+ return generateLoginResponseV3(data);
654
+ }
655
+
575
656
  async function preVerifyMFASMSForLogin(deviceId, body) {
576
657
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/sms/${deviceId}`, body);
577
658
  }
@@ -580,6 +661,11 @@ async function verifyMFASMSForLogin(deviceId, body) {
580
661
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/sms/${deviceId}/verify`, body);
581
662
  }
582
663
 
664
+ async function verifyMFASMSForLoginV2(deviceId, body) {
665
+ const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/sms/${deviceId}/verify`, body);
666
+ return generateLoginResponseV3(data);
667
+ }
668
+
583
669
  async function preEnrollMFAWebAuthnForLogin(body) {
584
670
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/webauthn/enroll`, body);
585
671
  }
@@ -588,6 +674,11 @@ async function enrollMFAWebAuthnForLogin(body) {
588
674
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/webauthn/enroll/verify`, body);
589
675
  }
590
676
 
677
+ async function enrollMFAWebAuthnForLoginV2(body) {
678
+ const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/webauthn/enroll/verify`, body);
679
+ return generateLoginResponseV3(data);
680
+ }
681
+
591
682
  async function preVerifyMFAWebAuthnForLogin(deviceId, body) {
592
683
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/webauthn/${deviceId}`, body);
593
684
  }
@@ -596,6 +687,11 @@ async function verifyMFAWebAuthnForLogin(deviceId, body) {
596
687
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/webauthn/${deviceId}/verify`, body);
597
688
  }
598
689
 
690
+ async function verifyMFAWebAuthnForLoginV2(deviceId, body) {
691
+ const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/mfa/webauthn/${deviceId}/verify`, body);
692
+ return generateLoginResponseV3(data);
693
+ }
694
+
599
695
  async function getSamlConfiguration() {
600
696
  return (0, _fetch.Get)(`${_constants.urls.team.sso.v1}/saml/configurations`);
601
697
  }
@@ -734,13 +830,26 @@ async function signUpUser(body) {
734
830
  userId,
735
831
  tenantId
736
832
  } = await (0, _fetch.Post)(`${_constants.urls.identity.users.v1}/signUp`, body);
737
- const loginResponse = !shouldActivate && authResponse ? await generateLoginResponse(authResponse) : undefined;
738
- return {
833
+ const response = {
739
834
  shouldActivate,
740
- user: loginResponse,
741
835
  userId,
742
836
  tenantId
743
837
  };
838
+
839
+ if (!shouldActivate && authResponse) {
840
+ const {
841
+ user,
842
+ tenants,
843
+ activeTenant
844
+ } = await generateLoginResponseV3(authResponse);
845
+ return (0, _extends2.default)({}, response, {
846
+ user,
847
+ tenants,
848
+ activeTenant
849
+ });
850
+ }
851
+
852
+ return response;
744
853
  }
745
854
 
746
855
  async function getCurrentUserSessions() {
@@ -849,11 +958,20 @@ async function passwordlessPreLogin(_ref) {
849
958
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/passwordless/${type.toLocaleLowerCase()}/prelogin`, body);
850
959
  }
851
960
 
852
- async function passwordlessPostLogin(_ref2) {
961
+ async function passwordlessPostLoginV2(_ref2) {
853
962
  let {
854
963
  type
855
964
  } = _ref2,
856
965
  body = (0, _objectWithoutPropertiesLoose2.default)(_ref2, _excluded2);
966
+ const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/passwordless/${type.toLocaleLowerCase()}/postlogin`, body);
967
+ return generateLoginResponseV3(data);
968
+ }
969
+
970
+ async function passwordlessPostLogin(_ref3) {
971
+ let {
972
+ type
973
+ } = _ref3,
974
+ body = (0, _objectWithoutPropertiesLoose2.default)(_ref3, _excluded3);
857
975
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/passwordless/${type.toLocaleLowerCase()}/postlogin`, body);
858
976
  }
859
977
 
@@ -941,6 +1059,16 @@ async function oidcPostLoginV2(body) {
941
1059
  return generateLoginResponse(data);
942
1060
  }
943
1061
 
1062
+ async function exchangeOAuthTokensV2(body) {
1063
+ const data = await (0, _fetch.Post)(`${_constants.urls.oauth.v1}/token`, body);
1064
+ return generateLoginResponseFromOAuthResponseV2(data);
1065
+ }
1066
+
1067
+ async function silentOAuthRefreshTokenV2() {
1068
+ const data = await (0, _fetch.Post)(`${_constants.urls.oauth.v1}/authorize/silent`);
1069
+ return generateLoginResponseFromOAuthResponseV2(data);
1070
+ }
1071
+
944
1072
  async function exchangeOAuthTokens(body) {
945
1073
  const data = await (0, _fetch.Post)(`${_constants.urls.oauth.v1}/token`, body);
946
1074
  return generateLoginResponseFromOAuthResponse(data);
@@ -979,6 +1107,11 @@ async function webAuthnPostLogin(body) {
979
1107
  return (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/webauthn/postlogin`, body);
980
1108
  }
981
1109
 
1110
+ async function webAuthnPostLoginV2(body) {
1111
+ const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/webauthn/postlogin`, body);
1112
+ return generateLoginResponseV3(data);
1113
+ }
1114
+
982
1115
  async function webAuthnCreateNewDeviceSession() {
983
1116
  return (0, _fetch.Post)(_constants.urls.identity.webAuthnDevices.v1);
984
1117
  }
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v3.0.132
1
+ /** @license Frontegg v3.0.134
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.132",
3
+ "version": "3.0.134",
4
4
  "main": "./node/index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {