jazz-tools 0.19.19 → 0.19.21
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/.svelte-kit/__package__/client.d.ts.map +1 -1
- package/.svelte-kit/__package__/client.js +3 -1
- package/.svelte-kit/__package__/server.d.ts.map +1 -1
- package/.svelte-kit/__package__/server.js +9 -7
- package/.svelte-kit/__package__/tests/client.test.js +48 -0
- package/.turbo/turbo-build.log +70 -66
- package/dist/better-auth/auth/client.d.ts.map +1 -1
- package/dist/better-auth/auth/client.js +1 -1
- package/dist/better-auth/auth/client.js.map +1 -1
- package/dist/better-auth/auth/server.d.ts.map +1 -1
- package/dist/better-auth/auth/server.js +4 -4
- package/dist/better-auth/auth/server.js.map +1 -1
- package/dist/better-auth/database-adapter/index.js.map +1 -1
- package/dist/better-auth/database-adapter/repository/generic.d.ts +3 -3
- package/dist/better-auth/database-adapter/repository/session.d.ts +2 -2
- package/dist/better-auth/database-adapter/schema.d.ts +3 -3
- package/dist/better-auth/database-adapter/schema.d.ts.map +1 -1
- package/dist/{chunk-PEHQ7TN2.js → chunk-QCTQH5RS.js} +31 -4
- package/dist/chunk-QCTQH5RS.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/react/hooks.d.ts +1 -2
- package/dist/react/hooks.d.ts.map +1 -1
- package/dist/react/index.js +7 -2
- package/dist/react/index.js.map +1 -1
- package/dist/react-core/hooks.d.ts +94 -3
- package/dist/react-core/hooks.d.ts.map +1 -1
- package/dist/react-core/index.js +130 -135
- package/dist/react-core/index.js.map +1 -1
- package/dist/react-core/tests/useCoStates.test.d.ts +2 -0
- package/dist/react-core/tests/useCoStates.test.d.ts.map +1 -0
- package/dist/react-native/chunk-DGUM43GV.js +11 -0
- package/dist/react-native/chunk-DGUM43GV.js.map +1 -0
- package/dist/react-native/crypto.js +2 -0
- package/dist/react-native/crypto.js.map +1 -1
- package/dist/react-native/index.js +544 -29
- package/dist/react-native/index.js.map +1 -1
- package/dist/react-native-core/auth/PasskeyAuth.d.ts +123 -0
- package/dist/react-native-core/auth/PasskeyAuth.d.ts.map +1 -0
- package/dist/react-native-core/auth/PasskeyAuthBasicUI.d.ts +34 -0
- package/dist/react-native-core/auth/PasskeyAuthBasicUI.d.ts.map +1 -0
- package/dist/react-native-core/auth/auth.d.ts +3 -0
- package/dist/react-native-core/auth/auth.d.ts.map +1 -1
- package/dist/react-native-core/auth/passkey-utils.d.ts +16 -0
- package/dist/react-native-core/auth/passkey-utils.d.ts.map +1 -0
- package/dist/react-native-core/auth/usePasskeyAuth.d.ts +48 -0
- package/dist/react-native-core/auth/usePasskeyAuth.d.ts.map +1 -0
- package/dist/react-native-core/chunk-DGUM43GV.js +11 -0
- package/dist/react-native-core/chunk-DGUM43GV.js.map +1 -0
- package/dist/react-native-core/crypto.js +2 -0
- package/dist/react-native-core/crypto.js.map +1 -1
- package/dist/react-native-core/hooks.d.ts +1 -1
- package/dist/react-native-core/hooks.d.ts.map +1 -1
- package/dist/react-native-core/index.js +539 -24
- package/dist/react-native-core/index.js.map +1 -1
- package/dist/react-native-core/tests/PasskeyAuth.test.d.ts +2 -0
- package/dist/react-native-core/tests/PasskeyAuth.test.d.ts.map +1 -0
- package/dist/react-native-core/tests/passkey-utils.test.d.ts +2 -0
- package/dist/react-native-core/tests/passkey-utils.test.d.ts.map +1 -0
- package/dist/svelte/auth/ClerkAuth.svelte.d.ts +38 -0
- package/dist/svelte/auth/ClerkAuth.svelte.d.ts.map +1 -0
- package/dist/svelte/auth/ClerkAuth.svelte.js +47 -0
- package/dist/svelte/auth/JazzSvelteProviderWithClerk.svelte +156 -0
- package/dist/svelte/auth/JazzSvelteProviderWithClerk.svelte.d.ts +67 -0
- package/dist/svelte/auth/JazzSvelteProviderWithClerk.svelte.d.ts.map +1 -0
- package/dist/svelte/auth/RegisterClerkAuth.svelte +27 -0
- package/dist/svelte/auth/RegisterClerkAuth.svelte.d.ts +17 -0
- package/dist/svelte/auth/RegisterClerkAuth.svelte.d.ts.map +1 -0
- package/dist/svelte/auth/index.d.ts +2 -0
- package/dist/svelte/auth/index.d.ts.map +1 -1
- package/dist/svelte/auth/index.js +2 -0
- package/dist/svelte/tests/ClerkAuth.svelte.test.d.ts +2 -0
- package/dist/svelte/tests/ClerkAuth.svelte.test.d.ts.map +1 -0
- package/dist/svelte/tests/ClerkAuth.svelte.test.js +202 -0
- package/dist/svelte/tests/TestClerkAuthWrapper.svelte +16 -0
- package/dist/svelte/tests/TestClerkAuthWrapper.svelte.d.ts +8 -0
- package/dist/svelte/tests/TestClerkAuthWrapper.svelte.d.ts.map +1 -0
- package/dist/svelte/tests/testUtils.d.ts +1 -0
- package/dist/svelte/tests/testUtils.d.ts.map +1 -1
- package/dist/svelte/tests/testUtils.js +3 -1
- package/dist/testing.js +1 -1
- package/dist/tools/auth/clerk/index.d.ts +1 -1
- package/dist/tools/auth/clerk/types.d.ts +1 -1
- package/dist/tools/auth/clerk/types.d.ts.map +1 -1
- package/dist/tools/coValues/account.d.ts +5 -1
- package/dist/tools/coValues/account.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +30 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
- package/dist/tools/subscribe/types.d.ts +1 -1
- package/dist/tools/subscribe/types.d.ts.map +1 -1
- package/dist/tools/testing.d.ts.map +1 -1
- package/package.json +8 -4
- package/src/better-auth/auth/client.ts +3 -1
- package/src/better-auth/auth/server.ts +9 -7
- package/src/better-auth/auth/tests/client.test.ts +66 -2
- package/src/better-auth/database-adapter/repository/generic.ts +3 -3
- package/src/better-auth/database-adapter/repository/session.ts +2 -2
- package/src/better-auth/database-adapter/schema.ts +5 -5
- package/src/react/hooks.tsx +4 -2
- package/src/react-core/hooks.ts +332 -178
- package/src/react-core/tests/useCoState.selector.test.ts +309 -22
- package/src/react-core/tests/useCoStates.test.tsx +414 -0
- package/src/react-native-core/auth/PasskeyAuth.ts +316 -0
- package/src/react-native-core/auth/PasskeyAuthBasicUI.tsx +284 -0
- package/src/react-native-core/auth/auth.ts +3 -0
- package/src/react-native-core/auth/passkey-utils.ts +47 -0
- package/src/react-native-core/auth/usePasskeyAuth.tsx +85 -0
- package/src/react-native-core/hooks.tsx +2 -0
- package/src/react-native-core/tests/PasskeyAuth.test.ts +463 -0
- package/src/react-native-core/tests/passkey-utils.test.ts +144 -0
- package/src/svelte/auth/ClerkAuth.svelte.ts +67 -0
- package/src/svelte/auth/JazzSvelteProviderWithClerk.svelte +156 -0
- package/src/svelte/auth/RegisterClerkAuth.svelte +27 -0
- package/src/svelte/auth/index.ts +2 -0
- package/src/svelte/tests/ClerkAuth.svelte.test.ts +305 -0
- package/src/svelte/tests/TestClerkAuthWrapper.svelte +16 -0
- package/src/svelte/tests/testUtils.ts +4 -1
- package/src/tools/auth/clerk/types.ts +1 -1
- package/src/tools/coValues/account.ts +11 -3
- package/src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts +27 -1
- package/src/tools/subscribe/types.ts +1 -1
- package/src/tools/tests/account.test.ts +2 -1
- package/src/tools/tests/inbox.test.ts +7 -7
- package/testSetup.ts +4 -0
- package/vitest.config.ts +1 -0
- package/dist/chunk-PEHQ7TN2.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createAuthClient } from "better-auth/client";
|
|
2
|
-
import
|
|
2
|
+
import { Account, AuthSecretStorage } from "jazz-tools";
|
|
3
3
|
import {
|
|
4
4
|
TestJazzContextManager,
|
|
5
5
|
createJazzTestAccount,
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
import { assert, beforeEach, describe, expect, it, vi } from "vitest";
|
|
10
10
|
import { jazzPluginClient } from "../client.js";
|
|
11
11
|
import { emailOTPClient, genericOAuthClient } from "better-auth/client/plugins";
|
|
12
|
-
|
|
13
12
|
describe("Better-Auth client plugin", () => {
|
|
14
13
|
let account: Account;
|
|
15
14
|
let jazzContextManager: TestJazzContextManager<Account>;
|
|
@@ -155,6 +154,71 @@ describe("Better-Auth client plugin", () => {
|
|
|
155
154
|
});
|
|
156
155
|
});
|
|
157
156
|
|
|
157
|
+
it("should preserve secretSeed over signup", async () => {
|
|
158
|
+
const secretSeed = new Uint8Array([1, 2, 3]);
|
|
159
|
+
await authSecretStorage.set({
|
|
160
|
+
accountID: account.$jazz.id,
|
|
161
|
+
secretSeed: secretSeed,
|
|
162
|
+
accountSecret: account.$jazz.localNode.getCurrentAgent().agentSecret,
|
|
163
|
+
provider: "test",
|
|
164
|
+
});
|
|
165
|
+
const credentials = await authSecretStorage.get();
|
|
166
|
+
assert(credentials, "Jazz credentials are not available");
|
|
167
|
+
expect(credentials.secretSeed).toBeInstanceOf(Uint8Array);
|
|
168
|
+
|
|
169
|
+
customFetchImpl.mockResolvedValue(
|
|
170
|
+
new Response(
|
|
171
|
+
JSON.stringify({
|
|
172
|
+
token: "6diDScDDcLJLl3sxAEestZz63mrw9Azy",
|
|
173
|
+
user: {
|
|
174
|
+
id: "S6SDKApdnh746gUnP3zujzsEY53tjuTm",
|
|
175
|
+
email: "test@jazz.dev",
|
|
176
|
+
name: "Matteo",
|
|
177
|
+
image: null,
|
|
178
|
+
emailVerified: false,
|
|
179
|
+
createdAt: new Date(),
|
|
180
|
+
updatedAt: new Date(),
|
|
181
|
+
},
|
|
182
|
+
jazzAuth: {
|
|
183
|
+
accountID: credentials.accountID,
|
|
184
|
+
secretSeed: credentials.secretSeed,
|
|
185
|
+
accountSecret: credentials.accountSecret,
|
|
186
|
+
},
|
|
187
|
+
}),
|
|
188
|
+
),
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
// Sign up
|
|
192
|
+
await authClient.signUp.email({
|
|
193
|
+
email: "test@jazz.dev",
|
|
194
|
+
password: "12345678",
|
|
195
|
+
name: "Matteo",
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
expect(customFetchImpl).toHaveBeenCalledTimes(1);
|
|
199
|
+
expect(customFetchImpl.mock.calls[0]![0].toString()).toBe(
|
|
200
|
+
"http://localhost:3000/api/auth/sign-up/email",
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
// Verify the credentials have been injected in the request body
|
|
204
|
+
expect(
|
|
205
|
+
customFetchImpl.mock.calls[0]![1].headers.get("x-jazz-auth")!,
|
|
206
|
+
).toEqual(
|
|
207
|
+
JSON.stringify({
|
|
208
|
+
accountID: credentials!.accountID,
|
|
209
|
+
secretSeed: Array.from(credentials.secretSeed!),
|
|
210
|
+
accountSecret: credentials!.accountSecret,
|
|
211
|
+
}),
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
expect(authSecretStorage.isAuthenticated).toBe(true);
|
|
215
|
+
|
|
216
|
+
// Verify the profile name has been updated
|
|
217
|
+
const context = jazzContextManager.getCurrentValue();
|
|
218
|
+
assert(context && "me" in context);
|
|
219
|
+
expect(context.me.$jazz.id).toBe(credentials!.accountID);
|
|
220
|
+
});
|
|
221
|
+
|
|
158
222
|
it("should logout from Jazz after BetterAuth sign-out", async () => {
|
|
159
223
|
const credentials = await authSecretStorage.get();
|
|
160
224
|
expect(authSecretStorage.isAuthenticated).toBe(false);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CleanedWhere } from "better-auth/adapters";
|
|
2
|
-
import {
|
|
2
|
+
import { BetterAuthDBSchema } from "better-auth/db";
|
|
3
3
|
import { Account, CoList, CoMap, Group, co } from "jazz-tools";
|
|
4
4
|
import type { Database, TableItem } from "../schema.js";
|
|
5
5
|
import {
|
|
@@ -14,7 +14,7 @@ export class JazzRepository {
|
|
|
14
14
|
protected databaseRoot: co.loaded<Database, { group: true }>;
|
|
15
15
|
protected worker: Account;
|
|
16
16
|
protected owner: Group;
|
|
17
|
-
protected betterAuthSchema:
|
|
17
|
+
protected betterAuthSchema: BetterAuthDBSchema;
|
|
18
18
|
|
|
19
19
|
private coValuesTracker:
|
|
20
20
|
| {
|
|
@@ -26,7 +26,7 @@ export class JazzRepository {
|
|
|
26
26
|
databaseSchema: Database,
|
|
27
27
|
databaseRoot: co.loaded<Database, { group: true }>,
|
|
28
28
|
worker: Account,
|
|
29
|
-
betterAuthSchema:
|
|
29
|
+
betterAuthSchema: BetterAuthDBSchema = {},
|
|
30
30
|
ensureSync: boolean = false,
|
|
31
31
|
) {
|
|
32
32
|
this.databaseSchema = databaseSchema;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BetterAuthDBSchema } from "better-auth/db";
|
|
2
2
|
import { CleanedWhere } from "better-auth/adapters";
|
|
3
3
|
import { co, Account } from "jazz-tools";
|
|
4
4
|
import { JazzRepository } from "./generic";
|
|
@@ -22,7 +22,7 @@ export class SessionRepository extends JazzRepository {
|
|
|
22
22
|
databaseSchema: Database,
|
|
23
23
|
databaseRoot: co.loaded<Database, { group: true }>,
|
|
24
24
|
worker: Account,
|
|
25
|
-
betterAuthSchema:
|
|
25
|
+
betterAuthSchema: BetterAuthDBSchema = {},
|
|
26
26
|
ensureSync: boolean = false,
|
|
27
27
|
) {
|
|
28
28
|
super(databaseSchema, databaseRoot, worker, betterAuthSchema, ensureSync);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BetterAuthDBSchema, DBFieldAttribute } from "better-auth/db";
|
|
2
2
|
import { Group, co, z } from "jazz-tools";
|
|
3
3
|
|
|
4
4
|
type TableRow = co.Map<any>;
|
|
@@ -20,7 +20,7 @@ type WorkerAccount = co.Account<{
|
|
|
20
20
|
type JazzSchema = {
|
|
21
21
|
WorkerAccount: WorkerAccount;
|
|
22
22
|
DatabaseRoot: Database;
|
|
23
|
-
betterAuthSchema:
|
|
23
|
+
betterAuthSchema: BetterAuthDBSchema;
|
|
24
24
|
loadDatabase: (
|
|
25
25
|
account: co.loaded<co.Account>,
|
|
26
26
|
options?: Parameters<Database["loadUnique"]>[2],
|
|
@@ -29,7 +29,7 @@ type JazzSchema = {
|
|
|
29
29
|
|
|
30
30
|
const DATABASE_ROOT_ID = "better-auth-root";
|
|
31
31
|
|
|
32
|
-
export function createJazzSchema(schema:
|
|
32
|
+
export function createJazzSchema(schema: BetterAuthDBSchema): JazzSchema {
|
|
33
33
|
const tablesSchema = generateSchemaFromBetterAuthSchema(schema);
|
|
34
34
|
|
|
35
35
|
const DatabaseRoot: Database = co.map({
|
|
@@ -134,7 +134,7 @@ type ZodPrimitiveSchema =
|
|
|
134
134
|
| z.z.ZodLiteral;
|
|
135
135
|
type ZodOptionalPrimitiveSchema = z.z.ZodOptional<ZodPrimitiveSchema>;
|
|
136
136
|
|
|
137
|
-
function generateSchemaFromBetterAuthSchema(schema:
|
|
137
|
+
function generateSchemaFromBetterAuthSchema(schema: BetterAuthDBSchema) {
|
|
138
138
|
const tablesSchema: Record<string, Table> = {};
|
|
139
139
|
|
|
140
140
|
for (const [key, value] of Object.entries(schema)) {
|
|
@@ -178,7 +178,7 @@ function generateSchemaFromBetterAuthSchema(schema: BetterAuthDbSchema) {
|
|
|
178
178
|
return tablesSchema;
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
function convertFieldToCoValue(field:
|
|
181
|
+
function convertFieldToCoValue(field: DBFieldAttribute) {
|
|
182
182
|
let zodType: ZodPrimitiveSchema | ZodOptionalPrimitiveSchema;
|
|
183
183
|
|
|
184
184
|
switch (field.type) {
|
package/src/react/hooks.tsx
CHANGED
|
@@ -4,8 +4,6 @@ import { useEffect } from "react";
|
|
|
4
4
|
import { CoValueClassOrSchema } from "jazz-tools";
|
|
5
5
|
import { useJazzContext } from "jazz-tools/react-core";
|
|
6
6
|
|
|
7
|
-
export { useCoState, useAuthSecretStorage } from "jazz-tools/react-core";
|
|
8
|
-
|
|
9
7
|
export function useAcceptInvite<S extends CoValueClassOrSchema>({
|
|
10
8
|
invitedObjectSchema,
|
|
11
9
|
onAccept,
|
|
@@ -49,7 +47,10 @@ export function useAcceptInvite<S extends CoValueClassOrSchema>({
|
|
|
49
47
|
export {
|
|
50
48
|
experimental_useInboxSender,
|
|
51
49
|
useJazzContext,
|
|
50
|
+
useAuthSecretStorage,
|
|
52
51
|
useAccount,
|
|
52
|
+
useCoState,
|
|
53
|
+
useCoStates,
|
|
53
54
|
useAgent,
|
|
54
55
|
useLogOut,
|
|
55
56
|
useSyncConnectionStatus,
|
|
@@ -58,4 +59,5 @@ export {
|
|
|
58
59
|
useSubscriptionSelector,
|
|
59
60
|
useSuspenseAccount,
|
|
60
61
|
useSuspenseCoState,
|
|
62
|
+
useSuspenseCoStates,
|
|
61
63
|
} from "jazz-tools/react-core";
|