@lowdefy/server 4.0.0-alpha.22 → 4.0.0-alpha.25

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.
@@ -14,12 +14,13 @@
14
14
  limitations under the License.
15
15
  */
16
16
 
17
- import { getSession } from 'next-auth/react';
17
+ import { unstable_getServerSession } from 'next-auth/next';
18
+ import { authOptions } from '../../pages/api/auth/[...nextauth].js';
18
19
  import authJson from '../../build/auth.json';
19
20
 
20
- async function getServerSession(context) {
21
+ async function getServerSession({ req, res }) {
21
22
  if (authJson.configured === true) {
22
- return await getSession(context);
23
+ return await unstable_getServerSession(req, res, authOptions);
23
24
  }
24
25
  return undefined;
25
26
  }
@@ -34,6 +34,7 @@ async function createCustomPluginTypesMap({ directories }) {
34
34
  const customTypesMap = {
35
35
  actions: {},
36
36
  auth: {
37
+ adapters: {},
37
38
  callbacks: {},
38
39
  events: {},
39
40
  providers: {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server",
3
- "version": "4.0.0-alpha.22",
3
+ "version": "4.0.0-alpha.25",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -42,26 +42,26 @@
42
42
  "next": "next"
43
43
  },
44
44
  "dependencies": {
45
- "@lowdefy/actions-core": "4.0.0-alpha.22",
46
- "@lowdefy/api": "4.0.0-alpha.22",
47
- "@lowdefy/blocks-antd": "4.0.0-alpha.22",
48
- "@lowdefy/blocks-basic": "4.0.0-alpha.22",
49
- "@lowdefy/blocks-loaders": "4.0.0-alpha.22",
50
- "@lowdefy/client": "4.0.0-alpha.22",
51
- "@lowdefy/helpers": "4.0.0-alpha.22",
52
- "@lowdefy/layout": "4.0.0-alpha.22",
53
- "@lowdefy/node-utils": "4.0.0-alpha.22",
54
- "@lowdefy/operators-js": "4.0.0-alpha.22",
55
- "@lowdefy/plugin-next-auth": "4.0.0-alpha.22",
45
+ "@lowdefy/actions-core": "4.0.0-alpha.25",
46
+ "@lowdefy/api": "4.0.0-alpha.25",
47
+ "@lowdefy/blocks-antd": "4.0.0-alpha.25",
48
+ "@lowdefy/blocks-basic": "4.0.0-alpha.25",
49
+ "@lowdefy/blocks-loaders": "4.0.0-alpha.25",
50
+ "@lowdefy/client": "4.0.0-alpha.25",
51
+ "@lowdefy/helpers": "4.0.0-alpha.25",
52
+ "@lowdefy/layout": "4.0.0-alpha.25",
53
+ "@lowdefy/node-utils": "4.0.0-alpha.25",
54
+ "@lowdefy/operators-js": "4.0.0-alpha.25",
55
+ "@lowdefy/plugin-next-auth": "4.0.0-alpha.25",
56
56
  "next": "12.1.6",
57
- "next-auth": "4.9.0",
57
+ "next-auth": "4.10.3",
58
58
  "process": "0.11.10",
59
59
  "react": "18.1.0",
60
60
  "react-dom": "18.1.0",
61
61
  "react-icons": "4.3.1"
62
62
  },
63
63
  "devDependencies": {
64
- "@lowdefy/build": "4.0.0-alpha.22",
64
+ "@lowdefy/build": "4.0.0-alpha.25",
65
65
  "@next/eslint-plugin-next": "12.1.6",
66
66
  "less": "4.1.2",
67
67
  "less-loader": "11.0.0",
@@ -72,5 +72,5 @@
72
72
  "publishConfig": {
73
73
  "access": "public"
74
74
  },
75
- "gitHead": "66ce29562c016a8bcf0cbea4bbbbb71d364ae995"
75
+ "gitHead": "720e5090c9777fc2176517a53e88a3b81fc8c237"
76
76
  }
@@ -16,6 +16,7 @@
16
16
 
17
17
  import React from 'react';
18
18
  import Document, { Html, Head, Main, NextScript } from 'next/document';
19
+ import appJson from '../build/app.json';
19
20
 
20
21
  class LowdefyDocument extends Document {
21
22
  render() {
@@ -25,10 +26,20 @@ class LowdefyDocument extends Document {
25
26
  <link rel="manifest" href="/manifest.webmanifest" />
26
27
  <link rel="icon" type="image/svg+xml" href="/icon.svg" />
27
28
  <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
29
+ <script
30
+ dangerouslySetInnerHTML={{
31
+ __html: `/* start of Lowdefy append head */</script>${appJson.html.appendHead}<script>/* end of Lowdefy append head */`,
32
+ }}
33
+ />
28
34
  </Head>
29
35
  <body>
30
36
  <Main />
31
37
  <NextScript />
38
+ <script
39
+ dangerouslySetInnerHTML={{
40
+ __html: `/* start of Lowdefy append body */</script>${appJson.html.appendBody}<script>/* end of Lowdefy append body */`,
41
+ }}
42
+ />
32
43
  </body>
33
44
  </Html>
34
45
  );
@@ -18,20 +18,19 @@ import NextAuth from 'next-auth';
18
18
  import { getNextAuthConfig } from '@lowdefy/api';
19
19
 
20
20
  import authJson from '../../../build/auth.json';
21
+ import adapters from '../../../build/plugins/auth/adapters.js';
21
22
  import callbacks from '../../../build/plugins/auth/callbacks.js';
22
23
  import events from '../../../build/plugins/auth/events.js';
23
24
  import providers from '../../../build/plugins/auth/providers.js';
24
25
 
26
+ export const authOptions = getNextAuthConfig(
27
+ { logger: console }, // TODO: make createApiContext synchronous
28
+ { authJson, plugins: { adapters, callbacks, events, providers } }
29
+ );
30
+
25
31
  export default async function auth(req, res) {
26
32
  if (authJson.configured === true) {
27
- return await NextAuth(
28
- req,
29
- res,
30
- getNextAuthConfig(
31
- { logger: console },
32
- { authJson, plugins: { callbacks, events, providers } }
33
- )
34
- );
33
+ return await NextAuth(req, res, authOptions);
35
34
  }
36
35
 
37
36
  return res.status(404).json({
@@ -28,7 +28,7 @@ export default async function handler(req, res) {
28
28
  if (req.method !== 'POST') {
29
29
  throw new Error('Only POST requests are supported.');
30
30
  }
31
- const session = await getServerSession({ req });
31
+ const session = await getServerSession({ req, res });
32
32
  // Important to give absolute path so Next can trace build files
33
33
  const apiContext = await createApiContext({
34
34
  buildDirectory: path.join(process.cwd(), 'build'),