@frontegg/rest-api 3.0.5 → 3.0.8

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
@@ -247,6 +247,10 @@ export declare function getCurrentUserSessions(): Promise<ISessionResponse[]>;
247
247
  * Get current user session
248
248
  */
249
249
  export declare function getCurrentUserSession(): Promise<ISessionResponse>;
250
+ /**
251
+ * Revoke sessions for user
252
+ */
253
+ export declare function revokeSessionsForUser(userId: string): Promise<void>;
250
254
  /**
251
255
  * Get session configurations
252
256
  */
package/auth/index.js CHANGED
@@ -51,7 +51,9 @@ export async function generateLoginResponseFromOAuthResponse(oauthResponse) {
51
51
  mfaRequired: false,
52
52
  accessToken: oauthResponse.id_token,
53
53
  refreshToken: oauthResponse.refresh_token
54
- }, decodedContent, me);
54
+ }, decodedContent, me, {
55
+ expiresIn: decodedContent.exp ? (new Date().getTime() - decodedContent.exp) / 1000 : 300
56
+ });
55
57
 
56
58
  ContextHolder.setUser(user);
57
59
  return user;
@@ -249,6 +251,11 @@ export async function getCurrentUserSessions() {
249
251
  export async function getCurrentUserSession() {
250
252
  return Get(`${urls.identity.users.sessions.currentUser.v1}/current`);
251
253
  }
254
+ export async function revokeSessionsForUser(userId) {
255
+ return Post(`${urls.identity.users.sessions.v1}/revoke`, {
256
+ userId
257
+ });
258
+ }
252
259
  export async function getSessionConfigurations() {
253
260
  return Get(urls.identity.users.sessions.configurations.v1);
254
261
  }
package/constants.d.ts CHANGED
@@ -15,6 +15,7 @@ export declare const urls: {
15
15
  v1: string;
16
16
  };
17
17
  sessions: {
18
+ v1: string;
18
19
  currentUser: {
19
20
  v1: string;
20
21
  };
@@ -117,6 +118,11 @@ export declare const urls: {
117
118
  tenantConfiguration: {
118
119
  v1: string;
119
120
  };
121
+ configurations: {
122
+ vendorPublicConfigurations: {
123
+ v1: string;
124
+ };
125
+ };
120
126
  paymentProviders: {
121
127
  stripe: {
122
128
  customers: {
package/constants.js CHANGED
@@ -15,6 +15,7 @@ export const urls = {
15
15
  v1: '/identity/resources/users/api-tokens/v1'
16
16
  },
17
17
  sessions: {
18
+ v1: '/identity/resources/users/sessions/v1',
18
19
  currentUser: {
19
20
  v1: '/identity/resources/users/sessions/v1/me'
20
21
  },
@@ -117,6 +118,11 @@ export const urls = {
117
118
  tenantConfiguration: {
118
119
  v1: '/subscriptions/resources/billing/tenant-configurations/v1'
119
120
  },
121
+ configurations: {
122
+ vendorPublicConfigurations: {
123
+ v1: '/subscriptions/resources/billing/configurations/vendor-public-configurations/v1'
124
+ }
125
+ },
120
126
  paymentProviders: {
121
127
  stripe: {
122
128
  customers: {
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v3.0.5
1
+ /** @license Frontegg v3.0.8
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.
@@ -49,6 +49,7 @@ var _exportNames = {
49
49
  signUpUser: true,
50
50
  getCurrentUserSessions: true,
51
51
  getCurrentUserSession: true,
52
+ revokeSessionsForUser: true,
52
53
  getSessionConfigurations: true,
53
54
  createOrUpdateSessionConfigrations: true,
54
55
  deleteSessionForUser: true,
@@ -158,6 +159,7 @@ exports.refreshTokenV2 = refreshTokenV2;
158
159
  exports.resendActivationEmail = resendActivationEmail;
159
160
  exports.resetPassword = resetPassword;
160
161
  exports.resetPhoneNumber = resetPhoneNumber;
162
+ exports.revokeSessionsForUser = revokeSessionsForUser;
161
163
  exports.setSSODefaultRoles = setSSODefaultRoles;
162
164
  exports.signUpUser = signUpUser;
163
165
  exports.updateSSOConfiguration = updateSSOConfiguration;
@@ -271,7 +273,9 @@ async function generateLoginResponseFromOAuthResponse(oauthResponse) {
271
273
  mfaRequired: false,
272
274
  accessToken: oauthResponse.id_token,
273
275
  refreshToken: oauthResponse.refresh_token
274
- }, decodedContent, me);
276
+ }, decodedContent, me, {
277
+ expiresIn: decodedContent.exp ? (new Date().getTime() - decodedContent.exp) / 1000 : 300
278
+ });
275
279
 
276
280
  _ContextHolder.ContextHolder.setUser(user);
277
281
 
@@ -511,6 +515,12 @@ async function getCurrentUserSession() {
511
515
  return (0, _fetch.Get)(`${_constants.urls.identity.users.sessions.currentUser.v1}/current`);
512
516
  }
513
517
 
518
+ async function revokeSessionsForUser(userId) {
519
+ return (0, _fetch.Post)(`${_constants.urls.identity.users.sessions.v1}/revoke`, {
520
+ userId
521
+ });
522
+ }
523
+
514
524
  async function getSessionConfigurations() {
515
525
  return (0, _fetch.Get)(_constants.urls.identity.users.sessions.configurations.v1);
516
526
  }
package/node/constants.js CHANGED
@@ -21,6 +21,7 @@ const urls = {
21
21
  v1: '/identity/resources/users/api-tokens/v1'
22
22
  },
23
23
  sessions: {
24
+ v1: '/identity/resources/users/sessions/v1',
24
25
  currentUser: {
25
26
  v1: '/identity/resources/users/sessions/v1/me'
26
27
  },
@@ -123,6 +124,11 @@ const urls = {
123
124
  tenantConfiguration: {
124
125
  v1: '/subscriptions/resources/billing/tenant-configurations/v1'
125
126
  },
127
+ configurations: {
128
+ vendorPublicConfigurations: {
129
+ v1: '/subscriptions/resources/billing/configurations/vendor-public-configurations/v1'
130
+ }
131
+ },
126
132
  paymentProviders: {
127
133
  stripe: {
128
134
  customers: {
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v3.0.5
1
+ /** @license Frontegg v3.0.8
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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.ProviderType = exports.PaymentMethodType = exports.ISubscriptionStatus = exports.ISubscriptionCancellationPolicy = void 0;
6
+ exports.TrialEndAction = exports.TenantCreatedAction = exports.ProviderType = exports.PaymentMethodType = exports.ISubscriptionStatus = exports.ISubscriptionCancellationPolicy = void 0;
7
7
  let ISubscriptionStatus;
8
8
  exports.ISubscriptionStatus = ISubscriptionStatus;
9
9
 
@@ -36,4 +36,19 @@ exports.ProviderType = ProviderType;
36
36
 
37
37
  (function (ProviderType) {
38
38
  ProviderType["Stripe"] = "Stripe";
39
- })(ProviderType || (exports.ProviderType = ProviderType = {}));
39
+ })(ProviderType || (exports.ProviderType = ProviderType = {}));
40
+
41
+ let TrialEndAction;
42
+ exports.TrialEndAction = TrialEndAction;
43
+
44
+ (function (TrialEndAction) {
45
+ TrialEndAction["CHANGE_TO_DEFAULT"] = "change_to_default";
46
+ TrialEndAction["RETAIN_TRIAL"] = "retain_trial";
47
+ })(TrialEndAction || (exports.TrialEndAction = TrialEndAction = {}));
48
+
49
+ let TenantCreatedAction;
50
+ exports.TenantCreatedAction = TenantCreatedAction;
51
+
52
+ (function (TenantCreatedAction) {
53
+ TenantCreatedAction["CREATE"] = "create_customer";
54
+ })(TenantCreatedAction || (exports.TenantCreatedAction = TenantCreatedAction = {}));
@@ -121,6 +121,19 @@ Object.keys(_paymentProviders).forEach(function (key) {
121
121
  });
122
122
  });
123
123
 
124
+ var _vendorPublicConfigurations = require("./vendorPublicConfigurations");
125
+
126
+ Object.keys(_vendorPublicConfigurations).forEach(function (key) {
127
+ if (key === "default" || key === "__esModule") return;
128
+ if (key in exports && exports[key] === _vendorPublicConfigurations[key]) return;
129
+ Object.defineProperty(exports, key, {
130
+ enumerable: true,
131
+ get: function () {
132
+ return _vendorPublicConfigurations[key];
133
+ }
134
+ });
135
+ });
136
+
124
137
  var _enums = require("./enums");
125
138
 
126
139
  Object.keys(_enums).forEach(function (key) {
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getVendorPublicConfigurations = getVendorPublicConfigurations;
7
+
8
+ var _fetch = require("../fetch");
9
+
10
+ var _constants = require("../constants");
11
+
12
+ async function getVendorPublicConfigurations() {
13
+ return (0, _fetch.Get)(`${_constants.urls.subscriptions.billing.configurations.vendorPublicConfigurations.v1}`);
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontegg/rest-api",
3
- "version": "3.0.5",
3
+ "version": "3.0.8",
4
4
  "main": "./node/index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -16,3 +16,10 @@ export declare enum ISubscriptionCancellationPolicy {
16
16
  export declare enum ProviderType {
17
17
  Stripe = "Stripe"
18
18
  }
19
+ export declare enum TrialEndAction {
20
+ CHANGE_TO_DEFAULT = "change_to_default",
21
+ RETAIN_TRIAL = "retain_trial"
22
+ }
23
+ export declare enum TenantCreatedAction {
24
+ CREATE = "create_customer"
25
+ }
@@ -26,4 +26,17 @@ export let ProviderType;
26
26
 
27
27
  (function (ProviderType) {
28
28
  ProviderType["Stripe"] = "Stripe";
29
- })(ProviderType || (ProviderType = {}));
29
+ })(ProviderType || (ProviderType = {}));
30
+
31
+ export let TrialEndAction;
32
+
33
+ (function (TrialEndAction) {
34
+ TrialEndAction["CHANGE_TO_DEFAULT"] = "change_to_default";
35
+ TrialEndAction["RETAIN_TRIAL"] = "retain_trial";
36
+ })(TrialEndAction || (TrialEndAction = {}));
37
+
38
+ export let TenantCreatedAction;
39
+
40
+ (function (TenantCreatedAction) {
41
+ TenantCreatedAction["CREATE"] = "create_customer";
42
+ })(TenantCreatedAction || (TenantCreatedAction = {}));
@@ -1,10 +1,11 @@
1
- export * from './subscriptions';
2
- export * from './managedSubscriptions';
3
- export * from './plans';
4
- export * from './invoices';
5
- export * from './paymentMethods';
6
- export * from './providers';
7
- export * from './summaries';
8
- export * from './tenantConfiguration';
9
- export * from './paymentProviders';
10
- export * from './enums';
1
+ export * from "./subscriptions";
2
+ export * from "./managedSubscriptions";
3
+ export * from "./plans";
4
+ export * from "./invoices";
5
+ export * from "./paymentMethods";
6
+ export * from "./providers";
7
+ export * from "./summaries";
8
+ export * from "./tenantConfiguration";
9
+ export * from "./paymentProviders";
10
+ export * from "./vendorPublicConfigurations";
11
+ export * from "./enums";
@@ -1,10 +1,11 @@
1
- export * from './subscriptions';
2
- export * from './managedSubscriptions';
3
- export * from './plans';
4
- export * from './invoices';
5
- export * from './paymentMethods';
6
- export * from './providers';
7
- export * from './summaries';
8
- export * from './tenantConfiguration';
9
- export * from './paymentProviders';
10
- export * from './enums';
1
+ export * from "./subscriptions";
2
+ export * from "./managedSubscriptions";
3
+ export * from "./plans";
4
+ export * from "./invoices";
5
+ export * from "./paymentMethods";
6
+ export * from "./providers";
7
+ export * from "./summaries";
8
+ export * from "./tenantConfiguration";
9
+ export * from "./paymentProviders";
10
+ export * from "./vendorPublicConfigurations";
11
+ export * from "./enums";
@@ -115,3 +115,7 @@ export interface IUpdateManagedSubscriptionRequest {
115
115
  paymentMethodId: string;
116
116
  planId: string;
117
117
  }
118
+ export interface IVendorPublicConfigurationResponse {
119
+ allowPlanDowngrade: boolean;
120
+ allowPlanCancellation: boolean;
121
+ }
@@ -0,0 +1,2 @@
1
+ import { IVendorPublicConfigurationResponse } from "./interfaces";
2
+ export declare function getVendorPublicConfigurations(): Promise<IVendorPublicConfigurationResponse[]>;
@@ -0,0 +1,5 @@
1
+ import { Get } from "../fetch";
2
+ import { urls } from "../constants";
3
+ export async function getVendorPublicConfigurations() {
4
+ return Get(`${urls.subscriptions.billing.configurations.vendorPublicConfigurations.v1}`);
5
+ }