@ambushsoftworks/nestjs-auth-graphql 0.9.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/CHANGELOG.md +231 -0
  2. package/README.md +164 -8
  3. package/dist/auth.module.d.ts +10 -0
  4. package/dist/auth.module.d.ts.map +1 -1
  5. package/dist/auth.module.js +69 -2
  6. package/dist/auth.module.js.map +1 -1
  7. package/dist/exceptions/oauth.exceptions.d.ts +4 -1
  8. package/dist/exceptions/oauth.exceptions.d.ts.map +1 -1
  9. package/dist/exceptions/oauth.exceptions.js +12 -1
  10. package/dist/exceptions/oauth.exceptions.js.map +1 -1
  11. package/dist/guards/create-auth-guard.d.ts.map +1 -1
  12. package/dist/guards/create-auth-guard.js +3 -6
  13. package/dist/guards/create-auth-guard.js.map +1 -1
  14. package/dist/guards/csrf.guard.d.ts +2 -0
  15. package/dist/guards/csrf.guard.d.ts.map +1 -1
  16. package/dist/guards/csrf.guard.js +26 -5
  17. package/dist/guards/csrf.guard.js.map +1 -1
  18. package/dist/guards/jwt-auth.guard.d.ts +2 -1
  19. package/dist/guards/jwt-auth.guard.d.ts.map +1 -1
  20. package/dist/guards/jwt-auth.guard.js +6 -3
  21. package/dist/guards/jwt-auth.guard.js.map +1 -1
  22. package/dist/guards/permission.guard.js +2 -2
  23. package/dist/guards/permission.guard.js.map +1 -1
  24. package/dist/guards/tenant.guard.d.ts.map +1 -1
  25. package/dist/guards/tenant.guard.js +3 -0
  26. package/dist/guards/tenant.guard.js.map +1 -1
  27. package/dist/index.d.ts +3 -0
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +3 -0
  30. package/dist/index.js.map +1 -1
  31. package/dist/interfaces/refresh-retry-cache.interface.d.ts +6 -0
  32. package/dist/interfaces/refresh-retry-cache.interface.d.ts.map +1 -0
  33. package/dist/interfaces/refresh-retry-cache.interface.js +3 -0
  34. package/dist/interfaces/refresh-retry-cache.interface.js.map +1 -0
  35. package/dist/interfaces/refresh-token-repository.interface.d.ts.map +1 -1
  36. package/dist/middleware/realm.middleware.d.ts +7 -2
  37. package/dist/middleware/realm.middleware.d.ts.map +1 -1
  38. package/dist/middleware/realm.middleware.js +60 -14
  39. package/dist/middleware/realm.middleware.js.map +1 -1
  40. package/dist/resolvers/base-auth.resolver.d.ts.map +1 -1
  41. package/dist/resolvers/base-auth.resolver.js +2 -1
  42. package/dist/resolvers/base-auth.resolver.js.map +1 -1
  43. package/dist/resolvers/oauth.controller.d.ts.map +1 -1
  44. package/dist/resolvers/oauth.controller.js +27 -17
  45. package/dist/resolvers/oauth.controller.js.map +1 -1
  46. package/dist/resolvers/rest-error.interceptor.d.ts +7 -0
  47. package/dist/resolvers/rest-error.interceptor.d.ts.map +1 -0
  48. package/dist/resolvers/rest-error.interceptor.js +36 -0
  49. package/dist/resolvers/rest-error.interceptor.js.map +1 -0
  50. package/dist/services/auth.service.d.ts +2 -3
  51. package/dist/services/auth.service.d.ts.map +1 -1
  52. package/dist/services/auth.service.js +15 -10
  53. package/dist/services/auth.service.js.map +1 -1
  54. package/dist/services/in-memory-refresh-retry-cache.d.ts +11 -0
  55. package/dist/services/in-memory-refresh-retry-cache.d.ts.map +1 -0
  56. package/dist/services/in-memory-refresh-retry-cache.js +45 -0
  57. package/dist/services/in-memory-refresh-retry-cache.js.map +1 -0
  58. package/dist/services/refresh-token.service.d.ts +13 -14
  59. package/dist/services/refresh-token.service.d.ts.map +1 -1
  60. package/dist/services/refresh-token.service.js +112 -33
  61. package/dist/services/refresh-token.service.js.map +1 -1
  62. package/dist/strategies/api-key.strategy.d.ts.map +1 -1
  63. package/dist/strategies/api-key.strategy.js +1 -1
  64. package/dist/strategies/api-key.strategy.js.map +1 -1
  65. package/dist/strategies/jwt.strategy.d.ts +3 -1
  66. package/dist/strategies/jwt.strategy.d.ts.map +1 -1
  67. package/dist/strategies/jwt.strategy.js +15 -11
  68. package/dist/strategies/jwt.strategy.js.map +1 -1
  69. package/dist/strategies/noop-facebook.strategy.d.ts.map +1 -1
  70. package/dist/strategies/noop-facebook.strategy.js +2 -1
  71. package/dist/strategies/noop-facebook.strategy.js.map +1 -1
  72. package/dist/strategies/noop-google.strategy.d.ts.map +1 -1
  73. package/dist/strategies/noop-google.strategy.js +2 -1
  74. package/dist/strategies/noop-google.strategy.js.map +1 -1
  75. package/dist/test-utils/execution-contexts.d.ts +7 -0
  76. package/dist/test-utils/execution-contexts.d.ts.map +1 -0
  77. package/dist/test-utils/execution-contexts.js +41 -0
  78. package/dist/test-utils/execution-contexts.js.map +1 -0
  79. package/dist/utils/cookies.d.ts +2 -0
  80. package/dist/utils/cookies.d.ts.map +1 -0
  81. package/dist/utils/cookies.js +34 -0
  82. package/dist/utils/cookies.js.map +1 -0
  83. package/dist/utils/execution-context.d.ts +3 -1
  84. package/dist/utils/execution-context.d.ts.map +1 -1
  85. package/dist/utils/execution-context.js +39 -4
  86. package/dist/utils/execution-context.js.map +1 -1
  87. package/dist/utils/request-realm.d.ts +2 -0
  88. package/dist/utils/request-realm.d.ts.map +1 -0
  89. package/dist/utils/request-realm.js +12 -0
  90. package/dist/utils/request-realm.js.map +1 -0
  91. package/package.json +13 -4
