mirror of
				https://github.com/KevinMidboe/zoff.git
				synced 2025-10-29 18:00:23 +00:00 
			
		
		
		
	Added shortid for server and unique id's for remote
This commit is contained in:
		
							
								
								
									
										7
									
								
								server/node_modules/shortid/.npmignore
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								server/node_modules/shortid/.npmignore
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
/templates/
 | 
			
		||||
/examples/
 | 
			
		||||
/test/
 | 
			
		||||
/.idea/
 | 
			
		||||
/browser/
 | 
			
		||||
.jshintrc
 | 
			
		||||
.travis.yml
 | 
			
		||||
							
								
								
									
										65
									
								
								server/node_modules/shortid/Gruntfile.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								server/node_modules/shortid/Gruntfile.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,65 @@
 | 
			
		||||
'use strict';
 | 
			
		||||
 | 
			
		||||
module.exports = function (grunt) {
 | 
			
		||||
 | 
			
		||||
    require('time-grunt')(grunt);
 | 
			
		||||
 | 
			
		||||
    grunt.initConfig({
 | 
			
		||||
        browserify: {
 | 
			
		||||
            browser: {
 | 
			
		||||
                src: [ require('./package.json').main ],
 | 
			
		||||
                dest: './browser/shortid.js'
 | 
			
		||||
            },
 | 
			
		||||
            tests: {
 | 
			
		||||
                src: [
 | 
			
		||||
                    './test/**/*.test.js'
 | 
			
		||||
                ],
 | 
			
		||||
                dest: './browser/shortid.test.js'
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        open: {
 | 
			
		||||
            test: {
 | 
			
		||||
                path: './test/index.html',
 | 
			
		||||
                app: 'Google Chrome'
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        mochaTest: {
 | 
			
		||||
            notify: {
 | 
			
		||||
                src: 'test/**/*.test.js',
 | 
			
		||||
                options: {
 | 
			
		||||
                    reporter: 'spec',
 | 
			
		||||
                    timeout: 50000
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        jshint: {
 | 
			
		||||
            options: {
 | 
			
		||||
                jshintrc: '.jshintrc'
 | 
			
		||||
            },
 | 
			
		||||
            all: [
 | 
			
		||||
                'Gruntfile.js',
 | 
			
		||||
                'lib/**/*.js',
 | 
			
		||||
                'tests/*'
 | 
			
		||||
            ]
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    });
 | 
			
		||||
    require('load-grunt-tasks')(grunt);
 | 
			
		||||
 | 
			
		||||
    grunt.registerTask('build', [
 | 
			
		||||
        'browserify'
 | 
			
		||||
    ]);
 | 
			
		||||
 | 
			
		||||
    grunt.registerTask('test', [
 | 
			
		||||
        'jshint',
 | 
			
		||||
        'mochaTest'
 | 
			
		||||
    ]);
 | 
			
		||||
 | 
			
		||||
    grunt.registerTask('default', [
 | 
			
		||||
        'build',
 | 
			
		||||
        'test'
 | 
			
		||||
    ]);
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										34
									
								
								server/node_modules/shortid/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								server/node_modules/shortid/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
			
		||||
Copyright (c) Dylan Greene
 | 
			
		||||
All rights reserved.
 | 
			
		||||
 | 
			
		||||
MIT +no-false-attribs License
 | 
			
		||||
 | 
			
		||||
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.
 | 
			
		||||
 | 
			
		||||
Distributions of all or part of the Software intended to be used
 | 
			
		||||
by the recipients as they would use the unmodified Software,
 | 
			
		||||
containing modifications that substantially alter, remove, or
 | 
			
		||||
disable functionality of the Software, outside of the documented
 | 
			
		||||
configuration mechanisms provided by the Software, shall be
 | 
			
		||||
modified such that the Original Author's bug reporting email
 | 
			
		||||
addresses and urls are either replaced with the contact information
 | 
			
		||||
of the parties responsible for the changes, or removed entirely.
 | 
			
		||||
 | 
			
		||||
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.
 | 
			
		||||
							
								
								
									
										255
									
								
								server/node_modules/shortid/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										255
									
								
								server/node_modules/shortid/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,255 @@
 | 
			
		||||
## shortid  [](https://travis-ci.org/dylang/shortid) [](https://www.npmjs.org/package/shortid)
 | 
			
		||||
 | 
			
		||||
> Amazingly short non-sequential url-friendly unique id generator.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
ShortId creates amazingly short non-sequential url-friendly unique ids.  Perfect for url shorteners, MongoDB and Reddis ids, and any other id users might see.
 | 
			
		||||
 | 
			
		||||
 * By default 7-14 url-friendly characters: `A-Z`, `a-z`, `0-9`, `_-`
 | 
			
		||||
 * Non-sequential so they are not predictable.
 | 
			
		||||
 * Supports `cluster` (automatically), custom seeds, custom alphabet.
 | 
			
		||||
 * Can generate any number of ids without duplicates, even millions per day.
 | 
			
		||||
 * Perfect for games, especially if you are concerned about cheating so you don't want an easily guessable id.
 | 
			
		||||
 * Apps can be restarted any number of times without any chance of repeating an id.
 | 
			
		||||
 * Popular replacement for Mongo ID/Mongoose ID.
 | 
			
		||||
 * Works in Node, io.js, and web browsers.
 | 
			
		||||
 * Includes [Mocha](http://visionmedia.github.com/mocha/) tests.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Usage
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
var shortid = require('shortid');
 | 
			
		||||
 | 
			
		||||
console.log(shortid.generate());
 | 
			
		||||
//PPBqWA9
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Mongoose Unique Id
 | 
			
		||||
```js
 | 
			
		||||
_id: {
 | 
			
		||||
    type: String,
 | 
			
		||||
    unique: true,
 | 
			
		||||
    'default': shortid.generate
 | 
			
		||||
},
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Browser Compatibility
 | 
			
		||||
 | 
			
		||||
The best way to use `shortid` in the browser is via [browserify](http://browserify.org/) or [webpack](http://webpack.github.io/).
 | 
			
		||||
 | 
			
		||||
These tools will automatically only include the files necessary for browser compatibility.
 | 
			
		||||
 | 
			
		||||
All tests will run in the browser as well:
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
## build the bundle, then open Mocha in a browser to see the tests run.
 | 
			
		||||
$ grunt build open
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Example
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
~/projects/shortid ❯ node examples/examples.js
 | 
			
		||||
eWRhpRV
 | 
			
		||||
23TplPdS
 | 
			
		||||
46Juzcyx
 | 
			
		||||
dBvJIh-H
 | 
			
		||||
2WEKaVNO
 | 
			
		||||
7oet_d9Z
 | 
			
		||||
dogPzIz8
 | 
			
		||||
nYrnfYEv
 | 
			
		||||
a4vhAoFG
 | 
			
		||||
hwX6aOr7
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#### Real World Examples
 | 
			
		||||
 | 
			
		||||
`shortId` was created for Node Knockout 2011 winner for Most Fun [Doodle Or Die](http://doodleordie.com).
 | 
			
		||||
Millions of doodles have been saved with `shortId` filenames. Every log message gets a `shortId` to make it easy
 | 
			
		||||
for us to look up later.
 | 
			
		||||
 | 
			
		||||
Here are some other projects that use shortId:
 | 
			
		||||
 | 
			
		||||
* [bevy](https://npmjs.org/package/bevy) - A simple server to manage multiple Node services.
 | 
			
		||||
* [capre](https://npmjs.org/package/capre) - Cross-Server Data Replication.
 | 
			
		||||
* [cordova-build](https://www.npmjs.org/package/cordova-build) - an alternative to phonegap build that runs on your servers/agents.
 | 
			
		||||
* [couchdb-tools](https://www.npmjs.org/package/couchdb-tools) - A library of handy functions for use when working with CouchDB documents.
 | 
			
		||||
* [CleverStack/clever-email](https://github.com/CleverStack/clever-email) - E-mail system for CleverStack.
 | 
			
		||||
* [CloudTypes](https://github.com/ticup/CloudTypes) - JavaScript end2end implementation of the Cloud Types model for Eventual Consistency programming.
 | 
			
		||||
* [dnode-tarantula](https://github.com/jutaz/dnode-tarantula) - an asynchronous rpc and event system for node.js based on dnode-protocol and TCP sockets.
 | 
			
		||||
* [mongoose-url-shortener](https://www.npmjs.org/package/mongoose-url-shortener) - A simple URL Shortening library for NodeJS using Promises/A+ results.
 | 
			
		||||
* [mozilla/smokejumper](https://github.com/mozilla/smokejumper) - The Smoke Jumper project is an effort to bring dead simple, secure, P2P file sharing to Firefox.
 | 
			
		||||
* [shortness](https://npmjs.org/package/shortness) - Node based URL shortener that uses SQLite.
 | 
			
		||||
* [file-db](https://npmjs.org/package/file-db) - Document database that uses directories and files to store its data, supporting nested key-value objects in named collections.
 | 
			
		||||
* [resume-generator](https://www.npmjs.org/package/resume-generator) - Resume Generator.
 | 
			
		||||
* [riffmint](https://npmjs.org/package/riffmint) - Collaboration in musical space.
 | 
			
		||||
* [rap1ds/dippa](https://github.com/rap1ds/dippa) - Dippa Editor – A web-based LaTeX editor
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### API
 | 
			
		||||
 | 
			
		||||
`var shortid = require('shortid');`
 | 
			
		||||
 | 
			
		||||
---------------------------------------
 | 
			
		||||
 | 
			
		||||
#### `shortid.generate()`
 | 
			
		||||
 | 
			
		||||
__Returns__ `string` non-sequential unique id.
 | 
			
		||||
 | 
			
		||||
__Example__
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
users.insert({
 | 
			
		||||
    _id: shortid.generate()
 | 
			
		||||
    name: ...
 | 
			
		||||
    email: ...
 | 
			
		||||
    });
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
---------------------------------------
 | 
			
		||||
 | 
			
		||||
#### `characters(string)`
 | 
			
		||||
 | 
			
		||||
__Default:__ `'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_'`
 | 
			
		||||
 | 
			
		||||
__Returns__ new alphabet as a `string` 
 | 
			
		||||
 | 
			
		||||
__Recommendation:__ If you don't like _ or -, you can to set new characters to use. 
 | 
			
		||||
 | 
			
		||||
__Optional__
 | 
			
		||||
 | 
			
		||||
Change the characters used.
 | 
			
		||||
 | 
			
		||||
You must provide a string of all 64 unique characters. Order is not important.
 | 
			
		||||
 | 
			
		||||
The default characters provided were selected because they are url safe.
 | 
			
		||||
 | 
			
		||||
__Example__
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
// use $ and @ instead of - and _
 | 
			
		||||
shortid.characters('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$@');
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
// any 64 unicode characters work, but I wouldn't recommend this.
 | 
			
		||||
shortid.characters('ⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ①②③④⑤⑥⑦⑧⑨⑩⑪⑫');
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
---------------------------------------
 | 
			
		||||
 | 
			
		||||
#### `isValid(id)`
 | 
			
		||||
 | 
			
		||||
__Returns__ `boolean`
 | 
			
		||||
 | 
			
		||||
Check to see if an id is a valid `shortid`. Note: This only means the id _could_ have been generated by `shortid`, it doesn't guarantee it.
 | 
			
		||||
 | 
			
		||||
__Example__
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
shortid.isValid('41XTDbE');
 | 
			
		||||
// true
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
shortid.isValid('i have spaces');
 | 
			
		||||
// false
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
---------------------------------------
 | 
			
		||||
 | 
			
		||||
#### `shortid.worker(integer)`
 | 
			
		||||
 | 
			
		||||
__Default:__ `process.env.NODE_UNIQUE_ID || 0`
 | 
			
		||||
 | 
			
		||||
__Recommendation:__ You typically won't want to change this.
 | 
			
		||||
 | 
			
		||||
__Optional__
 | 
			
		||||
 | 
			
		||||
If you are running multiple server processes then you should make sure every one has a unique `worker` id. Should be an integer between 0 and 16. 
 | 
			
		||||
If you do not do this there is very little chance of two servers generating the same id, but it is theatrically possible 
 | 
			
		||||
if both are generated in the exact same second and are generating the same number of ids that second and a half-dozen random numbers are all exactly the same. 
 | 
			
		||||
 | 
			
		||||
__Example__
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
shortId.seed(1000);
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
---------------------------------------
 | 
			
		||||
 | 
			
		||||
#### `shortid.seed(float)`
 | 
			
		||||
 | 
			
		||||
__Default:__ `1`
 | 
			
		||||
 | 
			
		||||
__Recommendation:__ You typically won't want to change this.
 | 
			
		||||
 | 
			
		||||
__Optional__
 | 
			
		||||
 | 
			
		||||
Choose a unique value that will seed the random number generator so users won't be able to figure out the pattern of the unique ids. Call it just once in your application before using `shortId` and always use the same value in your application.
 | 
			
		||||
 | 
			
		||||
Most developers won't need to use this, it's mainly for testing ShortId. 
 | 
			
		||||
 | 
			
		||||
If you are worried about users somehow decrypting the id then use it as a secret value for increased encryption.
 | 
			
		||||
 | 
			
		||||
__Example__
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
shortId.seed(1000);
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### About the Author
 | 
			
		||||
 | 
			
		||||
Hi! Thanks for checking out this project! My name is **Dylan Greene**. When not overwhelmed with my two young kids I enjoy contributing
 | 
			
		||||
to the open source community. I'm also a tech lead at [Opower](http://opower.com). [](https://github.com/dylang) [](https://twitter.com/dylang)
 | 
			
		||||
 | 
			
		||||
Here's some of my other Node projects:
 | 
			
		||||
 | 
			
		||||
| Name | Description | npm Downloads |
 | 
			
		||||
|---|---|---|
 | 
			
		||||
| [`grunt‑notify`](https://github.com/dylang/grunt-notify) | Automatic desktop notifications for Grunt errors and warnings using Growl for OS X or Windows, Mountain Lion and Mavericks Notification Center, and Notify-Send. | [](https://www.npmjs.org/package/grunt-notify) |
 | 
			
		||||
| [`npm‑check`](https://github.com/dylang/npm-check) | Check for outdated, incorrect, and unused dependencies. | [](https://www.npmjs.org/package/npm-check) |
 | 
			
		||||
| [`grunt‑prompt`](https://github.com/dylang/grunt-prompt) | Interactive prompt for your Grunt config using console checkboxes, text input with filtering, password fields. | [](https://www.npmjs.org/package/grunt-prompt) |
 | 
			
		||||
| [`rss`](https://github.com/dylang/node-rss) | RSS feed generator. Add RSS feeds to any project. Supports enclosures and GeoRSS. | [](https://www.npmjs.org/package/rss) |
 | 
			
		||||
| [`xml`](https://github.com/dylang/node-xml) | Fast and simple xml generator. Supports attributes, CDATA, etc. Includes tests and examples. | [](https://www.npmjs.org/package/xml) |
 | 
			
		||||
| [`changelog`](https://github.com/dylang/changelog) | Command line tool (and Node module) that generates a changelog in color output, markdown, or json for modules in npmjs.org's registry as well as any public github.com repo. | [](https://www.npmjs.org/package/changelog) |
 | 
			
		||||
| [`grunt‑attention`](https://github.com/dylang/grunt-attention) | Display attention-grabbing messages in the terminal | [](https://www.npmjs.org/package/grunt-attention) |
 | 
			
		||||
| [`observatory`](https://github.com/dylang/observatory) | Beautiful UI for showing tasks running on the command line. | [](https://www.npmjs.org/package/observatory) |
 | 
			
		||||
| [`anthology`](https://github.com/dylang/anthology) | Module information and stats for any @npmjs user | [](https://www.npmjs.org/package/anthology) |
 | 
			
		||||
| [`grunt‑cat`](https://github.com/dylang/grunt-cat) | Echo a file to the terminal. Works with text, figlets, ascii art, and full-color ansi. | [](https://www.npmjs.org/package/grunt-cat) |
 | 
			
		||||
 | 
			
		||||
_This list was generated using [anthology](https://github.com/dylang/anthology)._
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### License
 | 
			
		||||
Copyright (c) 2015 Dylan Greene, contributors.
 | 
			
		||||
 | 
			
		||||
Released under the [MIT license](https://tldrlegal.com/license/mit-license).
 | 
			
		||||
 | 
			
		||||
Screenshots are [CC BY-SA](http://creativecommons.org/licenses/by-sa/4.0/) (Attribution-ShareAlike).
 | 
			
		||||
 | 
			
		||||
***
 | 
			
		||||
_Generated using [grunt-readme](https://github.com/assemble/grunt-readme) with [grunt-templates-dylang](https://github.com/dylang/grunt-templates-dylang) on Sunday, April 5, 2015._
 | 
			
		||||
_To make changes to this document look in `/templates/readme/`
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										98
									
								
								server/node_modules/shortid/lib/alphabet.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										98
									
								
								server/node_modules/shortid/lib/alphabet.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,98 @@
 | 
			
		||||
'use strict';
 | 
			
		||||
 | 
			
		||||
var randomFromSeed = require('./random/random-from-seed');
 | 
			
		||||
 | 
			
		||||
var ORIGINAL = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-';
 | 
			
		||||
var alphabet;
 | 
			
		||||
var previousSeed;
 | 
			
		||||
 | 
			
		||||
var shuffled;
 | 
			
		||||
 | 
			
		||||
function reset() {
 | 
			
		||||
    shuffled = false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function setCharacters(_alphabet_) {
 | 
			
		||||
    if (!_alphabet_) {
 | 
			
		||||
        if (alphabet !== ORIGINAL) {
 | 
			
		||||
            alphabet = ORIGINAL;
 | 
			
		||||
            reset();
 | 
			
		||||
        }
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (_alphabet_ === alphabet) {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (_alphabet_.length !== ORIGINAL.length) {
 | 
			
		||||
        throw new Error('Custom alphabet for shortid must be ' + ORIGINAL.length + ' unique characters. You submitted ' + _alphabet_.length + ' characters: ' + _alphabet_);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    var unique = _alphabet_.split('').filter(function(item, ind, arr){
 | 
			
		||||
       return ind !== arr.lastIndexOf(item);
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    if (unique.length) {
 | 
			
		||||
        throw new Error('Custom alphabet for shortid must be ' + ORIGINAL.length + ' unique characters. These characters were not unique: ' + unique.join(', '));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    alphabet = _alphabet_;
 | 
			
		||||
    reset();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function characters(_alphabet_) {
 | 
			
		||||
    setCharacters(_alphabet_);
 | 
			
		||||
    return alphabet;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function setSeed(seed) {
 | 
			
		||||
    randomFromSeed.seed(seed);
 | 
			
		||||
    if (previousSeed !== seed) {
 | 
			
		||||
        reset();
 | 
			
		||||
        previousSeed = seed;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function shuffle() {
 | 
			
		||||
    if (!alphabet) {
 | 
			
		||||
        setCharacters(ORIGINAL);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    var sourceArray = alphabet.split('');
 | 
			
		||||
    var targetArray = [];
 | 
			
		||||
    var r = randomFromSeed.nextValue();
 | 
			
		||||
    var characterIndex;
 | 
			
		||||
 | 
			
		||||
    while (sourceArray.length > 0) {
 | 
			
		||||
        r = randomFromSeed.nextValue();
 | 
			
		||||
        characterIndex = Math.floor(r * sourceArray.length);
 | 
			
		||||
        targetArray.push(sourceArray.splice(characterIndex, 1)[0]);
 | 
			
		||||
    }
 | 
			
		||||
    return targetArray.join('');
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function getShuffled() {
 | 
			
		||||
    if (shuffled) {
 | 
			
		||||
        return shuffled;
 | 
			
		||||
    }
 | 
			
		||||
    shuffled = shuffle();
 | 
			
		||||
    return shuffled;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * lookup shuffled letter
 | 
			
		||||
 * @param index
 | 
			
		||||
 * @returns {string}
 | 
			
		||||
 */
 | 
			
		||||
function lookup(index) {
 | 
			
		||||
    var alphabetShuffled = getShuffled();
 | 
			
		||||
    return alphabetShuffled[index];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
    characters: characters,
 | 
			
		||||
    seed: setSeed,
 | 
			
		||||
    lookup: lookup,
 | 
			
		||||
    shuffled: getShuffled
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										17
									
								
								server/node_modules/shortid/lib/decode.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								server/node_modules/shortid/lib/decode.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
'use strict';
 | 
			
		||||
var alphabet = require('./alphabet');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Decode the id to get the version and worker
 | 
			
		||||
 * Mainly for debugging and testing.
 | 
			
		||||
 * @param id - the shortid-generated id.
 | 
			
		||||
 */
 | 
			
		||||
function decode(id) {
 | 
			
		||||
    var characters = alphabet.shuffled();
 | 
			
		||||
    return {
 | 
			
		||||
        version: characters.indexOf(id.substr(0, 1)) & 0x0f,
 | 
			
		||||
        worker: characters.indexOf(id.substr(1, 1)) & 0x0f
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports = decode;
 | 
			
		||||
							
								
								
									
										19
									
								
								server/node_modules/shortid/lib/encode.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								server/node_modules/shortid/lib/encode.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
			
		||||
'use strict';
 | 
			
		||||
 | 
			
		||||
var randomByte = require('./random/random-byte');
 | 
			
		||||
 | 
			
		||||
function encode(lookup, number) {
 | 
			
		||||
    var loopCounter = 0;
 | 
			
		||||
    var done;
 | 
			
		||||
 | 
			
		||||
    var str = '';
 | 
			
		||||
 | 
			
		||||
    while (!done) {
 | 
			
		||||
        str = str + lookup( ( (number >> (4 * loopCounter)) & 0x0f ) | randomByte() );
 | 
			
		||||
        done = number < (Math.pow(16, loopCounter + 1 ) );
 | 
			
		||||
        loopCounter++;
 | 
			
		||||
    }
 | 
			
		||||
    return str;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports = encode;
 | 
			
		||||
							
								
								
									
										100
									
								
								server/node_modules/shortid/lib/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										100
									
								
								server/node_modules/shortid/lib/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,100 @@
 | 
			
		||||
'use strict';
 | 
			
		||||
 | 
			
		||||
var alphabet = require('./alphabet');
 | 
			
		||||
var encode = require('./encode');
 | 
			
		||||
var decode = require('./decode');
 | 
			
		||||
var isValid = require('./is-valid');
 | 
			
		||||
 | 
			
		||||
// Ignore all milliseconds before a certain time to reduce the size of the date entropy without sacrificing uniqueness.
 | 
			
		||||
// This number should be updated every year or so to keep the generated id short.
 | 
			
		||||
// To regenerate `new Date() - 0` and bump the version. Always bump the version!
 | 
			
		||||
var REDUCE_TIME = 1426452414093;
 | 
			
		||||
 | 
			
		||||
// don't change unless we change the algos or REDUCE_TIME
 | 
			
		||||
// must be an integer and less than 16
 | 
			
		||||
var version = 5;
 | 
			
		||||
 | 
			
		||||
// if you are using cluster or multiple servers use this to make each instance
 | 
			
		||||
// has a unique value for worker
 | 
			
		||||
// Note: I don't know if this is automatically set when using third
 | 
			
		||||
// party cluster solutions such as pm2.
 | 
			
		||||
var clusterWorkerId = require('./util/cluster-worker-id') || 0;
 | 
			
		||||
 | 
			
		||||
// Counter is used when shortid is called multiple times in one second.
 | 
			
		||||
var counter;
 | 
			
		||||
 | 
			
		||||
// Remember the last time shortid was called in case counter is needed.
 | 
			
		||||
var previousSeconds;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Generate unique id
 | 
			
		||||
 * Returns string id
 | 
			
		||||
 */
 | 
			
		||||
function generate() {
 | 
			
		||||
 | 
			
		||||
    var str = '';
 | 
			
		||||
 | 
			
		||||
    var seconds = Math.floor((Date.now() - REDUCE_TIME) * 0.001);
 | 
			
		||||
 | 
			
		||||
    if (seconds === previousSeconds) {
 | 
			
		||||
        counter++;
 | 
			
		||||
    } else {
 | 
			
		||||
        counter = 0;
 | 
			
		||||
        previousSeconds = seconds;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    str = str + encode(alphabet.lookup, version);
 | 
			
		||||
    str = str + encode(alphabet.lookup, clusterWorkerId);
 | 
			
		||||
    if (counter > 0) {
 | 
			
		||||
        str = str + encode(alphabet.lookup, counter);
 | 
			
		||||
    }
 | 
			
		||||
    str = str + encode(alphabet.lookup, seconds);
 | 
			
		||||
 | 
			
		||||
    return str;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Set the seed.
 | 
			
		||||
 * Highly recommended if you don't want people to try to figure out your id schema.
 | 
			
		||||
 * exposed as shortid.seed(int)
 | 
			
		||||
 * @param seed Integer value to seed the random alphabet.  ALWAYS USE THE SAME SEED or you might get overlaps.
 | 
			
		||||
 */
 | 
			
		||||
function seed(seedValue) {
 | 
			
		||||
    alphabet.seed(seedValue);
 | 
			
		||||
    return module.exports;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Set the cluster worker or machine id
 | 
			
		||||
 * exposed as shortid.worker(int)
 | 
			
		||||
 * @param workerId worker must be positive integer.  Number less than 16 is recommended.
 | 
			
		||||
 * returns shortid module so it can be chained.
 | 
			
		||||
 */
 | 
			
		||||
function worker(workerId) {
 | 
			
		||||
    clusterWorkerId = workerId;
 | 
			
		||||
    return module.exports;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * sets new characters to use in the alphabet
 | 
			
		||||
 * returns the shuffled alphabet
 | 
			
		||||
 */
 | 
			
		||||
function characters(newCharacters) {
 | 
			
		||||
    if (newCharacters !== undefined) {
 | 
			
		||||
        alphabet.characters(newCharacters);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return alphabet.shuffled();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Export all other functions as properties of the generate function
 | 
			
		||||
module.exports = generate;
 | 
			
		||||
module.exports.generate = generate;
 | 
			
		||||
module.exports.seed = seed;
 | 
			
		||||
module.exports.worker = worker;
 | 
			
		||||
module.exports.characters = characters;
 | 
			
		||||
module.exports.decode = decode;
 | 
			
		||||
module.exports.isValid = isValid;
 | 
			
		||||
							
								
								
									
										19
									
								
								server/node_modules/shortid/lib/is-valid.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								server/node_modules/shortid/lib/is-valid.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
			
		||||
'use strict';
 | 
			
		||||
var alphabet = require('./alphabet');
 | 
			
		||||
 | 
			
		||||
function isShortId(id) {
 | 
			
		||||
    if (!id || typeof id !== 'string' || id.length < 6 ) {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    var characters = alphabet.characters();
 | 
			
		||||
    var invalidCharacters = id.split('').map(function(char){
 | 
			
		||||
        if (characters.indexOf(char) === -1) {
 | 
			
		||||
            return char;
 | 
			
		||||
        }
 | 
			
		||||
    }).join('').split('').join('');
 | 
			
		||||
 | 
			
		||||
    return invalidCharacters.length === 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports = isShortId;
 | 
			
		||||
							
								
								
									
										14
									
								
								server/node_modules/shortid/lib/random/random-byte-browser.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								server/node_modules/shortid/lib/random/random-byte-browser.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
			
		||||
'use strict';
 | 
			
		||||
 | 
			
		||||
var crypto = window.crypto || window.msCrypto; // IE 11 uses window.msCrypto
 | 
			
		||||
 | 
			
		||||
function randomByte() {
 | 
			
		||||
    if (!crypto || !crypto.getRandomValues) {
 | 
			
		||||
        return Math.floor(Math.random() * 256) & 0x30;
 | 
			
		||||
    }
 | 
			
		||||
    var dest = new Uint8Array(1);
 | 
			
		||||
    crypto.getRandomValues(dest);
 | 
			
		||||
    return dest[0] & 0x30;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports = randomByte;
 | 
			
		||||
							
								
								
									
										10
									
								
								server/node_modules/shortid/lib/random/random-byte.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								server/node_modules/shortid/lib/random/random-byte.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
'use strict';
 | 
			
		||||
 | 
			
		||||
var crypto = require('crypto');
 | 
			
		||||
var randomBytes = crypto.randomBytes;
 | 
			
		||||
 | 
			
		||||
function randomByte() {
 | 
			
		||||
    return randomBytes(1)[0] & 0x30;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports = randomByte;
 | 
			
		||||
							
								
								
									
										25
									
								
								server/node_modules/shortid/lib/random/random-from-seed.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								server/node_modules/shortid/lib/random/random-from-seed.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
			
		||||
'use strict';
 | 
			
		||||
 | 
			
		||||
// Found this seed-based random generator somewhere
 | 
			
		||||
// Based on The Central Randomizer 1.3 (C) 1997 by Paul Houle (houle@msc.cornell.edu)
 | 
			
		||||
 | 
			
		||||
var seed = 1;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * return a random number based on a seed
 | 
			
		||||
 * @param seed
 | 
			
		||||
 * @returns {number}
 | 
			
		||||
 */
 | 
			
		||||
function getNextValue() {
 | 
			
		||||
    seed = (seed * 9301 + 49297) % 233280;
 | 
			
		||||
    return seed/(233280.0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function setSeed(_seed_) {
 | 
			
		||||
    seed = _seed_;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
    nextValue: getNextValue,
 | 
			
		||||
    seed: setSeed
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										3
									
								
								server/node_modules/shortid/lib/util/cluster-worker-id-browser.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								server/node_modules/shortid/lib/util/cluster-worker-id-browser.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
'use strict';
 | 
			
		||||
 | 
			
		||||
module.exports = 0;
 | 
			
		||||
							
								
								
									
										3
									
								
								server/node_modules/shortid/lib/util/cluster-worker-id.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								server/node_modules/shortid/lib/util/cluster-worker-id.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
'use strict';
 | 
			
		||||
 | 
			
		||||
module.exports = parseInt(process.env.NODE_UNIQUE_ID || 0, 10);
 | 
			
		||||
							
								
								
									
										62
									
								
								server/node_modules/shortid/package.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								server/node_modules/shortid/package.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "zöff-backend",
 | 
			
		||||
  "name": "zoffbackend",
 | 
			
		||||
  "version": "0.0.1",
 | 
			
		||||
  "description": "Zöff, the shared YouTube based radio services",
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,7 @@ var server;
 | 
			
		||||
This if for the localhost running
 | 
			
		||||
 | 
			
		||||
******/
 | 
			
		||||
localhost = false;
 | 
			
		||||
localhost = true;
 | 
			
		||||
 | 
			
		||||
//https server
 | 
			
		||||
if(localhost)
 | 
			
		||||
@@ -25,6 +25,7 @@ var express = require('express');
 | 
			
		||||
var app = express();
 | 
			
		||||
//var server = require('http').createServer(app);
 | 
			
		||||
var io = require('socket.io')(server);
 | 
			
		||||
var shortid = require('shortid');
 | 
			
		||||
 | 
			
		||||
//db
 | 
			
		||||
var mongojs = require('mongojs');
 | 
			
		||||
@@ -63,6 +64,7 @@ io.on('connection', function(socket){
 | 
			
		||||
  var tot_lists = [];
 | 
			
		||||
  var in_list = false;
 | 
			
		||||
  var name = rndName(guid,8);
 | 
			
		||||
  var short_id = shortid.generate();
 | 
			
		||||
 | 
			
		||||
  socket.on('namechange', function(data)
 | 
			
		||||
  {
 | 
			
		||||
@@ -154,8 +156,8 @@ io.on('connection', function(socket){
 | 
			
		||||
    	list = list.split(',');
 | 
			
		||||
    	coll = list[0].toLowerCase();
 | 
			
		||||
      socket.join(coll);
 | 
			
		||||
      socket.join(rndName(socket.id, 10));
 | 
			
		||||
      socket.emit("id", rndName(socket.id, 10));
 | 
			
		||||
      socket.join(short_id);
 | 
			
		||||
      socket.emit("id", short_id);
 | 
			
		||||
 | 
			
		||||
      //console.log(name + " joined list " + coll);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user