From 3f49dc224802809dce19d07695087ab7f22427f9 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 30 May 2017 16:03:39 +0300 Subject: Release of version 1.0.0. --- CONTRIBUTING.md | 25 +++++ README.md | 15 +-- docs/global.html | 272 ++++++++++++++++++++++++++--------------------------- docs/index.html | 4 +- docs/index.js.html | 49 +++++----- package.json | 2 +- src/index.js | 45 +++++---- 7 files changed, 214 insertions(+), 198 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..5b4b08f --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,25 @@ +# Developer's Certificate of Origin 1.1 + +By making a contribution to this project, I certify that: + +* (a) The contribution was created in whole or in part by me and I + have the right to submit it under the open source license + indicated in the file; or + +* (b) The contribution is based upon previous work that, to the best + of my knowledge, is covered under an appropriate open source + license and I have the right under that license to submit that + work with modifications, whether created in whole or in part + by me, under the same open source license (unless I am + permitted to submit under a different license), as indicated + in the file; or + +* (c) The contribution was provided directly to me by some other + person who certified (a), (b) or (c) and I have not modified + it. + +* (d) I understand and agree that this project and the contribution + are public and that a record of the contribution (including all + personal information I submit with it, including my sign-off) is + maintained indefinitely and may be redistributed consistent with + this project or the open source license(s) involved. \ No newline at end of file diff --git a/README.md b/README.md index e8ec03b..1b4b6a6 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,7 @@ # III Client -[![npm][npm-image]][npm-url] -[![david][david-image]][david-url] -[![david-dev][david-dev-image]][david-dev-url] - -[npm-image]: https://img.shields.io/npm/v/iii-client.svg -[npm-url]: https://npmjs.org/package/iii-client -[david-image]: https://david-dm.org/valentineus/iii-client/status.svg -[david-url]: https://david-dm.org/valentineus/iii-client -[david-dev-image]: https://david-dm.org/valentineus/iii-client/dev-status.svg -[david-dev-url]: https://david-dm.org/valentineus/iii-client?type=dev +[![npm](https://img.shields.io/npm/v/iii-client.svg)](https://www.npmjs.com/package/iii-client) +[![dependencies Status](https://david-dm.org/valentineus/iii-client/status.svg)](https://david-dm.org/valentineus/iii-client) +[![devDependencies Status](https://david-dm.org/valentineus/iii-client/dev-status.svg)](https://david-dm.org/valentineus/iii-client?type=dev) Simple API for communicating with the bot of the \"iii.ru\" service. @@ -79,6 +72,6 @@ Description of the internal kitchen can be seen on the [documentation page](http Found out a mistake or feel a lack of functionality? [issues](https://github.com/valentineus/iii-client/issues) ## License -[![JavaScript Style Guide](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard) +[![JavaScript Style Guide](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/eslint/eslint) [MIT](LICENSE.md). Copyright (c) [Valentin Popov](https://valentineus.link/). \ No newline at end of file diff --git a/docs/global.html b/docs/global.html index bcec003..8b70834 100644 --- a/docs/global.html +++ b/docs/global.html @@ -24,7 +24,7 @@
@@ -160,7 +160,7 @@
Source:
@@ -191,14 +191,14 @@ -

_createPackage(raw) → {String}

+

connect(uuid, callback)

- Creates an encrypted package to send. + Connects to the server and returns the connection data.
@@ -234,7 +234,7 @@
Source:
@@ -278,50 +278,7 @@ - raw - - - - - -Object - - - - - - - - - - - The data to send. - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -347,13 +304,13 @@ - + - - - - -
NameTypeDescription
cuiduuid @@ -338,7 +295,7 @@ - Session identifier. + The bot UUID.
textcallback -String +requestCallback @@ -364,15 +321,7 @@ - Message text. - -
- + The callback that handles the response. @@ -394,31 +343,6 @@ -
-
Returns:
- - - -
-
- Type: -
-
- -String - - -
-
- - -
- - Encrypted string. -
- - -
-
@@ -428,14 +352,14 @@ -

