@solidxai/core 0.1.13-beta.19 → 0.1.13-beta.20
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/CHANGELOG.md +584 -0
- package/dist/constants/error-messages.d.ts +7 -0
- package/dist/constants/error-messages.d.ts.map +1 -1
- package/dist/constants/error-messages.js +7 -0
- package/dist/constants/error-messages.js.map +1 -1
- package/dist/constants/success-messages.d.ts +3 -0
- package/dist/constants/success-messages.d.ts.map +1 -1
- package/dist/constants/success-messages.js +3 -0
- package/dist/constants/success-messages.js.map +1 -1
- package/dist/controllers/mpin-authentication.controller.d.ts +44 -0
- package/dist/controllers/mpin-authentication.controller.d.ts.map +1 -0
- package/dist/controllers/mpin-authentication.controller.js +102 -0
- package/dist/controllers/mpin-authentication.controller.js.map +1 -0
- package/dist/dtos/change-mpin.dto.d.ts +6 -0
- package/dist/dtos/change-mpin.dto.d.ts.map +1 -0
- package/dist/dtos/change-mpin.dto.js +39 -0
- package/dist/dtos/change-mpin.dto.js.map +1 -0
- package/dist/dtos/mpin-login.dto.d.ts +5 -0
- package/dist/dtos/mpin-login.dto.d.ts.map +1 -0
- package/dist/dtos/mpin-login.dto.js +33 -0
- package/dist/dtos/mpin-login.dto.js.map +1 -0
- package/dist/dtos/setup-mpin.dto.d.ts +7 -0
- package/dist/dtos/setup-mpin.dto.d.ts.map +1 -0
- package/dist/dtos/setup-mpin.dto.js +47 -0
- package/dist/dtos/setup-mpin.dto.js.map +1 -0
- package/dist/entities/user-device-credential.entity.d.ts +18 -0
- package/dist/entities/user-device-credential.entity.d.ts.map +1 -0
- package/dist/entities/user-device-credential.entity.js +91 -0
- package/dist/entities/user-device-credential.entity.js.map +1 -0
- package/dist/helpers/solid-core-error-codes-provider.service.d.ts.map +1 -1
- package/dist/helpers/solid-core-error-codes-provider.service.js +45 -0
- package/dist/helpers/solid-core-error-codes-provider.service.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/repository/user-device-credential.repository.d.ts +12 -0
- package/dist/repository/user-device-credential.repository.d.ts.map +1 -0
- package/dist/repository/user-device-credential.repository.js +34 -0
- package/dist/repository/user-device-credential.repository.js.map +1 -0
- package/dist/seeders/seed-data/solid-core-metadata.json +158 -0
- package/dist/services/mpin.service.d.ts +67 -0
- package/dist/services/mpin.service.d.ts.map +1 -0
- package/dist/services/mpin.service.js +282 -0
- package/dist/services/mpin.service.js.map +1 -0
- package/dist/services/settings/default-settings-provider.service.d.ts +120 -0
- package/dist/services/settings/default-settings-provider.service.d.ts.map +1 -1
- package/dist/services/settings/default-settings-provider.service.js +66 -0
- package/dist/services/settings/default-settings-provider.service.js.map +1 -1
- package/dist/solid-core.module.d.ts.map +1 -1
- package/dist/solid-core.module.js +8 -0
- package/dist/solid-core.module.js.map +1 -1
- package/package.json +1 -1
- package/postman/mpin.postman_collection.json +1045 -0
- package/src/constants/error-messages.ts +14 -0
- package/src/constants/success-messages.ts +5 -0
- package/src/controllers/mpin-authentication.controller.ts +67 -0
- package/src/dtos/change-mpin.dto.ts +18 -0
- package/src/dtos/mpin-login.dto.ts +24 -0
- package/src/dtos/setup-mpin.dto.ts +51 -0
- package/src/entities/user-device-credential.entity.ts +130 -0
- package/src/helpers/solid-core-error-codes-provider.service.ts +53 -0
- package/src/index.ts +6 -0
- package/src/repository/user-device-credential.repository.ts +17 -0
- package/src/seeders/seed-data/solid-core-metadata.json +158 -0
- package/src/services/mpin.service.ts +447 -0
- package/src/services/settings/default-settings-provider.service.ts +71 -0
- package/src/solid-core.module.ts +8 -0
|
@@ -0,0 +1,282 @@
|
|
|
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 MpinService_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.MpinService = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const crypto_1 = require("crypto");
|
|
16
|
+
const error_messages_1 = require("../constants/error-messages");
|
|
17
|
+
const success_messages_1 = require("../constants/success-messages");
|
|
18
|
+
const user_device_credential_repository_1 = require("../repository/user-device-credential.repository");
|
|
19
|
+
const user_repository_1 = require("../repository/user.repository");
|
|
20
|
+
const authentication_service_1 = require("./authentication.service");
|
|
21
|
+
const hashing_service_1 = require("./hashing.service");
|
|
22
|
+
const setting_service_1 = require("./setting.service");
|
|
23
|
+
const user_activity_history_service_1 = require("./user-activity-history.service");
|
|
24
|
+
const MPIN_DENYLIST = new Set([
|
|
25
|
+
'0000', '1111', '2222', '3333', '4444', '5555', '6666', '7777', '8888', '9999',
|
|
26
|
+
'1234', '4321', '1212', '2001', '1004', '2000', '6969', '2580',
|
|
27
|
+
'000000', '111111', '123456', '654321', '121212', '112233', '123123',
|
|
28
|
+
]);
|
|
29
|
+
let MpinService = MpinService_1 = class MpinService {
|
|
30
|
+
constructor(credentialRepository, userRepository, hashingService, settingService, authenticationService, userActivityHistoryService) {
|
|
31
|
+
this.credentialRepository = credentialRepository;
|
|
32
|
+
this.userRepository = userRepository;
|
|
33
|
+
this.hashingService = hashingService;
|
|
34
|
+
this.settingService = settingService;
|
|
35
|
+
this.authenticationService = authenticationService;
|
|
36
|
+
this.userActivityHistoryService = userActivityHistoryService;
|
|
37
|
+
this.logger = new common_1.Logger(MpinService_1.name);
|
|
38
|
+
}
|
|
39
|
+
async setupMpin(activeUser, dto) {
|
|
40
|
+
this.assertEnabled();
|
|
41
|
+
this.assertMpinAcceptable(dto.mpin);
|
|
42
|
+
const user = await this.userRepository.findOne({ where: { id: activeUser.sub } });
|
|
43
|
+
if (!user) {
|
|
44
|
+
throw new common_1.NotFoundException(error_messages_1.ERROR_MESSAGES.USER_NOT_FOUND);
|
|
45
|
+
}
|
|
46
|
+
const deviceId = dto.deviceId.toLowerCase();
|
|
47
|
+
const existing = await this.credentialRepository.findOne({
|
|
48
|
+
where: { user: { id: user.id }, deviceId },
|
|
49
|
+
});
|
|
50
|
+
const record = existing ?? this.credentialRepository.create({
|
|
51
|
+
user,
|
|
52
|
+
deviceId,
|
|
53
|
+
});
|
|
54
|
+
record.credentialKey = this.buildCredentialKey(user.username, deviceId);
|
|
55
|
+
const credentialRef = this.mintCredentialRef();
|
|
56
|
+
record.hashedCredentialRef = this.hashCredentialRef(credentialRef);
|
|
57
|
+
record.hashedMpin = await this.hashingService.hash(dto.mpin);
|
|
58
|
+
record.mpinScheme = this.hashingService.name();
|
|
59
|
+
record.mpinSchemeVersion = this.hashingService.currentVersion();
|
|
60
|
+
record.deviceName = dto.deviceName ?? null;
|
|
61
|
+
record.platform = dto.platform ?? null;
|
|
62
|
+
record.isActive = true;
|
|
63
|
+
record.failedAttempts = 0;
|
|
64
|
+
record.lockedUntil = null;
|
|
65
|
+
await this.evictOldestIfAtCap(user.id, existing?.id);
|
|
66
|
+
await this.credentialRepository.save(record);
|
|
67
|
+
return { credentialRef, message: success_messages_1.SUCCESS_MESSAGES.MPIN_SETUP_SUCCESS };
|
|
68
|
+
}
|
|
69
|
+
async changeMpin(activeUser, dto) {
|
|
70
|
+
this.assertEnabled();
|
|
71
|
+
this.assertMpinAcceptable(dto.newMpin);
|
|
72
|
+
const credential = await this.credentialRepository.findOne({
|
|
73
|
+
where: {
|
|
74
|
+
hashedCredentialRef: this.hashCredentialRef(dto.credentialRef),
|
|
75
|
+
user: { id: activeUser.sub },
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
if (!credential || !credential.isActive) {
|
|
79
|
+
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.MPIN_INVALID);
|
|
80
|
+
}
|
|
81
|
+
this.assertNotLocked(credential);
|
|
82
|
+
const matches = await this.hashingService.compare(dto.currentMpin, credential.hashedMpin, credential.mpinSchemeVersion);
|
|
83
|
+
if (!matches) {
|
|
84
|
+
throw await this.registerFailedAttempt(credential);
|
|
85
|
+
}
|
|
86
|
+
const credentialRef = this.mintCredentialRef();
|
|
87
|
+
credential.hashedCredentialRef = this.hashCredentialRef(credentialRef);
|
|
88
|
+
credential.hashedMpin = await this.hashingService.hash(dto.newMpin);
|
|
89
|
+
credential.mpinScheme = this.hashingService.name();
|
|
90
|
+
credential.mpinSchemeVersion = this.hashingService.currentVersion();
|
|
91
|
+
credential.failedAttempts = 0;
|
|
92
|
+
credential.lockedUntil = null;
|
|
93
|
+
await this.credentialRepository.save(credential);
|
|
94
|
+
return { credentialRef, message: success_messages_1.SUCCESS_MESSAGES.MPIN_CHANGED_SUCCESS };
|
|
95
|
+
}
|
|
96
|
+
async loginWithMpin(dto) {
|
|
97
|
+
this.assertEnabled();
|
|
98
|
+
const credential = await this.credentialRepository.findOne({
|
|
99
|
+
where: { hashedCredentialRef: this.hashCredentialRef(dto.credentialRef) },
|
|
100
|
+
relations: { user: { roles: true } },
|
|
101
|
+
});
|
|
102
|
+
if (!credential || !credential.user) {
|
|
103
|
+
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.MPIN_INVALID);
|
|
104
|
+
}
|
|
105
|
+
if (!credential.isActive) {
|
|
106
|
+
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.MPIN_REVOKED);
|
|
107
|
+
}
|
|
108
|
+
this.assertNotLocked(credential);
|
|
109
|
+
const matches = await this.hashingService.compare(dto.mpin, credential.hashedMpin, credential.mpinSchemeVersion);
|
|
110
|
+
if (!matches) {
|
|
111
|
+
throw await this.registerFailedAttempt(credential);
|
|
112
|
+
}
|
|
113
|
+
credential.failedAttempts = 0;
|
|
114
|
+
credential.lockedUntil = null;
|
|
115
|
+
credential.lastUsedAt = new Date();
|
|
116
|
+
if (this.hashingService.needsRehash(credential.hashedMpin, credential.mpinSchemeVersion)) {
|
|
117
|
+
credential.hashedMpin = await this.hashingService.hash(dto.mpin);
|
|
118
|
+
credential.mpinScheme = this.hashingService.name();
|
|
119
|
+
credential.mpinSchemeVersion = this.hashingService.currentVersion();
|
|
120
|
+
}
|
|
121
|
+
await this.credentialRepository.save(credential);
|
|
122
|
+
const user = credential.user;
|
|
123
|
+
await this.userActivityHistoryService.logEvent('login', user);
|
|
124
|
+
const tokens = await this.authenticationService.generateTokens(user, credential.deviceId);
|
|
125
|
+
return {
|
|
126
|
+
user: {
|
|
127
|
+
id: user.id,
|
|
128
|
+
email: user.email,
|
|
129
|
+
mobile: user.mobile,
|
|
130
|
+
username: user.username,
|
|
131
|
+
forcePasswordChange: user.forcePasswordChange,
|
|
132
|
+
roles: (user.roles ?? []).map((role) => role.name),
|
|
133
|
+
},
|
|
134
|
+
...tokens,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
async listDevices(activeUser) {
|
|
138
|
+
this.assertEnabled();
|
|
139
|
+
const credentials = await this.credentialRepository.find({
|
|
140
|
+
where: { user: { id: activeUser.sub }, isActive: true },
|
|
141
|
+
});
|
|
142
|
+
return credentials
|
|
143
|
+
.sort((a, b) => this.lastUsedMillis(b) - this.lastUsedMillis(a))
|
|
144
|
+
.map((credential) => this.toDeviceView(credential));
|
|
145
|
+
}
|
|
146
|
+
async revokeDevice(activeUser, id) {
|
|
147
|
+
this.assertEnabled();
|
|
148
|
+
const credential = await this.credentialRepository.findOne({
|
|
149
|
+
where: { id, user: { id: activeUser.sub } },
|
|
150
|
+
});
|
|
151
|
+
if (!credential) {
|
|
152
|
+
throw new common_1.NotFoundException(error_messages_1.ERROR_MESSAGES.MPIN_CREDENTIAL_NOT_FOUND);
|
|
153
|
+
}
|
|
154
|
+
credential.isActive = false;
|
|
155
|
+
await this.credentialRepository.save(credential);
|
|
156
|
+
return { message: success_messages_1.SUCCESS_MESSAGES.MPIN_DEVICE_REVOKED };
|
|
157
|
+
}
|
|
158
|
+
toDeviceView(credential) {
|
|
159
|
+
return {
|
|
160
|
+
id: credential.id,
|
|
161
|
+
deviceId: credential.deviceId,
|
|
162
|
+
deviceName: credential.deviceName,
|
|
163
|
+
platform: credential.platform,
|
|
164
|
+
isActive: credential.isActive,
|
|
165
|
+
failedAttempts: credential.failedAttempts,
|
|
166
|
+
lockedUntil: credential.lockedUntil,
|
|
167
|
+
lastUsedAt: credential.lastUsedAt,
|
|
168
|
+
createdAt: credential.createdAt,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
assertEnabled() {
|
|
172
|
+
if (!this.settingService.getConfigValue('mpinEnabled')) {
|
|
173
|
+
throw new common_1.NotFoundException(error_messages_1.ERROR_MESSAGES.MPIN_NOT_ENABLED);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
assertNotLocked(credential) {
|
|
177
|
+
if (credential.lockedUntil && credential.lockedUntil.getTime() > Date.now()) {
|
|
178
|
+
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.MPIN_LOCKED);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
assertMpinAcceptable(mpin) {
|
|
182
|
+
const pattern = String(this.settingService.getConfigValue('mpinRegex') ?? '^\\d{4,6}$');
|
|
183
|
+
let matches = false;
|
|
184
|
+
try {
|
|
185
|
+
matches = new RegExp(pattern).test(mpin);
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
this.logger.error(`Invalid mpinRegex setting: ${pattern}`);
|
|
189
|
+
throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.MPIN_FORMAT_INVALID);
|
|
190
|
+
}
|
|
191
|
+
if (!matches) {
|
|
192
|
+
throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.MPIN_FORMAT_INVALID);
|
|
193
|
+
}
|
|
194
|
+
if (this.isPredictable(mpin)) {
|
|
195
|
+
throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.MPIN_TOO_PREDICTABLE);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
isPredictable(mpin) {
|
|
199
|
+
if (/^(\d)\1+$/.test(mpin)) {
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
if (this.isSequential(mpin)) {
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
return MPIN_DENYLIST.has(mpin);
|
|
206
|
+
}
|
|
207
|
+
isSequential(mpin) {
|
|
208
|
+
let ascending = true;
|
|
209
|
+
let descending = true;
|
|
210
|
+
for (let i = 1; i < mpin.length; i++) {
|
|
211
|
+
const step = mpin.charCodeAt(i) - mpin.charCodeAt(i - 1);
|
|
212
|
+
if (step !== 1)
|
|
213
|
+
ascending = false;
|
|
214
|
+
if (step !== -1)
|
|
215
|
+
descending = false;
|
|
216
|
+
}
|
|
217
|
+
return ascending || descending;
|
|
218
|
+
}
|
|
219
|
+
async registerFailedAttempt(credential) {
|
|
220
|
+
const lockThreshold = Number(this.settingService.getConfigValue('mpinMaxFailedAttempts'));
|
|
221
|
+
const deactivateThreshold = Number(this.settingService.getConfigValue('mpinMaxTotalFailedAttempts'));
|
|
222
|
+
const lockoutSeconds = Number(this.settingService.getConfigValue('mpinLockoutDuration'));
|
|
223
|
+
credential.failedAttempts += 1;
|
|
224
|
+
let error = new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.MPIN_INVALID);
|
|
225
|
+
if (credential.isActive && deactivateThreshold > 0 && credential.failedAttempts >= deactivateThreshold) {
|
|
226
|
+
credential.isActive = false;
|
|
227
|
+
credential.lockedUntil = null;
|
|
228
|
+
error = new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.MPIN_REVOKED);
|
|
229
|
+
}
|
|
230
|
+
else if (credential.isActive && lockThreshold > 0 && credential.failedAttempts % lockThreshold === 0) {
|
|
231
|
+
credential.lockedUntil = new Date(Date.now() + lockoutSeconds * 1000);
|
|
232
|
+
error = new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.MPIN_LOCKED);
|
|
233
|
+
}
|
|
234
|
+
await this.credentialRepository.save(credential);
|
|
235
|
+
return error;
|
|
236
|
+
}
|
|
237
|
+
async evictOldestIfAtCap(userId, excludeId) {
|
|
238
|
+
const cap = Number(this.settingService.getConfigValue('mpinMaxDevicesPerUser'));
|
|
239
|
+
if (!cap || cap <= 0) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
const active = (await this.credentialRepository.find({
|
|
243
|
+
where: { user: { id: userId }, isActive: true },
|
|
244
|
+
})).filter((credential) => credential.id !== excludeId);
|
|
245
|
+
const overflow = active.length - (cap - 1);
|
|
246
|
+
if (overflow <= 0) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
const doomed = active
|
|
250
|
+
.sort((a, b) => this.lastUsedMillis(a) - this.lastUsedMillis(b))
|
|
251
|
+
.slice(0, overflow);
|
|
252
|
+
for (const credential of doomed) {
|
|
253
|
+
credential.isActive = false;
|
|
254
|
+
}
|
|
255
|
+
await this.credentialRepository.save(doomed);
|
|
256
|
+
this.logger.log(`Evicted ${doomed.length} MPIN credential(s) for user ${userId} at the device cap of ${cap}`);
|
|
257
|
+
}
|
|
258
|
+
lastUsedMillis(credential) {
|
|
259
|
+
return credential.lastUsedAt?.getTime() ?? credential.createdAt?.getTime() ?? 0;
|
|
260
|
+
}
|
|
261
|
+
buildCredentialKey(username, deviceId) {
|
|
262
|
+
const normalizedUsername = (username ?? '').trim().toLowerCase().replace(/\s+/g, '-');
|
|
263
|
+
return `${normalizedUsername}-${deviceId}`;
|
|
264
|
+
}
|
|
265
|
+
mintCredentialRef() {
|
|
266
|
+
return (0, crypto_1.randomBytes)(32).toString('hex');
|
|
267
|
+
}
|
|
268
|
+
hashCredentialRef(credentialRef) {
|
|
269
|
+
return (0, crypto_1.createHash)('sha256').update(credentialRef).digest('hex');
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
exports.MpinService = MpinService;
|
|
273
|
+
exports.MpinService = MpinService = MpinService_1 = __decorate([
|
|
274
|
+
(0, common_1.Injectable)(),
|
|
275
|
+
__metadata("design:paramtypes", [user_device_credential_repository_1.UserDeviceCredentialRepository,
|
|
276
|
+
user_repository_1.UserRepository,
|
|
277
|
+
hashing_service_1.HashingService,
|
|
278
|
+
setting_service_1.SettingService,
|
|
279
|
+
authentication_service_1.AuthenticationService,
|
|
280
|
+
user_activity_history_service_1.UserActivityHistoryService])
|
|
281
|
+
], MpinService);
|
|
282
|
+
//# sourceMappingURL=mpin.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mpin.service.js","sourceRoot":"","sources":["../../src/services/mpin.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAMwB;AACxB,mCAAiD;AACjD,gEAA8D;AAC9D,oEAAkE;AAMlE,uGAAkG;AAClG,mEAAgE;AAEhE,qEAAiE;AACjE,uDAAmD;AACnD,uDAAmD;AACnD,mFAA6E;AAO7E,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IAC1B,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAC9E,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAC9D,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ;CACvE,CAAC,CAAC;AAGI,IA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QACd,gCAAc;QACd,gCAAc;QACP,8CAAqB;QAChB,0DAA0B;GATlE,WAAW,CA2ZvB","sourcesContent":["import {\n BadRequestException,\n Injectable,\n Logger,\n NotFoundException,\n UnauthorizedException,\n} from '@nestjs/common';\nimport { createHash, randomBytes } from 'crypto';\nimport { ERROR_MESSAGES } from 'src/constants/error-messages';\nimport { SUCCESS_MESSAGES } from 'src/constants/success-messages';\nimport { ChangeMpinDto } from 'src/dtos/change-mpin.dto';\nimport { MpinLoginDto } from 'src/dtos/mpin-login.dto';\nimport { SetupMpinDto } from 'src/dtos/setup-mpin.dto';\nimport { UserDeviceCredential } from 'src/entities/user-device-credential.entity';\nimport { ActiveUserData } from 'src/interfaces/active-user-data.interface';\nimport { UserDeviceCredentialRepository } from 'src/repository/user-device-credential.repository';\nimport { UserRepository } from 'src/repository/user.repository';\nimport type { SolidCoreSetting } from 'src/services/settings/default-settings-provider.service';\nimport { AuthenticationService } from './authentication.service';\nimport { HashingService } from './hashing.service';\nimport { SettingService } from './setting.service';\nimport { UserActivityHistoryService } from './user-activity-history.service';\n\n/**\n * The most-chosen PINs in published analyses of breached sets. `1234` alone\n * accounts for roughly a tenth of four-digit choices, so a list this short\n * removes a disproportionate share of guessable values.\n */\nconst MPIN_DENYLIST = new Set([\n '0000', '1111', '2222', '3333', '4444', '5555', '6666', '7777', '8888', '9999',\n '1234', '4321', '1212', '2001', '1004', '2000', '6969', '2580',\n '000000', '111111', '123456', '654321', '121212', '112233', '123123',\n]);\n\n@Injectable()\nexport class MpinService {\n private readonly logger = new Logger(MpinService.name);\n\n constructor(\n private readonly credentialRepository: UserDeviceCredentialRepository,\n private readonly userRepository: UserRepository,\n private readonly hashingService: HashingService,\n private readonly settingService: SettingService,\n private readonly authenticationService: AuthenticationService,\n private readonly userActivityHistoryService: UserActivityHistoryService,\n ) { }\n\n // ---------------------------------------------------------------- setup\n\n async setupMpin(activeUser: ActiveUserData, dto: SetupMpinDto) {\n this.assertEnabled();\n this.assertMpinAcceptable(dto.mpin);\n\n // The account comes from the access token, never from the body - a\n // client can only ever create a credential for the user it is signed\n // in as.\n const user = await this.userRepository.findOne({ where: { id: activeUser.sub } });\n if (!user) {\n throw new NotFoundException(ERROR_MESSAGES.USER_NOT_FOUND);\n }\n\n // Lower-cased because @IsUUID is case-insensitive: iOS renders a UUID\n // uppercase (identifierForVendor.uuidString) while Android renders it\n // lowercase, and both validate. Without normalising, the same physical\n // device could present two spellings, miss this exact-match lookup and\n // end up with two credential rows consuming two slots against the cap.\n const deviceId = dto.deviceId.toLowerCase();\n\n const existing = await this.credentialRepository.findOne({\n where: { user: { id: user.id }, deviceId },\n });\n\n // Re-running setup on the same device rotates the credential rather\n // than adding a second one.\n const record = existing ?? this.credentialRepository.create({\n user,\n deviceId,\n });\n\n // Recomputed on every setup so a renamed user does not keep a stale\n // key. It is an identifier for humans and tooling, never a lookup key,\n // so drift here costs nothing operationally.\n record.credentialKey = this.buildCredentialKey(user.username, deviceId);\n\n const credentialRef = this.mintCredentialRef();\n record.hashedCredentialRef = this.hashCredentialRef(credentialRef);\n record.hashedMpin = await this.hashingService.hash(dto.mpin);\n record.mpinScheme = this.hashingService.name();\n record.mpinSchemeVersion = this.hashingService.currentVersion();\n record.deviceName = dto.deviceName ?? null;\n record.platform = dto.platform ?? null;\n record.isActive = true;\n record.failedAttempts = 0;\n record.lockedUntil = null;\n\n await this.evictOldestIfAtCap(user.id, existing?.id);\n await this.credentialRepository.save(record);\n\n // Returned once. Only its SHA-256 is stored, so it can never be\n // re-issued - the client must persist it before reporting success.\n return { credentialRef, message: SUCCESS_MESSAGES.MPIN_SETUP_SUCCESS };\n }\n\n async changeMpin(activeUser: ActiveUserData, dto: ChangeMpinDto) {\n this.assertEnabled();\n this.assertMpinAcceptable(dto.newMpin);\n\n // Scoped to the caller, so holding someone else's handle is not enough\n // to change their MPIN.\n const credential = await this.credentialRepository.findOne({\n where: {\n hashedCredentialRef: this.hashCredentialRef(dto.credentialRef),\n user: { id: activeUser.sub },\n },\n });\n\n if (!credential || !credential.isActive) {\n throw new UnauthorizedException(ERROR_MESSAGES.MPIN_INVALID);\n }\n this.assertNotLocked(credential);\n\n const matches = await this.hashingService.compare(\n dto.currentMpin,\n credential.hashedMpin,\n credential.mpinSchemeVersion,\n );\n if (!matches) {\n throw await this.registerFailedAttempt(credential);\n }\n\n // Rotate the handle alongside the MPIN: a changed credential should\n // invalidate anything captured previously.\n const credentialRef = this.mintCredentialRef();\n credential.hashedCredentialRef = this.hashCredentialRef(credentialRef);\n credential.hashedMpin = await this.hashingService.hash(dto.newMpin);\n credential.mpinScheme = this.hashingService.name();\n credential.mpinSchemeVersion = this.hashingService.currentVersion();\n credential.failedAttempts = 0;\n credential.lockedUntil = null;\n await this.credentialRepository.save(credential);\n\n return { credentialRef, message: SUCCESS_MESSAGES.MPIN_CHANGED_SUCCESS };\n }\n\n // ---------------------------------------------------------------- login\n\n async loginWithMpin(dto: MpinLoginDto) {\n this.assertEnabled();\n\n // A single indexed exact-match lookup. The row already names the user,\n // so there is nothing to resolve and no identifier to enumerate with.\n const credential = await this.credentialRepository.findOne({\n where: { hashedCredentialRef: this.hashCredentialRef(dto.credentialRef) },\n relations: { user: { roles: true } },\n });\n\n // An unknown handle is reported exactly as a wrong MPIN is.\n if (!credential || !credential.user) {\n throw new UnauthorizedException(ERROR_MESSAGES.MPIN_INVALID);\n }\n\n // A dead credential is reported as such regardless of what MPIN was\n // supplied. Gating this on a correct MPIN would be marginally more\n // conservative, but it protects almost nothing - \"this dead handle was\n // once real\" grants no capability - and it costs an asymmetry that\n // reads as a bug: the attempt that causes deactivation reports\n // MPIN_REVOKED, while the very next identical attempt would report\n // MPIN_INVALID. The enumeration resistance that matters comes from the\n // handle being unguessable, not from this branch.\n if (!credential.isActive) {\n throw new UnauthorizedException(ERROR_MESSAGES.MPIN_REVOKED);\n }\n\n // Checked before the hash comparison, so attempts made during a lockout\n // neither extend it nor cost a bcrypt call.\n this.assertNotLocked(credential);\n\n const matches = await this.hashingService.compare(\n dto.mpin,\n credential.hashedMpin,\n credential.mpinSchemeVersion,\n );\n\n if (!matches) {\n throw await this.registerFailedAttempt(credential);\n }\n\n credential.failedAttempts = 0;\n credential.lockedUntil = null;\n credential.lastUsedAt = new Date();\n if (this.hashingService.needsRehash(credential.hashedMpin, credential.mpinSchemeVersion)) {\n credential.hashedMpin = await this.hashingService.hash(dto.mpin);\n credential.mpinScheme = this.hashingService.name();\n credential.mpinSchemeVersion = this.hashingService.currentVersion();\n }\n await this.credentialRepository.save(credential);\n\n const user = credential.user;\n await this.userActivityHistoryService.logEvent('login', user);\n\n // A fresh token pair - never a replay of a stored refresh token. This\n // is what makes MPIN survive logout and refresh-token expiry. The\n // stable deviceId keeps repeat logins in one session bucket.\n const tokens = await this.authenticationService.generateTokens(user, credential.deviceId);\n\n return {\n user: {\n id: user.id,\n email: user.email,\n mobile: user.mobile,\n username: user.username,\n forcePasswordChange: user.forcePasswordChange,\n roles: (user.roles ?? []).map((role) => role.name),\n },\n ...tokens,\n };\n }\n\n // ----------------------------------------------------- device management\n\n async listDevices(activeUser: ActiveUserData) {\n this.assertEnabled();\n\n const credentials = await this.credentialRepository.find({\n where: { user: { id: activeUser.sub }, isActive: true },\n });\n\n return credentials\n .sort((a, b) => this.lastUsedMillis(b) - this.lastUsedMillis(a))\n .map((credential) => this.toDeviceView(credential));\n }\n\n async revokeDevice(activeUser: ActiveUserData, id: number) {\n this.assertEnabled();\n\n const credential = await this.credentialRepository.findOne({\n where: { id, user: { id: activeUser.sub } },\n });\n if (!credential) {\n throw new NotFoundException(ERROR_MESSAGES.MPIN_CREDENTIAL_NOT_FOUND);\n }\n\n // Soft-delete. The row survives so a correct MPIN can be answered with\n // MPIN_REVOKED rather than a baffling MPIN_INVALID; only active rows\n // count towards the device cap.\n credential.isActive = false;\n await this.credentialRepository.save(credential);\n\n return { message: SUCCESS_MESSAGES.MPIN_DEVICE_REVOKED };\n }\n\n // -------------------------------------------------------------- internals\n\n /**\n * Never exposes the stored hashes, independently of whatever serialiser\n * configuration a consuming app runs. The entity also withholds them via\n * @Exclude()/@Expose(), but building the response explicitly means a\n * carelessly added decorator cannot leak a credential.\n */\n private toDeviceView(credential: UserDeviceCredential) {\n return {\n id: credential.id,\n deviceId: credential.deviceId,\n deviceName: credential.deviceName,\n platform: credential.platform,\n isActive: credential.isActive,\n failedAttempts: credential.failedAttempts,\n lockedUntil: credential.lockedUntil,\n lastUsedAt: credential.lastUsedAt,\n createdAt: credential.createdAt,\n };\n }\n\n private assertEnabled(): void {\n if (!this.settingService.getConfigValue<SolidCoreSetting>('mpinEnabled')) {\n // 404 rather than 403: a disabled feature should look absent.\n throw new NotFoundException(ERROR_MESSAGES.MPIN_NOT_ENABLED);\n }\n }\n\n private assertNotLocked(credential: UserDeviceCredential): void {\n if (credential.lockedUntil && credential.lockedUntil.getTime() > Date.now()) {\n throw new UnauthorizedException(ERROR_MESSAGES.MPIN_LOCKED);\n }\n }\n\n private assertMpinAcceptable(mpin: string): void {\n const pattern = String(\n this.settingService.getConfigValue<SolidCoreSetting>('mpinRegex') ?? '^\\\\d{4,6}$',\n );\n\n // Fails closed. `matches` starts false and a malformed pattern - the\n // setting is admin-editable free text - becomes a rejection rather\n // than a skipped check, so a typo cannot silently let users set an\n // MPIN weaker than policy allows.\n let matches = false;\n try {\n matches = new RegExp(pattern).test(mpin);\n } catch {\n this.logger.error(`Invalid mpinRegex setting: ${pattern}`);\n throw new BadRequestException(ERROR_MESSAGES.MPIN_FORMAT_INVALID);\n }\n\n if (!matches) {\n throw new BadRequestException(ERROR_MESSAGES.MPIN_FORMAT_INVALID);\n }\n\n // Predictability is semantics, not shape - a regex expressing \"not\n // sequential\" would be unreadable and easy to get subtly wrong.\n if (this.isPredictable(mpin)) {\n // Safe to distinguish, and 400 rather than 401: this only ever\n // happens on a bearer-authenticated route, so it is a validation\n // failure rather than an authentication one.\n throw new BadRequestException(ERROR_MESSAGES.MPIN_TOO_PREDICTABLE);\n }\n }\n\n private isPredictable(mpin: string): boolean {\n if (/^(\\d)\\1+$/.test(mpin)) {\n return true;\n }\n if (this.isSequential(mpin)) {\n return true;\n }\n return MPIN_DENYLIST.has(mpin);\n }\n\n private isSequential(mpin: string): boolean {\n let ascending = true;\n let descending = true;\n for (let i = 1; i < mpin.length; i++) {\n const step = mpin.charCodeAt(i) - mpin.charCodeAt(i - 1);\n if (step !== 1) ascending = false;\n if (step !== -1) descending = false;\n }\n return ascending || descending;\n }\n\n /**\n * Records a failure and escalates. `failedAttempts` is cumulative and\n * resets only on success - never when a lockout expires - which is what\n * makes the second threshold detectable without a separate counter.\n *\n * Returns the exception for the caller to throw, so the save is always\n * awaited before the response leaves.\n */\n private async registerFailedAttempt(\n credential: UserDeviceCredential,\n ): Promise<UnauthorizedException> {\n const lockThreshold = Number(\n this.settingService.getConfigValue<SolidCoreSetting>('mpinMaxFailedAttempts'),\n );\n const deactivateThreshold = Number(\n this.settingService.getConfigValue<SolidCoreSetting>('mpinMaxTotalFailedAttempts'),\n );\n const lockoutSeconds = Number(\n this.settingService.getConfigValue<SolidCoreSetting>('mpinLockoutDuration'),\n );\n\n credential.failedAttempts += 1;\n let error = new UnauthorizedException(ERROR_MESSAGES.MPIN_INVALID);\n\n if (credential.isActive && deactivateThreshold > 0 && credential.failedAttempts >= deactivateThreshold) {\n credential.isActive = false;\n credential.lockedUntil = null;\n // This attempt caused the deactivation, so it is reported. The\n // caller reached the limit on a handle they demonstrably hold and\n // caused this state themselves, so nothing is disclosed - and\n // without it they would keep retrying a permanently dead credential.\n error = new UnauthorizedException(ERROR_MESSAGES.MPIN_REVOKED);\n } else if (credential.isActive && lockThreshold > 0 && credential.failedAttempts % lockThreshold === 0) {\n credential.lockedUntil = new Date(Date.now() + lockoutSeconds * 1000);\n error = new UnauthorizedException(ERROR_MESSAGES.MPIN_LOCKED);\n }\n\n await this.credentialRepository.save(credential);\n return error;\n }\n\n /**\n * The cap evicts rather than rejects. A reinstall wipes the client's\n * deviceId, so the app generates a new one and setup adds a row instead of\n * replacing the old, orphaned one. Rejecting at the cap would mean a user\n * who reinstalls a few times could never set MPIN up again.\n */\n private async evictOldestIfAtCap(userId: number, excludeId?: number): Promise<void> {\n const cap = Number(\n this.settingService.getConfigValue<SolidCoreSetting>('mpinMaxDevicesPerUser'),\n );\n if (!cap || cap <= 0) {\n return;\n }\n\n const active = (await this.credentialRepository.find({\n where: { user: { id: userId }, isActive: true },\n })).filter((credential) => credential.id !== excludeId);\n\n // One slot is about to be taken by the credential being written.\n const overflow = active.length - (cap - 1);\n if (overflow <= 0) {\n return;\n }\n\n // Sorted in JS rather than SQL because a never-used credential has a\n // null lastUsedAt, and Postgres sorts nulls last on ASC - which would\n // treat the least-used rows as the most recently used.\n const doomed = active\n .sort((a, b) => this.lastUsedMillis(a) - this.lastUsedMillis(b))\n .slice(0, overflow);\n\n for (const credential of doomed) {\n credential.isActive = false;\n }\n await this.credentialRepository.save(doomed);\n this.logger.log(\n `Evicted ${doomed.length} MPIN credential(s) for user ${userId} at the device cap of ${cap}`,\n );\n }\n\n private lastUsedMillis(credential: UserDeviceCredential): number {\n return credential.lastUsedAt?.getTime() ?? credential.createdAt?.getTime() ?? 0;\n }\n\n /**\n * `<username>-<deviceId>`, the model's natural key.\n *\n * Not slugified: lodash `kebabCase` splits digit/letter boundaries, so it\n * would shred a UUID into `3-f-7-b-8-a-10-...`. The username is lower-cased\n * and stripped of whitespace, which is enough for a key that is only ever\n * read, never parsed back into its parts.\n */\n private buildCredentialKey(username: string, deviceId: string): string {\n const normalizedUsername = (username ?? '').trim().toLowerCase().replace(/\\s+/g, '-');\n return `${normalizedUsername}-${deviceId}`;\n }\n\n private mintCredentialRef(): string {\n return randomBytes(32).toString('hex');\n }\n\n // SHA-256, not bcrypt: 256 bits of randomness has nothing to brute-force,\n // so a slow hash would only add latency to every login. Same reasoning as\n // ApiKeyService.hash.\n private hashCredentialRef(credentialRef: string): string {\n return createHash('sha256').update(credentialRef).digest('hex');\n }\n}\n"]}
|
|
@@ -1073,6 +1073,66 @@ declare const getSolidCoreSettings: (isProd: boolean) => [{
|
|
|
1073
1073
|
readonly group: "authentication-settings";
|
|
1074
1074
|
readonly sortOrder: 200;
|
|
1075
1075
|
readonly controlType: "boolean";
|
|
1076
|
+
}, {
|
|
1077
|
+
readonly moduleName: "solid-core";
|
|
1078
|
+
readonly key: "mpinEnabled";
|
|
1079
|
+
readonly value: false;
|
|
1080
|
+
readonly level: SettingLevel.SystemAdminEditable;
|
|
1081
|
+
readonly label: "Enable MPIN Sign-in";
|
|
1082
|
+
readonly group: "authentication-settings";
|
|
1083
|
+
readonly sortOrder: 210;
|
|
1084
|
+
readonly controlType: "boolean";
|
|
1085
|
+
readonly helpText: "Allows users to set a short device PIN for faster sign-in. Every MPIN route returns 404 while this is off.";
|
|
1086
|
+
}, {
|
|
1087
|
+
readonly moduleName: "solid-core";
|
|
1088
|
+
readonly key: "mpinRegex";
|
|
1089
|
+
readonly value: string;
|
|
1090
|
+
readonly level: SettingLevel.SystemAdminEditable;
|
|
1091
|
+
readonly label: "MPIN Format";
|
|
1092
|
+
readonly group: "authentication-settings";
|
|
1093
|
+
readonly sortOrder: 211;
|
|
1094
|
+
readonly controlType: "shortText";
|
|
1095
|
+
readonly helpText: "Regular expression the MPIN must match. Sole authority on MPIN length - the default allows 4 to 6 digits. Predictable PINs (repeated or sequential digits) are rejected separately.";
|
|
1096
|
+
}, {
|
|
1097
|
+
readonly moduleName: "solid-core";
|
|
1098
|
+
readonly key: "mpinMaxFailedAttempts";
|
|
1099
|
+
readonly value: number;
|
|
1100
|
+
readonly level: SettingLevel.SystemAdminEditable;
|
|
1101
|
+
readonly label: "MPIN Attempts Before Lockout";
|
|
1102
|
+
readonly group: "authentication-settings";
|
|
1103
|
+
readonly sortOrder: 212;
|
|
1104
|
+
readonly controlType: "numeric";
|
|
1105
|
+
readonly helpText: "Cumulative failed attempts that trigger a temporary lockout. The counter resets only on a successful MPIN sign-in, not when the lockout expires.";
|
|
1106
|
+
}, {
|
|
1107
|
+
readonly moduleName: "solid-core";
|
|
1108
|
+
readonly key: "mpinLockoutDuration";
|
|
1109
|
+
readonly value: number;
|
|
1110
|
+
readonly level: SettingLevel.SystemAdminEditable;
|
|
1111
|
+
readonly label: "MPIN Lockout Duration (seconds)";
|
|
1112
|
+
readonly group: "authentication-settings";
|
|
1113
|
+
readonly sortOrder: 213;
|
|
1114
|
+
readonly controlType: "numeric";
|
|
1115
|
+
readonly helpText: "How long the temporary lockout lasts.";
|
|
1116
|
+
}, {
|
|
1117
|
+
readonly moduleName: "solid-core";
|
|
1118
|
+
readonly key: "mpinMaxTotalFailedAttempts";
|
|
1119
|
+
readonly value: number;
|
|
1120
|
+
readonly level: SettingLevel.SystemAdminEditable;
|
|
1121
|
+
readonly label: "MPIN Attempts Before Permanent Deactivation";
|
|
1122
|
+
readonly group: "authentication-settings";
|
|
1123
|
+
readonly sortOrder: 214;
|
|
1124
|
+
readonly controlType: "numeric";
|
|
1125
|
+
readonly helpText: "Cumulative failed attempts that permanently disable MPIN on that device. Must exceed the lockout threshold. The account itself is never locked - the user signs in normally and sets MPIN up again.";
|
|
1126
|
+
}, {
|
|
1127
|
+
readonly moduleName: "solid-core";
|
|
1128
|
+
readonly key: "mpinMaxDevicesPerUser";
|
|
1129
|
+
readonly value: number;
|
|
1130
|
+
readonly level: SettingLevel.SystemAdminEditable;
|
|
1131
|
+
readonly label: "Max MPIN Devices Per User";
|
|
1132
|
+
readonly group: "authentication-settings";
|
|
1133
|
+
readonly sortOrder: 215;
|
|
1134
|
+
readonly controlType: "numeric";
|
|
1135
|
+
readonly helpText: "At the cap the least recently used credential is evicted rather than the setup rejected, so repeated app reinstalls cannot lock a user out of MPIN setup.";
|
|
1076
1136
|
}, {
|
|
1077
1137
|
readonly moduleName: "solid-core";
|
|
1078
1138
|
readonly key: "queuesDefaultBroker";
|
|
@@ -2400,6 +2460,66 @@ export declare class SolidCoreDefaultSettingsProvider implements ISettingsProvid
|
|
|
2400
2460
|
readonly group: "authentication-settings";
|
|
2401
2461
|
readonly sortOrder: 200;
|
|
2402
2462
|
readonly controlType: "boolean";
|
|
2463
|
+
}, {
|
|
2464
|
+
readonly moduleName: "solid-core";
|
|
2465
|
+
readonly key: "mpinEnabled";
|
|
2466
|
+
readonly value: false;
|
|
2467
|
+
readonly level: SettingLevel.SystemAdminEditable;
|
|
2468
|
+
readonly label: "Enable MPIN Sign-in";
|
|
2469
|
+
readonly group: "authentication-settings";
|
|
2470
|
+
readonly sortOrder: 210;
|
|
2471
|
+
readonly controlType: "boolean";
|
|
2472
|
+
readonly helpText: "Allows users to set a short device PIN for faster sign-in. Every MPIN route returns 404 while this is off.";
|
|
2473
|
+
}, {
|
|
2474
|
+
readonly moduleName: "solid-core";
|
|
2475
|
+
readonly key: "mpinRegex";
|
|
2476
|
+
readonly value: string;
|
|
2477
|
+
readonly level: SettingLevel.SystemAdminEditable;
|
|
2478
|
+
readonly label: "MPIN Format";
|
|
2479
|
+
readonly group: "authentication-settings";
|
|
2480
|
+
readonly sortOrder: 211;
|
|
2481
|
+
readonly controlType: "shortText";
|
|
2482
|
+
readonly helpText: "Regular expression the MPIN must match. Sole authority on MPIN length - the default allows 4 to 6 digits. Predictable PINs (repeated or sequential digits) are rejected separately.";
|
|
2483
|
+
}, {
|
|
2484
|
+
readonly moduleName: "solid-core";
|
|
2485
|
+
readonly key: "mpinMaxFailedAttempts";
|
|
2486
|
+
readonly value: number;
|
|
2487
|
+
readonly level: SettingLevel.SystemAdminEditable;
|
|
2488
|
+
readonly label: "MPIN Attempts Before Lockout";
|
|
2489
|
+
readonly group: "authentication-settings";
|
|
2490
|
+
readonly sortOrder: 212;
|
|
2491
|
+
readonly controlType: "numeric";
|
|
2492
|
+
readonly helpText: "Cumulative failed attempts that trigger a temporary lockout. The counter resets only on a successful MPIN sign-in, not when the lockout expires.";
|
|
2493
|
+
}, {
|
|
2494
|
+
readonly moduleName: "solid-core";
|
|
2495
|
+
readonly key: "mpinLockoutDuration";
|
|
2496
|
+
readonly value: number;
|
|
2497
|
+
readonly level: SettingLevel.SystemAdminEditable;
|
|
2498
|
+
readonly label: "MPIN Lockout Duration (seconds)";
|
|
2499
|
+
readonly group: "authentication-settings";
|
|
2500
|
+
readonly sortOrder: 213;
|
|
2501
|
+
readonly controlType: "numeric";
|
|
2502
|
+
readonly helpText: "How long the temporary lockout lasts.";
|
|
2503
|
+
}, {
|
|
2504
|
+
readonly moduleName: "solid-core";
|
|
2505
|
+
readonly key: "mpinMaxTotalFailedAttempts";
|
|
2506
|
+
readonly value: number;
|
|
2507
|
+
readonly level: SettingLevel.SystemAdminEditable;
|
|
2508
|
+
readonly label: "MPIN Attempts Before Permanent Deactivation";
|
|
2509
|
+
readonly group: "authentication-settings";
|
|
2510
|
+
readonly sortOrder: 214;
|
|
2511
|
+
readonly controlType: "numeric";
|
|
2512
|
+
readonly helpText: "Cumulative failed attempts that permanently disable MPIN on that device. Must exceed the lockout threshold. The account itself is never locked - the user signs in normally and sets MPIN up again.";
|
|
2513
|
+
}, {
|
|
2514
|
+
readonly moduleName: "solid-core";
|
|
2515
|
+
readonly key: "mpinMaxDevicesPerUser";
|
|
2516
|
+
readonly value: number;
|
|
2517
|
+
readonly level: SettingLevel.SystemAdminEditable;
|
|
2518
|
+
readonly label: "Max MPIN Devices Per User";
|
|
2519
|
+
readonly group: "authentication-settings";
|
|
2520
|
+
readonly sortOrder: 215;
|
|
2521
|
+
readonly controlType: "numeric";
|
|
2522
|
+
readonly helpText: "At the cap the least recently used credential is evicted rather than the setup rejected, so repeated app reinstalls cannot lock a user out of MPIN setup.";
|
|
2403
2523
|
}, {
|
|
2404
2524
|
readonly moduleName: "solid-core";
|
|
2405
2525
|
readonly key: "queuesDefaultBroker";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-settings-provider.service.d.ts","sourceRoot":"","sources":["../../../src/services/settings/default-settings-provider.service.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,iBAAiB,EAEjB,YAAY,EACb,MAAM,gBAAgB,CAAC;AAGxB,eAAO,MAAM,wBAAwB,kBAAkB,CAAC;AACxD,eAAO,MAAM,8BAA8B,wBAAwB,CAAC;AAUpE,QAAA,MAAM,oBAAoB,GAAI,QAAQ,OAAO
|
|
1
|
+
{"version":3,"file":"default-settings-provider.service.d.ts","sourceRoot":"","sources":["../../../src/services/settings/default-settings-provider.service.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,iBAAiB,EAEjB,YAAY,EACb,MAAM,gBAAgB,CAAC;AAGxB,eAAO,MAAM,wBAAwB,kBAAkB,CAAC;AACxD,eAAO,MAAM,8BAA8B,wBAAwB,CAAC;AAUpE,QAAA,MAAM,oBAAoB,GAAI,QAAQ,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIZ"}
|
|
@@ -1201,6 +1201,72 @@ const getSolidCoreSettings = (isProd) => [
|
|
|
1201
1201
|
sortOrder: 200,
|
|
1202
1202
|
controlType: "boolean",
|
|
1203
1203
|
},
|
|
1204
|
+
{
|
|
1205
|
+
moduleName: "solid-core",
|
|
1206
|
+
key: "mpinEnabled",
|
|
1207
|
+
value: false,
|
|
1208
|
+
level: interfaces_1.SettingLevel.SystemAdminEditable,
|
|
1209
|
+
label: "Enable MPIN Sign-in",
|
|
1210
|
+
group: "authentication-settings",
|
|
1211
|
+
sortOrder: 210,
|
|
1212
|
+
controlType: "boolean",
|
|
1213
|
+
helpText: "Allows users to set a short device PIN for faster sign-in. Every MPIN route returns 404 while this is off.",
|
|
1214
|
+
},
|
|
1215
|
+
{
|
|
1216
|
+
moduleName: "solid-core",
|
|
1217
|
+
key: "mpinRegex",
|
|
1218
|
+
value: process.env.IAM_MPIN_REGEX ?? "^\\d{4,6}$",
|
|
1219
|
+
level: interfaces_1.SettingLevel.SystemAdminEditable,
|
|
1220
|
+
label: "MPIN Format",
|
|
1221
|
+
group: "authentication-settings",
|
|
1222
|
+
sortOrder: 211,
|
|
1223
|
+
controlType: "shortText",
|
|
1224
|
+
helpText: "Regular expression the MPIN must match. Sole authority on MPIN length - the default allows 4 to 6 digits. Predictable PINs (repeated or sequential digits) are rejected separately.",
|
|
1225
|
+
},
|
|
1226
|
+
{
|
|
1227
|
+
moduleName: "solid-core",
|
|
1228
|
+
key: "mpinMaxFailedAttempts",
|
|
1229
|
+
value: parseInt(process.env.IAM_MPIN_MAX_FAILED_ATTEMPTS ?? "5", 10),
|
|
1230
|
+
level: interfaces_1.SettingLevel.SystemAdminEditable,
|
|
1231
|
+
label: "MPIN Attempts Before Lockout",
|
|
1232
|
+
group: "authentication-settings",
|
|
1233
|
+
sortOrder: 212,
|
|
1234
|
+
controlType: "numeric",
|
|
1235
|
+
helpText: "Cumulative failed attempts that trigger a temporary lockout. The counter resets only on a successful MPIN sign-in, not when the lockout expires.",
|
|
1236
|
+
},
|
|
1237
|
+
{
|
|
1238
|
+
moduleName: "solid-core",
|
|
1239
|
+
key: "mpinLockoutDuration",
|
|
1240
|
+
value: parseInt(process.env.IAM_MPIN_LOCKOUT_DURATION ?? "900", 10),
|
|
1241
|
+
level: interfaces_1.SettingLevel.SystemAdminEditable,
|
|
1242
|
+
label: "MPIN Lockout Duration (seconds)",
|
|
1243
|
+
group: "authentication-settings",
|
|
1244
|
+
sortOrder: 213,
|
|
1245
|
+
controlType: "numeric",
|
|
1246
|
+
helpText: "How long the temporary lockout lasts.",
|
|
1247
|
+
},
|
|
1248
|
+
{
|
|
1249
|
+
moduleName: "solid-core",
|
|
1250
|
+
key: "mpinMaxTotalFailedAttempts",
|
|
1251
|
+
value: parseInt(process.env.IAM_MPIN_MAX_TOTAL_FAILED_ATTEMPTS ?? "10", 10),
|
|
1252
|
+
level: interfaces_1.SettingLevel.SystemAdminEditable,
|
|
1253
|
+
label: "MPIN Attempts Before Permanent Deactivation",
|
|
1254
|
+
group: "authentication-settings",
|
|
1255
|
+
sortOrder: 214,
|
|
1256
|
+
controlType: "numeric",
|
|
1257
|
+
helpText: "Cumulative failed attempts that permanently disable MPIN on that device. Must exceed the lockout threshold. The account itself is never locked - the user signs in normally and sets MPIN up again.",
|
|
1258
|
+
},
|
|
1259
|
+
{
|
|
1260
|
+
moduleName: "solid-core",
|
|
1261
|
+
key: "mpinMaxDevicesPerUser",
|
|
1262
|
+
value: parseInt(process.env.IAM_MPIN_MAX_DEVICES_PER_USER ?? "5", 10),
|
|
1263
|
+
level: interfaces_1.SettingLevel.SystemAdminEditable,
|
|
1264
|
+
label: "Max MPIN Devices Per User",
|
|
1265
|
+
group: "authentication-settings",
|
|
1266
|
+
sortOrder: 215,
|
|
1267
|
+
controlType: "numeric",
|
|
1268
|
+
helpText: "At the cap the least recently used credential is evicted rather than the setup rejected, so repeated app reinstalls cannot lock a user out of MPIN setup.",
|
|
1269
|
+
},
|
|
1204
1270
|
{
|
|
1205
1271
|
moduleName: "solid-core",
|
|
1206
1272
|
key: "queuesDefaultBroker",
|