├── .gitignore ├── README.md ├── lambda-functions ├── retrieve-subscribers.js └── subscribe-newsletter.js ├── package.json └── public ├── admin └── index.html ├── assets ├── amazon-cognito-identity.min.js ├── app.js ├── aws-cognito-sdk.min.js ├── aws-sdk.min.js ├── gateway │ ├── apigClient.js │ └── lib │ │ ├── CryptoJS │ │ ├── components │ │ │ ├── enc-base64.js │ │ │ └── hmac.js │ │ └── rollups │ │ │ ├── hmac-sha256.js │ │ │ └── sha256.js │ │ ├── apiGatewayCore │ │ ├── apiGatewayClient.js │ │ ├── sigV4Client.js │ │ ├── simpleHttpClient.js │ │ └── utils.js │ │ ├── axios │ │ └── dist │ │ │ └── axios.standalone.js │ │ └── url-template │ │ └── url-template.js ├── jsbn.js ├── jsbn2.js ├── moment.min.js └── sjcl.js ├── index.html ├── login.html └── post ├── function-as-a-service └── index.html ├── serverless-computing-takes-over-the-world └── index.html └── welcome-to-serverless-stories └── index.html /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # nyc test coverage 18 | .nyc_output 19 | 20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 21 | .grunt 22 | 23 | # node-waf configuration 24 | .lock-wscript 25 | 26 | # Compiled binary addons (http://nodejs.org/api/addons.html) 27 | build/Release 28 | 29 | # Dependency directories 30 | node_modules 31 | jspm_packages 32 | 33 | # Optional npm cache directory 34 | .npm 35 | 36 | # Optional REPL history 37 | .node_repl_history 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Serverless Stories (Lambda Implementation) 2 | 3 | Serverless Stories is a static blog that is enhanced with AWS Lambda. It is a sample application showing you can build serverless applications with AWS Lambda. Check out the blog post [here](https://auth0.com/blog/building-serverless-apps-with-aws-lambda/) and a comparison to Webtask [here](https://auth0.com/blog/2016/06/28/building-serverless-apps-with-webtask/). 4 | 5 | ![Serverless Stories](https://cdn.auth0.com/blog/webtask/app.png) 6 | 7 | ## Running the App 8 | 9 | 1. Clone the repo 10 | 2. Install the http-server by running `npm install http-server -g` (you will need Node and NPM) 11 | 3. Run `http-server` and navigate to `localhost:8080` to see the blog. 12 | 4. Read the blog post located [here](https://auth0.com/blog/building-serverless-apps-with-aws-lambda/) to learn how to work with AWS Lambda and get it implemented in the app. 13 | 14 | ## What is Auth0? 15 | 16 | Auth0 helps you to: 17 | 18 | * Add authentication with [multiple authentication sources](https://docs.auth0.com/identityproviders), either social like **Google, Facebook, Microsoft Account, LinkedIn, GitHub, Twitter, Box, Salesforce, amont others**, or enterprise identity systems like **Windows Azure AD, Google Apps, Active Directory, ADFS or any SAML Identity Provider**. 19 | * Add authentication through more traditional **[username/password databases](https://docs.auth0.com/mysql-connection-tutorial)**. 20 | * Add support for **[linking different user accounts](https://docs.auth0.com/link-accounts)** with the same user. 21 | * Support for generating signed [Json Web Tokens](https://docs.auth0.com/jwt) to call your APIs and **flow the user identity** securely. 22 | * Analytics of how, when and where users are logging in. 23 | * Pull data from other sources and add it to the user profile, through [JavaScript rules](https://docs.auth0.com/rules). 24 | 25 | ## Create a free Auth0 account 26 | 27 | 1. Go to [Auth0](https://auth0.com/signup) and click Sign Up. 28 | 2. Use Google, GitHub or Microsoft Account to login. 29 | 30 | ## Issue Reporting 31 | 32 | If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues. 33 | 34 | ## Author 35 | 36 | [Auth0](auth0.com) 37 | 38 | ## License 39 | 40 | This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info. 41 | 42 | -------------------------------------------------------------------------------- /lambda-functions/retrieve-subscribers.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // We'll again use the AWS SDK to get an instance of our database 4 | var aws = require('aws-sdk'); 5 | var db = new aws.DynamoDB(); 6 | 7 | exports.handler = (event, context, callback) => { 8 | // We'll modify our response code a little bit so that when the response 9 | // is ok, we'll return the list of emails in the message 10 | const RESPONSE = { 11 | OK : { 12 | statusCode : 200, 13 | message: [], 14 | }, 15 | ERROR : { 16 | status : 400, 17 | message: "Something went wrong. Please try again." 18 | } 19 | }; 20 | 21 | // We'll use the scan method to get all the data from our database 22 | db.scan({ 23 | TableName: "Emails" 24 | }, function(err, data) { 25 | if (err) { 26 | callback(null, RESPONSE.ERROR); 27 | } 28 | else { 29 | // If we get data back, we'll do some modifications to make it easier to read 30 | for(var i = 0; i < data.Items.length; i++){ 31 | RESPONSE.OK.message.push({'email': data.Items[i].email.S}); 32 | } 33 | callback(null, RESPONSE.OK); 34 | } 35 | }); 36 | }; -------------------------------------------------------------------------------- /lambda-functions/subscribe-newsletter.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // Require the AWS SDK and get the instance of our DynamoDB 4 | var aws = require('aws-sdk'); 5 | var db = new aws.DynamoDB(); 6 | 7 | // We'll use the same response we used in our Webtask module 8 | const RESPONSE = { 9 | OK : { 10 | statusCode : 200, 11 | message: "You have successfully subscribed to the newsletter!", 12 | }, 13 | DUPLICATE : { 14 | status : 400, 15 | message : "You are already subscribed." 16 | }, 17 | ERROR : { 18 | status : 400, 19 | message: "Something went wrong. Please try again." 20 | } 21 | }; 22 | 23 | 24 | // Set up the model for our the email 25 | var model = { 26 | email: {"S" : ""}, 27 | }; 28 | 29 | exports.handler = (event, context, callback) => { 30 | // Capture the email from our POST request 31 | var email = event.body.email; 32 | 33 | if(!email){ 34 | // If we don't get an email, we'll end our execution and send an error 35 | return callback(null, RESPONSE.ERROR); 36 | } 37 | 38 | // If we do have an email, we'll set it to our model 39 | model.email.S = email; 40 | 41 | // Insert the email into the database, but only if the email does not already exist. 42 | db.putItem({ 43 | TableName: 'Emails', 44 | Item: model, 45 | Expected: { 46 | email: { Exists: false } 47 | } 48 | }, function (err, data) { 49 | if (err) { 50 | // If we get an err, we'll assume it's a duplicate email and send an 51 | // appropriate message 52 | return callback(null, RESPONSE.DUPLICATE); 53 | } 54 | // If the data was stored succesfully, we'll respond accordingly 55 | callback(null, RESPONSE.OK); 56 | }); 57 | }; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "serverless-stories-lambda", 3 | "version" : "1.0.0", 4 | "dependencies" : { 5 | "http-server" : "latest" 6 | } 7 | } -------------------------------------------------------------------------------- /public/admin/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Serverless Stories | Admin 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 45 |
46 | 47 |
48 |
49 |

Admin

50 |

List of Subscribers

51 |
52 |
53 |
54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /public/assets/amazon-cognito-identity.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Amazon.com, 3 | * Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Licensed under the Amazon Software License (the "License"). 6 | * You may not use this file except in compliance with the 7 | * License. A copy of the License is located at 8 | * 9 | * http://aws.amazon.com/asl/ 10 | * 11 | * or in the "license" file accompanying this file. This file is 12 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | * CONDITIONS OF ANY KIND, express or implied. See the License 14 | * for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | 19 | AWSCognito.CognitoIdentityServiceProvider.CognitoUser=function(){var a=function b(a){if(!(this instanceof b))throw new Error("CognitoUser constructor was not called with new.");if(null==a||null==a.Username||null==a.Pool)throw new Error("Username and pool information are required.");this.username=a.Username||"",this.pool=a.Pool,this.AuthState=null,this.client=new AWSCognito.CognitoIdentityServiceProvider({apiVersion:"2016-04-19"}),this.signInUserSession=null};return a.prototype.getSignInUserSession=function(){return this.signInUserSession},a.prototype.getUsername=function(){return this.username},a.prototype.authenticateUser=function(a,b){var c,d,e=new AWSCognito.CognitoIdentityServiceProvider.AuthenticationHelper(this.pool.getUserPoolId().split("_")[1],this.pool.getParanoia()),f=this;this.client.getAuthenticationDetails({ClientId:this.pool.getClientId(),Username:this.username,SrpA:e.getLargeAValue().toString(16),ValidationData:a.getValidationData()},function(g,h){if(g)return b.onFailure(g);f.username=h.Username,c=new BigInteger(h.SrpB,16),d=new BigInteger(h.Salt,16);var i=e.getPasswordAuthenticationKey(f.username,a.getPassword(),c,d),j=sjcl.codec.bytes.toBits(h.SecretBlock),k=new sjcl.misc.hmac(i,sjcl.hash.sha256);k.update(sjcl.codec.utf8String.toBits(f.pool.getUserPoolId().split("_")[1])),k.update(sjcl.codec.utf8String.toBits(f.username)),k.update(j);var l=moment().utc(),m=l.format("ddd MMM D HH:mm:ss UTC YYYY");k.update(sjcl.codec.utf8String.toBits(m));for(var n=k.digest(),o=sjcl.codec.bytes.fromBits(n),p=new ArrayBuffer(32),q=new Uint8Array(p),r=0;rLog out'); 24 | $('#login').hide(); 25 | } else { 26 | $('#login').show().append('Log in'); 27 | $('#user').hide(); 28 | } 29 | } 30 | 31 | function loadAdmin(){ 32 | if(window.location.pathname == '/admin/'){ 33 | if(localStorage.getItem('token')){ 34 | AWS.config.credentials.get(function (err) { 35 | var client = apigClientFactory.newClient({ 36 | accessKey: AWS.config.credentials.accessKeyId, 37 | secretKey: AWS.config.credentials.secretAccessKey, 38 | sessionToken: AWS.config.credentials.sessionToken, 39 | region: 'us-east-1' 40 | }); 41 | client.subscribersGet().then(function(data){ 42 | for(var i = 0; i < data.data.message.length; i++){ 43 | $('#subscribers').append('

' + data.data.message[i].email + '

