jazz-tools 0.18.4 → 0.18.5
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 +37 -37
- package/CHANGELOG.md +12 -0
- package/dist/better-auth/auth/react.d.ts +5 -2
- package/dist/better-auth/auth/react.d.ts.map +1 -1
- package/dist/better-auth/auth/server.d.ts +21 -1
- package/dist/better-auth/auth/server.d.ts.map +1 -1
- package/dist/better-auth/auth/server.js +10 -5
- package/dist/better-auth/auth/server.js.map +1 -1
- package/dist/browser/createBrowserContext.d.ts.map +1 -1
- package/dist/browser/index.js +7 -0
- package/dist/browser/index.js.map +1 -1
- package/dist/{chunk-LHQQZH7I.js → chunk-3LE7N6TH.js} +1 -1
- package/dist/chunk-3LE7N6TH.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/react-core/index.js.map +1 -1
- package/dist/testing.js +1 -1
- package/dist/tools/implementation/anonymousJazzAgent.d.ts +1 -1
- package/dist/tools/implementation/anonymousJazzAgent.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/coExport.d.ts +2 -0
- package/dist/tools/implementation/zodSchema/coExport.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/CoFieldSchemaInit.d.ts +4 -0
- package/dist/tools/implementation/zodSchema/typeConverters/CoFieldSchemaInit.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/TypeOfZodSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/unionUtils.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/better-auth/auth/server.ts +38 -7
- package/src/better-auth/auth/tests/server.test.ts +95 -7
- package/src/browser/createBrowserContext.ts +8 -0
- package/src/tools/implementation/anonymousJazzAgent.ts +1 -1
- package/src/tools/implementation/zodSchema/coExport.ts +2 -0
- package/src/tools/implementation/zodSchema/typeConverters/CoFieldSchemaInit.ts +8 -1
- package/src/tools/implementation/zodSchema/typeConverters/TypeOfZodSchema.ts +0 -1
- package/src/tools/implementation/zodSchema/unionUtils.ts +0 -1
- package/src/tools/tests/coList.test-d.ts +17 -0
- package/src/tools/tests/coMap.record.test-d.ts +18 -0
- package/src/tools/tests/coMap.test-d.ts +15 -0
- package/dist/chunk-LHQQZH7I.js.map +0 -1
package/dist/testing.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"anonymousJazzAgent.d.ts","sourceRoot":"","sources":["../../../src/tools/implementation/anonymousJazzAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"anonymousJazzAgent.d.ts","sourceRoot":"","sources":["../../../src/tools/implementation/anonymousJazzAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,qBAAa,kBAAkB;IAEV,IAAI,EAAE,SAAS;IADlC,CAAC,OAAO,CAAC,cAAwB;gBACd,IAAI,EAAE,SAAS;CACnC"}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
export { Loaded as loaded } from "./zodSchema.js";
|
2
|
+
export { Loaded as output } from "./zodSchema.js";
|
2
3
|
export { CoMapSchema as Map } from "./schemaTypes/CoMapSchema.js";
|
3
4
|
export { CoRecordSchema as Record } from "./schemaTypes/CoRecordSchema.js";
|
4
5
|
export { CoListSchema as List } from "./schemaTypes/CoListSchema.js";
|
@@ -6,6 +7,7 @@ export { CoFeedSchema as Feed } from "./schemaTypes/CoFeedSchema.js";
|
|
6
7
|
export { PlainTextSchema as PlainText } from "./schemaTypes/PlainTextSchema.js";
|
7
8
|
export { RichTextSchema as RichText } from "./schemaTypes/RichTextSchema.js";
|
8
9
|
export { FileStreamSchema as FileStream } from "./schemaTypes/FileStreamSchema.js";
|
10
|
+
export { CoInput as input } from "./typeConverters/CoFieldSchemaInit.js";
|
9
11
|
export { AccountSchema as Account, CoProfileSchema as Profile, } from "./schemaTypes/AccountSchema.js";
|
10
12
|
export { CoOptionalSchema as Optional } from "./schemaTypes/CoOptionalSchema.js";
|
11
13
|
export { CoDiscriminatedUnionSchema as DiscriminatedUnion } from "./schemaTypes/CoDiscriminatedUnionSchema.js";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"coExport.d.ts","sourceRoot":"","sources":["../../../../src/tools/implementation/zodSchema/coExport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,WAAW,IAAI,GAAG,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,cAAc,IAAI,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,YAAY,IAAI,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,YAAY,IAAI,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,eAAe,IAAI,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAChF,OAAO,EAAE,cAAc,IAAI,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,IAAI,UAAU,EAAE,MAAM,mCAAmC,CAAC;AACnF,OAAO,EACL,aAAa,IAAI,OAAO,EACxB,eAAe,IAAI,OAAO,GAC3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,gBAAgB,IAAI,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,0BAA0B,IAAI,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAC/G,OAAO,EACL,YAAY,IAAI,GAAG,EACnB,eAAe,IAAI,MAAM,EACzB,aAAa,IAAI,IAAI,EACrB,aAAa,IAAI,IAAI,EACrB,kBAAkB,IAAI,SAAS,EAC/B,iBAAiB,IAAI,QAAQ,EAC7B,mBAAmB,IAAI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B,aAAa,IAAI,IAAI,EACrB,kBAAkB,IAAI,SAAS,EAC/B,iBAAiB,IAAI,QAAQ,EAC7B,mBAAmB,IAAI,UAAU,EACjC,cAAc,IAAI,KAAK,EACvB,gBAAgB,IAAI,OAAO,EAC3B,gBAAgB,IAAI,OAAO,EAC3B,iBAAiB,IAAI,QAAQ,EAC7B,2BAA2B,IAAI,kBAAkB,EACjD,qBAAqB,IAAI,KAAK,GAC/B,MAAM,YAAY,CAAC"}
|
@@ -21,4 +21,8 @@ export type CoMapSchemaInit<Shape extends z.core.$ZodLooseShape> = Simplify<{
|
|
21
21
|
}>;
|
22
22
|
export type CoListSchemaInit<T extends AnyZodOrCoValueSchema> = Simplify<ReadonlyArray<CoFieldSchemaInit<T>>>;
|
23
23
|
export type CoFeedSchemaInit<T extends AnyZodOrCoValueSchema> = Simplify<ReadonlyArray<CoFieldSchemaInit<T>>>;
|
24
|
+
/**
|
25
|
+
* The convenience type for extracting the init type of a CoValue schema.
|
26
|
+
*/
|
27
|
+
export type CoInput<S extends CoValueClass | AnyZodOrCoValueSchema> = S extends CoreCoValueSchema ? Exclude<CoFieldSchemaInit<S>, Loaded<S>> : CoFieldSchemaInit<S>;
|
24
28
|
//# sourceMappingURL=CoFieldSchemaInit.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CoFieldSchemaInit.d.ts","sourceRoot":"","sources":["../../../../../src/tools/implementation/zodSchema/typeConverters/CoFieldSchemaInit.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,
|
1
|
+
{"version":3,"file":"CoFieldSchemaInit.d.ts","sourceRoot":"","sources":["../../../../../src/tools/implementation/zodSchema/typeConverters/CoFieldSchemaInit.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,eA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ema/typeConverters/TypeOfZodSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;
|
1
|
+
{"version":3,"file":"TypeOfZodSchema.d.ts","sourceRoot":"","sources":["../../../../../src/tools/implementation/zodSchema/typeConverters/TypeOfZodSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAItC,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE;QACJ,KAAK,EAAE,UAAU,CAAC;KACnB,CAAC;CACH,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,QAAQ,IACnD,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAC9D,eAAe,CAAC,KAAK,CAAC,GAAG,SAAS,GAClC,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAChE,eAAe,CAAC,KAAK,CAAC,GAAG,IAAI,GAC7B,CAAC,SAAS,CAAC,CAAC,aAAa,GACvB,SAAS,GACT,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,CACtB,MAAM,OAAO,SAAS,SAAS,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CACjD,GACD,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAChC,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,GAKtC,AAJA;;;KAGG,CACH;IACE,CAAC,UAAU,GAAG,IAAI,MAAM,KAAK,IAAI,KAAK,CAAC,GAAG,CAAC,SAAS,gBAAgB,GAChE,KAAK,GACL,GAAG,GAAG,eA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C,GACtB,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,WAAW,CACxB,MAAM,OAAO,SAAS,CAAC,CAAC,IAAI,CAAC,QAAQ,CACtC,GACD,eAAe,CAAC,OAAO,CAAC,GACxB,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,CACtB,MAAM,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,QAAQ,CACpC,GACD,eAAe,CAAC,KAAK,CAAC,GACtB,KAAK,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"unionUtils.d.ts","sourceRoot":"","sources":["../../../../src/tools/implementation/zodSchema/unionUtils.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"unionUtils.d.ts","sourceRoot":"","sources":["../../../../src/tools/implementation/zodSchema/unionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EAErB,KAAK,EACL,8BAA8B,EAE9B,2BAA2B,EAE3B,wBAAwB,EACzB,MAAM,mBAAmB,CAAC;AAO3B,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,8BAA8B,CAAC,2BAA2B,CAAC,mCA+FpE;AAsBD,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,qBAAqB,WAMtE"}
|
package/package.json
CHANGED
@@ -167,7 +167,7 @@
|
|
167
167
|
},
|
168
168
|
"type": "module",
|
169
169
|
"license": "MIT",
|
170
|
-
"version": "0.18.
|
170
|
+
"version": "0.18.5",
|
171
171
|
"dependencies": {
|
172
172
|
"@manuscripts/prosemirror-recreate-steps": "^0.1.4",
|
173
173
|
"@scure/base": "1.2.1",
|
@@ -183,9 +183,9 @@
|
|
183
183
|
"prosemirror-state": "^1.4.3",
|
184
184
|
"prosemirror-transform": "^1.9.0",
|
185
185
|
"zod": "3.25.76",
|
186
|
-
"cojson": "0.18.
|
187
|
-
"cojson-storage-indexeddb": "0.18.
|
188
|
-
"cojson-transport-ws": "0.18.
|
186
|
+
"cojson": "0.18.5",
|
187
|
+
"cojson-storage-indexeddb": "0.18.5",
|
188
|
+
"cojson-transport-ws": "0.18.5"
|
189
189
|
},
|
190
190
|
"devDependencies": {
|
191
191
|
"@scure/bip39": "^1.3.0",
|
@@ -199,6 +199,7 @@
|
|
199
199
|
"@types/react-dom": "19.1.0",
|
200
200
|
"@vitest/browser": "^3.2.4",
|
201
201
|
"msw": "^2.10.3",
|
202
|
+
"oauth2-mock-server": "^8.1.0",
|
202
203
|
"playwright": "^1.50.1",
|
203
204
|
"queueueue": "^4.1.2",
|
204
205
|
"tsup": "8.5.0",
|
@@ -4,6 +4,29 @@ import { symmetricDecrypt, symmetricEncrypt } from "better-auth/crypto";
|
|
4
4
|
import { BetterAuthPlugin, createAuthMiddleware } from "better-auth/plugins";
|
5
5
|
import type { Account, AuthCredentials, ID } from "jazz-tools";
|
6
6
|
|
7
|
+
// Define a type to have user fields mapped in the better-auth instance
|
8
|
+
// It should be automatic, but it needs an hard reference to BetterAuthPlugin type
|
9
|
+
// in order to be exported as library.
|
10
|
+
type JazzPlugin = BetterAuthPlugin & {
|
11
|
+
schema: {
|
12
|
+
user: {
|
13
|
+
fields: {
|
14
|
+
accountID: {
|
15
|
+
type: "string";
|
16
|
+
required: false;
|
17
|
+
input: false;
|
18
|
+
};
|
19
|
+
encryptedCredentials: {
|
20
|
+
type: "string";
|
21
|
+
required: false;
|
22
|
+
input: false;
|
23
|
+
returned: false;
|
24
|
+
};
|
25
|
+
};
|
26
|
+
};
|
27
|
+
};
|
28
|
+
};
|
29
|
+
|
7
30
|
/**
|
8
31
|
* @returns The BetterAuth server plugin.
|
9
32
|
*
|
@@ -15,7 +38,7 @@ import type { Account, AuthCredentials, ID } from "jazz-tools";
|
|
15
38
|
* });
|
16
39
|
* ```
|
17
40
|
*/
|
18
|
-
export const jazzPlugin = ()
|
41
|
+
export const jazzPlugin: () => JazzPlugin = () => {
|
19
42
|
return {
|
20
43
|
id: "jazz-plugin",
|
21
44
|
schema: {
|
@@ -46,15 +69,15 @@ export const jazzPlugin = (): BetterAuthPlugin => {
|
|
46
69
|
// If the user is created without a jazzAuth, it will throw an error.
|
47
70
|
if (!contextContainsJazzAuth(context)) {
|
48
71
|
throw new APIError(422, {
|
49
|
-
message: "JazzAuth is required",
|
72
|
+
message: "JazzAuth is required on user creation",
|
50
73
|
});
|
51
74
|
}
|
52
75
|
// Decorate the user with the jazz's credentials.
|
53
76
|
return {
|
54
77
|
data: {
|
55
|
-
accountID: context
|
78
|
+
accountID: context.jazzAuth.accountID,
|
56
79
|
encryptedCredentials:
|
57
|
-
context
|
80
|
+
context.jazzAuth.encryptedCredentials,
|
58
81
|
},
|
59
82
|
};
|
60
83
|
},
|
@@ -131,7 +154,10 @@ export const jazzPlugin = (): BetterAuthPlugin => {
|
|
131
154
|
*/
|
132
155
|
{
|
133
156
|
matcher: (context) => {
|
134
|
-
return
|
157
|
+
return (
|
158
|
+
context.path.startsWith("/callback") ||
|
159
|
+
context.path.startsWith("/oauth2/callback")
|
160
|
+
);
|
135
161
|
},
|
136
162
|
handler: createAuthMiddleware(async (ctx) => {
|
137
163
|
const state = ctx.query?.state || ctx.body?.state;
|
@@ -158,7 +184,12 @@ export const jazzPlugin = (): BetterAuthPlugin => {
|
|
158
184
|
const parsed = JSON.parse(data.value);
|
159
185
|
|
160
186
|
if (parsed && "jazzAuth" in parsed) {
|
161
|
-
|
187
|
+
return {
|
188
|
+
context: {
|
189
|
+
...ctx,
|
190
|
+
jazzAuth: parsed.jazzAuth,
|
191
|
+
},
|
192
|
+
};
|
162
193
|
} else {
|
163
194
|
throw new APIError(404, {
|
164
195
|
message: "JazzAuth not found in verification value",
|
@@ -198,7 +229,7 @@ export const jazzPlugin = (): BetterAuthPlugin => {
|
|
198
229
|
},
|
199
230
|
],
|
200
231
|
},
|
201
|
-
};
|
232
|
+
} satisfies JazzPlugin;
|
202
233
|
};
|
203
234
|
|
204
235
|
function contextContainsJazzAuth(ctx: unknown): ctx is {
|
@@ -1,13 +1,54 @@
|
|
1
1
|
import { betterAuth } from "better-auth";
|
2
2
|
import { memoryAdapter } from "better-auth/adapters/memory";
|
3
|
-
import {
|
3
|
+
import {
|
4
|
+
afterAll,
|
5
|
+
beforeAll,
|
6
|
+
beforeEach,
|
7
|
+
describe,
|
8
|
+
expect,
|
9
|
+
it,
|
10
|
+
vi,
|
11
|
+
type Mock,
|
12
|
+
} from "vitest";
|
13
|
+
import { OAuth2Server } from "oauth2-mock-server";
|
4
14
|
import { jazzPlugin } from "../server.js";
|
15
|
+
import { genericOAuth } from "better-auth/plugins";
|
5
16
|
|
6
|
-
describe("Better Auth - Signup and Login Tests", () => {
|
7
|
-
|
17
|
+
describe("Better Auth - Signup and Login Tests", async () => {
|
18
|
+
const providerId = "test";
|
19
|
+
const clientId = "test-client-id";
|
20
|
+
const clientSecret = "test-client-secret";
|
21
|
+
const server = new OAuth2Server();
|
22
|
+
await server.start();
|
23
|
+
const oauthPort = Number(server.issuer.url?.split(":")[2]!);
|
24
|
+
|
25
|
+
let auth: ReturnType<
|
26
|
+
typeof betterAuth<{
|
27
|
+
plugins: ReturnType<typeof jazzPlugin | typeof genericOAuth>[];
|
28
|
+
}>
|
29
|
+
>;
|
8
30
|
let accountCreationSpy: Mock;
|
9
31
|
let verificationCreationSpy: Mock;
|
10
32
|
|
33
|
+
beforeAll(async () => {
|
34
|
+
await server.issuer.keys.generate("RS256");
|
35
|
+
|
36
|
+
server.service.on("beforeUserinfo", (userInfoResponse) => {
|
37
|
+
userInfoResponse.body = {
|
38
|
+
email: "oauth2@test.com",
|
39
|
+
name: "OAuth2 Test",
|
40
|
+
sub: "oauth2",
|
41
|
+
picture: "https://test.com/picture.png",
|
42
|
+
email_verified: true,
|
43
|
+
};
|
44
|
+
userInfoResponse.statusCode = 200;
|
45
|
+
});
|
46
|
+
});
|
47
|
+
|
48
|
+
afterAll(async () => {
|
49
|
+
await server.stop();
|
50
|
+
});
|
51
|
+
|
11
52
|
beforeEach(() => {
|
12
53
|
accountCreationSpy = vi.fn();
|
13
54
|
verificationCreationSpy = vi.fn();
|
@@ -20,7 +61,22 @@ describe("Better Auth - Signup and Login Tests", () => {
|
|
20
61
|
verification: [],
|
21
62
|
account: [],
|
22
63
|
}),
|
23
|
-
|
64
|
+
baseURL: "http://localhost:3000",
|
65
|
+
plugins: [
|
66
|
+
jazzPlugin(),
|
67
|
+
genericOAuth({
|
68
|
+
config: [
|
69
|
+
{
|
70
|
+
providerId,
|
71
|
+
discoveryUrl: `http://localhost:${oauthPort}/.well-known/openid-configuration`,
|
72
|
+
authorizationUrl: `http://localhost:${oauthPort}/authorize`,
|
73
|
+
clientId: clientId,
|
74
|
+
clientSecret: clientSecret,
|
75
|
+
pkce: true,
|
76
|
+
},
|
77
|
+
],
|
78
|
+
}),
|
79
|
+
],
|
24
80
|
emailAndPassword: {
|
25
81
|
enabled: true,
|
26
82
|
requireEmailVerification: false, // Disable for testing
|
@@ -219,8 +275,40 @@ describe("Better Auth - Signup and Login Tests", () => {
|
|
219
275
|
);
|
220
276
|
});
|
221
277
|
|
222
|
-
it
|
223
|
-
|
224
|
-
|
278
|
+
it("should create a new account with jazz auth when using social provider", async () => {
|
279
|
+
const response = await auth.api.signInSocial({
|
280
|
+
body: {
|
281
|
+
provider: providerId,
|
282
|
+
callbackURL: "http://localhost:3000/api/auth/sign-in/social/callback",
|
283
|
+
newUserCallbackURL:
|
284
|
+
"http://localhost:3000/api/auth/sign-in/social/callback",
|
285
|
+
},
|
286
|
+
headers: {
|
287
|
+
"x-jazz-auth": JSON.stringify({
|
288
|
+
accountID: "123",
|
289
|
+
secretSeed: [1, 2, 3],
|
290
|
+
accountSecret: "123",
|
291
|
+
}),
|
292
|
+
},
|
293
|
+
});
|
294
|
+
|
295
|
+
const oauthres = await fetch(response.url as string, {
|
296
|
+
redirect: "manual",
|
297
|
+
});
|
298
|
+
|
299
|
+
const resURL = new URL(oauthres.headers.get("Location") as string);
|
300
|
+
|
301
|
+
const callbackRes = await auth.handler(new Request(resURL));
|
302
|
+
|
303
|
+
expect(callbackRes.headers.getSetCookie()[0]).toMatch(
|
304
|
+
"better-auth.session_token=",
|
305
|
+
);
|
306
|
+
|
307
|
+
expect(accountCreationSpy).toHaveBeenCalledTimes(1);
|
308
|
+
expect(accountCreationSpy).toHaveBeenCalledWith(
|
309
|
+
expect.objectContaining({ accountID: "123" }),
|
310
|
+
expect.any(Object),
|
311
|
+
);
|
312
|
+
});
|
225
313
|
});
|
226
314
|
});
|
@@ -214,6 +214,14 @@ export function provideBrowserLockSession(
|
|
214
214
|
accountID: ID<Account> | AgentID,
|
215
215
|
crypto: CryptoProvider,
|
216
216
|
) {
|
217
|
+
if (typeof navigator === "undefined" || !navigator.locks?.request) {
|
218
|
+
// Fallback to random session ID for each tab session
|
219
|
+
return Promise.resolve({
|
220
|
+
sessionID: crypto.newRandomSessionID(accountID as RawAccountID | AgentID),
|
221
|
+
sessionDone: () => {},
|
222
|
+
});
|
223
|
+
}
|
224
|
+
|
217
225
|
let sessionDone!: () => void;
|
218
226
|
const donePromise = new Promise<void>((resolve) => {
|
219
227
|
sessionDone = resolve;
|
@@ -1,4 +1,5 @@
|
|
1
1
|
export { Loaded as loaded } from "./zodSchema.js";
|
2
|
+
export { Loaded as output } from "./zodSchema.js";
|
2
3
|
export { CoMapSchema as Map } from "./schemaTypes/CoMapSchema.js";
|
3
4
|
export { CoRecordSchema as Record } from "./schemaTypes/CoRecordSchema.js";
|
4
5
|
export { CoListSchema as List } from "./schemaTypes/CoListSchema.js";
|
@@ -6,6 +7,7 @@ export { CoFeedSchema as Feed } from "./schemaTypes/CoFeedSchema.js";
|
|
6
7
|
export { PlainTextSchema as PlainText } from "./schemaTypes/PlainTextSchema.js";
|
7
8
|
export { RichTextSchema as RichText } from "./schemaTypes/RichTextSchema.js";
|
8
9
|
export { FileStreamSchema as FileStream } from "./schemaTypes/FileStreamSchema.js";
|
10
|
+
export { CoInput as input } from "./typeConverters/CoFieldSchemaInit.js";
|
9
11
|
export {
|
10
12
|
AccountSchema as Account,
|
11
13
|
CoProfileSchema as Profile,
|
@@ -6,7 +6,6 @@ import {
|
|
6
6
|
CoreCoMapSchema,
|
7
7
|
CoreCoRecordSchema,
|
8
8
|
CorePlainTextSchema,
|
9
|
-
PartialOnUndefined,
|
10
9
|
Simplify,
|
11
10
|
} from "../../../internal.js";
|
12
11
|
import { CoreCoOptionalSchema } from "../schemaTypes/CoOptionalSchema.js";
|
@@ -76,3 +75,11 @@ export type CoListSchemaInit<T extends AnyZodOrCoValueSchema> = Simplify<
|
|
76
75
|
export type CoFeedSchemaInit<T extends AnyZodOrCoValueSchema> = Simplify<
|
77
76
|
ReadonlyArray<CoFieldSchemaInit<T>>
|
78
77
|
>;
|
78
|
+
|
79
|
+
/**
|
80
|
+
* The convenience type for extracting the init type of a CoValue schema.
|
81
|
+
*/
|
82
|
+
export type CoInput<S extends CoValueClass | AnyZodOrCoValueSchema> =
|
83
|
+
S extends CoreCoValueSchema
|
84
|
+
? Exclude<CoFieldSchemaInit<S>, Loaded<S>>
|
85
|
+
: CoFieldSchemaInit<S>;
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { JsonValue } from "cojson";
|
2
|
-
import { PartialOnUndefined } from "../../../internal.js";
|
3
2
|
import { z } from "../zodReExport.js";
|
4
3
|
|
5
4
|
// Copied from https://github.com/colinhacks/zod/blob/7e7e3461aceecf3633e158df50d6bc852e7cdf45/packages/zod/src/v4/core/schemas.ts#L1591,
|
@@ -19,6 +19,23 @@ describe("CoList", () => {
|
|
19
19
|
matches(list);
|
20
20
|
});
|
21
21
|
|
22
|
+
test("co.input returns the type for the init payload", () => {
|
23
|
+
const ListSchema = co.list(
|
24
|
+
co.map({
|
25
|
+
name: z.string(),
|
26
|
+
age: z.number(),
|
27
|
+
address: co.map({
|
28
|
+
street: z.string(),
|
29
|
+
city: z.string(),
|
30
|
+
}),
|
31
|
+
}),
|
32
|
+
);
|
33
|
+
|
34
|
+
const init: co.input<typeof ListSchema> = [];
|
35
|
+
|
36
|
+
ListSchema.create(init);
|
37
|
+
});
|
38
|
+
|
22
39
|
test("has the owner property", () => {
|
23
40
|
const StringList = co.list(z.string());
|
24
41
|
|
@@ -24,6 +24,24 @@ describe("CoMap.Record", () => {
|
|
24
24
|
matches(person);
|
25
25
|
});
|
26
26
|
|
27
|
+
test("co.input returns the type for the init payload", () => {
|
28
|
+
const Person = co.record(
|
29
|
+
z.string(),
|
30
|
+
co.map({
|
31
|
+
name: z.string(),
|
32
|
+
age: z.number(),
|
33
|
+
address: co.map({
|
34
|
+
street: z.string(),
|
35
|
+
city: z.string(),
|
36
|
+
}),
|
37
|
+
}),
|
38
|
+
);
|
39
|
+
|
40
|
+
const init: co.input<typeof Person> = {};
|
41
|
+
|
42
|
+
Person.create(init);
|
43
|
+
});
|
44
|
+
|
27
45
|
test("has the owner property", () => {
|
28
46
|
const Person = co.record(z.string(), z.string());
|
29
47
|
|
@@ -45,6 +45,21 @@ describe("CoMap", async () => {
|
|
45
45
|
matches(john);
|
46
46
|
});
|
47
47
|
|
48
|
+
test("co.input returns the type for the init payload", () => {
|
49
|
+
const Person = co.map({
|
50
|
+
name: z.string(),
|
51
|
+
age: z.number(),
|
52
|
+
address: co.map({
|
53
|
+
street: z.string(),
|
54
|
+
city: z.string(),
|
55
|
+
}),
|
56
|
+
});
|
57
|
+
|
58
|
+
const init = {} as co.input<typeof Person>;
|
59
|
+
|
60
|
+
Person.create(init);
|
61
|
+
});
|
62
|
+
|
48
63
|
test("has the owner property", () => {
|
49
64
|
const Person = co.map({
|
50
65
|
name: z.string(),
|