@opengeni/core 2.5.3 → 2.6.4-canary.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 (46) hide show
  1. package/dist/access/index.d.ts +24 -0
  2. package/dist/billing/limits.d.ts +5 -0
  3. package/dist/canonical-human-identities.js +2 -2
  4. package/dist/{chunk-ZVZJTMSV.js → chunk-OF65T3PM.js} +2 -2
  5. package/dist/{chunk-YGOMUGYS.js → chunk-QO5GVFFO.js} +17 -8
  6. package/dist/{chunk-YGOMUGYS.js.map → chunk-QO5GVFFO.js.map} +1 -1
  7. package/dist/dependencies.d.ts +10 -1
  8. package/dist/domain/company-brain-governed-writes.d.ts +15 -6
  9. package/dist/domain/company-profile-agent-admin.d.ts +3 -2
  10. package/dist/domain/environments.d.ts +1 -1
  11. package/dist/domain/memory-slack-delivery.d.ts +4 -1
  12. package/dist/domain/personal-connection-delegations.d.ts +1 -0
  13. package/dist/domain/pr-review.d.ts +1 -1
  14. package/dist/domain/scheduled-tasks.d.ts +12 -0
  15. package/dist/domain/sessions.d.ts +37 -11
  16. package/dist/domain/workspace-members.d.ts +8 -1
  17. package/dist/index.d.ts +1 -0
  18. package/dist/index.js +1706 -667
  19. package/dist/index.js.map +1 -1
  20. package/dist/managed-auth-session-sets.d.ts +18 -0
  21. package/dist/managed-auth-session-sets.js +3 -1
  22. package/dist/model-catalog.d.ts +89 -0
  23. package/dist/sandbox/fleet.d.ts +6 -4
  24. package/dist/sandbox/routing.d.ts +7 -2
  25. package/dist/sandbox/runtime-settings.d.ts +17 -1
  26. package/package.json +10 -10
  27. package/src/access/index.ts +140 -5
  28. package/src/application/user-resource-grants.ts +31 -2
  29. package/src/billing/limits.ts +57 -24
  30. package/src/dependencies.ts +15 -1
  31. package/src/domain/company-brain-governed-writes.ts +29 -13
  32. package/src/domain/company-profile-agent-admin.ts +3 -2
  33. package/src/domain/environments.ts +6 -34
  34. package/src/domain/memory-slack-delivery.ts +30 -0
  35. package/src/domain/personal-connection-delegations.ts +40 -7
  36. package/src/domain/remember.ts +5 -6
  37. package/src/domain/scheduled-tasks.ts +146 -1
  38. package/src/domain/sessions.ts +912 -358
  39. package/src/domain/workspace-members.ts +34 -2
  40. package/src/index.ts +1 -0
  41. package/src/managed-auth-session-sets.ts +38 -11
  42. package/src/model-catalog.ts +565 -0
  43. package/src/sandbox/fleet.ts +20 -17
  44. package/src/sandbox/routing.ts +18 -4
  45. package/src/sandbox/runtime-settings.ts +32 -0
  46. /package/dist/{chunk-ZVZJTMSV.js.map → chunk-OF65T3PM.js.map} +0 -0
