metamigo-common: build, fmt, lint
This commit is contained in:
parent
2a1ced5383
commit
75fb3f84c4
21 changed files with 95 additions and 156 deletions
|
|
@ -1,9 +1,9 @@
|
|||
/* eslint-disable unicorn/no-null,max-params */
|
||||
import { createHash, randomBytes } from "crypto";
|
||||
import { createHash, randomBytes } from "node:crypto";
|
||||
import type { AdapterInstance } from "next-auth/adapters";
|
||||
import omit from "lodash/omit";
|
||||
import type { IMetamigoRepositories } from "../records";
|
||||
import type { UnsavedAccount, SavedAccount } from "../records/account";
|
||||
import type { UnsavedAccount } from "../records/account";
|
||||
import type { UserId, UnsavedUser, SavedUser } from "../records/user";
|
||||
import type { UnsavedSession, SavedSession } from "../records/session";
|
||||
|
||||
|
|
@ -12,6 +12,7 @@ export const defaultSessionMaxAge = 30 * 24 * 60 * 60 * 1000;
|
|||
// Sessions updated only if session is greater than this value (0 = always)
|
||||
export const defaulteSessionUpdateAge = 24 * 60 * 60 * 1000;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const getCompoundId = (providerId: any, providerAccountId: any) =>
|
||||
createHash("sha256")
|
||||
.update(`${providerId}:${providerAccountId}`)
|
||||
|
|
@ -26,10 +27,10 @@ export class NextAuthAdapter<TRepositories extends IMetamigoRepositories>
|
|||
private repos: TRepositories,
|
||||
private readonly sessionMaxAge = defaultSessionMaxAge,
|
||||
private readonly sessionUpdateAge = defaulteSessionUpdateAge
|
||||
) { }
|
||||
) {}
|
||||
|
||||
async createUser(profile: UnsavedUser): Promise<SavedUser> {
|
||||
// @ts-expect-error
|
||||
// @ts-expect-error Typescript doesn't like lodash's omit()
|
||||
return this.repos.users.upsert(omit(profile, ["isActive", "id"]));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue