jazz-tools 0.17.14 → 0.18.1

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.
Files changed (250) hide show
  1. package/.svelte-kit/__package__/jazz.class.svelte.js +1 -1
  2. package/.svelte-kit/__package__/media/image.svelte +3 -9
  3. package/.svelte-kit/__package__/media/image.svelte.d.ts +1 -6
  4. package/.svelte-kit/__package__/media/image.svelte.d.ts.map +1 -1
  5. package/.svelte-kit/__package__/media/image.types.d.ts +7 -0
  6. package/.svelte-kit/__package__/media/image.types.d.ts.map +1 -0
  7. package/.svelte-kit/__package__/media/image.types.js +1 -0
  8. package/.svelte-kit/__package__/tests/media/image.svelte.test.js +31 -31
  9. package/.turbo/turbo-build.log +60 -46
  10. package/CHANGELOG.md +41 -0
  11. package/dist/better-auth/auth/client.d.ts +29 -0
  12. package/dist/better-auth/auth/client.d.ts.map +1 -0
  13. package/dist/better-auth/auth/client.js +127 -0
  14. package/dist/better-auth/auth/client.js.map +1 -0
  15. package/dist/better-auth/auth/react.d.ts +2170 -0
  16. package/dist/better-auth/auth/react.d.ts.map +1 -0
  17. package/dist/better-auth/auth/react.js +40 -0
  18. package/dist/better-auth/auth/react.js.map +1 -0
  19. package/dist/better-auth/auth/server.d.ts +14 -0
  20. package/dist/better-auth/auth/server.d.ts.map +1 -0
  21. package/dist/better-auth/auth/server.js +198 -0
  22. package/dist/better-auth/auth/server.js.map +1 -0
  23. package/dist/better-auth/auth/tests/client.test.d.ts +2 -0
  24. package/dist/better-auth/auth/tests/client.test.d.ts.map +1 -0
  25. package/dist/better-auth/auth/tests/server.test.d.ts +2 -0
  26. package/dist/better-auth/auth/tests/server.test.d.ts.map +1 -0
  27. package/dist/browser/index.js +2 -2
  28. package/dist/browser/index.js.map +1 -1
  29. package/dist/{chunk-LZOF6WP5.js → chunk-IERUTUXB.js} +1336 -1017
  30. package/dist/chunk-IERUTUXB.js.map +1 -0
  31. package/dist/index.js +18 -18
  32. package/dist/index.js.map +1 -1
  33. package/dist/inspector/{custom-element-ZSNTCECD.js → custom-element-WCY6D3QJ.js} +3 -3
  34. package/dist/inspector/{custom-element-ZSNTCECD.js.map → custom-element-WCY6D3QJ.js.map} +1 -1
  35. package/dist/inspector/index.js +1 -1
  36. package/dist/inspector/index.js.map +1 -1
  37. package/dist/inspector/register-custom-element.js +1 -1
  38. package/dist/media/{chunk-E5J3WLQW.js → chunk-KR2V6X2N.js} +14 -9
  39. package/dist/media/chunk-KR2V6X2N.js.map +1 -0
  40. package/dist/media/create-image.d.ts +6 -6
  41. package/dist/media/index.browser.d.ts +6 -6
  42. package/dist/media/index.browser.js +1 -1
  43. package/dist/media/index.d.ts +1 -1
  44. package/dist/media/index.js +1 -1
  45. package/dist/media/index.native.d.ts +6 -6
  46. package/dist/media/index.native.js +1 -1
  47. package/dist/media/utils.d.ts.map +1 -1
  48. package/dist/prosemirror/index.js +2 -2
  49. package/dist/prosemirror/index.js.map +1 -1
  50. package/dist/react/index.js +7 -5
  51. package/dist/react/index.js.map +1 -1
  52. package/dist/react-core/hooks.d.ts.map +1 -1
  53. package/dist/react-core/index.js +4675 -23
  54. package/dist/react-core/index.js.map +1 -1
  55. package/dist/react-native-core/index.js +1 -1
  56. package/dist/react-native-core/index.js.map +1 -1
  57. package/dist/svelte/jazz.class.svelte.js +1 -1
  58. package/dist/svelte/media/image.svelte +3 -9
  59. package/dist/svelte/media/image.svelte.d.ts +1 -6
  60. package/dist/svelte/media/image.svelte.d.ts.map +1 -1
  61. package/dist/svelte/media/image.types.d.ts +7 -0
  62. package/dist/svelte/media/image.types.d.ts.map +1 -0
  63. package/dist/svelte/media/image.types.js +1 -0
  64. package/dist/svelte/tests/media/image.svelte.test.js +31 -31
  65. package/dist/testing.js +18 -14
  66. package/dist/testing.js.map +1 -1
  67. package/dist/tools/coValues/CoFieldInit.d.ts +13 -0
  68. package/dist/tools/coValues/CoFieldInit.d.ts.map +1 -0
  69. package/dist/tools/coValues/CoValueBase.d.ts +18 -15
  70. package/dist/tools/coValues/CoValueBase.d.ts.map +1 -1
  71. package/dist/tools/coValues/account.d.ts +101 -46
  72. package/dist/tools/coValues/account.d.ts.map +1 -1
  73. package/dist/tools/coValues/coFeed.d.ts +78 -62
  74. package/dist/tools/coValues/coFeed.d.ts.map +1 -1
  75. package/dist/tools/coValues/coList.d.ts +212 -99
  76. package/dist/tools/coValues/coList.d.ts.map +1 -1
  77. package/dist/tools/coValues/coMap.d.ts +210 -192
  78. package/dist/tools/coValues/coMap.d.ts.map +1 -1
  79. package/dist/tools/coValues/coPlainText.d.ts +30 -22
  80. package/dist/tools/coValues/coPlainText.d.ts.map +1 -1
  81. package/dist/tools/coValues/deepLoading.d.ts +13 -13
  82. package/dist/tools/coValues/deepLoading.d.ts.map +1 -1
  83. package/dist/tools/coValues/extensions/imageDef.d.ts +1 -1
  84. package/dist/tools/coValues/group.d.ts +32 -32
  85. package/dist/tools/coValues/group.d.ts.map +1 -1
  86. package/dist/tools/coValues/inbox.d.ts.map +1 -1
  87. package/dist/tools/coValues/interfaces.d.ts +18 -17
  88. package/dist/tools/coValues/interfaces.d.ts.map +1 -1
  89. package/dist/tools/coValues/profile.d.ts +6 -5
  90. package/dist/tools/coValues/profile.d.ts.map +1 -1
  91. package/dist/tools/coValues/schemaUnion.d.ts +3 -3
  92. package/dist/tools/coValues/schemaUnion.d.ts.map +1 -1
  93. package/dist/tools/exports.d.ts +1 -1
  94. package/dist/tools/exports.d.ts.map +1 -1
  95. package/dist/tools/implementation/anonymousJazzAgent.d.ts +2 -1
  96. package/dist/tools/implementation/anonymousJazzAgent.d.ts.map +1 -1
  97. package/dist/tools/implementation/schema.d.ts +5 -5
  98. package/dist/tools/implementation/schema.d.ts.map +1 -1
  99. package/dist/tools/implementation/symbols.d.ts +2 -0
  100. package/dist/tools/implementation/symbols.d.ts.map +1 -1
  101. package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +2 -2
  102. package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
  103. package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts +6 -2
  104. package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +1 -1
  105. package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts +8 -3
  106. package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -1
  107. package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +12 -7
  108. package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -1
  109. package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts +13 -7
  110. package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts.map +1 -1
  111. package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts +11 -2
  112. package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts.map +1 -1
  113. package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts +4 -0
  114. package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts.map +1 -1
  115. package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts +4 -0
  116. package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts.map +1 -1
  117. package/dist/tools/implementation/zodSchema/typeConverters/{CoFieldInit.d.ts → CoFieldSchemaInit.d.ts} +7 -7
  118. package/dist/tools/implementation/zodSchema/typeConverters/CoFieldSchemaInit.d.ts.map +1 -0
  119. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts +4 -4
  120. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts.map +1 -1
  121. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts +4 -4
  122. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts.map +1 -1
  123. package/dist/tools/implementation/zodSchema/zodCo.d.ts +3 -3
  124. package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
  125. package/dist/tools/internal.d.ts +2 -1
  126. package/dist/tools/internal.d.ts.map +1 -1
  127. package/dist/tools/lib/migration.d.ts +1 -1
  128. package/dist/tools/lib/migration.d.ts.map +1 -1
  129. package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
  130. package/dist/tools/subscribe/index.d.ts +1 -1
  131. package/dist/tools/subscribe/index.d.ts.map +1 -1
  132. package/dist/tools/subscribe/utils.d.ts +2 -2
  133. package/dist/tools/subscribe/utils.d.ts.map +1 -1
  134. package/dist/tools/testing.d.ts.map +1 -1
  135. package/dist/tools/tests/utils.d.ts +2 -6
  136. package/dist/tools/tests/utils.d.ts.map +1 -1
  137. package/dist/worker/index.js +3 -3
  138. package/dist/worker/index.js.map +1 -1
  139. package/package.json +23 -4
  140. package/src/better-auth/auth/client.ts +169 -0
  141. package/src/better-auth/auth/react.tsx +105 -0
  142. package/src/better-auth/auth/server.ts +250 -0
  143. package/src/better-auth/auth/tests/client.test.ts +249 -0
  144. package/src/better-auth/auth/tests/server.test.ts +226 -0
  145. package/src/browser/auth/PasskeyAuth.ts +2 -2
  146. package/src/browser/createBrowserContext.ts +2 -2
  147. package/src/browser/tests/PasskeyAuth.test.ts +2 -2
  148. package/src/inspector/custom-element.tsx +2 -2
  149. package/src/inspector/viewer/new-app.tsx +1 -1
  150. package/src/media/create-image.test.ts +7 -7
  151. package/src/media/create-image.ts +5 -3
  152. package/src/media/index.ts +1 -1
  153. package/src/media/utils.test.ts +72 -66
  154. package/src/media/utils.ts +9 -6
  155. package/src/prosemirror/lib/plugin.ts +1 -1
  156. package/src/prosemirror/lib/sync.ts +1 -1
  157. package/src/prosemirror/tests/plugin.test.ts +4 -4
  158. package/src/react/media/image.tsx +2 -2
  159. package/src/react/tests/media/image.test.tsx +52 -32
  160. package/src/react-core/hooks.ts +11 -5
  161. package/src/react-core/tests/useAccount.test.ts +16 -22
  162. package/src/react-core/tests/useCoState.test.ts +19 -19
  163. package/src/react-core/tests/useInboxSender.test.ts +5 -2
  164. package/src/react-core/tests/usePassPhraseAuth.test.ts +6 -6
  165. package/src/react-native-core/media/image.tsx +1 -1
  166. package/src/svelte/jazz.class.svelte.ts +1 -1
  167. package/src/svelte/media/image.svelte +3 -9
  168. package/src/svelte/media/image.types.ts +7 -0
  169. package/src/svelte/tests/media/image.svelte.test.ts +34 -32
  170. package/src/tools/auth/DemoAuth.ts +2 -2
  171. package/src/tools/auth/PassphraseAuth.ts +2 -2
  172. package/src/tools/auth/clerk/index.ts +2 -2
  173. package/src/tools/auth/clerk/tests/JazzClerkAuth.test.ts +1 -1
  174. package/src/tools/coValues/CoFieldInit.ts +20 -0
  175. package/src/tools/coValues/CoValueBase.ts +40 -60
  176. package/src/tools/coValues/account.ts +311 -232
  177. package/src/tools/coValues/coFeed.ts +185 -153
  178. package/src/tools/coValues/coList.ts +507 -334
  179. package/src/tools/coValues/coMap.ts +434 -286
  180. package/src/tools/coValues/coPlainText.ts +94 -110
  181. package/src/tools/coValues/deepLoading.ts +13 -13
  182. package/src/tools/coValues/group.ts +100 -114
  183. package/src/tools/coValues/inbox.ts +16 -14
  184. package/src/tools/coValues/interfaces.ts +49 -31
  185. package/src/tools/coValues/profile.ts +8 -6
  186. package/src/tools/coValues/request.ts +9 -9
  187. package/src/tools/coValues/schemaUnion.ts +11 -5
  188. package/src/tools/exports.ts +1 -1
  189. package/src/tools/implementation/ContextManager.ts +4 -4
  190. package/src/tools/implementation/anonymousJazzAgent.ts +2 -1
  191. package/src/tools/implementation/createContext.ts +1 -1
  192. package/src/tools/implementation/devtoolsFormatters.ts +9 -9
  193. package/src/tools/implementation/invites.ts +2 -2
  194. package/src/tools/implementation/schema.ts +7 -7
  195. package/src/tools/implementation/symbols.ts +3 -0
  196. package/src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts +2 -2
  197. package/src/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.ts +11 -2
  198. package/src/tools/implementation/zodSchema/schemaTypes/CoListSchema.ts +18 -7
  199. package/src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts +17 -7
  200. package/src/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.ts +20 -11
  201. package/src/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.ts +19 -2
  202. package/src/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.ts +6 -0
  203. package/src/tools/implementation/zodSchema/schemaTypes/RichTextSchema.ts +6 -0
  204. package/src/tools/implementation/zodSchema/typeConverters/{CoFieldInit.ts → CoFieldSchemaInit.ts} +11 -11
  205. package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.ts +4 -4
  206. package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.ts +4 -4
  207. package/src/tools/implementation/zodSchema/zodCo.ts +3 -3
  208. package/src/tools/internal.ts +2 -1
  209. package/src/tools/lib/migration.ts +5 -5
  210. package/src/tools/subscribe/SubscriptionScope.ts +32 -24
  211. package/src/tools/subscribe/index.ts +4 -4
  212. package/src/tools/subscribe/utils.ts +11 -11
  213. package/src/tools/testing.ts +17 -13
  214. package/src/tools/tests/ContextManager.test.ts +70 -59
  215. package/src/tools/tests/PassphraseAuth.test.ts +2 -2
  216. package/src/tools/tests/account.test.ts +188 -67
  217. package/src/tools/tests/coDiscriminatedUnion.test-d.ts +12 -6
  218. package/src/tools/tests/coDiscriminatedUnion.test.ts +26 -17
  219. package/src/tools/tests/coFeed.test-d.ts +18 -17
  220. package/src/tools/tests/coFeed.test.ts +108 -97
  221. package/src/tools/tests/coList.test-d.ts +18 -23
  222. package/src/tools/tests/coList.test.ts +350 -165
  223. package/src/tools/tests/coMap.record.test-d.ts +9 -13
  224. package/src/tools/tests/coMap.record.test.ts +37 -23
  225. package/src/tools/tests/coMap.test-d.ts +43 -21
  226. package/src/tools/tests/coMap.test.ts +459 -182
  227. package/src/tools/tests/coOptional.test.ts +28 -13
  228. package/src/tools/tests/coPlainText.test.ts +15 -15
  229. package/src/tools/tests/createContext.test.ts +14 -14
  230. package/src/tools/tests/deepLoading.test.ts +95 -94
  231. package/src/tools/tests/exportImport.test.ts +61 -41
  232. package/src/tools/tests/groupsAndAccounts.test.ts +333 -116
  233. package/src/tools/tests/inbox.test.ts +22 -17
  234. package/src/tools/tests/interfaces.test.ts +12 -11
  235. package/src/tools/tests/invites.test.ts +6 -4
  236. package/src/tools/tests/load.test.ts +20 -18
  237. package/src/tools/tests/patterns/notifications.test.ts +7 -7
  238. package/src/tools/tests/patterns/quest.test.ts +3 -3
  239. package/src/tools/tests/patterns/requestToJoin.test.ts +22 -22
  240. package/src/tools/tests/request.test.ts +38 -39
  241. package/src/tools/tests/schemaUnion.test.ts +64 -10
  242. package/src/tools/tests/subscribe.test.ts +64 -64
  243. package/src/tools/tests/testing.test.ts +7 -11
  244. package/src/tools/tests/utils.ts +3 -3
  245. package/src/tools/tests/zod.test.ts +3 -3
  246. package/src/worker/index.ts +3 -3
  247. package/tsup.config.ts +9 -0
  248. package/dist/chunk-LZOF6WP5.js.map +0 -1
  249. package/dist/media/chunk-E5J3WLQW.js.map +0 -1
  250. package/dist/tools/implementation/zodSchema/typeConverters/CoFieldInit.d.ts.map +0 -1