@@ -44,7 +44,9 @@ export function assertWorkspaceMemberRemovable(input: {
44
44
  }): void {
45
45
  const { members, subjectId, callerSubjectId } = input;
46
46
  if (subjectId === callerSubjectId) {
47
- throw new HTTPException(409, { message: "you cannot remove your own membership" });
47
+ throw new HTTPException(409, {
48
+ message: "you cannot remove your own membership",
49
+ });
48
50
  }
49
51
  const target = members.find((member) => member.subjectId === subjectId);
50
52
  if (!target) {
@@ -62,6 +64,34 @@ export function assertWorkspaceMemberRemovable(input: {
62
64
  }
63
65
  }
64
66
 
67
+ /** Keep scoped member edits from orphaning the workspace or changing the caller's own grant. */
68
+ export function assertWorkspaceMemberUpdateAllowed(input: {
69
+ members: WorkspaceMember[];
70
+ subjectId: string;
71
+ callerSubjectId: string;
72
+ nextPermissions: Permission[];
73
+ }): void {
74
+ const { members, subjectId, callerSubjectId, nextPermissions } = input;
75
+ if (subjectId === callerSubjectId) {
76
+ throw new HTTPException(409, {
77
+ message: "you cannot change your own workspace access",
78
+ });
79
+ }
80
+ const target = members.find((member) => member.subjectId === subjectId);
81
+ if (!target) {
82
+ throw new HTTPException(404, { message: "member not found" });
83
+ }
84
+ if (
85
+ memberCanAdminister(target) &&
86
+ !memberCanAdminister({ permissions: nextPermissions }) &&
87
+ !members.some((member) => member.subjectId !== subjectId && memberCanAdminister(member))
88
+ ) {
89
+ throw new HTTPException(409, {
90
+ message: "the workspace must keep at least one administrator",
91
+ });
92
+ }
93
+ }
94
+
65
95
  /**
66
96
  * Guard the workspace-delete path before any external/DB mutation. Refuses
67
97
  * (409) to delete the account's last workspace, and refuses while any session
@@ -74,7 +104,9 @@ export function assertWorkspaceDeletable(input: {
74
104
  activeSessionCount: number;
75
105
  }): void {
76
106
  if (input.workspaceCountForAccount <= 1) {
77
- throw new HTTPException(409, { message: "cannot delete the account's only workspace" });
107
+ throw new HTTPException(409, {
108
+ message: "cannot delete the account's only workspace",
109
+ });
78
110
  }
79
111
  if (input.activeSessionCount > 0) {
80
112
  throw new HTTPException(409, {
package/src/index.ts CHANGED
@@ -49,6 +49,7 @@ export {
49
49
  type ManagedAuthActorMutationLeaseStamp,
50
50
  } from "./managed-session";
51
51
  export * from "./transcription";
52
+ export * from "./model-catalog";
52
53
 
53
54
  // Sandbox fleet/routing service — the closure of `domain/sessions.ts`
54
55
  // (`swapActiveSandbox` + `FleetContext`). apps/api re-imports these for its MCP
@@ -278,25 +278,48 @@ export async function authenticateAndAdoptManagedAuthSession(input: {
278
278
  credentials: { email: input.email, password: input.password },
279
279
  headers: input.isolatedHeaders,
280
280
  });
281
+ return await adoptManagedAuthSession({
282
+ ...input,
283
+ authorityHash: managedAuthSha256(input.authority),
284
+ transactionSecretHash: managedAuthSha256(input.transactionSecret),
285
+ authSessionId: created.authSessionId,
286
+ });
287
+ }
288
+
289
+ export async function adoptManagedAuthSession(input: {
290
+ db: Database;
291
+ adapter: ManagedAuthSessionAdapter;
292
+ authority: string;
293
+ authorityHash: string;
294
+ csrfHash: string;
295
+ operationId: string;
296
+ requestDigest: string;
297
+ expectedGeneration: string;
298
+ expectedActorEpoch: string;
299
+ transactionId: string;
300
+ transactionSecretHash: string;
301
+ authSessionId: string;
302
+ mode: ManagedAuthSessionSetMode;
303
+ }): Promise<{ projection: ManagedAuthDatabaseProjection; returnIntent: string | null }> {
281
304
  let completed: { projection: ManagedAuthDatabaseProjection; returnIntent: string | null };
282
305
  try {
283
306
  completed = await completeManagedAuthLoginTransaction(input.db, {
284
- authorityHash: managedAuthSha256(input.authority),
307
+ authorityHash: input.authorityHash,
285
308
  csrfHash: input.csrfHash,
286
309
  operationId: input.operationId,
287
310
  requestDigest: input.requestDigest,
288
311
  expectedGeneration: input.expectedGeneration,
289
312
  expectedActorEpoch: input.expectedActorEpoch,
290
313
  transactionId: input.transactionId,
291
- transactionSecretHash: managedAuthSha256(input.transactionSecret),
292
- authSessionId: created.authSessionId,
314
+ transactionSecretHash: input.transactionSecretHash,
315
+ authSessionId: input.authSessionId,
293
316
  mode: input.mode,
294
317
  });
295
318
  } catch (error) {
296
319
  let receipt: Awaited<ReturnType<typeof getManagedAuthSessionSetOperationReceipt>>;
297
320
  try {
298
321
  receipt = await getManagedAuthSessionSetOperationReceipt(input.db, {
299
- authorityHash: managedAuthSha256(input.authority),
322
+ authorityHash: input.authorityHash,
300
323
  operationId: input.operationId,
301
324
  requestDigest: input.requestDigest,
302
325
  });
@@ -304,14 +327,16 @@ export async function authenticateAndAdoptManagedAuthSession(input: {
304
327
  throw new ManagedAuthCompletionOutcomeUnknownError({ cause: receiptError });
305
328
  }
306
329
  if (receipt) {
307
- await reconcileCreatedManagedAuthSession(input, created.authSessionId);
330
+ await reconcileCreatedManagedAuthSession(input, input.authSessionId);
308
331
  return receipt;
309
332
  }
310
- await input.adapter.revokeSession(created).catch(() => undefined);
333
+ await input.adapter
334
+ .revokeSession({ authSessionId: input.authSessionId })
335
+ .catch(() => undefined);
311
336
  throw error;
312
337
  }
313
338
  try {
314
- await reconcileCreatedManagedAuthSession(input, created.authSessionId);
339
+ await reconcileCreatedManagedAuthSession(input, input.authSessionId);
315
340
  } catch (error) {
316
341
  throw new ManagedAuthCompletionOutcomeUnknownError({ cause: error });
317
342
  }
@@ -319,10 +344,12 @@ export async function authenticateAndAdoptManagedAuthSession(input: {
319
344
  }
320
345
 
321
346
  async function reconcileCreatedManagedAuthSession(
322
- input: Pick<
323
- Parameters<typeof authenticateAndAdoptManagedAuthSession>[0],
324
- "db" | "adapter" | "authority" | "mode"
325
- >,
347
+ input: {
348
+ db: Database;
349
+ adapter: ManagedAuthSessionAdapter;
350
+ authority: string;
351
+ mode: ManagedAuthSessionSetMode;
352
+ },
326
353
  authSessionId: string,
327
354
  ): Promise<void> {
328
355
  const snapshot = await getManagedAuthSessionSetSnapshot(input.db, {