@opengeni/core 0.14.4 → 0.16.1
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/access/index.d.ts +1 -1
- package/dist/index.js +48 -12
- package/dist/index.js.map +1 -1
- package/dist/session-authorization.d.ts +4 -2
- package/package.json +8 -8
- package/src/access/index.ts +10 -5
- package/src/domain/packs.ts +22 -1
- package/src/domain/sessions.ts +1 -1
- package/src/session-authorization.ts +23 -6
package/dist/access/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Settings } from "@opengeni/config";
|
|
2
2
|
import { type AccountGrant, type AccessContext, type AccessGrant, type Permission } from "@opengeni/contracts";
|
|
3
3
|
import { type Database } from "@opengeni/db";
|
|
4
4
|
import type { Context } from "hono";
|
package/dist/index.js
CHANGED
|
@@ -757,6 +757,7 @@ async function provisionSandbox(services, ctx, input) {
|
|
|
757
757
|
}
|
|
758
758
|
|
|
759
759
|
// src/access/index.ts
|
|
760
|
+
import { resolveFirstPartyDelegationSecret } from "@opengeni/config";
|
|
760
761
|
import {
|
|
761
762
|
verifyDelegatedAccessToken
|
|
762
763
|
} from "@opengeni/contracts";
|
|
@@ -837,7 +838,9 @@ function requirePermission(grant, permission) {
|
|
|
837
838
|
message: "missing permission: variable-sets:manage (deprecated alias: environments:manage)"
|
|
838
839
|
});
|
|
839
840
|
}
|
|
840
|
-
throw new HTTPException2(403, {
|
|
841
|
+
throw new HTTPException2(403, {
|
|
842
|
+
message: `missing permission: ${permission}`
|
|
843
|
+
});
|
|
841
844
|
}
|
|
842
845
|
}
|
|
843
846
|
function hasPermission(permissions, permission) {
|
|
@@ -899,7 +902,9 @@ async function resolveAccessContext(c, deps) {
|
|
|
899
902
|
}
|
|
900
903
|
}
|
|
901
904
|
if (deps.managedAuth) {
|
|
902
|
-
const session = await deps.managedAuth.api.getSession({
|
|
905
|
+
const session = await deps.managedAuth.api.getSession({
|
|
906
|
+
headers: c.req.raw.headers
|
|
907
|
+
});
|
|
903
908
|
if (session?.user) {
|
|
904
909
|
return await ensureManagedAccessForUser(deps.db, {
|
|
905
910
|
userId: session.user.id,
|
|
@@ -950,10 +955,11 @@ async function apiKeyAccessContext(c, deps, mode) {
|
|
|
950
955
|
};
|
|
951
956
|
}
|
|
952
957
|
async function delegatedAccessContext(c, deps, mode, token = bearerToken(c)) {
|
|
953
|
-
|
|
958
|
+
const delegationSecret = resolveFirstPartyDelegationSecret(deps.settings);
|
|
959
|
+
if (!token || !delegationSecret) {
|
|
954
960
|
return null;
|
|
955
961
|
}
|
|
956
|
-
const payload = await verifyDelegatedAccessToken(
|
|
962
|
+
const payload = await verifyDelegatedAccessToken(delegationSecret, token);
|
|
957
963
|
if (!payload) {
|
|
958
964
|
return null;
|
|
959
965
|
}
|
|
@@ -1019,7 +1025,8 @@ import {
|
|
|
1019
1025
|
import {
|
|
1020
1026
|
getSession,
|
|
1021
1027
|
getSessionRootId,
|
|
1022
|
-
getSessionTurnForAttempt
|
|
1028
|
+
getSessionTurnForAttempt,
|
|
1029
|
+
getSlackInteractionSessionAccessForSession
|
|
1023
1030
|
} from "@opengeni/db";
|
|
1024
1031
|
var SESSION_AUTHORIZATION_DEFAULT_REAUTHORIZE_MS = 15e3;
|
|
1025
1032
|
var SessionAuthorizationDeniedError = class extends Error {
|
|
@@ -1039,11 +1046,19 @@ var SessionAuthorizationUnavailableError = class extends Error {
|
|
|
1039
1046
|
};
|
|
1040
1047
|
async function requireSessionAuthorization(deps, grant, input) {
|
|
1041
1048
|
const port = deps.sessionAuthorization;
|
|
1049
|
+
const slackAccess = await getSlackInteractionSessionAccessForSession(deps.db, {
|
|
1050
|
+
accountId: grant.accountId,
|
|
1051
|
+
workspaceId: grant.workspaceId,
|
|
1052
|
+
sessionId: input.sessionId
|
|
1053
|
+
});
|
|
1054
|
+
if (!port && slackAccess?.visibility !== "private") return null;
|
|
1055
|
+
const actor = await resolveSessionAuthorizationActor(deps.db, grant);
|
|
1056
|
+
const target = slackAccess ? { sessionId: input.sessionId, rootSessionId: slackAccess.rootSessionId } : await resolveSessionAuthorizationTarget(deps.db, grant, input.sessionId);
|
|
1057
|
+
if (slackAccess?.visibility === "private") {
|
|
1058
|
+
const allowed = actor.kind === "subject" ? actor.subjectId === slackAccess.owningSubjectId : actor.callerRootSessionId === target.rootSessionId;
|
|
1059
|
+
if (!allowed) throw new SessionAuthorizationDeniedError("forbidden");
|
|
1060
|
+
}
|
|
1042
1061
|
if (!port) return null;
|
|
1043
|
-
const [actor, target] = await Promise.all([
|
|
1044
|
-
resolveSessionAuthorizationActor(deps.db, grant),
|
|
1045
|
-
resolveSessionAuthorizationTarget(deps.db, grant, input.sessionId)
|
|
1046
|
-
]);
|
|
1047
1062
|
let rawDecision;
|
|
1048
1063
|
try {
|
|
1049
1064
|
rawDecision = await port.authorizeSession({
|
|
@@ -1497,10 +1512,26 @@ var marketingSocialPack = {
|
|
|
1497
1512
|
category: "social-media",
|
|
1498
1513
|
authModel: "oauth2_authorization_code_pkce",
|
|
1499
1514
|
providers: ["x"],
|
|
1500
|
-
scopes: ["tweet.read", "users.read", "offline.access"],
|
|
1515
|
+
scopes: ["tweet.read", "tweet.write", "users.read", "offline.access"],
|
|
1516
|
+
required: false,
|
|
1517
|
+
metadata: {
|
|
1518
|
+
docs: "https://docs.x.com/fundamentals/authentication/oauth-2-0/authorization-code",
|
|
1519
|
+
firstParty: true,
|
|
1520
|
+
oauthStartPath: "/social/oauth/start"
|
|
1521
|
+
}
|
|
1522
|
+
},
|
|
1523
|
+
{
|
|
1524
|
+
id: "reddit",
|
|
1525
|
+
name: "Reddit",
|
|
1526
|
+
category: "social-media",
|
|
1527
|
+
authModel: "oauth2_authorization_code",
|
|
1528
|
+
providers: ["reddit"],
|
|
1529
|
+
scopes: ["identity", "read", "submit", "privatemessages", "history"],
|
|
1501
1530
|
required: false,
|
|
1502
1531
|
metadata: {
|
|
1503
|
-
docs: "https://
|
|
1532
|
+
docs: "https://github.com/reddit-archive/reddit/wiki/OAuth2",
|
|
1533
|
+
firstParty: true,
|
|
1534
|
+
oauthStartPath: "/social/oauth/start"
|
|
1504
1535
|
}
|
|
1505
1536
|
},
|
|
1506
1537
|
{
|
|
@@ -1589,7 +1620,12 @@ var marketingSocialPack = {
|
|
|
1589
1620
|
firstPartyMcpTools: [
|
|
1590
1621
|
"social_connections_list",
|
|
1591
1622
|
"social_posts_recent",
|
|
1592
|
-
"social_daily_analysis_context"
|
|
1623
|
+
"social_daily_analysis_context",
|
|
1624
|
+
"social_search_live",
|
|
1625
|
+
"social_mentions_live",
|
|
1626
|
+
"social_thread_fetch",
|
|
1627
|
+
"social_posts_sync",
|
|
1628
|
+
"social_post_reply"
|
|
1593
1629
|
]
|
|
1594
1630
|
}
|
|
1595
1631
|
};
|