Skip to content

Commit

Permalink
Merge pull request #119 from rmarscher/lucia-check-types-fixes
Browse files Browse the repository at this point in the history
Lucia check types fixes
  • Loading branch information
timothymiller authored Nov 28, 2023
2 parents 857563d + 01182a0 commit 7424443
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 36 deletions.
45 changes: 45 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Code of Conduct

1. Respect and Inclusion
- Treat all individuals with respect, regardless of their background, identity, or beliefs.
- Foster an inclusive environment where everyone feels welcome and valued.

2. Professionalism
- Maintain a professional demeanor in all interactions, both online and offline.
- Avoid engaging in personal attacks, harassment, or discrimination.

3. Collaboration and Teamwork
- Encourage open and constructive communication.
- Collaborate with others in a cooperative and respectful manner.
- Value diverse perspectives and opinions.

4. Accountability
- Take responsibility for your actions and their impact on others.
- Accept constructive feedback and learn from it.
- Adhere to the company's policies and procedures.

5. Confidentiality and Privacy
- Respect the confidentiality and privacy of sensitive information.
- Protect personal data and use it only for authorized purposes.

6. Prohibition of Profanity
- Refrain from using profanity, offensive language, or derogatory remarks.
- Maintain a professional and respectful tone in all communications.
- Use appropriate language to ensure a positive and inclusive environment.

7. Compliance with Laws and Regulations
- Adhere to all applicable laws, regulations, and industry standards.
- Report any illegal or unethical behavior to the appropriate authorities.

8. Safety and Security
- Promote a safe and secure environment for all individuals.
- Report any potential security risks or concerns promptly.

9. Continuous Learning and Improvement
- Stay updated with industry trends and best practices.
- Foster a culture of learning and support professional development.

10. Enforcement
- Violations of this Code of Conduct may result in disciplinary action, up to and including termination.

