@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/server.js CHANGED
@@ -4793,6 +4793,14 @@ function getSecret() {
4793
4793
  return new TextEncoder().encode(secret);
4794
4794
  }
4795
4795
  var DEFAULT_EXPIRY = "7d";
4796
+ var DEFAULT_SESSION_EXPIRY = DEFAULT_EXPIRY;
4797
+ function resolveSessionTokenExpiry(collection) {
4798
+ const auth = collection.auth;
4799
+ if (auth && typeof auth === "object" && typeof auth.tokenExpiration === "string" && auth.tokenExpiration.length > 0) {
4800
+ return auth.tokenExpiration;
4801
+ }
4802
+ return DEFAULT_SESSION_EXPIRY;
4803
+ }
4796
4804
  async function signCollectionToken(payload, expiresIn = DEFAULT_EXPIRY) {
4797
4805
  return new SignJWT({ ...payload }).setProtectedHeader({ alg: "HS256" }).setIssuedAt().setExpirationTime(expiresIn).sign(getSecret());
4798
4806
  }
@@ -9644,6 +9652,7 @@ var AuthController = class {
9644
9652
  userId: user.id,
9645
9653
  email: user.email,
9646
9654
  collection: this.collection.slug,
9655
+ expiresIn: resolveSessionTokenExpiry(this.collection),
9647
9656
  ip: c.get("clientIp"),
9648
9657
  authSource: "local"
9649
9658
  });
@@ -9735,6 +9744,7 @@ var AuthController = class {
9735
9744
  userId: user.id,
9736
9745
  email: user.email,
9737
9746
  collection: this.collection.slug,
9747
+ expiresIn: resolveSessionTokenExpiry(this.collection),
9738
9748
  ip: c.get("clientIp"),
9739
9749
  authSource: "local"
9740
9750
  });
@@ -9825,12 +9835,15 @@ var AuthController = class {
9825
9835
  }
9826
9836
  const tokenPayload = c.get("authTokenPayload");
9827
9837
  if (tokenPayload?.sid) {
9828
- const token2 = await signCollectionToken({
9829
- sub: requestUser.sub,
9830
- email: requestUser.email,
9831
- collection: this.collection.slug,
9832
- sid: tokenPayload.sid
9833
- });
9838
+ const token2 = await signCollectionToken(
9839
+ {
9840
+ sub: requestUser.sub,
9841
+ email: requestUser.email,
9842
+ collection: this.collection.slug,
9843
+ sid: tokenPayload.sid
9844
+ },
9845
+ resolveSessionTokenExpiry(this.collection)
9846
+ );
9834
9847
  return c.json({ token: token2 });
9835
9848
  }
9836
9849
  const token = await issueAuthSessionToken({
@@ -10092,6 +10105,7 @@ var AuthController = class {
10092
10105
  userId: user.id,
10093
10106
  email: inviteeEmail,
10094
10107
  collection: this.collection.slug,
10108
+ expiresIn: resolveSessionTokenExpiry(this.collection),
10095
10109
  ip: c.get("clientIp"),
10096
10110
  authSource: "local"
10097
10111
  });
@@ -10349,6 +10363,7 @@ var AdminAuthController = class {
10349
10363
  userId: user.id,
10350
10364
  email: user.email,
10351
10365
  collection: adminCollection.slug,
10366
+ expiresIn: resolveSessionTokenExpiry(adminCollection),
10352
10367
  providerId: provider.id,
10353
10368
  authSource: "external",
10354
10369
  ip: c.get("clientIp")
@@ -14638,7 +14653,7 @@ function normalizeConfig(config) {
14638
14653
  name: "roles",
14639
14654
  type: "select",
14640
14655
  label: "Roles",
14641
- defaultValue: [],
14656
+ defaultValue: "viewer",
14642
14657
  options: [
14643
14658
  { value: "admin", label: "Admin" },
14644
14659
  { value: "editor", label: "Editor" },
@@ -15088,8 +15103,12 @@ init_embedding_service();
15088
15103
  export {
15089
15104
  AIAgent,
15090
15105
  AIController,
15106
+ AUTH_SESSIONS_COLLECTION,
15091
15107
  AuthController,
15092
15108
  CollectionController,
15109
+ DEFAULT_LOCK_TIME_MS,
15110
+ DEFAULT_MAX_LOGIN_ATTEMPTS,
15111
+ DEFAULT_SESSION_EXPIRY,
15093
15112
  EmbeddingService,
15094
15113
  GlobalController,
15095
15114
  InMemoryRateLimitStore,
@@ -15100,7 +15119,11 @@ export {
15100
15119
  attachRequestMetrics,
15101
15120
  bindObservabilityRuntime,
15102
15121
  buildDyrectedSystemPrompt,
15122
+ buildInviteEmail,
15123
+ buildPasswordChangedEmail,
15103
15124
  buildRequestLogger,
15125
+ buildResetPasswordEmail,
15126
+ buildWelcomeEmail,
15104
15127
  captureRequestBody,
15105
15128
  chunkText,
15106
15129
  cosineSimilarity,
@@ -15108,24 +15131,39 @@ export {
15108
15131
  createDyrectedApp,
15109
15132
  createObservabilityRuntime,
15110
15133
  createRequestSpan,
15134
+ decodeCollectionToken,
15111
15135
  endRequestSpan,
15112
15136
  estimateTokens,
15113
15137
  extractTextFromDoc,
15114
15138
  formatAIErrorMessage,
15115
15139
  getAIModel,
15140
+ getAuthSession,
15116
15141
  getConfigLogger,
15117
15142
  getEmbeddingModel,
15143
+ getLockedUntilMs,
15118
15144
  getObservabilityRuntime,
15119
15145
  getRequestLogger,
15120
15146
  hashContent,
15147
+ hashPassword,
15148
+ isAuthSessionActive,
15149
+ issueAuthSessionToken,
15121
15150
  normalizeFieldValue,
15122
15151
  redactBody,
15123
15152
  redactHeaders,
15124
15153
  registerRoutes,
15125
15154
  renderPrometheusMetrics,
15155
+ resolveAuthLockoutConfig,
15126
15156
  resolveObservabilityConfig,
15157
+ resolveSessionTokenExpiry,
15158
+ revokeAllAuthSessions,
15159
+ revokeAuthSession,
15160
+ sendEmail,
15127
15161
  serializeDetailForApi,
15128
15162
  serializeViewForApi,
15129
15163
  shouldSampleRequest,
15130
- validatePayloadAgainstFields
15164
+ signCollectionToken,
15165
+ touchAuthSession,
15166
+ validatePayloadAgainstFields,
15167
+ verifyCollectionToken,
15168
+ verifyPassword
15131
15169
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dyrected/core",
3
- "version": "2.13.5",
3
+ "version": "2.14.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",