@noodleseed/one 0.82.0 → 0.84.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 (243) hide show
  1. package/dist/cli.d.ts.map +1 -1
  2. package/dist/cli.js +4 -1
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/catalog-data-platform-auth.d.ts.map +1 -1
  5. package/dist/commands/catalog-data-platform-auth.js +70 -2
  6. package/dist/commands/catalog-data-platform-auth.js.map +1 -1
  7. package/dist/commands/platform-account-reset-args.d.ts +40 -0
  8. package/dist/commands/platform-account-reset-args.d.ts.map +1 -0
  9. package/dist/commands/platform-account-reset-args.js +181 -0
  10. package/dist/commands/platform-account-reset-args.js.map +1 -0
  11. package/dist/commands/platform-account-reset-files.d.ts +9 -0
  12. package/dist/commands/platform-account-reset-files.d.ts.map +1 -0
  13. package/dist/commands/platform-account-reset-files.js +45 -0
  14. package/dist/commands/platform-account-reset-files.js.map +1 -0
  15. package/dist/commands/platform-account-reset-ops.d.ts +3 -0
  16. package/dist/commands/platform-account-reset-ops.d.ts.map +1 -0
  17. package/dist/commands/platform-account-reset-ops.js +162 -0
  18. package/dist/commands/platform-account-reset-ops.js.map +1 -0
  19. package/node_modules/@noodle-borg/agent-kit/dist/generated/example-files.js +1 -1
  20. package/node_modules/@noodle-borg/agent-kit/dist/generated/example-files.js.map +1 -1
  21. package/node_modules/@noodle-borg/agent-kit/dist/skill-embedded-assistant-ref.d.ts.map +1 -1
  22. package/node_modules/@noodle-borg/agent-kit/dist/skill-embedded-assistant-ref.js +39 -3
  23. package/node_modules/@noodle-borg/agent-kit/dist/skill-embedded-assistant-ref.js.map +1 -1
  24. package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
  25. package/node_modules/@noodle-borg/service/dist/assistant-interactive.d.ts +1 -0
  26. package/node_modules/@noodle-borg/service/dist/assistant-interactive.d.ts.map +1 -1
  27. package/node_modules/@noodle-borg/service/dist/assistant-interactive.js +1 -0
  28. package/node_modules/@noodle-borg/service/dist/assistant-interactive.js.map +1 -1
  29. package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation.d.ts +4 -4
  30. package/node_modules/@noodle-borg/service/dist/billing/read-contract.d.ts +6 -6
  31. package/node_modules/@noodle-borg/service/dist/index.d.ts +4 -1
  32. package/node_modules/@noodle-borg/service/dist/index.d.ts.map +1 -1
  33. package/node_modules/@noodle-borg/service/dist/index.js +2 -0
  34. package/node_modules/@noodle-borg/service/dist/index.js.map +1 -1
  35. package/node_modules/@noodle-borg/service/dist/main.js +5 -0
  36. package/node_modules/@noodle-borg/service/dist/main.js.map +1 -1
  37. package/node_modules/@noodle-borg/service/dist/oauth/developer-grant-flow.d.ts.map +1 -1
  38. package/node_modules/@noodle-borg/service/dist/oauth/developer-grant-flow.js +1 -0
  39. package/node_modules/@noodle-borg/service/dist/oauth/developer-grant-flow.js.map +1 -1
  40. package/node_modules/@noodle-borg/service/dist/oauth/provider.d.ts.map +1 -1
  41. package/node_modules/@noodle-borg/service/dist/oauth/provider.js +1 -0
  42. package/node_modules/@noodle-borg/service/dist/oauth/provider.js.map +1 -1
  43. package/node_modules/@noodle-borg/service/dist/oauth/store-postgres-schema.d.ts.map +1 -1
  44. package/node_modules/@noodle-borg/service/dist/oauth/store-postgres-schema.js +17 -0
  45. package/node_modules/@noodle-borg/service/dist/oauth/store-postgres-schema.js.map +1 -1
  46. package/node_modules/@noodle-borg/service/dist/oauth/store-postgres.d.ts +2 -2
  47. package/node_modules/@noodle-borg/service/dist/oauth/store-postgres.d.ts.map +1 -1
  48. package/node_modules/@noodle-borg/service/dist/oauth/store-postgres.js +25 -5
  49. package/node_modules/@noodle-borg/service/dist/oauth/store-postgres.js.map +1 -1
  50. package/node_modules/@noodle-borg/service/dist/oauth/store.d.ts +5 -3
  51. package/node_modules/@noodle-borg/service/dist/oauth/store.d.ts.map +1 -1
  52. package/node_modules/@noodle-borg/service/dist/oauth/store.js +5 -5
  53. package/node_modules/@noodle-borg/service/dist/oauth/store.js.map +1 -1
  54. package/node_modules/@noodle-borg/service/dist/oauth/upstream-callback-handler.d.ts.map +1 -1
  55. package/node_modules/@noodle-borg/service/dist/oauth/upstream-callback-handler.js +7 -2
  56. package/node_modules/@noodle-borg/service/dist/oauth/upstream-callback-handler.js.map +1 -1
  57. package/node_modules/@noodle-borg/service/dist/oauth/upstream-callback-support.d.ts +1 -1
  58. package/node_modules/@noodle-borg/service/dist/oauth/upstream-callback-support.d.ts.map +1 -1
  59. package/node_modules/@noodle-borg/service/dist/oauth/upstream-callback-support.js.map +1 -1
  60. package/node_modules/@noodle-borg/service/dist/oauth/upstream-consent.d.ts.map +1 -1
  61. package/node_modules/@noodle-borg/service/dist/oauth/upstream-consent.js +1 -1
  62. package/node_modules/@noodle-borg/service/dist/oauth/upstream-consent.js.map +1 -1
  63. package/node_modules/@noodle-borg/service/dist/oauth/upstream-federation.d.ts.map +1 -1
  64. package/node_modules/@noodle-borg/service/dist/oauth/upstream-federation.js +6 -1
  65. package/node_modules/@noodle-borg/service/dist/oauth/upstream-federation.js.map +1 -1
  66. package/node_modules/@noodle-borg/service/dist/options.d.ts +13 -0
  67. package/node_modules/@noodle-borg/service/dist/options.d.ts.map +1 -1
  68. package/node_modules/@noodle-borg/service/dist/platform-account-reset-config.d.ts +9 -0
  69. package/node_modules/@noodle-borg/service/dist/platform-account-reset-config.d.ts.map +1 -0
  70. package/node_modules/@noodle-borg/service/dist/platform-account-reset-config.js +24 -0
  71. package/node_modules/@noodle-borg/service/dist/platform-account-reset-config.js.map +1 -0
  72. package/node_modules/@noodle-borg/service/dist/platform-account-reset-dispatch-lock-postgres.d.ts +12 -0
  73. package/node_modules/@noodle-borg/service/dist/platform-account-reset-dispatch-lock-postgres.d.ts.map +1 -0
  74. package/node_modules/@noodle-borg/service/dist/platform-account-reset-dispatch-lock-postgres.js +110 -0
  75. package/node_modules/@noodle-borg/service/dist/platform-account-reset-dispatch-lock-postgres.js.map +1 -0
  76. package/node_modules/@noodle-borg/service/dist/platform-account-reset-fingerprint.d.ts +9 -0
  77. package/node_modules/@noodle-borg/service/dist/platform-account-reset-fingerprint.d.ts.map +1 -0
  78. package/node_modules/@noodle-borg/service/dist/platform-account-reset-fingerprint.js +46 -0
  79. package/node_modules/@noodle-borg/service/dist/platform-account-reset-fingerprint.js.map +1 -0
  80. package/node_modules/@noodle-borg/service/dist/platform-account-reset-operation-postgres.d.ts +77 -0
  81. package/node_modules/@noodle-borg/service/dist/platform-account-reset-operation-postgres.d.ts.map +1 -0
  82. package/node_modules/@noodle-borg/service/dist/platform-account-reset-operation-postgres.js +144 -0
  83. package/node_modules/@noodle-borg/service/dist/platform-account-reset-operation-postgres.js.map +1 -0
  84. package/node_modules/@noodle-borg/service/dist/platform-account-reset-operator.d.ts +29 -0
  85. package/node_modules/@noodle-borg/service/dist/platform-account-reset-operator.d.ts.map +1 -0
  86. package/node_modules/@noodle-borg/service/dist/platform-account-reset-operator.js +59 -0
  87. package/node_modules/@noodle-borg/service/dist/platform-account-reset-operator.js.map +1 -0
  88. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-helpers.d.ts +11 -0
  89. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-helpers.d.ts.map +1 -0
  90. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-helpers.js +22 -0
  91. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-helpers.js.map +1 -0
  92. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-postgres.d.ts +41 -0
  93. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-postgres.d.ts.map +1 -0
  94. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-postgres.js +314 -0
  95. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-postgres.js.map +1 -0
  96. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-resources-postgres.d.ts +14 -0
  97. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-resources-postgres.d.ts.map +1 -0
  98. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-resources-postgres.js +210 -0
  99. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-resources-postgres.js.map +1 -0
  100. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-rollback-postgres.d.ts +11 -0
  101. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-rollback-postgres.d.ts.map +1 -0
  102. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-rollback-postgres.js +71 -0
  103. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ownership-rollback-postgres.js.map +1 -0
  104. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ports.d.ts +12 -0
  105. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ports.d.ts.map +1 -0
  106. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ports.js +2 -0
  107. package/node_modules/@noodle-borg/service/dist/platform-account-reset-ports.js.map +1 -0
  108. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-evidence-postgres.d.ts +22 -0
  109. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-evidence-postgres.d.ts.map +1 -0
  110. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-evidence-postgres.js +177 -0
  111. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-evidence-postgres.js.map +1 -0
  112. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-local-postgres.d.ts +35 -0
  113. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-local-postgres.d.ts.map +1 -0
  114. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-local-postgres.js +184 -0
  115. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-local-postgres.js.map +1 -0
  116. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-persistence-postgres.d.ts +11 -0
  117. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-persistence-postgres.d.ts.map +1 -0
  118. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-persistence-postgres.js +120 -0
  119. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-persistence-postgres.js.map +1 -0
  120. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-postgres.d.ts +79 -0
  121. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-postgres.d.ts.map +1 -0
  122. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-postgres.js +286 -0
  123. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-postgres.js.map +1 -0
  124. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-result.d.ts +21 -0
  125. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-result.d.ts.map +1 -0
  126. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-result.js +81 -0
  127. package/node_modules/@noodle-borg/service/dist/platform-account-reset-preview-result.js.map +1 -0
  128. package/node_modules/@noodle-borg/service/dist/platform-account-reset-quarantine-postgres.d.ts +46 -0
  129. package/node_modules/@noodle-borg/service/dist/platform-account-reset-quarantine-postgres.d.ts.map +1 -0
  130. package/node_modules/@noodle-borg/service/dist/platform-account-reset-quarantine-postgres.js +283 -0
  131. package/node_modules/@noodle-borg/service/dist/platform-account-reset-quarantine-postgres.js.map +1 -0
  132. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-eligibility-postgres.d.ts +13 -0
  133. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-eligibility-postgres.d.ts.map +1 -0
  134. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-eligibility-postgres.js +81 -0
  135. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-eligibility-postgres.js.map +1 -0
  136. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-local-postgres.d.ts +30 -0
  137. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-local-postgres.d.ts.map +1 -0
  138. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-local-postgres.js +248 -0
  139. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-local-postgres.js.map +1 -0
  140. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-postgres.d.ts +29 -0
  141. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-postgres.d.ts.map +1 -0
  142. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-postgres.js +281 -0
  143. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-postgres.js.map +1 -0
  144. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-preview-postgres.d.ts +55 -0
  145. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-preview-postgres.d.ts.map +1 -0
  146. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-preview-postgres.js +262 -0
  147. package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-preview-postgres.js.map +1 -0
  148. package/node_modules/@noodle-borg/service/dist/platform-account-reset-schema-postgres.d.ts +7 -0
  149. package/node_modules/@noodle-borg/service/dist/platform-account-reset-schema-postgres.d.ts.map +1 -0
  150. package/node_modules/@noodle-borg/service/dist/platform-account-reset-schema-postgres.js +439 -0
  151. package/node_modules/@noodle-borg/service/dist/platform-account-reset-schema-postgres.js.map +1 -0
  152. package/node_modules/@noodle-borg/service/dist/platform-account-reset.d.ts +276 -0
  153. package/node_modules/@noodle-borg/service/dist/platform-account-reset.d.ts.map +1 -0
  154. package/node_modules/@noodle-borg/service/dist/platform-account-reset.js +141 -0
  155. package/node_modules/@noodle-borg/service/dist/platform-account-reset.js.map +1 -0
  156. package/node_modules/@noodle-borg/service/dist/platform-auth-configuration.d.ts +1 -1
  157. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-legacy-sources-postgres.d.ts.map +1 -1
  158. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-legacy-sources-postgres.js +5 -1
  159. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-legacy-sources-postgres.js.map +1 -1
  160. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-local-subjects-postgres.d.ts.map +1 -1
  161. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-local-subjects-postgres.js +10 -1
  162. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-local-subjects-postgres.js.map +1 -1
  163. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-source-fence-postgres.d.ts +5 -10
  164. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-source-fence-postgres.d.ts.map +1 -1
  165. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-source-fence-postgres.js +86 -47
  166. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-source-fence-postgres.js.map +1 -1
  167. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-source-fence-transaction-postgres.d.ts +17 -0
  168. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-source-fence-transaction-postgres.d.ts.map +1 -0
  169. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-source-fence-transaction-postgres.js +240 -0
  170. package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-source-fence-transaction-postgres.js.map +1 -0
  171. package/node_modules/@noodle-borg/service/dist/platform-auth-operator.d.ts +63 -63
  172. package/node_modules/@noodle-borg/service/dist/platform-auth-rollout-support.d.ts +1 -1
  173. package/node_modules/@noodle-borg/service/dist/platform-auth-runtime.d.ts +18 -1
  174. package/node_modules/@noodle-borg/service/dist/platform-auth-runtime.d.ts.map +1 -1
  175. package/node_modules/@noodle-borg/service/dist/platform-auth-runtime.js +97 -2
  176. package/node_modules/@noodle-borg/service/dist/platform-auth-runtime.js.map +1 -1
  177. package/node_modules/@noodle-borg/service/dist/platform-auth-service-bootstrap.d.ts +4 -1
  178. package/node_modules/@noodle-borg/service/dist/platform-auth-service-bootstrap.d.ts.map +1 -1
  179. package/node_modules/@noodle-borg/service/dist/platform-auth-service-bootstrap.js +4 -0
  180. package/node_modules/@noodle-borg/service/dist/platform-auth-service-bootstrap.js.map +1 -1
  181. package/node_modules/@noodle-borg/service/dist/platform-identity-postgres.d.ts +7 -2
  182. package/node_modules/@noodle-borg/service/dist/platform-identity-postgres.d.ts.map +1 -1
  183. package/node_modules/@noodle-borg/service/dist/platform-identity-postgres.js +24 -2
  184. package/node_modules/@noodle-borg/service/dist/platform-identity-postgres.js.map +1 -1
  185. package/node_modules/@noodle-borg/service/dist/platform-identity-schema-postgres.d.ts.map +1 -1
  186. package/node_modules/@noodle-borg/service/dist/platform-identity-schema-postgres.js +4 -0
  187. package/node_modules/@noodle-borg/service/dist/platform-identity-schema-postgres.js.map +1 -1
  188. package/node_modules/@noodle-borg/service/dist/platform-identity-sync-postgres.d.ts +7 -1
  189. package/node_modules/@noodle-borg/service/dist/platform-identity-sync-postgres.d.ts.map +1 -1
  190. package/node_modules/@noodle-borg/service/dist/platform-identity-sync-postgres.js +121 -8
  191. package/node_modules/@noodle-borg/service/dist/platform-identity-sync-postgres.js.map +1 -1
  192. package/node_modules/@noodle-borg/service/dist/platform-identity-sync-recovery-postgres.d.ts.map +1 -1
  193. package/node_modules/@noodle-borg/service/dist/platform-identity-sync-recovery-postgres.js +11 -1
  194. package/node_modules/@noodle-borg/service/dist/platform-identity-sync-recovery-postgres.js.map +1 -1
  195. package/node_modules/@noodle-borg/service/dist/platform-identity-sync.d.ts +5 -3
  196. package/node_modules/@noodle-borg/service/dist/platform-identity-sync.d.ts.map +1 -1
  197. package/node_modules/@noodle-borg/service/dist/platform-identity-sync.js +15 -1
  198. package/node_modules/@noodle-borg/service/dist/platform-identity-sync.js.map +1 -1
  199. package/node_modules/@noodle-borg/service/dist/platform-identity.d.ts +23 -2
  200. package/node_modules/@noodle-borg/service/dist/platform-identity.d.ts.map +1 -1
  201. package/node_modules/@noodle-borg/service/dist/platform-identity.js +21 -0
  202. package/node_modules/@noodle-borg/service/dist/platform-identity.js.map +1 -1
  203. package/node_modules/@noodle-borg/service/dist/registry-state.d.ts +8 -0
  204. package/node_modules/@noodle-borg/service/dist/registry-state.d.ts.map +1 -1
  205. package/node_modules/@noodle-borg/service/dist/registry-state.js +15 -2
  206. package/node_modules/@noodle-borg/service/dist/registry-state.js.map +1 -1
  207. package/node_modules/@noodle-borg/service/dist/registry.d.ts +2 -0
  208. package/node_modules/@noodle-borg/service/dist/registry.d.ts.map +1 -1
  209. package/node_modules/@noodle-borg/service/dist/registry.js +4 -1
  210. package/node_modules/@noodle-borg/service/dist/registry.js.map +1 -1
  211. package/node_modules/@noodle-borg/service/dist/routes/assistant-agent.d.ts +1 -1
  212. package/node_modules/@noodle-borg/service/dist/routes/assistant-agent.d.ts.map +1 -1
  213. package/node_modules/@noodle-borg/service/dist/routes/assistant-agent.js +1 -0
  214. package/node_modules/@noodle-borg/service/dist/routes/assistant-agent.js.map +1 -1
  215. package/node_modules/@noodle-borg/service/dist/routes/platform-account-reset-dispatch.d.ts +8 -0
  216. package/node_modules/@noodle-borg/service/dist/routes/platform-account-reset-dispatch.d.ts.map +1 -0
  217. package/node_modules/@noodle-borg/service/dist/routes/platform-account-reset-dispatch.js +36 -0
  218. package/node_modules/@noodle-borg/service/dist/routes/platform-account-reset-dispatch.js.map +1 -0
  219. package/node_modules/@noodle-borg/service/dist/routes/platform-account-reset.d.ts +22 -0
  220. package/node_modules/@noodle-borg/service/dist/routes/platform-account-reset.d.ts.map +1 -0
  221. package/node_modules/@noodle-borg/service/dist/routes/platform-account-reset.js +201 -0
  222. package/node_modules/@noodle-borg/service/dist/routes/platform-account-reset.js.map +1 -0
  223. package/node_modules/@noodle-borg/service/dist/routes/private-platform-auth-dispatch.d.ts +18 -0
  224. package/node_modules/@noodle-borg/service/dist/routes/private-platform-auth-dispatch.d.ts.map +1 -0
  225. package/node_modules/@noodle-borg/service/dist/routes/private-platform-auth-dispatch.js +36 -0
  226. package/node_modules/@noodle-borg/service/dist/routes/private-platform-auth-dispatch.js.map +1 -0
  227. package/node_modules/@noodle-borg/service/dist/serve-options.d.ts +2 -1
  228. package/node_modules/@noodle-borg/service/dist/serve-options.d.ts.map +1 -1
  229. package/node_modules/@noodle-borg/service/dist/serve.d.ts.map +1 -1
  230. package/node_modules/@noodle-borg/service/dist/serve.js +16 -1
  231. package/node_modules/@noodle-borg/service/dist/serve.js.map +1 -1
  232. package/node_modules/@noodle-borg/service/dist/service.d.ts.map +1 -1
  233. package/node_modules/@noodle-borg/service/dist/service.js +4 -5
  234. package/node_modules/@noodle-borg/service/dist/service.js.map +1 -1
  235. package/node_modules/@noodle-borg/service/dist/workos-directory.d.ts +22 -3
  236. package/node_modules/@noodle-borg/service/dist/workos-directory.d.ts.map +1 -1
  237. package/node_modules/@noodle-borg/service/dist/workos-directory.js +56 -5
  238. package/node_modules/@noodle-borg/service/dist/workos-directory.js.map +1 -1
  239. package/node_modules/@noodle-borg/wire-contracts/dist/assistant.d.ts +7 -0
  240. package/node_modules/@noodle-borg/wire-contracts/dist/assistant.d.ts.map +1 -1
  241. package/node_modules/@noodle-borg/wire-contracts/dist/assistant.js +5 -0
  242. package/node_modules/@noodle-borg/wire-contracts/dist/assistant.js.map +1 -1
  243. package/package.json +1 -1
