@frontegg/nextjs 6.7.9-alpha.3741489660 → 6.7.9-alpha.3787429476
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/CHANGELOG.md +4 -1
- package/{FronteggBaseProvider-5529ded6.js → FronteggClientProviderNext13-b55f477b.js} +10 -2
- package/FronteggClientProviderNext13-b55f477b.js.map +1 -0
- package/client/index.js +2 -2
- package/common/index.js +10 -2
- package/{helpers-dbf29bd5.js → helpers-dac4dc7b.js} +2 -2
- package/helpers-dac4dc7b.js.map +1 -0
- package/index.js +661 -92
- package/package.json +5 -6
- package/server/index.js +2 -3
- package/FronteggBaseProvider-5529ded6.js.map +0 -1
- package/FronteggClientProviderNext13-65bb4cd0.js +0 -19
- package/FronteggClientProviderNext13-65bb4cd0.js.map +0 -1
- package/consts-873fdf4e.js +0 -9
- package/consts-873fdf4e.js.map +0 -1
- package/helpers-dbf29bd5.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
## [6.7.9](https://github.com/frontegg/frontegg-nextjs/compare/v6.7.8...v6.7.9) (2022-12-
|
|
3
|
+
## [6.7.9](https://github.com/frontegg/frontegg-nextjs/compare/v6.7.8...v6.7.9) (2022-12-27)
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
### NextJS Wrapper 6.7.9:
|
|
7
|
+
- FR-10166 - update code owners
|
|
8
|
+
- FR-10106-FR-10103- Make package output both cjs and esm and support useAuthUser for SSR
|
|
6
9
|
|
|
7
10
|
## [6.7.8](https://github.com/frontegg/frontegg-nextjs/compare/v6.7.7...v6.7.8) (2022-12-20)
|
|
8
11
|
|
|
@@ -5,6 +5,7 @@ import { fronteggAuthApiRoutes, ContextHolder } from '@frontegg/rest-api';
|
|
|
5
5
|
import React, { createContext, useEffect, useRef, useCallback, useMemo } from 'react';
|
|
6
6
|
import { AppHolder, initialize } from '@frontegg/js';
|
|
7
7
|
import { createFronteggStore } from '@frontegg/redux-store';
|
|
8
|
+
import { useRouter } from 'next/navigation';
|
|
8
9
|
|
|
9
10
|
var AppContext = createContext(null);
|
|
10
11
|
|
|
@@ -115,5 +116,12 @@ var FronteggBaseProvider = function (props) {
|
|
|
115
116
|
props.children));
|
|
116
117
|
};
|
|
117
118
|
|
|
118
|
-
|
|
119
|
-
|
|
119
|
+
var FronteggClientProviderNext13 = function (_a) {
|
|
120
|
+
var children = _a.children, basename = _a.basename, props = __rest(_a, ["children", "basename"]);
|
|
121
|
+
var router = useRouter();
|
|
122
|
+
var basePath = process.env.__NEXT_ROUTER_BASEPATH || '';
|
|
123
|
+
return (React.createElement(FronteggBaseProvider, __assign({ router: router, basename: basename !== null && basename !== void 0 ? basename : basePath }, props), children));
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export { AppContext as A, FronteggClientProviderNext13 as F };
|
|
127
|
+
//# sourceMappingURL=FronteggClientProviderNext13-b55f477b.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FronteggClientProviderNext13-b55f477b.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/client/index.js
CHANGED
|
@@ -8,11 +8,11 @@ import 'jose';
|
|
|
8
8
|
import { useLoginWithRedirect, useLoginActions } from '@frontegg/react-hooks';
|
|
9
9
|
import '@frontegg/rest-api';
|
|
10
10
|
import { useContext, useEffect } from 'react';
|
|
11
|
-
import { A as AppContext } from '../
|
|
11
|
+
import { A as AppContext } from '../FronteggClientProviderNext13-b55f477b.js';
|
|
12
|
+
export { F as FronteggClientProviderNext13 } from '../FronteggClientProviderNext13-b55f477b.js';
|
|
12
13
|
import '@frontegg/js';
|
|
13
14
|
import { authInitialState } from '@frontegg/redux-store';
|
|
14
15
|
import { useRouter, notFound } from 'next/navigation';
|
|
15
|
-
export { F as FronteggClientProviderNext13 } from '../FronteggClientProviderNext13-65bb4cd0.js';
|
|
16
16
|
|
|
17
17
|
function FronteggAppRouter(_a) {
|
|
18
18
|
var _b = _a.params["frontegg-router"], pathArr = _b === void 0 ? [] : _b, searchParams = _a.searchParams;
|
package/common/index.js
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
export { F as FronteggConfig } from '../FronteggConfig-7ae86562.js';
|
|
2
|
-
export {
|
|
2
|
+
export { b as addToCookies, c as createCookie, e as createSessionFromAccessToken, a as getMeAndTenants, g as getTokensFromCookie, m as modifySetCookieIfUnsecure, p as parseCookieFromArray, d as removeCookies, r as rewriteCookieProperty } from '../helpers-dac4dc7b.js';
|
|
3
3
|
export { g as getCookieFromRequest, p as parseCookie } from '../getCookieFromRequest-624c37b5.js';
|
|
4
4
|
export { c as createGetSession } from '../createGetSession-81b1748e.js';
|
|
5
|
-
export { f as fronteggErrors } from '../consts-873fdf4e.js';
|
|
6
5
|
import 'tslib';
|
|
7
6
|
import 'jose';
|
|
8
7
|
import '../api-70f0e81e.js';
|
|
9
8
|
import '@frontegg/rest-api';
|
|
10
9
|
import 'cookie';
|
|
11
10
|
import 'iron-session';
|
|
11
|
+
|
|
12
|
+
var envError = function (varName) { return "@frontegg/nextjs: .env.local must contain " + varName; };
|
|
13
|
+
var fronteggErrors = {
|
|
14
|
+
envAppUrl: envError('FRONTEGG_APP_URL'),
|
|
15
|
+
envBaseUrl: envError('FRONTEGG_BASE_URL'),
|
|
16
|
+
envClientId: envError('FRONTEGG_CLIENT_ID'),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { fronteggErrors };
|
|
12
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -185,5 +185,5 @@ function getTokensFromCookie(cookie) {
|
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
export {
|
|
189
|
-
//# sourceMappingURL=helpers-
|
|
188
|
+
export { getMeAndTenants as a, addToCookies as b, createCookie as c, removeCookies as d, createSessionFromAccessToken as e, getTokensFromCookie as g, modifySetCookieIfUnsecure as m, parseCookieFromArray as p, rewriteCookieProperty as r };
|
|
189
|
+
//# sourceMappingURL=helpers-dac4dc7b.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers-dac4dc7b.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/index.js
CHANGED
|
@@ -1,44 +1,149 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var router = require('next/router');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var reactHooks = require('@frontegg/react-hooks');
|
|
9
|
+
var restApi = require('@frontegg/rest-api');
|
|
10
|
+
var js = require('@frontegg/js');
|
|
11
|
+
var reduxStore = require('@frontegg/redux-store');
|
|
12
|
+
var jose = require('jose');
|
|
13
|
+
var cookie = require('cookie');
|
|
14
|
+
var ironSession = require('iron-session');
|
|
15
|
+
var url = require('url');
|
|
16
|
+
var httpProxy = require('http-proxy');
|
|
17
|
+
var types = require('@frontegg/types');
|
|
18
|
+
|
|
19
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
|
+
|
|
21
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
22
|
+
var cookie__default = /*#__PURE__*/_interopDefaultLegacy(cookie);
|
|
23
|
+
var httpProxy__default = /*#__PURE__*/_interopDefaultLegacy(httpProxy);
|
|
24
|
+
|
|
25
|
+
var AppContext = React.createContext(null);
|
|
26
|
+
|
|
27
|
+
var createOrGetFronteggApp = function (_a) {
|
|
28
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
29
|
+
var options = _a.options, onRedirectTo = _a.onRedirectTo, appName = _a.appName, user = _a.user, tenants = _a.tenants, storeHolder = _a.storeHolder;
|
|
30
|
+
var _l = (_b = options.session) !== null && _b !== void 0 ? _b : {}, accessToken = _l.accessToken, refreshToken = _l.refreshToken;
|
|
31
|
+
var contextOptions = tslib.__assign(tslib.__assign({ requestCredentials: 'include' }, options.contextOptions), { baseUrl: function (path) {
|
|
32
|
+
if (restApi.fronteggAuthApiRoutes.indexOf(path) !== -1 ||
|
|
33
|
+
path.endsWith('/postlogin') ||
|
|
34
|
+
path.endsWith('/prelogin') ||
|
|
35
|
+
path === '/oauth/token') {
|
|
36
|
+
return options.envAppUrl + "/api";
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return options.envBaseUrl;
|
|
40
|
+
}
|
|
41
|
+
}, clientId: options.envClientId });
|
|
42
|
+
var tenantsState = tenants
|
|
43
|
+
? tslib.__assign({ tenantTree: null, subTenants: [], tenants: tenants, loading: false }, (_c = options.authOptions) === null || _c === void 0 ? void 0 : _c.tenantsState) : undefined;
|
|
44
|
+
var userData = user
|
|
45
|
+
? tslib.__assign(tslib.__assign(tslib.__assign({}, user), { accessToken: accessToken !== null && accessToken !== void 0 ? accessToken : '', refreshToken: refreshToken !== null && refreshToken !== void 0 ? refreshToken : undefined }), (_d = options.authOptions) === null || _d === void 0 ? void 0 : _d.user) : null;
|
|
46
|
+
var authOptions = tslib.__assign(tslib.__assign({}, options.authOptions), { onRedirectTo: onRedirectTo, isLoading: false, isAuthenticated: !!options.session, hostedLoginBox: (_e = options.hostedLoginBox) !== null && _e !== void 0 ? _e : false, disableSilentRefresh: (_g = (_f = options.authOptions) === null || _f === void 0 ? void 0 : _f.disableSilentRefresh) !== null && _g !== void 0 ? _g : false, user: userData, tenantsState: tenantsState });
|
|
47
|
+
var sharedStore = reduxStore.createFronteggStore({ context: contextOptions }, storeHolder.current, options.previewMode, authOptions, {
|
|
48
|
+
auth: authOptions !== null && authOptions !== void 0 ? authOptions : {},
|
|
49
|
+
audits: (_h = options.auditsOptions) !== null && _h !== void 0 ? _h : {},
|
|
50
|
+
}, false, options.urlStrategy);
|
|
51
|
+
var createdApp;
|
|
52
|
+
try {
|
|
53
|
+
createdApp = js.AppHolder.getInstance(appName !== null && appName !== void 0 ? appName : 'default');
|
|
54
|
+
createdApp.store = sharedStore;
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
createdApp = js.initialize(tslib.__assign(tslib.__assign({}, options), { store: sharedStore, hostedLoginBox: (_j = options.hostedLoginBox) !== null && _j !== void 0 ? _j : false, customLoginBox: (_k = options.customLoginBox) !== null && _k !== void 0 ? _k : false, basename: options.basename, authOptions: authOptions,
|
|
58
|
+
contextOptions: contextOptions,
|
|
59
|
+
onRedirectTo: onRedirectTo }), appName !== null && appName !== void 0 ? appName : 'default');
|
|
60
|
+
}
|
|
61
|
+
return createdApp;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
var ExpireInListener = function () {
|
|
65
|
+
var user = reactHooks.useAuthUserOrNull();
|
|
66
|
+
var actions = reactHooks.useAuthActions();
|
|
67
|
+
React.useEffect(function () {
|
|
68
|
+
if (user && (user === null || user === void 0 ? void 0 : user.expiresIn) == null) {
|
|
69
|
+
actions.setUser(tslib.__assign(tslib.__assign({}, user), { expiresIn: Math.floor((user['exp'] * 1000 - Date.now()) / 1000) }));
|
|
70
|
+
}
|
|
71
|
+
}, [actions, user]);
|
|
72
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
73
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
var useRequestAuthorizeSSR = function (_a) {
|
|
77
|
+
var app = _a.app, accessToken = _a.accessToken, user = _a.user, tenants = _a.tenants, refreshToken = _a.refreshToken;
|
|
78
|
+
React.useEffect(function () {
|
|
79
|
+
app === null || app === void 0 ? void 0 : app.store.dispatch({
|
|
80
|
+
type: 'auth/requestAuthorizeSSR',
|
|
81
|
+
payload: {
|
|
82
|
+
accessToken: accessToken,
|
|
83
|
+
user: user ? tslib.__assign(tslib.__assign({}, user), { refreshToken: refreshToken }) : null,
|
|
84
|
+
tenants: tenants,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
}, [app]);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
var Connector$1 = function (_a) {
|
|
91
|
+
var _b, _c;
|
|
92
|
+
var router = _a.router, _d = _a.appName, appName = _d === void 0 ? 'default' : _d, user = _a.user, tenants = _a.tenants, props = tslib.__rest(_a, ["router", "appName", "user", "tenants"]);
|
|
93
|
+
var isSSR = typeof window === 'undefined';
|
|
94
|
+
var _e = (_b = props.session) !== null && _b !== void 0 ? _b : {}, accessToken = _e.accessToken, refreshToken = _e.refreshToken;
|
|
95
|
+
var baseName = (_c = props.basename) !== null && _c !== void 0 ? _c : '';
|
|
96
|
+
var storeHolder = React.useRef({});
|
|
97
|
+
var onRedirectTo = React.useCallback(function (_path, opts) {
|
|
98
|
+
var path = _path;
|
|
99
|
+
if (path.startsWith(baseName)) {
|
|
100
|
+
path = path.substring(baseName.length);
|
|
101
|
+
}
|
|
102
|
+
if (opts === null || opts === void 0 ? void 0 : opts.preserveQueryParams) {
|
|
103
|
+
path = "" + path + window.location.search;
|
|
104
|
+
}
|
|
105
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.refresh) && !isSSR) {
|
|
106
|
+
// @ts-ignore
|
|
107
|
+
window.Cypress ? router.push(path) : (window.location.href = path);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
(opts === null || opts === void 0 ? void 0 : opts.replace) ? router.replace(path) : router.push(path);
|
|
111
|
+
}
|
|
112
|
+
}, []);
|
|
113
|
+
var app = React.useMemo(function () {
|
|
114
|
+
return createOrGetFronteggApp({
|
|
115
|
+
options: tslib.__assign(tslib.__assign({}, props), { basename: baseName }),
|
|
116
|
+
user: user,
|
|
117
|
+
tenants: tenants,
|
|
118
|
+
onRedirectTo: onRedirectTo,
|
|
119
|
+
appName: appName,
|
|
120
|
+
storeHolder: storeHolder,
|
|
121
|
+
});
|
|
122
|
+
}, [props]);
|
|
123
|
+
restApi.ContextHolder.setOnRedirectTo(onRedirectTo);
|
|
124
|
+
useRequestAuthorizeSSR({ app: app, accessToken: accessToken, user: user, tenants: tenants, refreshToken: refreshToken });
|
|
125
|
+
return (React__default["default"].createElement(AppContext.Provider, { value: app },
|
|
126
|
+
React__default["default"].createElement(reactHooks.FronteggStoreProvider, tslib.__assign({}, tslib.__assign(tslib.__assign({}, props), { app: app })), props.children)));
|
|
127
|
+
};
|
|
128
|
+
var FronteggBaseProvider = function (props) {
|
|
129
|
+
return (React__default["default"].createElement(Connector$1, tslib.__assign({}, props, { framework: 'nextjs' }),
|
|
130
|
+
React__default["default"].createElement(ExpireInListener, null),
|
|
131
|
+
props.children));
|
|
132
|
+
};
|
|
28
133
|
|
|
29
134
|
var FronteggProvider = function (_a) {
|
|
30
|
-
var children = _a.children, basename = _a.basename, props = __rest(_a, ["children", "basename"]);
|
|
31
|
-
var router = useRouter();
|
|
32
|
-
var baseName = basename !== null && basename !== void 0 ? basename : router.basePath;
|
|
33
|
-
return (
|
|
135
|
+
var children = _a.children, basename = _a.basename, props = tslib.__rest(_a, ["children", "basename"]);
|
|
136
|
+
var router$1 = router.useRouter();
|
|
137
|
+
var baseName = basename !== null && basename !== void 0 ? basename : router$1.basePath;
|
|
138
|
+
return (React__default["default"].createElement(FronteggBaseProvider, tslib.__assign({ router: router$1, basename: baseName }, props), children));
|
|
34
139
|
};
|
|
35
140
|
|
|
36
141
|
var Connector = function (_props) {
|
|
37
142
|
var _a;
|
|
38
|
-
var router = _props.router, appName = _props.appName, hostedLoginBox = _props.hostedLoginBox; _props.customLoginBox; var props = __rest(_props, ["router", "appName", "hostedLoginBox", "customLoginBox"]);
|
|
143
|
+
var router = _props.router, appName = _props.appName, hostedLoginBox = _props.hostedLoginBox; _props.customLoginBox; var props = tslib.__rest(_props, ["router", "appName", "hostedLoginBox", "customLoginBox"]);
|
|
39
144
|
var isSSR = typeof window === 'undefined';
|
|
40
145
|
var baseName = (_a = props.basename) !== null && _a !== void 0 ? _a : router.basePath;
|
|
41
|
-
var onRedirectTo = useCallback(function (_path, opts) {
|
|
146
|
+
var onRedirectTo = React.useCallback(function (_path, opts) {
|
|
42
147
|
var path = _path;
|
|
43
148
|
if (path.startsWith(baseName)) {
|
|
44
149
|
path = path.substring(baseName.length);
|
|
@@ -54,38 +159,38 @@ var Connector = function (_props) {
|
|
|
54
159
|
(opts === null || opts === void 0 ? void 0 : opts.replace) ? router.replace(path) : router.push(path);
|
|
55
160
|
}
|
|
56
161
|
}, []);
|
|
57
|
-
var app = useMemo(function () {
|
|
162
|
+
var app = React.useMemo(function () {
|
|
58
163
|
var _a;
|
|
59
164
|
var createdApp;
|
|
60
165
|
try {
|
|
61
|
-
createdApp = AppHolder.getInstance(appName !== null && appName !== void 0 ? appName : 'default');
|
|
166
|
+
createdApp = js.AppHolder.getInstance(appName !== null && appName !== void 0 ? appName : 'default');
|
|
62
167
|
}
|
|
63
168
|
catch (e) {
|
|
64
|
-
createdApp = initialize(__assign(__assign({}, props), { hostedLoginBox: hostedLoginBox !== null && hostedLoginBox !== void 0 ? hostedLoginBox : false, basename: (_a = props.basename) !== null && _a !== void 0 ? _a : baseName, authOptions: __assign(__assign({}, props.authOptions), { onRedirectTo: onRedirectTo }), contextOptions: __assign({ requestCredentials: 'include' }, props.contextOptions), onRedirectTo: onRedirectTo }), appName !== null && appName !== void 0 ? appName : 'default');
|
|
169
|
+
createdApp = js.initialize(tslib.__assign(tslib.__assign({}, props), { hostedLoginBox: hostedLoginBox !== null && hostedLoginBox !== void 0 ? hostedLoginBox : false, basename: (_a = props.basename) !== null && _a !== void 0 ? _a : baseName, authOptions: tslib.__assign(tslib.__assign({}, props.authOptions), { onRedirectTo: onRedirectTo }), contextOptions: tslib.__assign({ requestCredentials: 'include' }, props.contextOptions), onRedirectTo: onRedirectTo }), appName !== null && appName !== void 0 ? appName : 'default');
|
|
65
170
|
}
|
|
66
171
|
return createdApp;
|
|
67
172
|
}, [appName, props, hostedLoginBox, baseName, onRedirectTo]);
|
|
68
|
-
ContextHolder.setOnRedirectTo(onRedirectTo);
|
|
69
|
-
useEffect(function () {
|
|
173
|
+
restApi.ContextHolder.setOnRedirectTo(onRedirectTo);
|
|
174
|
+
React.useEffect(function () {
|
|
70
175
|
app.store.dispatch({ type: 'auth/requestAuthorize', payload: true });
|
|
71
176
|
}, [app]);
|
|
72
|
-
return (
|
|
73
|
-
|
|
177
|
+
return (React__default["default"].createElement(AppContext.Provider, { value: app },
|
|
178
|
+
React__default["default"].createElement(reactHooks.FronteggStoreProvider, tslib.__assign({}, tslib.__assign(tslib.__assign({}, props), { app: app })), props.children)));
|
|
74
179
|
};
|
|
75
180
|
var FronteggNextJSProvider = function (props) {
|
|
76
|
-
var router = useRouter();
|
|
77
|
-
return (
|
|
78
|
-
|
|
181
|
+
var router$1 = router.useRouter();
|
|
182
|
+
return (React__default["default"].createElement(Connector, tslib.__assign({}, props, { router: router$1 }),
|
|
183
|
+
React__default["default"].createElement(ExpireInListener, null),
|
|
79
184
|
props.children));
|
|
80
185
|
};
|
|
81
186
|
var FronteggProviderNoSSR = function (props) {
|
|
82
|
-
return (
|
|
187
|
+
return (React__default["default"].createElement(FronteggNextJSProvider, tslib.__assign({}, props, { framework: 'nextjs' }), props.children));
|
|
83
188
|
};
|
|
84
189
|
|
|
85
190
|
var AuthorizedContent = function (props) {
|
|
86
191
|
var _a, _b;
|
|
87
192
|
var isAuthorized = true; // Initially
|
|
88
|
-
var user = useAuthUserOrNull();
|
|
193
|
+
var user = reactHooks.useAuthUserOrNull();
|
|
89
194
|
if (!(user === null || user === void 0 ? void 0 : user.superUser)) {
|
|
90
195
|
if (props.requiredPermissions) {
|
|
91
196
|
if (!(user === null || user === void 0 ? void 0 : user.permissions) || (user === null || user === void 0 ? void 0 : user.permissions.length) === 0) {
|
|
@@ -123,23 +228,448 @@ var AuthorizedContent = function (props) {
|
|
|
123
228
|
}
|
|
124
229
|
}
|
|
125
230
|
if (typeof props.render === 'function') {
|
|
126
|
-
return
|
|
231
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null, props.render(isAuthorized));
|
|
232
|
+
}
|
|
233
|
+
return isAuthorized ? React__default["default"].createElement(React__default["default"].Fragment, null, props.children) : null;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
function normalizeStringPasswordToMap(password) {
|
|
237
|
+
return typeof password === 'string' ? { 1: password } : password;
|
|
238
|
+
}
|
|
239
|
+
var FronteggConfig = /** @class */ (function () {
|
|
240
|
+
function FronteggConfig() {
|
|
241
|
+
var _a, _b, _c;
|
|
242
|
+
this.authRoutes = {};
|
|
243
|
+
this.fronteggAppOptions = {};
|
|
244
|
+
this._clientId = (_a = process.env['FRONTEGG_CLIENT_ID']) !== null && _a !== void 0 ? _a : '';
|
|
245
|
+
this._cookieName = (_b = process.env['FRONTEGG_COOKIE_NAME']) !== null && _b !== void 0 ? _b : "fe_next_session";
|
|
246
|
+
this._password = (_c = process.env['FRONTEGG_ENCRYPTION_PASSWORD']) !== null && _c !== void 0 ? _c : '';
|
|
247
|
+
this._passwordsAsMap = normalizeStringPasswordToMap(this._password);
|
|
127
248
|
}
|
|
128
|
-
|
|
249
|
+
Object.defineProperty(FronteggConfig.prototype, "cookieName", {
|
|
250
|
+
get: function () {
|
|
251
|
+
return this._cookieName + "-" + this._clientId.replace(/-/g, '');
|
|
252
|
+
},
|
|
253
|
+
enumerable: false,
|
|
254
|
+
configurable: true
|
|
255
|
+
});
|
|
256
|
+
Object.defineProperty(FronteggConfig.prototype, "password", {
|
|
257
|
+
get: function () {
|
|
258
|
+
return this._password;
|
|
259
|
+
},
|
|
260
|
+
enumerable: false,
|
|
261
|
+
configurable: true
|
|
262
|
+
});
|
|
263
|
+
Object.defineProperty(FronteggConfig.prototype, "clientId", {
|
|
264
|
+
get: function () {
|
|
265
|
+
return this._clientId;
|
|
266
|
+
},
|
|
267
|
+
enumerable: false,
|
|
268
|
+
configurable: true
|
|
269
|
+
});
|
|
270
|
+
Object.defineProperty(FronteggConfig.prototype, "baseUrlHost", {
|
|
271
|
+
get: function () {
|
|
272
|
+
var _a;
|
|
273
|
+
return new URL((_a = process.env['FRONTEGG_BASE_URL']) !== null && _a !== void 0 ? _a : '').hostname;
|
|
274
|
+
},
|
|
275
|
+
enumerable: false,
|
|
276
|
+
configurable: true
|
|
277
|
+
});
|
|
278
|
+
FronteggConfig.prototype.getEnvAppUrl = function () {
|
|
279
|
+
var url = undefined;
|
|
280
|
+
if (process.env['FRONTEGG_APP_URL']) {
|
|
281
|
+
url = process.env['FRONTEGG_APP_URL'];
|
|
282
|
+
}
|
|
283
|
+
else if (process.env['VERCEL'] && process.env['VERCEL_URL']) {
|
|
284
|
+
url = process.env['VERCEL_URL'];
|
|
285
|
+
}
|
|
286
|
+
if (url && !url.startsWith('http')) {
|
|
287
|
+
var protocol = url.startsWith('localhost') ? 'http://' : 'https://';
|
|
288
|
+
url = "" + protocol + url;
|
|
289
|
+
}
|
|
290
|
+
return url;
|
|
291
|
+
};
|
|
292
|
+
Object.defineProperty(FronteggConfig.prototype, "appUrl", {
|
|
293
|
+
get: function () {
|
|
294
|
+
var _a;
|
|
295
|
+
return (_a = this.getEnvAppUrl()) !== null && _a !== void 0 ? _a : 'http://localhost:3000';
|
|
296
|
+
},
|
|
297
|
+
enumerable: false,
|
|
298
|
+
configurable: true
|
|
299
|
+
});
|
|
300
|
+
Object.defineProperty(FronteggConfig.prototype, "appEnvConfig", {
|
|
301
|
+
get: function () {
|
|
302
|
+
return {
|
|
303
|
+
envAppUrl: this.getEnvAppUrl(),
|
|
304
|
+
envBaseUrl: process.env['FRONTEGG_BASE_URL'],
|
|
305
|
+
envClientId: process.env['FRONTEGG_CLIENT_ID'],
|
|
306
|
+
};
|
|
307
|
+
},
|
|
308
|
+
enumerable: false,
|
|
309
|
+
configurable: true
|
|
310
|
+
});
|
|
311
|
+
Object.defineProperty(FronteggConfig.prototype, "cookieDomain", {
|
|
312
|
+
get: function () {
|
|
313
|
+
var _a;
|
|
314
|
+
return new URL((_a = this.getEnvAppUrl()) !== null && _a !== void 0 ? _a : '').hostname.replace(/:(\d)+$/, '');
|
|
315
|
+
},
|
|
316
|
+
enumerable: false,
|
|
317
|
+
configurable: true
|
|
318
|
+
});
|
|
319
|
+
FronteggConfig.prototype.getJwtPublicKey = function () {
|
|
320
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
321
|
+
var response, data, publicKey, _a;
|
|
322
|
+
return tslib.__generator(this, function (_b) {
|
|
323
|
+
switch (_b.label) {
|
|
324
|
+
case 0:
|
|
325
|
+
if (!!this._jwtPublicKey) return [3 /*break*/, 4];
|
|
326
|
+
return [4 /*yield*/, fetch(process.env['FRONTEGG_BASE_URL'] + "/.well-known/jwks.json")];
|
|
327
|
+
case 1:
|
|
328
|
+
response = _b.sent();
|
|
329
|
+
return [4 /*yield*/, response.json()];
|
|
330
|
+
case 2:
|
|
331
|
+
data = _b.sent();
|
|
332
|
+
publicKey = data.keys.find(function (key) { return key.kty === 'RSA'; });
|
|
333
|
+
_a = this;
|
|
334
|
+
return [4 /*yield*/, jose.importJWK(publicKey)];
|
|
335
|
+
case 3:
|
|
336
|
+
_a._jwtPublicKey = _b.sent();
|
|
337
|
+
_b.label = 4;
|
|
338
|
+
case 4: return [2 /*return*/, this._jwtPublicKey];
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
};
|
|
343
|
+
Object.defineProperty(FronteggConfig.prototype, "passwordsAsMap", {
|
|
344
|
+
get: function () {
|
|
345
|
+
return this._passwordsAsMap;
|
|
346
|
+
},
|
|
347
|
+
enumerable: false,
|
|
348
|
+
configurable: true
|
|
349
|
+
});
|
|
350
|
+
return FronteggConfig;
|
|
351
|
+
}());
|
|
352
|
+
var fronteggConfig = new FronteggConfig();
|
|
353
|
+
|
|
354
|
+
var BASE_URL = process.env['FRONTEGG_BASE_URL'] + "/frontegg";
|
|
355
|
+
var Get = function (_a) {
|
|
356
|
+
var url = _a.url, _b = _a.credentials, credentials = _b === void 0 ? 'include' : _b, headers = _a.headers;
|
|
357
|
+
return fetch(url, { method: 'GET', credentials: credentials, headers: headers });
|
|
358
|
+
};
|
|
359
|
+
var extractHeaders = function (headers) { return ({
|
|
360
|
+
'accept-encoding': headers['accept-encoding'],
|
|
361
|
+
'accept-language': headers['accept-language'],
|
|
362
|
+
cookie: headers['cookie'],
|
|
363
|
+
accept: headers['accept'],
|
|
364
|
+
'user-agent': headers['user-agent'],
|
|
365
|
+
// connection: headers['connection'],
|
|
366
|
+
'cache-control': headers['cache-control'],
|
|
367
|
+
Authorization: headers['Authorization'],
|
|
368
|
+
}); };
|
|
369
|
+
var parseResponse = function (res) { return tslib.__awaiter(void 0, void 0, void 0, function () {
|
|
370
|
+
var resText;
|
|
371
|
+
return tslib.__generator(this, function (_a) {
|
|
372
|
+
switch (_a.label) {
|
|
373
|
+
case 0:
|
|
374
|
+
if (!res.ok) {
|
|
375
|
+
return [2 /*return*/, undefined];
|
|
376
|
+
}
|
|
377
|
+
return [4 /*yield*/, res.text()];
|
|
378
|
+
case 1:
|
|
379
|
+
resText = _a.sent();
|
|
380
|
+
return [2 /*return*/, JSON.parse(resText)];
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
}); };
|
|
384
|
+
var getUsers = function (headers) { return tslib.__awaiter(void 0, void 0, void 0, function () {
|
|
385
|
+
var res;
|
|
386
|
+
return tslib.__generator(this, function (_a) {
|
|
387
|
+
switch (_a.label) {
|
|
388
|
+
case 0: return [4 /*yield*/, Get({ url: "" + BASE_URL + restApi.fronteggUsersUrl, headers: extractHeaders(headers) })];
|
|
389
|
+
case 1:
|
|
390
|
+
res = _a.sent();
|
|
391
|
+
return [2 /*return*/, parseResponse(res)];
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
}); };
|
|
395
|
+
var getTenants = function (headers) { return tslib.__awaiter(void 0, void 0, void 0, function () {
|
|
396
|
+
var res;
|
|
397
|
+
return tslib.__generator(this, function (_a) {
|
|
398
|
+
switch (_a.label) {
|
|
399
|
+
case 0: return [4 /*yield*/, Get({ url: "" + BASE_URL + restApi.fronteggTenantsUrl, headers: extractHeaders(headers) })];
|
|
400
|
+
case 1:
|
|
401
|
+
res = _a.sent();
|
|
402
|
+
return [2 /*return*/, parseResponse(res)];
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
}); };
|
|
406
|
+
|
|
407
|
+
function getMeAndTenants(reqHeaders, accessToken) {
|
|
408
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
409
|
+
var headers, _a, user, tenants;
|
|
410
|
+
return tslib.__generator(this, function (_b) {
|
|
411
|
+
switch (_b.label) {
|
|
412
|
+
case 0:
|
|
413
|
+
if (!reqHeaders || !accessToken) {
|
|
414
|
+
return [2 /*return*/, {}];
|
|
415
|
+
}
|
|
416
|
+
headers = tslib.__assign(tslib.__assign({}, reqHeaders), { Authorization: "Bearer " + accessToken });
|
|
417
|
+
return [4 /*yield*/, Promise.all([getUsers(headers), getTenants(headers)])];
|
|
418
|
+
case 1:
|
|
419
|
+
_a = _b.sent(), user = _a[0], tenants = _a[1];
|
|
420
|
+
return [2 /*return*/, { user: user, tenants: tenants }];
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
function rewriteCookieProperty(header, config, property) {
|
|
427
|
+
if (Array.isArray(header)) {
|
|
428
|
+
return header.map(function (headerElement) {
|
|
429
|
+
return rewriteCookieProperty(headerElement, config, property);
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
return header.replace(new RegExp('(;\\s*' + property + '=)([^;]+)', 'i'), function (match, prefix, previousValue) {
|
|
433
|
+
var newValue;
|
|
434
|
+
if (previousValue in config) {
|
|
435
|
+
newValue = config[previousValue];
|
|
436
|
+
}
|
|
437
|
+
else if ('*' in config) {
|
|
438
|
+
newValue = config['*'];
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
// no match, return previous value
|
|
442
|
+
return match;
|
|
443
|
+
}
|
|
444
|
+
if (newValue) {
|
|
445
|
+
// replace value
|
|
446
|
+
return prefix + newValue;
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
// remove value
|
|
450
|
+
return '';
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
var COOKIE_MAX_LENGTH = 4096;
|
|
455
|
+
function createCookie(_a) {
|
|
456
|
+
var _b = _a.cookieName, cookieName = _b === void 0 ? fronteggConfig.cookieName : _b, session = _a.session, expires = _a.expires, isSecured = _a.isSecured, _c = _a.cookieDomain, cookieDomain = _c === void 0 ? fronteggConfig.cookieDomain : _c, _d = _a.httpOnly, httpOnly = _d === void 0 ? true : _d, _e = _a.path, path = _e === void 0 ? '/' : _e;
|
|
457
|
+
var options = {
|
|
458
|
+
expires: expires,
|
|
459
|
+
httpOnly: httpOnly,
|
|
460
|
+
domain: cookieDomain,
|
|
461
|
+
path: path,
|
|
462
|
+
sameSite: isSecured ? 'none' : undefined,
|
|
463
|
+
secure: isSecured,
|
|
464
|
+
};
|
|
465
|
+
var cookieValue = cookie__default["default"].serialize(cookieName, session, options);
|
|
466
|
+
if (cookieValue.length < COOKIE_MAX_LENGTH) {
|
|
467
|
+
return [cookieValue];
|
|
468
|
+
}
|
|
469
|
+
return createSplitCookie(cookieName, session, options, cookieValue.length);
|
|
470
|
+
}
|
|
471
|
+
function createSplitCookie(cookieName, session, options, cookieLength) {
|
|
472
|
+
var numberOfCookies = Math.ceil(cookieLength / COOKIE_MAX_LENGTH);
|
|
473
|
+
var splitSession = chunkString(session, numberOfCookies);
|
|
474
|
+
var allCookies = [];
|
|
475
|
+
for (var i = 1; i <= numberOfCookies; i++) {
|
|
476
|
+
allCookies.push(cookie__default["default"].serialize(cookieName + "-" + i, splitSession[i - 1], options));
|
|
477
|
+
}
|
|
478
|
+
return allCookies;
|
|
479
|
+
}
|
|
480
|
+
function chunkString(str, numChunks) {
|
|
481
|
+
var chunkSize = Math.ceil(str.length / numChunks);
|
|
482
|
+
var chunks = [];
|
|
483
|
+
for (var i = 0; i < numChunks; i + chunkSize) {
|
|
484
|
+
var limit = i + chunkSize;
|
|
485
|
+
chunks.push(str.substring(i, limit < str.length ? limit : str.length));
|
|
486
|
+
}
|
|
487
|
+
return chunks;
|
|
488
|
+
}
|
|
489
|
+
function parseCookieFromArray(cookies) {
|
|
490
|
+
var userCookie = cookies.find(function (c) { return c.name === fronteggConfig.cookieName; });
|
|
491
|
+
if (userCookie) {
|
|
492
|
+
return userCookie.value;
|
|
493
|
+
}
|
|
494
|
+
var cookieChunks = cookies.filter(function (c) { return c.name.includes(fronteggConfig.cookieName); });
|
|
495
|
+
if (!cookieChunks) {
|
|
496
|
+
return undefined;
|
|
497
|
+
}
|
|
498
|
+
cookieChunks.sort(function (a, b) { return (parseInt(a.name) > parseInt(b.name) ? 1 : -1); });
|
|
499
|
+
return cookieChunks.map(function (c) { return c.value; }).join();
|
|
500
|
+
}
|
|
501
|
+
function addToCookies(newCookies, res) {
|
|
502
|
+
var _a;
|
|
503
|
+
var existingSetCookie = (_a = res.getHeader('set-cookie')) !== null && _a !== void 0 ? _a : [];
|
|
504
|
+
if (typeof existingSetCookie === 'string') {
|
|
505
|
+
existingSetCookie = [existingSetCookie];
|
|
506
|
+
}
|
|
507
|
+
res.setHeader('set-cookie', tslib.__spreadArrays(existingSetCookie, newCookies));
|
|
508
|
+
}
|
|
509
|
+
function removeCookies(cookieName, isSecured, cookieDomain, res) {
|
|
510
|
+
var _a;
|
|
511
|
+
var cookieValue = createCookie({ cookieName: cookieName, session: '', expires: new Date(), isSecured: isSecured, cookieDomain: cookieDomain });
|
|
512
|
+
var existingSetCookie = (_a = res.getHeader('set-cookie')) !== null && _a !== void 0 ? _a : [];
|
|
513
|
+
if (typeof existingSetCookie === 'string') {
|
|
514
|
+
existingSetCookie = [existingSetCookie];
|
|
515
|
+
}
|
|
516
|
+
res.setHeader('set-cookie', tslib.__spreadArrays(existingSetCookie, cookieValue));
|
|
517
|
+
}
|
|
518
|
+
function createSessionFromAccessToken(output) {
|
|
519
|
+
var _a, _b;
|
|
520
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
521
|
+
var data, accessToken, refreshToken, publicKey, decodedJwt, stringifySession, session;
|
|
522
|
+
return tslib.__generator(this, function (_c) {
|
|
523
|
+
switch (_c.label) {
|
|
524
|
+
case 0:
|
|
525
|
+
_c.trys.push([0, 4, , 5]);
|
|
526
|
+
data = JSON.parse(output);
|
|
527
|
+
accessToken = (_a = data === null || data === void 0 ? void 0 : data.accessToken) !== null && _a !== void 0 ? _a : data.access_token;
|
|
528
|
+
refreshToken = (_b = data === null || data === void 0 ? void 0 : data.refreshToken) !== null && _b !== void 0 ? _b : data.refresh_token;
|
|
529
|
+
return [4 /*yield*/, fronteggConfig.getJwtPublicKey()];
|
|
530
|
+
case 1:
|
|
531
|
+
publicKey = _c.sent();
|
|
532
|
+
return [4 /*yield*/, jose.jwtVerify(accessToken, publicKey)];
|
|
533
|
+
case 2:
|
|
534
|
+
decodedJwt = (_c.sent()).payload;
|
|
535
|
+
decodedJwt.expiresIn = Math.floor((decodedJwt.exp * 1000 - Date.now()) / 1000);
|
|
536
|
+
stringifySession = JSON.stringify({ accessToken: accessToken, refreshToken: refreshToken });
|
|
537
|
+
return [4 /*yield*/, ironSession.sealData(stringifySession, {
|
|
538
|
+
password: fronteggConfig.passwordsAsMap,
|
|
539
|
+
ttl: decodedJwt.exp,
|
|
540
|
+
})];
|
|
541
|
+
case 3:
|
|
542
|
+
session = _c.sent();
|
|
543
|
+
return [2 /*return*/, [session, decodedJwt, refreshToken]];
|
|
544
|
+
case 4:
|
|
545
|
+
_c.sent();
|
|
546
|
+
return [2 /*return*/, []];
|
|
547
|
+
case 5: return [2 /*return*/];
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
var modifySetCookieIfUnsecure = function (setCookieValue, isSecured) {
|
|
553
|
+
if (!setCookieValue) {
|
|
554
|
+
return setCookieValue;
|
|
555
|
+
}
|
|
556
|
+
if (setCookieValue.length > 0) {
|
|
557
|
+
return setCookieValue.map(function (c) {
|
|
558
|
+
var cookie = c.split('; ');
|
|
559
|
+
if (isSecured) {
|
|
560
|
+
return c;
|
|
561
|
+
}
|
|
562
|
+
return cookie.filter(function (property) { return property !== 'Secure' && property !== 'SameSite=None'; }).join('; ');
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
return setCookieValue;
|
|
566
|
+
};
|
|
567
|
+
function getTokensFromCookie(cookie) {
|
|
568
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
569
|
+
var stringifyJwt;
|
|
570
|
+
return tslib.__generator(this, function (_a) {
|
|
571
|
+
switch (_a.label) {
|
|
572
|
+
case 0:
|
|
573
|
+
if (!cookie) {
|
|
574
|
+
return [2 /*return*/, undefined];
|
|
575
|
+
}
|
|
576
|
+
return [4 /*yield*/, ironSession.unsealData(cookie, {
|
|
577
|
+
password: fronteggConfig.passwordsAsMap,
|
|
578
|
+
})];
|
|
579
|
+
case 1:
|
|
580
|
+
stringifyJwt = _a.sent();
|
|
581
|
+
return [2 /*return*/, JSON.parse(stringifyJwt)];
|
|
582
|
+
}
|
|
583
|
+
});
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
function parseCookie(cookieStr) {
|
|
588
|
+
var sealFromCookies = '';
|
|
589
|
+
if (cookie__default["default"].parse(cookieStr)[fronteggConfig.cookieName]) {
|
|
590
|
+
sealFromCookies = cookie__default["default"].parse(cookieStr)[fronteggConfig.cookieName];
|
|
591
|
+
}
|
|
592
|
+
else {
|
|
593
|
+
var i = 1;
|
|
594
|
+
while (cookie__default["default"].parse(cookieStr)[fronteggConfig.cookieName + "-" + i]) {
|
|
595
|
+
sealFromCookies += cookie__default["default"].parse(cookieStr)[fronteggConfig.cookieName + "-" + i];
|
|
596
|
+
i++;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
return sealFromCookies !== '' ? sealFromCookies : undefined;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
var createGetSession = function (_a) {
|
|
603
|
+
var getCookie = _a.getCookie, cookieResolver = _a.cookieResolver;
|
|
604
|
+
return tslib.__awaiter(void 0, void 0, void 0, function () {
|
|
605
|
+
var cookie, tokens, accessToken, refreshToken, publicKey, payload, session, e_1;
|
|
606
|
+
return tslib.__generator(this, function (_b) {
|
|
607
|
+
switch (_b.label) {
|
|
608
|
+
case 0:
|
|
609
|
+
_b.trys.push([0, 4, , 5]);
|
|
610
|
+
cookie = getCookie();
|
|
611
|
+
if (!cookie) {
|
|
612
|
+
return [2 /*return*/, undefined];
|
|
613
|
+
}
|
|
614
|
+
return [4 /*yield*/, cookieResolver(cookie)];
|
|
615
|
+
case 1:
|
|
616
|
+
tokens = _b.sent();
|
|
617
|
+
if (!(tokens === null || tokens === void 0 ? void 0 : tokens.accessToken)) {
|
|
618
|
+
return [2 /*return*/, undefined];
|
|
619
|
+
}
|
|
620
|
+
accessToken = tokens.accessToken, refreshToken = tokens.refreshToken;
|
|
621
|
+
return [4 /*yield*/, fronteggConfig.getJwtPublicKey()];
|
|
622
|
+
case 2:
|
|
623
|
+
publicKey = _b.sent();
|
|
624
|
+
return [4 /*yield*/, jose.jwtVerify(accessToken, publicKey)];
|
|
625
|
+
case 3:
|
|
626
|
+
payload = (_b.sent()).payload;
|
|
627
|
+
session = {
|
|
628
|
+
accessToken: accessToken,
|
|
629
|
+
user: payload,
|
|
630
|
+
refreshToken: refreshToken,
|
|
631
|
+
};
|
|
632
|
+
if (session.user.exp * 1000 < Date.now()) {
|
|
633
|
+
return [2 /*return*/, undefined];
|
|
634
|
+
}
|
|
635
|
+
return [2 /*return*/, session];
|
|
636
|
+
case 4:
|
|
637
|
+
e_1 = _b.sent();
|
|
638
|
+
console.error(e_1);
|
|
639
|
+
return [2 /*return*/, undefined];
|
|
640
|
+
case 5: return [2 /*return*/];
|
|
641
|
+
}
|
|
642
|
+
});
|
|
643
|
+
});
|
|
644
|
+
};
|
|
645
|
+
|
|
646
|
+
function getCookieFromRequest(req) {
|
|
647
|
+
if (!req) {
|
|
648
|
+
return undefined;
|
|
649
|
+
}
|
|
650
|
+
var cookieStr = 'credentials' in req ? req.headers.get('cookie') || '' : req.headers.cookie || '';
|
|
651
|
+
return parseCookie(cookieStr);
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
var envError = function (varName) { return "@frontegg/nextjs: .env.local must contain " + varName; };
|
|
655
|
+
var fronteggErrors = {
|
|
656
|
+
envAppUrl: envError('FRONTEGG_APP_URL'),
|
|
657
|
+
envBaseUrl: envError('FRONTEGG_BASE_URL'),
|
|
658
|
+
envClientId: envError('FRONTEGG_CLIENT_ID'),
|
|
129
659
|
};
|
|
130
660
|
|
|
131
661
|
function FronteggRouter() {
|
|
132
|
-
var app = useContext(AppContext);
|
|
133
|
-
var _a = useRouter(), query = _a.query, replace = _a.replace;
|
|
134
|
-
var loginWithRedirect = useLoginWithRedirect();
|
|
135
|
-
var logout = useLoginActions().logout;
|
|
136
|
-
useEffect(function () {
|
|
662
|
+
var app = React.useContext(AppContext);
|
|
663
|
+
var _a = router.useRouter(), query = _a.query, replace = _a.replace;
|
|
664
|
+
var loginWithRedirect = reactHooks.useLoginWithRedirect();
|
|
665
|
+
var logout = reactHooks.useLoginActions().logout;
|
|
666
|
+
React.useEffect(function () {
|
|
137
667
|
if (!app) {
|
|
138
668
|
return;
|
|
139
669
|
}
|
|
140
670
|
if (app.options.hostedLoginBox) {
|
|
141
|
-
var routesObj = __assign(__assign({}, authInitialState.routes),
|
|
142
|
-
var _a = query, pathArr = _a["frontegg-router"], queryParams = __rest(_a, ['frontegg-router']);
|
|
671
|
+
var routesObj = tslib.__assign(tslib.__assign({}, reduxStore.authInitialState.routes), fronteggConfig.authRoutes);
|
|
672
|
+
var _a = query, pathArr = _a["frontegg-router"], queryParams = tslib.__rest(_a, ['frontegg-router']);
|
|
143
673
|
var pathname = "/" + pathArr.join('/');
|
|
144
674
|
if (pathname === routesObj.loginUrl) {
|
|
145
675
|
if (queryParams.redirectUrl) {
|
|
@@ -160,15 +690,15 @@ function FronteggRouter() {
|
|
|
160
690
|
}
|
|
161
691
|
function FronteggRouterProps(context) {
|
|
162
692
|
var _a;
|
|
163
|
-
var routesObj = __assign(__assign({}, authInitialState.routes),
|
|
164
|
-
var routesArr = Object.keys(routesObj).reduce(function (p, key) { return __spreadArrays(p, [routesObj[key]]); }, []);
|
|
165
|
-
var pathname = parse((_a = context.resolvedUrl) !== null && _a !== void 0 ? _a : context.req.url, true).pathname;
|
|
693
|
+
var routesObj = tslib.__assign(tslib.__assign({}, reduxStore.authInitialState.routes), fronteggConfig.authRoutes);
|
|
694
|
+
var routesArr = Object.keys(routesObj).reduce(function (p, key) { return tslib.__spreadArrays(p, [routesObj[key]]); }, []);
|
|
695
|
+
var pathname = url.parse((_a = context.resolvedUrl) !== null && _a !== void 0 ? _a : context.req.url, true).pathname;
|
|
166
696
|
if (!pathname || pathname.startsWith('/_next/data')) {
|
|
167
697
|
var query = context.req.query[Object.keys(context.req.query)[0]];
|
|
168
698
|
pathname = "/" + (Array.isArray(query) ? query.join('/') : query);
|
|
169
699
|
}
|
|
170
700
|
var notFound = routesArr.indexOf(pathname) === -1;
|
|
171
|
-
if (
|
|
701
|
+
if (fronteggConfig.fronteggAppOptions.hostedLoginBox) {
|
|
172
702
|
var notFound_1 = !(routesObj.loginUrl === pathname ||
|
|
173
703
|
routesObj.logoutUrl === pathname ||
|
|
174
704
|
routesObj.hostedLoginRedirectUrl === pathname);
|
|
@@ -185,10 +715,10 @@ var getSession = function (req) {
|
|
|
185
715
|
};
|
|
186
716
|
function withSSRSession(handler) {
|
|
187
717
|
var _this = this;
|
|
188
|
-
return function (context) { return __awaiter(_this, void 0, void 0, function () {
|
|
718
|
+
return function (context) { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
189
719
|
var session, loginUrl;
|
|
190
720
|
var _a, _b;
|
|
191
|
-
return __generator(this, function (_c) {
|
|
721
|
+
return tslib.__generator(this, function (_c) {
|
|
192
722
|
switch (_c.label) {
|
|
193
723
|
case 0: return [4 /*yield*/, getSession(context.req)];
|
|
194
724
|
case 1:
|
|
@@ -197,7 +727,7 @@ function withSSRSession(handler) {
|
|
|
197
727
|
return [2 /*return*/, handler(context, session)];
|
|
198
728
|
}
|
|
199
729
|
else {
|
|
200
|
-
loginUrl = (_a =
|
|
730
|
+
loginUrl = (_a = fronteggConfig.authRoutes.loginUrl) !== null && _a !== void 0 ? _a : reduxStore.authInitialState.routes.loginUrl;
|
|
201
731
|
if (!loginUrl.startsWith('/')) {
|
|
202
732
|
loginUrl = "/" + loginUrl;
|
|
203
733
|
}
|
|
@@ -215,9 +745,9 @@ function withSSRSession(handler) {
|
|
|
215
745
|
}
|
|
216
746
|
|
|
217
747
|
function refreshTokenHostedLogin(ctx, headers) {
|
|
218
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
748
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
219
749
|
var sealFromCookies, tokens;
|
|
220
|
-
return __generator(this, function (_a) {
|
|
750
|
+
return tslib.__generator(this, function (_a) {
|
|
221
751
|
switch (_a.label) {
|
|
222
752
|
case 0:
|
|
223
753
|
_a.trys.push([0, 3, , 4]);
|
|
@@ -228,7 +758,7 @@ function refreshTokenHostedLogin(ctx, headers) {
|
|
|
228
758
|
if (!(tokens === null || tokens === void 0 ? void 0 : tokens.refreshToken)) {
|
|
229
759
|
return [2 /*return*/, null];
|
|
230
760
|
}
|
|
231
|
-
return [4 /*yield*/, fetch(process.env['FRONTEGG_BASE_URL'] + "/frontegg" + fronteggSilentRefreshTokenUrl, {
|
|
761
|
+
return [4 /*yield*/, fetch(process.env['FRONTEGG_BASE_URL'] + "/frontegg" + restApi.fronteggSilentRefreshTokenUrl, {
|
|
232
762
|
method: 'POST',
|
|
233
763
|
credentials: 'include',
|
|
234
764
|
body: JSON.stringify({
|
|
@@ -255,12 +785,12 @@ function refreshTokenHostedLogin(ctx, headers) {
|
|
|
255
785
|
});
|
|
256
786
|
}
|
|
257
787
|
function refreshTokenEmbedded(ctx, headers, cookies) {
|
|
258
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
788
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
259
789
|
var refreshTokenKey, cookieKey;
|
|
260
|
-
return __generator(this, function (_a) {
|
|
790
|
+
return tslib.__generator(this, function (_a) {
|
|
261
791
|
switch (_a.label) {
|
|
262
792
|
case 0:
|
|
263
|
-
refreshTokenKey = ("fe_refresh_" +
|
|
793
|
+
refreshTokenKey = ("fe_refresh_" + fronteggConfig.clientId).replace(/-/g, '');
|
|
264
794
|
cookieKey = Object.keys(cookies).find(function (cookie) {
|
|
265
795
|
return cookie.replace(/-/g, '') === refreshTokenKey;
|
|
266
796
|
});
|
|
@@ -269,7 +799,7 @@ function refreshTokenEmbedded(ctx, headers, cookies) {
|
|
|
269
799
|
// remove all fe_nextjs-session cookies
|
|
270
800
|
return [2 /*return*/, null];
|
|
271
801
|
}
|
|
272
|
-
return [4 /*yield*/, fetch(process.env['FRONTEGG_BASE_URL'] + "/frontegg" + fronteggRefreshTokenUrl, {
|
|
802
|
+
return [4 /*yield*/, fetch(process.env['FRONTEGG_BASE_URL'] + "/frontegg" + restApi.fronteggRefreshTokenUrl, {
|
|
273
803
|
method: 'POST',
|
|
274
804
|
credentials: 'include',
|
|
275
805
|
body: '{}',
|
|
@@ -290,10 +820,10 @@ function refreshTokenEmbedded(ctx, headers, cookies) {
|
|
|
290
820
|
}
|
|
291
821
|
function refreshToken(ctx) {
|
|
292
822
|
var _a;
|
|
293
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
823
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
294
824
|
var request, session, isSecured, headers, cookies, response, data, rewriteCookieDomainConfig, cookieHeader, newSetCookie, _b, session, decodedJwt, refreshToken_1, cookieValue;
|
|
295
825
|
var _c;
|
|
296
|
-
return __generator(this, function (_d) {
|
|
826
|
+
return tslib.__generator(this, function (_d) {
|
|
297
827
|
switch (_d.label) {
|
|
298
828
|
case 0:
|
|
299
829
|
_d.trys.push([0, 13, , 14]);
|
|
@@ -315,14 +845,14 @@ function refreshToken(ctx) {
|
|
|
315
845
|
_d.sent();
|
|
316
846
|
return [3 /*break*/, 4];
|
|
317
847
|
case 4:
|
|
318
|
-
isSecured = new URL(
|
|
848
|
+
isSecured = new URL(fronteggConfig.appUrl).protocol === 'https:';
|
|
319
849
|
headers = request.headers;
|
|
320
850
|
cookies = request.cookies;
|
|
321
851
|
if (ctx.req.url.startsWith('/oauth/callback')) {
|
|
322
852
|
return [2 /*return*/, null];
|
|
323
853
|
}
|
|
324
854
|
response = void 0;
|
|
325
|
-
if (!
|
|
855
|
+
if (!fronteggConfig.fronteggAppOptions.hostedLoginBox) return [3 /*break*/, 6];
|
|
326
856
|
return [4 /*yield*/, refreshTokenHostedLogin(ctx, headers)];
|
|
327
857
|
case 5:
|
|
328
858
|
response = _d.sent();
|
|
@@ -333,7 +863,7 @@ function refreshToken(ctx) {
|
|
|
333
863
|
_d.label = 8;
|
|
334
864
|
case 8:
|
|
335
865
|
if (!response) {
|
|
336
|
-
removeCookies(
|
|
866
|
+
removeCookies(fronteggConfig.cookieName, isSecured, fronteggConfig.cookieDomain, ctx.res);
|
|
337
867
|
return [2 /*return*/, null];
|
|
338
868
|
}
|
|
339
869
|
if (!response.ok) return [3 /*break*/, 11];
|
|
@@ -341,7 +871,7 @@ function refreshToken(ctx) {
|
|
|
341
871
|
case 9:
|
|
342
872
|
data = _d.sent();
|
|
343
873
|
rewriteCookieDomainConfig = (_c = {},
|
|
344
|
-
_c[
|
|
874
|
+
_c[fronteggConfig.baseUrlHost] = fronteggConfig.cookieDomain,
|
|
345
875
|
_c);
|
|
346
876
|
cookieHeader = response.headers.raw()['set-cookie'];
|
|
347
877
|
newSetCookie = rewriteCookieProperty(cookieHeader, rewriteCookieDomainConfig, 'domain');
|
|
@@ -379,10 +909,10 @@ function refreshToken(ctx) {
|
|
|
379
909
|
var withFronteggApp = function (app, options) {
|
|
380
910
|
var _a, _b;
|
|
381
911
|
var originalGetInitialProps = app.getInitialProps;
|
|
382
|
-
app.getInitialProps = function (appContext) { return __awaiter(void 0, void 0, void 0, function () {
|
|
912
|
+
app.getInitialProps = function (appContext) { return tslib.__awaiter(void 0, void 0, void 0, function () {
|
|
383
913
|
var ctx, Component, session, _a, user, tenants, _b, envAppUrl, envBaseUrl, envClientId, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
384
914
|
var _o;
|
|
385
|
-
return __generator(this, function (_p) {
|
|
915
|
+
return tslib.__generator(this, function (_p) {
|
|
386
916
|
switch (_p.label) {
|
|
387
917
|
case 0:
|
|
388
918
|
ctx = appContext.ctx, Component = appContext.Component;
|
|
@@ -396,7 +926,7 @@ var withFronteggApp = function (app, options) {
|
|
|
396
926
|
appContext.session = session;
|
|
397
927
|
appContext.user = user;
|
|
398
928
|
appContext.tenants = tenants;
|
|
399
|
-
_b =
|
|
929
|
+
_b = fronteggConfig.appEnvConfig, envAppUrl = _b.envAppUrl, envBaseUrl = _b.envBaseUrl, envClientId = _b.envClientId;
|
|
400
930
|
if (!envAppUrl) {
|
|
401
931
|
throw Error(fronteggErrors.envAppUrl);
|
|
402
932
|
}
|
|
@@ -417,7 +947,7 @@ var withFronteggApp = function (app, options) {
|
|
|
417
947
|
_e = {};
|
|
418
948
|
_p.label = 5;
|
|
419
949
|
case 5:
|
|
420
|
-
_f = [__assign.apply(void 0, _d.concat([(_e)]))];
|
|
950
|
+
_f = [tslib.__assign.apply(void 0, _d.concat([(_e)]))];
|
|
421
951
|
if (!Component.getInitialProps) return [3 /*break*/, 7];
|
|
422
952
|
return [4 /*yield*/, Component.getInitialProps(ctx)];
|
|
423
953
|
case 6:
|
|
@@ -426,7 +956,7 @@ var withFronteggApp = function (app, options) {
|
|
|
426
956
|
case 7:
|
|
427
957
|
_g = {};
|
|
428
958
|
_p.label = 8;
|
|
429
|
-
case 8: return [2 /*return*/, (_c.pageProps = __assign.apply(void 0, [__assign.apply(void 0, _f.concat([(_g)])), { session: session,
|
|
959
|
+
case 8: return [2 /*return*/, (_c.pageProps = tslib.__assign.apply(void 0, [tslib.__assign.apply(void 0, _f.concat([(_g)])), { session: session,
|
|
430
960
|
user: user,
|
|
431
961
|
tenants: tenants,
|
|
432
962
|
envAppUrl: envAppUrl, envBaseUrl: process.env['FRONTEGG_BASE_URL'], envClientId: process.env['FRONTEGG_CLIENT_ID'] }]),
|
|
@@ -444,7 +974,7 @@ var withFronteggApp = function (app, options) {
|
|
|
444
974
|
_k = {};
|
|
445
975
|
_p.label = 12;
|
|
446
976
|
case 12:
|
|
447
|
-
_l = [__assign.apply(void 0, _j.concat([(_k)]))];
|
|
977
|
+
_l = [tslib.__assign.apply(void 0, _j.concat([(_k)]))];
|
|
448
978
|
if (!Component.getInitialProps) return [3 /*break*/, 14];
|
|
449
979
|
return [4 /*yield*/, Component.getInitialProps(ctx)];
|
|
450
980
|
case 13:
|
|
@@ -453,16 +983,16 @@ var withFronteggApp = function (app, options) {
|
|
|
453
983
|
case 14:
|
|
454
984
|
_m = {};
|
|
455
985
|
_p.label = 15;
|
|
456
|
-
case 15: return [2 /*return*/, (_h.pageProps = __assign.apply(void 0, _l.concat([(_m)])),
|
|
986
|
+
case 15: return [2 /*return*/, (_h.pageProps = tslib.__assign.apply(void 0, _l.concat([(_m)])),
|
|
457
987
|
_h)];
|
|
458
988
|
}
|
|
459
989
|
});
|
|
460
990
|
}); };
|
|
461
|
-
|
|
462
|
-
|
|
991
|
+
fronteggConfig.authRoutes = (_b = (_a = options === null || options === void 0 ? void 0 : options.authOptions) === null || _a === void 0 ? void 0 : _a.routes) !== null && _b !== void 0 ? _b : {};
|
|
992
|
+
fronteggConfig.fronteggAppOptions = options !== null && options !== void 0 ? options : {};
|
|
463
993
|
function CustomFronteggApp(appProps) {
|
|
464
994
|
var _a = appProps.pageProps, user = _a.user, tenants = _a.tenants, session = _a.session, envAppUrl = _a.envAppUrl, envBaseUrl = _a.envBaseUrl, envClientId = _a.envClientId;
|
|
465
|
-
return (
|
|
995
|
+
return (React__default["default"].createElement(FronteggProvider, tslib.__assign({}, options, { user: user, tenants: tenants, session: session, envAppUrl: envAppUrl, envBaseUrl: envBaseUrl, envClientId: envClientId }), app(appProps)));
|
|
466
996
|
}
|
|
467
997
|
CustomFronteggApp.getInitialProps = app.getInitialProps;
|
|
468
998
|
return CustomFronteggApp;
|
|
@@ -471,7 +1001,7 @@ var withFronteggApp = function (app, options) {
|
|
|
471
1001
|
/**
|
|
472
1002
|
* @see https://www.npmjs.com/package/http-proxy
|
|
473
1003
|
*/
|
|
474
|
-
var proxy =
|
|
1004
|
+
var proxy = httpProxy__default["default"].createProxyServer({
|
|
475
1005
|
target: process.env['FRONTEGG_BASE_URL'],
|
|
476
1006
|
});
|
|
477
1007
|
/**
|
|
@@ -531,7 +1061,7 @@ function fronteggMiddleware(req, res) {
|
|
|
531
1061
|
if (hasRequestBodyMethods.indexOf(req.method) >= 0 && typeof req.body === 'object') {
|
|
532
1062
|
req.body = JSON.stringify(req.body);
|
|
533
1063
|
}
|
|
534
|
-
var isSecured = new URL(
|
|
1064
|
+
var isSecured = new URL(fronteggConfig.appUrl).protocol === 'https:';
|
|
535
1065
|
proxy
|
|
536
1066
|
.once('proxyReq', function (proxyReq, req) {
|
|
537
1067
|
if (hasRequestBodyMethods.indexOf(req.method) >= 0 && typeof req.body === 'string') {
|
|
@@ -547,16 +1077,16 @@ function fronteggMiddleware(req, res) {
|
|
|
547
1077
|
.on('data', function (chunk) {
|
|
548
1078
|
buffer = Buffer.concat([buffer, chunk]);
|
|
549
1079
|
})
|
|
550
|
-
.on('end', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1080
|
+
.on('end', function () { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
551
1081
|
var output, isLogout, _a, session, decodedJwt, sessionCookie;
|
|
552
1082
|
var _b, _c;
|
|
553
|
-
return __generator(this, function (_d) {
|
|
1083
|
+
return tslib.__generator(this, function (_d) {
|
|
554
1084
|
switch (_d.label) {
|
|
555
1085
|
case 0:
|
|
556
1086
|
output = buffer.toString('utf-8');
|
|
557
|
-
isLogout = (_b = req === null || req === void 0 ? void 0 : req.url) === null || _b === void 0 ? void 0 : _b.endsWith((_c = fronteggAuthApiRoutes.find(function (path) { return path.endsWith('/logout'); })) !== null && _c !== void 0 ? _c : '/logout');
|
|
1087
|
+
isLogout = (_b = req === null || req === void 0 ? void 0 : req.url) === null || _b === void 0 ? void 0 : _b.endsWith((_c = restApi.fronteggAuthApiRoutes.find(function (path) { return path.endsWith('/logout'); })) !== null && _c !== void 0 ? _c : '/logout');
|
|
558
1088
|
if (!isLogout) return [3 /*break*/, 1];
|
|
559
|
-
removeCookies(
|
|
1089
|
+
removeCookies(fronteggConfig.cookieName, isSecured, fronteggConfig.cookieDomain, serverResponse);
|
|
560
1090
|
return [3 /*break*/, 3];
|
|
561
1091
|
case 1: return [4 /*yield*/, createSessionFromAccessToken(output)];
|
|
562
1092
|
case 2:
|
|
@@ -589,11 +1119,50 @@ function fronteggMiddleware(req, res) {
|
|
|
589
1119
|
.web(req, res, {
|
|
590
1120
|
changeOrigin: true,
|
|
591
1121
|
cookieDomainRewrite: (_a = {},
|
|
592
|
-
_a[
|
|
1122
|
+
_a[fronteggConfig.baseUrlHost] = fronteggConfig.cookieDomain,
|
|
593
1123
|
_a),
|
|
594
1124
|
});
|
|
595
1125
|
});
|
|
596
1126
|
}
|
|
597
1127
|
|
|
598
|
-
|
|
1128
|
+
Object.defineProperty(exports, 'AdminPortal', {
|
|
1129
|
+
enumerable: true,
|
|
1130
|
+
get: function () { return js.AdminPortal; }
|
|
1131
|
+
});
|
|
1132
|
+
exports.AuthorizedContent = AuthorizedContent;
|
|
1133
|
+
exports.FronteggConfig = fronteggConfig;
|
|
1134
|
+
exports.FronteggProvider = FronteggProvider;
|
|
1135
|
+
exports.FronteggProviderNoSSR = FronteggProviderNoSSR;
|
|
1136
|
+
exports.FronteggRouter = FronteggRouter;
|
|
1137
|
+
exports.FronteggRouterProps = FronteggRouterProps;
|
|
1138
|
+
exports.addToCookies = addToCookies;
|
|
1139
|
+
exports.createCookie = createCookie;
|
|
1140
|
+
exports.createGetSession = createGetSession;
|
|
1141
|
+
exports.createSessionFromAccessToken = createSessionFromAccessToken;
|
|
1142
|
+
exports.fronteggErrors = fronteggErrors;
|
|
1143
|
+
exports.fronteggMiddleware = fronteggMiddleware;
|
|
1144
|
+
exports.getCookieFromRequest = getCookieFromRequest;
|
|
1145
|
+
exports.getMeAndTenants = getMeAndTenants;
|
|
1146
|
+
exports.getSession = getSession;
|
|
1147
|
+
exports.getTokensFromCookie = getTokensFromCookie;
|
|
1148
|
+
exports.modifySetCookieIfUnsecure = modifySetCookieIfUnsecure;
|
|
1149
|
+
exports.parseCookie = parseCookie;
|
|
1150
|
+
exports.parseCookieFromArray = parseCookieFromArray;
|
|
1151
|
+
exports.removeCookies = removeCookies;
|
|
1152
|
+
exports.rewriteCookieProperty = rewriteCookieProperty;
|
|
1153
|
+
exports.rewritePath = rewritePath;
|
|
1154
|
+
exports.withFronteggApp = withFronteggApp;
|
|
1155
|
+
exports.withSSRSession = withSSRSession;
|
|
1156
|
+
Object.keys(reactHooks).forEach(function (k) {
|
|
1157
|
+
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
1158
|
+
enumerable: true,
|
|
1159
|
+
get: function () { return reactHooks[k]; }
|
|
1160
|
+
});
|
|
1161
|
+
});
|
|
1162
|
+
Object.keys(types).forEach(function (k) {
|
|
1163
|
+
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
1164
|
+
enumerable: true,
|
|
1165
|
+
get: function () { return types[k]; }
|
|
1166
|
+
});
|
|
1167
|
+
});
|
|
599
1168
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/nextjs",
|
|
3
3
|
"libName": "FronteggNextJs",
|
|
4
|
-
"version": "6.7.9-alpha.
|
|
4
|
+
"version": "6.7.9-alpha.3787429476",
|
|
5
5
|
"author": "Frontegg LTD",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"types": "index.d.ts",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@frontegg/js": "6.
|
|
10
|
-
"@frontegg/react-hooks": "6.
|
|
9
|
+
"@frontegg/js": "6.53.0",
|
|
10
|
+
"@frontegg/react-hooks": "6.53.0",
|
|
11
11
|
"@types/http-proxy": "^1.17.9",
|
|
12
12
|
"cookie": "^0.5.0",
|
|
13
13
|
"http-proxy": "^1.18.1",
|
|
@@ -20,6 +20,5 @@
|
|
|
20
20
|
"react-dom": ">16.9.0"
|
|
21
21
|
},
|
|
22
22
|
"main": "index.js",
|
|
23
|
-
"
|
|
24
|
-
"es2015": "index.es.js"
|
|
23
|
+
"sideEffects": false
|
|
25
24
|
}
|
package/server/index.js
CHANGED
|
@@ -3,18 +3,17 @@ import React from 'react';
|
|
|
3
3
|
import { cookies, headers } from 'next/headers';
|
|
4
4
|
import '../FronteggConfig-7ae86562.js';
|
|
5
5
|
import '../api-70f0e81e.js';
|
|
6
|
-
import { g as getTokensFromCookie, p as parseCookieFromArray,
|
|
6
|
+
import { g as getTokensFromCookie, p as parseCookieFromArray, a as getMeAndTenants } from '../helpers-dac4dc7b.js';
|
|
7
7
|
import 'cookie';
|
|
8
8
|
import { c as createGetSession } from '../createGetSession-81b1748e.js';
|
|
9
9
|
import 'iron-session';
|
|
10
10
|
import 'jose';
|
|
11
11
|
import '@frontegg/react-hooks';
|
|
12
12
|
import '@frontegg/rest-api';
|
|
13
|
-
import '../
|
|
13
|
+
import { F as FronteggClientProviderNext13 } from '../FronteggClientProviderNext13-b55f477b.js';
|
|
14
14
|
import '@frontegg/js';
|
|
15
15
|
import '@frontegg/redux-store';
|
|
16
16
|
import 'next/navigation';
|
|
17
|
-
import { F as FronteggClientProviderNext13 } from '../FronteggClientProviderNext13-65bb4cd0.js';
|
|
18
17
|
|
|
19
18
|
var getCookie = function () {
|
|
20
19
|
var allCookies = cookies().getAll();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FronteggBaseProvider-5529ded6.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { __rest, __assign } from 'tslib';
|
|
3
|
-
import { F as FronteggBaseProvider } from './FronteggBaseProvider-5529ded6.js';
|
|
4
|
-
import '@frontegg/js';
|
|
5
|
-
import '@frontegg/redux-store';
|
|
6
|
-
import '@frontegg/rest-api';
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import '@frontegg/react-hooks';
|
|
9
|
-
import { useRouter } from 'next/navigation';
|
|
10
|
-
|
|
11
|
-
var FronteggClientProviderNext13 = function (_a) {
|
|
12
|
-
var children = _a.children, basename = _a.basename, props = __rest(_a, ["children", "basename"]);
|
|
13
|
-
var router = useRouter();
|
|
14
|
-
var basePath = process.env.__NEXT_ROUTER_BASEPATH || '';
|
|
15
|
-
return (React.createElement(FronteggBaseProvider, __assign({ router: router, basename: basename !== null && basename !== void 0 ? basename : basePath }, props), children));
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export { FronteggClientProviderNext13 as F };
|
|
19
|
-
//# sourceMappingURL=FronteggClientProviderNext13-65bb4cd0.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FronteggClientProviderNext13-65bb4cd0.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/consts-873fdf4e.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
var envError = function (varName) { return "@frontegg/nextjs: .env.local must contain " + varName; };
|
|
2
|
-
var fronteggErrors = {
|
|
3
|
-
envAppUrl: envError('FRONTEGG_APP_URL'),
|
|
4
|
-
envBaseUrl: envError('FRONTEGG_BASE_URL'),
|
|
5
|
-
envClientId: envError('FRONTEGG_CLIENT_ID'),
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export { fronteggErrors as f };
|
|
9
|
-
//# sourceMappingURL=consts-873fdf4e.js.map
|
package/consts-873fdf4e.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"consts-873fdf4e.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/helpers-dbf29bd5.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers-dbf29bd5.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|