@shipfox/api-workflows 7.0.2 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/.turbo/turbo-build.log +15 -15
  2. package/CHANGELOG.md +32 -0
  3. package/dist/core/agent-defaults.d.ts +2 -1
  4. package/dist/core/agent-defaults.d.ts.map +1 -1
  5. package/dist/core/agent-defaults.js.map +1 -1
  6. package/dist/core/agent-tools.d.ts +3 -2
  7. package/dist/core/agent-tools.d.ts.map +1 -1
  8. package/dist/core/agent-tools.js.map +1 -1
  9. package/dist/core/checkout.d.ts +2 -2
  10. package/dist/core/checkout.d.ts.map +1 -1
  11. package/dist/core/checkout.js.map +1 -1
  12. package/dist/core/entities/step.d.ts +2 -1
  13. package/dist/core/entities/step.d.ts.map +1 -1
  14. package/dist/core/entities/step.js.map +1 -1
  15. package/dist/core/run-workflow.d.ts +2 -2
  16. package/dist/core/run-workflow.d.ts.map +1 -1
  17. package/dist/core/run-workflow.js.map +1 -1
  18. package/dist/core/step-config/agent.d.ts +1 -1
  19. package/dist/core/step-config/agent.d.ts.map +1 -1
  20. package/dist/core/step-config/agent.js.map +1 -1
  21. package/dist/db/job-listeners.d.ts +2 -2
  22. package/dist/db/job-listeners.d.ts.map +1 -1
  23. package/dist/db/job-listeners.js.map +1 -1
  24. package/dist/db/workflow-runs/run-create.d.ts +2 -2
  25. package/dist/db/workflow-runs/run-create.d.ts.map +1 -1
  26. package/dist/db/workflow-runs/run-create.js.map +1 -1
  27. package/dist/index.d.ts +2 -2
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js.map +1 -1
  30. package/dist/presentation/inter-module.d.ts +2 -2
  31. package/dist/presentation/inter-module.d.ts.map +1 -1
  32. package/dist/presentation/inter-module.js +2 -1
  33. package/dist/presentation/inter-module.js.map +1 -1
  34. package/dist/presentation/routes/cancel-run.d.ts +1 -1
  35. package/dist/presentation/routes/cancel-run.d.ts.map +1 -1
  36. package/dist/presentation/routes/cancel-run.js.map +1 -1
  37. package/dist/presentation/routes/checkout-token.d.ts +2 -2
  38. package/dist/presentation/routes/checkout-token.d.ts.map +1 -1
  39. package/dist/presentation/routes/checkout-token.js +1 -1
  40. package/dist/presentation/routes/checkout-token.js.map +1 -1
  41. package/dist/presentation/routes/get-run-aggregates.d.ts +1 -1
  42. package/dist/presentation/routes/get-run-aggregates.d.ts.map +1 -1
  43. package/dist/presentation/routes/get-run-aggregates.js.map +1 -1
  44. package/dist/presentation/routes/get-run.d.ts +1 -1
  45. package/dist/presentation/routes/get-run.d.ts.map +1 -1
  46. package/dist/presentation/routes/get-run.js.map +1 -1
  47. package/dist/presentation/routes/index.d.ts +2 -2
  48. package/dist/presentation/routes/index.d.ts.map +1 -1
  49. package/dist/presentation/routes/index.js.map +1 -1
  50. package/dist/presentation/routes/list-run-attempts.d.ts +1 -1
  51. package/dist/presentation/routes/list-run-attempts.d.ts.map +1 -1
  52. package/dist/presentation/routes/list-run-attempts.js.map +1 -1
  53. package/dist/presentation/routes/list-runs.d.ts +1 -1
  54. package/dist/presentation/routes/list-runs.d.ts.map +1 -1
  55. package/dist/presentation/routes/list-runs.js.map +1 -1
  56. package/dist/presentation/routes/project-access.d.ts +1 -1
  57. package/dist/presentation/routes/project-access.d.ts.map +1 -1
  58. package/dist/presentation/routes/project-access.js.map +1 -1
  59. package/dist/presentation/routes/require-accessible-run.d.ts +1 -1
  60. package/dist/presentation/routes/require-accessible-run.d.ts.map +1 -1
  61. package/dist/presentation/routes/require-accessible-run.js.map +1 -1
  62. package/dist/presentation/routes/rerun-run.d.ts +1 -1
  63. package/dist/presentation/routes/rerun-run.d.ts.map +1 -1
  64. package/dist/presentation/routes/rerun-run.js.map +1 -1
  65. package/dist/temporal/activities/index.d.ts +2 -2
  66. package/dist/temporal/activities/index.d.ts.map +1 -1
  67. package/dist/temporal/activities/index.js.map +1 -1
  68. package/dist/temporal/activities/orchestration-activities.d.ts +2 -2
  69. package/dist/temporal/activities/orchestration-activities.d.ts.map +1 -1
  70. package/dist/temporal/activities/orchestration-activities.js.map +1 -1
  71. package/dist/temporal/workflows/index.bundle.js +17212 -3354
  72. package/dist/tsconfig.test.tsbuildinfo +1 -1
  73. package/package.json +15 -15
  74. package/src/core/agent-defaults.ts +2 -1
  75. package/src/core/agent-tool-capability-warning.test.ts +1 -1
  76. package/src/core/agent-tools.ts +2 -2
  77. package/src/core/checkout.test.ts +2 -2
  78. package/src/core/checkout.ts +2 -2
  79. package/src/core/entities/step.ts +1 -2
  80. package/src/core/run-workflow.test.ts +2 -0
  81. package/src/core/run-workflow.ts +2 -2
  82. package/src/core/step-config/agent.ts +1 -1
  83. package/src/core/step-config/materialize-workflow-model.test.ts +11 -2
  84. package/src/db/job-listeners.ts +2 -2
  85. package/src/db/workflow-runs/run-create.test.ts +11 -2
  86. package/src/db/workflow-runs/run-create.ts +2 -2
  87. package/src/index.ts +2 -2
  88. package/src/presentation/inter-module.ts +4 -7
  89. package/src/presentation/routes/agent-runtime-config.test.ts +2 -35
  90. package/src/presentation/routes/cancel-run.test.ts +1 -1
  91. package/src/presentation/routes/cancel-run.ts +1 -1
  92. package/src/presentation/routes/checkout-token.test.ts +4 -37
  93. package/src/presentation/routes/checkout-token.ts +2 -2
  94. package/src/presentation/routes/get-run-aggregates.test.ts +1 -1
  95. package/src/presentation/routes/get-run-aggregates.ts +1 -1
  96. package/src/presentation/routes/get-run.test.ts +1 -1
  97. package/src/presentation/routes/get-run.ts +1 -1
  98. package/src/presentation/routes/get-step-secrets.test.ts +2 -2
  99. package/src/presentation/routes/index.test.ts +3 -3
  100. package/src/presentation/routes/index.ts +2 -2
  101. package/src/presentation/routes/list-run-attempts.test.ts +1 -1
  102. package/src/presentation/routes/list-run-attempts.ts +1 -1
  103. package/src/presentation/routes/list-runs.test.ts +1 -1
  104. package/src/presentation/routes/list-runs.ts +1 -1
  105. package/src/presentation/routes/next-step.test.ts +9 -57
  106. package/src/presentation/routes/project-access.ts +1 -1
  107. package/src/presentation/routes/report-step.test.ts +2 -3
  108. package/src/presentation/routes/require-accessible-run.ts +1 -1
  109. package/src/presentation/routes/rerun-run.test.ts +1 -1
  110. package/src/presentation/routes/rerun-run.ts +1 -1
  111. package/src/temporal/activities/index.ts +2 -2
  112. package/src/temporal/activities/orchestration-activities.ts +2 -2
  113. package/test/fixtures/agent-inter-module.ts +31 -1
  114. package/test/fixtures/auth-inter-module.ts +2 -13
  115. package/test/fixtures/lease-token.ts +43 -29
  116. package/test/fixtures/projects-inter-module.ts +1 -1
  117. package/tsconfig.build.tsbuildinfo +1 -1
