@opengeni/db 0.31.1 → 0.36.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/dist/browser-auth.d.ts +209 -1
  2. package/dist/browser-downloads.d.ts +51 -0
  3. package/dist/browser-identities.d.ts +11 -2
  4. package/dist/browser-sessions.d.ts +83 -1
  5. package/dist/browser-state-artifacts.d.ts +75 -1
  6. package/dist/canonical-human-identities.d.ts +48 -0
  7. package/dist/canonical-human-identities.js +28 -0
  8. package/dist/canonical-human-identities.js.map +1 -0
  9. package/dist/capability-integrations.d.ts +8 -6
  10. package/dist/{chunk-MWDVXQOL.js → chunk-5KTIEDX7.js} +5773 -4212
  11. package/dist/chunk-5KTIEDX7.js.map +1 -0
  12. package/dist/chunk-FPVAD4CO.js +117 -0
  13. package/dist/chunk-FPVAD4CO.js.map +1 -0
  14. package/dist/chunk-GYO7ED2Q.js +259 -0
  15. package/dist/chunk-GYO7ED2Q.js.map +1 -0
  16. package/dist/{chunk-F5FT7BEZ.js → chunk-HSOWSYOX.js} +2 -2
  17. package/dist/{chunk-YHZXQ7HP.js → chunk-VKLB2ZGI.js} +446 -19
  18. package/dist/chunk-VKLB2ZGI.js.map +1 -0
  19. package/dist/{chunk-NBE6CHRI.js → chunk-VTPRIXKG.js} +49 -9
  20. package/dist/chunk-VTPRIXKG.js.map +1 -0
  21. package/dist/{chunk-ISI2TIUG.js → chunk-Z7VYMNPZ.js} +76 -4
  22. package/dist/chunk-Z7VYMNPZ.js.map +1 -0
  23. package/dist/database.d.ts +5 -0
  24. package/dist/editable-artifact-durable-export.js +2 -2
  25. package/dist/editable-artifacts.js +3 -3
  26. package/dist/index.d.ts +467 -29
  27. package/dist/index.js +23247 -16232
  28. package/dist/index.js.map +1 -1
  29. package/dist/insights.d.ts +23 -7
  30. package/dist/integration-bindings.d.ts +24 -24
  31. package/dist/integration-facets.d.ts +99 -0
  32. package/dist/interaction-revisions.d.ts +11 -0
  33. package/dist/interaction-schema.d.ts +698 -34
  34. package/dist/persistence-errors.d.ts +8 -0
  35. package/dist/provision-roles.js +1 -1
  36. package/dist/runtime-posture.d.ts +8 -7
  37. package/dist/schema.d.ts +9464 -5412
  38. package/dist/schema.js +51 -9
  39. package/dist/session-control.d.ts +29 -3
  40. package/dist/session-tenancy.d.ts +44 -0
  41. package/dist/session-tenancy.js +16 -0
  42. package/dist/session-tenancy.js.map +1 -0
  43. package/dist/slack-task-policy-schema.d.ts +847 -0
  44. package/dist/slack-task-policy.d.ts +65 -0
  45. package/dist/task-notes-schema.d.ts +924 -0
  46. package/dist/task-notes.d.ts +85 -0
  47. package/dist/video-generation.d.ts +9 -0
  48. package/dist/video-generation.js +5 -3
  49. package/dist/xai-subscription.d.ts +326 -0
  50. package/drizzle/0212_browser_state_transfer_hardening.sql +560 -0
  51. package/drizzle/0213_browser_interaction_authority.sql +67 -0
  52. package/drizzle/0214_browser_download_saves.sql +34 -0
  53. package/drizzle/0215_browser_controller_host.sql +385 -0
  54. package/drizzle/0216_browser_auth_health_evidence.sql +137 -0
  55. package/drizzle/0217_external_browser_auth_operations.sql +22 -0
  56. package/drizzle/0218_organization_tenancy_foundation.sql +299 -0
  57. package/drizzle/0219_organization_tenancy_managed_human_provisioning.sql +317 -0
  58. package/drizzle/0219_site_auth_maintenance_sessions.sql +234 -0
  59. package/drizzle/0220_memory_slack_append_only_cascade.sql +38 -0
  60. package/drizzle/0220_session_channels.sql +54 -0
  61. package/drizzle/0221_sessions_channel_index.sql +5 -0
  62. package/drizzle/0222_session_visibility_authority_epochs.sql +158 -0
  63. package/drizzle/0222_sessions_channel_fk.sql +89 -0
  64. package/drizzle/0223_pending_tool_event_output.sql +55 -0
  65. package/drizzle/0223_sessions_channel_fk_validate.sql +118 -0
  66. package/drizzle/0224_slack_post_outcome_reconciliation.sql +123 -0
  67. package/drizzle/0225_session_visibility_fork_activation.sql +1363 -0
  68. package/drizzle/0226_personal_codex_authority_foundation.sql +365 -0
  69. package/drizzle/0227_slack_native_actions.sql +145 -0
  70. package/drizzle/0228_interaction_controller_data_plane.sql +14 -0
  71. package/drizzle/0228_slack_task_policy.sql +400 -0
  72. package/drizzle/0229_slack_inbox_file_fact.sql +10 -0
  73. package/drizzle/0230_user_scoped_variable_sets_rigs.sql +84 -0
  74. package/drizzle/0231_integration_definition_identity_cutover.sql +271 -0
  75. package/drizzle/0232_integration_facet_authority_cutover.sql +610 -0
  76. package/drizzle/0233_skill_and_integration_authority_cutover.sql +1162 -0
  77. package/drizzle/0234_xai_subscription_authority.sql +1139 -0
  78. package/drizzle/0235_canonical_human_login_bindings.sql +920 -0
  79. package/drizzle/0236_browser_identity_lifecycle.sql +39 -0
  80. package/drizzle/0236_session_visibility_slack_policy.sql +72 -0
  81. package/drizzle/0237_interaction_transition_reaper.sql +263 -0
  82. package/drizzle/0238_goal_persistence_policy.sql +471 -0
  83. package/drizzle/0238_recover_unclaimed_session_turns.sql +307 -0
  84. package/drizzle/0238_supergrok_realtime_model.sql +29 -0
  85. package/drizzle/0239_supergrok_video_funding.sql +50 -0
  86. package/drizzle/0239_task_tree_notes.sql +990 -0
  87. package/package.json +13 -5
  88. package/src/browser-auth.ts +2600 -123
  89. package/src/browser-downloads.ts +517 -0
  90. package/src/browser-identities.ts +220 -3
  91. package/src/browser-sessions.ts +334 -45
  92. package/src/browser-state-artifacts.ts +402 -12
  93. package/src/canonical-human-identities.ts +317 -0
  94. package/src/capability-integrations.ts +121 -213
  95. package/src/database.ts +41 -1
  96. package/src/index.ts +4625 -411
  97. package/src/insights.ts +109 -28
  98. package/src/integration-bindings.ts +101 -101
  99. package/src/{integration-features.ts → integration-facets.ts} +187 -184
  100. package/src/interaction-revisions.ts +33 -3
  101. package/src/interaction-schema.ts +311 -8
  102. package/src/pack-components.ts +43 -43
  103. package/src/pack-installations.ts +0 -43
  104. package/src/persistence-errors.ts +60 -1
  105. package/src/plugin-packages.ts +9 -9
  106. package/src/provision-roles.ts +232 -0
  107. package/src/runtime-posture.ts +227 -14
  108. package/src/schema.ts +1188 -75
  109. package/src/session-control.ts +122 -37
  110. package/src/session-queue-commands.ts +78 -1
  111. package/src/session-tenancy.ts +188 -0
  112. package/src/session-tool-call-settlement.ts +9 -3
  113. package/src/slack-task-policy-schema.ts +130 -0
  114. package/src/slack-task-policy.ts +341 -0
  115. package/src/task-notes-schema.ts +135 -0
  116. package/src/task-notes.ts +178 -0
  117. package/src/video-generation.ts +90 -12
  118. package/src/workspace-artifacts.ts +1 -1
  119. package/src/xai-subscription.ts +1887 -0
  120. package/dist/chunk-ISI2TIUG.js.map +0 -1
  121. package/dist/chunk-MWDVXQOL.js.map +0 -1
  122. package/dist/chunk-NBE6CHRI.js.map +0 -1
  123. package/dist/chunk-YHZXQ7HP.js.map +0 -1
  124. package/dist/integration-features.d.ts +0 -99
  125. /package/dist/{chunk-F5FT7BEZ.js.map → chunk-HSOWSYOX.js.map} +0 -0
