From 9ab54535328986294b07e93436b7db6006c8dfb0 Mon Sep 17 00:00:00 2001 From: LEGO Technix <109212476+lego-technix@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:28:26 +0100 Subject: [PATCH 1/2] refactor(mon-pix): replace RSVP uses which have direct native Promise equivalents --- mon-pix/app/authenticators/anonymous.js | 5 ++--- mon-pix/app/authenticators/gar.js | 5 ++--- mon-pix/app/authenticators/oauth2.js | 3 +-- mon-pix/app/authenticators/oidc.js | 5 ++--- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/mon-pix/app/authenticators/anonymous.js b/mon-pix/app/authenticators/anonymous.js index 85faee035b7..ebdebd8f148 100644 --- a/mon-pix/app/authenticators/anonymous.js +++ b/mon-pix/app/authenticators/anonymous.js @@ -4,7 +4,6 @@ import BaseAuthenticator from 'ember-simple-auth/authenticators/base'; import fetch from 'fetch'; import ENV from 'mon-pix/config/environment'; import { decodeToken } from 'mon-pix/helpers/jwt'; -import RSVP from 'rsvp'; export default BaseAuthenticator.extend({ intl: service(), @@ -31,7 +30,7 @@ export default BaseAuthenticator.extend({ const data = await response.json(); if (!response.ok) { - return RSVP.reject(data); + return Promise.reject(data); } const decodedAccessToken = decodeToken(data.access_token); @@ -43,7 +42,7 @@ export default BaseAuthenticator.extend({ }, restore(data) { - return new RSVP.Promise((resolve, reject) => { + return new Promise((resolve, reject) => { if (!isEmpty(data['access_token'])) { resolve(data); } diff --git a/mon-pix/app/authenticators/gar.js b/mon-pix/app/authenticators/gar.js index d048bd3e34b..82931cc64a3 100644 --- a/mon-pix/app/authenticators/gar.js +++ b/mon-pix/app/authenticators/gar.js @@ -1,13 +1,12 @@ import { isEmpty } from '@ember/utils'; import BaseAuthenticator from 'ember-simple-auth/authenticators/base'; import { decodeToken } from 'mon-pix/helpers/jwt'; -import RSVP from 'rsvp'; export default class GarAuthenticator extends BaseAuthenticator { authenticate(token, tokenDecoder = decodeToken) { const token_type = 'bearer'; const { user_id, source } = tokenDecoder(token); - return RSVP.resolve({ + return Promise.resolve({ token_type, access_token: token, user_id, @@ -16,7 +15,7 @@ export default class GarAuthenticator extends BaseAuthenticator { } restore(data) { - return new RSVP.Promise((resolve, reject) => { + return new Promise((resolve, reject) => { if (!isEmpty(data['access_token'])) { resolve(data); } diff --git a/mon-pix/app/authenticators/oauth2.js b/mon-pix/app/authenticators/oauth2.js index b4f34513b1c..50911044fc3 100644 --- a/mon-pix/app/authenticators/oauth2.js +++ b/mon-pix/app/authenticators/oauth2.js @@ -1,7 +1,6 @@ import OAuth2PasswordGrant from 'ember-simple-auth/authenticators/oauth2-password-grant'; import ENV from 'mon-pix/config/environment'; import { decodeToken } from 'mon-pix/helpers/jwt'; -import RSVP from 'rsvp'; export default class OAuth2 extends OAuth2PasswordGrant { serverTokenEndpoint = `${ENV.APP.API_HOST}/api/token`; @@ -14,7 +13,7 @@ export default class OAuth2 extends OAuth2PasswordGrant { const decodedAccessToken = decodeToken(token); const user_id = decodedAccessToken.user_id; const source = decodedAccessToken.source; - return RSVP.resolve({ + return Promise.resolve({ token_type, access_token: token, user_id, diff --git a/mon-pix/app/authenticators/oidc.js b/mon-pix/app/authenticators/oidc.js index ab29d4d70e6..8351422501a 100644 --- a/mon-pix/app/authenticators/oidc.js +++ b/mon-pix/app/authenticators/oidc.js @@ -4,7 +4,6 @@ import BaseAuthenticator from 'ember-simple-auth/authenticators/base'; import fetch from 'fetch'; import ENV from 'mon-pix/config/environment'; import { decodeToken } from 'mon-pix/helpers/jwt'; -import RSVP from 'rsvp'; export default class OidcAuthenticator extends BaseAuthenticator { @service intl; @@ -49,7 +48,7 @@ export default class OidcAuthenticator extends BaseAuthenticator { const data = await response.json(); if (!response.ok) { - return RSVP.reject(data); + return Promise.reject(data); } const decodedAccessToken = decodeToken(data.access_token); @@ -65,7 +64,7 @@ export default class OidcAuthenticator extends BaseAuthenticator { } restore(data) { - return new RSVP.Promise((resolve, reject) => { + return new Promise((resolve, reject) => { if (!isEmpty(data['access_token'])) { resolve(data); } From 44047214b72c831be48d1a4994c884b0ed5ac817 Mon Sep 17 00:00:00 2001 From: LEGO Technix <109212476+lego-technix@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:29:39 +0100 Subject: [PATCH 2/2] refactor(admin): replace RSVP uses which have direct native Promise equivalents --- admin/app/authenticators/oidc.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/admin/app/authenticators/oidc.js b/admin/app/authenticators/oidc.js index 8d35fb2dc1a..35edb2433a8 100644 --- a/admin/app/authenticators/oidc.js +++ b/admin/app/authenticators/oidc.js @@ -4,7 +4,6 @@ import BaseAuthenticator from 'ember-simple-auth/authenticators/base'; import fetch from 'fetch'; import ENV from 'pix-admin/config/environment'; import { decodeToken } from 'pix-admin/helpers/jwt'; -import RSVP from 'rsvp'; export default class OidcAuthenticator extends BaseAuthenticator { @service session; @@ -47,7 +46,7 @@ export default class OidcAuthenticator extends BaseAuthenticator { const data = await response.json(); if (!response.ok) { - return RSVP.reject(data); + return Promise.reject(data); } const decodedAccessToken = decodeToken(data.access_token); @@ -61,7 +60,7 @@ export default class OidcAuthenticator extends BaseAuthenticator { } restore(data) { - return new RSVP.Promise((resolve, reject) => { + return new Promise((resolve, reject) => { if (!isEmpty(data['access_token'])) { resolve(data); }