{"_id":"@alphaapps/alpha-auth","_rev":"2-1155d9766caa405bc7428fc90779eb5d","name":"@alphaapps/alpha-auth","dist-tags":{"latest":"0.2.9"},"versions":{"0.2.7":{"name":"@alphaapps/alpha-auth","version":"0.2.7","description":"### Installation:","author":{"name":"Abdulrahman Falyoun"},"main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","publishConfig":{"access":"public"},"scripts":{"pre-publish":"yarn format && yarn build","prebuild":"rimraf dist","build":"nest build","format":"prettier --write \"src/**/*.ts\"","start":"nest start","start:dev":"nest start --watch","start:debug":"nest start --debug --watch","start:prod":"node dist/main","lint":"eslint \"{src,apps,libs,test}/**/*.ts\" --fix","test":"jest --detectOpenHandles","test:watch":"jest --watch","test:cov":"jest --coverage","test:debug":"node --inspect-brk -r tsconfig-paths/regfister -r ts-node/register node_modules/.bin/jest --runInBand","test:e2e":"jest --config src/test/jest-e2e.json"},"dependencies":{"@nestjs/common":"^8.0.0","@nestjs/core":"^8.0.0","@nestjs/jwt":"^8.0.0","@nestjs/passport":"^8.0.1","@nestjs/platform-express":"^8.0.0","@nestjs/sequelize":"^8.0.0","accept-language-parser":"^1.5.0","alpha-common":"^0.2.2","alpha-nestjsx-crud":"^0.0.6","class-transformer":"^0.5.1","class-validator":"^0.13.2","config":"^3.3.6","firebase-admin":"^10.0.0","iso-639-1":"^2.1.10","loadash":"^1.0.0","nest-access-control":"^2.0.2","nest-router":"^1.0.9","passport":"^0.5.2","passport-jwt":"^4.0.0","reflect-metadata":"^0.1.13","rimraf":"^3.0.2","rxjs":"^7.2.0","sequelize-typescript":"^2.1.1","tscpaths":"^0.0.9","validator":"^13.7.0"},"devDependencies":{"@nestjs/cli":"^8.0.0","@nestjs/schematics":"^8.0.0","@nestjs/testing":"^8.0.0","@types/accept-language-parser":"^1.5.3","@types/bcrypt":"^5.0.0","@types/config":"^0.0.40","@types/express":"^4.17.13","@types/jest":"27.0.2","@types/lodash":"^4.14.177","@types/node":"^16.0.0","@types/passport-jwt":"^3.0.6","@types/sequelize":"^4.28.11","@types/supertest":"^2.0.11","@types/validator":"^13.7.0","@typescript-eslint/eslint-plugin":"^5.0.0","@typescript-eslint/parser":"^5.0.0","eslint":"^8.0.1","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^4.0.0","jest":"^27.2.5","prettier":"^2.5.0","source-map-support":"^0.5.20","supertest":"^6.1.3","ts-jest":"^27.0.3","ts-loader":"^9.2.3","ts-node":"^10.0.0","tsconfig-paths":"^3.10.1","typescript":"^4.3.5"},"jest":{"moduleFileExtensions":["js","json","ts"],"rootDir":"src","testRegex":".*\\.spec\\.ts$","transform":{"^.+\\.(t|j)s$":"ts-jest"},"collectCoverageFrom":["**/*.(t|j)s"],"coverageDirectory":"../coverage","testEnvironment":"node"},"gitHead":"70c858796be3521b0797846052dc3b97162a60b2","_id":"@alphaapps/alpha-auth@0.2.7","_nodeVersion":"16.13.1","_npmVersion":"9.1.1","dist":{"integrity":"sha512-MaZEcIT6hoGQ10GJ+9qXFeGjuF/KHS2wcwPb2yMSw9pgxXJxu8+qZ0JeO5obeuEDQ7Bd/uoUfad+OxfCGWz99w==","shasum":"055fbb97a516e7776768d13044f731543df095de","tarball":"https://registry.npmjs.org/@alphaapps/alpha-auth/-/alpha-auth-0.2.7.tgz","fileCount":168,"unpackedSize":408363,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD27bCTfK7mJPKqrUmLsSydzL3adQ/57htxq4DIEsquUAIhANtDLxwA0EpqFA0ZcWhgttSCHxRTvCoRXbMSe9ohq85Z"}]},"_npmUser":{"name":"sami.sammour","email":"samisammour@gmail.com"},"directories":{},"maintainers":[{"name":"sami.sammour","email":"samisammour@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/alpha-auth_0.2.7_1693824087945_0.7053951862876875"},"_hasShrinkwrap":false},"0.2.8":{"name":"@alphaapps/alpha-auth","version":"0.2.8","description":"### Installation:","author":{"name":"Abdulrahman Falyoun"},"main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","publishConfig":{"access":"public"},"scripts":{"pre-publish":"yarn format && yarn build","prebuild":"rimraf dist","build":"nest build","format":"prettier --write \"src/**/*.ts\"","start":"nest start","start:dev":"nest start --watch","start:debug":"nest start --debug --watch","start:prod":"node dist/main","lint":"eslint \"{src,apps,libs,test}/**/*.ts\" --fix","test":"jest --detectOpenHandles","test:watch":"jest --watch","test:cov":"jest --coverage","test:debug":"node --inspect-brk -r tsconfig-paths/regfister -r ts-node/register node_modules/.bin/jest --runInBand","test:e2e":"jest --config src/test/jest-e2e.json"},"dependencies":{"@nestjs/common":"^8.0.0","@nestjs/core":"^8.0.0","@nestjs/jwt":"^8.0.0","@nestjs/passport":"^8.0.1","@nestjs/platform-express":"^8.0.0","@nestjs/sequelize":"^8.0.0","accept-language-parser":"^1.5.0","alpha-common":"^0.2.2","alpha-nestjsx-crud":"^0.0.6","class-transformer":"^0.5.1","class-validator":"^0.13.2","config":"^3.3.6","firebase-admin":"^10.0.0","iso-639-1":"^2.1.10","loadash":"^1.0.0","nest-access-control":"^2.0.2","nest-router":"^1.0.9","passport":"^0.5.2","passport-jwt":"^4.0.0","reflect-metadata":"^0.1.13","rimraf":"^3.0.2","rxjs":"^7.2.0","sequelize-typescript":"^2.1.1","tscpaths":"^0.0.9","validator":"^13.7.0"},"devDependencies":{"@nestjs/cli":"^8.0.0","@nestjs/schematics":"^8.0.0","@nestjs/testing":"^8.0.0","@types/accept-language-parser":"^1.5.3","@types/bcrypt":"^5.0.0","@types/config":"^0.0.40","@types/express":"^4.17.13","@types/jest":"27.0.2","@types/lodash":"^4.14.177","@types/node":"^16.0.0","@types/passport-jwt":"^3.0.6","@types/sequelize":"^4.28.11","@types/supertest":"^2.0.11","@types/validator":"^13.7.0","@typescript-eslint/eslint-plugin":"^5.0.0","@typescript-eslint/parser":"^5.0.0","eslint":"^8.0.1","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^4.0.0","jest":"^27.2.5","prettier":"^2.5.0","source-map-support":"^0.5.20","supertest":"^6.1.3","ts-jest":"^27.0.3","ts-loader":"^9.2.3","ts-node":"^10.0.0","tsconfig-paths":"^3.10.1","typescript":"^4.3.5"},"jest":{"moduleFileExtensions":["js","json","ts"],"rootDir":"src","testRegex":".*\\.spec\\.ts$","transform":{"^.+\\.(t|j)s$":"ts-jest"},"collectCoverageFrom":["**/*.(t|j)s"],"coverageDirectory":"../coverage","testEnvironment":"node"},"gitHead":"51f66df648330d748f237a4904f44466d63ebeae","_id":"@alphaapps/alpha-auth@0.2.8","_nodeVersion":"16.13.1","_npmVersion":"9.1.1","dist":{"integrity":"sha512-CetPFXUEGGZ3dwm7m2HYTtNxYC9Mj2VOMspi7sGYuJiJingZznbumdTdvKhi12fxa5yIdVJBHCtPw4IGPzvgbg==","shasum":"794550a3482709d90816fb4dbeaba4df7c35571e","tarball":"https://registry.npmjs.org/@alphaapps/alpha-auth/-/alpha-auth-0.2.8.tgz","fileCount":168,"unpackedSize":408374,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBL8XhXtCBnZ7g44BU/tDbRO1eMT6qCkdfOLa2HxM2CaAiBZRIMMjrQeDtPs9+eoQb4ihNCogi8IvSMAPZ94fFtPWg=="}]},"_npmUser":{"name":"sami.sammour","email":"samisammour@gmail.com"},"directories":{},"maintainers":[{"name":"sami.sammour","email":"samisammour@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/alpha-auth_0.2.8_1693827667220_0.9252031668024479"},"_hasShrinkwrap":false},"0.2.9":{"name":"@alphaapps/alpha-auth","version":"0.2.9","description":"### Installation:","author":{"name":"Abdulrahman Falyoun"},"main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","publishConfig":{"access":"public"},"scripts":{"prepublishOnly":"yarn format && yarn build","prebuild":"rimraf dist","build":"nest build","format":"prettier --write \"src/**/*.ts\"","start":"nest start","start:dev":"nest start --watch","start:debug":"nest start --debug --watch","start:prod":"node dist/main","lint":"eslint \"{src,apps,libs,test}/**/*.ts\" --fix","test":"jest --detectOpenHandles","test:watch":"jest --watch","test:cov":"jest --coverage","test:debug":"node --inspect-brk -r tsconfig-paths/regfister -r ts-node/register node_modules/.bin/jest --runInBand","test:e2e":"jest --config src/test/jest-e2e.json"},"dependencies":{"@nestjs/common":"^8.0.0","@nestjs/core":"^8.0.0","@nestjs/jwt":"^8.0.0","@nestjs/passport":"^8.0.1","@nestjs/platform-express":"^8.0.0","@nestjs/sequelize":"^8.0.0","accept-language-parser":"^1.5.0","alpha-common":"^0.2.2","alpha-nestjsx-crud":"^0.0.6","class-transformer":"^0.5.1","class-validator":"^0.13.2","config":"^3.3.6","firebase-admin":"^10.0.0","iso-639-1":"^2.1.10","loadash":"^1.0.0","nest-access-control":"^2.0.2","nest-router":"^1.0.9","passport":"^0.5.2","passport-jwt":"^4.0.0","reflect-metadata":"^0.1.13","rimraf":"^3.0.2","rxjs":"^7.2.0","sequelize-typescript":"^2.1.1","tscpaths":"^0.0.9","validator":"^13.7.0"},"devDependencies":{"@nestjs/cli":"^8.0.0","@nestjs/schematics":"^8.0.0","@nestjs/testing":"^8.0.0","@types/accept-language-parser":"^1.5.3","@types/bcrypt":"^5.0.0","@types/config":"^0.0.40","@types/express":"^4.17.13","@types/jest":"27.0.2","@types/lodash":"^4.14.177","@types/node":"^16.0.0","@types/passport-jwt":"^3.0.6","@types/sequelize":"^4.28.11","@types/supertest":"^2.0.11","@types/validator":"^13.7.0","@typescript-eslint/eslint-plugin":"^5.0.0","@typescript-eslint/parser":"^5.0.0","eslint":"^8.0.1","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^4.0.0","jest":"^27.2.5","prettier":"^2.5.0","source-map-support":"^0.5.20","supertest":"^6.1.3","ts-jest":"^27.0.3","ts-loader":"^9.2.3","ts-node":"^10.0.0","tsconfig-paths":"^3.10.1","typescript":"^4.3.5"},"jest":{"moduleFileExtensions":["js","json","ts"],"rootDir":"src","testRegex":".*\\.spec\\.ts$","transform":{"^.+\\.(t|j)s$":"ts-jest"},"collectCoverageFrom":["**/*.(t|j)s"],"coverageDirectory":"../coverage","testEnvironment":"node"},"gitHead":"27a19ac8eca0df89da07306189ed4850bf933900","_id":"@alphaapps/alpha-auth@0.2.9","_nodeVersion":"16.13.1","_npmVersion":"9.1.1","dist":{"integrity":"sha512-6jgeq7pJDCQv6NKuxVW5LuKO2iWphfLjOfxotP5Nc3n4XTHIgmL4PfPqww5K1stTV0YpkXuzcwx6LuTqiz/3/g==","shasum":"57185dcbe5b512c348914da3b953f4b13ec9b187","tarball":"https://registry.npmjs.org/@alphaapps/alpha-auth/-/alpha-auth-0.2.9.tgz","fileCount":168,"unpackedSize":408298,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAWwmuMEJMQz4WDa20qfAvas7AQlkShscekdFttO37R5AiEAtnYY8tMqRpajz90ZiOV/a6W6RrO/ei+44fxIHmk4g8I="}]},"_npmUser":{"name":"sami.sammour","email":"samisammour@gmail.com"},"directories":{},"maintainers":[{"name":"sami.sammour","email":"samisammour@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/alpha-auth_0.2.9_1693827965247_0.20212660165668916"},"_hasShrinkwrap":false}},"time":{"created":"2023-09-04T10:41:27.854Z","0.2.7":"2023-09-04T10:41:28.131Z","modified":"2023-09-04T11:46:05.629Z","0.2.8":"2023-09-04T11:41:07.486Z","0.2.9":"2023-09-04T11:46:05.416Z"},"maintainers":[{"name":"sami.sammour","email":"samisammour@gmail.com"}],"description":"### Installation:","author":{"name":"Abdulrahman Falyoun"},"readme":"## Authentication Module:\n\n### Installation:\n\n```shell\nnpm install @alphaapps/alpha-auth\n```\n\nThis is the basic module for authentication, and it can be used as the following:\n\n```ts\n@Module({\n  imports: [\n    AuthModule.register({\n      userModel: User,\n      expiresIn: 0,\n      oneSessionPerAccount: false,\n      loginMethods: [\n        {\n          loginField: 'phoneNumber',\n          passwordField: 'pin',\n        },\n        {\n          loginField: 'email',\n          passwordField: 'password',\n        },\n      ],\n    }),\n  ],\n})\nexport default class AppModule {}\n```\n\n### Options passed to the `register` method:\n\n- `userModel: typeof AuthUser`: Indicates the main model if the user in the system. This model must extend the `AuthUser` (can be imported from `@alphaapps/nestjs-auth`) model in order for it to work.\n- `expiresIn: number` The age of the authentication token (in seconds). `0` means the token does NOT expire.\n- `oneSessionPerAccount: boolean`: When set to `true` will generate a new token on each successful login.\n- `loginMethods: { loginField: string, passwordField: string }[]`: The allowed login methods in the system.\n- `property?: string`: The name of the property for the user object to be saved in the request. `default: 'user'`\n- `anonymousRole?: string`: The name of the role in the system that can access specific resources anonymously. `default: 'any'`\n- `userFindOptions?: FindOptions`: The options sent to database when selecting the user. This is useful when we want to include any relation and has it with the user object in the request.\n- `authModulePath?: string`: The path of the authentication routes.\n- `firebaseOTPValidation?: boolean`: Indicates whether we use Firebase OTP service, or our own. `default: false`\n- `useRoles?: boolean`: Indicates whether we have roles in the system or not. `default: true`\n- `rolesRelationName?: string`: The name of the `roles` relation in the User model. `default: 'associatedRoles'`\n- `sendOTPSMS?: (number: string, message: string, data: Record<string, any>) => Promise<void>`: A function called when sending an SMS. This is useful when we want to customize the OTP message.\n\n### Included Models:\n\n- `AuthUser`: The main User model, the `User` model in the system must extend this model to add its custom properties and relations. It already has an association with `Rols` model.\n- `Role`: The model used to define roles and ACLs in the system.\n- `VerifiactionCode`: Used to save verification codes when validating a phone number.\n\n#### A Note about roles:\n\nRoles are dynamic in our applications, meaning they are saved in the database and retrieved on every startup of the app.\nIn order to use it for pre-defined roles (like customer, client, agent... etc) an array of default roles is passed to the initiation of the `RolesModule` like this:\n\n```ts\nRoleModule.register([\n  {\n    role: 'default',\n    resource: 'User',\n    action: 'read:own',\n  },\n  {\n    role: 'default',\n    resource: 'User',\n    action: 'update:own',\n  },\n]);\n```\n\n> Hint: `RoleModule` can be imported from `alpha-auth`\n\n### Auth Routes:\n\nThere's a bunch of routes that are generated when using this module that can be used out of the box.  \nAll APIs are prefixed with the `authModulePath` specified in the `AuthModule.register` method.\n\n- validate-number:\n  - Body:\n    - `phoneNumber: string`\n  - Response:\n    - `next: 'login' | 'register'`\n    - `user: User`\n  - Headers:\n    - `Accept-Language`\n    - `X-App-Version`\n    - `X-Device-Platform`\n- signup:  \n  Creates a new user in the application. It internally calls `User.alphaCreate` method which can be overridden in the `User` model inside the application.\n  - Body:\n    - `name: string`\n    - `phoneNumber?: string`\n    - `pin?: string`\n    - `email?: string`\n    - `password?: string`\n    - `additionalData?: Record<string, unknown>` This is used to include any additional info in the sign-up process.\n  - Headers:\n    - `Accept-Language`\n    - `X-App-Version`\n    - `X-Device-Platform`\n  - Response:\n    - `user: User`\n    - `token: string`\n- signin:\n  - Body:\n    - `phoneNumber?: string`\n    - `pin?: string`\n    - `email?: string`\n    - `password?: string`\n  - Response:\n    - `user: User`\n    - `token: string`\n- validate-otp:\n  - Body:\n    - `phoneNumber: string`\n    - `code: string`\n- reset-pin:\n  - Body:\n    - `phoneNumber: string`\n    - `code: string`\n    - `pin: string`\n  - Headers:\n    - `Accept-Language`\n    - `X-App-Version`\n    - `X-Device-Platform`\n  - Response:\n    - `user: User`\n    - `token: string`\n- resend-otp: - Body: - `phoneNumber: string` - Headers: - `Accept-Language` - `X-App-Version` - `X-Device-Platform`\n  > Hint: In order to override the behaviour of one (or more) of the routes a controller with the same path as `authModulePath` can be used.  \n  > **IMPORTANT**: This module (that has the overridden routes) **BEFORE** the `AuthModule` in the `AppModule` imports\n","readmeFilename":"README.md"}