UNPKG

@bitwild/rockets-auth

Version:

Rockets Auth - Complete authentication and authorization solution for NestJS with JWT, OAuth, OTP, role-based access control, and more

104 lines 4.47 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 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; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; Object.defineProperty(exports, "__esModule", { value: true }); exports.AuthOAuthController = void 0; const common_1 = require("@nestjs/common"); const swagger_1 = require("@nestjs/swagger"); const nestjs_authentication_1 = require("@concepta/nestjs-authentication"); const nestjs_auth_router_1 = require("@concepta/nestjs-auth-router"); let AuthOAuthController = class AuthOAuthController { constructor(issueTokenService) { this.issueTokenService = issueTokenService; } authorize() { return; } async callback(user) { return this.issueTokenService.responsePayload(user.id); } async callbackPost(user) { return this.issueTokenService.responsePayload(user.id); } }; exports.AuthOAuthController = AuthOAuthController; __decorate([ (0, swagger_1.ApiResponse)({ status: 302, description: "HTTP Redirect to the OAuth identity provider's authorization URL.", headers: { Location: { description: 'URL to which the user agent should redirect (or open in a browser for mobile apps).', schema: { type: 'string', format: 'uri', }, }, }, }), (0, swagger_1.ApiQuery)({ name: 'provider', description: 'Name of the OAuth provider. Supported providers: google, github, apple', example: 'google', required: true, schema: { type: 'string', enum: ['google', 'github', 'apple'], }, }), (0, swagger_1.ApiQuery)({ name: 'scopes', required: true, description: 'Space separated list of OAuth scopes to pass on to the provider. Common scopes: email, userMetadata, openid', example: 'email,userMetadata', schema: { type: 'string', pattern: '[^ ]+( +[^ ]+)*', }, }), (0, common_1.Get)('authorize'), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], AuthOAuthController.prototype, "authorize", null); __decorate([ (0, swagger_1.ApiOkResponse)({ type: nestjs_authentication_1.AuthenticationJwtResponseDto, description: 'DTO containing an access token and a refresh token.', }), (0, common_1.Get)('callback'), __param(0, (0, nestjs_authentication_1.AuthUser)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise) ], AuthOAuthController.prototype, "callback", null); __decorate([ (0, swagger_1.ApiOkResponse)({ type: nestjs_authentication_1.AuthenticationJwtResponseDto, description: 'DTO containing an access token and a refresh token.', }), (0, common_1.Post)('callback'), __param(0, (0, nestjs_authentication_1.AuthUser)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise) ], AuthOAuthController.prototype, "callbackPost", null); exports.AuthOAuthController = AuthOAuthController = __decorate([ (0, common_1.Controller)('oauth'), (0, common_1.UseGuards)(nestjs_auth_router_1.AuthRouterGuard), (0, nestjs_authentication_1.AuthPublic)(), (0, swagger_1.ApiTags)('Authentication'), __param(0, (0, common_1.Inject)(nestjs_authentication_1.IssueTokenService)), __metadata("design:paramtypes", [Object]) ], AuthOAuthController); //# sourceMappingURL=auth-oauth.controller.js.map