jazz-tools 0.18.7 → 0.18.8
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/.turbo/turbo-build.log +46 -46
- package/CHANGELOG.md +11 -0
- package/dist/better-auth/auth/server.js +1 -1
- package/dist/better-auth/auth/server.js.map +1 -1
- package/dist/{chunk-CFAY3FMQ.js → chunk-QF3R3C4N.js} +6 -2
- package/dist/{chunk-CFAY3FMQ.js.map → chunk-QF3R3C4N.js.map} +1 -1
- package/dist/index.js +1 -1
- package/dist/react-core/index.js +5 -1
- package/dist/react-core/index.js.map +1 -1
- package/dist/testing.js +1 -1
- package/dist/tools/coValues/CoFieldInit.d.ts +5 -5
- package/dist/tools/coValues/CoFieldInit.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +5 -3
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/better-auth/auth/server.ts +1 -1
- package/src/tools/coValues/CoFieldInit.ts +5 -5
- package/src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts +22 -8
- package/src/tools/tests/coMap.test.ts +37 -0
package/.turbo/turbo-build.log
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
> jazz-tools@0.18.
|
2
|
+
> jazz-tools@0.18.8 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"}
|
@@ -109,23 +109,20 @@
|
|
109
109
|
[34mESM[39m Build start
|
110
110
|
[32mESM[39m [1mdist/react/ssr.js [22m[32m688.00 B[39m
|
111
111
|
[32mESM[39m [1mdist/react/ssr.js.map [22m[32m1.12 KB[39m
|
112
|
-
[32mESM[39m ⚡️ Build success in
|
113
|
-
[32mESM[39m [1mdist/
|
114
|
-
[32mESM[39m [1mdist/
|
112
|
+
[32mESM[39m ⚡️ Build success in 17ms
|
113
|
+
[32mESM[39m [1mdist/react-native/testing.js [22m[32m120.00 B[39m
|
114
|
+
[32mESM[39m [1mdist/react-native/index.js [22m[32m2.53 KB[39m
|
115
|
+
[32mESM[39m [1mdist/react-native/crypto.js [22m[32m161.00 B[39m
|
116
|
+
[32mESM[39m [1mdist/react-native/testing.js.map [22m[32m176.00 B[39m
|
117
|
+
[32mESM[39m [1mdist/react-native/index.js.map [22m[32m5.68 KB[39m
|
118
|
+
[32mESM[39m [1mdist/react-native/crypto.js.map [22m[32m197.00 B[39m
|
115
119
|
[32mESM[39m ⚡️ Build success in 18ms
|
116
120
|
[32mESM[39m [1mdist/tiptap/index.js [22m[32m564.00 B[39m
|
117
121
|
[32mESM[39m [1mdist/tiptap/index.js.map [22m[32m1.21 KB[39m
|
118
|
-
[32mESM[39m ⚡️ Build success in
|
119
|
-
[32mESM[39m [1mdist/
|
120
|
-
[32mESM[39m [1mdist/
|
121
|
-
[32mESM[39m
|
122
|
-
[32mESM[39m [1mdist/better-auth/auth/client.js.map [22m[32m8.24 KB[39m
|
123
|
-
[32mESM[39m [1mdist/better-auth/auth/react.js.map [22m[32m2.04 KB[39m
|
124
|
-
[32mESM[39m [1mdist/better-auth/auth/server.js.map [22m[32m15.28 KB[39m
|
125
|
-
[32mESM[39m ⚡️ Build success in 23ms
|
126
|
-
[32mESM[39m [1mdist/browser/index.js [22m[32m13.64 KB[39m
|
127
|
-
[32mESM[39m [1mdist/browser/index.js.map [22m[32m29.14 KB[39m
|
128
|
-
[32mESM[39m ⚡️ Build success in 37ms
|
122
|
+
[32mESM[39m ⚡️ Build success in 22ms
|
123
|
+
[32mESM[39m [1mdist/worker/index.js [22m[32m2.47 KB[39m
|
124
|
+
[32mESM[39m [1mdist/worker/index.js.map [22m[32m5.26 KB[39m
|
125
|
+
[32mESM[39m ⚡️ Build success in 21ms
|
129
126
|
[32mESM[39m [1mdist/media/index.js [22m[32m236.00 B[39m
|
130
127
|
[32mESM[39m [1mdist/media/index.browser.js [22m[32m2.79 KB[39m
|
131
128
|
[32mESM[39m [1mdist/media/index.native.js [22m[32m2.90 KB[39m
|
@@ -136,64 +133,67 @@
|
|
136
133
|
[32mESM[39m [1mdist/media/index.native.js.map [22m[32m6.09 KB[39m
|
137
134
|
[32mESM[39m [1mdist/media/index.server.js.map [22m[32m6.37 KB[39m
|
138
135
|
[32mESM[39m [1mdist/media/chunk-W3S526L3.js.map [22m[32m16.57 KB[39m
|
139
|
-
[32mESM[39m ⚡️ Build success in
|
136
|
+
[32mESM[39m ⚡️ Build success in 32ms
|
137
|
+
[32mESM[39m [1mdist/better-auth/auth/client.js [22m[32m4.44 KB[39m
|
138
|
+
[32mESM[39m [1mdist/better-auth/auth/server.js [22m[32m8.36 KB[39m
|
139
|
+
[32mESM[39m [1mdist/better-auth/auth/react.js [22m[32m799.00 B[39m
|
140
|
+
[32mESM[39m [1mdist/better-auth/auth/client.js.map [22m[32m8.24 KB[39m
|
141
|
+
[32mESM[39m [1mdist/better-auth/auth/react.js.map [22m[32m2.04 KB[39m
|
142
|
+
[32mESM[39m [1mdist/better-auth/auth/server.js.map [22m[32m15.29 KB[39m
|
143
|
+
[32mESM[39m ⚡️ Build success in 29ms
|
144
|
+
[32mESM[39m [1mdist/browser/index.js [22m[32m13.64 KB[39m
|
145
|
+
[32mESM[39m [1mdist/browser/index.js.map [22m[32m29.14 KB[39m
|
146
|
+
[32mESM[39m ⚡️ Build success in 38ms
|
140
147
|
[32mESM[39m [1mdist/expo/index.js [22m[32m4.68 KB[39m
|
141
148
|
[32mESM[39m [1mdist/expo/testing.js [22m[32m112.00 B[39m
|
142
149
|
[32mESM[39m [1mdist/expo/crypto.js [22m[32m153.00 B[39m
|
143
150
|
[32mESM[39m [1mdist/expo/index.js.map [22m[32m10.23 KB[39m
|
144
151
|
[32mESM[39m [1mdist/expo/testing.js.map [22m[32m168.00 B[39m
|
145
152
|
[32mESM[39m [1mdist/expo/crypto.js.map [22m[32m189.00 B[39m
|
146
|
-
[32mESM[39m ⚡️ Build success in
|
147
|
-
[32mESM[39m [1mdist/react-native/index.js [22m[32m2.53 KB[39m
|
148
|
-
[32mESM[39m [1mdist/react-native/testing.js [22m[32m120.00 B[39m
|
149
|
-
[32mESM[39m [1mdist/react-native/crypto.js [22m[32m161.00 B[39m
|
150
|
-
[32mESM[39m [1mdist/react-native/testing.js.map [22m[32m176.00 B[39m
|
151
|
-
[32mESM[39m [1mdist/react-native/index.js.map [22m[32m5.68 KB[39m
|
152
|
-
[32mESM[39m [1mdist/react-native/crypto.js.map [22m[32m197.00 B[39m
|
153
|
-
[32mESM[39m ⚡️ Build success in 44ms
|
154
|
-
[32mESM[39m [1mdist/prosemirror/index.js [22m[32m77.63 KB[39m
|
155
|
-
[32mESM[39m [1mdist/prosemirror/index.js.map [22m[32m306.98 KB[39m
|
156
|
-
[32mESM[39m ⚡️ Build success in 50ms
|
157
|
-
[32mESM[39m [1mdist/react/testing.js [22m[32m122.00 B[39m
|
158
|
-
[32mESM[39m [1mdist/react/index.js [22m[32m24.71 KB[39m
|
159
|
-
[32mESM[39m [1mdist/react/testing.js.map [22m[32m165.00 B[39m
|
160
|
-
[32mESM[39m [1mdist/react/index.js.map [22m[32m53.50 KB[39m
|
161
|
-
[32mESM[39m ⚡️ Build success in 51ms
|
153
|
+
[32mESM[39m ⚡️ Build success in 41ms
|
162
154
|
[32mESM[39m [1mdist/react-native-core/index.js [22m[32m17.95 KB[39m
|
163
|
-
[32mESM[39m [1mdist/react-native-core/crypto.js [22m[32m2.10 KB[39m
|
164
155
|
[32mESM[39m [1mdist/react-native-core/testing.js [22m[32m119.00 B[39m
|
165
|
-
[32mESM[39m [1mdist/react-native-core/
|
166
|
-
[32mESM[39m [1mdist/react-native-core/crypto.js.map [22m[32m4.25 KB[39m
|
156
|
+
[32mESM[39m [1mdist/react-native-core/crypto.js [22m[32m2.10 KB[39m
|
167
157
|
[32mESM[39m [1mdist/react-native-core/testing.js.map [22m[32m175.00 B[39m
|
168
|
-
[32mESM[39m
|
158
|
+
[32mESM[39m [1mdist/react-native-core/crypto.js.map [22m[32m4.25 KB[39m
|
159
|
+
[32mESM[39m [1mdist/react-native-core/index.js.map [22m[32m36.70 KB[39m
|
160
|
+
[32mESM[39m ⚡️ Build success in 41ms
|
161
|
+
[32mESM[39m [1mdist/react/index.js [22m[32m24.71 KB[39m
|
162
|
+
[32mESM[39m [1mdist/react/testing.js [22m[32m122.00 B[39m
|
163
|
+
[32mESM[39m [1mdist/react/index.js.map [22m[32m53.50 KB[39m
|
164
|
+
[32mESM[39m [1mdist/react/testing.js.map [22m[32m165.00 B[39m
|
165
|
+
[32mESM[39m ⚡️ Build success in 42ms
|
166
|
+
[32mESM[39m [1mdist/prosemirror/index.js [22m[32m77.63 KB[39m
|
167
|
+
[32mESM[39m [1mdist/prosemirror/index.js.map [22m[32m306.98 KB[39m
|
168
|
+
[32mESM[39m ⚡️ Build success in 44ms
|
169
169
|
[32mESM[39m [1mdist/inspector/index.js [22m[32m69.71 KB[39m
|
170
170
|
[32mESM[39m [1mdist/inspector/index.js.map [22m[32m121.38 KB[39m
|
171
|
-
[32mESM[39m ⚡️ Build success in
|
171
|
+
[32mESM[39m ⚡️ Build success in 57ms
|
172
172
|
[32mESM[39m [1mdist/testing.js [22m[32m7.17 KB[39m
|
173
173
|
[32mESM[39m [1mdist/index.js [22m[32m26.13 KB[39m
|
174
|
-
[32mESM[39m [1mdist/chunk-
|
174
|
+
[32mESM[39m [1mdist/chunk-QF3R3C4N.js [22m[32m168.58 KB[39m
|
175
175
|
[32mESM[39m [1mdist/testing.js.map [22m[32m14.10 KB[39m
|
176
176
|
[32mESM[39m [1mdist/index.js.map [22m[32m52.92 KB[39m
|
177
|
-
[32mESM[39m [1mdist/chunk-
|
178
|
-
[32mESM[39m ⚡️ Build success in
|
177
|
+
[32mESM[39m [1mdist/chunk-QF3R3C4N.js.map [22m[32m400.77 KB[39m
|
178
|
+
[32mESM[39m ⚡️ Build success in 81ms
|
179
|
+
[32mESM[39m [1mdist/react-core/index.js [22m[32m145.59 KB[39m
|
179
180
|
[32mESM[39m [1mdist/react-core/testing.js [22m[32m1.17 KB[39m
|
180
181
|
[32mESM[39m [1mdist/react-core/chunk-7DYMJ74I.js [22m[32m279.00 B[39m
|
181
|
-
[32mESM[39m [1mdist/react-core/index.js
|
182
|
+
[32mESM[39m [1mdist/react-core/index.js.map [22m[32m399.79 KB[39m
|
182
183
|
[32mESM[39m [1mdist/react-core/testing.js.map [22m[32m1.82 KB[39m
|
183
184
|
[32mESM[39m [1mdist/react-core/chunk-7DYMJ74I.js.map [22m[32m533.00 B[39m
|
184
|
-
[32mESM[39m
|
185
|
-
[32mESM[39m ⚡️ Build success in 106ms
|
185
|
+
[32mESM[39m ⚡️ Build success in 78ms
|
186
186
|
[32mESM[39m [1mdist/inspector/register-custom-element.js [22m[32m218.00 B[39m
|
187
187
|
[32mESM[39m [1mdist/inspector/register-custom-element.js.map [22m[32m314.00 B[39m
|
188
188
|
[32mESM[39m [1mdist/inspector/custom-element-G6SPZEBR.js [22m[32m1.54 MB[39m
|
189
189
|
[32mESM[39m [1mdist/inspector/custom-element-G6SPZEBR.js.map [22m[32m2.36 MB[39m
|
190
|
-
[32mESM[39m ⚡️ Build success in
|
190
|
+
[32mESM[39m ⚡️ Build success in 114ms
|
191
191
|
|
192
|
-
> jazz-tools@0.18.
|
192
|
+
> jazz-tools@0.18.8 types /home/runner/_work/jazz/jazz/packages/jazz-tools
|
193
193
|
> tsc --outDir dist
|
194
194
|
|
195
195
|
|
196
|
-
> jazz-tools@0.18.
|
196
|
+
> jazz-tools@0.18.8 build:svelte /home/runner/_work/jazz/jazz/packages/jazz-tools
|
197
197
|
> rm -rf dist/svelte && svelte-package -i src/svelte -o dist/svelte --tsconfig tsconfig.svelte.json
|
198
198
|
|
199
199
|
src/svelte -> dist/svelte
|
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# jazz-tools
|
2
2
|
|
3
|
+
## 0.18.8
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 700fe46: fix: in 32d1444 was used the wrong Better Auth internal function to delete old verification codes
|
8
|
+
- aba0d55: Support the selection of a subset of keys to make optional in `co.map().partial()`
|
9
|
+
- Updated dependencies [9a4caf2]
|
10
|
+
- cojson@0.18.8
|
11
|
+
- cojson-storage-indexeddb@0.18.8
|
12
|
+
- cojson-transport-ws@0.18.8
|
13
|
+
|
3
14
|
## 0.18.7
|
4
15
|
|
5
16
|
### Patch Changes
|
@@ -48,7 +48,7 @@ var jazzPlugin = () => {
|
|
48
48
|
after: async (verification, context) => {
|
49
49
|
if (contextContainsJazzAuth(context) && verification.identifier.startsWith("sign-in-otp-")) {
|
50
50
|
const identifier = `jazz-auth-${verification.identifier}`;
|
51
|
-
await context.context.internalAdapter.
|
51
|
+
await context.context.internalAdapter.deleteVerificationByIdentifier(
|
52
52
|
identifier
|
53
53
|
);
|
54
54
|
await context.context.internalAdapter.createVerificationValue(
|
@@ -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.deleteVerificationValue(\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,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/B,aAAa,WAAW,WAAW,cAAc,GACjD;AACA,0BAAM,aAAa,aAAa,aAAa,UAAU;AACvD,0BAAM,QAAQ,QAAQ,gBAAgB;AAAA,sBACpC;AAAA,oBACF;AACA,0BAAM,QAAQ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b,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 { 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;A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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":[]}
|
@@ -4694,9 +4694,13 @@ function enrichCoMapSchema(schema, coValueClass) {
|
|
4694
4694
|
}
|
4695
4695
|
return coMapDefiner(pickedShape);
|
4696
4696
|
},
|
4697
|
-
partial: () => {
|
4697
|
+
partial: (keys) => {
|
4698
4698
|
const partialShape = {};
|
4699
4699
|
for (const [key, value] of Object.entries(coValueSchema.shape)) {
|
4700
|
+
if (keys && !keys[key]) {
|
4701
|
+
partialShape[key] = value;
|
4702
|
+
continue;
|
4703
|
+
}
|
4700
4704
|
if (isAnyCoValueSchema2(value)) {
|
4701
4705
|
partialShape[key] = coOptionalDefiner(value);
|
4702
4706
|
} else {
|
@@ -5907,4 +5911,4 @@ export {
|
|
5907
5911
|
JazzContextManager
|
5908
5912
|
};
|
5909
5913
|
/* istanbul ignore file -- @preserve */
|
5910
|
-
//# sourceMappingURL=chunk-
|
5914
|
+
//# sourceMappingURL=chunk-QF3R3C4N.js.map
|