@frontegg/rest-api 3.0.1 → 3.0.4
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/ContextHolder.js +67 -101
- package/account-settings/index.js +4 -43
- package/audits/index.js +16 -69
- package/auth/enums.js +2 -2
- package/auth/index.d.ts +4 -0
- package/auth/index.js +354 -2044
- package/auth/interfaces.js +1 -1
- package/auth/secutiry-poilicy/index.js +45 -254
- package/connectivity/index.js +79 -73
- package/constants.js +1 -1
- package/error.js +9 -33
- package/fetch.js +165 -519
- package/index.js +26 -26
- package/jwt.js +19 -45
- package/metadata/index.js +19 -159
- package/node/ContextHolder.js +68 -104
- package/node/account-settings/index.js +4 -46
- package/node/audits/index.js +15 -68
- package/node/auth/enums.js +2 -2
- package/node/auth/index.js +487 -2099
- package/node/auth/interfaces.js +2 -2
- package/node/auth/secutiry-poilicy/index.js +36 -240
- package/node/connectivity/index.js +78 -71
- package/node/constants.js +1 -1
- package/node/error.js +9 -38
- package/node/fetch.js +166 -521
- package/node/index.js +47 -49
- package/node/jwt.js +19 -51
- package/node/metadata/index.js +19 -163
- package/node/notifications/index.js +18 -94
- package/node/reports/index.js +62 -171
- package/node/roles/index.js +34 -172
- package/node/routers.js +2 -2
- package/node/sub-tenants/index.js +12 -126
- package/node/subscriptions/enums.js +4 -4
- package/node/subscriptions/index.js +10 -10
- package/node/subscriptions/interfaces.js +1 -1
- package/node/subscriptions/invoices.js +10 -70
- package/node/subscriptions/managedSubscriptions.js +16 -111
- package/node/subscriptions/paymentMethods.js +15 -69
- package/node/subscriptions/paymentProviders.js +2 -26
- package/node/subscriptions/plans.js +4 -46
- package/node/subscriptions/providers/index.js +1 -1
- package/node/subscriptions/providers/stripe/index.js +10 -106
- package/node/subscriptions/subscriptions.js +16 -111
- package/node/subscriptions/summaries.js +2 -26
- package/node/subscriptions/tenantConfiguration.js +4 -46
- package/node/teams/index.js +57 -406
- package/node/tenants/index.js +8 -86
- package/node/vendor/index.js +2 -26
- package/notifications/index.js +18 -93
- package/package.json +1 -1
- package/reports/index.js +65 -175
- package/roles/index.js +34 -175
- package/routers.js +2 -2
- package/sub-tenants/index.js +12 -127
- package/subscriptions/enums.js +4 -4
- package/subscriptions/invoices.js +12 -70
- package/subscriptions/managedSubscriptions.js +20 -115
- package/subscriptions/paymentMethods.js +16 -70
- package/subscriptions/paymentProviders.js +2 -22
- package/subscriptions/plans.js +4 -43
- package/subscriptions/providers/stripe/index.js +10 -106
- package/subscriptions/subscriptions.js +20 -115
- package/subscriptions/summaries.js +2 -22
- package/subscriptions/tenantConfiguration.js +4 -43
- package/teams/index.js +56 -420
- package/tenants/index.js +8 -85
- package/vendor/index.js +2 -23
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license Frontegg v3.0.
|
|
1
|
+
/** @license Frontegg v3.0.4
|
|
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.
|
|
@@ -36,32 +36,32 @@ export * from './sub-tenants/interfaces';
|
|
|
36
36
|
export * from './routers';
|
|
37
37
|
import { AuthStrategyEnum, SocialLoginProviders } from './auth';
|
|
38
38
|
import { ISubscriptionCancellationPolicy, ISubscriptionStatus, PaymentMethodType, ProviderType } from './subscriptions';
|
|
39
|
-
|
|
40
|
-
auth
|
|
41
|
-
teams
|
|
42
|
-
metadata
|
|
43
|
-
reports
|
|
44
|
-
connectivity
|
|
45
|
-
notifications
|
|
46
|
-
audits
|
|
47
|
-
tenants
|
|
48
|
-
accountSettings
|
|
49
|
-
roles
|
|
50
|
-
subscriptions
|
|
51
|
-
vendor
|
|
52
|
-
subTenants
|
|
39
|
+
const api = {
|
|
40
|
+
auth,
|
|
41
|
+
teams,
|
|
42
|
+
metadata,
|
|
43
|
+
reports,
|
|
44
|
+
connectivity,
|
|
45
|
+
notifications,
|
|
46
|
+
audits,
|
|
47
|
+
tenants,
|
|
48
|
+
accountSettings,
|
|
49
|
+
roles,
|
|
50
|
+
subscriptions,
|
|
51
|
+
vendor,
|
|
52
|
+
subTenants
|
|
53
53
|
};
|
|
54
54
|
export { fetch, ContextHolder, FronteggContext, api, FronteggApiError, AuthStrategyEnum, SocialLoginProviders, ISubscriptionCancellationPolicy, ISubscriptionStatus, PaymentMethodType, ProviderType };
|
|
55
55
|
export default {
|
|
56
|
-
fetch
|
|
57
|
-
ContextHolder
|
|
58
|
-
FronteggContext
|
|
59
|
-
api
|
|
60
|
-
FronteggApiError
|
|
61
|
-
AuthStrategyEnum
|
|
62
|
-
SocialLoginProviders
|
|
63
|
-
ISubscriptionCancellationPolicy
|
|
64
|
-
ISubscriptionStatus
|
|
65
|
-
PaymentMethodType
|
|
66
|
-
ProviderType
|
|
56
|
+
fetch,
|
|
57
|
+
ContextHolder,
|
|
58
|
+
FronteggContext,
|
|
59
|
+
api,
|
|
60
|
+
FronteggApiError,
|
|
61
|
+
AuthStrategyEnum,
|
|
62
|
+
SocialLoginProviders,
|
|
63
|
+
ISubscriptionCancellationPolicy,
|
|
64
|
+
ISubscriptionStatus,
|
|
65
|
+
PaymentMethodType,
|
|
66
|
+
ProviderType
|
|
67
67
|
};
|
package/jwt.js
CHANGED
|
@@ -1,50 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
6
|
-
import _wrapNativeSuper from "@babel/runtime/helpers/esm/wrapNativeSuper";
|
|
7
|
-
|
|
8
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
-
|
|
10
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
11
|
-
|
|
12
|
-
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
13
|
-
export var InvalidCharacterError = function (_Error) {
|
|
14
|
-
_inherits(InvalidCharacterError, _Error);
|
|
15
|
-
|
|
16
|
-
var _super = _createSuper(InvalidCharacterError);
|
|
17
|
-
|
|
18
|
-
function InvalidCharacterError(message) {
|
|
19
|
-
_classCallCheck(this, InvalidCharacterError);
|
|
20
|
-
|
|
21
|
-
return _super.call(this, message);
|
|
1
|
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
2
|
+
export class InvalidCharacterError extends Error {
|
|
3
|
+
constructor(message) {
|
|
4
|
+
super(message);
|
|
22
5
|
}
|
|
23
6
|
|
|
24
|
-
|
|
25
|
-
}(_wrapNativeSuper(Error));
|
|
7
|
+
}
|
|
26
8
|
|
|
27
9
|
function polyfill(input) {
|
|
28
|
-
|
|
10
|
+
const str = String(input).replace(/=+$/, '');
|
|
29
11
|
|
|
30
12
|
if (str.length % 4 === 1) {
|
|
31
13
|
throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");
|
|
32
14
|
}
|
|
33
15
|
|
|
34
|
-
|
|
16
|
+
let output = '';
|
|
35
17
|
|
|
36
|
-
for (
|
|
18
|
+
for (let bc = 0, bs, buffer, idx = 0; buffer = str.charAt(idx++); ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0) {
|
|
37
19
|
buffer = chars.indexOf(buffer);
|
|
38
20
|
}
|
|
39
21
|
|
|
40
22
|
return output;
|
|
41
23
|
}
|
|
42
24
|
|
|
43
|
-
|
|
25
|
+
const atob = typeof window !== 'undefined' && window.atob && window.atob.bind(window) || polyfill;
|
|
44
26
|
|
|
45
27
|
function b64DecodeUnicode(str) {
|
|
46
|
-
return decodeURIComponent(atob(str).replace(/(.)/g,
|
|
47
|
-
|
|
28
|
+
return decodeURIComponent(atob(str).replace(/(.)/g, (m, p) => {
|
|
29
|
+
let code = p.charCodeAt(0).toString(16).toUpperCase();
|
|
48
30
|
|
|
49
31
|
if (code.length < 2) {
|
|
50
32
|
code = '0' + code;
|
|
@@ -54,8 +36,8 @@ function b64DecodeUnicode(str) {
|
|
|
54
36
|
}));
|
|
55
37
|
}
|
|
56
38
|
|
|
57
|
-
|
|
58
|
-
|
|
39
|
+
const base64UrlDecode = str => {
|
|
40
|
+
let output = str.replace(/-/g, '+').replace(/_/g, '/');
|
|
59
41
|
|
|
60
42
|
switch (output.length % 4) {
|
|
61
43
|
case 0:
|
|
@@ -80,22 +62,14 @@ var base64UrlDecode = function base64UrlDecode(str) {
|
|
|
80
62
|
}
|
|
81
63
|
};
|
|
82
64
|
|
|
83
|
-
export
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
var _super2 = _createSuper(InvalidTokenError);
|
|
87
|
-
|
|
88
|
-
function InvalidTokenError(message) {
|
|
89
|
-
_classCallCheck(this, InvalidTokenError);
|
|
90
|
-
|
|
91
|
-
return _super2.call(this, message);
|
|
65
|
+
export class InvalidTokenError extends Error {
|
|
66
|
+
constructor(message) {
|
|
67
|
+
super(message);
|
|
92
68
|
}
|
|
93
69
|
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
98
|
-
var pos = !!options.header ? 0 : 1;
|
|
70
|
+
}
|
|
71
|
+
export const jwtDecode = (token, options = {}) => {
|
|
72
|
+
const pos = !!options.header ? 0 : 1;
|
|
99
73
|
|
|
100
74
|
try {
|
|
101
75
|
return JSON.parse(base64UrlDecode(token.split('.')[pos]));
|
package/metadata/index.js
CHANGED
|
@@ -1,166 +1,26 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
1
|
import { Get } from '../fetch';
|
|
4
2
|
|
|
5
|
-
function getMetadata(
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function _getMetadata() {
|
|
10
|
-
_getMetadata = _asyncToGenerator(_regeneratorRuntime.mark(function _callee5(body) {
|
|
11
|
-
var _data$rows, _data$rows2;
|
|
12
|
-
|
|
13
|
-
var data;
|
|
14
|
-
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
15
|
-
while (1) {
|
|
16
|
-
switch (_context5.prev = _context5.next) {
|
|
17
|
-
case 0:
|
|
18
|
-
_context5.next = 2;
|
|
19
|
-
return Get('/metadata', body);
|
|
20
|
-
|
|
21
|
-
case 2:
|
|
22
|
-
data = _context5.sent;
|
|
23
|
-
|
|
24
|
-
if (!(data != null && (_data$rows = data.rows) != null && _data$rows[0])) {
|
|
25
|
-
_context5.next = 5;
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return _context5.abrupt("return", data == null ? void 0 : (_data$rows2 = data.rows) == null ? void 0 : _data$rows2[0]);
|
|
3
|
+
async function getMetadata(body) {
|
|
4
|
+
var _data$rows, _data$rows2;
|
|
30
5
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
case 6:
|
|
35
|
-
case "end":
|
|
36
|
-
return _context5.stop();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}, _callee5);
|
|
40
|
-
}));
|
|
41
|
-
return _getMetadata.apply(this, arguments);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function getIpMetadata(_x2) {
|
|
45
|
-
return _getIpMetadata.apply(this, arguments);
|
|
6
|
+
const data = await Get('/metadata', body);
|
|
7
|
+
if (data != null && (_data$rows = data.rows) != null && _data$rows[0]) return data == null ? void 0 : (_data$rows2 = data.rows) == null ? void 0 : _data$rows2[0];
|
|
8
|
+
throw new Error(`metadata not found: ${body.entityName}`);
|
|
46
9
|
}
|
|
47
10
|
|
|
48
|
-
function
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
while (1) {
|
|
53
|
-
switch (_context6.prev = _context6.next) {
|
|
54
|
-
case 0:
|
|
55
|
-
_context6.next = 2;
|
|
56
|
-
return Get("/metadata/ip/".concat(ip));
|
|
57
|
-
|
|
58
|
-
case 2:
|
|
59
|
-
data = _context6.sent;
|
|
60
|
-
|
|
61
|
-
if (!data) {
|
|
62
|
-
_context6.next = 5;
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return _context6.abrupt("return", data);
|
|
67
|
-
|
|
68
|
-
case 5:
|
|
69
|
-
throw new Error("ip metadata not found");
|
|
70
|
-
|
|
71
|
-
case 6:
|
|
72
|
-
case "end":
|
|
73
|
-
return _context6.stop();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}, _callee6);
|
|
77
|
-
}));
|
|
78
|
-
return _getIpMetadata.apply(this, arguments);
|
|
11
|
+
async function getIpMetadata(ip) {
|
|
12
|
+
const data = await Get(`/metadata/ip/${ip}`);
|
|
13
|
+
if (data) return data;
|
|
14
|
+
throw new Error(`ip metadata not found`);
|
|
79
15
|
}
|
|
80
16
|
|
|
81
|
-
export
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
case 1:
|
|
92
|
-
case "end":
|
|
93
|
-
return _context.stop();
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}, _callee);
|
|
97
|
-
}));
|
|
98
|
-
|
|
99
|
-
return function getNotificationsMetadata() {
|
|
100
|
-
return _ref.apply(this, arguments);
|
|
101
|
-
};
|
|
102
|
-
}();
|
|
103
|
-
export var getSamlMetadata = function () {
|
|
104
|
-
var _ref2 = _asyncToGenerator(_regeneratorRuntime.mark(function _callee2() {
|
|
105
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
106
|
-
while (1) {
|
|
107
|
-
switch (_context2.prev = _context2.next) {
|
|
108
|
-
case 0:
|
|
109
|
-
return _context2.abrupt("return", getMetadata({
|
|
110
|
-
entityName: 'saml'
|
|
111
|
-
}));
|
|
112
|
-
|
|
113
|
-
case 1:
|
|
114
|
-
case "end":
|
|
115
|
-
return _context2.stop();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}, _callee2);
|
|
119
|
-
}));
|
|
120
|
-
|
|
121
|
-
return function getSamlMetadata() {
|
|
122
|
-
return _ref2.apply(this, arguments);
|
|
123
|
-
};
|
|
124
|
-
}();
|
|
125
|
-
export var getAuditsMetadata = function () {
|
|
126
|
-
var _ref3 = _asyncToGenerator(_regeneratorRuntime.mark(function _callee3() {
|
|
127
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
128
|
-
while (1) {
|
|
129
|
-
switch (_context3.prev = _context3.next) {
|
|
130
|
-
case 0:
|
|
131
|
-
return _context3.abrupt("return", getMetadata({
|
|
132
|
-
entityName: 'audits'
|
|
133
|
-
}));
|
|
134
|
-
|
|
135
|
-
case 1:
|
|
136
|
-
case "end":
|
|
137
|
-
return _context3.stop();
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}, _callee3);
|
|
141
|
-
}));
|
|
142
|
-
|
|
143
|
-
return function getAuditsMetadata() {
|
|
144
|
-
return _ref3.apply(this, arguments);
|
|
145
|
-
};
|
|
146
|
-
}();
|
|
147
|
-
export var getIpAdressMetadata = function () {
|
|
148
|
-
var _ref4 = _asyncToGenerator(_regeneratorRuntime.mark(function _callee4(ip) {
|
|
149
|
-
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
150
|
-
while (1) {
|
|
151
|
-
switch (_context4.prev = _context4.next) {
|
|
152
|
-
case 0:
|
|
153
|
-
return _context4.abrupt("return", getIpMetadata(ip));
|
|
154
|
-
|
|
155
|
-
case 1:
|
|
156
|
-
case "end":
|
|
157
|
-
return _context4.stop();
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}, _callee4);
|
|
161
|
-
}));
|
|
162
|
-
|
|
163
|
-
return function getIpAdressMetadata(_x3) {
|
|
164
|
-
return _ref4.apply(this, arguments);
|
|
165
|
-
};
|
|
166
|
-
}();
|
|
17
|
+
export const getNotificationsMetadata = async () => getMetadata({
|
|
18
|
+
entityName: 'notifications'
|
|
19
|
+
});
|
|
20
|
+
export const getSamlMetadata = async () => getMetadata({
|
|
21
|
+
entityName: 'saml'
|
|
22
|
+
});
|
|
23
|
+
export const getAuditsMetadata = async () => getMetadata({
|
|
24
|
+
entityName: 'audits'
|
|
25
|
+
});
|
|
26
|
+
export const getIpAdressMetadata = async ip => getIpMetadata(ip);
|
package/node/ContextHolder.js
CHANGED
|
@@ -1,126 +1,90 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.FronteggContext = exports.ContextHolder = void 0;
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
|
-
var ContextHolder = function () {
|
|
15
|
-
function ContextHolder() {
|
|
16
|
-
(0, _classCallCheck2["default"])(this, ContextHolder);
|
|
8
|
+
class ContextHolder {
|
|
9
|
+
constructor() {
|
|
17
10
|
this.context = null;
|
|
18
11
|
this.accessToken = null;
|
|
19
12
|
this.user = null;
|
|
20
13
|
|
|
21
|
-
this.onRedirectTo =
|
|
22
|
-
|
|
14
|
+
this.onRedirectTo = path => window.location.href = path;
|
|
15
|
+
|
|
16
|
+
this.logout = () => window.location.href = '/account/logout';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static getInstance() {
|
|
20
|
+
if (!ContextHolder.instance) {
|
|
21
|
+
ContextHolder.instance = new ContextHolder();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return ContextHolder.instance;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static setContext(context) {
|
|
28
|
+
ContextHolder.getInstance().context = context;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static setAccessToken(accessToken) {
|
|
32
|
+
ContextHolder.getInstance().accessToken = accessToken;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static setUser(user) {
|
|
36
|
+
ContextHolder.getInstance().user = user;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static setOnRedirectTo(onRedirectTo) {
|
|
40
|
+
ContextHolder.getInstance().onRedirectTo = onRedirectTo;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static setLogout(logout, logoutUrl) {
|
|
44
|
+
ContextHolder.getInstance().logout = callback => {
|
|
45
|
+
if (!callback) {
|
|
46
|
+
ContextHolder.onRedirectTo(logoutUrl);
|
|
47
|
+
} else {
|
|
48
|
+
logout(callback);
|
|
49
|
+
}
|
|
23
50
|
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static getContext() {
|
|
54
|
+
var _ContextHolder$getIns;
|
|
24
55
|
|
|
25
|
-
|
|
26
|
-
|
|
56
|
+
return (_ContextHolder$getIns = ContextHolder.getInstance().context) != null ? _ContextHolder$getIns : {
|
|
57
|
+
baseUrl: window.location.href,
|
|
58
|
+
tokenResolver: () => 'my-authentication-token',
|
|
59
|
+
logLevel: 'error'
|
|
27
60
|
};
|
|
28
61
|
}
|
|
29
62
|
|
|
30
|
-
(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (!ContextHolder.instance) {
|
|
34
|
-
ContextHolder.instance = new ContextHolder();
|
|
35
|
-
}
|
|
63
|
+
static getAccessToken() {
|
|
64
|
+
return ContextHolder.getInstance().accessToken;
|
|
65
|
+
}
|
|
36
66
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
key: "setUser",
|
|
51
|
-
value: function setUser(user) {
|
|
52
|
-
ContextHolder.getInstance().user = user;
|
|
53
|
-
}
|
|
54
|
-
}, {
|
|
55
|
-
key: "setOnRedirectTo",
|
|
56
|
-
value: function setOnRedirectTo(onRedirectTo) {
|
|
57
|
-
ContextHolder.getInstance().onRedirectTo = onRedirectTo;
|
|
58
|
-
}
|
|
59
|
-
}, {
|
|
60
|
-
key: "setLogout",
|
|
61
|
-
value: function setLogout(logout, logoutUrl) {
|
|
62
|
-
ContextHolder.getInstance().logout = function (callback) {
|
|
63
|
-
if (!callback) {
|
|
64
|
-
ContextHolder.onRedirectTo(logoutUrl);
|
|
65
|
-
} else {
|
|
66
|
-
logout(callback);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
}, {
|
|
71
|
-
key: "getContext",
|
|
72
|
-
value: function getContext() {
|
|
73
|
-
var _ContextHolder$getIns;
|
|
74
|
-
|
|
75
|
-
return (_ContextHolder$getIns = ContextHolder.getInstance().context) != null ? _ContextHolder$getIns : {
|
|
76
|
-
baseUrl: window.location.href,
|
|
77
|
-
tokenResolver: function tokenResolver() {
|
|
78
|
-
return 'my-authentication-token';
|
|
79
|
-
},
|
|
80
|
-
logLevel: 'error'
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
}, {
|
|
84
|
-
key: "getAccessToken",
|
|
85
|
-
value: function getAccessToken() {
|
|
86
|
-
return ContextHolder.getInstance().accessToken;
|
|
87
|
-
}
|
|
88
|
-
}, {
|
|
89
|
-
key: "getUser",
|
|
90
|
-
value: function getUser() {
|
|
91
|
-
return ContextHolder.getInstance().user;
|
|
92
|
-
}
|
|
93
|
-
}, {
|
|
94
|
-
key: "onRedirectTo",
|
|
95
|
-
value: function onRedirectTo(path, opts) {
|
|
96
|
-
return ContextHolder.getInstance().onRedirectTo(path, opts);
|
|
97
|
-
}
|
|
98
|
-
}, {
|
|
99
|
-
key: "logout",
|
|
100
|
-
value: function logout(callback) {
|
|
101
|
-
return ContextHolder.getInstance().logout(callback);
|
|
102
|
-
}
|
|
103
|
-
}]);
|
|
104
|
-
return ContextHolder;
|
|
105
|
-
}();
|
|
67
|
+
static getUser() {
|
|
68
|
+
return ContextHolder.getInstance().user;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static onRedirectTo(path, opts) {
|
|
72
|
+
return ContextHolder.getInstance().onRedirectTo(path, opts);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
static logout(callback) {
|
|
76
|
+
return ContextHolder.getInstance().logout(callback);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
}
|
|
106
80
|
|
|
107
81
|
exports.ContextHolder = ContextHolder;
|
|
108
82
|
ContextHolder.instance = void 0;
|
|
109
|
-
|
|
110
|
-
getContext:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
},
|
|
116
|
-
getUser: function getUser() {
|
|
117
|
-
return ContextHolder.getUser();
|
|
118
|
-
},
|
|
119
|
-
onRedirectTo: function onRedirectTo(path, opts) {
|
|
120
|
-
return ContextHolder.onRedirectTo(path, opts);
|
|
121
|
-
},
|
|
122
|
-
logout: function logout(callback) {
|
|
123
|
-
return ContextHolder.logout(callback);
|
|
124
|
-
}
|
|
83
|
+
const FronteggContext = {
|
|
84
|
+
getContext: () => ContextHolder.getContext(),
|
|
85
|
+
getAccessToken: () => ContextHolder.getAccessToken(),
|
|
86
|
+
getUser: () => ContextHolder.getUser(),
|
|
87
|
+
onRedirectTo: (path, opts) => ContextHolder.onRedirectTo(path, opts),
|
|
88
|
+
logout: callback => ContextHolder.logout(callback)
|
|
125
89
|
};
|
|
126
90
|
exports.FronteggContext = FronteggContext;
|
|
@@ -1,61 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.getSettings = getSettings;
|
|
9
7
|
exports.updateSettings = updateSettings;
|
|
10
8
|
|
|
11
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
12
|
-
|
|
13
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
14
|
-
|
|
15
9
|
var _constants = require("../constants");
|
|
16
10
|
|
|
17
11
|
var _fetch = require("../fetch");
|
|
18
12
|
|
|
19
|
-
function updateSettings(
|
|
20
|
-
return
|
|
13
|
+
async function updateSettings(body) {
|
|
14
|
+
return (0, _fetch.Put)(_constants.urls.tenants.accountSettings.v1, body);
|
|
21
15
|
}
|
|
22
16
|
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
26
|
-
while (1) {
|
|
27
|
-
switch (_context.prev = _context.next) {
|
|
28
|
-
case 0:
|
|
29
|
-
return _context.abrupt("return", (0, _fetch.Put)(_constants.urls.tenants.accountSettings.v1, body));
|
|
30
|
-
|
|
31
|
-
case 1:
|
|
32
|
-
case "end":
|
|
33
|
-
return _context.stop();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}, _callee);
|
|
37
|
-
}));
|
|
38
|
-
return _updateSettings.apply(this, arguments);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function getSettings() {
|
|
42
|
-
return _getSettings.apply(this, arguments);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function _getSettings() {
|
|
46
|
-
_getSettings = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2() {
|
|
47
|
-
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
48
|
-
while (1) {
|
|
49
|
-
switch (_context2.prev = _context2.next) {
|
|
50
|
-
case 0:
|
|
51
|
-
return _context2.abrupt("return", (0, _fetch.Get)(_constants.urls.tenants.accountSettings.v1));
|
|
52
|
-
|
|
53
|
-
case 1:
|
|
54
|
-
case "end":
|
|
55
|
-
return _context2.stop();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}, _callee2);
|
|
59
|
-
}));
|
|
60
|
-
return _getSettings.apply(this, arguments);
|
|
17
|
+
async function getSettings() {
|
|
18
|
+
return (0, _fetch.Get)(_constants.urls.tenants.accountSettings.v1);
|
|
61
19
|
}
|