'); 44 | } 45 | }); 46 | }); 47 | } else { 48 | window.location = '/'; 49 | } 50 | } 51 | } 52 | 53 | $('#newsletter').submit(function(e){ 54 | e.preventDefault(); 55 | 56 | var client = apigClientFactory.newClient(); 57 | 58 | client.subscribePost({}, {email:$('#email').val()}, {}) 59 | .then(function(data){ 60 | if(data.data.statusCode == 200){ 61 | $('#newsletter').hide(); 62 | $('#response').append('
'+ data.data.message +'
') 63 | } else { 64 | $('#newsletter').hide(); 65 | $('#response').append('
'+ data.data.message +'
') 66 | } 67 | }) 68 | 69 | }) 70 | 71 | $('#signin').submit(function(e){ 72 | e.preventDefault(); 73 | AWSCognito.config.region = 'us-east-1'; 74 | AWSCognito.config.credentials = new AWS.CognitoIdentityCredentials({ 75 | IdentityPoolId: 'us-east-1_XXXXXXXXX' 76 | }); 77 | // Need to provide placeholder keys unless unauthorised user access is enabled for user pool 78 | AWSCognito.config.update({accessKeyId: 'anything', secretAccessKey: 'anything'}); 79 | 80 | var userPool = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserPool({ 81 | UserPoolId : 'us-east-1_XXXXXXXXX', 82 | ClientId : 'YOUR-APP-CLIENT-ID' 83 | }); 84 | 85 | var authenticationData = { 86 | Username : $('#username').val(), 87 | Password : $('#password').val(), 88 | }; 89 | var userData = { 90 | Username : $('#username').val(), 91 | Pool : userPool 92 | }; 93 | var authenticationDetails = new AWSCognito.CognitoIdentityServiceProvider.AuthenticationDetails(authenticationData); 94 | var cognitoUser = new AWSCognito.CognitoIdentityServiceProvider.CognitoUser(userData); 95 | 96 | cognitoUser.authenticateUser(authenticationDetails, { 97 | onSuccess: function (result) { 98 | localStorage.setItem('token', JSON.stringify(result.idToken.jwtToken)); 99 | window.location = '/'; 100 | }, 101 | onFailure: function(err) { 102 | console.log(err); 103 | } 104 | }); 105 | }) -------------------------------------------------------------------------------- /public/assets/gateway/apigClient.js: -------------------------------------------------------------------------------- 1 | /* 2 | * IMPORTANT!!! 3 | * DOWNLOAD YOUR API SDK FROM AWS 4 | * IT WILL HAVE YOUR API ENDPOINTS 5 | */ 6 | -------------------------------------------------------------------------------- /public/assets/gateway/lib/CryptoJS/components/enc-base64.js: -------------------------------------------------------------------------------- 1 | /* 2 | CryptoJS v3.1.2 3 | code.google.com/p/crypto-js 4 | (c) 2009-2013 by Jeff Mott. All rights reserved. 5 | code.google.com/p/crypto-js/wiki/License 6 | */ 7 | (function () { 8 | // Shortcuts 9 | var C = CryptoJS; 10 | var C_lib = C.lib; 11 | var WordArray = C_lib.WordArray; 12 | var C_enc = C.enc; 13 | 14 | /** 15 | * Base64 encoding strategy. 16 | */ 17 | var Base64 = C_enc.Base64 = { 18 | /** 19 | * Converts a word array to a Base64 string. 20 | * 21 | * @param {WordArray} wordArray The word array. 22 | * 23 | * @return {string} The Base64 string. 24 | * 25 | * @static 26 | * 27 | * @example 28 | * 29 | * var base64String = CryptoJS.enc.Base64.stringify(wordArray); 30 | */ 31 | stringify: function (wordArray) { 32 | // Shortcuts 33 | var words = wordArray.words; 34 | var sigBytes = wordArray.sigBytes; 35 | var map = this._map; 36 | 37 | // Clamp excess bits 38 | wordArray.clamp(); 39 | 40 | // Convert 41 | var base64Chars = []; 42 | for (var i = 0; i < sigBytes; i += 3) { 43 | var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; 44 | var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff; 45 | var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff; 46 | 47 | var triplet = (byte1 << 16) | (byte2 << 8) | byte3; 48 | 49 | for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) { 50 | base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f)); 51 | } 52 | } 53 | 54 | // Add padding 55 | var paddingChar = map.charAt(64); 56 | if (paddingChar) { 57 | while (base64Chars.length % 4) { 58 | base64Chars.push(paddingChar); 59 | } 60 | } 61 | 62 | return base64Chars.join(''); 63 | }, 64 | 65 | /** 66 | * Converts a Base64 string to a word array. 67 | * 68 | * @param {string} base64Str The Base64 string. 69 | * 70 | * @return {WordArray} The word array. 71 | * 72 | * @static 73 | * 74 | * @example 75 | * 76 | * var wordArray = CryptoJS.enc.Base64.parse(base64String); 77 | */ 78 | parse: function (base64Str) { 79 | // Shortcuts 80 | var base64StrLength = base64Str.length; 81 | var map = this._map; 82 | 83 | // Ignore padding 84 | var paddingChar = map.charAt(64); 85 | if (paddingChar) { 86 | var paddingIndex = base64Str.indexOf(paddingChar); 87 | if (paddingIndex != -1) { 88 | base64StrLength = paddingIndex; 89 | } 90 | } 91 | 92 | // Convert 93 | var words = []; 94 | var nBytes = 0; 95 | for (var i = 0; i < base64StrLength; i++) { 96 | if (i % 4) { 97 | var bits1 = map.indexOf(base64Str.charAt(i - 1)) << ((i % 4) * 2); 98 | var bits2 = map.indexOf(base64Str.charAt(i)) >>> (6 - (i % 4) * 2); 99 | words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8); 100 | nBytes++; 101 | } 102 | } 103 | 104 | return WordArray.create(words, nBytes); 105 | }, 106 | 107 | _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=' 108 | }; 109 | }()); 110 | -------------------------------------------------------------------------------- /public/assets/gateway/lib/CryptoJS/components/hmac.js: -------------------------------------------------------------------------------- 1 | /* 2 | CryptoJS v3.1.2 3 | code.google.com/p/crypto-js 4 | (c) 2009-2013 by Jeff Mott. All rights reserved. 5 | code.google.com/p/crypto-js/wiki/License 6 | */ 7 | (function () { 8 | // Shortcuts 9 | var C = CryptoJS; 10 | var C_lib = C.lib; 11 | var Base = C_lib.Base; 12 | var C_enc = C.enc; 13 | var Utf8 = C_enc.Utf8; 14 | var C_algo = C.algo; 15 | 16 | /** 17 | * HMAC algorithm. 18 | */ 19 | var HMAC = C_algo.HMAC = Base.extend({ 20 | /** 21 | * Initializes a newly created HMAC. 22 | * 23 | * @param {Hasher} hasher The hash algorithm to use. 24 | * @param {WordArray|string} key The secret key. 25 | * 26 | * @example 27 | * 28 | * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key); 29 | */ 30 | init: function (hasher, key) { 31 | // Init hasher 32 | hasher = this._hasher = new hasher.init(); 33 | 34 | // Convert string to WordArray, else assume WordArray already 35 | if (typeof key == 'string') { 36 | key = Utf8.parse(key); 37 | } 38 | 39 | // Shortcuts 40 | var hasherBlockSize = hasher.blockSize; 41 | var hasherBlockSizeBytes = hasherBlockSize * 4; 42 | 43 | // Allow arbitrary length keys 44 | if (key.sigBytes > hasherBlockSizeBytes) { 45 | key = hasher.finalize(key); 46 | } 47 | 48 | // Clamp excess bits 49 | key.clamp(); 50 | 51 | // Clone key for inner and outer pads 52 | var oKey = this._oKey = key.clone(); 53 | var iKey = this._iKey = key.clone(); 54 | 55 | // Shortcuts 56 | var oKeyWords = oKey.words; 57 | var iKeyWords = iKey.words; 58 | 59 | // XOR keys with pad constants 60 | for (var i = 0; i < hasherBlockSize; i++) { 61 | oKeyWords[i] ^= 0x5c5c5c5c; 62 | iKeyWords[i] ^= 0x36363636; 63 | } 64 | oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes; 65 | 66 | // Set initial values 67 | this.reset(); 68 | }, 69 | 70 | /** 71 | * Resets this HMAC to its initial state. 72 | * 73 | * @example 74 | * 75 | * hmacHasher.reset(); 76 | */ 77 | reset: function () { 78 | // Shortcut 79 | var hasher = this._hasher; 80 | 81 | // Reset 82 | hasher.reset(); 83 | hasher.update(this._iKey); 84 | }, 85 | 86 | /** 87 | * Updates this HMAC with a message. 88 | * 89 | * @param {WordArray|string} messageUpdate The message to append. 90 | * 91 | * @return {HMAC} This HMAC instance. 92 | * 93 | * @example 94 | * 95 | * hmacHasher.update('message'); 96 | * hmacHasher.update(wordArray); 97 | */ 98 | update: function (messageUpdate) { 99 | this._hasher.update(messageUpdate); 100 | 101 | // Chainable 102 | return this; 103 | }, 104 | 105 | /** 106 | * Finalizes the HMAC computation. 107 | * Note that the finalize operation is effectively a destructive, read-once operation. 108 | * 109 | * @param {WordArray|string} messageUpdate (Optional) A final message update. 110 | * 111 | * @return {WordArray} The HMAC. 112 | * 113 | * @example 114 | * 115 | * var hmac = hmacHasher.finalize(); 116 | * var hmac = hmacHasher.finalize('message'); 117 | * var hmac = hmacHasher.finalize(wordArray); 118 | */ 119 | finalize: function (messageUpdate) { 120 | // Shortcut 121 | var hasher = this._hasher; 122 | 123 | // Compute HMAC 124 | var innerHash = hasher.finalize(messageUpdate); 125 | hasher.reset(); 126 | var hmac = hasher.finalize(this._oKey.clone().concat(innerHash)); 127 | 128 | return hmac; 129 | } 130 | }); 131 | }()); 132 | -------------------------------------------------------------------------------- /public/assets/gateway/lib/CryptoJS/rollups/hmac-sha256.js: -------------------------------------------------------------------------------- 1 | /* 2 | CryptoJS v3.1.2 3 | code.google.com/p/crypto-js 4 | (c) 2009-2013 by Jeff Mott. All rights reserved. 5 | code.google.com/p/crypto-js/wiki/License 6 | */ 7 | var CryptoJS=CryptoJS||function(h,s){var f={},g=f.lib={},q=function(){},m=g.Base={extend:function(a){q.prototype=this;var c=new q;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}}, 8 | r=g.WordArray=m.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=s?c:4*a.length},toString:function(a){return(a||k).stringify(this)},concat:function(a){var c=this.words,d=a.words,b=this.sigBytes;a=a.sigBytes;this.clamp();if(b%4)for(var e=0;e>>2]|=(d[e>>>2]>>>24-8*(e%4)&255)<<24-8*((b+e)%4);else if(65535>>2]=d[e>>>2];else c.push.apply(c,d);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<< 9 | 32-8*(c%4);a.length=h.ceil(c/4)},clone:function(){var a=m.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],d=0;d>>2]>>>24-8*(b%4)&255;d.push((e>>>4).toString(16));d.push((e&15).toString(16))}return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b>>3]|=parseInt(a.substr(b, 10 | 2),16)<<24-4*(b%8);return new r.init(d,c/2)}},n=l.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var d=[],b=0;b>>2]>>>24-8*(b%4)&255));return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b>>2]|=(a.charCodeAt(b)&255)<<24-8*(b%4);return new r.init(d,c)}},j=l.Utf8={stringify:function(a){try{return decodeURIComponent(escape(n.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return n.parse(unescape(encodeURIComponent(a)))}}, 11 | u=g.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new r.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,d=c.words,b=c.sigBytes,e=this.blockSize,f=b/(4*e),f=a?h.ceil(f):h.max((f|0)-this._minBufferSize,0);a=f*e;b=h.min(4*a,b);if(a){for(var g=0;gn;){var j;a:{j=k;for(var u=h.sqrt(j),t=2;t<=u;t++)if(!(j%t)){j=!1;break a}j=!0}j&&(8>n&&(m[n]=l(h.pow(k,0.5))),r[n]=l(h.pow(k,1/3)),n++);k++}var a=[],f=f.SHA256=q.extend({_doReset:function(){this._hash=new g.init(m.slice(0))},_doProcessBlock:function(c,d){for(var b=this._hash.words,e=b[0],f=b[1],g=b[2],j=b[3],h=b[4],m=b[5],n=b[6],q=b[7],p=0;64>p;p++){if(16>p)a[p]= 15 | c[d+p]|0;else{var k=a[p-15],l=a[p-2];a[p]=((k<<25|k>>>7)^(k<<14|k>>>18)^k>>>3)+a[p-7]+((l<<15|l>>>17)^(l<<13|l>>>19)^l>>>10)+a[p-16]}k=q+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&m^~h&n)+r[p]+a[p];l=((e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22))+(e&f^e&g^f&g);q=n;n=m;m=h;h=j+k|0;j=g;g=f;f=e;e=k+l|0}b[0]=b[0]+e|0;b[1]=b[1]+f|0;b[2]=b[2]+g|0;b[3]=b[3]+j|0;b[4]=b[4]+h|0;b[5]=b[5]+m|0;b[6]=b[6]+n|0;b[7]=b[7]+q|0},_doFinalize:function(){var a=this._data,d=a.words,b=8*this._nDataBytes,e=8*a.sigBytes; 16 | d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=h.floor(b/4294967296);d[(e+64>>>9<<4)+15]=b;a.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var a=q.clone.call(this);a._hash=this._hash.clone();return a}});s.SHA256=q._createHelper(f);s.HmacSHA256=q._createHmacHelper(f)})(Math); 17 | (function(){var h=CryptoJS,s=h.enc.Utf8;h.algo.HMAC=h.lib.Base.extend({init:function(f,g){f=this._hasher=new f.init;"string"==typeof g&&(g=s.parse(g));var h=f.blockSize,m=4*h;g.sigBytes>m&&(g=f.finalize(g));g.clamp();for(var r=this._oKey=g.clone(),l=this._iKey=g.clone(),k=r.words,n=l.words,j=0;j>>2]|=(d[e>>>2]>>>24-8*(e%4)&255)<<24-8*((b+e)%4);else if(65535>>2]=d[e>>>2];else c.push.apply(c,d);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<< 9 | 32-8*(c%4);a.length=h.ceil(c/4)},clone:function(){var a=j.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],d=0;d>>2]>>>24-8*(b%4)&255;d.push((e>>>4).toString(16));d.push((e&15).toString(16))}return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b>>3]|=parseInt(a.substr(b, 10 | 2),16)<<24-4*(b%8);return new q.init(d,c/2)}},k=v.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var d=[],b=0;b>>2]>>>24-8*(b%4)&255));return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b>>2]|=(a.charCodeAt(b)&255)<<24-8*(b%4);return new q.init(d,c)}},l=v.Utf8={stringify:function(a){try{return decodeURIComponent(escape(k.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return k.parse(unescape(encodeURIComponent(a)))}}, 11 | x=t.BufferedBlockAlgorithm=j.extend({reset:function(){this._data=new q.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=l.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,d=c.words,b=c.sigBytes,e=this.blockSize,f=b/(4*e),f=a?h.ceil(f):h.max((f|0)-this._minBufferSize,0);a=f*e;b=h.min(4*a,b);if(a){for(var m=0;mk;){var l;a:{l=u;for(var x=h.sqrt(l),w=2;w<=x;w++)if(!(l%w)){l=!1;break a}l=!0}l&&(8>k&&(j[k]=v(h.pow(u,0.5))),q[k]=v(h.pow(u,1/3)),k++);u++}var a=[],f=f.SHA256=g.extend({_doReset:function(){this._hash=new t.init(j.slice(0))},_doProcessBlock:function(c,d){for(var b=this._hash.words,e=b[0],f=b[1],m=b[2],h=b[3],p=b[4],j=b[5],k=b[6],l=b[7],n=0;64>n;n++){if(16>n)a[n]= 15 | c[d+n]|0;else{var r=a[n-15],g=a[n-2];a[n]=((r<<25|r>>>7)^(r<<14|r>>>18)^r>>>3)+a[n-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+a[n-16]}r=l+((p<<26|p>>>6)^(p<<21|p>>>11)^(p<<7|p>>>25))+(p&j^~p&k)+q[n]+a[n];g=((e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22))+(e&f^e&m^f&m);l=k;k=j;j=p;p=h+r|0;h=m;m=f;f=e;e=r+g|0}b[0]=b[0]+e|0;b[1]=b[1]+f|0;b[2]=b[2]+m|0;b[3]=b[3]+h|0;b[4]=b[4]+p|0;b[5]=b[5]+j|0;b[6]=b[6]+k|0;b[7]=b[7]+l|0},_doFinalize:function(){var a=this._data,d=a.words,b=8*this._nDataBytes,e=8*a.sigBytes; 16 | d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=h.floor(b/4294967296);d[(e+64>>>9<<4)+15]=b;a.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var a=g.clone.call(this);a._hash=this._hash.clone();return a}});s.SHA256=g._createHelper(f);s.HmacSHA256=g._createHmacHelper(f)})(Math); 17 | -------------------------------------------------------------------------------- /public/assets/gateway/lib/apiGatewayCore/apiGatewayClient.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | var apiGateway = apiGateway || {}; 17 | apiGateway.core = apiGateway.core || {}; 18 | 19 | apiGateway.core.apiGatewayClientFactory = {}; 20 | apiGateway.core.apiGatewayClientFactory.newClient = function (simpleHttpClientConfig, sigV4ClientConfig) { 21 | var apiGatewayClient = { }; 22 | //Spin up 2 httpClients, one for simple requests, one for SigV4 23 | var sigV4Client = apiGateway.core.sigV4ClientFactory.newClient(sigV4ClientConfig); 24 | var simpleHttpClient = apiGateway.core.simpleHttpClientFactory.newClient(simpleHttpClientConfig); 25 | 26 | apiGatewayClient.makeRequest = function (request, authType, additionalParams, apiKey) { 27 | //Default the request to use the simple http client 28 | var clientToUse = simpleHttpClient; 29 | 30 | //Attach the apiKey to the headers request if one was provided 31 | if (apiKey !== undefined && apiKey !== '' && apiKey !== null) { 32 | request.headers['x-api-key'] = apiKey; 33 | } 34 | 35 | if (request.body === undefined || request.body === '' || request.body === null || Object.keys(request.body).length === 0) { 36 | request.body = undefined; 37 | } 38 | 39 | // If the user specified any additional headers or query params that may not have been modeled 40 | // merge them into the appropriate request properties 41 | request.headers = apiGateway.core.utils.mergeInto(request.headers, additionalParams.headers); 42 | request.queryParams = apiGateway.core.utils.mergeInto(request.queryParams, additionalParams.queryParams); 43 | 44 | //If an auth type was specified inject the appropriate auth client 45 | if (authType === 'AWS_IAM') { 46 | clientToUse = sigV4Client; 47 | } 48 | 49 | //Call the selected http client to make the request, returning a promise once the request is sent 50 | return clientToUse.makeRequest(request); 51 | }; 52 | return apiGatewayClient; 53 | }; 54 | -------------------------------------------------------------------------------- /public/assets/gateway/lib/apiGatewayCore/sigV4Client.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | var apiGateway = apiGateway || {}; 17 | apiGateway.core = apiGateway.core || {}; 18 | 19 | apiGateway.core.sigV4ClientFactory = {}; 20 | apiGateway.core.sigV4ClientFactory.newClient = function (config) { 21 | var AWS_SHA_256 = 'AWS4-HMAC-SHA256'; 22 | var AWS4_REQUEST = 'aws4_request'; 23 | var AWS4 = 'AWS4'; 24 | var X_AMZ_DATE = 'x-amz-date'; 25 | var X_AMZ_SECURITY_TOKEN = 'x-amz-security-token'; 26 | var HOST = 'host'; 27 | var AUTHORIZATION = 'Authorization'; 28 | 29 | function hash(value) { 30 | return CryptoJS.SHA256(value); 31 | } 32 | 33 | function hexEncode(value) { 34 | return value.toString(CryptoJS.enc.Hex); 35 | } 36 | 37 | function hmac(secret, value) { 38 | return CryptoJS.HmacSHA256(value, secret, {asBytes: true}); 39 | } 40 | 41 | function buildCanonicalRequest(method, path, queryParams, headers, payload) { 42 | return method + '\n' + 43 | buildCanonicalUri(path) + '\n' + 44 | buildCanonicalQueryString(queryParams) + '\n' + 45 | buildCanonicalHeaders(headers) + '\n' + 46 | buildCanonicalSignedHeaders(headers) + '\n' + 47 | hexEncode(hash(payload)); 48 | } 49 | 50 | function hashCanonicalRequest(request) { 51 | return hexEncode(hash(request)); 52 | } 53 | 54 | function buildCanonicalUri(uri) { 55 | return encodeURI(uri); 56 | } 57 | 58 | function buildCanonicalQueryString(queryParams) { 59 | if (Object.keys(queryParams).length < 1) { 60 | return ''; 61 | } 62 | 63 | var sortedQueryParams = []; 64 | for (var property in queryParams) { 65 | if (queryParams.hasOwnProperty(property)) { 66 | sortedQueryParams.push(property); 67 | } 68 | } 69 | sortedQueryParams.sort(); 70 | 71 | var canonicalQueryString = ''; 72 | for (var i = 0; i < sortedQueryParams.length; i++) { 73 | canonicalQueryString += sortedQueryParams[i] + '=' + encodeURIComponent(queryParams[sortedQueryParams[i]]) + '&'; 74 | } 75 | return canonicalQueryString.substr(0, canonicalQueryString.length - 1); 76 | } 77 | 78 | function buildCanonicalHeaders(headers) { 79 | var canonicalHeaders = ''; 80 | var sortedKeys = []; 81 | for (var property in headers) { 82 | if (headers.hasOwnProperty(property)) { 83 | sortedKeys.push(property); 84 | } 85 | } 86 | sortedKeys.sort(); 87 | 88 | for (var i = 0; i < sortedKeys.length; i++) { 89 | canonicalHeaders += sortedKeys[i].toLowerCase() + ':' + headers[sortedKeys[i]] + '\n'; 90 | } 91 | return canonicalHeaders; 92 | } 93 | 94 | function buildCanonicalSignedHeaders(headers) { 95 | var sortedKeys = []; 96 | for (var property in headers) { 97 | if (headers.hasOwnProperty(property)) { 98 | sortedKeys.push(property.toLowerCase()); 99 | } 100 | } 101 | sortedKeys.sort(); 102 | 103 | return sortedKeys.join(';'); 104 | } 105 | 106 | function buildStringToSign(datetime, credentialScope, hashedCanonicalRequest) { 107 | return AWS_SHA_256 + '\n' + 108 | datetime + '\n' + 109 | credentialScope + '\n' + 110 | hashedCanonicalRequest; 111 | } 112 | 113 | function buildCredentialScope(datetime, region, service) { 114 | return datetime.substr(0, 8) + '/' + region + '/' + service + '/' + AWS4_REQUEST 115 | } 116 | 117 | function calculateSigningKey(secretKey, datetime, region, service) { 118 | return hmac(hmac(hmac(hmac(AWS4 + secretKey, datetime.substr(0, 8)), region), service), AWS4_REQUEST); 119 | } 120 | 121 | function calculateSignature(key, stringToSign) { 122 | return hexEncode(hmac(key, stringToSign)); 123 | } 124 | 125 | function buildAuthorizationHeader(accessKey, credentialScope, headers, signature) { 126 | return AWS_SHA_256 + ' Credential=' + accessKey + '/' + credentialScope + ', SignedHeaders=' + buildCanonicalSignedHeaders(headers) + ', Signature=' + signature; 127 | } 128 | 129 | var awsSigV4Client = { }; 130 | if(config.accessKey === undefined || config.secretKey === undefined) { 131 | return awsSigV4Client; 132 | } 133 | awsSigV4Client.accessKey = apiGateway.core.utils.assertDefined(config.accessKey, 'accessKey'); 134 | awsSigV4Client.secretKey = apiGateway.core.utils.assertDefined(config.secretKey, 'secretKey'); 135 | awsSigV4Client.sessionToken = config.sessionToken; 136 | awsSigV4Client.serviceName = apiGateway.core.utils.assertDefined(config.serviceName, 'serviceName'); 137 | awsSigV4Client.region = apiGateway.core.utils.assertDefined(config.region, 'region'); 138 | awsSigV4Client.endpoint = apiGateway.core.utils.assertDefined(config.endpoint, 'endpoint'); 139 | 140 | awsSigV4Client.makeRequest = function (request) { 141 | var verb = apiGateway.core.utils.assertDefined(request.verb, 'verb'); 142 | var path = apiGateway.core.utils.assertDefined(request.path, 'path'); 143 | var queryParams = apiGateway.core.utils.copy(request.queryParams); 144 | if (queryParams === undefined) { 145 | queryParams = {}; 146 | } 147 | var headers = apiGateway.core.utils.copy(request.headers); 148 | if (headers === undefined) { 149 | headers = {}; 150 | } 151 | 152 | //If the user has not specified an override for Content type the use default 153 | if(headers['Content-Type'] === undefined) { 154 | headers['Content-Type'] = config.defaultContentType; 155 | } 156 | 157 | //If the user has not specified an override for Accept type the use default 158 | if(headers['Accept'] === undefined) { 159 | headers['Accept'] = config.defaultAcceptType; 160 | } 161 | 162 | var body = apiGateway.core.utils.copy(request.body); 163 | if (body === undefined || verb === 'GET') { // override request body and set to empty when signing GET requests 164 | body = ''; 165 | } else { 166 | body = JSON.stringify(body); 167 | } 168 | 169 | //If there is no body remove the content-type header so it is not included in SigV4 calculation 170 | if(body === '' || body === undefined || body === null) { 171 | delete headers['Content-Type']; 172 | } 173 | 174 | var datetime = new Date().toISOString().replace(/\.\d{3}Z$/, 'Z').replace(/[:\-]|\.\d{3}/g, ''); 175 | headers[X_AMZ_DATE] = datetime; 176 | var parser = document.createElement('a'); 177 | parser.href = awsSigV4Client.endpoint; 178 | headers[HOST] = parser.hostname; 179 | 180 | var canonicalRequest = buildCanonicalRequest(verb, path, queryParams, headers, body); 181 | var hashedCanonicalRequest = hashCanonicalRequest(canonicalRequest); 182 | var credentialScope = buildCredentialScope(datetime, awsSigV4Client.region, awsSigV4Client.serviceName); 183 | var stringToSign = buildStringToSign(datetime, credentialScope, hashedCanonicalRequest); 184 | var signingKey = calculateSigningKey(awsSigV4Client.secretKey, datetime, awsSigV4Client.region, awsSigV4Client.serviceName); 185 | var signature = calculateSignature(signingKey, stringToSign); 186 | headers[AUTHORIZATION] = buildAuthorizationHeader(awsSigV4Client.accessKey, credentialScope, headers, signature); 187 | if(awsSigV4Client.sessionToken !== undefined && awsSigV4Client.sessionToken !== '') { 188 | headers[X_AMZ_SECURITY_TOKEN] = awsSigV4Client.sessionToken; 189 | } 190 | delete headers[HOST]; 191 | 192 | var url = config.endpoint + path; 193 | var queryString = buildCanonicalQueryString(queryParams); 194 | if (queryString != '') { 195 | url += '?' + queryString; 196 | } 197 | 198 | //Need to re-attach Content-Type if it is not specified at this point 199 | if(headers['Content-Type'] === undefined) { 200 | headers['Content-Type'] = config.defaultContentType; 201 | } 202 | 203 | var signedRequest = { 204 | method: verb, 205 | url: url, 206 | headers: headers, 207 | data: body 208 | }; 209 | return axios(signedRequest); 210 | }; 211 | 212 | return awsSigV4Client; 213 | }; 214 | -------------------------------------------------------------------------------- /public/assets/gateway/lib/apiGatewayCore/simpleHttpClient.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | var apiGateway = apiGateway || {}; 17 | apiGateway.core = apiGateway.core || {}; 18 | 19 | apiGateway.core.simpleHttpClientFactory = {}; 20 | apiGateway.core.simpleHttpClientFactory.newClient = function (config) { 21 | function buildCanonicalQueryString(queryParams) { 22 | //Build a properly encoded query string from a QueryParam object 23 | if (Object.keys(queryParams).length < 1) { 24 | return ''; 25 | } 26 | 27 | var canonicalQueryString = ''; 28 | for (var property in queryParams) { 29 | if (queryParams.hasOwnProperty(property)) { 30 | canonicalQueryString += encodeURIComponent(property) + '=' + encodeURIComponent(queryParams[property]) + '&'; 31 | } 32 | } 33 | 34 | return canonicalQueryString.substr(0, canonicalQueryString.length - 1); 35 | } 36 | 37 | var simpleHttpClient = { }; 38 | simpleHttpClient.endpoint = apiGateway.core.utils.assertDefined(config.endpoint, 'endpoint'); 39 | 40 | simpleHttpClient.makeRequest = function (request) { 41 | var verb = apiGateway.core.utils.assertDefined(request.verb, 'verb'); 42 | var path = apiGateway.core.utils.assertDefined(request.path, 'path'); 43 | var queryParams = apiGateway.core.utils.copy(request.queryParams); 44 | if (queryParams === undefined) { 45 | queryParams = {}; 46 | } 47 | var headers = apiGateway.core.utils.copy(request.headers); 48 | if (headers === undefined) { 49 | headers = {}; 50 | } 51 | 52 | //If the user has not specified an override for Content type the use default 53 | if(headers['Content-Type'] === undefined) { 54 | headers['Content-Type'] = config.defaultContentType; 55 | } 56 | 57 | //If the user has not specified an override for Accept type the use default 58 | if(headers['Accept'] === undefined) { 59 | headers['Accept'] = config.defaultAcceptType; 60 | } 61 | 62 | var body = apiGateway.core.utils.copy(request.body); 63 | if (body === undefined) { 64 | body = ''; 65 | } 66 | 67 | var url = config.endpoint + path; 68 | var queryString = buildCanonicalQueryString(queryParams); 69 | if (queryString != '') { 70 | url += '?' + queryString; 71 | } 72 | var simpleHttpRequest = { 73 | method: verb, 74 | url: url, 75 | headers: headers, 76 | data: body 77 | }; 78 | return axios(simpleHttpRequest); 79 | }; 80 | return simpleHttpClient; 81 | }; -------------------------------------------------------------------------------- /public/assets/gateway/lib/apiGatewayCore/utils.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | var apiGateway = apiGateway || {}; 17 | apiGateway.core = apiGateway.core || {}; 18 | 19 | apiGateway.core.utils = { 20 | assertDefined: function (object, name) { 21 | if (object === undefined) { 22 | throw name + ' must be defined'; 23 | } else { 24 | return object; 25 | } 26 | }, 27 | assertParametersDefined: function (params, keys, ignore) { 28 | if (keys === undefined) { 29 | return; 30 | } 31 | if (keys.length > 0 && params === undefined) { 32 | params = {}; 33 | } 34 | for (var i = 0; i < keys.length; i++) { 35 | if(!apiGateway.core.utils.contains(ignore, keys[i])) { 36 | apiGateway.core.utils.assertDefined(params[keys[i]], keys[i]); 37 | } 38 | } 39 | }, 40 | parseParametersToObject: function (params, keys) { 41 | if (params === undefined) { 42 | return {}; 43 | } 44 | var object = { }; 45 | for (var i = 0; i < keys.length; i++) { 46 | object[keys[i]] = params[keys[i]]; 47 | } 48 | return object; 49 | }, 50 | contains: function(a, obj) { 51 | if(a === undefined) { return false;} 52 | var i = a.length; 53 | while (i--) { 54 | if (a[i] === obj) { 55 | return true; 56 | } 57 | } 58 | return false; 59 | }, 60 | copy: function (obj) { 61 | if (null == obj || "object" != typeof obj) return obj; 62 | var copy = obj.constructor(); 63 | for (var attr in obj) { 64 | if (obj.hasOwnProperty(attr)) copy[attr] = obj[attr]; 65 | } 66 | return copy; 67 | }, 68 | mergeInto: function (baseObj, additionalProps) { 69 | if (null == baseObj || "object" != typeof baseObj) return baseObj; 70 | var merged = baseObj.constructor(); 71 | for (var attr in baseObj) { 72 | if (baseObj.hasOwnProperty(attr)) merged[attr] = baseObj[attr]; 73 | } 74 | if (null == additionalProps || "object" != typeof additionalProps) return baseObj; 75 | for (attr in additionalProps) { 76 | if (additionalProps.hasOwnProperty(attr)) merged[attr] = additionalProps[attr]; 77 | } 78 | return merged; 79 | } 80 | }; 81 | -------------------------------------------------------------------------------- /public/assets/gateway/lib/axios/dist/axios.standalone.js: -------------------------------------------------------------------------------- 1 | /* 2 | axios v0.7.0 3 | Copyright (c) 2014 Matt Zabriskie 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | */ 23 | (function webpackUniversalModuleDefinition(root, factory) { 24 | if(typeof exports === 'object' && typeof module === 'object') 25 | module.exports = factory(); 26 | else if(typeof define === 'function' && define.amd) 27 | define([], factory); 28 | else if(typeof exports === 'object') 29 | exports["axios"] = factory(); 30 | else 31 | root["axios"] = factory(); 32 | })(this, function() { 33 | return /******/ (function(modules) { // webpackBootstrap 34 | /******/ // The module cache 35 | /******/ var installedModules = {}; 36 | /******/ 37 | /******/ // The require function 38 | /******/ function __webpack_require__(moduleId) { 39 | /******/ 40 | /******/ // Check if module is in cache 41 | /******/ if(installedModules[moduleId]) 42 | /******/ return installedModules[moduleId].exports; 43 | /******/ 44 | /******/ // Create a new module (and put it into the cache) 45 | /******/ var module = installedModules[moduleId] = { 46 | /******/ exports: {}, 47 | /******/ id: moduleId, 48 | /******/ loaded: false 49 | /******/ }; 50 | /******/ 51 | /******/ // Execute the module function 52 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 53 | /******/ 54 | /******/ // Flag the module as loaded 55 | /******/ module.loaded = true; 56 | /******/ 57 | /******/ // Return the exports of the module 58 | /******/ return module.exports; 59 | /******/ } 60 | /******/ 61 | /******/ 62 | /******/ // expose the modules object (__webpack_modules__) 63 | /******/ __webpack_require__.m = modules; 64 | /******/ 65 | /******/ // expose the module cache 66 | /******/ __webpack_require__.c = installedModules; 67 | /******/ 68 | /******/ // __webpack_public_path__ 69 | /******/ __webpack_require__.p = ""; 70 | /******/ 71 | /******/ // Load entry module and return exports 72 | /******/ return __webpack_require__(0); 73 | /******/ }) 74 | /************************************************************************/ 75 | /******/ ([ 76 | /* 0 */ 77 | /***/ function(module, exports, __webpack_require__) { 78 | 79 | module.exports = __webpack_require__(1); 80 | 81 | /***/ }, 82 | /* 1 */ 83 | /***/ function(module, exports, __webpack_require__) { 84 | 85 | 'use strict'; 86 | 87 | var defaults = __webpack_require__(2); 88 | var utils = __webpack_require__(3); 89 | var dispatchRequest = __webpack_require__(4); 90 | var InterceptorManager = __webpack_require__(12); 91 | 92 | var axios = module.exports = function (config) { 93 | // Allow for axios('example/url'[, config]) a la fetch API 94 | if (typeof config === 'string') { 95 | config = utils.merge({ 96 | url: arguments[0] 97 | }, arguments[1]); 98 | } 99 | 100 | config = utils.merge({ 101 | method: 'get', 102 | headers: {}, 103 | timeout: defaults.timeout, 104 | transformRequest: defaults.transformRequest, 105 | transformResponse: defaults.transformResponse 106 | }, config); 107 | 108 | // Don't allow overriding defaults.withCredentials 109 | config.withCredentials = config.withCredentials || defaults.withCredentials; 110 | 111 | // Hook up interceptors middleware 112 | var chain = [dispatchRequest, undefined]; 113 | var promise = Promise.resolve(config); 114 | 115 | axios.interceptors.request.forEach(function (interceptor) { 116 | chain.unshift(interceptor.fulfilled, interceptor.rejected); 117 | }); 118 | 119 | axios.interceptors.response.forEach(function (interceptor) { 120 | chain.push(interceptor.fulfilled, interceptor.rejected); 121 | }); 122 | 123 | while (chain.length) { 124 | promise = promise.then(chain.shift(), chain.shift()); 125 | } 126 | 127 | return promise; 128 | }; 129 | 130 | // Expose defaults 131 | axios.defaults = defaults; 132 | 133 | // Expose all/spread 134 | axios.all = function (promises) { 135 | return Promise.all(promises); 136 | }; 137 | axios.spread = __webpack_require__(13); 138 | 139 | // Expose interceptors 140 | axios.interceptors = { 141 | request: new InterceptorManager(), 142 | response: new InterceptorManager() 143 | }; 144 | 145 | // Provide aliases for supported request methods 146 | (function () { 147 | function createShortMethods() { 148 | utils.forEach(arguments, function (method) { 149 | axios[method] = function (url, config) { 150 | return axios(utils.merge(config || {}, { 151 | method: method, 152 | url: url 153 | })); 154 | }; 155 | }); 156 | } 157 | 158 | function createShortMethodsWithData() { 159 | utils.forEach(arguments, function (method) { 160 | axios[method] = function (url, data, config) { 161 | return axios(utils.merge(config || {}, { 162 | method: method, 163 | url: url, 164 | data: data 165 | })); 166 | }; 167 | }); 168 | } 169 | 170 | createShortMethods('delete', 'get', 'head'); 171 | createShortMethodsWithData('post', 'put', 'patch'); 172 | })(); 173 | 174 | 175 | /***/ }, 176 | /* 2 */ 177 | /***/ function(module, exports, __webpack_require__) { 178 | 179 | 'use strict'; 180 | 181 | var utils = __webpack_require__(3); 182 | 183 | var PROTECTION_PREFIX = /^\)\]\}',?\n/; 184 | var DEFAULT_CONTENT_TYPE = { 185 | 'Content-Type': 'application/json' 186 | }; 187 | 188 | module.exports = { 189 | transformRequest: [function (data, headers) { 190 | if(utils.isFormData(data)) { 191 | return data; 192 | } 193 | if (utils.isArrayBuffer(data)) { 194 | return data; 195 | } 196 | if (utils.isArrayBufferView(data)) { 197 | return data.buffer; 198 | } 199 | if (utils.isObject(data) && !utils.isFile(data) && !utils.isBlob(data)) { 200 | // Set application/json if no Content-Type has been specified 201 | if (!utils.isUndefined(headers)) { 202 | utils.forEach(headers, function (val, key) { 203 | if (key.toLowerCase() === 'content-type') { 204 | headers['Content-Type'] = val; 205 | } 206 | }); 207 | 208 | if (utils.isUndefined(headers['Content-Type'])) { 209 | headers['Content-Type'] = 'application/json;charset=utf-8'; 210 | } 211 | } 212 | return JSON.stringify(data); 213 | } 214 | return data; 215 | }], 216 | 217 | transformResponse: [function (data) { 218 | if (typeof data === 'string') { 219 | data = data.replace(PROTECTION_PREFIX, ''); 220 | try { 221 | data = JSON.parse(data); 222 | } catch (e) { /* Ignore */ } 223 | } 224 | return data; 225 | }], 226 | 227 | headers: { 228 | common: { 229 | 'Accept': 'application/json, text/plain, */*' 230 | }, 231 | patch: utils.merge(DEFAULT_CONTENT_TYPE), 232 | post: utils.merge(DEFAULT_CONTENT_TYPE), 233 | put: utils.merge(DEFAULT_CONTENT_TYPE) 234 | }, 235 | 236 | timeout: 0, 237 | 238 | xsrfCookieName: 'XSRF-TOKEN', 239 | xsrfHeaderName: 'X-XSRF-TOKEN' 240 | }; 241 | 242 | 243 | /***/ }, 244 | /* 3 */ 245 | /***/ function(module, exports) { 246 | 247 | 'use strict'; 248 | 249 | /*global toString:true*/ 250 | 251 | // utils is a library of generic helper functions non-specific to axios 252 | 253 | var toString = Object.prototype.toString; 254 | 255 | /** 256 | * Determine if a value is an Array 257 | * 258 | * @param {Object} val The value to test 259 | * @returns {boolean} True if value is an Array, otherwise false 260 | */ 261 | function isArray(val) { 262 | return toString.call(val) === '[object Array]'; 263 | } 264 | 265 | /** 266 | * Determine if a value is an ArrayBuffer 267 | * 268 | * @param {Object} val The value to test 269 | * @returns {boolean} True if value is an ArrayBuffer, otherwise false 270 | */ 271 | function isArrayBuffer(val) { 272 | return toString.call(val) === '[object ArrayBuffer]'; 273 | } 274 | 275 | /** 276 | * Determine if a value is a FormData 277 | * 278 | * @param {Object} val The value to test 279 | * @returns {boolean} True if value is an FormData, otherwise false 280 | */ 281 | function isFormData(val) { 282 | return toString.call(val) === '[object FormData]'; 283 | } 284 | 285 | /** 286 | * Determine if a value is a view on an ArrayBuffer 287 | * 288 | * @param {Object} val The value to test 289 | * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false 290 | */ 291 | function isArrayBufferView(val) { 292 | if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) { 293 | return ArrayBuffer.isView(val); 294 | } else { 295 | return (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer); 296 | } 297 | } 298 | 299 | /** 300 | * Determine if a value is a String 301 | * 302 | * @param {Object} val The value to test 303 | * @returns {boolean} True if value is a String, otherwise false 304 | */ 305 | function isString(val) { 306 | return typeof val === 'string'; 307 | } 308 | 309 | /** 310 | * Determine if a value is a Number 311 | * 312 | * @param {Object} val The value to test 313 | * @returns {boolean} True if value is a Number, otherwise false 314 | */ 315 | function isNumber(val) { 316 | return typeof val === 'number'; 317 | } 318 | 319 | /** 320 | * Determine if a value is undefined 321 | * 322 | * @param {Object} val The value to test 323 | * @returns {boolean} True if the value is undefined, otherwise false 324 | */ 325 | function isUndefined(val) { 326 | return typeof val === 'undefined'; 327 | } 328 | 329 | /** 330 | * Determine if a value is an Object 331 | * 332 | * @param {Object} val The value to test 333 | * @returns {boolean} True if value is an Object, otherwise false 334 | */ 335 | function isObject(val) { 336 | return val !== null && typeof val === 'object'; 337 | } 338 | 339 | /** 340 | * Determine if a value is a Date 341 | * 342 | * @param {Object} val The value to test 343 | * @returns {boolean} True if value is a Date, otherwise false 344 | */ 345 | function isDate(val) { 346 | return toString.call(val) === '[object Date]'; 347 | } 348 | 349 | /** 350 | * Determine if a value is a File 351 | * 352 | * @param {Object} val The value to test 353 | * @returns {boolean} True if value is a File, otherwise false 354 | */ 355 | function isFile(val) { 356 | return toString.call(val) === '[object File]'; 357 | } 358 | 359 | /** 360 | * Determine if a value is a Blob 361 | * 362 | * @param {Object} val The value to test 363 | * @returns {boolean} True if value is a Blob, otherwise false 364 | */ 365 | function isBlob(val) { 366 | return toString.call(val) === '[object Blob]'; 367 | } 368 | 369 | /** 370 | * Trim excess whitespace off the beginning and end of a string 371 | * 372 | * @param {String} str The String to trim 373 | * @returns {String} The String freed of excess whitespace 374 | */ 375 | function trim(str) { 376 | return str.replace(/^\s*/, '').replace(/\s*$/, ''); 377 | } 378 | 379 | /** 380 | * Determine if a value is an Arguments object 381 | * 382 | * @param {Object} val The value to test 383 | * @returns {boolean} True if value is an Arguments object, otherwise false 384 | */ 385 | function isArguments(val) { 386 | return toString.call(val) === '[object Arguments]'; 387 | } 388 | 389 | /** 390 | * Determine if we're running in a standard browser environment 391 | * 392 | * This allows axios to run in a web worker, and react-native. 393 | * Both environments support XMLHttpRequest, but not fully standard globals. 394 | * 395 | * web workers: 396 | * typeof window -> undefined 397 | * typeof document -> undefined 398 | * 399 | * react-native: 400 | * typeof document.createelement -> undefined 401 | */ 402 | function isStandardBrowserEnv() { 403 | return ( 404 | typeof window !== 'undefined' && 405 | typeof document !== 'undefined' && 406 | typeof document.createElement === 'function' 407 | ); 408 | } 409 | 410 | /** 411 | * Iterate over an Array or an Object invoking a function for each item. 412 | * 413 | * If `obj` is an Array or arguments callback will be called passing 414 | * the value, index, and complete array for each item. 415 | * 416 | * If 'obj' is an Object callback will be called passing 417 | * the value, key, and complete object for each property. 418 | * 419 | * @param {Object|Array} obj The object to iterate 420 | * @param {Function} fn The callback to invoke for each item 421 | */ 422 | function forEach(obj, fn) { 423 | // Don't bother if no value provided 424 | if (obj === null || typeof obj === 'undefined') { 425 | return; 426 | } 427 | 428 | // Check if obj is array-like 429 | var isArrayLike = isArray(obj) || isArguments(obj); 430 | 431 | // Force an array if not already something iterable 432 | if (typeof obj !== 'object' && !isArrayLike) { 433 | obj = [obj]; 434 | } 435 | 436 | // Iterate over array values 437 | if (isArrayLike) { 438 | for (var i = 0, l = obj.length; i < l; i++) { 439 | fn.call(null, obj[i], i, obj); 440 | } 441 | } 442 | // Iterate over object keys 443 | else { 444 | for (var key in obj) { 445 | if (obj.hasOwnProperty(key)) { 446 | fn.call(null, obj[key], key, obj); 447 | } 448 | } 449 | } 450 | } 451 | 452 | /** 453 | * Accepts varargs expecting each argument to be an object, then 454 | * immutably merges the properties of each object and returns result. 455 | * 456 | * When multiple objects contain the same key the later object in 457 | * the arguments list will take precedence. 458 | * 459 | * Example: 460 | * 461 | * ```js 462 | * var result = merge({foo: 123}, {foo: 456}); 463 | * console.log(result.foo); // outputs 456 464 | * ``` 465 | * 466 | * @param {Object} obj1 Object to merge 467 | * @returns {Object} Result of all merge properties 468 | */ 469 | function merge(/*obj1, obj2, obj3, ...*/) { 470 | var result = {}; 471 | forEach(arguments, function (obj) { 472 | forEach(obj, function (val, key) { 473 | result[key] = val; 474 | }); 475 | }); 476 | return result; 477 | } 478 | 479 | module.exports = { 480 | isArray: isArray, 481 | isArrayBuffer: isArrayBuffer, 482 | isFormData: isFormData, 483 | isArrayBufferView: isArrayBufferView, 484 | isString: isString, 485 | isNumber: isNumber, 486 | isObject: isObject, 487 | isUndefined: isUndefined, 488 | isDate: isDate, 489 | isFile: isFile, 490 | isBlob: isBlob, 491 | isStandardBrowserEnv: isStandardBrowserEnv, 492 | forEach: forEach, 493 | merge: merge, 494 | trim: trim 495 | }; 496 | 497 | 498 | /***/ }, 499 | /* 4 */ 500 | /***/ function(module, exports, __webpack_require__) { 501 | 502 | /* WEBPACK VAR INJECTION */(function(process) {'use strict'; 503 | 504 | /** 505 | * Dispatch a request to the server using whichever adapter 506 | * is supported by the current environment. 507 | * 508 | * @param {object} config The config that is to be used for the request 509 | * @returns {Promise} The Promise to be fulfilled 510 | */ 511 | module.exports = function dispatchRequest(config) { 512 | return new Promise(function (resolve, reject) { 513 | try { 514 | // For browsers use XHR adapter 515 | if ((typeof XMLHttpRequest !== 'undefined') || (typeof ActiveXObject !== 'undefined')) { 516 | __webpack_require__(6)(resolve, reject, config); 517 | } 518 | // For node use HTTP adapter 519 | else if (typeof process !== 'undefined') { 520 | __webpack_require__(6)(resolve, reject, config); 521 | } 522 | } catch (e) { 523 | reject(e); 524 | } 525 | }); 526 | }; 527 | 528 | 529 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5))) 530 | 531 | /***/ }, 532 | /* 5 */ 533 | /***/ function(module, exports) { 534 | 535 | // shim for using process in browser 536 | 537 | var process = module.exports = {}; 538 | var queue = []; 539 | var draining = false; 540 | var currentQueue; 541 | var queueIndex = -1; 542 | 543 | function cleanUpNextTick() { 544 | draining = false; 545 | if (currentQueue.length) { 546 | queue = currentQueue.concat(queue); 547 | } else { 548 | queueIndex = -1; 549 | } 550 | if (queue.length) { 551 | drainQueue(); 552 | } 553 | } 554 | 555 | function drainQueue() { 556 | if (draining) { 557 | return; 558 | } 559 | var timeout = setTimeout(cleanUpNextTick); 560 | draining = true; 561 | 562 | var len = queue.length; 563 | while(len) { 564 | currentQueue = queue; 565 | queue = []; 566 | while (++queueIndex < len) { 567 | if (currentQueue) { 568 | currentQueue[queueIndex].run(); 569 | } 570 | } 571 | queueIndex = -1; 572 | len = queue.length; 573 | } 574 | currentQueue = null; 575 | draining = false; 576 | clearTimeout(timeout); 577 | } 578 | 579 | process.nextTick = function (fun) { 580 | var args = new Array(arguments.length - 1); 581 | if (arguments.length > 1) { 582 | for (var i = 1; i < arguments.length; i++) { 583 | args[i - 1] = arguments[i]; 584 | } 585 | } 586 | queue.push(new Item(fun, args)); 587 | if (queue.length === 1 && !draining) { 588 | setTimeout(drainQueue, 0); 589 | } 590 | }; 591 | 592 | // v8 likes predictible objects 593 | function Item(fun, array) { 594 | this.fun = fun; 595 | this.array = array; 596 | } 597 | Item.prototype.run = function () { 598 | this.fun.apply(null, this.array); 599 | }; 600 | process.title = 'browser'; 601 | process.browser = true; 602 | process.env = {}; 603 | process.argv = []; 604 | process.version = ''; // empty string to avoid regexp issues 605 | process.versions = {}; 606 | 607 | function noop() {} 608 | 609 | process.on = noop; 610 | process.addListener = noop; 611 | process.once = noop; 612 | process.off = noop; 613 | process.removeListener = noop; 614 | process.removeAllListeners = noop; 615 | process.emit = noop; 616 | 617 | process.binding = function (name) { 618 | throw new Error('process.binding is not supported'); 619 | }; 620 | 621 | process.cwd = function () { return '/' }; 622 | process.chdir = function (dir) { 623 | throw new Error('process.chdir is not supported'); 624 | }; 625 | process.umask = function() { return 0; }; 626 | 627 | 628 | /***/ }, 629 | /* 6 */ 630 | /***/ function(module, exports, __webpack_require__) { 631 | 632 | 'use strict'; 633 | 634 | /*global ActiveXObject:true*/ 635 | 636 | var defaults = __webpack_require__(2); 637 | var utils = __webpack_require__(3); 638 | var buildUrl = __webpack_require__(7); 639 | var parseHeaders = __webpack_require__(8); 640 | var transformData = __webpack_require__(9); 641 | 642 | module.exports = function xhrAdapter(resolve, reject, config) { 643 | // Transform request data 644 | var data = transformData( 645 | config.data, 646 | config.headers, 647 | config.transformRequest 648 | ); 649 | 650 | // Merge headers 651 | var requestHeaders = utils.merge( 652 | defaults.headers.common, 653 | defaults.headers[config.method] || {}, 654 | config.headers || {} 655 | ); 656 | 657 | if (utils.isFormData(data)) { 658 | // Content-Type needs to be sent in all requests so the mapping template can be applied 659 | //delete requestHeaders['Content-Type']; // Let the browser set it 660 | } 661 | 662 | // Create the request 663 | var request = new (XMLHttpRequest || ActiveXObject)('Microsoft.XMLHTTP'); 664 | request.open(config.method.toUpperCase(), buildUrl(config.url, config.params), true); 665 | 666 | // Set the request timeout in MS 667 | request.timeout = config.timeout; 668 | 669 | // Listen for ready state 670 | request.onreadystatechange = function () { 671 | if (request && request.readyState === 4) { 672 | // Prepare the response 673 | var responseHeaders = parseHeaders(request.getAllResponseHeaders()); 674 | var responseData = ['text', ''].indexOf(config.responseType || '') !== -1 ? request.responseText : request.response; 675 | var response = { 676 | data: transformData( 677 | responseData, 678 | responseHeaders, 679 | config.transformResponse 680 | ), 681 | status: request.status, 682 | statusText: request.statusText, 683 | headers: responseHeaders, 684 | config: config 685 | }; 686 | 687 | // Resolve or reject the Promise based on the status 688 | (request.status >= 200 && request.status < 300 ? 689 | resolve : 690 | reject)(response); 691 | 692 | // Clean up request 693 | request = null; 694 | } 695 | }; 696 | 697 | // Add xsrf header 698 | // This is only done if running in a standard browser environment. 699 | // Specifically not if we're in a web worker, or react-native. 700 | if (utils.isStandardBrowserEnv()) { 701 | var cookies = __webpack_require__(10); 702 | var urlIsSameOrigin = __webpack_require__(11); 703 | 704 | // Add xsrf header 705 | var xsrfValue = urlIsSameOrigin(config.url) ? 706 | cookies.read(config.xsrfCookieName || defaults.xsrfCookieName) : 707 | undefined; 708 | 709 | if (xsrfValue) { 710 | requestHeaders[config.xsrfHeaderName || defaults.xsrfHeaderName] = xsrfValue; 711 | } 712 | } 713 | 714 | // Add headers to the request 715 | utils.forEach(requestHeaders, function (val, key) { 716 | // Remove Content-Type if data is undefined 717 | if (!data && key.toLowerCase() === 'content-type') { 718 | delete requestHeaders[key]; 719 | } 720 | // Otherwise add header to the request 721 | else { 722 | request.setRequestHeader(key, val); 723 | } 724 | }); 725 | 726 | // Add withCredentials to request if needed 727 | if (config.withCredentials) { 728 | request.withCredentials = true; 729 | } 730 | 731 | // Add responseType to request if needed 732 | if (config.responseType) { 733 | try { 734 | request.responseType = config.responseType; 735 | } catch (e) { 736 | if (request.responseType !== 'json') { 737 | throw e; 738 | } 739 | } 740 | } 741 | 742 | if (utils.isArrayBuffer(data)) { 743 | data = new DataView(data); 744 | } 745 | 746 | // Send the request 747 | request.send(data); 748 | }; 749 | 750 | 751 | /***/ }, 752 | /* 7 */ 753 | /***/ function(module, exports, __webpack_require__) { 754 | 755 | 'use strict'; 756 | 757 | var utils = __webpack_require__(3); 758 | 759 | function encode(val) { 760 | return encodeURIComponent(val). 761 | replace(/%40/gi, '@'). 762 | replace(/%3A/gi, ':'). 763 | replace(/%24/g, '$'). 764 | replace(/%2C/gi, ','). 765 | replace(/%20/g, '+'). 766 | replace(/%5B/gi, '['). 767 | replace(/%5D/gi, ']'); 768 | } 769 | 770 | /** 771 | * Build a URL by appending params to the end 772 | * 773 | * @param {string} url The base of the url (e.g., http://www.google.com) 774 | * @param {object} [params] The params to be appended 775 | * @returns {string} The formatted url 776 | */ 777 | module.exports = function buildUrl(url, params) { 778 | if (!params) { 779 | return url; 780 | } 781 | 782 | var parts = []; 783 | 784 | utils.forEach(params, function (val, key) { 785 | if (val === null || typeof val === 'undefined') { 786 | return; 787 | } 788 | 789 | if (utils.isArray(val)) { 790 | key = key + '[]'; 791 | } 792 | 793 | if (!utils.isArray(val)) { 794 | val = [val]; 795 | } 796 | 797 | utils.forEach(val, function (v) { 798 | if (utils.isDate(v)) { 799 | v = v.toISOString(); 800 | } 801 | else if (utils.isObject(v)) { 802 | v = JSON.stringify(v); 803 | } 804 | parts.push(encode(key) + '=' + encode(v)); 805 | }); 806 | }); 807 | 808 | if (parts.length > 0) { 809 | url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&'); 810 | } 811 | 812 | return url; 813 | }; 814 | 815 | 816 | /***/ }, 817 | /* 8 */ 818 | /***/ function(module, exports, __webpack_require__) { 819 | 820 | 'use strict'; 821 | 822 | var utils = __webpack_require__(3); 823 | 824 | /** 825 | * Parse headers into an object 826 | * 827 | * ``` 828 | * Date: Wed, 27 Aug 2014 08:58:49 GMT 829 | * Content-Type: application/json 830 | * Connection: keep-alive 831 | * Transfer-Encoding: chunked 832 | * ``` 833 | * 834 | * @param {String} headers Headers needing to be parsed 835 | * @returns {Object} Headers parsed into an object 836 | */ 837 | module.exports = function parseHeaders(headers) { 838 | var parsed = {}, key, val, i; 839 | 840 | if (!headers) { return parsed; } 841 | 842 | utils.forEach(headers.split('\n'), function(line) { 843 | i = line.indexOf(':'); 844 | key = utils.trim(line.substr(0, i)).toLowerCase(); 845 | val = utils.trim(line.substr(i + 1)); 846 | 847 | if (key) { 848 | parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; 849 | } 850 | }); 851 | 852 | return parsed; 853 | }; 854 | 855 | 856 | /***/ }, 857 | /* 9 */ 858 | /***/ function(module, exports, __webpack_require__) { 859 | 860 | 'use strict'; 861 | 862 | var utils = __webpack_require__(3); 863 | 864 | /** 865 | * Transform the data for a request or a response 866 | * 867 | * @param {Object|String} data The data to be transformed 868 | * @param {Array} headers The headers for the request or response 869 | * @param {Array|Function} fns A single function or Array of functions 870 | * @returns {*} The resulting transformed data 871 | */ 872 | module.exports = function transformData(data, headers, fns) { 873 | utils.forEach(fns, function (fn) { 874 | data = fn(data, headers); 875 | }); 876 | 877 | return data; 878 | }; 879 | 880 | 881 | /***/ }, 882 | /* 10 */ 883 | /***/ function(module, exports, __webpack_require__) { 884 | 885 | 'use strict'; 886 | 887 | /** 888 | * WARNING: 889 | * This file makes references to objects that aren't safe in all environments. 890 | * Please see lib/utils.isStandardBrowserEnv before including this file. 891 | */ 892 | 893 | var utils = __webpack_require__(3); 894 | 895 | module.exports = { 896 | write: function write(name, value, expires, path, domain, secure) { 897 | var cookie = []; 898 | cookie.push(name + '=' + encodeURIComponent(value)); 899 | 900 | if (utils.isNumber(expires)) { 901 | cookie.push('expires=' + new Date(expires).toGMTString()); 902 | } 903 | 904 | if (utils.isString(path)) { 905 | cookie.push('path=' + path); 906 | } 907 | 908 | if (utils.isString(domain)) { 909 | cookie.push('domain=' + domain); 910 | } 911 | 912 | if (secure === true) { 913 | cookie.push('secure'); 914 | } 915 | 916 | document.cookie = cookie.join('; '); 917 | }, 918 | 919 | read: function read(name) { 920 | var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); 921 | return (match ? decodeURIComponent(match[3]) : null); 922 | }, 923 | 924 | remove: function remove(name) { 925 | this.write(name, '', Date.now() - 86400000); 926 | } 927 | }; 928 | 929 | 930 | /***/ }, 931 | /* 11 */ 932 | /***/ function(module, exports, __webpack_require__) { 933 | 934 | 'use strict'; 935 | 936 | /** 937 | * WARNING: 938 | * This file makes references to objects that aren't safe in all environments. 939 | * Please see lib/utils.isStandardBrowserEnv before including this file. 940 | */ 941 | 942 | var utils = __webpack_require__(3); 943 | var msie = /(msie|trident)/i.test(navigator.userAgent); 944 | var urlParsingNode = document.createElement('a'); 945 | var originUrl; 946 | 947 | /** 948 | * Parse a URL to discover it's components 949 | * 950 | * @param {String} url The URL to be parsed 951 | * @returns {Object} 952 | */ 953 | function urlResolve(url) { 954 | var href = url; 955 | 956 | if (msie) { 957 | // IE needs attribute set twice to normalize properties 958 | urlParsingNode.setAttribute('href', href); 959 | href = urlParsingNode.href; 960 | } 961 | 962 | urlParsingNode.setAttribute('href', href); 963 | 964 | // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils 965 | return { 966 | href: urlParsingNode.href, 967 | protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', 968 | host: urlParsingNode.host, 969 | search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', 970 | hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', 971 | hostname: urlParsingNode.hostname, 972 | port: urlParsingNode.port, 973 | pathname: (urlParsingNode.pathname.charAt(0) === '/') ? 974 | urlParsingNode.pathname : 975 | '/' + urlParsingNode.pathname 976 | }; 977 | } 978 | 979 | originUrl = urlResolve(window.location.href); 980 | 981 | /** 982 | * Determine if a URL shares the same origin as the current location 983 | * 984 | * @param {String} requestUrl The URL to test 985 | * @returns {boolean} True if URL shares the same origin, otherwise false 986 | */ 987 | module.exports = function urlIsSameOrigin(requestUrl) { 988 | var parsed = (utils.isString(requestUrl)) ? urlResolve(requestUrl) : requestUrl; 989 | return (parsed.protocol === originUrl.protocol && 990 | parsed.host === originUrl.host); 991 | }; 992 | 993 | 994 | /***/ }, 995 | /* 12 */ 996 | /***/ function(module, exports, __webpack_require__) { 997 | 998 | 'use strict'; 999 | 1000 | var utils = __webpack_require__(3); 1001 | 1002 | function InterceptorManager() { 1003 | this.handlers = []; 1004 | } 1005 | 1006 | /** 1007 | * Add a new interceptor to the stack 1008 | * 1009 | * @param {Function} fulfilled The function to handle `then` for a `Promise` 1010 | * @param {Function} rejected The function to handle `reject` for a `Promise` 1011 | * 1012 | * @return {Number} An ID used to remove interceptor later 1013 | */ 1014 | InterceptorManager.prototype.use = function (fulfilled, rejected) { 1015 | this.handlers.push({ 1016 | fulfilled: fulfilled, 1017 | rejected: rejected 1018 | }); 1019 | return this.handlers.length - 1; 1020 | }; 1021 | 1022 | /** 1023 | * Remove an interceptor from the stack 1024 | * 1025 | * @param {Number} id The ID that was returned by `use` 1026 | */ 1027 | InterceptorManager.prototype.eject = function (id) { 1028 | if (this.handlers[id]) { 1029 | this.handlers[id] = null; 1030 | } 1031 | }; 1032 | 1033 | /** 1034 | * Iterate over all the registered interceptors 1035 | * 1036 | * This method is particularly useful for skipping over any 1037 | * interceptors that may have become `null` calling `remove`. 1038 | * 1039 | * @param {Function} fn The function to call for each interceptor 1040 | */ 1041 | InterceptorManager.prototype.forEach = function (fn) { 1042 | utils.forEach(this.handlers, function (h) { 1043 | if (h !== null) { 1044 | fn(h); 1045 | } 1046 | }); 1047 | }; 1048 | 1049 | module.exports = InterceptorManager; 1050 | 1051 | 1052 | /***/ }, 1053 | /* 13 */ 1054 | /***/ function(module, exports) { 1055 | 1056 | 'use strict'; 1057 | 1058 | /** 1059 | * Syntactic sugar for invoking a function and expanding an array for arguments. 1060 | * 1061 | * Common use case would be to use `Function.prototype.apply`. 1062 | * 1063 | * ```js 1064 | * function f(x, y, z) {} 1065 | * var args = [1, 2, 3]; 1066 | * f.apply(null, args); 1067 | * ``` 1068 | * 1069 | * With `spread` this example can be re-written. 1070 | * 1071 | * ```js 1072 | * spread(function(x, y, z) {})([1, 2, 3]); 1073 | * ``` 1074 | * 1075 | * @param {Function} callback 1076 | * @returns {Function} 1077 | */ 1078 | module.exports = function spread(callback) { 1079 | return function (arr) { 1080 | return callback.apply(null, arr); 1081 | }; 1082 | }; 1083 | 1084 | 1085 | /***/ } 1086 | /******/ ]) 1087 | }); 1088 | ; 1089 | //# sourceMappingURL=axios.map -------------------------------------------------------------------------------- /public/assets/gateway/lib/url-template/url-template.js: -------------------------------------------------------------------------------- 1 | /* 2 | UriTemplates Template Processor - Version: @VERSION - Dated: @DATE 3 | (c) marc.portier@gmail.com - 2011-2012 4 | Licensed under APLv2 (http://opensource.org/licenses/Apache-2.0) 5 | */ 6 | 7 | ; 8 | var uritemplate = (function() { 9 | 10 | // Below are the functions we originally used from jQuery. 11 | // The implementations below are often more naive then what is inside jquery, but they suffice for our needs. 12 | 13 | function isFunction(fn) { 14 | return typeof fn == 'function'; 15 | } 16 | 17 | function isEmptyObject (obj) { 18 | for(var name in obj){ 19 | return false; 20 | } 21 | return true; 22 | } 23 | 24 | function extend(base, newprops) { 25 | for (var name in newprops) { 26 | base[name] = newprops[name]; 27 | } 28 | return base; 29 | } 30 | 31 | /** 32 | * Create a runtime cache around retrieved values from the context. 33 | * This allows for dynamic (function) results to be kept the same for multiple 34 | * occuring expansions within one template. 35 | * Note: Uses key-value tupples to be able to cache null values as well. 36 | */ 37 | //TODO move this into prep-processing 38 | function CachingContext(context) { 39 | this.raw = context; 40 | this.cache = {}; 41 | } 42 | CachingContext.prototype.get = function(key) { 43 | var val = this.lookupRaw(key); 44 | var result = val; 45 | 46 | if (isFunction(val)) { // check function-result-cache 47 | var tupple = this.cache[key]; 48 | if (tupple !== null && tupple !== undefined) { 49 | result = tupple.val; 50 | } else { 51 | result = val(this.raw); 52 | this.cache[key] = {key: key, val: result}; 53 | // NOTE: by storing tupples we make sure a null return is validly consistent too in expansions 54 | } 55 | } 56 | return result; 57 | }; 58 | 59 | CachingContext.prototype.lookupRaw = function(key) { 60 | return CachingContext.lookup(this, this.raw, key); 61 | }; 62 | 63 | CachingContext.lookup = function(me, context, key) { 64 | var result = context[key]; 65 | if (result !== undefined) { 66 | return result; 67 | } else { 68 | var keyparts = key.split('.'); 69 | var i = 0, keysplits = keyparts.length - 1; 70 | for (i = 0; i= 0) { 35 | var v = x*this[i++]+w[j]+c; 36 | c = Math.floor(v/0x4000000); 37 | w[j++] = v&0x3ffffff; 38 | } 39 | return c; 40 | } 41 | // am2 avoids a big mult-and-extract completely. 42 | // Max digit bits should be <= 30 because we do bitwise ops 43 | // on values up to 2*hdvalue^2-hdvalue-1 (< 2^31) 44 | function am2(i,x,w,j,c,n) { 45 | var xl = x&0x7fff, xh = x>>15; 46 | while(--n >= 0) { 47 | var l = this[i]&0x7fff; 48 | var h = this[i++]>>15; 49 | var m = xh*l+h*xl; 50 | l = xl*l+((m&0x7fff)<<15)+w[j]+(c&0x3fffffff); 51 | c = (l>>>30)+(m>>>15)+xh*h+(c>>>30); 52 | w[j++] = l&0x3fffffff; 53 | } 54 | return c; 55 | } 56 | // Alternately, set max digit bits to 28 since some 57 | // browsers slow down when dealing with 32-bit numbers. 58 | function am3(i,x,w,j,c,n) { 59 | var xl = x&0x3fff, xh = x>>14; 60 | while(--n >= 0) { 61 | var l = this[i]&0x3fff; 62 | var h = this[i++]>>14; 63 | var m = xh*l+h*xl; 64 | l = xl*l+((m&0x3fff)<<14)+w[j]+c; 65 | c = (l>>28)+(m>>14)+xh*h; 66 | w[j++] = l&0xfffffff; 67 | } 68 | return c; 69 | } 70 | if(j_lm && (navigator.appName == "Microsoft Internet Explorer")) { 71 | BigInteger.prototype.am = am2; 72 | dbits = 30; 73 | } 74 | else if(j_lm && (navigator.appName != "Netscape")) { 75 | BigInteger.prototype.am = am1; 76 | dbits = 26; 77 | } 78 | else { // Mozilla/Netscape seems to prefer am3 79 | BigInteger.prototype.am = am3; 80 | dbits = 28; 81 | } 82 | 83 | BigInteger.prototype.DB = dbits; 84 | BigInteger.prototype.DM = ((1<= 0; --i) r[i] = this[i]; 112 | r.t = this.t; 113 | r.s = this.s; 114 | } 115 | 116 | // (protected) set from integer value x, -DV <= x < DV 117 | function bnpFromInt(x) { 118 | this.t = 1; 119 | this.s = (x<0)?-1:0; 120 | if(x > 0) this[0] = x; 121 | else if(x < -1) this[0] = x+this.DV; 122 | else this.t = 0; 123 | } 124 | 125 | // return bigint initialized to value 126 | function nbv(i) { var r = nbi(); r.fromInt(i); return r; } 127 | 128 | // (protected) set from string and radix 129 | function bnpFromString(s,b) { 130 | var k; 131 | if(b == 16) k = 4; 132 | else if(b == 8) k = 3; 133 | else if(b == 256) k = 8; // byte array 134 | else if(b == 2) k = 1; 135 | else if(b == 32) k = 5; 136 | else if(b == 4) k = 2; 137 | else { this.fromRadix(s,b); return; } 138 | this.t = 0; 139 | this.s = 0; 140 | var i = s.length, mi = false, sh = 0; 141 | while(--i >= 0) { 142 | var x = (k==8)?s[i]&0xff:intAt(s,i); 143 | if(x < 0) { 144 | if(s.charAt(i) == "-") mi = true; 145 | continue; 146 | } 147 | mi = false; 148 | if(sh == 0) 149 | this[this.t++] = x; 150 | else if(sh+k > this.DB) { 151 | this[this.t-1] |= (x&((1<<(this.DB-sh))-1))<>(this.DB-sh)); 153 | } 154 | else 155 | this[this.t-1] |= x<= this.DB) sh -= this.DB; 158 | } 159 | if(k == 8 && (s[0]&0x80) != 0) { 160 | this.s = -1; 161 | if(sh > 0) this[this.t-1] |= ((1<<(this.DB-sh))-1)< 0 && this[this.t-1] == c) --this.t; 171 | } 172 | 173 | // (public) return string representation in given radix 174 | function bnToString(b) { 175 | if(this.s < 0) return "-"+this.negate().toString(b); 176 | var k; 177 | if(b == 16) k = 4; 178 | else if(b == 8) k = 3; 179 | else if(b == 2) k = 1; 180 | else if(b == 32) k = 5; 181 | else if(b == 4) k = 2; 182 | else return this.toRadix(b); 183 | var km = (1< 0) { 186 | if(p < this.DB && (d = this[i]>>p) > 0) { m = true; r = int2char(d); } 187 | while(i >= 0) { 188 | if(p < k) { 189 | d = (this[i]&((1<>(p+=this.DB-k); 191 | } 192 | else { 193 | d = (this[i]>>(p-=k))&km; 194 | if(p <= 0) { p += this.DB; --i; } 195 | } 196 | if(d > 0) m = true; 197 | if(m) r += int2char(d); 198 | } 199 | } 200 | return m?r:"0"; 201 | } 202 | 203 | // (public) -this 204 | function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; } 205 | 206 | // (public) |this| 207 | function bnAbs() { return (this.s<0)?this.negate():this; } 208 | 209 | // (public) return + if this > a, - if this < a, 0 if equal 210 | function bnCompareTo(a) { 211 | var r = this.s-a.s; 212 | if(r != 0) return r; 213 | var i = this.t; 214 | r = i-a.t; 215 | if(r != 0) return (this.s<0)?-r:r; 216 | while(--i >= 0) if((r=this[i]-a[i]) != 0) return r; 217 | return 0; 218 | } 219 | 220 | // returns bit length of the integer x 221 | function nbits(x) { 222 | var r = 1, t; 223 | if((t=x>>>16) != 0) { x = t; r += 16; } 224 | if((t=x>>8) != 0) { x = t; r += 8; } 225 | if((t=x>>4) != 0) { x = t; r += 4; } 226 | if((t=x>>2) != 0) { x = t; r += 2; } 227 | if((t=x>>1) != 0) { x = t; r += 1; } 228 | return r; 229 | } 230 | 231 | // (public) return the number of bits in "this" 232 | function bnBitLength() { 233 | if(this.t <= 0) return 0; 234 | return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM)); 235 | } 236 | 237 | // (protected) r = this << n*DB 238 | function bnpDLShiftTo(n,r) { 239 | var i; 240 | for(i = this.t-1; i >= 0; --i) r[i+n] = this[i]; 241 | for(i = n-1; i >= 0; --i) r[i] = 0; 242 | r.t = this.t+n; 243 | r.s = this.s; 244 | } 245 | 246 | // (protected) r = this >> n*DB 247 | function bnpDRShiftTo(n,r) { 248 | for(var i = n; i < this.t; ++i) r[i-n] = this[i]; 249 | r.t = Math.max(this.t-n,0); 250 | r.s = this.s; 251 | } 252 | 253 | // (protected) r = this << n 254 | function bnpLShiftTo(n,r) { 255 | var bs = n%this.DB; 256 | var cbs = this.DB-bs; 257 | var bm = (1<= 0; --i) { 260 | r[i+ds+1] = (this[i]>>cbs)|c; 261 | c = (this[i]&bm)<= 0; --i) r[i] = 0; 264 | r[ds] = c; 265 | r.t = this.t+ds+1; 266 | r.s = this.s; 267 | r.clamp(); 268 | } 269 | 270 | // (protected) r = this >> n 271 | function bnpRShiftTo(n,r) { 272 | r.s = this.s; 273 | var ds = Math.floor(n/this.DB); 274 | if(ds >= this.t) { r.t = 0; return; } 275 | var bs = n%this.DB; 276 | var cbs = this.DB-bs; 277 | var bm = (1<>bs; 279 | for(var i = ds+1; i < this.t; ++i) { 280 | r[i-ds-1] |= (this[i]&bm)<>bs; 282 | } 283 | if(bs > 0) r[this.t-ds-1] |= (this.s&bm)<>= this.DB; 295 | } 296 | if(a.t < this.t) { 297 | c -= a.s; 298 | while(i < this.t) { 299 | c += this[i]; 300 | r[i++] = c&this.DM; 301 | c >>= this.DB; 302 | } 303 | c += this.s; 304 | } 305 | else { 306 | c += this.s; 307 | while(i < a.t) { 308 | c -= a[i]; 309 | r[i++] = c&this.DM; 310 | c >>= this.DB; 311 | } 312 | c -= a.s; 313 | } 314 | r.s = (c<0)?-1:0; 315 | if(c < -1) r[i++] = this.DV+c; 316 | else if(c > 0) r[i++] = c; 317 | r.t = i; 318 | r.clamp(); 319 | } 320 | 321 | // (protected) r = this * a, r != this,a (HAC 14.12) 322 | // "this" should be the larger one if appropriate. 323 | function bnpMultiplyTo(a,r) { 324 | var x = this.abs(), y = a.abs(); 325 | var i = x.t; 326 | r.t = i+y.t; 327 | while(--i >= 0) r[i] = 0; 328 | for(i = 0; i < y.t; ++i) r[i+x.t] = x.am(0,y[i],r,i,0,x.t); 329 | r.s = 0; 330 | r.clamp(); 331 | if(this.s != a.s) BigInteger.ZERO.subTo(r,r); 332 | } 333 | 334 | // (protected) r = this^2, r != this (HAC 14.16) 335 | function bnpSquareTo(r) { 336 | var x = this.abs(); 337 | var i = r.t = 2*x.t; 338 | while(--i >= 0) r[i] = 0; 339 | for(i = 0; i < x.t-1; ++i) { 340 | var c = x.am(i,x[i],r,2*i,0,1); 341 | if((r[i+x.t]+=x.am(i+1,2*x[i],r,2*i+1,c,x.t-i-1)) >= x.DV) { 342 | r[i+x.t] -= x.DV; 343 | r[i+x.t+1] = 1; 344 | } 345 | } 346 | if(r.t > 0) r[r.t-1] += x.am(i,x[i],r,2*i,0,1); 347 | r.s = 0; 348 | r.clamp(); 349 | } 350 | 351 | // (protected) divide this by m, quotient and remainder to q, r (HAC 14.20) 352 | // r != q, this != m. q or r may be null. 353 | function bnpDivRemTo(m,q,r) { 354 | var pm = m.abs(); 355 | if(pm.t <= 0) return; 356 | var pt = this.abs(); 357 | if(pt.t < pm.t) { 358 | if(q != null) q.fromInt(0); 359 | if(r != null) this.copyTo(r); 360 | return; 361 | } 362 | if(r == null) r = nbi(); 363 | var y = nbi(), ts = this.s, ms = m.s; 364 | var nsh = this.DB-nbits(pm[pm.t-1]); // normalize modulus 365 | if(nsh > 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); } 366 | else { pm.copyTo(y); pt.copyTo(r); } 367 | var ys = y.t; 368 | var y0 = y[ys-1]; 369 | if(y0 == 0) return; 370 | var yt = y0*(1<1)?y[ys-2]>>this.F2:0); 371 | var d1 = this.FV/yt, d2 = (1<= 0) { 375 | r[r.t++] = 1; 376 | r.subTo(t,r); 377 | } 378 | BigInteger.ONE.dlShiftTo(ys,t); 379 | t.subTo(y,y); // "negative" y so we can replace sub with am later 380 | while(y.t < ys) y[y.t++] = 0; 381 | while(--j >= 0) { 382 | // Estimate quotient digit 383 | var qd = (r[--i]==y0)?this.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2); 384 | if((r[i]+=y.am(0,qd,r,j,0,ys)) < qd) { // Try it out 385 | y.dlShiftTo(j,t); 386 | r.subTo(t,r); 387 | while(r[i] < --qd) r.subTo(t,r); 388 | } 389 | } 390 | if(q != null) { 391 | r.drShiftTo(ys,q); 392 | if(ts != ms) BigInteger.ZERO.subTo(q,q); 393 | } 394 | r.t = ys; 395 | r.clamp(); 396 | if(nsh > 0) r.rShiftTo(nsh,r); // Denormalize remainder 397 | if(ts < 0) BigInteger.ZERO.subTo(r,r); 398 | } 399 | 400 | // (public) this mod a 401 | function bnMod(a) { 402 | var r = nbi(); 403 | this.abs().divRemTo(a,null,r); 404 | if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r,r); 405 | return r; 406 | } 407 | 408 | // Modular reduction using "classic" algorithm 409 | function Classic(m) { this.m = m; } 410 | function cConvert(x) { 411 | if(x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m); 412 | else return x; 413 | } 414 | function cRevert(x) { return x; } 415 | function cReduce(x) { x.divRemTo(this.m,null,x); } 416 | function cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); } 417 | function cSqrTo(x,r) { x.squareTo(r); this.reduce(r); } 418 | 419 | Classic.prototype.convert = cConvert; 420 | Classic.prototype.revert = cRevert; 421 | Classic.prototype.reduce = cReduce; 422 | Classic.prototype.mulTo = cMulTo; 423 | Classic.prototype.sqrTo = cSqrTo; 424 | 425 | // (protected) return "-1/this % 2^DB"; useful for Mont. reduction 426 | // justification: 427 | // xy == 1 (mod m) 428 | // xy = 1+km 429 | // xy(2-xy) = (1+km)(1-km) 430 | // x[y(2-xy)] = 1-k^2m^2 431 | // x[y(2-xy)] == 1 (mod m^2) 432 | // if y is 1/x mod m, then y(2-xy) is 1/x mod m^2 433 | // should reduce x and y(2-xy) by m^2 at each step to keep size bounded. 434 | // JS multiply "overflows" differently from C/C++, so care is needed here. 435 | function bnpInvDigit() { 436 | if(this.t < 1) return 0; 437 | var x = this[0]; 438 | if((x&1) == 0) return 0; 439 | var y = x&3; // y == 1/x mod 2^2 440 | y = (y*(2-(x&0xf)*y))&0xf; // y == 1/x mod 2^4 441 | y = (y*(2-(x&0xff)*y))&0xff; // y == 1/x mod 2^8 442 | y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff; // y == 1/x mod 2^16 443 | // last step - calculate inverse mod DV directly; 444 | // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints 445 | y = (y*(2-x*y%this.DV))%this.DV; // y == 1/x mod 2^dbits 446 | // we really want the negative inverse, and -DV < y < DV 447 | return (y>0)?this.DV-y:-y; 448 | } 449 | 450 | // Montgomery reduction 451 | function Montgomery(m) { 452 | this.m = m; 453 | this.mp = m.invDigit(); 454 | this.mpl = this.mp&0x7fff; 455 | this.mph = this.mp>>15; 456 | this.um = (1<<(m.DB-15))-1; 457 | this.mt2 = 2*m.t; 458 | } 459 | 460 | // xR mod m 461 | function montConvert(x) { 462 | var r = nbi(); 463 | x.abs().dlShiftTo(this.m.t,r); 464 | r.divRemTo(this.m,null,r); 465 | if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r,r); 466 | return r; 467 | } 468 | 469 | // x/R mod m 470 | function montRevert(x) { 471 | var r = nbi(); 472 | x.copyTo(r); 473 | this.reduce(r); 474 | return r; 475 | } 476 | 477 | // x = x/R mod m (HAC 14.32) 478 | function montReduce(x) { 479 | while(x.t <= this.mt2) // pad x so am has enough room later 480 | x[x.t++] = 0; 481 | for(var i = 0; i < this.m.t; ++i) { 482 | // faster way of calculating u0 = x[i]*mp mod DV 483 | var j = x[i]&0x7fff; 484 | var u0 = (j*this.mpl+(((j*this.mph+(x[i]>>15)*this.mpl)&this.um)<<15))&x.DM; 485 | // use am to combine the multiply-shift-add into one call 486 | j = i+this.m.t; 487 | x[j] += this.m.am(0,u0,x,i,0,this.m.t); 488 | // propagate carry 489 | while(x[j] >= x.DV) { x[j] -= x.DV; x[++j]++; } 490 | } 491 | x.clamp(); 492 | x.drShiftTo(this.m.t,x); 493 | if(x.compareTo(this.m) >= 0) x.subTo(this.m,x); 494 | } 495 | 496 | // r = "x^2/R mod m"; x != r 497 | function montSqrTo(x,r) { x.squareTo(r); this.reduce(r); } 498 | 499 | // r = "xy/R mod m"; x,y != r 500 | function montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); } 501 | 502 | Montgomery.prototype.convert = montConvert; 503 | Montgomery.prototype.revert = montRevert; 504 | Montgomery.prototype.reduce = montReduce; 505 | Montgomery.prototype.mulTo = montMulTo; 506 | Montgomery.prototype.sqrTo = montSqrTo; 507 | 508 | // (protected) true iff this is even 509 | function bnpIsEven() { return ((this.t>0)?(this[0]&1):this.s) == 0; } 510 | 511 | // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79) 512 | function bnpExp(e,z) { 513 | if(e > 0xffffffff || e < 1) return BigInteger.ONE; 514 | var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1; 515 | g.copyTo(r); 516 | while(--i >= 0) { 517 | z.sqrTo(r,r2); 518 | if((e&(1< 0) z.mulTo(r2,g,r); 519 | else { var t = r; r = r2; r2 = t; } 520 | } 521 | return z.revert(r); 522 | } 523 | 524 | // (public) this^e % m, 0 <= e < 2^32 525 | function bnModPowInt(e,m) { 526 | var z; 527 | if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m); 528 | return this.exp(e,z); 529 | } 530 | 531 | // protected 532 | BigInteger.prototype.copyTo = bnpCopyTo; 533 | BigInteger.prototype.fromInt = bnpFromInt; 534 | BigInteger.prototype.fromString = bnpFromString; 535 | BigInteger.prototype.clamp = bnpClamp; 536 | BigInteger.prototype.dlShiftTo = bnpDLShiftTo; 537 | BigInteger.prototype.drShiftTo = bnpDRShiftTo; 538 | BigInteger.prototype.lShiftTo = bnpLShiftTo; 539 | BigInteger.prototype.rShiftTo = bnpRShiftTo; 540 | BigInteger.prototype.subTo = bnpSubTo; 541 | BigInteger.prototype.multiplyTo = bnpMultiplyTo; 542 | BigInteger.prototype.squareTo = bnpSquareTo; 543 | BigInteger.prototype.divRemTo = bnpDivRemTo; 544 | BigInteger.prototype.invDigit = bnpInvDigit; 545 | BigInteger.prototype.isEven = bnpIsEven; 546 | BigInteger.prototype.exp = bnpExp; 547 | 548 | // public 549 | BigInteger.prototype.toString = bnToString; 550 | BigInteger.prototype.negate = bnNegate; 551 | BigInteger.prototype.abs = bnAbs; 552 | BigInteger.prototype.compareTo = bnCompareTo; 553 | BigInteger.prototype.bitLength = bnBitLength; 554 | BigInteger.prototype.mod = bnMod; 555 | BigInteger.prototype.modPowInt = bnModPowInt; 556 | 557 | // "constants" 558 | BigInteger.ZERO = nbv(0); 559 | BigInteger.ONE = nbv(1); 560 | -------------------------------------------------------------------------------- /public/assets/jsbn2.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2005-2009 Tom Wu 2 | // All Rights Reserved. 3 | // See "LICENSE" for details. 4 | 5 | // Extended JavaScript BN functions, required for RSA private ops. 6 | 7 | // Version 1.1: new BigInteger("0", 10) returns "proper" zero 8 | // Version 1.2: square() API, isProbablePrime fix 9 | 10 | // (public) 11 | function bnClone() { var r = nbi(); this.copyTo(r); return r; } 12 | 13 | // (public) return value as integer 14 | function bnIntValue() { 15 | if(this.s < 0) { 16 | if(this.t == 1) return this[0]-this.DV; 17 | else if(this.t == 0) return -1; 18 | } 19 | else if(this.t == 1) return this[0]; 20 | else if(this.t == 0) return 0; 21 | // assumes 16 < DB < 32 22 | return ((this[1]&((1<<(32-this.DB))-1))<>24; } 27 | 28 | // (public) return value as short (assumes DB>=16) 29 | function bnShortValue() { return (this.t==0)?this.s:(this[0]<<16)>>16; } 30 | 31 | // (protected) return x s.t. r^x < DV 32 | function bnpChunkSize(r) { return Math.floor(Math.LN2*this.DB/Math.log(r)); } 33 | 34 | // (public) 0 if this == 0, 1 if this > 0 35 | function bnSigNum() { 36 | if(this.s < 0) return -1; 37 | else if(this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0; 38 | else return 1; 39 | } 40 | 41 | // (protected) convert to radix string 42 | function bnpToRadix(b) { 43 | if(b == null) b = 10; 44 | if(this.signum() == 0 || b < 2 || b > 36) return "0"; 45 | var cs = this.chunkSize(b); 46 | var a = Math.pow(b,cs); 47 | var d = nbv(a), y = nbi(), z = nbi(), r = ""; 48 | this.divRemTo(d,y,z); 49 | while(y.signum() > 0) { 50 | r = (a+z.intValue()).toString(b).substr(1) + r; 51 | y.divRemTo(d,y,z); 52 | } 53 | return z.intValue().toString(b) + r; 54 | } 55 | 56 | // (protected) convert from radix string 57 | function bnpFromRadix(s,b) { 58 | this.fromInt(0); 59 | if(b == null) b = 10; 60 | var cs = this.chunkSize(b); 61 | var d = Math.pow(b,cs), mi = false, j = 0, w = 0; 62 | for(var i = 0; i < s.length; ++i) { 63 | var x = intAt(s,i); 64 | if(x < 0) { 65 | if(s.charAt(i) == "-" && this.signum() == 0) mi = true; 66 | continue; 67 | } 68 | w = b*w+x; 69 | if(++j >= cs) { 70 | this.dMultiply(d); 71 | this.dAddOffset(w,0); 72 | j = 0; 73 | w = 0; 74 | } 75 | } 76 | if(j > 0) { 77 | this.dMultiply(Math.pow(b,j)); 78 | this.dAddOffset(w,0); 79 | } 80 | if(mi) BigInteger.ZERO.subTo(this,this); 81 | } 82 | 83 | // (protected) alternate constructor 84 | function bnpFromNumber(a,b,c) { 85 | if("number" == typeof b) { 86 | // new BigInteger(int,int,RNG) 87 | if(a < 2) this.fromInt(1); 88 | else { 89 | this.fromNumber(a,c); 90 | if(!this.testBit(a-1)) // force MSB set 91 | this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this); 92 | if(this.isEven()) this.dAddOffset(1,0); // force odd 93 | while(!this.isProbablePrime(b)) { 94 | this.dAddOffset(2,0); 95 | if(this.bitLength() > a) this.subTo(BigInteger.ONE.shiftLeft(a-1),this); 96 | } 97 | } 98 | } 99 | else { 100 | // new BigInteger(int,RNG) 101 | var x = new Array(), t = a&7; 102 | x.length = (a>>3)+1; 103 | b.nextBytes(x); 104 | if(t > 0) x[0] &= ((1< 0) { 115 | if(p < this.DB && (d = this[i]>>p) != (this.s&this.DM)>>p) 116 | r[k++] = d|(this.s<<(this.DB-p)); 117 | while(i >= 0) { 118 | if(p < 8) { 119 | d = (this[i]&((1<>(p+=this.DB-8); 121 | } 122 | else { 123 | d = (this[i]>>(p-=8))&0xff; 124 | if(p <= 0) { p += this.DB; --i; } 125 | } 126 | if((d&0x80) != 0) d |= -256; 127 | if(k == 0 && (this.s&0x80) != (d&0x80)) ++k; 128 | if(k > 0 || d != this.s) r[k++] = d; 129 | } 130 | } 131 | return r; 132 | } 133 | 134 | function bnEquals(a) { return(this.compareTo(a)==0); } 135 | function bnMin(a) { return(this.compareTo(a)<0)?this:a; } 136 | function bnMax(a) { return(this.compareTo(a)>0)?this:a; } 137 | 138 | // (protected) r = this op a (bitwise) 139 | function bnpBitwiseTo(a,op,r) { 140 | var i, f, m = Math.min(a.t,this.t); 141 | for(i = 0; i < m; ++i) r[i] = op(this[i],a[i]); 142 | if(a.t < this.t) { 143 | f = a.s&this.DM; 144 | for(i = m; i < this.t; ++i) r[i] = op(this[i],f); 145 | r.t = this.t; 146 | } 147 | else { 148 | f = this.s&this.DM; 149 | for(i = m; i < a.t; ++i) r[i] = op(f,a[i]); 150 | r.t = a.t; 151 | } 152 | r.s = op(this.s,a.s); 153 | r.clamp(); 154 | } 155 | 156 | // (public) this & a 157 | function op_and(x,y) { return x&y; } 158 | function bnAnd(a) { var r = nbi(); this.bitwiseTo(a,op_and,r); return r; } 159 | 160 | // (public) this | a 161 | function op_or(x,y) { return x|y; } 162 | function bnOr(a) { var r = nbi(); this.bitwiseTo(a,op_or,r); return r; } 163 | 164 | // (public) this ^ a 165 | function op_xor(x,y) { return x^y; } 166 | function bnXor(a) { var r = nbi(); this.bitwiseTo(a,op_xor,r); return r; } 167 | 168 | // (public) this & ~a 169 | function op_andnot(x,y) { return x&~y; } 170 | function bnAndNot(a) { var r = nbi(); this.bitwiseTo(a,op_andnot,r); return r; } 171 | 172 | // (public) ~this 173 | function bnNot() { 174 | var r = nbi(); 175 | for(var i = 0; i < this.t; ++i) r[i] = this.DM&~this[i]; 176 | r.t = this.t; 177 | r.s = ~this.s; 178 | return r; 179 | } 180 | 181 | // (public) this << n 182 | function bnShiftLeft(n) { 183 | var r = nbi(); 184 | if(n < 0) this.rShiftTo(-n,r); else this.lShiftTo(n,r); 185 | return r; 186 | } 187 | 188 | // (public) this >> n 189 | function bnShiftRight(n) { 190 | var r = nbi(); 191 | if(n < 0) this.lShiftTo(-n,r); else this.rShiftTo(n,r); 192 | return r; 193 | } 194 | 195 | // return index of lowest 1-bit in x, x < 2^31 196 | function lbit(x) { 197 | if(x == 0) return -1; 198 | var r = 0; 199 | if((x&0xffff) == 0) { x >>= 16; r += 16; } 200 | if((x&0xff) == 0) { x >>= 8; r += 8; } 201 | if((x&0xf) == 0) { x >>= 4; r += 4; } 202 | if((x&3) == 0) { x >>= 2; r += 2; } 203 | if((x&1) == 0) ++r; 204 | return r; 205 | } 206 | 207 | // (public) returns index of lowest 1-bit (or -1 if none) 208 | function bnGetLowestSetBit() { 209 | for(var i = 0; i < this.t; ++i) 210 | if(this[i] != 0) return i*this.DB+lbit(this[i]); 211 | if(this.s < 0) return this.t*this.DB; 212 | return -1; 213 | } 214 | 215 | // return number of 1 bits in x 216 | function cbit(x) { 217 | var r = 0; 218 | while(x != 0) { x &= x-1; ++r; } 219 | return r; 220 | } 221 | 222 | // (public) return number of set bits 223 | function bnBitCount() { 224 | var r = 0, x = this.s&this.DM; 225 | for(var i = 0; i < this.t; ++i) r += cbit(this[i]^x); 226 | return r; 227 | } 228 | 229 | // (public) true iff nth bit is set 230 | function bnTestBit(n) { 231 | var j = Math.floor(n/this.DB); 232 | if(j >= this.t) return(this.s!=0); 233 | return((this[j]&(1<<(n%this.DB)))!=0); 234 | } 235 | 236 | // (protected) this op (1<>= this.DB; 259 | } 260 | if(a.t < this.t) { 261 | c += a.s; 262 | while(i < this.t) { 263 | c += this[i]; 264 | r[i++] = c&this.DM; 265 | c >>= this.DB; 266 | } 267 | c += this.s; 268 | } 269 | else { 270 | c += this.s; 271 | while(i < a.t) { 272 | c += a[i]; 273 | r[i++] = c&this.DM; 274 | c >>= this.DB; 275 | } 276 | c += a.s; 277 | } 278 | r.s = (c<0)?-1:0; 279 | if(c > 0) r[i++] = c; 280 | else if(c < -1) r[i++] = this.DV+c; 281 | r.t = i; 282 | r.clamp(); 283 | } 284 | 285 | // (public) this + a 286 | function bnAdd(a) { var r = nbi(); this.addTo(a,r); return r; } 287 | 288 | // (public) this - a 289 | function bnSubtract(a) { var r = nbi(); this.subTo(a,r); return r; } 290 | 291 | // (public) this * a 292 | function bnMultiply(a) { var r = nbi(); this.multiplyTo(a,r); return r; } 293 | 294 | // (public) this^2 295 | function bnSquare() { var r = nbi(); this.squareTo(r); return r; } 296 | 297 | // (public) this / a 298 | function bnDivide(a) { var r = nbi(); this.divRemTo(a,r,null); return r; } 299 | 300 | // (public) this % a 301 | function bnRemainder(a) { var r = nbi(); this.divRemTo(a,null,r); return r; } 302 | 303 | // (public) [this/a,this%a] 304 | function bnDivideAndRemainder(a) { 305 | var q = nbi(), r = nbi(); 306 | this.divRemTo(a,q,r); 307 | return new Array(q,r); 308 | } 309 | 310 | // (protected) this *= n, this >= 0, 1 < n < DV 311 | function bnpDMultiply(n) { 312 | this[this.t] = this.am(0,n-1,this,0,0,this.t); 313 | ++this.t; 314 | this.clamp(); 315 | } 316 | 317 | // (protected) this += n << w words, this >= 0 318 | function bnpDAddOffset(n,w) { 319 | if(n == 0) return; 320 | while(this.t <= w) this[this.t++] = 0; 321 | this[w] += n; 322 | while(this[w] >= this.DV) { 323 | this[w] -= this.DV; 324 | if(++w >= this.t) this[this.t++] = 0; 325 | ++this[w]; 326 | } 327 | } 328 | 329 | // A "null" reducer 330 | function NullExp() {} 331 | function nNop(x) { return x; } 332 | function nMulTo(x,y,r) { x.multiplyTo(y,r); } 333 | function nSqrTo(x,r) { x.squareTo(r); } 334 | 335 | NullExp.prototype.convert = nNop; 336 | NullExp.prototype.revert = nNop; 337 | NullExp.prototype.mulTo = nMulTo; 338 | NullExp.prototype.sqrTo = nSqrTo; 339 | 340 | // (public) this^e 341 | function bnPow(e) { return this.exp(e,new NullExp()); } 342 | 343 | // (protected) r = lower n words of "this * a", a.t <= n 344 | // "this" should be the larger one if appropriate. 345 | function bnpMultiplyLowerTo(a,n,r) { 346 | var i = Math.min(this.t+a.t,n); 347 | r.s = 0; // assumes a,this >= 0 348 | r.t = i; 349 | while(i > 0) r[--i] = 0; 350 | var j; 351 | for(j = r.t-this.t; i < j; ++i) r[i+this.t] = this.am(0,a[i],r,i,0,this.t); 352 | for(j = Math.min(a.t,n); i < j; ++i) this.am(0,a[i],r,i,0,n-i); 353 | r.clamp(); 354 | } 355 | 356 | // (protected) r = "this * a" without lower n words, n > 0 357 | // "this" should be the larger one if appropriate. 358 | function bnpMultiplyUpperTo(a,n,r) { 359 | --n; 360 | var i = r.t = this.t+a.t-n; 361 | r.s = 0; // assumes a,this >= 0 362 | while(--i >= 0) r[i] = 0; 363 | for(i = Math.max(n-this.t,0); i < a.t; ++i) 364 | r[this.t+i-n] = this.am(n-i,a[i],r,0,0,this.t+i-n); 365 | r.clamp(); 366 | r.drShiftTo(1,r); 367 | } 368 | 369 | // Barrett modular reduction 370 | function Barrett(m) { 371 | // setup Barrett 372 | this.r2 = nbi(); 373 | this.q3 = nbi(); 374 | BigInteger.ONE.dlShiftTo(2*m.t,this.r2); 375 | this.mu = this.r2.divide(m); 376 | this.m = m; 377 | } 378 | 379 | function barrettConvert(x) { 380 | if(x.s < 0 || x.t > 2*this.m.t) return x.mod(this.m); 381 | else if(x.compareTo(this.m) < 0) return x; 382 | else { var r = nbi(); x.copyTo(r); this.reduce(r); return r; } 383 | } 384 | 385 | function barrettRevert(x) { return x; } 386 | 387 | // x = x mod m (HAC 14.42) 388 | function barrettReduce(x) { 389 | x.drShiftTo(this.m.t-1,this.r2); 390 | if(x.t > this.m.t+1) { x.t = this.m.t+1; x.clamp(); } 391 | this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3); 392 | this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2); 393 | while(x.compareTo(this.r2) < 0) x.dAddOffset(1,this.m.t+1); 394 | x.subTo(this.r2,x); 395 | while(x.compareTo(this.m) >= 0) x.subTo(this.m,x); 396 | } 397 | 398 | // r = x^2 mod m; x != r 399 | function barrettSqrTo(x,r) { x.squareTo(r); this.reduce(r); } 400 | 401 | // r = x*y mod m; x,y != r 402 | function barrettMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); } 403 | 404 | Barrett.prototype.convert = barrettConvert; 405 | Barrett.prototype.revert = barrettRevert; 406 | Barrett.prototype.reduce = barrettReduce; 407 | Barrett.prototype.mulTo = barrettMulTo; 408 | Barrett.prototype.sqrTo = barrettSqrTo; 409 | 410 | // (public) this^e % m (HAC 14.85) 411 | function bnModPow(e,m) { 412 | var i = e.bitLength(), k, r = nbv(1), z; 413 | if(i <= 0) return r; 414 | else if(i < 18) k = 1; 415 | else if(i < 48) k = 3; 416 | else if(i < 144) k = 4; 417 | else if(i < 768) k = 5; 418 | else k = 6; 419 | if(i < 8) 420 | z = new Classic(m); 421 | else if(m.isEven()) 422 | z = new Barrett(m); 423 | else 424 | z = new Montgomery(m); 425 | 426 | // precomputation 427 | var g = new Array(), n = 3, k1 = k-1, km = (1< 1) { 430 | var g2 = nbi(); 431 | z.sqrTo(g[1],g2); 432 | while(n <= km) { 433 | g[n] = nbi(); 434 | z.mulTo(g2,g[n-2],g[n]); 435 | n += 2; 436 | } 437 | } 438 | 439 | var j = e.t-1, w, is1 = true, r2 = nbi(), t; 440 | i = nbits(e[j])-1; 441 | while(j >= 0) { 442 | if(i >= k1) w = (e[j]>>(i-k1))&km; 443 | else { 444 | w = (e[j]&((1<<(i+1))-1))<<(k1-i); 445 | if(j > 0) w |= e[j-1]>>(this.DB+i-k1); 446 | } 447 | 448 | n = k; 449 | while((w&1) == 0) { w >>= 1; --n; } 450 | if((i -= n) < 0) { i += this.DB; --j; } 451 | if(is1) { // ret == 1, don't bother squaring or multiplying it 452 | g[w].copyTo(r); 453 | is1 = false; 454 | } 455 | else { 456 | while(n > 1) { z.sqrTo(r,r2); z.sqrTo(r2,r); n -= 2; } 457 | if(n > 0) z.sqrTo(r,r2); else { t = r; r = r2; r2 = t; } 458 | z.mulTo(r2,g[w],r); 459 | } 460 | 461 | while(j >= 0 && (e[j]&(1< 0) { 478 | x.rShiftTo(g,x); 479 | y.rShiftTo(g,y); 480 | } 481 | while(x.signum() > 0) { 482 | if((i = x.getLowestSetBit()) > 0) x.rShiftTo(i,x); 483 | if((i = y.getLowestSetBit()) > 0) y.rShiftTo(i,y); 484 | if(x.compareTo(y) >= 0) { 485 | x.subTo(y,x); 486 | x.rShiftTo(1,x); 487 | } 488 | else { 489 | y.subTo(x,y); 490 | y.rShiftTo(1,y); 491 | } 492 | } 493 | if(g > 0) y.lShiftTo(g,y); 494 | return y; 495 | } 496 | 497 | // (protected) this % n, n < 2^26 498 | function bnpModInt(n) { 499 | if(n <= 0) return 0; 500 | var d = this.DV%n, r = (this.s<0)?n-1:0; 501 | if(this.t > 0) 502 | if(d == 0) r = this[0]%n; 503 | else for(var i = this.t-1; i >= 0; --i) r = (d*r+this[i])%n; 504 | return r; 505 | } 506 | 507 | // (public) 1/this % m (HAC 14.61) 508 | function bnModInverse(m) { 509 | var ac = m.isEven(); 510 | if((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO; 511 | var u = m.clone(), v = this.clone(); 512 | var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1); 513 | while(u.signum() != 0) { 514 | while(u.isEven()) { 515 | u.rShiftTo(1,u); 516 | if(ac) { 517 | if(!a.isEven() || !b.isEven()) { a.addTo(this,a); b.subTo(m,b); } 518 | a.rShiftTo(1,a); 519 | } 520 | else if(!b.isEven()) b.subTo(m,b); 521 | b.rShiftTo(1,b); 522 | } 523 | while(v.isEven()) { 524 | v.rShiftTo(1,v); 525 | if(ac) { 526 | if(!c.isEven() || !d.isEven()) { c.addTo(this,c); d.subTo(m,d); } 527 | c.rShiftTo(1,c); 528 | } 529 | else if(!d.isEven()) d.subTo(m,d); 530 | d.rShiftTo(1,d); 531 | } 532 | if(u.compareTo(v) >= 0) { 533 | u.subTo(v,u); 534 | if(ac) a.subTo(c,a); 535 | b.subTo(d,b); 536 | } 537 | else { 538 | v.subTo(u,v); 539 | if(ac) c.subTo(a,c); 540 | d.subTo(b,d); 541 | } 542 | } 543 | if(v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO; 544 | if(d.compareTo(m) >= 0) return d.subtract(m); 545 | if(d.signum() < 0) d.addTo(m,d); else return d; 546 | if(d.signum() < 0) return d.add(m); else return d; 547 | } 548 | 549 | var lowprimes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997]; 550 | var lplim = (1<<26)/lowprimes[lowprimes.length-1]; 551 | 552 | // (public) test primality with certainty >= 1-.5^t 553 | function bnIsProbablePrime(t) { 554 | var i, x = this.abs(); 555 | if(x.t == 1 && x[0] <= lowprimes[lowprimes.length-1]) { 556 | for(i = 0; i < lowprimes.length; ++i) 557 | if(x[0] == lowprimes[i]) return true; 558 | return false; 559 | } 560 | if(x.isEven()) return false; 561 | i = 1; 562 | while(i < lowprimes.length) { 563 | var m = lowprimes[i], j = i+1; 564 | while(j < lowprimes.length && m < lplim) m *= lowprimes[j++]; 565 | m = x.modInt(m); 566 | while(i < j) if(m%lowprimes[i++] == 0) return false; 567 | } 568 | return x.millerRabin(t); 569 | } 570 | 571 | // (protected) true if probably prime (HAC 4.24, Miller-Rabin) 572 | function bnpMillerRabin(t) { 573 | var n1 = this.subtract(BigInteger.ONE); 574 | var k = n1.getLowestSetBit(); 575 | if(k <= 0) return false; 576 | var r = n1.shiftRight(k); 577 | t = (t+1)>>1; 578 | if(t > lowprimes.length) t = lowprimes.length; 579 | var a = nbi(); 580 | for(var i = 0; i < t; ++i) { 581 | //Pick bases at random, instead of starting at 2 582 | a.fromInt(lowprimes[Math.floor(Math.random()*lowprimes.length)]); 583 | var y = a.modPow(r,this); 584 | if(y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) { 585 | var j = 1; 586 | while(j++ < k && y.compareTo(n1) != 0) { 587 | y = y.modPowInt(2,this); 588 | if(y.compareTo(BigInteger.ONE) == 0) return false; 589 | } 590 | if(y.compareTo(n1) != 0) return false; 591 | } 592 | } 593 | return true; 594 | } 595 | 596 | // protected 597 | BigInteger.prototype.chunkSize = bnpChunkSize; 598 | BigInteger.prototype.toRadix = bnpToRadix; 599 | BigInteger.prototype.fromRadix = bnpFromRadix; 600 | BigInteger.prototype.fromNumber = bnpFromNumber; 601 | BigInteger.prototype.bitwiseTo = bnpBitwiseTo; 602 | BigInteger.prototype.changeBit = bnpChangeBit; 603 | BigInteger.prototype.addTo = bnpAddTo; 604 | BigInteger.prototype.dMultiply = bnpDMultiply; 605 | BigInteger.prototype.dAddOffset = bnpDAddOffset; 606 | BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo; 607 | BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo; 608 | BigInteger.prototype.modInt = bnpModInt; 609 | BigInteger.prototype.millerRabin = bnpMillerRabin; 610 | 611 | // public 612 | BigInteger.prototype.clone = bnClone; 613 | BigInteger.prototype.intValue = bnIntValue; 614 | BigInteger.prototype.byteValue = bnByteValue; 615 | BigInteger.prototype.shortValue = bnShortValue; 616 | BigInteger.prototype.signum = bnSigNum; 617 | BigInteger.prototype.toByteArray = bnToByteArray; 618 | BigInteger.prototype.equals = bnEquals; 619 | BigInteger.prototype.min = bnMin; 620 | BigInteger.prototype.max = bnMax; 621 | BigInteger.prototype.and = bnAnd; 622 | BigInteger.prototype.or = bnOr; 623 | BigInteger.prototype.xor = bnXor; 624 | BigInteger.prototype.andNot = bnAndNot; 625 | BigInteger.prototype.not = bnNot; 626 | BigInteger.prototype.shiftLeft = bnShiftLeft; 627 | BigInteger.prototype.shiftRight = bnShiftRight; 628 | BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit; 629 | BigInteger.prototype.bitCount = bnBitCount; 630 | BigInteger.prototype.testBit = bnTestBit; 631 | BigInteger.prototype.setBit = bnSetBit; 632 | BigInteger.prototype.clearBit = bnClearBit; 633 | BigInteger.prototype.flipBit = bnFlipBit; 634 | BigInteger.prototype.add = bnAdd; 635 | BigInteger.prototype.subtract = bnSubtract; 636 | BigInteger.prototype.multiply = bnMultiply; 637 | BigInteger.prototype.divide = bnDivide; 638 | BigInteger.prototype.remainder = bnRemainder; 639 | BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder; 640 | BigInteger.prototype.modPow = bnModPow; 641 | BigInteger.prototype.modInverse = bnModInverse; 642 | BigInteger.prototype.pow = bnPow; 643 | BigInteger.prototype.gcd = bnGCD; 644 | BigInteger.prototype.isProbablePrime = bnIsProbablePrime; 645 | 646 | // JSBN-specific extension 647 | BigInteger.prototype.square = bnSquare; 648 | 649 | // BigInteger interfaces not implemented in jsbn: 650 | 651 | // BigInteger(int signum, byte[] magnitude) 652 | // double doubleValue() 653 | // float floatValue() 654 | // int hashCode() 655 | // long longValue() 656 | // static BigInteger valueOf(long val) 657 | -------------------------------------------------------------------------------- /public/assets/sjcl.js: -------------------------------------------------------------------------------- 1 | "use strict";var sjcl={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(a){this.toString=function(){return"CORRUPT: "+this.message};this.message=a},invalid:function(a){this.toString=function(){return"INVALID: "+this.message};this.message=a},bug:function(a){this.toString=function(){return"BUG: "+this.message};this.message=a},notReady:function(a){this.toString=function(){return"NOT READY: "+this.message};this.message=a}}}; 2 | "undefined"!==typeof module&&module.exports&&(module.exports=sjcl);"function"===typeof define&&define([],function(){return sjcl}); 3 | sjcl.cipher.aes=function(a){this.s[0][0][0]||this.O();var b,c,d,e,f=this.s[0][4],g=this.s[1];b=a.length;var h=1;if(4!==b&&6!==b&&8!==b)throw new sjcl.exception.invalid("invalid aes key size");this.b=[d=a.slice(0),e=[]];for(a=b;a<4*b+28;a++){c=d[a-1];if(0===a%b||8===b&&4===a%b)c=f[c>>>24]<<24^f[c>>16&255]<<16^f[c>>8&255]<<8^f[c&255],0===a%b&&(c=c<<8^c>>>24^h<<24,h=h<<1^283*(h>>7));d[a]=d[a-b]^c}for(b=0;a;b++,a--)c=d[b&3?a:a-4],e[b]=4>=a||4>b?c:g[0][f[c>>>24]]^g[1][f[c>>16&255]]^g[2][f[c>>8&255]]^g[3][f[c& 4 | 255]]}; 5 | sjcl.cipher.aes.prototype={encrypt:function(a){return t(this,a,0)},decrypt:function(a){return t(this,a,1)},s:[[[],[],[],[],[]],[[],[],[],[],[]]],O:function(){var a=this.s[0],b=this.s[1],c=a[4],d=b[4],e,f,g,h=[],k=[],l,n,m,p;for(e=0;0x100>e;e++)k[(h[e]=e<<1^283*(e>>7))^e]=e;for(f=g=0;!c[f];f^=l||1,g=k[g]||1)for(m=g^g<<1^g<<2^g<<3^g<<4,m=m>>8^m&255^99,c[f]=m,d[m]=f,n=h[e=h[l=h[f]]],p=0x1010101*n^0x10001*e^0x101*l^0x1010100*f,n=0x101*h[m]^0x1010100*m,e=0;4>e;e++)a[e][f]=n=n<<24^n>>>8,b[e][m]=p=p<<24^p>>>8;for(e= 6 | 0;5>e;e++)a[e]=a[e].slice(0),b[e]=b[e].slice(0)}}; 7 | function t(a,b,c){if(4!==b.length)throw new sjcl.exception.invalid("invalid aes block size");var d=a.b[c],e=b[0]^d[0],f=b[c?3:1]^d[1],g=b[2]^d[2];b=b[c?1:3]^d[3];var h,k,l,n=d.length/4-2,m,p=4,r=[0,0,0,0];h=a.s[c];a=h[0];var q=h[1],v=h[2],w=h[3],x=h[4];for(m=0;m>>24]^q[f>>16&255]^v[g>>8&255]^w[b&255]^d[p],k=a[f>>>24]^q[g>>16&255]^v[b>>8&255]^w[e&255]^d[p+1],l=a[g>>>24]^q[b>>16&255]^v[e>>8&255]^w[f&255]^d[p+2],b=a[b>>>24]^q[e>>16&255]^v[f>>8&255]^w[g&255]^d[p+3],p+=4,e=h,f=k,g=l;for(m= 8 | 0;4>m;m++)r[c?3&-m:m]=x[e>>>24]<<24^x[f>>16&255]<<16^x[g>>8&255]<<8^x[b&255]^d[p++],h=e,e=f,f=g,g=b,b=h;return r} 9 | sjcl.bitArray={bitSlice:function(a,b,c){a=sjcl.bitArray.$(a.slice(b/32),32-(b&31)).slice(1);return void 0===c?a:sjcl.bitArray.clamp(a,c-b)},extract:function(a,b,c){var d=Math.floor(-b-c&31);return((b+c-1^b)&-32?a[b/32|0]<<32-d^a[b/32+1|0]>>>d:a[b/32|0]>>>d)&(1<>b-1,1));return a},partial:function(a,b,c){return 32===a?b:(c?b|0:b<<32-a)+0x10000000000*a},getPartial:function(a){return Math.round(a/0x10000000000)||32},equal:function(a,b){if(sjcl.bitArray.bitLength(a)!==sjcl.bitArray.bitLength(b))return!1;var c=0,d;for(d=0;d>>b),c=a[e]<<32-b;e=a.length?a[a.length-1]:0;a=sjcl.bitArray.getPartial(e);d.push(sjcl.bitArray.partial(b+a&31,32>>24|c>>>8&0xff00|(c&0xff00)<<8|c<<24;return a}}; 12 | sjcl.codec.utf8String={fromBits:function(a){var b="",c=sjcl.bitArray.bitLength(a),d,e;for(d=0;d>>24),e<<=8;return decodeURIComponent(escape(b))},toBits:function(a){a=unescape(encodeURIComponent(a));var b=[],c,d=0;for(c=0;c>>g)>>>e),gn){if(!b)try{return sjcl.codec.base32hex.toBits(a)}catch(p){}throw new sjcl.exception.invalid("this isn't "+m+"!");}h>e?(h-=e,f.push(l^n>>>h),l=n<>>e)>>>26),6>e?(g=a[c]<<6-e,e+=26,c++):(g<<=6,e-=6);for(;d.length&3&&!b;)d+="=";return d},toBits:function(a,b){a=a.replace(/\s|=/g,"");var c=[],d,e=0,f=sjcl.codec.base64.B,g=0,h;b&&(f=f.substr(0,62)+"-_");for(d=0;dh)throw new sjcl.exception.invalid("this isn't base64!");26>>e),g=h<<32-e):(e+=6,g^=h<<32-e)}e&56&&c.push(sjcl.bitArray.partial(e&56,g,1));return c}};sjcl.codec.base64url={fromBits:function(a){return sjcl.codec.base64.fromBits(a,1,1)},toBits:function(a){return sjcl.codec.base64.toBits(a,1)}}; 19 | sjcl.codec.bytes={fromBits:function(a){var b=[],c=sjcl.bitArray.bitLength(a),d,e;for(d=0;d>>24),e<<=8;return b},toBits:function(a){var b=[],c,d=0;for(c=0;cb;c++){for(d=2;d*d<=c;d++)if(0===c%d)continue a;8>b&&(this.Y[b]=a(Math.pow(c,.5)));this.b[b]=a(Math.pow(c,1/3));b++}}}; 22 | function u(a,b){var c,d,e,f=a.F,g=a.b,h=f[0],k=f[1],l=f[2],n=f[3],m=f[4],p=f[5],r=f[6],q=f[7];for(c=0;64>c;c++)16>c?d=b[c]:(d=b[c+1&15],e=b[c+14&15],d=b[c&15]=(d>>>7^d>>>18^d>>>3^d<<25^d<<14)+(e>>>17^e>>>19^e>>>10^e<<15^e<<13)+b[c&15]+b[c+9&15]|0),d=d+q+(m>>>6^m>>>11^m>>>25^m<<26^m<<21^m<<7)+(r^m&(p^r))+g[c],q=r,r=p,p=m,m=n+d|0,n=l,l=k,k=h,h=d+(k&l^n&(k^l))+(k>>>2^k>>>13^k>>>22^k<<30^k<<19^k<<10)|0;f[0]=f[0]+h|0;f[1]=f[1]+k|0;f[2]=f[2]+l|0;f[3]=f[3]+n|0;f[4]=f[4]+m|0;f[5]=f[5]+p|0;f[6]=f[6]+r|0;f[7]= 23 | f[7]+q|0} 24 | sjcl.mode.ccm={name:"ccm",G:[],listenProgress:function(a){sjcl.mode.ccm.G.push(a)},unListenProgress:function(a){a=sjcl.mode.ccm.G.indexOf(a);-1k)throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes");for(f=2;4>f&&l>>>8*f;f++);f<15-k&&(f=15-k);c=h.clamp(c, 25 | 8*(15-f));b=sjcl.mode.ccm.V(a,b,c,d,e,f);g=sjcl.mode.ccm.C(a,g,c,b,e,f);return h.concat(g.data,g.tag)},decrypt:function(a,b,c,d,e){e=e||64;d=d||[];var f=sjcl.bitArray,g=f.bitLength(c)/8,h=f.bitLength(b),k=f.clamp(b,h-e),l=f.bitSlice(b,h-e),h=(h-e)/8;if(7>g)throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes");for(b=2;4>b&&h>>>8*b;b++);b<15-g&&(b=15-g);c=f.clamp(c,8*(15-b));k=sjcl.mode.ccm.C(a,k,c,l,e,b);a=sjcl.mode.ccm.V(a,k.data,c,d,e,b);if(!f.equal(k.tag,a))throw new sjcl.exception.corrupt("ccm: tag doesn't match"); 26 | return k.data},na:function(a,b,c,d,e,f){var g=[],h=sjcl.bitArray,k=h.i;d=[h.partial(8,(b.length?64:0)|d-2<<2|f-1)];d=h.concat(d,c);d[3]|=e;d=a.encrypt(d);if(b.length)for(c=h.bitLength(b)/8,65279>=c?g=[h.partial(16,c)]:0xffffffff>=c&&(g=h.concat([h.partial(16,65534)],[c])),g=h.concat(g,b),b=0;be||16n&&(sjcl.mode.ccm.fa(g/ 28 | k),n+=m),c[3]++,e=a.encrypt(c),b[g]^=e[0],b[g+1]^=e[1],b[g+2]^=e[2],b[g+3]^=e[3];return{tag:d,data:h.clamp(b,l)}}}; 29 | sjcl.mode.ocb2={name:"ocb2",encrypt:function(a,b,c,d,e,f){if(128!==sjcl.bitArray.bitLength(c))throw new sjcl.exception.invalid("ocb iv must be 128 bits");var g,h=sjcl.mode.ocb2.S,k=sjcl.bitArray,l=k.i,n=[0,0,0,0];c=h(a.encrypt(c));var m,p=[];d=d||[];e=e||64;for(g=0;g+4e.bitLength(c)&&(h=f(h,d(h)),c=e.concat(c,[-2147483648,0,0,0]));g=f(g,c); 32 | return a.encrypt(f(d(f(h,d(h))),g))},S:function(a){return[a[0]<<1^a[1]>>>31,a[1]<<1^a[2]>>>31,a[2]<<1^a[3]>>>31,a[3]<<1^135*(a[0]>>>31)]}}; 33 | sjcl.mode.gcm={name:"gcm",encrypt:function(a,b,c,d,e){var f=b.slice(0);b=sjcl.bitArray;d=d||[];a=sjcl.mode.gcm.C(!0,a,f,d,c,e||128);return b.concat(a.data,a.tag)},decrypt:function(a,b,c,d,e){var f=b.slice(0),g=sjcl.bitArray,h=g.bitLength(f);e=e||128;d=d||[];e<=h?(b=g.bitSlice(f,h-e),f=g.bitSlice(f,0,h-e)):(b=f,f=[]);a=sjcl.mode.gcm.C(!1,a,f,d,c,e);if(!g.equal(a.tag,b))throw new sjcl.exception.corrupt("gcm: tag doesn't match");return a.data},ka:function(a,b){var c,d,e,f,g,h=sjcl.bitArray.i;e=[0,0, 34 | 0,0];f=b.slice(0);for(c=0;128>c;c++){(d=0!==(a[Math.floor(c/32)]&1<<31-c%32))&&(e=h(e,f));g=0!==(f[3]&1);for(d=3;0>>1|(f[d-1]&1)<<31;f[0]>>>=1;g&&(f[0]^=-0x1f000000)}return e},j:function(a,b,c){var d,e=c.length;b=b.slice(0);for(d=0;de&&(a=b.hash(a));for(d=0;dd||0>c)throw sjcl.exception.invalid("invalid params to pbkdf2");"string"===typeof a&&(a=sjcl.codec.utf8String.toBits(a));"string"===typeof b&&(b=sjcl.codec.utf8String.toBits(b));e=e||sjcl.misc.hmac;a=new e(a);var f,g,h,k,l=[],n=sjcl.bitArray;for(k=1;32*l.length<(d||1);k++){e=f=a.encrypt(n.concat(b,[k]));for(g=1;gg;g++)e.push(0x100000000*Math.random()|0);for(g=0;g=1<this.o&&(this.o= 41 | f);this.P++;this.b=sjcl.hash.sha256.hash(this.b.concat(e));this.L=new sjcl.cipher.aes(this.b);for(d=0;4>d&&(this.h[d]=this.h[d]+1|0,!this.h[d]);d++);}for(d=0;d>>1;this.c[g].update([d,this.N++,2,b,f,a.length].concat(a))}break;case "string":void 0===b&&(b=a.length);this.c[g].update([d,this.N++,3,b,f,a.length]);this.c[g].update(a);break;default:k=1}if(k)throw new sjcl.exception.bug("random: addEntropy only supports number, array of numbers or string");this.m[g]+=b;this.f+=b;h===this.u&&(this.isReady()!==this.u&&A("seeded",Math.max(this.o,this.f)),A("progress",this.getProgress()))},isReady:function(a){a=this.T[void 0!== 44 | a?a:this.M];return this.o&&this.o>=a?this.m[0]>this.ba&&(new Date).valueOf()>this.Z?this.J|this.I:this.I:this.f>=a?this.J|this.u:this.u},getProgress:function(a){a=this.T[a?a:this.M];return this.o>=a?1:this.f>a?1:this.f/a},startCollectors:function(){if(!this.D){this.a={loadTimeCollector:B(this,this.ma),mouseCollector:B(this,this.oa),keyboardCollector:B(this,this.la),accelerometerCollector:B(this,this.ea),touchCollector:B(this,this.qa)};if(window.addEventListener)window.addEventListener("load",this.a.loadTimeCollector, 45 | !1),window.addEventListener("mousemove",this.a.mouseCollector,!1),window.addEventListener("keypress",this.a.keyboardCollector,!1),window.addEventListener("devicemotion",this.a.accelerometerCollector,!1),window.addEventListener("touchmove",this.a.touchCollector,!1);else if(document.attachEvent)document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector);else throw new sjcl.exception.bug("can't attach event"); 46 | this.D=!0}},stopCollectors:function(){this.D&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,!1),window.removeEventListener("mousemove",this.a.mouseCollector,!1),window.removeEventListener("keypress",this.a.keyboardCollector,!1),window.removeEventListener("devicemotion",this.a.accelerometerCollector,!1),window.removeEventListener("touchmove",this.a.touchCollector,!1)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove", 47 | this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.D=!1)},addEventListener:function(a,b){this.K[a][this.ga++]=b},removeEventListener:function(a,b){var c,d,e=this.K[a],f=[];for(d in e)e.hasOwnProperty(d)&&e[d]===b&&f.push(d);for(c=0;cb&&(a.h[b]=a.h[b]+1|0,!a.h[b]);b++);return a.L.encrypt(a.h)} 50 | function B(a,b){return function(){b.apply(a,arguments)}}sjcl.random=new sjcl.prng(6); 51 | a:try{var D,E,F,G;if(G="undefined"!==typeof module&&module.exports){var H;try{H=require("crypto")}catch(a){H=null}G=E=H}if(G&&E.randomBytes)D=E.randomBytes(128),D=new Uint32Array((new Uint8Array(D)).buffer),sjcl.random.addEntropy(D,1024,"crypto['randomBytes']");else if("undefined"!==typeof window&&"undefined"!==typeof Uint32Array){F=new Uint32Array(32);if(window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(F);else if(window.msCrypto&&window.msCrypto.getRandomValues)window.msCrypto.getRandomValues(F); 52 | else break a;sjcl.random.addEntropy(F,1024,"crypto['getRandomValues']")}}catch(a){"undefined"!==typeof window&&window.console&&(console.log("There was an error collecting entropy from the browser:"),console.log(a))} 53 | sjcl.json={defaults:{v:1,iter:1E3,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},ja:function(a,b,c,d){c=c||{};d=d||{};var e=sjcl.json,f=e.g({iv:sjcl.random.randomWords(4,0)},e.defaults),g;e.g(f,c);c=f.adata;"string"===typeof f.salt&&(f.salt=sjcl.codec.base64.toBits(f.salt));"string"===typeof f.iv&&(f.iv=sjcl.codec.base64.toBits(f.iv));if(!sjcl.mode[f.mode]||!sjcl.cipher[f.cipher]||"string"===typeof a&&100>=f.iter||64!==f.ts&&96!==f.ts&&128!==f.ts||128!==f.ks&&192!==f.ks&&0x100!==f.ks||2>f.iv.length|| 54 | 4=b.iter||64!==b.ts&&96!==b.ts&&128!==b.ts||128!==b.ks&&192!==b.ks&&0x100!==b.ks||!b.iv||2>b.iv.length||4 2 | 3 | 4 | Serverless Stories 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 45 |
46 | 47 |
48 |
49 |

