Skip to content

Commit

Permalink
fix(auth): update all non-major dependencies (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeKarow committed Mar 29, 2023
2 parents db223bc + 755bb3f commit 03c3c6d
Show file tree
Hide file tree
Showing 22 changed files with 939 additions and 900 deletions.
36 changes: 18 additions & 18 deletions apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,27 @@
},
"dependencies": {
"@aws-crypto/sha256-js": "4.0.0",
"@aws-sdk/client-s3": "3.300.0",
"@aws-sdk/client-s3": "3.301.0",
"@aws-sdk/signature-v4": "3.299.0",
"@crowdin/crowdin-api-client": "1.22.1",
"@crowdin/ota-client": "0.7.0",
"@emotion/react": "11.10.6",
"@emotion/server": "11.10.0",
"@iconify/react": "4.1.0",
"@mantine/carousel": "6.0.4",
"@mantine/core": "6.0.4",
"@mantine/dates": "6.0.4",
"@mantine/dropzone": "6.0.4",
"@mantine/form": "6.0.4",
"@mantine/hooks": "6.0.4",
"@mantine/modals": "6.0.4",
"@mantine/next": "6.0.4",
"@mantine/notifications": "6.0.4",
"@mantine/nprogress": "6.0.4",
"@mantine/prism": "6.0.4",
"@mantine/spotlight": "6.0.4",
"@mantine/tiptap": "6.0.4",
"@mantine/utils": "6.0.4",
"@mantine/carousel": "6.0.5",
"@mantine/core": "6.0.5",
"@mantine/dates": "6.0.5",
"@mantine/dropzone": "6.0.5",
"@mantine/form": "6.0.5",
"@mantine/hooks": "6.0.5",
"@mantine/modals": "6.0.5",
"@mantine/next": "6.0.5",
"@mantine/notifications": "6.0.5",
"@mantine/nprogress": "6.0.5",
"@mantine/prism": "6.0.5",
"@mantine/spotlight": "6.0.5",
"@mantine/tiptap": "6.0.5",
"@mantine/utils": "6.0.5",
"@next/bundle-analyzer": "13.2.4",
"@tanstack/react-query": "4.28.0",
"@tiptap/extension-link": "2.0.0-beta.220",
Expand Down Expand Up @@ -80,13 +80,13 @@
},
"devDependencies": {
"@playwright/test": "1.32.1",
"@prisma/nextjs-monorepo-workaround-plugin": "4.11.0",
"@prisma/nextjs-monorepo-workaround-plugin": "4.12.0",
"@tanstack/react-query-devtools": "4.28.0",
"@total-typescript/ts-reset": "0.4.2",
"@types/eslint": "8.21.3",
"@types/flat": "5.0.2",
"@types/luxon": "3.2.0",
"@types/node": "18.15.10",
"@types/node": "18.15.11",
"@types/react": "18.0.31",
"@types/react-dom": "18.0.11",
"@types/umami": "0.1.1",
Expand All @@ -96,7 +96,7 @@
"@weareinreach/eslint-config": "0.100.0",
"commander": "10.0.0",
"dotenv": "16.0.3",
"eslint": "8.36.0",
"eslint": "8.37.0",
"eslint-plugin-i18next": "6.0.0-8",
"flat": "5.0.2",
"listr2": "5.0.8",
Expand Down
4 changes: 4 additions & 0 deletions apps/app/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@
"password-req-number": "Includes number",
"password-req-special": "Includes special character",
"password-req-uppercase": "Includes uppercase letter",
"password-reset": {
"email-body": "Click the following link to reset your password:",
"email-subject": "Reset your password"
},
"password-reset-success": "<Text>Please <LoginModal>login</LoginModal> using your new password.</Text>",
"password-saved": "Password saved!",
"phone": "Phone",
Expand Down
30 changes: 15 additions & 15 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@
"@crowdin/ota-client": "0.7.0",
"@emotion/react": "11.10.6",
"@emotion/server": "11.10.0",
"@mantine/carousel": "6.0.4",
"@mantine/core": "6.0.4",
"@mantine/dates": "6.0.4",
"@mantine/dropzone": "6.0.4",
"@mantine/form": "6.0.4",
"@mantine/hooks": "6.0.4",
"@mantine/modals": "6.0.4",
"@mantine/next": "6.0.4",
"@mantine/notifications": "6.0.4",
"@mantine/nprogress": "6.0.4",
"@mantine/prism": "6.0.4",
"@mantine/spotlight": "6.0.4",
"@mantine/tiptap": "6.0.4",
"@mantine/carousel": "6.0.5",
"@mantine/core": "6.0.5",
"@mantine/dates": "6.0.5",
"@mantine/dropzone": "6.0.5",
"@mantine/form": "6.0.5",
"@mantine/hooks": "6.0.5",
"@mantine/modals": "6.0.5",
"@mantine/next": "6.0.5",
"@mantine/notifications": "6.0.5",
"@mantine/nprogress": "6.0.5",
"@mantine/prism": "6.0.5",
"@mantine/spotlight": "6.0.5",
"@mantine/tiptap": "6.0.5",
"@tiptap/extension-link": "2.0.0-beta.220",
"@tiptap/react": "2.0.0-beta.220",
"@tiptap/starter-kit": "2.0.0-beta.220",
Expand All @@ -43,12 +43,12 @@
"devDependencies": {
"@next/bundle-analyzer": "13.2.4",
"@types/eslint": "8.21.3",
"@types/node": "18.15.10",
"@types/node": "18.15.11",
"@types/react": "18.0.31",
"@types/react-dom": "18.0.11",
"@weareinreach/config": "0.100.0",
"@weareinreach/eslint-config": "0.100.0",
"eslint": "8.36.0",
"eslint": "8.37.0",
"typescript": "5.0.2"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@changesets/cli": "2.26.1",
"@manypkg/cli": "0.20.0",
"@types/eslint": "8.21.3",
"@types/node": "18.15.10",
"@types/node": "18.15.11",
"@types/prettier": "2.7.2",
"@weareinreach/config": "0.100.0",
"@weareinreach/eslint-config": "0.100.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"dependencies": {
"@googlemaps/google-maps-services-js": "3.3.27",
"@tanstack/react-query": "4.28.0",
"@terraformer/wkt": "2.1.2",
"@terraformer/wkt": "2.2.0",
"@trpc/client": "10.18.0",
"@trpc/next": "10.18.0",
"@trpc/react-query": "10.18.0",
Expand All @@ -38,18 +38,18 @@
},
"devDependencies": {
"@types/eslint": "8.21.3",
"@types/node": "18.15.10",
"@types/node": "18.15.11",
"@types/prettier": "2.7.2",
"@types/terraformer__wkt": "2.0.0",
"@weareinreach/config": "0.100.0",
"@weareinreach/eslint-config": "0.100.0",
"dotenv-cli": "7.1.0",
"eslint": "8.36.0",
"eslint": "8.37.0",
"just-capitalize": "3.2.0",
"listr2": "5.0.8",
"next": "13.2.4",
"prettier": "2.8.7",
"prisma": "4.11.0",
"prisma": "4.12.0",
"trpc-client-devtools-link": "0.2.1-next",
"tslog": "4.8.2",
"typescript": "5.0.2"
Expand Down
12 changes: 5 additions & 7 deletions packages/api/router/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
type AdminCreateUserInput,
CognitoBase64,
ResetPassword,
ForgotPassword,
} from '~api/schemas/create/user'

export const userRouter = defineRouter({
Expand Down Expand Up @@ -127,13 +128,10 @@ export const userRouter = defineRouter({
handleError(error)
}
}),
forgotPassword: publicProcedure
.input(z.object({ email: z.string().email() }))
.mutation(async ({ input }) => {
const response = await forgotPassword(input.email)

return response
}),
forgotPassword: publicProcedure.input(ForgotPassword).mutation(async ({ input }) => {
const response = await forgotPassword(input)
return response
}),
confirmAccount: publicProcedure.input(CognitoBase64).mutation(async ({ input }) => {
const { code, email } = input
const response = await confirmAccount(email, code)
Expand Down
26 changes: 22 additions & 4 deletions packages/api/schemas/create/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ const CreateUserBase = {
/** Requires either `id` or `slug` */
currentGovDist: z.union([id, slug]).optional(),
userType: z.string().default('seeker'),
cognitoMessage: z.string().optional(),
cogintoSubject: z.string().optional(),
cognitoMessage: z.string().default('Confirm your account'),
cogintoSubject: z.string().default('Click the following link to confirm your account:'),
}

export const CreateUser = z
Expand Down Expand Up @@ -107,7 +107,7 @@ export const AdminCreateUser = () => {
z.object({ ...CreateUserBase, ...adminCreateFields })
)
const dataParser = parser.transform(({ actorId, data, operation }) => {
const { id, name, email, password, image } = data
const { id, name, email, password, image, cogintoSubject, cognitoMessage } = data
const [permissions, permissionLogs] = linkManyWithAudit(data?.permissions, actorId)
const [orgPermission, orgPermissionLogs] = linkManyWithAudit(data?.orgPermission, actorId, {
auditDataKeys: ['authorized'],
Expand Down Expand Up @@ -152,7 +152,13 @@ export const AdminCreateUser = () => {
},
select: { id: true },
}),
cognito: { databaseId: id, email, password },
cognito: {
databaseId: id,
email,
password,
message: data.cognitoMessage,
subject: data.cogintoSubject,
},
}
})
return { dataParser, inputSchema }
Expand Down Expand Up @@ -221,3 +227,15 @@ export const ResetPassword = z
password: z.string(),
})
.transform(({ data, password, code }) => ({ password, code, ...decodeUrl(data) }))

export const ForgotPassword = z
.object({
email: z.string().email(),
cognitoMessage: z.string(),
cognitoSubject: z.string(),
})
.transform(({ email, cognitoMessage, cognitoSubject }) => ({
email,
subject: cognitoSubject,
message: cognitoMessage,
}))
10 changes: 7 additions & 3 deletions packages/auth/lib/createUser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable node/no-process-env */
/* eslint-disable turbo/no-undeclared-env-vars */
import { prisma } from '@weareinreach/db'
import { z } from 'zod'

import { ClientId, cognito, generateHash } from './cognitoClient'
Expand Down Expand Up @@ -63,5 +62,10 @@ export const createCognitoUser = async (data: CreateCognitoUserParams) => {
}
}