@@ -1,5 +1,4 @@
1
1
  import type {AnnotationsInterModuleClient} from '@shipfox/annotations-dto/inter-module';
2
- import {createLeaseTokenAuthMethod, verifyJobLeaseToken} from '@shipfox/api-auth';
3
2
  import {closeApp, createApp, type FastifyInstance} from '@shipfox/node-fastify';
4
3
  import {eq, sql} from 'drizzle-orm';
5
4
  import {JobNotFoundError} from '#core/errors.js';
@@ -16,7 +15,11 @@ import {insertRunningJobLease, mintActiveLeaseToken} from '#test/fixtures/active
16
15
  import {agentTestClient} from '#test/fixtures/agent-inter-module.js';
17
16
  import {workflowsTestAuthClient} from '#test/fixtures/auth-inter-module.js';
18
17
  import {arrangeJobWithSteps} from '#test/fixtures/job-with-steps.js';
19
- import {mintLeaseToken} from '#test/fixtures/lease-token.js';
18
+ import {
19
+ fakeLeaseTokenAuthMethod,
20
+ getLeaseTokenClaims,
21
+ mintLeaseToken,
22
+ } from '#test/fixtures/lease-token.js';
20
23
  import {projectsTestClient} from '#test/fixtures/projects-inter-module.js';
