{"_id":"@aytacworld/express-module-mongo","_rev":"3-b61dcf7ce558c761021b54094d68e36e","name":"@aytacworld/express-module-mongo","dist-tags":{"latest":"4.0.2"},"versions":{"4.0.0":{"name":"@aytacworld/express-module-mongo","version":"4.0.0","description":"Contains the default schemes for login and oauth2 modules","main":"index.js","repository":{"type":"git","url":"https://git.aytacworld.com/aytacworld/express"},"author":{"name":"Adem Aytaç","email":"adem@aytacworld.com","url":"https://aytacworld.com"},"license":"MIT","dependencies":{"bcrypt":"^3.0.6","mongoose":"^5.5.7"},"_id":"@aytacworld/express-module-mongo@4.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"aytacworld","email":"adem@aytacworld.com"},"dist":{"integrity":"sha512-cOx11sHOb98blcsvxOGUV0OJQv1Qw7uKapoc8/34rQR2n1SDWOLi0olFulcKKrjPdVVSN5wMYtRxEZ6Ww/70aw==","shasum":"57befa34c86d7dade7573f518afdd68006a1f3b1","tarball":"https://registry.npmjs.org/@aytacworld/express-module-mongo/-/express-module-mongo-4.0.0.tgz","fileCount":6,"unpackedSize":15542,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc2CrQCRA9TVsSAnZWagAAsDYP/0nhODfef3Q0qRf4YyIH\nqbSN7H8RNFZKMOgHXZqsqP7Nt30N4eaowE45A7DusZg9pp+VPI2g7WnzLjKH\nasIG7IfDC7cPYierz9pit3KqP5XXSzniAwdrbCXYXqVtssH1+S9+jJrp3c0G\nuFMhjkC5pdLo2tlmvrFcukr8D6pxL5PAu0EoYD+qKaWJYb3JkSiZlDZ5mlIR\nPor/Ttx6xU0rP/mAyodk0Scdmyvm1dlCosS1I1arhm3wdIelEUZCKTD8qONC\nUwGGGbZiftIck1/oybB1li9mtvfxHYpPESOK2uQj84UiQHyGFywXNlFMObjd\nVQOLB0Qt9+VAN8Y7W0cJVNCAwdIrTqEIGPYDLfuDvxhEyakakhfdUloRMhw3\nEbxWWTdFnnhzTkvVd0o1+289QueggSHzwhCOhIRaNDIeMN7BOXnTvPHiSjoe\nJIYBBnw+LWTtw15VADS7opWd4jIIqUUDMPZl9lPDgOAdqlmjocG2Nvaksc/9\nTjRtw5TqSYDQ33I4j6rF7gD3/bP/dG87c0KNvALKO0jJCrKz4o0UR1r9Xkr4\n24Iyt6YXMZZtxxyzgX3JFWGv+A0AbFAsBweT7p8D3QqqA8MGywtIIb3r+fNd\nPpLzol+6YWsIKd4aGHGS12Trm36LdrBJC4pLVbe6799kFuf0l5ySaYv/X7YZ\n+1jJ\r\n=q6ZM\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCEhdtXZnJ8xMcKl4S2Yxxwrj/jfrd/Ryc9/lBqI5Zn0gIhAMMM9U9WBSzKU3QvGafrinqF4IEEgT8UTpGxI5vGSW/h"}]},"maintainers":[{"name":"aytacworld","email":"adem@aytacworld.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/express-module-mongo_4.0.0_1557670608362_0.4952124721517559"},"_hasShrinkwrap":false},"4.0.1":{"name":"@aytacworld/express-module-mongo","version":"4.0.1","description":"Contains the default schemes for login and oauth2 modules","main":"index.js","repository":{"type":"git","url":"https://git.aytacworld.com/aytacworld/express"},"author":{"name":"Adem Aytaç","email":"adem@aytacworld.com","url":"https://aytacworld.com"},"license":"MIT","dependencies":{"bcrypt":"^3.0.6","mongoose":"^5.5.9"},"_id":"@aytacworld/express-module-mongo@4.0.1","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"aytacworld","email":"adem@aytacworld.com"},"dist":{"integrity":"sha512-DnWnaF1XZknaYGBSLXALZAPe5CngNj+xm/arBOCgFcg/LG637amQp9iTDgU3NaxKz9QcOMawWU7yMojMifoM9g==","shasum":"b1701ea3821752c7a590307770ee89f97337a485","tarball":"https://registry.npmjs.org/@aytacworld/express-module-mongo/-/express-module-mongo-4.0.1.tgz","fileCount":6,"unpackedSize":15660,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc4tdLCRA9TVsSAnZWagAApcgP/RErHCGGOFyDy8RGdPAW\nxRx/0Ko5k5Lv63NAxDbv1dD9nHXSKiELHZTVtVNeTjkPf0q1i6V0qfGj20lL\ntol7uMHvrMHbYvWo5KeFZIuWf8r/6NBwIFRF6HZ0or6HNIqM/r6UJ1lEZLbf\ndCNN+dWhDkXm2UaZQZsS/eIKCK7x5G9Q8a/l4JdURdr2RgKqGHL2fDINlfSq\n7x/4bnBug/9uX/kR9E9sP4VGZ8HPzKd6pMth+HvrgSvPmm1Wj/CnJnrp13kU\nJrMhwUkfj9TaIFk8gptcpyOOu7PrwuxOEAyWjOtx10bn65eL9ryD8t1XqkjD\nmSxrPrYyiiMGcOWMQlQRMX2/8UE3v9RYLqgfrGIDb44w7GlDYMVks6GIgG16\nDfv0wWPnqtiH/2QEQYMnlpwYoSAz9tA81d9DsTWUb5peWbwCXAwyO9vFpSII\nwTPIxKtwPY9tgCK9CUphuFnJtasfmLRELwjVckYj3vetHSsrdK+xOeLpScyg\nTFx/X9i72QvHjEJRHUAkwAi/A7F4DwQv/eN4A5bdgpGR4JstJqOAL93jdyLQ\n6RDiKxC0kCq14aUdmbzbgjEatanBkP6bcjnLkdtSJCbmvFjTdm2kKHEL7d1y\nQPAzoM2plyb2IiXiITe/7/6/na7Qv2svkutJdwvP0EHSI5rC1vjTApXfb6E4\nsSW8\r\n=Mi5G\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC0F6RH96NTnoX9R6oNYsruShuEDxfJU+oF/Wqg7sR0CQIhAOFOkuTqbfN7sCfJXMjdAcYEAz9c8bQWlLw6qIIv+FsA"}]},"maintainers":[{"name":"aytacworld","email":"adem@aytacworld.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/express-module-mongo_4.0.1_1558370122396_0.2322433354054083"},"_hasShrinkwrap":false},"4.0.2":{"name":"@aytacworld/express-module-mongo","version":"4.0.2","description":"Contains the default schemes for login and oauth2 modules","main":"index.js","repository":{"type":"git","url":"https://git.aytacworld.com/aytacworld/express"},"author":{"name":"Adem Aytaç","email":"adem@aytacworld.com","url":"https://aytacworld.com"},"license":"MIT","dependencies":{"bcrypt":"^3.0.6","mongoose":"^5.5.9"},"_id":"@aytacworld/express-module-mongo@4.0.2","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"aytacworld","email":"adem@aytacworld.com"},"dist":{"integrity":"sha512-yqNQ5F3ajoR+tQRic7ey8Y5nUB8nB5qps8UUCqMAlDbX0dXzSSgO2CiEGz0slqYqCA/FMy4/3jV/PJ6eMw8a+g==","shasum":"72ea5b58b6b1a05222295e087803d6fcc8261da3","tarball":"https://registry.npmjs.org/@aytacworld/express-module-mongo/-/express-module-mongo-4.0.2.tgz","fileCount":6,"unpackedSize":15674,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc4tfgCRA9TVsSAnZWagAAOroQAKLrfh1Q5j0/w2aIsVyG\nS6pLZYPlNCww1M3amn9SSqClt22jQJJYnAnGaAGvH43vUty3bpOCxw7YR6jo\nm83TiJCfEiBFWoFClrDjVarPP1MEVXpK95MwAisnwmqpq0q0eglg2egjc9+J\njZ5GmX0Z3WVGOu72S4SitZ5ZQeTOEjfJ4ImI6ape1yYLvxzA2SjQLBGm6MgC\nb+Ua91ALrVn7jczD8C6E7UEAP4HNcDs5erICCHLL9MIN03VNFdkUVoMFbFsC\nGo89pOoLJHn53NEsiLhkTx36tJkw6bqBpmJ+K/9kJasCcgXICwUTmP5ihc8H\n0Pjr0J3w+OafThVeo1G60yp0HoAqb8OaN9KnjBc9lh5GRNvywKTDg9fFTOpY\nbsCG2bXcMd+AuyALLO0yiRiX60aESO8PzUizdvF8rhvHU3z53BbMK6o/t13y\n7fTRJ2SGHp0L/WbSr1pLa3M+DHWX50+r2bqN5jmX+3AN861YTww+uaiKX7P5\nj59fi3UuyQvDS8IkjdXHu8xVj38wq6z3U4RNXCRhZKCiFD0ymV+UgtEaGLI9\nlMC/WOyvb53Bd/NG3O0KZ0R/YKERLSmGucqpfd6rjRIGorVt7HSaXE+NC5X4\np5VRCrelqLHRvEGz1rdTA0ez/ppTfnH+KTEnjMPY9e4KsW7O7BZGDCGE1rqZ\nzlCc\r\n=Zl2R\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIE0pYa59x7XMsNiOmujYmfs+Y6yA8JytZa5YFXs2X47bAiEAyddRjBstH5++E3OUxA9Qx7gtjzfTjjvYjcZsyWdHgDk="}]},"maintainers":[{"name":"aytacworld","email":"adem@aytacworld.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/express-module-mongo_4.0.2_1558370272327_0.6849341992039386"},"_hasShrinkwrap":false}},"time":{"created":"2019-05-12T14:16:48.332Z","4.0.0":"2019-05-12T14:16:48.499Z","modified":"2022-04-04T17:15:02.559Z","4.0.1":"2019-05-20T16:35:22.609Z","4.0.2":"2019-05-20T16:37:52.431Z"},"maintainers":[{"name":"aytacworld","email":"adem@aytacworld.com"}],"description":"Contains the default schemes for login and oauth2 modules","repository":{"type":"git","url":"https://git.aytacworld.com/aytacworld/express"},"author":{"name":"Adem Aytaç","email":"adem@aytacworld.com","url":"https://aytacworld.com"},"license":"MIT","readme":"# @aytacworld/express-module-mongo\n\nThis module contains the database models for [@aytacworld/express-module-login](https://www.npmjs.com/package/@aytacworld/express-module-login) and [@aytacworld/express-module-oauth-server](https://www.npmjs.com/package/@aytacworld/express-module-oauth-server).\n\nThe module uses MongoDB as backend.\n\n*!!! You need to pass the connectionSting with configs object, or it will try to connect to a mongoDb instance on localhost*\n\n## Installation\n\nusing npm\n\n`npm i @aytacworld/express-module-mongo`\n\nusing yarn\n\n`yarn add @aytacworld/express-module-mongo`\n\n## Usage\n\nAdd the module using `app.module()` method, before any other module or route. So it will become available to others.\n\napp.js\n```javascript\nconst Express = require('@aytacworld/express');\nconst ExpressDatabase = require('@aytacworld/express-module-mongo');\nconst config = require('./config');\nconst app = new Express(config);\n\napp.module(ExpressDatabase);\n\napp.route('/', require('./route'));\n\napp.listen();\n```\n\nIn your route, you can access the db as authDb module.\n\nroute.js\n```javascript\nconst path = require('path');\nconst router = require('express').Router();\n\nconst Router = (config, { authDb }) => {\n  router.get('/', async (req, res) => {\n    const user = await authDb.users.findById(123);\n    res.render('homepage', { user });\n  });\n\n  return router;\n};\n\nmodule.exports = Router;\n```\n\n## Config\n\n```json\n{\n  \"EXPRESS_MODULE_AUTH_DB_NAME\": \"myAuthDb\", // String, default: authDb\n  \"EXPRESS_MODULE_AUTH_CONNECTION_STRING\": \"mongo://localhost:27017/authDb\", // String, default: \"mongo://localhost:27017/authDb\"\n  \"EXPRESS_MODULE_AUTH_APPLICATION_NAME\": \"my-awesome-app\", // String, default: \"myApplication\"\n  \"EXPRESS_MODULE_AUTH_SALT_ROUND\": 34, // Number, default: 10\n}\n```\n\n## Schemas and Methods\n\n### Users\n#### Schema\n```js\n{\n  username: String,\n  password: String,\n  hashed: Boolean,\n  applications: [String],\n}\n```\n#### Methods\n```js\n{\n  static findById(id): Promise<user>;\n  static findByUsername(username): Promise<user>;\n  static comparePassword(username, password): Promise<user|false>;\n  static updateUser(username, password): Promise<void>;\n  static addUser(username, password): Promise<void>;\n  static deleteUser(username): Promise<void>;\n}\n```\n### Clients\n#### Schema\n```js\n{\n  name: String,\n  clientId: String,\n  clientSecret: String,\n  redirectUrl: String,\n}\n```\n#### Methods\n```js\n{\n  static findById(id): Promise<client>;\n  static findByClientId(clientId): Promise<client>;\n  static compareSecret(username, secret): Promise<client|false>;\n  static updateClient(clientId, name, secret, redirectUrl): Promise<void>;\n  static addClient(clientId, name, secret, redirectUrl): Promise<void>;\n  static deleteClient(clientId): Promise<void>;\n}\n```\n\n### Tokens\n#### Schema\n```js\n{\n  token: String,\n  userId: String,\n  clientId: String,\n  redirectUri: String,\n\n  refreshToken: String,\n  expiresIn: Number,\n\n  authCode: String,\n  state: String,\n  transactionId: String,\n  codeChallenge: String,\n}\n```\n#### Methods\n```js\n{\n  static find(key): Promise<token>;\n  static findByUserIdAndClientId(userId, clientId): Promise<token>;\n  static findByTransactionId(transactionId): Promise<token>;\n  static saveCode(authCode, userId, clientId, redirectUri, state, transactionId): Promise<void>;\n  static exchangeAuthCodeForAccessToken(authCode, accessToken, refreshToken, expiresIn): Promise<void>;\n  static refreshAccessToken(refreshToken, accessToken, expiresIn): Promise<void>;\n}\n```\n\n## MIT License\n\nCopyright (c) 2019 Adem Aytaç\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","readmeFilename":"README.md"}