@groton/authjs-firestore-adapter 1.0.3 → 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/CHANGELOG.md +10 -0
- package/dist/Collections/Accounts.d.ts +7 -1
- package/dist/Collections/Accounts.js +17 -2
- package/dist/Collections/Authenticators.js +1 -2
- package/dist/Collections/Sessions.js +9 -8
- package/dist/Collections/Users.js +2 -4
- package/dist/Collections/VerificationTokens.js +1 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +4 -2
- package/package.json +3 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.1.0](https://github.com/groton-school/authjs/compare/firestore-adapter/1.0.4...firestore-adapter/1.1.0) (2026-11-26)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* optionally encrypt access and refresh tokens ([c7a1869](https://github.com/groton-school/authjs/commit/c7a1869c4413693233ce8e7983329208b277d158))
|
|
10
|
+
## [1.0.4](https://github.com/groton-school/authjs/compare/firestore-adapter/1.0.3...firestore-adapter/1.0.4) (2026-11-23)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* undo over-zealous object clean-up ([e6a782c](https://github.com/groton-school/authjs/commit/e6a782c88f57f309bf0c8ad6d30a9aeb3999cf42))
|
|
5
15
|
## [1.0.3](https://github.com/groton-school/authjs/compare/firestore-adapter/1.0.1...firestore-adapter/1.0.3) (2026-11-15)
|
|
6
16
|
|
|
7
17
|
### Bug Fixes
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { AdapterAccount, AdapterUser } from '@auth/core/adapters';
|
|
2
2
|
import { Collection, CollectionOptions } from '@battis/lazy-firestore';
|
|
3
|
+
interface Options extends CollectionOptions {
|
|
4
|
+
password?: string;
|
|
5
|
+
salt?: string;
|
|
6
|
+
}
|
|
3
7
|
export declare class Accounts extends Collection<AdapterAccount> {
|
|
4
8
|
static readonly DEFAULT: {
|
|
5
9
|
path: string;
|
|
6
10
|
};
|
|
11
|
+
constructor({ path, password, salt, converter, ...options }?: Options);
|
|
7
12
|
}
|
|
8
|
-
export declare function AccountsAdapter({ path, ...options }?:
|
|
13
|
+
export declare function AccountsAdapter({ path, ...options }?: Options): {
|
|
9
14
|
linkAccount: (account: AdapterAccount) => Promise<AdapterAccount | null>;
|
|
10
15
|
getAccount: (providerAccountId: AdapterAccount['providerAccountId'], provider: AdapterAccount['provider']) => Promise<AdapterAccount | null>;
|
|
11
16
|
getUserByAccount: ({ provider, providerAccountId }: Pick<AdapterAccount, 'provider' | 'providerAccountId'>) => Promise<AdapterUser | null>;
|
|
12
17
|
unlinkAccount: (account: Pick<AdapterAccount, 'provider' | 'providerAccountId'>) => Promise<AdapterAccount | undefined>;
|
|
13
18
|
};
|
|
19
|
+
export {};
|
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import { Collection } from '@battis/lazy-firestore';
|
|
2
|
-
import {
|
|
2
|
+
import { EncryptedString } from '@battis/lazy-firestore/converters/EncryptedString';
|
|
3
3
|
import { requireUnique } from '@battis/lazy-firestore/directives/requireUnique';
|
|
4
4
|
import { users } from './Users.js';
|
|
5
5
|
export class Accounts extends Collection {
|
|
6
6
|
static DEFAULT = { path: 'accounts' };
|
|
7
|
+
constructor({ path = Accounts.DEFAULT.path, password, salt, converter, ...options } = Accounts.DEFAULT) {
|
|
8
|
+
super({
|
|
9
|
+
path,
|
|
10
|
+
...options,
|
|
11
|
+
converter: {
|
|
12
|
+
...converter,
|
|
13
|
+
...(password && salt
|
|
14
|
+
? {
|
|
15
|
+
access_token: EncryptedString({ password, salt }),
|
|
16
|
+
refresh_token: EncryptedString({ password, salt })
|
|
17
|
+
}
|
|
18
|
+
: {})
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
7
22
|
}
|
|
8
23
|
export function AccountsAdapter({ path = Accounts.DEFAULT.path, ...options } = Accounts.DEFAULT) {
|
|
9
24
|
const accounts = new Accounts({ path, ...options });
|
|
@@ -19,7 +34,7 @@ export function AccountsAdapter({ path = Accounts.DEFAULT.path, ...options } = A
|
|
|
19
34
|
return {
|
|
20
35
|
linkAccount: async (account) => (await accounts.create({
|
|
21
36
|
...identify(account),
|
|
22
|
-
data:
|
|
37
|
+
data: account,
|
|
23
38
|
strict: false
|
|
24
39
|
})).data,
|
|
25
40
|
getAccount,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Collection } from '@battis/lazy-firestore';
|
|
2
2
|
import { DateConverter } from '@battis/lazy-firestore/converters/Date';
|
|
3
|
-
import { nullifyUndefinedProperties } from '@battis/lazy-firestore/directives/nullifyUndefinedProperties';
|
|
4
3
|
class Authenticators extends Collection {
|
|
5
4
|
static DEFAULT = { path: 'authenticators' };
|
|
6
5
|
constructor(options) {
|
|
@@ -14,7 +13,7 @@ export function AuthenticatorsAdapter({ path = Authenticators.DEFAULT.path, ...o
|
|
|
14
13
|
});
|
|
15
14
|
return {
|
|
16
15
|
createAuthenticator: async (authenticator) => (await authenticators.create({
|
|
17
|
-
data:
|
|
16
|
+
data: authenticator,
|
|
18
17
|
id: authenticator.credentialID,
|
|
19
18
|
strict: true
|
|
20
19
|
})).data,
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Collection } from '@battis/lazy-firestore';
|
|
2
2
|
import { DateConverter } from '@battis/lazy-firestore/converters/Date';
|
|
3
|
-
import { deleteUndefinedProperties } from '@battis/lazy-firestore/directives/deleteUndefinedProperties';
|
|
4
|
-
import { nullifyUndefinedProperties } from '@battis/lazy-firestore/directives/nullifyUndefinedProperties';
|
|
5
3
|
import { users } from './Users.js';
|
|
6
4
|
export class Sessions extends Collection {
|
|
7
5
|
static DEFAULT = { path: 'sessions' };
|
|
@@ -15,11 +13,14 @@ export class Sessions extends Collection {
|
|
|
15
13
|
export function SessionsAdapter({ path = Sessions.DEFAULT.path, ...options } = Sessions.DEFAULT) {
|
|
16
14
|
const sessions = new Sessions({ path, ...options });
|
|
17
15
|
return {
|
|
18
|
-
createSession: async (session) =>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
createSession: async (session) => {
|
|
17
|
+
console.log(JSON.stringify({ session }, null, 2));
|
|
18
|
+
return (await sessions.create({
|
|
19
|
+
id: session.sessionToken,
|
|
20
|
+
data: session,
|
|
21
|
+
strict: true
|
|
22
|
+
})).data;
|
|
23
|
+
},
|
|
23
24
|
getSessionAndUser: async (id) => {
|
|
24
25
|
const session = (await sessions.read({
|
|
25
26
|
id,
|
|
@@ -36,7 +37,7 @@ export function SessionsAdapter({ path = Sessions.DEFAULT.path, ...options } = S
|
|
|
36
37
|
},
|
|
37
38
|
updateSession: async (session) => (await sessions.update({
|
|
38
39
|
id: session.sessionToken,
|
|
39
|
-
patch:
|
|
40
|
+
patch: session,
|
|
40
41
|
strict: false
|
|
41
42
|
})).data,
|
|
42
43
|
deleteSession: async (id) => (await sessions.delete({
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { Collection } from '@battis/lazy-firestore';
|
|
2
|
-
import { deleteUndefinedProperties } from '@battis/lazy-firestore/directives/deleteUndefinedProperties';
|
|
3
|
-
import { nullifyUndefinedProperties } from '@battis/lazy-firestore/directives/nullifyUndefinedProperties';
|
|
4
2
|
import { requireUnique } from '@battis/lazy-firestore/directives/requireUnique';
|
|
5
3
|
export class Users extends Collection {
|
|
6
4
|
static DEFAULT = { path: 'users' };
|
|
@@ -27,7 +25,7 @@ export function UsersAdapter({ path = Users.DEFAULT.path, ...options } = Users.D
|
|
|
27
25
|
_users = new Users({ path, ...options });
|
|
28
26
|
return {
|
|
29
27
|
createUser: async (user) => (await users().create({
|
|
30
|
-
data:
|
|
28
|
+
data: user,
|
|
31
29
|
id: user.id,
|
|
32
30
|
query: (ref) => ref.where('email', '==', user.email),
|
|
33
31
|
strict: true
|
|
@@ -49,7 +47,7 @@ export function UsersAdapter({ path = Users.DEFAULT.path, ...options } = Users.D
|
|
|
49
47
|
},
|
|
50
48
|
updateUser: async (user) => (await users().update({
|
|
51
49
|
id: user.id,
|
|
52
|
-
patch:
|
|
50
|
+
patch: user,
|
|
53
51
|
strict: true
|
|
54
52
|
})).data,
|
|
55
53
|
deleteUser: async (id) => (await users().delete({
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Collection } from '@battis/lazy-firestore';
|
|
2
2
|
import { DateConverter } from '@battis/lazy-firestore/converters/Date';
|
|
3
|
-
import { nullifyUndefinedProperties } from '@battis/lazy-firestore/directives/nullifyUndefinedProperties';
|
|
4
3
|
export class VerificationTokens extends Collection {
|
|
5
4
|
static DEFAULT = { path: 'verificationTokens' };
|
|
6
5
|
constructor(options) {
|
|
@@ -12,7 +11,7 @@ export function VerificationTokensAdapter({ path = VerificationTokens.DEFAULT.pa
|
|
|
12
11
|
return {
|
|
13
12
|
createVerificationToken: async (token) => (await tokens.create({
|
|
14
13
|
...identify(token),
|
|
15
|
-
data:
|
|
14
|
+
data: token,
|
|
16
15
|
strict: false
|
|
17
16
|
})).data,
|
|
18
17
|
useVerificationToken: async (token) => (await tokens.delete({ ...identify(token), strict: false })).data
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ interface Options extends Omit<CollectionOptions, 'path'> {
|
|
|
7
7
|
sessionsPath?: string;
|
|
8
8
|
verificationTokensPath?: string;
|
|
9
9
|
authenticatorsPath?: string;
|
|
10
|
+
password?: string;
|
|
11
|
+
salt?: string;
|
|
10
12
|
}
|
|
11
|
-
export declare function FirestoreAdapter({ db, databaseId, basePath, usersPath, accountsPath, sessionsPath, verificationTokensPath, authenticatorsPath, firestore }?: Options): Adapter;
|
|
13
|
+
export declare function FirestoreAdapter({ db, databaseId, basePath, usersPath, accountsPath, password, salt, sessionsPath, verificationTokensPath, authenticatorsPath, firestore }?: Options): Adapter;
|
|
12
14
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { AuthenticatorsAdapter } from './Collections/Authenticators.js';
|
|
|
5
5
|
import { Sessions, SessionsAdapter } from './Collections/Sessions.js';
|
|
6
6
|
import { Users, UsersAdapter } from './Collections/Users.js';
|
|
7
7
|
import { VerificationTokens, VerificationTokensAdapter } from './Collections/VerificationTokens.js';
|
|
8
|
-
export function FirestoreAdapter({ db, databaseId, basePath = '.', usersPath, accountsPath, sessionsPath, verificationTokensPath, authenticatorsPath, firestore } = {}) {
|
|
8
|
+
export function FirestoreAdapter({ db, databaseId, basePath = '.', usersPath, accountsPath, password, salt, sessionsPath, verificationTokensPath, authenticatorsPath, firestore } = {}) {
|
|
9
9
|
db = db || new Firestore({ databaseId, ...firestore });
|
|
10
10
|
return {
|
|
11
11
|
...UsersAdapter({
|
|
@@ -16,7 +16,9 @@ export function FirestoreAdapter({ db, databaseId, basePath = '.', usersPath, ac
|
|
|
16
16
|
...AccountsAdapter({
|
|
17
17
|
db,
|
|
18
18
|
path: path.join(
|
|
19
|
-
/*turbopackIgnore: true*/ basePath, accountsPath || Accounts.DEFAULT.path)
|
|
19
|
+
/*turbopackIgnore: true*/ basePath, accountsPath || Accounts.DEFAULT.path),
|
|
20
|
+
password,
|
|
21
|
+
salt
|
|
20
22
|
}),
|
|
21
23
|
...SessionsAdapter({
|
|
22
24
|
db,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@groton/authjs-firestore-adapter",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"homepage": "https://github.com/groton-school/authjs/tree/main/packages/firestore-adapter#readme",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "github",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
"./package.json": "./package.json"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@battis/lazy-firestore": "^1.1
|
|
27
|
+
"@battis/lazy-firestore": "^1.2.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@battis/workspace": "^0.0.12",
|
|
31
31
|
"@tsconfig/node-lts": "^24.0.1",
|
|
32
|
-
"@types/node": "^24.19.
|
|
32
|
+
"@types/node": "^24.19.4",
|
|
33
33
|
"del-cli": "^8.0.1",
|
|
34
34
|
"npm-run-all": "^4.1.5",
|
|
35
35
|
"typescript": "^7.0.2"
|
|
@@ -42,7 +42,6 @@
|
|
|
42
42
|
"build": "run-s build:*",
|
|
43
43
|
"build:clean": "del ./dist",
|
|
44
44
|
"build:compile": "tsc",
|
|
45
|
-
"start": "echo 'noop'",
|
|
46
45
|
"release": "commit-and-tag-version --noBumpWhenEmptyChanges"
|
|
47
46
|
}
|
|
48
47
|
}
|