@inkeep/agents-core 0.58.7 → 0.58.8
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-schema.d.ts +85 -85
- package/dist/auth/auth-validation-schemas.d.ts +152 -152
- package/dist/auth/auth.d.ts +9 -9
- package/dist/auth/permissions.d.ts +9 -9
- package/dist/client-exports.d.ts +6 -4
- package/dist/client-exports.js +2 -2
- package/dist/data-access/index.d.ts +2 -1
- package/dist/data-access/index.js +2 -1
- package/dist/data-access/manage/agents.d.ts +10 -10
- 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/skills.d.ts +11 -11
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +12 -12
- package/dist/data-access/manage/subAgentRelations.d.ts +16 -16
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +12 -12
- package/dist/data-access/manage/subAgents.d.ts +6 -6
- package/dist/data-access/manage/tools.d.ts +12 -12
- 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/apps.d.ts +113 -0
- package/dist/data-access/runtime/apps.js +86 -0
- package/dist/data-access/runtime/cascade-delete.d.ts +2 -0
- package/dist/data-access/runtime/cascade-delete.js +16 -4
- package/dist/data-access/runtime/conversations.d.ts +32 -31
- package/dist/data-access/runtime/conversations.js +1 -0
- package/dist/data-access/runtime/messages.d.ts +9 -9
- package/dist/data-access/runtime/tasks.d.ts +9 -9
- package/dist/db/manage/manage-schema.d.ts +453 -453
- package/dist/db/runtime/runtime-schema.d.ts +582 -321
- package/dist/db/runtime/runtime-schema.js +16 -1
- package/dist/index.d.ts +10 -7
- package/dist/index.js +7 -4
- package/dist/middleware/no-auth.d.ts +2 -2
- package/dist/setup/setup.js +10 -0
- package/dist/types/entities.d.ts +10 -2
- package/dist/types/index.d.ts +4 -4
- package/dist/types/utility.d.ts +9 -3
- package/dist/utils/apiKeys.d.ts +6 -1
- package/dist/utils/apiKeys.js +9 -1
- package/dist/utils/domain-validation.d.ts +4 -0
- package/dist/utils/domain-validation.js +25 -0
- package/dist/utils/error.d.ts +51 -51
- package/dist/utils/index.d.ts +4 -2
- package/dist/utils/index.js +4 -2
- package/dist/utils/pow.d.ts +13 -0
- package/dist/utils/pow.js +52 -0
- package/dist/validation/dolt-schemas.d.ts +1 -1
- package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
- package/dist/validation/index.d.ts +2 -2
- package/dist/validation/index.js +2 -2
- package/dist/validation/schemas.d.ts +3282 -2001
- package/dist/validation/schemas.js +57 -3
- package/drizzle/runtime/0022_superb_micromacro.sql +17 -0
- package/drizzle/runtime/meta/0022_snapshot.json +4240 -0
- package/drizzle/runtime/meta/_journal.json +7 -0
- package/package.json +3 -2
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/utils/domain-validation.ts
|
|
2
|
+
function validateOrigin(origin, allowedDomains) {
|
|
3
|
+
if (!origin || allowedDomains.length === 0) return false;
|
|
4
|
+
let hostname;
|
|
5
|
+
let host;
|
|
6
|
+
try {
|
|
7
|
+
const url = new URL(origin);
|
|
8
|
+
hostname = url.hostname;
|
|
9
|
+
host = url.host;
|
|
10
|
+
} catch {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
for (const domain of allowedDomains) {
|
|
14
|
+
if (domain === "*") return true;
|
|
15
|
+
const target = domain.includes(":") && !domain.startsWith("*") ? host : hostname;
|
|
16
|
+
if (domain.startsWith("*.")) {
|
|
17
|
+
const suffix = domain.slice(2);
|
|
18
|
+
if (hostname === suffix || hostname.endsWith(`.${suffix}`)) return true;
|
|
19
|
+
} else if (target === domain) return true;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { validateOrigin };
|
package/dist/utils/error.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { HTTPException } from "hono/http-exception";
|
|
|
3
3
|
|
|
4
4
|
//#region src/utils/error.d.ts
|
|
5
5
|
declare const ErrorCode: z.ZodEnum<{
|
|
6
|
-
unauthorized: "unauthorized";
|
|
7
6
|
bad_request: "bad_request";
|
|
7
|
+
unauthorized: "unauthorized";
|
|
8
8
|
forbidden: "forbidden";
|
|
9
9
|
not_found: "not_found";
|
|
10
10
|
conflict: "conflict";
|
|
@@ -19,8 +19,8 @@ declare const problemDetailsSchema: z.ZodObject<{
|
|
|
19
19
|
instance: z.ZodOptional<z.ZodString>;
|
|
20
20
|
requestId: z.ZodOptional<z.ZodString>;
|
|
21
21
|
code: z.ZodEnum<{
|
|
22
|
-
unauthorized: "unauthorized";
|
|
23
22
|
bad_request: "bad_request";
|
|
23
|
+
unauthorized: "unauthorized";
|
|
24
24
|
forbidden: "forbidden";
|
|
25
25
|
not_found: "not_found";
|
|
26
26
|
conflict: "conflict";
|
|
@@ -33,8 +33,8 @@ type ErrorCodes = z.infer<typeof ErrorCode>;
|
|
|
33
33
|
declare const errorResponseSchema: z.ZodObject<{
|
|
34
34
|
error: z.ZodObject<{
|
|
35
35
|
code: z.ZodEnum<{
|
|
36
|
-
unauthorized: "unauthorized";
|
|
37
36
|
bad_request: "bad_request";
|
|
37
|
+
unauthorized: "unauthorized";
|
|
38
38
|
forbidden: "forbidden";
|
|
39
39
|
not_found: "not_found";
|
|
40
40
|
conflict: "conflict";
|
|
@@ -71,12 +71,12 @@ declare const errorSchemaFactory: (code: ErrorCodes, description: string) => {
|
|
|
71
71
|
schema: z.ZodObject<{
|
|
72
72
|
instance: z.ZodOptional<z.ZodString>;
|
|
73
73
|
requestId: z.ZodOptional<z.ZodString>;
|
|
74
|
-
code: z.ZodLiteral<"
|
|
74
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
75
75
|
detail: z.ZodString;
|
|
76
76
|
title: z.ZodString;
|
|
77
77
|
status: z.ZodNumber;
|
|
78
78
|
error: z.ZodObject<{
|
|
79
|
-
code: z.ZodLiteral<"
|
|
79
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
80
80
|
message: z.ZodString;
|
|
81
81
|
}, z.core.$strip>;
|
|
82
82
|
}, z.core.$strip>;
|
|
@@ -93,12 +93,12 @@ declare const commonCreateErrorResponses: {
|
|
|
93
93
|
schema: z.ZodObject<{
|
|
94
94
|
instance: z.ZodOptional<z.ZodString>;
|
|
95
95
|
requestId: z.ZodOptional<z.ZodString>;
|
|
96
|
-
code: z.ZodLiteral<"
|
|
96
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
97
97
|
detail: z.ZodString;
|
|
98
98
|
title: z.ZodString;
|
|
99
99
|
status: z.ZodNumber;
|
|
100
100
|
error: z.ZodObject<{
|
|
101
|
-
code: z.ZodLiteral<"
|
|
101
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
102
102
|
message: z.ZodString;
|
|
103
103
|
}, z.core.$strip>;
|
|
104
104
|
}, z.core.$strip>;
|
|
@@ -112,12 +112,12 @@ declare const commonCreateErrorResponses: {
|
|
|
112
112
|
schema: z.ZodObject<{
|
|
113
113
|
instance: z.ZodOptional<z.ZodString>;
|
|
114
114
|
requestId: z.ZodOptional<z.ZodString>;
|
|
115
|
-
code: z.ZodLiteral<"
|
|
115
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
116
116
|
detail: z.ZodString;
|
|
117
117
|
title: z.ZodString;
|
|
118
118
|
status: z.ZodNumber;
|
|
119
119
|
error: z.ZodObject<{
|
|
120
|
-
code: z.ZodLiteral<"
|
|
120
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
121
121
|
message: z.ZodString;
|
|
122
122
|
}, z.core.$strip>;
|
|
123
123
|
}, z.core.$strip>;
|
|
@@ -131,12 +131,12 @@ declare const commonCreateErrorResponses: {
|
|
|
131
131
|
schema: z.ZodObject<{
|
|
132
132
|
instance: z.ZodOptional<z.ZodString>;
|
|
133
133
|
requestId: z.ZodOptional<z.ZodString>;
|
|
134
|
-
code: z.ZodLiteral<"
|
|
134
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
135
135
|
detail: z.ZodString;
|
|
136
136
|
title: z.ZodString;
|
|
137
137
|
status: z.ZodNumber;
|
|
138
138
|
error: z.ZodObject<{
|
|
139
|
-
code: z.ZodLiteral<"
|
|
139
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
140
140
|
message: z.ZodString;
|
|
141
141
|
}, z.core.$strip>;
|
|
142
142
|
}, z.core.$strip>;
|
|
@@ -150,12 +150,12 @@ declare const commonCreateErrorResponses: {
|
|
|
150
150
|
schema: z.ZodObject<{
|
|
151
151
|
instance: z.ZodOptional<z.ZodString>;
|
|
152
152
|
requestId: z.ZodOptional<z.ZodString>;
|
|
153
|
-
code: z.ZodLiteral<"
|
|
153
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
154
154
|
detail: z.ZodString;
|
|
155
155
|
title: z.ZodString;
|
|
156
156
|
status: z.ZodNumber;
|
|
157
157
|
error: z.ZodObject<{
|
|
158
|
-
code: z.ZodLiteral<"
|
|
158
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
159
159
|
message: z.ZodString;
|
|
160
160
|
}, z.core.$strip>;
|
|
161
161
|
}, z.core.$strip>;
|
|
@@ -169,12 +169,12 @@ declare const commonCreateErrorResponses: {
|
|
|
169
169
|
schema: z.ZodObject<{
|
|
170
170
|
instance: z.ZodOptional<z.ZodString>;
|
|
171
171
|
requestId: z.ZodOptional<z.ZodString>;
|
|
172
|
-
code: z.ZodLiteral<"
|
|
172
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
173
173
|
detail: z.ZodString;
|
|
174
174
|
title: z.ZodString;
|
|
175
175
|
status: z.ZodNumber;
|
|
176
176
|
error: z.ZodObject<{
|
|
177
|
-
code: z.ZodLiteral<"
|
|
177
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
178
178
|
message: z.ZodString;
|
|
179
179
|
}, z.core.$strip>;
|
|
180
180
|
}, z.core.$strip>;
|
|
@@ -190,12 +190,12 @@ declare const commonUpdateErrorResponses: {
|
|
|
190
190
|
schema: z.ZodObject<{
|
|
191
191
|
instance: z.ZodOptional<z.ZodString>;
|
|
192
192
|
requestId: z.ZodOptional<z.ZodString>;
|
|
193
|
-
code: z.ZodLiteral<"
|
|
193
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
194
194
|
detail: z.ZodString;
|
|
195
195
|
title: z.ZodString;
|
|
196
196
|
status: z.ZodNumber;
|
|
197
197
|
error: z.ZodObject<{
|
|
198
|
-
code: z.ZodLiteral<"
|
|
198
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
199
199
|
message: z.ZodString;
|
|
200
200
|
}, z.core.$strip>;
|
|
201
201
|
}, z.core.$strip>;
|
|
@@ -209,12 +209,12 @@ declare const commonUpdateErrorResponses: {
|
|
|
209
209
|
schema: z.ZodObject<{
|
|
210
210
|
instance: z.ZodOptional<z.ZodString>;
|
|
211
211
|
requestId: z.ZodOptional<z.ZodString>;
|
|
212
|
-
code: z.ZodLiteral<"
|
|
212
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
213
213
|
detail: z.ZodString;
|
|
214
214
|
title: z.ZodString;
|
|
215
215
|
status: z.ZodNumber;
|
|
216
216
|
error: z.ZodObject<{
|
|
217
|
-
code: z.ZodLiteral<"
|
|
217
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
218
218
|
message: z.ZodString;
|
|
219
219
|
}, z.core.$strip>;
|
|
220
220
|
}, z.core.$strip>;
|
|
@@ -228,12 +228,12 @@ declare const commonUpdateErrorResponses: {
|
|
|
228
228
|
schema: z.ZodObject<{
|
|
229
229
|
instance: z.ZodOptional<z.ZodString>;
|
|
230
230
|
requestId: z.ZodOptional<z.ZodString>;
|
|
231
|
-
code: z.ZodLiteral<"
|
|
231
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
232
232
|
detail: z.ZodString;
|
|
233
233
|
title: z.ZodString;
|
|
234
234
|
status: z.ZodNumber;
|
|
235
235
|
error: z.ZodObject<{
|
|
236
|
-
code: z.ZodLiteral<"
|
|
236
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
237
237
|
message: z.ZodString;
|
|
238
238
|
}, z.core.$strip>;
|
|
239
239
|
}, z.core.$strip>;
|
|
@@ -247,12 +247,12 @@ declare const commonUpdateErrorResponses: {
|
|
|
247
247
|
schema: z.ZodObject<{
|
|
248
248
|
instance: z.ZodOptional<z.ZodString>;
|
|
249
249
|
requestId: z.ZodOptional<z.ZodString>;
|
|
250
|
-
code: z.ZodLiteral<"
|
|
250
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
251
251
|
detail: z.ZodString;
|
|
252
252
|
title: z.ZodString;
|
|
253
253
|
status: z.ZodNumber;
|
|
254
254
|
error: z.ZodObject<{
|
|
255
|
-
code: z.ZodLiteral<"
|
|
255
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
256
256
|
message: z.ZodString;
|
|
257
257
|
}, z.core.$strip>;
|
|
258
258
|
}, z.core.$strip>;
|
|
@@ -266,12 +266,12 @@ declare const commonUpdateErrorResponses: {
|
|
|
266
266
|
schema: z.ZodObject<{
|
|
267
267
|
instance: z.ZodOptional<z.ZodString>;
|
|
268
268
|
requestId: z.ZodOptional<z.ZodString>;
|
|
269
|
-
code: z.ZodLiteral<"
|
|
269
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
270
270
|
detail: z.ZodString;
|
|
271
271
|
title: z.ZodString;
|
|
272
272
|
status: z.ZodNumber;
|
|
273
273
|
error: z.ZodObject<{
|
|
274
|
-
code: z.ZodLiteral<"
|
|
274
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
275
275
|
message: z.ZodString;
|
|
276
276
|
}, z.core.$strip>;
|
|
277
277
|
}, z.core.$strip>;
|
|
@@ -285,12 +285,12 @@ declare const commonUpdateErrorResponses: {
|
|
|
285
285
|
schema: z.ZodObject<{
|
|
286
286
|
instance: z.ZodOptional<z.ZodString>;
|
|
287
287
|
requestId: z.ZodOptional<z.ZodString>;
|
|
288
|
-
code: z.ZodLiteral<"
|
|
288
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
289
289
|
detail: z.ZodString;
|
|
290
290
|
title: z.ZodString;
|
|
291
291
|
status: z.ZodNumber;
|
|
292
292
|
error: z.ZodObject<{
|
|
293
|
-
code: z.ZodLiteral<"
|
|
293
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
294
294
|
message: z.ZodString;
|
|
295
295
|
}, z.core.$strip>;
|
|
296
296
|
}, z.core.$strip>;
|
|
@@ -306,12 +306,12 @@ declare const commonGetErrorResponses: {
|
|
|
306
306
|
schema: z.ZodObject<{
|
|
307
307
|
instance: z.ZodOptional<z.ZodString>;
|
|
308
308
|
requestId: z.ZodOptional<z.ZodString>;
|
|
309
|
-
code: z.ZodLiteral<"
|
|
309
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
310
310
|
detail: z.ZodString;
|
|
311
311
|
title: z.ZodString;
|
|
312
312
|
status: z.ZodNumber;
|
|
313
313
|
error: z.ZodObject<{
|
|
314
|
-
code: z.ZodLiteral<"
|
|
314
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
315
315
|
message: z.ZodString;
|
|
316
316
|
}, z.core.$strip>;
|
|
317
317
|
}, z.core.$strip>;
|
|
@@ -325,12 +325,12 @@ declare const commonGetErrorResponses: {
|
|
|
325
325
|
schema: z.ZodObject<{
|
|
326
326
|
instance: z.ZodOptional<z.ZodString>;
|
|
327
327
|
requestId: z.ZodOptional<z.ZodString>;
|
|
328
|
-
code: z.ZodLiteral<"
|
|
328
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
329
329
|
detail: z.ZodString;
|
|
330
330
|
title: z.ZodString;
|
|
331
331
|
status: z.ZodNumber;
|
|
332
332
|
error: z.ZodObject<{
|
|
333
|
-
code: z.ZodLiteral<"
|
|
333
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
334
334
|
message: z.ZodString;
|
|
335
335
|
}, z.core.$strip>;
|
|
336
336
|
}, z.core.$strip>;
|
|
@@ -344,12 +344,12 @@ declare const commonGetErrorResponses: {
|
|
|
344
344
|
schema: z.ZodObject<{
|
|
345
345
|
instance: z.ZodOptional<z.ZodString>;
|
|
346
346
|
requestId: z.ZodOptional<z.ZodString>;
|
|
347
|
-
code: z.ZodLiteral<"
|
|
347
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
348
348
|
detail: z.ZodString;
|
|
349
349
|
title: z.ZodString;
|
|
350
350
|
status: z.ZodNumber;
|
|
351
351
|
error: z.ZodObject<{
|
|
352
|
-
code: z.ZodLiteral<"
|
|
352
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
353
353
|
message: z.ZodString;
|
|
354
354
|
}, z.core.$strip>;
|
|
355
355
|
}, z.core.$strip>;
|
|
@@ -363,12 +363,12 @@ declare const commonGetErrorResponses: {
|
|
|
363
363
|
schema: z.ZodObject<{
|
|
364
364
|
instance: z.ZodOptional<z.ZodString>;
|
|
365
365
|
requestId: z.ZodOptional<z.ZodString>;
|
|
366
|
-
code: z.ZodLiteral<"
|
|
366
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
367
367
|
detail: z.ZodString;
|
|
368
368
|
title: z.ZodString;
|
|
369
369
|
status: z.ZodNumber;
|
|
370
370
|
error: z.ZodObject<{
|
|
371
|
-
code: z.ZodLiteral<"
|
|
371
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
372
372
|
message: z.ZodString;
|
|
373
373
|
}, z.core.$strip>;
|
|
374
374
|
}, z.core.$strip>;
|
|
@@ -382,12 +382,12 @@ declare const commonGetErrorResponses: {
|
|
|
382
382
|
schema: z.ZodObject<{
|
|
383
383
|
instance: z.ZodOptional<z.ZodString>;
|
|
384
384
|
requestId: z.ZodOptional<z.ZodString>;
|
|
385
|
-
code: z.ZodLiteral<"
|
|
385
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
386
386
|
detail: z.ZodString;
|
|
387
387
|
title: z.ZodString;
|
|
388
388
|
status: z.ZodNumber;
|
|
389
389
|
error: z.ZodObject<{
|
|
390
|
-
code: z.ZodLiteral<"
|
|
390
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
391
391
|
message: z.ZodString;
|
|
392
392
|
}, z.core.$strip>;
|
|
393
393
|
}, z.core.$strip>;
|
|
@@ -401,12 +401,12 @@ declare const commonGetErrorResponses: {
|
|
|
401
401
|
schema: z.ZodObject<{
|
|
402
402
|
instance: z.ZodOptional<z.ZodString>;
|
|
403
403
|
requestId: z.ZodOptional<z.ZodString>;
|
|
404
|
-
code: z.ZodLiteral<"
|
|
404
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
405
405
|
detail: z.ZodString;
|
|
406
406
|
title: z.ZodString;
|
|
407
407
|
status: z.ZodNumber;
|
|
408
408
|
error: z.ZodObject<{
|
|
409
|
-
code: z.ZodLiteral<"
|
|
409
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
410
410
|
message: z.ZodString;
|
|
411
411
|
}, z.core.$strip>;
|
|
412
412
|
}, z.core.$strip>;
|
|
@@ -422,12 +422,12 @@ declare const commonDeleteErrorResponses: {
|
|
|
422
422
|
schema: z.ZodObject<{
|
|
423
423
|
instance: z.ZodOptional<z.ZodString>;
|
|
424
424
|
requestId: z.ZodOptional<z.ZodString>;
|
|
425
|
-
code: z.ZodLiteral<"
|
|
425
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
426
426
|
detail: z.ZodString;
|
|
427
427
|
title: z.ZodString;
|
|
428
428
|
status: z.ZodNumber;
|
|
429
429
|
error: z.ZodObject<{
|
|
430
|
-
code: z.ZodLiteral<"
|
|
430
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
431
431
|
message: z.ZodString;
|
|
432
432
|
}, z.core.$strip>;
|
|
433
433
|
}, z.core.$strip>;
|
|
@@ -441,12 +441,12 @@ declare const commonDeleteErrorResponses: {
|
|
|
441
441
|
schema: z.ZodObject<{
|
|
442
442
|
instance: z.ZodOptional<z.ZodString>;
|
|
443
443
|
requestId: z.ZodOptional<z.ZodString>;
|
|
444
|
-
code: z.ZodLiteral<"
|
|
444
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
445
445
|
detail: z.ZodString;
|
|
446
446
|
title: z.ZodString;
|
|
447
447
|
status: z.ZodNumber;
|
|
448
448
|
error: z.ZodObject<{
|
|
449
|
-
code: z.ZodLiteral<"
|
|
449
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
450
450
|
message: z.ZodString;
|
|
451
451
|
}, z.core.$strip>;
|
|
452
452
|
}, z.core.$strip>;
|
|
@@ -460,12 +460,12 @@ declare const commonDeleteErrorResponses: {
|
|
|
460
460
|
schema: z.ZodObject<{
|
|
461
461
|
instance: z.ZodOptional<z.ZodString>;
|
|
462
462
|
requestId: z.ZodOptional<z.ZodString>;
|
|
463
|
-
code: z.ZodLiteral<"
|
|
463
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
464
464
|
detail: z.ZodString;
|
|
465
465
|
title: z.ZodString;
|
|
466
466
|
status: z.ZodNumber;
|
|
467
467
|
error: z.ZodObject<{
|
|
468
|
-
code: z.ZodLiteral<"
|
|
468
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
469
469
|
message: z.ZodString;
|
|
470
470
|
}, z.core.$strip>;
|
|
471
471
|
}, z.core.$strip>;
|
|
@@ -479,12 +479,12 @@ declare const commonDeleteErrorResponses: {
|
|
|
479
479
|
schema: z.ZodObject<{
|
|
480
480
|
instance: z.ZodOptional<z.ZodString>;
|
|
481
481
|
requestId: z.ZodOptional<z.ZodString>;
|
|
482
|
-
code: z.ZodLiteral<"
|
|
482
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
483
483
|
detail: z.ZodString;
|
|
484
484
|
title: z.ZodString;
|
|
485
485
|
status: z.ZodNumber;
|
|
486
486
|
error: z.ZodObject<{
|
|
487
|
-
code: z.ZodLiteral<"
|
|
487
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
488
488
|
message: z.ZodString;
|
|
489
489
|
}, z.core.$strip>;
|
|
490
490
|
}, z.core.$strip>;
|
|
@@ -498,12 +498,12 @@ declare const commonDeleteErrorResponses: {
|
|
|
498
498
|
schema: z.ZodObject<{
|
|
499
499
|
instance: z.ZodOptional<z.ZodString>;
|
|
500
500
|
requestId: z.ZodOptional<z.ZodString>;
|
|
501
|
-
code: z.ZodLiteral<"
|
|
501
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
502
502
|
detail: z.ZodString;
|
|
503
503
|
title: z.ZodString;
|
|
504
504
|
status: z.ZodNumber;
|
|
505
505
|
error: z.ZodObject<{
|
|
506
|
-
code: z.ZodLiteral<"
|
|
506
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
507
507
|
message: z.ZodString;
|
|
508
508
|
}, z.core.$strip>;
|
|
509
509
|
}, z.core.$strip>;
|
|
@@ -517,12 +517,12 @@ declare const commonDeleteErrorResponses: {
|
|
|
517
517
|
schema: z.ZodObject<{
|
|
518
518
|
instance: z.ZodOptional<z.ZodString>;
|
|
519
519
|
requestId: z.ZodOptional<z.ZodString>;
|
|
520
|
-
code: z.ZodLiteral<"
|
|
520
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
521
521
|
detail: z.ZodString;
|
|
522
522
|
title: z.ZodString;
|
|
523
523
|
status: z.ZodNumber;
|
|
524
524
|
error: z.ZodObject<{
|
|
525
|
-
code: z.ZodLiteral<"
|
|
525
|
+
code: z.ZodLiteral<"bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
|
|
526
526
|
message: z.ZodString;
|
|
527
527
|
}, z.core.$strip>;
|
|
528
528
|
}, z.core.$strip>;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -2,11 +2,12 @@ import { JwtVerifyResult, SignJwtOptions, VerifyJwtOptions, decodeJwtPayload, ex
|
|
|
2
2
|
import { GenerateInternalServiceTokenParams, InternalServiceId, InternalServiceTokenPayload, InternalServices, VerifyInternalServiceTokenResult, generateInternalServiceToken, isInternalServiceToken, validateInternalServiceProjectAccess, validateInternalServiceTenantAccess, verifyInternalServiceAuthHeader, verifyInternalServiceToken } from "./internal-service-auth.js";
|
|
3
3
|
import { LoggerFactoryConfig, PinoLogger, PinoLoggerConfig, getLogger, loggerFactory } from "./logger.js";
|
|
4
4
|
import { McpClient, McpClientOptions, McpSSEConfig, McpServerConfig, McpStreamableHttpConfig, activeMcpClients } from "./mcp-client.js";
|
|
5
|
-
import { ApiKeyGenerationResult, extractPublicId, generateApiKey, getMetadataFromApiKey, hashApiKey, isApiKeyExpired, maskApiKey, validateApiKey } from "./apiKeys.js";
|
|
5
|
+
import { ApiKeyGenerationResult, AppCredentialResult, extractPublicId, generateApiKey, generateAppCredential, getMetadataFromApiKey, hashApiKey, isApiKeyExpired, maskApiKey, sanitizeAppConfig, validateApiKey } from "./apiKeys.js";
|
|
6
6
|
import { McpOAuthFlowResult, McpTokenExchangeResult, OAuthConfig, detectAuthenticationRequired, exchangeMcpAuthorizationCode, initiateMcpOAuthFlow } from "./auth-detection.js";
|
|
7
7
|
import { generateId, getConversationId } from "./conversations.js";
|
|
8
8
|
import { getCredentialStoreLookupKeyFromRetrievalParams } from "./credential-store-utils.js";
|
|
9
9
|
import { normalizeDateString, toISODateString } from "./date.js";
|
|
10
|
+
import { validateOrigin } from "./domain-validation.js";
|
|
10
11
|
import { CommonCreateErrorResponses, CommonDeleteErrorResponses, CommonGetErrorResponses, CommonUpdateErrorResponses, ERROR_DOCS_BASE_URL, ErrorCode, ErrorCodes, ErrorResponse, ProblemDetails, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, createApiError, errorResponseSchema, errorSchemaFactory, handleApiError, isUniqueConstraintError, problemDetailsSchema, throwIfUniqueConstraintError } from "./error.js";
|
|
11
12
|
import { LLMMessage, formatMessagesForLLM, formatMessagesForLLMContext } from "./format-messages.js";
|
|
12
13
|
import { getInProcessFetch, registerAppFetch } from "./in-process-fetch.js";
|
|
@@ -14,6 +15,7 @@ import { JsonTransformer } from "./JsonTransformer.js";
|
|
|
14
15
|
import { parseEmbeddedJson } from "./json-parser.js";
|
|
15
16
|
import { MockLanguageModel, createMockModel } from "./mock-provider.js";
|
|
16
17
|
import { ModelFactory } from "./model-factory.js";
|
|
18
|
+
import { PoWError, PoWResult, getPoWErrorMessage, isPoWEnabled, verifyPoW } from "./pow.js";
|
|
17
19
|
import { retryWithBackoff } from "./retry.js";
|
|
18
20
|
import { convertZodToJsonSchema, convertZodToJsonSchemaWithPreview, extractPreviewFields, isZodSchema, preview } from "./schema-conversion.js";
|
|
19
21
|
import { GenerateServiceTokenParams, ServiceTokenPayload, VerifyServiceTokenResult, generateServiceToken, validateTargetAgent, validateTenantId, verifyAuthorizationHeader, verifyServiceToken } from "./service-token-auth.js";
|
|
@@ -28,4 +30,4 @@ import "./third-party-mcp-servers/index.js";
|
|
|
28
30
|
import { flushTraces, getTracer, setSpanWithError, unwrapError } from "./tracer-factory.js";
|
|
29
31
|
import { HashedHeaderValue, SignatureVerificationErrorCode, SignatureVerificationResult, TriggerAuthResult, hashAuthenticationHeaders, hashTriggerHeaderValue, validateTriggerHeaderValue, verifySignatureWithConfig, verifyTriggerAuth } from "./trigger-auth.js";
|
|
30
32
|
import { _resetWaitUntilCache, getWaitUntil } from "./wait-until.js";
|
|
31
|
-
export { ApiKeyGenerationResult, CommonCreateErrorResponses, CommonDeleteErrorResponses, CommonGetErrorResponses, CommonUpdateErrorResponses, CredentialScope, ERROR_DOCS_BASE_URL, ErrorCode, ErrorCodes, ErrorResponse, GenerateInternalServiceTokenParams, GenerateServiceTokenParams, HashedHeaderValue, InternalServiceId, InternalServiceTokenPayload, InternalServices, JsonTransformer, JwtVerifyResult, LLMMessage, LoggerFactoryConfig, McpClient, McpClientOptions, McpOAuthFlowResult, McpSSEConfig, McpServerConfig, McpStreamableHttpConfig, McpTokenExchangeResult, MockLanguageModel, ModelFactory, OAuthConfig, ParsedSSEResponse, PinoLogger, PinoLoggerConfig, ProblemDetails, ServiceTokenPayload, SignJwtOptions, SignSlackLinkTokenParams, SignSlackUserTokenParams, SignatureVerificationErrorCode, SignatureVerificationResult, SignedTempToken, SlackAccessTokenPayload, SlackAccessTokenPayloadSchema, SlackLinkIntent, SlackLinkIntentSchema, SlackLinkTokenPayload, SlackLinkTokenPayloadSchema, TempTokenPayload, TriggerAuthResult, VerifyInternalServiceTokenResult, VerifyJwtOptions, VerifyServiceTokenResult, VerifySlackLinkTokenResult, VerifySlackUserTokenResult, _resetWaitUntilCache, activeMcpClients, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, configureComposioMCPServer, convertZodToJsonSchema, convertZodToJsonSchemaWithPreview, createApiError, createMockModel, decodeJwtPayload, detectAuthenticationRequired, errorResponseSchema, errorSchemaFactory, exchangeMcpAuthorizationCode, extractBearerToken, extractComposioServerId, extractPreviewFields, extractPublicId, fetchComposioServers, fetchSingleComposioServer, flushTraces, formatMessagesForLLM, formatMessagesForLLMContext, generateApiKey, generateId, generateInternalServiceToken, generateServiceToken, getComposioOAuthRedirectUrl, getComposioUserId, getConversationId, getCredentialStoreLookupKeyFromRetrievalParams, getInProcessFetch, getJwtSecret, getLogger, getMetadataFromApiKey, getTracer, getWaitUntil, handleApiError, hasIssuer, hashApiKey, hashAuthenticationHeaders, hashTriggerHeaderValue, initiateMcpOAuthFlow, interpolateTemplate, isApiKeyExpired, isComposioMCPServerAuthenticated, isInternalServiceToken, isSlackUserToken, isThirdPartyMCPServerAuthenticated, isUniqueConstraintError, isZodSchema, loggerFactory, maskApiKey, normalizeDateString, parseEmbeddedJson, parseSSEResponse, preview, problemDetailsSchema, registerAppFetch, retryWithBackoff, setSpanWithError, signJwt, signSlackLinkToken, signSlackUserToken, signTempToken, throwIfUniqueConstraintError, toISODateString, unwrapError, validateApiKey, validateInternalServiceProjectAccess, validateInternalServiceTenantAccess, validateTargetAgent, validateTenantId, validateTriggerHeaderValue, verifyAuthorizationHeader, verifyInternalServiceAuthHeader, verifyInternalServiceToken, verifyJwt, verifyServiceToken, verifySignatureWithConfig, verifySlackLinkToken, verifySlackUserToken, verifyTempToken, verifyTriggerAuth };
|
|
33
|
+
export { ApiKeyGenerationResult, AppCredentialResult, CommonCreateErrorResponses, CommonDeleteErrorResponses, CommonGetErrorResponses, CommonUpdateErrorResponses, CredentialScope, ERROR_DOCS_BASE_URL, ErrorCode, ErrorCodes, ErrorResponse, GenerateInternalServiceTokenParams, GenerateServiceTokenParams, HashedHeaderValue, InternalServiceId, InternalServiceTokenPayload, InternalServices, JsonTransformer, JwtVerifyResult, LLMMessage, LoggerFactoryConfig, McpClient, McpClientOptions, McpOAuthFlowResult, McpSSEConfig, McpServerConfig, McpStreamableHttpConfig, McpTokenExchangeResult, MockLanguageModel, ModelFactory, OAuthConfig, ParsedSSEResponse, PinoLogger, PinoLoggerConfig, PoWError, PoWResult, ProblemDetails, ServiceTokenPayload, SignJwtOptions, SignSlackLinkTokenParams, SignSlackUserTokenParams, SignatureVerificationErrorCode, SignatureVerificationResult, SignedTempToken, SlackAccessTokenPayload, SlackAccessTokenPayloadSchema, SlackLinkIntent, SlackLinkIntentSchema, SlackLinkTokenPayload, SlackLinkTokenPayloadSchema, TempTokenPayload, TriggerAuthResult, VerifyInternalServiceTokenResult, VerifyJwtOptions, VerifyServiceTokenResult, VerifySlackLinkTokenResult, VerifySlackUserTokenResult, _resetWaitUntilCache, activeMcpClients, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, configureComposioMCPServer, convertZodToJsonSchema, convertZodToJsonSchemaWithPreview, createApiError, createMockModel, decodeJwtPayload, detectAuthenticationRequired, errorResponseSchema, errorSchemaFactory, exchangeMcpAuthorizationCode, extractBearerToken, extractComposioServerId, extractPreviewFields, extractPublicId, fetchComposioServers, fetchSingleComposioServer, flushTraces, formatMessagesForLLM, formatMessagesForLLMContext, generateApiKey, generateAppCredential, generateId, generateInternalServiceToken, generateServiceToken, getComposioOAuthRedirectUrl, getComposioUserId, getConversationId, getCredentialStoreLookupKeyFromRetrievalParams, getInProcessFetch, getJwtSecret, getLogger, getMetadataFromApiKey, getPoWErrorMessage, getTracer, getWaitUntil, handleApiError, hasIssuer, hashApiKey, hashAuthenticationHeaders, hashTriggerHeaderValue, initiateMcpOAuthFlow, interpolateTemplate, isApiKeyExpired, isComposioMCPServerAuthenticated, isInternalServiceToken, isPoWEnabled, isSlackUserToken, isThirdPartyMCPServerAuthenticated, isUniqueConstraintError, isZodSchema, loggerFactory, maskApiKey, normalizeDateString, parseEmbeddedJson, parseSSEResponse, preview, problemDetailsSchema, registerAppFetch, retryWithBackoff, sanitizeAppConfig, setSpanWithError, signJwt, signSlackLinkToken, signSlackUserToken, signTempToken, throwIfUniqueConstraintError, toISODateString, unwrapError, validateApiKey, validateInternalServiceProjectAccess, validateInternalServiceTenantAccess, validateOrigin, validateTargetAgent, validateTenantId, validateTriggerHeaderValue, verifyAuthorizationHeader, verifyInternalServiceAuthHeader, verifyInternalServiceToken, verifyJwt, verifyPoW, verifyServiceToken, verifySignatureWithConfig, verifySlackLinkToken, verifySlackUserToken, verifyTempToken, verifyTriggerAuth };
|
package/dist/utils/index.js
CHANGED
|
@@ -5,8 +5,9 @@ import { InternalServices, generateInternalServiceToken, isInternalServiceToken,
|
|
|
5
5
|
import { convertZodToJsonSchema, convertZodToJsonSchemaWithPreview, extractPreviewFields, isZodSchema, preview } from "./schema-conversion.js";
|
|
6
6
|
import { getCredentialStoreLookupKeyFromRetrievalParams } from "./credential-store-utils.js";
|
|
7
7
|
import { generateId, getConversationId } from "./conversations.js";
|
|
8
|
-
import { extractPublicId, generateApiKey, getMetadataFromApiKey, hashApiKey, isApiKeyExpired, maskApiKey, validateApiKey } from "./apiKeys.js";
|
|
8
|
+
import { extractPublicId, generateApiKey, generateAppCredential, getMetadataFromApiKey, hashApiKey, isApiKeyExpired, maskApiKey, sanitizeAppConfig, validateApiKey } from "./apiKeys.js";
|
|
9
9
|
import { normalizeDateString, toISODateString } from "./date.js";
|
|
10
|
+
import { validateOrigin } from "./domain-validation.js";
|
|
10
11
|
import { ERROR_DOCS_BASE_URL, ErrorCode, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, createApiError, errorResponseSchema, errorSchemaFactory, handleApiError, isUniqueConstraintError, problemDetailsSchema, throwIfUniqueConstraintError } from "./error.js";
|
|
11
12
|
import { formatMessagesForLLM, formatMessagesForLLMContext } from "./format-messages.js";
|
|
12
13
|
import { getInProcessFetch, registerAppFetch } from "./in-process-fetch.js";
|
|
@@ -15,6 +16,7 @@ import { parseEmbeddedJson } from "./json-parser.js";
|
|
|
15
16
|
import { McpClient, activeMcpClients } from "./mcp-client.js";
|
|
16
17
|
import { MockLanguageModel, createMockModel } from "./mock-provider.js";
|
|
17
18
|
import { ModelFactory } from "./model-factory.js";
|
|
19
|
+
import { getPoWErrorMessage, isPoWEnabled, verifyPoW } from "./pow.js";
|
|
18
20
|
import { retryWithBackoff } from "./retry.js";
|
|
19
21
|
import { generateServiceToken, validateTargetAgent, validateTenantId, verifyAuthorizationHeader, verifyServiceToken } from "./service-token-auth.js";
|
|
20
22
|
import { SlackLinkIntentSchema, SlackLinkTokenPayloadSchema, signSlackLinkToken, verifySlackLinkToken } from "./slack-link-token.js";
|
|
@@ -29,4 +31,4 @@ import { flushTraces, getTracer, setSpanWithError, unwrapError } from "./tracer-
|
|
|
29
31
|
import { hashAuthenticationHeaders, hashTriggerHeaderValue, validateTriggerHeaderValue, verifySignatureWithConfig, verifyTriggerAuth } from "./trigger-auth.js";
|
|
30
32
|
import { _resetWaitUntilCache, getWaitUntil } from "./wait-until.js";
|
|
31
33
|
|
|
32
|
-
export { ERROR_DOCS_BASE_URL, ErrorCode, InternalServices, JsonTransformer, McpClient, MockLanguageModel, ModelFactory, PinoLogger, SlackAccessTokenPayloadSchema, SlackLinkIntentSchema, SlackLinkTokenPayloadSchema, _resetWaitUntilCache, activeMcpClients, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, configureComposioMCPServer, convertZodToJsonSchema, convertZodToJsonSchemaWithPreview, createApiError, createMockModel, decodeJwtPayload, detectAuthenticationRequired, errorResponseSchema, errorSchemaFactory, exchangeMcpAuthorizationCode, extractBearerToken, extractComposioServerId, extractPreviewFields, extractPublicId, fetchComposioServers, fetchSingleComposioServer, flushTraces, formatMessagesForLLM, formatMessagesForLLMContext, generateApiKey, generateId, generateInternalServiceToken, generateServiceToken, getComposioOAuthRedirectUrl, getComposioUserId, getConversationId, getCredentialStoreLookupKeyFromRetrievalParams, getInProcessFetch, getJwtSecret, getLogger, getMetadataFromApiKey, getTracer, getWaitUntil, handleApiError, hasIssuer, hashApiKey, hashAuthenticationHeaders, hashTriggerHeaderValue, initiateMcpOAuthFlow, interpolateTemplate, isApiKeyExpired, isComposioMCPServerAuthenticated, isInternalServiceToken, isSlackUserToken, isThirdPartyMCPServerAuthenticated, isUniqueConstraintError, isZodSchema, loggerFactory, maskApiKey, normalizeDateString, parseEmbeddedJson, parseSSEResponse, preview, problemDetailsSchema, registerAppFetch, retryWithBackoff, setSpanWithError, signJwt, signSlackLinkToken, signSlackUserToken, signTempToken, throwIfUniqueConstraintError, toISODateString, unwrapError, validateApiKey, validateInternalServiceProjectAccess, validateInternalServiceTenantAccess, validateTargetAgent, validateTenantId, validateTriggerHeaderValue, verifyAuthorizationHeader, verifyInternalServiceAuthHeader, verifyInternalServiceToken, verifyJwt, verifyServiceToken, verifySignatureWithConfig, verifySlackLinkToken, verifySlackUserToken, verifyTempToken, verifyTriggerAuth };
|
|
34
|
+
export { ERROR_DOCS_BASE_URL, ErrorCode, InternalServices, JsonTransformer, McpClient, MockLanguageModel, ModelFactory, PinoLogger, SlackAccessTokenPayloadSchema, SlackLinkIntentSchema, SlackLinkTokenPayloadSchema, _resetWaitUntilCache, activeMcpClients, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, configureComposioMCPServer, convertZodToJsonSchema, convertZodToJsonSchemaWithPreview, createApiError, createMockModel, decodeJwtPayload, detectAuthenticationRequired, errorResponseSchema, errorSchemaFactory, exchangeMcpAuthorizationCode, extractBearerToken, extractComposioServerId, extractPreviewFields, extractPublicId, fetchComposioServers, fetchSingleComposioServer, flushTraces, formatMessagesForLLM, formatMessagesForLLMContext, generateApiKey, generateAppCredential, generateId, generateInternalServiceToken, generateServiceToken, getComposioOAuthRedirectUrl, getComposioUserId, getConversationId, getCredentialStoreLookupKeyFromRetrievalParams, getInProcessFetch, getJwtSecret, getLogger, getMetadataFromApiKey, getPoWErrorMessage, getTracer, getWaitUntil, handleApiError, hasIssuer, hashApiKey, hashAuthenticationHeaders, hashTriggerHeaderValue, initiateMcpOAuthFlow, interpolateTemplate, isApiKeyExpired, isComposioMCPServerAuthenticated, isInternalServiceToken, isPoWEnabled, isSlackUserToken, isThirdPartyMCPServerAuthenticated, isUniqueConstraintError, isZodSchema, loggerFactory, maskApiKey, normalizeDateString, parseEmbeddedJson, parseSSEResponse, preview, problemDetailsSchema, registerAppFetch, retryWithBackoff, sanitizeAppConfig, setSpanWithError, signJwt, signSlackLinkToken, signSlackUserToken, signTempToken, throwIfUniqueConstraintError, toISODateString, unwrapError, validateApiKey, validateInternalServiceProjectAccess, validateInternalServiceTenantAccess, validateOrigin, validateTargetAgent, validateTenantId, validateTriggerHeaderValue, verifyAuthorizationHeader, verifyInternalServiceAuthHeader, verifyInternalServiceToken, verifyJwt, verifyPoW, verifyServiceToken, verifySignatureWithConfig, verifySlackLinkToken, verifySlackUserToken, verifyTempToken, verifyTriggerAuth };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/utils/pow.d.ts
|
|
2
|
+
type PoWError = 'pow_required' | 'pow_invalid' | 'pow_expired';
|
|
3
|
+
type PoWResult = {
|
|
4
|
+
ok: true;
|
|
5
|
+
} | {
|
|
6
|
+
ok: false;
|
|
7
|
+
error: PoWError;
|
|
8
|
+
};
|
|
9
|
+
declare function getPoWErrorMessage(error: PoWError): string;
|
|
10
|
+
declare function isPoWEnabled(hmacSecret: string | undefined): boolean;
|
|
11
|
+
declare function verifyPoW(request: Request, hmacSecret: string | undefined): Promise<PoWResult>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { PoWError, PoWResult, getPoWErrorMessage, isPoWEnabled, verifyPoW };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { verifySolution } from "altcha-lib";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/pow.ts
|
|
4
|
+
const POW_ERROR_MESSAGES = {
|
|
5
|
+
pow_expired: "Proof-of-work challenge has expired. Please request a new challenge.",
|
|
6
|
+
pow_required: "Proof-of-work challenge solution is required.",
|
|
7
|
+
pow_invalid: "Proof-of-work challenge solution is invalid."
|
|
8
|
+
};
|
|
9
|
+
function getPoWErrorMessage(error) {
|
|
10
|
+
return POW_ERROR_MESSAGES[error];
|
|
11
|
+
}
|
|
12
|
+
function isPoWEnabled(hmacSecret) {
|
|
13
|
+
return !!hmacSecret;
|
|
14
|
+
}
|
|
15
|
+
function isChallengeExpired(payload) {
|
|
16
|
+
try {
|
|
17
|
+
const salt = JSON.parse(atob(payload))?.salt;
|
|
18
|
+
if (!salt) return false;
|
|
19
|
+
const expires = new URLSearchParams(salt.split("?")[1] ?? "").get("expires");
|
|
20
|
+
if (!expires) return false;
|
|
21
|
+
return Date.now() / 1e3 > Number(expires);
|
|
22
|
+
} catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async function verifyPoW(request, hmacSecret) {
|
|
27
|
+
if (!hmacSecret) return { ok: true };
|
|
28
|
+
const challengeHeader = request.headers.get("x-inkeep-challenge-solution");
|
|
29
|
+
if (!challengeHeader) return {
|
|
30
|
+
ok: false,
|
|
31
|
+
error: "pow_required"
|
|
32
|
+
};
|
|
33
|
+
if (isChallengeExpired(challengeHeader)) return {
|
|
34
|
+
ok: false,
|
|
35
|
+
error: "pow_expired"
|
|
36
|
+
};
|
|
37
|
+
try {
|
|
38
|
+
if (!await verifySolution(challengeHeader, hmacSecret, false)) return {
|
|
39
|
+
ok: false,
|
|
40
|
+
error: "pow_invalid"
|
|
41
|
+
};
|
|
42
|
+
} catch {
|
|
43
|
+
return {
|
|
44
|
+
ok: false,
|
|
45
|
+
error: "pow_invalid"
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return { ok: true };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
export { getPoWErrorMessage, isPoWEnabled, verifyPoW };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from "@hono/zod-openapi";
|
|
2
|
-
import * as
|
|
2
|
+
import * as drizzle_zod0 from "drizzle-zod";
|
|
3
3
|
import { AnySQLiteTable } from "drizzle-orm/sqlite-core";
|
|
4
4
|
|
|
5
5
|
//#region src/validation/drizzle-schema-helpers.d.ts
|
|
6
|
-
declare function createSelectSchemaWithModifiers<T extends AnySQLiteTable>(table: T, overrides?: Partial<Record<keyof T['_']['columns'], (schema: z.ZodTypeAny) => z.ZodTypeAny>>):
|
|
7
|
-
declare function createInsertSchemaWithModifiers<T extends AnySQLiteTable>(table: T, overrides?: Partial<Record<keyof T['_']['columns'], (schema: z.ZodTypeAny) => z.ZodTypeAny>>):
|
|
6
|
+
declare function createSelectSchemaWithModifiers<T extends AnySQLiteTable>(table: T, overrides?: Partial<Record<keyof T['_']['columns'], (schema: z.ZodTypeAny) => z.ZodTypeAny>>): drizzle_zod0.BuildSchema<"select", T["_"]["columns"], drizzle_zod0.BuildRefine<T["_"]["columns"], undefined>, undefined>;
|
|
7
|
+
declare function createInsertSchemaWithModifiers<T extends AnySQLiteTable>(table: T, overrides?: Partial<Record<keyof T['_']['columns'], (schema: z.ZodTypeAny) => z.ZodTypeAny>>): drizzle_zod0.BuildSchema<"insert", T["_"]["columns"], drizzle_zod0.BuildRefine<Pick<T["_"]["columns"], keyof T["$inferInsert"]>, undefined>, undefined>;
|
|
8
8
|
declare const createSelectSchema: typeof createSelectSchemaWithModifiers;
|
|
9
9
|
declare const createInsertSchema: typeof createInsertSchemaWithModifiers;
|
|
10
10
|
/**
|