diff options
author | Valentin Popov <info@valentineus.link> | 2017-05-29 07:02:09 +0300 |
---|---|---|
committer | Valentin Popov <info@valentineus.link> | 2017-05-29 07:02:09 +0300 |
commit | c43c75e3d1c4c7a9b2fb71c7cf7e1086ea8fddf4 (patch) | |
tree | 0b1f3313312bdb00ef48f2a4fbfd43939f5140b3 /docs/index.js.html | |
parent | cb354fc09830944839ae4221a0bbe485d2cb64dd (diff) | |
download | iii-client-c43c75e3d1c4c7a9b2fb71c7cf7e1086ea8fddf4.tar.xz iii-client-c43c75e3d1c4c7a9b2fb71c7cf7e1086ea8fddf4.zip |
Release of version 0.0.3.
Diffstat (limited to 'docs/index.js.html')
-rw-r--r-- | docs/index.js.html | 54 |
1 files changed, 21 insertions, 33 deletions
diff --git a/docs/index.js.html b/docs/index.js.html index 3749990..29aeb27 100644 --- a/docs/index.js.html +++ b/docs/index.js.html @@ -47,12 +47,13 @@ var http = require('http'); +exports.connect = connect; /** * Connects to the server and returns the connection data. * @param {String} uuid - The bot UUID. * @param {requestCallback} callback - The callback that handles the response. */ -var connect = function(uuid, callback) { +function connect(uuid, callback) { uuid = uuid || ''; if (!_verification(uuid)) { @@ -64,7 +65,7 @@ var connect = function(uuid, callback) { hostname: 'iii.ru', path: '/api/2.0/json/Chat.init/' + uuid + '/', method: 'GET', - } + }; const request = http.request(query, function(response) { var json = ''; @@ -72,15 +73,12 @@ var connect = function(uuid, callback) { response.on('end', () => callback(json.result)); }); - request.on('error', function(error) { - console.error('Error connecting to the server!\n', error.message); - }); + request.on('error', (error) => Error(error.message)); request.end(); } -exports.connect = connect; - +exports.send = send; /** * Send a message to the server and return a response. * @param {Object} raw - The data to send. @@ -88,7 +86,7 @@ exports.connect = connect; * @param {String} raw.text - Message text. * @param {requestCallback} callback - The callback that handles the response. */ -var send = function(raw, callback) { +function send(raw, callback) { raw = raw || {}; const query = { @@ -96,7 +94,7 @@ var send = function(raw, callback) { hostname: 'iii.ru', path: '/api/2.0/json/Chat.request', method: 'POST', - } + }; const data = _createPackage(raw); @@ -106,22 +104,19 @@ var send = function(raw, callback) { response.on('end', () => callback(json)); }); - request.on('error', function(error) { - console.error('Error sending the package!\n', error.message); - }); + request.on('error', (error) => Error(error)); request.write(data); request.end(); } -exports.send = send; - +exports._encrypt = _encrypt; /** * Encrypts the incoming data. * @param {String} raw - Decrypted data. * @returns {String} - Encrypted string. */ -var _encrypt = function(raw) { +function _encrypt(raw) { raw = raw || ''; var base64 = Buffer.from(raw).toString('base64'); @@ -129,14 +124,13 @@ var _encrypt = function(raw) { return _merger(string).toString('base64'); } -exports._encrypt = _encrypt; - +exports._decrypt = _decrypt; /** * Decrypts the incoming data. * @param {String} raw - Encrypted data. * @returns {String} - Decrypted string. */ -var _decrypt = function(raw) { +function _decrypt(raw) { raw = raw || ''; var string = Buffer.from(raw, 'base64'); @@ -144,14 +138,13 @@ var _decrypt = function(raw) { return Buffer.from(decrypted, 'base64'); } -exports._decrypt = _decrypt; - +exports._decryptJSON = _decryptJSON; /** * Decrypts an encrypted JSON object. * @param {String} raw - Encrypted data. * @returns {Object} - Decrypted JSON. */ -var _decryptJSON = function(raw) { +function _decryptJSON(raw) { raw = raw || ''; var string = raw.toString('ascii'); @@ -159,14 +152,13 @@ var _decryptJSON = function(raw) { return JSON.parse(data); } -exports._decryptJSON = _decryptJSON; - +exports._merger = _merger; /** * Merge and convert a string. * @param {String} raw - The string to convert. * @returns {String} - The converted string. */ -var _merger = function(data) { +function _merger(data) { data = data || ''; const salt = Buffer.from('some very-very long string without any non-latin characters due to different string representations inside of variable programming languages'); @@ -178,8 +170,7 @@ var _merger = function(data) { return data; } -exports._merger = _merger; - +exports._createPackage = _createPackage; /** * Creates an encrypted package to send. * @param {Object} raw - The data to send. @@ -187,7 +178,7 @@ exports._merger = _merger; * @param {String} raw.text - Message text. * @returns {String} - Encrypted string. */ -var _createPackage = function(raw) { +function _createPackage(raw) { raw = raw || {}; if (!raw.text) { @@ -206,20 +197,17 @@ var _createPackage = function(raw) { return _encrypt(json); } -exports._createPackage = _createPackage; - +exports._verification = _verification; /** * Validation UUID format string. * @param {String} data - The string to check. * @returns {Boolean} */ -var _verification = function(data) { +function _verification(data) { data = data || ''; const regexp = new RegExp('^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$', 'i'); return regexp.test(data); } - -exports._verification = _verification; </code></pre> </article> </section> @@ -232,7 +220,7 @@ exports._verification = _verification; <br class="clear"> <footer> - Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon May 29 2017 02:00:06 GMT+0300 (MSK) using the Minami theme. + Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon May 29 2017 07:00:49 GMT+0300 (MSK) using the Minami theme. </footer> <script>prettyPrint();</script> |