@dyrected/core 2.13.5 → 2.14.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/{app-De-3eNn1.d.cts → app-Cp8RudRI.d.cts} +252 -63
- package/dist/{app-De-3eNn1.d.ts → app-Cp8RudRI.d.ts} +252 -63
- package/dist/index.cjs +46 -5
- package/dist/index.d.cts +139 -25
- package/dist/index.d.ts +139 -25
- package/dist/index.js +40 -5
- package/dist/server.cjs +70 -9
- package/dist/server.d.cts +93 -3
- package/dist/server.d.ts +93 -3
- package/dist/server.js +46 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1775,6 +1775,11 @@ var require_Jexl = __commonJS({
|
|
|
1775
1775
|
}
|
|
1776
1776
|
});
|
|
1777
1777
|
|
|
1778
|
+
// src/types/readonly-fix.ts
|
|
1779
|
+
function asCollection(config) {
|
|
1780
|
+
return config;
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1778
1783
|
// src/types/workflows.ts
|
|
1779
1784
|
var LIFECYCLE_EVENT_NAMES = [
|
|
1780
1785
|
"revision.created",
|
|
@@ -1787,6 +1792,21 @@ var LIFECYCLE_EVENT_NAMES = [
|
|
|
1787
1792
|
function defineView(config) {
|
|
1788
1793
|
return config;
|
|
1789
1794
|
}
|
|
1795
|
+
function defineTableView(config) {
|
|
1796
|
+
return config;
|
|
1797
|
+
}
|
|
1798
|
+
function defineKanbanView(config) {
|
|
1799
|
+
return config;
|
|
1800
|
+
}
|
|
1801
|
+
function defineCalendarView(config) {
|
|
1802
|
+
return config;
|
|
1803
|
+
}
|
|
1804
|
+
function defineGanttView(config) {
|
|
1805
|
+
return config;
|
|
1806
|
+
}
|
|
1807
|
+
function defineCardsView(config) {
|
|
1808
|
+
return config;
|
|
1809
|
+
}
|
|
1790
1810
|
function defineAction(config) {
|
|
1791
1811
|
return config;
|
|
1792
1812
|
}
|
|
@@ -3540,7 +3560,7 @@ function normalizeConfig(config) {
|
|
|
3540
3560
|
name: "roles",
|
|
3541
3561
|
type: "select",
|
|
3542
3562
|
label: "Roles",
|
|
3543
|
-
defaultValue:
|
|
3563
|
+
defaultValue: "viewer",
|
|
3544
3564
|
options: [
|
|
3545
3565
|
{ value: "admin", label: "Admin" },
|
|
3546
3566
|
{ value: "editor", label: "Editor" },
|
|
@@ -6300,7 +6320,7 @@ function sanitizeDocForAI(options) {
|
|
|
6300
6320
|
// src/index.ts
|
|
6301
6321
|
import { z } from "zod";
|
|
6302
6322
|
function defineCollection(config) {
|
|
6303
|
-
return config;
|
|
6323
|
+
return asCollection(config);
|
|
6304
6324
|
}
|
|
6305
6325
|
function defineGlobal(config) {
|
|
6306
6326
|
return config;
|
|
@@ -6328,17 +6348,26 @@ var defineTimeField = createFieldDefiner("time");
|
|
|
6328
6348
|
var defineSelectField = createFieldDefiner("select");
|
|
6329
6349
|
var defineMultiSelectField = createFieldDefiner("multiSelect");
|
|
6330
6350
|
var defineRadioField = createFieldDefiner("radio");
|
|
6331
|
-
var defineRelationshipField = createFieldDefiner("relationship");
|
|
6332
6351
|
var defineArrayField = createFieldDefiner("array");
|
|
6333
6352
|
var defineObjectField = createFieldDefiner("object");
|
|
6334
6353
|
var defineJsonField = createFieldDefiner("json");
|
|
6335
6354
|
var defineBlocksField = createFieldDefiner("blocks");
|
|
6336
|
-
var defineImageField = createFieldDefiner("image");
|
|
6337
6355
|
var defineEmailField = createFieldDefiner("email");
|
|
6338
6356
|
var defineUrlField = createFieldDefiner("url");
|
|
6339
6357
|
var defineIconField = createFieldDefiner("icon");
|
|
6340
|
-
var defineJoinField = createFieldDefiner("join");
|
|
6341
6358
|
var defineRowField = createFieldDefiner("row");
|
|
6359
|
+
var _defineRelationshipFieldBase = createFieldDefiner("relationship");
|
|
6360
|
+
var _defineImageFieldBase = createFieldDefiner("image");
|
|
6361
|
+
var _defineJoinFieldBase = createFieldDefiner("join");
|
|
6362
|
+
function defineRelationshipField(config) {
|
|
6363
|
+
return _defineRelationshipFieldBase(config);
|
|
6364
|
+
}
|
|
6365
|
+
function defineImageField(config) {
|
|
6366
|
+
return _defineImageFieldBase(config);
|
|
6367
|
+
}
|
|
6368
|
+
function defineJoinField(config) {
|
|
6369
|
+
return _defineJoinFieldBase(config);
|
|
6370
|
+
}
|
|
6342
6371
|
function defineTab(args) {
|
|
6343
6372
|
return args.fields.map((field) => ({
|
|
6344
6373
|
...field,
|
|
@@ -6363,6 +6392,7 @@ export {
|
|
|
6363
6392
|
WORKFLOW_HISTORY_COLLECTION,
|
|
6364
6393
|
abs,
|
|
6365
6394
|
addDays,
|
|
6395
|
+
asCollection,
|
|
6366
6396
|
assertValidAdminConditionsInConfig,
|
|
6367
6397
|
assertValidDeclarativeAccessInConfig,
|
|
6368
6398
|
assertValidDeclarativeHookExpression,
|
|
@@ -6391,17 +6421,21 @@ export {
|
|
|
6391
6421
|
defineBlock,
|
|
6392
6422
|
defineBlocksField,
|
|
6393
6423
|
defineBooleanField,
|
|
6424
|
+
defineCalendarView,
|
|
6425
|
+
defineCardsView,
|
|
6394
6426
|
defineCollection,
|
|
6395
6427
|
defineConfig,
|
|
6396
6428
|
defineDateField,
|
|
6397
6429
|
defineDateTimeField,
|
|
6398
6430
|
defineEmailField,
|
|
6399
6431
|
defineField,
|
|
6432
|
+
defineGanttView,
|
|
6400
6433
|
defineGlobal,
|
|
6401
6434
|
defineIconField,
|
|
6402
6435
|
defineImageField,
|
|
6403
6436
|
defineJoinField,
|
|
6404
6437
|
defineJsonField,
|
|
6438
|
+
defineKanbanView,
|
|
6405
6439
|
defineMultiSelectField,
|
|
6406
6440
|
defineNumberField,
|
|
6407
6441
|
defineObjectField,
|
|
@@ -6412,6 +6446,7 @@ export {
|
|
|
6412
6446
|
defineRowField,
|
|
6413
6447
|
defineSelectField,
|
|
6414
6448
|
defineTab,
|
|
6449
|
+
defineTableView,
|
|
6415
6450
|
defineTextField,
|
|
6416
6451
|
defineTextareaField,
|
|
6417
6452
|
defineTimeField,
|
package/dist/server.cjs
CHANGED
|
@@ -3948,8 +3948,12 @@ var server_exports = {};
|
|
|
3948
3948
|
__export(server_exports, {
|
|
3949
3949
|
AIAgent: () => AIAgent,
|
|
3950
3950
|
AIController: () => AIController,
|
|
3951
|
+
AUTH_SESSIONS_COLLECTION: () => AUTH_SESSIONS_COLLECTION,
|
|
3951
3952
|
AuthController: () => AuthController,
|
|
3952
3953
|
CollectionController: () => CollectionController,
|
|
3954
|
+
DEFAULT_LOCK_TIME_MS: () => DEFAULT_LOCK_TIME_MS,
|
|
3955
|
+
DEFAULT_MAX_LOGIN_ATTEMPTS: () => DEFAULT_MAX_LOGIN_ATTEMPTS,
|
|
3956
|
+
DEFAULT_SESSION_EXPIRY: () => DEFAULT_SESSION_EXPIRY,
|
|
3953
3957
|
EmbeddingService: () => EmbeddingService,
|
|
3954
3958
|
GlobalController: () => GlobalController,
|
|
3955
3959
|
InMemoryRateLimitStore: () => InMemoryRateLimitStore,
|
|
@@ -3960,7 +3964,11 @@ __export(server_exports, {
|
|
|
3960
3964
|
attachRequestMetrics: () => attachRequestMetrics,
|
|
3961
3965
|
bindObservabilityRuntime: () => bindObservabilityRuntime,
|
|
3962
3966
|
buildDyrectedSystemPrompt: () => buildDyrectedSystemPrompt,
|
|
3967
|
+
buildInviteEmail: () => buildInviteEmail,
|
|
3968
|
+
buildPasswordChangedEmail: () => buildPasswordChangedEmail,
|
|
3963
3969
|
buildRequestLogger: () => buildRequestLogger,
|
|
3970
|
+
buildResetPasswordEmail: () => buildResetPasswordEmail,
|
|
3971
|
+
buildWelcomeEmail: () => buildWelcomeEmail,
|
|
3964
3972
|
captureRequestBody: () => captureRequestBody,
|
|
3965
3973
|
chunkText: () => chunkText,
|
|
3966
3974
|
cosineSimilarity: () => cosineSimilarity,
|
|
@@ -3968,26 +3976,41 @@ __export(server_exports, {
|
|
|
3968
3976
|
createDyrectedApp: () => createDyrectedApp,
|
|
3969
3977
|
createObservabilityRuntime: () => createObservabilityRuntime,
|
|
3970
3978
|
createRequestSpan: () => createRequestSpan,
|
|
3979
|
+
decodeCollectionToken: () => decodeCollectionToken,
|
|
3971
3980
|
endRequestSpan: () => endRequestSpan,
|
|
3972
3981
|
estimateTokens: () => estimateTokens,
|
|
3973
3982
|
extractTextFromDoc: () => extractTextFromDoc,
|
|
3974
3983
|
formatAIErrorMessage: () => formatAIErrorMessage,
|
|
3975
3984
|
getAIModel: () => getAIModel,
|
|
3985
|
+
getAuthSession: () => getAuthSession,
|
|
3976
3986
|
getConfigLogger: () => getConfigLogger,
|
|
3977
3987
|
getEmbeddingModel: () => getEmbeddingModel,
|
|
3988
|
+
getLockedUntilMs: () => getLockedUntilMs,
|
|
3978
3989
|
getObservabilityRuntime: () => getObservabilityRuntime,
|
|
3979
3990
|
getRequestLogger: () => getRequestLogger,
|
|
3980
3991
|
hashContent: () => hashContent,
|
|
3992
|
+
hashPassword: () => hashPassword,
|
|
3993
|
+
isAuthSessionActive: () => isAuthSessionActive,
|
|
3994
|
+
issueAuthSessionToken: () => issueAuthSessionToken,
|
|
3981
3995
|
normalizeFieldValue: () => normalizeFieldValue,
|
|
3982
3996
|
redactBody: () => redactBody,
|
|
3983
3997
|
redactHeaders: () => redactHeaders,
|
|
3984
3998
|
registerRoutes: () => registerRoutes,
|
|
3985
3999
|
renderPrometheusMetrics: () => renderPrometheusMetrics,
|
|
4000
|
+
resolveAuthLockoutConfig: () => resolveAuthLockoutConfig,
|
|
3986
4001
|
resolveObservabilityConfig: () => resolveObservabilityConfig,
|
|
4002
|
+
resolveSessionTokenExpiry: () => resolveSessionTokenExpiry,
|
|
4003
|
+
revokeAllAuthSessions: () => revokeAllAuthSessions,
|
|
4004
|
+
revokeAuthSession: () => revokeAuthSession,
|
|
4005
|
+
sendEmail: () => sendEmail,
|
|
3987
4006
|
serializeDetailForApi: () => serializeDetailForApi,
|
|
3988
4007
|
serializeViewForApi: () => serializeViewForApi,
|
|
3989
4008
|
shouldSampleRequest: () => shouldSampleRequest,
|
|
3990
|
-
|
|
4009
|
+
signCollectionToken: () => signCollectionToken,
|
|
4010
|
+
touchAuthSession: () => touchAuthSession,
|
|
4011
|
+
validatePayloadAgainstFields: () => validatePayloadAgainstFields,
|
|
4012
|
+
verifyCollectionToken: () => verifyCollectionToken,
|
|
4013
|
+
verifyPassword: () => verifyPassword
|
|
3991
4014
|
});
|
|
3992
4015
|
module.exports = __toCommonJS(server_exports);
|
|
3993
4016
|
|
|
@@ -4829,6 +4852,14 @@ function getSecret() {
|
|
|
4829
4852
|
return new TextEncoder().encode(secret);
|
|
4830
4853
|
}
|
|
4831
4854
|
var DEFAULT_EXPIRY = "7d";
|
|
4855
|
+
var DEFAULT_SESSION_EXPIRY = DEFAULT_EXPIRY;
|
|
4856
|
+
function resolveSessionTokenExpiry(collection) {
|
|
4857
|
+
const auth = collection.auth;
|
|
4858
|
+
if (auth && typeof auth === "object" && typeof auth.tokenExpiration === "string" && auth.tokenExpiration.length > 0) {
|
|
4859
|
+
return auth.tokenExpiration;
|
|
4860
|
+
}
|
|
4861
|
+
return DEFAULT_SESSION_EXPIRY;
|
|
4862
|
+
}
|
|
4832
4863
|
async function signCollectionToken(payload, expiresIn = DEFAULT_EXPIRY) {
|
|
4833
4864
|
return new import_jose.SignJWT({ ...payload }).setProtectedHeader({ alg: "HS256" }).setIssuedAt().setExpirationTime(expiresIn).sign(getSecret());
|
|
4834
4865
|
}
|
|
@@ -9680,6 +9711,7 @@ var AuthController = class {
|
|
|
9680
9711
|
userId: user.id,
|
|
9681
9712
|
email: user.email,
|
|
9682
9713
|
collection: this.collection.slug,
|
|
9714
|
+
expiresIn: resolveSessionTokenExpiry(this.collection),
|
|
9683
9715
|
ip: c.get("clientIp"),
|
|
9684
9716
|
authSource: "local"
|
|
9685
9717
|
});
|
|
@@ -9771,6 +9803,7 @@ var AuthController = class {
|
|
|
9771
9803
|
userId: user.id,
|
|
9772
9804
|
email: user.email,
|
|
9773
9805
|
collection: this.collection.slug,
|
|
9806
|
+
expiresIn: resolveSessionTokenExpiry(this.collection),
|
|
9774
9807
|
ip: c.get("clientIp"),
|
|
9775
9808
|
authSource: "local"
|
|
9776
9809
|
});
|
|
@@ -9861,12 +9894,15 @@ var AuthController = class {
|
|
|
9861
9894
|
}
|
|
9862
9895
|
const tokenPayload = c.get("authTokenPayload");
|
|
9863
9896
|
if (tokenPayload?.sid) {
|
|
9864
|
-
const token2 = await signCollectionToken(
|
|
9865
|
-
|
|
9866
|
-
|
|
9867
|
-
|
|
9868
|
-
|
|
9869
|
-
|
|
9897
|
+
const token2 = await signCollectionToken(
|
|
9898
|
+
{
|
|
9899
|
+
sub: requestUser.sub,
|
|
9900
|
+
email: requestUser.email,
|
|
9901
|
+
collection: this.collection.slug,
|
|
9902
|
+
sid: tokenPayload.sid
|
|
9903
|
+
},
|
|
9904
|
+
resolveSessionTokenExpiry(this.collection)
|
|
9905
|
+
);
|
|
9870
9906
|
return c.json({ token: token2 });
|
|
9871
9907
|
}
|
|
9872
9908
|
const token = await issueAuthSessionToken({
|
|
@@ -10128,6 +10164,7 @@ var AuthController = class {
|
|
|
10128
10164
|
userId: user.id,
|
|
10129
10165
|
email: inviteeEmail,
|
|
10130
10166
|
collection: this.collection.slug,
|
|
10167
|
+
expiresIn: resolveSessionTokenExpiry(this.collection),
|
|
10131
10168
|
ip: c.get("clientIp"),
|
|
10132
10169
|
authSource: "local"
|
|
10133
10170
|
});
|
|
@@ -10380,6 +10417,7 @@ var AdminAuthController = class {
|
|
|
10380
10417
|
userId: user.id,
|
|
10381
10418
|
email: user.email,
|
|
10382
10419
|
collection: adminCollection.slug,
|
|
10420
|
+
expiresIn: resolveSessionTokenExpiry(adminCollection),
|
|
10383
10421
|
providerId: provider.id,
|
|
10384
10422
|
authSource: "external",
|
|
10385
10423
|
ip: c.get("clientIp")
|
|
@@ -14669,7 +14707,7 @@ function normalizeConfig(config) {
|
|
|
14669
14707
|
name: "roles",
|
|
14670
14708
|
type: "select",
|
|
14671
14709
|
label: "Roles",
|
|
14672
|
-
defaultValue:
|
|
14710
|
+
defaultValue: "viewer",
|
|
14673
14711
|
options: [
|
|
14674
14712
|
{ value: "admin", label: "Admin" },
|
|
14675
14713
|
{ value: "editor", label: "Editor" },
|
|
@@ -15120,8 +15158,12 @@ init_embedding_service();
|
|
|
15120
15158
|
0 && (module.exports = {
|
|
15121
15159
|
AIAgent,
|
|
15122
15160
|
AIController,
|
|
15161
|
+
AUTH_SESSIONS_COLLECTION,
|
|
15123
15162
|
AuthController,
|
|
15124
15163
|
CollectionController,
|
|
15164
|
+
DEFAULT_LOCK_TIME_MS,
|
|
15165
|
+
DEFAULT_MAX_LOGIN_ATTEMPTS,
|
|
15166
|
+
DEFAULT_SESSION_EXPIRY,
|
|
15125
15167
|
EmbeddingService,
|
|
15126
15168
|
GlobalController,
|
|
15127
15169
|
InMemoryRateLimitStore,
|
|
@@ -15132,7 +15174,11 @@ init_embedding_service();
|
|
|
15132
15174
|
attachRequestMetrics,
|
|
15133
15175
|
bindObservabilityRuntime,
|
|
15134
15176
|
buildDyrectedSystemPrompt,
|
|
15177
|
+
buildInviteEmail,
|
|
15178
|
+
buildPasswordChangedEmail,
|
|
15135
15179
|
buildRequestLogger,
|
|
15180
|
+
buildResetPasswordEmail,
|
|
15181
|
+
buildWelcomeEmail,
|
|
15136
15182
|
captureRequestBody,
|
|
15137
15183
|
chunkText,
|
|
15138
15184
|
cosineSimilarity,
|
|
@@ -15140,24 +15186,39 @@ init_embedding_service();
|
|
|
15140
15186
|
createDyrectedApp,
|
|
15141
15187
|
createObservabilityRuntime,
|
|
15142
15188
|
createRequestSpan,
|
|
15189
|
+
decodeCollectionToken,
|
|
15143
15190
|
endRequestSpan,
|
|
15144
15191
|
estimateTokens,
|
|
15145
15192
|
extractTextFromDoc,
|
|
15146
15193
|
formatAIErrorMessage,
|
|
15147
15194
|
getAIModel,
|
|
15195
|
+
getAuthSession,
|
|
15148
15196
|
getConfigLogger,
|
|
15149
15197
|
getEmbeddingModel,
|
|
15198
|
+
getLockedUntilMs,
|
|
15150
15199
|
getObservabilityRuntime,
|
|
15151
15200
|
getRequestLogger,
|
|
15152
15201
|
hashContent,
|
|
15202
|
+
hashPassword,
|
|
15203
|
+
isAuthSessionActive,
|
|
15204
|
+
issueAuthSessionToken,
|
|
15153
15205
|
normalizeFieldValue,
|
|
15154
15206
|
redactBody,
|
|
15155
15207
|
redactHeaders,
|
|
15156
15208
|
registerRoutes,
|
|
15157
15209
|
renderPrometheusMetrics,
|
|
15210
|
+
resolveAuthLockoutConfig,
|
|
15158
15211
|
resolveObservabilityConfig,
|
|
15212
|
+
resolveSessionTokenExpiry,
|
|
15213
|
+
revokeAllAuthSessions,
|
|
15214
|
+
revokeAuthSession,
|
|
15215
|
+
sendEmail,
|
|
15159
15216
|
serializeDetailForApi,
|
|
15160
15217
|
serializeViewForApi,
|
|
15161
15218
|
shouldSampleRequest,
|
|
15162
|
-
|
|
15219
|
+
signCollectionToken,
|
|
15220
|
+
touchAuthSession,
|
|
15221
|
+
validatePayloadAgainstFields,
|
|
15222
|
+
verifyCollectionToken,
|
|
15223
|
+
verifyPassword
|
|
15163
15224
|
});
|
package/dist/server.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { J as DyrectedContext, D as DyrectedConfig, C as CollectionConfig, G as GlobalConfig,
|
|
2
|
-
export {
|
|
1
|
+
import { J as DyrectedContext, D as DyrectedConfig, C as CollectionConfig, G as GlobalConfig, bj as DatabaseAdapter, b as AuthenticatedUser, bE as DyrectedAIContext, al as AIThread, ah as AIMessage, cu as RAGSearchResult, ak as AIRateLimitStore, aj as AIRateLimitResult } from './app-Cp8RudRI.cjs';
|
|
2
|
+
export { d8 as CollectionTokenPayload, d9 as DEFAULT_SESSION_EXPIRY, da as DyrectedObservabilityRuntime, db as RequestBodyCapture, dc as RequestTraceContext, dd as ResolvedObservabilityConfig, de as attachRequestMetrics, df as bindObservabilityRuntime, dg as buildRequestLogger, dh as captureRequestBody, di as createDyrectedApp, dj as createObservabilityRuntime, dk as createRequestSpan, dl as decodeCollectionToken, dm as endRequestSpan, dn as getConfigLogger, dp as getObservabilityRuntime, dq as getRequestLogger, dr as redactBody, ds as redactHeaders, dt as renderPrometheusMetrics, du as resolveObservabilityConfig, dv as resolveSessionTokenExpiry, dw as shouldSampleRequest, dx as signCollectionToken, dy as verifyCollectionToken } from './app-Cp8RudRI.cjs';
|
|
3
3
|
import * as hono from 'hono';
|
|
4
4
|
import { Hono, Context, Next } from 'hono';
|
|
5
5
|
import * as hono_utils_http_status from 'hono/utils/http-status';
|
|
@@ -434,6 +434,96 @@ declare class AIController {
|
|
|
434
434
|
}, hono_utils_http_status.ContentfulStatusCode, "json">>;
|
|
435
435
|
}
|
|
436
436
|
|
|
437
|
+
declare const AUTH_SESSIONS_COLLECTION = "__auth_sessions";
|
|
438
|
+
interface AuthSessionRecord {
|
|
439
|
+
id: string;
|
|
440
|
+
userId: string;
|
|
441
|
+
email: string;
|
|
442
|
+
collection: string;
|
|
443
|
+
authSource?: 'local' | 'external';
|
|
444
|
+
providerId?: string;
|
|
445
|
+
lastIp?: string;
|
|
446
|
+
createdAt?: string;
|
|
447
|
+
updatedAt?: string;
|
|
448
|
+
lastSeenAt?: string;
|
|
449
|
+
expiresAt?: string | null;
|
|
450
|
+
revokedAt?: string | null;
|
|
451
|
+
}
|
|
452
|
+
interface IssueAuthSessionArgs {
|
|
453
|
+
config: DyrectedConfig;
|
|
454
|
+
userId: string;
|
|
455
|
+
email: string;
|
|
456
|
+
collection: string;
|
|
457
|
+
expiresIn?: string;
|
|
458
|
+
authSource?: 'local' | 'external';
|
|
459
|
+
providerId?: string;
|
|
460
|
+
ip?: string;
|
|
461
|
+
}
|
|
462
|
+
declare function issueAuthSessionToken(args: IssueAuthSessionArgs): Promise<string>;
|
|
463
|
+
declare function getAuthSession(config: DyrectedConfig, sessionId: string): Promise<AuthSessionRecord | null>;
|
|
464
|
+
declare function isAuthSessionActive(session: AuthSessionRecord | null | undefined): session is AuthSessionRecord;
|
|
465
|
+
declare function touchAuthSession(config: DyrectedConfig, sessionId: string, args: {
|
|
466
|
+
ip?: string;
|
|
467
|
+
}): Promise<void>;
|
|
468
|
+
declare function revokeAuthSession(config: DyrectedConfig, sessionId: string): Promise<void>;
|
|
469
|
+
declare function revokeAllAuthSessions(config: DyrectedConfig, args: {
|
|
470
|
+
userId: string;
|
|
471
|
+
collection: string;
|
|
472
|
+
}): Promise<number>;
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Hash a plain-text password using scrypt.
|
|
476
|
+
* Returns a `salt:hash` string safe to store in the database.
|
|
477
|
+
*/
|
|
478
|
+
declare function hashPassword(plain: string): Promise<string>;
|
|
479
|
+
/**
|
|
480
|
+
* Verify a plain-text password against a stored `salt:hash` string.
|
|
481
|
+
*/
|
|
482
|
+
declare function verifyPassword(plain: string, stored: string): Promise<boolean>;
|
|
483
|
+
|
|
484
|
+
declare const DEFAULT_MAX_LOGIN_ATTEMPTS = 5;
|
|
485
|
+
declare const DEFAULT_LOCK_TIME_MS: number;
|
|
486
|
+
type ResolvedAuthLockoutConfig = {
|
|
487
|
+
enabled: boolean;
|
|
488
|
+
maxLoginAttempts: number;
|
|
489
|
+
lockTime: number;
|
|
490
|
+
};
|
|
491
|
+
declare function resolveAuthLockoutConfig(collection: CollectionConfig): ResolvedAuthLockoutConfig;
|
|
492
|
+
declare function getLockedUntilMs(value: unknown): number | null;
|
|
493
|
+
|
|
494
|
+
declare function sendEmail(config: DyrectedConfig, payload: {
|
|
495
|
+
to: string;
|
|
496
|
+
subject: string;
|
|
497
|
+
html: string;
|
|
498
|
+
}): Promise<void>;
|
|
499
|
+
declare function buildWelcomeEmail(config: DyrectedConfig, args: {
|
|
500
|
+
email: string;
|
|
501
|
+
}): {
|
|
502
|
+
subject: string;
|
|
503
|
+
html: string;
|
|
504
|
+
};
|
|
505
|
+
declare function buildInviteEmail(config: DyrectedConfig, args: {
|
|
506
|
+
token: string;
|
|
507
|
+
invitedByEmail?: string;
|
|
508
|
+
url?: string;
|
|
509
|
+
}): {
|
|
510
|
+
subject: string;
|
|
511
|
+
html: string;
|
|
512
|
+
};
|
|
513
|
+
declare function buildResetPasswordEmail(config: DyrectedConfig, args: {
|
|
514
|
+
token: string;
|
|
515
|
+
url?: string;
|
|
516
|
+
}): {
|
|
517
|
+
subject: string;
|
|
518
|
+
html: string;
|
|
519
|
+
};
|
|
520
|
+
declare function buildPasswordChangedEmail(config: DyrectedConfig, args: {
|
|
521
|
+
email: string;
|
|
522
|
+
}): {
|
|
523
|
+
subject: string;
|
|
524
|
+
html: string;
|
|
525
|
+
};
|
|
526
|
+
|
|
437
527
|
declare function getAIModel(config?: DyrectedConfig): LanguageModel;
|
|
438
528
|
declare function formatAIErrorMessage(error: any): string;
|
|
439
529
|
declare function buildDyrectedSystemPrompt(context: DyrectedAIContext): string;
|
|
@@ -648,4 +738,4 @@ declare class InMemoryRateLimitStore implements AIRateLimitStore {
|
|
|
648
738
|
}
|
|
649
739
|
declare function aiRateLimit(config?: DyrectedConfig): (c: Context<DyrectedContext>, next: Next) => Promise<void>;
|
|
650
740
|
|
|
651
|
-
export { AIAgent, type AIAgentOptions, AIController, AuthController, type ChunkOptions, type ChunkResult, CollectionController, type DeleteDocumentChunksOptions, DyrectedContext, EmbeddingService, GlobalController, InMemoryRateLimitStore, type IndexDocumentOptions, MediaController, PreviewController, type RAGSearchOptions, RAGService, type ReindexAllOptions, type ReindexCollectionOptions, aiRateLimit, buildDyrectedSystemPrompt, chunkText, cosineSimilarity, createDyrectedAITools, estimateTokens, extractTextFromDoc, formatAIErrorMessage, getAIModel, getEmbeddingModel, hashContent, normalizeFieldValue, registerRoutes, serializeDetailForApi, serializeViewForApi, validatePayloadAgainstFields };
|
|
741
|
+
export { AIAgent, type AIAgentOptions, AIController, AUTH_SESSIONS_COLLECTION, AuthController, type AuthSessionRecord, type ChunkOptions, type ChunkResult, CollectionController, DEFAULT_LOCK_TIME_MS, DEFAULT_MAX_LOGIN_ATTEMPTS, type DeleteDocumentChunksOptions, DyrectedContext, EmbeddingService, GlobalController, InMemoryRateLimitStore, type IndexDocumentOptions, MediaController, PreviewController, type RAGSearchOptions, RAGService, type ReindexAllOptions, type ReindexCollectionOptions, type ResolvedAuthLockoutConfig, aiRateLimit, buildDyrectedSystemPrompt, buildInviteEmail, buildPasswordChangedEmail, buildResetPasswordEmail, buildWelcomeEmail, chunkText, cosineSimilarity, createDyrectedAITools, estimateTokens, extractTextFromDoc, formatAIErrorMessage, getAIModel, getAuthSession, getEmbeddingModel, getLockedUntilMs, hashContent, hashPassword, isAuthSessionActive, issueAuthSessionToken, normalizeFieldValue, registerRoutes, resolveAuthLockoutConfig, revokeAllAuthSessions, revokeAuthSession, sendEmail, serializeDetailForApi, serializeViewForApi, touchAuthSession, validatePayloadAgainstFields, verifyPassword };
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { J as DyrectedContext, D as DyrectedConfig, C as CollectionConfig, G as GlobalConfig,
|
|
2
|
-
export {
|
|
1
|
+
import { J as DyrectedContext, D as DyrectedConfig, C as CollectionConfig, G as GlobalConfig, bj as DatabaseAdapter, b as AuthenticatedUser, bE as DyrectedAIContext, al as AIThread, ah as AIMessage, cu as RAGSearchResult, ak as AIRateLimitStore, aj as AIRateLimitResult } from './app-Cp8RudRI.js';
|
|
2
|
+
export { d8 as CollectionTokenPayload, d9 as DEFAULT_SESSION_EXPIRY, da as DyrectedObservabilityRuntime, db as RequestBodyCapture, dc as RequestTraceContext, dd as ResolvedObservabilityConfig, de as attachRequestMetrics, df as bindObservabilityRuntime, dg as buildRequestLogger, dh as captureRequestBody, di as createDyrectedApp, dj as createObservabilityRuntime, dk as createRequestSpan, dl as decodeCollectionToken, dm as endRequestSpan, dn as getConfigLogger, dp as getObservabilityRuntime, dq as getRequestLogger, dr as redactBody, ds as redactHeaders, dt as renderPrometheusMetrics, du as resolveObservabilityConfig, dv as resolveSessionTokenExpiry, dw as shouldSampleRequest, dx as signCollectionToken, dy as verifyCollectionToken } from './app-Cp8RudRI.js';
|
|
3
3
|
import * as hono from 'hono';
|
|
4
4
|
import { Hono, Context, Next } from 'hono';
|
|
5
5
|
import * as hono_utils_http_status from 'hono/utils/http-status';
|
|
@@ -434,6 +434,96 @@ declare class AIController {
|
|
|
434
434
|
}, hono_utils_http_status.ContentfulStatusCode, "json">>;
|
|
435
435
|
}
|
|
436
436
|
|
|
437
|
+
declare const AUTH_SESSIONS_COLLECTION = "__auth_sessions";
|
|
438
|
+
interface AuthSessionRecord {
|
|
439
|
+
id: string;
|
|
440
|
+
userId: string;
|
|
441
|
+
email: string;
|
|
442
|
+
collection: string;
|
|
443
|
+
authSource?: 'local' | 'external';
|
|
444
|
+
providerId?: string;
|
|
445
|
+
lastIp?: string;
|
|
446
|
+
createdAt?: string;
|
|
447
|
+
updatedAt?: string;
|
|
448
|
+
lastSeenAt?: string;
|
|
449
|
+
expiresAt?: string | null;
|
|
450
|
+
revokedAt?: string | null;
|
|
451
|
+
}
|
|
452
|
+
interface IssueAuthSessionArgs {
|
|
453
|
+
config: DyrectedConfig;
|
|
454
|
+
userId: string;
|
|
455
|
+
email: string;
|
|
456
|
+
collection: string;
|
|
457
|
+
expiresIn?: string;
|
|
458
|
+
authSource?: 'local' | 'external';
|
|
459
|
+
providerId?: string;
|
|
460
|
+
ip?: string;
|
|
461
|
+
}
|
|
462
|
+
declare function issueAuthSessionToken(args: IssueAuthSessionArgs): Promise<string>;
|
|
463
|
+
declare function getAuthSession(config: DyrectedConfig, sessionId: string): Promise<AuthSessionRecord | null>;
|
|
464
|
+
declare function isAuthSessionActive(session: AuthSessionRecord | null | undefined): session is AuthSessionRecord;
|
|
465
|
+
declare function touchAuthSession(config: DyrectedConfig, sessionId: string, args: {
|
|
466
|
+
ip?: string;
|
|
467
|
+
}): Promise<void>;
|
|
468
|
+
declare function revokeAuthSession(config: DyrectedConfig, sessionId: string): Promise<void>;
|
|
469
|
+
declare function revokeAllAuthSessions(config: DyrectedConfig, args: {
|
|
470
|
+
userId: string;
|
|
471
|
+
collection: string;
|
|
472
|
+
}): Promise<number>;
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Hash a plain-text password using scrypt.
|
|
476
|
+
* Returns a `salt:hash` string safe to store in the database.
|
|
477
|
+
*/
|
|
478
|
+
declare function hashPassword(plain: string): Promise<string>;
|
|
479
|
+
/**
|
|
480
|
+
* Verify a plain-text password against a stored `salt:hash` string.
|
|
481
|
+
*/
|
|
482
|
+
declare function verifyPassword(plain: string, stored: string): Promise<boolean>;
|
|
483
|
+
|
|
484
|
+
declare const DEFAULT_MAX_LOGIN_ATTEMPTS = 5;
|
|
485
|
+
declare const DEFAULT_LOCK_TIME_MS: number;
|
|
486
|
+
type ResolvedAuthLockoutConfig = {
|
|
487
|
+
enabled: boolean;
|
|
488
|
+
maxLoginAttempts: number;
|
|
489
|
+
lockTime: number;
|
|
490
|
+
};
|
|
491
|
+
declare function resolveAuthLockoutConfig(collection: CollectionConfig): ResolvedAuthLockoutConfig;
|
|
492
|
+
declare function getLockedUntilMs(value: unknown): number | null;
|
|
493
|
+
|
|
494
|
+
declare function sendEmail(config: DyrectedConfig, payload: {
|
|
495
|
+
to: string;
|
|
496
|
+
subject: string;
|
|
497
|
+
html: string;
|
|
498
|
+
}): Promise<void>;
|
|
499
|
+
declare function buildWelcomeEmail(config: DyrectedConfig, args: {
|
|
500
|
+
email: string;
|
|
501
|
+
}): {
|
|
502
|
+
subject: string;
|
|
503
|
+
html: string;
|
|
504
|
+
};
|
|
505
|
+
declare function buildInviteEmail(config: DyrectedConfig, args: {
|
|
506
|
+
token: string;
|
|
507
|
+
invitedByEmail?: string;
|
|
508
|
+
url?: string;
|
|
509
|
+
}): {
|
|
510
|
+
subject: string;
|
|
511
|
+
html: string;
|
|
512
|
+
};
|
|
513
|
+
declare function buildResetPasswordEmail(config: DyrectedConfig, args: {
|
|
514
|
+
token: string;
|
|
515
|
+
url?: string;
|
|
516
|
+
}): {
|
|
517
|
+
subject: string;
|
|
518
|
+
html: string;
|
|
519
|
+
};
|
|
520
|
+
declare function buildPasswordChangedEmail(config: DyrectedConfig, args: {
|
|
521
|
+
email: string;
|
|
522
|
+
}): {
|
|
523
|
+
subject: string;
|
|
524
|
+
html: string;
|
|
525
|
+
};
|
|
526
|
+
|
|
437
527
|
declare function getAIModel(config?: DyrectedConfig): LanguageModel;
|
|
438
528
|
declare function formatAIErrorMessage(error: any): string;
|
|
439
529
|
declare function buildDyrectedSystemPrompt(context: DyrectedAIContext): string;
|
|
@@ -648,4 +738,4 @@ declare class InMemoryRateLimitStore implements AIRateLimitStore {
|
|
|
648
738
|
}
|
|
649
739
|
declare function aiRateLimit(config?: DyrectedConfig): (c: Context<DyrectedContext>, next: Next) => Promise<void>;
|
|
650
740
|
|
|
651
|
-
export { AIAgent, type AIAgentOptions, AIController, AuthController, type ChunkOptions, type ChunkResult, CollectionController, type DeleteDocumentChunksOptions, DyrectedContext, EmbeddingService, GlobalController, InMemoryRateLimitStore, type IndexDocumentOptions, MediaController, PreviewController, type RAGSearchOptions, RAGService, type ReindexAllOptions, type ReindexCollectionOptions, aiRateLimit, buildDyrectedSystemPrompt, chunkText, cosineSimilarity, createDyrectedAITools, estimateTokens, extractTextFromDoc, formatAIErrorMessage, getAIModel, getEmbeddingModel, hashContent, normalizeFieldValue, registerRoutes, serializeDetailForApi, serializeViewForApi, validatePayloadAgainstFields };
|
|
741
|
+
export { AIAgent, type AIAgentOptions, AIController, AUTH_SESSIONS_COLLECTION, AuthController, type AuthSessionRecord, type ChunkOptions, type ChunkResult, CollectionController, DEFAULT_LOCK_TIME_MS, DEFAULT_MAX_LOGIN_ATTEMPTS, type DeleteDocumentChunksOptions, DyrectedContext, EmbeddingService, GlobalController, InMemoryRateLimitStore, type IndexDocumentOptions, MediaController, PreviewController, type RAGSearchOptions, RAGService, type ReindexAllOptions, type ReindexCollectionOptions, type ResolvedAuthLockoutConfig, aiRateLimit, buildDyrectedSystemPrompt, buildInviteEmail, buildPasswordChangedEmail, buildResetPasswordEmail, buildWelcomeEmail, chunkText, cosineSimilarity, createDyrectedAITools, estimateTokens, extractTextFromDoc, formatAIErrorMessage, getAIModel, getAuthSession, getEmbeddingModel, getLockedUntilMs, hashContent, hashPassword, isAuthSessionActive, issueAuthSessionToken, normalizeFieldValue, registerRoutes, resolveAuthLockoutConfig, revokeAllAuthSessions, revokeAuthSession, sendEmail, serializeDetailForApi, serializeViewForApi, touchAuthSession, validatePayloadAgainstFields, verifyPassword };
|