@libreapps/auth-firebase 1.1.1
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/.turbo/turbo-build.log +4 -0
- package/CHANGELOG.md +13 -0
- package/LICENSE.md +21 -0
- package/README.md +87 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/server/firebase-support.d.ts +28 -0
- package/dist/server/firebase-support.js +157 -0
- package/dist/server/firebase-support.js.map +1 -0
- package/dist/server/index.d.ts +4 -0
- package/dist/server/index.js +5 -0
- package/dist/server/index.js.map +1 -0
- package/dist/service/firebase-auth-service.d.ts +36 -0
- package/dist/service/firebase-auth-service.js +182 -0
- package/dist/service/firebase-auth-service.js.map +1 -0
- package/dist/service/firebase-support.d.ts +39 -0
- package/dist/service/firebase-support.js +187 -0
- package/dist/service/firebase-support.js.map +1 -0
- package/dist/service/index.d.ts +6 -0
- package/dist/service/index.js +7 -0
- package/dist/service/index.js.map +1 -0
- package/dist/service/wallet-support.d.ts +11 -0
- package/dist/service/wallet-support.js +85 -0
- package/dist/service/wallet-support.js.map +1 -0
- package/index.ts +30 -0
- package/package.json +51 -0
- package/server/firebase-support.ts +180 -0
- package/server/index.ts +11 -0
- package/service/firebase-auth-service.ts +233 -0
- package/service/firebase-support.ts +234 -0
- package/service/index.ts +20 -0
- package/service/wallet-support.ts +103 -0
- package/tsconfig.json +15 -0
package/CHANGELOG.md
ADDED
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 LibreApps.com
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# @libreapps/auth-firebase
|
|
2
|
+
|
|
3
|
+
Firebase authentication provider for `@libreapps/auth`.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
This package is **OPTIONAL**. Only install if you need Firebase authentication.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @libreapps/auth-firebase firebase firebase-admin
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Client-side Setup
|
|
16
|
+
|
|
17
|
+
Register the Firebase auth provider in your app's entry point:
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
// app/providers.tsx or similar
|
|
21
|
+
import { FirebaseAuthService, isFirebaseConfigured } from '@libreapps/auth-firebase'
|
|
22
|
+
import { registerAuthProvider } from '@libreapps/auth'
|
|
23
|
+
|
|
24
|
+
// Register Firebase as the auth provider (only if configured)
|
|
25
|
+
if (isFirebaseConfigured()) {
|
|
26
|
+
registerAuthProvider('firebase', FirebaseAuthService)
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Server-side Setup
|
|
31
|
+
|
|
32
|
+
For server-side authentication (Next.js Server Components, API routes):
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
// In Server Components or API routes
|
|
36
|
+
import { getUserServerSide, createSessionCookie } from '@libreapps/auth-firebase/server'
|
|
37
|
+
|
|
38
|
+
// Get current user from session cookie
|
|
39
|
+
const user = await getUserServerSide()
|
|
40
|
+
|
|
41
|
+
// Create session cookie after login
|
|
42
|
+
const sessionCookie = await createSessionCookie(idToken, { expiresIn: 60 * 60 * 24 * 5 * 1000 })
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Environment Variables
|
|
46
|
+
|
|
47
|
+
### Client-side (NEXT_PUBLIC_*)
|
|
48
|
+
|
|
49
|
+
```env
|
|
50
|
+
NEXT_PUBLIC_FIREBASE_API_KEY=your-api-key
|
|
51
|
+
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
|
|
52
|
+
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your-project
|
|
53
|
+
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your-project.appspot.com
|
|
54
|
+
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=123456789
|
|
55
|
+
NEXT_PUBLIC_FIREBASE_APP_ID=1:123456789:web:abcdef
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Server-side (Firebase Admin)
|
|
59
|
+
|
|
60
|
+
```env
|
|
61
|
+
FIREBASE_PROJECT_ID=your-project
|
|
62
|
+
FIREBASE_CLIENT_EMAIL=firebase-adminsdk-xxx@your-project.iam.gserviceaccount.com
|
|
63
|
+
FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Without Firebase
|
|
67
|
+
|
|
68
|
+
If you don't need Firebase, simply don't install this package. The `@libreapps/auth` package works without Firebase - it will use a stub implementation that returns graceful failures for all auth operations.
|
|
69
|
+
|
|
70
|
+
## Exports
|
|
71
|
+
|
|
72
|
+
### Main (`@libreapps/auth-firebase`)
|
|
73
|
+
|
|
74
|
+
- `FirebaseAuthService` - The Firebase auth service implementation
|
|
75
|
+
- `isFirebaseConfigured()` - Check if Firebase client config is present
|
|
76
|
+
|
|
77
|
+
### Server (`@libreapps/auth-firebase/server`)
|
|
78
|
+
|
|
79
|
+
- `getUserServerSide()` - Get current user from session cookie
|
|
80
|
+
- `generateCustomToken()` - Generate a custom token
|
|
81
|
+
- `createSessionCookie()` - Create a session cookie from ID token
|
|
82
|
+
- `revokeAllSessions()` - Revoke all sessions for current user
|
|
83
|
+
- `isFirebaseAdminConfigured()` - Check if Firebase Admin is configured
|
|
84
|
+
|
|
85
|
+
### Service (`@libreapps/auth-firebase/service`)
|
|
86
|
+
|
|
87
|
+
- Low-level Firebase auth functions (for advanced use)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @libreapps/auth-firebase
|
|
3
|
+
*
|
|
4
|
+
* Firebase authentication provider for @libreapps/auth
|
|
5
|
+
*
|
|
6
|
+
* This package is OPTIONAL - only install if you need Firebase authentication.
|
|
7
|
+
* The core @libreapps/auth package works without Firebase.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { FirebaseAuthService } from '@libreapps/auth-firebase'
|
|
12
|
+
* import { registerAuthProvider } from '@libreapps/auth'
|
|
13
|
+
*
|
|
14
|
+
* // Register Firebase as the auth provider
|
|
15
|
+
* if (FirebaseAuthService.isConfigured()) {
|
|
16
|
+
* registerAuthProvider('firebase', FirebaseAuthService)
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export { FirebaseAuthService, isFirebaseConfigured } from './service';
|
|
21
|
+
export type { AuthService, AuthServiceConf, LibreAppsUserInfo, LibreAppsUserInfoValue } from '@libreapps/auth';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @libreapps/auth-firebase
|
|
3
|
+
*
|
|
4
|
+
* Firebase authentication provider for @libreapps/auth
|
|
5
|
+
*
|
|
6
|
+
* This package is OPTIONAL - only install if you need Firebase authentication.
|
|
7
|
+
* The core @libreapps/auth package works without Firebase.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { FirebaseAuthService } from '@libreapps/auth-firebase'
|
|
12
|
+
* import { registerAuthProvider } from '@libreapps/auth'
|
|
13
|
+
*
|
|
14
|
+
* // Register Firebase as the auth provider
|
|
15
|
+
* if (FirebaseAuthService.isConfigured()) {
|
|
16
|
+
* registerAuthProvider('firebase', FirebaseAuthService)
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
// Client-side exports
|
|
21
|
+
export { FirebaseAuthService, isFirebaseConfigured } from './service';
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,sBAAsB;AACtB,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side Firebase authentication
|
|
3
|
+
* For static builds, these functions return null/false gracefully.
|
|
4
|
+
*/
|
|
5
|
+
import type { LibreAppsUserInfoValue } from '@libreapps/auth';
|
|
6
|
+
/**
|
|
7
|
+
* Check if Firebase Admin is properly configured
|
|
8
|
+
*/
|
|
9
|
+
export declare function isFirebaseAdminConfigured(): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Get the current user from server-side session cookie
|
|
12
|
+
*/
|
|
13
|
+
export declare function getUserServerSide(): Promise<LibreAppsUserInfoValue | null>;
|
|
14
|
+
/**
|
|
15
|
+
* Generate a custom token for the current session
|
|
16
|
+
*/
|
|
17
|
+
export declare function generateCustomToken(): Promise<{
|
|
18
|
+
success: boolean;
|
|
19
|
+
token: string | null;
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* Create a session cookie from an ID token
|
|
23
|
+
*/
|
|
24
|
+
export declare function createSessionCookie(idToken: string, sessionCookieOptions: any): Promise<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Revoke all sessions for the current user
|
|
27
|
+
*/
|
|
28
|
+
export declare function revokeAllSessions(session: string): Promise<void>;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side Firebase authentication
|
|
3
|
+
* For static builds, these functions return null/false gracefully.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Check if Firebase Admin is properly configured
|
|
7
|
+
*/
|
|
8
|
+
export function isFirebaseAdminConfigured() {
|
|
9
|
+
return !!(process.env.FIREBASE_CLIENT_EMAIL &&
|
|
10
|
+
process.env.FIREBASE_PROJECT_ID &&
|
|
11
|
+
process.env.FIREBASE_PRIVATE_KEY);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get the current user from server-side session cookie
|
|
15
|
+
*/
|
|
16
|
+
export async function getUserServerSide() {
|
|
17
|
+
// Check if we're in a server environment
|
|
18
|
+
if (typeof window !== 'undefined') {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
// Dynamic imports to prevent bundling issues in static export
|
|
23
|
+
const { cookies } = await import('next/headers');
|
|
24
|
+
const { initializeApp, getApps, cert } = await import('firebase-admin/app');
|
|
25
|
+
const { getAuth } = await import('firebase-admin/auth');
|
|
26
|
+
const { getFirestore } = await import('firebase-admin/firestore');
|
|
27
|
+
if (!isFirebaseAdminConfigured()) {
|
|
28
|
+
console.warn('Firebase credentials not configured');
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const firebaseApp = getApps().find((it) => it.name === 'firebase-admin-app') ||
|
|
32
|
+
initializeApp({
|
|
33
|
+
credential: cert({
|
|
34
|
+
clientEmail: process.env.FIREBASE_CLIENT_EMAIL,
|
|
35
|
+
projectId: process.env.FIREBASE_PROJECT_ID,
|
|
36
|
+
privateKey: process.env.FIREBASE_PRIVATE_KEY.replace(/\\n/g, '\n')
|
|
37
|
+
}),
|
|
38
|
+
}, 'firebase-admin-app');
|
|
39
|
+
const auth = getAuth(firebaseApp);
|
|
40
|
+
const db = getFirestore(firebaseApp, 'accounts');
|
|
41
|
+
const c = await cookies();
|
|
42
|
+
const session = c.get('__session')?.value;
|
|
43
|
+
if (!session)
|
|
44
|
+
return null;
|
|
45
|
+
try {
|
|
46
|
+
const isRevoked = !(await auth.verifySessionCookie(session, true));
|
|
47
|
+
if (isRevoked)
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
const decodedIdToken = await auth.verifySessionCookie(session);
|
|
54
|
+
const currentUser = await auth.getUser(decodedIdToken.uid);
|
|
55
|
+
const walletAddress = await db.collection('USER_INFO').doc(currentUser.email ?? '').get();
|
|
56
|
+
return {
|
|
57
|
+
email: currentUser.email ?? '',
|
|
58
|
+
displayName: currentUser.displayName ?? null,
|
|
59
|
+
walletAddress: walletAddress.get('walletAddress') ?? null,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
console.warn('Server-side auth not available:', error);
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Generate a custom token for the current session
|
|
69
|
+
*/
|
|
70
|
+
export async function generateCustomToken() {
|
|
71
|
+
if (typeof window !== 'undefined') {
|
|
72
|
+
return { success: false, token: null };
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
const { cookies } = await import('next/headers');
|
|
76
|
+
const { initializeApp, getApps, cert } = await import('firebase-admin/app');
|
|
77
|
+
const { getAuth } = await import('firebase-admin/auth');
|
|
78
|
+
if (!isFirebaseAdminConfigured()) {
|
|
79
|
+
return { success: false, token: null };
|
|
80
|
+
}
|
|
81
|
+
const firebaseApp = getApps().find((it) => it.name === 'firebase-admin-app') ||
|
|
82
|
+
initializeApp({
|
|
83
|
+
credential: cert({
|
|
84
|
+
clientEmail: process.env.FIREBASE_CLIENT_EMAIL,
|
|
85
|
+
projectId: process.env.FIREBASE_PROJECT_ID,
|
|
86
|
+
privateKey: process.env.FIREBASE_PRIVATE_KEY.replace(/\\n/g, '\n')
|
|
87
|
+
}),
|
|
88
|
+
}, 'firebase-admin-app');
|
|
89
|
+
const auth = getAuth(firebaseApp);
|
|
90
|
+
const c = await cookies();
|
|
91
|
+
const session = c.get('__session')?.value;
|
|
92
|
+
if (!session)
|
|
93
|
+
return { success: false, token: null };
|
|
94
|
+
const decodedIdToken = await auth.verifySessionCookie(session);
|
|
95
|
+
const currentUser = await auth.getUser(decodedIdToken.uid);
|
|
96
|
+
const token = await auth.createCustomToken(currentUser.uid);
|
|
97
|
+
return { success: true, token };
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
console.warn('Token generation not available:', error);
|
|
101
|
+
return { success: false, token: null };
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Create a session cookie from an ID token
|
|
106
|
+
*/
|
|
107
|
+
export async function createSessionCookie(idToken, sessionCookieOptions) {
|
|
108
|
+
try {
|
|
109
|
+
const { initializeApp, getApps, cert } = await import('firebase-admin/app');
|
|
110
|
+
const { getAuth } = await import('firebase-admin/auth');
|
|
111
|
+
if (!isFirebaseAdminConfigured()) {
|
|
112
|
+
throw new Error('Firebase not configured');
|
|
113
|
+
}
|
|
114
|
+
const firebaseApp = getApps().find((it) => it.name === 'firebase-admin-app') ||
|
|
115
|
+
initializeApp({
|
|
116
|
+
credential: cert({
|
|
117
|
+
clientEmail: process.env.FIREBASE_CLIENT_EMAIL,
|
|
118
|
+
projectId: process.env.FIREBASE_PROJECT_ID,
|
|
119
|
+
privateKey: process.env.FIREBASE_PRIVATE_KEY.replace(/\\n/g, '\n')
|
|
120
|
+
}),
|
|
121
|
+
}, 'firebase-admin-app');
|
|
122
|
+
const auth = getAuth(firebaseApp);
|
|
123
|
+
return auth.createSessionCookie(idToken, sessionCookieOptions);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
console.warn('Session cookie creation not available:', error);
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Revoke all sessions for the current user
|
|
132
|
+
*/
|
|
133
|
+
export async function revokeAllSessions(session) {
|
|
134
|
+
try {
|
|
135
|
+
const { initializeApp, getApps, cert } = await import('firebase-admin/app');
|
|
136
|
+
const { getAuth } = await import('firebase-admin/auth');
|
|
137
|
+
if (!isFirebaseAdminConfigured()) {
|
|
138
|
+
throw new Error('Firebase not configured');
|
|
139
|
+
}
|
|
140
|
+
const firebaseApp = getApps().find((it) => it.name === 'firebase-admin-app') ||
|
|
141
|
+
initializeApp({
|
|
142
|
+
credential: cert({
|
|
143
|
+
clientEmail: process.env.FIREBASE_CLIENT_EMAIL,
|
|
144
|
+
projectId: process.env.FIREBASE_PROJECT_ID,
|
|
145
|
+
privateKey: process.env.FIREBASE_PRIVATE_KEY.replace(/\\n/g, '\n')
|
|
146
|
+
}),
|
|
147
|
+
}, 'firebase-admin-app');
|
|
148
|
+
const auth = getAuth(firebaseApp);
|
|
149
|
+
const decodedIdToken = await auth.verifySessionCookie(session);
|
|
150
|
+
return await auth.revokeRefreshTokens(decodedIdToken.sub);
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
console.warn('Session revocation not available:', error);
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=firebase-support.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firebase-support.js","sourceRoot":"","sources":["../../server/firebase-support.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,MAAM,UAAU,yBAAyB;IACvC,OAAO,CAAC,CAAC,CACP,OAAO,CAAC,GAAG,CAAC,qBAAqB;QACjC,OAAO,CAAC,GAAG,CAAC,mBAAmB;QAC/B,OAAO,CAAC,GAAG,CAAC,oBAAoB,CACjC,CAAA;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACrC,yCAAyC;IACzC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,CAAC;QACH,8DAA8D;QAC9D,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAA;QAChD,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAA;QAE3E,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,CAAA;QACvD,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,0BAA0B,CAAC,CAAA;QAEjE,IAAI,CAAC,yBAAyB,EAAE,EAAE,CAAC;YACjC,OAAO,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAA;YACnD,OAAO,IAAI,CAAA;QACb,CAAC;QAED,MAAM,WAAW,GAAG,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,KAAK,oBAAoB,CAAC;YAC1E,aAAa,CAAC;gBACZ,UAAU,EAAE,IAAI,CAAC;oBACf,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAq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EAAE,IAAI,CAAC;iBACpE,CAAC;aACH,EAAE,oBAAoB,CAAC,CAAA;QAE1B,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;QACjC,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAA;QAC9D,OAAO,MAAM,IAAI,CAAC,mBAAmB,CAAC,cAAc,CAAC,GAAG,CAAC,CAAA;IAC3D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,mCAAmC,EAAE,KAAK,CAAC,CAAA;QACxD,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,yBAAyB,EAC1B,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Firebase Authentication Service Implementation
|
|
3
|
+
* Implements the AuthService interface using Firebase as the auth provider.
|
|
4
|
+
*/
|
|
5
|
+
import type { AuthService, AuthServiceConf, LibreAppsUserInfo, LibreAppsUserInfoValue } from '@libreapps/auth';
|
|
6
|
+
export declare class FirebaseAuthService implements AuthService {
|
|
7
|
+
private _hzUser;
|
|
8
|
+
constructor(conf: AuthServiceConf, user: LibreAppsUserInfoValue | null);
|
|
9
|
+
static isConfigured(): boolean;
|
|
10
|
+
get user(): LibreAppsUserInfo | null;
|
|
11
|
+
get loggedIn(): boolean;
|
|
12
|
+
signupEmailAndPassword: (email: string, password: string) => Promise<{
|
|
13
|
+
success: boolean;
|
|
14
|
+
userInfo: LibreAppsUserInfo | null;
|
|
15
|
+
message?: string;
|
|
16
|
+
}>;
|
|
17
|
+
loginEmailAndPassword: (email: string, password: string) => Promise<{
|
|
18
|
+
success: boolean;
|
|
19
|
+
userInfo: LibreAppsUserInfo | null;
|
|
20
|
+
message?: string;
|
|
21
|
+
}>;
|
|
22
|
+
loginWithProvider: (provider: "google" | "facebook" | "github") => Promise<{
|
|
23
|
+
success: boolean;
|
|
24
|
+
userInfo: LibreAppsUserInfo | null;
|
|
25
|
+
}>;
|
|
26
|
+
loginWithCustomToken: (token: string) => Promise<{
|
|
27
|
+
success: boolean;
|
|
28
|
+
userInfo: LibreAppsUserInfo | null;
|
|
29
|
+
}>;
|
|
30
|
+
associateWallet: () => Promise<void>;
|
|
31
|
+
logout: () => Promise<{
|
|
32
|
+
success: boolean;
|
|
33
|
+
}>;
|
|
34
|
+
setServerSideUser: (user: LibreAppsUserInfoValue | null) => void;
|
|
35
|
+
}
|
|
36
|
+
export default FirebaseAuthService;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Firebase Authentication Service Implementation
|
|
3
|
+
* Implements the AuthService interface using Firebase as the auth provider.
|
|
4
|
+
*/
|
|
5
|
+
import { makeAutoObservable, makeObservable, computed } from 'mobx';
|
|
6
|
+
import { auth as fbAuth, signupWithEmailAndPassword, loginWithCustomToken, loginWithEmailAndPassword, loginWithProvider, logoutBackend, isFirebaseConfigured } from './firebase-support';
|
|
7
|
+
import { associateWalletAddressWithAccount, getAssociatedWalletAddress } from './wallet-support';
|
|
8
|
+
class LibreAppsUserInfoStore {
|
|
9
|
+
constructor() {
|
|
10
|
+
this._email = '';
|
|
11
|
+
this._displayName = null;
|
|
12
|
+
this._walletAddress = null;
|
|
13
|
+
makeAutoObservable(this);
|
|
14
|
+
}
|
|
15
|
+
get email() { return this._email; }
|
|
16
|
+
get displayName() { return this._displayName; }
|
|
17
|
+
get walletAddress() { return this._walletAddress; }
|
|
18
|
+
clear() {
|
|
19
|
+
this._email = '';
|
|
20
|
+
this._displayName = null;
|
|
21
|
+
this._walletAddress = null;
|
|
22
|
+
}
|
|
23
|
+
set(v) {
|
|
24
|
+
this._email = v.email;
|
|
25
|
+
this._displayName = v.displayName;
|
|
26
|
+
this._walletAddress = v.walletAddress;
|
|
27
|
+
}
|
|
28
|
+
get isValid() {
|
|
29
|
+
return (this._email.length > 0);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export class FirebaseAuthService {
|
|
33
|
+
constructor(conf, user) {
|
|
34
|
+
this._hzUser = new LibreAppsUserInfoStore();
|
|
35
|
+
this.signupEmailAndPassword = async (email, password) => {
|
|
36
|
+
try {
|
|
37
|
+
this._hzUser.clear();
|
|
38
|
+
const res = await signupWithEmailAndPassword(email, password);
|
|
39
|
+
if (res.success && res.user) {
|
|
40
|
+
const walletAddress = res.user.email ? await getAssociatedWalletAddress(res.user.email) : undefined;
|
|
41
|
+
this._hzUser.set({
|
|
42
|
+
email: res.user.email ?? '',
|
|
43
|
+
displayName: res.user.displayName ?? null,
|
|
44
|
+
walletAddress: walletAddress?.result ?? null
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
success: true,
|
|
48
|
+
userInfo: this._hzUser,
|
|
49
|
+
message: res.message
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
success: false,
|
|
54
|
+
userInfo: null,
|
|
55
|
+
message: res.message
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
console.error('Error signing in with Firebase auth', e);
|
|
60
|
+
return { success: false, userInfo: null, message: 'Error signing in with Firebase auth' };
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
this.loginEmailAndPassword = async (email, password) => {
|
|
64
|
+
try {
|
|
65
|
+
this._hzUser.clear();
|
|
66
|
+
const res = await loginWithEmailAndPassword(email, password);
|
|
67
|
+
if (res.success && res.user) {
|
|
68
|
+
const walletAddress = res.user.email ? await getAssociatedWalletAddress(res.user.email) : undefined;
|
|
69
|
+
this._hzUser.set({
|
|
70
|
+
email: res.user.email ?? '',
|
|
71
|
+
displayName: res.user.displayName ?? null,
|
|
72
|
+
walletAddress: walletAddress?.result ?? null
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
success: true,
|
|
76
|
+
userInfo: this._hzUser,
|
|
77
|
+
message: res.message
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
success: false,
|
|
82
|
+
userInfo: null,
|
|
83
|
+
message: res.message
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
console.error('Error signing in with Firebase auth', e);
|
|
88
|
+
return { success: false, userInfo: null, message: 'Error signing in with Firebase auth' };
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
this.loginWithProvider = async (provider) => {
|
|
92
|
+
try {
|
|
93
|
+
this._hzUser.clear();
|
|
94
|
+
const res = await loginWithProvider(provider);
|
|
95
|
+
if (res.success && res.user) {
|
|
96
|
+
const walletAddress = res.user.email ? await getAssociatedWalletAddress(res.user.email) : undefined;
|
|
97
|
+
this._hzUser.set({
|
|
98
|
+
email: res.user.email ?? '',
|
|
99
|
+
displayName: res.user.displayName ?? null,
|
|
100
|
+
walletAddress: walletAddress?.result ?? null
|
|
101
|
+
});
|
|
102
|
+
return {
|
|
103
|
+
success: true,
|
|
104
|
+
userInfo: this._hzUser
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
success: false,
|
|
109
|
+
userInfo: null
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
catch (e) {
|
|
113
|
+
console.error('Error signing in with Firebase auth', e);
|
|
114
|
+
return { success: false, userInfo: null };
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
this.loginWithCustomToken = async (token) => {
|
|
118
|
+
try {
|
|
119
|
+
this._hzUser.clear();
|
|
120
|
+
const res = await loginWithCustomToken(token);
|
|
121
|
+
if (res.success && res.user) {
|
|
122
|
+
const walletAddress = res.user.email ? await getAssociatedWalletAddress(res.user.email) : undefined;
|
|
123
|
+
this._hzUser.set({
|
|
124
|
+
email: res.user.email ?? '',
|
|
125
|
+
displayName: res.user.displayName ?? null,
|
|
126
|
+
walletAddress: walletAddress?.result ?? null
|
|
127
|
+
});
|
|
128
|
+
return {
|
|
129
|
+
success: true,
|
|
130
|
+
userInfo: this._hzUser
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
success: false,
|
|
135
|
+
userInfo: null
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
catch (e) {
|
|
139
|
+
console.error('Error signing in with Firebase auth', e);
|
|
140
|
+
return { success: false, userInfo: null };
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
this.associateWallet = async () => {
|
|
144
|
+
if (this._hzUser.isValid) {
|
|
145
|
+
const res = await associateWalletAddressWithAccount(this._hzUser.email);
|
|
146
|
+
if (!res.error) {
|
|
147
|
+
this._hzUser._walletAddress = res.result ?? null;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
this.logout = async () => {
|
|
152
|
+
if (fbAuth) {
|
|
153
|
+
await fbAuth.signOut();
|
|
154
|
+
}
|
|
155
|
+
this._hzUser.clear();
|
|
156
|
+
return await logoutBackend();
|
|
157
|
+
};
|
|
158
|
+
this.setServerSideUser = (user) => {
|
|
159
|
+
if (user) {
|
|
160
|
+
this._hzUser.set(user);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
makeObservable(this, {
|
|
164
|
+
loggedIn: computed,
|
|
165
|
+
user: computed
|
|
166
|
+
});
|
|
167
|
+
if (user) {
|
|
168
|
+
this._hzUser.set(user);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
static isConfigured() {
|
|
172
|
+
return isFirebaseConfigured();
|
|
173
|
+
}
|
|
174
|
+
get user() {
|
|
175
|
+
return this._hzUser.isValid ? this._hzUser : null;
|
|
176
|
+
}
|
|
177
|
+
get loggedIn() {
|
|
178
|
+
return this._hzUser.isValid;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
export default FirebaseAuthService;
|
|
182
|
+
//# sourceMappingURL=firebase-auth-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firebase-auth-service.js","sourceRoot":"","sources":["../../service/firebase-auth-service.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AAInE,OAAO,EACL,IAAI,IAAI,MAAM,EACd,0BAA0B,EAC1B,oBAAoB,EACpB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACrB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,iCAAiC,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AAEhG,MAAM,sBAAsB;IAE1B;QAIA,WAAM,GAAW,EAAE,CAAA;QACnB,iBAAY,GAAkB,IAAI,CAAA;QAClC,mBAAc,GAAkB,IAAI,CAAA;QALlC,kBAAkB,CAAC,IAAI,CAAC,CAAA;IAC1B,CAAC;IAMD,IAAI,KAAK,KAAa,OAAO,IAAI,CAAC,MAAM,CAAA,CAAA,CAAC;IACzC,IAAI,WAAW,KAAoB,OAAO,IAAI,CAAC,YAAY,CAAA,CAAA,CAAC;IAC5D,IAAI,aAAa,KAAoB,OAAO,IAAI,CAAC,cAAc,CAAA,CAAA,CAAC;IAEhE,KAAK;QACH,IAAI,CAAC,MAAM,GAAG,EAAE,CAAA;QAChB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAA;QACxB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAA;IAC5B,CAAC;IAED,GAAG,CAAC,CAAyB;QAC3B,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,CAAA;QACrB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,WAAW,CAAA;QACjC,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,aAAa,CAAA;IACvC,CAAC;IAED,IAAI,O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KAAK,IAAmC,EAAE;YACjD,IAAI,MAAM,EAAE,CAAC;gBACX,MAAM,MAAM,CAAC,OAAO,EAAE,CAAA;YACxB,CAAC;YACD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;YACpB,OAAO,MAAM,aAAa,EAAE,CAAA;QAC9B,CAAC,CAAA;QAED,sBAAiB,GAAG,CAAC,IAAmC,EAAE,EAAE;YAC1D,IAAI,IAAI,EAAE,CAAC;gBACT,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;YACxB,CAAC;QACH,CAAC,CAAA;QA7KC,cAAc,CAAC,IAAI,EAAE;YACnB,QAAQ,EAAE,QAAQ;YAClB,IAAI,EAAE,QAAQ;SACf,CAAC,CAAA;QAEF,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACxB,CAAC;IACH,CAAC;IAED,MAAM,CAAC,YAAY;QACjB,OAAO,oBAAoB,EAAE,CAAA;IAC/B,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA;IACnD,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAA;IAC7B,CAAC;CA0JF;AAED,eAAe,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Firebase Client-side Authentication Support
|
|
3
|
+
* This module provides Firebase authentication methods for the client-side.
|
|
4
|
+
*/
|
|
5
|
+
import { type User, type Auth } from 'firebase/auth';
|
|
6
|
+
import { type Firestore } from 'firebase/firestore';
|
|
7
|
+
export declare const firebaseConfig: {
|
|
8
|
+
apiKey: string | undefined;
|
|
9
|
+
authDomain: string | undefined;
|
|
10
|
+
projectId: string | undefined;
|
|
11
|
+
storageBucket: string | undefined;
|
|
12
|
+
messagingSenderId: string | undefined;
|
|
13
|
+
appId: string | undefined;
|
|
14
|
+
};
|
|
15
|
+
export declare const isFirebaseConfigured: () => boolean;
|
|
16
|
+
declare let auth: Auth | null;
|
|
17
|
+
declare let db: Firestore | null;
|
|
18
|
+
export { auth, db };
|
|
19
|
+
export declare function loginWithProvider(provider: string): Promise<{
|
|
20
|
+
success: boolean;
|
|
21
|
+
user: User | null;
|
|
22
|
+
}>;
|
|
23
|
+
export declare function signupWithEmailAndPassword(email: string, password: string): Promise<{
|
|
24
|
+
success: boolean;
|
|
25
|
+
user?: User;
|
|
26
|
+
message?: string;
|
|
27
|
+
}>;
|
|
28
|
+
export declare function loginWithEmailAndPassword(email: string, password: string): Promise<{
|
|
29
|
+
success: boolean;
|
|
30
|
+
user?: User;
|
|
31
|
+
message?: string;
|
|
32
|
+
}>;
|
|
33
|
+
export declare function loginWithCustomToken(token: string): Promise<{
|
|
34
|
+
success: boolean;
|
|
35
|
+
user?: User;
|
|
36
|
+
}>;
|
|
37
|
+
export declare function logoutBackend(): Promise<{
|
|
38
|
+
success: boolean;
|
|
39
|
+
}>;
|