@indigoai-us/hq-cloud 6.18.44-alpha.48 → 6.18.44-alpha.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/active-company.test.d.ts +2 -0
- package/dist/active-company.test.d.ts.map +1 -0
- package/dist/active-company.test.js +149 -0
- package/dist/active-company.test.js.map +1 -0
- package/dist/agent-codex-instructions.test.d.ts +2 -0
- package/dist/agent-codex-instructions.test.d.ts.map +1 -0
- package/dist/agent-codex-instructions.test.js +276 -0
- package/dist/agent-codex-instructions.test.js.map +1 -0
- package/dist/backup-prune.test.d.ts +2 -0
- package/dist/backup-prune.test.d.ts.map +1 -0
- package/dist/backup-prune.test.js +154 -0
- package/dist/backup-prune.test.js.map +1 -0
- package/dist/bandwidth.test.d.ts +2 -0
- package/dist/bandwidth.test.d.ts.map +1 -0
- package/dist/bandwidth.test.js +342 -0
- package/dist/bandwidth.test.js.map +1 -0
- package/dist/best-effort-error.test.d.ts +2 -0
- package/dist/best-effort-error.test.d.ts.map +1 -0
- package/dist/best-effort-error.test.js +54 -0
- package/dist/best-effort-error.test.js.map +1 -0
- package/dist/bin/area-ledger-migration.test.d.ts +2 -0
- package/dist/bin/area-ledger-migration.test.d.ts.map +1 -0
- package/dist/bin/area-ledger-migration.test.js +410 -0
- package/dist/bin/area-ledger-migration.test.js.map +1 -0
- package/dist/bin/backup-prune-runner.test.d.ts +2 -0
- package/dist/bin/backup-prune-runner.test.d.ts.map +1 -0
- package/dist/bin/backup-prune-runner.test.js +22 -0
- package/dist/bin/backup-prune-runner.test.js.map +1 -0
- package/dist/bin/journal-repair.test.d.ts +2 -0
- package/dist/bin/journal-repair.test.d.ts.map +1 -0
- package/dist/bin/journal-repair.test.js +53 -0
- package/dist/bin/journal-repair.test.js.map +1 -0
- package/dist/bin/layout-compatibility.test.d.ts +2 -0
- package/dist/bin/layout-compatibility.test.d.ts.map +1 -0
- package/dist/bin/layout-compatibility.test.js +87 -0
- package/dist/bin/layout-compatibility.test.js.map +1 -0
- package/dist/bin/outpost-heartbeat.test.d.ts +7 -0
- package/dist/bin/outpost-heartbeat.test.d.ts.map +1 -0
- package/dist/bin/outpost-heartbeat.test.js +84 -0
- package/dist/bin/outpost-heartbeat.test.js.map +1 -0
- package/dist/bin/outpost-session-host.test.d.ts +7 -0
- package/dist/bin/outpost-session-host.test.d.ts.map +1 -0
- package/dist/bin/outpost-session-host.test.js +52 -0
- package/dist/bin/outpost-session-host.test.js.map +1 -0
- package/dist/bin/sync-mutation.test.d.ts +2 -0
- package/dist/bin/sync-mutation.test.d.ts.map +1 -0
- package/dist/bin/sync-mutation.test.js +64 -0
- package/dist/bin/sync-mutation.test.js.map +1 -0
- package/dist/bin/sync-runner-args.test.d.ts +2 -0
- package/dist/bin/sync-runner-args.test.d.ts.map +1 -0
- package/dist/bin/sync-runner-args.test.js +82 -0
- package/dist/bin/sync-runner-args.test.js.map +1 -0
- package/dist/bin/sync-runner-auth-wait.test.d.ts +2 -0
- package/dist/bin/sync-runner-auth-wait.test.d.ts.map +1 -0
- package/dist/bin/sync-runner-auth-wait.test.js +406 -0
- package/dist/bin/sync-runner-auth-wait.test.js.map +1 -0
- package/dist/bin/sync-runner-backoff.regression.test.d.ts +29 -0
- package/dist/bin/sync-runner-backoff.regression.test.d.ts.map +1 -0
- package/dist/bin/sync-runner-backoff.regression.test.js +224 -0
- package/dist/bin/sync-runner-backoff.regression.test.js.map +1 -0
- package/dist/bin/sync-runner-company.test.d.ts +2 -0
- package/dist/bin/sync-runner-company.test.d.ts.map +1 -0
- package/dist/bin/sync-runner-company.test.js +2439 -0
- package/dist/bin/sync-runner-company.test.js.map +1 -0
- package/dist/bin/sync-runner-delete-snapshot-mixed.bench.test.d.ts +2 -0
- package/dist/bin/sync-runner-delete-snapshot-mixed.bench.test.d.ts.map +1 -0
- package/dist/bin/sync-runner-delete-snapshot-mixed.bench.test.js +648 -0
- package/dist/bin/sync-runner-delete-snapshot-mixed.bench.test.js.map +1 -0
- package/dist/bin/sync-runner-delete-snapshot.bench.test.d.ts +2 -0
- package/dist/bin/sync-runner-delete-snapshot.bench.test.d.ts.map +1 -0
- package/dist/bin/sync-runner-delete-snapshot.bench.test.js +329 -0
- package/dist/bin/sync-runner-delete-snapshot.bench.test.js.map +1 -0
- package/dist/bin/sync-runner-events.test.d.ts +2 -0
- package/dist/bin/sync-runner-events.test.d.ts.map +1 -0
- package/dist/bin/sync-runner-events.test.js +364 -0
- package/dist/bin/sync-runner-events.test.js.map +1 -0
- package/dist/bin/sync-runner-heap-telemetry.test.d.ts +2 -0
- package/dist/bin/sync-runner-heap-telemetry.test.d.ts.map +1 -0
- package/dist/bin/sync-runner-heap-telemetry.test.js +1966 -0
- package/dist/bin/sync-runner-heap-telemetry.test.js.map +1 -0
- package/dist/bin/sync-runner-manifest.test.d.ts +12 -0
- package/dist/bin/sync-runner-manifest.test.d.ts.map +1 -0
- package/dist/bin/sync-runner-manifest.test.js +921 -0
- package/dist/bin/sync-runner-manifest.test.js.map +1 -0
- package/dist/bin/sync-runner-planning.test.d.ts +2 -0
- package/dist/bin/sync-runner-planning.test.d.ts.map +1 -0
- package/dist/bin/sync-runner-planning.test.js +448 -0
- package/dist/bin/sync-runner-planning.test.js.map +1 -0
- package/dist/bin/sync-runner-post-sync-flags.test.d.ts +2 -0
- package/dist/bin/sync-runner-post-sync-flags.test.d.ts.map +1 -0
- package/dist/bin/sync-runner-post-sync-flags.test.js +64 -0
- package/dist/bin/sync-runner-post-sync-flags.test.js.map +1 -0
- package/dist/bin/sync-runner-publish-expansion.test.d.ts +2 -0
- package/dist/bin/sync-runner-publish-expansion.test.d.ts.map +1 -0
- package/dist/bin/sync-runner-publish-expansion.test.js +54 -0
- package/dist/bin/sync-runner-publish-expansion.test.js.map +1 -0
- package/dist/bin/sync-runner-receiver-unresolved-company.test.d.ts +2 -0
- package/dist/bin/sync-runner-receiver-unresolved-company.test.d.ts.map +1 -0
- package/dist/bin/sync-runner-receiver-unresolved-company.test.js +379 -0
- package/dist/bin/sync-runner-receiver-unresolved-company.test.js.map +1 -0
- package/dist/bin/sync-runner-rollup.test.d.ts +2 -0
- package/dist/bin/sync-runner-rollup.test.d.ts.map +1 -0
- package/dist/bin/sync-runner-rollup.test.js +24 -0
- package/dist/bin/sync-runner-rollup.test.js.map +1 -0
- package/dist/bin/sync-runner-watch-loop.test.d.ts +2 -0
- package/dist/bin/sync-runner-watch-loop.test.d.ts.map +1 -0
- package/dist/bin/sync-runner-watch-loop.test.js +735 -0
- package/dist/bin/sync-runner-watch-loop.test.js.map +1 -0
- package/dist/bin/sync-runner-watch-routes.test.d.ts +2 -0
- package/dist/bin/sync-runner-watch-routes.test.d.ts.map +1 -0
- package/dist/bin/sync-runner-watch-routes.test.js +181 -0
- package/dist/bin/sync-runner-watch-routes.test.js.map +1 -0
- package/dist/bin/sync-runner.test.d.ts +10 -0
- package/dist/bin/sync-runner.test.d.ts.map +1 -0
- package/dist/bin/sync-runner.test.js +19084 -0
- package/dist/bin/sync-runner.test.js.map +1 -0
- package/dist/cli/case-alias.test.d.ts +2 -0
- package/dist/cli/case-alias.test.d.ts.map +1 -0
- package/dist/cli/case-alias.test.js +96 -0
- package/dist/cli/case-alias.test.js.map +1 -0
- package/dist/cli/conflict-recovery.test.d.ts +2 -0
- package/dist/cli/conflict-recovery.test.d.ts.map +1 -0
- package/dist/cli/conflict-recovery.test.js +207 -0
- package/dist/cli/conflict-recovery.test.js.map +1 -0
- package/dist/cli/conflict-winner.test.d.ts +7 -0
- package/dist/cli/conflict-winner.test.d.ts.map +1 -0
- package/dist/cli/conflict-winner.test.js +98 -0
- package/dist/cli/conflict-winner.test.js.map +1 -0
- package/dist/cli/doctor.test.d.ts +13 -0
- package/dist/cli/doctor.test.d.ts.map +1 -0
- package/dist/cli/doctor.test.js +607 -0
- package/dist/cli/doctor.test.js.map +1 -0
- package/dist/cli/invite.test.d.ts +5 -0
- package/dist/cli/invite.test.d.ts.map +1 -0
- package/dist/cli/invite.test.js +178 -0
- package/dist/cli/invite.test.js.map +1 -0
- package/dist/cli/onepass-pull-planner-regressions.test.d.ts +2 -0
- package/dist/cli/onepass-pull-planner-regressions.test.d.ts.map +1 -0
- package/dist/cli/onepass-pull-planner-regressions.test.js +300 -0
- package/dist/cli/onepass-pull-planner-regressions.test.js.map +1 -0
- package/dist/cli/onepass-pull-planner.test.d.ts +2 -0
- package/dist/cli/onepass-pull-planner.test.d.ts.map +1 -0
- package/dist/cli/onepass-pull-planner.test.js +266 -0
- package/dist/cli/onepass-pull-planner.test.js.map +1 -0
- package/dist/cli/push-scan-exclusions.test.d.ts +2 -0
- package/dist/cli/push-scan-exclusions.test.d.ts.map +1 -0
- package/dist/cli/push-scan-exclusions.test.js +99 -0
- package/dist/cli/push-scan-exclusions.test.js.map +1 -0
- package/dist/cli/reindex-knowledge.test.d.ts +12 -0
- package/dist/cli/reindex-knowledge.test.d.ts.map +1 -0
- package/dist/cli/reindex-knowledge.test.js +318 -0
- package/dist/cli/reindex-knowledge.test.js.map +1 -0
- package/dist/cli/reindex.test.d.ts +11 -0
- package/dist/cli/reindex.test.d.ts.map +1 -0
- package/dist/cli/reindex.test.js +860 -0
- package/dist/cli/reindex.test.js.map +1 -0
- package/dist/cli/rescue-breaker.test.d.ts +2 -0
- package/dist/cli/rescue-breaker.test.d.ts.map +1 -0
- package/dist/cli/rescue-breaker.test.js +812 -0
- package/dist/cli/rescue-breaker.test.js.map +1 -0
- package/dist/cli/rescue-classify-ordering.test.d.ts +2 -0
- package/dist/cli/rescue-classify-ordering.test.d.ts.map +1 -0
- package/dist/cli/rescue-classify-ordering.test.js +500 -0
- package/dist/cli/rescue-classify-ordering.test.js.map +1 -0
- package/dist/cli/rescue-clone-diagnostics.test.d.ts +2 -0
- package/dist/cli/rescue-clone-diagnostics.test.d.ts.map +1 -0
- package/dist/cli/rescue-clone-diagnostics.test.js +101 -0
- package/dist/cli/rescue-clone-diagnostics.test.js.map +1 -0
- package/dist/cli/rescue-clone-network-retry.test.d.ts +2 -0
- package/dist/cli/rescue-clone-network-retry.test.d.ts.map +1 -0
- package/dist/cli/rescue-clone-network-retry.test.js +415 -0
- package/dist/cli/rescue-clone-network-retry.test.js.map +1 -0
- package/dist/cli/rescue-core-stamp.test.d.ts +2 -0
- package/dist/cli/rescue-core-stamp.test.d.ts.map +1 -0
- package/dist/cli/rescue-core-stamp.test.js +364 -0
- package/dist/cli/rescue-core-stamp.test.js.map +1 -0
- package/dist/cli/rescue-drift-reconcile.test.d.ts +2 -0
- package/dist/cli/rescue-drift-reconcile.test.d.ts.map +1 -0
- package/dist/cli/rescue-drift-reconcile.test.js +162 -0
- package/dist/cli/rescue-drift-reconcile.test.js.map +1 -0
- package/dist/cli/rescue-drop-dir-symlink.test.d.ts +2 -0
- package/dist/cli/rescue-drop-dir-symlink.test.d.ts.map +1 -0
- package/dist/cli/rescue-drop-dir-symlink.test.js +255 -0
- package/dist/cli/rescue-drop-dir-symlink.test.js.map +1 -0
- package/dist/cli/rescue-exec-bit-preserve.test.d.ts +2 -0
- package/dist/cli/rescue-exec-bit-preserve.test.d.ts.map +1 -0
- package/dist/cli/rescue-exec-bit-preserve.test.js +177 -0
- package/dist/cli/rescue-exec-bit-preserve.test.js.map +1 -0
- package/dist/cli/rescue-hq-root-guard.test.d.ts +2 -0
- package/dist/cli/rescue-hq-root-guard.test.d.ts.map +1 -0
- package/dist/cli/rescue-hq-root-guard.test.js +210 -0
- package/dist/cli/rescue-hq-root-guard.test.js.map +1 -0
- package/dist/cli/rescue-journal-reconcile.test.d.ts +2 -0
- package/dist/cli/rescue-journal-reconcile.test.d.ts.map +1 -0
- package/dist/cli/rescue-journal-reconcile.test.js +186 -0
- package/dist/cli/rescue-journal-reconcile.test.js.map +1 -0
- package/dist/cli/rescue-keep-local-ignore.test.d.ts +2 -0
- package/dist/cli/rescue-keep-local-ignore.test.d.ts.map +1 -0
- package/dist/cli/rescue-keep-local-ignore.test.js +315 -0
- package/dist/cli/rescue-keep-local-ignore.test.js.map +1 -0
- package/dist/cli/rescue-move.test.d.ts +2 -0
- package/dist/cli/rescue-move.test.d.ts.map +1 -0
- package/dist/cli/rescue-move.test.js +166 -0
- package/dist/cli/rescue-move.test.js.map +1 -0
- package/dist/cli/rescue-mtime-preserve.test.d.ts +2 -0
- package/dist/cli/rescue-mtime-preserve.test.d.ts.map +1 -0
- package/dist/cli/rescue-mtime-preserve.test.js +186 -0
- package/dist/cli/rescue-mtime-preserve.test.js.map +1 -0
- package/dist/cli/rescue-preserve-copy-symlink.test.d.ts +2 -0
- package/dist/cli/rescue-preserve-copy-symlink.test.d.ts.map +1 -0
- package/dist/cli/rescue-preserve-copy-symlink.test.js +483 -0
- package/dist/cli/rescue-preserve-copy-symlink.test.js.map +1 -0
- package/dist/cli/rescue-realpath.test.d.ts +2 -0
- package/dist/cli/rescue-realpath.test.d.ts.map +1 -0
- package/dist/cli/rescue-realpath.test.js +109 -0
- package/dist/cli/rescue-realpath.test.js.map +1 -0
- package/dist/cli/rescue-restore-flag.test.d.ts +2 -0
- package/dist/cli/rescue-restore-flag.test.d.ts.map +1 -0
- package/dist/cli/rescue-restore-flag.test.js +82 -0
- package/dist/cli/rescue-restore-flag.test.js.map +1 -0
- package/dist/cli/rescue-rsync-preflight.test.d.ts +2 -0
- package/dist/cli/rescue-rsync-preflight.test.d.ts.map +1 -0
- package/dist/cli/rescue-rsync-preflight.test.js +579 -0
- package/dist/cli/rescue-rsync-preflight.test.js.map +1 -0
- package/dist/cli/rescue-rsync-status.test.d.ts +2 -0
- package/dist/cli/rescue-rsync-status.test.d.ts.map +1 -0
- package/dist/cli/rescue-rsync-status.test.js +406 -0
- package/dist/cli/rescue-rsync-status.test.js.map +1 -0
- package/dist/cli/rescue-settings-reconcile.test.d.ts +2 -0
- package/dist/cli/rescue-settings-reconcile.test.d.ts.map +1 -0
- package/dist/cli/rescue-settings-reconcile.test.js +610 -0
- package/dist/cli/rescue-settings-reconcile.test.js.map +1 -0
- package/dist/cli/rescue-snapshot-copy.test.d.ts +2 -0
- package/dist/cli/rescue-snapshot-copy.test.d.ts.map +1 -0
- package/dist/cli/rescue-snapshot-copy.test.js +790 -0
- package/dist/cli/rescue-snapshot-copy.test.js.map +1 -0
- package/dist/cli/rescue-snapshot-recovery.test.d.ts +2 -0
- package/dist/cli/rescue-snapshot-recovery.test.d.ts.map +1 -0
- package/dist/cli/rescue-snapshot-recovery.test.js +265 -0
- package/dist/cli/rescue-snapshot-recovery.test.js.map +1 -0
- package/dist/cli/rescue-snapshot.test.d.ts +2 -0
- package/dist/cli/rescue-snapshot.test.d.ts.map +1 -0
- package/dist/cli/rescue-snapshot.test.js +46 -0
- package/dist/cli/rescue-snapshot.test.js.map +1 -0
- package/dist/cli/rescue-source-switch-floor.test.d.ts +2 -0
- package/dist/cli/rescue-source-switch-floor.test.d.ts.map +1 -0
- package/dist/cli/rescue-source-switch-floor.test.js +247 -0
- package/dist/cli/rescue-source-switch-floor.test.js.map +1 -0
- package/dist/cli/rescue-unchanged-delete.test.d.ts +2 -0
- package/dist/cli/rescue-unchanged-delete.test.d.ts.map +1 -0
- package/dist/cli/rescue-unchanged-delete.test.js +305 -0
- package/dist/cli/rescue-unchanged-delete.test.js.map +1 -0
- package/dist/cli/rescue.reindex.test.d.ts +2 -0
- package/dist/cli/rescue.reindex.test.d.ts.map +1 -0
- package/dist/cli/rescue.reindex.test.js +72 -0
- package/dist/cli/rescue.reindex.test.js.map +1 -0
- package/dist/cli/rescue.test.d.ts +2 -0
- package/dist/cli/rescue.test.d.ts.map +1 -0
- package/dist/cli/rescue.test.js +127 -0
- package/dist/cli/rescue.test.js.map +1 -0
- package/dist/cli/share-plan-limit-presign.test.d.ts +2 -0
- package/dist/cli/share-plan-limit-presign.test.d.ts.map +1 -0
- package/dist/cli/share-plan-limit-presign.test.js +271 -0
- package/dist/cli/share-plan-limit-presign.test.js.map +1 -0
- package/dist/cli/share-presign-transport.test.d.ts +22 -0
- package/dist/cli/share-presign-transport.test.d.ts.map +1 -0
- package/dist/cli/share-presign-transport.test.js +388 -0
- package/dist/cli/share-presign-transport.test.js.map +1 -0
- package/dist/cli/share.test.d.ts +5 -0
- package/dist/cli/share.test.d.ts.map +1 -0
- package/dist/cli/share.test.js +12336 -0
- package/dist/cli/share.test.js.map +1 -0
- package/dist/cli/streaming-pull-planner.bench.test.d.ts +15 -0
- package/dist/cli/streaming-pull-planner.bench.test.d.ts.map +1 -0
- package/dist/cli/streaming-pull-planner.bench.test.js +273 -0
- package/dist/cli/streaming-pull-planner.bench.test.js.map +1 -0
- package/dist/cli/sync-scope.test.d.ts +22 -0
- package/dist/cli/sync-scope.test.d.ts.map +1 -0
- package/dist/cli/sync-scope.test.js +903 -0
- package/dist/cli/sync-scope.test.js.map +1 -0
- package/dist/cli/sync.test.d.ts +5 -0
- package/dist/cli/sync.test.d.ts.map +1 -0
- package/dist/cli/sync.test.js +9028 -0
- package/dist/cli/sync.test.js.map +1 -0
- package/dist/cli/tombstones.test.d.ts +2 -0
- package/dist/cli/tombstones.test.d.ts.map +1 -0
- package/dist/cli/tombstones.test.js +120 -0
- package/dist/cli/tombstones.test.js.map +1 -0
- package/dist/cli/watch-event-push-conflict.test.d.ts +25 -0
- package/dist/cli/watch-event-push-conflict.test.d.ts.map +1 -0
- package/dist/cli/watch-event-push-conflict.test.js +230 -0
- package/dist/cli/watch-event-push-conflict.test.js.map +1 -0
- package/dist/client-info.test.d.ts +11 -0
- package/dist/client-info.test.d.ts.map +1 -0
- package/dist/client-info.test.js +168 -0
- package/dist/client-info.test.js.map +1 -0
- package/dist/cognito-auth-lock-no-hard-links.test.d.ts +11 -0
- package/dist/cognito-auth-lock-no-hard-links.test.d.ts.map +1 -0
- package/dist/cognito-auth-lock-no-hard-links.test.js +76 -0
- package/dist/cognito-auth-lock-no-hard-links.test.js.map +1 -0
- package/dist/cognito-auth.test.d.ts +9 -0
- package/dist/cognito-auth.test.d.ts.map +1 -0
- package/dist/cognito-auth.test.js +745 -0
- package/dist/cognito-auth.test.js.map +1 -0
- package/dist/company-resolver.test.d.ts +7 -0
- package/dist/company-resolver.test.d.ts.map +1 -0
- package/dist/company-resolver.test.js +535 -0
- package/dist/company-resolver.test.js.map +1 -0
- package/dist/company-slug.test.d.ts +7 -0
- package/dist/company-slug.test.d.ts.map +1 -0
- package/dist/company-slug.test.js +43 -0
- package/dist/company-slug.test.js.map +1 -0
- package/dist/company-vault-transport.test.d.ts +12 -0
- package/dist/company-vault-transport.test.d.ts.map +1 -0
- package/dist/company-vault-transport.test.js +97 -0
- package/dist/company-vault-transport.test.js.map +1 -0
- package/dist/context.test.d.ts +7 -0
- package/dist/context.test.d.ts.map +1 -0
- package/dist/context.test.js +646 -0
- package/dist/context.test.js.map +1 -0
- package/dist/entity-resolver.test.d.ts +10 -0
- package/dist/entity-resolver.test.d.ts.map +1 -0
- package/dist/entity-resolver.test.js +244 -0
- package/dist/entity-resolver.test.js.map +1 -0
- package/dist/getindigo-dead-refs-contract.test.d.ts +2 -0
- package/dist/getindigo-dead-refs-contract.test.d.ts.map +1 -0
- package/dist/getindigo-dead-refs-contract.test.js +58 -0
- package/dist/getindigo-dead-refs-contract.test.js.map +1 -0
- package/dist/hermetic-test-env.test.d.ts +2 -0
- package/dist/hermetic-test-env.test.d.ts.map +1 -0
- package/dist/hermetic-test-env.test.js +61 -0
- package/dist/hermetic-test-env.test.js.map +1 -0
- package/dist/hq-root-recovery.test.d.ts +2 -0
- package/dist/hq-root-recovery.test.d.ts.map +1 -0
- package/dist/hq-root-recovery.test.js +65 -0
- package/dist/hq-root-recovery.test.js.map +1 -0
- package/dist/ignore.test.d.ts +10 -0
- package/dist/ignore.test.d.ts.map +1 -0
- package/dist/ignore.test.js +958 -0
- package/dist/ignore.test.js.map +1 -0
- package/dist/index.test.d.ts +2 -0
- package/dist/index.test.d.ts.map +1 -0
- package/dist/index.test.js +26 -0
- package/dist/index.test.js.map +1 -0
- package/dist/journal-area-ledger-read-boundary.test.d.ts +2 -0
- package/dist/journal-area-ledger-read-boundary.test.d.ts.map +1 -0
- package/dist/journal-area-ledger-read-boundary.test.js +425 -0
- package/dist/journal-area-ledger-read-boundary.test.js.map +1 -0
- package/dist/journal-baseline.test.d.ts +2 -0
- package/dist/journal-baseline.test.d.ts.map +1 -0
- package/dist/journal-baseline.test.js +218 -0
- package/dist/journal-baseline.test.js.map +1 -0
- package/dist/journal-decode-window.test.d.ts +2 -0
- package/dist/journal-decode-window.test.d.ts.map +1 -0
- package/dist/journal-decode-window.test.js +99 -0
- package/dist/journal-decode-window.test.js.map +1 -0
- package/dist/journal-delta-writes.test.d.ts +2 -0
- package/dist/journal-delta-writes.test.d.ts.map +1 -0
- package/dist/journal-delta-writes.test.js +159 -0
- package/dist/journal-delta-writes.test.js.map +1 -0
- package/dist/journal-ledger-index.test.d.ts +15 -0
- package/dist/journal-ledger-index.test.d.ts.map +1 -0
- package/dist/journal-ledger-index.test.js +269 -0
- package/dist/journal-ledger-index.test.js.map +1 -0
- package/dist/journal-public-boundary.test.d.ts +2 -0
- package/dist/journal-public-boundary.test.d.ts.map +1 -0
- package/dist/journal-public-boundary.test.js +216 -0
- package/dist/journal-public-boundary.test.js.map +1 -0
- package/dist/journal-row-store.test.d.ts +2 -0
- package/dist/journal-row-store.test.d.ts.map +1 -0
- package/dist/journal-row-store.test.js +729 -0
- package/dist/journal-row-store.test.js.map +1 -0
- package/dist/journal-snapshot-memory-helpers.d.ts +35 -0
- package/dist/journal-snapshot-memory-helpers.d.ts.map +1 -0
- package/dist/journal-snapshot-memory-helpers.js +298 -0
- package/dist/journal-snapshot-memory-helpers.js.map +1 -0
- package/dist/journal-snapshot-memory.test.d.ts +2 -0
- package/dist/journal-snapshot-memory.test.d.ts.map +1 -0
- package/dist/journal-snapshot-memory.test.js +55 -0
- package/dist/journal-snapshot-memory.test.js.map +1 -0
- package/dist/journal-snapshot-v4-memory.test.d.ts +2 -0
- package/dist/journal-snapshot-v4-memory.test.d.ts.map +1 -0
- package/dist/journal-snapshot-v4-memory.test.js +24 -0
- package/dist/journal-snapshot-v4-memory.test.js.map +1 -0
- package/dist/journal-snapshot-v4-writer-memory.test.d.ts +2 -0
- package/dist/journal-snapshot-v4-writer-memory.test.d.ts.map +1 -0
- package/dist/journal-snapshot-v4-writer-memory.test.js +76 -0
- package/dist/journal-snapshot-v4-writer-memory.test.js.map +1 -0
- package/dist/journal-snapshot-v4-writer.test.d.ts +2 -0
- package/dist/journal-snapshot-v4-writer.test.d.ts.map +1 -0
- package/dist/journal-snapshot-v4-writer.test.js +282 -0
- package/dist/journal-snapshot-v4-writer.test.js.map +1 -0
- package/dist/journal-snapshot-v4.test.d.ts +2 -0
- package/dist/journal-snapshot-v4.test.d.ts.map +1 -0
- package/dist/journal-snapshot-v4.test.js +281 -0
- package/dist/journal-snapshot-v4.test.js.map +1 -0
- package/dist/journal-store.test.d.ts +2 -0
- package/dist/journal-store.test.d.ts.map +1 -0
- package/dist/journal-store.test.js +1227 -0
- package/dist/journal-store.test.js.map +1 -0
- package/dist/journal-streaming.heap.test.d.ts +2 -0
- package/dist/journal-streaming.heap.test.d.ts.map +1 -0
- package/dist/journal-streaming.heap.test.js +190 -0
- package/dist/journal-streaming.heap.test.js.map +1 -0
- package/dist/journal.test.d.ts +9 -0
- package/dist/journal.test.d.ts.map +1 -0
- package/dist/journal.test.js +1074 -0
- package/dist/journal.test.js.map +1 -0
- package/dist/kms10-etag-safe-pull.test.d.ts +2 -0
- package/dist/kms10-etag-safe-pull.test.d.ts.map +1 -0
- package/dist/kms10-etag-safe-pull.test.js +53 -0
- package/dist/kms10-etag-safe-pull.test.js.map +1 -0
- package/dist/lib/cloud-authoritative.test.d.ts +2 -0
- package/dist/lib/cloud-authoritative.test.d.ts.map +1 -0
- package/dist/lib/cloud-authoritative.test.js +42 -0
- package/dist/lib/cloud-authoritative.test.js.map +1 -0
- package/dist/lib/conflict-reconcile.test.d.ts +7 -0
- package/dist/lib/conflict-reconcile.test.d.ts.map +1 -0
- package/dist/lib/conflict-reconcile.test.js +246 -0
- package/dist/lib/conflict-reconcile.test.js.map +1 -0
- package/dist/lib/conflict.test.d.ts +9 -0
- package/dist/lib/conflict.test.d.ts.map +1 -0
- package/dist/lib/conflict.test.js +340 -0
- package/dist/lib/conflict.test.js.map +1 -0
- package/dist/lib/describe-error.test.d.ts +2 -0
- package/dist/lib/describe-error.test.d.ts.map +1 -0
- package/dist/lib/describe-error.test.js +148 -0
- package/dist/lib/describe-error.test.js.map +1 -0
- package/dist/lib/machine-id.test.d.ts +8 -0
- package/dist/lib/machine-id.test.d.ts.map +1 -0
- package/dist/lib/machine-id.test.js +228 -0
- package/dist/lib/machine-id.test.js.map +1 -0
- package/dist/lib/net-errors.test.d.ts +2 -0
- package/dist/lib/net-errors.test.d.ts.map +1 -0
- package/dist/lib/net-errors.test.js +111 -0
- package/dist/lib/net-errors.test.js.map +1 -0
- package/dist/lib/ontology-entity-meta.test.d.ts +2 -0
- package/dist/lib/ontology-entity-meta.test.d.ts.map +1 -0
- package/dist/lib/ontology-entity-meta.test.js +79 -0
- package/dist/lib/ontology-entity-meta.test.js.map +1 -0
- package/dist/lib/ontology-entity-push.test.d.ts +2 -0
- package/dist/lib/ontology-entity-push.test.d.ts.map +1 -0
- package/dist/lib/ontology-entity-push.test.js +156 -0
- package/dist/lib/ontology-entity-push.test.js.map +1 -0
- package/dist/lib/personal-connector-settings-sync.test.d.ts +2 -0
- package/dist/lib/personal-connector-settings-sync.test.d.ts.map +1 -0
- package/dist/lib/personal-connector-settings-sync.test.js +34 -0
- package/dist/lib/personal-connector-settings-sync.test.js.map +1 -0
- package/dist/lib/readlink-safe.test.d.ts +2 -0
- package/dist/lib/readlink-safe.test.d.ts.map +1 -0
- package/dist/lib/readlink-safe.test.js +34 -0
- package/dist/lib/readlink-safe.test.js.map +1 -0
- package/dist/lib/s3-content-checksum.test.d.ts +2 -0
- package/dist/lib/s3-content-checksum.test.d.ts.map +1 -0
- package/dist/lib/s3-content-checksum.test.js +26 -0
- package/dist/lib/s3-content-checksum.test.js.map +1 -0
- package/dist/lib/skill-register-landed-bytes.test.d.ts +2 -0
- package/dist/lib/skill-register-landed-bytes.test.d.ts.map +1 -0
- package/dist/lib/skill-register-landed-bytes.test.js +83 -0
- package/dist/lib/skill-register-landed-bytes.test.js.map +1 -0
- package/dist/local-path-codec.test.d.ts +14 -0
- package/dist/local-path-codec.test.d.ts.map +1 -0
- package/dist/local-path-codec.test.js +122 -0
- package/dist/local-path-codec.test.js.map +1 -0
- package/dist/machine-auth.test.d.ts +14 -0
- package/dist/machine-auth.test.d.ts.map +1 -0
- package/dist/machine-auth.test.js +1492 -0
- package/dist/machine-auth.test.js.map +1 -0
- package/dist/machine-token-cache-isolation.test.d.ts +24 -0
- package/dist/machine-token-cache-isolation.test.d.ts.map +1 -0
- package/dist/machine-token-cache-isolation.test.js +284 -0
- package/dist/machine-token-cache-isolation.test.js.map +1 -0
- package/dist/manifest/US-002.acceptance.test.d.ts +11 -0
- package/dist/manifest/US-002.acceptance.test.d.ts.map +1 -0
- package/dist/manifest/US-002.acceptance.test.js +160 -0
- package/dist/manifest/US-002.acceptance.test.js.map +1 -0
- package/dist/manifest/US-004.acceptance.test.d.ts +12 -0
- package/dist/manifest/US-004.acceptance.test.d.ts.map +1 -0
- package/dist/manifest/US-004.acceptance.test.js +173 -0
- package/dist/manifest/US-004.acceptance.test.js.map +1 -0
- package/dist/manifest/bench-gate.d.ts +30 -0
- package/dist/manifest/bench-gate.d.ts.map +1 -0
- package/dist/manifest/bench-gate.js +47 -0
- package/dist/manifest/bench-gate.js.map +1 -0
- package/dist/manifest/bench-gate.test.d.ts +2 -0
- package/dist/manifest/bench-gate.test.d.ts.map +1 -0
- package/dist/manifest/bench-gate.test.js +67 -0
- package/dist/manifest/bench-gate.test.js.map +1 -0
- package/dist/manifest/build-manifest-resident-parity.test.d.ts +2 -0
- package/dist/manifest/build-manifest-resident-parity.test.d.ts.map +1 -0
- package/dist/manifest/build-manifest-resident-parity.test.js +69 -0
- package/dist/manifest/build-manifest-resident-parity.test.js.map +1 -0
- package/dist/manifest/build-manifest.bench.test.d.ts +22 -0
- package/dist/manifest/build-manifest.bench.test.d.ts.map +1 -0
- package/dist/manifest/build-manifest.bench.test.js +931 -0
- package/dist/manifest/build-manifest.bench.test.js.map +1 -0
- package/dist/manifest/build-manifest.test.d.ts +10 -0
- package/dist/manifest/build-manifest.test.d.ts.map +1 -0
- package/dist/manifest/build-manifest.test.js +1220 -0
- package/dist/manifest/build-manifest.test.js.map +1 -0
- package/dist/manifest/contract.test.d.ts +17 -0
- package/dist/manifest/contract.test.d.ts.map +1 -0
- package/dist/manifest/contract.test.js +346 -0
- package/dist/manifest/contract.test.js.map +1 -0
- package/dist/manifest/import-graph.test.d.ts +25 -0
- package/dist/manifest/import-graph.test.d.ts.map +1 -0
- package/dist/manifest/import-graph.test.js +120 -0
- package/dist/manifest/import-graph.test.js.map +1 -0
- package/dist/manifest/ledger-shard-isolation.test.d.ts +18 -0
- package/dist/manifest/ledger-shard-isolation.test.d.ts.map +1 -0
- package/dist/manifest/ledger-shard-isolation.test.js +153 -0
- package/dist/manifest/ledger-shard-isolation.test.js.map +1 -0
- package/dist/manifest/snapshot-store.test.d.ts +11 -0
- package/dist/manifest/snapshot-store.test.d.ts.map +1 -0
- package/dist/manifest/snapshot-store.test.js +206 -0
- package/dist/manifest/snapshot-store.test.js.map +1 -0
- package/dist/manifest/upload-manifest.test.d.ts +10 -0
- package/dist/manifest/upload-manifest.test.d.ts.map +1 -0
- package/dist/manifest/upload-manifest.test.js +1335 -0
- package/dist/manifest/upload-manifest.test.js.map +1 -0
- package/dist/manifest-reconcile.test.d.ts +2 -0
- package/dist/manifest-reconcile.test.d.ts.map +1 -0
- package/dist/manifest-reconcile.test.js +1032 -0
- package/dist/manifest-reconcile.test.js.map +1 -0
- package/dist/object-io.test.d.ts +11 -0
- package/dist/object-io.test.d.ts.map +1 -0
- package/dist/object-io.test.js +2376 -0
- package/dist/object-io.test.js.map +1 -0
- package/dist/operation-lock.test.d.ts +5 -0
- package/dist/operation-lock.test.d.ts.map +1 -0
- package/dist/operation-lock.test.js +796 -0
- package/dist/operation-lock.test.js.map +1 -0
- package/dist/outcome-telemetry.test.d.ts +9 -0
- package/dist/outcome-telemetry.test.d.ts.map +1 -0
- package/dist/outcome-telemetry.test.js +663 -0
- package/dist/outcome-telemetry.test.js.map +1 -0
- package/dist/outposts/client.test.d.ts +9 -0
- package/dist/outposts/client.test.d.ts.map +1 -0
- package/dist/outposts/client.test.js +415 -0
- package/dist/outposts/client.test.js.map +1 -0
- package/dist/outposts/command.test.d.ts +18 -0
- package/dist/outposts/command.test.d.ts.map +1 -0
- package/dist/outposts/command.test.js +1230 -0
- package/dist/outposts/command.test.js.map +1 -0
- package/dist/outposts/replica-sync.test.d.ts +2 -0
- package/dist/outposts/replica-sync.test.d.ts.map +1 -0
- package/dist/outposts/replica-sync.test.js +225 -0
- package/dist/outposts/replica-sync.test.js.map +1 -0
- package/dist/outposts/self-deploy.test.d.ts +2 -0
- package/dist/outposts/self-deploy.test.d.ts.map +1 -0
- package/dist/outposts/self-deploy.test.js +218 -0
- package/dist/outposts/self-deploy.test.js.map +1 -0
- package/dist/outposts/session-heartbeat-bounds.test.d.ts +25 -0
- package/dist/outposts/session-heartbeat-bounds.test.d.ts.map +1 -0
- package/dist/outposts/session-heartbeat-bounds.test.js +159 -0
- package/dist/outposts/session-heartbeat-bounds.test.js.map +1 -0
- package/dist/outposts/session-heartbeat-guard.test.d.ts +16 -0
- package/dist/outposts/session-heartbeat-guard.test.d.ts.map +1 -0
- package/dist/outposts/session-heartbeat-guard.test.js +88 -0
- package/dist/outposts/session-heartbeat-guard.test.js.map +1 -0
- package/dist/outposts/session-heartbeat-publisher.test.d.ts +10 -0
- package/dist/outposts/session-heartbeat-publisher.test.d.ts.map +1 -0
- package/dist/outposts/session-heartbeat-publisher.test.js +153 -0
- package/dist/outposts/session-heartbeat-publisher.test.js.map +1 -0
- package/dist/outposts/session-heartbeat-retain-guard.test.d.ts +18 -0
- package/dist/outposts/session-heartbeat-retain-guard.test.d.ts.map +1 -0
- package/dist/outposts/session-heartbeat-retain-guard.test.js +106 -0
- package/dist/outposts/session-heartbeat-retain-guard.test.js.map +1 -0
- package/dist/outposts/session-heartbeat-scan.test.d.ts +20 -0
- package/dist/outposts/session-heartbeat-scan.test.d.ts.map +1 -0
- package/dist/outposts/session-heartbeat-scan.test.js +242 -0
- package/dist/outposts/session-heartbeat-scan.test.js.map +1 -0
- package/dist/outposts/session-heartbeat.test.d.ts +11 -0
- package/dist/outposts/session-heartbeat.test.d.ts.map +1 -0
- package/dist/outposts/session-heartbeat.test.js +387 -0
- package/dist/outposts/session-heartbeat.test.js.map +1 -0
- package/dist/outposts/session-host-auth.test.d.ts +16 -0
- package/dist/outposts/session-host-auth.test.d.ts.map +1 -0
- package/dist/outposts/session-host-auth.test.js +284 -0
- package/dist/outposts/session-host-auth.test.js.map +1 -0
- package/dist/outposts/session-host-command.test.d.ts +10 -0
- package/dist/outposts/session-host-command.test.d.ts.map +1 -0
- package/dist/outposts/session-host-command.test.js +182 -0
- package/dist/outposts/session-host-command.test.js.map +1 -0
- package/dist/outposts/session-host-connection.test.d.ts +18 -0
- package/dist/outposts/session-host-connection.test.d.ts.map +1 -0
- package/dist/outposts/session-host-connection.test.js +392 -0
- package/dist/outposts/session-host-connection.test.js.map +1 -0
- package/dist/outposts/session-host-fakes.d.ts +61 -0
- package/dist/outposts/session-host-fakes.d.ts.map +1 -0
- package/dist/outposts/session-host-fakes.js +115 -0
- package/dist/outposts/session-host-fakes.js.map +1 -0
- package/dist/outposts/session-host-ndjson.test.d.ts +11 -0
- package/dist/outposts/session-host-ndjson.test.d.ts.map +1 -0
- package/dist/outposts/session-host-ndjson.test.js +73 -0
- package/dist/outposts/session-host-ndjson.test.js.map +1 -0
- package/dist/outposts/session-host-protocol.test.d.ts +15 -0
- package/dist/outposts/session-host-protocol.test.d.ts.map +1 -0
- package/dist/outposts/session-host-protocol.test.js +0 -0
- package/dist/outposts/session-host-protocol.test.js.map +1 -0
- package/dist/outposts/session-host-server.test.d.ts +10 -0
- package/dist/outposts/session-host-server.test.d.ts.map +1 -0
- package/dist/outposts/session-host-server.test.js +118 -0
- package/dist/outposts/session-host-server.test.js.map +1 -0
- package/dist/outposts/session-host-sessions.test.d.ts +18 -0
- package/dist/outposts/session-host-sessions.test.d.ts.map +1 -0
- package/dist/outposts/session-host-sessions.test.js +439 -0
- package/dist/outposts/session-host-sessions.test.js.map +1 -0
- package/dist/outposts/terminal.test.d.ts +2 -0
- package/dist/outposts/terminal.test.d.ts.map +1 -0
- package/dist/outposts/terminal.test.js +146 -0
- package/dist/outposts/terminal.test.js.map +1 -0
- package/dist/outposts/transport.test.d.ts +10 -0
- package/dist/outposts/transport.test.d.ts.map +1 -0
- package/dist/outposts/transport.test.js +205 -0
- package/dist/outposts/transport.test.js.map +1 -0
- package/dist/packed-journal-phase2.test.d.ts +2 -0
- package/dist/packed-journal-phase2.test.d.ts.map +1 -0
- package/dist/packed-journal-phase2.test.js +273 -0
- package/dist/packed-journal-phase2.test.js.map +1 -0
- package/dist/path-ancestors.test.d.ts +2 -0
- package/dist/path-ancestors.test.d.ts.map +1 -0
- package/dist/path-ancestors.test.js +21 -0
- package/dist/path-ancestors.test.js.map +1 -0
- package/dist/personal-vault-exclusions.test.d.ts +22 -0
- package/dist/personal-vault-exclusions.test.d.ts.map +1 -0
- package/dist/personal-vault-exclusions.test.js +294 -0
- package/dist/personal-vault-exclusions.test.js.map +1 -0
- package/dist/personal-vault.test.d.ts +18 -0
- package/dist/personal-vault.test.d.ts.map +1 -0
- package/dist/personal-vault.test.js +1106 -0
- package/dist/personal-vault.test.js.map +1 -0
- package/dist/plan-limit-pause.test.d.ts +2 -0
- package/dist/plan-limit-pause.test.d.ts.map +1 -0
- package/dist/plan-limit-pause.test.js +150 -0
- package/dist/plan-limit-pause.test.js.map +1 -0
- package/dist/plan-limit.fixtures.d.ts +34 -0
- package/dist/plan-limit.fixtures.d.ts.map +1 -0
- package/dist/plan-limit.fixtures.js +96 -0
- package/dist/plan-limit.fixtures.js.map +1 -0
- package/dist/plan-limit.test.d.ts +2 -0
- package/dist/plan-limit.test.d.ts.map +1 -0
- package/dist/plan-limit.test.js +132 -0
- package/dist/plan-limit.test.js.map +1 -0
- package/dist/prefix-coalesce.test.d.ts +2 -0
- package/dist/prefix-coalesce.test.d.ts.map +1 -0
- package/dist/prefix-coalesce.test.js +260 -0
- package/dist/prefix-coalesce.test.js.map +1 -0
- package/dist/private-folder-transport.test.d.ts +2 -0
- package/dist/private-folder-transport.test.d.ts.map +1 -0
- package/dist/private-folder-transport.test.js +33 -0
- package/dist/private-folder-transport.test.js.map +1 -0
- package/dist/public-surface.test.d.ts +15 -0
- package/dist/public-surface.test.d.ts.map +1 -0
- package/dist/public-surface.test.js +110 -0
- package/dist/public-surface.test.js.map +1 -0
- package/dist/qmd-reindex.test.d.ts +14 -0
- package/dist/qmd-reindex.test.d.ts.map +1 -0
- package/dist/qmd-reindex.test.js +904 -0
- package/dist/qmd-reindex.test.js.map +1 -0
- package/dist/read-only-state-dir.test.d.ts +27 -0
- package/dist/read-only-state-dir.test.d.ts.map +1 -0
- package/dist/read-only-state-dir.test.js +210 -0
- package/dist/read-only-state-dir.test.js.map +1 -0
- package/dist/remote-pull.test.d.ts +2 -0
- package/dist/remote-pull.test.d.ts.map +1 -0
- package/dist/remote-pull.test.js +1147 -0
- package/dist/remote-pull.test.js.map +1 -0
- package/dist/s3-download-stream-hash.test.d.ts +2 -0
- package/dist/s3-download-stream-hash.test.d.ts.map +1 -0
- package/dist/s3-download-stream-hash.test.js +70 -0
- package/dist/s3-download-stream-hash.test.js.map +1 -0
- package/dist/s3.list-cost.test.d.ts +2 -0
- package/dist/s3.list-cost.test.d.ts.map +1 -0
- package/dist/s3.list-cost.test.js +51 -0
- package/dist/s3.list-cost.test.js.map +1 -0
- package/dist/s3.rename-retry.test.d.ts +2 -0
- package/dist/s3.rename-retry.test.d.ts.map +1 -0
- package/dist/s3.rename-retry.test.js +217 -0
- package/dist/s3.rename-retry.test.js.map +1 -0
- package/dist/s3.symlink-materialize.test.d.ts +18 -0
- package/dist/s3.symlink-materialize.test.d.ts.map +1 -0
- package/dist/s3.symlink-materialize.test.js +591 -0
- package/dist/s3.symlink-materialize.test.js.map +1 -0
- package/dist/s3.test.d.ts +9 -0
- package/dist/s3.test.d.ts.map +1 -0
- package/dist/s3.test.js +2091 -0
- package/dist/s3.test.js.map +1 -0
- package/dist/s3.windows-portability.test.d.ts +12 -0
- package/dist/s3.windows-portability.test.d.ts.map +1 -0
- package/dist/s3.windows-portability.test.js +228 -0
- package/dist/s3.windows-portability.test.js.map +1 -0
- package/dist/schemas/signal-types.test.d.ts +2 -0
- package/dist/schemas/signal-types.test.d.ts.map +1 -0
- package/dist/schemas/signal-types.test.js +65 -0
- package/dist/schemas/signal-types.test.js.map +1 -0
- package/dist/schemas/source-channels.test.d.ts +2 -0
- package/dist/schemas/source-channels.test.d.ts.map +1 -0
- package/dist/schemas/source-channels.test.js +65 -0
- package/dist/schemas/source-channels.test.js.map +1 -0
- package/dist/scope-shrink.test.d.ts +13 -0
- package/dist/scope-shrink.test.d.ts.map +1 -0
- package/dist/scope-shrink.test.js +558 -0
- package/dist/scope-shrink.test.js.map +1 -0
- package/dist/session-log-capture.test.d.ts +2 -0
- package/dist/session-log-capture.test.d.ts.map +1 -0
- package/dist/session-log-capture.test.js +533 -0
- package/dist/session-log-capture.test.js.map +1 -0
- package/dist/session-log-retention.test.d.ts +2 -0
- package/dist/session-log-retention.test.d.ts.map +1 -0
- package/dist/session-log-retention.test.js +383 -0
- package/dist/session-log-retention.test.js.map +1 -0
- package/dist/signals/get.test.d.ts +5 -0
- package/dist/signals/get.test.d.ts.map +1 -0
- package/dist/signals/get.test.js +254 -0
- package/dist/signals/get.test.js.map +1 -0
- package/dist/signals/list.test.d.ts +9 -0
- package/dist/signals/list.test.d.ts.map +1 -0
- package/dist/signals/list.test.js +330 -0
- package/dist/signals/list.test.js.map +1 -0
- package/dist/skill-telemetry.test.d.ts +2 -0
- package/dist/skill-telemetry.test.d.ts.map +1 -0
- package/dist/skill-telemetry.test.js +1484 -0
- package/dist/skill-telemetry.test.js.map +1 -0
- package/dist/sources/get.test.d.ts +5 -0
- package/dist/sources/get.test.d.ts.map +1 -0
- package/dist/sources/get.test.js +236 -0
- package/dist/sources/get.test.js.map +1 -0
- package/dist/sources/list.test.d.ts +8 -0
- package/dist/sources/list.test.d.ts.map +1 -0
- package/dist/sources/list.test.js +318 -0
- package/dist/sources/list.test.js.map +1 -0
- package/dist/sts-credential-refresh.test.d.ts +2 -0
- package/dist/sts-credential-refresh.test.d.ts.map +1 -0
- package/dist/sts-credential-refresh.test.js +181 -0
- package/dist/sts-credential-refresh.test.js.map +1 -0
- package/dist/swallowed-error-sites.test.d.ts +2 -0
- package/dist/swallowed-error-sites.test.d.ts.map +1 -0
- package/dist/swallowed-error-sites.test.js +209 -0
- package/dist/swallowed-error-sites.test.js.map +1 -0
- package/dist/swallowed-error-w32.test.d.ts +2 -0
- package/dist/swallowed-error-w32.test.d.ts.map +1 -0
- package/dist/swallowed-error-w32.test.js +186 -0
- package/dist/swallowed-error-w32.test.js.map +1 -0
- package/dist/swallowed-error-w33.test.d.ts +2 -0
- package/dist/swallowed-error-w33.test.d.ts.map +1 -0
- package/dist/swallowed-error-w33.test.js +136 -0
- package/dist/swallowed-error-w33.test.js.map +1 -0
- package/dist/swallowed-error-w34.test.d.ts +2 -0
- package/dist/swallowed-error-w34.test.d.ts.map +1 -0
- package/dist/swallowed-error-w34.test.js +110 -0
- package/dist/swallowed-error-w34.test.js.map +1 -0
- package/dist/swallowed-error-w35.test.d.ts +2 -0
- package/dist/swallowed-error-w35.test.d.ts.map +1 -0
- package/dist/swallowed-error-w35.test.js +237 -0
- package/dist/swallowed-error-w35.test.js.map +1 -0
- package/dist/sync/area-ledger-auto-migration.test.d.ts +2 -0
- package/dist/sync/area-ledger-auto-migration.test.d.ts.map +1 -0
- package/dist/sync/area-ledger-auto-migration.test.js +291 -0
- package/dist/sync/area-ledger-auto-migration.test.js.map +1 -0
- package/dist/sync/area-ledger-migration.test.d.ts +2 -0
- package/dist/sync/area-ledger-migration.test.d.ts.map +1 -0
- package/dist/sync/area-ledger-migration.test.js +554 -0
- package/dist/sync/area-ledger-migration.test.js.map +1 -0
- package/dist/sync/area-ledger-recovery.bench.test.d.ts +2 -0
- package/dist/sync/area-ledger-recovery.bench.test.d.ts.map +1 -0
- package/dist/sync/area-ledger-recovery.bench.test.js +60 -0
- package/dist/sync/area-ledger-recovery.bench.test.js.map +1 -0
- package/dist/sync/area-ledger-writer-lock.bench.test.d.ts +2 -0
- package/dist/sync/area-ledger-writer-lock.bench.test.d.ts.map +1 -0
- package/dist/sync/area-ledger-writer-lock.bench.test.js +57 -0
- package/dist/sync/area-ledger-writer-lock.bench.test.js.map +1 -0
- package/dist/sync/area-ledger.test.d.ts +2 -0
- package/dist/sync/area-ledger.test.d.ts.map +1 -0
- package/dist/sync/area-ledger.test.js +1401 -0
- package/dist/sync/area-ledger.test.js.map +1 -0
- package/dist/sync/area-resolver.test.d.ts +2 -0
- package/dist/sync/area-resolver.test.d.ts.map +1 -0
- package/dist/sync/area-resolver.test.js +234 -0
- package/dist/sync/area-resolver.test.js.map +1 -0
- package/dist/sync/base-version-resolver.test.d.ts +2 -0
- package/dist/sync/base-version-resolver.test.d.ts.map +1 -0
- package/dist/sync/base-version-resolver.test.js +24 -0
- package/dist/sync/base-version-resolver.test.js.map +1 -0
- package/dist/sync/candidate-uploader.test.d.ts +2 -0
- package/dist/sync/candidate-uploader.test.d.ts.map +1 -0
- package/dist/sync/candidate-uploader.test.js +132 -0
- package/dist/sync/candidate-uploader.test.js.map +1 -0
- package/dist/sync/child-process-sync-worker-env.test.d.ts +2 -0
- package/dist/sync/child-process-sync-worker-env.test.d.ts.map +1 -0
- package/dist/sync/child-process-sync-worker-env.test.js +38 -0
- package/dist/sync/child-process-sync-worker-env.test.js.map +1 -0
- package/dist/sync/child-process-sync-worker-errors.test.d.ts +2 -0
- package/dist/sync/child-process-sync-worker-errors.test.d.ts.map +1 -0
- package/dist/sync/child-process-sync-worker-errors.test.js +121 -0
- package/dist/sync/child-process-sync-worker-errors.test.js.map +1 -0
- package/dist/sync/child-process-sync-worker.test.d.ts +2 -0
- package/dist/sync/child-process-sync-worker.test.d.ts.map +1 -0
- package/dist/sync/child-process-sync-worker.test.js +279 -0
- package/dist/sync/child-process-sync-worker.test.js.map +1 -0
- package/dist/sync/content-hash.test.d.ts +2 -0
- package/dist/sync/content-hash.test.d.ts.map +1 -0
- package/dist/sync/content-hash.test.js +16 -0
- package/dist/sync/content-hash.test.js.map +1 -0
- package/dist/sync/delta-client.test.d.ts +2 -0
- package/dist/sync/delta-client.test.d.ts.map +1 -0
- package/dist/sync/delta-client.test.js +97 -0
- package/dist/sync/delta-client.test.js.map +1 -0
- package/dist/sync/durable-apply.test.d.ts +2 -0
- package/dist/sync/durable-apply.test.d.ts.map +1 -0
- package/dist/sync/durable-apply.test.js +187 -0
- package/dist/sync/durable-apply.test.js.map +1 -0
- package/dist/sync/event-sync.test.d.ts +14 -0
- package/dist/sync/event-sync.test.d.ts.map +1 -0
- package/dist/sync/event-sync.test.js +1717 -0
- package/dist/sync/event-sync.test.js.map +1 -0
- package/dist/sync/feature-flags.test.d.ts +24 -0
- package/dist/sync/feature-flags.test.d.ts.map +1 -0
- package/dist/sync/feature-flags.test.js +594 -0
- package/dist/sync/feature-flags.test.js.map +1 -0
- package/dist/sync/fsync-compat.test.d.ts +2 -0
- package/dist/sync/fsync-compat.test.d.ts.map +1 -0
- package/dist/sync/fsync-compat.test.js +52 -0
- package/dist/sync/fsync-compat.test.js.map +1 -0
- package/dist/sync/full-pass-cap-governor.bench.test.d.ts +2 -0
- package/dist/sync/full-pass-cap-governor.bench.test.d.ts.map +1 -0
- package/dist/sync/full-pass-cap-governor.bench.test.js +179 -0
- package/dist/sync/full-pass-cap-governor.bench.test.js.map +1 -0
- package/dist/sync/full-pass-caps.test.d.ts +2 -0
- package/dist/sync/full-pass-caps.test.d.ts.map +1 -0
- package/dist/sync/full-pass-caps.test.js +550 -0
- package/dist/sync/full-pass-caps.test.js.map +1 -0
- package/dist/sync/idle-full-reconcile.test.d.ts +2 -0
- package/dist/sync/idle-full-reconcile.test.d.ts.map +1 -0
- package/dist/sync/idle-full-reconcile.test.js +62 -0
- package/dist/sync/idle-full-reconcile.test.js.map +1 -0
- package/dist/sync/inbound-event-admission.test.d.ts +2 -0
- package/dist/sync/inbound-event-admission.test.d.ts.map +1 -0
- package/dist/sync/inbound-event-admission.test.js +128 -0
- package/dist/sync/inbound-event-admission.test.js.map +1 -0
- package/dist/sync/journal-ledger-stream.test.d.ts +12 -0
- package/dist/sync/journal-ledger-stream.test.d.ts.map +1 -0
- package/dist/sync/journal-ledger-stream.test.js +134 -0
- package/dist/sync/journal-ledger-stream.test.js.map +1 -0
- package/dist/sync/lease-client.test.d.ts +2 -0
- package/dist/sync/lease-client.test.d.ts.map +1 -0
- package/dist/sync/lease-client.test.js +119 -0
- package/dist/sync/lease-client.test.js.map +1 -0
- package/dist/sync/logger.test.d.ts +19 -0
- package/dist/sync/logger.test.d.ts.map +1 -0
- package/dist/sync/logger.test.js +204 -0
- package/dist/sync/logger.test.js.map +1 -0
- package/dist/sync/metrics.test.d.ts +19 -0
- package/dist/sync/metrics.test.d.ts.map +1 -0
- package/dist/sync/metrics.test.js +357 -0
- package/dist/sync/metrics.test.js.map +1 -0
- package/dist/sync/multipart-uploader.test.d.ts +2 -0
- package/dist/sync/multipart-uploader.test.d.ts.map +1 -0
- package/dist/sync/multipart-uploader.test.js +141 -0
- package/dist/sync/multipart-uploader.test.js.map +1 -0
- package/dist/sync/mutation-client.test.d.ts +2 -0
- package/dist/sync/mutation-client.test.d.ts.map +1 -0
- package/dist/sync/mutation-client.test.js +100 -0
- package/dist/sync/mutation-client.test.js.map +1 -0
- package/dist/sync/mutation-session.test.d.ts +2 -0
- package/dist/sync/mutation-session.test.d.ts.map +1 -0
- package/dist/sync/mutation-session.test.js +190 -0
- package/dist/sync/mutation-session.test.js.map +1 -0
- package/dist/sync/parallel-sync-coordinator.test.d.ts +2 -0
- package/dist/sync/parallel-sync-coordinator.test.d.ts.map +1 -0
- package/dist/sync/parallel-sync-coordinator.test.js +564 -0
- package/dist/sync/parallel-sync-coordinator.test.js.map +1 -0
- package/dist/sync/path-leases.test.d.ts +2 -0
- package/dist/sync/path-leases.test.d.ts.map +1 -0
- package/dist/sync/path-leases.test.js +51 -0
- package/dist/sync/path-leases.test.js.map +1 -0
- package/dist/sync/per-area-maintenance.test.d.ts +2 -0
- package/dist/sync/per-area-maintenance.test.d.ts.map +1 -0
- package/dist/sync/per-area-maintenance.test.js +100 -0
- package/dist/sync/per-area-maintenance.test.js.map +1 -0
- package/dist/sync/push-event.test.d.ts +15 -0
- package/dist/sync/push-event.test.d.ts.map +1 -0
- package/dist/sync/push-event.test.js +282 -0
- package/dist/sync/push-event.test.js.map +1 -0
- package/dist/sync/push-receiver.test.d.ts +25 -0
- package/dist/sync/push-receiver.test.d.ts.map +1 -0
- package/dist/sync/push-receiver.test.js +2851 -0
- package/dist/sync/push-receiver.test.js.map +1 -0
- package/dist/sync/push-transport.test.d.ts +2 -0
- package/dist/sync/push-transport.test.d.ts.map +1 -0
- package/dist/sync/push-transport.test.js +70 -0
- package/dist/sync/push-transport.test.js.map +1 -0
- package/dist/sync/push-walk-matchers.bench.test.d.ts +2 -0
- package/dist/sync/push-walk-matchers.bench.test.d.ts.map +1 -0
- package/dist/sync/push-walk-matchers.bench.test.js +230 -0
- package/dist/sync/push-walk-matchers.bench.test.js.map +1 -0
- package/dist/sync/realtime-network-integration.test.d.ts +2 -0
- package/dist/sync/realtime-network-integration.test.d.ts.map +1 -0
- package/dist/sync/realtime-network-integration.test.js +83 -0
- package/dist/sync/realtime-network-integration.test.js.map +1 -0
- package/dist/sync/realtime-rollout.test.d.ts +2 -0
- package/dist/sync/realtime-rollout.test.d.ts.map +1 -0
- package/dist/sync/realtime-rollout.test.js +94 -0
- package/dist/sync/realtime-rollout.test.js.map +1 -0
- package/dist/sync/realtime-telemetry.test.d.ts +2 -0
- package/dist/sync/realtime-telemetry.test.d.ts.map +1 -0
- package/dist/sync/realtime-telemetry.test.js +300 -0
- package/dist/sync/realtime-telemetry.test.js.map +1 -0
- package/dist/sync/receiver-origin-config.test.d.ts +2 -0
- package/dist/sync/receiver-origin-config.test.d.ts.map +1 -0
- package/dist/sync/receiver-origin-config.test.js +39 -0
- package/dist/sync/receiver-origin-config.test.js.map +1 -0
- package/dist/sync/reconcile-cursor.test.d.ts +2 -0
- package/dist/sync/reconcile-cursor.test.d.ts.map +1 -0
- package/dist/sync/reconcile-cursor.test.js +139 -0
- package/dist/sync/reconcile-cursor.test.js.map +1 -0
- package/dist/sync/remote-file-spool.test.d.ts +2 -0
- package/dist/sync/remote-file-spool.test.d.ts.map +1 -0
- package/dist/sync/remote-file-spool.test.js +79 -0
- package/dist/sync/remote-file-spool.test.js.map +1 -0
- package/dist/sync/scope-inventory-client.test.d.ts +2 -0
- package/dist/sync/scope-inventory-client.test.d.ts.map +1 -0
- package/dist/sync/scope-inventory-client.test.js +110 -0
- package/dist/sync/scope-inventory-client.test.js.map +1 -0
- package/dist/sync/secret-path-policy.test.d.ts +2 -0
- package/dist/sync/secret-path-policy.test.d.ts.map +1 -0
- package/dist/sync/secret-path-policy.test.js +183 -0
- package/dist/sync/secret-path-policy.test.js.map +1 -0
- package/dist/sync/snapshot-client.test.d.ts +2 -0
- package/dist/sync/snapshot-client.test.d.ts.map +1 -0
- package/dist/sync/snapshot-client.test.js +169 -0
- package/dist/sync/snapshot-client.test.js.map +1 -0
- package/dist/sync/state-store.test.d.ts +2 -0
- package/dist/sync/state-store.test.d.ts.map +1 -0
- package/dist/sync/state-store.test.js +1556 -0
- package/dist/sync/state-store.test.js.map +1 -0
- package/dist/sync/sync-contract.test.d.ts +2 -0
- package/dist/sync/sync-contract.test.d.ts.map +1 -0
- package/dist/sync/sync-contract.test.js +141 -0
- package/dist/sync/sync-contract.test.js.map +1 -0
- package/dist/sync/targeted-pull-prefixes.test.d.ts +2 -0
- package/dist/sync/targeted-pull-prefixes.test.d.ts.map +1 -0
- package/dist/sync/targeted-pull-prefixes.test.js +33 -0
- package/dist/sync/targeted-pull-prefixes.test.js.map +1 -0
- package/dist/sync/targeted-upsert-exact-list.test.d.ts +2 -0
- package/dist/sync/targeted-upsert-exact-list.test.d.ts.map +1 -0
- package/dist/sync/targeted-upsert-exact-list.test.js +247 -0
- package/dist/sync/targeted-upsert-exact-list.test.js.map +1 -0
- package/dist/sync/unchanged-push-events.test.d.ts +2 -0
- package/dist/sync/unchanged-push-events.test.d.ts.map +1 -0
- package/dist/sync/unchanged-push-events.test.js +76 -0
- package/dist/sync/unchanged-push-events.test.js.map +1 -0
- package/dist/sync/uploader-finalization.test.d.ts +2 -0
- package/dist/sync/uploader-finalization.test.d.ts.map +1 -0
- package/dist/sync/uploader-finalization.test.js +107 -0
- package/dist/sync/uploader-finalization.test.js.map +1 -0
- package/dist/sync-core.test.d.ts +2 -0
- package/dist/sync-core.test.d.ts.map +1 -0
- package/dist/sync-core.test.js +189 -0
- package/dist/sync-core.test.js.map +1 -0
- package/dist/sync-progress.test.d.ts +2 -0
- package/dist/sync-progress.test.d.ts.map +1 -0
- package/dist/sync-progress.test.js +277 -0
- package/dist/sync-progress.test.js.map +1 -0
- package/dist/telemetry-events.test.d.ts +2 -0
- package/dist/telemetry-events.test.d.ts.map +1 -0
- package/dist/telemetry-events.test.js +113 -0
- package/dist/telemetry-events.test.js.map +1 -0
- package/dist/telemetry.test.d.ts +11 -0
- package/dist/telemetry.test.d.ts.map +1 -0
- package/dist/telemetry.test.js +1603 -0
- package/dist/telemetry.test.js.map +1 -0
- package/dist/vault-client.test.d.ts +7 -0
- package/dist/vault-client.test.d.ts.map +1 -0
- package/dist/vault-client.test.js +1334 -0
- package/dist/vault-client.test.js.map +1 -0
- package/dist/watch-coverage.test.d.ts +2 -0
- package/dist/watch-coverage.test.d.ts.map +1 -0
- package/dist/watch-coverage.test.js +56 -0
- package/dist/watch-coverage.test.js.map +1 -0
- package/dist/watch-owner-lease.test.d.ts +2 -0
- package/dist/watch-owner-lease.test.d.ts.map +1 -0
- package/dist/watch-owner-lease.test.js +364 -0
- package/dist/watch-owner-lease.test.js.map +1 -0
- package/dist/watch-parent.test.d.ts +2 -0
- package/dist/watch-parent.test.d.ts.map +1 -0
- package/dist/watch-parent.test.js +131 -0
- package/dist/watch-parent.test.js.map +1 -0
- package/dist/watch-roots.test.d.ts +18 -0
- package/dist/watch-roots.test.d.ts.map +1 -0
- package/dist/watch-roots.test.js +395 -0
- package/dist/watch-roots.test.js.map +1 -0
- package/dist/watcher-continuity-hot-path.test.d.ts +2 -0
- package/dist/watcher-continuity-hot-path.test.d.ts.map +1 -0
- package/dist/watcher-continuity-hot-path.test.js +40 -0
- package/dist/watcher-continuity-hot-path.test.js.map +1 -0
- package/dist/watcher-event-gate.test.d.ts +16 -0
- package/dist/watcher-event-gate.test.d.ts.map +1 -0
- package/dist/watcher-event-gate.test.js +191 -0
- package/dist/watcher-event-gate.test.js.map +1 -0
- package/dist/watcher-replan-sweep.test.d.ts +2 -0
- package/dist/watcher-replan-sweep.test.d.ts.map +1 -0
- package/dist/watcher-replan-sweep.test.js +260 -0
- package/dist/watcher-replan-sweep.test.js.map +1 -0
- package/dist/watcher-stdout.test.d.ts +2 -0
- package/dist/watcher-stdout.test.d.ts.map +1 -0
- package/dist/watcher-stdout.test.js +86 -0
- package/dist/watcher-stdout.test.js.map +1 -0
- package/dist/watcher.test.d.ts +2 -0
- package/dist/watcher.test.d.ts.map +1 -0
- package/dist/watcher.test.js +4329 -0
- package/dist/watcher.test.js.map +1 -0
- package/dist/watcher.warmup-cancel.test.d.ts +2 -0
- package/dist/watcher.warmup-cancel.test.d.ts.map +1 -0
- package/dist/watcher.warmup-cancel.test.js +59 -0
- package/dist/watcher.warmup-cancel.test.js.map +1 -0
- package/dist/watcher.warmup-responsive.test.d.ts +2 -0
- package/dist/watcher.warmup-responsive.test.d.ts.map +1 -0
- package/dist/watcher.warmup-responsive.test.js +62 -0
- package/dist/watcher.warmup-responsive.test.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,1492 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit tests for the machine-identity auth mode in cognito-auth.ts.
|
|
3
|
+
*
|
|
4
|
+
* Machine identities (company agents) carry long-lived Cognito creds at
|
|
5
|
+
* ~/.hq-agent/machine-creds.json (HQ_MACHINE_CREDS_FILE override) and mint
|
|
6
|
+
* sessions via USER_PASSWORD_AUTH on demand — no browser, no refresh token.
|
|
7
|
+
* The contract under test:
|
|
8
|
+
* - detection: creds file present + well-formed → machine mode
|
|
9
|
+
* - minting: BOTH tokens cached with correct field semantics
|
|
10
|
+
* - re-mint on expiry; cache hit when valid
|
|
11
|
+
* - getValidAccessToken short-circuits into machine mode (never browser)
|
|
12
|
+
*/
|
|
13
|
+
import * as fs from "fs";
|
|
14
|
+
import * as os from "os";
|
|
15
|
+
import * as path from "path";
|
|
16
|
+
import { spawn } from "child_process";
|
|
17
|
+
import { pathToFileURL } from "url";
|
|
18
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
19
|
+
let originalHome;
|
|
20
|
+
let originalUserProfile;
|
|
21
|
+
let originalCredsEnv;
|
|
22
|
+
let tmpHome;
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
originalHome = process.env.HOME;
|
|
25
|
+
originalUserProfile = process.env.USERPROFILE;
|
|
26
|
+
originalCredsEnv = process.env.HQ_MACHINE_CREDS_FILE;
|
|
27
|
+
tmpHome = fs.mkdtempSync(path.join(os.tmpdir(), "hq-machine-auth-test-"));
|
|
28
|
+
process.env.HOME = tmpHome;
|
|
29
|
+
process.env.USERPROFILE = tmpHome;
|
|
30
|
+
// Keep this suite's token-cache fixture coupled to its sandboxed HOME
|
|
31
|
+
// instead of inheriting Vitest's suite-wide hermetic state directory.
|
|
32
|
+
process.env.HQ_STATE_DIR = path.join(tmpHome, ".hq");
|
|
33
|
+
delete process.env.HQ_MACHINE_CREDS_FILE;
|
|
34
|
+
vi.resetModules();
|
|
35
|
+
});
|
|
36
|
+
afterEach(() => {
|
|
37
|
+
vi.useRealTimers();
|
|
38
|
+
if (originalHome === undefined)
|
|
39
|
+
delete process.env.HOME;
|
|
40
|
+
else
|
|
41
|
+
process.env.HOME = originalHome;
|
|
42
|
+
if (originalUserProfile === undefined)
|
|
43
|
+
delete process.env.USERPROFILE;
|
|
44
|
+
else
|
|
45
|
+
process.env.USERPROFILE = originalUserProfile;
|
|
46
|
+
if (originalCredsEnv === undefined)
|
|
47
|
+
delete process.env.HQ_MACHINE_CREDS_FILE;
|
|
48
|
+
else
|
|
49
|
+
process.env.HQ_MACHINE_CREDS_FILE = originalCredsEnv;
|
|
50
|
+
fs.rmSync(tmpHome, { recursive: true, force: true });
|
|
51
|
+
vi.unstubAllGlobals();
|
|
52
|
+
vi.restoreAllMocks();
|
|
53
|
+
});
|
|
54
|
+
async function importModule() {
|
|
55
|
+
return await import("./cognito-auth.js");
|
|
56
|
+
}
|
|
57
|
+
const CONFIG = {
|
|
58
|
+
region: "us-east-1",
|
|
59
|
+
userPoolDomain: "vault-indigo-hq-prod",
|
|
60
|
+
clientId: "test-client-id",
|
|
61
|
+
};
|
|
62
|
+
function writeCreds(creds = { username: "machine-agt_01TEST", secret: "s3cret" }) {
|
|
63
|
+
const dir = path.join(tmpHome, ".hq-agent");
|
|
64
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
65
|
+
const file = path.join(dir, "machine-creds.json");
|
|
66
|
+
fs.writeFileSync(file, JSON.stringify(creds));
|
|
67
|
+
return file;
|
|
68
|
+
}
|
|
69
|
+
/** Build a fake JWT whose payload decodes to the given claims. */
|
|
70
|
+
function fakeJwt(claims) {
|
|
71
|
+
const enc = (o) => Buffer.from(JSON.stringify(o)).toString("base64url");
|
|
72
|
+
return `${enc({ alg: "RS256", kid: "k" })}.${enc(claims)}.sig`;
|
|
73
|
+
}
|
|
74
|
+
function stubMintFetch(overrides = {}) {
|
|
75
|
+
const calls = [];
|
|
76
|
+
const fetchMock = vi.fn(async (url, init) => {
|
|
77
|
+
calls.push({ url: String(url), init: init ?? {} });
|
|
78
|
+
const body = JSON.parse(String(init?.body));
|
|
79
|
+
const credsFile = process.env.HQ_MACHINE_CREDS_FILE ??
|
|
80
|
+
path.join(tmpHome, ".hq-agent", "machine-creds.json");
|
|
81
|
+
const creds = JSON.parse(fs.readFileSync(credsFile, "utf-8"));
|
|
82
|
+
const username = body.AuthParameters.USERNAME;
|
|
83
|
+
const subject = `sub:${username}`;
|
|
84
|
+
const entityType = creds.entityType ?? "agent";
|
|
85
|
+
const entityUid = creds.entityUid ?? "agt_01TEST";
|
|
86
|
+
return new Response(JSON.stringify({
|
|
87
|
+
AuthenticationResult: {
|
|
88
|
+
AccessToken: overrides.AccessToken ??
|
|
89
|
+
fakeJwt({
|
|
90
|
+
token_use: "access",
|
|
91
|
+
client_id: body.ClientId,
|
|
92
|
+
username,
|
|
93
|
+
sub: subject,
|
|
94
|
+
}),
|
|
95
|
+
IdToken: overrides.IdToken ??
|
|
96
|
+
fakeJwt({
|
|
97
|
+
token_use: "id",
|
|
98
|
+
aud: body.ClientId,
|
|
99
|
+
"custom:entityType": entityType,
|
|
100
|
+
"custom:entityUid": entityUid,
|
|
101
|
+
...(entityType === "outpost"
|
|
102
|
+
? {
|
|
103
|
+
"custom:delegatedSub": "human-sub",
|
|
104
|
+
"custom:delegatedEmail": "owner@example.com",
|
|
105
|
+
}
|
|
106
|
+
: {}),
|
|
107
|
+
"cognito:username": username,
|
|
108
|
+
sub: subject,
|
|
109
|
+
}),
|
|
110
|
+
RefreshToken: overrides.RefreshToken,
|
|
111
|
+
ExpiresIn: overrides.ExpiresIn ?? 3600,
|
|
112
|
+
},
|
|
113
|
+
}), { status: 200 });
|
|
114
|
+
});
|
|
115
|
+
vi.stubGlobal("fetch", fetchMock);
|
|
116
|
+
return { fetchMock, calls };
|
|
117
|
+
}
|
|
118
|
+
// ---------------------------------------------------------------------------
|
|
119
|
+
// Detection
|
|
120
|
+
// ---------------------------------------------------------------------------
|
|
121
|
+
describe("machine identity detection", () => {
|
|
122
|
+
it("is off when no creds file exists", async () => {
|
|
123
|
+
const { isMachineIdentity, loadMachineCreds } = await importModule();
|
|
124
|
+
expect(loadMachineCreds()).toBeNull();
|
|
125
|
+
expect(isMachineIdentity()).toBe(false);
|
|
126
|
+
});
|
|
127
|
+
it("detects creds at the default ~/.hq-agent path", async () => {
|
|
128
|
+
writeCreds();
|
|
129
|
+
const { isMachineIdentity, loadMachineCreds } = await importModule();
|
|
130
|
+
expect(loadMachineCreds()).toEqual({
|
|
131
|
+
username: "machine-agt_01TEST",
|
|
132
|
+
secret: "s3cret",
|
|
133
|
+
clientId: undefined,
|
|
134
|
+
region: undefined,
|
|
135
|
+
});
|
|
136
|
+
expect(isMachineIdentity()).toBe(true);
|
|
137
|
+
});
|
|
138
|
+
it("detects provisioned-shape creds (agt-<ulid>@agents domain + clientId/region)", async () => {
|
|
139
|
+
writeCreds({
|
|
140
|
+
username: "agt-01ktt1rjj6kqrhnhhst0k4vrgt@agents.getindigo.ai",
|
|
141
|
+
secret: "s3cret",
|
|
142
|
+
clientId: "agent-client-1",
|
|
143
|
+
region: "us-east-1",
|
|
144
|
+
userPoolId: "us-east-1_pool",
|
|
145
|
+
});
|
|
146
|
+
const { isMachineIdentity, loadMachineCreds } = await importModule();
|
|
147
|
+
expect(loadMachineCreds()).toEqual({
|
|
148
|
+
username: "agt-01ktt1rjj6kqrhnhhst0k4vrgt@agents.getindigo.ai",
|
|
149
|
+
secret: "s3cret",
|
|
150
|
+
clientId: "agent-client-1",
|
|
151
|
+
region: "us-east-1",
|
|
152
|
+
});
|
|
153
|
+
expect(isMachineIdentity()).toBe(true);
|
|
154
|
+
});
|
|
155
|
+
it("parses the expected machine entity type and uid from provisioned creds", async () => {
|
|
156
|
+
writeCreds({
|
|
157
|
+
username: "out-01test@outposts.getindigo.ai",
|
|
158
|
+
secret: "s3cret",
|
|
159
|
+
clientId: "outpost-client-1",
|
|
160
|
+
region: "us-east-1",
|
|
161
|
+
entityType: "outpost",
|
|
162
|
+
entityUid: "out_01TEST",
|
|
163
|
+
});
|
|
164
|
+
const { loadMachineCreds } = await importModule();
|
|
165
|
+
expect(loadMachineCreds()).toEqual({
|
|
166
|
+
username: "out-01test@outposts.getindigo.ai",
|
|
167
|
+
secret: "s3cret",
|
|
168
|
+
clientId: "outpost-client-1",
|
|
169
|
+
region: "us-east-1",
|
|
170
|
+
entityType: "outpost",
|
|
171
|
+
entityUid: "out_01TEST",
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
it("honors HQ_MACHINE_CREDS_FILE override", async () => {
|
|
175
|
+
const custom = path.join(tmpHome, "elsewhere.json");
|
|
176
|
+
fs.writeFileSync(custom, JSON.stringify({ username: "machine-agt_X", secret: "y" }));
|
|
177
|
+
process.env.HQ_MACHINE_CREDS_FILE = custom;
|
|
178
|
+
const { loadMachineCreds, machineCredsFilePath } = await importModule();
|
|
179
|
+
expect(machineCredsFilePath()).toBe(custom);
|
|
180
|
+
expect(loadMachineCreds()?.username).toBe("machine-agt_X");
|
|
181
|
+
});
|
|
182
|
+
it("rejects malformed creds (missing secret, empty username, bad JSON)", async () => {
|
|
183
|
+
const { loadMachineCreds } = await importModule();
|
|
184
|
+
writeCreds({ username: "", secret: "x" });
|
|
185
|
+
expect(loadMachineCreds()).toBeNull();
|
|
186
|
+
writeCreds({ username: "machine-agt_01TEST" });
|
|
187
|
+
expect(loadMachineCreds()).toBeNull();
|
|
188
|
+
fs.writeFileSync(path.join(tmpHome, ".hq-agent", "machine-creds.json"), "{nope");
|
|
189
|
+
expect(loadMachineCreds()).toBeNull();
|
|
190
|
+
});
|
|
191
|
+
it.each([
|
|
192
|
+
{ entityType: "agent", entityUid: "out_WRONG" },
|
|
193
|
+
{ entityType: "outpost", entityUid: "agt_WRONG" },
|
|
194
|
+
{ entityType: "agent", entityUid: "garbage" },
|
|
195
|
+
{ entityType: "agent" },
|
|
196
|
+
{ entityType: "outpost" },
|
|
197
|
+
{ entityUid: "out_NO_TYPE" },
|
|
198
|
+
{ entityUid: "garbage" },
|
|
199
|
+
{ entityType: "agent", entityUid: "agt_" },
|
|
200
|
+
{ entityType: "outpost", entityUid: "out_" },
|
|
201
|
+
])("rejects malformed or cross-prefix entity metadata: %j", async (identity) => {
|
|
202
|
+
writeCreds({ username: "machine", secret: "secret", ...identity });
|
|
203
|
+
const { loadMachineCreds } = await importModule();
|
|
204
|
+
expect(loadMachineCreds()).toBeNull();
|
|
205
|
+
});
|
|
206
|
+
it("accepts an agt_* uid without a type as the legacy agent inference", async () => {
|
|
207
|
+
writeCreds({
|
|
208
|
+
username: "machine-agt_01TEST",
|
|
209
|
+
secret: "secret",
|
|
210
|
+
entityUid: "agt_01TEST",
|
|
211
|
+
});
|
|
212
|
+
const { loadMachineCreds } = await importModule();
|
|
213
|
+
expect(loadMachineCreds()).toMatchObject({ entityUid: "agt_01TEST" });
|
|
214
|
+
expect(loadMachineCreds()?.entityType).toBeUndefined();
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
// ---------------------------------------------------------------------------
|
|
218
|
+
// Minting
|
|
219
|
+
// ---------------------------------------------------------------------------
|
|
220
|
+
describe("mintMachineTokens", () => {
|
|
221
|
+
it("prefers the creds file's clientId/region over config (agent app client has USER_PASSWORD_AUTH)", async () => {
|
|
222
|
+
writeCreds({
|
|
223
|
+
username: "agt-01ktt1rjj6kqrhnhhst0k4vrgt@agents.getindigo.ai",
|
|
224
|
+
secret: "s3cret",
|
|
225
|
+
clientId: "agent-client-1",
|
|
226
|
+
region: "eu-west-1",
|
|
227
|
+
});
|
|
228
|
+
const { calls } = stubMintFetch();
|
|
229
|
+
const { mintMachineTokens } = await importModule();
|
|
230
|
+
await mintMachineTokens(CONFIG);
|
|
231
|
+
expect(calls[0].url).toBe("https://cognito-idp.eu-west-1.amazonaws.com/");
|
|
232
|
+
const body = JSON.parse(String(calls[0].init.body));
|
|
233
|
+
expect(body.ClientId).toBe("agent-client-1");
|
|
234
|
+
});
|
|
235
|
+
it("mints via USER_PASSWORD_AUTH and caches both tokens with correct fields", async () => {
|
|
236
|
+
writeCreds();
|
|
237
|
+
const { calls } = stubMintFetch({ RefreshToken: "rt" });
|
|
238
|
+
const { mintMachineTokens, loadCachedMachineTokens } = await importModule();
|
|
239
|
+
const tokens = await mintMachineTokens(CONFIG);
|
|
240
|
+
// Request shape: Cognito IDP InitiateAuth with the machine creds.
|
|
241
|
+
expect(calls).toHaveLength(1);
|
|
242
|
+
expect(calls[0].url).toBe("https://cognito-idp.us-east-1.amazonaws.com/");
|
|
243
|
+
const body = JSON.parse(String(calls[0].init.body));
|
|
244
|
+
expect(body).toMatchObject({
|
|
245
|
+
AuthFlow: "USER_PASSWORD_AUTH",
|
|
246
|
+
ClientId: CONFIG.clientId,
|
|
247
|
+
AuthParameters: { USERNAME: "machine-agt_01TEST", PASSWORD: "s3cret" },
|
|
248
|
+
});
|
|
249
|
+
// Field semantics: access token in accessToken, id token in idToken.
|
|
250
|
+
const accessClaims = JSON.parse(Buffer.from(tokens.accessToken.split(".")[1], "base64url").toString());
|
|
251
|
+
const idClaims = JSON.parse(Buffer.from(tokens.idToken.split(".")[1], "base64url").toString());
|
|
252
|
+
expect(accessClaims.token_use).toBe("access");
|
|
253
|
+
expect(idClaims.token_use).toBe("id");
|
|
254
|
+
expect(tokens.refreshToken).toBe("");
|
|
255
|
+
expect(typeof tokens.expiresAt).toBe("number");
|
|
256
|
+
// Persisted to the shared cache file.
|
|
257
|
+
expect(loadCachedMachineTokens()).toEqual(tokens);
|
|
258
|
+
});
|
|
259
|
+
it("throws CognitoAuthError on auth failure", async () => {
|
|
260
|
+
writeCreds();
|
|
261
|
+
vi.stubGlobal("fetch", vi.fn(async () => new Response(JSON.stringify({ __type: "NotAuthorizedException", message: "nope" }), { status: 400 })));
|
|
262
|
+
const { mintMachineTokens, CognitoAuthError } = await importModule();
|
|
263
|
+
await expect(mintMachineTokens(CONFIG)).rejects.toBeInstanceOf(CognitoAuthError);
|
|
264
|
+
expect(fs.existsSync(path.join(tmpHome, ".hq", "cognito-tokens.json.lock"))).toBe(false);
|
|
265
|
+
stubMintFetch();
|
|
266
|
+
await expect(mintMachineTokens(CONFIG)).resolves.toBeDefined();
|
|
267
|
+
});
|
|
268
|
+
it("throws when no creds are present", async () => {
|
|
269
|
+
const { mintMachineTokens, CognitoAuthError } = await importModule();
|
|
270
|
+
await expect(mintMachineTokens(CONFIG)).rejects.toBeInstanceOf(CognitoAuthError);
|
|
271
|
+
});
|
|
272
|
+
it.each([
|
|
273
|
+
["wrong entity type", { "custom:entityType": "agent", "custom:entityUid": "agt_OTHER" }],
|
|
274
|
+
["wrong entity uid", { "custom:entityUid": "out_OTHER" }],
|
|
275
|
+
["absent delegatedSub", { "custom:delegatedSub": undefined }],
|
|
276
|
+
["empty delegatedSub", { "custom:delegatedSub": "" }],
|
|
277
|
+
["non-string delegatedSub", { "custom:delegatedSub": 42 }],
|
|
278
|
+
["absent delegatedEmail", { "custom:delegatedEmail": undefined }],
|
|
279
|
+
["empty delegatedEmail", { "custom:delegatedEmail": "" }],
|
|
280
|
+
["non-string delegatedEmail", { "custom:delegatedEmail": 42 }],
|
|
281
|
+
])("rejects and does not cache a first mint with %s", async (_label, claimOverride) => {
|
|
282
|
+
const username = "out-01test@outposts.getindigo.ai";
|
|
283
|
+
writeCreds({
|
|
284
|
+
username,
|
|
285
|
+
secret: "outpost-secret",
|
|
286
|
+
entityType: "outpost",
|
|
287
|
+
entityUid: "out_01TEST",
|
|
288
|
+
});
|
|
289
|
+
const claims = {
|
|
290
|
+
token_use: "id",
|
|
291
|
+
aud: CONFIG.clientId,
|
|
292
|
+
"custom:entityType": "outpost",
|
|
293
|
+
"custom:entityUid": "out_01TEST",
|
|
294
|
+
"custom:delegatedSub": "human-sub",
|
|
295
|
+
"custom:delegatedEmail": "owner@example.com",
|
|
296
|
+
"cognito:username": username,
|
|
297
|
+
sub: "machine-sub",
|
|
298
|
+
...claimOverride,
|
|
299
|
+
};
|
|
300
|
+
for (const [key, value] of Object.entries(claims)) {
|
|
301
|
+
if (value === undefined)
|
|
302
|
+
delete claims[key];
|
|
303
|
+
}
|
|
304
|
+
stubMintFetch({
|
|
305
|
+
AccessToken: fakeJwt({
|
|
306
|
+
token_use: "access",
|
|
307
|
+
client_id: CONFIG.clientId,
|
|
308
|
+
username,
|
|
309
|
+
sub: "machine-sub",
|
|
310
|
+
}),
|
|
311
|
+
IdToken: fakeJwt(claims),
|
|
312
|
+
});
|
|
313
|
+
const { mintMachineTokens, loadCachedMachineTokens, CognitoAuthError } = await importModule();
|
|
314
|
+
await expect(mintMachineTokens(CONFIG)).rejects.toBeInstanceOf(CognitoAuthError);
|
|
315
|
+
expect(loadCachedMachineTokens()).toBeNull();
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
// ---------------------------------------------------------------------------
|
|
319
|
+
// getValidMachineTokens — cache vs re-mint
|
|
320
|
+
// ---------------------------------------------------------------------------
|
|
321
|
+
describe("getValidMachineTokens", () => {
|
|
322
|
+
const cacheWithIdentity = (expiresAt) => ({
|
|
323
|
+
accessToken: fakeJwt({
|
|
324
|
+
token_use: "access",
|
|
325
|
+
client_id: CONFIG.clientId,
|
|
326
|
+
username: "machine-agt_01TEST",
|
|
327
|
+
sub: "machine-sub",
|
|
328
|
+
}),
|
|
329
|
+
idToken: fakeJwt({
|
|
330
|
+
token_use: "id",
|
|
331
|
+
aud: CONFIG.clientId,
|
|
332
|
+
"custom:entityType": "agent",
|
|
333
|
+
"custom:entityUid": "agt_01TEST",
|
|
334
|
+
"cognito:username": "machine-agt_01TEST",
|
|
335
|
+
sub: "machine-sub",
|
|
336
|
+
}),
|
|
337
|
+
refreshToken: "",
|
|
338
|
+
expiresAt,
|
|
339
|
+
tokenType: "Bearer",
|
|
340
|
+
});
|
|
341
|
+
const getMachineTokensWithMinValidity = (get, minValiditySeconds) => get(CONFIG, { minValiditySeconds });
|
|
342
|
+
it("re-mints a hot cached token with 200 seconds left when 360 are required", async () => {
|
|
343
|
+
writeCreds();
|
|
344
|
+
vi.useFakeTimers();
|
|
345
|
+
vi.setSystemTime(new Date("2026-10-02T07:00:00.000Z"));
|
|
346
|
+
const { fetchMock } = stubMintFetch();
|
|
347
|
+
const { saveCachedTokens, getValidMachineTokens } = await importModule();
|
|
348
|
+
saveCachedTokens(cacheWithIdentity(Date.now() + 400_000));
|
|
349
|
+
await getMachineTokensWithMinValidity(getValidMachineTokens, 360);
|
|
350
|
+
await vi.advanceTimersByTimeAsync(200_000);
|
|
351
|
+
await getMachineTokensWithMinValidity(getValidMachineTokens, 360);
|
|
352
|
+
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
353
|
+
});
|
|
354
|
+
it("re-mints a disk-cached token with 200 seconds left under the lock", async () => {
|
|
355
|
+
writeCreds();
|
|
356
|
+
vi.useFakeTimers();
|
|
357
|
+
vi.setSystemTime(new Date("2026-10-02T07:00:00.000Z"));
|
|
358
|
+
const { fetchMock } = stubMintFetch();
|
|
359
|
+
const { saveCachedTokens, getValidMachineTokens } = await importModule();
|
|
360
|
+
saveCachedTokens(cacheWithIdentity(Date.now() + 200_000));
|
|
361
|
+
await getValidMachineTokens(CONFIG);
|
|
362
|
+
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
363
|
+
});
|
|
364
|
+
it("does not reuse a 200-second cache after a machine lock timeout", async () => {
|
|
365
|
+
writeCreds();
|
|
366
|
+
vi.useFakeTimers();
|
|
367
|
+
vi.setSystemTime(new Date("2026-10-02T07:00:00.000Z"));
|
|
368
|
+
const { fetchMock } = stubMintFetch();
|
|
369
|
+
const { saveCachedTokens, getValidMachineTokens, machineTokenCacheFile, CognitoRefreshError } = await importModule();
|
|
370
|
+
saveCachedTokens(cacheWithIdentity(Date.now() + 200_000));
|
|
371
|
+
fs.writeFileSync(`${machineTokenCacheFile()}.lock`, String(process.pid));
|
|
372
|
+
const resolution = getMachineTokensWithMinValidity(getValidMachineTokens, 360);
|
|
373
|
+
const rejected = resolution.then(() => false, (error) => error instanceof CognitoRefreshError);
|
|
374
|
+
await vi.advanceTimersByTimeAsync(20_050);
|
|
375
|
+
expect(await rejected).toBe(true);
|
|
376
|
+
expect(fetchMock).not.toHaveBeenCalled();
|
|
377
|
+
});
|
|
378
|
+
it("reuses a machine token with 400 seconds left when 360 are required", async () => {
|
|
379
|
+
writeCreds();
|
|
380
|
+
vi.useFakeTimers();
|
|
381
|
+
vi.setSystemTime(new Date("2026-10-02T07:00:00.000Z"));
|
|
382
|
+
const { fetchMock } = stubMintFetch();
|
|
383
|
+
const { saveCachedTokens, getValidMachineTokens } = await importModule();
|
|
384
|
+
const cached = cacheWithIdentity(Date.now() + 400_000);
|
|
385
|
+
saveCachedTokens(cached);
|
|
386
|
+
const reused = await getValidMachineTokens(CONFIG);
|
|
387
|
+
expect(reused.expiresAt).toBe(cached.expiresAt);
|
|
388
|
+
expect(fetchMock).not.toHaveBeenCalled();
|
|
389
|
+
});
|
|
390
|
+
it("rejects a required validity above 1800 seconds before any network call", async () => {
|
|
391
|
+
writeCreds();
|
|
392
|
+
const { fetchMock } = stubMintFetch();
|
|
393
|
+
const { getValidMachineTokens } = await importModule();
|
|
394
|
+
await expect(getMachineTokensWithMinValidity(getValidMachineTokens, 1801)).rejects.toThrow(RangeError);
|
|
395
|
+
expect(fetchMock).not.toHaveBeenCalled();
|
|
396
|
+
});
|
|
397
|
+
it("accepts a required validity of exactly 1800 seconds", async () => {
|
|
398
|
+
writeCreds();
|
|
399
|
+
vi.useFakeTimers();
|
|
400
|
+
vi.setSystemTime(new Date("2026-10-02T07:00:00.000Z"));
|
|
401
|
+
const { fetchMock } = stubMintFetch();
|
|
402
|
+
const { saveCachedTokens, getValidMachineTokens } = await importModule();
|
|
403
|
+
const cached = cacheWithIdentity(Date.now() + 1_900_000);
|
|
404
|
+
saveCachedTokens(cached);
|
|
405
|
+
const reused = await getMachineTokensWithMinValidity(getValidMachineTokens, 1800);
|
|
406
|
+
expect(reused.expiresAt).toBe(cached.expiresAt);
|
|
407
|
+
expect(fetchMock).not.toHaveBeenCalled();
|
|
408
|
+
});
|
|
409
|
+
it("returns the cache when valid without touching the network", async () => {
|
|
410
|
+
writeCreds();
|
|
411
|
+
const { fetchMock } = stubMintFetch();
|
|
412
|
+
const { saveCachedTokens, getValidMachineTokens } = await importModule();
|
|
413
|
+
// A valid machine cache must prove this exact agent identity (F06): the
|
|
414
|
+
// cached tokens carry the agent claims that distinguish a machine token
|
|
415
|
+
// from a same-client human token, so cache reuse is safe and skips the wire.
|
|
416
|
+
const cached = {
|
|
417
|
+
accessToken: fakeJwt({
|
|
418
|
+
token_use: "access",
|
|
419
|
+
client_id: CONFIG.clientId,
|
|
420
|
+
username: "machine-agt_01TEST",
|
|
421
|
+
}),
|
|
422
|
+
idToken: fakeJwt({
|
|
423
|
+
token_use: "id",
|
|
424
|
+
aud: CONFIG.clientId,
|
|
425
|
+
"custom:entityType": "agent",
|
|
426
|
+
"custom:entityUid": "agt_01TEST",
|
|
427
|
+
"cognito:username": "machine-agt_01TEST",
|
|
428
|
+
}),
|
|
429
|
+
refreshToken: "",
|
|
430
|
+
expiresAt: Date.now() + 30 * 60 * 1000,
|
|
431
|
+
tokenType: "Bearer",
|
|
432
|
+
};
|
|
433
|
+
saveCachedTokens(cached);
|
|
434
|
+
const tokens = await getValidMachineTokens(CONFIG);
|
|
435
|
+
expect(tokens).toEqual(cached);
|
|
436
|
+
expect(fetchMock).not.toHaveBeenCalled();
|
|
437
|
+
});
|
|
438
|
+
it("strips and persists an empty refresh token when reusing a machine cache", async () => {
|
|
439
|
+
writeCreds();
|
|
440
|
+
const { fetchMock } = stubMintFetch();
|
|
441
|
+
const { saveCachedTokens, loadCachedMachineTokens, getValidMachineTokens } = await importModule();
|
|
442
|
+
saveCachedTokens({
|
|
443
|
+
accessToken: fakeJwt({
|
|
444
|
+
token_use: "access",
|
|
445
|
+
client_id: CONFIG.clientId,
|
|
446
|
+
username: "machine-agt_01TEST",
|
|
447
|
+
sub: "machine-sub",
|
|
448
|
+
}),
|
|
449
|
+
idToken: fakeJwt({
|
|
450
|
+
token_use: "id",
|
|
451
|
+
aud: CONFIG.clientId,
|
|
452
|
+
"custom:entityType": "agent",
|
|
453
|
+
"custom:entityUid": "agt_01TEST",
|
|
454
|
+
"cognito:username": "machine-agt_01TEST",
|
|
455
|
+
sub: "machine-sub",
|
|
456
|
+
}),
|
|
457
|
+
refreshToken: "legacy-machine-refresh-token",
|
|
458
|
+
expiresAt: Date.now() + 30 * 60 * 1000,
|
|
459
|
+
tokenType: "Bearer",
|
|
460
|
+
});
|
|
461
|
+
const tokens = await getValidMachineTokens(CONFIG);
|
|
462
|
+
expect(tokens.refreshToken).toBe("");
|
|
463
|
+
expect(loadCachedMachineTokens()?.refreshToken).toBe("");
|
|
464
|
+
expect(fetchMock).not.toHaveBeenCalled();
|
|
465
|
+
});
|
|
466
|
+
it("re-mints when the cache is expiring", async () => {
|
|
467
|
+
writeCreds();
|
|
468
|
+
const { fetchMock } = stubMintFetch();
|
|
469
|
+
const { saveCachedTokens, getValidMachineTokens } = await importModule();
|
|
470
|
+
saveCachedTokens({
|
|
471
|
+
accessToken: fakeJwt({ token_use: "access", client_id: CONFIG.clientId }),
|
|
472
|
+
idToken: fakeJwt({ token_use: "id" }),
|
|
473
|
+
refreshToken: "",
|
|
474
|
+
expiresAt: Date.now() + 10 * 1000,
|
|
475
|
+
tokenType: "Bearer",
|
|
476
|
+
});
|
|
477
|
+
await getValidMachineTokens(CONFIG);
|
|
478
|
+
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
479
|
+
});
|
|
480
|
+
it("re-mints when the cached token targets a different app client", async () => {
|
|
481
|
+
writeCreds();
|
|
482
|
+
const { fetchMock } = stubMintFetch();
|
|
483
|
+
const { saveCachedTokens, getValidMachineTokens } = await importModule();
|
|
484
|
+
saveCachedTokens({
|
|
485
|
+
accessToken: fakeJwt({ token_use: "access", client_id: "other-client" }),
|
|
486
|
+
idToken: fakeJwt({ token_use: "id" }),
|
|
487
|
+
refreshToken: "",
|
|
488
|
+
expiresAt: Date.now() + 30 * 60 * 1000,
|
|
489
|
+
tokenType: "Bearer",
|
|
490
|
+
});
|
|
491
|
+
await getValidMachineTokens(CONFIG);
|
|
492
|
+
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
493
|
+
});
|
|
494
|
+
it("R-F06: re-mints when cached access and ID tokens belong to different agents", async () => {
|
|
495
|
+
writeCreds();
|
|
496
|
+
const freshAccess = fakeJwt({
|
|
497
|
+
token_use: "access",
|
|
498
|
+
client_id: CONFIG.clientId,
|
|
499
|
+
username: "machine-agt_01TEST",
|
|
500
|
+
sub: "sub-agent-1",
|
|
501
|
+
});
|
|
502
|
+
const freshId = fakeJwt({
|
|
503
|
+
token_use: "id",
|
|
504
|
+
aud: CONFIG.clientId,
|
|
505
|
+
"custom:entityType": "agent",
|
|
506
|
+
"custom:entityUid": "agt_01TEST",
|
|
507
|
+
"cognito:username": "machine-agt_01TEST",
|
|
508
|
+
sub: "sub-agent-1",
|
|
509
|
+
});
|
|
510
|
+
const { fetchMock } = stubMintFetch({
|
|
511
|
+
AccessToken: freshAccess,
|
|
512
|
+
IdToken: freshId,
|
|
513
|
+
});
|
|
514
|
+
const { saveCachedTokens, getValidAccessToken, loadCachedMachineTokens } = await importModule();
|
|
515
|
+
saveCachedTokens({
|
|
516
|
+
accessToken: fakeJwt({
|
|
517
|
+
token_use: "access",
|
|
518
|
+
client_id: CONFIG.clientId,
|
|
519
|
+
username: "machine-agt_01TEST",
|
|
520
|
+
sub: "sub-agent-1",
|
|
521
|
+
}),
|
|
522
|
+
idToken: fakeJwt({
|
|
523
|
+
token_use: "id",
|
|
524
|
+
aud: CONFIG.clientId,
|
|
525
|
+
"custom:entityType": "agent",
|
|
526
|
+
"custom:entityUid": "agt_OTHER",
|
|
527
|
+
"cognito:username": "machine-agt_OTHER",
|
|
528
|
+
sub: "sub-agent-2",
|
|
529
|
+
}),
|
|
530
|
+
refreshToken: "",
|
|
531
|
+
expiresAt: Date.now() + 30 * 60 * 1000,
|
|
532
|
+
tokenType: "Bearer",
|
|
533
|
+
});
|
|
534
|
+
const token = await getValidAccessToken(CONFIG, { interactive: false });
|
|
535
|
+
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
536
|
+
expect(token).toBe(freshId);
|
|
537
|
+
expect(loadCachedMachineTokens()?.idToken).toBe(freshId);
|
|
538
|
+
});
|
|
539
|
+
it("accepts an Outpost machine cache with delegated claims, then re-mints after expiry without OAuth refresh", async () => {
|
|
540
|
+
const username = "out-01test@outposts.getindigo.ai";
|
|
541
|
+
const entityUid = "out_01TEST";
|
|
542
|
+
writeCreds({
|
|
543
|
+
username,
|
|
544
|
+
secret: "outpost-secret",
|
|
545
|
+
clientId: CONFIG.clientId,
|
|
546
|
+
region: CONFIG.region,
|
|
547
|
+
entityType: "outpost",
|
|
548
|
+
entityUid,
|
|
549
|
+
});
|
|
550
|
+
const accessToken = fakeJwt({
|
|
551
|
+
token_use: "access",
|
|
552
|
+
client_id: CONFIG.clientId,
|
|
553
|
+
username,
|
|
554
|
+
sub: "machine-sub",
|
|
555
|
+
});
|
|
556
|
+
const idToken = fakeJwt({
|
|
557
|
+
token_use: "id",
|
|
558
|
+
aud: CONFIG.clientId,
|
|
559
|
+
"custom:entityType": "outpost",
|
|
560
|
+
"custom:entityUid": entityUid,
|
|
561
|
+
"custom:delegatedSub": "human-sub",
|
|
562
|
+
"custom:delegatedEmail": "owner@example.com",
|
|
563
|
+
"cognito:username": username,
|
|
564
|
+
sub: "machine-sub",
|
|
565
|
+
});
|
|
566
|
+
const { fetchMock, calls } = stubMintFetch({
|
|
567
|
+
AccessToken: accessToken,
|
|
568
|
+
IdToken: idToken,
|
|
569
|
+
RefreshToken: "must-not-be-stored",
|
|
570
|
+
});
|
|
571
|
+
const firstModule = await importModule();
|
|
572
|
+
const first = await firstModule.getValidMachineTokens(CONFIG);
|
|
573
|
+
expect(first.idToken).toBe(idToken);
|
|
574
|
+
expect(firstModule.loadCachedMachineTokens()?.refreshToken).toBe("");
|
|
575
|
+
// A new process accepts the shared Outpost cache without another mint.
|
|
576
|
+
vi.resetModules();
|
|
577
|
+
const cacheHitModule = await importModule();
|
|
578
|
+
await expect(cacheHitModule.getValidMachineTokens(CONFIG)).resolves.toEqual(first);
|
|
579
|
+
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
580
|
+
// Once expired, a new process re-mints with the permanent secret. It never
|
|
581
|
+
// attempts the browser client's /oauth2/token refresh-token flow.
|
|
582
|
+
cacheHitModule.saveCachedTokens({
|
|
583
|
+
...first,
|
|
584
|
+
expiresAt: Date.now() - 1,
|
|
585
|
+
});
|
|
586
|
+
vi.resetModules();
|
|
587
|
+
const expiredModule = await importModule();
|
|
588
|
+
await expiredModule.getValidMachineTokens(CONFIG);
|
|
589
|
+
expect(fetchMock).toHaveBeenCalledTimes(2);
|
|
590
|
+
expect(calls.every(({ url }) => !url.includes("/oauth2/token"))).toBe(true);
|
|
591
|
+
for (const { init } of calls) {
|
|
592
|
+
const body = JSON.parse(String(init.body));
|
|
593
|
+
expect(body).toMatchObject({
|
|
594
|
+
AuthFlow: "USER_PASSWORD_AUTH",
|
|
595
|
+
ClientId: CONFIG.clientId,
|
|
596
|
+
AuthParameters: { USERNAME: username, PASSWORD: "outpost-secret" },
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
expect(expiredModule.loadCachedMachineTokens()?.refreshToken).toBe("");
|
|
600
|
+
});
|
|
601
|
+
it.each([
|
|
602
|
+
[
|
|
603
|
+
"entity type",
|
|
604
|
+
{ entityType: "outpost", entityUid: "out_01TEST" },
|
|
605
|
+
"agent",
|
|
606
|
+
"agt_01TEST",
|
|
607
|
+
],
|
|
608
|
+
[
|
|
609
|
+
"entity uid",
|
|
610
|
+
{ entityType: "outpost", entityUid: "out_01TEST" },
|
|
611
|
+
"outpost",
|
|
612
|
+
"out_OTHER",
|
|
613
|
+
],
|
|
614
|
+
])("re-mints when the cached machine %s does not match the creds", async (_label, expectedIdentity, cachedEntityType, cachedEntityUid) => {
|
|
615
|
+
const username = "out-01test@outposts.getindigo.ai";
|
|
616
|
+
writeCreds({
|
|
617
|
+
username,
|
|
618
|
+
secret: "outpost-secret",
|
|
619
|
+
...expectedIdentity,
|
|
620
|
+
});
|
|
621
|
+
const { fetchMock } = stubMintFetch();
|
|
622
|
+
const { saveCachedTokens, getValidMachineTokens } = await importModule();
|
|
623
|
+
saveCachedTokens({
|
|
624
|
+
accessToken: fakeJwt({
|
|
625
|
+
token_use: "access",
|
|
626
|
+
client_id: CONFIG.clientId,
|
|
627
|
+
username,
|
|
628
|
+
sub: "machine-sub",
|
|
629
|
+
}),
|
|
630
|
+
idToken: fakeJwt({
|
|
631
|
+
token_use: "id",
|
|
632
|
+
aud: CONFIG.clientId,
|
|
633
|
+
"custom:entityType": cachedEntityType,
|
|
634
|
+
"custom:entityUid": cachedEntityUid,
|
|
635
|
+
"custom:delegatedSub": "human-sub",
|
|
636
|
+
"custom:delegatedEmail": "owner@example.com",
|
|
637
|
+
"cognito:username": username,
|
|
638
|
+
sub: "machine-sub",
|
|
639
|
+
}),
|
|
640
|
+
refreshToken: "",
|
|
641
|
+
expiresAt: Date.now() + 30 * 60 * 1000,
|
|
642
|
+
tokenType: "Bearer",
|
|
643
|
+
});
|
|
644
|
+
await getValidMachineTokens(CONFIG);
|
|
645
|
+
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
646
|
+
});
|
|
647
|
+
it.each(["custom:delegatedSub", "custom:delegatedEmail"])("re-mints when an Outpost cache is missing %s", async (missingClaim) => {
|
|
648
|
+
const username = "out-01test@outposts.getindigo.ai";
|
|
649
|
+
const outpostClaims = {
|
|
650
|
+
token_use: "id",
|
|
651
|
+
aud: CONFIG.clientId,
|
|
652
|
+
"custom:entityType": "outpost",
|
|
653
|
+
"custom:entityUid": "out_01TEST",
|
|
654
|
+
"custom:delegatedSub": "human-sub",
|
|
655
|
+
"custom:delegatedEmail": "owner@example.com",
|
|
656
|
+
"cognito:username": username,
|
|
657
|
+
sub: "machine-sub",
|
|
658
|
+
};
|
|
659
|
+
delete outpostClaims[missingClaim];
|
|
660
|
+
writeCreds({
|
|
661
|
+
username,
|
|
662
|
+
secret: "outpost-secret",
|
|
663
|
+
entityType: "outpost",
|
|
664
|
+
entityUid: "out_01TEST",
|
|
665
|
+
});
|
|
666
|
+
const { fetchMock } = stubMintFetch();
|
|
667
|
+
const { saveCachedTokens, getValidMachineTokens } = await importModule();
|
|
668
|
+
saveCachedTokens({
|
|
669
|
+
accessToken: fakeJwt({
|
|
670
|
+
token_use: "access",
|
|
671
|
+
client_id: CONFIG.clientId,
|
|
672
|
+
username,
|
|
673
|
+
sub: "machine-sub",
|
|
674
|
+
}),
|
|
675
|
+
idToken: fakeJwt(outpostClaims),
|
|
676
|
+
refreshToken: "",
|
|
677
|
+
expiresAt: Date.now() + 30 * 60 * 1000,
|
|
678
|
+
tokenType: "Bearer",
|
|
679
|
+
});
|
|
680
|
+
await getValidMachineTokens(CONFIG);
|
|
681
|
+
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
682
|
+
});
|
|
683
|
+
it("keeps accepting legacy agent creds without entity fields", async () => {
|
|
684
|
+
writeCreds({ username: "machine-agt_01TEST", secret: "s3cret" });
|
|
685
|
+
const { fetchMock } = stubMintFetch();
|
|
686
|
+
const { saveCachedTokens, getValidMachineTokens } = await importModule();
|
|
687
|
+
const cached = {
|
|
688
|
+
accessToken: fakeJwt({
|
|
689
|
+
token_use: "access",
|
|
690
|
+
client_id: CONFIG.clientId,
|
|
691
|
+
username: "machine-agt_01TEST",
|
|
692
|
+
sub: "machine-sub",
|
|
693
|
+
}),
|
|
694
|
+
idToken: fakeJwt({
|
|
695
|
+
token_use: "id",
|
|
696
|
+
aud: CONFIG.clientId,
|
|
697
|
+
"custom:entityType": "agent",
|
|
698
|
+
"custom:entityUid": "agt_01TEST",
|
|
699
|
+
"cognito:username": "machine-agt_01TEST",
|
|
700
|
+
sub: "machine-sub",
|
|
701
|
+
}),
|
|
702
|
+
refreshToken: "",
|
|
703
|
+
expiresAt: Date.now() + 30 * 60 * 1000,
|
|
704
|
+
tokenType: "Bearer",
|
|
705
|
+
};
|
|
706
|
+
saveCachedTokens(cached);
|
|
707
|
+
await expect(getValidMachineTokens(CONFIG)).resolves.toEqual(cached);
|
|
708
|
+
expect(fetchMock).not.toHaveBeenCalled();
|
|
709
|
+
});
|
|
710
|
+
it("invalidates the memo after the creds file is reprovisioned", async () => {
|
|
711
|
+
writeCreds({
|
|
712
|
+
username: "machine-a",
|
|
713
|
+
secret: "secret-a",
|
|
714
|
+
entityType: "agent",
|
|
715
|
+
entityUid: "agt_A",
|
|
716
|
+
});
|
|
717
|
+
const { fetchMock } = stubMintFetch();
|
|
718
|
+
const { getValidMachineTokens } = await importModule();
|
|
719
|
+
const first = await getValidMachineTokens(CONFIG);
|
|
720
|
+
writeCreds({
|
|
721
|
+
username: "machine-b",
|
|
722
|
+
secret: "secret-b",
|
|
723
|
+
entityType: "outpost",
|
|
724
|
+
entityUid: "out_B",
|
|
725
|
+
});
|
|
726
|
+
const second = await getValidMachineTokens(CONFIG);
|
|
727
|
+
expect(fetchMock).toHaveBeenCalledTimes(2);
|
|
728
|
+
expect(first.idToken).not.toBe(second.idToken);
|
|
729
|
+
expect(JSON.parse(Buffer.from(second.idToken.split(".")[1], "base64url").toString())["custom:entityUid"]).toBe("out_B");
|
|
730
|
+
});
|
|
731
|
+
it("invalidates the memo when legacy creds use a different config client", async () => {
|
|
732
|
+
writeCreds();
|
|
733
|
+
const { fetchMock } = stubMintFetch();
|
|
734
|
+
const { getValidMachineTokens } = await importModule();
|
|
735
|
+
const otherConfig = { ...CONFIG, clientId: "other-client-id" };
|
|
736
|
+
const first = await getValidMachineTokens(CONFIG);
|
|
737
|
+
const second = await getValidMachineTokens(otherConfig);
|
|
738
|
+
expect(fetchMock).toHaveBeenCalledTimes(2);
|
|
739
|
+
expect(first.idToken).not.toBe(second.idToken);
|
|
740
|
+
expect(JSON.parse(Buffer.from(second.idToken.split(".")[1], "base64url").toString()).aud).toBe(otherConfig.clientId);
|
|
741
|
+
});
|
|
742
|
+
it("does not attach a reprovisioned identity to the previous identity's in-flight mint", async () => {
|
|
743
|
+
writeCreds({
|
|
744
|
+
username: "machine-a",
|
|
745
|
+
secret: "secret-a",
|
|
746
|
+
entityType: "agent",
|
|
747
|
+
entityUid: "agt_A",
|
|
748
|
+
});
|
|
749
|
+
let releaseFirstMint;
|
|
750
|
+
const firstMintGate = new Promise((resolve) => {
|
|
751
|
+
releaseFirstMint = resolve;
|
|
752
|
+
});
|
|
753
|
+
let signalFirstMint;
|
|
754
|
+
const firstMintStarted = new Promise((resolve) => {
|
|
755
|
+
signalFirstMint = resolve;
|
|
756
|
+
});
|
|
757
|
+
let callCount = 0;
|
|
758
|
+
const fetchMock = vi.fn(async (_url, init) => {
|
|
759
|
+
callCount += 1;
|
|
760
|
+
const body = JSON.parse(String(init?.body));
|
|
761
|
+
if (callCount === 1) {
|
|
762
|
+
signalFirstMint?.();
|
|
763
|
+
await firstMintGate;
|
|
764
|
+
}
|
|
765
|
+
const username = body.AuthParameters.USERNAME;
|
|
766
|
+
const uid = username === "machine-a" ? "agt_A" : "agt_B";
|
|
767
|
+
return new Response(JSON.stringify({
|
|
768
|
+
AuthenticationResult: {
|
|
769
|
+
AccessToken: fakeJwt({
|
|
770
|
+
token_use: "access",
|
|
771
|
+
client_id: body.ClientId,
|
|
772
|
+
username,
|
|
773
|
+
sub: `sub:${username}`,
|
|
774
|
+
}),
|
|
775
|
+
IdToken: fakeJwt({
|
|
776
|
+
token_use: "id",
|
|
777
|
+
aud: body.ClientId,
|
|
778
|
+
"custom:entityType": "agent",
|
|
779
|
+
"custom:entityUid": uid,
|
|
780
|
+
"cognito:username": username,
|
|
781
|
+
sub: `sub:${username}`,
|
|
782
|
+
}),
|
|
783
|
+
ExpiresIn: 3600,
|
|
784
|
+
},
|
|
785
|
+
}), { status: 200 });
|
|
786
|
+
});
|
|
787
|
+
vi.stubGlobal("fetch", fetchMock);
|
|
788
|
+
const { getValidMachineTokens } = await importModule();
|
|
789
|
+
const first = getValidMachineTokens(CONFIG);
|
|
790
|
+
await firstMintStarted;
|
|
791
|
+
writeCreds({
|
|
792
|
+
username: "machine-b",
|
|
793
|
+
secret: "secret-b",
|
|
794
|
+
entityType: "agent",
|
|
795
|
+
entityUid: "agt_B",
|
|
796
|
+
});
|
|
797
|
+
const second = getValidMachineTokens(CONFIG);
|
|
798
|
+
releaseFirstMint?.();
|
|
799
|
+
const [firstTokens, secondTokens] = await Promise.all([first, second]);
|
|
800
|
+
expect(fetchMock).toHaveBeenCalledTimes(2);
|
|
801
|
+
expect(firstTokens.idToken).not.toBe(secondTokens.idToken);
|
|
802
|
+
expect(JSON.parse(Buffer.from(secondTokens.idToken.split(".")[1], "base64url").toString())["custom:entityUid"]).toBe("agt_B");
|
|
803
|
+
});
|
|
804
|
+
it("reuses only an empty-refresh matching cache after a lock timeout", async () => {
|
|
805
|
+
writeCreds();
|
|
806
|
+
const { fetchMock } = stubMintFetch();
|
|
807
|
+
const { saveCachedTokens, getValidMachineTokens, machineTokenCacheFile } = await importModule();
|
|
808
|
+
const cached = {
|
|
809
|
+
accessToken: fakeJwt({
|
|
810
|
+
token_use: "access",
|
|
811
|
+
client_id: CONFIG.clientId,
|
|
812
|
+
username: "machine-agt_01TEST",
|
|
813
|
+
sub: "machine-sub",
|
|
814
|
+
}),
|
|
815
|
+
idToken: fakeJwt({
|
|
816
|
+
token_use: "id",
|
|
817
|
+
aud: CONFIG.clientId,
|
|
818
|
+
"custom:entityType": "agent",
|
|
819
|
+
"custom:entityUid": "agt_01TEST",
|
|
820
|
+
"cognito:username": "machine-agt_01TEST",
|
|
821
|
+
sub: "machine-sub",
|
|
822
|
+
}),
|
|
823
|
+
refreshToken: "",
|
|
824
|
+
expiresAt: Date.now() + 30 * 60 * 1000,
|
|
825
|
+
tokenType: "Bearer",
|
|
826
|
+
};
|
|
827
|
+
saveCachedTokens(cached);
|
|
828
|
+
// The lock guards the MACHINE cache, which lives beside the creds file,
|
|
829
|
+
// not in the person's ~/.hq (machine-token-cache-isolation.test.ts).
|
|
830
|
+
fs.writeFileSync(`${machineTokenCacheFile()}.lock`, String(process.pid));
|
|
831
|
+
vi.useFakeTimers();
|
|
832
|
+
const resolution = getValidMachineTokens(CONFIG);
|
|
833
|
+
await vi.advanceTimersByTimeAsync(20_050);
|
|
834
|
+
await expect(resolution).resolves.toEqual(cached);
|
|
835
|
+
expect(fetchMock).not.toHaveBeenCalled();
|
|
836
|
+
});
|
|
837
|
+
it("rejects a legacy non-empty-refresh cache after a lock timeout without minting unlocked", async () => {
|
|
838
|
+
writeCreds();
|
|
839
|
+
const { fetchMock } = stubMintFetch();
|
|
840
|
+
const { saveCachedTokens, getValidMachineTokens, machineTokenCacheFile, CognitoAuthError, } = await importModule();
|
|
841
|
+
saveCachedTokens({
|
|
842
|
+
accessToken: fakeJwt({
|
|
843
|
+
token_use: "access",
|
|
844
|
+
client_id: CONFIG.clientId,
|
|
845
|
+
username: "machine-agt_01TEST",
|
|
846
|
+
sub: "machine-sub",
|
|
847
|
+
}),
|
|
848
|
+
idToken: fakeJwt({
|
|
849
|
+
token_use: "id",
|
|
850
|
+
aud: CONFIG.clientId,
|
|
851
|
+
"custom:entityType": "agent",
|
|
852
|
+
"custom:entityUid": "agt_01TEST",
|
|
853
|
+
"cognito:username": "machine-agt_01TEST",
|
|
854
|
+
sub: "machine-sub",
|
|
855
|
+
}),
|
|
856
|
+
refreshToken: "legacy-refresh",
|
|
857
|
+
expiresAt: Date.now() + 30 * 60 * 1000,
|
|
858
|
+
tokenType: "Bearer",
|
|
859
|
+
});
|
|
860
|
+
fs.writeFileSync(`${machineTokenCacheFile()}.lock`, String(process.pid));
|
|
861
|
+
vi.useFakeTimers();
|
|
862
|
+
const resolution = getValidMachineTokens(CONFIG);
|
|
863
|
+
const rejection = expect(resolution).rejects.toBeInstanceOf(CognitoAuthError);
|
|
864
|
+
await vi.advanceTimersByTimeAsync(20_050);
|
|
865
|
+
await rejection;
|
|
866
|
+
expect(fetchMock).not.toHaveBeenCalled();
|
|
867
|
+
});
|
|
868
|
+
});
|
|
869
|
+
// ---------------------------------------------------------------------------
|
|
870
|
+
// Regression: constant token mints over N files (sync-runner mint storm)
|
|
871
|
+
// ---------------------------------------------------------------------------
|
|
872
|
+
//
|
|
873
|
+
// `getValidAccessToken` (→ getValidMachineTokens) is invoked on EVERY vault
|
|
874
|
+
// request a sync makes, including the per-file tombstone HEAD verifies. The
|
|
875
|
+
// 2026-06-26 prod incident was 56 throttled USER_PASSWORD_AUTH mints over 314
|
|
876
|
+
// files on one box: with no in-process memo + single-flight, mints scaled with
|
|
877
|
+
// request count and tripped Cognito's per-user limit. These lock the invariant
|
|
878
|
+
// that mints are O(1) per process, independent of N.
|
|
879
|
+
describe("regression: constant mints regardless of file count", () => {
|
|
880
|
+
it.each([10, 300])("performs exactly ONE token mint across %i sequential file-verify requests", async (n) => {
|
|
881
|
+
writeCreds();
|
|
882
|
+
const { fetchMock } = stubMintFetch();
|
|
883
|
+
const { getValidMachineTokens } = await importModule();
|
|
884
|
+
for (let i = 0; i < n; i++) {
|
|
885
|
+
await getValidMachineTokens(CONFIG);
|
|
886
|
+
}
|
|
887
|
+
// One mint for N requests — NOT proportional to N. The first call mints;
|
|
888
|
+
// every later call is served by the in-process memo (no network).
|
|
889
|
+
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
890
|
+
});
|
|
891
|
+
it.each([10, 300])("collapses a concurrent burst of %i requests onto a SINGLE mint (single-flight)", async (n) => {
|
|
892
|
+
writeCreds();
|
|
893
|
+
const { fetchMock } = stubMintFetch();
|
|
894
|
+
const { getValidMachineTokens } = await importModule();
|
|
895
|
+
// Fire all N at once, as the run-start fan-out does. Without single-flight
|
|
896
|
+
// every concurrent miss would mint and burst the per-user limit.
|
|
897
|
+
const results = await Promise.all(Array.from({ length: n }, () => getValidMachineTokens(CONFIG)));
|
|
898
|
+
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
899
|
+
// All callers observe the same token.
|
|
900
|
+
for (const r of results)
|
|
901
|
+
expect(r).toEqual(results[0]);
|
|
902
|
+
// Follow-up sequential requests stay on the memo — still one mint total.
|
|
903
|
+
await getValidMachineTokens(CONFIG);
|
|
904
|
+
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
905
|
+
});
|
|
906
|
+
it("serializes independent module instances through the shared cache lock", async () => {
|
|
907
|
+
const username = "machine-agt_01TEST";
|
|
908
|
+
writeCreds({
|
|
909
|
+
username,
|
|
910
|
+
secret: "s3cret",
|
|
911
|
+
entityType: "agent",
|
|
912
|
+
entityUid: "agt_01TEST",
|
|
913
|
+
});
|
|
914
|
+
let releaseMint;
|
|
915
|
+
const mintGate = new Promise((resolve) => {
|
|
916
|
+
releaseMint = resolve;
|
|
917
|
+
});
|
|
918
|
+
let signalMintStarted;
|
|
919
|
+
const mintStarted = new Promise((resolve) => {
|
|
920
|
+
signalMintStarted = resolve;
|
|
921
|
+
});
|
|
922
|
+
const accessToken = fakeJwt({
|
|
923
|
+
token_use: "access",
|
|
924
|
+
client_id: CONFIG.clientId,
|
|
925
|
+
username,
|
|
926
|
+
sub: "machine-sub",
|
|
927
|
+
});
|
|
928
|
+
const idToken = fakeJwt({
|
|
929
|
+
token_use: "id",
|
|
930
|
+
aud: CONFIG.clientId,
|
|
931
|
+
"custom:entityType": "agent",
|
|
932
|
+
"custom:entityUid": "agt_01TEST",
|
|
933
|
+
"cognito:username": username,
|
|
934
|
+
sub: "machine-sub",
|
|
935
|
+
});
|
|
936
|
+
const fetchMock = vi.fn(async () => {
|
|
937
|
+
signalMintStarted?.();
|
|
938
|
+
await mintGate;
|
|
939
|
+
return new Response(JSON.stringify({
|
|
940
|
+
AuthenticationResult: {
|
|
941
|
+
AccessToken: accessToken,
|
|
942
|
+
IdToken: idToken,
|
|
943
|
+
RefreshToken: "must-not-be-stored",
|
|
944
|
+
ExpiresIn: 3600,
|
|
945
|
+
},
|
|
946
|
+
}), { status: 200 });
|
|
947
|
+
});
|
|
948
|
+
vi.stubGlobal("fetch", fetchMock);
|
|
949
|
+
const firstProcessModule = await importModule();
|
|
950
|
+
vi.resetModules();
|
|
951
|
+
const secondProcessModule = await importModule();
|
|
952
|
+
const first = firstProcessModule.getValidMachineTokens(CONFIG);
|
|
953
|
+
await mintStarted;
|
|
954
|
+
const second = secondProcessModule.getValidMachineTokens(CONFIG);
|
|
955
|
+
releaseMint?.();
|
|
956
|
+
const [firstTokens, secondTokens] = await Promise.all([first, second]);
|
|
957
|
+
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
958
|
+
expect(secondTokens).toEqual(firstTokens);
|
|
959
|
+
expect(secondProcessModule.loadCachedMachineTokens()?.refreshToken).toBe("");
|
|
960
|
+
});
|
|
961
|
+
it("serializes the exported direct mint API", async () => {
|
|
962
|
+
writeCreds();
|
|
963
|
+
let releaseFirstMint;
|
|
964
|
+
const firstMintGate = new Promise((resolve) => {
|
|
965
|
+
releaseFirstMint = resolve;
|
|
966
|
+
});
|
|
967
|
+
let signalFirstMint;
|
|
968
|
+
const firstMintStarted = new Promise((resolve) => {
|
|
969
|
+
signalFirstMint = resolve;
|
|
970
|
+
});
|
|
971
|
+
let activeMints = 0;
|
|
972
|
+
let maxActiveMints = 0;
|
|
973
|
+
let callCount = 0;
|
|
974
|
+
const accessToken = fakeJwt({
|
|
975
|
+
token_use: "access",
|
|
976
|
+
client_id: CONFIG.clientId,
|
|
977
|
+
username: "machine-agt_01TEST",
|
|
978
|
+
sub: "machine-sub",
|
|
979
|
+
});
|
|
980
|
+
const idToken = fakeJwt({
|
|
981
|
+
token_use: "id",
|
|
982
|
+
aud: CONFIG.clientId,
|
|
983
|
+
"custom:entityType": "agent",
|
|
984
|
+
"custom:entityUid": "agt_01TEST",
|
|
985
|
+
"cognito:username": "machine-agt_01TEST",
|
|
986
|
+
sub: "machine-sub",
|
|
987
|
+
});
|
|
988
|
+
const fetchMock = vi.fn(async () => {
|
|
989
|
+
callCount += 1;
|
|
990
|
+
activeMints += 1;
|
|
991
|
+
maxActiveMints = Math.max(maxActiveMints, activeMints);
|
|
992
|
+
if (callCount === 1) {
|
|
993
|
+
signalFirstMint?.();
|
|
994
|
+
await firstMintGate;
|
|
995
|
+
}
|
|
996
|
+
activeMints -= 1;
|
|
997
|
+
return new Response(JSON.stringify({
|
|
998
|
+
AuthenticationResult: {
|
|
999
|
+
AccessToken: accessToken,
|
|
1000
|
+
IdToken: idToken,
|
|
1001
|
+
ExpiresIn: 3600,
|
|
1002
|
+
},
|
|
1003
|
+
}), { status: 200 });
|
|
1004
|
+
});
|
|
1005
|
+
vi.stubGlobal("fetch", fetchMock);
|
|
1006
|
+
const firstModule = await importModule();
|
|
1007
|
+
vi.resetModules();
|
|
1008
|
+
const secondModule = await importModule();
|
|
1009
|
+
const first = firstModule.mintMachineTokens(CONFIG);
|
|
1010
|
+
await firstMintStarted;
|
|
1011
|
+
const second = secondModule.mintMachineTokens(CONFIG);
|
|
1012
|
+
releaseFirstMint?.();
|
|
1013
|
+
await Promise.all([first, second]);
|
|
1014
|
+
expect(fetchMock).toHaveBeenCalledTimes(2);
|
|
1015
|
+
expect(maxActiveMints).toBe(1);
|
|
1016
|
+
});
|
|
1017
|
+
it("serializes direct mints in actual separate processes", async () => {
|
|
1018
|
+
const moduleUrl = pathToFileURL(path.join(process.cwd(), "src", "cognito-auth.ts")).href;
|
|
1019
|
+
const marker = path.join(tmpHome, "mint-active");
|
|
1020
|
+
const overlap = path.join(tmpHome, "mint-overlap");
|
|
1021
|
+
const start = path.join(tmpHome, "mint-start");
|
|
1022
|
+
const childScript = String.raw `
|
|
1023
|
+
import fs from "fs";
|
|
1024
|
+
const pause = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
1025
|
+
const fakeJwt = (claims) => {
|
|
1026
|
+
const enc = (value) => Buffer.from(JSON.stringify(value)).toString("base64url");
|
|
1027
|
+
return enc({ alg: "none" }) + "." + enc(claims) + ".sig";
|
|
1028
|
+
};
|
|
1029
|
+
const auth = await import(process.env.HQ_LOCK_TEST_MODULE_URL);
|
|
1030
|
+
fs.writeFileSync(process.env.HQ_LOCK_TEST_READY, "ready");
|
|
1031
|
+
while (!fs.existsSync(process.env.HQ_LOCK_TEST_START)) await pause(5);
|
|
1032
|
+
globalThis.fetch = async () => {
|
|
1033
|
+
let ownsMarker = false;
|
|
1034
|
+
try {
|
|
1035
|
+
const fd = fs.openSync(process.env.HQ_LOCK_TEST_MARKER, "wx");
|
|
1036
|
+
fs.closeSync(fd);
|
|
1037
|
+
ownsMarker = true;
|
|
1038
|
+
} catch (error) {
|
|
1039
|
+
if (error.code === "EEXIST") {
|
|
1040
|
+
fs.writeFileSync(process.env.HQ_LOCK_TEST_OVERLAP, "overlap");
|
|
1041
|
+
} else {
|
|
1042
|
+
throw error;
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
await pause(125);
|
|
1046
|
+
if (ownsMarker) fs.unlinkSync(process.env.HQ_LOCK_TEST_MARKER);
|
|
1047
|
+
return new Response(JSON.stringify({ AuthenticationResult: {
|
|
1048
|
+
AccessToken: fakeJwt({ token_use: "access", client_id: "test-client-id", username: "machine", sub: "sub" }),
|
|
1049
|
+
IdToken: fakeJwt({ token_use: "id", aud: "test-client-id", "custom:entityType": "agent", "custom:entityUid": "agt_TEST", "cognito:username": "machine", sub: "sub" }),
|
|
1050
|
+
ExpiresIn: 3600
|
|
1051
|
+
}}), { status: 200 });
|
|
1052
|
+
};
|
|
1053
|
+
await auth.mintMachineTokens(
|
|
1054
|
+
{ region: "us-east-1", userPoolDomain: "unused", clientId: "test-client-id" },
|
|
1055
|
+
{ username: "machine", secret: "secret", entityType: "agent", entityUid: "agt_TEST" },
|
|
1056
|
+
{ baseDelayMs: 0 }
|
|
1057
|
+
);
|
|
1058
|
+
`;
|
|
1059
|
+
const children = ["a", "b"].map((name) => {
|
|
1060
|
+
// Drop FORCE_COLOR/NO_COLOR so child Node processes do not emit the
|
|
1061
|
+
// "NO_COLOR is ignored due to FORCE_COLOR" warning on stderr — that
|
|
1062
|
+
// warning is ambient harness noise and is not a mint failure signal.
|
|
1063
|
+
const childEnv = { ...process.env };
|
|
1064
|
+
delete childEnv.FORCE_COLOR;
|
|
1065
|
+
delete childEnv.NO_COLOR;
|
|
1066
|
+
// Node 22 before type stripping was unflagged (the HQ toolchain ships
|
|
1067
|
+
// 22.17.0) prints an ExperimentalWarning for --experimental-strip-types
|
|
1068
|
+
// on stderr. Silence only that warning class so the empty-stderr check
|
|
1069
|
+
// below still catches every real failure.
|
|
1070
|
+
const child = spawn(process.execPath, [
|
|
1071
|
+
"--experimental-strip-types",
|
|
1072
|
+
"--disable-warning=ExperimentalWarning",
|
|
1073
|
+
"--input-type=module",
|
|
1074
|
+
"-e",
|
|
1075
|
+
childScript,
|
|
1076
|
+
], {
|
|
1077
|
+
cwd: process.cwd(),
|
|
1078
|
+
env: {
|
|
1079
|
+
...childEnv,
|
|
1080
|
+
HOME: tmpHome,
|
|
1081
|
+
HQ_LOCK_TEST_MODULE_URL: moduleUrl,
|
|
1082
|
+
HQ_LOCK_TEST_READY: path.join(tmpHome, `ready-${name}`),
|
|
1083
|
+
HQ_LOCK_TEST_START: start,
|
|
1084
|
+
HQ_LOCK_TEST_MARKER: marker,
|
|
1085
|
+
HQ_LOCK_TEST_OVERLAP: overlap,
|
|
1086
|
+
},
|
|
1087
|
+
});
|
|
1088
|
+
let stderr = "";
|
|
1089
|
+
child.stderr.on("data", (chunk) => {
|
|
1090
|
+
stderr += String(chunk);
|
|
1091
|
+
});
|
|
1092
|
+
return { child, stderr: () => stderr };
|
|
1093
|
+
});
|
|
1094
|
+
const readyPaths = ["a", "b"].map((name) => path.join(tmpHome, `ready-${name}`));
|
|
1095
|
+
const readyDeadline = Date.now() + 5_000;
|
|
1096
|
+
while (!readyPaths.every((readyPath) => fs.existsSync(readyPath)) &&
|
|
1097
|
+
Date.now() < readyDeadline) {
|
|
1098
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
1099
|
+
}
|
|
1100
|
+
expect(readyPaths.every((readyPath) => fs.existsSync(readyPath))).toBe(true);
|
|
1101
|
+
fs.writeFileSync(start, "start");
|
|
1102
|
+
const exits = await Promise.all(children.map(({ child, stderr }) => new Promise((resolve) => {
|
|
1103
|
+
child.on("exit", (code) => resolve({ code, stderr: stderr() }));
|
|
1104
|
+
})));
|
|
1105
|
+
expect(exits).toEqual([
|
|
1106
|
+
{ code: 0, stderr: "" },
|
|
1107
|
+
{ code: 0, stderr: "" },
|
|
1108
|
+
]);
|
|
1109
|
+
expect(fs.existsSync(overlap)).toBe(false);
|
|
1110
|
+
}, 10_000);
|
|
1111
|
+
});
|
|
1112
|
+
// ---------------------------------------------------------------------------
|
|
1113
|
+
// Throttle handling: retry TooManyRequestsException with backoff
|
|
1114
|
+
// ---------------------------------------------------------------------------
|
|
1115
|
+
describe("mintMachineTokens throttle retry", () => {
|
|
1116
|
+
/** Fetch mock that throttles (HTTP 400 + TooManyRequestsException, the shape
|
|
1117
|
+
* Cognito actually returns) for the first `throttleCount` calls, then 200s. */
|
|
1118
|
+
function stubThrottleThenSuccess(throttleCount) {
|
|
1119
|
+
let call = 0;
|
|
1120
|
+
const fetchMock = vi.fn(async () => {
|
|
1121
|
+
call++;
|
|
1122
|
+
if (call <= throttleCount) {
|
|
1123
|
+
return new Response(JSON.stringify({
|
|
1124
|
+
__type: "TooManyRequestsException",
|
|
1125
|
+
message: "Too many requests",
|
|
1126
|
+
}), { status: 400 });
|
|
1127
|
+
}
|
|
1128
|
+
return new Response(JSON.stringify({
|
|
1129
|
+
AuthenticationResult: {
|
|
1130
|
+
AccessToken: fakeJwt({
|
|
1131
|
+
token_use: "access",
|
|
1132
|
+
client_id: CONFIG.clientId,
|
|
1133
|
+
username: "machine-agt_01TEST",
|
|
1134
|
+
sub: "machine-sub",
|
|
1135
|
+
}),
|
|
1136
|
+
IdToken: fakeJwt({
|
|
1137
|
+
token_use: "id",
|
|
1138
|
+
aud: CONFIG.clientId,
|
|
1139
|
+
"custom:entityType": "agent",
|
|
1140
|
+
"custom:entityUid": "agt_01TEST",
|
|
1141
|
+
"cognito:username": "machine-agt_01TEST",
|
|
1142
|
+
sub: "machine-sub",
|
|
1143
|
+
}),
|
|
1144
|
+
ExpiresIn: 3600,
|
|
1145
|
+
},
|
|
1146
|
+
}), { status: 200 });
|
|
1147
|
+
});
|
|
1148
|
+
vi.stubGlobal("fetch", fetchMock);
|
|
1149
|
+
return fetchMock;
|
|
1150
|
+
}
|
|
1151
|
+
it("retries a throttled mint with backoff and eventually succeeds", async () => {
|
|
1152
|
+
writeCreds();
|
|
1153
|
+
const fetchMock = stubThrottleThenSuccess(2);
|
|
1154
|
+
const { mintMachineTokens } = await importModule();
|
|
1155
|
+
// baseDelayMs: 0 keeps the test instant — jitter * 0 == 0.
|
|
1156
|
+
const tokens = await mintMachineTokens(CONFIG, undefined, {
|
|
1157
|
+
baseDelayMs: 0,
|
|
1158
|
+
maxRetries: 5,
|
|
1159
|
+
});
|
|
1160
|
+
expect(fetchMock).toHaveBeenCalledTimes(3); // 2 throttles + 1 success
|
|
1161
|
+
const idClaims = JSON.parse(Buffer.from(tokens.idToken.split(".")[1], "base64url").toString());
|
|
1162
|
+
expect(idClaims.token_use).toBe("id");
|
|
1163
|
+
});
|
|
1164
|
+
it("gives up after maxRetries and throws when throttling never clears", async () => {
|
|
1165
|
+
writeCreds();
|
|
1166
|
+
const fetchMock = stubThrottleThenSuccess(Number.POSITIVE_INFINITY);
|
|
1167
|
+
const { mintMachineTokens, CognitoAuthError } = await importModule();
|
|
1168
|
+
await expect(mintMachineTokens(CONFIG, undefined, { baseDelayMs: 0, maxRetries: 2 })).rejects.toBeInstanceOf(CognitoAuthError);
|
|
1169
|
+
// maxRetries: 2 → 3 total attempts (initial + 2 retries).
|
|
1170
|
+
expect(fetchMock).toHaveBeenCalledTimes(3);
|
|
1171
|
+
});
|
|
1172
|
+
it("does NOT retry a non-throttle auth failure (bad creds fail fast)", async () => {
|
|
1173
|
+
writeCreds();
|
|
1174
|
+
const fetchMock = vi.fn(async () => new Response(JSON.stringify({ __type: "NotAuthorizedException", message: "nope" }), { status: 400 }));
|
|
1175
|
+
vi.stubGlobal("fetch", fetchMock);
|
|
1176
|
+
const { mintMachineTokens, CognitoAuthError } = await importModule();
|
|
1177
|
+
await expect(mintMachineTokens(CONFIG, undefined, { baseDelayMs: 0, maxRetries: 5 })).rejects.toBeInstanceOf(CognitoAuthError);
|
|
1178
|
+
expect(fetchMock).toHaveBeenCalledTimes(1); // no retries
|
|
1179
|
+
});
|
|
1180
|
+
});
|
|
1181
|
+
// ---------------------------------------------------------------------------
|
|
1182
|
+
// getValidAccessToken — machine-mode short circuit
|
|
1183
|
+
// ---------------------------------------------------------------------------
|
|
1184
|
+
describe("getValidAccessToken in machine mode", () => {
|
|
1185
|
+
it("mints via machine creds and returns the ID token (vault-API identity)", async () => {
|
|
1186
|
+
writeCreds();
|
|
1187
|
+
const { calls } = stubMintFetch();
|
|
1188
|
+
const { getValidAccessToken } = await importModule();
|
|
1189
|
+
const token = await getValidAccessToken(CONFIG, { interactive: false });
|
|
1190
|
+
expect(calls).toHaveLength(1);
|
|
1191
|
+
const claims = JSON.parse(Buffer.from(token.split(".")[1], "base64url").toString());
|
|
1192
|
+
// ID, NOT access: agent identity rides the ID token; the access-token
|
|
1193
|
+
// return lobotomized first-sync on the first post-cutover box.
|
|
1194
|
+
expect(claims.token_use).toBe("id");
|
|
1195
|
+
});
|
|
1196
|
+
});
|
|
1197
|
+
// ---------------------------------------------------------------------------
|
|
1198
|
+
// External agents: host-key signed mint (api-contract v1)
|
|
1199
|
+
// ---------------------------------------------------------------------------
|
|
1200
|
+
import { generateKeyPairSync, createPublicKey, verify as cryptoVerify } from "crypto";
|
|
1201
|
+
const EXTERNAL_UID = "agt_01EXTERNAL0000000000000000";
|
|
1202
|
+
const EXTERNAL_API = "https://hqapi.example.test";
|
|
1203
|
+
function writeHostKey() {
|
|
1204
|
+
const dir = path.join(tmpHome, ".hq-agent");
|
|
1205
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
1206
|
+
const { privateKey, publicKey } = generateKeyPairSync("ed25519");
|
|
1207
|
+
const privatePath = path.join(dir, "host-key");
|
|
1208
|
+
fs.writeFileSync(privatePath, privateKey.export({ type: "pkcs8", format: "pem" }), { mode: 0o600 });
|
|
1209
|
+
return {
|
|
1210
|
+
privatePath,
|
|
1211
|
+
publicPem: publicKey.export({ type: "spki", format: "pem" }).toString(),
|
|
1212
|
+
};
|
|
1213
|
+
}
|
|
1214
|
+
function writeExternalCreds(hostKeyPath, overrides = {}) {
|
|
1215
|
+
return writeCreds({
|
|
1216
|
+
username: "agt-01external@agents.getindigo.ai",
|
|
1217
|
+
secret: "s3cret",
|
|
1218
|
+
clientId: "agent-client",
|
|
1219
|
+
region: "us-east-1",
|
|
1220
|
+
entityType: "agent",
|
|
1221
|
+
entityUid: EXTERNAL_UID,
|
|
1222
|
+
runtime: "external",
|
|
1223
|
+
hostKeyPath,
|
|
1224
|
+
apiBaseUrl: EXTERNAL_API,
|
|
1225
|
+
...overrides,
|
|
1226
|
+
});
|
|
1227
|
+
}
|
|
1228
|
+
/**
|
|
1229
|
+
* Fake hq-pro: hands out a nonce, then verifies the Ed25519 signature over
|
|
1230
|
+
* `${uid}.${nonce}` against the enrolled public key before minting.
|
|
1231
|
+
*/
|
|
1232
|
+
function stubExternalMintFetch(opts) {
|
|
1233
|
+
const calls = [];
|
|
1234
|
+
const nonces = new Set();
|
|
1235
|
+
let n = 0;
|
|
1236
|
+
const challengeStatuses = [...(opts.challengeStatus ?? [])];
|
|
1237
|
+
const mintStatuses = [...(opts.mintStatus ?? [])];
|
|
1238
|
+
const fetchMock = vi.fn(async (url, init) => {
|
|
1239
|
+
const u = String(url);
|
|
1240
|
+
calls.push({ url: u, init: init ?? {} });
|
|
1241
|
+
if (u.endsWith("/mint-challenge")) {
|
|
1242
|
+
const forced = challengeStatuses.shift();
|
|
1243
|
+
if (forced && forced !== 200) {
|
|
1244
|
+
return new Response(JSON.stringify({ error: "throttled" }), { status: forced });
|
|
1245
|
+
}
|
|
1246
|
+
const nonce = `nonce-${++n}`;
|
|
1247
|
+
nonces.add(nonce);
|
|
1248
|
+
return new Response(JSON.stringify({ nonce, expiresAt: new Date(Date.now() + 60_000).toISOString() }), { status: 200 });
|
|
1249
|
+
}
|
|
1250
|
+
if (u.endsWith("/mint")) {
|
|
1251
|
+
const forced = mintStatuses.shift();
|
|
1252
|
+
if (forced && forced !== 200) {
|
|
1253
|
+
return new Response(JSON.stringify({ error: "throttled" }), { status: forced });
|
|
1254
|
+
}
|
|
1255
|
+
const body = JSON.parse(String(init?.body));
|
|
1256
|
+
if (opts.rejectCode) {
|
|
1257
|
+
return new Response(JSON.stringify({ code: opts.rejectCode, error: "refused" }), { status: opts.rejectStatus ?? 401 });
|
|
1258
|
+
}
|
|
1259
|
+
if (body.secret !== "s3cret") {
|
|
1260
|
+
return new Response(JSON.stringify({ code: "not_authorized", error: "wrong secret" }), { status: 401 });
|
|
1261
|
+
}
|
|
1262
|
+
if (!nonces.delete(body.nonce)) {
|
|
1263
|
+
return new Response(JSON.stringify({ code: "bad_nonce", error: "unknown nonce" }), { status: 401 });
|
|
1264
|
+
}
|
|
1265
|
+
const ok = cryptoVerify(null, Buffer.from(`${EXTERNAL_UID}.${body.nonce}`), createPublicKey(opts.publicPem), Buffer.from(body.signature, "base64"));
|
|
1266
|
+
if (!ok) {
|
|
1267
|
+
return new Response(JSON.stringify({ code: "bad_signature", error: "signature mismatch" }), { status: 401 });
|
|
1268
|
+
}
|
|
1269
|
+
const clientId = opts.clientId ?? "agent-client";
|
|
1270
|
+
return new Response(JSON.stringify(opts.mintBody ?? {
|
|
1271
|
+
accessToken: fakeJwt({
|
|
1272
|
+
token_use: "access",
|
|
1273
|
+
client_id: clientId,
|
|
1274
|
+
username: "uuid-external",
|
|
1275
|
+
sub: "sub-external",
|
|
1276
|
+
}),
|
|
1277
|
+
idToken: fakeJwt({
|
|
1278
|
+
token_use: "id",
|
|
1279
|
+
aud: clientId,
|
|
1280
|
+
"custom:entityType": "agent",
|
|
1281
|
+
"custom:entityUid": EXTERNAL_UID,
|
|
1282
|
+
"cognito:username": "uuid-external",
|
|
1283
|
+
sub: "sub-external",
|
|
1284
|
+
}),
|
|
1285
|
+
refreshToken: "should-not-be-kept",
|
|
1286
|
+
expiresIn: 3600,
|
|
1287
|
+
}), { status: 200 });
|
|
1288
|
+
}
|
|
1289
|
+
throw new Error(`unexpected fetch ${u}`);
|
|
1290
|
+
});
|
|
1291
|
+
vi.stubGlobal("fetch", fetchMock);
|
|
1292
|
+
return { fetchMock, calls };
|
|
1293
|
+
}
|
|
1294
|
+
describe("external machine creds parsing", () => {
|
|
1295
|
+
it("parses runtime, hostKeyPath and apiBaseUrl", async () => {
|
|
1296
|
+
const { privatePath } = writeHostKey();
|
|
1297
|
+
writeExternalCreds(privatePath);
|
|
1298
|
+
const { loadMachineCreds, isExternalMachineCreds } = await importModule();
|
|
1299
|
+
const creds = loadMachineCreds();
|
|
1300
|
+
expect(creds).toMatchObject({
|
|
1301
|
+
runtime: "external",
|
|
1302
|
+
hostKeyPath: privatePath,
|
|
1303
|
+
apiBaseUrl: EXTERNAL_API,
|
|
1304
|
+
entityType: "agent",
|
|
1305
|
+
entityUid: EXTERNAL_UID,
|
|
1306
|
+
});
|
|
1307
|
+
expect(isExternalMachineCreds(creds)).toBe(true);
|
|
1308
|
+
});
|
|
1309
|
+
it("keeps hosted creds hosted (no runtime field → not external)", async () => {
|
|
1310
|
+
writeCreds({ username: "machine-agt_01TEST", secret: "s3cret" });
|
|
1311
|
+
const { loadMachineCreds, isExternalMachineCreds } = await importModule();
|
|
1312
|
+
const creds = loadMachineCreds();
|
|
1313
|
+
expect(creds?.runtime).toBeUndefined();
|
|
1314
|
+
expect(isExternalMachineCreds(creds)).toBe(false);
|
|
1315
|
+
});
|
|
1316
|
+
it("rejects an external file without hostKeyPath (no silent hosted downgrade)", async () => {
|
|
1317
|
+
writeCreds({
|
|
1318
|
+
username: "u",
|
|
1319
|
+
secret: "s",
|
|
1320
|
+
entityType: "agent",
|
|
1321
|
+
entityUid: EXTERNAL_UID,
|
|
1322
|
+
runtime: "external",
|
|
1323
|
+
});
|
|
1324
|
+
const { loadMachineCreds } = await importModule();
|
|
1325
|
+
expect(loadMachineCreds()).toBeNull();
|
|
1326
|
+
});
|
|
1327
|
+
it("rejects an unknown runtime value", async () => {
|
|
1328
|
+
writeCreds({ username: "u", secret: "s", runtime: "cloud" });
|
|
1329
|
+
const { loadMachineCreds } = await importModule();
|
|
1330
|
+
expect(loadMachineCreds()).toBeNull();
|
|
1331
|
+
});
|
|
1332
|
+
it("honors HQ_MACHINE_CREDS_FILE for external creds too", async () => {
|
|
1333
|
+
const { privatePath } = writeHostKey();
|
|
1334
|
+
const alt = path.join(tmpHome, "elsewhere.json");
|
|
1335
|
+
fs.writeFileSync(alt, JSON.stringify({
|
|
1336
|
+
username: "u",
|
|
1337
|
+
secret: "s",
|
|
1338
|
+
entityType: "agent",
|
|
1339
|
+
entityUid: EXTERNAL_UID,
|
|
1340
|
+
runtime: "external",
|
|
1341
|
+
hostKeyPath: privatePath,
|
|
1342
|
+
}));
|
|
1343
|
+
process.env.HQ_MACHINE_CREDS_FILE = alt;
|
|
1344
|
+
const { loadMachineCreds, externalMintApiBaseUrl } = await importModule();
|
|
1345
|
+
const creds = loadMachineCreds();
|
|
1346
|
+
expect(creds?.runtime).toBe("external");
|
|
1347
|
+
// No apiBaseUrl in the file → env → default, trailing slash trimmed.
|
|
1348
|
+
process.env.HQ_VAULT_API_URL = "https://alt.example.test/";
|
|
1349
|
+
expect(externalMintApiBaseUrl(creds)).toBe("https://alt.example.test");
|
|
1350
|
+
delete process.env.HQ_VAULT_API_URL;
|
|
1351
|
+
expect(externalMintApiBaseUrl(creds)).toBe("https://hqapi.hq.computer");
|
|
1352
|
+
});
|
|
1353
|
+
});
|
|
1354
|
+
describe("signExternalMintChallenge", () => {
|
|
1355
|
+
it("produces a base64 Ed25519 signature over `${uid}.${nonce}`", async () => {
|
|
1356
|
+
const { privatePath, publicPem } = writeHostKey();
|
|
1357
|
+
const { signExternalMintChallenge, externalMintChallengeMessage } = await importModule();
|
|
1358
|
+
const sig = signExternalMintChallenge(fs.readFileSync(privatePath), EXTERNAL_UID, "abc");
|
|
1359
|
+
expect(externalMintChallengeMessage(EXTERNAL_UID, "abc")).toBe(`${EXTERNAL_UID}.abc`);
|
|
1360
|
+
expect(cryptoVerify(null, Buffer.from(`${EXTERNAL_UID}.abc`), createPublicKey(publicPem), Buffer.from(sig, "base64"))).toBe(true);
|
|
1361
|
+
// A different nonce must not verify with the same signature.
|
|
1362
|
+
expect(cryptoVerify(null, Buffer.from(`${EXTERNAL_UID}.abd`), createPublicKey(publicPem), Buffer.from(sig, "base64"))).toBe(false);
|
|
1363
|
+
});
|
|
1364
|
+
it("refuses a non-Ed25519 key", async () => {
|
|
1365
|
+
const { signExternalMintChallenge, CognitoAuthError } = await importModule();
|
|
1366
|
+
const { privateKey } = generateKeyPairSync("rsa", { modulusLength: 2048 });
|
|
1367
|
+
expect(() => signExternalMintChallenge(privateKey.export({ type: "pkcs8", format: "pem" }), EXTERNAL_UID, "n")).toThrow(CognitoAuthError);
|
|
1368
|
+
});
|
|
1369
|
+
});
|
|
1370
|
+
describe("mintMachineTokens for external agents", () => {
|
|
1371
|
+
it("challenges, signs, mints through hq-pro and never calls Cognito", async () => {
|
|
1372
|
+
const { privatePath, publicPem } = writeHostKey();
|
|
1373
|
+
writeExternalCreds(privatePath);
|
|
1374
|
+
const { calls } = stubExternalMintFetch({ publicPem });
|
|
1375
|
+
const { mintMachineTokens, loadCachedMachineTokens } = await importModule();
|
|
1376
|
+
const tokens = await mintMachineTokens(CONFIG, undefined, { baseDelayMs: 0 });
|
|
1377
|
+
expect(calls.map((c) => c.url)).toEqual([
|
|
1378
|
+
`${EXTERNAL_API}/v1/agents/${EXTERNAL_UID}/mint-challenge`,
|
|
1379
|
+
`${EXTERNAL_API}/v1/agents/${EXTERNAL_UID}/mint`,
|
|
1380
|
+
]);
|
|
1381
|
+
expect(calls.every((c) => !c.url.includes("cognito-idp"))).toBe(true);
|
|
1382
|
+
// The challenge carries nothing; the mint carries nonce + signature +
|
|
1383
|
+
// the machine secret (hq-pro runs USER_PASSWORD_AUTH with it).
|
|
1384
|
+
expect(String(calls[0].init.body)).toBe("{}");
|
|
1385
|
+
const mintBody = JSON.parse(String(calls[1].init.body));
|
|
1386
|
+
expect(mintBody).toEqual({ nonce: "nonce-1", signature: expect.any(String), secret: "s3cret" });
|
|
1387
|
+
expect(tokens.refreshToken).toBe("");
|
|
1388
|
+
const claims = JSON.parse(Buffer.from(tokens.idToken.split(".")[1], "base64url").toString());
|
|
1389
|
+
expect(claims["custom:entityUid"]).toBe(EXTERNAL_UID);
|
|
1390
|
+
expect(loadCachedMachineTokens()?.idToken).toBe(tokens.idToken);
|
|
1391
|
+
});
|
|
1392
|
+
it("getValidMachineTokens routes external creds through the signed mint", async () => {
|
|
1393
|
+
const { privatePath, publicPem } = writeHostKey();
|
|
1394
|
+
writeExternalCreds(privatePath);
|
|
1395
|
+
const { calls } = stubExternalMintFetch({ publicPem });
|
|
1396
|
+
const { getValidMachineTokens } = await importModule();
|
|
1397
|
+
await getValidMachineTokens(CONFIG);
|
|
1398
|
+
await getValidMachineTokens(CONFIG);
|
|
1399
|
+
// One challenge + one mint; the second call is served from the memo.
|
|
1400
|
+
expect(calls).toHaveLength(2);
|
|
1401
|
+
});
|
|
1402
|
+
it("surfaces hq-pro's 401 code (bad_signature) as a hard CognitoAuthError", async () => {
|
|
1403
|
+
const { privatePath } = writeHostKey();
|
|
1404
|
+
const other = generateKeyPairSync("ed25519").publicKey
|
|
1405
|
+
.export({ type: "spki", format: "pem" })
|
|
1406
|
+
.toString();
|
|
1407
|
+
writeExternalCreds(privatePath);
|
|
1408
|
+
const { calls } = stubExternalMintFetch({ publicPem: other });
|
|
1409
|
+
const { mintMachineTokens, CognitoAuthError } = await importModule();
|
|
1410
|
+
await expect(mintMachineTokens(CONFIG, undefined, { baseDelayMs: 0 })).rejects.toThrow(/External machine token mint failed \(401\) bad_signature/);
|
|
1411
|
+
await expect(mintMachineTokens(CONFIG, undefined, { baseDelayMs: 0 })).rejects.toBeInstanceOf(CognitoAuthError);
|
|
1412
|
+
// No retry on a hard refusal: each attempt is exactly challenge + mint.
|
|
1413
|
+
expect(calls.filter((c) => c.url.endsWith("/mint"))).toHaveLength(2);
|
|
1414
|
+
});
|
|
1415
|
+
it("surfaces revoked / not_authorized / agent_not_found without retrying", async () => {
|
|
1416
|
+
const { privatePath, publicPem } = writeHostKey();
|
|
1417
|
+
for (const [code, status] of [["revoked", 401], ["not_authorized", 401], ["agent_not_found", 404]]) {
|
|
1418
|
+
writeExternalCreds(privatePath);
|
|
1419
|
+
const { calls } = stubExternalMintFetch({ publicPem, rejectCode: code, rejectStatus: status });
|
|
1420
|
+
const { mintMachineTokens } = await importModule();
|
|
1421
|
+
await expect(mintMachineTokens(CONFIG, undefined, { baseDelayMs: 0 })).rejects.toThrow(new RegExp(`\\(${status}\\) ${code}`));
|
|
1422
|
+
expect(calls).toHaveLength(2);
|
|
1423
|
+
vi.resetModules();
|
|
1424
|
+
}
|
|
1425
|
+
});
|
|
1426
|
+
it("a wrong machine secret is refused as not_authorized", async () => {
|
|
1427
|
+
const { privatePath, publicPem } = writeHostKey();
|
|
1428
|
+
writeExternalCreds(privatePath, { secret: "stale" });
|
|
1429
|
+
stubExternalMintFetch({ publicPem });
|
|
1430
|
+
const { mintMachineTokens } = await importModule();
|
|
1431
|
+
await expect(mintMachineTokens(CONFIG)).rejects.toThrow(/\(401\) not_authorized/);
|
|
1432
|
+
});
|
|
1433
|
+
it("retries a throttled challenge and a throttled mint, then succeeds", async () => {
|
|
1434
|
+
const { privatePath, publicPem } = writeHostKey();
|
|
1435
|
+
writeExternalCreds(privatePath);
|
|
1436
|
+
const { calls } = stubExternalMintFetch({
|
|
1437
|
+
publicPem,
|
|
1438
|
+
challengeStatus: [429, 200, 200],
|
|
1439
|
+
mintStatus: [429, 200],
|
|
1440
|
+
});
|
|
1441
|
+
const { mintMachineTokens } = await importModule();
|
|
1442
|
+
await mintMachineTokens(CONFIG, undefined, { baseDelayMs: 0, maxRetries: 3 });
|
|
1443
|
+
expect(calls.filter((c) => c.url.endsWith("/mint-challenge"))).toHaveLength(3);
|
|
1444
|
+
expect(calls.filter((c) => c.url.endsWith("/mint"))).toHaveLength(2);
|
|
1445
|
+
});
|
|
1446
|
+
it("fails with an actionable error when the host key is missing", async () => {
|
|
1447
|
+
const missing = path.join(tmpHome, ".hq-agent", "host-key");
|
|
1448
|
+
writeExternalCreds(missing);
|
|
1449
|
+
const { fetchMock } = stubExternalMintFetch({ publicPem: "" });
|
|
1450
|
+
const { mintMachineTokens } = await importModule();
|
|
1451
|
+
await expect(mintMachineTokens(CONFIG)).rejects.toThrow(/Cannot read host key .*--replace/);
|
|
1452
|
+
expect(fetchMock).not.toHaveBeenCalled();
|
|
1453
|
+
});
|
|
1454
|
+
it("rejects tokens that do not match the enrolled identity", async () => {
|
|
1455
|
+
const { privatePath, publicPem } = writeHostKey();
|
|
1456
|
+
writeExternalCreds(privatePath);
|
|
1457
|
+
stubExternalMintFetch({
|
|
1458
|
+
publicPem,
|
|
1459
|
+
mintBody: {
|
|
1460
|
+
accessToken: fakeJwt({ token_use: "access", client_id: "agent-client", username: "x", sub: "x" }),
|
|
1461
|
+
idToken: fakeJwt({
|
|
1462
|
+
token_use: "id",
|
|
1463
|
+
aud: "agent-client",
|
|
1464
|
+
"custom:entityType": "agent",
|
|
1465
|
+
"custom:entityUid": "agt_01SOMEONEELSE000000000000",
|
|
1466
|
+
"cognito:username": "x",
|
|
1467
|
+
sub: "x",
|
|
1468
|
+
}),
|
|
1469
|
+
expiresIn: 3600,
|
|
1470
|
+
},
|
|
1471
|
+
});
|
|
1472
|
+
const { mintMachineTokens } = await importModule();
|
|
1473
|
+
await expect(mintMachineTokens(CONFIG)).rejects.toThrow(/do not match the requested machine identity/);
|
|
1474
|
+
});
|
|
1475
|
+
it("hosted creds still mint straight against Cognito (path untouched)", async () => {
|
|
1476
|
+
writeCreds({
|
|
1477
|
+
username: "agt-01hosted@agents.getindigo.ai",
|
|
1478
|
+
secret: "s3cret",
|
|
1479
|
+
clientId: "agent-client",
|
|
1480
|
+
region: "us-east-1",
|
|
1481
|
+
entityType: "agent",
|
|
1482
|
+
entityUid: "agt_01TEST",
|
|
1483
|
+
runtime: "hosted",
|
|
1484
|
+
});
|
|
1485
|
+
const { calls } = stubMintFetch();
|
|
1486
|
+
const { mintMachineTokens } = await importModule();
|
|
1487
|
+
await mintMachineTokens(CONFIG);
|
|
1488
|
+
expect(calls).toHaveLength(1);
|
|
1489
|
+
expect(calls[0].url).toBe("https://cognito-idp.us-east-1.amazonaws.com/");
|
|
1490
|
+
});
|
|
1491
|
+
});
|
|
1492
|
+
//# sourceMappingURL=machine-auth.test.js.map
|