@monocloud/auth-nextjs 0.1.2 → 0.1.4
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/README.md +3 -0
- package/dist/index.cjs +20 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +21 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MonoCloudAuthBaseError, MonoCloudCoreClient, MonoCloudHttpError, MonoCloudOPError, MonoCloudTokenError, MonoCloudValidationError, MonoCloudValidationError as MonoCloudValidationError$1 } from "@monocloud/auth-node-core";
|
|
2
2
|
import { NextRequest, NextResponse } from "next/server.js";
|
|
3
|
-
import { ensureLeadingSlash, isAbsoluteUrl } from "@monocloud/auth-node-core/internal";
|
|
3
|
+
import { ensureLeadingSlash, isAbsoluteUrl, isPresent } from "@monocloud/auth-node-core/internal";
|
|
4
4
|
import { isUserInGroup } from "@monocloud/auth-node-core/utils";
|
|
5
5
|
import { serialize } from "cookie";
|
|
6
6
|
import { IncomingMessage, ServerResponse } from "node:http";
|
|
@@ -221,11 +221,28 @@ const isMonoCloudResponse = (res) => res instanceof MonoCloudAppRouterResponse |
|
|
|
221
221
|
const isAppRouter = (req) => req instanceof Request || req.headers instanceof Headers || typeof req.bodyUsed === "boolean";
|
|
222
222
|
const getNextRequest = (req) => {
|
|
223
223
|
if (req instanceof NextRequest) return req;
|
|
224
|
-
return new NextRequest(req
|
|
224
|
+
return new NextRequest(req.url, {
|
|
225
|
+
method: req.method,
|
|
226
|
+
headers: req.headers,
|
|
227
|
+
body: req.body,
|
|
228
|
+
duplex: req.duplex ?? "half"
|
|
229
|
+
});
|
|
225
230
|
};
|
|
226
231
|
const getNextResponse = (res) => {
|
|
227
232
|
if (res instanceof NextResponse) return res;
|
|
228
|
-
if (res instanceof Response)
|
|
233
|
+
if (res instanceof Response) {
|
|
234
|
+
const nextResponse = new NextResponse(res.body, {
|
|
235
|
+
status: res.status,
|
|
236
|
+
statusText: res.statusText,
|
|
237
|
+
headers: res.headers,
|
|
238
|
+
url: res.url
|
|
239
|
+
});
|
|
240
|
+
try {
|
|
241
|
+
/* v8 ignore else -- @preserve */
|
|
242
|
+
if (!isPresent(nextResponse.url)) nextResponse.url = res.url;
|
|
243
|
+
} catch {}
|
|
244
|
+
return nextResponse;
|
|
245
|
+
}
|
|
229
246
|
return new NextResponse();
|
|
230
247
|
};
|
|
231
248
|
const getMonoCloudCookieReqRes = (req, resOrCtx) => {
|
|
@@ -441,7 +458,7 @@ var MonoCloudNextClient = class {
|
|
|
441
458
|
constructor(options) {
|
|
442
459
|
const opt = {
|
|
443
460
|
...options ?? {},
|
|
444
|
-
userAgent: (options === null || options === void 0 ? void 0 : options.userAgent) ?? `@monocloud/auth-nextjs@0.1.
|
|
461
|
+
userAgent: (options === null || options === void 0 ? void 0 : options.userAgent) ?? `@monocloud/auth-nextjs@0.1.4`,
|
|
445
462
|
debugger: (options === null || options === void 0 ? void 0 : options.debugger) ?? "@monocloud:auth-nextjs"
|
|
446
463
|
};
|
|
447
464
|
this.registerPublicEnvVariables();
|