@frontegg/rest-api 3.2.2 → 3.2.4
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/index.js +1 -1
- package/interfaces.d.ts +1 -0
- package/node/FetchClient.js +5 -2
- package/node/index.js +1 -1
- package/node/routers.js +1 -1
- package/package.json +1 -1
- package/routers.js +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/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/index.js
CHANGED
package/node/routers.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.fronteggUsersUrl = exports.fronteggTenantsV3Url = exports.fronteggTenant
|
|
|
7
7
|
|
|
8
8
|
var _constants = require("./constants");
|
|
9
9
|
|
|
10
|
-
const fronteggAuthApiRoutesRegex = [/^(.*)\/logout$/g, '/logout', /^\/identity\/resources\/auth\/v[0-9]*\/user\/[^\/]*\/postlogin$/g, /^\/identity\/resources\/impersonation\/v[0-9]$/g, /^\/identity\/resources\/auth\/v[0-9]*\/passwordless\/[^\/]*\/postlogin$/g, /^\/identity\/resources\/auth\/v[0-9]*\/webauthn\/postlogin$/g, /^\/identity\/resources\/auth\/v[0-9]*\/user$/g, /^\/identity\/resources\/auth\/v[0-9]*\/user\/token\/refresh$/g, /^\/identity\/resources\/users\/v[0-9]
|
|
10
|
+
const fronteggAuthApiRoutesRegex = [/^(.*)\/logout$/g, '/logout', /^\/identity\/resources\/auth\/v[0-9]*\/user\/[^\/]*\/postlogin$/g, /^\/identity\/resources\/impersonation\/v[0-9]$/g, /^\/identity\/resources\/auth\/v[0-9]*\/passwordless\/[^\/]*\/postlogin$/g, /^\/identity\/resources\/auth\/v[0-9]*\/webauthn\/postlogin$/g, /^\/identity\/resources\/auth\/v[0-9]*\/user$/g, /^\/identity\/resources\/auth\/v[0-9]*\/user\/token\/refresh$/g, /^\/identity\/resources\/users\/v[0-9]*\/signUp$/g, /^\/identity\/resources\/users\/v[0-9]*\/activate$/g, /^\/identity\/resources\/users\/v[0-9]*\/invitation\/accept$/g, /^\/identity\/resources\/auth\/v[0-9]*\/user\/mfa\/verify$/g, /^\/identity\/resources\/auth\/v[0-9]*\/user\/mfa\/[^\/]*\/[^\/]*\/verify$/g, /^\/oauth\/token$/g, /^\/oauth\/authorize\/silent$/g];
|
|
11
11
|
exports.fronteggAuthApiRoutesRegex = fronteggAuthApiRoutesRegex;
|
|
12
12
|
const fronteggRefreshTokenUrl = `${_constants.urls.identity.auth.v1}/user/token/refresh`;
|
|
13
13
|
exports.fronteggRefreshTokenUrl = fronteggRefreshTokenUrl;
|
package/package.json
CHANGED
package/routers.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { urls } from './constants';
|
|
2
|
-
export const fronteggAuthApiRoutesRegex = [/^(.*)\/logout$/g, '/logout', /^\/identity\/resources\/auth\/v[0-9]*\/user\/[^\/]*\/postlogin$/g, /^\/identity\/resources\/impersonation\/v[0-9]$/g, /^\/identity\/resources\/auth\/v[0-9]*\/passwordless\/[^\/]*\/postlogin$/g, /^\/identity\/resources\/auth\/v[0-9]*\/webauthn\/postlogin$/g, /^\/identity\/resources\/auth\/v[0-9]*\/user$/g, /^\/identity\/resources\/auth\/v[0-9]*\/user\/token\/refresh$/g, /^\/identity\/resources\/users\/v[0-9]
|
|
2
|
+
export const fronteggAuthApiRoutesRegex = [/^(.*)\/logout$/g, '/logout', /^\/identity\/resources\/auth\/v[0-9]*\/user\/[^\/]*\/postlogin$/g, /^\/identity\/resources\/impersonation\/v[0-9]$/g, /^\/identity\/resources\/auth\/v[0-9]*\/passwordless\/[^\/]*\/postlogin$/g, /^\/identity\/resources\/auth\/v[0-9]*\/webauthn\/postlogin$/g, /^\/identity\/resources\/auth\/v[0-9]*\/user$/g, /^\/identity\/resources\/auth\/v[0-9]*\/user\/token\/refresh$/g, /^\/identity\/resources\/users\/v[0-9]*\/signUp$/g, /^\/identity\/resources\/users\/v[0-9]*\/activate$/g, /^\/identity\/resources\/users\/v[0-9]*\/invitation\/accept$/g, /^\/identity\/resources\/auth\/v[0-9]*\/user\/mfa\/verify$/g, /^\/identity\/resources\/auth\/v[0-9]*\/user\/mfa\/[^\/]*\/[^\/]*\/verify$/g, /^\/oauth\/token$/g, /^\/oauth\/authorize\/silent$/g];
|
|
3
3
|
export const fronteggRefreshTokenUrl = `${urls.identity.auth.v1}/user/token/refresh`;
|
|
4
4
|
export const fronteggSilentRefreshTokenUrl = `${urls.oauth.v1}/authorize/silent`;
|
|
5
5
|
export const fronteggUsersUrl = `${urls.identity.users.v2}/me`;
|