Release 7.0.0 doesn't contain any new features and the API haven't really changed. It focuses on housekeeping, modernizing the codebase and introducing Typescript to our library. The biggest change was getting rid of as much "classic" Ember syntax as possible and get onto ES6 classes.
There are some not-so-painful breaking changes however, please refer to the following document.
Most if not all of the public API is ES6 classes, as a result you'll have to change how ESA's classes are extended in your codebases. Here's an example based on the OAuth2PasswordGrant authenticator.
Old
import OAuth2PasswordGrant from 'ember-simple-auth/authenticators/oauth2-password-grant';
import config from '../config/environment';
export default OAuth2PasswordGrant.extend({
serverTokenEndpoint: `${config.apiHost}/token`,
serverTokenRevocationEndpoint: `${config.apiHost}/revoke`,
});
New
import OAuth2PasswordGrant from 'ember-simple-auth/authenticators/oauth2-password-grant';
import config from '../config/environment';
export default class OAuth2 extends OAuth2PasswordGrant {
serverTokenEndpoint = `${config.apiHost}/token`;
serverTokenRevocationEndpoint = `${config.apiHost}/revoke`;
}
This change is made due to processing problems found here ember-simple-auth/#2888 and shipshapecode/swach#1736. It's been a problem for a long time and with Ember-Data and Ember itself being more explicit around dependencies, we're making the change too.
The only thing that ESA will continue to export is the initializer, they aren't usually imported and extended by users so they shouldn't cause problems as long as Ember still supports it.
Add app/services/session.js
or app/services/session.ts
import Service from 'ember-simple-auth/services/session';
export default class SessionService extends Service {}
Add app/session-stores/application.js
or app/session-stores/application.ts
import AdaptiveStore from 'ember-simple-auth/session-stores/adaptive';
export default class SessionStore extends AdaptiveStore {}
Typescript: Optional Generic Data
argument.
import Service from 'ember-simple-auth/services/session';
type Data = {
authenticated: {
// Any data your authenticators return
id: string;
}
}
export default class SessionService extends Service<Data> {}
Async APIs were built on top of RSVP.Promise, we're no longer relying on it and use the native Promise instead.
For historical reasons, when Ajax was still in use. OAuth2PasswordGrantAuthenticator adds responseJSON
and responseText
properties to the response returned by its #authenticated method.
These properties are deprecated and will be removed with later releases.