@inkeep/agents-core 0.41.1 → 0.42.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/api-client/base-client.d.ts +87 -8
- package/dist/api-client/base-client.js +174 -1
- package/dist/api-client/eval-api-client.d.ts +47 -0
- package/dist/api-client/eval-api-client.js +65 -0
- package/dist/api-client/index.d.ts +4 -0
- package/dist/api-client/index.js +5 -0
- package/dist/api-client/manage-api-client.d.ts +34 -0
- package/dist/api-client/manage-api-client.js +104 -0
- package/dist/auth/auth-schema.d.ts +104 -104
- package/dist/auth/auth-validation-schemas.d.ts +146 -146
- package/dist/auth/auth.d.ts +114 -20
- package/dist/auth/auth.js +72 -2
- package/dist/auth/authz/client.d.ts +81 -0
- package/dist/auth/authz/client.js +189 -0
- package/dist/auth/authz/config.d.ts +76 -0
- package/dist/auth/authz/config.js +76 -0
- package/dist/auth/authz/index.d.ts +5 -0
- package/dist/auth/authz/index.js +6 -0
- package/dist/auth/authz/permissions.d.ts +57 -0
- package/dist/auth/authz/permissions.js +83 -0
- package/dist/auth/authz/sync.d.ts +85 -0
- package/dist/auth/authz/sync.js +237 -0
- package/dist/auth/permissions.d.ts +13 -13
- package/dist/auth/permissions.js +2 -181
- package/dist/client-exports.d.ts +8 -3
- package/dist/client-exports.js +3 -2
- package/dist/constants/context-breakdown.d.ts +61 -0
- package/dist/constants/context-breakdown.js +124 -0
- package/dist/constants/otel-attributes.d.ts +4 -0
- package/dist/constants/otel-attributes.js +4 -0
- package/dist/context/ContextConfig.d.ts +2 -2
- package/dist/context/ContextConfig.js +3 -3
- package/dist/context/TemplateEngine.js +0 -1
- package/dist/context/index.d.ts +1 -5
- package/dist/context/index.js +1 -5
- package/dist/credential-stuffer/CredentialStuffer.d.ts +1 -1
- package/dist/data-access/index.d.ts +34 -26
- package/dist/data-access/index.js +34 -26
- package/dist/data-access/manage/agentFull.d.ts +36 -0
- package/dist/data-access/{agentFull.js → manage/agentFull.js} +205 -7
- package/dist/data-access/{agents.d.ts → manage/agents.d.ts} +44 -43
- package/dist/data-access/{agents.js → manage/agents.js} +52 -7
- package/dist/data-access/{artifactComponents.d.ts → manage/artifactComponents.d.ts} +31 -31
- package/dist/data-access/{artifactComponents.js → manage/artifactComponents.js} +5 -5
- package/dist/data-access/{contextConfigs.d.ts → manage/contextConfigs.d.ts} +26 -26
- package/dist/data-access/{contextConfigs.js → manage/contextConfigs.js} +3 -3
- package/dist/data-access/{credentialReferences.d.ts → manage/credentialReferences.d.ts} +17 -17
- package/dist/data-access/{credentialReferences.js → manage/credentialReferences.js} +2 -2
- package/dist/data-access/{dataComponents.d.ts → manage/dataComponents.d.ts} +24 -24
- package/dist/data-access/{dataComponents.js → manage/dataComponents.js} +7 -7
- package/dist/data-access/manage/evalConfig.d.ts +221 -0
- package/dist/data-access/manage/evalConfig.js +275 -0
- package/dist/data-access/{externalAgents.d.ts → manage/externalAgents.d.ts} +16 -16
- package/dist/data-access/{externalAgents.js → manage/externalAgents.js} +2 -2
- package/dist/data-access/{functionTools.d.ts → manage/functionTools.d.ts} +73 -23
- package/dist/data-access/{functionTools.js → manage/functionTools.js} +90 -8
- package/dist/data-access/{functions.d.ts → manage/functions.d.ts} +9 -9
- package/dist/data-access/{functions.js → manage/functions.js} +3 -3
- package/dist/data-access/manage/projectFull.d.ts +38 -0
- package/dist/data-access/{projectFull.js → manage/projectFull.js} +64 -65
- package/dist/data-access/manage/projectLifecycle.d.ts +119 -0
- package/dist/data-access/manage/projectLifecycle.js +234 -0
- package/dist/data-access/manage/projects.d.ts +75 -0
- package/dist/data-access/{projects.js → manage/projects.js} +15 -16
- package/dist/data-access/{subAgentExternalAgentRelations.d.ts → manage/subAgentExternalAgentRelations.d.ts} +43 -43
- package/dist/data-access/{subAgentExternalAgentRelations.js → manage/subAgentExternalAgentRelations.js} +2 -2
- package/dist/data-access/{subAgentRelations.d.ts → manage/subAgentRelations.d.ts} +57 -57
- package/dist/data-access/{subAgentRelations.js → manage/subAgentRelations.js} +3 -3
- package/dist/data-access/{subAgentTeamAgentRelations.d.ts → manage/subAgentTeamAgentRelations.d.ts} +43 -43
- package/dist/data-access/{subAgentTeamAgentRelations.js → manage/subAgentTeamAgentRelations.js} +2 -2
- package/dist/data-access/{subAgents.d.ts → manage/subAgents.d.ts} +28 -28
- package/dist/data-access/{subAgents.js → manage/subAgents.js} +4 -4
- package/dist/data-access/{tools.d.ts → manage/tools.d.ts} +59 -52
- package/dist/data-access/{tools.js → manage/tools.js} +57 -35
- package/dist/data-access/manage/triggers.d.ts +80 -0
- package/dist/data-access/manage/triggers.js +81 -0
- package/dist/data-access/{apiKeys.d.ts → runtime/apiKeys.d.ts} +32 -32
- package/dist/data-access/{apiKeys.js → runtime/apiKeys.js} +3 -3
- package/dist/data-access/runtime/cascade-delete.d.ts +77 -0
- package/dist/data-access/runtime/cascade-delete.js +111 -0
- package/dist/data-access/{contextCache.d.ts → runtime/contextCache.d.ts} +13 -13
- package/dist/data-access/{contextCache.js → runtime/contextCache.js} +5 -5
- package/dist/data-access/{conversations.d.ts → runtime/conversations.d.ts} +84 -35
- package/dist/data-access/{conversations.js → runtime/conversations.js} +13 -7
- package/dist/data-access/runtime/evalRuns.d.ts +120 -0
- package/dist/data-access/runtime/evalRuns.js +168 -0
- package/dist/data-access/{ledgerArtifacts.d.ts → runtime/ledgerArtifacts.d.ts} +13 -13
- package/dist/data-access/{ledgerArtifacts.js → runtime/ledgerArtifacts.js} +3 -3
- package/dist/data-access/{messages.d.ts → runtime/messages.d.ts} +27 -27
- package/dist/data-access/{messages.js → runtime/messages.js} +2 -2
- package/dist/data-access/{organizations.d.ts → runtime/organizations.d.ts} +16 -7
- package/dist/data-access/{organizations.js → runtime/organizations.js} +15 -3
- package/dist/data-access/runtime/projects.d.ts +62 -0
- package/dist/data-access/runtime/projects.js +90 -0
- package/dist/data-access/runtime/tasks.d.ts +55 -0
- package/dist/data-access/{tasks.js → runtime/tasks.js} +2 -2
- package/dist/data-access/runtime/triggerInvocations.d.ts +62 -0
- package/dist/data-access/runtime/triggerInvocations.js +54 -0
- package/dist/data-access/runtime/users.d.ts +19 -0
- package/dist/data-access/{users.js → runtime/users.js} +2 -2
- package/dist/data-access/validation.d.ts +4 -4
- package/dist/data-access/validation.js +1 -1
- package/dist/db/clean.d.ts +8 -4
- package/dist/db/clean.js +14 -105
- package/dist/db/delete.d.ts +1 -1
- package/dist/db/delete.js +7 -10
- package/dist/db/manage/dolt-cleanup.d.ts +51 -0
- package/dist/db/manage/dolt-cleanup.js +132 -0
- package/dist/db/manage/manage-client.d.ts +26 -0
- package/dist/db/manage/manage-client.js +68 -0
- package/dist/db/{schema.d.ts → manage/manage-schema.d.ts} +1459 -1285
- package/dist/db/{schema.js → manage/manage-schema.js} +433 -341
- package/dist/db/manage/test-manage-client.d.ts +27 -0
- package/dist/db/manage/test-manage-client.js +68 -0
- package/dist/db/runtime/runtime-client.d.ts +20 -0
- package/dist/db/runtime/runtime-client.js +30 -0
- package/dist/db/runtime/runtime-schema.d.ts +2834 -0
- package/dist/db/runtime/runtime-schema.js +483 -0
- package/dist/db/runtime/test-runtime-client.d.ts +27 -0
- package/dist/db/{test-client.js → runtime/test-runtime-client.js} +11 -25
- package/dist/dolt/branch.d.ts +62 -0
- package/dist/dolt/branch.js +82 -0
- package/dist/dolt/branches-api.d.ts +108 -0
- package/dist/dolt/branches-api.js +162 -0
- package/dist/dolt/commit.d.ts +94 -0
- package/dist/dolt/commit.js +103 -0
- package/dist/dolt/diff.d.ts +27 -0
- package/dist/dolt/diff.js +21 -0
- package/dist/dolt/index.d.ts +10 -0
- package/dist/dolt/index.js +11 -0
- package/dist/dolt/merge.d.ts +63 -0
- package/dist/dolt/merge.js +81 -0
- package/dist/dolt/migrate-all-branches.d.ts +4 -0
- package/dist/dolt/migrate-all-branches.js +78 -0
- package/dist/dolt/migrate-dolt.d.ts +1 -0
- package/dist/dolt/migrate-dolt.js +22 -0
- package/dist/dolt/ref-helpers.d.ts +19 -0
- package/dist/dolt/ref-helpers.js +65 -0
- package/dist/dolt/ref-middleware.d.ts +82 -0
- package/dist/dolt/ref-middleware.js +217 -0
- package/dist/dolt/ref-scope.d.ts +101 -0
- package/dist/dolt/ref-scope.js +231 -0
- package/dist/dolt/schema-sync.d.ts +134 -0
- package/dist/dolt/schema-sync.js +246 -0
- package/dist/env.d.ts +6 -4
- package/dist/env.js +3 -2
- package/dist/index.d.ts +71 -44
- package/dist/index.js +74 -47
- package/dist/types/entities.d.ts +81 -2
- package/dist/types/index.d.ts +3 -3
- package/dist/types/utility.d.ts +45 -4
- package/dist/utils/JsonTransformer.d.ts +44 -0
- package/dist/utils/JsonTransformer.js +112 -0
- package/dist/utils/apiKeys.d.ts +5 -1
- package/dist/utils/apiKeys.js +11 -1
- package/dist/utils/colors.d.ts +34 -0
- package/dist/utils/colors.js +49 -0
- package/dist/utils/credential-store-utils.d.ts +1 -1
- package/dist/utils/format-messages.d.ts +1 -1
- package/dist/utils/index.d.ts +7 -3
- package/dist/utils/index.js +7 -3
- package/dist/utils/internal-service-auth.d.ts +79 -0
- package/dist/utils/internal-service-auth.js +140 -0
- package/dist/utils/jwt-helpers.d.ts +56 -0
- package/dist/utils/jwt-helpers.js +90 -0
- package/dist/utils/service-token-auth.d.ts +9 -27
- package/dist/utils/service-token-auth.js +48 -96
- package/dist/utils/template-interpolation.d.ts +22 -0
- package/dist/utils/template-interpolation.js +62 -0
- package/dist/utils/third-party-mcp-servers/composio-client.js +23 -23
- package/dist/utils/trigger-auth.d.ts +62 -0
- package/dist/utils/trigger-auth.js +125 -0
- package/dist/validation/agentFull.js +2 -4
- package/dist/validation/dolt-schemas.d.ts +49 -0
- package/dist/validation/dolt-schemas.js +44 -0
- package/dist/validation/drizzle-schema-helpers.d.ts +4 -26
- package/dist/validation/drizzle-schema-helpers.js +5 -151
- package/dist/validation/index.d.ts +4 -3
- package/dist/validation/index.js +3 -2
- package/dist/validation/schemas.d.ts +17867 -5009
- package/dist/validation/schemas.js +328 -11
- package/drizzle/manage/0000_tearful_rhodey.sql +414 -0
- package/drizzle/manage/0001_broken_wendell_vaughn.sql +19 -0
- package/drizzle/manage/0002_bent_sunfire.sql +1 -0
- package/drizzle/manage/meta/0000_snapshot.json +2987 -0
- package/drizzle/manage/meta/0001_snapshot.json +3115 -0
- package/drizzle/manage/meta/0002_snapshot.json +3115 -0
- package/drizzle/manage/meta/_journal.json +27 -0
- package/drizzle/runtime/0008_silly_preak.sql +127 -0
- package/drizzle/runtime/0009_freezing_leo.sql +17 -0
- package/drizzle/runtime/meta/0008_snapshot.json +2263 -0
- package/drizzle/runtime/meta/0009_snapshot.json +2397 -0
- package/drizzle/{meta → runtime/meta}/_journal.json +14 -0
- package/package.json +49 -15
- package/dist/context/ContextFetcher.d.ts +0 -73
- package/dist/context/ContextFetcher.js +0 -291
- package/dist/context/ContextResolver.d.ts +0 -60
- package/dist/context/ContextResolver.js +0 -278
- package/dist/context/context.d.ts +0 -27
- package/dist/context/context.js +0 -128
- package/dist/context/contextCache.d.ts +0 -58
- package/dist/context/contextCache.js +0 -177
- package/dist/data-access/agentFull.d.ts +0 -33
- package/dist/data-access/projectFull.d.ts +0 -32
- package/dist/data-access/projects.d.ts +0 -71
- package/dist/data-access/tasks.d.ts +0 -45
- package/dist/data-access/users.d.ts +0 -19
- package/dist/db/client.d.ts +0 -20
- package/dist/db/client.js +0 -28
- package/dist/db/test-client.d.ts +0 -31
- package/dist/middleware/contextValidation.d.ts +0 -46
- package/dist/middleware/contextValidation.js +0 -280
- package/dist/middleware/index.d.ts +0 -2
- package/dist/middleware/index.js +0 -3
- package/dist/utils/execution.d.ts +0 -22
- package/dist/utils/execution.js +0 -25
- /package/drizzle/{0000_exotic_mysterio.sql → runtime/0000_exotic_mysterio.sql} +0 -0
- /package/drizzle/{0001_calm_sheva_callister.sql → runtime/0001_calm_sheva_callister.sql} +0 -0
- /package/drizzle/{0002_puzzling_goblin_queen.sql → runtime/0002_puzzling_goblin_queen.sql} +0 -0
- /package/drizzle/{0003_sweet_human_robot.sql → runtime/0003_sweet_human_robot.sql} +0 -0
- /package/drizzle/{0004_cuddly_shooting_star.sql → runtime/0004_cuddly_shooting_star.sql} +0 -0
- /package/drizzle/{0005_reflective_starfox.sql → runtime/0005_reflective_starfox.sql} +0 -0
- /package/drizzle/{0006_stale_thaddeus_ross.sql → runtime/0006_stale_thaddeus_ross.sql} +0 -0
- /package/drizzle/{0007_slim_karma.sql → runtime/0007_slim_karma.sql} +0 -0
- /package/drizzle/{meta → runtime/meta}/0000_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0001_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0003_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0005_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0006_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0007_snapshot.json +0 -0
package/dist/auth/auth.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
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";
|
|
@@ -56,7 +56,7 @@ interface SSOProviderConfig {
|
|
|
56
56
|
interface BetterAuthConfig {
|
|
57
57
|
baseURL: string;
|
|
58
58
|
secret: string;
|
|
59
|
-
dbClient:
|
|
59
|
+
dbClient: AgentsRunDatabaseClient;
|
|
60
60
|
ssoProviders?: SSOProviderConfig[];
|
|
61
61
|
socialProviders?: {
|
|
62
62
|
google?: GoogleOptions;
|
|
@@ -81,6 +81,40 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
|
|
|
81
81
|
requireEmailVerification: false;
|
|
82
82
|
autoSignIn: true;
|
|
83
83
|
};
|
|
84
|
+
account: {
|
|
85
|
+
accountLinking: {
|
|
86
|
+
enabled: true;
|
|
87
|
+
trustedProviders: ("google" | "email-password" | "auth0")[];
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
databaseHooks: {
|
|
91
|
+
session: {
|
|
92
|
+
create: {
|
|
93
|
+
before: (session: {
|
|
94
|
+
id: string;
|
|
95
|
+
createdAt: Date;
|
|
96
|
+
updatedAt: Date;
|
|
97
|
+
userId: string;
|
|
98
|
+
expiresAt: Date;
|
|
99
|
+
token: string;
|
|
100
|
+
ipAddress?: string | null | undefined;
|
|
101
|
+
userAgent?: string | null | undefined;
|
|
102
|
+
} & Record<string, unknown>) => Promise<{
|
|
103
|
+
data: {
|
|
104
|
+
activeOrganizationId: string | null;
|
|
105
|
+
id: string;
|
|
106
|
+
createdAt: Date;
|
|
107
|
+
updatedAt: Date;
|
|
108
|
+
userId: string;
|
|
109
|
+
expiresAt: Date;
|
|
110
|
+
token: string;
|
|
111
|
+
ipAddress?: string | null | undefined;
|
|
112
|
+
userAgent?: string | null | undefined;
|
|
113
|
+
};
|
|
114
|
+
}>;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
};
|
|
84
118
|
socialProviders: {
|
|
85
119
|
google: {
|
|
86
120
|
redirectURI?: string | undefined;
|
|
@@ -818,25 +852,25 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
|
|
|
818
852
|
ac: better_auth_plugins0.AccessControl;
|
|
819
853
|
roles: {
|
|
820
854
|
member: {
|
|
821
|
-
authorize<K_1 extends "
|
|
822
|
-
actions: better_auth_plugins0.Subset<"
|
|
855
|
+
authorize<K_1 extends "organization" | "ac" | "member" | "project" | "team" | "invitation">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key] | {
|
|
856
|
+
actions: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key];
|
|
823
857
|
connector: "OR" | "AND";
|
|
824
858
|
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
|
|
825
|
-
statements: better_auth_plugins0.Subset<"
|
|
859
|
+
statements: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>;
|
|
826
860
|
};
|
|
827
861
|
admin: {
|
|
828
|
-
authorize<K_1 extends "
|
|
829
|
-
actions: better_auth_plugins0.Subset<"
|
|
862
|
+
authorize<K_1 extends "organization" | "ac" | "member" | "project" | "team" | "invitation">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key] | {
|
|
863
|
+
actions: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key];
|
|
830
864
|
connector: "OR" | "AND";
|
|
831
865
|
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
|
|
832
|
-
statements: better_auth_plugins0.Subset<"
|
|
866
|
+
statements: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>;
|
|
833
867
|
};
|
|
834
868
|
owner: {
|
|
835
|
-
authorize<K_1 extends "
|
|
836
|
-
actions: better_auth_plugins0.Subset<"
|
|
869
|
+
authorize<K_1 extends "organization" | "ac" | "member" | "project" | "team" | "invitation">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key] | {
|
|
870
|
+
actions: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key];
|
|
837
871
|
connector: "OR" | "AND";
|
|
838
872
|
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
|
|
839
|
-
statements: better_auth_plugins0.Subset<"
|
|
873
|
+
statements: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>;
|
|
840
874
|
};
|
|
841
875
|
};
|
|
842
876
|
membershipLimit: number;
|
|
@@ -852,6 +886,36 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
|
|
|
852
886
|
user: better_auth0.User;
|
|
853
887
|
};
|
|
854
888
|
}): Promise<void>;
|
|
889
|
+
organizationHooks: {
|
|
890
|
+
afterAcceptInvitation: ({
|
|
891
|
+
member,
|
|
892
|
+
user,
|
|
893
|
+
organization: org
|
|
894
|
+
}: {
|
|
895
|
+
invitation: better_auth_plugins0.Invitation & Record<string, any>;
|
|
896
|
+
member: better_auth_plugins0.Member & Record<string, any>;
|
|
897
|
+
user: better_auth0.User & Record<string, any>;
|
|
898
|
+
organization: better_auth_plugins0.Organization & Record<string, any>;
|
|
899
|
+
}) => Promise<void>;
|
|
900
|
+
afterUpdateMemberRole: ({
|
|
901
|
+
member,
|
|
902
|
+
organization: org,
|
|
903
|
+
previousRole
|
|
904
|
+
}: {
|
|
905
|
+
member: better_auth_plugins0.Member & Record<string, any>;
|
|
906
|
+
previousRole: string;
|
|
907
|
+
user: better_auth0.User & Record<string, any>;
|
|
908
|
+
organization: better_auth_plugins0.Organization & Record<string, any>;
|
|
909
|
+
}) => Promise<void>;
|
|
910
|
+
afterRemoveMember: ({
|
|
911
|
+
member,
|
|
912
|
+
organization: org
|
|
913
|
+
}: {
|
|
914
|
+
member: better_auth_plugins0.Member & Record<string, any>;
|
|
915
|
+
user: better_auth0.User & Record<string, any>;
|
|
916
|
+
organization: better_auth_plugins0.Organization & Record<string, any>;
|
|
917
|
+
}) => Promise<void>;
|
|
918
|
+
};
|
|
855
919
|
}>;
|
|
856
920
|
schema: {
|
|
857
921
|
organization: {
|
|
@@ -1097,25 +1161,25 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
|
|
|
1097
1161
|
ac: better_auth_plugins0.AccessControl;
|
|
1098
1162
|
roles: {
|
|
1099
1163
|
member: {
|
|
1100
|
-
authorize<K_1 extends "
|
|
1101
|
-
actions: better_auth_plugins0.Subset<"
|
|
1164
|
+
authorize<K_1 extends "organization" | "ac" | "member" | "project" | "team" | "invitation">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key] | {
|
|
1165
|
+
actions: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key];
|
|
1102
1166
|
connector: "OR" | "AND";
|
|
1103
1167
|
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
|
|
1104
|
-
statements: better_auth_plugins0.Subset<"
|
|
1168
|
+
statements: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>;
|
|
1105
1169
|
};
|
|
1106
1170
|
admin: {
|
|
1107
|
-
authorize<K_1 extends "
|
|
1108
|
-
actions: better_auth_plugins0.Subset<"
|
|
1171
|
+
authorize<K_1 extends "organization" | "ac" | "member" | "project" | "team" | "invitation">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key] | {
|
|
1172
|
+
actions: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key];
|
|
1109
1173
|
connector: "OR" | "AND";
|
|
1110
1174
|
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
|
|
1111
|
-
statements: better_auth_plugins0.Subset<"
|
|
1175
|
+
statements: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>;
|
|
1112
1176
|
};
|
|
1113
1177
|
owner: {
|
|
1114
|
-
authorize<K_1 extends "
|
|
1115
|
-
actions: better_auth_plugins0.Subset<"
|
|
1178
|
+
authorize<K_1 extends "organization" | "ac" | "member" | "project" | "team" | "invitation">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key] | {
|
|
1179
|
+
actions: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key];
|
|
1116
1180
|
connector: "OR" | "AND";
|
|
1117
1181
|
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
|
|
1118
|
-
statements: better_auth_plugins0.Subset<"
|
|
1182
|
+
statements: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>;
|
|
1119
1183
|
};
|
|
1120
1184
|
};
|
|
1121
1185
|
membershipLimit: number;
|
|
@@ -1131,6 +1195,36 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
|
|
|
1131
1195
|
user: better_auth0.User;
|
|
1132
1196
|
};
|
|
1133
1197
|
}): Promise<void>;
|
|
1198
|
+
organizationHooks: {
|
|
1199
|
+
afterAcceptInvitation: ({
|
|
1200
|
+
member,
|
|
1201
|
+
user,
|
|
1202
|
+
organization: org
|
|
1203
|
+
}: {
|
|
1204
|
+
invitation: better_auth_plugins0.Invitation & Record<string, any>;
|
|
1205
|
+
member: better_auth_plugins0.Member & Record<string, any>;
|
|
1206
|
+
user: better_auth0.User & Record<string, any>;
|
|
1207
|
+
organization: better_auth_plugins0.Organization & Record<string, any>;
|
|
1208
|
+
}) => Promise<void>;
|
|
1209
|
+
afterUpdateMemberRole: ({
|
|
1210
|
+
member,
|
|
1211
|
+
organization: org,
|
|
1212
|
+
previousRole
|
|
1213
|
+
}: {
|
|
1214
|
+
member: better_auth_plugins0.Member & Record<string, any>;
|
|
1215
|
+
previousRole: string;
|
|
1216
|
+
user: better_auth0.User & Record<string, any>;
|
|
1217
|
+
organization: better_auth_plugins0.Organization & Record<string, any>;
|
|
1218
|
+
}) => Promise<void>;
|
|
1219
|
+
afterRemoveMember: ({
|
|
1220
|
+
member,
|
|
1221
|
+
organization: org
|
|
1222
|
+
}: {
|
|
1223
|
+
member: better_auth_plugins0.Member & Record<string, any>;
|
|
1224
|
+
user: better_auth0.User & Record<string, any>;
|
|
1225
|
+
organization: better_auth_plugins0.Organization & Record<string, any>;
|
|
1226
|
+
}) => Promise<void>;
|
|
1227
|
+
};
|
|
1134
1228
|
}>;
|
|
1135
1229
|
}, {
|
|
1136
1230
|
id: "device-authorization";
|
package/dist/auth/auth.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ssoProvider } from "./auth-schema.js";
|
|
1
|
+
import { member, ssoProvider } from "./auth-schema.js";
|
|
2
2
|
import { env } from "../env.js";
|
|
3
3
|
import { generateId } from "../utils/conversations.js";
|
|
4
4
|
import "../utils/index.js";
|
|
@@ -11,6 +11,15 @@ import { bearer, deviceAuthorization, oAuthProxy, organization } from "better-au
|
|
|
11
11
|
|
|
12
12
|
//#region src/auth/auth.ts
|
|
13
13
|
/**
|
|
14
|
+
* Get the user's initial organization for a new session.
|
|
15
|
+
* Returns the oldest organization the user is a member of.
|
|
16
|
+
* See: https://www.better-auth.com/docs/plugins/organization#active-organization
|
|
17
|
+
*/
|
|
18
|
+
async function getInitialOrganization(dbClient, userId) {
|
|
19
|
+
const [membership] = await dbClient.select({ organizationId: member.organizationId }).from(member).where(eq(member.userId, userId)).orderBy(member.createdAt).limit(1);
|
|
20
|
+
return membership ? { id: membership.organizationId } : null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
14
23
|
* Extracts the root domain from a URL for cross-subdomain cookie sharing.
|
|
15
24
|
* For example:
|
|
16
25
|
* - https://manage-api.pilot.inkeep.com -> .pilot.inkeep.com
|
|
@@ -67,6 +76,21 @@ function createAuth(config) {
|
|
|
67
76
|
requireEmailVerification: false,
|
|
68
77
|
autoSignIn: true
|
|
69
78
|
},
|
|
79
|
+
account: { accountLinking: {
|
|
80
|
+
enabled: true,
|
|
81
|
+
trustedProviders: [
|
|
82
|
+
"auth0",
|
|
83
|
+
"google",
|
|
84
|
+
"email-password"
|
|
85
|
+
]
|
|
86
|
+
} },
|
|
87
|
+
databaseHooks: { session: { create: { before: async (session) => {
|
|
88
|
+
const organization$1 = await getInitialOrganization(config.dbClient, session.userId);
|
|
89
|
+
return { data: {
|
|
90
|
+
...session,
|
|
91
|
+
activeOrganizationId: organization$1?.id ?? null
|
|
92
|
+
} };
|
|
93
|
+
} } } },
|
|
70
94
|
socialProviders: config.socialProviders?.google && { google: {
|
|
71
95
|
...config.socialProviders.google,
|
|
72
96
|
...env.OAUTH_PROXY_PRODUCTION_URL && { redirectURI: `${env.OAUTH_PROXY_PRODUCTION_URL}/api/auth/callback/google` }
|
|
@@ -98,7 +122,7 @@ function createAuth(config) {
|
|
|
98
122
|
"http://localhost:3000",
|
|
99
123
|
"http://localhost:3002",
|
|
100
124
|
env.INKEEP_AGENTS_MANAGE_UI_URL,
|
|
101
|
-
env.
|
|
125
|
+
env.INKEEP_AGENTS_API_URL,
|
|
102
126
|
env.TRUSTED_ORIGIN
|
|
103
127
|
].filter((origin) => typeof origin === "string" && origin.length > 0),
|
|
104
128
|
plugins: [
|
|
@@ -123,6 +147,52 @@ function createAuth(config) {
|
|
|
123
147
|
organization: data.organization.name,
|
|
124
148
|
invitationId: data.id
|
|
125
149
|
});
|
|
150
|
+
},
|
|
151
|
+
organizationHooks: {
|
|
152
|
+
afterAcceptInvitation: async ({ member: member$1, user, organization: org }) => {
|
|
153
|
+
try {
|
|
154
|
+
const { syncOrgMemberToSpiceDb } = await import("./authz/sync.js");
|
|
155
|
+
await syncOrgMemberToSpiceDb({
|
|
156
|
+
tenantId: org.id,
|
|
157
|
+
userId: user.id,
|
|
158
|
+
role: member$1.role,
|
|
159
|
+
action: "add"
|
|
160
|
+
});
|
|
161
|
+
console.log(`🔐 SpiceDB: Synced member ${user.email} as ${member$1.role} to org ${org.name}`);
|
|
162
|
+
} catch (error) {
|
|
163
|
+
console.error("❌ SpiceDB sync failed for new member:", error);
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
afterUpdateMemberRole: async ({ member: member$1, organization: org, previousRole }) => {
|
|
167
|
+
try {
|
|
168
|
+
const { changeOrgRole } = await import("./authz/sync.js");
|
|
169
|
+
const oldRole = previousRole;
|
|
170
|
+
const newRole = member$1.role;
|
|
171
|
+
await changeOrgRole({
|
|
172
|
+
tenantId: org.id,
|
|
173
|
+
userId: member$1.userId,
|
|
174
|
+
oldRole,
|
|
175
|
+
newRole
|
|
176
|
+
});
|
|
177
|
+
console.log(`🔐 SpiceDB: Updated member ${member$1.userId} role from ${oldRole} to ${newRole} in org ${org.name}`);
|
|
178
|
+
} catch (error) {
|
|
179
|
+
console.error("❌ SpiceDB sync failed for role update:", error);
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
afterRemoveMember: async ({ member: member$1, organization: org }) => {
|
|
183
|
+
try {
|
|
184
|
+
const { syncOrgMemberToSpiceDb } = await import("./authz/sync.js");
|
|
185
|
+
await syncOrgMemberToSpiceDb({
|
|
186
|
+
tenantId: org.id,
|
|
187
|
+
userId: member$1.userId,
|
|
188
|
+
role: member$1.role,
|
|
189
|
+
action: "remove"
|
|
190
|
+
});
|
|
191
|
+
console.log(`🔐 SpiceDB: Removed member ${member$1.userId} from org ${org.name}`);
|
|
192
|
+
} catch (error) {
|
|
193
|
+
console.error("❌ SpiceDB sync failed for member removal:", error);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
126
196
|
}
|
|
127
197
|
}),
|
|
128
198
|
deviceAuthorization({
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { v1 } from "@authzed/authzed-node";
|
|
2
|
+
|
|
3
|
+
//#region src/auth/authz/client.d.ts
|
|
4
|
+
|
|
5
|
+
type ZedClientInterface = ReturnType<typeof v1.NewClient>;
|
|
6
|
+
/**
|
|
7
|
+
* Get the SpiceDB client singleton.
|
|
8
|
+
* Creates a new client on first call.
|
|
9
|
+
*/
|
|
10
|
+
declare function getSpiceClient(): ZedClientInterface;
|
|
11
|
+
/**
|
|
12
|
+
* Reset the client (useful for testing)
|
|
13
|
+
*/
|
|
14
|
+
declare function resetSpiceClient(): void;
|
|
15
|
+
/**
|
|
16
|
+
* Check if a subject has a permission on a resource.
|
|
17
|
+
* Note: Caller must verify isAuthzEnabled(tenantId) before calling.
|
|
18
|
+
*/
|
|
19
|
+
declare function checkPermission(params: {
|
|
20
|
+
resourceType: string;
|
|
21
|
+
resourceId: string;
|
|
22
|
+
permission: string;
|
|
23
|
+
subjectType: string;
|
|
24
|
+
subjectId: string;
|
|
25
|
+
}): Promise<boolean>;
|
|
26
|
+
/**
|
|
27
|
+
* Check multiple permissions on a resource in a single request.
|
|
28
|
+
* More efficient than multiple checkPermission calls.
|
|
29
|
+
*
|
|
30
|
+
* @returns Record mapping permission names to boolean results
|
|
31
|
+
*/
|
|
32
|
+
declare function checkBulkPermissions(params: {
|
|
33
|
+
resourceType: string;
|
|
34
|
+
resourceId: string;
|
|
35
|
+
permissions: string[];
|
|
36
|
+
subjectType: string;
|
|
37
|
+
subjectId: string;
|
|
38
|
+
}): Promise<Record<string, boolean>>;
|
|
39
|
+
/**
|
|
40
|
+
* Find all resources of a type that a subject has a permission on.
|
|
41
|
+
*/
|
|
42
|
+
declare function lookupResources(params: {
|
|
43
|
+
resourceType: string;
|
|
44
|
+
permission: string;
|
|
45
|
+
subjectType: string;
|
|
46
|
+
subjectId: string;
|
|
47
|
+
}): Promise<string[]>;
|
|
48
|
+
/**
|
|
49
|
+
* Write a relationship to SpiceDB.
|
|
50
|
+
*/
|
|
51
|
+
declare function writeRelationship(params: {
|
|
52
|
+
resourceType: string;
|
|
53
|
+
resourceId: string;
|
|
54
|
+
relation: string;
|
|
55
|
+
subjectType: string;
|
|
56
|
+
subjectId: string;
|
|
57
|
+
}): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Delete a relationship from SpiceDB.
|
|
60
|
+
*/
|
|
61
|
+
declare function deleteRelationship(params: {
|
|
62
|
+
resourceType: string;
|
|
63
|
+
resourceId: string;
|
|
64
|
+
relation: string;
|
|
65
|
+
subjectType: string;
|
|
66
|
+
subjectId: string;
|
|
67
|
+
}): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Read relationships for a resource to list subjects with access.
|
|
70
|
+
*/
|
|
71
|
+
declare function readRelationships(params: {
|
|
72
|
+
resourceType: string;
|
|
73
|
+
resourceId: string;
|
|
74
|
+
relation?: string;
|
|
75
|
+
}): Promise<Array<{
|
|
76
|
+
subjectType: string;
|
|
77
|
+
subjectId: string;
|
|
78
|
+
relation: string;
|
|
79
|
+
}>>;
|
|
80
|
+
//#endregion
|
|
81
|
+
export { checkBulkPermissions, checkPermission, deleteRelationship, getSpiceClient, lookupResources, readRelationships, resetSpiceClient, v1, writeRelationship };
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { getSpiceDbConfig } from "./config.js";
|
|
2
|
+
import { v1 } from "@authzed/authzed-node";
|
|
3
|
+
|
|
4
|
+
//#region src/auth/authz/client.ts
|
|
5
|
+
/**
|
|
6
|
+
* SpiceDB Client Wrapper
|
|
7
|
+
*
|
|
8
|
+
* Provides a singleton SpiceDB client and helper functions for common operations.
|
|
9
|
+
*/
|
|
10
|
+
let client = null;
|
|
11
|
+
/**
|
|
12
|
+
* Get the SpiceDB client singleton.
|
|
13
|
+
* Creates a new client on first call.
|
|
14
|
+
*/
|
|
15
|
+
function getSpiceClient() {
|
|
16
|
+
if (!client) {
|
|
17
|
+
const config = getSpiceDbConfig();
|
|
18
|
+
client = v1.NewClient(config.token, config.endpoint, config.tlsEnabled ? v1.ClientSecurity.SECURE : v1.ClientSecurity.INSECURE_LOCALHOST_ALLOWED);
|
|
19
|
+
}
|
|
20
|
+
return client;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Reset the client (useful for testing)
|
|
24
|
+
*/
|
|
25
|
+
function resetSpiceClient() {
|
|
26
|
+
client = null;
|
|
27
|
+
}
|
|
28
|
+
const PERMISSIONSHIP_HAS_PERMISSION = 2;
|
|
29
|
+
const RELATIONSHIP_OPERATION_CREATE = 1;
|
|
30
|
+
/**
|
|
31
|
+
* Check if a subject has a permission on a resource.
|
|
32
|
+
* Note: Caller must verify isAuthzEnabled(tenantId) before calling.
|
|
33
|
+
*/
|
|
34
|
+
async function checkPermission(params) {
|
|
35
|
+
return (await getSpiceClient().promises.checkPermission({
|
|
36
|
+
resource: {
|
|
37
|
+
objectType: params.resourceType,
|
|
38
|
+
objectId: params.resourceId
|
|
39
|
+
},
|
|
40
|
+
permission: params.permission,
|
|
41
|
+
subject: {
|
|
42
|
+
object: {
|
|
43
|
+
objectType: params.subjectType,
|
|
44
|
+
objectId: params.subjectId
|
|
45
|
+
},
|
|
46
|
+
optionalRelation: ""
|
|
47
|
+
},
|
|
48
|
+
consistency: { requirement: {
|
|
49
|
+
oneofKind: "minimizeLatency",
|
|
50
|
+
minimizeLatency: true
|
|
51
|
+
} },
|
|
52
|
+
context: void 0,
|
|
53
|
+
withTracing: false
|
|
54
|
+
})).permissionship === PERMISSIONSHIP_HAS_PERMISSION;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Check multiple permissions on a resource in a single request.
|
|
58
|
+
* More efficient than multiple checkPermission calls.
|
|
59
|
+
*
|
|
60
|
+
* @returns Record mapping permission names to boolean results
|
|
61
|
+
*/
|
|
62
|
+
async function checkBulkPermissions(params) {
|
|
63
|
+
const spice = getSpiceClient();
|
|
64
|
+
const items = params.permissions.map((permission) => v1.CheckBulkPermissionsRequestItem.create({
|
|
65
|
+
resource: v1.ObjectReference.create({
|
|
66
|
+
objectType: params.resourceType,
|
|
67
|
+
objectId: params.resourceId
|
|
68
|
+
}),
|
|
69
|
+
permission,
|
|
70
|
+
subject: v1.SubjectReference.create({ object: v1.ObjectReference.create({
|
|
71
|
+
objectType: params.subjectType,
|
|
72
|
+
objectId: params.subjectId
|
|
73
|
+
}) })
|
|
74
|
+
}));
|
|
75
|
+
const response = await spice.promises.checkBulkPermissions(v1.CheckBulkPermissionsRequest.create({
|
|
76
|
+
items,
|
|
77
|
+
consistency: { requirement: {
|
|
78
|
+
oneofKind: "minimizeLatency",
|
|
79
|
+
minimizeLatency: true
|
|
80
|
+
} }
|
|
81
|
+
}));
|
|
82
|
+
const result = {};
|
|
83
|
+
for (let i = 0; i < params.permissions.length; i++) {
|
|
84
|
+
const permission = params.permissions[i];
|
|
85
|
+
const pair = response.pairs[i];
|
|
86
|
+
if (pair.response.oneofKind === "item") result[permission] = pair.response.item.permissionship === PERMISSIONSHIP_HAS_PERMISSION;
|
|
87
|
+
else result[permission] = false;
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Find all resources of a type that a subject has a permission on.
|
|
93
|
+
*/
|
|
94
|
+
async function lookupResources(params) {
|
|
95
|
+
return (await getSpiceClient().promises.lookupResources({
|
|
96
|
+
resourceObjectType: params.resourceType,
|
|
97
|
+
permission: params.permission,
|
|
98
|
+
subject: {
|
|
99
|
+
object: {
|
|
100
|
+
objectType: params.subjectType,
|
|
101
|
+
objectId: params.subjectId
|
|
102
|
+
},
|
|
103
|
+
optionalRelation: ""
|
|
104
|
+
},
|
|
105
|
+
consistency: { requirement: {
|
|
106
|
+
oneofKind: "minimizeLatency",
|
|
107
|
+
minimizeLatency: true
|
|
108
|
+
} },
|
|
109
|
+
context: void 0,
|
|
110
|
+
optionalLimit: 0,
|
|
111
|
+
optionalCursor: void 0
|
|
112
|
+
})).map((item) => item.resourceObjectId);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Write a relationship to SpiceDB.
|
|
116
|
+
*/
|
|
117
|
+
async function writeRelationship(params) {
|
|
118
|
+
await getSpiceClient().promises.writeRelationships({
|
|
119
|
+
updates: [{
|
|
120
|
+
operation: RELATIONSHIP_OPERATION_CREATE,
|
|
121
|
+
relationship: {
|
|
122
|
+
resource: {
|
|
123
|
+
objectType: params.resourceType,
|
|
124
|
+
objectId: params.resourceId
|
|
125
|
+
},
|
|
126
|
+
relation: params.relation,
|
|
127
|
+
subject: {
|
|
128
|
+
object: {
|
|
129
|
+
objectType: params.subjectType,
|
|
130
|
+
objectId: params.subjectId
|
|
131
|
+
},
|
|
132
|
+
optionalRelation: ""
|
|
133
|
+
},
|
|
134
|
+
optionalCaveat: void 0
|
|
135
|
+
}
|
|
136
|
+
}],
|
|
137
|
+
optionalPreconditions: [],
|
|
138
|
+
optionalTransactionMetadata: void 0
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Delete a relationship from SpiceDB.
|
|
143
|
+
*/
|
|
144
|
+
async function deleteRelationship(params) {
|
|
145
|
+
await getSpiceClient().promises.deleteRelationships({
|
|
146
|
+
relationshipFilter: {
|
|
147
|
+
resourceType: params.resourceType,
|
|
148
|
+
optionalResourceId: params.resourceId,
|
|
149
|
+
optionalResourceIdPrefix: "",
|
|
150
|
+
optionalRelation: params.relation,
|
|
151
|
+
optionalSubjectFilter: {
|
|
152
|
+
subjectType: params.subjectType,
|
|
153
|
+
optionalSubjectId: params.subjectId,
|
|
154
|
+
optionalRelation: void 0
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
optionalPreconditions: [],
|
|
158
|
+
optionalLimit: 0,
|
|
159
|
+
optionalAllowPartialDeletions: false,
|
|
160
|
+
optionalTransactionMetadata: void 0
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Read relationships for a resource to list subjects with access.
|
|
165
|
+
*/
|
|
166
|
+
async function readRelationships(params) {
|
|
167
|
+
return (await getSpiceClient().promises.readRelationships({
|
|
168
|
+
relationshipFilter: {
|
|
169
|
+
resourceType: params.resourceType,
|
|
170
|
+
optionalResourceId: params.resourceId,
|
|
171
|
+
optionalResourceIdPrefix: "",
|
|
172
|
+
optionalRelation: params.relation || "",
|
|
173
|
+
optionalSubjectFilter: void 0
|
|
174
|
+
},
|
|
175
|
+
consistency: { requirement: {
|
|
176
|
+
oneofKind: "minimizeLatency",
|
|
177
|
+
minimizeLatency: true
|
|
178
|
+
} },
|
|
179
|
+
optionalLimit: 0,
|
|
180
|
+
optionalCursor: void 0
|
|
181
|
+
})).map((item) => ({
|
|
182
|
+
subjectType: item.relationship?.subject?.object?.objectType || "",
|
|
183
|
+
subjectId: item.relationship?.subject?.object?.objectId || "",
|
|
184
|
+
relation: item.relationship?.relation || ""
|
|
185
|
+
}));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
//#endregion
|
|
189
|
+
export { checkBulkPermissions, checkPermission, deleteRelationship, getSpiceClient, lookupResources, readRelationships, resetSpiceClient, v1, writeRelationship };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
//#region src/auth/authz/config.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* SpiceDB Authorization Configuration
|
|
4
|
+
*
|
|
5
|
+
* Feature flag and configuration for the SpiceDB authorization system.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Check if authorization is enabled.
|
|
9
|
+
*
|
|
10
|
+
* When called without tenantId:
|
|
11
|
+
* - Returns true if ENABLE_AUTHZ=true
|
|
12
|
+
*
|
|
13
|
+
* When called with tenantId:
|
|
14
|
+
* - If ENABLE_AUTHZ=false → returns false
|
|
15
|
+
* - If ENABLE_AUTHZ=true and TENANT_ID is not set → returns true (all tenants)
|
|
16
|
+
* - If ENABLE_AUTHZ=true and TENANT_ID is set → returns true only if tenantId matches
|
|
17
|
+
*/
|
|
18
|
+
declare function isAuthzEnabled(tenantId: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Get SpiceDB connection configuration from environment variables.
|
|
21
|
+
*/
|
|
22
|
+
declare function getSpiceDbConfig(): {
|
|
23
|
+
endpoint: string;
|
|
24
|
+
token: string;
|
|
25
|
+
tlsEnabled: boolean;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* SpiceDB resource types used in the schema
|
|
29
|
+
*/
|
|
30
|
+
declare const SpiceDbResourceTypes: {
|
|
31
|
+
readonly USER: "user";
|
|
32
|
+
readonly ORGANIZATION: "organization";
|
|
33
|
+
readonly PROJECT: "project";
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* SpiceDB relations used in the schema
|
|
37
|
+
*
|
|
38
|
+
* Relations are named as nouns (roles) per SpiceDB best practices.
|
|
39
|
+
* Project roles are prefixed for clarity when debugging/grepping.
|
|
40
|
+
*/
|
|
41
|
+
declare const SpiceDbRelations: {
|
|
42
|
+
readonly OWNER: "owner";
|
|
43
|
+
readonly ADMIN: "admin";
|
|
44
|
+
readonly MEMBER: "member";
|
|
45
|
+
readonly ORGANIZATION: "organization";
|
|
46
|
+
readonly PROJECT_ADMIN: "project_admin";
|
|
47
|
+
readonly PROJECT_MEMBER: "project_member";
|
|
48
|
+
readonly PROJECT_VIEWER: "project_viewer";
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* SpiceDB permissions used in the schema
|
|
52
|
+
*
|
|
53
|
+
* Permissions are named as verbs (actions) per SpiceDB best practices.
|
|
54
|
+
*/
|
|
55
|
+
/**
|
|
56
|
+
* SpiceDB permissions used in permission checks.
|
|
57
|
+
*
|
|
58
|
+
* Note: Organization-level permissions (manage) are handled via
|
|
59
|
+
* orgRole bypass in permission functions, not direct SpiceDB checks.
|
|
60
|
+
*/
|
|
61
|
+
declare const SpiceDbPermissions: {
|
|
62
|
+
readonly VIEW: "view";
|
|
63
|
+
readonly USE: "use";
|
|
64
|
+
readonly EDIT: "edit";
|
|
65
|
+
readonly DELETE: "delete";
|
|
66
|
+
};
|
|
67
|
+
type OrgRole = 'owner' | 'admin' | 'member';
|
|
68
|
+
/**
|
|
69
|
+
* Project roles hierarchy:
|
|
70
|
+
* - project_admin: Full access (view + use + edit + manage members + delete)
|
|
71
|
+
* - project_member: Operator access (view + use: invoke agents, create API keys)
|
|
72
|
+
* - project_viewer: Read-only access (view only)
|
|
73
|
+
*/
|
|
74
|
+
type ProjectRole = 'project_admin' | 'project_member' | 'project_viewer';
|
|
75
|
+
//#endregion
|
|
76
|
+
export { OrgRole, ProjectRole, SpiceDbPermissions, SpiceDbRelations, SpiceDbResourceTypes, getSpiceDbConfig, isAuthzEnabled };
|