@fabriktor/fx 0.0.15 → 0.0.16
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { InUser, PLUsersForgotPassword, PLUsersSignInLink, UpsertResult } from "@fabriktor/schema";
|
|
2
2
|
import type { Op } from "@fabriktor/client";
|
|
3
3
|
import type { AuthEmailOptions, AuthOperator } from "../auth/auth.js";
|
|
4
|
-
import type { UsersFXOperator } from "../users/users.js";
|
|
4
|
+
import type { BootstrapOptions, UsersFXOperator } from "../users/users.js";
|
|
5
5
|
export type SignInMode = "email" | "username";
|
|
6
6
|
export type SignInOptions = {
|
|
7
7
|
mode: SignInMode;
|
|
@@ -16,6 +16,8 @@ export type SessionFXOptions = {
|
|
|
16
16
|
users: UsersFXOperator;
|
|
17
17
|
};
|
|
18
18
|
export interface SessionFXOperator {
|
|
19
|
+
startSignUp(opts: AuthEmailOptions): Promise<void>;
|
|
20
|
+
finishSignUp(opts: BootstrapOptions): Promise<Op<UpsertResult>>;
|
|
19
21
|
signUpAndBootstrap(opts: SignUpAndBootstrapOptions): Promise<Op<UpsertResult>>;
|
|
20
22
|
signIn(opts: SignInOptions): Promise<void>;
|
|
21
23
|
signInWithEmail(opts: AuthEmailOptions): Promise<void>;
|
|
@@ -28,6 +30,8 @@ export declare class SessionFX implements SessionFXOperator {
|
|
|
28
30
|
private auth;
|
|
29
31
|
private users;
|
|
30
32
|
constructor(opts: SessionFXOptions);
|
|
33
|
+
startSignUp(opts: AuthEmailOptions): Promise<void>;
|
|
34
|
+
finishSignUp(opts: BootstrapOptions): Promise<Op<UpsertResult>>;
|
|
31
35
|
signUpAndBootstrap(opts: SignUpAndBootstrapOptions): Promise<Op<UpsertResult>>;
|
|
32
36
|
signIn(opts: SignInOptions): Promise<void>;
|
|
33
37
|
signInWithEmail(opts: AuthEmailOptions): Promise<void>;
|
|
@@ -10,17 +10,28 @@ export class SessionFX {
|
|
|
10
10
|
this.auth = opts.auth;
|
|
11
11
|
this.users = opts.users;
|
|
12
12
|
}
|
|
13
|
-
async
|
|
13
|
+
async startSignUp(opts) {
|
|
14
14
|
await this.auth.signUp({
|
|
15
15
|
email: opts.email,
|
|
16
16
|
password: opts.password,
|
|
17
17
|
});
|
|
18
|
+
}
|
|
19
|
+
async finishSignUp(opts) {
|
|
18
20
|
const out = await this.users.bootstrap({
|
|
19
21
|
in: opts.in,
|
|
20
22
|
});
|
|
21
23
|
await this.users.sendEmailVerification();
|
|
22
24
|
return out;
|
|
23
25
|
}
|
|
26
|
+
async signUpAndBootstrap(opts) {
|
|
27
|
+
await this.startSignUp({
|
|
28
|
+
email: opts.email,
|
|
29
|
+
password: opts.password,
|
|
30
|
+
});
|
|
31
|
+
return await this.finishSignUp({
|
|
32
|
+
in: opts.in,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
24
35
|
async signIn(opts) {
|
|
25
36
|
const email = opts.mode === "email"
|
|
26
37
|
? opts.identifier
|