Compare commits

..

75 Commits

Author SHA1 Message Date
Guido D'Orsi
94131ba6d6 feat: change the peer & localOnly props into sync 2025-01-29 18:17:21 +01:00
Guido D'Orsi
03df4fee8e fix: move the Auth UI outside the container div 2025-01-29 16:34:36 +01:00
Guido D'Orsi
c658ed3404 fix: remove the localOnly prop where breaking 2025-01-29 16:20:07 +01:00
Guido D'Orsi
99e58e60dc test: fix the PasskeyAuthBasicUI test 2025-01-29 16:04:58 +01:00
Guido D'Orsi
a9ad0284e9 fix: fdix example apps tests 2025-01-29 15:39:31 +01:00
Guido D'Orsi
6e2d791c4b feat: better username management in chat example 2025-01-29 13:58:02 +01:00
Guido D'Orsi
f9be857bbb feat: improve builtin auth UIs 2025-01-29 13:40:38 +01:00
Guido D'Orsi
1288ac140e Merge pull request #1293 from garden-co/authv2-auth-state-refactoring
feat: update the React Native packages with the new auth system
2025-01-29 10:31:52 +01:00
Guido D'Orsi
7f07f7e049 Merge pull request #1294 from boorad/authv2-web-example-refactoring
feat: update web examples to new auth system
2025-01-29 10:31:25 +01:00
Guido D'Orsi
b22589bbad test: add integration tests for the websocket peer 2025-01-29 10:26:09 +01:00
Guido D'Orsi
be144adeee chore: rename onSuccessCalles to isFirstMessage and add a test 2025-01-29 10:17:59 +01:00
Brad Anderson
513619b04e feat: update web examples to new auth system 2025-01-28 23:13:44 -05:00
Guido D'Orsi
81f6a75aac chore: add comment 2025-01-28 20:11:52 +01:00
Guido D'Orsi
913d03de75 feat: update the RN example apps with the new Auth system 2025-01-28 19:34:56 +01:00
Guido D'Orsi
2d0172d839 feat: update the React Native packages with the new auth system 2025-01-28 19:34:04 +01:00
Guido D'Orsi
27d46641e3 feat: unify React Native and Jazz Tools DemoAuth users management 2025-01-28 19:32:55 +01:00
Guido D'Orsi
1014816d79 feat: move WebSocketPeerWithReconnection to jazz-tools 2025-01-28 19:09:34 +01:00
Guido D'Orsi
441194acb7 feat: add onSuccess hook and close the WebSocket on error 2025-01-28 19:06:35 +01:00
Guido D'Orsi
c9bea7200f feat: rename jazz-browser-clerk-auth in jazz-clerk-auth and update jazz-react-native-auth-clerk 2025-01-28 19:05:43 +01:00
Guido D'Orsi
9eaa88bd83 Merge pull request #1291 from garden-co/authv2-auth-state-refactoring
feat: make auth state platform agnostic
2025-01-28 18:35:50 +01:00
Guido D'Orsi
6ada48d57a chore: remove unused imports 2025-01-28 18:05:55 +01:00
Guido D'Orsi
8fa978df21 fix: initialize the anonymous storage only if newAccountProps is not provided 2025-01-28 16:27:25 +01:00
Guido D'Orsi
df7356fd24 chore: cleanup and small fix on websocket enable/disable 2025-01-28 14:45:58 +01:00
Guido D'Orsi
153fa4ce44 fix: invalidate context when localOnly is updated 2025-01-28 12:19:46 +01:00
Guido D'Orsi
6105bd2c88 test: cover createContext and ContextManager 2025-01-28 12:09:48 +01:00
Guido D'Orsi
c06d63eec1 fix: align passphrase auth with the current auth flow 2025-01-28 10:54:47 +01:00
Guido D'Orsi
4ee7359370 test: PassphraseAuth 2025-01-27 22:25:22 +01:00
Guido D'Orsi
7b5c47b377 test: cover DemoAuth 2025-01-27 22:12:42 +01:00
Guido D'Orsi
7ad57e88f3 test: add tests on the react-core auth hooks 2025-01-27 21:59:06 +01:00
Guido D'Orsi
c181e55557 feat: make auth state platform agnostic 2025-01-27 19:27:21 +01:00
Guido D'Orsi
7e0cd721e6 Merge remote-tracking branch 'origin/main' into authv2 2025-01-27 15:51:33 +01:00
Guido D'Orsi
4d01cbae03 Merge pull request #1288 from garden-co/sync-tests-improvements
Improve sync tests and add some utils to track the messages exchanges
2025-01-27 15:47:03 +01:00
Guido D'Orsi
13f6389559 chore: format text 2025-01-27 15:38:34 +01:00
Guido D'Orsi
f6ea9bcc50 test: remove flaky test 2025-01-27 15:37:02 +01:00
Guido D'Orsi
f6f2766eac test: cover the initial messages exchanges 2025-01-27 15:35:35 +01:00
Guido D'Orsi
f8f63bface test: simplify sync tests with the test sync pattern 2025-01-27 15:35:34 +01:00
Guido D'Orsi
5ec561fec4 Merge pull request #1281 from garden-co/changeset-release/main
Version Packages
2025-01-27 11:07:35 +01:00
github-actions[bot]
277787cbd2 Version Packages 2025-01-27 10:03:17 +00:00
Guido D'Orsi
dda4336721 Merge pull request #1252 from garden-co/fix-ts-symbol-error
fix(typescript): replace private symbols with prefixed strings
2025-01-27 11:01:37 +01:00
Guido D'Orsi
59ddff40ab Merge pull request #1270 from garden-co/authv2-clerk
feat: improve the clerk integration
2025-01-27 11:01:13 +01:00
Guido D'Orsi
064d19b48c chore: move jazz-react-core version up to 0.9.19 2025-01-27 09:27:18 +01:00
Guido D'Orsi
3ea269f4d8 chore: package json formatting 2025-01-27 09:27:00 +01:00
Guido D'Orsi
cb75cc62b2 chore: exclude storage from the propsChanged check 2025-01-25 00:38:09 +01:00
Guido D'Orsi
b141f6a62f fix: double context creation on React 2025-01-25 00:36:58 +01:00
Guido D'Orsi
4a251a528c feat: improve the clerk integration 2025-01-24 19:37:59 +01:00
Guido D'Orsi
f8b6119996 feat: translate isAnonymous checks into isAuthenticated and add tests 2025-01-24 16:15:18 +01:00
Guido D'Orsi
a7c90f749e feat: move the context manager into jazz-tools 2025-01-24 15:30:43 +01:00
Guido D'Orsi
b01cc1fe9d fix(typescript): fix type error on ItemsSym 2025-01-23 19:21:29 +01:00
Guido D'Orsi
3a6e34589f feat: defaultName and better props tracking 2025-01-23 18:34:37 +01:00
Guido D'Orsi
a1d512d9d7 Merge remote-tracking branch 'origin/main' into authv2 2025-01-23 17:28:14 +01:00
Guido D'Orsi
51bf6b7fdc Merge pull request #1223 from garden-co/auth-flow-rewrite
Auth flow rewrite
2025-01-23 17:26:53 +01:00
Guido D'Orsi
b5826fc0a5 Merge pull request #1176 from garden-co/user-onboarding-upgrade
feat: zero-setup auth, anonymous user upgrade and localOnly sync
2025-01-23 17:22:50 +01:00
Guido D'Orsi
becdd2f451 test(music-player): fix e2e tests 2025-01-23 17:12:47 +01:00
Guido D'Orsi
3b20bf354f feat: migrate svelte 2025-01-23 16:58:44 +01:00
Guido D'Orsi
fff7fe934b feat: update Vue 2025-01-23 12:55:12 +01:00
Guido D'Orsi
4c8d128eee feat: auth flow rewrite 2025-01-22 18:04:45 +01:00
Guido D'Orsi
df106ca680 test: fix create image test 2025-01-21 11:15:18 +01:00
Guido D'Orsi
c58f93b597 Merge remote-tracking branch 'origin/main' into user-onboarding-upgrade 2025-01-21 10:49:01 +01:00
Guido D'Orsi
3f2a0ead1b fix: self-review fixes 2025-01-21 10:34:42 +01:00
Guido D'Orsi
c9e6d2998e feat: improve the jazz-react provider 2025-01-20 20:10:18 +01:00
Guido D'Orsi
40634c6ec1 chore: update lockfile 2025-01-20 12:41:08 +01:00
Guido D'Orsi
8bc758ce95 Merge remote-tracking branch 'origin/main' into user-onboarding-upgrade 2025-01-20 12:32:25 +01:00
Guido D'Orsi
73079ca1b7 test: update e2e tests 2025-01-17 22:57:45 +01:00
Guido D'Orsi
c36f19a97f fix: fix imports & and tests on createJazzBrowserContext 2025-01-17 19:28:38 +01:00
Guido D'Orsi
109338923a chore: update lockfile 2025-01-17 18:18:57 +01:00
Guido D'Orsi
f4c2501b06 chore: move auth hook in useInJazzAuth 2025-01-17 18:18:24 +01:00
Guido D'Orsi
9161229474 chore: revert the changes on the todo example 2025-01-17 18:17:46 +01:00
Guido D'Orsi
265f2f40bf fix: fix passkey auth cancelation and add tests 2025-01-17 17:50:35 +01:00
Guido D'Orsi
d2935ac2ae feat: make clerk auth compatible with passkeys 2025-01-17 14:49:25 +01:00
Guido D'Orsi
aaf00b8a20 feat: update starter example with anonymous auth 2025-01-17 14:49:25 +01:00
Guido D'Orsi
f9c6a49d2a feat: onboarding auth on todo example 2025-01-17 14:49:25 +01:00
Guido D'Orsi
2f54a48a3d feat: make auth code disappear from the React setup 2025-01-17 14:49:25 +01:00
Guido D'Orsi
be4dd0a787 feat: centralize auth secret management 2025-01-17 14:49:25 +01:00
Guido D'Orsi
f3f072e7cf feat: improve login/signup code and better UX on the music player auth 2025-01-17 14:49:24 +01:00
Guido D'Orsi
a6270bf552 feat: add onboarding user upgrade to Passkey and Clerk auth 2025-01-17 14:49:24 +01:00
275 changed files with 16547 additions and 6188 deletions

