Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
b4e1769
WIP initial implementation
infomiho Jul 22, 2025
8b708bb
Apply the SDK location hack to the libs
infomiho Jul 22, 2025
49d979c
Include libs in the built CLI
infomiho Jul 22, 2025
a352e57
Merge branch 'main' into templates-to-libs
infomiho Jul 28, 2025
97a6838
Add build config. Copy libs in the Dockerfile.
infomiho Jul 28, 2025
121901f
Update todoApp package-lock.json
infomiho Jul 28, 2025
4e248ae
Merge branch 'main' into templates-to-libs
infomiho Jul 29, 2025
ac9d038
Fixes libs deps install in Dockerfile
infomiho Jul 29, 2025
3840e58
Move to using npm pack
infomiho Jul 30, 2025
db8aaeb
Formatting
infomiho Jul 30, 2025
ac55723
Client entry point experiment
infomiho Jul 30, 2025
6dfc790
Fix copy command
infomiho Jul 30, 2025
7a84ae8
Formatting
infomiho Jul 30, 2025
e8c955a
Refactor code
infomiho Jul 31, 2025
f0cfe95
Cleanup
infomiho Jul 31, 2025
2f77c1c
Merge branch 'main' into templates-to-libs
infomiho Aug 11, 2025
36b720c
Install script update
infomiho Aug 11, 2025
083fecb
Append hash to tarball path
infomiho Aug 11, 2025
9a70244
Exclude auth lib from Vite optimizations
infomiho Aug 11, 2025
b450ef2
Test auth client code, test using peerDependencies.
infomiho Aug 11, 2025
00e6fbf
Migrate to tsdown
infomiho Aug 11, 2025
90eab52
Refactor unit tests
infomiho Aug 11, 2025
6b6b2f7
Move typeVersions comment
infomiho Aug 11, 2025
3c818cd
d.ts sourcemap. cleanup.
infomiho Aug 11, 2025
7e76f65
PR comments
infomiho Aug 11, 2025
43aaac5
Refactor
infomiho Aug 11, 2025
1073098
Update shell scripts
infomiho Aug 12, 2025
828b096
Use newtype
infomiho Aug 12, 2025
aa05550
Fix unit tests
infomiho Aug 12, 2025
c4099d5
Update exports to be explict about sdk and server exports
infomiho Aug 12, 2025
82f258c
Refactor WaspLib to have the checksum from creation
infomiho Aug 12, 2025
c3454d7
Copy libs to both out and build dir
infomiho Aug 12, 2025
22958f5
Update the README
infomiho Aug 13, 2025
9f3a53a
Update README and WaspLib to clarify library versioning and improve S…
infomiho Aug 13, 2025
a06e101
Remove redundant copying of libs to the build directory
infomiho Aug 13, 2025
1e1d36c
Merge branch 'main' into templates-to-libs
infomiho Aug 14, 2025
190e789
PR comments
infomiho Aug 14, 2025
fb548b0
Fix Dockerfile consistency
infomiho Aug 14, 2025
48dfe49
Comment dots, scripts cleanup.
infomiho Aug 14, 2025
58fe09a
Formatting
infomiho Aug 14, 2025
bd54fb4
Merge branch 'main' into templates-to-libs
infomiho Aug 14, 2025
ef0182b
Improve Tarball module
infomiho Aug 14, 2025
8851649
WaspLibs comment
infomiho Aug 14, 2025
9fc9e17
Add WaspLib comment
infomiho Aug 14, 2025
8a4ce86
Define SDK package name
infomiho Aug 14, 2025
a88c972
Unit tests helper
infomiho Aug 14, 2025
5bd2680
PR comments
infomiho Aug 14, 2025
4f0a8e7
Naming
infomiho Aug 14, 2025
211a04b
Update unit tests
infomiho Aug 14, 2025
03066ee
Move getting WaspLibs out of AppSpec
infomiho Aug 14, 2025
ae1255b
Ignore `tgz` files in e2e tests (#3078)
infomiho Sep 9, 2025
b9ace98
Merge branch 'main' into templates-to-libs
infomiho Sep 9, 2025
f50e54b
Fix unit tests
infomiho Sep 9, 2025
2478372
Merge branch 'main' into templates-to-libs
infomiho Sep 10, 2025
cd5347c
Remove typesVersions since it's redundant now
infomiho Sep 10, 2025
438314a
Rename from @wasp.sh/{libs-auth => lib-auth}
infomiho Sep 10, 2025
10803d4
Improve password tests
infomiho Sep 10, 2025
52fe7f2
Add Reader monad to Generator to use WaspLibs more easily
infomiho Sep 11, 2025
f2df493
Replace explicit copying of libs with generating copy file drafts
infomiho Sep 11, 2025
b234395
PR comments
infomiho Sep 11, 2025
669faca
Merge branch 'main' into templates-to-libs
infomiho Sep 24, 2025
4e6ddbb
Merge branch 'main' into templates-to-libs
infomiho Sep 26, 2025
5f3078e
PR comments
infomiho Sep 26, 2025
b0417a3
Named empty waspLibs list
infomiho Sep 27, 2025
a695db1
Update package copying scripts safety
infomiho Sep 27, 2025
cd6940b
Rename npm dep making fn
infomiho Sep 27, 2025
5771e1f
Update libs README
infomiho Sep 27, 2025
4b5a1c7
Simplify makeWaspLib
infomiho Sep 27, 2025
133e837
Return CI note for the packages README
infomiho Sep 27, 2025
bcab437
Update tsconfig to be more general
infomiho Sep 30, 2025
f1a21e0
Use ESM only profile for arethetypeswrong
infomiho Sep 30, 2025
563c00c
Fix formatting
infomiho Oct 2, 2025
7c08e2d
Merge branch 'main' into templates-to-libs
infomiho Oct 3, 2025
e2d5eda
Update unit tests
infomiho Oct 3, 2025
12b925a
Include `files` note in the README
infomiho Oct 3, 2025
0fae11c
Drop `types` to allow `@types/` packages to be used
infomiho Oct 3, 2025
ac02cca
Update package.json to replace 'import' with 'default' in exports
infomiho Oct 3, 2025
6ecacc3
Use `attw` as dev dep instead of through npx
infomiho Oct 3, 2025
075cc77
Add build:libs command to `run` script
infomiho Oct 3, 2025
1587964
Add note about adding new libs to AvailableLibs module
infomiho Oct 3, 2025
279d1b4
Cleanup Auth.tsx
infomiho Oct 3, 2025
38fdbe0
Update cookies import and formatting
infomiho Oct 3, 2025
0bec41e
Update comment in makeWaspLib to clarify why we append the checksum
infomiho Oct 3, 2025
68a4035
Update README paths
infomiho Oct 3, 2025
500f574
Remove libs/ dir from Git
infomiho Oct 3, 2025
2dc8399
Rename sanitizePackageNameAsNpmPackTarball to packageNameToTarballPrefix
infomiho Oct 3, 2025
97f1a49
Fix typos and improve clarity in WaspLib documentation
infomiho Oct 3, 2025
d07b368
Improve packages install script
infomiho Oct 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion waspc/data/Generator/templates/react-app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const defaultViteConfig = {
detectServerImports(),
],
optimizeDeps: {
exclude: ['wasp']
exclude: {=& depsExcludedFromOptimization =}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
exclude: {=& depsExcludedFromOptimization =}
exclude: {=& depsExcludedFromOptimization =}

},
server: {
port: {= defaultClientPort =},
Expand Down
10 changes: 1 addition & 9 deletions waspc/data/Generator/templates/sdk/wasp/auth/forms/Auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import { useState, createContext } from 'react'
import { createTheme } from '@stitches/react'
import { styled } from 'wasp/core/stitches.config'
import { AuthContext, type ErrorMessage } from '@wasp.sh/libs-auth/client'

import {
type State,
type CustomizationOptions,
type ErrorMessage,
type AdditionalSignupFields,
} from './types'
import { LoginSignupForm } from './internal/common/LoginSignupForm'
Expand Down Expand Up @@ -38,14 +38,6 @@ const HeaderText = styled('h2', {
})


// PRIVATE API
export const AuthContext = createContext({
isLoading: false,
setIsLoading: (isLoading: boolean) => {},
setErrorMessage: (errorMessage: ErrorMessage | null) => {},
setSuccessMessage: (successMessage: string | null) => {},
})

function Auth ({ state, appearance, logo, socialLayout = 'horizontal', additionalSignupFields }: {
state: State;
} & CustomizationOptions & {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{{={= =}=}}
import { useContext } from 'react'
import { useForm, UseFormReturn } from 'react-hook-form'
import { styled } from 'wasp/core/stitches.config'
import { config } from 'wasp/client'

import { AuthContext } from '../../Auth'
import { useAuthContext } from '@wasp.sh/libs-auth/client'
import {
Form,
FormInput,
Expand Down Expand Up @@ -146,7 +145,7 @@ export const LoginSignupForm = ({
setErrorMessage,
setSuccessMessage,
setIsLoading,
} = useContext(AuthContext)
} = useAuthContext();
const isLogin = state === 'login'
const cta = isLogin ? 'Log in' : 'Sign up';
{=# isAnyPasswordBasedAuthEnabled =}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { useContext } from 'react'
import { useForm } from 'react-hook-form'
import { useAuthContext } from '@wasp.sh/libs-auth/client'

import { requestPasswordReset } from '../../../email/actions/passwordReset.js'
import { Form, FormItemGroup, FormLabel, FormInput, SubmitButton, FormError } from '../Form'
import { AuthContext } from '../../Auth'


// PRIVATE API
export const ForgotPasswordForm = () => {
const { register, handleSubmit, reset, formState: { errors } } = useForm<{ email: string }>()
const { isLoading, setErrorMessage, setSuccessMessage, setIsLoading } = useContext(AuthContext)
const { isLoading, setErrorMessage, setSuccessMessage, setIsLoading } = useAuthContext()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When doing big PRs like this, I advise staying away from all other changes, no matter how minor.

This can stay but we should apply the principle to future PRs.

Btw, update the public API table if necessary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think it's good that he made this change, it's scoped enough to be a demonstration and a proof that it works, without big changes otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a POC where I had to get a feel for how the lib will ship browser code - I didn't want to ship the system which would be completely wrong for browser stuff. I can remove this bit if you want and add it in a separate PR.


const onSubmit = async (data) => {
setIsLoading(true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { useContext } from 'react'
import { useForm } from 'react-hook-form'
import { resetPassword } from '../../../email/actions/passwordReset.js'
import { useLocation } from 'react-router-dom'
import { useAuthContext } from '@wasp.sh/libs-auth/client'

import { resetPassword } from '../../../email/actions/passwordReset.js'
import { Form, FormItemGroup, FormLabel, FormInput, SubmitButton, FormError } from '../Form'
import { AuthContext } from '../../Auth'

// PRIVATE API
export const ResetPasswordForm = () => {
const { register, handleSubmit, reset, formState: { errors } } = useForm<{ password: string; passwordConfirmation: string }>()
const { isLoading, setErrorMessage, setSuccessMessage, setIsLoading } = useContext(AuthContext)
const { isLoading, setErrorMessage, setSuccessMessage, setIsLoading } = useAuthContext()
const location = useLocation()
const token = new URLSearchParams(location.search).get('token')
const onSubmit = async (data) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useContext, useEffect } from 'react'
import { useEffect } from 'react'
import { useLocation } from 'react-router-dom'
import { useAuthContext } from '@wasp.sh/libs-auth/client'
import { verifyEmail } from '../../../email/actions/verifyEmail.js'
import { Message } from '../Message'
import { AuthContext } from '../../Auth'

// PRIVATE API
export const VerifyEmailForm = () => {
const { isLoading, setErrorMessage, setSuccessMessage, setIsLoading } = useContext(AuthContext)
const { isLoading, setErrorMessage, setSuccessMessage, setIsLoading } = useAuthContext()
const location = useLocation()
const token = new URLSearchParams(location.search).get('token')

Expand Down
6 changes: 0 additions & 6 deletions waspc/data/Generator/templates/sdk/wasp/auth/forms/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ export type CustomizationOptions = {
appearance?: Parameters<typeof createTheme>[0]
}

// PRIVATE API
export type ErrorMessage = {
title: string
description?: string
}

// PRIVATE API
export type FormState = {
isLoading: boolean
Expand Down
10 changes: 5 additions & 5 deletions waspc/data/Generator/templates/sdk/wasp/auth/jwt.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { createCreateJWT, createValidateJWT } from "@wasp.sh/libs-auth";
import { createJWTHelpers } from "@wasp.sh/libs-auth";

import { config } from "wasp/server";

const JWT_SECRET = new TextEncoder().encode(config.auth.jwtSecret);
const JWT_ALGORITHM = "HS256";

// PRIVATE API
export const createJWT = createCreateJWT(JWT_SECRET, JWT_ALGORITHM);

// PRIVATE API
export const validateJWT = createValidateJWT(JWT_SECRET, JWT_ALGORITHM);
export const { createJWT, validateJWT } = createJWTHelpers(
JWT_SECRET,
JWT_ALGORITHM,
);

// PRIVATE API
export { TimeSpan } from "@wasp.sh/libs-auth";
4 changes: 0 additions & 4 deletions waspc/data/Generator/templates/sdk/wasp/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,3 @@ export { config, ClientConfig } from './config.js'

// PUBLIC API
export { env } from './env.js'

import { cowsay } from "@wasp.sh/libs-auth/client"

console.log(cowsay("Hello from Wasp SDK!"))
26 changes: 7 additions & 19 deletions waspc/examples/todoApp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions waspc/libs/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# Testing Libs Locally

Run `tools/install_libs_to_data_dir.sh` to compile the libs and copy
them into `data/`. Then you can use `cabal run` as normal, or you can
`cabal install` and then use `wasp-cli`.
them into `data/`. Then you can use `./run wasp-cli` as normal. You can run
`./run install` which will run the script before installing the
Wasp CLI.

# Adding a New Package

Create a directory in this folder to contain the new package. It should have a
`pack-and-copy` script inside `package.json`.
Create a directory in this folder to contain the new package. It should contain a
`prepare` script that will be run to prepare the package for use e.g. to build
the package.

The package will be packaged using `npm pack` and the resulting tarball will
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a note to make sure to tweak the package.json#files property to only pack built files.

be copied to `data/libs/` by the `tools/install_libs_to_data_dir.sh` script.

# CI Builds/Release

Expand Down
2 changes: 1 addition & 1 deletion waspc/libs/auth/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Wasp Auth Library

Based on a `unbuild` template.
Based on the default `tsdown` template.
9 changes: 0 additions & 9 deletions waspc/libs/auth/build.config.ts

This file was deleted.

Loading
Loading