@frontegg/nextjs 5.10.0 → 5.11.0-alpha.2958914476
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/FronteggConfig.d.ts +1 -0
- package/README.md +214 -4
- package/index.cjs.js +52 -38
- package/index.esm.js +52 -38
- package/package.json +4 -4
package/FronteggConfig.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ declare class FronteggConfig {
|
|
|
19
19
|
get password(): string;
|
|
20
20
|
get clientId(): string;
|
|
21
21
|
get baseUrlHost(): string;
|
|
22
|
+
getEnvAppUrl(): string | undefined;
|
|
22
23
|
get appUrl(): string;
|
|
23
24
|
get cookieDomain(): string;
|
|
24
25
|
getJwtPublicKey(): Promise<KeyLike | Uint8Array>;
|
package/README.md
CHANGED
|
@@ -1,7 +1,217 @@
|
|
|
1
|
-
|
|
1
|
+

|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Frontegg is a web platform where SaaS companies can set up their fully managed, scalable and brand aware - SaaS features
|
|
4
|
+
and integrate them into their SaaS portals in up to 5 lines of code.
|
|
4
5
|
|
|
5
|
-
##
|
|
6
|
+
## Table of Contents
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
- [Installation](#installation)
|
|
9
|
+
- [Create new NextJS project](#create-new-nextjs-project)
|
|
10
|
+
- [Add to existing project](#add-to-existing-project)
|
|
11
|
+
- [Getting Started](#getting-started)
|
|
12
|
+
- [Create Frontegg worksapce](#create-frontegg-worksapce)
|
|
13
|
+
- [Setup environment](#setup-environment)
|
|
14
|
+
- [Documentation](#documentation)
|
|
15
|
+
- [API Reference](#api-reference)
|
|
16
|
+
- [Frontegg Provider Options](#frontegg-provider-options)
|
|
17
|
+
- [getSession](#getsession)
|
|
18
|
+
- [withSSRSession](#withssrsession)
|
|
19
|
+
- for more [visit](https://docs.frontegg.com/docs/self-service-introduction)
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
### Create new NextJS project
|
|
24
|
+
|
|
25
|
+
To start a new Create Next App project with TypeScript, you can run:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx create-next-app --example "https://github.com/frontegg/frontegg-nextjs" --example-path "apps/example" my-nextjs-app-name
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
or
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
yarn create next-app --example "https://github.com/frontegg/frontegg-nextjs" --example-path "apps/example" my-nextjs-app-name
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
> If you've previously installed `create-react-app` globally via `npm install -g create-next-app`, we recommend you uninstall the package using `npm uninstall -g create-next-app` or `yarn global remove create-next-app` to ensure that `npx` always uses the latest version.
|
|
38
|
+
>
|
|
39
|
+
> Global installations of `create-next-app` are no longer supported.
|
|
40
|
+
|
|
41
|
+
### Add to existing project
|
|
42
|
+
|
|
43
|
+
To Add Frontegg to your existing Nextjs project, follow below steps:
|
|
44
|
+
|
|
45
|
+
1. Use package manager to install Frontegg Next.JS library.
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install --save @frontegg/nextjs
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
or
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
yarn add --save @frontegg/nextjs
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
2. Wrap the default export with `withFronteggApp` in `./pages/_app.tsx`:
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
// ./pages/_app.tsx
|
|
61
|
+
|
|
62
|
+
import { withFronteggApp } from '@frontegg/nextjs';
|
|
63
|
+
|
|
64
|
+
function CustomApp({ Component, pageProps }: AppProps) {
|
|
65
|
+
return <Component {...pageProps} />;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export default withFronteggApp(CustomApp);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
3. Create files for frontegg middleware under `./pages/api/frontegg/[...frontegg-middleware].ts`:
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
// ./pages/api/frontegg/[...frontegg-middleware].ts
|
|
75
|
+
|
|
76
|
+
export { fronteggMiddleware as default } from '@frontegg/nextjs';
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
4. Create placeholder pages for frontegg router under `./pages/[...frontegg-router].tsx`:
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
// ./pages/[...frontegg-router].tsx
|
|
83
|
+
|
|
84
|
+
export {
|
|
85
|
+
FronteggRouter as default,
|
|
86
|
+
FronteggRouterProps as getServerSideProps,
|
|
87
|
+
} from '@frontegg/nextjs';
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Getting Started
|
|
91
|
+
|
|
92
|
+
### Create Frontegg worksapce
|
|
93
|
+
|
|
94
|
+
Navigate to [Frontegg Portal Settgins](https://portal.frontegg.com/development/settings), If you don't have application
|
|
95
|
+
follow integration steps after signing up.
|
|
96
|
+
|
|
97
|
+
Next, configure the "Allowed Origins" in your application under "Domain" tab of the "Settings" page :
|
|
98
|
+
|
|
99
|
+
- http://localhost:3000 // for development environments
|
|
100
|
+
- https://my-company-domain.com // for production environments
|
|
101
|
+
|
|
102
|
+
Copy ClientID, Frontegg Domain from "Settings" page, You'll need these values in the next step.
|
|
103
|
+
|
|
104
|
+
### Setup environment
|
|
105
|
+
|
|
106
|
+
To setup your Next.js application to communicate with Frontegg, you have to create a new file named `.env.local` under
|
|
107
|
+
your root project directory, this file will be used to store environment variables that will be used, configuration
|
|
108
|
+
options:
|
|
109
|
+
|
|
110
|
+
```dotenv
|
|
111
|
+
# The AppUrl is to tell Frontegg your application hostname
|
|
112
|
+
FRONTEGG_APP_URL='http://localhost:3000'
|
|
113
|
+
|
|
114
|
+
# The Frontegg domain is your unique URL to connect to the Frontegg gateway
|
|
115
|
+
FRONTEGG_BASE_URL='https://{YOUR_SUB_DOMAIN}.frontegg.com'
|
|
116
|
+
|
|
117
|
+
# Your Frontegg application's Client ID
|
|
118
|
+
FRONTEGG_CLIENT_ID='{YOUR_APPLICATION_CLIENT_ID}'
|
|
119
|
+
|
|
120
|
+
# The statless session encruption password, used to encrypt
|
|
121
|
+
# jwt before sending it to the client side.
|
|
122
|
+
#
|
|
123
|
+
# For quick password generation use the following command:
|
|
124
|
+
# node -e "console.log(crypto.randomBytes(32).toString('hex'))"
|
|
125
|
+
FRONTEGG_ENCRYPTION_PASSWORD='{SESSION_ENCRYPTION_PASSWORD}'
|
|
126
|
+
|
|
127
|
+
# The statless session cookie name
|
|
128
|
+
FRONTEGG_COOKIE_NAME='fe_session'
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Documentation
|
|
132
|
+
|
|
133
|
+
### API Reference
|
|
134
|
+
|
|
135
|
+
Visit [Frontegg Docs](https://docs.frontegg.com) for the full documentation.
|
|
136
|
+
|
|
137
|
+
### Frontegg Provider Options
|
|
138
|
+
|
|
139
|
+
Pass seconds argument to `withFronteggApp` function in `_app.ts` file to customize
|
|
140
|
+
Frontegg library.
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
// ./pages/_app.tsx
|
|
144
|
+
|
|
145
|
+
import { withFronteggApp } from '@frontegg/nextjs';
|
|
146
|
+
|
|
147
|
+
function CustomApp({ Component, pageProps }: AppProps) {
|
|
148
|
+
return <Component {...pageProps} />;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export default withFronteggApp(CustomApp, {
|
|
152
|
+
/**
|
|
153
|
+
* Frontegg options for customizations
|
|
154
|
+
*/
|
|
155
|
+
});
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### getSession
|
|
159
|
+
|
|
160
|
+
For any pages that required AccessToken in Server Side, you can use:
|
|
161
|
+
|
|
162
|
+
```tsx
|
|
163
|
+
import { GetServerSideProps } from 'next';
|
|
164
|
+
import { getSession } from '@frontegg/nextjs';
|
|
165
|
+
|
|
166
|
+
export default function MyPage({ products }) {
|
|
167
|
+
return (
|
|
168
|
+
<div>
|
|
169
|
+
<h1>My Page</h1>
|
|
170
|
+
{products}
|
|
171
|
+
</div>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export const getServerSideProps: GetServerSideProps = async (context) => {
|
|
176
|
+
const session = await getSession(context.req);
|
|
177
|
+
if (session) {
|
|
178
|
+
const { data } = await fetch('{external}/product', {
|
|
179
|
+
headers: {
|
|
180
|
+
Authorization: 'bearer ' + session.accessToken,
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
return { props: { products: data } };
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return { props: { products: [] } };
|
|
187
|
+
};
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### withSSRSession
|
|
191
|
+
|
|
192
|
+
withSSRSession HOC can be used to automatic redirect users to login screen if not logged in:
|
|
193
|
+
|
|
194
|
+
```tsx
|
|
195
|
+
import { GetServerSideProps } from 'next';
|
|
196
|
+
import { withSSRSession } from '@frontegg/nextjs';
|
|
197
|
+
|
|
198
|
+
export default function MyPage({ products }) {
|
|
199
|
+
return (
|
|
200
|
+
<div>
|
|
201
|
+
<h1>My Page</h1>
|
|
202
|
+
{products}
|
|
203
|
+
</div>
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export const getServerSideProps: GetServerSideProps = withSSRSession(
|
|
208
|
+
async (context, session) => {
|
|
209
|
+
const { data } = await fetch('{external}/product', {
|
|
210
|
+
headers: {
|
|
211
|
+
Authorization: 'bearer ' + session.accessToken,
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
return { props: { products: data } };
|
|
215
|
+
}
|
|
216
|
+
);
|
|
217
|
+
```
|
package/index.cjs.js
CHANGED
|
@@ -1109,19 +1109,32 @@ var FronteggConfig = /*#__PURE__*/function () {
|
|
|
1109
1109
|
|
|
1110
1110
|
return new URL((_a = process.env['FRONTEGG_BASE_URL']) !== null && _a !== void 0 ? _a : '').hostname;
|
|
1111
1111
|
}
|
|
1112
|
+
}, {
|
|
1113
|
+
key: "getEnvAppUrl",
|
|
1114
|
+
value: function getEnvAppUrl() {
|
|
1115
|
+
if (process.env['VERCEL_URL']) {
|
|
1116
|
+
return process.env['VERCEL_URL'];
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
if (process.env['FRONTEGG_APP_URL']) {
|
|
1120
|
+
return process.env['FRONTEGG_APP_URL'];
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
return undefined;
|
|
1124
|
+
}
|
|
1112
1125
|
}, {
|
|
1113
1126
|
key: "appUrl",
|
|
1114
1127
|
get: function get() {
|
|
1115
1128
|
var _a;
|
|
1116
1129
|
|
|
1117
|
-
return (_a =
|
|
1130
|
+
return (_a = this.getEnvAppUrl()) !== null && _a !== void 0 ? _a : 'http://localhost:3000';
|
|
1118
1131
|
}
|
|
1119
1132
|
}, {
|
|
1120
1133
|
key: "cookieDomain",
|
|
1121
1134
|
get: function get() {
|
|
1122
1135
|
var _a;
|
|
1123
1136
|
|
|
1124
|
-
return new URL((_a =
|
|
1137
|
+
return new URL((_a = this.getEnvAppUrl()) !== null && _a !== void 0 ? _a : '').hostname.replace(/:(\d)+$/, '');
|
|
1125
1138
|
}
|
|
1126
1139
|
}, {
|
|
1127
1140
|
key: "getJwtPublicKey",
|
|
@@ -1767,7 +1780,7 @@ var withFronteggApp = function withFronteggApp(app, options) {
|
|
|
1767
1780
|
|
|
1768
1781
|
app.getInitialProps = function (appContext) {
|
|
1769
1782
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee() {
|
|
1770
|
-
var _c, _d, ctx, Component, session;
|
|
1783
|
+
var _c, _d, ctx, Component, session, envAppUrl;
|
|
1771
1784
|
|
|
1772
1785
|
return regenerator.wrap(function _callee$(_context) {
|
|
1773
1786
|
while (1) {
|
|
@@ -1776,7 +1789,7 @@ var withFronteggApp = function withFronteggApp(app, options) {
|
|
|
1776
1789
|
ctx = appContext.ctx, Component = appContext.Component;
|
|
1777
1790
|
|
|
1778
1791
|
if (!(((_d = (_c = ctx.req) === null || _c === void 0 ? void 0 : _c.url) === null || _d === void 0 ? void 0 : _d.indexOf('/_next/data/')) === -1)) {
|
|
1779
|
-
_context.next =
|
|
1792
|
+
_context.next = 40;
|
|
1780
1793
|
break;
|
|
1781
1794
|
}
|
|
1782
1795
|
|
|
@@ -1786,78 +1799,79 @@ var withFronteggApp = function withFronteggApp(app, options) {
|
|
|
1786
1799
|
case 4:
|
|
1787
1800
|
session = _context.sent;
|
|
1788
1801
|
appContext.session = session;
|
|
1802
|
+
envAppUrl = fronteggConfig.getEnvAppUrl();
|
|
1789
1803
|
|
|
1790
|
-
if (
|
|
1791
|
-
_context.next =
|
|
1804
|
+
if (envAppUrl) {
|
|
1805
|
+
_context.next = 9;
|
|
1792
1806
|
break;
|
|
1793
1807
|
}
|
|
1794
1808
|
|
|
1795
1809
|
throw Error('@frontegg/nextjs: .env.local must contain FRONTEGG_APP_URL');
|
|
1796
1810
|
|
|
1797
|
-
case
|
|
1811
|
+
case 9:
|
|
1798
1812
|
if (process.env['FRONTEGG_BASE_URL']) {
|
|
1799
|
-
_context.next =
|
|
1813
|
+
_context.next = 11;
|
|
1800
1814
|
break;
|
|
1801
1815
|
}
|
|
1802
1816
|
|
|
1803
1817
|
throw Error('@frontegg/nextjs: .env.local must contain FRONTEGG_BASE_URL');
|
|
1804
1818
|
|
|
1805
|
-
case
|
|
1819
|
+
case 11:
|
|
1806
1820
|
if (process.env['FRONTEGG_CLIENT_ID']) {
|
|
1807
|
-
_context.next =
|
|
1821
|
+
_context.next = 13;
|
|
1808
1822
|
break;
|
|
1809
1823
|
}
|
|
1810
1824
|
|
|
1811
1825
|
throw Error('@frontegg/nextjs: .env.local must contain FRONTEGG_CLIENT_ID');
|
|
1812
1826
|
|
|
1813
|
-
case
|
|
1827
|
+
case 13:
|
|
1814
1828
|
_context.t0 = Object;
|
|
1815
1829
|
_context.t1 = Object;
|
|
1816
1830
|
_context.t2 = Object;
|
|
1817
1831
|
_context.t3 = {};
|
|
1818
1832
|
|
|
1819
1833
|
if (!originalGetInitialProps) {
|
|
1820
|
-
_context.next =
|
|
1834
|
+
_context.next = 23;
|
|
1821
1835
|
break;
|
|
1822
1836
|
}
|
|
1823
1837
|
|
|
1824
|
-
_context.next =
|
|
1838
|
+
_context.next = 20;
|
|
1825
1839
|
return originalGetInitialProps(appContext);
|
|
1826
1840
|
|
|
1827
|
-
case
|
|
1841
|
+
case 20:
|
|
1828
1842
|
_context.t4 = _context.sent;
|
|
1829
|
-
_context.next =
|
|
1843
|
+
_context.next = 24;
|
|
1830
1844
|
break;
|
|
1831
1845
|
|
|
1832
|
-
case
|
|
1846
|
+
case 23:
|
|
1833
1847
|
_context.t4 = {};
|
|
1834
1848
|
|
|
1835
|
-
case
|
|
1849
|
+
case 24:
|
|
1836
1850
|
_context.t5 = _context.t4;
|
|
1837
1851
|
_context.t6 = _context.t2.assign.call(_context.t2, _context.t3, _context.t5);
|
|
1838
1852
|
|
|
1839
1853
|
if (!Component.getInitialProps) {
|
|
1840
|
-
_context.next =
|
|
1854
|
+
_context.next = 32;
|
|
1841
1855
|
break;
|
|
1842
1856
|
}
|
|
1843
1857
|
|
|
1844
|
-
_context.next =
|
|
1858
|
+
_context.next = 29;
|
|
1845
1859
|
return Component.getInitialProps(ctx);
|
|
1846
1860
|
|
|
1847
|
-
case
|
|
1861
|
+
case 29:
|
|
1848
1862
|
_context.t7 = _context.sent;
|
|
1849
|
-
_context.next =
|
|
1863
|
+
_context.next = 33;
|
|
1850
1864
|
break;
|
|
1851
1865
|
|
|
1852
|
-
case
|
|
1866
|
+
case 32:
|
|
1853
1867
|
_context.t7 = {};
|
|
1854
1868
|
|
|
1855
|
-
case
|
|
1869
|
+
case 33:
|
|
1856
1870
|
_context.t8 = _context.t7;
|
|
1857
1871
|
_context.t9 = _context.t1.assign.call(_context.t1, _context.t6, _context.t8);
|
|
1858
1872
|
_context.t10 = {
|
|
1859
1873
|
session: session,
|
|
1860
|
-
envAppUrl:
|
|
1874
|
+
envAppUrl: envAppUrl,
|
|
1861
1875
|
envBaseUrl: process.env['FRONTEGG_BASE_URL'],
|
|
1862
1876
|
envClientId: process.env['FRONTEGG_CLIENT_ID']
|
|
1863
1877
|
};
|
|
@@ -1866,56 +1880,56 @@ var withFronteggApp = function withFronteggApp(app, options) {
|
|
|
1866
1880
|
pageProps: _context.t11
|
|
1867
1881
|
});
|
|
1868
1882
|
|
|
1869
|
-
case
|
|
1883
|
+
case 40:
|
|
1870
1884
|
appContext.session = null;
|
|
1871
1885
|
_context.t12 = Object;
|
|
1872
1886
|
_context.t13 = Object;
|
|
1873
1887
|
_context.t14 = {};
|
|
1874
1888
|
|
|
1875
1889
|
if (!originalGetInitialProps) {
|
|
1876
|
-
_context.next =
|
|
1890
|
+
_context.next = 50;
|
|
1877
1891
|
break;
|
|
1878
1892
|
}
|
|
1879
1893
|
|
|
1880
|
-
_context.next =
|
|
1894
|
+
_context.next = 47;
|
|
1881
1895
|
return originalGetInitialProps(appContext);
|
|
1882
1896
|
|
|
1883
|
-
case
|
|
1897
|
+
case 47:
|
|
1884
1898
|
_context.t15 = _context.sent;
|
|
1885
|
-
_context.next =
|
|
1899
|
+
_context.next = 51;
|
|
1886
1900
|
break;
|
|
1887
1901
|
|
|
1888
|
-
case
|
|
1902
|
+
case 50:
|
|
1889
1903
|
_context.t15 = {};
|
|
1890
1904
|
|
|
1891
|
-
case
|
|
1905
|
+
case 51:
|
|
1892
1906
|
_context.t16 = _context.t15;
|
|
1893
1907
|
_context.t17 = _context.t13.assign.call(_context.t13, _context.t14, _context.t16);
|
|
1894
1908
|
|
|
1895
1909
|
if (!Component.getInitialProps) {
|
|
1896
|
-
_context.next =
|
|
1910
|
+
_context.next = 59;
|
|
1897
1911
|
break;
|
|
1898
1912
|
}
|
|
1899
1913
|
|
|
1900
|
-
_context.next =
|
|
1914
|
+
_context.next = 56;
|
|
1901
1915
|
return Component.getInitialProps(ctx);
|
|
1902
1916
|
|
|
1903
|
-
case
|
|
1917
|
+
case 56:
|
|
1904
1918
|
_context.t18 = _context.sent;
|
|
1905
|
-
_context.next =
|
|
1919
|
+
_context.next = 60;
|
|
1906
1920
|
break;
|
|
1907
1921
|
|
|
1908
|
-
case
|
|
1922
|
+
case 59:
|
|
1909
1923
|
_context.t18 = {};
|
|
1910
1924
|
|
|
1911
|
-
case
|
|
1925
|
+
case 60:
|
|
1912
1926
|
_context.t19 = _context.t18;
|
|
1913
1927
|
_context.t20 = _context.t12.assign.call(_context.t12, _context.t17, _context.t19);
|
|
1914
1928
|
return _context.abrupt("return", {
|
|
1915
1929
|
pageProps: _context.t20
|
|
1916
1930
|
});
|
|
1917
1931
|
|
|
1918
|
-
case
|
|
1932
|
+
case 63:
|
|
1919
1933
|
case "end":
|
|
1920
1934
|
return _context.stop();
|
|
1921
1935
|
}
|
package/index.esm.js
CHANGED
|
@@ -1083,19 +1083,32 @@ var FronteggConfig = /*#__PURE__*/function () {
|
|
|
1083
1083
|
|
|
1084
1084
|
return new URL((_a = process.env['FRONTEGG_BASE_URL']) !== null && _a !== void 0 ? _a : '').hostname;
|
|
1085
1085
|
}
|
|
1086
|
+
}, {
|
|
1087
|
+
key: "getEnvAppUrl",
|
|
1088
|
+
value: function getEnvAppUrl() {
|
|
1089
|
+
if (process.env['VERCEL_URL']) {
|
|
1090
|
+
return process.env['VERCEL_URL'];
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
if (process.env['FRONTEGG_APP_URL']) {
|
|
1094
|
+
return process.env['FRONTEGG_APP_URL'];
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
return undefined;
|
|
1098
|
+
}
|
|
1086
1099
|
}, {
|
|
1087
1100
|
key: "appUrl",
|
|
1088
1101
|
get: function get() {
|
|
1089
1102
|
var _a;
|
|
1090
1103
|
|
|
1091
|
-
return (_a =
|
|
1104
|
+
return (_a = this.getEnvAppUrl()) !== null && _a !== void 0 ? _a : 'http://localhost:3000';
|
|
1092
1105
|
}
|
|
1093
1106
|
}, {
|
|
1094
1107
|
key: "cookieDomain",
|
|
1095
1108
|
get: function get() {
|
|
1096
1109
|
var _a;
|
|
1097
1110
|
|
|
1098
|
-
return new URL((_a =
|
|
1111
|
+
return new URL((_a = this.getEnvAppUrl()) !== null && _a !== void 0 ? _a : '').hostname.replace(/:(\d)+$/, '');
|
|
1099
1112
|
}
|
|
1100
1113
|
}, {
|
|
1101
1114
|
key: "getJwtPublicKey",
|
|
@@ -1741,7 +1754,7 @@ var withFronteggApp = function withFronteggApp(app, options) {
|
|
|
1741
1754
|
|
|
1742
1755
|
app.getInitialProps = function (appContext) {
|
|
1743
1756
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee() {
|
|
1744
|
-
var _c, _d, ctx, Component, session;
|
|
1757
|
+
var _c, _d, ctx, Component, session, envAppUrl;
|
|
1745
1758
|
|
|
1746
1759
|
return regenerator.wrap(function _callee$(_context) {
|
|
1747
1760
|
while (1) {
|
|
@@ -1750,7 +1763,7 @@ var withFronteggApp = function withFronteggApp(app, options) {
|
|
|
1750
1763
|
ctx = appContext.ctx, Component = appContext.Component;
|
|
1751
1764
|
|
|
1752
1765
|
if (!(((_d = (_c = ctx.req) === null || _c === void 0 ? void 0 : _c.url) === null || _d === void 0 ? void 0 : _d.indexOf('/_next/data/')) === -1)) {
|
|
1753
|
-
_context.next =
|
|
1766
|
+
_context.next = 40;
|
|
1754
1767
|
break;
|
|
1755
1768
|
}
|
|
1756
1769
|
|
|
@@ -1760,78 +1773,79 @@ var withFronteggApp = function withFronteggApp(app, options) {
|
|
|
1760
1773
|
case 4:
|
|
1761
1774
|
session = _context.sent;
|
|
1762
1775
|
appContext.session = session;
|
|
1776
|
+
envAppUrl = fronteggConfig.getEnvAppUrl();
|
|
1763
1777
|
|
|
1764
|
-
if (
|
|
1765
|
-
_context.next =
|
|
1778
|
+
if (envAppUrl) {
|
|
1779
|
+
_context.next = 9;
|
|
1766
1780
|
break;
|
|
1767
1781
|
}
|
|
1768
1782
|
|
|
1769
1783
|
throw Error('@frontegg/nextjs: .env.local must contain FRONTEGG_APP_URL');
|
|
1770
1784
|
|
|
1771
|
-
case
|
|
1785
|
+
case 9:
|
|
1772
1786
|
if (process.env['FRONTEGG_BASE_URL']) {
|
|
1773
|
-
_context.next =
|
|
1787
|
+
_context.next = 11;
|
|
1774
1788
|
break;
|
|
1775
1789
|
}
|
|
1776
1790
|
|
|
1777
1791
|
throw Error('@frontegg/nextjs: .env.local must contain FRONTEGG_BASE_URL');
|
|
1778
1792
|
|
|
1779
|
-
case
|
|
1793
|
+
case 11:
|
|
1780
1794
|
if (process.env['FRONTEGG_CLIENT_ID']) {
|
|
1781
|
-
_context.next =
|
|
1795
|
+
_context.next = 13;
|
|
1782
1796
|
break;
|
|
1783
1797
|
}
|
|
1784
1798
|
|
|
1785
1799
|
throw Error('@frontegg/nextjs: .env.local must contain FRONTEGG_CLIENT_ID');
|
|
1786
1800
|
|
|
1787
|
-
case
|
|
1801
|
+
case 13:
|
|
1788
1802
|
_context.t0 = Object;
|
|
1789
1803
|
_context.t1 = Object;
|
|
1790
1804
|
_context.t2 = Object;
|
|
1791
1805
|
_context.t3 = {};
|
|
1792
1806
|
|
|
1793
1807
|
if (!originalGetInitialProps) {
|
|
1794
|
-
_context.next =
|
|
1808
|
+
_context.next = 23;
|
|
1795
1809
|
break;
|
|
1796
1810
|
}
|
|
1797
1811
|
|
|
1798
|
-
_context.next =
|
|
1812
|
+
_context.next = 20;
|
|
1799
1813
|
return originalGetInitialProps(appContext);
|
|
1800
1814
|
|
|
1801
|
-
case
|
|
1815
|
+
case 20:
|
|
1802
1816
|
_context.t4 = _context.sent;
|
|
1803
|
-
_context.next =
|
|
1817
|
+
_context.next = 24;
|
|
1804
1818
|
break;
|
|
1805
1819
|
|
|
1806
|
-
case
|
|
1820
|
+
case 23:
|
|
1807
1821
|
_context.t4 = {};
|
|
1808
1822
|
|
|
1809
|
-
case
|
|
1823
|
+
case 24:
|
|
1810
1824
|
_context.t5 = _context.t4;
|
|
1811
1825
|
_context.t6 = _context.t2.assign.call(_context.t2, _context.t3, _context.t5);
|
|
1812
1826
|
|
|
1813
1827
|
if (!Component.getInitialProps) {
|
|
1814
|
-
_context.next =
|
|
1828
|
+
_context.next = 32;
|
|
1815
1829
|
break;
|
|
1816
1830
|
}
|
|
1817
1831
|
|
|
1818
|
-
_context.next =
|
|
1832
|
+
_context.next = 29;
|
|
1819
1833
|
return Component.getInitialProps(ctx);
|
|
1820
1834
|
|
|
1821
|
-
case
|
|
1835
|
+
case 29:
|
|
1822
1836
|
_context.t7 = _context.sent;
|
|
1823
|
-
_context.next =
|
|
1837
|
+
_context.next = 33;
|
|
1824
1838
|
break;
|
|
1825
1839
|
|
|
1826
|
-
case
|
|
1840
|
+
case 32:
|
|
1827
1841
|
_context.t7 = {};
|
|
1828
1842
|
|
|
1829
|
-
case
|
|
1843
|
+
case 33:
|
|
1830
1844
|
_context.t8 = _context.t7;
|
|
1831
1845
|
_context.t9 = _context.t1.assign.call(_context.t1, _context.t6, _context.t8);
|
|
1832
1846
|
_context.t10 = {
|
|
1833
1847
|
session: session,
|
|
1834
|
-
envAppUrl:
|
|
1848
|
+
envAppUrl: envAppUrl,
|
|
1835
1849
|
envBaseUrl: process.env['FRONTEGG_BASE_URL'],
|
|
1836
1850
|
envClientId: process.env['FRONTEGG_CLIENT_ID']
|
|
1837
1851
|
};
|
|
@@ -1840,56 +1854,56 @@ var withFronteggApp = function withFronteggApp(app, options) {
|
|
|
1840
1854
|
pageProps: _context.t11
|
|
1841
1855
|
});
|
|
1842
1856
|
|
|
1843
|
-
case
|
|
1857
|
+
case 40:
|
|
1844
1858
|
appContext.session = null;
|
|
1845
1859
|
_context.t12 = Object;
|
|
1846
1860
|
_context.t13 = Object;
|
|
1847
1861
|
_context.t14 = {};
|
|
1848
1862
|
|
|
1849
1863
|
if (!originalGetInitialProps) {
|
|
1850
|
-
_context.next =
|
|
1864
|
+
_context.next = 50;
|
|
1851
1865
|
break;
|
|
1852
1866
|
}
|
|
1853
1867
|
|
|
1854
|
-
_context.next =
|
|
1868
|
+
_context.next = 47;
|
|
1855
1869
|
return originalGetInitialProps(appContext);
|
|
1856
1870
|
|
|
1857
|
-
case
|
|
1871
|
+
case 47:
|
|
1858
1872
|
_context.t15 = _context.sent;
|
|
1859
|
-
_context.next =
|
|
1873
|
+
_context.next = 51;
|
|
1860
1874
|
break;
|
|
1861
1875
|
|
|
1862
|
-
case
|
|
1876
|
+
case 50:
|
|
1863
1877
|
_context.t15 = {};
|
|
1864
1878
|
|
|
1865
|
-
case
|
|
1879
|
+
case 51:
|
|
1866
1880
|
_context.t16 = _context.t15;
|
|
1867
1881
|
_context.t17 = _context.t13.assign.call(_context.t13, _context.t14, _context.t16);
|
|
1868
1882
|
|
|
1869
1883
|
if (!Component.getInitialProps) {
|
|
1870
|
-
_context.next =
|
|
1884
|
+
_context.next = 59;
|
|
1871
1885
|
break;
|
|
1872
1886
|
}
|
|
1873
1887
|
|
|
1874
|
-
_context.next =
|
|
1888
|
+
_context.next = 56;
|
|
1875
1889
|
return Component.getInitialProps(ctx);
|
|
1876
1890
|
|
|
1877
|
-
case
|
|
1891
|
+
case 56:
|
|
1878
1892
|
_context.t18 = _context.sent;
|
|
1879
|
-
_context.next =
|
|
1893
|
+
_context.next = 60;
|
|
1880
1894
|
break;
|
|
1881
1895
|
|
|
1882
|
-
case
|
|
1896
|
+
case 59:
|
|
1883
1897
|
_context.t18 = {};
|
|
1884
1898
|
|
|
1885
|
-
case
|
|
1899
|
+
case 60:
|
|
1886
1900
|
_context.t19 = _context.t18;
|
|
1887
1901
|
_context.t20 = _context.t12.assign.call(_context.t12, _context.t17, _context.t19);
|
|
1888
1902
|
return _context.abrupt("return", {
|
|
1889
1903
|
pageProps: _context.t20
|
|
1890
1904
|
});
|
|
1891
1905
|
|
|
1892
|
-
case
|
|
1906
|
+
case 63:
|
|
1893
1907
|
case "end":
|
|
1894
1908
|
return _context.stop();
|
|
1895
1909
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/nextjs",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.11.0-alpha.2958914476",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@frontegg/admin-portal": "5.
|
|
6
|
-
"@frontegg/react-hooks": "5.
|
|
5
|
+
"@frontegg/admin-portal": "5.80.2",
|
|
6
|
+
"@frontegg/react-hooks": "5.80.2",
|
|
7
7
|
"jose": "^4.8.0",
|
|
8
8
|
"iron-session": "^6.1.2",
|
|
9
9
|
"http-proxy": "^1.18.1",
|
|
@@ -16,4 +16,4 @@
|
|
|
16
16
|
"main": "./index.cjs.js",
|
|
17
17
|
"module": "./index.esm.js",
|
|
18
18
|
"typings": "./index.d.ts"
|
|
19
|
-
}
|
|
19
|
+
}
|