strapi-plugin-firebase-authentication 1.3.2 → 1.4.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.
Files changed (28) hide show
  1. package/dist/_chunks/{App-DjamRMm8.mjs → App-BetYshSi.mjs} +480 -160
  2. package/dist/_chunks/{App-BmP-duLn.js → App-CvU_Hs6w.js} +592 -251
  3. package/dist/_chunks/{api-Bg075IIT.js → api-e13nzvp3.js} +2 -1
  4. package/dist/_chunks/{api-CLQa5PFi.mjs → api-ut3LjIwN.mjs} +2 -1
  5. package/dist/_chunks/{index-B2NvsXdF.mjs → index-CciifEG2.mjs} +13 -14
  6. package/dist/_chunks/{index-B4ptk_Em.js → index-Cdk5SnH2.js} +1 -1
  7. package/dist/_chunks/{index-CyOVjVQb.js → index-DG0-IQtm.js} +4 -5
  8. package/dist/_chunks/{index-CAZnRswo.mjs → index-LLF37Cdh.mjs} +1 -1
  9. package/dist/admin/index.js +1 -1
  10. package/dist/admin/index.mjs +2 -2
  11. package/dist/admin/src/components/ActivityLog/ActivityLog.d.ts +6 -0
  12. package/dist/admin/src/components/ActivityLog/index.d.ts +1 -0
  13. package/dist/admin/src/pages/utils/api.d.ts +18 -1
  14. package/dist/server/index.js +8147 -30597
  15. package/dist/server/index.mjs +8144 -30589
  16. package/dist/server/src/config/index.d.ts +8 -0
  17. package/dist/server/src/content-types/index.d.ts +74 -0
  18. package/dist/server/src/controllers/activityLogController.d.ts +8 -0
  19. package/dist/server/src/controllers/index.d.ts +3 -0
  20. package/dist/server/src/index.d.ts +93 -1
  21. package/dist/server/src/middlewares/activity-logger.d.ts +9 -0
  22. package/dist/server/src/middlewares/index.d.ts +5 -1
  23. package/dist/server/src/services/activityLogService.d.ts +58 -0
  24. package/dist/server/src/services/firebaseService.d.ts +1 -0
  25. package/dist/server/src/services/firebaseUserDataService.d.ts +1 -0
  26. package/dist/server/src/services/index.d.ts +10 -0
  27. package/dist/server/src/services/userService.d.ts +1 -0
  28. package/package.json +2 -1
@@ -41,6 +41,13 @@ export type FirebaseAuthConfig = {
41
41
  * @default '{randomString}@phone-user.firebase.local'
42
42
  */
43
43
  emailPattern?: string;
44
+ /**
45
+ * Number of days to retain activity logs. If not set, logs are kept forever.
46
+ * Set via FIREBASE_ACTIVITY_LOG_RETENTION_DAYS environment variable.
47
+ *
48
+ * @default null (never delete)
49
+ */
50
+ activityLogRetentionDays?: number | null;
44
51
  };
45
52
  declare const _default: {
46
53
  default: ({ env }: {
@@ -49,6 +56,7 @@ declare const _default: {
49
56
  firebaseJsonEncryptionKey: any;
50
57
  emailRequired: any;
51
58
  emailPattern: string;
59
+ activityLogRetentionDays: any;
52
60
  };
53
61
  validator(config: FirebaseAuthConfig): void;
54
62
  };
@@ -141,5 +141,79 @@ declare const _default: {
141
141
  };
142
142
  };
143
143
  };
144
+ "firebase-activity-log": {
145
+ schema: {
146
+ kind: string;
147
+ collectionName: string;
148
+ info: {
149
+ singularName: string;
150
+ pluralName: string;
151
+ displayName: string;
152
+ description: string;
153
+ };
154
+ options: {
155
+ draftAndPublish: boolean;
156
+ };
157
+ pluginOptions: {
158
+ "content-manager": {
159
+ visible: boolean;
160
+ };
161
+ "content-type-builder": {
162
+ visible: boolean;
163
+ };
164
+ };
165
+ attributes: {
166
+ firebaseUserId: {
167
+ type: string;
168
+ required: boolean;
169
+ };
170
+ strapiUserId: {
171
+ type: string;
172
+ };
173
+ activityType: {
174
+ type: string;
175
+ enum: string[];
176
+ required: boolean;
177
+ };
178
+ action: {
179
+ type: string;
180
+ required: boolean;
181
+ };
182
+ endpoint: {
183
+ type: string;
184
+ };
185
+ method: {
186
+ type: string;
187
+ };
188
+ ipAddress: {
189
+ type: string;
190
+ };
191
+ userAgent: {
192
+ type: string;
193
+ };
194
+ changes: {
195
+ type: string;
196
+ };
197
+ metadata: {
198
+ type: string;
199
+ };
200
+ success: {
201
+ type: string;
202
+ default: boolean;
203
+ };
204
+ errorMessage: {
205
+ type: string;
206
+ };
207
+ performedBy: {
208
+ type: string;
209
+ };
210
+ performedByType: {
211
+ type: string;
212
+ enum: string[];
213
+ default: string;
214
+ };
215
+ };
216
+ };
217
+ };
144
218
  };
