bdy 1.22.23 → 1.22.24-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.22.23",
4
+ "version": "1.22.24-beta",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -767,6 +767,26 @@ class Tunnel extends events_1.default {
767
767
  sameSite: 'lax',
768
768
  }));
769
769
  }
770
+ _checkHttpAuthTokenRedirect(req, res, code, state, accessToken, url) {
771
+ if ((code || accessToken) && state && url) {
772
+ const u2 = new URL(url);
773
+ const currentHost = req.headers['x-forwarded-host'] || req.headers.host || req.headers[':authority'] || '';
774
+ const currentUrl = `https://${currentHost}`;
775
+ const originalUrl = `https://${u2.host}`;
776
+ if (currentUrl !== originalUrl) {
777
+ let newUrl = `${originalUrl}?state=${encodeURIComponent(state)}`;
778
+ if (code)
779
+ newUrl += `&code=${encodeURIComponent(code)}`;
780
+ else if (accessToken)
781
+ newUrl += `&access_token=${encodeURIComponent(accessToken)}`;
782
+ this.httpEndFast(req, res, 302, 'Found', {
783
+ location: newUrl,
784
+ });
785
+ return true;
786
+ }
787
+ }
788
+ return false;
789
+ }
770
790
  async _checkHttpAuthToken(code, verifier, token, req, res) {
771
791
  let fromCookie = false;
772
792
  if (code && verifier && !token) {
@@ -878,6 +898,10 @@ class Tunnel extends events_1.default {
878
898
  const state = searchParams.get('state') || '';
879
899
  const token = searchParams.get('access_token') || '';
880
900
  const { url, verifier } = this._httpDecryptState(state);
901
+ const redirectByAuthToken = this._checkHttpAuthTokenRedirect(req, res, code, state, token, url);
902
+ if (redirectByAuthToken) {
903
+ return false;
904
+ }
881
905
  const authByToken = await this._checkHttpAuthToken(code, verifier || '', token, req, res);
882
906
  if (authByToken) {
883
907
  if (url) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.22.23",
4
+ "version": "1.22.24-beta",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {