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