powr-sdk-api 4.22.1 → 4.22.2
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/routes/auth.js +38 -0
- package/package.json +1 -1
package/dist/routes/auth.js
CHANGED
|
@@ -945,4 +945,42 @@ router.post("/verify-otp", async (req, res) => {
|
|
|
945
945
|
});
|
|
946
946
|
}
|
|
947
947
|
});
|
|
948
|
+
|
|
949
|
+
// Cross-project memberships for the signed-in user (Ampy install catalog). No projectId on the request.
|
|
950
|
+
router.get("/my-project-memberships", verifyToken, async (req, res) => {
|
|
951
|
+
try {
|
|
952
|
+
var _req$user4;
|
|
953
|
+
const raw = String(((_req$user4 = req.user) === null || _req$user4 === void 0 ? void 0 : _req$user4.powrId) || "");
|
|
954
|
+
if (!ObjectId.isValid(raw)) {
|
|
955
|
+
return res.status(400).json({
|
|
956
|
+
success: false,
|
|
957
|
+
message: "Invalid user"
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
const userId = new ObjectId(raw);
|
|
961
|
+
const db = await getDb();
|
|
962
|
+
const profiles = await db.collection("profiles").find({
|
|
963
|
+
userId: {
|
|
964
|
+
$in: [userId, raw]
|
|
965
|
+
}
|
|
966
|
+
}).project({
|
|
967
|
+
projectId: 1,
|
|
968
|
+
access: 1,
|
|
969
|
+
_id: 0
|
|
970
|
+
}).toArray();
|
|
971
|
+
return res.json({
|
|
972
|
+
success: true,
|
|
973
|
+
memberships: profiles.map(profile => ({
|
|
974
|
+
projectId: String(profile.projectId),
|
|
975
|
+
access: typeof profile.access === "number" ? profile.access : Number(profile.access) || 0
|
|
976
|
+
}))
|
|
977
|
+
});
|
|
978
|
+
} catch (error) {
|
|
979
|
+
console.error("Error in my-project-memberships:", error);
|
|
980
|
+
return res.status(500).json({
|
|
981
|
+
success: false,
|
|
982
|
+
message: "Failed to load project memberships"
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
});
|
|
948
986
|
module.exports = router;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "powr-sdk-api",
|
|
3
|
-
"version": "4.22.
|
|
3
|
+
"version": "4.22.2",
|
|
4
4
|
"description": "Shared API core library for PowrStack projects. Zero dependencies - works with Express, Next.js API routes, and other frameworks. All features are optional and install only what you need.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|