( response: Response, )
| 651 | * absent or empty, and normalize Slack's comma separator back to RFC space-delimited |
| 652 | * scope syntax at this boundary. */ |
| 653 | const nestedAuthedUserGrant = async ( |
| 654 | response: Response, |
| 655 | ): Promise<NestedAuthedUserGrant | undefined> => { |
| 656 | const body = await response |
| 657 | .clone() |
| 658 | .json() |
| 659 | .then( |
| 660 | (value: unknown) => value, |
| 661 | () => null, |
| 662 | ); |
| 663 | const decoded = decodeNestedAuthedUserScope(body); |
| 664 | if (Option.isNone(decoded)) return undefined; |
| 665 | const normalized = decoded.value.authed_user.scope |
| 666 | .split(/[\s,]+/) |
| 667 | .filter(Boolean) |
| 668 | .join(" "); |
| 669 | if (normalized.length === 0) return undefined; |
| 670 | const nestedAccessToken = decoded.value.authed_user.access_token; |
| 671 | const nestedTokenType = decoded.value.authed_user.token_type; |
| 672 | const nestedRefreshToken = decoded.value.authed_user.refresh_token; |
| 673 | const nestedExpiresIn = decoded.value.authed_user.expires_in; |
| 674 | return { |
| 675 | scope: normalized, |
| 676 | ...(nestedAccessToken === undefined ? {} : { accessToken: nestedAccessToken }), |
| 677 | ...(nestedTokenType === undefined ? {} : { tokenType: nestedTokenType }), |
| 678 | ...(nestedRefreshToken === undefined ? {} : { refreshToken: nestedRefreshToken }), |
| 679 | ...(nestedExpiresIn === undefined ? {} : { expiresIn: nestedExpiresIn }), |
| 680 | }; |
| 681 | }; |
| 682 | |
| 683 | // MCP source connections are pure OAuth 2.0. Some providers (PostHog, etc.) |
| 684 | // front an OIDC backend and emit an `id_token` anyway; oauth4webapi then |
no test coverage detected