najm-auth 1.1.7 → 1.1.8
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/dist/index.d.ts +15 -5
- package/dist/index.js +307 -234
- package/package.json +10 -14
package/dist/index.d.ts
CHANGED
|
@@ -807,13 +807,23 @@ declare class AuthController {
|
|
|
807
807
|
}
|
|
808
808
|
|
|
809
809
|
declare class AuthGuard {
|
|
810
|
-
|
|
811
|
-
private log;
|
|
812
|
-
canActivate(auth: string): Promise<GuardResult | false>;
|
|
810
|
+
canActivate(user: any): boolean;
|
|
813
811
|
}
|
|
814
812
|
declare const isAuth: () => ClassDecorator & MethodDecorator;
|
|
815
813
|
|
|
816
|
-
declare
|
|
814
|
+
declare class AuthResolver {
|
|
815
|
+
private container;
|
|
816
|
+
private app;
|
|
817
|
+
private log;
|
|
818
|
+
resolve(token: string): Promise<{
|
|
819
|
+
user: any;
|
|
820
|
+
role?: string;
|
|
821
|
+
permissions?: string[];
|
|
822
|
+
} | false>;
|
|
823
|
+
activate(): Promise<void>;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
declare const AUTH_MODULE: readonly [typeof AuthService, typeof CookieManager, typeof EncryptionService, typeof AuthGuard, typeof AuthController, typeof AuthResolver];
|
|
817
827
|
|
|
818
828
|
declare class PermissionRepository {
|
|
819
829
|
db: TDb;
|
|
@@ -1686,4 +1696,4 @@ declare const authSeed: (config: AuthSeedConfig) => Record<string, SeedEntry>;
|
|
|
1686
1696
|
*/
|
|
1687
1697
|
declare function seedAuthData(config: SeedAuthDataConfig): Promise<SeedAuthDataResult>;
|
|
1688
1698
|
|
|
1689
|
-
export { AUTH_CONFIG, en as AUTH_EN, AUTH_LOCALES, AUTH_MODULE, AUTH_PERMISSIONS, AUTH_ROLE, AUTH_SCHEMA, AUTH_SUPPORTED_LANGUAGES, AUTH_USER, type AssignPermissionDto, type AssignRoleDto, type AssignRoleParams, type AuthConfig, AuthController, AuthGuard, type AuthPluginConfig, AuthQueries, type AuthSchema, type AuthSeedConfig, AuthService, type AuthUser, Can, CanCreate, CanDelete, CanList, CanRead, CanUpdate, type ChainableGuard, type ChangePasswordDto, type CheckPermissionDto, type ConfiguredOwnership, type ConfirmResetPasswordDto, CookieManager, type CreatePermissionDto, type CreateRoleDto, type CreateTokenDto, type CreateUserDto, type EmailParam, EncryptionService, type JwtConfig, type JwtPayload, type LanguageParam, type LoginDto, NewPermission, NewRoleEntity, NewUser, Owned, type OwnedMethods, type OwnershipConfig, type OwnershipProvider, type OwnershipRule, OwnershipToken, type OwnershipTokenOptions, Permission, PermissionController, PermissionGuard, type PermissionIdParam, PermissionRepository, PermissionService, PermissionValidator, Policy, ROLES, ROLE_GROUPS, type RefreshTokenDto, type ResetPasswordDto, type ResourceAccessor, type ResourceGuards, type ResourceGuardsOptions, type RevokeTokenDto, Role, RoleController, RoleEntity, RoleGuard, type RoleIdParam, type RoleInput, RolePermission, RoleRepository, RoleService, type RoleType, RoleValidator, type SanitizedUser, ScopeContext, type ScopeResult, type SeedAuthDataConfig, type SeedAuthDataResult, type SeedUserConfig, TOKEN_STATUS, TOKEN_TYPE, type TokenIdParam, type TokenPair, TokenRepository, TokenService, USER_STATUS, type UpdatePermissionDto, type UpdateRoleDto, type UpdateTokenDto, type UpdateUserDto, User, UserController, type UserIdInParam, type UserIdParam, UserRepository, UserService, UserValidator, type UserWithPermissions, type VerifyTokenDto, assignPermissionDto, assignRoleDto, assignRoleParams, auth$1 as auth, authSeed, avatarsPath, calculateAge, calculateYearsOfExperience, changePasswordDto, checkPermissionDto, clean, configureOwnership, confirmResetPasswordDto, createPermissionDto, createRoleDto, createTokenDto, createUserDto, defineRoles, emailParam, formatDate, getAuthLocale, getAvatarFile, isAdmin, isAdministrator, isAuth, isEmpty, isFile, isPath, join, languageParam, loginDto, own, parseSchema, permissionIdParam, pickProps, refreshTokenDto, resetPasswordDto, revokeTokenDto, roleIdParam, seedAuthData, tokenIdParam, updatePermissionDto, updateRoleDto, updateTokenDto, updateUserDto, userIdInParam, userIdParam, verifyTokenDto, where };
|
|
1699
|
+
export { AUTH_CONFIG, en as AUTH_EN, AUTH_LOCALES, AUTH_MODULE, AUTH_PERMISSIONS, AUTH_ROLE, AUTH_SCHEMA, AUTH_SUPPORTED_LANGUAGES, AUTH_USER, type AssignPermissionDto, type AssignRoleDto, type AssignRoleParams, type AuthConfig, AuthController, AuthGuard, type AuthPluginConfig, AuthQueries, AuthResolver, type AuthSchema, type AuthSeedConfig, AuthService, type AuthUser, Can, CanCreate, CanDelete, CanList, CanRead, CanUpdate, type ChainableGuard, type ChangePasswordDto, type CheckPermissionDto, type ConfiguredOwnership, type ConfirmResetPasswordDto, CookieManager, type CreatePermissionDto, type CreateRoleDto, type CreateTokenDto, type CreateUserDto, type EmailParam, EncryptionService, type JwtConfig, type JwtPayload, type LanguageParam, type LoginDto, NewPermission, NewRoleEntity, NewUser, Owned, type OwnedMethods, type OwnershipConfig, type OwnershipProvider, type OwnershipRule, OwnershipToken, type OwnershipTokenOptions, Permission, PermissionController, PermissionGuard, type PermissionIdParam, PermissionRepository, PermissionService, PermissionValidator, Policy, ROLES, ROLE_GROUPS, type RefreshTokenDto, type ResetPasswordDto, type ResourceAccessor, type ResourceGuards, type ResourceGuardsOptions, type RevokeTokenDto, Role, RoleController, RoleEntity, RoleGuard, type RoleIdParam, type RoleInput, RolePermission, RoleRepository, RoleService, type RoleType, RoleValidator, type SanitizedUser, ScopeContext, type ScopeResult, type SeedAuthDataConfig, type SeedAuthDataResult, type SeedUserConfig, TOKEN_STATUS, TOKEN_TYPE, type TokenIdParam, type TokenPair, TokenRepository, TokenService, USER_STATUS, type UpdatePermissionDto, type UpdateRoleDto, type UpdateTokenDto, type UpdateUserDto, User, UserController, type UserIdInParam, type UserIdParam, UserRepository, UserService, UserValidator, type UserWithPermissions, type VerifyTokenDto, assignPermissionDto, assignRoleDto, assignRoleParams, auth$1 as auth, authSeed, avatarsPath, calculateAge, calculateYearsOfExperience, changePasswordDto, checkPermissionDto, clean, configureOwnership, confirmResetPasswordDto, createPermissionDto, createRoleDto, createTokenDto, createUserDto, defineRoles, emailParam, formatDate, getAuthLocale, getAvatarFile, isAdmin, isAdministrator, isAuth, isEmpty, isFile, isPath, join, languageParam, loginDto, own, parseSchema, permissionIdParam, pickProps, refreshTokenDto, resetPasswordDto, revokeTokenDto, roleIdParam, seedAuthData, tokenIdParam, updatePermissionDto, updateRoleDto, updateTokenDto, updateUserDto, userIdInParam, userIdParam, verifyTokenDto, where };
|
package/dist/index.js
CHANGED
|
@@ -194,6 +194,7 @@ __export(auth_exports, {
|
|
|
194
194
|
AUTH_MODULE: () => AUTH_MODULE,
|
|
195
195
|
AuthController: () => AuthController,
|
|
196
196
|
AuthGuard: () => AuthGuard,
|
|
197
|
+
AuthResolver: () => AuthResolver,
|
|
197
198
|
AuthService: () => AuthService,
|
|
198
199
|
CookieManager: () => CookieManager,
|
|
199
200
|
EncryptionService: () => EncryptionService,
|
|
@@ -285,7 +286,7 @@ CookieManager = __decorate2([
|
|
|
285
286
|
// src/auth/AuthController.ts
|
|
286
287
|
import { Controller } from "najm-core";
|
|
287
288
|
import { Get, Post, ResMsg } from "najm-core";
|
|
288
|
-
import { Body, User, Headers
|
|
289
|
+
import { Body, User as User2, Headers } from "najm-core";
|
|
289
290
|
|
|
290
291
|
// src/auth/AuthService.ts
|
|
291
292
|
import { Injectable as Injectable7, Inject as Inject7 } from "najm-core";
|
|
@@ -1586,9 +1587,7 @@ AuthService = AuthService_1 = __decorate11([
|
|
|
1586
1587
|
], AuthService);
|
|
1587
1588
|
|
|
1588
1589
|
// src/auth/AuthGuard.ts
|
|
1589
|
-
import { Service as Service2,
|
|
1590
|
-
import { Headers } from "najm-core";
|
|
1591
|
-
import { LOGGER } from "najm-core";
|
|
1590
|
+
import { Service as Service2, User } from "najm-core";
|
|
1592
1591
|
import { createGuard } from "najm-guard";
|
|
1593
1592
|
var __decorate12 = function(decorators, target, key, desc) {
|
|
1594
1593
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -1604,41 +1603,19 @@ var __param2 = function(paramIndex, decorator) {
|
|
|
1604
1603
|
decorator(target, key, paramIndex);
|
|
1605
1604
|
};
|
|
1606
1605
|
};
|
|
1607
|
-
var _a8;
|
|
1608
|
-
var _b6;
|
|
1609
1606
|
var AuthGuard = class AuthGuard2 {
|
|
1610
1607
|
static {
|
|
1611
1608
|
__name(this, "AuthGuard");
|
|
1612
1609
|
}
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
async canActivate(auth2) {
|
|
1616
|
-
if (!auth2)
|
|
1617
|
-
return false;
|
|
1618
|
-
try {
|
|
1619
|
-
const user = await this.tokenService.getUser(auth2);
|
|
1620
|
-
if (!user)
|
|
1621
|
-
return false;
|
|
1622
|
-
return { user };
|
|
1623
|
-
} catch (error) {
|
|
1624
|
-
this.log.warn("Auth guard token verification failed", error);
|
|
1625
|
-
return false;
|
|
1626
|
-
}
|
|
1610
|
+
canActivate(user) {
|
|
1611
|
+
return !!user;
|
|
1627
1612
|
}
|
|
1628
1613
|
};
|
|
1629
1614
|
__decorate12([
|
|
1630
|
-
|
|
1631
|
-
__metadata12("design:type", typeof (_a8 = typeof TokenService !== "undefined" && TokenService) === "function" ? _a8 : Object)
|
|
1632
|
-
], AuthGuard.prototype, "tokenService", void 0);
|
|
1633
|
-
__decorate12([
|
|
1634
|
-
Inject8(LOGGER),
|
|
1635
|
-
__metadata12("design:type", Object)
|
|
1636
|
-
], AuthGuard.prototype, "log", void 0);
|
|
1637
|
-
__decorate12([
|
|
1638
|
-
__param2(0, Headers("authorization")),
|
|
1615
|
+
__param2(0, User()),
|
|
1639
1616
|
__metadata12("design:type", Function),
|
|
1640
|
-
__metadata12("design:paramtypes", [
|
|
1641
|
-
__metadata12("design:returntype",
|
|
1617
|
+
__metadata12("design:paramtypes", [Object]),
|
|
1618
|
+
__metadata12("design:returntype", Boolean)
|
|
1642
1619
|
], AuthGuard.prototype, "canActivate", null);
|
|
1643
1620
|
AuthGuard = __decorate12([
|
|
1644
1621
|
Service2()
|
|
@@ -1712,7 +1689,7 @@ var __param3 = function(paramIndex, decorator) {
|
|
|
1712
1689
|
decorator(target, key, paramIndex);
|
|
1713
1690
|
};
|
|
1714
1691
|
};
|
|
1715
|
-
var
|
|
1692
|
+
var _a8;
|
|
1716
1693
|
var AuthController = class AuthController2 {
|
|
1717
1694
|
static {
|
|
1718
1695
|
__name(this, "AuthController");
|
|
@@ -1775,8 +1752,8 @@ __decorate13([
|
|
|
1775
1752
|
Get("/logout"),
|
|
1776
1753
|
isAuth(),
|
|
1777
1754
|
RateLimit({ limit: 10, window: "15m", key: "user" }),
|
|
1778
|
-
__param3(0,
|
|
1779
|
-
__param3(1,
|
|
1755
|
+
__param3(0, User2("id")),
|
|
1756
|
+
__param3(1, Headers("authorization")),
|
|
1780
1757
|
__metadata13("design:type", Function),
|
|
1781
1758
|
__metadata13("design:paramtypes", [String, String]),
|
|
1782
1759
|
__metadata13("design:returntype", Promise)
|
|
@@ -1786,7 +1763,7 @@ __decorate13([
|
|
|
1786
1763
|
isAuth(),
|
|
1787
1764
|
RateLimit({ limit: 30, window: "1m", key: "user" }),
|
|
1788
1765
|
ResMsg("auth.users.success.retrieved"),
|
|
1789
|
-
__param3(0,
|
|
1766
|
+
__param3(0, User2()),
|
|
1790
1767
|
__metadata13("design:type", Function),
|
|
1791
1768
|
__metadata13("design:paramtypes", [Object]),
|
|
1792
1769
|
__metadata13("design:returntype", Promise)
|
|
@@ -1813,16 +1790,111 @@ __decorate13([
|
|
|
1813
1790
|
], AuthController.prototype, "resetPassword", null);
|
|
1814
1791
|
AuthController = __decorate13([
|
|
1815
1792
|
Controller("/auth"),
|
|
1816
|
-
__metadata13("design:paramtypes", [typeof (
|
|
1793
|
+
__metadata13("design:paramtypes", [typeof (_a8 = typeof AuthService !== "undefined" && AuthService) === "function" ? _a8 : Object])
|
|
1817
1794
|
], AuthController);
|
|
1818
1795
|
|
|
1796
|
+
// src/auth/AuthResolver.ts
|
|
1797
|
+
import { APP, Container, DI, Inject as Inject8, LOGGER, Meta, Service as Service3 } from "najm-core";
|
|
1798
|
+
import { USER, ROLE, PERMISSIONS } from "najm-guard";
|
|
1799
|
+
var __decorate14 = function(decorators, target, key, desc) {
|
|
1800
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1801
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1802
|
+
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;
|
|
1803
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1804
|
+
};
|
|
1805
|
+
var __metadata14 = function(k, v) {
|
|
1806
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1807
|
+
};
|
|
1808
|
+
var _a9;
|
|
1809
|
+
var AuthResolver = class AuthResolver2 {
|
|
1810
|
+
static {
|
|
1811
|
+
__name(this, "AuthResolver");
|
|
1812
|
+
}
|
|
1813
|
+
container;
|
|
1814
|
+
app;
|
|
1815
|
+
log;
|
|
1816
|
+
async resolve(token) {
|
|
1817
|
+
if (!token)
|
|
1818
|
+
return false;
|
|
1819
|
+
try {
|
|
1820
|
+
const authHeader = token.startsWith("Bearer ") ? token : `Bearer ${token}`;
|
|
1821
|
+
const tokenService = await this.container.resolve(TokenService);
|
|
1822
|
+
const user = await tokenService.getUser(authHeader);
|
|
1823
|
+
if (!user)
|
|
1824
|
+
return false;
|
|
1825
|
+
return {
|
|
1826
|
+
user,
|
|
1827
|
+
role: user.role,
|
|
1828
|
+
permissions: user.permissions
|
|
1829
|
+
};
|
|
1830
|
+
} catch (error) {
|
|
1831
|
+
this.log.warn("Token verification failed", error);
|
|
1832
|
+
return false;
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
async activate() {
|
|
1836
|
+
this.app.use("*", async (c, next) => {
|
|
1837
|
+
const raw = c.req.header("authorization") ?? "";
|
|
1838
|
+
const token = raw.replace(/^Bearer\s+/i, "").trim();
|
|
1839
|
+
if (token) {
|
|
1840
|
+
const result = await this.resolve(token);
|
|
1841
|
+
if (result) {
|
|
1842
|
+
if (this.container.isActive()) {
|
|
1843
|
+
this.container.set(USER, result.user);
|
|
1844
|
+
if (result.role !== void 0)
|
|
1845
|
+
this.container.set(ROLE, result.role);
|
|
1846
|
+
if (result.permissions !== void 0)
|
|
1847
|
+
this.container.set(PERMISSIONS, result.permissions);
|
|
1848
|
+
} else {
|
|
1849
|
+
const als = this.container.store?.als;
|
|
1850
|
+
if (als && typeof als.getStore === "function") {
|
|
1851
|
+
const previousStore = als.getStore();
|
|
1852
|
+
const nextStore = new Map(previousStore);
|
|
1853
|
+
nextStore.set(USER.key, result.user);
|
|
1854
|
+
if (result.role !== void 0)
|
|
1855
|
+
nextStore.set(ROLE.key, result.role);
|
|
1856
|
+
if (result.permissions !== void 0)
|
|
1857
|
+
nextStore.set(PERMISSIONS.key, result.permissions);
|
|
1858
|
+
als.store = nextStore;
|
|
1859
|
+
try {
|
|
1860
|
+
await next();
|
|
1861
|
+
return;
|
|
1862
|
+
} finally {
|
|
1863
|
+
als.store = previousStore;
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
await next();
|
|
1870
|
+
});
|
|
1871
|
+
}
|
|
1872
|
+
};
|
|
1873
|
+
__decorate14([
|
|
1874
|
+
DI(),
|
|
1875
|
+
__metadata14("design:type", typeof (_a9 = typeof Container !== "undefined" && Container) === "function" ? _a9 : Object)
|
|
1876
|
+
], AuthResolver.prototype, "container", void 0);
|
|
1877
|
+
__decorate14([
|
|
1878
|
+
Inject8(APP),
|
|
1879
|
+
__metadata14("design:type", Object)
|
|
1880
|
+
], AuthResolver.prototype, "app", void 0);
|
|
1881
|
+
__decorate14([
|
|
1882
|
+
Inject8(LOGGER),
|
|
1883
|
+
__metadata14("design:type", Object)
|
|
1884
|
+
], AuthResolver.prototype, "log", void 0);
|
|
1885
|
+
AuthResolver = __decorate14([
|
|
1886
|
+
Service3(),
|
|
1887
|
+
Meta({ layer: "plugin", order: 30 })
|
|
1888
|
+
], AuthResolver);
|
|
1889
|
+
|
|
1819
1890
|
// src/auth/index.ts
|
|
1820
1891
|
var AUTH_MODULE = [
|
|
1821
1892
|
AuthService,
|
|
1822
1893
|
CookieManager,
|
|
1823
1894
|
EncryptionService,
|
|
1824
1895
|
AuthGuard,
|
|
1825
|
-
AuthController
|
|
1896
|
+
AuthController,
|
|
1897
|
+
AuthResolver
|
|
1826
1898
|
];
|
|
1827
1899
|
|
|
1828
1900
|
// src/users/index.ts
|
|
@@ -1874,16 +1946,16 @@ __export(roles_exports, {
|
|
|
1874
1946
|
import { composeGuards as composeGuards2, createGuard as createGuard3 } from "najm-guard";
|
|
1875
1947
|
|
|
1876
1948
|
// src/roles/RoleGuards.ts
|
|
1877
|
-
import { Service as
|
|
1878
|
-
import { GuardParams, User as
|
|
1949
|
+
import { Service as Service4 } from "najm-core";
|
|
1950
|
+
import { GuardParams, User as User3 } from "najm-core";
|
|
1879
1951
|
import { composeGuards, createGuard as createGuard2 } from "najm-guard";
|
|
1880
|
-
var
|
|
1952
|
+
var __decorate15 = function(decorators, target, key, desc) {
|
|
1881
1953
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1882
1954
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1883
1955
|
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;
|
|
1884
1956
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1885
1957
|
};
|
|
1886
|
-
var
|
|
1958
|
+
var __metadata15 = function(k, v) {
|
|
1887
1959
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1888
1960
|
};
|
|
1889
1961
|
var __param4 = function(paramIndex, decorator) {
|
|
@@ -1906,15 +1978,15 @@ var RoleGuard = class RoleGuard2 {
|
|
|
1906
1978
|
return false;
|
|
1907
1979
|
}
|
|
1908
1980
|
};
|
|
1909
|
-
|
|
1981
|
+
__decorate15([
|
|
1910
1982
|
__param4(0, GuardParams()),
|
|
1911
|
-
__param4(1,
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1983
|
+
__param4(1, User3("role")),
|
|
1984
|
+
__metadata15("design:type", Function),
|
|
1985
|
+
__metadata15("design:paramtypes", [Object, String]),
|
|
1986
|
+
__metadata15("design:returntype", void 0)
|
|
1915
1987
|
], RoleGuard.prototype, "canActivate", null);
|
|
1916
|
-
RoleGuard =
|
|
1917
|
-
|
|
1988
|
+
RoleGuard = __decorate15([
|
|
1989
|
+
Service4()
|
|
1918
1990
|
], RoleGuard);
|
|
1919
1991
|
var Role = createGuard2(RoleGuard);
|
|
1920
1992
|
var isAdmin = composeGuards(isAuth(), Role(ROLES.ADMIN));
|
|
@@ -1973,13 +2045,13 @@ var assignRoleDto = z2.object({
|
|
|
1973
2045
|
});
|
|
1974
2046
|
|
|
1975
2047
|
// src/roles/RoleController.ts
|
|
1976
|
-
var
|
|
2048
|
+
var __decorate16 = function(decorators, target, key, desc) {
|
|
1977
2049
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1978
2050
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1979
2051
|
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;
|
|
1980
2052
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1981
2053
|
};
|
|
1982
|
-
var
|
|
2054
|
+
var __metadata16 = function(k, v) {
|
|
1983
2055
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1984
2056
|
};
|
|
1985
2057
|
var __param5 = function(paramIndex, decorator) {
|
|
@@ -2012,35 +2084,35 @@ var RoleController = class RoleController2 {
|
|
|
2012
2084
|
return this.roleService.delete(params.id);
|
|
2013
2085
|
}
|
|
2014
2086
|
};
|
|
2015
|
-
|
|
2087
|
+
__decorate16([
|
|
2016
2088
|
Get2(),
|
|
2017
2089
|
isAdmin(),
|
|
2018
2090
|
ResMsg2("roles.success.retrieved"),
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2091
|
+
__metadata16("design:type", Function),
|
|
2092
|
+
__metadata16("design:paramtypes", []),
|
|
2093
|
+
__metadata16("design:returntype", Promise)
|
|
2022
2094
|
], RoleController.prototype, "getRoles", null);
|
|
2023
|
-
|
|
2095
|
+
__decorate16([
|
|
2024
2096
|
Get2("/:id"),
|
|
2025
2097
|
isAdmin(),
|
|
2026
2098
|
Validate2({ params: roleIdParam }),
|
|
2027
2099
|
ResMsg2("roles.success.retrieved"),
|
|
2028
2100
|
__param5(0, Params()),
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2101
|
+
__metadata16("design:type", Function),
|
|
2102
|
+
__metadata16("design:paramtypes", [Object]),
|
|
2103
|
+
__metadata16("design:returntype", Promise)
|
|
2032
2104
|
], RoleController.prototype, "getRole", null);
|
|
2033
|
-
|
|
2105
|
+
__decorate16([
|
|
2034
2106
|
Post2(),
|
|
2035
2107
|
isAdmin(),
|
|
2036
2108
|
Validate2(createRoleDto),
|
|
2037
2109
|
ResMsg2("roles.success.created"),
|
|
2038
2110
|
__param5(0, Body2()),
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2111
|
+
__metadata16("design:type", Function),
|
|
2112
|
+
__metadata16("design:paramtypes", [Object]),
|
|
2113
|
+
__metadata16("design:returntype", Promise)
|
|
2042
2114
|
], RoleController.prototype, "createRole", null);
|
|
2043
|
-
|
|
2115
|
+
__decorate16([
|
|
2044
2116
|
Put("/:id"),
|
|
2045
2117
|
isAdmin(),
|
|
2046
2118
|
Validate2({
|
|
@@ -2050,34 +2122,34 @@ __decorate15([
|
|
|
2050
2122
|
ResMsg2("roles.success.updated"),
|
|
2051
2123
|
__param5(0, Params()),
|
|
2052
2124
|
__param5(1, Body2()),
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2125
|
+
__metadata16("design:type", Function),
|
|
2126
|
+
__metadata16("design:paramtypes", [Object, Object]),
|
|
2127
|
+
__metadata16("design:returntype", Promise)
|
|
2056
2128
|
], RoleController.prototype, "updateRole", null);
|
|
2057
|
-
|
|
2129
|
+
__decorate16([
|
|
2058
2130
|
Delete("/:id"),
|
|
2059
2131
|
isAdmin(),
|
|
2060
2132
|
Validate2({ params: roleIdParam }),
|
|
2061
2133
|
ResMsg2("roles.success.deleted"),
|
|
2062
2134
|
__param5(0, Params()),
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2135
|
+
__metadata16("design:type", Function),
|
|
2136
|
+
__metadata16("design:paramtypes", [Object]),
|
|
2137
|
+
__metadata16("design:returntype", Promise)
|
|
2066
2138
|
], RoleController.prototype, "deleteRole", null);
|
|
2067
|
-
RoleController =
|
|
2139
|
+
RoleController = __decorate16([
|
|
2068
2140
|
Controller2("/roles"),
|
|
2069
|
-
|
|
2141
|
+
__metadata16("design:paramtypes", [typeof (_a10 = typeof RoleService !== "undefined" && RoleService) === "function" ? _a10 : Object])
|
|
2070
2142
|
], RoleController);
|
|
2071
2143
|
|
|
2072
2144
|
// src/users/UserController.ts
|
|
2073
2145
|
import { Validate as Validate3 } from "najm-validation";
|
|
2074
|
-
var
|
|
2146
|
+
var __decorate17 = function(decorators, target, key, desc) {
|
|
2075
2147
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2076
2148
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2077
2149
|
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;
|
|
2078
2150
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2079
2151
|
};
|
|
2080
|
-
var
|
|
2152
|
+
var __metadata17 = function(k, v) {
|
|
2081
2153
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2082
2154
|
};
|
|
2083
2155
|
var __param6 = function(paramIndex, decorator) {
|
|
@@ -2132,73 +2204,73 @@ var UserController = class UserController2 {
|
|
|
2132
2204
|
return this.userService.removeRole(params.userId);
|
|
2133
2205
|
}
|
|
2134
2206
|
};
|
|
2135
|
-
|
|
2207
|
+
__decorate17([
|
|
2136
2208
|
Get3(),
|
|
2137
2209
|
isAdmin(),
|
|
2138
2210
|
ResMsg3("users.success.retrieved"),
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2211
|
+
__metadata17("design:type", Function),
|
|
2212
|
+
__metadata17("design:paramtypes", []),
|
|
2213
|
+
__metadata17("design:returntype", Promise)
|
|
2142
2214
|
], UserController.prototype, "getUsers", null);
|
|
2143
|
-
|
|
2215
|
+
__decorate17([
|
|
2144
2216
|
Get3("/lang"),
|
|
2145
2217
|
isAuth(),
|
|
2146
2218
|
ResMsg3("users.success.retrieved"),
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2219
|
+
__metadata17("design:type", Function),
|
|
2220
|
+
__metadata17("design:paramtypes", []),
|
|
2221
|
+
__metadata17("design:returntype", Promise)
|
|
2150
2222
|
], UserController.prototype, "getLang", null);
|
|
2151
|
-
|
|
2223
|
+
__decorate17([
|
|
2152
2224
|
Post3("/lang/:language"),
|
|
2153
2225
|
isAuth(),
|
|
2154
2226
|
Validate3({ params: languageParam }),
|
|
2155
2227
|
ResMsg3("users.success.updated"),
|
|
2156
2228
|
__param6(0, Params2()),
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2229
|
+
__metadata17("design:type", Function),
|
|
2230
|
+
__metadata17("design:paramtypes", [Object]),
|
|
2231
|
+
__metadata17("design:returntype", Promise)
|
|
2160
2232
|
], UserController.prototype, "updateLang", null);
|
|
2161
|
-
|
|
2233
|
+
__decorate17([
|
|
2162
2234
|
Get3("/:id"),
|
|
2163
2235
|
isAdmin(),
|
|
2164
2236
|
Validate3({ params: userIdParam }),
|
|
2165
2237
|
ResMsg3("users.success.retrieved"),
|
|
2166
2238
|
__param6(0, Params2()),
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2239
|
+
__metadata17("design:type", Function),
|
|
2240
|
+
__metadata17("design:paramtypes", [Object]),
|
|
2241
|
+
__metadata17("design:returntype", Promise)
|
|
2170
2242
|
], UserController.prototype, "getUser", null);
|
|
2171
|
-
|
|
2243
|
+
__decorate17([
|
|
2172
2244
|
Get3("/email/:email"),
|
|
2173
2245
|
isAdmin(),
|
|
2174
2246
|
Validate3({ params: emailParam }),
|
|
2175
2247
|
ResMsg3("users.success.retrieved"),
|
|
2176
2248
|
__param6(0, Params2()),
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2249
|
+
__metadata17("design:type", Function),
|
|
2250
|
+
__metadata17("design:paramtypes", [Object]),
|
|
2251
|
+
__metadata17("design:returntype", Promise)
|
|
2180
2252
|
], UserController.prototype, "getByEmail", null);
|
|
2181
|
-
|
|
2253
|
+
__decorate17([
|
|
2182
2254
|
Get3("/role/:userId"),
|
|
2183
2255
|
isAdmin(),
|
|
2184
2256
|
Validate3({ params: userIdInParam }),
|
|
2185
2257
|
ResMsg3("users.success.retrieved"),
|
|
2186
2258
|
__param6(0, Params2()),
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2259
|
+
__metadata17("design:type", Function),
|
|
2260
|
+
__metadata17("design:paramtypes", [Object]),
|
|
2261
|
+
__metadata17("design:returntype", Promise)
|
|
2190
2262
|
], UserController.prototype, "getRole", null);
|
|
2191
|
-
|
|
2263
|
+
__decorate17([
|
|
2192
2264
|
Post3(),
|
|
2193
2265
|
isAdmin(),
|
|
2194
2266
|
Validate3(createUserDto),
|
|
2195
2267
|
ResMsg3("users.success.created"),
|
|
2196
2268
|
__param6(0, Body3()),
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2269
|
+
__metadata17("design:type", Function),
|
|
2270
|
+
__metadata17("design:paramtypes", [Object]),
|
|
2271
|
+
__metadata17("design:returntype", Promise)
|
|
2200
2272
|
], UserController.prototype, "create", null);
|
|
2201
|
-
|
|
2273
|
+
__decorate17([
|
|
2202
2274
|
Put2("/:id"),
|
|
2203
2275
|
isAdmin(),
|
|
2204
2276
|
Validate3({
|
|
@@ -2208,51 +2280,51 @@ __decorate16([
|
|
|
2208
2280
|
ResMsg3("users.success.updated"),
|
|
2209
2281
|
__param6(0, Params2()),
|
|
2210
2282
|
__param6(1, Body3()),
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2283
|
+
__metadata17("design:type", Function),
|
|
2284
|
+
__metadata17("design:paramtypes", [Object, Object]),
|
|
2285
|
+
__metadata17("design:returntype", Promise)
|
|
2214
2286
|
], UserController.prototype, "update", null);
|
|
2215
|
-
|
|
2287
|
+
__decorate17([
|
|
2216
2288
|
Delete2("/:id"),
|
|
2217
2289
|
isAdmin(),
|
|
2218
2290
|
Validate3({ params: userIdParam }),
|
|
2219
2291
|
ResMsg3("users.success.deleted"),
|
|
2220
2292
|
__param6(0, Params2()),
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2293
|
+
__metadata17("design:type", Function),
|
|
2294
|
+
__metadata17("design:paramtypes", [Object]),
|
|
2295
|
+
__metadata17("design:returntype", Promise)
|
|
2224
2296
|
], UserController.prototype, "delete", null);
|
|
2225
|
-
|
|
2297
|
+
__decorate17([
|
|
2226
2298
|
Delete2(),
|
|
2227
2299
|
isAdmin(),
|
|
2228
2300
|
ResMsg3("users.success.allDeleted"),
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2301
|
+
__metadata17("design:type", Function),
|
|
2302
|
+
__metadata17("design:paramtypes", []),
|
|
2303
|
+
__metadata17("design:returntype", Promise)
|
|
2232
2304
|
], UserController.prototype, "deleteAll", null);
|
|
2233
|
-
|
|
2305
|
+
__decorate17([
|
|
2234
2306
|
Post3("/assign/:userId/:roleId"),
|
|
2235
2307
|
isAdmin(),
|
|
2236
2308
|
Validate3({ params: assignRoleParams }),
|
|
2237
2309
|
ResMsg3("users.success.updated"),
|
|
2238
2310
|
__param6(0, Params2()),
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2311
|
+
__metadata17("design:type", Function),
|
|
2312
|
+
__metadata17("design:paramtypes", [Object]),
|
|
2313
|
+
__metadata17("design:returntype", Promise)
|
|
2242
2314
|
], UserController.prototype, "assignRole", null);
|
|
2243
|
-
|
|
2315
|
+
__decorate17([
|
|
2244
2316
|
Delete2("/remove/:userId"),
|
|
2245
2317
|
isAdmin(),
|
|
2246
2318
|
Validate3({ params: userIdInParam }),
|
|
2247
2319
|
ResMsg3("users.success.updated"),
|
|
2248
2320
|
__param6(0, Params2()),
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2321
|
+
__metadata17("design:type", Function),
|
|
2322
|
+
__metadata17("design:paramtypes", [Object]),
|
|
2323
|
+
__metadata17("design:returntype", Promise)
|
|
2252
2324
|
], UserController.prototype, "removeRole", null);
|
|
2253
|
-
UserController =
|
|
2325
|
+
UserController = __decorate17([
|
|
2254
2326
|
Controller3("/users"),
|
|
2255
|
-
|
|
2327
|
+
__metadata17("design:paramtypes", [typeof (_a11 = typeof UserService !== "undefined" && UserService) === "function" ? _a11 : Object])
|
|
2256
2328
|
], UserController);
|
|
2257
2329
|
|
|
2258
2330
|
// src/permissions/index.ts
|
|
@@ -2275,13 +2347,13 @@ __export(permissions_exports, {
|
|
|
2275
2347
|
import { eq as eq5, and } from "drizzle-orm";
|
|
2276
2348
|
import { Repository as Repository4, Inject as Inject9 } from "najm-core";
|
|
2277
2349
|
import { DB as DB4 } from "najm-database";
|
|
2278
|
-
var
|
|
2350
|
+
var __decorate18 = function(decorators, target, key, desc) {
|
|
2279
2351
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2280
2352
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2281
2353
|
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;
|
|
2282
2354
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2283
2355
|
};
|
|
2284
|
-
var
|
|
2356
|
+
var __metadata18 = function(k, v) {
|
|
2285
2357
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2286
2358
|
};
|
|
2287
2359
|
var PermissionRepository = class PermissionRepository2 {
|
|
@@ -2359,29 +2431,29 @@ var PermissionRepository = class PermissionRepository2 {
|
|
|
2359
2431
|
return deletedPermissions;
|
|
2360
2432
|
}
|
|
2361
2433
|
};
|
|
2362
|
-
|
|
2434
|
+
__decorate18([
|
|
2363
2435
|
DB4(),
|
|
2364
|
-
|
|
2436
|
+
__metadata18("design:type", Object)
|
|
2365
2437
|
], PermissionRepository.prototype, "db", void 0);
|
|
2366
|
-
|
|
2438
|
+
__decorate18([
|
|
2367
2439
|
Inject9(AUTH_SCHEMA),
|
|
2368
|
-
|
|
2440
|
+
__metadata18("design:type", Object)
|
|
2369
2441
|
], PermissionRepository.prototype, "schema", void 0);
|
|
2370
|
-
PermissionRepository =
|
|
2442
|
+
PermissionRepository = __decorate18([
|
|
2371
2443
|
Repository4()
|
|
2372
2444
|
], PermissionRepository);
|
|
2373
2445
|
|
|
2374
2446
|
// src/permissions/PermissionGuards.ts
|
|
2375
2447
|
import { Injectable as Injectable8 } from "najm-core";
|
|
2376
|
-
import { GuardParams as GuardParams2, User as
|
|
2448
|
+
import { GuardParams as GuardParams2, User as User4 } from "najm-core";
|
|
2377
2449
|
import { createGuard as createGuard4, composeGuards as composeGuards3 } from "najm-guard";
|
|
2378
|
-
var
|
|
2450
|
+
var __decorate19 = function(decorators, target, key, desc) {
|
|
2379
2451
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2380
2452
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2381
2453
|
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;
|
|
2382
2454
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2383
2455
|
};
|
|
2384
|
-
var
|
|
2456
|
+
var __metadata19 = function(k, v) {
|
|
2385
2457
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2386
2458
|
};
|
|
2387
2459
|
var __param7 = function(paramIndex, decorator) {
|
|
@@ -2417,14 +2489,14 @@ var PermissionGuard = class PermissionGuard2 {
|
|
|
2417
2489
|
return false;
|
|
2418
2490
|
}
|
|
2419
2491
|
};
|
|
2420
|
-
|
|
2492
|
+
__decorate19([
|
|
2421
2493
|
__param7(0, GuardParams2()),
|
|
2422
|
-
__param7(1,
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2494
|
+
__param7(1, User4("permissions")),
|
|
2495
|
+
__metadata19("design:type", Function),
|
|
2496
|
+
__metadata19("design:paramtypes", [String, Array]),
|
|
2497
|
+
__metadata19("design:returntype", Object)
|
|
2426
2498
|
], PermissionGuard.prototype, "canActivate", null);
|
|
2427
|
-
PermissionGuard =
|
|
2499
|
+
PermissionGuard = __decorate19([
|
|
2428
2500
|
Injectable8()
|
|
2429
2501
|
], PermissionGuard);
|
|
2430
2502
|
var Permission = createGuard4(PermissionGuard);
|
|
@@ -2442,17 +2514,17 @@ import { Injectable as Injectable10 } from "najm-core";
|
|
|
2442
2514
|
import { Injectable as Injectable9 } from "najm-core";
|
|
2443
2515
|
import { I18n as I18n5 } from "najm-i18n";
|
|
2444
2516
|
import { Err as Err7 } from "najm-core";
|
|
2445
|
-
var
|
|
2517
|
+
var __decorate20 = function(decorators, target, key, desc) {
|
|
2446
2518
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2447
2519
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2448
2520
|
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;
|
|
2449
2521
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2450
2522
|
};
|
|
2451
|
-
var
|
|
2523
|
+
var __metadata20 = function(k, v) {
|
|
2452
2524
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2453
2525
|
};
|
|
2454
2526
|
var _a12;
|
|
2455
|
-
var
|
|
2527
|
+
var _b6;
|
|
2456
2528
|
var PermissionValidator = class PermissionValidator2 {
|
|
2457
2529
|
static {
|
|
2458
2530
|
__name(this, "PermissionValidator");
|
|
@@ -2519,27 +2591,27 @@ var PermissionValidator = class PermissionValidator2 {
|
|
|
2519
2591
|
}
|
|
2520
2592
|
}
|
|
2521
2593
|
};
|
|
2522
|
-
|
|
2594
|
+
__decorate20([
|
|
2523
2595
|
I18n5("permissions"),
|
|
2524
|
-
|
|
2596
|
+
__metadata20("design:type", Object)
|
|
2525
2597
|
], PermissionValidator.prototype, "t", void 0);
|
|
2526
|
-
PermissionValidator =
|
|
2598
|
+
PermissionValidator = __decorate20([
|
|
2527
2599
|
Injectable9(),
|
|
2528
|
-
|
|
2600
|
+
__metadata20("design:paramtypes", [typeof (_a12 = typeof PermissionRepository !== "undefined" && PermissionRepository) === "function" ? _a12 : Object, typeof (_b6 = typeof RoleValidator !== "undefined" && RoleValidator) === "function" ? _b6 : Object])
|
|
2529
2601
|
], PermissionValidator);
|
|
2530
2602
|
|
|
2531
2603
|
// src/permissions/PermissionService.ts
|
|
2532
|
-
var
|
|
2604
|
+
var __decorate21 = function(decorators, target, key, desc) {
|
|
2533
2605
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2534
2606
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2535
2607
|
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;
|
|
2536
2608
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2537
2609
|
};
|
|
2538
|
-
var
|
|
2610
|
+
var __metadata21 = function(k, v) {
|
|
2539
2611
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2540
2612
|
};
|
|
2541
2613
|
var _a13;
|
|
2542
|
-
var
|
|
2614
|
+
var _b7;
|
|
2543
2615
|
var _c4;
|
|
2544
2616
|
var PermissionService = class PermissionService2 {
|
|
2545
2617
|
static {
|
|
@@ -2645,9 +2717,9 @@ var PermissionService = class PermissionService2 {
|
|
|
2645
2717
|
return await this.permissionRepository.deleteAll();
|
|
2646
2718
|
}
|
|
2647
2719
|
};
|
|
2648
|
-
PermissionService =
|
|
2720
|
+
PermissionService = __decorate21([
|
|
2649
2721
|
Injectable10(),
|
|
2650
|
-
|
|
2722
|
+
__metadata21("design:paramtypes", [typeof (_a13 = typeof PermissionRepository !== "undefined" && PermissionRepository) === "function" ? _a13 : Object, typeof (_b7 = typeof PermissionValidator !== "undefined" && PermissionValidator) === "function" ? _b7 : Object, typeof (_c4 = typeof RoleService !== "undefined" && RoleService) === "function" ? _c4 : Object])
|
|
2651
2723
|
], PermissionService);
|
|
2652
2724
|
|
|
2653
2725
|
// src/permissions/PermissionController.ts
|
|
@@ -2680,13 +2752,13 @@ var checkPermissionDto = z3.object({
|
|
|
2680
2752
|
});
|
|
2681
2753
|
|
|
2682
2754
|
// src/permissions/PermissionController.ts
|
|
2683
|
-
var
|
|
2755
|
+
var __decorate22 = function(decorators, target, key, desc) {
|
|
2684
2756
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2685
2757
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2686
2758
|
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;
|
|
2687
2759
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2688
2760
|
};
|
|
2689
|
-
var
|
|
2761
|
+
var __metadata22 = function(k, v) {
|
|
2690
2762
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2691
2763
|
};
|
|
2692
2764
|
var __param8 = function(paramIndex, decorator) {
|
|
@@ -2740,32 +2812,32 @@ var PermissionController = class PermissionController2 {
|
|
|
2740
2812
|
return this.permissionService.deleteAll();
|
|
2741
2813
|
}
|
|
2742
2814
|
};
|
|
2743
|
-
|
|
2815
|
+
__decorate22([
|
|
2744
2816
|
Get4(),
|
|
2745
2817
|
ResMsg4("permissions.success.retrieved"),
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2818
|
+
__metadata22("design:type", Function),
|
|
2819
|
+
__metadata22("design:paramtypes", []),
|
|
2820
|
+
__metadata22("design:returntype", Promise)
|
|
2749
2821
|
], PermissionController.prototype, "getPermissions", null);
|
|
2750
|
-
|
|
2822
|
+
__decorate22([
|
|
2751
2823
|
Get4("/:id"),
|
|
2752
2824
|
Validate4({ params: permissionIdParam }),
|
|
2753
2825
|
ResMsg4("permissions.success.retrieved"),
|
|
2754
2826
|
__param8(0, Params3()),
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2827
|
+
__metadata22("design:type", Function),
|
|
2828
|
+
__metadata22("design:paramtypes", [Object]),
|
|
2829
|
+
__metadata22("design:returntype", Promise)
|
|
2758
2830
|
], PermissionController.prototype, "getPermission", null);
|
|
2759
|
-
|
|
2831
|
+
__decorate22([
|
|
2760
2832
|
Post4(),
|
|
2761
2833
|
Validate4(createPermissionDto),
|
|
2762
2834
|
ResMsg4({ message: "Permission created successfully", status: 201 }),
|
|
2763
2835
|
__param8(0, Body4()),
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2836
|
+
__metadata22("design:type", Function),
|
|
2837
|
+
__metadata22("design:paramtypes", [Object]),
|
|
2838
|
+
__metadata22("design:returntype", Promise)
|
|
2767
2839
|
], PermissionController.prototype, "create", null);
|
|
2768
|
-
|
|
2840
|
+
__decorate22([
|
|
2769
2841
|
Put3("/:id"),
|
|
2770
2842
|
Validate4({
|
|
2771
2843
|
params: permissionIdParam,
|
|
@@ -2774,67 +2846,67 @@ __decorate21([
|
|
|
2774
2846
|
ResMsg4("permissions.success.updated"),
|
|
2775
2847
|
__param8(0, Params3()),
|
|
2776
2848
|
__param8(1, Body4()),
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2849
|
+
__metadata22("design:type", Function),
|
|
2850
|
+
__metadata22("design:paramtypes", [Object, Object]),
|
|
2851
|
+
__metadata22("design:returntype", Promise)
|
|
2780
2852
|
], PermissionController.prototype, "update", null);
|
|
2781
|
-
|
|
2853
|
+
__decorate22([
|
|
2782
2854
|
Delete3("/:id"),
|
|
2783
2855
|
Validate4({ params: permissionIdParam }),
|
|
2784
2856
|
ResMsg4("permissions.success.deleted"),
|
|
2785
2857
|
__param8(0, Params3()),
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2858
|
+
__metadata22("design:type", Function),
|
|
2859
|
+
__metadata22("design:paramtypes", [Object]),
|
|
2860
|
+
__metadata22("design:returntype", Promise)
|
|
2789
2861
|
], PermissionController.prototype, "delete", null);
|
|
2790
|
-
|
|
2862
|
+
__decorate22([
|
|
2791
2863
|
Get4("/role/:id"),
|
|
2792
2864
|
Validate4({ params: roleIdParam }),
|
|
2793
2865
|
ResMsg4("permissions.success.retrieved"),
|
|
2794
2866
|
__param8(0, Params3()),
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2867
|
+
__metadata22("design:type", Function),
|
|
2868
|
+
__metadata22("design:paramtypes", [Object]),
|
|
2869
|
+
__metadata22("design:returntype", Promise)
|
|
2798
2870
|
], PermissionController.prototype, "getByRole", null);
|
|
2799
|
-
|
|
2871
|
+
__decorate22([
|
|
2800
2872
|
Get4("/roles/:id"),
|
|
2801
2873
|
Validate4({ params: permissionIdParam }),
|
|
2802
2874
|
ResMsg4("permissions.success.retrieved"),
|
|
2803
2875
|
__param8(0, Params3()),
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2876
|
+
__metadata22("design:type", Function),
|
|
2877
|
+
__metadata22("design:paramtypes", [Object]),
|
|
2878
|
+
__metadata22("design:returntype", Promise)
|
|
2807
2879
|
], PermissionController.prototype, "getRolesByPermission", null);
|
|
2808
|
-
|
|
2880
|
+
__decorate22([
|
|
2809
2881
|
Post4("/assign/:roleId/:permissionId"),
|
|
2810
2882
|
Validate4({ params: assignPermissionDto }),
|
|
2811
2883
|
ResMsg4("permissions.success.assigned"),
|
|
2812
2884
|
__param8(0, Params3()),
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2885
|
+
__metadata22("design:type", Function),
|
|
2886
|
+
__metadata22("design:paramtypes", [Object]),
|
|
2887
|
+
__metadata22("design:returntype", Promise)
|
|
2816
2888
|
], PermissionController.prototype, "assignToRole", null);
|
|
2817
|
-
|
|
2889
|
+
__decorate22([
|
|
2818
2890
|
Delete3("/remove/:roleId/:permissionId"),
|
|
2819
2891
|
Validate4({ params: assignPermissionDto }),
|
|
2820
2892
|
ResMsg4("permissions.success.removed"),
|
|
2821
2893
|
__param8(0, Params3()),
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2894
|
+
__metadata22("design:type", Function),
|
|
2895
|
+
__metadata22("design:paramtypes", [Object]),
|
|
2896
|
+
__metadata22("design:returntype", Promise)
|
|
2825
2897
|
], PermissionController.prototype, "removeFromRole", null);
|
|
2826
|
-
|
|
2898
|
+
__decorate22([
|
|
2827
2899
|
Delete3(),
|
|
2828
2900
|
isAdmin(),
|
|
2829
2901
|
ResMsg4("permissions.success.allDeleted"),
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2902
|
+
__metadata22("design:type", Function),
|
|
2903
|
+
__metadata22("design:paramtypes", []),
|
|
2904
|
+
__metadata22("design:returntype", Promise)
|
|
2833
2905
|
], PermissionController.prototype, "deleteAll", null);
|
|
2834
|
-
PermissionController =
|
|
2906
|
+
PermissionController = __decorate22([
|
|
2835
2907
|
Controller4("/permissions"),
|
|
2836
2908
|
isAdmin(),
|
|
2837
|
-
|
|
2909
|
+
__metadata22("design:paramtypes", [typeof (_a14 = typeof PermissionService !== "undefined" && PermissionService) === "function" ? _a14 : Object])
|
|
2838
2910
|
], PermissionController);
|
|
2839
2911
|
|
|
2840
2912
|
// src/tokens/index.ts
|
|
@@ -3181,15 +3253,15 @@ function own(table, opts) {
|
|
|
3181
3253
|
__name(own, "own");
|
|
3182
3254
|
|
|
3183
3255
|
// src/ownership/configureOwnership.ts
|
|
3184
|
-
import { Injectable as Injectable11, Inject as Inject10, User as
|
|
3256
|
+
import { Injectable as Injectable11, Inject as Inject10, User as User5, Body as Body5, Params as Params4 } from "najm-core";
|
|
3185
3257
|
import { createGuard as createGuard5, composeGuards as composeGuards4 } from "najm-guard";
|
|
3186
|
-
var
|
|
3258
|
+
var __decorate23 = function(decorators, target, key, desc) {
|
|
3187
3259
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3188
3260
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3189
3261
|
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;
|
|
3190
3262
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3191
3263
|
};
|
|
3192
|
-
var
|
|
3264
|
+
var __metadata23 = function(k, v) {
|
|
3193
3265
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3194
3266
|
};
|
|
3195
3267
|
var __param9 = function(paramIndex, decorator) {
|
|
@@ -3209,7 +3281,7 @@ function toSingular(plural) {
|
|
|
3209
3281
|
}
|
|
3210
3282
|
__name(toSingular, "toSingular");
|
|
3211
3283
|
function createResourceGuards(ownershipClass, resourceType, resource, options) {
|
|
3212
|
-
var _a16,
|
|
3284
|
+
var _a16, _b8;
|
|
3213
3285
|
const writeGuard = options?.adminGuard ?? isAdmin;
|
|
3214
3286
|
let AccessGuard = class AccessGuard {
|
|
3215
3287
|
static {
|
|
@@ -3221,18 +3293,18 @@ function createResourceGuards(ownershipClass, resourceType, resource, options) {
|
|
|
3221
3293
|
return allowed ? { owner: user } : false;
|
|
3222
3294
|
}
|
|
3223
3295
|
};
|
|
3224
|
-
|
|
3296
|
+
__decorate23([
|
|
3225
3297
|
Inject10(ownershipClass),
|
|
3226
|
-
|
|
3298
|
+
__metadata23("design:type", Object)
|
|
3227
3299
|
], AccessGuard.prototype, "ownership", void 0);
|
|
3228
|
-
|
|
3229
|
-
__param9(0,
|
|
3300
|
+
__decorate23([
|
|
3301
|
+
__param9(0, User5()),
|
|
3230
3302
|
__param9(1, Params4("id")),
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3303
|
+
__metadata23("design:type", Function),
|
|
3304
|
+
__metadata23("design:paramtypes", [Object, String]),
|
|
3305
|
+
__metadata23("design:returntype", typeof (_a16 = typeof Promise !== "undefined" && Promise) === "function" ? _a16 : Object)
|
|
3234
3306
|
], AccessGuard.prototype, "canActivate", null);
|
|
3235
|
-
AccessGuard =
|
|
3307
|
+
AccessGuard = __decorate23([
|
|
3236
3308
|
Injectable11()
|
|
3237
3309
|
], AccessGuard);
|
|
3238
3310
|
let ListGuard = class ListGuard {
|
|
@@ -3245,17 +3317,17 @@ function createResourceGuards(ownershipClass, resourceType, resource, options) {
|
|
|
3245
3317
|
return { filter: ids };
|
|
3246
3318
|
}
|
|
3247
3319
|
};
|
|
3248
|
-
|
|
3320
|
+
__decorate23([
|
|
3249
3321
|
Inject10(ownershipClass),
|
|
3250
|
-
|
|
3322
|
+
__metadata23("design:type", Object)
|
|
3251
3323
|
], ListGuard.prototype, "ownership", void 0);
|
|
3252
|
-
|
|
3253
|
-
__param9(0,
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3324
|
+
__decorate23([
|
|
3325
|
+
__param9(0, User5()),
|
|
3326
|
+
__metadata23("design:type", Function),
|
|
3327
|
+
__metadata23("design:paramtypes", [Object]),
|
|
3328
|
+
__metadata23("design:returntype", typeof (_b8 = typeof Promise !== "undefined" && Promise) === "function" ? _b8 : Object)
|
|
3257
3329
|
], ListGuard.prototype, "canActivate", null);
|
|
3258
|
-
ListGuard =
|
|
3330
|
+
ListGuard = __decorate23([
|
|
3259
3331
|
Injectable11()
|
|
3260
3332
|
], ListGuard);
|
|
3261
3333
|
const access = createGuard5(AccessGuard);
|
|
@@ -3387,7 +3459,7 @@ function configureOwnership(config) {
|
|
|
3387
3459
|
}
|
|
3388
3460
|
}
|
|
3389
3461
|
};
|
|
3390
|
-
GeneratedOwnershipService =
|
|
3462
|
+
GeneratedOwnershipService = __decorate23([
|
|
3391
3463
|
Injectable11()
|
|
3392
3464
|
], GeneratedOwnershipService);
|
|
3393
3465
|
function bodyGuard(resourceType, bodyField, optional = false) {
|
|
@@ -3404,18 +3476,18 @@ function configureOwnership(config) {
|
|
|
3404
3476
|
return this.ownership.canAccess(user, resourceType, id);
|
|
3405
3477
|
}
|
|
3406
3478
|
};
|
|
3407
|
-
|
|
3479
|
+
__decorate23([
|
|
3408
3480
|
Inject10(GeneratedOwnershipService),
|
|
3409
|
-
|
|
3481
|
+
__metadata23("design:type", GeneratedOwnershipService)
|
|
3410
3482
|
], BodyAccessGuard.prototype, "ownership", void 0);
|
|
3411
|
-
|
|
3412
|
-
__param9(0,
|
|
3483
|
+
__decorate23([
|
|
3484
|
+
__param9(0, User5()),
|
|
3413
3485
|
__param9(1, Body5()),
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3486
|
+
__metadata23("design:type", Function),
|
|
3487
|
+
__metadata23("design:paramtypes", [Object, Object]),
|
|
3488
|
+
__metadata23("design:returntype", typeof (_a16 = typeof Promise !== "undefined" && Promise) === "function" ? _a16 : Object)
|
|
3417
3489
|
], BodyAccessGuard.prototype, "canActivate", null);
|
|
3418
|
-
BodyAccessGuard =
|
|
3490
|
+
BodyAccessGuard = __decorate23([
|
|
3419
3491
|
Injectable11()
|
|
3420
3492
|
], BodyAccessGuard);
|
|
3421
3493
|
return createGuard5(BodyAccessGuard);
|
|
@@ -3531,15 +3603,15 @@ __name(Policy, "Policy");
|
|
|
3531
3603
|
// src/ownership/OwnedDecorator.ts
|
|
3532
3604
|
import "reflect-metadata";
|
|
3533
3605
|
import { sql as sql5, and as and2 } from "drizzle-orm";
|
|
3534
|
-
import { Injectable as Injectable12, Inject as Inject11, DI, Container, REQUEST_ID } from "najm-core";
|
|
3535
|
-
import { USER } from "najm-guard";
|
|
3536
|
-
var
|
|
3606
|
+
import { Injectable as Injectable12, Inject as Inject11, DI as DI2, Container as Container2, REQUEST_ID } from "najm-core";
|
|
3607
|
+
import { USER as USER2 } from "najm-guard";
|
|
3608
|
+
var __decorate24 = function(decorators, target, key, desc) {
|
|
3537
3609
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3538
3610
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3539
3611
|
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;
|
|
3540
3612
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3541
3613
|
};
|
|
3542
|
-
var
|
|
3614
|
+
var __metadata24 = function(k, v) {
|
|
3543
3615
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3544
3616
|
};
|
|
3545
3617
|
var _a15;
|
|
@@ -3556,7 +3628,7 @@ var ScopeContext = class ScopeContext2 {
|
|
|
3556
3628
|
const requestId = this.container?.get?.(REQUEST_ID) ?? null;
|
|
3557
3629
|
if (requestId && requestId === this._cachedRequestId)
|
|
3558
3630
|
return this._cachedUser;
|
|
3559
|
-
const user = this.container?.get?.(
|
|
3631
|
+
const user = this.container?.get?.(USER2) ?? null;
|
|
3560
3632
|
this._cachedRequestId = requestId;
|
|
3561
3633
|
this._cachedUser = user;
|
|
3562
3634
|
return user;
|
|
@@ -3565,11 +3637,11 @@ var ScopeContext = class ScopeContext2 {
|
|
|
3565
3637
|
}
|
|
3566
3638
|
}
|
|
3567
3639
|
};
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3640
|
+
__decorate24([
|
|
3641
|
+
DI2(),
|
|
3642
|
+
__metadata24("design:type", typeof (_a15 = typeof Container2 !== "undefined" && Container2) === "function" ? _a15 : Object)
|
|
3571
3643
|
], ScopeContext.prototype, "container", void 0);
|
|
3572
|
-
ScopeContext =
|
|
3644
|
+
ScopeContext = __decorate24([
|
|
3573
3645
|
Injectable12()
|
|
3574
3646
|
], ScopeContext);
|
|
3575
3647
|
function Owned(token) {
|
|
@@ -3760,6 +3832,7 @@ export {
|
|
|
3760
3832
|
AuthController,
|
|
3761
3833
|
AuthGuard,
|
|
3762
3834
|
AuthQueries,
|
|
3835
|
+
AuthResolver,
|
|
3763
3836
|
AuthService,
|
|
3764
3837
|
Can,
|
|
3765
3838
|
CanCreate,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "najm-auth",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"description": "Authentication and authorization library for najm framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -10,25 +10,21 @@
|
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
-
"bun": "./src/index.ts",
|
|
14
13
|
"types": "./dist/index.d.ts",
|
|
15
14
|
"import": "./dist/index.js",
|
|
16
15
|
"default": "./dist/index.js"
|
|
17
16
|
},
|
|
18
17
|
"./pg": {
|
|
19
|
-
"bun": "./src/schema/pg.ts",
|
|
20
18
|
"types": "./dist/schema/pg.d.ts",
|
|
21
19
|
"import": "./dist/schema/pg.js",
|
|
22
20
|
"default": "./dist/schema/pg.js"
|
|
23
21
|
},
|
|
24
22
|
"./sqlite": {
|
|
25
|
-
"bun": "./src/schema/sqlite.ts",
|
|
26
23
|
"types": "./dist/schema/sqlite.d.ts",
|
|
27
24
|
"import": "./dist/schema/sqlite.js",
|
|
28
25
|
"default": "./dist/schema/sqlite.js"
|
|
29
26
|
},
|
|
30
27
|
"./mysql": {
|
|
31
|
-
"bun": "./src/schema/mysql.ts",
|
|
32
28
|
"types": "./dist/schema/mysql.d.ts",
|
|
33
29
|
"import": "./dist/schema/mysql.js",
|
|
34
30
|
"default": "./dist/schema/mysql.js"
|
|
@@ -62,15 +58,15 @@
|
|
|
62
58
|
"typescript": "^5.9.3"
|
|
63
59
|
},
|
|
64
60
|
"dependencies": {
|
|
65
|
-
"najm-cookies": "^1.1.
|
|
66
|
-
"najm-core": "^1.1.
|
|
67
|
-
"najm-database": "^1.1.
|
|
68
|
-
"najm-guard": "^1.1.
|
|
69
|
-
"najm-i18n": "^1.1.
|
|
70
|
-
"najm-cache": "^1.1.
|
|
71
|
-
"najm-email": "^1.1.
|
|
72
|
-
"najm-rate": "^1.1.
|
|
73
|
-
"najm-validation": "^1.1.
|
|
61
|
+
"najm-cookies": "^1.1.2",
|
|
62
|
+
"najm-core": "^1.1.2",
|
|
63
|
+
"najm-database": "^1.1.3",
|
|
64
|
+
"najm-guard": "^1.1.2",
|
|
65
|
+
"najm-i18n": "^1.1.2",
|
|
66
|
+
"najm-cache": "^1.1.2",
|
|
67
|
+
"najm-email": "^1.1.2",
|
|
68
|
+
"najm-rate": "^1.1.2",
|
|
69
|
+
"najm-validation": "^1.1.2",
|
|
74
70
|
"bcryptjs": "^3.0.3",
|
|
75
71
|
"hono": "^4.0.0",
|
|
76
72
|
"jsonwebtoken": "^9.0.3",
|