@os.io/nest-kit 0.0.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +111 -0
- package/dist/auth/auth.constants.d.ts +19 -0
- package/dist/auth/auth.constants.d.ts.map +1 -0
- package/dist/auth/auth.constants.js +19 -0
- package/dist/auth/auth.constants.js.map +1 -0
- package/dist/auth/auth.guard.d.ts +20 -0
- package/dist/auth/auth.guard.d.ts.map +1 -0
- package/dist/auth/auth.guard.js +84 -0
- package/dist/auth/auth.guard.js.map +1 -0
- package/dist/auth/auth.module.d.ts +26 -0
- package/dist/auth/auth.module.d.ts.map +1 -0
- package/dist/auth/auth.module.js +344 -0
- package/dist/auth/auth.module.js.map +1 -0
- package/dist/auth/auth.options.d.ts +179 -0
- package/dist/auth/auth.options.d.ts.map +1 -0
- package/dist/auth/auth.options.js +2 -0
- package/dist/auth/auth.options.js.map +1 -0
- package/dist/auth/auth.service.d.ts +57 -0
- package/dist/auth/auth.service.d.ts.map +1 -0
- package/dist/auth/auth.service.js +175 -0
- package/dist/auth/auth.service.js.map +1 -0
- package/dist/auth/authorization/index.d.ts +3 -0
- package/dist/auth/authorization/index.d.ts.map +1 -0
- package/dist/auth/authorization/index.js +3 -0
- package/dist/auth/authorization/index.js.map +1 -0
- package/dist/auth/authorization/pbac/index.d.ts +6 -0
- package/dist/auth/authorization/pbac/index.d.ts.map +1 -0
- package/dist/auth/authorization/pbac/index.js +4 -0
- package/dist/auth/authorization/pbac/index.js.map +1 -0
- package/dist/auth/authorization/pbac/pbac.decorator.d.ts +18 -0
- package/dist/auth/authorization/pbac/pbac.decorator.d.ts.map +1 -0
- package/dist/auth/authorization/pbac/pbac.decorator.js +14 -0
- package/dist/auth/authorization/pbac/pbac.decorator.js.map +1 -0
- package/dist/auth/authorization/pbac/pbac.guard.d.ts +19 -0
- package/dist/auth/authorization/pbac/pbac.guard.d.ts.map +1 -0
- package/dist/auth/authorization/pbac/pbac.guard.js +60 -0
- package/dist/auth/authorization/pbac/pbac.guard.js.map +1 -0
- package/dist/auth/authorization/pbac/pbac.service.d.ts +44 -0
- package/dist/auth/authorization/pbac/pbac.service.d.ts.map +1 -0
- package/dist/auth/authorization/pbac/pbac.service.js +146 -0
- package/dist/auth/authorization/pbac/pbac.service.js.map +1 -0
- package/dist/auth/authorization/pbac/pbac.types.d.ts +47 -0
- package/dist/auth/authorization/pbac/pbac.types.d.ts.map +1 -0
- package/dist/auth/authorization/pbac/pbac.types.js +2 -0
- package/dist/auth/authorization/pbac/pbac.types.js.map +1 -0
- package/dist/auth/authorization/rbac/index.d.ts +4 -0
- package/dist/auth/authorization/rbac/index.d.ts.map +1 -0
- package/dist/auth/authorization/rbac/index.js +4 -0
- package/dist/auth/authorization/rbac/index.js.map +1 -0
- package/dist/auth/authorization/rbac/rbac.decorator.d.ts +18 -0
- package/dist/auth/authorization/rbac/rbac.decorator.d.ts.map +1 -0
- package/dist/auth/authorization/rbac/rbac.decorator.js +25 -0
- package/dist/auth/authorization/rbac/rbac.decorator.js.map +1 -0
- package/dist/auth/authorization/rbac/rbac.guard.d.ts +19 -0
- package/dist/auth/authorization/rbac/rbac.guard.d.ts.map +1 -0
- package/dist/auth/authorization/rbac/rbac.guard.js +50 -0
- package/dist/auth/authorization/rbac/rbac.guard.js.map +1 -0
- package/dist/auth/authorization/rbac/rbac.service.d.ts +43 -0
- package/dist/auth/authorization/rbac/rbac.service.d.ts.map +1 -0
- package/dist/auth/authorization/rbac/rbac.service.js +95 -0
- package/dist/auth/authorization/rbac/rbac.service.js.map +1 -0
- package/dist/auth/decorators/current-user.decorator.d.ts +17 -0
- package/dist/auth/decorators/current-user.decorator.d.ts.map +1 -0
- package/dist/auth/decorators/current-user.decorator.js +23 -0
- package/dist/auth/decorators/current-user.decorator.js.map +1 -0
- package/dist/auth/decorators/index.d.ts +3 -0
- package/dist/auth/decorators/index.d.ts.map +1 -0
- package/dist/auth/decorators/index.js +3 -0
- package/dist/auth/decorators/index.js.map +1 -0
- package/dist/auth/decorators/public.decorator.d.ts +13 -0
- package/dist/auth/decorators/public.decorator.d.ts.map +1 -0
- package/dist/auth/decorators/public.decorator.js +15 -0
- package/dist/auth/decorators/public.decorator.js.map +1 -0
- package/dist/auth/index.d.ts +63 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +65 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/interfaces/auth-request.interface.d.ts +18 -0
- package/dist/auth/interfaces/auth-request.interface.d.ts.map +1 -0
- package/dist/auth/interfaces/auth-request.interface.js +2 -0
- package/dist/auth/interfaces/auth-request.interface.js.map +1 -0
- package/dist/auth/interfaces/auth-result.interface.d.ts +28 -0
- package/dist/auth/interfaces/auth-result.interface.d.ts.map +1 -0
- package/dist/auth/interfaces/auth-result.interface.js +2 -0
- package/dist/auth/interfaces/auth-result.interface.js.map +1 -0
- package/dist/auth/interfaces/auth-strategy.interface.d.ts +37 -0
- package/dist/auth/interfaces/auth-strategy.interface.d.ts.map +1 -0
- package/dist/auth/interfaces/auth-strategy.interface.js +16 -0
- package/dist/auth/interfaces/auth-strategy.interface.js.map +1 -0
- package/dist/auth/interfaces/auth-user.interface.d.ts +25 -0
- package/dist/auth/interfaces/auth-user.interface.d.ts.map +1 -0
- package/dist/auth/interfaces/auth-user.interface.js +2 -0
- package/dist/auth/interfaces/auth-user.interface.js.map +1 -0
- package/dist/auth/interfaces/cache-service.interface.d.ts +30 -0
- package/dist/auth/interfaces/cache-service.interface.d.ts.map +1 -0
- package/dist/auth/interfaces/cache-service.interface.js +2 -0
- package/dist/auth/interfaces/cache-service.interface.js.map +1 -0
- package/dist/auth/interfaces/index.d.ts +8 -0
- package/dist/auth/interfaces/index.d.ts.map +1 -0
- package/dist/auth/interfaces/index.js +2 -0
- package/dist/auth/interfaces/index.js.map +1 -0
- package/dist/auth/interfaces/user-service.interface.d.ts +34 -0
- package/dist/auth/interfaces/user-service.interface.d.ts.map +1 -0
- package/dist/auth/interfaces/user-service.interface.js +2 -0
- package/dist/auth/interfaces/user-service.interface.js.map +1 -0
- package/dist/auth/password/password.service.d.ts +23 -0
- package/dist/auth/password/password.service.d.ts.map +1 -0
- package/dist/auth/password/password.service.js +52 -0
- package/dist/auth/password/password.service.js.map +1 -0
- package/dist/auth/session/device-session.service.d.ts +43 -0
- package/dist/auth/session/device-session.service.d.ts.map +1 -0
- package/dist/auth/session/device-session.service.js +72 -0
- package/dist/auth/session/device-session.service.js.map +1 -0
- package/dist/auth/session/index.d.ts +5 -0
- package/dist/auth/session/index.d.ts.map +1 -0
- package/dist/auth/session/index.js +4 -0
- package/dist/auth/session/index.js.map +1 -0
- package/dist/auth/session/jwt.service.d.ts +37 -0
- package/dist/auth/session/jwt.service.d.ts.map +1 -0
- package/dist/auth/session/jwt.service.js +119 -0
- package/dist/auth/session/jwt.service.js.map +1 -0
- package/dist/auth/session/token-blacklist.service.d.ts +37 -0
- package/dist/auth/session/token-blacklist.service.d.ts.map +1 -0
- package/dist/auth/session/token-blacklist.service.js +70 -0
- package/dist/auth/session/token-blacklist.service.js.map +1 -0
- package/dist/auth/strategies/anonymous/anonymous.strategy.d.ts +19 -0
- package/dist/auth/strategies/anonymous/anonymous.strategy.d.ts.map +1 -0
- package/dist/auth/strategies/anonymous/anonymous.strategy.js +49 -0
- package/dist/auth/strategies/anonymous/anonymous.strategy.js.map +1 -0
- package/dist/auth/strategies/base/base.strategy.d.ts +11 -0
- package/dist/auth/strategies/base/base.strategy.d.ts.map +1 -0
- package/dist/auth/strategies/base/base.strategy.js +6 -0
- package/dist/auth/strategies/base/base.strategy.js.map +1 -0
- package/dist/auth/strategies/credentials/credentials.strategy.d.ts +21 -0
- package/dist/auth/strategies/credentials/credentials.strategy.d.ts.map +1 -0
- package/dist/auth/strategies/credentials/credentials.strategy.js +67 -0
- package/dist/auth/strategies/credentials/credentials.strategy.js.map +1 -0
- package/dist/auth/strategies/index.d.ts +12 -0
- package/dist/auth/strategies/index.d.ts.map +1 -0
- package/dist/auth/strategies/index.js +12 -0
- package/dist/auth/strategies/index.js.map +1 -0
- package/dist/auth/strategies/magic-link/magic-link.strategy.d.ts +31 -0
- package/dist/auth/strategies/magic-link/magic-link.strategy.d.ts.map +1 -0
- package/dist/auth/strategies/magic-link/magic-link.strategy.js +88 -0
- package/dist/auth/strategies/magic-link/magic-link.strategy.js.map +1 -0
- package/dist/auth/strategies/oauth/index.d.ts +3 -0
- package/dist/auth/strategies/oauth/index.d.ts.map +1 -0
- package/dist/auth/strategies/oauth/index.js +3 -0
- package/dist/auth/strategies/oauth/index.js.map +1 -0
- package/dist/auth/strategies/oauth/oauth-provider-registry.d.ts +13 -0
- package/dist/auth/strategies/oauth/oauth-provider-registry.d.ts.map +1 -0
- package/dist/auth/strategies/oauth/oauth-provider-registry.js +20 -0
- package/dist/auth/strategies/oauth/oauth-provider-registry.js.map +1 -0
- package/dist/auth/strategies/oauth/oauth.strategy.d.ts +23 -0
- package/dist/auth/strategies/oauth/oauth.strategy.d.ts.map +1 -0
- package/dist/auth/strategies/oauth/oauth.strategy.js +79 -0
- package/dist/auth/strategies/oauth/oauth.strategy.js.map +1 -0
- package/dist/auth/strategies/onetap/onetap.strategy.d.ts +24 -0
- package/dist/auth/strategies/onetap/onetap.strategy.d.ts.map +1 -0
- package/dist/auth/strategies/onetap/onetap.strategy.js +77 -0
- package/dist/auth/strategies/onetap/onetap.strategy.js.map +1 -0
- package/dist/auth/strategies/otp/otp.strategy.d.ts +31 -0
- package/dist/auth/strategies/otp/otp.strategy.d.ts.map +1 -0
- package/dist/auth/strategies/otp/otp.strategy.js +93 -0
- package/dist/auth/strategies/otp/otp.strategy.js.map +1 -0
- package/dist/auth/strategies/passkey/passkey.strategy.d.ts +32 -0
- package/dist/auth/strategies/passkey/passkey.strategy.d.ts.map +1 -0
- package/dist/auth/strategies/passkey/passkey.strategy.js +102 -0
- package/dist/auth/strategies/passkey/passkey.strategy.js.map +1 -0
- package/dist/auth/strategies/sso/sso.strategy.d.ts +25 -0
- package/dist/auth/strategies/sso/sso.strategy.d.ts.map +1 -0
- package/dist/auth/strategies/sso/sso.strategy.js +80 -0
- package/dist/auth/strategies/sso/sso.strategy.js.map +1 -0
- package/dist/auth/strategies/totp/totp.strategy.d.ts +37 -0
- package/dist/auth/strategies/totp/totp.strategy.d.ts.map +1 -0
- package/dist/auth/strategies/totp/totp.strategy.js +109 -0
- package/dist/auth/strategies/totp/totp.strategy.js.map +1 -0
- package/dist/auth/throttling/index.d.ts +2 -0
- package/dist/auth/throttling/index.d.ts.map +1 -0
- package/dist/auth/throttling/index.js +2 -0
- package/dist/auth/throttling/index.js.map +1 -0
- package/dist/auth/throttling/throttle.service.d.ts +27 -0
- package/dist/auth/throttling/throttle.service.d.ts.map +1 -0
- package/dist/auth/throttling/throttle.service.js +63 -0
- package/dist/auth/throttling/throttle.service.js.map +1 -0
- package/dist/bootstrap/cache/config.d.ts +135 -0
- package/dist/bootstrap/cache/config.d.ts.map +1 -0
- package/dist/bootstrap/cache/config.js +189 -0
- package/dist/bootstrap/cache/config.js.map +1 -0
- package/dist/bootstrap/cache/index.d.ts +11 -0
- package/dist/bootstrap/cache/index.d.ts.map +1 -0
- package/dist/bootstrap/cache/index.js +11 -0
- package/dist/bootstrap/cache/index.js.map +1 -0
- package/dist/bootstrap/index.d.ts +21 -0
- package/dist/bootstrap/index.d.ts.map +1 -0
- package/dist/bootstrap/index.js +21 -0
- package/dist/bootstrap/index.js.map +1 -0
- package/dist/bootstrap/scalar/api-docs.d.ts +39 -0
- package/dist/bootstrap/scalar/api-docs.d.ts.map +1 -0
- package/dist/bootstrap/scalar/api-docs.js +41 -0
- package/dist/bootstrap/scalar/api-docs.js.map +1 -0
- package/dist/bootstrap/scalar/index.d.ts +39 -0
- package/dist/bootstrap/scalar/index.d.ts.map +1 -0
- package/dist/bootstrap/scalar/index.js +41 -0
- package/dist/bootstrap/scalar/index.js.map +1 -0
- package/dist/bootstrap/swagger/api-docs.d.ts +73 -0
- package/dist/bootstrap/swagger/api-docs.d.ts.map +1 -0
- package/dist/bootstrap/swagger/api-docs.js +87 -0
- package/dist/bootstrap/swagger/api-docs.js.map +1 -0
- package/dist/bootstrap/swagger/index.d.ts +37 -0
- package/dist/bootstrap/swagger/index.d.ts.map +1 -0
- package/dist/bootstrap/swagger/index.js +36 -0
- package/dist/bootstrap/swagger/index.js.map +1 -0
- package/dist/bootstrap/typeorm/config/index.d.ts +12 -0
- package/dist/bootstrap/typeorm/config/index.d.ts.map +1 -0
- package/dist/bootstrap/typeorm/config/index.js +62 -0
- package/dist/bootstrap/typeorm/config/index.js.map +1 -0
- package/dist/bootstrap/typeorm/crud/controller.d.ts +13 -0
- package/dist/bootstrap/typeorm/crud/controller.d.ts.map +1 -0
- package/dist/bootstrap/typeorm/crud/controller.js +72 -0
- package/dist/bootstrap/typeorm/crud/controller.js.map +1 -0
- package/dist/bootstrap/typeorm/crud/index.d.ts +4 -0
- package/dist/bootstrap/typeorm/crud/index.d.ts.map +1 -0
- package/dist/bootstrap/typeorm/crud/index.js +3 -0
- package/dist/bootstrap/typeorm/crud/index.js.map +1 -0
- package/dist/bootstrap/typeorm/crud/service.d.ts +10 -0
- package/dist/bootstrap/typeorm/crud/service.d.ts.map +1 -0
- package/dist/bootstrap/typeorm/crud/service.js +21 -0
- package/dist/bootstrap/typeorm/crud/service.js.map +1 -0
- package/dist/bootstrap/typeorm/index.d.ts +18 -0
- package/dist/bootstrap/typeorm/index.d.ts.map +1 -0
- package/dist/bootstrap/typeorm/index.js +18 -0
- package/dist/bootstrap/typeorm/index.js.map +1 -0
- package/dist/bootstrap/typeorm/uow/factory.d.ts +5 -0
- package/dist/bootstrap/typeorm/uow/factory.d.ts.map +1 -0
- package/dist/bootstrap/typeorm/uow/factory.js +27 -0
- package/dist/bootstrap/typeorm/uow/factory.js.map +1 -0
- package/dist/bootstrap/typeorm/uow/index.d.ts +4 -0
- package/dist/bootstrap/typeorm/uow/index.d.ts.map +1 -0
- package/dist/bootstrap/typeorm/uow/index.js +4 -0
- package/dist/bootstrap/typeorm/uow/index.js.map +1 -0
- package/dist/bootstrap/typeorm/uow/transactional.decorator.d.ts +62 -0
- package/dist/bootstrap/typeorm/uow/transactional.decorator.d.ts.map +1 -0
- package/dist/bootstrap/typeorm/uow/transactional.decorator.js +114 -0
- package/dist/bootstrap/typeorm/uow/transactional.decorator.js.map +1 -0
- package/dist/bootstrap/typeorm/uow/unit-of-work.d.ts +11 -0
- package/dist/bootstrap/typeorm/uow/unit-of-work.d.ts.map +1 -0
- package/dist/bootstrap/typeorm/uow/unit-of-work.js +23 -0
- package/dist/bootstrap/typeorm/uow/unit-of-work.js.map +1 -0
- package/dist/core/index.d.ts +11 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +11 -0
- package/dist/core/index.js.map +1 -0
- package/dist/infra/audit-log/index.d.ts +12 -0
- package/dist/infra/audit-log/index.d.ts.map +1 -0
- package/dist/infra/audit-log/index.js +13 -0
- package/dist/infra/audit-log/index.js.map +1 -0
- package/dist/infra/index.d.ts +20 -0
- package/dist/infra/index.d.ts.map +1 -0
- package/dist/infra/index.js +21 -0
- package/dist/infra/index.js.map +1 -0
- package/dist/infra/logger/index.d.ts +12 -0
- package/dist/infra/logger/index.d.ts.map +1 -0
- package/dist/infra/logger/index.js +13 -0
- package/dist/infra/logger/index.js.map +1 -0
- package/dist/infra/metrics/index.d.ts +18 -0
- package/dist/infra/metrics/index.d.ts.map +1 -0
- package/dist/infra/metrics/index.js +19 -0
- package/dist/infra/metrics/index.js.map +1 -0
- package/dist/infra/notification/index.d.ts +12 -0
- package/dist/infra/notification/index.d.ts.map +1 -0
- package/dist/infra/notification/index.js +13 -0
- package/dist/infra/notification/index.js.map +1 -0
- package/dist/infra/storage/index.d.ts +12 -0
- package/dist/infra/storage/index.d.ts.map +1 -0
- package/dist/infra/storage/index.js +13 -0
- package/dist/infra/storage/index.js.map +1 -0
- package/dist/infra/stripe/index.d.ts +12 -0
- package/dist/infra/stripe/index.d.ts.map +1 -0
- package/dist/infra/stripe/index.js +13 -0
- package/dist/infra/stripe/index.js.map +1 -0
- package/dist/saas/index.d.ts +18 -0
- package/dist/saas/index.d.ts.map +1 -0
- package/dist/saas/index.js +19 -0
- package/dist/saas/index.js.map +1 -0
- package/package.json +165 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Wind Blade
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://nestjs.com/img/logo-small.svg" width="120" alt="NestJS Logo" />
|
|
3
|
+
<br/>
|
|
4
|
+
<strong>+</strong>
|
|
5
|
+
<br/>
|
|
6
|
+
<img src="https://raw.githubusercontent.com/oxpo-io/nest-kit/main/docs/public/nest-kit-logo.svg" width="240" alt="@oxpo/nest-kit" />
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<h1 align="center">@oxpo/nest-kit</h1>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<em>A modular, production-ready NestJS toolkit.</em>
|
|
13
|
+
<br />
|
|
14
|
+
<em>Bootstrap · Auth · SaaS · Infra</em>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
<a href="https://www.npmjs.com/package/@oxpo/nest-kit">
|
|
19
|
+
<img src="https://img.shields.io/npm/v/@oxpo/nest-kit?logo=npm" alt="npm version" />
|
|
20
|
+
</a>
|
|
21
|
+
<a href="https://github.com/oxpo-io/nest-kit/actions">
|
|
22
|
+
<img src="https://img.shields.io/github/actions/workflow/status/oxpo-io/nest-kit/ci.yml?branch=main&logo=github" alt="CI" />
|
|
23
|
+
</a>
|
|
24
|
+
<a href="https://github.com/oxpo-io/nest-kit/blob/main/LICENSE">
|
|
25
|
+
<img src="https://img.shields.io/github/license/oxpo-io/nest-kit" alt="License" />
|
|
26
|
+
</a>
|
|
27
|
+
<a href="https://nodejs.org/">
|
|
28
|
+
<img src="https://img.shields.io/node/v/@oxpo/nest-kit" alt="Node version" />
|
|
29
|
+
</a>
|
|
30
|
+
<a href="https://www.typescriptlang.org/">
|
|
31
|
+
<img src="https://img.shields.io/badge/TypeScript-5.7-blue?logo=typescript" alt="TypeScript" />
|
|
32
|
+
</a>
|
|
33
|
+
<a href="https://nestjs.com/">
|
|
34
|
+
<img src="https://img.shields.io/badge/NestJS-11-e0234e?logo=nestjs" alt="NestJS" />
|
|
35
|
+
</a>
|
|
36
|
+
</p>
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## ✨ Module Groups
|
|
41
|
+
|
|
42
|
+
| Import path | Directory | Description |
|
|
43
|
+
| ------------------------------ | -------------------- | -------------------------------------------- |
|
|
44
|
+
| `@oxpo/nest-kit` (or `./core`) | `packages/core` | Shared types, utilities, base classes |
|
|
45
|
+
| `@oxpo/nest-kit/bootstrap` | `packages/bootstrap` | One-liner setup for Swagger, Cache, TypeORM… |
|
|
46
|
+
| `@oxpo/nest-kit/auth` | `packages/auth` | RBAC, OAuth 2.0, SSO, JWT, API Keys |
|
|
47
|
+
| `@oxpo/nest-kit/saas` | `packages/saas` | Orgs, Teams, Multi-tenancy, Subscriptions |
|
|
48
|
+
| `@oxpo/nest-kit/infra` | `packages/infra` | Infrastructure integrations |
|
|
49
|
+
|
|
50
|
+
**Infra sub-modules** (import via sub-path):
|
|
51
|
+
|
|
52
|
+
| Import path | Purpose |
|
|
53
|
+
| ----------------------------------- | ----------------------------------------------- |
|
|
54
|
+
| `@oxpo/nest-kit/infra/logger` | Structured logging (Pino, Winston) |
|
|
55
|
+
| `@oxpo/nest-kit/infra/notification` | Email (SES, SendGrid), SMS (Twilio), Push (FCM) |
|
|
56
|
+
| `@oxpo/nest-kit/infra/storage` | Unified file API: LocalFS, S3, GCS, Azure |
|
|
57
|
+
| `@oxpo/nest-kit/infra/stripe` | Webhooks, subscriptions, checkout |
|
|
58
|
+
| `@oxpo/nest-kit/infra/audit-log` | Audit trails, data change capture |
|
|
59
|
+
| `@oxpo/nest-kit/infra/metrics` | Prometheus, OpenTelemetry, health checks |
|
|
60
|
+
|
|
61
|
+
## 📦 Installation
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npm install @oxpo/nest-kit
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Then import only what you need:
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import { setupSwagger } from '@oxpo/nest-kit/bootstrap';
|
|
71
|
+
import { RBACGuard } from '@oxpo/nest-kit/auth';
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
> **All modules are in early alpha.** APIs are subject to change.
|
|
75
|
+
|
|
76
|
+
## 🚀 Quick Start
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
// main.ts
|
|
80
|
+
import { NestFactory } from '@nestjs/core';
|
|
81
|
+
import { AppModule } from './app.module';
|
|
82
|
+
// import { setupSwagger } from '@oxpo/nest-kit/bootstrap';
|
|
83
|
+
|
|
84
|
+
async function bootstrap() {
|
|
85
|
+
const app = await NestFactory.create(AppModule);
|
|
86
|
+
// setupSwagger(app, { title: 'My API', version: '1.0.0' });
|
|
87
|
+
await app.listen(3000);
|
|
88
|
+
}
|
|
89
|
+
bootstrap();
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## 📖 Documentation
|
|
93
|
+
|
|
94
|
+
Full documentation is available at:
|
|
95
|
+
➡️ **https://oxpo-io.github.io/nest-kit** (coming soon)
|
|
96
|
+
|
|
97
|
+
Or browse the [docs](./docs) folder locally.
|
|
98
|
+
|
|
99
|
+
## 🤝 Contributing
|
|
100
|
+
|
|
101
|
+
We welcome contributions! Please read our [contributing guide](./CONTRIBUTING.md).
|
|
102
|
+
|
|
103
|
+
## 📄 License
|
|
104
|
+
|
|
105
|
+
This project is [MIT licensed](./LICENSE).
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
<p align="center">
|
|
110
|
+
Made with ❤️ by <a href="https://github.com/oxpo-io">Wind Blade</a>
|
|
111
|
+
</p>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const AUTH_MODULE_OPTIONS = "AUTH_MODULE_OPTIONS";
|
|
2
|
+
export declare const CACHE_SERVICE = "CACHE_SERVICE";
|
|
3
|
+
export declare const USER_SERVICE = "USER_SERVICE";
|
|
4
|
+
export declare const AUTH_STRATEGIES = "AUTH_STRATEGIES";
|
|
5
|
+
export declare const AUTH_METHODS_CONFIG = "AUTH_METHODS_CONFIG";
|
|
6
|
+
export declare const RBAC_OPTIONS = "RBAC_OPTIONS";
|
|
7
|
+
export declare const PBAC_OPTIONS = "PBAC_OPTIONS";
|
|
8
|
+
export declare const METADATA_PUBLIC = "auth:public";
|
|
9
|
+
export declare const METADATA_ROLES = "auth:roles";
|
|
10
|
+
export declare const METADATA_PERMISSIONS = "auth:permissions";
|
|
11
|
+
export declare const METADATA_POLICY = "auth:policy";
|
|
12
|
+
export declare const METADATA_AUTH_METHODS = "auth:methods";
|
|
13
|
+
export declare const TOKEN_BLACKLIST_PREFIX = "tok_blk:";
|
|
14
|
+
export declare const REFRESH_TOKEN_FAMILY_PREFIX = "rt_fam:";
|
|
15
|
+
export declare const DEVICE_SESSION_PREFIX = "dev_sess:";
|
|
16
|
+
export declare const OTP_PREFIX = "otp:";
|
|
17
|
+
export declare const MAGIC_LINK_PREFIX = "magic:";
|
|
18
|
+
export declare const LOGIN_ATTEMPT_PREFIX = "login_attempt:";
|
|
19
|
+
//# sourceMappingURL=auth.constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.constants.d.ts","sourceRoot":"","sources":["../../packages/auth/auth.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAEzD,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAE7C,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,eAAO,MAAM,eAAe,oBAAoB,CAAC;AAEjD,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAEzD,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAE7C,eAAO,MAAM,cAAc,eAAe,CAAC;AAE3C,eAAO,MAAM,oBAAoB,qBAAqB,CAAC;AAEvD,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAE7C,eAAO,MAAM,qBAAqB,iBAAiB,CAAC;AAEpD,eAAO,MAAM,sBAAsB,aAAa,CAAC;AAEjD,eAAO,MAAM,2BAA2B,YAAY,CAAC;AAErD,eAAO,MAAM,qBAAqB,cAAc,CAAC;AAEjD,eAAO,MAAM,UAAU,SAAS,CAAC;AAEjC,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAE1C,eAAO,MAAM,oBAAoB,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const AUTH_MODULE_OPTIONS = 'AUTH_MODULE_OPTIONS';
|
|
2
|
+
export const CACHE_SERVICE = 'CACHE_SERVICE';
|
|
3
|
+
export const USER_SERVICE = 'USER_SERVICE';
|
|
4
|
+
export const AUTH_STRATEGIES = 'AUTH_STRATEGIES';
|
|
5
|
+
export const AUTH_METHODS_CONFIG = 'AUTH_METHODS_CONFIG';
|
|
6
|
+
export const RBAC_OPTIONS = 'RBAC_OPTIONS';
|
|
7
|
+
export const PBAC_OPTIONS = 'PBAC_OPTIONS';
|
|
8
|
+
export const METADATA_PUBLIC = 'auth:public';
|
|
9
|
+
export const METADATA_ROLES = 'auth:roles';
|
|
10
|
+
export const METADATA_PERMISSIONS = 'auth:permissions';
|
|
11
|
+
export const METADATA_POLICY = 'auth:policy';
|
|
12
|
+
export const METADATA_AUTH_METHODS = 'auth:methods';
|
|
13
|
+
export const TOKEN_BLACKLIST_PREFIX = 'tok_blk:';
|
|
14
|
+
export const REFRESH_TOKEN_FAMILY_PREFIX = 'rt_fam:';
|
|
15
|
+
export const DEVICE_SESSION_PREFIX = 'dev_sess:';
|
|
16
|
+
export const OTP_PREFIX = 'otp:';
|
|
17
|
+
export const MAGIC_LINK_PREFIX = 'magic:';
|
|
18
|
+
export const LOGIN_ATTEMPT_PREFIX = 'login_attempt:';
|
|
19
|
+
//# sourceMappingURL=auth.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.constants.js","sourceRoot":"","sources":["../../packages/auth/auth.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AAEzD,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAC;AAE7C,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAE3C,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAEjD,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AAEzD,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAE3C,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAE3C,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC;AAE7C,MAAM,CAAC,MAAM,cAAc,GAAG,YAAY,CAAC;AAE3C,MAAM,CAAC,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAEvD,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC;AAE7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,cAAc,CAAC;AAEpD,MAAM,CAAC,MAAM,sBAAsB,GAAG,UAAU,CAAC;AAEjD,MAAM,CAAC,MAAM,2BAA2B,GAAG,SAAS,CAAC;AAErD,MAAM,CAAC,MAAM,qBAAqB,GAAG,WAAW,CAAC;AAEjD,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC;AAEjC,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC;AAE1C,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import { Reflector } from '@nestjs/core';
|
|
3
|
+
import { AuthService } from './auth.service';
|
|
4
|
+
/**
|
|
5
|
+
* Global authentication guard.
|
|
6
|
+
*
|
|
7
|
+
* Extracts the JWT from the `Authorization: Bearer <token>` header,
|
|
8
|
+
* validates it via `AuthService.validateToken()`, and attaches the
|
|
9
|
+
* decoded user to `request.user`.
|
|
10
|
+
*
|
|
11
|
+
* Skip authentication on routes or controllers decorated with `@Public()`.
|
|
12
|
+
*/
|
|
13
|
+
export declare class AuthGuard implements CanActivate {
|
|
14
|
+
private readonly reflector;
|
|
15
|
+
private readonly authService;
|
|
16
|
+
constructor(reflector: Reflector, authService: AuthService);
|
|
17
|
+
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
18
|
+
private extractToken;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=auth.guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.guard.d.ts","sourceRoot":"","sources":["../../packages/auth/auth.guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,WAAW,EAAE,gBAAgB,EAAyB,MAAM,gBAAgB,CAAC;AAClG,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C;;;;;;;;GAQG;AACH,qBACa,SAAU,YAAW,WAAW;IAEzC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,WAAW;gBADX,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW;IAGrC,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAwC9D,OAAO,CAAC,YAAY;CAqBrB"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
|
11
|
+
import { Reflector } from '@nestjs/core';
|
|
12
|
+
import { AuthService } from './auth.service';
|
|
13
|
+
import { METADATA_PUBLIC } from './auth.constants';
|
|
14
|
+
/**
|
|
15
|
+
* Global authentication guard.
|
|
16
|
+
*
|
|
17
|
+
* Extracts the JWT from the `Authorization: Bearer <token>` header,
|
|
18
|
+
* validates it via `AuthService.validateToken()`, and attaches the
|
|
19
|
+
* decoded user to `request.user`.
|
|
20
|
+
*
|
|
21
|
+
* Skip authentication on routes or controllers decorated with `@Public()`.
|
|
22
|
+
*/
|
|
23
|
+
let AuthGuard = class AuthGuard {
|
|
24
|
+
reflector;
|
|
25
|
+
authService;
|
|
26
|
+
constructor(reflector, authService) {
|
|
27
|
+
this.reflector = reflector;
|
|
28
|
+
this.authService = authService;
|
|
29
|
+
}
|
|
30
|
+
async canActivate(context) {
|
|
31
|
+
// Skip if marked as public
|
|
32
|
+
const isPublic = this.reflector.getAllAndOverride(METADATA_PUBLIC, [
|
|
33
|
+
context.getHandler(),
|
|
34
|
+
context.getClass(),
|
|
35
|
+
]);
|
|
36
|
+
if (isPublic)
|
|
37
|
+
return true;
|
|
38
|
+
const request = context.switchToHttp().getRequest();
|
|
39
|
+
const token = this.extractToken(request);
|
|
40
|
+
if (!token) {
|
|
41
|
+
throw new UnauthorizedException('Missing authentication token');
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
const payload = await this.authService.validateToken(token);
|
|
45
|
+
request.user = {
|
|
46
|
+
id: payload.sub,
|
|
47
|
+
email: payload.email,
|
|
48
|
+
username: payload.username,
|
|
49
|
+
roles: payload.roles ?? [],
|
|
50
|
+
permissions: payload.permissions ?? [],
|
|
51
|
+
isAnonymous: payload.isAnonymous ?? false,
|
|
52
|
+
isMfaVerified: payload.isMfaVerified ?? false,
|
|
53
|
+
};
|
|
54
|
+
request.accessToken = token;
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
throw new UnauthorizedException(error instanceof Error ? error.message : 'Invalid token');
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
extractToken(request) {
|
|
62
|
+
// Authorization header
|
|
63
|
+
const authHeader = request.headers?.authorization;
|
|
64
|
+
if (authHeader?.startsWith('Bearer ')) {
|
|
65
|
+
return authHeader.slice(7);
|
|
66
|
+
}
|
|
67
|
+
// Cookie fallback
|
|
68
|
+
const cookie = request.cookies?.['access_token'];
|
|
69
|
+
if (cookie)
|
|
70
|
+
return cookie;
|
|
71
|
+
// Query param fallback (for WebSocket / SSE)
|
|
72
|
+
const query = request.query?.['token'];
|
|
73
|
+
if (query)
|
|
74
|
+
return query;
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
AuthGuard = __decorate([
|
|
79
|
+
Injectable(),
|
|
80
|
+
__metadata("design:paramtypes", [Reflector,
|
|
81
|
+
AuthService])
|
|
82
|
+
], AuthGuard);
|
|
83
|
+
export { AuthGuard };
|
|
84
|
+
//# sourceMappingURL=auth.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.guard.js","sourceRoot":"","sources":["../../packages/auth/auth.guard.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAiC,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAClG,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;;;;;GAQG;AAEI,IAAM,SAAS,GAAf,MAAM,SAAS;IAED;IACA;IAFnB,YACmB,SAAoB,EACpB,WAAwB;QADxB,cAAS,GAAT,SAAS,CAAW;QACpB,gBAAW,GAAX,WAAW,CAAa;IACxC,CAAC;IAEJ,KAAK,CAAC,WAAW,CAAC,OAAyB;QACzC,2BAA2B;QAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAU,eAAe,EAAE;YAC1E,OAAO,CAAC,UAAU,EAAE;YACpB,OAAO,CAAC,QAAQ,EAAE;SACnB,CAAC,CAAC;QACH,IAAI,QAAQ;YAAE,OAAO,IAAI,CAAC;QAE1B,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAM7C,CAAC;QACL,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAEzC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,qBAAqB,CAAC,8BAA8B,CAAC,CAAC;QAClE,CAAC;QAED,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAC5D,OAAO,CAAC,IAAI,GAAG;gBACb,EAAE,EAAE,OAAO,CAAC,GAAa;gBACzB,KAAK,EAAE,OAAO,CAAC,KAA2B;gBAC1C,QAAQ,EAAE,OAAO,CAAC,QAA8B;gBAChD,KAAK,EAAG,OAAO,CAAC,KAAkB,IAAI,EAAE;gBACxC,WAAW,EAAG,OAAO,CAAC,WAAwB,IAAI,EAAE;gBACpD,WAAW,EAAG,OAAO,CAAC,WAAuB,IAAI,KAAK;gBACtD,aAAa,EAAG,OAAO,CAAC,aAAyB,IAAI,KAAK;aAC3D,CAAC;YACF,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC;QAC9B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,qBAAqB,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;QAC5F,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,YAAY,CAAC,OAIpB;QACC,uBAAuB;QACvB,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,EAAE,aAAa,CAAC;QAClD,IAAI,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YACtC,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC7B,CAAC;QAED,kBAAkB;QAClB,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,cAAc,CAAC,CAAC;QACjD,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC;QAE1B,6CAA6C;QAC7C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,CAAC;QACvC,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC;QAExB,OAAO,SAAS,CAAC;IACnB,CAAC;CACF,CAAA;AAnEY,SAAS;IADrB,UAAU,EAAE;qCAGmB,SAAS;QACP,WAAW;GAHhC,SAAS,CAmErB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type DynamicModule, type Provider } from '@nestjs/common';
|
|
2
|
+
import type { AuthModuleOptions, AuthModuleAsyncOptions } from './auth.options';
|
|
3
|
+
export declare class AuthModule {
|
|
4
|
+
/**
|
|
5
|
+
* Configure the auth module synchronously.
|
|
6
|
+
*/
|
|
7
|
+
static forRoot(options: AuthModuleOptions, extraProviders?: Provider[]): DynamicModule;
|
|
8
|
+
/**
|
|
9
|
+
* Configure the auth module asynchronously.
|
|
10
|
+
*/
|
|
11
|
+
static forRootAsync(options: AuthModuleAsyncOptions): DynamicModule;
|
|
12
|
+
private static buildModule;
|
|
13
|
+
private static createAsyncProviders;
|
|
14
|
+
/**
|
|
15
|
+
* Conditionally register strategy classes based on config.
|
|
16
|
+
* Only enabled strategies are registered as providers.
|
|
17
|
+
*/
|
|
18
|
+
private static createStrategyProviders;
|
|
19
|
+
private static createCoreProviders;
|
|
20
|
+
private static createAuthzProviders;
|
|
21
|
+
private static createEnabledStrategiesProvider;
|
|
22
|
+
private static getExports;
|
|
23
|
+
private static createDisabledStrategy;
|
|
24
|
+
private static nameFor;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=auth.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.module.d.ts","sourceRoot":"","sources":["../../packages/auth/auth.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,QAAQ,EAAkB,MAAM,gBAAgB,CAAC;AACnF,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AA6BhF,qBACa,UAAU;IACrB;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,iBAAiB,EAAE,cAAc,GAAE,QAAQ,EAAO,GAAG,aAAa;IAI1F;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,sBAAsB,GAAG,aAAa;IAuBnE,OAAO,CAAC,MAAM,CAAC,WAAW;IA4B1B,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAUnC;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAgKtC,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAYlC,OAAO,CAAC,MAAM,CAAC,oBAAoB;IA2BnC,OAAO,CAAC,MAAM,CAAC,+BAA+B;IAyC9C,OAAO,CAAC,MAAM,CAAC,UAAU;IA0BzB,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAMrC,OAAO,CAAC,MAAM,CAAC,OAAO;CAGvB"}
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var AuthModule_1;
|
|
8
|
+
import { Module, Logger } from '@nestjs/common';
|
|
9
|
+
import { AUTH_MODULE_OPTIONS, AUTH_STRATEGIES, CACHE_SERVICE, USER_SERVICE, } from './auth.constants';
|
|
10
|
+
import { AuthService } from './auth.service';
|
|
11
|
+
import { AuthGuard } from './auth.guard';
|
|
12
|
+
import { PasswordService } from './password/password.service';
|
|
13
|
+
import { JwtService } from './session/jwt.service';
|
|
14
|
+
import { TokenBlacklistService } from './session/token-blacklist.service';
|
|
15
|
+
import { DeviceSessionService } from './session/device-session.service';
|
|
16
|
+
import { ThrottleService } from './throttling/throttle.service';
|
|
17
|
+
import { CredentialsStrategy } from './strategies/credentials/credentials.strategy';
|
|
18
|
+
import { OAuthStrategy, OAuthProviderRegistry } from './strategies/oauth/index';
|
|
19
|
+
import { TotpStrategy } from './strategies/totp/totp.strategy';
|
|
20
|
+
import { AnonymousStrategy } from './strategies/anonymous/anonymous.strategy';
|
|
21
|
+
import { MagicLinkStrategy } from './strategies/magic-link/magic-link.strategy';
|
|
22
|
+
import { OtpStrategy } from './strategies/otp/otp.strategy';
|
|
23
|
+
import { PasskeyStrategy } from './strategies/passkey/passkey.strategy';
|
|
24
|
+
import { OneTapStrategy } from './strategies/onetap/onetap.strategy';
|
|
25
|
+
import { SsoStrategy } from './strategies/sso/sso.strategy';
|
|
26
|
+
import { RbacService, RbacGuard } from './authorization/rbac';
|
|
27
|
+
import { PbacService, PbacGuard } from './authorization/pbac';
|
|
28
|
+
const logger = new Logger('AuthModule');
|
|
29
|
+
let AuthModule = AuthModule_1 = class AuthModule {
|
|
30
|
+
/**
|
|
31
|
+
* Configure the auth module synchronously.
|
|
32
|
+
*/
|
|
33
|
+
static forRoot(options, extraProviders = []) {
|
|
34
|
+
return AuthModule_1.buildModule(options, extraProviders);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Configure the auth module asynchronously.
|
|
38
|
+
*/
|
|
39
|
+
static forRootAsync(options) {
|
|
40
|
+
const asyncProviders = AuthModule_1.createAsyncProviders(options);
|
|
41
|
+
const strategyProviders = AuthModule_1.createStrategyProviders(true);
|
|
42
|
+
const coreProviders = AuthModule_1.createCoreProviders();
|
|
43
|
+
const authzProviders = AuthModule_1.createAuthzProviders();
|
|
44
|
+
const enabledStrategiesProvider = AuthModule_1.createEnabledStrategiesProvider();
|
|
45
|
+
return {
|
|
46
|
+
module: AuthModule_1,
|
|
47
|
+
global: options.global ?? true,
|
|
48
|
+
imports: options.imports ?? [],
|
|
49
|
+
providers: [
|
|
50
|
+
...asyncProviders,
|
|
51
|
+
...strategyProviders,
|
|
52
|
+
...coreProviders,
|
|
53
|
+
...authzProviders,
|
|
54
|
+
enabledStrategiesProvider,
|
|
55
|
+
...(options.extraProviders ?? []),
|
|
56
|
+
],
|
|
57
|
+
exports: AuthModule_1.getExports(),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
static buildModule(options, extraProviders) {
|
|
61
|
+
const providers = [
|
|
62
|
+
{ provide: AUTH_MODULE_OPTIONS, useValue: options },
|
|
63
|
+
...AuthModule_1.createStrategyProviders(false),
|
|
64
|
+
...AuthModule_1.createCoreProviders(),
|
|
65
|
+
...AuthModule_1.createAuthzProviders(),
|
|
66
|
+
AuthModule_1.createEnabledStrategiesProvider(),
|
|
67
|
+
...extraProviders,
|
|
68
|
+
];
|
|
69
|
+
if (!options.cacheServiceToken) {
|
|
70
|
+
logger.warn('You must register a provider under the "CACHE_SERVICE" injection token. ' +
|
|
71
|
+
'See AuthModuleOptions.cacheServiceToken.');
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
module: AuthModule_1,
|
|
75
|
+
global: options.global ?? true,
|
|
76
|
+
providers,
|
|
77
|
+
exports: AuthModule_1.getExports(),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
static createAsyncProviders(options) {
|
|
81
|
+
return [
|
|
82
|
+
{
|
|
83
|
+
provide: AUTH_MODULE_OPTIONS,
|
|
84
|
+
useFactory: options.useFactory,
|
|
85
|
+
inject: options.inject ?? [],
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Conditionally register strategy classes based on config.
|
|
91
|
+
* Only enabled strategies are registered as providers.
|
|
92
|
+
*/
|
|
93
|
+
static createStrategyProviders(async) {
|
|
94
|
+
const providers = [];
|
|
95
|
+
// Credentials — enabled by default (unless explicitly false)
|
|
96
|
+
providers.push({
|
|
97
|
+
provide: CredentialsStrategy,
|
|
98
|
+
useFactory: (...args) => {
|
|
99
|
+
const options = args[0];
|
|
100
|
+
if (options.credentials === false) {
|
|
101
|
+
return AuthModule_1.createDisabledStrategy(AuthModule_1.nameFor('credentials'));
|
|
102
|
+
}
|
|
103
|
+
return new CredentialsStrategy(args[1], args[2], args[3]);
|
|
104
|
+
},
|
|
105
|
+
inject: async
|
|
106
|
+
? [AUTH_MODULE_OPTIONS, USER_SERVICE, PasswordService, JwtService]
|
|
107
|
+
: [AUTH_MODULE_OPTIONS, USER_SERVICE, PasswordService, JwtService],
|
|
108
|
+
});
|
|
109
|
+
// OAuth — enabled when config provided
|
|
110
|
+
providers.push({
|
|
111
|
+
provide: OAuthStrategy,
|
|
112
|
+
useFactory: (...args) => {
|
|
113
|
+
const options = args[0];
|
|
114
|
+
if (!options.oauth) {
|
|
115
|
+
return AuthModule_1.createDisabledStrategy(AuthModule_1.nameFor('oauth'));
|
|
116
|
+
}
|
|
117
|
+
const registry = new OAuthProviderRegistry();
|
|
118
|
+
const oauthOpts = options.oauth;
|
|
119
|
+
for (const [provider, cfg] of Object.entries(oauthOpts)) {
|
|
120
|
+
if (typeof cfg === 'object' && cfg !== null) {
|
|
121
|
+
registry.register(provider, cfg);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return new OAuthStrategy(args[1], args[2], registry);
|
|
125
|
+
},
|
|
126
|
+
inject: async
|
|
127
|
+
? [AUTH_MODULE_OPTIONS, USER_SERVICE, JwtService]
|
|
128
|
+
: [AUTH_MODULE_OPTIONS, USER_SERVICE, JwtService],
|
|
129
|
+
});
|
|
130
|
+
// TOTP — enabled when config provided
|
|
131
|
+
providers.push({
|
|
132
|
+
provide: TotpStrategy,
|
|
133
|
+
useFactory: (...args) => {
|
|
134
|
+
const options = args[0];
|
|
135
|
+
if (!options.totp) {
|
|
136
|
+
return AuthModule_1.createDisabledStrategy(AuthModule_1.nameFor('totp'));
|
|
137
|
+
}
|
|
138
|
+
return new TotpStrategy(args[1], args[2]);
|
|
139
|
+
},
|
|
140
|
+
inject: async
|
|
141
|
+
? [AUTH_MODULE_OPTIONS, USER_SERVICE, JwtService]
|
|
142
|
+
: [AUTH_MODULE_OPTIONS, USER_SERVICE, JwtService],
|
|
143
|
+
});
|
|
144
|
+
// Anonymous — enabled when config provided
|
|
145
|
+
providers.push({
|
|
146
|
+
provide: AnonymousStrategy,
|
|
147
|
+
useFactory: (...args) => {
|
|
148
|
+
const options = args[0];
|
|
149
|
+
if (!options.anonymous) {
|
|
150
|
+
return AuthModule_1.createDisabledStrategy(AuthModule_1.nameFor('anonymous'));
|
|
151
|
+
}
|
|
152
|
+
return new AnonymousStrategy(args[1]);
|
|
153
|
+
},
|
|
154
|
+
inject: async
|
|
155
|
+
? [AUTH_MODULE_OPTIONS, JwtService]
|
|
156
|
+
: [AUTH_MODULE_OPTIONS, JwtService],
|
|
157
|
+
});
|
|
158
|
+
// Magic Link — enabled when config provided
|
|
159
|
+
providers.push({
|
|
160
|
+
provide: MagicLinkStrategy,
|
|
161
|
+
useFactory: (...args) => {
|
|
162
|
+
const options = args[0];
|
|
163
|
+
if (!options.magicLink) {
|
|
164
|
+
return AuthModule_1.createDisabledStrategy(AuthModule_1.nameFor('magic-link'));
|
|
165
|
+
}
|
|
166
|
+
return new MagicLinkStrategy(args[1], args[2], args[3]);
|
|
167
|
+
},
|
|
168
|
+
inject: async
|
|
169
|
+
? [AUTH_MODULE_OPTIONS, CACHE_SERVICE, USER_SERVICE, JwtService]
|
|
170
|
+
: [AUTH_MODULE_OPTIONS, CACHE_SERVICE, USER_SERVICE, JwtService],
|
|
171
|
+
});
|
|
172
|
+
// OTP — enabled when config provided
|
|
173
|
+
providers.push({
|
|
174
|
+
provide: OtpStrategy,
|
|
175
|
+
useFactory: (...args) => {
|
|
176
|
+
const options = args[0];
|
|
177
|
+
if (!options.otp) {
|
|
178
|
+
return AuthModule_1.createDisabledStrategy(AuthModule_1.nameFor('otp'));
|
|
179
|
+
}
|
|
180
|
+
return new OtpStrategy(args[1], args[2], args[3]);
|
|
181
|
+
},
|
|
182
|
+
inject: async
|
|
183
|
+
? [AUTH_MODULE_OPTIONS, CACHE_SERVICE, USER_SERVICE, JwtService]
|
|
184
|
+
: [AUTH_MODULE_OPTIONS, CACHE_SERVICE, USER_SERVICE, JwtService],
|
|
185
|
+
});
|
|
186
|
+
// Passkey — enabled when config provided
|
|
187
|
+
providers.push({
|
|
188
|
+
provide: PasskeyStrategy,
|
|
189
|
+
useFactory: (...args) => {
|
|
190
|
+
const options = args[0];
|
|
191
|
+
if (!options.passkey) {
|
|
192
|
+
return AuthModule_1.createDisabledStrategy(AuthModule_1.nameFor('passkey'));
|
|
193
|
+
}
|
|
194
|
+
return new PasskeyStrategy(args[1], args[2]);
|
|
195
|
+
},
|
|
196
|
+
inject: async
|
|
197
|
+
? [AUTH_MODULE_OPTIONS, USER_SERVICE, JwtService]
|
|
198
|
+
: [AUTH_MODULE_OPTIONS, USER_SERVICE, JwtService],
|
|
199
|
+
});
|
|
200
|
+
// OneTap — enabled when config provided
|
|
201
|
+
providers.push({
|
|
202
|
+
provide: OneTapStrategy,
|
|
203
|
+
useFactory: (...args) => {
|
|
204
|
+
const options = args[0];
|
|
205
|
+
if (!options.onetap) {
|
|
206
|
+
return AuthModule_1.createDisabledStrategy(AuthModule_1.nameFor('onetap'));
|
|
207
|
+
}
|
|
208
|
+
return new OneTapStrategy(args[1], args[2]);
|
|
209
|
+
},
|
|
210
|
+
inject: async
|
|
211
|
+
? [AUTH_MODULE_OPTIONS, USER_SERVICE, JwtService]
|
|
212
|
+
: [AUTH_MODULE_OPTIONS, USER_SERVICE, JwtService],
|
|
213
|
+
});
|
|
214
|
+
// SSO — enabled when config provided
|
|
215
|
+
providers.push({
|
|
216
|
+
provide: SsoStrategy,
|
|
217
|
+
useFactory: (...args) => {
|
|
218
|
+
const options = args[0];
|
|
219
|
+
if (!options.sso) {
|
|
220
|
+
return AuthModule_1.createDisabledStrategy(AuthModule_1.nameFor('sso'));
|
|
221
|
+
}
|
|
222
|
+
return new SsoStrategy(args[1], args[2]);
|
|
223
|
+
},
|
|
224
|
+
inject: async
|
|
225
|
+
? [AUTH_MODULE_OPTIONS, USER_SERVICE, JwtService]
|
|
226
|
+
: [AUTH_MODULE_OPTIONS, USER_SERVICE, JwtService],
|
|
227
|
+
});
|
|
228
|
+
return providers;
|
|
229
|
+
}
|
|
230
|
+
static createCoreProviders() {
|
|
231
|
+
return [
|
|
232
|
+
AuthService,
|
|
233
|
+
AuthGuard,
|
|
234
|
+
PasswordService,
|
|
235
|
+
JwtService,
|
|
236
|
+
TokenBlacklistService,
|
|
237
|
+
DeviceSessionService,
|
|
238
|
+
ThrottleService,
|
|
239
|
+
];
|
|
240
|
+
}
|
|
241
|
+
static createAuthzProviders() {
|
|
242
|
+
return [
|
|
243
|
+
RbacGuard,
|
|
244
|
+
{
|
|
245
|
+
provide: RbacService,
|
|
246
|
+
useFactory: (cache) => {
|
|
247
|
+
return new RbacService(cache);
|
|
248
|
+
},
|
|
249
|
+
inject: [CACHE_SERVICE],
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
provide: PbacGuard,
|
|
253
|
+
useFactory: (reflector, pbacService) => {
|
|
254
|
+
return new PbacGuard(reflector, pbacService);
|
|
255
|
+
},
|
|
256
|
+
inject: ['Reflector', PbacService],
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
provide: PbacService,
|
|
260
|
+
useFactory: (cache) => {
|
|
261
|
+
return new PbacService(cache);
|
|
262
|
+
},
|
|
263
|
+
inject: [CACHE_SERVICE],
|
|
264
|
+
},
|
|
265
|
+
];
|
|
266
|
+
}
|
|
267
|
+
static createEnabledStrategiesProvider() {
|
|
268
|
+
return {
|
|
269
|
+
provide: AUTH_STRATEGIES,
|
|
270
|
+
useFactory: (credentials, oauth, totp, anonymous, magicLink, otp, passkey, onetap, sso) => {
|
|
271
|
+
const all = [
|
|
272
|
+
credentials,
|
|
273
|
+
oauth,
|
|
274
|
+
totp,
|
|
275
|
+
anonymous,
|
|
276
|
+
magicLink,
|
|
277
|
+
otp,
|
|
278
|
+
passkey,
|
|
279
|
+
onetap,
|
|
280
|
+
sso,
|
|
281
|
+
];
|
|
282
|
+
return all.filter((s) => !s._disabled);
|
|
283
|
+
},
|
|
284
|
+
inject: [
|
|
285
|
+
CredentialsStrategy,
|
|
286
|
+
OAuthStrategy,
|
|
287
|
+
TotpStrategy,
|
|
288
|
+
AnonymousStrategy,
|
|
289
|
+
MagicLinkStrategy,
|
|
290
|
+
OtpStrategy,
|
|
291
|
+
PasskeyStrategy,
|
|
292
|
+
OneTapStrategy,
|
|
293
|
+
SsoStrategy,
|
|
294
|
+
],
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
static getExports() {
|
|
298
|
+
return [
|
|
299
|
+
AuthService,
|
|
300
|
+
AuthGuard,
|
|
301
|
+
RbacService,
|
|
302
|
+
RbacGuard,
|
|
303
|
+
PbacService,
|
|
304
|
+
PbacGuard,
|
|
305
|
+
PasswordService,
|
|
306
|
+
JwtService,
|
|
307
|
+
TokenBlacklistService,
|
|
308
|
+
DeviceSessionService,
|
|
309
|
+
ThrottleService,
|
|
310
|
+
CredentialsStrategy,
|
|
311
|
+
OAuthStrategy,
|
|
312
|
+
OAuthProviderRegistry,
|
|
313
|
+
TotpStrategy,
|
|
314
|
+
AnonymousStrategy,
|
|
315
|
+
MagicLinkStrategy,
|
|
316
|
+
OtpStrategy,
|
|
317
|
+
PasskeyStrategy,
|
|
318
|
+
OneTapStrategy,
|
|
319
|
+
SsoStrategy,
|
|
320
|
+
];
|
|
321
|
+
}
|
|
322
|
+
static createDisabledStrategy(name) {
|
|
323
|
+
const s = new DisabledStrategy();
|
|
324
|
+
s._name = name;
|
|
325
|
+
return s;
|
|
326
|
+
}
|
|
327
|
+
static nameFor(method) {
|
|
328
|
+
return method;
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
AuthModule = AuthModule_1 = __decorate([
|
|
332
|
+
Module({})
|
|
333
|
+
], AuthModule);
|
|
334
|
+
export { AuthModule };
|
|
335
|
+
class DisabledStrategy {
|
|
336
|
+
_disabled = true;
|
|
337
|
+
_name = 'disabled';
|
|
338
|
+
type = '';
|
|
339
|
+
name = 'disabled';
|
|
340
|
+
authenticate() {
|
|
341
|
+
throw new Error(`Strategy "${this._name}" is not enabled`);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
//# sourceMappingURL=auth.module.js.map
|