@company-semantics/contracts 0.61.2 → 0.63.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/package.json +1 -1
- package/src/chat/index.ts +0 -1
- package/src/chat/types.ts +3 -16
- package/src/impersonation.ts +68 -0
- package/src/index.ts +13 -1
package/package.json
CHANGED
package/src/chat/index.ts
CHANGED
package/src/chat/types.ts
CHANGED
|
@@ -109,13 +109,6 @@ export interface UpdateShareRequest {
|
|
|
109
109
|
// Chat Lifecycle Types
|
|
110
110
|
// =============================================================================
|
|
111
111
|
|
|
112
|
-
/**
|
|
113
|
-
* Chat status for lifecycle management.
|
|
114
|
-
* - active: Normal visible chat
|
|
115
|
-
* - archived: Hidden from main list, still searchable
|
|
116
|
-
*/
|
|
117
|
-
export type ChatStatus = 'active' | 'archived'
|
|
118
|
-
|
|
119
112
|
/**
|
|
120
113
|
* Title source - tracks how the title was set.
|
|
121
114
|
* - auto: Generated automatically by LLM
|
|
@@ -129,8 +122,6 @@ export type TitleSource = 'auto' | 'manual'
|
|
|
129
122
|
export interface ChatListFilters {
|
|
130
123
|
/** Search query - matches against title */
|
|
131
124
|
search?: string
|
|
132
|
-
/** Filter by status. Defaults to 'active' */
|
|
133
|
-
status?: ChatStatus | 'all'
|
|
134
125
|
/** Include pinned chats at top */
|
|
135
126
|
includePinned?: boolean
|
|
136
127
|
/** Pagination limit */
|
|
@@ -140,10 +131,9 @@ export interface ChatListFilters {
|
|
|
140
131
|
}
|
|
141
132
|
|
|
142
133
|
/**
|
|
143
|
-
* Extended chat summary with pin/
|
|
134
|
+
* Extended chat summary with pin/title status.
|
|
144
135
|
*/
|
|
145
136
|
export interface ChatSummaryExtended extends ChatSummary {
|
|
146
|
-
status: ChatStatus
|
|
147
137
|
/** If pinned, when it was pinned */
|
|
148
138
|
pinnedAt: string | null
|
|
149
139
|
/** How the title was set: 'auto' or 'manual' */
|
|
@@ -203,7 +193,7 @@ export type InvalidationReason = 'external-mutation' | 'bulk-operation' | 'sync-
|
|
|
203
193
|
/**
|
|
204
194
|
* Fields that can change on a chat, used in changed[] array.
|
|
205
195
|
*/
|
|
206
|
-
export type ChatChangedField = 'title' | 'titleSource' | '
|
|
196
|
+
export type ChatChangedField = 'title' | 'titleSource' | 'pinnedAt'
|
|
207
197
|
|
|
208
198
|
// =============================================================================
|
|
209
199
|
// Domain Events (past-tense facts, carry full state)
|
|
@@ -227,8 +217,6 @@ export interface ChatCreatedEvent extends BaseEvent {
|
|
|
227
217
|
title: string
|
|
228
218
|
/** How the title was set */
|
|
229
219
|
titleSource: TitleSource
|
|
230
|
-
/** Chat status */
|
|
231
|
-
status: ChatStatus
|
|
232
220
|
/** When pinned (null if not pinned) */
|
|
233
221
|
pinnedAt: string | null
|
|
234
222
|
/** Message count */
|
|
@@ -243,7 +231,7 @@ export interface ChatCreatedEvent extends BaseEvent {
|
|
|
243
231
|
}
|
|
244
232
|
|
|
245
233
|
/**
|
|
246
|
-
* Emitted when chat metadata changes (title, pin,
|
|
234
|
+
* Emitted when chat metadata changes (title, pin, etc.)
|
|
247
235
|
* Carries full current state - clients should replace local state entirely.
|
|
248
236
|
*/
|
|
249
237
|
export interface ChatUpdatedEvent extends BaseEvent {
|
|
@@ -253,7 +241,6 @@ export interface ChatUpdatedEvent extends BaseEvent {
|
|
|
253
241
|
title: string
|
|
254
242
|
titleSource: TitleSource | null
|
|
255
243
|
titleGeneratedAt: string | null
|
|
256
|
-
status: ChatStatus
|
|
257
244
|
pinnedAt: string | null
|
|
258
245
|
messageCount: number
|
|
259
246
|
createdAt: string
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Break-Glass Impersonation — Shared Vocabulary
|
|
3
|
+
*
|
|
4
|
+
* This module defines the types for the emergency impersonation mechanism.
|
|
5
|
+
* See ADR-BE-068 for the trust model and invariant documentation.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Authentication mode — tags every request context
|
|
9
|
+
export type AuthMode = 'STANDARD' | 'BREAK_GLASS';
|
|
10
|
+
|
|
11
|
+
// Impersonation session model — full session state
|
|
12
|
+
export interface ImpersonationSession {
|
|
13
|
+
readonly impersonationSessionId: string;
|
|
14
|
+
readonly adminUserId: string;
|
|
15
|
+
readonly targetUserId: string;
|
|
16
|
+
readonly reason: string;
|
|
17
|
+
readonly reasonHash: string; // SHA-256 of reason text — tamper-evidence
|
|
18
|
+
readonly startedAt: string; // ISO 8601
|
|
19
|
+
readonly expiresAt: string; // ISO 8601
|
|
20
|
+
readonly endedAt: string | null; // ISO 8601 or null if active
|
|
21
|
+
readonly ipAddress: string;
|
|
22
|
+
readonly userAgent: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Restricted action classes — single source of truth
|
|
26
|
+
// Backend impersonation middleware consumes this enum centrally.
|
|
27
|
+
// Routes do NOT self-classify. This prevents bypass via new routes.
|
|
28
|
+
export type RestrictedImpersonationAction =
|
|
29
|
+
| 'delete_chat'
|
|
30
|
+
| 'delete_message'
|
|
31
|
+
| 'modify_billing'
|
|
32
|
+
| 'rotate_credentials'
|
|
33
|
+
| 'invite_remove_users'
|
|
34
|
+
| 'accept_agreements'
|
|
35
|
+
| 'irreversible_write';
|
|
36
|
+
|
|
37
|
+
// All restricted actions as a const array for runtime checks
|
|
38
|
+
export const RESTRICTED_IMPERSONATION_ACTIONS: readonly RestrictedImpersonationAction[] = [
|
|
39
|
+
'delete_chat',
|
|
40
|
+
'delete_message',
|
|
41
|
+
'modify_billing',
|
|
42
|
+
'rotate_credentials',
|
|
43
|
+
'invite_remove_users',
|
|
44
|
+
'accept_agreements',
|
|
45
|
+
'irreversible_write',
|
|
46
|
+
] as const;
|
|
47
|
+
|
|
48
|
+
// Impersonation-specific company capability
|
|
49
|
+
export type ImpersonationCapability = 'company.impersonate';
|
|
50
|
+
|
|
51
|
+
// Session summary — emitted on impersonation.ended and impersonation.expired
|
|
52
|
+
export interface ImpersonationSessionSummary {
|
|
53
|
+
readonly impersonationSessionId: string;
|
|
54
|
+
readonly adminUserId: string;
|
|
55
|
+
readonly targetUserId: string;
|
|
56
|
+
readonly durationMs: number;
|
|
57
|
+
readonly actionCount: number;
|
|
58
|
+
readonly blockedActionCount: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Impersonation audit event types
|
|
62
|
+
export type ImpersonationAuditEventType =
|
|
63
|
+
| 'impersonation.started'
|
|
64
|
+
| 'impersonation.ended'
|
|
65
|
+
| 'impersonation.expired'
|
|
66
|
+
| 'impersonation.session_summary'
|
|
67
|
+
| 'impersonated.action'
|
|
68
|
+
| 'impersonation.blocked_action';
|
package/src/index.ts
CHANGED
|
@@ -150,7 +150,6 @@ export type {
|
|
|
150
150
|
CreateShareRequest,
|
|
151
151
|
UpdateShareRequest,
|
|
152
152
|
// Chat lifecycle types
|
|
153
|
-
ChatStatus,
|
|
154
153
|
TitleSource,
|
|
155
154
|
ChatListFilters,
|
|
156
155
|
ChatSummaryExtended,
|
|
@@ -402,3 +401,16 @@ export { RateLimitTier } from './rate-limit/index'
|
|
|
402
401
|
// Billing domain types (v1 — read-only)
|
|
403
402
|
// @see PRD-00121 for design rationale
|
|
404
403
|
export type { OrgPlanStatus, OrgBillingInfo } from './billing/index'
|
|
404
|
+
|
|
405
|
+
// Impersonation types (break-glass emergency access)
|
|
406
|
+
// @see ADR-BE-068 for trust model
|
|
407
|
+
export type {
|
|
408
|
+
AuthMode,
|
|
409
|
+
ImpersonationSession,
|
|
410
|
+
RestrictedImpersonationAction,
|
|
411
|
+
ImpersonationCapability,
|
|
412
|
+
ImpersonationSessionSummary,
|
|
413
|
+
ImpersonationAuditEventType,
|
|
414
|
+
} from './impersonation'
|
|
415
|
+
|
|
416
|
+
export { RESTRICTED_IMPERSONATION_ACTIONS } from './impersonation'
|