_decrypt(raw) → {String}

+

createPackage(raw) → {String}

- Decrypts the incoming data. + Creates an encrypted package to send.
@@ -471,7 +395,7 @@
Source:
@@ -521,6 +445,49 @@ +Object + + + + + + + + + + + The data to send. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
cuid + + String @@ -532,7 +499,41 @@ - Encrypted data. + Session identifier. + +
text + + +String + + + + + Message text. + +
+ @@ -573,7 +574,7 @@
- - Decrypted string. + - Encrypted string.
@@ -588,14 +589,14 @@ -

_decryptJSON(raw) → {Object}

+

decrypt(raw) → {String}

- Decrypts an encrypted JSON object. + Decrypts the incoming data.
@@ -631,7 +632,7 @@
Source:
@@ -725,7 +726,7 @@
-Object +String
@@ -733,7 +734,7 @@
- - Decrypted JSON. + - Decrypted string.
@@ -748,14 +749,14 @@ -

_encrypt(raw) → {String}

+

decryptJSON(raw) → {Object}

- Encrypts the incoming data. + Decrypts an encrypted JSON object.
@@ -791,7 +792,7 @@
Source:
@@ -852,7 +853,7 @@ - Decrypted data. + Encrypted data. @@ -885,7 +886,7 @@
-String +Object
@@ -893,7 +894,7 @@
- - Encrypted string. + - Decrypted JSON.
@@ -908,14 +909,14 @@ -

_merger(raw) → {String}

+

encrypt(raw) → {String}

- Merge and convert a string. + Encrypts the incoming data.
@@ -951,7 +952,7 @@
Source:
@@ -1012,7 +1013,7 @@ - The string to convert. + Decrypted data. @@ -1053,7 +1054,7 @@
- - The converted string. + - Encrypted string.
@@ -1068,7 +1069,7 @@ -

_verification(data) → {Boolean}

+

isVerification(data) → {Boolean}

@@ -1111,7 +1112,7 @@
Source:
@@ -1224,14 +1225,14 @@ -

connect(uuid, callback)

+

mergerString(raw) → {String}

