{"_id":"@arunvaradharajalu/common.learning-management-system-api.authorization","_rev":"3-cad2783a85abf1038ff40d64737d8d2a","name":"@arunvaradharajalu/common.learning-management-system-api.authorization","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.0":{"name":"@arunvaradharajalu/common.learning-management-system-api.authorization","version":"1.0.0","keywords":["common-authorization-learning-mangement-system","common-authorization-lms"],"author":{"name":"Arun Varadharajalu"},"license":"ISC","_id":"@arunvaradharajalu/common.learning-management-system-api.authorization@1.0.0","maintainers":[{"name":"arunvaradharajalu","email":"arunvaradharajalu@gmail.com"}],"homepage":"https://github.com/arunv11u/lms-api-common-authorization#readme","bugs":{"url":"https://github.com/arunv11u/lms-api-common-authorization/issues"},"dist":{"shasum":"003782c061085d37f18ee87eb140ed949436d203","tarball":"https://registry.npmjs.org/@arunvaradharajalu/common.learning-management-system-api.authorization/-/common.learning-management-system-api.authorization-1.0.0.tgz","fileCount":32,"integrity":"sha512-bAMRdbIygtXSJsWeCiE0/3/7AgT4ncfr6Yvc1kVk7uZLKL+xq8/ph/z7xQ9oNYBWsCeYUInwwPBpNBGtElFguw==","signatures":[{"sig":"MEUCIAji86oTBBI7kU1OaEAGbvW5dlGt6LXlQDOoev1T4JH1AiEA1enlUetX+i0o7jy8Lvj09Z3W8Ly2SRN7Q2O8UpBv6B0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23847},"jest":{"roots":["<rootDir>/test"],"preset":"ts-jest","reporters":["default",["./node_modules/jest-html-reporter",{"pageTitle":"Common Authorization Module Test Report"}]],"clearMocks":true,"testEnvironment":"node"},"main":"./build/index.js","types":"./build/index.d.ts","gitHead":"c726ca69ca5ab499fa13390b9eef01ca0a084848","scripts":{"test":"jest --watchAll --verbose --no-cache --detectOpenHandles --env=node --coverage","build":"npm run clean && tsc --project tsconfig.build.json","clean":"rimraf build"},"_npmUser":{"name":"arunvaradharajalu","email":"arunvaradharajalu@gmail.com"},"repository":{"url":"git+ssh://git@github.com/arunv11u/lms-api-common-authorization.git","type":"git"},"_npmVersion":"10.2.4","description":"This package contains the common authorization module for the Learning Management System services","directories":{},"_nodeVersion":"20.11.0","dependencies":{"jsonwebtoken":"^9.0.2","@arunvaradharajalu/common.errors":"^1.1.0"},"_hasShrinkwrap":false,"devDependencies":{"rimraf":"^5.0.7","ts-jest":"^29.1.4","@types/jest":"^29.5.12","@faker-js/faker":"^9.0.2","jest-html-reporter":"^3.10.2","@types/jsonwebtoken":"^9.0.7"},"_npmOperationalInternal":{"tmp":"tmp/common.learning-management-system-api.authorization_1.0.0_1727189363812_0.8950842840304267","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@arunvaradharajalu/common.learning-management-system-api.authorization","version":"1.0.1","keywords":["common-authorization-learning-mangement-system","common-authorization-lms"],"author":{"name":"Arun Varadharajalu"},"license":"ISC","_id":"@arunvaradharajalu/common.learning-management-system-api.authorization@1.0.1","maintainers":[{"name":"arunvaradharajalu","email":"arunvaradharajalu@gmail.com"}],"homepage":"https://github.com/arunv11u/lms-api-common-authorization#readme","bugs":{"url":"https://github.com/arunv11u/lms-api-common-authorization/issues"},"dist":{"shasum":"1109ff9f5595b5beffed8c1946ca89cd6f694381","tarball":"https://registry.npmjs.org/@arunvaradharajalu/common.learning-management-system-api.authorization/-/common.learning-management-system-api.authorization-1.0.1.tgz","fileCount":33,"integrity":"sha512-OecvUPlQr4aRrVOrpNf3zFaeyz7QZbdGmR8SuCDWeJrYyqvNpZUFXbzy5qaVt0IIlTf+ch86Hsc0m6cX25ehAw==","signatures":[{"sig":"MEQCIGwnVfNCMgh9uWYYv/z8fFpAgNs2PolijAqPoibiKHJ1AiASD2XsgedSbbooEmsGo3yXnJXvmbkwD/Fv+17j2seMbQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":26383},"jest":{"roots":["<rootDir>/test"],"preset":"ts-jest","reporters":["default",["./node_modules/jest-html-reporter",{"pageTitle":"Common Authorization Module Test Report"}]],"clearMocks":true,"testEnvironment":"node"},"main":"./build/index.js","types":"./build/index.d.ts","gitHead":"752ed4d8bf249f2d936695f71c4512ab5c0667ab","scripts":{"test":"jest --watchAll --verbose --no-cache --detectOpenHandles --env=node --coverage","build":"npm run clean && tsc --project tsconfig.build.json","clean":"rimraf build"},"_npmUser":{"name":"arunvaradharajalu","email":"arunvaradharajalu@gmail.com"},"repository":{"url":"git+ssh://git@github.com/arunv11u/lms-api-common-authorization.git","type":"git"},"_npmVersion":"10.2.4","description":"This package contains the common authorization module for the Learning Management System services","directories":{},"_nodeVersion":"20.11.0","dependencies":{"jsonwebtoken":"^9.0.2","@arunvaradharajalu/common.errors":"^1.1.0"},"_hasShrinkwrap":false,"devDependencies":{"rimraf":"^5.0.7","ts-jest":"^29.1.4","@types/jest":"^29.5.12","@faker-js/faker":"^9.0.2","jest-html-reporter":"^3.10.2","@types/jsonwebtoken":"^9.0.7"},"_npmOperationalInternal":{"tmp":"tmp/common.learning-management-system-api.authorization_1.0.1_1727190486878_0.9575319297602511","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"@arunvaradharajalu/common.learning-management-system-api.authorization","version":"1.0.2","keywords":["common-authorization-learning-mangement-system","common-authorization-lms"],"author":{"name":"Arun Varadharajalu"},"license":"ISC","_id":"@arunvaradharajalu/common.learning-management-system-api.authorization@1.0.2","maintainers":[{"name":"arunvaradharajalu","email":"arunvaradharajalu@gmail.com"}],"homepage":"https://github.com/arunv11u/lms-api-common-authorization#readme","bugs":{"url":"https://github.com/arunv11u/lms-api-common-authorization/issues"},"dist":{"shasum":"43aa5e643b7a4a82bede6e605a33b23d514a26dc","tarball":"https://registry.npmjs.org/@arunvaradharajalu/common.learning-management-system-api.authorization/-/common.learning-management-system-api.authorization-1.0.2.tgz","fileCount":33,"integrity":"sha512-zBihmx5+YsBmY1OXgS8SteKAjNnCDy5TzP4fn9k56tBqYuI39tsZoolhBVK7SROB4RV+aXfWQT6dU/qc212Mfg==","signatures":[{"sig":"MEUCIQDmBTfEjEVLuZJhdlCCNpViXuA290+BEi5m21OP00Nh2QIgL81QH+UuHPA3RROqzhsL8NyvMMQiuAD6KClN2M3ZEzQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":26943},"jest":{"roots":["<rootDir>/test"],"preset":"ts-jest","reporters":["default",["./node_modules/jest-html-reporter",{"pageTitle":"Common Authorization Module Test Report"}]],"clearMocks":true,"testEnvironment":"node"},"main":"./build/index.js","types":"./build/index.d.ts","gitHead":"6dff09b1cac80b0f7d03b1c267c9b660e8098a38","scripts":{"test":"jest --watchAll --verbose --no-cache --detectOpenHandles --env=node --coverage","build":"npm run clean && tsc --project tsconfig.build.json","clean":"rimraf build"},"_npmUser":{"name":"arunvaradharajalu","email":"arunvaradharajalu@gmail.com"},"repository":{"url":"git+ssh://git@github.com/arunv11u/lms-api-common-authorization.git","type":"git"},"_npmVersion":"10.2.4","description":"This package contains the common authorization module for the Learning Management System services","directories":{},"_nodeVersion":"20.11.0","dependencies":{"jsonwebtoken":"^9.0.2","@arunvaradharajalu/common.errors":"^1.1.0"},"_hasShrinkwrap":false,"devDependencies":{"rimraf":"^5.0.7","ts-jest":"^29.1.4","@types/jest":"^29.5.12","@faker-js/faker":"^9.0.2","jest-html-reporter":"^3.10.2","@types/jsonwebtoken":"^9.0.7"},"_npmOperationalInternal":{"tmp":"tmp/common.learning-management-system-api.authorization_1.0.2_1727191122013_0.9517850312689666","host":"s3://npm-registry-packages"}},"1.0.3":{"name":"@arunvaradharajalu/common.learning-management-system-api.authorization","version":"1.0.3","description":"This package contains the common authorization module for the Learning Management System services","main":"./build/index.js","types":"./build/index.d.ts","scripts":{"clean":"rimraf build","build":"npm run clean && tsc --project tsconfig.build.json","test":"jest --watchAll --verbose --no-cache --detectOpenHandles --env=node --coverage"},"jest":{"preset":"ts-jest","testEnvironment":"node","roots":["<rootDir>/test"],"clearMocks":true,"reporters":["default",["./node_modules/jest-html-reporter",{"pageTitle":"Common Authorization Module Test Report"}]]},"repository":{"type":"git","url":"git+ssh://git@github.com/arunv11u/lms-api-common-authorization.git"},"keywords":["common-authorization-learning-mangement-system","common-authorization-lms"],"author":{"name":"Arun Varadharajalu"},"license":"ISC","bugs":{"url":"https://github.com/arunv11u/lms-api-common-authorization/issues"},"homepage":"https://github.com/arunv11u/lms-api-common-authorization#readme","devDependencies":{"@faker-js/faker":"^9.0.2","@types/jest":"^29.5.12","@types/jsonwebtoken":"^9.0.7","jest-html-reporter":"^3.10.2","rimraf":"^5.0.7","ts-jest":"^29.1.4"},"dependencies":{"@arunvaradharajalu/common.errors":"^1.1.0","jsonwebtoken":"^9.0.2"},"_id":"@arunvaradharajalu/common.learning-management-system-api.authorization@1.0.3","gitHead":"d83aa34a56d5520d15148b86694f85ff01e42662","_nodeVersion":"20.11.0","_npmVersion":"10.2.4","dist":{"integrity":"sha512-8VZorYLyyom+/h5ZuFWbT/reJGQQ9qMLRZGrUPKtdUEEqYeEZWMr9fwFfsrgcMmEbnf9Y1rYNJ65Q/bZ9s/y2g==","shasum":"ce0aa4fe2f7c332ccd7e3ad8b6435fb87410f954","tarball":"https://registry.npmjs.org/@arunvaradharajalu/common.learning-management-system-api.authorization/-/common.learning-management-system-api.authorization-1.0.3.tgz","fileCount":33,"unpackedSize":26941,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIB3OA89HSRT3O7FfdO4OwQKwN0spajjRI+1Vke9xHrxwAiA920hLFa68rQb6OlJR3rug3NWKlt+mfxuZi+yFFWXCSw=="}]},"_npmUser":{"name":"arunvaradharajalu","email":"arunvaradharajalu@gmail.com"},"directories":{},"maintainers":[{"name":"arunvaradharajalu","email":"arunvaradharajalu@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/common.learning-management-system-api.authorization_1.0.3_1727668268990_0.7188446625345946"},"_hasShrinkwrap":false}},"time":{"created":"2024-09-24T14:49:23.687Z","modified":"2024-09-30T03:51:09.364Z","1.0.0":"2024-09-24T14:49:24.029Z","1.0.1":"2024-09-24T15:08:07.107Z","1.0.2":"2024-09-24T15:18:42.261Z","1.0.3":"2024-09-30T03:51:09.182Z"},"bugs":{"url":"https://github.com/arunv11u/lms-api-common-authorization/issues"},"author":{"name":"Arun Varadharajalu"},"license":"ISC","homepage":"https://github.com/arunv11u/lms-api-common-authorization#readme","keywords":["common-authorization-learning-mangement-system","common-authorization-lms"],"repository":{"type":"git","url":"git+ssh://git@github.com/arunv11u/lms-api-common-authorization.git"},"description":"This package contains the common authorization module for the Learning Management System services","maintainers":[{"name":"arunvaradharajalu","email":"arunvaradharajalu@gmail.com"}],"readme":"# @arunvaradharajalu/common.learning-management-system-api.authorization\n\n[![npm version](https://badge.fury.io/js/%40arunvaradharajalu%2Fcommon.learning-management-system-api.authorization.svg)](https://www.npmjs.com/package/@arunvaradharajalu/common.learning-management-system-api.authorization)\n[![GitHub issues](https://img.shields.io/github/issues/arunv11u/lms-api-common-authorization)](https://github.com/arunv11u/lms-api-common-authorization/issues)\n[![GitHub license](https://img.shields.io/github/license/arunv11u/lms-api-common-authorization)](https://github.com/arunv11u/lms-api-common-authorization/blob/master/LICENSE)\n\n## Overview\n\nThis package provides a common authorization module for services within the Learning Management System (LMS). It allows for the validation of bearer authorization tokens using JSON Web Tokens (JWT), ensuring secure access to system resources.\n\n## Installation\n\nYou can install this package using npm:\n\n```bash\nnpm install @arunvaradharajalu/common.learning-management-system-api.authorization\n```\n\n## Usage\n\n### Importing the Module\n\n```bash\nimport {\n    Authorization,\n    AuthorizationImpl,\n    JWTPayload\n} from \"@arunvaradharajalu/common.learning-management-system-api.authorization\";\n```\n\n### Example: Validating Authorization Tokens\n\n```bash\nconst authorization: Authorization = new AuthorizationImpl(\"your_jwt_private_key\");\n\nasync function validateToken(bearerToken: string) {\n    try {\n        const payload: JWTPayload = await authorization.validate(bearerToken);\n        console.log(\"User authenticated with session ID:\", payload.sessionId);\n    } catch (error) {\n        console.error(\"Invalid token:\", error.message);\n    }\n}\n```\n\nIn this example, the AuthorizationImpl class is initialized with a JWT private key. The validate method takes a bearer token, extracts the JWT from it, verifies the signature, and returns the decoded payload.\n\n## API Reference\n\n### `AuthorizationImpl`\n\n#### Constructor\n\n```bash\nconstructor(jwtPrivateKey: string);\n```\n\n- jwtPrivateKey: The private key used to verify JWT tokens.\n\n#### Methods\n\n`validate(bearerAuthToken: string): Promise<JWTPayload>`\n\nValidates the provided bearer authorization token.\n\n- bearerAuthToken: A string that contains the bearer token (must start with \"Bearer \").\n- Returns: A Promise<JWTPayload> containing session and user data.\n\n`JWTPayload`\n\nA class representing the decoded JWT payload. It contains the following properties:\n\n- sessionId: The session ID associated with the token.\n- user: The user object associated with the session.\n- type: The type of token (e.g., access or refresh token).\n\n## Scripts\n\n- clean: Cleans the build directory.\n- build: Compiles the TypeScript code to JavaScript.\n- test: Runs the tests using Jest and generates a test report.\n\n## Tests\n\nTests can be run using:\n\n```bash\nnpm run test\n```\n\nTest results will be available in an HTML format using the jest-html-reporter.\n\n## License\n\nThis project is licensed under the ISC License.\n\n## Issues\n\nFor any issues or bug reports, please visit the GitHub Issues Page.\n\n## Author\n\nArun Varadharajalu","readmeFilename":"README.md"}