@mastra/auth-firebase 0.10.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.
@@ -0,0 +1,30 @@
1
+
2
+ > @mastra/auth-firebase@0.10.0 build /home/runner/work/mastra/mastra/auth/firebase
3
+ > tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake
4
+
5
+ CLI Building entry: src/index.ts
6
+ CLI Using tsconfig: tsconfig.json
7
+ CLI tsup v8.4.0
8
+ TSC Build start
9
+ TSC ⚡️ Build success in 11101ms
10
+ DTS Build start
11
+ CLI Target: es2022
12
+ Analysis will use the bundled TypeScript version 5.8.3
13
+ Writing package typings: /home/runner/work/mastra/mastra/auth/firebase/dist/_tsup-dts-rollup.d.ts
14
+ Analysis will use the bundled TypeScript version 5.8.3
15
+ Writing package typings: /home/runner/work/mastra/mastra/auth/firebase/dist/_tsup-dts-rollup.d.cts
16
+ DTS ⚡️ Build success in 17515ms
17
+ CLI Cleaning output folder
18
+ ESM Build start
19
+ CJS Build start
20
+ ESM dist/index.js 11.55 KB
21
+ ESM dist/getMachineId-darwin-UJH25LDA.js 770.00 B
22
+ ESM dist/getMachineId-linux-YF3RLZNP.js 440.00 B
23
+ ESM dist/getMachineId-bsd-IPBZSYCM.js 564.00 B
24
+ ESM dist/getMachineId-win-PKATJI4A.js 738.00 B
25
+ ESM dist/chunk-N62AETLJ.js 334.00 B
26
+ ESM dist/getMachineId-unsupported-UOUTBEEW.js 382.00 B
27
+ ESM dist/chunk-JLXWUSDO.js 32.51 KB
28
+ ESM ⚡️ Build success in 2453ms
29
+ CJS dist/index.cjs 53.73 KB
30
+ CJS ⚡️ Build success in 2454ms
package/CHANGELOG.md ADDED
@@ -0,0 +1 @@
1
+ # @mastra/auth-firebase
package/LICENSE.md ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2025 Mastra AI, Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # @mastra/auth-firebase
2
+
3
+ A Firebase authentication integration package for Mastra applications. This package provides seamless integration with Firebase Authentication and Firestore for user authentication and authorization.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @mastra/auth-firebase
9
+ # or
10
+ yarn add @mastra/auth-firebase
11
+ # or
12
+ pnpm add @mastra/auth-firebase
13
+ ```
14
+
15
+ ## Features
16
+
17
+ - Firebase Authentication integration
18
+ - Firestore-based user authorization
19
+ - Support for service account credentials
20
+ - Automatic token verification
21
+ - User access control through Firestore
22
+
23
+ ## Usage
24
+
25
+ ```typescript
26
+ import { Mastra } from '@mastra/core';
27
+ import { MastraAuthFirebase } from '@mastra/auth-firebase';
28
+
29
+ // Initialize with default configuration
30
+ const auth = new MastraAuthFirebase();
31
+
32
+ // Or with custom options
33
+ const auth = new MastraAuthFirebase({
34
+ serviceAccount: 'path/to/service-account.json',
35
+ databaseId: 'your-database-id',
36
+ });
37
+
38
+ // Enable auth in Mastra
39
+ const mastra = new Mastra({
40
+ ...
41
+ server: {
42
+ experimental_auth: auth,
43
+ },
44
+ });
45
+ ```
46
+
47
+ ## Configuration
48
+
49
+ The package can be configured through constructor options or environment variables:
50
+
51
+ ### Constructor Options
52
+
53
+ - `serviceAccount`: Path to Firebase service account JSON file
54
+ - `databaseId`: Firestore database ID
55
+
56
+ ### Environment Variables
57
+
58
+ - `FIREBASE_SERVICE_ACCOUNT`: Path to Firebase service account JSON file
59
+ - `FIRESTORE_DATABASE_ID` or `FIREBASE_DATABASE_ID`: Firestore database ID
60
+
61
+ ## User Authorization
62
+
63
+ The package uses Firestore to manage user access. It expects a collection named `user_access` with documents keyed by user UIDs. The presence of a document in this collection determines whether a user is authorized.
64
+
65
+ ## License
66
+
67
+ Elastic-2.0
@@ -0,0 +1,20 @@
1
+ import admin from 'firebase-admin';
2
+ import { MastraAuthProvider } from '@mastra/core/server';
3
+ import type { MastraAuthProviderOptions } from '@mastra/core/server';
4
+
5
+ declare type FirebaseUser = admin.auth.DecodedIdToken;
6
+
7
+ export declare class MastraAuthFirebase extends MastraAuthProvider<FirebaseUser> {
8
+ private serviceAccount;
9
+ private databaseId;
10
+ constructor(options?: MastraAuthFirebaseOptions);
11
+ authenticateToken(token: string): Promise<FirebaseUser | null>;
12
+ authorizeUser(user: FirebaseUser): Promise<boolean>;
13
+ }
14
+
15
+ declare interface MastraAuthFirebaseOptions extends MastraAuthProviderOptions<FirebaseUser> {
16
+ databaseId?: string;
17
+ serviceAccount?: string;
18
+ }
19
+
20
+ export { }
@@ -0,0 +1,20 @@
1
+ import admin from 'firebase-admin';
2
+ import { MastraAuthProvider } from '@mastra/core/server';
3
+ import type { MastraAuthProviderOptions } from '@mastra/core/server';
4
+
5
+ declare type FirebaseUser = admin.auth.DecodedIdToken;
6
+
7
+ export declare class MastraAuthFirebase extends MastraAuthProvider<FirebaseUser> {
8
+ private serviceAccount;
9
+ private databaseId;
10
+ constructor(options?: MastraAuthFirebaseOptions);
11
+ authenticateToken(token: string): Promise<FirebaseUser | null>;
12
+ authorizeUser(user: FirebaseUser): Promise<boolean>;
13
+ }
14
+
15
+ declare interface MastraAuthFirebaseOptions extends MastraAuthProviderOptions<FirebaseUser> {
16
+ databaseId?: string;
17
+ serviceAccount?: string;
18
+ }
19
+
20
+ export { }