Top Stories

50 |
51 |
52 |
53 |
54 | 55 |

Serverless Computing Takes Over the World!

56 |

The Serverless Computing trend shows no sings of slowing down. Companies are buring their servers and going serverless...

57 | Read Story 58 |
59 |
60 |
61 | 62 |
63 |
64 |
65 | 66 |

Function as a Service: The Next Big Thing

67 |

Every decade or so, an idea so powerful comes about that it changes the way we think, work and play. FaaS is that idea...

68 | Read Story 69 |
70 |
71 |
72 | 73 |
74 |
75 |
76 | 77 |

Welcome to Serverless Stories

78 |

Our blog is officially live. Find out how we created this blog and the technology behind running it. We think it's pretty great...

79 | Read Story 80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 | 89 | 90 |
91 | 92 |
93 |
94 |
95 |
96 |
97 |
98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /public/login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Serverless Stories | Login 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 45 |
46 | 47 |
48 |
49 |

Login

50 |
51 |
52 | 53 | 54 |
55 |
56 | 57 | 58 |
59 | 60 |
61 |
62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /public/post/function-as-a-service/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Serverless Stories 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 45 |
46 | 47 |
48 |
49 |

Function as a Service (FaaS)

50 | 51 |

Lorem ipsum dolor sit amet, dolor eu nec, a etiam elit sed, iaculis vehicula nam suspendisse orci arcu, pellentesque est sit fringilla. Vehicula et ut. Elit felis fusce in in sollicitudin, a ac venenatis fermentum egestas scelerisque sit, morbi vehicula ultricies, fusce sit feugiat primis amet, lobortis lacinia curabitur integer. Pretium dignissim enim eget, nostra vulputate ipsum proin dui, arcu ad ut et augue nulla vel. Fermentum ante, ea et ornare amet in dolor, vestibulum quis erat, pulvinar mollis, in mollis eget ut auctor nunc mollis. Hendrerit a adipiscing pede nulla quisque donec, nec nulla vitae quisque. In sagittis donec accumsan dolor massa in.

