@vritti/api-sdk 0.3.11 → 0.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/auth.cjs CHANGED
@@ -31,18 +31,24 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  // src/auth/index.ts
32
32
  var auth_exports = {};
33
33
  __export(auth_exports, {
34
+ APP_SESSION_TYPE: () => APP_SESSION_TYPE,
34
35
  AUTH_CONFIG: () => AUTH_CONFIG,
35
36
  AUTH_CONFIG_DEFAULTS: () => AUTH_CONFIG_DEFAULTS,
36
37
  AccessToken: () => AccessToken,
37
38
  AuthConfigModule: () => AuthConfigModule,
39
+ CLIENT_ID_HEADER: () => CLIENT_ID_HEADER,
38
40
  ClientIp: () => ClientIp,
39
41
  CookieDomain: () => CookieDomain,
40
42
  CookieName: () => CookieName,
41
43
  Hostname: () => Hostname,
44
+ MAX_CLOCK_SKEW_SECONDS: () => MAX_CLOCK_SKEW_SECONDS,
45
+ PARTY_ID_HEADER: () => PARTY_ID_HEADER,
42
46
  Public: () => Public,
47
+ REQUIRE_APP_KEY: () => REQUIRE_APP_KEY,
43
48
  REQUIRE_SESSION_KEY: () => REQUIRE_SESSION_KEY,
44
49
  RefreshCookieOptions: () => RefreshCookieOptions,
45
50
  RefreshTokenCookie: () => RefreshTokenCookie,
51
+ RequireApp: () => RequireApp,
46
52
  RequireSession: () => RequireSession,
47
53
  SKIP_CSRF_KEY: () => SKIP_CSRF_KEY,
48
54
  SessionData: () => SessionData,
@@ -53,11 +59,27 @@ __export(auth_exports, {
53
59
  UserAgent: () => UserAgent,
54
60
  UserId: () => UserId,
55
61
  VrittiAuthGuard: () => VrittiAuthGuard,
62
+ WORKSPACE_HEADER_ORDER: () => WORKSPACE_HEADER_ORDER,
56
63
  hashToken: () => hashToken,
57
64
  verifyTokenHash: () => verifyTokenHash
58
65
  });
59
66
  module.exports = __toCommonJS(auth_exports);
60
67
 
68
+ // src/signing/request.ts
69
+ var import_node_crypto = require("crypto");
70
+ var WORKSPACE_HEADER_ORDER = [
71
+ "x-site-id",
72
+ "x-sg-id",
73
+ "x-le-id",
74
+ "x-org-id"
75
+ ];
76
+
77
+ // src/auth/app-request.ts
78
+ var CLIENT_ID_HEADER = "x-vritti-client-id";
79
+ var PARTY_ID_HEADER = "x-party-id";
80
+ var MAX_CLOCK_SKEW_SECONDS = 300;
81
+ var APP_SESSION_TYPE = "APP";
82
+
61
83
  // src/auth/auth.config.ts
62
84
  var AUTH_CONFIG = Symbol("AUTH_CONFIG");
63
85
  var AUTH_CONFIG_DEFAULTS = {
@@ -84,7 +106,7 @@ var TokenType = /* @__PURE__ */ (function(TokenType2) {
84
106
  })({});
85
107
 
86
108
  // src/auth/auth-config.module.ts
87
- var import_common7 = require("@nestjs/common");
109
+ var import_common8 = require("@nestjs/common");
88
110
  var import_config = require("@nestjs/config");
89
111
  var import_core3 = require("@nestjs/core");
90
112
  var import_jwt2 = require("@nestjs/jwt");
@@ -174,6 +196,46 @@ var RequestService = class {
174
196
  getAllHeaders() {
175
197
  return this.request.headers || {};
176
198
  }
199
+ // Returns the HTTP method
200
+ getMethod() {
201
+ return this.request.method ?? "";
202
+ }
203
+ /**
204
+ * Returns the path with any query string stripped.
205
+ *
206
+ * Signature canonicals cover the path only, so a query string must not be part
207
+ * of what gets signed or verified.
208
+ */
209
+ getPath() {
210
+ const url = this.request.url ?? "";
211
+ return url.split("?")[0] ?? url;
212
+ }
213
+ /**
214
+ * Returns the raw query string, without the leading `?`.
215
+ *
216
+ * Companion to `getPath()`, which strips it. Signed separately so a REST request's
217
+ * filters are covered — `getPath()` alone would sign `GET /people?search=salt` as
218
+ * though the filter were not there.
219
+ */
220
+ getQuery() {
221
+ const url = this.request.url ?? "";
222
+ const index = url.indexOf("?");
223
+ return index === -1 ? "" : url.slice(index + 1);
224
+ }
225
+ /**
226
+ * Returns the raw request body, as `fastify-raw-body` leaves it.
227
+ *
228
+ * Read structurally rather than through a module augmentation: that plugin is the
229
+ * consuming server's dependency, not this SDK's, and declaring `rawBody` here
230
+ * would collide with the plugin's own declaration the moment the two drift.
231
+ *
232
+ * A server that has not registered it yields `undefined`, which hashes as an empty
233
+ * body and therefore fails any signature made over real bytes — refused, never
234
+ * waved through.
235
+ */
236
+ getRawBody() {
237
+ return this.request.rawBody;
238
+ }
177
239
  };
178
240
  RequestService = _ts_decorate([
179
241
  (0, import_common.Injectable)({
@@ -214,7 +276,7 @@ RequestModule = _ts_decorate2([
214
276
  ], RequestModule);
215
277
 
216
278
  // src/auth/guards/vritti-auth.guard.ts
217
- var import_common6 = require("@nestjs/common");
279
+ var import_common7 = require("@nestjs/common");
218
280
  var import_constants = require("@nestjs/common/constants");
219
281
  var import_core2 = require("@nestjs/core");
220
282
 
@@ -258,18 +320,23 @@ function getResponseFromContext(host) {
258
320
  }
259
321
  __name(getResponseFromContext, "getResponseFromContext");
260
322
 
261
- // src/auth/decorators/require-session.decorator.ts
323
+ // src/auth/decorators/require-app.decorator.ts
262
324
  var import_common3 = require("@nestjs/common");
325
+ var REQUIRE_APP_KEY = "requiredAppTypes";
326
+ var RequireApp = /* @__PURE__ */ __name((...types) => (0, import_common3.SetMetadata)(REQUIRE_APP_KEY, types), "RequireApp");
327
+
328
+ // src/auth/decorators/require-session.decorator.ts
329
+ var import_common4 = require("@nestjs/common");
263
330
  var REQUIRE_SESSION_KEY = "requiredSessionTypes";
264
- var RequireSession = /* @__PURE__ */ __name((...types) => (0, import_common3.SetMetadata)(REQUIRE_SESSION_KEY, types), "RequireSession");
331
+ var RequireSession = /* @__PURE__ */ __name((...types) => (0, import_common4.SetMetadata)(REQUIRE_SESSION_KEY, types), "RequireSession");
265
332
 
266
333
  // src/auth/decorators/skip-csrf.decorator.ts
267
- var import_common4 = require("@nestjs/common");
334
+ var import_common5 = require("@nestjs/common");
268
335
  var SKIP_CSRF_KEY = "skipCsrf";
269
- var SkipCsrf = /* @__PURE__ */ __name(() => (0, import_common4.SetMetadata)(SKIP_CSRF_KEY, true), "SkipCsrf");
336
+ var SkipCsrf = /* @__PURE__ */ __name(() => (0, import_common5.SetMetadata)(SKIP_CSRF_KEY, true), "SkipCsrf");
270
337
 
271
338
  // src/auth/services/token.service.ts
272
- var import_common5 = require("@nestjs/common");
339
+ var import_common6 = require("@nestjs/common");
273
340
  var import_jwt = require("@nestjs/jwt");
274
341
 
275
342
  // src/utils/time.utils.ts
@@ -329,7 +396,7 @@ var TokenService = class _TokenService {
329
396
  }
330
397
  jwtService;
331
398
  config;
332
- logger = new import_common5.Logger(_TokenService.name);
399
+ logger = new import_common6.Logger(_TokenService.name);
333
400
  constructor(jwtService, config) {
334
401
  this.jwtService = jwtService;
335
402
  this.config = config;
@@ -393,21 +460,21 @@ var TokenService = class _TokenService {
393
460
  try {
394
461
  const decoded = this.jwtService.verify(token);
395
462
  if (decoded.tokenType !== TokenType.ACCESS) {
396
- throw new import_common5.UnauthorizedException("Invalid token type");
463
+ throw new import_common6.UnauthorizedException("Invalid token type");
397
464
  }
398
465
  return decoded;
399
466
  } catch (error) {
400
- if (error instanceof import_common5.UnauthorizedException) throw error;
467
+ if (error instanceof import_common6.UnauthorizedException) throw error;
401
468
  const jwtError = error;
402
469
  switch (jwtError.name) {
403
470
  case "TokenExpiredError":
404
- throw new import_common5.UnauthorizedException("Access token has expired");
471
+ throw new import_common6.UnauthorizedException("Access token has expired");
405
472
  case "JsonWebTokenError":
406
- throw new import_common5.UnauthorizedException("Invalid access token");
473
+ throw new import_common6.UnauthorizedException("Invalid access token");
407
474
  case "NotBeforeError":
408
- throw new import_common5.UnauthorizedException("Access token not yet valid");
475
+ throw new import_common6.UnauthorizedException("Access token not yet valid");
409
476
  default:
410
- throw new import_common5.UnauthorizedException("Access token validation failed");
477
+ throw new import_common6.UnauthorizedException("Access token validation failed");
411
478
  }
412
479
  }
413
480
  }
@@ -416,24 +483,24 @@ var TokenService = class _TokenService {
416
483
  try {
417
484
  const decoded = this.jwtService.verify(token);
418
485
  if (decoded.tokenType !== TokenType.REFRESH) {
419
- throw new import_common5.UnauthorizedException("Invalid token type");
486
+ throw new import_common6.UnauthorizedException("Invalid token type");
420
487
  }
421
488
  return decoded;
422
489
  } catch (error) {
423
- if (error instanceof import_common5.UnauthorizedException) throw error;
424
- throw new import_common5.UnauthorizedException("Invalid or expired session");
490
+ if (error instanceof import_common6.UnauthorizedException) throw error;
491
+ throw new import_common6.UnauthorizedException("Invalid or expired session");
425
492
  }
426
493
  }
427
494
  // Validates that the access token is bound to the refresh token
428
495
  validateTokenBinding(accessToken, refreshToken) {
429
496
  if (!verifyTokenHash(refreshToken, accessToken.refreshTokenHash)) {
430
- throw new import_common5.UnauthorizedException("Session validation failed");
497
+ throw new import_common6.UnauthorizedException("Session validation failed");
431
498
  }
432
499
  }
433
500
  };
434
501
  TokenService = _ts_decorate3([
435
- (0, import_common5.Injectable)(),
436
- _ts_param2(1, (0, import_common5.Inject)(AUTH_CONFIG)),
502
+ (0, import_common6.Injectable)(),
503
+ _ts_param2(1, (0, import_common6.Inject)(AUTH_CONFIG)),
437
504
  _ts_metadata2("design:type", Function),
438
505
  _ts_metadata2("design:paramtypes", [
439
506
  typeof import_jwt.JwtService === "undefined" ? Object : import_jwt.JwtService,
@@ -467,7 +534,7 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
467
534
  requestService;
468
535
  tokenService;
469
536
  config;
470
- logger = new import_common6.Logger(_VrittiAuthGuard.name);
537
+ logger = new import_common7.Logger(_VrittiAuthGuard.name);
471
538
  constructor(reflector, requestService, tokenService, config) {
472
539
  this.reflector = reflector;
473
540
  this.requestService = requestService;
@@ -484,6 +551,13 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
484
551
  context.getHandler(),
485
552
  context.getClass()
486
553
  ]) || csrfExemptTransports.includes(context.getType());
554
+ const requiredAppTypes = this.reflector.getAllAndOverride(REQUIRE_APP_KEY, [
555
+ context.getHandler(),
556
+ context.getClass()
557
+ ]);
558
+ if (requiredAppTypes) {
559
+ return this.handleAppAuth(request, requiredAppTypes, route);
560
+ }
487
561
  const isPublic = this.reflector.getAllAndOverride("isPublic", [
488
562
  context.getHandler(),
489
563
  context.getClass()
@@ -511,26 +585,59 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
511
585
  }
512
586
  return true;
513
587
  }
588
+ /**
589
+ * Authenticates a signed request from an external app.
590
+ *
591
+ * The credential lookup and the signature check are the consuming server's job —
592
+ * it is the only side with a database — so this delegates to
593
+ * `guard.onAuthenticated`, the same hook the session path already uses to resolve
594
+ * organization and workspace context. That server fills in `organizationId`,
595
+ * `appType` and whatever else it knows.
596
+ *
597
+ * What stays here is the part only this side can do: reading the decorator's
598
+ * metadata and enforcing the app-type filter against what the server resolved.
599
+ *
600
+ * An empty list means "any type" — the caller is still authenticated. That makes
601
+ * `@RequireApp()` with no arguments mean what it reads like.
602
+ */
603
+ async handleAppAuth(request, requiredAppTypes, route) {
604
+ const onAuthenticated = this.config.guard.onAuthenticated;
605
+ if (!onAuthenticated) {
606
+ this.logger.error(`${route} \u2014 @RequireApp() requires guard.onAuthenticated to be configured`);
607
+ throw new import_common7.UnauthorizedException("App authentication is not configured");
608
+ }
609
+ const sessionInfo = {
610
+ sessionType: APP_SESSION_TYPE
611
+ };
612
+ request.sessionInfo = sessionInfo;
613
+ await onAuthenticated(this.requestService, sessionInfo);
614
+ if (requiredAppTypes.length && !requiredAppTypes.includes(sessionInfo.appType ?? "")) {
615
+ this.logger.warn(`${route} \u2014 app type ${sessionInfo.appType ?? "unknown"} not in allowed: [${requiredAppTypes.join(", ")}]`);
616
+ throw new import_common7.UnauthorizedException("This client is not recognised.");
617
+ }
618
+ this.logger.debug(`${route} \u2014 authenticated app (${sessionInfo.appType})`);
619
+ return true;
620
+ }
514
621
  // Authenticates standard HTTP requests using the access token from Authorization header
515
622
  async handleHttpAuth(request, requiredSessionTypes) {
516
623
  const route = `${request.method} ${request.url}`;
517
624
  const accessToken = this.requestService.getAccessToken();
518
625
  if (!accessToken) {
519
626
  this.logger.warn(`${route} \u2014 no access token found`);
520
- throw new import_common6.UnauthorizedException("Access token not found");
627
+ throw new import_common7.UnauthorizedException("Access token not found");
521
628
  }
522
629
  const decoded = this.tokenService.validateAccessToken(accessToken);
523
630
  const refreshTokenBindingExemptSessionTypes = this.config.guard.refreshTokenBindingExemptSessionTypes ?? [];
524
631
  if (!refreshTokenBindingExemptSessionTypes.includes(decoded.sessionType)) {
525
632
  const refreshToken = this.requestService.getRefreshToken();
526
633
  if (!refreshToken) {
527
- throw new import_common6.UnauthorizedException("Session validation failed");
634
+ throw new import_common7.UnauthorizedException("Session validation failed");
528
635
  }
529
636
  this.tokenService.validateTokenBinding(decoded, refreshToken);
530
637
  }
531
638
  if (requiredSessionTypes?.length && !requiredSessionTypes.includes(decoded.sessionType)) {
532
639
  this.logger.warn(`${route} \u2014 session type ${decoded.sessionType} not in allowed: [${requiredSessionTypes.join(", ")}]`);
533
- throw new import_common6.UnauthorizedException(`${decoded.sessionType} sessions cannot access this endpoint`);
640
+ throw new import_common7.UnauthorizedException(`${decoded.sessionType} sessions cannot access this endpoint`);
534
641
  }
535
642
  const { tokenType: _tokenType, refreshTokenHash: _hash, exp: _exp, iat: _iat, ...sessionInfo } = decoded;
536
643
  request.sessionInfo = sessionInfo;
@@ -546,12 +653,12 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
546
653
  const refreshToken = this.requestService.getRefreshToken();
547
654
  if (!refreshToken) {
548
655
  this.logger.warn(`SSE ${request.url} \u2014 no refresh token cookie`);
549
- throw new import_common6.UnauthorizedException("Authentication required");
656
+ throw new import_common7.UnauthorizedException("Authentication required");
550
657
  }
551
658
  const decoded = this.tokenService.validateRefreshToken(refreshToken);
552
659
  if (requiredSessionTypes?.length && !requiredSessionTypes.includes(decoded.sessionType)) {
553
660
  this.logger.warn(`SSE ${request.url} \u2014 session type ${decoded.sessionType} not allowed`);
554
- throw new import_common6.UnauthorizedException(`${decoded.sessionType} sessions cannot access this endpoint`);
661
+ throw new import_common7.UnauthorizedException(`${decoded.sessionType} sessions cannot access this endpoint`);
555
662
  }
556
663
  const { tokenType: _tokenType, exp: _exp, iat: _iat, ...sessionInfo } = decoded;
557
664
  request.sessionInfo = sessionInfo;
@@ -570,7 +677,7 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
570
677
  const fastifyInstance = request.server;
571
678
  const csrfProtection = fastifyInstance.csrfProtection;
572
679
  if (!csrfProtection) {
573
- throw new import_common6.ForbiddenException("CSRF protection not configured");
680
+ throw new import_common7.ForbiddenException("CSRF protection not configured");
574
681
  }
575
682
  await new Promise((resolve, reject) => {
576
683
  const originalSend = reply.send.bind(reply);
@@ -587,7 +694,7 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
587
694
  });
588
695
  } catch (_error) {
589
696
  this.logger.warn(`${request.method} ${request.url} \u2014 CSRF validation failed`);
590
- throw new import_common6.ForbiddenException({
697
+ throw new import_common7.ForbiddenException({
591
698
  errors: [
592
699
  {
593
700
  field: "csrf",
@@ -600,10 +707,10 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
600
707
  }
601
708
  };
602
709
  VrittiAuthGuard = _ts_decorate4([
603
- (0, import_common6.Injectable)({
604
- scope: import_common6.Scope.REQUEST
710
+ (0, import_common7.Injectable)({
711
+ scope: import_common7.Scope.REQUEST
605
712
  }),
606
- _ts_param3(3, (0, import_common6.Inject)(AUTH_CONFIG)),
713
+ _ts_param3(3, (0, import_common7.Inject)(AUTH_CONFIG)),
607
714
  _ts_metadata3("design:type", Function),
608
715
  _ts_metadata3("design:paramtypes", [
609
716
  typeof import_core2.Reflector === "undefined" ? Object : import_core2.Reflector,
@@ -646,6 +753,7 @@ var AuthConfigModule = class _AuthConfigModule {
646
753
  imports: [
647
754
  import_config.ConfigModule,
648
755
  RequestModule,
756
+ ...options.imports ?? [],
649
757
  import_jwt2.JwtModule.registerAsync({
650
758
  imports: [
651
759
  import_config.ConfigModule
@@ -689,27 +797,27 @@ var AuthConfigModule = class _AuthConfigModule {
689
797
  }
690
798
  };
691
799
  AuthConfigModule = _ts_decorate5([
692
- (0, import_common7.Global)(),
693
- (0, import_common7.Module)({})
800
+ (0, import_common8.Global)(),
801
+ (0, import_common8.Module)({})
694
802
  ], AuthConfigModule);
695
803
 
696
804
  // src/auth/decorators/access-token.decorator.ts
697
- var import_common8 = require("@nestjs/common");
698
- var AccessToken = (0, import_common8.createParamDecorator)((_data, ctx) => {
805
+ var import_common9 = require("@nestjs/common");
806
+ var AccessToken = (0, import_common9.createParamDecorator)((_data, ctx) => {
699
807
  const request = getRequestFromContext(ctx);
700
808
  const authHeader = request.headers.authorization;
701
809
  return authHeader?.replace("Bearer ", "") || "";
702
810
  });
703
811
 
704
812
  // src/auth/decorators/client-ip.decorator.ts
705
- var import_common9 = require("@nestjs/common");
706
- var ClientIp = (0, import_common9.createParamDecorator)((_data, ctx) => {
813
+ var import_common10 = require("@nestjs/common");
814
+ var ClientIp = (0, import_common10.createParamDecorator)((_data, ctx) => {
707
815
  return getRequestFromContext(ctx).ip;
708
816
  });
709
817
 
710
818
  // src/auth/decorators/cookie-domain.decorator.ts
711
- var import_common10 = require("@nestjs/common");
712
- var CookieDomain = (0, import_common10.createParamDecorator)((_data, ctx) => {
819
+ var import_common11 = require("@nestjs/common");
820
+ var CookieDomain = (0, import_common11.createParamDecorator)((_data, ctx) => {
713
821
  const request = getRequestFromContext(ctx);
714
822
  const forwarded = request.headers["x-forwarded-host"];
715
823
  const raw = Array.isArray(forwarded) ? forwarded[0] : forwarded;
@@ -720,15 +828,15 @@ var CookieDomain = (0, import_common10.createParamDecorator)((_data, ctx) => {
720
828
  });
721
829
 
722
830
  // src/auth/decorators/cookie-name.decorator.ts
723
- var import_common11 = require("@nestjs/common");
724
- var CookieName = (0, import_common11.createParamDecorator)((_data, ctx) => {
831
+ var import_common12 = require("@nestjs/common");
832
+ var CookieName = (0, import_common12.createParamDecorator)((_data, ctx) => {
725
833
  const request = getRequestFromContext(ctx);
726
834
  return request.authConfig?.cookie.refreshCookieName ?? AUTH_CONFIG_DEFAULTS.cookie.refreshCookieName;
727
835
  });
728
836
 
729
837
  // src/auth/decorators/hostname.decorator.ts
730
- var import_common12 = require("@nestjs/common");
731
- var Hostname = (0, import_common12.createParamDecorator)((_data, ctx) => {
838
+ var import_common13 = require("@nestjs/common");
839
+ var Hostname = (0, import_common13.createParamDecorator)((_data, ctx) => {
732
840
  const request = getRequestFromContext(ctx);
733
841
  const forwarded = request.headers["x-forwarded-host"];
734
842
  const raw = Array.isArray(forwarded) ? forwarded[0] : forwarded;
@@ -737,18 +845,18 @@ var Hostname = (0, import_common12.createParamDecorator)((_data, ctx) => {
737
845
  });
738
846
 
739
847
  // src/auth/decorators/public.decorator.ts
740
- var import_common13 = require("@nestjs/common");
741
- var Public = /* @__PURE__ */ __name(() => (0, import_common13.SetMetadata)("isPublic", true), "Public");
848
+ var import_common14 = require("@nestjs/common");
849
+ var Public = /* @__PURE__ */ __name(() => (0, import_common14.SetMetadata)("isPublic", true), "Public");
742
850
 
743
851
  // src/auth/decorators/refresh-cookie-options.decorator.ts
744
- var import_common33 = require("@nestjs/common");
852
+ var import_common34 = require("@nestjs/common");
745
853
 
746
854
  // src/exceptions/bad-gateway.exception.ts
747
- var import_common15 = require("@nestjs/common");
855
+ var import_common16 = require("@nestjs/common");
748
856
 
749
857
  // src/exceptions/base-field.exception.ts
750
- var import_common14 = require("@nestjs/common");
751
- var HttpProblemException = class extends import_common14.HttpException {
858
+ var import_common15 = require("@nestjs/common");
859
+ var HttpProblemException = class extends import_common15.HttpException {
752
860
  static {
753
861
  __name(this, "HttpProblemException");
754
862
  }
@@ -766,63 +874,63 @@ var HttpProblemException = class extends import_common14.HttpException {
766
874
  };
767
875
 
768
876
  // src/exceptions/bad-request.exception.ts
769
- var import_common16 = require("@nestjs/common");
877
+ var import_common17 = require("@nestjs/common");
770
878
 
771
879
  // src/exceptions/conflict.exception.ts
772
- var import_common17 = require("@nestjs/common");
880
+ var import_common18 = require("@nestjs/common");
773
881
 
774
882
  // src/exceptions/forbidden.exception.ts
775
- var import_common18 = require("@nestjs/common");
883
+ var import_common19 = require("@nestjs/common");
776
884
 
777
885
  // src/exceptions/gone.exception.ts
778
- var import_common19 = require("@nestjs/common");
886
+ var import_common20 = require("@nestjs/common");
779
887
 
780
888
  // src/exceptions/internal-server-error.exception.ts
781
- var import_common20 = require("@nestjs/common");
889
+ var import_common21 = require("@nestjs/common");
782
890
 
783
891
  // src/exceptions/method-not-allowed.exception.ts
784
- var import_common21 = require("@nestjs/common");
892
+ var import_common22 = require("@nestjs/common");
785
893
 
786
894
  // src/exceptions/not-acceptable.exception.ts
787
- var import_common22 = require("@nestjs/common");
895
+ var import_common23 = require("@nestjs/common");
788
896
 
789
897
  // src/exceptions/not-found.exception.ts
790
- var import_common23 = require("@nestjs/common");
898
+ var import_common24 = require("@nestjs/common");
791
899
 
792
900
  // src/exceptions/not-implemented.exception.ts
793
- var import_common24 = require("@nestjs/common");
901
+ var import_common25 = require("@nestjs/common");
794
902
 
795
903
  // src/exceptions/payload-too-large.exception.ts
796
- var import_common25 = require("@nestjs/common");
904
+ var import_common26 = require("@nestjs/common");
797
905
 
798
906
  // src/exceptions/request-timeout.exception.ts
799
- var import_common26 = require("@nestjs/common");
907
+ var import_common27 = require("@nestjs/common");
800
908
 
801
909
  // src/exceptions/service-unavailable.exception.ts
802
- var import_common27 = require("@nestjs/common");
910
+ var import_common28 = require("@nestjs/common");
803
911
 
804
912
  // src/exceptions/too-many-requests.exception.ts
805
- var import_common28 = require("@nestjs/common");
913
+ var import_common29 = require("@nestjs/common");
806
914
 
807
915
  // src/exceptions/unauthorized.exception.ts
808
- var import_common29 = require("@nestjs/common");
916
+ var import_common30 = require("@nestjs/common");
809
917
  var UnauthorizedException3 = class extends HttpProblemException {
810
918
  static {
811
919
  __name(this, "UnauthorizedException");
812
920
  }
813
921
  constructor(detailOrOptions) {
814
- super(detailOrOptions ?? "Unauthorized", import_common29.HttpStatus.UNAUTHORIZED);
922
+ super(detailOrOptions ?? "Unauthorized", import_common30.HttpStatus.UNAUTHORIZED);
815
923
  }
816
924
  };
817
925
 
818
926
  // src/exceptions/unprocessable-entity.exception.ts
819
- var import_common30 = require("@nestjs/common");
927
+ var import_common31 = require("@nestjs/common");
820
928
 
821
929
  // src/exceptions/unsupported-media-type.exception.ts
822
- var import_common31 = require("@nestjs/common");
930
+ var import_common32 = require("@nestjs/common");
823
931
 
824
932
  // src/exceptions/validation.exception.ts
825
- var import_common32 = require("@nestjs/common");
933
+ var import_common33 = require("@nestjs/common");
826
934
 
827
935
  // src/auth/decorators/refresh-cookie-options.decorator.ts
828
936
  function buildCookieOptionsForHost(cookieConfig, hostname) {
@@ -843,7 +951,7 @@ function buildCookieOptionsForHost(cookieConfig, hostname) {
843
951
  };
844
952
  }
845
953
  __name(buildCookieOptionsForHost, "buildCookieOptionsForHost");
846
- var RefreshCookieOptions = (0, import_common33.createParamDecorator)((_data, ctx) => {
954
+ var RefreshCookieOptions = (0, import_common34.createParamDecorator)((_data, ctx) => {
847
955
  const request = getRequestFromContext(ctx);
848
956
  const forwarded = request.headers["x-forwarded-host"];
849
957
  const raw = Array.isArray(forwarded) ? forwarded[0] : forwarded;
@@ -854,8 +962,8 @@ var RefreshCookieOptions = (0, import_common33.createParamDecorator)((_data, ctx
854
962
  });
855
963
 
856
964
  // src/auth/decorators/refresh-token-cookie.decorator.ts
857
- var import_common34 = require("@nestjs/common");
858
- var RefreshTokenCookie = (0, import_common34.createParamDecorator)((_data, ctx) => {
965
+ var import_common35 = require("@nestjs/common");
966
+ var RefreshTokenCookie = (0, import_common35.createParamDecorator)((_data, ctx) => {
859
967
  const request = getRequestFromContext(ctx);
860
968
  const cookies = request.cookies ?? {};
861
969
  const cookieName = request.authConfig?.cookie.refreshCookieName ?? AUTH_CONFIG_DEFAULTS.cookie.refreshCookieName;
@@ -863,8 +971,8 @@ var RefreshTokenCookie = (0, import_common34.createParamDecorator)((_data, ctx)
863
971
  });
864
972
 
865
973
  // src/auth/decorators/session-data.decorator.ts
866
- var import_common35 = require("@nestjs/common");
867
- var SessionData = (0, import_common35.createParamDecorator)((_data, ctx) => {
974
+ var import_common36 = require("@nestjs/common");
975
+ var SessionData = (0, import_common36.createParamDecorator)((_data, ctx) => {
868
976
  const request = getRequestFromContext(ctx);
869
977
  const sessionInfo = request.sessionInfo;
870
978
  if (!sessionInfo?.sessionId) {
@@ -878,8 +986,8 @@ var SessionData = (0, import_common35.createParamDecorator)((_data, ctx) => {
878
986
  });
879
987
 
880
988
  // src/auth/decorators/subdomain.decorator.ts
881
- var import_common36 = require("@nestjs/common");
882
- var Subdomain = (0, import_common36.createParamDecorator)((_data, ctx) => {
989
+ var import_common37 = require("@nestjs/common");
990
+ var Subdomain = (0, import_common37.createParamDecorator)((_data, ctx) => {
883
991
  const request = getRequestFromContext(ctx);
884
992
  const forwarded = request.headers["x-forwarded-host"];
885
993
  const raw = Array.isArray(forwarded) ? forwarded[0] : forwarded;
@@ -890,15 +998,15 @@ var Subdomain = (0, import_common36.createParamDecorator)((_data, ctx) => {
890
998
  });
891
999
 
892
1000
  // src/auth/decorators/user-agent.decorator.ts
893
- var import_common37 = require("@nestjs/common");
894
- var UserAgent = (0, import_common37.createParamDecorator)((_data, ctx) => {
1001
+ var import_common38 = require("@nestjs/common");
1002
+ var UserAgent = (0, import_common38.createParamDecorator)((_data, ctx) => {
895
1003
  const userAgent = getRequestFromContext(ctx).headers["user-agent"];
896
1004
  return Array.isArray(userAgent) ? userAgent[0] : userAgent;
897
1005
  });
898
1006
 
899
1007
  // src/auth/decorators/user-id.decorator.ts
900
- var import_common38 = require("@nestjs/common");
901
- var UserId = (0, import_common38.createParamDecorator)((_data, ctx) => {
1008
+ var import_common39 = require("@nestjs/common");
1009
+ var UserId = (0, import_common39.createParamDecorator)((_data, ctx) => {
902
1010
  const request = getRequestFromContext(ctx);
903
1011
  const sessionInfo = request.sessionInfo;
904
1012
  if (!sessionInfo?.userId) {
@@ -908,18 +1016,24 @@ var UserId = (0, import_common38.createParamDecorator)((_data, ctx) => {
908
1016
  });
909
1017
  // Annotate the CommonJS export names for ESM import in node:
910
1018
  0 && (module.exports = {
1019
+ APP_SESSION_TYPE,
911
1020
  AUTH_CONFIG,
912
1021
  AUTH_CONFIG_DEFAULTS,
913
1022
  AccessToken,
914
1023
  AuthConfigModule,
1024
+ CLIENT_ID_HEADER,
915
1025
  ClientIp,
916
1026
  CookieDomain,
917
1027
  CookieName,
918
1028
  Hostname,
1029
+ MAX_CLOCK_SKEW_SECONDS,
1030
+ PARTY_ID_HEADER,
919
1031
  Public,
1032
+ REQUIRE_APP_KEY,
920
1033
  REQUIRE_SESSION_KEY,
921
1034
  RefreshCookieOptions,
922
1035
  RefreshTokenCookie,
1036
+ RequireApp,
923
1037
  RequireSession,
924
1038
  SKIP_CSRF_KEY,
925
1039
  SessionData,
@@ -930,6 +1044,7 @@ var UserId = (0, import_common38.createParamDecorator)((_data, ctx) => {
930
1044
  UserAgent,
931
1045
  UserId,
932
1046
  VrittiAuthGuard,
1047
+ WORKSPACE_HEADER_ORDER,
933
1048
  hashToken,
934
1049
  verifyTokenHash
935
1050
  });