@inkeep/agents-core 0.58.21 → 0.59.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-config-utils.d.ts +49 -0
- package/dist/auth/auth-config-utils.js +133 -0
- package/dist/auth/auth-schema.d.ts +102 -85
- package/dist/auth/auth-schema.js +1 -0
- package/dist/auth/auth-types.d.ts +170 -0
- package/dist/auth/auth-types.js +53 -0
- package/dist/auth/auth-validation-schemas.d.ts +186 -152
- package/dist/auth/auth.d.ts +43 -1286
- package/dist/auth/auth.js +61 -70
- package/dist/auth/email-send-status-store.js +15 -3
- package/dist/auth/init.js +2 -1
- package/dist/auth/password-reset-link-store.js +8 -1
- package/dist/auth/permissions.d.ts +13 -13
- package/dist/data-access/index.d.ts +4 -3
- package/dist/data-access/index.js +3 -3
- package/dist/data-access/manage/skills.d.ts +1 -1
- package/dist/data-access/runtime/auth.d.ts +9 -9
- package/dist/data-access/runtime/auth.js +19 -21
- package/dist/data-access/runtime/conversations.d.ts +4 -4
- package/dist/data-access/runtime/messages.d.ts +9 -9
- package/dist/data-access/runtime/organizations.d.ts +28 -4
- package/dist/data-access/runtime/organizations.js +131 -9
- package/dist/data-access/runtime/tasks.d.ts +2 -2
- package/dist/db/manage/manage-schema.d.ts +357 -357
- package/dist/db/runtime/runtime-schema.d.ts +298 -298
- package/dist/index.d.ts +4 -3
- package/dist/index.js +3 -3
- package/dist/middleware/no-auth.d.ts +2 -2
- package/dist/utils/error.d.ts +51 -48
- package/dist/utils/error.js +3 -0
- package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
- package/dist/validation/schemas.d.ts +1535 -1535
- package/drizzle/runtime/0023_lazy_energizer.sql +1 -0
- package/drizzle/runtime/0024_moaning_kingpin.sql +1 -0
- package/drizzle/runtime/meta/0024_snapshot.json +4270 -0
- package/drizzle/runtime/meta/_journal.json +7 -0
- package/package.json +8 -3
package/dist/auth/auth-schema.js
CHANGED
|
@@ -63,6 +63,7 @@ const organization = pgTable("organization", {
|
|
|
63
63
|
createdAt: timestamp("created_at").notNull(),
|
|
64
64
|
metadata: text("metadata"),
|
|
65
65
|
preferredAuthMethod: text("preferred_auth_method"),
|
|
66
|
+
allowedAuthMethods: text("allowed_auth_methods"),
|
|
66
67
|
serviceAccountUserId: text("service_account_user_id")
|
|
67
68
|
}, (table) => [uniqueIndex("organization_slug_uidx").on(table.slug)]);
|
|
68
69
|
const member = pgTable("member", {
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { AgentsRunDatabaseClient } from "../db/runtime/runtime-client.js";
|
|
2
|
+
import * as pg0 from "pg";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { BetterAuthAdvancedOptions } from "better-auth";
|
|
5
|
+
import { GoogleOptions } from "better-auth/social-providers";
|
|
6
|
+
|
|
7
|
+
//#region src/auth/auth-types.d.ts
|
|
8
|
+
type AuthMethodType = 'email-password' | 'google' | 'sso';
|
|
9
|
+
declare const authMethodTypeSchema: z.ZodEnum<{
|
|
10
|
+
"email-password": "email-password";
|
|
11
|
+
google: "google";
|
|
12
|
+
sso: "sso";
|
|
13
|
+
}>;
|
|
14
|
+
declare const methodOptionSchema: z.ZodObject<{
|
|
15
|
+
method: z.ZodEnum<{
|
|
16
|
+
"email-password": "email-password";
|
|
17
|
+
google: "google";
|
|
18
|
+
sso: "sso";
|
|
19
|
+
}>;
|
|
20
|
+
providerId: z.ZodOptional<z.ZodString>;
|
|
21
|
+
providerType: z.ZodOptional<z.ZodEnum<{
|
|
22
|
+
oidc: "oidc";
|
|
23
|
+
saml: "saml";
|
|
24
|
+
}>>;
|
|
25
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
type MethodOption = z.infer<typeof methodOptionSchema>;
|
|
28
|
+
declare const orgAuthInfoSchema: z.ZodObject<{
|
|
29
|
+
organizationId: z.ZodString;
|
|
30
|
+
organizationName: z.ZodString;
|
|
31
|
+
organizationSlug: z.ZodOptional<z.ZodString>;
|
|
32
|
+
methods: z.ZodArray<z.ZodObject<{
|
|
33
|
+
method: z.ZodEnum<{
|
|
34
|
+
"email-password": "email-password";
|
|
35
|
+
google: "google";
|
|
36
|
+
sso: "sso";
|
|
37
|
+
}>;
|
|
38
|
+
providerId: z.ZodOptional<z.ZodString>;
|
|
39
|
+
providerType: z.ZodOptional<z.ZodEnum<{
|
|
40
|
+
oidc: "oidc";
|
|
41
|
+
saml: "saml";
|
|
42
|
+
}>>;
|
|
43
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
44
|
+
}, z.core.$strip>>;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
type OrgAuthInfo = z.infer<typeof orgAuthInfoSchema>;
|
|
47
|
+
declare const authLookupResponseSchema: z.ZodObject<{
|
|
48
|
+
organizations: z.ZodArray<z.ZodObject<{
|
|
49
|
+
organizationId: z.ZodString;
|
|
50
|
+
organizationName: z.ZodString;
|
|
51
|
+
organizationSlug: z.ZodOptional<z.ZodString>;
|
|
52
|
+
methods: z.ZodArray<z.ZodObject<{
|
|
53
|
+
method: z.ZodEnum<{
|
|
54
|
+
"email-password": "email-password";
|
|
55
|
+
google: "google";
|
|
56
|
+
sso: "sso";
|
|
57
|
+
}>;
|
|
58
|
+
providerId: z.ZodOptional<z.ZodString>;
|
|
59
|
+
providerType: z.ZodOptional<z.ZodEnum<{
|
|
60
|
+
oidc: "oidc";
|
|
61
|
+
saml: "saml";
|
|
62
|
+
}>>;
|
|
63
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
64
|
+
}, z.core.$strip>>;
|
|
65
|
+
}, z.core.$strip>>;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
type AuthLookupResponse = z.infer<typeof authLookupResponseSchema>;
|
|
68
|
+
interface OIDCProviderConfig {
|
|
69
|
+
clientId: string;
|
|
70
|
+
clientSecret: string;
|
|
71
|
+
authorizationEndpoint?: string;
|
|
72
|
+
tokenEndpoint?: string;
|
|
73
|
+
userinfoEndpoint?: string;
|
|
74
|
+
jwksEndpoint?: string;
|
|
75
|
+
discoveryEndpoint?: string;
|
|
76
|
+
scopes?: string[];
|
|
77
|
+
pkce?: boolean;
|
|
78
|
+
mapping?: {
|
|
79
|
+
id?: string;
|
|
80
|
+
email?: string;
|
|
81
|
+
emailVerified?: string;
|
|
82
|
+
name?: string;
|
|
83
|
+
image?: string;
|
|
84
|
+
extraFields?: Record<string, string>;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
interface SAMLProviderConfig {
|
|
88
|
+
entryPoint: string;
|
|
89
|
+
cert: string;
|
|
90
|
+
callbackUrl: string;
|
|
91
|
+
audience?: string;
|
|
92
|
+
wantAssertionsSigned?: boolean;
|
|
93
|
+
signatureAlgorithm?: string;
|
|
94
|
+
digestAlgorithm?: string;
|
|
95
|
+
identifierFormat?: string;
|
|
96
|
+
mapping?: {
|
|
97
|
+
id?: string;
|
|
98
|
+
email?: string;
|
|
99
|
+
name?: string;
|
|
100
|
+
firstName?: string;
|
|
101
|
+
lastName?: string;
|
|
102
|
+
emailVerified?: string;
|
|
103
|
+
extraFields?: Record<string, string>;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
interface SSOProviderConfig {
|
|
107
|
+
providerId: string;
|
|
108
|
+
issuer: string;
|
|
109
|
+
domain: string;
|
|
110
|
+
organizationId?: string;
|
|
111
|
+
oidcConfig?: OIDCProviderConfig;
|
|
112
|
+
samlConfig?: SAMLProviderConfig;
|
|
113
|
+
}
|
|
114
|
+
declare const allowedAuthMethodSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
115
|
+
method: z.ZodLiteral<"email-password">;
|
|
116
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
117
|
+
method: z.ZodLiteral<"google">;
|
|
118
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
119
|
+
method: z.ZodLiteral<"sso">;
|
|
120
|
+
providerId: z.ZodString;
|
|
121
|
+
displayName: z.ZodString;
|
|
122
|
+
autoProvision: z.ZodBoolean;
|
|
123
|
+
enabled: z.ZodBoolean;
|
|
124
|
+
}, z.core.$strip>], "method">;
|
|
125
|
+
type AllowedAuthMethod = z.infer<typeof allowedAuthMethodSchema>;
|
|
126
|
+
declare function parseAllowedAuthMethods(raw: string | null | undefined): AllowedAuthMethod[];
|
|
127
|
+
declare function serializeAllowedAuthMethods(methods: AllowedAuthMethod[]): string;
|
|
128
|
+
interface EmailServiceConfig {
|
|
129
|
+
sendInvitationEmail(data: {
|
|
130
|
+
to: string;
|
|
131
|
+
inviterName: string;
|
|
132
|
+
organizationName: string;
|
|
133
|
+
role: string;
|
|
134
|
+
invitationUrl: string;
|
|
135
|
+
authMethod?: string;
|
|
136
|
+
expiresInDays?: number;
|
|
137
|
+
}): Promise<{
|
|
138
|
+
emailSent: boolean;
|
|
139
|
+
error?: string;
|
|
140
|
+
}>;
|
|
141
|
+
sendPasswordResetEmail(data: {
|
|
142
|
+
to: string;
|
|
143
|
+
resetUrl: string;
|
|
144
|
+
expiresInMinutes?: number;
|
|
145
|
+
}): Promise<{
|
|
146
|
+
emailSent: boolean;
|
|
147
|
+
error?: string;
|
|
148
|
+
}>;
|
|
149
|
+
isConfigured: boolean;
|
|
150
|
+
}
|
|
151
|
+
interface BetterAuthConfig {
|
|
152
|
+
baseURL: string;
|
|
153
|
+
secret: string;
|
|
154
|
+
dbClient: AgentsRunDatabaseClient;
|
|
155
|
+
manageDbPool?: pg0.Pool;
|
|
156
|
+
cookieDomain?: string;
|
|
157
|
+
socialProviders?: {
|
|
158
|
+
google?: GoogleOptions;
|
|
159
|
+
};
|
|
160
|
+
advanced?: BetterAuthAdvancedOptions;
|
|
161
|
+
emailService?: EmailServiceConfig;
|
|
162
|
+
}
|
|
163
|
+
interface UserAuthConfig {
|
|
164
|
+
socialProviders?: {
|
|
165
|
+
google?: GoogleOptions;
|
|
166
|
+
};
|
|
167
|
+
advanced?: BetterAuthAdvancedOptions;
|
|
168
|
+
}
|
|
169
|
+
//#endregion
|
|
170
|
+
export { AllowedAuthMethod, AuthLookupResponse, AuthMethodType, BetterAuthConfig, EmailServiceConfig, MethodOption, OIDCProviderConfig, OrgAuthInfo, SAMLProviderConfig, SSOProviderConfig, UserAuthConfig, authLookupResponseSchema, authMethodTypeSchema, methodOptionSchema, orgAuthInfoSchema, parseAllowedAuthMethods, serializeAllowedAuthMethods };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/auth/auth-types.ts
|
|
4
|
+
const authMethodTypeSchema = z.enum([
|
|
5
|
+
"email-password",
|
|
6
|
+
"google",
|
|
7
|
+
"sso"
|
|
8
|
+
]);
|
|
9
|
+
const methodOptionSchema = z.object({
|
|
10
|
+
method: authMethodTypeSchema,
|
|
11
|
+
providerId: z.string().optional(),
|
|
12
|
+
providerType: z.enum(["oidc", "saml"]).optional(),
|
|
13
|
+
displayName: z.string().optional()
|
|
14
|
+
});
|
|
15
|
+
const orgAuthInfoSchema = z.object({
|
|
16
|
+
organizationId: z.string(),
|
|
17
|
+
organizationName: z.string(),
|
|
18
|
+
organizationSlug: z.string().optional(),
|
|
19
|
+
methods: z.array(methodOptionSchema)
|
|
20
|
+
});
|
|
21
|
+
const authLookupResponseSchema = z.object({ organizations: z.array(orgAuthInfoSchema) });
|
|
22
|
+
const allowedAuthMethodSchema = z.discriminatedUnion("method", [
|
|
23
|
+
z.object({ method: z.literal("email-password") }),
|
|
24
|
+
z.object({ method: z.literal("google") }),
|
|
25
|
+
z.object({
|
|
26
|
+
method: z.literal("sso"),
|
|
27
|
+
providerId: z.string(),
|
|
28
|
+
displayName: z.string(),
|
|
29
|
+
autoProvision: z.boolean(),
|
|
30
|
+
enabled: z.boolean()
|
|
31
|
+
})
|
|
32
|
+
]);
|
|
33
|
+
const DEFAULT_AUTH_METHODS = [{ method: "email-password" }];
|
|
34
|
+
function parseAllowedAuthMethods(raw) {
|
|
35
|
+
if (!raw) return DEFAULT_AUTH_METHODS;
|
|
36
|
+
try {
|
|
37
|
+
const parsed = JSON.parse(raw);
|
|
38
|
+
if (!Array.isArray(parsed)) return DEFAULT_AUTH_METHODS;
|
|
39
|
+
const valid = parsed.flatMap((item) => {
|
|
40
|
+
const result = allowedAuthMethodSchema.safeParse(item);
|
|
41
|
+
return result.success ? [result.data] : [];
|
|
42
|
+
});
|
|
43
|
+
return valid.length > 0 ? valid : DEFAULT_AUTH_METHODS;
|
|
44
|
+
} catch {
|
|
45
|
+
return DEFAULT_AUTH_METHODS;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function serializeAllowedAuthMethods(methods) {
|
|
49
|
+
return JSON.stringify(methods);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
export { authLookupResponseSchema, authMethodTypeSchema, methodOptionSchema, orgAuthInfoSchema, parseAllowedAuthMethods, serializeAllowedAuthMethods };
|