Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies #154

Merged
merged 6 commits into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

root = true


[*]
end_of_line = lf
charset = utf-8
Expand Down
26 changes: 9 additions & 17 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
'use strict';

/* eslint-env node */
module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module'
sourceType: 'module',
ecmaFeatures: {
legacyDecorators: true
}
},
plugins: [
'ember'
Expand All @@ -28,6 +34,7 @@ module.exports = {
'.eslintrc.js',
'.template-lintrc.js',
'ember-cli-build.js',
'index.js',
'testem.js',
'blueprints/*/index.js',
'config/**/*.js',
Expand All @@ -47,22 +54,7 @@ module.exports = {
node: true
},
plugins: ['node'],
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
// add your custom rules and overrides for node files here
})
},
{
files: [
'addon/**/*.js',
'app/**/*.js'
],
plugins: [
'disable-features',
],
rules: {
'disable-features/disable-async-await': 'error',
'disable-features/disable-generator-functions': 'error',
}
extends: ['plugin:node/recommended']
}
]
};
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/.env*
/.eslintignore
/.eslintrc.js
/.git/
/.gitignore
/.template-lintrc.js
/.travis.yml
Expand Down
7 changes: 1 addition & 6 deletions .template-lintrc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
'use strict';

module.exports = {
extends: 'recommended',
rules: {
"inline-link-to": true,
// "no-implicit-this": true,
"link-rel-noopener": "strict"
}
extends: 'octane'
};
40 changes: 17 additions & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ language: node_js
node_js:
# we recommend testing addons with the same minimum supported node version as Ember CLI
# so that your addon works for all apps
- "8"
- "10"

sudo: false
dist: trusty
dist: xenial

addons:
chrome: stable
code_climate:
repo_token: afee53726fd886e21390e86c4426e1e9200d809f0a5b3fe8d6aa9d5c697772ff

cache:
yarn: true
Expand All @@ -28,44 +25,41 @@ branches:
- /^v\d+\.\d+\.\d+/

jobs:
fail_fast: true
fast_finish: true
allow_failures:
- env: EMBER_TRY_SCENARIO=ember-canary

include:
# runs linting and tests with current locked deps

- stage: "Tests"
name: "Tests"
script:
- yarn run lint:hbs
- yarn run lint:js
- yarn test
- yarn lint
- yarn test:ember

- stage: "Additional Tests"
name: "Floating Dependencies"
install:
- yarn install --no-lockfile --non-interactive
script:
- yarn test:ember

# we recommend new addons test the current and previous LTS
# as well as latest stable release (bonus points to beta/canary)
- stage: "Additional Tests"
env: EMBER_TRY_SCENARIO=ember-lts-3.4
- env: EMBER_TRY_SCENARIO=ember-lts-3.8
- env: EMBER_TRY_SCENARIO=ember-lts-3.12
- env: EMBER_TRY_SCENARIO=ember-lts-3.16
- env: EMBER_TRY_SCENARIO=ember-release
- env: EMBER_TRY_SCENARIO=ember-beta
- env: EMBER_TRY_SCENARIO=ember-canary
- env: EMBER_TRY_SCENARIO=ember-default-with-jquery
- env: EMBER_TRY_SCENARIO=ember-classic

before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH
- yarn global add greenkeeper-lockfile@1

before_script:
- greenkeeper-lockfile-update

after_script:
- greenkeeper-lockfile-upload

after_success:
- yarn global add codeclimate-test-reporter
- codeclimate-test-reporter < coverage/lcov.info
install:
- yarn install --non-interactive

script:
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
## An authenticator and library for using ember-simple-auth and AWS Amplify/Cognito

