@quatrain/auth-firebase 1.1.22 → 1.1.23
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 +16 -72
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,94 +1,38 @@
|
|
|
1
1
|
# @quatrain/auth-firebase
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Firebase Authentication adapter for `@quatrain/auth`.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Introduction
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- Supports email/password, social logins (Google, Facebook, etc.), and custom tokens.
|
|
9
|
-
- Integrates with Firebase security rules.
|
|
10
|
-
- Uses the `firebase-admin` SDK for server-side operations.
|
|
7
|
+
Firebase Authentication provides backend services to authenticate users. This adapter implements the Quatrain Auth interface using the `firebase-admin` SDK to verify JWTs and manage users.
|
|
11
8
|
|
|
12
9
|
## Installation
|
|
13
10
|
|
|
14
11
|
```bash
|
|
15
12
|
npm install @quatrain/auth-firebase firebase-admin
|
|
13
|
+
# or
|
|
14
|
+
yarn add @quatrain/auth-firebase firebase-admin
|
|
16
15
|
```
|
|
17
16
|
|
|
18
|
-
##
|
|
17
|
+
## Configuration
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
Register the adapter using your Firebase service account credentials.
|
|
21
20
|
|
|
22
21
|
```typescript
|
|
23
22
|
import { Auth } from '@quatrain/auth'
|
|
24
23
|
import { FirebaseAuthAdapter } from '@quatrain/auth-firebase'
|
|
25
24
|
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
const firebaseAuth = new FirebaseAuthAdapter({
|
|
26
|
+
config: {
|
|
27
|
+
projectId: 'your-project-id',
|
|
28
|
+
clientEmail: 'firebase-adminsdk-xxx@your-project-id.iam.gserviceaccount.com',
|
|
29
|
+
privateKey: '-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n'
|
|
30
|
+
}
|
|
32
31
|
})
|
|
33
|
-
Auth.addProvider(adapter, 'default', true)
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### Register a New User
|
|
37
|
-
|
|
38
|
-
```typescript
|
|
39
|
-
import { User } from '@quatrain/backend'
|
|
40
|
-
|
|
41
|
-
const user = new User({
|
|
42
|
-
uid: 'unique-user-id',
|
|
43
|
-
_: {
|
|
44
|
-
name: 'John Doe',
|
|
45
|
-
email: 'john@example.com',
|
|
46
|
-
phone: '+1234567890',
|
|
47
|
-
},
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
const userId = await adapter.register(user, 'password123')
|
|
51
|
-
console.log('User registered with ID:', userId)
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### Verify Auth Token
|
|
55
|
-
|
|
56
|
-
```typescript
|
|
57
|
-
const decodedToken = await adapter.getAuthToken('firebase-id-token')
|
|
58
|
-
console.log('Token verified for user:', decodedToken.uid)
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
### Update User Profile
|
|
62
32
|
|
|
63
|
-
|
|
64
|
-
await adapter.update(user, {
|
|
65
|
-
email: 'newemail@example.com',
|
|
66
|
-
displayName: 'Jane Doe',
|
|
67
|
-
phoneNumber: '+0987654321',
|
|
68
|
-
})
|
|
33
|
+
Auth.addAdapter('firebase', firebaseAuth, true)
|
|
69
34
|
```
|
|
70
35
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
```typescript
|
|
74
|
-
await adapter.delete(user)
|
|
75
|
-
console.log('User deleted')
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### Refresh Token
|
|
79
|
-
|
|
80
|
-
```typescript
|
|
81
|
-
const newTokens = await adapter.refreshToken(refreshToken)
|
|
82
|
-
console.log('New access token:', newTokens.access_token)
|
|
83
|
-
```
|
|
36
|
+
## License
|
|
84
37
|
|
|
85
|
-
|
|
86
|
-
>
|
|
87
|
-
> The following methods are currently not implemented (empty stubs):
|
|
88
|
-
>
|
|
89
|
-
> - `signup()` - Client-side sign in
|
|
90
|
-
> - `signout()` - Sign out user
|
|
91
|
-
> - `revokeAuthToken()` - Revoke tokens
|
|
92
|
-
> - `setCustomUserClaims()` - Set custom claims
|
|
93
|
-
>
|
|
94
|
-
> These methods exist to satisfy the interface but do not perform any operations.
|
|
38
|
+
AGPL-3.0-only
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatrain/auth-firebase",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.23",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"@quatrain/core": "^1.1.48"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@quatrain/auth": "^1.1.
|
|
20
|
-
"@quatrain/backend": "^1.1.
|
|
19
|
+
"@quatrain/auth": "^1.1.28",
|
|
20
|
+
"@quatrain/backend": "^1.1.34",
|
|
21
21
|
"@quatrain/core": "^1.1.48",
|
|
22
22
|
"firebase-admin": "^13.0.1",
|
|
23
23
|
"node-fetch-native": "^1.6.4"
|