From 67fdec20726e48ba3a934cb25bb30d47ec4a4f29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaroslav=20De=20La=20Pe=C3=B1a=20Smirnov?= Date: Wed, 29 Nov 2017 11:44:34 +0300 Subject: Initial commit, version 0.5.3 --- node_modules/base64id/.npmignore | 3 + node_modules/base64id/LICENSE | 22 ++++++++ node_modules/base64id/README.md | 18 ++++++ node_modules/base64id/lib/base64id.js | 103 ++++++++++++++++++++++++++++++++++ node_modules/base64id/package.json | 89 +++++++++++++++++++++++++++++ 5 files changed, 235 insertions(+) create mode 100644 node_modules/base64id/.npmignore create mode 100644 node_modules/base64id/LICENSE create mode 100644 node_modules/base64id/README.md create mode 100644 node_modules/base64id/lib/base64id.js create mode 100644 node_modules/base64id/package.json (limited to 'node_modules/base64id') diff --git a/node_modules/base64id/.npmignore b/node_modules/base64id/.npmignore new file mode 100644 index 0000000..39e9864 --- /dev/null +++ b/node_modules/base64id/.npmignore @@ -0,0 +1,3 @@ +support +test +examples diff --git a/node_modules/base64id/LICENSE b/node_modules/base64id/LICENSE new file mode 100644 index 0000000..0d03c83 --- /dev/null +++ b/node_modules/base64id/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2012-2016 Kristian Faeldt + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/base64id/README.md b/node_modules/base64id/README.md new file mode 100644 index 0000000..17689e6 --- /dev/null +++ b/node_modules/base64id/README.md @@ -0,0 +1,18 @@ +base64id +======== + +Node.js module that generates a base64 id. + +Uses crypto.randomBytes when available, falls back to unsafe methods for node.js <= 0.4. + +To increase performance, random bytes are buffered to minimize the number of synchronous calls to crypto.randomBytes. + +## Installation + + $ npm install base64id + +## Usage + + var base64id = require('base64id'); + + var id = base64id.generateId(); diff --git a/node_modules/base64id/lib/base64id.js b/node_modules/base64id/lib/base64id.js new file mode 100644 index 0000000..f688159 --- /dev/null +++ b/node_modules/base64id/lib/base64id.js @@ -0,0 +1,103 @@ +/*! + * base64id v0.1.0 + */ + +/** + * Module dependencies + */ + +var crypto = require('crypto'); + +/** + * Constructor + */ + +var Base64Id = function() { }; + +/** + * Get random bytes + * + * Uses a buffer if available, falls back to crypto.randomBytes + */ + +Base64Id.prototype.getRandomBytes = function(bytes) { + + var BUFFER_SIZE = 4096 + var self = this; + + bytes = bytes || 12; + + if (bytes > BUFFER_SIZE) { + return crypto.randomBytes(bytes); + } + + var bytesInBuffer = parseInt(BUFFER_SIZE/bytes); + var threshold = parseInt(bytesInBuffer*0.85); + + if (!threshold) { + return crypto.randomBytes(bytes); + } + + if (this.bytesBufferIndex == null) { + this.bytesBufferIndex = -1; + } + + if (this.bytesBufferIndex == bytesInBuffer) { + this.bytesBuffer = null; + this.bytesBufferIndex = -1; + } + + // No buffered bytes available or index above threshold + if (this.bytesBufferIndex == -1 || this.bytesBufferIndex > threshold) { + + if (!this.isGeneratingBytes) { + this.isGeneratingBytes = true; + crypto.randomBytes(BUFFER_SIZE, function(err, bytes) { + self.bytesBuffer = bytes; + self.bytesBufferIndex = 0; + self.isGeneratingBytes = false; + }); + } + + // Fall back to sync call when no buffered bytes are available + if (this.bytesBufferIndex == -1) { + return crypto.randomBytes(bytes); + } + } + + var result = this.bytesBuffer.slice(bytes*this.bytesBufferIndex, bytes*(this.bytesBufferIndex+1)); + this.bytesBufferIndex++; + + return result; +} + +/** + * Generates a base64 id + * + * (Original version from socket.io ) + */ + +Base64Id.prototype.generateId = function () { + var rand = new Buffer(15); // multiple of 3 for base64 + if (!rand.writeInt32BE) { + return Math.abs(Math.random() * Math.random() * Date.now() | 0).toString() + + Math.abs(Math.random() * Math.random() * Date.now() | 0).toString(); + } + this.sequenceNumber = (this.sequenceNumber + 1) | 0; + rand.writeInt32BE(this.sequenceNumber, 11); + if (crypto.randomBytes) { + this.getRandomBytes(12).copy(rand); + } else { + // not secure for node 0.4 + [0, 4, 8].forEach(function(i) { + rand.writeInt32BE(Math.random() * Math.pow(2, 32) | 0, i); + }); + } + return rand.toString('base64').replace(/\//g, '_').replace(/\+/g, '-'); +}; + +/** + * Export + */ + +exports = module.exports = new Base64Id(); diff --git a/node_modules/base64id/package.json b/node_modules/base64id/package.json new file mode 100644 index 0000000..b761a2d --- /dev/null +++ b/node_modules/base64id/package.json @@ -0,0 +1,89 @@ +{ + "_args": [ + [ + { + "raw": "base64id@1.0.0", + "scope": null, + "escapedName": "base64id", + "name": "base64id", + "rawSpec": "1.0.0", + "spec": "1.0.0", + "type": "version" + }, + "/mnt/e/Yaroslav/Documents/Webs/nodejs/checkers/node_modules/engine.io" + ] + ], + "_from": "base64id@1.0.0", + "_id": "base64id@1.0.0", + "_inCache": true, + "_location": "/base64id", + "_nodeVersion": "4.4.7", + "_npmOperationalInternal": { + "host": "packages-18-east.internal.npmjs.com", + "tmp": "tmp/base64id-1.0.0.tgz_1480551701495_0.042360062478110194" + }, + "_npmUser": { + "name": "darrachequesne", + "email": "damien.arrachequesne@gmail.com" + }, + "_npmVersion": "2.15.8", + "_phantomChildren": {}, + "_requested": { + "raw": "base64id@1.0.0", + "scope": null, + "escapedName": "base64id", + "name": "base64id", + "rawSpec": "1.0.0", + "spec": "1.0.0", + "type": "version" + }, + "_requiredBy": [ + "/engine.io" + ], + "_resolved": "https://registry.npmjs.org/base64id/-/base64id-1.0.0.tgz", + "_shasum": "47688cb99bb6804f0e06d3e763b1c32e57d8e6b6", + "_shrinkwrap": null, + "_spec": "base64id@1.0.0", + "_where": "/mnt/e/Yaroslav/Documents/Webs/nodejs/checkers/node_modules/engine.io", + "author": { + "name": "Kristian Faeldt", + "email": "faeldt_kristian@cyberagent.co.jp" + }, + "bugs": { + "url": "https://github.com/faeldt/base64id/issues" + }, + "dependencies": {}, + "description": "Generates a base64 id", + "devDependencies": {}, + "directories": {}, + "dist": { + "shasum": "47688cb99bb6804f0e06d3e763b1c32e57d8e6b6", + "tarball": "https://registry.npmjs.org/base64id/-/base64id-1.0.0.tgz" + }, + "engines": { + "node": ">= 0.4.0" + }, + "gitHead": "3c846f0818ff88b683ad39fde2f8e015ce0f9807", + "homepage": "https://github.com/faeldt/base64id#readme", + "license": "MIT", + "main": "./lib/base64id.js", + "maintainers": [ + { + "name": "darrachequesne", + "email": "damien.arrachequesne@gmail.com" + }, + { + "name": "faeldt_kristian", + "email": "kristian.faeldt@gmail.com" + } + ], + "name": "base64id", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/faeldt/base64id.git" + }, + "scripts": {}, + "version": "1.0.0" +} -- cgit v1.2.3