From 471970960279220a128eca0e832afc77cedb6288 Mon Sep 17 00:00:00 2001 From: Priyatham-sai-chand Date: Sun, 29 Nov 2020 22:35:56 +0530 Subject: [PATCH] auth revamp --- .env | 2 + .gitignore | 2 +- auth/middleware/auth.js | 24 ++ auth/node_modules/context/LICENSE | 21 ++ auth/node_modules/context/README.md | 101 +++++++ .../context/dist/context.cjs.development.js | 180 ++++++++++++ .../dist/context.cjs.development.js.map | 1 + .../dist/context.cjs.production.min.js | 2 + .../dist/context.cjs.production.min.js.map | 1 + auth/node_modules/context/dist/context.esm.js | 176 ++++++++++++ .../context/dist/context.esm.js.map | 1 + auth/node_modules/context/dist/index.d.ts | 39 +++ auth/node_modules/context/dist/index.js | 8 + auth/node_modules/context/package.json | 78 +++++ auth/node_modules/context/src/index.ts | 173 +++++++++++ auth/node_modules/cors/CONTRIBUTING.md | 33 +++ auth/node_modules/cors/HISTORY.md | 58 ++++ auth/node_modules/cors/LICENSE | 22 ++ auth/node_modules/cors/README.md | 243 ++++++++++++++++ auth/node_modules/cors/lib/index.js | 238 +++++++++++++++ auth/node_modules/cors/package.json | 78 +++++ auth/node_modules/dotenv/CHANGELOG.md | 155 ++++++++++ auth/node_modules/dotenv/LICENSE | 23 ++ auth/node_modules/dotenv/README.md | 271 ++++++++++++++++++ auth/node_modules/dotenv/config.js | 11 + auth/node_modules/dotenv/lib/cli-options.js | 13 + auth/node_modules/dotenv/lib/env-options.js | 18 ++ auth/node_modules/dotenv/lib/main.js | 113 ++++++++ auth/node_modules/dotenv/package.json | 80 ++++++ auth/node_modules/dotenv/types/index.d.ts | 59 ++++ auth/node_modules/dotenv/types/test.ts | 19 ++ auth/node_modules/dotenv/types/tsconfig.json | 15 + auth/node_modules/dotenv/types/tslint.json | 6 + auth/node_modules/object-assign/index.js | 90 ++++++ auth/node_modules/object-assign/license | 21 ++ auth/node_modules/object-assign/package.json | 74 +++++ auth/node_modules/object-assign/readme.md | 61 ++++ auth/package-lock.json | 24 ++ auth/package.json | 3 + auth/routes/users.js | 194 ++++++------- auth/schemas/User.js | 8 +- auth/server.js | 33 ++- public/manifest.json | 10 - src/components/AuthReducer.js | 17 -- src/components/ErrorNotice.js | 10 + src/components/NavBar.js | 40 ++- src/components/SignIn.js | 63 ++-- src/components/store.js | 17 -- src/context/UserContext.js | 3 + src/navbar.css | 5 +- 50 files changed, 2749 insertions(+), 188 deletions(-) create mode 100644 .env create mode 100644 auth/middleware/auth.js create mode 100644 auth/node_modules/context/LICENSE create mode 100644 auth/node_modules/context/README.md create mode 100644 auth/node_modules/context/dist/context.cjs.development.js create mode 100644 auth/node_modules/context/dist/context.cjs.development.js.map create mode 100644 auth/node_modules/context/dist/context.cjs.production.min.js create mode 100644 auth/node_modules/context/dist/context.cjs.production.min.js.map create mode 100644 auth/node_modules/context/dist/context.esm.js create mode 100644 auth/node_modules/context/dist/context.esm.js.map create mode 100644 auth/node_modules/context/dist/index.d.ts create mode 100644 auth/node_modules/context/dist/index.js create mode 100644 auth/node_modules/context/package.json create mode 100644 auth/node_modules/context/src/index.ts create mode 100644 auth/node_modules/cors/CONTRIBUTING.md create mode 100644 auth/node_modules/cors/HISTORY.md create mode 100644 auth/node_modules/cors/LICENSE create mode 100644 auth/node_modules/cors/README.md create mode 100644 auth/node_modules/cors/lib/index.js create mode 100644 auth/node_modules/cors/package.json create mode 100644 auth/node_modules/dotenv/CHANGELOG.md create mode 100644 auth/node_modules/dotenv/LICENSE create mode 100644 auth/node_modules/dotenv/README.md create mode 100644 auth/node_modules/dotenv/config.js create mode 100644 auth/node_modules/dotenv/lib/cli-options.js create mode 100644 auth/node_modules/dotenv/lib/env-options.js create mode 100644 auth/node_modules/dotenv/lib/main.js create mode 100644 auth/node_modules/dotenv/package.json create mode 100644 auth/node_modules/dotenv/types/index.d.ts create mode 100644 auth/node_modules/dotenv/types/test.ts create mode 100644 auth/node_modules/dotenv/types/tsconfig.json create mode 100644 auth/node_modules/dotenv/types/tslint.json create mode 100644 auth/node_modules/object-assign/index.js create mode 100644 auth/node_modules/object-assign/license create mode 100644 auth/node_modules/object-assign/package.json create mode 100644 auth/node_modules/object-assign/readme.md delete mode 100644 src/components/AuthReducer.js create mode 100644 src/components/ErrorNotice.js delete mode 100644 src/components/store.js create mode 100644 src/context/UserContext.js diff --git a/.env b/.env new file mode 100644 index 0000000..7dbacbf --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ + +MONGODB_CONNECTION_STRING = mongodb+srv://admin:ABxXFUBs5FMiAaDJ@form.iynew.mongodb.net/?retryWrites=true&w=majority \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4d29575..9576d54 100644 --- a/.gitignore +++ b/.gitignore @@ -3,8 +3,8 @@ # dependencies /node_modules /.pnp +/src/.env .pnp.js - # testing /coverage diff --git a/auth/middleware/auth.js b/auth/middleware/auth.js new file mode 100644 index 0000000..d22ae5b --- /dev/null +++ b/auth/middleware/auth.js @@ -0,0 +1,24 @@ +const jwt = require("jsonwebtoken"); + +const auth = (req, res, next) => { + try { + const token = req.header("x-auth-token"); + if (!token) + return res + .status(401) + .json({ msg: "No authentication token, authorization denied." }); + + const verified = jwt.verify(token, process.env.JWT_SECRET); + if (!verified) + return res + .status(401) + .json({ msg: "Token verification failed, authorization denied." }); + + req.user = verified.id; + next(); + } catch (err) { + res.status(500).json({ error: err.message }); + } +}; + +module.exports = auth; diff --git a/auth/node_modules/context/LICENSE b/auth/node_modules/context/LICENSE new file mode 100644 index 0000000..d802be8 --- /dev/null +++ b/auth/node_modules/context/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 ealush + +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. \ No newline at end of file diff --git a/auth/node_modules/context/README.md b/auth/node_modules/context/README.md new file mode 100644 index 0000000..784616a --- /dev/null +++ b/auth/node_modules/context/README.md @@ -0,0 +1,101 @@ +# Context + +Simple utility that creates a multi-layerd context singleton. +It allows you to keep reference for shared variables, and access them later down in your function call even if not declared in the same scope. + +It was built for [vest](https://github.com/ealush/vest) validations frameworks, but can be used in all sort of places. + +```js +// myContext.js +import createContext from 'context'; + +export default createContext(); +``` + +```js +// framework.js + +import context from './myContext.js'; + +function suite(id, tests) { + context.run({ suiteId: id }, () => tests()); + // ... +} + +function group(name, groupTests) { + const { suiteId } = context.use(); + + context.run( + { + group: name, + }, + () => groupTests() + ); +} + +function test(message, cb) { + const { suiteId, group } = context.use(); + + const testId = Math.random(); // 0.8418151199238901 + + const testData = context.run({ test: testId }, () => cb()); + + // ... +} + +export { suite, group, test } from './framework'; +``` + +```js +import testFramework from './framwork.js'; + +suite('some_id', () => { + /* + context now is: + { + suiteId: 'some_id' + } + */ + + group('some_group_name', () => { + /* + context now is: + { + group: 'some_group_name', + parentContext: { + suiteId: 'some_id', + } + } + */ + + test('blah blah', () => { + /* + context now is: + { + test: 0.8418151199238901, + parentContext: { + group: 'some_group_name', + parentContext: { + suiteId: 'some_id', + } + } + } + */ + }); + }); +}); +``` + +## Binding a function with context + +You can bind a function to a context with ctx.bind, this allows you to create a bound function that's when called - will be called with that bound context, even if not in the same scope anymore. + +```js +const boundFunction = ctx.bind(ctxRef, fn, ...args); + +boundFunction() // Will run with the context as if you run it directly within ctx.run(); +``` + +## Context initialization + +You can add an init function to your context creation. The init function will run every time you call context.run, to allow you to set in-flight keys to your context. It accepts two params - the provided ctxRef, and the parent context when nested. diff --git a/auth/node_modules/context/dist/context.cjs.development.js b/auth/node_modules/context/dist/context.cjs.development.js new file mode 100644 index 0000000..201b0b3 --- /dev/null +++ b/auth/node_modules/context/dist/context.cjs.development.js @@ -0,0 +1,180 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } +} + +function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; +} + +var getInnerName = function getInnerName(name) { + return "__" + name; +}; + +var Context = /*#__PURE__*/function () { + function Context(_ref, ctxRef) { + var _init; + + var use = _ref.use, + set = _ref.set, + addQueryableProperties = _ref.addQueryableProperties, + init = _ref.init; + this._parentContext = null; + var ctx = use(); + var usedRef = typeof init === 'function' ? (_init = init(ctxRef, ctx)) !== null && _init !== void 0 ? _init : ctxRef : ctxRef; + var queryableProperties = addQueryableProperties(usedRef); + + if (usedRef && typeof usedRef === 'object') { + for (var key in queryableProperties) { + if (Object.prototype.hasOwnProperty.call(usedRef, key)) { + this[getInnerName(key)] = usedRef[key]; + } + + this.addLookupProperty(key); + } + } + + if (ctx) { + this.setParentContext(ctx); + } + + set(this); + } + + Context.is = function is(value) { + return value instanceof Context; + }; + + var _proto = Context.prototype; + + _proto.addLookupProperty = function addLookupProperty(key) { + var innerName = getInnerName(key); + Object.defineProperty(this, key, { + get: function get() { + return this.lookup(innerName); + }, + set: function set(value) { + throw new Error("Context: Unable to set \"" + key + "\" to `" + JSON.stringify(value) + "`. Context properties cannot be set directly. Use context.run() instead."); + } + }); + } // @ts-ignore - we actually do use lookup + ; + + _proto.lookup = function lookup(key) { + var ctx = this; + + do { + if (ctx.hasOwnProperty(key)) { + return ctx[key]; + } + + if (Context.is(ctx.parentContext)) { + ctx = ctx.parentContext; + } else { + return; + } + } while (ctx); + }; + + _proto.setParentContext = function setParentContext(parentContext) { + if (Context.is(this)) { + this._parentContext = parentContext; + } + }; + + _createClass(Context, [{ + key: "parentContext", + get: function get() { + return this._parentContext; + } + }]); + + return Context; +}(); + +function createContext(init) { + var storage = { + ctx: undefined + }; + var queryableProperties = {}; + + function addQueryableProperties(ctxRef) { + if (!ctxRef || typeof ctxRef !== 'object') { + return {}; + } + + for (var key in ctxRef) { + if (Object.prototype.hasOwnProperty.call(ctxRef, key)) { + queryableProperties[key] = true; + } + } + + return queryableProperties; + } + + function use() { + return storage.ctx; + } + + function set(value) { + return storage.ctx = value; + } + + function clear() { + var ctx = use(); + + if (!Context.is(ctx)) { + return; + } + + set(ctx.parentContext); + } + + function run(ctxRef, fn) { + var ctx = new Context({ + set: set, + use: use, + addQueryableProperties: addQueryableProperties, + init: init + }, ctxRef); + var res = fn(ctx); + clear(); + return res; + } + + function bind(ctxRef, fn) { + for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + args[_key - 2] = arguments[_key]; + } + + return function () { + for (var _len2 = arguments.length, runTimeArgs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + runTimeArgs[_key2] = arguments[_key2]; + } + + return run(ctxRef, function () { + return fn.apply(void 0, args.concat(runTimeArgs)); + }); + }; + } + + return { + use: use, + run: run, + bind: bind + }; +} + +exports.default = createContext; +//# sourceMappingURL=context.cjs.development.js.map diff --git a/auth/node_modules/context/dist/context.cjs.development.js.map b/auth/node_modules/context/dist/context.cjs.development.js.map new file mode 100644 index 0000000..e0adc5d --- /dev/null +++ b/auth/node_modules/context/dist/context.cjs.development.js.map @@ -0,0 +1 @@ +{"version":3,"file":"context.cjs.development.js","sources":["../src/index.ts"],"sourcesContent":["type TypeCTXRef = { [key: string]: any };\n\nexport interface ICTXFN {\n (context: Context): any;\n}\ninterface Init {\n (ctxRef?: TypeCTXRef, parentContext?: Context | void): TypeCTXRef | null;\n}\n\ntype ContextOptions = {\n use: () => Context | void;\n set: (value: any) => any;\n addQueryableProperties: (ctxRef: TypeCTXRef) => TQueryableProperties;\n init?: Init;\n};\n\ntype TQueryableProperties = { [key: string]: true };\n\nexport type TCTX = {\n use: () => Context | void;\n run: (ctxRef: TypeCTXRef, fn: ICTXFN) => any;\n bind: (\n ctxRef: TypeCTXRef,\n fn: (...args: any[]) => any,\n ...args: any[]\n ) => (...runTimeArgs: any[]) => any;\n};\n\nconst getInnerName = (name: string): string => `__${name}`;\n\nclass Context {\n private _parentContext: Context | null = null;\n [key: string]: any;\n\n static is(value: any): value is Context {\n return value instanceof Context;\n }\n\n constructor(\n { use, set, addQueryableProperties, init }: ContextOptions,\n ctxRef: TypeCTXRef\n ) {\n const ctx = use();\n\n const usedRef =\n typeof init === 'function' ? init(ctxRef, ctx) ?? ctxRef : ctxRef;\n\n const queryableProperties = addQueryableProperties(usedRef);\n\n if (usedRef && typeof usedRef === 'object') {\n for (const key in queryableProperties) {\n if (Object.prototype.hasOwnProperty.call(usedRef, key)) {\n this[getInnerName(key)] = usedRef[key];\n }\n this.addLookupProperty(key);\n }\n }\n\n if (ctx) {\n this.setParentContext(ctx);\n }\n\n set(this);\n }\n\n addLookupProperty(key: string) {\n const innerName = getInnerName(key);\n\n Object.defineProperty(this, key, {\n get() {\n return this.lookup(innerName);\n },\n set(value) {\n throw new Error(\n `Context: Unable to set \"${key}\" to \\`${JSON.stringify(\n value\n )}\\`. Context properties cannot be set directly. Use context.run() instead.`\n );\n },\n });\n }\n\n // @ts-ignore - we actually do use lookup\n private lookup(key: string) {\n let ctx: Context = this;\n do {\n if (ctx.hasOwnProperty(key)) {\n return ctx[key];\n }\n if (Context.is(ctx.parentContext)) {\n ctx = ctx.parentContext;\n } else {\n return;\n }\n } while (ctx);\n }\n\n private setParentContext(parentContext: Context) {\n if (Context.is(this)) {\n this._parentContext = parentContext;\n }\n }\n\n get parentContext(): Context | null {\n return this._parentContext;\n }\n}\n\nfunction createContext(init?: Init) {\n const storage = {\n ctx: undefined,\n };\n\n const queryableProperties: TQueryableProperties = {};\n\n function addQueryableProperties(ctxRef: TypeCTXRef): TQueryableProperties {\n if (!ctxRef || typeof ctxRef !== 'object') {\n return {};\n }\n\n for (const key in ctxRef) {\n if (Object.prototype.hasOwnProperty.call(ctxRef, key)) {\n queryableProperties[key] = true;\n }\n }\n\n return queryableProperties;\n }\n\n function use(): Context | void {\n return storage.ctx;\n }\n function set(value: any) {\n return (storage.ctx = value);\n }\n function clear() {\n const ctx = use();\n\n if (!Context.is(ctx)) {\n return;\n }\n\n set(ctx.parentContext);\n }\n function run(ctxRef: TypeCTXRef, fn: ICTXFN) {\n const ctx = new Context({ set, use, addQueryableProperties, init }, ctxRef);\n\n const res = fn(ctx);\n\n clear();\n return res;\n }\n\n function bind(\n ctxRef: TypeCTXRef,\n fn: (...args: any[]) => any,\n ...args: any[]\n ) {\n return function(...runTimeArgs: any[]) {\n return run(ctxRef, function() {\n return fn(...args, ...runTimeArgs);\n });\n };\n }\n\n return {\n use,\n run,\n bind,\n };\n}\n\nexport default createContext;\n"],"names":["getInnerName","name","Context","ctxRef","use","set","addQueryableProperties","init","ctx","usedRef","queryableProperties","key","Object","prototype","hasOwnProperty","call","addLookupProperty","setParentContext","is","value","innerName","defineProperty","get","lookup","Error","JSON","stringify","parentContext","_parentContext","createContext","storage","undefined","clear","run","fn","res","bind","args","runTimeArgs"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4BA,IAAMA,YAAY,GAAG,SAAfA,YAAe,CAACC,IAAD;AAAA,gBAA+BA,IAA/B;AAAA,CAArB;;IAEMC;AAQJ,yBAEEC,MAFF;;;QACIC,WAAAA;QAAKC,WAAAA;QAAKC,8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O,CAACgB,EAAR,CAAWV,GAAX,CAAL,EAAsB;AACpB;AACD;;AAEDH,IAAAA,GAAG,CAACG,GAAG,CAACmB,aAAL,CAAH;AACD;;AACD,WAASM,GAAT,CAAa9B,MAAb,EAAiC+B,EAAjC;AACE,QAAM1B,GAAG,GAAG,IAAIN,OAAJ,CAAY;AAAEG,MAAAA,GAAG,EAAHA,GAAF;AAAOD,MAAAA,GAAG,EAAHA,GAAP;AAAYE,MAAAA,sBAAsB,EAAtBA,sBAAZ;AAAoCC,MAAAA,IAAI,EAAJA;AAApC,KAAZ,EAAwDJ,MAAxD,CAAZ;AAEA,QAAMgC,GAAG,GAAGD,EAAE,CAAC1B,GAAD,CAAd;AAEAwB,IAAAA,KAAK;AACL,WAAOG,GAAP;AACD;;AAED,WAASC,IAAT,CACEjC,MADF,EAEE+B,EAFF;sCAGKG;AAAAA,MAAAA;;;AAEH,WAAO;yCAAYC;AAAAA,QAAAA;;;AACjB,aAAOL,GAAG,CAAC9B,MAAD,EAAS;AACjB,eAAO+B,EAAE,MAAF,SAAMG,IAAN,QAAeC,WAAf,EAAP;AACD,OAFS,CAAV;AAGD,KAJD;AAKD;;AAED,SAAO;AACLlC,IAAAA,GAAG,EAAHA,GADK;AAEL6B,IAAAA,GAAG,EAAHA,GAFK;AAGLG,IAAAA,IAAI,EAAJA;AAHK,GAAP;AAKD;;;;"} \ No newline at end of file diff --git a/auth/node_modules/context/dist/context.cjs.production.min.js b/auth/node_modules/context/dist/context.cjs.production.min.js new file mode 100644 index 0000000..d1204e7 --- /dev/null +++ b/auth/node_modules/context/dist/context.cjs.production.min.js @@ -0,0 +1,2 @@ +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(t){return"__"+t},e=function(){function e(e,n){var r,o=e.use,i=e.set,u=e.addQueryableProperties,a=e.init;this._parentContext=null;var c=o(),s="function"==typeof a&&null!==(r=a(n,c))&&void 0!==r?r:n,f=u(s);if(s&&"object"==typeof s)for(var p in f)Object.prototype.hasOwnProperty.call(s,p)&&(this[t(p)]=s[p]),this.addLookupProperty(p);c&&this.setParentContext(c),i(this)}e.is=function(t){return t instanceof e};var n,r=e.prototype;return r.addLookupProperty=function(e){var n=t(e);Object.defineProperty(this,e,{get:function(){return this.lookup(n)},set:function(t){throw new Error('Context: Unable to set "'+e+'" to `'+JSON.stringify(t)+"`. Context properties cannot be set directly. Use context.run() instead.")}})},r.lookup=function(t){var n=this;do{if(n.hasOwnProperty(t))return n[t];if(!e.is(n.parentContext))return;n=n.parentContext}while(n)},r.setParentContext=function(t){e.is(this)&&(this._parentContext=t)},(n=[{key:"parentContext",get:function(){return this._parentContext}}])&&function(t,e){for(var n=0;n2?n-2:0),o=2;o Context | void;\n set: (value: any) => any;\n addQueryableProperties: (ctxRef: TypeCTXRef) => TQueryableProperties;\n init?: Init;\n};\n\ntype TQueryableProperties = { [key: string]: true };\n\nexport type TCTX = {\n use: () => Context | void;\n run: (ctxRef: TypeCTXRef, fn: ICTXFN) => any;\n bind: (\n ctxRef: TypeCTXRef,\n fn: (...args: any[]) => any,\n ...args: any[]\n ) => (...runTimeArgs: any[]) => any;\n};\n\nconst getInnerName = (name: string): string => `__${name}`;\n\nclass Context {\n private _parentContext: Context | null = null;\n [key: string]: any;\n\n static is(value: any): value is Context {\n return value instanceof Context;\n }\n\n constructor(\n { use, set, addQueryableProperties, init }: ContextOptions,\n ctxRef: TypeCTXRef\n ) {\n const ctx = use();\n\n const usedRef =\n typeof init === 'function' ? init(ctxRef, ctx) ?? ctxRef : ctxRef;\n\n const queryableProperties = addQueryableProperties(usedRef);\n\n if (usedRef && typeof usedRef === 'object') {\n for (const key in queryableProperties) {\n if (Object.prototype.hasOwnProperty.call(usedRef, key)) {\n this[getInnerName(key)] = usedRef[key];\n }\n this.addLookupProperty(key);\n }\n }\n\n if (ctx) {\n this.setParentContext(ctx);\n }\n\n set(this);\n }\n\n addLookupProperty(key: string) {\n const innerName = getInnerName(key);\n\n Object.defineProperty(this, key, {\n get() {\n return this.lookup(innerName);\n },\n set(value) {\n throw new Error(\n `Context: Unable to set \"${key}\" to \\`${JSON.stringify(\n value\n )}\\`. Context properties cannot be set directly. Use context.run() instead.`\n );\n },\n });\n }\n\n // @ts-ignore - we actually do use lookup\n private lookup(key: string) {\n let ctx: Context = this;\n do {\n if (ctx.hasOwnProperty(key)) {\n return ctx[key];\n }\n if (Context.is(ctx.parentContext)) {\n ctx = ctx.parentContext;\n } else {\n return;\n }\n } while (ctx);\n }\n\n private setParentContext(parentContext: Context) {\n if (Context.is(this)) {\n this._parentContext = parentContext;\n }\n }\n\n get parentContext(): Context | null {\n return this._parentContext;\n }\n}\n\nfunction createContext(init?: Init) {\n const storage = {\n ctx: undefined,\n };\n\n const queryableProperties: TQueryableProperties = {};\n\n function addQueryableProperties(ctxRef: TypeCTXRef): TQueryableProperties {\n if (!ctxRef || typeof ctxRef !== 'object') {\n return {};\n }\n\n for (const key in ctxRef) {\n if (Object.prototype.hasOwnProperty.call(ctxRef, key)) {\n queryableProperties[key] = true;\n }\n }\n\n return queryableProperties;\n }\n\n function use(): Context | void {\n return storage.ctx;\n }\n function set(value: any) {\n return (storage.ctx = value);\n }\n function clear() {\n const ctx = use();\n\n if (!Context.is(ctx)) {\n return;\n }\n\n set(ctx.parentContext);\n }\n function run(ctxRef: TypeCTXRef, fn: ICTXFN) {\n const ctx = new Context({ set, use, addQueryableProperties, init }, ctxRef);\n\n const res = fn(ctx);\n\n clear();\n return res;\n }\n\n function bind(\n ctxRef: TypeCTXRef,\n fn: (...args: any[]) => any,\n ...args: any[]\n ) {\n return function(...runTimeArgs: any[]) {\n return run(ctxRef, function() {\n return fn(...args, ...runTimeArgs);\n });\n };\n }\n\n return {\n use,\n run,\n bind,\n };\n}\n\nexport default createContext;\n"],"names":["getInnerName","name","Context","ctxRef","use","set","addQueryableProperties","init","ctx","usedRef","queryableProperties","key","Object","prototype","hasOwnProperty","call","addLookupProperty","setParentContext","this","is","value","innerName","defineProperty","get","lookup","Error","JSON","stringify","parentCont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E,uBAAAA,EAAwBC,KAAAA,GAAQJ,WAT9DK,EAAMJ,IAEPF,EAAQiB,GAAGX,IAIhBH,EAAIG,EAAIoB,eAQDM,QAeF,CACL9B,IAAAA,EACA4B,IAAAA,EACAG,cAdAhC,EACA8B,8BACGG,mCAAAA,2BAEI,sCAAYC,2BAAAA,yBACVL,EAAI7B,GAAQ,kBACV8B,eAAMG,SAASC"} \ No newline at end of file diff --git a/auth/node_modules/context/dist/context.esm.js b/auth/node_modules/context/dist/context.esm.js new file mode 100644 index 0000000..3566121 --- /dev/null +++ b/auth/node_modules/context/dist/context.esm.js @@ -0,0 +1,176 @@ +function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } +} + +function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; +} + +var getInnerName = function getInnerName(name) { + return "__" + name; +}; + +var Context = /*#__PURE__*/function () { + function Context(_ref, ctxRef) { + var _init; + + var use = _ref.use, + set = _ref.set, + addQueryableProperties = _ref.addQueryableProperties, + init = _ref.init; + this._parentContext = null; + var ctx = use(); + var usedRef = typeof init === 'function' ? (_init = init(ctxRef, ctx)) !== null && _init !== void 0 ? _init : ctxRef : ctxRef; + var queryableProperties = addQueryableProperties(usedRef); + + if (usedRef && typeof usedRef === 'object') { + for (var key in queryableProperties) { + if (Object.prototype.hasOwnProperty.call(usedRef, key)) { + this[getInnerName(key)] = usedRef[key]; + } + + this.addLookupProperty(key); + } + } + + if (ctx) { + this.setParentContext(ctx); + } + + set(this); + } + + Context.is = function is(value) { + return value instanceof Context; + }; + + var _proto = Context.prototype; + + _proto.addLookupProperty = function addLookupProperty(key) { + var innerName = getInnerName(key); + Object.defineProperty(this, key, { + get: function get() { + return this.lookup(innerName); + }, + set: function set(value) { + throw new Error("Context: Unable to set \"" + key + "\" to `" + JSON.stringify(value) + "`. Context properties cannot be set directly. Use context.run() instead."); + } + }); + } // @ts-ignore - we actually do use lookup + ; + + _proto.lookup = function lookup(key) { + var ctx = this; + + do { + if (ctx.hasOwnProperty(key)) { + return ctx[key]; + } + + if (Context.is(ctx.parentContext)) { + ctx = ctx.parentContext; + } else { + return; + } + } while (ctx); + }; + + _proto.setParentContext = function setParentContext(parentContext) { + if (Context.is(this)) { + this._parentContext = parentContext; + } + }; + + _createClass(Context, [{ + key: "parentContext", + get: function get() { + return this._parentContext; + } + }]); + + return Context; +}(); + +function createContext(init) { + var storage = { + ctx: undefined + }; + var queryableProperties = {}; + + function addQueryableProperties(ctxRef) { + if (!ctxRef || typeof ctxRef !== 'object') { + return {}; + } + + for (var key in ctxRef) { + if (Object.prototype.hasOwnProperty.call(ctxRef, key)) { + queryableProperties[key] = true; + } + } + + return queryableProperties; + } + + function use() { + return storage.ctx; + } + + function set(value) { + return storage.ctx = value; + } + + function clear() { + var ctx = use(); + + if (!Context.is(ctx)) { + return; + } + + set(ctx.parentContext); + } + + function run(ctxRef, fn) { + var ctx = new Context({ + set: set, + use: use, + addQueryableProperties: addQueryableProperties, + init: init + }, ctxRef); + var res = fn(ctx); + clear(); + return res; + } + + function bind(ctxRef, fn) { + for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + args[_key - 2] = arguments[_key]; + } + + return function () { + for (var _len2 = arguments.length, runTimeArgs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + runTimeArgs[_key2] = arguments[_key2]; + } + + return run(ctxRef, function () { + return fn.apply(void 0, args.concat(runTimeArgs)); + }); + }; + } + + return { + use: use, + run: run, + bind: bind + }; +} + +export default createContext; +//# sourceMappingURL=context.esm.js.map diff --git a/auth/node_modules/context/dist/context.esm.js.map b/auth/node_modules/context/dist/context.esm.js.map new file mode 100644 index 0000000..294719e --- /dev/null +++ b/auth/node_modules/context/dist/context.esm.js.map @@ -0,0 +1 @@ +{"version":3,"file":"context.esm.js","sources":["../src/index.ts"],"sourcesContent":["type TypeCTXRef = { [key: string]: any };\n\nexport interface ICTXFN {\n (context: Context): any;\n}\ninterface Init {\n (ctxRef?: TypeCTXRef, parentContext?: Context | void): TypeCTXRef | null;\n}\n\ntype ContextOptions = {\n use: () => Context | void;\n set: (value: any) => any;\n addQueryableProperties: (ctxRef: TypeCTXRef) => TQueryableProperties;\n init?: Init;\n};\n\ntype TQueryableProperties = { [key: string]: true };\n\nexport type TCTX = {\n use: () => Context | void;\n run: (ctxRef: TypeCTXRef, fn: ICTXFN) => any;\n bind: (\n ctxRef: TypeCTXRef,\n fn: (...args: any[]) => any,\n ...args: any[]\n ) => (...runTimeArgs: any[]) => any;\n};\n\nconst getInnerName = (name: string): string => `__${name}`;\n\nclass Context {\n private _parentContext: Context | null = null;\n [key: string]: any;\n\n static is(value: any): value is Context {\n return value instanceof Context;\n }\n\n constructor(\n { use, set, addQueryableProperties, init }: ContextOptions,\n ctxRef: TypeCTXRef\n ) {\n const ctx = use();\n\n const usedRef =\n typeof init === 'function' ? init(ctxRef, ctx) ?? ctxRef : ctxRef;\n\n const queryableProperties = addQueryableProperties(usedRef);\n\n if (usedRef && typeof usedRef === 'object') {\n for (const key in queryableProperties) {\n if (Object.prototype.hasOwnProperty.call(usedRef, key)) {\n this[getInnerName(key)] = usedRef[key];\n }\n this.addLookupProperty(key);\n }\n }\n\n if (ctx) {\n this.setParentContext(ctx);\n }\n\n set(this);\n }\n\n addLookupProperty(key: string) {\n const innerName = getInnerName(key);\n\n Object.defineProperty(this, key, {\n get() {\n return this.lookup(innerName);\n },\n set(value) {\n throw new Error(\n `Context: Unable to set \"${key}\" to \\`${JSON.stringify(\n value\n )}\\`. Context properties cannot be set directly. Use context.run() instead.`\n );\n },\n });\n }\n\n // @ts-ignore - we actually do use lookup\n private lookup(key: string) {\n let ctx: Context = this;\n do {\n if (ctx.hasOwnProperty(key)) {\n return ctx[key];\n }\n if (Context.is(ctx.parentContext)) {\n ctx = ctx.parentContext;\n } else {\n return;\n }\n } while (ctx);\n }\n\n private setParentContext(parentContext: Context) {\n if (Context.is(this)) {\n this._parentContext = parentContext;\n }\n }\n\n get parentContext(): Context | null {\n return this._parentContext;\n }\n}\n\nfunction createContext(init?: Init) {\n const storage = {\n ctx: undefined,\n };\n\n const queryableProperties: TQueryableProperties = {};\n\n function addQueryableProperties(ctxRef: TypeCTXRef): TQueryableProperties {\n if (!ctxRef || typeof ctxRef !== 'object') {\n return {};\n }\n\n for (const key in ctxRef) {\n if (Object.prototype.hasOwnProperty.call(ctxRef, key)) {\n queryableProperties[key] = true;\n }\n }\n\n return queryableProperties;\n }\n\n function use(): Context | void {\n return storage.ctx;\n }\n function set(value: any) {\n return (storage.ctx = value);\n }\n function clear() {\n const ctx = use();\n\n if (!Context.is(ctx)) {\n return;\n }\n\n set(ctx.parentContext);\n }\n function run(ctxRef: TypeCTXRef, fn: ICTXFN) {\n const ctx = new Context({ set, use, addQueryableProperties, init }, ctxRef);\n\n const res = fn(ctx);\n\n clear();\n return res;\n }\n\n function bind(\n ctxRef: TypeCTXRef,\n fn: (...args: any[]) => any,\n ...args: any[]\n ) {\n return function(...runTimeArgs: any[]) {\n return run(ctxRef, function() {\n return fn(...args, ...runTimeArgs);\n });\n };\n }\n\n return {\n use,\n run,\n bind,\n };\n}\n\nexport default createContext;\n"],"names":["getInnerName","name","Context","ctxRef","use","set","addQueryableProperties","init","ctx","usedRef","queryableProperties","key","Object","prototype","hasOwnProperty","call","addLookupProperty","setParentContext","is","value","innerName","defineProperty","get","lookup","Error","JSON","stringify","parentContext","_parentContext","createContext","storage","undefined","clear","run","fn","res","bind","args","runTimeArgs"],"mappings":";;;;;;;;;;;;;;;;AA4BA,IAAMA,YAAY,GAAG,SAAfA,YAAe,CAACC,IAAD;AAAA,gBAA+BA,IAA/B;AAAA,CAArB;;IAEMC;AAQJ,yBAEEC,MAFF;;;Q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GAAG,EAAf;;AAEA,QAAI,CAACF,OAAO,CAACgB,EAAR,CAAWV,GAAX,CAAL,EAAsB;AACpB;AACD;;AAEDH,IAAAA,GAAG,CAACG,GAAG,CAACmB,aAAL,CAAH;AACD;;AACD,WAASM,GAAT,CAAa9B,MAAb,EAAiC+B,EAAjC;AACE,QAAM1B,GAAG,GAAG,IAAIN,OAAJ,CAAY;AAAEG,MAAAA,GAAG,EAAHA,GAAF;AAAOD,MAAAA,GAAG,EAAHA,GAAP;AAAYE,MAAAA,sBAAsB,EAAtBA,sBAAZ;AAAoCC,MAAAA,IAAI,EAAJA;AAApC,KAAZ,EAAwDJ,MAAxD,CAAZ;AAEA,QAAMgC,GAAG,GAAGD,EAAE,CAAC1B,GAAD,CAAd;AAEAwB,IAAAA,KAAK;AACL,WAAOG,GAAP;AACD;;AAED,WAASC,IAAT,CACEjC,MADF,EAEE+B,EAFF;sCAGKG;AAAAA,MAAAA;;;AAEH,WAAO;yCAAYC;AAAAA,QAAAA;;;AACjB,aAAOL,GAAG,CAAC9B,MAAD,EAAS;AACjB,eAAO+B,EAAE,MAAF,SAAMG,IAAN,QAAeC,WAAf,EAAP;AACD,OAFS,CAAV;AAGD,KAJD;AAKD;;AAED,SAAO;AACLlC,IAAAA,GAAG,EAAHA,GADK;AAEL6B,IAAAA,GAAG,EAAHA,GAFK;AAGLG,IAAAA,IAAI,EAAJA;AAHK,GAAP;AAKD;;;;"} \ No newline at end of file diff --git a/auth/node_modules/context/dist/index.d.ts b/auth/node_modules/context/dist/index.d.ts new file mode 100644 index 0000000..2b824ed --- /dev/null +++ b/auth/node_modules/context/dist/index.d.ts @@ -0,0 +1,39 @@ +declare type TypeCTXRef = { + [key: string]: any; +}; +export interface ICTXFN { + (context: Context): any; +} +interface Init { + (ctxRef?: TypeCTXRef, parentContext?: Context | void): TypeCTXRef | null; +} +declare type ContextOptions = { + use: () => Context | void; + set: (value: any) => any; + addQueryableProperties: (ctxRef: TypeCTXRef) => TQueryableProperties; + init?: Init; +}; +declare type TQueryableProperties = { + [key: string]: true; +}; +export declare type TCTX = { + use: () => Context | void; + run: (ctxRef: TypeCTXRef, fn: ICTXFN) => any; + bind: (ctxRef: TypeCTXRef, fn: (...args: any[]) => any, ...args: any[]) => (...runTimeArgs: any[]) => any; +}; +declare class Context { + private _parentContext; + [key: string]: any; + static is(value: any): value is Context; + constructor({ use, set, addQueryableProperties, init }: ContextOptions, ctxRef: TypeCTXRef); + addLookupProperty(key: string): void; + private lookup; + private setParentContext; + get parentContext(): Context | null; +} +declare function createContext(init?: Init): { + use: () => Context | void; + run: (ctxRef: TypeCTXRef, fn: ICTXFN) => any; + bind: (ctxRef: TypeCTXRef, fn: (...args: any[]) => any, ...args: any[]) => (...runTimeArgs: any[]) => any; +}; +export default createContext; diff --git a/auth/node_modules/context/dist/index.js b/auth/node_modules/context/dist/index.js new file mode 100644 index 0000000..b40e7a0 --- /dev/null +++ b/auth/node_modules/context/dist/index.js @@ -0,0 +1,8 @@ + +'use strict' + +if (process.env.NODE_ENV === 'production') { + module.exports = require('./context.cjs.production.min.js') +} else { + module.exports = require('./context.cjs.development.js') +} diff --git a/auth/node_modules/context/package.json b/auth/node_modules/context/package.json new file mode 100644 index 0000000..10842bd --- /dev/null +++ b/auth/node_modules/context/package.json @@ -0,0 +1,78 @@ +{ + "_from": "context", + "_id": "context@1.1.0", + "_inBundle": false, + "_integrity": "sha512-nfNLy6MbBleZuK0vDwxUnYyu1McpjaZIHo7a3+yNoLWEJtnUjnB4z5xYZhg3XmVcCflh5U2FeaHbHUfCCLSeHA==", + "_location": "/context", + "_phantomChildren": {}, + "_requested": { + "type": "tag", + "registry": true, + "raw": "context", + "name": "context", + "escapedName": "context", + "rawSpec": "", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "#USER", + "/" + ], + "_resolved": "https://registry.npmjs.org/context/-/context-1.1.0.tgz", + "_shasum": "1675cfe546b4d8f9925a2c4896a7ee41e917f015", + "_spec": "context", + "_where": "C:\\Priyathamwork\\locaft\\locaft\\auth", + "author": { + "name": "ealush" + }, + "bugs": { + "url": "https://github.com/ealush/context/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "Simple utility that creates a multi-layerd context singleton. It allows you to keep reference for shared variables, and access them later down in your function call even if not declared in the same scope.", + "devDependencies": { + "husky": "^4.2.5", + "tsdx": "^0.13.2", + "tslib": "^2.0.1", + "typescript": "^4.0.2" + }, + "engines": { + "node": ">=10" + }, + "files": [ + "dist", + "src" + ], + "homepage": "https://github.com/ealush/context#readme", + "husky": { + "hooks": { + "pre-commit": "tsdx lint" + } + }, + "license": "MIT", + "main": "dist/index.js", + "module": "dist/context.esm.js", + "name": "context", + "peerDependencies": {}, + "prettier": { + "printWidth": 80, + "semi": true, + "singleQuote": true, + "trailingComma": "es5" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/ealush/context.git" + }, + "scripts": { + "build": "tsdx build", + "lint": "tsdx lint", + "prepare": "tsdx build", + "start": "tsdx watch", + "test": "tsdx test" + }, + "typings": "dist/index.d.ts", + "version": "1.1.0" +} diff --git a/auth/node_modules/context/src/index.ts b/auth/node_modules/context/src/index.ts new file mode 100644 index 0000000..8ab48eb --- /dev/null +++ b/auth/node_modules/context/src/index.ts @@ -0,0 +1,173 @@ +type TypeCTXRef = { [key: string]: any }; + +export interface ICTXFN { + (context: Context): any; +} +interface Init { + (ctxRef?: TypeCTXRef, parentContext?: Context | void): TypeCTXRef | null; +} + +type ContextOptions = { + use: () => Context | void; + set: (value: any) => any; + addQueryableProperties: (ctxRef: TypeCTXRef) => TQueryableProperties; + init?: Init; +}; + +type TQueryableProperties = { [key: string]: true }; + +export type TCTX = { + use: () => Context | void; + run: (ctxRef: TypeCTXRef, fn: ICTXFN) => any; + bind: ( + ctxRef: TypeCTXRef, + fn: (...args: any[]) => any, + ...args: any[] + ) => (...runTimeArgs: any[]) => any; +}; + +const getInnerName = (name: string): string => `__${name}`; + +class Context { + private _parentContext: Context | null = null; + [key: string]: any; + + static is(value: any): value is Context { + return value instanceof Context; + } + + constructor( + { use, set, addQueryableProperties, init }: ContextOptions, + ctxRef: TypeCTXRef + ) { + const ctx = use(); + + const usedRef = + typeof init === 'function' ? init(ctxRef, ctx) ?? ctxRef : ctxRef; + + const queryableProperties = addQueryableProperties(usedRef); + + if (usedRef && typeof usedRef === 'object') { + for (const key in queryableProperties) { + if (Object.prototype.hasOwnProperty.call(usedRef, key)) { + this[getInnerName(key)] = usedRef[key]; + } + this.addLookupProperty(key); + } + } + + if (ctx) { + this.setParentContext(ctx); + } + + set(this); + } + + addLookupProperty(key: string) { + const innerName = getInnerName(key); + + Object.defineProperty(this, key, { + get() { + return this.lookup(innerName); + }, + set(value) { + throw new Error( + `Context: Unable to set "${key}" to \`${JSON.stringify( + value + )}\`. Context properties cannot be set directly. Use context.run() instead.` + ); + }, + }); + } + + // @ts-ignore - we actually do use lookup + private lookup(key: string) { + let ctx: Context = this; + do { + if (ctx.hasOwnProperty(key)) { + return ctx[key]; + } + if (Context.is(ctx.parentContext)) { + ctx = ctx.parentContext; + } else { + return; + } + } while (ctx); + } + + private setParentContext(parentContext: Context) { + if (Context.is(this)) { + this._parentContext = parentContext; + } + } + + get parentContext(): Context | null { + return this._parentContext; + } +} + +function createContext(init?: Init) { + const storage = { + ctx: undefined, + }; + + const queryableProperties: TQueryableProperties = {}; + + function addQueryableProperties(ctxRef: TypeCTXRef): TQueryableProperties { + if (!ctxRef || typeof ctxRef !== 'object') { + return {}; + } + + for (const key in ctxRef) { + if (Object.prototype.hasOwnProperty.call(ctxRef, key)) { + queryableProperties[key] = true; + } + } + + return queryableProperties; + } + + function use(): Context | void { + return storage.ctx; + } + function set(value: any) { + return (storage.ctx = value); + } + function clear() { + const ctx = use(); + + if (!Context.is(ctx)) { + return; + } + + set(ctx.parentContext); + } + function run(ctxRef: TypeCTXRef, fn: ICTXFN) { + const ctx = new Context({ set, use, addQueryableProperties, init }, ctxRef); + + const res = fn(ctx); + + clear(); + return res; + } + + function bind( + ctxRef: TypeCTXRef, + fn: (...args: any[]) => any, + ...args: any[] + ) { + return function(...runTimeArgs: any[]) { + return run(ctxRef, function() { + return fn(...args, ...runTimeArgs); + }); + }; + } + + return { + use, + run, + bind, + }; +} + +export default createContext; diff --git a/auth/node_modules/cors/CONTRIBUTING.md b/auth/node_modules/cors/CONTRIBUTING.md new file mode 100644 index 0000000..591b09a --- /dev/null +++ b/auth/node_modules/cors/CONTRIBUTING.md @@ -0,0 +1,33 @@ +# contributing to `cors` + +CORS is a node.js package for providing a [connect](http://www.senchalabs.org/connect/)/[express](http://expressjs.com/) middleware that can be used to enable [CORS](http://en.wikipedia.org/wiki/Cross-origin_resource_sharing) with various options. Learn more about the project in [the README](README.md). + +## The CORS Spec + +[http://www.w3.org/TR/cors/](http://www.w3.org/TR/cors/) + +## Pull Requests Welcome + +* Include `'use strict';` in every javascript file. +* 2 space indentation. +* Please run the testing steps below before submitting. + +## Testing + +```bash +$ npm install +$ npm test +``` + +## Interactive Testing Harness + +[http://node-cors-client.herokuapp.com](http://node-cors-client.herokuapp.com) + +Related git repositories: + +* [https://github.com/TroyGoode/node-cors-server](https://github.com/TroyGoode/node-cors-server) +* [https://github.com/TroyGoode/node-cors-client](https://github.com/TroyGoode/node-cors-client) + +## License + +[MIT License](http://www.opensource.org/licenses/mit-license.php) diff --git a/auth/node_modules/cors/HISTORY.md b/auth/node_modules/cors/HISTORY.md new file mode 100644 index 0000000..5762bce --- /dev/null +++ b/auth/node_modules/cors/HISTORY.md @@ -0,0 +1,58 @@ +2.8.5 / 2018-11-04 +================== + + * Fix setting `maxAge` option to `0` + +2.8.4 / 2017-07-12 +================== + + * Work-around Safari bug in default pre-flight response + +2.8.3 / 2017-03-29 +================== + + * Fix error when options delegate missing `methods` option + +2.8.2 / 2017-03-28 +================== + + * Fix error when frozen options are passed + * Send "Vary: Origin" when using regular expressions + * Send "Vary: Access-Control-Request-Headers" when dynamic `allowedHeaders` + +2.8.1 / 2016-09-08 +================== + +This release only changed documentation. + +2.8.0 / 2016-08-23 +================== + + * Add `optionsSuccessStatus` option + +2.7.2 / 2016-08-23 +================== + + * Fix error when Node.js running in strict mode + +2.7.1 / 2015-05-28 +================== + + * Move module into expressjs organization + +2.7.0 / 2015-05-28 +================== + + * Allow array of matching condition as `origin` option + * Allow regular expression as `origin` option + +2.6.1 / 2015-05-28 +================== + + * Update `license` in package.json + +2.6.0 / 2015-04-27 +================== + + * Add `preflightContinue` option + * Fix "Vary: Origin" header added for "*" diff --git a/auth/node_modules/cors/LICENSE b/auth/node_modules/cors/LICENSE new file mode 100644 index 0000000..fd10c84 --- /dev/null +++ b/auth/node_modules/cors/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2013 Troy Goode + +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/auth/node_modules/cors/README.md b/auth/node_modules/cors/README.md new file mode 100644 index 0000000..732b847 --- /dev/null +++ b/auth/node_modules/cors/README.md @@ -0,0 +1,243 @@ +# cors + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +CORS is a node.js package for providing a [Connect](http://www.senchalabs.org/connect/)/[Express](http://expressjs.com/) middleware that can be used to enable [CORS](http://en.wikipedia.org/wiki/Cross-origin_resource_sharing) with various options. + +**[Follow me (@troygoode) on Twitter!](https://twitter.com/intent/user?screen_name=troygoode)** + +* [Installation](#installation) +* [Usage](#usage) + * [Simple Usage](#simple-usage-enable-all-cors-requests) + * [Enable CORS for a Single Route](#enable-cors-for-a-single-route) + * [Configuring CORS](#configuring-cors) + * [Configuring CORS Asynchronously](#configuring-cors-asynchronously) + * [Enabling CORS Pre-Flight](#enabling-cors-pre-flight) +* [Configuration Options](#configuration-options) +* [Demo](#demo) +* [License](#license) +* [Author](#author) + +## Installation + +This is a [Node.js](https://nodejs.org/en/) module available through the +[npm registry](https://www.npmjs.com/). Installation is done using the +[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally): + +```sh +$ npm install cors +``` + +## Usage + +### Simple Usage (Enable *All* CORS Requests) + +```javascript +var express = require('express') +var cors = require('cors') +var app = express() + +app.use(cors()) + +app.get('/products/:id', function (req, res, next) { + res.json({msg: 'This is CORS-enabled for all origins!'}) +}) + +app.listen(80, function () { + console.log('CORS-enabled web server listening on port 80') +}) +``` + +### Enable CORS for a Single Route + +```javascript +var express = require('express') +var cors = require('cors') +var app = express() + +app.get('/products/:id', cors(), function (req, res, next) { + res.json({msg: 'This is CORS-enabled for a Single Route'}) +}) + +app.listen(80, function () { + console.log('CORS-enabled web server listening on port 80') +}) +``` + +### Configuring CORS + +```javascript +var express = require('express') +var cors = require('cors') +var app = express() + +var corsOptions = { + origin: 'http://example.com', + optionsSuccessStatus: 200 // some legacy browsers (IE11, various SmartTVs) choke on 204 +} + +app.get('/products/:id', cors(corsOptions), function (req, res, next) { + res.json({msg: 'This is CORS-enabled for only example.com.'}) +}) + +app.listen(80, function () { + console.log('CORS-enabled web server listening on port 80') +}) +``` + +### Configuring CORS w/ Dynamic Origin + +```javascript +var express = require('express') +var cors = require('cors') +var app = express() + +var whitelist = ['http://example1.com', 'http://example2.com'] +var corsOptions = { + origin: function (origin, callback) { + if (whitelist.indexOf(origin) !== -1) { + callback(null, true) + } else { + callback(new Error('Not allowed by CORS')) + } + } +} + +app.get('/products/:id', cors(corsOptions), function (req, res, next) { + res.json({msg: 'This is CORS-enabled for a whitelisted domain.'}) +}) + +app.listen(80, function () { + console.log('CORS-enabled web server listening on port 80') +}) +``` + +If you do not want to block REST tools or server-to-server requests, +add a `!origin` check in the origin function like so: + +```javascript +var corsOptions = { + origin: function (origin, callback) { + if (whitelist.indexOf(origin) !== -1 || !origin) { + callback(null, true) + } else { + callback(new Error('Not allowed by CORS')) + } + } +} +``` + +### Enabling CORS Pre-Flight + +Certain CORS requests are considered 'complex' and require an initial +`OPTIONS` request (called the "pre-flight request"). An example of a +'complex' CORS request is one that uses an HTTP verb other than +GET/HEAD/POST (such as DELETE) or that uses custom headers. To enable +pre-flighting, you must add a new OPTIONS handler for the route you want +to support: + +```javascript +var express = require('express') +var cors = require('cors') +var app = express() + +app.options('/products/:id', cors()) // enable pre-flight request for DELETE request +app.del('/products/:id', cors(), function (req, res, next) { + res.json({msg: 'This is CORS-enabled for all origins!'}) +}) + +app.listen(80, function () { + console.log('CORS-enabled web server listening on port 80') +}) +``` + +You can also enable pre-flight across-the-board like so: + +```javascript +app.options('*', cors()) // include before other routes +``` + +### Configuring CORS Asynchronously + +```javascript +var express = require('express') +var cors = require('cors') +var app = express() + +var whitelist = ['http://example1.com', 'http://example2.com'] +var corsOptionsDelegate = function (req, callback) { + var corsOptions; + if (whitelist.indexOf(req.header('Origin')) !== -1) { + corsOptions = { origin: true } // reflect (enable) the requested origin in the CORS response + } else { + corsOptions = { origin: false } // disable CORS for this request + } + callback(null, corsOptions) // callback expects two parameters: error and options +} + +app.get('/products/:id', cors(corsOptionsDelegate), function (req, res, next) { + res.json({msg: 'This is CORS-enabled for a whitelisted domain.'}) +}) + +app.listen(80, function () { + console.log('CORS-enabled web server listening on port 80') +}) +``` + +## Configuration Options + +* `origin`: Configures the **Access-Control-Allow-Origin** CORS header. Possible values: + - `Boolean` - set `origin` to `true` to reflect the [request origin](http://tools.ietf.org/html/draft-abarth-origin-09), as defined by `req.header('Origin')`, or set it to `false` to disable CORS. + - `String` - set `origin` to a specific origin. For example if you set it to `"http://example.com"` only requests from "http://example.com" will be allowed. + - `RegExp` - set `origin` to a regular expression pattern which will be used to test the request origin. If it's a match, the request origin will be reflected. For example the pattern `/example\.com$/` will reflect any request that is coming from an origin ending with "example.com". + - `Array` - set `origin` to an array of valid origins. Each origin can be a `String` or a `RegExp`. For example `["http://example1.com", /\.example2\.com$/]` will accept any request from "http://example1.com" or from a subdomain of "example2.com". + - `Function` - set `origin` to a function implementing some custom logic. The function takes the request origin as the first parameter and a callback (which expects the signature `err [object], allow [bool]`) as the second. +* `methods`: Configures the **Access-Control-Allow-Methods** CORS header. Expects a comma-delimited string (ex: 'GET,PUT,POST') or an array (ex: `['GET', 'PUT', 'POST']`). +* `allowedHeaders`: Configures the **Access-Control-Allow-Headers** CORS header. Expects a comma-delimited string (ex: 'Content-Type,Authorization') or an array (ex: `['Content-Type', 'Authorization']`). If not specified, defaults to reflecting the headers specified in the request's **Access-Control-Request-Headers** header. +* `exposedHeaders`: Configures the **Access-Control-Expose-Headers** CORS header. Expects a comma-delimited string (ex: 'Content-Range,X-Content-Range') or an array (ex: `['Content-Range', 'X-Content-Range']`). If not specified, no custom headers are exposed. +* `credentials`: Configures the **Access-Control-Allow-Credentials** CORS header. Set to `true` to pass the header, otherwise it is omitted. +* `maxAge`: Configures the **Access-Control-Max-Age** CORS header. Set to an integer to pass the header, otherwise it is omitted. +* `preflightContinue`: Pass the CORS preflight response to the next handler. +* `optionsSuccessStatus`: Provides a status code to use for successful `OPTIONS` requests, since some legacy browsers (IE11, various SmartTVs) choke on `204`. + +The default configuration is the equivalent of: + +```json +{ + "origin": "*", + "methods": "GET,HEAD,PUT,PATCH,POST,DELETE", + "preflightContinue": false, + "optionsSuccessStatus": 204 +} +``` + +For details on the effect of each CORS header, read [this](http://www.html5rocks.com/en/tutorials/cors/) article on HTML5 Rocks. + +## Demo + +A demo that illustrates CORS working (and not working) using jQuery is available here: [http://node-cors-client.herokuapp.com/](http://node-cors-client.herokuapp.com/) + +Code for that demo can be found here: + +* Client: [https://github.com/TroyGoode/node-cors-client](https://github.com/TroyGoode/node-cors-client) +* Server: [https://github.com/TroyGoode/node-cors-server](https://github.com/TroyGoode/node-cors-server) + +## License + +[MIT License](http://www.opensource.org/licenses/mit-license.php) + +## Author + +[Troy Goode](https://github.com/TroyGoode) ([troygoode@gmail.com](mailto:troygoode@gmail.com)) + +[coveralls-image]: https://img.shields.io/coveralls/expressjs/cors/master.svg +[coveralls-url]: https://coveralls.io/r/expressjs/cors?branch=master +[downloads-image]: https://img.shields.io/npm/dm/cors.svg +[downloads-url]: https://npmjs.org/package/cors +[npm-image]: https://img.shields.io/npm/v/cors.svg +[npm-url]: https://npmjs.org/package/cors +[travis-image]: https://img.shields.io/travis/expressjs/cors/master.svg +[travis-url]: https://travis-ci.org/expressjs/cors diff --git a/auth/node_modules/cors/lib/index.js b/auth/node_modules/cors/lib/index.js new file mode 100644 index 0000000..5475aec --- /dev/null +++ b/auth/node_modules/cors/lib/index.js @@ -0,0 +1,238 @@ +(function () { + + 'use strict'; + + var assign = require('object-assign'); + var vary = require('vary'); + + var defaults = { + origin: '*', + methods: 'GET,HEAD,PUT,PATCH,POST,DELETE', + preflightContinue: false, + optionsSuccessStatus: 204 + }; + + function isString(s) { + return typeof s === 'string' || s instanceof String; + } + + function isOriginAllowed(origin, allowedOrigin) { + if (Array.isArray(allowedOrigin)) { + for (var i = 0; i < allowedOrigin.length; ++i) { + if (isOriginAllowed(origin, allowedOrigin[i])) { + return true; + } + } + return false; + } else if (isString(allowedOrigin)) { + return origin === allowedOrigin; + } else if (allowedOrigin instanceof RegExp) { + return allowedOrigin.test(origin); + } else { + return !!allowedOrigin; + } + } + + function configureOrigin(options, req) { + var requestOrigin = req.headers.origin, + headers = [], + isAllowed; + + if (!options.origin || options.origin === '*') { + // allow any origin + headers.push([{ + key: 'Access-Control-Allow-Origin', + value: '*' + }]); + } else if (isString(options.origin)) { + // fixed origin + headers.push([{ + key: 'Access-Control-Allow-Origin', + value: options.origin + }]); + headers.push([{ + key: 'Vary', + value: 'Origin' + }]); + } else { + isAllowed = isOriginAllowed(requestOrigin, options.origin); + // reflect origin + headers.push([{ + key: 'Access-Control-Allow-Origin', + value: isAllowed ? requestOrigin : false + }]); + headers.push([{ + key: 'Vary', + value: 'Origin' + }]); + } + + return headers; + } + + function configureMethods(options) { + var methods = options.methods; + if (methods.join) { + methods = options.methods.join(','); // .methods is an array, so turn it into a string + } + return { + key: 'Access-Control-Allow-Methods', + value: methods + }; + } + + function configureCredentials(options) { + if (options.credentials === true) { + return { + key: 'Access-Control-Allow-Credentials', + value: 'true' + }; + } + return null; + } + + function configureAllowedHeaders(options, req) { + var allowedHeaders = options.allowedHeaders || options.headers; + var headers = []; + + if (!allowedHeaders) { + allowedHeaders = req.headers['access-control-request-headers']; // .headers wasn't specified, so reflect the request headers + headers.push([{ + key: 'Vary', + value: 'Access-Control-Request-Headers' + }]); + } else if (allowedHeaders.join) { + allowedHeaders = allowedHeaders.join(','); // .headers is an array, so turn it into a string + } + if (allowedHeaders && allowedHeaders.length) { + headers.push([{ + key: 'Access-Control-Allow-Headers', + value: allowedHeaders + }]); + } + + return headers; + } + + function configureExposedHeaders(options) { + var headers = options.exposedHeaders; + if (!headers) { + return null; + } else if (headers.join) { + headers = headers.join(','); // .headers is an array, so turn it into a string + } + if (headers && headers.length) { + return { + key: 'Access-Control-Expose-Headers', + value: headers + }; + } + return null; + } + + function configureMaxAge(options) { + var maxAge = (typeof options.maxAge === 'number' || options.maxAge) && options.maxAge.toString() + if (maxAge && maxAge.length) { + return { + key: 'Access-Control-Max-Age', + value: maxAge + }; + } + return null; + } + + function applyHeaders(headers, res) { + for (var i = 0, n = headers.length; i < n; i++) { + var header = headers[i]; + if (header) { + if (Array.isArray(header)) { + applyHeaders(header, res); + } else if (header.key === 'Vary' && header.value) { + vary(res, header.value); + } else if (header.value) { + res.setHeader(header.key, header.value); + } + } + } + } + + function cors(options, req, res, next) { + var headers = [], + method = req.method && req.method.toUpperCase && req.method.toUpperCase(); + + if (method === 'OPTIONS') { + // preflight + headers.push(configureOrigin(options, req)); + headers.push(configureCredentials(options, req)); + headers.push(configureMethods(options, req)); + headers.push(configureAllowedHeaders(options, req)); + headers.push(configureMaxAge(options, req)); + headers.push(configureExposedHeaders(options, req)); + applyHeaders(headers, res); + + if (options.preflightContinue) { + next(); + } else { + // Safari (and potentially other browsers) need content-length 0, + // for 204 or they just hang waiting for a body + res.statusCode = options.optionsSuccessStatus; + res.setHeader('Content-Length', '0'); + res.end(); + } + } else { + // actual response + headers.push(configureOrigin(options, req)); + headers.push(configureCredentials(options, req)); + headers.push(configureExposedHeaders(options, req)); + applyHeaders(headers, res); + next(); + } + } + + function middlewareWrapper(o) { + // if options are static (either via defaults or custom options passed in), wrap in a function + var optionsCallback = null; + if (typeof o === 'function') { + optionsCallback = o; + } else { + optionsCallback = function (req, cb) { + cb(null, o); + }; + } + + return function corsMiddleware(req, res, next) { + optionsCallback(req, function (err, options) { + if (err) { + next(err); + } else { + var corsOptions = assign({}, defaults, options); + var originCallback = null; + if (corsOptions.origin && typeof corsOptions.origin === 'function') { + originCallback = corsOptions.origin; + } else if (corsOptions.origin) { + originCallback = function (origin, cb) { + cb(null, corsOptions.origin); + }; + } + + if (originCallback) { + originCallback(req.headers.origin, function (err2, origin) { + if (err2 || !origin) { + next(err2); + } else { + corsOptions.origin = origin; + cors(corsOptions, req, res, next); + } + }); + } else { + next(); + } + } + }); + }; + } + + // can pass either an options hash, an options delegate, or nothing + module.exports = middlewareWrapper; + +}()); diff --git a/auth/node_modules/cors/package.json b/auth/node_modules/cors/package.json new file mode 100644 index 0000000..42ee220 --- /dev/null +++ b/auth/node_modules/cors/package.json @@ -0,0 +1,78 @@ +{ + "_from": "cors", + "_id": "cors@2.8.5", + "_inBundle": false, + "_integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "_location": "/cors", + "_phantomChildren": {}, + "_requested": { + "type": "tag", + "registry": true, + "raw": "cors", + "name": "cors", + "escapedName": "cors", + "rawSpec": "", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "#USER", + "/" + ], + "_resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "_shasum": "eac11da51592dd86b9f06f6e7ac293b3df875d29", + "_spec": "cors", + "_where": "C:\\Priyathamwork\\locaft\\locaft\\auth", + "author": { + "name": "Troy Goode", + "email": "troygoode@gmail.com", + "url": "https://github.com/troygoode/" + }, + "bugs": { + "url": "https://github.com/expressjs/cors/issues" + }, + "bundleDependencies": false, + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "deprecated": false, + "description": "Node.js CORS middleware", + "devDependencies": { + "after": "0.8.2", + "eslint": "2.13.1", + "express": "4.16.3", + "mocha": "5.2.0", + "nyc": "13.1.0", + "supertest": "3.3.0" + }, + "engines": { + "node": ">= 0.10" + }, + "files": [ + "lib/index.js", + "CONTRIBUTING.md", + "HISTORY.md", + "LICENSE", + "README.md" + ], + "homepage": "https://github.com/expressjs/cors#readme", + "keywords": [ + "cors", + "express", + "connect", + "middleware" + ], + "license": "MIT", + "main": "./lib/index.js", + "name": "cors", + "repository": { + "type": "git", + "url": "git+https://github.com/expressjs/cors.git" + }, + "scripts": { + "lint": "eslint lib test", + "test": "npm run lint && nyc --reporter=html --reporter=text mocha --require test/support/env" + }, + "version": "2.8.5" +} diff --git a/auth/node_modules/dotenv/CHANGELOG.md b/auth/node_modules/dotenv/CHANGELOG.md new file mode 100644 index 0000000..7bf933b --- /dev/null +++ b/auth/node_modules/dotenv/CHANGELOG.md @@ -0,0 +1,155 @@ +# Changelog + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [8.2.0](https://github.com/motdotla/dotenv/compare/v8.1.0...v8.2.0) (2019-10-16) + +## [8.1.0](https://github.com/motdotla/dotenv/compare/v7.0.0...v8.1.0) (2019-08-18) + + +### ⚠ BREAKING CHANGES + +* dropping Node v6 support because end-of-life + +* Drop support for Node v6 (#392) ([2e9636a](https://github.com/motdotla/dotenv/commit/2e9636a)), closes [#392](https://github.com/motdotla/dotenv/issues/392) + +# [8.0.0](https://github.com/motdotla/dotenv/compare/v7.0.0...v8.0.0) (2019-05-02) + +- Drop support for Node v6 (#392) ([2e9636a](https://github.com/motdotla/dotenv/commit/2e9636a)), closes [#392](https://github.com/motdotla/dotenv/issues/392) + +### BREAKING CHANGES + +- dropping Node v6 support because end-of-life + +## [7.0.0] - 2019-03-12 + +### Fixed + +- Fix removing unbalanced quotes ([#376](https://github.com/motdotla/dotenv/pull/376)) + +### Removed + +- Removed `load` alias for `config` for consistency throughout code and documentation. + +## [6.2.0] - 2018-12-03 + +### Added + +- Support preload configuration via environment variables ([#351](https://github.com/motdotla/dotenv/issues/351)) + +## [6.1.0] - 2018-10-08 + +### Added + +- `debug` option for `config` and `parse` methods will turn on logging + +## [6.0.0] - 2018-06-02 + +### Changed + +- _Breaking:_ drop support for Node v4 ([#304](https://github.com/motdotla/dotenv/pull/304)) + +## [5.0.0] - 2018-01-29 + +### Added + +- Testing against Node v8 and v9 +- Documentation on trim behavior of values +- Documentation on how to use with `import` + +### Changed + +- _Breaking_: default `path` is now `path.resolve(process.cwd(), '.env')` +- _Breaking_: does not write over keys already in `process.env` if the key has a falsy value +- using `const` and `let` instead of `var` + +### Removed + +- Testing against Node v7 + +## [4.0.0] - 2016-12-23 + +### Changed + +- Return Object with parsed content or error instead of false ([#165](https://github.com/motdotla/dotenv/pull/165)). + +### Removed + +- `verbose` option removed in favor of returning result. + +## [3.0.0] - 2016-12-20 + +### Added + +- `verbose` option will log any error messages. Off by default. +- parses email addresses correctly +- allow importing config method directly in ES6 + +### Changed + +- Suppress error messages by default ([#154](https://github.com/motdotla/dotenv/pull/154)) +- Ignoring more files for NPM to make package download smaller + +### Fixed + +- False positive test due to case-sensitive variable ([#124](https://github.com/motdotla/dotenv/pull/124)) + +### Removed + +- `silent` option removed in favor of `verbose` + +## [2.0.0] - 2016-01-20 + +### Added + +- CHANGELOG to ["make it easier for users and contributors to see precisely what notable changes have been made between each release"](http://keepachangelog.com/). Linked to from README +- LICENSE to be more explicit about what was defined in `package.json`. Linked to from README +- Testing nodejs v4 on travis-ci +- added examples of how to use dotenv in different ways +- return parsed object on success rather than boolean true + +### Changed + +- README has shorter description not referencing ruby gem since we don't have or want feature parity + +### Removed + +- Variable expansion and escaping so environment variables are encouraged to be fully orthogonal + +## [1.2.0] - 2015-06-20 + +### Added + +- Preload hook to require dotenv without including it in your code + +### Changed + +- clarified license to be "BSD-2-Clause" in `package.json` + +### Fixed + +- retain spaces in string vars + +## [1.1.0] - 2015-03-31 + +### Added + +- Silent option to silence `console.log` when `.env` missing + +## [1.0.0] - 2015-03-13 + +### Removed + +- support for multiple `.env` files. should always use one `.env` file for the current environment + +[7.0.0]: https://github.com/motdotla/dotenv/compare/v6.2.0...v7.0.0 +[6.2.0]: https://github.com/motdotla/dotenv/compare/v6.1.0...v6.2.0 +[6.1.0]: https://github.com/motdotla/dotenv/compare/v6.0.0...v6.1.0 +[6.0.0]: https://github.com/motdotla/dotenv/compare/v5.0.0...v6.0.0 +[5.0.0]: https://github.com/motdotla/dotenv/compare/v4.0.0...v5.0.0 +[4.0.0]: https://github.com/motdotla/dotenv/compare/v3.0.0...v4.0.0 +[3.0.0]: https://github.com/motdotla/dotenv/compare/v2.0.0...v3.0.0 +[2.0.0]: https://github.com/motdotla/dotenv/compare/v1.2.0...v2.0.0 +[1.2.0]: https://github.com/motdotla/dotenv/compare/v1.1.0...v1.2.0 +[1.1.0]: https://github.com/motdotla/dotenv/compare/v1.0.0...v1.1.0 +[1.0.0]: https://github.com/motdotla/dotenv/compare/v0.4.0...v1.0.0 diff --git a/auth/node_modules/dotenv/LICENSE b/auth/node_modules/dotenv/LICENSE new file mode 100644 index 0000000..c430ad8 --- /dev/null +++ b/auth/node_modules/dotenv/LICENSE @@ -0,0 +1,23 @@ +Copyright (c) 2015, Scott Motte +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/auth/node_modules/dotenv/README.md b/auth/node_modules/dotenv/README.md new file mode 100644 index 0000000..cf65c9e --- /dev/null +++ b/auth/node_modules/dotenv/README.md @@ -0,0 +1,271 @@ +# dotenv + +dotenv + +Dotenv is a zero-dependency module that loads environment variables from a `.env` file into [`process.env`](https://nodejs.org/docs/latest/api/process.html#process_process_env). Storing configuration in the environment separate from code is based on [The Twelve-Factor App](http://12factor.net/config) methodology. + +[![BuildStatus](https://img.shields.io/travis/motdotla/dotenv/master.svg?style=flat-square)](https://travis-ci.org/motdotla/dotenv) +[![Build status](https://ci.appveyor.com/api/projects/status/github/motdotla/dotenv?svg=true)](https://ci.appveyor.com/project/motdotla/dotenv/branch/master) +[![NPM version](https://img.shields.io/npm/v/dotenv.svg?style=flat-square)](https://www.npmjs.com/package/dotenv) +[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) +[![Coverage Status](https://img.shields.io/coveralls/motdotla/dotenv/master.svg?style=flat-square)](https://coveralls.io/github/motdotla/dotenv?branch=coverall-intergration) +[![LICENSE](https://img.shields.io/github/license/motdotla/dotenv.svg)](LICENSE) +[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) + +## Install + +```bash +# with npm +npm install dotenv + +# or with Yarn +yarn add dotenv +``` + +## Usage + +As early as possible in your application, require and configure dotenv. + +```javascript +require('dotenv').config() +``` + +Create a `.env` file in the root directory of your project. Add +environment-specific variables on new lines in the form of `NAME=VALUE`. +For example: + +```dosini +DB_HOST=localhost +DB_USER=root +DB_PASS=s1mpl3 +``` + +`process.env` now has the keys and values you defined in your `.env` file. + +```javascript +const db = require('db') +db.connect({ + host: process.env.DB_HOST, + username: process.env.DB_USER, + password: process.env.DB_PASS +}) +``` + +### Preload + +You can use the `--require` (`-r`) [command line option](https://nodejs.org/api/cli.html#cli_r_require_module) to preload dotenv. By doing this, you do not need to require and load dotenv in your application code. This is the preferred approach when using `import` instead of `require`. + +```bash +$ node -r dotenv/config your_script.js +``` + +The configuration options below are supported as command line arguments in the format `dotenv_config_