@frontegg/client
Advanced tools
Comparing version 2.0.23 to 2.0.24
@@ -1,13 +0,14 @@ | ||
import { AuditsClient } from './src/audits'; | ||
import { FronteggAuthenticator } from './src/authenticator'; | ||
import { IdentityClient } from './src/identity'; | ||
import { contextResolver, withAuthentication } from './src/identity'; | ||
import { ContextHolder, frontegg, fronteggNextJs, IFronteggOptions } from './src/middleware'; | ||
import { NotificationsClient } from './src/notifications'; | ||
import { FronteggPermissions } from './src/permissions'; | ||
import { RbacMiddleware } from './src/rbac'; | ||
import { SsoClient } from './src/sso'; | ||
import { TenantsClient } from './src/tenants'; | ||
import { AuditsClient } from "./src/audits"; | ||
import { FronteggAuthenticator } from "./src/authenticator"; | ||
import { IdentityClient } from "./src/identity"; | ||
import { contextResolver, withAuthentication } from "./src/identity"; | ||
import { ContextHolder, frontegg, fronteggNextJs, IFronteggOptions } from "./src/middleware"; | ||
import { NotificationsClient } from "./src/notifications"; | ||
import { FronteggPermissions } from "./src/permissions"; | ||
import { RbacMiddleware } from "./src/rbac"; | ||
import { SsoClient } from "./src/sso"; | ||
import { TenantsClient } from "./src/tenants"; | ||
import { AuthzClient } from "./src/authz"; | ||
export * from './src/events'; | ||
export { AuditsClient, ContextHolder, NotificationsClient, TenantsClient, frontegg, fronteggNextJs, FronteggPermissions, IFronteggOptions, FronteggAuthenticator, RbacMiddleware, SsoClient, withAuthentication, contextResolver, IdentityClient, AuthzClient, }; | ||
import { HttpClient } from "./src/http"; | ||
export * from "./src/events"; | ||
export { AuditsClient, ContextHolder, NotificationsClient, TenantsClient, frontegg, fronteggNextJs, FronteggPermissions, IFronteggOptions, FronteggAuthenticator, RbacMiddleware, SsoClient, withAuthentication, contextResolver, IdentityClient, AuthzClient, HttpClient, }; |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.HttpClient = exports.AuthzClient = exports.IdentityClient = exports.contextResolver = exports.withAuthentication = exports.SsoClient = exports.RbacMiddleware = exports.FronteggAuthenticator = exports.FronteggPermissions = exports.fronteggNextJs = exports.frontegg = exports.TenantsClient = exports.NotificationsClient = exports.ContextHolder = exports.AuditsClient = void 0; | ||
var audits_1 = require("./src/audits"); | ||
exports.AuditsClient = audits_1.AuditsClient; | ||
Object.defineProperty(exports, "AuditsClient", { enumerable: true, get: function () { return audits_1.AuditsClient; } }); | ||
var authenticator_1 = require("./src/authenticator"); | ||
exports.FronteggAuthenticator = authenticator_1.FronteggAuthenticator; | ||
Object.defineProperty(exports, "FronteggAuthenticator", { enumerable: true, get: function () { return authenticator_1.FronteggAuthenticator; } }); | ||
var identity_1 = require("./src/identity"); | ||
exports.IdentityClient = identity_1.IdentityClient; | ||
Object.defineProperty(exports, "IdentityClient", { enumerable: true, get: function () { return identity_1.IdentityClient; } }); | ||
var identity_2 = require("./src/identity"); | ||
exports.contextResolver = identity_2.contextResolver; | ||
exports.withAuthentication = identity_2.withAuthentication; | ||
Object.defineProperty(exports, "contextResolver", { enumerable: true, get: function () { return identity_2.contextResolver; } }); | ||
Object.defineProperty(exports, "withAuthentication", { enumerable: true, get: function () { return identity_2.withAuthentication; } }); | ||
var middleware_1 = require("./src/middleware"); | ||
exports.ContextHolder = middleware_1.ContextHolder; | ||
exports.frontegg = middleware_1.frontegg; | ||
exports.fronteggNextJs = middleware_1.fronteggNextJs; | ||
Object.defineProperty(exports, "ContextHolder", { enumerable: true, get: function () { return middleware_1.ContextHolder; } }); | ||
Object.defineProperty(exports, "frontegg", { enumerable: true, get: function () { return middleware_1.frontegg; } }); | ||
Object.defineProperty(exports, "fronteggNextJs", { enumerable: true, get: function () { return middleware_1.fronteggNextJs; } }); | ||
var notifications_1 = require("./src/notifications"); | ||
exports.NotificationsClient = notifications_1.NotificationsClient; | ||
Object.defineProperty(exports, "NotificationsClient", { enumerable: true, get: function () { return notifications_1.NotificationsClient; } }); | ||
var permissions_1 = require("./src/permissions"); | ||
exports.FronteggPermissions = permissions_1.FronteggPermissions; | ||
Object.defineProperty(exports, "FronteggPermissions", { enumerable: true, get: function () { return permissions_1.FronteggPermissions; } }); | ||
var rbac_1 = require("./src/rbac"); | ||
exports.RbacMiddleware = rbac_1.RbacMiddleware; | ||
Object.defineProperty(exports, "RbacMiddleware", { enumerable: true, get: function () { return rbac_1.RbacMiddleware; } }); | ||
var sso_1 = require("./src/sso"); | ||
exports.SsoClient = sso_1.SsoClient; | ||
Object.defineProperty(exports, "SsoClient", { enumerable: true, get: function () { return sso_1.SsoClient; } }); | ||
var tenants_1 = require("./src/tenants"); | ||
exports.TenantsClient = tenants_1.TenantsClient; | ||
Object.defineProperty(exports, "TenantsClient", { enumerable: true, get: function () { return tenants_1.TenantsClient; } }); | ||
var authz_1 = require("./src/authz"); | ||
exports.AuthzClient = authz_1.AuthzClient; | ||
__export(require("./src/events")); | ||
Object.defineProperty(exports, "AuthzClient", { enumerable: true, get: function () { return authz_1.AuthzClient; } }); | ||
var http_1 = require("./src/http"); | ||
Object.defineProperty(exports, "HttpClient", { enumerable: true, get: function () { return http_1.HttpClient; } }); | ||
__exportStar(require("./src/events"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -14,6 +14,7 @@ "use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -50,2 +51,3 @@ }); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AuditsClient = void 0; | ||
var axios_1 = require("axios"); | ||
@@ -113,3 +115,3 @@ var authenticator_1 = require("../authenticator"); | ||
logger_1.default.info('going to get audits'); | ||
paramsToSend = __assign({}, params, params.filters); | ||
paramsToSend = __assign(__assign({}, params), params.filters); | ||
delete paramsToSend.filters; | ||
@@ -216,3 +218,3 @@ return [4 /*yield*/, this.authenticator.validateAuthentication()]; | ||
logger_1.default.info('going to export audits to pdf'); | ||
paramsToSend = __assign({}, params, params.filters); | ||
paramsToSend = __assign(__assign({}, params), params.filters); | ||
delete paramsToSend.filters; | ||
@@ -245,3 +247,3 @@ return [4 /*yield*/, this.authenticator.validateAuthentication()]; | ||
logger_1.default.info('going to export audits to pdf'); | ||
paramsToSend = __assign({}, params, params.filters); | ||
paramsToSend = __assign(__assign({}, params), params.filters); | ||
delete paramsToSend.filters; | ||
@@ -248,0 +250,0 @@ return [4 /*yield*/, this.authenticator.validateAuthentication()]; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -38,2 +39,3 @@ }); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FronteggAuthenticator = void 0; | ||
var axios_1 = require("axios"); | ||
@@ -45,6 +47,6 @@ var config_1 = require("../config"); | ||
function FronteggAuthenticator() { | ||
this.accessToken = ''; | ||
this.accessToken = ""; | ||
this.accessTokenExpiry = Date.now(); | ||
this.clientId = ''; | ||
this.apiKey = ''; | ||
this.clientId = ""; | ||
this.apiKey = ""; | ||
this.refreshTimeout = null; | ||
@@ -62,7 +64,7 @@ this.shuttingDown = false; | ||
if (process.env.FRONTEGG_AUTHENTICATOR_NUMBER_OF_TRIES) { | ||
if (isNaN(+(process.env.FRONTEGG_AUTHENTICATOR_NUMBER_OF_TRIES))) { | ||
logger_1.default.error('got invalid value for FRONTEGG_AUTHENTICATOR_NUMBER_OF_TRIES'); | ||
if (isNaN(+process.env.FRONTEGG_AUTHENTICATOR_NUMBER_OF_TRIES)) { | ||
logger_1.default.error("got invalid value for FRONTEGG_AUTHENTICATOR_NUMBER_OF_TRIES"); | ||
} | ||
else { | ||
numberOfTries = +(process.env.FRONTEGG_AUTHENTICATOR_NUMBER_OF_TRIES); | ||
numberOfTries = +process.env.FRONTEGG_AUTHENTICATOR_NUMBER_OF_TRIES; | ||
} | ||
@@ -73,4 +75,5 @@ } | ||
secondsDelayRange: { | ||
min: 0.5, max: 5 | ||
} | ||
min: 0.5, | ||
max: 5, | ||
}, | ||
})]; | ||
@@ -97,4 +100,6 @@ }); | ||
case 0: | ||
if (!(this.accessToken === '' || this.accessTokenExpiry === 0 || Date.now() >= this.accessTokenExpiry)) return [3 /*break*/, 2]; | ||
logger_1.default.info('authentication token needs refresh - going to refresh it'); | ||
if (!(this.accessToken === "" || | ||
this.accessTokenExpiry === 0 || | ||
Date.now() >= this.accessTokenExpiry)) return [3 /*break*/, 2]; | ||
logger_1.default.info("authentication token needs refresh - going to refresh it"); | ||
return [4 /*yield*/, this.refreshAuthentication()]; | ||
@@ -128,6 +133,6 @@ case 1: | ||
case 0: | ||
if (this.accessToken !== '' && !force) { | ||
if (this.accessToken !== "" && !force) { | ||
return [2 /*return*/]; | ||
} | ||
logger_1.default.info('posting authentication request'); | ||
logger_1.default.info("posting authentication request"); | ||
_b.label = 1; | ||
@@ -145,15 +150,15 @@ case 1: | ||
e_1 = _b.sent(); | ||
logger_1.default.error('Failed to authenticate with Frontegg'); | ||
logger_1.default.error("Failed to authenticate with Frontegg"); | ||
if (e_1.response) { | ||
logger_1.default.error("Failed with status - " + e_1.response.status); | ||
} | ||
this.accessToken = ''; | ||
this.accessToken = ""; | ||
this.accessTokenExpiry = 0; | ||
throw new Error('Failed to authenticate with Frontegg'); | ||
throw new Error("Failed to authenticate with Frontegg"); | ||
case 4: | ||
logger_1.default.info('authenticated with frontegg'); | ||
logger_1.default.info("authenticated with frontegg"); | ||
_a = response.data, token = _a.token, expiresIn = _a.expiresIn; | ||
// Save the token | ||
this.accessToken = token; | ||
nextRefresh = (expiresIn * 1000) * 0.8; | ||
nextRefresh = expiresIn * 1000 * 0.8; | ||
this.accessTokenExpiry = Date.now() + nextRefresh; | ||
@@ -160,0 +165,0 @@ if (!this.shuttingDown) { |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -38,2 +39,3 @@ }); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AuthzClient = void 0; | ||
var strategy_types_1 = require("./strategy-types"); | ||
@@ -40,0 +42,0 @@ var strategies_1 = require("./strategies"); |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -38,2 +39,3 @@ }); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FronteggStrategy = exports.OpaStrategy = void 0; | ||
var logger_1 = require("../helpers/logger"); | ||
@@ -40,0 +42,0 @@ var axios_1 = require("axios"); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.StrategyType = void 0; | ||
var StrategyType; | ||
@@ -4,0 +5,0 @@ (function (StrategyType) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.config = exports.baseUrl = void 0; | ||
exports.baseUrl = process.env.FRONTEGG_API_GATEWAY_URL || "https://api.frontegg.com/"; | ||
@@ -4,0 +5,0 @@ if (exports.baseUrl.endsWith('/')) { |
import { FronteggAuthenticator } from "../authenticator"; | ||
import { EventId, EventTrigger } from "./types/event-types"; | ||
import { EventStatus } from './types/status-types'; | ||
import { EventStatus } from "./types/status-types"; | ||
export declare class EventsClient { | ||
@@ -5,0 +5,0 @@ private readonly authenticator; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -38,2 +39,3 @@ }); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.EventsClient = void 0; | ||
var axios_1 = require("axios"); | ||
@@ -91,4 +93,4 @@ var config_1 = require("../config"); | ||
headers: { | ||
'x-access-token': this.authenticator.accessToken, | ||
'frontegg-tenant-id': tenantId, | ||
"x-access-token": this.authenticator.accessToken, | ||
"frontegg-tenant-id": tenantId, | ||
}, | ||
@@ -110,3 +112,3 @@ })]; | ||
headers: { | ||
'x-access-token': this.authenticator.accessToken, | ||
"x-access-token": this.authenticator.accessToken, | ||
}, | ||
@@ -113,0 +115,0 @@ })]; |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./types")); | ||
__export(require("./events")); | ||
__exportStar(require("./types"), exports); | ||
__exportStar(require("./events"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -16,2 +16,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NoEventKeyException = exports.NoDataException = void 0; | ||
var NoDataException = /** @class */ (function (_super) { | ||
@@ -18,0 +19,0 @@ __extends(NoDataException, _super); |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./errors")); | ||
__exportStar(require("./channel-configuration"), exports); | ||
__exportStar(require("./errors"), exports); | ||
__exportStar(require("./event-types"), exports); | ||
__exportStar(require("./status-types"), exports); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.contextResolverWithPermissions = exports.contextResolver = void 0; | ||
var index_1 = require("../../index"); | ||
@@ -4,0 +5,0 @@ exports.contextResolver = function (req) { |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -38,2 +39,3 @@ }); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.IdentityClient = void 0; | ||
var axios_1 = require("axios"); | ||
@@ -40,0 +42,0 @@ var jsonwebtoken_1 = require("jsonwebtoken"); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var identity_client_1 = require("./identity-client"); | ||
exports.IdentityClient = identity_client_1.IdentityClient; | ||
Object.defineProperty(exports, "IdentityClient", { enumerable: true, get: function () { return identity_client_1.IdentityClient; } }); | ||
var with_authentication_1 = require("./with-authentication"); | ||
exports.withAuthentication = with_authentication_1.withAuthentication; | ||
Object.defineProperty(exports, "withAuthentication", { enumerable: true, get: function () { return with_authentication_1.withAuthentication; } }); | ||
var contextResolver_1 = require("./contextResolver"); | ||
exports.contextResolver = contextResolver_1.contextResolver; | ||
Object.defineProperty(exports, "contextResolver", { enumerable: true, get: function () { return contextResolver_1.contextResolver; } }); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -38,2 +39,3 @@ }); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.withAuthentication = exports.tokenTypes = void 0; | ||
var identity_client_1 = require("./identity-client"); | ||
@@ -40,0 +42,0 @@ var tokenTypes; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ContextHolder = void 0; | ||
var ContextHolder = /** @class */ (function () { | ||
@@ -4,0 +5,0 @@ function ContextHolder() { |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -37,3 +38,11 @@ }); | ||
}; | ||
var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; | ||
for (var r = Array(s), k = 0, i = 0; i < il; i++) | ||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) | ||
r[k] = a[j]; | ||
return r; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.frontegg = void 0; | ||
var httpProxy = require("http-proxy"); | ||
@@ -168,3 +177,3 @@ var authenticator_1 = require("../authenticator"); | ||
catch (e) { | ||
logger_1.default.error.apply(logger_1.default, ['could not proxy request to frontegg'].concat(e)); | ||
logger_1.default.error.apply(logger_1.default, __spreadArrays(['could not proxy request to frontegg'], e)); | ||
} | ||
@@ -171,0 +180,0 @@ }); |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -37,4 +38,4 @@ }); | ||
}; | ||
var _this = this; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.fronteggNextJs = exports.rewritePath = exports.FRONTEGG_API_KEY_NEXTJS = exports.FRONTEGG_CLIENT_ID_NEXTJS = void 0; | ||
var httpProxy = require("http-proxy"); | ||
@@ -83,3 +84,3 @@ var authenticator_1 = require("../authenticator"); | ||
var authInitedPromise = authenticator.init(options.clientId, options.apiKey); | ||
return function (nextJsReq, nextJsRes) { return __awaiter(_this, void 0, void 0, function () { | ||
return function (nextJsReq, nextJsRes) { return __awaiter(void 0, void 0, void 0, function () { | ||
var pathRewrite, _a, e_1, context, e_2; | ||
@@ -86,0 +87,0 @@ return __generator(this, function (_b) { |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -38,2 +39,3 @@ }); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.fronteggRoutes = void 0; | ||
var axios_1 = require("axios"); | ||
@@ -40,0 +42,0 @@ var config_1 = require("../config"); |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./fronteggMiddleware")); | ||
__export(require("./fronteggNextJs")); | ||
__export(require("./ContextHolder")); | ||
__exportStar(require("./fronteggMiddleware"), exports); | ||
__exportStar(require("./fronteggNextJs"), exports); | ||
__exportStar(require("./types"), exports); | ||
__exportStar(require("./ContextHolder"), exports); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -37,4 +38,4 @@ }); | ||
}; | ||
var _this = this; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.retry = exports.callMiddleware = exports.enableCors = exports.rewriteCookieDomain = exports.validatePermissions = exports.flattenPermissions = exports.getUrlWithoutQueryParams = exports.FRONTEGG_API_KEY = exports.FRONTEGG_CLIENT_ID = void 0; | ||
var logger_1 = require("../helpers/logger"); | ||
@@ -194,3 +195,3 @@ var permissions_1 = require("../permissions"); | ||
var numberOfTries = _a.numberOfTries, secondsDelayRange = _a.secondsDelayRange; | ||
return __awaiter(_this, void 0, void 0, function () { | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
var res, error_1, delayTime; | ||
@@ -197,0 +198,0 @@ return __generator(this, function (_b) { |
@@ -14,6 +14,7 @@ "use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -50,2 +51,3 @@ }); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NotificationsClient = void 0; | ||
var axios_1 = require("axios"); | ||
@@ -89,3 +91,3 @@ var authenticator_1 = require("../authenticator"); | ||
} | ||
return [4 /*yield*/, this.sendNotification(__assign({}, notification, { userId: userId, tenantId: tenantId }))]; | ||
return [4 /*yield*/, this.sendNotification(__assign(__assign({}, notification), { userId: userId, tenantId: tenantId }))]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
@@ -106,3 +108,3 @@ } | ||
} | ||
return [4 /*yield*/, this.sendNotification(__assign({}, notification, { userId: null, tenantId: tenantId }))]; | ||
return [4 /*yield*/, this.sendNotification(__assign(__assign({}, notification), { userId: null, tenantId: tenantId }))]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
@@ -117,3 +119,3 @@ } | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.sendNotification(__assign({}, notification, { userId: null, tenantId: null }))]; | ||
case 0: return [4 /*yield*/, this.sendNotification(__assign(__assign({}, notification), { userId: null, tenantId: null }))]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
@@ -120,0 +122,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FronteggPermissions = void 0; | ||
var FronteggPermissions = /** @class */ (function () { | ||
@@ -4,0 +5,0 @@ function FronteggPermissions() { |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -38,2 +39,3 @@ }); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RbacMiddleware = void 0; | ||
var logger_1 = require("../helpers/logger"); | ||
@@ -40,0 +42,0 @@ function throwIfRequired(res, next, options) { |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -37,3 +38,2 @@ }); | ||
}; | ||
var _this = this; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -53,5 +53,4 @@ var axios_1 = require("axios"); | ||
}); | ||
it('should allow to pass when defined to any any', function () { return __awaiter(_this, void 0, void 0, function () { | ||
it('should allow to pass when defined to any any', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var response; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
@@ -61,3 +60,3 @@ switch (_a.label) { | ||
app.use(index_1.RbacMiddleware({ | ||
contextResolver: function (req) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { | ||
contextResolver: function (req) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { | ||
return [2 /*return*/, { roles: ['admin'] }]; | ||
@@ -82,5 +81,4 @@ }); }); }, | ||
}); }); | ||
it('should allow to pass when the actual route is defined', function () { return __awaiter(_this, void 0, void 0, function () { | ||
it('should allow to pass when the actual route is defined', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var response; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
@@ -90,3 +88,3 @@ switch (_a.label) { | ||
app.use(index_1.RbacMiddleware({ | ||
contextResolver: function (req) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { | ||
contextResolver: function (req) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { | ||
return [2 /*return*/, { roles: ['admin'] }]; | ||
@@ -115,5 +113,4 @@ }); }); }, | ||
}); }); | ||
it('should allow to pass when the actual route and method are defined', function () { return __awaiter(_this, void 0, void 0, function () { | ||
it('should allow to pass when the actual route and method are defined', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var response; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
@@ -123,3 +120,3 @@ switch (_a.label) { | ||
app.use(index_1.RbacMiddleware({ | ||
contextResolver: function (req) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { | ||
contextResolver: function (req) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { | ||
return [2 /*return*/, { roles: ['admin'] }]; | ||
@@ -148,5 +145,4 @@ }); }); }, | ||
}); }); | ||
it('should not allow to pass when the actual route is defined but the method is wrong', function () { return __awaiter(_this, void 0, void 0, function () { | ||
it('should not allow to pass when the actual route is defined but the method is wrong', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var e_1; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
@@ -156,3 +152,3 @@ switch (_a.label) { | ||
app.use(index_1.RbacMiddleware({ | ||
contextResolver: function (req) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { | ||
contextResolver: function (req) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { | ||
return [2 /*return*/, { roles: ['admin'] }]; | ||
@@ -188,5 +184,4 @@ }); }); }, | ||
}); }); | ||
it('should not allow to pass when the actual method is defined but the route is wrong', function () { return __awaiter(_this, void 0, void 0, function () { | ||
it('should not allow to pass when the actual method is defined but the route is wrong', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var e_2; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
@@ -196,3 +191,3 @@ switch (_a.label) { | ||
app.use(index_1.RbacMiddleware({ | ||
contextResolver: function (req) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { | ||
contextResolver: function (req) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { | ||
return [2 /*return*/, { roles: ['admin'] }]; | ||
@@ -228,4 +223,3 @@ }); }); }, | ||
}); }); | ||
it('should allow when regex match', function () { return __awaiter(_this, void 0, void 0, function () { | ||
var _this = this; | ||
it('should allow when regex match', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
@@ -235,3 +229,3 @@ switch (_a.label) { | ||
app.use(index_1.RbacMiddleware({ | ||
contextResolver: function (req) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { | ||
contextResolver: function (req) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { | ||
return [2 /*return*/, { roles: ['admin'] }]; | ||
@@ -259,4 +253,3 @@ }); }); }, | ||
}); }); | ||
it('should allow when defining a policy based on permissions', function () { return __awaiter(_this, void 0, void 0, function () { | ||
var _this = this; | ||
it('should allow when defining a policy based on permissions', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
@@ -266,3 +259,3 @@ switch (_a.label) { | ||
app.use(index_1.RbacMiddleware({ | ||
contextResolver: function (req) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { | ||
contextResolver: function (req) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { | ||
return [2 /*return*/, { roles: ['admin'], permissions: ['policy.read', 'policy.create'] }]; | ||
@@ -300,5 +293,4 @@ }); }); }, | ||
}); }); | ||
it('should block when defining a policy based on permissions and accessing a forbidden route', function () { return __awaiter(_this, void 0, void 0, function () { | ||
it('should block when defining a policy based on permissions and accessing a forbidden route', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var e_3; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
@@ -308,3 +300,3 @@ switch (_a.label) { | ||
app.use(index_1.RbacMiddleware({ | ||
contextResolver: function (req) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { | ||
contextResolver: function (req) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { | ||
return [2 /*return*/, { roles: ['admin'], permissions: ['policy.read', 'policy.create'] }]; | ||
@@ -347,5 +339,4 @@ }); }); }, | ||
}); }); | ||
it('should not allow when regex match but method is wrong', function () { return __awaiter(_this, void 0, void 0, function () { | ||
it('should not allow when regex match but method is wrong', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var e_4; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
@@ -355,3 +346,3 @@ switch (_a.label) { | ||
app.use(index_1.RbacMiddleware({ | ||
contextResolver: function (req) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { | ||
contextResolver: function (req) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { | ||
return [2 /*return*/, { roles: ['admin'] }]; | ||
@@ -387,5 +378,4 @@ }); }); }, | ||
}); }); | ||
it('should not allow when regex match but higher policy is defined', function () { return __awaiter(_this, void 0, void 0, function () { | ||
it('should not allow when regex match but higher policy is defined', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var e_5; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
@@ -395,3 +385,3 @@ switch (_a.label) { | ||
app.use(index_1.RbacMiddleware({ | ||
contextResolver: function (req) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { | ||
contextResolver: function (req) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { | ||
return [2 /*return*/, { permissions: ['read'] }]; | ||
@@ -431,4 +421,3 @@ }); }); }, | ||
}); }); | ||
it('should allow when regex match and meets higher policy', function () { return __awaiter(_this, void 0, void 0, function () { | ||
var _this = this; | ||
it('should allow when regex match and meets higher policy', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
@@ -438,3 +427,3 @@ switch (_a.label) { | ||
app.use(index_1.RbacMiddleware({ | ||
contextResolver: function (req) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { | ||
contextResolver: function (req) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { | ||
return [2 /*return*/, { permissions: ['write'] }]; | ||
@@ -466,4 +455,3 @@ }); }); }, | ||
}); }); | ||
it('should allow when regex match and meets both policies', function () { return __awaiter(_this, void 0, void 0, function () { | ||
var _this = this; | ||
it('should allow when regex match and meets both policies', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
@@ -473,3 +461,3 @@ switch (_a.label) { | ||
app.use(index_1.RbacMiddleware({ | ||
contextResolver: function (req) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { | ||
contextResolver: function (req) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { | ||
return [2 /*return*/, { permissions: ['read', 'write'] }]; | ||
@@ -501,4 +489,3 @@ }); }); }, | ||
}); }); | ||
it('should allow to pass to other routes which are defined on the policy', function () { return __awaiter(_this, void 0, void 0, function () { | ||
var _this = this; | ||
it('should allow to pass to other routes which are defined on the policy', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
@@ -509,3 +496,3 @@ switch (_a.label) { | ||
// Hook to the role in the context of the request (each request can contain several roles / permissions) | ||
contextResolver: function (req) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { | ||
contextResolver: function (req) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { | ||
return [2 /*return*/, { roles: ['admin'], permissions: ['rule.delete'] }]; | ||
@@ -512,0 +499,0 @@ }); }); }, |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -38,2 +39,3 @@ }); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SsoClient = void 0; | ||
var axios_1 = require("axios"); | ||
@@ -40,0 +42,0 @@ var authenticator_1 = require("../authenticator"); |
@@ -14,6 +14,7 @@ "use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -50,2 +51,3 @@ }); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TenantsClient = void 0; | ||
var axios_1 = require("axios"); | ||
@@ -82,3 +84,3 @@ var authenticator_1 = require("../authenticator"); | ||
logger_1.default.info('going to get Tenant'); | ||
paramsToSend = __assign({}, params, params.filters); | ||
paramsToSend = __assign(__assign({}, params), params.filters); | ||
delete paramsToSend.filters; | ||
@@ -188,3 +190,3 @@ return [4 /*yield*/, axios_1.default.get(config_1.config.urls.tenantsService, { | ||
logger_1.default.info('going to delete a Tenant'); | ||
paramsToSend = __assign({}, params, params.filters); | ||
paramsToSend = __assign(__assign({}, params), params.filters); | ||
delete paramsToSend.filters; | ||
@@ -213,3 +215,3 @@ return [4 /*yield*/, axios_1.default.delete(config_1.config.urls.tenantsService, { | ||
logger_1.default.info('going to get Tenant events'); | ||
paramsToSend = __assign({}, params, params.filters); | ||
paramsToSend = __assign(__assign({}, params), params.filters); | ||
delete paramsToSend.filters; | ||
@@ -265,3 +267,3 @@ return [4 /*yield*/, axios_1.default.get(config_1.config.urls.tenantsService + "/events", { | ||
logger_1.default.info('going to get tenant-key history'); | ||
paramsToSend = __assign({}, params, params.filters); | ||
paramsToSend = __assign(__assign({}, params), params.filters); | ||
delete paramsToSend.filters; | ||
@@ -268,0 +270,0 @@ return [4 /*yield*/, axios_1.default.get(config_1.config.urls.tenantsService + "/history", { |
import { Package } from 'normalize-package-data'; | ||
export declare const getPackageJson: () => void | Package; | ||
export declare const getPackageJson: () => Package | void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getPackageJson = void 0; | ||
exports.getPackageJson = function () { | ||
@@ -4,0 +5,0 @@ try { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.sleep = void 0; | ||
exports.sleep = function (time) { return new Promise(function (resolve) { | ||
@@ -4,0 +5,0 @@ setTimeout(resolve, time); |
29
index.ts
@@ -1,14 +0,20 @@ | ||
import { AuditsClient } from './src/audits'; | ||
import { FronteggAuthenticator } from './src/authenticator'; | ||
import { IdentityClient } from './src/identity'; | ||
import { contextResolver, withAuthentication } from './src/identity'; | ||
import { ContextHolder, frontegg, fronteggNextJs, IFronteggOptions } from './src/middleware'; | ||
import { NotificationsClient } from './src/notifications'; | ||
import { FronteggPermissions } from './src/permissions'; | ||
import { RbacMiddleware } from './src/rbac'; | ||
import { SsoClient } from './src/sso'; | ||
import { TenantsClient } from './src/tenants'; | ||
import { AuditsClient } from "./src/audits"; | ||
import { FronteggAuthenticator } from "./src/authenticator"; | ||
import { IdentityClient } from "./src/identity"; | ||
import { contextResolver, withAuthentication } from "./src/identity"; | ||
import { | ||
ContextHolder, | ||
frontegg, | ||
fronteggNextJs, | ||
IFronteggOptions, | ||
} from "./src/middleware"; | ||
import { NotificationsClient } from "./src/notifications"; | ||
import { FronteggPermissions } from "./src/permissions"; | ||
import { RbacMiddleware } from "./src/rbac"; | ||
import { SsoClient } from "./src/sso"; | ||
import { TenantsClient } from "./src/tenants"; | ||
import { AuthzClient } from "./src/authz"; | ||
import { HttpClient } from "./src/http"; | ||
export * from './src/events'; | ||
export * from "./src/events"; | ||
@@ -31,2 +37,3 @@ export { | ||
AuthzClient, | ||
HttpClient, | ||
}; |
{ | ||
"name": "@frontegg/client", | ||
"version": "2.0.23", | ||
"version": "2.0.24", | ||
"description": "Frontegg Javascript Library for backend", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -197,65 +197,19 @@ # Frontegg Client | ||
### Working with the REST API | ||
### Notifications | ||
Frontegg provides a comprehensive REST API for your application. | ||
In order to use the API from your backend it is required to initialize the client and the | ||
authenticator which maintains the backend to backend session. | ||
Allow your customers to be aware of any important business related event they need to pay attention to, both in the dashboard and even when offline. | ||
Frontegg’s Managed Notifications feature allows a SaaS company to embed an end-to-end working feature in just 5 lines of code. | ||
#### Sending notifications | ||
```javascript | ||
import { NotificationsClient } from '@frontegg/client' | ||
const notificationsClient = new NotificationsClient(); | ||
const authenticator = new FronteggAuthenticator(); | ||
await authenticator.init('<YOUR_CLIENT_ID>', '<YOUR_API_KEY>') | ||
const httpClient = new HttpClient(authenticator); | ||
// First initialize the module | ||
await notificationsClient.init('YOUR-CLIENT-ID', 'YOUR-API-KEY'); | ||
await httpClient.post('https://api.frontegg.com/identity/resources/auth/v1/user', { | ||
email: 'johndoe@acme.com', | ||
password: 'my-super-duper-password' | ||
}, { | ||
frontegg-vendor-host: 'https://acme.frontegg.com' | ||
}); | ||
// Set the notification you want to send | ||
const notification = { | ||
"title": "Notification Title", | ||
"body": "Notification Body", | ||
"severity": "info", | ||
"url": "example.com" // url to be opened when user clicks on the notification | ||
} | ||
// send the notification to a specific user | ||
await notificationsClient.sendToUser('RECEPIENT-USER-ID', 'RECEPIENT-TENANT-ID', notification) | ||
// send the notification to all tenant users | ||
await notificationsClient.sendToTenantUsers('RECEPIENT-TENANT-ID', notification) | ||
// send the notification to all users | ||
await notificationsClient.sendToAllUsers(notification) | ||
``` | ||
### Role Based Access Middleware | ||
Protect your routes and controllers with a simple middleware and policy | ||
The middleware needs to run **BEFORE** the rest of your routes and controllers and is initiated via a simple policy and context hook | ||
```javascript | ||
app.use(RbacMiddleware({ | ||
// Hook to the role in the context of the request (each request can contain several roles / permissions) | ||
contextResolver: async (req) => { return { roles: ['admin'], permissions: ['rule.delete'] } }, | ||
// Define the policy | ||
policy: { | ||
default: 'deny', // Can be 'allow' as default as well | ||
rules: [{ | ||
url: '/api/admin/*', | ||
method: '*', | ||
requiredPermissions: ['write'] // For each of the admin routes require 'write' permissions | ||
}, { | ||
url: '/api/*', | ||
method: '*', | ||
requiredPermissions: ['read'] // For all the /api require 'read' permissions | ||
}, { | ||
url: '*', | ||
method: '*', | ||
requiredRoles: [], | ||
requiredPermissions: [] // For all the other APIs allow without any required permissions / roles | ||
}] | ||
} | ||
})); | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
353969
121
6093
215