52 | 53 |

Convallis sodales in mi mollis maecenas massa, sed id, aenean eum sodales a varius proin vero, sit magna massa. Nec rhoncus duis, velit sed nulla lobortis a vestibulum condimentum, consectetuer auctor justo nibh odio felis turpis. Turpis eos, aliquet metus fringilla eleifend tincidunt felis nulla. Turpis molestie tellus ante vestibulum, turpis vestibulum, eget urna arcu scelerisque et, nonummy sapien vivamus ac, quis libero. Donec ac consequat accumsan ipsum neque, lorem at mi fermentum quis. Leo in aliquam nam erat, vitae amet, montes aliquet urna lacus. Placerat ullamcorper, placerat ut et quam est. Aenean adipiscing arcu dicta varius ante massa, nunc arcu quisque mi eget libero, elit non, suscipit suscipit ullamcorper sem risus.

54 | 55 |

Sodales proin montes condimentum vitae dignissimos sollicitudin, scelerisque eu aenean quis eros eget quisque, vel amet sem enim dolor, massa in et sollicitudin tincidunt non phasellus, facilisis mollis senectus urna. Facilisis vel dapibus eu purus habitasse, ac eget arcu dui libero hymenaeos aliquam, justo quis eu mus consequat vitae sed, elit posuere. Ultricies aliquam adipiscing purus morbi mollis. Tortor laoreet sit ut et praesent, fringilla cras, tortor amet volutpat nec est ut vestibulum. Varius diam in nunc, rhoncus sit et amet non etiam amet, sit vehicula praesent. Ridiculus maecenas, praesent dolorum molestie ipsum molestie, tristique accumsan nec tincidunt ullamcorper nullam pede, ultrices fusce sit ante nulla. Sollicitudin quia risus vehicula sed a nunc, aliquet suspendisse et. Neque nam molestie vehicula vel, lacus sollicitudin est erat arcu. Elit cras quis blandit vestibulum interdum pulvinar, turpis viverra tellus eu, nam semper neque sit ligula. Quis quis nulla gravida eget vestibulum luctus, fusce integer vitae elit enim suspendisse ut, nec pellentesque etiam eu turpis congue libero, augue eget scelerisque sed donec mi. Fermentum ut amet massa, sapien senectus hac, vehicula sed vivamus. Integer commodo dui vel euismod vivamus, lacus ornare, phasellus mi donec maecenas, nam et vestibulum euismod.

