@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.
- package/README.md +5 -0
- package/assets/storage/engram-memory/C6-FREEZE.md +63 -0
- package/assets/storage/engram-memory/contract-manifest.json +6 -4
- package/assets/storage/engram-memory/equivalence.json +1 -1
- package/assets/storage/engram-memory/neutral-asset-inventory.json +53 -0
- package/assets/storage/engram-memory/neutral-equivalence.json +44 -0
- package/assets/storage/postgres/007-consumed-counters.sql +17 -0
- package/assets/storage/postgres/008-instance-ownership.sql +35 -0
- package/assets/storage/postgres/engram-memory/001-projections.sql +14 -0
- package/assets/storage/postgres/engram-memory/002-host-ledger.sql +14 -0
- package/assets/storage/postgres/engram-memory/manifest.json +29 -0
- package/assets/storage/postgres/manifest.json +26 -0
- package/contracts/engram-memory-neutral-contract-v1.d.ts +367 -0
- package/dist/comments/postgres.d.ts +1 -0
- package/dist/comments/postgres.d.ts.map +1 -1
- package/dist/engram-memory/binding.d.ts +115 -0
- package/dist/engram-memory/binding.d.ts.map +1 -0
- package/dist/engram-memory/binding.js +239 -0
- package/dist/engram-memory/binding.js.map +1 -0
- package/dist/engram-memory/commit-result-recovery.d.ts +12 -0
- package/dist/engram-memory/commit-result-recovery.d.ts.map +1 -0
- package/dist/engram-memory/commit-result-recovery.js +14 -0
- package/dist/engram-memory/commit-result-recovery.js.map +1 -0
- package/dist/engram-memory/contract.d.ts +7 -1
- package/dist/engram-memory/contract.d.ts.map +1 -1
- package/dist/engram-memory/contract.js +7 -1
- package/dist/engram-memory/contract.js.map +1 -1
- package/dist/engram-memory/host-maintenance.d.ts +40 -0
- package/dist/engram-memory/host-maintenance.d.ts.map +1 -0
- package/dist/engram-memory/host-maintenance.js +44 -0
- package/dist/engram-memory/host-maintenance.js.map +1 -0
- package/dist/engram-memory/ledger.d.ts +75 -0
- package/dist/engram-memory/ledger.d.ts.map +1 -0
- package/dist/engram-memory/ledger.js +286 -0
- package/dist/engram-memory/ledger.js.map +1 -0
- package/dist/engram-memory/manifest.d.ts +1 -1
- package/dist/engram-memory/manifest.d.ts.map +1 -1
- package/dist/engram-memory/manifest.js +2 -1
- package/dist/engram-memory/manifest.js.map +1 -1
- package/dist/engram-memory/neutral-contract.d.ts +368 -0
- package/dist/engram-memory/neutral-contract.d.ts.map +1 -0
- package/dist/engram-memory/neutral-contract.js +39 -0
- package/dist/engram-memory/neutral-contract.js.map +1 -0
- package/dist/engram-memory/neutral-handle.d.ts +62 -0
- package/dist/engram-memory/neutral-handle.d.ts.map +1 -0
- package/dist/engram-memory/neutral-handle.js +131 -0
- package/dist/engram-memory/neutral-handle.js.map +1 -0
- package/dist/engram-memory/postgres-queries.d.ts +1 -1
- package/dist/engram-memory/postgres-queries.d.ts.map +1 -1
- package/dist/engram-memory/postgres-queries.js +111 -21
- package/dist/engram-memory/postgres-queries.js.map +1 -1
- package/dist/engram-memory/postgres.d.ts +51 -10
- package/dist/engram-memory/postgres.d.ts.map +1 -1
- package/dist/engram-memory/postgres.js +118 -17
- package/dist/engram-memory/postgres.js.map +1 -1
- package/dist/engram-memory/projection.d.ts +12 -0
- package/dist/engram-memory/projection.d.ts.map +1 -0
- package/dist/engram-memory/projection.js +123 -0
- package/dist/engram-memory/projection.js.map +1 -0
- package/dist/engram-memory/wire-adaptation.d.ts +61 -0
- package/dist/engram-memory/wire-adaptation.d.ts.map +1 -0
- package/dist/engram-memory/wire-adaptation.js +239 -0
- package/dist/engram-memory/wire-adaptation.js.map +1 -0
- package/dist/identity-contracts/access.d.ts +54 -0
- package/dist/identity-contracts/access.d.ts.map +1 -0
- package/dist/identity-contracts/access.js +168 -0
- package/dist/identity-contracts/access.js.map +1 -0
- package/dist/identity-contracts/accounts.d.ts +44 -0
- package/dist/identity-contracts/accounts.d.ts.map +1 -0
- package/dist/identity-contracts/accounts.js +149 -0
- package/dist/identity-contracts/accounts.js.map +1 -0
- package/dist/identity-contracts/descriptors.d.ts +12 -0
- package/dist/identity-contracts/descriptors.d.ts.map +1 -0
- package/dist/identity-contracts/descriptors.js +57 -0
- package/dist/identity-contracts/descriptors.js.map +1 -0
- package/dist/identity-contracts/doubles.d.ts +115 -0
- package/dist/identity-contracts/doubles.d.ts.map +1 -0
- package/dist/identity-contracts/doubles.js +340 -0
- package/dist/identity-contracts/doubles.js.map +1 -0
- package/dist/identity-contracts/enforcement.d.ts +27 -0
- package/dist/identity-contracts/enforcement.d.ts.map +1 -0
- package/dist/identity-contracts/enforcement.js +155 -0
- package/dist/identity-contracts/enforcement.js.map +1 -0
- package/dist/identity-contracts/errors.d.ts +71 -0
- package/dist/identity-contracts/errors.d.ts.map +1 -0
- package/dist/identity-contracts/errors.js +129 -0
- package/dist/identity-contracts/errors.js.map +1 -0
- package/dist/identity-contracts/index.d.ts +12 -0
- package/dist/identity-contracts/index.d.ts.map +1 -0
- package/dist/identity-contracts/index.js +13 -0
- package/dist/identity-contracts/index.js.map +1 -0
- package/dist/identity-contracts/ports.d.ts +116 -0
- package/dist/identity-contracts/ports.d.ts.map +1 -0
- package/dist/identity-contracts/ports.js +7 -0
- package/dist/identity-contracts/ports.js.map +1 -0
- package/dist/identity-contracts/resolution.d.ts +56 -0
- package/dist/identity-contracts/resolution.d.ts.map +1 -0
- package/dist/identity-contracts/resolution.js +87 -0
- package/dist/identity-contracts/resolution.js.map +1 -0
- package/dist/identity-contracts/tenancy.d.ts +52 -0
- package/dist/identity-contracts/tenancy.d.ts.map +1 -0
- package/dist/identity-contracts/tenancy.js +171 -0
- package/dist/identity-contracts/tenancy.js.map +1 -0
- package/dist/identity-contracts/types.d.ts +253 -0
- package/dist/identity-contracts/types.d.ts.map +1 -0
- package/dist/identity-contracts/types.js +7 -0
- package/dist/identity-contracts/types.js.map +1 -0
- package/dist/identity-contracts/workspaces.d.ts +37 -0
- package/dist/identity-contracts/workspaces.d.ts.map +1 -0
- package/dist/identity-contracts/workspaces.js +118 -0
- package/dist/identity-contracts/workspaces.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/integrations/mcp/memory-compose.d.ts +11 -0
- package/dist/integrations/mcp/memory-compose.d.ts.map +1 -0
- package/dist/integrations/mcp/memory-compose.js +79 -0
- package/dist/integrations/mcp/memory-compose.js.map +1 -0
- package/dist/integrations/mcp/memory-definition.d.ts +28 -0
- package/dist/integrations/mcp/memory-definition.d.ts.map +1 -0
- package/dist/integrations/mcp/memory-definition.js +2 -0
- package/dist/integrations/mcp/memory-definition.js.map +1 -0
- package/dist/integrations/mcp/memory-manifest.d.ts +4 -0
- package/dist/integrations/mcp/memory-manifest.d.ts.map +1 -0
- package/dist/integrations/mcp/memory-manifest.js +9 -0
- package/dist/integrations/mcp/memory-manifest.js.map +1 -0
- package/dist/integrations/mcp/memory-transport.d.ts +21 -0
- package/dist/integrations/mcp/memory-transport.d.ts.map +1 -0
- package/dist/integrations/mcp/memory-transport.js +47 -0
- package/dist/integrations/mcp/memory-transport.js.map +1 -0
- package/dist/integrations/mcp/memory.d.ts +19 -0
- package/dist/integrations/mcp/memory.d.ts.map +1 -0
- package/dist/integrations/mcp/memory.js +40 -0
- package/dist/integrations/mcp/memory.js.map +1 -0
- package/dist/loaders/mcp/index.d.ts +1 -0
- package/dist/loaders/mcp/index.d.ts.map +1 -1
- package/dist/loaders/mcp/index.js +1 -0
- package/dist/loaders/mcp/index.js.map +1 -1
- package/dist/loaders/mcp/memory.d.ts +6 -0
- package/dist/loaders/mcp/memory.d.ts.map +1 -0
- package/dist/loaders/mcp/memory.js +9 -0
- package/dist/loaders/mcp/memory.js.map +1 -0
- package/dist/modules/catalog.d.ts +2 -0
- package/dist/modules/catalog.d.ts.map +1 -1
- package/dist/modules/catalog.js +15 -1
- package/dist/modules/catalog.js.map +1 -1
- package/dist/modules/contracts.d.ts +1 -1
- package/dist/modules/contracts.d.ts.map +1 -1
- package/dist/modules/contracts.js +2 -0
- package/dist/modules/contracts.js.map +1 -1
- package/dist/storage/atomic.d.ts +66 -1
- package/dist/storage/atomic.d.ts.map +1 -1
- package/dist/storage/atomic.js +173 -1
- package/dist/storage/atomic.js.map +1 -1
- package/dist/storage/backend.d.ts +3 -0
- package/dist/storage/backend.d.ts.map +1 -1
- package/dist/storage/backend.js +8 -0
- package/dist/storage/backend.js.map +1 -1
- package/dist/storage/contracts.d.ts +13 -0
- package/dist/storage/contracts.d.ts.map +1 -1
- package/dist/storage/contracts.js +12 -0
- package/dist/storage/contracts.js.map +1 -1
- package/dist/storage/instance-ownership.d.ts.map +1 -1
- package/dist/storage/instance-ownership.js +25 -7
- package/dist/storage/instance-ownership.js.map +1 -1
- package/dist/storage/postgres/codec.d.ts +1 -0
- package/dist/storage/postgres/codec.d.ts.map +1 -1
- package/dist/storage/postgres/codec.js +19 -0
- package/dist/storage/postgres/codec.js.map +1 -1
- package/dist/storage/postgres/commit-results.d.ts +6 -0
- package/dist/storage/postgres/commit-results.d.ts.map +1 -0
- package/dist/storage/postgres/commit-results.js +28 -0
- package/dist/storage/postgres/commit-results.js.map +1 -0
- package/dist/storage/postgres/core.d.ts +3 -1
- package/dist/storage/postgres/core.d.ts.map +1 -1
- package/dist/storage/postgres/core.js +99 -36
- package/dist/storage/postgres/core.js.map +1 -1
- package/dist/storage/postgres/effects.d.ts +1 -1
- package/dist/storage/postgres/effects.d.ts.map +1 -1
- package/dist/storage/postgres/effects.js +31 -6
- package/dist/storage/postgres/effects.js.map +1 -1
- package/dist/storage/postgres/errors.d.ts.map +1 -1
- package/dist/storage/postgres/errors.js +13 -0
- package/dist/storage/postgres/errors.js.map +1 -1
- package/dist/storage/postgres/index.d.ts +1 -0
- package/dist/storage/postgres/index.d.ts.map +1 -1
- package/dist/storage/postgres/index.js +1 -0
- package/dist/storage/postgres/index.js.map +1 -1
- package/dist/storage/postgres/instance-guard.d.ts +48 -0
- package/dist/storage/postgres/instance-guard.d.ts.map +1 -0
- package/dist/storage/postgres/instance-guard.js +147 -0
- package/dist/storage/postgres/instance-guard.js.map +1 -0
- package/dist/storage/postgres/instance-ownership.d.ts +22 -0
- package/dist/storage/postgres/instance-ownership.d.ts.map +1 -0
- package/dist/storage/postgres/instance-ownership.js +165 -0
- package/dist/storage/postgres/instance-ownership.js.map +1 -0
- package/dist/storage/postgres/journal.d.ts +24 -8
- package/dist/storage/postgres/journal.d.ts.map +1 -1
- package/dist/storage/postgres/journal.js +43 -32
- package/dist/storage/postgres/journal.js.map +1 -1
- package/dist/storage/postgres/migrations.d.ts +2 -1
- package/dist/storage/postgres/migrations.d.ts.map +1 -1
- package/dist/storage/postgres/migrations.js +14 -4
- package/dist/storage/postgres/migrations.js.map +1 -1
- package/dist/storage/postgres/ordinary-transactions.d.ts.map +1 -1
- package/dist/storage/postgres/ordinary-transactions.js +3 -2
- package/dist/storage/postgres/ordinary-transactions.js.map +1 -1
- package/dist/storage/postgres/profiles.d.ts +15 -8
- package/dist/storage/postgres/profiles.d.ts.map +1 -1
- package/dist/storage/postgres/protocol.d.ts +14 -0
- package/dist/storage/postgres/protocol.d.ts.map +1 -1
- package/dist/storage/postgres/protocol.js.map +1 -1
- package/dist/storage/postgres/queries.js +5 -5
- package/dist/storage/postgres/queries.js.map +1 -1
- package/dist/storage/postgres/readers.js +2 -2
- package/dist/storage/postgres/readers.js.map +1 -1
- package/dist/storage/postgres/roots.d.ts.map +1 -1
- package/dist/storage/postgres/roots.js +10 -6
- package/dist/storage/postgres/roots.js.map +1 -1
- package/dist/storage/postgres/scope.d.ts +17 -8
- package/dist/storage/postgres/scope.d.ts.map +1 -1
- package/dist/storage/postgres/scope.js +4 -0
- package/dist/storage/postgres/scope.js.map +1 -1
- package/dist/storage/postgres/snapshots.d.ts +2 -2
- package/dist/storage/postgres/snapshots.d.ts.map +1 -1
- package/dist/storage/postgres/snapshots.js +7 -4
- package/dist/storage/postgres/snapshots.js.map +1 -1
- package/dist/storage/postgres/transactions.d.ts +11 -0
- package/dist/storage/postgres/transactions.d.ts.map +1 -1
- package/dist/storage/postgres/transactions.js +21 -0
- package/dist/storage/postgres/transactions.js.map +1 -1
- package/dist/storage/u64.d.ts +18 -0
- package/dist/storage/u64.d.ts.map +1 -0
- package/dist/storage/u64.js +54 -0
- package/dist/storage/u64.js.map +1 -0
- package/docs/memory-mcp-candidate.md +46 -0
- package/docs/memory-mcp.md +98 -0
- package/examples/memory-mcp-stdio.mjs +42 -0
- package/package.json +12 -2
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// Identity core contracts: stable error codes. Refusals stay typed so routers
|
|
2
|
+
// and tests can match on `code` without parsing messages.
|
|
3
|
+
export class IdentityNotFoundError extends Error {
|
|
4
|
+
entity;
|
|
5
|
+
id;
|
|
6
|
+
code = 'identity_not_found';
|
|
7
|
+
constructor(entity, id) {
|
|
8
|
+
super(`Identity ${entity} not found${id ? `: ${id}` : ''}`);
|
|
9
|
+
this.entity = entity;
|
|
10
|
+
this.id = id;
|
|
11
|
+
this.name = 'IdentityNotFoundError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export class IdentityConflictError extends Error {
|
|
15
|
+
conflict;
|
|
16
|
+
code = 'identity_conflict';
|
|
17
|
+
constructor(conflict, message) {
|
|
18
|
+
super(message ?? `Identity conflict: ${conflict}`);
|
|
19
|
+
this.conflict = conflict;
|
|
20
|
+
this.name = 'IdentityConflictError';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export class AccountNotActiveError extends Error {
|
|
24
|
+
userId;
|
|
25
|
+
code = 'account_not_active';
|
|
26
|
+
constructor(userId) {
|
|
27
|
+
super(`Account is not active${userId ? `: ${userId}` : ''}`);
|
|
28
|
+
this.userId = userId;
|
|
29
|
+
this.name = 'AccountNotActiveError';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export class AccountTransitionError extends Error {
|
|
33
|
+
code = 'invalid_account_transition';
|
|
34
|
+
constructor(message = 'Account status transition is not allowed') {
|
|
35
|
+
super(message);
|
|
36
|
+
this.name = 'AccountTransitionError';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export class TenantNotActiveError extends Error {
|
|
40
|
+
tenantId;
|
|
41
|
+
code = 'tenant_not_active';
|
|
42
|
+
constructor(tenantId) {
|
|
43
|
+
super(`Tenant is not active${tenantId ? `: ${tenantId}` : ''}`);
|
|
44
|
+
this.tenantId = tenantId;
|
|
45
|
+
this.name = 'TenantNotActiveError';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export class TenantOffboardBlockedError extends Error {
|
|
49
|
+
tenantId;
|
|
50
|
+
liveSessions;
|
|
51
|
+
code = 'tenant_offboard_blocked';
|
|
52
|
+
constructor(tenantId, liveSessions) {
|
|
53
|
+
super(`Tenant ${tenantId} keeps ${liveSessions} live sessions; offboard is blocked without force`);
|
|
54
|
+
this.tenantId = tenantId;
|
|
55
|
+
this.liveSessions = liveSessions;
|
|
56
|
+
this.name = 'TenantOffboardBlockedError';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export class MembershipTransitionError extends Error {
|
|
60
|
+
code = 'invalid_membership_transition';
|
|
61
|
+
constructor(message = 'Tenant membership transition is not allowed') {
|
|
62
|
+
super(message);
|
|
63
|
+
this.name = 'MembershipTransitionError';
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export class InvitationError extends Error {
|
|
67
|
+
reason;
|
|
68
|
+
code = 'invitation_invalid';
|
|
69
|
+
constructor(reason) {
|
|
70
|
+
super(`Invitation is invalid: ${reason}`);
|
|
71
|
+
this.reason = reason;
|
|
72
|
+
this.name = 'InvitationError';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export class LoginSessionError extends Error {
|
|
76
|
+
reason;
|
|
77
|
+
code = 'login_session_invalid';
|
|
78
|
+
constructor(reason) {
|
|
79
|
+
super(`Login session is invalid: ${reason}`);
|
|
80
|
+
this.reason = reason;
|
|
81
|
+
this.name = 'LoginSessionError';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export class DeviceCodeError extends Error {
|
|
85
|
+
reason;
|
|
86
|
+
code = 'device_code_invalid';
|
|
87
|
+
constructor(reason) {
|
|
88
|
+
super(`Device code is invalid: ${reason}`);
|
|
89
|
+
this.reason = reason;
|
|
90
|
+
this.name = 'DeviceCodeError';
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export class WorkspaceAlreadyEnrolledError extends Error {
|
|
94
|
+
workspaceId;
|
|
95
|
+
code = 'workspace_already_enrolled';
|
|
96
|
+
constructor(workspaceId) {
|
|
97
|
+
super(`Workspace already enrolled for this repo: ${workspaceId}`);
|
|
98
|
+
this.workspaceId = workspaceId;
|
|
99
|
+
this.name = 'WorkspaceAlreadyEnrolledError';
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export class SelfActionForbiddenError extends Error {
|
|
103
|
+
action;
|
|
104
|
+
code = 'self_action_forbidden';
|
|
105
|
+
constructor(action) {
|
|
106
|
+
super(`Admin action on self is forbidden, use self-service: ${action}`);
|
|
107
|
+
this.action = action;
|
|
108
|
+
this.name = 'SelfActionForbiddenError';
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
export class AdminUserProtectedError extends Error {
|
|
112
|
+
action;
|
|
113
|
+
code = 'admin_user_protected';
|
|
114
|
+
constructor(action) {
|
|
115
|
+
super(`Cannot ${action} admin users`);
|
|
116
|
+
this.action = action;
|
|
117
|
+
this.name = 'AdminUserProtectedError';
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
export class ProofVerificationError extends Error {
|
|
121
|
+
reason;
|
|
122
|
+
code = 'proof_verification_failed';
|
|
123
|
+
constructor(reason) {
|
|
124
|
+
super(`Identity proof verification failed: ${reason}`);
|
|
125
|
+
this.reason = reason;
|
|
126
|
+
this.name = 'ProofVerificationError';
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","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,CAA+D;QAExF,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './types.js';
|
|
2
|
+
export * from './errors.js';
|
|
3
|
+
export * from './descriptors.js';
|
|
4
|
+
export * from './ports.js';
|
|
5
|
+
export * from './accounts.js';
|
|
6
|
+
export * from './access.js';
|
|
7
|
+
export * from './tenancy.js';
|
|
8
|
+
export * from './workspaces.js';
|
|
9
|
+
export * from './resolution.js';
|
|
10
|
+
export * from './enforcement.js';
|
|
11
|
+
export * from './doubles.js';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/identity-contracts/index.ts"],"names":[],"mappings":"AAEA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Identity core contracts (contract-only): public barrel.
|
|
2
|
+
export * from './types.js';
|
|
3
|
+
export * from './errors.js';
|
|
4
|
+
export * from './descriptors.js';
|
|
5
|
+
export * from './ports.js';
|
|
6
|
+
export * from './accounts.js';
|
|
7
|
+
export * from './access.js';
|
|
8
|
+
export * from './tenancy.js';
|
|
9
|
+
export * from './workspaces.js';
|
|
10
|
+
export * from './resolution.js';
|
|
11
|
+
export * from './enforcement.js';
|
|
12
|
+
export * from './doubles.js';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/identity-contracts/index.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAE1D,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { DeviceCodeRecord, DivergenceSample, DivergenceSummary, IdentityAuditEvent, IdentityProof, InvitationRecord, LoginSession, OAuthConsentRecord, ServiceClientBinding, TenantMembershipRecord, TenantRecord, TenantStatus, UserAccount, WorkspaceMembershipRecord, WorkspaceRecord } from './types.js';
|
|
2
|
+
export interface TenantRegistryStore {
|
|
3
|
+
createTenant(record: TenantRecord): Promise<void>;
|
|
4
|
+
findTenant(tenantId: string): Promise<TenantRecord | null>;
|
|
5
|
+
findTenantBySlug(slug: string): Promise<TenantRecord | null>;
|
|
6
|
+
listTenants(): Promise<readonly TenantRecord[]>;
|
|
7
|
+
setTenantStatus(tenantId: string, status: TenantStatus, at: string): Promise<TenantRecord>;
|
|
8
|
+
}
|
|
9
|
+
export interface UserAccountStore {
|
|
10
|
+
createAccount(record: UserAccount): Promise<void>;
|
|
11
|
+
findAccount(userId: string): Promise<UserAccount | null>;
|
|
12
|
+
findAccountByEmail(email: string): Promise<UserAccount | null>;
|
|
13
|
+
listAccounts(): Promise<readonly UserAccount[]>;
|
|
14
|
+
setAccountStatus(userId: string, status: UserAccount['accountStatus'], at: string): Promise<UserAccount>;
|
|
15
|
+
setGlobalRole(userId: string, role: UserAccount['globalRole'], at: string): Promise<UserAccount>;
|
|
16
|
+
deleteAccount(userId: string, at: string): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export interface IdentityProofStore {
|
|
19
|
+
addProof(record: IdentityProof): Promise<void>;
|
|
20
|
+
findProof(proofId: string): Promise<IdentityProof | null>;
|
|
21
|
+
listProofsForUser(userId: string): Promise<readonly IdentityProof[]>;
|
|
22
|
+
markProofConsumed(proofId: string, at: string): Promise<IdentityProof>;
|
|
23
|
+
revokeProof(proofId: string, at: string): Promise<IdentityProof>;
|
|
24
|
+
}
|
|
25
|
+
export interface InvitationStore {
|
|
26
|
+
saveInvitation(record: InvitationRecord): Promise<void>;
|
|
27
|
+
findInvitation(invitationId: string): Promise<InvitationRecord | null>;
|
|
28
|
+
findInvitationByToken(token: string): Promise<InvitationRecord | null>;
|
|
29
|
+
/** Atomically consumes a pending invitation; false when already consumed. */
|
|
30
|
+
markInvitationConsumed(token: string, at: string): Promise<boolean>;
|
|
31
|
+
revokeInvitation(invitationId: string): Promise<InvitationRecord>;
|
|
32
|
+
}
|
|
33
|
+
export interface DeviceCodeStore {
|
|
34
|
+
saveDeviceCode(record: DeviceCodeRecord): Promise<void>;
|
|
35
|
+
findDeviceCode(deviceCode: string): Promise<DeviceCodeRecord | null>;
|
|
36
|
+
findDeviceCodeByUser(userCode: string): Promise<DeviceCodeRecord | null>;
|
|
37
|
+
/** Atomically approves a pending device code; false when already resolved. */
|
|
38
|
+
approveDeviceCode(userCode: string, approvedUserId: string, at: string): Promise<boolean>;
|
|
39
|
+
}
|
|
40
|
+
export interface LoginSessionStore {
|
|
41
|
+
createSession(record: LoginSession): Promise<void>;
|
|
42
|
+
findSession(sessionId: string): Promise<LoginSession | null>;
|
|
43
|
+
touchSession(sessionId: string, update: Pick<LoginSession, 'expiresAt' | 'refreshCount'>): Promise<LoginSession>;
|
|
44
|
+
revokeSession(sessionId: string, at: string): Promise<LoginSession>;
|
|
45
|
+
revokeAllSessionsForUser(userId: string, at: string): Promise<number>;
|
|
46
|
+
listSessionsForUser(userId: string): Promise<readonly LoginSession[]>;
|
|
47
|
+
}
|
|
48
|
+
export interface TenantMembershipStore {
|
|
49
|
+
upsertMembershipRequest(record: TenantMembershipRecord): Promise<TenantMembershipRecord>;
|
|
50
|
+
findMembership(userId: string, tenantId: string): Promise<TenantMembershipRecord | null>;
|
|
51
|
+
setMembershipState(userId: string, tenantId: string, state: Pick<TenantMembershipRecord, 'status' | 'tenantRole'> & {
|
|
52
|
+
readonly decidedBy: string;
|
|
53
|
+
readonly decidedAt: string;
|
|
54
|
+
readonly updatedAt: string;
|
|
55
|
+
}): Promise<TenantMembershipRecord>;
|
|
56
|
+
listMembershipsForTenant(tenantId: string): Promise<readonly TenantMembershipRecord[]>;
|
|
57
|
+
listMembershipsForUser(userId: string): Promise<readonly TenantMembershipRecord[]>;
|
|
58
|
+
findApprovedMembership(userId: string, tenantId: string): Promise<TenantMembershipRecord | null>;
|
|
59
|
+
}
|
|
60
|
+
export interface WorkspaceDirectoryStore {
|
|
61
|
+
enrolWorkspace(record: WorkspaceRecord): Promise<void>;
|
|
62
|
+
findWorkspace(workspaceId: string): Promise<WorkspaceRecord | null>;
|
|
63
|
+
/** Uniqueness read for one workspace per repo (tenant x repoIdentity). */
|
|
64
|
+
findWorkspaceByRepoIdentity(tenantId: string, repoIdentity: string): Promise<WorkspaceRecord | null>;
|
|
65
|
+
listWorkspacesForTenant(tenantId: string): Promise<readonly WorkspaceRecord[]>;
|
|
66
|
+
approveWorkspaceAlias(workspaceId: string, alias: string): Promise<WorkspaceRecord>;
|
|
67
|
+
}
|
|
68
|
+
export interface WorkspaceMembershipStore {
|
|
69
|
+
putWorkspaceMember(record: WorkspaceMembershipRecord): Promise<WorkspaceMembershipRecord>;
|
|
70
|
+
removeWorkspaceMember(workspaceId: string, userId: string): Promise<boolean>;
|
|
71
|
+
findWorkspaceMember(workspaceId: string, userId: string): Promise<WorkspaceMembershipRecord | null>;
|
|
72
|
+
listWorkspaceMembers(workspaceId: string): Promise<readonly WorkspaceMembershipRecord[]>;
|
|
73
|
+
}
|
|
74
|
+
export interface OAuthTenantStore {
|
|
75
|
+
grantConsent(record: OAuthConsentRecord): Promise<void>;
|
|
76
|
+
revokeConsent(consentId: string, at: string): Promise<boolean>;
|
|
77
|
+
bindServiceClient(record: ServiceClientBinding): Promise<void>;
|
|
78
|
+
listTenantServiceClients(tenantId: string): Promise<readonly ServiceClientBinding[]>;
|
|
79
|
+
}
|
|
80
|
+
export interface IdentityAuditPort {
|
|
81
|
+
append(event: IdentityAuditEvent): Promise<void>;
|
|
82
|
+
}
|
|
83
|
+
export interface DivergenceMetricsPort {
|
|
84
|
+
record(sample: Omit<DivergenceSample, 'at'> & {
|
|
85
|
+
readonly at?: string;
|
|
86
|
+
}): void;
|
|
87
|
+
summary(): DivergenceSummary;
|
|
88
|
+
}
|
|
89
|
+
export interface AgentPlaneRevocationPort {
|
|
90
|
+
closeAgentSessionsForUser(userId: string): Promise<number>;
|
|
91
|
+
}
|
|
92
|
+
export interface InvitationTokenPort {
|
|
93
|
+
issue(): string;
|
|
94
|
+
}
|
|
95
|
+
export interface IdentityStores {
|
|
96
|
+
readonly tenants: TenantRegistryStore;
|
|
97
|
+
readonly accounts: UserAccountStore;
|
|
98
|
+
readonly proofs: IdentityProofStore;
|
|
99
|
+
readonly invitations: InvitationStore;
|
|
100
|
+
readonly deviceCodes: DeviceCodeStore;
|
|
101
|
+
readonly sessions: LoginSessionStore;
|
|
102
|
+
readonly memberships: TenantMembershipStore;
|
|
103
|
+
readonly workspaces: WorkspaceDirectoryStore;
|
|
104
|
+
readonly workspaceMembers: WorkspaceMembershipStore;
|
|
105
|
+
readonly oauth: OAuthTenantStore;
|
|
106
|
+
readonly audit: IdentityAuditPort;
|
|
107
|
+
}
|
|
108
|
+
export type IdentityPersistenceBinding = {
|
|
109
|
+
readonly mode: 'LOCAL_ONLY';
|
|
110
|
+
readonly local: IdentityStores;
|
|
111
|
+
} | {
|
|
112
|
+
readonly mode: 'DURABLE';
|
|
113
|
+
readonly durable: IdentityStores;
|
|
114
|
+
};
|
|
115
|
+
export declare function selectIdentityStores(binding: IdentityPersistenceBinding): IdentityStores;
|
|
116
|
+
//# sourceMappingURL=ports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../src/identity-contracts/ports.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,YAAY,EAEZ,YAAY,EACZ,WAAW,EACX,yBAAyB,EACzB,eAAe,EAEhB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,mBAAmB;IAClC,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IAC3D,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IAC7D,WAAW,IAAI,OAAO,CAAC,SAAS,YAAY,EAAE,CAAC,CAAC;IAChD,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAC5F;AAED,MAAM,WAAW,gBAAgB;IAC/B,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACzD,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC/D,YAAY,IAAI,OAAO,CAAC,SAAS,WAAW,EAAE,CAAC,CAAC;IAChD,gBAAgB,CACd,MAAM,EAAE,MAAM,EACd,MA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AM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,QAAQ,CAAC,WAAW,EAAE,eAAe,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,eAAe,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,WAAW,EAAE,qBAAqB,CAAC;IAC5C,QAAQ,CAAC,UAAU,EAAE,uBAAuB,CAAC;IAC7C,QAAQ,CAAC,gBAAgB,EAAE,wBAAwB,CAAC;IACpD,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;CACnC;AAED,MAAM,MAAM,0BAA0B,GAClC;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAA;CAAE,GAC/D;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAA;CAAE,CAAC;AAEnE,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,0BAA0B,GAAG,cAAc,CAExF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Identity core contracts: storage ports. One port per record class; backends
|
|
2
|
+
// (PostgreSQL hosted profile, SQLite local profile) implement these ports in
|
|
3
|
+
// later lots. Domains orchestrate through ports only, never through a driver.
|
|
4
|
+
export function selectIdentityStores(binding) {
|
|
5
|
+
return binding.mode === 'LOCAL_ONLY' ? binding.local : binding.durable;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=ports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ports.js","sourceRoot":"","sources":["../../src/identity-contracts/ports.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,6EAA6E;AAC7E,8EAA8E;AA4J9E,MAAM,UAAU,oBAAoB,CAAC,OAAmC;IACtE,OAAO,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { DivergenceMetricsPort, OAuthTenantStore, TenantMembershipStore, TenantRegistryStore, WorkspaceDirectoryStore } from './ports.js';
|
|
2
|
+
import { type AuthoritativeResolution, type IdentityClock, type OAuthConsentRecord, type ServiceClientBinding, type ShadowComparison, type TenantResolutionMode, type TidClaim } from './types.js';
|
|
3
|
+
export interface TenantResolver {
|
|
4
|
+
resolveAuthoritatively(input: {
|
|
5
|
+
readonly workspaceId: string;
|
|
6
|
+
readonly userId: string;
|
|
7
|
+
}): Promise<AuthoritativeResolution>;
|
|
8
|
+
resolveWithMode(input: {
|
|
9
|
+
readonly workspaceId: string;
|
|
10
|
+
readonly userId: string;
|
|
11
|
+
}, mode: TenantResolutionMode, options: {
|
|
12
|
+
readonly legacyResolve: (input: {
|
|
13
|
+
readonly workspaceId: string;
|
|
14
|
+
readonly userId: string;
|
|
15
|
+
}) => Promise<string>;
|
|
16
|
+
}): Promise<AuthoritativeResolution | {
|
|
17
|
+
readonly tid: string;
|
|
18
|
+
readonly mode: 'alias';
|
|
19
|
+
} | ShadowComparison>;
|
|
20
|
+
}
|
|
21
|
+
export declare function createTenantResolver(input: {
|
|
22
|
+
readonly workspaces: WorkspaceDirectoryStore;
|
|
23
|
+
readonly tenants: TenantRegistryStore;
|
|
24
|
+
readonly memberships: TenantMembershipStore;
|
|
25
|
+
readonly metrics: DivergenceMetricsPort;
|
|
26
|
+
readonly clock?: IdentityClock;
|
|
27
|
+
}): TenantResolver;
|
|
28
|
+
export interface TidIssuer {
|
|
29
|
+
issueTid(input: {
|
|
30
|
+
readonly userId: string;
|
|
31
|
+
readonly tenantId: string;
|
|
32
|
+
}, now: string): Promise<TidClaim>;
|
|
33
|
+
}
|
|
34
|
+
export declare function createTidIssuer(input: {
|
|
35
|
+
readonly memberships: TenantMembershipStore;
|
|
36
|
+
readonly tenants: TenantRegistryStore;
|
|
37
|
+
}): TidIssuer;
|
|
38
|
+
export interface TenantOAuthDomain {
|
|
39
|
+
grantConsent(input: {
|
|
40
|
+
readonly consentId: string;
|
|
41
|
+
readonly tenantId: string;
|
|
42
|
+
readonly userId: string;
|
|
43
|
+
readonly clientId: string;
|
|
44
|
+
}): Promise<OAuthConsentRecord>;
|
|
45
|
+
revokeConsent(consentId: string, actorId: string): Promise<boolean>;
|
|
46
|
+
bindServiceClient(input: {
|
|
47
|
+
readonly clientId: string;
|
|
48
|
+
readonly tenantId: string;
|
|
49
|
+
}): Promise<ServiceClientBinding>;
|
|
50
|
+
listTenantOAuthClients(tenantId: string): Promise<readonly ServiceClientBinding[]>;
|
|
51
|
+
}
|
|
52
|
+
export declare function createTenantOAuth(input: {
|
|
53
|
+
readonly oauth: OAuthTenantStore;
|
|
54
|
+
readonly clock?: IdentityClock;
|
|
55
|
+
}): TenantOAuthDomain;
|
|
56
|
+
//# sourceMappingURL=resolution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolution.d.ts","sourceRoot":"","sources":["../../src/identity-contracts/resolution.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AACpB,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,QAAQ,EACd,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,cAAc;IAC7B,sBAAsB,CAAC,KAAK,EAAE;QAAE,QAAQ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AC5C,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;CACvC,GAAG,SAAS,CAWZ;AAED,MAAM,WAAW,iBAAiB;IAChC,YAAY,CAAC,KAAK,EAAE;QAClB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;KAC3B,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAChC,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACpE,iBAAiB,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAClH,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,oBAAoB,EAAE,CAAC,CAAC;CACpF;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IACjC,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC;CAChC,GAAG,iBAAiB,CAoBpB"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// Identity core contracts: tenant resolution with switch-over modes (F12)
|
|
2
|
+
// and tid issuance with tenant-scoped OAuth legs (F13).
|
|
3
|
+
// Steady state is authoritative resolution only; alias/shadow are transition
|
|
4
|
+
// tooling with a deletion date in the lot plan, never permanent semantics.
|
|
5
|
+
import { TenantBoundaryError } from '../errors.js';
|
|
6
|
+
import { IdentityNotFoundError, TenantNotActiveError } from './errors.js';
|
|
7
|
+
import { systemIdentityClock, } from './types.js';
|
|
8
|
+
export function createTenantResolver(input) {
|
|
9
|
+
const clock = input.clock ?? systemIdentityClock;
|
|
10
|
+
async function authoritative(lookup) {
|
|
11
|
+
const workspace = await input.workspaces.findWorkspace(lookup.workspaceId);
|
|
12
|
+
if (!workspace)
|
|
13
|
+
throw new TenantBoundaryError();
|
|
14
|
+
const tenant = await input.tenants.findTenant(workspace.tenantId);
|
|
15
|
+
if (!tenant || tenant.status !== 'active')
|
|
16
|
+
throw new TenantBoundaryError();
|
|
17
|
+
const membership = await input.memberships.findApprovedMembership(lookup.userId, workspace.tenantId);
|
|
18
|
+
if (!membership || membership.status !== 'approved' || membership.userId !== lookup.userId) {
|
|
19
|
+
throw new TenantBoundaryError();
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
tid: tenant.slug,
|
|
23
|
+
tenantId: tenant.tenantId,
|
|
24
|
+
workspaceId: lookup.workspaceId,
|
|
25
|
+
userId: lookup.userId,
|
|
26
|
+
membershipRevision: membership.updatedAt,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
resolveAuthoritatively: authoritative,
|
|
31
|
+
async resolveWithMode(lookup, mode, options) {
|
|
32
|
+
if (mode === 'strict')
|
|
33
|
+
return authoritative(lookup);
|
|
34
|
+
if (mode === 'alias')
|
|
35
|
+
return { tid: await options.legacyResolve(lookup), mode: 'alias' };
|
|
36
|
+
let resolved = null;
|
|
37
|
+
try {
|
|
38
|
+
resolved = await authoritative(lookup);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
if (!(error instanceof TenantBoundaryError))
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
const legacyTid = await options.legacyResolve(lookup);
|
|
45
|
+
const diverged = resolved === null || resolved.tid !== legacyTid;
|
|
46
|
+
input.metrics.record({ workspaceId: lookup.workspaceId, userId: lookup.userId, diverged, at: clock() });
|
|
47
|
+
return { mode: 'shadow', authoritative: resolved, legacyTid, diverged };
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export function createTidIssuer(input) {
|
|
52
|
+
return {
|
|
53
|
+
async issueTid(claim, now) {
|
|
54
|
+
const tenant = await input.tenants.findTenant(claim.tenantId);
|
|
55
|
+
if (!tenant)
|
|
56
|
+
throw new IdentityNotFoundError('tenant', claim.tenantId);
|
|
57
|
+
const membership = await input.memberships.findApprovedMembership(claim.userId, claim.tenantId);
|
|
58
|
+
if (!membership || membership.status !== 'approved')
|
|
59
|
+
throw new TenantBoundaryError();
|
|
60
|
+
if (tenant.status !== 'active')
|
|
61
|
+
throw new TenantNotActiveError(claim.tenantId);
|
|
62
|
+
return { tid: tenant.slug, tenantId: tenant.tenantId, userId: claim.userId, issuedAt: now };
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export function createTenantOAuth(input) {
|
|
67
|
+
const clock = input.clock ?? systemIdentityClock;
|
|
68
|
+
return {
|
|
69
|
+
async grantConsent(consent) {
|
|
70
|
+
const record = { ...consent, grantedAt: clock() };
|
|
71
|
+
await input.oauth.grantConsent(record);
|
|
72
|
+
return record;
|
|
73
|
+
},
|
|
74
|
+
async revokeConsent(consentId, _actorId) {
|
|
75
|
+
return input.oauth.revokeConsent(consentId, clock());
|
|
76
|
+
},
|
|
77
|
+
async bindServiceClient(binding) {
|
|
78
|
+
const record = { ...binding, boundAt: clock() };
|
|
79
|
+
await input.oauth.bindServiceClient(record);
|
|
80
|
+
return record;
|
|
81
|
+
},
|
|
82
|
+
async listTenantOAuthClients(tenantId) {
|
|
83
|
+
return input.oauth.listTenantServiceClients(tenantId);
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=resolution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolution.js","sourceRoot":"","sources":["../../src/identity-contracts/resolution.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,wDAAwD;AACxD,6EAA6E;AAC7E,2EAA2E;AAE3E,OAAO,EAA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5C,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,KAAK,CAAC,sBAAsB,CAAC,QAAQ;YACnC,OAAO,KAAK,CAAC,KAAK,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QACxD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { IdentityAuditPort, LoginSessionStore, TenantMembershipStore, TenantRegistryStore } from './ports.js';
|
|
2
|
+
import { type IdentityClock, type MembershipDecision, type MembershipRequestReceipt, type TenantMembershipRecord, type TenantRecord, type TenantRole } from './types.js';
|
|
3
|
+
export interface TenantRegistryDomain {
|
|
4
|
+
createTenant(input: {
|
|
5
|
+
readonly tenantId: string;
|
|
6
|
+
readonly slug: string;
|
|
7
|
+
}, actorId: string): Promise<TenantRecord>;
|
|
8
|
+
getTenant(tenantId: string): Promise<TenantRecord>;
|
|
9
|
+
listTenants(): Promise<readonly TenantRecord[]>;
|
|
10
|
+
suspendTenant(tenantId: string, actorId: string): Promise<TenantRecord>;
|
|
11
|
+
offboardTenant(tenantId: string, input: {
|
|
12
|
+
readonly actorId: string;
|
|
13
|
+
readonly force?: boolean;
|
|
14
|
+
}): Promise<TenantRecord>;
|
|
15
|
+
}
|
|
16
|
+
export declare function createTenantRegistry(input: {
|
|
17
|
+
readonly tenants: TenantRegistryStore;
|
|
18
|
+
readonly memberships: TenantMembershipStore;
|
|
19
|
+
readonly sessions: LoginSessionStore;
|
|
20
|
+
readonly audit: IdentityAuditPort;
|
|
21
|
+
readonly clock?: IdentityClock;
|
|
22
|
+
}): TenantRegistryDomain;
|
|
23
|
+
export interface TenantMembershipDomain {
|
|
24
|
+
requestMembership(input: {
|
|
25
|
+
readonly userId: string;
|
|
26
|
+
readonly tenantId: string;
|
|
27
|
+
}): Promise<MembershipRequestReceipt>;
|
|
28
|
+
inviteMember(input: {
|
|
29
|
+
readonly userId: string;
|
|
30
|
+
readonly tenantId: string;
|
|
31
|
+
readonly role?: TenantRole;
|
|
32
|
+
readonly actorId: string;
|
|
33
|
+
}): Promise<TenantMembershipRecord>;
|
|
34
|
+
decideMembership(input: {
|
|
35
|
+
readonly userId: string;
|
|
36
|
+
readonly tenantId: string;
|
|
37
|
+
readonly decision: MembershipDecision;
|
|
38
|
+
readonly actorId: string;
|
|
39
|
+
readonly role?: TenantRole;
|
|
40
|
+
}): Promise<TenantMembershipRecord>;
|
|
41
|
+
listMembershipsForTenant(tenantId: string): Promise<readonly TenantMembershipRecord[]>;
|
|
42
|
+
listMembershipsForUser(userId: string): Promise<readonly TenantMembershipRecord[]>;
|
|
43
|
+
/** Internal read for the boundary domain; never served from caller input. */
|
|
44
|
+
resolveApprovedMembership(userId: string, tenantId: string): Promise<TenantMembershipRecord | null>;
|
|
45
|
+
}
|
|
46
|
+
export declare function createTenantMemberships(input: {
|
|
47
|
+
readonly memberships: TenantMembershipStore;
|
|
48
|
+
readonly tenants: TenantRegistryStore;
|
|
49
|
+
readonly audit: IdentityAuditPort;
|
|
50
|
+
readonly clock?: IdentityClock;
|
|
51
|
+
}): TenantMembershipDomain;
|
|
52
|
+
//# sourceMappingURL=tenancy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenancy.d.ts","sourceRoot":"","sources":["../../src/identity-contracts/tenancy.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,KAAK,UAAU,EAChB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,oBAAoB;IACnC,YAAY,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EA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