@auth/firebase-adapter 1.6.0 → 2.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 +2 -2
- package/index.d.ts +0 -71
- package/index.d.ts.map +1 -1
- package/index.js +0 -71
- package/package.json +2 -2
- package/src/index.ts +0 -71
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<br/>
|
|
3
3
|
<a href="https://authjs.dev" target="_blank">
|
|
4
|
-
<img height="64px" src="https://authjs.dev/img/logo
|
|
4
|
+
<img height="64px" src="https://authjs.dev/img/logo-sm.png" />
|
|
5
5
|
</a>
|
|
6
6
|
<a href="https://firebase.google.com" target="_blank">
|
|
7
7
|
<img height="64px" src="https://authjs.dev/img/adapters/firebase.svg"/>
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
<img src="https://img.shields.io/npm/dm/@auth/firebase-adapter?label=%20downloads&style=flat-square" alt="Downloads" />
|
|
19
19
|
</a>
|
|
20
20
|
<a href="https://github.com/nextauthjs/next-auth/stargazers">
|
|
21
|
-
<img src="https://img.shields.io/github/stars/nextauthjs/next-auth?style=flat-square" alt="
|
|
21
|
+
<img src="https://img.shields.io/github/stars/nextauthjs/next-auth?style=flat-square" alt="GitHub Stars" />
|
|
22
22
|
</a>
|
|
23
23
|
</p>
|
|
24
24
|
</p>
|
package/index.d.ts
CHANGED
|
@@ -41,77 +41,6 @@ export interface FirebaseAdapterConfig extends AppOptions {
|
|
|
41
41
|
*/
|
|
42
42
|
namingStrategy?: "snake_case" | "default";
|
|
43
43
|
}
|
|
44
|
-
/**
|
|
45
|
-
* ## Setup
|
|
46
|
-
*
|
|
47
|
-
* First, create a Firebase project and generate a service account key. Visit: `https://console.firebase.google.com/u/0/project/{project-id}/settings/serviceaccounts/adminsdk` (replace `{project-id}` with your project's id)
|
|
48
|
-
*
|
|
49
|
-
* Now you have a few options to authenticate with the Firebase Admin SDK in your app:
|
|
50
|
-
*
|
|
51
|
-
* ### Environment variables
|
|
52
|
-
* - Download the service account key and save it in your project. (Make sure to add the file to your `.gitignore`!)
|
|
53
|
-
* - Add [`GOOGLE_APPLICATION_CREDENTIALS`](https://cloud.google.com/docs/authentication/application-default-credentials#GAC) to your environment variables and point it to the service account key file.
|
|
54
|
-
* - The adapter will automatically pick up the environment variable and use it to authenticate with the Firebase Admin SDK.
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* ```ts title="pages/api/auth/[...nextauth].ts"
|
|
58
|
-
* import NextAuth from "next-auth"
|
|
59
|
-
* import { FirestoreAdapter } from "@auth/firebase-adapter"
|
|
60
|
-
*
|
|
61
|
-
* export default NextAuth({
|
|
62
|
-
* adapter: FirestoreAdapter(),
|
|
63
|
-
* // ...
|
|
64
|
-
* })
|
|
65
|
-
* ```
|
|
66
|
-
*
|
|
67
|
-
* ### Service account values
|
|
68
|
-
*
|
|
69
|
-
* - Download the service account key to a temporary location. (Make sure to not commit this file to your repository!)
|
|
70
|
-
* - Add the following environment variables to your project: `FIREBASE_PROJECT_ID`, `FIREBASE_CLIENT_EMAIL`, `FIREBASE_PRIVATE_KEY`.
|
|
71
|
-
* - Pass the config to the adapter, using the environment variables as shown in the example below.
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```ts title="pages/api/auth/[...nextauth].ts"
|
|
75
|
-
* import NextAuth from "next-auth"
|
|
76
|
-
* import { FirestoreAdapter } from "@auth/firebase-adapter"
|
|
77
|
-
* import { cert } from "firebase-admin/app"
|
|
78
|
-
*
|
|
79
|
-
* export default NextAuth({
|
|
80
|
-
* adapter: FirestoreAdapter({
|
|
81
|
-
* credential: cert({
|
|
82
|
-
* projectId: process.env.FIREBASE_PROJECT_ID,
|
|
83
|
-
* clientEmail: process.env.FIREBASE_CLIENT_EMAIL,
|
|
84
|
-
* privateKey: process.env.FIREBASE_PRIVATE_KEY,
|
|
85
|
-
* })
|
|
86
|
-
* })
|
|
87
|
-
* // ...
|
|
88
|
-
* })
|
|
89
|
-
* ```
|
|
90
|
-
*
|
|
91
|
-
* ### Using an existing Firestore instance
|
|
92
|
-
*
|
|
93
|
-
* If you already have a Firestore instance, you can pass that to the adapter directly instead.
|
|
94
|
-
*
|
|
95
|
-
* :::note
|
|
96
|
-
* When passing an instance and in a serverless environment, remember to handle duplicate app initialization.
|
|
97
|
-
* :::
|
|
98
|
-
*
|
|
99
|
-
* :::tip
|
|
100
|
-
* You can use the {@link initFirestore} utility to initialize the app and get an instance safely.
|
|
101
|
-
* :::
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* ```ts title="pages/api/auth/[...nextauth].ts"
|
|
105
|
-
* import NextAuth from "next-auth"
|
|
106
|
-
* import { FirestoreAdapter } from "@auth/firebase-adapter"
|
|
107
|
-
* import { firestore } from "lib/firestore"
|
|
108
|
-
*
|
|
109
|
-
* export default NextAuth({
|
|
110
|
-
* adapter: FirestoreAdapter(firestore),
|
|
111
|
-
* // ...
|
|
112
|
-
* })
|
|
113
|
-
* ```
|
|
114
|
-
*/
|
|
115
44
|
export declare function FirestoreAdapter(config?: FirebaseAdapterConfig | Firestore): Adapter;
|
|
116
45
|
/**
|
|
117
46
|
* Utility function that helps making sure that there is no duplicate app initialization issues in serverless environments.
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,UAAU,EAA0B,MAAM,oBAAoB,CAAA;AAE5E,OAAO,EACL,SAAS,EAIV,MAAM,0BAA0B,CAAA;AAEjC,OAAO,KAAK,EACV,OAAO,EAKR,MAAM,qBAAqB,CAAA;AAE5B,sCAAsC;AACtC,MAAM,WAAW,qBAAsB,SAAQ,UAAU;IACvD;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB;;;;;;;;;;;;;;;;;OAiBG;IACH,cAAc,CAAC,EAAE,YAAY,GAAG,SAAS,CAAA;CAC1C;AAED
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,UAAU,EAA0B,MAAM,oBAAoB,CAAA;AAE5E,OAAO,EACL,SAAS,EAIV,MAAM,0BAA0B,CAAA;AAEjC,OAAO,KAAK,EACV,OAAO,EAKR,MAAM,qBAAqB,CAAA;AAE5B,sCAAsC;AACtC,MAAM,WAAW,qBAAsB,SAAQ,UAAU;IACvD;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB;;;;;;;;;;;;;;;;;OAiBG;IACH,cAAc,CAAC,EAAE,YAAY,GAAG,SAAS,CAAA;CAC1C;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,CAAC,EAAE,qBAAqB,GAAG,SAAS,GACzC,OAAO,CAgKT;AA8HD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAC3B,OAAO,GAAE,UAAU,GAAG;IAAE,IAAI,CAAC,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAAA;CAAO,aAQpE"}
|
package/index.js
CHANGED
|
@@ -13,77 +13,6 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { getApps, initializeApp } from "firebase-admin/app";
|
|
15
15
|
import { Firestore, getFirestore, initializeFirestore, Timestamp, } from "firebase-admin/firestore";
|
|
16
|
-
/**
|
|
17
|
-
* ## Setup
|
|
18
|
-
*
|
|
19
|
-
* First, create a Firebase project and generate a service account key. Visit: `https://console.firebase.google.com/u/0/project/{project-id}/settings/serviceaccounts/adminsdk` (replace `{project-id}` with your project's id)
|
|
20
|
-
*
|
|
21
|
-
* Now you have a few options to authenticate with the Firebase Admin SDK in your app:
|
|
22
|
-
*
|
|
23
|
-
* ### Environment variables
|
|
24
|
-
* - Download the service account key and save it in your project. (Make sure to add the file to your `.gitignore`!)
|
|
25
|
-
* - Add [`GOOGLE_APPLICATION_CREDENTIALS`](https://cloud.google.com/docs/authentication/application-default-credentials#GAC) to your environment variables and point it to the service account key file.
|
|
26
|
-
* - The adapter will automatically pick up the environment variable and use it to authenticate with the Firebase Admin SDK.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```ts title="pages/api/auth/[...nextauth].ts"
|
|
30
|
-
* import NextAuth from "next-auth"
|
|
31
|
-
* import { FirestoreAdapter } from "@auth/firebase-adapter"
|
|
32
|
-
*
|
|
33
|
-
* export default NextAuth({
|
|
34
|
-
* adapter: FirestoreAdapter(),
|
|
35
|
-
* // ...
|
|
36
|
-
* })
|
|
37
|
-
* ```
|
|
38
|
-
*
|
|
39
|
-
* ### Service account values
|
|
40
|
-
*
|
|
41
|
-
* - Download the service account key to a temporary location. (Make sure to not commit this file to your repository!)
|
|
42
|
-
* - Add the following environment variables to your project: `FIREBASE_PROJECT_ID`, `FIREBASE_CLIENT_EMAIL`, `FIREBASE_PRIVATE_KEY`.
|
|
43
|
-
* - Pass the config to the adapter, using the environment variables as shown in the example below.
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* ```ts title="pages/api/auth/[...nextauth].ts"
|
|
47
|
-
* import NextAuth from "next-auth"
|
|
48
|
-
* import { FirestoreAdapter } from "@auth/firebase-adapter"
|
|
49
|
-
* import { cert } from "firebase-admin/app"
|
|
50
|
-
*
|
|
51
|
-
* export default NextAuth({
|
|
52
|
-
* adapter: FirestoreAdapter({
|
|
53
|
-
* credential: cert({
|
|
54
|
-
* projectId: process.env.FIREBASE_PROJECT_ID,
|
|
55
|
-
* clientEmail: process.env.FIREBASE_CLIENT_EMAIL,
|
|
56
|
-
* privateKey: process.env.FIREBASE_PRIVATE_KEY,
|
|
57
|
-
* })
|
|
58
|
-
* })
|
|
59
|
-
* // ...
|
|
60
|
-
* })
|
|
61
|
-
* ```
|
|
62
|
-
*
|
|
63
|
-
* ### Using an existing Firestore instance
|
|
64
|
-
*
|
|
65
|
-
* If you already have a Firestore instance, you can pass that to the adapter directly instead.
|
|
66
|
-
*
|
|
67
|
-
* :::note
|
|
68
|
-
* When passing an instance and in a serverless environment, remember to handle duplicate app initialization.
|
|
69
|
-
* :::
|
|
70
|
-
*
|
|
71
|
-
* :::tip
|
|
72
|
-
* You can use the {@link initFirestore} utility to initialize the app and get an instance safely.
|
|
73
|
-
* :::
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```ts title="pages/api/auth/[...nextauth].ts"
|
|
77
|
-
* import NextAuth from "next-auth"
|
|
78
|
-
* import { FirestoreAdapter } from "@auth/firebase-adapter"
|
|
79
|
-
* import { firestore } from "lib/firestore"
|
|
80
|
-
*
|
|
81
|
-
* export default NextAuth({
|
|
82
|
-
* adapter: FirestoreAdapter(firestore),
|
|
83
|
-
* // ...
|
|
84
|
-
* })
|
|
85
|
-
* ```
|
|
86
|
-
*/
|
|
87
16
|
export function FirestoreAdapter(config) {
|
|
88
17
|
const { db, namingStrategy = "default" } = config instanceof Firestore
|
|
89
18
|
? { db: config }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auth/firebase-adapter",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Firebase adapter for Auth.js",
|
|
5
5
|
"homepage": "https://authjs.dev",
|
|
6
6
|
"repository": "https://github.com/nextauthjs/next-auth",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@auth/core": "0.
|
|
40
|
+
"@auth/core": "0.31.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"firebase-admin": "^11.4.1"
|
package/src/index.ts
CHANGED
|
@@ -57,77 +57,6 @@ export interface FirebaseAdapterConfig extends AppOptions {
|
|
|
57
57
|
namingStrategy?: "snake_case" | "default"
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
/**
|
|
61
|
-
* ## Setup
|
|
62
|
-
*
|
|
63
|
-
* First, create a Firebase project and generate a service account key. Visit: `https://console.firebase.google.com/u/0/project/{project-id}/settings/serviceaccounts/adminsdk` (replace `{project-id}` with your project's id)
|
|
64
|
-
*
|
|
65
|
-
* Now you have a few options to authenticate with the Firebase Admin SDK in your app:
|
|
66
|
-
*
|
|
67
|
-
* ### Environment variables
|
|
68
|
-
* - Download the service account key and save it in your project. (Make sure to add the file to your `.gitignore`!)
|
|
69
|
-
* - Add [`GOOGLE_APPLICATION_CREDENTIALS`](https://cloud.google.com/docs/authentication/application-default-credentials#GAC) to your environment variables and point it to the service account key file.
|
|
70
|
-
* - The adapter will automatically pick up the environment variable and use it to authenticate with the Firebase Admin SDK.
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* ```ts title="pages/api/auth/[...nextauth].ts"
|
|
74
|
-
* import NextAuth from "next-auth"
|
|
75
|
-
* import { FirestoreAdapter } from "@auth/firebase-adapter"
|
|
76
|
-
*
|
|
77
|
-
* export default NextAuth({
|
|
78
|
-
* adapter: FirestoreAdapter(),
|
|
79
|
-
* // ...
|
|
80
|
-
* })
|
|
81
|
-
* ```
|
|
82
|
-
*
|
|
83
|
-
* ### Service account values
|
|
84
|
-
*
|
|
85
|
-
* - Download the service account key to a temporary location. (Make sure to not commit this file to your repository!)
|
|
86
|
-
* - Add the following environment variables to your project: `FIREBASE_PROJECT_ID`, `FIREBASE_CLIENT_EMAIL`, `FIREBASE_PRIVATE_KEY`.
|
|
87
|
-
* - Pass the config to the adapter, using the environment variables as shown in the example below.
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* ```ts title="pages/api/auth/[...nextauth].ts"
|
|
91
|
-
* import NextAuth from "next-auth"
|
|
92
|
-
* import { FirestoreAdapter } from "@auth/firebase-adapter"
|
|
93
|
-
* import { cert } from "firebase-admin/app"
|
|
94
|
-
*
|
|
95
|
-
* export default NextAuth({
|
|
96
|
-
* adapter: FirestoreAdapter({
|
|
97
|
-
* credential: cert({
|
|
98
|
-
* projectId: process.env.FIREBASE_PROJECT_ID,
|
|
99
|
-
* clientEmail: process.env.FIREBASE_CLIENT_EMAIL,
|
|
100
|
-
* privateKey: process.env.FIREBASE_PRIVATE_KEY,
|
|
101
|
-
* })
|
|
102
|
-
* })
|
|
103
|
-
* // ...
|
|
104
|
-
* })
|
|
105
|
-
* ```
|
|
106
|
-
*
|
|
107
|
-
* ### Using an existing Firestore instance
|
|
108
|
-
*
|
|
109
|
-
* If you already have a Firestore instance, you can pass that to the adapter directly instead.
|
|
110
|
-
*
|
|
111
|
-
* :::note
|
|
112
|
-
* When passing an instance and in a serverless environment, remember to handle duplicate app initialization.
|
|
113
|
-
* :::
|
|
114
|
-
*
|
|
115
|
-
* :::tip
|
|
116
|
-
* You can use the {@link initFirestore} utility to initialize the app and get an instance safely.
|
|
117
|
-
* :::
|
|
118
|
-
*
|
|
119
|
-
* @example
|
|
120
|
-
* ```ts title="pages/api/auth/[...nextauth].ts"
|
|
121
|
-
* import NextAuth from "next-auth"
|
|
122
|
-
* import { FirestoreAdapter } from "@auth/firebase-adapter"
|
|
123
|
-
* import { firestore } from "lib/firestore"
|
|
124
|
-
*
|
|
125
|
-
* export default NextAuth({
|
|
126
|
-
* adapter: FirestoreAdapter(firestore),
|
|
127
|
-
* // ...
|
|
128
|
-
* })
|
|
129
|
-
* ```
|
|
130
|
-
*/
|
|
131
60
|
export function FirestoreAdapter(
|
|
132
61
|
config?: FirebaseAdapterConfig | Firestore
|
|
133
62
|
): Adapter {
|