@inkeep/agents-core 0.46.1 → 0.47.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/dist/auth/auth-validation-schemas.d.ts +148 -148
- package/dist/auth/auth.d.ts +57 -57
- package/dist/auth/auth.js +1 -1
- package/dist/auth/authz/config.d.ts +1 -86
- package/dist/auth/authz/config.js +6 -72
- package/dist/auth/authz/index.d.ts +2 -1
- package/dist/auth/authz/index.js +2 -1
- package/dist/auth/authz/permissions.d.ts +1 -1
- package/dist/auth/authz/permissions.js +1 -1
- package/dist/auth/authz/sync.d.ts +1 -1
- package/dist/auth/authz/sync.js +1 -1
- package/dist/auth/authz/types.d.ts +92 -0
- package/dist/auth/authz/types.js +76 -0
- package/dist/auth/init.js +1 -1
- package/dist/auth/permissions.d.ts +13 -13
- package/dist/auth/spicedb-schema.js +2 -2
- package/dist/client-exports.d.ts +1 -1
- package/dist/client-exports.js +1 -1
- package/dist/data-access/manage/agents.d.ts +31 -31
- package/dist/data-access/manage/artifactComponents.d.ts +6 -6
- package/dist/data-access/manage/contextConfigs.d.ts +8 -8
- package/dist/data-access/manage/dataComponents.d.ts +2 -2
- package/dist/data-access/manage/functionTools.d.ts +8 -8
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +18 -18
- package/dist/data-access/manage/subAgentRelations.d.ts +18 -18
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +18 -18
- package/dist/data-access/manage/subAgents.d.ts +21 -21
- package/dist/data-access/manage/tools.d.ts +18 -18
- package/dist/data-access/manage/triggers.d.ts +2 -2
- package/dist/data-access/runtime/apiKeys.d.ts +12 -12
- package/dist/data-access/runtime/conversations.d.ts +20 -20
- package/dist/data-access/runtime/messages.d.ts +18 -18
- package/dist/data-access/runtime/tasks.d.ts +4 -4
- package/dist/db/manage/manage-schema.d.ts +306 -306
- package/dist/db/runtime/runtime-schema.d.ts +206 -206
- package/dist/env.d.ts +6 -0
- package/dist/env.js +4 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
- package/dist/validation/schemas.d.ts +1629 -1629
- package/package.json +1 -1
package/dist/auth/auth.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { AgentsRunDatabaseClient } from "../db/runtime/runtime-client.js";
|
|
|
2
2
|
import * as _better_auth_sso0 from "@better-auth/sso";
|
|
3
3
|
import * as better_auth0 from "better-auth";
|
|
4
4
|
import { BetterAuthAdvancedOptions } from "better-auth";
|
|
5
|
-
import * as
|
|
5
|
+
import * as better_auth_plugins20 from "better-auth/plugins";
|
|
6
6
|
import * as zod0 from "zod";
|
|
7
7
|
import { GoogleOptions } from "better-auth/social-providers";
|
|
8
8
|
|
|
@@ -247,7 +247,7 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
|
|
|
247
247
|
handler: (inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<void>;
|
|
248
248
|
}[];
|
|
249
249
|
};
|
|
250
|
-
options:
|
|
250
|
+
options: better_auth_plugins20.BearerOptions | undefined;
|
|
251
251
|
}, {
|
|
252
252
|
id: "sso";
|
|
253
253
|
endpoints: {
|
|
@@ -875,30 +875,30 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
|
|
|
875
875
|
};
|
|
876
876
|
}, {
|
|
877
877
|
id: "organization";
|
|
878
|
-
endpoints:
|
|
878
|
+
endpoints: better_auth_plugins20.OrganizationEndpoints<{
|
|
879
879
|
allowUserToCreateOrganization: true;
|
|
880
|
-
ac:
|
|
880
|
+
ac: better_auth_plugins20.AccessControl;
|
|
881
881
|
roles: {
|
|
882
882
|
member: {
|
|
883
|
-
authorize<K_1 extends "organization" | "member" | "invitation" | "
|
|
884
|
-
actions:
|
|
883
|
+
authorize<K_1 extends "organization" | "member" | "invitation" | "project" | "team" | "ac">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins20.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins20.Statements>[key] | {
|
|
884
|
+
actions: better_auth_plugins20.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins20.Statements>[key];
|
|
885
885
|
connector: "OR" | "AND";
|
|
886
|
-
} | undefined } : never, connector?: "OR" | "AND"):
|
|
887
|
-
statements:
|
|
886
|
+
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins20.AuthorizeResponse;
|
|
887
|
+
statements: better_auth_plugins20.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins20.Statements>;
|
|
888
888
|
};
|
|
889
889
|
admin: {
|
|
890
|
-
authorize<K_1 extends "organization" | "member" | "invitation" | "
|
|
891
|
-
actions:
|
|
890
|
+
authorize<K_1 extends "organization" | "member" | "invitation" | "project" | "team" | "ac">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins20.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins20.Statements>[key] | {
|
|
891
|
+
actions: better_auth_plugins20.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins20.Statements>[key];
|
|
892
892
|
connector: "OR" | "AND";
|
|
893
|
-
} | undefined } : never, connector?: "OR" | "AND"):
|
|
894
|
-
statements:
|
|
893
|
+
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins20.AuthorizeResponse;
|
|
894
|
+
statements: better_auth_plugins20.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins20.Statements>;
|
|
895
895
|
};
|
|
896
896
|
owner: {
|
|
897
|
-
authorize<K_1 extends "organization" | "member" | "invitation" | "
|
|
898
|
-
actions:
|
|
897
|
+
authorize<K_1 extends "organization" | "member" | "invitation" | "project" | "team" | "ac">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins20.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins20.Statements>[key] | {
|
|
898
|
+
actions: better_auth_plugins20.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins20.Statements>[key];
|
|
899
899
|
connector: "OR" | "AND";
|
|
900
|
-
} | undefined } : never, connector?: "OR" | "AND"):
|
|
901
|
-
statements:
|
|
900
|
+
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins20.AuthorizeResponse;
|
|
901
|
+
statements: better_auth_plugins20.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins20.Statements>;
|
|
902
902
|
};
|
|
903
903
|
};
|
|
904
904
|
creatorRole: "admin";
|
|
@@ -909,9 +909,9 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
|
|
|
909
909
|
id: string;
|
|
910
910
|
role: string;
|
|
911
911
|
email: string;
|
|
912
|
-
organization:
|
|
913
|
-
invitation:
|
|
914
|
-
inviter:
|
|
912
|
+
organization: better_auth_plugins20.Organization;
|
|
913
|
+
invitation: better_auth_plugins20.Invitation;
|
|
914
|
+
inviter: better_auth_plugins20.Member & {
|
|
915
915
|
user: better_auth0.User;
|
|
916
916
|
};
|
|
917
917
|
}): Promise<void>;
|
|
@@ -932,28 +932,28 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
|
|
|
932
932
|
user,
|
|
933
933
|
organization: org
|
|
934
934
|
}: {
|
|
935
|
-
invitation:
|
|
936
|
-
member:
|
|
935
|
+
invitation: better_auth_plugins20.Invitation & Record<string, any>;
|
|
936
|
+
member: better_auth_plugins20.Member & Record<string, any>;
|
|
937
937
|
user: better_auth0.User & Record<string, any>;
|
|
938
|
-
organization:
|
|
938
|
+
organization: better_auth_plugins20.Organization & Record<string, any>;
|
|
939
939
|
}) => Promise<void>;
|
|
940
940
|
beforeUpdateMemberRole: ({
|
|
941
941
|
member,
|
|
942
942
|
organization: org,
|
|
943
943
|
newRole
|
|
944
944
|
}: {
|
|
945
|
-
member:
|
|
945
|
+
member: better_auth_plugins20.Member & Record<string, any>;
|
|
946
946
|
newRole: string;
|
|
947
947
|
user: better_auth0.User & Record<string, any>;
|
|
948
|
-
organization:
|
|
948
|
+
organization: better_auth_plugins20.Organization & Record<string, any>;
|
|
949
949
|
}) => Promise<void>;
|
|
950
950
|
afterRemoveMember: ({
|
|
951
951
|
member,
|
|
952
952
|
organization: org
|
|
953
953
|
}: {
|
|
954
|
-
member:
|
|
954
|
+
member: better_auth_plugins20.Member & Record<string, any>;
|
|
955
955
|
user: better_auth0.User & Record<string, any>;
|
|
956
|
-
organization:
|
|
956
|
+
organization: better_auth_plugins20.Organization & Record<string, any>;
|
|
957
957
|
}) => Promise<void>;
|
|
958
958
|
};
|
|
959
959
|
}>;
|
|
@@ -1084,8 +1084,8 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
|
|
|
1084
1084
|
id: string;
|
|
1085
1085
|
organizationId: string;
|
|
1086
1086
|
email: string;
|
|
1087
|
-
role: "member" | "
|
|
1088
|
-
status:
|
|
1087
|
+
role: "member" | "owner" | "admin";
|
|
1088
|
+
status: better_auth_plugins20.InvitationStatus;
|
|
1089
1089
|
inviterId: string;
|
|
1090
1090
|
expiresAt: Date;
|
|
1091
1091
|
createdAt: Date;
|
|
@@ -1094,7 +1094,7 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
|
|
|
1094
1094
|
Member: {
|
|
1095
1095
|
id: string;
|
|
1096
1096
|
organizationId: string;
|
|
1097
|
-
role: "member" | "
|
|
1097
|
+
role: "member" | "owner" | "admin";
|
|
1098
1098
|
createdAt: Date;
|
|
1099
1099
|
userId: string;
|
|
1100
1100
|
user: {
|
|
@@ -1110,7 +1110,7 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
|
|
|
1110
1110
|
members: {
|
|
1111
1111
|
id: string;
|
|
1112
1112
|
organizationId: string;
|
|
1113
|
-
role: "member" | "
|
|
1113
|
+
role: "member" | "owner" | "admin";
|
|
1114
1114
|
createdAt: Date;
|
|
1115
1115
|
userId: string;
|
|
1116
1116
|
user: {
|
|
@@ -1124,8 +1124,8 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
|
|
|
1124
1124
|
id: string;
|
|
1125
1125
|
organizationId: string;
|
|
1126
1126
|
email: string;
|
|
1127
|
-
role: "member" | "
|
|
1128
|
-
status:
|
|
1127
|
+
role: "member" | "owner" | "admin";
|
|
1128
|
+
status: better_auth_plugins20.InvitationStatus;
|
|
1129
1129
|
inviterId: string;
|
|
1130
1130
|
expiresAt: Date;
|
|
1131
1131
|
createdAt: Date;
|
|
@@ -1200,28 +1200,28 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
|
|
|
1200
1200
|
};
|
|
1201
1201
|
options: NoInfer<{
|
|
1202
1202
|
allowUserToCreateOrganization: true;
|
|
1203
|
-
ac:
|
|
1203
|
+
ac: better_auth_plugins20.AccessControl;
|
|
1204
1204
|
roles: {
|
|
1205
1205
|
member: {
|
|
1206
|
-
authorize<K_1 extends "organization" | "member" | "invitation" | "
|
|
1207
|
-
actions:
|
|
1206
|
+
authorize<K_1 extends "organization" | "member" | "invitation" | "project" | "team" | "ac">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins20.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins20.Statements>[key] | {
|
|
1207
|
+
actions: better_auth_plugins20.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins20.Statements>[key];
|
|
1208
1208
|
connector: "OR" | "AND";
|
|
1209
|
-
} | undefined } : never, connector?: "OR" | "AND"):
|
|
1210
|
-
statements:
|
|
1209
|
+
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins20.AuthorizeResponse;
|
|
1210
|
+
statements: better_auth_plugins20.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins20.Statements>;
|
|
1211
1211
|
};
|
|
1212
1212
|
admin: {
|
|
1213
|
-
authorize<K_1 extends "organization" | "member" | "invitation" | "
|
|
1214
|
-
actions:
|
|
1213
|
+
authorize<K_1 extends "organization" | "member" | "invitation" | "project" | "team" | "ac">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins20.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins20.Statements>[key] | {
|
|
1214
|
+
actions: better_auth_plugins20.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins20.Statements>[key];
|
|
1215
1215
|
connector: "OR" | "AND";
|
|
1216
|
-
} | undefined } : never, connector?: "OR" | "AND"):
|
|
1217
|
-
statements:
|
|
1216
|
+
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins20.AuthorizeResponse;
|
|
1217
|
+
statements: better_auth_plugins20.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins20.Statements>;
|
|
1218
1218
|
};
|
|
1219
1219
|
owner: {
|
|
1220
|
-
authorize<K_1 extends "organization" | "member" | "invitation" | "
|
|
1221
|
-
actions:
|
|
1220
|
+
authorize<K_1 extends "organization" | "member" | "invitation" | "project" | "team" | "ac">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins20.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins20.Statements>[key] | {
|
|
1221
|
+
actions: better_auth_plugins20.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins20.Statements>[key];
|
|
1222
1222
|
connector: "OR" | "AND";
|
|
1223
|
-
} | undefined } : never, connector?: "OR" | "AND"):
|
|
1224
|
-
statements:
|
|
1223
|
+
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins20.AuthorizeResponse;
|
|
1224
|
+
statements: better_auth_plugins20.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins20.Statements>;
|
|
1225
1225
|
};
|
|
1226
1226
|
};
|
|
1227
1227
|
creatorRole: "admin";
|
|
@@ -1232,9 +1232,9 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
|
|
|
1232
1232
|
id: string;
|
|
1233
1233
|
role: string;
|
|
1234
1234
|
email: string;
|
|
1235
|
-
organization:
|
|
1236
|
-
invitation:
|
|
1237
|
-
inviter:
|
|
1235
|
+
organization: better_auth_plugins20.Organization;
|
|
1236
|
+
invitation: better_auth_plugins20.Invitation;
|
|
1237
|
+
inviter: better_auth_plugins20.Member & {
|
|
1238
1238
|
user: better_auth0.User;
|
|
1239
1239
|
};
|
|
1240
1240
|
}): Promise<void>;
|
|
@@ -1255,28 +1255,28 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
|
|
|
1255
1255
|
user,
|
|
1256
1256
|
organization: org
|
|
1257
1257
|
}: {
|
|
1258
|
-
invitation:
|
|
1259
|
-
member:
|
|
1258
|
+
invitation: better_auth_plugins20.Invitation & Record<string, any>;
|
|
1259
|
+
member: better_auth_plugins20.Member & Record<string, any>;
|
|
1260
1260
|
user: better_auth0.User & Record<string, any>;
|
|
1261
|
-
organization:
|
|
1261
|
+
organization: better_auth_plugins20.Organization & Record<string, any>;
|
|
1262
1262
|
}) => Promise<void>;
|
|
1263
1263
|
beforeUpdateMemberRole: ({
|
|
1264
1264
|
member,
|
|
1265
1265
|
organization: org,
|
|
1266
1266
|
newRole
|
|
1267
1267
|
}: {
|
|
1268
|
-
member:
|
|
1268
|
+
member: better_auth_plugins20.Member & Record<string, any>;
|
|
1269
1269
|
newRole: string;
|
|
1270
1270
|
user: better_auth0.User & Record<string, any>;
|
|
1271
|
-
organization:
|
|
1271
|
+
organization: better_auth_plugins20.Organization & Record<string, any>;
|
|
1272
1272
|
}) => Promise<void>;
|
|
1273
1273
|
afterRemoveMember: ({
|
|
1274
1274
|
member,
|
|
1275
1275
|
organization: org
|
|
1276
1276
|
}: {
|
|
1277
|
-
member:
|
|
1277
|
+
member: better_auth_plugins20.Member & Record<string, any>;
|
|
1278
1278
|
user: better_auth0.User & Record<string, any>;
|
|
1279
|
-
organization:
|
|
1279
|
+
organization: better_auth_plugins20.Organization & Record<string, any>;
|
|
1280
1280
|
}) => Promise<void>;
|
|
1281
1281
|
};
|
|
1282
1282
|
}>;
|
|
@@ -1613,8 +1613,8 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
|
|
|
1613
1613
|
readonly AUTHENTICATION_REQUIRED: "Authentication required";
|
|
1614
1614
|
};
|
|
1615
1615
|
options: Partial<{
|
|
1616
|
-
expiresIn:
|
|
1617
|
-
interval:
|
|
1616
|
+
expiresIn: better_auth_plugins20.TimeString;
|
|
1617
|
+
interval: better_auth_plugins20.TimeString;
|
|
1618
1618
|
deviceCodeLength: number;
|
|
1619
1619
|
userCodeLength: number;
|
|
1620
1620
|
schema: {
|
package/dist/auth/auth.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { member, ssoProvider } from "./auth-schema.js";
|
|
2
|
-
import { OrgRoles } from "./authz/
|
|
2
|
+
import { OrgRoles } from "./authz/types.js";
|
|
3
3
|
import { env } from "../env.js";
|
|
4
4
|
import { setPasswordResetLink } from "./password-reset-link-store.js";
|
|
5
5
|
import { generateId } from "../utils/conversations.js";
|
|
@@ -12,90 +12,5 @@ declare function getSpiceDbConfig(): {
|
|
|
12
12
|
token: string;
|
|
13
13
|
tlsEnabled: boolean;
|
|
14
14
|
};
|
|
15
|
-
/**
|
|
16
|
-
* SpiceDB resource types used in the schema
|
|
17
|
-
*/
|
|
18
|
-
declare const SpiceDbResourceTypes: {
|
|
19
|
-
readonly USER: "user";
|
|
20
|
-
readonly ORGANIZATION: "organization";
|
|
21
|
-
readonly PROJECT: "project";
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* SpiceDB relations used in the schema
|
|
25
|
-
*
|
|
26
|
-
* Relations are named as nouns (roles) per SpiceDB best practices.
|
|
27
|
-
* Project roles are prefixed for clarity when debugging/grepping.
|
|
28
|
-
*/
|
|
29
|
-
declare const SpiceDbRelations: {
|
|
30
|
-
readonly OWNER: "owner";
|
|
31
|
-
readonly ADMIN: "admin";
|
|
32
|
-
readonly MEMBER: "member";
|
|
33
|
-
readonly ORGANIZATION: "organization";
|
|
34
|
-
readonly PROJECT_ADMIN: "project_admin";
|
|
35
|
-
readonly PROJECT_MEMBER: "project_member";
|
|
36
|
-
readonly PROJECT_VIEWER: "project_viewer";
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* SpiceDB permissions for organization resources.
|
|
40
|
-
*
|
|
41
|
-
* From schema.zed definition organization:
|
|
42
|
-
* - view: owner + admin + member
|
|
43
|
-
* - manage: owner + admin (includes managing org settings and all projects)
|
|
44
|
-
*/
|
|
45
|
-
declare const SpiceDbOrgPermissions: {
|
|
46
|
-
readonly VIEW: "view";
|
|
47
|
-
readonly MANAGE: "manage";
|
|
48
|
-
};
|
|
49
|
-
type SpiceDbOrgPermission = (typeof SpiceDbOrgPermissions)[keyof typeof SpiceDbOrgPermissions];
|
|
50
|
-
/**
|
|
51
|
-
* SpiceDB permissions for project resources.
|
|
52
|
-
*
|
|
53
|
-
* From schema.zed definition project:
|
|
54
|
-
* - view: read-only access to project and its resources
|
|
55
|
-
* - use: invoke agents, create API keys, view traces
|
|
56
|
-
* - edit: modify configurations, manage members
|
|
57
|
-
*/
|
|
58
|
-
declare const SpiceDbProjectPermissions: {
|
|
59
|
-
readonly VIEW: "view";
|
|
60
|
-
readonly USE: "use";
|
|
61
|
-
readonly EDIT: "edit";
|
|
62
|
-
};
|
|
63
|
-
type SpiceDbProjectPermission = (typeof SpiceDbProjectPermissions)[keyof typeof SpiceDbProjectPermissions];
|
|
64
|
-
/**
|
|
65
|
-
* Permission levels for project access checks.
|
|
66
|
-
*/
|
|
67
|
-
type ProjectPermissionLevel = SpiceDbProjectPermission;
|
|
68
|
-
/**
|
|
69
|
-
* Organization roles from SpiceDB schema.
|
|
70
|
-
*/
|
|
71
|
-
declare const OrgRoles: {
|
|
72
|
-
readonly OWNER: "owner";
|
|
73
|
-
readonly ADMIN: "admin";
|
|
74
|
-
readonly MEMBER: "member";
|
|
75
|
-
};
|
|
76
|
-
type OrgRole = (typeof OrgRoles)[keyof typeof OrgRoles];
|
|
77
|
-
/**
|
|
78
|
-
* Project roles from SpiceDB schema.
|
|
79
|
-
*
|
|
80
|
-
* Hierarchy:
|
|
81
|
-
* - project_admin: Full access (view + use + edit + manage members)
|
|
82
|
-
* - project_member: Operator access (view + use: invoke agents, create API keys)
|
|
83
|
-
* - project_viewer: Read-only access (view only)
|
|
84
|
-
*/
|
|
85
|
-
declare const ProjectRoles: {
|
|
86
|
-
readonly ADMIN: "project_admin";
|
|
87
|
-
readonly MEMBER: "project_member";
|
|
88
|
-
readonly VIEWER: "project_viewer";
|
|
89
|
-
};
|
|
90
|
-
type ProjectRole = (typeof ProjectRoles)[keyof typeof ProjectRoles];
|
|
91
|
-
/**
|
|
92
|
-
* Project permission capabilities.
|
|
93
|
-
* Maps to the SpiceDB permission checks (view, use, edit).
|
|
94
|
-
*/
|
|
95
|
-
interface ProjectPermissions {
|
|
96
|
-
canView: boolean;
|
|
97
|
-
canUse: boolean;
|
|
98
|
-
canEdit: boolean;
|
|
99
|
-
}
|
|
100
15
|
//#endregion
|
|
101
|
-
export {
|
|
16
|
+
export { getSpiceDbConfig, isLocalhostEndpoint };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { env } from "../../env.js";
|
|
2
|
+
|
|
1
3
|
//#region src/auth/authz/config.ts
|
|
2
4
|
/**
|
|
3
5
|
* Check if a SpiceDB endpoint is localhost (used for TLS auto-detection).
|
|
@@ -10,81 +12,13 @@ function isLocalhostEndpoint(endpoint) {
|
|
|
10
12
|
* TLS is auto-detected: disabled for localhost, enabled for remote endpoints.
|
|
11
13
|
*/
|
|
12
14
|
function getSpiceDbConfig() {
|
|
13
|
-
const endpoint =
|
|
15
|
+
const endpoint = env.SPICEDB_ENDPOINT || "localhost:50051";
|
|
14
16
|
return {
|
|
15
17
|
endpoint,
|
|
16
|
-
token:
|
|
17
|
-
tlsEnabled: !isLocalhostEndpoint(endpoint)
|
|
18
|
+
token: env.SPICEDB_PRESHARED_KEY || "",
|
|
19
|
+
tlsEnabled: env.SPICEDB_TLS_ENABLED ?? !isLocalhostEndpoint(endpoint)
|
|
18
20
|
};
|
|
19
21
|
}
|
|
20
|
-
/**
|
|
21
|
-
* SpiceDB resource types used in the schema
|
|
22
|
-
*/
|
|
23
|
-
const SpiceDbResourceTypes = {
|
|
24
|
-
USER: "user",
|
|
25
|
-
ORGANIZATION: "organization",
|
|
26
|
-
PROJECT: "project"
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* SpiceDB relations used in the schema
|
|
30
|
-
*
|
|
31
|
-
* Relations are named as nouns (roles) per SpiceDB best practices.
|
|
32
|
-
* Project roles are prefixed for clarity when debugging/grepping.
|
|
33
|
-
*/
|
|
34
|
-
const SpiceDbRelations = {
|
|
35
|
-
OWNER: "owner",
|
|
36
|
-
ADMIN: "admin",
|
|
37
|
-
MEMBER: "member",
|
|
38
|
-
ORGANIZATION: "organization",
|
|
39
|
-
PROJECT_ADMIN: "project_admin",
|
|
40
|
-
PROJECT_MEMBER: "project_member",
|
|
41
|
-
PROJECT_VIEWER: "project_viewer"
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* SpiceDB permissions for organization resources.
|
|
45
|
-
*
|
|
46
|
-
* From schema.zed definition organization:
|
|
47
|
-
* - view: owner + admin + member
|
|
48
|
-
* - manage: owner + admin (includes managing org settings and all projects)
|
|
49
|
-
*/
|
|
50
|
-
const SpiceDbOrgPermissions = {
|
|
51
|
-
VIEW: "view",
|
|
52
|
-
MANAGE: "manage"
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* SpiceDB permissions for project resources.
|
|
56
|
-
*
|
|
57
|
-
* From schema.zed definition project:
|
|
58
|
-
* - view: read-only access to project and its resources
|
|
59
|
-
* - use: invoke agents, create API keys, view traces
|
|
60
|
-
* - edit: modify configurations, manage members
|
|
61
|
-
*/
|
|
62
|
-
const SpiceDbProjectPermissions = {
|
|
63
|
-
VIEW: "view",
|
|
64
|
-
USE: "use",
|
|
65
|
-
EDIT: "edit"
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Organization roles from SpiceDB schema.
|
|
69
|
-
*/
|
|
70
|
-
const OrgRoles = {
|
|
71
|
-
OWNER: "owner",
|
|
72
|
-
ADMIN: "admin",
|
|
73
|
-
MEMBER: "member"
|
|
74
|
-
};
|
|
75
|
-
/**
|
|
76
|
-
* Project roles from SpiceDB schema.
|
|
77
|
-
*
|
|
78
|
-
* Hierarchy:
|
|
79
|
-
* - project_admin: Full access (view + use + edit + manage members)
|
|
80
|
-
* - project_member: Operator access (view + use: invoke agents, create API keys)
|
|
81
|
-
* - project_viewer: Read-only access (view only)
|
|
82
|
-
*/
|
|
83
|
-
const ProjectRoles = {
|
|
84
|
-
ADMIN: "project_admin",
|
|
85
|
-
MEMBER: "project_member",
|
|
86
|
-
VIEWER: "project_viewer"
|
|
87
|
-
};
|
|
88
22
|
|
|
89
23
|
//#endregion
|
|
90
|
-
export {
|
|
24
|
+
export { getSpiceDbConfig, isLocalhostEndpoint };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { checkBulkPermissions, checkPermission, deleteRelationship, getSpiceClient, lookupResources, readRelationships, resetSpiceClient, writeRelationship } from "./client.js";
|
|
2
|
-
import {
|
|
2
|
+
import { getSpiceDbConfig } from "./config.js";
|
|
3
|
+
import { OrgRole, OrgRoles, ProjectPermissionLevel, ProjectPermissions, ProjectRole, ProjectRoles, SpiceDbOrgPermission, SpiceDbOrgPermissions, SpiceDbProjectPermission, SpiceDbProjectPermissions, SpiceDbRelations, SpiceDbResourceTypes } from "./types.js";
|
|
3
4
|
import { canEditProject, canUseProject, canUseProjectStrict, canViewProject, listAccessibleProjectIds, listUsableProjectIds } from "./permissions.js";
|
|
4
5
|
import { changeOrgRole, changeProjectRole, grantProjectAccess, listProjectMembers, listUserProjectMembershipsInSpiceDb, removeProjectFromSpiceDb, revokeAllProjectMemberships, revokeProjectAccess, syncOrgMemberToSpiceDb, syncProjectToSpiceDb } from "./sync.js";
|
|
5
6
|
export { type OrgRole, OrgRoles, type ProjectPermissionLevel, type ProjectPermissions, type ProjectRole, ProjectRoles, type SpiceDbOrgPermission, SpiceDbOrgPermissions, type SpiceDbProjectPermission, SpiceDbProjectPermissions, SpiceDbRelations, SpiceDbResourceTypes, canEditProject, canUseProject, canUseProjectStrict, canViewProject, changeOrgRole, changeProjectRole, checkBulkPermissions, checkPermission, deleteRelationship, getSpiceClient, getSpiceDbConfig, grantProjectAccess, listAccessibleProjectIds, listProjectMembers, listUsableProjectIds, listUserProjectMembershipsInSpiceDb, lookupResources, readRelationships, removeProjectFromSpiceDb, resetSpiceClient, revokeAllProjectMemberships, revokeProjectAccess, syncOrgMemberToSpiceDb, syncProjectToSpiceDb, writeRelationship };
|
package/dist/auth/authz/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { OrgRoles, ProjectRoles, SpiceDbOrgPermissions, SpiceDbProjectPermissions, SpiceDbRelations, SpiceDbResourceTypes
|
|
1
|
+
import { OrgRoles, ProjectRoles, SpiceDbOrgPermissions, SpiceDbProjectPermissions, SpiceDbRelations, SpiceDbResourceTypes } from "./types.js";
|
|
2
|
+
import { getSpiceDbConfig } from "./config.js";
|
|
2
3
|
import { checkBulkPermissions, checkPermission, deleteRelationship, getSpiceClient, lookupResources, readRelationships, resetSpiceClient, writeRelationship } from "./client.js";
|
|
3
4
|
import { canEditProject, canUseProject, canUseProjectStrict, canViewProject, listAccessibleProjectIds, listUsableProjectIds } from "./permissions.js";
|
|
4
5
|
import { changeOrgRole, changeProjectRole, grantProjectAccess, listProjectMembers, listUserProjectMembershipsInSpiceDb, removeProjectFromSpiceDb, revokeAllProjectMemberships, revokeProjectAccess, syncOrgMemberToSpiceDb, syncProjectToSpiceDb } from "./sync.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OrgRoles, SpiceDbProjectPermissions, SpiceDbResourceTypes } from "./
|
|
1
|
+
import { OrgRoles, SpiceDbProjectPermissions, SpiceDbResourceTypes } from "./types.js";
|
|
2
2
|
import { checkPermission, lookupResources } from "./client.js";
|
|
3
3
|
|
|
4
4
|
//#region src/auth/authz/permissions.ts
|
package/dist/auth/authz/sync.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SpiceDbRelations, SpiceDbResourceTypes } from "./
|
|
1
|
+
import { SpiceDbRelations, SpiceDbResourceTypes } from "./types.js";
|
|
2
2
|
import { RelationshipOperation, deleteRelationship, getSpiceClient, readRelationships, writeRelationship } from "./client.js";
|
|
3
3
|
|
|
4
4
|
//#region src/auth/authz/sync.ts
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
//#region src/auth/authz/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Client-safe authz types and constants.
|
|
4
|
+
* These can be safely imported in client-side code without any Node.js dependencies.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* SpiceDB resource types used in the schema
|
|
8
|
+
*/
|
|
9
|
+
declare const SpiceDbResourceTypes: {
|
|
10
|
+
readonly USER: "user";
|
|
11
|
+
readonly ORGANIZATION: "organization";
|
|
12
|
+
readonly PROJECT: "project";
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* SpiceDB relations used in the schema
|
|
16
|
+
*
|
|
17
|
+
* Relations are named as nouns (roles) per SpiceDB best practices.
|
|
18
|
+
* Project roles are prefixed for clarity when debugging/grepping.
|
|
19
|
+
*/
|
|
20
|
+
declare const SpiceDbRelations: {
|
|
21
|
+
readonly OWNER: "owner";
|
|
22
|
+
readonly ADMIN: "admin";
|
|
23
|
+
readonly MEMBER: "member";
|
|
24
|
+
readonly ORGANIZATION: "organization";
|
|
25
|
+
readonly PROJECT_ADMIN: "project_admin";
|
|
26
|
+
readonly PROJECT_MEMBER: "project_member";
|
|
27
|
+
readonly PROJECT_VIEWER: "project_viewer";
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* SpiceDB permissions for organization resources.
|
|
31
|
+
*
|
|
32
|
+
* From schema.zed definition organization:
|
|
33
|
+
* - view: owner + admin + member
|
|
34
|
+
* - manage: owner + admin (includes managing org settings and all projects)
|
|
35
|
+
*/
|
|
36
|
+
declare const SpiceDbOrgPermissions: {
|
|
37
|
+
readonly VIEW: "view";
|
|
38
|
+
readonly MANAGE: "manage";
|
|
39
|
+
};
|
|
40
|
+
type SpiceDbOrgPermission = (typeof SpiceDbOrgPermissions)[keyof typeof SpiceDbOrgPermissions];
|
|
41
|
+
/**
|
|
42
|
+
* SpiceDB permissions for project resources.
|
|
43
|
+
*
|
|
44
|
+
* From schema.zed definition project:
|
|
45
|
+
* - view: read-only access to project and its resources
|
|
46
|
+
* - use: invoke agents, create API keys, view traces
|
|
47
|
+
* - edit: modify configurations, manage members
|
|
48
|
+
*/
|
|
49
|
+
declare const SpiceDbProjectPermissions: {
|
|
50
|
+
readonly VIEW: "view";
|
|
51
|
+
readonly USE: "use";
|
|
52
|
+
readonly EDIT: "edit";
|
|
53
|
+
};
|
|
54
|
+
type SpiceDbProjectPermission = (typeof SpiceDbProjectPermissions)[keyof typeof SpiceDbProjectPermissions];
|
|
55
|
+
/**
|
|
56
|
+
* Permission levels for project access checks.
|
|
57
|
+
*/
|
|
58
|
+
type ProjectPermissionLevel = SpiceDbProjectPermission;
|
|
59
|
+
/**
|
|
60
|
+
* Organization roles from SpiceDB schema.
|
|
61
|
+
*/
|
|
62
|
+
declare const OrgRoles: {
|
|
63
|
+
readonly OWNER: "owner";
|
|
64
|
+
readonly ADMIN: "admin";
|
|
65
|
+
readonly MEMBER: "member";
|
|
66
|
+
};
|
|
67
|
+
type OrgRole = (typeof OrgRoles)[keyof typeof OrgRoles];
|
|
68
|
+
/**
|
|
69
|
+
* Project roles from SpiceDB schema.
|
|
70
|
+
*
|
|
71
|
+
* Hierarchy:
|
|
72
|
+
* - project_admin: Full access (view + use + edit + manage members)
|
|
73
|
+
* - project_member: Operator access (view + use: invoke agents, create API keys)
|
|
74
|
+
* - project_viewer: Read-only access (view only)
|
|
75
|
+
*/
|
|
76
|
+
declare const ProjectRoles: {
|
|
77
|
+
readonly ADMIN: "project_admin";
|
|
78
|
+
readonly MEMBER: "project_member";
|
|
79
|
+
readonly VIEWER: "project_viewer";
|
|
80
|
+
};
|
|
81
|
+
type ProjectRole = (typeof ProjectRoles)[keyof typeof ProjectRoles];
|
|
82
|
+
/**
|
|
83
|
+
* Project permission capabilities.
|
|
84
|
+
* Maps to the SpiceDB permission checks (view, use, edit).
|
|
85
|
+
*/
|
|
86
|
+
interface ProjectPermissions {
|
|
87
|
+
canView: boolean;
|
|
88
|
+
canUse: boolean;
|
|
89
|
+
canEdit: boolean;
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
export { OrgRole, OrgRoles, ProjectPermissionLevel, ProjectPermissions, ProjectRole, ProjectRoles, SpiceDbOrgPermission, SpiceDbOrgPermissions, SpiceDbProjectPermission, SpiceDbProjectPermissions, SpiceDbRelations, SpiceDbResourceTypes };
|