├── lib ├── errors.js ├── commands │ ├── index.js │ ├── balance-command.js │ └── send-command.js ├── senders │ ├── sender.js │ ├── mock-sender.js │ └── twilio-sender.js ├── receivers │ ├── receiver.js │ ├── mock-receiver.js │ └── twilio-receiver.js ├── initializers │ ├── heroku.js │ ├── horizon.js │ └── sms.js ├── message.js ├── app.js ├── controllers │ ├── middlewares │ │ └── raw-body.js │ └── receive.js └── command-parser.js ├── .gitignore ├── Procfile ├── config ├── development.json └── all-envs.json ├── scripts └── command.js ├── package.json ├── CONTRIBUTING.md ├── README.md └── LICENSE.txt /lib/errors.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /pid-* 3 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: ./node_modules/.bin/stex www 2 | -------------------------------------------------------------------------------- /lib/commands/index.js: -------------------------------------------------------------------------------- 1 | export * from './balance-command'; 2 | export * from './send-command'; 3 | -------------------------------------------------------------------------------- /config/development.json: -------------------------------------------------------------------------------- 1 | { 2 | "testAccountSeed": "SAYF5SICVFWFA3AGE4QVJY5P5W7FTKLNQXZRZ6IZCFVUPQUKFRBN7RTB" 3 | } 4 | -------------------------------------------------------------------------------- /lib/senders/sender.js: -------------------------------------------------------------------------------- 1 | export default class Sender { 2 | constructor() {} 3 | 4 | send(to, message) { 5 | throw new Error('This class is abstract.'); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /lib/receivers/receiver.js: -------------------------------------------------------------------------------- 1 | export default class Receiver { 2 | constructor() {} 3 | 4 | parse(rawMessage) { 5 | throw new Error('This class is abstract.'); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /lib/initializers/heroku.js: -------------------------------------------------------------------------------- 1 | import Stex from "stex"; 2 | import Initializer from "stex/lib/initializer"; 3 | 4 | Initializer.add('startup', 'heroku', ['stex.config'], function(stex) { 5 | stex.conf.set('PORT', process.env.PORT || 5000); 6 | }); 7 | -------------------------------------------------------------------------------- /lib/message.js: -------------------------------------------------------------------------------- 1 | export default class Message { 2 | constructor(from, data) { 3 | this._from = from; 4 | this._data = data; 5 | } 6 | 7 | get from() { 8 | return this._from; 9 | } 10 | 11 | get data() { 12 | return this._data; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/initializers/horizon.js: -------------------------------------------------------------------------------- 1 | import Stex from "stex"; 2 | import Initializer from "stex/lib/initializer"; 3 | import {Server} from 'stellar-sdk'; 4 | 5 | Initializer.add('startup', 'horizon', ['stex.config'], function(stex) { 6 | stex.horizon = new Server(stex.conf.get('horizon')); 7 | }); 8 | -------------------------------------------------------------------------------- /lib/receivers/mock-receiver.js: -------------------------------------------------------------------------------- 1 | import {Promise} from 'stex'; 2 | import Message from '../message' 3 | import Receiver from './receiver'; 4 | 5 | export default class MockReceiver extends Receiver { 6 | parse(rawMessage) { 7 | return new Message('+10000000000', rawMessage); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /lib/senders/mock-sender.js: -------------------------------------------------------------------------------- 1 | import {Promise} from 'stex'; 2 | import Sender from './sender'; 3 | 4 | export default class MockSender extends Sender { 5 | sendMessage(to, body) { 6 | return new Promise(resolve => { 7 | console.log(`Sent message: "${body}" to: ${to}`); 8 | resolve(); 9 | }); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /lib/app.js: -------------------------------------------------------------------------------- 1 | require("babel/register"); 2 | var Stex = require('stex'); 3 | 4 | module.exports = Stex.new(__dirname + "/..", function(stex) { 5 | var router = stex.router; 6 | var controllers = stex.controllers; 7 | 8 | app.use(controllers.middlewares.rawBody); 9 | 10 | router.post('/receive', controllers.receive); 11 | }); 12 | -------------------------------------------------------------------------------- /lib/controllers/middlewares/raw-body.js: -------------------------------------------------------------------------------- 1 | var getRawBody = require('raw-body'); 2 | 3 | module.exports = (req, res, next) => { 4 | getRawBody(req, { 5 | length: req.headers['content-length'], 6 | limit: '1mb' 7 | }, function (err, buffer) { 8 | if (err) return next(err); 9 | req.rawBody = buffer.toString(); 10 | next(); 11 | }) 12 | }; 13 | -------------------------------------------------------------------------------- /scripts/command.js: -------------------------------------------------------------------------------- 1 | import Stex, {Promise} from 'stex'; 2 | import CommandParser from '../lib/command-parser'; 3 | 4 | if (!process.argv[4]) { 5 | console.log('Usage: stex run command [command]'); 6 | process.exit(); 7 | } 8 | 9 | let commandText = process.argv.slice(4).join(' '); 10 | let message = stex.sms.receiver.parse(commandText); 11 | let command = CommandParser.parse(message); 12 | command.run(); 13 | -------------------------------------------------------------------------------- /lib/receivers/twilio-receiver.js: -------------------------------------------------------------------------------- 1 | import {Promise} from 'stex'; 2 | import Message from '../message' 3 | import Receiver from './receiver'; 4 | import Twilio from 'twilio'; 5 | import querystring from 'querystring'; 6 | 7 | export default class TwilioReceiver extends Receiver { 8 | parse(rawMessage) { 9 | var data = querystring.parse(rawMessage); 10 | return new Message(data.From, data.Body); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/controllers/receive.js: -------------------------------------------------------------------------------- 1 | import CommandParser from '../command-parser'; 2 | 3 | export default function(req, res, next) { 4 | let message = stex.sms.receiver.parse(req.rawBody); 5 | let command = CommandParser.parse(message); 6 | command.run(); 7 | 8 | // Return empty response for Twilio. We could send a message using 9 | // TwiML but we want to separate `sender` and `receiver`. 10 | res.status(200).send(''); 11 | }; 12 | -------------------------------------------------------------------------------- /lib/initializers/sms.js: -------------------------------------------------------------------------------- 1 | import Stex from "stex"; 2 | import Initializer from "stex/lib/initializer"; 3 | 4 | Initializer.add('startup', 'sms', ['stex.config'], function(stex) { 5 | let smsConfig = stex.conf.get('sms'); 6 | let Sender = require(`../senders/${smsConfig.sender.name}-sender`); 7 | let Receiver = require(`../receivers/${smsConfig.receiver.name}-receiver`); 8 | 9 | stex.sms = { 10 | sender: new Sender(smsConfig.sender), 11 | receiver: new Receiver(smsConfig.receiver) 12 | }; 13 | }); 14 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "stellar-sms-client", 3 | "version": "0.0.1", 4 | "private": true, 5 | "engines": { 6 | "node": "0.10.x" 7 | }, 8 | "dependencies": { 9 | "babel": "^5.4.7", 10 | "bookshelf": "git+https://github.com/bartekn/bookshelf.git#master", 11 | "lodash": "^3.9.3", 12 | "moment": "2.9.0", 13 | "raw-body": "^2.1.0", 14 | "stex": "git+https://github.com/stellar/stex.git#master", 15 | "stellar-sdk": "^0.4.1", 16 | "superagent": "^1.2.0", 17 | "twilio": "^2.2.1" 18 | }, 19 | "devDependencies": { 20 | "gulp": "^3.8.5" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/command-parser.js: -------------------------------------------------------------------------------- 1 | import {SendCommand, BalanceCommand} from './commands'; 2 | 3 | export default class CommandParser { 4 | static parse(message) { 5 | let from = message.from; 6 | let data = message.data.split(' '); 7 | let [command] = data; 8 | 9 | switch (command) { 10 | case 'send': 11 | let [,to,amount] = data; 12 | return new SendCommand(from, to, amount); 13 | break; 14 | case 'balance': 15 | return new BalanceCommand(from); 16 | break; 17 | default: 18 | throw new Error('Unknown command'); 19 | break; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /config/all-envs.json: -------------------------------------------------------------------------------- 1 | { 2 | "logLevel": "info", 3 | "logTarget": "humanizer", 4 | "db" : { 5 | "client" : "mysql", 6 | "connection": { 7 | "user" : "root", 8 | "database" : "stellar-sms_development" 9 | } 10 | }, 11 | "horizon": { 12 | "secure": true, 13 | "hostname": "horizon-testnet.stellar.org", 14 | "port": 443 15 | }, 16 | "sms": { 17 | "sender": { 18 | "name": "twilio", 19 | "accountSID": "", 20 | "authToken": "", 21 | "number": "" 22 | }, 23 | "receiver": { 24 | "name": "twilio", 25 | "accountSID": "", 26 | "authToken": "" 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/senders/twilio-sender.js: -------------------------------------------------------------------------------- 1 | import {Promise} from 'stex'; 2 | import Sender from './sender'; 3 | import Twilio from 'twilio'; 4 | 5 | export default class TwilioSender extends Sender { 6 | constructor(data) { 7 | super(data); 8 | this.twilio = new Twilio.RestClient(data.accountSID, data.authToken); 9 | this.fromNumber = data.number; 10 | } 11 | 12 | sendMessage(to, body) { 13 | return new Promise((resolve, reject) => { 14 | let from = this.fromNumber; 15 | this.twilio.sendMessage({to, from, body}) 16 | .then(response => { 17 | resolve(response); 18 | }).fail(error => { 19 | reject(error); 20 | }); 21 | }); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/commands/balance-command.js: -------------------------------------------------------------------------------- 1 | import {Account, Currency, Keypair, Operation, TransactionBuilder} from 'stellar-sdk'; 2 | import {isArray, forEach} from 'lodash'; 3 | 4 | export class BalanceCommand { 5 | constructor(from) { 6 | this._from = from; 7 | } 8 | 9 | run() { 10 | let keypair = Keypair.fromSeed(stex.conf.get('testAccountSeed')); 11 | 12 | stex.horizon.accounts().accountId(keypair.accountId()) 13 | .call() 14 | .then(account => { 15 | let response = "Balances: "; 16 | 17 | if (!(isArray(account.balances) && account.balances.length > 0)) { 18 | account.balances = [{balance: 0, asset_code: 'XLM'}]; 19 | } 20 | 21 | forEach(account.balances, asset => { 22 | if (asset.asset_type === 'native') { 23 | response += `XLM: ${asset.balance} `; 24 | } else { 25 | response += `${asset.asset_code}: ${asset.balance} `; 26 | } 27 | }); 28 | 29 | stex.sms.sender.sendMessage(this._from, response.trim()); 30 | }) 31 | .catch(e => { 32 | stex.sms.sender.sendMessage(this._from, "Error getting account info."); 33 | }); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/commands/send-command.js: -------------------------------------------------------------------------------- 1 | import {Account, Asset, Keypair, Operation, TransactionBuilder} from 'stellar-sdk'; 2 | import request from 'superagent'; 3 | 4 | export class SendCommand { 5 | constructor(from, to, amount) { 6 | this._from = from; 7 | this._to = to; 8 | this._amount = amount; 9 | } 10 | 11 | run() { 12 | let keypair = Keypair.fromSeed(stex.conf.get('testAccountSeed')); 13 | let destinationAddress = ''; 14 | 15 | request 16 | .get(`https://api.stellar.org/federation?destination=${this._to}&domain=stellar.org`) 17 | .type('json') 18 | .send() 19 | .end((err, res) => { 20 | stex.horizon.loadAccount(keypair.accountId()) 21 | .then(account => { 22 | console.log('Account loaded.'); 23 | let asset = Asset.native(); 24 | let amount = this._amount; 25 | let transaction = new TransactionBuilder(account) 26 | .addOperation(Operation.payment({ 27 | destination: res.body.federation_json.destination_new_address, 28 | asset: asset, 29 | amount: amount 30 | })) 31 | .build(); 32 | 33 | transaction.sign(keypair); 34 | 35 | stex.horizon.submitTransaction(transaction) 36 | .then(transactionResult => { 37 | console.log(transactionResult); 38 | stex.sms.sender.sendMessage(this._from, 'Transaction sent!'); 39 | }) 40 | .catch(e => { 41 | console.error(e); 42 | stex.sms.sender.sendMessage(this._from, 'Error sending transaction!'); 43 | }); 44 | }); 45 | }); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | Your contributions to the Stellar network will help improve the world’s financial 4 | infrastructure, faster. 5 | 6 | We want to make it as easy as possible to contribute changes that 7 | help the Stellar network grow and thrive. There are a few guidelines that we 8 | ask contributors to follow so that we can merge your changes quickly. 9 | 10 | ## Getting Started 11 | 12 | * Create a GitHub issue for your contribution, assuming one does not already exist. 13 | * Clearly describe the issue including steps to reproduce if it is a bug. 14 | * Fork the repository on GitHub 15 | 16 | ## Making Changes 17 | 18 | * Create a topic branch from where you want to base your work. 19 | * This is usually the master branch. 20 | * Please avoid working directly on the `master` branch. 21 | * Make sure you have added the necessary tests for your changes, and make sure all tests pass. 22 | 23 | ## Submitting Changes 24 | 25 | * Sign the Contributor License Agreement. 26 | * All content, comments, and pull requests must follow the [Stellar Community Guidelines](https://www.stellar.org/community-guidelines/). 27 | * Push your changes to a topic branch in your fork of the repository. 28 | * Submit a pull request to the [stellar-sms-client repository](https://github.com/stellar/stellar-sms-client) in the Stellar organization. 29 | * Include a descriptive [commit message](https://github.com/erlang/otp/wiki/Writing-good-commit-messages). 30 | * Changes contributed via pull request should focus on a single issue at a time. 31 | * Rebase your local changes against the master branch. Resolve any conflicts that arise. 32 | 33 | At this point you're waiting on us. We like to at least comment on pull requests within three 34 | business days (and, typically, one business day). We may suggest some changes or improvements or alternatives. 35 | 36 | ## Making Trivial Changes 37 | 38 | ### Documentation 39 | For changes of a trivial nature to comments and documentation, it is not 40 | always necessary to create a new GitHub issue. In this case, it is 41 | appropriate to start the first line of a commit with 'doc' instead of 42 | an issue number. 43 | 44 | # Additional Resources 45 | 46 | * [Bug tracker (Github)](https://github.com/stellar/stellar-sms-client/issues) 47 | * Contributor License Agreement 48 | * [Explore the API](http://docs.stellarhorizon.apiary.io/) 49 | * [Readme for stellar-sms-client](https://github.com/stellar/stellar-sms-client/blob/master/README.md) 50 | * #stellar-dev IRC channel on freenode.org 51 | * #dev channel on [Slack](http://slack.stellar.org) 52 | 53 | 54 | This document is inspired by: 55 | 56 | https://github.com/puppetlabs/puppet/blob/master/CONTRIBUTING.md 57 | 58 | https://github.com/thoughtbot/factory_girl_rails/blob/master/CONTRIBUTING.md 59 | 60 | https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md 61 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | stellar-sms-client 2 | ================== 3 | 4 | This is a demo of Stellar SMS Client. This project was developed during Stellar Hack Day. **Do not use in production.** 5 | 6 | ## Current functionality 7 | 8 | * Only one account working (configurable by updating app config files). 9 | * After [deploying the app](#testing-using-heroku-and-twilio) you can send a transaction by sending SMS to your Twilio phone numer: `send [federation name] [amount]`. For example: `send joyce 10` will send 10 STR to Joyce. 10 | * If you want to use your **test** account update config. You account must be funded - get some free lumens on [Galaxy](https://www.stellar.org/galaxy/). 11 | 12 | ## Future Usage scenarios 13 | 14 | ### Registration 15 | 16 | This is the idea of usage of this system in production. We don't want users to send their passwords via SMS because of the following reasons: 17 | 18 | * Passwords should be complicated and we don't want users type complicated passwords every time they're sending a payment. 19 | * Mobile devices save sent messages. 20 | * There should be an additional layer of authentication in case of device theft. 21 | * We don't want plain-text passwords to be transmitted via 3rd party networks (GSM/Twilio etc.). 22 | 23 | To meet requirements above we can use a system of one-time passwords. 24 | 25 | 1. User opens a webapp where he/she can login using stellar-wallet login data. 26 | 1. stellar-wallet returns encrypted keychain data to a webapp. 27 | 1. Webap decrypts keychain data in user's browser. 28 | 1. 20 random keys are generated. 29 | 1. Keychain data is encrypted by each of random keys. After encrypting keychain data, each key is SHA-256 hashed. Half of a hash and encrypted data are sent to a server. 30 | 1. User can print/save encryption keys which are now their one-time passwords. 31 | 32 | In a production version users probably should be allowed to opt-out from one-time passwords solution or we should allow users to use 2 wallets: one for every day spendings (does not require passwords), another with savings (one-time passwords required). 33 | 34 | ### Sending a transaction 35 | 36 | 1. Users sends SMS with a transaction recipient (this can be address or federation name) and amount to be sent. 37 | 1. User receives SMS with transaction summary. 38 | 1. If everything is correct user needs to send one of one-time passwords (or a specific one, ex. 3rd.) to confirm a transaction. 39 | 1. Server calculates a SHA-256 hash and finds encrypted data in a database. Then decrypts keychain data, signs and submits a transaction. Used one-time password is removed from a database. 40 | 1. Server sends SMS message to a user with a confirmation. 41 | 42 | In this demo transactions are sent right away. 43 | 44 | ## Testing using Heroku and Twilio 45 | 46 | You can test this app live [using Heroku](https://devcenter.heroku.com/articles/getting-started-with-nodejs#deploy-the-app). 47 | 48 | After deploying your app you need to configure [Twilio](https://www.twilio.com/): 49 | 50 | 1. Create a phone number that is capable of sending/receiving SMS. 51 | 1. Update stellar-sms-client configuration with your Twilio API credentials and phone number. Deploy your app again. 52 | 1. In your phone number details set SMS & MMS > Request URL to: 53 | ``` 54 | https://[your heroku app URL]/receive 55 | ``` 56 | Request method should be set to `HTTP POST`. 57 | 58 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright 2015 Stellar Development Foundation 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | --------------------------------------------------------------------------------