diff --git a/.circleci/config.yml b/.circleci/config.yml index 1594d44d3..fa2bf469b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,6 +4,7 @@ jobs: build: docker: - image: circleci/node:8 + - image: circleci/mongo:3 steps: - checkout - run: yarn install --frozen-lockfile diff --git a/package.json b/package.json index b24b020b7..96e0c5f5b 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ }, "license": "MIT", "devDependencies": { - "@accounts/tslint-config-accounts": "0.0.6", + "@accounts/tslint-config-accounts": "0.0.9", "@types/jest": "22.2.0", "@types/node": "9.4.6", "codecov": "3.0.0", diff --git a/packages/database-mongo/README.md b/packages/database-mongo/README.md new file mode 100644 index 000000000..627ac5ea5 --- /dev/null +++ b/packages/database-mongo/README.md @@ -0,0 +1,54 @@ +# @accounts/mongo + +_MongoDB adaptor for accounts_ + +[![npm](https://img.shields.io/npm/v/@accounts/mongo.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/mongo) +[![Circle CI](https://circleci.com/gh/accounts-js/mongo.svg?style=shield)](https://circleci.com/gh/accounts-js/mongo) +[![codecov](https://codecov.io/gh/accounts-js/mongo/branch/master/graph/badge.svg)](https://codecov.io/gh/accounts-js/mongo) +![MIT License](https://img.shields.io/badge/license-MIT-blue.svg) + +## Note + +This package is under active development. + +## Install + +``` +yarn add @accounts/mongo +``` + +## Usage + +```javascript +import { AccountsServer } from '@accounts/server'; +import { Mongo } from '@accounts/mongo'; + +// If you are using mongoose +mongoose.connect(process.env.MONGO_URL); +const db = mongoose.connection; + +// If you are using mongodb 2.x +const db = await mongodb.MongoClient.connect(process.env.MONGO_URL); + +// If you are using mongodb 3.x +const client = await mongodb.MongoClient.connect(process.env.MONGO_URL); +const db = client.db('my-db-name'); + +const accountsMongo = new Mongo(db, options); +const accountsServer = new AccountsServer({ db: accountsMongo }); +``` + +The users will be saved under the `users` collection. + +## Options + +| Property | Type | Default | Description | +| ------------------------------- | :--------------------: | :-----------------------------------------------------: | ------------------------------------------------------------- | +| collectionName | String | users | The users collection name. | +| sessionCollectionName | String | sessions | The sessions collection name. | +| timestamps | Object | `{ createdAt: 'createdAt', updatedAt: 'updatedAt' }` | The timestamps for the users and sessions collection. | +| convertUserIdToMongoObjectId | Boolean | true | Should the user collection use \_id as string or ObjectId. | +| convertSessionIdToMongoObjectId | Boolean | true | Should the session collection use \_id as string or ObjectId. | +| caseSensitiveUserName | Boolean | true | Perform case intensitive query for user name. | +| idProvider | Function | | Function that generate the id for new objects. | +| dateProvider | `(date?: Date) => any` | `(date?: Date) => (date ? date.getTime() : Date.now())` | Function that generate the date for the timestamps. | diff --git a/packages/database-mongo/__tests__/index.ts b/packages/database-mongo/__tests__/index.ts new file mode 100644 index 000000000..181d40df4 --- /dev/null +++ b/packages/database-mongo/__tests__/index.ts @@ -0,0 +1,797 @@ +import * as mongodb from 'mongodb'; +// tslint:disable-next-line +import { ObjectID } from 'mongodb'; +import { randomBytes } from 'crypto'; +import Mongo from '../src'; + +const generateRandomToken = (length: number = 43): string => + randomBytes(length).toString('hex'); + +let mongo: Mongo; +let db: mongodb.Db; +let client: mongodb.MongoClient; +const user = { + username: 'johndoe', + email: 'john@doe.com', + password: 'toto', + profile: {}, +}; +const session = { + userId: '123', + ip: '127.0.0.1', + userAgent: 'user agent', +}; + +function dropDatabase(cb) { + db.dropDatabase(err => { + if (err) { + return cb(err); + } + return cb(); + }); +} + +function createConnection(cb) { + const url = 'mongodb://localhost:27017'; + mongodb.MongoClient.connect(url, (err, clientMongo) => { + client = clientMongo; + db = client.db('accounts-mongo-tests'); + mongo = new Mongo(db); + if (err) { + return cb(err); + } + return dropDatabase(error => { + cb(error); + }); + }); +} + +function closeConnection(cb) { + dropDatabase(async err => { + if (err) { + return cb(err); + } + await client.close(); + return cb(); + }); +} + +function delay(time) { + return new Promise(resolve => setTimeout(() => resolve(), time)); +} + +describe('Mongo', () => { + beforeAll(createConnection); + afterAll(closeConnection); + + describe('toMongoID', () => { + it('should not throw when mongo id is valid', () => { + expect(async () => { + await mongo.findUserById('589871d1c9393d445745a57c'); + }).not.toThrow(); + }); + + it('should throw when mongo id is not valid', async () => { + try { + await mongo.findUserById('invalid_hex'); + throw new Error(); + } catch (err) { + expect(err.message).toEqual( + 'Argument passed in must be a single String of 12 bytes or a string of 24 hex characters' + ); + } + }); + + it('should not auto convert to mongo object id when users collection has string ids', async () => { + const mongoWithStringIds = new Mongo(db, { + convertUserIdToMongoObjectId: false, + }); + const mockFindOne = jest.fn(); + mongoWithStringIds.collection.findOne = mockFindOne; + await mongoWithStringIds.findUserById('589871d1c9393d445745a57c'); + + expect(mockFindOne.mock.calls[0][0]).toHaveProperty( + '_id', + '589871d1c9393d445745a57c' + ); + }); + }); + + describe('#constructor', () => { + it('should have default options', () => { + expect(mongo.options).toBeTruthy(); + }); + + it('should overwrite options', () => { + const mongoTestOptions = new Mongo(db, { + collectionName: 'users-test', + sessionCollectionName: 'sessions-test', + }); + expect(mongoTestOptions.options).toBeTruthy(); + expect(mongoTestOptions.options.collectionName).toEqual('users-test'); + expect(mongoTestOptions.options.sessionCollectionName).toEqual( + 'sessions-test' + ); + }); + + it('should throw with an invalid database connection object', () => { + try { + // tslint:disable-next-line + new Mongo(); + throw new Error(); + } catch (err) { + expect(err.message).toBe('A database connection is required'); + } + }); + }); + + describe('setupIndexes', () => { + it('should create indexes', async () => { + await mongo.setupIndexes(); + const ret = await mongo.collection.indexInformation(); + expect(ret).toBeTruthy(); + expect(ret._id_[0]).toEqual(['_id', 1]); // eslint-disable-line no-underscore-dangle + expect(ret.username_1[0]).toEqual(['username', 1]); + expect(ret['emails.address_1'][0]).toEqual(['emails.address', 1]); + }); + + afterAll(done => { + dropDatabase(done); + }); + }); + + describe('createUser', () => { + it('should create a new user', async () => { + const userId = await mongo.createUser(user); + const ret = await mongo.findUserById(userId); + expect(ret._id).toBeTruthy(); + expect(ret.emails[0].address).toBe(user.email); + expect(ret.emails[0].verified).toBe(false); + expect(ret.createdAt).toBeTruthy(); + expect(ret.updatedAt).toBeTruthy(); + }); + + it('should not set password', async () => { + const userId = await mongo.createUser({ email: user.email }); + const ret = await mongo.findUserById(userId); + expect(ret._id).toBeTruthy(); + expect(ret.services.password).not.toBeTruthy(); + }); + + it('should not set username', async () => { + const userId = await mongo.createUser({ email: user.email }); + const ret = await mongo.findUserById(userId); + expect(ret._id).toBeTruthy(); + expect(ret.username).not.toBeTruthy(); + }); + + it('should not set email', async () => { + const userId = await mongo.createUser({ username: user.username }); + const ret = await mongo.findUserById(userId); + expect(ret._id).toBeTruthy(); + expect(ret.emails).not.toBeTruthy(); + }); + + it('email should be lowercase', async () => { + const userId = await mongo.createUser({ email: 'JohN@doe.com' }); + const ret = await mongo.findUserById(userId); + expect(ret._id).toBeTruthy(); + expect(ret.emails[0].address).toEqual('john@doe.com'); + }); + + it('call options.idProvider', async () => { + const mongoOptions = new Mongo(db, { + idProvider: () => 'toto', + convertUserIdToMongoObjectId: false, + }); + const userId = await mongoOptions.createUser({ email: 'JohN@doe.com' }); + const ret = await mongoOptions.findUserById(userId); + expect(userId).toBe('toto'); + expect(ret._id).toBeTruthy(); + expect(ret.emails[0].address).toEqual('john@doe.com'); + }); + }); + + describe('findUserById', () => { + it('should return null for not found user', async () => { + const ret = await mongo.findUserById('589871d1c9393d445745a57c'); + expect(ret).not.toBeTruthy(); + }); + + it('should return user', async () => { + const userId = await mongo.createUser(user); + const ret = await mongo.findUserById(userId); + expect(ret).toBeTruthy(); + expect(ret._id).toBeTruthy(); + expect(ret.id).toBeTruthy(); + }); + }); + + describe('findUserByEmail', () => { + it('should return null for not found user', async () => { + const ret = await mongo.findUserByEmail('unknow@user.com'); + expect(ret).not.toBeTruthy(); + }); + + it('should return user', async () => { + const ret = await mongo.findUserByEmail(user.email); + expect(ret).toBeTruthy(); + expect(ret._id).toBeTruthy(); + expect(ret.id).toBeTruthy(); + }); + + it('should return user with uppercase email', async () => { + await mongo.createUser({ email: 'JOHN@DOES.COM' }); + const ret = await mongo.findUserByEmail('JOHN@DOES.COM'); + expect(ret._id).toBeTruthy(); + expect(ret.emails[0].address).toEqual('john@does.com'); + }); + }); + + describe('findUserByUsername', () => { + it('should return null for not found user', async () => { + const ret = await mongo.findUserByUsername('unknowuser'); + expect(ret).not.toBeTruthy(); + }); + + it('should return username for case insensitive query', async () => { + const mongoWithOptions = new Mongo(db, { caseSensitiveUserName: false }); + const ret = await mongoWithOptions.findUserByUsername( + user.username.toUpperCase() + ); + expect(ret).toBeTruthy(); + expect(ret._id).toBeTruthy(); + expect(ret.id).toBeTruthy(); + }); + + it('should return null for incomplete matching user when using insensitive', async () => { + const mongoWithOptions = new Mongo(db, { caseSensitiveUserName: false }); + const ret = await mongoWithOptions.findUserByUsername('john'); + expect(ret).not.toBeTruthy(); + }); + + it('should return null when using regex wildcards when using insensitive', async () => { + const mongoWithOptions = new Mongo(db, { caseSensitiveUserName: false }); + const ret = await mongoWithOptions.findUserByUsername('*'); + expect(ret).not.toBeTruthy(); + }); + + it('should return user', async () => { + const ret = await mongo.findUserByUsername(user.username); + expect(ret).toBeTruthy(); + expect(ret._id).toBeTruthy(); + expect(ret.id).toBeTruthy(); + }); + }); + + describe('findUserByEmailVerificationToken', () => { + it('should return null for not found user', async () => { + const ret = await mongo.findUserByEmailVerificationToken('token'); + expect(ret).not.toBeTruthy(); + }); + + it('should return user', async () => { + const userId = await mongo.createUser(user); + await mongo.addEmailVerificationToken(userId, 'john@doe.com', 'token'); + const ret = await mongo.findUserByEmailVerificationToken('token'); + expect(ret).toBeTruthy(); + expect(ret._id).toBeTruthy(); + expect(ret.id).toBeTruthy(); + }); + }); + + describe('findUserByResetPasswordToken', () => { + it('should return null for not found user', async () => { + const ret = await mongo.findUserByResetPasswordToken('token'); + expect(ret).not.toBeTruthy(); + }); + + it('should return user', async () => { + const userId = await mongo.createUser(user); + await mongo.addResetPasswordToken(userId, 'john@doe.com', 'token'); + const ret = await mongo.findUserByResetPasswordToken('token'); + expect(ret).toBeTruthy(); + expect(ret._id).toBeTruthy(); + expect(ret.id).toBeTruthy(); + }); + }); + + describe('findUserByServiceId', () => { + it('should return null for not found user', async () => { + const ret = await mongo.findUserByServiceId('facebook', 'invalid'); + expect(ret).not.toBeTruthy(); + }); + + it('should return user', async () => { + const userId = await mongo.createUser(user); + let ret = await mongo.findUserByServiceId('facebook', '1'); + expect(ret).not.toBeTruthy(); + await mongo.setService(userId, 'facebook', { id: '1' }); + ret = await mongo.findUserByServiceId('facebook', '1'); + expect(ret).toBeTruthy(); + expect(ret._id).toBeTruthy(); + expect(ret.id).toBeTruthy(); + }); + }); + + describe('findPasswordHash', () => { + it('should not convert id', async () => { + const mongoOptions = new Mongo(db, { + convertUserIdToMongoObjectId: false, + }); + await mongoOptions.findPasswordHash('toto'); + }); + + it('should return null on not found user', async () => { + const ret = await mongo.findPasswordHash('589871d1c9393d445745a57c'); + expect(ret).toEqual(null); + }); + + it('should return hash', async () => { + const userId = await mongo.createUser(user); + const retUser = await mongo.findUserById(userId); + const ret = await mongo.findPasswordHash(userId); + expect(ret).toBeTruthy(); + expect(ret).toEqual(retUser.services.password.bcrypt); + }); + }); + + describe('addEmail', () => { + it('should not convert id', async () => { + const mongoOptions = new Mongo(db, { + convertUserIdToMongoObjectId: false, + }); + await mongoOptions.addEmail('toto', 'hey', false); + }); + + it('should throw if user is not found', async () => { + try { + await mongo.addEmail('589871d1c9393d445745a57c', 'unknowemail'); + throw new Error(); + } catch (err) { + expect(err.message).toEqual('User not found'); + } + }); + + it('should add email', async () => { + const email = 'johns@doe.com'; + const userId = await mongo.createUser(user); + await delay(10); + await mongo.addEmail(userId, email, false); + const retUser = await mongo.findUserByEmail(email); + expect(retUser.emails.length).toEqual(2); + expect(retUser.createdAt).not.toEqual(retUser.updatedAt); + }); + + it('should add lowercase email', async () => { + const email = 'johnS@doe.com'; + const userId = await mongo.createUser(user); + await mongo.addEmail(userId, email, false); + const retUser = await mongo.findUserByEmail(email); + expect(retUser.emails.length).toEqual(2); + expect(retUser.emails[1].address).toEqual('johns@doe.com'); + }); + }); + + describe('removeEmail', () => { + it('should not convert id', async () => { + const mongoOptions = new Mongo(db, { + convertUserIdToMongoObjectId: false, + }); + await mongoOptions.removeEmail('toto', 'hey'); + }); + + it('should throw if user is not found', async () => { + try { + await mongo.removeEmail('589871d1c9393d445745a57c', 'unknowemail'); + throw new Error(); + } catch (err) { + expect(err.message).toEqual('User not found'); + } + }); + + it('should remove email', async () => { + const email = 'johns@doe.com'; + const userId = await mongo.createUser(user); + await delay(10); + await mongo.addEmail(userId, email, false); + await mongo.removeEmail(userId, user.email, false); + const retUser = await mongo.findUserById(userId); + expect(retUser.emails.length).toEqual(1); + expect(retUser.emails[0].address).toEqual(email); + expect(retUser.createdAt).not.toEqual(retUser.updatedAt); + }); + + it('should remove uppercase email', async () => { + const email = 'johns@doe.com'; + const userId = await mongo.createUser(user); + await mongo.addEmail(userId, email, false); + await mongo.removeEmail(userId, 'JOHN@doe.com', false); + const retUser = await mongo.findUserById(userId); + expect(retUser.emails.length).toEqual(1); + expect(retUser.emails[0].address).toEqual(email); + }); + }); + + describe('verifyEmail', () => { + it('should not convert id', async () => { + const mongoOptions = new Mongo(db, { + convertUserIdToMongoObjectId: false, + }); + try { + await mongoOptions.verifyEmail('toto', 'hey'); + } catch (err) { + expect(err.message).toEqual('User not found'); + } + }); + + it('should throw if user is not found', async () => { + try { + await mongo.verifyEmail('589871d1c9393d445745a57c', 'unknowemail'); + throw new Error(); + } catch (err) { + expect(err.message).toEqual('User not found'); + } + }); + + it('should verify email', async () => { + const userId = await mongo.createUser(user); + await delay(10); + let retUser = await mongo.findUserById(userId); + expect(retUser.emails.length).toEqual(1); + expect(retUser.emails[0].address).toBe(user.email); + expect(retUser.emails[0].verified).toBe(false); + await mongo.verifyEmail(userId, user.email); + retUser = await mongo.findUserById(userId); + expect(retUser.emails.length).toEqual(1); + expect(retUser.emails[0].address).toBe(user.email); + expect(retUser.emails[0].verified).toBe(true); + expect(retUser.createdAt).not.toEqual(retUser.updatedAt); + }); + }); + + describe('setUsername', () => { + it('should not convert id', async () => { + const mongoOptions = new Mongo(db, { + convertUserIdToMongoObjectId: false, + }); + try { + await mongoOptions.setUsername('toto', 'hey'); + } catch (err) { + expect(err.message).toEqual('User not found'); + } + }); + + it('should throw if user is not found', async () => { + try { + await mongo.setUsername('589871d1c9393d445745a57c'); + throw new Error(); + } catch (err) { + expect(err.message).toEqual('User not found'); + } + }); + + it('should change username', async () => { + const username = 'johnsdoe'; + const userId = await mongo.createUser(user); + await delay(10); + await mongo.setUsername(userId, username); + const retUser = await mongo.findUserById(userId); + expect(retUser.username).toEqual(username); + expect(retUser.createdAt).not.toEqual(retUser.updatedAt); + }); + }); + + describe('setPassword', () => { + it('should not convert id', async () => { + const mongoOptions = new Mongo(db, { + convertUserIdToMongoObjectId: false, + }); + try { + await mongoOptions.setPassword('toto', 'hey'); + } catch (err) { + expect(err.message).toEqual('User not found'); + } + }); + + it('should throw if user is not found', async () => { + try { + await mongo.setPassword('589871d1c9393d445745a57c', 'toto'); + throw new Error(); + } catch (err) { + expect(err.message).toEqual('User not found'); + } + }); + + it('should change password', async () => { + const newPassword = 'newpass'; + const userId = await mongo.createUser(user); + await delay(10); + await mongo.setPassword(userId, newPassword); + const retUser = await mongo.findUserById(userId); + expect(retUser.services.password.bcrypt).toBeTruthy(); + expect(retUser.services.password.bcrypt).toEqual(newPassword); + expect(retUser.createdAt).not.toEqual(retUser.updatedAt); + }); + }); + + describe('setProfile', () => { + it('should not convert id', async () => { + const mongoOptions = new Mongo(db, { + convertUserIdToMongoObjectId: false, + }); + await mongoOptions.setProfile('toto', { username: 'toto' }); + }); + + it('should change profile', async () => { + const userId = await mongo.createUser(user); + await delay(10); + const retUser = await mongo.setProfile(userId, { username: 'toto' }); + expect(retUser.username).toEqual('toto'); + }); + }); + + describe('setService', () => { + it('should not convert id', async () => { + const mongoOptions = new Mongo(db, { + convertUserIdToMongoObjectId: false, + }); + await mongoOptions.setService('toto', 'twitter', { id: '1' }); + }); + + it('should set service', async () => { + const userId = await mongo.createUser(user); + let ret = await mongo.findUserByServiceId('google', '1'); + expect(ret).not.toBeTruthy(); + await mongo.setService(userId, 'google', { id: '1' }); + ret = await mongo.findUserByServiceId('google', '1'); + expect(ret).toBeTruthy(); + expect(ret._id).toBeTruthy(); + expect(ret.id).toBeTruthy(); + }); + }); + + describe('unsetService', () => { + it('should not convert id', async () => { + const collection: any = { update: jest.fn() }; + const mockDb: any = { collection: () => collection }; + const mongoOptions = new Mongo(mockDb, { + convertUserIdToMongoObjectId: false, + }); + await mongoOptions.unsetService('toto', 'twitter'); + expect(collection.update.mock.calls[0][0]._id).toBe('toto'); + }); + + it('should unset service', async () => { + const userId = await mongo.createUser(user); + await mongo.setService(userId, 'telegram', { id: '1' }); + await mongo.unsetService(userId, 'telegram'); + const ret = await mongo.findUserByServiceId('telegram', '1'); + expect(ret).not.toBeTruthy(); + }); + }); + + describe('createSession', () => { + it('should create session', async () => { + const token = generateRandomToken(); + const sessionId = await mongo.createSession(session.userId, token, { + ip: session.ip, + userAgent: session.userAgent, + }); + const ret = await mongo.findSessionById(sessionId); + expect(ret).toBeTruthy(); + expect(ret._id).toBeTruthy(); + expect(ret.userId).toEqual(session.userId); + expect(ret.ip).toEqual(session.ip); + expect(ret.userAgent).toEqual(session.userAgent); + expect(ret.token).toEqual(token); + expect(ret.valid).toEqual(true); + expect(ret.createdAt).toBeTruthy(); + expect(ret.createdAt).toEqual(new Date(ret.createdAt).getTime()); + expect(ret.updatedAt).toBeTruthy(); + }); + + it('should create session with extra data', async () => { + const impersonatorUserId = '789'; + const token = generateRandomToken(); + const sessionId = await mongo.createSession( + session.userId, + token, + { ip: session.ip, userAgent: session.userAgent }, + { impersonatorUserId } + ); + const ret = await mongo.findSessionById(sessionId); + expect(ret).toBeTruthy(); + expect(ret._id).toBeTruthy(); + expect(ret.userId).toEqual(session.userId); + expect(ret.ip).toEqual(session.ip); + expect(ret.userAgent).toEqual(session.userAgent); + expect(ret.valid).toEqual(true); + expect(ret.token).toEqual(token); + expect(ret.createdAt).toEqual(new Date(ret.createdAt).getTime()); + expect(ret.updatedAt).toBeTruthy(); + expect(ret.extraData).toEqual({ impersonatorUserId }); + }); + + it('using date provider on create session', async () => { + const mongoTestOptions = new Mongo(db, { + dateProvider: () => new Date(), + }); + const sessionId = await mongoTestOptions.createSession( + session.userId, + session.ip, + session.userAgent + ); + const ret = await mongoTestOptions.findSessionById(sessionId); + expect(ret.createdAt).toBeTruthy(); + expect(ret.createdAt).not.toEqual(new Date(ret.createdAt).getTime()); + expect(ret.createdAt).toEqual(new Date(ret.createdAt)); + }); + + it('using id provider on create session', async () => { + const mongoTestOptions = new Mongo(db, { + idProvider: () => new ObjectID().toHexString(), + convertSessionIdToMongoObjectId: false, + }); + const sessionId = await mongoTestOptions.createSession( + session.userId, + session.ip, + session.userAgent + ); + const ret = await mongoTestOptions.findSessionById(sessionId); + expect(ret._id).toBeTruthy(); + expect(ret._id).not.toEqual(new ObjectID(ret._id)); + expect(ret._id).toEqual(new ObjectID(ret._id).toHexString()); + }); + }); + + describe('findSessionByToken', () => { + it('should return null for not found session', async () => { + const ret = await mongo.findSessionByToken('589871d1c9393d445745a57c'); + expect(ret).not.toBeTruthy(); + }); + + it('should find session', async () => { + const token = generateRandomToken(); + const sessionId = await mongo.createSession(session.userId, token, { + ip: session.ip, + userAgent: session.userAgent, + }); + const ret = await mongo.findSessionByToken(token); + expect(ret).toBeTruthy(); + }); + }); + + describe('findSessionById', () => { + it('should return null for not found session', async () => { + const ret = await mongo.findSessionById('589871d1c9393d445745a57c'); + expect(ret).not.toBeTruthy(); + }); + + it('should find session', async () => { + const sessionId = await mongo.createSession(session); + const ret = await mongo.findSessionById(sessionId); + expect(ret).toBeTruthy(); + }); + }); + + describe('updateSession', () => { + it('should not convert id', async () => { + const mongoOptions = new Mongo(db, { + convertSessionIdToMongoObjectId: false, + }); + await mongoOptions.updateSession('toto', 'new ip', 'new user agent'); + }); + + it('should update session', async () => { + const token = generateRandomToken(); + const sessionId = await mongo.createSession(session.userId, token, { + ip: session.ip, + userAgent: session.userAgent, + }); + await delay(10); + await mongo.updateSession(sessionId, { + ip: 'new ip', + userAgent: 'new user agent', + }); + const ret = await mongo.findSessionById(sessionId); + expect(ret.userId).toEqual(session.userId); + expect(ret.ip).toEqual('new ip'); + expect(ret.userAgent).toEqual('new user agent'); + expect(ret.valid).toEqual(true); + expect(ret.token).toEqual(token); + expect(ret.createdAt).toBeTruthy(); + expect(ret.updatedAt).toBeTruthy(); + expect(ret.createdAt).not.toEqual(ret.updatedAt); + }); + }); + + describe('invalidateSession', () => { + it('should not convert id', async () => { + const mongoOptions = new Mongo(db, { + convertSessionIdToMongoObjectId: false, + }); + await mongoOptions.invalidateSession('toto'); + }); + + it('invalidates a session', async () => { + const token = generateRandomToken(); + const sessionId = await mongo.createSession(session.userId, token, { + ip: session.ip, + userAgent: session.userAgent, + }); + await delay(10); + await mongo.invalidateSession(sessionId); + const ret = await mongo.findSessionById(sessionId); + expect(ret.valid).toEqual(false); + expect(ret.createdAt).not.toEqual(ret.updatedAt); + }); + }); + + describe('invalidateAllSessions', () => { + it('invalidates all sessions', async () => { + const sessionId1 = await mongo.createSession( + session.userId, + generateRandomToken(), + { ip: session.ip, userAgent: session.userAgent } + ); + const sessionId2 = await mongo.createSession( + session.userId, + generateRandomToken(), + { ip: session.ip, userAgent: session.userAgent } + ); + await delay(10); + await mongo.invalidateAllSessions(session.userId); + const session1 = await mongo.findSessionById(sessionId1); + const session2 = await mongo.findSessionById(sessionId2); + expect(session1.valid).toEqual(false); + expect(session1.createdAt).not.toEqual(session1.updatedAt); + expect(session2.valid).toEqual(false); + expect(session2.createdAt).not.toEqual(session2.updatedAt); + }); + }); + + describe('addEmailVerificationToken', () => { + it('should add a token', async () => { + const userId = await mongo.createUser(user); + await mongo.addEmailVerificationToken(userId, 'john@doe.com', 'token'); + const retUser = await mongo.findUserById(userId); + expect(retUser.services.email.verificationTokens.length).toEqual(1); + expect(retUser.services.email.verificationTokens[0].address).toEqual( + 'john@doe.com' + ); + expect(retUser.services.email.verificationTokens[0].token).toEqual( + 'token' + ); + expect(retUser.services.email.verificationTokens[0].when).toBeTruthy(); + }); + }); + + describe('addResetPasswordToken', () => { + it('should add a token', async () => { + const userId = await mongo.createUser(user); + await mongo.addResetPasswordToken(userId, 'john@doe.com', 'token'); + const retUser = await mongo.findUserById(userId); + expect(retUser.services.password.reset.length).toEqual(1); + expect(retUser.services.password.reset[0].address).toEqual( + 'john@doe.com' + ); + expect(retUser.services.password.reset[0].token).toEqual('token'); + expect(retUser.services.password.reset[0].when).toBeTruthy(); + expect(retUser.services.password.reset[0].reason).toEqual('reset'); + }); + }); + + describe('setResetPassword', () => { + it('should change password', async () => { + const newPassword = 'newpass'; + const userId = await mongo.createUser(user); + await delay(10); + await mongo.setResetPassword(userId, 'toto', newPassword); + const retUser = await mongo.findUserById(userId); + expect(retUser.services.password.bcrypt).toBeTruthy(); + expect(retUser.services.password.bcrypt).toEqual(newPassword); + expect(retUser.createdAt).not.toEqual(retUser.updatedAt); + }); + }); +}); diff --git a/packages/database-mongo/package.json b/packages/database-mongo/package.json new file mode 100644 index 000000000..b1e125452 --- /dev/null +++ b/packages/database-mongo/package.json @@ -0,0 +1,43 @@ +{ + "name": "@accounts/mongo", + "version": "0.1.0-beta.3", + "description": "MongoDB adaptor for accounts", + "main": "lib/index.js", + "typings": "lib/index.d.ts", + "scripts": { + "start": "tsc --watch", + "compile": "tsc", + "testonly": "jest", + "test:watch": "jest --watch", + "coverage": "yarn testonly --coverage", + "prepublishOnly": "yarn compile" + }, + "files": ["src", "lib"], + "jest": { + "transform": { + ".(ts|tsx)": "/../../node_modules/ts-jest/preprocessor.js" + }, + "testRegex": "./__tests__/.*.ts$", + "moduleFileExtensions": ["ts", "js"] + }, + "repository": { + "type": "git", + "url": "https://github.com/accounts-js/accounts/tree/master/packages/database-mongo" + }, + "author": "Leo Pradel", + "license": "MIT", + "devDependencies": { + "@accounts/common": "0.1.0-beta.3", + "@accounts/server": "0.1.0-beta.3", + "@types/lodash": "4.14.104", + "@types/mongodb": "3.0.7" + }, + "peerDependencies": { + "@accounts/common": "^0.1.0-beta.3", + "@accounts/server": "^0.1.0-beta.3" + }, + "dependencies": { + "lodash": "^4.17.4", + "mongodb": "^3.0.0" + } +} diff --git a/packages/database-mongo/src/index.ts b/packages/database-mongo/src/index.ts new file mode 100644 index 000000000..78dbc0347 --- /dev/null +++ b/packages/database-mongo/src/index.ts @@ -0,0 +1,4 @@ +import { Mongo } from './mongo'; + +export { Mongo }; +export default Mongo; diff --git a/packages/database-mongo/src/mongo.ts b/packages/database-mongo/src/mongo.ts new file mode 100644 index 000000000..854c5f316 --- /dev/null +++ b/packages/database-mongo/src/mongo.ts @@ -0,0 +1,511 @@ +import { ObjectID, Db, Collection } from 'mongodb'; +import { get } from 'lodash'; +import { CreateUserType, UserObjectType, SessionType } from '@accounts/common'; +import { DBInterface, ConnectionInformationsType } from '@accounts/server'; + +export interface MongoOptionsType { + // The users collection name, default 'users'. + collectionName?: string; + // The sessions collection name, default 'sessions'. + sessionCollectionName?: string; + // The timestamps for the users and sessions collection, default 'createdAt' and 'updatedAt'. + timestamps?: { + createdAt: string; + updatedAt: string; + }; + // Should the user collection use _id as string or ObjectId, default 'true'. + convertUserIdToMongoObjectId?: boolean; + // Should the session collection use _id as string or ObjectId, default 'true'. + convertSessionIdToMongoObjectId?: boolean; + // Perform case intensitive query for user name, default 'true'. + caseSensitiveUserName?: boolean; + // Function that generate the id for new objects. + idProvider?: () => string | object; + // Function that generate the date for the timestamps. + dateProvider?: (date?: Date) => any; +} + +export interface MongoUserObjectType { + _id?: string | object; + username?: string; + profile?: object; + services: { + password?: { + bcrypt: string; + }; + }; + emails?: [ + { + address: string; + verified: boolean; + } + ]; +} + +const toMongoID = objectId => { + if (typeof objectId === 'string') { + return new ObjectID(objectId); + } + return objectId; +}; + +const defaultOptions = { + collectionName: 'users', + sessionCollectionName: 'sessions', + timestamps: { + createdAt: 'createdAt', + updatedAt: 'updatedAt', + }, + convertUserIdToMongoObjectId: true, + convertSessionIdToMongoObjectId: true, + caseSensitiveUserName: true, + idProvider: null, + dateProvider: (date?: Date) => (date ? date.getTime() : Date.now()), +}; + +export class Mongo implements DBInterface { + // Options of Mongo class + private options: MongoOptionsType; + // Db object + private db: Db; + // Account collection + private collection: Collection; + // Session collection + private sessionCollection: Collection; + + constructor(db: any, options?: MongoOptionsType) { + this.options = { ...defaultOptions, ...options }; + if (!db) { + throw new Error('A database connection is required'); + } + this.db = db; + this.collection = this.db.collection(this.options.collectionName); + this.sessionCollection = this.db.collection( + this.options.sessionCollectionName + ); + } + + public async setupIndexes(): Promise { + await this.sessionCollection.createIndex('token', { + unique: true, + sparse: true, + }); + await this.collection.createIndex('username', { + unique: true, + sparse: true, + }); + await this.collection.createIndex('emails.address', { + unique: true, + sparse: true, + }); + } + + public async createUser(options: CreateUserType): Promise { + const user: MongoUserObjectType = { + services: {}, + profile: {}, + [this.options.timestamps.createdAt]: this.options.dateProvider(), + [this.options.timestamps.updatedAt]: this.options.dateProvider(), + }; + if (options.password) { + user.services.password = { bcrypt: options.password }; + } + if (options.username) { + user.username = options.username; + } + if (options.email) { + user.emails = [{ address: options.email.toLowerCase(), verified: false }]; + } + if (options.profile) { + user.profile = options.profile; + } + if (this.options.idProvider) { + user._id = this.options.idProvider(); + } + const ret = await this.collection.insertOne(user); + return ret.ops[0]._id; + } + + public async findUserById(userId: string): Promise { + const id = this.options.convertUserIdToMongoObjectId + ? toMongoID(userId) + : userId; + const user = await this.collection.findOne({ _id: id }); + if (user) { + user.id = user._id; + } + return user; + } + + public async findUserByEmail(email: string): Promise { + const user = await this.collection.findOne({ + 'emails.address': email.toLowerCase(), + }); + if (user) { + user.id = user._id; + } + return user; + } + + public async findUserByUsername( + username: string + ): Promise { + const filter = this.options.caseSensitiveUserName + ? { username } + : { + $where: `obj.username && (obj.username.toLowerCase() === "${username.toLowerCase()}")`, + }; + const user = await this.collection.findOne(filter); + if (user) { + user.id = user._id; + } + return user; + } + + public async findPasswordHash(userId: string): Promise { + const id = this.options.convertUserIdToMongoObjectId + ? toMongoID(userId) + : userId; + const user = await this.findUserById(id); + if (user) { + return get(user, 'services.password.bcrypt'); + } + return null; + } + + public async findUserByEmailVerificationToken( + token: string + ): Promise { + const user = await this.collection.findOne({ + 'services.email.verificationTokens.token': token, + }); + if (user) { + user.id = user._id; + } + return user; + } + + public async findUserByResetPasswordToken( + token: string + ): Promise { + const user = await this.collection.findOne({ + 'services.password.reset.token': token, + }); + if (user) { + user.id = user._id; + } + return user; + } + + public async findUserByServiceId( + serviceName: string, + serviceId: string + ): Promise { + const user = await this.collection.findOne({ + [`services.${serviceName}.id`]: serviceId, + }); + if (user) { + user.id = user._id; + } + return user; + } + + public async addEmail( + userId: string, + newEmail: string, + verified: boolean + ): Promise { + const id = this.options.convertUserIdToMongoObjectId + ? toMongoID(userId) + : userId; + const ret = await this.collection.update( + { _id: id }, + { + $addToSet: { + emails: { + address: newEmail.toLowerCase(), + verified, + }, + }, + $set: { + [this.options.timestamps.updatedAt]: this.options.dateProvider(), + }, + } + ); + if (ret.result.nModified === 0) { + throw new Error('User not found'); + } + } + + public async removeEmail(userId: string, email: string): Promise { + const id = this.options.convertUserIdToMongoObjectId + ? toMongoID(userId) + : userId; + const ret = await this.collection.update( + { _id: id }, + { + $pull: { emails: { address: email.toLowerCase() } }, + $set: { + [this.options.timestamps.updatedAt]: this.options.dateProvider(), + }, + } + ); + if (ret.result.nModified === 0) { + throw new Error('User not found'); + } + } + + public async verifyEmail(userId: string, email: string): Promise { + const id = this.options.convertUserIdToMongoObjectId + ? toMongoID(userId) + : userId; + const ret = await this.collection.update( + { _id: id, 'emails.address': email }, + { + $set: { + 'emails.$.verified': true, + [this.options.timestamps.updatedAt]: this.options.dateProvider(), + }, + $pull: { 'services.email.verificationTokens': { address: email } }, + } + ); + if (ret.result.nModified === 0) { + throw new Error('User not found'); + } + } + + public async setUsername(userId: string, newUsername: string): Promise { + const id = this.options.convertUserIdToMongoObjectId + ? toMongoID(userId) + : userId; + const ret = await this.collection.update( + { _id: id }, + { + $set: { + username: newUsername, + [this.options.timestamps.updatedAt]: this.options.dateProvider(), + }, + } + ); + if (ret.result.nModified === 0) { + throw new Error('User not found'); + } + } + + public async setPassword(userId: string, newPassword: string): Promise { + const id = this.options.convertUserIdToMongoObjectId + ? toMongoID(userId) + : userId; + const ret = await this.collection.update( + { _id: id }, + { + $set: { + 'services.password.bcrypt': newPassword, + [this.options.timestamps.updatedAt]: this.options.dateProvider(), + }, + $unset: { + 'services.password.reset': '', + }, + } + ); + if (ret.result.nModified === 0) { + throw new Error('User not found'); + } + } + + public async setProfile(userId: string, profile: object): Promise { + const id = this.options.convertUserIdToMongoObjectId + ? toMongoID(userId) + : userId; + await this.collection.update( + { _id: id }, + { + $set: { + profile, + [this.options.timestamps.updatedAt]: this.options.dateProvider(), + }, + } + ); + return profile; + } + + public async setService( + userId: string, + serviceName: string, + service: object + ): Promise { + const id = this.options.convertUserIdToMongoObjectId + ? toMongoID(userId) + : userId; + await this.collection.update( + { _id: id }, + { + $set: { + [`services.${serviceName}`]: service, + [this.options.timestamps.updatedAt]: this.options.dateProvider(), + }, + } + ); + } + + public async unsetService( + userId: string, + serviceName: string + ): Promise { + const id = this.options.convertUserIdToMongoObjectId + ? toMongoID(userId) + : userId; + await this.collection.update( + { _id: id }, + { + $set: { + [this.options.timestamps.updatedAt]: this.options.dateProvider(), + }, + $unset: { + [`services.${serviceName}`]: '', + }, + } + ); + } + + public async createSession( + userId: string, + token: string, + connection: ConnectionInformationsType = {}, + extraData?: object + ): Promise { + const session = { + userId, + token, + userAgent: connection.userAgent, + ip: connection.ip, + extraData, + valid: true, + [this.options.timestamps.createdAt]: this.options.dateProvider(), + [this.options.timestamps.updatedAt]: this.options.dateProvider(), + }; + + if (this.options.idProvider) { + session._id = this.options.idProvider(); + } + + const ret = await this.sessionCollection.insertOne(session); + return ret.ops[0]._id; + } + + public async updateSession( + sessionId: string, + connection: ConnectionInformationsType + ): Promise { + // tslint:disable-next-line variable-name + const _id = this.options.convertSessionIdToMongoObjectId + ? toMongoID(sessionId) + : sessionId; + await this.sessionCollection.update( + { _id }, + { + $set: { + userAgent: connection.userAgent, + ip: connection.ip, + [this.options.timestamps.updatedAt]: this.options.dateProvider(), + }, + } + ); + } + + public async invalidateSession(sessionId: string): Promise { + // tslint:disable-next-line variable-name + const _id = this.options.convertSessionIdToMongoObjectId + ? toMongoID(sessionId) + : sessionId; + await this.sessionCollection.update( + { _id }, + { + $set: { + valid: false, + [this.options.timestamps.updatedAt]: this.options.dateProvider(), + }, + } + ); + } + + public async invalidateAllSessions(userId: string): Promise { + await this.sessionCollection.updateMany( + { userId }, + { + $set: { + valid: false, + [this.options.timestamps.updatedAt]: this.options.dateProvider(), + }, + } + ); + } + + public async findSessionByToken(token: string): Promise { + const session = await this.sessionCollection.findOne({ token }); + if (session) { + session.id = session._id; + } + return session; + } + + public async findSessionById(sessionId: string): Promise { + // tslint:disable-next-line variable-name + const _id = this.options.convertSessionIdToMongoObjectId + ? toMongoID(sessionId) + : sessionId; + const session = await this.sessionCollection.findOne({ _id }); + if (session) { + session.id = session._id; + } + return session; + } + + public async addEmailVerificationToken( + userId: string, + email: string, + token: string + ): Promise { + await this.collection.update( + { _id: userId }, + { + $push: { + 'services.email.verificationTokens': { + token, + address: email.toLowerCase(), + when: this.options.dateProvider(), + }, + }, + } + ); + } + + public async addResetPasswordToken( + userId: string, + email: string, + token: string, + reason: string = 'reset' + ): Promise { + await this.collection.update( + { _id: userId }, + { + $push: { + 'services.password.reset': { + token, + address: email.toLowerCase(), + when: this.options.dateProvider(), + reason, + }, + }, + } + ); + } + + public async setResetPassword( + userId: string, + email: string, + newPassword: string + ): Promise { + await this.setPassword(userId, newPassword); + } +} diff --git a/packages/database-mongo/tsconfig.json b/packages/database-mongo/tsconfig.json new file mode 100644 index 000000000..823be082e --- /dev/null +++ b/packages/database-mongo/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "rootDir": "./src", + "outDir": "./lib", + }, + "exclude": [ + "node_modules", + "__tests__", + "lib" + ] +} diff --git a/packages/database-mongo/yarn.lock b/packages/database-mongo/yarn.lock new file mode 100644 index 000000000..28d47cf4f --- /dev/null +++ b/packages/database-mongo/yarn.lock @@ -0,0 +1,3592 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@accounts/common@0.1.0-beta.3", "@accounts/common@^0.1.0-beta.3": + version "0.1.0-beta.3" + resolved "https://registry.yarnpkg.com/@accounts/common/-/common-0.1.0-beta.3.tgz#311a9676526160b37fcb8aec3526f3d0e0cad9e6" + dependencies: + lodash "^4.16.4" + +"@accounts/server@0.1.0-beta.3": + version "0.1.0-beta.3" + resolved "https://registry.yarnpkg.com/@accounts/server/-/server-0.1.0-beta.3.tgz#fc584094bedce26c115d9e19679dcf0259a4a675" + dependencies: + "@accounts/common" "^0.1.0-beta.3" + babel-polyfill "^6.23.0" + bcryptjs "^2.4.0" + jsonwebtoken "^8.0.0" + jwt-decode "^2.1.0" + lodash "^4.16.4" + +"@accounts/tslint-config-accounts@0.0.9": + version "0.0.9" + resolved "https://registry.yarnpkg.com/@accounts/tslint-config-accounts/-/tslint-config-accounts-0.0.9.tgz#a2073361c4127ba7c8662cd72e08a28a794a44df" + dependencies: + tslint-config-prettier "^1.1.0" + tslint-eslint-rules "^4.1.1" + +"@babel/code-frame@^7.0.0-beta.35": + version "7.0.0-beta.40" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0-beta.40.tgz#37e2b0cf7c56026b4b21d3927cadf81adec32ac6" + dependencies: + "@babel/highlight" "7.0.0-beta.40" + +"@babel/highlight@7.0.0-beta.40": + version "7.0.0-beta.40" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.0.0-beta.40.tgz#b43d67d76bf46e1d10d227f68cddcd263786b255" + dependencies: + chalk "^2.0.0" + esutils "^2.0.2" + js-tokens "^3.0.0" + +"@types/bson@*": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@types/bson/-/bson-1.0.3.tgz#6c26f0876bf9d8cbb06edd4019e29354bf3a03e0" + dependencies: + "@types/node" "*" + +"@types/events@*": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@types/events/-/events-1.2.0.tgz#81a6731ce4df43619e5c8c945383b3e62a89ea86" + +"@types/jest@22.2.0": + version "22.2.0" + resolved "https://registry.yarnpkg.com/@types/jest/-/jest-22.2.0.tgz#55ce83139f7ad1b48b414c3927746614c6963c0f" + +"@types/lodash@4.14.104": + version "4.14.104" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.104.tgz#53ee2357fa2e6e68379341d92eb2ecea4b11bb80" + +"@types/mongodb@3.0.7": + version "3.0.7" + resolved "https://registry.yarnpkg.com/@types/mongodb/-/mongodb-3.0.7.tgz#f71f403b392b1f5414b85ec395360868edb4f6e3" + dependencies: + "@types/bson" "*" + "@types/events" "*" + "@types/node" "*" + +"@types/node@*": + version "8.0.10" + resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.10.tgz#12efec9183b072d5f951cf86395a4c780f868a17" + +"@types/node@9.4.7": + version "9.4.7" + resolved "https://registry.yarnpkg.com/@types/node/-/node-9.4.7.tgz#57d81cd98719df2c9de118f2d5f3b1120dcd7275" + +abab@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.4.tgz#5faad9c2c07f60dd76770f71cf025b62a63cfd4e" + +abbrev@1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" + +acorn-globals@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-4.1.0.tgz#ab716025dbe17c54d3ef81d32ece2b2d99fe2538" + dependencies: + acorn "^5.0.0" + +acorn@^5.0.0, acorn@^5.3.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.5.0.tgz#1abb587fbf051f94e3de20e6b26ef910b1828298" + +ajv@^4.9.1: + version "4.11.8" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536" + dependencies: + co "^4.6.0" + json-stable-stringify "^1.0.1" + +ajv@^5.1.0: + version "5.5.2" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965" + dependencies: + co "^4.6.0" + fast-deep-equal "^1.0.0" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.3.0" + +align-text@^0.1.1, align-text@^0.1.3: + version "0.1.4" + resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" + dependencies: + kind-of "^3.0.2" + longest "^1.0.1" + repeat-string "^1.5.2" + +amdefine@>=0.0.4: + version "1.0.1" + resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" + +ansi-escapes@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.0.0.tgz#ec3e8b4e9f8064fc02c3ac9b65f1c275bda8ef92" + +ansi-regex@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.0.0.tgz#c5061b6e0ef8a81775e50f5d66151bf6bf371107" + +ansi-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" + +ansi-styles@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" + +ansi-styles@^3.1.0, ansi-styles@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.0.tgz#c159b8d5be0f9e5a6f346dab94f16ce022161b88" + dependencies: + color-convert "^1.9.0" + +anymatch@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-1.3.0.tgz#a3e52fa39168c825ff57b0248126ce5a8ff95507" + dependencies: + arrify "^1.0.0" + micromatch "^2.1.5" + +append-transform@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/append-transform/-/append-transform-0.4.0.tgz#d76ebf8ca94d276e247a36bad44a4b74ab611991" + dependencies: + default-require-extensions "^1.0.0" + +aproba@^1.0.3: + version "1.2.0" + resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" + +are-we-there-yet@~1.1.2: + version "1.1.4" + resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz#bb5dca382bb94f05e15194373d16fd3ba1ca110d" + dependencies: + delegates "^1.0.0" + readable-stream "^2.0.6" + +argparse@^1.0.7: + version "1.0.9" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.9.tgz#73d83bc263f86e97f8cc4f6bae1b0e90a7d22c86" + dependencies: + sprintf-js "~1.0.2" + +argv@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/argv/-/argv-0.0.2.tgz#ecbd16f8949b157183711b1bda334f37840185ab" + +arr-diff@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf" + dependencies: + arr-flatten "^1.0.1" + +arr-flatten@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.0.1.tgz#e5ffe54d45e19f32f216e91eb99c8ce892bb604b" + +array-equal@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/array-equal/-/array-equal-1.0.0.tgz#8c2a5ef2472fd9ea742b04c77a75093ba2757c93" + +array-filter@~0.0.0: + version "0.0.1" + resolved "https://registry.yarnpkg.com/array-filter/-/array-filter-0.0.1.tgz#7da8cf2e26628ed732803581fd21f67cacd2eeec" + +array-map@~0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/array-map/-/array-map-0.0.0.tgz#88a2bab73d1cf7bcd5c1b118a003f66f665fa662" + +array-reduce@~0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/array-reduce/-/array-reduce-0.0.0.tgz#173899d3ffd1c7d9383e4479525dbe278cab5f2b" + +array-unique@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" + +arrify@^1.0.0, arrify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" + +asn1@~0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.3.tgz#dac8787713c9966849fc8180777ebe9c1ddf3b86" + +assert-plus@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234" + +assert-plus@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" + +astral-regex@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9" + +async-each@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d" + +async-limiter@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.0.tgz#78faed8c3d074ab81f22b4e985d79e8738f720f8" + +async@^1.4.0: + version "1.5.2" + resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" + +async@^2.1.4: + version "2.5.0" + resolved "https://registry.yarnpkg.com/async/-/async-2.5.0.tgz#843190fd6b7357a0b9e1c956edddd5ec8462b54d" + dependencies: + lodash "^4.14.0" + +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + +aws-sign2@~0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" + +aws-sign2@~0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" + +aws4@^1.2.1: + version "1.5.0" + resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.5.0.tgz#0a29ffb79c31c9e712eeb087e8e7a64b4a56d755" + +aws4@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" + +babel-code-frame@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.22.0.tgz#027620bee567a88c32561574e7fd0801d33118e4" + dependencies: + chalk "^1.1.0" + esutils "^2.0.2" + js-tokens "^3.0.0" + +babel-core@^6.0.0, babel-core@^6.24.1: + version "6.25.0" + resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.25.0.tgz#7dd42b0463c742e9d5296deb3ec67a9322dad729" + dependencies: + babel-code-frame "^6.22.0" + babel-generator "^6.25.0" + babel-helpers "^6.24.1" + babel-messages "^6.23.0" + babel-register "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.25.0" + babel-traverse "^6.25.0" + babel-types "^6.25.0" + babylon "^6.17.2" + convert-source-map "^1.1.0" + debug "^2.1.1" + json5 "^0.5.0" + lodash "^4.2.0" + minimatch "^3.0.2" + path-is-absolute "^1.0.0" + private "^0.1.6" + slash "^1.0.0" + source-map "^0.5.0" + +babel-generator@^6.18.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.22.0.tgz#d642bf4961911a8adc7c692b0c9297f325cda805" + dependencies: + babel-messages "^6.22.0" + babel-runtime "^6.22.0" + babel-types "^6.22.0" + detect-indent "^4.0.0" + jsesc "^1.3.0" + lodash "^4.2.0" + source-map "^0.5.0" + +babel-generator@^6.25.0: + version "6.25.0" + resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.25.0.tgz#33a1af70d5f2890aeb465a4a7793c1df6a9ea9fc" + dependencies: + babel-messages "^6.23.0" + babel-runtime "^6.22.0" + babel-types "^6.25.0" + detect-indent "^4.0.0" + jsesc "^1.3.0" + lodash "^4.2.0" + source-map "^0.5.0" + trim-right "^1.0.1" + +babel-helpers@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helpers/-/babel-helpers-6.24.1.tgz#3471de9caec388e5c850e597e58a26ddf37602b2" + dependencies: + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-jest@^22.4.1: + version "22.4.1" + resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-22.4.1.tgz#ff53ebca45957347f27ff4666a31499fbb4c4ddd" + dependencies: + babel-plugin-istanbul "^4.1.5" + babel-preset-jest "^22.4.1" + +babel-messages@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.22.0.tgz#36066a214f1217e4ed4164867669ecb39e3ea575" + dependencies: + babel-runtime "^6.22.0" + +babel-messages@^6.23.0: + version "6.23.0" + resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-istanbul@^4.1.4: + version "4.1.4" + resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.4.tgz#18dde84bf3ce329fddf3f4103fae921456d8e587" + dependencies: + find-up "^2.1.0" + istanbul-lib-instrument "^1.7.2" + test-exclude "^4.1.1" + +babel-plugin-istanbul@^4.1.5: + version "4.1.5" + resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.5.tgz#6760cdd977f411d3e175bb064f2bc327d99b2b6e" + dependencies: + find-up "^2.1.0" + istanbul-lib-instrument "^1.7.5" + test-exclude "^4.1.1" + +babel-plugin-jest-hoist@^22.4.1: + version "22.4.1" + resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-22.4.1.tgz#d712fe5da8b6965f3191dacddbefdbdf4fb66d63" + +babel-plugin-syntax-object-rest-spread@^6.13.0: + version "6.13.0" + resolved "https://registry.yarnpkg.com/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz#fd6536f2bce13836ffa3a5458c4903a597bb3bf5" + +babel-plugin-transform-es2015-modules-commonjs@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.24.1.tgz#d3e310b40ef664a36622200097c6d440298f2bfe" + dependencies: + babel-plugin-transform-strict-mode "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-types "^6.24.1" + +babel-plugin-transform-strict-mode@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz#d5faf7aa578a65bbe591cf5edae04a0c67020758" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-polyfill@^6.23.0: + version "6.23.0" + resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.23.0.tgz#8364ca62df8eafb830499f699177466c3b03499d" + dependencies: + babel-runtime "^6.22.0" + core-js "^2.4.0" + regenerator-runtime "^0.10.0" + +babel-preset-jest@^22.4.0, babel-preset-jest@^22.4.1: + version "22.4.1" + resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-22.4.1.tgz#efa2e5f5334242a9457a068452d7d09735db172a" + dependencies: + babel-plugin-jest-hoist "^22.4.1" + babel-plugin-syntax-object-rest-spread "^6.13.0" + +babel-register@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.24.1.tgz#7e10e13a2f71065bdfad5a1787ba45bca6ded75f" + dependencies: + babel-core "^6.24.1" + babel-runtime "^6.22.0" + core-js "^2.4.0" + home-or-tmp "^2.0.0" + lodash "^4.2.0" + mkdirp "^0.5.1" + source-map-support "^0.4.2" + +babel-runtime@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.22.0.tgz#1cf8b4ac67c77a4ddb0db2ae1f74de52ac4ca611" + dependencies: + core-js "^2.4.0" + regenerator-runtime "^0.10.0" + +babel-runtime@^6.9.2: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" + dependencies: + core-js "^2.4.0" + regenerator-runtime "^0.11.0" + +babel-template@^6.16.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.22.0.tgz#403d110905a4626b317a2a1fcb8f3b73204b2edb" + dependencies: + babel-runtime "^6.22.0" + babel-traverse "^6.22.0" + babel-types "^6.22.0" + babylon "^6.11.0" + lodash "^4.2.0" + +babel-template@^6.24.1, babel-template@^6.25.0: + version "6.25.0" + resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.25.0.tgz#665241166b7c2aa4c619d71e192969552b10c071" + dependencies: + babel-runtime "^6.22.0" + babel-traverse "^6.25.0" + babel-types "^6.25.0" + babylon "^6.17.2" + lodash "^4.2.0" + +babel-traverse@^6.18.0, babel-traverse@^6.22.0: + version "6.22.1" + resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.22.1.tgz#3b95cd6b7427d6f1f757704908f2fc9748a5f59f" + dependencies: + babel-code-frame "^6.22.0" + babel-messages "^6.22.0" + babel-runtime "^6.22.0" + babel-types "^6.22.0" + babylon "^6.15.0" + debug "^2.2.0" + globals "^9.0.0" + invariant "^2.2.0" + lodash "^4.2.0" + +babel-traverse@^6.25.0: + version "6.25.0" + resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.25.0.tgz#2257497e2fcd19b89edc13c4c91381f9512496f1" + dependencies: + babel-code-frame "^6.22.0" + babel-messages "^6.23.0" + babel-runtime "^6.22.0" + babel-types "^6.25.0" + babylon "^6.17.2" + debug "^2.2.0" + globals "^9.0.0" + invariant "^2.2.0" + lodash "^4.2.0" + +babel-types@^6.18.0, babel-types@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.22.0.tgz#2a447e8d0ea25d2512409e4175479fd78cc8b1db" + dependencies: + babel-runtime "^6.22.0" + esutils "^2.0.2" + lodash "^4.2.0" + to-fast-properties "^1.0.1" + +babel-types@^6.24.1, babel-types@^6.25.0: + version "6.25.0" + resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.25.0.tgz#70afb248d5660e5d18f811d91c8303b54134a18e" + dependencies: + babel-runtime "^6.22.0" + esutils "^2.0.2" + lodash "^4.2.0" + to-fast-properties "^1.0.1" + +babylon@^6.11.0: + version "6.14.1" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.14.1.tgz#956275fab72753ad9b3435d7afe58f8bf0a29815" + +babylon@^6.15.0: + version "6.15.0" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.15.0.tgz#ba65cfa1a80e1759b0e89fb562e27dccae70348e" + +babylon@^6.17.2, babylon@^6.17.4: + version "6.17.4" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.17.4.tgz#3e8b7402b88d22c3423e137a1577883b15ff869a" + +babylon@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" + +balanced-match@^0.4.1: + version "0.4.2" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838" + +balanced-match@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" + +base64url@2.0.0, base64url@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/base64url/-/base64url-2.0.0.tgz#eac16e03ea1438eff9423d69baa36262ed1f70bb" + +bcrypt-pbkdf@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.0.tgz#3ca76b85241c7170bf7d9703e7b9aa74630040d4" + dependencies: + tweetnacl "^0.14.3" + +bcryptjs@^2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/bcryptjs/-/bcryptjs-2.4.0.tgz#fb7f4a0b133854503fe1b2da3f25db834cf0e678" + +binary-extensions@^1.0.0: + version "1.11.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.11.0.tgz#46aa1751fb6a2f93ee5e689bb1087d4b14c6c205" + +block-stream@*: + version "0.0.9" + resolved "https://registry.yarnpkg.com/block-stream/-/block-stream-0.0.9.tgz#13ebfe778a03205cfe03751481ebb4b3300c126a" + dependencies: + inherits "~2.0.0" + +boom@2.x.x: + version "2.10.1" + resolved "https://registry.yarnpkg.com/boom/-/boom-2.10.1.tgz#39c8918ceff5799f83f9492a848f625add0c766f" + dependencies: + hoek "2.x.x" + +boom@4.x.x: + version "4.3.1" + resolved "https://registry.yarnpkg.com/boom/-/boom-4.3.1.tgz#4f8a3005cb4a7e3889f749030fd25b96e01d2e31" + dependencies: + hoek "4.x.x" + +boom@5.x.x: + version "5.2.0" + resolved "https://registry.yarnpkg.com/boom/-/boom-5.2.0.tgz#5dd9da6ee3a5f302077436290cb717d3f4a54e02" + dependencies: + hoek "4.x.x" + +brace-expansion@^1.0.0: + version "1.1.6" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.6.tgz#7197d7eaa9b87e648390ea61fc66c84427420df9" + dependencies: + balanced-match "^0.4.1" + concat-map "0.0.1" + +brace-expansion@^1.1.7: + version "1.1.8" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292" + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +braces@^1.8.2: + version "1.8.5" + resolved "https://registry.yarnpkg.com/braces/-/braces-1.8.5.tgz#ba77962e12dff969d6b76711e914b737857bf6a7" + dependencies: + expand-range "^1.8.1" + preserve "^0.2.0" + repeat-element "^1.1.2" + +browser-process-hrtime@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-0.1.2.tgz#425d68a58d3447f02a04aa894187fce8af8b7b8e" + +browser-resolve@^1.11.2: + version "1.11.2" + resolved "https://registry.yarnpkg.com/browser-resolve/-/browser-resolve-1.11.2.tgz#8ff09b0a2c421718a1051c260b32e48f442938ce" + dependencies: + resolve "1.1.7" + +bser@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/bser/-/bser-2.0.0.tgz#9ac78d3ed5d915804fd87acb158bc797147a1719" + dependencies: + node-int64 "^0.4.0" + +bson@~1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/bson/-/bson-1.0.4.tgz#93c10d39eaa5b58415cbc4052f3e53e562b0b72c" + +buffer-equal-constant-time@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz#f8e71132f7ffe6e01a5c9697a4c6f3e48d5cc819" + +builtin-modules@^1.0.0, builtin-modules@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" + +callsites@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/callsites/-/callsites-2.0.0.tgz#06eb84f00eea413da86affefacbffb36093b3c50" + +camelcase@^1.0.2: + version "1.2.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39" + +camelcase@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" + +caseless@~0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.11.0.tgz#715b96ea9841593cc33067923f5ec60ebda4f7d7" + +caseless@~0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" + +center-align@^0.1.1: + version "0.1.3" + resolved "https://registry.yarnpkg.com/center-align/-/center-align-0.1.3.tgz#aa0d32629b6ee972200411cbd4461c907bc2b7ad" + dependencies: + align-text "^0.1.3" + lazy-cache "^1.0.3" + +chalk@^1.1.0, chalk@^1.1.1: + version "1.1.3" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" + dependencies: + ansi-styles "^2.2.1" + escape-string-regexp "^1.0.2" + has-ansi "^2.0.0" + strip-ansi "^3.0.0" + supports-color "^2.0.0" + +chalk@^2.0.0: + version "2.3.1" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.1.tgz#523fe2678aec7b04e8041909292fe8b17059b796" + dependencies: + ansi-styles "^3.2.0" + escape-string-regexp "^1.0.5" + supports-color "^5.2.0" + +chalk@^2.0.1, chalk@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.0.tgz#b5ea48efc9c1793dccc9b4767c93914d3f2d52ba" + dependencies: + ansi-styles "^3.1.0" + escape-string-regexp "^1.0.5" + supports-color "^4.0.0" + +chokidar@^1.6.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468" + dependencies: + anymatch "^1.3.0" + async-each "^1.0.0" + glob-parent "^2.0.0" + inherits "^2.0.1" + is-binary-path "^1.0.0" + is-glob "^2.0.0" + path-is-absolute "^1.0.0" + readdirp "^2.0.0" + optionalDependencies: + fsevents "^1.0.0" + +ci-info@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.0.0.tgz#dc5285f2b4e251821683681c381c3388f46ec534" + +cliui@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-2.1.0.tgz#4b475760ff80264c762c3a1719032e91c7fea0d1" + dependencies: + center-align "^0.1.1" + right-align "^0.1.1" + wordwrap "0.0.2" + +cliui@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-4.0.0.tgz#743d4650e05f36d1ed2575b59638d87322bfbbcc" + dependencies: + string-width "^2.1.1" + strip-ansi "^4.0.0" + wrap-ansi "^2.0.0" + +co@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" + +code-point-at@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" + +codecov@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/codecov/-/codecov-3.0.0.tgz#c273b8c4f12945723e8dc9d25803d89343e5f28e" + dependencies: + argv "0.0.2" + request "2.81.0" + urlgrey "0.4.4" + +color-convert@^1.9.0: + version "1.9.0" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.0.tgz#1accf97dd739b983bf994d56fec8f95853641b7a" + dependencies: + color-name "^1.1.1" + +color-name@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.2.tgz#5c8ab72b64bd2215d617ae9559ebb148475cf98d" + +combined-stream@1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.6.tgz#723e7df6e801ac5613113a7e445a9b69cb632818" + dependencies: + delayed-stream "~1.0.0" + +combined-stream@^1.0.5, combined-stream@~1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009" + dependencies: + delayed-stream "~1.0.0" + +commander@^2.12.1: + version "2.14.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.14.1.tgz#2235123e37af8ca3c65df45b026dbd357b01b9aa" + +commander@^2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" + dependencies: + graceful-readlink ">= 1.0.0" + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + +console-control-strings@^1.0.0, console-control-strings@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" + +content-type-parser@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/content-type-parser/-/content-type-parser-1.0.2.tgz#caabe80623e63638b2502fd4c7f12ff4ce2352e7" + +convert-source-map@^1.1.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.3.0.tgz#e9f3e9c6e2728efc2676696a70eb382f73106a67" + +convert-source-map@^1.4.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.5.0.tgz#9acd70851c6d5dfdd93d9282e5edf94a03ff46b5" + +core-js@^2.4.0: + version "2.4.1" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.4.1.tgz#4de911e667b0eae9124e34254b53aea6fc618d3e" + +core-util-is@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + +coveralls@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/coveralls/-/coveralls-3.0.0.tgz#22ef730330538080d29b8c151dc9146afde88a99" + dependencies: + js-yaml "^3.6.1" + lcov-parse "^0.0.10" + log-driver "^1.2.5" + minimist "^1.2.0" + request "^2.79.0" + +cpx@^1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/cpx/-/cpx-1.5.0.tgz#185be018511d87270dedccc293171e37655ab88f" + dependencies: + babel-runtime "^6.9.2" + chokidar "^1.6.0" + duplexer "^0.1.1" + glob "^7.0.5" + glob2base "^0.0.12" + minimatch "^3.0.2" + mkdirp "^0.5.1" + resolve "^1.1.7" + safe-buffer "^5.0.1" + shell-quote "^1.6.1" + subarg "^1.0.0" + +cross-spawn@^4.0.0: + version "4.0.2" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-4.0.2.tgz#7b9247621c23adfdd3856004a823cbe397424d41" + dependencies: + lru-cache "^4.0.1" + which "^1.2.9" + +cross-spawn@^5.0.1: + version "5.1.0" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" + dependencies: + lru-cache "^4.0.1" + shebang-command "^1.2.0" + which "^1.2.9" + +cryptiles@2.x.x: + version "2.0.5" + resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8" + dependencies: + boom "2.x.x" + +cryptiles@3.x.x: + version "3.1.2" + resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-3.1.2.tgz#a89fbb220f5ce25ec56e8c4aa8a4fd7b5b0d29fe" + dependencies: + boom "5.x.x" + +cssom@0.3.x: + version "0.3.1" + resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.3.1.tgz#c9e37ef2490e64f6d1baa10fda852257082c25d3" + +"cssom@>= 0.3.2 < 0.4.0": + version "0.3.2" + resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.3.2.tgz#b8036170c79f07a90ff2f16e22284027a243848b" + +"cssstyle@>= 0.2.37 < 0.3.0": + version "0.2.37" + resolved "https://registry.yarnpkg.com/cssstyle/-/cssstyle-0.2.37.tgz#541097234cb2513c83ceed3acddc27ff27987d54" + dependencies: + cssom "0.3.x" + +dashdash@^1.12.0: + version "1.14.1" + resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" + dependencies: + assert-plus "^1.0.0" + +debug@^2.1.1, debug@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" + dependencies: + ms "0.7.1" + +debug@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" + dependencies: + ms "2.0.0" + +decamelize@^1.0.0, decamelize@^1.1.1: + version "1.2.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + +deep-extend@~0.4.0: + version "0.4.2" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f" + +deep-is@~0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" + +default-require-extensions@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/default-require-extensions/-/default-require-extensions-1.0.0.tgz#f37ea15d3e13ffd9b437d33e1a75b5fb97874cb8" + dependencies: + strip-bom "^2.0.0" + +define-properties@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94" + dependencies: + foreach "^2.0.5" + object-keys "^1.0.8" + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + +delegates@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" + +detect-indent@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-4.0.0.tgz#f76d064352cdf43a1cb6ce619c4ee3a9475de208" + dependencies: + repeating "^2.0.0" + +detect-libc@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.2.tgz#71ad5d204bf17a6a6ca8f450c61454066ef461e1" + +detect-newline@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-2.1.0.tgz#f41f1c10be4b00e87b5f13da680759f2c5bfd3e2" + +diff@^3.2.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-3.3.0.tgz#056695150d7aa93237ca7e378ac3b1682b7963b9" + +doctrine@^0.7.2: + version "0.7.2" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-0.7.2.tgz#7cb860359ba3be90e040b26b729ce4bfa654c523" + dependencies: + esutils "^1.1.6" + isarray "0.0.1" + +domexception@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/domexception/-/domexception-1.0.1.tgz#937442644ca6a31261ef36e3ec677fe805582c90" + dependencies: + webidl-conversions "^4.0.2" + +duplexer@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1" + +ecc-jsbn@~0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505" + dependencies: + jsbn "~0.1.0" + +ecdsa-sig-formatter@1.0.9: + version "1.0.9" + resolved "https://registry.yarnpkg.com/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.9.tgz#4bc926274ec3b5abb5016e7e1d60921ac262b2a1" + dependencies: + base64url "^2.0.0" + safe-buffer "^5.0.1" + +error-ex@^1.2.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.0.tgz#e67b43f3e82c96ea3a584ffee0b9fc3325d802d9" + dependencies: + is-arrayish "^0.2.1" + +es-abstract@^1.5.1: + version "1.10.0" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.10.0.tgz#1ecb36c197842a00d8ee4c2dfd8646bb97d60864" + dependencies: + es-to-primitive "^1.1.1" + function-bind "^1.1.1" + has "^1.0.1" + is-callable "^1.1.3" + is-regex "^1.0.4" + +es-to-primitive@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d" + dependencies: + is-callable "^1.1.1" + is-date-object "^1.0.1" + is-symbol "^1.0.1" + +escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + +escodegen@^1.9.0: + version "1.9.1" + resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.9.1.tgz#dbae17ef96c8e4bedb1356f4504fa4cc2f7cb7e2" + dependencies: + esprima "^3.1.3" + estraverse "^4.2.0" + esutils "^2.0.2" + optionator "^0.8.1" + optionalDependencies: + source-map "~0.6.1" + +esprima@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633" + +esprima@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.0.tgz#4499eddcd1110e0b218bacf2fa7f7f59f55ca804" + +estraverse@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" + +esutils@^1.1.6: + version "1.1.6" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-1.1.6.tgz#c01ccaa9ae4b897c6d0c3e210ae52f3c7a844375" + +esutils@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" + +exec-sh@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/exec-sh/-/exec-sh-0.2.0.tgz#14f75de3f20d286ef933099b2ce50a90359cef10" + dependencies: + merge "^1.1.3" + +execa@^0.5.0: + version "0.5.1" + resolved "https://registry.yarnpkg.com/execa/-/execa-0.5.1.tgz#de3fb85cb8d6e91c85bcbceb164581785cb57b36" + dependencies: + cross-spawn "^4.0.0" + get-stream "^2.2.0" + is-stream "^1.1.0" + npm-run-path "^2.0.0" + p-finally "^1.0.0" + signal-exit "^3.0.0" + strip-eof "^1.0.0" + +execa@^0.8.0: + version "0.8.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-0.8.0.tgz#d8d76bbc1b55217ed190fd6dd49d3c774ecfc8da" + dependencies: + cross-spawn "^5.0.1" + get-stream "^3.0.0" + is-stream "^1.1.0" + npm-run-path "^2.0.0" + p-finally "^1.0.0" + signal-exit "^3.0.0" + strip-eof "^1.0.0" + +exit@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" + +expand-brackets@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" + dependencies: + is-posix-bracket "^0.1.0" + +expand-range@^1.8.1: + version "1.8.2" + resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-1.8.2.tgz#a299effd335fe2721ebae8e257ec79644fc85337" + dependencies: + fill-range "^2.1.0" + +expect@^22.4.0: + version "22.4.0" + resolved "https://registry.yarnpkg.com/expect/-/expect-22.4.0.tgz#371edf1ae15b83b5bf5ec34b42f1584660a36c16" + dependencies: + ansi-styles "^3.2.0" + jest-diff "^22.4.0" + jest-get-type "^22.1.0" + jest-matcher-utils "^22.4.0" + jest-message-util "^22.4.0" + jest-regex-util "^22.1.0" + +extend@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.0.tgz#5a474353b9f3353ddd8176dfd37b91c83a46f1d4" + +extend@~3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" + +extglob@^0.3.1: + version "0.3.2" + resolved "https://registry.yarnpkg.com/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1" + dependencies: + is-extglob "^1.0.0" + +extsprintf@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550" + +fast-deep-equal@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz#c053477817c86b51daa853c81e059b733d023614" + +fast-json-stable-stringify@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" + +fast-levenshtein@~2.0.4: + version "2.0.5" + resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.5.tgz#bd33145744519ab1c36c3ee9f31f08e9079b67f2" + +fb-watchman@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.0.tgz#54e9abf7dfa2f26cd9b1636c588c1afc05de5d58" + dependencies: + bser "^2.0.0" + +filename-regex@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.0.tgz#996e3e80479b98b9897f15a8a58b3d084e926775" + +fileset@^2.0.2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/fileset/-/fileset-2.0.3.tgz#8e7548a96d3cc2327ee5e674168723a333bba2a0" + dependencies: + glob "^7.0.3" + minimatch "^3.0.3" + +fill-range@^2.1.0: + version "2.2.3" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-2.2.3.tgz#50b77dfd7e469bc7492470963699fe7a8485a723" + dependencies: + is-number "^2.1.0" + isobject "^2.0.0" + randomatic "^1.1.3" + repeat-element "^1.1.2" + repeat-string "^1.5.2" + +find-index@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/find-index/-/find-index-0.1.1.tgz#675d358b2ca3892d795a1ab47232f8b6e2e0dde4" + +find-up@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" + dependencies: + path-exists "^2.0.0" + pinkie-promise "^2.0.0" + +find-up@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7" + dependencies: + locate-path "^2.0.0" + +for-in@^0.1.5: + version "0.1.6" + resolved "https://registry.yarnpkg.com/for-in/-/for-in-0.1.6.tgz#c9f96e89bfad18a545af5ec3ed352a1d9e5b4dc8" + +for-own@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/for-own/-/for-own-0.1.4.tgz#0149b41a39088c7515f51ebe1c1386d45f935072" + dependencies: + for-in "^0.1.5" + +foreach@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99" + +forever-agent@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" + +form-data@~2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.2.tgz#89c3534008b97eada4cbb157d58f6f5df025eae4" + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.5" + mime-types "^2.1.12" + +form-data@~2.3.1: + version "2.3.2" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.2.tgz#4970498be604c20c005d4f5c23aecd21d6b49099" + dependencies: + asynckit "^0.4.0" + combined-stream "1.0.6" + mime-types "^2.1.12" + +fs-extra@4.0.3: + version "4.0.3" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.3.tgz#0d852122e5bc5beb453fb028e9c0c9bf36340c94" + dependencies: + graceful-fs "^4.1.2" + jsonfile "^4.0.0" + universalify "^0.1.0" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + +fsevents@^1.0.0: + version "1.1.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.1.3.tgz#11f82318f5fe7bb2cd22965a108e9306208216d8" + dependencies: + nan "^2.3.0" + node-pre-gyp "^0.6.39" + +fsevents@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.1.2.tgz#3282b713fb3ad80ede0e9fcf4611b5aa6fc033f4" + dependencies: + nan "^2.3.0" + node-pre-gyp "^0.6.36" + +fstream-ignore@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/fstream-ignore/-/fstream-ignore-1.0.5.tgz#9c31dae34767018fe1d249b24dada67d092da105" + dependencies: + fstream "^1.0.0" + inherits "2" + minimatch "^3.0.0" + +fstream@^1.0.0, fstream@^1.0.10, fstream@^1.0.2: + version "1.0.11" + resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.11.tgz#5c1fb1f117477114f0632a0eb4b71b3cb0fd3171" + dependencies: + graceful-fs "^4.1.2" + inherits "~2.0.0" + mkdirp ">=0.5 0" + rimraf "2" + +function-bind@^1.0.2, function-bind@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" + +gauge@~2.7.3: + version "2.7.4" + resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" + dependencies: + aproba "^1.0.3" + console-control-strings "^1.0.0" + has-unicode "^2.0.0" + object-assign "^4.1.0" + signal-exit "^3.0.0" + string-width "^1.0.1" + strip-ansi "^3.0.1" + wide-align "^1.1.0" + +generate-function@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.0.0.tgz#6858fe7c0969b7d4e9093337647ac79f60dfbe74" + +generate-object-property@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/generate-object-property/-/generate-object-property-1.2.0.tgz#9c0e1c40308ce804f4783618b937fa88f99d50d0" + dependencies: + is-property "^1.0.0" + +get-caller-file@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.2.tgz#f702e63127e7e231c160a80c1554acb70d5047e5" + +get-stream@^2.2.0: + version "2.3.1" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-2.3.1.tgz#5f38f93f346009666ee0150a054167f91bdd95de" + dependencies: + object-assign "^4.0.1" + pinkie-promise "^2.0.0" + +get-stream@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" + +getpass@^0.1.1: + version "0.1.6" + resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.6.tgz#283ffd9fc1256840875311c1b60e8c40187110e6" + dependencies: + assert-plus "^1.0.0" + +glob-base@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4" + dependencies: + glob-parent "^2.0.0" + is-glob "^2.0.0" + +glob-parent@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-2.0.0.tgz#81383d72db054fcccf5336daa902f182f6edbb28" + dependencies: + is-glob "^2.0.0" + +glob2base@^0.0.12: + version "0.0.12" + resolved "https://registry.yarnpkg.com/glob2base/-/glob2base-0.0.12.tgz#9d419b3e28f12e83a362164a277055922c9c0d56" + dependencies: + find-index "^0.1.1" + +glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2: + version "7.1.2" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +globals@^9.0.0: + version "9.14.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-9.14.0.tgz#8859936af0038741263053b39d0e76ca241e4034" + +graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6: + version "4.1.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" + +"graceful-readlink@>= 1.0.0": + version "1.0.1" + resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" + +growly@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" + +handlebars@^4.0.3: + version "4.0.10" + resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.10.tgz#3d30c718b09a3d96f23ea4cc1f403c4d3ba9ff4f" + dependencies: + async "^1.4.0" + optimist "^0.6.1" + source-map "^0.4.4" + optionalDependencies: + uglify-js "^2.6" + +har-schema@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-1.0.5.tgz#d263135f43307c02c602afc8fe95970c0151369e" + +har-schema@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" + +har-validator@~2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-2.0.6.tgz#cdcbc08188265ad119b6a5a7c8ab70eecfb5d27d" + dependencies: + chalk "^1.1.1" + commander "^2.9.0" + is-my-json-valid "^2.12.4" + pinkie-promise "^2.0.0" + +har-validator@~4.2.1: + version "4.2.1" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-4.2.1.tgz#33481d0f1bbff600dd203d75812a6a5fba002e2a" + dependencies: + ajv "^4.9.1" + har-schema "^1.0.5" + +har-validator@~5.0.3: + version "5.0.3" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.0.3.tgz#ba402c266194f15956ef15e0fcf242993f6a7dfd" + dependencies: + ajv "^5.1.0" + har-schema "^2.0.0" + +has-ansi@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" + dependencies: + ansi-regex "^2.0.0" + +has-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" + +has-flag@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-2.0.0.tgz#e8207af1cc7b30d446cc70b734b5e8be18f88d51" + +has-flag@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + +has-unicode@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" + +has@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28" + dependencies: + function-bind "^1.0.2" + +hawk@3.1.3, hawk@~3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4" + dependencies: + boom "2.x.x" + cryptiles "2.x.x" + hoek "2.x.x" + sntp "1.x.x" + +hawk@~6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/hawk/-/hawk-6.0.2.tgz#af4d914eb065f9b5ce4d9d11c1cb2126eecc3038" + dependencies: + boom "4.x.x" + cryptiles "3.x.x" + hoek "4.x.x" + sntp "2.x.x" + +hoek@2.x.x: + version "2.16.3" + resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed" + +hoek@4.x.x: + version "4.2.1" + resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.1.tgz#9634502aa12c445dd5a7c5734b572bb8738aacbb" + +home-or-tmp@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" + dependencies: + os-homedir "^1.0.0" + os-tmpdir "^1.0.1" + +hosted-git-info@^2.1.4: + version "2.1.5" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.1.5.tgz#0ba81d90da2e25ab34a332e6ec77936e1598118b" + +html-encoding-sniffer@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz#e70d84b94da53aa375e11fe3a351be6642ca46f8" + dependencies: + whatwg-encoding "^1.0.1" + +http-signature@~1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.1.1.tgz#df72e267066cd0ac67fb76adf8e134a8fbcf91bf" + dependencies: + assert-plus "^0.2.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + +http-signature@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" + dependencies: + assert-plus "^1.0.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + +husky@0.14.3: + version "0.14.3" + resolved "https://registry.yarnpkg.com/husky/-/husky-0.14.3.tgz#c69ed74e2d2779769a17ba8399b54ce0b63c12c3" + dependencies: + is-ci "^1.0.10" + normalize-path "^1.0.0" + strip-indent "^2.0.0" + +iconv-lite@0.4.13: + version "0.4.13" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.13.tgz#1f88aba4ab0b1508e8312acc39345f36e992e2f2" + +iconv-lite@0.4.19: + version "0.4.19" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" + +ignore@^3.3.7: + version "3.3.7" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.7.tgz#612289bfb3c220e186a58118618d5be8c1bab021" + +import-local@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/import-local/-/import-local-1.0.0.tgz#5e4ffdc03f4fe6c009c6729beb29631c2f8227bc" + dependencies: + pkg-dir "^2.0.0" + resolve-cwd "^2.0.0" + +imurmurhash@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2, inherits@^2.0.1, inherits@~2.0.0, inherits@~2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + +ini@~1.3.0: + version "1.3.4" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e" + +invariant@^2.2.0: + version "2.2.2" + resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360" + dependencies: + loose-envify "^1.0.0" + +invert-kv@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" + +is-arrayish@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" + +is-binary-path@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-1.0.1.tgz#75f16642b480f187a711c814161fd3a4a7655898" + dependencies: + binary-extensions "^1.0.0" + +is-buffer@^1.0.2: + version "1.1.4" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.4.tgz#cfc86ccd5dc5a52fa80489111c6920c457e2d98b" + +is-builtin-module@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-builtin-module/-/is-builtin-module-1.0.0.tgz#540572d34f7ac3119f8f76c30cbc1b1e037affbe" + dependencies: + builtin-modules "^1.0.0" + +is-callable@^1.1.1, is-callable@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2" + +is-ci@^1.0.10: + version "1.0.10" + resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-1.0.10.tgz#f739336b2632365061a9d48270cd56ae3369318e" + dependencies: + ci-info "^1.0.0" + +is-date-object@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" + +is-dotfile@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.2.tgz#2c132383f39199f8edc268ca01b9b007d205cc4d" + +is-equal-shallow@^0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz#2238098fc221de0bcfa5d9eac4c45d638aa1c534" + dependencies: + is-primitive "^2.0.0" + +is-extendable@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" + +is-extglob@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0" + +is-finite@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa" + dependencies: + number-is-nan "^1.0.0" + +is-fullwidth-code-point@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" + dependencies: + number-is-nan "^1.0.0" + +is-fullwidth-code-point@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" + +is-generator-fn@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-generator-fn/-/is-generator-fn-1.0.0.tgz#969d49e1bb3329f6bb7f09089be26578b2ddd46a" + +is-glob@^2.0.0, is-glob@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863" + dependencies: + is-extglob "^1.0.0" + +is-my-json-valid@^2.12.4: + version "2.15.0" + resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.15.0.tgz#936edda3ca3c211fd98f3b2d3e08da43f7b2915b" + dependencies: + generate-function "^2.0.0" + generate-object-property "^1.1.0" + jsonpointer "^4.0.0" + xtend "^4.0.0" + +is-number@^2.0.2, is-number@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" + dependencies: + kind-of "^3.0.2" + +is-posix-bracket@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4" + +is-primitive@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" + +is-property@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" + +is-regex@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491" + dependencies: + has "^1.0.1" + +is-stream@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" + +is-symbol@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572" + +is-typedarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" + +is-utf8@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" + +isarray@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" + +isarray@1.0.0, isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + +isobject@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" + dependencies: + isarray "1.0.0" + +isstream@~0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" + +istanbul-api@^1.1.14: + version "1.2.2" + resolved "https://registry.yarnpkg.com/istanbul-api/-/istanbul-api-1.2.2.tgz#e17cd519dd5ec4141197f246fdf380b75487f3b1" + dependencies: + async "^2.1.4" + fileset "^2.0.2" + istanbul-lib-coverage "^1.1.2" + istanbul-lib-hook "^1.1.0" + istanbul-lib-instrument "^1.9.2" + istanbul-lib-report "^1.1.3" + istanbul-lib-source-maps "^1.2.3" + istanbul-reports "^1.1.4" + js-yaml "^3.7.0" + mkdirp "^0.5.1" + once "^1.4.0" + +istanbul-lib-coverage@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.1.1.tgz#73bfb998885299415c93d38a3e9adf784a77a9da" + +istanbul-lib-coverage@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.1.2.tgz#4113c8ff6b7a40a1ef7350b01016331f63afde14" + +istanbul-lib-hook@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/istanbul-lib-hook/-/istanbul-lib-hook-1.1.0.tgz#8538d970372cb3716d53e55523dd54b557a8d89b" + dependencies: + append-transform "^0.4.0" + +istanbul-lib-instrument@^1.7.2: + version "1.7.3" + resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.7.3.tgz#925b239163eabdd68cc4048f52c2fa4f899ecfa7" + dependencies: + babel-generator "^6.18.0" + babel-template "^6.16.0" + babel-traverse "^6.18.0" + babel-types "^6.18.0" + babylon "^6.17.4" + istanbul-lib-coverage "^1.1.1" + semver "^5.3.0" + +istanbul-lib-instrument@^1.7.5, istanbul-lib-instrument@^1.8.0, istanbul-lib-instrument@^1.9.2: + version "1.9.2" + resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.9.2.tgz#84905bf47f7e0b401d6b840da7bad67086b4aab6" + dependencies: + babel-generator "^6.18.0" + babel-template "^6.16.0" + babel-traverse "^6.18.0" + babel-types "^6.18.0" + babylon "^6.18.0" + istanbul-lib-coverage "^1.1.2" + semver "^5.3.0" + +istanbul-lib-report@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-1.1.3.tgz#2df12188c0fa77990c0d2176d2d0ba3394188259" + dependencies: + istanbul-lib-coverage "^1.1.2" + mkdirp "^0.5.1" + path-parse "^1.0.5" + supports-color "^3.1.2" + +istanbul-lib-source-maps@^1.2.1, istanbul-lib-source-maps@^1.2.3: + version "1.2.3" + resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-1.2.3.tgz#20fb54b14e14b3fb6edb6aca3571fd2143db44e6" + dependencies: + debug "^3.1.0" + istanbul-lib-coverage "^1.1.2" + mkdirp "^0.5.1" + rimraf "^2.6.1" + source-map "^0.5.3" + +istanbul-reports@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-1.1.4.tgz#5ccba5e22b7b5a5d91d5e0a830f89be334bf97bd" + dependencies: + handlebars "^4.0.3" + +jest-changed-files@^22.2.0: + version "22.2.0" + resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-22.2.0.tgz#517610c4a8ca0925bdc88b0ca53bd678aa8d019e" + dependencies: + throat "^4.0.0" + +jest-cli@^22.4.2: + version "22.4.2" + resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-22.4.2.tgz#e6546dc651e13d164481aa3e76e53ac4f4edab06" + dependencies: + ansi-escapes "^3.0.0" + chalk "^2.0.1" + exit "^0.1.2" + glob "^7.1.2" + graceful-fs "^4.1.11" + import-local "^1.0.0" + is-ci "^1.0.10" + istanbul-api "^1.1.14" + istanbul-lib-coverage "^1.1.1" + istanbul-lib-instrument "^1.8.0" + istanbul-lib-source-maps "^1.2.1" + jest-changed-files "^22.2.0" + jest-config "^22.4.2" + jest-environment-jsdom "^22.4.1" + jest-get-type "^22.1.0" + jest-haste-map "^22.4.2" + jest-message-util "^22.4.0" + jest-regex-util "^22.1.0" + jest-resolve-dependencies "^22.1.0" + jest-runner "^22.4.2" + jest-runtime "^22.4.2" + jest-snapshot "^22.4.0" + jest-util "^22.4.1" + jest-validate "^22.4.2" + jest-worker "^22.2.2" + micromatch "^2.3.11" + node-notifier "^5.2.1" + realpath-native "^1.0.0" + rimraf "^2.5.4" + slash "^1.0.0" + string-length "^2.0.0" + strip-ansi "^4.0.0" + which "^1.2.12" + yargs "^10.0.3" + +jest-config@^22.4.0, jest-config@^22.4.2: + version "22.4.2" + resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-22.4.2.tgz#580ba5819bf81a5e48f4fd470e8b81834f45c855" + dependencies: + chalk "^2.0.1" + glob "^7.1.1" + jest-environment-jsdom "^22.4.1" + jest-environment-node "^22.4.1" + jest-get-type "^22.1.0" + jest-jasmine2 "^22.4.2" + jest-regex-util "^22.1.0" + jest-resolve "^22.4.2" + jest-util "^22.4.1" + jest-validate "^22.4.2" + pretty-format "^22.4.0" + +jest-diff@^22.4.0: + version "22.4.0" + resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-22.4.0.tgz#384c2b78519ca44ca126382df53f134289232525" + dependencies: + chalk "^2.0.1" + diff "^3.2.0" + jest-get-type "^22.1.0" + pretty-format "^22.4.0" + +jest-docblock@^22.4.0: + version "22.4.0" + resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-22.4.0.tgz#dbf1877e2550070cfc4d9b07a55775a0483159b8" + dependencies: + detect-newline "^2.1.0" + +jest-environment-jsdom@^22.4.1: + version "22.4.1" + resolved "https://registry.yarnpkg.com/jest-environment-jsdom/-/jest-environment-jsdom-22.4.1.tgz#754f408872441740100d3917e5ec40c74de6447f" + dependencies: + jest-mock "^22.2.0" + jest-util "^22.4.1" + jsdom "^11.5.1" + +jest-environment-node@^22.4.1: + version "22.4.1" + resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-22.4.1.tgz#418850eb654596b8d6e36c2021cbedbc23df8e16" + dependencies: + jest-mock "^22.2.0" + jest-util "^22.4.1" + +jest-get-type@^22.1.0: + version "22.1.0" + resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-22.1.0.tgz#4e90af298ed6181edc85d2da500dbd2753e0d5a9" + +jest-haste-map@^22.4.2: + version "22.4.2" + resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-22.4.2.tgz#a90178e66146d4378bb076345a949071f3b015b4" + dependencies: + fb-watchman "^2.0.0" + graceful-fs "^4.1.11" + jest-docblock "^22.4.0" + jest-serializer "^22.4.0" + jest-worker "^22.2.2" + micromatch "^2.3.11" + sane "^2.0.0" + +jest-jasmine2@^22.4.2: + version "22.4.2" + resolved "https://registry.yarnpkg.com/jest-jasmine2/-/jest-jasmine2-22.4.2.tgz#dfd3d259579ed6f52510d8f1ab692808f0d40691" + dependencies: + chalk "^2.0.1" + co "^4.6.0" + expect "^22.4.0" + graceful-fs "^4.1.11" + is-generator-fn "^1.0.0" + jest-diff "^22.4.0" + jest-matcher-utils "^22.4.0" + jest-message-util "^22.4.0" + jest-snapshot "^22.4.0" + jest-util "^22.4.1" + source-map-support "^0.5.0" + +jest-leak-detector@^22.4.0: + version "22.4.0" + resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-22.4.0.tgz#64da77f05b001c96d2062226e079f89989c4aa2f" + dependencies: + pretty-format "^22.4.0" + +jest-matcher-utils@^22.4.0: + version "22.4.0" + resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-22.4.0.tgz#d55f5faf2270462736bdf7c7485ee931c9d4b6a1" + dependencies: + chalk "^2.0.1" + jest-get-type "^22.1.0" + pretty-format "^22.4.0" + +jest-message-util@^22.4.0: + version "22.4.0" + resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-22.4.0.tgz#e3d861df16d2fee60cb2bc8feac2188a42579642" + dependencies: + "@babel/code-frame" "^7.0.0-beta.35" + chalk "^2.0.1" + micromatch "^2.3.11" + slash "^1.0.0" + stack-utils "^1.0.1" + +jest-mock@^22.2.0: + version "22.2.0" + resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-22.2.0.tgz#444b3f9488a7473adae09bc8a77294afded397a7" + +jest-regex-util@^22.1.0: + version "22.1.0" + resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-22.1.0.tgz#5daf2fe270074b6da63e5d85f1c9acc866768f53" + +jest-resolve-dependencies@^22.1.0: + version "22.1.0" + resolved "https://registry.yarnpkg.com/jest-resolve-dependencies/-/jest-resolve-dependencies-22.1.0.tgz#340e4139fb13315cd43abc054e6c06136be51e31" + dependencies: + jest-regex-util "^22.1.0" + +jest-resolve@^22.4.2: + version "22.4.2" + resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-22.4.2.tgz#25d88aa4147462c9c1c6a1ba16250d3794c24d00" + dependencies: + browser-resolve "^1.11.2" + chalk "^2.0.1" + +jest-runner@^22.4.2: + version "22.4.2" + resolved "https://registry.yarnpkg.com/jest-runner/-/jest-runner-22.4.2.tgz#19390ea9d99f768973e16f95a1efa351c0017e87" + dependencies: + exit "^0.1.2" + jest-config "^22.4.2" + jest-docblock "^22.4.0" + jest-haste-map "^22.4.2" + jest-jasmine2 "^22.4.2" + jest-leak-detector "^22.4.0" + jest-message-util "^22.4.0" + jest-runtime "^22.4.2" + jest-util "^22.4.1" + jest-worker "^22.2.2" + throat "^4.0.0" + +jest-runtime@^22.4.2: + version "22.4.2" + resolved "https://registry.yarnpkg.com/jest-runtime/-/jest-runtime-22.4.2.tgz#0de0444f65ce15ee4f2e0055133fc7c17b9168f3" + dependencies: + babel-core "^6.0.0" + babel-jest "^22.4.1" + babel-plugin-istanbul "^4.1.5" + chalk "^2.0.1" + convert-source-map "^1.4.0" + exit "^0.1.2" + graceful-fs "^4.1.11" + jest-config "^22.4.2" + jest-haste-map "^22.4.2" + jest-regex-util "^22.1.0" + jest-resolve "^22.4.2" + jest-util "^22.4.1" + jest-validate "^22.4.2" + json-stable-stringify "^1.0.1" + micromatch "^2.3.11" + realpath-native "^1.0.0" + slash "^1.0.0" + strip-bom "3.0.0" + write-file-atomic "^2.1.0" + yargs "^10.0.3" + +jest-serializer@^22.4.0: + version "22.4.0" + resolved "https://registry.yarnpkg.com/jest-serializer/-/jest-serializer-22.4.0.tgz#b5d145b98c4b0d2c20ab686609adbb81fe23b566" + +jest-snapshot@^22.4.0: + version "22.4.0" + resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-22.4.0.tgz#03d3ce63f8fa7352388afc6a3c8b5ccc3a180ed7" + dependencies: + chalk "^2.0.1" + jest-diff "^22.4.0" + jest-matcher-utils "^22.4.0" + mkdirp "^0.5.1" + natural-compare "^1.4.0" + pretty-format "^22.4.0" + +jest-util@^22.4.1: + version "22.4.1" + resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-22.4.1.tgz#dd17c3bdb067f8e90591563ec0c42bf847dc249f" + dependencies: + callsites "^2.0.0" + chalk "^2.0.1" + graceful-fs "^4.1.11" + is-ci "^1.0.10" + jest-message-util "^22.4.0" + mkdirp "^0.5.1" + source-map "^0.6.0" + +jest-validate@^22.4.2: + version "22.4.2" + resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-22.4.2.tgz#e789a4e056173bf97fe797a2df2d52105c57d4f4" + dependencies: + chalk "^2.0.1" + jest-config "^22.4.2" + jest-get-type "^22.1.0" + leven "^2.1.0" + pretty-format "^22.4.0" + +jest-worker@^22.2.2: + version "22.2.2" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-22.2.2.tgz#c1f5dc39976884b81f68ec50cb8532b2cbab3390" + dependencies: + merge-stream "^1.0.1" + +jest@22.4.2: + version "22.4.2" + resolved "https://registry.yarnpkg.com/jest/-/jest-22.4.2.tgz#34012834a49bf1bdd3bc783850ab44e4499afc20" + dependencies: + import-local "^1.0.0" + jest-cli "^22.4.2" + +jodid25519@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/jodid25519/-/jodid25519-1.0.2.tgz#06d4912255093419477d425633606e0e90782967" + dependencies: + jsbn "~0.1.0" + +js-tokens@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-2.0.0.tgz#79903f5563ee778cc1162e6dcf1a0027c97f9cb5" + +js-tokens@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.0.tgz#a2f2a969caae142fb3cd56228358c89366957bd1" + +js-yaml@^3.6.1: + version "3.10.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.10.0.tgz#2e78441646bd4682e963f22b6e92823c309c62dc" + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + +js-yaml@^3.7.0: + version "3.9.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.9.0.tgz#4ffbbf25c2ac963b8299dc74da7e3740de1c18ce" + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + +jsbn@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.0.tgz#650987da0dd74f4ebf5a11377a2aa2d273e97dfd" + +jsdom@^11.5.1: + version "11.6.2" + resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-11.6.2.tgz#25d1ef332d48adf77fc5221fe2619967923f16bb" + dependencies: + abab "^1.0.4" + acorn "^5.3.0" + acorn-globals "^4.1.0" + array-equal "^1.0.0" + browser-process-hrtime "^0.1.2" + content-type-parser "^1.0.2" + cssom ">= 0.3.2 < 0.4.0" + cssstyle ">= 0.2.37 < 0.3.0" + domexception "^1.0.0" + escodegen "^1.9.0" + html-encoding-sniffer "^1.0.2" + left-pad "^1.2.0" + nwmatcher "^1.4.3" + parse5 "4.0.0" + pn "^1.1.0" + request "^2.83.0" + request-promise-native "^1.0.5" + sax "^1.2.4" + symbol-tree "^3.2.2" + tough-cookie "^2.3.3" + w3c-hr-time "^1.0.1" + webidl-conversions "^4.0.2" + whatwg-encoding "^1.0.3" + whatwg-url "^6.4.0" + ws "^4.0.0" + xml-name-validator "^3.0.0" + +jsesc@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" + +json-schema-traverse@^0.3.0: + version "0.3.1" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340" + +json-schema@0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" + +json-stable-stringify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" + dependencies: + jsonify "~0.0.0" + +json-stringify-safe@~5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" + +json5@^0.5.0: + version "0.5.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" + +jsonfile@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" + optionalDependencies: + graceful-fs "^4.1.6" + +jsonify@~0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" + +jsonpointer@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.0.tgz#6661e161d2fc445f19f98430231343722e1fcbd5" + +jsonwebtoken@^8.0.0: + version "8.2.0" + resolved "https://registry.yarnpkg.com/jsonwebtoken/-/jsonwebtoken-8.2.0.tgz#690ec3a9e7e95e2884347ce3e9eb9d389aa598b3" + dependencies: + jws "^3.1.4" + lodash.includes "^4.3.0" + lodash.isboolean "^3.0.3" + lodash.isinteger "^4.0.4" + lodash.isnumber "^3.0.3" + lodash.isplainobject "^4.0.6" + lodash.isstring "^4.0.1" + lodash.once "^4.0.0" + ms "^2.1.1" + xtend "^4.0.1" + +jsprim@^1.2.2: + version "1.3.1" + resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.3.1.tgz#2a7256f70412a29ee3670aaca625994c4dcff252" + dependencies: + extsprintf "1.0.2" + json-schema "0.2.3" + verror "1.3.6" + +jwa@^1.1.4: + version "1.1.5" + resolved "https://registry.yarnpkg.com/jwa/-/jwa-1.1.5.tgz#a0552ce0220742cd52e153774a32905c30e756e5" + dependencies: + base64url "2.0.0" + buffer-equal-constant-time "1.0.1" + ecdsa-sig-formatter "1.0.9" + safe-buffer "^5.0.1" + +jws@^3.1.4: + version "3.1.4" + resolved "https://registry.yarnpkg.com/jws/-/jws-3.1.4.tgz#f9e8b9338e8a847277d6444b1464f61880e050a2" + dependencies: + base64url "^2.0.0" + jwa "^1.1.4" + safe-buffer "^5.0.1" + +jwt-decode@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/jwt-decode/-/jwt-decode-2.1.0.tgz#d3079cef1689d82d56bbb7aedcfea28b12f0e36a" + +kind-of@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.1.0.tgz#475d698a5e49ff5e53d14e3e732429dc8bf4cf47" + dependencies: + is-buffer "^1.0.2" + +lazy-cache@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e" + +lcid@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835" + dependencies: + invert-kv "^1.0.0" + +lcov-parse@^0.0.10: + version "0.0.10" + resolved "https://registry.yarnpkg.com/lcov-parse/-/lcov-parse-0.0.10.tgz#1b0b8ff9ac9c7889250582b70b71315d9da6d9a3" + +left-pad@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.2.0.tgz#d30a73c6b8201d8f7d8e7956ba9616087a68e0ee" + +leven@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/leven/-/leven-2.1.0.tgz#c2e7a9f772094dee9d34202ae8acce4687875580" + +levn@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" + dependencies: + prelude-ls "~1.1.2" + type-check "~0.3.2" + +load-json-file@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" + dependencies: + graceful-fs "^4.1.2" + parse-json "^2.2.0" + pify "^2.0.0" + pinkie-promise "^2.0.0" + strip-bom "^2.0.0" + +locate-path@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" + dependencies: + p-locate "^2.0.0" + path-exists "^3.0.0" + +lodash.includes@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/lodash.includes/-/lodash.includes-4.3.0.tgz#60bb98a87cb923c68ca1e51325483314849f553f" + +lodash.isboolean@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz#6c2e171db2a257cd96802fd43b01b20d5f5870f6" + +lodash.isinteger@^4.0.4: + version "4.0.4" + resolved "https://registry.yarnpkg.com/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz#619c0af3d03f8b04c31f5882840b77b11cd68343" + +lodash.isnumber@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz#3ce76810c5928d03352301ac287317f11c0b1ffc" + +lodash.isplainobject@^4.0.6: + version "4.0.6" + resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb" + +lodash.isstring@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/lodash.isstring/-/lodash.isstring-4.0.1.tgz#d527dfb5456eca7cc9bb95d5daeaf88ba54a5451" + +lodash.once@^4.0.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/lodash.once/-/lodash.once-4.1.1.tgz#0dd3971213c7c56df880977d504c88fb471a97ac" + +lodash.sortby@^4.7.0: + version "4.7.0" + resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" + +lodash@^4.13.1: + version "4.17.5" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.5.tgz#99a92d65c0272debe8c96b6057bc8fbfa3bed511" + +lodash@^4.14.0, lodash@^4.16.4, lodash@^4.17.4, lodash@^4.2.0: + version "4.17.4" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" + +log-driver@^1.2.5: + version "1.2.5" + resolved "https://registry.yarnpkg.com/log-driver/-/log-driver-1.2.5.tgz#7ae4ec257302fd790d557cb10c97100d857b0056" + +longest@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" + +loose-envify@^1.0.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.0.tgz#6b26248c42f6d4fa4b0d8542f78edfcde35642a8" + dependencies: + js-tokens "^2.0.0" + +lru-cache@^4.0.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.1.tgz#622e32e82488b49279114a4f9ecf45e7cd6bba55" + dependencies: + pseudomap "^1.0.2" + yallist "^2.1.2" + +makeerror@1.0.x: + version "1.0.11" + resolved "https://registry.yarnpkg.com/makeerror/-/makeerror-1.0.11.tgz#e01a5c9109f2af79660e4e8b9587790184f5a96c" + dependencies: + tmpl "1.0.x" + +mem@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/mem/-/mem-1.1.0.tgz#5edd52b485ca1d900fe64895505399a0dfa45f76" + dependencies: + mimic-fn "^1.0.0" + +merge-stream@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-1.0.1.tgz#4041202d508a342ba00174008df0c251b8c135e1" + dependencies: + readable-stream "^2.0.1" + +merge@^1.1.3: + version "1.2.0" + resolved "https://registry.yarnpkg.com/merge/-/merge-1.2.0.tgz#7531e39d4949c281a66b8c5a6e0265e8b05894da" + +micromatch@^2.1.5, micromatch@^2.3.11: + version "2.3.11" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565" + dependencies: + arr-diff "^2.0.0" + array-unique "^0.2.1" + braces "^1.8.2" + expand-brackets "^0.1.4" + extglob "^0.3.1" + filename-regex "^2.0.0" + is-extglob "^1.0.0" + is-glob "^2.0.1" + kind-of "^3.0.2" + normalize-path "^2.0.1" + object.omit "^2.0.0" + parse-glob "^3.0.4" + regex-cache "^0.4.2" + +mime-db@~1.25.0: + version "1.25.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.25.0.tgz#c18dbd7c73a5dbf6f44a024dc0d165a1e7b1c392" + +mime-db@~1.33.0: + version "1.33.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.33.0.tgz#a3492050a5cb9b63450541e39d9788d2272783db" + +mime-types@^2.1.12, mime-types@~2.1.7: + version "2.1.13" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.13.tgz#e07aaa9c6c6b9a7ca3012c69003ad25a39e92a88" + dependencies: + mime-db "~1.25.0" + +mime-types@~2.1.17: + version "2.1.18" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.18.tgz#6f323f60a83d11146f831ff11fd66e2fe5503bb8" + dependencies: + mime-db "~1.33.0" + +mimic-fn@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.1.0.tgz#e667783d92e89dbd342818b5230b9d62a672ad18" + +minimatch@^3.0.0, minimatch@^3.0.3, minimatch@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" + dependencies: + brace-expansion "^1.1.7" + +minimatch@^3.0.2: + version "3.0.3" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774" + dependencies: + brace-expansion "^1.0.0" + +minimist@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" + +minimist@^1.1.0, minimist@^1.1.1, minimist@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + +minimist@~0.0.1: + version "0.0.10" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" + +"mkdirp@>=0.5 0", mkdirp@^0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" + dependencies: + minimist "0.0.8" + +mongodb-core@3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/mongodb-core/-/mongodb-core-3.0.3.tgz#496d7dd0052dc3a2e213edf9ddcddc78b47a712c" + dependencies: + bson "~1.0.4" + require_optional "^1.0.1" + +mongodb@^3.0.0: + version "3.0.3" + resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-3.0.3.tgz#83b33e01f26b4a2e1f8a2b3427cabbaee31df017" + dependencies: + mongodb-core "3.0.3" + +mri@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/mri/-/mri-1.1.0.tgz#5c0a3f29c8ccffbbb1ec941dcec09d71fa32f36a" + +ms@0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + +ms@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" + +nan@^2.3.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.7.0.tgz#d95bf721ec877e08db276ed3fc6eb78f9083ad46" + +natural-compare@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" + +node-int64@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" + +node-notifier@^5.2.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/node-notifier/-/node-notifier-5.2.1.tgz#fa313dd08f5517db0e2502e5758d664ac69f9dea" + dependencies: + growly "^1.3.0" + semver "^5.4.1" + shellwords "^0.1.1" + which "^1.3.0" + +node-pre-gyp@^0.6.36, node-pre-gyp@^0.6.39: + version "0.6.39" + resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.39.tgz#c00e96860b23c0e1420ac7befc5044e1d78d8649" + dependencies: + detect-libc "^1.0.2" + hawk "3.1.3" + mkdirp "^0.5.1" + nopt "^4.0.1" + npmlog "^4.0.2" + rc "^1.1.7" + request "2.81.0" + rimraf "^2.6.1" + semver "^5.3.0" + tar "^2.2.1" + tar-pack "^3.4.0" + +nopt@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.1.tgz#d0d4685afd5415193c8c7505602d0d17cd64474d" + dependencies: + abbrev "1" + osenv "^0.1.4" + +normalize-package-data@^2.3.2: + version "2.3.5" + resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.3.5.tgz#8d924f142960e1777e7ffe170543631cc7cb02df" + dependencies: + hosted-git-info "^2.1.4" + is-builtin-module "^1.0.0" + semver "2 || 3 || 4 || 5" + validate-npm-package-license "^3.0.1" + +normalize-path@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-1.0.0.tgz#32d0e472f91ff345701c15a8311018d3b0a90379" + +normalize-path@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.0.1.tgz#47886ac1662760d4261b7d979d241709d3ce3f7a" + +npm-run-path@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" + dependencies: + path-key "^2.0.0" + +npmlog@^4.0.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" + dependencies: + are-we-there-yet "~1.1.2" + console-control-strings "~1.1.0" + gauge "~2.7.3" + set-blocking "~2.0.0" + +number-is-nan@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" + +nwmatcher@^1.4.3: + version "1.4.3" + resolved "https://registry.yarnpkg.com/nwmatcher/-/nwmatcher-1.4.3.tgz#64348e3b3d80f035b40ac11563d278f8b72db89c" + +oauth-sign@~0.8.1, oauth-sign@~0.8.2: + version "0.8.2" + resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" + +object-assign@^4.0.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + +object-assign@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.0.tgz#7a3b3d0e98063d43f4c03f2e8ae6cd51a86883a0" + +object-keys@^1.0.8: + version "1.0.11" + resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d" + +object.getownpropertydescriptors@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz#8758c846f5b407adab0f236e0986f14b051caa16" + dependencies: + define-properties "^1.1.2" + es-abstract "^1.5.1" + +object.omit@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa" + dependencies: + for-own "^0.1.4" + is-extendable "^0.1.1" + +once@^1.3.0: + version "1.3.3" + resolved "https://registry.yarnpkg.com/once/-/once-1.3.3.tgz#b2e261557ce4c314ec8304f3fa82663e4297ca20" + dependencies: + wrappy "1" + +once@^1.3.3, once@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + dependencies: + wrappy "1" + +optimist@^0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686" + dependencies: + minimist "~0.0.1" + wordwrap "~0.0.2" + +optionator@^0.8.1: + version "0.8.2" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" + dependencies: + deep-is "~0.1.3" + fast-levenshtein "~2.0.4" + levn "~0.3.0" + prelude-ls "~1.1.2" + type-check "~0.3.2" + wordwrap "~1.0.0" + +os-homedir@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" + +os-locale@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-2.0.0.tgz#15918ded510522b81ee7ae5a309d54f639fc39a4" + dependencies: + execa "^0.5.0" + lcid "^1.0.0" + mem "^1.1.0" + +os-tmpdir@^1.0.0, os-tmpdir@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + +osenv@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.4.tgz#42fe6d5953df06c8064be6f176c3d05aaaa34644" + dependencies: + os-homedir "^1.0.0" + os-tmpdir "^1.0.0" + +p-finally@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" + +p-limit@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.1.0.tgz#b07ff2d9a5d88bec806035895a2bab66a27988bc" + +p-locate@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43" + dependencies: + p-limit "^1.1.0" + +parse-glob@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c" + dependencies: + glob-base "^0.3.0" + is-dotfile "^1.0.0" + is-extglob "^1.0.0" + is-glob "^2.0.0" + +parse-json@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9" + dependencies: + error-ex "^1.2.0" + +parse5@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/parse5/-/parse5-4.0.0.tgz#6d78656e3da8d78b4ec0b906f7c08ef1dfe3f608" + +path-exists@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" + dependencies: + pinkie-promise "^2.0.0" + +path-exists@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + +path-key@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" + +path-parse@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1" + +path-type@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" + dependencies: + graceful-fs "^4.1.2" + pify "^2.0.0" + pinkie-promise "^2.0.0" + +performance-now@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-0.2.0.tgz#33ef30c5c77d4ea21c5a53869d91b56d8f2555e5" + +performance-now@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" + +pify@^2.0.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" + +pinkie-promise@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" + dependencies: + pinkie "^2.0.0" + +pinkie@^2.0.0: + version "2.0.4" + resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" + +pkg-dir@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-2.0.0.tgz#f6d5d1109e19d63edf428e0bd57e12777615334b" + dependencies: + find-up "^2.1.0" + +pn@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/pn/-/pn-1.1.0.tgz#e2f4cef0e219f463c179ab37463e4e1ecdccbafb" + +prelude-ls@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" + +preserve@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" + +prettier@1.11.1: + version "1.11.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.11.1.tgz#61e43fc4cd44e68f2b0dfc2c38cd4bb0fccdcc75" + +pretty-format@^22.4.0: + version "22.4.0" + resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-22.4.0.tgz#237b1f7e1c50ed03bc65c03ccc29d7c8bb7beb94" + dependencies: + ansi-regex "^3.0.0" + ansi-styles "^3.2.0" + +pretty-quick@1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/pretty-quick/-/pretty-quick-1.4.1.tgz#9d41f778d2d4d940ec603d1293a0998e84c4722c" + dependencies: + chalk "^2.3.0" + execa "^0.8.0" + find-up "^2.1.0" + ignore "^3.3.7" + mri "^1.1.0" + +private@^0.1.6: + version "0.1.6" + resolved "https://registry.yarnpkg.com/private/-/private-0.1.6.tgz#55c6a976d0f9bafb9924851350fe47b9b5fbb7c1" + +process-nextick-args@~1.0.6: + version "1.0.7" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" + +process-nextick-args@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa" + +pseudomap@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" + +punycode@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" + +punycode@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.0.tgz#5f863edc89b96db09074bad7947bf09056ca4e7d" + +qs@~6.3.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.3.0.tgz#f403b264f23bc01228c74131b407f18d5ea5d442" + +qs@~6.4.0: + version "6.4.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233" + +qs@~6.5.1: + version "6.5.1" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" + +randomatic@^1.1.3: + version "1.1.6" + resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-1.1.6.tgz#110dcabff397e9dcff7c0789ccc0a49adf1ec5bb" + dependencies: + is-number "^2.0.2" + kind-of "^3.0.2" + +rc@^1.1.7: + version "1.2.2" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.2.tgz#d8ce9cb57e8d64d9c7badd9876c7c34cbe3c7077" + dependencies: + deep-extend "~0.4.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~2.0.1" + +read-pkg-up@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" + dependencies: + find-up "^1.0.0" + read-pkg "^1.0.0" + +read-pkg@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" + dependencies: + load-json-file "^1.0.0" + normalize-package-data "^2.3.2" + path-type "^1.0.0" + +readable-stream@^2.0.1: + version "2.3.5" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.5.tgz#b4f85003a938cbb6ecbce2a124fb1012bd1a838d" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~2.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.0.3" + util-deprecate "~1.0.1" + +readable-stream@^2.0.2: + version "2.3.4" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.4.tgz#c946c3f47fa7d8eabc0b6150f4a12f69a4574071" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~2.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.0.3" + util-deprecate "~1.0.1" + +readable-stream@^2.0.6, readable-stream@^2.1.4: + version "2.3.3" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.3.tgz#368f2512d79f9d46fdfc71349ae7878bbc1eb95c" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~1.0.6" + safe-buffer "~5.1.1" + string_decoder "~1.0.3" + util-deprecate "~1.0.1" + +readdirp@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-2.1.0.tgz#4ed0ad060df3073300c48440373f72d1cc642d78" + dependencies: + graceful-fs "^4.1.2" + minimatch "^3.0.2" + readable-stream "^2.0.2" + set-immediate-shim "^1.0.1" + +realpath-native@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/realpath-native/-/realpath-native-1.0.0.tgz#7885721a83b43bd5327609f0ddecb2482305fdf0" + dependencies: + util.promisify "^1.0.0" + +regenerator-runtime@^0.10.0: + version "0.10.1" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.1.tgz#257f41961ce44558b18f7814af48c17559f9faeb" + +regenerator-runtime@^0.11.0: + version "0.11.1" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" + +regex-cache@^0.4.2: + version "0.4.3" + resolved "https://registry.yarnpkg.com/regex-cache/-/regex-cache-0.4.3.tgz#9b1a6c35d4d0dfcef5711ae651e8e9d3d7114145" + dependencies: + is-equal-shallow "^0.1.3" + is-primitive "^2.0.0" + +repeat-element@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a" + +repeat-string@^1.5.2: + version "1.6.1" + resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" + +repeating@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" + dependencies: + is-finite "^1.0.0" + +request-promise-core@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/request-promise-core/-/request-promise-core-1.1.1.tgz#3eee00b2c5aa83239cfb04c5700da36f81cd08b6" + dependencies: + lodash "^4.13.1" + +request-promise-native@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/request-promise-native/-/request-promise-native-1.0.5.tgz#5281770f68e0c9719e5163fd3fab482215f4fda5" + dependencies: + request-promise-core "1.1.1" + stealthy-require "^1.1.0" + tough-cookie ">=2.3.3" + +request@2.81.0: + version "2.81.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0" + dependencies: + aws-sign2 "~0.6.0" + aws4 "^1.2.1" + caseless "~0.12.0" + combined-stream "~1.0.5" + extend "~3.0.0" + forever-agent "~0.6.1" + form-data "~2.1.1" + har-validator "~4.2.1" + hawk "~3.1.3" + http-signature "~1.1.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.7" + oauth-sign "~0.8.1" + performance-now "^0.2.0" + qs "~6.4.0" + safe-buffer "^5.0.1" + stringstream "~0.0.4" + tough-cookie "~2.3.0" + tunnel-agent "^0.6.0" + uuid "^3.0.0" + +request@^2.79.0: + version "2.79.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.79.0.tgz#4dfe5bf6be8b8cdc37fcf93e04b65577722710de" + dependencies: + aws-sign2 "~0.6.0" + aws4 "^1.2.1" + caseless "~0.11.0" + combined-stream "~1.0.5" + extend "~3.0.0" + forever-agent "~0.6.1" + form-data "~2.1.1" + har-validator "~2.0.6" + hawk "~3.1.3" + http-signature "~1.1.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.7" + oauth-sign "~0.8.1" + qs "~6.3.0" + stringstream "~0.0.4" + tough-cookie "~2.3.0" + tunnel-agent "~0.4.1" + uuid "^3.0.0" + +request@^2.83.0: + version "2.83.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.83.0.tgz#ca0b65da02ed62935887808e6f510381034e3356" + dependencies: + aws-sign2 "~0.7.0" + aws4 "^1.6.0" + caseless "~0.12.0" + combined-stream "~1.0.5" + extend "~3.0.1" + forever-agent "~0.6.1" + form-data "~2.3.1" + har-validator "~5.0.3" + hawk "~6.0.2" + http-signature "~1.2.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.17" + oauth-sign "~0.8.2" + performance-now "^2.1.0" + qs "~6.5.1" + safe-buffer "^5.1.1" + stringstream "~0.0.5" + tough-cookie "~2.3.3" + tunnel-agent "^0.6.0" + uuid "^3.1.0" + +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + +require-main-filename@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" + +require_optional@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/require_optional/-/require_optional-1.0.1.tgz#4cf35a4247f64ca3df8c2ef208cc494b1ca8fc2e" + dependencies: + resolve-from "^2.0.0" + semver "^5.1.0" + +resolve-cwd@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-2.0.0.tgz#00a9f7387556e27038eae232caa372a6a59b665a" + dependencies: + resolve-from "^3.0.0" + +resolve-from@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-2.0.0.tgz#9480ab20e94ffa1d9e80a804c7ea147611966b57" + +resolve-from@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-3.0.0.tgz#b22c7af7d9d6881bc8b6e653335eebcb0a188748" + +resolve@1.1.7: + version "1.1.7" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" + +resolve@^1.1.7: + version "1.5.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.5.0.tgz#1f09acce796c9a762579f31b2c1cc4c3cddf9f36" + dependencies: + path-parse "^1.0.5" + +resolve@^1.3.2: + version "1.3.3" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.3.3.tgz#655907c3469a8680dc2de3a275a8fdd69691f0e5" + dependencies: + path-parse "^1.0.5" + +right-align@^0.1.1: + version "0.1.3" + resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef" + dependencies: + align-text "^0.1.1" + +rimraf@2, rimraf@^2.5.1, rimraf@^2.5.4: + version "2.6.2" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" + dependencies: + glob "^7.0.5" + +rimraf@^2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d" + dependencies: + glob "^7.0.5" + +safe-buffer@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.0.1.tgz#d263ca54696cd8a306b5ca6551e92de57918fbe7" + +safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" + +sane@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/sane/-/sane-2.2.0.tgz#d6d2e2fcab00e3d283c93b912b7c3a20846f1d56" + dependencies: + anymatch "^1.3.0" + exec-sh "^0.2.0" + fb-watchman "^2.0.0" + minimatch "^3.0.2" + minimist "^1.1.1" + walker "~1.0.5" + watch "~0.18.0" + optionalDependencies: + fsevents "^1.1.1" + +sax@^1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" + +"semver@2 || 3 || 4 || 5", semver@^5.1.0, semver@^5.3.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" + +semver@^5.4.1: + version "5.5.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab" + +set-blocking@^2.0.0, set-blocking@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" + +set-immediate-shim@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz#4b2b1b27eb808a9f8dcc481a58e5e56f599f3f61" + +shebang-command@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" + dependencies: + shebang-regex "^1.0.0" + +shebang-regex@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" + +shell-quote@^1.6.1: + version "1.6.1" + resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.6.1.tgz#f4781949cce402697127430ea3b3c5476f481767" + dependencies: + array-filter "~0.0.0" + array-map "~0.0.0" + array-reduce "~0.0.0" + jsonify "~0.0.0" + +shellwords@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b" + +signal-exit@^3.0.0, signal-exit@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" + +slash@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" + +sntp@1.x.x: + version "1.0.9" + resolved "https://registry.yarnpkg.com/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198" + dependencies: + hoek "2.x.x" + +sntp@2.x.x: + version "2.1.0" + resolved "https://registry.yarnpkg.com/sntp/-/sntp-2.1.0.tgz#2c6cec14fedc2222739caf9b5c3d85d1cc5a2cc8" + dependencies: + hoek "4.x.x" + +source-map-support@^0.4.2: + version "0.4.6" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.6.tgz#32552aa64b458392a85eab3b0b5ee61527167aeb" + dependencies: + source-map "^0.5.3" + +source-map-support@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.0.tgz#2018a7ad2bdf8faf2691e5fddab26bed5a2bacab" + dependencies: + source-map "^0.6.0" + +source-map@^0.4.4: + version "0.4.4" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b" + dependencies: + amdefine ">=0.0.4" + +source-map@^0.5.0, source-map@^0.5.3, source-map@~0.5.1: + version "0.5.6" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" + +source-map@^0.6.0, source-map@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + +spdx-correct@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-1.0.2.tgz#4b3073d933ff51f3912f03ac5519498a4150db40" + dependencies: + spdx-license-ids "^1.0.2" + +spdx-expression-parse@~1.0.0: + version "1.0.4" + resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-1.0.4.tgz#9bdf2f20e1f40ed447fbe273266191fced51626c" + +spdx-license-ids@^1.0.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz#c9df7a3424594ade6bd11900d596696dc06bac57" + +sprintf-js@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + +sshpk@^1.7.0: + version "1.10.1" + resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.10.1.tgz#30e1a5d329244974a1af61511339d595af6638b0" + dependencies: + asn1 "~0.2.3" + assert-plus "^1.0.0" + dashdash "^1.12.0" + getpass "^0.1.1" + optionalDependencies: + bcrypt-pbkdf "^1.0.0" + ecc-jsbn "~0.1.1" + jodid25519 "^1.0.0" + jsbn "~0.1.0" + tweetnacl "~0.14.0" + +stack-utils@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-1.0.1.tgz#d4f33ab54e8e38778b0ca5cfd3b3afb12db68620" + +stealthy-require@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b" + +string-length@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/string-length/-/string-length-2.0.0.tgz#d40dbb686a3ace960c1cffca562bf2c45f8363ed" + dependencies: + astral-regex "^1.0.0" + strip-ansi "^4.0.0" + +string-width@^1.0.1, string-width@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" + dependencies: + code-point-at "^1.0.0" + is-fullwidth-code-point "^1.0.0" + strip-ansi "^3.0.0" + +string-width@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.0.tgz#030664561fc146c9423ec7d978fe2457437fe6d0" + dependencies: + is-fullwidth-code-point "^2.0.0" + strip-ansi "^4.0.0" + +string-width@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" + dependencies: + is-fullwidth-code-point "^2.0.0" + strip-ansi "^4.0.0" + +string_decoder@~1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab" + dependencies: + safe-buffer "~5.1.0" + +stringstream@~0.0.4, stringstream@~0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.5.tgz#4e484cd4de5a0bbbee18e46307710a8a81621878" + +strip-ansi@^3.0.0, strip-ansi@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" + dependencies: + ansi-regex "^2.0.0" + +strip-ansi@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" + dependencies: + ansi-regex "^3.0.0" + +strip-bom@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" + +strip-bom@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" + dependencies: + is-utf8 "^0.2.0" + +strip-eof@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" + +strip-indent@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-2.0.0.tgz#5ef8db295d01e6ed6cbf7aab96998d7822527b68" + +strip-json-comments@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + +subarg@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/subarg/-/subarg-1.0.0.tgz#f62cf17581e996b48fc965699f54c06ae268b8d2" + dependencies: + minimist "^1.1.0" + +supports-color@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" + +supports-color@^3.1.2: + version "3.2.3" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6" + dependencies: + has-flag "^1.0.0" + +supports-color@^4.0.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.5.0.tgz#be7a0de484dec5c5cddf8b3d59125044912f635b" + dependencies: + has-flag "^2.0.0" + +supports-color@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.2.0.tgz#b0d5333b1184dd3666cbe5aa0b45c5ac7ac17a4a" + dependencies: + has-flag "^3.0.0" + +symbol-tree@^3.2.2: + version "3.2.2" + resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.2.tgz#ae27db38f660a7ae2e1c3b7d1bc290819b8519e6" + +tar-pack@^3.4.0: + version "3.4.1" + resolved "https://registry.yarnpkg.com/tar-pack/-/tar-pack-3.4.1.tgz#e1dbc03a9b9d3ba07e896ad027317eb679a10a1f" + dependencies: + debug "^2.2.0" + fstream "^1.0.10" + fstream-ignore "^1.0.5" + once "^1.3.3" + readable-stream "^2.1.4" + rimraf "^2.5.1" + tar "^2.2.1" + uid-number "^0.0.6" + +tar@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/tar/-/tar-2.2.1.tgz#8e4d2a256c0e2185c6b18ad694aec968b83cb1d1" + dependencies: + block-stream "*" + fstream "^1.0.2" + inherits "2" + +test-exclude@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-4.1.1.tgz#4d84964b0966b0087ecc334a2ce002d3d9341e26" + dependencies: + arrify "^1.0.1" + micromatch "^2.3.11" + object-assign "^4.1.0" + read-pkg-up "^1.0.1" + require-main-filename "^1.0.1" + +throat@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/throat/-/throat-4.1.0.tgz#89037cbc92c56ab18926e6ba4cbb200e15672a6a" + +tmpl@1.0.x: + version "1.0.4" + resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.4.tgz#23640dd7b42d00433911140820e5cf440e521dd1" + +to-fast-properties@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.2.tgz#f3f5c0c3ba7299a7ef99427e44633257ade43320" + +tough-cookie@>=2.3.3, tough-cookie@^2.3.3, tough-cookie@~2.3.3: + version "2.3.4" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.4.tgz#ec60cee38ac675063ffc97a5c18970578ee83655" + dependencies: + punycode "^1.4.1" + +tough-cookie@~2.3.0: + version "2.3.2" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.2.tgz#f081f76e4c85720e6c37a5faced737150d84072a" + dependencies: + punycode "^1.4.1" + +tr46@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-1.0.1.tgz#a8b13fd6bfd2489519674ccde55ba3693b706d09" + dependencies: + punycode "^2.1.0" + +trim-right@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" + +ts-jest@22.4.1: + version "22.4.1" + resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-22.4.1.tgz#69defb2042d689cff9b4244365ef638ecd35f706" + dependencies: + babel-core "^6.24.1" + babel-plugin-istanbul "^4.1.4" + babel-plugin-transform-es2015-modules-commonjs "^6.24.1" + babel-preset-jest "^22.4.0" + cpx "^1.5.0" + fs-extra "4.0.3" + jest-config "^22.4.0" + pkg-dir "^2.0.0" + yargs "^11.0.0" + +tslib@^1.0.0, tslib@^1.7.1: + version "1.7.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.7.1.tgz#bc8004164691923a79fe8378bbeb3da2017538ec" + +tslib@^1.8.0: + version "1.9.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.0.tgz#e37a86fda8cbbaf23a057f473c9f4dc64e5fc2e8" + +tslint-config-prettier@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/tslint-config-prettier/-/tslint-config-prettier-1.1.0.tgz#40c026a56e4da27063b3e9bcd71f4f8109fee369" + +tslint-eslint-rules@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/tslint-eslint-rules/-/tslint-eslint-rules-4.1.1.tgz#7c30e7882f26bc276bff91d2384975c69daf88ba" + dependencies: + doctrine "^0.7.2" + tslib "^1.0.0" + tsutils "^1.4.0" + +tslint@5.9.1: + version "5.9.1" + resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.9.1.tgz#1255f87a3ff57eb0b0e1f0e610a8b4748046c9ae" + dependencies: + babel-code-frame "^6.22.0" + builtin-modules "^1.1.1" + chalk "^2.3.0" + commander "^2.12.1" + diff "^3.2.0" + glob "^7.1.1" + js-yaml "^3.7.0" + minimatch "^3.0.4" + resolve "^1.3.2" + semver "^5.3.0" + tslib "^1.8.0" + tsutils "^2.12.1" + +tsutils@^1.4.0: + version "1.9.1" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-1.9.1.tgz#b9f9ab44e55af9681831d5f28d0aeeaf5c750cb0" + +tsutils@^2.12.1: + version "2.12.2" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.12.2.tgz#ad58a4865d17ec3ddb6631b6ca53be14a5656ff3" + dependencies: + tslib "^1.7.1" + +tunnel-agent@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" + dependencies: + safe-buffer "^5.0.1" + +tunnel-agent@~0.4.1: + version "0.4.3" + resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.4.3.tgz#6373db76909fe570e08d73583365ed828a74eeeb" + +tweetnacl@^0.14.3, tweetnacl@~0.14.0: + version "0.14.5" + resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" + +type-check@~0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" + dependencies: + prelude-ls "~1.1.2" + +typescript@2.7.2: + version "2.7.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.7.2.tgz#2d615a1ef4aee4f574425cdff7026edf81919836" + +uglify-js@^2.6: + version "2.8.29" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd" + dependencies: + source-map "~0.5.1" + yargs "~3.10.0" + optionalDependencies: + uglify-to-browserify "~1.0.0" + +uglify-to-browserify@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" + +uid-number@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81" + +universalify@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.0.tgz#9eb1c4651debcc670cc94f1a75762332bb967778" + +urlgrey@0.4.4: + version "0.4.4" + resolved "https://registry.yarnpkg.com/urlgrey/-/urlgrey-0.4.4.tgz#892fe95960805e85519f1cd4389f2cb4cbb7652f" + +util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + +util.promisify@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/util.promisify/-/util.promisify-1.0.0.tgz#440f7165a459c9a16dc145eb8e72f35687097030" + dependencies: + define-properties "^1.1.2" + object.getownpropertydescriptors "^2.0.3" + +uuid@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" + +uuid@^3.1.0: + version "3.2.1" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.2.1.tgz#12c528bb9d58d0b9265d9a2f6f0fe8be17ff1f14" + +validate-npm-package-license@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz#2804babe712ad3379459acfbe24746ab2c303fbc" + dependencies: + spdx-correct "~1.0.0" + spdx-expression-parse "~1.0.0" + +verror@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/verror/-/verror-1.3.6.tgz#cff5df12946d297d2baaefaa2689e25be01c005c" + dependencies: + extsprintf "1.0.2" + +w3c-hr-time@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/w3c-hr-time/-/w3c-hr-time-1.0.1.tgz#82ac2bff63d950ea9e3189a58a65625fedf19045" + dependencies: + browser-process-hrtime "^0.1.2" + +walker@~1.0.5: + version "1.0.7" + resolved "https://registry.yarnpkg.com/walker/-/walker-1.0.7.tgz#2f7f9b8fd10d677262b18a884e28d19618e028fb" + dependencies: + makeerror "1.0.x" + +watch@~0.18.0: + version "0.18.0" + resolved "https://registry.yarnpkg.com/watch/-/watch-0.18.0.tgz#28095476c6df7c90c963138990c0a5423eb4b986" + dependencies: + exec-sh "^0.2.0" + minimist "^1.2.0" + +webidl-conversions@^4.0.1, webidl-conversions@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad" + +whatwg-encoding@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/whatwg-encoding/-/whatwg-encoding-1.0.1.tgz#3c6c451a198ee7aec55b1ec61d0920c67801a5f4" + dependencies: + iconv-lite "0.4.13" + +whatwg-encoding@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/whatwg-encoding/-/whatwg-encoding-1.0.3.tgz#57c235bc8657e914d24e1a397d3c82daee0a6ba3" + dependencies: + iconv-lite "0.4.19" + +whatwg-url@^6.4.0: + version "6.4.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-6.4.0.tgz#08fdf2b9e872783a7a1f6216260a1d66cc722e08" + dependencies: + lodash.sortby "^4.7.0" + tr46 "^1.0.0" + webidl-conversions "^4.0.1" + +which-module@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" + +which@^1.2.12, which@^1.2.9: + version "1.2.14" + resolved "https://registry.yarnpkg.com/which/-/which-1.2.14.tgz#9a87c4378f03e827cecaf1acdf56c736c01c14e5" + dependencies: + isexe "^2.0.0" + +which@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a" + dependencies: + isexe "^2.0.0" + +wide-align@^1.1.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.2.tgz#571e0f1b0604636ebc0dfc21b0339bbe31341710" + dependencies: + string-width "^1.0.2" + +window-size@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d" + +wordwrap@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" + +wordwrap@~0.0.2: + version "0.0.3" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" + +wordwrap@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" + +wrap-ansi@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85" + dependencies: + string-width "^1.0.1" + strip-ansi "^3.0.1" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + +write-file-atomic@^2.1.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.3.0.tgz#1ff61575c2e2a4e8e510d6fa4e243cce183999ab" + dependencies: + graceful-fs "^4.1.11" + imurmurhash "^0.1.4" + signal-exit "^3.0.2" + +ws@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-4.1.0.tgz#a979b5d7d4da68bf54efe0408967c324869a7289" + dependencies: + async-limiter "~1.0.0" + safe-buffer "~5.1.0" + +xml-name-validator@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" + +xtend@^4.0.0, xtend@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" + +y18n@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41" + +yallist@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" + +yargs-parser@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-8.1.0.tgz#f1376a33b6629a5d063782944da732631e966950" + dependencies: + camelcase "^4.1.0" + +yargs-parser@^9.0.2: + version "9.0.2" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-9.0.2.tgz#9ccf6a43460fe4ed40a9bb68f48d43b8a68cc077" + dependencies: + camelcase "^4.1.0" + +yargs@^10.0.3: + version "10.1.2" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-10.1.2.tgz#454d074c2b16a51a43e2fb7807e4f9de69ccb5c5" + dependencies: + cliui "^4.0.0" + decamelize "^1.1.1" + find-up "^2.1.0" + get-caller-file "^1.0.1" + os-locale "^2.0.0" + require-directory "^2.1.1" + require-main-filename "^1.0.1" + set-blocking "^2.0.0" + string-width "^2.0.0" + which-module "^2.0.0" + y18n "^3.2.1" + yargs-parser "^8.1.0" + +yargs@^11.0.0: + version "11.0.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-11.0.0.tgz#c052931006c5eee74610e5fc0354bedfd08a201b" + dependencies: + cliui "^4.0.0" + decamelize "^1.1.1" + find-up "^2.1.0" + get-caller-file "^1.0.1" + os-locale "^2.0.0" + require-directory "^2.1.1" + require-main-filename "^1.0.1" + set-blocking "^2.0.0" + string-width "^2.0.0" + which-module "^2.0.0" + y18n "^3.2.1" + yargs-parser "^9.0.2" + +yargs@~3.10.0: + version "3.10.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.10.0.tgz#f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1" + dependencies: + camelcase "^1.0.2" + cliui "^2.1.0" + decamelize "^1.0.0" + window-size "0.1.0" diff --git a/packages/oauth-twitter/src/accounts-oauth-twitter.ts b/packages/oauth-twitter/src/accounts-oauth-twitter.ts index 7961c4d51..bbd31da4a 100644 --- a/packages/oauth-twitter/src/accounts-oauth-twitter.ts +++ b/packages/oauth-twitter/src/accounts-oauth-twitter.ts @@ -1,21 +1,18 @@ import * as oauth from 'oauth'; -export interface AccountsOauthTwitterOptions { - key: string; - secret: string; -} +import { Configuration } from './types/configuration'; export class AccountsOAuthTwitter { - private options: AccountsOauthTwitterOptions; + private config: Configuration; private oauth: any; - constructor(options: AccountsOauthTwitterOptions) { - this.options = options; + constructor(config: Configuration) { + this.config = config; this.oauth = new oauth.OAuth( 'https://twitter.com/oauth/request_token', 'https://twitter.com/oauth/access_token', - this.options.key, - this.options.secret, + this.config.key, + this.config.secret, '1.0A', null, 'HMAC-SHA1' diff --git a/packages/oauth-twitter/src/index.ts b/packages/oauth-twitter/src/index.ts index 49db7e5ff..b3fa767f8 100644 --- a/packages/oauth-twitter/src/index.ts +++ b/packages/oauth-twitter/src/index.ts @@ -1,4 +1,3 @@ import { AccountsOAuthTwitter } from './accounts-oauth-twitter'; -export { AccountsOauthTwitterOptions } from './accounts-oauth-twitter'; export default AccountsOAuthTwitter; diff --git a/packages/oauth-twitter/src/types/configuration.ts b/packages/oauth-twitter/src/types/configuration.ts new file mode 100644 index 000000000..f64a72efc --- /dev/null +++ b/packages/oauth-twitter/src/types/configuration.ts @@ -0,0 +1,4 @@ +export interface Configuration { + key: string; + secret: string; +} diff --git a/packages/oauth/__tests__/accounts-oauth.ts b/packages/oauth/__tests__/accounts-oauth.ts index 56993901c..e51791575 100644 --- a/packages/oauth/__tests__/accounts-oauth.ts +++ b/packages/oauth/__tests__/accounts-oauth.ts @@ -63,7 +63,7 @@ describe('AccountsOauth', () => { } }); - it('should call provider\'s authenticate method in order to get the user itself', async () => { + it("should call provider's authenticate method in order to get the user itself", async () => { const authSpy = jest.fn(() => ({ id: '312312', name: 'Mr. Anderson', @@ -150,7 +150,7 @@ describe('AccountsOauth', () => { }); }); - it('should update the user\'s profile if logged in after change in profile', async () => { + it("should update the user's profile if logged in after change in profile", async () => { const userChanged = { id: '312312', name: 'Mr. Anderson', diff --git a/packages/oauth/src/accounts-oauth.ts b/packages/oauth/src/accounts-oauth.ts index 2fa95cb88..c3194f33f 100644 --- a/packages/oauth/src/accounts-oauth.ts +++ b/packages/oauth/src/accounts-oauth.ts @@ -2,25 +2,15 @@ import { UserObjectType } from '@accounts/common'; import { AccountsServer, DBInterface, AuthService } from '@accounts/server'; import * as requestPromise from 'request-promise'; -export interface OauthUser { - id: string; - email?: string; - profile?: object; -} - -export interface OauthOptions { - [provider: string]: { - authenticate: (params: any) => Promise; - }; -} +import { OAuthOptions } from './types/oauth-options'; export class AccountsOauth implements AuthService { public server: AccountsServer; public serviceName = 'oauth'; private db: DBInterface; - private options: OauthOptions; + private options: OAuthOptions; - constructor(options) { + constructor(options: OAuthOptions) { this.options = options; } diff --git a/packages/oauth/src/types/oauth-options.ts b/packages/oauth/src/types/oauth-options.ts new file mode 100644 index 000000000..d5c5deae0 --- /dev/null +++ b/packages/oauth/src/types/oauth-options.ts @@ -0,0 +1,7 @@ +import { OAuthUser } from './oauth-user'; + +export interface OAuthOptions { + [provider: string]: { + authenticate: (params: any) => Promise; + }; +} diff --git a/packages/oauth/src/types/oauth-user.ts b/packages/oauth/src/types/oauth-user.ts new file mode 100644 index 000000000..270c60f4f --- /dev/null +++ b/packages/oauth/src/types/oauth-user.ts @@ -0,0 +1,5 @@ +export interface OAuthUser { + id: string; + email?: string; + profile?: object; +} diff --git a/packages/password/__tests__/encryption.ts b/packages/password/__tests__/utils/encryption.ts similarity index 96% rename from packages/password/__tests__/encryption.ts rename to packages/password/__tests__/utils/encryption.ts index 035d6fda2..eb17e3f2d 100644 --- a/packages/password/__tests__/encryption.ts +++ b/packages/password/__tests__/utils/encryption.ts @@ -2,7 +2,7 @@ import { bcryptPassword, hashPassword, verifyPassword, -} from '../src/encryption'; +} from '../../src/utils/encryption'; describe('encryption', () => { describe('bcryptPassword', () => { diff --git a/packages/password/src/accounts-password.ts b/packages/password/src/accounts-password.ts index 4458f2b1e..bf2bace82 100644 --- a/packages/password/src/accounts-password.ts +++ b/packages/password/src/accounts-password.ts @@ -21,19 +21,19 @@ import { AccountsServer, generateRandomToken, AuthService, + getFirstUserEmail, } from '@accounts/server'; -import { getFirstUserEmail } from '@accounts/server/lib/utils'; -import { hashPassword, bcryptPassword, verifyPassword } from './encryption'; import { - PasswordCreateUserType, - PasswordLoginType, - PasswordType, -} from './types'; - -export const isEmail = (email?: string) => { - const re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; - return email && re.test(email); -}; + hashPassword, + bcryptPassword, + verifyPassword, +} from './utils/encryption'; + +import { PasswordCreateUserType } from './types/password-create-user-type'; +import { PasswordLoginType } from './types/password-login-type'; +import { PasswordType } from './types/password-type'; + +import { isEmail } from './utils/isEmail'; export interface AccountsPasswordOptions { passwordHashAlgorithm?: HashAlgorithm; diff --git a/packages/password/src/types.ts b/packages/password/src/types.ts deleted file mode 100644 index c06c2fc5e..000000000 --- a/packages/password/src/types.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { - CreateUserType, - HashAlgorithm, - LoginUserIdentityType, -} from '@accounts/common'; - -export type PasswordType = - | string - | { - digest: string; - algorithm: HashAlgorithm; - }; - -export interface PasswordLoginType { - user: string | LoginUserIdentityType; - password: PasswordType; -} - -export interface PasswordCreateUserType extends CreateUserType { - password: PasswordType; -} diff --git a/packages/password/src/types/password-create-user-type.ts b/packages/password/src/types/password-create-user-type.ts new file mode 100644 index 000000000..bd63bcef5 --- /dev/null +++ b/packages/password/src/types/password-create-user-type.ts @@ -0,0 +1,6 @@ +import { CreateUserType } from '@accounts/common'; +import { PasswordType } from './password-type'; + +export interface PasswordCreateUserType extends CreateUserType { + password: PasswordType; +} diff --git a/packages/password/src/types/password-login-type.ts b/packages/password/src/types/password-login-type.ts new file mode 100644 index 000000000..f2aadf47f --- /dev/null +++ b/packages/password/src/types/password-login-type.ts @@ -0,0 +1,7 @@ +import { LoginUserIdentityType } from '@accounts/common'; +import { PasswordType } from './password-type'; + +export interface PasswordLoginType { + user: string | LoginUserIdentityType; + password: PasswordType; +} diff --git a/packages/password/src/types/password-type.ts b/packages/password/src/types/password-type.ts new file mode 100644 index 000000000..0eede99bc --- /dev/null +++ b/packages/password/src/types/password-type.ts @@ -0,0 +1,8 @@ +import { HashAlgorithm } from '@accounts/common'; + +export type PasswordType = + | string + | { + digest: string; + algorithm: HashAlgorithm; + }; diff --git a/packages/password/src/encryption.ts b/packages/password/src/utils/encryption.ts similarity index 92% rename from packages/password/src/encryption.ts rename to packages/password/src/utils/encryption.ts index 5351e1d8d..84fe520dd 100644 --- a/packages/password/src/encryption.ts +++ b/packages/password/src/utils/encryption.ts @@ -1,6 +1,6 @@ import * as bcrypt from 'bcryptjs'; import * as crypto from 'crypto'; -import { PasswordType } from './types'; +import { PasswordType } from '../types/password-type'; export const bcryptPassword = async (password: string): Promise => { const salt = await bcrypt.genSalt(10); diff --git a/packages/password/src/utils/isEmail.ts b/packages/password/src/utils/isEmail.ts new file mode 100644 index 000000000..c3e096484 --- /dev/null +++ b/packages/password/src/utils/isEmail.ts @@ -0,0 +1,4 @@ +export const isEmail = (email?: string) => { + const re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; + return email && re.test(email); +}; diff --git a/packages/rest-client/.npmignore b/packages/rest-client/.npmignore new file mode 100644 index 000000000..987e688aa --- /dev/null +++ b/packages/rest-client/.npmignore @@ -0,0 +1,7 @@ +__tests__ +src/ +coverage/ +node_modules +.npmignore +tsconfig.json +yarn.lock \ No newline at end of file diff --git a/packages/rest-client/README.md b/packages/rest-client/README.md new file mode 100644 index 000000000..e4dbd96ed --- /dev/null +++ b/packages/rest-client/README.md @@ -0,0 +1,12 @@ +# @accounts/rest-client + +[![npm](https://img.shields.io/npm/v/@accounts/rest-client.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/rest-client) +[![CircleCI](https://circleci.com/gh/accounts-js/rest.svg?style=shield)](https://circleci.com/gh/accounts-js/rest) +[![codecov](https://codecov.io/gh/accounts-js/rest/branch/master/graph/badge.svg)](https://codecov.io/gh/accounts-js/rest) +![MIT License](https://img.shields.io/badge/license-MIT-blue.svg) + +## Install + +``` +yarn add @accounts/rest-client +``` diff --git a/packages/rest-client/__tests__/auth-fetch.ts b/packages/rest-client/__tests__/auth-fetch.ts new file mode 100644 index 000000000..c890a7b1d --- /dev/null +++ b/packages/rest-client/__tests__/auth-fetch.ts @@ -0,0 +1,51 @@ +import fetch from 'node-fetch'; +import { authFetch } from '../src/auth-fetch'; + +window.fetch = jest.fn().mockImplementation(() => ({ + status: 200, + json: jest.fn().mockImplementation(() => ({ test: 'test' })), +})); + +describe('authFetch', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('should call fetch', async () => { + const accounts = { + refreshSession: jest.fn(() => Promise.resolve()), + tokens: jest.fn(() => Promise.resolve({})), + }; + await authFetch(accounts, 'path', {}); + expect(accounts.refreshSession).toBeCalled(); + expect(accounts.tokens).toBeCalled(); + }); + + it('should set access token header', async () => { + const accounts = { + refreshSession: jest.fn(() => Promise.resolve()), + tokens: jest.fn(() => Promise.resolve({ accessToken: 'accessToken' })), + }; + await authFetch(accounts, 'path', {}); + expect(accounts.refreshSession).toBeCalled(); + expect(accounts.tokens).toBeCalled(); + expect(window.fetch.mock.calls[0][1].headers['accounts-access-token']).toBe( + 'accessToken' + ); + }); + + it('should pass other headers', async () => { + const accounts = { + refreshSession: jest.fn(() => Promise.resolve()), + tokens: jest.fn(() => Promise.resolve({ accessToken: 'accessToken' })), + }; + await authFetch(accounts, 'path', { + headers: { + toto: 'toto', + }, + }); + expect(accounts.refreshSession).toBeCalled(); + expect(accounts.tokens).toBeCalled(); + expect(window.fetch.mock.calls[0][1].headers.toto).toBe('toto'); + }); +}); diff --git a/packages/rest-client/__tests__/rest-client.ts b/packages/rest-client/__tests__/rest-client.ts new file mode 100644 index 000000000..49a95e6fe --- /dev/null +++ b/packages/rest-client/__tests__/rest-client.ts @@ -0,0 +1,251 @@ +import fetch from 'node-fetch'; +import { RestClient } from '../src/rest-client'; + +window.fetch = jest.fn().mockImplementation(() => ({ + status: 200, + json: jest.fn().mockImplementation(() => ({ test: 'test' })), +})); + +window.Headers = fetch.Headers; + +describe('RestClient', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('should have a way to configure api host address and root path', () => { + const client = new RestClient({ + apiHost: 'http://localhost:3000/', + rootPath: 'accounts', + }); + + expect(client.options.apiHost).toBe('http://localhost:3000/'); + expect(client.options.rootPath).toBe('accounts'); + + return client.fetch('try').then(() => { + expect(window.fetch.mock.calls[0][0]).toBe( + 'http://localhost:3000/accounts/try' + ); + }); + }); + + describe('fetch', () => { + const client = new RestClient({ + apiHost: 'http://localhost:3000/', + rootPath: 'accounts', + }); + + it('should enable custom headers', () => + client + .fetch('route', {}, { origin: 'localhost:3000' }) + .then(() => + expect(window.fetch.mock.calls[0][1].headers.origin).toBe( + 'localhost:3000' + ) + )); + + it('should throw error', async () => { + window.fetch = jest.fn().mockImplementation(() => ({ + status: 400, + json: jest.fn().mockImplementation(() => ({ test: 'test' })), + })); + + try { + await client.fetch('route', {}, { origin: 'localhost:3000' }); + throw new Error(); + } catch (err) { + expect(window.fetch.mock.calls[0][1].headers.origin).toBe( + 'localhost:3000' + ); + } + window.fetch = jest.fn().mockImplementation(() => ({ + status: 200, + json: jest.fn().mockImplementation(() => ({ test: 'test' })), + })); + }); + + it('should throw if server did not return a response', async () => { + window.fetch = jest.fn().mockImplementation(() => null); + + try { + await client.fetch('route', {}, { origin: 'localhost:3000' }); + throw new Error(); + } catch (err) { + expect(window.fetch.mock.calls[0][1].headers.origin).toBe( + 'localhost:3000' + ); + expect(err.message).toBe('Server did not return a response'); + } + window.fetch = jest.fn().mockImplementation(() => ({ + status: 200, + json: jest.fn().mockImplementation(() => ({ test: 'test' })), + })); + }); + }); + + describe('loginWithService', () => { + const client = new RestClient({ + apiHost: 'http://localhost:3000', + rootPath: '/accounts', + }); + + it('should call fetch with authenticate path', async () => { + await client.loginWithService('password', { + user: { + username: 'toto', + }, + password: 'password', + }); + expect(window.fetch.mock.calls[0][0]).toBe( + 'http://localhost:3000/accounts/password/authenticate' + ); + expect(window.fetch.mock.calls[0][1].body).toBe( + '{"user":{"username":"toto"},"password":"password"}' + ); + }); + }); + + describe('impersonate', () => { + const client = new RestClient({ + apiHost: 'http://localhost:3000', + rootPath: '/accounts', + }); + + it('should call fetch with impersonate path', () => + client + .impersonate('token', 'user') + .then(() => + expect(window.fetch.mock.calls[0][0]).toBe( + 'http://localhost:3000/accounts/impersonate' + ) + )); + }); + + describe('refreshTokens', () => { + const client = new RestClient({ + apiHost: 'http://localhost:3000', + rootPath: '/accounts', + }); + + it('should call fetch with refreshTokens path', () => + client + .refreshTokens('accessToken', 'refreshToken') + .then(() => + expect(window.fetch.mock.calls[0][0]).toBe( + 'http://localhost:3000/accounts/refreshTokens' + ) + )); + }); + + describe('logout', () => { + const client = new RestClient({ + apiHost: 'http://localhost:3000', + rootPath: '/accounts', + }); + + it('should call fetch with logout path', () => + client + .logout('accessToken') + .then(() => + expect(window.fetch.mock.calls[0][0]).toBe( + 'http://localhost:3000/accounts/logout' + ) + )); + }); + + describe('getUser', () => { + const client = new RestClient({ + apiHost: 'http://localhost:3000', + rootPath: '/accounts', + }); + + it('should call fetch with user path', () => + client + .getUser('accessToken') + .then(() => + expect(window.fetch.mock.calls[0][0]).toBe( + 'http://localhost:3000/accounts/user' + ) + )); + }); + + describe('createUser', () => { + const client = new RestClient({ + apiHost: 'http://localhost:3000', + rootPath: '/accounts', + }); + + it('should call fetch with register path', () => + client + .createUser('user') + .then(() => + expect(window.fetch.mock.calls[0][0]).toBe( + 'http://localhost:3000/accounts/password/register' + ) + )); + }); + + describe('resetPassword', () => { + const client = new RestClient({ + apiHost: 'http://localhost:3000', + rootPath: '/accounts', + }); + + it('should call fetch with resetPassword path', () => + client + .resetPassword('token', 'resetPassword') + .then(() => + expect(window.fetch.mock.calls[0][0]).toBe( + 'http://localhost:3000/accounts/password/resetPassword' + ) + )); + }); + + describe('verifyEmail', () => { + const client = new RestClient({ + apiHost: 'http://localhost:3000', + rootPath: '/accounts', + }); + + it('should call fetch with verifyEmail path', () => + client + .verifyEmail('token') + .then(() => + expect(window.fetch.mock.calls[0][0]).toBe( + 'http://localhost:3000/accounts/password/verifyEmail' + ) + )); + }); + + describe('sendVerificationEmail', () => { + const client = new RestClient({ + apiHost: 'http://localhost:3000', + rootPath: '/accounts', + }); + + it('should call fetch with verifyEmail path', () => + client + .sendVerificationEmail('email') + .then(() => + expect(window.fetch.mock.calls[0][0]).toBe( + 'http://localhost:3000/accounts/password/sendVerificationEmail' + ) + )); + }); + + describe('sendResetPasswordEmail', () => { + const client = new RestClient({ + apiHost: 'http://localhost:3000', + rootPath: '/accounts', + }); + + it('should call fetch with verifyEmail path', () => + client + .sendResetPasswordEmail('email') + .then(() => + expect(window.fetch.mock.calls[0][0]).toBe( + 'http://localhost:3000/accounts/password/sendResetPasswordEmail' + ) + )); + }); +}); diff --git a/packages/rest-client/package.json b/packages/rest-client/package.json new file mode 100644 index 000000000..78e40161e --- /dev/null +++ b/packages/rest-client/package.json @@ -0,0 +1,61 @@ +{ + "name": "@accounts/rest-client", + "version": "0.1.0-beta.2", + "description": "REST client for accounts", + "main": "lib/index", + "typings": "lib/index", + "publishConfig": { + "access": "public" + }, + "scripts": { + "start": "tsc --watch", + "precompile": "rimraf ./lib", + "compile": "tsc", + "prepublishOnly": "npm run compile", + "test": "npm run testonly", + "testonly": "jest", + "coverage": "npm run testonly -- --coverage", + "coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage" + }, + "jest": { + "testEnvironment": "jsdom", + "transform": { + ".(ts|tsx)": "/../../node_modules/ts-jest/preprocessor.js" + }, + "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx)$", + "moduleFileExtensions": [ + "ts", + "js" + ], + "mapCoverage": true + }, + "repository": { + "type": "git", + "url": "https://github.com/js-accounts/rest/tree/master/packages/rest-client" + }, + "keywords": [ + "rest", + "graphql", + "grant", + "auth", + "authentication", + "accounts", + "users", + "oauth" + ], + "author": "Tim Mikeladze", + "license": "MIT", + "devDependencies": { + "@accounts/client": "0.1.0-beta.3", + "@accounts/common": "0.1.0-beta.3", + "@types/lodash": "4.14.104", + "node-fetch": "2.1.1" + }, + "peerDependencies": { + "@accounts/client": "^0.1.0-beta.0", + "@accounts/common": "^0.1.0-beta.0" + }, + "dependencies": { + "lodash": "^4.17.4" + } +} diff --git a/packages/rest-client/src/auth-fetch.ts b/packages/rest-client/src/auth-fetch.ts new file mode 100644 index 000000000..37599432a --- /dev/null +++ b/packages/rest-client/src/auth-fetch.ts @@ -0,0 +1,34 @@ +import { forIn } from 'lodash'; +import { AccountsClient } from '@accounts/client'; + +const headers: { [key: string]: string } = { + 'Content-Type': 'application/json', +}; + +export const authFetch = async ( + accounts: AccountsClient, + path: string, + request: any +) => { + await accounts.refreshSession(); + const { accessToken } = await accounts.tokens(); + const headersCopy = { ...headers }; + + if (accessToken) { + headersCopy['accounts-access-token'] = accessToken; + } + + /* tslint:disable no-string-literal */ + if (request['headers']) { + forIn(request['headers'], (v: string, k: string) => { + headersCopy[v] = k; + }); + } + /* tslint:enable no-string-literal */ + + const fetchOptions = { + ...request, + headers: headersCopy, + }; + return fetch(path, fetchOptions); +}; diff --git a/packages/rest-client/src/index.ts b/packages/rest-client/src/index.ts new file mode 100644 index 000000000..5f16eacb7 --- /dev/null +++ b/packages/rest-client/src/index.ts @@ -0,0 +1,2 @@ +export { RestClient } from './rest-client'; +export { authFetch } from './auth-fetch'; diff --git a/packages/rest-client/src/rest-client.ts b/packages/rest-client/src/rest-client.ts new file mode 100644 index 000000000..75d8cb72b --- /dev/null +++ b/packages/rest-client/src/rest-client.ts @@ -0,0 +1,195 @@ +import { forIn, isPlainObject } from 'lodash'; +import { TransportInterface, AccountsClient } from '@accounts/client'; +import { + AccountsError, + CreateUserType, + LoginReturnType, + UserObjectType, + ImpersonateReturnType, +} from '@accounts/common'; + +export interface OptionsType { + apiHost: string; + rootPath: string; +} + +const headers: { [key: string]: string } = { + 'Content-Type': 'application/json', +}; + +export class RestClient implements TransportInterface { + private options: OptionsType; + + constructor(options: OptionsType) { + this.options = options; + } + + public async fetch( + route: string, + args: object, + customHeaders: object = {} + ): Promise { + const fetchOptions = { + headers: this._loadHeadersObject(customHeaders), + ...args, + }; + const res = await fetch( + `${this.options.apiHost}${this.options.rootPath}/${route}`, + fetchOptions + ); + + if (res) { + if (res.status >= 400 && res.status < 600) { + const { message, loginInfo, errorCode } = await res.json(); + throw new AccountsError(message, loginInfo, errorCode); + } + return res.json(); + } else { + throw new Error('Server did not return a response'); + } + } + + public loginWithService( + provider: string, + data: any, + customHeaders?: object + ): Promise { + const args = { + method: 'POST', + body: JSON.stringify({ + ...data, + }), + }; + return this.fetch(`${provider}/authenticate`, args, customHeaders); + } + + public impersonate( + accessToken: string, + username: string, + customHeaders?: object + ): Promise { + const args = { + method: 'POST', + body: JSON.stringify({ + accessToken, + username, + }), + }; + return this.fetch('impersonate', args, customHeaders); + } + + public refreshTokens( + accessToken: string, + refreshToken: string, + customHeaders?: object + ): Promise { + const args = { + method: 'POST', + body: JSON.stringify({ + accessToken, + refreshToken, + }), + }; + return this.fetch('refreshTokens', args, customHeaders); + } + + public logout(accessToken: string, customHeaders?: object): Promise { + const args = { + method: 'POST', + body: JSON.stringify({ + accessToken, + }), + }; + return this.fetch('logout', args, customHeaders); + } + + public async getUser( + accessToken: string, + customHeaders?: object + ): Promise { + const args = { + method: 'POST', + body: JSON.stringify({ + accessToken, + }), + }; + return this.fetch('user', args, customHeaders); + } + + public async createUser( + user: CreateUserType, + customHeaders?: object + ): Promise { + const args = { + method: 'POST', + body: JSON.stringify({ user }), + }; + return this.fetch('password/register', args, customHeaders); + } + + public resetPassword( + token: string, + newPassword: string, + customHeaders?: object + ): Promise { + const args = { + method: 'POST', + body: JSON.stringify({ + token, + newPassword, + }), + }; + return this.fetch('password/resetPassword', args, customHeaders); + } + + public verifyEmail(token: string, customHeaders?: object): Promise { + const args = { + method: 'POST', + body: JSON.stringify({ + token, + }), + }; + return this.fetch('password/verifyEmail', args, customHeaders); + } + + public sendVerificationEmail( + email: string, + customHeaders?: object + ): Promise { + const args = { + method: 'POST', + body: JSON.stringify({ + email, + }), + }; + return this.fetch('password/sendVerificationEmail', args, customHeaders); + } + + public sendResetPasswordEmail( + email: string, + customHeaders?: object + ): Promise { + const args = { + method: 'POST', + body: JSON.stringify({ + email, + }), + }; + return this.fetch('password/sendResetPasswordEmail', args, customHeaders); + } + + private _loadHeadersObject(plainHeaders: object): { [key: string]: string } { + if (isPlainObject(plainHeaders)) { + const customHeaders = headers; + forIn(plainHeaders, (v: string, k: string) => { + customHeaders[k] = v; + }); + + return customHeaders; + } + + return headers; + } +} + +export default RestClient; diff --git a/packages/rest-client/tsconfig.json b/packages/rest-client/tsconfig.json new file mode 100644 index 000000000..e0945a464 --- /dev/null +++ b/packages/rest-client/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig", + "compilerOptions": { + "rootDir": "./src", + "outDir": "./lib", + "lib": ["dom", "es6", "es2015", "es2016", "es2017"], + "typeRoots": [ + "node_modules/@types" + ] + }, + "exclude": [ + "node_modules", + "__tests__", + "lib" + ] +} diff --git a/packages/rest-client/yarn.lock b/packages/rest-client/yarn.lock new file mode 100644 index 000000000..6a982f55b --- /dev/null +++ b/packages/rest-client/yarn.lock @@ -0,0 +1,15 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@types/lodash@4.14.104": + version "4.14.104" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.104.tgz#53ee2357fa2e6e68379341d92eb2ecea4b11bb80" + +lodash@^4.17.4: + version "4.17.5" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.5.tgz#99a92d65c0272debe8c96b6057bc8fbfa3bed511" + +node-fetch@2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.1.1.tgz#369ca70b82f50c86496104a6c776d274f4e4a2d4" diff --git a/packages/rest-express/.npmignore b/packages/rest-express/.npmignore new file mode 100644 index 000000000..987e688aa --- /dev/null +++ b/packages/rest-express/.npmignore @@ -0,0 +1,7 @@ +__tests__ +src/ +coverage/ +node_modules +.npmignore +tsconfig.json +yarn.lock \ No newline at end of file diff --git a/packages/rest-express/README.md b/packages/rest-express/README.md new file mode 100644 index 000000000..eb5650079 --- /dev/null +++ b/packages/rest-express/README.md @@ -0,0 +1,12 @@ +# @accounts/rest-express + +[![npm](https://img.shields.io/npm/v/@accounts/rest-express.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/rest-express) +[![CircleCI](https://circleci.com/gh/accounts-js/rest.svg?style=shield)](https://circleci.com/gh/accounts-js/rest) +[![codecov](https://codecov.io/gh/accounts-js/rest/branch/master/graph/badge.svg)](https://codecov.io/gh/accounts-js/rest) +![MIT License](https://img.shields.io/badge/license-MIT-blue.svg) + +## Install + +``` +yarn add @accounts/rest-express +``` diff --git a/packages/rest-express/__tests__/endpoints/get-user.ts b/packages/rest-express/__tests__/endpoints/get-user.ts new file mode 100644 index 000000000..f4ac97f69 --- /dev/null +++ b/packages/rest-express/__tests__/endpoints/get-user.ts @@ -0,0 +1,61 @@ +import { getUser } from '../../src/endpoints/get-user'; + +const res = { + json: jest.fn(), + status: jest.fn(() => res), +}; + +describe('getUser', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('calls getUser and returns the user json response', async () => { + const user = { + id: '1', + }; + const accountsServer = { + resumeSession: jest.fn(() => user), + }; + const middleware = getUser(accountsServer as any); + + const req = { + body: { + accessToken: 'token', + }, + headers: {}, + }; + const reqCopy = { ...req }; + + await middleware(req, res); + + expect(req).toEqual(reqCopy); + expect(accountsServer.resumeSession).toBeCalledWith('token'); + expect(res.json).toBeCalledWith(user); + expect(res.status).not.toBeCalled(); + }); + + it('Sends error if it was thrown on getUser', async () => { + const error = { message: 'Could not get user' }; + const accountsServer = { + resumeSession: jest.fn(() => { + throw error; + }), + }; + const middleware = getUser(accountsServer as any); + const req = { + body: { + accessToken: 'token', + }, + headers: {}, + }; + const reqCopy = { ...req }; + + await middleware(req, res); + + expect(req).toEqual(reqCopy); + expect(accountsServer.resumeSession).toBeCalledWith('token'); + expect(res.status).toBeCalledWith(400); + expect(res.json).toBeCalledWith(error); + }); +}); diff --git a/packages/rest-express/__tests__/endpoints/impersonate.ts b/packages/rest-express/__tests__/endpoints/impersonate.ts new file mode 100644 index 000000000..8c59e9781 --- /dev/null +++ b/packages/rest-express/__tests__/endpoints/impersonate.ts @@ -0,0 +1,73 @@ +import { impersonate } from '../../src/endpoints/impersonate'; + +const res = { + json: jest.fn(), + status: jest.fn(() => res), +}; + +describe('impersonate', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('calls impersonate and returns the impersonate json response', async () => { + const impersonateReturnType = { + id: '1', + }; + const accountsServer = { + impersonate: jest.fn(() => impersonateReturnType), + }; + const middleware = impersonate(accountsServer as any); + + const req = { + body: { + username: 'toto', + accessToken: 'token', + }, + headers: {}, + }; + const reqCopy = { ...req }; + + await middleware(req, res); + + expect(req).toEqual(reqCopy); + expect(accountsServer.impersonate).toBeCalledWith( + 'token', + 'toto', + null, + '' + ); + expect(res.json).toBeCalledWith(impersonateReturnType); + expect(res.status).not.toBeCalled(); + }); + + it('Sends error if it was thrown on impersonate', async () => { + const error = { message: 'Could not impersonate' }; + const accountsServer = { + impersonate: jest.fn(() => { + throw error; + }), + }; + const middleware = impersonate(accountsServer as any); + const req = { + body: { + username: 'toto', + accessToken: 'token', + }, + headers: {}, + }; + const reqCopy = { ...req }; + + await middleware(req, res); + + expect(req).toEqual(reqCopy); + expect(accountsServer.impersonate).toBeCalledWith( + 'token', + 'toto', + null, + '' + ); + expect(res.status).toBeCalledWith(400); + expect(res.json).toBeCalledWith(error); + }); +}); diff --git a/packages/rest-express/__tests__/endpoints/logout.ts b/packages/rest-express/__tests__/endpoints/logout.ts new file mode 100644 index 000000000..9a375c6df --- /dev/null +++ b/packages/rest-express/__tests__/endpoints/logout.ts @@ -0,0 +1,56 @@ +import { logout } from '../../src/endpoints/logout'; + +const res = { + json: jest.fn(), + status: jest.fn(() => res), +}; + +describe('logout', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('calls logout and returns a message if when logged out successfuly', async () => { + const accountsServer = { + logout: jest.fn(), + }; + const middleware = logout(accountsServer as any); + + const req = { + body: { + accessToken: 'token', + }, + }; + const reqCopy = { ...req }; + + await middleware(req, res); + + expect(req).toEqual(reqCopy); + expect(accountsServer.logout).toBeCalledWith('token'); + expect(res.json).toBeCalledWith({ message: 'Logged out' }); + expect(res.status).not.toBeCalled(); + }); + + it('Sends error if it was thrown on logout', async () => { + const error = { message: 'Could not logout' }; + const accountsServer = { + logout: jest.fn(() => { + throw error; + }), + }; + const middleware = logout(accountsServer as any); + const req = { + body: { + accessToken: 'token', + }, + }; + const reqCopy = { ...req }; + + await middleware(req, res); + + expect(req).toEqual(reqCopy); + expect(accountsServer.logout).toBeCalledWith('token'); + expect(res.status).toBeCalledWith(400); + expect(res.json).toBeCalledWith(error); + }); +}); diff --git a/packages/rest-express/__tests__/endpoints/oauth/provider-callback.ts b/packages/rest-express/__tests__/endpoints/oauth/provider-callback.ts new file mode 100644 index 000000000..f7a8002f2 --- /dev/null +++ b/packages/rest-express/__tests__/endpoints/oauth/provider-callback.ts @@ -0,0 +1,72 @@ +import { providerCallback } from '../../../src/endpoints/oauth/provider-callback'; + +const res = { + json: jest.fn(), + status: jest.fn(() => res), +}; + +describe('providerCallback', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('calls loginWithService and returns the user json response', async () => { + const user = { + id: '1', + }; + const accountsServer = { + loginWithService: jest.fn(() => user), + }; + const middleware = providerCallback(accountsServer as any); + + const req = { + params: { + accessToken: 'token', + }, + query: { + accessTokenSecret: 'secret', + }, + headers: {}, + }; + const reqCopy = { ...req }; + + await middleware(req, res); + + expect(req).toEqual(reqCopy); + expect(accountsServer.loginWithService).toBeCalledWith( + 'oauth', + { accessToken: 'token', accessTokenSecret: 'secret' }, + { ip: null, userAgent: '' } + ); + expect(res.json).toBeCalledWith(user); + expect(res.status).not.toBeCalled(); + }); + + it('Sends error if it was thrown on loginWithService', async () => { + const error = { message: 'Could not login' }; + const accountsServer = { + loginWithService: jest.fn(() => { + throw error; + }), + }; + const middleware = providerCallback(accountsServer as any); + const req = { + params: { + accessToken: 'token', + }, + headers: {}, + }; + const reqCopy = { ...req }; + + await middleware(req, res); + + expect(req).toEqual(reqCopy); + expect(accountsServer.loginWithService).toBeCalledWith( + 'oauth', + { accessToken: 'token' }, + { ip: null, userAgent: '' } + ); + expect(res.status).toBeCalledWith(400); + expect(res.json).toBeCalledWith(error); + }); +}); diff --git a/packages/rest-express/__tests__/endpoints/password/register.ts b/packages/rest-express/__tests__/endpoints/password/register.ts new file mode 100644 index 000000000..660ca2008 --- /dev/null +++ b/packages/rest-express/__tests__/endpoints/password/register.ts @@ -0,0 +1,79 @@ +import { registerPassword } from '../../../src/endpoints/password/register'; + +const res = { + json: jest.fn(), + status: jest.fn(() => res), +}; + +describe('registerPassword', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('calls password.createUser and returns the user json response', async () => { + const userId = '1'; + const passwordService = { + createUser: jest.fn(() => userId), + }; + const accountsServer = { + getServices: () => ({ + password: passwordService, + }), + }; + const middleware = registerPassword(accountsServer as any); + + const req = { + body: { + user: { + username: 'toto', + }, + extraFieldThatShouldNotBePassed: 'hey', + }, + headers: {}, + }; + const reqCopy = { ...req }; + + await middleware(req, res); + + expect(req).toEqual(reqCopy); + expect(accountsServer.getServices().password.createUser).toBeCalledWith({ + username: 'toto', + }); + expect(res.json).toBeCalledWith({ userId: '1' }); + expect(res.status).not.toBeCalled(); + }); + + it('Sends error if it was thrown on loginWithService', async () => { + const error = { message: 'Could not login' }; + const passwordService = { + createUser: jest.fn(() => { + throw error; + }), + }; + const accountsServer = { + getServices: () => ({ + password: passwordService, + }), + }; + const middleware = registerPassword(accountsServer as any); + const req = { + body: { + user: { + username: 'toto', + }, + extraFieldThatShouldNotBePassed: 'hey', + }, + headers: {}, + }; + const reqCopy = { ...req }; + + await middleware(req, res); + + expect(req).toEqual(reqCopy); + expect(accountsServer.getServices().password.createUser).toBeCalledWith({ + username: 'toto', + }); + expect(res.status).toBeCalledWith(400); + expect(res.json).toBeCalledWith(error); + }); +}); diff --git a/packages/rest-express/__tests__/endpoints/password/reset.ts b/packages/rest-express/__tests__/endpoints/password/reset.ts new file mode 100644 index 000000000..450c2db1e --- /dev/null +++ b/packages/rest-express/__tests__/endpoints/password/reset.ts @@ -0,0 +1,143 @@ +import { + resetPassword, + sendResetPasswordEmail, +} from '../../../src/endpoints/password/reset'; + +const res = { + json: jest.fn(), + status: jest.fn(() => res), +}; + +describe('resetPassword', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + describe('resetPassword', () => { + it('calls password.resetPassword and returns a message', async () => { + const message = 'Password changed'; + const passwordService = { + resetPassword: jest.fn(() => null), + }; + const accountsServer = { + getServices: () => ({ + password: passwordService, + }), + }; + const middleware = resetPassword(accountsServer as any); + + const req = { + body: { + token: 'token', + newPassword: 'new-password', + }, + headers: {}, + }; + const reqCopy = { ...req }; + + await middleware(req, res); + + expect(req).toEqual(reqCopy); + expect( + accountsServer.getServices().password.resetPassword + ).toBeCalledWith('token', 'new-password'); + expect(res.json).toBeCalledWith({ message }); + expect(res.status).not.toBeCalled(); + }); + + it('Sends error if it was thrown on resetPassword', async () => { + const error = { message: 'Could not reset password' }; + const passwordService = { + resetPassword: jest.fn(() => { + throw error; + }), + }; + const accountsServer = { + getServices: () => ({ + password: passwordService, + }), + }; + const middleware = resetPassword(accountsServer as any); + const req = { + body: { + token: 'token', + newPassword: 'new-password', + }, + headers: {}, + }; + const reqCopy = { ...req }; + + await middleware(req, res); + + expect(req).toEqual(reqCopy); + expect( + accountsServer.getServices().password.resetPassword + ).toBeCalledWith('token', 'new-password'); + expect(res.status).toBeCalledWith(400); + expect(res.json).toBeCalledWith(error); + }); + }); + + describe('sendResetPasswordEmail', () => { + it('calls password.sendResetPasswordEmail and returns a message', async () => { + const message = 'Email sent'; + const passwordService = { + sendResetPasswordEmail: jest.fn(() => null), + }; + const accountsServer = { + getServices: () => ({ + password: passwordService, + }), + }; + const middleware = sendResetPasswordEmail(accountsServer as any); + + const req = { + body: { + email: 'email', + }, + headers: {}, + }; + const reqCopy = { ...req }; + + await middleware(req, res); + + expect(req).toEqual(reqCopy); + expect( + accountsServer.getServices().password.sendResetPasswordEmail + ).toBeCalledWith('email'); + expect(res.json).toBeCalledWith({ message }); + expect(res.status).not.toBeCalled(); + }); + + it('Sends error if it was thrown on sendResetPasswordEmail', async () => { + const error = { message: 'Could not send reset password' }; + const passwordService = { + sendResetPasswordEmail: jest.fn(() => { + throw error; + }), + }; + const accountsServer = { + getServices: () => ({ + password: passwordService, + }), + }; + const middleware = sendResetPasswordEmail(accountsServer as any); + const req = { + body: { + email: 'email', + }, + headers: {}, + }; + const reqCopy = { ...req }; + + await middleware(req, res); + + expect(req).toEqual(reqCopy); + expect( + accountsServer.getServices().password.sendResetPasswordEmail + ).toBeCalledWith('email'); + expect(res.status).toBeCalledWith(400); + expect(res.json).toBeCalledWith(error); + }); + }); +}); diff --git a/packages/rest-express/__tests__/endpoints/password/verify-email.ts b/packages/rest-express/__tests__/endpoints/password/verify-email.ts new file mode 100644 index 000000000..fb31379ae --- /dev/null +++ b/packages/rest-express/__tests__/endpoints/password/verify-email.ts @@ -0,0 +1,141 @@ +import { + verifyEmail, + sendVerificationEmail, +} from '../../../src/endpoints/password/verify-email'; + +const res = { + json: jest.fn(), + status: jest.fn(() => res), +}; + +describe('verifyEmail', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + describe('verifyEmail', () => { + it('calls password.verifyEmail and returns a message', async () => { + const message = 'Email verified'; + const passwordService = { + verifyEmail: jest.fn(() => null), + }; + const accountsServer = { + getServices: () => ({ + password: passwordService, + }), + }; + const middleware = verifyEmail(accountsServer as any); + + const req = { + body: { + token: 'token', + }, + headers: {}, + }; + const reqCopy = { ...req }; + + await middleware(req, res); + + expect(req).toEqual(reqCopy); + expect(accountsServer.getServices().password.verifyEmail).toBeCalledWith( + 'token' + ); + expect(res.json).toBeCalledWith({ message }); + expect(res.status).not.toBeCalled(); + }); + + it('Sends error if it was thrown on verifyEmail', async () => { + const error = { message: 'Could not verify email' }; + const passwordService = { + verifyEmail: jest.fn(() => { + throw error; + }), + }; + const accountsServer = { + getServices: () => ({ + password: passwordService, + }), + }; + const middleware = verifyEmail(accountsServer as any); + const req = { + body: { + token: 'token', + }, + headers: {}, + }; + const reqCopy = { ...req }; + + await middleware(req, res); + + expect(req).toEqual(reqCopy); + expect(accountsServer.getServices().password.verifyEmail).toBeCalledWith( + 'token' + ); + expect(res.status).toBeCalledWith(400); + expect(res.json).toBeCalledWith(error); + }); + }); + + describe('sendVerificationEmail', () => { + it('calls password.sendVerificationEmail and returns a message', async () => { + const message = 'Email sent'; + const passwordService = { + sendVerificationEmail: jest.fn(() => null), + }; + const accountsServer = { + getServices: () => ({ + password: passwordService, + }), + }; + const middleware = sendVerificationEmail(accountsServer as any); + + const req = { + body: { + email: 'email', + }, + headers: {}, + }; + const reqCopy = { ...req }; + + await middleware(req, res); + + expect(req).toEqual(reqCopy); + expect( + accountsServer.getServices().password.sendVerificationEmail + ).toBeCalledWith('email'); + expect(res.json).toBeCalledWith({ message }); + expect(res.status).not.toBeCalled(); + }); + + it('Sends error if it was thrown on sendVerificationEmail', async () => { + const error = { message: 'Could not send verification email' }; + const passwordService = { + sendVerificationEmail: jest.fn(() => { + throw error; + }), + }; + const accountsServer = { + getServices: () => ({ + password: passwordService, + }), + }; + const middleware = sendVerificationEmail(accountsServer as any); + const req = { + body: { + email: 'email', + }, + headers: {}, + }; + const reqCopy = { ...req }; + + await middleware(req, res); + + expect(req).toEqual(reqCopy); + expect( + accountsServer.getServices().password.sendVerificationEmail + ).toBeCalledWith('email'); + expect(res.status).toBeCalledWith(400); + expect(res.json).toBeCalledWith(error); + }); + }); +}); diff --git a/packages/rest-express/__tests__/endpoints/refresh-access-token.ts b/packages/rest-express/__tests__/endpoints/refresh-access-token.ts new file mode 100644 index 000000000..d97b3dcfe --- /dev/null +++ b/packages/rest-express/__tests__/endpoints/refresh-access-token.ts @@ -0,0 +1,75 @@ +import { refreshAccessToken } from '../../src/endpoints/refresh-access-token'; + +const res = { + json: jest.fn(), + status: jest.fn(() => res), +}; + +describe('refreshAccessToken', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('calls refreshTokens and returns the session in json format', async () => { + const session = { + user: { + id: '1', + }, + }; + const accountsServer = { + refreshTokens: jest.fn(() => session), + }; + const middleware = refreshAccessToken(accountsServer as any); + + const req = { + headers: {}, + body: { + accessToken: 'token', + refreshToken: 'refresh', + }, + }; + const reqCopy = { ...req }; + + await middleware(req, res); + + expect(accountsServer.refreshTokens).toBeCalledWith( + 'token', + 'refresh', + null, + '' + ); + expect(req).toEqual(reqCopy); + expect(res.json).toBeCalledWith(session); + expect(res.status).not.toBeCalled(); + }); + + it('Sends error if it was thrown on refreshTokens', async () => { + const error = { message: 'error' }; + const accountsServer = { + refreshTokens: jest.fn(() => { + throw error; + }), + }; + const middleware = refreshAccessToken(accountsServer as any); + const req = { + headers: {}, + body: { + accessToken: 'token', + refreshToken: 'refresh', + }, + }; + const reqCopy = { ...req }; + + await middleware(req, res); + + expect(req).toEqual(reqCopy); + expect(accountsServer.refreshTokens).toBeCalledWith( + 'token', + 'refresh', + null, + '' + ); + expect(res.status).toBeCalledWith(400); + expect(res.json).toBeCalledWith(error); + }); +}); diff --git a/packages/rest-express/__tests__/endpoints/service-authenticate.ts b/packages/rest-express/__tests__/endpoints/service-authenticate.ts new file mode 100644 index 000000000..3873ff667 --- /dev/null +++ b/packages/rest-express/__tests__/endpoints/service-authenticate.ts @@ -0,0 +1,67 @@ +import { serviceAuthenticate } from '../../src/endpoints/service-authenticate'; + +const res = { + json: jest.fn(), + status: jest.fn(() => res), +}; + +describe('serviceAuthenticate', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('calls loginWithService and returns the user in json format', async () => { + const user = { + id: '1', + }; + const accountsServer = { + loginWithService: jest.fn(() => user), + }; + const middleware = serviceAuthenticate(accountsServer as any); + + const req = { + params: { + service: 'sms', + }, + headers: {}, + }; + const reqCopy = { ...req }; + + await middleware(req, res); + + expect(req).toEqual(reqCopy); + expect(accountsServer.loginWithService).toBeCalledWith('sms', undefined, { + ip: null, + userAgent: '', + }); + expect(res.json).toBeCalledWith(user); + expect(res.status).not.toBeCalled(); + }); + + it('Sends error if it was thrown on loginWithService', async () => { + const error = { message: 'Could not login' }; + const accountsServer = { + loginWithService: jest.fn(() => { + throw error; + }), + }; + const middleware = serviceAuthenticate(accountsServer as any); + const req = { + params: { + service: 'sms', + }, + headers: {}, + }; + const reqCopy = { ...req }; + + await middleware(req, res); + + expect(req).toEqual(reqCopy); + expect(accountsServer.loginWithService).toBeCalledWith('sms', undefined, { + ip: null, + userAgent: '', + }); + expect(res.status).toBeCalledWith(400); + expect(res.json).toBeCalledWith(error); + }); +}); diff --git a/packages/rest-express/__tests__/express-middleware.ts b/packages/rest-express/__tests__/express-middleware.ts new file mode 100644 index 000000000..6bca1701c --- /dev/null +++ b/packages/rest-express/__tests__/express-middleware.ts @@ -0,0 +1,76 @@ +import accountsExpress from '../src'; +import * as express from 'express'; + +jest.mock('express', () => { + const mockRouter = { + post: jest.fn(), + get: jest.fn(), + }; + return { + Router: () => mockRouter, + }; +}); + +const router = express.Router(); + +describe('express middleware', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('Defines default endpoints on given path fragment', () => { + accountsExpress( + { + getServices: () => ({}), + } as any, + { path: 'test' } + ); + expect(router.post.mock.calls[0][0]).toBe('test/impersonate'); + expect(router.post.mock.calls[1][0]).toBe('test/user'); + expect(router.post.mock.calls[2][0]).toBe('test/refreshTokens'); + expect(router.post.mock.calls[3][0]).toBe('test/logout'); + expect(router.post.mock.calls[4][0]).toBe('test/:service/authenticate'); + }); + + it('Defines password endpoints when password service is present', () => { + accountsExpress( + { + getServices: () => ({ + password: {}, + }), + } as any, + { path: 'test' } + ); + expect(router.post.mock.calls[0][0]).toBe('test/impersonate'); + expect(router.post.mock.calls[1][0]).toBe('test/user'); + expect(router.post.mock.calls[2][0]).toBe('test/refreshTokens'); + expect(router.post.mock.calls[3][0]).toBe('test/logout'); + expect(router.post.mock.calls[4][0]).toBe('test/:service/authenticate'); + expect(router.post.mock.calls[5][0]).toBe('test/password/register'); + expect(router.post.mock.calls[6][0]).toBe('test/password/verifyEmail'); + expect(router.post.mock.calls[7][0]).toBe('test/password/resetPassword'); + expect(router.post.mock.calls[8][0]).toBe( + 'test/password/sendVerificationEmail' + ); + expect(router.post.mock.calls[9][0]).toBe( + 'test/password/sendResetPasswordEmail' + ); + }); + + it('Defines oauth endpoints when oauth service is present', () => { + accountsExpress( + { + getServices: () => ({ + oauth: {}, + }), + } as any, + { path: 'test' } + ); + expect(router.post.mock.calls[0][0]).toBe('test/impersonate'); + expect(router.post.mock.calls[1][0]).toBe('test/user'); + expect(router.post.mock.calls[2][0]).toBe('test/refreshTokens'); + expect(router.post.mock.calls[3][0]).toBe('test/logout'); + expect(router.post.mock.calls[4][0]).toBe('test/:service/authenticate'); + expect(router.get.mock.calls[0][0]).toBe('test/oauth/:provider/callback'); + }); +}); diff --git a/packages/rest-express/__tests__/user-loader.ts b/packages/rest-express/__tests__/user-loader.ts new file mode 100644 index 000000000..064c30a4b --- /dev/null +++ b/packages/rest-express/__tests__/user-loader.ts @@ -0,0 +1,61 @@ +import accountsExpress from '../src'; +import { userLoader } from '../src/user-loader'; + +const user = { id: '1' }; +const accountsServer = { + resumeSession: jest.fn(() => user), +}; +describe('userLoader', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('does noting when request has no accessToken', async () => { + const provider = userLoader(accountsServer as any); + const req = {}; + const res = {}; + const next = jest.fn(); + await provider(req, res, next); + + expect(accountsServer.resumeSession).not.toHaveBeenCalled(); + expect(req).toEqual({}); + expect(res).toEqual({}); + expect(next).toHaveBeenCalledTimes(1); + }); + + it('load user to req object when access token is present on the headers', async () => { + const provider = userLoader(accountsServer as any); + const req = { + headers: { + 'accounts-access-token': 'token', + }, + }; + const reqCopy = { ...req }; + const res = {}; + const next = jest.fn(); + await provider(req, res, next); + + expect(accountsServer.resumeSession).toHaveBeenCalledWith('token'); + expect(req).toEqual({ ...reqCopy, user, userId: user.id }); + expect(res).toEqual({}); + expect(next).toHaveBeenCalledTimes(1); + }); + + it('load user to req object when access token is present on the body', async () => { + const provider = userLoader(accountsServer as any); + const req = { + body: { + accessToken: 'token', + }, + }; + const reqCopy = { ...req }; + const res = {}; + const next = jest.fn(); + await provider(req, res, next); + + expect(accountsServer.resumeSession).toHaveBeenCalledWith('token'); + expect(req).toEqual({ ...reqCopy, user, userId: user.id }); + expect(res).toEqual({}); + expect(next).toHaveBeenCalledTimes(1); + }); +}); diff --git a/packages/rest-express/__tests__/utils/get-user-agent.ts b/packages/rest-express/__tests__/utils/get-user-agent.ts new file mode 100644 index 000000000..db1c9fd2f --- /dev/null +++ b/packages/rest-express/__tests__/utils/get-user-agent.ts @@ -0,0 +1,23 @@ +import { getUserAgent } from '../../src/utils/get-user-agent'; + +describe('getUserAgent', () => { + it('should return header user agent', () => { + const req = { + headers: { + 'user-agent': 'agent', + }, + }; + const userAgent = getUserAgent(req); + expect(userAgent).toBe('agent'); + }); + + it('should return header UC Browser user agent', () => { + const req = { + headers: { + 'x-ucbrowser-ua': 'agent', + }, + }; + const userAgent = getUserAgent(req); + expect(userAgent).toBe('agent'); + }); +}); diff --git a/packages/rest-express/package.json b/packages/rest-express/package.json new file mode 100644 index 000000000..0d2757ea3 --- /dev/null +++ b/packages/rest-express/package.json @@ -0,0 +1,60 @@ +{ + "name": "@accounts/rest-express", + "version": "0.1.0-beta.2", + "description": "Server side REST express middleware for accounts", + "main": "lib/index", + "typings": "lib/index", + "publishConfig": { + "access": "public" + }, + "scripts": { + "start": "tsc --watch", + "compile": "tsc", + "prepublishOnly": "npm run compile", + "test": "npm run testonly", + "test:watch": "npm run testonly -- --watch --coverage", + "testonly": "jest", + "coverage": "npm run testonly -- --coverage", + "coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage" + }, + "jest": { + "testEnvironment": "node", + "transform": { + ".(ts|tsx)": "/../../node_modules/ts-jest/preprocessor.js" + }, + "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx)$", + "moduleFileExtensions": [ + "ts", + "js" + ], + "mapCoverage": true + }, + "repository": { + "type": "git", + "url": "https://github.com/js-accounts/rest/tree/master/packages/rest-express" + }, + "keywords": [ + "users", + "accounts", + "rest", + "express" + ], + "author": "Tim Mikeladze", + "license": "MIT", + "devDependencies": { + "@accounts/common": "0.1.0-beta.3", + "@accounts/server": "0.1.0-beta.3", + "@types/express": "4.11.1", + "@types/lodash": "4.14.104", + "@types/request-ip": "0.0.33" + }, + "peerDependencies": { + "@accounts/common": "^0.1.0-beta.0", + "@accounts/server": "^0.1.0-beta.0" + }, + "dependencies": { + "express": "^4.16.2", + "lodash": "^4.17.4", + "request-ip": "^2.0.2" + } +} diff --git a/packages/rest-express/src/endpoints/get-user.ts b/packages/rest-express/src/endpoints/get-user.ts new file mode 100644 index 000000000..91a8c4b9f --- /dev/null +++ b/packages/rest-express/src/endpoints/get-user.ts @@ -0,0 +1,16 @@ +import * as express from 'express'; +import { AccountsServer } from '@accounts/server'; +import { sendError } from '../utils/send-error'; + +export const getUser = (accountsServer: AccountsServer) => async ( + req: express.Request, + res: express.Response +) => { + try { + const { accessToken } = req.body; + const user = await accountsServer.resumeSession(accessToken); + res.json(user); + } catch (err) { + sendError(res, err); + } +}; diff --git a/packages/rest-express/src/endpoints/impersonate.ts b/packages/rest-express/src/endpoints/impersonate.ts new file mode 100644 index 000000000..2c620f1fb --- /dev/null +++ b/packages/rest-express/src/endpoints/impersonate.ts @@ -0,0 +1,25 @@ +import * as express from 'express'; +import * as requestIp from 'request-ip'; +import { AccountsServer } from '@accounts/server'; +import { getUserAgent } from '../utils/get-user-agent'; +import { sendError } from '../utils/send-error'; + +export const impersonate = (accountsServer: AccountsServer) => async ( + req: express.Request, + res: express.Response +) => { + try { + const { username, accessToken } = req.body; + const userAgent = getUserAgent(req); + const ip = requestIp.getClientIp(req); + const impersonateRes = await accountsServer.impersonate( + accessToken, + username, + ip, + userAgent + ); + res.json(impersonateRes); + } catch (err) { + sendError(res, err); + } +}; diff --git a/packages/rest-express/src/endpoints/logout.ts b/packages/rest-express/src/endpoints/logout.ts new file mode 100644 index 000000000..83b7723d3 --- /dev/null +++ b/packages/rest-express/src/endpoints/logout.ts @@ -0,0 +1,16 @@ +import * as express from 'express'; +import { AccountsServer } from '@accounts/server'; +import { sendError } from '../utils/send-error'; + +export const logout = (accountsServer: AccountsServer) => async ( + req: express.Request, + res: express.Response +) => { + try { + const { accessToken } = req.body; + await accountsServer.logout(accessToken); + res.json({ message: 'Logged out' }); + } catch (err) { + sendError(res, err); + } +}; diff --git a/packages/rest-express/src/endpoints/oauth/provider-callback.ts b/packages/rest-express/src/endpoints/oauth/provider-callback.ts new file mode 100644 index 000000000..ec2fbafee --- /dev/null +++ b/packages/rest-express/src/endpoints/oauth/provider-callback.ts @@ -0,0 +1,32 @@ +import * as express from 'express'; +import * as requestIp from 'request-ip'; +import { AccountsServer } from '@accounts/server'; +import { getUserAgent } from '../../utils/get-user-agent'; +import { sendError } from '../../utils/send-error'; + +interface RequestWithSession extends express.Request { + session: { [key: string]: any }; +} + +export const providerCallback = (accountsServer: AccountsServer) => async ( + req: express.Request, + res: express.Response +) => { + try { + const userAgent = getUserAgent(req); + const ip = requestIp.getClientIp(req); + const loggedInUser = await accountsServer.loginWithService( + 'oauth', + { + ...(req.params || {}), + ...(req.query || {}), + ...(req.body || {}), + ...((req as RequestWithSession).session || {}), + }, + { ip, userAgent } + ); + res.json(loggedInUser); + } catch (err) { + sendError(res, err); + } +}; diff --git a/packages/rest-express/src/endpoints/password/register.ts b/packages/rest-express/src/endpoints/password/register.ts new file mode 100644 index 000000000..c44a9a4e9 --- /dev/null +++ b/packages/rest-express/src/endpoints/password/register.ts @@ -0,0 +1,16 @@ +import * as express from 'express'; +import { AccountsServer } from '@accounts/server'; +import { sendError } from '../../utils/send-error'; + +export const registerPassword = (accountsServer: AccountsServer) => async ( + req: express.Request, + res: express.Response +) => { + try { + const password: any = accountsServer.getServices().password; + const userId = await password.createUser(req.body.user); + res.json({ userId }); + } catch (err) { + sendError(res, err); + } +}; diff --git a/packages/rest-express/src/endpoints/password/reset.ts b/packages/rest-express/src/endpoints/password/reset.ts new file mode 100644 index 000000000..33e300849 --- /dev/null +++ b/packages/rest-express/src/endpoints/password/reset.ts @@ -0,0 +1,30 @@ +import * as express from 'express'; +import { AccountsServer } from '@accounts/server'; +import { sendError } from '../../utils/send-error'; + +export const resetPassword = (accountsServer: AccountsServer) => async ( + req: express.Request, + res: express.Response +) => { + try { + const { token, newPassword } = req.body; + const password: any = accountsServer.getServices().password; + await password.resetPassword(token, newPassword); + res.json({ message: 'Password changed' }); + } catch (err) { + sendError(res, err); + } +}; + +export const sendResetPasswordEmail = ( + accountsServer: AccountsServer +) => async (req: express.Request, res: express.Response) => { + try { + const { email } = req.body; + const password: any = accountsServer.getServices().password; + await password.sendResetPasswordEmail(email); + res.json({ message: 'Email sent' }); + } catch (err) { + sendError(res, err); + } +}; diff --git a/packages/rest-express/src/endpoints/password/verify-email.ts b/packages/rest-express/src/endpoints/password/verify-email.ts new file mode 100644 index 000000000..bbd162406 --- /dev/null +++ b/packages/rest-express/src/endpoints/password/verify-email.ts @@ -0,0 +1,31 @@ +import * as express from 'express'; +import { AccountsServer } from '@accounts/server'; +import { sendError } from '../../utils/send-error'; + +export const verifyEmail = (accountsServer: AccountsServer) => async ( + req: express.Request, + res: express.Response +) => { + try { + const { token } = req.body; + const password: any = accountsServer.getServices().password; + await password.verifyEmail(token); + res.json({ message: 'Email verified' }); + } catch (err) { + sendError(res, err); + } +}; + +export const sendVerificationEmail = (accountsServer: AccountsServer) => async ( + req: express.Request, + res: express.Response +) => { + try { + const { email } = req.body; + const password: any = accountsServer.getServices().password; + await password.sendVerificationEmail(email); + res.json({ message: 'Email sent' }); + } catch (err) { + sendError(res, err); + } +}; diff --git a/packages/rest-express/src/endpoints/refresh-access-token.ts b/packages/rest-express/src/endpoints/refresh-access-token.ts new file mode 100644 index 000000000..0e2f73803 --- /dev/null +++ b/packages/rest-express/src/endpoints/refresh-access-token.ts @@ -0,0 +1,25 @@ +import * as express from 'express'; +import * as requestIp from 'request-ip'; +import { AccountsServer } from '@accounts/server'; +import { getUserAgent } from '../utils/get-user-agent'; +import { sendError } from '../utils/send-error'; + +export const refreshAccessToken = (accountsServer: AccountsServer) => async ( + req: express.Request, + res: express.Response +) => { + try { + const { accessToken, refreshToken } = req.body; + const userAgent = getUserAgent(req); + const ip = requestIp.getClientIp(req); + const refreshedSession = await accountsServer.refreshTokens( + accessToken, + refreshToken, + ip, + userAgent + ); + res.json(refreshedSession); + } catch (err) { + sendError(res, err); + } +}; diff --git a/packages/rest-express/src/endpoints/service-authenticate.ts b/packages/rest-express/src/endpoints/service-authenticate.ts new file mode 100644 index 000000000..abc1bee57 --- /dev/null +++ b/packages/rest-express/src/endpoints/service-authenticate.ts @@ -0,0 +1,24 @@ +import * as express from 'express'; +import * as requestIp from 'request-ip'; +import { AccountsServer } from '@accounts/server'; +import { getUserAgent } from '../utils/get-user-agent'; +import { sendError } from '../utils/send-error'; + +export const serviceAuthenticate = (accountsServer: AccountsServer) => async ( + req: express.Request, + res: express.Response +) => { + try { + const serviceName = req.params.service; + const userAgent = getUserAgent(req); + const ip = requestIp.getClientIp(req); + const loggedInUser = await accountsServer.loginWithService( + serviceName, + req.body, + { ip, userAgent } + ); + res.json(loggedInUser); + } catch (err) { + sendError(res, err); + } +}; diff --git a/packages/rest-express/src/express-middleware.ts b/packages/rest-express/src/express-middleware.ts new file mode 100644 index 000000000..a11728179 --- /dev/null +++ b/packages/rest-express/src/express-middleware.ts @@ -0,0 +1,88 @@ +import { providerCallback } from './endpoints/oauth/provider-callback'; +import { + resetPassword, + sendResetPasswordEmail, +} from './endpoints/password/reset'; +import { + verifyEmail, + sendVerificationEmail, +} from './endpoints/password/verify-email'; +import * as express from 'express'; +import { get, isEmpty, pick } from 'lodash'; +import * as requestIp from 'request-ip'; +import { AccountsError } from '@accounts/common'; +import { AccountsServer } from '@accounts/server'; +import { refreshAccessToken } from './endpoints/refresh-access-token'; +import { getUser } from './endpoints/get-user'; +import { impersonate } from './endpoints/impersonate'; +import { logout } from './endpoints/logout'; +import { serviceAuthenticate } from './endpoints/service-authenticate'; +import { registerPassword } from './endpoints/password/register'; +import { userLoader } from './user-loader'; + +export interface AccountsExpressOptions { + path?: string; +} + +const defaultOptions: AccountsExpressOptions = { + path: '/accounts', +}; + +const accountsExpress = ( + accountsServer: AccountsServer, + options: AccountsExpressOptions = {} +): express.Router => { + options = { ...defaultOptions, ...options }; + const { path } = options; + + const router = express.Router(); + + router.post(`${path}/impersonate`, impersonate(accountsServer)); + + router.post(`${path}/user`, getUser(accountsServer)); + + router.post(`${path}/refreshTokens`, refreshAccessToken(accountsServer)); + + router.post(`${path}/logout`, logout(accountsServer)); + + router.post( + `${path}/:service/authenticate`, + serviceAuthenticate(accountsServer) + ); + + const services = accountsServer.getServices(); + + // @accounts/password + if (services.password) { + router.post(`${path}/password/register`, registerPassword(accountsServer)); + + router.post(`${path}/password/verifyEmail`, verifyEmail(accountsServer)); + + router.post( + `${path}/password/resetPassword`, + resetPassword(accountsServer) + ); + + router.post( + `${path}/password/sendVerificationEmail`, + sendVerificationEmail(accountsServer) + ); + + router.post( + `${path}/password/sendResetPasswordEmail`, + sendResetPasswordEmail(accountsServer) + ); + } + + // @accounts/oauth + if (services.oauth) { + router.get( + `${path}/oauth/:provider/callback`, + providerCallback(accountsServer) + ); + } + + return router; +}; + +export default accountsExpress; diff --git a/packages/rest-express/src/index.ts b/packages/rest-express/src/index.ts new file mode 100644 index 000000000..01980145d --- /dev/null +++ b/packages/rest-express/src/index.ts @@ -0,0 +1,3 @@ +import middleware from './express-middleware'; +export { userLoader } from './user-loader'; +export default middleware; diff --git a/packages/rest-express/src/user-loader.ts b/packages/rest-express/src/user-loader.ts new file mode 100644 index 000000000..09795a843 --- /dev/null +++ b/packages/rest-express/src/user-loader.ts @@ -0,0 +1,23 @@ +import * as express from 'express'; +import { get, isEmpty } from 'lodash'; +import { AccountsServer } from '@accounts/server'; + +export const userLoader = (accountsServer: AccountsServer) => async ( + req: express.Request, + res: express.Response, + next: any +) => { + const accessToken = + get(req.headers, 'accounts-access-token') || + get(req.body, 'accessToken', undefined); + if (!isEmpty(accessToken)) { + try { + const user = await accountsServer.resumeSession(accessToken); + (req as any).user = user; + (req as any).userId = user.id; + } catch (e) { + // Do nothing + } + } + next(); +}; diff --git a/packages/rest-express/src/utils/get-user-agent.ts b/packages/rest-express/src/utils/get-user-agent.ts new file mode 100644 index 000000000..bb59566e9 --- /dev/null +++ b/packages/rest-express/src/utils/get-user-agent.ts @@ -0,0 +1,10 @@ +import * as express from 'express'; + +export const getUserAgent = (req: express.Request) => { + let userAgent: string = (req.headers['user-agent'] as string) || ''; + if (req.headers['x-ucbrowser-ua']) { + // special case of UC Browser + userAgent = req.headers['x-ucbrowser-ua'] as string; + } + return userAgent; +}; diff --git a/packages/rest-express/src/utils/send-error.ts b/packages/rest-express/src/utils/send-error.ts new file mode 100644 index 000000000..36b38bbc9 --- /dev/null +++ b/packages/rest-express/src/utils/send-error.ts @@ -0,0 +1,6 @@ +export const sendError = (res: any, err: any) => + res.status(400).json({ + message: err.message, + loginInfo: err.loginInfo, + errorCode: err.errorCode, + }); diff --git a/packages/rest-express/tsconfig.json b/packages/rest-express/tsconfig.json new file mode 100644 index 000000000..7a3de3c2a --- /dev/null +++ b/packages/rest-express/tsconfig.json @@ -0,0 +1,15 @@ +{ + "extends": "../../tsconfig", + "compilerOptions": { + "rootDir": "./src", + "outDir": "./lib", + "typeRoots": [ + "node_modules/@types" + ] + }, + "exclude": [ + "node_modules", + "__tests__", + "lib" + ] +} diff --git a/packages/rest-express/yarn.lock b/packages/rest-express/yarn.lock new file mode 100644 index 000000000..07322add7 --- /dev/null +++ b/packages/rest-express/yarn.lock @@ -0,0 +1,364 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@types/body-parser@*": + version "1.16.8" + resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.16.8.tgz#687ec34140624a3bec2b1a8ea9268478ae8f3be3" + dependencies: + "@types/express" "*" + "@types/node" "*" + +"@types/events@*": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@types/events/-/events-1.2.0.tgz#81a6731ce4df43619e5c8c945383b3e62a89ea86" + +"@types/express-serve-static-core@*": + version "4.11.1" + resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.11.1.tgz#f6f7212382d59b19d696677bcaa48a37280f5d45" + dependencies: + "@types/events" "*" + "@types/node" "*" + +"@types/express@*", "@types/express@4.11.1": + version "4.11.1" + resolved "https://registry.yarnpkg.com/@types/express/-/express-4.11.1.tgz#f99663b3ab32d04cb11db612ef5dd7933f75465b" + dependencies: + "@types/body-parser" "*" + "@types/express-serve-static-core" "*" + "@types/serve-static" "*" + +"@types/lodash@4.14.104": + version "4.14.104" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.104.tgz#53ee2357fa2e6e68379341d92eb2ecea4b11bb80" + +"@types/mime@*": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@types/mime/-/mime-2.0.0.tgz#5a7306e367c539b9f6543499de8dd519fac37a8b" + +"@types/node@*": + version "9.4.7" + resolved "https://registry.yarnpkg.com/@types/node/-/node-9.4.7.tgz#57d81cd98719df2c9de118f2d5f3b1120dcd7275" + +"@types/request-ip@0.0.33": + version "0.0.33" + resolved "https://registry.yarnpkg.com/@types/request-ip/-/request-ip-0.0.33.tgz#4c4a16f8b27a4ed906470fdac64168bc4de6c295" + dependencies: + "@types/node" "*" + +"@types/serve-static@*": + version "1.13.1" + resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.13.1.tgz#1d2801fa635d274cd97d4ec07e26b21b44127492" + dependencies: + "@types/express-serve-static-core" "*" + "@types/mime" "*" + +accepts@~1.3.4: + version "1.3.4" + resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.4.tgz#86246758c7dd6d21a6474ff084a4740ec05eb21f" + dependencies: + mime-types "~2.1.16" + negotiator "0.6.1" + +array-flatten@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" + +body-parser@1.18.2: + version "1.18.2" + resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.18.2.tgz#87678a19d84b47d859b83199bd59bce222b10454" + dependencies: + bytes "3.0.0" + content-type "~1.0.4" + debug "2.6.9" + depd "~1.1.1" + http-errors "~1.6.2" + iconv-lite "0.4.19" + on-finished "~2.3.0" + qs "6.5.1" + raw-body "2.3.2" + type-is "~1.6.15" + +bytes@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048" + +content-disposition@0.5.2: + version "0.5.2" + resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.2.tgz#0cf68bb9ddf5f2be7961c3a85178cb85dba78cb4" + +content-type@~1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b" + +cookie-signature@1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" + +cookie@0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" + +debug@2.6.9: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + dependencies: + ms "2.0.0" + +depd@1.1.1, depd@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.1.tgz#5783b4e1c459f06fa5ca27f991f3d06e7a310359" + +destroy@~1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80" + +ee-first@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" + +encodeurl@~1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.1.tgz#79e3d58655346909fe6f0f45a5de68103b294d20" + +escape-html@~1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" + +etag@~1.8.1: + version "1.8.1" + resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" + +express@^4.16.2: + version "4.16.2" + resolved "https://registry.yarnpkg.com/express/-/express-4.16.2.tgz#e35c6dfe2d64b7dca0a5cd4f21781be3299e076c" + dependencies: + accepts "~1.3.4" + array-flatten "1.1.1" + body-parser "1.18.2" + content-disposition "0.5.2" + content-type "~1.0.4" + cookie "0.3.1" + cookie-signature "1.0.6" + debug "2.6.9" + depd "~1.1.1" + encodeurl "~1.0.1" + escape-html "~1.0.3" + etag "~1.8.1" + finalhandler "1.1.0" + fresh "0.5.2" + merge-descriptors "1.0.1" + methods "~1.1.2" + on-finished "~2.3.0" + parseurl "~1.3.2" + path-to-regexp "0.1.7" + proxy-addr "~2.0.2" + qs "6.5.1" + range-parser "~1.2.0" + safe-buffer "5.1.1" + send "0.16.1" + serve-static "1.13.1" + setprototypeof "1.1.0" + statuses "~1.3.1" + type-is "~1.6.15" + utils-merge "1.0.1" + vary "~1.1.2" + +finalhandler@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.0.tgz#ce0b6855b45853e791b2fcc680046d88253dd7f5" + dependencies: + debug "2.6.9" + encodeurl "~1.0.1" + escape-html "~1.0.3" + on-finished "~2.3.0" + parseurl "~1.3.2" + statuses "~1.3.1" + unpipe "~1.0.0" + +forwarded@~0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84" + +fresh@0.5.2: + version "0.5.2" + resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" + +http-errors@1.6.2, http-errors@~1.6.2: + version "1.6.2" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.2.tgz#0a002cc85707192a7e7946ceedc11155f60ec736" + dependencies: + depd "1.1.1" + inherits "2.0.3" + setprototypeof "1.0.3" + statuses ">= 1.3.1 < 2" + +iconv-lite@0.4.19: + version "0.4.19" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" + +inherits@2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + +ipaddr.js@1.5.2: + version "1.5.2" + resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.5.2.tgz#d4b505bde9946987ccf0fc58d9010ff9607e3fa0" + +is_js@^0.9.0: + version "0.9.0" + resolved "https://registry.yarnpkg.com/is_js/-/is_js-0.9.0.tgz#0ab94540502ba7afa24c856aa985561669e9c52d" + +lodash@^4.17.4: + version "4.17.4" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" + +media-typer@0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" + +merge-descriptors@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" + +methods@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" + +mime-db@~1.27.0: + version "1.27.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.27.0.tgz#820f572296bbd20ec25ed55e5b5de869e5436eb1" + +mime-db@~1.30.0: + version "1.30.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.30.0.tgz#74c643da2dd9d6a45399963465b26d5ca7d71f01" + +mime-types@~2.1.15: + version "2.1.15" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.15.tgz#a4ebf5064094569237b8cf70046776d09fc92aed" + dependencies: + mime-db "~1.27.0" + +mime-types@~2.1.16: + version "2.1.17" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.17.tgz#09d7a393f03e995a79f8af857b70a9e0ab16557a" + dependencies: + mime-db "~1.30.0" + +mime@1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/mime/-/mime-1.4.1.tgz#121f9ebc49e3766f311a76e1fa1c8003c4b03aa6" + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + +negotiator@0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9" + +on-finished@~2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" + dependencies: + ee-first "1.1.1" + +parseurl@~1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.2.tgz#fc289d4ed8993119460c156253262cdc8de65bf3" + +path-to-regexp@0.1.7: + version "0.1.7" + resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" + +proxy-addr@~2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.2.tgz#6571504f47bb988ec8180253f85dd7e14952bdec" + dependencies: + forwarded "~0.1.2" + ipaddr.js "1.5.2" + +qs@6.5.1: + version "6.5.1" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" + +range-parser@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e" + +raw-body@2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.3.2.tgz#bcd60c77d3eb93cde0050295c3f379389bc88f89" + dependencies: + bytes "3.0.0" + http-errors "1.6.2" + iconv-lite "0.4.19" + unpipe "1.0.0" + +request-ip@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/request-ip/-/request-ip-2.0.2.tgz#deeae6d4af21768497db8cd05fa37143f8f1257e" + dependencies: + is_js "^0.9.0" + +safe-buffer@5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" + +send@0.16.1: + version "0.16.1" + resolved "https://registry.yarnpkg.com/send/-/send-0.16.1.tgz#a70e1ca21d1382c11d0d9f6231deb281080d7ab3" + dependencies: + debug "2.6.9" + depd "~1.1.1" + destroy "~1.0.4" + encodeurl "~1.0.1" + escape-html "~1.0.3" + etag "~1.8.1" + fresh "0.5.2" + http-errors "~1.6.2" + mime "1.4.1" + ms "2.0.0" + on-finished "~2.3.0" + range-parser "~1.2.0" + statuses "~1.3.1" + +serve-static@1.13.1: + version "1.13.1" + resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.13.1.tgz#4c57d53404a761d8f2e7c1e8a18a47dbf278a719" + dependencies: + encodeurl "~1.0.1" + escape-html "~1.0.3" + parseurl "~1.3.2" + send "0.16.1" + +setprototypeof@1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.0.3.tgz#66567e37043eeb4f04d91bd658c0cbefb55b8e04" + +setprototypeof@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.0.tgz#d0bd85536887b6fe7c0d818cb962d9d91c54e656" + +"statuses@>= 1.3.1 < 2", statuses@~1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.3.1.tgz#faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e" + +type-is@~1.6.15: + version "1.6.15" + resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.15.tgz#cab10fb4909e441c82842eafe1ad646c81804410" + dependencies: + media-typer "0.3.0" + mime-types "~2.1.15" + +unpipe@1.0.0, unpipe@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" + +utils-merge@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" + +vary@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" diff --git a/packages/server/__tests__/__snapshots__/accounts-server.ts.snap b/packages/server/__tests__/__snapshots__/account-server.ts.snap similarity index 100% rename from packages/server/__tests__/__snapshots__/accounts-server.ts.snap rename to packages/server/__tests__/__snapshots__/account-server.ts.snap diff --git a/packages/server/__tests__/accounts-server.ts b/packages/server/__tests__/account-server.ts similarity index 99% rename from packages/server/__tests__/accounts-server.ts rename to packages/server/__tests__/account-server.ts index f46d3c059..fc41ddf1d 100644 --- a/packages/server/__tests__/accounts-server.ts +++ b/packages/server/__tests__/account-server.ts @@ -1,10 +1,11 @@ import * as jwtDecode from 'jwt-decode'; -import { AccountsServer, JwtData } from '../src/accounts-server'; +import { AccountsServer } from '../src/accounts-server'; +import { JwtData } from '../src/types/jwt-data'; import { bcryptPassword, hashPassword, verifyPassword, -} from '../src/encryption'; +} from '../src/utils/encryption'; describe('AccountsServer', () => { const db = { diff --git a/packages/server/__tests__/__snapshots__/email.ts.snap b/packages/server/__tests__/utils/__snapshots__/email.ts.snap similarity index 100% rename from packages/server/__tests__/__snapshots__/email.ts.snap rename to packages/server/__tests__/utils/__snapshots__/email.ts.snap diff --git a/packages/server/__tests__/email.ts b/packages/server/__tests__/utils/email.ts similarity index 92% rename from packages/server/__tests__/email.ts rename to packages/server/__tests__/utils/email.ts index a9d8957de..344609535 100644 --- a/packages/server/__tests__/email.ts +++ b/packages/server/__tests__/utils/email.ts @@ -1,4 +1,4 @@ -import { emailTemplates } from '../src/email'; +import { emailTemplates } from '../../src/utils/email'; describe('email', () => { describe('emailTemplates', () => { diff --git a/packages/server/__tests__/encryption.ts b/packages/server/__tests__/utils/encryption.ts similarity index 96% rename from packages/server/__tests__/encryption.ts rename to packages/server/__tests__/utils/encryption.ts index 3143fc60a..c469fcd14 100644 --- a/packages/server/__tests__/encryption.ts +++ b/packages/server/__tests__/utils/encryption.ts @@ -2,7 +2,7 @@ import { bcryptPassword, hashPassword, verifyPassword, -} from '../src/encryption'; +} from '../../src/utils/encryption'; describe('bcryptPassword', () => { it('hashes password using bcrypt', async () => { diff --git a/packages/server/src/accounts-server.ts b/packages/server/src/accounts-server.ts index 37fa56881..13356125f 100644 --- a/packages/server/src/accounts-server.ts +++ b/packages/server/src/accounts-server.ts @@ -16,26 +16,19 @@ import { generateAccessToken, generateRefreshToken, generateRandomToken, -} from './tokens'; -import { emailTemplates, EmailTemplateType, sendMail } from './email'; -import { - AccountsServerOptions, - ConnectionInformationsType, - AuthService, - DBInterface, -} from './types'; - -export interface TokenRecord { - token: string; - address: string; - when: number; - reason: string; -} +} from './utils/tokens'; -export interface JwtData { - token: string; - isImpersonated: boolean; -} +import { emailTemplates, sendMail } from './utils/email'; +import { ServerHooks } from './utils/server-hooks'; + +import { AccountsServerOptions } from './types/accounts-server-options'; +import { ConnectionInformationsType } from './types/connection-informations-type'; +import { AuthService } from './types/auth-service'; +import { DBInterface } from './types/db-interface'; +import { TokenRecord } from './types/token-record'; +import { JwtData } from './types/jwt-data'; +import { RemoveListenerHandle } from './types/remove-listener-handle'; +import { EmailTemplateType } from './types/email-template-type'; const defaultOptions = { tokenSecret: 'secret', @@ -53,23 +46,6 @@ const defaultOptions = { siteUrl: 'http://localhost:3000', }; -export type RemoveListnerHandle = () => EventEmitter; - -export const ServerHooks = { - LoginSuccess: 'LoginSuccess', - LoginError: 'LoginError', - LogoutSuccess: 'LogoutSuccess', - LogoutError: 'LogoutError', - CreateUserSuccess: 'CreateUserSuccess', - CreateUserError: 'CreateUserError', - ResumeSessionSuccess: 'ResumeSessionSuccess', - ResumeSessionError: 'ResumeSessionError', - RefreshTokensSuccess: 'RefreshTokensSuccess', - RefreshTokensError: 'RefreshTokensError', - ImpersonationSuccess: 'ImpersonationSuccess', - ImpersonationError: 'ImpersonationError', -}; - export class AccountsServer { public options: AccountsServerOptions; private services: { [key: string]: AuthService }; @@ -105,51 +81,51 @@ export class AccountsServer { return this.options; } - public onLoginSuccess(callback: HookListener): RemoveListnerHandle { + public onLoginSuccess(callback: HookListener): RemoveListenerHandle { return this.on(ServerHooks.LoginSuccess, callback); } - public onLoginError(callback: HookListener): RemoveListnerHandle { + public onLoginError(callback: HookListener): RemoveListenerHandle { return this.on(ServerHooks.LoginError, callback); } - public onLogoutSuccess(callback: HookListener): RemoveListnerHandle { + public onLogoutSuccess(callback: HookListener): RemoveListenerHandle { return this.on(ServerHooks.LogoutSuccess, callback); } - public onLogoutError(callback: HookListener): RemoveListnerHandle { + public onLogoutError(callback: HookListener): RemoveListenerHandle { return this.on(ServerHooks.LogoutError, callback); } - public onCreateUserSuccess(callback: HookListener): RemoveListnerHandle { + public onCreateUserSuccess(callback: HookListener): RemoveListenerHandle { return this.on(ServerHooks.CreateUserSuccess, callback); } - public onCreateUserError(callback: HookListener): RemoveListnerHandle { + public onCreateUserError(callback: HookListener): RemoveListenerHandle { return this.on(ServerHooks.CreateUserError, callback); } - public onResumeSessionSuccess(callback: HookListener): RemoveListnerHandle { + public onResumeSessionSuccess(callback: HookListener): RemoveListenerHandle { return this.on(ServerHooks.ResumeSessionSuccess, callback); } - public onResumeSessionError(callback: HookListener): RemoveListnerHandle { + public onResumeSessionError(callback: HookListener): RemoveListenerHandle { return this.on(ServerHooks.ResumeSessionError, callback); } - public onRefreshTokensSuccess(callback: HookListener): RemoveListnerHandle { + public onRefreshTokensSuccess(callback: HookListener): RemoveListenerHandle { return this.on(ServerHooks.RefreshTokensSuccess, callback); } - public onRefreshTokensError(callback: HookListener): RemoveListnerHandle { + public onRefreshTokensError(callback: HookListener): RemoveListenerHandle { return this.on(ServerHooks.RefreshTokensError, callback); } - public onImpersonationSuccess(callback: HookListener): RemoveListnerHandle { + public onImpersonationSuccess(callback: HookListener): RemoveListenerHandle { return this.on(ServerHooks.ImpersonationSuccess, callback); } - public onImpersonationError(callback: HookListener): RemoveListnerHandle { + public onImpersonationError(callback: HookListener): RemoveListenerHandle { return this.on(ServerHooks.ImpersonationError, callback); } @@ -542,7 +518,7 @@ export class AccountsServer { return this.db.setProfile(userId, { ...user.profile, ...profile }); } - public on(eventName: string, callback: HookListener): RemoveListnerHandle { + public on(eventName: string, callback: HookListener): RemoveListenerHandle { this.hooks.on(eventName, callback); return () => this.hooks.removeListener(eventName, callback); diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index aaaa1073c..492a03f1f 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -1,7 +1,11 @@ import { AccountsServer } from './accounts-server'; -import * as encryption from './encryption'; -import { generateRandomToken } from './tokens'; -import { AuthService, DBInterface, ConnectionInformationsType } from './types'; +import * as encryption from './utils/encryption'; +import { generateRandomToken } from './utils/tokens'; +import { getFirstUserEmail } from './utils/get-first-user-email'; + +import { ConnectionInformationsType } from './types/connection-informations-type'; +import { AuthService } from './types/auth-service'; +import { DBInterface } from './types/db-interface'; export default AccountsServer; export { @@ -11,4 +15,5 @@ export { DBInterface, generateRandomToken, ConnectionInformationsType, + getFirstUserEmail, }; diff --git a/packages/server/src/types/accounts-server-options.ts b/packages/server/src/types/accounts-server-options.ts new file mode 100644 index 000000000..62ed3024a --- /dev/null +++ b/packages/server/src/types/accounts-server-options.ts @@ -0,0 +1,34 @@ +import { UserObjectType } from '@accounts/common'; +import { DBInterface } from './db-interface'; +import { EmailTemplateType } from './email-template-type'; +import { EmailTemplatesType } from './email-templates-type'; +import { UserObjectSanitizerFunction } from './user-object-sanitizer-function'; +import { ResumeSessionValidator } from './resume-session-validator'; +import { PrepareMailFunction } from './prepare-mail-function'; +import { SendMailType } from './send-mail-type'; + +export interface AccountsServerOptions { + db: DBInterface; + tokenSecret: string; + tokenConfigs?: { + accessToken?: { + expiresIn?: string; + }; + refreshToken?: { + expiresIn?: string; + }; + }; + emailTokensExpiry?: number; + emailTemplates?: EmailTemplatesType; + userObjectSanitizer?: UserObjectSanitizerFunction; + impersonationAuthorize?: ( + user: UserObjectType, + impersonateToUser: UserObjectType + ) => Promise; + resumeSessionValidator?: ResumeSessionValidator; + siteUrl?: string; + prepareMail?: PrepareMailFunction; + sendMail?: SendMailType; + // https://github.com/eleith/emailjs#emailserverconnectoptions + email?: object; +} diff --git a/packages/server/src/types/auth-service.ts b/packages/server/src/types/auth-service.ts new file mode 100644 index 000000000..e3c8f769d --- /dev/null +++ b/packages/server/src/types/auth-service.ts @@ -0,0 +1,11 @@ +import { UserObjectType } from '@accounts/common'; +import { DBInterface } from './db-interface'; + +import { AccountsServer } from '../accounts-server'; + +export interface AuthService { + server: AccountsServer; + serviceName: string; + setStore(store: DBInterface): void; + authenticate(params: any): Promise; +} diff --git a/packages/server/src/types/connection-informations-type.ts b/packages/server/src/types/connection-informations-type.ts new file mode 100644 index 000000000..e563525d6 --- /dev/null +++ b/packages/server/src/types/connection-informations-type.ts @@ -0,0 +1,4 @@ +export interface ConnectionInformationsType { + ip?: string; + userAgent?: string; +} diff --git a/packages/server/src/types.ts b/packages/server/src/types/db-interface.ts similarity index 55% rename from packages/server/src/types.ts rename to packages/server/src/types/db-interface.ts index e6f308c01..f4e7ab8e1 100644 --- a/packages/server/src/types.ts +++ b/packages/server/src/types/db-interface.ts @@ -1,66 +1,5 @@ -import { UserObjectType, CreateUserType, SessionType } from '@accounts/common'; -import { EmailTemplatesType, EmailTemplateType, SendMailType } from './email'; -import { AccountsServer } from './accounts-server'; - -export interface AuthService { - server: AccountsServer; - serviceName: string; - setStore(store: DBInterface): void; - authenticate(params: any): Promise; -} - -export type UserObjectSanitizerFunction = ( - userObject: UserObjectType, - omitFunction: (userDoc: object, fields: string[]) => UserObjectType, - pickFunction: (userDoc: object, fields: string[]) => UserObjectType -) => any; - -export type ResumeSessionValidator = ( - user: UserObjectType, - session: SessionType -) => Promise; - -export type PrepareMailFunction = ( - to: string, - token: string, - user: UserObjectType, - pathFragment: string, - emailTemplate: EmailTemplateType, - from: string -) => object; - -export type EmailType = EmailTemplateType & { to: string }; - -export interface AccountsServerOptions { - db: DBInterface; - tokenSecret: string; - tokenConfigs?: { - accessToken?: { - expiresIn?: string; - }; - refreshToken?: { - expiresIn?: string; - }; - }; - emailTokensExpiry?: number; - emailTemplates?: EmailTemplatesType; - userObjectSanitizer?: UserObjectSanitizerFunction; - impersonationAuthorize?: ( - user: UserObjectType, - impersonateToUser: UserObjectType - ) => Promise; - resumeSessionValidator?: ResumeSessionValidator; - siteUrl?: string; - prepareMail?: PrepareMailFunction; - sendMail?: SendMailType; - // https://github.com/eleith/emailjs#emailserverconnectoptions - email?: object; -} - -export interface ConnectionInformationsType { - ip?: string; - userAgent?: string; -} +import { UserObjectType, SessionType, CreateUserType } from '@accounts/common'; +import { ConnectionInformationsType } from './connection-informations-type'; export interface DBInterface { // Find user by identity fields diff --git a/packages/server/src/types/email-template-type.ts b/packages/server/src/types/email-template-type.ts new file mode 100644 index 000000000..c8ddfd6d8 --- /dev/null +++ b/packages/server/src/types/email-template-type.ts @@ -0,0 +1,7 @@ +import { UserObjectType } from '@accounts/common'; + +export interface EmailTemplateType { + from?: string; + subject: (user?: UserObjectType) => string; + text: (user: UserObjectType, url: string) => string; +} diff --git a/packages/server/src/types/email-templates-type.ts b/packages/server/src/types/email-templates-type.ts new file mode 100644 index 000000000..2c8f18d6a --- /dev/null +++ b/packages/server/src/types/email-templates-type.ts @@ -0,0 +1,8 @@ +import { EmailTemplateType } from './email-template-type'; + +export interface EmailTemplatesType { + from: string; + verifyEmail: EmailTemplateType; + resetPassword: EmailTemplateType; + enrollAccount: EmailTemplateType; +} diff --git a/packages/server/src/types/email-type.ts b/packages/server/src/types/email-type.ts new file mode 100644 index 000000000..b561ea33f --- /dev/null +++ b/packages/server/src/types/email-type.ts @@ -0,0 +1,3 @@ +import { EmailTemplateType } from './email-template-type'; + +export type EmailType = EmailTemplateType & { to: string }; diff --git a/packages/server/src/types/jwt-data.ts b/packages/server/src/types/jwt-data.ts new file mode 100644 index 000000000..c637c04ef --- /dev/null +++ b/packages/server/src/types/jwt-data.ts @@ -0,0 +1,4 @@ +export interface JwtData { + token: string; + isImpersonated: boolean; +} diff --git a/packages/server/src/types/prepare-mail-function.ts b/packages/server/src/types/prepare-mail-function.ts new file mode 100644 index 000000000..f79be4927 --- /dev/null +++ b/packages/server/src/types/prepare-mail-function.ts @@ -0,0 +1,11 @@ +import { UserObjectType } from '@accounts/common'; +import { EmailTemplateType } from './email-template-type'; + +export type PrepareMailFunction = ( + to: string, + token: string, + user: UserObjectType, + pathFragment: string, + emailTemplate: EmailTemplateType, + from: string +) => object; diff --git a/packages/server/src/types/remove-listener-handle.ts b/packages/server/src/types/remove-listener-handle.ts new file mode 100644 index 000000000..1368bb771 --- /dev/null +++ b/packages/server/src/types/remove-listener-handle.ts @@ -0,0 +1,2 @@ +import { EventEmitter } from 'events'; +export type RemoveListenerHandle = () => EventEmitter; diff --git a/packages/server/src/types/resume-session-validator.ts b/packages/server/src/types/resume-session-validator.ts new file mode 100644 index 000000000..1ca60cee4 --- /dev/null +++ b/packages/server/src/types/resume-session-validator.ts @@ -0,0 +1,6 @@ +import { UserObjectType, SessionType } from '@accounts/common'; + +export type ResumeSessionValidator = ( + user: UserObjectType, + session: SessionType +) => Promise; diff --git a/packages/server/src/types/send-mail-type.ts b/packages/server/src/types/send-mail-type.ts new file mode 100644 index 000000000..a08d843f7 --- /dev/null +++ b/packages/server/src/types/send-mail-type.ts @@ -0,0 +1 @@ +export type SendMailType = (mail: object) => Promise; diff --git a/packages/server/src/types/token-record.ts b/packages/server/src/types/token-record.ts new file mode 100644 index 000000000..3df3ef3f6 --- /dev/null +++ b/packages/server/src/types/token-record.ts @@ -0,0 +1,6 @@ +export interface TokenRecord { + token: string; + address: string; + when: number; + reason: string; +} diff --git a/packages/server/src/types/user-object-sanitizer-function.ts b/packages/server/src/types/user-object-sanitizer-function.ts new file mode 100644 index 000000000..14924489a --- /dev/null +++ b/packages/server/src/types/user-object-sanitizer-function.ts @@ -0,0 +1,7 @@ +import { UserObjectType } from '@accounts/common'; + +export type UserObjectSanitizerFunction = ( + userObject: UserObjectType, + omitFunction: (userDoc: object, fields: string[]) => UserObjectType, + pickFunction: (userDoc: object, fields: string[]) => UserObjectType +) => any; diff --git a/packages/server/src/email.ts b/packages/server/src/utils/email.ts similarity index 75% rename from packages/server/src/email.ts rename to packages/server/src/utils/email.ts index aa6764439..573fedd31 100644 --- a/packages/server/src/email.ts +++ b/packages/server/src/utils/email.ts @@ -1,17 +1,6 @@ import { UserObjectType } from '@accounts/common'; - -export interface EmailTemplateType { - from?: string; - subject: (user?: UserObjectType) => string; - text: (user: UserObjectType, url: string) => string; -} - -export interface EmailTemplatesType { - from: string; - verifyEmail: EmailTemplateType; - resetPassword: EmailTemplateType; - enrollAccount: EmailTemplateType; -} +import { EmailTemplateType } from '../types/email-template-type'; +import { EmailTemplatesType } from '../types/email-templates-type'; export const emailTemplates = { from: 'js-accounts ', diff --git a/packages/server/src/encryption.ts b/packages/server/src/utils/encryption.ts similarity index 100% rename from packages/server/src/encryption.ts rename to packages/server/src/utils/encryption.ts diff --git a/packages/server/src/utils.ts b/packages/server/src/utils/get-first-user-email.ts similarity index 100% rename from packages/server/src/utils.ts rename to packages/server/src/utils/get-first-user-email.ts diff --git a/packages/server/src/utils/server-hooks.ts b/packages/server/src/utils/server-hooks.ts new file mode 100644 index 000000000..f9d1b5e37 --- /dev/null +++ b/packages/server/src/utils/server-hooks.ts @@ -0,0 +1,14 @@ +export const ServerHooks = { + LoginSuccess: 'LoginSuccess', + LoginError: 'LoginError', + LogoutSuccess: 'LogoutSuccess', + LogoutError: 'LogoutError', + CreateUserSuccess: 'CreateUserSuccess', + CreateUserError: 'CreateUserError', + ResumeSessionSuccess: 'ResumeSessionSuccess', + ResumeSessionError: 'ResumeSessionError', + RefreshTokensSuccess: 'RefreshTokensSuccess', + RefreshTokensError: 'RefreshTokensError', + ImpersonationSuccess: 'ImpersonationSuccess', + ImpersonationError: 'ImpersonationError', +}; diff --git a/packages/server/src/tokens.ts b/packages/server/src/utils/tokens.ts similarity index 100% rename from packages/server/src/tokens.ts rename to packages/server/src/utils/tokens.ts diff --git a/tsconfig.json b/tsconfig.json index fe38d4bc4..a0c280f20 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,7 @@ "removeComments": true, "lib": ["es6", "es2015", "es2016", "es2017"], "types": [ - "@types/node" + "node" ] } } diff --git a/tslint.json b/tslint.json index 785fd5f61..7befafb1d 100644 --- a/tslint.json +++ b/tslint.json @@ -3,6 +3,7 @@ "@accounts/tslint-config-accounts" ], "rules": { - "no-submodule-imports": [true, "lodash", "@accounts/server"] + "no-submodule-imports": [true, "lodash", "@accounts/server"], + "no-implicit-dependencies": [true, "dev"] } } diff --git a/yarn.lock b/yarn.lock index 83b11189c..0c631f446 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,9 +2,9 @@ # yarn lockfile v1 -"@accounts/tslint-config-accounts@0.0.6": - version "0.0.6" - resolved "https://registry.yarnpkg.com/@accounts/tslint-config-accounts/-/tslint-config-accounts-0.0.6.tgz#d2ab1480f0aff7c911b2bea9fb924d7f04328931" +"@accounts/tslint-config-accounts@0.0.9": + version "0.0.9" + resolved "https://registry.yarnpkg.com/@accounts/tslint-config-accounts/-/tslint-config-accounts-0.0.9.tgz#a2073361c4127ba7c8662cd72e08a28a794a44df" dependencies: tslint-config-prettier "^1.1.0" tslint-eslint-rules "^4.1.1"