@frontegg/rest-api
Advanced tools
Comparing version 1.5.0 to 1.6.0
@@ -10,2 +10,3 @@ export declare const AUTH_SERVICE_URL_V1 = "/identity/resources/auth/v1"; | ||
export declare const TEAMS_STATS_SERVICE_URL_V1 = "/team/resources/stats/v1/members"; | ||
export declare const TEAMS_PROFILE_SERVICE_URL = "/team/resources/profile"; | ||
export declare const NOTIFICATIONS_SERVICE_URL = "/notification"; |
@@ -9,2 +9,3 @@ import { IUserProfile } from './teams/interfaces'; | ||
private onRedirectTo; | ||
private logout; | ||
private constructor(); | ||
@@ -16,2 +17,3 @@ static getInstance(): ContextHolder; | ||
static setOnRedirectTo(onRedirectTo: (path: string, opts?: RedirectOptions) => void): void; | ||
static setLogout(logout: (callback?: () => void) => void, logoutUrl: string): void; | ||
static getContext(): ContextOptions; | ||
@@ -21,2 +23,3 @@ static getAccessToken(): string | null; | ||
static onRedirectTo(path: string, opts?: RedirectOptions): void; | ||
static logout(callback?: () => void): void; | ||
} | ||
@@ -27,2 +30,4 @@ export declare const FronteggContext: { | ||
getUser: () => IUserProfile | null; | ||
onRedirectTo: (path: string, opts: RedirectOptions) => void; | ||
logout: (callback?: (() => void) | undefined) => void; | ||
}; |
@@ -10,2 +10,3 @@ import { __awaiter, __generator, __assign } from 'tslib'; | ||
this.onRedirectTo = function (path) { return (window.location.href = path); }; | ||
this.logout = function () { return (window.location.href = '/account/logout'); }; | ||
} | ||
@@ -30,2 +31,12 @@ ContextHolder.getInstance = function () { | ||
}; | ||
ContextHolder.setLogout = function (logout, logoutUrl) { | ||
ContextHolder.getInstance().logout = function (callback) { | ||
if (!callback) { | ||
ContextHolder.onRedirectTo(logoutUrl); | ||
} | ||
else { | ||
logout(callback); | ||
} | ||
}; | ||
}; | ||
ContextHolder.getContext = function () { | ||
@@ -47,2 +58,5 @@ var _a; | ||
}; | ||
ContextHolder.logout = function (callback) { | ||
return ContextHolder.getInstance().logout(callback); | ||
}; | ||
return ContextHolder; | ||
@@ -54,2 +68,4 @@ }()); | ||
getUser: function () { return ContextHolder.getUser(); }, | ||
onRedirectTo: function (path, opts) { return ContextHolder.onRedirectTo(path, opts); }, | ||
logout: function (callback) { return ContextHolder.logout(callback); }, | ||
}; | ||
@@ -97,3 +113,2 @@ | ||
var _a; | ||
if (contentType === void 0) { contentType = 'application/json'; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -208,3 +223,3 @@ var authToken, headers, _i, _b, additionalHeader; | ||
return [4 /*yield*/, fetch(url, { | ||
body: opts.body ? JSON.stringify(opts.body) : null, | ||
body: opts.body ? (opts.contentType === 'application/json' ? JSON.stringify(opts.body) : opts.body) : null, | ||
method: (_a = opts.method) !== null && _a !== void 0 ? _a : 'GET', | ||
@@ -217,2 +232,5 @@ headers: __assign(__assign({}, headers), opts.headers), | ||
if (!!response.ok) return [3 /*break*/, 8]; | ||
if (response.status === 413) { | ||
throw new Error('Error request is too large'); | ||
} | ||
errorMessage = void 0; | ||
@@ -307,2 +325,3 @@ _d.label = 4; | ||
var TEAMS_STATS_SERVICE_URL_V1 = '/team/resources/stats/v1/members'; | ||
var TEAMS_PROFILE_SERVICE_URL = '/team/resources/profile'; | ||
var NOTIFICATIONS_SERVICE_URL = '/notification'; | ||
@@ -701,2 +720,14 @@ | ||
/** | ||
* update user profile image | ||
* ``authorized user`` | ||
*/ | ||
function updateProfileImage(body) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
console.debug('updateProfileImage()', body); | ||
return [2 /*return*/, Put(TEAMS_PROFILE_SERVICE_URL + "/me/image/v1", body, { responseType: 'plain', contentType: undefined })]; | ||
}); | ||
}); | ||
} | ||
/** | ||
* change user password by providing current password and the new password. | ||
@@ -825,2 +856,3 @@ * | ||
updateProfile: updateProfile, | ||
updateProfileImage: updateProfileImage, | ||
changePassword: changePassword, | ||
@@ -827,0 +859,0 @@ loadUsers: loadUsers, |
@@ -10,2 +10,3 @@ import { __awaiter } from 'tslib'; | ||
this.onRedirectTo = (path) => (window.location.href = path); | ||
this.logout = () => (window.location.href = '/account/logout'); | ||
} | ||
@@ -30,2 +31,12 @@ static getInstance() { | ||
} | ||
static setLogout(logout, logoutUrl) { | ||
ContextHolder.getInstance().logout = (callback) => { | ||
if (!callback) { | ||
ContextHolder.onRedirectTo(logoutUrl); | ||
} | ||
else { | ||
logout(callback); | ||
} | ||
}; | ||
} | ||
static getContext() { | ||
@@ -47,2 +58,5 @@ var _a; | ||
} | ||
static logout(callback) { | ||
return ContextHolder.getInstance().logout(callback); | ||
} | ||
} | ||
@@ -53,2 +67,4 @@ const FronteggContext = { | ||
getUser: () => ContextHolder.getUser(), | ||
onRedirectTo: (path, opts) => ContextHolder.onRedirectTo(path, opts), | ||
logout: (callback) => ContextHolder.logout(callback), | ||
}; | ||
@@ -82,3 +98,3 @@ | ||
} | ||
function buildRequestHeaders(context, contentType = 'application/json') { | ||
function buildRequestHeaders(context, contentType) { | ||
var _a; | ||
@@ -142,3 +158,3 @@ return __awaiter(this, void 0, void 0, function* () { | ||
const response = yield fetch(url, { | ||
body: opts.body ? JSON.stringify(opts.body) : null, | ||
body: opts.body ? (opts.contentType === 'application/json' ? JSON.stringify(opts.body) : opts.body) : null, | ||
method: (_a = opts.method) !== null && _a !== void 0 ? _a : 'GET', | ||
@@ -149,2 +165,5 @@ headers: Object.assign(Object.assign({}, headers), opts.headers), | ||
if (!response.ok) { | ||
if (response.status === 413) { | ||
throw new Error('Error request is too large'); | ||
} | ||
let errorMessage; | ||
@@ -215,2 +234,3 @@ try { | ||
const TEAMS_STATS_SERVICE_URL_V1 = '/team/resources/stats/v1/members'; | ||
const TEAMS_PROFILE_SERVICE_URL = '/team/resources/profile'; | ||
const NOTIFICATIONS_SERVICE_URL = '/notification'; | ||
@@ -527,2 +547,12 @@ | ||
/** | ||
* update user profile image | ||
* ``authorized user`` | ||
*/ | ||
function updateProfileImage(body) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.debug('updateProfileImage()', body); | ||
return Put(`${TEAMS_PROFILE_SERVICE_URL}/me/image/v1`, body, { responseType: 'plain', contentType: undefined }); | ||
}); | ||
} | ||
/** | ||
* change user password by providing current password and the new password. | ||
@@ -631,2 +661,3 @@ * | ||
updateProfile: updateProfile, | ||
updateProfileImage: updateProfileImage, | ||
changePassword: changePassword, | ||
@@ -633,0 +664,0 @@ loadUsers: loadUsers, |
36
index.js
@@ -16,2 +16,3 @@ 'use strict'; | ||
this.onRedirectTo = function (path) { return (window.location.href = path); }; | ||
this.logout = function () { return (window.location.href = '/account/logout'); }; | ||
} | ||
@@ -36,2 +37,12 @@ ContextHolder.getInstance = function () { | ||
}; | ||
ContextHolder.setLogout = function (logout, logoutUrl) { | ||
ContextHolder.getInstance().logout = function (callback) { | ||
if (!callback) { | ||
ContextHolder.onRedirectTo(logoutUrl); | ||
} | ||
else { | ||
logout(callback); | ||
} | ||
}; | ||
}; | ||
ContextHolder.getContext = function () { | ||
@@ -53,2 +64,5 @@ var _a; | ||
}; | ||
ContextHolder.logout = function (callback) { | ||
return ContextHolder.getInstance().logout(callback); | ||
}; | ||
return ContextHolder; | ||
@@ -60,2 +74,4 @@ }()); | ||
getUser: function () { return ContextHolder.getUser(); }, | ||
onRedirectTo: function (path, opts) { return ContextHolder.onRedirectTo(path, opts); }, | ||
logout: function (callback) { return ContextHolder.logout(callback); }, | ||
}; | ||
@@ -103,3 +119,2 @@ | ||
var _a; | ||
if (contentType === void 0) { contentType = 'application/json'; } | ||
return tslib.__awaiter(this, void 0, void 0, function () { | ||
@@ -214,3 +229,3 @@ var authToken, headers, _i, _b, additionalHeader; | ||
return [4 /*yield*/, fetch(url, { | ||
body: opts.body ? JSON.stringify(opts.body) : null, | ||
body: opts.body ? (opts.contentType === 'application/json' ? JSON.stringify(opts.body) : opts.body) : null, | ||
method: (_a = opts.method) !== null && _a !== void 0 ? _a : 'GET', | ||
@@ -223,2 +238,5 @@ headers: tslib.__assign(tslib.__assign({}, headers), opts.headers), | ||
if (!!response.ok) return [3 /*break*/, 8]; | ||
if (response.status === 413) { | ||
throw new Error('Error request is too large'); | ||
} | ||
errorMessage = void 0; | ||
@@ -313,2 +331,3 @@ _d.label = 4; | ||
var TEAMS_STATS_SERVICE_URL_V1 = '/team/resources/stats/v1/members'; | ||
var TEAMS_PROFILE_SERVICE_URL = '/team/resources/profile'; | ||
var NOTIFICATIONS_SERVICE_URL = '/notification'; | ||
@@ -707,2 +726,14 @@ | ||
/** | ||
* update user profile image | ||
* ``authorized user`` | ||
*/ | ||
function updateProfileImage(body) { | ||
return tslib.__awaiter(this, void 0, void 0, function () { | ||
return tslib.__generator(this, function (_a) { | ||
console.debug('updateProfileImage()', body); | ||
return [2 /*return*/, Put(TEAMS_PROFILE_SERVICE_URL + "/me/image/v1", body, { responseType: 'plain', contentType: undefined })]; | ||
}); | ||
}); | ||
} | ||
/** | ||
* change user password by providing current password and the new password. | ||
@@ -831,2 +862,3 @@ * | ||
updateProfile: updateProfile, | ||
updateProfileImage: updateProfileImage, | ||
changePassword: changePassword, | ||
@@ -833,0 +865,0 @@ loadUsers: loadUsers, |
{ | ||
"name": "@frontegg/rest-api", | ||
"libName": "FronteggRestApi", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"author": "Frontegg LTD", | ||
@@ -12,5 +12,5 @@ "module": "index.esm.js", | ||
}, | ||
"gitHead": "8773559ad2f0de82d5341fe9a0fff472b8a6699e", | ||
"gitHead": "af24a6cde923635a99a454d8a6c36fee8258943b", | ||
"main": "index.js", | ||
"peerDependencies": {} | ||
} |
@@ -19,2 +19,7 @@ import { IAddUser, IChangePassword, ILoadUsers, IResendActivationLink, ITeamUserRole, ITeamStats, ITeamUser, IUpdateProfile, IUserProfile, IUpdateUser, IDeleteUser } from './interfaces'; | ||
/** | ||
* update user profile image | ||
* ``authorized user`` | ||
*/ | ||
export declare function updateProfileImage(body: FormData): Promise<string>; | ||
/** | ||
* change user password by providing current password and the new password. | ||
@@ -21,0 +26,0 @@ * |
@@ -8,2 +8,3 @@ import { QueryFilter, QuerySort } from '../interfaces'; | ||
phoneNumber: string; | ||
profileImage?: string; | ||
profilePictureUrl: string; | ||
@@ -53,2 +54,5 @@ roles: string[]; | ||
}; | ||
export declare type IUpdateProfileImage = { | ||
profileImage: string; | ||
}; | ||
export declare type IChangePassword = { | ||
@@ -55,0 +59,0 @@ password: string; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
246840
3347