@frontegg/nextjs 6.1.0-alpha.2962640568 → 6.1.0-alpha.2964994546

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.
@@ -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/index.cjs.js CHANGED
@@ -1109,19 +1109,37 @@ 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
+ var url = undefined;
1116
+
1117
+ if (process.env['VERCEL_URL']) {
1118
+ url = process.env['VERCEL_URL'];
1119
+ } else if (process.env['FRONTEGG_APP_URL']) {
1120
+ url = process.env['FRONTEGG_APP_URL'];
1121
+ }
1122
+
1123
+ if (url && !url.startsWith('http')) {
1124
+ var protocol = url.startsWith('localhost') ? 'http://' : 'https://';
1125
+ url = "".concat(protocol).concat(url);
1126
+ }
1127
+
1128
+ return url;
1129
+ }
1112
1130
  }, {
1113
1131
  key: "appUrl",
1114
1132
  get: function get() {
1115
1133
  var _a;
1116
1134
 
1117
- return (_a = process.env['FRONTEGG_APP_URL']) !== null && _a !== void 0 ? _a : 'http://localhost:3000';
1135
+ return (_a = this.getEnvAppUrl()) !== null && _a !== void 0 ? _a : 'http://localhost:3000';
1118
1136
  }
1119
1137
  }, {
1120
1138
  key: "cookieDomain",
1121
1139
  get: function get() {
1122
1140
  var _a;
1123
1141
 
1124
- return new URL((_a = process.env['FRONTEGG_APP_URL']) !== null && _a !== void 0 ? _a : '').hostname.replace(/:(\d)+$/, '');
1142
+ return new URL((_a = this.getEnvAppUrl()) !== null && _a !== void 0 ? _a : '').hostname.replace(/:(\d)+$/, '');
1125
1143
  }
1126
1144
  }, {
1127
1145
  key: "getJwtPublicKey",
@@ -1767,7 +1785,7 @@ var withFronteggApp = function withFronteggApp(app, options) {
1767
1785
 
1768
1786
  app.getInitialProps = function (appContext) {
1769
1787
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee() {
1770
- var _c, _d, ctx, Component, session;
1788
+ var _c, _d, ctx, Component, session, envAppUrl;
1771
1789
 
1772
1790
  return regenerator.wrap(function _callee$(_context) {
1773
1791
  while (1) {
@@ -1776,7 +1794,7 @@ var withFronteggApp = function withFronteggApp(app, options) {
1776
1794
  ctx = appContext.ctx, Component = appContext.Component;
1777
1795
 
1778
1796
  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 = 39;
1797
+ _context.next = 40;
1780
1798
  break;
1781
1799
  }
1782
1800
 
@@ -1786,78 +1804,79 @@ var withFronteggApp = function withFronteggApp(app, options) {
1786
1804
  case 4:
1787
1805
  session = _context.sent;
1788
1806
  appContext.session = session;
1807
+ envAppUrl = fronteggConfig.getEnvAppUrl();
1789
1808
 
1790
- if (process.env['FRONTEGG_APP_URL']) {
1791
- _context.next = 8;
1809
+ if (envAppUrl) {
1810
+ _context.next = 9;
1792
1811
  break;
1793
1812
  }
1794
1813
 
1795
1814
  throw Error('@frontegg/nextjs: .env.local must contain FRONTEGG_APP_URL');
1796
1815
 
1797
- case 8:
1816
+ case 9:
1798
1817
  if (process.env['FRONTEGG_BASE_URL']) {
1799
- _context.next = 10;
1818
+ _context.next = 11;
1800
1819
  break;
1801
1820
  }
1802
1821
 
1803
1822
  throw Error('@frontegg/nextjs: .env.local must contain FRONTEGG_BASE_URL');
1804
1823
 
1805
- case 10:
1824
+ case 11:
1806
1825
  if (process.env['FRONTEGG_CLIENT_ID']) {
1807
- _context.next = 12;
1826
+ _context.next = 13;
1808
1827
  break;
1809
1828
  }
1810
1829
 
1811
1830
  throw Error('@frontegg/nextjs: .env.local must contain FRONTEGG_CLIENT_ID');
1812
1831
 
1813
- case 12:
1832
+ case 13:
1814
1833
  _context.t0 = Object;
1815
1834
  _context.t1 = Object;
1816
1835
  _context.t2 = Object;
1817
1836
  _context.t3 = {};
1818
1837
 
1819
1838
  if (!originalGetInitialProps) {
1820
- _context.next = 22;
1839
+ _context.next = 23;
1821
1840
  break;
1822
1841
  }
1823
1842
 
1824
- _context.next = 19;
1843
+ _context.next = 20;
1825
1844
  return originalGetInitialProps(appContext);
1826
1845
 
1827
- case 19:
1846
+ case 20:
1828
1847
  _context.t4 = _context.sent;
1829
- _context.next = 23;
1848
+ _context.next = 24;
1830
1849
  break;
1831
1850
 
1832
- case 22:
1851
+ case 23:
1833
1852
  _context.t4 = {};
1834
1853
 
1835
- case 23:
1854
+ case 24:
1836
1855
  _context.t5 = _context.t4;
1837
1856
  _context.t6 = _context.t2.assign.call(_context.t2, _context.t3, _context.t5);
1838
1857
 
1839
1858
  if (!Component.getInitialProps) {
1840
- _context.next = 31;
1859
+ _context.next = 32;
1841
1860
  break;
1842
1861
  }
1843
1862
 
1844
- _context.next = 28;
1863
+ _context.next = 29;
1845
1864
  return Component.getInitialProps(ctx);
1846
1865
 
1847
- case 28:
1866
+ case 29:
1848
1867
  _context.t7 = _context.sent;
1849
- _context.next = 32;
1868
+ _context.next = 33;
1850
1869
  break;
1851
1870
 
1852
- case 31:
1871
+ case 32:
1853
1872
  _context.t7 = {};
1854
1873
 
1855
- case 32:
1874
+ case 33:
1856
1875
  _context.t8 = _context.t7;
1857
1876
  _context.t9 = _context.t1.assign.call(_context.t1, _context.t6, _context.t8);
1858
1877
  _context.t10 = {
1859
1878
  session: session,
1860
- envAppUrl: process.env['FRONTEGG_APP_URL'],
1879
+ envAppUrl: envAppUrl,
1861
1880
  envBaseUrl: process.env['FRONTEGG_BASE_URL'],
1862
1881
  envClientId: process.env['FRONTEGG_CLIENT_ID']
1863
1882
  };
@@ -1866,56 +1885,56 @@ var withFronteggApp = function withFronteggApp(app, options) {
1866
1885
  pageProps: _context.t11
1867
1886
  });
1868
1887
 
1869
- case 39:
1888
+ case 40:
1870
1889
  appContext.session = null;
1871
1890
  _context.t12 = Object;
1872
1891
  _context.t13 = Object;
1873
1892
  _context.t14 = {};
1874
1893
 
1875
1894
  if (!originalGetInitialProps) {
1876
- _context.next = 49;
1895
+ _context.next = 50;
1877
1896
  break;
1878
1897
  }
1879
1898
 
1880
- _context.next = 46;
1899
+ _context.next = 47;
1881
1900
  return originalGetInitialProps(appContext);
1882
1901
 
1883
- case 46:
1902
+ case 47:
1884
1903
  _context.t15 = _context.sent;
1885
- _context.next = 50;
1904
+ _context.next = 51;
1886
1905
  break;
1887
1906
 
1888
- case 49:
1907
+ case 50:
1889
1908
  _context.t15 = {};
1890
1909
 
1891
- case 50:
1910
+ case 51:
1892
1911
  _context.t16 = _context.t15;
1893
1912
  _context.t17 = _context.t13.assign.call(_context.t13, _context.t14, _context.t16);
1894
1913
 
1895
1914
  if (!Component.getInitialProps) {
1896
- _context.next = 58;
1915
+ _context.next = 59;
1897
1916
  break;
1898
1917
  }
1899
1918
 
1900
- _context.next = 55;
1919
+ _context.next = 56;
1901
1920
  return Component.getInitialProps(ctx);
1902
1921
 
1903
- case 55:
1922
+ case 56:
1904
1923
  _context.t18 = _context.sent;
1905
- _context.next = 59;
1924
+ _context.next = 60;
1906
1925
  break;
1907
1926
 
1908
- case 58:
1927
+ case 59:
1909
1928
  _context.t18 = {};
1910
1929
 
1911
- case 59:
1930
+ case 60:
1912
1931
  _context.t19 = _context.t18;
1913
1932
  _context.t20 = _context.t12.assign.call(_context.t12, _context.t17, _context.t19);
1914
1933
  return _context.abrupt("return", {
1915
1934
  pageProps: _context.t20
1916
1935
  });
1917
1936
 
1918
- case 62:
1937
+ case 63:
1919
1938
  case "end":
1920
1939
  return _context.stop();
1921
1940
  }
package/index.esm.js CHANGED
@@ -1083,19 +1083,37 @@ 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
+ var url = undefined;
1090
+
1091
+ if (process.env['VERCEL_URL']) {
1092
+ url = process.env['VERCEL_URL'];
1093
+ } else if (process.env['FRONTEGG_APP_URL']) {
1094
+ url = process.env['FRONTEGG_APP_URL'];
1095
+ }
1096
+
1097
+ if (url && !url.startsWith('http')) {
1098
+ var protocol = url.startsWith('localhost') ? 'http://' : 'https://';
1099
+ url = "".concat(protocol).concat(url);
1100
+ }
1101
+
1102
+ return url;
1103
+ }
1086
1104
  }, {
1087
1105
  key: "appUrl",
1088
1106
  get: function get() {
1089
1107
  var _a;
1090
1108
 
1091
- return (_a = process.env['FRONTEGG_APP_URL']) !== null && _a !== void 0 ? _a : 'http://localhost:3000';
1109
+ return (_a = this.getEnvAppUrl()) !== null && _a !== void 0 ? _a : 'http://localhost:3000';
1092
1110
  }
1093
1111
  }, {
1094
1112
  key: "cookieDomain",
1095
1113
  get: function get() {
1096
1114
  var _a;
1097
1115
 
1098
- return new URL((_a = process.env['FRONTEGG_APP_URL']) !== null && _a !== void 0 ? _a : '').hostname.replace(/:(\d)+$/, '');
1116
+ return new URL((_a = this.getEnvAppUrl()) !== null && _a !== void 0 ? _a : '').hostname.replace(/:(\d)+$/, '');
1099
1117
  }
1100
1118
  }, {
1101
1119
  key: "getJwtPublicKey",
@@ -1741,7 +1759,7 @@ var withFronteggApp = function withFronteggApp(app, options) {
1741
1759
 
1742
1760
  app.getInitialProps = function (appContext) {
1743
1761
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee() {
1744
- var _c, _d, ctx, Component, session;
1762
+ var _c, _d, ctx, Component, session, envAppUrl;
1745
1763
 
1746
1764
  return regenerator.wrap(function _callee$(_context) {
1747
1765
  while (1) {
@@ -1750,7 +1768,7 @@ var withFronteggApp = function withFronteggApp(app, options) {
1750
1768
  ctx = appContext.ctx, Component = appContext.Component;
1751
1769
 
1752
1770
  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 = 39;
1771
+ _context.next = 40;
1754
1772
  break;
1755
1773
  }
1756
1774
 
@@ -1760,78 +1778,79 @@ var withFronteggApp = function withFronteggApp(app, options) {
1760
1778
  case 4:
1761
1779
  session = _context.sent;
1762
1780
  appContext.session = session;
1781
+ envAppUrl = fronteggConfig.getEnvAppUrl();
1763
1782
 
1764
- if (process.env['FRONTEGG_APP_URL']) {
1765
- _context.next = 8;
1783
+ if (envAppUrl) {
1784
+ _context.next = 9;
1766
1785
  break;
1767
1786
  }
1768
1787
 
1769
1788
  throw Error('@frontegg/nextjs: .env.local must contain FRONTEGG_APP_URL');
1770
1789
 
1771
- case 8:
1790
+ case 9:
1772
1791
  if (process.env['FRONTEGG_BASE_URL']) {
1773
- _context.next = 10;
1792
+ _context.next = 11;
1774
1793
  break;
1775
1794
  }
1776
1795
 
1777
1796
  throw Error('@frontegg/nextjs: .env.local must contain FRONTEGG_BASE_URL');
1778
1797
 
1779
- case 10:
1798
+ case 11:
1780
1799
  if (process.env['FRONTEGG_CLIENT_ID']) {
1781
- _context.next = 12;
1800
+ _context.next = 13;
1782
1801
  break;
1783
1802
  }
1784
1803
 
1785
1804
  throw Error('@frontegg/nextjs: .env.local must contain FRONTEGG_CLIENT_ID');
1786
1805
 
1787
- case 12:
1806
+ case 13:
1788
1807
  _context.t0 = Object;
1789
1808
  _context.t1 = Object;
1790
1809
  _context.t2 = Object;
1791
1810
  _context.t3 = {};
1792
1811
 
1793
1812
  if (!originalGetInitialProps) {
1794
- _context.next = 22;
1813
+ _context.next = 23;
1795
1814
  break;
1796
1815
  }
1797
1816
 
1798
- _context.next = 19;
1817
+ _context.next = 20;
1799
1818
  return originalGetInitialProps(appContext);
1800
1819
 
1801
- case 19:
1820
+ case 20:
1802
1821
  _context.t4 = _context.sent;
1803
- _context.next = 23;
1822
+ _context.next = 24;
1804
1823
  break;
1805
1824
 
1806
- case 22:
1825
+ case 23:
1807
1826
  _context.t4 = {};
1808
1827
 
1809
- case 23:
1828
+ case 24:
1810
1829
  _context.t5 = _context.t4;
1811
1830
  _context.t6 = _context.t2.assign.call(_context.t2, _context.t3, _context.t5);
1812
1831
 
1813
1832
  if (!Component.getInitialProps) {
1814
- _context.next = 31;
1833
+ _context.next = 32;
1815
1834
  break;
1816
1835
  }
1817
1836
 
1818
- _context.next = 28;
1837
+ _context.next = 29;
1819
1838
  return Component.getInitialProps(ctx);
1820
1839
 
1821
- case 28:
1840
+ case 29:
1822
1841
  _context.t7 = _context.sent;
1823
- _context.next = 32;
1842
+ _context.next = 33;
1824
1843
  break;
1825
1844
 
1826
- case 31:
1845
+ case 32:
1827
1846
  _context.t7 = {};
1828
1847
 
1829
- case 32:
1848
+ case 33:
1830
1849
  _context.t8 = _context.t7;
1831
1850
  _context.t9 = _context.t1.assign.call(_context.t1, _context.t6, _context.t8);
1832
1851
  _context.t10 = {
1833
1852
  session: session,
1834
- envAppUrl: process.env['FRONTEGG_APP_URL'],
1853
+ envAppUrl: envAppUrl,
1835
1854
  envBaseUrl: process.env['FRONTEGG_BASE_URL'],
1836
1855
  envClientId: process.env['FRONTEGG_CLIENT_ID']
1837
1856
  };
@@ -1840,56 +1859,56 @@ var withFronteggApp = function withFronteggApp(app, options) {
1840
1859
  pageProps: _context.t11
1841
1860
  });
1842
1861
 
1843
- case 39:
1862
+ case 40:
1844
1863
  appContext.session = null;
1845
1864
  _context.t12 = Object;
1846
1865
  _context.t13 = Object;
1847
1866
  _context.t14 = {};
1848
1867
 
1849
1868
  if (!originalGetInitialProps) {
1850
- _context.next = 49;
1869
+ _context.next = 50;
1851
1870
  break;
1852
1871
  }
1853
1872
 
1854
- _context.next = 46;
1873
+ _context.next = 47;
1855
1874
  return originalGetInitialProps(appContext);
1856
1875
 
1857
- case 46:
1876
+ case 47:
1858
1877
  _context.t15 = _context.sent;
1859
- _context.next = 50;
1878
+ _context.next = 51;
1860
1879
  break;
1861
1880
 
1862
- case 49:
1881
+ case 50:
1863
1882
  _context.t15 = {};
1864
1883
 
1865
- case 50:
1884
+ case 51:
1866
1885
  _context.t16 = _context.t15;
1867
1886
  _context.t17 = _context.t13.assign.call(_context.t13, _context.t14, _context.t16);
1868
1887
 
1869
1888
  if (!Component.getInitialProps) {
1870
- _context.next = 58;
1889
+ _context.next = 59;
1871
1890
  break;
1872
1891
  }
1873
1892
 
1874
- _context.next = 55;
1893
+ _context.next = 56;
1875
1894
  return Component.getInitialProps(ctx);
1876
1895
 
1877
- case 55:
1896
+ case 56:
1878
1897
  _context.t18 = _context.sent;
1879
- _context.next = 59;
1898
+ _context.next = 60;
1880
1899
  break;
1881
1900
 
1882
- case 58:
1901
+ case 59:
1883
1902
  _context.t18 = {};
1884
1903
 
1885
- case 59:
1904
+ case 60:
1886
1905
  _context.t19 = _context.t18;
1887
1906
  _context.t20 = _context.t12.assign.call(_context.t12, _context.t17, _context.t19);
1888
1907
  return _context.abrupt("return", {
1889
1908
  pageProps: _context.t20
1890
1909
  });
1891
1910
 
1892
- case 62:
1911
+ case 63:
1893
1912
  case "end":
1894
1913
  return _context.stop();
1895
1914
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@frontegg/nextjs",
3
- "version": "6.1.0-alpha.2962640568",
3
+ "version": "6.1.0-alpha.2964994546",
4
4
  "dependencies": {
5
- "@frontegg/js": "6.0.3-alpha.4",
6
- "@frontegg/react-hooks": "6.0.3-alpha.4",
5
+ "@frontegg/js": "6.2.1",
6
+ "@frontegg/react-hooks": "6.2.1",
7
7
  "jose": "^4.8.0",
8
8
  "iron-session": "^6.1.2",
9
9
  "http-proxy": "^1.18.1",