56 | 57 |

A eget, ultricies ultricies metus congue quis, faucibus arcu. Libero sapien, vel risus lectus nec nibh diam sem, tellus sagittis, mus taciti sed et in. Sed sed est vitae sed tincidunt. Dictum tempus, velit et nunc, et ridiculus mollis curabitur risus praesent. Volutpat elit sequi pellentesque enim blandit, diam dignissim lorem id id, in sapien molestie elit morbi vestibulum est. Elit vitae donec libero magna ut ipsum, scelerisque ut phasellus eget sed id vulputate, wisi phasellus sed sit, fames lacus a integer non ultricies, facilisis nullam ligula amet ante etiam. Duis montes, velit lectus, mattis nunc eget odio sed faucibus, augue dolor ante amet lacus, eleifend luctus volutpat a natoque luctus penatibus. Nam dui aliquet arcu ligula libero, et adipiscing mauris at urna nec, pede neque nullam arcu in morbi tempus, turpis eget et vitae lacinia mattis. Vitae nunc leo sed non, non dolor nibh amet bibendum ut, quis sit et, felis ligula, suscipit libero non elit cras.

58 |
59 | 60 | 61 | -------------------------------------------------------------------------------- /public/post/serverless-computing-takes-over-the-world/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Serverless Stories 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 45 |
46 | 47 |
48 |
49 |

