@frontegg/rest-api 2.10.45 → 2.10.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/auth/index.d.ts +9 -2
  3. package/dist/auth/index.js +36 -3
  4. package/dist/auth/index.js.map +1 -1
  5. package/dist/auth/interfaces.d.ts +20 -0
  6. package/dist/constants.d.ts +7 -0
  7. package/dist/constants.js +9 -2
  8. package/dist/constants.js.map +1 -1
  9. package/dist/es2015/auth/index.d.ts +9 -2
  10. package/dist/es2015/auth/index.js +31 -1
  11. package/dist/es2015/auth/index.js.map +1 -1
  12. package/dist/es2015/auth/interfaces.d.ts +20 -0
  13. package/dist/es2015/constants.d.ts +7 -0
  14. package/dist/es2015/constants.js +9 -2
  15. package/dist/es2015/constants.js.map +1 -1
  16. package/dist/es2015/fetch.d.ts +2 -0
  17. package/dist/es2015/fetch.js +11 -13
  18. package/dist/es2015/fetch.js.map +1 -1
  19. package/dist/es2015/interfaces.d.ts +1 -0
  20. package/dist/es2015/jwt.js.map +1 -1
  21. package/dist/es2015/teams/interfaces.d.ts +5 -0
  22. package/dist/es2015/tenants/index.d.ts +7 -1
  23. package/dist/es2015/tenants/index.js +11 -0
  24. package/dist/es2015/tenants/index.js.map +1 -1
  25. package/dist/es2015/tenants/interfaces.d.ts +5 -0
  26. package/dist/fetch.d.ts +2 -0
  27. package/dist/fetch.js +12 -13
  28. package/dist/fetch.js.map +1 -1
  29. package/dist/interfaces.d.ts +1 -0
  30. package/dist/jwt.js.map +1 -1
  31. package/dist/teams/interfaces.d.ts +5 -0
  32. package/dist/tenants/index.d.ts +7 -1
  33. package/dist/tenants/index.js +13 -1
  34. package/dist/tenants/index.js.map +1 -1
  35. package/dist/tenants/interfaces.d.ts +5 -0
  36. package/dist/umd/index.js +67 -16
  37. package/package.json +1 -1
  38. package/src/auth/index.ts +51 -2
  39. package/src/auth/interfaces.ts +23 -0
  40. package/src/constants.ts +9 -2
  41. package/src/fetch.ts +2 -2
  42. package/src/interfaces.ts +1 -0
  43. package/src/jwt.ts +1 -1
  44. package/src/teams/interfaces.ts +6 -0
  45. package/src/tenants/index.ts +12 -1
  46. package/src/tenants/interfaces.ts +6 -0
@@ -143,6 +143,15 @@ export interface ISocialLoginProviderConfiguration {
143
143
  active: boolean;
144
144
  }
145
145
 
