@axiom-lattice/protocols 7.7.0 → 7.8.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axiom-lattice/protocols",
3
- "version": "7.7.0",
3
+ "version": "7.8.1",
4
4
  "description": "Unified protocol type definitions for Axiom Lattice framework",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -1,6 +1,43 @@
1
1
  /** Channel types persisted by the installation store, including internal-only channels. */
2
2
  export type ChannelInstallationType = "lark" | "email" | "slack" | "wechat" | "wecom" | "room";
3
3
 
4
+ /**
5
+ * Installation config fields that must never be returned in plaintext from public
6
+ * installation APIs. Reads replace non-empty values with {@link CHANNEL_INSTALLATION_SECRET_MASK};
7
+ * writes treat the mask as "keep the stored value".
8
+ */
9
+ export const CHANNEL_INSTALLATION_SECRET_FIELDS = [
10
+ "appSecret",
11
+ "verificationToken",
12
+ "encryptKey",
13
+ "botToken",
14
+ "secret",
15
+ ] as const;
16
+
17
+ /** Placeholder returned in place of a stored channel secret. */
18
+ export const CHANNEL_INSTALLATION_SECRET_MASK = "********";
19
+
20
+ /**
21
+ * Return a copy of an installation with every non-empty secret replaced by
22
+ * {@link CHANNEL_INSTALLATION_SECRET_MASK}. Safe for public read surfaces and
23
+ * agent tools; the stored record is never mutated.
24
+ */
25
+ export function maskChannelInstallationSecrets<TConfig>(
26
+ installation: ChannelInstallation<TConfig>,
27
+ ): ChannelInstallation<TConfig> {
28
+ const config = installation.config;
29
+ if (config === null || typeof config !== "object" || Array.isArray(config)) {
30
+ return installation;
31
+ }
32
+ const masked: Record<string, unknown> = { ...(config as Record<string, unknown>) };
33
+ for (const field of CHANNEL_INSTALLATION_SECRET_FIELDS) {
34
+ if (typeof masked[field] === "string" && masked[field] !== "") {
35
+ masked[field] = CHANNEL_INSTALLATION_SECRET_MASK;
36
+ }
37
+ }
38
+ return { ...installation, config: masked as TConfig };
39
+ }
40
+
4
41
  /** Channel types exposed by the public installation management API. */
5
42
  export type PublicChannelInstallationType = Exclude<ChannelInstallationType, "room">;
6
43
 
@@ -22,6 +22,8 @@ export interface DatabaseConfig {
22
22
  password?: string;
23
23
  connectionString?: string;
24
24
  ssl?: boolean;
25
+ /** Verify the database server certificate when SSL is enabled (default: true). */
26
+ sslRejectUnauthorized?: boolean;
25
27
  }
26
28
 
27
29
  /**
@@ -112,9 +112,21 @@ export interface PlatformRateLimitPolicyOverride {
112
112
  enabled?: boolean;
113
113
  }
114
114
 
115
+ /** Runtime session policy shared by the gateway and the console. */
116
+ export interface PlatformSessionSettings {
117
+ refreshEnabled: boolean;
118
+ accessTtlSeconds: number;
119
+ refreshIdleSeconds: number;
120
+ refreshAbsoluteSeconds: number;
121
+ refreshReuseGraceSeconds: number;
122
+ }
123
+
115
124
  /** Persisted, partial platform settings document managed by platform admins. */