Serverless Computing Takes Over the World!

50 | 51 |

Lorem ipsum dolor sit amet, dolor eu nec, a etiam elit sed, iaculis vehicula nam suspendisse orci arcu, pellentesque est sit fringilla. Vehicula et ut. Elit felis fusce in in sollicitudin, a ac venenatis fermentum egestas scelerisque sit, morbi vehicula ultricies, fusce sit feugiat primis amet, lobortis lacinia curabitur integer. Pretium dignissim enim eget, nostra vulputate ipsum proin dui, arcu ad ut et augue nulla vel. Fermentum ante, ea et ornare amet in dolor, vestibulum quis erat, pulvinar mollis, in mollis eget ut auctor nunc mollis. Hendrerit a adipiscing pede nulla quisque donec, nec nulla vitae quisque. In sagittis donec accumsan dolor massa in.

52 | 53 |

Convallis sodales in mi mollis maecenas massa, sed id, aenean eum sodales a varius proin vero, sit magna massa. Nec rhoncus duis, velit sed nulla lobortis a vestibulum condimentum, consectetuer auctor justo nibh odio felis turpis. Turpis eos, aliquet metus fringilla eleifend tincidunt felis nulla. Turpis molestie tellus ante vestibulum, turpis vestibulum, eget urna arcu scelerisque et, nonummy sapien vivamus ac, quis libero. Donec ac consequat accumsan ipsum neque, lorem at mi fermentum quis. Leo in aliquam nam erat, vitae amet, montes aliquet urna lacus. Placerat ullamcorper, placerat ut et quam est. Aenean adipiscing arcu dicta varius ante massa, nunc arcu quisque mi eget libero, elit non, suscipit suscipit ullamcorper sem risus.

