@henosia/app-next 1.0.8 → 1.0.9
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.
|
@@ -1,65 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*/
|
|
8
|
-
function patchWebpackOutputFileSystem(ofs) {
|
|
9
|
-
if (!ofs || ofs.__atomicEmitPatched) return;
|
|
10
|
-
if (typeof ofs.writeFile !== 'function' || typeof ofs.rename !== 'function') {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const origWriteFile = ofs.writeFile.bind(ofs);
|
|
15
|
-
const origRename = ofs.rename.bind(ofs);
|
|
16
|
-
const origUnlink = typeof ofs.unlink === 'function' ? ofs.unlink.bind(ofs) : null;
|
|
17
|
-
|
|
18
|
-
ofs.writeFile = function patchedWriteFile(filePath, content, optionsOrCb, maybeCb) {
|
|
19
|
-
const hasOptions = typeof optionsOrCb !== 'function';
|
|
20
|
-
const options = hasOptions ? optionsOrCb : undefined;
|
|
21
|
-
const cb = hasOptions ? maybeCb : optionsOrCb;
|
|
22
|
-
const tmp = `${filePath}.${process.pid}.${randomBytes(6).toString('hex')}.tmp`;
|
|
23
|
-
|
|
24
|
-
const done = (err) => {
|
|
25
|
-
if (err) {
|
|
26
|
-
if (origUnlink) origUnlink(tmp, () => cb(err));
|
|
27
|
-
else cb(err);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
origRename(tmp, filePath, cb);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
if (hasOptions && options !== undefined) {
|
|
34
|
-
origWriteFile(tmp, content, options, done);
|
|
35
|
-
} else {
|
|
36
|
-
origWriteFile(tmp, content, done);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
Object.defineProperty(ofs, '__atomicEmitPatched', { value: true, enumerable: false });
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
class AtomicEmitPlugin {
|
|
44
|
-
apply(compiler) {
|
|
45
|
-
// `outputFileSystem` may be assigned/replaced after `apply` runs (e.g. by
|
|
46
|
-
// Next.js or webpack-dev-middleware), so patch lazily right before each
|
|
47
|
-
// build's emit phase. This is idempotent thanks to `__atomicEmitPatched`.
|
|
48
|
-
const patch = () => patchWebpackOutputFileSystem(compiler.outputFileSystem);
|
|
49
|
-
compiler.hooks.beforeRun.tap('AtomicEmitPlugin', patch);
|
|
50
|
-
compiler.hooks.watchRun.tap('AtomicEmitPlugin', patch);
|
|
51
|
-
compiler.hooks.beforeCompile.tap('AtomicEmitPlugin', patch);
|
|
1
|
+
const henosiaPreviewTurboPackRules = {};
|
|
2
|
+
if (process.env.HENOSIA_LOADER_TURBOPACK_RULES) {
|
|
3
|
+
try {
|
|
4
|
+
Object.assign(henosiaPreviewTurboPackRules, JSON.parse(process.env.HENOSIA_LOADER_TURBOPACK_RULES));
|
|
5
|
+
} catch (e) {
|
|
6
|
+
console.error('[Henosia Loader] Error loading Turbopack rules', e);
|
|
52
7
|
}
|
|
53
8
|
}
|
|
54
9
|
|
|
55
10
|
/** @type {import('next').NextConfig} */
|
|
56
11
|
const nextConfig = {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
12
|
+
// the better-auth url is also a valid dev origin (note: next.js expects hostnames despite naming this option allowedDevOrigins)
|
|
13
|
+
allowedDevOrigins: process.env.BETTER_AUTH_URL ? [new URL(process.env.BETTER_AUTH_URL).hostname] : undefined,
|
|
14
|
+
devIndicators: false,
|
|
15
|
+
turbopack: {
|
|
16
|
+
"rules": {
|
|
17
|
+
...henosiaPreviewTurboPackRules
|
|
60
18
|
}
|
|
61
|
-
|
|
62
|
-
},
|
|
19
|
+
}
|
|
63
20
|
};
|
|
64
21
|
|
|
65
22
|
export default nextConfig;
|
|
@@ -3,7 +3,6 @@ import { HENOSIA_AUTH_SIGN_IN_PATH_NAME } from "../shared.mjs";
|
|
|
3
3
|
import { o as isUnauthorizedException, s as verifyHenosiaAuthToken } from "../server-DvvkIB4j.mjs";
|
|
4
4
|
import { headers } from "next/headers.js";
|
|
5
5
|
import { cache } from "react";
|
|
6
|
-
import { redirect } from "next/navigation.js";
|
|
7
6
|
import { NextResponse } from "next/server.js";
|
|
8
7
|
//#region src/auth/server-guards.ts
|
|
9
8
|
async function buildRequestFromHeaders() {
|
|
@@ -41,7 +40,10 @@ const requireHenosiaAuth = cache(async () => {
|
|
|
41
40
|
try {
|
|
42
41
|
return await verifyClaims();
|
|
43
42
|
} catch (error) {
|
|
44
|
-
if (isUnauthorizedException(error))
|
|
43
|
+
if (isUnauthorizedException(error)) {
|
|
44
|
+
const { redirect } = await import("next/navigation.js");
|
|
45
|
+
redirect(HENOSIA_AUTH_SIGN_IN_PATH_NAME);
|
|
46
|
+
}
|
|
45
47
|
throw error;
|
|
46
48
|
}
|
|
47
49
|
});
|
package/package.json
CHANGED