memory-privacy 1.5.0 → 1.6.0
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/identity.ts +5 -2
- package/package.json +1 -1
package/identity.ts
CHANGED
|
@@ -35,10 +35,13 @@ export function resolveSessionIdentity(sessionKey: string | undefined): SessionI
|
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* 判断 userId 是否是主人
|
|
38
|
-
* 从环境变量
|
|
38
|
+
* 从环境变量 OPENCLAW_GATEWAY_TOKEN 获取并解析主人 ID
|
|
39
|
+
* token 格式如 "oc-user-f76e8c98afb148539963c1b726f2afac",用 "-" 切分取最后一段作为 owner ID
|
|
39
40
|
*/
|
|
40
41
|
export function isOwner(userId: string): boolean {
|
|
41
|
-
const
|
|
42
|
+
const token = process.env.OPENCLAW_GATEWAY_TOKEN || "";
|
|
43
|
+
if (!token) return false;
|
|
44
|
+
const ownerUserId = token.split("-").pop() || "";
|
|
42
45
|
if (!ownerUserId) return false;
|
|
43
46
|
return ownerUserId === userId;
|
|
44
47
|
}
|