Skip to content

Commit

Permalink
feat(ember-simple-auth): remove ember-fetch dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
BobrImperator committed Aug 2, 2023
1 parent 9608c7c commit 2d603be
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
6 changes: 3 additions & 3 deletions packages/ember-simple-auth/addon/authenticators/devise.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Promise } from 'rsvp';
import { isEmpty } from '@ember/utils';
import { run } from '@ember/runloop';
import BaseAuthenticator from './base';
import fetch from 'fetch';
import { waitFor } from '@ember/test-waiters';

const JSON_CONTENT_TYPE = 'application/json';

Expand Down Expand Up @@ -145,7 +145,7 @@ export default BaseAuthenticator.extend({
@return {Promise} The promise returned by `fetch`
@protected
*/
makeRequest(data, options = {}) {
makeRequest: waitFor(function(data, options = {}) {
let url = options.url || this.get('serverTokenEndpoint');
let requestOptions = {};
let body = JSON.stringify(data);
Expand All @@ -160,7 +160,7 @@ export default BaseAuthenticator.extend({
Object.assign(requestOptions, options || {});

return fetch(url, requestOptions);
},
}),

_validate(data) {
const tokenAttributeName = this.get('tokenAttributeName');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { warn } from '@ember/debug';
import { getOwner } from '@ember/application';
import Ember from 'ember';
import BaseAuthenticator from './base';
import fetch from 'fetch';
import isFastBoot from 'ember-simple-auth/utils/is-fastboot';
import { waitFor } from '@ember/test-waiters';

/**
Authenticator that conforms to OAuth 2
Expand Down Expand Up @@ -283,7 +283,7 @@ export default BaseAuthenticator.extend({
@return {Promise} A promise that resolves with the response object
@protected
*/
makeRequest(url, data, headers = {}) {
makeRequest: waitFor(function(url, data, headers = {}) {
headers['Content-Type'] = 'application/x-www-form-urlencoded';

const clientId = this.get('clientId');
Expand Down Expand Up @@ -319,7 +319,7 @@ export default BaseAuthenticator.extend({
});
}).catch(reject);
});
},
}),

_scheduleAccessTokenRefresh(expiresIn, expiresAt, refreshToken) {
const refreshAccessTokens = this.get('refreshAccessTokens') && !isFastBoot(getOwner(this));
Expand Down
6 changes: 2 additions & 4 deletions packages/ember-simple-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"ember-cli-babel": "^7.20.5",
"ember-cli-is-package-missing": "^1.0.0",
"ember-cookies": "^1.0.0",
"silent-error": "^1.0.0"
"silent-error": "^1.0.0",
"@ember/test-waiters": "^3"
},
"devDependencies": {
"@babel/eslint-parser": "7.22.9",
Expand Down Expand Up @@ -86,9 +87,6 @@
"ember": ">=3.28"
}
},
"peerDependencies": {
"ember-fetch": "^8"
},
"ember": {
"edition": "octane"
}
Expand Down
5 changes: 3 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2d603be

Please sign in to comment.