@cuna_labs/cli 0.1.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 (624) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +9 -0
  3. package/README.md +169 -0
  4. package/THIRD_PARTY_NOTICES.md +29 -0
  5. package/dist/api/capability-evidence.d.ts +19 -0
  6. package/dist/api/capability-evidence.d.ts.map +1 -0
  7. package/dist/api/capability-evidence.js +38 -0
  8. package/dist/api/capability-evidence.js.map +1 -0
  9. package/dist/api/client.d.ts +167 -0
  10. package/dist/api/client.d.ts.map +1 -0
  11. package/dist/api/client.js +937 -0
  12. package/dist/api/client.js.map +1 -0
  13. package/dist/api/contracts.d.ts +345 -0
  14. package/dist/api/contracts.d.ts.map +1 -0
  15. package/dist/api/contracts.js +976 -0
  16. package/dist/api/contracts.js.map +1 -0
  17. package/dist/api/execution-workspaces.d.ts +17 -0
  18. package/dist/api/execution-workspaces.d.ts.map +1 -0
  19. package/dist/api/execution-workspaces.js +46 -0
  20. package/dist/api/execution-workspaces.js.map +1 -0
  21. package/dist/api/http.d.ts +76 -0
  22. package/dist/api/http.d.ts.map +1 -0
  23. package/dist/api/http.js +838 -0
  24. package/dist/api/http.js.map +1 -0
  25. package/dist/api/managed-executions.d.ts +37 -0
  26. package/dist/api/managed-executions.d.ts.map +1 -0
  27. package/dist/api/managed-executions.js +80 -0
  28. package/dist/api/managed-executions.js.map +1 -0
  29. package/dist/api/observer-v2-schema.d.ts +206 -0
  30. package/dist/api/observer-v2-schema.d.ts.map +1 -0
  31. package/dist/api/observer-v2-schema.js +264 -0
  32. package/dist/api/observer-v2-schema.js.map +1 -0
  33. package/dist/api/observer-v2.d.ts +33 -0
  34. package/dist/api/observer-v2.d.ts.map +1 -0
  35. package/dist/api/observer-v2.js +60 -0
  36. package/dist/api/observer-v2.js.map +1 -0
  37. package/dist/api/owner-observe-grants-v2-schema.d.ts +678 -0
  38. package/dist/api/owner-observe-grants-v2-schema.d.ts.map +1 -0
  39. package/dist/api/owner-observe-grants-v2-schema.js +887 -0
  40. package/dist/api/owner-observe-grants-v2-schema.js.map +1 -0
  41. package/dist/api/owner-observe-grants-v2.d.ts +268 -0
  42. package/dist/api/owner-observe-grants-v2.d.ts.map +1 -0
  43. package/dist/api/owner-observe-grants-v2.js +604 -0
  44. package/dist/api/owner-observe-grants-v2.js.map +1 -0
  45. package/dist/api/provider-v2-schema.d.ts +293 -0
  46. package/dist/api/provider-v2-schema.d.ts.map +1 -0
  47. package/dist/api/provider-v2-schema.js +381 -0
  48. package/dist/api/provider-v2-schema.js.map +1 -0
  49. package/dist/api/provider-v2.d.ts +55 -0
  50. package/dist/api/provider-v2.d.ts.map +1 -0
  51. package/dist/api/provider-v2.js +54 -0
  52. package/dist/api/provider-v2.js.map +1 -0
  53. package/dist/api/remote-workspace.d.ts +29 -0
  54. package/dist/api/remote-workspace.d.ts.map +1 -0
  55. package/dist/api/remote-workspace.js +62 -0
  56. package/dist/api/remote-workspace.js.map +1 -0
  57. package/dist/api/supervisor-live-update.d.ts +248 -0
  58. package/dist/api/supervisor-live-update.d.ts.map +1 -0
  59. package/dist/api/supervisor-live-update.js +434 -0
  60. package/dist/api/supervisor-live-update.js.map +1 -0
  61. package/dist/api/terminal-reason.d.ts +5 -0
  62. package/dist/api/terminal-reason.d.ts.map +1 -0
  63. package/dist/api/terminal-reason.js +12 -0
  64. package/dist/api/terminal-reason.js.map +1 -0
  65. package/dist/auth/browser-handoff.d.ts +59 -0
  66. package/dist/auth/browser-handoff.d.ts.map +1 -0
  67. package/dist/auth/browser-handoff.js +33 -0
  68. package/dist/auth/browser-handoff.js.map +1 -0
  69. package/dist/auth/browser.d.ts +11 -0
  70. package/dist/auth/browser.d.ts.map +1 -0
  71. package/dist/auth/browser.js +47 -0
  72. package/dist/auth/browser.js.map +1 -0
  73. package/dist/auth/human-client.d.ts +39 -0
  74. package/dist/auth/human-client.d.ts.map +1 -0
  75. package/dist/auth/human-client.js +66 -0
  76. package/dist/auth/human-client.js.map +1 -0
  77. package/dist/auth/human-contracts.d.ts +52 -0
  78. package/dist/auth/human-contracts.d.ts.map +1 -0
  79. package/dist/auth/human-contracts.js +229 -0
  80. package/dist/auth/human-contracts.js.map +1 -0
  81. package/dist/auth/human-session.d.ts +48 -0
  82. package/dist/auth/human-session.d.ts.map +1 -0
  83. package/dist/auth/human-session.js +902 -0
  84. package/dist/auth/human-session.js.map +1 -0
  85. package/dist/auth/onboarding-state.d.ts +31 -0
  86. package/dist/auth/onboarding-state.d.ts.map +1 -0
  87. package/dist/auth/onboarding-state.js +52 -0
  88. package/dist/auth/onboarding-state.js.map +1 -0
  89. package/dist/auth/pkce.d.ts +15 -0
  90. package/dist/auth/pkce.d.ts.map +1 -0
  91. package/dist/auth/pkce.js +19 -0
  92. package/dist/auth/pkce.js.map +1 -0
  93. package/dist/bin/cuna.d.ts +3 -0
  94. package/dist/bin/cuna.d.ts.map +1 -0
  95. package/dist/bin/cuna.js +4 -0
  96. package/dist/bin/cuna.js.map +1 -0
  97. package/dist/build-identity.d.ts +20 -0
  98. package/dist/build-identity.d.ts.map +1 -0
  99. package/dist/build-identity.js +77 -0
  100. package/dist/build-identity.js.map +1 -0
  101. package/dist/cli/command-help.d.ts +9 -0
  102. package/dist/cli/command-help.d.ts.map +1 -0
  103. package/dist/cli/command-help.js +324 -0
  104. package/dist/cli/command-help.js.map +1 -0
  105. package/dist/cli/help.d.ts +40 -0
  106. package/dist/cli/help.d.ts.map +1 -0
  107. package/dist/cli/help.js +256 -0
  108. package/dist/cli/help.js.map +1 -0
  109. package/dist/cli/output.d.ts +28 -0
  110. package/dist/cli/output.d.ts.map +1 -0
  111. package/dist/cli/output.js +95 -0
  112. package/dist/cli/output.js.map +1 -0
  113. package/dist/cli/parser.d.ts +65 -0
  114. package/dist/cli/parser.d.ts.map +1 -0
  115. package/dist/cli/parser.js +294 -0
  116. package/dist/cli/parser.js.map +1 -0
  117. package/dist/cli/process-entrypoint.d.ts +18 -0
  118. package/dist/cli/process-entrypoint.d.ts.map +1 -0
  119. package/dist/cli/process-entrypoint.js +26 -0
  120. package/dist/cli/process-entrypoint.js.map +1 -0
  121. package/dist/cli/run.d.ts +114 -0
  122. package/dist/cli/run.d.ts.map +1 -0
  123. package/dist/cli/run.js +1969 -0
  124. package/dist/cli/run.js.map +1 -0
  125. package/dist/commands/commands.d.ts +74 -0
  126. package/dist/commands/commands.d.ts.map +1 -0
  127. package/dist/commands/commands.js +2814 -0
  128. package/dist/commands/commands.js.map +1 -0
  129. package/dist/config/config.d.ts +86 -0
  130. package/dist/config/config.d.ts.map +1 -0
  131. package/dist/config/config.js +323 -0
  132. package/dist/config/config.js.map +1 -0
  133. package/dist/config/infra-contract-witness.d.ts +29 -0
  134. package/dist/config/infra-contract-witness.d.ts.map +1 -0
  135. package/dist/config/infra-contract-witness.js +30 -0
  136. package/dist/config/infra-contract-witness.js.map +1 -0
  137. package/dist/core/browser-url.d.ts +2 -0
  138. package/dist/core/browser-url.d.ts.map +1 -0
  139. package/dist/core/browser-url.js +20 -0
  140. package/dist/core/browser-url.js.map +1 -0
  141. package/dist/core/deployed-wire-compatibility.d.ts +15 -0
  142. package/dist/core/deployed-wire-compatibility.d.ts.map +1 -0
  143. package/dist/core/deployed-wire-compatibility.js +15 -0
  144. package/dist/core/deployed-wire-compatibility.js.map +1 -0
  145. package/dist/core/errors.d.ts +59 -0
  146. package/dist/core/errors.d.ts.map +1 -0
  147. package/dist/core/errors.js +82 -0
  148. package/dist/core/errors.js.map +1 -0
  149. package/dist/core/exit-codes.d.ts +68 -0
  150. package/dist/core/exit-codes.d.ts.map +1 -0
  151. package/dist/core/exit-codes.js +84 -0
  152. package/dist/core/exit-codes.js.map +1 -0
  153. package/dist/core/instant.d.ts +60 -0
  154. package/dist/core/instant.d.ts.map +1 -0
  155. package/dist/core/instant.js +90 -0
  156. package/dist/core/instant.js.map +1 -0
  157. package/dist/core/namespace.d.ts +171 -0
  158. package/dist/core/namespace.d.ts.map +1 -0
  159. package/dist/core/namespace.js +227 -0
  160. package/dist/core/namespace.js.map +1 -0
  161. package/dist/core/observation-budget.d.ts +185 -0
  162. package/dist/core/observation-budget.d.ts.map +1 -0
  163. package/dist/core/observation-budget.js +209 -0
  164. package/dist/core/observation-budget.js.map +1 -0
  165. package/dist/core/product-web.d.ts +81 -0
  166. package/dist/core/product-web.d.ts.map +1 -0
  167. package/dist/core/product-web.js +87 -0
  168. package/dist/core/product-web.js.map +1 -0
  169. package/dist/core/validation.d.ts +90 -0
  170. package/dist/core/validation.d.ts.map +1 -0
  171. package/dist/core/validation.js +199 -0
  172. package/dist/core/validation.js.map +1 -0
  173. package/dist/credentials/contracts.d.ts +82 -0
  174. package/dist/credentials/contracts.d.ts.map +1 -0
  175. package/dist/credentials/contracts.js +2 -0
  176. package/dist/credentials/contracts.js.map +1 -0
  177. package/dist/credentials/errors.d.ts +19 -0
  178. package/dist/credentials/errors.d.ts.map +1 -0
  179. package/dist/credentials/errors.js +16 -0
  180. package/dist/credentials/errors.js.map +1 -0
  181. package/dist/credentials/index.d.ts +6 -0
  182. package/dist/credentials/index.d.ts.map +1 -0
  183. package/dist/credentials/index.js +6 -0
  184. package/dist/credentials/index.js.map +1 -0
  185. package/dist/credentials/local-session.d.ts +101 -0
  186. package/dist/credentials/local-session.d.ts.map +1 -0
  187. package/dist/credentials/local-session.js +839 -0
  188. package/dist/credentials/local-session.js.map +1 -0
  189. package/dist/credentials/secret-material.d.ts +17 -0
  190. package/dist/credentials/secret-material.d.ts.map +1 -0
  191. package/dist/credentials/secret-material.js +49 -0
  192. package/dist/credentials/secret-material.js.map +1 -0
  193. package/dist/credentials/vault.d.ts +41 -0
  194. package/dist/credentials/vault.d.ts.map +1 -0
  195. package/dist/credentials/vault.js +719 -0
  196. package/dist/credentials/vault.js.map +1 -0
  197. package/dist/daemon/endpoint.d.ts +29 -0
  198. package/dist/daemon/endpoint.d.ts.map +1 -0
  199. package/dist/daemon/endpoint.js +66 -0
  200. package/dist/daemon/endpoint.js.map +1 -0
  201. package/dist/daemon/journal.d.ts +62 -0
  202. package/dist/daemon/journal.d.ts.map +1 -0
  203. package/dist/daemon/journal.js +299 -0
  204. package/dist/daemon/journal.js.map +1 -0
  205. package/dist/daemon/lease.d.ts +25 -0
  206. package/dist/daemon/lease.d.ts.map +1 -0
  207. package/dist/daemon/lease.js +94 -0
  208. package/dist/daemon/lease.js.map +1 -0
  209. package/dist/daemon/lifecycle.d.ts +14 -0
  210. package/dist/daemon/lifecycle.d.ts.map +1 -0
  211. package/dist/daemon/lifecycle.js +29 -0
  212. package/dist/daemon/lifecycle.js.map +1 -0
  213. package/dist/daemon/protocol.d.ts +65 -0
  214. package/dist/daemon/protocol.d.ts.map +1 -0
  215. package/dist/daemon/protocol.js +194 -0
  216. package/dist/daemon/protocol.js.map +1 -0
  217. package/dist/daemon/supervisor.d.ts +29 -0
  218. package/dist/daemon/supervisor.d.ts.map +1 -0
  219. package/dist/daemon/supervisor.js +87 -0
  220. package/dist/daemon/supervisor.js.map +1 -0
  221. package/dist/daemon/views.d.ts +31 -0
  222. package/dist/daemon/views.d.ts.map +1 -0
  223. package/dist/daemon/views.js +86 -0
  224. package/dist/daemon/views.js.map +1 -0
  225. package/dist/index.d.ts +38 -0
  226. package/dist/index.d.ts.map +1 -0
  227. package/dist/index.js +38 -0
  228. package/dist/index.js.map +1 -0
  229. package/dist/journey/api-effects.d.ts +59 -0
  230. package/dist/journey/api-effects.d.ts.map +1 -0
  231. package/dist/journey/api-effects.js +386 -0
  232. package/dist/journey/api-effects.js.map +1 -0
  233. package/dist/journey/derived-identity.d.ts +91 -0
  234. package/dist/journey/derived-identity.d.ts.map +1 -0
  235. package/dist/journey/derived-identity.js +123 -0
  236. package/dist/journey/derived-identity.js.map +1 -0
  237. package/dist/journey/index.d.ts +6 -0
  238. package/dist/journey/index.d.ts.map +1 -0
  239. package/dist/journey/index.js +6 -0
  240. package/dist/journey/index.js.map +1 -0
  241. package/dist/journey/intent.d.ts +36 -0
  242. package/dist/journey/intent.d.ts.map +1 -0
  243. package/dist/journey/intent.js +191 -0
  244. package/dist/journey/intent.js.map +1 -0
  245. package/dist/journey/orchestrator.d.ts +140 -0
  246. package/dist/journey/orchestrator.d.ts.map +1 -0
  247. package/dist/journey/orchestrator.js +415 -0
  248. package/dist/journey/orchestrator.js.map +1 -0
  249. package/dist/journey/provider-launch-intent.d.ts +12 -0
  250. package/dist/journey/provider-launch-intent.d.ts.map +1 -0
  251. package/dist/journey/provider-launch-intent.js +40 -0
  252. package/dist/journey/provider-launch-intent.js.map +1 -0
  253. package/dist/journey/remote-workspace.d.ts +34 -0
  254. package/dist/journey/remote-workspace.d.ts.map +1 -0
  255. package/dist/journey/remote-workspace.js +91 -0
  256. package/dist/journey/remote-workspace.js.map +1 -0
  257. package/dist/journey/root-entry.d.ts +56 -0
  258. package/dist/journey/root-entry.d.ts.map +1 -0
  259. package/dist/journey/root-entry.js +19 -0
  260. package/dist/journey/root-entry.js.map +1 -0
  261. package/dist/journey/selection.d.ts +165 -0
  262. package/dist/journey/selection.d.ts.map +1 -0
  263. package/dist/journey/selection.js +565 -0
  264. package/dist/journey/selection.js.map +1 -0
  265. package/dist/journey/session-failure.d.ts +4 -0
  266. package/dist/journey/session-failure.d.ts.map +1 -0
  267. package/dist/journey/session-failure.js +28 -0
  268. package/dist/journey/session-failure.js.map +1 -0
  269. package/dist/journey/workspace-effects.d.ts +30 -0
  270. package/dist/journey/workspace-effects.d.ts.map +1 -0
  271. package/dist/journey/workspace-effects.js +348 -0
  272. package/dist/journey/workspace-effects.js.map +1 -0
  273. package/dist/local-actions/broker.d.ts +32 -0
  274. package/dist/local-actions/broker.d.ts.map +1 -0
  275. package/dist/local-actions/broker.js +400 -0
  276. package/dist/local-actions/broker.js.map +1 -0
  277. package/dist/local-actions/browser-action.d.ts +78 -0
  278. package/dist/local-actions/browser-action.d.ts.map +1 -0
  279. package/dist/local-actions/browser-action.js +307 -0
  280. package/dist/local-actions/browser-action.js.map +1 -0
  281. package/dist/local-actions/callback-relay.d.ts +45 -0
  282. package/dist/local-actions/callback-relay.d.ts.map +1 -0
  283. package/dist/local-actions/callback-relay.js +265 -0
  284. package/dist/local-actions/callback-relay.js.map +1 -0
  285. package/dist/local-actions/clipboard.d.ts +3 -0
  286. package/dist/local-actions/clipboard.d.ts.map +1 -0
  287. package/dist/local-actions/clipboard.js +18 -0
  288. package/dist/local-actions/clipboard.js.map +1 -0
  289. package/dist/local-actions/contracts.d.ts +63 -0
  290. package/dist/local-actions/contracts.d.ts.map +1 -0
  291. package/dist/local-actions/contracts.js +18 -0
  292. package/dist/local-actions/contracts.js.map +1 -0
  293. package/dist/local-actions/desktop-presentation.d.ts +141 -0
  294. package/dist/local-actions/desktop-presentation.d.ts.map +1 -0
  295. package/dist/local-actions/desktop-presentation.js +253 -0
  296. package/dist/local-actions/desktop-presentation.js.map +1 -0
  297. package/dist/local-actions/device-selection.d.ts +43 -0
  298. package/dist/local-actions/device-selection.d.ts.map +1 -0
  299. package/dist/local-actions/device-selection.js +154 -0
  300. package/dist/local-actions/device-selection.js.map +1 -0
  301. package/dist/local-actions/executor.d.ts +49 -0
  302. package/dist/local-actions/executor.d.ts.map +1 -0
  303. package/dist/local-actions/executor.js +329 -0
  304. package/dist/local-actions/executor.js.map +1 -0
  305. package/dist/local-actions/file-transfers.d.ts +141 -0
  306. package/dist/local-actions/file-transfers.d.ts.map +1 -0
  307. package/dist/local-actions/file-transfers.js +446 -0
  308. package/dist/local-actions/file-transfers.js.map +1 -0
  309. package/dist/local-actions/foreground-notifications.d.ts +45 -0
  310. package/dist/local-actions/foreground-notifications.d.ts.map +1 -0
  311. package/dist/local-actions/foreground-notifications.js +163 -0
  312. package/dist/local-actions/foreground-notifications.js.map +1 -0
  313. package/dist/local-actions/git-signing.d.ts +39 -0
  314. package/dist/local-actions/git-signing.d.ts.map +1 -0
  315. package/dist/local-actions/git-signing.js +135 -0
  316. package/dist/local-actions/git-signing.js.map +1 -0
  317. package/dist/local-actions/index.d.ts +19 -0
  318. package/dist/local-actions/index.d.ts.map +1 -0
  319. package/dist/local-actions/index.js +19 -0
  320. package/dist/local-actions/index.js.map +1 -0
  321. package/dist/local-actions/local-service-actions.d.ts +87 -0
  322. package/dist/local-actions/local-service-actions.d.ts.map +1 -0
  323. package/dist/local-actions/local-service-actions.js +347 -0
  324. package/dist/local-actions/local-service-actions.js.map +1 -0
  325. package/dist/local-actions/loopback.d.ts +5 -0
  326. package/dist/local-actions/loopback.d.ts.map +1 -0
  327. package/dist/local-actions/loopback.js +15 -0
  328. package/dist/local-actions/loopback.js.map +1 -0
  329. package/dist/local-actions/policy-store.d.ts +7 -0
  330. package/dist/local-actions/policy-store.d.ts.map +1 -0
  331. package/dist/local-actions/policy-store.js +70 -0
  332. package/dist/local-actions/policy-store.js.map +1 -0
  333. package/dist/local-actions/policy.d.ts +21 -0
  334. package/dist/local-actions/policy.d.ts.map +1 -0
  335. package/dist/local-actions/policy.js +43 -0
  336. package/dist/local-actions/policy.js.map +1 -0
  337. package/dist/local-actions/private-port-forward.d.ts +36 -0
  338. package/dist/local-actions/private-port-forward.d.ts.map +1 -0
  339. package/dist/local-actions/private-port-forward.js +154 -0
  340. package/dist/local-actions/private-port-forward.js.map +1 -0
  341. package/dist/local-actions/provider-mcp-config.d.ts +101 -0
  342. package/dist/local-actions/provider-mcp-config.d.ts.map +1 -0
  343. package/dist/local-actions/provider-mcp-config.js +166 -0
  344. package/dist/local-actions/provider-mcp-config.js.map +1 -0
  345. package/dist/local-actions/providers.d.ts +12 -0
  346. package/dist/local-actions/providers.d.ts.map +1 -0
  347. package/dist/local-actions/providers.js +42 -0
  348. package/dist/local-actions/providers.js.map +1 -0
  349. package/dist/local-actions/schemas.d.ts +4 -0
  350. package/dist/local-actions/schemas.d.ts.map +1 -0
  351. package/dist/local-actions/schemas.js +314 -0
  352. package/dist/local-actions/schemas.js.map +1 -0
  353. package/dist/local-actions/sensitive-consent.d.ts +32 -0
  354. package/dist/local-actions/sensitive-consent.d.ts.map +1 -0
  355. package/dist/local-actions/sensitive-consent.js +47 -0
  356. package/dist/local-actions/sensitive-consent.js.map +1 -0
  357. package/dist/machines/command-launch.d.ts +17 -0
  358. package/dist/machines/command-launch.d.ts.map +1 -0
  359. package/dist/machines/command-launch.js +52 -0
  360. package/dist/machines/command-launch.js.map +1 -0
  361. package/dist/machines/execution-receipt.d.ts +18 -0
  362. package/dist/machines/execution-receipt.d.ts.map +1 -0
  363. package/dist/machines/execution-receipt.js +87 -0
  364. package/dist/machines/execution-receipt.js.map +1 -0
  365. package/dist/machines/executions-screen.d.ts +6 -0
  366. package/dist/machines/executions-screen.d.ts.map +1 -0
  367. package/dist/machines/executions-screen.js +410 -0
  368. package/dist/machines/executions-screen.js.map +1 -0
  369. package/dist/machines/explorer.d.ts +75 -0
  370. package/dist/machines/explorer.d.ts.map +1 -0
  371. package/dist/machines/explorer.js +1726 -0
  372. package/dist/machines/explorer.js.map +1 -0
  373. package/dist/machines/live-supervisor-update.d.ts +325 -0
  374. package/dist/machines/live-supervisor-update.d.ts.map +1 -0
  375. package/dist/machines/live-supervisor-update.js +513 -0
  376. package/dist/machines/live-supervisor-update.js.map +1 -0
  377. package/dist/machines/machine-first.d.ts +123 -0
  378. package/dist/machines/machine-first.d.ts.map +1 -0
  379. package/dist/machines/machine-first.js +119 -0
  380. package/dist/machines/machine-first.js.map +1 -0
  381. package/dist/machines/opencode-supervisor.d.ts +51 -0
  382. package/dist/machines/opencode-supervisor.d.ts.map +1 -0
  383. package/dist/machines/opencode-supervisor.js +124 -0
  384. package/dist/machines/opencode-supervisor.js.map +1 -0
  385. package/dist/machines/pagination.d.ts +4 -0
  386. package/dist/machines/pagination.d.ts.map +1 -0
  387. package/dist/machines/pagination.js +7 -0
  388. package/dist/machines/pagination.js.map +1 -0
  389. package/dist/machines/provider-availability.d.ts +42 -0
  390. package/dist/machines/provider-availability.d.ts.map +1 -0
  391. package/dist/machines/provider-availability.js +82 -0
  392. package/dist/machines/provider-availability.js.map +1 -0
  393. package/dist/machines/provider-screen.d.ts +12 -0
  394. package/dist/machines/provider-screen.d.ts.map +1 -0
  395. package/dist/machines/provider-screen.js +129 -0
  396. package/dist/machines/provider-screen.js.map +1 -0
  397. package/dist/machines/session-actionability.d.ts +86 -0
  398. package/dist/machines/session-actionability.d.ts.map +1 -0
  399. package/dist/machines/session-actionability.js +125 -0
  400. package/dist/machines/session-actionability.js.map +1 -0
  401. package/dist/machines/session-visibility.d.ts +139 -0
  402. package/dist/machines/session-visibility.d.ts.map +1 -0
  403. package/dist/machines/session-visibility.js +109 -0
  404. package/dist/machines/session-visibility.js.map +1 -0
  405. package/dist/platform/adapter.d.ts +62 -0
  406. package/dist/platform/adapter.d.ts.map +1 -0
  407. package/dist/platform/adapter.js +240 -0
  408. package/dist/platform/adapter.js.map +1 -0
  409. package/dist/platform/support.d.ts +12 -0
  410. package/dist/platform/support.d.ts.map +1 -0
  411. package/dist/platform/support.js +25 -0
  412. package/dist/platform/support.js.map +1 -0
  413. package/dist/pty/contracts.d.ts +45 -0
  414. package/dist/pty/contracts.d.ts.map +1 -0
  415. package/dist/pty/contracts.js +2 -0
  416. package/dist/pty/contracts.js.map +1 -0
  417. package/dist/pty/evidence-gate.d.ts +14 -0
  418. package/dist/pty/evidence-gate.d.ts.map +1 -0
  419. package/dist/pty/evidence-gate.js +35 -0
  420. package/dist/pty/evidence-gate.js.map +1 -0
  421. package/dist/pty/index.d.ts +5 -0
  422. package/dist/pty/index.d.ts.map +1 -0
  423. package/dist/pty/index.js +5 -0
  424. package/dist/pty/index.js.map +1 -0
  425. package/dist/pty/node-host-terminal.d.ts +14 -0
  426. package/dist/pty/node-host-terminal.d.ts.map +1 -0
  427. package/dist/pty/node-host-terminal.js +173 -0
  428. package/dist/pty/node-host-terminal.js.map +1 -0
  429. package/dist/pty/node-process.d.ts +26 -0
  430. package/dist/pty/node-process.d.ts.map +1 -0
  431. package/dist/pty/node-process.js +102 -0
  432. package/dist/pty/node-process.js.map +1 -0
  433. package/dist/runtime/api-terminal-control-plane.d.ts +7 -0
  434. package/dist/runtime/api-terminal-control-plane.d.ts.map +1 -0
  435. package/dist/runtime/api-terminal-control-plane.js +95 -0
  436. package/dist/runtime/api-terminal-control-plane.js.map +1 -0
  437. package/dist/runtime/backoff.d.ts +17 -0
  438. package/dist/runtime/backoff.d.ts.map +1 -0
  439. package/dist/runtime/backoff.js +61 -0
  440. package/dist/runtime/backoff.js.map +1 -0
  441. package/dist/runtime/boundary.d.ts +171 -0
  442. package/dist/runtime/boundary.d.ts.map +1 -0
  443. package/dist/runtime/boundary.js +1858 -0
  444. package/dist/runtime/boundary.js.map +1 -0
  445. package/dist/runtime/capability-gate.d.ts +25 -0
  446. package/dist/runtime/capability-gate.d.ts.map +1 -0
  447. package/dist/runtime/capability-gate.js +77 -0
  448. package/dist/runtime/capability-gate.js.map +1 -0
  449. package/dist/runtime/contracts.d.ts +25 -0
  450. package/dist/runtime/contracts.d.ts.map +1 -0
  451. package/dist/runtime/contracts.js +66 -0
  452. package/dist/runtime/contracts.js.map +1 -0
  453. package/dist/runtime/errors.d.ts +20 -0
  454. package/dist/runtime/errors.d.ts.map +1 -0
  455. package/dist/runtime/errors.js +22 -0
  456. package/dist/runtime/errors.js.map +1 -0
  457. package/dist/runtime/index.d.ts +9 -0
  458. package/dist/runtime/index.d.ts.map +1 -0
  459. package/dist/runtime/index.js +9 -0
  460. package/dist/runtime/index.js.map +1 -0
  461. package/dist/runtime/node-foreground-session.d.ts +50 -0
  462. package/dist/runtime/node-foreground-session.d.ts.map +1 -0
  463. package/dist/runtime/node-foreground-session.js +431 -0
  464. package/dist/runtime/node-foreground-session.js.map +1 -0
  465. package/dist/runtime/node-websocket-connector.d.ts +6 -0
  466. package/dist/runtime/node-websocket-connector.d.ts.map +1 -0
  467. package/dist/runtime/node-websocket-connector.js +344 -0
  468. package/dist/runtime/node-websocket-connector.js.map +1 -0
  469. package/dist/runtime/observer-screen.d.ts +6 -0
  470. package/dist/runtime/observer-screen.d.ts.map +1 -0
  471. package/dist/runtime/observer-screen.js +144 -0
  472. package/dist/runtime/observer-screen.js.map +1 -0
  473. package/dist/runtime/owner-grant-operations.d.ts +136 -0
  474. package/dist/runtime/owner-grant-operations.d.ts.map +1 -0
  475. package/dist/runtime/owner-grant-operations.js +216 -0
  476. package/dist/runtime/owner-grant-operations.js.map +1 -0
  477. package/dist/runtime/owner-grants-screen.d.ts +40 -0
  478. package/dist/runtime/owner-grants-screen.d.ts.map +1 -0
  479. package/dist/runtime/owner-grants-screen.js +987 -0
  480. package/dist/runtime/owner-grants-screen.js.map +1 -0
  481. package/dist/runtime/terminal-transport.d.ts +85 -0
  482. package/dist/runtime/terminal-transport.d.ts.map +1 -0
  483. package/dist/runtime/terminal-transport.js +152 -0
  484. package/dist/runtime/terminal-transport.js.map +1 -0
  485. package/dist/sync/continuous-sync-supervisor.d.ts +107 -0
  486. package/dist/sync/continuous-sync-supervisor.d.ts.map +1 -0
  487. package/dist/sync/continuous-sync-supervisor.js +1117 -0
  488. package/dist/sync/continuous-sync-supervisor.js.map +1 -0
  489. package/dist/sync/index.d.ts +9 -0
  490. package/dist/sync/index.d.ts.map +1 -0
  491. package/dist/sync/index.js +9 -0
  492. package/dist/sync/index.js.map +1 -0
  493. package/dist/sync/journal.d.ts +57 -0
  494. package/dist/sync/journal.d.ts.map +1 -0
  495. package/dist/sync/journal.js +685 -0
  496. package/dist/sync/journal.js.map +1 -0
  497. package/dist/sync/revisions.d.ts +118 -0
  498. package/dist/sync/revisions.d.ts.map +1 -0
  499. package/dist/sync/revisions.js +364 -0
  500. package/dist/sync/revisions.js.map +1 -0
  501. package/dist/sync/supervisor.d.ts +107 -0
  502. package/dist/sync/supervisor.d.ts.map +1 -0
  503. package/dist/sync/supervisor.js +246 -0
  504. package/dist/sync/supervisor.js.map +1 -0
  505. package/dist/sync/workspace-sync-client.d.ts +18 -0
  506. package/dist/sync/workspace-sync-client.d.ts.map +1 -0
  507. package/dist/sync/workspace-sync-client.js +150 -0
  508. package/dist/sync/workspace-sync-client.js.map +1 -0
  509. package/dist/sync/workspace-sync-coordinator.d.ts +76 -0
  510. package/dist/sync/workspace-sync-coordinator.d.ts.map +1 -0
  511. package/dist/sync/workspace-sync-coordinator.js +621 -0
  512. package/dist/sync/workspace-sync-coordinator.js.map +1 -0
  513. package/dist/sync/workspace-sync-product-service.d.ts +79 -0
  514. package/dist/sync/workspace-sync-product-service.d.ts.map +1 -0
  515. package/dist/sync/workspace-sync-product-service.js +398 -0
  516. package/dist/sync/workspace-sync-product-service.js.map +1 -0
  517. package/dist/sync/workspace-sync-protocol.d.ts +145 -0
  518. package/dist/sync/workspace-sync-protocol.d.ts.map +1 -0
  519. package/dist/sync/workspace-sync-protocol.js +347 -0
  520. package/dist/sync/workspace-sync-protocol.js.map +1 -0
  521. package/dist/terminal/appbar.d.ts +40 -0
  522. package/dist/terminal/appbar.d.ts.map +1 -0
  523. package/dist/terminal/appbar.js +55 -0
  524. package/dist/terminal/appbar.js.map +1 -0
  525. package/dist/terminal/cell-width.d.ts +3 -0
  526. package/dist/terminal/cell-width.d.ts.map +1 -0
  527. package/dist/terminal/cell-width.js +53 -0
  528. package/dist/terminal/cell-width.js.map +1 -0
  529. package/dist/terminal/codec.d.ts +107 -0
  530. package/dist/terminal/codec.d.ts.map +1 -0
  531. package/dist/terminal/codec.js +538 -0
  532. package/dist/terminal/codec.js.map +1 -0
  533. package/dist/terminal/foreground.d.ts +135 -0
  534. package/dist/terminal/foreground.d.ts.map +1 -0
  535. package/dist/terminal/foreground.js +2097 -0
  536. package/dist/terminal/foreground.js.map +1 -0
  537. package/dist/terminal/generated/terminal-wire-v1.d.ts +26 -0
  538. package/dist/terminal/generated/terminal-wire-v1.d.ts.map +1 -0
  539. package/dist/terminal/generated/terminal-wire-v1.js +27 -0
  540. package/dist/terminal/generated/terminal-wire-v1.js.map +1 -0
  541. package/dist/terminal/mode.d.ts +33 -0
  542. package/dist/terminal/mode.d.ts.map +1 -0
  543. package/dist/terminal/mode.js +99 -0
  544. package/dist/terminal/mode.js.map +1 -0
  545. package/dist/terminal/passthrough.d.ts +47 -0
  546. package/dist/terminal/passthrough.d.ts.map +1 -0
  547. package/dist/terminal/passthrough.js +666 -0
  548. package/dist/terminal/passthrough.js.map +1 -0
  549. package/dist/terminal/resume.d.ts +58 -0
  550. package/dist/terminal/resume.d.ts.map +1 -0
  551. package/dist/terminal/resume.js +185 -0
  552. package/dist/terminal/resume.js.map +1 -0
  553. package/dist/terminal/viewport.d.ts +93 -0
  554. package/dist/terminal/viewport.d.ts.map +1 -0
  555. package/dist/terminal/viewport.js +266 -0
  556. package/dist/terminal/viewport.js.map +1 -0
  557. package/dist/terminal/workbench.d.ts +32 -0
  558. package/dist/terminal/workbench.d.ts.map +1 -0
  559. package/dist/terminal/workbench.js +316 -0
  560. package/dist/terminal/workbench.js.map +1 -0
  561. package/dist/terminal/xterm-vte.d.ts +49 -0
  562. package/dist/terminal/xterm-vte.d.ts.map +1 -0
  563. package/dist/terminal/xterm-vte.js +602 -0
  564. package/dist/terminal/xterm-vte.js.map +1 -0
  565. package/dist/version.d.ts +3 -0
  566. package/dist/version.d.ts.map +1 -0
  567. package/dist/version.js +3 -0
  568. package/dist/version.js.map +1 -0
  569. package/dist/workspace/binding-path.d.ts +17 -0
  570. package/dist/workspace/binding-path.d.ts.map +1 -0
  571. package/dist/workspace/binding-path.js +91 -0
  572. package/dist/workspace/binding-path.js.map +1 -0
  573. package/dist/workspace/binding-store.d.ts +107 -0
  574. package/dist/workspace/binding-store.d.ts.map +1 -0
  575. package/dist/workspace/binding-store.js +783 -0
  576. package/dist/workspace/binding-store.js.map +1 -0
  577. package/dist/workspace/binding.d.ts +35 -0
  578. package/dist/workspace/binding.d.ts.map +1 -0
  579. package/dist/workspace/binding.js +70 -0
  580. package/dist/workspace/binding.js.map +1 -0
  581. package/dist/workspace/errors.d.ts +4 -0
  582. package/dist/workspace/errors.d.ts.map +1 -0
  583. package/dist/workspace/errors.js +19 -0
  584. package/dist/workspace/errors.js.map +1 -0
  585. package/dist/workspace/exclusion.d.ts +21 -0
  586. package/dist/workspace/exclusion.d.ts.map +1 -0
  587. package/dist/workspace/exclusion.js +243 -0
  588. package/dist/workspace/exclusion.js.map +1 -0
  589. package/dist/workspace/index.d.ts +8 -0
  590. package/dist/workspace/index.d.ts.map +1 -0
  591. package/dist/workspace/index.js +8 -0
  592. package/dist/workspace/index.js.map +1 -0
  593. package/dist/workspace/lifecycle.d.ts +56 -0
  594. package/dist/workspace/lifecycle.d.ts.map +1 -0
  595. package/dist/workspace/lifecycle.js +94 -0
  596. package/dist/workspace/lifecycle.js.map +1 -0
  597. package/dist/workspace/manifest.d.ts +47 -0
  598. package/dist/workspace/manifest.d.ts.map +1 -0
  599. package/dist/workspace/manifest.js +243 -0
  600. package/dist/workspace/manifest.js.map +1 -0
  601. package/dist/workspace/paths.d.ts +14 -0
  602. package/dist/workspace/paths.d.ts.map +1 -0
  603. package/dist/workspace/paths.js +67 -0
  604. package/dist/workspace/paths.js.map +1 -0
  605. package/dist/workspace/schema.d.ts +15 -0
  606. package/dist/workspace/schema.d.ts.map +1 -0
  607. package/dist/workspace/schema.js +33 -0
  608. package/dist/workspace/schema.js.map +1 -0
  609. package/dist/workspace/selection-screen.d.ts +4 -0
  610. package/dist/workspace/selection-screen.d.ts.map +1 -0
  611. package/dist/workspace/selection-screen.js +216 -0
  612. package/dist/workspace/selection-screen.js.map +1 -0
  613. package/dist/workspace/selection-service.d.ts +16 -0
  614. package/dist/workspace/selection-service.d.ts.map +1 -0
  615. package/dist/workspace/selection-service.js +65 -0
  616. package/dist/workspace/selection-service.js.map +1 -0
  617. package/node_modules/@xterm/headless/README.md +31 -0
  618. package/node_modules/@xterm/headless/lib-headless/xterm-headless.js +2 -0
  619. package/node_modules/@xterm/headless/lib-headless/xterm-headless.js.map +1 -0
  620. package/node_modules/@xterm/headless/lib-headless/xterm-headless.mjs +46 -0
  621. package/node_modules/@xterm/headless/lib-headless/xterm-headless.mjs.map +7 -0
  622. package/node_modules/@xterm/headless/package.json +29 -0
  623. package/node_modules/@xterm/headless/typings/xterm-headless.d.ts +1385 -0
  624. package/package.json +75 -0