type CreateCognitoUser = (data: CreateCognitoUserParams) => Promise<unknown>
type CreateCognitoUserParams = { email: string; password: string; databaseId: string }
type CreateCognitoUserParams = {
email: string
password: string
databaseId: string
subject: string
message: string
}
19 changes: 16 additions & 3 deletions packages/auth/lib/forgotPassword.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
import { z } from 'zod'

import { cognito, ClientId, generateHash } from './cognitoClient'
import { getBaseUrl } from './getBaseUrl'

export const forgotPassword: ForgotPassword = async (email) => {
const ForgotPasswordSchema = z.object({
email: z.string().email(),
subject: z.string().default('Reset your password'),
message: z.string().default('Click the following link to reset your password:'),
})
export const forgotPassword = async (data: ForgotPasswordParams) => {
const { email, message, subject } = ForgotPasswordSchema.parse(data)

const response = await cognito.forgotPassword({
ClientId,
Username: email,
SecretHash: generateHash(email),
ClientMetadata: { baseUrl: getBaseUrl() },
ClientMetadata: { baseUrl: getBaseUrl(), message, subject },
})

return response
}

type ForgotPassword = (email: string) => Promise<unknown>
type ForgotPasswordParams = {
email: string
subject: string
message: string
}
1 change: 1 addition & 0 deletions packages/auth/lib/getBaseUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* eslint-disable node/no-process-env */
export const getBaseUrl = () => {
if (typeof window !== 'undefined') return '' // browser should use relative url
if (process.env.BASE_URL) return `https://${process.env.BASE_URL}` // Use env var, if set - VERCEL_URL only points to the internal `vercel.app` url.
if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}` // SSR should use vercel url
return `http://localhost:${process.env.PORT ?? 3000}` // dev SSR should use localhost
}
6 changes: 3 additions & 3 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@
"type-check": "tsc --noEmit"
},
"dependencies": {
"@aws-sdk/client-cognito-identity-provider": "3.300.0",
"@aws-sdk/client-cognito-identity-provider": "3.301.0",
"@next-auth/prisma-adapter": "1.0.5",
"aws-jwt-verify": "4.0.0",
"tiny-invariant": "1.3.1",
"zod": "3.21.4"
},
"devDependencies": {
"@types/eslint": "8.21.3",
"@types/node": "18.15.10",
"@types/node": "18.15.11",
"@types/react": "18.0.31",
"@types/react-dom": "18.0.11",
"@weareinreach/config": "0.100.0",
"@weareinreach/db": "0.100.0",
"@weareinreach/eslint-config": "0.100.0",
"eslint": "8.36.0",
"eslint": "8.37.0",
"next": "13.2.4",
"next-auth": "4.20.1",
"react": "18.2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/aws-cache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
"@types/aws-lambda": "8.10.114",
"@types/eslint": "8.21.3",
"@types/flat": "5.0.2",
"@types/node": "18.15.10",
"@types/node": "18.15.11",
"@types/prettier": "2.7.2",
"@vercel/ncc": "0.36.1",
"@weareinreach/config": "0.100.0",
"@weareinreach/eslint-config": "0.100.0",
"aws-lambda": "1.0.7",
"esbuild": "0.17.14",
"eslint": "8.36.0",
"eslint": "8.37.0",
"prettier": "2.8.7",
"typescript": "5.0.2"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/aws-messaging/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
"devDependencies": {
"@types/aws-lambda": "8.10.114",
"@types/eslint": "8.21.3",
"@types/node": "18.15.10",
"@types/node": "18.15.11",
"@types/prettier": "2.7.2",
"@vercel/ncc": "0.36.1",
"@weareinreach/config": "0.100.0",
"@weareinreach/eslint-config": "0.100.0",
"aws-lambda": "1.0.7",
"eslint": "8.36.0",
"eslint": "8.37.0",
"prettier": "2.8.7",
"typescript": "5.0.2"
}
Expand Down
8 changes: 4 additions & 4 deletions packages/aws-user-migrate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@
},
"dependencies": {
"@aws-lambda-powertools/logger": "1.7.0",
"@prisma/client": "4.11.0",
"@prisma/client": "4.12.0",
"@weareinreach/db": "0.100.0"
},
"devDependencies": {
"@types/aws-lambda": "8.10.114",
"@types/eslint": "8.21.3",
"@types/node": "18.15.10",
"@types/node": "18.15.11",
"@types/prettier": "2.7.2",
"@vercel/ncc": "0.36.1",
"@weareinreach/config": "0.100.0",
"@weareinreach/eslint-config": "0.100.0",
"aws-lambda": "1.0.7",
"eslint": "8.36.0",
"eslint": "8.37.0",
"prettier": "2.8.7",
"prisma": "4.11.0",
"prisma": "4.12.0",
"typescript": "5.0.2"
}
}
2 changes: 1 addition & 1 deletion packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"znv": "0.3.2"
},
"devDependencies": {
"@types/node": "18.15.10",
"@types/node": "18.15.11",
"@weareinreach/eslint-config": "0.100.0",
"next-i18next": "13.2.2",
"typescript": "5.0.2"
Expand Down
Loading

0 comments on commit 03c3c6d

Please sign in to comment.