145
219
  export default _default;
@@ -0,0 +1,8 @@
1
+ import { Context, DefaultContext } from "koa";
2
+ declare const _default: {
3
+ /**
4
+ * GET /activity-logs?firebaseUserId=xxx&page=1&pageSize=20&activityType=...&startDate=...&endDate=...
5
+ */
6
+ list(ctx: DefaultContext | Context): Promise<void>;
7
+ };
8
+ export default _default;
@@ -31,5 +31,8 @@ declare const _default: {
31
31
  getPublicConfig(ctx: import("koa").Context | import("koa").DefaultContext): Promise<any>;
32
32
  savePasswordConfig(ctx: import("koa").Context | import("koa").DefaultContext): Promise<void>;
33
33
  };
34
+ activityLogController: {
35
+ list(ctx: import("koa").Context | import("koa").DefaultContext): Promise<void>;
36
+ };
34
37
  };
35
38
  export default _default;
@@ -16,6 +16,7 @@ declare const _default: {
16
16
  firebaseJsonEncryptionKey: any;
17
17
  emailRequired: any;
18
18
  emailPattern: string;
19
+ activityLogRetentionDays: any;
19
20
  };
20
21
  validator(config: import("./config").FirebaseAuthConfig): void;
21
22
  };
@@ -52,6 +53,9 @@ declare const _default: {
52
53
  getPublicConfig(ctx: import("koa").Context | import("koa").DefaultContext): Promise<any>;
53
54
  savePasswordConfig(ctx: import("koa").Context | import("koa").DefaultContext): Promise<void>;
54
55
  };
56
+ activityLogController: {
57
+ list(ctx: import("koa").Context | import("koa").DefaultContext): Promise<void>;
58
+ };
55
59
  };
