@things-factory/auth-base 9.0.0-beta.76 → 9.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/dist-client/auth.js +2 -4
- package/dist-client/auth.js.map +1 -1
- package/dist-client/reducers/auth.js +9 -2
- package/dist-client/reducers/auth.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/controllers/change-pwd.js +5 -2
- package/dist-server/controllers/change-pwd.js.map +1 -1
- package/dist-server/controllers/checkin.js +1 -1
- package/dist-server/controllers/checkin.js.map +1 -1
- package/dist-server/controllers/delete-user.js +2 -2
- package/dist-server/controllers/delete-user.js.map +1 -1
- package/dist-server/controllers/profile.js +4 -1
- package/dist-server/controllers/profile.js.map +1 -1
- package/dist-server/controllers/reset-password.js +5 -2
- package/dist-server/controllers/reset-password.js.map +1 -1
- package/dist-server/controllers/signin.js +2 -2
- package/dist-server/controllers/signin.js.map +1 -1
- package/dist-server/controllers/signup.js +8 -1
- package/dist-server/controllers/signup.js.map +1 -1
- package/dist-server/errors/auth-error.js +3 -1
- package/dist-server/errors/auth-error.js.map +1 -1
- package/dist-server/middlewares/authenticate-401-middleware.js +22 -9
- package/dist-server/middlewares/authenticate-401-middleware.js.map +1 -1
- package/dist-server/middlewares/domain-authenticate-middleware.js +1 -1
- package/dist-server/middlewares/domain-authenticate-middleware.js.map +1 -1
- package/dist-server/middlewares/jwt-authenticate-middleware.js +1 -1
- package/dist-server/middlewares/jwt-authenticate-middleware.js.map +1 -1
- package/dist-server/migrations/1548206416130-SeedUser.js +11 -3
- package/dist-server/migrations/1548206416130-SeedUser.js.map +1 -1
- package/dist-server/router/auth-signup-router.js +5 -2
- package/dist-server/router/auth-signup-router.js.map +1 -1
- package/dist-server/router/oauth2/oauth2-authorize-router.js +5 -2
- package/dist-server/router/oauth2/oauth2-authorize-router.js.map +1 -1
- package/dist-server/router/oauth2/oauth2-router.js +1 -2
- package/dist-server/router/oauth2/oauth2-router.js.map +1 -1
- package/dist-server/router/oauth2/oauth2-server.js +21 -3
- package/dist-server/router/oauth2/oauth2-server.js.map +1 -1
- package/dist-server/router/site-root-router.js +1 -1
- package/dist-server/router/site-root-router.js.map +1 -1
- package/dist-server/router/webauthn-router.js +1 -1
- package/dist-server/router/webauthn-router.js.map +1 -1
- package/dist-server/service/app-binding/app-binding-types.js +3 -3
- package/dist-server/service/app-binding/app-binding-types.js.map +1 -1
- package/dist-server/service/app-binding/app-binding.js +6 -4
- package/dist-server/service/app-binding/app-binding.js.map +1 -1
- package/dist-server/service/appliance/appliance-mutation.js +20 -4
- package/dist-server/service/appliance/appliance-mutation.js.map +1 -1
- package/dist-server/service/appliance/appliance-types.js +18 -18
- package/dist-server/service/appliance/appliance-types.js.map +1 -1
- package/dist-server/service/appliance/appliance.js +22 -18
- package/dist-server/service/appliance/appliance.js.map +1 -1
- package/dist-server/service/application/application-mutation.js +22 -4
- package/dist-server/service/application/application-mutation.js.map +1 -1
- package/dist-server/service/application/application-types.js +24 -24
- package/dist-server/service/application/application-types.js.map +1 -1
- package/dist-server/service/application/application.d.ts +6 -6
- package/dist-server/service/application/application.js +22 -22
- package/dist-server/service/application/application.js.map +1 -1
- package/dist-server/service/auth-provider/auth-provider-mutation.js +29 -7
- package/dist-server/service/auth-provider/auth-provider-mutation.js.map +1 -1
- package/dist-server/service/auth-provider/auth-provider-parameter-spec.js +12 -7
- package/dist-server/service/auth-provider/auth-provider-parameter-spec.js.map +1 -1
- package/dist-server/service/auth-provider/auth-provider-type.js +24 -21
- package/dist-server/service/auth-provider/auth-provider-type.js.map +1 -1
- package/dist-server/service/auth-provider/auth-provider.js +35 -25
- package/dist-server/service/auth-provider/auth-provider.js.map +1 -1
- package/dist-server/service/domain-generator/domain-generator-mutation.js +1 -2
- package/dist-server/service/domain-generator/domain-generator-mutation.js.map +1 -1
- package/dist-server/service/domain-generator/domain-generator-types.js +17 -14
- package/dist-server/service/domain-generator/domain-generator-types.js.map +1 -1
- package/dist-server/service/domain-link/domain-link-mutation.js +23 -6
- package/dist-server/service/domain-link/domain-link-mutation.js.map +1 -1
- package/dist-server/service/domain-link/domain-link-types.js +13 -13
- package/dist-server/service/domain-link/domain-link-types.js.map +1 -1
- package/dist-server/service/domain-link/domain-link.d.ts +2 -2
- package/dist-server/service/domain-link/domain-link.js +11 -11
- package/dist-server/service/domain-link/domain-link.js.map +1 -1
- package/dist-server/service/granted-role/granted-role-mutation.js +7 -7
- package/dist-server/service/granted-role/granted-role-mutation.js.map +1 -1
- package/dist-server/service/granted-role/granted-role.js +4 -4
- package/dist-server/service/granted-role/granted-role.js.map +1 -1
- package/dist-server/service/invitation/invitation-mutation.js +6 -2
- package/dist-server/service/invitation/invitation-mutation.js.map +1 -1
- package/dist-server/service/invitation/invitation-types.js +3 -3
- package/dist-server/service/invitation/invitation-types.js.map +1 -1
- package/dist-server/service/invitation/invitation.js +10 -10
- package/dist-server/service/invitation/invitation.js.map +1 -1
- package/dist-server/service/login-history/login-history-type.js +3 -3
- package/dist-server/service/login-history/login-history-type.js.map +1 -1
- package/dist-server/service/login-history/login-history.js +6 -6
- package/dist-server/service/login-history/login-history.js.map +1 -1
- package/dist-server/service/partner/partner-types.js +3 -3
- package/dist-server/service/partner/partner-types.js.map +1 -1
- package/dist-server/service/partner/partner.js +8 -8
- package/dist-server/service/partner/partner.js.map +1 -1
- package/dist-server/service/password-history/password-history.js +3 -3
- package/dist-server/service/password-history/password-history.js.map +1 -1
- package/dist-server/service/privilege/privilege-directive.js +1 -2
- package/dist-server/service/privilege/privilege-directive.js.map +1 -1
- package/dist-server/service/privilege/privilege-mutation.js +11 -2
- package/dist-server/service/privilege/privilege-mutation.js.map +1 -1
- package/dist-server/service/privilege/privilege.js +20 -20
- package/dist-server/service/privilege/privilege.js.map +1 -1
- package/dist-server/service/role/role-mutation.js +12 -2
- package/dist-server/service/role/role-mutation.js.map +1 -1
- package/dist-server/service/role/role-query.js +1 -1
- package/dist-server/service/role/role-query.js.map +1 -1
- package/dist-server/service/role/role-types.js +29 -29
- package/dist-server/service/role/role-types.js.map +1 -1
- package/dist-server/service/role/role.js +11 -11
- package/dist-server/service/role/role.js.map +1 -1
- package/dist-server/service/user/user-mutation.js +89 -41
- package/dist-server/service/user/user-mutation.js.map +1 -1
- package/dist-server/service/user/user-query.js +16 -10
- package/dist-server/service/user/user-query.js.map +1 -1
- package/dist-server/service/user/user-types.js +33 -32
- package/dist-server/service/user/user-types.js.map +1 -1
- package/dist-server/service/user/user.d.ts +5 -5
- package/dist-server/service/user/user.js +25 -22
- package/dist-server/service/user/user.js.map +1 -1
- package/dist-server/service/users-auth-providers/users-auth-providers.js +11 -8
- package/dist-server/service/users-auth-providers/users-auth-providers.js.map +1 -1
- package/dist-server/service/verification-token/verification-token.d.ts +3 -3
- package/dist-server/service/verification-token/verification-token.js +8 -8
- package/dist-server/service/verification-token/verification-token.js.map +1 -1
- package/dist-server/service/web-auth-credential/web-auth-credential.js +11 -10
- package/dist-server/service/web-auth-credential/web-auth-credential.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/dist-server/utils/access-token-cookie.js +1 -2
- package/dist-server/utils/access-token-cookie.js.map +1 -1
- package/dist-server/utils/check-user-belongs-domain.js +1 -2
- package/dist-server/utils/check-user-belongs-domain.js.map +1 -1
- package/dist-server/utils/get-domain-users.js +2 -2
- package/dist-server/utils/get-domain-users.js.map +1 -1
- package/package.json +6 -6
@@ -1,4 +1,6 @@
|
|
1
1
|
"use strict";
|
2
|
+
// This file defines the User entity and its GraphQL schema for authentication and authorization.
|
3
|
+
// It includes user fields, status enum, and utility methods for password and privilege management.
|
2
4
|
var User_1;
|
3
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
6
|
exports.User = exports.UserStatus = void 0;
|
@@ -28,7 +30,7 @@ var UserStatus;
|
|
28
30
|
UserStatus["DELETED"] = "deleted";
|
29
31
|
UserStatus["LOCKED"] = "locked";
|
30
32
|
UserStatus["BANNED"] = "banned";
|
31
|
-
UserStatus["PWD_RESET_REQUIRED"] = "password_reset_required";
|
33
|
+
UserStatus["PWD_RESET_REQUIRED"] = "password_reset_required"; // The user must reset their password before logging in.
|
32
34
|
})(UserStatus || (exports.UserStatus = UserStatus = {}));
|
33
35
|
let User = User_1 = class User {
|
34
36
|
/* signing for jsonwebtoken */
|
@@ -72,7 +74,7 @@ let User = User_1 = class User {
|
|
72
74
|
.digest('base64'));
|
73
75
|
}
|
74
76
|
static async checkAuthWithEmail(decoded) {
|
75
|
-
if (!
|
77
|
+
if (!decoded?.email) {
|
76
78
|
throw new auth_error_js_1.AuthError({
|
77
79
|
errorCode: auth_error_js_1.AuthError.ERROR_CODES.USER_NOT_FOUND
|
78
80
|
});
|
@@ -214,33 +216,33 @@ let User = User_1 = class User {
|
|
214
216
|
exports.User = User;
|
215
217
|
tslib_1.__decorate([
|
216
218
|
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
217
|
-
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
219
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'Unique identifier for the user.' }),
|
218
220
|
tslib_1.__metadata("design:type", String)
|
219
221
|
], User.prototype, "id", void 0);
|
220
222
|
tslib_1.__decorate([
|
221
223
|
(0, typeorm_1.Column)({ nullable: true }),
|
222
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
224
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Unique username for the user.' }),
|
223
225
|
tslib_1.__metadata("design:type", String)
|
224
226
|
], User.prototype, "username", void 0);
|
225
227
|
tslib_1.__decorate([
|
226
228
|
(0, typeorm_1.Column)(),
|
227
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
229
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Full name of the user.' }),
|
228
230
|
tslib_1.__metadata("design:type", String)
|
229
231
|
], User.prototype, "name", void 0);
|
230
232
|
tslib_1.__decorate([
|
231
233
|
(0, typeorm_1.Column)({ nullable: true }),
|
232
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
234
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Optional description or note about the user.' }),
|
233
235
|
tslib_1.__metadata("design:type", String)
|
234
236
|
], User.prototype, "description", void 0);
|
235
237
|
tslib_1.__decorate([
|
236
238
|
(0, typeorm_1.ManyToMany)(type => shell_1.Domain),
|
237
239
|
(0, typeorm_1.JoinTable)({ name: 'users_domains' }),
|
238
|
-
(0, type_graphql_1.Field)(type => [shell_1.Domain]),
|
240
|
+
(0, type_graphql_1.Field)(type => [shell_1.Domain], { description: 'Domains (organizations, companies, etc.) the user belongs to.' }),
|
239
241
|
tslib_1.__metadata("design:type", Array)
|
240
242
|
], User.prototype, "domains", void 0);
|
241
243
|
tslib_1.__decorate([
|
242
244
|
(0, typeorm_1.Column)(),
|
243
|
-
(0, type_graphql_1.Field)(type => graphql_scalars_1.GraphQLEmailAddress),
|
245
|
+
(0, type_graphql_1.Field)(type => graphql_scalars_1.GraphQLEmailAddress, { description: 'Email address of the user.' }),
|
244
246
|
tslib_1.__metadata("design:type", String)
|
245
247
|
], User.prototype, "email", void 0);
|
246
248
|
tslib_1.__decorate([
|
@@ -261,17 +263,17 @@ tslib_1.__decorate([
|
|
261
263
|
tslib_1.__decorate([
|
262
264
|
(0, typeorm_1.ManyToMany)(type => role_js_1.Role, role => role.users),
|
263
265
|
(0, typeorm_1.JoinTable)({ name: 'users_roles' }),
|
264
|
-
(0, type_graphql_1.Field)(type => [role_js_1.Role]),
|
266
|
+
(0, type_graphql_1.Field)(type => [role_js_1.Role], { description: 'Roles assigned to the user.' }),
|
265
267
|
tslib_1.__metadata("design:type", Array)
|
266
268
|
], User.prototype, "roles", void 0);
|
267
269
|
tslib_1.__decorate([
|
268
270
|
(0, typeorm_1.Column)({ nullable: true }),
|
269
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
271
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Type or category of the user (e.g., user, application, appliance).' }),
|
270
272
|
tslib_1.__metadata("design:type", String)
|
271
273
|
], User.prototype, "userType", void 0);
|
272
274
|
tslib_1.__decorate([
|
273
275
|
(0, typeorm_1.Column)({ nullable: true }),
|
274
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
276
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Reference information for the user (external system, etc.).' }),
|
275
277
|
tslib_1.__metadata("design:type", String)
|
276
278
|
], User.prototype, "reference", void 0);
|
277
279
|
tslib_1.__decorate([
|
@@ -281,13 +283,13 @@ tslib_1.__decorate([
|
|
281
283
|
], User.prototype, "salt", void 0);
|
282
284
|
tslib_1.__decorate([
|
283
285
|
(0, typeorm_1.Column)({ nullable: true }),
|
284
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
286
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Locale or language preference for the user.' }),
|
285
287
|
tslib_1.__metadata("design:type", String)
|
286
288
|
], User.prototype, "locale", void 0);
|
287
289
|
tslib_1.__decorate([
|
288
290
|
(0, type_graphql_1.Directive)('@privilege(category: "security", privilege: "query", domainOwnerGranted: true)'),
|
289
291
|
(0, typeorm_1.Column)({ nullable: true }),
|
290
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
292
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Single sign-on (SSO) identifier for federated authentication.' }),
|
291
293
|
tslib_1.__metadata("design:type", String)
|
292
294
|
], User.prototype, "ssoId", void 0);
|
293
295
|
tslib_1.__decorate([
|
@@ -303,7 +305,7 @@ tslib_1.__decorate([
|
|
303
305
|
length: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? undefined : 32,
|
304
306
|
default: UserStatus.INACTIVE
|
305
307
|
}),
|
306
|
-
(0, type_graphql_1.Field)(type => String),
|
308
|
+
(0, type_graphql_1.Field)(type => String, { description: 'Current status of the user account.' }),
|
307
309
|
tslib_1.__metadata("design:type", String)
|
308
310
|
], User.prototype, "status", void 0);
|
309
311
|
tslib_1.__decorate([
|
@@ -312,10 +314,11 @@ tslib_1.__decorate([
|
|
312
314
|
], User.prototype, "failCount", void 0);
|
313
315
|
tslib_1.__decorate([
|
314
316
|
(0, typeorm_1.Column)({ nullable: true }),
|
315
|
-
tslib_1.__metadata("design:type", Date
|
317
|
+
tslib_1.__metadata("design:type", Date // Last time the password was updated
|
318
|
+
)
|
316
319
|
], User.prototype, "passwordUpdatedAt", void 0);
|
317
320
|
tslib_1.__decorate([
|
318
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
321
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Whether the user is the owner of the domain (not persisted in DB).' }),
|
319
322
|
tslib_1.__metadata("design:type", Boolean)
|
320
323
|
], User.prototype, "owner", void 0);
|
321
324
|
tslib_1.__decorate([
|
@@ -324,12 +327,12 @@ tslib_1.__decorate([
|
|
324
327
|
], User.prototype, "credentials", void 0);
|
325
328
|
tslib_1.__decorate([
|
326
329
|
(0, typeorm_1.OneToMany)(() => users_auth_providers_js_1.UsersAuthProviders, usersAuthProviders => usersAuthProviders.user),
|
327
|
-
(0, type_graphql_1.Field)(type => [users_auth_providers_js_1.UsersAuthProviders], { nullable: true }),
|
330
|
+
(0, type_graphql_1.Field)(type => [users_auth_providers_js_1.UsersAuthProviders], { nullable: true, description: 'External authentication providers linked to the user.' }),
|
328
331
|
tslib_1.__metadata("design:type", Array)
|
329
332
|
], User.prototype, "usersAuthProviders", void 0);
|
330
333
|
tslib_1.__decorate([
|
331
334
|
(0, typeorm_1.ManyToOne)(type => User, { nullable: true }),
|
332
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
335
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'User who created this user account.' }),
|
333
336
|
tslib_1.__metadata("design:type", User)
|
334
337
|
], User.prototype, "creator", void 0);
|
335
338
|
tslib_1.__decorate([
|
@@ -338,7 +341,7 @@ tslib_1.__decorate([
|
|
338
341
|
], User.prototype, "creatorId", void 0);
|
339
342
|
tslib_1.__decorate([
|
340
343
|
(0, typeorm_1.ManyToOne)(type => User, { nullable: true }),
|
341
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
344
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'User who last updated this user account.' }),
|
342
345
|
tslib_1.__metadata("design:type", User)
|
343
346
|
], User.prototype, "updater", void 0);
|
344
347
|
tslib_1.__decorate([
|
@@ -347,12 +350,12 @@ tslib_1.__decorate([
|
|
347
350
|
], User.prototype, "updaterId", void 0);
|
348
351
|
tslib_1.__decorate([
|
349
352
|
(0, typeorm_1.CreateDateColumn)(),
|
350
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
353
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Timestamp when the user account was created.' }),
|
351
354
|
tslib_1.__metadata("design:type", Date)
|
352
355
|
], User.prototype, "createdAt", void 0);
|
353
356
|
tslib_1.__decorate([
|
354
357
|
(0, typeorm_1.UpdateDateColumn)(),
|
355
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
358
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Timestamp when the user account was last updated.' }),
|
356
359
|
tslib_1.__metadata("design:type", Date
|
357
360
|
/* signing for jsonwebtoken */
|
358
361
|
)
|
@@ -366,6 +369,6 @@ exports.User = User = User_1 = tslib_1.__decorate([
|
|
366
369
|
unique: true,
|
367
370
|
where: '"username" IS NOT NULL'
|
368
371
|
}),
|
369
|
-
(0, type_graphql_1.ObjectType)()
|
372
|
+
(0, type_graphql_1.ObjectType)({ description: 'Represents a user account in the system, including authentication, roles, and domain associations.' })
|
370
373
|
], User);
|
371
374
|
//# sourceMappingURL=user.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../../server/service/user/user.ts"],"names":[],"mappings":";;;;;AAAA,4DAA2B;AAC3B,wEAA8B;AAC9B,+CAA+D;AAC/D,qDAAqD;AACrD,qCAagB;AAEhB,6CAA4C;AAC5C,iDAA6D;AAE7D,+EAA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IADC,IAAA,oBAAU,EAAC,CAAC,IAAU,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;;uCACxB;AAIjB;IAFC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACf,IAAI;uCAAA;AAIf;IAFC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACf,IAAI;IAEf,8BAA8B;;uCAFf;eAxHJ,IAAI;IAThB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,WAAW,EAAE,CAAC,IAAU,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;QAChD,MAAM,EAAE,IAAI;KACb,CAAC;IACD,IAAA,eAAK,EAAC,WAAW,EAAE,CAAC,IAAU,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;QACnD,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,wBAAwB;KAChC,CAAC;IACD,IAAA,yBAAU,GAAE;GACA,IAAI,CAsUhB","sourcesContent":["import crypto from 'crypto'\nimport jwt from 'jsonwebtoken'\nimport { Directive, Field, ID, ObjectType } from 'type-graphql'\nimport { GraphQLEmailAddress } from 'graphql-scalars'\nimport {\n Column,\n CreateDateColumn,\n Entity,\n ILike,\n Index,\n JoinTable,\n ManyToMany,\n ManyToOne,\n OneToMany,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\n\nimport { config } from '@things-factory/env'\nimport { Domain, getRepository } from '@things-factory/shell'\n\nimport { validatePasswordByRule } from '../../controllers/utils/password-rule.js'\nimport { AuthError } from '../../errors/auth-error.js'\nimport { SECRET } from '../../utils/get-secret.js'\nimport { Role } from '../role/role.js'\nimport { Privilege } from '../privilege/privilege.js'\nimport { WebAuthCredential } from '../web-auth-credential/web-auth-credential.js'\nimport { UsersAuthProviders } from '../users-auth-providers/users-auth-providers.js'\nimport { getDomainsWithPrivilege } from '../../utils/get-user-domains.js'\n\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\nconst sessionExpirySeconds = Number(config.get('session/expirySeconds')) || '7d'\n\nexport enum UserStatus {\n INACTIVE = 'inactive',\n ACTIVATED = 'activated',\n DELETED = 'deleted',\n LOCKED = 'locked',\n BANNED = 'banned',\n PWD_RESET_REQUIRED = 'password_reset_required'\n}\n\n@Entity()\n@Index('ix_user_0', (user: User) => [user.email], {\n unique: true\n})\n@Index('ix_user_1', (user: User) => [user.username], {\n unique: true,\n where: '\"username\" IS NOT NULL'\n})\n@ObjectType()\nexport class User {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n username: string\n\n @Column()\n @Field({ nullable: true })\n name: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n description: string\n\n @ManyToMany(type => Domain)\n @JoinTable({ name: 'users_domains' })\n @Field(type => [Domain])\n domains?: Domain[]\n\n @Column()\n @Field(type => GraphQLEmailAddress)\n email: string\n\n @Directive('@privilege(category: \"security\", privilege: \"query\", domainOwnerGranted: true)')\n @Column({\n nullable: true,\n type:\n DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'longtext'\n : DATABASE_TYPE == 'oracle'\n ? 'clob'\n : DATABASE_TYPE == 'mssql'\n ? 'nvarchar'\n : 'varchar',\n length: DATABASE_TYPE == 'mssql' ? 'MAX' : undefined\n })\n password: string\n\n @ManyToMany(type => Role, role => role.users)\n @JoinTable({ name: 'users_roles' })\n @Field(type => [Role])\n roles?: Role[]\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n userType: string // default: 'user', enum: 'user', 'application', 'appliance'\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n reference: string\n\n @Directive('@privilege(category: \"security\", privilege: \"query\", domainOwnerGranted: true)')\n @Column({ nullable: true })\n salt: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n locale: string\n\n @Directive('@privilege(category: \"security\", privilege: \"query\", domainOwnerGranted: true)')\n @Column({ nullable: true })\n @Field({ nullable: true })\n ssoId: string\n\n @Column({\n type:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'enum'\n : DATABASE_TYPE == 'oracle'\n ? 'varchar2'\n : DATABASE_TYPE == 'mssql'\n ? 'nvarchar'\n : 'varchar',\n enum:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? UserStatus : undefined,\n length: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? undefined : 32,\n default: UserStatus.INACTIVE\n })\n @Field(type => String)\n status: UserStatus\n\n @Column({ type: 'smallint', default: 0 })\n failCount: number\n\n @Column({ nullable: true })\n passwordUpdatedAt: Date\n\n @Field({ nullable: true })\n owner: boolean /* should not be a column */\n\n @OneToMany(() => WebAuthCredential, credential => credential.user)\n credentials: WebAuthCredential[]\n\n @OneToMany(() => UsersAuthProviders, usersAuthProviders => usersAuthProviders.user)\n @Field(type => [UsersAuthProviders], { nullable: true })\n usersAuthProviders: UsersAuthProviders[]\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n creator: User\n\n @RelationId((user: User) => user.creator)\n creatorId: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n updater: User\n\n @RelationId((user: User) => user.updater)\n updaterId: string\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt: Date\n\n /* signing for jsonwebtoken */\n async sign(options?) {\n var { expiresIn = sessionExpirySeconds } = options || {}\n\n var user = {\n username: this.username || this.email\n }\n\n return await jwt.sign(user, SECRET, {\n expiresIn,\n issuer: 'hatiolab.com',\n subject: 'user'\n })\n }\n\n /* validate password through password rule */\n static validatePasswordByRule(password, lng) {\n validatePasswordByRule(password, lng)\n }\n\n /* generate salt */\n static generateSalt() {\n return crypto.randomBytes(16).toString('hex')\n }\n\n /* encode password */\n static encode(password: string, salt) {\n return crypto\n .createHmac('sha256', salt || SECRET)\n .update(password)\n .digest('base64')\n }\n\n /* verify password */\n static verify(hashed, password, salt) {\n return (\n hashed ==\n crypto\n .createHmac('sha256', salt || SECRET)\n .update(password)\n .digest('base64') ||\n hashed ==\n crypto\n .createHmac('sha1', salt || SECRET)\n .update(password)\n .digest('base64')\n )\n }\n\n static async checkAuthWithEmail(decoded) {\n if (!decoded?.email) {\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_NOT_FOUND\n })\n }\n\n const repository = getRepository(User)\n var user = await repository.findOne({\n where: { email: decoded.email },\n relations: ['domains'],\n cache: true\n })\n\n if (!user)\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_NOT_FOUND\n })\n else {\n switch (user.status) {\n case UserStatus.INACTIVE:\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_NOT_ACTIVATED,\n detail: {\n email: user.email\n }\n })\n case UserStatus.LOCKED:\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_LOCKED,\n detail: {\n email: user.email\n }\n })\n case UserStatus.DELETED:\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_DELETED\n })\n }\n\n return user\n }\n }\n\n static async checkAuth(decoded) {\n // id 는 하위호환성을 위해 단기적으로 유지함\n const { id, username } = decoded || {}\n\n if (!id && !username) {\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_NOT_FOUND\n })\n }\n\n const repository = getRepository(User)\n if (id) {\n var user = await repository.findOne({\n where: { id },\n relations: ['domains', 'credentials'],\n cache: true\n })\n } else {\n var user = await repository.findOne({\n where: { username },\n relations: ['domains', 'credentials'],\n cache: true\n })\n\n if (!user && /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(username)) {\n user = await repository.findOne({\n where: {\n email: ILike(username)\n },\n relations: ['domains', 'credentials'],\n cache: true\n })\n }\n }\n\n if (!user)\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_NOT_FOUND\n })\n else {\n switch (user.status) {\n case UserStatus.INACTIVE:\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_NOT_ACTIVATED,\n detail: {\n email: user.email\n }\n })\n case UserStatus.LOCKED:\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_LOCKED,\n detail: {\n email: user.email\n }\n })\n case UserStatus.DELETED:\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_DELETED\n })\n }\n\n const { defaultPassword } = config.get('password')\n\n if (defaultPassword && user.password === this.encode(defaultPassword, user.salt)) {\n user.status = UserStatus.PWD_RESET_REQUIRED\n }\n\n return user\n }\n }\n\n static async hasPrivilege(privilege: string, category: string, domain: Domain, user: User): Promise<boolean> {\n const result = await getRepository(Privilege)\n .createQueryBuilder('privilege')\n .innerJoin('privilege.roles', 'role')\n .innerJoin('role.users', 'user')\n .where('privilege.category = :category', { category })\n .andWhere('privilege.name = :privilege', { privilege })\n .andWhere('user.id = :userId', { userId: user.id })\n .andWhere('role.domain.id = :domainId', { domainId: domain.id })\n .getCount()\n\n return result > 0\n }\n\n static async getPrivilegesByDomain(user: User, domain: Domain): Promise<{ category: string; privilege: string }[]> {\n const result = await getRepository(User)\n .createQueryBuilder('user')\n .leftJoinAndSelect('user.roles', 'role')\n .leftJoinAndSelect('role.privileges', 'privilege')\n .select(['privilege.name AS privilege', 'privilege.category AS category'])\n .where('user.id = :userId', { userId: user.id })\n .andWhere('role.domain.id = :domainId', { domainId: domain.id })\n .orderBy('privilege.category')\n .addOrderBy('privilege.name')\n .getRawMany()\n\n const distinct = result.reduce((acc, current) => {\n const last = acc[acc.length - 1]\n if (!last || last.privilege !== current.privilege || last.category !== current.category) {\n acc.push(current)\n }\n return acc\n }, [])\n\n return distinct\n }\n\n static async getDomainsWithPrivilege(privilege: string, category: string, user: User) {\n return getDomainsWithPrivilege(user, privilege, category)\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../../server/service/user/user.ts"],"names":[],"mappings":";AAAA,iGAAiG;AACjG,mGAAmG;;;;;AAEnG,4DAA2B;AAC3B,wEAA8B;AAC9B,+CAA+D;AAC/D,qDAAqD;AACrD,qCAagB;AAEhB,6CAA4C;AAC5C,iDAA6D;AAE7D,+EAAiF;AACjF,8DAAsD;AACtD,6DAAkD;AAClD,6CAAsC;AACtC,4DAAqD;AACrD,0FAAiF;AACjF,6FAAoF;AACpF,yEAAyE;AAEzE,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAA;AAEpC,MAAM,oBAAoB,GAAG,MAAM,CAAC,YAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC,IAAI,IAAI,CAAA;AAEhF,IAAY,UAOX;AAPD,WAAY,UAAU;IACpB,mCAAqB,CAAA;IACrB,qCAAuB,CAAA;IACvB,iCAAmB,CAAA;IACnB,+BAAiB,CAAA;IACjB,+BAAiB,CAAA;IACjB,4DAA8C,CAAA,CAAC,wDAAwD;AACzG,CAAC,EAPW,UAAU,0BAAV,UAAU,QAOrB;AAWM,IAAM,IAAI,YAAV,MAAM,IAAI;IA0Hf,8BAA8B;IAC9B,KAAK,CAAC,IAAI,CAAC,OAAQ;QACjB,IAAI,EAAE,SAAS,GAAG,oBAAoB,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;QAExD,IAAI,IAAI,GAAG;YACT,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK;SACtC,CAAA;QAED,OAAO,MAAM,sBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,sBAAM,EAAE;YAClC,SAAS;YACT,MAAM,EAAE,cAAc;YACtB,OA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AAA,eAAK,EAAC,WAAW,EAAE,CAAC,IAAU,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;QAChD,MAAM,EAAE,IAAI;KACb,CAAC;IACD,IAAA,eAAK,EAAC,WAAW,EAAE,CAAC,IAAU,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;QACnD,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,wBAAwB;KAChC,CAAC;IACD,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,oGAAoG,EAAE,CAAC;GACrH,IAAI,CAsUhB","sourcesContent":["// This file defines the User entity and its GraphQL schema for authentication and authorization.\n// It includes user fields, status enum, and utility methods for password and privilege management.\n\nimport crypto from 'crypto'\nimport jwt from 'jsonwebtoken'\nimport { Directive, Field, ID, ObjectType } from 'type-graphql'\nimport { GraphQLEmailAddress } from 'graphql-scalars'\nimport {\n Column,\n CreateDateColumn,\n Entity,\n ILike,\n Index,\n JoinTable,\n ManyToMany,\n ManyToOne,\n OneToMany,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\n\nimport { config } from '@things-factory/env'\nimport { Domain, getRepository } from '@things-factory/shell'\n\nimport { validatePasswordByRule } from '../../controllers/utils/password-rule.js'\nimport { AuthError } from '../../errors/auth-error.js'\nimport { SECRET } from '../../utils/get-secret.js'\nimport { Role } from '../role/role.js'\nimport { Privilege } from '../privilege/privilege.js'\nimport { WebAuthCredential } from '../web-auth-credential/web-auth-credential.js'\nimport { UsersAuthProviders } from '../users-auth-providers/users-auth-providers.js'\nimport { getDomainsWithPrivilege } from '../../utils/get-user-domains.js'\n\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\nconst sessionExpirySeconds = Number(config.get('session/expirySeconds')) || '7d'\n\nexport enum UserStatus {\n INACTIVE = 'inactive', // The user account is inactive and cannot log in.\n ACTIVATED = 'activated', // The user account is active and can log in.\n DELETED = 'deleted', // The user account has been deleted.\n LOCKED = 'locked', // The user account is locked due to security reasons.\n BANNED = 'banned', // The user account is banned from the system.\n PWD_RESET_REQUIRED = 'password_reset_required' // The user must reset their password before logging in.\n}\n\n@Entity()\n@Index('ix_user_0', (user: User) => [user.email], {\n unique: true\n})\n@Index('ix_user_1', (user: User) => [user.username], {\n unique: true,\n where: '\"username\" IS NOT NULL'\n})\n@ObjectType({ description: 'Represents a user account in the system, including authentication, roles, and domain associations.' })\nexport class User {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier for the user.' })\n readonly id: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Unique username for the user.' })\n username: string\n\n @Column()\n @Field({ nullable: true, description: 'Full name of the user.' })\n name: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Optional description or note about the user.' })\n description: string\n\n @ManyToMany(type => Domain)\n @JoinTable({ name: 'users_domains' })\n @Field(type => [Domain], { description: 'Domains (organizations, companies, etc.) the user belongs to.' })\n domains?: Domain[]\n\n @Column()\n @Field(type => GraphQLEmailAddress, { description: 'Email address of the user.' })\n email: string\n\n @Directive('@privilege(category: \"security\", privilege: \"query\", domainOwnerGranted: true)')\n @Column({\n nullable: true,\n type:\n DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'longtext'\n : DATABASE_TYPE == 'oracle'\n ? 'clob'\n : DATABASE_TYPE == 'mssql'\n ? 'nvarchar'\n : 'varchar',\n length: DATABASE_TYPE == 'mssql' ? 'MAX' : undefined\n })\n password: string // Hashed password for authentication\n\n @ManyToMany(type => Role, role => role.users)\n @JoinTable({ name: 'users_roles' })\n @Field(type => [Role], { description: 'Roles assigned to the user.' })\n roles?: Role[]\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Type or category of the user (e.g., user, application, appliance).' })\n userType: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Reference information for the user (external system, etc.).' })\n reference: string\n\n @Directive('@privilege(category: \"security\", privilege: \"query\", domainOwnerGranted: true)')\n @Column({ nullable: true })\n salt: string // Salt used for password hashing\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Locale or language preference for the user.' })\n locale: string\n\n @Directive('@privilege(category: \"security\", privilege: \"query\", domainOwnerGranted: true)')\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Single sign-on (SSO) identifier for federated authentication.' })\n ssoId: string\n\n @Column({\n type:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'enum'\n : DATABASE_TYPE == 'oracle'\n ? 'varchar2'\n : DATABASE_TYPE == 'mssql'\n ? 'nvarchar'\n : 'varchar',\n enum:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? UserStatus : undefined,\n length: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? undefined : 32,\n default: UserStatus.INACTIVE\n })\n @Field(type => String, { description: 'Current status of the user account.' })\n status: UserStatus\n\n @Column({ type: 'smallint', default: 0 })\n failCount: number // Number of failed login attempts\n\n @Column({ nullable: true })\n passwordUpdatedAt: Date // Last time the password was updated\n\n @Field({ nullable: true, description: 'Whether the user is the owner of the domain (not persisted in DB).' })\n owner: boolean /* should not be a column */\n\n @OneToMany(() => WebAuthCredential, credential => credential.user)\n credentials: WebAuthCredential[]\n\n @OneToMany(() => UsersAuthProviders, usersAuthProviders => usersAuthProviders.user)\n @Field(type => [UsersAuthProviders], { nullable: true, description: 'External authentication providers linked to the user.' })\n usersAuthProviders: UsersAuthProviders[]\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true, description: 'User who created this user account.' })\n creator: User\n\n @RelationId((user: User) => user.creator)\n creatorId: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true, description: 'User who last updated this user account.' })\n updater: User\n\n @RelationId((user: User) => user.updater)\n updaterId: string\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'Timestamp when the user account was created.' })\n createdAt: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'Timestamp when the user account was last updated.' })\n updatedAt: Date\n\n /* signing for jsonwebtoken */\n async sign(options?) {\n var { expiresIn = sessionExpirySeconds } = options || {}\n\n var user = {\n username: this.username || this.email\n }\n\n return await jwt.sign(user, SECRET, {\n expiresIn,\n issuer: 'hatiolab.com',\n subject: 'user'\n })\n }\n\n /* validate password through password rule */\n static validatePasswordByRule(password, lng) {\n validatePasswordByRule(password, lng)\n }\n\n /* generate salt */\n static generateSalt() {\n return crypto.randomBytes(16).toString('hex')\n }\n\n /* encode password */\n static encode(password: string, salt) {\n return crypto\n .createHmac('sha256', salt || SECRET)\n .update(password)\n .digest('base64')\n }\n\n /* verify password */\n static verify(hashed, password, salt) {\n return (\n hashed ==\n crypto\n .createHmac('sha256', salt || SECRET)\n .update(password)\n .digest('base64') ||\n hashed ==\n crypto\n .createHmac('sha1', salt || SECRET)\n .update(password)\n .digest('base64')\n )\n }\n\n static async checkAuthWithEmail(decoded) {\n if (!decoded?.email) {\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_NOT_FOUND\n })\n }\n\n const repository = getRepository(User)\n var user = await repository.findOne({\n where: { email: decoded.email },\n relations: ['domains'],\n cache: true\n })\n\n if (!user)\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_NOT_FOUND\n })\n else {\n switch (user.status) {\n case UserStatus.INACTIVE:\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_NOT_ACTIVATED,\n detail: {\n email: user.email\n }\n })\n case UserStatus.LOCKED:\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_LOCKED,\n detail: {\n email: user.email\n }\n })\n case UserStatus.DELETED:\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_DELETED\n })\n }\n\n return user\n }\n }\n\n static async checkAuth(decoded) {\n // id 는 하위호환성을 위해 단기적으로 유지함\n const { id, username } = decoded || {}\n\n if (!id && !username) {\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_NOT_FOUND\n })\n }\n\n const repository = getRepository(User)\n if (id) {\n var user = await repository.findOne({\n where: { id },\n relations: ['domains', 'credentials'],\n cache: true\n })\n } else {\n var user = await repository.findOne({\n where: { username },\n relations: ['domains', 'credentials'],\n cache: true\n })\n\n if (!user && /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(username)) {\n user = await repository.findOne({\n where: {\n email: ILike(username)\n },\n relations: ['domains', 'credentials'],\n cache: true\n })\n }\n }\n\n if (!user)\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_NOT_FOUND\n })\n else {\n switch (user.status) {\n case UserStatus.INACTIVE:\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_NOT_ACTIVATED,\n detail: {\n email: user.email\n }\n })\n case UserStatus.LOCKED:\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_LOCKED,\n detail: {\n email: user.email\n }\n })\n case UserStatus.DELETED:\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_DELETED\n })\n }\n\n const { defaultPassword } = config.get('password')\n\n if (defaultPassword && user.password === this.encode(defaultPassword, user.salt)) {\n user.status = UserStatus.PWD_RESET_REQUIRED\n }\n\n return user\n }\n }\n\n static async hasPrivilege(privilege: string, category: string, domain: Domain, user: User): Promise<boolean> {\n const result = await getRepository(Privilege)\n .createQueryBuilder('privilege')\n .innerJoin('privilege.roles', 'role')\n .innerJoin('role.users', 'user')\n .where('privilege.category = :category', { category })\n .andWhere('privilege.name = :privilege', { privilege })\n .andWhere('user.id = :userId', { userId: user.id })\n .andWhere('role.domain.id = :domainId', { domainId: domain.id })\n .getCount()\n\n return result > 0\n }\n\n static async getPrivilegesByDomain(user: User, domain: Domain): Promise<{ category: string; privilege: string }[]> {\n const result = await getRepository(User)\n .createQueryBuilder('user')\n .leftJoinAndSelect('user.roles', 'role')\n .leftJoinAndSelect('role.privileges', 'privilege')\n .select(['privilege.name AS privilege', 'privilege.category AS category'])\n .where('user.id = :userId', { userId: user.id })\n .andWhere('role.domain.id = :domainId', { domainId: domain.id })\n .orderBy('privilege.category')\n .addOrderBy('privilege.name')\n .getRawMany()\n\n const distinct = result.reduce((acc, current) => {\n const last = acc[acc.length - 1]\n if (!last || last.privilege !== current.privilege || last.category !== current.category) {\n acc.push(current)\n }\n return acc\n }, [])\n\n return distinct\n }\n\n static async getDomainsWithPrivilege(privilege: string, category: string, user: User) {\n return getDomainsWithPrivilege(user, privilege, category)\n }\n}\n"]}
|
@@ -12,12 +12,12 @@ let UsersAuthProviders = class UsersAuthProviders {
|
|
12
12
|
exports.UsersAuthProviders = UsersAuthProviders;
|
13
13
|
tslib_1.__decorate([
|
14
14
|
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
15
|
-
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
15
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'Unique identifier for the user-provider link.' }),
|
16
16
|
tslib_1.__metadata("design:type", String)
|
17
17
|
], UsersAuthProviders.prototype, "id", void 0);
|
18
18
|
tslib_1.__decorate([
|
19
19
|
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
20
|
-
(0, type_graphql_1.Field)(type => shell_1.Domain),
|
20
|
+
(0, type_graphql_1.Field)(type => shell_1.Domain, { description: 'The domain to which this link belongs.' }),
|
21
21
|
tslib_1.__metadata("design:type", shell_1.Domain)
|
22
22
|
], UsersAuthProviders.prototype, "domain", void 0);
|
23
23
|
tslib_1.__decorate([
|
@@ -28,7 +28,7 @@ tslib_1.__decorate([
|
|
28
28
|
(0, typeorm_1.ManyToOne)(() => user_js_1.User, user => user.usersAuthProviders, {
|
29
29
|
onDelete: 'CASCADE'
|
30
30
|
}),
|
31
|
-
(0, type_graphql_1.Field)(type => user_js_1.User, { nullable: true }),
|
31
|
+
(0, type_graphql_1.Field)(type => user_js_1.User, { nullable: true, description: 'The user associated with this link.' }),
|
32
32
|
tslib_1.__metadata("design:type", user_js_1.User)
|
33
33
|
], UsersAuthProviders.prototype, "user", void 0);
|
34
34
|
tslib_1.__decorate([
|
@@ -39,7 +39,10 @@ tslib_1.__decorate([
|
|
39
39
|
(0, typeorm_1.ManyToOne)(() => auth_provider_js_1.AuthProvider, authProvider => authProvider.usersAuthProviders, {
|
40
40
|
onDelete: 'CASCADE'
|
41
41
|
}),
|
42
|
-
(0, type_graphql_1.Field)(type => auth_provider_js_1.AuthProvider, {
|
42
|
+
(0, type_graphql_1.Field)(type => auth_provider_js_1.AuthProvider, {
|
43
|
+
nullable: true,
|
44
|
+
description: 'The authentication provider associated with this link.'
|
45
|
+
}),
|
43
46
|
tslib_1.__metadata("design:type", auth_provider_js_1.AuthProvider)
|
44
47
|
], UsersAuthProviders.prototype, "authProvider", void 0);
|
45
48
|
tslib_1.__decorate([
|
@@ -48,17 +51,17 @@ tslib_1.__decorate([
|
|
48
51
|
], UsersAuthProviders.prototype, "authProviderId", void 0);
|
49
52
|
tslib_1.__decorate([
|
50
53
|
(0, typeorm_1.Column)(),
|
51
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
54
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The unique identifier for the user from the external provider (SSO ID).' }),
|
52
55
|
tslib_1.__metadata("design:type", String)
|
53
56
|
], UsersAuthProviders.prototype, "ssoId", void 0);
|
54
57
|
tslib_1.__decorate([
|
55
58
|
(0, typeorm_1.CreateDateColumn)(),
|
56
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
59
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The timestamp when this link was created.' }),
|
57
60
|
tslib_1.__metadata("design:type", Date)
|
58
61
|
], UsersAuthProviders.prototype, "createdAt", void 0);
|
59
62
|
tslib_1.__decorate([
|
60
63
|
(0, typeorm_1.UpdateDateColumn)(),
|
61
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
64
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The timestamp when this link was last updated.' }),
|
62
65
|
tslib_1.__metadata("design:type", Date)
|
63
66
|
], UsersAuthProviders.prototype, "updatedAt", void 0);
|
64
67
|
exports.UsersAuthProviders = UsersAuthProviders = tslib_1.__decorate([
|
@@ -68,6 +71,6 @@ exports.UsersAuthProviders = UsersAuthProviders = tslib_1.__decorate([
|
|
68
71
|
usersAuthProviders.user,
|
69
72
|
usersAuthProviders.authProvider
|
70
73
|
], { unique: true }),
|
71
|
-
(0, type_graphql_1.ObjectType)({ description: '
|
74
|
+
(0, type_graphql_1.ObjectType)({ description: 'Represents the link between a user and an external authentication provider.' })
|
72
75
|
], UsersAuthProviders);
|
73
76
|
//# sourceMappingURL=users-auth-providers.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"users-auth-providers.js","sourceRoot":"","sources":["../../../server/service/users-auth-providers/users-auth-providers.ts"],"names":[],"mappings":";;;;AAAA,qCAWgB;AAChB,+CAA2E;AAE3E,iDAA8C;AAC9C,6CAAsC;AACtC,wEAAgE;AAazD,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;
|
1
|
+
{"version":3,"file":"users-auth-providers.js","sourceRoot":"","sources":["../../../server/service/users-auth-providers/users-auth-providers.ts"],"names":[],"mappings":";;;;AAAA,qCAWgB;AAChB,+CAA2E;AAE3E,iDAA8C;AAC9C,6CAAsC;AACtC,wEAAgE;AAazD,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;CA4C9B,CAAA;AA5CY,gDAAkB;AAGpB;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,WAAW,EAAE,+CAA+C,EAAE,CAAC;;8CACjE;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,WAAW,EAA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IAClB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,gDAAgD,EAAE,CAAC;sCAC9E,IAAI;qDAAA;6BA3CJ,kBAAkB;IAX9B,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EACJ,2BAA2B,EAC3B,CAAC,kBAAsC,EAAE,EAAE,CAAC;QAC1C,kBAAkB,CAAC,MAAM;QACzB,kBAAkB,CAAC,IAAI;QACvB,kBAAkB,CAAC,YAAY;KAChC,EACD,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,6EAA6E,EAAE,CAAC;GAC9F,kBAAkB,CA4C9B","sourcesContent":["import {\n CreateDateColumn,\n UpdateDateColumn,\n DeleteDateColumn,\n Entity,\n Index,\n Column,\n RelationId,\n ManyToOne,\n PrimaryGeneratedColumn,\n VersionColumn\n} from 'typeorm'\nimport { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'\n\nimport { Domain } from '@things-factory/shell'\nimport { User } from '../user/user.js'\nimport { AuthProvider } from '../auth-provider/auth-provider.js'\n\n@Entity()\n@Index(\n 'ix_users_auth_providers_0',\n (usersAuthProviders: UsersAuthProviders) => [\n usersAuthProviders.domain,\n usersAuthProviders.user,\n usersAuthProviders.authProvider\n ],\n { unique: true }\n)\n@ObjectType({ description: 'Represents the link between a user and an external authentication provider.' })\nexport class UsersAuthProviders {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier for the user-provider link.' })\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { description: 'The domain to which this link belongs.' })\n domain?: Domain\n\n @RelationId((usersAuthProviders: UsersAuthProviders) => usersAuthProviders.domain)\n domainId?: string\n\n @ManyToOne(() => User, user => user.usersAuthProviders, {\n onDelete: 'CASCADE'\n })\n @Field(type => User, { nullable: true, description: 'The user associated with this link.' })\n user: User\n\n @RelationId((usersAuthProviders: UsersAuthProviders) => usersAuthProviders.user)\n userId?: string\n\n @ManyToOne(() => AuthProvider, authProvider => authProvider.usersAuthProviders, {\n onDelete: 'CASCADE'\n })\n @Field(type => AuthProvider, {\n nullable: true,\n description: 'The authentication provider associated with this link.'\n })\n authProvider: AuthProvider\n\n @RelationId((usersAuthProviders: UsersAuthProviders) => usersAuthProviders.authProvider)\n authProviderId?: string\n\n @Column()\n @Field({ nullable: true, description: 'The unique identifier for the user from the external provider (SSO ID).' })\n ssoId: string\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'The timestamp when this link was created.' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'The timestamp when this link was last updated.' })\n updatedAt: Date\n}\n"]}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
export declare enum VerificationTokenType {
|
2
|
-
ACTIVATION = "activation"
|
3
|
-
PASSWORD_RESET = "password-reset"
|
4
|
-
UNLOCK = "unlock"
|
2
|
+
ACTIVATION = "activation",// Token to activate a new user account.
|
3
|
+
PASSWORD_RESET = "password-reset",// Token to reset a user's password.
|
4
|
+
UNLOCK = "unlock",// Token to unlock a locked user account.
|
5
5
|
REQUEST_ACCESS_TOKEN = "access-token"
|
6
6
|
}
|
7
7
|
export declare class VerificationToken {
|
@@ -12,21 +12,21 @@ var VerificationTokenType;
|
|
12
12
|
VerificationTokenType["ACTIVATION"] = "activation";
|
13
13
|
VerificationTokenType["PASSWORD_RESET"] = "password-reset";
|
14
14
|
VerificationTokenType["UNLOCK"] = "unlock";
|
15
|
-
VerificationTokenType["REQUEST_ACCESS_TOKEN"] = "access-token";
|
15
|
+
VerificationTokenType["REQUEST_ACCESS_TOKEN"] = "access-token"; // Token to request a new access token.
|
16
16
|
})(VerificationTokenType || (exports.VerificationTokenType = VerificationTokenType = {}));
|
17
17
|
let VerificationToken = class VerificationToken {
|
18
18
|
};
|
19
19
|
exports.VerificationToken = VerificationToken;
|
20
20
|
tslib_1.__decorate([
|
21
21
|
(0, typeorm_1.PrimaryColumn)(),
|
22
|
-
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
22
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'The ID of the user to whom this token belongs.' }),
|
23
23
|
tslib_1.__metadata("design:type", String)
|
24
24
|
], VerificationToken.prototype, "userId", void 0);
|
25
25
|
tslib_1.__decorate([
|
26
26
|
(0, typeorm_1.Column)({
|
27
27
|
nullable: false
|
28
28
|
}),
|
29
|
-
(0, type_graphql_1.Field)(),
|
29
|
+
(0, type_graphql_1.Field)({ description: 'The verification token string.' }),
|
30
30
|
tslib_1.__metadata("design:type", String)
|
31
31
|
], VerificationToken.prototype, "token", void 0);
|
32
32
|
tslib_1.__decorate([
|
@@ -45,28 +45,28 @@ tslib_1.__decorate([
|
|
45
45
|
length: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? undefined : 32,
|
46
46
|
default: VerificationTokenType.ACTIVATION
|
47
47
|
}),
|
48
|
-
(0, type_graphql_1.Field)(),
|
48
|
+
(0, type_graphql_1.Field)({ description: 'The type of action this token is for.' }),
|
49
49
|
tslib_1.__metadata("design:type", String)
|
50
50
|
], VerificationToken.prototype, "type", void 0);
|
51
51
|
tslib_1.__decorate([
|
52
52
|
(0, typeorm_1.Column)({
|
53
53
|
nullable: true
|
54
54
|
}),
|
55
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
55
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Supplementary data associated with the token.' }),
|
56
56
|
tslib_1.__metadata("design:type", String)
|
57
57
|
], VerificationToken.prototype, "suppliment", void 0);
|
58
58
|
tslib_1.__decorate([
|
59
59
|
(0, typeorm_1.CreateDateColumn)(),
|
60
|
-
(0, type_graphql_1.Field)(),
|
60
|
+
(0, type_graphql_1.Field)({ description: 'The timestamp when the token was created.' }),
|
61
61
|
tslib_1.__metadata("design:type", Date)
|
62
62
|
], VerificationToken.prototype, "createdAt", void 0);
|
63
63
|
tslib_1.__decorate([
|
64
64
|
(0, typeorm_1.UpdateDateColumn)(),
|
65
|
-
(0, type_graphql_1.Field)(),
|
65
|
+
(0, type_graphql_1.Field)({ description: 'The timestamp when the token was last updated.' }),
|
66
66
|
tslib_1.__metadata("design:type", Date)
|
67
67
|
], VerificationToken.prototype, "updatedAt", void 0);
|
68
68
|
exports.VerificationToken = VerificationToken = tslib_1.__decorate([
|
69
69
|
(0, typeorm_1.Entity)(),
|
70
|
-
(0, type_graphql_1.ObjectType)()
|
70
|
+
(0, type_graphql_1.ObjectType)({ description: 'A token used for verifying user actions like account activation or password reset.' })
|
71
71
|
], VerificationToken);
|
72
72
|
//# sourceMappingURL=verification-token.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"verification-token.js","sourceRoot":"","sources":["../../../server/service/verification-token/verification-token.ts"],"names":[],"mappings":";;;;AAAA,qCAA2F;AAC3F,6CAA4C;AAC5C,+CAAoD;AACpD,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAA;AAEpC,IAAY,qBAKX;AALD,WAAY,qBAAqB;IAC/B,kDAAyB,CAAA;IACzB,0DAAiC,CAAA;IACjC,0CAAiB,CAAA;IACjB,8DAAqC,CAAA;
|
1
|
+
{"version":3,"file":"verification-token.js","sourceRoot":"","sources":["../../../server/service/verification-token/verification-token.ts"],"names":[],"mappings":";;;;AAAA,qCAA2F;AAC3F,6CAA4C;AAC5C,+CAAoD;AACpD,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAA;AAEpC,IAAY,qBAKX;AALD,WAAY,qBAAqB;IAC/B,kDAAyB,CAAA;IACzB,0DAAiC,CAAA;IACjC,0CAAiB,CAAA;IACjB,8DAAqC,CAAA,CAAC,uCAAuC;AAC/E,C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AA+C,EAAE,CAAC;;qDACtE;AAIlB;IAFC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,2CAA2C,EAAE,CAAC;sCACzD,IAAI;oDAAA;AAIf;IAFC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,gDAAgD,EAAE,CAAC;sCAC9D,IAAI;oDAAA;4BA3CJ,iBAAiB;IAF7B,IAAA,gBAAM,GAAE;IACR,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,oFAAoF,EAAE,CAAC;GACrG,iBAAiB,CA4C7B","sourcesContent":["import { Column, CreateDateColumn, Entity, PrimaryColumn, UpdateDateColumn } from 'typeorm'\nimport { config } from '@things-factory/env'\nimport { ObjectType, Field, ID } from 'type-graphql'\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\nexport enum VerificationTokenType {\n ACTIVATION = 'activation', // Token to activate a new user account.\n PASSWORD_RESET = 'password-reset', // Token to reset a user's password.\n UNLOCK = 'unlock', // Token to unlock a locked user account.\n REQUEST_ACCESS_TOKEN = 'access-token' // Token to request a new access token.\n}\n\n@Entity()\n@ObjectType({ description: 'A token used for verifying user actions like account activation or password reset.' })\nexport class VerificationToken {\n @PrimaryColumn()\n @Field(type => ID, { description: 'The ID of the user to whom this token belongs.' })\n userId: string\n\n @Column({\n nullable: false\n })\n @Field({ description: 'The verification token string.' })\n token: string\n\n @Column({\n nullable: false,\n type:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'enum'\n : DATABASE_TYPE == 'oracle'\n ? 'varchar2'\n : DATABASE_TYPE == 'mssql'\n ? 'nvarchar'\n : 'varchar',\n enum:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? VerificationTokenType\n : undefined,\n length: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? undefined : 32,\n default: VerificationTokenType.ACTIVATION\n })\n @Field({ description: 'The type of action this token is for.' })\n type: VerificationTokenType\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true, description: 'Supplementary data associated with the token.' })\n suppliment: string\n\n @CreateDateColumn()\n @Field({ description: 'The timestamp when the token was created.' })\n createdAt: Date\n\n @UpdateDateColumn()\n @Field({ description: 'The timestamp when the token was last updated.' })\n updatedAt: Date\n}\n"]}
|
@@ -10,12 +10,12 @@ let WebAuthCredential = class WebAuthCredential {
|
|
10
10
|
exports.WebAuthCredential = WebAuthCredential;
|
11
11
|
tslib_1.__decorate([
|
12
12
|
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
13
|
-
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
13
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'Unique identifier for the credential.' }),
|
14
14
|
tslib_1.__metadata("design:type", String)
|
15
15
|
], WebAuthCredential.prototype, "id", void 0);
|
16
16
|
tslib_1.__decorate([
|
17
17
|
(0, typeorm_1.ManyToOne)(type => user_js_1.User, { nullable: true }),
|
18
|
-
(0, type_graphql_1.Field)(type => user_js_1.User, { nullable: true }),
|
18
|
+
(0, type_graphql_1.Field)(type => user_js_1.User, { nullable: true, description: 'The user associated with this credential.' }),
|
19
19
|
tslib_1.__metadata("design:type", user_js_1.User)
|
20
20
|
], WebAuthCredential.prototype, "user", void 0);
|
21
21
|
tslib_1.__decorate([
|
@@ -24,32 +24,32 @@ tslib_1.__decorate([
|
|
24
24
|
], WebAuthCredential.prototype, "userId", void 0);
|
25
25
|
tslib_1.__decorate([
|
26
26
|
(0, typeorm_1.Column)(),
|
27
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
27
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The unique ID for this credential, provided by the authenticator.' }),
|
28
28
|
tslib_1.__metadata("design:type", String)
|
29
29
|
], WebAuthCredential.prototype, "credentialId", void 0);
|
30
30
|
tslib_1.__decorate([
|
31
31
|
(0, typeorm_1.Column)(),
|
32
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
32
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The public key of the credential.' }),
|
33
33
|
tslib_1.__metadata("design:type", String)
|
34
34
|
], WebAuthCredential.prototype, "publicKey", void 0);
|
35
35
|
tslib_1.__decorate([
|
36
36
|
(0, typeorm_1.Column)(),
|
37
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
37
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The signature counter, used to prevent replay attacks.' }),
|
38
38
|
tslib_1.__metadata("design:type", Number)
|
39
39
|
], WebAuthCredential.prototype, "counter", void 0);
|
40
40
|
tslib_1.__decorate([
|
41
41
|
(0, typeorm_1.CreateDateColumn)(),
|
42
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
42
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The timestamp when the credential was created.' }),
|
43
43
|
tslib_1.__metadata("design:type", Date)
|
44
44
|
], WebAuthCredential.prototype, "createdAt", void 0);
|
45
45
|
tslib_1.__decorate([
|
46
46
|
(0, typeorm_1.UpdateDateColumn)(),
|
47
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
47
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The timestamp when the credential was last updated.' }),
|
48
48
|
tslib_1.__metadata("design:type", Date)
|
49
49
|
], WebAuthCredential.prototype, "updatedAt", void 0);
|
50
50
|
tslib_1.__decorate([
|
51
51
|
(0, typeorm_1.ManyToOne)(type => user_js_1.User, { nullable: true }),
|
52
|
-
(0, type_graphql_1.Field)(type => user_js_1.User, { nullable: true }),
|
52
|
+
(0, type_graphql_1.Field)(type => user_js_1.User, { nullable: true, description: 'The user who created the credential.' }),
|
53
53
|
tslib_1.__metadata("design:type", user_js_1.User)
|
54
54
|
], WebAuthCredential.prototype, "creator", void 0);
|
55
55
|
tslib_1.__decorate([
|
@@ -58,7 +58,7 @@ tslib_1.__decorate([
|
|
58
58
|
], WebAuthCredential.prototype, "creatorId", void 0);
|
59
59
|
tslib_1.__decorate([
|
60
60
|
(0, typeorm_1.ManyToOne)(type => user_js_1.User, { nullable: true }),
|
61
|
-
(0, type_graphql_1.Field)(type => user_js_1.User, { nullable: true }),
|
61
|
+
(0, type_graphql_1.Field)(type => user_js_1.User, { nullable: true, description: 'The user who last updated the credential.' }),
|
62
62
|
tslib_1.__metadata("design:type", user_js_1.User)
|
63
63
|
], WebAuthCredential.prototype, "updater", void 0);
|
64
64
|
tslib_1.__decorate([
|
@@ -67,6 +67,7 @@ tslib_1.__decorate([
|
|
67
67
|
], WebAuthCredential.prototype, "updaterId", void 0);
|
68
68
|
exports.WebAuthCredential = WebAuthCredential = tslib_1.__decorate([
|
69
69
|
(0, typeorm_1.Entity)(),
|
70
|
-
(0, typeorm_1.Index)('ix_web_auth_credential_0', (webAuthCredential) => [webAuthCredential.user, webAuthCredential.credentialId], { unique: true })
|
70
|
+
(0, typeorm_1.Index)('ix_web_auth_credential_0', (webAuthCredential) => [webAuthCredential.user, webAuthCredential.credentialId], { unique: true }),
|
71
|
+
(0, type_graphql_1.ObjectType)({ description: 'Represents a WebAuthn credential for passwordless authentication.' })
|
71
72
|
], WebAuthCredential);
|
72
73
|
//# sourceMappingURL=web-auth-credential.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"web-auth-credential.js","sourceRoot":"","sources":["../../../server/service/web-auth-credential/web-auth-credential.ts"],"names":[],"mappings":";;;;AAAA,+
|
1
|
+
{"version":3,"file":"web-auth-credential.js","sourceRoot":"","sources":["../../../server/service/web-auth-credential/web-auth-credential.ts"],"names":[],"mappings":";;;;AAAA,+CAAoD;AACpD,qCASgB;AAEhB,6CAAsC;AAS/B,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CA6C7B,CAAA;AA7CY,8CAAiB;AAGnB;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;I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,CAAC;IAC3C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,sCAAsC,EAAE,CAAC;sCACnF,cAAI;kDAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,iBAAoC,EAAE,EAAE,CAAC,iBAAiB,CAAC,OAAO,CAAC;;oDAC9D;AAIlB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,2CAA2C,EAAE,CAAC;sCACxF,cAAI;kDAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,iBAAoC,EAAE,EAAE,CAAC,iBAAiB,CAAC,OAAO,CAAC;;oDAC9D;4BA5CP,iBAAiB;IAP7B,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EACJ,0BAA0B,EAC1B,CAAC,iBAAoC,EAAE,EAAE,CAAC,CAAC,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,CAAC,YAAY,CAAC,EAClG,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,mEAAmE,EAAE,CAAC;GACpF,iBAAiB,CA6C7B","sourcesContent":["import { Field, ID, ObjectType } from 'type-graphql'\nimport {\n CreateDateColumn,\n UpdateDateColumn,\n Entity,\n Index,\n Column,\n RelationId,\n ManyToOne,\n PrimaryGeneratedColumn\n} from 'typeorm'\n\nimport { User } from '../user/user.js'\n\n@Entity()\n@Index(\n 'ix_web_auth_credential_0',\n (webAuthCredential: WebAuthCredential) => [webAuthCredential.user, webAuthCredential.credentialId],\n { unique: true }\n)\n@ObjectType({ description: 'Represents a WebAuthn credential for passwordless authentication.' })\nexport class WebAuthCredential {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier for the credential.' })\n readonly id: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'The user associated with this credential.' })\n user?: User\n\n @RelationId((webAuthCredential: WebAuthCredential) => webAuthCredential.user)\n userId?: string\n\n @Column()\n @Field({ nullable: true, description: 'The unique ID for this credential, provided by the authenticator.' })\n credentialId: string\n\n @Column()\n @Field({ nullable: true, description: 'The public key of the credential.' })\n publicKey: string\n\n @Column()\n @Field({ nullable: true, description: 'The signature counter, used to prevent replay attacks.' })\n counter: number\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'The timestamp when the credential was created.' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'The timestamp when the credential was last updated.' })\n updatedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'The user who created the credential.' })\n creator?: User\n\n @RelationId((webAuthCredential: WebAuthCredential) => webAuthCredential.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'The user who last updated the credential.' })\n updater?: User\n\n @RelationId((webAuthCredential: WebAuthCredential) => webAuthCredential.updater)\n updaterId?: string\n}\n"]}
|