|
12 | 12 | * POST /getTokenForRepo - { githubRepo, userId, orgId? } |
13 | 13 | * POST /getToken - { installationId, appType? } |
14 | 14 | * POST /getGitLabToken - { userId, orgId?, repositoryUrl?, createdOnPlatform? } |
| 15 | + * POST /issueGitHubSessionCapability |
| 16 | + * POST /redeemGitHubSessionCapability |
| 17 | + * POST /issueGitLabSessionCapability |
| 18 | + * POST /redeemGitLabSessionCapability |
15 | 19 | */ |
16 | 20 | import type { |
17 | 21 | GitTokenRPCEntrypoint, |
18 | 22 | GetTokenForRepoParams, |
19 | 23 | GetTokenForRepoResult, |
20 | 24 | GetGitLabTokenParams, |
21 | 25 | GetGitLabTokenResult, |
| 26 | + IssueGitHubSessionCapabilityParams, |
| 27 | + IssueGitHubSessionCapabilityResult, |
| 28 | + RedeemGitHubSessionCapabilityParams, |
| 29 | + RedeemGitHubSessionCapabilityResult, |
| 30 | + IssueGitLabSessionCapabilityParams, |
| 31 | + IssueGitLabSessionCapabilityResult, |
| 32 | + RedeemGitLabSessionCapabilityParams, |
| 33 | + RedeemGitLabSessionCapabilityResult, |
22 | 34 | } from '../src/index.js'; |
23 | 35 | import type { GitHubAppType } from '../src/github-token-service.js'; |
24 | 36 |
|
@@ -58,13 +70,45 @@ export default { |
58 | 70 | return Response.json(result); |
59 | 71 | } |
60 | 72 |
|
| 73 | + if (url.pathname === '/issueGitHubSessionCapability' && request.method === 'POST') { |
| 74 | + const body = (await request.json()) as IssueGitHubSessionCapabilityParams; |
| 75 | + const result: IssueGitHubSessionCapabilityResult = |
| 76 | + await env.GIT_TOKEN_SERVICE.issueGitHubSessionCapability(body); |
| 77 | + return Response.json(result, { status: result.success ? 200 : 400 }); |
| 78 | + } |
| 79 | + |
| 80 | + if (url.pathname === '/redeemGitHubSessionCapability' && request.method === 'POST') { |
| 81 | + const body = (await request.json()) as RedeemGitHubSessionCapabilityParams; |
| 82 | + const result: RedeemGitHubSessionCapabilityResult = |
| 83 | + await env.GIT_TOKEN_SERVICE.redeemGitHubSessionCapability(body); |
| 84 | + return Response.json(result, { status: result.success ? 200 : 400 }); |
| 85 | + } |
| 86 | + |
| 87 | + if (url.pathname === '/issueGitLabSessionCapability' && request.method === 'POST') { |
| 88 | + const body = (await request.json()) as IssueGitLabSessionCapabilityParams; |
| 89 | + const result: IssueGitLabSessionCapabilityResult = |
| 90 | + await env.GIT_TOKEN_SERVICE.issueGitLabSessionCapability(body); |
| 91 | + return Response.json(result, { status: result.success ? 200 : 400 }); |
| 92 | + } |
| 93 | + |
| 94 | + if (url.pathname === '/redeemGitLabSessionCapability' && request.method === 'POST') { |
| 95 | + const body = (await request.json()) as RedeemGitLabSessionCapabilityParams; |
| 96 | + const result: RedeemGitLabSessionCapabilityResult = |
| 97 | + await env.GIT_TOKEN_SERVICE.redeemGitLabSessionCapability(body); |
| 98 | + return Response.json(result, { status: result.success ? 200 : 400 }); |
| 99 | + } |
| 100 | + |
61 | 101 | return Response.json( |
62 | 102 | { |
63 | 103 | error: 'Not Found', |
64 | 104 | endpoints: [ |
65 | 105 | 'POST /getTokenForRepo - { githubRepo, userId, orgId? }', |
66 | 106 | 'POST /getToken - { installationId, appType? }', |
67 | 107 | 'POST /getGitLabToken - { userId, orgId?, repositoryUrl?, createdOnPlatform? }', |
| 108 | + 'POST /issueGitHubSessionCapability', |
| 109 | + 'POST /redeemGitHubSessionCapability', |
| 110 | + 'POST /issueGitLabSessionCapability', |
| 111 | + 'POST /redeemGitLabSessionCapability', |
68 | 112 | ], |
69 | 113 | }, |
70 | 114 | { status: 404 } |
|
0 commit comments