najm-auth 3.2.0 → 3.3.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/README.md +11 -5
- package/dist/client/react/index.d.ts +16 -17
- package/dist/index.d.ts +43 -9
- package/dist/index.js +469 -431
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3254,19 +3254,16 @@ var AuthService = class AuthService2 {
|
|
|
3254
3254
|
user.failedLoginAttempts = 0;
|
|
3255
3255
|
user.lockoutUntil = null;
|
|
3256
3256
|
}
|
|
3257
|
-
|
|
3258
|
-
Err12(this.t("errors.accountLocked"), 423);
|
|
3259
|
-
}
|
|
3257
|
+
const isLocked = Boolean(user && this.isLockoutActive(user.lockoutUntil));
|
|
3260
3258
|
const requirement = await this.credentialSetupRequirements?.find(user?.id ?? "", PASSWORD_SETUP_PURPOSE);
|
|
3261
3259
|
const { credential, kindUnavailable } = this.resolveLoginCredential(body.password, requirement);
|
|
3262
3260
|
const storedHash = kindUnavailable || !user?.password ? await this.getDummyHash() : user.password;
|
|
3263
3261
|
const isValid = await this.userValidator.comparePassword(credential, storedHash);
|
|
3264
|
-
if (!user || !isValid) {
|
|
3265
|
-
if (user) {
|
|
3262
|
+
if (!user || !isValid || isLocked) {
|
|
3263
|
+
if (user && !isLocked) {
|
|
3266
3264
|
const attempts = await this.userService.incrementFailedAttempts(user.id);
|
|
3267
3265
|
if (attempts >= this.config.lockout.maxAttempts) {
|
|
3268
3266
|
await this.userService.setLockout(user.id, this.nextLockoutUntil());
|
|
3269
|
-
Err12(this.t("errors.accountLocked"), 423);
|
|
3270
3267
|
}
|
|
3271
3268
|
}
|
|
3272
3269
|
Err12(this.t("errors.invalidCredentials"), 401);
|
|
@@ -3564,7 +3561,7 @@ var isAdministrator = composeGuards(isAuth(), Role(ROLE_GROUPS.ADMINISTRATORS));
|
|
|
3564
3561
|
|
|
3565
3562
|
// src/auth/AuthController.ts
|
|
3566
3563
|
import { Validate } from "najm-validation";
|
|
3567
|
-
import { RateLimit } from "najm-rate";
|
|
3564
|
+
import { RateLimit, UNRESOLVED_CLIENT_ADDRESS } from "najm-rate";
|
|
3568
3565
|
import { createHash as createHash3 } from "crypto";
|
|
3569
3566
|
|
|
3570
3567
|
// src/identity/requestResolver.ts
|
|
@@ -3742,14 +3739,13 @@ var __param5 = function(paramIndex, decorator) {
|
|
|
3742
3739
|
};
|
|
3743
3740
|
var _a12;
|
|
3744
3741
|
var hashKeyPart = /* @__PURE__ */ __name((value) => createHash3("sha256").update(value).digest("base64url").slice(0, 32), "hashKeyPart");
|
|
3745
|
-
var cookieFingerprint = /* @__PURE__ */ __name(() => (ctx) => {
|
|
3746
|
-
const ip = ctx.req.header("x-forwarded-for")?.split(",")[0]?.trim() ?? ctx.req.header("x-real-ip") ?? "unknown";
|
|
3742
|
+
var cookieFingerprint = /* @__PURE__ */ __name(() => (ctx, { clientIp }) => {
|
|
3747
3743
|
const cookie = ctx.req.raw.headers.get("cookie") ?? "";
|
|
3748
3744
|
const fingerprint = cookie ? hashKeyPart(cookie) : "none";
|
|
3749
|
-
return `${
|
|
3745
|
+
return `${clientIp}:${fingerprint}`;
|
|
3750
3746
|
}, "cookieFingerprint");
|
|
3751
|
-
var authIdentityRateLimitKey = /* @__PURE__ */ __name(async (ctx) => {
|
|
3752
|
-
const ip =
|
|
3747
|
+
var authIdentityRateLimitKey = /* @__PURE__ */ __name(async (ctx, keyContext) => {
|
|
3748
|
+
const ip = keyContext?.clientIp ?? UNRESOLVED_CLIENT_ADDRESS;
|
|
3753
3749
|
try {
|
|
3754
3750
|
const body = await ctx.req.json();
|
|
3755
3751
|
const identity = body?.identifier ?? body?.email;
|
|
@@ -3770,9 +3766,6 @@ var AuthController = class AuthController2 {
|
|
|
3770
3766
|
constructor(authService) {
|
|
3771
3767
|
this.authService = authService;
|
|
3772
3768
|
}
|
|
3773
|
-
async registerUser(body) {
|
|
3774
|
-
return this.authService.registerUser(body);
|
|
3775
|
-
}
|
|
3776
3769
|
async loginUser(body) {
|
|
3777
3770
|
return this.authService.loginUser(body);
|
|
3778
3771
|
}
|
|
@@ -3806,16 +3799,6 @@ var AuthController = class AuthController2 {
|
|
|
3806
3799
|
return this.authService.resetPassword(body.token, body.newPassword);
|
|
3807
3800
|
}
|
|
3808
3801
|
};
|
|
3809
|
-
__decorate20([
|
|
3810
|
-
Post("/register"),
|
|
3811
|
-
RateLimit({ limit: 5, window: "15m", key: authIdentityRateLimitKey }),
|
|
3812
|
-
Validate(registerDto),
|
|
3813
|
-
ResMsg("auth.success.register"),
|
|
3814
|
-
__param5(0, Body()),
|
|
3815
|
-
__metadata20("design:type", Function),
|
|
3816
|
-
__metadata20("design:paramtypes", [Object]),
|
|
3817
|
-
__metadata20("design:returntype", Promise)
|
|
3818
|
-
], AuthController.prototype, "registerUser", null);
|
|
3819
3802
|
__decorate20([
|
|
3820
3803
|
Post("/login"),
|
|
3821
3804
|
RateLimit({
|
|
@@ -4110,6 +4093,52 @@ AuthIdentityContextService = __decorate22([
|
|
|
4110
4093
|
__metadata22("design:paramtypes", [Object])
|
|
4111
4094
|
], AuthIdentityContextService);
|
|
4112
4095
|
|
|
4096
|
+
// src/auth/RegistrationController.ts
|
|
4097
|
+
import { Body as Body2, Controller as Controller2, Post as Post2, ResMsg as ResMsg2 } from "najm-core";
|
|
4098
|
+
import { RateLimit as RateLimit2 } from "najm-rate";
|
|
4099
|
+
import { Validate as Validate2 } from "najm-validation";
|
|
4100
|
+
var __decorate23 = function(decorators, target, key, desc) {
|
|
4101
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4102
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4103
|
+
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;
|
|
4104
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4105
|
+
};
|
|
4106
|
+
var __metadata23 = function(k, v) {
|
|
4107
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4108
|
+
};
|
|
4109
|
+
var __param7 = function(paramIndex, decorator) {
|
|
4110
|
+
return function(target, key) {
|
|
4111
|
+
decorator(target, key, paramIndex);
|
|
4112
|
+
};
|
|
4113
|
+
};
|
|
4114
|
+
var _a14;
|
|
4115
|
+
var RegistrationController = class RegistrationController2 {
|
|
4116
|
+
static {
|
|
4117
|
+
__name(this, "RegistrationController");
|
|
4118
|
+
}
|
|
4119
|
+
authService;
|
|
4120
|
+
constructor(authService) {
|
|
4121
|
+
this.authService = authService;
|
|
4122
|
+
}
|
|
4123
|
+
async registerUser(body) {
|
|
4124
|
+
return this.authService.registerUser(body);
|
|
4125
|
+
}
|
|
4126
|
+
};
|
|
4127
|
+
__decorate23([
|
|
4128
|
+
Post2("/register"),
|
|
4129
|
+
RateLimit2({ limit: 5, window: "15m", key: authIdentityRateLimitKey }),
|
|
4130
|
+
Validate2(registerDto),
|
|
4131
|
+
ResMsg2("auth.success.register"),
|
|
4132
|
+
__param7(0, Body2()),
|
|
4133
|
+
__metadata23("design:type", Function),
|
|
4134
|
+
__metadata23("design:paramtypes", [Object]),
|
|
4135
|
+
__metadata23("design:returntype", Promise)
|
|
4136
|
+
], RegistrationController.prototype, "registerUser", null);
|
|
4137
|
+
RegistrationController = __decorate23([
|
|
4138
|
+
Controller2("/auth"),
|
|
4139
|
+
__metadata23("design:paramtypes", [typeof (_a14 = typeof AuthService !== "undefined" && AuthService) === "function" ? _a14 : Object])
|
|
4140
|
+
], RegistrationController);
|
|
4141
|
+
|
|
4113
4142
|
// src/auth/runAsUser.ts
|
|
4114
4143
|
import { randomUUID } from "crypto";
|
|
4115
4144
|
function runAsUser(container, user, fn) {
|
|
@@ -4134,7 +4163,7 @@ function runAsUser(container, user, fn) {
|
|
|
4134
4163
|
__name(runAsUser, "runAsUser");
|
|
4135
4164
|
|
|
4136
4165
|
// src/auth/index.ts
|
|
4137
|
-
var
|
|
4166
|
+
var AUTH_CORE_MODULE = [
|
|
4138
4167
|
AuthService,
|
|
4139
4168
|
AuthSessionService,
|
|
4140
4169
|
CookieManager,
|
|
@@ -4144,6 +4173,11 @@ var AUTH_MODULE = [
|
|
|
4144
4173
|
AuthResolver,
|
|
4145
4174
|
AuthIdentityContextService
|
|
4146
4175
|
];
|
|
4176
|
+
var PUBLIC_REGISTRATION_MODULE = [RegistrationController];
|
|
4177
|
+
var AUTH_MODULE = [
|
|
4178
|
+
...AUTH_CORE_MODULE,
|
|
4179
|
+
...PUBLIC_REGISTRATION_MODULE
|
|
4180
|
+
];
|
|
4147
4181
|
|
|
4148
4182
|
// src/users/index.ts
|
|
4149
4183
|
var users_exports = {};
|
|
@@ -4169,9 +4203,9 @@ __export(users_exports, {
|
|
|
4169
4203
|
});
|
|
4170
4204
|
|
|
4171
4205
|
// src/users/UserController.ts
|
|
4172
|
-
import { Controller as
|
|
4173
|
-
import { Get as Get3, Post as
|
|
4174
|
-
import { Params as Params2, Body as
|
|
4206
|
+
import { Controller as Controller4 } from "najm-core";
|
|
4207
|
+
import { Get as Get3, Post as Post4, Put as Put2, Delete as Delete2, ResMsg as ResMsg4 } from "najm-core";
|
|
4208
|
+
import { Params as Params2, Body as Body4, Query } from "najm-core";
|
|
4175
4209
|
|
|
4176
4210
|
// src/roles/index.ts
|
|
4177
4211
|
var roles_exports = {};
|
|
@@ -4230,10 +4264,10 @@ function defineRoles(roles, options) {
|
|
|
4230
4264
|
__name(defineRoles, "defineRoles");
|
|
4231
4265
|
|
|
4232
4266
|
// src/roles/RoleController.ts
|
|
4233
|
-
import { Controller as
|
|
4234
|
-
import { Get as Get2, Post as
|
|
4235
|
-
import { Params, Body as
|
|
4236
|
-
import { Validate as
|
|
4267
|
+
import { Controller as Controller3 } from "najm-core";
|
|
4268
|
+
import { Get as Get2, Post as Post3, Put, Delete, ResMsg as ResMsg3 } from "najm-core";
|
|
4269
|
+
import { Params, Body as Body3 } from "najm-core";
|
|
4270
|
+
import { Validate as Validate3 } from "najm-validation";
|
|
4237
4271
|
|
|
4238
4272
|
// src/roles/RoleDto.ts
|
|
4239
4273
|
import { z as z2 } from "zod";
|
|
@@ -4253,21 +4287,21 @@ var assignRoleDto = z2.object({
|
|
|
4253
4287
|
});
|
|
4254
4288
|
|
|
4255
4289
|
// src/roles/RoleController.ts
|
|
4256
|
-
var
|
|
4290
|
+
var __decorate24 = function(decorators, target, key, desc) {
|
|
4257
4291
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4258
4292
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4259
4293
|
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;
|
|
4260
4294
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4261
4295
|
};
|
|
4262
|
-
var
|
|
4296
|
+
var __metadata24 = function(k, v) {
|
|
4263
4297
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4264
4298
|
};
|
|
4265
|
-
var
|
|
4299
|
+
var __param8 = function(paramIndex, decorator) {
|
|
4266
4300
|
return function(target, key) {
|
|
4267
4301
|
decorator(target, key, paramIndex);
|
|
4268
4302
|
};
|
|
4269
4303
|
};
|
|
4270
|
-
var
|
|
4304
|
+
var _a15;
|
|
4271
4305
|
var RoleController = class RoleController2 {
|
|
4272
4306
|
static {
|
|
4273
4307
|
__name(this, "RoleController");
|
|
@@ -4292,80 +4326,80 @@ var RoleController = class RoleController2 {
|
|
|
4292
4326
|
return this.roleService.delete(params.id);
|
|
4293
4327
|
}
|
|
4294
4328
|
};
|
|
4295
|
-
|
|
4329
|
+
__decorate24([
|
|
4296
4330
|
Get2(),
|
|
4297
4331
|
isAdmin(),
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4332
|
+
ResMsg3("roles.success.retrieved"),
|
|
4333
|
+
__metadata24("design:type", Function),
|
|
4334
|
+
__metadata24("design:paramtypes", []),
|
|
4335
|
+
__metadata24("design:returntype", Promise)
|
|
4302
4336
|
], RoleController.prototype, "getRoles", null);
|
|
4303
|
-
|
|
4337
|
+
__decorate24([
|
|
4304
4338
|
Get2("/:id"),
|
|
4305
4339
|
isAdmin(),
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4340
|
+
Validate3({ params: roleIdParam }),
|
|
4341
|
+
ResMsg3("roles.success.retrieved"),
|
|
4342
|
+
__param8(0, Params()),
|
|
4343
|
+
__metadata24("design:type", Function),
|
|
4344
|
+
__metadata24("design:paramtypes", [Object]),
|
|
4345
|
+
__metadata24("design:returntype", Promise)
|
|
4312
4346
|
], RoleController.prototype, "getRole", null);
|
|
4313
|
-
|
|
4314
|
-
|
|
4347
|
+
__decorate24([
|
|
4348
|
+
Post3(),
|
|
4315
4349
|
isAdmin(),
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4350
|
+
Validate3(createRoleDto),
|
|
4351
|
+
ResMsg3("roles.success.created"),
|
|
4352
|
+
__param8(0, Body3()),
|
|
4353
|
+
__metadata24("design:type", Function),
|
|
4354
|
+
__metadata24("design:paramtypes", [Object]),
|
|
4355
|
+
__metadata24("design:returntype", Promise)
|
|
4322
4356
|
], RoleController.prototype, "createRole", null);
|
|
4323
|
-
|
|
4357
|
+
__decorate24([
|
|
4324
4358
|
Put("/:id"),
|
|
4325
4359
|
isAdmin(),
|
|
4326
|
-
|
|
4360
|
+
Validate3({
|
|
4327
4361
|
params: roleIdParam,
|
|
4328
4362
|
body: updateRoleDto
|
|
4329
4363
|
}),
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4364
|
+
ResMsg3("roles.success.updated"),
|
|
4365
|
+
__param8(0, Params()),
|
|
4366
|
+
__param8(1, Body3()),
|
|
4367
|
+
__metadata24("design:type", Function),
|
|
4368
|
+
__metadata24("design:paramtypes", [Object, Object]),
|
|
4369
|
+
__metadata24("design:returntype", Promise)
|
|
4336
4370
|
], RoleController.prototype, "updateRole", null);
|
|
4337
|
-
|
|
4371
|
+
__decorate24([
|
|
4338
4372
|
Delete("/:id"),
|
|
4339
4373
|
isAdmin(),
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4374
|
+
Validate3({ params: roleIdParam }),
|
|
4375
|
+
ResMsg3("roles.success.deleted"),
|
|
4376
|
+
__param8(0, Params()),
|
|
4377
|
+
__metadata24("design:type", Function),
|
|
4378
|
+
__metadata24("design:paramtypes", [Object]),
|
|
4379
|
+
__metadata24("design:returntype", Promise)
|
|
4346
4380
|
], RoleController.prototype, "deleteRole", null);
|
|
4347
|
-
RoleController =
|
|
4348
|
-
|
|
4349
|
-
|
|
4381
|
+
RoleController = __decorate24([
|
|
4382
|
+
Controller3("/roles"),
|
|
4383
|
+
__metadata24("design:paramtypes", [typeof (_a15 = typeof RoleService !== "undefined" && RoleService) === "function" ? _a15 : Object])
|
|
4350
4384
|
], RoleController);
|
|
4351
4385
|
|
|
4352
4386
|
// src/users/UserController.ts
|
|
4353
|
-
import { Validate as
|
|
4354
|
-
var
|
|
4387
|
+
import { Validate as Validate4 } from "najm-validation";
|
|
4388
|
+
var __decorate25 = function(decorators, target, key, desc) {
|
|
4355
4389
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4356
4390
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4357
4391
|
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;
|
|
4358
4392
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4359
4393
|
};
|
|
4360
|
-
var
|
|
4394
|
+
var __metadata25 = function(k, v) {
|
|
4361
4395
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4362
4396
|
};
|
|
4363
|
-
var
|
|
4397
|
+
var __param9 = function(paramIndex, decorator) {
|
|
4364
4398
|
return function(target, key) {
|
|
4365
4399
|
decorator(target, key, paramIndex);
|
|
4366
4400
|
};
|
|
4367
4401
|
};
|
|
4368
|
-
var
|
|
4402
|
+
var _a16;
|
|
4369
4403
|
var UserController = class UserController2 {
|
|
4370
4404
|
static {
|
|
4371
4405
|
__name(this, "UserController");
|
|
@@ -4412,129 +4446,129 @@ var UserController = class UserController2 {
|
|
|
4412
4446
|
return this.userService.removeRole(params.userId);
|
|
4413
4447
|
}
|
|
4414
4448
|
};
|
|
4415
|
-
|
|
4449
|
+
__decorate25([
|
|
4416
4450
|
Get3(),
|
|
4417
4451
|
isAdmin(),
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4452
|
+
Validate4({ query: userListQuery }),
|
|
4453
|
+
ResMsg4("users.success.retrieved"),
|
|
4454
|
+
__param9(0, Query()),
|
|
4455
|
+
__metadata25("design:type", Function),
|
|
4456
|
+
__metadata25("design:paramtypes", [Object]),
|
|
4457
|
+
__metadata25("design:returntype", Promise)
|
|
4424
4458
|
], UserController.prototype, "getUsers", null);
|
|
4425
|
-
|
|
4459
|
+
__decorate25([
|
|
4426
4460
|
Get3("/lang"),
|
|
4427
4461
|
isAuth(),
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4462
|
+
ResMsg4("users.success.retrieved"),
|
|
4463
|
+
__metadata25("design:type", Function),
|
|
4464
|
+
__metadata25("design:paramtypes", []),
|
|
4465
|
+
__metadata25("design:returntype", Promise)
|
|
4432
4466
|
], UserController.prototype, "getLang", null);
|
|
4433
|
-
|
|
4434
|
-
|
|
4467
|
+
__decorate25([
|
|
4468
|
+
Post4("/lang/:language"),
|
|
4435
4469
|
isAuth(),
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4470
|
+
Validate4({ params: languageParam }),
|
|
4471
|
+
ResMsg4("users.success.updated"),
|
|
4472
|
+
__param9(0, Params2()),
|
|
4473
|
+
__metadata25("design:type", Function),
|
|
4474
|
+
__metadata25("design:paramtypes", [Object]),
|
|
4475
|
+
__metadata25("design:returntype", Promise)
|
|
4442
4476
|
], UserController.prototype, "updateLang", null);
|
|
4443
|
-
|
|
4477
|
+
__decorate25([
|
|
4444
4478
|
Get3("/:id"),
|
|
4445
4479
|
isAdmin(),
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4480
|
+
Validate4({ params: userIdParam }),
|
|
4481
|
+
ResMsg4("users.success.retrieved"),
|
|
4482
|
+
__param9(0, Params2()),
|
|
4483
|
+
__metadata25("design:type", Function),
|
|
4484
|
+
__metadata25("design:paramtypes", [Object]),
|
|
4485
|
+
__metadata25("design:returntype", Promise)
|
|
4452
4486
|
], UserController.prototype, "getUser", null);
|
|
4453
|
-
|
|
4487
|
+
__decorate25([
|
|
4454
4488
|
Get3("/email/:email"),
|
|
4455
4489
|
isAdmin(),
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4490
|
+
Validate4({ params: emailParam }),
|
|
4491
|
+
ResMsg4("users.success.retrieved"),
|
|
4492
|
+
__param9(0, Params2()),
|
|
4493
|
+
__metadata25("design:type", Function),
|
|
4494
|
+
__metadata25("design:paramtypes", [Object]),
|
|
4495
|
+
__metadata25("design:returntype", Promise)
|
|
4462
4496
|
], UserController.prototype, "getByEmail", null);
|
|
4463
|
-
|
|
4497
|
+
__decorate25([
|
|
4464
4498
|
Get3("/role/:userId"),
|
|
4465
4499
|
isAdmin(),
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4500
|
+
Validate4({ params: userIdInParam }),
|
|
4501
|
+
ResMsg4("users.success.retrieved"),
|
|
4502
|
+
__param9(0, Params2()),
|
|
4503
|
+
__metadata25("design:type", Function),
|
|
4504
|
+
__metadata25("design:paramtypes", [Object]),
|
|
4505
|
+
__metadata25("design:returntype", Promise)
|
|
4472
4506
|
], UserController.prototype, "getRole", null);
|
|
4473
|
-
|
|
4474
|
-
|
|
4507
|
+
__decorate25([
|
|
4508
|
+
Post4(),
|
|
4475
4509
|
isAdmin(),
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4510
|
+
Validate4(createUserDto),
|
|
4511
|
+
ResMsg4("users.success.created"),
|
|
4512
|
+
__param9(0, Body4()),
|
|
4513
|
+
__metadata25("design:type", Function),
|
|
4514
|
+
__metadata25("design:paramtypes", [Object]),
|
|
4515
|
+
__metadata25("design:returntype", Promise)
|
|
4482
4516
|
], UserController.prototype, "create", null);
|
|
4483
|
-
|
|
4517
|
+
__decorate25([
|
|
4484
4518
|
Put2("/:id"),
|
|
4485
4519
|
isAdmin(),
|
|
4486
|
-
|
|
4520
|
+
Validate4({
|
|
4487
4521
|
params: userIdParam,
|
|
4488
4522
|
body: updateUserDto
|
|
4489
4523
|
}),
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4524
|
+
ResMsg4("users.success.updated"),
|
|
4525
|
+
__param9(0, Params2()),
|
|
4526
|
+
__param9(1, Body4()),
|
|
4527
|
+
__metadata25("design:type", Function),
|
|
4528
|
+
__metadata25("design:paramtypes", [Object, Object]),
|
|
4529
|
+
__metadata25("design:returntype", Promise)
|
|
4496
4530
|
], UserController.prototype, "update", null);
|
|
4497
|
-
|
|
4531
|
+
__decorate25([
|
|
4498
4532
|
Delete2("/:id"),
|
|
4499
4533
|
isAdmin(),
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4534
|
+
Validate4({ params: userIdParam }),
|
|
4535
|
+
ResMsg4("users.success.deleted"),
|
|
4536
|
+
__param9(0, Params2()),
|
|
4537
|
+
__metadata25("design:type", Function),
|
|
4538
|
+
__metadata25("design:paramtypes", [Object]),
|
|
4539
|
+
__metadata25("design:returntype", Promise)
|
|
4506
4540
|
], UserController.prototype, "delete", null);
|
|
4507
|
-
|
|
4541
|
+
__decorate25([
|
|
4508
4542
|
Delete2(),
|
|
4509
4543
|
isAdmin(),
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4544
|
+
ResMsg4("users.success.allDeleted"),
|
|
4545
|
+
__metadata25("design:type", Function),
|
|
4546
|
+
__metadata25("design:paramtypes", []),
|
|
4547
|
+
__metadata25("design:returntype", Promise)
|
|
4514
4548
|
], UserController.prototype, "deleteAll", null);
|
|
4515
|
-
|
|
4516
|
-
|
|
4549
|
+
__decorate25([
|
|
4550
|
+
Post4("/assign/:userId/:roleId"),
|
|
4517
4551
|
isAdmin(),
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4552
|
+
Validate4({ params: assignRoleParams }),
|
|
4553
|
+
ResMsg4("users.success.updated"),
|
|
4554
|
+
__param9(0, Params2()),
|
|
4555
|
+
__metadata25("design:type", Function),
|
|
4556
|
+
__metadata25("design:paramtypes", [Object]),
|
|
4557
|
+
__metadata25("design:returntype", Promise)
|
|
4524
4558
|
], UserController.prototype, "assignRole", null);
|
|
4525
|
-
|
|
4559
|
+
__decorate25([
|
|
4526
4560
|
Delete2("/remove/:userId"),
|
|
4527
4561
|
isAdmin(),
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4562
|
+
Validate4({ params: userIdInParam }),
|
|
4563
|
+
ResMsg4("users.success.updated"),
|
|
4564
|
+
__param9(0, Params2()),
|
|
4565
|
+
__metadata25("design:type", Function),
|
|
4566
|
+
__metadata25("design:paramtypes", [Object]),
|
|
4567
|
+
__metadata25("design:returntype", Promise)
|
|
4534
4568
|
], UserController.prototype, "removeRole", null);
|
|
4535
|
-
UserController =
|
|
4536
|
-
|
|
4537
|
-
|
|
4569
|
+
UserController = __decorate25([
|
|
4570
|
+
Controller4("/users"),
|
|
4571
|
+
__metadata25("design:paramtypes", [typeof (_a16 = typeof UserService !== "undefined" && UserService) === "function" ? _a16 : Object])
|
|
4538
4572
|
], UserController);
|
|
4539
4573
|
|
|
4540
4574
|
// src/permissions/index.ts
|
|
@@ -4557,13 +4591,13 @@ __export(permissions_exports, {
|
|
|
4557
4591
|
import { eq as eq7, and as and4 } from "drizzle-orm";
|
|
4558
4592
|
import { Repository as Repository6, Inject as Inject14 } from "najm-core";
|
|
4559
4593
|
import { DB as DB6 } from "najm-database";
|
|
4560
|
-
var
|
|
4594
|
+
var __decorate26 = function(decorators, target, key, desc) {
|
|
4561
4595
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4562
4596
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4563
4597
|
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;
|
|
4564
4598
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4565
4599
|
};
|
|
4566
|
-
var
|
|
4600
|
+
var __metadata26 = function(k, v) {
|
|
4567
4601
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4568
4602
|
};
|
|
4569
4603
|
var PermissionRepository = class PermissionRepository2 {
|
|
@@ -4641,15 +4675,15 @@ var PermissionRepository = class PermissionRepository2 {
|
|
|
4641
4675
|
return deletedPermissions;
|
|
4642
4676
|
}
|
|
4643
4677
|
};
|
|
4644
|
-
|
|
4678
|
+
__decorate26([
|
|
4645
4679
|
DB6(),
|
|
4646
|
-
|
|
4680
|
+
__metadata26("design:type", Object)
|
|
4647
4681
|
], PermissionRepository.prototype, "db", void 0);
|
|
4648
|
-
|
|
4682
|
+
__decorate26([
|
|
4649
4683
|
Inject14(AUTH_SCHEMA),
|
|
4650
|
-
|
|
4684
|
+
__metadata26("design:type", Object)
|
|
4651
4685
|
], PermissionRepository.prototype, "schema", void 0);
|
|
4652
|
-
PermissionRepository =
|
|
4686
|
+
PermissionRepository = __decorate26([
|
|
4653
4687
|
Repository6()
|
|
4654
4688
|
], PermissionRepository);
|
|
4655
4689
|
|
|
@@ -4657,16 +4691,16 @@ PermissionRepository = __decorate25([
|
|
|
4657
4691
|
import { Injectable as Injectable12 } from "najm-core";
|
|
4658
4692
|
import { GuardParams as GuardParams2, User as User3 } from "najm-core";
|
|
4659
4693
|
import { createGuard as createGuard4, composeGuards as composeGuards3 } from "najm-guard";
|
|
4660
|
-
var
|
|
4694
|
+
var __decorate27 = function(decorators, target, key, desc) {
|
|
4661
4695
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4662
4696
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4663
4697
|
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;
|
|
4664
4698
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4665
4699
|
};
|
|
4666
|
-
var
|
|
4700
|
+
var __metadata27 = function(k, v) {
|
|
4667
4701
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4668
4702
|
};
|
|
4669
|
-
var
|
|
4703
|
+
var __param10 = function(paramIndex, decorator) {
|
|
4670
4704
|
return function(target, key) {
|
|
4671
4705
|
decorator(target, key, paramIndex);
|
|
4672
4706
|
};
|
|
@@ -4699,23 +4733,23 @@ var PermissionGuard = class PermissionGuard2 {
|
|
|
4699
4733
|
return false;
|
|
4700
4734
|
}
|
|
4701
4735
|
};
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4736
|
+
__decorate27([
|
|
4737
|
+
__param10(0, GuardParams2()),
|
|
4738
|
+
__param10(1, User3("permissions")),
|
|
4739
|
+
__metadata27("design:type", Function),
|
|
4740
|
+
__metadata27("design:paramtypes", [String, Array]),
|
|
4741
|
+
__metadata27("design:returntype", Object)
|
|
4708
4742
|
], PermissionGuard.prototype, "canActivate", null);
|
|
4709
|
-
PermissionGuard =
|
|
4743
|
+
PermissionGuard = __decorate27([
|
|
4710
4744
|
Injectable12()
|
|
4711
4745
|
], PermissionGuard);
|
|
4712
4746
|
var Permission = createGuard4(PermissionGuard);
|
|
4713
4747
|
var Can = /* @__PURE__ */ __name((permission) => composeGuards3(isAuth(), Permission(permission))(), "Can");
|
|
4714
4748
|
|
|
4715
4749
|
// src/permissions/PermissionController.ts
|
|
4716
|
-
import { Controller as
|
|
4717
|
-
import { Get as Get4, Post as
|
|
4718
|
-
import { Params as Params3, Body as
|
|
4750
|
+
import { Controller as Controller5 } from "najm-core";
|
|
4751
|
+
import { Get as Get4, Post as Post5, Put as Put3, Delete as Delete3, ResMsg as ResMsg5 } from "najm-core";
|
|
4752
|
+
import { Params as Params3, Body as Body5 } from "najm-core";
|
|
4719
4753
|
|
|
4720
4754
|
// src/permissions/PermissionService.ts
|
|
4721
4755
|
import { Injectable as Injectable14 } from "najm-core";
|
|
@@ -4724,16 +4758,16 @@ import { Injectable as Injectable14 } from "najm-core";
|
|
|
4724
4758
|
import { Injectable as Injectable13 } from "najm-core";
|
|
4725
4759
|
import { I18n as I18n9 } from "najm-i18n";
|
|
4726
4760
|
import { Err as Err14 } from "najm-core";
|
|
4727
|
-
var
|
|
4761
|
+
var __decorate28 = function(decorators, target, key, desc) {
|
|
4728
4762
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4729
4763
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4730
4764
|
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;
|
|
4731
4765
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4732
4766
|
};
|
|
4733
|
-
var
|
|
4767
|
+
var __metadata28 = function(k, v) {
|
|
4734
4768
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4735
4769
|
};
|
|
4736
|
-
var
|
|
4770
|
+
var _a17;
|
|
4737
4771
|
var _b10;
|
|
4738
4772
|
var PermissionValidator = class PermissionValidator2 {
|
|
4739
4773
|
static {
|
|
@@ -4801,26 +4835,26 @@ var PermissionValidator = class PermissionValidator2 {
|
|
|
4801
4835
|
}
|
|
4802
4836
|
}
|
|
4803
4837
|
};
|
|
4804
|
-
|
|
4838
|
+
__decorate28([
|
|
4805
4839
|
I18n9("permissions"),
|
|
4806
|
-
|
|
4840
|
+
__metadata28("design:type", Object)
|
|
4807
4841
|
], PermissionValidator.prototype, "t", void 0);
|
|
4808
|
-
PermissionValidator =
|
|
4842
|
+
PermissionValidator = __decorate28([
|
|
4809
4843
|
Injectable13(),
|
|
4810
|
-
|
|
4844
|
+
__metadata28("design:paramtypes", [typeof (_a17 = typeof PermissionRepository !== "undefined" && PermissionRepository) === "function" ? _a17 : Object, typeof (_b10 = typeof RoleValidator !== "undefined" && RoleValidator) === "function" ? _b10 : Object])
|
|
4811
4845
|
], PermissionValidator);
|
|
4812
4846
|
|
|
4813
4847
|
// src/permissions/PermissionService.ts
|
|
4814
|
-
var
|
|
4848
|
+
var __decorate29 = function(decorators, target, key, desc) {
|
|
4815
4849
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4816
4850
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4817
4851
|
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;
|
|
4818
4852
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4819
4853
|
};
|
|
4820
|
-
var
|
|
4854
|
+
var __metadata29 = function(k, v) {
|
|
4821
4855
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4822
4856
|
};
|
|
4823
|
-
var
|
|
4857
|
+
var _a18;
|
|
4824
4858
|
var _b11;
|
|
4825
4859
|
var _c8;
|
|
4826
4860
|
var PermissionService = class PermissionService2 {
|
|
@@ -4927,13 +4961,13 @@ var PermissionService = class PermissionService2 {
|
|
|
4927
4961
|
return await this.permissionRepository.deleteAll();
|
|
4928
4962
|
}
|
|
4929
4963
|
};
|
|
4930
|
-
PermissionService =
|
|
4964
|
+
PermissionService = __decorate29([
|
|
4931
4965
|
Injectable14(),
|
|
4932
|
-
|
|
4966
|
+
__metadata29("design:paramtypes", [typeof (_a18 = typeof PermissionRepository !== "undefined" && PermissionRepository) === "function" ? _a18 : Object, typeof (_b11 = typeof PermissionValidator !== "undefined" && PermissionValidator) === "function" ? _b11 : Object, typeof (_c8 = typeof RoleService !== "undefined" && RoleService) === "function" ? _c8 : Object])
|
|
4933
4967
|
], PermissionService);
|
|
4934
4968
|
|
|
4935
4969
|
// src/permissions/PermissionController.ts
|
|
4936
|
-
import { Validate as
|
|
4970
|
+
import { Validate as Validate5 } from "najm-validation";
|
|
4937
4971
|
|
|
4938
4972
|
// src/permissions/PermissionDto.ts
|
|
4939
4973
|
import { z as z3 } from "zod";
|
|
@@ -4962,21 +4996,21 @@ var checkPermissionDto = z3.object({
|
|
|
4962
4996
|
});
|
|
4963
4997
|
|
|
4964
4998
|
// src/permissions/PermissionController.ts
|
|
4965
|
-
var
|
|
4999
|
+
var __decorate30 = function(decorators, target, key, desc) {
|
|
4966
5000
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4967
5001
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4968
5002
|
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;
|
|
4969
5003
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4970
5004
|
};
|
|
4971
|
-
var
|
|
5005
|
+
var __metadata30 = function(k, v) {
|
|
4972
5006
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4973
5007
|
};
|
|
4974
|
-
var
|
|
5008
|
+
var __param11 = function(paramIndex, decorator) {
|
|
4975
5009
|
return function(target, key) {
|
|
4976
5010
|
decorator(target, key, paramIndex);
|
|
4977
5011
|
};
|
|
4978
5012
|
};
|
|
4979
|
-
var
|
|
5013
|
+
var _a19;
|
|
4980
5014
|
var PermissionController = class PermissionController2 {
|
|
4981
5015
|
static {
|
|
4982
5016
|
__name(this, "PermissionController");
|
|
@@ -5022,101 +5056,101 @@ var PermissionController = class PermissionController2 {
|
|
|
5022
5056
|
return this.permissionService.deleteAll();
|
|
5023
5057
|
}
|
|
5024
5058
|
};
|
|
5025
|
-
|
|
5059
|
+
__decorate30([
|
|
5026
5060
|
Get4(),
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5061
|
+
ResMsg5("permissions.success.retrieved"),
|
|
5062
|
+
__metadata30("design:type", Function),
|
|
5063
|
+
__metadata30("design:paramtypes", []),
|
|
5064
|
+
__metadata30("design:returntype", Promise)
|
|
5031
5065
|
], PermissionController.prototype, "getPermissions", null);
|
|
5032
|
-
|
|
5066
|
+
__decorate30([
|
|
5033
5067
|
Get4("/:id"),
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5068
|
+
Validate5({ params: permissionIdParam }),
|
|
5069
|
+
ResMsg5("permissions.success.retrieved"),
|
|
5070
|
+
__param11(0, Params3()),
|
|
5071
|
+
__metadata30("design:type", Function),
|
|
5072
|
+
__metadata30("design:paramtypes", [Object]),
|
|
5073
|
+
__metadata30("design:returntype", Promise)
|
|
5040
5074
|
], PermissionController.prototype, "getPermission", null);
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5075
|
+
__decorate30([
|
|
5076
|
+
Post5(),
|
|
5077
|
+
Validate5(createPermissionDto),
|
|
5078
|
+
ResMsg5({ message: "Permission created successfully", status: 201 }),
|
|
5079
|
+
__param11(0, Body5()),
|
|
5080
|
+
__metadata30("design:type", Function),
|
|
5081
|
+
__metadata30("design:paramtypes", [Object]),
|
|
5082
|
+
__metadata30("design:returntype", Promise)
|
|
5049
5083
|
], PermissionController.prototype, "create", null);
|
|
5050
|
-
|
|
5084
|
+
__decorate30([
|
|
5051
5085
|
Put3("/:id"),
|
|
5052
|
-
|
|
5086
|
+
Validate5({
|
|
5053
5087
|
params: permissionIdParam,
|
|
5054
5088
|
body: updatePermissionDto
|
|
5055
5089
|
}),
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5090
|
+
ResMsg5("permissions.success.updated"),
|
|
5091
|
+
__param11(0, Params3()),
|
|
5092
|
+
__param11(1, Body5()),
|
|
5093
|
+
__metadata30("design:type", Function),
|
|
5094
|
+
__metadata30("design:paramtypes", [Object, Object]),
|
|
5095
|
+
__metadata30("design:returntype", Promise)
|
|
5062
5096
|
], PermissionController.prototype, "update", null);
|
|
5063
|
-
|
|
5097
|
+
__decorate30([
|
|
5064
5098
|
Delete3("/:id"),
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5099
|
+
Validate5({ params: permissionIdParam }),
|
|
5100
|
+
ResMsg5("permissions.success.deleted"),
|
|
5101
|
+
__param11(0, Params3()),
|
|
5102
|
+
__metadata30("design:type", Function),
|
|
5103
|
+
__metadata30("design:paramtypes", [Object]),
|
|
5104
|
+
__metadata30("design:returntype", Promise)
|
|
5071
5105
|
], PermissionController.prototype, "delete", null);
|
|
5072
|
-
|
|
5106
|
+
__decorate30([
|
|
5073
5107
|
Get4("/role/:id"),
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5108
|
+
Validate5({ params: roleIdParam }),
|
|
5109
|
+
ResMsg5("permissions.success.retrieved"),
|
|
5110
|
+
__param11(0, Params3()),
|
|
5111
|
+
__metadata30("design:type", Function),
|
|
5112
|
+
__metadata30("design:paramtypes", [Object]),
|
|
5113
|
+
__metadata30("design:returntype", Promise)
|
|
5080
5114
|
], PermissionController.prototype, "getByRole", null);
|
|
5081
|
-
|
|
5115
|
+
__decorate30([
|
|
5082
5116
|
Get4("/roles/:id"),
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5117
|
+
Validate5({ params: permissionIdParam }),
|
|
5118
|
+
ResMsg5("permissions.success.retrieved"),
|
|
5119
|
+
__param11(0, Params3()),
|
|
5120
|
+
__metadata30("design:type", Function),
|
|
5121
|
+
__metadata30("design:paramtypes", [Object]),
|
|
5122
|
+
__metadata30("design:returntype", Promise)
|
|
5089
5123
|
], PermissionController.prototype, "getRolesByPermission", null);
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5124
|
+
__decorate30([
|
|
5125
|
+
Post5("/assign/:roleId/:permissionId"),
|
|
5126
|
+
Validate5({ params: assignPermissionDto }),
|
|
5127
|
+
ResMsg5("permissions.success.assigned"),
|
|
5128
|
+
__param11(0, Params3()),
|
|
5129
|
+
__metadata30("design:type", Function),
|
|
5130
|
+
__metadata30("design:paramtypes", [Object]),
|
|
5131
|
+
__metadata30("design:returntype", Promise)
|
|
5098
5132
|
], PermissionController.prototype, "assignToRole", null);
|
|
5099
|
-
|
|
5133
|
+
__decorate30([
|
|
5100
5134
|
Delete3("/remove/:roleId/:permissionId"),
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5135
|
+
Validate5({ params: assignPermissionDto }),
|
|
5136
|
+
ResMsg5("permissions.success.removed"),
|
|
5137
|
+
__param11(0, Params3()),
|
|
5138
|
+
__metadata30("design:type", Function),
|
|
5139
|
+
__metadata30("design:paramtypes", [Object]),
|
|
5140
|
+
__metadata30("design:returntype", Promise)
|
|
5107
5141
|
], PermissionController.prototype, "removeFromRole", null);
|
|
5108
|
-
|
|
5142
|
+
__decorate30([
|
|
5109
5143
|
Delete3(),
|
|
5110
5144
|
isAdmin(),
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5145
|
+
ResMsg5("permissions.success.allDeleted"),
|
|
5146
|
+
__metadata30("design:type", Function),
|
|
5147
|
+
__metadata30("design:paramtypes", []),
|
|
5148
|
+
__metadata30("design:returntype", Promise)
|
|
5115
5149
|
], PermissionController.prototype, "deleteAll", null);
|
|
5116
|
-
PermissionController =
|
|
5117
|
-
|
|
5150
|
+
PermissionController = __decorate30([
|
|
5151
|
+
Controller5("/permissions"),
|
|
5118
5152
|
isAdmin(),
|
|
5119
|
-
|
|
5153
|
+
__metadata30("design:paramtypes", [typeof (_a19 = typeof PermissionService !== "undefined" && PermissionService) === "function" ? _a19 : Object])
|
|
5120
5154
|
], PermissionController);
|
|
5121
5155
|
|
|
5122
5156
|
// src/tokens/index.ts
|
|
@@ -5323,18 +5357,18 @@ function own(table, opts) {
|
|
|
5323
5357
|
__name(own, "own");
|
|
5324
5358
|
|
|
5325
5359
|
// src/ownership/configureOwnership.ts
|
|
5326
|
-
import { Injectable as Injectable15, Inject as Inject15, User as User4, Body as
|
|
5360
|
+
import { Injectable as Injectable15, Inject as Inject15, User as User4, Body as Body6, Params as Params4 } from "najm-core";
|
|
5327
5361
|
import { createGuard as createGuard5, composeGuards as composeGuards4 } from "najm-guard";
|
|
5328
|
-
var
|
|
5362
|
+
var __decorate31 = function(decorators, target, key, desc) {
|
|
5329
5363
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5330
5364
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5331
5365
|
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;
|
|
5332
5366
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5333
5367
|
};
|
|
5334
|
-
var
|
|
5368
|
+
var __metadata31 = function(k, v) {
|
|
5335
5369
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
5336
5370
|
};
|
|
5337
|
-
var
|
|
5371
|
+
var __param12 = function(paramIndex, decorator) {
|
|
5338
5372
|
return function(target, key) {
|
|
5339
5373
|
decorator(target, key, paramIndex);
|
|
5340
5374
|
};
|
|
@@ -5351,7 +5385,7 @@ function toSingular(plural) {
|
|
|
5351
5385
|
}
|
|
5352
5386
|
__name(toSingular, "toSingular");
|
|
5353
5387
|
function createResourceGuards(ownershipClass, resourceType, resource, options) {
|
|
5354
|
-
var
|
|
5388
|
+
var _a27, _b15;
|
|
5355
5389
|
const writeGuard = options?.adminGuard ?? isAdmin;
|
|
5356
5390
|
let AccessGuard = class AccessGuard {
|
|
5357
5391
|
static {
|
|
@@ -5363,18 +5397,18 @@ function createResourceGuards(ownershipClass, resourceType, resource, options) {
|
|
|
5363
5397
|
return allowed ? { owner: user } : false;
|
|
5364
5398
|
}
|
|
5365
5399
|
};
|
|
5366
|
-
|
|
5400
|
+
__decorate31([
|
|
5367
5401
|
Inject15(ownershipClass),
|
|
5368
|
-
|
|
5402
|
+
__metadata31("design:type", Object)
|
|
5369
5403
|
], AccessGuard.prototype, "ownership", void 0);
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5404
|
+
__decorate31([
|
|
5405
|
+
__param12(0, User4()),
|
|
5406
|
+
__param12(1, Params4("id")),
|
|
5407
|
+
__metadata31("design:type", Function),
|
|
5408
|
+
__metadata31("design:paramtypes", [Object, String]),
|
|
5409
|
+
__metadata31("design:returntype", typeof (_a27 = typeof Promise !== "undefined" && Promise) === "function" ? _a27 : Object)
|
|
5376
5410
|
], AccessGuard.prototype, "canActivate", null);
|
|
5377
|
-
AccessGuard =
|
|
5411
|
+
AccessGuard = __decorate31([
|
|
5378
5412
|
Injectable15()
|
|
5379
5413
|
], AccessGuard);
|
|
5380
5414
|
let ListGuard = class ListGuard {
|
|
@@ -5387,17 +5421,17 @@ function createResourceGuards(ownershipClass, resourceType, resource, options) {
|
|
|
5387
5421
|
return { filter: ids };
|
|
5388
5422
|
}
|
|
5389
5423
|
};
|
|
5390
|
-
|
|
5424
|
+
__decorate31([
|
|
5391
5425
|
Inject15(ownershipClass),
|
|
5392
|
-
|
|
5426
|
+
__metadata31("design:type", Object)
|
|
5393
5427
|
], ListGuard.prototype, "ownership", void 0);
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5428
|
+
__decorate31([
|
|
5429
|
+
__param12(0, User4()),
|
|
5430
|
+
__metadata31("design:type", Function),
|
|
5431
|
+
__metadata31("design:paramtypes", [Object]),
|
|
5432
|
+
__metadata31("design:returntype", typeof (_b15 = typeof Promise !== "undefined" && Promise) === "function" ? _b15 : Object)
|
|
5399
5433
|
], ListGuard.prototype, "canActivate", null);
|
|
5400
|
-
ListGuard =
|
|
5434
|
+
ListGuard = __decorate31([
|
|
5401
5435
|
Injectable15()
|
|
5402
5436
|
], ListGuard);
|
|
5403
5437
|
const access = createGuard5(AccessGuard);
|
|
@@ -5529,11 +5563,11 @@ function configureOwnership(config) {
|
|
|
5529
5563
|
}
|
|
5530
5564
|
}
|
|
5531
5565
|
};
|
|
5532
|
-
GeneratedOwnershipService =
|
|
5566
|
+
GeneratedOwnershipService = __decorate31([
|
|
5533
5567
|
Injectable15()
|
|
5534
5568
|
], GeneratedOwnershipService);
|
|
5535
5569
|
function bodyGuard(resourceType, bodyField, optional = false) {
|
|
5536
|
-
var
|
|
5570
|
+
var _a27;
|
|
5537
5571
|
let BodyAccessGuard = class BodyAccessGuard {
|
|
5538
5572
|
static {
|
|
5539
5573
|
__name(this, "BodyAccessGuard");
|
|
@@ -5546,18 +5580,18 @@ function configureOwnership(config) {
|
|
|
5546
5580
|
return this.ownership.canAccess(user, resourceType, id);
|
|
5547
5581
|
}
|
|
5548
5582
|
};
|
|
5549
|
-
|
|
5583
|
+
__decorate31([
|
|
5550
5584
|
Inject15(GeneratedOwnershipService),
|
|
5551
|
-
|
|
5585
|
+
__metadata31("design:type", GeneratedOwnershipService)
|
|
5552
5586
|
], BodyAccessGuard.prototype, "ownership", void 0);
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5587
|
+
__decorate31([
|
|
5588
|
+
__param12(0, User4()),
|
|
5589
|
+
__param12(1, Body6()),
|
|
5590
|
+
__metadata31("design:type", Function),
|
|
5591
|
+
__metadata31("design:paramtypes", [Object, Object]),
|
|
5592
|
+
__metadata31("design:returntype", typeof (_a27 = typeof Promise !== "undefined" && Promise) === "function" ? _a27 : Object)
|
|
5559
5593
|
], BodyAccessGuard.prototype, "canActivate", null);
|
|
5560
|
-
BodyAccessGuard =
|
|
5594
|
+
BodyAccessGuard = __decorate31([
|
|
5561
5595
|
Injectable15()
|
|
5562
5596
|
], BodyAccessGuard);
|
|
5563
5597
|
return createGuard5(BodyAccessGuard);
|
|
@@ -5675,16 +5709,16 @@ import "reflect-metadata";
|
|
|
5675
5709
|
import { sql as sql5, and as and5 } from "drizzle-orm";
|
|
5676
5710
|
import { Injectable as Injectable16, Inject as Inject16, DI as DI3, Container as Container2, REQUEST_ID } from "najm-core";
|
|
5677
5711
|
import { USER as USER2 } from "najm-guard";
|
|
5678
|
-
var
|
|
5712
|
+
var __decorate32 = function(decorators, target, key, desc) {
|
|
5679
5713
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5680
5714
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5681
5715
|
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;
|
|
5682
5716
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5683
5717
|
};
|
|
5684
|
-
var
|
|
5718
|
+
var __metadata32 = function(k, v) {
|
|
5685
5719
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
5686
5720
|
};
|
|
5687
|
-
var
|
|
5721
|
+
var _a20;
|
|
5688
5722
|
var OWNED_META = Symbol.for("najm:owned");
|
|
5689
5723
|
var ScopeContext = class ScopeContext2 {
|
|
5690
5724
|
static {
|
|
@@ -5716,11 +5750,11 @@ var ScopeContext = class ScopeContext2 {
|
|
|
5716
5750
|
}
|
|
5717
5751
|
}
|
|
5718
5752
|
};
|
|
5719
|
-
|
|
5753
|
+
__decorate32([
|
|
5720
5754
|
DI3(),
|
|
5721
|
-
|
|
5755
|
+
__metadata32("design:type", typeof (_a20 = typeof Container2 !== "undefined" && Container2) === "function" ? _a20 : Object)
|
|
5722
5756
|
], ScopeContext.prototype, "container", void 0);
|
|
5723
|
-
ScopeContext =
|
|
5757
|
+
ScopeContext = __decorate32([
|
|
5724
5758
|
Injectable16()
|
|
5725
5759
|
], ScopeContext);
|
|
5726
5760
|
function Owned(token) {
|
|
@@ -5957,13 +5991,13 @@ var OAuthFlowError = class extends Error {
|
|
|
5957
5991
|
// src/oauth/google/GoogleTokenVerifier.ts
|
|
5958
5992
|
import { Inject as Inject17, Injectable as Injectable17 } from "najm-core";
|
|
5959
5993
|
import { createRemoteJWKSet, jwtVerify } from "jose";
|
|
5960
|
-
var
|
|
5994
|
+
var __decorate33 = function(decorators, target, key, desc) {
|
|
5961
5995
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5962
5996
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5963
5997
|
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;
|
|
5964
5998
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5965
5999
|
};
|
|
5966
|
-
var
|
|
6000
|
+
var __metadata33 = function(k, v) {
|
|
5967
6001
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
5968
6002
|
};
|
|
5969
6003
|
var GOOGLE_JWKS = createRemoteJWKSet(new URL("https://www.googleapis.com/oauth2/v3/certs"));
|
|
@@ -6015,25 +6049,25 @@ var GoogleTokenVerifier = class GoogleTokenVerifier2 {
|
|
|
6015
6049
|
return google;
|
|
6016
6050
|
}
|
|
6017
6051
|
};
|
|
6018
|
-
|
|
6052
|
+
__decorate33([
|
|
6019
6053
|
Inject17(AUTH_CONFIG),
|
|
6020
|
-
|
|
6054
|
+
__metadata33("design:type", Object)
|
|
6021
6055
|
], GoogleTokenVerifier.prototype, "config", void 0);
|
|
6022
|
-
GoogleTokenVerifier =
|
|
6056
|
+
GoogleTokenVerifier = __decorate33([
|
|
6023
6057
|
Injectable17()
|
|
6024
6058
|
], GoogleTokenVerifier);
|
|
6025
6059
|
|
|
6026
6060
|
// src/oauth/google/GoogleOAuthProvider.ts
|
|
6027
|
-
var
|
|
6061
|
+
var __decorate34 = function(decorators, target, key, desc) {
|
|
6028
6062
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6029
6063
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6030
6064
|
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;
|
|
6031
6065
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6032
6066
|
};
|
|
6033
|
-
var
|
|
6067
|
+
var __metadata34 = function(k, v) {
|
|
6034
6068
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
6035
6069
|
};
|
|
6036
|
-
var
|
|
6070
|
+
var _a21;
|
|
6037
6071
|
var AUTHORIZATION_ENDPOINT = "https://accounts.google.com/o/oauth2/v2/auth";
|
|
6038
6072
|
var TOKEN_ENDPOINT = "https://oauth2.googleapis.com/token";
|
|
6039
6073
|
var GoogleOAuthProvider = class GoogleOAuthProvider2 {
|
|
@@ -6101,26 +6135,26 @@ var GoogleOAuthProvider = class GoogleOAuthProvider2 {
|
|
|
6101
6135
|
return google;
|
|
6102
6136
|
}
|
|
6103
6137
|
};
|
|
6104
|
-
|
|
6138
|
+
__decorate34([
|
|
6105
6139
|
Inject18(AUTH_CONFIG),
|
|
6106
|
-
|
|
6140
|
+
__metadata34("design:type", Object)
|
|
6107
6141
|
], GoogleOAuthProvider.prototype, "config", void 0);
|
|
6108
|
-
GoogleOAuthProvider =
|
|
6142
|
+
GoogleOAuthProvider = __decorate34([
|
|
6109
6143
|
Injectable18(),
|
|
6110
|
-
|
|
6144
|
+
__metadata34("design:paramtypes", [typeof (_a21 = typeof GoogleTokenVerifier !== "undefined" && GoogleTokenVerifier) === "function" ? _a21 : Object])
|
|
6111
6145
|
], GoogleOAuthProvider);
|
|
6112
6146
|
|
|
6113
6147
|
// src/oauth/OAuthAccountRepository.ts
|
|
6114
6148
|
import { and as and6, eq as eq9 } from "drizzle-orm";
|
|
6115
6149
|
import { Inject as Inject19, Repository as Repository7 } from "najm-core";
|
|
6116
6150
|
import { DB as DB7 } from "najm-database";
|
|
6117
|
-
var
|
|
6151
|
+
var __decorate35 = function(decorators, target, key, desc) {
|
|
6118
6152
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6119
6153
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6120
6154
|
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;
|
|
6121
6155
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6122
6156
|
};
|
|
6123
|
-
var
|
|
6157
|
+
var __metadata35 = function(k, v) {
|
|
6124
6158
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
6125
6159
|
};
|
|
6126
6160
|
var OAuthAccountRepository = class OAuthAccountRepository2 {
|
|
@@ -6148,15 +6182,15 @@ var OAuthAccountRepository = class OAuthAccountRepository2 {
|
|
|
6148
6182
|
return account;
|
|
6149
6183
|
}
|
|
6150
6184
|
};
|
|
6151
|
-
|
|
6185
|
+
__decorate35([
|
|
6152
6186
|
DB7(),
|
|
6153
|
-
|
|
6187
|
+
__metadata35("design:type", Object)
|
|
6154
6188
|
], OAuthAccountRepository.prototype, "db", void 0);
|
|
6155
|
-
|
|
6189
|
+
__decorate35([
|
|
6156
6190
|
Inject19(AUTH_SCHEMA),
|
|
6157
|
-
|
|
6191
|
+
__metadata35("design:type", Object)
|
|
6158
6192
|
], OAuthAccountRepository.prototype, "schema", void 0);
|
|
6159
|
-
OAuthAccountRepository =
|
|
6193
|
+
OAuthAccountRepository = __decorate35([
|
|
6160
6194
|
Repository7()
|
|
6161
6195
|
], OAuthAccountRepository);
|
|
6162
6196
|
|
|
@@ -6164,16 +6198,16 @@ OAuthAccountRepository = __decorate34([
|
|
|
6164
6198
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
6165
6199
|
import { Inject as Inject20, Injectable as Injectable19 } from "najm-core";
|
|
6166
6200
|
import { Transaction as Transaction5 } from "najm-database";
|
|
6167
|
-
var
|
|
6201
|
+
var __decorate36 = function(decorators, target, key, desc) {
|
|
6168
6202
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6169
6203
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6170
6204
|
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;
|
|
6171
6205
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6172
6206
|
};
|
|
6173
|
-
var
|
|
6207
|
+
var __metadata36 = function(k, v) {
|
|
6174
6208
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
6175
6209
|
};
|
|
6176
|
-
var
|
|
6210
|
+
var _a22;
|
|
6177
6211
|
var _b12;
|
|
6178
6212
|
var _c9;
|
|
6179
6213
|
var _d7;
|
|
@@ -6252,31 +6286,31 @@ var OAuthAccountService = class OAuthAccountService2 {
|
|
|
6252
6286
|
return google;
|
|
6253
6287
|
}
|
|
6254
6288
|
};
|
|
6255
|
-
|
|
6289
|
+
__decorate36([
|
|
6256
6290
|
Inject20(AUTH_CONFIG),
|
|
6257
|
-
|
|
6291
|
+
__metadata36("design:type", Object)
|
|
6258
6292
|
], OAuthAccountService.prototype, "config", void 0);
|
|
6259
|
-
|
|
6293
|
+
__decorate36([
|
|
6260
6294
|
Transaction5(),
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6295
|
+
__metadata36("design:type", Function),
|
|
6296
|
+
__metadata36("design:paramtypes", [Object]),
|
|
6297
|
+
__metadata36("design:returntype", typeof (_c9 = typeof Promise !== "undefined" && Promise) === "function" ? _c9 : Object)
|
|
6264
6298
|
], OAuthAccountService.prototype, "resolveForLogin", null);
|
|
6265
|
-
|
|
6299
|
+
__decorate36([
|
|
6266
6300
|
Transaction5(),
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6301
|
+
__metadata36("design:type", Function),
|
|
6302
|
+
__metadata36("design:paramtypes", [String, Object]),
|
|
6303
|
+
__metadata36("design:returntype", typeof (_d7 = typeof Promise !== "undefined" && Promise) === "function" ? _d7 : Object)
|
|
6270
6304
|
], OAuthAccountService.prototype, "linkUser", null);
|
|
6271
|
-
OAuthAccountService =
|
|
6305
|
+
OAuthAccountService = __decorate36([
|
|
6272
6306
|
Injectable19(),
|
|
6273
|
-
|
|
6307
|
+
__metadata36("design:paramtypes", [typeof (_a22 = typeof OAuthAccountRepository !== "undefined" && OAuthAccountRepository) === "function" ? _a22 : Object, typeof (_b12 = typeof UserService !== "undefined" && UserService) === "function" ? _b12 : Object])
|
|
6274
6308
|
], OAuthAccountService);
|
|
6275
6309
|
|
|
6276
6310
|
// src/oauth/OAuthController.ts
|
|
6277
6311
|
import { createHash as createHash5 } from "crypto";
|
|
6278
|
-
import { Controller as
|
|
6279
|
-
import { RateLimit as
|
|
6312
|
+
import { Controller as Controller6, Ctx as Ctx2, Get as Get5, Post as Post6, Query as Query2, User as User5 } from "najm-core";
|
|
6313
|
+
import { RateLimit as RateLimit3 } from "najm-rate";
|
|
6280
6314
|
|
|
6281
6315
|
// src/oauth/OAuthService.ts
|
|
6282
6316
|
import { Inject as Inject21, Injectable as Injectable21, Log as Log2 } from "najm-core";
|
|
@@ -6285,16 +6319,16 @@ import { Inject as Inject21, Injectable as Injectable21, Log as Log2 } from "naj
|
|
|
6285
6319
|
import { createHash as createHash4, randomBytes as randomBytes4, timingSafeEqual } from "crypto";
|
|
6286
6320
|
import { Injectable as Injectable20 } from "najm-core";
|
|
6287
6321
|
import { CookieService as CookieService3 } from "najm-cookies";
|
|
6288
|
-
var
|
|
6322
|
+
var __decorate37 = function(decorators, target, key, desc) {
|
|
6289
6323
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6290
6324
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6291
6325
|
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;
|
|
6292
6326
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6293
6327
|
};
|
|
6294
|
-
var
|
|
6328
|
+
var __metadata37 = function(k, v) {
|
|
6295
6329
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
6296
6330
|
};
|
|
6297
|
-
var
|
|
6331
|
+
var _a23;
|
|
6298
6332
|
var _b13;
|
|
6299
6333
|
var ATTEMPT_TTL_MS = 10 * 60 * 1e3;
|
|
6300
6334
|
var COOKIE_PREFIX = "najm.oauth.google.";
|
|
@@ -6384,22 +6418,22 @@ var OAuthStateService = class OAuthStateService2 {
|
|
|
6384
6418
|
return /^[A-Za-z0-9_-]{40,128}$/.test(state);
|
|
6385
6419
|
}
|
|
6386
6420
|
};
|
|
6387
|
-
OAuthStateService =
|
|
6421
|
+
OAuthStateService = __decorate37([
|
|
6388
6422
|
Injectable20(),
|
|
6389
|
-
|
|
6423
|
+
__metadata37("design:paramtypes", [typeof (_a23 = typeof CookieService3 !== "undefined" && CookieService3) === "function" ? _a23 : Object, typeof (_b13 = typeof EncryptionService !== "undefined" && EncryptionService) === "function" ? _b13 : Object])
|
|
6390
6424
|
], OAuthStateService);
|
|
6391
6425
|
|
|
6392
6426
|
// src/oauth/OAuthService.ts
|
|
6393
|
-
var
|
|
6427
|
+
var __decorate38 = function(decorators, target, key, desc) {
|
|
6394
6428
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6395
6429
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6396
6430
|
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;
|
|
6397
6431
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6398
6432
|
};
|
|
6399
|
-
var
|
|
6433
|
+
var __metadata38 = function(k, v) {
|
|
6400
6434
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
6401
6435
|
};
|
|
6402
|
-
var
|
|
6436
|
+
var _a24;
|
|
6403
6437
|
var _b14;
|
|
6404
6438
|
var _c10;
|
|
6405
6439
|
var _d8;
|
|
@@ -6510,37 +6544,37 @@ var OAuthService = class OAuthService2 {
|
|
|
6510
6544
|
return google;
|
|
6511
6545
|
}
|
|
6512
6546
|
};
|
|
6513
|
-
|
|
6547
|
+
__decorate38([
|
|
6514
6548
|
Inject21(AUTH_CONFIG),
|
|
6515
|
-
|
|
6549
|
+
__metadata38("design:type", Object)
|
|
6516
6550
|
], OAuthService.prototype, "config", void 0);
|
|
6517
|
-
|
|
6551
|
+
__decorate38([
|
|
6518
6552
|
Log2(),
|
|
6519
|
-
|
|
6553
|
+
__metadata38("design:type", Object)
|
|
6520
6554
|
], OAuthService.prototype, "logger", void 0);
|
|
6521
|
-
OAuthService =
|
|
6555
|
+
OAuthService = __decorate38([
|
|
6522
6556
|
Injectable21(),
|
|
6523
|
-
|
|
6557
|
+
__metadata38("design:paramtypes", [typeof (_a24 = typeof OAuthStateService !== "undefined" && OAuthStateService) === "function" ? _a24 : Object, typeof (_b14 = typeof GoogleOAuthProvider !== "undefined" && GoogleOAuthProvider) === "function" ? _b14 : Object, typeof (_c10 = typeof OAuthAccountService !== "undefined" && OAuthAccountService) === "function" ? _c10 : Object, typeof (_d8 = typeof AuthSessionService !== "undefined" && AuthSessionService) === "function" ? _d8 : Object, typeof (_e5 = typeof TokenService !== "undefined" && TokenService) === "function" ? _e5 : Object, typeof (_f5 = typeof UserService !== "undefined" && UserService) === "function" ? _f5 : Object, typeof (_g4 = typeof CredentialSetupRequirementService !== "undefined" && CredentialSetupRequirementService) === "function" ? _g4 : Object])
|
|
6524
6558
|
], OAuthService);
|
|
6525
6559
|
|
|
6526
6560
|
// src/oauth/OAuthController.ts
|
|
6527
|
-
var
|
|
6561
|
+
var __decorate39 = function(decorators, target, key, desc) {
|
|
6528
6562
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6529
6563
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6530
6564
|
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;
|
|
6531
6565
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6532
6566
|
};
|
|
6533
|
-
var
|
|
6567
|
+
var __metadata39 = function(k, v) {
|
|
6534
6568
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
6535
6569
|
};
|
|
6536
|
-
var
|
|
6570
|
+
var __param13 = function(paramIndex, decorator) {
|
|
6537
6571
|
return function(target, key) {
|
|
6538
6572
|
decorator(target, key, paramIndex);
|
|
6539
6573
|
};
|
|
6540
6574
|
};
|
|
6541
|
-
var
|
|
6542
|
-
var callbackKey = /* @__PURE__ */ __name((ctx) => {
|
|
6543
|
-
const ip =
|
|
6575
|
+
var _a25;
|
|
6576
|
+
var callbackKey = /* @__PURE__ */ __name((ctx, { clientIp }) => {
|
|
6577
|
+
const ip = clientIp;
|
|
6544
6578
|
const state = ctx.req.query("state") ?? "none";
|
|
6545
6579
|
const fingerprint = createHash5("sha256").update(state).digest("base64url").slice(0, 24);
|
|
6546
6580
|
return `${ip}:${fingerprint}`;
|
|
@@ -6564,39 +6598,39 @@ var OAuthController = class OAuthController2 {
|
|
|
6564
6598
|
return this.oauth.startGoogleLink(userId, returnTo);
|
|
6565
6599
|
}
|
|
6566
6600
|
};
|
|
6567
|
-
|
|
6601
|
+
__decorate39([
|
|
6568
6602
|
Get5("/start"),
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
|
|
6603
|
+
RateLimit3({ limit: 20, window: "15m", key: "ip" }),
|
|
6604
|
+
__param13(0, Ctx2()),
|
|
6605
|
+
__param13(1, Query2("returnTo")),
|
|
6606
|
+
__metadata39("design:type", Function),
|
|
6607
|
+
__metadata39("design:paramtypes", [Object, String]),
|
|
6608
|
+
__metadata39("design:returntype", void 0)
|
|
6575
6609
|
], OAuthController.prototype, "start", null);
|
|
6576
|
-
|
|
6610
|
+
__decorate39([
|
|
6577
6611
|
Get5("/callback"),
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
|
|
6584
|
-
|
|
6585
|
-
|
|
6612
|
+
RateLimit3({ limit: 20, window: "15m", key: callbackKey }),
|
|
6613
|
+
__param13(0, Ctx2()),
|
|
6614
|
+
__param13(1, Query2("code")),
|
|
6615
|
+
__param13(2, Query2("state")),
|
|
6616
|
+
__param13(3, Query2("error")),
|
|
6617
|
+
__metadata39("design:type", Function),
|
|
6618
|
+
__metadata39("design:paramtypes", [Object, String, String, String]),
|
|
6619
|
+
__metadata39("design:returntype", Promise)
|
|
6586
6620
|
], OAuthController.prototype, "callback", null);
|
|
6587
|
-
|
|
6588
|
-
|
|
6621
|
+
__decorate39([
|
|
6622
|
+
Post6("/link"),
|
|
6589
6623
|
isAuth(),
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6624
|
+
RateLimit3({ limit: 10, window: "15m", key: "user" }),
|
|
6625
|
+
__param13(0, User5("id")),
|
|
6626
|
+
__param13(1, Query2("returnTo")),
|
|
6627
|
+
__metadata39("design:type", Function),
|
|
6628
|
+
__metadata39("design:paramtypes", [String, String]),
|
|
6629
|
+
__metadata39("design:returntype", void 0)
|
|
6596
6630
|
], OAuthController.prototype, "link", null);
|
|
6597
|
-
OAuthController =
|
|
6598
|
-
|
|
6599
|
-
|
|
6631
|
+
OAuthController = __decorate39([
|
|
6632
|
+
Controller6("/auth/oauth/google"),
|
|
6633
|
+
__metadata39("design:paramtypes", [typeof (_a25 = typeof OAuthService !== "undefined" && OAuthService) === "function" ? _a25 : Object])
|
|
6600
6634
|
], OAuthController);
|
|
6601
6635
|
|
|
6602
6636
|
// src/oauth/index.ts
|
|
@@ -6611,9 +6645,9 @@ var OAUTH_MODULE = [
|
|
|
6611
6645
|
];
|
|
6612
6646
|
|
|
6613
6647
|
// src/credentialSetup/CredentialSetupController.ts
|
|
6614
|
-
import { Body as
|
|
6615
|
-
import { RateLimit as
|
|
6616
|
-
import { Validate as
|
|
6648
|
+
import { Body as Body7, Controller as Controller7, Get as Get6, Post as Post7, ResMsg as ResMsg6 } from "najm-core";
|
|
6649
|
+
import { RateLimit as RateLimit4 } from "najm-rate";
|
|
6650
|
+
import { Validate as Validate6 } from "najm-validation";
|
|
6617
6651
|
|
|
6618
6652
|
// src/credentialSetup/CredentialSetupDto.ts
|
|
6619
6653
|
import { z as z5 } from "zod";
|
|
@@ -6623,21 +6657,21 @@ var credentialSetupChangeDto = z5.object({
|
|
|
6623
6657
|
});
|
|
6624
6658
|
|
|
6625
6659
|
// src/credentialSetup/CredentialSetupController.ts
|
|
6626
|
-
var
|
|
6660
|
+
var __decorate40 = function(decorators, target, key, desc) {
|
|
6627
6661
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6628
6662
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6629
6663
|
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;
|
|
6630
6664
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6631
6665
|
};
|
|
6632
|
-
var
|
|
6666
|
+
var __metadata40 = function(k, v) {
|
|
6633
6667
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
6634
6668
|
};
|
|
6635
|
-
var
|
|
6669
|
+
var __param14 = function(paramIndex, decorator) {
|
|
6636
6670
|
return function(target, key) {
|
|
6637
6671
|
decorator(target, key, paramIndex);
|
|
6638
6672
|
};
|
|
6639
6673
|
};
|
|
6640
|
-
var
|
|
6674
|
+
var _a26;
|
|
6641
6675
|
var CredentialSetupController = class CredentialSetupController2 {
|
|
6642
6676
|
static {
|
|
6643
6677
|
__name(this, "CredentialSetupController");
|
|
@@ -6656,35 +6690,35 @@ var CredentialSetupController = class CredentialSetupController2 {
|
|
|
6656
6690
|
return this.passwords.cancel();
|
|
6657
6691
|
}
|
|
6658
6692
|
};
|
|
6659
|
-
|
|
6693
|
+
__decorate40([
|
|
6660
6694
|
Get6("/setup"),
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6695
|
+
RateLimit4({ limit: 30, window: "15m", key: "ip" }),
|
|
6696
|
+
ResMsg6("auth.success.credentialSetupPending"),
|
|
6697
|
+
__metadata40("design:type", Function),
|
|
6698
|
+
__metadata40("design:paramtypes", []),
|
|
6699
|
+
__metadata40("design:returntype", void 0)
|
|
6666
6700
|
], CredentialSetupController.prototype, "status", null);
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
|
|
6675
|
-
|
|
6701
|
+
__decorate40([
|
|
6702
|
+
Post7("/change"),
|
|
6703
|
+
RateLimit4({ limit: 5, window: "15m", key: "ip" }),
|
|
6704
|
+
Validate6(credentialSetupChangeDto),
|
|
6705
|
+
ResMsg6("auth.success.credentialSetupPasswordReplaced"),
|
|
6706
|
+
__param14(0, Body7()),
|
|
6707
|
+
__metadata40("design:type", Function),
|
|
6708
|
+
__metadata40("design:paramtypes", [Object]),
|
|
6709
|
+
__metadata40("design:returntype", void 0)
|
|
6676
6710
|
], CredentialSetupController.prototype, "change", null);
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6711
|
+
__decorate40([
|
|
6712
|
+
Post7("/cancel"),
|
|
6713
|
+
RateLimit4({ limit: 10, window: "15m", key: "ip" }),
|
|
6714
|
+
ResMsg6("auth.success.credentialSetupCancelled"),
|
|
6715
|
+
__metadata40("design:type", Function),
|
|
6716
|
+
__metadata40("design:paramtypes", []),
|
|
6717
|
+
__metadata40("design:returntype", void 0)
|
|
6684
6718
|
], CredentialSetupController.prototype, "cancel", null);
|
|
6685
|
-
CredentialSetupController =
|
|
6686
|
-
|
|
6687
|
-
|
|
6719
|
+
CredentialSetupController = __decorate40([
|
|
6720
|
+
Controller7("/auth/credential-setup"),
|
|
6721
|
+
__metadata40("design:paramtypes", [typeof (_a26 = typeof PasswordSetupService !== "undefined" && PasswordSetupService) === "function" ? _a26 : Object])
|
|
6688
6722
|
], CredentialSetupController);
|
|
6689
6723
|
|
|
6690
6724
|
// src/credentialSetup/index.ts
|
|
@@ -6774,6 +6808,7 @@ var resolveAuthConfig = /* @__PURE__ */ __name((config) => {
|
|
|
6774
6808
|
defaultRole: config?.defaultRole ?? null,
|
|
6775
6809
|
frontendUrl: config?.frontendUrl ?? process.env.FRONTEND_URL ?? "http://localhost:3000",
|
|
6776
6810
|
registrationMode: config?.registrationMode ?? "active",
|
|
6811
|
+
publicRegistration: config?.publicRegistration ?? true,
|
|
6777
6812
|
requireVerifiedEmail: config?.requireVerifiedEmail ?? false,
|
|
6778
6813
|
refreshCookiePath: config?.refreshCookiePath ?? "/",
|
|
6779
6814
|
lockout: {
|
|
@@ -6826,7 +6861,7 @@ var selectAuthSchema = /* @__PURE__ */ __name((config) => {
|
|
|
6826
6861
|
return authSchema;
|
|
6827
6862
|
}
|
|
6828
6863
|
}, "selectAuthSchema");
|
|
6829
|
-
var auth = /* @__PURE__ */ __name((config) => plugin("auth").version("1.0.0").depends(cache(), cookies(), i18n(), guards(), validation(config?.validation), rateLimit(config?.rateLimit), email(config?.email)).requires("database").contributes(I18N_CONTRIBUTIONS, AUTH_LOCALES).services(
|
|
6864
|
+
var auth = /* @__PURE__ */ __name((config) => plugin("auth").version("1.0.0").depends(cache(config?.cache), cookies(), i18n(), guards(), validation(config?.validation), rateLimit(config?.rateLimit), email(config?.email)).requires("database").contributes(I18N_CONTRIBUTIONS, AUTH_LOCALES).services(AUTH_CORE_MODULE, config?.publicRegistration === false ? [] : PUBLIC_REGISTRATION_MODULE, OAUTH_MODULE, users_exports, roles_exports, permissions_exports, tokens_exports, CREDENTIAL_SETUP_MODULE, ScopeContext).config(AUTH_CONFIG, resolveAuthConfig(config)).set(AUTH_SCHEMA, selectAuthSchema(config)).set(AUTH_ENCRYPTION_KEY, config?.encryptionKey ?? null).build(), "auth");
|
|
6830
6865
|
|
|
6831
6866
|
// src/seed.ts
|
|
6832
6867
|
var toSeedId = /* @__PURE__ */ __name((prefix, value) => {
|
|
@@ -6959,6 +6994,7 @@ async function seedAuthData(config) {
|
|
|
6959
6994
|
__name(seedAuthData, "seedAuthData");
|
|
6960
6995
|
export {
|
|
6961
6996
|
AUTH_CONFIG,
|
|
6997
|
+
AUTH_CORE_MODULE,
|
|
6962
6998
|
en_default as AUTH_EN,
|
|
6963
6999
|
AUTH_LOCALES,
|
|
6964
7000
|
AUTH_LOGIN_RATE_LIMIT_ENV,
|
|
@@ -6999,6 +7035,7 @@ export {
|
|
|
6999
7035
|
Owned,
|
|
7000
7036
|
OwnershipToken,
|
|
7001
7037
|
PASSWORD_SETUP_PURPOSE,
|
|
7038
|
+
PUBLIC_REGISTRATION_MODULE,
|
|
7002
7039
|
PasswordSetupService,
|
|
7003
7040
|
PermissionController,
|
|
7004
7041
|
PermissionGuard,
|
|
@@ -7008,6 +7045,7 @@ export {
|
|
|
7008
7045
|
Policy,
|
|
7009
7046
|
ROLES,
|
|
7010
7047
|
ROLE_GROUPS,
|
|
7048
|
+
RegistrationController,
|
|
7011
7049
|
Role,
|
|
7012
7050
|
RoleController,
|
|
7013
7051
|
RoleGuard,
|