{"_id":"@boyuai/nestjs-oauth2-server","_rev":"2-9719fbb6dd00f4395792a56f62d24772","name":"@boyuai/nestjs-oauth2-server","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0-rc.0":{"name":"@boyuai/nestjs-oauth2-server","version":"0.1.0-rc.0","description":"A Nestjs wrapper for oauth2-server","main":"index.js","types":"index.d.ts","author":{"name":"B'Tunde Aromire"},"keywords":["nestjs oauth2 server","nestjs oauth2","@nestjs/oauth2-server","nest oauth2 server","nestjs","nest"],"directories":{"lib":"lib","test":"test"},"scripts":{"commit":"commit","format":"prettier --write lib/**/*.ts test/**/*.ts","build":"rimraf -rf dist && tsc -p tsconfig.build.json","build:watch":"rimraf -rf dist && tsc -p tsconfig.build.json -w","lint":"eslint lib/**/*.ts --fix","prepublish:npm":"npm run build","publish:npm":"npm publish --access public","prepublish:next":"npm run build","publish:next":"npm publish --access public --tag next","test":"npm run test:integration","test:integration":"jest --config ./test/jest-e2e.config.json --runInBand","test:cov":"jest --config ./test/jest-e2e.config.json --runInBand --coverage","prerelease":"npm run build","release":"dotenv release-it --"},"dependencies":{},"devDependencies":{"@commitlint/cli":"11.0.0","@commitlint/config-conventional":"11.0.0","@commitlint/prompt-cli":"11.0.0","@compodoc/compodoc":"1.1.12","@nestjs/common":"7.6.15","@nestjs/core":"7.6.15","@nestjs/platform-express":"7.6.15","@nestjs/testing":"7.6.15","@types/jest":"26.0.23","@types/node":"13.13.52","@types/oauth2-server":"3.0.12","@types/rimraf":"3.0.1","@types/supertest":"2.0.11","@typescript-eslint/eslint-plugin":"4.23.0","@typescript-eslint/parser":"4.23.0","dotenv-cli":"4.0.0","eslint":"7.26.0","eslint-config-prettier":"7.2.0","eslint-plugin-import":"2.22.1","husky":"4.3.8","jest":"26.6.3","lint-staged":"10.5.4","moment":"2.29.1","oauth2-server":"3.1.1","prettier":"2.2.1","reflect-metadata":"0.1.13","release-it":"14.6.2","renovate":"24.119.23","rimraf":"3.0.2","rxjs":"6.6.7","supertest":"6.1.3","ts-jest":"26.5.6","typescript":"4.2.4"},"repository":{"type":"git","url":"git+https://github.com/toondaey/nestjs-oauth2-server.git"},"license":"MIT","bugs":{"url":"https://github.com/toondaey/nestjs-oauth2-server/issues"},"husky":{"hooks":{"commit-msg":"commitlint -E HUSKY_GIT_PARAMS","pre-commit":"lint-staged"}},"lint-staged":{"lib/**/*.ts":["prettier --write"],"test/**/*.ts":["prettier --write"]},"peerDependencies":{"@nestjs/common":"^6.10.0 || ^7.0.0 || ^8.0.10","reflect-metadata":"^0.1.12","rxjs":"^6.0.0 || ^7.2.0"},"homepage":"https://github.com/toondaey/nestjs-oauth2-server#readme","publishConfig":{"access":"public"},"gitHead":"7a20d062cd6c9352cf6654ea0b2644648e7648b2","_id":"@boyuai/nestjs-oauth2-server@0.1.0-rc.0","_nodeVersion":"14.16.0","_npmVersion":"7.19.1","dist":{"integrity":"sha512-v5rYWC0/tsUtknhMRKcsrTMJMOEHJB58RTfL9zKn9nVIHRQVbjvTS9Y/T8/7bYdKvR9gZNYCyjmwuPfqjfINdw==","shasum":"f2b7a1fa1ff7962594429c83c918b300997ad0aa","tarball":"https://registry.npmjs.org/@boyuai/nestjs-oauth2-server/-/nestjs-oauth2-server-0.1.0-rc.0.tgz","fileCount":39,"unpackedSize":47805,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhmLhECRA9TVsSAnZWagAAcTcP/RDbPvX3B6C0MQQTsxJi\noeDsf/6FUM8d+iflDiMyiT56x+T1/ChfJAOr+7tVNhGflzqgZ827gYPlkxH2\nixnkQe838MaLYciz/QNa55vlQr0Dbn2OZYUzBeXGQd0dJuhmTQ21g32BGoVm\n5AgLza/wDBYB2XgNE0VyNJvC8+QfA+3u1513UQFYObNXGBtq/avegae8aROn\nLZ3qi9M31C0qhLgkqAzYmCdJAx23ENeKWqMTuLAyfldxQ8gwZ30fOzcx+VhI\nPbPPkP8hRDatXOI6O0/yEH44IIqi+M0pizGHL1/ip+eB3BXx5xGoc4WrLoa8\nsFT+35+1qzFou1f2p0KCFvLwuNkWqqXo+f1f23rWWpOKo359b6iigiLat5uO\nPTn6cUOc9hBbe7Qk6WAFh9Ht8nrB/XbF96Hj8GYA6GD9aBj69/Z/N4fJX3k+\ngndlMFA5xgqyKB2f7iypamYnxiplJ3twAKrlhU277WDw17Dr0W0w1pTpj9kz\nAIIjP/ICF+U4u6hohL/MCUAq9w0hXiZjAAzW3r5tjCgiQ1znb1Haapo1biRA\njH3EqMBYAVpBTO3Kvh2L0Y4966fnB0u88FEYLIUMzzfYafRrFnvZIEC0LFGp\nE9mlKYq2qmkquZhUoYCKNpagHRr4wDdvYHouC8Yo9uaFlvUGjon5u4VCwsNg\nGMrr\r\n=iGVg\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA24oJXMaBAVLnzKf6QPmw8b53Q/mTDElGHNw7FhufOjAiBbPOOU5eoGPy1EZZ2aYPWHXmCyofBnHeMyzrUwQpVh7w=="}]},"_npmUser":{"name":"helsonxiao","email":"helsonxiao@gmail.com"},"maintainers":[{"name":"wangsijie","email":"wangsijie94@gmail.com"},{"name":"tripley","email":"keanever@outlook.com"},{"name":"weiyichong","email":"864147974@qq.com"},{"name":"qianyue","email":"xiangyujames@gmail.com"},{"name":"helsonxiao","email":"helsonxiao@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nestjs-oauth2-server_0.1.0-rc.0_1637398595899_0.13008182415447989"},"_hasShrinkwrap":false},"0.1.0":{"name":"@boyuai/nestjs-oauth2-server","version":"0.1.0","description":"A NestJS wrapper for oauth2-server","main":"index.js","types":"index.d.ts","author":{"name":"B'Tunde Aromire"},"keywords":["nestjs oauth2 server","nestjs oauth2","@nestjs/oauth2-server","nest oauth2 server","nestjs","nest"],"directories":{"lib":"lib","test":"test"},"scripts":{"commit":"commit","format":"prettier --write lib/**/*.ts test/**/*.ts","build":"rimraf -rf dist && tsc -p tsconfig.build.json","build:watch":"rimraf -rf dist && tsc -p tsconfig.build.json -w","lint":"eslint lib/**/*.ts --fix","prepublish:npm":"npm run build","publish:npm":"npm publish --access public","prepublish:next":"npm run build","publish:next":"npm publish --access public --tag next","test":"npm run test:integration","test:integration":"jest --config ./test/jest-e2e.config.json --runInBand","test:cov":"jest --config ./test/jest-e2e.config.json --runInBand --coverage","prerelease":"npm run build","release":"dotenv release-it --"},"dependencies":{},"devDependencies":{"@commitlint/cli":"11.0.0","@commitlint/config-conventional":"11.0.0","@commitlint/prompt-cli":"11.0.0","@compodoc/compodoc":"1.1.12","@nestjs/common":"7.6.15","@nestjs/core":"7.6.15","@nestjs/platform-express":"7.6.15","@nestjs/testing":"7.6.15","@types/jest":"26.0.23","@types/node":"13.13.52","@types/oauth2-server":"3.0.12","@types/rimraf":"3.0.1","@types/supertest":"2.0.11","@typescript-eslint/eslint-plugin":"4.23.0","@typescript-eslint/parser":"4.23.0","dotenv-cli":"4.0.0","eslint":"7.26.0","eslint-config-prettier":"7.2.0","eslint-plugin-import":"2.22.1","husky":"4.3.8","jest":"26.6.3","lint-staged":"10.5.4","moment":"2.29.1","oauth2-server":"3.1.1","prettier":"2.2.1","reflect-metadata":"0.1.13","release-it":"14.6.2","renovate":"24.119.23","rimraf":"3.0.2","rxjs":"6.6.7","supertest":"6.1.3","ts-jest":"26.5.6","typescript":"4.2.4"},"repository":{"type":"git","url":"git+https://github.com/boyuai/nestjs-oauth2-server.git"},"license":"MIT","bugs":{"url":"https://github.com/boyuai/nestjs-oauth2-server/issues"},"husky":{"hooks":{"commit-msg":"commitlint -E HUSKY_GIT_PARAMS","pre-commit":"lint-staged"}},"lint-staged":{"lib/**/*.ts":["prettier --write"],"test/**/*.ts":["prettier --write"]},"peerDependencies":{"@nestjs/common":"^6.10.0 || ^7.0.0 || ^8.0.10","reflect-metadata":"^0.1.12","rxjs":"^6.0.0 || ^7.2.0"},"homepage":"https://github.com/boyuai/nestjs-oauth2-server#readme","publishConfig":{"access":"public"},"gitHead":"21305dcdbde0ad182afc0ff1e0f53593a69623a1","_id":"@boyuai/nestjs-oauth2-server@0.1.0","_nodeVersion":"14.19.0","_npmVersion":"7.24.2","dist":{"integrity":"sha512-jSpSHeWI18pFnUXN2+eUJd8Oos5RyxnZoSEX4oTeAewIq1AOXaj/7ZwrxgZ56W8qJfpQw5ri7FATJAu7orrW1g==","shasum":"d0d55580c44384a970a7385c8dfa0c3b6898a529","tarball":"https://registry.npmjs.org/@boyuai/nestjs-oauth2-server/-/nestjs-oauth2-server-0.1.0.tgz","fileCount":39,"unpackedSize":48337,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiGj3HACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrxDQ//fmms/EPVwFW0QjLBfq87ODAMQ7zJMC6kGgN2uqDFCXXWiP+h\r\nStpu3wpJJIaV3WnhRjgP6koK9oZOFSnQt3O6j+5PifIt6UVjpm3TonmBgA26\r\nG70veYGkzyqnCwcW1ra465yDQ86nlWgDjs8Vbfa4j8LkVFFuoPUHPMzOEr66\r\nFH33X01aF2gLEpmpp7esKx7QZ8V2aGopuIWyUZKnhNGH7dkiwUnwq9RKFL+/\r\n2FET9s/lRhjuF0INZE2HYt8tEVQCY6uRBSKl4OwaoPGrAZUzg5g/Ji0niTxh\r\n5Vi6JtDGVszkDX2Qv4K/kFyfnDBEnm3Nmakk44X179djP3eB1lxi9UbSyyDO\r\nvc5aokq9CvCNkSHSVgZa/YyTGXva72luw8+AyMxlxro8S7SAIiga1XDGfNPU\r\nA9QD0oYdp+RqpXiVlYVge4GDFz8UCrUzprDOFddEbBwm6Io/2z1ojBj9ENlD\r\nw6+3ABncaqKuo4onMA/PmCQb/rgtUyBZniQt2Nq3TosyjGIAuFJBW+tpIP3Q\r\nZuV8jrJZiOTuXE1/8k4/TowUR+xlRt4I6OYvEBhWZllUnYqNqV1PMM6tsl+e\r\n0rqXxyQBIDHuLOuCCbMNeW85POiDvo8ZTqb+5TjGXzT57hTmZdHznMalNbiV\r\nSPI+Jxoo4rVo40p45nT96M43vO5FA+WBdPg=\r\n=Uyn7\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBDH9+tKozrN6yMjO3mpNMu+rOlU/sWmHT8fefs2PGa2AiB0l67FCD5TxO8UCX2lx1S6xgUEp5O41gKfI4ayZvp7Vg=="}]},"_npmUser":{"name":"helsonxiao","email":"helsonxiao@gmail.com"},"maintainers":[{"name":"wangsijie","email":"wangsijie94@gmail.com"},{"name":"tripley","email":"keanever@outlook.com"},{"name":"weiyichong","email":"864147974@qq.com"},{"name":"qianyue","email":"xiangyujames@gmail.com"},{"name":"helsonxiao","email":"helsonxiao@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nestjs-oauth2-server_0.1.0_1645886919794_0.14735211755104793"},"_hasShrinkwrap":false}},"time":{"created":"2021-11-20T08:56:35.838Z","0.1.0-rc.0":"2021-11-20T08:56:36.046Z","modified":"2022-04-04T20:18:34.056Z","0.1.0":"2022-02-26T14:48:39.925Z"},"maintainers":[{"name":"wangsijie","email":"wangsijie94@gmail.com"},{"name":"tripley","email":"keanever@outlook.com"},{"name":"weiyichong","email":"864147974@qq.com"},{"name":"qianyue","email":"xiangyujames@gmail.com"},{"name":"helsonxiao","email":"helsonxiao@gmail.com"}],"description":"A NestJS wrapper for oauth2-server","homepage":"https://github.com/boyuai/nestjs-oauth2-server#readme","keywords":["nestjs oauth2 server","nestjs oauth2","@nestjs/oauth2-server","nest oauth2 server","nestjs","nest"],"repository":{"type":"git","url":"git+https://github.com/boyuai/nestjs-oauth2-server.git"},"author":{"name":"B'Tunde Aromire"},"bugs":{"url":"https://github.com/boyuai/nestjs-oauth2-server/issues"},"license":"MIT","readme":"## NestJS OAuth2 Server\n\n<p align=\"center\">\n  <a href=\"http://nestjs.com/\" target=\"blank\"><img src=\"https://nestjs.com/img/logo-small.svg\" width=\"120\" alt=\"Nest Logo\" /></a>\n  <img src=\"https://github.com/boyuai/nestjs-oauth2-server/blob/master/oauth2.png?raw=true\" width=\"120\" alt=\"OAuth2 Logo\" />\n</p>\n\n<p align='center'>\n    <a href=\"https://www.npmjs.com/package/@boyuai/nestjs-oauth2-server\" target='_blank'><img alt=\"npm\" src=\"https://img.shields.io/npm/dm/@boyuai/nestjs-oauth2-server\" alt=\"NPM Downloads\"></a>\n    <!-- <a href=\"https://coveralls.io/github/toondaey/nestjs-oauth2-server\" target=\"_blank\" rel=\"noopener noreferrer\"><img alt=\"Coveralls github\" src=\"https://img.shields.io/coveralls/github/toondaey/nestjs-oauth2-server\"></a> -->\n    <a href=\"https://npmjs.com/@boyuai/nestjs-oauth2-server\" target=\"_blank\" rel=\"noopener noreferrer\"><img alt=\"npm version\" src=\"https://img.shields.io/npm/v/@boyuai/nestjs-oauth2-server?label=NPM&logo=NPM\"></a>\n    <a href=\"https://npmjs.com/@boyuai/nestjs-oauth2-server\" target=\"_blank\" rel=\"noopener noreferrer\"><img alt=\"LICENCE\" src=\"https://img.shields.io/npm/l/@boyuai/nestjs-oauth2-server\"></a>\n    <!-- <a href=\"https://circleci.com/gh/toondaey/nestjs-oauth2-server\" target=\"_blank\" rel=\"noopener noreferrer\"><img alt=\"CircleCI build\" src=\"https://img.shields.io/circleci/build/gh/toondaey/nestjs-oauth2-server/master\"></a> -->\n    <a href=\"https://www.npmjs.com/package/@boyuai/nestjs-oauth2-server\" target=\"_blank\" rel=\"noopener noreferrer\"><img alt=\"synk vulnerabilities\" src=\"https://img.shields.io/snyk/vulnerabilities/npm/@boyuai/nestjs-oauth2-server\"></a>\n</p>\n\n<p>\nA <a href=\"https://nestjs.com\" target='_blank'>NestJS</a> wrapper module for the <a href='https://oauth2-server.readthedocs.io/en/latest/index.html' target='_blank'>oauth2-server</a> package.\n</p>\n\n<details>\n<summary><strong>Table of content</strong> (click to expand)</summary>\n\n<!-- toc -->\n\n-   [Installation](#installation)\n-   [Configuration](#configuration)\n-   [Usage](#usage)\n-   [Learnings](#learnings)\n-   [Contributing](#contributing)\n    <!-- tocstop -->\n    </details>\n\n## Installation\n\nInstallation is as simple as running:\n\n`npm install @boyuai/nestjs-oauth2-server`\n\nor\n\n`yarn add @boyuai/nestjs-oauth2-server`.\n\n## Configuration\n\n1. Include the module as a dependency in the module where oauth will happen:\n\n`oauth2.module.ts`\n\n```ts\nimport { Module } from '@nestjs/common';\nimport { OAuth2ServerModule } from '@boyuai/nestjs-oauth2-server';\nimport { OAuth2Controller } from './oauth2.controller';\nimport { OAuth2ServiceModule } from './oauth2-service.module';\nimport { OAuth2Model } from './oauth2.model';\n\n@Module({\n  imports: [\n    OAuth2ServiceModule,\n    OAuth2ServerModule.forRoot({\n      imports: [OAuth2ServiceModule], // import your repository for OAuth2Model here\n      modelClass: OAuth2Model,\n    }),\n  ],\n  controllers: [OAuth2Controller],\n})\nexport class OAuth2Module {}\n```\n\nIn addition to the above the, **oauth2-server** requires a [model](https://oauth2-server.readthedocs.io/en/latest/model/overview.html) to create the server. This can be provided as a service from any part of the application. This should be able to fetch data about clients, users, token, and authorization codes. This **MUST** be a service decorated with the `Injectable` decorator.\n\n`oauth2.model.ts`\n\n```ts\nimport { Injectable } from '@nestjs/common';\n\n@Injectable()\nexport class OAuth2Model implements RequestAuthenticationModel {\n    getAccessToken() {}\n\n    verifyScope() {}\n    // ...\n    // check more codes in test/src/test-model.service.ts\n}\n```\n\n## Usage\n\nThe module also provides some nifty decorators to help with configuring the oauth2 handler endpoints. An example controller covering the entire array of decorators is given below\n\n`oauth2.controller.ts`\n\n```ts\nimport { Controller } from '@nestjs/common';\nimport {\n  OAuth2Authorization,\n  OAuth2Authorize,\n  OAuth2RenewToken,\n  OAuth2Token,\n} from '@boyuai/nestjs-oauth2-server';\n\n@Controller()\nexport class OAuth2Controller {\n    @Post()\n    @OAuth2Authenticate()\n    authenticateClient(@OAuth2Token() token: Token) {\n        return token;\n    }\n\n    @Post()\n    @OAuth2Authorize()\n    authorizeClient(\n        @OAuth2Authorization()\n        authorization: AuthorizationCode,\n    ) {\n        return authorization;\n    }\n\n    @Post()\n    @OAuth2RenewToken()\n    renewToken(@OAuth2Token() token: Token) {\n        return token;\n    }\n}\n```\n\n## Async Configuration\n\nThe module could also be included asynchronously using the `forRootAsync` method.\n\nExamples below:\n\n-   Using factory provider approach\n\n```ts\nimport { Module } from '@nestjs/common';\nimport {\n    OAuth2ServerModule,\n    IOAuth2ServerModuleOptions,\n} from '@boyuai/nestjs-oauth2-server';\n\n@Module({\n    imports: [\n        // ... other modules\n        OAuth2ServerModule.forRootAsync({\n            useFactory: (factory: IOAuth2ServerOptionsFactory) => ({}),\n            modelClass: YourModelService,\n        }),\n    ],\n})\nexport class YourModule {}\n```\n\n-   Using class or existing provider approach:\n\n`oauth2-server-config.service.ts`\n\n```ts\nimport {\n    IOAuth2ServerModuleOptions,\n    IOAuth2ServerOptionsFactory,\n} from '@boyuai/nestjs-oauth2-server';\nimport { Injectable } from '@nestjs/common';\n\n@Injectable()\nexport class OAuth2ServerConfigService\n    implements IOAuth2ServerOptionsFactory {\n    createOAuth2ServerOptions(): IOAuth2ServerModuleOptions {\n        return {};\n    }\n}\n```\n\nThe `OAuth2ServerConfigService` **SHOULD** implement the `IOAuth2ServerOptionsFactory`, **MUST** declare the `createOAuth2ServerOptions` method and **MUST** return `IOAuth2ServerModuleOptions` object.\n\n```ts\nimport { Module } from '@nestjs/common';\nimport { OAuth2ServerModule } from '@boyuai/nestjs-oauth2-server';\nimport { OAuth2ServerConfigService } from './oauth2-server-config.service.ts';\n\n@Module({\n    imports: [\n        // ... other modules\n        OAuth2ServerModule.forRootAsync({\n            useClass: OAuth2ServerConfigService,\n            modelClass: YourModelService,\n        }),\n    ],\n})\nexport class YourModule {}\n```\n\n## Learnings\n\nThe concept of OAuth2 can be further understood in this article [here](https://www.digitalocean.com/community/tutorials/an-introduction-to-oauth-2). Also you can head over to the oauth2-server package [documentation](package).\n\n## Contributing\n\nSuggestions for improvement are welcomed, however, please adhere to the [contributing](./CONTRIBUTING.md) guidelines.\n\n[package]: https://oauth2-server.readthedocs.io/en/latest/index.html\n","readmeFilename":"README.md"}