(account: string, role: string | undefined, state: string, pkce: PkceCodes)
| 89 | } |
| 90 | |
| 91 | function buildAuthorizeUrl(account: string, role: string | undefined, state: string, pkce: PkceCodes) { |
| 92 | const scope = oauthScope(role) |
| 93 | const params = new URLSearchParams({ |
| 94 | client_id: OAUTH_CLIENT_ID, |
| 95 | response_type: "code", |
| 96 | redirect_uri: callbackUrl(), |
| 97 | scope, |
| 98 | state, |
| 99 | code_challenge: pkce.challenge, |
| 100 | code_challenge_method: "S256", |
| 101 | }) |
| 102 | return `https://${account}.snowflakecomputing.com/oauth/authorize?${params.toString()}` |
| 103 | } |
| 104 | |
| 105 | async function exchangeCodeForToken(account: string, code: string, pkce: PkceCodes) { |
| 106 | const response = await fetch(`https://${account}.snowflakecomputing.com/oauth/token-request`, { |
no test coverage detected