| 189 | } |
| 190 | |
| 191 | async exchangeAuthorizationCode( |
| 192 | client: OAuthClientInformationFull, |
| 193 | authorizationCode: string, |
| 194 | _codeVerifier?: string, |
| 195 | redirectUri?: string, |
| 196 | resource?: URL, |
| 197 | ): Promise<OAuthTokens> { |
| 198 | const record = this.validCodeRecord(client, authorizationCode); |
| 199 | if (redirectUri && redirectUri !== record.params.redirectUri) { |
| 200 | throw new InvalidGrantError("redirect_uri does not match the authorization request"); |
| 201 | } |
| 202 | if (resource && !checkResourceAllowed({ requestedResource: resource, configuredResource: this.resourceServerUrl })) { |
| 203 | throw new InvalidGrantError("Invalid resource"); |
| 204 | } |
| 205 | |
| 206 | this.codes.delete(authorizationCode); |
| 207 | return this.issueTokens(client.client_id, record.params.scopes ?? this.config.scopes, record.params.resource); |
| 208 | } |
| 209 | |
| 210 | async exchangeRefreshToken( |
| 211 | client: OAuthClientInformationFull, |