jazz-tools 0.18.29 → 0.18.30
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__/media/image.svelte +7 -4
- package/.svelte-kit/__package__/media/image.svelte.d.ts.map +1 -1
- package/.svelte-kit/__package__/media/image.types.d.ts +1 -0
- package/.svelte-kit/__package__/media/image.types.d.ts.map +1 -1
- package/.svelte-kit/__package__/tests/media/image.svelte.test.js +63 -0
- package/.turbo/turbo-build.log +62 -62
- package/CHANGELOG.md +17 -0
- package/dist/better-auth/auth/client.d.ts +1 -1
- package/dist/better-auth/auth/server.d.ts +1 -1
- package/dist/better-auth/auth/server.d.ts.map +1 -1
- package/dist/better-auth/auth/server.js.map +1 -1
- package/dist/better-auth/database-adapter/index.d.ts +3 -3
- package/dist/better-auth/database-adapter/index.d.ts.map +1 -1
- package/dist/better-auth/database-adapter/index.js +6 -2
- package/dist/better-auth/database-adapter/index.js.map +1 -1
- package/dist/better-auth/database-adapter/utils.d.ts.map +1 -1
- package/dist/browser/index.d.ts +2 -1
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/{chunk-F55R554M.js → chunk-6BIYT3KH.js} +51 -30
- package/dist/chunk-6BIYT3KH.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/inspector/{custom-element-35MDW4SW.js → custom-element-RQTLPAPJ.js} +584 -298
- package/dist/inspector/custom-element-RQTLPAPJ.js.map +1 -0
- package/dist/inspector/index.js +570 -338
- package/dist/inspector/index.js.map +1 -1
- package/dist/inspector/register-custom-element.js +1 -1
- package/dist/inspector/ui/index.d.ts +6 -0
- package/dist/inspector/ui/index.d.ts.map +1 -0
- package/dist/inspector/viewer/group-view.d.ts +3 -2
- package/dist/inspector/viewer/group-view.d.ts.map +1 -1
- package/dist/inspector/viewer/page.d.ts.map +1 -1
- package/dist/react/index.js +2 -2
- package/dist/react/index.js.map +1 -1
- package/dist/react/media/image.d.ts +8 -0
- package/dist/react/media/image.d.ts.map +1 -1
- package/dist/react-native-core/index.js +3 -3
- package/dist/react-native-core/index.js.map +1 -1
- package/dist/react-native-core/media/image.d.ts +15 -0
- package/dist/react-native-core/media/image.d.ts.map +1 -1
- package/dist/svelte/media/image.svelte +7 -4
- package/dist/svelte/media/image.svelte.d.ts.map +1 -1
- package/dist/svelte/media/image.types.d.ts +1 -0
- package/dist/svelte/media/image.types.d.ts.map +1 -1
- package/dist/svelte/tests/media/image.svelte.test.js +63 -0
- package/dist/testing.js +8 -1
- package/dist/testing.js.map +1 -1
- package/dist/tools/coValues/account.d.ts +1 -0
- package/dist/tools/coValues/account.d.ts.map +1 -1
- package/dist/tools/coValues/group.d.ts +3 -3
- package/dist/tools/coValues/group.d.ts.map +1 -1
- package/dist/tools/implementation/invites.d.ts +2 -2
- package/dist/tools/implementation/invites.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/runtimeConverters/schemaFieldToCoFieldDef.d.ts +1 -1
- package/dist/tools/implementation/zodSchema/runtimeConverters/schemaFieldToCoFieldDef.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/TypeOfZodSchema.d.ts +3 -1
- package/dist/tools/implementation/zodSchema/typeConverters/TypeOfZodSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/zodReExport.d.ts +1 -1
- package/dist/tools/implementation/zodSchema/zodReExport.d.ts.map +1 -1
- package/dist/tools/subscribe/CoValueCoreSubscription.d.ts.map +1 -1
- package/dist/tools/subscribe/SubscriptionScope.d.ts +0 -2
- package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
- package/dist/tools/testing.d.ts +1 -0
- package/dist/tools/testing.d.ts.map +1 -1
- package/dist/tools/tests/CoValueCoreSubscription.test.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/better-auth/auth/server.ts +7 -2
- package/src/better-auth/auth/tests/server.test.ts +39 -17
- package/src/better-auth/database-adapter/index.ts +8 -5
- package/src/better-auth/database-adapter/utils.ts +4 -0
- package/src/browser/index.ts +2 -1
- package/src/inspector/ui/index.ts +5 -0
- package/src/inspector/viewer/group-view.tsx +304 -20
- package/src/inspector/viewer/new-app.tsx +4 -4
- package/src/inspector/viewer/page.tsx +16 -2
- package/src/react/media/image.tsx +11 -2
- package/src/react/tests/media/image.test.tsx +94 -0
- package/src/react-native-core/media/image.tsx +11 -3
- package/src/svelte/media/image.svelte +7 -4
- package/src/svelte/media/image.types.ts +1 -0
- package/src/svelte/tests/media/image.svelte.test.ts +85 -0
- package/src/tools/coValues/account.ts +30 -5
- package/src/tools/coValues/group.ts +13 -12
- package/src/tools/coValues/inbox.ts +5 -5
- package/src/tools/implementation/invites.ts +3 -8
- package/src/tools/implementation/zodSchema/runtimeConverters/schemaFieldToCoFieldDef.ts +5 -1
- package/src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts +2 -0
- package/src/tools/implementation/zodSchema/typeConverters/TypeOfZodSchema.ts +63 -50
- package/src/tools/implementation/zodSchema/zodReExport.ts +2 -2
- package/src/tools/subscribe/CoValueCoreSubscription.ts +17 -0
- package/src/tools/subscribe/SubscriptionScope.ts +1 -27
- package/src/tools/testing.ts +7 -0
- package/src/tools/{subscribe → tests}/CoValueCoreSubscription.test.ts +233 -3
- package/src/tools/tests/coFeed.branch.test.ts +14 -5
- package/src/tools/tests/coMap.test.ts +139 -42
- package/src/tools/tests/coOptional.test.ts +9 -1
- package/src/tools/tests/groupsAndAccounts.test.ts +156 -1
- package/src/tools/tests/load.test.ts +198 -1
- package/src/tools/tests/zod.test-d.ts +0 -2
- package/src/tools/tests/zod.test.ts +43 -40
- package/dist/chunk-F55R554M.js.map +0 -1
- package/dist/inspector/custom-element-35MDW4SW.js.map +0 -1
- package/dist/tools/subscribe/CoValueCoreSubscription.test.d.ts.map +0 -1
- /package/dist/tools/{subscribe → tests}/CoValueCoreSubscription.test.d.ts +0 -0
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { CoState } from "../jazz.class.svelte";
|
|
6
6
|
import type { ImageProps } from "./image.types.js";
|
|
7
7
|
|
|
8
|
-
const { imageId, width, height, ...rest }: ImageProps = $props();
|
|
8
|
+
const { imageId, width, height, placeholder, ...rest }: ImageProps = $props();
|
|
9
9
|
|
|
10
10
|
const imageState = new CoState(ImageDefinition, () => imageId);
|
|
11
11
|
let lastBestImage: [string, string] | null = null;
|
|
@@ -69,7 +69,10 @@
|
|
|
69
69
|
|
|
70
70
|
const image = imageState.current;
|
|
71
71
|
if (image === undefined)
|
|
72
|
-
return
|
|
72
|
+
return (
|
|
73
|
+
placeholder ??
|
|
74
|
+
"data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
|
|
75
|
+
);
|
|
73
76
|
|
|
74
77
|
if (!image) return undefined;
|
|
75
78
|
|
|
@@ -79,7 +82,7 @@
|
|
|
79
82
|
dimensions.height || dimensions.width || 9999,
|
|
80
83
|
);
|
|
81
84
|
|
|
82
|
-
if (!bestImage) return image.placeholderDataURL;
|
|
85
|
+
if (!bestImage) return image.placeholderDataURL ?? placeholder;
|
|
83
86
|
if (lastBestImage?.[0] === bestImage.image.$jazz.id)
|
|
84
87
|
return lastBestImage?.[1];
|
|
85
88
|
|
|
@@ -92,7 +95,7 @@
|
|
|
92
95
|
return url;
|
|
93
96
|
}
|
|
94
97
|
|
|
95
|
-
return image.placeholderDataURL;
|
|
98
|
+
return image.placeholderDataURL ?? placeholder;
|
|
96
99
|
});
|
|
97
100
|
|
|
98
101
|
// Cleanup object URL on component destroy
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.svelte.d.ts","sourceRoot":"","sources":["../../../../src/svelte/media/image.svelte.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"image.svelte.d.ts","sourceRoot":"","sources":["../../../../src/svelte/media/image.svelte.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAoInD,QAAA,MAAM,KAAK,gDAAsC,CAAC;AAClD,KAAK,KAAK,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;AACtC,eAAe,KAAK,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.types.d.ts","sourceRoot":"","sources":["../../../../src/svelte/media/image.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,iBAAiB,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC7E,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"image.types.d.ts","sourceRoot":"","sources":["../../../../src/svelte/media/image.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,iBAAiB,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC7E,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -79,6 +79,69 @@ describe("Image", async () => {
|
|
|
79
79
|
expect(img).toBeDefined();
|
|
80
80
|
expect(img.src).toBe(placeholderDataUrl);
|
|
81
81
|
});
|
|
82
|
+
it("should not override actual placeholders", async () => {
|
|
83
|
+
const placeholderDataUrl = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=";
|
|
84
|
+
const customPlaceholder = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJsdWNpZGUgbHVjaWRlLXVzZXItaWNvbiBsdWNpZGUtdXNlciI+PHBhdGggZD0iTTE5IDIxdi0yYTQgNCAwIDAgMC00LTRIOWE0IDQgMCAwIDAtNCA0djIiLz48Y2lyY2xlIGN4PSIxMiIgY3k9IjciIHI9IjQiLz48L3N2Zz4=";
|
|
85
|
+
const original = FileStream.create({ owner: account });
|
|
86
|
+
original.start({ mimeType: "image/jpeg" });
|
|
87
|
+
// Don't end original, so it has no chunks
|
|
88
|
+
const im = ImageDefinition.create({
|
|
89
|
+
original,
|
|
90
|
+
originalSize: [100, 100],
|
|
91
|
+
progressive: false,
|
|
92
|
+
placeholderDataURL: placeholderDataUrl,
|
|
93
|
+
}, {
|
|
94
|
+
owner: account,
|
|
95
|
+
});
|
|
96
|
+
const { container } = renderWithAccount({
|
|
97
|
+
imageId: im.$jazz.id,
|
|
98
|
+
alt: "test",
|
|
99
|
+
placeholder: customPlaceholder
|
|
100
|
+
});
|
|
101
|
+
const img = container.querySelector("img");
|
|
102
|
+
expect(img).toBeDefined();
|
|
103
|
+
expect(img.src).toBe(placeholderDataUrl);
|
|
104
|
+
});
|
|
105
|
+
it("should show custom placeholder while loading and replace with loaded image", async () => {
|
|
106
|
+
const createObjectURLSpy = vi
|
|
107
|
+
.spyOn(URL, "createObjectURL")
|
|
108
|
+
.mockImplementation((blob) => {
|
|
109
|
+
if (!(blob instanceof Blob)) {
|
|
110
|
+
throw new Error("Blob expected");
|
|
111
|
+
}
|
|
112
|
+
return `blob:test-${blob.size}`;
|
|
113
|
+
});
|
|
114
|
+
const customPlaceholder = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJsdWNpZGUgbHVjaWRlLXVzZXItaWNvbiBsdWNpZGUtdXNlciI+PHBhdGggZD0iTTE5IDIxdi0yYTQgNCAwIDAgMC00LTRIOWE0IDQgMCAwIDAtNCA0djIiLz48Y2lyY2xlIGN4PSIxMiIgY3k9IjciIHI9IjQiLz48L3N2Zz4=";
|
|
115
|
+
// Create an image with no chunks initially (loading state)
|
|
116
|
+
const original = FileStream.create({ owner: account });
|
|
117
|
+
original.start({ mimeType: "image/jpeg" });
|
|
118
|
+
// Don't end original, so it has no chunks
|
|
119
|
+
const im = ImageDefinition.create({
|
|
120
|
+
original,
|
|
121
|
+
originalSize: [100, 100],
|
|
122
|
+
progressive: false,
|
|
123
|
+
}, {
|
|
124
|
+
owner: account,
|
|
125
|
+
});
|
|
126
|
+
const { container } = renderWithAccount({
|
|
127
|
+
imageId: im.$jazz.id,
|
|
128
|
+
alt: "test-loading-custom-placeholder",
|
|
129
|
+
placeholder: customPlaceholder
|
|
130
|
+
});
|
|
131
|
+
// Initially should show custom placeholder
|
|
132
|
+
let img = container.querySelector("img");
|
|
133
|
+
expect(img).toBeDefined();
|
|
134
|
+
expect(img.src).toBe(customPlaceholder);
|
|
135
|
+
// Now add the actual image data
|
|
136
|
+
const imageData = await createDummyFileStream(100, account);
|
|
137
|
+
im.$jazz.set("100x100", imageData);
|
|
138
|
+
// Wait for the image to load and replace the placeholder
|
|
139
|
+
await waitFor(() => {
|
|
140
|
+
img = container.querySelector("img");
|
|
141
|
+
expect(img.src).toBe("blob:test-100");
|
|
142
|
+
});
|
|
143
|
+
expect(createObjectURLSpy).toHaveBeenCalledTimes(1);
|
|
144
|
+
});
|
|
82
145
|
it("should render the original image once loaded", async () => {
|
|
83
146
|
const createObjectURLSpy = vi
|
|
84
147
|
.spyOn(URL, "createObjectURL")
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> jazz-tools@0.18.
|
|
2
|
+
> jazz-tools@0.18.30 build /home/runner/_work/jazz/jazz/packages/jazz-tools
|
|
3
3
|
> tsup && pnpm types && pnpm build:svelte
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: {"index":"src/index.ts","testing":"src/testing.ts","tools/ssr":"src/tools/ssr/index.ts"}
|
|
@@ -107,105 +107,105 @@
|
|
|
107
107
|
[34mESM[39m Build start
|
|
108
108
|
[34mCLI[39m Cleaning output folder
|
|
109
109
|
[34mESM[39m Build start
|
|
110
|
+
[32mESM[39m [1mdist/tiptap/index.js [22m[32m564.00 B[39m
|
|
111
|
+
[32mESM[39m [1mdist/tiptap/index.js.map [22m[32m1.21 KB[39m
|
|
112
|
+
[32mESM[39m ⚡️ Build success in 38ms
|
|
110
113
|
[32mESM[39m [1mdist/worker/index.js [22m[32m3.16 KB[39m
|
|
111
|
-
[32mESM[39m [1mdist/worker/edge-wasm.js [22m[32m215.00 B[39m
|
|
112
114
|
[32mESM[39m [1mdist/worker/napi-crypto.js [22m[32m110.00 B[39m
|
|
113
|
-
[32mESM[39m [1mdist/worker/edge-wasm.js
|
|
115
|
+
[32mESM[39m [1mdist/worker/edge-wasm.js [22m[32m215.00 B[39m
|
|
114
116
|
[32mESM[39m [1mdist/worker/index.js.map [22m[32m6.14 KB[39m
|
|
115
117
|
[32mESM[39m [1mdist/worker/napi-crypto.js.map [22m[32m162.00 B[39m
|
|
116
|
-
[32mESM[39m
|
|
117
|
-
[32mESM[39m
|
|
118
|
-
[32mESM[39m [1mdist/tiptap/index.js.map [22m[32m1.21 KB[39m
|
|
119
|
-
[32mESM[39m ⚡️ Build success in 39ms
|
|
120
|
-
[32mESM[39m [1mdist/better-auth/auth/server.js [22m[32m8.36 KB[39m
|
|
121
|
-
[32mESM[39m [1mdist/better-auth/auth/react.js [22m[32m799.00 B[39m
|
|
122
|
-
[32mESM[39m [1mdist/better-auth/auth/client.js [22m[32m4.50 KB[39m
|
|
123
|
-
[32mESM[39m [1mdist/better-auth/auth/server.js.map [22m[32m15.29 KB[39m
|
|
124
|
-
[32mESM[39m [1mdist/better-auth/auth/react.js.map [22m[32m2.04 KB[39m
|
|
125
|
-
[32mESM[39m [1mdist/better-auth/auth/client.js.map [22m[32m8.32 KB[39m
|
|
126
|
-
[32mESM[39m ⚡️ Build success in 35ms
|
|
118
|
+
[32mESM[39m [1mdist/worker/edge-wasm.js.map [22m[32m434.00 B[39m
|
|
119
|
+
[32mESM[39m ⚡️ Build success in 37ms
|
|
127
120
|
[32mESM[39m [1mdist/media/index.js [22m[32m236.00 B[39m
|
|
128
|
-
[32mESM[39m [1mdist/media/index.browser.js [22m[32m2.79 KB[39m
|
|
129
121
|
[32mESM[39m [1mdist/media/index.native.js [22m[32m4.01 KB[39m
|
|
130
|
-
[32mESM[39m [1mdist/media/index.
|
|
122
|
+
[32mESM[39m [1mdist/media/index.browser.js [22m[32m2.79 KB[39m
|
|
131
123
|
[32mESM[39m [1mdist/media/chunk-K6GCHLQU.js [22m[32m6.47 KB[39m
|
|
124
|
+
[32mESM[39m [1mdist/media/index.server.js [22m[32m2.95 KB[39m
|
|
125
|
+
[32mESM[39m [1mdist/media/index.native.js.map [22m[32m8.10 KB[39m
|
|
132
126
|
[32mESM[39m [1mdist/media/index.js.map [22m[32m71.00 B[39m
|
|
133
127
|
[32mESM[39m [1mdist/media/index.browser.js.map [22m[32m6.15 KB[39m
|
|
134
|
-
[32mESM[39m [1mdist/media/index.native.js.map [22m[32m8.10 KB[39m
|
|
135
|
-
[32mESM[39m [1mdist/media/index.server.js.map [22m[32m6.37 KB[39m
|
|
136
128
|
[32mESM[39m [1mdist/media/chunk-K6GCHLQU.js.map [22m[32m16.64 KB[39m
|
|
129
|
+
[32mESM[39m [1mdist/media/index.server.js.map [22m[32m6.37 KB[39m
|
|
137
130
|
[32mESM[39m ⚡️ Build success in 42ms
|
|
131
|
+
[32mESM[39m [1mdist/better-auth/auth/client.js [22m[32m4.50 KB[39m
|
|
132
|
+
[32mESM[39m [1mdist/better-auth/auth/react.js [22m[32m799.00 B[39m
|
|
133
|
+
[32mESM[39m [1mdist/better-auth/auth/server.js [22m[32m8.36 KB[39m
|
|
134
|
+
[32mESM[39m [1mdist/better-auth/auth/client.js.map [22m[32m8.32 KB[39m
|
|
135
|
+
[32mESM[39m [1mdist/better-auth/auth/react.js.map [22m[32m2.04 KB[39m
|
|
136
|
+
[32mESM[39m [1mdist/better-auth/auth/server.js.map [22m[32m15.31 KB[39m
|
|
137
|
+
[32mESM[39m ⚡️ Build success in 36ms
|
|
138
138
|
[32mESM[39m [1mdist/react-native/index.js [22m[32m2.53 KB[39m
|
|
139
|
-
[32mESM[39m [1mdist/react-native/testing.js [22m[32m120.00 B[39m
|
|
140
139
|
[32mESM[39m [1mdist/react-native/crypto.js [22m[32m161.00 B[39m
|
|
141
|
-
[32mESM[39m [1mdist/react-native/testing.js
|
|
140
|
+
[32mESM[39m [1mdist/react-native/testing.js [22m[32m120.00 B[39m
|
|
142
141
|
[32mESM[39m [1mdist/react-native/index.js.map [22m[32m5.68 KB[39m
|
|
143
142
|
[32mESM[39m [1mdist/react-native/crypto.js.map [22m[32m197.00 B[39m
|
|
144
|
-
[32mESM[39m
|
|
145
|
-
[32mESM[39m
|
|
146
|
-
[32mESM[39m [1mdist/expo/testing.js [22m[32m112.00 B[39m
|
|
147
|
-
[32mESM[39m [1mdist/expo/crypto.js [22m[32m153.00 B[39m
|
|
148
|
-
[32mESM[39m [1mdist/expo/index.js.map [22m[32m10.23 KB[39m
|
|
149
|
-
[32mESM[39m [1mdist/expo/testing.js.map [22m[32m168.00 B[39m
|
|
150
|
-
[32mESM[39m [1mdist/expo/crypto.js.map [22m[32m189.00 B[39m
|
|
151
|
-
[32mESM[39m ⚡️ Build success in 44ms
|
|
152
|
-
[32mESM[39m [1mdist/react-core/index.js [22m[32m14.06 KB[39m
|
|
143
|
+
[32mESM[39m [1mdist/react-native/testing.js.map [22m[32m176.00 B[39m
|
|
144
|
+
[32mESM[39m ⚡️ Build success in 41ms
|
|
153
145
|
[32mESM[39m [1mdist/react-core/testing.js [22m[32m1.22 KB[39m
|
|
146
|
+
[32mESM[39m [1mdist/react-core/index.js [22m[32m14.06 KB[39m
|
|
154
147
|
[32mESM[39m [1mdist/react-core/chunk-7DYMJ74I.js [22m[32m279.00 B[39m
|
|
155
|
-
[32mESM[39m [1mdist/react-core/index.js.map [22m[32m42.79 KB[39m
|
|
156
148
|
[32mESM[39m [1mdist/react-core/testing.js.map [22m[32m1.86 KB[39m
|
|
157
149
|
[32mESM[39m [1mdist/react-core/chunk-7DYMJ74I.js.map [22m[32m533.00 B[39m
|
|
158
|
-
[32mESM[39m
|
|
150
|
+
[32mESM[39m [1mdist/react-core/index.js.map [22m[32m42.79 KB[39m
|
|
151
|
+
[32mESM[39m ⚡️ Build success in 39ms
|
|
159
152
|
[32mESM[39m [1mdist/browser/index.js [22m[32m14.06 KB[39m
|
|
160
153
|
[32mESM[39m [1mdist/browser/index.js.map [22m[32m29.94 KB[39m
|
|
161
|
-
[32mESM[39m ⚡️ Build success in 58ms
|
|
162
|
-
[32mESM[39m [1mdist/better-auth/database-adapter/index.js [22m[32m26.34 KB[39m
|
|
163
|
-
[32mESM[39m [1mdist/better-auth/database-adapter/index.js.map [22m[32m57.62 KB[39m
|
|
164
154
|
[32mESM[39m ⚡️ Build success in 53ms
|
|
165
|
-
[32mESM[39m [1mdist/
|
|
166
|
-
[32mESM[39m [1mdist/
|
|
167
|
-
[32mESM[39m
|
|
168
|
-
[32mESM[39m [1mdist/
|
|
155
|
+
[32mESM[39m [1mdist/expo/index.js [22m[32m4.68 KB[39m
|
|
156
|
+
[32mESM[39m [1mdist/expo/testing.js [22m[32m112.00 B[39m
|
|
157
|
+
[32mESM[39m [1mdist/expo/crypto.js [22m[32m153.00 B[39m
|
|
158
|
+
[32mESM[39m [1mdist/expo/index.js.map [22m[32m10.23 KB[39m
|
|
159
|
+
[32mESM[39m [1mdist/expo/testing.js.map [22m[32m168.00 B[39m
|
|
160
|
+
[32mESM[39m [1mdist/expo/crypto.js.map [22m[32m189.00 B[39m
|
|
161
|
+
[32mESM[39m ⚡️ Build success in 44ms
|
|
162
|
+
[32mESM[39m [1mdist/react-native-core/index.js [22m[32m18.96 KB[39m
|
|
169
163
|
[32mESM[39m [1mdist/react-native-core/crypto.js [22m[32m2.10 KB[39m
|
|
170
164
|
[32mESM[39m [1mdist/react-native-core/testing.js [22m[32m119.00 B[39m
|
|
165
|
+
[32mESM[39m [1mdist/react-native-core/index.js.map [22m[32m38.49 KB[39m
|
|
171
166
|
[32mESM[39m [1mdist/react-native-core/crypto.js.map [22m[32m4.25 KB[39m
|
|
172
167
|
[32mESM[39m [1mdist/react-native-core/testing.js.map [22m[32m175.00 B[39m
|
|
173
|
-
[32mESM[39m
|
|
174
|
-
[32mESM[39m
|
|
175
|
-
[32mESM[39m [1mdist/
|
|
176
|
-
[32mESM[39m
|
|
168
|
+
[32mESM[39m ⚡️ Build success in 51ms
|
|
169
|
+
[32mESM[39m [1mdist/prosemirror/index.js [22m[32m77.76 KB[39m
|
|
170
|
+
[32mESM[39m [1mdist/prosemirror/index.js.map [22m[32m307.20 KB[39m
|
|
171
|
+
[32mESM[39m ⚡️ Build success in 56ms
|
|
172
|
+
[32mESM[39m [1mdist/better-auth/database-adapter/index.js [22m[32m26.44 KB[39m
|
|
173
|
+
[32mESM[39m [1mdist/better-auth/database-adapter/index.js.map [22m[32m57.91 KB[39m
|
|
174
|
+
[32mESM[39m ⚡️ Build success in 44ms
|
|
177
175
|
[32mESM[39m [1mdist/react/ssr.js [22m[32m697.00 B[39m
|
|
178
|
-
[32mESM[39m [1mdist/react/index.js
|
|
179
|
-
[32mESM[39m [1mdist/react/testing.js
|
|
176
|
+
[32mESM[39m [1mdist/react/index.js [22m[32m25.36 KB[39m
|
|
177
|
+
[32mESM[39m [1mdist/react/testing.js [22m[32m122.00 B[39m
|
|
180
178
|
[32mESM[39m [1mdist/react/ssr.js.map [22m[32m1.11 KB[39m
|
|
181
|
-
[32mESM[39m
|
|
182
|
-
[32mESM[39m [1mdist/
|
|
183
|
-
[32mESM[39m
|
|
184
|
-
[32mESM[39m
|
|
179
|
+
[32mESM[39m [1mdist/react/testing.js.map [22m[32m165.00 B[39m
|
|
180
|
+
[32mESM[39m [1mdist/react/index.js.map [22m[32m54.73 KB[39m
|
|
181
|
+
[32mESM[39m ⚡️ Build success in 51ms
|
|
182
|
+
[32mESM[39m [1mdist/inspector/index.js [22m[32m79.98 KB[39m
|
|
183
|
+
[32mESM[39m [1mdist/inspector/index.js.map [22m[32m138.43 KB[39m
|
|
184
|
+
[32mESM[39m ⚡️ Build success in 62ms
|
|
185
185
|
[32mESM[39m [1mdist/index.js [22m[32m28.82 KB[39m
|
|
186
|
-
[32mESM[39m [1mdist/testing.js [22m[32m8.32 KB[39m
|
|
187
|
-
[32mESM[39m [1mdist/chunk-M2HGBOXS.js [22m[32m694.00 B[39m
|
|
188
186
|
[32mESM[39m [1mdist/tools/ssr.js [22m[32m156.00 B[39m
|
|
189
187
|
[32mESM[39m [1mdist/chunk-PZ5AY32C.js [22m[32m233.00 B[39m
|
|
190
|
-
[32mESM[39m [1mdist/chunk-
|
|
191
|
-
[32mESM[39m [1mdist/testing.js
|
|
192
|
-
[32mESM[39m [1mdist/chunk-
|
|
193
|
-
[32mESM[39m [1mdist/
|
|
194
|
-
[32mESM[39m [1mdist/index.js.map [22m[32m59.94 KB[39m
|
|
188
|
+
[32mESM[39m [1mdist/chunk-M2HGBOXS.js [22m[32m694.00 B[39m
|
|
189
|
+
[32mESM[39m [1mdist/testing.js [22m[32m8.48 KB[39m
|
|
190
|
+
[32mESM[39m [1mdist/chunk-6BIYT3KH.js [22m[32m191.07 KB[39m
|
|
191
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m59.88 KB[39m
|
|
195
192
|
[32mESM[39m [1mdist/chunk-PZ5AY32C.js.map [22m[32m71.00 B[39m
|
|
196
|
-
[32mESM[39m [1mdist/
|
|
197
|
-
[32mESM[39m
|
|
193
|
+
[32mESM[39m [1mdist/tools/ssr.js.map [22m[32m71.00 B[39m
|
|
194
|
+
[32mESM[39m [1mdist/chunk-M2HGBOXS.js.map [22m[32m1.10 KB[39m
|
|
195
|
+
[32mESM[39m [1mdist/testing.js.map [22m[32m16.07 KB[39m
|
|
196
|
+
[32mESM[39m [1mdist/chunk-6BIYT3KH.js.map [22m[32m452.42 KB[39m
|
|
197
|
+
[32mESM[39m ⚡️ Build success in 70ms
|
|
198
198
|
[32mESM[39m [1mdist/inspector/register-custom-element.js [22m[32m218.00 B[39m
|
|
199
199
|
[32mESM[39m [1mdist/inspector/register-custom-element.js.map [22m[32m314.00 B[39m
|
|
200
|
-
[32mESM[39m [1mdist/inspector/custom-element-
|
|
201
|
-
[32mESM[39m [1mdist/inspector/custom-element-
|
|
202
|
-
[32mESM[39m ⚡️ Build success in
|
|
200
|
+
[32mESM[39m [1mdist/inspector/custom-element-RQTLPAPJ.js [22m[32m1.55 MB[39m
|
|
201
|
+
[32mESM[39m [1mdist/inspector/custom-element-RQTLPAPJ.js.map [22m[32m2.38 MB[39m
|
|
202
|
+
[32mESM[39m ⚡️ Build success in 121ms
|
|
203
203
|
|
|
204
|
-
> jazz-tools@0.18.
|
|
204
|
+
> jazz-tools@0.18.30 types /home/runner/_work/jazz/jazz/packages/jazz-tools
|
|
205
205
|
> tsc --outDir dist
|
|
206
206
|
|
|
207
207
|
|
|
208
|
-
> jazz-tools@0.18.
|
|
208
|
+
> jazz-tools@0.18.30 build:svelte /home/runner/_work/jazz/jazz/packages/jazz-tools
|
|
209
209
|
> rm -rf dist/svelte && svelte-package -i src/svelte -o dist/svelte --tsconfig tsconfig.svelte.json
|
|
210
210
|
|
|
211
211
|
src/svelte -> dist/svelte
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# jazz-tools
|
|
2
2
|
|
|
3
|
+
## 0.18.30
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b3dbcaa: feat: inspector's group view now shows parents/children groups, with addMember/removeMember features
|
|
8
|
+
- 75d452e: Allow users to specify custom placeholders to be used while images are loading
|
|
9
|
+
- 346c5fb: Add `.optional()` method to Account schema
|
|
10
|
+
- 354895b: Wait for the full download of groups on load and subscribe
|
|
11
|
+
- 162757c: Export `z.record` and `z.intersection` as part of jazz-tools
|
|
12
|
+
- d08b7e2: feat: introduced new "manager" role who can invite and remove members, and being removed by admins.
|
|
13
|
+
- ad19280: fix: visual bug on "delete my local data" button in inspector on mobile viewports
|
|
14
|
+
- Updated dependencies [ad83da2]
|
|
15
|
+
- Updated dependencies [d08b7e2]
|
|
16
|
+
- cojson@0.18.30
|
|
17
|
+
- cojson-storage-indexeddb@0.18.30
|
|
18
|
+
- cojson-transport-ws@0.18.30
|
|
19
|
+
|
|
3
20
|
## 0.18.29
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -11,7 +11,7 @@ import type { jazzPlugin } from "./server.js";
|
|
|
11
11
|
export declare const jazzPluginClient: () => {
|
|
12
12
|
id: "jazz-plugin";
|
|
13
13
|
$InferServerPlugin: ReturnType<typeof jazzPlugin>;
|
|
14
|
-
getActions: ($fetch: import("@better-fetch/fetch").BetterFetch, $store: import("better-auth").
|
|
14
|
+
getActions: ($fetch: import("@better-fetch/fetch").BetterFetch, $store: import("better-auth").ClientStore) => {
|
|
15
15
|
jazz: {
|
|
16
16
|
setJazzContext: (context: JazzContextType<Account>) => void;
|
|
17
17
|
setAuthSecretStorage: (storage: AuthSecretStorage) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/better-auth/auth/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/better-auth/auth/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EAGtB,MAAM,aAAa,CAAC;AASrB,KAAK,UAAU,GAAG,gBAAgB,GAAG;IACnC,MAAM,EAAE;QACN,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,SAAS,EAAE;oBACT,IAAI,EAAE,QAAQ,CAAC;oBACf,QAAQ,EAAE,KAAK,CAAC;oBAChB,KAAK,EAAE,KAAK,CAAC;iBACd,CAAC;gBACF,oBAAoB,EAAE;oBACpB,IAAI,EAAE,QAAQ,CAAC;oBACf,QAAQ,EAAE,KAAK,CAAC;oBAChB,KAAK,EAAE,KAAK,CAAC;oBACb,QAAQ,EAAE,KAAK,CAAC;iBACjB,CAAC;aACH,CAAC;SACH,CAAC;KACH,CAAC;CACH,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,UA0Q9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/better-auth/auth/server.ts"],"sourcesContent":["import { AuthContext, MiddlewareContext, MiddlewareOptions } from \"better-auth\";\nimport { APIError } from \"better-auth/api\";\nimport { symmetricDecrypt, symmetricEncrypt } from \"better-auth/crypto\";\nimport { BetterAuthPlugin, createAuthMiddleware } from \"better-auth/plugins\";\nimport type { Account, AuthCredentials, ID } from \"jazz-tools\";\n\n// Define a type to have user fields mapped in the better-auth instance\n// It should be automatic, but it needs an hard reference to BetterAuthPlugin type\n// in order to be exported as library.\ntype JazzPlugin = BetterAuthPlugin & {\n schema: {\n user: {\n fields: {\n accountID: {\n type: \"string\";\n required: false;\n input: false;\n };\n encryptedCredentials: {\n type: \"string\";\n required: false;\n input: false;\n returned: false;\n };\n };\n };\n };\n};\n\n/**\n * @returns The BetterAuth server plugin.\n *\n * @example\n * ```ts\n * const auth = betterAuth({\n * plugins: [jazzPlugin()],\n * // ... other BetterAuth options\n * });\n * ```\n */\nexport const jazzPlugin: () => JazzPlugin = () => {\n return {\n id: \"jazz-plugin\",\n schema: {\n user: {\n fields: {\n accountID: {\n type: \"string\",\n required: false,\n input: false,\n },\n encryptedCredentials: {\n type: \"string\",\n required: false,\n input: false,\n returned: false,\n },\n },\n },\n },\n\n init() {\n return {\n options: {\n databaseHooks: {\n user: {\n create: {\n before: async (user, context) => {\n // If the user is created without a jazzAuth, it will throw an error.\n if (!contextContainsJazzAuth(context)) {\n throw new APIError(422, {\n message: \"JazzAuth is required on user creation\",\n });\n }\n // Decorate the user with the jazz's credentials.\n return {\n data: {\n accountID: context.jazzAuth.accountID,\n encryptedCredentials:\n context.jazzAuth.encryptedCredentials,\n },\n };\n },\n },\n },\n verification: {\n create: {\n after: async (verification, context) => {\n /**\n * For: Email OTP plugin\n * After a verification is created, if it is from the EmailOTP plugin,\n * create a new verification value with the jazzAuth with the same expiration.\n */\n if (\n contextContainsJazzAuth(context) &&\n verification.identifier.startsWith(\"sign-in-otp-\")\n ) {\n const identifier = `jazz-auth-${verification.identifier}`;\n await context.context.internalAdapter.deleteVerificationByIdentifier(\n identifier,\n );\n await context.context.internalAdapter.createVerificationValue(\n {\n value: JSON.stringify({ jazzAuth: context.jazzAuth }),\n identifier: identifier,\n expiresAt: verification.expiresAt,\n },\n );\n }\n },\n },\n },\n },\n },\n };\n },\n\n hooks: {\n before: [\n /**\n * If the client sends a x-jazz-auth header,\n * we encrypt the credentials and inject them into the context.\n */\n {\n matcher: (context) => {\n return !!context.headers?.get(\"x-jazz-auth\");\n },\n handler: createAuthMiddleware(async (ctx) => {\n const jazzAuth = JSON.parse(ctx.headers?.get(\"x-jazz-auth\")!);\n\n const credentials: AuthCredentials = {\n accountID: jazzAuth.accountID as ID<Account>,\n secretSeed: jazzAuth.secretSeed,\n accountSecret: jazzAuth.accountSecret as any,\n // If the provider remains 'anonymous', Jazz will not consider us authenticated later.\n provider: \"better-auth\",\n };\n\n const encryptedCredentials = await symmetricEncrypt({\n key: ctx.context.secret,\n data: JSON.stringify(credentials),\n });\n\n return {\n context: {\n ...ctx,\n jazzAuth: {\n accountID: jazzAuth.accountID,\n encryptedCredentials: encryptedCredentials,\n },\n },\n };\n }),\n },\n\n /**\n * For: Social / OAuth2 plugin\n * /callback is the endpoint that BetterAuth uses to authenticate the user coming from a social provider.\n * 1. Catch the state\n * 2. Find the verification value\n * 3. If the verification value contains a jazzAuth, inject into the context to have it in case of registration.\n */\n {\n matcher: (context) => {\n return (\n context.path.startsWith(\"/callback\") ||\n context.path.startsWith(\"/oauth2/callback\")\n );\n },\n handler: createAuthMiddleware(async (ctx) => {\n const state = ctx.query?.state || ctx.body?.state;\n\n const identifier = `jazz-auth-${state}`;\n\n const data =\n await ctx.context.internalAdapter.findVerificationValue(\n identifier,\n );\n\n // if not found, the social plugin will throw later anyway\n if (!data) {\n throw new APIError(404, {\n message: \"Verification not found\",\n });\n }\n\n const parsed = JSON.parse(data.value);\n\n if (parsed && \"jazzAuth\" in parsed) {\n return {\n context: {\n ...ctx,\n jazzAuth: parsed.jazzAuth,\n },\n };\n } else {\n throw new APIError(404, {\n message: \"JazzAuth not found in verification value\",\n });\n }\n }),\n },\n /**\n * For: Email OTP plugin\n * When the user sends an OTP, we try to find the jazzAuth.\n * If it isn't a sign-up, we expect to not find a verification value.\n */\n {\n matcher: (context) => {\n return context.path.startsWith(\"/sign-in/email-otp\");\n },\n handler: createAuthMiddleware(async (ctx) => {\n const email = ctx.body.email;\n const identifier = `jazz-auth-sign-in-otp-${email}`;\n\n const data =\n await ctx.context.internalAdapter.findVerificationValue(\n identifier,\n );\n\n // if not found, it isn't a sign-up\n if (!data || data.expiresAt < new Date()) {\n return;\n }\n\n const parsed = JSON.parse(data.value);\n\n if (parsed && \"jazzAuth\" in parsed) {\n return {\n context: {\n ...ctx,\n jazzAuth: parsed.jazzAuth,\n },\n };\n } else {\n throw new APIError(500, {\n message: \"JazzAuth not found in verification value\",\n });\n }\n }),\n },\n ],\n after: [\n /**\n * This middleware is used to extract the jazzAuth from the user and return it in the response.\n * It is used in the following endpoints that return the user:\n * - /sign-up/email\n * - /sign-in/email\n * - /get-session\n */\n {\n matcher: (context) => {\n return (\n context.path.startsWith(\"/sign-up\") ||\n context.path.startsWith(\"/sign-in\") ||\n context.path.startsWith(\"/get-session\")\n );\n },\n handler: createAuthMiddleware({}, async (ctx) => {\n const returned = ctx.context.returned as any;\n if (!returned?.user?.id) {\n return;\n }\n const jazzAuth = await extractJazzAuth(returned.user.id, ctx);\n\n return ctx.json({\n ...returned,\n jazzAuth: jazzAuth,\n });\n }),\n },\n\n /**\n * For: Social / OAuth2 plugin\n * When the user sign-in via social, we create a verification value with the jazzAuth.\n */\n {\n matcher: (context) => {\n return context.path.startsWith(\"/sign-in/social\");\n },\n handler: createAuthMiddleware(async (ctx) => {\n if (!contextContainsJazzAuth(ctx)) {\n throw new APIError(500, {\n message: \"JazzAuth not found in context\",\n });\n }\n\n const returned = ctx.context.returned as { url: string };\n\n const url = new URL(returned.url);\n const state = url.searchParams.get(\"state\");\n\n const value = JSON.stringify({ jazzAuth: ctx.jazzAuth });\n const expiresAt = new Date();\n expiresAt.setMinutes(expiresAt.getMinutes() + 10);\n\n await ctx.context.internalAdapter.createVerificationValue({\n value,\n identifier: `jazz-auth-${state}`,\n expiresAt,\n });\n }),\n },\n ],\n },\n } satisfies JazzPlugin;\n};\n\nfunction contextContainsJazzAuth(ctx: unknown): ctx is {\n jazzAuth: {\n accountID: string;\n encryptedCredentials: string;\n };\n} {\n return !!ctx && typeof ctx === \"object\" && \"jazzAuth\" in ctx;\n}\n\nasync function extractJazzAuth(\n userId: string,\n ctx: MiddlewareContext<\n MiddlewareOptions,\n AuthContext & {\n returned?: unknown;\n responseHeaders?: Headers;\n }\n >,\n) {\n const user = await ctx.context.adapter.findOne<{\n accountID: string;\n encryptedCredentials: string;\n }>({\n model: ctx.context.tables.user!.modelName,\n where: [\n {\n field: \"id\",\n operator: \"eq\",\n value: userId,\n },\n ],\n select: [\"accountID\", \"encryptedCredentials\"],\n });\n\n if (!user) {\n return;\n }\n\n const jazzAuth = JSON.parse(\n await symmetricDecrypt({\n key: ctx.context.secret,\n data: user.encryptedCredentials,\n }),\n );\n\n return jazzAuth;\n}\n"],"mappings":";AACA,SAAS,gBAAgB;AACzB,SAAS,kBAAkB,wBAAwB;AACnD,SAA2B,4BAA4B;AAqChD,IAAM,aAA+B,MAAM;AAChD,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,QAAQ;AAAA,MACN,MAAM;AAAA,QACJ,QAAQ;AAAA,UACN,WAAW;AAAA,YACT,MAAM;AAAA,YACN,UAAU;AAAA,YACV,OAAO;AAAA,UACT;AAAA,UACA,sBAAsB;AAAA,YACpB,MAAM;AAAA,YACN,UAAU;AAAA,YACV,OAAO;AAAA,YACP,UAAU;AAAA,UACZ;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IAEA,OAAO;AACL,aAAO;AAAA,QACL,SAAS;AAAA,UACP,eAAe;AAAA,YACb,MAAM;AAAA,cACJ,QAAQ;AAAA,gBACN,QAAQ,OAAO,MAAM,YAAY;AAE/B,sBAAI,CAAC,wBAAwB,OAAO,GAAG;AACrC,0BAAM,IAAI,SAAS,KAAK;AAAA,sBACtB,SAAS;AAAA,oBACX,CAAC;AAAA,kBACH;AAEA,yBAAO;AAAA,oBACL,MAAM;AAAA,sBACJ,WAAW,QAAQ,SAAS;AAAA,sBAC5B,sBACE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B,sBAAU,WAAW,UAAU,WAAW,IAAI,EAAE;AAEhD,kBAAM,IAAI,QAAQ,gBAAgB,wBAAwB;AAAA,cACxD;AAAA,cACA,YAAY,aAAa,KAAK;AAAA,cAC9B;AAAA,YACF,CAAC;AAAA,UACH,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,wBAAwB,KAK/B;AACA,SAAO,CAAC,CAAC,OAAO,OAAO,QAAQ,YAAY,cAAc;AAC3D;AAEA,eAAe,gBACb,QACA,KAOA;AACA,QAAM,OAAO,MAAM,IAAI,QAAQ,QAAQ,QAGpC;AAAA,IACD,OAAO,IAAI,QAAQ,OAAO,KAAM;AAAA,IAChC,OAAO;AAAA,MACL;AAAA,QACE,OAAO;AAAA,QACP,UAAU;AAAA,QACV,OAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,QAAQ,CAAC,aAAa,sBAAsB;AAAA,EAC9C,CAAC;AAED,MAAI,CAAC,MAAM;AACT;AAAA,EACF;AAEA,QAAM,WAAW,KAAK;AAAA,IACpB,MAAM,iBAAiB;AAAA,MACrB,KAAK,IAAI,QAAQ;AAAA,MACjB,MAAM,KAAK;AAAA,IACb,CAAC;AAAA,EACH;AAEA,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/better-auth/auth/server.ts"],"sourcesContent":["import {\n AuthContext,\n type BetterAuthPlugin,\n MiddlewareContext,\n MiddlewareOptions,\n} from \"better-auth\";\nimport { APIError } from \"better-auth/api\";\nimport { symmetricDecrypt, symmetricEncrypt } from \"better-auth/crypto\";\nimport { createAuthMiddleware } from \"better-auth/plugins\";\nimport type { Account, AuthCredentials, ID } from \"jazz-tools\";\n\n// Define a type to have user fields mapped in the better-auth instance\n// It should be automatic, but it needs an hard reference to BetterAuthPlugin type\n// in order to be exported as library.\ntype JazzPlugin = BetterAuthPlugin & {\n schema: {\n user: {\n fields: {\n accountID: {\n type: \"string\";\n required: false;\n input: false;\n };\n encryptedCredentials: {\n type: \"string\";\n required: false;\n input: false;\n returned: false;\n };\n };\n };\n };\n};\n\n/**\n * @returns The BetterAuth server plugin.\n *\n * @example\n * ```ts\n * const auth = betterAuth({\n * plugins: [jazzPlugin()],\n * // ... other BetterAuth options\n * });\n * ```\n */\nexport const jazzPlugin: () => JazzPlugin = () => {\n return {\n id: \"jazz-plugin\",\n schema: {\n user: {\n fields: {\n accountID: {\n type: \"string\",\n required: false,\n input: false,\n },\n encryptedCredentials: {\n type: \"string\",\n required: false,\n input: false,\n returned: false,\n },\n },\n },\n },\n\n init() {\n return {\n options: {\n databaseHooks: {\n user: {\n create: {\n before: async (user, context) => {\n // If the user is created without a jazzAuth, it will throw an error.\n if (!contextContainsJazzAuth(context)) {\n throw new APIError(422, {\n message: \"JazzAuth is required on user creation\",\n });\n }\n // Decorate the user with the jazz's credentials.\n return {\n data: {\n accountID: context.jazzAuth.accountID,\n encryptedCredentials:\n context.jazzAuth.encryptedCredentials,\n },\n };\n },\n },\n },\n verification: {\n create: {\n after: async (verification, context) => {\n /**\n * For: Email OTP plugin\n * After a verification is created, if it is from the EmailOTP plugin,\n * create a new verification value with the jazzAuth with the same expiration.\n */\n if (\n contextContainsJazzAuth(context) &&\n verification.identifier.startsWith(\"sign-in-otp-\")\n ) {\n const identifier = `jazz-auth-${verification.identifier}`;\n await context.context.internalAdapter.deleteVerificationByIdentifier(\n identifier,\n );\n await context.context.internalAdapter.createVerificationValue(\n {\n value: JSON.stringify({ jazzAuth: context.jazzAuth }),\n identifier: identifier,\n expiresAt: verification.expiresAt,\n },\n );\n }\n },\n },\n },\n },\n },\n };\n },\n\n hooks: {\n before: [\n /**\n * If the client sends a x-jazz-auth header,\n * we encrypt the credentials and inject them into the context.\n */\n {\n matcher: (context) => {\n return !!context.headers?.get(\"x-jazz-auth\");\n },\n handler: createAuthMiddleware(async (ctx) => {\n const jazzAuth = JSON.parse(ctx.headers?.get(\"x-jazz-auth\")!);\n\n const credentials: AuthCredentials = {\n accountID: jazzAuth.accountID as ID<Account>,\n secretSeed: jazzAuth.secretSeed,\n accountSecret: jazzAuth.accountSecret as any,\n // If the provider remains 'anonymous', Jazz will not consider us authenticated later.\n provider: \"better-auth\",\n };\n\n const encryptedCredentials = await symmetricEncrypt({\n key: ctx.context.secret,\n data: JSON.stringify(credentials),\n });\n\n return {\n context: {\n ...ctx,\n jazzAuth: {\n accountID: jazzAuth.accountID,\n encryptedCredentials: encryptedCredentials,\n },\n },\n };\n }),\n },\n\n /**\n * For: Social / OAuth2 plugin\n * /callback is the endpoint that BetterAuth uses to authenticate the user coming from a social provider.\n * 1. Catch the state\n * 2. Find the verification value\n * 3. If the verification value contains a jazzAuth, inject into the context to have it in case of registration.\n */\n {\n matcher: (context) => {\n return (\n context.path.startsWith(\"/callback\") ||\n context.path.startsWith(\"/oauth2/callback\")\n );\n },\n handler: createAuthMiddleware(async (ctx) => {\n const state = ctx.query?.state || ctx.body?.state;\n\n const identifier = `jazz-auth-${state}`;\n\n const data =\n await ctx.context.internalAdapter.findVerificationValue(\n identifier,\n );\n\n // if not found, the social plugin will throw later anyway\n if (!data) {\n throw new APIError(404, {\n message: \"Verification not found\",\n });\n }\n\n const parsed = JSON.parse(data.value);\n\n if (parsed && \"jazzAuth\" in parsed) {\n return {\n context: {\n ...ctx,\n jazzAuth: parsed.jazzAuth,\n },\n };\n } else {\n throw new APIError(404, {\n message: \"JazzAuth not found in verification value\",\n });\n }\n }),\n },\n /**\n * For: Email OTP plugin\n * When the user sends an OTP, we try to find the jazzAuth.\n * If it isn't a sign-up, we expect to not find a verification value.\n */\n {\n matcher: (context) => {\n return context.path.startsWith(\"/sign-in/email-otp\");\n },\n handler: createAuthMiddleware(async (ctx) => {\n const email = ctx.body.email;\n const identifier = `jazz-auth-sign-in-otp-${email}`;\n\n const data =\n await ctx.context.internalAdapter.findVerificationValue(\n identifier,\n );\n\n // if not found, it isn't a sign-up\n if (!data || data.expiresAt < new Date()) {\n return;\n }\n\n const parsed = JSON.parse(data.value);\n\n if (parsed && \"jazzAuth\" in parsed) {\n return {\n context: {\n ...ctx,\n jazzAuth: parsed.jazzAuth,\n },\n };\n } else {\n throw new APIError(500, {\n message: \"JazzAuth not found in verification value\",\n });\n }\n }),\n },\n ],\n after: [\n /**\n * This middleware is used to extract the jazzAuth from the user and return it in the response.\n * It is used in the following endpoints that return the user:\n * - /sign-up/email\n * - /sign-in/email\n * - /get-session\n */\n {\n matcher: (context) => {\n return (\n context.path.startsWith(\"/sign-up\") ||\n context.path.startsWith(\"/sign-in\") ||\n context.path.startsWith(\"/get-session\")\n );\n },\n handler: createAuthMiddleware({}, async (ctx) => {\n const returned = ctx.context.returned as any;\n if (!returned?.user?.id) {\n return;\n }\n const jazzAuth = await extractJazzAuth(returned.user.id, ctx);\n\n return ctx.json({\n ...returned,\n jazzAuth: jazzAuth,\n });\n }),\n },\n\n /**\n * For: Social / OAuth2 plugin\n * When the user sign-in via social, we create a verification value with the jazzAuth.\n */\n {\n matcher: (context) => {\n return context.path.startsWith(\"/sign-in/social\");\n },\n handler: createAuthMiddleware(async (ctx) => {\n if (!contextContainsJazzAuth(ctx)) {\n throw new APIError(500, {\n message: \"JazzAuth not found in context\",\n });\n }\n\n const returned = ctx.context.returned as { url: string };\n\n const url = new URL(returned.url);\n const state = url.searchParams.get(\"state\");\n\n const value = JSON.stringify({ jazzAuth: ctx.jazzAuth });\n const expiresAt = new Date();\n expiresAt.setMinutes(expiresAt.getMinutes() + 10);\n\n await ctx.context.internalAdapter.createVerificationValue({\n value,\n identifier: `jazz-auth-${state}`,\n expiresAt,\n });\n }),\n },\n ],\n },\n } satisfies JazzPlugin;\n};\n\nfunction contextContainsJazzAuth(ctx: unknown): ctx is {\n jazzAuth: {\n accountID: string;\n encryptedCredentials: string;\n };\n} {\n return !!ctx && typeof ctx === \"object\" && \"jazzAuth\" in ctx;\n}\n\nasync function extractJazzAuth(\n userId: string,\n ctx: MiddlewareContext<\n MiddlewareOptions,\n AuthContext & {\n returned?: unknown;\n responseHeaders?: Headers;\n }\n >,\n) {\n const user = await ctx.context.adapter.findOne<{\n accountID: string;\n encryptedCredentials: string;\n }>({\n model: ctx.context.tables.user!.modelName,\n where: [\n {\n field: \"id\",\n operator: \"eq\",\n value: userId,\n },\n ],\n select: [\"accountID\", \"encryptedCredentials\"],\n });\n\n if (!user) {\n return;\n }\n\n const jazzAuth = JSON.parse(\n await symmetricDecrypt({\n key: ctx.context.secret,\n data: user.encryptedCredentials,\n }),\n );\n\n return jazzAuth;\n}\n"],"mappings":";AAMA,SAAS,gBAAgB;AACzB,SAAS,kBAAkB,wBAAwB;AACnD,SAAS,4BAA4B;AAqC9B,IAAM,aAA+B,MAAM;AAChD,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,QAAQ;AAAA,MACN,MAAM;AAAA,QACJ,QAAQ;AAAA,UACN,WAAW;AAAA,YACT,MAAM;AAAA,YACN,UAAU;AAAA,YACV,OAAO;AAAA,UACT;AAAA,UACA,sBAAsB;AAAA,YACpB,MAAM;AAAA,YACN,UAAU;AAAA,YACV,OAAO;AAAA,YACP,UAAU;AAAA,UACZ;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IAEA,OAAO;AACL,aAAO;AAAA,QACL,SAAS;AAAA,UACP,eAAe;AAAA,YACb,MAAM;AAAA,cACJ,QAAQ;AAAA,gBACN,QAAQ,OAAO,MAAM,YAAY;AAE/B,sBAAI,CAAC,wBAAwB,OAAO,GAAG;AACrC,0BAAM,IAAI,SAAS,KAAK;AAAA,sBACtB,SAAS;AAAA,oBACX,CAAC;AAAA,kBACH;AAEA,yBAAO;AAAA,oBACL,MAAM;AAAA,sBACJ,WAAW,QAAQ,SAAS;AAAA,sBAC5B,sBACE,QAAQ,SAAS;AAAA,oBACrB;AAAA,kBACF;AAAA,gBACF;AAAA,cACF;AAAA,YACF;AAAA,YACA,cAAc;AAAA,cACZ,QAAQ;AAAA,gBACN,OAAO,OAAO,cAAc,YAAY;AAMtC,sBACE,wBAAwB,OAAO,KAC/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QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,wBAAwB,KAK/B;AACA,SAAO,CAAC,CAAC,OAAO,OAAO,QAAQ,YAAY,cAAc;AAC3D;AAEA,eAAe,gBACb,QACA,KAOA;AACA,QAAM,OAAO,MAAM,IAAI,QAAQ,QAAQ,QAGpC;AAAA,IACD,OAAO,IAAI,QAAQ,OAAO,KAAM;AAAA,IAChC,OAAO;AAAA,MACL;AAAA,QACE,OAAO;AAAA,QACP,UAAU;AAAA,QACV,OAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,QAAQ,CAAC,aAAa,sBAAsB;AAAA,EAC9C,CAAC;AAED,MAAI,CAAC,MAAM;AACT;AAAA,EACF;AAEA,QAAM,WAAW,KAAK;AAAA,IACpB,MAAM,iBAAiB;AAAA,MACrB,KAAK,IAAI,QAAQ;AAAA,MACjB,MAAM,KAAK;AAAA,IACb,CAAC;AAAA,EACH;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { createAdapterFactory, type DBAdapterDebugLogOption } from "better-auth/adapters";
|
|
2
2
|
export interface JazzAdapterConfig {
|
|
3
3
|
/**
|
|
4
4
|
* Helps you debug issues with the adapter.
|
|
5
5
|
*/
|
|
6
|
-
debugLogs?:
|
|
6
|
+
debugLogs?: DBAdapterDebugLogOption;
|
|
7
7
|
/**
|
|
8
8
|
* The sync server to use.
|
|
9
9
|
*/
|
|
@@ -46,5 +46,5 @@ export interface JazzAdapterConfig {
|
|
|
46
46
|
* });
|
|
47
47
|
* ```
|
|
48
48
|
*/
|
|
49
|
-
export declare const JazzBetterAuthDatabaseAdapter: (config: JazzAdapterConfig) => ReturnType<typeof
|
|
49
|
+
export declare const JazzBetterAuthDatabaseAdapter: (config: JazzAdapterConfig) => ReturnType<typeof createAdapterFactory>;
|
|
50
50
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/better-auth/database-adapter/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/better-auth/database-adapter/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,KAAK,uBAAuB,EAC7B,MAAM,sBAAsB,CAAC;AAY9B,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,SAAS,CAAC,EAAE,uBAAuB,CAAC;IACpC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,6BAA6B,WAChC,iBAAiB,KACxB,UAAU,CAAC,OAAO,oBAAoB,CAqKrC,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// src/better-auth/database-adapter/index.ts
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createAdapterFactory
|
|
4
|
+
} from "better-auth/adapters";
|
|
3
5
|
import { startWorker } from "jazz-tools/worker";
|
|
4
6
|
|
|
5
7
|
// src/better-auth/database-adapter/utils.ts
|
|
@@ -31,6 +33,8 @@ function filterListByWhere(data, where) {
|
|
|
31
33
|
return value !== null && itemValue >= value;
|
|
32
34
|
case "in":
|
|
33
35
|
return Array.isArray(value) ? value.includes(itemValue) : false;
|
|
36
|
+
case "not_in":
|
|
37
|
+
return Array.isArray(value) ? !value.includes(itemValue) : false;
|
|
34
38
|
case "contains":
|
|
35
39
|
return typeof itemValue === "string" && typeof value === "string" ? itemValue.includes(value) : false;
|
|
36
40
|
case "starts_with":
|
|
@@ -782,7 +786,7 @@ function tableItem2Record(tableItem) {
|
|
|
782
786
|
}
|
|
783
787
|
|
|
784
788
|
// src/better-auth/database-adapter/index.ts
|
|
785
|
-
var JazzBetterAuthDatabaseAdapter = (config) =>
|
|
789
|
+
var JazzBetterAuthDatabaseAdapter = (config) => createAdapterFactory({
|
|
786
790
|
config: {
|
|
787
791
|
adapterId: "jazz-tools-adapter",
|
|
788
792
|
// A unique identifier for the adapter.
|