@frontegg/rest-api 3.2.2-alpha.11551682009 → 3.2.3
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/FetchClient.js +5 -2
- package/auth/index.d.ts +16 -4
- package/auth/index.js +9 -0
- package/auth/interfaces.d.ts +6 -0
- package/index.js +1 -1
- package/interfaces.d.ts +1 -0
- package/node/FetchClient.js +5 -2
- package/node/auth/index.js +9 -0
- package/node/index.js +1 -1
- package/package.json +1 -1
package/FetchClient.js
CHANGED
|
@@ -124,12 +124,15 @@ export class FetchClient {
|
|
|
124
124
|
const context = this.getFronteggContext().getContext();
|
|
125
125
|
const headers = await this.buildRequestHeaders(opts.contentType);
|
|
126
126
|
const url = await this.prepareUrl(opts.url, opts.params);
|
|
127
|
-
const
|
|
127
|
+
const interceptor = context.beforeRequestInterceptor;
|
|
128
|
+
const initialRequestOptions = {
|
|
128
129
|
body: opts.body ? opts.contentType === 'application/json' ? JSON.stringify(opts.body) : opts.body : null,
|
|
129
130
|
method: (_opts$method = opts.method) != null ? _opts$method : 'GET',
|
|
130
131
|
headers: _extends({}, headers, opts.headers),
|
|
131
132
|
credentials: (_ref = (_opts$credentials = opts.credentials) != null ? _opts$credentials : context.requestCredentials) != null ? _ref : 'same-origin'
|
|
132
|
-
}
|
|
133
|
+
};
|
|
134
|
+
const requestOptions = interceptor ? interceptor(initialRequestOptions) : initialRequestOptions;
|
|
135
|
+
const response = await fetch(url, requestOptions);
|
|
133
136
|
|
|
134
137
|
if (response.status === 302) {
|
|
135
138
|
window.location.href = await response.text();
|
package/auth/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export * from "./enums";
|
|
|
3
3
|
export { FRONTEGG_SEPARATE_TABS_BY_TENANT } from "./constants";
|
|
4
4
|
export { setTabTenantInSessionStorage, getTabTenantFromSessionStorage, getCurrentUserTenantsFunction, removeTabTenantFromSessionStorage } from './utils';
|
|
5
5
|
import { ISamlRolesGroup } from "../teams/interfaces";
|
|
6
|
-
import { IAcceptInvitation, IActivateAccount, IAllowedToRememberMfaDevice, ICreateSamlGroup, IDeleteApiToken, IDisableMfa, IEnrollMfaResponse, IForgotPassword, IGetActivateAccountStrategy, IGetActivateAccountStrategyResponse, IGetUserById, IGetUserPasswordConfig, ILogin, ILoginResponse, ILoginViaSocialLogin, ILoginViaSocialLoginResponse, ILoginWithMfa, IOidcPostLogin, IOidcConfiguration, IPostLogin, IPreLogin, IRecoverMFAToken, IResendActivationEmail, IResetPassword, ISamlConfiguration, ISamlVendorConfigResponse, ISignUpResponse, ISignUpUser, ISocialLoginProviderConfiguration, ITenantApiTokensData, IUpdateSamlConfiguration, IUpdateSamlGroup, IUpdateSamlRoles, IUpdateSamlVendorMetadata, IUpdateTenantApiTokensData, IUpdateUserApiTokensData, IUserApiTokensData, IUserIdResponse, IVendorConfig, IVerifyMfa, IVerifyMfaResponse, TestConfig, ISSOPublicConfiguration, IPreLoginWithIdpTypeResponse, IPasswordlessPreLogin, IPasswordlessPostLogin, ICreateSSODomain, IVerifyInviteToken, ISSODomain, ISSOConfigurationDefaultRoles, ISSOConfiguration, IUpdateSSOConfiguration, IOidcPostLoginV2, IExchangeOAuthTokens, IOAuthTokenResponse, ISocialLoginProviderConfigurationV2, ILoginResponseV2, IResetPhoneNumber, IVerifyResetPhoneNumber, IChangePhoneNumber, IVerifyResetPhoneNumberResponse, IResetPhoneNumberResponse, IWebAuthnPreLogin, IWebAuthnPostLogin, IVerifyNewWebAuthnDevice, IWebAuthnPreLoginResponse, ICreateNewDeviceSessionResponse, IAuthStrategiesConfig, ISessionResponse, IChangePhoneNumberWithVerification, IChangePhoneNumberWithVerificationResponse, IVerifyChangePhoneNumber, ISessionConfigurations, IResendInvitationEmail, IPreEnrollMFA, IEnrollMFAAuthenticatorApp, IPreEnrollMFASMS, IEnrollMFASMS, IEnrollMFAWebAuthn, IPreEnrollMFAAuthenticatorAppResponse, IPreEnrollMFAWebAuthnResponse, IVerifyMFAAuthenticatorApp, IPreVerifyMFA, IPreVerifyMFASMSResponse, IVerifyMFASMS, IPreVerifyMFAWebAuthnResponse, IVerifyMFAWebAuthn, IPreEnrollMFASMSResponse, IPreDisableMFASMSResponse, IDisableMFASMS, IDisableMFAWebAuthn, IPreDisableMFAWebAuthnResponse, UserMFADevicesResponse, WithoutMFAToken, IMFAStrategiesResponse, IOAuthLogout, IGetUserAccessTokens, IGetTenantAccessTokens, IDeleteAccessToken, ICreateTenantAccessTokenData, ICreateUserAccessTokenData, IWebAuthnDevices, ICustomSocialLoginProviderConfigurationV1, ILoginResponseV3, IPreVerifyMFAEmailCodeResponse, IVerifyMFAEmailCode, ICreateOrUpdateSSOConfigurationByMetadataUrl, GenerateStepUpRequest, GenerateStepUpResponse } from './interfaces';
|
|
6
|
+
import { IAcceptInvitation, IAcceptInvitationWithOTC, IActivateAccount, IActivateAccountWithOTC, IAllowedToRememberMfaDevice, ICreateSamlGroup, IDeleteApiToken, IDisableMfa, IEnrollMfaResponse, IForgotPassword, IGetActivateAccountStrategy, IGetActivateAccountStrategyResponse, IGetUserById, IGetUserPasswordConfig, ILogin, ILoginResponse, ILoginViaSocialLogin, ILoginViaSocialLoginResponse, ILoginWithMfa, IOidcPostLogin, IOidcConfiguration, IPostLogin, IPreLogin, IRecoverMFAToken, IResendActivationEmail, IResetPassword, ISamlConfiguration, ISamlVendorConfigResponse, ISignUpResponse, ISignUpUser, ISocialLoginProviderConfiguration, ITenantApiTokensData, IUpdateSamlConfiguration, IUpdateSamlGroup, IUpdateSamlRoles, IUpdateSamlVendorMetadata, IUpdateTenantApiTokensData, IUpdateUserApiTokensData, IUserApiTokensData, IUserIdResponse, IVendorConfig, IVerifyMfa, IVerifyMfaResponse, TestConfig, ISSOPublicConfiguration, IPreLoginWithIdpTypeResponse, IPasswordlessPreLogin, IPasswordlessPostLogin, ICreateSSODomain, IVerifyInviteToken, ISSODomain, ISSOConfigurationDefaultRoles, ISSOConfiguration, IUpdateSSOConfiguration, IOidcPostLoginV2, IExchangeOAuthTokens, IOAuthTokenResponse, ISocialLoginProviderConfigurationV2, ILoginResponseV2, IResetPhoneNumber, IVerifyResetPhoneNumber, IChangePhoneNumber, IVerifyResetPhoneNumberResponse, IResetPhoneNumberResponse, IWebAuthnPreLogin, IWebAuthnPostLogin, IVerifyNewWebAuthnDevice, IWebAuthnPreLoginResponse, ICreateNewDeviceSessionResponse, IAuthStrategiesConfig, ISessionResponse, IChangePhoneNumberWithVerification, IChangePhoneNumberWithVerificationResponse, IVerifyChangePhoneNumber, ISessionConfigurations, IResendInvitationEmail, IPreEnrollMFA, IEnrollMFAAuthenticatorApp, IPreEnrollMFASMS, IEnrollMFASMS, IEnrollMFAWebAuthn, IPreEnrollMFAAuthenticatorAppResponse, IPreEnrollMFAWebAuthnResponse, IVerifyMFAAuthenticatorApp, IPreVerifyMFA, IPreVerifyMFASMSResponse, IVerifyMFASMS, IPreVerifyMFAWebAuthnResponse, IVerifyMFAWebAuthn, IPreEnrollMFASMSResponse, IPreDisableMFASMSResponse, IDisableMFASMS, IDisableMFAWebAuthn, IPreDisableMFAWebAuthnResponse, UserMFADevicesResponse, WithoutMFAToken, IMFAStrategiesResponse, IOAuthLogout, IGetUserAccessTokens, IGetTenantAccessTokens, IDeleteAccessToken, ICreateTenantAccessTokenData, ICreateUserAccessTokenData, IWebAuthnDevices, ICustomSocialLoginProviderConfigurationV1, ILoginResponseV3, IPreVerifyMFAEmailCodeResponse, IVerifyMFAEmailCode, ICreateOrUpdateSSOConfigurationByMetadataUrl, GenerateStepUpRequest, GenerateStepUpResponse } from './interfaces';
|
|
7
7
|
import { IGetUserAuthorizationResponse, IUserProfile } from "../users/interfaces";
|
|
8
8
|
import { BaseApiClient } from '../BaseApiClient';
|
|
9
9
|
import { SecurityPolicyApi } from './secutiry-poilicy';
|
|
@@ -87,6 +87,12 @@ export declare class AuthenticationApi extends BaseApiClient {
|
|
|
87
87
|
* @throws exception if activation failed
|
|
88
88
|
*/
|
|
89
89
|
activateAccountV2: (body: IActivateAccount) => Promise<ILoginResponseV3>;
|
|
90
|
+
/**
|
|
91
|
+
* activating account should be called after registering new user or deactivating account
|
|
92
|
+
* ``activateAccount`` should contains userId, code and the token that has been sent to the user after activation requested.
|
|
93
|
+
* @throws exception if activation failed
|
|
94
|
+
*/
|
|
95
|
+
activateAccountWithOTC: (body: IActivateAccountWithOTC) => Promise<ILoginResponseV3>;
|
|
90
96
|
/**
|
|
91
97
|
* get account activation configuration.
|
|
92
98
|
*/
|
|
@@ -104,11 +110,17 @@ export declare class AuthenticationApi extends BaseApiClient {
|
|
|
104
110
|
*/
|
|
105
111
|
resendInvitationEmail: (body: IResendInvitationEmail) => Promise<void>;
|
|
106
112
|
/**
|
|
107
|
-
*
|
|
108
|
-
* ``
|
|
109
|
-
* @throws exception if
|
|
113
|
+
* accepting invitation should be called after inviting user to new account
|
|
114
|
+
* ``acceptInvitation`` should contains userId and the token that has been sent to the user after invitation requested.
|
|
115
|
+
* @throws exception if accept invitation failed
|
|
110
116
|
*/
|
|
111
117
|
acceptInvitation: (body: IAcceptInvitation) => Promise<void>;
|
|
118
|
+
/**
|
|
119
|
+
* accepting invitation should be called after inviting user to new account
|
|
120
|
+
* ``acceptInvitation`` should contains userId, code and the token that has been sent to the user after invitation requested.
|
|
121
|
+
* @throws exception if accept invitation failed
|
|
122
|
+
*/
|
|
123
|
+
acceptInvitationWithOTC: (body: IAcceptInvitationWithOTC) => Promise<void>;
|
|
112
124
|
/**
|
|
113
125
|
* refresh token called as authenticated use, access and refresh tokens resolved by the cookies.
|
|
114
126
|
* the server will return ILoginResponse with new access Token and refresh token and store it in the browser cookies.
|
package/auth/index.js
CHANGED
|
@@ -190,6 +190,11 @@ export class AuthenticationApi extends BaseApiClient {
|
|
|
190
190
|
return this.generateLoginResponseV3(data);
|
|
191
191
|
};
|
|
192
192
|
|
|
193
|
+
this.activateAccountWithOTC = async body => {
|
|
194
|
+
const data = await this.post(`${urls.identity.users.v1}/activate/code`, body);
|
|
195
|
+
return this.generateLoginResponseV3(data);
|
|
196
|
+
};
|
|
197
|
+
|
|
193
198
|
this.getActivateAccountStrategy = async params => {
|
|
194
199
|
return this.get(`${urls.identity.users.v1}/activate/strategy`, params);
|
|
195
200
|
};
|
|
@@ -206,6 +211,10 @@ export class AuthenticationApi extends BaseApiClient {
|
|
|
206
211
|
return this.post(`${urls.identity.users.v1}/invitation/accept`, body);
|
|
207
212
|
};
|
|
208
213
|
|
|
214
|
+
this.acceptInvitationWithOTC = async body => {
|
|
215
|
+
return this.post(`${urls.identity.users.v1}/invitation/accept/code`, body);
|
|
216
|
+
};
|
|
217
|
+
|
|
209
218
|
this.refreshToken = async () => {
|
|
210
219
|
const tabTenantId = getTabTenantFromSessionStorage(this.appName);
|
|
211
220
|
const data = await this.post(`${urls.identity.auth.v1}/user/token/refresh`, {
|
package/auth/interfaces.d.ts
CHANGED
|
@@ -77,10 +77,16 @@ export declare type IActivateAccount = {
|
|
|
77
77
|
recaptchaToken?: string;
|
|
78
78
|
lastTermsCheck?: string;
|
|
79
79
|
};
|
|
80
|
+
export declare type IActivateAccountWithOTC = {
|
|
81
|
+
code: string;
|
|
82
|
+
} & IActivateAccount;
|
|
80
83
|
export declare type IAcceptInvitation = {
|
|
81
84
|
userId: string;
|
|
82
85
|
token: string;
|
|
83
86
|
};
|
|
87
|
+
export declare type IAcceptInvitationWithOTC = IAcceptInvitation & {
|
|
88
|
+
code: string;
|
|
89
|
+
};
|
|
84
90
|
export declare type IResendActivationEmail = {
|
|
85
91
|
email: string;
|
|
86
92
|
};
|
package/index.js
CHANGED
package/interfaces.d.ts
CHANGED
|
@@ -71,6 +71,7 @@ export interface ContextOptions {
|
|
|
71
71
|
* @returns `{ tenant: string | null }`
|
|
72
72
|
*/
|
|
73
73
|
tenantResolver?: () => Promise<ResolvedTenantResult> | ResolvedTenantResult;
|
|
74
|
+
beforeRequestInterceptor?: (opts: Omit<RequestOptions, 'url'>) => RequestOptions;
|
|
74
75
|
additionalQueryParamsResolver?: () => Promise<KeyValuePair[]> | KeyValuePair[];
|
|
75
76
|
additionalHeadersResolver?: () => Promise<KeyValuePair[]> | KeyValuePair[];
|
|
76
77
|
currentUserRoles?: string[];
|
package/node/FetchClient.js
CHANGED
|
@@ -138,12 +138,15 @@ class FetchClient {
|
|
|
138
138
|
const context = this.getFronteggContext().getContext();
|
|
139
139
|
const headers = await this.buildRequestHeaders(opts.contentType);
|
|
140
140
|
const url = await this.prepareUrl(opts.url, opts.params);
|
|
141
|
-
const
|
|
141
|
+
const interceptor = context.beforeRequestInterceptor;
|
|
142
|
+
const initialRequestOptions = {
|
|
142
143
|
body: opts.body ? opts.contentType === 'application/json' ? JSON.stringify(opts.body) : opts.body : null,
|
|
143
144
|
method: (_opts$method = opts.method) != null ? _opts$method : 'GET',
|
|
144
145
|
headers: (0, _extends2.default)({}, headers, opts.headers),
|
|
145
146
|
credentials: (_ref = (_opts$credentials = opts.credentials) != null ? _opts$credentials : context.requestCredentials) != null ? _ref : 'same-origin'
|
|
146
|
-
}
|
|
147
|
+
};
|
|
148
|
+
const requestOptions = interceptor ? interceptor(initialRequestOptions) : initialRequestOptions;
|
|
149
|
+
const response = await fetch(url, requestOptions);
|
|
147
150
|
|
|
148
151
|
if (response.status === 302) {
|
|
149
152
|
window.location.href = await response.text();
|
package/node/auth/index.js
CHANGED
|
@@ -273,6 +273,11 @@ class AuthenticationApi extends _BaseApiClient.BaseApiClient {
|
|
|
273
273
|
return this.generateLoginResponseV3(data);
|
|
274
274
|
};
|
|
275
275
|
|
|
276
|
+
this.activateAccountWithOTC = async body => {
|
|
277
|
+
const data = await this.post(`${_constants2.urls.identity.users.v1}/activate/code`, body);
|
|
278
|
+
return this.generateLoginResponseV3(data);
|
|
279
|
+
};
|
|
280
|
+
|
|
276
281
|
this.getActivateAccountStrategy = async params => {
|
|
277
282
|
return this.get(`${_constants2.urls.identity.users.v1}/activate/strategy`, params);
|
|
278
283
|
};
|
|
@@ -289,6 +294,10 @@ class AuthenticationApi extends _BaseApiClient.BaseApiClient {
|
|
|
289
294
|
return this.post(`${_constants2.urls.identity.users.v1}/invitation/accept`, body);
|
|
290
295
|
};
|
|
291
296
|
|
|
297
|
+
this.acceptInvitationWithOTC = async body => {
|
|
298
|
+
return this.post(`${_constants2.urls.identity.users.v1}/invitation/accept/code`, body);
|
|
299
|
+
};
|
|
300
|
+
|
|
292
301
|
this.refreshToken = async () => {
|
|
293
302
|
const tabTenantId = (0, _utils.getTabTenantFromSessionStorage)(this.appName);
|
|
294
303
|
const data = await this.post(`${_constants2.urls.identity.auth.v1}/user/token/refresh`, {
|
package/node/index.js
CHANGED