@sentropic/cluster-mesh 0.23.5 → 0.25.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.
Files changed (240) hide show
  1. package/README.md +5 -0
  2. package/assets/storage/engram-memory/C6-FREEZE.md +63 -0
  3. package/assets/storage/engram-memory/contract-manifest.json +6 -4
  4. package/assets/storage/engram-memory/equivalence.json +1 -1
  5. package/assets/storage/engram-memory/neutral-asset-inventory.json +53 -0
  6. package/assets/storage/engram-memory/neutral-equivalence.json +44 -0
  7. package/assets/storage/postgres/007-consumed-counters.sql +17 -0
  8. package/assets/storage/postgres/008-instance-ownership.sql +35 -0
  9. package/assets/storage/postgres/engram-memory/001-projections.sql +14 -0
  10. package/assets/storage/postgres/engram-memory/002-host-ledger.sql +14 -0
  11. package/assets/storage/postgres/engram-memory/manifest.json +29 -0
  12. package/assets/storage/postgres/manifest.json +26 -0
  13. package/contracts/engram-memory-neutral-contract-v1.d.ts +367 -0
  14. package/dist/comments/postgres.d.ts +1 -0
  15. package/dist/comments/postgres.d.ts.map +1 -1
  16. package/dist/engram-memory/binding.d.ts +115 -0
  17. package/dist/engram-memory/binding.d.ts.map +1 -0
  18. package/dist/engram-memory/binding.js +239 -0
  19. package/dist/engram-memory/binding.js.map +1 -0
  20. package/dist/engram-memory/commit-result-recovery.d.ts +12 -0
  21. package/dist/engram-memory/commit-result-recovery.d.ts.map +1 -0
  22. package/dist/engram-memory/commit-result-recovery.js +14 -0
  23. package/dist/engram-memory/commit-result-recovery.js.map +1 -0
  24. package/dist/engram-memory/contract.d.ts +7 -1
  25. package/dist/engram-memory/contract.d.ts.map +1 -1
  26. package/dist/engram-memory/contract.js +7 -1
  27. package/dist/engram-memory/contract.js.map +1 -1
  28. package/dist/engram-memory/host-maintenance.d.ts +40 -0
  29. package/dist/engram-memory/host-maintenance.d.ts.map +1 -0
  30. package/dist/engram-memory/host-maintenance.js +44 -0
  31. package/dist/engram-memory/host-maintenance.js.map +1 -0
  32. package/dist/engram-memory/ledger.d.ts +75 -0
  33. package/dist/engram-memory/ledger.d.ts.map +1 -0
  34. package/dist/engram-memory/ledger.js +286 -0
  35. package/dist/engram-memory/ledger.js.map +1 -0
  36. package/dist/engram-memory/manifest.d.ts +1 -1
  37. package/dist/engram-memory/manifest.d.ts.map +1 -1
  38. package/dist/engram-memory/manifest.js +2 -1
  39. package/dist/engram-memory/manifest.js.map +1 -1
  40. package/dist/engram-memory/neutral-contract.d.ts +368 -0
  41. package/dist/engram-memory/neutral-contract.d.ts.map +1 -0
  42. package/dist/engram-memory/neutral-contract.js +39 -0
  43. package/dist/engram-memory/neutral-contract.js.map +1 -0
  44. package/dist/engram-memory/neutral-handle.d.ts +62 -0
  45. package/dist/engram-memory/neutral-handle.d.ts.map +1 -0
  46. package/dist/engram-memory/neutral-handle.js +131 -0
  47. package/dist/engram-memory/neutral-handle.js.map +1 -0
  48. package/dist/engram-memory/postgres-queries.d.ts +1 -1
  49. package/dist/engram-memory/postgres-queries.d.ts.map +1 -1
  50. package/dist/engram-memory/postgres-queries.js +111 -21
  51. package/dist/engram-memory/postgres-queries.js.map +1 -1
  52. package/dist/engram-memory/postgres.d.ts +51 -10
  53. package/dist/engram-memory/postgres.d.ts.map +1 -1
  54. package/dist/engram-memory/postgres.js +118 -17
  55. package/dist/engram-memory/postgres.js.map +1 -1
  56. package/dist/engram-memory/projection.d.ts +12 -0
  57. package/dist/engram-memory/projection.d.ts.map +1 -0
  58. package/dist/engram-memory/projection.js +123 -0
  59. package/dist/engram-memory/projection.js.map +1 -0
  60. package/dist/engram-memory/wire-adaptation.d.ts +61 -0
  61. package/dist/engram-memory/wire-adaptation.d.ts.map +1 -0
  62. package/dist/engram-memory/wire-adaptation.js +239 -0
  63. package/dist/engram-memory/wire-adaptation.js.map +1 -0
  64. package/dist/identity-contracts/access.d.ts +54 -0
  65. package/dist/identity-contracts/access.d.ts.map +1 -0
  66. package/dist/identity-contracts/access.js +168 -0
  67. package/dist/identity-contracts/access.js.map +1 -0
  68. package/dist/identity-contracts/accounts.d.ts +44 -0
  69. package/dist/identity-contracts/accounts.d.ts.map +1 -0
  70. package/dist/identity-contracts/accounts.js +149 -0
  71. package/dist/identity-contracts/accounts.js.map +1 -0
  72. package/dist/identity-contracts/descriptors.d.ts +12 -0
  73. package/dist/identity-contracts/descriptors.d.ts.map +1 -0
  74. package/dist/identity-contracts/descriptors.js +57 -0
  75. package/dist/identity-contracts/descriptors.js.map +1 -0
  76. package/dist/identity-contracts/doubles.d.ts +115 -0
  77. package/dist/identity-contracts/doubles.d.ts.map +1 -0
  78. package/dist/identity-contracts/doubles.js +340 -0
  79. package/dist/identity-contracts/doubles.js.map +1 -0
  80. package/dist/identity-contracts/enforcement.d.ts +27 -0
  81. package/dist/identity-contracts/enforcement.d.ts.map +1 -0
  82. package/dist/identity-contracts/enforcement.js +155 -0
  83. package/dist/identity-contracts/enforcement.js.map +1 -0
  84. package/dist/identity-contracts/errors.d.ts +71 -0
  85. package/dist/identity-contracts/errors.d.ts.map +1 -0
  86. package/dist/identity-contracts/errors.js +129 -0
  87. package/dist/identity-contracts/errors.js.map +1 -0
  88. package/dist/identity-contracts/index.d.ts +12 -0
  89. package/dist/identity-contracts/index.d.ts.map +1 -0
  90. package/dist/identity-contracts/index.js +13 -0
  91. package/dist/identity-contracts/index.js.map +1 -0
  92. package/dist/identity-contracts/ports.d.ts +116 -0
  93. package/dist/identity-contracts/ports.d.ts.map +1 -0
  94. package/dist/identity-contracts/ports.js +7 -0
  95. package/dist/identity-contracts/ports.js.map +1 -0
  96. package/dist/identity-contracts/resolution.d.ts +56 -0
  97. package/dist/identity-contracts/resolution.d.ts.map +1 -0
  98. package/dist/identity-contracts/resolution.js +87 -0
  99. package/dist/identity-contracts/resolution.js.map +1 -0
  100. package/dist/identity-contracts/tenancy.d.ts +52 -0
  101. package/dist/identity-contracts/tenancy.d.ts.map +1 -0
  102. package/dist/identity-contracts/tenancy.js +171 -0
  103. package/dist/identity-contracts/tenancy.js.map +1 -0
  104. package/dist/identity-contracts/types.d.ts +253 -0
  105. package/dist/identity-contracts/types.d.ts.map +1 -0
  106. package/dist/identity-contracts/types.js +7 -0
  107. package/dist/identity-contracts/types.js.map +1 -0
  108. package/dist/identity-contracts/workspaces.d.ts +37 -0
  109. package/dist/identity-contracts/workspaces.d.ts.map +1 -0
  110. package/dist/identity-contracts/workspaces.js +118 -0
  111. package/dist/identity-contracts/workspaces.js.map +1 -0
  112. package/dist/index.d.ts +1 -0
  113. package/dist/index.d.ts.map +1 -1
  114. package/dist/index.js +1 -0
  115. package/dist/index.js.map +1 -1
  116. package/dist/integrations/mcp/memory-compose.d.ts +11 -0
  117. package/dist/integrations/mcp/memory-compose.d.ts.map +1 -0
  118. package/dist/integrations/mcp/memory-compose.js +79 -0
  119. package/dist/integrations/mcp/memory-compose.js.map +1 -0
  120. package/dist/integrations/mcp/memory-definition.d.ts +28 -0
  121. package/dist/integrations/mcp/memory-definition.d.ts.map +1 -0
  122. package/dist/integrations/mcp/memory-definition.js +2 -0
  123. package/dist/integrations/mcp/memory-definition.js.map +1 -0
  124. package/dist/integrations/mcp/memory-manifest.d.ts +4 -0
  125. package/dist/integrations/mcp/memory-manifest.d.ts.map +1 -0
  126. package/dist/integrations/mcp/memory-manifest.js +9 -0
  127. package/dist/integrations/mcp/memory-manifest.js.map +1 -0
  128. package/dist/integrations/mcp/memory-transport.d.ts +21 -0
  129. package/dist/integrations/mcp/memory-transport.d.ts.map +1 -0
  130. package/dist/integrations/mcp/memory-transport.js +47 -0
  131. package/dist/integrations/mcp/memory-transport.js.map +1 -0
  132. package/dist/integrations/mcp/memory.d.ts +19 -0
  133. package/dist/integrations/mcp/memory.d.ts.map +1 -0
  134. package/dist/integrations/mcp/memory.js +40 -0
  135. package/dist/integrations/mcp/memory.js.map +1 -0
  136. package/dist/loaders/mcp/index.d.ts +1 -0
  137. package/dist/loaders/mcp/index.d.ts.map +1 -1
  138. package/dist/loaders/mcp/index.js +1 -0
  139. package/dist/loaders/mcp/index.js.map +1 -1
  140. package/dist/loaders/mcp/memory.d.ts +6 -0
  141. package/dist/loaders/mcp/memory.d.ts.map +1 -0
  142. package/dist/loaders/mcp/memory.js +9 -0
  143. package/dist/loaders/mcp/memory.js.map +1 -0
  144. package/dist/modules/catalog.d.ts +2 -0
  145. package/dist/modules/catalog.d.ts.map +1 -1
  146. package/dist/modules/catalog.js +15 -1
  147. package/dist/modules/catalog.js.map +1 -1
  148. package/dist/modules/contracts.d.ts +1 -1
  149. package/dist/modules/contracts.d.ts.map +1 -1
  150. package/dist/modules/contracts.js +2 -0
  151. package/dist/modules/contracts.js.map +1 -1
  152. package/dist/storage/atomic.d.ts +66 -1
  153. package/dist/storage/atomic.d.ts.map +1 -1
  154. package/dist/storage/atomic.js +173 -1
  155. package/dist/storage/atomic.js.map +1 -1
  156. package/dist/storage/backend.d.ts +3 -0
  157. package/dist/storage/backend.d.ts.map +1 -1
  158. package/dist/storage/backend.js +8 -0
  159. package/dist/storage/backend.js.map +1 -1
  160. package/dist/storage/contracts.d.ts +13 -0
  161. package/dist/storage/contracts.d.ts.map +1 -1
  162. package/dist/storage/contracts.js +12 -0
  163. package/dist/storage/contracts.js.map +1 -1
  164. package/dist/storage/instance-ownership.d.ts.map +1 -1
  165. package/dist/storage/instance-ownership.js +25 -7
  166. package/dist/storage/instance-ownership.js.map +1 -1
  167. package/dist/storage/postgres/codec.d.ts +1 -0
  168. package/dist/storage/postgres/codec.d.ts.map +1 -1
  169. package/dist/storage/postgres/codec.js +19 -0
  170. package/dist/storage/postgres/codec.js.map +1 -1
  171. package/dist/storage/postgres/commit-results.d.ts +6 -0
  172. package/dist/storage/postgres/commit-results.d.ts.map +1 -0
  173. package/dist/storage/postgres/commit-results.js +28 -0
  174. package/dist/storage/postgres/commit-results.js.map +1 -0
  175. package/dist/storage/postgres/core.d.ts +3 -1
  176. package/dist/storage/postgres/core.d.ts.map +1 -1
  177. package/dist/storage/postgres/core.js +99 -36
  178. package/dist/storage/postgres/core.js.map +1 -1
  179. package/dist/storage/postgres/effects.d.ts +1 -1
  180. package/dist/storage/postgres/effects.d.ts.map +1 -1
  181. package/dist/storage/postgres/effects.js +31 -6
  182. package/dist/storage/postgres/effects.js.map +1 -1
  183. package/dist/storage/postgres/errors.d.ts.map +1 -1
  184. package/dist/storage/postgres/errors.js +13 -0
  185. package/dist/storage/postgres/errors.js.map +1 -1
  186. package/dist/storage/postgres/index.d.ts +1 -0
  187. package/dist/storage/postgres/index.d.ts.map +1 -1
  188. package/dist/storage/postgres/index.js +1 -0
  189. package/dist/storage/postgres/index.js.map +1 -1
  190. package/dist/storage/postgres/instance-guard.d.ts +48 -0
  191. package/dist/storage/postgres/instance-guard.d.ts.map +1 -0
  192. package/dist/storage/postgres/instance-guard.js +147 -0
  193. package/dist/storage/postgres/instance-guard.js.map +1 -0
  194. package/dist/storage/postgres/instance-ownership.d.ts +22 -0
  195. package/dist/storage/postgres/instance-ownership.d.ts.map +1 -0
  196. package/dist/storage/postgres/instance-ownership.js +165 -0
  197. package/dist/storage/postgres/instance-ownership.js.map +1 -0
  198. package/dist/storage/postgres/journal.d.ts +24 -8
  199. package/dist/storage/postgres/journal.d.ts.map +1 -1
  200. package/dist/storage/postgres/journal.js +43 -32
  201. package/dist/storage/postgres/journal.js.map +1 -1
  202. package/dist/storage/postgres/migrations.d.ts +2 -1
  203. package/dist/storage/postgres/migrations.d.ts.map +1 -1
  204. package/dist/storage/postgres/migrations.js +14 -4
  205. package/dist/storage/postgres/migrations.js.map +1 -1
  206. package/dist/storage/postgres/ordinary-transactions.d.ts.map +1 -1
  207. package/dist/storage/postgres/ordinary-transactions.js +3 -2
  208. package/dist/storage/postgres/ordinary-transactions.js.map +1 -1
  209. package/dist/storage/postgres/profiles.d.ts +15 -8
  210. package/dist/storage/postgres/profiles.d.ts.map +1 -1
  211. package/dist/storage/postgres/protocol.d.ts +14 -0
  212. package/dist/storage/postgres/protocol.d.ts.map +1 -1
  213. package/dist/storage/postgres/protocol.js.map +1 -1
  214. package/dist/storage/postgres/queries.js +5 -5
  215. package/dist/storage/postgres/queries.js.map +1 -1
  216. package/dist/storage/postgres/readers.js +2 -2
  217. package/dist/storage/postgres/readers.js.map +1 -1
  218. package/dist/storage/postgres/roots.d.ts.map +1 -1
  219. package/dist/storage/postgres/roots.js +10 -6
  220. package/dist/storage/postgres/roots.js.map +1 -1
  221. package/dist/storage/postgres/scope.d.ts +17 -8
  222. package/dist/storage/postgres/scope.d.ts.map +1 -1
  223. package/dist/storage/postgres/scope.js +4 -0
  224. package/dist/storage/postgres/scope.js.map +1 -1
  225. package/dist/storage/postgres/snapshots.d.ts +2 -2
  226. package/dist/storage/postgres/snapshots.d.ts.map +1 -1
  227. package/dist/storage/postgres/snapshots.js +7 -4
  228. package/dist/storage/postgres/snapshots.js.map +1 -1
  229. package/dist/storage/postgres/transactions.d.ts +11 -0
  230. package/dist/storage/postgres/transactions.d.ts.map +1 -1
  231. package/dist/storage/postgres/transactions.js +21 -0
  232. package/dist/storage/postgres/transactions.js.map +1 -1
  233. package/dist/storage/u64.d.ts +18 -0
  234. package/dist/storage/u64.d.ts.map +1 -0
  235. package/dist/storage/u64.js +54 -0
  236. package/dist/storage/u64.js.map +1 -0
  237. package/docs/memory-mcp-candidate.md +46 -0
  238. package/docs/memory-mcp.md +98 -0
  239. package/examples/memory-mcp-stdio.mjs +42 -0
  240. package/package.json +12 -2