[![Build Status](https://travis-ci.org/paulcwatts/ember-cognito.svg?branch=master)](https://travis-ci.org/paulcwatts/ember-cognito)
[![Code Climate](https://codeclimate.com/github/paulcwatts/ember-cognito/badges/gpa.svg)](https://codeclimate.com/github/paulcwatts/ember-cognito)
[![Ember Observer Score](https://emberobserver.com/badges/ember-cognito.svg)](https://emberobserver.com/addons/ember-cognito)
[![Test Coverage](https://codeclimate.com/github/paulcwatts/ember-cognito/badges/coverage.svg)](https://codeclimate.com/github/paulcwatts/ember-cognito/coverage)
[![npm version](https://badge.fury.io/js/ember-cognito.svg)](https://badge.fury.io/js/ember-cognito)
[![Greenkeeper badge](https://badges.greenkeeper.io/paulcwatts/ember-cognito.svg)](https://greenkeeper.io/)

Ember Cognito is an Ember Addon that integrates
[ember-simple-auth](https://github.com/simplabs/ember-simple-auth/)
Expand Down
6 changes: 3 additions & 3 deletions addon-test-support/utils/-mock-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ export default EmberObject.extend({
},

signUp() {
const user = this.get('_authenticatedUser');
const user = this._authenticatedUser;
return resolve({ user, userConfirmed: false, userSub: "xxxx" });
},

_resolveAuthedUser(msg) {
const user = this.get('_authenticatedUser');
const user = this._authenticatedUser;
if (user) {
return resolve(user);
} else {
Expand All @@ -65,7 +65,7 @@ export default EmberObject.extend({
},

currentSession() {
const user = this.get('_authenticatedUser');
const user = this._authenticatedUser;
if (user) {
return resolve(newSession());
} else {
Expand Down
16 changes: 8 additions & 8 deletions addon-test-support/utils/ember-cognito.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CognitoUserAttribute } from 'amazon-cognito-identity-js';
import EmberObject, { get } from '@ember/object';
import EmberObject from '@ember/object';
import { typeOf } from '@ember/utils';
import { resolve } from 'rsvp';
import { newSession } from "./-mock-auth";
Expand Down Expand Up @@ -35,17 +35,17 @@ const MockUser = EmberObject.extend({
},

getSession() {
return resolve(this.get('session') || newSession());
return resolve(this.session || newSession());
},

getUserAttributes() {
return resolve(get(this, 'userAttributes').map(({ name, value }) => {
return resolve(this.userAttributes.map(({ name, value }) => {
return new CognitoUserAttribute({ Name: name, Value: value });
}));
},

getUserAttributesHash() {
return resolve(get(this, 'userAttributes').reduce((acc, { name, value }) => {
return resolve(this.userAttributes.reduce((acc, { name, value }) => {
acc[name] = value;
return acc;
}, {}));
Expand All @@ -60,7 +60,7 @@ const MockUser = EmberObject.extend({
},

_updateAttrsList(attributesList) {
let attrs = this.get('userAttributes');
let attrs = this.userAttributes;
attributesList.forEach((updated) => {
let found = false;
attrs.forEach((existing) => {
Expand All @@ -77,7 +77,7 @@ const MockUser = EmberObject.extend({
},

_updateAttrsHash(attributes) {
let attrs = this.get('userAttributes');
let attrs = this.userAttributes;
Object.keys(attributes).forEach((name) => {
let found = false;
attrs.forEach((existing) => {
Expand Down Expand Up @@ -110,12 +110,12 @@ const MockUser = EmberObject.extend({

// Non-AWS method
getGroups() {
return resolve(get(this, 'groups'));
return resolve(this.groups);
},

// Non-AWS method
getStorageData() {
return get(this, 'storageData');
return this.storageData;
}
});

Expand Down
24 changes: 11 additions & 13 deletions addon/authenticators/cognito.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { get } from '@ember/object';
import { readOnly } from '@ember/object/computed';
import { inject as service } from '@ember/service';
import Base from 'ember-simple-auth/authenticators/base';
Expand All @@ -12,11 +11,11 @@ export default Base.extend({
authenticationFlowType: readOnly('cognito.authenticationFlowType'),

restore({ poolId, clientId }) {
this.get('cognito').configure({
this.cognito.configure({
userPoolId: poolId,
userPoolWebClientId: clientId
});
return this.get('auth').currentAuthenticatedUser().then((user) => {
return this.auth.currentAuthenticatedUser().then((user) => {
return this._resolveAuth(user);
});
},
Expand All @@ -30,10 +29,10 @@ export default Base.extend({
},

_resolveAuth(user) {
const cognito = this.get('cognito');
const { cognito } = this;
cognito._setUser(user);
// Now pull out the (promisified) user
return get(cognito, 'user').getSession().then((session) => {
return cognito.user.getSession().then((session) => {
/* eslint-disable camelcase */
cognito.startRefreshTask(session);
return this._makeAuthData(user, session);
Expand All @@ -55,21 +54,21 @@ export default Base.extend({
},

_handleNewPasswordRequired({ password, state: { user } }) {
return this.get('auth').completeNewPassword(user, password).then((user) => {
return this.auth.completeNewPassword(user, password).then((user) => {
return this._handleSignIn(user);
});
},

_handleRefresh() {
const cognito = this.get('cognito');
const user = get(cognito, 'user');
const { cognito } = this;
const { auth, user } = cognito;
// Get the session, which will refresh it if necessary
return user.getSession().then((session) => {
if (session.isValid()) {
/* eslint-disable camelcase */

cognito.startRefreshTask(session);
return get(cognito, 'auth').currentAuthenticatedUser().then((awsUser) => {
return auth.currentAuthenticatedUser().then((awsUser) => {
return this._makeAuthData(awsUser, session);
});
} else {
Expand All @@ -94,17 +93,16 @@ export default Base.extend({
return this._handleState(state.name, params);
}

const { auth, authenticationFlowType } =
this.getProperties('auth', 'authenticationFlowType');
this.get('cognito').configure({ authenticationFlowType });
const { auth, authenticationFlowType, cognito } = this;
cognito.configure({ authenticationFlowType });

return auth.signIn(username, password).then((user) => {
return this._handleSignIn(user);
});
},

invalidate(data) {
return this.get('cognito.user').signOut().then(() => {
return this.cognito.user.signOut().then(() => {
this.set('cognito.user', undefined);
return data;
});
Expand Down
Loading