The Open Source DocuSign Alternative.
TypeScript digital-signaturedocument-signingdocusign-alternativee-signatureesignesignaturenext-authnextjsopen-sourcepades-standardpdfpdf-signpdf-signaturepostgresqlprismaself-hostedsigningtypescript
signup and loginbasics
Timur Ercan58fbaab935df
diff --git a/apps/web/package.json b/apps/web/package.jsonindex fb9eb903a..0d773608d 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -13,9 +13,11 @@"@headlessui/react": "^1.7.4","@heroicons/react": "^2.0.13","@tailwindcss/forms": "^0.5.3",+ "@types/bcryptjs": "^2.4.2","@types/node": "18.11.9","@types/react": "18.0.25","@types/react-dom": "18.0.9",+ "bcryptjs": "^2.4.3","dotenv": "^16.0.3","eslint": "8.27.0","eslint-config-next": "13.0.3",diff --git a/apps/web/pages/api/auth/[...nextauth].ts b/apps/web/pages/api/auth/[...nextauth].tsindex 526de1281..8483dbae4 100644--- a/apps/web/pages/api/auth/[...nextauth].ts+++ b/apps/web/pages/api/auth/[...nextauth].ts@@ -1,11 +1,70 @@import NextAuth from "next-auth";import GitHubProvider from "next-auth/providers/github";+import CredentialsProvider from "next-auth/providers/credentials";+import { ErrorCode } from "@documenso/lib/auth";+import prisma from "@documenso/prisma";+import { verifyPassword } from "@documenso/lib/auth";export default NextAuth({providers: [- GitHubProvider({- clientId: "df804870b0d11b0779cf",- clientSecret: "7ef4bbc0957e48e4e6e59c5b5879b3d75d90acc5",+ CredentialsProvider({+ id: "crediantials",+ name: "Documenso.com Login",+ type: "credentials",+ credentials: {+ email: {+ label: "Email Address",+ type: "email",+ placeholder: "[email protected]",+ },+ password: {+ label: "Password",+ type: "password",+ placeholder:+ "Select a password. Here is some inspiration: https://xkcd.com/936/",+ },+ },+ async authorize(credentials: any) {+ if (!credentials) {+ console.error("Credential missing in authorize()");+ throw new Error(ErrorCode.InternalServerError);+ }++ const user = await prisma.user.findUnique({+ where: {+ email: credentials.email.toLowerCase(),+ },+ select: {+ id: true,+ email: true,+ password: true,+ name: true,+ },+ });++ if (!user) {+ throw new Error(ErrorCode.UserNotFound);+ }++ if (!user.password) {+ throw new Error(ErrorCode.UserMissingPassword);+ }++ const isCorrectPassword = await verifyPassword(+ credentials.password,+ user.password+ );++ if (!isCorrectPassword) {+ throw new Error(ErrorCode.IncorrectPassword);+ }++ return {+ id: user.id.toString(),+ email: user.email,+ name: user.name,+ };+ },}),],});diff --git a/apps/web/pages/api/auth/signup.ts b/apps/web/pages/api/auth/signup.tsnew file mode 100644index 000000000..182da7d35--- /dev/null+++ b/apps/web/pages/api/auth/signup.ts@@ -0,0 +1,58 @@+import { IdentityProvider } from "@prisma/client";+import { NextApiRequest, NextApiResponse } from "next";++import prisma from "@documenso/prisma";+import { hashPassword } from "@documenso/lib/auth";+import { defaultHandler, defaultResponder } from "@documenso/lib/server";++async function postHandler(req: NextApiRequest, res: NextApiResponse) {+ const data = req.body;+ const { email, password } = data;+ const cleanEmail = email.toLowerCase();++ if (!cleanEmail || !cleanEmail.includes("@")) {+ res.status(422).json({ message: "Invalid email" });+ return;+ }++ if (!password || password.trim().length < 7) {+ res.status(422).json({+ message: "Invalid input - password should be at least 7 characters long.",+ });+ return;+ }++ // User already exists if email already exists+ const existingUser = await prisma.user.findFirst({+ where: {+ email: cleanEmail,+ },+ });++ if (existingUser) {+ const message: string = "Email address is already registered";+ return res.status(409).json({ message });+ }++ const hashedPassword = await hashPassword(password);++ const user = await prisma.user.upsert({+ where: { email: cleanEmail },+ update: {+ password: hashedPassword,+ emailVerified: new Date(Date.now()),+ identityProvider: IdentityProvider.DOCUMENSO,+ },+ create: {+ email: cleanEmail,+ password: hashedPassword,+ identityProvider: IdentityProvider.DOCUMENSO,+ },+ });++ res.status(201).json({ message: "Created user" });+}++export default defaultHandler({+ POST: Promise.resolve({ default: defaultResponder(postHandler) }),+});diff --git a/package-lock.json b/package-lock.jsonindex 53573c2f5..9a0867f85 100644--- a/package-lock.json+++ b/package-lock.json@@ -20,9 +20,11 @@"@headlessui/react": "^1.7.4","@heroicons/react": "^2.0.13","@tailwindcss/forms": "^0.5.3",+ "@types/bcryptjs": "^2.4.2","@types/node": "18.11.9","@types/react": "18.0.25","@types/react-dom": "18.0.9",+ "bcryptjs": "^2.4.3","dotenv": "^16.0.3","eslint": "8.27.0","eslint-config-next": "13.0.3",@@ -52,22 +54,18 @@"node": ">=6.9.0"}},- "node_modules/@babel/runtime-corejs3": {- "version": "7.20.7",- "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.20.7.tgz",- "integrity": "sha512-jr9lCZ4RbRQmCR28Q8U8Fu49zvFqLxTY9AMOUz+iyMohMoAgpEcVxY+wJNay99oXOpOcCTODkk70NDN2aaJEeg==",- "dependencies": {- "core-js-pure": "^3.25.1",- "regenerator-runtime": "^0.13.11"- },- "engines": {- "node": ">=6.9.0"- }+ "node_modules/@documenso/lib": {+ "resolved": "packages/lib",+ "link": true},"node_modules/@documenso/prisma": {"resolved": "packages/prisma","link": true},+ "node_modules/@documenso/ui": {+ "resolved": "packages/ui",+ "link": true+ },"node_modules/@documenso/web": {"resolved": "apps/web","link": true@@ -450,6 +448,11 @@"tailwindcss": ">=3.0.0 || >= 3.0.0-alpha.1"}},+ "node_modules/@types/bcryptjs": {+ "version": "2.4.2",+ "resolved": "https://registry.npmjs.org/@types/bcryptjs/-/bcryptjs-2.4.2.tgz",+ "integrity": "sha512-LiMQ6EOPob/4yUL66SZzu6Yh77cbzJFYll+ZfaPiPPFswtIlA/Fs1MzdKYA7JApHU49zQTbJGX3PDmCpIdDBRQ=="+ },"node_modules/@types/json5": {"version": "0.0.29","resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz",@@ -489,13 +492,13 @@"integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew=="},"node_modules/@typescript-eslint/parser": {- "version": "5.48.0",- "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.48.0.tgz",- "integrity": "sha512-1mxNA8qfgxX8kBvRDIHEzrRGrKHQfQlbW6iHyfHYS0Q4X1af+S6mkLNtgCOsGVl8+/LUPrqdHMssAemkrQ01qg==",+ "version": "5.48.1",+ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.48.1.tgz",+ "integrity": "sha512-4yg+FJR/V1M9Xoq56SF9Iygqm+r5LMXvheo6DQ7/yUWynQ4YfCRnsKuRgqH4EQ5Ya76rVwlEpw4Xu+TgWQUcdA==","dependencies": {- "@typescript-eslint/scope-manager": "5.48.0",- "@typescript-eslint/types": "5.48.0",- "@typescript-eslint/typescript-estree": "5.48.0",+ "@typescript-eslint/scope-manager": "5.48.1",+ "@typescript-eslint/types": "5.48.1",+ "@typescript-eslint/typescript-estree": "5.48.1","debug": "^4.3.4"},"engines": {@@ -515,12 +518,12 @@}},"node_modules/@typescript-eslint/scope-manager": {- "version": "5.48.0",- "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.48.0.tgz",- "integrity": "sha512-0AA4LviDtVtZqlyUQnZMVHydDATpD9SAX/RC5qh6cBd3xmyWvmXYF+WT1oOmxkeMnWDlUVTwdODeucUnjz3gow==",+ "version": "5.48.1",+ "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.48.1.tgz",+ "integrity": "sha512-S035ueRrbxRMKvSTv9vJKIWgr86BD8s3RqoRZmsSh/s8HhIs90g6UlK8ZabUSjUZQkhVxt7nmZ63VJ9dcZhtDQ==","dependencies": {- "@typescript-eslint/types": "5.48.0",- "@typescript-eslint/visitor-keys": "5.48.0"+ "@typescript-eslint/types": "5.48.1",+ "@typescript-eslint/visitor-keys": "5.48.1"},"engines": {"node": "^12.22.0 || ^14.17.0 || >=16.0.0"@@ -531,9 +534,9 @@}},"node_modules/@typescript-eslint/types": {- "version": "5.48.0",- "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.48.0.tgz",- "integrity": "sha512-UTe67B0Ypius0fnEE518NB2N8gGutIlTojeTg4nt0GQvikReVkurqxd2LvYa9q9M5MQ6rtpNyWTBxdscw40Xhw==",+ "version": "5.48.1",+ "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.48.1.tgz",+ "integrity": "sha512-xHyDLU6MSuEEdIlzrrAerCGS3T7AA/L8Hggd0RCYBi0w3JMvGYxlLlXHeg50JI9Tfg5MrtsfuNxbS/3zF1/ATg==","engines": {"node": "^12.22.0 || ^14.17.0 || >=16.0.0"},@@ -543,12 +546,12 @@}},"node_modules/@typescript-eslint/typescript-estree": {- "version": "5.48.0",- "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.48.0.tgz",- "integrity": "sha512-7pjd94vvIjI1zTz6aq/5wwE/YrfIyEPLtGJmRfyNR9NYIW+rOvzzUv3Cmq2hRKpvt6e9vpvPUQ7puzX7VSmsEw==",+ "version": "5.48.1",+ "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.48.1.tgz",+ "integrity": "sha512-Hut+Osk5FYr+sgFh8J/FHjqX6HFcDzTlWLrFqGoK5kVUN3VBHF/QzZmAsIXCQ8T/W9nQNBTqalxi1P3LSqWnRA==","dependencies": {- "@typescript-eslint/types": "5.48.0",- "@typescript-eslint/visitor-keys": "5.48.0",+ "@typescript-eslint/types": "5.48.1",+ "@typescript-eslint/visitor-keys": "5.48.1","debug": "^4.3.4","globby": "^11.1.0","is-glob": "^4.0.3",@@ -569,11 +572,11 @@}},"node_modules/@typescript-eslint/visitor-keys": {- "version": "5.48.0",- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.48.0.tgz",- "integrity": "sha512-5motVPz5EgxQ0bHjut3chzBkJ3Z3sheYVcSwS5BpHZpLqSptSmELNtGixmgj65+rIfhvtQTz5i9OP2vtzdDH7Q==",+ "version": "5.48.1",+ "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.48.1.tgz",+ "integrity": "sha512-Ns0XBwmfuX7ZknznfXozgnydyR8F6ev/KEGePP4i74uL3ArsKbEhJ7raeKr1JSa997DBDwol/4a0Y+At82c9dA==","dependencies": {- "@typescript-eslint/types": "5.48.0",+ "@typescript-eslint/types": "5.48.1","eslint-visitor-keys": "^3.3.0"},"engines": {@@ -692,15 +695,11 @@"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="},"node_modules/aria-query": {- "version": "4.2.2",- "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-4.2.2.tgz",- "integrity": "sha512-o/HelwhuKpTj/frsOsbNLNgnNGVIFsVP/SW2BSF14gVl7kAfMOJ6/8wUAUvG1R1NHKrfG+2sHZTu0yauT1qBrA==",+ "version": "5.1.3",+ "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.1.3.tgz",+ "integrity": "sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ==","dependencies": {- "@babel/runtime": "^7.10.2",- "@babel/runtime-corejs3": "^7.10.2"- },- "engines": {- "node": ">=6.0"+ "deep-equal": "^2.0.5"}},"node_modules/array-includes": {@@ -833,15 +832,23 @@}},"node_modules/axobject-query": {- "version": "2.2.0",- "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz",- "integrity": "sha512-Td525n+iPOOyUQIeBfcASuG6uJsDOITl7Mds5gFyerkWiX7qhUTdYUBlSgNMyVqtSJqwpt1kXGLdUt6SykLMRA=="+ "version": "3.1.1",+ "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.1.1.tgz",+ "integrity": "sha512-goKlv8DZrK9hUh975fnHzhNIO4jUnFCfv/dszV5VwUGDFjI6vQ2VwoyjYjYNEbBE8AH87TduWP5uyDR1D+Iteg==",+ "dependencies": {+ "deep-equal": "^2.0.5"+ }},"node_modules/balanced-match": {"version": "1.0.2","resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz","integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="},+ "node_modules/bcryptjs": {+ "version": "2.4.3",+ "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz",+ "integrity": "sha512-V/Hy/X9Vt7f3BbPJEi8BdVFMByHi+jNXrYkW3huaybV/kQ0KJg0Y6PkEMbn+zeT+i+SiKZ/HMqJGIIt4LZDqNQ=="+ },"node_modules/binary-extensions": {"version": "2.2.0","resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz",@@ -1027,16 +1034,6 @@"node": ">= 0.6"}},- "node_modules/core-js-pure": {- "version": "3.27.1",- "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.27.1.tgz",- "integrity": "sha512-BS2NHgwwUppfeoqOXqi08mUqS5FiZpuRuJJpKsaME7kJz0xxuk0xkhDdfMIlP/zLa80krBqss1LtD7f889heAw==",- "hasInstallScript": true,- "funding": {- "type": "opencollective",- "url": "https://opencollective.com/core-js"- }- },"node_modules/cross-spawn": {"version": "7.0.3","resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",@@ -1087,6 +1084,33 @@}}},+ "node_modules/deep-equal": {+ "version": "2.2.0",+ "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.2.0.tgz",+ "integrity": "sha512-RdpzE0Hv4lhowpIUKKMJfeH6C1pXdtT1/it80ubgWqwI3qpuxUBpC1S4hnHg+zjnuOoDkzUtUCEEkG+XG5l3Mw==",+ "dependencies": {+ "call-bind": "^1.0.2",+ "es-get-iterator": "^1.1.2",+ "get-intrinsic": "^1.1.3",+ "is-arguments": "^1.1.1",+ "is-array-buffer": "^3.0.1",+ "is-date-object": "^1.0.5",+ "is-regex": "^1.1.4",+ "is-shared-array-buffer": "^1.0.2",+ "isarray": "^2.0.5",+ "object-is": "^1.1.5",+ "object-keys": "^1.1.1",+ "object.assign": "^4.1.4",+ "regexp.prototype.flags": "^1.4.3",+ "side-channel": "^1.0.4",+ "which-boxed-primitive": "^1.0.2",+ "which-collection": "^1.0.1",+ "which-typed-array": "^1.1.9"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },"node_modules/deep-is": {"version": "0.1.4","resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz",@@ -1239,6 +1263,24 @@"url": "https://github.com/sponsors/ljharb"}},+ "node_modules/es-get-iterator": {+ "version": "1.1.2",+ "resolved": "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.2.tgz",+ "integrity": "sha512-+DTO8GYwbMCwbywjimwZMHp8AuYXOS2JZFWoi2AlPOS3ebnII9w/NLpNZtA7A0YLaVDw+O7KFCeoIV7OPvM7hQ==",+ "dependencies": {+ "call-bind": "^1.0.2",+ "get-intrinsic": "^1.1.0",+ "has-symbols": "^1.0.1",+ "is-arguments": "^1.1.0",+ "is-map": "^2.0.2",+ "is-set": "^2.0.2",+ "is-string": "^1.0.5",+ "isarray": "^2.0.5"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },"node_modules/es-set-tostringtag": {"version": "2.0.1","resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.1.tgz",@@ -1506,22 +1548,25 @@"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="},"node_modules/eslint-plugin-jsx-a11y": {- "version": "6.6.1",- "resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.6.1.tgz",- "integrity": "sha512-sXgFVNHiWffBq23uiS/JaP6eVR622DqwB4yTzKvGZGcPq6/yZ3WmOZfuBks/vHWo9GaFOqC2ZK4i6+C35knx7Q==",+ "version": "6.7.0",+ "resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.7.0.tgz",+ "integrity": "sha512-EGGRKhzejSzXKtjmEjWNtr4SK/DkMkSzkBH7g7e7moBDXZXrqaUIxkmD7uF93upMysc4dKYEJwupu7Dff+ShwA==","dependencies": {- "@babel/runtime": "^7.18.9",- "aria-query": "^4.2.2",- "array-includes": "^3.1.5",+ "@babel/runtime": "^7.20.7",+ "aria-query": "^5.1.3",+ "array-includes": "^3.1.6",+ "array.prototype.flatmap": "^1.3.1","ast-types-flow": "^0.0.7",- "axe-core": "^4.4.3",- "axobject-query": "^2.2.0",+ "axe-core": "^4.6.2",+ "axobject-query": "^3.1.1","damerau-levenshtein": "^1.0.8","emoji-regex": "^9.2.2","has": "^1.0.3",- "jsx-ast-utils": "^3.3.2",- "language-tags": "^1.0.5",+ "jsx-ast-utils": "^3.3.3",+ "language-tags": "=1.0.5","minimatch": "^3.1.2",+ "object.entries": "^1.1.6",+ "object.fromentries": "^2.0.6","semver": "^6.3.0"},"engines": {@@ -2150,6 +2195,21 @@"node": ">= 0.4"}},+ "node_modules/is-arguments": {+ "version": "1.1.1",+ "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz",+ "integrity": "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==",+ "dependencies": {+ "call-bind": "^1.0.2",+ "has-tostringtag": "^1.0.0"+ },+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },"node_modules/is-array-buffer": {"version": "3.0.1","resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.1.tgz",@@ -2255,6 +2315,14 @@"node": ">=0.10.0"}},+ "node_modules/is-map": {+ "version": "2.0.2",+ "resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.2.tgz",+ "integrity": "sha512-cOZFQQozTha1f4MxLFzlgKYPTyj26picdZTx82hbc/Xf4K/tZOOXSCkMvU4pKioRXGDLJRn0GM7Upe7kR721yg==",+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },"node_modules/is-negative-zero": {"version": "2.0.2","resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz",@@ -2311,6 +2379,14 @@"url": "https://github.com/sponsors/ljharb"}},+ "node_modules/is-set": {+ "version": "2.0.2",+ "resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.2.tgz",+ "integrity": "sha512-+2cnTEZeY5z/iXGbLhPrOAaK/Mau5k5eXq9j14CpRTftq0pAJu2MwVRSZhyZWBzx3o6X795Lz6Bpb6R0GKf37g==",+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },"node_modules/is-shared-array-buffer": {"version": "1.0.2","resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz",@@ -2368,6 +2444,14 @@"url": "https://github.com/sponsors/ljharb"}},+ "node_modules/is-weakmap": {+ "version": "2.0.1",+ "resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.1.tgz",+ "integrity": "sha512-NSBR4kH5oVj1Uwvv970ruUkCV7O1mzgVFO4/rev2cLRda9Tm9HrL70ZPut4rOHgY0FNrUu9BCbXA2sdQ+x0chA==",+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },"node_modules/is-weakref": {"version": "1.0.2","resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz",@@ -2379,6 +2463,23 @@"url": "https://github.com/sponsors/ljharb"}},+ "node_modules/is-weakset": {+ "version": "2.0.2",+ "resolved": "https://registry.npmjs.org/is-weakset/-/is-weakset-2.0.2.tgz",+ "integrity": "sha512-t2yVvttHkQktwnNNmBQ98AhENLdPUTDTE21uPqAQ0ARwQfGeQKRVS0NNurH7bTf7RrvcVn1OOge45CnBeHCSmg==",+ "dependencies": {+ "call-bind": "^1.0.2",+ "get-intrinsic": "^1.1.1"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/isarray": {+ "version": "2.0.5",+ "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz",+ "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw=="+ },"node_modules/isexe": {"version": "2.0.0","resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",@@ -2456,11 +2557,11 @@"integrity": "sha512-tN0MCzyWnoz/4nHS6uxdlFWoUZT7ABptwKPQ52Ea7URk6vll88bWBVhodtnlfEuCcKWNGoc+uGbw1cwa9IKh/w=="},"node_modules/language-tags": {- "version": "1.0.7",- "resolved": "https://registry.npmjs.org/language-tags/-/language-tags-1.0.7.tgz",- "integrity": "sha512-bSytju1/657hFjgUzPAPqszxH62ouE8nQFoFaVlIQfne4wO/wXC9A4+m8jYve7YBBvi59eq0SUpcshvG8h5Usw==",+ "version": "1.0.5",+ "resolved": "https://registry.npmjs.org/language-tags/-/language-tags-1.0.5.tgz",+ "integrity": "sha512-qJhlO9cGXi6hBGKoxEG/sKZDAHD5Hnu9Hs4WbOY3pCWXDhw0N8x1NenNzm2EnNLkLkk7J2SdxAkDSbb6ftT+UQ==","dependencies": {- "language-subtag-registry": "^0.3.20"+ "language-subtag-registry": "~0.3.2"}},"node_modules/levn": {@@ -5407,6 +5508,21 @@"url": "https://github.com/sponsors/ljharb"}},+ "node_modules/object-is": {+ "version": "1.1.5",+ "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.5.tgz",+ "integrity": "sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw==",+ "dependencies": {+ "call-bind": "^1.0.2",+ "define-properties": "^1.1.3"+ },+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },"node_modules/object-keys": {"version": "1.1.1","resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",@@ -5815,9 +5931,9 @@}},"node_modules/punycode": {- "version": "2.1.1",- "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",- "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==",+ "version": "2.2.0",+ "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.2.0.tgz",+ "integrity": "sha512-LN6QV1IJ9ZhxWTNdktaPClrNfp8xdSAYS0Zk2ddX7XsXZAxckMHPCBcHRo0cTcEIgYPRiGEkmji3Idkh2yFtYw==","engines": {"node": ">=6"}@@ -6453,6 +6569,20 @@"url": "https://github.com/sponsors/ljharb"}},+ "node_modules/which-collection": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/which-collection/-/which-collection-1.0.1.tgz",+ "integrity": "sha512-W8xeTUwaln8i3K/cY1nGXzdnVZlidBcagyNFtBdD5kxnb4TvGKR7FfSIS3mYpwWS1QUCutfKz8IY8RjftB0+1A==",+ "dependencies": {+ "is-map": "^2.0.1",+ "is-set": "^2.0.1",+ "is-weakmap": "^2.0.1",+ "is-weakset": "^2.0.1"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },"node_modules/which-typed-array": {"version": "1.1.9","resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.9.tgz",@@ -6517,6 +6647,14 @@"url": "https://github.com/sponsors/sindresorhus"}},+ "packages/lib": {+ "name": "@documenso/lib",+ "version": "0.0.0",+ "dependencies": {+ "bcryptjs": "^2.4.3"+ },+ "devDependencies": {}+ },"packages/prisma": {"name": "@documenso/prisma","version": "0.0.0",@@ -6525,6 +6663,11 @@"prisma": "^4.8.0"},"devDependencies": {}+ },+ "packages/ui": {+ "name": "@documenso/ui",+ "version": "0.0.0",+ "devDependencies": {}}},"dependencies": {@@ -6536,13 +6679,10 @@"regenerator-runtime": "^0.13.11"}},- "@babel/runtime-corejs3": {- "version": "7.20.7",- "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.20.7.tgz",- "integrity": "sha512-jr9lCZ4RbRQmCR28Q8U8Fu49zvFqLxTY9AMOUz+iyMohMoAgpEcVxY+wJNay99oXOpOcCTODkk70NDN2aaJEeg==",+ "@documenso/lib": {+ "version": "file:packages/lib","requires": {- "core-js-pure": "^3.25.1",- "regenerator-runtime": "^0.13.11"+ "bcryptjs": "*"}},"@documenso/prisma": {@@ -6552,6 +6692,9 @@"prisma": "^4.8.0"}},+ "@documenso/ui": {+ "version": "file:packages/ui"+ },"@documenso/web": {"version": "file:apps/web","requires": {@@ -6559,10 +6702,12 @@"@headlessui/react": "^1.7.4","@heroicons/react": "^2.0.13","@tailwindcss/forms": "^0.5.3",+ "@types/bcryptjs": "^2.4.2","@types/node": "18.11.9","@types/react": "18.0.25","@types/react-dom": "18.0.9","autoprefixer": "^10.4.13",+ "bcryptjs": "^2.4.3","dotenv": "^16.0.3","eslint": "8.27.0","eslint-config-next": "13.0.3",@@ -6786,6 +6931,11 @@"mini-svg-data-uri": "^1.2.3"}},+ "@types/bcryptjs": {+ "version": "2.4.2",+ "resolved": "https://registry.npmjs.org/@types/bcryptjs/-/bcryptjs-2.4.2.tgz",+ "integrity": "sha512-LiMQ6EOPob/4yUL66SZzu6Yh77cbzJFYll+ZfaPiPPFswtIlA/Fs1MzdKYA7JApHU49zQTbJGX3PDmCpIdDBRQ=="+ },"@types/json5": {"version": "0.0.29","resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz",@@ -6825,37 +6975,37 @@"integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew=="},"@typescript-eslint/parser": {- "version": "5.48.0",- "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.48.0.tgz",- "integrity": "sha512-1mxNA8qfgxX8kBvRDIHEzrRGrKHQfQlbW6iHyfHYS0Q4X1af+S6mkLNtgCOsGVl8+/LUPrqdHMssAemkrQ01qg==",+ "version": "5.48.1",+ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.48.1.tgz",+ "integrity": "sha512-4yg+FJR/V1M9Xoq56SF9Iygqm+r5LMXvheo6DQ7/yUWynQ4YfCRnsKuRgqH4EQ5Ya76rVwlEpw4Xu+TgWQUcdA==","requires": {- "@typescript-eslint/scope-manager": "5.48.0",- "@typescript-eslint/types": "5.48.0",- "@typescript-eslint/typescript-estree": "5.48.0",+ "@typescript-eslint/scope-manager": "5.48.1",+ "@typescript-eslint/types": "5.48.1",+ "@typescript-eslint/typescript-estree": "5.48.1","debug": "^4.3.4"}},"@typescript-eslint/scope-manager": {- "version": "5.48.0",- "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.48.0.tgz",- "integrity": "sha512-0AA4LviDtVtZqlyUQnZMVHydDATpD9SAX/RC5qh6cBd3xmyWvmXYF+WT1oOmxkeMnWDlUVTwdODeucUnjz3gow==",+ "version": "5.48.1",+ "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.48.1.tgz",+ "integrity": "sha512-S035ueRrbxRMKvSTv9vJKIWgr86BD8s3RqoRZmsSh/s8HhIs90g6UlK8ZabUSjUZQkhVxt7nmZ63VJ9dcZhtDQ==","requires": {- "@typescript-eslint/types": "5.48.0",- "@typescript-eslint/visitor-keys": "5.48.0"+ "@typescript-eslint/types": "5.48.1",+ "@typescript-eslint/visitor-keys": "5.48.1"}},"@typescript-eslint/types": {- "version": "5.48.0",- "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.48.0.tgz",- "integrity": "sha512-UTe67B0Ypius0fnEE518NB2N8gGutIlTojeTg4nt0GQvikReVkurqxd2LvYa9q9M5MQ6rtpNyWTBxdscw40Xhw=="+ "version": "5.48.1",+ "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.48.1.tgz",+ "integrity": "sha512-xHyDLU6MSuEEdIlzrrAerCGS3T7AA/L8Hggd0RCYBi0w3JMvGYxlLlXHeg50JI9Tfg5MrtsfuNxbS/3zF1/ATg=="},"@typescript-eslint/typescript-estree": {- "version": "5.48.0",- "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.48.0.tgz",- "integrity": "sha512-7pjd94vvIjI1zTz6aq/5wwE/YrfIyEPLtGJmRfyNR9NYIW+rOvzzUv3Cmq2hRKpvt6e9vpvPUQ7puzX7VSmsEw==",+ "version": "5.48.1",+ "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.48.1.tgz",+ "integrity": "sha512-Hut+Osk5FYr+sgFh8J/FHjqX6HFcDzTlWLrFqGoK5kVUN3VBHF/QzZmAsIXCQ8T/W9nQNBTqalxi1P3LSqWnRA==","requires": {- "@typescript-eslint/types": "5.48.0",- "@typescript-eslint/visitor-keys": "5.48.0",+ "@typescript-eslint/types": "5.48.1",+ "@typescript-eslint/visitor-keys": "5.48.1","debug": "^4.3.4","globby": "^11.1.0","is-glob": "^4.0.3",@@ -6864,11 +7014,11 @@}},"@typescript-eslint/visitor-keys": {- "version": "5.48.0",- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.48.0.tgz",- "integrity": "sha512-5motVPz5EgxQ0bHjut3chzBkJ3Z3sheYVcSwS5BpHZpLqSptSmELNtGixmgj65+rIfhvtQTz5i9OP2vtzdDH7Q==",+ "version": "5.48.1",+ "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.48.1.tgz",+ "integrity": "sha512-Ns0XBwmfuX7ZknznfXozgnydyR8F6ev/KEGePP4i74uL3ArsKbEhJ7raeKr1JSa997DBDwol/4a0Y+At82c9dA==","requires": {- "@typescript-eslint/types": "5.48.0",+ "@typescript-eslint/types": "5.48.1","eslint-visitor-keys": "^3.3.0"}},@@ -6949,12 +7099,11 @@"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="},"aria-query": {- "version": "4.2.2",- "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-4.2.2.tgz",- "integrity": "sha512-o/HelwhuKpTj/frsOsbNLNgnNGVIFsVP/SW2BSF14gVl7kAfMOJ6/8wUAUvG1R1NHKrfG+2sHZTu0yauT1qBrA==",+ "version": "5.1.3",+ "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.1.3.tgz",+ "integrity": "sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ==","requires": {- "@babel/runtime": "^7.10.2",- "@babel/runtime-corejs3": "^7.10.2"+ "deep-equal": "^2.0.5"}},"array-includes": {@@ -7038,15 +7187,23 @@"integrity": "sha512-b1WlTV8+XKLj9gZy2DZXgQiyDp9xkkoe2a6U6UbYccScq2wgH/YwCeI2/Jq2mgo0HzQxqJOjWZBLeA/mqsk5Mg=="},"axobject-query": {- "version": "2.2.0",- "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz",- "integrity": "sha512-Td525n+iPOOyUQIeBfcASuG6uJsDOITl7Mds5gFyerkWiX7qhUTdYUBlSgNMyVqtSJqwpt1kXGLdUt6SykLMRA=="+ "version": "3.1.1",+ "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.1.1.tgz",+ "integrity": "sha512-goKlv8DZrK9hUh975fnHzhNIO4jUnFCfv/dszV5VwUGDFjI6vQ2VwoyjYjYNEbBE8AH87TduWP5uyDR1D+Iteg==",+ "requires": {+ "deep-equal": "^2.0.5"+ }},"balanced-match": {"version": "1.0.2","resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz","integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="},+ "bcryptjs": {+ "version": "2.4.3",+ "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz",+ "integrity": "sha512-V/Hy/X9Vt7f3BbPJEi8BdVFMByHi+jNXrYkW3huaybV/kQ0KJg0Y6PkEMbn+zeT+i+SiKZ/HMqJGIIt4LZDqNQ=="+ },"binary-extensions": {"version": "2.2.0","resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz",@@ -7167,11 +7324,6 @@"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz","integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw=="},- "core-js-pure": {- "version": "3.27.1",- "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.27.1.tgz",- "integrity": "sha512-BS2NHgwwUppfeoqOXqi08mUqS5FiZpuRuJJpKsaME7kJz0xxuk0xkhDdfMIlP/zLa80krBqss1LtD7f889heAw=="- },"cross-spawn": {"version": "7.0.3","resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",@@ -7205,6 +7357,30 @@"ms": "2.1.2"}},+ "deep-equal": {+ "version": "2.2.0",+ "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.2.0.tgz",+ "integrity": "sha512-RdpzE0Hv4lhowpIUKKMJfeH6C1pXdtT1/it80ubgWqwI3qpuxUBpC1S4hnHg+zjnuOoDkzUtUCEEkG+XG5l3Mw==",+ "requires": {+ "call-bind": "^1.0.2",+ "es-get-iterator": "^1.1.2",+ "get-intrinsic": "^1.1.3",+ "is-arguments": "^1.1.1",+ "is-array-buffer": "^3.0.1",+ "is-date-object": "^1.0.5",+ "is-regex": "^1.1.4",+ "is-shared-array-buffer": "^1.0.2",+ "isarray": "^2.0.5",+ "object-is": "^1.1.5",+ "object-keys": "^1.1.1",+ "object.assign": "^4.1.4",+ "regexp.prototype.flags": "^1.4.3",+ "side-channel": "^1.0.4",+ "which-boxed-primitive": "^1.0.2",+ "which-collection": "^1.0.1",+ "which-typed-array": "^1.1.9"+ }+ },"deep-is": {"version": "0.1.4","resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz",@@ -7324,6 +7500,21 @@"which-typed-array": "^1.1.9"}},+ "es-get-iterator": {+ "version": "1.1.2",+ "resolved": "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.2.tgz",+ "integrity": "sha512-+DTO8GYwbMCwbywjimwZMHp8AuYXOS2JZFWoi2AlPOS3ebnII9w/NLpNZtA7A0YLaVDw+O7KFCeoIV7OPvM7hQ==",+ "requires": {+ "call-bind": "^1.0.2",+ "get-intrinsic": "^1.1.0",+ "has-symbols": "^1.0.1",+ "is-arguments": "^1.1.0",+ "is-map": "^2.0.2",+ "is-set": "^2.0.2",+ "is-string": "^1.0.5",+ "isarray": "^2.0.5"+ }+ },"es-set-tostringtag": {"version": "2.0.1","resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.1.tgz",@@ -7533,22 +7724,25 @@}},"eslint-plugin-jsx-a11y": {- "version": "6.6.1",- "resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.6.1.tgz",- "integrity": "sha512-sXgFVNHiWffBq23uiS/JaP6eVR622DqwB4yTzKvGZGcPq6/yZ3WmOZfuBks/vHWo9GaFOqC2ZK4i6+C35knx7Q==",+ "version": "6.7.0",+ "resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.7.0.tgz",+ "integrity": "sha512-EGGRKhzejSzXKtjmEjWNtr4SK/DkMkSzkBH7g7e7moBDXZXrqaUIxkmD7uF93upMysc4dKYEJwupu7Dff+ShwA==","requires": {- "@babel/runtime": "^7.18.9",- "aria-query": "^4.2.2",- "array-includes": "^3.1.5",+ "@babel/runtime": "^7.20.7",+ "aria-query": "^5.1.3",+ "array-includes": "^3.1.6",+ "array.prototype.flatmap": "^1.3.1","ast-types-flow": "^0.0.7",- "axe-core": "^4.4.3",- "axobject-query": "^2.2.0",+ "axe-core": "^4.6.2",+ "axobject-query": "^3.1.1","damerau-levenshtein": "^1.0.8","emoji-regex": "^9.2.2","has": "^1.0.3",- "jsx-ast-utils": "^3.3.2",- "language-tags": "^1.0.5",+ "jsx-ast-utils": "^3.3.3",+ "language-tags": "=1.0.5","minimatch": "^3.1.2",+ "object.entries": "^1.1.6",+ "object.fromentries": "^2.0.6","semver": "^6.3.0"},"dependencies": {@@ -7986,6 +8180,15 @@"side-channel": "^1.0.4"}},+ "is-arguments": {+ "version": "1.1.1",+ "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz",+ "integrity": "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==",+ "requires": {+ "call-bind": "^1.0.2",+ "has-tostringtag": "^1.0.0"+ }+ },"is-array-buffer": {"version": "3.0.1","resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.1.tgz",@@ -8055,6 +8258,11 @@"is-extglob": "^2.1.1"}},+ "is-map": {+ "version": "2.0.2",+ "resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.2.tgz",+ "integrity": "sha512-cOZFQQozTha1f4MxLFzlgKYPTyj26picdZTx82hbc/Xf4K/tZOOXSCkMvU4pKioRXGDLJRn0GM7Upe7kR721yg=="+ },"is-negative-zero": {"version": "2.0.2","resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz",@@ -8087,6 +8295,11 @@"has-tostringtag": "^1.0.0"}},+ "is-set": {+ "version": "2.0.2",+ "resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.2.tgz",+ "integrity": "sha512-+2cnTEZeY5z/iXGbLhPrOAaK/Mau5k5eXq9j14CpRTftq0pAJu2MwVRSZhyZWBzx3o6X795Lz6Bpb6R0GKf37g=="+ },"is-shared-array-buffer": {"version": "1.0.2","resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz",@@ -8123,6 +8336,11 @@"has-tostringtag": "^1.0.0"}},+ "is-weakmap": {+ "version": "2.0.1",+ "resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.1.tgz",+ "integrity": "sha512-NSBR4kH5oVj1Uwvv970ruUkCV7O1mzgVFO4/rev2cLRda9Tm9HrL70ZPut4rOHgY0FNrUu9BCbXA2sdQ+x0chA=="+ },"is-weakref": {"version": "1.0.2","resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz",@@ -8131,6 +8349,20 @@"call-bind": "^1.0.2"}},+ "is-weakset": {+ "version": "2.0.2",+ "resolved": "https://registry.npmjs.org/is-weakset/-/is-weakset-2.0.2.tgz",+ "integrity": "sha512-t2yVvttHkQktwnNNmBQ98AhENLdPUTDTE21uPqAQ0ARwQfGeQKRVS0NNurH7bTf7RrvcVn1OOge45CnBeHCSmg==",+ "requires": {+ "call-bind": "^1.0.2",+ "get-intrinsic": "^1.1.1"+ }+ },+ "isarray": {+ "version": "2.0.5",+ "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz",+ "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw=="+ },"isexe": {"version": "2.0.0","resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",@@ -8192,11 +8424,11 @@"integrity": "sha512-tN0MCzyWnoz/4nHS6uxdlFWoUZT7ABptwKPQ52Ea7URk6vll88bWBVhodtnlfEuCcKWNGoc+uGbw1cwa9IKh/w=="},"language-tags": {- "version": "1.0.7",- "resolved": "https://registry.npmjs.org/language-tags/-/language-tags-1.0.7.tgz",- "integrity": "sha512-bSytju1/657hFjgUzPAPqszxH62ouE8nQFoFaVlIQfne4wO/wXC9A4+m8jYve7YBBvi59eq0SUpcshvG8h5Usw==",+ "version": "1.0.5",+ "resolved": "https://registry.npmjs.org/language-tags/-/language-tags-1.0.5.tgz",+ "integrity": "sha512-qJhlO9cGXi6hBGKoxEG/sKZDAHD5Hnu9Hs4WbOY3pCWXDhw0N8x1NenNzm2EnNLkLkk7J2SdxAkDSbb6ftT+UQ==","requires": {- "language-subtag-registry": "^0.3.20"+ "language-subtag-registry": "~0.3.2"}},"levn": {@@ -10137,6 +10369,15 @@"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz","integrity": "sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ=="},+ "object-is": {+ "version": "1.1.5",+ "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.5.tgz",+ "integrity": "sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw==",+ "requires": {+ "call-bind": "^1.0.2",+ "define-properties": "^1.1.3"+ }+ },"object-keys": {"version": "1.1.1","resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",@@ -10394,9 +10635,9 @@}},"punycode": {- "version": "2.1.1",- "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",- "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="+ "version": "2.2.0",+ "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.2.0.tgz",+ "integrity": "sha512-LN6QV1IJ9ZhxWTNdktaPClrNfp8xdSAYS0Zk2ddX7XsXZAxckMHPCBcHRo0cTcEIgYPRiGEkmji3Idkh2yFtYw=="},"queue-microtask": {"version": "1.2.3",@@ -10814,6 +11055,17 @@"is-symbol": "^1.0.3"}},+ "which-collection": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/which-collection/-/which-collection-1.0.1.tgz",+ "integrity": "sha512-W8xeTUwaln8i3K/cY1nGXzdnVZlidBcagyNFtBdD5kxnb4TvGKR7FfSIS3mYpwWS1QUCutfKz8IY8RjftB0+1A==",+ "requires": {+ "is-map": "^2.0.1",+ "is-set": "^2.0.1",+ "is-weakmap": "^2.0.1",+ "is-weakset": "^2.0.1"+ }+ },"which-typed-array": {"version": "1.1.9","resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.9.tgz",diff --git a/packages/lib/auth.ts b/packages/lib/auth.tsnew file mode 100644index 000000000..1c83255b6--- /dev/null+++ b/packages/lib/auth.ts@@ -0,0 +1,101 @@+import { compare, hash } from "bcryptjs";+import type { NextApiRequest } from "next";+import type { Session } from "next-auth";+import {+ getSession as getSessionInner,+ GetSessionParams,+} from "next-auth/react";++import { HttpError } from "@documenso/lib/server";++export async function hashPassword(password: string) {+ const hashedPassword = await hash(password, 12);+ return hashedPassword;+}++export async function verifyPassword(password: string, hashedPassword: string) {+ const isValid = await compare(password, hashedPassword);+ return isValid;+}++export function validPassword(password: string) {+ if (password.length < 7) return false;++ if (!/[A-Z]/.test(password) || !/[a-z]/.test(password)) return false;++ if (!/\d+/.test(password)) return false;++ return true;+}++export async function getSession(+ options: GetSessionParams+): Promise<Session | null> {+ const session = await getSessionInner(options);++ // that these are equal are ensured in `[...nextauth]`'s callback+ return session as Session | null;+}++export function isPasswordValid(password: string): boolean;+export function isPasswordValid(+ password: string,+ breakdown: boolean,+ strict?: boolean+): { caplow: boolean; num: boolean; min: boolean; admin_min: boolean };+export function isPasswordValid(+ password: string,+ breakdown?: boolean,+ strict?: boolean+) {+ let cap = false, // Has uppercase characters+ low = false, // Has lowercase characters+ num = false, // At least one number+ min = false, // Eight characters, or fifteen in strict mode.+ admin_min = false;+ if (password.length > 7 && (!strict || password.length > 14)) min = true;+ if (strict && password.length > 14) admin_min = true;+ for (let i = 0; i < password.length; i++) {+ if (!isNaN(parseInt(password[i]))) num = true;+ else {+ if (password[i] === password[i].toUpperCase()) cap = true;+ if (password[i] === password[i].toLowerCase()) low = true;+ }+ }++ if (!breakdown)+ return cap && low && num && min && (strict ? admin_min : true);++ let errors: Record<string, boolean> = { caplow: cap && low, num, min };+ // Only return the admin key if strict mode is enabled.+ if (strict) errors = { ...errors, admin_min };++ return errors;+}++type CtxOrReq =+ | { req: NextApiRequest; ctx?: never }+ | { ctx: { req: NextApiRequest }; req?: never };++export const ensureSession = async (ctxOrReq: CtxOrReq) => {+ const session = await getSession(ctxOrReq);+ if (!session?.user)+ throw new HttpError({ statusCode: 401, message: "Unauthorized" });+ return session;+};++export enum ErrorCode {+ UserNotFound = "user-not-found",+ IncorrectPassword = "incorrect-password",+ UserMissingPassword = "missing-password",+ TwoFactorDisabled = "two-factor-disabled",+ TwoFactorAlreadyEnabled = "two-factor-already-enabled",+ TwoFactorSetupRequired = "two-factor-setup-required",+ SecondFactorRequired = "second-factor-required",+ IncorrectTwoFactorCode = "incorrect-two-factor-code",+ InternalServerError = "internal-server-error",+ NewPasswordMatchesOld = "new-password-matches-old",+ ThirdPartyIdentityProviderEnabled = "third-party-identity-provider-enabled",+ RateLimitExceeded = "rate-limit-exceeded",+ SocialIdentityProviderRequired = "social-identity-provider-required",+}diff --git a/packages/lib/package.json b/packages/lib/package.jsonindex c9dd457c3..366f15115 100644--- a/packages/lib/package.json+++ b/packages/lib/package.json@@ -3,6 +3,7 @@"version": "0.0.0","private": true,"main": "index.ts",- "devDependencies": {},- "dependencies": {}+ "dependencies": {+ "bcryptjs": "^2.4.3"+ }}diff --git a/packages/prisma/schema.prisma b/packages/prisma/schema.prismaindex 197c72bf2..588625b85 100644--- a/packages/prisma/schema.prisma+++ b/packages/prisma/schema.prisma@@ -26,12 +26,48 @@ model Recipient {}model User {- id Int @id @default(autoincrement())- firstName String? @db.VarChar(255)- lastName String? @db.VarChar(255)- email String @unique @db.VarChar(255)- password String? @db.VarChar(255)- Document Document[]+ id Int @id @default(autoincrement())+ username String? @unique+ name String?+ email String @unique+ emailVerified DateTime?+ password String?+ identityProvider IdentityProvider @default(DOCUMENSO)+ accounts Account[]+ sessions Session[]+ Document Document[]+}++model Account {+ id String @id @default(cuid())+ userId Int+ type String+ provider String+ providerAccountId String+ refresh_token String? @db.Text+ access_token String? @db.Text+ expires_at Int?+ token_type String?+ scope String?+ id_token String? @db.Text+ session_state String?++ user User? @relation(fields: [userId], references: [id], onDelete: Cascade)++ @@unique([provider, providerAccountId])+}++model Session {+ id String @id @default(cuid())+ sessionToken String @unique+ userId Int+ expires DateTime+ user User? @relation(fields: [userId], references: [id], onDelete: Cascade)+}++enum IdentityProvider {+ DOCUMENSO}enum ReadStatus {diff --git a/packages/types/next-auth.d.ts b/packages/types/next-auth.d.tsnew file mode 100644index 000000000..72a623fa8--- /dev/null+++ b/packages/types/next-auth.d.ts@@ -0,0 +1,20 @@+import { User as PrismaUser } from "@prisma/client";+import { DefaultUser } from "next-auth";++declare module "next-auth" {+ /**+ * Returned by `useSession`, `getSession` and received as a prop on the `Provider` React Context+ */+ interface Session {+ hasValidLicense: boolean;+ user: User;+ }+ interface User extends Omit<DefaultUser, "id"> {+ id: PrismaUser["id"];+ emailVerified?: PrismaUser["emailVerified"];+ email_verified?: boolean;+ impersonatedByUID?: number;+ belongsToActiveTeam?: boolean;+ username?: PrismaUser["username"];+ }+}