Remember, this Code of Conduct serves as a guideline for expected behavior and sets the standard for a respectful and professional environment. It is essential to review and adhere to this code to create a positive and inclusive community.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<img src="https://img.shields.io/discord/1117289587472081016?color=%235865F2&label=Discord&logo=discord&logoColor=white&style=for-the-badge" alt="Join the T4 discord community">
</a>&nbsp;
<a href = "https://www.npmjs.com/package/create-t4-app">
<img src="https://img.shields.io/npm/dw/create-t4-app?logo=npm&style=for-the-badge&color=CC3534" alt="Weekly downloads for create-t4-app on npmjs.org">
<img src="https://img.shields.io/npm/dm/create-t4-app?logo=npm&style=for-the-badge&color=CC3534" alt="Weekly downloads for create-t4-app on npmjs.org">
</a>&nbsp;
<a href="https://marketplace.visualstudio.com/items?itemName=albbus.t4-app-tools">
<img src="https://img.shields.io/visual-studio-marketplace/i/albbus.t4-app-tools?logo=visual-studio-code&style=for-the-badge&color=0078D7" alt="VSCode Extension Installs">
Expand All @@ -36,6 +36,8 @@ The T4 Stack is a universal web and native stack made by [Tim Miller](https://tw

Easy integration with **Cloudflare** services, such as R2 & D1 enable developers to build apps with **AI-powered features** at a **lower cost** compared to AWS.

Ship it today and witness **6 second package install** times & **30 second backend deployments**.

👉 Further documentation can be found on the [T4 Stack website](https://t4stack.com). 👈

<br>
Expand Down Expand Up @@ -107,7 +109,7 @@ Easy integration with **Cloudflare** services, such as R2 & D1 enable developers

## 📖 Background

T4 is a project starter kit for building **type-safe**, **native** & **web** applications in TypeScript using Tamagui, tRPC, and Turborepo. Deploy to Cloudflare for a global edge network. All at a fraction of the cost of AWS, Vercel, or Azure.
T4 is a project starter kit for building **type-safe**, **native** & **web** applications in TypeScript using Tamagui, tRPC, and Tauri. Deploy to Cloudflare for a global edge network. All at a fraction of the cost of AWS, Vercel, or Azure.

It provides a unified, opinionated, & minimalistic setup for quickly getting started with building native & web apps, using the same code, without having to worry about the complexities of setting up a development environment.

Expand Down
10 changes: 5 additions & 5 deletions apps/expo/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "react-native-url-polyfill/auto";
import 'react-native-url-polyfill/auto'
// ^^ Remove after upgrade to Expo v50
// https://github.com/expo/expo/pull/24941
import "expo-router/entry";
import { LogBox } from "react-native";
console.disableYellowBox = true;
LogBox.ignoreAllLogs();
import 'expo-router/entry'
import { LogBox } from 'react-native'
console.disableYellowBox = true
LogBox.ignoreAllLogs()
2 changes: 1 addition & 1 deletion apps/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@supabase/auth-helpers-react": "^0.4.2",
"@t4/ui": "workspace:*",
"@tamagui/next-theme": "1.75.9",
"@tsndr/cloudflare-worker-jwt": "^2.2.5",
"@tsndr/cloudflare-worker-jwt": "2.2.7",
"app": "workspace:*",
"million": "2.6.4",
"next": "14.0.1",
Expand Down
3 changes: 2 additions & 1 deletion apps/next/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import '@tamagui/core/reset.css'
import '@tamagui/font-inter/css/400.css'
import '@tamagui/font-inter/css/700.css'

import type { Session } from '@supabase/supabase-js'
// import type { Session } from '@supabase/supabase-js'
import type { Session } from 'app/utils/auth'
import { Provider } from 'app/provider'
import { trpc } from 'app/utils/trpc/index.web'
import { DefaultSeo } from 'next-seo'
Expand Down
Binary file removed bun.lockb
Binary file not shown.
12 changes: 6 additions & 6 deletions packages/api/drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { defineConfig } from 'drizzle-kit/utils'
import type { Config } from 'drizzle-kit'

export default defineConfig({
export default {
schema: './src/db/schema.ts',
out: './migrations',
driver: 'd1',
dbCredentials: {
wranglerConfigPath: 'wrangler.toml',
dbName: 'production',
},
schema: './src/db/schema.ts',
out: './migrations',
verbose: true,
verbose: false,
strict: true,
})
} satisfies Config
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@lucia-auth/adapter-sqlite": "3.0.0-beta.1",
"@trpc/server": "^10.43.2",
"arctic": "0.3.1",
"drizzle-orm": "0.29.0",
"drizzle-orm": "^0.29.0",
"drizzle-valibot": "beta",
"hono": "^3.9.2",
"lucia": "3.0.0-beta.6",
Expand Down
10 changes: 0 additions & 10 deletions packages/api/src/schema/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,8 @@ import {
toLowerCase,
toTrimmed,
} from 'valibot'
import type { User as SessionUser } from 'lucia'
import type { User } from '../db/schema'
import { AuthProviderName } from '../auth/providers'

export function isSessionUser(user: User | SessionUser): user is SessionUser {
return !!(user as SessionUser).userId
}

export function isUser(user: User | SessionUser): user is User {
return !!(user as User).id
}

const email = string('Email address is required.', [
toTrimmed(),
minLength(1, 'Email address is required.'),
Expand Down
3 changes: 2 additions & 1 deletion packages/api/src/utils/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ function getTotpController({ seconds = 30 }: { seconds?: number } = {}) {
period: new TimeSpan(seconds, 's'),
})
}
return totpControllers[seconds]
return totpControllers[seconds] as TOTPController
}

async function getTotpSecret(secret?: string) {
if (secret) {
totpSecret = decodeBase64(secret).buffer as ArrayBuffer
}
if (!totpSecret) {
// @ts-ignore TS1323 (fix needed for top-level tsc that runs without esnext module target)
const { HMAC } = await import('oslo/crypto')
totpSecret = await new HMAC('SHA-1').generateKey()
console.log(
Expand Down
4 changes: 3 additions & 1 deletion packages/api/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ const app = new Hono<{ Bindings: Bindings }>()

const corsHandler = async (c: Context<{ Bindings: Bindings }>, next: Next) => {
if (c.env.APP_URL === undefined) {
console.log('APP_URL is not set. CORS errors may occur.')
console.log(
'APP_URL is not set. CORS errors may occur. Make sure the .dev.vars file is present at /packages/api/.dev.vars'
)
}
return await cors({
origin: [c.env.APP_URL],
Expand Down
2 changes: 0 additions & 2 deletions packages/app/utils/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,4 @@ export function useSessionRedirect(props: SessionRedirectProps = { true: '/', fa
}, [user, isLoadingSession, props, push])
}

export * from 'app/utils/auth/validation'

export type { Session }
5 changes: 0 additions & 5 deletions packages/app/utils/auth/validation.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/app/utils/supabase/cookies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function getCookieValue(cookieName: string): string | undefined {
}

if (cookie?.indexOf(cookieName) === 0) {
const cookieValue = cookie.substring(cookieNameLength + 1)
const cookieValue = cookie.replace('-code-verifier', '').substring(cookieNameLength + 1)
return decodeURIComponent(cookieValue)
}
}
Expand Down

0 comments on commit 7424443

Please sign in to comment.