- Connects to the server and returns the connection data. + Merge and convert a string.
@@ -1267,7 +1268,7 @@
Source:
@@ -1311,7 +1312,7 @@ - uuid + raw @@ -1328,53 +1329,52 @@ - The bot UUID. + The string to convert. + + - - - callback - - - - -requestCallback - - - - - - The callback that handles the response. - - - - - - +
+
Returns:
+ +
+
+ Type: +
+
+ +String +
+
+
+ - The converted string. +
+ +
@@ -1428,7 +1428,7 @@
Source:
@@ -1635,7 +1635,7 @@
diff --git a/docs/index.html b/docs/index.html index f19634a..691916c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -24,7 +24,7 @@
@@ -57,7 +57,7 @@
- Generated by JSDoc 3.4.3 on Mon May 29 2017 07:00:49 GMT+0300 (MSK) using the Minami theme. + Generated by JSDoc 3.4.3 on Tue May 30 2017 16:03:16 GMT+0300 (MSK) using the Minami theme.
diff --git a/docs/index.js.html b/docs/index.js.html index 29aeb27..3e970dc 100644 --- a/docs/index.js.html +++ b/docs/index.js.html @@ -24,7 +24,7 @@
@@ -44,7 +44,6 @@ * @author Valentin Popov <info@valentineus.link> * @license See LICENSE.md file included in this distribution. */ - var http = require('http'); exports.connect = connect; @@ -56,7 +55,7 @@ exports.connect = connect; function connect(uuid, callback) { uuid = uuid || ''; - if (!_verification(uuid)) { + if (!isVerification(uuid)) { throw new Error('The UUID is not a valid value!'); } @@ -69,7 +68,7 @@ function connect(uuid, callback) { const request = http.request(query, function(response) { var json = ''; - response.on('data', (raw) => json = _decryptJSON(raw)); + response.on('data', (raw) => json = decryptJSON(raw)); response.on('end', () => callback(json.result)); }); @@ -96,12 +95,12 @@ function send(raw, callback) { method: 'POST', }; - const data = _createPackage(raw); + const data = createPackage(raw); const request = http.request(query, function(response) { var json = ''; - response.on('data', (raw) => json = _decryptJSON(raw)); - response.on('end', () => callback(json)); + response.on('data', (raw) => json = decryptJSON(raw)); + response.on('end', () => callback(json.result)); }); request.on('error', (error) => Error(error)); @@ -110,55 +109,55 @@ function send(raw, callback) { request.end(); } -exports._encrypt = _encrypt; +exports.encrypt = encrypt; /** * Encrypts the incoming data. * @param {String} raw - Decrypted data. * @returns {String} - Encrypted string. */ -function _encrypt(raw) { +function encrypt(raw) { raw = raw || ''; var base64 = Buffer.from(raw).toString('base64'); var string = Buffer.from(base64); - return _merger(string).toString('base64'); + return mergerString(string).toString('base64'); } -exports._decrypt = _decrypt; +exports.decrypt = decrypt; /** * Decrypts the incoming data. * @param {String} raw - Encrypted data. * @returns {String} - Decrypted string. */ -function _decrypt(raw) { +function decrypt(raw) { raw = raw || ''; var string = Buffer.from(raw, 'base64'); - var decrypted = _merger(string).toString(); + var decrypted = mergerString(string).toString(); return Buffer.from(decrypted, 'base64'); } -exports._decryptJSON = _decryptJSON; +exports.decryptJSON = decryptJSON; /** * Decrypts an encrypted JSON object. * @param {String} raw - Encrypted data. * @returns {Object} - Decrypted JSON. */ -function _decryptJSON(raw) { +function decryptJSON(raw) { raw = raw || ''; var string = raw.toString('ascii'); - var data = _decrypt(string); + var data = decrypt(string); return JSON.parse(data); } -exports._merger = _merger; +exports.mergerString = mergerString; /** * Merge and convert a string. * @param {String} raw - The string to convert. * @returns {String} - The converted string. */ -function _merger(data) { +function mergerString(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'); @@ -170,7 +169,7 @@ function _merger(data) { return data; } -exports._createPackage = _createPackage; +exports.createPackage = createPackage; /** * Creates an encrypted package to send. * @param {Object} raw - The data to send. @@ -178,14 +177,14 @@ exports._createPackage = _createPackage; * @param {String} raw.text - Message text. * @returns {String} - Encrypted string. */ -function _createPackage(raw) { +function createPackage(raw) { raw = raw || {}; if (!raw.text) { throw new Error('There is no data to send!'); } - if (!_verification(raw.cuid)) { + if (!isVerification(raw.cuid)) { throw new Error('Parameter \'CUID\' is not a valid UUID value!'); } @@ -194,16 +193,16 @@ function _createPackage(raw) { data.push(raw.text.toString()); var json = JSON.stringify(data); - return _encrypt(json); + return encrypt(json); } -exports._verification = _verification; +exports.isVerification = isVerification; /** * Validation UUID format string. * @param {String} data - The string to check. * @returns {Boolean} */ -function _verification(data) { +function isVerification(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); @@ -220,7 +219,7 @@ function _verification(data) {
- Generated by JSDoc 3.4.3 on Mon May 29 2017 07:00:49 GMT+0300 (MSK) using the Minami theme. + Generated by JSDoc 3.4.3 on Tue May 30 2017 16:03:16 GMT+0300 (MSK) using the Minami theme.
diff --git a/package.json b/package.json index 0cc805d..c533931 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "iii-client", - "version": "0.0.3", + "version": "1.0.0", "description": "Simple API for communicating with the bot of the \"iii.ru\" service.", "homepage": "https://github.com/valentineus/iii-client", "license": "MIT", diff --git a/src/index.js b/src/index.js index 31e238d..24bfd6e 100644 --- a/src/index.js +++ b/src/index.js @@ -3,7 +3,6 @@ * @author Valentin Popov * @license See LICENSE.md file included in this distribution. */ - var http = require('http'); exports.connect = connect; @@ -15,7 +14,7 @@ exports.connect = connect; function connect(uuid, callback) { uuid = uuid || ''; - if (!_verification(uuid)) { + if (!isVerification(uuid)) { throw new Error('The UUID is not a valid value!'); } @@ -28,7 +27,7 @@ function connect(uuid, callback) { const request = http.request(query, function(response) { var json = ''; - response.on('data', (raw) => json = _decryptJSON(raw)); + response.on('data', (raw) => json = decryptJSON(raw)); response.on('end', () => callback(json.result)); }); @@ -55,12 +54,12 @@ function send(raw, callback) { method: 'POST', }; - const data = _createPackage(raw); + const data = createPackage(raw); const request = http.request(query, function(response) { var json = ''; - response.on('data', (raw) => json = _decryptJSON(raw)); - response.on('end', () => callback(json)); + response.on('data', (raw) => json = decryptJSON(raw)); + response.on('end', () => callback(json.result)); }); request.on('error', (error) => Error(error)); @@ -69,55 +68,55 @@ function send(raw, callback) { request.end(); } -exports._encrypt = _encrypt; +exports.encrypt = encrypt; /** * Encrypts the incoming data. * @param {String} raw - Decrypted data. * @returns {String} - Encrypted string. */ -function _encrypt(raw) { +function encrypt(raw) { raw = raw || ''; var base64 = Buffer.from(raw).toString('base64'); var string = Buffer.from(base64); - return _merger(string).toString('base64'); + return mergerString(string).toString('base64'); } -exports._decrypt = _decrypt; +exports.decrypt = decrypt; /** * Decrypts the incoming data. * @param {String} raw - Encrypted data. * @returns {String} - Decrypted string. */ -function _decrypt(raw) { +function decrypt(raw) { raw = raw || ''; var string = Buffer.from(raw, 'base64'); - var decrypted = _merger(string).toString(); + var decrypted = mergerString(string).toString(); return Buffer.from(decrypted, 'base64'); } -exports._decryptJSON = _decryptJSON; +exports.decryptJSON = decryptJSON; /** * Decrypts an encrypted JSON object. * @param {String} raw - Encrypted data. * @returns {Object} - Decrypted JSON. */ -function _decryptJSON(raw) { +function decryptJSON(raw) { raw = raw || ''; var string = raw.toString('ascii'); - var data = _decrypt(string); + var data = decrypt(string); return JSON.parse(data); } -exports._merger = _merger; +exports.mergerString = mergerString; /** * Merge and convert a string. * @param {String} raw - The string to convert. * @returns {String} - The converted string. */ -function _merger(data) { +function mergerString(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'); @@ -129,7 +128,7 @@ function _merger(data) { return data; } -exports._createPackage = _createPackage; +exports.createPackage = createPackage; /** * Creates an encrypted package to send. * @param {Object} raw - The data to send. @@ -137,14 +136,14 @@ exports._createPackage = _createPackage; * @param {String} raw.text - Message text. * @returns {String} - Encrypted string. */ -function _createPackage(raw) { +function createPackage(raw) { raw = raw || {}; if (!raw.text) { throw new Error('There is no data to send!'); } - if (!_verification(raw.cuid)) { + if (!isVerification(raw.cuid)) { throw new Error('Parameter \'CUID\' is not a valid UUID value!'); } @@ -153,16 +152,16 @@ function _createPackage(raw) { data.push(raw.text.toString()); var json = JSON.stringify(data); - return _encrypt(json); + return encrypt(json); } -exports._verification = _verification; +exports.isVerification = isVerification; /** * Validation UUID format string. * @param {String} data - The string to check. * @returns {Boolean} */ -function _verification(data) { +function isVerification(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); -- cgit v1.2.3