{"_id":"guide","_rev":"9-fded20ce21e032973ddd80fdf63d6008","name":"guide","description":"Encrypted Globally Unique Identifier generator.","dist-tags":{"latest":"1.1.0"},"versions":{"0.1.0":{"name":"guide","main":"guide.js","author":{"name":"Roland Poulter"},"version":"0.1.0","keywords":["router","routes","path","regex","browser"],"homepage":"https://github.com/rolandpoulter/guide","repository":{"type":"git","url":"git://github.com/rolandpoulter/guide.git"},"description":"Another path router.","contributors":[],"dependencies":{"cornerstone":"x"},"_npmUser":{"name":"rolandpoulter","email":"rolandpoulter@gmail.com"},"_id":"guide@0.1.0","devDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.6.2","_defaultsLoaded":true,"dist":{"shasum":"0b372756020fbe6d14ff5b2c8f308c4808939717","tarball":"https://registry.npmjs.org/guide/-/guide-0.1.0.tgz","integrity":"sha512-RbmhAxnqTj6smmHcpAe3bZe3IOkLAuYbL09VS5g4SBuqrdH5U3az0WTyhxbVJXY78AsFy8gc7wn1Pi7SUNTYtA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFKcjcCRloqx2UF2zyIxjd8mEnHlolWg4J7JNrFf9IXIAiEAkJJWE245UVGJ3fRncnQCsYxAF3oxkvRqJk1pYUQAKZs="}]},"maintainers":[{"name":"rolandpoulter","email":"rolandpoulter@gmail.com"}]},"1.0.0":{"author":{"name":"Gajus Kuizinas","email":"gajus@gajus.com","url":"http://gajus.com"},"ava":{"babel":"inherit","require":["babel-register"]},"dependencies":{"base64-url":"^1.3.3","es6-error":"^4.0.1"},"description":"Encrypted Globally Unique Identifier generator.","devDependencies":{"ava":"^0.17.0","babel-cli":"^6.18.0","babel-plugin-transform-flow-comments":"^6.22.0","babel-preset-env":"^1.1.8","eslint":"^3.11.1","babel-plugin-istanbul":"^3.0.0","nyc":"^10.0.0","eslint-config-canonical":"^6.0.0","flow-bin":"^0.37.4","husky":"^0.12.0","semantic-release":"^6.3.5"},"engines":{"node":">5.0.0"},"keywords":["encryption","GUID"],"license":"BSD-3-Clause","main":"dist/index.js","name":"guide","nyc":{"include":["src/**/*.js"],"instrument":false,"reporter":["text-lcov"],"require":["babel-register"],"sourceMap":false},"repository":{"type":"git","url":"git+https://github.com/gajus/guide.git"},"scripts":{"build":"rm -fr ./dist && NODE_ENV=production babel ./src --out-dir ./dist --source-maps","lint":"eslint ./src && flow","precommit":"npm run test && npm run lint","test":"NODE_ENV=development ava --verbose"},"version":"1.0.0","gitHead":"97437aea1cf05fa9e59d7428167096933cbde401","bugs":{"url":"https://github.com/gajus/guide/issues"},"homepage":"https://github.com/gajus/guide#readme","_id":"guide@1.0.0","_shasum":"3e291f5047d5573379668156bf678f1a7d439e57","_from":".","_npmVersion":"4.0.5","_nodeVersion":"7.4.0","_npmUser":{"name":"gajus","email":"gajus@gajus.com"},"dist":{"shasum":"3e291f5047d5573379668156bf678f1a7d439e57","tarball":"https://registry.npmjs.org/guide/-/guide-1.0.0.tgz","integrity":"sha512-WMK7izJ/TcVMVhVXmT2ocDOA8W4WCLYN2Fs+YSpbzQ3CGUSziL0/1ZD/pT3rGvuilcGWIIm72EAEITCdZWi9ww==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG0WP35nRgNIipK8ZNCsD/ykcvQKXh14K5JBYFFls6oFAiATiYpWSSfY52XHD499X546VUMMf3JoxCaaWswiNV3CvQ=="}]},"maintainers":[{"name":"gajus","email":"gajus@gajus.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/guide-1.0.0.tgz_1485989283445_0.1125127247069031"}},"1.1.0":{"author":{"name":"Gajus Kuizinas","email":"gajus@gajus.com","url":"http://gajus.com"},"ava":{"babel":"inherit","require":["babel-register"]},"dependencies":{"base64-url":"^1.3.3","es6-error":"^4.0.1"},"description":"Encrypted Globally Unique Identifier generator.","devDependencies":{"ava":"^0.17.0","babel-cli":"^6.18.0","babel-plugin-istanbul":"^3.0.0","babel-plugin-transform-flow-comments":"^6.22.0","babel-preset-env":"^1.1.8","coveralls":"^2.11.15","eslint":"^3.11.1","eslint-config-canonical":"^6.0.0","flow-bin":"^0.37.4","husky":"^0.12.0","nyc":"^10.0.0","semantic-release":"^6.3.5"},"engines":{"node":">5.0.0"},"keywords":["encryption","GUID"],"license":"BSD-3-Clause","main":"dist/index.js","name":"guide","nyc":{"include":["src/**/*.js"],"instrument":false,"reporter":["text-lcov"],"require":["babel-register"],"sourceMap":false},"repository":{"type":"git","url":"git+https://github.com/gajus/guide.git"},"scripts":{"build":"rm -fr ./dist && NODE_ENV=production babel ./src --out-dir ./dist --source-maps","lint":"eslint ./src && flow","precommit":"npm run test && npm run lint","test":"NODE_ENV=development ava --verbose"},"version":"1.1.0","gitHead":"bfad64503a70022408682752e519735e9aa9e945","bugs":{"url":"https://github.com/gajus/guide/issues"},"homepage":"https://github.com/gajus/guide#readme","_id":"guide@1.1.0","_shasum":"ed2d7e994d3013a84ae91bb353e622c2035f908d","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.5.0","_npmUser":{"name":"gajus","email":"gajus@gajus.com"},"dist":{"shasum":"ed2d7e994d3013a84ae91bb353e622c2035f908d","tarball":"https://registry.npmjs.org/guide/-/guide-1.1.0.tgz","integrity":"sha512-SYSw5z3iLGKcYEs4ZZLtnY38+T6J3gIHWwmUEbGb28Vnr+sdc3FAcEmm0KJ+GOPuTD1j+0ctu5lXy8AW2XiIFw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDOBC2PJyiI21BfIbkcuC6cjj6du7pMml7tbDGA4O0HJQIgF8mH0s4zczm1SIpHF/Fbgw1HVJI7SWfKBVlmoY1tijU="}]},"maintainers":[{"name":"gajus","email":"gajus@gajus.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/guide-1.1.0.tgz_1485993215264_0.9631064222194254"}}},"readme":"# GUIDE\n\n[![Travis build status](http://img.shields.io/travis/gajus/guide/master.svg?style=flat-square)](https://travis-ci.org/gajus/guide)\n[![Coveralls](https://img.shields.io/coveralls/gajus/guide.svg?style=flat-square)](https://coveralls.io/github/gajus/guide)\n[![NPM version](http://img.shields.io/npm/v/guide.svg?style=flat-square)](https://www.npmjs.org/package/guide)\n[![Canonical Code Style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical)\n[![Twitter Follow](https://img.shields.io/twitter/follow/kuizinas.svg?style=social&label=Follow)](https://twitter.com/kuizinas)\n\nEncrypted Globally Unique Identifier (GUIDE) generator.\n\n* [Implementation](#implementation)\n* [Use case](#use-case)\n* [API](#api)\n* [Usage](#Usage)\n\n## Implementation\n\n* GUIDE is using aes-256-gcm encryption.\n* Identifiers are encoded using URL-safe base64 encoding.\n\n> `aes-256-gcm` is the closest thing I have found to a misuse resistant algorithm.\n> If you know of a better encryption algorithm (misuse resistant) thats available to Node.js – [raise an issue](https://github.com/gajus/guide/issues).\n\n## Use case\n\nGUIDE is used to mitigate certain types of DDoS attacks.\n\n* [Protecting APIs from the DDoS attacks by encrypting the PKs](https://medium.com/p/97a8a5090c89)\n\n## API\n\n```js\ntype GuidePayloadType = {|\n  id: number | string,\n  namespace: string,\n  type: string\n|};\n\n/**\n* @throws InvalidGuideError Throws if input guide cannot be decrypted.\n* @throws UnexpectedNamespaceValueError Throws if the namespace contained in the payload does not match the expected namespace.\n* @throws UnexpectedResourceTypeNameValueError Throws if the resource type name contained in the payload does not match the expected resource type name.\n*/\ntype FromGuideType = (initializationVectorValue: string, expectedNamespace: string, expectedResourceTypeName: string, guide: string) => GuidePayloadType;\n\n/**\n * @param initializationVectorValue Initialization vector. Must be at least 128 characters long.\n * @param namespace A namespace of the GUID (e.g. company name or the application name).\n * @param type A resource type name (e.g. article).\n */\ntype ToGuideType = (initializationVectorValue: string, namespace: string, type: string, id: number | string) => string;\n\n```\n\n## Usage\n\n```js\nimport {\n  fromGuide,\n  toGuide,\n} from 'guide';\n\nconst initializationVectorValue = 'lGMUlgYOZXkT7MWjRozJ7F3MlSm89SPkop2AvQciBk1xXLGCX5aUy3uIJHEInjQzyHZSnZ0NaQaVpEldAlVWeguOLYkW5ZluwbaHY0iWEgFULRV92GV5KgHj2P5YChgW';\nconst namespace = 'gajus';\nconst resourceTypeName = 'article';\n\nconst guide = toGuide(initializationVectorValue, namespace, resourceTypeName, 1);\n\n// \"ao-CZ7gmFSaFhA4tzWaM2CiOGtt772ZqJDB1k1ty3QWkc24Rx43iYuUc_S0ecZiiWS8aTP-0EQ\"\n\nconst payload = fromGuide(initializationVectorValue, namespace, resourceTypeName, guide);\n\n// {\n//   \"id\": 1,\n//   \"namespace\": \"gajus\",\n//   \"type\": \"article\"\n// }\n\n```\n\n\n## Handling errors\n\n`fromGuide` method can throw the following errors.\n\n|Error constructor name|Description|\n|---|---|\n|`InvalidGuideError`|Throws if input guide cannot be decrypted.|\n|`UnexpectedNamespaceValueError`|Throws if the namespace contained in the payload does not match the expected namespace.|\n|`UnexpectedResourceTypeNameValueError`|Throws if the resource type name contained in the payload does not match the expected resource type name.|\n\nError constructors can be imported from `guide` package.\n\n`UnexpectedNamespaceValueError` and `UnexpectedResourceTypeNameValueError` extend from `InvalidGuideError`. It is enough to check if an error object is an instance of `InvalidGuideError` to assert that an error is a result of an invalid GUIDE.\n\n```js\nimport {\n  fromGuide,\n  InvalidGuideError\n} from 'guide';\n\ntry {\n  fromGuide(initializationVectorValue, namespace, resourceTypeName, guide);\n} catch (error) {\n  if (error instanceof InvalidGuideError) {\n    // Handle error.\n  }\n\n  // Re-throw other errors.\n  throw error;\n}\n\n```\n","maintainers":[{"name":"gajus","email":"gajus@gajus.com"}],"time":{"modified":"2022-06-18T16:30:31.201Z","created":"2011-11-20T01:38:05.525Z","0.1.0":"2011-11-20T01:38:06.802Z","1.0.0":"2017-02-01T22:48:04.184Z","1.1.0":"2017-02-01T23:53:35.839Z"},"author":{"name":"Gajus Kuizinas","email":"gajus@gajus.com","url":"http://gajus.com"},"repository":{"type":"git","url":"git+https://github.com/gajus/guide.git"},"homepage":"https://github.com/gajus/guide#readme","keywords":["encryption","GUID"],"readmeFilename":"README.md","bugs":{"url":"https://github.com/gajus/guide/issues"},"license":"BSD-3-Clause"}