54 | 55 |

Sodales proin montes condimentum vitae dignissimos sollicitudin, scelerisque eu aenean quis eros eget quisque, vel amet sem enim dolor, massa in et sollicitudin tincidunt non phasellus, facilisis mollis senectus urna. Facilisis vel dapibus eu purus habitasse, ac eget arcu dui libero hymenaeos aliquam, justo quis eu mus consequat vitae sed, elit posuere. Ultricies aliquam adipiscing purus morbi mollis. Tortor laoreet sit ut et praesent, fringilla cras, tortor amet volutpat nec est ut vestibulum. Varius diam in nunc, rhoncus sit et amet non etiam amet, sit vehicula praesent. Ridiculus maecenas, praesent dolorum molestie ipsum molestie, tristique accumsan nec tincidunt ullamcorper nullam pede, ultrices fusce sit ante nulla. Sollicitudin quia risus vehicula sed a nunc, aliquet suspendisse et. Neque nam molestie vehicula vel, lacus sollicitudin est erat arcu. Elit cras quis blandit vestibulum interdum pulvinar, turpis viverra tellus eu, nam semper neque sit ligula. Quis quis nulla gravida eget vestibulum luctus, fusce integer vitae elit enim suspendisse ut, nec pellentesque etiam eu turpis congue libero, augue eget scelerisque sed donec mi. Fermentum ut amet massa, sapien senectus hac, vehicula sed vivamus. Integer commodo dui vel euismod vivamus, lacus ornare, phasellus mi donec maecenas, nam et vestibulum euismod.

