Skip to content

Commit c57b9dd

Browse files
authored
Merge pull request #1034 from supertokens/fix/send-json-response-not-being-ignored
fix: send json response not being ignored
2 parents 4e988a5 + 9b410a9 commit c57b9dd

File tree

12 files changed

+182
-19
lines changed

12 files changed

+182
-19
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
## [23.1.0] - 2025-11-25
11+
12+
- Fix the OAuth2Provider `tokenExchange` error message when the refresh token is expired
13+
- Updates custom framework to following correct CollectingResponse flow order (to ensure that subsequent calls to the `sendJSONResponse` doesn't overwrite the response).
14+
1015
## [23.0.1] - 2025-07-31
1116

1217
- Updated FDI support to 4.2
@@ -15,7 +20,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1520
- Fix WebAuthn credential listing and removal to work even when the WebAuthn user is not the primary user and when there are multiple WebAuthn users linked
1621
- Prevent removal of WebAuthn credentials unless all session claims are satisfied
1722
- Change how sessions are fetched before listing, removing and adding WebAuthn credentials
18-
- Fix the OAuth2Provider `tokenExchange` error message when the refresh token is expired
1923

2024
## [23.0.0] - 2025-07-21
2125

lib/build/framework/custom/framework.d.ts

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/framework/custom/framework.js

Lines changed: 14 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/recipe/oauth2provider/constants.js

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/recipe/session/constants.js

Lines changed: 15 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/version.d.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/version.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ts/framework/custom/framework.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export class CollectingResponse extends BaseResponse {
103103
public readonly headers: Headers;
104104
public readonly cookies: CookieInfo[];
105105
public body?: string;
106+
private responseSet: boolean;
106107

107108
constructor() {
108109
super();
@@ -115,11 +116,15 @@ export class CollectingResponse extends BaseResponse {
115116
}
116117
this.statusCode = 200;
117118
this.cookies = [];
119+
this.responseSet = false;
118120
}
119121

120122
sendHTMLResponse = (html: string) => {
121-
this.headers.set("Content-Type", "text/html");
122-
this.body = html;
123+
if (!this.responseSet) {
124+
this.headers.set("Content-Type", "text/html");
125+
this.body = html;
126+
this.responseSet = true;
127+
}
123128
};
124129

125130
setHeader = (key: string, value: string, allowDuplicateKey: boolean) => {
@@ -158,12 +163,17 @@ export class CollectingResponse extends BaseResponse {
158163
* @param {number} statusCode
159164
*/
160165
setStatusCode = (statusCode: number) => {
161-
this.statusCode = statusCode;
166+
if (!this.responseSet) {
167+
this.statusCode = statusCode;
168+
}
162169
};
163170

164171
sendJSONResponse = (content: any) => {
165-
this.headers.set("Content-Type", "application/json");
166-
this.body = JSON.stringify(content);
172+
if (!this.responseSet) {
173+
this.headers.set("Content-Type", "application/json");
174+
this.body = JSON.stringify(content);
175+
this.responseSet = true;
176+
}
167177
};
168178
}
169179

lib/ts/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* License for the specific language governing permissions and limitations
1313
* under the License.
1414
*/
15-
export const version = "23.0.1";
15+
export const version = "23.0.2";
1616

1717
export const cdiSupported = ["5.3"];
1818

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)