@skroz/profile-api 1.0.7 → 1.0.9
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/adapters/TypeOrmProfileAdapter.d.ts +3 -2
- package/dist/adapters/TypeOrmProfileAdapter.js +11 -8
- package/dist/dto/ConfirmEmailInput.d.ts +1 -1
- package/dist/dto/ConfirmEmailInput.js +3 -3
- package/dist/dto/ForgotPasswordInput.d.ts +1 -1
- package/dist/dto/ForgotPasswordInput.js +3 -3
- package/dist/dto/LoginInput.d.ts +2 -2
- package/dist/dto/LoginInput.js +38 -5
- package/dist/dto/PasswordInput.d.ts +1 -1
- package/dist/dto/PasswordInput.js +3 -3
- package/dist/dto/RecoverPasswordInput.d.ts +2 -2
- package/dist/dto/RecoverPasswordInput.js +38 -5
- package/dist/dto/RegisterInput.d.ts +2 -2
- package/dist/dto/RegisterInput.js +38 -5
- package/dist/dto/SendTokenPayload.d.ts +2 -2
- package/dist/dto/SendTokenPayload.js +3 -4
- package/dist/dto/StatusPayload.d.ts +1 -1
- package/dist/dto/StatusPayload.js +2 -3
- package/dist/dto/UpdateEmailInput.d.ts +1 -1
- package/dist/dto/UpdateEmailInput.js +3 -3
- package/dist/dto/UpdatePasswordInput.d.ts +2 -2
- package/dist/dto/UpdatePasswordInput.js +38 -5
- package/dist/dto/UpdateProfileInput.d.ts +1 -1
- package/dist/dto/UpdateProfileInput.js +3 -3
- package/dist/dto/index.d.ts +11 -11
- package/dist/dto/index.js +42 -24
- package/dist/email-templates/base/content.pug +32 -0
- package/dist/email-templates/base/header.pug +28 -0
- package/dist/email-templates/base/layout.pug +34 -0
- package/dist/email-templates/base/mixins.pug +16 -0
- package/dist/email-templates/confirmEmail.pug +16 -0
- package/dist/email-templates/forgotPassword.pug +16 -0
- package/dist/email-templates/notification.pug +14 -0
- package/dist/email-templates/tempPassword.pug +14 -0
- package/dist/resolvers/AuthResolver.d.ts +1 -24
- package/dist/resolvers/AuthResolver.js +6 -3
- package/dist/resolvers/ProfileResolver.d.ts +1 -18
- package/dist/resolvers/ProfileResolver.js +8 -2
- package/dist/services/ProfileEmailService.js +2 -2
- package/dist/types/index.d.ts +1 -1
- package/package.json +7 -7
- package/src/adapters/TypeOrmProfileAdapter.ts +10 -10
- package/src/dto/ConfirmEmailInput.ts +1 -1
- package/src/dto/ForgotPasswordInput.ts +1 -1
- package/src/dto/LoginInput.ts +2 -2
- package/src/dto/PasswordInput.ts +1 -1
- package/src/dto/RecoverPasswordInput.ts +2 -2
- package/src/dto/RegisterInput.ts +2 -2
- package/src/dto/SendTokenPayload.ts +2 -2
- package/src/dto/StatusPayload.ts +1 -1
- package/src/dto/UpdateEmailInput.ts +1 -1
- package/src/dto/UpdatePasswordInput.ts +2 -2
- package/src/dto/UpdateProfileInput.ts +1 -1
- package/src/dto/index.ts +11 -11
- package/src/email-templates/base/content.pug +32 -0
- package/src/email-templates/base/header.pug +28 -0
- package/src/email-templates/base/layout.pug +34 -0
- package/src/email-templates/base/mixins.pug +16 -0
- package/src/email-templates/confirmEmail.pug +16 -0
- package/src/email-templates/forgotPassword.pug +16 -0
- package/src/email-templates/notification.pug +14 -0
- package/src/email-templates/tempPassword.pug +14 -0
- package/src/resolvers/AuthResolver.ts +76 -30
- package/src/resolvers/ProfileResolver.ts +125 -98
- package/src/services/ProfileEmailService.ts +147 -147
- package/src/types/index.ts +1 -1
package/dist/dto/index.js
CHANGED
|
@@ -1,27 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
16
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
6
|
+
exports.recoverPasswordValidators = exports.recoverPasswordTransformers = exports.RecoverPasswordInput = exports.updateProfileValidators = exports.updateProfileTransformers = exports.UpdateProfileInput = exports.updateEmailValidators = exports.updateEmailTransformers = exports.UpdateEmailInput = exports.updatePasswordValidators = exports.updatePasswordTransformers = exports.UpdatePasswordInput = exports.SendTokenPayload = exports.StatusPayload = exports.confirmEmailValidators = exports.ConfirmEmailInput = exports.forgotPasswordValidators = exports.forgotPasswordTransformers = exports.ForgotPasswordInput = exports.loginValidators = exports.loginTransformers = exports.LoginInput = exports.registerValidators = exports.registerTransformers = exports.RegisterInput = exports.passwordValidators = exports.passwordTransformers = exports.PasswordInput = void 0;
|
|
7
|
+
var PasswordInput_1 = require("./PasswordInput");
|
|
8
|
+
Object.defineProperty(exports, "PasswordInput", { enumerable: true, get: function () { return __importDefault(PasswordInput_1).default; } });
|
|
9
|
+
Object.defineProperty(exports, "passwordTransformers", { enumerable: true, get: function () { return PasswordInput_1.passwordTransformers; } });
|
|
10
|
+
Object.defineProperty(exports, "passwordValidators", { enumerable: true, get: function () { return PasswordInput_1.passwordValidators; } });
|
|
11
|
+
var RegisterInput_1 = require("./RegisterInput");
|
|
12
|
+
Object.defineProperty(exports, "RegisterInput", { enumerable: true, get: function () { return __importDefault(RegisterInput_1).default; } });
|
|
13
|
+
Object.defineProperty(exports, "registerTransformers", { enumerable: true, get: function () { return RegisterInput_1.registerTransformers; } });
|
|
14
|
+
Object.defineProperty(exports, "registerValidators", { enumerable: true, get: function () { return RegisterInput_1.registerValidators; } });
|
|
15
|
+
var LoginInput_1 = require("./LoginInput");
|
|
16
|
+
Object.defineProperty(exports, "LoginInput", { enumerable: true, get: function () { return __importDefault(LoginInput_1).default; } });
|
|
17
|
+
Object.defineProperty(exports, "loginTransformers", { enumerable: true, get: function () { return LoginInput_1.loginTransformers; } });
|
|
18
|
+
Object.defineProperty(exports, "loginValidators", { enumerable: true, get: function () { return LoginInput_1.loginValidators; } });
|
|
19
|
+
var ForgotPasswordInput_1 = require("./ForgotPasswordInput");
|
|
20
|
+
Object.defineProperty(exports, "ForgotPasswordInput", { enumerable: true, get: function () { return __importDefault(ForgotPasswordInput_1).default; } });
|
|
21
|
+
Object.defineProperty(exports, "forgotPasswordTransformers", { enumerable: true, get: function () { return ForgotPasswordInput_1.forgotPasswordTransformers; } });
|
|
22
|
+
Object.defineProperty(exports, "forgotPasswordValidators", { enumerable: true, get: function () { return ForgotPasswordInput_1.forgotPasswordValidators; } });
|
|
23
|
+
var ConfirmEmailInput_1 = require("./ConfirmEmailInput");
|
|
24
|
+
Object.defineProperty(exports, "ConfirmEmailInput", { enumerable: true, get: function () { return __importDefault(ConfirmEmailInput_1).default; } });
|
|
25
|
+
Object.defineProperty(exports, "confirmEmailValidators", { enumerable: true, get: function () { return ConfirmEmailInput_1.confirmEmailValidators; } });
|
|
26
|
+
var StatusPayload_1 = require("./StatusPayload");
|
|
27
|
+
Object.defineProperty(exports, "StatusPayload", { enumerable: true, get: function () { return __importDefault(StatusPayload_1).default; } });
|
|
28
|
+
var SendTokenPayload_1 = require("./SendTokenPayload");
|
|
29
|
+
Object.defineProperty(exports, "SendTokenPayload", { enumerable: true, get: function () { return __importDefault(SendTokenPayload_1).default; } });
|
|
30
|
+
var UpdatePasswordInput_1 = require("./UpdatePasswordInput");
|
|
31
|
+
Object.defineProperty(exports, "UpdatePasswordInput", { enumerable: true, get: function () { return __importDefault(UpdatePasswordInput_1).default; } });
|
|
32
|
+
Object.defineProperty(exports, "updatePasswordTransformers", { enumerable: true, get: function () { return UpdatePasswordInput_1.updatePasswordTransformers; } });
|
|
33
|
+
Object.defineProperty(exports, "updatePasswordValidators", { enumerable: true, get: function () { return UpdatePasswordInput_1.updatePasswordValidators; } });
|
|
34
|
+
var UpdateEmailInput_1 = require("./UpdateEmailInput");
|
|
35
|
+
Object.defineProperty(exports, "UpdateEmailInput", { enumerable: true, get: function () { return __importDefault(UpdateEmailInput_1).default; } });
|
|
36
|
+
Object.defineProperty(exports, "updateEmailTransformers", { enumerable: true, get: function () { return UpdateEmailInput_1.updateEmailTransformers; } });
|
|
37
|
+
Object.defineProperty(exports, "updateEmailValidators", { enumerable: true, get: function () { return UpdateEmailInput_1.updateEmailValidators; } });
|
|
38
|
+
var UpdateProfileInput_1 = require("./UpdateProfileInput");
|
|
39
|
+
Object.defineProperty(exports, "UpdateProfileInput", { enumerable: true, get: function () { return __importDefault(UpdateProfileInput_1).default; } });
|
|
40
|
+
Object.defineProperty(exports, "updateProfileTransformers", { enumerable: true, get: function () { return UpdateProfileInput_1.updateProfileTransformers; } });
|
|
41
|
+
Object.defineProperty(exports, "updateProfileValidators", { enumerable: true, get: function () { return UpdateProfileInput_1.updateProfileValidators; } });
|
|
42
|
+
var RecoverPasswordInput_1 = require("./RecoverPasswordInput");
|
|
43
|
+
Object.defineProperty(exports, "RecoverPasswordInput", { enumerable: true, get: function () { return __importDefault(RecoverPasswordInput_1).default; } });
|
|
44
|
+
Object.defineProperty(exports, "recoverPasswordTransformers", { enumerable: true, get: function () { return RecoverPasswordInput_1.recoverPasswordTransformers; } });
|
|
45
|
+
Object.defineProperty(exports, "recoverPasswordValidators", { enumerable: true, get: function () { return RecoverPasswordInput_1.recoverPasswordValidators; } });
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
table(
|
|
2
|
+
width='600px'
|
|
3
|
+
bgcolor='#f4f8fc'
|
|
4
|
+
border='0'
|
|
5
|
+
cellspacing='0'
|
|
6
|
+
cellpadding='0'
|
|
7
|
+
style={
|
|
8
|
+
'margin': '15px',
|
|
9
|
+
'width': 'inherit',
|
|
10
|
+
'max-width': '600px',
|
|
11
|
+
'min-width': '600px',
|
|
12
|
+
'border-radius': '25px',
|
|
13
|
+
'-webkit-border-radius': '25px',
|
|
14
|
+
'-moz-border-radius': '25px'
|
|
15
|
+
}
|
|
16
|
+
)
|
|
17
|
+
tr
|
|
18
|
+
td(valign='top')
|
|
19
|
+
include header
|
|
20
|
+
|
|
21
|
+
tr
|
|
22
|
+
td(
|
|
23
|
+
align='left'
|
|
24
|
+
valign='top'
|
|
25
|
+
style={
|
|
26
|
+
'padding-left': '25px',
|
|
27
|
+
'padding-right': '25px',
|
|
28
|
+
'padding-bottom': '35px',
|
|
29
|
+
'overflow-wrap': 'break-word'
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
block content
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
table(
|
|
2
|
+
width='100%'
|
|
3
|
+
bgcolor='#ff0066'
|
|
4
|
+
border='0'
|
|
5
|
+
cellspacing='0'
|
|
6
|
+
cellpadding='0'
|
|
7
|
+
style={
|
|
8
|
+
'border-radius': '25px 25px 0 0',
|
|
9
|
+
'-webkit-border-radius': '25px 25px 0 0',
|
|
10
|
+
'-moz-border-radius': '25px 25px 0 0'
|
|
11
|
+
}
|
|
12
|
+
)
|
|
13
|
+
tr
|
|
14
|
+
td(
|
|
15
|
+
align='center'
|
|
16
|
+
height='60px'
|
|
17
|
+
style={
|
|
18
|
+
'line-height': '1',
|
|
19
|
+
}
|
|
20
|
+
)
|
|
21
|
+
a(href=websiteUrl)
|
|
22
|
+
img(
|
|
23
|
+
src=logoUrl
|
|
24
|
+
height='26px'
|
|
25
|
+
style={
|
|
26
|
+
'margin-top': '2px',
|
|
27
|
+
}
|
|
28
|
+
)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
doctype html
|
|
2
|
+
html
|
|
3
|
+
head
|
|
4
|
+
meta(http-equiv='Content-Type' content='text/html; charset=utf-8')
|
|
5
|
+
meta(name='viewport' content='width=device-width, initial-scale=1.0')
|
|
6
|
+
|
|
7
|
+
body(
|
|
8
|
+
style={
|
|
9
|
+
'margin': '0',
|
|
10
|
+
'padding': '0',
|
|
11
|
+
'width': '100% !important',
|
|
12
|
+
'height': '100% !important',
|
|
13
|
+
'max-width': '100%',
|
|
14
|
+
'font-family': '"Helvetica Neue", Helvetica, Arial, sans-serif',
|
|
15
|
+
'font-size': '16px',
|
|
16
|
+
'line-height': '1.5',
|
|
17
|
+
'color': '#222',
|
|
18
|
+
'border-collapse': 'collapse',
|
|
19
|
+
'-webkit-font-smoothing': 'antialiased',
|
|
20
|
+
'-webkit-text-size-adjust': 'none',
|
|
21
|
+
'-ms-text-size-adjust': '100%',
|
|
22
|
+
'border-spacing': '0'
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
table(
|
|
26
|
+
width='100%'
|
|
27
|
+
align='center'
|
|
28
|
+
border='0'
|
|
29
|
+
cellspacing='0'
|
|
30
|
+
cellpadding='0'
|
|
31
|
+
)
|
|
32
|
+
tr
|
|
33
|
+
td(align='center' valign='top')
|
|
34
|
+
include content
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
mixin header(title)
|
|
2
|
+
h1(style={
|
|
3
|
+
'font-size': '26px',
|
|
4
|
+
'font-weight': '500',
|
|
5
|
+
'margin-top': '20px',
|
|
6
|
+
'margin-bottom': '15px',
|
|
7
|
+
})= title
|
|
8
|
+
|
|
9
|
+
mixin link(href, title)
|
|
10
|
+
if href
|
|
11
|
+
a(
|
|
12
|
+
href=href
|
|
13
|
+
style={
|
|
14
|
+
'color': '#1890ff'
|
|
15
|
+
}
|
|
16
|
+
)= title
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
extends base/layout
|
|
2
|
+
include base/mixins
|
|
3
|
+
|
|
4
|
+
block content
|
|
5
|
+
//+header(header)
|
|
6
|
+
//p #{' ' + text}
|
|
7
|
+
//if (link)
|
|
8
|
+
// +link(link.href, link.label)
|
|
9
|
+
//div(style='margin-top: 30px;')
|
|
10
|
+
// strong #{mistakeHeader}
|
|
11
|
+
// br
|
|
12
|
+
// | #{mistakeText}
|
|
13
|
+
div(style='margin-top: 30px; background-color: white; border-radius: 25px; padding: 20px; text-align: center; font-size: 30px ')
|
|
14
|
+
strong #{confirmationToken}
|
|
15
|
+
div(style='margin-top: 30px; text-align: center; font-size: 25px ')
|
|
16
|
+
p #{header}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
extends base/layout
|
|
2
|
+
include base/mixins
|
|
3
|
+
|
|
4
|
+
block content
|
|
5
|
+
//+header(header)
|
|
6
|
+
//p #{' ' + text}
|
|
7
|
+
//if (link)
|
|
8
|
+
// +link(link.href, link.label)
|
|
9
|
+
//div(style='margin-top: 30px;')
|
|
10
|
+
// strong #{mistakeHeader}
|
|
11
|
+
// br
|
|
12
|
+
// | #{mistakeText}
|
|
13
|
+
div(style='margin-top: 30px; background-color: white; border-radius: 25px; padding: 20px; text-align: center; font-size: 30px ')
|
|
14
|
+
strong #{confirmationToken}
|
|
15
|
+
div(style='margin-top: 30px; text-align: center; font-size: 25px ')
|
|
16
|
+
p #{header}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
extends base/layout
|
|
2
|
+
include base/mixins
|
|
3
|
+
|
|
4
|
+
block content
|
|
5
|
+
+header(header)
|
|
6
|
+
p #{' ' + text}
|
|
7
|
+
if (link)
|
|
8
|
+
+link(link.href, link.label)
|
|
9
|
+
div(style='margin-top: 30px;')
|
|
10
|
+
strong #{mistakeHeader}
|
|
11
|
+
a(href=unsubscribeLink)
|
|
12
|
+
strong Отписаться
|
|
13
|
+
br
|
|
14
|
+
| #{mistakeText}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
extends base/layout
|
|
2
|
+
include base/mixins
|
|
3
|
+
|
|
4
|
+
block content
|
|
5
|
+
+header(header)
|
|
6
|
+
p #{' ' + text}
|
|
7
|
+
if (link)
|
|
8
|
+
+link(link.href, link.label)
|
|
9
|
+
div(style='margin-top: 30px;')
|
|
10
|
+
strong #{mistakeHeader}
|
|
11
|
+
a(href=unsubscribeLink)
|
|
12
|
+
strong Отписаться
|
|
13
|
+
br
|
|
14
|
+
| #{mistakeText}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ProfileAuthService } from '../services/ProfileAuthService';
|
|
2
2
|
import { ProfileContext } from '../types';
|
|
3
|
-
import { RegisterInput, LoginInput, ConfirmEmailInput, ForgotPasswordInput, RecoverPasswordInput } from '../dto';
|
|
4
3
|
export interface AuthResolverDependencies<TContext extends ProfileContext = ProfileContext> {
|
|
5
4
|
authService: ProfileAuthService | (() => ProfileAuthService);
|
|
6
5
|
userType: any;
|
|
@@ -13,26 +12,4 @@ export interface AuthResolverDependencies<TContext extends ProfileContext = Prof
|
|
|
13
12
|
sendError: (msg: string) => Promise<any>;
|
|
14
13
|
};
|
|
15
14
|
}
|
|
16
|
-
export declare function createAuthResolver<TContext extends ProfileContext = ProfileContext>(deps: AuthResolverDependencies<TContext>):
|
|
17
|
-
new (): {
|
|
18
|
-
register(input: RegisterInput, ctx: TContext): Promise<{
|
|
19
|
-
ok: boolean;
|
|
20
|
-
}>;
|
|
21
|
-
login(input: LoginInput, ctx: TContext): Promise<{
|
|
22
|
-
ok: boolean;
|
|
23
|
-
}>;
|
|
24
|
-
logout(ctx: TContext): Promise<{
|
|
25
|
-
ok: boolean;
|
|
26
|
-
}>;
|
|
27
|
-
confirmEmail(input: ConfirmEmailInput, ctx: TContext): Promise<{
|
|
28
|
-
ok: boolean;
|
|
29
|
-
}>;
|
|
30
|
-
forgotPassword(input: ForgotPasswordInput, ctx: TContext): Promise<{
|
|
31
|
-
confirmationLinkIsSent: boolean;
|
|
32
|
-
limitExpiresAt: number;
|
|
33
|
-
}>;
|
|
34
|
-
recoverPassword(input: RecoverPasswordInput, ctx: TContext): Promise<{
|
|
35
|
-
ok: boolean;
|
|
36
|
-
}>;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
15
|
+
export declare function createAuthResolver<TContext extends ProfileContext = ProfileContext>(deps: AuthResolverDependencies<TContext>): any;
|
|
@@ -29,7 +29,7 @@ const graphql_validators_1 = require("@os-team/graphql-validators");
|
|
|
29
29
|
const ProfileAuthService_1 = require("../services/ProfileAuthService");
|
|
30
30
|
const dto_1 = require("../dto");
|
|
31
31
|
function createAuthResolver(deps) {
|
|
32
|
-
const { authService, onUserCreated, onLogin, onLogout, onEmailConfirmed, onPasswordRecovered, logTelegramBot, userType } = deps;
|
|
32
|
+
const { authService, onUserCreated, onLogin, onLogout, onEmailConfirmed, onPasswordRecovered, logTelegramBot, userType, } = deps;
|
|
33
33
|
const getAuthService = () => {
|
|
34
34
|
if (typeof authService === 'function')
|
|
35
35
|
return authService();
|
|
@@ -135,7 +135,7 @@ function createAuthResolver(deps) {
|
|
|
135
135
|
yield logTelegramBot.sendError(`${user.email || user.urlSlug} запросил(а) восстановление пароля`);
|
|
136
136
|
}
|
|
137
137
|
return {
|
|
138
|
-
|
|
138
|
+
recoveryLinkIsSent: res.ok,
|
|
139
139
|
limitExpiresAt: res.limitExpiresAt,
|
|
140
140
|
};
|
|
141
141
|
});
|
|
@@ -194,7 +194,10 @@ function createAuthResolver(deps) {
|
|
|
194
194
|
__metadata("design:returntype", Promise)
|
|
195
195
|
], AuthResolver.prototype, "logout", null);
|
|
196
196
|
__decorate([
|
|
197
|
-
(0, graphql_validators_1.ValidateArgs)(dto_1.confirmEmailValidators, {
|
|
197
|
+
(0, graphql_validators_1.ValidateArgs)(dto_1.confirmEmailValidators, {
|
|
198
|
+
arg: 'input',
|
|
199
|
+
tKey: 'confirmEmail',
|
|
200
|
+
}),
|
|
198
201
|
(0, type_graphql_1.Mutation)(() => graphql_utils_1.StatusPayload),
|
|
199
202
|
__param(0, (0, type_graphql_1.Arg)('input')),
|
|
200
203
|
__param(1, (0, type_graphql_1.Ctx)()),
|
|
@@ -1,24 +1,7 @@
|
|
|
1
1
|
import { ProfileAuthService } from '../services/ProfileAuthService';
|
|
2
2
|
import { ProfileContext } from '../types';
|
|
3
|
-
import { UpdateEmailInput, UpdatePasswordInput, UpdateProfileInput } from '../dto';
|
|
4
3
|
export interface ProfileResolverDependencies {
|
|
5
4
|
authService: ProfileAuthService | (() => ProfileAuthService);
|
|
6
5
|
userType: any;
|
|
7
6
|
}
|
|
8
|
-
export declare function createProfileResolver<TContext extends ProfileContext = ProfileContext>(deps: ProfileResolverDependencies):
|
|
9
|
-
new (): {
|
|
10
|
-
updateEmail(input: UpdateEmailInput, ctx: TContext): Promise<{
|
|
11
|
-
ok: boolean;
|
|
12
|
-
}>;
|
|
13
|
-
updatePassword(input: UpdatePasswordInput, ctx: TContext): Promise<{
|
|
14
|
-
ok: boolean;
|
|
15
|
-
}>;
|
|
16
|
-
updateProfile(input: UpdateProfileInput, ctx: TContext): Promise<import("../types").AuthUser>;
|
|
17
|
-
toggleEmailNotification(ctx: TContext): Promise<{
|
|
18
|
-
ok: boolean;
|
|
19
|
-
}>;
|
|
20
|
-
toggleTelegramNotification(ctx: TContext): Promise<{
|
|
21
|
-
ok: boolean;
|
|
22
|
-
}>;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
7
|
+
export declare function createProfileResolver<TContext extends ProfileContext = ProfileContext>(deps: ProfileResolverDependencies): any;
|
|
@@ -110,7 +110,10 @@ function createProfileResolver(deps) {
|
|
|
110
110
|
__decorate([
|
|
111
111
|
(0, type_graphql_1.Authorized)(),
|
|
112
112
|
(0, graphql_transformers_1.TransformArgs)(dto_1.updatePasswordTransformers, { arg: 'input' }),
|
|
113
|
-
(0, graphql_validators_1.ValidateArgs)(dto_1.updatePasswordValidators, {
|
|
113
|
+
(0, graphql_validators_1.ValidateArgs)(dto_1.updatePasswordValidators, {
|
|
114
|
+
arg: 'input',
|
|
115
|
+
tKey: 'updatePassword',
|
|
116
|
+
}),
|
|
114
117
|
(0, type_graphql_1.Mutation)(() => graphql_utils_1.StatusPayload),
|
|
115
118
|
__param(0, (0, type_graphql_1.Arg)('input')),
|
|
116
119
|
__param(1, (0, type_graphql_1.Ctx)()),
|
|
@@ -121,7 +124,10 @@ function createProfileResolver(deps) {
|
|
|
121
124
|
__decorate([
|
|
122
125
|
(0, type_graphql_1.Authorized)(),
|
|
123
126
|
(0, graphql_transformers_1.TransformArgs)(dto_1.updateProfileTransformers, { arg: 'input' }),
|
|
124
|
-
(0, graphql_validators_1.ValidateArgs)(dto_1.updateProfileValidators, {
|
|
127
|
+
(0, graphql_validators_1.ValidateArgs)(dto_1.updateProfileValidators, {
|
|
128
|
+
arg: 'input',
|
|
129
|
+
tKey: 'updateProfile',
|
|
130
|
+
}),
|
|
125
131
|
(0, type_graphql_1.Mutation)(() => userType),
|
|
126
132
|
__param(0, (0, type_graphql_1.Arg)('input')),
|
|
127
133
|
__param(1, (0, type_graphql_1.Ctx)()),
|
|
@@ -27,8 +27,8 @@ class ProfileEmailService {
|
|
|
27
27
|
return this.config.websiteUrl || `https://${this.config.domain}`;
|
|
28
28
|
}
|
|
29
29
|
render(templateName, vars) {
|
|
30
|
-
const templatePath = path_1.default.resolve(this.config.templateDir, `${templateName}.pug`);
|
|
31
|
-
return pug_1.default.renderFile(templatePath, Object.assign({ domain: this.config.domain, websiteUrl: this.getWebsiteUrl(), primaryBrandColor: this.config.primaryBrandColor, logoUrl: this.config.logoUrl || '' }, vars));
|
|
30
|
+
const templatePath = path_1.default.resolve(this.config.templateDir || path_1.default.resolve(__dirname, '../email-templates'), `${templateName}.pug`);
|
|
31
|
+
return pug_1.default.renderFile(templatePath, Object.assign({ domain: this.config.domain, websiteUrl: this.getWebsiteUrl(), primaryBrandColor: this.config.primaryBrandColor, logoUrl: this.config.logoUrl || '', link: vars.linkHref ? { href: vars.linkHref, label: vars.linkTitle } : undefined }, vars));
|
|
32
32
|
}
|
|
33
33
|
getFrom(type) {
|
|
34
34
|
const { domain } = this.config;
|
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skroz/profile-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "git@gitlab.com:skroz/libs/utils.git",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
],
|
|
13
13
|
"scripts": {
|
|
14
14
|
"clean": "rimraf dist",
|
|
15
|
-
"build": "yarn clean && tsc --outDir dist",
|
|
15
|
+
"build": "yarn clean && tsc --outDir dist && cp -R src/email-templates dist/email-templates",
|
|
16
16
|
"ncu": "ncu -u"
|
|
17
17
|
},
|
|
18
18
|
"publishConfig": {
|
|
@@ -27,9 +27,7 @@
|
|
|
27
27
|
"argon2": "0.30.2",
|
|
28
28
|
"class-validator": "0.13.2",
|
|
29
29
|
"nanoid": "3.3.4",
|
|
30
|
-
"pug": "3.0.2"
|
|
31
|
-
"type-graphql": "2.0.0-beta.1",
|
|
32
|
-
"typeorm": "0.2.45"
|
|
30
|
+
"pug": "3.0.2"
|
|
33
31
|
},
|
|
34
32
|
"devDependencies": {
|
|
35
33
|
"@types/node": "18.0.6",
|
|
@@ -39,7 +37,9 @@
|
|
|
39
37
|
"typescript": "^5.0.0"
|
|
40
38
|
},
|
|
41
39
|
"peerDependencies": {
|
|
42
|
-
"reflect-metadata": "0.1.13"
|
|
40
|
+
"reflect-metadata": "0.1.13",
|
|
41
|
+
"type-graphql": "^1.1.1",
|
|
42
|
+
"typeorm": "^0.2.45"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "3208ed23610d456e63fddd636448fe4585adf401"
|
|
45
45
|
}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { Repository,
|
|
1
|
+
import { Repository, Not } from 'typeorm';
|
|
2
2
|
import { AuthUser, ProfileDbAdapter } from '../types';
|
|
3
3
|
|
|
4
4
|
export class TypeOrmProfileAdapter implements ProfileDbAdapter {
|
|
5
|
-
private
|
|
5
|
+
constructor(private getRepository: () => any) { }
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
this.
|
|
7
|
+
private get repo(): Repository<any> {
|
|
8
|
+
return this.getRepository();
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
async findUserByEmail(email: string): Promise<AuthUser | null> {
|
|
12
|
-
return this.
|
|
12
|
+
return this.repo.findOne({ where: { email: email.toLowerCase() } }) as Promise<AuthUser | null>;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
async findUserById(id: number): Promise<AuthUser | null> {
|
|
16
|
-
return this.
|
|
16
|
+
return this.repo.findOne(id) as Promise<AuthUser | null>;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
async findUserByTelegramId(telegramId: string): Promise<AuthUser | null> {
|
|
20
|
-
return this.
|
|
20
|
+
return this.repo.findOne({ where: { telegramId } }) as Promise<AuthUser | null>;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
async createUser(data: { email: string; passwordHash: string }): Promise<AuthUser> {
|
|
24
|
-
const user = this.
|
|
24
|
+
const user = this.repo.create({
|
|
25
25
|
email: data.email.toLowerCase(),
|
|
26
26
|
password: data.passwordHash,
|
|
27
27
|
isEmailConfirmed: false,
|
|
28
28
|
});
|
|
29
|
-
return (await this.
|
|
29
|
+
return (await this.repo.save(user)) as AuthUser;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
async isEmailTaken(email: string, excludeUserId?: number): Promise<boolean> {
|
|
@@ -34,7 +34,7 @@ export class TypeOrmProfileAdapter implements ProfileDbAdapter {
|
|
|
34
34
|
if (excludeUserId) {
|
|
35
35
|
where.id = Not(excludeUserId);
|
|
36
36
|
}
|
|
37
|
-
const count = await this.
|
|
37
|
+
const count = await this.repo.count({ where });
|
|
38
38
|
return count > 0;
|
|
39
39
|
}
|
|
40
40
|
}
|
package/src/dto/LoginInput.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Field, InputType } from 'type-graphql';
|
|
2
2
|
import { isEmail, isNotEmpty } from '@os-team/graphql-validators';
|
|
3
3
|
import { toLowerCase, trim } from '@os-team/graphql-transformers';
|
|
4
|
-
import
|
|
4
|
+
import PasswordInput, { passwordTransformers } from './PasswordInput';
|
|
5
5
|
|
|
6
6
|
@InputType()
|
|
7
|
-
export class LoginInput extends PasswordInput {
|
|
7
|
+
export default class LoginInput extends PasswordInput {
|
|
8
8
|
@Field()
|
|
9
9
|
email!: string;
|
|
10
10
|
}
|
package/src/dto/PasswordInput.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Field, InputType } from 'type-graphql';
|
|
2
2
|
import { isNotEmpty } from '@os-team/graphql-validators';
|
|
3
3
|
import { trim } from '@os-team/graphql-transformers';
|
|
4
|
-
import
|
|
4
|
+
import PasswordInput, { passwordTransformers, passwordValidators } from './PasswordInput';
|
|
5
5
|
|
|
6
6
|
@InputType()
|
|
7
|
-
export class RecoverPasswordInput extends PasswordInput {
|
|
7
|
+
export default class RecoverPasswordInput extends PasswordInput {
|
|
8
8
|
@Field()
|
|
9
9
|
token!: string;
|
|
10
10
|
}
|
package/src/dto/RegisterInput.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Field, InputType } from 'type-graphql';
|
|
2
2
|
import { isEmail } from '@os-team/graphql-validators';
|
|
3
3
|
import { toLowerCase, trim } from '@os-team/graphql-transformers';
|
|
4
|
-
import
|
|
4
|
+
import PasswordInput, { passwordTransformers, passwordValidators } from './PasswordInput';
|
|
5
5
|
import isTrue from '../validators/isTrue';
|
|
6
6
|
|
|
7
7
|
@InputType()
|
|
8
|
-
export class RegisterInput extends PasswordInput {
|
|
8
|
+
export default class RegisterInput extends PasswordInput {
|
|
9
9
|
@Field()
|
|
10
10
|
email!: string;
|
|
11
11
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Field, ObjectType } from 'type-graphql';
|
|
2
2
|
|
|
3
3
|
@ObjectType()
|
|
4
|
-
export class SendTokenPayload {
|
|
4
|
+
export default class SendTokenPayload {
|
|
5
5
|
@Field()
|
|
6
|
-
|
|
6
|
+
recoveryLinkIsSent!: boolean;
|
|
7
7
|
|
|
8
8
|
@Field(() => Number, { nullable: true })
|
|
9
9
|
limitExpiresAt?: number;
|
package/src/dto/StatusPayload.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Field, InputType } from 'type-graphql';
|
|
2
2
|
import { isNotEmpty } from '@os-team/graphql-validators';
|
|
3
3
|
import { trim } from '@os-team/graphql-transformers';
|
|
4
|
-
import
|
|
4
|
+
import PasswordInput, { passwordTransformers, passwordValidators } from './PasswordInput';
|
|
5
5
|
|
|
6
6
|
@InputType()
|
|
7
|
-
export class UpdatePasswordInput extends PasswordInput {
|
|
7
|
+
export default class UpdatePasswordInput extends PasswordInput {
|
|
8
8
|
@Field()
|
|
9
9
|
oldPassword!: string;
|
|
10
10
|
}
|
package/src/dto/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
1
|
+
export { default as PasswordInput, passwordTransformers, passwordValidators } from './PasswordInput';
|
|
2
|
+
export { default as RegisterInput, registerTransformers, registerValidators } from './RegisterInput';
|
|
3
|
+
export { default as LoginInput, loginTransformers, loginValidators } from './LoginInput';
|
|
4
|
+
export { default as ForgotPasswordInput, forgotPasswordTransformers, forgotPasswordValidators } from './ForgotPasswordInput';
|
|
5
|
+
export { default as ConfirmEmailInput, confirmEmailValidators } from './ConfirmEmailInput';
|
|
6
|
+
export { default as StatusPayload } from './StatusPayload';
|
|
7
|
+
export { default as SendTokenPayload } from './SendTokenPayload';
|
|
8
|
+
export { default as UpdatePasswordInput, updatePasswordTransformers, updatePasswordValidators } from './UpdatePasswordInput';
|
|
9
|
+
export { default as UpdateEmailInput, updateEmailTransformers, updateEmailValidators } from './UpdateEmailInput';
|
|
10
|
+
export { default as UpdateProfileInput, updateProfileTransformers, updateProfileValidators } from './UpdateProfileInput';
|
|
11
|
+
export { default as RecoverPasswordInput, recoverPasswordTransformers, recoverPasswordValidators } from './RecoverPasswordInput';
|