56
60
  routes: {
57
61
  admin: {
@@ -153,6 +157,7 @@ declare const _default: {
153
157
  resetPasswordWithToken: (token: string, newPassword: string) => Promise<{
154
158
  success: boolean;
155
159
  message: string;
160
+ uid: any;
156
161
  }>;
157
162
  sendVerificationEmail: (entityId: string) => Promise<any>;
158
163
  };
@@ -210,6 +215,7 @@ declare const _default: {
210
215
  verifyEmail(token: string): Promise<{
211
216
  success: boolean;
212
217
  message: string;
218
+ uid: any;
213
219
  }>;
214
220
  checkPassword(user: any, password: string): Promise<{
215
221
  valid: boolean;
@@ -272,6 +278,14 @@ declare const _default: {
272
278
  validateVerificationToken(token: string): Promise<import("./services/tokenService").VerificationTokenValidationResult>;
273
279
  invalidateVerificationToken(firebaseUserDataDocumentId: string): Promise<void>;
274
280
  };
281
+ activityLogService: ({ strapi }: {
282
+ strapi: import("@strapi/types/dist/core").Strapi;
283
+ }) => {
284
+ logActivity(params: import("./services/activityLogService").LogActivityParams): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
285
+ getActivityLogs(firebaseUserId: string, options?: import("./services/activityLogService").GetActivityLogsOptions): Promise<import("@strapi/types/dist/modules/documents").AnyDocument[]>;
286
+ getActivityCount(firebaseUserId: string, options?: import("./services/activityLogService").GetActivityLogsOptions): Promise<number>;
287
+ cleanupOldLogs(retentionDays: number): Promise<number>;
288
+ };
275
289
  };
276
290
  contentTypes: {
277
291
  "firebase-authentication-configuration": {
@@ -416,10 +430,88 @@ declare const _default: {
416
430
  };
417
431
  };
418
432
  };
433
+ "firebase-activity-log": {
434
+ schema: {
435
+ kind: string;
436
+ collectionName: string;
437
+ info: {
438
+ singularName: string;
439
+ pluralName: string;
440
+ displayName: string;
441
+ description: string;
442
+ };
443
+ options: {
444
+ draftAndPublish: boolean;
445
+ };
446
+ pluginOptions: {
447
+ "content-manager": {
448
+ visible: boolean;
449
+ };
450
+ "content-type-builder": {
451
+ visible: boolean;
452
+ };
453
+ };
454
+ attributes: {
455
+ firebaseUserId: {
456
+ type: string;
457
+ required: boolean;
458
+ };
459
+ strapiUserId: {
460
+ type: string;
461
+ };
462
+ activityType: {
463
+ type: string;
464
+ enum: string[];
465
+ required: boolean;
466
+ };
467
+ action: {
468
+ type: string;
469
+ required: boolean;
470
+ };
471
+ endpoint: {
472
+ type: string;
473
+ };
474
+ method: {
475
+ type: string;
476
+ };
477
+ ipAddress: {
478
+ type: string;
479
+ };
480
+ userAgent: {
481
+ type: string;
482
+ };
483
+ changes: {
484
+ type: string;
485
+ };
486
+ metadata: {
487
+ type: string;
488
+ };
489
+ success: {
490
+ type: string;
491
+ default: boolean;
492
+ };
493
+ errorMessage: {
494
+ type: string;
495
+ };
496
+ performedBy: {
497
+ type: string;
498
+ };
499
+ performedByType: {
500
+ type: string;
501
+ enum: string[];
502
+ default: string;
503
+ };
504
+ };
505
+ };
506
+ };
419
507
  };
420
508
  policies: {
421
509
  "is-authenticated": (policyContext: any) => Promise<boolean>;
422
510
  };
423
- middlewares: {};
511
+ middlewares: {
512
+ "activity-logger": ({ strapi }: {
513
+ strapi: import("@strapi/types/dist/core").Strapi;
514
+ }) => (ctx: import("koa").Context, next: import("koa").Next) => Promise<void>;
515
+ };
424
516
  };
425
517
  export default _default;
@@ -0,0 +1,9 @@
1
+ import type { Core } from "@strapi/strapi";
2
+ import type Koa from "koa";
3
+ /**
4
+ * Factory function that creates the activity logger middleware
5
+ */
6
+ declare const _default: ({ strapi }: {
7
+ strapi: Core.Strapi;
8
+ }) => (ctx: Koa.Context, next: Koa.Next) => Promise<void>;
9
+ export default _default;
@@ -1,2 +1,6 @@
1
- declare const _default: {};
1
+ declare const _default: {
2
+ "activity-logger": ({ strapi }: {
3
+ strapi: import("@strapi/types/dist/core").Strapi;
4
+ }) => (ctx: import("koa").Context, next: import("koa").Next) => Promise<void>;
5
+ };
2
6
  export default _default;
@@ -0,0 +1,58 @@
1
+ import type { Core } from "@strapi/strapi";
2
+ export interface LogActivityParams {
3
+ firebaseUserId: string;
4
+ strapiUserId?: string;
5
+ activityType: "authentication" | "tokenValidation" | "fieldUpdate" | "passwordReset" | "emailVerification" | "accountCreation" | "accountDeletion" | "adminAction";
6
+ action: string;
7
+ endpoint?: string;
8
+ method?: string;
9
+ ipAddress?: string;
10
+ userAgent?: string;
11
+ changes?: Record<string, {
12
+ old: any;
13
+ new: any;
14
+ }>;
15
+ metadata?: Record<string, any>;
16
+ success?: boolean;
17
+ errorMessage?: string;
18
+ performedBy?: string;
19
+ performedByType?: "user" | "admin" | "system";
20
+ }
21
+ export interface GetActivityLogsOptions {
22
+ page?: number;
23
+ pageSize?: number;
24
+ activityType?: string;
25
+ startDate?: string;
26
+ endDate?: string;
27
+ }
28
+ declare const _default: ({ strapi }: {
29
+ strapi: Core.Strapi;
30
+ }) => {
31
+ /**
32
+ * Log an activity (non-blocking - errors are caught internally)
33
+ * @param params - Activity log parameters
34
+ * @returns Created activity log or undefined on error
35
+ */
36
+ logActivity(params: LogActivityParams): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
37
+ /**
38
+ * Get paginated activity logs for a user with optional filters
39
+ * @param firebaseUserId - Firebase UID
40
+ * @param options - Pagination and filter options
41
+ * @returns Array of activity logs
42
+ */
43
+ getActivityLogs(firebaseUserId: string, options?: GetActivityLogsOptions): Promise<import("@strapi/types/dist/modules/documents").AnyDocument[]>;
44
+ /**
45
+ * Get total count for pagination
46
+ * @param firebaseUserId - Firebase UID
47
+ * @param options - Filter options
48
+ * @returns Total count of matching logs
49
+ */
50
+ getActivityCount(firebaseUserId: string, options?: GetActivityLogsOptions): Promise<number>;
51
+ /**
52
+ * Delete logs older than specified days
53
+ * @param retentionDays - Number of days to retain logs
54
+ * @returns Number of deleted entries
55
+ */
56
+ cleanupOldLogs(retentionDays: number): Promise<number>;
57
+ };
58
+ export default _default;
@@ -130,6 +130,7 @@ declare const _default: ({ strapi }: {
130
130
  verifyEmail(token: string): Promise<{
131
131
  success: boolean;
132
132
  message: string;
133
+ uid: any;
133
134
  }>;
134
135
  /**
135
136
  * Check if a password is valid for the authenticated user
@@ -15,6 +15,7 @@ declare const _default: ({ strapi }: {
15
15
  getByFirebaseUID(firebaseUID: string): Promise<any>;
16
16
  /**
17
17
  * Update Firebase-specific fields for a user (creates if doesn't exist)
18
+ * Handles orphaned records and race conditions gracefully
18
19
  * @param userId - Strapi user documentId
19
20
  * @param data - Fields to update
20
21
  */
@@ -63,6 +63,7 @@ declare const _default: {
63
63
  resetPasswordWithToken: (token: string, newPassword: string) => Promise<{
64
64
  success: boolean;
65
65
  message: string;
66
+ uid: any;
66
67
  }>;
67
68
  sendVerificationEmail: (entityId: string) => Promise<any>;
68
69
  };
@@ -120,6 +121,7 @@ declare const _default: {
120
121
  verifyEmail(token: string): Promise<{
121
122
  success: boolean;
122
123
  message: string;
124
+ uid: any;
123
125
  }>;
124
126
  checkPassword(user: any, password: string): Promise<{
125
127
  valid: boolean;
@@ -182,5 +184,13 @@ declare const _default: {
182
184
  validateVerificationToken(token: string): Promise<import("./tokenService").VerificationTokenValidationResult>;
183
185
  invalidateVerificationToken(firebaseUserDataDocumentId: string): Promise<void>;
184
186
  };
187
+ activityLogService: ({ strapi }: {
188
+ strapi: import("@strapi/types/dist/core").Strapi;
189
+ }) => {
190
+ logActivity(params: import("./activityLogService").LogActivityParams): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
191
+ getActivityLogs(firebaseUserId: string, options?: import("./activityLogService").GetActivityLogsOptions): Promise<import("@strapi/types/dist/modules/documents").AnyDocument[]>;
192
+ getActivityCount(firebaseUserId: string, options?: import("./activityLogService").GetActivityLogsOptions): Promise<number>;
193
+ cleanupOldLogs(retentionDays: number): Promise<number>;
194
+ };
185
195
  };
186
196
  export default _default;
@@ -42,6 +42,7 @@ declare const _default: ({ strapi }: {
42
42
  resetPasswordWithToken: (token: string, newPassword: string) => Promise<{
43
43
  success: boolean;
44
44
  message: string;
45
+ uid: any;
45
46
  }>;
46
47
  /**
47
48
  * Send email verification email (admin-initiated)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strapi-plugin-firebase-authentication",
3
- "version": "1.3.2",
3
+ "version": "1.4.0",
4
4
  "description": "Allows easy integration between clients utilizing Firebase for authentication and Strapi",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -85,6 +85,7 @@
85
85
  },
86
86
  "peerDependencies": {
87
87
  "@strapi/strapi": "^5.0.0",
88
+ "@strapi/utils": "^5.0.0",
88
89
  "react": "^18.0.0",
89
90
  "react-dom": "^18.0.0",
90
91
  "react-router-dom": "^6.0.0",