@@ -0,0 +1,719 @@
1
+ import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
2
+ import { CREDENTIAL_BACKEND_PROTOCOL, } from "./contracts.js";
3
+ import { CredentialBoundaryError, credentialFailure } from "./errors.js";
4
+ import { SecretMaterial } from "./secret-material.js";
5
+ const ENVELOPE_MAGIC = new TextEncoder().encode("CUNACRED");
6
+ const ENVELOPE_VERSION = 1;
7
+ const MAXIMUM_ENVELOPE_BYTES = 96 * 1024;
8
+ const MAXIMUM_HEADER_BYTES = 8 * 1024;
9
+ export class CredentialVault {
10
+ #backend;
11
+ #clock;
12
+ #platform;
13
+ #allowPreviewBackend;
14
+ #queues = new Map();
15
+ #refreshes = new Map();
16
+ #revoked = new Set();
17
+ #observedRevisionFences = new Map();
18
+ // This is process-local liveness evidence only. It never replaces the
19
+ // backend's own lock, ACL, metadata, or CAS checks performed by every read
20
+ // and write. Avoiding redundant probes matters on Windows, where a probe
21
+ // itself requires an owner/DACL inspection through the OS boundary.
22
+ #backendEvidence;
23
+ #lastObservedNow;
24
+ constructor(input) {
25
+ this.#backend = input.backend;
26
+ this.#clock = input.clock ?? Date.now;
27
+ this.#platform = input.platform ?? process.platform;
28
+ this.#allowPreviewBackend = input.allowPreviewBackend ?? false;
29
+ }
30
+ async load(binding) {
31
+ const normalized = normalizeBinding(binding);
32
+ const target = credentialTarget(normalized);
33
+ return await this.#exclusive(target, async () => {
34
+ await this.#requireBackend();
35
+ const encoded = await this.#backend.read(target);
36
+ if (encoded === undefined)
37
+ return undefined;
38
+ try {
39
+ const decoded = decodeEnvelope(encoded, bindingDigest(normalized));
40
+ if (decoded.header.expiresAt !== null && decoded.header.expiresAt <= this.#now()) {
41
+ decoded.payload.fill(0);
42
+ // Expired renewable material has no future use. Remove it while the
43
+ // target is exclusively locked so a concurrent rotation cannot be
44
+ // mistaken for the stale envelope we just decoded.
45
+ if (this.#backend.compareAndDelete !== undefined) {
46
+ // The digest belongs to the exact ciphertext decoded above. If a
47
+ // different process rotated it, expiry cleanup loses the compare
48
+ // and must not erase the newer session.
49
+ await this.#backend.compareAndDelete(target, decoded.storageSha256);
50
+ }
51
+ return undefined;
52
+ }
53
+ const material = SecretMaterial.fromBytes(decoded.payload);
54
+ decoded.payload.fill(0);
55
+ return {
56
+ material,
57
+ revision: decoded.header.revision,
58
+ expiresAt: decoded.header.expiresAt ?? undefined,
59
+ };
60
+ }
61
+ finally {
62
+ encoded.fill(0);
63
+ }
64
+ });
65
+ }
66
+ async rotate(input) {
67
+ const normalized = normalizeBinding(input.binding);
68
+ const target = credentialTarget(normalized);
69
+ return await this.#exclusive(target, async () => {
70
+ await this.#requireBackend();
71
+ // A rotation attempt makes any prior read fence unsuitable for a later
72
+ // fast deletion. Even an ambiguous write must fall back to a fresh
73
+ // observation rather than treating a process-local hint as authority.
74
+ this.#observedRevisionFences.delete(target);
75
+ const current = await this.#readEnvelope(target, normalized);
76
+ try {
77
+ if (input.expectedRevision !== undefined && current?.header.revision !== input.expectedRevision) {
78
+ throw credentialFailure("credential_revision_conflict", "The credential changed before rotation could be applied.", { retryable: true });
79
+ }
80
+ const nextRevision = safeRevisionIncrement(current?.header.revision ?? 0);
81
+ const encoded = input.material.withBytes((bytes) => encodeEnvelope({
82
+ binding: normalized,
83
+ revision: nextRevision,
84
+ storedAt: this.#now(),
85
+ ...(input.expiresAt !== undefined && { expiresAt: input.expiresAt }),
86
+ payload: bytes,
87
+ }));
88
+ try {
89
+ await this.#replaceWithReconciliation(target, encoded, normalized, current);
90
+ }
91
+ finally {
92
+ encoded.fill(0);
93
+ }
94
+ this.#revoked.delete(target);
95
+ return this.#presentStatus(normalized, nextRevision, input.expiresAt);
96
+ }
97
+ finally {
98
+ current?.payload.fill(0);
99
+ }
100
+ });
101
+ }
102
+ async refresh(binding, refresher) {
103
+ const normalized = normalizeBinding(binding);
104
+ const target = credentialTarget(normalized);
105
+ let flight = this.#refreshes.get(target);
106
+ if (flight === undefined) {
107
+ const created = {
108
+ waiters: 0,
109
+ promise: this.#exclusive(target, async () => {
110
+ const perform = async () => await this.#performRefresh(normalized, target, refresher);
111
+ return this.#backend.withRefreshLock === undefined
112
+ ? await perform()
113
+ : await this.#backend.withRefreshLock(target, perform);
114
+ }),
115
+ };
116
+ this.#refreshes.set(target, created);
117
+ flight = created;
118
+ }
119
+ flight.waiters += 1;
120
+ try {
121
+ const result = await flight.promise;
122
+ return {
123
+ material: SecretMaterial.fromBytes(result.bytes),
124
+ revision: result.revision,
125
+ expiresAt: result.expiresAt,
126
+ };
127
+ }
128
+ finally {
129
+ flight.waiters -= 1;
130
+ if (flight.waiters === 0 && this.#refreshes.get(target) === flight) {
131
+ this.#refreshes.delete(target);
132
+ void flight.promise.then((result) => result.bytes.fill(0), () => undefined);
133
+ }
134
+ }
135
+ }
136
+ async delete(binding) {
137
+ const normalized = normalizeBinding(binding);
138
+ const target = credentialTarget(normalized);
139
+ return await this.#exclusive(target, async () => {
140
+ await this.#requireBackend();
141
+ this.#observedRevisionFences.delete(target);
142
+ await this.#backend.delete(target);
143
+ this.#revoked.add(target);
144
+ return {
145
+ backendId: this.#backend.backendId,
146
+ backendStatus: this.#allowPreviewBackend ? "preview" : "verified",
147
+ state: "revoked",
148
+ bindingDigest: bindingDigest(normalized),
149
+ };
150
+ });
151
+ }
152
+ /**
153
+ * Remove a session only when the exact revision written by this operation is
154
+ * still current. A conflict is a successful safety outcome: a concurrent
155
+ * process owns the newer session and must not be erased as compensation for
156
+ * this caller.
157
+ */
158
+ async deleteIfRevision(input) {
159
+ if (!Number.isSafeInteger(input.expectedRevision) || input.expectedRevision < 1) {
160
+ throw credentialFailure("credential_binding_invalid", "The credential revision is invalid.");
161
+ }
162
+ const normalized = normalizeBinding(input.binding);
163
+ const target = credentialTarget(normalized);
164
+ return await this.#exclusive(target, async () => {
165
+ await this.#requireBackend();
166
+ if (this.#backend.compareAndDelete === undefined) {
167
+ throw credentialFailure("credential_backend_unverified", "The secure credential store cannot safely remove a revision-fenced session.");
168
+ }
169
+ // `refresh` has already parsed this exact envelope while it was read
170
+ // through the backend boundary. Avoid a second identical read only when
171
+ // that private observation matches the requested revision. The backend
172
+ // still atomically reads and compares the digest under its physical
173
+ // lock; a changed session is a conflict, never a deletion.
174
+ const fence = this.#observedRevisionFences.get(target);
175
+ if (fence !== undefined && fence.revision === input.expectedRevision) {
176
+ this.#observedRevisionFences.delete(target);
177
+ const outcome = await this.#backend.compareAndDelete(target, fence.storageSha256);
178
+ if (outcome === "deleted" || outcome === "absent") {
179
+ this.#revoked.add(target);
180
+ return outcome;
181
+ }
182
+ if (outcome === "conflict")
183
+ return outcome;
184
+ throw credentialFailure("credential_backend_failure", "The secure credential store returned an invalid revision-fenced deletion result.");
185
+ }
186
+ const current = await this.#readEnvelope(target, normalized);
187
+ if (current === undefined) {
188
+ this.#revoked.add(target);
189
+ return "absent";
190
+ }
191
+ try {
192
+ if (current.header.revision !== input.expectedRevision)
193
+ return "conflict";
194
+ const outcome = await this.#backend.compareAndDelete(target, current.storageSha256);
195
+ if (outcome === "deleted" || outcome === "absent") {
196
+ this.#revoked.add(target);
197
+ return outcome;
198
+ }
199
+ if (outcome === "conflict")
200
+ return outcome;
201
+ throw credentialFailure("credential_backend_failure", "The secure credential store returned an invalid revision-fenced deletion result.");
202
+ }
203
+ finally {
204
+ current.payload.fill(0);
205
+ }
206
+ });
207
+ }
208
+ async status(binding) {
209
+ const normalized = normalizeBinding(binding);
210
+ const target = credentialTarget(normalized);
211
+ let evidence;
212
+ try {
213
+ evidence = await this.#requireBackend();
214
+ }
215
+ catch {
216
+ return this.#unavailableStatus(normalized);
217
+ }
218
+ if (this.#revoked.has(target)) {
219
+ return {
220
+ backendId: this.#backend.backendId,
221
+ backendStatus: evidence.status,
222
+ state: "revoked",
223
+ bindingDigest: bindingDigest(normalized),
224
+ };
225
+ }
226
+ const encoded = await this.#backend.read(target);
227
+ if (encoded === undefined) {
228
+ return {
229
+ backendId: this.#backend.backendId,
230
+ backendStatus: evidence.status,
231
+ state: "absent",
232
+ bindingDigest: bindingDigest(normalized),
233
+ };
234
+ }
235
+ try {
236
+ const decoded = decodeEnvelope(encoded, bindingDigest(normalized));
237
+ decoded.payload.fill(0);
238
+ return this.#presentStatus(normalized, decoded.header.revision, decoded.header.expiresAt ?? undefined, evidence.status === "preview" ? "preview" : "verified");
239
+ }
240
+ catch (error) {
241
+ if (error instanceof CredentialBoundaryError && error.code === "credential_corrupt") {
242
+ return {
243
+ backendId: this.#backend.backendId,
244
+ backendStatus: evidence.status === "preview" ? "preview" : "verified",
245
+ state: "corrupt",
246
+ bindingDigest: bindingDigest(normalized),
247
+ };
248
+ }
249
+ throw error;
250
+ }
251
+ finally {
252
+ encoded.fill(0);
253
+ }
254
+ }
255
+ async #performRefresh(binding, target, refresher) {
256
+ await this.#requireBackend();
257
+ // A new refresh is a fresh durability observation. Any fence from an
258
+ // earlier refresh must not be reused if this invocation rejects, rotates,
259
+ // or encounters an uncertain backend outcome.
260
+ this.#observedRevisionFences.delete(target);
261
+ const currentEnvelope = await this.#readEnvelope(target, binding);
262
+ const currentSnapshot = currentEnvelope === undefined ? undefined : {
263
+ material: SecretMaterial.fromBytes(currentEnvelope.payload),
264
+ revision: currentEnvelope.header.revision,
265
+ expiresAt: currentEnvelope.header.expiresAt ?? undefined,
266
+ };
267
+ try {
268
+ let refreshed;
269
+ try {
270
+ refreshed = await refresher(currentSnapshot);
271
+ }
272
+ catch (cause) {
273
+ // The bare `catch` here is deliberate: the refresher is untrusted and
274
+ // its message may carry credential material, so the cause is NOT
275
+ // retained. But dropping everything made a transient outage and a
276
+ // revoked session print one identical sentence, with no flag able to
277
+ // tell them apart. Lift the error code alone, and only when its shape
278
+ // is a code rather than a secret.
279
+ throw credentialFailure("credential_refresh_failed", "Credential refresh failed without changing the stored credential.", { retryable: true, ...refreshFailureDetails(cause) });
280
+ }
281
+ if (refreshed.status === "missing") {
282
+ if (currentEnvelope !== undefined) {
283
+ throw credentialFailure("credential_refresh_failed", "Credential refresh reported an absent credential after reading one.");
284
+ }
285
+ throw credentialFailure("credential_missing", "Credential refresh requires a stored credential.");
286
+ }
287
+ if (refreshed.status === "rejected") {
288
+ if (currentEnvelope === undefined) {
289
+ throw credentialFailure("credential_refresh_failed", "Credential refresh rejected an absent credential.");
290
+ }
291
+ if (this.#backend.compareAndDelete === undefined) {
292
+ throw credentialFailure("credential_backend_unverified", "The secure credential store cannot safely reconcile a rejected session.");
293
+ }
294
+ let outcome;
295
+ try {
296
+ outcome = await this.#backend.compareAndDelete(target, currentEnvelope.storageSha256);
297
+ }
298
+ catch (cause) {
299
+ throw credentialFailure("credential_backend_failure", "The secure credential store could not reconcile a rejected session.", { retryable: true, cause });
300
+ }
301
+ if (outcome === "conflict") {
302
+ throw credentialFailure("credential_revision_conflict", "The credential changed while a rejected session was being reconciled.", { retryable: true });
303
+ }
304
+ if (outcome !== "deleted" && outcome !== "absent") {
305
+ throw credentialFailure("credential_backend_failure", "The secure credential store returned an invalid rejected-session reconciliation result.");
306
+ }
307
+ this.#revoked.add(target);
308
+ throw credentialFailure("credential_revoked", "The renewable credential was rejected and has been removed.", { safeDetails: { refreshRejection: refreshed.reason } });
309
+ }
310
+ if (refreshed.status === "retained") {
311
+ if (currentEnvelope === undefined) {
312
+ throw credentialFailure("credential_refresh_failed", "Credential refresh cannot retain an absent credential.");
313
+ }
314
+ // This is only an optimization token for a subsequent exact
315
+ // revision-fenced cleanup in this vault instance. It is not returned
316
+ // to callers and never bypasses the backend's physical CAS.
317
+ this.#observedRevisionFences.set(target, {
318
+ revision: currentEnvelope.header.revision,
319
+ storageSha256: currentEnvelope.storageSha256,
320
+ });
321
+ return {
322
+ bytes: currentEnvelope.payload.slice(),
323
+ revision: currentEnvelope.header.revision,
324
+ expiresAt: currentEnvelope.header.expiresAt ?? undefined,
325
+ };
326
+ }
327
+ const nextRevision = safeRevisionIncrement(currentEnvelope?.header.revision ?? 0);
328
+ let nextBytes;
329
+ let encoded;
330
+ let replaced = false;
331
+ try {
332
+ nextBytes = refreshed.material.copyBytes();
333
+ encoded = encodeEnvelope({
334
+ binding,
335
+ revision: nextRevision,
336
+ storedAt: this.#now(),
337
+ ...(refreshed.expiresAt !== undefined && { expiresAt: refreshed.expiresAt }),
338
+ payload: nextBytes,
339
+ });
340
+ await this.#replaceWithReconciliation(target, encoded, binding, currentEnvelope);
341
+ replaced = true;
342
+ }
343
+ finally {
344
+ encoded?.fill(0);
345
+ if (!replaced)
346
+ nextBytes?.fill(0);
347
+ refreshed.material.dispose();
348
+ }
349
+ if (nextBytes === undefined)
350
+ throw credentialFailure("credential_refresh_failed", "Credential refresh did not produce protected material.");
351
+ this.#revoked.delete(target);
352
+ return {
353
+ bytes: nextBytes,
354
+ revision: nextRevision,
355
+ expiresAt: refreshed.expiresAt,
356
+ };
357
+ }
358
+ finally {
359
+ currentSnapshot?.material.dispose();
360
+ currentEnvelope?.payload.fill(0);
361
+ }
362
+ }
363
+ async #readEnvelope(target, binding) {
364
+ const encoded = await this.#backend.read(target);
365
+ if (encoded === undefined)
366
+ return undefined;
367
+ try {
368
+ return decodeEnvelope(encoded, bindingDigest(binding));
369
+ }
370
+ finally {
371
+ encoded.fill(0);
372
+ }
373
+ }
374
+ async #requireBackend() {
375
+ const now = this.#now();
376
+ const cached = this.#backendEvidence;
377
+ if (cached !== undefined && validEvidence(cached, this.#backend, this.#platform, now, this.#allowPreviewBackend)) {
378
+ return cached;
379
+ }
380
+ let evidence;
381
+ try {
382
+ evidence = await this.#backend.probe();
383
+ }
384
+ catch (cause) {
385
+ throw credentialFailure("credential_backend_unavailable", "The secure credential store could not be verified.", { cause });
386
+ }
387
+ if (!validEvidence(evidence, this.#backend, this.#platform, this.#now(), this.#allowPreviewBackend)) {
388
+ throw credentialFailure(evidence.status === "unavailable" ? "credential_backend_unavailable" : "credential_backend_unverified", "The secure credential store lacks current platform-bound evidence.", {
389
+ safeDetails: {
390
+ backendId: this.#backend.backendId,
391
+ status: evidence.status,
392
+ // The backend states WHY it is unavailable and this frame used to
393
+ // drop it, so every cause printed the same unactionable sentence.
394
+ ...(evidence.reason === undefined ? {} : { reason: evidence.reason }),
395
+ },
396
+ });
397
+ }
398
+ this.#backendEvidence = evidence;
399
+ return evidence;
400
+ }
401
+ async #replaceWithReconciliation(target, encoded, binding, previous) {
402
+ try {
403
+ if (this.#backend.compareAndSwap !== undefined) {
404
+ const result = await this.#backend.compareAndSwap(target, previous?.storageSha256 ?? null, encoded);
405
+ if (result === "conflict") {
406
+ throw credentialFailure("credential_revision_conflict", "The credential changed before rotation could be applied.", { retryable: true });
407
+ }
408
+ }
409
+ else {
410
+ await this.#backend.replace(target, encoded);
411
+ }
412
+ return;
413
+ }
414
+ catch (error) {
415
+ if (error instanceof CredentialBoundaryError && error.code === "credential_revision_conflict")
416
+ throw error;
417
+ // A durable backend can commit and still lose its acknowledgement. Retrying
418
+ // an unknown replacement would rotate the same logical credential twice.
419
+ // Read back by stable target and adjudicate the effect before returning.
420
+ }
421
+ let observed;
422
+ try {
423
+ observed = await this.#backend.read(target);
424
+ if (observed !== undefined && bytesEqual(observed, encoded))
425
+ return;
426
+ if (observed === undefined && previous === undefined) {
427
+ throw credentialFailure("credential_backend_failure", "The secure credential replacement was not committed.", { retryable: true, safeDetails: { replacementOutcome: "not_committed" } });
428
+ }
429
+ if (observed !== undefined && previous !== undefined) {
430
+ let decoded;
431
+ try {
432
+ decoded = decodeEnvelope(observed, bindingDigest(binding));
433
+ if (sameEnvelope(decoded, previous)) {
434
+ throw credentialFailure("credential_backend_failure", "The secure credential replacement was not committed.", { retryable: true, safeDetails: { replacementOutcome: "not_committed" } });
435
+ }
436
+ }
437
+ catch (error) {
438
+ if (error instanceof CredentialBoundaryError && error.code === "credential_backend_failure")
439
+ throw error;
440
+ }
441
+ finally {
442
+ decoded?.payload.fill(0);
443
+ }
444
+ }
445
+ }
446
+ catch (error) {
447
+ if (error instanceof CredentialBoundaryError && error.code === "credential_backend_failure")
448
+ throw error;
449
+ }
450
+ finally {
451
+ observed?.fill(0);
452
+ }
453
+ throw credentialFailure("credential_backend_failure", "The secure credential replacement outcome is unknown and requires reconciliation.", { safeDetails: { replacementOutcome: "ambiguous" } });
454
+ }
455
+ async #exclusive(target, operation) {
456
+ const predecessor = this.#queues.get(target) ?? Promise.resolve();
457
+ let release = () => undefined;
458
+ const gate = new Promise((resolve) => { release = resolve; });
459
+ const queued = predecessor.catch(() => undefined).then(async () => gate);
460
+ this.#queues.set(target, queued);
461
+ await predecessor.catch(() => undefined);
462
+ try {
463
+ return await operation();
464
+ }
465
+ finally {
466
+ release();
467
+ if (this.#queues.get(target) === queued)
468
+ this.#queues.delete(target);
469
+ }
470
+ }
471
+ #presentStatus(binding, revision, expiresAt, backendStatus = this.#allowPreviewBackend ? "preview" : "verified") {
472
+ return {
473
+ backendId: this.#backend.backendId,
474
+ backendStatus,
475
+ state: expiresAt !== undefined && expiresAt <= this.#now() ? "expired" : "present",
476
+ bindingDigest: bindingDigest(binding),
477
+ revision,
478
+ ...(expiresAt !== undefined && { expiresAt }),
479
+ };
480
+ }
481
+ #unavailableStatus(binding) {
482
+ return {
483
+ backendId: this.#backend.backendId,
484
+ backendStatus: "unavailable",
485
+ state: "unavailable",
486
+ bindingDigest: bindingDigest(binding),
487
+ };
488
+ }
489
+ #now() {
490
+ const now = this.#clock();
491
+ if (!Number.isSafeInteger(now) || now < 0 || (this.#lastObservedNow !== undefined && now < this.#lastObservedNow)) {
492
+ throw credentialFailure("credential_backend_unverified", "The credential boundary clock is not trustworthy.", { safeDetails: { clockTrusted: false } });
493
+ }
494
+ this.#lastObservedNow = now;
495
+ return now;
496
+ }
497
+ }
498
+ /**
499
+ * The single mint for the credential namespace. Every target this product hands
500
+ * to its encrypted local store -- real or probe -- is produced here. Callers
501
+ * must not concatenate target strings: a target outside this grammar is not a
502
+ * credential target and must fail before it reaches storage.
503
+ */
504
+ export function credentialTarget(binding) {
505
+ return `cuna-cli:v1:${bindingDigest(normalizeBinding(binding))}`;
506
+ }
507
+ /**
508
+ * The reserved binding a backend liveness probe writes, reads back and deletes.
509
+ *
510
+ * The probe must be indistinguishable from a real target to an *acceptor* and
511
+ * distinguishable from a real credential to the *store*. Both hold because the
512
+ * target is a SHA-256 over the length-prefixed 4-tuple, which is injective: two
513
+ * targets are equal only if the tuples are equal or SHA-256 collides. The
514
+ * probe's `workspaceId` carries 256 bits of fresh CSPRNG entropy, so colliding
515
+ * with a genuine binding requires a caller to supply the exact nonce drawn
516
+ * microseconds earlier. The probe therefore cannot read, overwrite or delete a
517
+ * stored credential, and every probe uses a target no probe has used before.
518
+ */
519
+ const PROBE_BINDING_NAMESPACE = "cuna.credential-backend-probe.v1";
520
+ const PROBE_BINDING_KIND = "credential-backend-liveness-probe";
521
+ const PROBE_NONCE_BYTES = 32;
522
+ export function probeCredentialTarget(nonce = randomBytes(PROBE_NONCE_BYTES)) {
523
+ if (nonce.byteLength !== PROBE_NONCE_BYTES) {
524
+ throw credentialFailure("credential_binding_invalid", "A credential probe target is bound to exactly 256 bits of fresh entropy.");
525
+ }
526
+ return credentialTarget({
527
+ profileId: PROBE_BINDING_NAMESPACE,
528
+ accountId: PROBE_BINDING_NAMESPACE,
529
+ workspaceId: `${PROBE_BINDING_NAMESPACE}:${hexadecimal(nonce)}`,
530
+ kind: PROBE_BINDING_KIND,
531
+ });
532
+ }
533
+ /**
534
+ * A refresh failure carries the one fact a user needs — wait, or sign in again
535
+ * — in its error code. The message and the cause stay quarantined because the
536
+ * refresher is untrusted, so this lifts the code and nothing else, and only
537
+ * when it LOOKS like a code. The grammar is the control: a lowercase dotted
538
+ * identifier cannot express a high-entropy secret, so a leaked token fails the
539
+ * shape test rather than relying on the field's name. Returns an empty object
540
+ * so the caller can spread it under `exactOptionalPropertyTypes`.
541
+ */
542
+ const PUBLIC_ERROR_CODE = /^[a-z][a-z0-9_]*(?:\.[a-z0-9_]+)*$/u;
543
+ function refreshFailureDetails(cause) {
544
+ if (typeof cause !== "object" || cause === null)
545
+ return {};
546
+ const code = cause.code;
547
+ if (typeof code !== "string" || code.length > 64 || !PUBLIC_ERROR_CODE.test(code))
548
+ return {};
549
+ return { safeDetails: { reason: code } };
550
+ }
551
+ function hexadecimal(bytes) {
552
+ let result = "";
553
+ for (const byte of bytes)
554
+ result += byte.toString(16).padStart(2, "0");
555
+ return result;
556
+ }
557
+ export function bindingDigest(binding) {
558
+ const canonical = [binding.profileId, binding.accountId, binding.workspaceId, binding.kind]
559
+ .map((value) => `${new TextEncoder().encode(value).byteLength}:${value}`)
560
+ .join("|");
561
+ return createHash("sha256").update(canonical, "utf8").digest("hex");
562
+ }
563
+ function normalizeBinding(binding) {
564
+ return Object.freeze({
565
+ profileId: normalizeIdentifier("profile", binding.profileId, 256),
566
+ accountId: normalizeIdentifier("account", binding.accountId, 256),
567
+ workspaceId: normalizeIdentifier("workspace", binding.workspaceId, 256),
568
+ kind: normalizeIdentifier("kind", binding.kind, 64),
569
+ });
570
+ }
571
+ function normalizeIdentifier(label, value, maximumBytes) {
572
+ if (typeof value !== "string") {
573
+ throw credentialFailure("credential_binding_invalid", `The credential ${label} binding is invalid.`);
574
+ }
575
+ const normalized = value.normalize("NFC");
576
+ const bytes = new TextEncoder().encode(normalized).byteLength;
577
+ if (bytes < 1 || bytes > maximumBytes || hasForbiddenControl(normalized)) {
578
+ throw credentialFailure("credential_binding_invalid", `The credential ${label} binding is invalid.`);
579
+ }
580
+ return normalized;
581
+ }
582
+ function hasForbiddenControl(value) {
583
+ for (const character of value) {
584
+ const codePoint = character.codePointAt(0) ?? 0;
585
+ if (codePoint <= 0x1f || codePoint === 0x7f)
586
+ return true;
587
+ }
588
+ return false;
589
+ }
590
+ function encodeEnvelope(input) {
591
+ if (!Number.isSafeInteger(input.revision) || input.revision < 1) {
592
+ throw credentialFailure("credential_corrupt", "Credential revision is invalid.");
593
+ }
594
+ if (input.payload.byteLength < 1 || input.payload.byteLength > 32_768) {
595
+ throw credentialFailure("credential_corrupt", "Credential material has an invalid size.");
596
+ }
597
+ if (!Number.isSafeInteger(input.storedAt) ||
598
+ (input.expiresAt !== undefined && (!Number.isSafeInteger(input.expiresAt) || input.expiresAt <= input.storedAt))) {
599
+ throw credentialFailure("credential_corrupt", "Credential timestamps are invalid.");
600
+ }
601
+ const header = {
602
+ version: ENVELOPE_VERSION,
603
+ bindingDigest: bindingDigest(input.binding),
604
+ revision: input.revision,
605
+ storedAt: input.storedAt,
606
+ expiresAt: input.expiresAt ?? null,
607
+ payloadLength: input.payload.byteLength,
608
+ payloadSha256: createHash("sha256").update(input.payload).digest("hex"),
609
+ };
610
+ const headerBytes = new TextEncoder().encode(JSON.stringify(header));
611
+ if (headerBytes.byteLength > MAXIMUM_HEADER_BYTES) {
612
+ throw credentialFailure("credential_corrupt", "Credential metadata is oversized.");
613
+ }
614
+ const encoded = new Uint8Array(ENVELOPE_MAGIC.byteLength + 4 + headerBytes.byteLength + input.payload.byteLength);
615
+ encoded.set(ENVELOPE_MAGIC, 0);
616
+ new DataView(encoded.buffer).setUint32(ENVELOPE_MAGIC.byteLength, headerBytes.byteLength, false);
617
+ encoded.set(headerBytes, ENVELOPE_MAGIC.byteLength + 4);
618
+ encoded.set(input.payload, ENVELOPE_MAGIC.byteLength + 4 + headerBytes.byteLength);
619
+ return encoded;
620
+ }
621
+ function decodeEnvelope(encoded, expectedBindingDigest) {
622
+ if (encoded.byteLength < ENVELOPE_MAGIC.byteLength + 5 || encoded.byteLength > MAXIMUM_ENVELOPE_BYTES) {
623
+ throw credentialFailure("credential_corrupt", "The protected credential envelope is invalid.");
624
+ }
625
+ for (let index = 0; index < ENVELOPE_MAGIC.byteLength; index += 1) {
626
+ if (encoded[index] !== ENVELOPE_MAGIC[index]) {
627
+ throw credentialFailure("credential_corrupt", "The protected credential envelope is invalid.");
628
+ }
629
+ }
630
+ const headerLength = new DataView(encoded.buffer, encoded.byteOffset, encoded.byteLength)
631
+ .getUint32(ENVELOPE_MAGIC.byteLength, false);
632
+ if (headerLength < 2 || headerLength > MAXIMUM_HEADER_BYTES) {
633
+ throw credentialFailure("credential_corrupt", "The protected credential metadata is invalid.");
634
+ }
635
+ const payloadOffset = ENVELOPE_MAGIC.byteLength + 4 + headerLength;
636
+ if (payloadOffset >= encoded.byteLength) {
637
+ throw credentialFailure("credential_corrupt", "The protected credential payload is missing.");
638
+ }
639
+ let parsed;
640
+ try {
641
+ parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(encoded.slice(ENVELOPE_MAGIC.byteLength + 4, payloadOffset)));
642
+ }
643
+ catch (cause) {
644
+ throw credentialFailure("credential_corrupt", "The protected credential metadata is malformed.", { cause });
645
+ }
646
+ const header = parseHeader(parsed);
647
+ const payload = encoded.slice(payloadOffset);
648
+ const actualDigest = createHash("sha256").update(payload).digest();
649
+ const declaredDigest = Buffer.from(header.payloadSha256, "hex");
650
+ const bindingMatches = safeHexEqual(header.bindingDigest, expectedBindingDigest);
651
+ const payloadMatches = declaredDigest.byteLength === actualDigest.byteLength && timingSafeEqual(declaredDigest, actualDigest);
652
+ if (!bindingMatches || header.payloadLength !== payload.byteLength || !payloadMatches) {
653
+ payload.fill(0);
654
+ throw credentialFailure("credential_corrupt", "The protected credential failed binding or integrity validation.");
655
+ }
656
+ return { header, payload, storageSha256: createHash("sha256").update(encoded).digest("hex") };
657
+ }
658
+ function parseHeader(value) {
659
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
660
+ throw credentialFailure("credential_corrupt", "The protected credential metadata is invalid.");
661
+ }
662
+ const record = value;
663
+ const keys = Object.keys(record).sort();
664
+ const expectedKeys = ["bindingDigest", "expiresAt", "payloadLength", "payloadSha256", "revision", "storedAt", "version"];
665
+ if (keys.length !== expectedKeys.length || keys.some((key, index) => key !== expectedKeys[index])) {
666
+ throw credentialFailure("credential_corrupt", "The protected credential metadata shape is invalid.");
667
+ }
668
+ if (record.version !== ENVELOPE_VERSION ||
669
+ typeof record.bindingDigest !== "string" || !/^[a-f0-9]{64}$/u.test(record.bindingDigest) ||
670
+ !Number.isSafeInteger(record.revision) || record.revision < 1 ||
671
+ !Number.isSafeInteger(record.storedAt) || record.storedAt < 0 ||
672
+ !(record.expiresAt === null || (Number.isSafeInteger(record.expiresAt) && record.expiresAt > record.storedAt)) ||
673
+ !Number.isSafeInteger(record.payloadLength) || record.payloadLength < 1 || record.payloadLength > 32_768 ||
674
+ typeof record.payloadSha256 !== "string" || !/^[a-f0-9]{64}$/u.test(record.payloadSha256)) {
675
+ throw credentialFailure("credential_corrupt", "The protected credential metadata values are invalid.");
676
+ }
677
+ return record;
678
+ }
679
+ function safeHexEqual(left, right) {
680
+ if (!/^[a-f0-9]{64}$/u.test(left) || !/^[a-f0-9]{64}$/u.test(right))
681
+ return false;
682
+ return timingSafeEqual(Buffer.from(left, "hex"), Buffer.from(right, "hex"));
683
+ }
684
+ function bytesEqual(left, right) {
685
+ return left.byteLength === right.byteLength && timingSafeEqual(left, right);
686
+ }
687
+ function sameEnvelope(left, right) {
688
+ return left.header.version === right.header.version &&
689
+ left.header.bindingDigest === right.header.bindingDigest &&
690
+ left.header.revision === right.header.revision &&
691
+ left.header.storedAt === right.header.storedAt &&
692
+ left.header.expiresAt === right.header.expiresAt &&
693
+ left.header.payloadLength === right.header.payloadLength &&
694
+ left.header.payloadSha256 === right.header.payloadSha256 &&
695
+ bytesEqual(left.payload, right.payload);
696
+ }
697
+ function safeRevisionIncrement(revision) {
698
+ if (!Number.isSafeInteger(revision) || revision < 0 || revision >= Number.MAX_SAFE_INTEGER) {
699
+ throw credentialFailure("credential_corrupt", "Credential revision cannot be advanced safely.");
700
+ }
701
+ return revision + 1;
702
+ }
703
+ function validEvidence(evidence, backend, platform, now, allowPreviewBackend) {
704
+ const verifiedEvidence = evidence.status === "verified" &&
705
+ (evidence.source === "live_round_trip" || evidence.source === "encrypted_local_file");
706
+ const previewEvidence = allowPreviewBackend && evidence.status === "preview" &&
707
+ evidence.source === "local_file_preview" && evidence.reason === undefined;
708
+ return evidence.protocol === CREDENTIAL_BACKEND_PROTOCOL &&
709
+ (verifiedEvidence || previewEvidence) &&
710
+ evidence.backendId === backend.backendId &&
711
+ evidence.platform === backend.platform &&
712
+ evidence.platform === platform &&
713
+ Number.isSafeInteger(evidence.observedAt) &&
714
+ Number.isSafeInteger(evidence.expiresAt) &&
715
+ evidence.observedAt <= now &&
716
+ evidence.expiresAt > now &&
717
+ evidence.expiresAt - evidence.observedAt <= 5 * 60_000;
718
+ }
719
+ //# sourceMappingURL=vault.js.map