aaspai-authx 0.1.1 → 0.1.2

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/index.d.cts CHANGED
@@ -64,10 +64,20 @@ declare class AuthAdminService {
64
64
  }): Promise<(mongoose.Document<unknown, {}, {
65
65
  email: string;
66
66
  roles: string[];
67
- projectId: string;
68
- id: string;
69
67
  firstName: string;
70
68
  lastName: string;
69
+ metadata: mongoose.Types.DocumentArray<{
70
+ key: string;
71
+ value: any;
72
+ }, mongoose.Types.Subdocument<bson.ObjectId, any, {
73
+ key: string;
74
+ value: any;
75
+ }> & {
76
+ key: string;
77
+ value: any;
78
+ }>;
79
+ projectId: string;
80
+ id: string;
71
81
  emailVerified: boolean;
72
82
  lastEmailSent: mongoose.Types.DocumentArray<{
73
83
  prototype?: {
@@ -220,6 +230,17 @@ declare class AuthAdminService {
220
230
  UTC?: {} | null | undefined;
221
231
  now?: {} | null | undefined;
222
232
  }>;
233
+ orgId?: string | null | undefined;
234
+ lastPasswordReset?: NativeDate | null | undefined;
235
+ passwordHash?: string | null | undefined;
236
+ } & mongoose.DefaultTimestampProps, {}, {
237
+ timestamps: true;
238
+ collection: string;
239
+ }> & {
240
+ email: string;
241
+ roles: string[];
242
+ firstName: string;
243
+ lastName: string;
223
244
  metadata: mongoose.Types.DocumentArray<{
224
245
  key: string;
225
246
  value: any;
@@ -230,19 +251,8 @@ declare class AuthAdminService {
230
251
  key: string;
231
252
  value: any;
232
253
  }>;
233
- orgId?: string | null | undefined;
234
- lastPasswordReset?: NativeDate | null | undefined;
235
- passwordHash?: string | null | undefined;
236
- } & mongoose.DefaultTimestampProps, {}, {
237
- timestamps: true;
238
- collection: string;
239
- }> & {
240
- email: string;
241
- roles: string[];
242
254
  projectId: string;
243
255
  id: string;
244
- firstName: string;
245
- lastName: string;
246
256
  emailVerified: boolean;
247
257
  lastEmailSent: mongoose.Types.DocumentArray<{
248
258
  prototype?: {
@@ -395,16 +405,6 @@ declare class AuthAdminService {
395
405
  UTC?: {} | null | undefined;
396
406
  now?: {} | null | undefined;
397
407
  }>;
398
- metadata: mongoose.Types.DocumentArray<{
399
- key: string;
400
- value: any;
401
- }, mongoose.Types.Subdocument<bson.ObjectId, any, {
402
- key: string;
403
- value: any;
404
- }> & {
405
- key: string;
406
- value: any;
407
- }>;
408
408
  orgId?: string | null | undefined;
409
409
  lastPasswordReset?: NativeDate | null | undefined;
410
410
  passwordHash?: string | null | undefined;
@@ -416,10 +416,20 @@ declare class AuthAdminService {
416
416
  getUserById(userId: string): Promise<(mongoose.Document<unknown, {}, {
417
417
  email: string;
418
418
  roles: string[];
419
- projectId: string;
420
- id: string;
421
419
  firstName: string;
422
420
  lastName: string;
421
+ metadata: mongoose.Types.DocumentArray<{
422
+ key: string;
423
+ value: any;
424
+ }, mongoose.Types.Subdocument<bson.ObjectId, any, {
425
+ key: string;
426
+ value: any;
427
+ }> & {
428
+ key: string;
429
+ value: any;
430
+ }>;
431
+ projectId: string;
432
+ id: string;
423
433
  emailVerified: boolean;
424
434
  lastEmailSent: mongoose.Types.DocumentArray<{
425
435
  prototype?: {
@@ -572,6 +582,17 @@ declare class AuthAdminService {
572
582
  UTC?: {} | null | undefined;
573
583
  now?: {} | null | undefined;
574
584
  }>;
585
+ orgId?: string | null | undefined;
586
+ lastPasswordReset?: NativeDate | null | undefined;
587
+ passwordHash?: string | null | undefined;
588
+ } & mongoose.DefaultTimestampProps, {}, {
589
+ timestamps: true;
590
+ collection: string;
591
+ }> & {
592
+ email: string;
593
+ roles: string[];
594
+ firstName: string;
595
+ lastName: string;
575
596
  metadata: mongoose.Types.DocumentArray<{
576
597
  key: string;
577
598
  value: any;
@@ -582,19 +603,8 @@ declare class AuthAdminService {
582
603
  key: string;
583
604
  value: any;
584
605
  }>;
585
- orgId?: string | null | undefined;
586
- lastPasswordReset?: NativeDate | null | undefined;
587
- passwordHash?: string | null | undefined;
588
- } & mongoose.DefaultTimestampProps, {}, {
589
- timestamps: true;
590
- collection: string;
591
- }> & {
592
- email: string;
593
- roles: string[];
594
606
  projectId: string;
595
607
  id: string;
596
- firstName: string;
597
- lastName: string;
598
608
  emailVerified: boolean;
599
609
  lastEmailSent: mongoose.Types.DocumentArray<{
600
610
  prototype?: {
@@ -747,16 +757,6 @@ declare class AuthAdminService {
747
757
  UTC?: {} | null | undefined;
748
758
  now?: {} | null | undefined;
749
759
  }>;
750
- metadata: mongoose.Types.DocumentArray<{
751
- key: string;
752
- value: any;
753
- }, mongoose.Types.Subdocument<bson.ObjectId, any, {
754
- key: string;
755
- value: any;
756
- }> & {
757
- key: string;
758
- value: any;
759
- }>;
760
760
  orgId?: string | null | undefined;
761
761
  lastPasswordReset?: NativeDate | null | undefined;
762
762
  passwordHash?: string | null | undefined;
@@ -778,10 +778,20 @@ declare class AuthAdminService {
778
778
  }): Promise<mongoose.Document<unknown, {}, {
779
779
  email: string;
780
780
  roles: string[];
781
- projectId: string;
782
- id: string;
783
781
  firstName: string;
784
782
  lastName: string;
783
+ metadata: mongoose.Types.DocumentArray<{
784
+ key: string;
785
+ value: any;
786
+ }, mongoose.Types.Subdocument<bson.ObjectId, any, {
787
+ key: string;
788
+ value: any;
789
+ }> & {
790
+ key: string;
791
+ value: any;
792
+ }>;
793
+ projectId: string;
794
+ id: string;
785
795
  emailVerified: boolean;
786
796
  lastEmailSent: mongoose.Types.DocumentArray<{
787
797
  prototype?: {
@@ -934,6 +944,17 @@ declare class AuthAdminService {
934
944
  UTC?: {} | null | undefined;
935
945
  now?: {} | null | undefined;
936
946
  }>;
947
+ orgId?: string | null | undefined;
948
+ lastPasswordReset?: NativeDate | null | undefined;
949
+ passwordHash?: string | null | undefined;
950
+ } & mongoose.DefaultTimestampProps, {}, {
951
+ timestamps: true;
952
+ collection: string;
953
+ }> & {
954
+ email: string;
955
+ roles: string[];
956
+ firstName: string;
957
+ lastName: string;
937
958
  metadata: mongoose.Types.DocumentArray<{
938
959
  key: string;
939
960
  value: any;
@@ -944,19 +965,8 @@ declare class AuthAdminService {
944
965
  key: string;
945
966
  value: any;
946
967
  }>;
947
- orgId?: string | null | undefined;
948
- lastPasswordReset?: NativeDate | null | undefined;
949
- passwordHash?: string | null | undefined;
950
- } & mongoose.DefaultTimestampProps, {}, {
951
- timestamps: true;
952
- collection: string;
953
- }> & {
954
- email: string;
955
- roles: string[];
956
968
  projectId: string;
957
969
  id: string;
958
- firstName: string;
959
- lastName: string;
960
970
  emailVerified: boolean;
961
971
  lastEmailSent: mongoose.Types.DocumentArray<{
962
972
  prototype?: {
@@ -1109,16 +1119,6 @@ declare class AuthAdminService {
1109
1119
  UTC?: {} | null | undefined;
1110
1120
  now?: {} | null | undefined;
1111
1121
  }>;
1112
- metadata: mongoose.Types.DocumentArray<{
1113
- key: string;
1114
- value: any;
1115
- }, mongoose.Types.Subdocument<bson.ObjectId, any, {
1116
- key: string;
1117
- value: any;
1118
- }> & {
1119
- key: string;
1120
- value: any;
1121
- }>;
1122
1122
  orgId?: string | null | undefined;
1123
1123
  lastPasswordReset?: NativeDate | null | undefined;
1124
1124
  passwordHash?: string | null | undefined;
package/dist/index.d.ts CHANGED
@@ -64,10 +64,20 @@ declare class AuthAdminService {
64
64
  }): Promise<(mongoose.Document<unknown, {}, {
65
65
  email: string;
66
66
  roles: string[];
67
- projectId: string;
68
- id: string;
69
67
  firstName: string;
70
68
  lastName: string;
69
+ metadata: mongoose.Types.DocumentArray<{
70
+ key: string;
71
+ value: any;
72
+ }, mongoose.Types.Subdocument<bson.ObjectId, any, {
73
+ key: string;
74
+ value: any;
75
+ }> & {
76
+ key: string;
77
+ value: any;
78
+ }>;
79
+ projectId: string;
80
+ id: string;
71
81
  emailVerified: boolean;
72
82
  lastEmailSent: mongoose.Types.DocumentArray<{
73
83
  prototype?: {
@@ -220,6 +230,17 @@ declare class AuthAdminService {
220
230
  UTC?: {} | null | undefined;
221
231
  now?: {} | null | undefined;
222
232
  }>;
233
+ orgId?: string | null | undefined;
234
+ lastPasswordReset?: NativeDate | null | undefined;
235
+ passwordHash?: string | null | undefined;
236
+ } & mongoose.DefaultTimestampProps, {}, {
237
+ timestamps: true;
238
+ collection: string;
239
+ }> & {
240
+ email: string;
241
+ roles: string[];
242
+ firstName: string;
243
+ lastName: string;
223
244
  metadata: mongoose.Types.DocumentArray<{
224
245
  key: string;
225
246
  value: any;
@@ -230,19 +251,8 @@ declare class AuthAdminService {
230
251
  key: string;
231
252
  value: any;
232
253
  }>;
233
- orgId?: string | null | undefined;
234
- lastPasswordReset?: NativeDate | null | undefined;
235
- passwordHash?: string | null | undefined;
236
- } & mongoose.DefaultTimestampProps, {}, {
237
- timestamps: true;
238
- collection: string;
239
- }> & {
240
- email: string;
241
- roles: string[];
242
254
  projectId: string;
243
255
  id: string;
244
- firstName: string;
245
- lastName: string;
246
256
  emailVerified: boolean;
247
257
  lastEmailSent: mongoose.Types.DocumentArray<{
248
258
  prototype?: {
@@ -395,16 +405,6 @@ declare class AuthAdminService {
395
405
  UTC?: {} | null | undefined;
396
406
  now?: {} | null | undefined;
397
407
  }>;
398
- metadata: mongoose.Types.DocumentArray<{
399
- key: string;
400
- value: any;
401
- }, mongoose.Types.Subdocument<bson.ObjectId, any, {
402
- key: string;
403
- value: any;
404
- }> & {
405
- key: string;
406
- value: any;
407
- }>;
408
408
  orgId?: string | null | undefined;
409
409
  lastPasswordReset?: NativeDate | null | undefined;
410
410
  passwordHash?: string | null | undefined;
@@ -416,10 +416,20 @@ declare class AuthAdminService {
416
416
  getUserById(userId: string): Promise<(mongoose.Document<unknown, {}, {
417
417
  email: string;
418
418
  roles: string[];
419
- projectId: string;
420
- id: string;
421
419
  firstName: string;
422
420
  lastName: string;
421
+ metadata: mongoose.Types.DocumentArray<{
422
+ key: string;
423
+ value: any;
424
+ }, mongoose.Types.Subdocument<bson.ObjectId, any, {
425
+ key: string;
426
+ value: any;
427
+ }> & {
428
+ key: string;
429
+ value: any;
430
+ }>;
431
+ projectId: string;
432
+ id: string;
423
433
  emailVerified: boolean;
424
434
  lastEmailSent: mongoose.Types.DocumentArray<{
425
435
  prototype?: {
@@ -572,6 +582,17 @@ declare class AuthAdminService {
572
582
  UTC?: {} | null | undefined;
573
583
  now?: {} | null | undefined;
574
584
  }>;
585
+ orgId?: string | null | undefined;
586
+ lastPasswordReset?: NativeDate | null | undefined;
587
+ passwordHash?: string | null | undefined;
588
+ } & mongoose.DefaultTimestampProps, {}, {
589
+ timestamps: true;
590
+ collection: string;
591
+ }> & {
592
+ email: string;
593
+ roles: string[];
594
+ firstName: string;
595
+ lastName: string;
575
596
  metadata: mongoose.Types.DocumentArray<{
576
597
  key: string;
577
598
  value: any;
@@ -582,19 +603,8 @@ declare class AuthAdminService {
582
603
  key: string;
583
604
  value: any;
584
605
  }>;
585
- orgId?: string | null | undefined;
586
- lastPasswordReset?: NativeDate | null | undefined;
587
- passwordHash?: string | null | undefined;
588
- } & mongoose.DefaultTimestampProps, {}, {
589
- timestamps: true;
590
- collection: string;
591
- }> & {
592
- email: string;
593
- roles: string[];
594
606
  projectId: string;
595
607
  id: string;
596
- firstName: string;
597
- lastName: string;
598
608
  emailVerified: boolean;
599
609
  lastEmailSent: mongoose.Types.DocumentArray<{
600
610
  prototype?: {
@@ -747,16 +757,6 @@ declare class AuthAdminService {
747
757
  UTC?: {} | null | undefined;
748
758
  now?: {} | null | undefined;
749
759
  }>;
750
- metadata: mongoose.Types.DocumentArray<{
751
- key: string;
752
- value: any;
753
- }, mongoose.Types.Subdocument<bson.ObjectId, any, {
754
- key: string;
755
- value: any;
756
- }> & {
757
- key: string;
758
- value: any;
759
- }>;
760
760
  orgId?: string | null | undefined;
761
761
  lastPasswordReset?: NativeDate | null | undefined;
762
762
  passwordHash?: string | null | undefined;
@@ -778,10 +778,20 @@ declare class AuthAdminService {
778
778
  }): Promise<mongoose.Document<unknown, {}, {
779
779
  email: string;
780
780
  roles: string[];
781
- projectId: string;
782
- id: string;
783
781
  firstName: string;
784
782
  lastName: string;
783
+ metadata: mongoose.Types.DocumentArray<{
784
+ key: string;
785
+ value: any;
786
+ }, mongoose.Types.Subdocument<bson.ObjectId, any, {
787
+ key: string;
788
+ value: any;
789
+ }> & {
790
+ key: string;
791
+ value: any;
792
+ }>;
793
+ projectId: string;
794
+ id: string;
785
795
  emailVerified: boolean;
786
796
  lastEmailSent: mongoose.Types.DocumentArray<{
787
797
  prototype?: {
@@ -934,6 +944,17 @@ declare class AuthAdminService {
934
944
  UTC?: {} | null | undefined;
935
945
  now?: {} | null | undefined;
936
946
  }>;
947
+ orgId?: string | null | undefined;
948
+ lastPasswordReset?: NativeDate | null | undefined;
949
+ passwordHash?: string | null | undefined;
950
+ } & mongoose.DefaultTimestampProps, {}, {
951
+ timestamps: true;
952
+ collection: string;
953
+ }> & {
954
+ email: string;
955
+ roles: string[];
956
+ firstName: string;
957
+ lastName: string;
937
958
  metadata: mongoose.Types.DocumentArray<{
938
959
  key: string;
939
960
  value: any;
@@ -944,19 +965,8 @@ declare class AuthAdminService {
944
965
  key: string;
945
966
  value: any;
946
967
  }>;
947
- orgId?: string | null | undefined;
948
- lastPasswordReset?: NativeDate | null | undefined;
949
- passwordHash?: string | null | undefined;
950
- } & mongoose.DefaultTimestampProps, {}, {
951
- timestamps: true;
952
- collection: string;
953
- }> & {
954
- email: string;
955
- roles: string[];
956
968
  projectId: string;
957
969
  id: string;
958
- firstName: string;
959
- lastName: string;
960
970
  emailVerified: boolean;
961
971
  lastEmailSent: mongoose.Types.DocumentArray<{
962
972
  prototype?: {
@@ -1109,16 +1119,6 @@ declare class AuthAdminService {
1109
1119
  UTC?: {} | null | undefined;
1110
1120
  now?: {} | null | undefined;
1111
1121
  }>;
1112
- metadata: mongoose.Types.DocumentArray<{
1113
- key: string;
1114
- value: any;
1115
- }, mongoose.Types.Subdocument<bson.ObjectId, any, {
1116
- key: string;
1117
- value: any;
1118
- }> & {
1119
- key: string;
1120
- value: any;
1121
- }>;
1122
1122
  orgId?: string | null | undefined;
1123
1123
  lastPasswordReset?: NativeDate | null | undefined;
1124
1124
  passwordHash?: string | null | undefined;
package/dist/index.js CHANGED
@@ -195,10 +195,14 @@ function buildSession(payload) {
195
195
  roles: normalizedRoles,
196
196
  permissions
197
197
  };
198
+ if (payload?.firstName) session.firstName = payload.firstName;
199
+ if (payload?.lastName) session.lastName = payload.lastName;
198
200
  if (payload?.projectId) session.projectId = payload.projectId;
199
201
  if (payload?.orgId) session.orgId = payload.orgId;
200
202
  if (payload?.org_id) session.org_id = payload.org_id;
201
203
  if (payload?.authType) session.authType = payload.authType;
204
+ if (payload?.createdAt) session.createdAt = payload.createdAt;
205
+ if (payload?.metadata) session.metadata = payload.metadata;
202
206
  Object.keys(payload || {}).forEach((key) => {
203
207
  if (![
204
208
  "sub",
@@ -372,10 +376,14 @@ function requireAuth() {
372
376
  const session = buildSession({
373
377
  sub: user.id.toString(),
374
378
  email: user.email,
379
+ firstName: user.firstName,
380
+ lastName: user.lastName,
381
+ metadata: user.metadata || [],
375
382
  roles: user.roles || [],
376
383
  orgId: user.orgId,
377
384
  org_id: user.orgId,
378
- projectId: user.projectId
385
+ projectId: user.projectId,
386
+ createdAt: user.createdAt
379
387
  });
380
388
  session.authType = "api-key";
381
389
  session.projectId = readProjectId(req) || user.projectId || void 0;
@@ -487,7 +495,6 @@ var Invite = mongoose3.model("Invite", InviteSchema);
487
495
  // src/services/auth-admin.service.ts
488
496
  import bcrypt from "bcrypt";
489
497
  import jwt2 from "jsonwebtoken";
490
- import { v4 as uuid2 } from "uuid";
491
498
 
492
499
  // src/models/client.model.ts
493
500
  import mongoose4, { Schema as Schema2 } from "mongoose";
@@ -557,7 +564,7 @@ var AuthAdminService = class {
557
564
  async createUserInRealm(payload) {
558
565
  const hashedPassword = payload.credentials?.[0]?.value ? await bcrypt.hash(payload.credentials[0].value, 10) : void 0;
559
566
  const user = await OrgUser.create({
560
- id: uuid2(),
567
+ id: crypto.randomUUID(),
561
568
  email: payload.email,
562
569
  firstName: payload.firstName,
563
570
  lastName: payload.lastName,
@@ -1283,6 +1290,11 @@ function generateTokens(user) {
1283
1290
  orgId: user.orgId || null,
1284
1291
  org_id: user.orgId || null,
1285
1292
  projectId: user.projectId || null,
1293
+ firstName: user.firstName,
1294
+ lastName: user.lastName,
1295
+ emailVerified: user.emailVerified,
1296
+ createdAt: user.createdAt,
1297
+ metadata: user.metadata,
1286
1298
  type: "user"
1287
1299
  };
1288
1300
  const accessToken = jwt4.sign(accessPayload, process.env.JWT_SECRET, {