@protobase/client 0.14.6 → 0.15.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-types.d.ts +3 -1
- package/dist/auth.d.ts +7 -0
- package/dist/auth.js +1 -0
- package/dist/sign-in-flows.js +24 -0
- package/dist/static-session.js +2 -0
- package/package.json +3 -3
package/dist/auth-types.d.ts
CHANGED
|
@@ -24,7 +24,8 @@ export type PlatformSignIn = {
|
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
26
26
|
* `needsAdmin` while no user exists yet; `signInMethods` the ways to sign in the server's policy leaves on;
|
|
27
|
-
* `passwordReset` when the server can email reset links; `
|
|
27
|
+
* `passwordReset` when the server can email reset links; `signUp` when anyone can make their own account (see
|
|
28
|
+
* `sendSignUpCode`); `socialProviders` the ids of the sign-in providers, for example
|
|
28
29
|
* `github`; `platformSignIn` the one of them the platform adds; `staffSignIn` the operator provider's name when its staff
|
|
29
30
|
* can sign in as people; `organizations` when the app has them; `anonymous` when visitors may browse what the project's
|
|
30
31
|
* anonymous role reads without signing in.
|
|
@@ -33,6 +34,7 @@ export type SetupStatus = {
|
|
|
33
34
|
needsAdmin: boolean;
|
|
34
35
|
signInMethods: SignInMethod[];
|
|
35
36
|
passwordReset: boolean;
|
|
37
|
+
signUp?: boolean;
|
|
36
38
|
socialProviders: string[];
|
|
37
39
|
platformSignIn?: PlatformSignIn;
|
|
38
40
|
staffSignIn?: string;
|
package/dist/auth.d.ts
CHANGED
|
@@ -114,6 +114,13 @@ export declare const createAuthSession: (options?: AuthSessionOptions) => {
|
|
|
114
114
|
signIn: (email: string, password: string) => Promise<SignInResult>;
|
|
115
115
|
sendSignInCode: (email: string) => Promise<void>;
|
|
116
116
|
signInWithCode: (email: string, code: string) => Promise<SignInResult>;
|
|
117
|
+
sendSignUpCode: (email: string) => Promise<void>;
|
|
118
|
+
signUp: (input: {
|
|
119
|
+
email: string;
|
|
120
|
+
code: string;
|
|
121
|
+
name: string;
|
|
122
|
+
password?: string;
|
|
123
|
+
}) => Promise<AuthUser>;
|
|
117
124
|
signInWithPasskey: (domain?: string) => Promise<AuthUser>;
|
|
118
125
|
sendTwoFactorCode: () => Promise<void>;
|
|
119
126
|
verifyTwoFactor: ({ method, code, trustDevice }: {
|
package/dist/auth.js
CHANGED
|
@@ -73,6 +73,7 @@ const createAuthSession = (options = {}) => {
|
|
|
73
73
|
needsAdmin: Boolean(body.needsAdmin),
|
|
74
74
|
signInMethods: body.signInMethods ?? ["password"],
|
|
75
75
|
passwordReset: Boolean(body.passwordReset),
|
|
76
|
+
...body.signUp && { signUp: true },
|
|
76
77
|
socialProviders: body.socialProviders ?? [],
|
|
77
78
|
...body.platformSignIn && { platformSignIn: body.platformSignIn },
|
|
78
79
|
...body.staffSignIn && { staffSignIn: body.staffSignIn },
|
package/dist/sign-in-flows.js
CHANGED
|
@@ -43,6 +43,30 @@ const signInFlows = (client, signedIn) => {
|
|
|
43
43
|
return finish(data);
|
|
44
44
|
},
|
|
45
45
|
/**
|
|
46
|
+
* Open sign-up, when the status has `signUp`: emails a code for making an account with the address. The answer is
|
|
47
|
+
* the same when the address has an account already; that address is mailed a note instead of a code.
|
|
48
|
+
*/
|
|
49
|
+
sendSignUpCode: async (email) => {
|
|
50
|
+
const { error } = await client.$fetch("/sign-up/send-code", {
|
|
51
|
+
method: "POST",
|
|
52
|
+
body: { email }
|
|
53
|
+
});
|
|
54
|
+
if (error) throw authError(error, "Could not send the code");
|
|
55
|
+
},
|
|
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.
|
|
59
|
+
*/
|
|
60
|
+
signUp: async (input) => {
|
|
61
|
+
const { data, error } = await client.$fetch("/sign-up/create", {
|
|
62
|
+
method: "POST",
|
|
63
|
+
body: input
|
|
64
|
+
});
|
|
65
|
+
if (error || !data) throw authError(error, "Could not create your account");
|
|
66
|
+
await signedIn();
|
|
67
|
+
return data.user;
|
|
68
|
+
},
|
|
69
|
+
/**
|
|
46
70
|
* Asks the browser for one of the person's passkeys made for `domain`, one of the status's `passkeyDomains`, or for
|
|
47
71
|
* the app's passkey domain when left out. A browser asks for the passkeys of one domain at a time.
|
|
48
72
|
*/
|
package/dist/static-session.js
CHANGED
|
@@ -31,6 +31,8 @@ const createStaticSession = (token, user = {
|
|
|
31
31
|
kind: "signed-in",
|
|
32
32
|
user
|
|
33
33
|
}),
|
|
34
|
+
sendSignUpCode: unsupported("make an account"),
|
|
35
|
+
signUp: unsupported("make an account"),
|
|
34
36
|
signInWithPasskey: async () => user,
|
|
35
37
|
sendTwoFactorCode: async () => void 0,
|
|
36
38
|
verifyTwoFactor: async () => user,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.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.
|
|
34
|
-
"@protobase/schema": "0.
|
|
33
|
+
"@protobase/layout": "0.15.0",
|
|
34
|
+
"@protobase/schema": "0.15.0",
|
|
35
35
|
"@simplewebauthn/browser": "^13.3.0",
|
|
36
36
|
"better-auth": "^1.7.7"
|
|
37
37
|
}
|