nicot-simple-user 1.0.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.
- package/.prettierrc +4 -0
- package/Dockerfile.puppeteer +45 -0
- package/LICENSE +22 -0
- package/README.md +414 -0
- package/config.example.yaml +7 -0
- package/dist/app.module.d.ts +2 -0
- package/dist/app.module.js +53 -0
- package/dist/app.module.js.map +1 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +26 -0
- package/dist/main.js.map +1 -0
- package/dist/simple-user/aragami-init.d.ts +2 -0
- package/dist/simple-user/aragami-init.js +55 -0
- package/dist/simple-user/aragami-init.js.map +1 -0
- package/dist/simple-user/index.d.ts +6 -0
- package/dist/simple-user/index.js +23 -0
- package/dist/simple-user/index.js.map +1 -0
- package/dist/simple-user/login/login.controller.d.ts +14 -0
- package/dist/simple-user/login/login.controller.js +90 -0
- package/dist/simple-user/login/login.controller.js.map +1 -0
- package/dist/simple-user/module-builder.d.ts +2 -0
- package/dist/simple-user/module-builder.js +34 -0
- package/dist/simple-user/module-builder.js.map +1 -0
- package/dist/simple-user/options.d.ts +26 -0
- package/dist/simple-user/options.js +3 -0
- package/dist/simple-user/options.js.map +1 -0
- package/dist/simple-user/resolver.d.ts +41 -0
- package/dist/simple-user/resolver.js +48 -0
- package/dist/simple-user/resolver.js.map +1 -0
- package/dist/simple-user/send-code/code-context.d.ts +4 -0
- package/dist/simple-user/send-code/code-context.js +8 -0
- package/dist/simple-user/send-code/code-context.js.map +1 -0
- package/dist/simple-user/send-code/decorators.d.ts +2 -0
- package/dist/simple-user/send-code/decorators.js +13 -0
- package/dist/simple-user/send-code/decorators.js.map +1 -0
- package/dist/simple-user/send-code/send-code.controller.d.ts +9 -0
- package/dist/simple-user/send-code/send-code.controller.js +71 -0
- package/dist/simple-user/send-code/send-code.controller.js.map +1 -0
- package/dist/simple-user/send-code/send-code.dto.d.ts +12 -0
- package/dist/simple-user/send-code/send-code.dto.js +55 -0
- package/dist/simple-user/send-code/send-code.dto.js.map +1 -0
- package/dist/simple-user/send-code/send-code.service.d.ts +18 -0
- package/dist/simple-user/send-code/send-code.service.js +144 -0
- package/dist/simple-user/send-code/send-code.service.js.map +1 -0
- package/dist/simple-user/send-code/wait-time.dto.d.ts +3 -0
- package/dist/simple-user/send-code/wait-time.dto.js +29 -0
- package/dist/simple-user/send-code/wait-time.dto.js.map +1 -0
- package/dist/simple-user/simple-user/change-email.dto.d.ts +3 -0
- package/dist/simple-user/simple-user/change-email.dto.js +12 -0
- package/dist/simple-user/simple-user/change-email.dto.js.map +1 -0
- package/dist/simple-user/simple-user/change-password.dto.d.ts +4 -0
- package/dist/simple-user/simple-user/change-password.dto.js +41 -0
- package/dist/simple-user/simple-user/change-password.dto.js.map +1 -0
- package/dist/simple-user/simple-user/email.dto.d.ts +6 -0
- package/dist/simple-user/simple-user/email.dto.js +46 -0
- package/dist/simple-user/simple-user/email.dto.js.map +1 -0
- package/dist/simple-user/simple-user/login.dto.d.ts +11 -0
- package/dist/simple-user/simple-user/login.dto.js +80 -0
- package/dist/simple-user/simple-user/login.dto.js.map +1 -0
- package/dist/simple-user/simple-user/reset-password.dto.d.ts +4 -0
- package/dist/simple-user/simple-user/reset-password.dto.js +32 -0
- package/dist/simple-user/simple-user/reset-password.dto.js.map +1 -0
- package/dist/simple-user/simple-user/simple-user.service.d.ts +33 -0
- package/dist/simple-user/simple-user/simple-user.service.js +338 -0
- package/dist/simple-user/simple-user/simple-user.service.js.map +1 -0
- package/dist/simple-user/simple-user/user-exists.dto.d.ts +3 -0
- package/dist/simple-user/simple-user/user-exists.dto.js +28 -0
- package/dist/simple-user/simple-user/user-exists.dto.js.map +1 -0
- package/dist/simple-user/simple-user.entity.d.ts +40 -0
- package/dist/simple-user/simple-user.entity.js +119 -0
- package/dist/simple-user/simple-user.entity.js.map +1 -0
- package/dist/simple-user/simple-user.module.d.ts +8 -0
- package/dist/simple-user/simple-user.module.js +52 -0
- package/dist/simple-user/simple-user.module.js.map +1 -0
- package/dist/simple-user/tokens.d.ts +2 -0
- package/dist/simple-user/tokens.js +6 -0
- package/dist/simple-user/tokens.js.map +1 -0
- package/dist/simple-user/user-center/patch-me.d.ts +2 -0
- package/dist/simple-user/user-center/patch-me.js +16 -0
- package/dist/simple-user/user-center/patch-me.js.map +1 -0
- package/dist/simple-user/user-center/user-center.controller.d.ts +13 -0
- package/dist/simple-user/user-center/user-center.controller.js +88 -0
- package/dist/simple-user/user-center/user-center.controller.js.map +1 -0
- package/dist/simple-user/user-center/user-center.service.d.ts +2 -0
- package/dist/simple-user/user-center/user-center.service.js +17 -0
- package/dist/simple-user/user-center/user-center.service.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/utility/load-config.d.ts +7 -0
- package/dist/utility/load-config.js +61 -0
- package/dist/utility/load-config.js.map +1 -0
- package/eslint.config.mjs +34 -0
- package/install-npm-typeorm.sh +3 -0
- package/nest-cli.json +7 -0
- package/package.json +98 -0
- package/test/app-e2e.spec.ts +242 -0
- package/test/jest-e2e.json +9 -0
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,144 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SendCodeService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const module_builder_1 = require("../module-builder");
|
|
18
|
+
const send_code_dto_1 = require("./send-code.dto");
|
|
19
|
+
const aragami_1 = require("aragami");
|
|
20
|
+
const nestjs_aragami_1 = require("nestjs-aragami");
|
|
21
|
+
const nicot_1 = require("nicot");
|
|
22
|
+
const wait_time_dto_1 = require("./wait-time.dto");
|
|
23
|
+
const nicot_2 = require("nicot");
|
|
24
|
+
const buildSendCodeCacheKey = (ctx) => `email:${ctx.email}:${ctx.codePurpose}`;
|
|
25
|
+
class SendCodeRecord extends send_code_dto_1.SendCodeDto {
|
|
26
|
+
get cacheKey() {
|
|
27
|
+
return buildSendCodeCacheKey(this);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, aragami_1.CacheKey)(),
|
|
32
|
+
__metadata("design:type", Object),
|
|
33
|
+
__metadata("design:paramtypes", [])
|
|
34
|
+
], SendCodeRecord.prototype, "cacheKey", null);
|
|
35
|
+
class VerifyCodeAttemptRecord extends send_code_dto_1.SendCodeDto {
|
|
36
|
+
get cacheKey() {
|
|
37
|
+
return buildSendCodeCacheKey(this) + `:attempts:${this.time.getTime()}`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, aragami_1.CacheKey)(),
|
|
42
|
+
__metadata("design:type", Object),
|
|
43
|
+
__metadata("design:paramtypes", [])
|
|
44
|
+
], VerifyCodeAttemptRecord.prototype, "cacheKey", null);
|
|
45
|
+
let SendCodeService = class SendCodeService {
|
|
46
|
+
constructor(options, aragami) {
|
|
47
|
+
this.options = options;
|
|
48
|
+
this.aragami = aragami;
|
|
49
|
+
this.logger = new common_1.ConsoleLogger('SendCodeService');
|
|
50
|
+
this.sendCodeValidTimeMs = this.options.sendCodeValidTimeMs || 10 * 60 * 1000;
|
|
51
|
+
this.sendCodeCooldownTimeMs = this.options.sendCodeCooldownTimeMs || 60 * 1000;
|
|
52
|
+
this.verifyCodeMaxAttempts = this.options.verifyCodeMaxAttempts || 5;
|
|
53
|
+
this.verifyCodeBlockTimeMs = this.options.verifyCodeBlockTimeMs || 15 * 60 * 1000;
|
|
54
|
+
}
|
|
55
|
+
async sendCode(dto, riskControlContext) {
|
|
56
|
+
const riskControlKeys = [
|
|
57
|
+
`ip:${riskControlContext.ip}:${dto.codePurpose}`,
|
|
58
|
+
`ssaid:${riskControlContext.ssaid}:${dto.codePurpose}`,
|
|
59
|
+
];
|
|
60
|
+
if (this.sendCodeCooldownTimeMs) {
|
|
61
|
+
const cooldownChecks = await Promise.all([buildSendCodeCacheKey(dto), ...riskControlKeys].map(async (key) => {
|
|
62
|
+
const existing = await this.aragami.get(SendCodeRecord, key);
|
|
63
|
+
if (existing) {
|
|
64
|
+
const elapsed = Date.now() - existing.sentTime.getTime();
|
|
65
|
+
if (elapsed < this.sendCodeCooldownTimeMs) {
|
|
66
|
+
return this.sendCodeCooldownTimeMs - elapsed;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}));
|
|
70
|
+
const hitChecks = cooldownChecks.filter((s) => !!s);
|
|
71
|
+
if (hitChecks.length > 0) {
|
|
72
|
+
const waitTimeMs = Math.max(...hitChecks);
|
|
73
|
+
const waitTimeDto = new wait_time_dto_1.WaitTimeDto();
|
|
74
|
+
waitTimeDto.waitTimeMs = waitTimeMs;
|
|
75
|
+
throw new nicot_1.GenericReturnMessageDto(429, 'Please wait before requesting another code', waitTimeDto).toException();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (!this.options.sendCodeGenerator) {
|
|
79
|
+
throw new nicot_2.BlankReturnMessageDto(501, 'Send code generator not configured').toException();
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
const code = await this.options.sendCodeGenerator(dto);
|
|
83
|
+
const record = new SendCodeRecord();
|
|
84
|
+
record.email = dto.email;
|
|
85
|
+
record.codePurpose = dto.codePurpose;
|
|
86
|
+
record.code = code;
|
|
87
|
+
record.sentTime = new Date();
|
|
88
|
+
await this.aragami.set(record, {
|
|
89
|
+
ttl: this.sendCodeValidTimeMs,
|
|
90
|
+
});
|
|
91
|
+
if (this.sendCodeCooldownTimeMs) {
|
|
92
|
+
await Promise.all(riskControlKeys.map((key) => this.aragami.set(record, {
|
|
93
|
+
ttl: this.sendCodeCooldownTimeMs,
|
|
94
|
+
key,
|
|
95
|
+
})));
|
|
96
|
+
}
|
|
97
|
+
return new nicot_2.BlankReturnMessageDto(200, 'success');
|
|
98
|
+
}
|
|
99
|
+
catch (e) {
|
|
100
|
+
this.logger.error(`Failed to send code to ${dto.email} for purpose ${dto.codePurpose}: ${e}`);
|
|
101
|
+
throw new nicot_1.GenericReturnMessageDto(501, 'Failed to send code').toException();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async verifyCode(dto, noConsume = false) {
|
|
105
|
+
const key = buildSendCodeCacheKey(dto);
|
|
106
|
+
if (this.verifyCodeMaxAttempts && this.verifyCodeBlockTimeMs) {
|
|
107
|
+
const tries = await this.aragami.values(VerifyCodeAttemptRecord, key + ':attempts:');
|
|
108
|
+
if (tries.length >= this.verifyCodeMaxAttempts) {
|
|
109
|
+
tries.sort((a, b) => a.time.getTime() - b.time.getTime());
|
|
110
|
+
const firstExceed = tries[0];
|
|
111
|
+
const waitTimeMs = firstExceed.time.getTime() + this.verifyCodeBlockTimeMs - Date.now();
|
|
112
|
+
const waitTimeDto = new wait_time_dto_1.WaitTimeDto();
|
|
113
|
+
waitTimeDto.waitTimeMs = waitTimeMs;
|
|
114
|
+
throw new nicot_1.GenericReturnMessageDto(429, 'Too many invalid code attempts, please try again later', waitTimeDto).toException();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const record = await this.aragami.get(SendCodeRecord, key);
|
|
118
|
+
if (!record || record.code !== dto.code) {
|
|
119
|
+
if (this.verifyCodeMaxAttempts && this.verifyCodeBlockTimeMs) {
|
|
120
|
+
const attemptRecord = new VerifyCodeAttemptRecord();
|
|
121
|
+
attemptRecord.email = dto.email;
|
|
122
|
+
attemptRecord.codePurpose = dto.codePurpose;
|
|
123
|
+
attemptRecord.time = new Date();
|
|
124
|
+
await this.aragami.set(attemptRecord, {
|
|
125
|
+
ttl: this.verifyCodeBlockTimeMs,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
throw new nicot_2.BlankReturnMessageDto(403, 'Invalid email code').toException();
|
|
129
|
+
}
|
|
130
|
+
if (!noConsume) {
|
|
131
|
+
await this.aragami.del(SendCodeRecord, key);
|
|
132
|
+
}
|
|
133
|
+
await this.aragami.clear(VerifyCodeAttemptRecord, key);
|
|
134
|
+
return new nicot_2.BlankReturnMessageDto(200, 'success');
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
exports.SendCodeService = SendCodeService;
|
|
138
|
+
exports.SendCodeService = SendCodeService = __decorate([
|
|
139
|
+
(0, common_1.Injectable)(),
|
|
140
|
+
__param(0, (0, common_1.Inject)(module_builder_1.MODULE_OPTIONS_TOKEN)),
|
|
141
|
+
__param(1, (0, nestjs_aragami_1.InjectAragami)()),
|
|
142
|
+
__metadata("design:paramtypes", [Object, aragami_1.Aragami])
|
|
143
|
+
], SendCodeService);
|
|
144
|
+
//# sourceMappingURL=send-code.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-code.service.js","sourceRoot":"","sources":["../../../src/simple-user/send-code/send-code.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAmE;AACnE,sDAAyD;AAEzD,mDAA2D;AAC3D,qCAA4C;AAC5C,mDAA+C;AAC/C,iCAAgD;AAChD,mDAA8C;AAC9C,iCAA8C;AAI9C,MAAM,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;gBAChC,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE;oBACpC,GAAG,EAAE,IAAI,CAAC,qBAAqB;iBAChC,CAAC,CAAC;YACL,CAAC;YACD,MAAM,IAAI,6BAAqB,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,WAAW,EAAE,CAAC;QAC3E,CAAC;QAED,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;QAC9C,CAAC;QACD,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC;QACvD,OAAO,IAAI,6BAAqB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IACnD,CAAC;CACF,CAAA;AA7HY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,eAAM,EAAC,qCAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,8BAAa,GAAE,CAAA;6CAAkB,iBAAO;GAHhC,eAAe,CA6H3B"}
|
|
@@ -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.WaitTimeDto = void 0;
|
|
13
|
+
const openapi = require("@nestjs/swagger");
|
|
14
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
15
|
+
class WaitTimeDto {
|
|
16
|
+
static _OPENAPI_METADATA_FACTORY() {
|
|
17
|
+
return { waitTimeMs: { required: true, type: () => Number } };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.WaitTimeDto = WaitTimeDto;
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, swagger_1.ApiProperty)({
|
|
23
|
+
description: 'The time in milliseconds the user needs to wait before retrying',
|
|
24
|
+
example: 45000,
|
|
25
|
+
required: true,
|
|
26
|
+
}),
|
|
27
|
+
__metadata("design:type", Number)
|
|
28
|
+
], WaitTimeDto.prototype, "waitTimeMs", void 0);
|
|
29
|
+
//# sourceMappingURL=wait-time.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait-time.dto.js","sourceRoot":"","sources":["../../../src/simple-user/send-code/wait-time.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA8C;AAE9C,MAAa,WAAW;;;;CAQvB;AARD,kCAQC;AADC;IANC,IAAA,qBAAW,EAAC;QACX,WAAW,EACT,iEAAiE;QACnE,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,IAAI;KACf,CAAC;;+CACiB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChangeEmailDto = void 0;
|
|
4
|
+
const openapi = require("@nestjs/swagger");
|
|
5
|
+
const email_dto_1 = require("./email.dto");
|
|
6
|
+
class ChangeEmailDto extends email_dto_1.EmailAndCodeDto {
|
|
7
|
+
static _OPENAPI_METADATA_FACTORY() {
|
|
8
|
+
return {};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.ChangeEmailDto = ChangeEmailDto;
|
|
12
|
+
//# sourceMappingURL=change-email.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"change-email.dto.js","sourceRoot":"","sources":["../../../src/simple-user/simple-user/change-email.dto.ts"],"names":[],"mappings":";;;;AAAA,2CAA8C;AAE9C,MAAa,cAAe,SAAQ,2BAAe;;;;CAAG;AAAtD,wCAAsD"}
|
|
@@ -0,0 +1,41 @@
|
|
|
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.ChangePasswordDto = void 0;
|
|
13
|
+
const openapi = require("@nestjs/swagger");
|
|
14
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
15
|
+
const class_validator_1 = require("class-validator");
|
|
16
|
+
class ChangePasswordDto {
|
|
17
|
+
static _OPENAPI_METADATA_FACTORY() {
|
|
18
|
+
return { currentPassword: { required: false, type: () => String }, newPassword: { required: true, type: () => String } };
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.ChangePasswordDto = ChangePasswordDto;
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, class_validator_1.IsOptional)(),
|
|
24
|
+
(0, class_validator_1.IsString)(),
|
|
25
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
26
|
+
(0, swagger_1.ApiProperty)({
|
|
27
|
+
description: 'The current password of the user. Must be provided if applicable.',
|
|
28
|
+
example: 'currentpassword',
|
|
29
|
+
}),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], ChangePasswordDto.prototype, "currentPassword", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, class_validator_1.IsString)(),
|
|
34
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
35
|
+
(0, swagger_1.ApiProperty)({
|
|
36
|
+
description: 'The new password to set for the user',
|
|
37
|
+
example: 'newsecurepassword',
|
|
38
|
+
}),
|
|
39
|
+
__metadata("design:type", String)
|
|
40
|
+
], ChangePasswordDto.prototype, "newPassword", void 0);
|
|
41
|
+
//# sourceMappingURL=change-password.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"change-password.dto.js","sourceRoot":"","sources":["../../../src/simple-user/simple-user/change-password.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA8C;AAC9C,qDAAmE;AAEnE,MAAa,iBAAiB;;;;CAkB7B;AAlBD,8CAkBC;AATC;IARC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,qBAAW,EAAC;QACX,WAAW,EACT,mEAAmE;QACrE,OAAO,EAAE,iBAAiB;KAC3B,CAAC;;0DACuB;AAQzB;IANC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,sCAAsC;QACnD,OAAO,EAAE,mBAAmB;KAC7B,CAAC;;sDACkB"}
|
|
@@ -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.EmailAndCodeDto = exports.EmailDto = void 0;
|
|
13
|
+
const openapi = require("@nestjs/swagger");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
16
|
+
class EmailDto {
|
|
17
|
+
static _OPENAPI_METADATA_FACTORY() {
|
|
18
|
+
return { email: { required: true, type: () => String, format: "email" } };
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.EmailDto = EmailDto;
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, class_validator_1.IsEmail)(),
|
|
24
|
+
(0, swagger_1.ApiProperty)({
|
|
25
|
+
description: 'The email address',
|
|
26
|
+
example: 'someuser@example.com',
|
|
27
|
+
required: true,
|
|
28
|
+
}),
|
|
29
|
+
__metadata("design:type", String)
|
|
30
|
+
], EmailDto.prototype, "email", void 0);
|
|
31
|
+
class EmailAndCodeDto extends EmailDto {
|
|
32
|
+
static _OPENAPI_METADATA_FACTORY() {
|
|
33
|
+
return { code: { required: true, type: () => String } };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.EmailAndCodeDto = EmailAndCodeDto;
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, class_validator_1.IsString)(),
|
|
39
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
40
|
+
(0, swagger_1.ApiProperty)({
|
|
41
|
+
description: 'The code sent to the email address',
|
|
42
|
+
example: '123456',
|
|
43
|
+
}),
|
|
44
|
+
__metadata("design:type", String)
|
|
45
|
+
], EmailAndCodeDto.prototype, "code", void 0);
|
|
46
|
+
//# sourceMappingURL=email.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.dto.js","sourceRoot":"","sources":["../../../src/simple-user/simple-user/email.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,qDAAgE;AAChE,6CAA8C;AAE9C,MAAa,QAAQ;;;;CAQpB;AARD,4BAQC;AADC;IANC,IAAA,yBAAO,GAAE;IACT,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,mBAAmB;QAChC,OAAO,EAAE,sBAAsB;QAC/B,QAAQ,EAAE,IAAI;KACf,CAAC;;uCACY;AAGhB,MAAa,eAAgB,SAAQ,QAAQ;;;;CAQ5C;AARD,0CAQC;AADC;IANC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,oCAAoC;QACjD,OAAO,EAAE,QAAQ;KAClB,CAAC;;6CACW"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EmailDto } from './email.dto';
|
|
2
|
+
export declare class LoginDto extends EmailDto {
|
|
3
|
+
code?: string;
|
|
4
|
+
password?: string;
|
|
5
|
+
setPassword?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class LoginResponseDto {
|
|
8
|
+
token: string;
|
|
9
|
+
tokenExpiresAt: Date;
|
|
10
|
+
userId: number;
|
|
11
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
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.LoginResponseDto = exports.LoginDto = void 0;
|
|
13
|
+
const openapi = require("@nestjs/swagger");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
16
|
+
const email_dto_1 = require("./email.dto");
|
|
17
|
+
class LoginDto extends email_dto_1.EmailDto {
|
|
18
|
+
static _OPENAPI_METADATA_FACTORY() {
|
|
19
|
+
return { code: { required: false, type: () => String }, password: { required: false, type: () => String }, setPassword: { required: false, type: () => String } };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.LoginDto = LoginDto;
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, class_validator_1.IsOptional)(),
|
|
25
|
+
(0, class_validator_1.IsString)(),
|
|
26
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
27
|
+
(0, swagger_1.ApiProperty)({
|
|
28
|
+
description: 'The login code sent to the email address (MUST present if no password)',
|
|
29
|
+
example: '123456',
|
|
30
|
+
}),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], LoginDto.prototype, "code", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, class_validator_1.IsOptional)(),
|
|
35
|
+
(0, class_validator_1.IsString)(),
|
|
36
|
+
(0, swagger_1.ApiProperty)({
|
|
37
|
+
description: 'The password for login (if applicable)',
|
|
38
|
+
example: 'yourpassword',
|
|
39
|
+
}),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], LoginDto.prototype, "password", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, class_validator_1.IsOptional)(),
|
|
44
|
+
(0, class_validator_1.IsString)(),
|
|
45
|
+
(0, swagger_1.ApiProperty)({
|
|
46
|
+
description: 'The new password to set for the user (if applicable, e.g., during registration)',
|
|
47
|
+
example: 'newsecurepassword',
|
|
48
|
+
}),
|
|
49
|
+
__metadata("design:type", String)
|
|
50
|
+
], LoginDto.prototype, "setPassword", void 0);
|
|
51
|
+
class LoginResponseDto {
|
|
52
|
+
static _OPENAPI_METADATA_FACTORY() {
|
|
53
|
+
return { token: { required: true, type: () => String }, tokenExpiresAt: { required: true, type: () => Date }, userId: { required: true, type: () => Number } };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.LoginResponseDto = LoginResponseDto;
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, swagger_1.ApiProperty)({
|
|
59
|
+
description: 'The authentication token for the user',
|
|
60
|
+
minLength: 64,
|
|
61
|
+
maxLength: 64,
|
|
62
|
+
example: 'x'.repeat(64),
|
|
63
|
+
}),
|
|
64
|
+
__metadata("design:type", String)
|
|
65
|
+
], LoginResponseDto.prototype, "token", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, swagger_1.ApiProperty)({
|
|
68
|
+
description: 'The expiration time of the authentication token',
|
|
69
|
+
example: new Date(),
|
|
70
|
+
}),
|
|
71
|
+
__metadata("design:type", Date)
|
|
72
|
+
], LoginResponseDto.prototype, "tokenExpiresAt", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
(0, swagger_1.ApiProperty)({
|
|
75
|
+
description: 'The ID of the logged-in user',
|
|
76
|
+
example: 123,
|
|
77
|
+
}),
|
|
78
|
+
__metadata("design:type", Number)
|
|
79
|
+
], LoginResponseDto.prototype, "userId", void 0);
|
|
80
|
+
//# sourceMappingURL=login.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.dto.js","sourceRoot":"","sources":["../../../src/simple-user/simple-user/login.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,qDAAmE;AACnE,6CAA8C;AAC9C,2CAAuC;AAEvC,MAAa,QAAS,SAAQ,oBAAQ;;;;CA2BrC;AA3BD,4BA2BC;AAlBC;IARC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,qBAAW,EAAC;QACX,WAAW,EACT,wEAAwE;QAC1E,OAAO,EAAE,QAAQ;KAClB,CAAC;;sCACY;AAQd;IANC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,wCAAwC;QACrD,OAAO,EAAE,cAAc;KACxB,CAAC;;0CACgB;AASlB;IAPC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,qBAAW,EAAC;QACX,WAAW,EACT,iFAAiF;QACnF,OAAO,EAAE,mBAAmB;KAC7B,CAAC;;6CACmB;AAGvB,MAAa,gBAAgB;;;;CAkB5B;AAlBD,4CAkBC;AAXC;IANC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,uCAAuC;QACpD,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,EAAE;QACb,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;KACxB,CAAC;;+CACY;AAKd;IAJC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,iDAAiD;QAC9D,OAAO,EAAE,IAAI,IAAI,EAAE;KACpB,CAAC;8BACc,IAAI;wDAAC;AAKrB;IAJC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,8BAA8B;QAC3C,OAAO,EAAE,GAAG;KACb,CAAC;;gDACa"}
|
|
@@ -0,0 +1,32 @@
|
|
|
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.ResetPasswordDto = void 0;
|
|
13
|
+
const openapi = require("@nestjs/swagger");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
16
|
+
const email_dto_1 = require("./email.dto");
|
|
17
|
+
class ResetPasswordDto extends email_dto_1.EmailAndCodeDto {
|
|
18
|
+
static _OPENAPI_METADATA_FACTORY() {
|
|
19
|
+
return { newPassword: { required: true, type: () => String } };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.ResetPasswordDto = ResetPasswordDto;
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, class_validator_1.IsString)(),
|
|
25
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
26
|
+
(0, swagger_1.ApiProperty)({
|
|
27
|
+
description: 'The new password to set for the user',
|
|
28
|
+
example: 'newsecurepassword',
|
|
29
|
+
}),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], ResetPasswordDto.prototype, "newPassword", void 0);
|
|
32
|
+
//# sourceMappingURL=reset-password.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reset-password.dto.js","sourceRoot":"","sources":["../../../src/simple-user/simple-user/reset-password.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,qDAAuD;AACvD,6CAA8C;AAC9C,2CAA8C;AAE9C,MAAa,gBAAiB,SAAQ,2BAAe;;;;CAQpD;AARD,4CAQC;AADC;IANC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,sCAAsC;QACnD,OAAO,EAAE,mBAAmB;KAC7B,CAAC;;qDACkB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BlankReturnMessageDto, CrudBase, GenericReturnMessageDto } from 'nicot';
|
|
2
|
+
import { SimpleUser } from '../simple-user.entity';
|
|
3
|
+
import { Repository } from 'typeorm';
|
|
4
|
+
import { SimpleUserExtraOptions, SimpleUserOptions } from '../options';
|
|
5
|
+
import { UserContext, UserRiskControlContext } from '../resolver';
|
|
6
|
+
import { Aragami } from 'aragami';
|
|
7
|
+
import { LoginDto, LoginResponseDto } from './login.dto';
|
|
8
|
+
import { SendCodeService } from '../send-code/send-code.service';
|
|
9
|
+
import { ChangeEmailDto } from './change-email.dto';
|
|
10
|
+
import { ChangePasswordDto } from './change-password.dto';
|
|
11
|
+
import { ResetPasswordDto } from './reset-password.dto';
|
|
12
|
+
export declare class SimpleUserService<U extends SimpleUser = SimpleUser> extends CrudBase<U> {
|
|
13
|
+
private options;
|
|
14
|
+
private optionsEx;
|
|
15
|
+
private aragami;
|
|
16
|
+
private sendCodeService;
|
|
17
|
+
constructor(repo: Repository<U>, options: SimpleUserOptions, optionsEx: SimpleUserExtraOptions, aragami: Aragami, sendCodeService: SendCodeService);
|
|
18
|
+
private getFindOptions;
|
|
19
|
+
findOrCreateUser(ctx: UserContext): Promise<U>;
|
|
20
|
+
findUserWithId(id: number): Promise<U>;
|
|
21
|
+
checkUserExists(email: string): Promise<GenericReturnMessageDto<{
|
|
22
|
+
exists: boolean;
|
|
23
|
+
}>>;
|
|
24
|
+
private passwordMaxAttempts;
|
|
25
|
+
private passwordBlockTimeMs;
|
|
26
|
+
private checkPasswordRiskControl;
|
|
27
|
+
private recordPasswordFailAttempt;
|
|
28
|
+
login(dto: LoginDto, ctx: UserRiskControlContext): Promise<GenericReturnMessageDto<LoginResponseDto>>;
|
|
29
|
+
changeEmail(user: U, dto: ChangeEmailDto): Promise<BlankReturnMessageDto>;
|
|
30
|
+
kickUserEmail(email: string): Promise<void>;
|
|
31
|
+
changePassword(user: U, dto: ChangePasswordDto, ctx: UserRiskControlContext): Promise<BlankReturnMessageDto>;
|
|
32
|
+
resetPassword(dto: ResetPasswordDto): Promise<BlankReturnMessageDto>;
|
|
33
|
+
}
|