146
+ export interface ISocialLoginProviderConfigurationV2 {
147
+ type: SocialLoginProviders;
148
+ clientId?: string | null;
149
+ redirectUrl: string;
150
+ active: boolean;
151
+ authorizationUrl?: string | null;
152
+ customised: boolean;
153
+ }
154
+
146
155
  export interface ILoginViaSocialLogin {
147
156
  code: string;
148
157
  redirectUri?: string;
@@ -151,6 +160,7 @@ export interface ILoginViaSocialLogin {
151
160
  codeVerifier?: string;
152
161
  metadata?: string;
153
162
  invitationToken?: string;
163
+ state?: string
154
164
  }
155
165
 
156
166
  export interface ILoginViaSocialLoginResponse {
@@ -315,4 +325,17 @@ export interface ISSOConfiguration {
315
325
  groups: ISamlRolesGroup[]
316
326
  }
317
327
 
328
+ export interface IExchangeOAuthTokens {
329
+ code: string;
330
+ redirect_uri: string;
331
+ code_verifier: string;
332
+ }
333
+
334
+ export interface IOAuthTokenResponse {
335
+ access_token: string;
336
+ expires_in?: number;
337
+ id_token: string;
338
+ refresh_token: string;
339
+ }
340
+
318
341
  export type IUpdateSSOConfiguration = Partial<Omit<ISSOConfiguration, 'id' | 'createdAt' | 'updatedAt' | 'domains'>>
package/src/constants.ts CHANGED
@@ -16,7 +16,8 @@ export const urls = {
16
16
  v1: '/identity/resources/configurations/v1'
17
17
  },
18
18
  sso: {
19
- v1: '/identity/resources/sso/v1'
19
+ v1: '/identity/resources/sso/v1',
20
+ v2: '/identity/resources/sso/v2'
20
21
  },
21
22
  permissions: {
22
23
  v1: '/identity/resources/permissions/v1'
@@ -63,6 +64,9 @@ export const urls = {
63
64
  tenants: {
64
65
  accountSettings: {
65
66
  v1: '/tenants/resources/account-settings/v1'
67
+ },
68
+ hierarchy: {
69
+ v1: '/tenants/resources/hierarchy/v1'
66
70
  }
67
71
  },
68
72
  integrations: {
@@ -134,5 +138,8 @@ export const urls = {
134
138
  },
135
139
  webhooks: {
136
140
  v1: '/webhook'
137
- }
141
+ },
142
+ oauth: {
143
+ v1: '/oauth'
144
+ },
138
145
  }
package/src/fetch.ts CHANGED
@@ -13,7 +13,7 @@ interface RequestOptions {
13
13
  credentials?: RequestCredentials;
14
14
  }
15
15
 
16
- async function getBaseUrl(context: ContextOptions): Promise<string> {
16
+ export function getBaseUrl(context: ContextOptions): string {
17
17
  let baseUrl = context.baseUrl;
18
18
  const prefix = context.urlPrefix || 'frontegg';
19
19
  if (!baseUrl.endsWith('/')) {
@@ -26,7 +26,7 @@ async function getBaseUrl(context: ContextOptions): Promise<string> {
26
26
  }
27
27
 
28
28
  async function prepareUrl(context: ContextOptions, url: string, params?: any): Promise<string> {
29
- const baseUrl = await getBaseUrl(context);
29
+ const baseUrl = getBaseUrl(context);
30
30
  const paramsToSend = await buildQueryParams(context, params);
31
31
 
32
32
  let finalUrl = url.startsWith('http') ? url : `${baseUrl}${url}`;
package/src/interfaces.ts CHANGED
@@ -17,6 +17,7 @@ export type LogLevel = 'warn' | 'error';
17
17
 
18
18
  export interface ContextOptions {
19
19
  baseUrl: string;
20
+ clientId?: string;
20
21
  tokenResolver?: () => Promise<string> | string; // custom resolve Authorization Header value
21
22
  additionalQueryParamsResolver?: () => Promise<KeyValuePair[]> | KeyValuePair[];
22
23
  additionalHeadersResolver?: () => Promise<KeyValuePair[]> | KeyValuePair[];
package/src/jwt.ts CHANGED
@@ -87,6 +87,6 @@ export const jwtDecode = (token: string, options: { header?: boolean } = {}) =>
87
87
  try {
88
88
  return JSON.parse(base64UrlDecode(token.split('.')[pos]));
89
89
  } catch (e) {
90
- throw new InvalidTokenError('Invalid token specified: ' + e.message);
90
+ throw new InvalidTokenError('Invalid token specified: ' + (e as Error).message);
91
91
  }
92
92
  };
@@ -20,6 +20,11 @@ export type IUserProfile = {
20
20
  superUser?: boolean;
21
21
  };
22
22
 
23
+ export type ITeamUserTenant = {
24
+ tenantId: string;
25
+ roles: IRole[]
26
+ }
27
+
23
28
  export type ITeamUser = {
24
29
  // info
25
30
  id: string;
@@ -40,6 +45,7 @@ export type ITeamUser = {
40
45
  customData?: any;
41
46
  lastLogin?: string;
42
47
  mfaEnabled?: boolean;
48
+ tenants?: ITeamUserTenant;
43
49
  };
44
50
 
45
51
  export type ITeamUserRole = {
@@ -1,4 +1,4 @@
1
- import {ISwitchTenant, ITenantsResponse} from './interfaces';
1
+ import {ISubTenant, ISwitchTenant, ITenantsResponse} from './interfaces';
2
2
  import {Get, Put} from '../fetch';
3
3
  import {urls} from '../constants';
4
4
 
@@ -22,3 +22,14 @@ export async function getTenants(): Promise<ITenantsResponse[]> {
22
22
  console.debug('getTenants()');
23
23
  return Get(`${urls.identity.users.v2}/me/tenants`);
24
24
  }
25
+
26
+
27
+ /**
28
+ * retrieve logged in user's available sub tenants.
29
+ *
30
+ * ``authorized user``
31
+ */
32
+ export async function getSubTenants(): Promise<ISubTenant> {
33
+ console.debug('getSubTenants()');
34
+ return Get(urls.tenants.hierarchy.v1);
35
+ }
@@ -18,3 +18,9 @@ export interface ITenantsResponse {
18
18
  currency?: string;
19
19
  logo?: string;
20
20
  }
21
+
22
+ export interface ISubTenant {
23
+ tenantId: string;
24
+ tenantName?: string;
25
+ level: number;
26
+ }