@monocloud/auth-nextjs 0.1.4 → 0.1.5
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/dist/client/index.cjs +1 -1
- package/dist/client/index.d.mts +43 -5
- package/dist/client/index.mjs +1 -1
- package/dist/{client-CnvBgZM-.mjs → client-D-3RMRNY.mjs} +43 -9
- package/dist/client-D-3RMRNY.mjs.map +1 -0
- package/dist/{client-Be6A2vEn.cjs → client-xfBYYato.cjs} +43 -9
- package/dist/client-xfBYYato.cjs.map +1 -0
- package/dist/components/client/index.cjs +9 -9
- package/dist/components/client/index.cjs.map +1 -1
- package/dist/components/client/index.d.mts +13 -8
- package/dist/components/client/index.mjs +9 -9
- package/dist/components/client/index.mjs.map +1 -1
- package/dist/components/index.d.mts +1 -1
- package/dist/index.cjs +10 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +21 -12
- package/dist/index.mjs +10 -11
- package/dist/index.mjs.map +1 -1
- package/dist/{types-DOfZTKa6.d.mts → types-CsBjAJce.d.mts} +79 -20
- package/package.json +1 -1
- package/dist/client-Be6A2vEn.cjs.map +0 -1
- package/dist/client-CnvBgZM-.mjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -459,7 +459,7 @@ var MonoCloudNextClient = class {
|
|
|
459
459
|
constructor(options) {
|
|
460
460
|
const opt = {
|
|
461
461
|
...options ?? {},
|
|
462
|
-
userAgent: (options === null || options === void 0 ? void 0 : options.userAgent) ?? `@monocloud/auth-nextjs@0.1.
|
|
462
|
+
userAgent: (options === null || options === void 0 ? void 0 : options.userAgent) ?? `@monocloud/auth-nextjs@0.1.5`,
|
|
463
463
|
debugger: (options === null || options === void 0 ? void 0 : options.debugger) ?? "@monocloud:auth-nextjs"
|
|
464
464
|
};
|
|
465
465
|
this.registerPublicEnvVariables();
|
|
@@ -578,7 +578,7 @@ var MonoCloudNextClient = class {
|
|
|
578
578
|
return redirect(signInRoute.toString());
|
|
579
579
|
}
|
|
580
580
|
if ((options === null || options === void 0 ? void 0 : options.groups) && !(0, _monocloud_auth_node_core_utils.isUserInGroup)(session.user, options.groups, options.groupsClaim ?? process.env.MONOCLOUD_AUTH_GROUPS_CLAIM, options.matchAll)) {
|
|
581
|
-
if (options.
|
|
581
|
+
if (options.onGroupAccessDenied) return options.onGroupAccessDenied({
|
|
582
582
|
...params,
|
|
583
583
|
user: session.user
|
|
584
584
|
});
|
|
@@ -620,11 +620,11 @@ var MonoCloudNextClient = class {
|
|
|
620
620
|
} };
|
|
621
621
|
}
|
|
622
622
|
if ((options === null || options === void 0 ? void 0 : options.groups) && !(0, _monocloud_auth_node_core_utils.isUserInGroup)(session.user, options.groups, options.groupsClaim ?? process.env.MONOCLOUD_AUTH_GROUPS_CLAIM, options.matchAll)) {
|
|
623
|
-
var _options$
|
|
624
|
-
const customProps$1 = await ((_options$
|
|
623
|
+
var _options$onGroupAcces;
|
|
624
|
+
const customProps$1 = await ((_options$onGroupAcces = options.onGroupAccessDenied) === null || _options$onGroupAcces === void 0 ? void 0 : _options$onGroupAcces.call(options, {
|
|
625
625
|
...context,
|
|
626
626
|
user: session.user
|
|
627
|
-
})) ?? { props: {
|
|
627
|
+
})) ?? { props: { groupAccessDenied: true } };
|
|
628
628
|
return {
|
|
629
629
|
...customProps$1,
|
|
630
630
|
props: { ...customProps$1.props ?? {} }
|
|
@@ -666,8 +666,8 @@ var MonoCloudNextClient = class {
|
|
|
666
666
|
return mergeResponse([res, next_server_js.NextResponse.json({ message: "unauthorized" }, { status: 401 })]);
|
|
667
667
|
}
|
|
668
668
|
if ((options === null || options === void 0 ? void 0 : options.groups) && !(0, _monocloud_auth_node_core_utils.isUserInGroup)(session.user, options.groups, options.groupsClaim ?? process.env.MONOCLOUD_AUTH_GROUPS_CLAIM, options.matchAll)) {
|
|
669
|
-
if (options.
|
|
670
|
-
const result = await options.
|
|
669
|
+
if (options.onGroupAccessDenied) {
|
|
670
|
+
const result = await options.onGroupAccessDenied(req, ctx, session.user);
|
|
671
671
|
if (result instanceof next_server_js.NextResponse) return mergeResponse([res, result]);
|
|
672
672
|
return mergeResponse([res, new next_server_js.NextResponse(result.body, result)]);
|
|
673
673
|
}
|
|
@@ -684,7 +684,7 @@ var MonoCloudNextClient = class {
|
|
|
684
684
|
return res.status(401).json({ message: "unauthorized" });
|
|
685
685
|
}
|
|
686
686
|
if ((options === null || options === void 0 ? void 0 : options.groups) && !(0, _monocloud_auth_node_core_utils.isUserInGroup)(session.user, options.groups, options.groupsClaim ?? process.env.MONOCLOUD_AUTH_GROUPS_CLAIM, options.matchAll)) {
|
|
687
|
-
if (options.
|
|
687
|
+
if (options.onGroupAccessDenied) return options.onGroupAccessDenied(req, res, session.user);
|
|
688
688
|
return res.status(403).json({ message: "forbidden" });
|
|
689
689
|
}
|
|
690
690
|
return handler(req, res);
|
|
@@ -748,10 +748,9 @@ var MonoCloudNextClient = class {
|
|
|
748
748
|
return mergeResponse([nxtResp, next_server_js.NextResponse.redirect(signInRoute)]);
|
|
749
749
|
}
|
|
750
750
|
const groupsClaim = (options === null || options === void 0 ? void 0 : options.groupsClaim) ?? process.env.MONOCLOUD_AUTH_GROUPS_CLAIM;
|
|
751
|
-
const onAccessDenied = options === null || options === void 0 ? void 0 : options.onAccessDenied;
|
|
752
751
|
if (allowedGroups && !(0, _monocloud_auth_node_core_utils.isUserInGroup)(session.user, allowedGroups, groupsClaim)) {
|
|
753
|
-
if (
|
|
754
|
-
const result = await
|
|
752
|
+
if (options === null || options === void 0 ? void 0 : options.onGroupAccessDenied) {
|
|
753
|
+
const result = await options.onGroupAccessDenied(req, evt, session.user);
|
|
755
754
|
if (result instanceof next_server_js.NextResponse) return mergeResponse([nxtResp, result]);
|
|
756
755
|
if (result) return mergeResponse([nxtResp, new next_server_js.NextResponse(result.body, result)]);
|
|
757
756
|
return next_server_js.NextResponse.next(nxtResp);
|