jazz-svelte 0.9.22 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2024, Garden Computing, Inc.
1
+ Copyright 2025, Garden Computing, Inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
@@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
16
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
17
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
18
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- SOFTWARE.
19
+ SOFTWARE.
@@ -1,64 +1,55 @@
1
1
  <script lang="ts" module>
2
- export type Props<Acc extends Account = Account> = {
2
+ export type Props<Acc extends Account = Account> = JazzContextManagerProps<Acc> & {
3
3
  children?: Snippet;
4
- auth: AuthMethod | 'guest';
5
- peer: `wss://${string}` | `ws://${string}`;
6
- storage?: 'indexedDB' | 'singleTabOPFS';
7
- AccountSchema?: AccountClass<Acc>;
8
4
  };
9
5
  </script>
10
6
 
11
7
  <script lang="ts" generics="Acc extends Account">
12
- import { createJazzBrowserContext } from 'jazz-browser';
13
- import type { AccountClass, AuthMethod } from 'jazz-tools';
8
+ import { JazzBrowserContextManager, type JazzContextManagerProps } from 'jazz-browser';
9
+ import type { AuthSecretStorage } from 'jazz-tools';
14
10
  import { Account } from 'jazz-tools';
15
11
  import { type Snippet, setContext, untrack } from 'svelte';
16
- import { JAZZ_CTX, type JazzContext } from './jazz.svelte.js';
12
+ import { JAZZ_AUTH_CTX, JAZZ_CTX, type JazzContext } from './jazz.svelte.js';
17
13
 
18
- let { children, auth, peer, storage, AccountSchema }: Props<Acc> = $props();
14
+ let props: Props<Acc> = $props();
15
+
16
+ const contextManager = new JazzBrowserContextManager<Acc>();
19
17
 
20
18
  const ctx = $state<JazzContext<Acc>>({ current: undefined });
21
19
  setContext<JazzContext<Acc>>(JAZZ_CTX, ctx);
22
- let sessionCount = $state(0);
20
+ setContext<AuthSecretStorage>(JAZZ_AUTH_CTX, contextManager.getAuthSecretStorage());
23
21
 
24
22
  $effect(() => {
25
- auth;
26
- peer;
27
- storage;
28
- sessionCount;
23
+ props.sync.when;
24
+ props.sync.peer;
25
+ props.storage;
26
+ props.guestMode;
29
27
  return untrack(() => {
30
- if (!auth || !peer) return;
28
+ if (!props.sync) return;
31
29
 
32
- const promiseWithDoneCallback = createJazzBrowserContext<Acc>(
33
- auth === 'guest'
34
- ? {
35
- peer,
36
- storage
37
- }
38
- : {
39
- AccountSchema: AccountSchema ?? Account as unknown as AccountClass<Acc>,
40
- auth,
41
- peer,
42
- storage
43
- }
44
- ).then((context) => {
45
- ctx.current = {
46
- ...context,
47
- logOut: () => {
48
- context.logOut();
49
- ctx.current = undefined;
50
- sessionCount = sessionCount + 1;
51
- }
52
- };
53
- return context.done;
54
- });
55
- return () => {
56
- void promiseWithDoneCallback.then((done) => done());
57
- };
30
+ contextManager
31
+ .createContext({
32
+ sync: props.sync,
33
+ storage: props.storage,
34
+ guestMode: props.guestMode,
35
+ AccountSchema: props.AccountSchema,
36
+ defaultProfileName: props.defaultProfileName,
37
+ onAnonymousAccountDiscarded: props.onAnonymousAccountDiscarded,
38
+ onLogOut: props.onLogOut,
39
+ })
40
+ .catch((error) => {
41
+ console.error('Error creating Jazz browser context:', error);
42
+ });
43
+ });
44
+ });
45
+
46
+ $effect(() => {
47
+ return contextManager.subscribe(() => {
48
+ ctx.current = contextManager.getCurrentValue();
58
49
  });
59
50
  });
60
51
  </script>
61
52
 
62
53
  {#if ctx.current}
63
- {@render children?.()}
54
+ {@render props.children?.()}
64
55
  {/if}
@@ -1,11 +1,7 @@
1
- export type Props<Acc extends Account = Account> = {
1
+ export type Props<Acc extends Account = Account> = JazzContextManagerProps<Acc> & {
2
2
  children?: Snippet;
3
- auth: AuthMethod | 'guest';
4
- peer: `wss://${string}` | `ws://${string}`;
5
- storage?: 'indexedDB' | 'singleTabOPFS';
6
- AccountSchema?: AccountClass<Acc>;
7
3
  };
8
- import type { AccountClass, AuthMethod } from 'jazz-tools';
4
+ import { type JazzContextManagerProps } from 'jazz-browser';
9
5
  import { Account } from 'jazz-tools';
10
6
  import { type Snippet } from 'svelte';
11
7
  declare class __sveltets_Render<Acc extends Account> {
@@ -1,21 +1,7 @@
1
1
  import { BrowserPasskeyAuth } from "jazz-browser";
2
- export type PasskeyAuthState = ({
3
- state: "uninitialized";
4
- } | {
5
- state: "loading";
6
- } | {
7
- state: "ready";
8
- logIn: () => void;
9
- signUp: (username: string) => void;
10
- } | {
11
- state: "signedIn";
12
- logOut: () => void;
13
- }) & {
14
- errors: string[];
15
- };
16
2
  export type PasskeyAuth = {
17
- current?: BrowserPasskeyAuth;
18
- state: PasskeyAuthState;
3
+ current: BrowserPasskeyAuth;
4
+ state: "anonymous" | "signedIn";
19
5
  };
20
6
  /** @category Auth Providers */
21
7
  export declare function usePasskeyAuth({ appName, appHostname, }: {
@@ -1,53 +1,18 @@
1
+ import { getAuthSecretStorage, getJazzContext } from "../jazz.svelte.js";
1
2
  import { BrowserPasskeyAuth } from "jazz-browser";
2
- import { onMount } from "svelte";
3
+ import { useIsAuthenticated } from "./useIsAuthenticated.svelte.js";
3
4
  /** @category Auth Providers */
4
5
  export function usePasskeyAuth({ appName, appHostname, }) {
5
- let instance = $state();
6
- let state = $state({
7
- state: "loading",
8
- errors: [],
9
- });
10
- // Function to create a new auth instance
11
- function createAuthInstance() {
12
- instance = new BrowserPasskeyAuth({
13
- onReady(next) {
14
- state = {
15
- state: "ready",
16
- logIn: next.logIn,
17
- signUp: next.signUp,
18
- errors: [],
19
- };
20
- },
21
- onSignedIn(next) {
22
- state = {
23
- state: "signedIn",
24
- logOut: () => {
25
- // First set state to loading
26
- state = { state: "loading", errors: [] };
27
- // Then trigger logout
28
- next.logOut();
29
- // Create new instance to trigger onReady
30
- createAuthInstance();
31
- },
32
- errors: [],
33
- };
34
- },
35
- onError(error) {
36
- state = {
37
- ...state,
38
- errors: [...state.errors, error.toString()],
39
- };
40
- },
41
- }, appName, appHostname);
6
+ const context = getJazzContext();
7
+ const authSecretStorage = getAuthSecretStorage();
8
+ const auth = new BrowserPasskeyAuth(context.current.node.crypto, context.current.authenticate, authSecretStorage, appName, appHostname);
9
+ if ("guest" in context.current) {
10
+ throw new Error("Passkey auth is not supported in guest mode");
42
11
  }
43
- // Initialize the auth instance on mount
44
- onMount(() => {
45
- createAuthInstance();
46
- });
12
+ const isAuthenticated = useIsAuthenticated();
13
+ const state = $derived(isAuthenticated.value ? "signedIn" : "anonymous");
47
14
  return {
48
- get current() {
49
- return instance;
50
- },
15
+ current: auth,
51
16
  get state() {
52
17
  return state;
53
18
  },
@@ -1,42 +1,58 @@
1
1
  <script lang="ts">
2
- import { type PasskeyAuthState } from 'jazz-svelte';
2
+ import type { Snippet } from 'svelte';
3
+ import { usePasskeyAuth } from './PasskeyAuth.svelte.js';
3
4
 
4
- let { state: authState }: { state: PasskeyAuthState } = $props();
5
+ let { appName, children }: { appName: string; children?: Snippet } = $props();
5
6
 
6
- let name = $state('');
7
+ const auth = usePasskeyAuth({ appName });
8
+
9
+ let error = $state<string | undefined>(undefined);
7
10
 
8
11
  function signUp(e: Event) {
12
+ const formData = new FormData(e.currentTarget as HTMLFormElement);
13
+ const name = formData.get('name') as string;
14
+
15
+ if (!name) {
16
+ error = 'Name is required';
17
+ return;
18
+ }
9
19
  e.preventDefault();
10
- if (!name.trim() || authState.state !== 'ready') return;
11
- authState.signUp(name);
20
+ error = undefined;
21
+ auth.current.signUp(name).catch((e) => {
22
+ error = e.message;
23
+ });
12
24
  }
13
25
 
14
26
  function logIn(e: Event) {
27
+ error = undefined;
15
28
  e.preventDefault();
16
29
  e.stopPropagation();
17
- if (authState.state !== 'ready') return;
18
- authState.logIn();
30
+ auth.current.logIn().catch((e) => {
31
+ error = e.message;
32
+ });
19
33
  }
20
34
  </script>
21
35
 
22
- <div style="max-width: 18rem; display: flex; flex-direction: column; gap: 2rem;">
23
- {#if authState.state === 'loading'}
24
- <div>Loading...</div>
25
- {:else if authState.state === 'ready'}
26
- {#if authState.errors?.length > 0}
27
- <div style="color: red;">
28
- {#each authState.errors as error}
29
- <div>{error}</div>
30
- {/each}
31
- </div>
32
- {/if}
33
- <form onsubmit={signUp}>
34
- <input type="text" placeholder="Display name" bind:value={name} autocomplete="name" />
35
- <input type="submit" value="Sign up" />
36
- </form>
37
- <button onclick={logIn}> Log in with existing account </button>
38
- {/if}
39
- </div>
36
+ {#if auth.state === 'anonymous'}
37
+ <div
38
+ style="width: 100vw; height: 100vh; display: flex; align-items: center; justify-content: center;"
39
+ >
40
+ <div style="max-width: 18rem; display: flex; flex-direction: column; gap: 2rem;">
41
+ {#if error}
42
+ <div style="color: red;">
43
+ {error}
44
+ </div>
45
+ {/if}
46
+ <form onsubmit={signUp}>
47
+ <input type="text" name="name" placeholder="Display name" autocomplete="name" />
48
+ <input type="submit" value="Sign up" />
49
+ </form>
50
+ <button onclick={logIn}> Log in with existing account </button>
51
+ </div>
52
+ </div>
53
+ {:else}
54
+ {@render children?.()}
55
+ {/if}
40
56
 
41
57
  <style>
42
58
  form {
@@ -49,17 +65,17 @@
49
65
  input[type='submit'] {
50
66
  background: #000;
51
67
  color: #fff;
52
- padding: 6px 12px;
68
+ padding: 6px 12px;
53
69
  border: none;
54
70
  border-radius: 6px;
55
- min-height: 38px;
71
+ min-height: 38px;
56
72
  cursor: pointer;
57
73
  }
58
74
 
59
75
  input[type='text'] {
60
76
  border: 2px solid #000;
61
- padding: 6px 12px;
77
+ padding: 6px 12px;
62
78
  border-radius: 6px;
63
- min-height: 24px;
79
+ min-height: 24px;
64
80
  }
65
81
  </style>
@@ -1,6 +1,7 @@
1
- import { type PasskeyAuthState } from 'jazz-svelte';
1
+ import type { Snippet } from 'svelte';
2
2
  type $$ComponentProps = {
3
- state: PasskeyAuthState;
3
+ appName: string;
4
+ children?: Snippet;
4
5
  };
5
6
  declare const PasskeyAuthBasicUi: import("svelte").Component<$$ComponentProps, {}, "">;
6
7
  type PasskeyAuthBasicUi = ReturnType<typeof PasskeyAuthBasicUi>;
@@ -0,0 +1,9 @@
1
+ /** @category Auth Providers */
2
+ export declare function usePassphraseAuth({ wordlist, }: {
3
+ wordlist: string[];
4
+ }): {
5
+ logIn: (passphrase: string) => Promise<void>;
6
+ signUp: () => Promise<string>;
7
+ readonly passphrase: string;
8
+ readonly state: "anonymous" | "signedIn";
9
+ };
@@ -0,0 +1,29 @@
1
+ import { untrack } from "svelte";
2
+ import { getAuthSecretStorage, getJazzContext } from "../jazz.svelte.js";
3
+ import { useIsAuthenticated } from "./useIsAuthenticated.svelte.js";
4
+ import { PassphraseAuth } from "jazz-tools";
5
+ /** @category Auth Providers */
6
+ export function usePassphraseAuth({ wordlist, }) {
7
+ const context = getJazzContext();
8
+ const authSecretStorage = getAuthSecretStorage();
9
+ const auth = new PassphraseAuth(context.current.node.crypto, context.current.authenticate, authSecretStorage, wordlist);
10
+ let passphrase = $state(auth.passphrase);
11
+ $effect(untrack(() => {
12
+ auth.loadCurrentAccountPassphrase();
13
+ return auth.subscribe(() => {
14
+ passphrase = auth.passphrase;
15
+ });
16
+ }));
17
+ const isAuthenticated = useIsAuthenticated();
18
+ const state = $derived(isAuthenticated.value ? "signedIn" : "anonymous");
19
+ return {
20
+ logIn: auth.logIn,
21
+ signUp: auth.signUp,
22
+ get passphrase() {
23
+ return passphrase;
24
+ },
25
+ get state() {
26
+ return state;
27
+ },
28
+ };
29
+ }
@@ -1,2 +1,3 @@
1
- export * from "./PasskeyAuth.svelte";
1
+ export * from "./PasskeyAuth.svelte.js";
2
+ export * from "./PassphraseAuth.svelte.js";
2
3
  export { default as PasskeyAuthBasicUI } from "./PasskeyAuthBasicUI.svelte";
@@ -1,2 +1,3 @@
1
- export * from "./PasskeyAuth.svelte";
1
+ export * from "./PasskeyAuth.svelte.js";
2
+ export * from "./PassphraseAuth.svelte.js";
2
3
  export { default as PasskeyAuthBasicUI } from "./PasskeyAuthBasicUI.svelte";
@@ -0,0 +1,3 @@
1
+ export declare function useIsAuthenticated(): {
2
+ readonly value: boolean;
3
+ };
@@ -0,0 +1,17 @@
1
+ import { getAuthSecretStorage } from "../jazz.svelte.js";
2
+ import { onDestroy } from "svelte";
3
+ export function useIsAuthenticated() {
4
+ const authSecretStorage = getAuthSecretStorage();
5
+ let isAuthenticated = $state(authSecretStorage.isAuthenticated);
6
+ const unsubscribe = authSecretStorage.onUpdate(() => {
7
+ isAuthenticated = authSecretStorage.isAuthenticated;
8
+ });
9
+ onDestroy(() => {
10
+ unsubscribe();
11
+ });
12
+ return {
13
+ get value() {
14
+ return isAuthenticated;
15
+ }
16
+ };
17
+ }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { createInviteLink, parseInviteLink } from "jazz-browser";
2
2
  export * from "./auth/index.js";
3
3
  export * from "./jazz.svelte.js";
4
+ export { useIsAuthenticated } from "./auth/useIsAuthenticated.svelte.js";
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export { createInviteLink, parseInviteLink } from "jazz-browser";
2
2
  export * from "./auth/index.js";
3
3
  export * from "./jazz.svelte.js";
4
+ export { useIsAuthenticated } from "./auth/useIsAuthenticated.svelte.js";
@@ -1,5 +1,4 @@
1
- import { type BrowserContext, type BrowserGuestContext } from 'jazz-browser';
2
- import type { AnonymousJazzAgent, CoValue, CoValueClass, DeeplyLoaded, DepthsIn, ID } from 'jazz-tools';
1
+ import type { AnonymousJazzAgent, AuthSecretStorage, CoValue, CoValueClass, DeeplyLoaded, DepthsIn, ID, JazzContextType } from 'jazz-tools';
3
2
  import { Account } from 'jazz-tools';
4
3
  import Provider from './Provider.svelte';
5
4
  export { Provider as JazzProvider };
@@ -7,17 +6,21 @@ export { Provider as JazzProvider };
7
6
  * The key for the Jazz context.
8
7
  */
9
8
  export declare const JAZZ_CTX: {};
9
+ export declare const JAZZ_AUTH_CTX: {};
10
10
  /**
11
11
  * The Jazz context.
12
12
  */
13
13
  export type JazzContext<Acc extends Account> = {
14
- current?: BrowserContext<Acc> | BrowserGuestContext;
14
+ current?: JazzContextType<Acc>;
15
15
  };
16
16
  /**
17
17
  * Get the current Jazz context.
18
18
  * @returns The current Jazz context.
19
19
  */
20
- export declare function getJazzContext<Acc extends Account>(): JazzContext<Acc>;
20
+ export declare function getJazzContext<Acc extends Account>(): {
21
+ current: JazzContextType<Acc>;
22
+ };
23
+ export declare function getAuthSecretStorage(): AuthSecretStorage;
21
24
  export interface Register {
22
25
  }
23
26
  export type RegisteredAccount = Register extends {
@@ -28,14 +31,14 @@ export declare function useAccount(): {
28
31
  logOut: () => void;
29
32
  };
30
33
  export declare function useAccount<D extends DepthsIn<RegisteredAccount>>(depth: D): {
31
- me: DeeplyLoaded<RegisteredAccount, D> | undefined;
34
+ me: DeeplyLoaded<RegisteredAccount, D> | undefined | null;
32
35
  logOut: () => void;
33
36
  };
34
37
  export declare function useAccountOrGuest(): {
35
38
  me: RegisteredAccount | AnonymousJazzAgent;
36
39
  };
37
40
  export declare function useAccountOrGuest<D extends DepthsIn<RegisteredAccount>>(depth: D): {
38
- me: DeeplyLoaded<RegisteredAccount, D> | undefined | AnonymousJazzAgent;
41
+ me: DeeplyLoaded<RegisteredAccount, D> | undefined | null | AnonymousJazzAgent;
39
42
  };
40
43
  /**
41
44
  * Use a CoValue with a optional depth.
@@ -45,7 +48,7 @@ export declare function useAccountOrGuest<D extends DepthsIn<RegisteredAccount>>
45
48
  * @returns The CoValue.
46
49
  */
47
50
  export declare function useCoState<V extends CoValue, D extends DepthsIn<V> = []>(Schema: CoValueClass<V>, id: ID<V> | undefined, depth?: D): {
48
- current?: DeeplyLoaded<V, D>;
51
+ current?: DeeplyLoaded<V, D> | null;
49
52
  };
50
53
  /**
51
54
  * Use the accept invite hook.
@@ -7,12 +7,27 @@ export { Provider as JazzProvider };
7
7
  * The key for the Jazz context.
8
8
  */
9
9
  export const JAZZ_CTX = {};
10
+ export const JAZZ_AUTH_CTX = {};
10
11
  /**
11
12
  * Get the current Jazz context.
12
13
  * @returns The current Jazz context.
13
14
  */
14
15
  export function getJazzContext() {
15
- return getContext(JAZZ_CTX);
16
+ const context = getContext(JAZZ_CTX);
17
+ if (!context) {
18
+ throw new Error('useJazzContext must be used within a JazzProvider');
19
+ }
20
+ if (!context.current) {
21
+ throw new Error('Jazz context is not initialized');
22
+ }
23
+ return context;
24
+ }
25
+ export function getAuthSecretStorage() {
26
+ const context = getContext(JAZZ_AUTH_CTX);
27
+ if (!context) {
28
+ throw new Error('useJazzContext must be used within a JazzProvider');
29
+ }
30
+ return context;
16
31
  }
17
32
  /**
18
33
  * Use the current account with a optional depth.
@@ -102,7 +117,9 @@ export function useCoState(Schema, id, depth = []) {
102
117
  return subscribeToCoValue(Schema, id, 'me' in ctx.current ? ctx.current.me : ctx.current.guest, depth, (value) => {
103
118
  // Get current value from our stable observable
104
119
  state = value;
105
- }, undefined, true);
120
+ }, () => {
121
+ state = null;
122
+ }, true);
106
123
  });
107
124
  return {
108
125
  get current() {
@@ -128,6 +145,7 @@ export function useAcceptInvite({ invitedObjectSchema, onAccept, forValueHint })
128
145
  }
129
146
  // Subscribe to the onAccept function.
130
147
  $effect(() => {
148
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
131
149
  _onAccept;
132
150
  // Subscribe to the onAccept function.
133
151
  untrack(() => {
package/dist/testing.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { Account, AnonymousJazzAgent } from "jazz-tools";
1
+ import { Account, AnonymousJazzAgent, AuthSecretStorage } from "jazz-tools";
2
2
  import { type JazzContext } from './jazz.svelte.js';
3
- export declare function createJazzTestContext<Acc extends Account>({ account }: {
4
- account: Acc | {
3
+ export declare function createJazzTestContext<Acc extends Account>(opts?: {
4
+ account?: Acc | {
5
5
  guest: AnonymousJazzAgent;
6
6
  };
7
- }): Map<{}, JazzContext<Acc>>;
7
+ isAuthenticated?: boolean;
8
+ }): Map<{} | {}, AuthSecretStorage | JazzContext<Acc>>;
8
9
  export { createJazzTestAccount, createJazzTestGuest, linkAccounts, setActiveAccount, setupJazzTestSync, } from "jazz-tools/testing";
package/dist/testing.js CHANGED
@@ -1,17 +1,21 @@
1
- import { Account, AnonymousJazzAgent } from "jazz-tools";
2
- import { JAZZ_CTX } from './jazz.svelte.js';
3
- import { getJazzContextShape } from "jazz-tools/testing";
4
- export function createJazzTestContext({ account }) {
1
+ import { Account, AnonymousJazzAgent, AuthSecretStorage, } from "jazz-tools";
2
+ import { JAZZ_AUTH_CTX, JAZZ_CTX } from './jazz.svelte.js';
3
+ import { TestJazzContextManager } from "jazz-tools/testing";
4
+ export function createJazzTestContext(opts = {}) {
5
5
  const ctx = new Map();
6
- const value = getJazzContextShape(account);
6
+ const account = opts.account ?? Account.getMe();
7
+ const value = TestJazzContextManager.fromAccountOrGuest(account, {
8
+ isAuthenticated: opts.isAuthenticated
9
+ });
10
+ ctx.set(JAZZ_AUTH_CTX, value.getAuthSecretStorage());
7
11
  if ('guest' in account) {
8
12
  ctx.set(JAZZ_CTX, {
9
- current: value
13
+ current: value.getCurrentValue()
10
14
  });
11
15
  }
12
16
  else {
13
17
  ctx.set(JAZZ_CTX, {
14
- current: value
18
+ current: value.getCurrentValue()
15
19
  });
16
20
  }
17
21
  return ctx;
@@ -1,13 +1,11 @@
1
1
  <script lang="ts">
2
2
  import { JazzProvider } from "../../jazz.svelte.js";
3
3
 
4
- const { auth } = $props();
4
+ const { guestMode } = $props();
5
5
  </script>
6
6
 
7
7
  <div data-testid="provider-test">
8
- <JazzProvider {auth} peer="wss://cloud.jazz.tools/?key=jazz-svelte-test">
9
- {#if auth}
10
- <span data-testid="provider-auth-test">{JSON.stringify(auth)}</span>
11
- {/if}
8
+ <JazzProvider {guestMode} peer="wss://cloud.jazz.tools/?key=jazz-svelte-test">
9
+ <span data-testid="provider-auth-test">Hello</span>
12
10
  </JazzProvider>
13
11
  </div>
@@ -1,5 +1,5 @@
1
1
  declare const ProviderTestComponent: import("svelte").Component<{
2
- auth: any;
2
+ guestMode: any;
3
3
  }, {}, "">;
4
4
  type ProviderTestComponent = ReturnType<typeof ProviderTestComponent>;
5
5
  export default ProviderTestComponent;
@@ -0,0 +1,18 @@
1
+ <script lang="ts">
2
+ import { usePassphraseAuth } from "../../auth/PassphraseAuth.svelte.js";
3
+
4
+ let { wordlist, setResult }: { wordlist: string[]; setResult: (value: ReturnType<typeof usePassphraseAuth>) => void } = $props();
5
+
6
+ const auth = usePassphraseAuth({ wordlist });
7
+
8
+ $effect(() => {
9
+ setResult({
10
+ state: auth.state,
11
+ passphrase: auth.passphrase,
12
+ logIn: auth.logIn,
13
+ signUp: auth.signUp
14
+ });
15
+ });
16
+ </script>
17
+
18
+ <div>Test Component</div>
@@ -0,0 +1,7 @@
1
+ import { usePassphraseAuth } from "../../auth/PassphraseAuth.svelte.js";
2
+ declare const UsePassphraseAuth: import("svelte").Component<{
3
+ wordlist: string[];
4
+ setResult: (value: ReturnType<typeof usePassphraseAuth>) => void;
5
+ }, {}, "">;
6
+ type UsePassphraseAuth = ReturnType<typeof UsePassphraseAuth>;
7
+ export default UsePassphraseAuth;
@@ -0,0 +1 @@
1
+ export declare const testWordlist: string[];