@lenne.tech/nest-server 8.6.25 → 8.6.26
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/config.env.js +3 -0
- package/dist/config.env.js.map +1 -1
- package/dist/core/common/helpers/service.helper.js +5 -3
- package/dist/core/common/helpers/service.helper.js.map +1 -1
- package/dist/core/common/interfaces/server-options.interface.d.ts +1 -0
- package/dist/core/modules/user/core-user.service.js +2 -1
- package/dist/core/modules/user/core-user.service.js.map +1 -1
- package/dist/server/modules/user/user.resolver.js +1 -2
- package/dist/server/modules/user/user.resolver.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/config.env.ts +3 -0
- package/src/core/common/helpers/service.helper.ts +5 -3
- package/src/core/common/interfaces/server-options.interface.ts +7 -0
- package/src/core/modules/user/core-user.service.ts +2 -1
- package/src/server/modules/user/user.resolver.ts +1 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lenne.tech/nest-server",
|
|
3
|
-
"version": "8.6.
|
|
3
|
+
"version": "8.6.26",
|
|
4
4
|
"description": "Modern, fast, powerful Node.js web framework in TypeScript based on Nest with a GraphQL API and a connection to MongoDB (or other databases).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
package/src/config.env.ts
CHANGED
|
@@ -55,6 +55,7 @@ const config: { [env: string]: IServerOptions } = {
|
|
|
55
55
|
uri: 'mongodb://localhost/nest-server-dev',
|
|
56
56
|
},
|
|
57
57
|
port: 3000,
|
|
58
|
+
sha256: true,
|
|
58
59
|
staticAssets: {
|
|
59
60
|
path: join(__dirname, '..', 'public'),
|
|
60
61
|
options: { prefix: '' },
|
|
@@ -105,6 +106,7 @@ const config: { [env: string]: IServerOptions } = {
|
|
|
105
106
|
uri: 'mongodb://localhost/nest-server-dev',
|
|
106
107
|
},
|
|
107
108
|
port: 3000,
|
|
109
|
+
sha256: true,
|
|
108
110
|
staticAssets: {
|
|
109
111
|
path: join(__dirname, '..', 'public'),
|
|
110
112
|
options: { prefix: '' },
|
|
@@ -155,6 +157,7 @@ const config: { [env: string]: IServerOptions } = {
|
|
|
155
157
|
uri: 'mongodb://localhost/nest-server-prod',
|
|
156
158
|
},
|
|
157
159
|
port: 3000,
|
|
160
|
+
sha256: true,
|
|
158
161
|
staticAssets: {
|
|
159
162
|
path: join(__dirname, '..', 'public'),
|
|
160
163
|
options: { prefix: '' },
|
|
@@ -4,6 +4,7 @@ import { plainToInstance } from 'class-transformer';
|
|
|
4
4
|
import { sha256 } from 'js-sha256';
|
|
5
5
|
import * as _ from 'lodash';
|
|
6
6
|
import { Types } from 'mongoose';
|
|
7
|
+
import envConfig from '../../../config.env';
|
|
7
8
|
import { RoleEnum } from '../enums/role.enum';
|
|
8
9
|
import { PrepareInputOptions } from '../interfaces/prepare-input-options.interface';
|
|
9
10
|
import { PrepareOutputOptions } from '../interfaces/prepare-output-options.interface';
|
|
@@ -133,9 +134,10 @@ export async function prepareInput<T = any>(
|
|
|
133
134
|
if ((input as any).password) {
|
|
134
135
|
// Check if the password was transmitted encrypted
|
|
135
136
|
// If not, the password is encrypted to enable future encrypted and unencrypted transmissions
|
|
136
|
-
(input as any).password =
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
(input as any).password =
|
|
138
|
+
!envConfig.sha256 || /^[a-f0-9]{64}$/i.test((input as any).password)
|
|
139
|
+
? (input as any).password
|
|
140
|
+
: sha256((input as any).password);
|
|
139
141
|
|
|
140
142
|
// Hash password
|
|
141
143
|
(input as any).password = await bcrypt.hash((input as any).password, 10);
|
|
@@ -4,6 +4,7 @@ import { JwtModuleOptions } from '@nestjs/jwt';
|
|
|
4
4
|
import { MongooseModuleOptions } from '@nestjs/mongoose';
|
|
5
5
|
import { ServeStaticOptions } from '@nestjs/platform-express/interfaces/serve-static-options.interface';
|
|
6
6
|
import { CronExpression } from '@nestjs/schedule';
|
|
7
|
+
import { sha256 } from 'js-sha256';
|
|
7
8
|
import * as SMTPTransport from 'nodemailer/lib/smtp-transport';
|
|
8
9
|
import { Falsy } from '../types/falsy.type';
|
|
9
10
|
import { CronJobConfig } from './cron-job-config.interface';
|
|
@@ -156,6 +157,12 @@ export interface IServerOptions {
|
|
|
156
157
|
path?: string;
|
|
157
158
|
};
|
|
158
159
|
|
|
160
|
+
/**
|
|
161
|
+
* Whether to enable verification and automatic encryption for received passwords that are not in sha256 format
|
|
162
|
+
* default = false, sha256 format check: /^[a-f0-9]{64}$/i
|
|
163
|
+
*/
|
|
164
|
+
sha256?: boolean;
|
|
165
|
+
|
|
159
166
|
/**
|
|
160
167
|
* Templates
|
|
161
168
|
*/
|
|
@@ -3,6 +3,7 @@ import * as bcrypt from 'bcrypt';
|
|
|
3
3
|
import * as crypto from 'crypto';
|
|
4
4
|
import { sha256 } from 'js-sha256';
|
|
5
5
|
import { Document, Model } from 'mongoose';
|
|
6
|
+
import envConfig from '../../../config.env';
|
|
6
7
|
import { merge } from '../../common/helpers/config.helper';
|
|
7
8
|
import { assignPlain } from '../../common/helpers/input.helper';
|
|
8
9
|
import { ServiceOptions } from '../../common/interfaces/service-options.interface';
|
|
@@ -131,7 +132,7 @@ export abstract class CoreUserService<
|
|
|
131
132
|
async () => {
|
|
132
133
|
// Check if the password was transmitted encrypted
|
|
133
134
|
// If not, the password is encrypted to enable future encrypted and unencrypted transmissions
|
|
134
|
-
newPassword = /^[a-f0-9]{64}$/i.test(newPassword) ? newPassword : sha256(newPassword);
|
|
135
|
+
newPassword = !envConfig.sha256 || /^[a-f0-9]{64}$/i.test(newPassword) ? newPassword : sha256(newPassword);
|
|
135
136
|
|
|
136
137
|
// Update and return user
|
|
137
138
|
return await assignPlain(dbObject, {
|
|
@@ -54,7 +54,7 @@ export class UserResolver {
|
|
|
54
54
|
/**
|
|
55
55
|
* Get verified state of user with token
|
|
56
56
|
*/
|
|
57
|
-
@Roles(RoleEnum.
|
|
57
|
+
@Roles(RoleEnum.S_EVERYONE)
|
|
58
58
|
@Query(() => Boolean, { description: 'Get verified state of user with token' })
|
|
59
59
|
async getVerifiedState(@Args('token') token: string) {
|
|
60
60
|
return await this.userService.getVerifiedState(token);
|
|
@@ -148,7 +148,6 @@ export class UserResolver {
|
|
|
148
148
|
/**
|
|
149
149
|
* Subscription for created user
|
|
150
150
|
*/
|
|
151
|
-
@Roles(RoleEnum.ADMIN)
|
|
152
151
|
@Subscription(() => User, {
|
|
153
152
|
filter(this: UserResolver, payload, variables, context) {
|
|
154
153
|
return context?.user?.hasRole?.(RoleEnum.ADMIN);
|