View File

@@ -1,5 +1,15 @@
# chat-rn-clerk
## 1.0.61
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-react-native@0.9.20
- jazz-react-native-auth-clerk@0.9.20
- jazz-react-native-media-images@0.9.20
## 1.0.60
### Patch Changes

View File

@@ -1,9 +1,9 @@
import { Redirect, Stack } from "expo-router";
import { useIsAuthenticated } from "jazz-react-native";
import React from "react";
import { useAuth } from "../../src/auth-context";
export default function HomeLayout() {
const { isAuthenticated } = useAuth();
const isAuthenticated = useIsAuthenticated();
if (isAuthenticated) {
return <Redirect href={"/chat"} />;

View File

@@ -1,8 +1,8 @@
import { Redirect, Stack } from "expo-router";
import { useAuth } from "../../src/auth-context";
import { useIsAuthenticated } from "jazz-react-native";
export default function UnAuthenticatedLayout() {
const { isAuthenticated } = useAuth();
const isAuthenticated = useIsAuthenticated();
if (isAuthenticated) {
return <Redirect href={"/chat"} />;

View File

@@ -20,10 +20,15 @@ export default function ChatScreen() {
const navigation = useNavigation();
const { user } = useUser();
function handleLogOut() {
logOut();
router.navigate("/");
}
useLayoutEffect(() => {
navigation.setOptions({
headerTitle: "Chat",
headerRight: () => <Button onPress={logOut} title="Logout" />,
headerRight: () => <Button onPress={handleLogOut} title="Logout" />,
});
}, [navigation]);

View File

@@ -1,7 +1,7 @@
{
"name": "chat-rn-clerk",
"main": "index.js",
"version": "1.0.60",
"version": "1.0.61",
"scripts": {
"build": "expo export -p ios",
"start": "expo start",

View File

@@ -1,49 +1,20 @@
import { useClerk, useUser } from "@clerk/clerk-expo";
import { JazzProvider, setupKvStore } from "jazz-react-native";
import { useJazzClerkAuth } from "jazz-react-native-auth-clerk";
import React, { createContext, PropsWithChildren, useContext } from "react";
import { Text, View } from "react-native";
const AuthContext = createContext<{
isAuthenticated: boolean;
isLoading: boolean;
}>({
isAuthenticated: false,
isLoading: true,
});
export function useAuth() {
return useContext(AuthContext);
}
const kvStore = setupKvStore();
import { useClerk } from "@clerk/clerk-expo";
import { JazzProviderWithClerk } from "jazz-react-native-auth-clerk";
import React, { PropsWithChildren } from "react";
export function JazzAndAuth({ children }: PropsWithChildren) {
const { isSignedIn, isLoaded: isClerkLoaded } = useUser();
const clerk = useClerk();
const [auth, state] = useJazzClerkAuth(clerk, kvStore);
const isAuthenticated = Boolean(isSignedIn && isClerkLoaded && auth);
return (
<AuthContext.Provider
value={{ isAuthenticated, isLoading: !isClerkLoaded || !auth }}
<JazzProviderWithClerk
clerk={clerk}
storage="sqlite"
sync={{
peer: "wss://cloud.jazz.tools/?key=chat-rn-clerk-example-jazz@garden.co",
when: "signedUp", // This makes the app work in local mode when the user is not authenticated
}}
>
{state?.errors?.length > 0 &&
state.errors.map((error) => (
<View key={error}>
<Text style={{ color: "red" }}>{error}</Text>
</View>
))}
{auth && clerk.user ? (
<JazzProvider
auth={auth}
storage="sqlite"
peer="wss://cloud.jazz.tools/?key=chat-rn-clerk-example-jazz@garden.co"
>
{children}
</JazzProvider>
) : (
children
)}
</AuthContext.Provider>
{children}
</JazzProviderWithClerk>
);
}

View File

@@ -1,5 +1,13 @@
# chat-rn
## 1.0.58
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-react-native@0.9.20
## 1.0.57
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "chat-rn",
"version": "1.0.57",
"version": "1.0.58",
"main": "index.js",
"scripts": {
"build": "expo export -p ios",

View File

@@ -9,7 +9,7 @@ import * as Linking from "expo-linking";
import React, { StrictMode, useEffect, useState } from "react";
import HandleInviteScreen from "./invite";
import { DemoAuthBasicUI, JazzProvider, useDemoAuth } from "jazz-react-native";
import { JazzProvider } from "jazz-react-native";
import ChatScreen from "./chat";
const Stack = createNativeStackNavigator();
@@ -28,7 +28,6 @@ const linking = {
};
function App() {
const [auth, state] = useDemoAuth();
const [initialRoute, setInitialRoute] = useState<
"ChatScreen" | "HandleInviteScreen"
>("ChatScreen");
@@ -43,16 +42,13 @@ function App() {
});
}, []);
if (!auth) {
return null;
}
return (
<StrictMode>
<JazzProvider
auth={auth}
storage="sqlite"
peer="wss://cloud.jazz.tools/?key=chat-rn-example-jazz@garden.co"
sync={{
peer: "wss://cloud.jazz.tools/?key=chat-rn-example-jazz@garden.co",
}}
>
<NavigationContainer linking={linking} ref={navigationRef}>
<Stack.Navigator initialRouteName={initialRoute}>
@@ -69,9 +65,6 @@ function App() {
</Stack.Navigator>
</NavigationContainer>
</JazzProvider>
{state.state !== "signedIn" ? (
<DemoAuthBasicUI appName="Jazz Chat" state={state} />
) : null}
</StrictMode>
);
}

View File

@@ -1,6 +1,6 @@
import clsx from "clsx";
import * as Clipboard from "expo-clipboard";
import { Group, ID } from "jazz-tools";
import { Group, ID, Profile } from "jazz-tools";
import { useEffect, useState } from "react";
import React, {
Button,
@@ -22,10 +22,16 @@ export default function ChatScreen({ navigation }: { navigation: any }) {
const [chatId, setChatId] = useState<ID<Chat>>();
const loadedChat = useCoState(Chat, chatId, [{}]);
const [message, setMessage] = useState("");
const profile = useCoState(Profile, me._refs.profile?.id, {});
function handleLogOut() {
setChatId(undefined);
logOut();
}
useEffect(() => {
navigation.setOptions({
headerRight: () => <Button onPress={logOut} title="Logout" />,
headerRight: () => <Button onPress={handleLogOut} title="Logout" />,
headerLeft: () =>
loadedChat ? (
<Button
@@ -131,6 +137,18 @@ export default function ChatScreen({ navigation }: { navigation: any }) {
<View className="flex flex-col h-full">
{!loadedChat ? (
<View className="flex flex-col h-full items-center justify-center">
<Text className="text-m font-bold mb-6">Username</Text>
<TextInput
className="rounded h-12 p-2 mb-12 w-40 border border-gray-200 block"
value={profile?.name ?? ""}
onChangeText={(value) => {
if (profile) {
profile.name = value;
}
}}
textAlignVertical="center"
onSubmitEditing={sendMessage}
/>
<TouchableOpacity
onPress={createChat}
className="bg-blue-500 p-4 rounded-md"

View File

@@ -1,5 +1,14 @@
# chat-vue
## 0.0.45
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-browser@0.9.20
- jazz-vue@0.9.20
## 0.0.44
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "chat-vue",
"version": "0.0.44",
"version": "0.0.45",
"private": true,
"type": "module",
"scripts": {

View File

@@ -1,4 +1,4 @@
import { DemoAuthBasicUI, JazzProvider, useDemoAuth } from "jazz-vue";
import { DemoAuthBasicUI, JazzProvider } from "jazz-vue";
import { createApp, defineComponent, h } from "vue";
import App from "./App.vue";
import "./index.css";
@@ -7,26 +7,24 @@ import router from "./router";
const RootComponent = defineComponent({
name: "RootComponent",
setup() {
const { authMethod, state } = useDemoAuth();
return () => [
return () =>
h(
JazzProvider,
{
auth: authMethod.value,
peer: "wss://cloud.jazz.tools/?key=chat-example-jazz@garden.co",
sync: {
peer: "wss://cloud.jazz.tools/?key=vue-todo-example-jazz@garden.co",
},
},
{
default: () => h(App),
},
),
state.state !== "signedIn" &&
h(DemoAuthBasicUI, {
appName: "Jazz Chat",
state,
}),
];
h(
DemoAuthBasicUI,
{
appName: "Jazz Vue Chat",
},
{
default: () => h(App),
},
),
);
},
});

View File

@@ -1,5 +1,14 @@
# jazz-example-chat
## 0.0.141
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-browser-media-images@0.9.20
- jazz-react@0.9.20
## 0.0.140
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-chat",
"private": true,
"version": "0.0.140",
"version": "0.0.141",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -1,11 +1,10 @@
import { inIframe, onChatLoad } from "@/util.ts";
import { getRandomUsername, inIframe, onChatLoad } from "@/util.ts";
import { useIframeHashRouter } from "hash-slash";
import { useAccount } from "jazz-react";
import { JazzProvider, useAccount } from "jazz-react";
import { Group, ID } from "jazz-tools";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { ChatScreen } from "./chatScreen.tsx";
import { JazzAndAuth } from "./jazz.tsx";
import { Chat } from "./schema.ts";
import { ThemeProvider } from "./themeProvider.tsx";
import { AppContainer, TopBar } from "./ui.tsx";
@@ -28,7 +27,15 @@ export function App() {
return (
<AppContainer>
<TopBar>
<p>{me?.profile?.name}</p>
<input
type="text"
value={me?.profile?.name ?? ""}
onChange={(e) => {
if (!me?.profile) return;
me.profile.name = e.target.value;
}}
placeholder="Set username"
/>
{!inIframe && <button onClick={logOut}>Log out</button>}
</TopBar>
{router.route({
@@ -39,12 +46,20 @@ export function App() {
);
}
const url = new URL(window.location.href);
const defaultProfileName = url.searchParams.get("user") ?? getRandomUsername();
createRoot(document.getElementById("root")!).render(
<ThemeProvider>
<StrictMode>
<JazzAndAuth>
<JazzProvider
sync={{
peer: "wss://cloud.jazz.tools/?key=chat-example-jazz@garden.co",
}}
defaultProfileName={defaultProfileName}
>
<App />
</JazzAndAuth>
</JazzProvider>
</StrictMode>
</ThemeProvider>,
);

View File

@@ -1,19 +0,0 @@
import { DemoAuthBasicUI, JazzProvider, useDemoAuth } from "jazz-react";
export function JazzAndAuth({ children }: { children: React.ReactNode }) {
const [auth, state] = useDemoAuth();
return (
<>
<JazzProvider
auth={auth}
peer="wss://cloud.jazz.tools/?key=chat-example-jazz@garden.co"
>
{children}
</JazzProvider>
{state.state !== "signedIn" && (
<DemoAuthBasicUI appName="Jazz Chat" state={state} />
)}
</>
);
}

View File

@@ -15,3 +15,20 @@ export function onChatLoad(chat: Chat) {
}
export const inIframe = window.self !== window.top;
const animals = [
"elephant",
"penguin",
"giraffe",
"octopus",
"kangaroo",
"dolphin",
"cheetah",
"koala",
"platypus",
"pangolin",
];
export function getRandomUsername() {
return `Anonymous ${animals[Math.floor(Math.random() * animals.length)]}`;
}

View File

@@ -1,48 +1,35 @@
import { test } from "@playwright/test";
import { ChatPage } from "./pages/ChatPage";
import { LoginPage } from "./pages/LoginPage";
test("chat between two users", async ({ page }) => {
const loginPage = new LoginPage(page);
test("chat between two users", async ({ page: marioPage, browser }) => {
const context = await browser.newContext();
const luigiPage = await context.newPage();
const mario = "S. Mario";
const luigi = "Luigi";
await marioPage.goto("/");
await loginPage.goto();
await loginPage.fillUsername(mario);
await loginPage.signup();
const marioChat = new ChatPage(marioPage);
const luigiChat = new ChatPage(luigiPage);
const chatPage = new ChatPage(page);
await marioChat.setUsername("Mario");
const message1ByMario = "Hello Luigi, are you ready to save the princess?";
await chatPage.sendMessage(message1ByMario);
await chatPage.expectMessageRow(message1ByMario);
await marioChat.sendMessage(message1ByMario);
await marioChat.expectMessageRow(message1ByMario);
const roomURL = page.url();
const roomURL = marioPage.url();
await luigiPage.goto(roomURL);
await chatPage.logout();
await luigiChat.setUsername("Luigi");
await loginPage.expectLoaded();
await loginPage.fillUsername(luigi);
await loginPage.signup();
await page.goto(roomURL);
await chatPage.expectMessageRow(message1ByMario);
await luigiChat.expectMessageRow(message1ByMario);
const message2ByLuigi =
"No, I'm not ready yet. I'm still trying to find the key to the castle.";
await chatPage.sendMessage(message2ByLuigi);
await chatPage.expectMessageRow(message2ByLuigi);
await luigiChat.sendMessage(message2ByLuigi);
await luigiChat.expectMessageRow(message2ByLuigi);
await chatPage.logout();
await loginPage.loginAs(mario);
await page.goto(roomURL);
await chatPage.expectMessageRow(message1ByMario);
await chatPage.expectMessageRow(message2ByLuigi);
await marioChat.expectMessageRow(message1ByMario);
await luigiChat.expectMessageRow(message2ByLuigi);
});

View File

@@ -4,7 +4,7 @@ export class ChatPage {
readonly page: Page;
readonly messageInput: Locator;
readonly logoutButton: Locator;
readonly usernameInput: Locator;
constructor(page: Page) {
this.page = page;
this.messageInput = page.getByRole("textbox", {
@@ -13,6 +13,11 @@ export class ChatPage {
this.logoutButton = page.getByRole("button", {
name: "Log out",
});
this.usernameInput = page.getByPlaceholder("Set username");
}
async setUsername(username: string) {
await this.usernameInput.fill(username);
}
async sendMessage(message: string) {

View File

@@ -1,40 +0,0 @@
import { Locator, Page, expect } from "@playwright/test";
export class LoginPage {
readonly page: Page;
readonly usernameInput: Locator;
readonly signupButton: Locator;
constructor(page: Page) {
this.page = page;
this.usernameInput = page.getByRole("textbox");
this.signupButton = page.getByRole("button", {
name: "Sign up",
});
}
async goto() {
this.page.goto("/");
}
async fillUsername(value: string) {
await this.usernameInput.clear();
await this.usernameInput.fill(value);
}
async loginAs(value: string) {
await this.page
.getByRole("button", {
name: value,
})
.click();
}
async signup() {
await this.signupButton.click();
}
async expectLoaded() {
await expect(this.signupButton).toBeVisible();
}
}

View File

@@ -1,5 +1,14 @@
# minimal-auth-clerk
## 0.0.40
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-react@0.9.20
- jazz-react-auth-clerk@0.9.20
## 0.0.39
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "clerk",
"private": true,
"version": "0.0.39",
"version": "0.0.40",
"type": "module",
"scripts": {
"dev": "vite",
@@ -13,7 +13,7 @@
"dependencies": {
"@clerk/clerk-react": "^5.4.1",
"jazz-react": "workspace:*",
"jazz-react-auth-clerk": "workspace:0.9.19",
"jazz-react-auth-clerk": "workspace:0.9.20",
"jazz-tools": "workspace:*",
"react": "^18.3.1",
"react-dom": "^18.3.1"

View File

@@ -1,13 +1,25 @@
import { useAccount } from "jazz-react";
import { SignInButton } from "@clerk/clerk-react";
import { useAccount, useIsAuthenticated } from "jazz-react";
function App() {
const { me, logOut } = useAccount();
const isAuthenticated = useIsAuthenticated();
if (isAuthenticated) {
return (
<div className="container">
<h1>You're logged in</h1>
<p>Welcome back, {me?.profile?.name}</p>
<button onClick={() => logOut()}>Logout</button>
</div>
);
}
return (
<div className="container">
<h1>You're logged in</h1>
<p>Welcome back, {me?.profile?.name}</p>
<button onClick={() => logOut()}>Logout</button>
<h1>You're not logged in</h1>
<SignInButton />
</div>
);
}

View File

@@ -62,7 +62,7 @@ button {
}
.container {
max-width: 200px;
max-width: 400px;
margin: 0 auto;
padding: 0 1rem;
display: flex;

View File

@@ -1,10 +1,9 @@
import { ClerkProvider, SignInButton, useClerk } from "@clerk/clerk-react";
import { useJazzClerkAuth } from "jazz-react-auth-clerk";
import { ClerkProvider, useClerk } from "@clerk/clerk-react";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import App from "./App.tsx";
import "./index.css";
import { JazzProvider } from "jazz-react";
import { JazzProviderWithClerk } from "jazz-react-auth-clerk";
// Import your publishable key
const PUBLISHABLE_KEY = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY;
@@ -13,35 +12,28 @@ if (!PUBLISHABLE_KEY) {
throw new Error("Add your Clerk publishable key to the .env.local file");
}
function JazzAndAuth({ children }: { children: React.ReactNode }) {
function JazzProvider({ children }: { children: React.ReactNode }) {
const clerk = useClerk();
const [auth, state] = useJazzClerkAuth(clerk);
return (
<main className="container">
{state?.errors?.map((error) => (
<div key={error}>{error}</div>
))}
{clerk.user && auth ? (
<JazzProvider
auth={auth}
peer="wss://cloud.jazz.tools/?key=minimal-auth-clerk-example@garden.co"
>
{children}
</JazzProvider>
) : (
<SignInButton />
)}
</main>
<JazzProviderWithClerk
clerk={clerk}
sync={{
peer: "wss://cloud.jazz.tools/?key=minimal-auth-clerk-example@garden.co",
when: "signedUp", // This makes the app work in local mode when the user is not authenticated
}}
>
{children}
</JazzProviderWithClerk>
);
}
createRoot(document.getElementById("root")!).render(
<StrictMode>
<ClerkProvider publishableKey={PUBLISHABLE_KEY} afterSignOutUrl="/">
<JazzAndAuth>
<JazzProvider>
<App />
</JazzAndAuth>
</JazzProvider>
</ClerkProvider>
</StrictMode>,
);

View File

@@ -1,5 +1,13 @@
# file-share-svelte
## 0.0.25
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-svelte@0.9.20
## 0.0.24
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "file-share-svelte",
"version": "0.0.24",
"version": "0.0.25",
"private": true,
"type": "module",
"scripts": {

View File

@@ -17,6 +17,6 @@ export function formatFileSize(bytes: number): string {
* @param createdAt The creation date
* @returns A unique file ID string
*/
export function generateTempFileId(fileName: string, createdAt: Date): string {
return `file-${fileName}-${createdAt.getTime()}`;
export function generateTempFileId(fileName: string | undefined, createdAt: Date | undefined): string {
return `file-${fileName ?? 'unknown'}-${createdAt?.getTime() ?? 0}`;
}

View File

@@ -14,9 +14,6 @@
import { FileShareAccount } from '$lib/schema';
let { children } = $props();
const auth = usePasskeyAuth({
appName: 'File Share'
});
</script>
<svelte:head>
@@ -25,21 +22,16 @@
<Toaster richColors />
{#if auth.state.state === 'ready'}
<div class="fixed inset-0 flex items-center justify-center bg-gray-50/80">
<div class="rounded-lg bg-white p-8 shadow-lg">
<PasskeyAuthBasicUI state={auth.state} />
</div>
</div>
{/if}
{#if auth.current}
<JazzProvider
AccountSchema={FileShareAccount}
auth={auth.current}
peer="wss://cloud.jazz.tools/?key=file-share-svelte@garden.co"
>
<JazzProvider
AccountSchema={FileShareAccount}
sync={{
peer: "wss://cloud.jazz.tools/?key=minimal-svelte-auth-passkey@garden.co",
when: "signedUp",
}}
>
<PasskeyAuthBasicUI appName="File Share">
<div class="min-h-screen bg-gray-100">
{@render children()}
</div>
</JazzProvider>
{/if}
</PasskeyAuthBasicUI>
</JazzProvider>

View File

@@ -28,7 +28,7 @@
const input = event.target as HTMLInputElement;
const files = input.files;
if (!files || !files.length || !me?.root?.sharedFiles || !me.root.publicGroup) return;
if (!files || !files.length || !me.root?.sharedFiles || !me.root.publicGroup) return;
const file = files[0];
const fileName = file.name;
@@ -129,12 +129,14 @@
{#if sharedFiles.current}
{#if !(sharedFiles.current.length === 0 && uploadingFiles.size === 0)}
{#each [...sharedFiles.current, ...uploadingFiles.values()] as file (generateTempFileId(file?.name, file?.createdAt))}
<FileItem
{file}
loading={uploadingFiles.has(generateTempFileId(file?.name, file?.createdAt))}
onShare={shareFile}
onDelete={deleteFile}
/>
{#if file}
<FileItem
{file}
loading={uploadingFiles.has(generateTempFileId(file?.name, file?.createdAt))}
onShare={shareFile}
onDelete={deleteFile}
/>
{/if}
{/each}
{:else}
<p class="text-center text-gray-500">No files yet</p>

View File

@@ -1,5 +1,14 @@
# form
## 0.0.36
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-browser-media-images@0.9.20
- jazz-react@0.9.20
## 0.0.35
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "form",
"private": true,
"version": "0.0.35",
"version": "0.0.36",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -1,30 +1,10 @@
import { DemoAuthBasicUI, JazzProvider, useDemoAuth } from "jazz-react";
import { JazzProvider } from "jazz-react";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import App from "./App.tsx";
import "./index.css";
import { JazzAccount } from "./schema.ts";
function JazzAndAuth({ children }: { children: React.ReactNode }) {
const [auth, authState] = useDemoAuth();
return (
<>
<JazzProvider
auth={auth}
peer="wss://cloud.jazz.tools/?key=form-example@garden.co"
AccountSchema={JazzAccount}
>
{children}
</JazzProvider>
{authState.state !== "signedIn" && (
<DemoAuthBasicUI appName="Form" state={authState} />
)}
</>
);
}
declare module "jazz-react" {
interface Register {
Account: JazzAccount;
@@ -33,8 +13,13 @@ declare module "jazz-react" {
createRoot(document.getElementById("root")!).render(
<StrictMode>
<JazzAndAuth>
<JazzProvider
sync={{
peer: "wss://cloud.jazz.tools/?key=form-example@garden.co",
}}
AccountSchema={JazzAccount}
>
<App />
</JazzAndAuth>
</JazzProvider>
</StrictMode>,
);

View File

@@ -1,13 +1,7 @@
import { expect, test } from "@playwright/test";
import { LoginPage } from "./pages/LoginPage";
test("create and edit an order", async ({ page }) => {
const loginPage = new LoginPage(page);
await loginPage.goto();
await loginPage.fillUsername("Alice");
await loginPage.signup();
await page.goto("/");
// start an order
await page.getByRole("link", { name: "Add new order" }).click();
await page.getByLabel("Base tea").selectOption("Oolong");

View File

@@ -1,40 +0,0 @@
import { Locator, Page, expect } from "@playwright/test";
export class LoginPage {
readonly page: Page;
readonly usernameInput: Locator;
readonly signupButton: Locator;
constructor(page: Page) {
this.page = page;
this.usernameInput = page.getByRole("textbox");
this.signupButton = page.getByRole("button", {
name: "Sign up",
});
}
async goto() {
this.page.goto("/");
}
async fillUsername(value: string) {
await this.usernameInput.clear();
await this.usernameInput.fill(value);
}
async loginAs(value: string) {
await this.page
.getByRole("button", {
name: value,
})
.click();
}
async signup() {
await this.signupButton.click();
}
async expectLoaded() {
await expect(this.signupButton).toBeVisible();
}
}

View File

@@ -1,5 +1,14 @@
# image-upload
## 0.0.38
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-browser-media-images@0.9.20
- jazz-react@0.9.20
## 0.0.37
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "image-upload",
"private": true,
"version": "0.0.37",
"version": "0.0.38",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -1,30 +1,10 @@
import { DemoAuthBasicUI, JazzProvider, useDemoAuth } from "jazz-react";
import { JazzProvider } from "jazz-react";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import App from "./App.tsx";
import "./index.css";
import { JazzAccount } from "./schema.ts";
function JazzAndAuth({ children }: { children: React.ReactNode }) {
const [auth, authState] = useDemoAuth();
return (
<>
<JazzProvider
auth={auth}
peer="wss://cloud.jazz.tools/?key=image-upload-example@garden.co"
AccountSchema={JazzAccount}
>
{children}
</JazzProvider>
{authState.state !== "signedIn" && (
<DemoAuthBasicUI appName="Image upload" state={authState} />
)}
</>
);
}
declare module "jazz-react" {
interface Register {
Account: JazzAccount;
@@ -33,8 +13,13 @@ declare module "jazz-react" {
createRoot(document.getElementById("root")!).render(
<StrictMode>
<JazzAndAuth>
<JazzProvider
sync={{
peer: "wss://cloud.jazz.tools/?key=image-upload-example@garden.co",
}}
AccountSchema={JazzAccount}
>
<App />
</JazzAndAuth>
</JazzProvider>
</StrictMode>,
);

View File

@@ -1,5 +1,14 @@
# jazz-example-musicplayer
## 0.0.62
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-inspector@0.9.21
- jazz-react@0.9.20
## 0.0.61
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-music-player",
"private": true,
"version": "0.0.61",
"version": "0.0.62",
"type": "module",
"scripts": {
"dev": "vite",
@@ -13,13 +13,16 @@
"test:ui": "playwright test --ui"
},
"dependencies": {
"@radix-ui/react-dialog": "^1.1.4",
"@radix-ui/react-dropdown-menu": "^2.1.1",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-label": "^2.1.1",
"@radix-ui/react-slot": "^1.1.1",
"@radix-ui/react-toast": "^1.1.4",
"@radix-ui/react-tooltip": "^1.1.6",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"jazz-react": "workspace:0.9.19",
"jazz-tools": "workspace:0.9.19",
"jazz-react": "workspace:0.9.20",
"jazz-tools": "workspace:0.9.20",
"jazz-inspector": "workspace:*",
"lucide-react": "^0.274.0",
"react": "^18.3.1",

View File

@@ -86,7 +86,7 @@ export class MusicaAccount extends Account {
* You can use it to set up the account root and any other initial CoValues you need.
*/
migrate() {
if (!this._refs.root) {
if (this.root === undefined) {
const ownership = { owner: this };
const tracks = ListOfTracks.create([], ownership);

View File

@@ -11,7 +11,7 @@ import { PlayerControls } from "./components/PlayerControls";
import "./index.css";
import { MusicaAccount } from "@/1_schema";
import { DemoAuthBasicUI, JazzProvider, useDemoAuth } from "jazz-react";
import { JazzProvider } from "jazz-react";
import { useUploadExampleData } from "./lib/useUploadExampleData";
/**
@@ -54,30 +54,11 @@ function Main() {
);
}
function JazzAndAuth({ children }: { children: React.ReactNode }) {
const [auth, state] = useDemoAuth();
const peer =
(new URL(window.location.href).searchParams.get(
"peer",
) as `ws://${string}`) ??
"wss://cloud.jazz.tools/?key=music-player-example-jazz@garden.co";
return (
<>
<JazzProvider
storage="indexedDB"
auth={auth}
peer={peer}
AccountSchema={MusicaAccount}
>
{children}
<JazzInspector />
</JazzProvider>
<DemoAuthBasicUI appName="Jazz Music Player" state={state} />
</>
);
}
const peer =
(new URL(window.location.href).searchParams.get(
"peer",
) as `ws://${string}`) ??
"wss://cloud.jazz.tools/?key=music-player-example-jazz@garden.co";
declare module "jazz-react" {
interface Register {
@@ -87,8 +68,17 @@ declare module "jazz-react" {
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<JazzAndAuth>
<JazzProvider
sync={{
peer,
when: "signedUp", // This makes the app work in local mode when the user is anonymous
}}
storage="indexedDB"
AccountSchema={MusicaAccount}
defaultProfileName="Anonymous unicorn"
>
<Main />
</JazzAndAuth>
<JazzInspector />
</JazzProvider>
</React.StrictMode>,
);

View File

@@ -1,12 +1,17 @@
import { useToast } from "@/hooks/use-toast";
import { createInviteLink, useAccount, useCoState } from "jazz-react";
import {
createInviteLink,
useAccount,
useCoState,
useIsAuthenticated,
} from "jazz-react";
import { ID } from "jazz-tools";
import { useNavigate, useParams } from "react-router";
import { Playlist } from "./1_schema";
import { createNewPlaylist, uploadMusicTracks } from "./4_actions";
import { MediaPlayer } from "./5_useMediaPlayer";
import { AuthButton } from "./components/AuthButton";
import { FileUploadButton } from "./components/FileUploadButton";
import { LogoutButton } from "./components/LogoutButton";
import { MusicTrackRow } from "./components/MusicTrackRow";
import { PlaylistTitleInput } from "./components/PlaylistTitleInput";
import { SidePanel } from "./components/SidePanel";
@@ -66,6 +71,8 @@ export function HomePage({ mediaPlayer }: { mediaPlayer: MediaPlayer }) {
});
};
const isAuthenticated = useIsAuthenticated();
return (
<div className="flex flex-col h-screen text-gray-800 bg-blue-50">
<div className="flex flex-1 overflow-hidden">
@@ -86,12 +93,12 @@ export function HomePage({ mediaPlayer }: { mediaPlayer: MediaPlayer }) {
<Button onClick={handleCreatePlaylist}>New playlist</Button>
</>
)}
{!isRootPlaylist && (
{!isRootPlaylist && isAuthenticated && (
<Button onClick={handlePlaylistShareClick}>
Share playlist
</Button>
)}
<LogoutButton />
<AuthButton />
</div>
</div>
<ul className="flex flex-col">

View File

@@ -0,0 +1,40 @@
"use client";
import { Button } from "@/components/ui/button";
import { useAccount, useIsAuthenticated } from "jazz-react";
import { useState } from "react";
import { useNavigate } from "react-router-dom";
import { AuthModal } from "./AuthModal";
export function AuthButton() {
const [open, setOpen] = useState(false);
const { logOut } = useAccount();
const navigate = useNavigate();
const isAuthenticated = useIsAuthenticated();
function handleSignOut() {
logOut();
navigate("/");
}
if (isAuthenticated) {
return (
<Button variant="outline" onClick={handleSignOut}>
Sign out
</Button>
);
}
return (
<>
<Button
onClick={() => setOpen(true)}
className="bg-white text-black hover:bg-gray-100"
>
Sign up
</Button>
<AuthModal open={open} onOpenChange={setOpen} />
</>
);
}

View File

@@ -0,0 +1,97 @@
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { usePasskeyAuth } from "jazz-react";
import { useState } from "react";
interface AuthModalProps {
open: boolean;
onOpenChange: (open: boolean) => void;
}
export function AuthModal({ open, onOpenChange }: AuthModalProps) {
const [username, setUsername] = useState("");
const [isSignUp, setIsSignUp] = useState(true);
const [error, setError] = useState<string | null>(null);
const auth = usePasskeyAuth({
appName: "Jazz Music Player",
});
const handleViewChange = () => {
setIsSignUp(!isSignUp);
setError(null);
};
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
try {
if (isSignUp) {
await auth.signUp(username);
} else {
await auth.logIn();
}
onOpenChange(false);
} catch (error) {
setError(error instanceof Error ? error.message : "Unknown error");
}
};
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="sm:max-w-[425px]">
<DialogHeader>
<DialogTitle className="text-2xl font-bold">
{isSignUp ? "Create account" : "Welcome back"}
</DialogTitle>
<DialogDescription>
{isSignUp
? "Sign up to enable network sync and share your playlists with others"
: "Changes done before logging in will be lost"}
</DialogDescription>
</DialogHeader>
<form onSubmit={handleSubmit} className="space-y-4">
{isSignUp && (
<div className="space-y-2">
<Label htmlFor="username">Username</Label>
<Input
id="username"
value={username}
onChange={(e) => setUsername(e.target.value)}
placeholder="Enter your username"
required
/>
</div>
)}
{error && <div className="text-sm text-red-500">{error}</div>}
<div className="space-y-4">
<Button
type="submit"
className="w-full bg-blue-600 hover:bg-blue-700"
>
{isSignUp ? "Sign up with passkey" : "Login with passkey"}
</Button>
<div className="text-center text-sm">
{isSignUp ? "Already have an account?" : "Don't have an account?"}{" "}
<button
type="button"
onClick={handleViewChange}
className="text-blue-600 hover:underline"
>
{isSignUp ? "Login" : "Sign up"}
</button>
</div>
</div>
</form>
</DialogContent>
</Dialog>
);
}

View File

@@ -0,0 +1,37 @@
import { Badge } from "@/components/ui/badge";
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "@/components/ui/tooltip";
import { useIsAuthenticated } from "jazz-react";
import { Info } from "lucide-react";
export function LocalOnlyTag() {
const isAuthenticated = useIsAuthenticated();
if (isAuthenticated) {
return null;
}
return (
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<div className="inline-flex items-center gap-1.5 cursor-help">
<Badge variant="default" className="h-5 text-xs font-normal">
Local only
</Badge>
<Info className="h-3.5 w-3.5 text-muted-foreground" />
</div>
</TooltipTrigger>
<TooltipContent className="max-w-[250px]">
<p>
Sign up to enable network sync and share your playlists with others
</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
);
}

View File

@@ -1,5 +1,6 @@
import { useAccount } from "jazz-react";
import { useNavigate, useParams } from "react-router";
import { LocalOnlyTag } from "./LocalOnlyTag";
export function SidePanel() {
const { playlistId } = useParams();
@@ -25,7 +26,7 @@ export function SidePanel() {
return (
<aside className="w-64 p-6 bg-white overflow-y-auto">
<div className="flex items-center mb-6">
<div className="flex items-center mb-1">
<svg
className="w-8 h-8 mr-2"
viewBox="0 0 24 24"
@@ -46,6 +47,9 @@ export function SidePanel() {
</svg>
<span className="text-xl font-bold text-blue-600">Music Player</span>
</div>
<div className="mb-6">
<LocalOnlyTag />
</div>
<nav>
<h2 className="mb-2 text-sm font-semibold text-gray-600">Playlists</h2>
<ul className="space-y-1">

View File

@@ -0,0 +1,36 @@
import { type VariantProps, cva } from "class-variance-authority";
import * as React from "react";
import { cn } from "@/lib/utils";
const badgeVariants = cva(
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
{
variants: {
variant: {
default:
"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
secondary:
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
destructive:
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
outline: "text-foreground",
},
},
defaultVariants: {
variant: "default",
},
},
);
export interface BadgeProps
extends React.HTMLAttributes<HTMLDivElement>,
VariantProps<typeof badgeVariants> {}
function Badge({ className, variant, ...props }: BadgeProps) {
return (
<div className={cn(badgeVariants({ variant }), className)} {...props} />
);
}
export { Badge, badgeVariants };

View File

@@ -0,0 +1,120 @@
import * as DialogPrimitive from "@radix-ui/react-dialog";
import { X } from "lucide-react";
import * as React from "react";
import { cn } from "@/lib/utils";
const Dialog = DialogPrimitive.Root;
const DialogTrigger = DialogPrimitive.Trigger;
const DialogPortal = DialogPrimitive.Portal;
const DialogClose = DialogPrimitive.Close;
const DialogOverlay = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Overlay>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Overlay
ref={ref}
className={cn(
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
className,
)}
{...props}
/>
));
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
const DialogContent = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
>(({ className, children, ...props }, ref) => (
<DialogPortal>
<DialogOverlay />
<DialogPrimitive.Content
ref={ref}
className={cn(
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
className,
)}
{...props}
>
{children}
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
<X className="h-4 w-4" />
<span className="sr-only">Close</span>
</DialogPrimitive.Close>
</DialogPrimitive.Content>
</DialogPortal>
));
DialogContent.displayName = DialogPrimitive.Content.displayName;
const DialogHeader = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
"flex flex-col space-y-1.5 text-center sm:text-left",
className,
)}
{...props}
/>
);
DialogHeader.displayName = "DialogHeader";
const DialogFooter = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
className,
)}
{...props}
/>
);
DialogFooter.displayName = "DialogFooter";
const DialogTitle = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Title
ref={ref}
className={cn(
"text-lg font-semibold leading-none tracking-tight",
className,
)}
{...props}
/>
));
DialogTitle.displayName = DialogPrimitive.Title.displayName;
const DialogDescription = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Description>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Description
ref={ref}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
));
DialogDescription.displayName = DialogPrimitive.Description.displayName;
export {
Dialog,
DialogPortal,
DialogOverlay,
DialogClose,
DialogTrigger,
DialogContent,
DialogHeader,
DialogFooter,
DialogTitle,
DialogDescription,
};

View File

@@ -0,0 +1,22 @@
import * as React from "react";
import { cn } from "@/lib/utils";
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
({ className, type, ...props }, ref) => {
return (
<input
type={type}
className={cn(
"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
className,
)}
ref={ref}
{...props}
/>
);
},
);
Input.displayName = "Input";
export { Input };

View File

@@ -0,0 +1,24 @@
import * as LabelPrimitive from "@radix-ui/react-label";
import { type VariantProps, cva } from "class-variance-authority";
import * as React from "react";
import { cn } from "@/lib/utils";
const labelVariants = cva(
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
);
const Label = React.forwardRef<
React.ElementRef<typeof LabelPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
VariantProps<typeof labelVariants>
>(({ className, ...props }, ref) => (
<LabelPrimitive.Root
ref={ref}
className={cn(labelVariants(), className)}
{...props}
/>
));
Label.displayName = LabelPrimitive.Root.displayName;
export { Label };

View File

@@ -0,0 +1,30 @@
"use client";
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
import * as React from "react";
import { cn } from "@/lib/utils";
const TooltipProvider = TooltipPrimitive.Provider;
const Tooltip = TooltipPrimitive.Root;
const TooltipTrigger = TooltipPrimitive.Trigger;
const TooltipContent = React.forwardRef<
React.ElementRef<typeof TooltipPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
>(({ className, sideOffset = 4, ...props }, ref) => (
<TooltipPrimitive.Content
ref={ref}
sideOffset={sideOffset}
className={cn(
"z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className,
)}
{...props}
/>
));
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };

View File

@@ -1,11 +1,14 @@
import { MusicaAccount } from "@/1_schema";
import { useAccount } from "jazz-react";
import { useEffect } from "react";
import { uploadMusicTracks } from "../4_actions";
export function useUploadExampleData() {
const { me } = useAccount();
useEffect(() => {
uploadOnboardingData();
}, []);
}, [me.id]);
}
async function uploadOnboardingData() {

View File

@@ -1,44 +1,84 @@
import { test } from "@playwright/test";
import { BrowserContext, test } from "@playwright/test";
import { HomePage } from "./pages/HomePage";
import { LoginPage } from "./pages/LoginPage";
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
test("create a new playlist and share", async ({ page }) => {
const loginPage = new LoginPage(page);
async function mockAuthenticator(context: BrowserContext) {
await context.addInitScript(() => {
Object.defineProperty(window.navigator, "credentials", {
value: {
...window.navigator.credentials,
create: async () => ({
type: "public-key",
id: new Uint8Array([1, 2, 3, 4]),
rawId: new Uint8Array([1, 2, 3, 4]),
response: {
clientDataJSON: new Uint8Array([1]),
attestationObject: new Uint8Array([2]),
},
}),
get: async () => ({
type: "public-key",
id: new Uint8Array([1, 2, 3, 4]),
rawId: new Uint8Array([1, 2, 3, 4]),
response: {
authenticatorData: new Uint8Array([1]),
clientDataJSON: new Uint8Array([2]),
signature: new Uint8Array([3]),
},
}),
},
configurable: true,
});
});
}
await loginPage.goto();
await loginPage.fillUsername("S. Mario");
await loginPage.signup();
// Configure the authenticator
test.beforeEach(async ({ context }) => {
// Enable virtual authenticator environment
await mockAuthenticator(context);
});
const homePage = new HomePage(page);
test("create a new playlist and share", async ({
page: marioPage,
browser,
}) => {
await marioPage.goto("/");
const marioHome = new HomePage(marioPage);
// The example song should be loaded
await homePage.expectMusicTrack("Example song");
await homePage.editTrackTitle("Example song", "Super Mario World");
await marioHome.expectMusicTrack("Example song");
await marioHome.editTrackTitle("Example song", "Super Mario World");
await homePage.createPlaylist();
await homePage.editPlaylistTitle("Save the princess");
await marioHome.createPlaylist();
await marioHome.editPlaylistTitle("Save the princess");
await homePage.navigateToPlaylist("All tracks");
await homePage.addTrackToPlaylist("Super Mario World", "Save the princess");
await marioHome.navigateToPlaylist("All tracks");
await marioHome.addTrackToPlaylist("Super Mario World", "Save the princess");
await homePage.navigateToPlaylist("Save the princess");
await homePage.expectMusicTrack("Super Mario World");
await marioHome.navigateToPlaylist("Save the princess");
await marioHome.expectMusicTrack("Super Mario World");
const url = await homePage.getShareLink();
await marioHome.signUp("Mario");
const url = await marioHome.getShareLink();
await sleep(4000); // Wait for the sync to complete
await homePage.logout();
const luigiContext = await browser.newContext();
await mockAuthenticator(luigiContext);
await loginPage.goto();
await loginPage.fillUsername("Luigi");
await loginPage.signup();
const luigiPage = await luigiContext.newPage();
await luigiPage.goto("/");
await page.goto(url);
const luigiHome = new HomePage(luigiPage);
await homePage.expectMusicTrack("Super Mario World");
await homePage.playMusicTrack("Super Mario World");
await homePage.expectActiveTrackPlaying();
await luigiHome.signUp("Luigi");
await luigiPage.goto(url);
await luigiHome.expectMusicTrack("Super Mario World");
await luigiHome.playMusicTrack("Super Mario World");
await luigiHome.expectActiveTrackPlaying();
});

View File

@@ -95,6 +95,17 @@ export class HomePage {
.click();
}
async signUp(name: string) {
await this.page.getByRole("button", { name: "Sign up" }).click();
await this.page.getByRole("textbox", { name: "Username" }).fill(name);
await this.page
.getByRole("button", { name: "Sign up with passkey" })
.click();
await expect(
this.page.getByRole("button", { name: "Sign out" }),
).toBeVisible();
}
async logout() {
await this.logoutButton.click();
}

View File

@@ -1,40 +0,0 @@
import { Locator, Page, expect } from "@playwright/test";
export class LoginPage {
readonly page: Page;
readonly usernameInput: Locator;
readonly signupButton: Locator;
constructor(page: Page) {
this.page = page;
this.usernameInput = page.getByRole("textbox");
this.signupButton = page.getByRole("button", {
name: "Sign up",
});
}
async goto() {
this.page.goto("/");
}
async fillUsername(value: string) {
await this.usernameInput.clear();
await this.usernameInput.fill(value);
}
async loginAs(value: string) {
await this.page
.getByRole("button", {
name: value,
})
.click();
}
async signup() {
await this.signupButton.click();
}
async expectLoaded() {
await expect(this.signupButton).toBeVisible();
}
}

View File

@@ -1,5 +1,14 @@
# jazz-example-onboarding
## 0.0.42
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-browser-media-images@0.9.20
- jazz-react@0.9.20
## 0.0.41
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-onboarding",
"private": true,
"version": "0.0.41",
"version": "0.0.42",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -1,7 +1,7 @@
import App from "@/App.tsx";
import "@/index.css";
import { HRAccount } from "@/schema.ts";
import { DemoAuthBasicUI, JazzProvider, useDemoAuth } from "jazz-react";
import { JazzProvider } from "jazz-react";
import React from "react";
import ReactDOM from "react-dom/client";
@@ -11,20 +11,6 @@ const peer =
) as `ws://${string}`) ??
"wss://cloud.jazz.tools/?key=onboarding-example-jazz@garden.co";
function JazzAndAuth({ children }: { children: React.ReactNode }) {
const [auth, authState] = useDemoAuth();
return (
<>
<JazzProvider AccountSchema={HRAccount} auth={auth} peer={peer}>
{children}
</JazzProvider>
{authState.state !== "signedIn" && (
<DemoAuthBasicUI appName="Jazz Onboarding" state={authState} />
)}
</>
);
}
declare module "jazz-react" {
interface Register {
Account: HRAccount;
@@ -33,8 +19,13 @@ declare module "jazz-react" {
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<JazzAndAuth>
<JazzProvider
AccountSchema={HRAccount}
sync={{
peer,
}}
>
<App />
</JazzAndAuth>
</JazzProvider>
</React.StrictMode>,
);

View File

@@ -16,25 +16,6 @@ async function scrollToBottom(page: Page) {
});
}
const login = async ({
page,
userName,
loginAs = false,
}: {
page: Page;
userName: string;
loginAs?: boolean;
}) => {
const loginPage = new LoginPage(page);
await loginPage.goto("/");
if (loginAs) {
await loginPage.loginAs(userName);
} else {
await loginPage.fillUsername(userName);
await loginPage.signup();
}
};
test.describe("Admin onboarding flow", () => {
let browser: Browser;
let adminContext: BrowserContext;
@@ -54,7 +35,7 @@ test.describe("Admin onboarding flow", () => {
test("Create and delete flow", async () => {
const adminPage = await adminContext.newPage();
await login({ page: adminPage, userName: "HR specialist" });
await adminPage.goto("/");
const adminHomePage = new HomePage(adminPage);
await adminHomePage.createEmployee("Paul");
await adminHomePage.createEmployee("Sean");
@@ -70,10 +51,8 @@ test.describe("Admin onboarding flow", () => {
const adminPage = await adminContext.newPage();
const writerPage = await writerContext.newPage();
const adminUser = "HR specialist";
const writerUser = "Invitee";
await login({ page: adminPage, userName: adminUser });
await login({ page: writerPage, userName: writerUser });
await adminPage.goto("/");
await writerPage.goto("/");
const adminHomePage = new HomePage(adminPage);
await adminHomePage.createEmployee("Paul");

View File

@@ -0,0 +1,20 @@
// vite.config.ts
import path from "path";
import react from "file:///Users/brad/dev/jazz/node_modules/@vitejs/plugin-react-swc/index.mjs";
import topLevelAwait from "file:///Users/brad/dev/jazz/node_modules/vite-plugin-top-level-await/exports/import.mjs";
import { defineConfig } from "file:///Users/brad/dev/jazz/node_modules/vite/dist/node/index.js";
var __vite_injected_original_dirname =
"/Users/brad/dev/jazz/examples/onboarding";
var vite_config_default = defineConfig({
plugins: [react(), topLevelAwait()],
resolve: {
alias: {
"@": path.resolve(__vite_injected_original_dirname, "./src"),
},
},
build: {
minify: false,
},
});
export { vite_config_default as default };
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCIvVXNlcnMvYnJhZC9kZXYvamF6ei9leGFtcGxlcy9vbmJvYXJkaW5nXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ZpbGVuYW1lID0gXCIvVXNlcnMvYnJhZC9kZXYvamF6ei9leGFtcGxlcy9vbmJvYXJkaW5nL3ZpdGUuY29uZmlnLnRzXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ltcG9ydF9tZXRhX3VybCA9IFwiZmlsZTovLy9Vc2Vycy9icmFkL2Rldi9qYXp6L2V4YW1wbGVzL29uYm9hcmRpbmcvdml0ZS5jb25maWcudHNcIjtpbXBvcnQgcGF0aCBmcm9tIFwicGF0aFwiO1xuaW1wb3J0IHJlYWN0IGZyb20gXCJAdml0ZWpzL3BsdWdpbi1yZWFjdC1zd2NcIjtcbmltcG9ydCB7IGRlZmluZUNvbmZpZyB9IGZyb20gXCJ2aXRlXCI7XG5pbXBvcnQgdG9wTGV2ZWxBd2FpdCBmcm9tIFwidml0ZS1wbHVnaW4tdG9wLWxldmVsLWF3YWl0XCI7XG5cbi8vIGh0dHBzOi8vdml0ZWpzLmRldi9jb25maWcvXG5leHBvcnQgZGVmYXVsdCBkZWZpbmVDb25maWcoe1xuICBwbHVnaW5zOiBbcmVhY3QoKSwgdG9wTGV2ZWxBd2FpdCgpXSxcbiAgcmVzb2x2ZToge1xuICAgIGFsaWFzOiB7XG4gICAgICBcIkBcIjogcGF0aC5yZXNvbHZlKF9fZGlybmFtZSwgXCIuL3NyY1wiKSxcbiAgICB9LFxuICB9LFxuICBidWlsZDoge1xuICAgIG1pbmlmeTogZmFsc2UsXG4gIH0sXG59KTtcbiJdLAogICJtYXBwaW5ncyI6ICI7QUFBMFMsT0FBTyxVQUFVO0FBQzNULE9BQU8sV0FBVztBQUNsQixTQUFTLG9CQUFvQjtBQUM3QixPQUFPLG1CQUFtQjtBQUgxQixJQUFNLG1DQUFtQztBQU16QyxJQUFPLHNCQUFRLGFBQWE7QUFBQSxFQUMxQixTQUFTLENBQUMsTUFBTSxHQUFHLGNBQWMsQ0FBQztBQUFBLEVBQ2xDLFNBQVM7QUFBQSxJQUNQLE9BQU87QUFBQSxNQUNMLEtBQUssS0FBSyxRQUFRLGtDQUFXLE9BQU87QUFBQSxJQUN0QztBQUFBLEVBQ0Y7QUFBQSxFQUNBLE9BQU87QUFBQSxJQUNMLFFBQVE7QUFBQSxFQUNWO0FBQ0YsQ0FBQzsiLAogICJuYW1lcyI6IFtdCn0K

View File

@@ -1,5 +1,13 @@
# organization
## 0.0.34
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-react@0.9.20
## 0.0.33
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "organization",
"private": true,
"version": "0.0.33",
"version": "0.0.34",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -1,4 +1,4 @@
import { DemoAuthBasicUI, JazzProvider, useDemoAuth } from "jazz-react";
import { JazzProvider } from "jazz-react";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import "./index.css";
@@ -27,26 +27,6 @@ function Router() {
return <RouterProvider router={router}></RouterProvider>;
}
function JazzAndAuth({ children }: { children: React.ReactNode }) {
const [auth, authState] = useDemoAuth();
return (
<>
<JazzProvider
AccountSchema={JazzAccount}
auth={auth}
peer="wss://cloud.jazz.tools/?key=organization-example@garden.co"
>
{children}
</JazzProvider>
{authState.state !== "signedIn" && (
<DemoAuthBasicUI appName="Organization" state={authState} />
)}
</>
);
}
declare module "jazz-react" {
interface Register {
Account: JazzAccount;
@@ -55,8 +35,13 @@ declare module "jazz-react" {
createRoot(document.getElementById("root")!).render(
<StrictMode>
<JazzAndAuth>
<JazzProvider
AccountSchema={JazzAccount}
sync={{
peer: "wss://cloud.jazz.tools/?key=organization-example@garden.co",
}}
>
<Router />
</JazzAndAuth>
</JazzProvider>
</StrictMode>,
);

View File

@@ -1,5 +1,11 @@
# passkey-svelte
## 0.0.29
### Patch Changes
- jazz-svelte@0.9.20
## 0.0.28
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "passkey-svelte",
"version": "0.0.28",
"version": "0.0.29",
"type": "module",
"private": true,
"scripts": {

View File

@@ -1,27 +1,19 @@
<script lang="ts">
import { JazzProvider, PasskeyAuthBasicUI, usePasskeyAuth } from 'jazz-svelte';
import { JazzProvider, PasskeyAuthBasicUI } from 'jazz-svelte';
let { children } = $props();
let auth = usePasskeyAuth({ appName: 'minimal-svelte-auth-passkey' });
$inspect(auth.state);
</script>
<div
style="width: 100vw; height: 100vh; display: flex; align-items: center; justify-content: center;"
<JazzProvider
sync={{
peer: "wss://cloud.jazz.tools/?key=minimal-svelte-auth-passkey@garden.co",
when: "signedUp",
}}
>
<PasskeyAuthBasicUI state={auth.state} />
{#if auth.current}
<JazzProvider
auth={auth.current}
peer="wss://cloud.jazz.tools/?key=minimal-svelte-auth-passkey@garden.co"
>
{@render children?.()}
</JazzProvider>
{/if}
</div>
<PasskeyAuthBasicUI appName="minimal-svelte-auth-passkey">
{@render children?.()}
</PasskeyAuthBasicUI>
</JazzProvider>
<style>
:global(html, body) {

View File

@@ -1,5 +1,13 @@
# minimal-auth-passkey
## 0.0.39
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-react@0.9.20
## 0.0.38
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "passkey",
"private": true,
"version": "0.0.38",
"version": "0.0.39",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -1,24 +1,21 @@
import { JazzProvider, PasskeyAuthBasicUI, usePasskeyAuth } from "jazz-react";
import { JazzProvider, PasskeyAuthBasicUI } from "jazz-react";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import App from "./App.tsx";
import "./index.css";
function JazzAndAuth({ children }: { children: React.ReactNode }) {
const [auth, state] = usePasskeyAuth({
appName: "Jazz Minimal Auth Passkey Example",
});
return (
<>
<JazzProvider
auth={auth}
peer="wss://cloud.jazz.tools/?key=minimal-auth-passkey-example@garden.co"
>
<JazzProvider
sync={{
peer: "wss://cloud.jazz.tools/?key=minimal-auth-passkey-example@garden.co",
when: "signedUp",
}}
>
<PasskeyAuthBasicUI appName="Jazz Minimal Auth Passkey Example">
{children}
</JazzProvider>
<PasskeyAuthBasicUI state={state} />
</>
</PasskeyAuthBasicUI>
</JazzProvider>
);
}

24
examples/passphrase/.gitignore vendored Normal file
View File

@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

View File

@@ -0,0 +1,56 @@
# Passphrase authentication example with Jazz and React
This is an example of how to use passphrase authentication with Jazz.
## Getting started
You can either
1. Clone the jazz repository, and run the app within the monorepo.
2. Or create a new Jazz project using this example as a template.
### Using the example as a template
Create a new Jazz project, and use this example as a template.
```bash
npx create-jazz-app@latest --example passphrase --project-name passphrase
```
Go to the new project directory.
```bash
cd passphrase
```
Run the dev server.
```bash
npm run dev
```
### Using the monorepo
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
Clone the jazz repository.
```bash
git clone https://github.com/garden-co/jazz.git
```
Install and build dependencies.
```bash
pnpm i && npx turbo build
```
Go to the example directory.
```bash
cd jazz/examples/passphrase/
```
Start the dev server.
```bash
pnpm dev
```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Questions / problems / feedback
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.

View File

@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Jazz | Minimal Auth Passphrase Example</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

View File

@@ -0,0 +1,28 @@
{
"name": "passphrase",
"private": true,
"version": "0.0.39",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"preview": "vite preview",
"format-and-lint": "biome check .",
"format-and-lint:fix": "biome check . --write"
},
"dependencies": {
"jazz-react": "workspace:*",
"jazz-tools": "workspace:*",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@vitejs/plugin-react": "^4.3.3",
"globals": "^15.11.0",
"typescript": "~5.6.2",
"vite": "^5.4.10"
}
}

View File

@@ -0,0 +1,14 @@
import { useAccount } from "jazz-react";
function App() {
const { logOut } = useAccount();
return (
<main>
<h1>You're logged in</h1>
<button onClick={() => logOut()}>Logout</button>
</main>
);
}
export default App;

View File

@@ -0,0 +1,68 @@
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;
color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}
body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}
#root {
width: 100%;
}
h1 {
font-size: 3.2em;
line-height: 1.1;
}
button {
border-radius: 8px;
border: 0;
padding: 0.6em 1.2em;
font-weight: 500;
background-color: #1a1a1a;
cursor: pointer;
}
@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}
main {
padding: 1rem;
margin: 0 auto;
text-align: center;
}

View File

@@ -0,0 +1,32 @@
import { JazzProvider, PassphraseAuthBasicUI } from "jazz-react";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import App from "./App.tsx";
import "./index.css";
import { wordlist } from "./wordlist.ts";
function JazzAndAuth({ children }: { children: React.ReactNode }) {
return (
<JazzProvider
sync={{
peer: "wss://cloud.jazz.tools/?key=minimal-auth-passphrase-example@garden.co",
when: "signedUp",
}}
>
<PassphraseAuthBasicUI
appName="Jazz Minimal Auth Passphrase Example"
wordlist={wordlist}
>
{children}
</PassphraseAuthBasicUI>
</JazzProvider>
);
}
createRoot(document.getElementById("root")!).render(
<StrictMode>
<JazzAndAuth>
<App />
</JazzAndAuth>
</StrictMode>,
);

1
examples/passphrase/src/vite-env.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
/// <reference types="vite/client" />

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,24 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2023", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"moduleResolution": "Bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["src"]
}

View File

@@ -0,0 +1,7 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}

View File

@@ -0,0 +1,22 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2022",
"lib": ["ES2023"],
"module": "ESNext",
"skipLibCheck": true,
"moduleResolution": "Bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["vite.config.ts"]
}

View File

@@ -0,0 +1,8 @@
{
"build": {
"env": {
"APP_NAME": "passphrase-demo"
}
},
"ignoreCommand": "node ../../ignore-vercel-build.js"
}

View File

@@ -0,0 +1,7 @@
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
});

View File

@@ -1,5 +1,13 @@
# jazz-password-manager
## 0.0.60
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-react@0.9.20
## 0.0.59
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-password-manager",
"private": true,
"version": "0.0.59",
"version": "0.0.60",
"type": "module",
"scripts": {
"dev": "vite",
@@ -12,8 +12,8 @@
"clean-install": "rm -rf node_modules pnpm-lock.yaml && pnpm install"
},
"dependencies": {
"jazz-react": "workspace:0.9.19",
"jazz-tools": "workspace:0.9.19",
"jazz-react": "workspace:0.9.20",
"jazz-tools": "workspace:0.9.20",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.41.5",

View File

@@ -1,4 +1,4 @@
import { JazzProvider, PasskeyAuthBasicUI, usePasskeyAuth } from "jazz-react";
import { JazzProvider, PasskeyAuthBasicUI } from "jazz-react";
import React from "react";
import ReactDOM from "react-dom/client";
import { PasswordManagerAccount } from "./1_schema.ts";
@@ -6,21 +6,18 @@ import App from "./5_App.tsx";
import "./index.css";
function JazzAndAuth({ children }: { children: React.ReactNode }) {
const [auth, state] = usePasskeyAuth({
appName: "Jazz Password Manager",
});
return (
<>
<JazzProvider
AccountSchema={PasswordManagerAccount}
auth={auth}
peer="wss://cloud.jazz.tools/?key=password-manager-example-jazz@garden.co"
>
<JazzProvider
AccountSchema={PasswordManagerAccount}
sync={{
peer: "wss://cloud.jazz.tools/?key=password-manager-example-jazz@garden.co",
when: "signedUp",
}}
>
<PasskeyAuthBasicUI appName="Jazz Password Manager">
{children}
</JazzProvider>
<PasskeyAuthBasicUI state={state} />
</>
</PasskeyAuthBasicUI>
</JazzProvider>
);
}

View File

@@ -1,5 +1,14 @@
# jazz-example-pets
## 0.0.158
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-browser-media-images@0.9.20
- jazz-react@0.9.20
## 0.0.157
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-pets",
"private": true,
"version": "0.0.157",
"version": "0.0.158",
"type": "module",
"scripts": {
"dev": "vite",
@@ -19,9 +19,9 @@
"@radix-ui/react-toast": "^1.1.4",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"jazz-browser-media-images": "workspace:0.9.19",
"jazz-react": "workspace:0.9.19",
"jazz-tools": "workspace:0.9.19",
"jazz-browser-media-images": "workspace:0.9.20",
"jazz-react": "workspace:0.9.20",
"jazz-tools": "workspace:0.9.20",
"lucide-react": "^0.274.0",
"qrcode": "^1.5.3",
"react": "^18.3.1",
@@ -41,7 +41,7 @@
"@vitejs/plugin-react-swc": "^3.3.2",
"autoprefixer": "^10.4.20",
"is-ci": "^3.0.1",
"jazz-run": "workspace:0.9.19",
"jazz-run": "workspace:0.9.20",
"postcss": "^8.4.27",
"tailwindcss": "^3.4.15",
"typescript": "~5.6.2",

View File

@@ -9,11 +9,10 @@ import {
import "./index.css";
import {
DemoAuthBasicUI,
JazzProvider,
PasskeyAuthBasicUI,
useAcceptInvite,
useAccount,
useDemoAuth,
} from "jazz-react";
import { PetAccount, PetPost } from "./1_schema.ts";
@@ -31,42 +30,36 @@ const peer =
) as `ws://${string}`) ??
"wss://cloud.jazz.tools/?key=pets-example-jazz@garden.co";
/** Walkthrough: The top-level provider `<JazzProvider/>`
*
* This shows how to use the top-level provider `<JazzProvider/>`,
* which provides the rest of the app with a `LocalNode` (used through `useJazz` later),
* based on `LocalAuth` that uses PassKeys (aka WebAuthn) to store a user's account secret
* - no backend needed. */
const appName = "Jazz Rate My Pet Example";
function JazzAndAuth({ children }: { children: React.ReactNode }) {
const [auth, authState] = useDemoAuth();
return (
<>
<JazzProvider auth={auth} peer={peer} AccountSchema={PetAccount}>
{children}
</JazzProvider>
<DemoAuthBasicUI appName={appName} state={authState} />
</>
);
}
declare module "jazz-react" {
interface Register {
Account: PetAccount;
}
}
/** Walkthrough: The top-level provider `<JazzProvider/>`
*
* This shows how to use the top-level provider `<JazzProvider/>`,
* which provides the rest of the app with a `LocalNode` (used through `useCoState` later),
* based on `PasskeyAuth` that uses PassKeys (aka WebAuthn) to store a user's account secret
* - no backend needed. */
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<ThemeProvider>
<TitleAndLogo name={appName} />
<div className="flex flex-col h-full items-center justify-start gap-10 pt-10 pb-10 px-5">
<JazzAndAuth>
<App />
</JazzAndAuth>
<JazzProvider
sync={{
peer,
when: "signedUp",
}}
AccountSchema={PetAccount}
>
<PasskeyAuthBasicUI appName={appName}>
<App />
</PasskeyAuthBasicUI>
</JazzProvider>
</div>
</ThemeProvider>
</React.StrictMode>,
@@ -78,7 +71,6 @@ ReactDOM.createRoot(document.getElementById("root")!).render(
* on the CoValue ID (CoID) of our PetPost, stored in the URL hash
* - which can also contain invite links.
*/
export default function App() {
const { logOut } = useAccount();

View File

@@ -1,4 +1,4 @@
import { test } from "@playwright/test";
import { BrowserContext, test } from "@playwright/test";
import { HomePage } from "./pages/HomePage";
import { LoginPage } from "./pages/LoginPage";
import { NewPostPage } from "./pages/NewPostPage";
@@ -6,50 +6,80 @@ import { PostPage } from "./pages/PostPage";
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
test("create a new post and share", async ({ page }) => {
const loginPage = new LoginPage(page);
test("create a new post and share", async ({ page: luigiPage, browser }) => {
const context = await browser.newContext();
await mockAuthenticator(context);
await loginPage.goto();
await loginPage.fillUsername("S. Mario");
await loginPage.signup();
const marioPage = await context.newPage();
await marioPage.goto("/");
await luigiPage.goto("/");
const homePage = new HomePage(page);
const marioLoginPage = new LoginPage(marioPage);
await marioLoginPage.fillUsername("S. Mario");
await marioLoginPage.signup();
await homePage.navigateToNewPost();
const luigiLoginPage = new LoginPage(luigiPage);
await luigiLoginPage.fillUsername("Luigi");
await luigiLoginPage.signup();
const newPostPage = new NewPostPage(page);
const marioHomePage = new HomePage(marioPage);
await marioHomePage.navigateToNewPost();
const newPostPage = new NewPostPage(marioPage);
await newPostPage.fillPetName("Yoshi");
await newPostPage.uploadFile("./public/jazz-logo-low-res.jpg");
await newPostPage.submit();
const postPage = new PostPage(page);
const marioPostPage = new PostPage(marioPage);
await marioPostPage.expectPetName("Yoshi");
await postPage.expectPetName("Yoshi");
const invitation = await postPage.getShareLink();
const invitation = await marioPostPage.getShareLink();
await sleep(1000);
await luigiPage.goto(invitation);
await postPage.logout();
const luigiPostPage = new PostPage(luigiPage);
await luigiPostPage.expectPetName("Yoshi");
await luigiPostPage.expectReactionSelectedByCurrentUser("😍", false);
await luigiPostPage.toggleReaction("😍");
await luigiPostPage.expectReactionSelectedByCurrentUser("😍", true);
await loginPage.expectLoaded();
await loginPage.fillUsername("Luigi");
await loginPage.signup();
await page.goto(invitation);
await postPage.expectPetName("Yoshi");
await postPage.expectReactionSelectedByCurrentUser("😍", false);
await postPage.toggleReaction("😍");
await postPage.expectReactionSelectedByCurrentUser("😍", true);
await postPage.logout();
await loginPage.expectLoaded();
await loginPage.loginAs("S. Mario");
await homePage.navigateToPost("Yoshi");
await postPage.expectPetName("Yoshi");
await postPage.expectReactionByUser("😍", "Luigi");
await marioPostPage.expectReactionByUser("😍", "Luigi");
});
async function mockAuthenticator(context: BrowserContext) {
await context.addInitScript(() => {
Object.defineProperty(window.navigator, "credentials", {
value: {
...window.navigator.credentials,
create: async () => ({
type: "public-key",
id: new Uint8Array([1, 2, 3, 4]),
rawId: new Uint8Array([1, 2, 3, 4]),
response: {
clientDataJSON: new Uint8Array([1]),
attestationObject: new Uint8Array([2]),
},
}),
get: async () => ({
type: "public-key",
id: new Uint8Array([1, 2, 3, 4]),
rawId: new Uint8Array([1, 2, 3, 4]),
response: {
authenticatorData: new Uint8Array([1]),
clientDataJSON: new Uint8Array([2]),
signature: new Uint8Array([3]),
},
}),
},
configurable: true,
});
});
}
// Configure the authenticator
test.beforeEach(async ({ context }) => {
// Enable virtual authenticator environment
await mockAuthenticator(context);
});

View File

@@ -1,5 +1,14 @@
# reactions
## 0.0.38
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-browser-media-images@0.9.20
- jazz-react@0.9.20
## 0.0.37
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "reactions",
"private": true,
"version": "0.0.37",
"version": "0.0.38",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -1,32 +1,20 @@
import { DemoAuthBasicUI, JazzProvider, useDemoAuth } from "jazz-react";
import { JazzProvider, PasskeyAuthBasicUI } from "jazz-react";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import App from "./App.tsx";
import "./index.css";
function JazzAndAuth({ children }: { children: React.ReactNode }) {
const [auth, authState] = useDemoAuth();
return (
<>
<JazzProvider
auth={auth}
peer="wss://cloud.jazz.tools/?key=reactions-example@garden.co"
>
{children}
</JazzProvider>
{authState.state !== "signedIn" && (
<DemoAuthBasicUI appName="Reactions" state={authState} />
)}
</>
);
}
createRoot(document.getElementById("root")!).render(
<StrictMode>
<JazzAndAuth>
<App />
</JazzAndAuth>
<JazzProvider
sync={{
peer: "wss://cloud.jazz.tools/?key=reactions-example@garden.co",
when: "signedUp",
}}
>
<PasskeyAuthBasicUI appName="Jazz Reactions Example">
<App />
</PasskeyAuthBasicUI>
</JazzProvider>
</StrictMode>,
);

View File

@@ -1,5 +1,14 @@
# todo-vue
## 0.0.43
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-browser@0.9.20
- jazz-vue@0.9.20
## 0.0.42
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "todo-vue",
"version": "0.0.42",
"version": "0.0.43",
"private": true,
"type": "module",
"scripts": {

View File

@@ -14,27 +14,25 @@ declare module "jazz-vue" {
const RootComponent = defineComponent({
name: "RootComponent",
setup() {
const { authMethod, state } = useDemoAuth();
return () => [
return () =>
h(
JazzProvider,
{
AccountSchema: ToDoAccount,
auth: authMethod.value,
peer: "wss://cloud.jazz.tools/?key=vue-todo-example-jazz@garden.co",
sync: {
peer: "wss://cloud.jazz.tools/?key=vue-todo-example-jazz@garden.co",
},
},
{
default: () => h(App),
},
),
state.state !== "signedIn" &&
h(DemoAuthBasicUI, {
appName: "Jazz Vue Todo",
state,
}),
];
h(
DemoAuthBasicUI,
{
appName: "Jazz Vue Todo",
},
{
default: () => h(App),
},
),
);
},
});

View File

@@ -1,5 +1,13 @@
# jazz-example-todo
## 0.0.157
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-react@0.9.20
## 0.0.156
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-todo",
"private": true,
"version": "0.0.156",
"version": "0.0.157",
"type": "module",
"scripts": {
"dev": "vite",
@@ -16,8 +16,8 @@
"@radix-ui/react-toast": "^1.1.4",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"jazz-react": "workspace:0.9.19",
"jazz-tools": "workspace:0.9.19",
"jazz-react": "workspace:0.9.20",
"jazz-tools": "workspace:0.9.20",
"lucide-react": "^0.274.0",
"qrcode": "^1.5.3",
"react": "^18.3.1",

Some files were not shown because too many files have changed in this diff Show More