strapi-plugin-firebase-authentication 1.0.13 → 1.1.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/README.md +415 -191
- package/dist/_chunks/App-Bl6D4TFu.mjs +6197 -0
- package/dist/_chunks/App-HfsY_18f.js +6181 -0
- package/dist/_chunks/{api-4hcml0jk.mjs → api-B01IAVEC.mjs} +14 -3
- package/dist/_chunks/{api-DPtT1Bpu.js → api-BSejy8nn.js} +14 -3
- package/dist/_chunks/index-4hUrKd7Y.mjs +815 -0
- package/dist/_chunks/index-BbVqBI3M.js +859 -0
- package/dist/_chunks/index-BqF9RRVF.mjs +859 -0
- package/dist/_chunks/index-DgfRCyyQ.js +814 -0
- package/dist/admin/index.js +6 -1
- package/dist/admin/index.mjs +7 -2
- package/dist/admin/src/components/PasswordResetButton/PasswordResetButton.d.ts +11 -0
- package/dist/admin/src/components/PasswordResetButton/index.d.ts +1 -0
- package/dist/admin/src/components/common/Header/Header.d.ts +12 -0
- package/dist/admin/src/components/common/index.d.ts +3 -0
- package/dist/admin/src/components/forms/CreateUserForm/CreateUserForm.d.ts +2 -0
- package/dist/admin/src/components/forms/EditUserForm/EditUserForm.d.ts +6 -0
- package/dist/admin/src/components/forms/index.d.ts +4 -0
- package/dist/admin/src/components/forms/shared/UserFormFields/UserFormFields.d.ts +17 -0
- package/dist/admin/src/components/forms/shared/UserFormLayout/UserFormLayout.d.ts +7 -0
- package/dist/admin/src/components/index.d.ts +5 -0
- package/dist/admin/src/components/search/SearchURLQuery/SearchURLQuery.d.ts +6 -0
- package/dist/admin/src/components/search/index.d.ts +1 -0
- package/dist/admin/src/components/{DynamicTable → table/FirebaseTable}/FirebaseTable.d.ts +3 -2
- package/dist/admin/src/components/{DynamicTable → table}/FirebaseTableRows/FirebaseTableRows.d.ts +2 -2
- package/dist/admin/src/components/table/index.d.ts +3 -0
- package/dist/admin/src/components/user-management/ResetPassword/ResetPassword.d.ts +12 -0
- package/dist/admin/src/components/user-management/index.d.ts +2 -0
- package/dist/admin/src/hooks/useBulkSelection.d.ts +14 -0
- package/dist/admin/src/hooks/useUserForm.d.ts +18 -0
- package/dist/admin/src/pages/CreateView.d.ts +1 -0
- package/dist/admin/src/pages/EditView.d.ts +1 -0
- package/dist/admin/src/pages/ListView/index.d.ts +3 -5
- package/dist/admin/src/pages/Settings/api.d.ts +20 -1
- package/dist/admin/src/pages/utils/api.d.ts +4 -1
- package/dist/admin/src/utils/hasPasswordProvider.d.ts +15 -0
- package/dist/admin/src/utils/validation.d.ts +16 -0
- package/dist/model/Request.d.ts +2 -0
- package/dist/model/User.d.ts +6 -0
- package/dist/server/index.js +6564 -931
- package/dist/server/index.mjs +6518 -902
- package/dist/server/src/config/index.d.ts +36 -1
- package/dist/server/src/constants/index.d.ts +107 -0
- package/dist/server/src/content-types/index.d.ts +82 -0
- package/dist/server/src/controllers/firebaseController.d.ts +32 -2
- package/dist/server/src/controllers/index.d.ts +16 -10
- package/dist/server/src/controllers/settingsController.d.ts +2 -0
- package/dist/server/src/controllers/userController.d.ts +1 -0
- package/dist/server/src/index.d.ts +194 -27
- package/dist/server/src/migrations/migrate-firebase-user-data.d.ts +30 -0
- package/dist/server/src/routes/admin.d.ts +1 -1
- package/dist/server/src/routes/content-api.d.ts +1 -0
- package/dist/server/src/routes/content-internal-api.d.ts +1 -1
- package/dist/server/src/routes/index.d.ts +3 -2
- package/dist/server/src/routes/settingsRoutes.d.ts +1 -1
- package/dist/server/src/services/autoLinkService.d.ts +29 -0
- package/dist/server/src/services/emailService.d.ts +32 -0
- package/dist/server/src/services/firebaseService.d.ts +87 -13
- package/dist/server/src/services/firebaseStrapiLinkService.d.ts +34 -0
- package/dist/server/src/services/firebaseUserDataService.d.ts +26 -0
- package/dist/server/src/services/index.d.ts +91 -16
- package/dist/server/src/services/settingsService.d.ts +55 -0
- package/dist/server/src/services/templateService.d.ts +21 -0
- package/dist/server/src/services/userService.d.ts +2 -1
- package/dist/server/src/templates/defaults/index.d.ts +2 -0
- package/dist/server/src/templates/defaults/magic-link.d.ts +2 -0
- package/dist/server/src/templates/defaults/password-reset.d.ts +2 -0
- package/dist/server/src/templates/types.d.ts +30 -0
- package/dist/server/src/utils/fetch-me.d.ts +2 -10
- package/dist/server/src/utils/get-user-by-id.d.ts +1 -5
- package/dist/server/src/utils/users.d.ts +14 -0
- package/package.json +32 -22
- package/dist/_chunks/App-B2LtHk9g.js +0 -5062
- package/dist/_chunks/App-B3HcVa5j.mjs +0 -5081
- package/dist/_chunks/index-CALp4X47.mjs +0 -110
- package/dist/_chunks/index-CrGRt-Ya.mjs +0 -191
- package/dist/_chunks/index-DMBPEFUy.js +0 -109
- package/dist/_chunks/index-DmTKNKJB.js +0 -191
- package/dist/admin/src/components/SearchURLQuery/SearchURLQuery.d.ts +0 -18
- package/dist/admin/src/components/UserManagement/ResetPassword.d.ts +0 -8
- /package/dist/admin/src/components/{Initializer.d.ts → common/Initializer/Initializer.d.ts} +0 -0
- /package/dist/admin/src/components/{PluginIcon.d.ts → common/PluginIcon/PluginIcon.d.ts} +0 -0
- /package/dist/admin/src/components/{DynamicTable → table/FirebaseTable}/TableHeaders.d.ts +0 -0
- /package/dist/admin/src/components/{UserManagement → user-management/DeleteAccount}/DeleteAccount.d.ts +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Core } from "@strapi/strapi";
|
|
2
|
+
interface MigrationResult {
|
|
3
|
+
totalUsers: number;
|
|
4
|
+
usersWithFirebaseData: number;
|
|
5
|
+
migrated: number;
|
|
6
|
+
skipped: number;
|
|
7
|
+
errors: Array<{
|
|
8
|
+
user: string;
|
|
9
|
+
error: string;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Migrate Firebase user data from up_users table to firebase_user_data table
|
|
14
|
+
*
|
|
15
|
+
* This script:
|
|
16
|
+
* 1. Finds all users with Firebase data (firebaseUserID or appleEmail)
|
|
17
|
+
* 2. Creates corresponding firebase_user_data records
|
|
18
|
+
* 3. Skips users that already have firebase_user_data records
|
|
19
|
+
* 4. Logs all operations for verification
|
|
20
|
+
*
|
|
21
|
+
* Note: idToken is NOT migrated (tokens expire in 1 hour, not needed)
|
|
22
|
+
*
|
|
23
|
+
* Run this script via:
|
|
24
|
+
* yarn strapi migrate:firebase-user-data
|
|
25
|
+
*
|
|
26
|
+
* Or in development:
|
|
27
|
+
* Call this function from bootstrap() temporarily
|
|
28
|
+
*/
|
|
29
|
+
declare function migrateFirebaseUserData(strapi: Core.Strapi, dryRun?: boolean): Promise<MigrationResult>;
|
|
30
|
+
export default migrateFirebaseUserData;
|
|
@@ -6,7 +6,7 @@ declare const _default: {
|
|
|
6
6
|
path: string;
|
|
7
7
|
handler: string;
|
|
8
8
|
config: {
|
|
9
|
-
policies:
|
|
9
|
+
policies: string[];
|
|
10
10
|
};
|
|
11
11
|
}[];
|
|
12
12
|
};
|
|
@@ -17,6 +17,7 @@ declare const _default: {
|
|
|
17
17
|
path: string;
|
|
18
18
|
handler: string;
|
|
19
19
|
config: {
|
|
20
|
+
auth: boolean;
|
|
20
21
|
policies: any[];
|
|
21
22
|
};
|
|
22
23
|
}[];
|
|
@@ -27,7 +28,7 @@ declare const _default: {
|
|
|
27
28
|
path: string;
|
|
28
29
|
handler: string;
|
|
29
30
|
config: {
|
|
30
|
-
policies:
|
|
31
|
+
policies: string[];
|
|
31
32
|
};
|
|
32
33
|
}[];
|
|
33
34
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Core } from "@strapi/strapi";
|
|
2
|
+
export interface LinkResult {
|
|
3
|
+
totalStrapiUsers: number;
|
|
4
|
+
totalFirebaseUsers: number;
|
|
5
|
+
linked: number;
|
|
6
|
+
skipped: number;
|
|
7
|
+
errors: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Auto-Link Service
|
|
11
|
+
*
|
|
12
|
+
* Automatically links existing Strapi users with their Firebase counterparts
|
|
13
|
+
* by matching email and phone numbers.
|
|
14
|
+
*
|
|
15
|
+
* Runs on every Strapi startup in the background (non-blocking).
|
|
16
|
+
*/
|
|
17
|
+
declare const _default: {
|
|
18
|
+
/**
|
|
19
|
+
* Link all Strapi users with matching Firebase users
|
|
20
|
+
*
|
|
21
|
+
* This runs automatically on Strapi startup to ensure all users
|
|
22
|
+
* who exist in both Strapi and Firebase are properly linked.
|
|
23
|
+
*
|
|
24
|
+
* @param strapi - Strapi instance
|
|
25
|
+
* @returns Promise<LinkResult> - Summary of linking operation
|
|
26
|
+
*/
|
|
27
|
+
linkAllUsers(strapi: Core.Strapi): Promise<LinkResult>;
|
|
28
|
+
};
|
|
29
|
+
export default _default;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { TemplateVariables, TemplateType } from "../templates/types";
|
|
2
|
+
declare class EmailService {
|
|
3
|
+
/**
|
|
4
|
+
* Send a templated email using Strapi's email service
|
|
5
|
+
* Templates are compiled with Lodash before sending
|
|
6
|
+
*/
|
|
7
|
+
sendTemplatedEmail(to: string, templateType: TemplateType, variables: Partial<TemplateVariables>): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Send password reset email with three-tier fallback system
|
|
10
|
+
* Tier 1: Strapi Email Plugin (if configured)
|
|
11
|
+
* Tier 2: Custom Hook Function (if provided in config)
|
|
12
|
+
* Tier 3: Development Console Logging (dev mode only)
|
|
13
|
+
*/
|
|
14
|
+
sendPasswordResetEmail(user: any, resetLink: string): Promise<{
|
|
15
|
+
success: boolean;
|
|
16
|
+
message: string;
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Send magic link email with three-tier fallback system
|
|
20
|
+
* Tier 1: Strapi Email Plugin (if configured)
|
|
21
|
+
* Tier 2: Custom Hook Function (if provided in config)
|
|
22
|
+
* Tier 3: Development Console Logging (dev mode only)
|
|
23
|
+
*/
|
|
24
|
+
sendMagicLinkEmail(email: string, magicLink: string, config: any): Promise<{
|
|
25
|
+
success: boolean;
|
|
26
|
+
message: string;
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
declare const _default: ({ strapi }: {
|
|
30
|
+
strapi: any;
|
|
31
|
+
}) => EmailService;
|
|
32
|
+
export default _default;
|
|
@@ -7,24 +7,98 @@ declare const _default: ({ strapi }: {
|
|
|
7
7
|
}>;
|
|
8
8
|
validateExchangeTokenPayload: (requestPayload: any) => Promise<any>;
|
|
9
9
|
decodeIDToken: (idToken: any) => Promise<any>;
|
|
10
|
-
overrideFirebaseAccess: (
|
|
10
|
+
overrideFirebaseAccess: (overrideUserId: string, populate?: string[]) => Promise<{
|
|
11
|
+
user: any;
|
|
12
|
+
jwt: any;
|
|
13
|
+
}>;
|
|
11
14
|
checkIfUserExists(decodedToken: any): Promise<any>;
|
|
12
15
|
fetchUser: (decodedToken: any) => Promise<any>;
|
|
13
16
|
generateJWTForCurrentUser: (user: any) => Promise<any>;
|
|
14
17
|
createStrapiUser(decodedToken: any, idToken: any, profileMetaData: any): Promise<any>;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
validateFirebaseToken: (idToken: string, profileMetaData?: any, populate?: string[]) => Promise<{
|
|
19
|
+
user: any;
|
|
20
|
+
jwt: any;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Authenticates a user with email and password through Firebase Identity Toolkit API
|
|
24
|
+
*
|
|
25
|
+
* @param ctx - Koa context object containing the HTTP request and response
|
|
26
|
+
* @returns Response object containing user and JWT token
|
|
27
|
+
*
|
|
28
|
+
* @throws ValidationError - When email/password are missing or invalid
|
|
29
|
+
* @throws ApplicationError - When Firebase Web API key is not configured or authentication fails
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* // Request
|
|
34
|
+
* POST /api/firebase-authentication/emailLogin
|
|
35
|
+
* {
|
|
36
|
+
* "email": "user@example.com",
|
|
37
|
+
* "password": "securePassword123"
|
|
38
|
+
* }
|
|
39
|
+
*
|
|
40
|
+
* // Response
|
|
41
|
+
* {
|
|
42
|
+
* "user": {
|
|
43
|
+
* "id": 1,
|
|
44
|
+
* "email": "user@example.com",
|
|
45
|
+
* "username": "user",
|
|
46
|
+
* "confirmed": true,
|
|
47
|
+
* "blocked": false
|
|
48
|
+
* },
|
|
49
|
+
* "jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @remarks
|
|
54
|
+
* This method acts as a proxy to Firebase's REST API, eliminating the need for
|
|
55
|
+
* Firebase SDK on the client. It performs the following steps:
|
|
56
|
+
* 1. Validates email and password inputs
|
|
57
|
+
* 2. Retrieves Firebase Web API key from configuration
|
|
58
|
+
* 3. Calls Firebase Identity Toolkit API for authentication
|
|
59
|
+
* 4. Processes Firebase response and handles errors
|
|
60
|
+
* 5. Looks up or creates Strapi user
|
|
61
|
+
* 6. Generates and returns Strapi JWT token
|
|
62
|
+
*/
|
|
63
|
+
emailLogin: (email: string, password: string, populate?: string[]) => Promise<{
|
|
64
|
+
user: any;
|
|
65
|
+
jwt: any;
|
|
66
|
+
}>;
|
|
67
|
+
/**
|
|
68
|
+
* Forgot password flow - sends reset email
|
|
69
|
+
* Public endpoint that generates a JWT token and sends a password reset email
|
|
70
|
+
*/
|
|
71
|
+
forgotPassword: (ctx: any) => Promise<{
|
|
72
|
+
message: string;
|
|
73
|
+
}>;
|
|
74
|
+
/**
|
|
75
|
+
* Reset password with authenticated JWT
|
|
76
|
+
* Public endpoint that validates a JWT token and resets the user's password
|
|
77
|
+
*/
|
|
78
|
+
resetPassword: (ctx: any) => Promise<{
|
|
79
|
+
user: any;
|
|
26
80
|
jwt: any;
|
|
27
|
-
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* Request Magic Link for passwordless authentication
|
|
84
|
+
* Generates a sign-in link using Firebase Admin SDK
|
|
85
|
+
* Note: Verification requires client-side completion
|
|
86
|
+
*/
|
|
87
|
+
requestMagicLink(ctx: any): Promise<{
|
|
88
|
+
debug: {
|
|
89
|
+
linkSent: any;
|
|
90
|
+
email: string;
|
|
91
|
+
message: any;
|
|
92
|
+
};
|
|
93
|
+
success: boolean;
|
|
94
|
+
message: string;
|
|
95
|
+
requiresFrontend: boolean;
|
|
96
|
+
verificationUrl: any;
|
|
97
|
+
} | {
|
|
98
|
+
success: boolean;
|
|
99
|
+
message: string;
|
|
100
|
+
requiresFrontend: boolean;
|
|
101
|
+
verificationUrl: any;
|
|
28
102
|
}>;
|
|
29
103
|
};
|
|
30
104
|
export default _default;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Firebase-Strapi Link Service
|
|
3
|
+
*
|
|
4
|
+
* Links Firebase users with Strapi users via the firebase_user_data table.
|
|
5
|
+
* Uses Firebase UID as the sole source of truth for linking.
|
|
6
|
+
*/
|
|
7
|
+
declare const _default: ({ strapi }: {
|
|
8
|
+
strapi: any;
|
|
9
|
+
}) => {
|
|
10
|
+
/**
|
|
11
|
+
* Builds a Map of Firebase UID → Strapi User for O(1) lookups
|
|
12
|
+
*
|
|
13
|
+
* Fetches all firebase_user_data records with populated user relation.
|
|
14
|
+
* Uses Document Service API for proper Strapi v5 relation handling.
|
|
15
|
+
*
|
|
16
|
+
* @returns Map<firebaseUID, strapiUserWithAppleEmail>
|
|
17
|
+
*/
|
|
18
|
+
buildUserMap(): Promise<Map<any, any>>;
|
|
19
|
+
/**
|
|
20
|
+
* Links Firebase users with Strapi data using firebase_user_data table
|
|
21
|
+
*
|
|
22
|
+
* Matching Strategy:
|
|
23
|
+
* - ONLY uses Firebase UID → firebase_user_data.firebaseUserID
|
|
24
|
+
* - firebase_user_data table is the source of truth
|
|
25
|
+
* - No email/phone fallback (security risk from recycled identifiers)
|
|
26
|
+
*
|
|
27
|
+
* @param firebaseUsers - Array of Firebase user objects
|
|
28
|
+
* @param uidToUserMap - Map from buildUserMap()
|
|
29
|
+
* @param allStrapiUsers - Unused (kept for backward compatibility)
|
|
30
|
+
* @returns Array of linked user objects with linkStatus and warnings
|
|
31
|
+
*/
|
|
32
|
+
linkFirebaseUsers(firebaseUsers: any[], uidToUserMap: Map<string, any>, allStrapiUsers: any[]): any[];
|
|
33
|
+
};
|
|
34
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare const _default: ({ strapi }: {
|
|
2
|
+
strapi: any;
|
|
3
|
+
}) => {
|
|
4
|
+
/**
|
|
5
|
+
* Find or create Firebase user data for a Strapi user
|
|
6
|
+
* @param userId - Strapi user documentId
|
|
7
|
+
* @returns Firebase user data record
|
|
8
|
+
*/
|
|
9
|
+
findOrCreateForUser(userId: string): Promise<any>;
|
|
10
|
+
/**
|
|
11
|
+
* Get Firebase user data by Firebase UID
|
|
12
|
+
* @param firebaseUID - Firebase user ID
|
|
13
|
+
* @returns Firebase user data with populated user
|
|
14
|
+
*/
|
|
15
|
+
getByFirebaseUID(firebaseUID: string): Promise<any>;
|
|
16
|
+
/**
|
|
17
|
+
* Update Firebase-specific fields for a user (creates if doesn't exist)
|
|
18
|
+
* @param userId - Strapi user documentId
|
|
19
|
+
* @param data - Fields to update
|
|
20
|
+
*/
|
|
21
|
+
updateForUser(userId: string, data: {
|
|
22
|
+
firebaseUserID?: string;
|
|
23
|
+
appleEmail?: string;
|
|
24
|
+
}): Promise<any>;
|
|
25
|
+
};
|
|
26
|
+
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/// <reference types="
|
|
1
|
+
/// <reference types="lodash" />
|
|
2
2
|
declare const _default: {
|
|
3
3
|
settingsService: ({ strapi }: {
|
|
4
4
|
strapi: any;
|
|
@@ -6,9 +6,24 @@ declare const _default: {
|
|
|
6
6
|
init(): Promise<void>;
|
|
7
7
|
getFirebaseConfigJson(): Promise<{
|
|
8
8
|
firebaseConfigJson: any;
|
|
9
|
+
firebaseWebApiKey: any;
|
|
10
|
+
passwordRequirementsRegex: any;
|
|
11
|
+
passwordRequirementsMessage: any;
|
|
12
|
+
passwordResetUrl: any;
|
|
13
|
+
passwordResetEmailSubject: any;
|
|
14
|
+
enableMagicLink: any;
|
|
15
|
+
magicLinkUrl: any;
|
|
16
|
+
magicLinkEmailSubject: any;
|
|
17
|
+
magicLinkExpiryHours: any;
|
|
9
18
|
}>;
|
|
10
|
-
setFirebaseConfigJson(ctx: import("koa").
|
|
19
|
+
setFirebaseConfigJson(ctx: import("koa").Context | import("koa").DefaultContext): Promise<any>;
|
|
11
20
|
delFirebaseConfigJson: () => Promise<any>;
|
|
21
|
+
updateMagicLinkSettings(settings: any): Promise<{
|
|
22
|
+
enableMagicLink: any;
|
|
23
|
+
magicLinkUrl: any;
|
|
24
|
+
magicLinkEmailSubject: any;
|
|
25
|
+
magicLinkExpiryHours: any;
|
|
26
|
+
}>;
|
|
12
27
|
encryptJson(key: string, json: string): Promise<any>;
|
|
13
28
|
decryptJson(key: string, hash: string): Promise<any>;
|
|
14
29
|
restart(): Promise<void>;
|
|
@@ -19,7 +34,7 @@ declare const _default: {
|
|
|
19
34
|
get: (entityId: string) => Promise<any>;
|
|
20
35
|
create: (payload: any) => Promise<any>;
|
|
21
36
|
register: (userID: any, payload: any) => Promise<void>;
|
|
22
|
-
list: (pagination: any, nextPageToken: any) => Promise<{
|
|
37
|
+
list: (pagination: any, nextPageToken: any, sort: any, searchQuery: any) => Promise<{
|
|
23
38
|
data: any;
|
|
24
39
|
pageToken: any;
|
|
25
40
|
meta: {
|
|
@@ -36,6 +51,7 @@ declare const _default: {
|
|
|
36
51
|
deleteStrapiUser: (entityId: any) => Promise<any>;
|
|
37
52
|
deleteMany: (entityIDs: any) => Promise<any>;
|
|
38
53
|
setSocialMetaData(): Promise<void>;
|
|
54
|
+
sendPasswordResetEmail: (entityId: any) => Promise<any>;
|
|
39
55
|
};
|
|
40
56
|
firebaseService: ({ strapi }: {
|
|
41
57
|
strapi: any;
|
|
@@ -46,25 +62,84 @@ declare const _default: {
|
|
|
46
62
|
}>;
|
|
47
63
|
validateExchangeTokenPayload: (requestPayload: any) => Promise<any>;
|
|
48
64
|
decodeIDToken: (idToken: any) => Promise<any>;
|
|
49
|
-
overrideFirebaseAccess: (
|
|
65
|
+
overrideFirebaseAccess: (overrideUserId: string, populate?: string[]) => Promise<{
|
|
66
|
+
user: any;
|
|
67
|
+
jwt: any;
|
|
68
|
+
}>;
|
|
50
69
|
checkIfUserExists(decodedToken: any): Promise<any>;
|
|
51
70
|
fetchUser: (decodedToken: any) => Promise<any>;
|
|
52
71
|
generateJWTForCurrentUser: (user: any) => Promise<any>;
|
|
53
72
|
createStrapiUser(decodedToken: any, idToken: any, profileMetaData: any): Promise<any>;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
73
|
+
validateFirebaseToken: (idToken: string, profileMetaData?: any, populate?: string[]) => Promise<{
|
|
74
|
+
user: any;
|
|
75
|
+
jwt: any;
|
|
76
|
+
}>;
|
|
77
|
+
emailLogin: (email: string, password: string, populate?: string[]) => Promise<{
|
|
78
|
+
user: any;
|
|
79
|
+
jwt: any;
|
|
80
|
+
}>;
|
|
81
|
+
forgotPassword: (ctx: any) => Promise<{
|
|
82
|
+
message: string;
|
|
83
|
+
}>;
|
|
84
|
+
resetPassword: (ctx: any) => Promise<{
|
|
85
|
+
user: any;
|
|
65
86
|
jwt: any;
|
|
66
|
-
error?: undefined;
|
|
67
87
|
}>;
|
|
88
|
+
requestMagicLink(ctx: any): Promise<{
|
|
89
|
+
debug: {
|
|
90
|
+
linkSent: any;
|
|
91
|
+
email: string;
|
|
92
|
+
message: any;
|
|
93
|
+
};
|
|
94
|
+
success: boolean;
|
|
95
|
+
message: string;
|
|
96
|
+
requiresFrontend: boolean;
|
|
97
|
+
verificationUrl: any;
|
|
98
|
+
} | {
|
|
99
|
+
success: boolean;
|
|
100
|
+
message: string;
|
|
101
|
+
requiresFrontend: boolean;
|
|
102
|
+
verificationUrl: any;
|
|
103
|
+
}>;
|
|
104
|
+
};
|
|
105
|
+
templateService: ({ strapi }: {
|
|
106
|
+
strapi: any;
|
|
107
|
+
}) => {
|
|
108
|
+
getTemplate(templateType: import("../templates/types").TemplateType): Promise<import("../templates/types").EmailTemplate>;
|
|
109
|
+
compileTemplate(templateString: string): import("lodash").TemplateExecutor;
|
|
110
|
+
validateVariables(variables: Partial<import("../templates/types").TemplateVariables>, required: string[]): void;
|
|
111
|
+
};
|
|
112
|
+
emailService: ({ strapi }: {
|
|
113
|
+
strapi: any;
|
|
114
|
+
}) => {
|
|
115
|
+
sendTemplatedEmail(to: string, templateType: import("../templates/types").TemplateType, variables: Partial<import("../templates/types").TemplateVariables>): Promise<void>;
|
|
116
|
+
sendPasswordResetEmail(user: any, resetLink: string): Promise<{
|
|
117
|
+
success: boolean;
|
|
118
|
+
message: string;
|
|
119
|
+
}>;
|
|
120
|
+
sendMagicLinkEmail(email: string, magicLink: string, config: any): Promise<{
|
|
121
|
+
success: boolean;
|
|
122
|
+
message: string;
|
|
123
|
+
}>;
|
|
124
|
+
};
|
|
125
|
+
firebaseUserDataService: ({ strapi }: {
|
|
126
|
+
strapi: any;
|
|
127
|
+
}) => {
|
|
128
|
+
findOrCreateForUser(userId: string): Promise<any>;
|
|
129
|
+
getByFirebaseUID(firebaseUID: string): Promise<any>;
|
|
130
|
+
updateForUser(userId: string, data: {
|
|
131
|
+
firebaseUserID?: string;
|
|
132
|
+
appleEmail?: string;
|
|
133
|
+
}): Promise<any>;
|
|
134
|
+
};
|
|
135
|
+
autoLinkService: {
|
|
136
|
+
linkAllUsers(strapi: import("@strapi/types/dist/core").Strapi): Promise<import("./autoLinkService").LinkResult>;
|
|
137
|
+
};
|
|
138
|
+
firebaseStrapiLinkService: ({ strapi }: {
|
|
139
|
+
strapi: any;
|
|
140
|
+
}) => {
|
|
141
|
+
buildUserMap(): Promise<Map<any, any>>;
|
|
142
|
+
linkFirebaseUsers(firebaseUsers: any[], uidToUserMap: Map<string, any>, allStrapiUsers: any[]): any[];
|
|
68
143
|
};
|
|
69
144
|
};
|
|
70
145
|
export default _default;
|
|
@@ -3,11 +3,66 @@ declare const _default: ({ strapi }: {
|
|
|
3
3
|
strapi: any;
|
|
4
4
|
}) => {
|
|
5
5
|
init(): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Retrieves and decrypts the Firebase configuration including Web API key and password reset settings
|
|
8
|
+
*
|
|
9
|
+
* @returns Firebase configuration object or null if not configured
|
|
10
|
+
*
|
|
11
|
+
* @throws ApplicationError - When there's an error retrieving or decrypting the configuration
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* Returns an object containing:
|
|
15
|
+
* - `firebaseConfigJson`: Decrypted Firebase service account JSON string
|
|
16
|
+
* - `firebaseWebApiKey`: Firebase Web API key for Identity Toolkit API calls
|
|
17
|
+
* - `passwordRequirementsRegex`: Regex pattern for password validation
|
|
18
|
+
* - `passwordRequirementsMessage`: Error message for invalid passwords
|
|
19
|
+
* - `passwordResetUrl`: URL for password reset page
|
|
20
|
+
* - `passwordResetEmailSubject`: Subject line for reset emails
|
|
21
|
+
*/
|
|
6
22
|
getFirebaseConfigJson(): Promise<{
|
|
7
23
|
firebaseConfigJson: any;
|
|
24
|
+
firebaseWebApiKey: any;
|
|
25
|
+
passwordRequirementsRegex: any;
|
|
26
|
+
passwordRequirementsMessage: any;
|
|
27
|
+
passwordResetUrl: any;
|
|
28
|
+
passwordResetEmailSubject: any;
|
|
29
|
+
enableMagicLink: any;
|
|
30
|
+
magicLinkUrl: any;
|
|
31
|
+
magicLinkEmailSubject: any;
|
|
32
|
+
magicLinkExpiryHours: any;
|
|
8
33
|
}>;
|
|
34
|
+
/**
|
|
35
|
+
* Stores and encrypts Firebase configuration including Web API key and password reset settings
|
|
36
|
+
*
|
|
37
|
+
* @param ctx - Koa context object containing the configuration in request body
|
|
38
|
+
* @returns The saved configuration object with decrypted values
|
|
39
|
+
*
|
|
40
|
+
* @throws ValidationError - When required data is missing
|
|
41
|
+
* @throws ApplicationError - When there's an error saving the configuration
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* Expects request body to contain:
|
|
45
|
+
* - `firebaseConfigJson`: Firebase service account JSON as string
|
|
46
|
+
* - `firebaseWebApiKey`: Firebase Web API key for REST API calls
|
|
47
|
+
* - `passwordRequirementsRegex`: Regex pattern for password validation
|
|
48
|
+
* - `passwordRequirementsMessage`: Error message for invalid passwords
|
|
49
|
+
* - `passwordResetUrl`: URL for password reset page
|
|
50
|
+
* - `passwordResetEmailSubject`: Subject line for reset emails
|
|
51
|
+
*
|
|
52
|
+
* The service account JSON is encrypted using AES before storage,
|
|
53
|
+
* while the Web API key and password settings are stored in plain text.
|
|
54
|
+
*/
|
|
9
55
|
setFirebaseConfigJson(ctx: DefaultContext | Context): Promise<any>;
|
|
10
56
|
delFirebaseConfigJson: () => Promise<any>;
|
|
57
|
+
/**
|
|
58
|
+
* Updates only the magic link settings without affecting other configuration
|
|
59
|
+
*/
|
|
60
|
+
updateMagicLinkSettings(settings: any): Promise<{
|
|
61
|
+
enableMagicLink: any;
|
|
62
|
+
magicLinkUrl: any;
|
|
63
|
+
magicLinkEmailSubject: any;
|
|
64
|
+
magicLinkExpiryHours: any;
|
|
65
|
+
}>;
|
|
11
66
|
encryptJson(key: string, json: string): Promise<any>;
|
|
12
67
|
decryptJson(key: string, hash: string): Promise<any>;
|
|
13
68
|
restart(): Promise<void>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import { EmailTemplate, TemplateVariables, TemplateType } from "../templates/types";
|
|
3
|
+
declare class TemplateService {
|
|
4
|
+
/**
|
|
5
|
+
* Get template with user overrides from configuration
|
|
6
|
+
*/
|
|
7
|
+
getTemplate(templateType: TemplateType): Promise<EmailTemplate>;
|
|
8
|
+
/**
|
|
9
|
+
* Compile a template string using Lodash
|
|
10
|
+
* Uses Lodash default delimiters: <%= %>
|
|
11
|
+
*/
|
|
12
|
+
compileTemplate(templateString: string): _.TemplateExecutor;
|
|
13
|
+
/**
|
|
14
|
+
* Validate that required variables are present
|
|
15
|
+
*/
|
|
16
|
+
validateVariables(variables: Partial<TemplateVariables>, required: string[]): void;
|
|
17
|
+
}
|
|
18
|
+
declare const _default: ({ strapi }: {
|
|
19
|
+
strapi: any;
|
|
20
|
+
}) => TemplateService;
|
|
21
|
+
export default _default;
|
|
@@ -4,7 +4,7 @@ declare const _default: ({ strapi }: {
|
|
|
4
4
|
get: (entityId: string) => Promise<any>;
|
|
5
5
|
create: (payload: any) => Promise<any>;
|
|
6
6
|
register: (userID: any, payload: any) => Promise<void>;
|
|
7
|
-
list: (pagination: any, nextPageToken: any) => Promise<{
|
|
7
|
+
list: (pagination: any, nextPageToken: any, sort: any, searchQuery: any) => Promise<{
|
|
8
8
|
data: any;
|
|
9
9
|
pageToken: any;
|
|
10
10
|
meta: {
|
|
@@ -21,5 +21,6 @@ declare const _default: ({ strapi }: {
|
|
|
21
21
|
deleteStrapiUser: (entityId: any) => Promise<any>;
|
|
22
22
|
deleteMany: (entityIDs: any) => Promise<any>;
|
|
23
23
|
setSocialMetaData(): Promise<void>;
|
|
24
|
+
sendPasswordResetEmail: (entityId: any) => Promise<any>;
|
|
24
25
|
};
|
|
25
26
|
export default _default;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface EmailTemplate {
|
|
2
|
+
subject: string;
|
|
3
|
+
html?: string;
|
|
4
|
+
text?: string;
|
|
5
|
+
htmlFile?: string;
|
|
6
|
+
textFile?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface EmailTemplateConfig {
|
|
9
|
+
passwordReset?: Partial<EmailTemplate>;
|
|
10
|
+
magicLink?: Partial<EmailTemplate>;
|
|
11
|
+
}
|
|
12
|
+
export interface TemplateVariables {
|
|
13
|
+
user: {
|
|
14
|
+
email: string;
|
|
15
|
+
firstName?: string;
|
|
16
|
+
lastName?: string;
|
|
17
|
+
displayName?: string;
|
|
18
|
+
phoneNumber?: string;
|
|
19
|
+
uid: string;
|
|
20
|
+
};
|
|
21
|
+
link?: string;
|
|
22
|
+
resetLink?: string;
|
|
23
|
+
magicLink?: string;
|
|
24
|
+
appName: string;
|
|
25
|
+
appUrl: string;
|
|
26
|
+
expiresIn: string;
|
|
27
|
+
year: number;
|
|
28
|
+
supportEmail?: string;
|
|
29
|
+
}
|
|
30
|
+
export type TemplateType = "passwordReset" | "magicLink";
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
export declare const fetchUser: (currentUser: any, populate?: string[]) => Promise<
|
|
2
|
-
|
|
3
|
-
} & {
|
|
4
|
-
[key: string]: any;
|
|
5
|
-
}>;
|
|
6
|
-
export declare const processMeData: (currentUser: any, populate?: string[]) => Promise<{
|
|
7
|
-
id: import("@strapi/types/dist/data").ID;
|
|
8
|
-
} & {
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
}>;
|
|
1
|
+
export declare const fetchUser: (currentUser: any, populate?: string[]) => Promise<any>;
|
|
2
|
+
export declare const processMeData: (currentUser: any, populate?: string[]) => Promise<any>;
|
|
@@ -1,2 +1,16 @@
|
|
|
1
1
|
import { StrapiUser } from "../../../model/User";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated This utility is deprecated and should not be used.
|
|
4
|
+
* Use firebaseStrapiLinkService.linkFirebaseUsers() instead.
|
|
5
|
+
*
|
|
6
|
+
* This function incorrectly looks for firebaseUserID on the User table,
|
|
7
|
+
* which was moved to the firebase_user_data table.
|
|
8
|
+
*
|
|
9
|
+
* Replacement:
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const linkService = strapi.plugin('firebase-authentication').service('firebaseStrapiLinkService');
|
|
12
|
+
* const uidToUserMap = await linkService.buildUserMap();
|
|
13
|
+
* const linkedUsers = linkService.linkFirebaseUsers(firebaseUsers, uidToUserMap, strapiUsers);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
2
16
|
export declare const formatUserData: (result: any, strapiUsersData: StrapiUser[]) => any;
|