@voyantjs/auth-react 0.35.0 → 0.37.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.
- package/README.md +157 -1
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +6 -0
- package/dist/hooks/use-accept-invitation.d.ts +11 -0
- package/dist/hooks/use-accept-invitation.d.ts.map +1 -0
- package/dist/hooks/use-accept-invitation.js +35 -0
- package/dist/hooks/use-accept-invitation.test.d.ts +2 -0
- package/dist/hooks/use-accept-invitation.test.d.ts.map +1 -0
- package/dist/hooks/use-accept-invitation.test.js +36 -0
- package/dist/hooks/use-account-mutation.d.ts +41 -0
- package/dist/hooks/use-account-mutation.d.ts.map +1 -0
- package/dist/hooks/use-account-mutation.js +68 -0
- package/dist/hooks/use-account-mutation.test.d.ts +2 -0
- package/dist/hooks/use-account-mutation.test.d.ts.map +1 -0
- package/dist/hooks/use-account-mutation.test.js +67 -0
- package/dist/hooks/use-current-user.d.ts +2 -0
- package/dist/hooks/use-current-user.d.ts.map +1 -1
- package/dist/hooks/use-password-reset.d.ts +20 -0
- package/dist/hooks/use-password-reset.d.ts.map +1 -0
- package/dist/hooks/use-password-reset.js +83 -0
- package/dist/hooks/use-password-reset.test.d.ts +2 -0
- package/dist/hooks/use-password-reset.test.d.ts.map +1 -0
- package/dist/hooks/use-password-reset.test.js +55 -0
- package/dist/hooks/use-sign-in.d.ts +15 -0
- package/dist/hooks/use-sign-in.d.ts.map +1 -0
- package/dist/hooks/use-sign-in.js +80 -0
- package/dist/hooks/use-sign-in.test.d.ts +2 -0
- package/dist/hooks/use-sign-in.test.d.ts.map +1 -0
- package/dist/hooks/use-sign-in.test.js +49 -0
- package/dist/hooks/use-sign-up.d.ts +15 -0
- package/dist/hooks/use-sign-up.d.ts.map +1 -0
- package/dist/hooks/use-sign-up.js +80 -0
- package/dist/hooks/use-sign-up.test.d.ts +2 -0
- package/dist/hooks/use-sign-up.test.d.ts.map +1 -0
- package/dist/hooks/use-sign-up.test.js +49 -0
- package/dist/hooks/use-update-account-profile.d.ts +25 -0
- package/dist/hooks/use-update-account-profile.d.ts.map +1 -0
- package/dist/hooks/use-update-account-profile.js +37 -0
- package/dist/hooks/use-update-account-profile.test.d.ts +2 -0
- package/dist/hooks/use-update-account-profile.test.d.ts.map +1 -0
- package/dist/hooks/use-update-account-profile.test.js +62 -0
- package/dist/hooks/use-verify-email.d.ts +18 -0
- package/dist/hooks/use-verify-email.d.ts.map +1 -0
- package/dist/hooks/use-verify-email.js +86 -0
- package/dist/hooks/use-verify-email.test.d.ts +2 -0
- package/dist/hooks/use-verify-email.test.d.ts.map +1 -0
- package/dist/hooks/use-verify-email.test.js +50 -0
- package/dist/hooks/use-workspace-mutation.d.ts +2 -0
- package/dist/hooks/use-workspace-mutation.d.ts.map +1 -1
- package/dist/query-options.d.ts +8 -0
- package/dist/query-options.d.ts.map +1 -1
- package/dist/schemas.d.ts +2 -0
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +2 -0
- package/package.json +7 -7
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { verifyEmail } from "./use-verify-email.js";
|
|
3
|
+
function jsonResponse(body, init) {
|
|
4
|
+
return new Response(JSON.stringify(body), {
|
|
5
|
+
headers: { "Content-Type": "application/json" },
|
|
6
|
+
...init,
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
describe("verifyEmail", () => {
|
|
10
|
+
it("verifies token links through the mounted Better Auth endpoint", async () => {
|
|
11
|
+
const emailLinkFixture = "email-link-fixture";
|
|
12
|
+
const fetcher = vi
|
|
13
|
+
.fn()
|
|
14
|
+
.mockResolvedValueOnce(jsonResponse({ status: true }))
|
|
15
|
+
.mockResolvedValueOnce(jsonResponse({ userExists: true, authenticated: true }));
|
|
16
|
+
const result = await verifyEmail({ token: emailLinkFixture }, { baseUrl: "https://operator.example/api", fetcher });
|
|
17
|
+
expect(result).toEqual({ data: { status: true } });
|
|
18
|
+
expect(fetcher).toHaveBeenNthCalledWith(1, `https://operator.example/api/auth/verify-email?token=${emailLinkFixture}`, { method: "GET" });
|
|
19
|
+
expect(fetcher).toHaveBeenNthCalledWith(2, "https://operator.example/api/auth/status", {
|
|
20
|
+
method: "GET",
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
it("verifies email OTP codes through the Better Auth email OTP plugin", async () => {
|
|
24
|
+
const fetcher = vi
|
|
25
|
+
.fn()
|
|
26
|
+
.mockResolvedValueOnce(jsonResponse({ status: true }))
|
|
27
|
+
.mockResolvedValueOnce(jsonResponse({ userExists: true, authenticated: true }));
|
|
28
|
+
await verifyEmail({ email: "ana@example.com", otp: "123456" }, { baseUrl: "https://operator.example/api/", fetcher });
|
|
29
|
+
expect(fetcher).toHaveBeenNthCalledWith(1, "https://operator.example/api/auth/email-otp/verify-email", {
|
|
30
|
+
method: "POST",
|
|
31
|
+
headers: { "Content-Type": "application/json" },
|
|
32
|
+
body: JSON.stringify({
|
|
33
|
+
email: "ana@example.com",
|
|
34
|
+
otp: "123456",
|
|
35
|
+
}),
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
it("surfaces Better Auth verification errors", async () => {
|
|
39
|
+
const fetcher = vi.fn().mockResolvedValueOnce(jsonResponse({ error: { message: "Invalid verification code" } }, {
|
|
40
|
+
status: 400,
|
|
41
|
+
statusText: "Bad Request",
|
|
42
|
+
}));
|
|
43
|
+
await expect(verifyEmail({ email: "ana@example.com", otp: "000000" }, { baseUrl: "https://operator.example/api", fetcher })).rejects.toMatchObject({
|
|
44
|
+
name: "VoyantApiError",
|
|
45
|
+
message: "Invalid verification code",
|
|
46
|
+
status: 400,
|
|
47
|
+
});
|
|
48
|
+
expect(fetcher).toHaveBeenCalledTimes(1);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-workspace-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-workspace-mutation.ts"],"names":[],"mappings":"AASA,wBAAgB,oBAAoB
|
|
1
|
+
{"version":3,"file":"use-workspace-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-workspace-mutation.ts"],"names":[],"mappings":"AASA,wBAAgB,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8BnC"}
|
package/dist/query-options.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export declare function getCurrentUserQueryOptions(client: FetchWithValidationOp
|
|
|
5
5
|
email: string | null;
|
|
6
6
|
firstName: string | null;
|
|
7
7
|
lastName: string | null;
|
|
8
|
+
locale: string;
|
|
9
|
+
timezone: string | null;
|
|
8
10
|
isSuperAdmin: boolean;
|
|
9
11
|
isSupportUser: boolean;
|
|
10
12
|
createdAt: string;
|
|
@@ -15,6 +17,8 @@ export declare function getCurrentUserQueryOptions(client: FetchWithValidationOp
|
|
|
15
17
|
email: string | null;
|
|
16
18
|
firstName: string | null;
|
|
17
19
|
lastName: string | null;
|
|
20
|
+
locale: string;
|
|
21
|
+
timezone: string | null;
|
|
18
22
|
isSuperAdmin: boolean;
|
|
19
23
|
isSupportUser: boolean;
|
|
20
24
|
createdAt: string;
|
|
@@ -26,6 +30,8 @@ export declare function getCurrentUserQueryOptions(client: FetchWithValidationOp
|
|
|
26
30
|
email: string | null;
|
|
27
31
|
firstName: string | null;
|
|
28
32
|
lastName: string | null;
|
|
33
|
+
locale: string;
|
|
34
|
+
timezone: string | null;
|
|
29
35
|
isSuperAdmin: boolean;
|
|
30
36
|
isSupportUser: boolean;
|
|
31
37
|
createdAt: string;
|
|
@@ -39,6 +45,8 @@ export declare function getCurrentUserQueryOptions(client: FetchWithValidationOp
|
|
|
39
45
|
email: string | null;
|
|
40
46
|
firstName: string | null;
|
|
41
47
|
lastName: string | null;
|
|
48
|
+
locale: string;
|
|
49
|
+
timezone: string | null;
|
|
42
50
|
isSuperAdmin: boolean;
|
|
43
51
|
isSupportUser: boolean;
|
|
44
52
|
createdAt: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-options.d.ts","sourceRoot":"","sources":["../src/query-options.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,0BAA0B,EAAwC,MAAM,aAAa,CAAA;AACnG,OAAO,EAEL,KAAK,kCAAkC,EACvC,KAAK,8BAA8B,EACnC,KAAK,yBAAyB,EAC/B,MAAM,iBAAiB,CAAA;AAUxB,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,0BAA0B
|
|
1
|
+
{"version":3,"file":"query-options.d.ts","sourceRoot":"","sources":["../src/query-options.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,0BAA0B,EAAwC,MAAM,aAAa,CAAA;AACnG,OAAO,EAEL,KAAK,kCAAkC,EACvC,KAAK,8BAA8B,EACnC,KAAK,yBAAyB,EAC/B,MAAM,iBAAiB,CAAA;AAUxB,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK5E;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;EAK3E;AAED,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKjF;AAED,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,8BAA8B,EACvC,MAAM,EAAE,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWnC;AAED,wBAAgB,sCAAsC,CACpD,OAAO,EAAE,kCAAkC,EAC3C,MAAM,EAAE,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWnC;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,yBAAyB,EAClC,MAAM,EAAE,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWnC"}
|
package/dist/schemas.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export declare const currentUserSchema: z.ZodObject<{
|
|
|
5
5
|
phoneNumber: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
6
6
|
firstName: z.ZodNullable<z.ZodString>;
|
|
7
7
|
lastName: z.ZodNullable<z.ZodString>;
|
|
8
|
+
locale: z.ZodDefault<z.ZodString>;
|
|
9
|
+
timezone: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
8
10
|
isSuperAdmin: z.ZodBoolean;
|
|
9
11
|
isSupportUser: z.ZodBoolean;
|
|
10
12
|
createdAt: z.ZodString;
|
package/dist/schemas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,iBAAiB;;;;;;;;;;;;iBAc5B,CAAA;AACF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAE3D,eAAO,MAAM,gBAAgB;;;;iBAI3B,CAAA;AACF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAEzD,eAAO,MAAM,sBAAsB,6DAA6C,CAAA;AAChF,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eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAsB,CAAA;AACjD,MAAM,MAAM,QAAQ,GAAG,aAAa,CAAA;AAEpC,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAWrC,CAAA;AACL,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAA;AACnF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAgC,CAAA;AACrE,MAAM,MAAM,kBAAkB,GAAG,uBAAuB,CAAA;AAExD,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAKvC,CAAA;AACF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAA;AACjF,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAA+B,CAAA;AACnE,MAAM,MAAM,iBAAiB,GAAG,sBAAsB,CAAA;AAEtD,eAAO,MAAM,iCAAiC;;iBAE5C,CAAA;AACF,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAA;AAC3F,eAAO,MAAM,4BAA4B;;iBAAoC,CAAA;AAC7E,MAAM,MAAM,sBAAsB,GAAG,2BAA2B,CAAA"}
|
package/dist/schemas.js
CHANGED
|
@@ -8,6 +8,8 @@ export const currentUserSchema = z.object({
|
|
|
8
8
|
phoneNumber: z.string().nullable().optional(),
|
|
9
9
|
firstName: z.string().nullable(),
|
|
10
10
|
lastName: z.string().nullable(),
|
|
11
|
+
locale: z.string().default("en"),
|
|
12
|
+
timezone: z.string().nullable().default(null),
|
|
11
13
|
isSuperAdmin: z.boolean(),
|
|
12
14
|
isSupportUser: z.boolean(),
|
|
13
15
|
createdAt: z.string(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voyantjs/auth-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"react": "^19.0.0",
|
|
42
42
|
"react-dom": "^19.0.0",
|
|
43
43
|
"zod": "^4.0.0",
|
|
44
|
-
"@voyantjs/auth": "0.
|
|
45
|
-
"@voyantjs/types": "0.
|
|
44
|
+
"@voyantjs/auth": "0.37.1",
|
|
45
|
+
"@voyantjs/types": "0.37.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@tanstack/react-query": "^5.96.2",
|
|
@@ -53,13 +53,13 @@
|
|
|
53
53
|
"typescript": "^6.0.2",
|
|
54
54
|
"vitest": "^4.1.2",
|
|
55
55
|
"zod": "^4.3.6",
|
|
56
|
-
"@voyantjs/auth": "0.
|
|
57
|
-
"@voyantjs/react": "0.
|
|
58
|
-
"@voyantjs/types": "0.
|
|
56
|
+
"@voyantjs/auth": "0.37.1",
|
|
57
|
+
"@voyantjs/react": "0.37.1",
|
|
58
|
+
"@voyantjs/types": "0.37.1",
|
|
59
59
|
"@voyantjs/voyant-typescript-config": "0.1.0"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@voyantjs/react": "0.
|
|
62
|
+
"@voyantjs/react": "0.37.1"
|
|
63
63
|
},
|
|
64
64
|
"files": [
|
|
65
65
|
"dist"
|