@@ -0,0 +1,117 @@
1
+ import {
2
+ rawRows,
3
+ rlsContextForWorkspace,
4
+ withWorkspaceSubjectRls,
5
+ withWorkspaceSubjectSessionActivityRls
6
+ } from "./chunk-Z7VYMNPZ.js";
7
+
8
+ // src/session-tenancy.ts
9
+ import { createHash } from "crypto";
10
+ import { sql } from "drizzle-orm";
11
+ function canonicalSessionVisibilityTransitionHash(input) {
12
+ return createHash("sha256").update(
13
+ JSON.stringify({
14
+ version: 1,
15
+ sessionId: input.sessionId,
16
+ targetVisibility: input.targetVisibility,
17
+ expectedAuthorityEpoch: input.expectedAuthorityEpoch
18
+ })
19
+ ).digest("hex");
20
+ }
21
+ function canonicalSessionForkHash(input) {
22
+ return createHash("sha256").update(
23
+ JSON.stringify({
24
+ version: 1,
25
+ sourceSessionId: input.sourceSessionId,
26
+ destinationWorkspaceId: input.destinationWorkspaceId,
27
+ destinationVisibility: input.destinationVisibility
28
+ })
29
+ ).digest("hex");
30
+ }
31
+ async function transitionSessionVisibility(db, input) {
32
+ if (!Number.isSafeInteger(input.expectedAuthorityEpoch) || input.expectedAuthorityEpoch < 1) {
33
+ throw new Error("expectedAuthorityEpoch must be a positive safe integer");
34
+ }
35
+ if (!input.operationKey.trim()) throw new Error("operationKey must not be empty");
36
+ const requestHash = canonicalSessionVisibilityTransitionHash(input);
37
+ const { accountId } = await rlsContextForWorkspace(db, input.workspaceId);
38
+ return await withWorkspaceSubjectSessionActivityRls(
39
+ db,
40
+ input.workspaceId,
41
+ input.actorSubjectId,
42
+ async (scopedDb) => {
43
+ const rows = await rawRows(
44
+ scopedDb,
45
+ sql`select
46
+ operation_id as "operationId",
47
+ visibility,
48
+ authority_epoch as "authorityEpoch",
49
+ owner_organization_membership_id as "ownerOrganizationMembershipId",
50
+ changed,
51
+ replay,
52
+ interrupted_attempt_count as "interruptedAttemptCount",
53
+ cancelled_turn_count as "cancelledTurnCount",
54
+ cancelled_update_count as "cancelledUpdateCount",
55
+ paused_goal_count as "pausedGoalCount",
56
+ revoked_grant_count as "revokedGrantCount"
57
+ from transition_session_visibility(
58
+ ${accountId}::uuid,
59
+ ${input.workspaceId}::uuid,
60
+ ${input.sessionId}::uuid,
61
+ ${input.actorSubjectId},
62
+ ${input.targetVisibility},
63
+ ${input.expectedAuthorityEpoch},
64
+ ${input.operationKey},
65
+ ${requestHash}
66
+ )`
67
+ );
68
+ const result = rows[0];
69
+ if (!result) throw new Error("Session visibility transition returned no result");
70
+ return result;
71
+ }
72
+ );
73
+ }
74
+ async function forkSessionContent(db, input) {
75
+ if (!input.operationKey.trim()) throw new Error("operationKey must not be empty");
76
+ const { accountId } = await rlsContextForWorkspace(db, input.sourceWorkspaceId);
77
+ const requestHash = canonicalSessionForkHash(input);
78
+ return await withWorkspaceSubjectRls(
79
+ db,
80
+ input.sourceWorkspaceId,
81
+ input.actorSubjectId,
82
+ async (scopedDb) => {
83
+ const rows = await rawRows(
84
+ scopedDb,
85
+ sql`select
86
+ operation_id as "operationId",
87
+ session_id as "sessionId",
88
+ workspace_id as "workspaceId",
89
+ visibility,
90
+ authority_epoch as "authorityEpoch",
91
+ copied_history_item_count as "copiedHistoryItemCount",
92
+ replay
93
+ from fork_session_content(
94
+ ${accountId}::uuid,
95
+ ${input.sourceWorkspaceId}::uuid,
96
+ ${input.sourceSessionId}::uuid,
97
+ ${input.actorSubjectId},
98
+ ${input.destinationWorkspaceId}::uuid,
99
+ ${input.destinationVisibility},
100
+ ${input.operationKey},
101
+ ${requestHash}
102
+ )`
103
+ );
104
+ const result = rows[0];
105
+ if (!result) throw new Error("Session fork returned no result");
106
+ return result;
107
+ }
108
+ );
109
+ }
110
+
111
+ export {
112
+ canonicalSessionVisibilityTransitionHash,
113
+ canonicalSessionForkHash,
114
+ transitionSessionVisibility,
115
+ forkSessionContent
116
+ };
117
+ //# sourceMappingURL=chunk-FPVAD4CO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/session-tenancy.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { sql } from \"drizzle-orm\";\nimport {\n rawRows,\n type Database,\n rlsContextForWorkspace,\n withWorkspaceSubjectRls,\n withWorkspaceSubjectSessionActivityRls,\n} from \"./database\";\n\nexport type SessionTenancyVisibility = \"user_private\" | \"workspace_shared\";\n\nexport type TransitionSessionVisibilityInput = {\n workspaceId: string;\n sessionId: string;\n actorSubjectId: string;\n targetVisibility: SessionTenancyVisibility;\n expectedAuthorityEpoch: number;\n operationKey: string;\n};\n\nexport type TransitionSessionVisibilityResult = {\n operationId: string;\n visibility: SessionTenancyVisibility;\n authorityEpoch: number;\n ownerOrganizationMembershipId: string | null;\n changed: boolean;\n replay: boolean;\n interruptedAttemptCount: number;\n cancelledTurnCount: number;\n cancelledUpdateCount: number;\n pausedGoalCount: number;\n revokedGrantCount: number;\n};\n\nexport type ForkSessionContentInput = {\n sourceWorkspaceId: string;\n sourceSessionId: string;\n actorSubjectId: string;\n destinationWorkspaceId: string;\n destinationVisibility: SessionTenancyVisibility;\n operationKey: string;\n};\n\nexport type ForkSessionContentResult = {\n operationId: string;\n sessionId: string;\n workspaceId: string;\n visibility: SessionTenancyVisibility;\n authorityEpoch: number;\n copiedHistoryItemCount: number;\n replay: boolean;\n};\n\nexport function canonicalSessionVisibilityTransitionHash(\n input: Pick<\n TransitionSessionVisibilityInput,\n \"sessionId\" | \"targetVisibility\" | \"expectedAuthorityEpoch\"\n >,\n): string {\n return createHash(\"sha256\")\n .update(\n JSON.stringify({\n version: 1,\n sessionId: input.sessionId,\n targetVisibility: input.targetVisibility,\n expectedAuthorityEpoch: input.expectedAuthorityEpoch,\n }),\n )\n .digest(\"hex\");\n}\n\nexport function canonicalSessionForkHash(\n input: Pick<\n ForkSessionContentInput,\n \"sourceSessionId\" | \"destinationWorkspaceId\" | \"destinationVisibility\"\n >,\n): string {\n return createHash(\"sha256\")\n .update(\n JSON.stringify({\n version: 1,\n sourceSessionId: input.sourceSessionId,\n destinationWorkspaceId: input.destinationWorkspaceId,\n destinationVisibility: input.destinationVisibility,\n }),\n )\n .digest(\"hex\");\n}\n\nexport async function transitionSessionVisibility(\n db: Database,\n input: TransitionSessionVisibilityInput,\n): Promise<TransitionSessionVisibilityResult> {\n if (!Number.isSafeInteger(input.expectedAuthorityEpoch) || input.expectedAuthorityEpoch < 1) {\n throw new Error(\"expectedAuthorityEpoch must be a positive safe integer\");\n }\n if (!input.operationKey.trim()) throw new Error(\"operationKey must not be empty\");\n const requestHash = canonicalSessionVisibilityTransitionHash(input);\n const { accountId } = await rlsContextForWorkspace(db, input.workspaceId);\n return await withWorkspaceSubjectSessionActivityRls(\n db,\n input.workspaceId,\n input.actorSubjectId,\n async (scopedDb) => {\n const rows = await rawRows<{\n operationId: string;\n visibility: SessionTenancyVisibility;\n authorityEpoch: number;\n ownerOrganizationMembershipId: string | null;\n changed: boolean;\n replay: boolean;\n interruptedAttemptCount: number;\n cancelledTurnCount: number;\n cancelledUpdateCount: number;\n pausedGoalCount: number;\n revokedGrantCount: number;\n }>(\n scopedDb,\n sql`select\n operation_id as \"operationId\",\n visibility,\n authority_epoch as \"authorityEpoch\",\n owner_organization_membership_id as \"ownerOrganizationMembershipId\",\n changed,\n replay,\n interrupted_attempt_count as \"interruptedAttemptCount\",\n cancelled_turn_count as \"cancelledTurnCount\",\n cancelled_update_count as \"cancelledUpdateCount\",\n paused_goal_count as \"pausedGoalCount\",\n revoked_grant_count as \"revokedGrantCount\"\n from transition_session_visibility(\n ${accountId}::uuid,\n ${input.workspaceId}::uuid,\n ${input.sessionId}::uuid,\n ${input.actorSubjectId},\n ${input.targetVisibility},\n ${input.expectedAuthorityEpoch},\n ${input.operationKey},\n ${requestHash}\n )`,\n );\n const result = rows[0];\n if (!result) throw new Error(\"Session visibility transition returned no result\");\n return result;\n },\n );\n}\n\nexport async function forkSessionContent(\n db: Database,\n input: ForkSessionContentInput,\n): Promise<ForkSessionContentResult> {\n if (!input.operationKey.trim()) throw new Error(\"operationKey must not be empty\");\n const { accountId } = await rlsContextForWorkspace(db, input.sourceWorkspaceId);\n const requestHash = canonicalSessionForkHash(input);\n return await withWorkspaceSubjectRls(\n db,\n input.sourceWorkspaceId,\n input.actorSubjectId,\n async (scopedDb) => {\n const rows = await rawRows<ForkSessionContentResult>(\n scopedDb,\n sql`select\n operation_id as \"operationId\",\n session_id as \"sessionId\",\n workspace_id as \"workspaceId\",\n visibility,\n authority_epoch as \"authorityEpoch\",\n copied_history_item_count as \"copiedHistoryItemCount\",\n replay\n from fork_session_content(\n ${accountId}::uuid,\n ${input.sourceWorkspaceId}::uuid,\n ${input.sourceSessionId}::uuid,\n ${input.actorSubjectId},\n ${input.destinationWorkspaceId}::uuid,\n ${input.destinationVisibility},\n ${input.operationKey},\n ${requestHash}\n )`,\n );\n const result = rows[0];\n if (!result) throw new Error(\"Session fork returned no result\");\n return result;\n },\n );\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,WAAW;AAqDb,SAAS,yCACd,OAIQ;AACR,SAAO,WAAW,QAAQ,EACvB;AAAA,IACC,KAAK,UAAU;AAAA,MAC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ACmC;AACnC,MAAI,CAAC,MAAM,aAAa,KAAK,EAAG,OAAM,IAAI,MAAM,gCAAgC;AAChF,QAAM,EAAE,UAAU,IAAI,MAAM,uBAAuB,IAAI,MAAM,iBAAiB;AAC9E,QAAM,cAAc,yBAAyB,KAAK;AAClD,SAAO,MAAM;AAAA,IACX;AAAA,IACA,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO,aAAa;AAClB,YAAM,OAAO,MAAM;AAAA,QACjB;AAAA,QACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YASI,SAAS;AAAA,YACT,MAAM,iBAAiB;AAAA,YACvB,MAAM,eAAe;AAAA,YACrB,MAAM,cAAc;AAAA,YACpB,MAAM,sBAAsB;AAAA,YAC5B,MAAM,qBAAqB;AAAA,YAC3B,MAAM,YAAY;AAAA,YAClB,WAAW;AAAA;AAAA,MAEjB;AACA,YAAM,SAAS,KAAK,CAAC;AACrB,UAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,iCAAiC;AAC9D,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,259 @@
1
+ import {
2
+ nestedPostgresSqlState,
3
+ rawRows
4
+ } from "./chunk-Z7VYMNPZ.js";
5
+
6
+ // src/canonical-human-identities.ts
7
+ import { createHash } from "crypto";
8
+ import {
9
+ CanonicalHumanIdentityMutationResponse,
10
+ CanonicalHumanIdentityProjection
11
+ } from "@opengeni/contracts/canonical-human-identities";
12
+ import { sql } from "drizzle-orm";
13
+ var CanonicalHumanIdentityConflictError = class extends Error {
14
+ name = "CanonicalHumanIdentityConflictError";
15
+ code = "CANONICAL_HUMAN_IDENTITY_CONFLICT";
16
+ constructor() {
17
+ super("The canonical human identity changed in another request");
18
+ }
19
+ };
20
+ var CanonicalHumanIdentityOperationReuseError = class extends Error {
21
+ name = "CanonicalHumanIdentityOperationReuseError";
22
+ code = "CANONICAL_HUMAN_IDENTITY_OPERATION_REUSED";
23
+ constructor() {
24
+ super("The canonical human identity operation id was already used for another request");
25
+ }
26
+ };
27
+ var CanonicalHumanIdentityNotFoundError = class extends Error {
28
+ name = "CanonicalHumanIdentityNotFoundError";
29
+ constructor(message = "Canonical human identity was not found") {
30
+ super(message);
31
+ }
32
+ };
33
+ var CanonicalHumanIdentityAuthorityError = class extends Error {
34
+ name = "CanonicalHumanIdentityAuthorityError";
35
+ };
36
+ function deterministicOperationId(seed) {
37
+ const bytes = createHash("sha256").update(seed, "utf8").digest().subarray(0, 16);
38
+ bytes[6] = bytes[6] & 15 | 80;
39
+ bytes[8] = bytes[8] & 63 | 128;
40
+ const hex = bytes.toString("hex");
41
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
42
+ }
43
+ function projectionValue(value) {
44
+ if (typeof value === "string") return JSON.parse(value);
45
+ return value;
46
+ }
47
+ function mapSqlError(error) {
48
+ const state = nestedPostgresSqlState(error);
49
+ if (state === "40001") throw new CanonicalHumanIdentityConflictError();
50
+ if (state === "23505") throw new CanonicalHumanIdentityOperationReuseError();
51
+ if (state === "P0002") throw new CanonicalHumanIdentityNotFoundError();
52
+ if (state === "42501") {
53
+ throw new CanonicalHumanIdentityAuthorityError(
54
+ error instanceof Error ? error.message : "Canonical human identity authority denied"
55
+ );
56
+ }
57
+ throw error;
58
+ }
59
+ async function ensureCanonicalHumanIdentity(db, input) {
60
+ try {
61
+ const [row] = await rawRows(
62
+ db,
63
+ sql`
64
+ select
65
+ identity_id as "identityId",
66
+ identity_revision as "identityRevision",
67
+ auth_revision as "authRevision",
68
+ identity_status as "identityStatus"
69
+ from ensure_canonical_human_identity(${input.authUserId}, ${input.displayName})
70
+ `
71
+ );
72
+ if (!row) throw new CanonicalHumanIdentityNotFoundError();
73
+ return {
74
+ identityId: row.identityId,
75
+ identityRevision: Number(row.identityRevision),
76
+ authRevision: Number(row.authRevision),
77
+ identityStatus: row.identityStatus
78
+ };
79
+ } catch (error) {
80
+ mapSqlError(error);
81
+ }
82
+ }
83
+ async function ensureCanonicalHumanIdentityForAuthUser(db, authUserId) {
84
+ const [user] = await rawRows(
85
+ db,
86
+ sql`
87
+ select coalesce(nullif(btrim(name), ''), email) as "displayName"
88
+ from auth_users
89
+ where id = ${authUserId}
90
+ limit 1
91
+ `
92
+ );
93
+ if (!user) throw new CanonicalHumanIdentityNotFoundError("Authentication user was not found");
94
+ return await ensureCanonicalHumanIdentity(db, {
95
+ authUserId,
96
+ displayName: user.displayName
97
+ });
98
+ }
99
+ async function synchronizeCanonicalHumanLoginBindings(db, authUserId) {
100
+ let authority = await ensureCanonicalHumanIdentityForAuthUser(db, authUserId);
101
+ const accounts = await rawRows(
102
+ db,
103
+ sql`
104
+ select
105
+ id,
106
+ lower(provider_id) as "providerId",
107
+ account_id as "providerAccountId"
108
+ from auth_identities
109
+ where user_id = ${authUserId}
110
+ order by created_at, id
111
+ `
112
+ );
113
+ for (const account of accounts) {
114
+ for (let attempt = 0; attempt < 4; attempt += 1) {
115
+ const projection = await getCanonicalHumanIdentityProjection(db, authUserId);
116
+ if (projection.activeIdentity.status !== "active") {
117
+ return {
118
+ identityId: projection.activeIdentity.id,
119
+ identityRevision: projection.activeIdentity.identityRevision,
120
+ authRevision: projection.activeIdentity.authRevision,
121
+ identityStatus: projection.activeIdentity.status
122
+ };
123
+ }
124
+ const existing = projection.loginBindings.find(
125
+ (binding) => binding.providerId === account.providerId && binding.providerAccountId === account.providerAccountId
126
+ );
127
+ if (existing?.status === "active") {
128
+ authority = {
129
+ identityId: projection.activeIdentity.id,
130
+ identityRevision: projection.activeIdentity.identityRevision,
131
+ authRevision: projection.activeIdentity.authRevision,
132
+ identityStatus: projection.activeIdentity.status
133
+ };
134
+ break;
135
+ }
136
+ try {
137
+ const result = await applyCanonicalHumanIdentityOperation(db, {
138
+ operationId: deterministicOperationId(
139
+ `canonical-human-account-link
140
+ ${account.id}
141
+ ${projection.activeIdentity.identityRevision}`
142
+ ),
143
+ authUserId,
144
+ expectedIdentityRevision: projection.activeIdentity.identityRevision,
145
+ operationType: "link",
146
+ providerId: account.providerId,
147
+ providerAccountId: account.providerAccountId,
148
+ reason: "Synchronize verified authentication account"
149
+ });
150
+ authority = {
151
+ identityId: result.identity.activeIdentity.id,
152
+ identityRevision: result.identity.activeIdentity.identityRevision,
153
+ authRevision: result.identity.activeIdentity.authRevision,
154
+ identityStatus: result.identity.activeIdentity.status
155
+ };
156
+ break;
157
+ } catch (error) {
158
+ if (error instanceof CanonicalHumanIdentityConflictError && attempt < 3) continue;
159
+ if (error instanceof CanonicalHumanIdentityAuthorityError) {
160
+ const currentProjection = await getCanonicalHumanIdentityProjection(db, authUserId);
161
+ if (currentProjection.activeIdentity.status !== "active") {
162
+ return {
163
+ identityId: currentProjection.activeIdentity.id,
164
+ identityRevision: currentProjection.activeIdentity.identityRevision,
165
+ authRevision: currentProjection.activeIdentity.authRevision,
166
+ identityStatus: currentProjection.activeIdentity.status
167
+ };
168
+ }
169
+ }
170
+ throw error;
171
+ }
172
+ }
173
+ }
174
+ return authority;
175
+ }
176
+ async function validateCanonicalHumanSession(db, input) {
177
+ try {
178
+ const [row] = await rawRows(
179
+ db,
180
+ sql`
181
+ select validate_canonical_human_session(
182
+ ${input.authSessionId},
183
+ ${input.authUserId},
184
+ ${input.allowRecovery ?? false}
185
+ ) as valid
186
+ `
187
+ );
188
+ return row?.valid === true;
189
+ } catch (error) {
190
+ mapSqlError(error);
191
+ }
192
+ }
193
+ async function getCanonicalHumanIdentityProjection(db, authUserId) {
194
+ try {
195
+ const [row] = await rawRows(
196
+ db,
197
+ sql`
198
+ select get_canonical_human_identity_projection(${authUserId}) as projection
199
+ `
200
+ );
201
+ if (row?.projection === null || row?.projection === void 0) {
202
+ throw new CanonicalHumanIdentityNotFoundError();
203
+ }
204
+ return CanonicalHumanIdentityProjection.parse(projectionValue(row.projection));
205
+ } catch (error) {
206
+ if (error instanceof CanonicalHumanIdentityNotFoundError) throw error;
207
+ mapSqlError(error);
208
+ }
209
+ }
210
+ async function applyCanonicalHumanIdentityOperation(db, input) {
211
+ try {
212
+ const [row] = await rawRows(
213
+ db,
214
+ sql`
215
+ select
216
+ outcome,
217
+ identity_id as "identityId",
218
+ identity_revision as "identityRevision",
219
+ auth_revision as "authRevision"
220
+ from apply_canonical_human_identity_operation(
221
+ ${input.operationId},
222
+ ${input.authUserId},
223
+ ${input.expectedIdentityRevision},
224
+ ${input.operationType},
225
+ ${input.bindingId ?? null},
226
+ ${input.providerId ?? null},
227
+ ${input.providerAccountId ?? null},
228
+ ${input.reason}
229
+ )
230
+ `
231
+ );
232
+ if (!row) throw new CanonicalHumanIdentityNotFoundError();
233
+ const identity = await getCanonicalHumanIdentityProjection(db, input.authUserId);
234
+ return CanonicalHumanIdentityMutationResponse.parse({
235
+ outcome: row.outcome,
236
+ operationId: input.operationId,
237
+ identity
238
+ });
239
+ } catch (error) {
240
+ if (error instanceof CanonicalHumanIdentityConflictError || error instanceof CanonicalHumanIdentityOperationReuseError || error instanceof CanonicalHumanIdentityNotFoundError || error instanceof CanonicalHumanIdentityAuthorityError) {
241
+ throw error;
242
+ }
243
+ mapSqlError(error);
244
+ }
245
+ }
246
+
247
+ export {
248
+ CanonicalHumanIdentityConflictError,
249
+ CanonicalHumanIdentityOperationReuseError,
250
+ CanonicalHumanIdentityNotFoundError,
251
+ CanonicalHumanIdentityAuthorityError,
252
+ ensureCanonicalHumanIdentity,
253
+ ensureCanonicalHumanIdentityForAuthUser,
254
+ synchronizeCanonicalHumanLoginBindings,
255
+ validateCanonicalHumanSession,
256
+ getCanonicalHumanIdentityProjection,
257
+ applyCanonicalHumanIdentityOperation
258
+ };
259
+ //# sourceMappingURL=chunk-GYO7ED2Q.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/canonical-human-identities.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport {\n CanonicalHumanIdentityMutationResponse,\n CanonicalHumanIdentityProjection,\n type CanonicalHumanIdentityMutationOutcome,\n type CanonicalHumanIdentityMutationResponse as CanonicalHumanIdentityMutationResponseType,\n type CanonicalHumanIdentityProjection as CanonicalHumanIdentityProjectionType,\n} from \"@opengeni/contracts/canonical-human-identities\";\nimport { sql } from \"drizzle-orm\";\nimport type { Database } from \"./database\";\nimport { rawRows } from \"./database\";\nimport { nestedPostgresSqlState } from \"./persistence-errors\";\n\nexport type CanonicalHumanSessionAuthority = {\n identityId: string;\n identityRevision: number;\n authRevision: number;\n identityStatus: \"active\" | \"recovery_required\" | \"disputed\" | \"disabled\";\n};\n\nexport class CanonicalHumanIdentityConflictError extends Error {\n readonly name = \"CanonicalHumanIdentityConflictError\";\n readonly code = \"CANONICAL_HUMAN_IDENTITY_CONFLICT\";\n\n constructor() {\n super(\"The canonical human identity changed in another request\");\n }\n}\n\nexport class CanonicalHumanIdentityOperationReuseError extends Error {\n readonly name = \"CanonicalHumanIdentityOperationReuseError\";\n readonly code = \"CANONICAL_HUMAN_IDENTITY_OPERATION_REUSED\";\n\n constructor() {\n super(\"The canonical human identity operation id was already used for another request\");\n }\n}\n\nexport class CanonicalHumanIdentityNotFoundError extends Error {\n readonly name = \"CanonicalHumanIdentityNotFoundError\";\n\n constructor(message = \"Canonical human identity was not found\") {\n super(message);\n }\n}\n\nexport class CanonicalHumanIdentityAuthorityError extends Error {\n readonly name = \"CanonicalHumanIdentityAuthorityError\";\n}\n\nfunction deterministicOperationId(seed: string): string {\n const bytes = createHash(\"sha256\").update(seed, \"utf8\").digest().subarray(0, 16);\n bytes[6] = (bytes[6]! & 0x0f) | 0x50;\n bytes[8] = (bytes[8]! & 0x3f) | 0x80;\n const hex = bytes.toString(\"hex\");\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n}\n\nfunction projectionValue(value: unknown): unknown {\n if (typeof value === \"string\") return JSON.parse(value);\n return value;\n}\n\nfunction mapSqlError(error: unknown): never {\n const state = nestedPostgresSqlState(error);\n if (state === \"40001\") throw new CanonicalHumanIdentityConflictError();\n if (state === \"23505\") throw new CanonicalHumanIdentityOperationReuseError();\n if (state === \"P0002\") throw new CanonicalHumanIdentityNotFoundError();\n if (state === \"42501\") {\n throw new CanonicalHumanIdentityAuthorityError(\n error instanceof Error ? error.message : \"Canonical human identity authority denied\",\n );\n }\n throw error;\n}\n\nexport async function ensureCanonicalHumanIdentity(\n db: Database,\n input: { authUserId: string; displayName: string },\n): Promise<CanonicalHumanSessionAuthority> {\n try {\n const [row] = await rawRows<{\n identityId: string;\n identityRevision: number | string;\n authRevision: number | string;\n identityStatus: CanonicalHumanSessionAuthority[\"identityStatus\"];\n }>(\n db,\n sql`\n select\n identity_id as \"identityId\",\n identity_revision as \"identityRevision\",\n auth_revision as \"authRevision\",\n identity_status as \"identityStatus\"\n from ensure_canonical_human_identity(${input.authUserId}, ${input.displayName})\n `,\n );\n if (!row) throw new CanonicalHumanIdentityNotFoundError();\n return {\n identityId: row.identityId,\n identityRevision: Number(row.identityRevision),\n authRevision: Number(row.authRevision),\n identityStatus: row.identityStatus,\n };\n } catch (error) {\n mapSqlError(error);\n }\n}\n\nexport async function ensureCanonicalHumanIdentityForAuthUser(\n db: Database,\n authUserId: string,\n): Promise<CanonicalHumanSessionAuthority> {\n const [user] = await rawRows<{ displayName: string }>(\n db,\n sql`\n select coalesce(nullif(btrim(name), ''), email) as \"displayName\"\n from auth_users\n where id = ${authUserId}\n limit 1\n `,\n );\n if (!user) throw new CanonicalHumanIdentityNotFoundError(\"Authentication user was not found\");\n return await ensureCanonicalHumanIdentity(db, {\n authUserId,\n displayName: user.displayName,\n });\n}\n\nexport async function synchronizeCanonicalHumanLoginBindings(\n db: Database,\n authUserId: string,\n): Promise<CanonicalHumanSessionAuthority> {\n let authority = await ensureCanonicalHumanIdentityForAuthUser(db, authUserId);\n const accounts = await rawRows<{\n id: string;\n providerId: string;\n providerAccountId: string;\n }>(\n db,\n sql`\n select\n id,\n lower(provider_id) as \"providerId\",\n account_id as \"providerAccountId\"\n from auth_identities\n where user_id = ${authUserId}\n order by created_at, id\n `,\n );\n\n for (const account of accounts) {\n for (let attempt = 0; attempt < 4; attempt += 1) {\n const projection = await getCanonicalHumanIdentityProjection(db, authUserId);\n if (projection.activeIdentity.status !== \"active\") {\n return {\n identityId: projection.activeIdentity.id,\n identityRevision: projection.activeIdentity.identityRevision,\n authRevision: projection.activeIdentity.authRevision,\n identityStatus: projection.activeIdentity.status,\n };\n }\n const existing = projection.loginBindings.find(\n (binding) =>\n binding.providerId === account.providerId &&\n binding.providerAccountId === account.providerAccountId,\n );\n if (existing?.status === \"active\") {\n authority = {\n identityId: projection.activeIdentity.id,\n identityRevision: projection.activeIdentity.identityRevision,\n authRevision: projection.activeIdentity.authRevision,\n identityStatus: projection.activeIdentity.status,\n };\n break;\n }\n try {\n const result = await applyCanonicalHumanIdentityOperation(db, {\n operationId: deterministicOperationId(\n `canonical-human-account-link\\n${account.id}\\n${projection.activeIdentity.identityRevision}`,\n ),\n authUserId,\n expectedIdentityRevision: projection.activeIdentity.identityRevision,\n operationType: \"link\",\n providerId: account.providerId,\n providerAccountId: account.providerAccountId,\n reason: \"Synchronize verified authentication account\",\n });\n authority = {\n identityId: result.identity.activeIdentity.id,\n identityRevision: result.identity.activeIdentity.identityRevision,\n authRevision: result.identity.activeIdentity.authRevision,\n identityStatus: result.identity.activeIdentity.status,\n };\n break;\n } catch (error) {\n if (error instanceof CanonicalHumanIdentityConflictError && attempt < 3) continue;\n if (error instanceof CanonicalHumanIdentityAuthorityError) {\n const currentProjection = await getCanonicalHumanIdentityProjection(db, authUserId);\n if (currentProjection.activeIdentity.status !== \"active\") {\n return {\n identityId: currentProjection.activeIdentity.id,\n identityRevision: currentProjection.activeIdentity.identityRevision,\n authRevision: currentProjection.activeIdentity.authRevision,\n identityStatus: currentProjection.activeIdentity.status,\n };\n }\n }\n throw error;\n }\n }\n }\n return authority;\n}\n\nexport async function validateCanonicalHumanSession(\n db: Database,\n input: { authSessionId: string; authUserId: string; allowRecovery?: boolean },\n): Promise<boolean> {\n try {\n const [row] = await rawRows<{ valid: boolean }>(\n db,\n sql`\n select validate_canonical_human_session(\n ${input.authSessionId},\n ${input.authUserId},\n ${input.allowRecovery ?? false}\n ) as valid\n `,\n );\n return row?.valid === true;\n } catch (error) {\n mapSqlError(error);\n }\n}\n\nexport async function getCanonicalHumanIdentityProjection(\n db: Database,\n authUserId: string,\n): Promise<CanonicalHumanIdentityProjectionType> {\n try {\n const [row] = await rawRows<{ projection: unknown }>(\n db,\n sql`\n select get_canonical_human_identity_projection(${authUserId}) as projection\n `,\n );\n if (row?.projection === null || row?.projection === undefined) {\n throw new CanonicalHumanIdentityNotFoundError();\n }\n return CanonicalHumanIdentityProjection.parse(projectionValue(row.projection));\n } catch (error) {\n if (error instanceof CanonicalHumanIdentityNotFoundError) throw error;\n mapSqlError(error);\n }\n}\n\nexport type ApplyCanonicalHumanIdentityOperationInput = {\n operationId: string;\n authUserId: string;\n expectedIdentityRevision: number;\n operationType: \"link\" | \"unlink\" | \"begin_recovery\" | \"recover\";\n bindingId?: string | null;\n providerId?: string | null;\n providerAccountId?: string | null;\n reason: string;\n};\n\nexport async function applyCanonicalHumanIdentityOperation(\n db: Database,\n input: ApplyCanonicalHumanIdentityOperationInput,\n): Promise<CanonicalHumanIdentityMutationResponseType> {\n try {\n const [row] = await rawRows<{\n outcome: CanonicalHumanIdentityMutationOutcome;\n identityId: string;\n identityRevision: number | string;\n authRevision: number | string;\n }>(\n db,\n sql`\n select\n outcome,\n identity_id as \"identityId\",\n identity_revision as \"identityRevision\",\n auth_revision as \"authRevision\"\n from apply_canonical_human_identity_operation(\n ${input.operationId},\n ${input.authUserId},\n ${input.expectedIdentityRevision},\n ${input.operationType},\n ${input.bindingId ?? null},\n ${input.providerId ?? null},\n ${input.providerAccountId ?? null},\n ${input.reason}\n )\n `,\n );\n if (!row) throw new CanonicalHumanIdentityNotFoundError();\n const identity = await getCanonicalHumanIdentityProjection(db, input.authUserId);\n return CanonicalHumanIdentityMutationResponse.parse({\n outcome: row.outcome,\n operationId: input.operationId,\n identity,\n });\n } catch (error) {\n if (\n error instanceof CanonicalHumanIdentityConflictError ||\n error instanceof CanonicalHumanIdentityOperationReuseError ||\n error instanceof CanonicalHumanIdentityNotFoundError ||\n error instanceof CanonicalHumanIdentityAuthorityError\n ) {\n throw error;\n }\n mapSqlError(error);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAS,kBAAkB;AAC3B;AAAA,EACE;AAAA,EACA;AAAA,OAIK;AACP,SAAS,WAAW;AAYb,IAAM,sCAAN,cAAkD,MAAM;AAAA,EACpD,OAAO;AAAA,EACP,OAAO;AAAA,EAEhB,cAAc;AACZ,UAAM,yDAAyD;AAAA,EACjE;AACF;AAEO,IAAM,4CAAN,cAAwD,MAAM;AAAA,EAC1D,OAAO;AAAA,EACP,OAAO;AAAA,EAEhB,cAAc;AACZ,UAAM,gFAAgF;AAAA,EACxF;AACF;AAEO,IAAM,sCAAN,cAAkD,MAAM;AAAA,EACpD,OAAO;AAAA,EAEhB,YAAY,UAAU,0CAA0C;AAC9D,UAAM,OAAO;AAAA,EACf;AACF;AAEO,IAAM,uCAAN,cAAmD,MAAM;AAAA,EACrD,OAAO;AAClB;AAEA,SAAS,yBAAyB,MAAsB;AACtD,QAAM,QAAQ,WAAW,QAAQ,EAAE,OAAO,MAAM,MAAM,EAAE,OAAO,EAAE,SAAS,GAAG,EAAE;AAC/E,QAAM,CAAC,IAAK,MAAM,CAAC,IAAK,KAAQ;AAChC,QAAM,CAAC,IAAK,MAAM,CAAC,IAAK,KAAQ;AAChC,QAAM,MAAM,MAAM,SAAS,KAAK;AAChC,SAAO,GAAG,IAAI,MAAM,GAAG,CAAC,CAAC,IAAI,IAAI,MAAM,GAAG,EAAE,CAAC,IAAI,IAAI,MAAM,IAAI,EAAE,CAAC,IAAI,IAAI,MAAM,IAAI,EAAE,CAAC,IAAI,IAAI,MAAM,EAAE,CAAC;AAC1G;AAEA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AOM,MAAM,WAAW;AAAA,YACjB,MAAM,UAAU;AAAA,YAChB,MAAM,wBAAwB;AAAA,YAC9B,MAAM,aAAa;AAAA,YACnB,MAAM,aAAa,IAAI;AAAA,YACvB,MAAM,cAAc,IAAI;AAAA,YACxB,MAAM,qBAAqB,IAAI;AAAA,YAC/B,MAAM,MAAM;AAAA;AAAA;AAAA,IAGpB;AACA,QAAI,CAAC,IAAK,OAAM,IAAI,oCAAoC;AACxD,UAAM,WAAW,MAAM,oCAAoC,IAAI,MAAM,UAAU;AAC/E,WAAO,uCAAuC,MAAM;AAAA,MAClD,SAAS,IAAI;AAAA,MACb,aAAa,MAAM;AAAA,MACnB;AAAA,IACF,CAAC;AAAA,EACH,SAAS,OAAO;AACd,QACE,iBAAiB,uCACjB,iBAAiB,6CACjB,iBAAiB,uCACjB,iBAAiB,sCACjB;AACA,YAAM;AAAA,IACR;AACA,gBAAY,KAAK;AAAA,EACnB;AACF;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  rawRows,
3
3
  withRlsContext
4
- } from "./chunk-ISI2TIUG.js";
4
+ } from "./chunk-Z7VYMNPZ.js";
5
5
 
6
6
  // src/editable-artifacts.ts
7
7
  import { createHash } from "crypto";
@@ -3532,4 +3532,4 @@ export {
3532
3532
  PostgresEditableArtifactStore,
3533
3533
  PostgresEditableArtifactLiveReadStore
3534
3534
  };
3535
- //# sourceMappingURL=chunk-F5FT7BEZ.js.map
3535
+ //# sourceMappingURL=chunk-HSOWSYOX.js.map