@protobase/client 0.15.5 → 0.16.0

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/dist/auth.d.ts CHANGED
@@ -115,9 +115,9 @@ export declare const createAuthSession: (options?: AuthSessionOptions) => {
115
115
  sendSignInCode: (email: string) => Promise<void>;
116
116
  signInWithCode: (email: string, code: string) => Promise<SignInResult>;
117
117
  sendSignUpCode: (email: string) => Promise<void>;
118
+ verifySignUpCode: (email: string, code: string) => Promise<string>;
118
119
  signUp: (input: {
119
- email: string;
120
- code: string;
120
+ ticket: string;
121
121
  name: string;
122
122
  password?: string;
123
123
  }) => Promise<AuthUser>;
@@ -54,8 +54,23 @@ const signInFlows = (client, signedIn) => {
54
54
  if (error) throw authError(error, "Could not send the code");
55
55
  },
56
56
  /**
57
- * Makes the account with the emailed code, the person's name and a password (optional when the server offers emailed
58
- * sign-in codes), and signs in with it.
57
+ * Checks the code emailed to `email` on its own, before anything else is asked, and answers the ticket that makes the
58
+ * account with `signUp`. A ticket works once, for 30 minutes; a wrong code rejects with `SIGN_UP_CODE_INVALID`.
59
+ */
60
+ verifySignUpCode: async (email, code) => {
61
+ const { data, error } = await client.$fetch("/sign-up/verify-code", {
62
+ method: "POST",
63
+ body: {
64
+ email,
65
+ code
66
+ }
67
+ });
68
+ if (error || !data) throw authError(error, "Could not check the code");
69
+ return data.ticket;
70
+ },
71
+ /**
72
+ * Makes the account for the address whose code `verifySignUpCode` took, with the ticket it answered, the person's
73
+ * name and a password (optional when the server offers emailed sign-in codes), and signs in with it.
59
74
  */
60
75
  signUp: async (input) => {
61
76
  const { data, error } = await client.$fetch("/sign-up/create", {
@@ -32,6 +32,7 @@ const createStaticSession = (token, user = {
32
32
  user
33
33
  }),
34
34
  sendSignUpCode: unsupported("make an account"),
35
+ verifySignUpCode: unsupported("make an account"),
35
36
  signUp: unsupported("make an account"),
36
37
  signInWithPasskey: async () => user,
37
38
  sendTwoFactorCode: async () => void 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/client",
3
- "version": "0.15.5",
3
+ "version": "0.16.0",
4
4
  "description": "Typed fetch client for the Protobase REST API.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -30,8 +30,8 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@better-auth/passkey": "^1.7.7",
33
- "@protobase/layout": "0.15.5",
34
- "@protobase/schema": "0.15.5",
33
+ "@protobase/layout": "0.16.0",
34
+ "@protobase/schema": "0.16.0",
35
35
  "@simplewebauthn/browser": "^13.3.0",
36
36
  "better-auth": "^1.7.7"
37
37
  }