@@ -69,7 +69,7 @@ export class AccountCoState {
69
69
  return this.update(undefined);
70
70
  }
71
71
  const me = ctx.me;
72
- const unsubscribe = subscribeToCoValue(coValueClassFromCoValueClassOrSchema(Schema), me.id, {
72
+ const unsubscribe = subscribeToCoValue(coValueClassFromCoValueClassOrSchema(Schema), me.$jazz.id, {
73
73
  // @ts-expect-error The resolve query type isn't compatible with the coValueClassFromCoValueClassOrSchema conversion
74
74
  resolve: options?.resolve,
75
75
  loadAs: me,
@@ -2,14 +2,8 @@
2
2
  import { ImageDefinition } from "jazz-tools";
3
3
  import { highestResAvailable } from "jazz-tools/media";
4
4
  import { onDestroy } from "svelte";
5
- import type { HTMLImgAttributes } from "svelte/elements";
6
5
  import { CoState } from "../jazz.class.svelte";
7
-
8
- interface ImageProps extends Omit<HTMLImgAttributes, "width" | "height"> {
9
- imageId: string;
10
- width?: number | "original";
11
- height?: number | "original";
12
- }
6
+ import type { ImageProps } from "./image.types.js";
13
7
 
14
8
  const { imageId, width, height, ...rest }: ImageProps = $props();
15
9
 
@@ -83,14 +77,14 @@ const src = $derived.by(() => {
83
77
  );
84
78
 
85
79
  if (!bestImage) return image.placeholderDataURL;
86
- if (lastBestImage?.[0] === bestImage.image.id) return lastBestImage?.[1];
80
+ if (lastBestImage?.[0] === bestImage.image.$jazz.id) return lastBestImage?.[1];
87
81
 
88
82
  const blob = bestImage.image.toBlob();
89
83
 
90
84
  if (blob) {
91
85
  const url = URL.createObjectURL(blob);
92
86
  revokeObjectURL(lastBestImage?.[1]);
93
- lastBestImage = [bestImage.image.id, url];
87
+ lastBestImage = [bestImage.image.$jazz.id, url];
94
88
  return url;
95
89
  }
96
90
 
@@ -1,9 +1,4 @@
1
- import type { HTMLImgAttributes } from "svelte/elements";
2
- interface ImageProps extends Omit<HTMLImgAttributes, "width" | "height"> {
3
- imageId: string;
4
- width?: number | "original";
5
- height?: number | "original";
6
- }
1
+ import type { ImageProps } from "./image.types.js";
7
2
  declare const Image: import("svelte").Component<ImageProps, {}, "">;
8
3
  type Image = ReturnType<typeof Image>;
9
4
  export default Image;
@@ -1 +1 @@
1
- {"version":3,"file":"image.svelte.d.ts","sourceRoot":"","sources":["../../../../src/svelte/media/image.svelte.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAIzD,UAAU,UAAW,SAAQ,IAAI,CAAC,iBAAiB,EAAE,OAAO,GAAG,QAAQ,CAAC;IACtE,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;CAC9B;AA2HD,QAAA,MAAM,KAAK,gDAAsC,CAAC;AAClD,KAAK,KAAK,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;AACtC,eAAe,KAAK,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;AA2HnD,QAAA,MAAM,KAAK,gDAAsC,CAAC;AAClD,KAAK,KAAK,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;AACtC,eAAe,KAAK,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { HTMLImgAttributes } from "svelte/elements";
2
+ export interface ImageProps extends Omit<HTMLImgAttributes, "width" | "height"> {
3
+ imageId: string;
4
+ width?: number | "original";
5
+ height?: number | "original";
6
+ }
7
+ //# sourceMappingURL=image.types.d.ts.map
@@ -0,0 +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;CAC9B"}
@@ -0,0 +1 @@
1
+ export {};
@@ -23,7 +23,7 @@ describe("Image", async () => {
23
23
  expect(img.src).toBe("");
24
24
  });
25
25
  it("should render an empty image if the image is not loaded yet", async () => {
26
- const original = FileStream.create({ owner: account._owner });
26
+ const original = FileStream.create({ owner: account.$jazz.owner });
27
27
  original.start({ mimeType: "image/jpeg" });
28
28
  // Don't end original, so it has no chunks
29
29
  const im = ImageDefinition.create({
@@ -34,7 +34,7 @@ describe("Image", async () => {
34
34
  owner: account,
35
35
  });
36
36
  const { container } = renderWithAccount({
37
- imageId: im.id,
37
+ imageId: im.$jazz.id,
38
38
  alt: "test",
39
39
  });
40
40
  const img = container.querySelector("img");
@@ -46,7 +46,7 @@ describe("Image", async () => {
46
46
  });
47
47
  it("should render the placeholder image if the image is not loaded yet", async () => {
48
48
  const placeholderDataUrl = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=";
49
- const original = FileStream.create({ owner: account._owner });
49
+ const original = FileStream.create({ owner: account.$jazz.owner });
50
50
  original.start({ mimeType: "image/jpeg" });
51
51
  // Don't end original, so it has no chunks
52
52
  const im = ImageDefinition.create({
@@ -58,7 +58,7 @@ describe("Image", async () => {
58
58
  owner: account,
59
59
  });
60
60
  const { container } = renderWithAccount({
61
- imageId: im.id,
61
+ imageId: im.$jazz.id,
62
62
  alt: "test",
63
63
  });
64
64
  const img = container.querySelector("img");
@@ -82,7 +82,7 @@ describe("Image", async () => {
82
82
  owner: account,
83
83
  });
84
84
  renderWithAccount({
85
- imageId: im.id,
85
+ imageId: im.$jazz.id,
86
86
  alt: "test-loading",
87
87
  });
88
88
  await waitFor(() => {
@@ -101,7 +101,7 @@ describe("Image", async () => {
101
101
  owner: account,
102
102
  });
103
103
  const { container } = renderWithAccount({
104
- imageId: im.id,
104
+ imageId: im.$jazz.id,
105
105
  alt: "test",
106
106
  });
107
107
  const img = container.querySelector("img");
@@ -118,7 +118,7 @@ describe("Image", async () => {
118
118
  owner: account,
119
119
  });
120
120
  const { container } = renderWithAccount({
121
- imageId: im.id,
121
+ imageId: im.$jazz.id,
122
122
  alt: "test",
123
123
  width: "original",
124
124
  height: "original",
@@ -137,7 +137,7 @@ describe("Image", async () => {
137
137
  owner: account,
138
138
  });
139
139
  const { container } = renderWithAccount({
140
- imageId: im.id,
140
+ imageId: im.$jazz.id,
141
141
  alt: "test",
142
142
  width: "original",
143
143
  height: 300,
@@ -156,7 +156,7 @@ describe("Image", async () => {
156
156
  owner: account,
157
157
  });
158
158
  const { container } = renderWithAccount({
159
- imageId: im.id,
159
+ imageId: im.$jazz.id,
160
160
  alt: "test",
161
161
  width: 50,
162
162
  });
@@ -174,7 +174,7 @@ describe("Image", async () => {
174
174
  owner: account,
175
175
  });
176
176
  const { container } = renderWithAccount({
177
- imageId: im.id,
177
+ imageId: im.$jazz.id,
178
178
  alt: "test",
179
179
  height: 50,
180
180
  });
@@ -192,7 +192,7 @@ describe("Image", async () => {
192
192
  owner: account,
193
193
  });
194
194
  const { container } = renderWithAccount({
195
- imageId: im.id,
195
+ imageId: im.$jazz.id,
196
196
  alt: "test",
197
197
  class: "test-class",
198
198
  });
@@ -219,10 +219,10 @@ describe("Image", async () => {
219
219
  }, {
220
220
  owner: account,
221
221
  });
222
- im["500x500"] = original;
223
- im["256x256"] = await createDummyFileStream(256, account);
222
+ im.$jazz.set("500x500", original);
223
+ im.$jazz.set("256x256", await createDummyFileStream(256, account));
224
224
  const { container } = renderWithAccount({
225
- imageId: im.id,
225
+ imageId: im.$jazz.id,
226
226
  alt: "test-progressive",
227
227
  width: 300,
228
228
  });
@@ -248,10 +248,10 @@ describe("Image", async () => {
248
248
  }, {
249
249
  owner: account,
250
250
  });
251
- im["1920x1080"] = original;
252
- im["256x256"] = await createDummyFileStream(256, account);
251
+ im.$jazz.set("1920x1080", original);
252
+ im.$jazz.set("256x256", await createDummyFileStream(256, account));
253
253
  const { container } = renderWithAccount({
254
- imageId: im.id,
254
+ imageId: im.$jazz.id,
255
255
  alt: "test-progressive",
256
256
  width: 1024,
257
257
  });
@@ -260,7 +260,7 @@ describe("Image", async () => {
260
260
  });
261
261
  expect(createObjectURLSpy).toHaveBeenCalledTimes(1);
262
262
  // Load higher resolution image
263
- im["1024x1024"] = await createDummyFileStream(1024, account);
263
+ im.$jazz.set("1024x1024", await createDummyFileStream(1024, account));
264
264
  await waitFor(() => {
265
265
  expect(container.querySelector("img").src).toBe("blob:test-1024");
266
266
  });
@@ -285,11 +285,11 @@ describe("Image", async () => {
285
285
  }, {
286
286
  owner: account,
287
287
  });
288
- im["100x100"] = original;
289
- im["256x256"] = await createDummyFileStream(256, account);
290
- im["1024x1024"] = await createDummyFileStream(1024, account);
288
+ im.$jazz.set("100x100", original);
289
+ im.$jazz.set("256x256", await createDummyFileStream(256, account));
290
+ im.$jazz.set("1024x1024", await createDummyFileStream(1024, account));
291
291
  const { container } = renderWithAccount({
292
- imageId: im.id,
292
+ imageId: im.$jazz.id,
293
293
  alt: "test-progressive",
294
294
  width: 256,
295
295
  });
@@ -315,10 +315,10 @@ describe("Image", async () => {
315
315
  }, {
316
316
  owner: account,
317
317
  });
318
- im["100x100"] = original;
319
- im["256x256"] = await createDummyFileStream(256, account);
318
+ im.$jazz.set("100x100", original);
319
+ im.$jazz.set("256x256", await createDummyFileStream(256, account));
320
320
  const { container } = renderWithAccount({
321
- imageId: im.id,
321
+ imageId: im.$jazz.id,
322
322
  alt: "test-progressive",
323
323
  width: 100,
324
324
  });
@@ -344,10 +344,10 @@ describe("Image", async () => {
344
344
  }, {
345
345
  owner: account,
346
346
  });
347
- im["256x256"] = original;
348
- im["1024x1024"] = await createDummyFileStream(1024, account);
347
+ im.$jazz.set("256x256", original);
348
+ im.$jazz.set("1024x1024", await createDummyFileStream(1024, account));
349
349
  const { container, rerender } = renderWithAccount({
350
- imageId: im.id,
350
+ imageId: im.$jazz.id,
351
351
  alt: "test-dynamic",
352
352
  width: 256,
353
353
  height: 256,
@@ -358,7 +358,7 @@ describe("Image", async () => {
358
358
  });
359
359
  expect(createObjectURLSpy).toHaveBeenCalledTimes(1);
360
360
  rerender({
361
- imageId: im.id,
361
+ imageId: im.$jazz.id,
362
362
  alt: "test-dynamic",
363
363
  width: 1024,
364
364
  height: 1024,
@@ -380,7 +380,7 @@ describe("Image", async () => {
380
380
  owner: account,
381
381
  });
382
382
  const { container } = renderWithAccount({
383
- imageId: im.id,
383
+ imageId: im.$jazz.id,
384
384
  alt: "test",
385
385
  loading: "lazy",
386
386
  });
@@ -405,7 +405,7 @@ describe("Image", async () => {
405
405
  owner: account,
406
406
  });
407
407
  const { container } = renderWithAccount({
408
- imageId: im.id,
408
+ imageId: im.$jazz.id,
409
409
  alt: "test",
410
410
  loading: "lazy",
411
411
  });
@@ -1,5 +1,5 @@
1
1
 
2
- > jazz-tools@0.17.14 build /home/runner/_work/jazz/jazz/packages/jazz-tools
2
+ > jazz-tools@0.18.1 build /home/runner/_work/jazz/jazz/packages/jazz-tools
3
3
  > tsup && pnpm types && pnpm build:svelte
4
4
 
5
5
  CLI Building entry: {"index":"src/index.ts","testing":"src/testing.ts"}
@@ -30,6 +30,10 @@
30
30
  CLI Using tsconfig: tsconfig.json
31
31
  CLI Building entry: {"index":"src/worker/index.ts"}
32
32
  CLI Using tsconfig: tsconfig.json
33
+ CLI Building entry: {"client":"src/better-auth/auth/client.ts","server":"src/better-auth/auth/server.ts","react":"src/better-auth/auth/react.tsx"}
34
+ CLI Using tsconfig: tsconfig.json
35
+ CLI tsup v8.5.0
36
+ CLI Using tsup config: /home/runner/_work/jazz/jazz/packages/jazz-tools/tsup.config.ts
33
37
  CLI tsup v8.5.0
34
38
  CLI Using tsup config: /home/runner/_work/jazz/jazz/packages/jazz-tools/tsup.config.ts
35
39
  CLI tsup v8.5.0
@@ -72,6 +76,9 @@
72
76
  CLI Target: es2021
73
77
  CLI Target: es2021
74
78
  CLI Target: es2021
79
+ CLI Target: es2021
80
+ CLI Cleaning output folder
81
+ ESM Build start
75
82
  CLI Cleaning output folder
76
83
  ESM Build start
77
84
  CLI Cleaning output folder
@@ -100,84 +107,91 @@
100
107
  ESM Build start
101
108
  CLI Cleaning output folder
102
109
  ESM Build start
103
- ESM dist/worker/index.js 2.31 KB
104
- ESM dist/worker/index.js.map 4.77 KB
105
- ESM ⚡️ Build success in 18ms
106
- ESM dist/tiptap/index.js 564.00 B
107
- ESM dist/tiptap/index.js.map 1.21 KB
108
- ESM ⚡️ Build success in 20ms
109
110
  ESM dist/react/ssr.js 688.00 B
110
111
  ESM dist/react/ssr.js.map 1.12 KB
111
- ESM ⚡️ Build success in 24ms
112
+ ESM ⚡️ Build success in 28ms
113
+ ESM dist/tiptap/index.js 564.00 B
114
+ ESM dist/tiptap/index.js.map 1.21 KB
115
+ ESM ⚡️ Build success in 27ms
116
+ ESM dist/worker/index.js 2.33 KB
117
+ ESM dist/worker/index.js.map 4.79 KB
118
+ ESM ⚡️ Build success in 25ms
112
119
  ESM dist/media/index.js 236.00 B
113
120
  ESM dist/media/index.browser.js 3.21 KB
114
121
  ESM dist/media/index.native.js 3.53 KB
115
- ESM dist/media/chunk-E5J3WLQW.js 6.34 KB
122
+ ESM dist/media/chunk-KR2V6X2N.js 6.42 KB
116
123
  ESM dist/media/index.js.map 71.00 B
117
- ESM dist/media/index.browser.js.map 6.02 KB
118
124
  ESM dist/media/index.native.js.map 6.52 KB
119
- ESM dist/media/chunk-E5J3WLQW.js.map 15.95 KB
125
+ ESM dist/media/index.browser.js.map 6.02 KB
126
+ ESM dist/media/chunk-KR2V6X2N.js.map 16.19 KB
127
+ ESM ⚡️ Build success in 34ms
128
+ ESM dist/better-auth/auth/server.js 5.94 KB
129
+ ESM dist/better-auth/auth/react.js 1.19 KB
130
+ ESM dist/better-auth/auth/client.js 4.36 KB
131
+ ESM dist/better-auth/auth/server.js.map 10.66 KB
132
+ ESM dist/better-auth/auth/react.js.map 3.37 KB
133
+ ESM dist/better-auth/auth/client.js.map 8.12 KB
120
134
  ESM ⚡️ Build success in 26ms
121
- ESM dist/browser/index.js 13.43 KB
122
- ESM dist/browser/index.js.map 28.65 KB
123
- ESM ⚡️ Build success in 29ms
135
+ ESM dist/browser/index.js 13.44 KB
136
+ ESM dist/browser/index.js.map 28.70 KB
137
+ ESM ⚡️ Build success in 40ms
124
138
  ESM dist/react-native/index.js 2.53 KB
125
139
  ESM dist/react-native/testing.js 120.00 B
126
140
  ESM dist/react-native/crypto.js 161.00 B
127
141
  ESM dist/react-native/index.js.map 5.68 KB
128
142
  ESM dist/react-native/testing.js.map 176.00 B
129
143
  ESM dist/react-native/crypto.js.map 197.00 B
130
- ESM ⚡️ Build success in 25ms
131
- ESM dist/react-core/index.js 8.41 KB
132
- ESM dist/react-core/testing.js 1.17 KB
133
- ESM dist/react-core/chunk-7DYMJ74I.js 279.00 B
134
- ESM dist/react-core/index.js.map 20.68 KB
135
- ESM dist/react-core/testing.js.map 1.82 KB
136
- ESM dist/react-core/chunk-7DYMJ74I.js.map 533.00 B
137
- ESM ⚡️ Build success in 26ms
144
+ ESM ⚡️ Build success in 46ms
138
145
  ESM dist/expo/index.js 4.68 KB
139
146
  ESM dist/expo/testing.js 112.00 B
140
147
  ESM dist/expo/crypto.js 153.00 B
141
148
  ESM dist/expo/index.js.map 10.23 KB
142
- ESM dist/expo/testing.js.map 168.00 B
143
149
  ESM dist/expo/crypto.js.map 189.00 B
144
- ESM ⚡️ Build success in 35ms
150
+ ESM dist/expo/testing.js.map 168.00 B
151
+ ESM ⚡️ Build success in 50ms
145
152
  ESM dist/react-native-core/index.js 17.90 KB
146
153
  ESM dist/react-native-core/testing.js 119.00 B
147
154
  ESM dist/react-native-core/crypto.js 2.10 KB
148
- ESM dist/react-native-core/index.js.map 36.65 KB
155
+ ESM dist/react-native-core/index.js.map 36.66 KB
149
156
  ESM dist/react-native-core/testing.js.map 175.00 B
150
157
  ESM dist/react-native-core/crypto.js.map 4.25 KB
151
- ESM ⚡️ Build success in 38ms
152
- ESM dist/react/index.js 24.62 KB
158
+ ESM ⚡️ Build success in 47ms
159
+ ESM dist/react/index.js 24.66 KB
153
160
  ESM dist/react/testing.js 122.00 B
161
+ ESM dist/react/index.js.map 53.09 KB
154
162
  ESM dist/react/testing.js.map 165.00 B
155
- ESM dist/react/index.js.map 52.88 KB
156
- ESM ⚡️ Build success in 40ms
157
- ESM dist/prosemirror/index.js 77.61 KB
158
- ESM dist/prosemirror/index.js.map 306.96 KB
159
- ESM ⚡️ Build success in 54ms
163
+ ESM ⚡️ Build success in 61ms
164
+ ESM dist/prosemirror/index.js 77.63 KB
165
+ ESM dist/prosemirror/index.js.map 306.98 KB
166
+ ESM ⚡️ Build success in 62ms
160
167
  ESM dist/inspector/index.js 61.52 KB
161
- ESM dist/inspector/index.js.map 109.97 KB
162
- ESM ⚡️ Build success in 63ms
163
- ESM dist/testing.js 7.10 KB
164
- ESM dist/index.js 26.03 KB
165
- ESM dist/chunk-LZOF6WP5.js 154.80 KB
166
- ESM dist/testing.js.map 14.00 KB
167
- ESM dist/index.js.map 52.73 KB
168
- ESM dist/chunk-LZOF6WP5.js.map 370.75 KB
169
- ESM ⚡️ Build success in 82ms
168
+ ESM dist/inspector/index.js.map 109.98 KB
169
+ ESM ⚡️ Build success in 76ms
170
+ ESM dist/index.js 26.13 KB
171
+ ESM dist/chunk-IERUTUXB.js 163.90 KB
172
+ ESM dist/testing.js 7.17 KB
173
+ ESM dist/testing.js.map 14.10 KB
174
+ ESM dist/index.js.map 52.92 KB
175
+ ESM dist/chunk-IERUTUXB.js.map 389.03 KB
176
+ ESM ⚡️ Build success in 108ms
177
+ ESM dist/react-core/testing.js 1.17 KB
178
+ ESM dist/react-core/chunk-7DYMJ74I.js 279.00 B
179
+ ESM dist/react-core/index.js 141.07 KB
180
+ ESM dist/react-core/testing.js.map 1.82 KB
181
+ ESM dist/react-core/chunk-7DYMJ74I.js.map 533.00 B
182
+ ESM dist/react-core/index.js.map 383.45 KB
183
+ ESM ⚡️ Build success in 107ms
170
184
  ESM dist/inspector/register-custom-element.js 218.00 B
171
185
  ESM dist/inspector/register-custom-element.js.map 314.00 B
172
- ESM dist/inspector/custom-element-ZSNTCECD.js 1.53 MB
173
- ESM dist/inspector/custom-element-ZSNTCECD.js.map 2.35 MB
174
- ESM ⚡️ Build success in 125ms
186
+ ESM dist/inspector/custom-element-WCY6D3QJ.js 1.53 MB
187
+ ESM dist/inspector/custom-element-WCY6D3QJ.js.map 2.35 MB
188
+ ESM ⚡️ Build success in 147ms
175
189
 
176
- > jazz-tools@0.17.14 types /home/runner/_work/jazz/jazz/packages/jazz-tools
190
+ > jazz-tools@0.18.1 types /home/runner/_work/jazz/jazz/packages/jazz-tools
177
191
  > tsc --outDir dist
178
192
 
179
193
 
180
- > jazz-tools@0.17.14 build:svelte /home/runner/_work/jazz/jazz/packages/jazz-tools
194
+ > jazz-tools@0.18.1 build:svelte /home/runner/_work/jazz/jazz/packages/jazz-tools
181
195
  > rm -rf dist/svelte && svelte-package -i src/svelte -o dist/svelte --tsconfig tsconfig.svelte.json
182
196
 
183
197
  src/svelte -> dist/svelte
package/CHANGELOG.md CHANGED
@@ -1,5 +1,46 @@
1
1
  # jazz-tools
2
2
 
3
+ ## 0.18.1
4
+
5
+ ### Patch Changes
6
+
7
+ - af5fbe7: New BetterAuth plugins to store Jazz's credentials
8
+ - 9837459: Add `CoMap.$jazz.has` and `Account.$jazz.has` method to check for property existance without loading referenced CoValues or checking permissions
9
+ - cojson@0.18.1
10
+ - cojson-storage-indexeddb@0.18.1
11
+ - cojson-transport-ws@0.18.1
12
+
13
+ ## 0.18.0
14
+
15
+ ### Minor Changes
16
+
17
+ - f263856: Add `$jazz` field to CoValues:
18
+ - This field contains Jazz methods that cluttered CoValues' API, as well as Jazz internal properties. This field is not enumerable, to allow CoValues to behave similarly to JSON objects.
19
+ - Added a `$jazz.set` method to update a CoValue's fields. When updating collaborative fields, you can pass in JSON objects instead of CoValues and Jazz will create
20
+ the CoValues automatically (similarly to CoValue `create` methods).
21
+ - All CoMap methods have been moved into `$jazz`, to allow defining any arbitrary key in the CoMap (except for `$jazz`) without conflicts.
22
+ - For CoMaps created with `co.map`, fields are now `readonly` to prevent setting properties directly. Use the `$jazz.set` method instead.
23
+ - CoMaps created with class schemas don't get type errors on direct property assignments, but they get a runtime errors prompting indicating to use `$jazz.set`.
24
+ - the `delete` operator can no longer be used to delete CoRecord properties. Use `$jazz.delete` instead.
25
+ - CoList's array-mutation methods have been moved into `$jazz`, in order to prevent using methods
26
+ - CoLists are now readonly arrays. Trying to use any mutation method yields a type error.
27
+ - `$jazz.set` can be used in place of direct element assignments.
28
+ - Added two new utility methods: `$jazz.remove` and `$jazz.retain`. They allow editing a CoList in-place with a simpler API than `$jazz.splice`.
29
+ - `sort`, `reverse`, `fill` and `copyWithin` have been deprecated, given that they could behave inconsistently with CoLists. `$jazz` replacements may be introduced
30
+ in future releases.
31
+ - `.$jazz.owner` now always returns a Group (instead of a Group or an Account). We'll be migrating away of having Accounts as CoValue owners in future releases.
32
+ - Removed `castAs`, since it's an inherently unsafe operation that bypassed typechecking and enabled using CoValues in unsupported ways.
33
+ - Removed the `id` and `_type` fields from `toJSON()`'s output in Account, CoMap, CoFeed & FileStream, to make CoValues behave more similarly to JSON objects.
34
+ - Removed the `root` and `profile` fields from Group.
35
+
36
+ ### Patch Changes
37
+
38
+ - Updated dependencies [b709494]
39
+ - Updated dependencies [f263856]
40
+ - cojson@0.18.0
41
+ - cojson-storage-indexeddb@0.18.0
42
+ - cojson-transport-ws@0.18.0
43
+
3
44
  ## 0.17.14
4
45
 
5
46
  ### Patch Changes
@@ -0,0 +1,29 @@
1
+ import type { AuthSecretStorage, Account, JazzContextType } from "jazz-tools";
2
+ import type { jazzPlugin } from "./server.js";
3
+ /**
4
+ * @example
5
+ * ```ts
6
+ * const auth = betterAuth({
7
+ * plugins: [jazzPluginClient()],
8
+ * });
9
+ * ```
10
+ */
11
+ export declare const jazzPluginClient: () => {
12
+ id: "jazz-plugin";
13
+ $InferServerPlugin: ReturnType<typeof jazzPlugin>;
14
+ getActions: ($fetch: import("@better-fetch/fetch").BetterFetch, $store: import("better-auth").Store) => {
15
+ jazz: {
16
+ setJazzContext: (context: JazzContextType<Account>) => void;
17
+ setAuthSecretStorage: (storage: AuthSecretStorage) => void;
18
+ };
19
+ };
20
+ fetchPlugins: {
21
+ id: string;
22
+ name: string;
23
+ hooks: {
24
+ onRequest<T extends Record<string, any>>(context: import("@better-fetch/fetch").RequestContext<T>): Promise<void>;
25
+ onSuccess(context: import("@better-fetch/fetch").SuccessContext<any>): Promise<void>;
26
+ };
27
+ }[];
28
+ };
29
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/better-auth/auth/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,iBAAiB,EAEjB,OAAO,EACP,eAAe,EAChB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB;;wBAmBC,UAAU,CAAC,OAAO,UAAU,CAAC;;;sCAIvB,eAAe,CAAC,OAAO,CAAC;4CAGlB,iBAAiB;;;;;;;;;;;CA6H1D,CAAC"}
@@ -0,0 +1,127 @@
1
+ // src/better-auth/auth/client.ts
2
+ var jazzPluginClient = () => {
3
+ let jazzContext;
4
+ let authSecretStorage;
5
+ let signOutUnsubscription;
6
+ const authenticateOnJazz = async (jazzAuth) => {
7
+ const parsedJazzAuth = {
8
+ ...jazzAuth,
9
+ secretSeed: jazzAuth.secretSeed ? Uint8Array.from(jazzAuth.secretSeed) : void 0
10
+ };
11
+ await jazzContext.authenticate(parsedJazzAuth);
12
+ await authSecretStorage.set(parsedJazzAuth);
13
+ };
14
+ return {
15
+ id: "jazz-plugin",
16
+ $InferServerPlugin: {},
17
+ getActions: ($fetch, $store) => {
18
+ return {
19
+ jazz: {
20
+ setJazzContext: (context) => {
21
+ jazzContext = context;
22
+ },
23
+ setAuthSecretStorage: (storage) => {
24
+ authSecretStorage = storage;
25
+ if (signOutUnsubscription) signOutUnsubscription();
26
+ signOutUnsubscription = authSecretStorage.onUpdate(
27
+ (isAuthenticated) => {
28
+ if (isAuthenticated === false) {
29
+ const session = $store.atoms.session?.get();
30
+ if (!session) return;
31
+ if (session.isPending || session.isRefetching) {
32
+ const unsub = $store.atoms.session?.listen((session2) => {
33
+ unsub?.();
34
+ if (session2.data !== null) {
35
+ $fetch("/sign-out", { method: "POST" });
36
+ }
37
+ });
38
+ } else {
39
+ $fetch("/sign-out", { method: "POST" });
40
+ }
41
+ }
42
+ }
43
+ );
44
+ }
45
+ }
46
+ };
47
+ },
48
+ fetchPlugins: [
49
+ {
50
+ id: "jazz-plugin",
51
+ name: "jazz-plugin",
52
+ hooks: {
53
+ async onRequest(context) {
54
+ if (context.url.toString().includes("/sign-up") || context.url.toString().includes("/sign-in/social")) {
55
+ const credentials = await authSecretStorage.get();
56
+ if (!credentials) {
57
+ throw new Error("Jazz credentials not found");
58
+ }
59
+ context.headers.set(
60
+ "x-jazz-auth",
61
+ JSON.stringify({
62
+ accountID: credentials.accountID,
63
+ secretSeed: credentials.secretSeed,
64
+ accountSecret: credentials.accountSecret
65
+ })
66
+ );
67
+ }
68
+ },
69
+ async onSuccess(context) {
70
+ if (context.request.url.toString().includes("/sign-up")) {
71
+ await authenticateOnJazz(context.data.jazzAuth);
72
+ return;
73
+ }
74
+ if (context.request.url.toString().includes("/sign-in/email")) {
75
+ await authenticateOnJazz(context.data.jazzAuth);
76
+ return;
77
+ }
78
+ if (context.request.url.toString().includes("/get-session")) {
79
+ if (context.data === null) {
80
+ if (authSecretStorage.isAuthenticated === true) {
81
+ console.warn(
82
+ "Jazz is authenticated, but the session is null"
83
+ );
84
+ }
85
+ return;
86
+ }
87
+ if (!context.data?.user) {
88
+ return;
89
+ }
90
+ if (authSecretStorage.isAuthenticated === false) {
91
+ console.info(
92
+ "Jazz is not authenticated, using Better Auth stored credentials"
93
+ );
94
+ await authenticateOnJazz(context.data.jazzAuth);
95
+ return;
96
+ }
97
+ const sessionAccountID = context.data.user.accountID;
98
+ const credentials = await authSecretStorage.get();
99
+ if (!credentials) {
100
+ throw new Error("Jazz credentials not found");
101
+ }
102
+ if (credentials.accountID !== sessionAccountID) {
103
+ console.info(
104
+ "Jazz credentials mismatch, using Better Auth stored credentials"
105
+ );
106
+ await authenticateOnJazz(context.data.jazzAuth);
107
+ }
108
+ return;
109
+ }
110
+ if (context.request.url.toString().includes("/sign-out")) {
111
+ await jazzContext.logOut();
112
+ return;
113
+ }
114
+ if (context.request.url.toString().includes("/delete-user")) {
115
+ await jazzContext.logOut();
116
+ return;
117
+ }
118
+ }
119
+ }
120
+ }
121
+ ]
122
+ };
123
+ };
124
+ export {
125
+ jazzPluginClient
126
+ };
127
+ //# sourceMappingURL=client.js.map