@frontegg/rest-api
Advanced tools
Comparing version 1.25.0-alpha.629485945 to 1.25.0-rescript
@@ -5,3 +5,3 @@ export declare type SortDirectionType = 'asc' | 'desc'; | ||
ip: string; | ||
json: Array<any>; | ||
json: any[]; | ||
action: string; | ||
@@ -26,3 +26,3 @@ resource: string; | ||
export interface IAudits { | ||
data: Array<AuditRowData>; | ||
data: AuditRowData[]; | ||
total: number; | ||
@@ -29,0 +29,0 @@ } |
@@ -1,3 +0,3 @@ | ||
import { IActivateAccount, IDisableMfa, IEnrollMfaResponse, IForgotPassword, ILogin, ILoginResponse, ILoginWithMfa, IPreLogin, IPostLogin, ICaptchaPolicy, IUpdateSamlRoles, IRecoverMFAToken, IResetPassword, ISamlConfiguration, ISamlVendorConfigResponse, IUpdateSamlConfiguration, IUpdateSamlVendorMetadata, IVerifyMfa, IVerifyMfaResponse, IAcceptInvitation, ISocialLoginProviderConfiguration, ILoginViaSocialLogin, IVendorConfig, ISignUpUser, ISignUpResponse, IUserApiTokensData, ITenantApiTokensData, IUpdateUserApiTokensData, IUpdateTenantApiTokensData, IDeleteApiToken, IGetUserById, IUserIdResponse } from './interfaces'; | ||
export declare function getCaptchaPolicy(): Promise<ICaptchaPolicy | null>; | ||
export * from './secutiry-poilicy'; | ||
import { IActivateAccount, IDisableMfa, IEnrollMfaResponse, IForgotPassword, ILogin, ILoginResponse, ILoginWithMfa, IPreLogin, IPostLogin, IRecoverMFAToken, IResetPassword, ISamlConfiguration, ISamlVendorConfigResponse, IUpdateSamlConfiguration, IUpdateSamlVendorMetadata, IUpdateSamlRoles, IVerifyMfa, IVerifyMfaResponse, IAcceptInvitation, ISocialLoginProviderConfiguration, ILoginViaSocialLogin, IVendorConfig, ISignUpUser, ISignUpResponse, IUserApiTokensData, ITenantApiTokensData, IUpdateUserApiTokensData, IUpdateTenantApiTokensData, IDeleteApiToken, IGetUserById, IUserIdResponse } from './interfaces'; | ||
/** | ||
@@ -147,3 +147,3 @@ * Check if requested email address has sso configuration | ||
*/ | ||
export declare function getSamlRoles(): Promise<Array<string>>; | ||
export declare function getSamlRoles(): Promise<string[]>; | ||
/** | ||
@@ -178,7 +178,7 @@ * Update Saml roles for authorization | ||
*/ | ||
export declare function getUserApiTokensData(): Promise<Array<IUserApiTokensData>>; | ||
export declare function getUserApiTokensData(): Promise<IUserApiTokensData[]>; | ||
/** | ||
* Get tenant api tokens data | ||
*/ | ||
export declare function getTenantApiTokensData(): Promise<Array<ITenantApiTokensData>>; | ||
export declare function getTenantApiTokensData(): Promise<ITenantApiTokensData[]>; | ||
/** | ||
@@ -185,0 +185,0 @@ * Update User Api Tokens |
import { IUserProfile } from '..'; | ||
export * from './secutiry-poilicy/interfaces'; | ||
export declare type IPreLogin = { | ||
@@ -9,6 +10,2 @@ email: string; | ||
}; | ||
export interface ICaptchaPolicy { | ||
siteKey: string; | ||
enabled: boolean; | ||
} | ||
export declare type ILogin = { | ||
@@ -155,3 +152,3 @@ email: string; | ||
export interface IUpdateSamlRoles { | ||
roleIds: Array<string>; | ||
roleIds: string[]; | ||
} | ||
@@ -158,0 +155,0 @@ export declare type IGetUserById = { |
@@ -8,3 +8,2 @@ export declare const AUTH_SERVICE_URL_V1 = "/identity/resources/auth/v1"; | ||
export declare const SSO_SERVICE_URL_V1 = "/team/resources/sso/v1"; | ||
export declare const TEAMS_SERVICE_URL_V1 = "/team"; | ||
export declare const CONNECTIVITY_SERVICE_URL_V1 = "/integrations/resources/configurations/v1"; | ||
@@ -17,2 +16,3 @@ export declare const CONNECTIVITY_SERVICE_URL_V2 = "/integrations/resources/configurations/v2"; | ||
export declare const TEAMS_ROLES_SERVICE_URL_V1 = "/team/resources/roles/v1"; | ||
export declare const TEAMS_PERMISSIONS_SERVICE_URL_V1 = "/identity/resources/permissions/v1"; | ||
export declare const TEAMS_STATS_SERVICE_URL_V1 = "/team/resources/stats/v1/members"; | ||
@@ -23,5 +23,6 @@ export declare const TEAMS_PROFILE_SERVICE_URL = "/team/resources/profile"; | ||
export declare const AUDITS_SERVICE_EXPORT_URL = "/audits/export"; | ||
export declare const TENANTS_SERVICE_V1 = "/tenants/resources/tenants/v1"; | ||
export declare const ACCOUNT_SETTINGS_SERVICE_V1 = "/tenants/resources/tenants/account-settings/v1"; | ||
export declare const ACCOUNT_SETTINGS_SERVICE_V1 = "/tenants/resources/account-settings/v1"; | ||
export declare const IDENTITY_API_TOKENS_USERS_SERVICE = "/identity/resources/users/api-tokens/v1"; | ||
export declare const IDENTITY_API_TOKENS_TENANTS_SERVICE = "/identity/resources/tenants/api-tokens/v1"; | ||
export declare const IDENTITY_ROLES_SERVICE_URL_V1 = "/identity/resources/roles/v1"; | ||
export declare const IDENTITY_PERMISSIONS_SERVICE_URL_V1 = "/identity/resources/permissions/v1"; |
@@ -11,2 +11,3 @@ import * as auth from './auth'; | ||
import * as accountSettings from './account-settings'; | ||
import * as roles from './roles'; | ||
import { ContextHolder, FronteggContext } from './ContextHolder'; | ||
@@ -23,2 +24,3 @@ export * from './interfaces'; | ||
export * from './account-settings/interfaces'; | ||
export * from './roles/interfaces'; | ||
declare const api: { | ||
@@ -34,3 +36,4 @@ auth: typeof auth; | ||
accountSettings: typeof accountSettings; | ||
roles: typeof roles; | ||
}; | ||
export { fetch, ContextHolder, FronteggContext, api }; |
275
index.esm.js
import { __awaiter, __rest } from 'tslib'; | ||
import jwtDecode from 'jwt-decode'; | ||
@@ -242,2 +241,3 @@ class ContextHolder { | ||
const TEAMS_ROLES_SERVICE_URL_V1 = '/team/resources/roles/v1'; | ||
const TEAMS_PERMISSIONS_SERVICE_URL_V1 = '/identity/resources/permissions/v1'; | ||
const TEAMS_STATS_SERVICE_URL_V1 = '/team/resources/stats/v1/members'; | ||
@@ -248,7 +248,158 @@ const TEAMS_PROFILE_SERVICE_URL = '/team/resources/profile'; | ||
const AUDITS_SERVICE_EXPORT_URL = '/audits/export'; | ||
const ACCOUNT_SETTINGS_SERVICE_V1 = '/tenants/resources/tenants/account-settings/v1'; | ||
const ACCOUNT_SETTINGS_SERVICE_V1 = '/tenants/resources/account-settings/v1'; | ||
const IDENTITY_API_TOKENS_USERS_SERVICE = '/identity/resources/users/api-tokens/v1'; | ||
const IDENTITY_API_TOKENS_TENANTS_SERVICE = '/identity/resources/tenants/api-tokens/v1'; | ||
const IDENTITY_ROLES_SERVICE_URL_V1 = '/identity/resources/roles/v1'; | ||
const IDENTITY_PERMISSIONS_SERVICE_URL_V1 = '/identity/resources/permissions/v1'; | ||
/* tslint:disable:no-console */ | ||
/** | ||
* Get global secure access configuration | ||
*/ | ||
function getGlobalSecurityPolicy() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.debug('getGlobalSecurityPolicy()'); | ||
return Get(IDENTITY_CONFIGURATION_SERVICE_URL_V1); | ||
}); | ||
} | ||
/** | ||
* Get Mfa configuration from security policy | ||
*/ | ||
function getMfaPolicy() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.debug('getMfaPolicy()'); | ||
return Get(`${IDENTITY_CONFIGURATION_SERVICE_URL_V1}/mfa-policy`); | ||
}); | ||
} | ||
/** | ||
* Create/Update Mfa configuration from security policy | ||
*/ | ||
function saveMfaPolicy(body) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.debug('saveMfaPolicy()'); | ||
if (body.id) { | ||
return Patch(`${IDENTITY_CONFIGURATION_SERVICE_URL_V1}/mfa-policy`, body); | ||
} | ||
else { | ||
return Post(`${IDENTITY_CONFIGURATION_SERVICE_URL_V1}/mfa-policy`, body); | ||
} | ||
}); | ||
} | ||
/** | ||
* Get Lockout configuration from security policy | ||
*/ | ||
function getLockoutPolicy() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.debug('getLockoutPolicy()'); | ||
return Get(`${IDENTITY_CONFIGURATION_SERVICE_URL_V1}/lockout-policy`); | ||
}); | ||
} | ||
/** | ||
* Create/Update Lockout configuration from security policy | ||
*/ | ||
function saveLockoutPolicy(body) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.debug('saveLockoutPolicy()'); | ||
if (body.id) { | ||
return Patch(`${IDENTITY_CONFIGURATION_SERVICE_URL_V1}/lockout-policy`, body); | ||
} | ||
else { | ||
return Post(`${IDENTITY_CONFIGURATION_SERVICE_URL_V1}/lockout-policy`, body); | ||
} | ||
}); | ||
} | ||
/** | ||
* Get Captcha configuration from security policy | ||
*/ | ||
function getCaptchaPolicy() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.debug('getCaptchaPolicy()'); | ||
return Get(`${IDENTITY_CONFIGURATION_SERVICE_URL_V1}/captcha-policy/public`); | ||
}); | ||
} | ||
/** | ||
* The code was extracted from: | ||
* https://github.com/davidchambers/Base64.js | ||
*/ | ||
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; | ||
class InvalidCharacterError extends Error { | ||
constructor(message) { | ||
super(message); | ||
} | ||
} | ||
function polyfill(input) { | ||
const str = String(input).replace(/=+$/, ''); | ||
if (str.length % 4 === 1) { | ||
throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded."); | ||
} | ||
let output = ''; | ||
// noinspection JSAssignmentUsedAsCondition,JSUnusedAssignment,CommaExpressionJS | ||
for ( | ||
// initialize result and counters | ||
let bc = 0, bs, buffer, idx = 0; | ||
// get next character | ||
// tslint:disable-next-line:no-conditional-assignment | ||
(buffer = str.charAt(idx++)); | ||
// character found in table? initialize bit storage and add its ascii value; | ||
// tslint:disable-next-line:no-conditional-assignment | ||
~buffer && | ||
((bs = bc % 4 ? bs * 64 + buffer : buffer), | ||
// and if not first of each 4 characters, | ||
// convert the first 8 bits to one ascii character | ||
bc++ % 4) | ||
? (output += String.fromCharCode(255 & (bs >> ((-2 * bc) & 6)))) | ||
: 0) { | ||
// try to find character in table (0-63, not found => -1) | ||
buffer = chars.indexOf(buffer); | ||
} | ||
return output; | ||
} | ||
const atob = (typeof window !== 'undefined' && window.atob && window.atob.bind(window)) || polyfill; | ||
function b64DecodeUnicode(str) { | ||
return decodeURIComponent(atob(str).replace(/(.)/g, (m, p) => { | ||
let code = p.charCodeAt(0).toString(16).toUpperCase(); | ||
if (code.length < 2) { | ||
code = '0' + code; | ||
} | ||
return '%' + code; | ||
})); | ||
} | ||
const base64UrlDecode = (str) => { | ||
let output = str.replace(/-/g, '+').replace(/_/g, '/'); | ||
switch (output.length % 4) { | ||
case 0: | ||
break; | ||
case 2: | ||
output += '=='; | ||
break; | ||
case 3: | ||
output += '='; | ||
break; | ||
default: | ||
throw new Error('Illegal base64url string!'); | ||
} | ||
try { | ||
return b64DecodeUnicode(output); | ||
} | ||
catch (err) { | ||
return atob(output); | ||
} | ||
}; | ||
class InvalidTokenError extends Error { | ||
constructor(message) { | ||
super(message); | ||
} | ||
} | ||
const jwtDecode = (token, options = {}) => { | ||
const pos = !!options.header ? 0 : 1; | ||
try { | ||
return JSON.parse(base64UrlDecode(token.split('.')[pos])); | ||
} | ||
catch (e) { | ||
throw new InvalidTokenError('Invalid token specified: ' + e.message); | ||
} | ||
}; | ||
/* tslint:disable:no-console */ | ||
/***************************************** | ||
@@ -270,14 +421,2 @@ * Authentication | ||
} | ||
function getCaptchaPolicy() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
const policy = yield Get(`${IDENTITY_CONFIGURATION_SERVICE_URL_V1}/captcha-policy/public`); | ||
return policy; | ||
} | ||
catch (e) { | ||
console.error('getCaptchaPolicy()', e); | ||
return null; | ||
} | ||
}); | ||
} | ||
/** | ||
@@ -659,3 +798,3 @@ * Check if requested email address has sso configuration | ||
console.debug('getUserById()'); | ||
return Get(`${USERS_SERVICE_URL_V1}/${userId}`); | ||
return Get(`${USERS_SERVICE_URL_V2}/${userId}`); | ||
}); | ||
@@ -666,3 +805,2 @@ } | ||
__proto__: null, | ||
getCaptchaPolicy: getCaptchaPolicy, | ||
preLogin: preLogin, | ||
@@ -700,3 +838,9 @@ postLogin: postLogin, | ||
deleteUserApiToken: deleteUserApiToken, | ||
getUserById: getUserById | ||
getUserById: getUserById, | ||
getGlobalSecurityPolicy: getGlobalSecurityPolicy, | ||
getMfaPolicy: getMfaPolicy, | ||
saveMfaPolicy: saveMfaPolicy, | ||
getLockoutPolicy: getLockoutPolicy, | ||
saveLockoutPolicy: saveLockoutPolicy, | ||
getCaptchaPolicy: getCaptchaPolicy | ||
}); | ||
@@ -815,2 +959,8 @@ | ||
} | ||
function loadAvailablePermissions() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.debug('loadAvailablePermissions()'); | ||
return Get(TEAMS_PERMISSIONS_SERVICE_URL_V1); | ||
}); | ||
} | ||
/** | ||
@@ -850,2 +1000,3 @@ * load users stats from team-management-service | ||
loadAvailableRoles: loadAvailableRoles, | ||
loadAvailablePermissions: loadAvailablePermissions, | ||
loadStats: loadStats, | ||
@@ -1170,2 +1321,91 @@ resendActivationLink: resendActivationLink | ||
/** | ||
* Gets tenant related roles | ||
*/ | ||
function getRoles() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.debug('getRoles()'); | ||
return Get(`${IDENTITY_ROLES_SERVICE_URL_V1}`); | ||
}); | ||
} | ||
/** | ||
* Adds tenant related roles | ||
* @param body: IAddRole | ||
*/ | ||
function addRole(body) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.debug('addRole()', body); | ||
return Post(`${IDENTITY_ROLES_SERVICE_URL_V1}`, body); | ||
}); | ||
} | ||
/** | ||
* Deletes role given role ID | ||
*/ | ||
function deleteRole({ roleId }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.debug('deleteRole()', roleId); | ||
return Delete(`${IDENTITY_ROLES_SERVICE_URL_V1}/${roleId}`); | ||
}); | ||
} | ||
/** | ||
* Updates role using a given role ID and IUpdateRole object | ||
*/ | ||
function updateRole(_a) { | ||
var { roleId } = _a, body = __rest(_a, ["roleId"]); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.debug('updateRole()', roleId, body); | ||
return Patch(`${IDENTITY_ROLES_SERVICE_URL_V1}/${roleId}`, body); | ||
}); | ||
} | ||
/** | ||
* Attaches permissions to role given a role ID | ||
*/ | ||
function attachPermissionsToRole(_a) { | ||
var { roleId } = _a, body = __rest(_a, ["roleId"]); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.debug('attachPermissionsToRole()', roleId, body); | ||
return Put(`${IDENTITY_ROLES_SERVICE_URL_V1}/${roleId}/permissions`, body); | ||
}); | ||
} | ||
/** | ||
* Gets all vendor permissions | ||
*/ | ||
function getPermissions() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.debug('getPermissions()'); | ||
return Get(`${IDENTITY_PERMISSIONS_SERVICE_URL_V1}`); | ||
}); | ||
} | ||
/** | ||
* Associate permission to roles | ||
*/ | ||
function attachPermissionToRoles(_a) { | ||
var { permissionId } = _a, body = __rest(_a, ["permissionId"]); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.debug('attachPermissionToRoles()'); | ||
return Put(`${IDENTITY_PERMISSIONS_SERVICE_URL_V1}/${permissionId}/roles`, body); | ||
}); | ||
} | ||
/** | ||
* Gets all vendor categories including the permissions | ||
*/ | ||
function getPermissionCategories() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.debug('getPermissionCategories()'); | ||
return Get(`${IDENTITY_PERMISSIONS_SERVICE_URL_V1}/categories`); | ||
}); | ||
} | ||
var roles = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
getRoles: getRoles, | ||
addRole: addRole, | ||
deleteRole: deleteRole, | ||
updateRole: updateRole, | ||
attachPermissionsToRole: attachPermissionsToRole, | ||
getPermissions: getPermissions, | ||
attachPermissionToRoles: attachPermissionToRoles, | ||
getPermissionCategories: getPermissionCategories | ||
}); | ||
var SocialLoginsProviders; | ||
@@ -1187,2 +1427,3 @@ (function (SocialLoginsProviders) { | ||
accountSettings, | ||
roles, | ||
}; | ||
@@ -1189,0 +1430,0 @@ |
{ | ||
"name": "@frontegg/rest-api", | ||
"libName": "FronteggRestApi", | ||
"version": "1.25.0-alpha.629485945", | ||
"version": "1.25.0-rescript", | ||
"author": "Frontegg LTD", | ||
"main": "index.js", | ||
"module": "index.esm.js", | ||
"es2015": "index.es.js", | ||
"types": "index.d.ts", | ||
"dependencies": { | ||
"jwt-decode": "2.2.0" | ||
"scripts": { | ||
"build": "rollup -c ../../scripts/rollup.config.js && echo DONE", | ||
"build:watch": "rollup -w -c ../../scripts/rollup.config.js", | ||
"test": "jest --runInBand --passWithNoTests -c ../../scripts/jest.config.json --rootDir . && echo DONE" | ||
}, | ||
"gitHead": "dd66305fcb585f50b67f51a83b6816d6571c9d6c", | ||
"main": "index.js", | ||
"peerDependencies": {} | ||
} | ||
"devDependencies": { | ||
"gentype": "^3.44.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { IAddUser, IChangePassword, ILoadUsers, IResendActivationLink, ITeamUserRole, ITeamStats, ITeamUser, IUpdateProfile, IUserProfile, IUpdateUser, IDeleteUser } from './interfaces'; | ||
import { IAddUser, IChangePassword, ILoadUsers, IResendActivationLink, ITeamUserRole, ITeamStats, ITeamUser, IUpdateProfile, IUserProfile, IUpdateUser, IDeleteUser, ITeamUserPermission } from './interfaces'; | ||
import { PaginationResult } from '../interfaces'; | ||
@@ -63,2 +63,3 @@ /***************************************** | ||
export declare function loadAvailableRoles(): Promise<ITeamUserRole[]>; | ||
export declare function loadAvailablePermissions(): Promise<ITeamUserPermission[]>; | ||
/** | ||
@@ -65,0 +66,0 @@ * load users stats from team-management-service |
import { QueryFilter, QuerySort } from '../interfaces'; | ||
export declare type IRole = { | ||
id: string; | ||
key: string; | ||
isDefault: boolean; | ||
name: string; | ||
description?: null; | ||
permissions: string[]; | ||
tenantId?: string; | ||
vendorId: string; | ||
createdAt: Date; | ||
updatedAt: Date; | ||
}; | ||
export declare type IRolePermission = { | ||
id: string; | ||
key: string; | ||
name: string; | ||
description?: string; | ||
categoryId: string; | ||
fePermission: boolean; | ||
createdAt: Date; | ||
updatedAt: Date; | ||
}; | ||
import { IRole, IRolePermission } from '../roles/interfaces'; | ||
export declare type IUserProfile = { | ||
@@ -39,2 +18,3 @@ id: string; | ||
roleIds?: string[]; | ||
verified?: boolean; | ||
}; | ||
@@ -65,2 +45,13 @@ export declare type ITeamUser = { | ||
}; | ||
export declare type ITeamUserPermission = { | ||
description: string; | ||
fePermission: boolean; | ||
id: string; | ||
key: string; | ||
name: string; | ||
roleIds: string[]; | ||
createdAt: Date; | ||
updatedAt: Date; | ||
categoryId: string; | ||
}; | ||
export declare type ITeamStats = { | ||
@@ -96,2 +87,3 @@ totalItems: number; | ||
email: string; | ||
phone?: string; | ||
roleIds: string[]; | ||
@@ -98,0 +90,0 @@ }; |
Sorry, the diff of this file is too big to display
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 too big to display
Sorry, the diff of this file is not supported yet
470408
0
35
6178
1
- Removedjwt-decode@2.2.0
- Removedjwt-decode@2.2.0(transitive)