@lowdefy/server 4.0.0-rc.6 → 4.0.0-rc.8

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/lib/Page.js CHANGED
@@ -26,7 +26,7 @@ import blocks from '../build/plugins/blocks.js';
26
26
  import icons from '../build/plugins/icons.js';
27
27
  import operators from '../build/plugins/operators/client.js';
28
28
 
29
- const Page = ({ auth, pageConfig, rootConfig }) => {
29
+ const Page = ({ auth, lowdefy, pageConfig, rootConfig }) => {
30
30
  const router = useRouter();
31
31
  return (
32
32
  <Client
@@ -36,6 +36,7 @@ const Page = ({ auth, pageConfig, rootConfig }) => {
36
36
  pageConfig,
37
37
  rootConfig,
38
38
  }}
39
+ lowdefy={lowdefy}
39
40
  router={router}
40
41
  types={{
41
42
  actions,
package/lib/auth/Auth.js CHANGED
@@ -24,7 +24,7 @@ import authConfig from '../../build/auth.json';
24
24
  function Auth({ children, session }) {
25
25
  if (authConfig.configured === true) {
26
26
  return (
27
- <AuthConfigured session={session} authConfig={authConfig}>
27
+ <AuthConfigured serverSession={session} authConfig={authConfig}>
28
28
  {(auth) => children(auth)}
29
29
  </AuthConfigured>
30
30
  );
@@ -15,11 +15,22 @@
15
15
  */
16
16
  /* eslint-disable react/jsx-props-no-spreading */
17
17
 
18
- import React from 'react';
19
- import { SessionProvider, signIn, signOut, useSession } from 'next-auth/react';
18
+ import React, { useEffect, useRef } from 'react';
19
+ import { getSession, SessionProvider, signIn, signOut, useSession } from 'next-auth/react';
20
+
21
+ import lowdefyConfig from '../../build/config.json';
20
22
 
21
23
  function Session({ children }) {
24
+ const wasAuthenticated = useRef(false);
22
25
  const { data: session, status } = useSession();
26
+ wasAuthenticated.current = wasAuthenticated.current || status === 'authenticated';
27
+
28
+ useEffect(() => {
29
+ if (wasAuthenticated.current && status === 'unauthenticated') {
30
+ window.location.reload();
31
+ }
32
+ }, [status]);
33
+
23
34
  // If session is passed to SessionProvider from getServerSideProps
24
35
  // we won't have a loading state here.
25
36
  // But 404 uses getStaticProps so we have this for 404.
@@ -30,10 +41,13 @@ function Session({ children }) {
30
41
  }
31
42
 
32
43
  function AuthConfigured({ authConfig, children, serverSession }) {
33
- const auth = { signIn, signOut, authConfig };
34
-
44
+ const auth = { authConfig, getSession, signIn, signOut };
45
+ let basePath = lowdefyConfig.basePath;
46
+ if (basePath) {
47
+ basePath = `${basePath}/api/auth`;
48
+ }
35
49
  return (
36
- <SessionProvider session={serverSession}>
50
+ <SessionProvider session={serverSession} basePath={basePath}>
37
51
  <Session>
38
52
  {(session) => {
39
53
  auth.session = session;
@@ -22,6 +22,7 @@ function authNotConfigured() {
22
22
  function AuthNotConfigured({ authConfig, children }) {
23
23
  const auth = {
24
24
  authConfig,
25
+ getSession: authNotConfigured,
25
26
  signIn: authNotConfigured,
26
27
  signOut: authNotConfigured,
27
28
  };
package/next.config.js CHANGED
@@ -2,7 +2,7 @@ const withLess = require('next-with-less');
2
2
  const lowdefyConfig = require('./build/config.json');
3
3
 
4
4
  module.exports = withLess({
5
- basePath: process.env.LOWDEFY_BASE_PATH || lowdefyConfig.basePath,
5
+ basePath: lowdefyConfig.basePath,
6
6
  reactStrictMode: true,
7
7
  webpack: (config, { isServer }) => {
8
8
  if (!isServer) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server",
3
- "version": "4.0.0-rc.6",
3
+ "version": "4.0.0-rc.8",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -45,17 +45,17 @@
45
45
  "next": "next"
46
46
  },
47
47
  "dependencies": {
48
- "@lowdefy/actions-core": "4.0.0-rc.6",
49
- "@lowdefy/api": "4.0.0-rc.6",
50
- "@lowdefy/blocks-antd": "4.0.0-rc.6",
51
- "@lowdefy/blocks-basic": "4.0.0-rc.6",
52
- "@lowdefy/blocks-loaders": "4.0.0-rc.6",
53
- "@lowdefy/client": "4.0.0-rc.6",
54
- "@lowdefy/helpers": "4.0.0-rc.6",
55
- "@lowdefy/layout": "4.0.0-rc.6",
56
- "@lowdefy/node-utils": "4.0.0-rc.6",
57
- "@lowdefy/operators-js": "4.0.0-rc.6",
58
- "@lowdefy/plugin-next-auth": "4.0.0-rc.6",
48
+ "@lowdefy/actions-core": "4.0.0-rc.8",
49
+ "@lowdefy/api": "4.0.0-rc.8",
50
+ "@lowdefy/blocks-antd": "4.0.0-rc.8",
51
+ "@lowdefy/blocks-basic": "4.0.0-rc.8",
52
+ "@lowdefy/blocks-loaders": "4.0.0-rc.8",
53
+ "@lowdefy/client": "4.0.0-rc.8",
54
+ "@lowdefy/helpers": "4.0.0-rc.8",
55
+ "@lowdefy/layout": "4.0.0-rc.8",
56
+ "@lowdefy/node-utils": "4.0.0-rc.8",
57
+ "@lowdefy/operators-js": "4.0.0-rc.8",
58
+ "@lowdefy/plugin-next-auth": "4.0.0-rc.8",
59
59
  "next": "12.3.1",
60
60
  "next-auth": "4.20.1",
61
61
  "process": "0.11.10",
@@ -64,18 +64,18 @@
64
64
  "react-icons": "4.7.1"
65
65
  },
66
66
  "devDependencies": {
67
- "@lowdefy/build": "4.0.0-rc.6",
67
+ "@lowdefy/build": "4.0.0-rc.8",
68
68
  "@next/eslint-plugin-next": "12.1.6",
69
69
  "less": "4.1.3",
70
70
  "less-loader": "11.1.0",
71
71
  "next-with-less": "2.0.5",
72
72
  "webpack": "5.76.0",
73
- "yaml": "2.2.1",
73
+ "yaml": "2.2.2",
74
74
  "yargs": "17.6.2"
75
75
  },
76
76
  "packageManager": "pnpm@7.11.0",
77
77
  "publishConfig": {
78
78
  "access": "public"
79
79
  },
80
- "gitHead": "8238145a9eb26c6f3dc48661ab6eca6e3aca4f83"
80
+ "gitHead": "db883daef0443647439b6fe2db845b846ffb6d4e"
81
81
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server",
3
- "version": "4.0.0-rc.6",
3
+ "version": "4.0.0-rc.8",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -45,17 +45,17 @@
45
45
  "next": "next"
46
46
  },
47
47
  "dependencies": {
48
- "@lowdefy/actions-core": "4.0.0-rc.6",
49
- "@lowdefy/api": "4.0.0-rc.6",
50
- "@lowdefy/blocks-antd": "4.0.0-rc.6",
51
- "@lowdefy/blocks-basic": "4.0.0-rc.6",
52
- "@lowdefy/blocks-loaders": "4.0.0-rc.6",
53
- "@lowdefy/client": "4.0.0-rc.6",
54
- "@lowdefy/helpers": "4.0.0-rc.6",
55
- "@lowdefy/layout": "4.0.0-rc.6",
56
- "@lowdefy/node-utils": "4.0.0-rc.6",
57
- "@lowdefy/operators-js": "4.0.0-rc.6",
58
- "@lowdefy/plugin-next-auth": "4.0.0-rc.6",
48
+ "@lowdefy/actions-core": "4.0.0-rc.8",
49
+ "@lowdefy/api": "4.0.0-rc.8",
50
+ "@lowdefy/blocks-antd": "4.0.0-rc.8",
51
+ "@lowdefy/blocks-basic": "4.0.0-rc.8",
52
+ "@lowdefy/blocks-loaders": "4.0.0-rc.8",
53
+ "@lowdefy/client": "4.0.0-rc.8",
54
+ "@lowdefy/helpers": "4.0.0-rc.8",
55
+ "@lowdefy/layout": "4.0.0-rc.8",
56
+ "@lowdefy/node-utils": "4.0.0-rc.8",
57
+ "@lowdefy/operators-js": "4.0.0-rc.8",
58
+ "@lowdefy/plugin-next-auth": "4.0.0-rc.8",
59
59
  "next": "12.3.1",
60
60
  "next-auth": "4.20.1",
61
61
  "process": "0.11.10",
@@ -64,13 +64,13 @@
64
64
  "react-icons": "4.7.1"
65
65
  },
66
66
  "devDependencies": {
67
- "@lowdefy/build": "4.0.0-rc.6",
67
+ "@lowdefy/build": "4.0.0-rc.8",
68
68
  "@next/eslint-plugin-next": "12.1.6",
69
69
  "less": "4.1.3",
70
70
  "less-loader": "11.1.0",
71
71
  "next-with-less": "2.0.5",
72
72
  "webpack": "5.76.0",
73
- "yaml": "2.2.1",
73
+ "yaml": "2.2.2",
74
74
  "yargs": "17.6.2"
75
75
  },
76
76
  "packageManager": "pnpm@7.11.0",
package/pages/_app.js CHANGED
@@ -15,7 +15,7 @@
15
15
  */
16
16
  /* eslint-disable react/jsx-props-no-spreading */
17
17
 
18
- import React from 'react';
18
+ import React, { useRef } from 'react';
19
19
  import dynamic from 'next/dynamic';
20
20
 
21
21
  import Auth from '../lib/auth/Auth.js';
@@ -24,9 +24,17 @@ import Auth from '../lib/auth/Auth.js';
24
24
  import '../build/plugins/styles.less';
25
25
 
26
26
  function App({ Component, pageProps: { session, rootConfig, pageConfig } }) {
27
+ const lowdefyRef = useRef({});
27
28
  return (
28
29
  <Auth session={session}>
29
- {(auth) => <Component auth={auth} rootConfig={rootConfig} pageConfig={pageConfig} />}
30
+ {(auth) => (
31
+ <Component
32
+ auth={auth}
33
+ lowdefy={lowdefyRef.current}
34
+ rootConfig={rootConfig}
35
+ pageConfig={pageConfig}
36
+ />
37
+ )}
30
38
  </Auth>
31
39
  );
32
40
  }
@@ -16,16 +16,20 @@
16
16
 
17
17
  import React from 'react';
18
18
  import Document, { Html, Head, Main, NextScript } from 'next/document';
19
+
19
20
  import appJson from '../build/app.json';
21
+ import lowdefyConfig from '../build/config.json';
22
+
23
+ const basePath = lowdefyConfig.basePath ?? '';
20
24
 
21
25
  class LowdefyDocument extends Document {
22
26
  render() {
23
27
  return (
24
28
  <Html>
25
29
  <Head>
26
- <link rel="manifest" href="/manifest.webmanifest" />
27
- <link rel="icon" type="image/svg+xml" href="/icon.svg" />
28
- <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
30
+ <link rel="manifest" href={`${basePath}/manifest.webmanifest`} />
31
+ <link rel="icon" type="image/svg+xml" href={`${basePath}/icon.svg`} />
32
+ <link rel="apple-touch-icon" href={`${basePath}/apple-touch-icon.png`} />
29
33
  <meta name="viewport" content="width=device-width, initial-scale=1" />
30
34
  <script
31
35
  dangerouslySetInnerHTML={{
@@ -36,6 +36,11 @@ export const authOptions = getNextAuthConfig(
36
36
 
37
37
  export default async function auth(req, res) {
38
38
  if (authJson.configured === true) {
39
+ // Required for emails in corporate networks, see:
40
+ // https://next-auth.js.org/tutorials/avoid-corporate-link-checking-email-provider
41
+ if (req.method === 'HEAD') {
42
+ return res.status(200).end();
43
+ }
39
44
  return await NextAuth(req, res, authOptions);
40
45
  }
41
46