@@ -0,0 +1,168 @@
1
+ // Identity core contracts: invitations, device enrolment entry and login
2
+ // sessions (F04, F05). Invitation tokens carry the `sit_` prefix; entropy comes
3
+ // from an injected port so tests stay deterministic. Login sessions are
4
+ // distinct from agent and runtime sessions; revoking one class never touches
5
+ // another directly.
6
+ import { AccountNotActiveError, DeviceCodeError, IdentityNotFoundError, InvitationError, LoginSessionError } from './errors.js';
7
+ import { systemIdentityClock, } from './types.js';
8
+ export function createInvitations(input) {
9
+ const clock = input.clock ?? systemIdentityClock;
10
+ return {
11
+ async issueInvitation(invitation, actorId) {
12
+ const record = {
13
+ ...invitation,
14
+ token: `sit_${input.tokens.issue()}`,
15
+ status: 'pending',
16
+ };
17
+ await input.invitations.saveInvitation(record);
18
+ await input.audit.append({
19
+ at: clock(),
20
+ kind: 'invitation.issued',
21
+ actorId,
22
+ subjectId: invitation.invitationId,
23
+ });
24
+ return record;
25
+ },
26
+ async consumeInvitation(token, now) {
27
+ const invitation = await input.invitations.findInvitationByToken(token);
28
+ if (!invitation)
29
+ throw new InvitationError('not_found');
30
+ if (invitation.status === 'revoked')
31
+ throw new InvitationError('revoked');
32
+ if (invitation.status === 'consumed')
33
+ throw new InvitationError('consumed');
34
+ if (invitation.expiresAt <= now)
35
+ throw new InvitationError('expired');
36
+ const consumed = await input.invitations.markInvitationConsumed(token, now);
37
+ if (!consumed)
38
+ throw new InvitationError('consumed');
39
+ return {
40
+ invitation: { ...invitation, status: 'consumed', consumedAt: now },
41
+ emailVerified: true,
42
+ };
43
+ },
44
+ async revokeInvitation(invitationId, actorId) {
45
+ const invitation = await input.invitations.findInvitation(invitationId);
46
+ if (!invitation)
47
+ throw new IdentityNotFoundError('invitation', invitationId);
48
+ const revoked = await input.invitations.revokeInvitation(invitationId);
49
+ await input.audit.append({
50
+ at: clock(),
51
+ kind: 'invitation.revoked',
52
+ actorId,
53
+ subjectId: invitationId,
54
+ });
55
+ return revoked;
56
+ },
57
+ };
58
+ }
59
+ export function createDeviceEnrolment(input) {
60
+ return {
61
+ async issueDeviceCode(device, options) {
62
+ const now = options.now;
63
+ const record = {
64
+ deviceCode: input.tokens.issue(),
65
+ userCode: input.tokens.issue(),
66
+ deviceName: device.deviceName ?? null,
67
+ status: 'pending',
68
+ issuedAt: now,
69
+ expiresAt: addSeconds(now, options.ttlSeconds),
70
+ };
71
+ await input.deviceCodes.saveDeviceCode(record);
72
+ const issuance = {
73
+ deviceCode: record.deviceCode,
74
+ userCode: record.userCode,
75
+ intervalSec: options.intervalSec ?? 5,
76
+ expiresAt: record.expiresAt,
77
+ };
78
+ await input.audit.append({ at: now, kind: 'device_code.issued', subjectId: record.deviceCode });
79
+ return issuance;
80
+ },
81
+ async pollDeviceCode(deviceCode, now) {
82
+ const record = await input.deviceCodes.findDeviceCode(deviceCode);
83
+ if (!record)
84
+ throw new DeviceCodeError('not_found');
85
+ if (record.status === 'approved') {
86
+ return { status: 'approved', userId: record.approvedUserId, deviceName: record.deviceName };
87
+ }
88
+ if (record.expiresAt <= now)
89
+ return { status: 'expired' };
90
+ return { status: 'authorization_pending' };
91
+ },
92
+ async approveDeviceCode(userCode, approval, now) {
93
+ const account = await input.accounts.findAccount(approval.userId);
94
+ if (!account || account.accountStatus !== 'active')
95
+ throw new AccountNotActiveError(approval.userId);
96
+ const record = await input.deviceCodes.findDeviceCodeByUser(userCode);
97
+ if (!record)
98
+ throw new DeviceCodeError('not_found');
99
+ if (record.expiresAt <= now)
100
+ throw new DeviceCodeError('expired');
101
+ const approved = await input.deviceCodes.approveDeviceCode(userCode, approval.userId, now);
102
+ if (!approved)
103
+ throw new DeviceCodeError('already_resolved');
104
+ await input.audit.append({ at: now, kind: 'device_code.approved', actorId: approval.userId, subjectId: userCode });
105
+ return { ...record, status: 'approved', approvedUserId: approval.userId, approvedAt: now };
106
+ },
107
+ };
108
+ }
109
+ function addSeconds(now, ttlSeconds) {
110
+ return new Date(Date.parse(now) + ttlSeconds * 1000).toISOString();
111
+ }
112
+ export function createLoginSessions(input) {
113
+ const clock = input.clock ?? systemIdentityClock;
114
+ async function requireSession(sessionId) {
115
+ const session = await input.sessions.findSession(sessionId);
116
+ if (!session)
117
+ throw new LoginSessionError('not_found');
118
+ return session;
119
+ }
120
+ return {
121
+ async createSession(session, options) {
122
+ const record = {
123
+ sessionId: session.sessionId,
124
+ userId: session.userId,
125
+ status: 'active',
126
+ mfaState: session.mfaState ?? 'none',
127
+ createdAt: options.now,
128
+ expiresAt: addSeconds(options.now, options.ttlSeconds),
129
+ refreshCount: 0,
130
+ };
131
+ await input.sessions.createSession(record);
132
+ return record;
133
+ },
134
+ async validateSession(sessionId, now) {
135
+ const session = await requireSession(sessionId);
136
+ if (session.status === 'revoked')
137
+ throw new LoginSessionError('revoked');
138
+ if (session.status === 'expired' || session.expiresAt <= now) {
139
+ throw new LoginSessionError('expired');
140
+ }
141
+ return session;
142
+ },
143
+ async refreshSession(sessionId, options) {
144
+ const session = await requireSession(sessionId);
145
+ if (session.status === 'revoked')
146
+ throw new LoginSessionError('revoked');
147
+ if (session.expiresAt <= options.now)
148
+ throw new LoginSessionError('expired');
149
+ return input.sessions.touchSession(sessionId, {
150
+ expiresAt: addSeconds(options.now, options.ttlSeconds),
151
+ refreshCount: session.refreshCount + 1,
152
+ });
153
+ },
154
+ async revokeSession(sessionId, _actorId) {
155
+ const session = await requireSession(sessionId);
156
+ if (session.status === 'revoked')
157
+ return session;
158
+ return input.sessions.revokeSession(sessionId, clock());
159
+ },
160
+ async revokeAllSessionsForUser(userId, _actorId) {
161
+ return input.sessions.revokeAllSessionsForUser(userId, clock());
162
+ },
163
+ async listSessionsForUser(userId) {
164
+ return input.sessions.listSessionsForUser(userId);
165
+ },
166
+ };
167
+ }
168
+ //# sourceMappingURL=access.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access.js","sourceRoot":"","sources":["../../src/identity-contracts/access.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,gFAAgF;AAChF,wEAAwE;AACxE,6EAA6E;AAC7E,oBAAoB;AAEpB,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,qBAAqB,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAShI,OAAO,EACL,mBAAmB,GAUpB,MAAM,YAAY,CAAC;AAQpB,MAAM,UAAU,iBAAiB,CAAC,KAKjC;IACC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,mBAAmB,CAAC;IACjD,OAAO;QACL,KAAK,CAAC,eAAe,CAAC,UAAU,EAAE,OAAO;YACvC,MAAM,MAAM,GAAqB;gBAC/B,GAAG,UAAU;gB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AC,YAAY,GAAG,CAAC;aACvC,CAAC,CAAC;QACL,CAAC;QACD,KAAK,CAAC,aAAa,CAAC,SAAS,EAAE,QAAQ;YACrC,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,SAAS,CAAC,CAAC;YAChD,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS;gBAAE,OAAO,OAAO,CAAC;YACjD,OAAO,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1D,CAAC;QACD,KAAK,CAAC,wBAAwB,CAAC,MAAM,EAAE,QAAQ;YAC7C,OAAO,KAAK,CAAC,QAAQ,CAAC,wBAAwB,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QAClE,CAAC;QACD,KAAK,CAAC,mBAAmB,CAAC,MAAM;YAC9B,OAAO,KAAK,CAAC,QAAQ,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;QACpD,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,44 @@
1
+ import type { IdentityProofStore, UserAccountStore, IdentityAuditPort } from './ports.js';
2
+ import { type GlobalRole, type IdentityClock, type IdentityProof, type IdentityProofKind, type RegisterAccountInput, type UserAccount, type VerifiedProofSubject } from './types.js';
3
+ export interface UserAccountDomain {
4
+ register(input: RegisterAccountInput, options?: {
5
+ readonly firstAdmin?: boolean;
6
+ }): Promise<UserAccount>;
7
+ approveAccount(userId: string, input: {
8
+ readonly role: GlobalRole;
9
+ readonly actorId: string;
10
+ }): Promise<UserAccount>;
11
+ disableAccount(userId: string, actorId: string): Promise<UserAccount>;
12
+ reactivateAccount(userId: string, actorId: string): Promise<UserAccount>;
13
+ deleteAccount(userId: string, actorId: string): Promise<void>;
14
+ getAccount(userId: string): Promise<UserAccount>;
15
+ listUsers(): Promise<readonly UserAccount[]>;
16
+ /** Self-service surface (F02): the caller acts on its own account only. */
17
+ getSelf(userId: string): Promise<UserAccount>;
18
+ disableSelf(userId: string): Promise<UserAccount>;
19
+ deleteSelf(userId: string): Promise<void>;
20
+ }
21
+ export declare function createUserAccounts(input: {
22
+ readonly accounts: UserAccountStore;
23
+ readonly audit: IdentityAuditPort;
24
+ readonly clock?: IdentityClock;
25
+ }): UserAccountDomain;
26
+ export interface IdentityProofDomain {
27
+ registerProof(input: {
28
+ readonly proofId: string;
29
+ readonly userId: string;
30
+ readonly kind: IdentityProofKind;
31
+ readonly provider?: string;
32
+ readonly expiresAt?: string;
33
+ }): Promise<IdentityProof>;
34
+ verifyProof(input: {
35
+ readonly proofId: string;
36
+ readonly userId: string;
37
+ }, now: string): Promise<VerifiedProofSubject>;
38
+ revokeProof(proofId: string, actorId: string): Promise<IdentityProof>;
39
+ }
40
+ export declare function createIdentityProofs(input: {
41
+ readonly proofs: IdentityProofStore;
42
+ readonly clock?: IdentityClock;
43
+ }): IdentityProofDomain;
44
+ //# sourceMappingURL=accounts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/identity-contracts/accounts.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC1F,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,oBAAoB,EAC1B,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,EAAE,oBAAoB,EAAE,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACzG,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;QAAC,QAAQ,CAAC,OAAO,EAA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AAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAC3B,WAAW,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACtH,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CACvE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAC1C,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC;CAChC,GAAG,mBAAmB,CAwBtB"}
@@ -0,0 +1,149 @@
1
+ // Identity core contracts: user accounts and identity proofs (F02, F03).
2
+ // Account approval is the first approval; it never implies tenant membership.
3
+ import { AccountNotActiveError, AccountTransitionError, AdminUserProtectedError, IdentityConflictError, IdentityNotFoundError, ProofVerificationError, SelfActionForbiddenError, } from './errors.js';
4
+ import { systemIdentityClock, } from './types.js';
5
+ function isProtectedAdmin(role) {
6
+ return role === 'admin_app' || role === 'admin_org';
7
+ }
8
+ export function createUserAccounts(input) {
9
+ const clock = input.clock ?? systemIdentityClock;
10
+ async function requireAccount(userId) {
11
+ const account = await input.accounts.findAccount(userId);
12
+ if (!account)
13
+ throw new IdentityNotFoundError('user', userId);
14
+ return account;
15
+ }
16
+ function forbidSelfAction(userId, actorId, action) {
17
+ if (userId === actorId)
18
+ throw new SelfActionForbiddenError(action);
19
+ }
20
+ return {
21
+ async register(registerInput, options) {
22
+ const existing = await input.accounts.findAccountByEmail(registerInput.email);
23
+ if (existing)
24
+ throw new IdentityConflictError('email', `Email is already registered: ${registerInput.email}`);
25
+ const now = clock();
26
+ const record = {
27
+ userId: registerInput.userId,
28
+ email: registerInput.email,
29
+ accountStatus: options?.firstAdmin === true ? 'active' : 'pending_admin_approval',
30
+ globalRole: options?.firstAdmin === true ? 'admin_app' : 'guest',
31
+ createdAt: now,
32
+ updatedAt: now,
33
+ };
34
+ await input.accounts.createAccount(record);
35
+ await input.audit.append({ at: now, kind: 'account.registered', subjectId: record.userId });
36
+ return record;
37
+ },
38
+ async approveAccount(userId, approval) {
39
+ forbidSelfAction(userId, approval.actorId, 'approve');
40
+ const account = await requireAccount(userId);
41
+ if (account.accountStatus === 'deleted')
42
+ throw new AccountNotActiveError(userId);
43
+ const now = clock();
44
+ await input.accounts.setAccountStatus(userId, 'active', now);
45
+ const updated = await input.accounts.setGlobalRole(userId, approval.role, now);
46
+ await input.audit.append({ at: now, kind: 'account.approved', actorId: approval.actorId, subjectId: userId });
47
+ return updated;
48
+ },
49
+ async disableAccount(userId, actorId) {
50
+ forbidSelfAction(userId, actorId, 'disable');
51
+ const account = await requireAccount(userId);
52
+ if (isProtectedAdmin(account.globalRole))
53
+ throw new AdminUserProtectedError('disable');
54
+ if (account.accountStatus !== 'active')
55
+ throw new AccountTransitionError();
56
+ const now = clock();
57
+ const updated = await input.accounts.setAccountStatus(userId, 'disabled', now);
58
+ await input.audit.append({ at: now, kind: 'account.disabled', actorId, subjectId: userId });
59
+ return updated;
60
+ },
61
+ async reactivateAccount(userId, actorId) {
62
+ forbidSelfAction(userId, actorId, 'reactivate');
63
+ const account = await requireAccount(userId);
64
+ if (account.accountStatus !== 'disabled')
65
+ throw new AccountTransitionError();
66
+ const now = clock();
67
+ const updated = await input.accounts.setAccountStatus(userId, 'active', now);
68
+ await input.audit.append({ at: now, kind: 'account.reactivated', actorId, subjectId: userId });
69
+ return updated;
70
+ },
71
+ async deleteAccount(userId, actorId) {
72
+ forbidSelfAction(userId, actorId, 'delete');
73
+ const account = await requireAccount(userId);
74
+ if (isProtectedAdmin(account.globalRole))
75
+ throw new AdminUserProtectedError('delete');
76
+ if (account.accountStatus !== 'disabled')
77
+ throw new AccountTransitionError('User must be disabled before deletion');
78
+ const now = clock();
79
+ await input.accounts.deleteAccount(userId, now);
80
+ await input.audit.append({ at: now, kind: 'account.deleted', actorId, subjectId: userId });
81
+ },
82
+ async getAccount(userId) {
83
+ const account = await requireAccount(userId);
84
+ if (account.accountStatus === 'deleted')
85
+ throw new AccountNotActiveError(userId);
86
+ return account;
87
+ },
88
+ async listUsers() {
89
+ return input.accounts.listAccounts();
90
+ },
91
+ async getSelf(userId) {
92
+ const account = await requireAccount(userId);
93
+ if (account.accountStatus === 'deleted')
94
+ throw new AccountNotActiveError(userId);
95
+ return account;
96
+ },
97
+ async disableSelf(userId) {
98
+ const account = await requireAccount(userId);
99
+ if (account.accountStatus !== 'active')
100
+ throw new AccountTransitionError();
101
+ const now = clock();
102
+ const updated = await input.accounts.setAccountStatus(userId, 'disabled', now);
103
+ await input.audit.append({ at: now, kind: 'account.self_disabled', subjectId: userId });
104
+ return updated;
105
+ },
106
+ async deleteSelf(userId) {
107
+ const account = await requireAccount(userId);
108
+ if (account.accountStatus !== 'disabled')
109
+ throw new AccountTransitionError('User must be disabled before deletion');
110
+ const now = clock();
111
+ await input.accounts.deleteAccount(userId, now);
112
+ await input.audit.append({ at: now, kind: 'account.self_deleted', subjectId: userId });
113
+ },
114
+ };
115
+ }
116
+ const SINGLE_USE_PROOFS = ['email_code', 'magic_link'];
117
+ export function createIdentityProofs(input) {
118
+ const clock = input.clock ?? systemIdentityClock;
119
+ return {
120
+ async registerProof(proof) {
121
+ const record = { ...proof, createdAt: clock() };
122
+ await input.proofs.addProof(record);
123
+ return record;
124
+ },
125
+ async verifyProof(lookup, now) {
126
+ const proof = await input.proofs.findProof(lookup.proofId);
127
+ if (!proof)
128
+ throw new ProofVerificationError('not_found');
129
+ if (proof.userId !== lookup.userId)
130
+ throw new ProofVerificationError('mismatch');
131
+ if (proof.revokedAt)
132
+ throw new ProofVerificationError('revoked');
133
+ if (proof.expiresAt && proof.expiresAt <= now)
134
+ throw new ProofVerificationError('expired');
135
+ if (proof.consumedAt)
136
+ throw new ProofVerificationError('consumed');
137
+ if (SINGLE_USE_PROOFS.includes(proof.kind))
138
+ await input.proofs.markProofConsumed(proof.proofId, now);
139
+ return { proofId: proof.proofId, userId: proof.userId, kind: proof.kind };
140
+ },
141
+ async revokeProof(proofId, _actorId) {
142
+ const proof = await input.proofs.findProof(proofId);
143
+ if (!proof)
144
+ throw new ProofVerificationError('not_found');
145
+ return input.proofs.revokeProof(proofId, clock());
146
+ },
147
+ };
148
+ }
149
+ //# sourceMappingURL=accounts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../src/identity-contracts/accounts.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,8EAA8E;AAE9E,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,mBAAmB,GAQpB,MAAM,YAAY,CAAC;AAgBpB,SAAS,gBAAgB,CAAC,IAAgB;IACxC,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,WAAW,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAIlC;IACC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,mBAAmB,CAAC;IACjD,KAAK,UAAU,cAAc,CAAC,MAAc;QAC1C,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QACzD,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC9D,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,SAAS,gBAAgB,CAAC,MAAc,EAAE,OAAe,EAAE,MAAuD;QAChH,IAAI,MAAM,KAAK,OAAO;YAAE,MAAM,IAAI,wBAAwB,CAAC,MAAM,CAAC,CAAC;IACrE,CAAC;IACD,OAAO;QACL,KAA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I,sBAAsB,CAAC,UAAU,CAAC,CAAC;YACnE,IAAI,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;gBAAE,MAAM,KAAK,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;YACrG,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;QAC5E,CAAC;QACD,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,QAAQ;YACjC,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YACpD,IAAI,CAAC,KAAK;gBAAE,MAAM,IAAI,sBAAsB,CAAC,WAAW,CAAC,CAAC;YAC1D,OAAO,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QACpD,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ export declare const IDENTITY_CONTRACT_VERSION: "1.0.0";
2
+ export type IdentityDomainName = 'tenants' | 'accounts' | 'proofs' | 'invitations' | 'device_enrolment' | 'login_sessions' | 'tenant_memberships' | 'workspaces' | 'resolution' | 'tid_oauth' | 'revocation' | 'decision';
3
+ export interface IdentityDomainDescriptor {
4
+ readonly domain: IdentityDomainName;
5
+ readonly version: typeof IDENTITY_CONTRACT_VERSION;
6
+ /** Contract-only: types, ports and doubles; no durable backend yet. */
7
+ readonly status: 'contract-only';
8
+ readonly records: readonly string[];
9
+ }
10
+ export declare const IDENTITY_DOMAIN_DESCRIPTORS: readonly IdentityDomainDescriptor[];
11
+ export declare function identityDomainDescriptor(domain: IdentityDomainName): IdentityDomainDescriptor | undefined;
12
+ //# sourceMappingURL=descriptors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"descriptors.d.ts","sourceRoot":"","sources":["../../src/identity-contracts/descriptors.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,yBAAyB,SAAmB,CAAC;AAE1D,MAAM,MAAM,kBAAkB,GAC1B,SAAS,GACT,UAAU,GACV,QAAQ,GACR,aAAa,GACb,kBAAkB,GAClB,gBAAgB,GAChB,oBAAoB,GACpB,YAAY,GACZ,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,UAAU,CAAC;AAEf,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,OAAO,yBAAyB,CAAC;IACnD,uEAAuE;IACvE,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED,eAAO,MAAM,2BAA2B,EAAE,SAAS,wBAAwB,EAgD1E,CAAC;AAEF,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,kBAAkB,GACzB,wBAAwB,GAAG,SAAS,CAEtC"}
@@ -0,0 +1,57 @@
1
+ // Identity core contracts: versioned domain descriptors. Each descriptor names
2
+ // the records a domain owns and pins the contract version it was frozen at,
3
+ // so parallel implementation lots can detect contract drift mechanically.
4
+ export const IDENTITY_CONTRACT_VERSION = '1.0.0';
5
+ export const IDENTITY_DOMAIN_DESCRIPTORS = [
6
+ { domain: 'tenants', version: IDENTITY_CONTRACT_VERSION, status: 'contract-only', records: ['TenantRecord'] },
7
+ { domain: 'accounts', version: IDENTITY_CONTRACT_VERSION, status: 'contract-only', records: ['UserAccount'] },
8
+ { domain: 'proofs', version: IDENTITY_CONTRACT_VERSION, status: 'contract-only', records: ['IdentityProof'] },
9
+ { domain: 'invitations', version: IDENTITY_CONTRACT_VERSION, status: 'contract-only', records: ['InvitationRecord'] },
10
+ {
11
+ domain: 'device_enrolment',
12
+ version: IDENTITY_CONTRACT_VERSION,
13
+ status: 'contract-only',
14
+ records: ['DeviceCodeRecord'],
15
+ },
16
+ { domain: 'login_sessions', version: IDENTITY_CONTRACT_VERSION, status: 'contract-only', records: ['LoginSession'] },
17
+ {
18
+ domain: 'tenant_memberships',
19
+ version: IDENTITY_CONTRACT_VERSION,
20
+ status: 'contract-only',
21
+ records: ['TenantMembershipRecord'],
22
+ },
23
+ {
24
+ domain: 'workspaces',
25
+ version: IDENTITY_CONTRACT_VERSION,
26
+ status: 'contract-only',
27
+ records: ['WorkspaceRecord', 'WorkspaceMembershipRecord'],
28
+ },
29
+ {
30
+ domain: 'resolution',
31
+ version: IDENTITY_CONTRACT_VERSION,
32
+ status: 'contract-only',
33
+ records: ['AuthoritativeResolution', 'ShadowComparison', 'DivergenceSample'],
34
+ },
35
+ {
36
+ domain: 'tid_oauth',
37
+ version: IDENTITY_CONTRACT_VERSION,
38
+ status: 'contract-only',
39
+ records: ['TidClaim', 'OAuthConsentRecord', 'ServiceClientBinding'],
40
+ },
41
+ {
42
+ domain: 'revocation',
43
+ version: IDENTITY_CONTRACT_VERSION,
44
+ status: 'contract-only',
45
+ records: ['PersonRevocationReceipt', 'RevocationStepReceipt'],
46
+ },
47
+ {
48
+ domain: 'decision',
49
+ version: IDENTITY_CONTRACT_VERSION,
50
+ status: 'contract-only',
51
+ records: ['FreshDecisionInput', 'FreshDecision'],
52
+ },
53
+ ];
54
+ export function identityDomainDescriptor(domain) {
55
+ return IDENTITY_DOMAIN_DESCRIPTORS.find((descriptor) => descriptor.domain === domain);
56
+ }
57
+ //# sourceMappingURL=descriptors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"descriptors.js","sourceRoot":"","sources":["../../src/identity-contracts/descriptors.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,4EAA4E;AAC5E,0EAA0E;AAE1E,MAAM,CAAC,MAAM,yBAAyB,GAAG,OAAgB,CAAC;AAwB1D,MAAM,CAAC,MAAM,2BAA2B,GAAwC;IAC9E,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAA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EAAE,oBAAoB,EAAE,sBAAsB,CAAC;KACpE;IACD;QACE,MAAM,EAAE,YAAY;QACpB,OAAO,EAAE,yBAAyB;QAClC,MAAM,EAAE,eAAe;QACvB,OAAO,EAAE,CAAC,yBAAyB,EAAE,uBAAuB,CAAC;KAC9D;IACD;QACE,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,yBAAyB;QAClC,MAAM,EAAE,eAAe;QACvB,OAAO,EAAE,CAAC,oBAAoB,EAAE,eAAe,CAAC;KACjD;CACF,CAAC;AAEF,MAAM,UAAU,wBAAwB,CACtC,MAA0B;IAE1B,OAAO,2BAA2B,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;AACxF,CAAC"}
@@ -0,0 +1,115 @@
1
+ import type { DeviceCodeStore, DivergenceMetricsPort, IdentityAuditPort, IdentityProofStore, InvitationStore, InvitationTokenPort, LoginSessionStore, OAuthTenantStore, TenantMembershipStore, TenantRegistryStore, UserAccountStore, WorkspaceDirectoryStore, WorkspaceMembershipStore, IdentityStores } from './ports.js';
2
+ import type { DeviceCodeRecord, DivergenceSample, DivergenceSummary, IdentityAuditEvent, IdentityProof, InvitationRecord, LoginSession, OAuthConsentRecord, ServiceClientBinding, TenantMembershipRecord, TenantRecord, TenantStatus, UserAccount, WorkspaceMembershipRecord, WorkspaceRecord } from './types.js';
3
+ export declare class InMemoryTenantRegistryStore implements TenantRegistryStore {
4
+ private readonly byId;
5
+ private readonly bySlug;
6
+ createTenant(record: TenantRecord): Promise<void>;
7
+ findTenant(tenantId: string): Promise<TenantRecord | null>;
8
+ findTenantBySlug(slug: string): Promise<TenantRecord | null>;
9
+ listTenants(): Promise<readonly TenantRecord[]>;
10
+ setTenantStatus(tenantId: string, status: TenantStatus, _at: string): Promise<TenantRecord>;
11
+ }
12
+ export declare class InMemoryUserAccountStore implements UserAccountStore {
13
+ private readonly byId;
14
+ private readonly byEmail;
15
+ createAccount(record: UserAccount): Promise<void>;
16
+ findAccount(userId: string): Promise<UserAccount | null>;
17
+ findAccountByEmail(email: string): Promise<UserAccount | null>;
18
+ listAccounts(): Promise<readonly UserAccount[]>;
19
+ setAccountStatus(userId: string, status: UserAccount['accountStatus'], at: string): Promise<UserAccount>;
20
+ setGlobalRole(userId: string, role: UserAccount['globalRole'], at: string): Promise<UserAccount>;
21
+ deleteAccount(userId: string, _at: string): Promise<void>;
22
+ private update;
23
+ }
24
+ export declare class InMemoryIdentityProofStore implements IdentityProofStore {
25
+ private readonly byId;
26
+ addProof(record: IdentityProof): Promise<void>;
27
+ findProof(proofId: string): Promise<IdentityProof | null>;
28
+ listProofsForUser(userId: string): Promise<readonly IdentityProof[]>;
29
+ markProofConsumed(proofId: string, at: string): Promise<IdentityProof>;
30
+ revokeProof(proofId: string, at: string): Promise<IdentityProof>;
31
+ private update;
32
+ }
33
+ export declare class InMemoryInvitationStore implements InvitationStore {
34
+ private readonly byId;
35
+ private readonly byToken;
36
+ saveInvitation(record: InvitationRecord): Promise<void>;
37
+ findInvitation(invitationId: string): Promise<InvitationRecord | null>;
38
+ findInvitationByToken(token: string): Promise<InvitationRecord | null>;
39
+ markInvitationConsumed(token: string, at: string): Promise<boolean>;
40
+ revokeInvitation(invitationId: string): Promise<InvitationRecord>;
41
+ }
42
+ export declare class InMemoryDeviceCodeStore implements DeviceCodeStore {
43
+ private readonly byDeviceCode;
44
+ private readonly byUserCode;
45
+ saveDeviceCode(record: DeviceCodeRecord): Promise<void>;
46
+ findDeviceCode(deviceCode: string): Promise<DeviceCodeRecord | null>;
47
+ findDeviceCodeByUser(userCode: string): Promise<DeviceCodeRecord | null>;
48
+ approveDeviceCode(userCode: string, approvedUserId: string, at: string): Promise<boolean>;
49
+ }
50
+ export declare class InMemoryLoginSessionStore implements LoginSessionStore {
51
+ private readonly byId;
52
+ createSession(record: LoginSession): Promise<void>;
53
+ findSession(sessionId: string): Promise<LoginSession | null>;
54
+ touchSession(sessionId: string, update: Pick<LoginSession, 'expiresAt' | 'refreshCount'>): Promise<LoginSession>;
55
+ revokeSession(sessionId: string, at: string): Promise<LoginSession>;
56
+ revokeAllSessionsForUser(userId: string, at: string): Promise<number>;
57
+ listSessionsForUser(userId: string): Promise<readonly LoginSession[]>;
58
+ }
59
+ export declare class InMemoryTenantMembershipStore implements TenantMembershipStore {
60
+ private readonly rows;
61
+ private key;
62
+ upsertMembershipRequest(record: TenantMembershipRecord): Promise<TenantMembershipRecord>;
63
+ findMembership(userId: string, tenantId: string): Promise<TenantMembershipRecord | null>;
64
+ setMembershipState(userId: string, tenantId: string, state: Pick<TenantMembershipRecord, 'status' | 'tenantRole'> & {
65
+ readonly decidedBy: string;
66
+ readonly decidedAt: string;
67
+ readonly updatedAt: string;
68
+ }): Promise<TenantMembershipRecord>;
69
+ listMembershipsForTenant(tenantId: string): Promise<readonly TenantMembershipRecord[]>;
70
+ listMembershipsForUser(userId: string): Promise<readonly TenantMembershipRecord[]>;
71
+ findApprovedMembership(userId: string, tenantId: string): Promise<TenantMembershipRecord | null>;
72
+ }
73
+ export declare class InMemoryWorkspaceDirectoryStore implements WorkspaceDirectoryStore {
74
+ private readonly byId;
75
+ enrolWorkspace(record: WorkspaceRecord): Promise<void>;
76
+ findWorkspace(workspaceId: string): Promise<WorkspaceRecord | null>;
77
+ findWorkspaceByRepoIdentity(tenantId: string, repoIdentity: string): Promise<WorkspaceRecord | null>;
78
+ listWorkspacesForTenant(tenantId: string): Promise<readonly WorkspaceRecord[]>;
79
+ approveWorkspaceAlias(workspaceId: string, alias: string): Promise<WorkspaceRecord>;
80
+ }
81
+ export declare class InMemoryWorkspaceMembershipStore implements WorkspaceMembershipStore {
82
+ private readonly rows;
83
+ private key;
84
+ putWorkspaceMember(record: WorkspaceMembershipRecord): Promise<WorkspaceMembershipRecord>;
85
+ removeWorkspaceMember(workspaceId: string, userId: string): Promise<boolean>;
86
+ findWorkspaceMember(workspaceId: string, userId: string): Promise<WorkspaceMembershipRecord | null>;
87
+ listWorkspaceMembers(workspaceId: string): Promise<readonly WorkspaceMembershipRecord[]>;
88
+ }
89
+ export declare class InMemoryOAuthTenantStore implements OAuthTenantStore {
90
+ private readonly consents;
91
+ private readonly clients;
92
+ grantConsent(record: OAuthConsentRecord): Promise<void>;
93
+ revokeConsent(consentId: string, at: string): Promise<boolean>;
94
+ bindServiceClient(record: ServiceClientBinding): Promise<void>;
95
+ listTenantServiceClients(tenantId: string): Promise<readonly ServiceClientBinding[]>;
96
+ }
97
+ export declare class InMemoryIdentityAudit implements IdentityAuditPort {
98
+ readonly events: IdentityAuditEvent[];
99
+ append(event: IdentityAuditEvent): Promise<void>;
100
+ }
101
+ export declare class InMemoryDivergenceMetrics implements DivergenceMetricsPort {
102
+ private samples;
103
+ record(sample: Omit<DivergenceSample, 'at'> & {
104
+ readonly at?: string;
105
+ }): void;
106
+ summary(): DivergenceSummary;
107
+ }
108
+ export declare class StubTokenPort implements InvitationTokenPort {
109
+ private counter;
110
+ issue(): string;
111
+ }
112
+ export declare function createStubTokenPort(): InvitationTokenPort;
113
+ export declare function createInMemoryIdentityStores(): IdentityStores;
114
+ export declare function createInMemoryDivergenceMetrics(): DivergenceMetricsPort;
115
+ //# sourceMappingURL=doubles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doubles.d.ts","sourceRoot":"","sources":["../../src/identity-contracts/doubles.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACxB,cAAc,EACf,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,o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