Park an authorization code in KV the way POST /api/oauth/code does.
(
code: string,
overrides: Record<string, unknown> = {},
)
| 24 | |
| 25 | /** Park an authorization code in KV the way POST /api/oauth/code does. */ |
| 26 | async function putCode( |
| 27 | code: string, |
| 28 | overrides: Record<string, unknown> = {}, |
| 29 | ): Promise<void> { |
| 30 | const stored = { |
| 31 | key: "sk_test_access_token", |
| 32 | clientId: "pk_test_client", |
| 33 | redirectUri: REDIRECT_URI, |
| 34 | scope: "profile", |
| 35 | codeChallenge: await s256(VERIFIER), |
| 36 | expiresIn: 604800, |
| 37 | ...overrides, |
| 38 | }; |
| 39 | await env.KV.put(`oauth-code:${code}`, JSON.stringify(stored), { |
| 40 | expirationTtl: 600, |
| 41 | }); |
| 42 | } |
| 43 | |
| 44 | function formPost(params: Record<string, string>): RequestInit { |
| 45 | return { |
no test coverage detected