21
24
  import {runnersTestClient} from '#test/fixtures/runners-inter-module.js';
22
25
  import {createTestSecretsClient} from '#test/fixtures/secrets-inter-module.js';
@@ -58,7 +61,7 @@ describe('POST /runs/jobs/current/steps/next', () => {
58
61
 
59
62
  beforeAll(async () => {
60
63
  app = await createApp({
61
- auth: [createLeaseTokenAuthMethod()],
64
+ auth: [fakeLeaseTokenAuthMethod],
62
65
  routes: [
63
66
  createLeaseTokenRouteGroup({
64
67
  agent: agentTestClient,
@@ -108,57 +111,6 @@ describe('POST /runs/jobs/current/steps/next', () => {
108
111
  expect(res.statusCode).toBe(401);
109
112
  expect(res.json().code).toBe('unauthorized');
110
113
  });
111
-
112
- test('rejects an expired token', async () => {
113
- const token = await mintLeaseToken({
114
- jobId: crypto.randomUUID(),
115
- jobExecutionId: crypto.randomUUID(),
116
- expiresIn: '-1s',
117
- });
118
-
119
- const res = await app.inject({
120
- method: 'POST',
121
- url: URL,
122
- headers: {authorization: `Bearer ${token}`},
123
- });
124
-
125
- expect(res.statusCode).toBe(401);
126
- expect(res.json().code).toBe('unauthorized');
127
- });
128
-
129
- test('rejects a token signed with the wrong secret', async () => {
130
- const token = await mintLeaseToken({
131
- jobId: crypto.randomUUID(),
132
- jobExecutionId: crypto.randomUUID(),
133
- secret: 'wrong-secret',
134
- });
135
-
136
- const res = await app.inject({
137
- method: 'POST',
138
- url: URL,
139
- headers: {authorization: `Bearer ${token}`},
140
- });
141
-
142
- expect(res.statusCode).toBe(401);
143
- expect(res.json().code).toBe('unauthorized');
144
- });
145
-
146
- test('rejects a token with the wrong audience (e.g. a user JWT)', async () => {
147
- const token = await mintLeaseToken({
148
- jobId: crypto.randomUUID(),
149
- jobExecutionId: crypto.randomUUID(),
150
- audience: 'user-session',
151
- });
152
-
153
- const res = await app.inject({
154
- method: 'POST',
155
- url: URL,
156
- headers: {authorization: `Bearer ${token}`},
157
- });
158
-
159
- expect(res.statusCode).toBe(401);
160
- expect(res.json().code).toBe('unauthorized');
161
- });
162
114
  });
163
115
 
164
116
  test('returns the lowest-position pending step and marks it running', async () => {
@@ -177,7 +129,7 @@ describe('POST /runs/jobs/current/steps/next', () => {
177
129
  expect(body.step.id).toBe(steps[0]?.id);
178
130
  expect(body.step.status).toBe('running');
179
131
  expect(body.lease_token).toEqual(expect.any(String));
180
- const scopedLease = await verifyJobLeaseToken(body.lease_token);
132
+ const scopedLease = getLeaseTokenClaims(body.lease_token);
181
133
  expect(scopedLease).toMatchObject({
182
134
  jobId,
183
135
  jobExecutionId: steps[0]?.jobExecutionId,
@@ -228,7 +180,7 @@ describe('POST /runs/jobs/current/steps/next', () => {
228
180
  })
229
181
  .where(eq(stepsTable.id, steps[0]?.id as string));
230
182
  const token = await mintActiveLeaseToken({jobId});
231
- const lease = await verifyJobLeaseToken(token);
183
+ const lease = getLeaseTokenClaims(token);
232
184
  if (!lease) throw new Error('Expected minted lease token to verify');
233
185
  await setRunnerToolCapabilities(lease.runnerSessionId, {harnesses: {pi: {tools: ['read']}}});
234
186
 
@@ -378,7 +330,7 @@ describe('POST /runs/jobs/current/steps/next', () => {
378
330
  expect(res.statusCode).toBe(200);
379
331
  const body = res.json();
380
332
  expect(body.attempt).toBe(2);
381
- const scopedLease = await verifyJobLeaseToken(body.lease_token);
333
+ const scopedLease = getLeaseTokenClaims(body.lease_token);
382
334
  expect(scopedLease?.currentStepId).toBe(steps[0]?.id);
383
335
  expect(scopedLease?.currentStepAttempt).toBe(body.attempt);
384
336
  });
@@ -1,5 +1,5 @@
1
1
  import {requireWorkspaceAccess} from '@shipfox/api-auth-context';
2
- import type {ProjectsModuleClient} from '@shipfox/api-projects-dto';
2
+ import type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';
3
3
  import {ClientError} from '@shipfox/node-fastify';
4
4
  import type {FastifyRequest} from 'fastify';
5
5
 
@@ -1,4 +1,3 @@
1
- import {createLeaseTokenAuthMethod} from '@shipfox/api-auth';
2
1
  import {closeApp, createApp, type FastifyInstance} from '@shipfox/node-fastify';
3
2
  import {nextStepForJob} from '#core/job-execution.js';
4
3
  import {
@@ -13,7 +12,7 @@ import {agentTestClient} from '#test/fixtures/agent-inter-module.js';
13
12
  import {annotationsTestClient} from '#test/fixtures/annotations-inter-module.js';
14
13
  import {workflowsTestAuthClient} from '#test/fixtures/auth-inter-module.js';
15
14
  import {arrangeJobWithSteps} from '#test/fixtures/job-with-steps.js';
16
- import {mintLeaseToken} from '#test/fixtures/lease-token.js';
15
+ import {fakeLeaseTokenAuthMethod, mintLeaseToken} from '#test/fixtures/lease-token.js';
17
16
  import {projectsTestClient} from '#test/fixtures/projects-inter-module.js';
18
17
  import {runnersTestClient} from '#test/fixtures/runners-inter-module.js';
19
18
  import {createTestSecretsClient} from '#test/fixtures/secrets-inter-module.js';
@@ -32,7 +31,7 @@ describe('POST /runs/jobs/current/steps/:stepId/report', () => {
32
31
 
33
32
  beforeAll(async () => {
34
33
  app = await createApp({
35
- auth: [createLeaseTokenAuthMethod()],
34
+ auth: [fakeLeaseTokenAuthMethod],
36
35
  routes: [
37
36
  createLeaseTokenRouteGroup({
38
37
  agent: agentTestClient,
@@ -1,4 +1,4 @@
1
- import type {ProjectsModuleClient} from '@shipfox/api-projects-dto';
1
+ import type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';
2
2
  import {ClientError} from '@shipfox/node-fastify';
3
3
  import type {FastifyRequest} from 'fastify';
4
4
  import type {WorkflowRun} from '#core/entities/workflow-run.js';
@@ -1,5 +1,5 @@
1
1
  import {buildUserContext, setUserContext} from '@shipfox/api-auth-context';
2
- import type {ProjectsModuleClient} from '@shipfox/api-projects-dto';
2
+ import type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';
3
3
  import {ClientError} from '@shipfox/node-fastify';
4
4
  import type {FastifyInstance} from 'fastify';
5
5
  import Fastify from 'fastify';
@@ -1,5 +1,5 @@
1
1
  import {requireUserContext} from '@shipfox/api-auth-context';
2
- import type {ProjectsModuleClient} from '@shipfox/api-projects-dto';
2
+ import type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';
3
3
  import {rerunWorkflowRunBodySchema, workflowRunResponseSchema} from '@shipfox/api-workflows-dto';
4
4
  import {ClientError, defineRoute} from '@shipfox/node-fastify';
5
5
  import {z} from 'zod';
@@ -1,6 +1,6 @@
1
1
  import type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';
2
- import type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto';
3
- import type {ProjectsModuleClient} from '@shipfox/api-projects-dto';
2
+ import type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto/inter-module';
3
+ import type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';
4
4
  import type {RunnersInterModuleClient} from '@shipfox/api-runners-dto/inter-module';
5
5
  import type {SecretsInterModuleClient} from '@shipfox/api-secrets-dto/inter-module';
6
6
  import {
@@ -1,6 +1,6 @@
1
1
  import type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';
2
- import type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto';
3
- import type {ProjectsModuleClient} from '@shipfox/api-projects-dto';
2
+ import type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto/inter-module';
3
+ import type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';
4
4
  import {
5
5
  type RunnersInterModuleClient,
6
6
  runnersInterModuleContract,
@@ -1,7 +1,37 @@
1
- import type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';
1
+ import {
2
+ DEFAULT_HARNESS_TOOL_DEPLOYMENT_CONFIG,
3
+ getModelProviderEntry,
4
+ listEnabledHarnessTools,
5
+ listHarnessDescriptors,
6
+ MODEL_PROVIDER_IDS,
7
+ } from '@shipfox/api-agent-dto';
8
+ import type {
9
+ AgentInterModuleClient,
10
+ AgentValidationCatalog,
11
+ } from '@shipfox/api-agent-dto/inter-module';
2
12
  import type {AgentDefaultsResolver} from '#core/agent-defaults.js';
3
13
 
14
+ export const agentValidationCatalog: AgentValidationCatalog = {
15
+ version: 1,
16
+ providers: MODEL_PROVIDER_IDS.map((id) => ({
17
+ id,
18
+ support_status: getModelProviderEntry(id)?.support_status ?? 'unsupported',
19
+ })),
20
+ harnesses: listHarnessDescriptors().map((harness) => ({
21
+ id: harness.id,
22
+ supported_provider_ids: [...harness.supportedProviderIds],
23
+ thinking_levels: [...harness.thinkingLevels],
24
+ effective_tools: listEnabledHarnessTools(
25
+ harness.id,
26
+ DEFAULT_HARNESS_TOOL_DEPLOYMENT_CONFIG,
27
+ ).map((tool) => tool.name),
28
+ })),
29
+ };
30
+
4
31
  export const agentTestClient: AgentInterModuleClient = {
32
+ getValidationCatalog() {
33
+ return Promise.resolve(agentValidationCatalog);
34
+ },
5
35
  resolveAgentConfig({config}) {
6
36
  return Promise.resolve(resolveTestAgentDefaults(config));
7
37
  },
@@ -1,22 +1,11 @@
1
- import {JOB_LEASE_TOKEN_AUDIENCE} from '@shipfox/api-auth-dto';
2
1
  import type {AuthInterModuleClient} from '@shipfox/api-auth-dto/inter-module';
3
- import {jobLeaseTokenKey} from '@shipfox/node-auth-root-key';
4
- import {signHs256} from '@shipfox/node-jwt';
5
-
6
- const leaseSecret = jobLeaseTokenKey();
2
+ import {mintLeaseToken} from './lease-token.js';
7
3
 
8
4
  export const workflowsTestAuthClient: AuthInterModuleClient = {
9
5
  mintRunnerSessionToken() {
10
6
  throw new Error('Runner session token minting is not configured');
11
7
  },
12
8
  async mintJobLeaseToken(claims) {
13
- return {
14
- token: await signHs256({
15
- payload: claims,
16
- secret: leaseSecret,
17
- expiresIn: '90m',
18
- audience: JOB_LEASE_TOKEN_AUDIENCE,
19
- }),
20
- };
9
+ return {token: await mintLeaseToken(claims)};
21
10
  },
22
11
  };
@@ -1,45 +1,59 @@
1
- import {JOB_LEASE_TOKEN_AUDIENCE} from '@shipfox/api-auth-dto';
2
- import {jobLeaseTokenKey} from '@shipfox/node-auth-root-key';
3
- import {signHs256} from '@shipfox/node-jwt';
1
+ import {AUTH_LEASED_JOB, setLeasedJobContext} from '@shipfox/api-auth-context';
2
+ import {JOB_LEASE_TOKEN_AUDIENCE, type JobLeaseTokenClaims} from '@shipfox/api-auth-dto';
3
+ import {type AuthMethod, ClientError, extractBearerToken} from '@shipfox/node-fastify';
4
4
  import {getFirstJobExecutionByJobId} from '#db/workflow-runs.js';
5
5
 
6
- // Matches test/env.ts; the lease-token auth method reads this same value from config.
7
- const SECRET = jobLeaseTokenKey();
6
+ const leaseClaims = new Map<string, JobLeaseTokenClaims>();
8
7
 
9
8
  export interface MintLeaseTokenParams {
10
9
  jobId: string;
11
10
  jobExecutionId?: string;
12
- // Override informational claims to pair a job with chosen surrounding context.
13
11
  workflowRunId?: string;
14
12
  workflowRunAttemptId?: string;
15
13
  projectId?: string;
16
14
  workspaceId?: string;
17
15
  runnerSessionId?: string;
18
- secret?: string;
19
- expiresIn?: string;
20
- audience?: string;
16
+ currentStepId?: string | undefined;
17
+ currentStepAttempt?: number | undefined;
21
18
  }
22
19
 
23
20
  export async function mintLeaseToken(params: MintLeaseTokenParams): Promise<string> {
24
- let jobExecutionId = params.jobExecutionId;
25
- if (jobExecutionId === undefined) {
26
- const jobExecution = await getFirstJobExecutionByJobId(params.jobId);
27
- if (!jobExecution) throw new Error('Expected job execution to exist');
28
- jobExecutionId = jobExecution.id;
29
- }
30
-
31
- return signHs256({
32
- payload: {
33
- jobId: params.jobId,
34
- jobExecutionId,
35
- workflowRunId: params.workflowRunId ?? crypto.randomUUID(),
36
- workflowRunAttemptId: params.workflowRunAttemptId ?? crypto.randomUUID(),
37
- projectId: params.projectId ?? crypto.randomUUID(),
38
- workspaceId: params.workspaceId ?? crypto.randomUUID(),
39
- runnerSessionId: params.runnerSessionId ?? crypto.randomUUID(),
40
- },
41
- secret: params.secret ?? SECRET,
42
- expiresIn: params.expiresIn ?? '90m',
43
- audience: params.audience ?? JOB_LEASE_TOKEN_AUDIENCE,
21
+ const jobExecution =
22
+ params.jobExecutionId === undefined
23
+ ? await getFirstJobExecutionByJobId(params.jobId)
24
+ : undefined;
25
+ const jobExecutionId = params.jobExecutionId ?? jobExecution?.id;
26
+ if (!jobExecutionId) throw new Error('Expected job execution to exist');
27
+ const token = `test-auth-${crypto.randomUUID()}`;
28
+ leaseClaims.set(token, {
29
+ jobId: params.jobId,
30
+ jobExecutionId,
31
+ workflowRunId: params.workflowRunId ?? crypto.randomUUID(),
32
+ workflowRunAttemptId: params.workflowRunAttemptId ?? crypto.randomUUID(),
33
+ projectId: params.projectId ?? crypto.randomUUID(),
34
+ workspaceId: params.workspaceId ?? crypto.randomUUID(),
35
+ runnerSessionId: params.runnerSessionId ?? crypto.randomUUID(),
36
+ ...(params.currentStepId && params.currentStepAttempt !== undefined
37
+ ? {currentStepId: params.currentStepId, currentStepAttempt: params.currentStepAttempt}
38
+ : {}),
39
+ aud: JOB_LEASE_TOKEN_AUDIENCE,
40
+ iat: 0,
41
+ exp: Number.MAX_SAFE_INTEGER,
44
42
  });
43
+ return token;
44
+ }
45
+
46
+ export function getLeaseTokenClaims(token: string): JobLeaseTokenClaims | undefined {
47
+ return leaseClaims.get(token);
45
48
  }
49
+
50
+ export const fakeLeaseTokenAuthMethod: AuthMethod = {
51
+ name: AUTH_LEASED_JOB,
52
+ authenticate: (request) => {
53
+ const token = extractBearerToken(request.headers.authorization);
54
+ const claims = token ? leaseClaims.get(token) : undefined;
55
+ if (!claims) throw new ClientError('Authentication required', 'unauthorized', {status: 401});
56
+ setLeasedJobContext(request, claims);
57
+ return Promise.resolve();
58
+ },
59
+ };
@@ -1,4 +1,4 @@
1
- import type {ProjectsModuleClient} from '@shipfox/api-projects-dto';
1
+ import type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';
2
2
 
3
3
  export const projectsTestClient = {
4
4
  getProjectById: async () => ({project: undefined}),