116
125
  export interface PlatformSettingsDocument {
117
- auth?: { emailCompletionEnabled?: boolean };
126
+ auth?: {
127
+ emailCompletionEnabled?: boolean;
128
+ session?: Partial<PlatformSessionSettings>;
129
+ };
118
130
  invite?: { defaultExpiresInHours?: number; defaultMaxUses?: number };
119
131
  rateLimits?: {
120
132
  /** Per-policy platform overrides keyed by policy name. */
@@ -135,7 +147,7 @@ export interface PlatformSettingsRecord extends PlatformSettingsDocument {
135
147
 
136
148
  /** Fully-resolved platform settings (no optional fields). */
137
149
  export interface EffectivePlatformSettings {
138
- auth: { emailCompletionEnabled: boolean };
150
+ auth: { emailCompletionEnabled: boolean; session: PlatformSessionSettings };
139
151
  invite: { defaultExpiresInHours: number; defaultMaxUses: number };
140
152
  rateLimits: {
141
153
  openApiPerMinute: number;
@@ -192,7 +204,16 @@ export class PlatformSettingsVersionConflictError extends Error {
192
204
 
193
205
  /** Built-in fallback values used when neither platform nor env set a value. */
194
206
  export const PLATFORM_SETTINGS_DEFAULTS = {
195
- auth: { emailCompletionEnabled: false },
207
+ auth: {
208
+ emailCompletionEnabled: false,
209
+ session: {
210
+ refreshEnabled: true,
211
+ accessTtlSeconds: 86400,
212
+ refreshIdleSeconds: 604800,
213
+ refreshAbsoluteSeconds: 2592000,
214
+ refreshReuseGraceSeconds: 20,
215
+ },
216
+ },
196
217
  invite: { defaultExpiresInHours: 168, defaultMaxUses: 1 },
197
218
  rateLimits: {
198
219
  openApiPerMinute: 60_000,
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Server-side refresh sessions.
3
+ *
4
+ * A session family is created at login and rotated on every refresh. Access
5
+ * tokens remain stateless and carry a user-level `epoch`; this store backs
6
+ * refresh rotation, single-session logout, reuse detection, and device listing.
7
+ */
8
+
9
+ export interface SessionRecord {
10
+ id: string;
11
+ familyId: string;
12
+ userId: string;
13
+ tenantId?: string;
14
+ /** Snapshot of `user.authEpoch` at creation/rotation; refresh must match. */
15
+ authEpoch: string;
16
+ refreshTokenHash: string;
17
+ createdAt: Date;
18
+ lastUsedAt: Date;
19
+ idleExpiresAt: Date;
20
+ absoluteExpiresAt: Date;
21
+ revokedAt?: Date;
22
+ replacedBy?: string;
23
+ ip?: string;
24
+ userAgent?: string;
25
+ providerId: "local" | `oidc:${string}`;
26
+ /** Encrypted IdP refresh token (Phase 2). */
27
+ idpRefreshTokenEnc?: string;
28
+ idpRefreshExpiresAt?: Date;
29
+ }
30
+
31
+ export interface SessionStore {
32
+ create(record: SessionRecord): Promise<void>;
33
+ findByRefreshTokenHash(hash: string): Promise<SessionRecord | null>;
34
+ findByFamilyId(familyId: string): Promise<SessionRecord | null>;
35
+ rotate(oldId: string, next: SessionRecord): Promise<void>;
36
+ revokeFamily(familyId: string, reason: string): Promise<void>;
37
+ revokeAllForUser(userId: string, reason: string): Promise<void>;
38
+ touch(id: string, lastUsedAt: Date): Promise<void>;
39
+ listForUser(userId: string): Promise<SessionRecord[]>;
40
+ }
@@ -5,6 +5,8 @@ export interface User {
5
5
  email: string;
6
6
  name: string;
7
7
  status: UserStatus;
8
+ /** Bumped on disable/password-change/logout-all to revoke outstanding access tokens. */
9
+ authEpoch?: string;
8
10
  metadata?: Record<string, any>;
9
11
  createdAt: Date;
10
12
  updatedAt: Date;
@@ -21,6 +23,7 @@ export interface UpdateUserRequest {
21
23
  email?: string;
22
24
  name?: string;
23
25
  status?: UserStatus;
26
+ authEpoch?: string;
24
27
  metadata?: Record<string, any>;
25
28
  }
26
29
 
package/src/index.ts CHANGED
@@ -32,6 +32,7 @@ export * from "./MetricsServerConfigStoreProtocol";
32
32
  export * from "./McpServerConfigStoreProtocol";
33
33
  export * from "./ModelProviderProtocol";
34
34
  export * from "./UserStoreProtocol";
35
+ export * from "./SessionStoreProtocol";
35
36
  export * from "./UserTenantLinkProtocol";
36
37
  export * from "./AuthProviderProtocol";
37
38
  export * from "./UserExternalIdentityStoreProtocol";