@my-nestjs-kit/auth 0.0.0-stage → 0.1.0-dev.20261129010337
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/LICENSE +21 -0
- package/README.md +27 -2
- package/dist/access-tokens/access-token.d.ts +13 -0
- package/dist/access-tokens/access-token.js +10 -0
- package/dist/access-tokens/access-tokens.module.d.ts +2 -0
- package/dist/access-tokens/access-tokens.module.js +22 -0
- package/dist/access-tokens/access-tokens.service.d.ts +16 -0
- package/dist/access-tokens/access-tokens.service.js +72 -0
- package/dist/access-tokens/access-tokens.types.d.ts +5 -0
- package/dist/access-tokens/access-tokens.types.js +9 -0
- package/dist/access-tokens/dto/access-token.dto.d.ts +13 -0
- package/dist/access-tokens/dto/access-token.dto.js +33 -0
- package/dist/auth-sessions/devices/dto/create-device.dto.d.ts +6 -0
- package/dist/auth-sessions/devices/dto/create-device.dto.js +33 -0
- package/dist/auth-sessions/dto/create-auth-session.dto.d.ts +8 -0
- package/dist/auth-sessions/dto/create-auth-session.dto.js +36 -0
- package/dist/auth.constants.d.ts +30 -0
- package/dist/auth.constants.js +36 -0
- package/dist/decorators/GetAuthParams.decorator.d.ts +34 -0
- package/dist/decorators/GetAuthParams.decorator.js +64 -0
- package/dist/decorators/GetSession.decorator.d.ts +2 -0
- package/dist/decorators/GetSession.decorator.js +13 -0
- package/dist/decorators/GetUser.decorator.d.ts +2 -0
- package/dist/decorators/GetUser.decorator.js +13 -0
- package/dist/decorators/Public.decorator.d.ts +3 -0
- package/dist/decorators/Public.decorator.js +18 -0
- package/dist/decorators/SetAuthConfig.decorator.d.ts +3 -0
- package/dist/decorators/SetAuthConfig.decorator.js +13 -0
- package/dist/dto/confirm-secure-action.dto.d.ts +8 -0
- package/dist/dto/confirm-secure-action.dto.js +46 -0
- package/dist/dto/log-in-by-email.dto.d.ts +16 -0
- package/dist/dto/log-in-by-email.dto.js +15 -0
- package/dist/dto/login-user-auth.dto.d.ts +4 -0
- package/dist/dto/login-user-auth.dto.js +29 -0
- package/dist/dto/verify-user-registration.dto.d.ts +4 -0
- package/dist/dto/verify-user-registration.dto.js +25 -0
- package/dist/entities/abstract-device-base.entity.d.ts +10 -0
- package/dist/entities/abstract-device-base.entity.js +77 -0
- package/dist/entities/abstract-o-auth-connection.entity.d.ts +28 -0
- package/dist/entities/abstract-o-auth-connection.entity.js +100 -0
- package/dist/entities/abstract-o-auth-profile.entity.d.ts +10 -0
- package/dist/entities/abstract-o-auth-profile.entity.js +38 -0
- package/dist/entities/auth-session-base.entity.d.ts +18 -0
- package/dist/entities/auth-session-base.entity.js +73 -0
- package/dist/guards/AbstractRefreshJwtToken.guard.d.ts +9 -0
- package/dist/guards/AbstractRefreshJwtToken.guard.js +45 -0
- package/dist/guards/abstract/AppAuthGuard-abstract.d.ts +219 -0
- package/dist/guards/abstract/AppAuthGuard-abstract.js +187 -0
- package/dist/guards/index.d.ts +0 -0
- package/dist/guards/index.js +0 -0
- package/dist/helper/base-auth-service.helper.d.ts +60 -0
- package/dist/helper/base-auth-service.helper.js +184 -0
- package/dist/helper/jsw-auth-controller-abstract.d.ts +33 -0
- package/dist/helper/jsw-auth-controller-abstract.js +89 -0
- package/dist/helper/jwt-auth-service-abstract.d.ts +40 -0
- package/dist/helper/jwt-auth-service-abstract.js +181 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +55 -0
- package/dist/jwt/index.d.ts +5 -0
- package/dist/jwt/index.js +21 -0
- package/dist/jwt/jwt-auth.module.d.ts +6 -0
- package/dist/jwt/jwt-auth.module.js +45 -0
- package/dist/jwt/jwt-auth.service.d.ts +33 -0
- package/dist/jwt/jwt-auth.service.js +170 -0
- package/dist/jwt/jwt-keys.helper.d.ts +12 -0
- package/dist/jwt/jwt-keys.helper.js +32 -0
- package/dist/jwt/types/enums.d.ts +19 -0
- package/dist/jwt/types/enums.js +26 -0
- package/dist/jwt/types/index.d.ts +2 -0
- package/dist/jwt/types/index.js +18 -0
- package/dist/jwt/types/jwt-auth.types.d.ts +44 -0
- package/dist/jwt/types/jwt-auth.types.js +2 -0
- package/dist/o-auth/abstract-o-auth.service.d.ts +30 -0
- package/dist/o-auth/abstract-o-auth.service.js +64 -0
- package/dist/o-auth/o-auth.namespace.d.ts +131 -0
- package/dist/o-auth/o-auth.namespace.js +256 -0
- package/dist/o-auth/sdk/base-ext-o-auth-sdk.d.ts +104 -0
- package/dist/o-auth/sdk/base-ext-o-auth-sdk.js +56 -0
- package/dist/route-auth-configs.helper.d.ts +29 -0
- package/dist/route-auth-configs.helper.js +36 -0
- package/dist/services/abstrac-auth-sessions.service.d.ts +28 -0
- package/dist/services/abstrac-auth-sessions.service.js +41 -0
- package/dist/services/abstract-sessions-repo.service.d.ts +28 -0
- package/dist/services/abstract-sessions-repo.service.js +28 -0
- package/dist/types/app-request.inteface.d.ts +14 -0
- package/dist/types/app-request.inteface.js +2 -0
- package/dist/types/auth.types.d.ts +43 -0
- package/dist/types/auth.types.js +12 -0
- package/dist/types/ws-client.types.d.ts +14 -0
- package/dist/types/ws-client.types.js +2 -0
- package/package.json +95 -3
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ConfirmSecureActionDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
const core_1 = require("@my-nestjs-kit/core");
|
|
15
|
+
const core_2 = require("@my-nestjs-kit/core");
|
|
16
|
+
const access_tokens_types_1 = require("../access-tokens/access-tokens.types");
|
|
17
|
+
// From the ERP users/dto/user-secure-action.dto (verification by token / code / Bearer)
|
|
18
|
+
class ConfirmSecureActionDto {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.verifyBy = access_tokens_types_1.AccessTokenTypeEnum.code;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.ConfirmSecureActionDto = ConfirmSecureActionDto;
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, class_validator_1.IsJWT)(),
|
|
26
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
27
|
+
(0, class_validator_1.ValidateIf)((ref) => ref.verifyBy === access_tokens_types_1.AccessTokenTypeEnum.token),
|
|
28
|
+
(0, core_2.ApiPropDescriptor)(),
|
|
29
|
+
__metadata("design:type", String)
|
|
30
|
+
], ConfirmSecureActionDto.prototype, "token", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, core_1.IsString32)({ optional: false }),
|
|
33
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
34
|
+
(0, class_validator_1.ValidateIf)((ref) => ref.verifyBy === access_tokens_types_1.AccessTokenTypeEnum.code),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], ConfirmSecureActionDto.prototype, "code", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, class_validator_1.IsJWT)(),
|
|
39
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
40
|
+
(0, class_validator_1.ValidateIf)((ref) => ref.verifyBy === access_tokens_types_1.AccessTokenTypeEnum.Bearer),
|
|
41
|
+
__metadata("design:type", String)
|
|
42
|
+
], ConfirmSecureActionDto.prototype, "Bearer", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, core_1.IsEnumProperty)(access_tokens_types_1.AccessTokenTypeEnum, { optional: true }),
|
|
45
|
+
__metadata("design:type", String)
|
|
46
|
+
], ConfirmSecureActionDto.prototype, "verifyBy", void 0);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LoginUserAuthDto } from './login-user-auth.dto';
|
|
2
|
+
import { VerifyUserRegistrationDto } from './verify-user-registration.dto';
|
|
3
|
+
export declare class LogInBaseDto {
|
|
4
|
+
ip?: string;
|
|
5
|
+
device?: {
|
|
6
|
+
userAgent?: string;
|
|
7
|
+
trackId?: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
declare const LogInByEmailDto_base: import("@nestjs/common").Type<LoginUserAuthDto & LogInBaseDto>;
|
|
11
|
+
export declare class LogInByEmailDto extends LogInByEmailDto_base {
|
|
12
|
+
}
|
|
13
|
+
declare const VerificationAuthDto_base: import("@nestjs/common").Type<LogInBaseDto & VerifyUserRegistrationDto>;
|
|
14
|
+
export declare class VerificationAuthDto extends VerificationAuthDto_base {
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VerificationAuthDto = exports.LogInByEmailDto = exports.LogInBaseDto = void 0;
|
|
4
|
+
const login_user_auth_dto_1 = require("./login-user-auth.dto");
|
|
5
|
+
const verify_user_registration_dto_1 = require("./verify-user-registration.dto");
|
|
6
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
7
|
+
class LogInBaseDto {
|
|
8
|
+
}
|
|
9
|
+
exports.LogInBaseDto = LogInBaseDto;
|
|
10
|
+
class LogInByEmailDto extends (0, swagger_1.IntersectionType)(login_user_auth_dto_1.LoginUserAuthDto, LogInBaseDto) {
|
|
11
|
+
}
|
|
12
|
+
exports.LogInByEmailDto = LogInByEmailDto;
|
|
13
|
+
class VerificationAuthDto extends (0, swagger_1.IntersectionType)(verify_user_registration_dto_1.VerifyUserRegistrationDto, LogInBaseDto) {
|
|
14
|
+
}
|
|
15
|
+
exports.VerificationAuthDto = VerificationAuthDto;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.LoginUserAuthDto = void 0;
|
|
13
|
+
const core_1 = require("@my-nestjs-kit/core");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
class LoginUserAuthDto {
|
|
16
|
+
}
|
|
17
|
+
exports.LoginUserAuthDto = LoginUserAuthDto;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
20
|
+
(0, class_validator_1.IsEmail)(),
|
|
21
|
+
(0, core_1.ApiPropDescriptor)({ optional: false }),
|
|
22
|
+
__metadata("design:type", String)
|
|
23
|
+
], LoginUserAuthDto.prototype, "email", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
26
|
+
(0, class_validator_1.IsString)(),
|
|
27
|
+
(0, core_1.ApiPropDescriptor)({ optional: false }),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], LoginUserAuthDto.prototype, "password", void 0);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.VerifyUserRegistrationDto = void 0;
|
|
13
|
+
const core_1 = require("@my-nestjs-kit/core");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
const access_tokens_types_1 = require("../access-tokens/access-tokens.types");
|
|
16
|
+
const confirm_secure_action_dto_1 = require("./confirm-secure-action.dto");
|
|
17
|
+
class VerifyUserRegistrationDto extends confirm_secure_action_dto_1.ConfirmSecureActionDto {
|
|
18
|
+
}
|
|
19
|
+
exports.VerifyUserRegistrationDto = VerifyUserRegistrationDto;
|
|
20
|
+
__decorate([
|
|
21
|
+
(0, class_validator_1.IsEmail)(),
|
|
22
|
+
(0, class_validator_1.ValidateIf)((ref) => ref.verifyBy === access_tokens_types_1.AccessTokenTypeEnum.code),
|
|
23
|
+
(0, core_1.ApiPropDescriptor)({ optional: false }),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], VerifyUserRegistrationDto.prototype, "email", void 0);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AppBaseEntity } from '@my-nestjs-kit/core';
|
|
2
|
+
export declare abstract class AbstractDeviceBaseEntity extends AppBaseEntity {
|
|
3
|
+
userAgent?: string;
|
|
4
|
+
os?: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
type?: string;
|
|
7
|
+
aspectRatio?: string;
|
|
8
|
+
trackId: string;
|
|
9
|
+
addCookiesId(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.AbstractDeviceBaseEntity = void 0;
|
|
36
|
+
const core_1 = require("@my-nestjs-kit/core");
|
|
37
|
+
const typeorm_1 = require("typeorm");
|
|
38
|
+
const crypto = __importStar(require("crypto"));
|
|
39
|
+
class AbstractDeviceBaseEntity extends core_1.AppBaseEntity {
|
|
40
|
+
addCookiesId() {
|
|
41
|
+
if (!this._id && !this.trackId) {
|
|
42
|
+
this.trackId = crypto.randomUUID();
|
|
43
|
+
console.log('[BeforeInsert] set session cookiesId', this);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.AbstractDeviceBaseEntity = AbstractDeviceBaseEntity;
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, typeorm_1.Column)({ type: 'varchar', nullable: true }),
|
|
50
|
+
__metadata("design:type", String)
|
|
51
|
+
], AbstractDeviceBaseEntity.prototype, "userAgent", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, typeorm_1.Column)({ type: 'varchar', nullable: true }),
|
|
54
|
+
__metadata("design:type", String)
|
|
55
|
+
], AbstractDeviceBaseEntity.prototype, "os", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, typeorm_1.Column)({ type: 'varchar', nullable: true }),
|
|
58
|
+
__metadata("design:type", String)
|
|
59
|
+
], AbstractDeviceBaseEntity.prototype, "label", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
(0, typeorm_1.Column)({ type: 'varchar', nullable: true }),
|
|
62
|
+
__metadata("design:type", String)
|
|
63
|
+
], AbstractDeviceBaseEntity.prototype, "type", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
(0, typeorm_1.Column)({ type: 'varchar', nullable: true }),
|
|
66
|
+
__metadata("design:type", String)
|
|
67
|
+
], AbstractDeviceBaseEntity.prototype, "aspectRatio", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
(0, typeorm_1.Column)({ type: 'varchar', nullable: true }),
|
|
70
|
+
__metadata("design:type", String)
|
|
71
|
+
], AbstractDeviceBaseEntity.prototype, "trackId", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, typeorm_1.BeforeInsert)(),
|
|
74
|
+
__metadata("design:type", Function),
|
|
75
|
+
__metadata("design:paramtypes", []),
|
|
76
|
+
__metadata("design:returntype", void 0)
|
|
77
|
+
], AbstractDeviceBaseEntity.prototype, "addCookiesId", null);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AppBaseEntity } from '@my-nestjs-kit/core';
|
|
2
|
+
import { ProviderNameEnum } from '@my-nestjs-kit/core';
|
|
3
|
+
export declare class ConfigsEndpointsEmbeddedEntity {
|
|
4
|
+
auth?: string;
|
|
5
|
+
refresh?: string;
|
|
6
|
+
redirect?: string;
|
|
7
|
+
support?: string;
|
|
8
|
+
getAuthUrl?: string;
|
|
9
|
+
privacyPolicy?: string;
|
|
10
|
+
terms?: string;
|
|
11
|
+
webhook?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare abstract class AbstractOAuthConnectionEntity extends AppBaseEntity {
|
|
14
|
+
provider?: ProviderNameEnum;
|
|
15
|
+
label?: string;
|
|
16
|
+
privateKey: string;
|
|
17
|
+
publicKey: string;
|
|
18
|
+
endpoints?: ConfigsEndpointsEmbeddedEntity;
|
|
19
|
+
scopes?: string[];
|
|
20
|
+
domain?: string;
|
|
21
|
+
origin?: string;
|
|
22
|
+
supportInfo?: {
|
|
23
|
+
email?: string;
|
|
24
|
+
phone?: string;
|
|
25
|
+
};
|
|
26
|
+
isActive?: boolean;
|
|
27
|
+
status?: string;
|
|
28
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AbstractOAuthConnectionEntity = exports.ConfigsEndpointsEmbeddedEntity = void 0;
|
|
13
|
+
const core_1 = require("@my-nestjs-kit/core");
|
|
14
|
+
const core_2 = require("@my-nestjs-kit/core");
|
|
15
|
+
const typeorm_1 = require("typeorm");
|
|
16
|
+
const core_3 = require("@my-nestjs-kit/core");
|
|
17
|
+
const core_4 = require("@my-nestjs-kit/core");
|
|
18
|
+
class ConfigsEndpointsEmbeddedEntity {
|
|
19
|
+
}
|
|
20
|
+
exports.ConfigsEndpointsEmbeddedEntity = ConfigsEndpointsEmbeddedEntity;
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, core_2.ColumnVarchar255)({ nullable: true }),
|
|
23
|
+
(0, core_4.IsURLProperty)(),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], ConfigsEndpointsEmbeddedEntity.prototype, "auth", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, core_2.ColumnVarchar255)({ nullable: true }),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], ConfigsEndpointsEmbeddedEntity.prototype, "refresh", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, core_2.ColumnVarchar255)({ nullable: true }),
|
|
32
|
+
__metadata("design:type", String)
|
|
33
|
+
], ConfigsEndpointsEmbeddedEntity.prototype, "redirect", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, core_2.ColumnVarchar255)({ nullable: true }),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], ConfigsEndpointsEmbeddedEntity.prototype, "support", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, core_2.ColumnVarchar255)({ nullable: true }),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], ConfigsEndpointsEmbeddedEntity.prototype, "getAuthUrl", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, core_2.ColumnVarchar255)({ nullable: true }),
|
|
44
|
+
__metadata("design:type", String)
|
|
45
|
+
], ConfigsEndpointsEmbeddedEntity.prototype, "privacyPolicy", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, core_2.ColumnVarchar255)({ nullable: true }),
|
|
48
|
+
__metadata("design:type", String)
|
|
49
|
+
], ConfigsEndpointsEmbeddedEntity.prototype, "terms", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, core_2.ColumnVarchar255)({ nullable: true }),
|
|
52
|
+
__metadata("design:type", String)
|
|
53
|
+
], ConfigsEndpointsEmbeddedEntity.prototype, "webhook", void 0);
|
|
54
|
+
class AbstractOAuthConnectionEntity extends core_1.AppBaseEntity {
|
|
55
|
+
}
|
|
56
|
+
exports.AbstractOAuthConnectionEntity = AbstractOAuthConnectionEntity;
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, core_2.ColumnVarchar64)({ nullable: true }),
|
|
59
|
+
__metadata("design:type", String)
|
|
60
|
+
], AbstractOAuthConnectionEntity.prototype, "provider", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, core_2.ColumnVarchar255)({ nullable: true }),
|
|
63
|
+
__metadata("design:type", String)
|
|
64
|
+
], AbstractOAuthConnectionEntity.prototype, "label", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, core_2.ColumnVarchar255)({ nullable: true }),
|
|
67
|
+
__metadata("design:type", String)
|
|
68
|
+
], AbstractOAuthConnectionEntity.prototype, "privateKey", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, core_2.ColumnVarchar255)({ nullable: true, unique: true }),
|
|
71
|
+
__metadata("design:type", String)
|
|
72
|
+
], AbstractOAuthConnectionEntity.prototype, "publicKey", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
(0, typeorm_1.Column)(() => ConfigsEndpointsEmbeddedEntity),
|
|
75
|
+
__metadata("design:type", ConfigsEndpointsEmbeddedEntity)
|
|
76
|
+
], AbstractOAuthConnectionEntity.prototype, "endpoints", void 0);
|
|
77
|
+
__decorate([
|
|
78
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 126, array: true, nullable: true }),
|
|
79
|
+
__metadata("design:type", Array)
|
|
80
|
+
], AbstractOAuthConnectionEntity.prototype, "scopes", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
(0, core_2.ColumnVarchar64)({ nullable: true }),
|
|
83
|
+
__metadata("design:type", String)
|
|
84
|
+
], AbstractOAuthConnectionEntity.prototype, "domain", void 0);
|
|
85
|
+
__decorate([
|
|
86
|
+
(0, core_2.ColumnVarchar255)({ nullable: true }),
|
|
87
|
+
__metadata("design:type", String)
|
|
88
|
+
], AbstractOAuthConnectionEntity.prototype, "origin", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
(0, typeorm_1.Column)({ type: 'json', nullable: true }),
|
|
91
|
+
__metadata("design:type", Object)
|
|
92
|
+
], AbstractOAuthConnectionEntity.prototype, "supportInfo", void 0);
|
|
93
|
+
__decorate([
|
|
94
|
+
(0, typeorm_1.Column)({ type: 'boolean', default: false, nullable: true }),
|
|
95
|
+
__metadata("design:type", Boolean)
|
|
96
|
+
], AbstractOAuthConnectionEntity.prototype, "isActive", void 0);
|
|
97
|
+
__decorate([
|
|
98
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
99
|
+
__metadata("design:type", String)
|
|
100
|
+
], AbstractOAuthConnectionEntity.prototype, "status", void 0);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AppBaseEntity } from '@my-nestjs-kit/core';
|
|
2
|
+
import { OAuth } from '../o-auth/o-auth.namespace';
|
|
3
|
+
import { ProviderNameEnum } from '@my-nestjs-kit/core';
|
|
4
|
+
export declare class AbstractOAuthProfileEntity<Provider extends ProviderNameEnum = ProviderNameEnum> extends AppBaseEntity {
|
|
5
|
+
provider?: Provider;
|
|
6
|
+
extId: string;
|
|
7
|
+
reference: string;
|
|
8
|
+
email?: string;
|
|
9
|
+
extra?: OAuth.Provider.ExtraDataJsonByType.MappedData[Provider];
|
|
10
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AbstractOAuthProfileEntity = void 0;
|
|
13
|
+
const core_1 = require("@my-nestjs-kit/core");
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
const core_2 = require("@my-nestjs-kit/core");
|
|
16
|
+
class AbstractOAuthProfileEntity extends core_1.AppBaseEntity {
|
|
17
|
+
}
|
|
18
|
+
exports.AbstractOAuthProfileEntity = AbstractOAuthProfileEntity;
|
|
19
|
+
__decorate([
|
|
20
|
+
(0, typeorm_1.Column)({ type: 'varchar', nullable: true }),
|
|
21
|
+
__metadata("design:type", String)
|
|
22
|
+
], AbstractOAuthProfileEntity.prototype, "provider", void 0);
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, typeorm_1.Column)({ type: 'varchar', nullable: true }),
|
|
25
|
+
__metadata("design:type", String)
|
|
26
|
+
], AbstractOAuthProfileEntity.prototype, "extId", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, typeorm_1.Column)({ type: 'varchar', nullable: true }),
|
|
29
|
+
__metadata("design:type", String)
|
|
30
|
+
], AbstractOAuthProfileEntity.prototype, "reference", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, core_2.ColumnVarchar255)({ nullable: true }),
|
|
33
|
+
__metadata("design:type", String)
|
|
34
|
+
], AbstractOAuthProfileEntity.prototype, "email", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, typeorm_1.Column)({ type: 'json', nullable: true }),
|
|
37
|
+
__metadata("design:type", Object)
|
|
38
|
+
], AbstractOAuthProfileEntity.prototype, "extra", void 0);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AppBaseEntity } from '@my-nestjs-kit/core';
|
|
2
|
+
import { AbstractDeviceBaseEntity } from './abstract-device-base.entity';
|
|
3
|
+
import { AbstractUserBaseEntity } from '@my-nestjs-kit/core';
|
|
4
|
+
import { ProviderNameEnum } from '@my-nestjs-kit/core';
|
|
5
|
+
export declare abstract class AuthSessionBaseEntity<Type extends string = any, Provider extends ProviderNameEnum = ProviderNameEnum> extends AppBaseEntity {
|
|
6
|
+
abstract user?: AbstractUserBaseEntity;
|
|
7
|
+
device?: AbstractDeviceBaseEntity;
|
|
8
|
+
access_token?: string;
|
|
9
|
+
refresh_token?: string;
|
|
10
|
+
expireAt?: string;
|
|
11
|
+
protocol?: 'ws' | 'wss' | 'http' | 'https' | string;
|
|
12
|
+
timeZone?: string;
|
|
13
|
+
ip?: string;
|
|
14
|
+
type?: Type;
|
|
15
|
+
tokenType?: string;
|
|
16
|
+
expiresIn?: number;
|
|
17
|
+
_onSoftRemove?: () => void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AuthSessionBaseEntity = void 0;
|
|
13
|
+
const core_1 = require("@my-nestjs-kit/core");
|
|
14
|
+
const core_2 = require("@my-nestjs-kit/core");
|
|
15
|
+
const typeorm_1 = require("typeorm");
|
|
16
|
+
const core_3 = require("@my-nestjs-kit/core");
|
|
17
|
+
class AuthSessionBaseEntity extends core_2.AppBaseEntity {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this._onSoftRemove = () => {
|
|
21
|
+
this.access_token = null;
|
|
22
|
+
this.refresh_token = null;
|
|
23
|
+
// this.verify_code = null;
|
|
24
|
+
// this.verify_token = null;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.AuthSessionBaseEntity = AuthSessionBaseEntity;
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], AuthSessionBaseEntity.prototype, "access_token", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], AuthSessionBaseEntity.prototype, "refresh_token", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.Column)({ type: 'timestamptz', nullable: true }),
|
|
39
|
+
(0, core_1.ApiPropDescriptor)(),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], AuthSessionBaseEntity.prototype, "expireAt", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, typeorm_1.Column)({ type: 'varchar', nullable: true }),
|
|
44
|
+
(0, core_1.ApiPropDescriptor)(),
|
|
45
|
+
__metadata("design:type", String)
|
|
46
|
+
], AuthSessionBaseEntity.prototype, "protocol", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, typeorm_1.Column)({ type: 'varchar', nullable: true }),
|
|
49
|
+
(0, core_1.ApiPropDescriptor)(),
|
|
50
|
+
__metadata("design:type", String)
|
|
51
|
+
], AuthSessionBaseEntity.prototype, "timeZone", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, typeorm_1.Column)({ type: 'varchar', nullable: true }),
|
|
54
|
+
(0, core_1.ApiPropDescriptor)(),
|
|
55
|
+
__metadata("design:type", String)
|
|
56
|
+
], AuthSessionBaseEntity.prototype, "ip", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, typeorm_1.Column)({ type: 'varchar', nullable: true }),
|
|
59
|
+
__metadata("design:type", String)
|
|
60
|
+
], AuthSessionBaseEntity.prototype, "type", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, core_3.ColumnVarchar64)({ nullable: true }),
|
|
63
|
+
__metadata("design:type", String)
|
|
64
|
+
], AuthSessionBaseEntity.prototype, "tokenType", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, typeorm_1.Column)({ type: 'integer', nullable: true }),
|
|
67
|
+
__metadata("design:type", Number)
|
|
68
|
+
], AuthSessionBaseEntity.prototype, "expiresIn", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, typeorm_1.BeforeSoftRemove)(),
|
|
71
|
+
(0, typeorm_1.BeforeRemove)(),
|
|
72
|
+
__metadata("design:type", Function)
|
|
73
|
+
], AuthSessionBaseEntity.prototype, "_onSoftRemove", void 0);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import { AbstractAuthGuard, AuthGuardMeta } from './abstract/AppAuthGuard-abstract';
|
|
3
|
+
import { Reflector } from '@nestjs/core';
|
|
4
|
+
import type { AuthConfigs } from '../types/auth.types';
|
|
5
|
+
export declare abstract class AbstractRefreshJwtTokenGuard<AsyncInput = any> extends AbstractAuthGuard<AsyncInput> {
|
|
6
|
+
protected constructor(meta: AuthGuardMeta, reflector: Reflector);
|
|
7
|
+
validate(ctx: ExecutionContext, conf: AuthConfigs): boolean | Promise<boolean>;
|
|
8
|
+
abstract validateAsync(input: AsyncInput): Promise<boolean>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbstractRefreshJwtTokenGuard = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const AppAuthGuard_abstract_1 = require("./abstract/AppAuthGuard-abstract");
|
|
6
|
+
const core_1 = require("@my-nestjs-kit/core");
|
|
7
|
+
const core_2 = require("@my-nestjs-kit/core");
|
|
8
|
+
var HeaderName = core_1.HttpApi.HeaderName;
|
|
9
|
+
class AbstractRefreshJwtTokenGuard extends AppAuthGuard_abstract_1.AbstractAuthGuard {
|
|
10
|
+
constructor(meta, reflector) {
|
|
11
|
+
super(reflector, {
|
|
12
|
+
ignorePublic: true,
|
|
13
|
+
type: '',
|
|
14
|
+
cookiesKeys: [core_1.AppCookiesKeyEnum.refresh_token],
|
|
15
|
+
failStatusCode: common_1.HttpStatus.UNAUTHORIZED,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
validate(ctx, conf) {
|
|
19
|
+
const ctxType = ctx.getType();
|
|
20
|
+
const target = this.getTarget(ctxType, ctx);
|
|
21
|
+
const tValue = target.headers[HeaderName.doNotTrack.toLowerCase()];
|
|
22
|
+
const cookiesPermission = (0, core_2.isTruth)(tValue);
|
|
23
|
+
if (!cookiesPermission) {
|
|
24
|
+
if (!target.headers[HeaderName.refresh_token.toLowerCase()]) {
|
|
25
|
+
this.fail({
|
|
26
|
+
reason: 'Not found refresh token in cookies headers',
|
|
27
|
+
statusCode: common_1.HttpStatus.UNAUTHORIZED,
|
|
28
|
+
error: { cookiesPermission },
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else if (!('cookies' in target) ||
|
|
33
|
+
!target.cookies[core_1.AppCookiesKeyEnum.refresh_token]) {
|
|
34
|
+
this.fail({
|
|
35
|
+
reason: 'Not found refresh token in ',
|
|
36
|
+
statusCode: common_1.HttpStatus.UNAUTHORIZED,
|
|
37
|
+
error: {
|
|
38
|
+
cookiesPermission,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.AbstractRefreshJwtTokenGuard = AbstractRefreshJwtTokenGuard;
|