56 | 57 |

A eget, ultricies ultricies metus congue quis, faucibus arcu. Libero sapien, vel risus lectus nec nibh diam sem, tellus sagittis, mus taciti sed et in. Sed sed est vitae sed tincidunt. Dictum tempus, velit et nunc, et ridiculus mollis curabitur risus praesent. Volutpat elit sequi pellentesque enim blandit, diam dignissim lorem id id, in sapien molestie elit morbi vestibulum est. Elit vitae donec libero magna ut ipsum, scelerisque ut phasellus eget sed id vulputate, wisi phasellus sed sit, fames lacus a integer non ultricies, facilisis nullam ligula amet ante etiam. Duis montes, velit lectus, mattis nunc eget odio sed faucibus, augue dolor ante amet lacus, eleifend luctus volutpat a natoque luctus penatibus. Nam dui aliquet arcu ligula libero, et adipiscing mauris at urna nec, pede neque nullam arcu in morbi tempus, turpis eget et vitae lacinia mattis. Vitae nunc leo sed non, non dolor nibh amet bibendum ut, quis sit et, felis ligula, suscipit libero non elit cras.

58 |
59 | 60 | 61 | -------------------------------------------------------------------------------- /public/post/welcome-to-serverless-stories/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Serverless Stories 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 45 |
46 | 47 |
48 |
49 |

Welcome to Serverless Stories

50 | 51 |

Lorem ipsum dolor sit amet, dolor eu nec, a etiam elit sed, iaculis vehicula nam suspendisse orci arcu, pellentesque est sit fringilla. Vehicula et ut. Elit felis fusce in in sollicitudin, a ac venenatis fermentum egestas scelerisque sit, morbi vehicula ultricies, fusce sit feugiat primis amet, lobortis lacinia curabitur integer. Pretium dignissim enim eget, nostra vulputate ipsum proin dui, arcu ad ut et augue nulla vel. Fermentum ante, ea et ornare amet in dolor, vestibulum quis erat, pulvinar mollis, in mollis eget ut auctor nunc mollis. Hendrerit a adipiscing pede nulla quisque donec, nec nulla vitae quisque. In sagittis donec accumsan dolor massa in.

52 | 53 |

Convallis sodales in mi mollis maecenas massa, sed id, aenean eum sodales a varius proin vero, sit magna massa. Nec rhoncus duis, velit sed nulla lobortis a vestibulum condimentum, consectetuer auctor justo nibh odio felis turpis. Turpis eos, aliquet metus fringilla eleifend tincidunt felis nulla. Turpis molestie tellus ante vestibulum, turpis vestibulum, eget urna arcu scelerisque et, nonummy sapien vivamus ac, quis libero. Donec ac consequat accumsan ipsum neque, lorem at mi fermentum quis. Leo in aliquam nam erat, vitae amet, montes aliquet urna lacus. Placerat ullamcorper, placerat ut et quam est. Aenean adipiscing arcu dicta varius ante massa, nunc arcu quisque mi eget libero, elit non, suscipit suscipit ullamcorper sem risus.

54 | 55 |

Sodales proin montes condimentum vitae dignissimos sollicitudin, scelerisque eu aenean quis eros eget quisque, vel amet sem enim dolor, massa in et sollicitudin tincidunt non phasellus, facilisis mollis senectus urna. Facilisis vel dapibus eu purus habitasse, ac eget arcu dui libero hymenaeos aliquam, justo quis eu mus consequat vitae sed, elit posuere. Ultricies aliquam adipiscing purus morbi mollis. Tortor laoreet sit ut et praesent, fringilla cras, tortor amet volutpat nec est ut vestibulum. Varius diam in nunc, rhoncus sit et amet non etiam amet, sit vehicula praesent. Ridiculus maecenas, praesent dolorum molestie ipsum molestie, tristique accumsan nec tincidunt ullamcorper nullam pede, ultrices fusce sit ante nulla. Sollicitudin quia risus vehicula sed a nunc, aliquet suspendisse et. Neque nam molestie vehicula vel, lacus sollicitudin est erat arcu. Elit cras quis blandit vestibulum interdum pulvinar, turpis viverra tellus eu, nam semper neque sit ligula. Quis quis nulla gravida eget vestibulum luctus, fusce integer vitae elit enim suspendisse ut, nec pellentesque etiam eu turpis congue libero, augue eget scelerisque sed donec mi. Fermentum ut amet massa, sapien senectus hac, vehicula sed vivamus. Integer commodo dui vel euismod vivamus, lacus ornare, phasellus mi donec maecenas, nam et vestibulum euismod.

56 | 57 |

A eget, ultricies ultricies metus congue quis, faucibus arcu. Libero sapien, vel risus lectus nec nibh diam sem, tellus sagittis, mus taciti sed et in. Sed sed est vitae sed tincidunt. Dictum tempus, velit et nunc, et ridiculus mollis curabitur risus praesent. Volutpat elit sequi pellentesque enim blandit, diam dignissim lorem id id, in sapien molestie elit morbi vestibulum est. Elit vitae donec libero magna ut ipsum, scelerisque ut phasellus eget sed id vulputate, wisi phasellus sed sit, fames lacus a integer non ultricies, facilisis nullam ligula amet ante etiam. Duis montes, velit lectus, mattis nunc eget odio sed faucibus, augue dolor ante amet lacus, eleifend luctus volutpat a natoque luctus penatibus. Nam dui aliquet arcu ligula libero, et adipiscing mauris at urna nec, pede neque nullam arcu in morbi tempus, turpis eget et vitae lacinia mattis. Vitae nunc leo sed non, non dolor nibh amet bibendum ut, quis sit et, felis ligula, suscipit libero non elit cras.

58 |
59 | 60 | 61 | --------------------------------------------------------------------------------