@@ -0,0 +1,248 @@
1
+ import { PlatformAccountResetResultSchema, } from './platform-account-reset.js';
2
+ import { sha256Canonical } from './platform-account-reset-fingerprint.js';
3
+ import { PlatformAccountResetPreviewError } from './platform-account-reset-preview-result.js';
4
+ import { assertPlatformAccountResetRollbackEligibility } from './platform-account-reset-rollback-eligibility-postgres.js';
5
+ import { lockPlatformAuthInventorySourceFenceTargets, readPlatformAuthInventorySourceEpoch, } from './platform-auth-inventory-source-fence-postgres.js';
6
+ export async function inspectPlatformAccountResetRollbackLocalEvidence(connection, operationId, options) {
7
+ const operationResult = await connection.query(`SELECT lifecycle, release_sha, rollout_generation::text, workos_realm,
8
+ target_set_fingerprint, quarantine_safe_result, quarantined_at,
9
+ finalize_after, quarantine_idempotency_key_hash,
10
+ quarantine_request_fingerprint, quarantine_reason_fingerprint
11
+ FROM platform_account_reset_operations
12
+ WHERE operation_id = $1
13
+ AND lifecycle = 'quarantined'
14
+ AND finalize_after > clock_timestamp()
15
+ FOR SHARE`, [operationId]);
16
+ const operation = operationResult.rows[0];
17
+ if (operation === undefined)
18
+ throw new PlatformAccountResetPreviewError('operation_conflict');
19
+ if (operation.release_sha !== options.releaseSha)
20
+ throw new PlatformAccountResetPreviewError('release_mismatch');
21
+ if (operation.workos_realm !== options.workosRealm)
22
+ throw new PlatformAccountResetPreviewError('operation_conflict');
23
+ const quarantinedAt = validDate(operation.quarantined_at);
24
+ const finalizeAfter = validDate(operation.finalize_after);
25
+ const targetsResult = await connection.query(`SELECT principal_id, lifecycle, source_snapshot_fingerprint
26
+ FROM platform_account_reset_targets
27
+ WHERE operation_id = $1 ORDER BY principal_id FOR SHARE`, [operationId]);
28
+ if (targetsResult.rows.length !== 3 ||
29
+ targetsResult.rows.some((row) => row.lifecycle !== 'quarantined'))
30
+ throw new PlatformAccountResetPreviewError('target_count_invalid');
31
+ const targets = targetsResult.rows.map((row) => row.principal_id);
32
+ await lockPlatformAuthInventorySourceFenceTargets(connection, targets);
33
+ const targetFingerprints = targets.map((target) => sha256Canonical(target));
34
+ const sourceEpoch = Number(await readPlatformAuthInventorySourceEpoch(connection));
35
+ const rollout = await connection.query(`SELECT generation::text, lifecycle, workos_percentage
36
+ FROM platform_auth_rollout_state WHERE singleton = true FOR SHARE`);
37
+ const rolloutState = rollout.rows[0];
38
+ if (rolloutState === undefined ||
39
+ Number(rolloutState.generation) !== Number(operation.rollout_generation))
40
+ throw new PlatformAccountResetPreviewError('generation_mismatch');
41
+ if (rolloutState.lifecycle !== 'google' || rolloutState.workos_percentage !== 0)
42
+ throw new PlatformAccountResetPreviewError('operation_conflict');
43
+ const reservations = await connection.query(`SELECT principal_id, normalized_email, realm, expires_at, created_at, released_at
44
+ FROM platform_account_reset_email_reservations
45
+ WHERE operation_id = $1 ORDER BY principal_id FOR SHARE`, [operationId]);
46
+ if (reservations.rows.length !== 3 ||
47
+ reservations.rows.some((row) => row.realm !== options.workosRealm ||
48
+ row.released_at !== null ||
49
+ validDate(row.created_at).getTime() !== quarantinedAt.getTime() ||
50
+ validDate(row.expires_at).getTime() !== finalizeAfter.getTime()))
51
+ throw new PlatformAccountResetPreviewError('operation_conflict');
52
+ const contacts = new Map(reservations.rows.map((row) => [row.principal_id, row.normalized_email]));
53
+ if (contacts.size !== 3 || targets.some((target) => !contacts.has(target)))
54
+ throw new PlatformAccountResetPreviewError('operation_conflict');
55
+ const principals = await connection.query(`SELECT principal_id, status, suspended_at, billing_identity_issuer, billing_subject
56
+ FROM platform_principals
57
+ WHERE principal_id = ANY($1::text[]) ORDER BY principal_id FOR SHARE`, [targets]);
58
+ if (principals.rows.length !== 3 ||
59
+ principals.rows.some((row) => row.status !== 'suspended' ||
60
+ validDate(row.suspended_at).getTime() !== quarantinedAt.getTime() ||
61
+ row.billing_identity_issuer !== 'https://accounts.google.com' ||
62
+ row.billing_subject !== row.principal_id))
63
+ throw new PlatformAccountResetPreviewError('operation_conflict');
64
+ const links = await connection.query(`SELECT principal_id, provider, realm, external_id, disabled_at
65
+ FROM platform_identity_links
66
+ WHERE principal_id = ANY($1::text[])
67
+ ORDER BY principal_id, provider, realm, external_id FOR SHARE`, [targets]);
68
+ for (const target of targets) {
69
+ const google = links.rows.filter((row) => row.principal_id === target &&
70
+ row.provider === 'google' &&
71
+ row.realm === options.googleRealm &&
72
+ row.disabled_at === null &&
73
+ row.external_id === target);
74
+ if (google.length !== 1)
75
+ throw new PlatformAccountResetPreviewError('principal_not_legacy_google');
76
+ }
77
+ await assertNoActiveWorkosLineage(connection, targets, targetFingerprints);
78
+ await assertCredentialsRevoked(connection, targets);
79
+ const ledgerResult = await connection.query(`SELECT provider, resource_kind, provider_locator, locator_fingerprint, state,
80
+ lease_token_hash, lease_expires_at, attempt_count, retry_at, outcome_code,
81
+ quarantine_archive_at
82
+ FROM platform_account_reset_cleanup_ledger
83
+ WHERE operation_id = $1
84
+ ORDER BY provider, resource_kind, locator_fingerprint FOR SHARE`, [operationId]);
85
+ const resources = [];
86
+ const expectedDeployments = [];
87
+ for (const row of ledgerResult.rows) {
88
+ const locator = parseLocator(row);
89
+ resources.push({
90
+ provider: row.provider,
91
+ resourceKind: row.resource_kind,
92
+ locator,
93
+ locatorFingerprint: row.locator_fingerprint,
94
+ });
95
+ if (row.provider === 'postgres' &&
96
+ row.resource_kind === 'deployment' &&
97
+ locator.archived === false) {
98
+ if (typeof locator.deploymentId !== 'string' ||
99
+ validDate(row.quarantine_archive_at).getTime() !== quarantinedAt.getTime())
100
+ throw new PlatformAccountResetPreviewError('operation_conflict');
101
+ expectedDeployments.push(locator.deploymentId);
102
+ }
103
+ }
104
+ const deployments = await connection.query(`SELECT deployment_id, archived_at FROM deploy_records
105
+ WHERE deployment_id = ANY($1::text[]) ORDER BY deployment_id FOR SHARE`, [expectedDeployments]);
106
+ if (deployments.rows.length !== expectedDeployments.length ||
107
+ deployments.rows.some((row) => validDate(row.archived_at).getTime() !== quarantinedAt.getTime()))
108
+ throw new PlatformAccountResetPreviewError('operation_conflict');
109
+ const baseResult = PlatformAccountResetResultSchema.safeParse(operation.quarantine_safe_result);
110
+ if (!baseResult.success)
111
+ throw new PlatformAccountResetPreviewError('operation_conflict');
112
+ const eligibilityFingerprint = await assertPlatformAccountResetRollbackEligibility(connection, {
113
+ operationId,
114
+ targets,
115
+ frozenContacts: contacts,
116
+ frozenCleanupResources: resources,
117
+ sourceAvailability: options.sourceAvailability,
118
+ baseResult: baseResult.data,
119
+ });
120
+ const localEvidence = {
121
+ schemaVersion: 1,
122
+ label: 'platform_account_reset_rollback_local_evidence',
123
+ operation: {
124
+ releaseSha: operation.release_sha,
125
+ rolloutGeneration: Number(operation.rollout_generation),
126
+ targetSetFingerprint: operation.target_set_fingerprint,
127
+ quarantinedAt: quarantinedAt.toISOString(),
128
+ finalizeAfter: finalizeAfter.toISOString(),
129
+ quarantineIdempotencyKeyHash: operation.quarantine_idempotency_key_hash,
130
+ quarantineRequestFingerprint: operation.quarantine_request_fingerprint,
131
+ quarantineReasonFingerprint: operation.quarantine_reason_fingerprint,
132
+ },
133
+ sourceEpoch,
134
+ eligibilityFingerprint,
135
+ targetRows: targetsResult.rows,
136
+ reservations: reservations.rows.map((row) => ({
137
+ ...row,
138
+ expires_at: validDate(row.expires_at).toISOString(),
139
+ created_at: validDate(row.created_at).toISOString(),
140
+ released_at: optionalDate(row.released_at),
141
+ })),
142
+ principals: principals.rows.map((row) => ({
143
+ ...row,
144
+ suspended_at: optionalDate(row.suspended_at),
145
+ })),
146
+ links: links.rows.map((row) => ({
147
+ ...row,
148
+ disabled_at: optionalDate(row.disabled_at),
149
+ })),
150
+ cleanupLedger: ledgerResult.rows.map((row) => ({
151
+ ...row,
152
+ lease_expires_at: optionalDate(row.lease_expires_at),
153
+ retry_at: optionalDate(row.retry_at),
154
+ quarantine_archive_at: optionalDate(row.quarantine_archive_at),
155
+ })),
156
+ deployments: deployments.rows.map((row) => ({
157
+ ...row,
158
+ archived_at: optionalDate(row.archived_at),
159
+ })),
160
+ };
161
+ return {
162
+ operationId,
163
+ sourceEpoch,
164
+ rolloutGeneration: Number(operation.rollout_generation),
165
+ releaseSha: operation.release_sha,
166
+ targetSetFingerprint: operation.target_set_fingerprint,
167
+ targets,
168
+ contacts,
169
+ workosResources: resources.filter((resource) => resource.provider === 'workos'),
170
+ baseResult: baseResult.data,
171
+ evidenceFingerprint: sha256Canonical(localEvidence),
172
+ };
173
+ }
174
+ async function assertNoActiveWorkosLineage(connection, targets, targetFingerprints) {
175
+ const evidence = await connection.query(`SELECT 1
176
+ FROM platform_identity_links
177
+ WHERE principal_id = ANY($1::text[]) AND provider = 'workos' AND disabled_at IS NULL
178
+ UNION ALL
179
+ SELECT 1 FROM workos_import_ledger
180
+ WHERE principal_id = ANY($1::text[])
181
+ UNION ALL
182
+ SELECT 1 FROM workos_import_attempt_evidence
183
+ WHERE principal_id = ANY($1::text[])
184
+ OR principal_fingerprint = ANY($2::text[])
185
+ UNION ALL
186
+ SELECT 1
187
+ FROM platform_auth_inventory_candidates candidate
188
+ JOIN identity_migration_runs inventory
189
+ ON inventory.id = candidate.migration_run_id
190
+ JOIN identity_migration_runs import_run
191
+ ON import_run.inventory_run_id = inventory.id
192
+ AND import_run.kind = 'import'
193
+ WHERE (candidate.principal_id = ANY($1::text[])
194
+ OR candidate.source_subject = ANY($1::text[]))
195
+ AND import_run.state IN ('running', 'completed')
196
+ LIMIT 1`, [targets, targetFingerprints]);
197
+ if (evidence.rows[0] !== undefined)
198
+ throw new PlatformAccountResetPreviewError('workos_import_present');
199
+ }
200
+ async function assertCredentialsRevoked(connection, targets) {
201
+ const active = await connection.query(`SELECT (
202
+ (SELECT count(*) FROM oauth_refresh_tokens
203
+ WHERE owner_subject = ANY($1::text[]) AND identity_kind IS DISTINCT FROM 'customer')
204
+ + (SELECT count(*) FROM oauth_authorization_codes
205
+ WHERE owner_subject = ANY($1::text[]) AND identity_kind IS DISTINCT FROM 'customer')
206
+ + (SELECT count(*) FROM oauth_consent_grant_provenance
207
+ WHERE owner_subject = ANY($1::text[]) AND identity_kind = 'platform')
208
+ + (SELECT count(*) FROM oauth_consent_grants
209
+ WHERE owner_subject = ANY($1::text[]) AND identity_kind = 'platform')
210
+ + (SELECT count(*) FROM oauth_device_authorizations
211
+ WHERE owner_subject = ANY($1::text[]) AND identity_kind IS DISTINCT FROM 'customer')
212
+ + (SELECT count(*) FROM developer_access_grants
213
+ WHERE subject = ANY($1::text[]) AND revoked_at IS NULL)
214
+ )::int AS count`, [targets]);
215
+ if (active.rows[0]?.count !== 0)
216
+ throw new PlatformAccountResetPreviewError('operation_conflict');
217
+ }
218
+ function parseLocator(row) {
219
+ let locator;
220
+ try {
221
+ locator = JSON.parse(row.provider_locator);
222
+ }
223
+ catch {
224
+ throw new PlatformAccountResetPreviewError('operation_conflict');
225
+ }
226
+ if (!isRecord(locator) ||
227
+ !['postgres', 'object_storage', 'github', 'stripe', 'workos'].includes(row.provider) ||
228
+ sha256Canonical({
229
+ schemaVersion: 1,
230
+ label: `platform_account_reset_locator:${row.provider}:${row.resource_kind}`,
231
+ locator,
232
+ }) !== row.locator_fingerprint)
233
+ throw new PlatformAccountResetPreviewError('operation_conflict');
234
+ return locator;
235
+ }
236
+ function validDate(value) {
237
+ const date = value === null ? new Date(Number.NaN) : new Date(value);
238
+ if (!Number.isFinite(date.getTime()))
239
+ throw new PlatformAccountResetPreviewError('operation_conflict');
240
+ return date;
241
+ }
242
+ function optionalDate(value) {
243
+ return value === null ? null : validDate(value).toISOString();
244
+ }
245
+ function isRecord(value) {
246
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
247
+ }
248
+ //# sourceMappingURL=platform-account-reset-rollback-local-postgres.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-account-reset-rollback-local-postgres.js","sourceRoot":"","sources":["../src/platform-account-reset-rollback-local-postgres.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gCAAgC,GACjC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAAE,gCAAgC,EAAE,MAAM,4CAA4C,CAAC;AAC9F,OAAO,EAAE,6CAA6C,EAAE,MAAM,2DAA2D,CAAC;AAC1H,OAAO,EACL,2CAA2C,EAC3C,oCAAoC,GACrC,MAAM,oDAAoD,CAAC;AA2D5D,MAAM,CAAC,KAAK,UAAU,gDAAgD,CACpE,UAAqC,EACrC,WAAmB,EACnB,OAA6B;IAE7B,MAAM,eAAe,GAAG,MAAM,UAAU,CAAC,KAAK,CAC5C;;;;;;;;gBAQY,EACZ,CAAC,WAAW,CAAC,CACd,CAAC;IACF,MAAM,SAAS,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC1C,IAAI,SAAS,KAAK,SAAS;QAAE,MAAM,IAAI,gCAAgC,CAAC,oBAAoB,CAAC,CAAC;IAC9F,IAAI,SAAS,CAAC,WAAW,KAAK,OAAO,CAAC,UAAU;QAC9C,MAAM,IAAI,gCAAgC,CAAC,kBAAkB,CAAC,CAAC;I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CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IACrE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAClC,MAAM,IAAI,gCAAgC,CAAC,oBAAoB,CAAC,CAAC;IACnE,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,YAAY,CAAC,KAA2B;IAC/C,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AAChE,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { type PlatformAccountResetExecuteRequest, type PlatformAccountResetResult } from './platform-account-reset.js';
2
+ import { type PlatformAccountResetMutationOutcome, type PlatformAccountResetPool } from './platform-account-reset-operation-postgres.js';
3
+ import type { PlatformAccountResetPreparedRollbackValidation, PlatformAccountResetRollbackPreviewEvidence } from './platform-account-reset-rollback-preview-postgres.js';
4
+ import type { PlatformAuthInventorySourceManifest } from './platform-auth-inventory-sources.js';
5
+ import type { PlatformIdentityQueryable } from './platform-identity-postgres.js';
6
+ export type PlatformAccountResetRollbackBoundary = 'canonical_validated' | 'operation_transitioned' | 'reservations_removed' | 'principals_reactivated' | 'deployments_restored' | 'cleanup_cancelled' | 'targets_transitioned' | 'event_appended';
7
+ interface RollbackOptions {
8
+ readonly preview: {
9
+ prepareUsable(input: PlatformAccountResetRollbackPreviewEvidence, deadline?: number): Promise<PlatformAccountResetPreparedRollbackValidation>;
10
+ assertPrepared(connection: PlatformIdentityQueryable, input: PlatformAccountResetRollbackPreviewEvidence, prepared: PlatformAccountResetPreparedRollbackValidation): Promise<PlatformAccountResetResult>;
11
+ };
12
+ readonly releaseSha: string;
13
+ readonly workosRealm: string;
14
+ readonly approvedTargetSetFingerprint: string;
15
+ readonly actorFingerprint: string;
16
+ readonly googleRealm?: string;
17
+ readonly sourceAvailability: PlatformAuthInventorySourceManifest;
18
+ readonly now?: () => Date;
19
+ readonly localCaptureTimeoutMs?: number;
20
+ readonly fault?: (boundary: PlatformAccountResetRollbackBoundary) => void | Promise<void>;
21
+ }
22
+ export declare class PostgresPlatformAccountResetRollbackStore {
23
+ #private;
24
+ constructor(pool: PlatformAccountResetPool, options: RollbackOptions);
25
+ rollback(rawRequest: PlatformAccountResetExecuteRequest): Promise<PlatformAccountResetResult>;
26
+ apply(rawRequest: PlatformAccountResetExecuteRequest): Promise<PlatformAccountResetMutationOutcome>;
27
+ }
28
+ export {};
29
+ //# sourceMappingURL=platform-account-reset-rollback-postgres.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-account-reset-rollback-postgres.d.ts","sourceRoot":"","sources":["../src/platform-account-reset-rollback-postgres.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kCAAkC,EAEvC,KAAK,0BAA0B,EAChC,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAML,KAAK,mCAAmC,EACxC,KAAK,wBAAwB,EAE9B,MAAM,gDAAgD,CAAC;AAExD,OAAO,KAAK,EACV,8CAA8C,EAC9C,2CAA2C,EAC5C,MAAM,uDAAuD,CAAC;AAQ/D,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,sCAAsC,CAAC;AAChG,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAEjF,MAAM,MAAM,oCAAoC,GAC5C,qBAAqB,GACrB,wBAAwB,GACxB,sBAAsB,GACtB,wBAAwB,GACxB,sBAAsB,GACtB,mBAAmB,GACnB,sBAAsB,GACtB,gBAAgB,CAAC;AAErB,UAAU,eAAe;IACvB,QAAQ,CAAC,OAAO,EAAE;QAChB,aAAa,CACX,KAAK,EAAE,2CAA2C,EAClD,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,8CAA8C,CAAC,CAAC;QAC3D,cAAc,CACZ,UAAU,EAAE,yBAAyB,EACrC,KAAK,EAAE,2CAA2C,EAClD,QAAQ,EAAE,8CAA8C,GACvD,OAAO,CAAC,0BAA0B,CAAC,CAAC;KACxC,CAAC;IACF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,4BAA4B,EAAE,MAAM,CAAC;IAC9C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,kBAAkB,EAAE,mCAAmC,CAAC;IACjE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IACxC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,oCAAoC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3F;AAKD,qBAAa,yCAAyC;;gBAIxC,IAAI,EAAE,wBAAwB,EAAE,OAAO,EAAE,eAAe;IAQ9D,QAAQ,CACZ,UAAU,EAAE,kCAAkC,GAC7C,OAAO,CAAC,0BAA0B,CAAC;IAIhC,KAAK,CACT,UAAU,EAAE,kCAAkC,GAC7C,OAAO,CAAC,mCAAmC,CAAC;CAiXhD"}
@@ -0,0 +1,281 @@
1
+ import { PlatformAccountResetExecuteRequestSchema, } from './platform-account-reset.js';
2
+ import { remainingPlatformAccountResetDispatchMilliseconds, runPlatformAccountResetWithDispatchLock, } from './platform-account-reset-dispatch-lock-postgres.js';
3
+ import { sha256Canonical } from './platform-account-reset-fingerprint.js';
4
+ import { assertPlatformAccountResetActionReplay, assertPlatformAccountResetApprovedTargetSet, loadPlatformAccountResetFrozenResources, loadPlatformAccountResetTargets, lockPlatformAccountResetOperation, platformAccountResetActionEvidence, } from './platform-account-reset-operation-postgres.js';
5
+ import { PlatformAccountResetPreviewError } from './platform-account-reset-preview-result.js';
6
+ import { PostgresPlatformAuthLegacyInventorySources } from './platform-auth-inventory-legacy-sources-postgres.js';
7
+ import { assertPlatformAuthInventorySourceFence, lockPlatformAuthInventorySourceFenceTargets, PLATFORM_ACCOUNT_RESET_EXECUTION_TABLES, runPlatformAuthInventorySourceFenceTransaction, } from './platform-auth-inventory-source-fence-postgres.js';
8
+ const DEFAULT_LOCAL_CAPTURE_TIMEOUT_MS = 5_000;
9
+ const MAX_LOCAL_CAPTURE_TIMEOUT_MS = 60_000;
10
+ export class PostgresPlatformAccountResetRollbackStore {
11
+ #pool;
12
+ #options;
13
+ constructor(pool, options) {
14
+ this.#pool = pool;
15
+ this.#options = {
16
+ ...options,
17
+ googleRealm: options.googleRealm ?? 'accounts.google.com',
18
+ };
19
+ }
20
+ async rollback(rawRequest) {
21
+ return (await this.apply(rawRequest)).result;
22
+ }
23
+ async apply(rawRequest) {
24
+ const request = PlatformAccountResetExecuteRequestSchema.parse(rawRequest);
25
+ if (request.action !== 'rollback')
26
+ throw new PlatformAccountResetPreviewError('operation_conflict');
27
+ return runPlatformAccountResetWithDispatchLock(this.#pool, {
28
+ operationId: request.operationId,
29
+ timeoutMs: this.#localCaptureTimeout(),
30
+ task: (context) => this.#applyLocked(request, context.replayLifecycle, context.deadline),
31
+ });
32
+ }
33
+ async #applyLocked(request, replayLifecycle, deadline) {
34
+ const evidence = platformAccountResetActionEvidence(request, this.#options.actorFingerprint);
35
+ const previewEvidence = {
36
+ operationId: request.operationId,
37
+ releaseSha: request.releaseSha,
38
+ expectedGeneration: request.expectedGeneration,
39
+ previewChecksum: request.previewChecksum,
40
+ };
41
+ const prepared = replayLifecycle === 'rolled_back'
42
+ ? undefined
43
+ : await this.#options.preview.prepareUsable(previewEvidence, deadline);
44
+ return runPlatformAuthInventorySourceFenceTransaction(this.#pool, async (connection) => {
45
+ await this.#assertSourceFence(connection);
46
+ const operation = await lockPlatformAccountResetOperation(connection, request.operationId);
47
+ assertPlatformAccountResetApprovedTargetSet(operation, this.#options.approvedTargetSetFingerprint);
48
+ const resources = await loadPlatformAccountResetFrozenResources(connection, request.operationId);
49
+ if (operation.lifecycle === 'rolled_back') {
50
+ const result = assertPlatformAccountResetActionReplay(evidence, {
51
+ idempotencyKeyHash: operation.rollback_idempotency_key_hash,
52
+ requestFingerprint: operation.rollback_request_fingerprint,
53
+ reasonFingerprint: operation.rollback_reason_fingerprint,
54
+ actorFingerprint: operation.rollback_actor_fingerprint,
55
+ safeResult: operation.rollback_safe_result,
56
+ });
57
+ return {
58
+ result,
59
+ registry: this.#registryPlan(resources.apps, operation.quarantined_at),
60
+ };
61
+ }
62
+ if (operation.lifecycle !== 'quarantined' || prepared === undefined)
63
+ throw new PlatformAccountResetPreviewError('operation_conflict');
64
+ const validated = await this.#options.preview.assertPrepared(connection, previewEvidence, prepared);
65
+ if (request.releaseSha !== this.#options.releaseSha ||
66
+ operation.release_sha !== request.releaseSha ||
67
+ operation.workos_realm !== this.#options.workosRealm ||
68
+ Number(operation.rollout_generation) !== request.expectedGeneration ||
69
+ validated.previewChecksum !== request.previewChecksum)
70
+ throw new PlatformAccountResetPreviewError('operation_conflict');
71
+ const targets = await loadPlatformAccountResetTargets(connection, request.operationId, 'quarantined');
72
+ await lockPlatformAuthInventorySourceFenceTargets(connection, targets);
73
+ await this.#assertRollbackCoordination(connection, targets, request, operation.quarantined_at);
74
+ await this.#assertFrozenQuarantineState(connection, request.operationId, targets);
75
+ const result = this.#rollbackResult(validated);
76
+ await this.#fault('canonical_validated');
77
+ const operationTransitioned = await connection.query(`WITH authority AS MATERIALIZED (
78
+ SELECT clock_timestamp() AS rolled_back_at
79
+ )
80
+ UPDATE platform_account_reset_operations operation
81
+ SET lifecycle = 'rolled_back',
82
+ rollback_idempotency_key_hash = $2,
83
+ rollback_request_fingerprint = $3,
84
+ rollback_reason_fingerprint = $4,
85
+ rollback_actor_fingerprint = $5,
86
+ rollback_safe_result = $6::jsonb,
87
+ updated_at = authority.rolled_back_at
88
+ FROM authority
89
+ WHERE operation.operation_id = $1 AND operation.lifecycle = 'quarantined'
90
+ AND operation.finalize_after > authority.rolled_back_at
91
+ AND EXISTS (
92
+ SELECT 1 FROM platform_account_reset_rollback_previews preview
93
+ WHERE preview.operation_id = $1
94
+ AND preview.preview_checksum = $7
95
+ AND preview.preview_expires_at > authority.rolled_back_at
96
+ )
97
+ RETURNING operation.updated_at::text AS rolled_back_at`, [
98
+ request.operationId,
99
+ evidence.idempotencyKeyHash,
100
+ evidence.requestFingerprint,
101
+ evidence.reasonFingerprint,
102
+ evidence.actorFingerprint,
103
+ JSON.stringify(result),
104
+ request.previewChecksum,
105
+ ]);
106
+ if (operationTransitioned.rows.length !== 1)
107
+ throw new PlatformAccountResetPreviewError('operation_conflict');
108
+ const rolledBackAt = operationTransitioned.rows[0]?.rolled_back_at;
109
+ if (rolledBackAt === undefined)
110
+ throw new PlatformAccountResetPreviewError('operation_conflict');
111
+ await this.#fault('operation_transitioned');
112
+ const removed = await connection.query(`DELETE FROM platform_account_reset_email_reservations
113
+ WHERE operation_id = $1 AND realm = $2
114
+ RETURNING principal_id`, [request.operationId, this.#options.workosRealm]);
115
+ if (removed.rows.length !== 3)
116
+ throw new PlatformAccountResetPreviewError('operation_conflict');
117
+ await this.#fault('reservations_removed');
118
+ const reactivated = await connection.query(`UPDATE platform_principals
119
+ SET status = 'active', suspended_at = NULL
120
+ WHERE principal_id = ANY($1::text[]) AND status = 'suspended'
121
+ AND suspended_at = (
122
+ SELECT quarantined_at FROM platform_account_reset_operations
123
+ WHERE operation_id = $2
124
+ )
125
+ RETURNING principal_id`, [targets, request.operationId]);
126
+ if (reactivated.rows.length !== 3)
127
+ throw new PlatformAccountResetPreviewError('operation_conflict');
128
+ await this.#fault('principals_reactivated');
129
+ const restored = await connection.query(`UPDATE deploy_records deployment
130
+ SET archived_at = NULL
131
+ FROM platform_account_reset_cleanup_ledger ledger
132
+ WHERE ledger.operation_id = $1 AND ledger.provider = 'postgres'
133
+ AND ledger.resource_kind = 'deployment'
134
+ AND ledger.quarantine_archive_at IS NOT NULL
135
+ AND deployment.deployment_id =
136
+ ledger.provider_locator::jsonb->>'deploymentId'
137
+ AND deployment.archived_at = ledger.quarantine_archive_at
138
+ RETURNING deployment.deployment_id`, [request.operationId]);
139
+ if (restored.rows.length !== resources.deploymentIds.length)
140
+ throw new PlatformAccountResetPreviewError('operation_conflict');
141
+ await this.#fault('deployments_restored');
142
+ await connection.query(`UPDATE platform_account_reset_cleanup_ledger
143
+ SET state = 'blocked', lease_token_hash = NULL, lease_expires_at = NULL,
144
+ retry_at = NULL, outcome_code = 'rolled_back', updated_at = $2
145
+ WHERE operation_id = $1`, [request.operationId, rolledBackAt]);
146
+ await this.#fault('cleanup_cancelled');
147
+ const targetsTransitioned = await connection.query(`UPDATE platform_account_reset_targets
148
+ SET lifecycle = 'rolled_back', updated_at = $2
149
+ WHERE operation_id = $1 AND lifecycle = 'quarantined'
150
+ RETURNING principal_id`, [request.operationId, rolledBackAt]);
151
+ if (targetsTransitioned.rows.length !== 3)
152
+ throw new PlatformAccountResetPreviewError('operation_conflict');
153
+ await this.#fault('targets_transitioned');
154
+ await connection.query(`INSERT INTO platform_account_reset_events
155
+ (operation_id, event_type, target_set_fingerprint, event_fingerprint,
156
+ target_count, resource_count, blocker_count, created_at)
157
+ VALUES ($1, 'rolled_back', $2, $3, 3, $4, 0, $5)`, [
158
+ request.operationId,
159
+ result.targetSetFingerprint,
160
+ sha256Canonical({
161
+ schemaVersion: 1,
162
+ label: 'platform_account_reset_event:rolled_back',
163
+ operationId: request.operationId,
164
+ requestFingerprint: evidence.requestFingerprint,
165
+ result,
166
+ }),
167
+ resources.resourceCount,
168
+ rolledBackAt,
169
+ ]);
170
+ await this.#fault('event_appended');
171
+ return {
172
+ result,
173
+ registry: this.#registryPlan(resources.apps, operation.quarantined_at),
174
+ };
175
+ }, this.#transactionOptions(deadline));
176
+ }
177
+ async #assertRollbackCoordination(connection, targets, request, quarantinedAtValue) {
178
+ const targetFingerprints = targets.map((target) => sha256Canonical(target));
179
+ const rollout = await connection.query(`SELECT generation::text, lifecycle, workos_percentage
180
+ FROM platform_auth_rollout_state WHERE singleton = true FOR SHARE`);
181
+ const state = rollout.rows[0];
182
+ if (state === undefined || Number(state.generation) !== request.expectedGeneration)
183
+ throw new PlatformAccountResetPreviewError('generation_mismatch');
184
+ if (state.lifecycle !== 'google' || state.workos_percentage !== 0)
185
+ throw new PlatformAccountResetPreviewError('operation_conflict');
186
+ const quarantinedAt = quarantinedAtValue === null ? new Date(Number.NaN) : new Date(quarantinedAtValue);
187
+ if (!Number.isFinite(quarantinedAt.getTime()))
188
+ throw new PlatformAccountResetPreviewError('operation_conflict');
189
+ const lineage = await connection.query(`SELECT 1
190
+ FROM platform_auth_inventory_candidates candidate
191
+ JOIN identity_migration_runs inventory
192
+ ON inventory.id = candidate.migration_run_id
193
+ JOIN identity_migration_runs import_run
194
+ ON import_run.inventory_run_id = inventory.id
195
+ AND import_run.kind = 'import'
196
+ WHERE (candidate.principal_id = ANY($1::text[])
197
+ OR candidate.source_subject = ANY($1::text[]))
198
+ AND import_run.state IN ('running', 'completed')
199
+ AND COALESCE(import_run.started_at, import_run.created_at) > $2
200
+ LIMIT 1`, [targets, quarantinedAt]);
201
+ const imported = await connection.query(`SELECT 1 FROM workos_import_ledger
202
+ WHERE principal_id = ANY($1::text[]) AND created_at > $2
203
+ AND state IN ('pending', 'reconcile_required', 'linked')
204
+ LIMIT 1`, [targets, quarantinedAt]);
205
+ const attempted = await connection.query(`SELECT 1 FROM workos_import_attempt_evidence
206
+ WHERE (principal_id = ANY($1::text[])
207
+ OR principal_fingerprint = ANY($3::text[]))
208
+ AND created_at > $2
209
+ AND outcome_code IN ('pending', 'reconcile_required', 'linked')
210
+ LIMIT 1`, [targets, quarantinedAt, targetFingerprints]);
211
+ const linked = await connection.query(`SELECT 1 FROM platform_identity_links
212
+ WHERE principal_id = ANY($1::text[]) AND provider = 'workos'
213
+ AND created_at > $2 AND disabled_at IS NULL
214
+ LIMIT 1`, [targets, quarantinedAt]);
215
+ if (lineage.rows[0] !== undefined ||
216
+ imported.rows[0] !== undefined ||
217
+ attempted.rows[0] !== undefined ||
218
+ linked.rows[0] !== undefined)
219
+ throw new PlatformAccountResetPreviewError('workos_import_present');
220
+ }
221
+ async #assertFrozenQuarantineState(connection, operationId, targets) {
222
+ const state = await connection.query(`SELECT
223
+ (SELECT count(*)::int
224
+ FROM platform_account_reset_email_reservations
225
+ WHERE operation_id = $1 AND realm = $2 AND released_at IS NULL) AS reservations,
226
+ (SELECT count(*)::int FROM platform_principals
227
+ WHERE principal_id = ANY($3::text[]) AND status = 'suspended'
228
+ AND suspended_at = (
229
+ SELECT quarantined_at FROM platform_account_reset_operations
230
+ WHERE operation_id = $1
231
+ )) AS suspended`, [operationId, this.#options.workosRealm, targets]);
232
+ if (state.rows[0]?.reservations !== 3 || state.rows[0]?.suspended !== 3)
233
+ throw new PlatformAccountResetPreviewError('operation_conflict');
234
+ }
235
+ #rollbackResult(quarantined) {
236
+ return {
237
+ ...quarantined,
238
+ lifecycle: 'rolled_back',
239
+ counts: {
240
+ ...quarantined.counts,
241
+ suspendedPrincipalCount: 0,
242
+ cleanupPendingCount: 0,
243
+ },
244
+ };
245
+ }
246
+ #registryPlan(apps, quarantinedAtValue) {
247
+ const quarantinedAt = quarantinedAtValue === null ? new Date(Number.NaN) : new Date(quarantinedAtValue);
248
+ if (!Number.isFinite(quarantinedAt.getTime()))
249
+ throw new PlatformAccountResetPreviewError('operation_conflict');
250
+ return { action: 'rollback', apps, archivedAt: quarantinedAt.toISOString() };
251
+ }
252
+ async #fault(boundary) {
253
+ await this.#options.fault?.(boundary);
254
+ }
255
+ async #assertSourceFence(connection) {
256
+ await new PostgresPlatformAuthLegacyInventorySources({
257
+ googleRealm: this.#options.googleRealm,
258
+ sourceAvailability: this.#options.sourceAvailability,
259
+ excludedSubjects: [],
260
+ }).assertManifest(connection);
261
+ await assertPlatformAuthInventorySourceFence(connection, this.#options.sourceAvailability);
262
+ }
263
+ #transactionOptions(deadline) {
264
+ const timeout = deadline === undefined
265
+ ? this.#localCaptureTimeout()
266
+ : remainingPlatformAccountResetDispatchMilliseconds(deadline, this.#localCaptureTimeout());
267
+ return {
268
+ lockTables: PLATFORM_ACCOUNT_RESET_EXECUTION_TABLES,
269
+ lockTimeoutMs: timeout,
270
+ statementTimeoutMs: timeout,
271
+ };
272
+ }
273
+ #localCaptureTimeout() {
274
+ return Math.min(this.#options.localCaptureTimeoutMs !== undefined &&
275
+ Number.isSafeInteger(this.#options.localCaptureTimeoutMs) &&
276
+ this.#options.localCaptureTimeoutMs > 0
277
+ ? this.#options.localCaptureTimeoutMs
278
+ : DEFAULT_LOCAL_CAPTURE_TIMEOUT_MS, MAX_LOCAL_CAPTURE_TIMEOUT_MS);
279
+ }
280
+ }
281
+ //# sourceMappingURL=platform-account-reset-rollback-postgres.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-account-reset-rollback-postgres.js","sourceRoot":"","sources":["../src/platform-account-reset-rollback-postgres.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,wCAAwC,GAEzC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,iDAAiD,EACjD,uCAAuC,GACxC,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EACL,sCAAsC,EACtC,2CAA2C,EAC3C,uCAAuC,EACvC,+BAA+B,EAC/B,iCAAiC,EAGjC,kCAAkC,GACnC,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,gCAAgC,EAAE,MAAM,4CAA4C,CAAC;AAK9F,OAAO,EAAE,0CAA0C,EAAE,MAAM,sDAA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