@@ -11,6 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  return function (target, key) { decorator(target, key, paramIndex); }
13
13
  };
14
+ var JwtStrategy_1;
14
15
  Object.defineProperty(exports, "__esModule", { value: true });
15
16
  exports.JwtStrategy = void 0;
16
17
  const common_1 = require("@nestjs/common");
@@ -19,15 +20,12 @@ const passport_jwt_1 = require("passport-jwt");
19
20
  const auth_service_1 = require("../services/auth.service");
20
21
  const default_jwt_payload_factory_1 = require("../services/default-jwt-payload-factory");
21
22
  const constants_1 = require("../constants");
23
+ const cookies_1 = require("../utils/cookies");
24
+ const realm_middleware_1 = require("../middleware/realm.middleware");
22
25
  function fromCookie(cookieName) {
23
- return (req) => {
24
- if (req && req.cookies && req.cookies[cookieName]) {
25
- return req.cookies[cookieName];
26
- }
27
- return null;
28
- };
26
+ return (req) => (0, cookies_1.readCookie)(req, cookieName);
29
27
  }
30
- let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(passport_jwt_1.Strategy) {
28
+ let JwtStrategy = JwtStrategy_1 = class JwtStrategy extends (0, passport_1.PassportStrategy)(passport_jwt_1.Strategy) {
31
29
  constructor(options, authService, jwtPayloadFactory) {
32
30
  const bearerExtractor = passport_jwt_1.ExtractJwt.fromAuthHeaderAsBearerToken();
33
31
  const cookieAuthEnabled = options.features?.cookieAuth === true;
@@ -45,13 +43,19 @@ let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(pas
45
43
  passReqToCallback: true,
46
44
  });
47
45
  this.authService = authService;
46
+ this.logger = new common_1.Logger(JwtStrategy_1.name);
48
47
  this.jwtValidation = options.jwtValidation || 'full';
49
48
  this.jwtPayloadFactory = jwtPayloadFactory || new default_jwt_payload_factory_1.DefaultJwtPayloadFactory();
50
- this.realmsEnabled = !!options.realmExtractorInstance;
49
+ this.realmExtractor = options.realmExtractorInstance;
50
+ this.realmSkip = options.realm?.skip;
51
51
  }
52
52
  async validate(req, payload) {
53
- if (this.realmsEnabled) {
54
- const requestRealm = req._realm;
53
+ if (this.realmExtractor) {
54
+ const request = req;
55
+ if (request._realm === undefined) {
56
+ await (0, realm_middleware_1.resolveRealm)(request, this.realmExtractor, this.realmSkip, this.logger);
57
+ }
58
+ const requestRealm = request._realm;
55
59
  const tokenRealm = payload.realm;
56
60
  if (!tokenRealm || tokenRealm !== requestRealm) {
57
61
  throw new common_1.UnauthorizedException('Invalid token');
@@ -69,7 +73,7 @@ let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(pas
69
73
  }
70
74
  };
71
75
  exports.JwtStrategy = JwtStrategy;
72
- exports.JwtStrategy = JwtStrategy = __decorate([
76
+ exports.JwtStrategy = JwtStrategy = JwtStrategy_1 = __decorate([
73
77
  (0, common_1.Injectable)(),
74
78
  __param(0, (0, common_1.Inject)(constants_1.AUTH_MODULE_OPTIONS)),
75
79
  __param(2, (0, common_1.Optional)()),
@@ -1 +1 @@
1
- {"version":3,"file":"jwt.strategy.js","sourceRoot":"","sources":["../../src/strategies/jwt.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAqF;AACrF,+CAAoD;AACpD,+CAAoD;AAEpD,2DAAuD;AAIvD,yFAAmF;AACnF,4CAAwE;AAQxE,SAAS,UAAU,CAAC,UAAkB;IACpC,OAAO,CAAC,GAAY,EAAiB,EAAE;QACrC,IAAI,GAAG,IAAI,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;YAClD,OAAO,GAAG,CAAC,OAAO,CAAC,UAAU,CAAW,CAAC;QAC3C,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AAGM,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,IAAA,2BAAgB,EAAC,uBAAQ,CAAC;IAKzD,YAC+B,OAA0B,EAC/C,WAAwB,EAGhC,iBAAsC;QAEtC,MAAM,eAAe,GAAG,yBAAU,CAAC,2BAA2B,EAAE,CAAC;QAIjE,MAAM,iBAAiB,GAAG,OAAO,CAAC,QAAQ,EAAE,UAAU,KAAK,IAAI,CAAC;QAChE,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,EAAE,eAAe,IAAI,cAAc,CAAC;QAGzE,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,EAAE,aAAa;YAC9C,CAAC,CAAC,UAAU,cAAc,EAAE;YAC5B,CAAC,CAAC,cAAc,CAAC;QAEnB,MAAM,YAAY,GAAG,iBAAiB;YACpC,CAAC,CAAC,yBAAU,CAAC,cAAc,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,eAAe,CAAC,CAAC;YACtE,CAAC,CAAC,eAAe,CAAC;QAEpB,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MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;QAC9C,CAAC;QAKD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;QAE9E,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,8BAAqB,CAAC,eAAe,CAAC,CAAC;QACnD,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAxFY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;IASR,WAAA,IAAA,eAAM,EAAC,+BAAmB,CAAC,CAAA;IAE3B,WAAA,IAAA,iBAAQ,GAAE,CAAA;IACV,WAAA,IAAA,eAAM,EAAC,+BAAmB,CAAC,CAAA;6CAFP,0BAAW;GATvB,WAAW,CAwFvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"noop-facebook.strategy.d.ts","sourceRoot":"","sources":["../../src/strategies/noop-facebook.strategy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAiB3D,qBACa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyC;IAY1D,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;CAUxE"}
1
+ {"version":3,"file":"noop-facebook.strategy.d.ts","sourceRoot":"","sources":["../../src/strategies/noop-facebook.strategy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAkB3D,qBACa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyC;IAY1D,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;CAQxE"}
@@ -9,6 +9,7 @@ var NoOpFacebookStrategy_1;
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.NoOpFacebookStrategy = void 0;
11
11
  const common_1 = require("@nestjs/common");
12
+ const oauth_exceptions_1 = require("../exceptions/oauth.exceptions");
12
13
  let NoOpFacebookStrategy = NoOpFacebookStrategy_1 = class NoOpFacebookStrategy {
13
14
  constructor() {
14
15
  this.logger = new common_1.Logger(NoOpFacebookStrategy_1.name);
@@ -16,7 +17,7 @@ let NoOpFacebookStrategy = NoOpFacebookStrategy_1 = class NoOpFacebookStrategy {
16
17
  async verifyAccessToken(_accessToken) {
17
18
  this.logger.warn('[NoOpFacebookStrategy] Attempted to verify Facebook access token, but Facebook OAuth is not configured. ' +
18
19
  'Configure oauth.facebook.clientId and clientSecret in AuthModuleOptions to enable Facebook Login.');
19
- throw new Error('Facebook OAuth not configured. Please provide oauth.facebook.clientId and clientSecret in AuthModuleOptions.');
20
+ throw new oauth_exceptions_1.OAuthProviderNotConfiguredException('facebook');
20
21
  }
21
22
  };
22
23
  exports.NoOpFacebookStrategy = NoOpFacebookStrategy;
@@ -1 +1 @@
1
- {"version":3,"file":"noop-facebook.strategy.js","sourceRoot":"","sources":["../../src/strategies/noop-facebook.strategy.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AAmB7C,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAA1B;QACY,WAAM,GAAG,IAAI,eAAM,CAAC,sBAAoB,CAAC,IAAI,CAAC,CAAC;IAsBlE,CAAC;IAVC,KAAK,CAAC,iBAAiB,CAAC,YAAoB;QAC1C,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,0GAA0G;YACxG,mGAAmG,CACtG,CAAC;QAEF,MAAM,IAAI,KAAK,CACb,8GAA8G,CAC/G,CAAC;IACJ,CAAC;CACF,CAAA;AAvBY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;GACA,oBAAoB,CAuBhC"}
1
+ {"version":3,"file":"noop-facebook.strategy.js","sourceRoot":"","sources":["../../src/strategies/noop-facebook.strategy.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AAEpD,qEAAqF;AAkB9E,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAA1B;QACY,WAAM,GAAG,IAAI,eAAM,CAAC,sBAAoB,CAAC,IAAI,CAAC,CAAC;IAoBlE,CAAC;IARC,KAAK,CAAC,iBAAiB,CAAC,YAAoB;QAC1C,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,0GAA0G;YACxG,mGAAmG,CACtG,CAAC;QAEF,MAAM,IAAI,sDAAmC,CAAC,UAAU,CAAC,CAAC;IAC5D,CAAC;CACF,CAAA;AArBY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;GACA,oBAAoB,CAqBhC"}
@@ -1 +1 @@
1
- {"version":3,"file":"noop-google.strategy.d.ts","sourceRoot":"","sources":["../../src/strategies/noop-google.strategy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAiBvD,qBACa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuC;IAYxD,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;CAU9D"}
1
+ {"version":3,"file":"noop-google.strategy.d.ts","sourceRoot":"","sources":["../../src/strategies/noop-google.strategy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAkBvD,qBACa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuC;IAYxD,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;CAQ9D"}
@@ -9,6 +9,7 @@ var NoOpGoogleStrategy_1;
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.NoOpGoogleStrategy = void 0;
11
11
  const common_1 = require("@nestjs/common");
12
+ const oauth_exceptions_1 = require("../exceptions/oauth.exceptions");
12
13
  let NoOpGoogleStrategy = NoOpGoogleStrategy_1 = class NoOpGoogleStrategy {
13
14
  constructor() {
14
15
  this.logger = new common_1.Logger(NoOpGoogleStrategy_1.name);
@@ -16,7 +17,7 @@ let NoOpGoogleStrategy = NoOpGoogleStrategy_1 = class NoOpGoogleStrategy {
16
17
  async verifyIdToken(_idToken) {
17
18
  this.logger.warn('[NoOpGoogleStrategy] Attempted to verify Google ID token, but Google OAuth is not configured. ' +
18
19
  'Configure oauth.google.clientId in AuthModuleOptions to enable Google Sign-In.');
19
- throw new Error('Google OAuth not configured. Please provide oauth.google.clientId in AuthModuleOptions.');
20
+ throw new oauth_exceptions_1.OAuthProviderNotConfiguredException('google');
20
21
  }
21
22
  };
22
23
  exports.NoOpGoogleStrategy = NoOpGoogleStrategy;
@@ -1 +1 @@
1
- {"version":3,"file":"noop-google.strategy.js","sourceRoot":"","sources":["../../src/strategies/noop-google.strategy.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AAmB7C,IAAM,kBAAkB,0BAAxB,MAAM,kBAAkB;IAAxB;QACY,WAAM,GAAG,IAAI,eAAM,CAAC,oBAAkB,CAAC,IAAI,CAAC,CAAC;IAsBhE,CAAC;IAVC,KAAK,CAAC,aAAa,CAAC,QAAgB;QAClC,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,gGAAgG;YAC9F,gFAAgF,CACnF,CAAC;QAEF,MAAM,IAAI,KAAK,CACb,yFAAyF,CAC1F,CAAC;IACJ,CAAC;CACF,CAAA;AAvBY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;GACA,kBAAkB,CAuB9B"}
1
+ {"version":3,"file":"noop-google.strategy.js","sourceRoot":"","sources":["../../src/strategies/noop-google.strategy.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AAEpD,qEAAqF;AAkB9E,IAAM,kBAAkB,0BAAxB,MAAM,kBAAkB;IAAxB;QACY,WAAM,GAAG,IAAI,eAAM,CAAC,oBAAkB,CAAC,IAAI,CAAC,CAAC;IAoBhE,CAAC;IARC,KAAK,CAAC,aAAa,CAAC,QAAgB;QAClC,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,gGAAgG;YAC9F,gFAAgF,CACnF,CAAC;QAEF,MAAM,IAAI,sDAAmC,CAAC,QAAQ,CAAC,CAAC;IAC1D,CAAC;CACF,CAAA;AArBY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;GACA,kBAAkB,CAqB9B"}
@@ -0,0 +1,7 @@
1
+ import { ExecutionContext } from '@nestjs/common';
2
+ type Operation = 'query' | 'mutation' | 'subscription';
3
+ export declare function httpExecutionContext(request: unknown): ExecutionContext;
4
+ export declare function graphqlExecutionContext(gqlContext: unknown, operation?: Operation, operationName?: string): ExecutionContext;
5
+ export declare function graphqlWsConnection(upgradeRequest: Record<string, any>): Record<string, any>;
6
+ export {};
7
+ //# sourceMappingURL=execution-contexts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-contexts.d.ts","sourceRoot":"","sources":["../../src/test-utils/execution-contexts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,KAAK,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,cAAc,CAAC;AAMvD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,gBAAgB,CAUvE;AAMD,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,OAAO,EACnB,SAAS,GAAE,SAAmB,EAC9B,aAAa,CAAC,EAAE,MAAM,GACrB,gBAAgB,CAalB;AAMD,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAQ5F"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.httpExecutionContext = httpExecutionContext;
4
+ exports.graphqlExecutionContext = graphqlExecutionContext;
5
+ exports.graphqlWsConnection = graphqlWsConnection;
6
+ const handler = () => undefined;
7
+ class Resolver {
8
+ }
9
+ function httpExecutionContext(request) {
10
+ const args = [request, {}, () => undefined];
11
+ return {
12
+ getType: () => 'http',
13
+ getArgs: () => args,
14
+ getArgByIndex: (index) => args[index],
15
+ getHandler: () => handler,
16
+ getClass: () => Resolver,
17
+ switchToHttp: () => ({ getRequest: () => request }),
18
+ };
19
+ }
20
+ function graphqlExecutionContext(gqlContext, operation = 'query', operationName) {
21
+ const info = { operation: { operation, name: operationName ? { value: operationName } : undefined } };
22
+ const args = [{}, {}, gqlContext, info];
23
+ return {
24
+ getType: () => 'graphql',
25
+ getArgs: () => args,
26
+ getArgByIndex: (index) => args[index],
27
+ getHandler: () => handler,
28
+ getClass: () => Resolver,
29
+ switchToHttp: () => ({ getRequest: () => args[0], getResponse: () => args[1], getNext: () => args[2] }),
30
+ };
31
+ }
32
+ function graphqlWsConnection(upgradeRequest) {
33
+ return {
34
+ connectionInitReceived: true,
35
+ acknowledged: true,
36
+ subscriptions: {},
37
+ extra: { socket: {}, request: upgradeRequest },
38
+ connectionParams: {},
39
+ };
40
+ }
41
+ //# sourceMappingURL=execution-contexts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-contexts.js","sourceRoot":"","sources":["../../src/test-utils/execution-contexts.ts"],"names":[],"mappings":";;AAQA,oDAUC;AAMD,0DAiBC;AAMD,kDAQC;AAnDD,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC;AAChC,MAAM,QAAQ;CAAG;AAGjB,SAAgB,oBAAoB,CAAC,OAAgB;IACnD,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAC5C,OAAO;QACL,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM;QACrB,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI;Q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EAAE;QACjB,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE;QAC9C,gBAAgB,EAAE,EAAE;KACrB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function readCookie(request: Record<string, any> | undefined, name: string): string | null;
2
+ //# sourceMappingURL=cookies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookies.d.ts","sourceRoot":"","sources":["../../src/utils/cookies.ts"],"names":[],"mappings":"AAiBA,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAiChG"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readCookie = readCookie;
4
+ function readCookie(request, name) {
5
+ const parsed = request?.cookies?.[name];
6
+ if (typeof parsed === 'string' && parsed !== '') {
7
+ return parsed;
8
+ }
9
+ const header = request?.headers?.cookie;
10
+ if (typeof header !== 'string') {
11
+ return null;
12
+ }
13
+ for (const pair of header.split(';')) {
14
+ const separator = pair.indexOf('=');
15
+ if (separator === -1 || pair.slice(0, separator).trim() !== name) {
16
+ continue;
17
+ }
18
+ let value = pair.slice(separator + 1).trim();
19
+ if (value.length >= 2 && value.startsWith('"') && value.endsWith('"')) {
20
+ value = value.slice(1, -1);
21
+ }
22
+ if (value === '') {
23
+ return null;
24
+ }
25
+ try {
26
+ return decodeURIComponent(value);
27
+ }
28
+ catch {
29
+ return value;
30
+ }
31
+ }
32
+ return null;
33
+ }
34
+ //# sourceMappingURL=cookies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookies.js","sourceRoot":"","sources":["../../src/utils/cookies.ts"],"names":[],"mappings":";;AAiBA,gCAiCC;AAjCD,SAAgB,UAAU,CAAC,OAAwC,EAAE,IAAY;IAC/E,MAAM,MAAM,GAAG,O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getRequestFromContext(context: ExecutionContext): Record<string, any>;
2
+ export declare function getRequestFromContext(context: ExecutionContext): Record<string, any> | undefined;
3
+ export declare function isWebSocketContext(context: ExecutionContext): boolean;
4
+ export declare function requireRequestFromContext(context: ExecutionContext): Record<string, any>;
3
5
  //# sourceMappingURL=execution-context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"execution-context.d.ts","sourceRoot":"","sources":["../../src/utils/execution-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAOlD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAMpF"}
1
+ {"version":3,"file":"execution-context.d.ts","sourceRoot":"","sources":["../../src/utils/execution-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAiC,MAAM,gBAAgB,CAAC;AAoBjF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAchG;AASD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAYrE;AAWD,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAexF"}
@@ -1,12 +1,47 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getRequestFromContext = getRequestFromContext;
4
+ exports.isWebSocketContext = isWebSocketContext;
5
+ exports.requireRequestFromContext = requireRequestFromContext;
6
+ const common_1 = require("@nestjs/common");
4
7
  const graphql_1 = require("@nestjs/graphql");
5
8
  function getRequestFromContext(context) {
6
- const contextType = context.getType();
7
- if (contextType === 'graphql') {
8
- return graphql_1.GqlExecutionContext.create(context).getContext().req;
9
+ if (context.getType() !== 'graphql') {
10
+ return context.switchToHttp().getRequest();
9
11
  }
10
- return context.switchToHttp().getRequest();
12
+ const gqlContext = graphql_1.GqlExecutionContext.create(context).getContext();
13
+ const req = gqlContext?.req;
14
+ if (req && !isGraphqlWsContext(req)) {
15
+ return req;
16
+ }
17
+ return gqlContext?.extra?.request ?? req?.extra?.request ?? undefined;
18
+ }
19
+ function isWebSocketContext(context) {
20
+ if (context.getType() !== 'graphql') {
21
+ return false;
22
+ }
23
+ const gqlExecutionContext = graphql_1.GqlExecutionContext.create(context);
24
+ const req = gqlExecutionContext.getContext()?.req;
25
+ if (req && !isGraphqlWsContext(req)) {
26
+ return false;
27
+ }
28
+ return gqlExecutionContext.getInfo()?.operation?.operation === 'subscription';
29
+ }
30
+ let warnedMissingRequest = false;
31
+ function requireRequestFromContext(context) {
32
+ const request = getRequestFromContext(context);
33
+ if (request) {
34
+ return request;
35
+ }
36
+ if (!warnedMissingRequest) {
37
+ warnedMissingRequest = true;
38
+ new common_1.Logger('AuthGuard').warn('An auth guard found no request in the execution context and rejected the operation. ' +
39
+ 'For GraphQL subscriptions on your own graphql-ws server, pass the connection context ' +
40
+ 'through: useServer({ schema, context: (ctx) => ctx }, wsServer).');
41
+ }
42
+ throw new common_1.UnauthorizedException();
43
+ }
44
+ function isGraphqlWsContext(value) {
45
+ return typeof value === 'object' && 'connectionInitReceived' in value && 'extra' in value;
11
46
  }
12
47
  //# sourceMappingURL=execution-context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"execution-context.js","sourceRoot":"","sources":["../../src/utils/execution-context.ts"],"names":[],"mappings":";;AAOA,sDAMC;AAZD,6CAAsD;AAMtD,SAAgB,qBAAqB,CAAC,OAAyB;IAC7D,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,EAAU,CAAC;IAC9C,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,6BAAmB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC;IAC9D,CAAC;IACD,OAAO,OAAO,CAAC,YAAY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,CAAC,OAAyB;IACjE,MAAM,OAAO,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAC/C,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC1B,oBAAoB,GAAG,IAAI,CAAC;QAC5B,IAAI,eAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAC1B,sFAAsF;YACpF,uFAAuF;YACvF,kEAAkE,CACrE,CAAC;IACJ,CAAC;IACD,MAAM,IAAI,8BAAqB,EAAE,CAAC;AACpC,CAAC;AAGD,SAAS,kBAAkB,CAAC,KAA0B;IACpD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,wBAAwB,IAAI,KAAK,IAAI,OAAO,IAAI,KAAK,CAAC;AAC5F,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function realmForRequest(request: Record<string, any> | undefined, realmsEnabled: boolean): string | undefined;
2
+ //# sourceMappingURL=request-realm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-realm.d.ts","sourceRoot":"","sources":["../../src/utils/request-realm.ts"],"names":[],"mappings":"AAaA,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,EACxC,aAAa,EAAE,OAAO,GACrB,MAAM,GAAG,SAAS,CAQpB"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.realmForRequest = realmForRequest;
4
+ const common_1 = require("@nestjs/common");
5
+ function realmForRequest(request, realmsEnabled) {
6
+ const realm = request?._realm;
7
+ if (realmsEnabled && (realm === undefined || realm === null)) {
8
+ throw new common_1.BadRequestException('Realm required');
9
+ }
10
+ return realm;
11
+ }
12
+ //# sourceMappingURL=request-realm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-realm.js","sourceRoot":"","sources":["../../src/utils/request-realm.ts"],"names":[],"mappings":";;AAaA,0CAWC;AAxBD,2CAAqD;AAarD,SAAgB,eAAe,CAC7B,OAAwC,EACxC,aAAsB;IAEtB,MAAM,KAAK,GAAG,OAAO,EAAE,MAAM,CAAC;IAE9B,IAAI,aAAa,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC,EAAE,CAAC;QAC7D,MAAM,IAAI,4BAAmB,CAAC,gBAAgB,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ambushsoftworks/nestjs-auth-graphql",
3
- "version": "0.9.1",
3
+ "version": "0.11.0",
4
4
  "description": "Production-grade authentication package for NestJS with GraphQL, supporting JWT, OAuth, email/SMS verification, and biometric auth",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,10 +18,12 @@
18
18
  "test": "jest",
19
19
  "test:watch": "jest --watch",
20
20
  "test:cov": "jest --coverage",
21
- "lint": "eslint \"src/**/*.ts\"",
21
+ "pretest:e2e": "npm run build",
22
+ "test:e2e": "jest --config test/e2e/jest.config.js --runInBand",
23
+ "lint": "eslint \"{src,test}/**/*.ts\"",
22
24
  "format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\"",
23
25
  "prepublishOnly": "npm run build",
24
- "lint:fix": "eslint \"src/**/*.ts\" --fix"
26
+ "lint:fix": "eslint \"{src,test}/**/*.ts\" --fix"
25
27
  },
26
28
  "keywords": [
27
29
  "nestjs",
@@ -75,8 +77,11 @@
75
77
  "twilio": "^5.10.4"
76
78
  },
77
79
  "devDependencies": {
80
+ "@apollo/server": "^4.13.0",
81
+ "@nestjs/apollo": "^12.2.2",
78
82
  "@nestjs/cli": "^10.3.0",
79
83
  "@nestjs/config": "^3.3.0",
84
+ "@nestjs/platform-express": "^10.4.22",
80
85
  "@nestjs/testing": "^10.3.1",
81
86
  "@nestjs/throttler": "^6.4.0",
82
87
  "@types/bcrypt": "^6.0.0",
@@ -84,18 +89,22 @@
84
89
  "@types/node": "^20.11.5",
85
90
  "@types/passport-google-oauth20": "^2.0.17",
86
91
  "@types/passport-jwt": "^4.0.0",
92
+ "@types/supertest": "^7.2.1",
87
93
  "@typescript-eslint/eslint-plugin": "^6.19.0",
88
94
  "@typescript-eslint/parser": "^6.19.0",
89
95
  "eslint": "^8.56.0",
90
96
  "eslint-config-prettier": "^9.1.0",
91
97
  "eslint-plugin-prettier": "^5.1.3",
92
98
  "graphql": "^16.12.0",
99
+ "graphql-ws": "^5.16.2",
93
100
  "jest": "^29.7.0",
94
101
  "prettier": "^3.2.4",
95
102
  "reflect-metadata": "^0.2.2",
96
103
  "rxjs": "^7.8.2",
104
+ "supertest": "^7.2.2",
97
105
  "ts-jest": "^29.1.1",
98
- "typescript": "^5.3.3"
106
+ "typescript": "^5.3.3",
107
+ "ws": "^8.21.3"
99
108
  },
100
109
  "jest": {
101
110
  "moduleFileExtensions": [