najm-auth 4.2.0 → 4.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 CHANGED
@@ -220,7 +220,8 @@ All routes are prefixed with `/auth` and auto-registered by the plugin.
220
220
  Applications with an approval-owned onboarding flow should set
221
221
  `publicRegistration: false`. This removes the unauthenticated route while
222
222
  retaining `AuthService.registerUser()`, `provisionUser()`, and other internal
223
- account-management APIs for trusted application services.
223
+ account-management APIs for trusted application services. The registration
224
+ controller also answers 404 when disabled if an older core mounts it anyway.
224
225
 
225
226
  ### Identity presets
226
227
 
package/dist/index.d.ts CHANGED
@@ -2170,6 +2170,7 @@ declare class AuthIdentityContextService {
2170
2170
  */
2171
2171
  declare class RegistrationController {
2172
2172
  private authService;
2173
+ private config;
2173
2174
  constructor(authService: AuthService);
2174
2175
  registerUser(body: RegisterDto): Promise<SanitizedUser>;
2175
2176
  }
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ var __export = (target, all) => {
6
6
  };
7
7
 
8
8
  // src/AuthPlugin.ts
9
- import { Err as Err16, plugin } from "najm-core";
9
+ import { Err as Err17, plugin } from "najm-core";
10
10
  import { cache } from "najm-cache";
11
11
 
12
12
  // src/auth.tokens.ts
@@ -4194,6 +4194,7 @@ var isAdmin = composeGuards(isAuth(), Role(ROLES.ADMIN));
4194
4194
  var isAdministrator = composeGuards(isAuth(), Role(ROLE_GROUPS.ADMINISTRATORS));
4195
4195
 
4196
4196
  // src/auth/AuthController.ts
4197
+ import { Public } from "najm-guard";
4197
4198
  import { Validate } from "najm-validation";
4198
4199
  import { RateLimit, UNRESOLVED_CLIENT_ADDRESS } from "najm-rate";
4199
4200
  import { createHash as createHash3 } from "crypto";
@@ -4447,6 +4448,7 @@ var AuthController = class AuthController2 {
4447
4448
  };
4448
4449
  __decorate21([
4449
4450
  Post("/login"),
4451
+ Public(),
4450
4452
  RateLimit({
4451
4453
  limit: loginRateLimit.limit,
4452
4454
  window: loginRateLimit.window,
@@ -4474,6 +4476,7 @@ __decorate21([
4474
4476
  ], AuthController.prototype, "inviteUser", null);
4475
4477
  __decorate21([
4476
4478
  Post("/refresh"),
4479
+ Public(),
4477
4480
  RateLimit({ limit: 15, window: "15m", key: cookieFingerprint() }),
4478
4481
  ResMsg("auth.success.tokenRefreshed"),
4479
4482
  __metadata21("design:type", Function),
@@ -4482,6 +4485,7 @@ __decorate21([
4482
4485
  ], AuthController.prototype, "refreshTokens", null);
4483
4486
  __decorate21([
4484
4487
  Post("/session/recover"),
4488
+ Public(),
4485
4489
  RateLimit({ limit: 120, window: "1m", key: cookieFingerprint() }),
4486
4490
  ResMsg("auth.success.sessionRecovered"),
4487
4491
  __param5(0, Headers("x-najm-session-recovery")),
@@ -4492,6 +4496,7 @@ __decorate21([
4492
4496
  ], AuthController.prototype, "recoverSession", null);
4493
4497
  __decorate21([
4494
4498
  Post("/logout"),
4499
+ Public(),
4495
4500
  __param5(0, User2("id")),
4496
4501
  __param5(1, Headers("authorization")),
4497
4502
  __metadata21("design:type", Function),
@@ -4511,6 +4516,7 @@ __decorate21([
4511
4516
  ], AuthController.prototype, "changePassword", null);
4512
4517
  __decorate21([
4513
4518
  Get("/me"),
4519
+ Public(),
4514
4520
  RateLimit({ limit: 30, window: "1m", key: cookieFingerprint() }),
4515
4521
  ResMsg("auth.users.success.retrieved"),
4516
4522
  __param5(0, Headers("authorization")),
@@ -4520,6 +4526,7 @@ __decorate21([
4520
4526
  ], AuthController.prototype, "userProfile", null);
4521
4527
  __decorate21([
4522
4528
  Post("/forgot-password"),
4529
+ Public(),
4523
4530
  RateLimit({ limit: 3, window: "15m", key: authEmailRateLimitKey, message: "Too many password reset requests. Please try again later." }),
4524
4531
  Validate(resetPasswordDto),
4525
4532
  ResMsg("auth.success.passwordResetSent"),
@@ -4530,6 +4537,7 @@ __decorate21([
4530
4537
  ], AuthController.prototype, "forgotPassword", null);
4531
4538
  __decorate21([
4532
4539
  Post("/reset-password"),
4540
+ Public(),
4533
4541
  RateLimit({ limit: 5, window: "15m", key: "ip", message: "Too many password reset attempts. Please try again later." }),
4534
4542
  Validate(confirmResetPasswordDto),
4535
4543
  ResMsg("auth.success.passwordReset"),
@@ -4744,8 +4752,9 @@ AuthIdentityContextService = __decorate23([
4744
4752
  ], AuthIdentityContextService);
4745
4753
 
4746
4754
  // src/auth/RegistrationController.ts
4747
- import { Body as Body2, Controller as Controller2, Post as Post2, ResMsg as ResMsg2 } from "najm-core";
4755
+ import { Body as Body2, Controller as Controller2, Err as Err14, Inject as Inject15, Post as Post2, ResMsg as ResMsg2 } from "najm-core";
4748
4756
  import { RateLimit as RateLimit2 } from "najm-rate";
4757
+ import { Public as Public2 } from "najm-guard";
4749
4758
  import { Validate as Validate2 } from "najm-validation";
4750
4759
  var __decorate24 = function(decorators, target, key, desc) {
4751
4760
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -4767,15 +4776,23 @@ var RegistrationController = class RegistrationController2 {
4767
4776
  __name(this, "RegistrationController");
4768
4777
  }
4769
4778
  authService;
4779
+ config;
4770
4780
  constructor(authService) {
4771
4781
  this.authService = authService;
4772
4782
  }
4773
4783
  async registerUser(body) {
4784
+ if (this.config.publicRegistration === false)
4785
+ Err14("Not Found", 404);
4774
4786
  return this.authService.registerUser(body);
4775
4787
  }
4776
4788
  };
4789
+ __decorate24([
4790
+ Inject15(AUTH_CONFIG),
4791
+ __metadata24("design:type", Object)
4792
+ ], RegistrationController.prototype, "config", void 0);
4777
4793
  __decorate24([
4778
4794
  Post2("/register"),
4795
+ Public2(),
4779
4796
  RateLimit2({ limit: 5, window: "15m", key: authEmailRateLimitKey }),
4780
4797
  Validate2(registerDto),
4781
4798
  ResMsg2("auth.success.register"),
@@ -5239,7 +5256,7 @@ __export(permissions_exports, {
5239
5256
 
5240
5257
  // src/permissions/PermissionRepository.ts
5241
5258
  import { eq as eq7, and as and4 } from "drizzle-orm";
5242
- import { Repository as Repository6, Inject as Inject15 } from "najm-core";
5259
+ import { Repository as Repository6, Inject as Inject16 } from "najm-core";
5243
5260
  import { DB as DB6 } from "najm-database";
5244
5261
  var __decorate27 = function(decorators, target, key, desc) {
5245
5262
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -5330,7 +5347,7 @@ __decorate27([
5330
5347
  __metadata27("design:type", Object)
5331
5348
  ], PermissionRepository.prototype, "db", void 0);
5332
5349
  __decorate27([
5333
- Inject15(AUTH_SCHEMA),
5350
+ Inject16(AUTH_SCHEMA),
5334
5351
  __metadata27("design:type", Object)
5335
5352
  ], PermissionRepository.prototype, "schema", void 0);
5336
5353
  PermissionRepository = __decorate27([
@@ -5407,7 +5424,7 @@ import { Injectable as Injectable15 } from "najm-core";
5407
5424
  // src/permissions/PermissionValidator.ts
5408
5425
  import { Injectable as Injectable14 } from "najm-core";
5409
5426
  import { I18n as I18n9 } from "najm-i18n";
5410
- import { Err as Err14 } from "najm-core";
5427
+ import { Err as Err15 } from "najm-core";
5411
5428
  var __decorate29 = function(decorators, target, key, desc) {
5412
5429
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5413
5430
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -5436,7 +5453,7 @@ var PermissionValidator = class PermissionValidator2 {
5436
5453
  async checkPermissionExists(id) {
5437
5454
  const permission = await this.permissionRepository.getById(id);
5438
5455
  if (!permission) {
5439
- Err14(this.t("errors.notFound"), 404);
5456
+ Err15(this.t("errors.notFound"), 404);
5440
5457
  }
5441
5458
  return permission;
5442
5459
  }
@@ -5446,7 +5463,7 @@ var PermissionValidator = class PermissionValidator2 {
5446
5463
  async checkPermissionExistsByName(name) {
5447
5464
  const permission = await this.permissionRepository.getByName(name);
5448
5465
  if (!permission) {
5449
- Err14(this.t("errors.notFound"), 404);
5466
+ Err15(this.t("errors.notFound"), 404);
5450
5467
  }
5451
5468
  return permission;
5452
5469
  }
@@ -5458,7 +5475,7 @@ var PermissionValidator = class PermissionValidator2 {
5458
5475
  return;
5459
5476
  const existingPermission = await this.permissionRepository.getByName(name);
5460
5477
  if (existingPermission && existingPermission.id !== excludeId) {
5461
- Err14(this.t("errors.nameExists"), 409);
5478
+ Err15(this.t("errors.nameExists"), 409);
5462
5479
  }
5463
5480
  }
5464
5481
  /**
@@ -5481,7 +5498,7 @@ var PermissionValidator = class PermissionValidator2 {
5481
5498
  await this.checkPermissionExists(permissionId);
5482
5499
  const hasPermission = await this.permissionRepository.checkRoleHasPermission(roleId, permissionId);
5483
5500
  if (hasPermission) {
5484
- Err14(this.t("errors.roleAlreadyHasPermission"), 409);
5501
+ Err15(this.t("errors.roleAlreadyHasPermission"), 409);
5485
5502
  }
5486
5503
  }
5487
5504
  };
@@ -6034,7 +6051,7 @@ function own(table, opts) {
6034
6051
  __name(own, "own");
6035
6052
 
6036
6053
  // src/ownership/configureOwnership.ts
6037
- import { Injectable as Injectable16, Inject as Inject16, User as User4, Body as Body6, Params as Params4 } from "najm-core";
6054
+ import { Injectable as Injectable16, Inject as Inject17, User as User4, Body as Body6, Params as Params4 } from "najm-core";
6038
6055
  import { createGuard as createGuard5, composeGuards as composeGuards4 } from "najm-guard";
6039
6056
  var __decorate32 = function(decorators, target, key, desc) {
6040
6057
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -6075,7 +6092,7 @@ function createResourceGuards(ownershipClass, resourceType, resource, options) {
6075
6092
  }
6076
6093
  };
6077
6094
  __decorate32([
6078
- Inject16(ownershipClass),
6095
+ Inject17(ownershipClass),
6079
6096
  __metadata32("design:type", Object)
6080
6097
  ], AccessGuard.prototype, "ownership", void 0);
6081
6098
  __decorate32([
@@ -6099,7 +6116,7 @@ function createResourceGuards(ownershipClass, resourceType, resource, options) {
6099
6116
  }
6100
6117
  };
6101
6118
  __decorate32([
6102
- Inject16(ownershipClass),
6119
+ Inject17(ownershipClass),
6103
6120
  __metadata32("design:type", Object)
6104
6121
  ], ListGuard.prototype, "ownership", void 0);
6105
6122
  __decorate32([
@@ -6258,7 +6275,7 @@ function configureOwnership(config) {
6258
6275
  }
6259
6276
  };
6260
6277
  __decorate32([
6261
- Inject16(GeneratedOwnershipService),
6278
+ Inject17(GeneratedOwnershipService),
6262
6279
  __metadata32("design:type", GeneratedOwnershipService)
6263
6280
  ], BodyAccessGuard.prototype, "ownership", void 0);
6264
6281
  __decorate32([
@@ -6384,7 +6401,7 @@ __name(Policy, "Policy");
6384
6401
  // src/ownership/OwnedDecorator.ts
6385
6402
  import "reflect-metadata";
6386
6403
  import { sql as sql6, and as and5 } from "drizzle-orm";
6387
- import { Injectable as Injectable17, Inject as Inject17, DI as DI3, Container as Container2, REQUEST_ID } from "najm-core";
6404
+ import { Injectable as Injectable17, Inject as Inject18, DI as DI3, Container as Container2, REQUEST_ID } from "najm-core";
6388
6405
  import { USER as USER2 } from "najm-guard";
6389
6406
 
6390
6407
  // src/ownership/ownershipCondition.ts
@@ -6449,7 +6466,7 @@ function ownedProperty(proto, key, tokens) {
6449
6466
  enumerable: false
6450
6467
  });
6451
6468
  if (!Reflect.hasOwnMetadata(OWNED_PROPERTIES, proto, "_scopeCtx")) {
6452
- Inject17(ScopeContext)(proto, "_scopeCtx");
6469
+ Inject18(ScopeContext)(proto, "_scopeCtx");
6453
6470
  Reflect.defineMetadata(OWNED_PROPERTIES, true, proto, "_scopeCtx");
6454
6471
  Object.defineProperty(proto, "_scopeCtx", {
6455
6472
  get() {
@@ -6523,7 +6540,7 @@ function Owned(token, ...alternatives) {
6523
6540
  throw new Error("@Owned requires a repository class");
6524
6541
  Reflect.defineMetadata(OWNED_META, token, target);
6525
6542
  const proto = target.prototype;
6526
- Inject17(ScopeContext)(proto, "_scopeCtx");
6543
+ Inject18(ScopeContext)(proto, "_scopeCtx");
6527
6544
  Object.defineProperty(proto, "ownershipCondition", {
6528
6545
  value() {
6529
6546
  return ownershipCondition(this.db, tokens, this._scopeCtx);
@@ -6745,7 +6762,7 @@ __name(getAuthLocale, "getAuthLocale");
6745
6762
  var AUTH_SUPPORTED_LANGUAGES = Object.keys(AUTH_LOCALES);
6746
6763
 
6747
6764
  // src/oauth/google/GoogleOAuthProvider.ts
6748
- import { Inject as Inject19, Injectable as Injectable19 } from "najm-core";
6765
+ import { Inject as Inject20, Injectable as Injectable19 } from "najm-core";
6749
6766
 
6750
6767
  // src/oauth/types.ts
6751
6768
  var OAuthFlowError = class extends Error {
@@ -6763,7 +6780,7 @@ var OAuthFlowError = class extends Error {
6763
6780
  };
6764
6781
 
6765
6782
  // src/oauth/google/GoogleTokenVerifier.ts
6766
- import { Inject as Inject18, Injectable as Injectable18 } from "najm-core";
6783
+ import { Inject as Inject19, Injectable as Injectable18 } from "najm-core";
6767
6784
  import { createRemoteJWKSet, jwtVerify } from "jose";
6768
6785
  var __decorate34 = function(decorators, target, key, desc) {
6769
6786
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -6824,7 +6841,7 @@ var GoogleTokenVerifier = class GoogleTokenVerifier2 {
6824
6841
  }
6825
6842
  };
6826
6843
  __decorate34([
6827
- Inject18(AUTH_CONFIG),
6844
+ Inject19(AUTH_CONFIG),
6828
6845
  __metadata34("design:type", Object)
6829
6846
  ], GoogleTokenVerifier.prototype, "config", void 0);
6830
6847
  GoogleTokenVerifier = __decorate34([
@@ -6910,7 +6927,7 @@ var GoogleOAuthProvider = class GoogleOAuthProvider2 {
6910
6927
  }
6911
6928
  };
6912
6929
  __decorate35([
6913
- Inject19(AUTH_CONFIG),
6930
+ Inject20(AUTH_CONFIG),
6914
6931
  __metadata35("design:type", Object)
6915
6932
  ], GoogleOAuthProvider.prototype, "config", void 0);
6916
6933
  GoogleOAuthProvider = __decorate35([
@@ -6919,7 +6936,7 @@ GoogleOAuthProvider = __decorate35([
6919
6936
  ], GoogleOAuthProvider);
6920
6937
 
6921
6938
  // src/oauth/github/GitHubOAuthProvider.ts
6922
- import { Inject as Inject20, Injectable as Injectable20 } from "najm-core";
6939
+ import { Inject as Inject21, Injectable as Injectable20 } from "najm-core";
6923
6940
  var __decorate36 = function(decorators, target, key, desc) {
6924
6941
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6925
6942
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -7043,7 +7060,7 @@ var GitHubOAuthProvider = class GitHubOAuthProvider2 {
7043
7060
  }
7044
7061
  };
7045
7062
  __decorate36([
7046
- Inject20(AUTH_CONFIG),
7063
+ Inject21(AUTH_CONFIG),
7047
7064
  __metadata36("design:type", Object)
7048
7065
  ], GitHubOAuthProvider.prototype, "config", void 0);
7049
7066
  GitHubOAuthProvider = __decorate36([
@@ -7054,18 +7071,19 @@ GitHubOAuthProvider = __decorate36([
7054
7071
  import { createHash as createHash5 } from "crypto";
7055
7072
  import { Controller as Controller6, Ctx as Ctx2, Get as Get5, Post as Post6, Query as Query2, User as User5 } from "najm-core";
7056
7073
  import { RateLimit as RateLimit3 } from "najm-rate";
7074
+ import { Public as Public3 } from "najm-guard";
7057
7075
 
7058
7076
  // src/oauth/OAuthService.ts
7059
- import { Err as Err15, Inject as Inject23, Injectable as Injectable23, Log as Log2 } from "najm-core";
7077
+ import { Err as Err16, Inject as Inject24, Injectable as Injectable23, Log as Log2 } from "najm-core";
7060
7078
 
7061
7079
  // src/oauth/OAuthAccountService.ts
7062
7080
  import { randomBytes as randomBytes3 } from "crypto";
7063
- import { Inject as Inject22, Injectable as Injectable21 } from "najm-core";
7081
+ import { Inject as Inject23, Injectable as Injectable21 } from "najm-core";
7064
7082
  import { Transaction as Transaction5 } from "najm-database";
7065
7083
 
7066
7084
  // src/oauth/OAuthAccountRepository.ts
7067
7085
  import { and as and6, eq as eq9 } from "drizzle-orm";
7068
- import { Inject as Inject21, Repository as Repository7 } from "najm-core";
7086
+ import { Inject as Inject22, Repository as Repository7 } from "najm-core";
7069
7087
  import { DB as DB7 } from "najm-database";
7070
7088
  var __decorate37 = function(decorators, target, key, desc) {
7071
7089
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -7106,7 +7124,7 @@ __decorate37([
7106
7124
  __metadata37("design:type", Object)
7107
7125
  ], OAuthAccountRepository.prototype, "db", void 0);
7108
7126
  __decorate37([
7109
- Inject21(AUTH_SCHEMA),
7127
+ Inject22(AUTH_SCHEMA),
7110
7128
  __metadata37("design:type", Object)
7111
7129
  ], OAuthAccountRepository.prototype, "schema", void 0);
7112
7130
  OAuthAccountRepository = __decorate37([
@@ -7203,7 +7221,7 @@ var OAuthAccountService = class OAuthAccountService2 {
7203
7221
  }
7204
7222
  };
7205
7223
  __decorate38([
7206
- Inject22(AUTH_CONFIG),
7224
+ Inject23(AUTH_CONFIG),
7207
7225
  __metadata38("design:type", Object)
7208
7226
  ], OAuthAccountService.prototype, "config", void 0);
7209
7227
  __decorate38([
@@ -7407,7 +7425,7 @@ var OAuthService = class OAuthService2 {
7407
7425
  */
7408
7426
  failStart(error) {
7409
7427
  if (error instanceof OAuthFlowError) {
7410
- Err15(error.oauthCode, error.status);
7428
+ Err16(error.oauthCode, error.status);
7411
7429
  }
7412
7430
  throw error;
7413
7431
  }
@@ -7514,7 +7532,7 @@ var OAuthService = class OAuthService2 {
7514
7532
  }
7515
7533
  };
7516
7534
  __decorate40([
7517
- Inject23(AUTH_CONFIG),
7535
+ Inject24(AUTH_CONFIG),
7518
7536
  __metadata40("design:type", Object)
7519
7537
  ], OAuthService.prototype, "config", void 0);
7520
7538
  __decorate40([
@@ -7568,6 +7586,7 @@ var GitHubOAuthController = class GitHubOAuthController2 {
7568
7586
  };
7569
7587
  __decorate41([
7570
7588
  Get5("/start"),
7589
+ Public3(),
7571
7590
  RateLimit3({ limit: 20, window: "15m", key: "ip" }),
7572
7591
  __param13(0, Ctx2()),
7573
7592
  __param13(1, Query2("returnTo")),
@@ -7577,6 +7596,7 @@ __decorate41([
7577
7596
  ], GitHubOAuthController.prototype, "start", null);
7578
7597
  __decorate41([
7579
7598
  Get5("/callback"),
7599
+ Public3(),
7580
7600
  RateLimit3({ limit: 20, window: "15m", key: callbackKey }),
7581
7601
  __param13(0, Ctx2()),
7582
7602
  __param13(1, Query2("code")),
@@ -7605,6 +7625,7 @@ GitHubOAuthController = __decorate41([
7605
7625
  import { createHash as createHash6 } from "crypto";
7606
7626
  import { Controller as Controller7, Ctx as Ctx3, Get as Get6, Post as Post7, Query as Query3, User as User6 } from "najm-core";
7607
7627
  import { RateLimit as RateLimit4 } from "najm-rate";
7628
+ import { Public as Public4 } from "najm-guard";
7608
7629
  var __decorate42 = function(decorators, target, key, desc) {
7609
7630
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7610
7631
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -7647,6 +7668,7 @@ var OAuthController = class OAuthController2 {
7647
7668
  };
7648
7669
  __decorate42([
7649
7670
  Get6("/start"),
7671
+ Public4(),
7650
7672
  RateLimit4({ limit: 20, window: "15m", key: "ip" }),
7651
7673
  __param14(0, Ctx3()),
7652
7674
  __param14(1, Query3("returnTo")),
@@ -7656,6 +7678,7 @@ __decorate42([
7656
7678
  ], OAuthController.prototype, "start", null);
7657
7679
  __decorate42([
7658
7680
  Get6("/callback"),
7681
+ Public4(),
7659
7682
  RateLimit4({ limit: 20, window: "15m", key: callbackKey2 }),
7660
7683
  __param14(0, Ctx3()),
7661
7684
  __param14(1, Query3("code")),
@@ -7696,6 +7719,7 @@ var OAUTH_MODULE = [
7696
7719
  // src/credentialSetup/CredentialSetupController.ts
7697
7720
  import { Body as Body7, Controller as Controller8, Get as Get7, Post as Post8, ResMsg as ResMsg6 } from "najm-core";
7698
7721
  import { RateLimit as RateLimit5 } from "najm-rate";
7722
+ import { Public as Public5 } from "najm-guard";
7699
7723
  import { Validate as Validate6 } from "najm-validation";
7700
7724
 
7701
7725
  // src/credentialSetup/CredentialSetupDto.ts
@@ -7741,6 +7765,7 @@ var CredentialSetupController = class CredentialSetupController2 {
7741
7765
  };
7742
7766
  __decorate43([
7743
7767
  Get7("/setup"),
7768
+ Public5(),
7744
7769
  RateLimit5({ limit: 30, window: "15m", key: "ip" }),
7745
7770
  ResMsg6("auth.success.credentialSetupPending"),
7746
7771
  __metadata43("design:type", Function),
@@ -7749,6 +7774,7 @@ __decorate43([
7749
7774
  ], CredentialSetupController.prototype, "status", null);
7750
7775
  __decorate43([
7751
7776
  Post8("/change"),
7777
+ Public5(),
7752
7778
  RateLimit5({ limit: 5, window: "15m", key: "ip" }),
7753
7779
  Validate6(credentialSetupChangeDto),
7754
7780
  ResMsg6("auth.success.credentialSetupPasswordReplaced"),
@@ -7759,6 +7785,7 @@ __decorate43([
7759
7785
  ], CredentialSetupController.prototype, "change", null);
7760
7786
  __decorate43([
7761
7787
  Post8("/cancel"),
7788
+ Public5(),
7762
7789
  RateLimit5({ limit: 10, window: "15m", key: "ip" }),
7763
7790
  ResMsg6("auth.success.credentialSetupCancelled"),
7764
7791
  __metadata43("design:type", Function),
@@ -7821,9 +7848,9 @@ var resolveGoogleConfig = /* @__PURE__ */ __name((config) => {
7821
7848
  const clientId = google.clientId ?? process.env.GOOGLE_CLIENT_ID ?? "";
7822
7849
  const clientSecret = google.clientSecret ?? process.env.GOOGLE_CLIENT_SECRET ?? "";
7823
7850
  if (!clientId)
7824
- throw Err16.configRequired("auth.oauth.google", "GOOGLE_CLIENT_ID");
7851
+ throw Err17.configRequired("auth.oauth.google", "GOOGLE_CLIENT_ID");
7825
7852
  if (!clientSecret)
7826
- throw Err16.configRequired("auth.oauth.google", "GOOGLE_CLIENT_SECRET");
7853
+ throw Err17.configRequired("auth.oauth.google", "GOOGLE_CLIENT_SECRET");
7827
7854
  const frontendUrl = config?.frontendUrl ?? process.env.FRONTEND_URL ?? "http://localhost:3000";
7828
7855
  const callbackUrl = google.callbackUrl ?? process.env.GOOGLE_CALLBACK_URL ?? `${frontendUrl.replace(/\/$/, "")}/api/auth/oauth/google/callback`;
7829
7856
  return {
@@ -7845,9 +7872,9 @@ var resolveGitHubConfig = /* @__PURE__ */ __name((config) => {
7845
7872
  const clientId = github.clientId ?? process.env.GITHUB_CLIENT_ID ?? "";
7846
7873
  const clientSecret = github.clientSecret ?? process.env.GITHUB_CLIENT_SECRET ?? "";
7847
7874
  if (!clientId)
7848
- throw Err16.configRequired("auth.oauth.github", "GITHUB_CLIENT_ID");
7875
+ throw Err17.configRequired("auth.oauth.github", "GITHUB_CLIENT_ID");
7849
7876
  if (!clientSecret)
7850
- throw Err16.configRequired("auth.oauth.github", "GITHUB_CLIENT_SECRET");
7877
+ throw Err17.configRequired("auth.oauth.github", "GITHUB_CLIENT_SECRET");
7851
7878
  const frontendUrl = config?.frontendUrl ?? process.env.FRONTEND_URL ?? "http://localhost:3000";
7852
7879
  const callbackUrl = github.callbackUrl ?? process.env.GITHUB_CALLBACK_URL ?? `${frontendUrl.replace(/\/$/, "")}/api/auth/oauth/github/callback`;
7853
7880
  return {
@@ -7917,10 +7944,10 @@ var resolveAuthConfig = /* @__PURE__ */ __name((config) => {
7917
7944
  }
7918
7945
  };
7919
7946
  if (!finalConfig.jwt.accessSecret) {
7920
- throw Err16.configRequired("auth", "JWT_ACCESS_SECRET");
7947
+ throw Err17.configRequired("auth", "JWT_ACCESS_SECRET");
7921
7948
  }
7922
7949
  if (!finalConfig.jwt.refreshSecret) {
7923
- throw Err16.configRequired("auth", "JWT_REFRESH_SECRET");
7950
+ throw Err17.configRequired("auth", "JWT_REFRESH_SECRET");
7924
7951
  }
7925
7952
  return finalConfig;
7926
7953
  }, "resolveAuthConfig");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "najm-auth",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "description": "Authentication and authorization library for najm framework",
5
5
  "type": "module",
6
6
  "files": [
@@ -92,9 +92,9 @@
92
92
  "dependencies": {
93
93
  "bcryptjs": "^3.0.2",
94
94
  "najm-cookies": "^2.0.2",
95
- "najm-core": "^2.1.0",
95
+ "najm-core": "^3.0.0",
96
96
  "najm-database": "^2.0.4",
97
- "najm-guard": "^2.0.2",
97
+ "najm-guard": "^2.1.0",
98
98
  "najm-i18n": "^2.1.2",
99
99
  "najm-cache": "^2.2.0",
100
100
  "najm-email": "^2.0.4",